From e242913a13e80bda0be5d9c17b573d168dbe0770 Mon Sep 17 00:00:00 2001 From: xiaosheng <811373724@qq.com> Date: Sat, 18 Dec 2021 21:39:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20imput-number=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devui/input-number/src/input-number.scss | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/devui-vue/devui/input-number/src/input-number.scss b/packages/devui-vue/devui/input-number/src/input-number.scss index 287e4fb55b..e061101aef 100644 --- a/packages/devui-vue/devui/input-number/src/input-number.scss +++ b/packages/devui-vue/devui/input-number/src/input-number.scss @@ -51,23 +51,26 @@ } &.devui-input-number-sm { - .devui-subtract, - .devui-add { - width: 40px; - height: 34px; - line-height: 34px; + .devui-input-box{ + width: 80px; + height: 26px; + line-height: 26px; } + } - .devui-input-style { - height: 34px; - line-height: 34px; + &.devui-input-number-normal { + .devui-input-box{ + width: 80px; + height: 28px; + line-height: 28px; } } &.devui-input-number-lg { - .devui-subtract, - .devui-add { - width: 60px; + .devui-input-box{ + width: 80px; + height: 46px; + line-height: 46px; } } From 66eb6edd3aab848f1455341e268b9db8411a1b85 Mon Sep 17 00:00:00 2001 From: yeqs <811373724@qq.com> Date: Mon, 18 Apr 2022 21:39:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix(test=20bug):=20=20=E8=87=AA=E6=B5=8B?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devui/input-number/src/input-number.scss | 25 ++++++------ .../devui/input-number/src/input-number.tsx | 38 +++++++++++++++---- .../docs/components/input-number/index.md | 15 ++++++-- 3 files changed, 56 insertions(+), 22 deletions(-) diff --git a/packages/devui-vue/devui/input-number/src/input-number.scss b/packages/devui-vue/devui/input-number/src/input-number.scss index 44ede7ae04..804161f15c 100644 --- a/packages/devui-vue/devui/input-number/src/input-number.scss +++ b/packages/devui-vue/devui/input-number/src/input-number.scss @@ -46,26 +46,29 @@ } &.devui-input-number-sm { - .devui-input-box{ - width: 80px; + width: 60px; + + .devui-input-box { height: 26px; line-height: 26px; } } - &.devui-input-number-normal { - .devui-input-box{ - width: 80px; - height: 28px; - line-height: 28px; + &.devui-input-number-md { + width: 80px; + + .devui-input-box { + height: 32px; + line-height: 32px; } } &.devui-input-number-lg { - .devui-input-box{ - width: 80px; - height: 46px; - line-height: 46px; + width: 100px; + + .devui-input-box { + height: 38px; + line-height: 38px; } } diff --git a/packages/devui-vue/devui/input-number/src/input-number.tsx b/packages/devui-vue/devui/input-number/src/input-number.tsx index de60d57698..703611ee22 100644 --- a/packages/devui-vue/devui/input-number/src/input-number.tsx +++ b/packages/devui-vue/devui/input-number/src/input-number.tsx @@ -8,7 +8,7 @@ export default defineComponent({ props: inputNumberProps, emits: ['update:modelValue', 'change', 'input', 'focus', 'blur', 'keydown'], setup(props: InputNumberProps, ctx) { - const inputVal = ref(props.modelValue); + const inputVal = ref(props.modelValue < props.min ? props.min : props.modelValue); const focusVal = ref(''); @@ -26,7 +26,18 @@ export default defineComponent({ const add = () => { if (props.disabled) {return;} if (inputVal.value >= props.max) {return;} - inputVal.value += props.step != 0 ? props.step : 1; + if(props.step !== 0){ + const maxSpaceVal = props.max - inputVal.value; + if(inputVal.value < props.max && maxSpaceVal < props.step){ + inputVal.value += maxSpaceVal; + }else if(inputVal.value < props.max && maxSpaceVal > props.step){ + inputVal.value += props.step; + }else{ + inputVal.value += props.step; + } + }else{ + inputVal.value += 1; + } focusVal.value = 'active'; ctx.emit('change', inputVal.value); ctx.emit('update:modelValue', inputVal.value); @@ -35,15 +46,26 @@ export default defineComponent({ const subtract = () => { if (props.disabled) {return;} if (inputVal.value <= props.min) {return;} - inputVal.value -= props.step != 0 ? props.step : 1; + if(props.step !== 0){ + const minSpaceVal = inputVal.value - props.min; + if(inputVal.value > props.min && minSpaceVal > props.step){ + inputVal.value -= props.step; + }else if (inputVal.value > props.min && minSpaceVal < props.step){ + inputVal.value -= minSpaceVal; + }else{ + inputVal.value -= props.step; + } + }else{ + inputVal.value -= 1; + } focusVal.value = 'active'; ctx.emit('change', inputVal.value); ctx.emit('update:modelValue', inputVal.value); }; const onInput = (val) => { inputVal.value = parseInt(val.data); - ctx.emit('input', val.data); - ctx.emit('update:modelValue', val.data); + ctx.emit('input', inputVal.value); + ctx.emit('update:modelValue', inputVal.value); }; const onFocus = ($event: Event) => { focusVal.value = 'active'; @@ -91,9 +113,9 @@ export default defineComponent({ const dInputNum = ['devui-input-number', isDisabled ? 'devui-input-disabled' : '', isSize]; return (
-
- - +
+ +
- +
+ ``` ::: ### API From ba4fe95b38ebf8e2217b6f50f3f7dc1b9b0f9a66 Mon Sep 17 00:00:00 2001 From: yeqs <811373724@qq.com> Date: Mon, 18 Apr 2022 21:51:35 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20size=E7=B1=BB=E5=9E=8B=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/devui-vue/docs/components/input-number/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/devui-vue/docs/components/input-number/index.md b/packages/devui-vue/docs/components/input-number/index.md index c898fdbd10..1ffe1e6b39 100644 --- a/packages/devui-vue/docs/components/input-number/index.md +++ b/packages/devui-vue/docs/components/input-number/index.md @@ -134,7 +134,7 @@ import { defineComponent, ref } from 'vue' | min | `number` | -- | 可选,输入框的最小值min | [基本用法](#基本用法) | | disabled | `boolean` | false | 可选,文本框是否被禁用 | [禁用状态](#禁用状态) | | value | `number` | 0 | 可选,文本框默认值 | [基本用法](#基本用法) | -| size | `'lg'\|'normal'\|'sm'` | '' | 可选,文本框尺寸,有三种选择`'lg'`,`'narmal'`,`'sm'` | [尺寸](#尺寸) | +| size | `'lg'\|'md'\|'sm'` | '' | 可选,文本框尺寸,有三种选择`'lg'`,`'md'`,`'sm'` | [尺寸](#尺寸) | ### Events