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/.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 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
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
index 7c5e0671..b399f316 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@v7
+ 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..36dacae4 100644
--- a/.github/workflows/react-component-ci.yml
+++ b/.github/workflows/react-component-ci.yml
@@ -1,6 +1,9 @@
name: ✅ test
on: [push, pull_request]
+permissions:
+ contents: read
jobs:
test:
uses: react-component/rc-test/.github/workflows/test-utoo.yml@main
- secrets: inherit
\ No newline at end of file
+ secrets:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml
new file mode 100644
index 00000000..097eb883
--- /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@v7
+ 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..4c2f17ed
--- /dev/null
+++ b/.github/workflows/surge-preview.yml
@@ -0,0 +1,54 @@
+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
+
+jobs:
+ preview:
+ runs-on: ubuntu-latest
+ concurrency:
+ group: surge-preview-${{ github.event.pull_request.number }}
+ cancel-in-progress: true
+ env:
+ PREVIEW: true
+ steps:
+ - uses: actions/checkout@v7
+ 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: ${{ steps.surge-token.outputs.enabled == 'true' }}
+ run: |
+ npm install
+ npm run build
+ - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec
+ if: ${{ steps.surge-token.outputs.enabled == 'true' }}
+ env:
+ SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
+ with:
+ surge_token: ${{ env.SURGE_TOKEN }}
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ dist: docs-dist
+ failOnError: false
+ setCommitStatus: false
+ - name: Skip Surge preview
+ if: ${{ steps.surge-token.outputs.enabled != 'true' }}
+ 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/.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/.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
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 64aee149..1c6b2511 100644
--- a/README.md
+++ b/README.md
@@ -1,277 +1,151 @@
-# @rc-component/input-number
-
-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-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
-
-## Screenshots
-
-
+
Part of the Ant Design ecosystem.
🔢 Accessible React number input with precision, formatting, keyboard, and wheel support.
+ + +English | 简体中文
+ +## 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 -[](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 () =>| name | -type | -default | -description | -
|---|---|---|---|
| prefixCls | -string | -rc-input-number | -Specifies the class prefix | -
| min | -Number | -- | Specifies the minimum value | -
| onClick | -- | - | - |
| placeholder | -string | -- | - |
| max | -Number | -- | Specifies the maximum value | -
| step | -Number or String | -1 | -Specifies the legal number intervals | -
| precision | -Number | -- | Specifies the precision length of value | -
| disabled | -Boolean | -false | -Specifies that an InputNumber should be disabled | -
| required | -Boolean | -false | -Specifies that an InputNumber is required | -
| autoFocus | -Boolean | -false | -Specifies that an InputNumber should automatically get focus when the page loads | -
| readOnly | -Boolean | -false | -Specifies that an InputNumber is read only | -
| controls | -Boolean | -true | -Whether to enable the control buttons | -
| name | -String | -- | Specifies the name of an InputNumber | -
| id | -String | -- | Specifies the id of an InputNumber | -
| value | -Number | -- | Specifies the value of an InputNumber | -
| defaultValue | -Number | -- | Specifies the defaultValue of an InputNumber | -
| onChange | -Function | -- | Called when value of an InputNumber changed | -
| onBlur | -Function | -- | Called when user leaves an input field | -
| onPressEnter | -Function | -- | The callback function that is triggered when Enter key is pressed. | -
| onFocus | -Function | -- | Called when an element gets focus | -
| style | -Object | -- | root style. such as {width:100} | -
| upHandler | -React.Node | -- | custom the up step element | -
| downHandler | -React.Node | -- | custom the down step element | -
| formatter | -(value: number|string): displayValue: string | -- | Specifies the format of the value presented | -
| parser | -(displayValue: string) => value: number | -`input => input.replace(/[^\w\.-]*/g, '')` | -Specifies the value extracted from formatter | -
| pattern | -string | -- | Specifies 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 | -
| decimalSeparator | -string | -- | Specifies the decimal separator | -
| inputMode | -string | -- | Specifies the inputmode of input | -
| wheel | -Boolean | -true | -Allows changing value with mouse wheel | -
Ant Design 生态的一部分。
🔢 React 数字输入组件,支持格式化、精度、步进和键盘交互。
+ + +English | 简体中文
+ +## 特性 + +- 受控和非受控数字输入模式。 +- 小数精度、自定义解析器、格式化程序和小数分隔符支持。 +- 支持键盘步进、鼠标滚轮步进和自定义步进处理。 +- 支持前缀、后缀、步进控制器和语义化 `classNames` / `styles` 插槽。 +- TypeScript 通用值类型用于基于数字和字符串的值流。 + +## 安装 + +```bash +npm install @rc-component/input-number +``` + +## 使用 + +```tsx | pure +import InputNumber from '@rc-component/input-number'; + +export default () =>