-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor(InputNumber): Vue2/Vue3/React 多个框架逻辑统一,支持超过 16 位的大数字 (#1412)
* feat(input): add allowInputOverMax, onValidate, showLimitNumber * feat(input-number): update demos * feat(input-number): supoort large number * test(unit): update snapshots * test(unit): update snapshots * chore(input-number): remove code * fix(table): affixed header 1px Co-authored-by: sheepluo <sheepluo@tencent.com>
- Loading branch information
Showing
33 changed files
with
3,414 additions
and
3,043 deletions.
There are no files selected for viewing
This file contains 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,14 +1,14 @@ | ||
<template> | ||
<div class="tdesign-demo-block-column"> | ||
<div style="width: 20%"> | ||
<t-input-number :default-value="100" align="left" style="width: 120px" /> | ||
<t-input-number :default-value="200" align="center" style="width: 120px" /> | ||
<t-input-number :default-value="300" align="right" style="width: 120px" /> | ||
</div> | ||
<div style="width: 20%"> | ||
<t-input-number :default-value="100" align="left" theme="normal" style="width: 120px" /> | ||
<t-input-number :default-value="200" align="center" theme="normal" style="width: 120px" /> | ||
<t-input-number :default-value="300" align="right" theme="normal" style="width: 120px" /> | ||
</div> | ||
</div> | ||
<t-space> | ||
<t-space direction="vertical"> | ||
<t-input-number :default-value="100" align="left" /> | ||
<t-input-number :default-value="200" align="center" /> | ||
<t-input-number :default-value="300" align="right" /> | ||
</t-space> | ||
<t-space direction="vertical" style="margin-left: 100px"> | ||
<t-input-number :default-value="100" align="left" theme="normal" /> | ||
<t-input-number :default-value="200" align="center" theme="normal" /> | ||
<t-input-number :default-value="300" align="right" theme="normal" /> | ||
</t-space> | ||
</t-space> | ||
</template> |
This file contains 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 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,14 +1,20 @@ | ||
<template> | ||
<div> | ||
<t-input-number v-model="value" :max="15" :min="-2" :format="(value) => `${value}%`" @change="onChange" /> | ||
</div> | ||
<t-space direction="vertical"> | ||
<t-input-number v-model="value1" :max="15" :min="-2" :format="(value) => `${value} %`" auto-width></t-input-number> | ||
|
||
<!-- 小数位数和格式化函数组合使用 --> | ||
<t-input-number | ||
v-model="value2" | ||
:decimal-places="2" | ||
:format="(value, { fixedNumber }) => `${fixedNumber} %`" | ||
auto-width | ||
></t-input-number> | ||
</t-space> | ||
</template> | ||
|
||
<script setup> | ||
import { ref } from 'vue'; | ||
const value = ref(3); | ||
const onChange = (ev) => { | ||
console.info(ev); | ||
}; | ||
const value1 = ref(3); | ||
const value2 = ref(3.01); | ||
</script> |
This file contains 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<template> | ||
<div class="tdesign-demo-block-column-large"> | ||
<div> | ||
<t-input-number v-model="value1" large-number :decimal-places="2" step="1" style="width: 300px"></t-input-number> | ||
</div> | ||
|
||
<div> | ||
<t-input-number v-model="value2" large-number step="0.888" style="width: 300px"></t-input-number> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { ref } from 'vue'; | ||
const value1 = ref('19999999999999999'); | ||
const value2 = ref('0.8975527383412673418'); | ||
</script> |
This file contains 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,11 +1,22 @@ | ||
<template> | ||
<div> | ||
<t-input-number v-model="value" theme="column" :max="15" :min="-2" /> | ||
</div> | ||
<t-space> | ||
<t-input-number v-model="value1" theme="column"></t-input-number> | ||
|
||
<t-input-number | ||
v-model="value2" | ||
theme="column" | ||
align="center" | ||
:max="15" | ||
:min="-2" | ||
label="数字" | ||
style="width: 150px" | ||
></t-input-number> | ||
</t-space> | ||
</template> | ||
|
||
<script setup> | ||
import { ref } from 'vue'; | ||
const value = ref(3); | ||
const value1 = ref(3); | ||
const value2 = ref(3); | ||
</script> |
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
:: BASE_DOC :: | ||
|
||
## API | ||
|
||
### InputNumber Props | ||
|
||
name | type | default | description | required | ||
-- | -- | -- | -- | -- | ||
align | String | - | options:left/center/right | N | ||
autoWidth | Boolean | false | \- | N | ||
decimalPlaces | Number | undefined | \- | N | ||
disabled | Boolean | - | \- | N | ||
format | Function | - | Typescript:`(value: InputNumberValue, context?: { fixedNumber?: InputNumberValue }) => InputNumberValue` | N | ||
inputProps | Object | - | Typescript:`InputProps`,[Input API Documents](./input?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/input-number/type.ts) | N | ||
label | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N | ||
largeNumber | Boolean | false | \- | N | ||
max | String / Number | Infinity | Typescript:`InputNumberValue` | N | ||
min | String / Number | -Infinity | Typescript:`InputNumberValue` | N | ||
placeholder | String | undefined | \- | N | ||
readonly | Boolean | false | \- | N | ||
size | String | medium | options:small/medium/large | N | ||
status | String | - | options:default/success/warning/error | N | ||
step | String / Number | 1 | Typescript:`InputNumberValue` | N | ||
suffix | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N | ||
theme | String | row | options:column/row/normal | N | ||
tips | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N | ||
value | String / Number | - | `v-model` and `v-model:value` is supported。Typescript:`T` `type InputNumberValue = number | string`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/input-number/type.ts) | N | ||
defaultValue | String / Number | - | uncontrolled property。Typescript:`T` `type InputNumberValue = number | string`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/input-number/type.ts) | N | ||
onBlur | Function | | Typescript:`(value: InputNumberValue, context: { e: FocusEvent }) => void`<br/> | N | ||
onChange | Function | | Typescript:`(value: T, context: ChangeContext) => void`<br/>[see more ts definition](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/input-number/type.ts)。<br/>`interface ChangeContext { type: ChangeSource; e: InputEvent | MouseEvent | FocusEvent | KeyboardEvent }`<br/><br/>`type ChangeSource = 'add' | 'reduce' | 'input' | 'blur' | 'enter' | ''`<br/> | N | ||
onEnter | Function | | Typescript:`(value: InputNumberValue, context: { e: KeyboardEvent }) => void`<br/> | N | ||
onFocus | Function | | Typescript:`(value: InputNumberValue, context: { e: FocusEvent }) => void`<br/> | N | ||
onKeydown | Function | | Typescript:`(value: InputNumberValue, context: { e: KeyboardEvent }) => void`<br/> | N | ||
onKeypress | Function | | Typescript:`(value: InputNumberValue, context: { e: KeyboardEvent }) => void`<br/> | N | ||
onKeyup | Function | | Typescript:`(value: InputNumberValue, context: { e: KeyboardEvent }) => void`<br/> | N | ||
onValidate | Function | | Typescript:`(context: { error?: 'exceed-maximum' | 'below-minimum' }) => void`<br/> | N | ||
|
||
### InputNumber Events | ||
|
||
name | params | description | ||
-- | -- | -- | ||
blur | `(value: InputNumberValue, context: { e: FocusEvent })` | \- | ||
change | `(value: T, context: ChangeContext)` | [see more ts definition](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/input-number/type.ts)。<br/>`interface ChangeContext { type: ChangeSource; e: InputEvent | MouseEvent | FocusEvent | KeyboardEvent }`<br/><br/>`type ChangeSource = 'add' | 'reduce' | 'input' | 'blur' | 'enter' | ''`<br/> | ||
enter | `(value: InputNumberValue, context: { e: KeyboardEvent })` | \- | ||
focus | `(value: InputNumberValue, context: { e: FocusEvent })` | \- | ||
keydown | `(value: InputNumberValue, context: { e: KeyboardEvent })` | \- | ||
keypress | `(value: InputNumberValue, context: { e: KeyboardEvent })` | \- | ||
keyup | `(value: InputNumberValue, context: { e: KeyboardEvent })` | \- | ||
validate | `(context: { error?: 'exceed-maximum' | 'below-minimum' })` | \- |
Oops, something went wrong.