diff --git a/demo/documentation/components/inputNumber/enUS/event.md b/demo/documentation/components/inputNumber/enUS/event.md index 3c4b367c8..03c8294e2 100644 --- a/demo/documentation/components/inputNumber/enUS/event.md +++ b/demo/documentation/components/inputNumber/enUS/event.md @@ -3,6 +3,7 @@ ``` ```js @@ -15,7 +16,10 @@ export default { methods: { handleChange (newValue) { this.$NMessage.info(`value: ${newValue}`) - } + }, + handleBlur (e, v) { + this.$NMessage.info(`blur: ` + v) + }, } } ``` diff --git a/demo/documentation/components/inputNumber/enUS/index.md b/demo/documentation/components/inputNumber/enUS/index.md index 8364055c9..6b6885277 100644 --- a/demo/documentation/components/inputNumber/enUS/index.md +++ b/demo/documentation/components/inputNumber/enUS/index.md @@ -6,4 +6,5 @@ event min-max size step +validator ``` \ No newline at end of file diff --git a/demo/documentation/components/inputNumber/enUS/minMax.md b/demo/documentation/components/inputNumber/enUS/minMax.md index d638ec69d..f94d0d7c4 100644 --- a/demo/documentation/components/inputNumber/enUS/minMax.md +++ b/demo/documentation/components/inputNumber/enUS/minMax.md @@ -15,7 +15,7 @@ export default { data () { return { - value: 0 + value: null } } } diff --git a/demo/documentation/components/inputNumber/enUS/validator.md b/demo/documentation/components/inputNumber/enUS/validator.md new file mode 100644 index 000000000..f58e9e56d --- /dev/null +++ b/demo/documentation/components/inputNumber/enUS/validator.md @@ -0,0 +1,17 @@ +# Validator +```html + +``` +```js +export default { + data () { + return { + value: null, + validator: x => x > 0 + } + } +} +``` \ No newline at end of file diff --git a/packages/common/InputNumber/src/main.vue b/packages/common/InputNumber/src/main.vue index 906e66438..a2f735d3b 100644 --- a/packages/common/InputNumber/src/main.vue +++ b/packages/common/InputNumber/src/main.vue @@ -12,7 +12,7 @@ type="button" class="n-input-number__minus-button" :class="{ - [`n-input-number__minus-button--disabled`]: value !== null && safeMin !== null && value <= safeMin + [`n-input-number__minus-button--disabled`]: !minusable }" @mousedown="handleMouseDown" @click="minus" @@ -25,8 +25,8 @@ type="text" :value="value" :disabled="disabled ? 'disabled' : false" + @focus="handleFocus" @blur="handleBlur" - @input="handleInput" @keyup.enter="handleEnter" >