Skip to content
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

feat(input-number): add keyboard props #2592

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/web-vue/components/input-number/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ description: Only input boxes in numeric format are allowed.
|allow-clear|Whether to allow the input to be cleared|`boolean`|`false`||
|model-event|Trigger event for `v-model`|`'change' \| 'input'`|`'change'`||
|read-only|Readonly|`boolean`|`false`|3.33.1|
|keyboard|If enable keyboard behavior|`boolean`|`true`||

### `<input-number>` Events

|Event Name|Description|Parameters|version|
Expand Down
1 change: 1 addition & 0 deletions packages/web-vue/components/input-number/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ description: 仅允许输入数字格式的输入框。
|allow-clear|是否允许清空输入框|`boolean`|`false`||
|model-event|触发 `v-model` 的事件|`'change' \| 'input'`|`'change'`||
|read-only|只读|`boolean`|`false`|3.33.1|
|keyboard|是否启用键盘快捷行为|`boolean`|`true`||
### `<input-number>` Events

|事件名|描述|参数|版本|
Expand Down
1 change: 1 addition & 0 deletions packages/web-vue/components/input-number/__demo__/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Use the mouse or keyboard to enter the standard value within the range.
<a-input-number v-model="value" :style="{width:'320px'}" placeholder="Please Enter" class="input-demo" :min="10" :max="100"/>
<a-input-number :style="{width:'320px'}" placeholder="Please Enter" class="input-demo" :min="10" :max="100"/>
<a-input-number :style="{width:'320px'}" placeholder="Please Enter" :default-value="500" class="input-demo" disabled/>
<a-input-number :style="{width:'320px'}" placeholder="disable keyboard" class="input-demo" :keyboard="false"/>
</a-space>
</template>

Expand Down
12 changes: 10 additions & 2 deletions packages/web-vue/components/input-number/input-number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ export default defineComponent({
type: Boolean,
default: false,
},
/**
* @zh 是否启用键盘快捷行为
* @en If enable keyboard behavior
*/
keyboard: {
type: Boolean,
default: true,
},
},
emits: {
'update:modelValue': (value: number | undefined) => true,
Expand Down Expand Up @@ -461,14 +469,14 @@ export default defineComponent({
KEYBOARD_KEY.ARROW_UP,
(ev: Event) => {
ev.preventDefault();
!props.readOnly && nextStep('plus', ev);
props.keyboard && !props.readOnly && nextStep('plus', ev);
},
],
[
KEYBOARD_KEY.ARROW_DOWN,
(ev: Event) => {
ev.preventDefault();
!props.readOnly && nextStep('minus', ev);
props.keyboard && !props.readOnly && nextStep('minus', ev);
},
],
])
Expand Down