From b12f5de43015c87278bd4085733a49304f1881b5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 15:29:23 +0800 Subject: [PATCH 01/36] chore: standardize repository config --- .dumirc.ts | 5 + .github/FUNDING.yml | 17 +- .github/dependabot.yml | 26 +- .github/workflows/codeql.yml | 22 +- .github/workflows/main.yml | 6 - .github/workflows/react-component-ci.yml | 8 + .github/workflows/react-doctor.yml | 27 + .github/workflows/surge-preview.yml | 39 ++ .gitignore | 3 +- README.md | 198 +++++--- docs/examples/controlled.tsx | 2 +- docs/examples/jumper.tsx | 2 +- docs/examples/jumperWithGoButton.tsx | 2 +- docs/examples/locale.tsx | 2 +- docs/examples/sizer.tsx | 2 +- docs/examples/utils/commonUtil.tsx | 4 +- docs/index.md | 4 +- package.json | 13 +- tests/__snapshots__/demo.test.tsx.snap | 590 +++++++--------------- tests/__snapshots__/options.test.tsx.snap | 49 +- tests/commonUtil.tsx | 4 +- tests/setupAfterEnv.ts | 21 + tests/simple.test.tsx | 2 +- tests/sizer.test.tsx | 8 +- tests/two-pagination.tsx | 2 +- tsconfig.json | 3 +- vercel.json | 5 +- 27 files changed, 509 insertions(+), 557 deletions(-) delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/react-component-ci.yml create mode 100644 .github/workflows/react-doctor.yml create mode 100644 .github/workflows/surge-preview.yml diff --git a/.dumirc.ts b/.dumirc.ts index d017cabd..7ac2fe6d 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -1,5 +1,8 @@ import { defineConfig } from 'dumi'; +const basePath = process.env.GH_PAGES ? '/pagination/' : '/'; +const publicPath = process.env.GH_PAGES ? '/pagination/' : '/'; + export default defineConfig({ favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], themeConfig: { @@ -7,4 +10,6 @@ export default defineConfig({ logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', }, outputPath: 'docs-dist', + base: basePath, + publicPath, }); diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 33b1999c..758659af 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,15 +1,2 @@ -# These are supported funding model platforms - -github: ant-design # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: # Replace with a single Patreon username -open_collective: ant-design # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry -polar: # Replace with a single Polar username -buy_me_a_coffee: # Replace with a single Buy Me a Coffee username -thanks_dev: # Replace with a single thanks.dev username -custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] +github: ant-design +open_collective: ant-design diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b4cee470..165cd4ec 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,15 +1,15 @@ version: 2 updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - time: "21:00" - open-pull-requests-limit: 10 - ignore: - - dependency-name: react-dom - versions: - - 17.0.1 - - dependency-name: less - versions: - - 4.1.0 + - package-ecosystem: npm + directory: '/' + schedule: + interval: daily + time: '21:00' + open-pull-requests-limit: 10 + ignore: + - dependency-name: react-dom + versions: + - 17.0.1 + - dependency-name: less + versions: + - 4.1.0 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index f9ed7d8f..cd3ecdce 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,12 +1,12 @@ -name: "CodeQL" +name: 'CodeQL' on: push: - branches: [ "master" ] + branches: ['master'] pull_request: - branches: [ "master" ] + branches: ['master'] schedule: - - cron: "21 9 * * 6" + - cron: '21 9 * * 6' jobs: analyze: @@ -20,22 +20,24 @@ jobs: strategy: fail-fast: false matrix: - language: [ javascript ] + language: [javascript] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + with: + persist-credentials: false - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: languages: ${{ matrix.language }} queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: - category: "/language:${{ matrix.language }}" + category: '/language:${{ matrix.language }}' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 5735e2d2..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: ✅ test -on: [push, pull_request] -jobs: - test: - uses: react-component/rc-test/.github/workflows/test.yml@main - secrets: inherit \ No newline at end of file diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml new file mode 100644 index 00000000..9503b960 --- /dev/null +++ b/.github/workflows/react-component-ci.yml @@ -0,0 +1,8 @@ +name: ✅ test +on: [push, pull_request] +permissions: + contents: read +jobs: + test: + uses: react-component/rc-test/.github/workflows/test-utoo.yml@main + secrets: inherit diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml new file mode 100644 index 00000000..f68281c8 --- /dev/null +++ b/.github/workflows/react-doctor.yml @@ -0,0 +1,27 @@ +name: React Doctor + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + push: + branches: [master] + +permissions: + contents: read + pull-requests: write + issues: write + statuses: write + +concurrency: + group: react-doctor-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + react-doctor: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + with: + fetch-depth: 0 + persist-credentials: false + - uses: millionco/react-doctor@0b4f4f4bd248a154e64eb508a48347f71154b3f3 diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml new file mode 100644 index 00000000..1b29a17b --- /dev/null +++ b/.github/workflows/surge-preview.yml @@ -0,0 +1,39 @@ +name: Surge Preview + +on: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +permissions: + contents: read + pull-requests: write + checks: write + statuses: write + +jobs: + preview: + runs-on: ubuntu-latest + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + PREVIEW: true + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + with: + persist-credentials: false + - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec + if: ${{ env.SURGE_TOKEN != '' }} + with: + surge_token: ${{ env.SURGE_TOKEN }} + github_token: ${{ secrets.GITHUB_TOKEN }} + dist: docs-dist + failOnError: true + setCommitStatus: true + build: | + npm install + npm run build + - name: Skip Surge preview + if: ${{ env.SURGE_TOKEN == '' }} + run: echo "SURGE_TOKEN is not configured; skip Surge preview." diff --git a/.gitignore b/.gitignore index 36e64185..75a71bca 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ coverage/ .doc dist docs-dist +.vercel .vscode # umi .umi @@ -43,4 +44,4 @@ docs-dist .dumi/tmp .dumi/tmp-production -bun.lockb \ No newline at end of file +bun.lockb diff --git a/README.md b/README.md index 56f91964..7b7d8db7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ -# @rc-component/pagination +
+

@rc-component/pagination

+

📄 React pagination primitives for page navigation, size changing, quick jumping, and locale-aware controls.

+
-React Pagination Component. +
[![NPM version][npm-image]][npm-url] [![npm download][download-image]][download-url] @@ -9,76 +12,157 @@ React Pagination Component. [![bundle size][bundlephobia-image]][bundlephobia-url] [![dumi][dumi-image]][dumi-url] -[npm-image]: http://img.shields.io/npm/v/@rc-component/pagination.svg?style=flat-square -[npm-url]: http://npmjs.org/package/@rc-component/pagination -[github-actions-image]: https://github.com/react-component/pagination/actions/workflows/main.yml/badge.svg -[github-actions-url]: https://github.com/react-component/pagination/actions/workflows/main.yml -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/pagination/master.svg?style=flat-square -[codecov-url]: https://codecov.io/gh/react-component/pagination/branch/master -[download-image]: https://img.shields.io/npm/dm/@rc-component/pagination.svg?style=flat-square -[download-url]: https://npmjs.org/package/@rc-component/pagination -[bundlephobia-url]: https://bundlephobia.com/result?p=@rc-component/pagination -[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/pagination -[dumi-url]: https://github.com/umijs/dumi -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square +
-## Development +
+ + Part of the Ant Design ecosystem + Ant Design + +
-``` -npm install -npm start -``` +## Highlights -## Examples - -Online example: `https://pagination-react-component.vercel.app` -Local example: `npm run start` then `http://localhost:9001` +- Controlled and uncontrolled pagination state. +- Page-size changer, quick jumper, simple mode, compact item count, and custom item rendering. +- Locale packages exposed from `@rc-component/pagination/locale/*`. +- Semantic `classNames` and `styles` for item-level customization. +- TypeScript definitions for props, locale, callbacks, and state. +- Used by Ant Design as the shared pagination foundation. ## Install -[![@rc-component/pagination](https://nodei.co/npm/@rc-component/pagination.png)](https://npmjs.org/package/@rc-component/pagination) +```bash +npm install @rc-component/pagination +``` ## Usage -```js +```tsx | pure +import Pagination from '@rc-component/pagination'; +import '@rc-component/pagination/assets/index.css'; +import React, { useState } from 'react'; + +export default () => { + const [current, setCurrent] = useState(1); + + return ( + + ); +}; +``` + +```tsx | pure import Pagination from '@rc-component/pagination'; +import enUS from '@rc-component/pagination/locale/en_US'; +import React from 'react'; + +export default () => ( + `${range[0]}-${range[1]} of ${total} items`} + /> +); +``` + +## Examples + +Run the examples locally: -ReactDOM.render(, container); +```bash +npm install +npm start ``` +Then open the dumi dev server in your browser. + ## API -// prettier-ignore -| Parameter | Description | Type | Default | -| --- | --- | --- | --- | -| disabled | disable pagination | Bool | - | -| align | align of pagination | start \| center \| end | undefined | -| defaultCurrent | uncontrolled current page | Number | 1 | -| current | current page | Number | undefined | -| total | items total count | Number | 0 | -| defaultPageSize | default items per page | Number | 10 | -| pageSize | items per page | Number | 10 | -| onChange | page change callback | Function(current, pageSize) | - | -| showSizeChanger | show pageSize changer | boolean \| [SelectProps](https://github.com/react-component/select/blob/561f8b7d69fd5dd2cd7d917c88976cca4e539a9d/src/Select.tsx#L112) | `false` when total less than `totalBoundaryShowSizeChanger`, `true` when otherwise | -| totalBoundaryShowSizeChanger | when total larger than it, `showSizeChanger` will be true | number | 50 | -| pageSizeOptions | specify the sizeChanger selections | Array | ['10', '20', '50', '100'] | -| onShowSizeChange | pageSize change callback | Function(current, size) | - | -| hideOnSinglePage | hide on single page | Bool | false | -| showPrevNextJumpers | show jump-prev, jump-next | Bool | true | -| showQuickJumper | show quick goto jumper | Bool / Object | false / {goButton: true} | -| showTotal | show total records and range | Function(total, [from, to]) | - | -| className | className of pagination | String | - | -| simple | when set, show simple pager | Bool / { readOnly?: boolean; } | - | -| locale | to set l10n config | Object | [zh_CN](https://github.com/react-component/pagination/blob/master/src/locale/zh_CN.js) | -| style | the style of pagination | Object | {} | -| showLessItems | show less page items | Bool | false | -| showTitle | show page items title | Bool | true | -| itemRender | custom page item renderer | Function(current, type: 'page' \| 'prev' \| 'next' \| 'jump-prev' \| 'jump-next', element): React.ReactNode \| `(current, type, element) => element` | | -| prevIcon | specify the default previous icon | ReactNode \| (props: PaginationProps) => ReactNode | | -| nextIcon | specify the default next icon | ReactNode \| (props: PaginationProps) => ReactNode | | -| jumpPrevIcon | specify the default previous icon | ReactNode \| (props: PaginationProps) => ReactNode | | -| jumpNextIcon | specify the default next icon | ReactNode \| (props: PaginationProps) => ReactNode | | +### Pagination + +| Property | Type | Default | Description | +| ---------------------------- | ------------------------------------------ | -------------------------------------- | ----------------------------------------------- | +| align | `'start' \| 'center' \| 'end'` | - | Align pagination items. | +| className | `string` | - | Class name for the root element. | +| classNames | `Partial>` | - | Semantic class names. | +| current | `number` | - | Controlled current page. | +| defaultCurrent | `number` | `1` | Initial current page. | +| defaultPageSize | `number` | `10` | Initial page size. | +| disabled | `boolean` | `false` | Disable pagination interactions. | +| hideOnSinglePage | `boolean` | `false` | Hide when there is only one page. | +| itemRender | `(page, type, element) => ReactNode` | - | Customize page, previous, next, and jump items. | +| jumpNextIcon | `ReactNode \| ComponentType` | - | Custom next-jump icon. | +| jumpPrevIcon | `ReactNode \| ComponentType` | - | Custom previous-jump icon. | +| locale | `PaginationLocale` | `zh_CN` | Locale text. | +| nextIcon | `ReactNode \| ComponentType` | - | Custom next icon. | +| pageSize | `number` | - | Controlled page size. | +| pageSizeOptions | `number[]` | - | Page-size options. | +| prefixCls | `string` | `rc-pagination` | Class name prefix. | +| prevIcon | `ReactNode \| ComponentType` | - | Custom previous icon. | +| role | `React.AriaRole` | - | WAI-ARIA role. | +| selectPrefixCls | `string` | `rc-select` | Prefix for the size changer select. | +| showLessItems | `boolean` | `false` | Show fewer page items. | +| showPrevNextJumpers | `boolean` | `true` | Show previous and next jumpers. | +| showQuickJumper | `boolean \| object` | `false` | Show quick page jumper. | +| showSizeChanger | `boolean` | `total > totalBoundaryShowSizeChanger` | Show page-size changer. | +| showTitle | `boolean` | `true` | Show title on page items. | +| showTotal | `(total, range) => ReactNode` | - | Render total text. | +| simple | `boolean \| { readOnly?: boolean }` | `false` | Use simple pager. | +| sizeChangerRender | `SizeChangerRender` | - | Customize the size changer. | +| style | `React.CSSProperties` | - | Root inline style. | +| styles | `Partial>` | - | Semantic styles. | +| total | `number` | `0` | Total item count. | +| totalBoundaryShowSizeChanger | `number` | `50` | Boundary for default `showSizeChanger`. | +| onChange | `(page: number, pageSize: number) => void` | - | Triggered when page or page size changes. | +| onShowSizeChange | `(current: number, size: number) => void` | - | Triggered when page size changes. | + +## Development + +```bash +npm install +npm start +npm test +npm run tsc +npm run coverage +npm run compile +npm run build +``` + +## Release + +The package is published with [`@rc-component/np`](https://github.com/react-component/np): + +```bash +npm run prepublishOnly +``` + +This runs the package build before the release helper. ## License -@rc-component/pagination is released under the MIT license. +`@rc-component/pagination` is released under the MIT license. + +[npm-image]: https://img.shields.io/npm/v/@rc-component/pagination.svg?style=flat-square +[npm-url]: https://npmjs.org/package/@rc-component/pagination +[github-actions-image]: https://github.com/react-component/pagination/actions/workflows/react-component-ci.yml/badge.svg +[github-actions-url]: https://github.com/react-component/pagination/actions/workflows/react-component-ci.yml +[codecov-image]: https://img.shields.io/codecov/c/github/react-component/pagination/master.svg?style=flat-square +[codecov-url]: https://app.codecov.io/gh/react-component/pagination +[download-image]: https://img.shields.io/npm/dm/@rc-component/pagination.svg?style=flat-square +[download-url]: https://npmjs.org/package/@rc-component/pagination +[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/pagination +[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/pagination +[dumi-url]: https://github.com/umijs/dumi +[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square diff --git a/docs/examples/controlled.tsx b/docs/examples/controlled.tsx index 376791f2..84874e13 100644 --- a/docs/examples/controlled.tsx +++ b/docs/examples/controlled.tsx @@ -1,7 +1,7 @@ import React, { useState } from 'react'; import Pagination from '../../src'; import '../../assets/index.less'; -import 'rc-select/assets/index.less'; +import '@rc-component/select/assets/index.less'; const App = () => { const [current, setCurrent] = useState(1); diff --git a/docs/examples/jumper.tsx b/docs/examples/jumper.tsx index 20bd423b..9dbeef2f 100644 --- a/docs/examples/jumper.tsx +++ b/docs/examples/jumper.tsx @@ -1,7 +1,7 @@ /* eslint func-names: 0, no-console: 0 */ import React from 'react'; import '../../assets/index.less'; -import 'rc-select/assets/index.less'; +import '@rc-component/select/assets/index.less'; import PaginationWithSizeChanger from './utils/commonUtil'; function onShowSizeChange(current, pageSize) { diff --git a/docs/examples/jumperWithGoButton.tsx b/docs/examples/jumperWithGoButton.tsx index 16364fa9..f7290935 100644 --- a/docs/examples/jumperWithGoButton.tsx +++ b/docs/examples/jumperWithGoButton.tsx @@ -2,7 +2,7 @@ import React from 'react'; import Pagination from '../../src'; import '../../assets/index.less'; -import 'rc-select/assets/index.less'; +import '@rc-component/select/assets/index.less'; import PaginationWithSizeChanger from './utils/commonUtil'; class App extends React.Component { diff --git a/docs/examples/locale.tsx b/docs/examples/locale.tsx index 75b7a2a6..e294b0f7 100644 --- a/docs/examples/locale.tsx +++ b/docs/examples/locale.tsx @@ -2,7 +2,7 @@ import React from 'react'; import localeInfo from '../../src/locale/en_US'; import '../../assets/index.less'; -import 'rc-select/assets/index.less'; +import '@rc-component/select/assets/index.less'; import PaginationWithSizeChanger from './utils/commonUtil'; function onShowSizeChange(current, pageSize) { diff --git a/docs/examples/sizer.tsx b/docs/examples/sizer.tsx index 847a3127..35311a68 100644 --- a/docs/examples/sizer.tsx +++ b/docs/examples/sizer.tsx @@ -1,7 +1,7 @@ /* eslint func-names: 0, no-console: 0 */ import React from 'react'; import '../../assets/index.less'; -import 'rc-select/assets/index.less'; +import '@rc-component/select/assets/index.less'; import PaginationWithSizeChanger from './utils/commonUtil'; class App extends React.Component { diff --git a/docs/examples/utils/commonUtil.tsx b/docs/examples/utils/commonUtil.tsx index 88aa477d..4f68f64e 100644 --- a/docs/examples/utils/commonUtil.tsx +++ b/docs/examples/utils/commonUtil.tsx @@ -1,5 +1,5 @@ import Pagination, { type PaginationProps } from '../../../src'; -import Select from 'rc-select'; +import Select from '@rc-component/select'; import React from 'react'; export const getSizeChangerRender = (selectProps?: any) => { @@ -14,7 +14,7 @@ export const getSizeChangerRender = (selectProps?: any) => { - - - 20 条/页 - - + 20 条/页 +
- - - - - - 20 条/页 - - + 20 条/页 +
- - - - - - 10 条/页 - - + 10 条/页 +
@@ -1966,43 +1915,26 @@ exports[`Example jumper 1`] = ` class="rc-pagination-options" >
- - - - - - 10 条/页 - - + 10 条/页 +
@@ -2123,43 +2055,26 @@ exports[`Example jumperWithGoButton 1`] = ` class="rc-pagination-options" >
- - - - - - 20 条/页 - - + 20 条/页 +
- - - - - - 20 / page - - + 20 / page +
- - - - - - 10 条/页 - - + 10 条/页 +
@@ -3065,43 +2946,26 @@ exports[`Example showSizeChanger 1`] = ` class="rc-pagination-options" >
- - - - - - 10 条每页 - - + 10 条每页 +
@@ -3793,43 +3657,26 @@ exports[`Example simple 1`] = ` class="rc-pagination-options" >
- - - - - - 10 条/页 - - + 10 条/页 +
@@ -3887,43 +3734,26 @@ exports[`Example simple 1`] = ` class="rc-pagination-options" >
- - - - - - 10 条/页 - - + 10 条/页 +
- - - - - - 15 条/页 - - + 15 条/页 +
@@ -4199,43 +4012,26 @@ exports[`Example sizer 1`] = ` class="rc-pagination-options" >
- - - - - - 15 条/页 - - + 15 条/页 +
diff --git a/tests/__snapshots__/options.test.tsx.snap b/tests/__snapshots__/options.test.tsx.snap index c241a318..5bb32df2 100644 --- a/tests/__snapshots__/options.test.tsx.snap +++ b/tests/__snapshots__/options.test.tsx.snap @@ -5,43 +5,26 @@ exports[`Options should render correctly 1`] = ` class="rc-pagination-options" >
- - - - - - 10 条/页 - - + 10 条/页 +
triggerNode.parentNode} aria-label={ariaLabel} diff --git a/tests/setupAfterEnv.ts b/tests/setupAfterEnv.ts index 7b0828bf..0d86ed48 100644 --- a/tests/setupAfterEnv.ts +++ b/tests/setupAfterEnv.ts @@ -1 +1,22 @@ import '@testing-library/jest-dom'; + +class TestMessageChannel { + port1 = { + onmessage: null as ((event: MessageEvent) => void) | null, + }; + + port2 = { + postMessage: (data: unknown) => { + setTimeout(() => { + this.port1.onmessage?.({ data } as MessageEvent); + }, 0); + }, + }; +} + +if (!globalThis.MessageChannel) { + Object.defineProperty(globalThis, 'MessageChannel', { + configurable: true, + value: TestMessageChannel, + }); +} diff --git a/tests/simple.test.tsx b/tests/simple.test.tsx index 4191ab39..568858a4 100644 --- a/tests/simple.test.tsx +++ b/tests/simple.test.tsx @@ -1,6 +1,6 @@ import type { RenderResult } from '@testing-library/react'; import { render, fireEvent, createEvent } from '@testing-library/react'; -import Select from 'rc-select'; +import Select from '@rc-component/select'; import React, { useState } from 'react'; import Pagination from '../src'; import { sizeChangerRender } from './commonUtil'; diff --git a/tests/sizer.test.tsx b/tests/sizer.test.tsx index b53ef01b..ba4d1d3b 100644 --- a/tests/sizer.test.tsx +++ b/tests/sizer.test.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { render, fireEvent } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import Select from 'rc-select'; +import Select from '@rc-component/select'; import Pagination from '../src'; import { sizeChangerRender } from './commonUtil'; @@ -80,8 +80,8 @@ describe('Pagination with sizer', () => { pageSizeOptions={[20, 50]} />, ); - expect( - container.querySelector('.rc-select-selection-item'), - ).toHaveTextContent('20 条/页'); + expect(container.querySelector('.rc-select-content')).toHaveTextContent( + '20 条/页', + ); }); }); diff --git a/tests/two-pagination.tsx b/tests/two-pagination.tsx index ea30b656..1e472b85 100644 --- a/tests/two-pagination.tsx +++ b/tests/two-pagination.tsx @@ -1,4 +1,4 @@ -// import 'rc-select/assets/index.less'; +// import '@rc-component/select/assets/index.less'; import React from 'react'; import Pagination from '../src'; import { sizeChangerRender } from './commonUtil'; diff --git a/tsconfig.json b/tsconfig.json index 5a078dd8..5bd8b319 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,5 +13,6 @@ "@rc-component/pagination": ["src/index.ts"] } }, - "include": [".dumirc.ts", "**/*.ts", "**/*.tsx"] + "include": [".dumirc.ts", "src", "docs", "tests"], + "exclude": ["node_modules", "lib", "es", "dist", "docs-dist", ".dumi"] } diff --git a/vercel.json b/vercel.json index cc12e405..5f9139ef 100644 --- a/vercel.json +++ b/vercel.json @@ -1,3 +1,6 @@ { - "framework": "umijs" + "framework": "umijs", + "installCommand": "npm install", + "buildCommand": "npm run build", + "outputDirectory": "docs-dist" } From 2ecc6d6919d797846ca46355c572eee170af5c9c Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 15:32:59 +0800 Subject: [PATCH 02/36] test: refine message channel polyfill --- tests/setupAfterEnv.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/setupAfterEnv.ts b/tests/setupAfterEnv.ts index 0d86ed48..233ef93a 100644 --- a/tests/setupAfterEnv.ts +++ b/tests/setupAfterEnv.ts @@ -7,9 +7,9 @@ class TestMessageChannel { port2 = { postMessage: (data: unknown) => { - setTimeout(() => { + queueMicrotask(() => { this.port1.onmessage?.({ data } as MessageEvent); - }, 0); + }); }, }; } From 3268d6f2b0f4ae207dc731977880c5de1a5ca330 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 00:42:37 +0800 Subject: [PATCH 03/36] docs: add Ant Design logo to README header --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7b7d8db7..271f6263 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@

@rc-component/pagination

+ Ant Design

📄 React pagination primitives for page navigation, size changing, quick jumping, and locale-aware controls.

From f8b74859b45fbdb03b71e09f29447b2a408af259 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 01:27:27 +0800 Subject: [PATCH 04/36] chore: address AI review feedback --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 19eaf519..9e8d4609 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "build": "npm run docs:build", "docs:build": "dumi build", "docs:deploy": "gh-pages -d docs-dist", - "gh-pages": "GH_PAGES=1 npm run docs:build && npm run docs:deploy", + "gh-pages": "cross-env GH_PAGES=1 npm run docs:build && npm run docs:deploy", "compile": "father build && lessc assets/index.less assets/index.css", "prepublishOnly": "npm run compile && rc-np", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", @@ -81,6 +81,7 @@ "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@umijs/fabric": "^4.0.1", + "cross-env": "^7.0.0", "dumi": "^2.1.2", "eslint": "^8.54.0", "father": "^4.0.0", From 722fa82e47889d15deb91e768119322bb0b8ff41 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 01:56:48 +0800 Subject: [PATCH 05/36] docs: standardize README release details --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 271f6263..53345b2d 100644 --- a/README.md +++ b/README.md @@ -143,17 +143,15 @@ npm run build ## Release -The package is published with [`@rc-component/np`](https://github.com/react-component/np): - ```bash npm run prepublishOnly ``` -This runs the package build before the release helper. +The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build. ## License -`@rc-component/pagination` is released under the MIT license. +@rc-component/pagination is released under the [MIT](./LICENSE.md) license. [npm-image]: https://img.shields.io/npm/v/@rc-component/pagination.svg?style=flat-square [npm-url]: https://npmjs.org/package/@rc-component/pagination From c5c94d85ab945dd2cd55f6997f4c6b8010c76099 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:13:58 +0800 Subject: [PATCH 06/36] ci: make surge preview non-blocking --- .github/workflows/surge-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index 1b29a17b..ad8683da 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -29,7 +29,7 @@ jobs: surge_token: ${{ env.SURGE_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }} dist: docs-dist - failOnError: true + failOnError: false setCommitStatus: true build: | npm install From db5bdb884e319e1d76ac57027ba2a22cf260ba3b Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:17:44 +0800 Subject: [PATCH 07/36] docs: clarify Ant Design ecosystem note --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 53345b2d..51fc1a2b 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,15 @@

📄 React pagination primitives for page navigation, size changing, quick jumping, and locale-aware controls.

+

+ + + Ant Design + + Part of the Ant Design ecosystem. + +

+
[![NPM version][npm-image]][npm-url] From 09fef637c330b0b4d06adf86525cebe65e788ec0 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:25:42 +0800 Subject: [PATCH 08/36] ci: keep surge preview as fallback --- .github/workflows/surge-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index ad8683da..70768bf2 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -30,7 +30,7 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} dist: docs-dist failOnError: false - setCommitStatus: true + setCommitStatus: false build: | npm install npm run build From faccd96467bb8376704352983d89518755d8049a Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 13:04:01 +0800 Subject: [PATCH 09/36] docs: refine README usage and ecosystem note --- README.md | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 51fc1a2b..f66108da 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,10 @@

@rc-component/pagination

+

Part of the Ant Design ecosystem.

Ant Design

📄 React pagination primitives for page navigation, size changing, quick jumping, and locale-aware controls.

-

- - - Ant Design - - Part of the Ant Design ecosystem. - -

@@ -55,28 +48,14 @@ npm install @rc-component/pagination ```tsx | pure import Pagination from '@rc-component/pagination'; import '@rc-component/pagination/assets/index.css'; -import React, { useState } from 'react'; - -export default () => { - const [current, setCurrent] = useState(1); - - return ( - - ); -}; +export default () => ( + +); ``` ```tsx | pure import Pagination from '@rc-component/pagination'; import enUS from '@rc-component/pagination/locale/en_US'; -import React from 'react'; - export default () => ( Date: Sat, 27 Jun 2026 13:22:16 +0800 Subject: [PATCH 10/36] ci: isolate surge preview token --- .github/workflows/surge-preview.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index 70768bf2..faf6b8bd 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -17,23 +17,26 @@ jobs: preview: runs-on: ubuntu-latest env: - SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} PREVIEW: true steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with: persist-credentials: false + - name: Build preview + if: ${{ secrets.SURGE_TOKEN != '' }} + run: | + npm install + npm run build - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec - if: ${{ env.SURGE_TOKEN != '' }} + if: ${{ secrets.SURGE_TOKEN != '' }} + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} with: surge_token: ${{ env.SURGE_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }} dist: docs-dist failOnError: false setCommitStatus: false - build: | - npm install - npm run build - name: Skip Surge preview - if: ${{ env.SURGE_TOKEN == '' }} + if: ${{ secrets.SURGE_TOKEN == '' }} run: echo "SURGE_TOKEN is not configured; skip Surge preview." From 8aaacd128e82db01bf681bc72dde566c7294d636 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 13:51:03 +0800 Subject: [PATCH 11/36] chore: address review comments --- .github/workflows/react-doctor.yml | 1 + README.md | 10 ---------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml index f68281c8..70be3947 100644 --- a/.github/workflows/react-doctor.yml +++ b/.github/workflows/react-doctor.yml @@ -19,6 +19,7 @@ concurrency: jobs: react-doctor: runs-on: ubuntu-latest + timeout-minutes: 15 steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with: diff --git a/README.md b/README.md index f66108da..f68c25a2 100644 --- a/README.md +++ b/README.md @@ -17,16 +17,6 @@
-
- - Part of the Ant Design ecosystem - Ant Design - -
## Highlights From e4526e71f7b47a1632d8c95ea36b3847bcff4a6c Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 22:01:01 +0800 Subject: [PATCH 12/36] docs: update Ant Design logo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f68c25a2..7c708147 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

@rc-component/pagination

Part of the Ant Design ecosystem.

- Ant Design + Ant Design

📄 React pagination primitives for page navigation, size changing, quick jumping, and locale-aware controls.

From f8e1490faf6f0caec8afd8ce408b72a75f2dcf8f Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 22:19:49 +0800 Subject: [PATCH 13/36] docs: add Chinese README --- README.md | 2 + README.zh-CN.md | 147 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 README.zh-CN.md diff --git a/README.md b/README.md index 7c708147..4c606dbf 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@

📄 React pagination primitives for page navigation, size changing, quick jumping, and locale-aware controls.

+

English | 简体中文

+
diff --git a/README.zh-CN.md b/README.zh-CN.md new file mode 100644 index 00000000..fc6abdc5 --- /dev/null +++ b/README.zh-CN.md @@ -0,0 +1,147 @@ +
+

@rc-component/pagination

+

Ant Design 生态的一部分。

+ Ant Design +

📄 React 分页组件,支持页码、快速跳转、尺寸切换和本地化。

+
+ +

English | 简体中文

+ + +
+ +[![NPM version][npm-image]][npm-url] +[![npm download][download-image]][download-url] +[![build status][github-actions-image]][github-actions-url] +[![Codecov][codecov-image]][codecov-url] +[![bundle size][bundlephobia-image]][bundlephobia-url] +[![dumi][dumi-image]][dumi-url] + +
+ + +## 特性 + +- Controlled and uncontrolled pagination state. +- Page-size changer, quick jumper, simple mode, compact item count, and custom item rendering. +- Locale packages exposed from `@rc-component/pagination/locale/*`. +- Semantic `classNames` and `styles` for item-level customization. +- TypeScript definitions for props, locale, callbacks, and state. +- 被 Ant Design 用作共享的 pagination 基础能力。 + +## 安装 + +```bash +npm install @rc-component/pagination +``` + +## 使用 + +```tsx | pure +import Pagination from '@rc-component/pagination'; +import '@rc-component/pagination/assets/index.css'; +export default () => ( + +); +``` + +```tsx | pure +import Pagination from '@rc-component/pagination'; +import enUS from '@rc-component/pagination/locale/en_US'; +export default () => ( + `${range[0]}-${range[1]} of ${total} items`} + /> +); +``` + +## 示例 + +本地运行示例: + +```bash +npm install +npm start +``` + +然后在浏览器中打开 dumi 开发服务地址。 + +## API + +### Pagination + +| 参数 | 类型 | 默认值 | 说明 | +| ---------------------------- | ------------------------------------------ | -------------------------------------- | ----------------------------------------------- | +| align | `'start' \| 'center' \| 'end'` | - | Align pagination items. | +| className | `string` | - | Class name for the root element. | +| classNames | `Partial>` | - | Semantic class names. | +| current | `number` | - | Controlled current page. | +| defaultCurrent | `number` | `1` | Initial current page. | +| defaultPageSize | `number` | `10` | Initial page size. | +| disabled | `boolean` | `false` | Disable pagination interactions. | +| hideOnSinglePage | `boolean` | `false` | Hide when there is only one page. | +| itemRender | `(page, type, element) => ReactNode` | - | Customize page, previous, next, and jump items. | +| jumpNextIcon | `ReactNode \| ComponentType` | - | Custom next-jump icon. | +| jumpPrevIcon | `ReactNode \| ComponentType` | - | Custom previous-jump icon. | +| locale | `PaginationLocale` | `zh_CN` | Locale text. | +| nextIcon | `ReactNode \| ComponentType` | - | Custom next icon. | +| pageSize | `number` | - | Controlled page size. | +| pageSizeOptions | `number[]` | - | Page-size options. | +| prefixCls | `string` | `rc-pagination` | Class name prefix. | +| prevIcon | `ReactNode \| ComponentType` | - | Custom previous icon. | +| role | `React.AriaRole` | - | WAI-ARIA role. | +| selectPrefixCls | `string` | `rc-select` | Prefix for the size changer select. | +| showLessItems | `boolean` | `false` | Show fewer page items. | +| showPrevNextJumpers | `boolean` | `true` | Show previous and next jumpers. | +| showQuickJumper | `boolean \| object` | `false` | Show quick page jumper. | +| showSizeChanger | `boolean` | `total > totalBoundaryShowSizeChanger` | Show page-size changer. | +| showTitle | `boolean` | `true` | Show title on page items. | +| showTotal | `(total, range) => ReactNode` | - | Render total text. | +| simple | `boolean \| { readOnly?: boolean }` | `false` | Use simple pager. | +| sizeChangerRender | `SizeChangerRender` | - | Customize the size changer. | +| style | `React.CSSProperties` | - | Root inline style. | +| styles | `Partial>` | - | Semantic styles. | +| total | `number` | `0` | Total item count. | +| totalBoundaryShowSizeChanger | `number` | `50` | Boundary for default `showSizeChanger`. | +| onChange | `(page: number, pageSize: number) => void` | - | Triggered when page or page size changes. | +| onShowSizeChange | `(current: number, size: number) => void` | - | Triggered when page size changes. | + +## 本地开发 + +```bash +npm install +npm start +npm test +npm run tsc +npm run coverage +npm run compile +npm run build +``` + +## 发布 + +```bash +npm run prepublishOnly +``` + +The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build. + +## 许可证 + +@rc-component/pagination is released under the [MIT](./LICENSE.md) license. + +[npm-image]: https://img.shields.io/npm/v/@rc-component/pagination.svg?style=flat-square +[npm-url]: https://npmjs.org/package/@rc-component/pagination +[github-actions-image]: https://github.com/react-component/pagination/actions/workflows/react-component-ci.yml/badge.svg +[github-actions-url]: https://github.com/react-component/pagination/actions/workflows/react-component-ci.yml +[codecov-image]: https://img.shields.io/codecov/c/github/react-component/pagination/master.svg?style=flat-square +[codecov-url]: https://app.codecov.io/gh/react-component/pagination +[download-image]: https://img.shields.io/npm/dm/@rc-component/pagination.svg?style=flat-square +[download-url]: https://npmjs.org/package/@rc-component/pagination +[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/pagination +[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/pagination +[dumi-url]: https://github.com/umijs/dumi +[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square From c1ad1797ab5442731153e8474a32495f3791ed60 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 23:03:26 +0800 Subject: [PATCH 14/36] docs: refine bilingual README branding --- README.md | 3 +- README.zh-CN.md | 79 ++++++++++++++++++++++++------------------------- 2 files changed, 40 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 4c606dbf..9f3e608e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@

@rc-component/pagination

-

Part of the Ant Design ecosystem.

- Ant Design +

Ant Design Part of the Ant Design ecosystem.

📄 React pagination primitives for page navigation, size changing, quick jumping, and locale-aware controls.

diff --git a/README.zh-CN.md b/README.zh-CN.md index fc6abdc5..847dc865 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,7 +1,6 @@

@rc-component/pagination

-

Ant Design 生态的一部分。

- Ant Design +

Ant Design Ant Design 生态的一部分。

📄 React 分页组件,支持页码、快速跳转、尺寸切换和本地化。

@@ -22,11 +21,11 @@ ## 特性 -- Controlled and uncontrolled pagination state. -- Page-size changer, quick jumper, simple mode, compact item count, and custom item rendering. -- Locale packages exposed from `@rc-component/pagination/locale/*`. -- Semantic `classNames` and `styles` for item-level customization. -- TypeScript definitions for props, locale, callbacks, and state. +- 受控和非受控分页状态。 +- 页面大小更改器、快速跳转、简单模式、紧凑项目计数和自定义项目渲染。 +- 从 `@rc-component/pagination/locale/*` 公开的语言环境包。 +- 用于项目级自定义的语义 `classNames` 和 `styles`。 +- 属性、本地化、回调和状态的 TypeScript 定义。 - 被 Ant Design 用作共享的 pagination 基础能力。 ## 安装 @@ -75,39 +74,39 @@ npm start | 参数 | 类型 | 默认值 | 说明 | | ---------------------------- | ------------------------------------------ | -------------------------------------- | ----------------------------------------------- | -| align | `'start' \| 'center' \| 'end'` | - | Align pagination items. | -| className | `string` | - | Class name for the root element. | -| classNames | `Partial>` | - | Semantic class names. | -| current | `number` | - | Controlled current page. | -| defaultCurrent | `number` | `1` | Initial current page. | -| defaultPageSize | `number` | `10` | Initial page size. | -| disabled | `boolean` | `false` | Disable pagination interactions. | -| hideOnSinglePage | `boolean` | `false` | Hide when there is only one page. | -| itemRender | `(page, type, element) => ReactNode` | - | Customize page, previous, next, and jump items. | -| jumpNextIcon | `ReactNode \| ComponentType` | - | Custom next-jump icon. | -| jumpPrevIcon | `ReactNode \| ComponentType` | - | Custom previous-jump icon. | -| locale | `PaginationLocale` | `zh_CN` | Locale text. | -| nextIcon | `ReactNode \| ComponentType` | - | Custom next icon. | -| pageSize | `number` | - | Controlled page size. | -| pageSizeOptions | `number[]` | - | Page-size options. | -| prefixCls | `string` | `rc-pagination` | Class name prefix. | -| prevIcon | `ReactNode \| ComponentType` | - | Custom previous icon. | +| align | `'start' \| 'center' \| 'end'` | - | 对齐分页项目。 | +| className | `string` | - | 根元素的className。 | +| classNames | `Partial>` | - | 语义className。 | +| 当前的 | `number` | - | 控制当前页面。 | +| defaultCurrent | `number` | `1` | 初始当前页面。 | +| defaultPageSize | `number` | `10` | 初始页面大小。 | +| disabled | `boolean` | `false` | 禁用分页交互。 | +| hideOnSinglePage | `boolean` | `false` | 当只有一页时隐藏。 | +| itemRender | `(page, type, element) => ReactNode` | - | 自定义页面、上一个、下一个和跳转项目。 | +| jumpNextIcon | `ReactNode \| ComponentType` | - | 自定义下一跳图标。 | +| jumpPrevIcon | `ReactNode \| ComponentType` | - | 自定义上一跳转图标。 | +| 语言环境 | `PaginationLocale` | `zh_CN` | 区域设置文本。 | +| nextIcon | `ReactNode \| ComponentType` | - | 自定义下一个图标。 | +| pageSize | `number` | - | 受控的页面大小。 | +| pageSizeOptions | `number[]` | - | 页面大小选项。 | +| prefixCls | `string` | `rc-pagination` | className前缀。 | +| prevIcon | `ReactNode \| ComponentType` | - | 自定义上一个图标。 | | role | `React.AriaRole` | - | WAI-ARIA role. | -| selectPrefixCls | `string` | `rc-select` | Prefix for the size changer select. | -| showLessItems | `boolean` | `false` | Show fewer page items. | -| showPrevNextJumpers | `boolean` | `true` | Show previous and next jumpers. | -| showQuickJumper | `boolean \| object` | `false` | Show quick page jumper. | -| showSizeChanger | `boolean` | `total > totalBoundaryShowSizeChanger` | Show page-size changer. | -| showTitle | `boolean` | `true` | Show title on page items. | -| showTotal | `(total, range) => ReactNode` | - | Render total text. | +| selectPrefixCls | `string` | `rc-select` | 尺寸变换器选择的前缀。 | +| showLessItems | `boolean` | `false` | 显示较少的页面项目。 | +| showPrevNextJumpers | `boolean` | `true` | 显示上一个和下一个跳线。 | +| showQuickJumper | `boolean \| object` | `false` | 显示快速跳页。 | +| showSizeChanger | `boolean` | `total > totalBoundaryShowSizeChanger` | 显示页面大小更改器。 | +| showTitle | `boolean` | `true` | 在页面项目上显示标题。 | +| showTotal | `(total, range) => ReactNode` | - | 渲染总文本。 | | simple | `boolean \| { readOnly?: boolean }` | `false` | Use simple pager. | -| sizeChangerRender | `SizeChangerRender` | - | Customize the size changer. | -| style | `React.CSSProperties` | - | Root inline style. | -| styles | `Partial>` | - | Semantic styles. | -| total | `number` | `0` | Total item count. | -| totalBoundaryShowSizeChanger | `number` | `50` | Boundary for default `showSizeChanger`. | -| onChange | `(page: number, pageSize: number) => void` | - | Triggered when page or page size changes. | -| onShowSizeChange | `(current: number, size: number) => void` | - | Triggered when page size changes. | +| sizeChangerRender | `SizeChangerRender` | - | 定制尺寸变换器。 | +| 风格 | `React.CSSProperties` | - | 根内联样式。 | +| styles | `Partial>` | - | 语义化样式。 | +| total | `number` | `0` | 项目总数。 | +| totalBoundaryShowSizeChanger | `number` | `50` | 默认的边界 `showSizeChanger`。 | +| onChange | `(page: number, pageSize: number) => void` | - | 当页面或页面大小更改时触发。 | +| onShowSizeChange | `(current: number, size: number) => void` | - | 当页面大小改变时触发。 | ## 本地开发 @@ -127,11 +126,11 @@ npm run build npm run prepublishOnly ``` -The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build. +包构建完成后,发布流程由 `@rc-component/np` 通过 `rc-np` 命令处理。 ## 许可证 -@rc-component/pagination is released under the [MIT](./LICENSE.md) license. +@rc-component/pagination 基于 [MIT](./LICENSE.md) 许可证发布。 [npm-image]: https://img.shields.io/npm/v/@rc-component/pagination.svg?style=flat-square [npm-url]: https://npmjs.org/package/@rc-component/pagination From fe72437b40be8641e6c1669f82c5b0f7904d0b9c Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 01:28:41 +0800 Subject: [PATCH 15/36] chore: standardize rc tooling and docs --- .dumirc.ts | 2 +- README.md | 4 ++-- README.zh-CN.md | 4 ++-- package.json | 42 +++++++++++++++++++++--------------------- tsconfig.json | 31 +++++++++++++++++++++++++------ 5 files changed, 51 insertions(+), 32 deletions(-) diff --git a/.dumirc.ts b/.dumirc.ts index 7ac2fe6d..a7e45134 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -1,7 +1,7 @@ import { defineConfig } from 'dumi'; const basePath = process.env.GH_PAGES ? '/pagination/' : '/'; -const publicPath = process.env.GH_PAGES ? '/pagination/' : '/'; +const publicPath = basePath; export default defineConfig({ favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], diff --git a/README.md b/README.md index 9f3e608e..dd7df916 100644 --- a/README.md +++ b/README.md @@ -59,14 +59,14 @@ export default () => ( ## Examples -Run the examples locally: +Run the local dumi site: ```bash npm install npm start ``` -Then open the dumi dev server in your browser. +Then open `http://localhost:8000`. ## API diff --git a/README.zh-CN.md b/README.zh-CN.md index 847dc865..f2fa8fdd 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -59,14 +59,14 @@ export default () => ( ## 示例 -本地运行示例: +运行本地 dumi 站点: ```bash npm install npm start ``` -然后在浏览器中打开 dumi 开发服务地址。 +然后打开 `http://localhost:8000`。 ## API diff --git a/package.json b/package.json index 9e8d4609..9dd8ecca 100644 --- a/package.json +++ b/package.json @@ -72,30 +72,30 @@ }, "devDependencies": { "@rc-component/father-plugin": "^2.2.0", - "@rc-component/np": "^1.0.3", - "@testing-library/jest-dom": "^6.1.5", - "@testing-library/react": "^16.0.1", - "@testing-library/user-event": "^14.5.2", - "@types/jest": "^30.0.0", - "@types/node": "^24.5.2", - "@types/react": "^19.0.8", - "@types/react-dom": "^19.0.3", + "@rc-component/np": "^1.0.4", + "@testing-library/jest-dom": "^6.9.1", + "@testing-library/react": "^15.0.7", + "@testing-library/user-event": "14.5.2", + "@types/jest": "^29.5.14", + "@types/node": "^26.0.1", + "@types/react": "^18.3.31", + "@types/react-dom": "^18.3.7", "@umijs/fabric": "^4.0.1", - "cross-env": "^7.0.0", - "dumi": "^2.1.2", - "eslint": "^8.54.0", - "father": "^4.0.0", - "gh-pages": "^6.1.0", - "glob": "^13.0.2", - "husky": "^9.0.11", + "cross-env": "^10.1.0", + "dumi": "^2.4.35", + "eslint": "^8.57.1", + "father": "^4.6.23", + "gh-pages": "^6.3.0", + "glob": "^13.0.6", + "husky": "^9.1.7", "identity-obj-proxy": "^3.0.0", - "less": "^4.1.3", - "lint-staged": "^17.0.7", - "prettier": "^3.1.0", + "less": "^4.6.7", + "lint-staged": "^16.4.0", + "prettier": "^3.9.0", "@rc-component/select": "^1.8.0", - "rc-test": "^7.0.15", - "react": "^19.0.0", - "react-dom": "^19.0.0" + "rc-test": "^7.1.3", + "react": "^18.3.1", + "react-dom": "^18.3.1" }, "peerDependencies": { "react": ">=16.9.0", diff --git a/tsconfig.json b/tsconfig.json index 5bd8b319..832143be 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,11 +8,30 @@ "skipLibCheck": true, "esModuleInterop": true, "paths": { - "@/*": ["src/*"], - "@@/*": [".dumi/tmp/*"], - "@rc-component/pagination": ["src/index.ts"] - } + "@/*": [ + "src/*" + ], + "@@/*": [ + ".dumi/tmp/*" + ], + "@rc-component/pagination": [ + "src/index.ts" + ] + }, + "ignoreDeprecations": "5.0" }, - "include": [".dumirc.ts", "src", "docs", "tests"], - "exclude": ["node_modules", "lib", "es", "dist", "docs-dist", ".dumi"] + "include": [ + ".dumirc.ts", + "src", + "docs", + "tests" + ], + "exclude": [ + "node_modules", + "lib", + "es", + "dist", + "docs-dist", + ".dumi" + ] } From 26a631a9ba46535b2c1abbd270e8b0482db92192 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 02:01:06 +0800 Subject: [PATCH 16/36] chore: address standardization review comments --- .github/workflows/surge-preview.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index faf6b8bd..cb6c8c4a 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -22,13 +22,23 @@ jobs: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with: persist-credentials: false + - name: Check Surge token + id: surge-token + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + run: | + if [ -n "$SURGE_TOKEN" ]; then + echo "enabled=true" >> "$GITHUB_OUTPUT" + else + echo "enabled=false" >> "$GITHUB_OUTPUT" + fi - name: Build preview - if: ${{ secrets.SURGE_TOKEN != '' }} + if: ${{ steps.surge-token.outputs.enabled == 'true' }} run: | npm install npm run build - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec - if: ${{ secrets.SURGE_TOKEN != '' }} + if: ${{ steps.surge-token.outputs.enabled == 'true' }} env: SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} with: @@ -38,5 +48,5 @@ jobs: failOnError: false setCommitStatus: false - name: Skip Surge preview - if: ${{ secrets.SURGE_TOKEN == '' }} + if: ${{ steps.surge-token.outputs.enabled != 'true' }} run: echo "SURGE_TOKEN is not configured; skip Surge preview." From f0add58dca0d833a8edd947d9e33daff2eb2cc51 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 12:24:10 +0800 Subject: [PATCH 17/36] ci: update GitHub Actions versions --- .github/workflows/codeql.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index cd3ecdce..0500defd 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -29,15 +29,15 @@ jobs: persist-credentials: false - name: Initialize CodeQL - uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + uses: github/codeql-action/init@a0853c24544627f65ddf259abe73b1d18a591444 with: languages: ${{ matrix.language }} queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + uses: github/codeql-action/autobuild@a0853c24544627f65ddf259abe73b1d18a591444 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + uses: github/codeql-action/analyze@a0853c24544627f65ddf259abe73b1d18a591444 with: category: '/language:${{ matrix.language }}' From ce1909796a705e737f8ae49df0d22e45d58955f6 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 12:29:49 +0800 Subject: [PATCH 18/36] ci: use resolvable CodeQL action ref --- .github/workflows/codeql.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 0500defd..cd3ecdce 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -29,15 +29,15 @@ jobs: persist-credentials: false - name: Initialize CodeQL - uses: github/codeql-action/init@a0853c24544627f65ddf259abe73b1d18a591444 + uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: languages: ${{ matrix.language }} queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@a0853c24544627f65ddf259abe73b1d18a591444 + uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@a0853c24544627f65ddf259abe73b1d18a591444 + uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e with: category: '/language:${{ matrix.language }}' From e435d642ee459a5b99e5a4dd5d9e6d7f17571445 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 13:27:37 +0800 Subject: [PATCH 19/36] docs: add license file --- LICENSE | 21 +++++++++++++++++++++ README.md | 2 +- README.zh-CN.md | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..bd0a1f72 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019-present react-component + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index dd7df916..fbf80608 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ The release flow is handled by `@rc-component/np` through the `rc-np` command af ## License -@rc-component/pagination is released under the [MIT](./LICENSE.md) license. +@rc-component/pagination is released under the [MIT](./LICENSE) license. [npm-image]: https://img.shields.io/npm/v/@rc-component/pagination.svg?style=flat-square [npm-url]: https://npmjs.org/package/@rc-component/pagination diff --git a/README.zh-CN.md b/README.zh-CN.md index f2fa8fdd..084c70a9 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -130,7 +130,7 @@ npm run prepublishOnly ## 许可证 -@rc-component/pagination 基于 [MIT](./LICENSE.md) 许可证发布。 +@rc-component/pagination 基于 [MIT](./LICENSE) 许可证发布。 [npm-image]: https://img.shields.io/npm/v/@rc-component/pagination.svg?style=flat-square [npm-url]: https://npmjs.org/package/@rc-component/pagination From 4a3bccad22e8b69266c9e9572e68554c15eef752 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:00:42 +0800 Subject: [PATCH 20/36] ci: use actions checkout v7 --- .github/workflows/codeql.yml | 2 +- .github/workflows/react-doctor.yml | 2 +- .github/workflows/surge-preview.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index cd3ecdce..8fa1ebc8 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + uses: actions/checkout@v7 with: persist-credentials: false diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml index 70be3947..32975018 100644 --- a/.github/workflows/react-doctor.yml +++ b/.github/workflows/react-doctor.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + - uses: actions/checkout@v7 with: fetch-depth: 0 persist-credentials: false diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index cb6c8c4a..ebfecd53 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -19,7 +19,7 @@ jobs: env: PREVIEW: true steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + - uses: actions/checkout@v7 with: persist-credentials: false - name: Check Surge token From 103c319e2f856edaa223c2050cf1791b40682ed8 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:31:27 +0800 Subject: [PATCH 21/36] chore: standardize package metadata --- package.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9dd8ecca..b42ee134 100644 --- a/package.json +++ b/package.json @@ -45,10 +45,10 @@ "homepage": "https://react-component.github.io/pagination", "repository": { "type": "git", - "url": "git@github.com:react-component/pagination.git" + "url": "https://github.com/react-component/pagination.git" }, "bugs": { - "url": "http://github.com/react-component/pagination/issues" + "url": "https://github.com/react-component/pagination/issues" }, "license": "MIT", "scripts": { @@ -111,5 +111,8 @@ "**/*.{js,jsx,tsx,ts,md,json}": [ "prettier --write --ignore-unknown" ] + }, + "publishConfig": { + "access": "public" } } From 519184ecc59f9a22a4bc24d108e2ebb991d25b47 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:37:47 +0800 Subject: [PATCH 22/36] ci: standardize dependabot updates --- .github/dependabot.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 165cd4ec..3b730ef9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,13 +3,17 @@ updates: - package-ecosystem: npm directory: '/' schedule: - interval: daily + interval: weekly + day: monday time: '21:00' + timezone: Asia/Shanghai + open-pull-requests-limit: 10 + + - package-ecosystem: github-actions + directory: '/' + schedule: + interval: weekly + day: monday + time: '21:00' + timezone: Asia/Shanghai open-pull-requests-limit: 10 - ignore: - - dependency-name: react-dom - versions: - - 17.0.1 - - dependency-name: less - versions: - - 4.1.0 From 9bdd10e6aec3258ad527ad7fa49dbfe7c244af4a Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 16:27:19 +0800 Subject: [PATCH 23/36] docs: fix Chinese README API names --- README.zh-CN.md | 64 ++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/README.zh-CN.md b/README.zh-CN.md index 084c70a9..8611fe7b 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -6,7 +6,6 @@

English | 简体中文

-
[![NPM version][npm-image]][npm-url] @@ -18,7 +17,6 @@
- ## 特性 - 受控和非受控分页状态。 @@ -72,41 +70,41 @@ npm start ### Pagination -| 参数 | 类型 | 默认值 | 说明 | -| ---------------------------- | ------------------------------------------ | -------------------------------------- | ----------------------------------------------- | +| 参数 | 类型 | 默认值 | 说明 | +| ---------------------------- | ------------------------------------------ | -------------------------------------- | -------------------------------------- | | align | `'start' \| 'center' \| 'end'` | - | 对齐分页项目。 | -| className | `string` | - | 根元素的className。 | -| classNames | `Partial>` | - | 语义className。 | -| 当前的 | `number` | - | 控制当前页面。 | -| defaultCurrent | `number` | `1` | 初始当前页面。 | -| defaultPageSize | `number` | `10` | 初始页面大小。 | -| disabled | `boolean` | `false` | 禁用分页交互。 | -| hideOnSinglePage | `boolean` | `false` | 当只有一页时隐藏。 | +| className | `string` | - | 根元素的className。 | +| classNames | `Partial>` | - | 语义className。 | +| current | `number` | - | 控制当前页面。 | +| defaultCurrent | `number` | `1` | 初始当前页面。 | +| defaultPageSize | `number` | `10` | 初始页面大小。 | +| disabled | `boolean` | `false` | 禁用分页交互。 | +| hideOnSinglePage | `boolean` | `false` | 当只有一页时隐藏。 | | itemRender | `(page, type, element) => ReactNode` | - | 自定义页面、上一个、下一个和跳转项目。 | -| jumpNextIcon | `ReactNode \| ComponentType` | - | 自定义下一跳图标。 | -| jumpPrevIcon | `ReactNode \| ComponentType` | - | 自定义上一跳转图标。 | -| 语言环境 | `PaginationLocale` | `zh_CN` | 区域设置文本。 | -| nextIcon | `ReactNode \| ComponentType` | - | 自定义下一个图标。 | -| pageSize | `number` | - | 受控的页面大小。 | -| pageSizeOptions | `number[]` | - | 页面大小选项。 | -| prefixCls | `string` | `rc-pagination` | className前缀。 | -| prevIcon | `ReactNode \| ComponentType` | - | 自定义上一个图标。 | -| role | `React.AriaRole` | - | WAI-ARIA role. | -| selectPrefixCls | `string` | `rc-select` | 尺寸变换器选择的前缀。 | -| showLessItems | `boolean` | `false` | 显示较少的页面项目。 | -| showPrevNextJumpers | `boolean` | `true` | 显示上一个和下一个跳线。 | +| jumpNextIcon | `ReactNode \| ComponentType` | - | 自定义下一跳图标。 | +| jumpPrevIcon | `ReactNode \| ComponentType` | - | 自定义上一跳转图标。 | +| locale | `PaginationLocale` | `zh_CN` | 区域设置文本。 | +| nextIcon | `ReactNode \| ComponentType` | - | 自定义下一个图标。 | +| pageSize | `number` | - | 受控的页面大小。 | +| pageSizeOptions | `number[]` | - | 页面大小选项。 | +| prefixCls | `string` | `rc-pagination` | className前缀。 | +| prevIcon | `ReactNode \| ComponentType` | - | 自定义上一个图标。 | +| role | `React.AriaRole` | - | WAI-ARIA role. | +| selectPrefixCls | `string` | `rc-select` | 尺寸变换器选择的前缀。 | +| showLessItems | `boolean` | `false` | 显示较少的页面项目。 | +| showPrevNextJumpers | `boolean` | `true` | 显示上一个和下一个跳线。 | | showQuickJumper | `boolean \| object` | `false` | 显示快速跳页。 | -| showSizeChanger | `boolean` | `total > totalBoundaryShowSizeChanger` | 显示页面大小更改器。 | -| showTitle | `boolean` | `true` | 在页面项目上显示标题。 | -| showTotal | `(total, range) => ReactNode` | - | 渲染总文本。 | -| simple | `boolean \| { readOnly?: boolean }` | `false` | Use simple pager. | -| sizeChangerRender | `SizeChangerRender` | - | 定制尺寸变换器。 | -| 风格 | `React.CSSProperties` | - | 根内联样式。 | -| styles | `Partial>` | - | 语义化样式。 | -| total | `number` | `0` | 项目总数。 | +| showSizeChanger | `boolean` | `total > totalBoundaryShowSizeChanger` | 显示页面大小更改器。 | +| showTitle | `boolean` | `true` | 在页面项目上显示标题。 | +| showTotal | `(total, range) => ReactNode` | - | 渲染总文本。 | +| simple | `boolean \| { readOnly?: boolean }` | `false` | Use simple pager. | +| sizeChangerRender | `SizeChangerRender` | - | 定制尺寸变换器。 | +| style | `React.CSSProperties` | - | 根内联样式。 | +| styles | `Partial>` | - | 语义化样式。 | +| total | `number` | `0` | 项目总数。 | | totalBoundaryShowSizeChanger | `number` | `50` | 默认的边界 `showSizeChanger`。 | -| onChange | `(page: number, pageSize: number) => void` | - | 当页面或页面大小更改时触发。 | -| onShowSizeChange | `(current: number, size: number) => void` | - | 当页面大小改变时触发。 | +| onChange | `(page: number, pageSize: number) => void` | - | 当页面或页面大小更改时触发。 | +| onShowSizeChange | `(current: number, size: number) => void` | - | 当页面大小改变时触发。 | ## 本地开发 From ff4d4b3ced095b7ae52ef25c783b3c9a064d0dd3 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 16:52:21 +0800 Subject: [PATCH 24/36] docs: localize Chinese README descriptions --- README.zh-CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.zh-CN.md b/README.zh-CN.md index 8611fe7b..15c66a42 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -97,7 +97,7 @@ npm start | showSizeChanger | `boolean` | `total > totalBoundaryShowSizeChanger` | 显示页面大小更改器。 | | showTitle | `boolean` | `true` | 在页面项目上显示标题。 | | showTotal | `(total, range) => ReactNode` | - | 渲染总文本。 | -| simple | `boolean \| { readOnly?: boolean }` | `false` | Use simple pager. | +| simple | `boolean \| { readOnly?: boolean }` | `false` | 使用简洁分页器。 | | sizeChangerRender | `SizeChangerRender` | - | 定制尺寸变换器。 | | style | `React.CSSProperties` | - | 根内联样式。 | | styles | `Partial>` | - | 语义化样式。 | From 8be63b3395798c568eeb1fa138905807ea24621f Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 17:15:25 +0800 Subject: [PATCH 25/36] chore: refine preview workflow ignores --- .github/workflows/surge-preview.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index ebfecd53..eaff160a 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -16,6 +16,9 @@ permissions: jobs: preview: runs-on: ubuntu-latest + concurrency: + group: surge-preview-${{ github.event.pull_request.number }} + cancel-in-progress: true env: PREVIEW: true steps: From 05bdb1f2f6c6afc65dbf7d69bbed3d66f2077401 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 17:36:22 +0800 Subject: [PATCH 26/36] docs: polish Chinese README wording --- README.zh-CN.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.zh-CN.md b/README.zh-CN.md index 15c66a42..38d4ba87 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -73,8 +73,8 @@ npm start | 参数 | 类型 | 默认值 | 说明 | | ---------------------------- | ------------------------------------------ | -------------------------------------- | -------------------------------------- | | align | `'start' \| 'center' \| 'end'` | - | 对齐分页项目。 | -| className | `string` | - | 根元素的className。 | -| classNames | `Partial>` | - | 语义className。 | +| className | `string` | - | 根元素的 className。 | +| classNames | `Partial>` | - | 语义 className。 | | current | `number` | - | 控制当前页面。 | | defaultCurrent | `number` | `1` | 初始当前页面。 | | defaultPageSize | `number` | `10` | 初始页面大小。 | @@ -87,7 +87,7 @@ npm start | nextIcon | `ReactNode \| ComponentType` | - | 自定义下一个图标。 | | pageSize | `number` | - | 受控的页面大小。 | | pageSizeOptions | `number[]` | - | 页面大小选项。 | -| prefixCls | `string` | `rc-pagination` | className前缀。 | +| prefixCls | `string` | `rc-pagination` | className 前缀。 | | prevIcon | `ReactNode \| ComponentType` | - | 自定义上一个图标。 | | role | `React.AriaRole` | - | WAI-ARIA role. | | selectPrefixCls | `string` | `rc-select` | 尺寸变换器选择的前缀。 | From 0ed4887e3a739e4dbceb612557e2c7e248a2f1a4 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 17:48:06 +0800 Subject: [PATCH 27/36] chore: align tooling ignores and typescript --- .prettierignore | 10 ++++++++++ package.json | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.prettierignore b/.prettierignore index e1497d59..4b2b6cef 100644 --- a/.prettierignore +++ b/.prettierignore @@ -10,3 +10,13 @@ public _site .umi .doc +coverage +docs-dist +dist +.dumi/tmp +.dumi/tmp-production +.vercel +pnpm-lock.yaml +yarn.lock +bun.lockb +*.log diff --git a/package.json b/package.json index b42ee134..bd3a1da8 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,8 @@ "@rc-component/select": "^1.8.0", "rc-test": "^7.1.3", "react": "^18.3.1", - "react-dom": "^18.3.1" + "react-dom": "^18.3.1", + "typescript": "^5.9.3" }, "peerDependencies": { "react": ">=16.9.0", From d5c9805cc4e259b35f818e43e6aff8cc585fdd95 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 19:13:40 +0800 Subject: [PATCH 28/36] chore: align father config and Chinese README --- .fatherrc.ts | 5 +++++ README.zh-CN.md | 2 +- tsconfig.json | 28 +++++----------------------- 3 files changed, 11 insertions(+), 24 deletions(-) create mode 100644 .fatherrc.ts diff --git a/.fatherrc.ts b/.fatherrc.ts new file mode 100644 index 00000000..96268ae1 --- /dev/null +++ b/.fatherrc.ts @@ -0,0 +1,5 @@ +import { defineConfig } from 'father'; + +export default defineConfig({ + plugins: ['@rc-component/father-plugin'], +}); diff --git a/README.zh-CN.md b/README.zh-CN.md index 38d4ba87..f9da3f45 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -89,7 +89,7 @@ npm start | pageSizeOptions | `number[]` | - | 页面大小选项。 | | prefixCls | `string` | `rc-pagination` | className 前缀。 | | prevIcon | `ReactNode \| ComponentType` | - | 自定义上一个图标。 | -| role | `React.AriaRole` | - | WAI-ARIA role. | +| role | `React.AriaRole` | - | WAI-ARIA 角色。 | | selectPrefixCls | `string` | `rc-select` | 尺寸变换器选择的前缀。 | | showLessItems | `boolean` | `false` | 显示较少的页面项目。 | | showPrevNextJumpers | `boolean` | `true` | 显示上一个和下一个跳线。 | diff --git a/tsconfig.json b/tsconfig.json index 832143be..3b97dca2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,30 +8,12 @@ "skipLibCheck": true, "esModuleInterop": true, "paths": { - "@/*": [ - "src/*" - ], - "@@/*": [ - ".dumi/tmp/*" - ], - "@rc-component/pagination": [ - "src/index.ts" - ] + "@/*": ["src/*"], + "@@/*": [".dumi/tmp/*"], + "@rc-component/pagination": ["src/index.ts"] }, "ignoreDeprecations": "5.0" }, - "include": [ - ".dumirc.ts", - "src", - "docs", - "tests" - ], - "exclude": [ - "node_modules", - "lib", - "es", - "dist", - "docs-dist", - ".dumi" - ] + "include": [".dumirc.ts", ".fatherrc.ts", "src", "docs", "tests"], + "exclude": ["node_modules", "lib", "es", "dist", "docs-dist", ".dumi"] } From 3a584e52fdb497a0dddeb176efac8a7941b55921 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 19:38:49 +0800 Subject: [PATCH 29/36] docs: document dumi dev server port --- README.md | 4 ++-- README.zh-CN.md | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fbf80608..e04ee51b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@

English | 简体中文

-
[![NPM version][npm-image]][npm-url] @@ -18,7 +17,6 @@
- ## Highlights - Controlled and uncontrolled pagination state. @@ -120,6 +118,8 @@ npm run compile npm run build ``` +The dumi site runs at `http://localhost:8000` by default. + ## Release ```bash diff --git a/README.zh-CN.md b/README.zh-CN.md index f9da3f45..053a2ee7 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -118,6 +118,8 @@ npm run compile npm run build ``` +dumi 站点默认运行在 `http://localhost:8000`。 + ## 发布 ```bash From 4fc1c47437e62a06eef457f25313583367a35afa Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 19:58:06 +0800 Subject: [PATCH 30/36] chore: standardize husky configuration --- .husky/pre-commit | 2 +- package.json | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index c27d8893..2312dc58 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1 +1 @@ -lint-staged +npx lint-staged diff --git a/package.json b/package.json index bd3a1da8..94d3bb93 100644 --- a/package.json +++ b/package.json @@ -109,9 +109,7 @@ "mode": "npm" }, "lint-staged": { - "**/*.{js,jsx,tsx,ts,md,json}": [ - "prettier --write --ignore-unknown" - ] + "*": "prettier --write --ignore-unknown" }, "publishConfig": { "access": "public" From baa343bb2530277c47e4220636df5aaa228754fe Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 20:06:35 +0800 Subject: [PATCH 31/36] docs: align readme badge layout --- README.md | 33 +++++++++------------------------ README.zh-CN.md | 33 +++++++++------------------------ 2 files changed, 18 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index e04ee51b..d767ccff 100644 --- a/README.md +++ b/README.md @@ -2,21 +2,19 @@

@rc-component/pagination

Ant Design Part of the Ant Design ecosystem.

📄 React pagination primitives for page navigation, size changing, quick jumping, and locale-aware controls.

+ +

+ NPM version + npm downloads + build status + Codecov + bundle size + dumi +

English | 简体中文

-
- -[![NPM version][npm-image]][npm-url] -[![npm download][download-image]][download-url] -[![build status][github-actions-image]][github-actions-url] -[![Codecov][codecov-image]][codecov-url] -[![bundle size][bundlephobia-image]][bundlephobia-url] -[![dumi][dumi-image]][dumi-url] - -
- ## Highlights - Controlled and uncontrolled pagination state. @@ -131,16 +129,3 @@ The release flow is handled by `@rc-component/np` through the `rc-np` command af ## License @rc-component/pagination is released under the [MIT](./LICENSE) license. - -[npm-image]: https://img.shields.io/npm/v/@rc-component/pagination.svg?style=flat-square -[npm-url]: https://npmjs.org/package/@rc-component/pagination -[github-actions-image]: https://github.com/react-component/pagination/actions/workflows/react-component-ci.yml/badge.svg -[github-actions-url]: https://github.com/react-component/pagination/actions/workflows/react-component-ci.yml -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/pagination/master.svg?style=flat-square -[codecov-url]: https://app.codecov.io/gh/react-component/pagination -[download-image]: https://img.shields.io/npm/dm/@rc-component/pagination.svg?style=flat-square -[download-url]: https://npmjs.org/package/@rc-component/pagination -[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/pagination -[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/pagination -[dumi-url]: https://github.com/umijs/dumi -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square diff --git a/README.zh-CN.md b/README.zh-CN.md index 053a2ee7..38dde12a 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -2,21 +2,19 @@

@rc-component/pagination

Ant Design Ant Design 生态的一部分。

📄 React 分页组件,支持页码、快速跳转、尺寸切换和本地化。

+ +

+ NPM version + npm downloads + build status + Codecov + bundle size + dumi +

English | 简体中文

-
- -[![NPM version][npm-image]][npm-url] -[![npm download][download-image]][download-url] -[![build status][github-actions-image]][github-actions-url] -[![Codecov][codecov-image]][codecov-url] -[![bundle size][bundlephobia-image]][bundlephobia-url] -[![dumi][dumi-image]][dumi-url] - -
- ## 特性 - 受控和非受控分页状态。 @@ -131,16 +129,3 @@ npm run prepublishOnly ## 许可证 @rc-component/pagination 基于 [MIT](./LICENSE) 许可证发布。 - -[npm-image]: https://img.shields.io/npm/v/@rc-component/pagination.svg?style=flat-square -[npm-url]: https://npmjs.org/package/@rc-component/pagination -[github-actions-image]: https://github.com/react-component/pagination/actions/workflows/react-component-ci.yml/badge.svg -[github-actions-url]: https://github.com/react-component/pagination/actions/workflows/react-component-ci.yml -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/pagination/master.svg?style=flat-square -[codecov-url]: https://app.codecov.io/gh/react-component/pagination -[download-image]: https://img.shields.io/npm/dm/@rc-component/pagination.svg?style=flat-square -[download-url]: https://npmjs.org/package/@rc-component/pagination -[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/pagination -[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/pagination -[dumi-url]: https://github.com/umijs/dumi -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square From f2c630310c85591fbb23c9511386dc015ad92f5e Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 21:00:45 +0800 Subject: [PATCH 32/36] docs: normalize readme badges --- README.md | 2 +- README.zh-CN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d767ccff..71d2b5c8 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ npm downloads build status Codecov - bundle size + bundle size dumi

diff --git a/README.zh-CN.md b/README.zh-CN.md index 38dde12a..21bbfd08 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -8,7 +8,7 @@ npm downloads build status Codecov - bundle size + bundle size dumi

From 37447e2849c3341e9494c867e6e90f708d40d668 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 21:20:28 +0800 Subject: [PATCH 33/36] ci: limit reusable workflow secrets --- .github/workflows/react-component-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index 9503b960..36dacae4 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -5,4 +5,5 @@ permissions: jobs: test: uses: react-component/rc-test/.github/workflows/test-utoo.yml@main - secrets: inherit + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From ec5408c3de7f36c901921a81bab5608a2ef37b44 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 21:33:15 +0800 Subject: [PATCH 34/36] ci: restore reusable workflow compatibility --- .github/workflows/react-component-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index 36dacae4..9503b960 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -5,5 +5,4 @@ permissions: jobs: test: uses: react-component/rc-test/.github/workflows/test-utoo.yml@main - secrets: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + secrets: inherit From 4f798f605755b2d877568ebbe46cf50f959e1b55 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 29 Jun 2026 00:59:50 +0800 Subject: [PATCH 35/36] ci: narrow surge preview permissions --- .github/workflows/surge-preview.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index eaff160a..4c2f17ed 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -11,7 +11,6 @@ permissions: contents: read pull-requests: write checks: write - statuses: write jobs: preview: From 3f40ee5c4a1be55ff84498fb9db04efbac35df61 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 29 Jun 2026 14:25:52 +0800 Subject: [PATCH 36/36] chore: limit reusable workflow secrets --- .github/workflows/react-component-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index 9503b960..36dacae4 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -5,4 +5,5 @@ permissions: jobs: test: uses: react-component/rc-test/.github/workflows/test-utoo.yml@main - secrets: inherit + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}