-
Notifications
You must be signed in to change notification settings - Fork 286
feat(inputNumber): v14 multi-platform adaption #2823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
89492fd
chore: temp save content
Miles-hxy 93a6c25
feat(inputNumber): v14 multi-platform adaption
Miles-hxy 33ac3d6
feat(inputNumber): update docs and variables
Miles-hxy ed09115
fix: varaible and doc supplement
Miles-hxy abe3804
fix: varaible and doc supplement
Miles-hxy 4f1ca2d
fix: varaible and doc supplement
Miles-hxy 4e78bd6
feat: cancel auto compute input-width
Miles-hxy 97901fd
fix: delete useless id
Miles-hxy 1b70e9f
Merge branch 'feat_v3.x' into feat_v14_inputnumber
xiaoyatong 4236ddc
fix: correct var value
Miles-hxy f2bd515
fix: correct var value
Miles-hxy b413235
Merge branch 'feat_v3.x' into feat_v14_inputnumber
Miles-hxy 9ae8aa5
Merge branch 'feat_v3.x' into feat_v14_inputnumber
Miles-hxy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,148 +1,146 @@ | ||
| # InputNumber 数字输入框 | ||
|
|
||
| 通过点击按钮控制数字增减。 | ||
|
|
||
| ## 引入 | ||
|
|
||
| ```tsx | ||
| import { InputNumber } from '@nutui/nutui-react-taro' | ||
| ``` | ||
|
|
||
| ## 示例代码 | ||
|
|
||
| ### 基础用法 | ||
|
|
||
| 初始化一个默认值 | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo1.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ### 步长设置 | ||
|
|
||
| 设置步长 `step` 5 | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo2.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ### 限制输入范围 | ||
|
|
||
| `min` 和 `max` 属性分别表示最小值和最大值 | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo3.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ### 禁用状态 | ||
|
|
||
| `disabled` 禁用状态下无法点击按钮或修改输入框。 | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo4.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ### 只读禁用输入框 | ||
|
|
||
| `readOnly` 设置只读禁用输入框输入行为 | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo5.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ### 设置按钮样式 | ||
|
|
||
| 可使用`ConfigProvider`组件来设置按钮样式。 | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo6.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ### 支持小数点 | ||
|
|
||
| 设置步长 `step` 0.1 `decimal-places` 小数保留1位 | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo7.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ### 支持异步修改 | ||
|
|
||
| 通过 `change` 事件和 `model-value` 进行异步修改 | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo8.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ### 支持formatter | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo9.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ## InputNumber | ||
|
|
||
| ### Props | ||
|
|
||
| | 属性 | 说明 | 类型 | 默认值 | | ||
| | --- | --- | --- | --- | | ||
| | allowEmpty | 是否允许内容为空 | `boolean` | `false` | | ||
| | defaultValue | 默认值 | `string` \| `number` | `0` | | ||
| | value | 当前值,受控值 | `string` \| `number` | `-` | | ||
| | min | 最小值限制 | `string` \| `number` | `1` | | ||
| | max | 最大值限制 | `string` \| `number` | `9999` | | ||
| | type | input 的类型 | `digit` \| `number` | `digit` | | ||
| | step | 步长 | `string` \| `number` | `1` | | ||
| | digits | 设置保留的小数位 | `string` \| `number` | `0` | | ||
| | disabled | 禁用所有功能 | `boolean` | `false` | | ||
| | readOnly | 只读状态禁用输入框操作行为 | `boolean` | `false` | | ||
| | async | 支持异步修改 | `boolean` | `false` | | ||
| | formatter | 指定输入框展示值的格式 | `function(value: number \| string): string` | `-` | | ||
| | onPlus | 点击增加按钮时触发 | `(e: MouseEvent) => void` | `-` | | ||
| | onMinus | 点击减少按钮时触发 | `(e: MouseEvent) => void` | `-` | | ||
| | onOverlimit | 点击不可用的按钮时触发 | `(e: MouseEvent) => void` | `-` | | ||
| | onChange | 值改变时触发 | `(param: string \| number, e: MouseEvent \| ChangeEvent<HTMLInputElement>) => void` | `-` | | ||
| | onFocus | 输入框获得焦点时触发 | `(e: FocusEvent<HTMLInputElement>) => void` | `-` | | ||
| | onBlur | 输入框失去焦点时触发 | `(e: ChangeEvent<HTMLInputElement>) => void` | `-` | | ||
|
|
||
| ## 主题定制 | ||
|
|
||
| ### 样式变量 | ||
|
|
||
| 组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](#/zh-CN/component/configprovider)。 | ||
|
|
||
| | 名称 | 说明 | 默认值 | | ||
| | --- | --- | --- | | ||
| | \--nutui-inputnumber-input-width | 数字输入框中input的宽度 | `40px` | | ||
| | \--nutui-inputnumber-input-height | 数字输入框中input的高度 | `24px` | | ||
| | \--nutui-inputnumber-input-background-color | 数字输入框中input的背景颜色 | `$color-background` | | ||
| | \--nutui-inputnumber-input-font-color | 数字输入框中input的字号颜色 | `$color-title` | | ||
| | \--nutui-inputnumber-input-font-size | 数字输入框中input的字号大小 | `14px` | | ||
| | \--nutui-inputnumber-input-border | 数字输入框中input的border值 | `0` | | ||
| | \--nutui-inputnumber-input-border-radius | 数字输入框中input的圆角 | `6px` | | ||
| | \--nutui-inputnumber-input-margin | 数字输入框中input的margin值 | `0` | | ||
| | \--nutui-inputnumber-button-width | 数字输入框左右按钮的宽度 | `14px` | | ||
| | \--nutui-inputnumber-button-height | 数字输入框左右按钮的高度 | `16px` | | ||
| | \--nutui-inputnumber-button-border-radius | 数字输入框左右按钮的圆角 | `30px` | | ||
| | \--nutui-inputnumber-button-background-color | 数字输入框左右按钮的背景色 | `transparent` | | ||
| | \--nutui-inputnumber-icon-color | 数字输入框中icon的颜色 | `$color-text` | | ||
| | \--nutui-inputnumber-icon-size | 数字输入框中icon的大小 | `8px` | | ||
| | \--nutui-inputnumber-disabled-color | 数字输入框禁用色 | `$color-text-disabled` | | ||
| # InputNumber 数字输入框 | ||
|
|
||
| 通过点击按钮控制数字增减。 | ||
|
|
||
| ## 引入 | ||
|
|
||
| ```tsx | ||
| import { InputNumber } from '@nutui/nutui-react-taro' | ||
| ``` | ||
|
|
||
| ## 示例代码 | ||
|
|
||
| ### 基础用法 | ||
|
|
||
| 初始化一个默认值 | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo1.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ### 步长设置 | ||
|
|
||
| 设置步长 `step` 5 | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo2.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ### 限制输入范围 | ||
|
|
||
| `min` 和 `max` 属性分别表示最小值和最大值 | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo3.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ### 禁用状态 | ||
|
|
||
| `disabled` 禁用状态下无法点击按钮或修改输入框。 | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo4.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ### 只读禁用输入框 | ||
|
|
||
| `readOnly` 设置只读禁用输入框输入行为 | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo5.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ### 设置按钮样式 | ||
|
|
||
| 可使用`ConfigProvider`组件来设置按钮样式。 | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo6.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ### 支持小数点 | ||
|
|
||
| 设置步长 `step` 0.1 `decimal-places` 小数保留1位 | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo7.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ### 支持异步修改 | ||
|
|
||
| 通过 `change` 事件和 `model-value` 进行异步修改 | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo8.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ### 支持formatter | ||
|
|
||
| :::demo | ||
|
|
||
| <CodeBlock src='taro/demo9.tsx'></CodeBlock> | ||
|
|
||
| ::: | ||
|
|
||
| ## InputNumber | ||
|
|
||
| ### Props | ||
|
|
||
| | 属性 | 说明 | 类型 | 默认值 | | ||
| | --- | --- | --- | --- | | ||
| | allowEmpty | 是否允许内容为空 | `boolean` | `false` | | ||
| | defaultValue | 默认值 | `string` \| `number` | `0` | | ||
| | value | 当前值,受控值 | `string` \| `number` | `-` | | ||
| | min | 最小值限制 | `string` \| `number` | `1` | | ||
| | max | 最大值限制 | `string` \| `number` | `9999` | | ||
| | type | input 的类型 | `digit` \| `number` | `digit` | | ||
| | step | 步长 | `string` \| `number` | `1` | | ||
| | digits | 设置保留的小数位 | `string` \| `number` | `0` | | ||
| | disabled | 禁用所有功能 | `boolean` | `false` | | ||
| | readOnly | 只读状态禁用输入框操作行为 | `boolean` | `false` | | ||
| | async | 支持异步修改 | `boolean` | `false` | | ||
| | formatter | 指定输入框展示值的格式 | `function(value: number \| string): string` | `-` | | ||
| | onPlus | 点击增加按钮时触发 | `(e: MouseEvent) => void` | `-` | | ||
| | onMinus | 点击减少按钮时触发 | `(e: MouseEvent) => void` | `-` | | ||
| | onOverlimit | 点击不可用的按钮时触发 | `(e: MouseEvent) => void` | `-` | | ||
| | onChange | 值改变时触发 | `(param: string \| number, e: MouseEvent \| ChangeEvent<HTMLInputElement>) => void` | `-` | | ||
| | onFocus | 输入框获得焦点时触发 | `(e: FocusEvent<HTMLInputElement>) => void` | `-` | | ||
| | onBlur | 输入框失去焦点时触发 | `(e: ChangeEvent<HTMLInputElement>) => void` | `-` | | ||
|
|
||
| ## 主题定制 | ||
|
|
||
| ### 样式变量 | ||
|
|
||
| 组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](#/zh-CN/component/configprovider)。 | ||
Miles-hxy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| | 名称 | 说明 | 默认值 | | ||
| | --- | --- | --- | | ||
| | \--nutui-inputnumber-input-height | 数字输入框中input的高度 | `20px` | | ||
| | \--nutui-inputnumber-input-background-color | 数字输入框中input的背景颜色 | `$color-background` | | ||
| | \--nutui-inputnumber-input-font-color | 数字输入框中input的字号颜色 | `$color-title` | | ||
| | \--nutui-inputnumber-input-font-size | 数字输入框中input的字号大小 | `12px` | | ||
| | \--nutui-inputnumber-input-border | 数字输入框中input的border值 | `0` | | ||
| | \--nutui-inputnumber-input-border-radius | 数字输入框中input的圆角 | `4px` | | ||
| | \--nutui-inputnumber-input-margin | 数字输入框中input的margin值 | `2px` | | ||
| | \--nutui-inputnumber-button-width | 数字输入框左右按钮的宽度 | `20px` | | ||
| | \--nutui-inputnumber-button-height | 数字输入框左右按钮的高度 | `20px` | | ||
| | \--nutui-inputnumber-button-background-color | 数字输入框左右按钮的背景色 | `transparent` | | ||
| | \--nutui-inputnumber-icon-color | 数字输入框中icon的颜色 | `$color-text` | | ||
| | \--nutui-inputnumber-icon-size | 数字输入框中icon的大小 | `8px` | | ||
| | \--nutui-inputnumber-disabled-color | 数字输入框禁用色 | `$color-text-disabled` | | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.