From 71b8c55c69aad5520c8e65cd4fe57b8dd9150b21 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 13:56:16 +0800 Subject: [PATCH 01/39] chore: standardize repository config --- .github/FUNDING.yml | 17 +- .../workflows/cloudflare-pages-preview.yml | 42 ++ .github/workflows/codeql.yml | 22 +- .github/workflows/react-component-ci.yml | 2 +- .github/workflows/react-doctor.yml | 27 ++ .github/workflows/surge-preview.yml | 39 ++ .gitignore | 3 +- README.md | 376 +++++++----------- package.json | 10 +- tsconfig.json | 3 +- vercel.json | 6 + 11 files changed, 273 insertions(+), 274 deletions(-) create mode 100644 .github/workflows/cloudflare-pages-preview.yml create mode 100644 .github/workflows/react-doctor.yml create mode 100644 .github/workflows/surge-preview.yml create mode 100644 vercel.json 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/workflows/cloudflare-pages-preview.yml b/.github/workflows/cloudflare-pages-preview.yml new file mode 100644 index 00000000..d925f518 --- /dev/null +++ b/.github/workflows/cloudflare-pages-preview.yml @@ -0,0 +1,42 @@ +name: Cloudflare Pages Preview + +on: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +permissions: + contents: read + deployments: write + +jobs: + preview: + runs-on: ubuntu-latest + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_PAGES_PROJECT: ${{ vars.CLOUDFLARE_PAGES_PROJECT }} + PREVIEW: true + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + with: + persist-credentials: false + - name: Skip Cloudflare Pages preview + if: ${{ env.CLOUDFLARE_API_TOKEN == '' || env.CLOUDFLARE_ACCOUNT_ID == '' || env.CLOUDFLARE_PAGES_PROJECT == '' }} + run: echo "Cloudflare Pages preview is not configured; skip deployment." + - name: Install dependencies + if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} + run: npm install + - name: Build site + if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} + run: npm run build + - name: Deploy preview + if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} + uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 + with: + apiToken: ${{ env.CLOUDFLARE_API_TOKEN }} + accountId: ${{ env.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy docs-dist --project-name=${{ env.CLOUDFLARE_PAGES_PROJECT }} --branch=${{ github.head_ref }} + gitHubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 7c5e0671..d21c1b2d 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: "19 0 * * 4" + - cron: '19 0 * * 4' 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/react-component-ci.yml b/.github/workflows/react-component-ci.yml index 7b1f97cb..f8482b63 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -3,4 +3,4 @@ on: [push, pull_request] jobs: test: uses: react-component/rc-test/.github/workflows/test-utoo.yml@main - secrets: inherit \ No newline at end of file + 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 e44962a4..f774ac03 100755 --- a/.gitignore +++ b/.gitignore @@ -40,4 +40,5 @@ docs-dist/ .dumi/tmp .dumi/tmp-production -bun.lockb \ No newline at end of file +bun.lockb +.vercel diff --git a/README.md b/README.md index 64aee149..ab83dfbe 100644 --- a/README.md +++ b/README.md @@ -1,277 +1,169 @@ -# @rc-component/input-number +
+

@rc-component/input-number

+

🔢 Accessible React number input with precision, formatting, keyboard, and wheel support.

+
-Input number control. +
-[![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] +[![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] -[npm-image]: http://img.shields.io/npm/v/@rc-component/input-number.svg?style=flat-square -[npm-url]: http://npmjs.org/package/@rc-component/input-number -[travis-image]: https://img.shields.io/travis/react-component/input-number/master?style=flat-square -[travis-url]: https://travis-ci.com/react-component/input-number -[github-actions-image]: https://github.com/react-component/input-number/actions/workflows/react-component-ci.yml/badge.svg -[github-actions-url]: https://github.com/react-component/input-number/actions/workflows/react-component-ci.yml -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/input-number/master.svg?style=flat-square -[codecov-url]: https://app.codecov.io/gh/react-component/input-number -[david-url]: https://david-dm.org/react-component/input-number -[david-image]: https://david-dm.org/react-component/input-number/status.svg?style=flat-square -[david-dev-url]: https://david-dm.org/react-component/input-number?type=dev -[david-dev-image]: https://david-dm.org/react-component/input-number/dev-status.svg?style=flat-square -[download-image]: https://img.shields.io/npm/dm/@rc-component/input-number.svg?style=flat-square -[download-url]: https://npmjs.org/package/@rc-component/input-number -[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/input-number -[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/input-number -[dumi-url]: https://github.com/umijs/dumi -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square +
+ +
+ + Part of the Ant Design ecosystem + Ant Design + +
-## Screenshots +## Highlights - +- Controlled and uncontrolled numeric input modes. +- Decimal precision, custom parser, formatter, and decimal separator support. +- Keyboard stepping, mouse wheel stepping, and custom step handlers. +- Prefix, suffix, spinner controls, and semantic `classNames` / `styles` slots. +- TypeScript generic value typing for number and string based value flows. ## Install -[![@rc-component/input-number](https://nodei.co/npm/@rc-component/input-number.png)](https://npmjs.org/package/@rc-component/input-number) +```bash +npm install @rc-component/input-number +``` ## Usage -```js +```tsx | pure import InputNumber from '@rc-component/input-number'; -export default () => ; +export default () => ; ``` -## Development +```tsx | pure +import InputNumber from '@rc-component/input-number'; +export default () => ( + `$ ${value}`} + parser={(displayValue) => displayValue?.replace(/\$\s?/g, '') || ''} + /> +); ``` + +## Examples + +Run the examples locally: + +```bash npm install npm start ``` -## Example +Online preview: https://input-number.vercel.app/ -http://127.0.0.1:8000/examples/ +## API -online example: https://input-number.vercel.app/ +### InputNumber + +| Property | Type | Default | Description | +| --- | --- | --- | --- | +| autoFocus | `boolean` | `false` | Focus the input when mounted. | +| changeOnBlur | `boolean` | `true` | Commit value changes on blur. | +| changeOnWheel | `boolean` | `false` | Allow value changes from the mouse wheel. | +| className | `string` | - | Class name for the root element. | +| classNames | `Partial>` | - | Semantic class names for input-number slots. | +| controls | `boolean` | `true` | Show increment and decrement controls. | +| decimalSeparator | `string` | - | Decimal separator used by the display formatter. | +| defaultValue | `T` | - | Initial value. | +| disabled | `boolean` | `false` | Disable the input. | +| downHandler | `ReactNode` | - | Custom decrement control. | +| formatter | `(value: T \| undefined, info: { userTyping: boolean; input: string }) => string` | - | Format the displayed value. | +| inputMode | `string` | - | Native input `inputMode` attribute. | +| keyboard | `boolean` | `true` | Enable keyboard stepping. | +| max | `T` | - | Maximum value. | +| min | `T` | - | Minimum value. | +| mode | `'input' \| 'spinner'` | `input` | Render mode. | +| parser | `(displayValue: string \| undefined) => T` | - | Parse the displayed value back to a value. | +| precision | `number` | - | Display precision. | +| prefix | `ReactNode` | - | Prefix content. | +| prefixCls | `string` | `rc-input-number` | Class name prefix. | +| readOnly | `boolean` | `false` | Mark the input as read only. | +| step | `number \| string` | `1` | Step size. | +| stringMode | `boolean` | `false` | Keep values as strings for high precision decimals. | +| style | `React.CSSProperties` | - | Inline styles for the root element. | +| styles | `Partial>` | - | Semantic styles for input-number slots. | +| suffix | `ReactNode` | - | Suffix content. | +| upHandler | `ReactNode` | - | Custom increment control. | +| value | `T \| null` | - | Controlled value. | +| onChange | `(value: T \| null) => void` | - | Triggered when the committed value changes. | +| onInput | `(text: string) => void` | - | Triggered when the raw input text changes. | +| onPressEnter | `React.KeyboardEventHandler` | - | Triggered when Enter is pressed. | +| onStep | `(value: T, info: { offset: ValueType; type: 'up' \| 'down'; emitter: 'handler' \| 'keyboard' \| 'wheel' }) => void` | - | Triggered when the value changes by step. | + +Native input attributes such as `id`, `name`, `placeholder`, `required`, `readOnly`, and `tabIndex` are also supported unless explicitly overridden above. + +### Ref + +```tsx | pure +import InputNumber, { type InputNumberRef } from '@rc-component/input-number'; + +const ref = React.useRef(null); + +ref.current?.focus(); +ref.current?.blur(); +``` -## API +| Property | Type | Description | +| ------------- | --------------------------------------- | -------------------- | +| focus | `(options?: InputFocusOptions) => void` | Focus the input. | +| blur | `() => void` | Blur the input. | +| nativeElement | `HTMLElement` | Root native element. | -### props - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
nametypedefaultdescription
prefixClsstringrc-input-numberSpecifies the class prefix
minNumberSpecifies the minimum value
onClick
placeholderstring
maxNumberSpecifies the maximum value
stepNumber or String1Specifies the legal number intervals
precisionNumberSpecifies the precision length of value
disabledBooleanfalseSpecifies that an InputNumber should be disabled
requiredBooleanfalseSpecifies that an InputNumber is required
autoFocusBooleanfalseSpecifies that an InputNumber should automatically get focus when the page loads
readOnlyBooleanfalseSpecifies that an InputNumber is read only
controlsBooleantrueWhether to enable the control buttons
nameStringSpecifies the name of an InputNumber
idStringSpecifies the id of an InputNumber
valueNumberSpecifies the value of an InputNumber
defaultValueNumberSpecifies the defaultValue of an InputNumber
onChangeFunctionCalled when value of an InputNumber changed
onBlurFunctionCalled when user leaves an input field
onPressEnterFunctionThe callback function that is triggered when Enter key is pressed.
onFocusFunctionCalled when an element gets focus
styleObjectroot style. such as {width:100}
upHandlerReact.Nodecustom the up step element
downHandlerReact.Nodecustom the down step element
formatter(value: number|string): displayValue: stringSpecifies the format of the value presented
parser(displayValue: string) => value: number`input => input.replace(/[^\w\.-]*/g, '')`Specifies the value extracted from formatter
patternstringSpecifies a regex pattern to be added to the input number element - useful for forcing iOS to open the number pad instead of the normal keyboard (supply a regex of "\d*" to do this) or form validation
decimalSeparatorstringSpecifies the decimal separator
inputModestringSpecifies the inputmode of input
wheelBooleantrueAllows changing value with mouse wheel
- -## Keyboard Navigation -* When you hit the or key, the input value will be increased or decreased by `step` -* With the Shift key (Shift+⬆, Shift+⬇), the input value will be changed by `10 * step` -* With the Ctrl or key (Ctrl+⬆ or ⌘+⬆ or Ctrl+⬇ or ⌘+⬇ ), the input value will be changed by `0.1 * step` - -## Mouse Wheel -* When you scroll up or down, the input value will be increased or decreased by `step` -* Scrolling with the Shift key, the input value will be changed by `10 * step` - -## Test Case +## Keyboard And Wheel -``` +- Arrow up and Arrow down change the value by `step`. +- `Shift + Arrow` changes the value by `10 * step`. +- `Ctrl` / `Command + Arrow` changes the value by `0.1 * step`. +- Mouse wheel changes are opt-in through `changeOnWheel`. + +## Development + +```bash +npm install +npm start npm test -npm run chrome-test +npm run tsc +npm run compile +npm run build ``` -## Coverage +## Release -``` -npm run coverage +The package is published with [`@rc-component/np`](https://github.com/react-component/np): + +```bash +npm run prepublishOnly ``` -open coverage/ dir +This runs the package build before the release helper. ## License -@rc-component/input-number is released under the MIT license. +`@rc-component/input-number` is released under the MIT license. + +[npm-image]: https://img.shields.io/npm/v/@rc-component/input-number.svg?style=flat-square +[npm-url]: https://npmjs.org/package/@rc-component/input-number +[github-actions-image]: https://github.com/react-component/input-number/actions/workflows/react-component-ci.yml/badge.svg +[github-actions-url]: https://github.com/react-component/input-number/actions/workflows/react-component-ci.yml +[codecov-image]: https://img.shields.io/codecov/c/github/react-component/input-number/master.svg?style=flat-square +[codecov-url]: https://app.codecov.io/gh/react-component/input-number +[download-image]: https://img.shields.io/npm/dm/@rc-component/input-number.svg?style=flat-square +[download-url]: https://npmjs.org/package/@rc-component/input-number +[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/input-number +[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/@rc-component/input-number?style=flat-square +[dumi-url]: https://github.com/umijs/dumi +[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square diff --git a/package.json b/package.json index 37963cab..bddfdb58 100644 --- a/package.json +++ b/package.json @@ -27,21 +27,23 @@ "assets/*.css" ], "scripts": { + "build": "npm run docs:build", "compile": "father build && lessc assets/index.less assets/index.css", "coverage": "rc-test --coverage", "docs:build": "dumi build", "docs:deploy": "gh-pages -d docs-dist", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", + "now-build": "npm run docs:build", "prepare": "husky install", "prepublishOnly": "npm run compile && rc-np", - "prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"", + "prettier": "prettier --write --ignore-unknown .", "start": "dumi dev", - "test": "rc-test" + "test": "rc-test", + "tsc": "tsc --noEmit" }, "lint-staged": { "**/*.{js,jsx,tsx,ts,md,json}": [ - "prettier --write", - "git add" + "prettier --write --ignore-unknown" ] }, "dependencies": { diff --git a/tsconfig.json b/tsconfig.json index 172aabc3..f3fa8fe9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,5 +12,6 @@ "@@/*": ["src/.umi/*"], "@rc-component/input-number": ["src/index.ts"] } - } + }, + "include": [".dumirc.ts", "**/*.ts", "**/*.tsx"] } diff --git a/vercel.json b/vercel.json new file mode 100644 index 00000000..5f9139ef --- /dev/null +++ b/vercel.json @@ -0,0 +1,6 @@ +{ + "framework": "umijs", + "installCommand": "npm install", + "buildCommand": "npm run build", + "outputDirectory": "docs-dist" +} From 7319259cb721b120419f32604278be27230f8ea0 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 14:00:32 +0800 Subject: [PATCH 02/39] chore: address review feedback --- README.md | 2 +- tsconfig.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ab83dfbe..0077baee 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ Online preview: https://input-number.vercel.app/ | onChange | `(value: T \| null) => void` | - | Triggered when the committed value changes. | | onInput | `(text: string) => void` | - | Triggered when the raw input text changes. | | onPressEnter | `React.KeyboardEventHandler` | - | Triggered when Enter is pressed. | -| onStep | `(value: T, info: { offset: ValueType; type: 'up' \| 'down'; emitter: 'handler' \| 'keyboard' \| 'wheel' }) => void` | - | Triggered when the value changes by step. | +| onStep | `(value: T, info: { offset: number \| string; type: 'up' \| 'down'; emitter: 'handler' \| 'keyboard' \| 'wheel' }) => void` | - | Triggered when the value changes by step. | Native input attributes such as `id`, `name`, `placeholder`, `required`, `readOnly`, and `tabIndex` are also supported unless explicitly overridden above. diff --git a/tsconfig.json b/tsconfig.json index f3fa8fe9..626ea838 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,5 +13,6 @@ "@rc-component/input-number": ["src/index.ts"] } }, - "include": [".dumirc.ts", "**/*.ts", "**/*.tsx"] + "include": [".dumirc.ts", "**/*.ts", "**/*.tsx"], + "exclude": ["node_modules", "lib", "es", "dist", "docs-dist", ".dumi/tmp"] } From afd83c5c066684c6290e4b1f6ef441bfa7575e07 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 14:11:16 +0800 Subject: [PATCH 03/39] chore: limit workflow token permissions --- .github/workflows/react-component-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml index f8482b63..9503b960 100644 --- a/.github/workflows/react-component-ci.yml +++ b/.github/workflows/react-component-ci.yml @@ -1,5 +1,7 @@ name: ✅ test on: [push, pull_request] +permissions: + contents: read jobs: test: uses: react-component/rc-test/.github/workflows/test-utoo.yml@main From 94c900f43703269111519704ea298b940b72dacd Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 26 Jun 2026 15:04:08 +0800 Subject: [PATCH 04/39] chore: remove cloudflare preview and now-build --- .../workflows/cloudflare-pages-preview.yml | 42 ------------------- package.json | 1 - 2 files changed, 43 deletions(-) delete mode 100644 .github/workflows/cloudflare-pages-preview.yml diff --git a/.github/workflows/cloudflare-pages-preview.yml b/.github/workflows/cloudflare-pages-preview.yml deleted file mode 100644 index d925f518..00000000 --- a/.github/workflows/cloudflare-pages-preview.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Cloudflare Pages Preview - -on: - pull_request: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number }} - cancel-in-progress: true - -permissions: - contents: read - deployments: write - -jobs: - preview: - runs-on: ubuntu-latest - env: - CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} - CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - CLOUDFLARE_PAGES_PROJECT: ${{ vars.CLOUDFLARE_PAGES_PROJECT }} - PREVIEW: true - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 - with: - persist-credentials: false - - name: Skip Cloudflare Pages preview - if: ${{ env.CLOUDFLARE_API_TOKEN == '' || env.CLOUDFLARE_ACCOUNT_ID == '' || env.CLOUDFLARE_PAGES_PROJECT == '' }} - run: echo "Cloudflare Pages preview is not configured; skip deployment." - - name: Install dependencies - if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} - run: npm install - - name: Build site - if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} - run: npm run build - - name: Deploy preview - if: ${{ env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != '' && env.CLOUDFLARE_PAGES_PROJECT != '' }} - uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 - with: - apiToken: ${{ env.CLOUDFLARE_API_TOKEN }} - accountId: ${{ env.CLOUDFLARE_ACCOUNT_ID }} - command: pages deploy docs-dist --project-name=${{ env.CLOUDFLARE_PAGES_PROJECT }} --branch=${{ github.head_ref }} - gitHubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index bddfdb58..b25b0216 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ "docs:build": "dumi build", "docs:deploy": "gh-pages -d docs-dist", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", - "now-build": "npm run docs:build", "prepare": "husky install", "prepublishOnly": "npm run compile && rc-np", "prettier": "prettier --write --ignore-unknown .", From a0e0a3b3b7490a5653e8fe666bc4ae7f1046c8ab Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 00:41:57 +0800 Subject: [PATCH 05/39] 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 0077baee..e9619f34 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@

@rc-component/input-number

+ Ant Design

🔢 Accessible React number input with precision, formatting, keyboard, and wheel support.

From 97aa6b5fc92faece908edd2e73f1d925883cc512 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 01:56:47 +0800 Subject: [PATCH 06/39] docs: standardize README release details --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e9619f34..b49c9ef0 100644 --- a/README.md +++ b/README.md @@ -144,17 +144,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/input-number` is released under the MIT license. +@rc-component/input-number is released under the [MIT](./LICENSE.md) license. [npm-image]: https://img.shields.io/npm/v/@rc-component/input-number.svg?style=flat-square [npm-url]: https://npmjs.org/package/@rc-component/input-number From 59fbf0df9642488c573ca65234e759ce71cae57c Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:13:57 +0800 Subject: [PATCH 07/39] 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 4881d5835f9c9bb60853fcfd61a3b9adca6f033f Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:17:43 +0800 Subject: [PATCH 08/39] docs: clarify Ant Design ecosystem note --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index b49c9ef0..90b5ac5c 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,15 @@

🔢 Accessible React number input with precision, formatting, keyboard, and wheel support.

+

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

+
[![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] From 85903b85cbd6836ba6bc7d42a6de221bd7105e0b Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 02:25:41 +0800 Subject: [PATCH 09/39] 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 63dc94c720c78c2286e2a33b75f11234b87914dd Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 13:04:00 +0800 Subject: [PATCH 10/39] docs: refine README usage and ecosystem note --- README.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/README.md b/README.md index 90b5ac5c..4924d8fe 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,10 @@

@rc-component/input-number

+

Part of the Ant Design ecosystem.

Ant Design

🔢 Accessible React number input with precision, formatting, keyboard, and wheel support.

-

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

From 7af3cb367bebee0cf3891b566a9f98925cb6d433 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 13:22:15 +0800 Subject: [PATCH 11/39] 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 eb63e60c73d7323234facd086cdfe433551d5030 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 13:50:46 +0800 Subject: [PATCH 12/39] chore: address review comments --- README.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/README.md b/README.md index 4924d8fe..566d4a41 100644 --- a/README.md +++ b/README.md @@ -12,16 +12,6 @@
-
- - Part of the Ant Design ecosystem - Ant Design - -
## Highlights From eafc0c3c68f2835a325fcad7532db4da0c1f3186 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 22:00:44 +0800 Subject: [PATCH 13/39] docs: update Ant Design logo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 566d4a41..152b64dc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

@rc-component/input-number

Part of the Ant Design ecosystem.

- Ant Design + Ant Design

🔢 Accessible React number input with precision, formatting, keyboard, and wheel support.

From 32211dd2802bcb651009888aac63054b95ae0a02 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 22:19:33 +0800 Subject: [PATCH 14/39] docs: add Chinese README --- README.md | 2 + README.zh-CN.md | 162 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 164 insertions(+) create mode 100644 README.zh-CN.md diff --git a/README.md b/README.md index 152b64dc..81824831 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@

🔢 Accessible React number input with precision, formatting, keyboard, and wheel support.

+

English | 简体中文

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

@rc-component/input-number

+

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 numeric input modes. +- Decimal precision, custom parser, formatter, and decimal separator support. +- Keyboard stepping, mouse wheel stepping, and custom step handlers. +- Prefix, suffix, spinner controls, and semantic `classNames` / `styles` slots. +- TypeScript generic value typing for number and string based value flows. + +## 安装 + +```bash +npm install @rc-component/input-number +``` + +## 使用 + +```tsx | pure +import InputNumber from '@rc-component/input-number'; + +export default () => ; +``` + +```tsx | pure +import InputNumber from '@rc-component/input-number'; + +export default () => ( + `$ ${value}`} + parser={(displayValue) => displayValue?.replace(/\$\s?/g, '') || ''} + /> +); +``` + +## 示例 + +本地运行示例: + +```bash +npm install +npm start +``` + +Online preview: https://input-number.vercel.app/ + +## API + +### InputNumber + +| 参数 | 类型 | 默认值 | 说明 | +| --- | --- | --- | --- | +| autoFocus | `boolean` | `false` | Focus the input when mounted. | +| changeOnBlur | `boolean` | `true` | Commit value changes on blur. | +| changeOnWheel | `boolean` | `false` | Allow value changes from the mouse wheel. | +| className | `string` | - | Class name for the root element. | +| classNames | `Partial>` | - | Semantic class names for input-number slots. | +| controls | `boolean` | `true` | Show increment and decrement controls. | +| decimalSeparator | `string` | - | Decimal separator used by the display formatter. | +| defaultValue | `T` | - | Initial value. | +| disabled | `boolean` | `false` | Disable the input. | +| downHandler | `ReactNode` | - | Custom decrement control. | +| formatter | `(value: T \| undefined, info: { userTyping: boolean; input: string }) => string` | - | Format the displayed value. | +| inputMode | `string` | - | Native input `inputMode` attribute. | +| keyboard | `boolean` | `true` | Enable keyboard stepping. | +| max | `T` | - | Maximum value. | +| min | `T` | - | Minimum value. | +| mode | `'input' \| 'spinner'` | `input` | Render mode. | +| parser | `(displayValue: string \| undefined) => T` | - | Parse the displayed value back to a value. | +| precision | `number` | - | Display precision. | +| prefix | `ReactNode` | - | Prefix content. | +| prefixCls | `string` | `rc-input-number` | Class name prefix. | +| readOnly | `boolean` | `false` | Mark the input as read only. | +| step | `number \| string` | `1` | Step size. | +| stringMode | `boolean` | `false` | Keep values as strings for high precision decimals. | +| style | `React.CSSProperties` | - | Inline styles for the root element. | +| styles | `Partial>` | - | Semantic styles for input-number slots. | +| suffix | `ReactNode` | - | Suffix content. | +| upHandler | `ReactNode` | - | Custom increment control. | +| value | `T \| null` | - | Controlled value. | +| onChange | `(value: T \| null) => void` | - | Triggered when the committed value changes. | +| onInput | `(text: string) => void` | - | Triggered when the raw input text changes. | +| onPressEnter | `React.KeyboardEventHandler` | - | Triggered when Enter is pressed. | +| onStep | `(value: T, info: { offset: number \| string; type: 'up' \| 'down'; emitter: 'handler' \| 'keyboard' \| 'wheel' }) => void` | - | Triggered when the value changes by step. | + +Native input attributes such as `id`, `name`, `placeholder`, `required`, `readOnly`, and `tabIndex` are also supported unless explicitly overridden above. + +### Ref + +```tsx | pure +import InputNumber, { type InputNumberRef } from '@rc-component/input-number'; + +const ref = React.useRef(null); + +ref.current?.focus(); +ref.current?.blur(); +``` + +| 参数 | 类型 | 说明 | +| ------------- | --------------------------------------- | -------------------- | +| focus | `(options?: InputFocusOptions) => void` | Focus the input. | +| blur | `() => void` | Blur the input. | +| nativeElement | `HTMLElement` | Root native element. | + +## Keyboard And Wheel + +- Arrow up and Arrow down change the value by `step`. +- `Shift + Arrow` changes the value by `10 * step`. +- `Ctrl` / `Command + Arrow` changes the value by `0.1 * step`. +- Mouse wheel changes are opt-in through `changeOnWheel`. + +## 本地开发 + +```bash +npm install +npm start +npm test +npm run tsc +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/input-number is released under the [MIT](./LICENSE.md) license. + +[npm-image]: https://img.shields.io/npm/v/@rc-component/input-number.svg?style=flat-square +[npm-url]: https://npmjs.org/package/@rc-component/input-number +[github-actions-image]: https://github.com/react-component/input-number/actions/workflows/react-component-ci.yml/badge.svg +[github-actions-url]: https://github.com/react-component/input-number/actions/workflows/react-component-ci.yml +[codecov-image]: https://img.shields.io/codecov/c/github/react-component/input-number/master.svg?style=flat-square +[codecov-url]: https://app.codecov.io/gh/react-component/input-number +[download-image]: https://img.shields.io/npm/dm/@rc-component/input-number.svg?style=flat-square +[download-url]: https://npmjs.org/package/@rc-component/input-number +[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/input-number +[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/@rc-component/input-number?style=flat-square +[dumi-url]: https://github.com/umijs/dumi +[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square From fc3d5f455d8851d8f54cd6857d3eaa3462879237 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 27 Jun 2026 23:03:10 +0800 Subject: [PATCH 15/39] docs: refine bilingual README branding --- README.md | 3 +- README.zh-CN.md | 99 ++++++++++++++++++++++++------------------------- 2 files changed, 50 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 81824831..0b142dc3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@

@rc-component/input-number

-

Part of the Ant Design ecosystem.

- Ant Design +

Ant Design Part of the Ant Design ecosystem.

🔢 Accessible React number input with precision, formatting, keyboard, and wheel support.

diff --git a/README.zh-CN.md b/README.zh-CN.md index e1d90494..a493dd16 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,7 +1,6 @@

@rc-component/input-number

-

Ant Design 生态的一部分。

- Ant Design +

Ant Design Ant Design 生态的一部分。

🔢 React 数字输入组件,支持格式化、精度、步进和键盘交互。

@@ -17,11 +16,11 @@ ## 特性 -- Controlled and uncontrolled numeric input modes. -- Decimal precision, custom parser, formatter, and decimal separator support. -- Keyboard stepping, mouse wheel stepping, and custom step handlers. -- Prefix, suffix, spinner controls, and semantic `classNames` / `styles` slots. -- TypeScript generic value typing for number and string based value flows. +- 受控和非受控数字输入模式。 +- 小数精度、自定义解析器、格式化程序和小数分隔符支持。 +- 支持键盘步进、鼠标滚轮步进和自定义步进处理。 +- 支持前缀、后缀、步进控制器和语义化 `classNames` / `styles` 插槽。 +- TypeScript 通用值类型用于基于数字和字符串的值流。 ## 安装 @@ -58,7 +57,7 @@ npm install npm start ``` -Online preview: https://input-number.vercel.app/ +在线预览:https://input-number.vercel.app/ ## API @@ -66,40 +65,40 @@ Online preview: https://input-number.vercel.app/ | 参数 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | -| autoFocus | `boolean` | `false` | Focus the input when mounted. | -| changeOnBlur | `boolean` | `true` | Commit value changes on blur. | -| changeOnWheel | `boolean` | `false` | Allow value changes from the mouse wheel. | -| className | `string` | - | Class name for the root element. | -| classNames | `Partial>` | - | Semantic class names for input-number slots. | -| controls | `boolean` | `true` | Show increment and decrement controls. | -| decimalSeparator | `string` | - | Decimal separator used by the display formatter. | -| defaultValue | `T` | - | Initial value. | -| disabled | `boolean` | `false` | Disable the input. | -| downHandler | `ReactNode` | - | Custom decrement control. | -| formatter | `(value: T \| undefined, info: { userTyping: boolean; input: string }) => string` | - | Format the displayed value. | -| inputMode | `string` | - | Native input `inputMode` attribute. | -| keyboard | `boolean` | `true` | Enable keyboard stepping. | -| max | `T` | - | Maximum value. | -| min | `T` | - | Minimum value. | -| mode | `'input' \| 'spinner'` | `input` | Render mode. | -| parser | `(displayValue: string \| undefined) => T` | - | Parse the displayed value back to a value. | +| autoFocus | `boolean` | `false` | 安装后聚焦输入。 | +| changeOnBlur | `boolean` | `true` | 提交模糊值的变化。 | +| changeOnWheel | `boolean` | `false` | 允许通过鼠标滚轮更改值。 | +| className | `string` | - | 根元素的className。 | +| classNames | `Partial>` | - | 输入数字槽的语义className称。 | +| controls | `boolean` | `true` | 显示增量和减量控件。 | +| decimalSeparator | `string` | - | 显示格式化程序使用的小数分隔符。 | +| defaultValue | `T` | - | 初始值。 | +| disabled | `boolean` | `false` | 禁用输入。 | +| downHandler | `ReactNode` | - | 自定义减量控制。 | +| formatter | `(value: T \| undefined, info: { userTyping: boolean; input: string }) => string` | - | 设置显示值的格式。 | +| inputMode | `string` | - | 本机输入 `inputMode` 属性。 | +| keyboard | `boolean` | `true` | 启用键盘步进。 | +| max | `T` | - | 最大值。 | +| min | `T` | - | 最小值。 | +| mode | `'input' \| 'spinner'` | `input` | 渲染模式。 | +| parser | `(displayValue: string \| undefined) => T` | - | 将显示的值解析回一个值。 | | precision | `number` | - | Display precision. | -| prefix | `ReactNode` | - | Prefix content. | -| prefixCls | `string` | `rc-input-number` | Class name prefix. | -| readOnly | `boolean` | `false` | Mark the input as read only. | +| 前缀 | `ReactNode` | - | 前缀内容。 | +| prefixCls | `string` | `rc-input-number` | className前缀。 | +| readOnly | `boolean` | `false` | 将输入标记为只读。 | | step | `number \| string` | `1` | Step size. | -| stringMode | `boolean` | `false` | Keep values as strings for high precision decimals. | -| style | `React.CSSProperties` | - | Inline styles for the root element. | -| styles | `Partial>` | - | Semantic styles for input-number slots. | -| suffix | `ReactNode` | - | Suffix content. | -| upHandler | `ReactNode` | - | Custom increment control. | -| value | `T \| null` | - | Controlled value. | -| onChange | `(value: T \| null) => void` | - | Triggered when the committed value changes. | -| onInput | `(text: string) => void` | - | Triggered when the raw input text changes. | -| onPressEnter | `React.KeyboardEventHandler` | - | Triggered when Enter is pressed. | -| onStep | `(value: T, info: { offset: number \| string; type: 'up' \| 'down'; emitter: 'handler' \| 'keyboard' \| 'wheel' }) => void` | - | Triggered when the value changes by step. | - -Native input attributes such as `id`, `name`, `placeholder`, `required`, `readOnly`, and `tabIndex` are also supported unless explicitly overridden above. +| stringMode | `boolean` | `false` | 将值保留为字符串以获得高精度小数。 | +| 风格 | `React.CSSProperties` | - | 根元素的内联样式。 | +| styles | `Partial>` | - | 输入数字槽的语义样式。 | +| 后缀 | `ReactNode` | - | 后缀内容。 | +| upHandler | `ReactNode` | - | 自定义增量控制。 | +| 价值 | `T \| null` | - | 受控值。 | +| onChange | `(value: T \| null) => void` | - | 当提交的值改变时触发。 | +| onInput | `(text: string) => void` | - | 当原始输入文本更改时触发。 | +| onPressEnter | `React.KeyboardEventHandler` | - | 当按下 Enter 时触发。 | +| onStep | `(value: T, info: { offset: number \| string; type: 'up' \| 'down'; emitter: 'handler' \| 'keyboard' \| 'wheel' }) => void` | - | 当值逐步变化时触发。 | + +除非上方明确覆盖,也支持 `id`, `name`, `placeholder`, `required`, `readOnly`, and `tabIndex` 等原生 input 属性。 ### Ref @@ -114,16 +113,16 @@ ref.current?.blur(); | 参数 | 类型 | 说明 | | ------------- | --------------------------------------- | -------------------- | -| focus | `(options?: InputFocusOptions) => void` | Focus the input. | -| blur | `() => void` | Blur the input. | -| nativeElement | `HTMLElement` | Root native element. | +| 重点 | `(options?: InputFocusOptions) => void` | 集中输入。 | +| 模糊 | `() => void` | 模糊输入。 | +| nativeElement | `HTMLElement` | 根原生元素。 | -## Keyboard And Wheel +## 键盘与滚轮 -- Arrow up and Arrow down change the value by `step`. -- `Shift + Arrow` changes the value by `10 * step`. -- `Ctrl` / `Command + Arrow` changes the value by `0.1 * step`. -- Mouse wheel changes are opt-in through `changeOnWheel`. +- 上箭头和下箭头会按 `step` 改变数值。 +- `Shift + Arrow` 将值更改为 `10 * step`。 +- `Ctrl` / `Command + Arrow` 将值更改为`0.1 * step`。 +- 鼠标滚轮改值需要通过 `changeOnWheel` 显式开启。 ## 本地开发 @@ -142,11 +141,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/input-number is released under the [MIT](./LICENSE.md) license. +@rc-component/input-number 基于 [MIT](./LICENSE.md) 许可证发布。 [npm-image]: https://img.shields.io/npm/v/@rc-component/input-number.svg?style=flat-square [npm-url]: https://npmjs.org/package/@rc-component/input-number From 7c64b9c46070c92d28332499dfd68d4a40b928e8 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 01:28:39 +0800 Subject: [PATCH 16/39] chore: standardize rc tooling and docs --- .dumirc.ts | 15 ++++++++++----- README.md | 4 ++-- README.zh-CN.md | 4 ++-- package.json | 38 +++++++++++++++++++------------------- tests/util/wrapper.ts | 8 +++++--- tsconfig.json | 30 ++++++++++++++++++++++++------ 6 files changed, 62 insertions(+), 37 deletions(-) diff --git a/.dumirc.ts b/.dumirc.ts index f9137735..83cdabe3 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -1,14 +1,19 @@ import { defineConfig } from 'dumi'; +const basePath = process.env.GH_PAGES ? '/input-number/' : '/'; +const publicPath = basePath; + export default defineConfig({ - favicons: [ - 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', - ], + favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], themeConfig: { name: 'InputNumber', - logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4' + logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', }, outputPath: 'docs-dist', + base: basePath, + publicPath, exportStatic: {}, - styles: [`body .dumi-default-header-left { width: 230px; } body .dumi-default-hero-title { font-size: 100px; }`], + styles: [ + `body .dumi-default-header-left { width: 230px; } body .dumi-default-hero-title { font-size: 100px; }`, + ], }); diff --git a/README.md b/README.md index 0b142dc3..441f7586 100644 --- a/README.md +++ b/README.md @@ -50,14 +50,14 @@ export default () => ( ## Examples -Run the examples locally: +Run the local dumi site: ```bash npm install npm start ``` -Online preview: https://input-number.vercel.app/ +Then open `http://localhost:8000`. ## API diff --git a/README.zh-CN.md b/README.zh-CN.md index a493dd16..94b1ffba 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -50,14 +50,14 @@ export default () => ( ## 示例 -本地运行示例: +运行本地 dumi 站点: ```bash npm install npm start ``` -在线预览:https://input-number.vercel.app/ +然后打开 `http://localhost:8000`。 ## API diff --git a/package.json b/package.json index b25b0216..c31f6ba9 100644 --- a/package.json +++ b/package.json @@ -52,31 +52,31 @@ }, "devDependencies": { "@rc-component/father-plugin": "^2.2.0", - "@rc-component/np": "^1.0.3", + "@rc-component/np": "^1.0.4", "@swc-node/jest": "^1.5.5", - "@testing-library/jest-dom": "^6.1.5", - "@testing-library/react": "^16.0.0", - "@types/jest": "^29.2.4", - "@types/node": "^24.5.2", - "@types/react": "^18.0.26", - "@types/react-dom": "^18.0.9", + "@testing-library/jest-dom": "^6.9.1", + "@testing-library/react": "^15.0.7", + "@types/jest": "^29.5.14", + "@types/node": "^26.0.1", + "@types/react": "^18.3.31", + "@types/react-dom": "^18.3.7", "@types/responselike": "^1.0.0", "@umijs/fabric": "^4.0.1", - "@umijs/test": "^4.0.36", - "dumi": "^2.0.13", - "eslint": "^8.54.0", - "father": "^4.5.5", - "glob": "^11.0.0", + "@umijs/test": "^4.6.68", + "dumi": "^2.4.35", + "eslint": "^8.57.1", + "father": "^4.6.23", + "glob": "^13.0.6", "husky": "^9.1.7", - "jest-environment-jsdom": "^29.3.1", - "less": "^4.1.3", - "lint-staged": "^15.1.0", - "rc-test": "^7.0.14", - "react": "^18.2.0", - "react-dom": "^18.2.0", + "jest-environment-jsdom": "^29.7.0", + "less": "^4.6.7", + "lint-staged": "^16.4.0", + "rc-test": "^7.1.3", + "react": "^18.3.1", + "react-dom": "^18.3.1", "regenerator-runtime": "^0.14.1", "ts-node": "^10.9.1", - "typescript": "^5.1.6" + "typescript": "^5.9.3" }, "peerDependencies": { "react": ">=16.9.0", diff --git a/tests/util/wrapper.ts b/tests/util/wrapper.ts index dd31921f..dafc2518 100644 --- a/tests/util/wrapper.ts +++ b/tests/util/wrapper.ts @@ -1,4 +1,4 @@ -import type { RenderOptions } from '@testing-library/react'; +import type { RenderOptions, RenderResult } from '@testing-library/react'; import { act, render } from '@testing-library/react'; import type { ReactElement } from 'react'; @@ -12,8 +12,10 @@ export const sleep = async (timeout = 0) => { }); }; -const customRender = (ui: ReactElement, options?: Omit) => - render(ui, { ...options }); +const customRender = ( + ui: ReactElement, + options?: Omit, +): RenderResult => render(ui, { ...options }); export * from '@testing-library/react'; export { customRender as render }; diff --git a/tsconfig.json b/tsconfig.json index 626ea838..f58a0287 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,11 +8,29 @@ "skipLibCheck": true, "esModuleInterop": true, "paths": { - "@/*": ["src/*"], - "@@/*": ["src/.umi/*"], - "@rc-component/input-number": ["src/index.ts"] - } + "@/*": [ + "src/*" + ], + "@@/*": [ + "src/.umi/*" + ], + "@rc-component/input-number": [ + "src/index.ts" + ] + }, + "ignoreDeprecations": "5.0" }, - "include": [".dumirc.ts", "**/*.ts", "**/*.tsx"], - "exclude": ["node_modules", "lib", "es", "dist", "docs-dist", ".dumi/tmp"] + "include": [ + ".dumirc.ts", + "**/*.ts", + "**/*.tsx" + ], + "exclude": [ + "node_modules", + "lib", + "es", + "dist", + "docs-dist", + ".dumi/tmp" + ] } From b98f97e53bf903bd57bb7c667e151ead46fe57e5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 02:01:05 +0800 Subject: [PATCH 17/39] chore: address standardization review comments --- .github/workflows/surge-preview.yml | 16 +++++++++++++--- package.json | 3 ++- 2 files changed, 15 insertions(+), 4 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." diff --git a/package.json b/package.json index c31f6ba9..588e96a1 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ "prettier": "prettier --write --ignore-unknown .", "start": "dumi dev", "test": "rc-test", - "tsc": "tsc --noEmit" + "tsc": "tsc --noEmit", + "docs:build:gh-pages": "GH_PAGES=1 npm run docs:build" }, "lint-staged": { "**/*.{js,jsx,tsx,ts,md,json}": [ From 2f7622c30d3a6eb64a27ee0ddc644bc7b4a8926c Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 02:10:33 +0800 Subject: [PATCH 18/39] chore: include father config in type checks --- tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tsconfig.json b/tsconfig.json index f58a0287..c9cba3fe 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,6 +21,7 @@ "ignoreDeprecations": "5.0" }, "include": [ + ".fatherrc.ts", ".dumirc.ts", "**/*.ts", "**/*.tsx" From d27ed0fd85e06b305c140db3e38af0778ad08454 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 12:23:52 +0800 Subject: [PATCH 19/39] 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 d21c1b2d..55e133c1 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 67f433d893d298fbee875a68b02da8b4aa7393dd Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 12:28:35 +0800 Subject: [PATCH 20/39] 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 55e133c1..d21c1b2d 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 d55b788f990d24c495cac43a54309ef3b20abe19 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 13:27:17 +0800 Subject: [PATCH 21/39] 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 441f7586..fe6e0a41 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,7 @@ The release flow is handled by `@rc-component/np` through the `rc-np` command af ## License -@rc-component/input-number is released under the [MIT](./LICENSE.md) license. +@rc-component/input-number is released under the [MIT](./LICENSE) license. [npm-image]: https://img.shields.io/npm/v/@rc-component/input-number.svg?style=flat-square [npm-url]: https://npmjs.org/package/@rc-component/input-number diff --git a/README.zh-CN.md b/README.zh-CN.md index 94b1ffba..2c57435b 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -145,7 +145,7 @@ npm run prepublishOnly ## 许可证 -@rc-component/input-number 基于 [MIT](./LICENSE.md) 许可证发布。 +@rc-component/input-number 基于 [MIT](./LICENSE) 许可证发布。 [npm-image]: https://img.shields.io/npm/v/@rc-component/input-number.svg?style=flat-square [npm-url]: https://npmjs.org/package/@rc-component/input-number From 82158ee41ec816e6dd217ac747f294617f1d54d7 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:00:18 +0800 Subject: [PATCH 22/39] 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 d21c1b2d..b399f316 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 f68281c8..097eb883 100644 --- a/.github/workflows/react-doctor.yml +++ b/.github/workflows/react-doctor.yml @@ -20,7 +20,7 @@ jobs: react-doctor: runs-on: ubuntu-latest 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 a944f5aecf4258bab88d4c12e6483f68b7a0a229 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:30:54 +0800 Subject: [PATCH 23/39] chore: standardize package metadata --- package.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 588e96a1..059c393d 100644 --- a/package.json +++ b/package.json @@ -8,13 +8,13 @@ "react-input-number", "input-number" ], - "homepage": "https://github.com/react-component/input-number", + "homepage": "https://react-component.github.io/input-number", "bugs": { "url": "https://github.com/react-component/input-number/issues" }, "repository": { "type": "git", - "url": "git@github.com:react-component/input-number.git" + "url": "https://github.com/react-component/input-number.git" }, "license": "MIT", "author": "tsjxyz@gmail.com", @@ -82,5 +82,8 @@ "peerDependencies": { "react": ">=16.9.0", "react-dom": ">=16.9.0" + }, + "publishConfig": { + "access": "public" } } From 90bb2b7dd15a76ebfb6342d3fa8812c41290a96b Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 14:37:18 +0800 Subject: [PATCH 24/39] ci: standardize dependabot updates --- .github/dependabot.yml | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index add01c3d..3b730ef9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,23 +1,19 @@ version: 2 updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - time: "21:00" - open-pull-requests-limit: 10 - ignore: - - dependency-name: "@types/react-dom" - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - dependency-name: "@types/react" - versions: - - 17.0.0 - - 17.0.1 - - 17.0.2 - - 17.0.3 - - dependency-name: less - versions: - - 4.1.0 + - package-ecosystem: npm + directory: '/' + schedule: + 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 From 3132e8379f69f7a1635d9ebd5b316aab6cfe84b9 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 16:26:10 +0800 Subject: [PATCH 25/39] docs: fix Chinese README API names --- README.zh-CN.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.zh-CN.md b/README.zh-CN.md index 2c57435b..c2ce590d 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -83,16 +83,16 @@ npm start | mode | `'input' \| 'spinner'` | `input` | 渲染模式。 | | parser | `(displayValue: string \| undefined) => T` | - | 将显示的值解析回一个值。 | | precision | `number` | - | Display precision. | -| 前缀 | `ReactNode` | - | 前缀内容。 | +| prefix | `ReactNode` | - | 前缀内容。 | | prefixCls | `string` | `rc-input-number` | className前缀。 | | readOnly | `boolean` | `false` | 将输入标记为只读。 | | step | `number \| string` | `1` | Step size. | | stringMode | `boolean` | `false` | 将值保留为字符串以获得高精度小数。 | -| 风格 | `React.CSSProperties` | - | 根元素的内联样式。 | +| style | `React.CSSProperties` | - | 根元素的内联样式。 | | styles | `Partial>` | - | 输入数字槽的语义样式。 | -| 后缀 | `ReactNode` | - | 后缀内容。 | +| suffix | `ReactNode` | - | 后缀内容。 | | upHandler | `ReactNode` | - | 自定义增量控制。 | -| 价值 | `T \| null` | - | 受控值。 | +| value | `T \| null` | - | 受控值。 | | onChange | `(value: T \| null) => void` | - | 当提交的值改变时触发。 | | onInput | `(text: string) => void` | - | 当原始输入文本更改时触发。 | | onPressEnter | `React.KeyboardEventHandler` | - | 当按下 Enter 时触发。 | @@ -113,8 +113,8 @@ ref.current?.blur(); | 参数 | 类型 | 说明 | | ------------- | --------------------------------------- | -------------------- | -| 重点 | `(options?: InputFocusOptions) => void` | 集中输入。 | -| 模糊 | `() => void` | 模糊输入。 | +| focus | `(options?: InputFocusOptions) => void` | 集中输入。 | +| blur | `() => void` | 模糊输入。 | | nativeElement | `HTMLElement` | 根原生元素。 | ## 键盘与滚轮 From ba60fd394849a2504c4e643e79a3388a9c1d84be Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 16:51:37 +0800 Subject: [PATCH 26/39] 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 c2ce590d..c7df8010 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -86,7 +86,7 @@ npm start | prefix | `ReactNode` | - | 前缀内容。 | | prefixCls | `string` | `rc-input-number` | className前缀。 | | readOnly | `boolean` | `false` | 将输入标记为只读。 | -| step | `number \| string` | `1` | Step size. | +| step | `number \| string` | `1` | 步长。 | | stringMode | `boolean` | `false` | 将值保留为字符串以获得高精度小数。 | | style | `React.CSSProperties` | - | 根元素的内联样式。 | | styles | `Partial>` | - | 输入数字槽的语义样式。 | From 5f1fe5d7ff65144351eb21e2a204ac95cb3fa84e Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 17:15:04 +0800 Subject: [PATCH 27/39] chore: refine preview workflow ignores --- .github/workflows/surge-preview.yml | 3 +++ .prettierignore | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 .prettierignore 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: diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..c466d872 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,14 @@ +node_modules +coverage +docs-dist +dist +es +lib +.dumi/tmp +.dumi/tmp-production +.vercel +package-lock.json +pnpm-lock.yaml +yarn.lock +bun.lockb +*.log From 9dad1c38a4a03624d7864530a3ce4b9d96e9693e Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 17:36:01 +0800 Subject: [PATCH 28/39] 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 c7df8010..df4550fb 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -68,8 +68,8 @@ npm start | autoFocus | `boolean` | `false` | 安装后聚焦输入。 | | changeOnBlur | `boolean` | `true` | 提交模糊值的变化。 | | changeOnWheel | `boolean` | `false` | 允许通过鼠标滚轮更改值。 | -| className | `string` | - | 根元素的className。 | -| classNames | `Partial>` | - | 输入数字槽的语义className称。 | +| className | `string` | - | 根元素的 className。 | +| classNames | `Partial>` | - | 输入数字槽的语义 className。 | | controls | `boolean` | `true` | 显示增量和减量控件。 | | decimalSeparator | `string` | - | 显示格式化程序使用的小数分隔符。 | | defaultValue | `T` | - | 初始值。 | @@ -84,7 +84,7 @@ npm start | parser | `(displayValue: string \| undefined) => T` | - | 将显示的值解析回一个值。 | | precision | `number` | - | Display precision. | | prefix | `ReactNode` | - | 前缀内容。 | -| prefixCls | `string` | `rc-input-number` | className前缀。 | +| prefixCls | `string` | `rc-input-number` | className 前缀。 | | readOnly | `boolean` | `false` | 将输入标记为只读。 | | step | `number \| string` | `1` | 步长。 | | stringMode | `boolean` | `false` | 将值保留为字符串以获得高精度小数。 | From 9ec5458c34f957e207d16b84221d07fc2bf6a6e0 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 18:19:24 +0800 Subject: [PATCH 29/39] chore: add missing prettier dependency --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 059c393d..d5f5e56d 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ }, "devDependencies": { "@rc-component/father-plugin": "^2.2.0", + "prettier": "^3.9.0", "@rc-component/np": "^1.0.4", "@swc-node/jest": "^1.5.5", "@testing-library/jest-dom": "^6.9.1", From a9f93047868db61a00f4e48c63196e722a4cb5e6 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 18:53:21 +0800 Subject: [PATCH 30/39] chore: add missing gh-pages dependency --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index d5f5e56d..8b57257f 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "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", "jest-environment-jsdom": "^29.7.0", From 35f10235f21c4821fdb10d1720834288e3bb5f26 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 19:13:23 +0800 Subject: [PATCH 31/39] docs: polish Chinese README wording --- 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 df4550fb..eeb8436b 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -82,7 +82,7 @@ npm start | min | `T` | - | 最小值。 | | mode | `'input' \| 'spinner'` | `input` | 渲染模式。 | | parser | `(displayValue: string \| undefined) => T` | - | 将显示的值解析回一个值。 | -| precision | `number` | - | Display precision. | +| precision | `number` | - | 显示精度。 | | prefix | `ReactNode` | - | 前缀内容。 | | prefixCls | `string` | `rc-input-number` | className 前缀。 | | readOnly | `boolean` | `false` | 将输入标记为只读。 | From 692149cc52ac6f1b214cc9df7f66073bb2f80280 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 19:38:23 +0800 Subject: [PATCH 32/39] docs: document dumi dev server port --- README.md | 2 ++ README.zh-CN.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index fe6e0a41..e7f2aa89 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,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 eeb8436b..b03272a3 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -135,6 +135,8 @@ npm run compile npm run build ``` +dumi 站点默认运行在 `http://localhost:8000`。 + ## 发布 ```bash From 01e7631b3b60b6c0fc5116c8ad549aea726acaa0 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 19:57:41 +0800 Subject: [PATCH 33/39] chore: standardize husky configuration --- .husky/pre-commit | 1 + package.json | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) create mode 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000..2312dc58 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +npx lint-staged diff --git a/package.json b/package.json index 8b57257f..d7fb3495 100644 --- a/package.json +++ b/package.json @@ -31,20 +31,18 @@ "compile": "father build && lessc assets/index.less assets/index.css", "coverage": "rc-test --coverage", "docs:build": "dumi build", + "docs:build:gh-pages": "GH_PAGES=1 npm run docs:build", "docs:deploy": "gh-pages -d docs-dist", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", - "prepare": "husky install", + "prepare": "husky", "prepublishOnly": "npm run compile && rc-np", "prettier": "prettier --write --ignore-unknown .", "start": "dumi dev", "test": "rc-test", - "tsc": "tsc --noEmit", - "docs:build:gh-pages": "GH_PAGES=1 npm run docs:build" + "tsc": "tsc --noEmit" }, "lint-staged": { - "**/*.{js,jsx,tsx,ts,md,json}": [ - "prettier --write --ignore-unknown" - ] + "*": "prettier --write --ignore-unknown" }, "dependencies": { "@rc-component/mini-decimal": "^1.1.1", @@ -53,7 +51,6 @@ }, "devDependencies": { "@rc-component/father-plugin": "^2.2.0", - "prettier": "^3.9.0", "@rc-component/np": "^1.0.4", "@swc-node/jest": "^1.5.5", "@testing-library/jest-dom": "^6.9.1", @@ -74,6 +71,7 @@ "jest-environment-jsdom": "^29.7.0", "less": "^4.6.7", "lint-staged": "^16.4.0", + "prettier": "^3.9.0", "rc-test": "^7.1.3", "react": "^18.3.1", "react-dom": "^18.3.1", From b70ff85e8dc3a8b65a32cccaa0dfb8f7905f19e3 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 20:06:08 +0800 Subject: [PATCH 34/39] docs: align readme badge layout --- README.md | 30 +++++++++--------------------- README.zh-CN.md | 38 +++++++++++++------------------------- 2 files changed, 22 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index e7f2aa89..1c6b2511 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,18 @@

@rc-component/input-number

Ant Design Part of the Ant Design ecosystem.

🔢 Accessible React number input with precision, formatting, keyboard, and wheel support.

-
- -

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] +

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

+

English | 简体中文

## Highlights @@ -148,16 +149,3 @@ The release flow is handled by `@rc-component/np` through the `rc-np` command af ## License @rc-component/input-number is released under the [MIT](./LICENSE) license. - -[npm-image]: https://img.shields.io/npm/v/@rc-component/input-number.svg?style=flat-square -[npm-url]: https://npmjs.org/package/@rc-component/input-number -[github-actions-image]: https://github.com/react-component/input-number/actions/workflows/react-component-ci.yml/badge.svg -[github-actions-url]: https://github.com/react-component/input-number/actions/workflows/react-component-ci.yml -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/input-number/master.svg?style=flat-square -[codecov-url]: https://app.codecov.io/gh/react-component/input-number -[download-image]: https://img.shields.io/npm/dm/@rc-component/input-number.svg?style=flat-square -[download-url]: https://npmjs.org/package/@rc-component/input-number -[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/input-number -[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/@rc-component/input-number?style=flat-square -[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 b03272a3..482d219d 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -2,17 +2,18 @@

@rc-component/input-number

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] +

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

+

English | 简体中文

## 特性 @@ -111,10 +112,10 @@ ref.current?.focus(); ref.current?.blur(); ``` -| 参数 | 类型 | 说明 | -| ------------- | --------------------------------------- | -------------------- | -| focus | `(options?: InputFocusOptions) => void` | 集中输入。 | -| blur | `() => void` | 模糊输入。 | +| 参数 | 类型 | 说明 | +| ------------- | --------------------------------------- | ------------ | +| focus | `(options?: InputFocusOptions) => void` | 集中输入。 | +| blur | `() => void` | 模糊输入。 | | nativeElement | `HTMLElement` | 根原生元素。 | ## 键盘与滚轮 @@ -148,16 +149,3 @@ npm run prepublishOnly ## 许可证 @rc-component/input-number 基于 [MIT](./LICENSE) 许可证发布。 - -[npm-image]: https://img.shields.io/npm/v/@rc-component/input-number.svg?style=flat-square -[npm-url]: https://npmjs.org/package/@rc-component/input-number -[github-actions-image]: https://github.com/react-component/input-number/actions/workflows/react-component-ci.yml/badge.svg -[github-actions-url]: https://github.com/react-component/input-number/actions/workflows/react-component-ci.yml -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/input-number/master.svg?style=flat-square -[codecov-url]: https://app.codecov.io/gh/react-component/input-number -[download-image]: https://img.shields.io/npm/dm/@rc-component/input-number.svg?style=flat-square -[download-url]: https://npmjs.org/package/@rc-component/input-number -[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/input-number -[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/@rc-component/input-number?style=flat-square -[dumi-url]: https://github.com/umijs/dumi -[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square From 24a29c1bb3ea28f4b5e983af038de2cfa51f7251 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 21:20:01 +0800 Subject: [PATCH 35/39] 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 38a7ae5c849a6472c855e15e3b95c2df42fd33e0 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 21:32:49 +0800 Subject: [PATCH 36/39] 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 3cb5887574733a0d194d9c0f4a5ad8371a12182a Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 28 Jun 2026 21:52:35 +0800 Subject: [PATCH 37/39] docs: polish zh-CN readme wording --- 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 482d219d..86c62412 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -77,7 +77,7 @@ npm start | disabled | `boolean` | `false` | 禁用输入。 | | downHandler | `ReactNode` | - | 自定义减量控制。 | | formatter | `(value: T \| undefined, info: { userTyping: boolean; input: string }) => string` | - | 设置显示值的格式。 | -| inputMode | `string` | - | 本机输入 `inputMode` 属性。 | +| inputMode | `string` | - | 原生 input `inputMode` 属性。 | | keyboard | `boolean` | `true` | 启用键盘步进。 | | max | `T` | - | 最大值。 | | min | `T` | - | 最小值。 | From f7890cc172e0baac7982d15927c690128453e2e3 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 29 Jun 2026 00:47:05 +0800 Subject: [PATCH 38/39] 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 5bd2ec907f09193931e65e49cfedff661bb60589 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 29 Jun 2026 14:25:27 +0800 Subject: [PATCH 39/39] 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 }}