From 5c0ff4b5626416314ee0b2db80f3bda3c0b8268c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E9=95=9C=E7=A7=91?= <895149033@qq.com> Date: Thu, 27 Jul 2023 16:33:27 +0800 Subject: [PATCH] feat: add keyboard props --- .../web-vue/components/input-number/README.en-US.md | 2 ++ .../web-vue/components/input-number/README.zh-CN.md | 1 + .../components/input-number/__demo__/basic.md | 1 + .../web-vue/components/input-number/input-number.tsx | 12 ++++++++++-- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/web-vue/components/input-number/README.en-US.md b/packages/web-vue/components/input-number/README.en-US.md index bcaf6f0f2..60bdb6654 100644 --- a/packages/web-vue/components/input-number/README.en-US.md +++ b/packages/web-vue/components/input-number/README.en-US.md @@ -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`|| + ### `` Events |Event Name|Description|Parameters|version| diff --git a/packages/web-vue/components/input-number/README.zh-CN.md b/packages/web-vue/components/input-number/README.zh-CN.md index aef4c6010..d10f2d837 100644 --- a/packages/web-vue/components/input-number/README.zh-CN.md +++ b/packages/web-vue/components/input-number/README.zh-CN.md @@ -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`|| ### `` Events |事件名|描述|参数|版本| diff --git a/packages/web-vue/components/input-number/__demo__/basic.md b/packages/web-vue/components/input-number/__demo__/basic.md index 846033892..ba19c2930 100644 --- a/packages/web-vue/components/input-number/__demo__/basic.md +++ b/packages/web-vue/components/input-number/__demo__/basic.md @@ -22,6 +22,7 @@ Use the mouse or keyboard to enter the standard value within the range. + diff --git a/packages/web-vue/components/input-number/input-number.tsx b/packages/web-vue/components/input-number/input-number.tsx index c9a7a6c11..4f2bbfe71 100644 --- a/packages/web-vue/components/input-number/input-number.tsx +++ b/packages/web-vue/components/input-number/input-number.tsx @@ -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, @@ -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); }, ], ])