Fixed #1502 - Add allowEmpty property to InputNumber
parent
a14af778f8
commit
75e14a66d4
|
@ -20,6 +20,7 @@ interface InputNumberProps {
|
||||||
min?: number;
|
min?: number;
|
||||||
max?: number;
|
max?: number;
|
||||||
step?: number;
|
step?: number;
|
||||||
|
allowEmpty?: boolean;
|
||||||
inputStyle?: any;
|
inputStyle?: any;
|
||||||
inputClass?: string;
|
inputClass?: string;
|
||||||
style?: any;
|
style?: any;
|
||||||
|
|
|
@ -104,6 +104,10 @@ export default {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 1
|
default: 1
|
||||||
},
|
},
|
||||||
|
allowEmpty: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
style: null,
|
style: null,
|
||||||
class: null,
|
class: null,
|
||||||
inputStyle: null,
|
inputStyle: null,
|
||||||
|
@ -740,6 +744,7 @@ export default {
|
||||||
|
|
||||||
if (valueStr != null) {
|
if (valueStr != null) {
|
||||||
newValue = this.parseValue(valueStr);
|
newValue = this.parseValue(valueStr);
|
||||||
|
newValue = !newValue && !this.allowEmpty ? 0 : newValue;
|
||||||
this.updateInput(newValue, insertedValueStr, operation, valueStr);
|
this.updateInput(newValue, insertedValueStr, operation, valueStr);
|
||||||
|
|
||||||
this.handleOnInput(event, currentValue, newValue);
|
this.handleOnInput(event, currentValue, newValue);
|
||||||
|
@ -931,7 +936,8 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
formattedValue() {
|
formattedValue() {
|
||||||
return this.formatValue(this.modelValue);
|
const val = !this.modelValue && !this.allowEmpty ? 0 : this.modelValue;
|
||||||
|
return this.formatValue(val);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
Loading…
Reference in New Issue