vxe-pc-ui 3.3.26 → 3.3.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/icon/style.css +1 -1
- package/es/number-input/src/number-input.js +27 -4
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/index.umd.js +58 -8
- package/lib/index.umd.min.js +1 -1
- package/lib/number-input/src/number-input.js +27 -4
- package/lib/number-input/src/number-input.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +2 -2
- package/packages/number-input/src/number-input.ts +28 -4
- package/types/components/number-input.d.ts +1 -0
- package/types/components/table-module/filter.d.ts +2 -2
- package/types/components/table.d.ts +6 -0
- /package/es/icon/{iconfont.1733730280166.ttf → iconfont.1733840904064.ttf} +0 -0
- /package/es/icon/{iconfont.1733730280166.woff → iconfont.1733840904064.woff} +0 -0
- /package/es/icon/{iconfont.1733730280166.woff2 → iconfont.1733840904064.woff2} +0 -0
- /package/es/{iconfont.1733730280166.ttf → iconfont.1733840904064.ttf} +0 -0
- /package/es/{iconfont.1733730280166.woff → iconfont.1733840904064.woff} +0 -0
- /package/es/{iconfont.1733730280166.woff2 → iconfont.1733840904064.woff2} +0 -0
- /package/lib/icon/style/{iconfont.1733730280166.ttf → iconfont.1733840904064.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1733730280166.woff → iconfont.1733840904064.woff} +0 -0
- /package/lib/icon/style/{iconfont.1733730280166.woff2 → iconfont.1733840904064.woff2} +0 -0
- /package/lib/{iconfont.1733730280166.ttf → iconfont.1733840904064.ttf} +0 -0
- /package/lib/{iconfont.1733730280166.woff → iconfont.1733840904064.woff} +0 -0
- /package/lib/{iconfont.1733730280166.woff2 → iconfont.1733840904064.woff2} +0 -0
|
@@ -122,7 +122,8 @@ var _default2 = exports.default = (0, _comp.defineVxeComponent)({
|
|
|
122
122
|
inputValue: ''
|
|
123
123
|
};
|
|
124
124
|
var internalData = {
|
|
125
|
-
dnTimeout: undefined
|
|
125
|
+
// dnTimeout: undefined,
|
|
126
|
+
// isUM: undefined
|
|
126
127
|
};
|
|
127
128
|
return {
|
|
128
129
|
xID: xID,
|
|
@@ -349,11 +350,12 @@ var _default2 = exports.default = (0, _comp.defineVxeComponent)({
|
|
|
349
350
|
var $xeNumberInput = this;
|
|
350
351
|
var props = $xeNumberInput;
|
|
351
352
|
var reactData = $xeNumberInput.reactData;
|
|
353
|
+
var internalData = $xeNumberInput.internalData;
|
|
352
354
|
var $xeForm = $xeNumberInput.$xeForm;
|
|
353
355
|
var formItemInfo = $xeNumberInput.formItemInfo;
|
|
354
356
|
var value = (0, _utils.eqEmptyValue)(val) ? null : Number(val);
|
|
355
357
|
var isChange = value !== props.value;
|
|
356
|
-
|
|
358
|
+
internalData.isUM = true;
|
|
357
359
|
if (isChange) {
|
|
358
360
|
$xeNumberInput.emitModel(value);
|
|
359
361
|
}
|
|
@@ -439,6 +441,24 @@ var _default2 = exports.default = (0, _comp.defineVxeComponent)({
|
|
|
439
441
|
}, evnt);
|
|
440
442
|
}
|
|
441
443
|
},
|
|
444
|
+
updateModel: function updateModel(val) {
|
|
445
|
+
var $xeNumberInput = this;
|
|
446
|
+
var reactData = $xeNumberInput.reactData;
|
|
447
|
+
var inputValue = reactData.inputValue;
|
|
448
|
+
var digitsValue = $xeNumberInput.computeDigitsValue;
|
|
449
|
+
var decimalsType = $xeNumberInput.computeDecimalsType;
|
|
450
|
+
if (decimalsType) {
|
|
451
|
+
if (val) {
|
|
452
|
+
var textValue = '';
|
|
453
|
+
if (val) {
|
|
454
|
+
textValue = (0, _util.toFloatValueFixed)(val, digitsValue);
|
|
455
|
+
}
|
|
456
|
+
if (textValue !== inputValue) {
|
|
457
|
+
reactData.inputValue = textValue;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
},
|
|
442
462
|
/**
|
|
443
463
|
* 检查初始值
|
|
444
464
|
*/
|
|
@@ -904,8 +924,11 @@ var _default2 = exports.default = (0, _comp.defineVxeComponent)({
|
|
|
904
924
|
watch: {
|
|
905
925
|
value: function value(val) {
|
|
906
926
|
var $xeNumberInput = this;
|
|
907
|
-
var
|
|
908
|
-
|
|
927
|
+
var internalData = $xeNumberInput.internalData;
|
|
928
|
+
if (!internalData.isUM) {
|
|
929
|
+
this.updateModel(val);
|
|
930
|
+
}
|
|
931
|
+
internalData.isUM = false;
|
|
909
932
|
},
|
|
910
933
|
type: function type() {
|
|
911
934
|
var $xeNumberInput = this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _comp=require("../../ui/src/comp"),_xeUtils=_interopRequireDefault(require("xe-utils")),_ui=require("../../ui"),_utils=require("../../ui/src/utils"),_dom=require("../../ui/src/dom"),_vn=require("../..//ui/src/vn"),_util=require("./util");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,t,n){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:e+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);n=n.call(e,t||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}var handleNumberString=function(e){return _xeUtils.default.eqNull(e)?"":"".concat(e)},_default2=exports.default=(0,_comp.defineVxeComponent)({name:"VxeNumberInput",mixins:[_ui.globalMixins.sizeMixin],model:{prop:"value",event:"modelValue"},props:{value:[String,Number],immediate:{type:Boolean,default:!0},name:String,type:{type:String,default:"number"},clearable:{type:Boolean,default:function(){return(0,_ui.getConfig)().numberInput.clearable}},readonly:{type:Boolean,default:null},disabled:{type:Boolean,default:null},placeholder:String,maxLength:[String,Number],autoComplete:{type:String,default:"off"},align:String,form:String,className:String,size:{type:String,default:function(){return(0,_ui.getConfig)().numberInput.size||(0,_ui.getConfig)().size}},multiple:Boolean,min:{type:[String,Number],default:null},max:{type:[String,Number],default:null},step:[String,Number],exponential:{type:Boolean,default:function(){return(0,_ui.getConfig)().numberInput.exponential}},controls:{type:Boolean,default:function(){return(0,_ui.getConfig)().numberInput.controls}},digits:{type:[String,Number],default:null},prefixIcon:String,suffixIcon:String,maxlength:[String,Number],autocomplete:String},inject:{$xeForm:{default:null},formItemInfo:{from:"xeFormItemInfo",default:null}},data:function(){return{xID:_xeUtils.default.uniqueId(),reactData:{isFocus:!1,isActivated:!1,inputValue:""},internalData:{dnTimeout:void 0}}},computed:Object.assign(Object.assign({},{}),{computeFormReadonly:function(){var e=this.$xeForm,t=this.readonly;return null===t?!!e&&e.readonly:t},computeIsDisabled:function(){var e=this.$xeForm,t=this.disabled;return null===t?!!e&&e.disabled:t},computeDigitsValue:function(){var e=this.type,t=this.digits;return null===t&&null===(t=(0,_ui.getConfig)().numberInput.digits)&&"amount"===e&&(t=2),_xeUtils.default.toInteger(t)||1},computeDecimalsType:function(){var e=this.type;return"float"===e||"amount"===e},computeStepValue:function(){var e=this,t=e.type,n=e.computeDigitsValue,i=e.computeDecimalsType,e=e.step;return"integer"===t?_xeUtils.default.toInteger(e)||1:i?_xeUtils.default.toNumber(e)||1/Math.pow(10,n):_xeUtils.default.toNumber(e)||1},computeIsClearable:function(){return this.clearable},computeInputReadonly:function(){var e=this.multiple;return this.computeFormReadonly||e},computeInpPlaceholder:function(){var e=this.placeholder;return(e=e||(0,_ui.getConfig)().numberInput.placeholder)?(0,_utils.getFuncText)(e):(0,_ui.getI18n)("vxe.base.pleaseInput")},computeInpMaxLength:function(){var e=this.maxLength,t=this.maxlength;return _xeUtils.default.toNumber(e||t)||16},computeInpImmediate:function(){return this.immediate},computeNumValue:function(){var e=this.reactData,t=this.type,e=e.inputValue;return"integer"===t?_xeUtils.default.toInteger((0,_util.handleNumber)(e)):_xeUtils.default.toNumber((0,_util.handleNumber)(e))},computeNumLabel:function(){var e=this.reactData,t=this.type,e=e.inputValue,n=this.computeDigitsValue;return"amount"===t?_xeUtils.default.commafy(_xeUtils.default.toNumber(e),{digits:n}):_xeUtils.default.toString(e)},computeIsDisabledSubtractNumber:function(){var e=this.reactData,t=this.min,e=e.inputValue,n=this.computeNumValue;return!(!e&&0!==e||null===t)&&n<=_xeUtils.default.toNumber(t)},computeIsDisabledAddNumber:function(){var e=this.reactData,t=this.max,e=e.inputValue,n=this.computeNumValue;return!(!e&&0!==e||null===t)&&n>=_xeUtils.default.toNumber(t)}}),methods:{dispatchEvent:function(e,t,n){this.$emit(e,(0,_ui.createEvent)(n,{$numberInput:this},t))},emitModel:function(e){var t=this._events;t&&t.modelValue?this.$emit("modelValue",e):this.$emit("model-value",e)},focus:function(){var e=this.reactData,t=this.$refs.refInputTarget;return e.isActivated=!0,t.focus(),this.$nextTick()},blur:function(){var e=this.reactData;return this.$refs.refInputTarget.blur(),e.isActivated=!1,this.$nextTick()},select:function(){var e=this.reactData;return this.$refs.refInputTarget.select(),e.isActivated=!1,this.$nextTick()},getNumberValue:function(e){var t=this.exponential,n=this.computeInpMaxLength,i=this.computeDigitsValue,i=this.computeDecimalsType?(0,_util.toFloatValueFixed)(e,i):handleNumberString(e);return!t||e!==i&&handleNumberString(e).toLowerCase()!==_xeUtils.default.toNumber(i).toExponential()?i.slice(0,n):e},triggerEvent:function(e){var t=this.reactData.inputValue;this.dispatchEvent(e.type,{value:t},e)},handleChange:function(e,t,n){var i=this,u=i,a=i.reactData,r=i.$xeForm,l=i.formItemInfo,e=(0,_utils.eqEmptyValue)(e)?null:Number(e),u=e!==u.value;a.inputValue=t||"",u&&i.emitModel(e),a.inputValue!==t&&i.$nextTick(function(){a.inputValue=t||""}),i.dispatchEvent("input",{value:e},n),u&&(i.dispatchEvent("change",{value:e},n),r)&&l&&r.triggerItemEvent(n,l.itemConfig.field,e)},emitInputEvent:function(e,t){var n=this.reactData,i=this.computeInpImmediate,u=""===e||_xeUtils.default.eqNull(e)?null:_xeUtils.default.toNumber(e);n.inputValue=e,i?this.handleChange(u,e,t):this.dispatchEvent("input",{value:u},t)},inputEvent:function(e){var t=e.target.value;this.emitInputEvent(t,e)},changeEvent:function(e){this.computeInpImmediate||this.triggerEvent(e)},focusEvent:function(e){var t=this.reactData;t.isFocus=!0,t.isActivated=!0,this.triggerEvent(e)},clickPrefixEvent:function(e){var t=this.reactData;this.computeIsDisabled||(t=t.inputValue,this.dispatchEvent("prefix-click",{value:t},e))},clearValueEvent:function(e,t){this.focus(),this.handleChange(null,"",e),this.dispatchEvent("clear",{value:t},e)},clickSuffixEvent:function(e){var t=this.reactData;this.computeIsDisabled||(t=t.inputValue,this.dispatchEvent("suffix-click",{value:t},e))},initValue:function(){var e,t,n=this.reactData.inputValue,i=this.computeDigitsValue;this.computeDecimalsType&&n&&(e="",t=null,n&&(e=(0,_util.toFloatValueFixed)(n,i),t=Number(e)),n!==t)&&this.handleChange(t,e,{type:"init"})},validMaxNum:function(e){return null===this.max||_xeUtils.default.toNumber(e)<=_xeUtils.default.toNumber(this.max)},validMinNum:function(e){return null===this.min||_xeUtils.default.toNumber(e)>=_xeUtils.default.toNumber(this.min)},afterCheckValue:function(){var e,t,n=this,i=n.reactData,u=n.type,a=n.min,r=n.max,l=n.exponential,i=i.inputValue;n.computeInputReadonly||((0,_utils.eqEmptyValue)(i)?(e=null,t=i,!a&&0!==a||(e=_xeUtils.default.toNumber(a),t="".concat(e)),n.handleChange(e,"".concat(t||""),{type:"check"})):(i||a||r)&&(e="integer"===u?_xeUtils.default.toInteger((0,_util.handleNumber)(i)):_xeUtils.default.toNumber((0,_util.handleNumber)(i)),n.validMinNum(e)?n.validMaxNum(e)||(e=r):e=a,l&&(t=handleNumberString(i).toLowerCase())===_xeUtils.default.toNumber(e).toExponential()&&(e=t),u=n.getNumberValue(e),n.handleChange((0,_utils.eqEmptyValue)(u)?null:Number(u),u,{type:"check"})))},blurEvent:function(e){var t=this,n=t.reactData,i=t.$xeForm,u=t.formItemInfo,a=n.inputValue,r=t.computeInpImmediate,l=a?Number(a):null;r||t.handleChange(l,handleNumberString(a),e),t.afterCheckValue(),n.isFocus=!1,n.isActivated=!1,t.dispatchEvent("blur",{value:l},e),i&&u&&i.triggerItemEvent(e,u.itemConfig.field,l)},numberChange:function(e,t){var n=this,i=n.reactData,u=n.min,a=n.max,i=i.inputValue,r=n.computeStepValue,i="integer"===n.type?_xeUtils.default.toInteger((0,_util.handleNumber)(i)):_xeUtils.default.toNumber((0,_util.handleNumber)(i)),e=e?_xeUtils.default.add(i,r):_xeUtils.default.subtract(i,r),i=n.validMinNum(e)?n.validMaxNum(e)?e:a:u;n.emitInputEvent(n.getNumberValue(i),t)},numberNextEvent:function(e){var t=this,n=t.reactData,i=t.computeIsDisabled,u=t.computeFormReadonly,a=t.computeIsDisabledSubtractNumber;t.numberStopDown(),i||u||a||t.numberChange(!1,e),t.dispatchEvent("next-number",{value:n.inputValue},e)},numberDownNextEvent:function(e){var t=this;t.internalData.dnTimeout=window.setTimeout(function(){t.numberNextEvent(e),t.numberDownNextEvent(e)},60)},numberPrevEvent:function(e){var t=this,n=t.reactData,i=t.computeIsDisabled,u=t.computeFormReadonly,a=t.computeIsDisabledAddNumber;t.numberStopDown(),i||u||a||t.numberChange(!0,e),t.dispatchEvent("prev-number",{value:n.inputValue},e)},numberKeydownEvent:function(e){var t=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.ARROW_UP),n=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.ARROW_DOWN);(t||n)&&(e.preventDefault(),t?this.numberPrevEvent(e):this.numberNextEvent(e))},keydownEvent:function(e){var t=this.exponential,n=this.controls,i=e.ctrlKey,u=e.shiftKey,a=e.altKey,r=e.keyCode,l=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.ESCAPE),o=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.ARROW_UP),s=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.ARROW_DOWN);i||u||a||!(_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.SPACEBAR)||(!t||69!==r)&&65<=r&&r<=90||186<=r&&r<=188||191<=r)||e.preventDefault(),l?this.afterCheckValue():(o||s)&&n&&this.numberKeydownEvent(e),this.triggerEvent(e)},keyupEvent:function(e){this.triggerEvent(e)},numberStopDown:function(){var e=this.internalData,t=e.dnTimeout;t&&(clearTimeout(t),e.dnTimeout=void 0)},numberDownPrevEvent:function(e){var t=this;t.internalData.dnTimeout=window.setTimeout(function(){t.numberPrevEvent(e),t.numberDownPrevEvent(e)},60)},numberMousedownEvent:function(e){var t,n=this,i=n.internalData;n.numberStopDown(),0===e.button&&((t=(0,_dom.hasClass)(e.currentTarget,"is--prev"))?n.numberPrevEvent(e):n.numberNextEvent(e),i.dnTimeout=window.setTimeout(function(){t?n.numberDownPrevEvent(e):n.numberDownNextEvent(e)},500))},wheelEvent:function(e){var t=this,n=t.reactData;t.controls&&n.isActivated&&(0<(n=e.deltaY)?t.numberNextEvent(e):n<0&&t.numberPrevEvent(e),e.preventDefault()),t.triggerEvent(e)},clickEvent:function(e){this.triggerEvent(e)},handleGlobalMousedownEvent:function(e){var t=this,n=t.reactData,i=n.isActivated,u=t.$refs.refElem,a=t.$refs.refInputPanel;!t.computeIsDisabled&&i&&(n.isActivated=(0,_dom.getEventTargetNode)(e,u).flag||(0,_dom.getEventTargetNode)(e,a).flag,n.isActivated||t.afterCheckValue())},handleGlobalKeydownEvent:function(e){var t,n,i,u=this,a=u.reactData,r=u.clearable;u.computeIsDisabled||(t=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.TAB),n=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.DELETE),i=a.isActivated,t&&(i&&u.afterCheckValue(),a.isActivated=i=!1),n&&r&&i&&u.clearValueEvent(e,null))},handleGlobalBlurEvent:function(){this.reactData.isActivated&&this.afterCheckValue()},renderNumberIcon:function(e){var t=this,n=t.computeIsDisabledAddNumber,i=t.computeIsDisabledSubtractNumber;return e("div",{class:"vxe-input--control-icon"},[e("div",{class:"vxe-input--number-icon"},[e("div",{class:["vxe-input--number-btn is--prev",{"is--disabled":n}],on:{mousedown:t.numberMousedownEvent,mouseup:t.numberStopDown,mouseleave:t.numberStopDown}},[e("i",{class:(0,_ui.getIcon)().NUMBER_INPUT_PREV_NUM})]),e("div",{class:["vxe-input--number-btn is--next",{"is--disabled":i}],on:{mousedown:t.numberMousedownEvent,mouseup:t.numberStopDown,mouseleave:t.numberStopDown}},[e("i",{class:(0,_ui.getIcon)().NUMBER_INPUT_NEXT_NUM})])])])},renderPrefixIcon:function(e){var t=this.$scopedSlots,n=this.prefixIcon,t=t.prefix;return t||n?e("div",{class:"vxe-number-input--prefix",on:{click:this.clickPrefixEvent}},[e("div",{class:"vxe-number-input--prefix-icon"},t?(0,_vn.getSlotVNs)(t({})):[e("i",{class:n})])]):null},renderSuffixIcon:function(e){var t=this,n=t.$scopedSlots,i=t.suffixIcon,u=t.reactData.inputValue,n=n.suffix,a=t.computeIsClearable;return e("div",{class:["vxe-number-input--suffix",{"is--clear":a&&!t.computeIsDisabled&&!(""===u||_xeUtils.default.eqNull(u))}]},[a?e("div",{class:"vxe-number-input--clear-icon",on:{click:t.clearValueEvent}},[e("i",{class:(0,_ui.getIcon)().INPUT_CLEAR})]):(0,_ui.renderEmptyElement)(t),t.renderExtraSuffixIcon(e),n||i?e("div",{class:"vxe-number-input--suffix-icon",on:{click:t.clickSuffixEvent}},n?(0,_vn.getSlotVNs)(n({})):[e("i",{class:i})]):(0,_ui.renderEmptyElement)(t)])},renderExtraSuffixIcon:function(e){return this.controls?this.renderNumberIcon(e):(0,_ui.renderEmptyElement)(this)},renderVN:function(e){var t,n,i,u,a,r,l=this,o=l.reactData,s=l.className,c=l.controls,m=l.type,d=l.align,p=l.name,f=l.autocomplete,v=l.autoComplete,h=o.inputValue,b=o.isFocus,o=o.isActivated,_=l.computeSize,E=l.computeIsDisabled,g=l.computeNumLabel;return l.computeFormReadonly?e("div",{ref:"refElem",class:["vxe-number-input--readonly","type--".concat(m),s]},g):(t=l.computeInputReadonly,n=l.computeInpMaxLength,i=l.computeInpPlaceholder,u=l.computeIsClearable,a=l.renderPrefixIcon(e),r=l.renderSuffixIcon(e),e("div",{ref:"refElem",class:["vxe-number-input","type--".concat(m),s,_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({},"size--".concat(_),_),"is--".concat(d),d),"is--controls",c),"is--prefix",!!a),"is--suffix",!!r),"is--disabled",E),"is--active",o),"show--clear",u&&!E&&!(""===h||_xeUtils.default.eqNull(h)))],attrs:{spellcheck:!1}},[a||(0,_ui.renderEmptyElement)(l),e("div",{class:"vxe-number-input--wrapper"},[e("input",{ref:"refInputTarget",class:"vxe-number-input--inner",domProps:{value:b||"amount"!==m?h:g},attrs:{name:p,type:"text",placeholder:i,maxlength:n,readonly:t,disabled:E,autocomplete:v||f},on:{keydown:l.keydownEvent,keyup:l.keyupEvent,wheel:l.wheelEvent,click:l.clickEvent,input:l.inputEvent,change:l.changeEvent,focus:l.focusEvent,blur:l.blurEvent}})]),r||(0,_ui.renderEmptyElement)(l)]))}},watch:{value:function(e){this.reactData.inputValue=e},type:function(){var e=this.reactData;Object.assign(e,{inputValue:this.value}),this.initValue()}},created:function(){this.reactData.inputValue=this.value,this.initValue()},mounted:function(){var e=this;_ui.globalEvents.on(e,"mousedown",e.handleGlobalMousedownEvent),_ui.globalEvents.on(e,"keydown",e.handleGlobalKeydownEvent),_ui.globalEvents.on(e,"blur",e.handleGlobalBlurEvent)},beforeDestroy:function(){var e=this;e.reactData.isFocus=!1,e.numberStopDown(),e.afterCheckValue(),_ui.globalEvents.off(e,"mousedown"),_ui.globalEvents.off(e,"keydown"),_ui.globalEvents.off(e,"blur")},render:function(e){return this.renderVN(e)}});
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _comp=require("../../ui/src/comp"),_xeUtils=_interopRequireDefault(require("xe-utils")),_ui=require("../../ui"),_utils=require("../../ui/src/utils"),_dom=require("../../ui/src/dom"),_vn=require("../..//ui/src/vn"),_util=require("./util");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,t,n){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:e+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);n=n.call(e,t||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}var handleNumberString=function(e){return _xeUtils.default.eqNull(e)?"":"".concat(e)},_default2=exports.default=(0,_comp.defineVxeComponent)({name:"VxeNumberInput",mixins:[_ui.globalMixins.sizeMixin],model:{prop:"value",event:"modelValue"},props:{value:[String,Number],immediate:{type:Boolean,default:!0},name:String,type:{type:String,default:"number"},clearable:{type:Boolean,default:function(){return(0,_ui.getConfig)().numberInput.clearable}},readonly:{type:Boolean,default:null},disabled:{type:Boolean,default:null},placeholder:String,maxLength:[String,Number],autoComplete:{type:String,default:"off"},align:String,form:String,className:String,size:{type:String,default:function(){return(0,_ui.getConfig)().numberInput.size||(0,_ui.getConfig)().size}},multiple:Boolean,min:{type:[String,Number],default:null},max:{type:[String,Number],default:null},step:[String,Number],exponential:{type:Boolean,default:function(){return(0,_ui.getConfig)().numberInput.exponential}},controls:{type:Boolean,default:function(){return(0,_ui.getConfig)().numberInput.controls}},digits:{type:[String,Number],default:null},prefixIcon:String,suffixIcon:String,maxlength:[String,Number],autocomplete:String},inject:{$xeForm:{default:null},formItemInfo:{from:"xeFormItemInfo",default:null}},data:function(){return{xID:_xeUtils.default.uniqueId(),reactData:{isFocus:!1,isActivated:!1,inputValue:""},internalData:{}}},computed:Object.assign(Object.assign({},{}),{computeFormReadonly:function(){var e=this.$xeForm,t=this.readonly;return null===t?!!e&&e.readonly:t},computeIsDisabled:function(){var e=this.$xeForm,t=this.disabled;return null===t?!!e&&e.disabled:t},computeDigitsValue:function(){var e=this.type,t=this.digits;return null===t&&null===(t=(0,_ui.getConfig)().numberInput.digits)&&"amount"===e&&(t=2),_xeUtils.default.toInteger(t)||1},computeDecimalsType:function(){var e=this.type;return"float"===e||"amount"===e},computeStepValue:function(){var e=this,t=e.type,n=e.computeDigitsValue,i=e.computeDecimalsType,e=e.step;return"integer"===t?_xeUtils.default.toInteger(e)||1:i?_xeUtils.default.toNumber(e)||1/Math.pow(10,n):_xeUtils.default.toNumber(e)||1},computeIsClearable:function(){return this.clearable},computeInputReadonly:function(){var e=this.multiple;return this.computeFormReadonly||e},computeInpPlaceholder:function(){var e=this.placeholder;return(e=e||(0,_ui.getConfig)().numberInput.placeholder)?(0,_utils.getFuncText)(e):(0,_ui.getI18n)("vxe.base.pleaseInput")},computeInpMaxLength:function(){var e=this.maxLength,t=this.maxlength;return _xeUtils.default.toNumber(e||t)||16},computeInpImmediate:function(){return this.immediate},computeNumValue:function(){var e=this.reactData,t=this.type,e=e.inputValue;return"integer"===t?_xeUtils.default.toInteger((0,_util.handleNumber)(e)):_xeUtils.default.toNumber((0,_util.handleNumber)(e))},computeNumLabel:function(){var e=this.reactData,t=this.type,e=e.inputValue,n=this.computeDigitsValue;return"amount"===t?_xeUtils.default.commafy(_xeUtils.default.toNumber(e),{digits:n}):_xeUtils.default.toString(e)},computeIsDisabledSubtractNumber:function(){var e=this.reactData,t=this.min,e=e.inputValue,n=this.computeNumValue;return!(!e&&0!==e||null===t)&&n<=_xeUtils.default.toNumber(t)},computeIsDisabledAddNumber:function(){var e=this.reactData,t=this.max,e=e.inputValue,n=this.computeNumValue;return!(!e&&0!==e||null===t)&&n>=_xeUtils.default.toNumber(t)}}),methods:{dispatchEvent:function(e,t,n){this.$emit(e,(0,_ui.createEvent)(n,{$numberInput:this},t))},emitModel:function(e){var t=this._events;t&&t.modelValue?this.$emit("modelValue",e):this.$emit("model-value",e)},focus:function(){var e=this.reactData,t=this.$refs.refInputTarget;return e.isActivated=!0,t.focus(),this.$nextTick()},blur:function(){var e=this.reactData;return this.$refs.refInputTarget.blur(),e.isActivated=!1,this.$nextTick()},select:function(){var e=this.reactData;return this.$refs.refInputTarget.select(),e.isActivated=!1,this.$nextTick()},getNumberValue:function(e){var t=this.exponential,n=this.computeInpMaxLength,i=this.computeDigitsValue,i=this.computeDecimalsType?(0,_util.toFloatValueFixed)(e,i):handleNumberString(e);return!t||e!==i&&handleNumberString(e).toLowerCase()!==_xeUtils.default.toNumber(i).toExponential()?i.slice(0,n):e},triggerEvent:function(e){var t=this.reactData.inputValue;this.dispatchEvent(e.type,{value:t},e)},handleChange:function(e,t,n){var i=this,u=i,a=i.reactData,r=i.internalData,l=i.$xeForm,o=i.formItemInfo,e=(0,_utils.eqEmptyValue)(e)?null:Number(e),u=e!==u.value;r.isUM=!0,u&&i.emitModel(e),a.inputValue!==t&&i.$nextTick(function(){a.inputValue=t||""}),i.dispatchEvent("input",{value:e},n),u&&(i.dispatchEvent("change",{value:e},n),l)&&o&&l.triggerItemEvent(n,o.itemConfig.field,e)},emitInputEvent:function(e,t){var n=this.reactData,i=this.computeInpImmediate,u=""===e||_xeUtils.default.eqNull(e)?null:_xeUtils.default.toNumber(e);n.inputValue=e,i?this.handleChange(u,e,t):this.dispatchEvent("input",{value:u},t)},inputEvent:function(e){var t=e.target.value;this.emitInputEvent(t,e)},changeEvent:function(e){this.computeInpImmediate||this.triggerEvent(e)},focusEvent:function(e){var t=this.reactData;t.isFocus=!0,t.isActivated=!0,this.triggerEvent(e)},clickPrefixEvent:function(e){var t=this.reactData;this.computeIsDisabled||(t=t.inputValue,this.dispatchEvent("prefix-click",{value:t},e))},clearValueEvent:function(e,t){this.focus(),this.handleChange(null,"",e),this.dispatchEvent("clear",{value:t},e)},clickSuffixEvent:function(e){var t=this.reactData;this.computeIsDisabled||(t=t.inputValue,this.dispatchEvent("suffix-click",{value:t},e))},updateModel:function(e){var t,n=this.reactData,i=n.inputValue,u=this.computeDigitsValue;this.computeDecimalsType&&e&&(t="",(t=e?(0,_util.toFloatValueFixed)(e,u):t)!==i)&&(n.inputValue=t)},initValue:function(){var e,t,n=this.reactData.inputValue,i=this.computeDigitsValue;this.computeDecimalsType&&n&&(e="",t=null,n&&(e=(0,_util.toFloatValueFixed)(n,i),t=Number(e)),n!==t)&&this.handleChange(t,e,{type:"init"})},validMaxNum:function(e){return null===this.max||_xeUtils.default.toNumber(e)<=_xeUtils.default.toNumber(this.max)},validMinNum:function(e){return null===this.min||_xeUtils.default.toNumber(e)>=_xeUtils.default.toNumber(this.min)},afterCheckValue:function(){var e,t,n=this,i=n.reactData,u=n.type,a=n.min,r=n.max,l=n.exponential,i=i.inputValue;n.computeInputReadonly||((0,_utils.eqEmptyValue)(i)?(e=null,t=i,!a&&0!==a||(e=_xeUtils.default.toNumber(a),t="".concat(e)),n.handleChange(e,"".concat(t||""),{type:"check"})):(i||a||r)&&(e="integer"===u?_xeUtils.default.toInteger((0,_util.handleNumber)(i)):_xeUtils.default.toNumber((0,_util.handleNumber)(i)),n.validMinNum(e)?n.validMaxNum(e)||(e=r):e=a,l&&(t=handleNumberString(i).toLowerCase())===_xeUtils.default.toNumber(e).toExponential()&&(e=t),u=n.getNumberValue(e),n.handleChange((0,_utils.eqEmptyValue)(u)?null:Number(u),u,{type:"check"})))},blurEvent:function(e){var t=this,n=t.reactData,i=t.$xeForm,u=t.formItemInfo,a=n.inputValue,r=t.computeInpImmediate,l=a?Number(a):null;r||t.handleChange(l,handleNumberString(a),e),t.afterCheckValue(),n.isFocus=!1,n.isActivated=!1,t.dispatchEvent("blur",{value:l},e),i&&u&&i.triggerItemEvent(e,u.itemConfig.field,l)},numberChange:function(e,t){var n=this,i=n.reactData,u=n.min,a=n.max,i=i.inputValue,r=n.computeStepValue,i="integer"===n.type?_xeUtils.default.toInteger((0,_util.handleNumber)(i)):_xeUtils.default.toNumber((0,_util.handleNumber)(i)),e=e?_xeUtils.default.add(i,r):_xeUtils.default.subtract(i,r),i=n.validMinNum(e)?n.validMaxNum(e)?e:a:u;n.emitInputEvent(n.getNumberValue(i),t)},numberNextEvent:function(e){var t=this,n=t.reactData,i=t.computeIsDisabled,u=t.computeFormReadonly,a=t.computeIsDisabledSubtractNumber;t.numberStopDown(),i||u||a||t.numberChange(!1,e),t.dispatchEvent("next-number",{value:n.inputValue},e)},numberDownNextEvent:function(e){var t=this;t.internalData.dnTimeout=window.setTimeout(function(){t.numberNextEvent(e),t.numberDownNextEvent(e)},60)},numberPrevEvent:function(e){var t=this,n=t.reactData,i=t.computeIsDisabled,u=t.computeFormReadonly,a=t.computeIsDisabledAddNumber;t.numberStopDown(),i||u||a||t.numberChange(!0,e),t.dispatchEvent("prev-number",{value:n.inputValue},e)},numberKeydownEvent:function(e){var t=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.ARROW_UP),n=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.ARROW_DOWN);(t||n)&&(e.preventDefault(),t?this.numberPrevEvent(e):this.numberNextEvent(e))},keydownEvent:function(e){var t=this.exponential,n=this.controls,i=e.ctrlKey,u=e.shiftKey,a=e.altKey,r=e.keyCode,l=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.ESCAPE),o=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.ARROW_UP),s=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.ARROW_DOWN);i||u||a||!(_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.SPACEBAR)||(!t||69!==r)&&65<=r&&r<=90||186<=r&&r<=188||191<=r)||e.preventDefault(),l?this.afterCheckValue():(o||s)&&n&&this.numberKeydownEvent(e),this.triggerEvent(e)},keyupEvent:function(e){this.triggerEvent(e)},numberStopDown:function(){var e=this.internalData,t=e.dnTimeout;t&&(clearTimeout(t),e.dnTimeout=void 0)},numberDownPrevEvent:function(e){var t=this;t.internalData.dnTimeout=window.setTimeout(function(){t.numberPrevEvent(e),t.numberDownPrevEvent(e)},60)},numberMousedownEvent:function(e){var t,n=this,i=n.internalData;n.numberStopDown(),0===e.button&&((t=(0,_dom.hasClass)(e.currentTarget,"is--prev"))?n.numberPrevEvent(e):n.numberNextEvent(e),i.dnTimeout=window.setTimeout(function(){t?n.numberDownPrevEvent(e):n.numberDownNextEvent(e)},500))},wheelEvent:function(e){var t=this,n=t.reactData;t.controls&&n.isActivated&&(0<(n=e.deltaY)?t.numberNextEvent(e):n<0&&t.numberPrevEvent(e),e.preventDefault()),t.triggerEvent(e)},clickEvent:function(e){this.triggerEvent(e)},handleGlobalMousedownEvent:function(e){var t=this,n=t.reactData,i=n.isActivated,u=t.$refs.refElem,a=t.$refs.refInputPanel;!t.computeIsDisabled&&i&&(n.isActivated=(0,_dom.getEventTargetNode)(e,u).flag||(0,_dom.getEventTargetNode)(e,a).flag,n.isActivated||t.afterCheckValue())},handleGlobalKeydownEvent:function(e){var t,n,i,u=this,a=u.reactData,r=u.clearable;u.computeIsDisabled||(t=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.TAB),n=_ui.globalEvents.hasKey(e,_ui.GLOBAL_EVENT_KEYS.DELETE),i=a.isActivated,t&&(i&&u.afterCheckValue(),a.isActivated=i=!1),n&&r&&i&&u.clearValueEvent(e,null))},handleGlobalBlurEvent:function(){this.reactData.isActivated&&this.afterCheckValue()},renderNumberIcon:function(e){var t=this,n=t.computeIsDisabledAddNumber,i=t.computeIsDisabledSubtractNumber;return e("div",{class:"vxe-input--control-icon"},[e("div",{class:"vxe-input--number-icon"},[e("div",{class:["vxe-input--number-btn is--prev",{"is--disabled":n}],on:{mousedown:t.numberMousedownEvent,mouseup:t.numberStopDown,mouseleave:t.numberStopDown}},[e("i",{class:(0,_ui.getIcon)().NUMBER_INPUT_PREV_NUM})]),e("div",{class:["vxe-input--number-btn is--next",{"is--disabled":i}],on:{mousedown:t.numberMousedownEvent,mouseup:t.numberStopDown,mouseleave:t.numberStopDown}},[e("i",{class:(0,_ui.getIcon)().NUMBER_INPUT_NEXT_NUM})])])])},renderPrefixIcon:function(e){var t=this.$scopedSlots,n=this.prefixIcon,t=t.prefix;return t||n?e("div",{class:"vxe-number-input--prefix",on:{click:this.clickPrefixEvent}},[e("div",{class:"vxe-number-input--prefix-icon"},t?(0,_vn.getSlotVNs)(t({})):[e("i",{class:n})])]):null},renderSuffixIcon:function(e){var t=this,n=t.$scopedSlots,i=t.suffixIcon,u=t.reactData.inputValue,n=n.suffix,a=t.computeIsClearable;return e("div",{class:["vxe-number-input--suffix",{"is--clear":a&&!t.computeIsDisabled&&!(""===u||_xeUtils.default.eqNull(u))}]},[a?e("div",{class:"vxe-number-input--clear-icon",on:{click:t.clearValueEvent}},[e("i",{class:(0,_ui.getIcon)().INPUT_CLEAR})]):(0,_ui.renderEmptyElement)(t),t.renderExtraSuffixIcon(e),n||i?e("div",{class:"vxe-number-input--suffix-icon",on:{click:t.clickSuffixEvent}},n?(0,_vn.getSlotVNs)(n({})):[e("i",{class:i})]):(0,_ui.renderEmptyElement)(t)])},renderExtraSuffixIcon:function(e){return this.controls?this.renderNumberIcon(e):(0,_ui.renderEmptyElement)(this)},renderVN:function(e){var t,n,i,u,a,r,l=this,o=l.reactData,s=l.className,c=l.controls,m=l.type,p=l.align,d=l.name,f=l.autocomplete,v=l.autoComplete,h=o.inputValue,b=o.isFocus,o=o.isActivated,_=l.computeSize,E=l.computeIsDisabled,g=l.computeNumLabel;return l.computeFormReadonly?e("div",{ref:"refElem",class:["vxe-number-input--readonly","type--".concat(m),s]},g):(t=l.computeInputReadonly,n=l.computeInpMaxLength,i=l.computeInpPlaceholder,u=l.computeIsClearable,a=l.renderPrefixIcon(e),r=l.renderSuffixIcon(e),e("div",{ref:"refElem",class:["vxe-number-input","type--".concat(m),s,_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({},"size--".concat(_),_),"is--".concat(p),p),"is--controls",c),"is--prefix",!!a),"is--suffix",!!r),"is--disabled",E),"is--active",o),"show--clear",u&&!E&&!(""===h||_xeUtils.default.eqNull(h)))],attrs:{spellcheck:!1}},[a||(0,_ui.renderEmptyElement)(l),e("div",{class:"vxe-number-input--wrapper"},[e("input",{ref:"refInputTarget",class:"vxe-number-input--inner",domProps:{value:b||"amount"!==m?h:g},attrs:{name:d,type:"text",placeholder:i,maxlength:n,readonly:t,disabled:E,autocomplete:v||f},on:{keydown:l.keydownEvent,keyup:l.keyupEvent,wheel:l.wheelEvent,click:l.clickEvent,input:l.inputEvent,change:l.changeEvent,focus:l.focusEvent,blur:l.blurEvent}})]),r||(0,_ui.renderEmptyElement)(l)]))}},watch:{value:function(e){var t=this.internalData;t.isUM||this.updateModel(e),t.isUM=!1},type:function(){var e=this.reactData;Object.assign(e,{inputValue:this.value}),this.initValue()}},created:function(){this.reactData.inputValue=this.value,this.initValue()},mounted:function(){var e=this;_ui.globalEvents.on(e,"mousedown",e.handleGlobalMousedownEvent),_ui.globalEvents.on(e,"keydown",e.handleGlobalKeydownEvent),_ui.globalEvents.on(e,"blur",e.handleGlobalBlurEvent)},beforeDestroy:function(){var e=this;e.reactData.isFocus=!1,e.numberStopDown(),e.afterCheckValue(),_ui.globalEvents.off(e,"mousedown"),_ui.globalEvents.off(e,"keydown"),_ui.globalEvents.off(e,"blur")},render:function(e){return this.renderVN(e)}});
|