@progress/kendo-vue-inputs 10.1.0 → 10.1.1-develop.2
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/dist/cdn/js/kendo-vue-inputs.js +1 -1
- package/numerictextbox/NumericTextBox.d.ts +4 -0
- package/numerictextbox/NumericTextBox.js +1 -1
- package/numerictextbox/NumericTextBox.mjs +161 -86
- package/numerictextbox/utils/main.d.ts +13 -0
- package/numerictextbox/utils/main.js +1 -1
- package/numerictextbox/utils/main.mjs +154 -131
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +9 -9
|
@@ -120,6 +120,7 @@ declare const NumericTextBox: import('vue').DefineComponent<import('vue').Extrac
|
|
|
120
120
|
focused: boolean;
|
|
121
121
|
forceUpdate: boolean;
|
|
122
122
|
}, {
|
|
123
|
+
isPlainNumberEditing(): boolean;
|
|
123
124
|
computedValue(): number | undefined;
|
|
124
125
|
looseValue(): string;
|
|
125
126
|
spanClassNames(): {
|
|
@@ -167,12 +168,15 @@ declare const NumericTextBox: import('vue').DefineComponent<import('vue').Extrac
|
|
|
167
168
|
};
|
|
168
169
|
parseNumber(text: string): number;
|
|
169
170
|
elementChange(event: any): void;
|
|
171
|
+
plainNumberChange(event: any): void;
|
|
170
172
|
triggerChange(event: any, newState: NumericTextBoxData): void;
|
|
171
173
|
onPasteHandler(_event: any): void;
|
|
172
174
|
increase(event: any): void;
|
|
173
175
|
decrease(event: any): void;
|
|
176
|
+
toPlainNumberState(newState: NumericTextBoxData): NumericTextBoxData;
|
|
174
177
|
wheel(event: any): void;
|
|
175
178
|
keyDown(event: any): void;
|
|
179
|
+
plainNumberKeyDown(event: any): void;
|
|
176
180
|
spinnersWrapperMouseDown(e: any): void;
|
|
177
181
|
}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
178
182
|
change: (event: NumericTextBoxChangeEvent) => true;
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),i=require("@progress/kendo-vue-common"),$=require("@progress/kendo-vue-intl"),g=require("@progress/kendo-vue-buttons"),r=require("../messages/main.js"),a=require("./utils/main.js"),S=require("../package-metadata.js"),h=require("@progress/kendo-svg-icons"),k="Please enter a valid value!",y=s.defineComponent({model:{event:"changemodel"},emits:{change:t=>!0,changemodel:t=>!0,"update:modelValue":t=>!0,focus:t=>!0,blur:t=>!0},props:{modelValue:Number,value:Number,defaultValue:Number,step:{type:Number,default:1},format:[String,Object],tabIndex:Number,accessKey:String,title:String,placeholder:String,min:Number,max:Number,spinners:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},dir:String,name:String,label:String,validationMessage:String,validityStyles:{type:Boolean,default:!0},valid:{type:Boolean,default:void 0},size:{type:String,validator:function(t){return["small","medium","large"].includes(t)}},rounded:{type:String,validator:function(t){return["none","small","medium","large","full"].includes(t)}},fillMode:{type:String,validator:function(t){return["solid","flat","outline"].includes(t)}},required:{type:Boolean,default:!1},id:String,ariaLabel:String,iconName:String,inputPrefix:[String,Function],inputSuffix:[String,Function],showValidationIcon:Boolean,showLoadingIcon:Boolean,showClearButton:Boolean,inputClass:String,inputType:{type:String,default:"tel"},wrapperClass:String,inputAttributes:Object},inject:{kendoIntlService:{default:null},kendoLocalizationService:{default:null}},data(){return{hasMounted:!1,isInvalid:!1,isEmpty:!1,currentValue:0,valueDuringOnChange:0,currentLooseValue:"",selectionStart:0,selectionEnd:0,decimalSelect:!1,focused:!1,forceUpdate:!1}},created(){i.validatePackage(S.packageMetadata),this._textBeforeInput="",this._inputId=i.guid(),this.$data.currentLooseValue=null,this.$data.valueDuringOnChange=void 0,this._intl=$.provideIntlService(this),this._symbols=this._intl.numberSymbols(),this.$props.value!==void 0?this.$data.currentValue=this.$props.value:this.$props.modelValue!==void 0?this.$data.currentValue=this.$props.modelValue:this.$props.defaultValue!==void 0?this.$data.currentValue=this.$props.defaultValue:this.$data.currentValue=null},mounted(){this._input=i.getRef(this,"input"),this._elementWrapper=this.elementWrapperRef,this.$data.hasMounted=!0,this._input&&(this._textBeforeInput=this._input.value),this.setValidity()},updated(){!(i.canUseDOM&&document.activeElement!==this._input||!this._input)&&this.$data.currentLooseValue!==null&&this.$data.forceUpdate&&this._input.type!=="number"&&(this._input.selectionStart=this.$data.selectionStart,this._input.selectionEnd=this.$data.selectionEnd,this.$data.forceUpdate=!1),this._input&&(this._textBeforeInput=this._input.value),this.setValidity()},computed:{computedValue(){return this.$data.valueDuringOnChange!==void 0?this.$data.valueDuringOnChange:this.$data.currentValue},looseValue(){return a.formatValue(this.$data.focused?this.$data.currentLooseValue:a.getStateOrPropsValue(this.$props.value,this.$data.currentValue),this.$props.format,this._intl)},spanClassNames(){const t=!this.$data.hasMounted||!this.$props.validityStyles||this.validity().valid,e=this.computedValue;return{"k-floating-label-container":!0,"k-focus":this.$data.focused,"k-empty":!(e===0||e||this.$props.placeholder),"k-invalid":!t&&t!==void 0,"k-rtl":this.$props.dir==="rtl",[this.inputClass]:this.inputClass}},wrapperClassNames(){const{size:t,fillMode:e,rounded:n,required:l,disabled:p}=this.$props,u=!this.$props.validityStyles||this.validity().valid;return{"k-input":!0,"k-numerictextbox":!0,[`k-input-${i.kendoThemeMaps.sizeMap[t]||t}`]:t,[`k-input-${e}`]:e,[`k-rounded-${i.kendoThemeMaps.roundedMap[n]||n}`]:n,"k-invalid":!u,"k-required":l,"k-disabled":p,"k-loading":this.showLoadingIcon,[this.wrapperClass]:this.wrapperClass}},inputInnerClass(){return{"k-input-inner":!0,[this.inputClass]:this.inputClass}}},methods:{validity(){const t=this.$props.validationMessage!==void 0,e=!this.$data.valueIsOutOfRange&&(!this.$props.required||this.computedValue!==null),n=this.$props.valid!==void 0?this.$props.valid:e;return{customError:t,valid:n,valueMissing:this.computedValue===null}},clearClick(t){this.$props.value!==void 0?this.$data.currentValue=this.$props.value:this.$props.modelValue!==void 0?this.$data.currentValue=this.$props.modelValue:this.$data.currentValue=null,this.$emit("changemodel",null),this.$emit("update:modelValue",null),this.$emit("change",{event:t,value:null,component:this,target:{name:this.$props.name,value:null},validity:this.validity()})},focus(){this._input&&this._input.focus()},emitFocus(t){this.$data.currentLooseValue=this._prevLooseValue,this.$data.focused=!0,this.$emit("focus",{event:t})},emitBlur(t){this.$data.eventValue=null,this.$data.prevLooseValue="",this.$data.currentLooseValue="",this.$data.focused=!1,this.$data.selectionStart=void 0,this.$data.selectionEnd=void 0,this.$data.decimalSelect=!1,this.$data.valueIsCorrected=!1,this.$data.valueIsOutOfRange=!1,this.$emit("blur",{event:t})},handleFocus(t){this.$data.focused=!0},handleBlur(t){this.$data.focused=!1},setValidity(){this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity().valid?"":this.$props.validationMessage||k)},getCurrentState(){return{eventValue:a.getStateOrPropsValue(this.$props.value,this.$data.currentValue),prevLooseValue:this._prevLooseValue,currentLooseValue:this._input.value,selectionStart:this._input.selectionStart,selectionEnd:this._input.selectionEnd,decimalSelect:!1,valueIsCorrected:!1,valueIsOutOfRange:!1,isPaste:this._isPaste,focused:this.$data.focused}},parseNumber(t){return this._intl.parseNumber(t,this.$props.format)},elementChange(t){const e=this.getCurrentState();this._isPaste=!1,this.triggerChange(t,a.sanitizeNumber(e,this.$props.format,this._intl))},triggerChange(t,e){if(this.$props.disabled)return;this.$data.valueDuringOnChange=e.eventValue,this.$data.currentValue=e.eventValue;const n=a.formatValue(a.rangeValue(e.eventValue,this.$props.min,this.$props.max),this.$props.format,this._intl),l=a.rangeValue(this.parseNumber(n),this.$props.min,this.$props.max);if(l!==e.eventValue&&(e.valueIsOutOfRange=!0,e.eventValue=l,this.$data.valueDuringOnChange=l,this.$data.currentValue=l),e.valueIsCorrected){const u=this._elementWrapper;u&&u.className.indexOf("k-invalid")===-1&&(this.$data.isInvalid=!0,setTimeout(()=>{this.$data.isInvalid=!1},50))}const p=this.$props.value!==e.eventValue;this.$props.value!==void 0?this.$data.currentValue=this.$props.value:this.$props.modelValue!==void 0?this.$data.currentValue=this.$props.modelValue:this.$data.currentValue=this.$data.valueDuringOnChange,this.$data.prevLooseValue=e.prevLooseValue,this.$data.currentLooseValue=void 0,this.$data.currentLooseValue=e.currentLooseValue,this.$data.selectionStart=e.selectionStart,this.$data.selectionEnd=e.selectionEnd,this.$data.decimalSelect=e.decimalSelect,this.$data.valueIsCorrected=e.valueIsCorrected,this.$data.valueIsOutOfRange=e.valueIsOutOfRange,this.$data.focused=e.focused,this.$data.isPaste=e.isPaste,this.$data.forceUpdate=!this.$data.forceUpdate,p&&(this.$emit("changemodel",this.$data.valueDuringOnChange),this.$emit("update:modelValue",this.$data.valueDuringOnChange),this.$emit("change",{event:t,value:this.$data.valueDuringOnChange,component:this,target:{name:this.$props.name,value:this.$data.valueDuringOnChange},validity:this.validity()})),this.$data.valueDuringOnChange=void 0},onPasteHandler(t){this._isPaste=!0},increase(t){const e=this.getCurrentState();a.increaseValue(this.parseNumber(String(e.currentLooseValue)),e,this.$props.step,this.$props.min,this.$props.max,this.$props.format,this._intl),this.triggerChange(t,e)},decrease(t){const e=this.getCurrentState();a.decreaseValue(this.parseNumber(String(e.currentLooseValue)),e,this.$props.step,this.$props.min,this.$props.max,this.$props.format,this._intl),this.triggerChange(t,e)},wheel(t){!i.canUseDOM||document.activeElement!==this._input||!this._input||(t.deltaY<0&&(t.preventDefault(),this.increase(t)),t.deltaY>0&&(t.preventDefault(),this.decrease(t)))},keyDown(t){let e=this.getCurrentState(),n,l,p,u;const c=this.parseNumber(String(e.currentLooseValue));if(e.selectionEnd>e.selectionStart&&e.selectionEnd-e.selectionStart===String(e.currentLooseValue).length){const o=this._intl.numberSymbols(),d=o&&t.key===o.minusSign,m=o&&t.key===o.decimal;this.$data.isPaste=!d&&!m;return}switch(t.keyCode){case 38:a.increaseValue(c,e,this.$props.step,this.$props.min,this.$props.max,this.$props.format,this._intl);break;case 40:a.decreaseValue(c,e,this.$props.step,this.$props.min,this.$props.max,this.$props.format,this._intl);break;case 13:n=a.formatValue(a.rangeValue(c,this.$props.min,this.$props.max),this.$props.format,this._intl),l=a.rangeValue(this.parseNumber(n),this.$props.min,this.$props.max),e.eventValue=l,e.currentLooseValue=a.formatValue(l,this.$props.format,this._intl),e.selectionStart=e.selectionEnd=e.currentLooseValue.length;break;case 110:p=this._input,u=this._intl.numberSymbols(),p&&(e.currentLooseValue=e.currentLooseValue.slice(0,e.selectionStart)+u.decimal+e.currentLooseValue.slice(e.selectionEnd),e.selectionStart=e.selectionEnd=e.selectionStart+1,e=a.sanitizeNumber(e,this.$props.format,this._intl));break;default:return}t.preventDefault(),this.triggerChange(t,e)},spinnersWrapperMouseDown(t){i.canUseDOM&&this._input&&(t.preventDefault(),document.activeElement!==this._input&&this._input.focus())}},setup(){const t=s.ref(null),e=s.ref(null),n=s.inject("kendoLocalizationService",{}),l=s.inject("kendoIntlService",{});return{inputRef:t,elementWrapperRef:e,kendoLocalizationService:n,kendoIntlService:l}},render(){const{iconName:t,showValidationIcon:e,showLoadingIcon:n,showClearButton:l,inputAttributes:p}=this.$props,u=this.$props.id||this._inputId,c=i.getDefaultSlots(this),o=$.provideLocalizationService(this),d=this.validity().valid;this.$props.value!==void 0&&this.$props.value!==this.$data.currentValue?this.$data.currentValue=this.$props.value:this.$props.modelValue!==void 0&&this.$props.modelValue!==this.$data.currentValue&&(this.$data.currentValue=this.$props.modelValue),this._prevLooseValue=this.looseValue;const m=i.templateRendering.call(this,this.$props.inputPrefix,i.getListeners.call(this)),V=i.templateRendering.call(this,this.$props.inputSuffix,i.getListeners.call(this)),v=i.getTemplate.call(this,{h:s.h,template:m,additionalProps:{value:this.computedValue,valid:d}}),b=i.getTemplate.call(this,{h:s.h,template:V,additionalProps:{value:this.computedValue,valid:d}}),f=s.createVNode("span",{dir:this.$props.dir,class:this.wrapperClassNames,style:this.$attrs.style},[t&&s.createVNode(i.Icon,{name:t,class:"k-input-icon"},null),this.$props.inputPrefix&&s.createVNode("span",{class:"k-input-prefix k-input-prefix-horizontal"},[v]),this.$props.inputPrefix&&s.createVNode("span",{class:"k-input-separator k-input-separator-vertical"},null),s.createVNode("input",s.mergeProps({tabindex:this.$props.tabIndex,accesskey:this.$props.accessKey,disabled:this.$props.disabled,title:this.$props.title,"aria-label":this.$props.ariaLabel,"aria-valuemin":this.$props.min,"aria-valuemax":this.$props.max,"aria-disabled":this.$props.disabled?"true":void 0,placeholder:this.$props.placeholder,type:this.$props.inputType,spellcheck:!1,autocomplete:"off",autocorrect:"off",class:this.inputInnerClass,id:u,role:"spinbutton",value:this.looseValue,name:this.$props.name,onWheel:this.wheel,onKeydown:this.keyDown,onInput:this.elementChange,onFocus:this.emitFocus,onBlur:this.emitBlur,onPaste:this.onPasteHandler,ref:i.setRef(this,"input")},p),null),this.$props.inputSuffix&&s.createVNode("span",{class:"k-input-separator k-input-separator-vertical"},null),this.$props.inputSuffix&&s.createVNode("span",{class:"k-input-suffix k-input-suffix-horizontal"},[b]),e&&d&&s.createVNode(i.Icon,{name:"check",icon:h.checkIcon,class:"k-input-validation-icon"},null),e&&!d&&s.createVNode(i.Icon,{name:"exclamation-circle",icon:h.exclamationCircleIcon,class:"k-input-validation-icon"},null),n&&s.createVNode(i.Icon,{name:"loading",class:"k-input-loading-icon"},null),l&&this.computedValue!==void 0&&this.computedValue!==null&&s.createVNode("span",{onClick:this.clearClick,class:"k-clear-value"},[s.createVNode(i.Icon,{name:"x",icon:h.xIcon},null)]),c,this.$props.spinners&&s.createVNode("span",{class:"k-input-spinner k-spin-button",onMousedown:this.spinnersWrapperMouseDown},[s.createVNode(g.Button,{type:"button",tabIndex:-1,icon:"chevron-up",svgIcon:h.chevronUpIcon,class:"k-spinner-increase",rounded:null,disabled:this.$props.disabled,"aria-label":o.toLanguageString(r.numericIncreaseValue,r.messages[r.numericIncreaseValue]),title:o.toLanguageString(r.numericIncreaseValue,r.messages[r.numericIncreaseValue]),onClick:this.increase},null),s.createVNode(g.Button,{type:"button",tabIndex:-1,class:"k-spinner-decrease",icon:"chevron-down",svgIcon:h.chevronDownIcon,rounded:null,disabled:this.$props.disabled,"aria-label":o.toLanguageString(r.numericDecreaseValue,r.messages[r.numericDecreaseValue]),title:o.toLanguageString(r.numericDecreaseValue,r.messages[r.numericDecreaseValue]),onClick:this.decrease},null)])]);return this.$props.label?s.createVNode("span",{class:this.spanClassNames,onFocusin:this.handleFocus,onFocusout:this.handleBlur,dir:this.$props.dir},[f,this.$props.label?u?s.createVNode("label",{for:u,class:"k-floating-label"},[this.$props.label]):s.createVNode("span",{class:"k-label"},[this.$props.label]):null]):f}});exports.NumericTextBox=y;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("vue"),n=require("@progress/kendo-vue-common"),$=require("@progress/kendo-vue-intl"),g=require("@progress/kendo-vue-buttons"),d=require("../messages/main.js"),a=require("./utils/main.js"),_=require("../package-metadata.js"),h=require("@progress/kendo-svg-icons"),S="Please enter a valid value!",k=i.defineComponent({model:{event:"changemodel"},emits:{change:t=>!0,changemodel:t=>!0,"update:modelValue":t=>!0,focus:t=>!0,blur:t=>!0},props:{modelValue:Number,value:Number,defaultValue:Number,step:{type:Number,default:1},format:[String,Object],tabIndex:Number,accessKey:String,title:String,placeholder:String,min:Number,max:Number,spinners:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},dir:String,name:String,label:String,validationMessage:String,validityStyles:{type:Boolean,default:!0},valid:{type:Boolean,default:void 0},size:{type:String,validator:function(t){return["small","medium","large"].includes(t)}},rounded:{type:String,validator:function(t){return["none","small","medium","large","full"].includes(t)}},fillMode:{type:String,validator:function(t){return["solid","flat","outline"].includes(t)}},required:{type:Boolean,default:!1},id:String,ariaLabel:String,iconName:String,inputPrefix:[String,Function],inputSuffix:[String,Function],showValidationIcon:Boolean,showLoadingIcon:Boolean,showClearButton:Boolean,inputClass:String,inputType:{type:String,default:"tel"},wrapperClass:String,inputAttributes:Object},inject:{kendoIntlService:{default:null},kendoLocalizationService:{default:null}},data(){return{hasMounted:!1,isInvalid:!1,isEmpty:!1,currentValue:0,valueDuringOnChange:0,currentLooseValue:"",selectionStart:0,selectionEnd:0,decimalSelect:!1,focused:!1,forceUpdate:!1}},created(){n.validatePackage(_.packageMetadata),this._textBeforeInput="",this._inputId=n.guid(),this.$data.currentLooseValue=null,this.$data.valueDuringOnChange=void 0,this._intl=$.provideIntlService(this),this._symbols=this._intl.numberSymbols(),this.$props.value!==void 0?this.$data.currentValue=this.$props.value:this.$props.modelValue!==void 0?this.$data.currentValue=this.$props.modelValue:this.$props.defaultValue!==void 0?this.$data.currentValue=this.$props.defaultValue:this.$data.currentValue=null},mounted(){this._input=n.getRef(this,"input"),this._elementWrapper=this.elementWrapperRef,this.$data.hasMounted=!0,this._input&&(this._textBeforeInput=this._input.value),this.setValidity()},updated(){!(n.canUseDOM&&document.activeElement!==this._input||!this._input)&&this.$data.currentLooseValue!==null&&this._input.type!=="number"&&(this._input.selectionStart=this.$data.selectionStart,this._input.selectionEnd=this.$data.selectionEnd),this._input&&(this._textBeforeInput=this._input.value),this.setValidity()},computed:{isPlainNumberEditing(){return a.isCurrencyFormat(this.$props.format)},computedValue(){return this.$data.valueDuringOnChange!==void 0?this.$data.valueDuringOnChange:this.$data.currentValue},looseValue(){return a.formatValue(this.$data.focused?this.$data.currentLooseValue:a.getStateOrPropsValue(this.$props.value,this.$data.currentValue),this.$props.format,this._intl)},spanClassNames(){const t=!this.$data.hasMounted||!this.$props.validityStyles||this.validity().valid,e=this.computedValue;return{"k-floating-label-container":!0,"k-focus":this.$data.focused,"k-empty":!(e===0||e||this.$props.placeholder),"k-invalid":!t&&t!==void 0,"k-rtl":this.$props.dir==="rtl",[this.inputClass]:this.inputClass}},wrapperClassNames(){const{size:t,fillMode:e,rounded:s,required:l,disabled:r}=this.$props,u=!this.$props.validityStyles||this.validity().valid;return{"k-input":!0,"k-numerictextbox":!0,[`k-input-${n.kendoThemeMaps.sizeMap[t]||t}`]:t,[`k-input-${e}`]:e,[`k-rounded-${n.kendoThemeMaps.roundedMap[s]||s}`]:s,"k-invalid":!u,"k-required":l,"k-disabled":r,"k-loading":this.showLoadingIcon,[this.wrapperClass]:this.wrapperClass}},inputInnerClass(){return{"k-input-inner":!0,[this.inputClass]:this.inputClass}}},methods:{validity(){const t=this.$props.validationMessage!==void 0,e=!this.$data.valueIsOutOfRange&&(!this.$props.required||this.computedValue!==null),s=this.$props.valid!==void 0?this.$props.valid:e;return{customError:t,valid:s,valueMissing:this.computedValue===null}},clearClick(t){this.$props.value!==void 0?this.$data.currentValue=this.$props.value:this.$props.modelValue!==void 0?this.$data.currentValue=this.$props.modelValue:this.$data.currentValue=null,this.$emit("changemodel",null),this.$emit("update:modelValue",null),this.$emit("change",{event:t,value:null,component:this,target:{name:this.$props.name,value:null},validity:this.validity()})},focus(){this._input&&this._input.focus()},emitFocus(t){if(this.isPlainNumberEditing){const e=a.formatInputValue(this.$data.currentValue,this._intl.numberSymbols().decimal);this.$data.currentLooseValue=e,this.$data.selectionStart=0,this.$data.selectionEnd=e.length,clearTimeout(this._selectAllTimeout),this._selectAllTimeout=setTimeout(()=>{this.$data.focused&&this._input&&this._input.setSelectionRange(0,this._input.value.length)})}else this.$data.currentLooseValue=this._prevLooseValue;this.$data.focused=!0,this.$emit("focus",{event:t})},emitBlur(t){if(clearTimeout(this._selectAllTimeout),this.isPlainNumberEditing&&this._input){const e=this.$data.currentValue,s=a.rangeValue(e,this.$props.min,this.$props.max);s!==e&&this.triggerChange(t,{...this.getCurrentState(),eventValue:s,currentLooseValue:a.formatInputValue(s,this._intl.numberSymbols().decimal)})}this.$data.eventValue=null,this.$data.prevLooseValue="",this.$data.currentLooseValue="",this.$data.focused=!1,this.$data.selectionStart=void 0,this.$data.selectionEnd=void 0,this.$data.decimalSelect=!1,this.$data.valueIsCorrected=!1,this.$data.valueIsOutOfRange=!1,this.$emit("blur",{event:t})},handleFocus(t){this.$data.focused=!0},handleBlur(t){this.$data.focused=!1},setValidity(){this._input&&this._input.setCustomValidity&&this._input.setCustomValidity(this.validity().valid?"":this.$props.validationMessage||S)},getCurrentState(){return{eventValue:a.getStateOrPropsValue(this.$props.value,this.$data.currentValue),prevLooseValue:this._prevLooseValue,currentLooseValue:this._input.value,selectionStart:this._input.selectionStart,selectionEnd:this._input.selectionEnd,decimalSelect:!1,valueIsCorrected:!1,valueIsOutOfRange:!1,isPaste:this._isPaste,focused:this.$data.focused}},parseNumber(t){return this._intl.parseNumber(t,this.$props.format)},elementChange(t){if(this.isPlainNumberEditing){this.plainNumberChange(t);return}const e=this.getCurrentState();this._isPaste=!1,this.triggerChange(t,a.sanitizeNumber(e,this.$props.format,this._intl))},plainNumberChange(t){const e=this._input,s=this._intl.numberSymbols().decimal,l=this._prevLooseValue||"",{selectionStart:r,selectionEnd:u}=e;let p=e.value;if(this._isPaste){this._isPaste=!1;const c=this._intl.parseNumber(p,this.$props.format);p=c===null?l:a.formatInputValue(c,s),e.value=p}if(!a.numericInputRegex(s).test(p)){e.value=l,e.setSelectionRange(r-1,u-1),this.$data.selectionStart=e.selectionStart,this.$data.selectionEnd=e.selectionEnd;return}const o=this.getCurrentState();o.currentLooseValue=p,o.eventValue=this._intl.parseNumber(p),this.triggerChange(t,o)},triggerChange(t,e){if(this.$props.disabled)return;if(this.$data.valueDuringOnChange=e.eventValue,this.$data.currentValue=e.eventValue,this.isPlainNumberEditing)e.valueIsOutOfRange=a.rangeValue(e.eventValue,this.$props.min,this.$props.max)!==e.eventValue;else{const r=a.formatValue(a.rangeValue(e.eventValue,this.$props.min,this.$props.max),this.$props.format,this._intl),u=a.rangeValue(this.parseNumber(r),this.$props.min,this.$props.max);u!==e.eventValue&&(e.valueIsOutOfRange=!0,e.eventValue=u,this.$data.valueDuringOnChange=u,this.$data.currentValue=u)}if(e.valueIsCorrected){const r=this._elementWrapper;r&&r.className.indexOf("k-invalid")===-1&&(this.$data.isInvalid=!0,setTimeout(()=>{this.$data.isInvalid=!1},50))}const s=this.$props.value!==e.eventValue;this.$props.value!==void 0?this.$data.currentValue=this.$props.value:this.$props.modelValue!==void 0?this.$data.currentValue=this.$props.modelValue:this.$data.currentValue=this.$data.valueDuringOnChange,this.$data.prevLooseValue=e.prevLooseValue,this.$data.currentLooseValue=void 0,this.$data.currentLooseValue=e.currentLooseValue,this.$data.selectionStart=e.selectionStart,this.$data.selectionEnd=e.selectionEnd,this.$data.decimalSelect=e.decimalSelect,this.$data.valueIsCorrected=e.valueIsCorrected,this.$data.valueIsOutOfRange=e.valueIsOutOfRange,this.$data.focused=e.focused,this.$data.isPaste=e.isPaste;const l=typeof e.currentLooseValue=="string"&&e.currentLooseValue===e.prevLooseValue;this._input&&(e.valueIsCorrected||l)&&(this._input.value=e.currentLooseValue,this._input.selectionStart=e.selectionStart,this._input.selectionEnd=e.selectionEnd),this.$data.forceUpdate=!this.$data.forceUpdate,s&&(this.$emit("changemodel",this.$data.valueDuringOnChange),this.$emit("update:modelValue",this.$data.valueDuringOnChange),this.$emit("change",{event:t,value:this.$data.valueDuringOnChange,component:this,target:{name:this.$props.name,value:this.$data.valueDuringOnChange},validity:this.validity()})),this.$data.valueDuringOnChange=void 0},onPasteHandler(t){this._isPaste=!0},increase(t){const e=this.getCurrentState();a.increaseValue(this.isPlainNumberEditing?this.$data.currentValue:this.parseNumber(String(e.currentLooseValue)),e,this.$props.step,this.$props.min,this.$props.max,this.$props.format,this._intl),this.triggerChange(t,this.toPlainNumberState(e))},decrease(t){const e=this.getCurrentState();a.decreaseValue(this.isPlainNumberEditing?this.$data.currentValue:this.parseNumber(String(e.currentLooseValue)),e,this.$props.step,this.$props.min,this.$props.max,this.$props.format,this._intl),this.triggerChange(t,this.toPlainNumberState(e))},toPlainNumberState(t){return this.isPlainNumberEditing&&(t.currentLooseValue=a.formatInputValue(t.eventValue,this._intl.numberSymbols().decimal),t.selectionStart=t.selectionEnd=t.currentLooseValue.length),t},wheel(t){!n.canUseDOM||document.activeElement!==this._input||!this._input||(t.deltaY<0&&(t.preventDefault(),this.increase(t)),t.deltaY>0&&(t.preventDefault(),this.decrease(t)))},keyDown(t){if(this.isPlainNumberEditing){this.plainNumberKeyDown(t);return}let e=this.getCurrentState(),s,l,r,u;const p=this.parseNumber(String(e.currentLooseValue));if(e.selectionEnd>e.selectionStart&&e.selectionEnd-e.selectionStart===String(e.currentLooseValue).length){const o=this._intl.numberSymbols(),c=o&&t.key===o.minusSign,m=o&&t.key===o.decimal;this.$data.isPaste=!c&&!m;return}switch(t.keyCode){case 38:a.increaseValue(p,e,this.$props.step,this.$props.min,this.$props.max,this.$props.format,this._intl);break;case 40:a.decreaseValue(p,e,this.$props.step,this.$props.min,this.$props.max,this.$props.format,this._intl);break;case 13:s=a.formatValue(a.rangeValue(p,this.$props.min,this.$props.max),this.$props.format,this._intl),l=a.rangeValue(this.parseNumber(s),this.$props.min,this.$props.max),e.eventValue=l,e.currentLooseValue=a.formatValue(l,this.$props.format,this._intl),e.selectionStart=e.selectionEnd=e.currentLooseValue.length;break;case 110:r=this._input,u=this._intl.numberSymbols(),r&&(e.currentLooseValue=e.currentLooseValue.slice(0,e.selectionStart)+u.decimal+e.currentLooseValue.slice(e.selectionEnd),e.selectionStart=e.selectionEnd=e.selectionStart+1,e=a.sanitizeNumber(e,this.$props.format,this._intl));break;default:return}t.preventDefault(),this.triggerChange(t,e)},plainNumberKeyDown(t){const e=this._input;switch(t.keyCode){case 38:t.preventDefault(),this.increase(t);break;case 40:t.preventDefault(),this.decrease(t);break;case 110:if(e){t.preventDefault();const{selectionStart:s,selectionEnd:l,value:r}=e;e.value=r.slice(0,s)+this._intl.numberSymbols().decimal+r.slice(l),e.setSelectionRange(s+1,s+1),this.plainNumberChange(t)}break}},spinnersWrapperMouseDown(t){n.canUseDOM&&this._input&&(t.preventDefault(),document.activeElement!==this._input&&this._input.focus())}},setup(){const t=i.ref(null),e=i.ref(null),s=i.inject("kendoLocalizationService",{}),l=i.inject("kendoIntlService",{});return{inputRef:t,elementWrapperRef:e,kendoLocalizationService:s,kendoIntlService:l}},render(){const{iconName:t,showValidationIcon:e,showLoadingIcon:s,showClearButton:l,inputAttributes:r}=this.$props,u=this.$props.id||this._inputId,p=n.getDefaultSlots(this),o=$.provideLocalizationService(this),c=this.validity().valid;this.$props.value!==void 0&&this.$props.value!==this.$data.currentValue?this.$data.currentValue=this.$props.value:this.$props.modelValue!==void 0&&this.$props.modelValue!==this.$data.currentValue&&(this.$data.currentValue=this.$props.modelValue),this._prevLooseValue=this.looseValue;const m=n.templateRendering.call(this,this.$props.inputPrefix,n.getListeners.call(this)),V=n.templateRendering.call(this,this.$props.inputSuffix,n.getListeners.call(this)),v=n.getTemplate.call(this,{h:i.h,template:m,additionalProps:{value:this.computedValue,valid:c}}),b=n.getTemplate.call(this,{h:i.h,template:V,additionalProps:{value:this.computedValue,valid:c}}),f=i.createVNode("span",{dir:this.$props.dir,class:this.wrapperClassNames,style:this.$attrs.style},[t&&i.createVNode(n.Icon,{name:t,class:"k-input-icon"},null),this.$props.inputPrefix&&i.createVNode("span",{class:"k-input-prefix k-input-prefix-horizontal"},[v]),this.$props.inputPrefix&&i.createVNode("span",{class:"k-input-separator k-input-separator-vertical"},null),i.createVNode("input",i.mergeProps({tabindex:this.$props.tabIndex,accesskey:this.$props.accessKey,disabled:this.$props.disabled,title:this.$props.title,"aria-label":this.$props.ariaLabel,"aria-valuemin":this.$props.min,"aria-valuemax":this.$props.max,"aria-disabled":this.$props.disabled?"true":void 0,placeholder:this.$props.placeholder,type:this.$props.inputType,spellcheck:!1,autocomplete:"off",autocorrect:"off",class:this.inputInnerClass,id:u,role:"spinbutton",value:this.looseValue,name:this.$props.name,onWheel:this.wheel,onKeydown:this.keyDown,onInput:this.elementChange,onFocus:this.emitFocus,onBlur:this.emitBlur,onPaste:this.onPasteHandler,ref:n.setRef(this,"input")},r),null),this.$props.inputSuffix&&i.createVNode("span",{class:"k-input-separator k-input-separator-vertical"},null),this.$props.inputSuffix&&i.createVNode("span",{class:"k-input-suffix k-input-suffix-horizontal"},[b]),e&&c&&i.createVNode(n.Icon,{name:"check",icon:h.checkIcon,class:"k-input-validation-icon"},null),e&&!c&&i.createVNode(n.Icon,{name:"exclamation-circle",icon:h.exclamationCircleIcon,class:"k-input-validation-icon"},null),s&&i.createVNode(n.Icon,{name:"loading",class:"k-input-loading-icon"},null),l&&this.computedValue!==void 0&&this.computedValue!==null&&i.createVNode("span",{onClick:this.clearClick,class:"k-clear-value"},[i.createVNode(n.Icon,{name:"x",icon:h.xIcon},null)]),p,this.$props.spinners&&i.createVNode("span",{class:"k-input-spinner k-spin-button",onMousedown:this.spinnersWrapperMouseDown},[i.createVNode(g.Button,{type:"button",tabIndex:-1,icon:"chevron-up",svgIcon:h.chevronUpIcon,class:"k-spinner-increase",rounded:null,disabled:this.$props.disabled,"aria-label":o.toLanguageString(d.numericIncreaseValue,d.messages[d.numericIncreaseValue]),title:o.toLanguageString(d.numericIncreaseValue,d.messages[d.numericIncreaseValue]),onClick:this.increase},null),i.createVNode(g.Button,{type:"button",tabIndex:-1,class:"k-spinner-decrease",icon:"chevron-down",svgIcon:h.chevronDownIcon,rounded:null,disabled:this.$props.disabled,"aria-label":o.toLanguageString(d.numericDecreaseValue,d.messages[d.numericDecreaseValue]),title:o.toLanguageString(d.numericDecreaseValue,d.messages[d.numericDecreaseValue]),onClick:this.decrease},null)])]);return this.$props.label?i.createVNode("span",{class:this.spanClassNames,onFocusin:this.handleFocus,onFocusout:this.handleBlur,dir:this.$props.dir},[f,this.$props.label?u?i.createVNode("label",{for:u,class:"k-floating-label"},[this.$props.label]):i.createVNode("span",{class:"k-label"},[this.$props.label]):null]):f}});exports.NumericTextBox=k;
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { defineComponent as
|
|
9
|
-
import { getDefaultSlots as
|
|
10
|
-
import { provideLocalizationService as
|
|
11
|
-
import { Button as
|
|
12
|
-
import { numericIncreaseValue as d, messages as
|
|
13
|
-
import { sanitizeNumber as
|
|
14
|
-
import { packageMetadata as
|
|
15
|
-
import { checkIcon as
|
|
16
|
-
const
|
|
8
|
+
import { defineComponent as M, h as b, createVNode as s, mergeProps as R, ref as _, inject as S } from "vue";
|
|
9
|
+
import { getDefaultSlots as T, templateRendering as k, getListeners as y, getTemplate as C, Icon as h, setRef as z, canUseDOM as v, kendoThemeMaps as x, getRef as F, validatePackage as A, guid as W } from "@progress/kendo-vue-common";
|
|
10
|
+
import { provideLocalizationService as j, provideIntlService as K } from "@progress/kendo-vue-intl";
|
|
11
|
+
import { Button as I } from "@progress/kendo-vue-buttons";
|
|
12
|
+
import { numericIncreaseValue as d, messages as c, numericDecreaseValue as m } from "../messages/main.mjs";
|
|
13
|
+
import { sanitizeNumber as L, formatValue as f, rangeValue as p, decreaseValue as N, increaseValue as E, formatInputValue as $, numericInputRegex as U, getStateOrPropsValue as P, isCurrencyFormat as q } from "./utils/main.mjs";
|
|
14
|
+
import { packageMetadata as H } from "../package-metadata.mjs";
|
|
15
|
+
import { checkIcon as Y, exclamationCircleIcon as w, xIcon as G, chevronUpIcon as J, chevronDownIcon as Q } from "@progress/kendo-svg-icons";
|
|
16
|
+
const X = "Please enter a valid value!", re = /* @__PURE__ */ M({
|
|
17
17
|
model: {
|
|
18
18
|
event: "changemodel"
|
|
19
19
|
},
|
|
@@ -121,20 +121,23 @@ const G = "Please enter a valid value!", ae = /* @__PURE__ */ B({
|
|
|
121
121
|
};
|
|
122
122
|
},
|
|
123
123
|
created() {
|
|
124
|
-
|
|
124
|
+
A(H), this._textBeforeInput = "", this._inputId = W(), this.$data.currentLooseValue = null, this.$data.valueDuringOnChange = void 0, this._intl = K(this), this._symbols = this._intl.numberSymbols(), this.$props.value !== void 0 ? this.$data.currentValue = this.$props.value : this.$props.modelValue !== void 0 ? this.$data.currentValue = this.$props.modelValue : this.$props.defaultValue !== void 0 ? this.$data.currentValue = this.$props.defaultValue : this.$data.currentValue = null;
|
|
125
125
|
},
|
|
126
126
|
mounted() {
|
|
127
|
-
this._input =
|
|
127
|
+
this._input = F(this, "input"), this._elementWrapper = this.elementWrapperRef, this.$data.hasMounted = !0, this._input && (this._textBeforeInput = this._input.value), this.setValidity();
|
|
128
128
|
},
|
|
129
129
|
updated() {
|
|
130
|
-
!(v && document.activeElement !== this._input || !this._input) && this.$data.currentLooseValue !== null && this
|
|
130
|
+
!(v && document.activeElement !== this._input || !this._input) && this.$data.currentLooseValue !== null && this._input.type !== "number" && (this._input.selectionStart = this.$data.selectionStart, this._input.selectionEnd = this.$data.selectionEnd), this._input && (this._textBeforeInput = this._input.value), this.setValidity();
|
|
131
131
|
},
|
|
132
132
|
computed: {
|
|
133
|
+
isPlainNumberEditing() {
|
|
134
|
+
return q(this.$props.format);
|
|
135
|
+
},
|
|
133
136
|
computedValue() {
|
|
134
137
|
return this.$data.valueDuringOnChange !== void 0 ? this.$data.valueDuringOnChange : this.$data.currentValue;
|
|
135
138
|
},
|
|
136
139
|
looseValue() {
|
|
137
|
-
return
|
|
140
|
+
return f(this.$data.focused ? this.$data.currentLooseValue : P(this.$props.value, this.$data.currentValue), this.$props.format, this._intl);
|
|
138
141
|
},
|
|
139
142
|
spanClassNames() {
|
|
140
143
|
const t = !this.$data.hasMounted || !this.$props.validityStyles || this.validity().valid, e = this.computedValue;
|
|
@@ -151,19 +154,19 @@ const G = "Please enter a valid value!", ae = /* @__PURE__ */ B({
|
|
|
151
154
|
const {
|
|
152
155
|
size: t,
|
|
153
156
|
fillMode: e,
|
|
154
|
-
rounded:
|
|
157
|
+
rounded: i,
|
|
155
158
|
required: a,
|
|
156
|
-
disabled:
|
|
157
|
-
} = this.$props,
|
|
159
|
+
disabled: n
|
|
160
|
+
} = this.$props, l = !this.$props.validityStyles || this.validity().valid;
|
|
158
161
|
return {
|
|
159
162
|
"k-input": !0,
|
|
160
163
|
"k-numerictextbox": !0,
|
|
161
|
-
[`k-input-${
|
|
164
|
+
[`k-input-${x.sizeMap[t] || t}`]: t,
|
|
162
165
|
[`k-input-${e}`]: e,
|
|
163
|
-
[`k-rounded-${
|
|
164
|
-
"k-invalid": !
|
|
166
|
+
[`k-rounded-${x.roundedMap[i] || i}`]: i,
|
|
167
|
+
"k-invalid": !l,
|
|
165
168
|
"k-required": a,
|
|
166
|
-
"k-disabled":
|
|
169
|
+
"k-disabled": n,
|
|
167
170
|
"k-loading": this.showLoadingIcon,
|
|
168
171
|
[this.wrapperClass]: this.wrapperClass
|
|
169
172
|
};
|
|
@@ -177,10 +180,10 @@ const G = "Please enter a valid value!", ae = /* @__PURE__ */ B({
|
|
|
177
180
|
},
|
|
178
181
|
methods: {
|
|
179
182
|
validity() {
|
|
180
|
-
const t = this.$props.validationMessage !== void 0, e = !this.$data.valueIsOutOfRange && (!this.$props.required || this.computedValue !== null),
|
|
183
|
+
const t = this.$props.validationMessage !== void 0, e = !this.$data.valueIsOutOfRange && (!this.$props.required || this.computedValue !== null), i = this.$props.valid !== void 0 ? this.$props.valid : e;
|
|
181
184
|
return {
|
|
182
185
|
customError: t,
|
|
183
|
-
valid:
|
|
186
|
+
valid: i,
|
|
184
187
|
valueMissing: this.computedValue === null
|
|
185
188
|
};
|
|
186
189
|
},
|
|
@@ -200,11 +203,26 @@ const G = "Please enter a valid value!", ae = /* @__PURE__ */ B({
|
|
|
200
203
|
this._input && this._input.focus();
|
|
201
204
|
},
|
|
202
205
|
emitFocus(t) {
|
|
203
|
-
|
|
206
|
+
if (this.isPlainNumberEditing) {
|
|
207
|
+
const e = $(this.$data.currentValue, this._intl.numberSymbols().decimal);
|
|
208
|
+
this.$data.currentLooseValue = e, this.$data.selectionStart = 0, this.$data.selectionEnd = e.length, clearTimeout(this._selectAllTimeout), this._selectAllTimeout = setTimeout(() => {
|
|
209
|
+
this.$data.focused && this._input && this._input.setSelectionRange(0, this._input.value.length);
|
|
210
|
+
});
|
|
211
|
+
} else
|
|
212
|
+
this.$data.currentLooseValue = this._prevLooseValue;
|
|
213
|
+
this.$data.focused = !0, this.$emit("focus", {
|
|
204
214
|
event: t
|
|
205
215
|
});
|
|
206
216
|
},
|
|
207
217
|
emitBlur(t) {
|
|
218
|
+
if (clearTimeout(this._selectAllTimeout), this.isPlainNumberEditing && this._input) {
|
|
219
|
+
const e = this.$data.currentValue, i = p(e, this.$props.min, this.$props.max);
|
|
220
|
+
i !== e && this.triggerChange(t, {
|
|
221
|
+
...this.getCurrentState(),
|
|
222
|
+
eventValue: i,
|
|
223
|
+
currentLooseValue: $(i, this._intl.numberSymbols().decimal)
|
|
224
|
+
});
|
|
225
|
+
}
|
|
208
226
|
this.$data.eventValue = null, this.$data.prevLooseValue = "", this.$data.currentLooseValue = "", this.$data.focused = !1, this.$data.selectionStart = void 0, this.$data.selectionEnd = void 0, this.$data.decimalSelect = !1, this.$data.valueIsCorrected = !1, this.$data.valueIsOutOfRange = !1, this.$emit("blur", {
|
|
209
227
|
event: t
|
|
210
228
|
});
|
|
@@ -216,11 +234,11 @@ const G = "Please enter a valid value!", ae = /* @__PURE__ */ B({
|
|
|
216
234
|
this.$data.focused = !1;
|
|
217
235
|
},
|
|
218
236
|
setValidity() {
|
|
219
|
-
this._input && this._input.setCustomValidity && this._input.setCustomValidity(this.validity().valid ? "" : this.$props.validationMessage ||
|
|
237
|
+
this._input && this._input.setCustomValidity && this._input.setCustomValidity(this.validity().valid ? "" : this.$props.validationMessage || X);
|
|
220
238
|
},
|
|
221
239
|
getCurrentState() {
|
|
222
240
|
return {
|
|
223
|
-
eventValue:
|
|
241
|
+
eventValue: P(this.$props.value, this.$data.currentValue),
|
|
224
242
|
prevLooseValue: this._prevLooseValue,
|
|
225
243
|
currentLooseValue: this._input.value,
|
|
226
244
|
selectionStart: this._input.selectionStart,
|
|
@@ -236,22 +254,50 @@ const G = "Please enter a valid value!", ae = /* @__PURE__ */ B({
|
|
|
236
254
|
return this._intl.parseNumber(t, this.$props.format);
|
|
237
255
|
},
|
|
238
256
|
elementChange(t) {
|
|
257
|
+
if (this.isPlainNumberEditing) {
|
|
258
|
+
this.plainNumberChange(t);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
239
261
|
const e = this.getCurrentState();
|
|
240
|
-
this._isPaste = !1, this.triggerChange(t,
|
|
262
|
+
this._isPaste = !1, this.triggerChange(t, L(e, this.$props.format, this._intl));
|
|
263
|
+
},
|
|
264
|
+
plainNumberChange(t) {
|
|
265
|
+
const e = this._input, i = this._intl.numberSymbols().decimal, a = this._prevLooseValue || "", {
|
|
266
|
+
selectionStart: n,
|
|
267
|
+
selectionEnd: l
|
|
268
|
+
} = e;
|
|
269
|
+
let u = e.value;
|
|
270
|
+
if (this._isPaste) {
|
|
271
|
+
this._isPaste = !1;
|
|
272
|
+
const o = this._intl.parseNumber(u, this.$props.format);
|
|
273
|
+
u = o === null ? a : $(o, i), e.value = u;
|
|
274
|
+
}
|
|
275
|
+
if (!U(i).test(u)) {
|
|
276
|
+
e.value = a, e.setSelectionRange(n - 1, l - 1), this.$data.selectionStart = e.selectionStart, this.$data.selectionEnd = e.selectionEnd;
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
const r = this.getCurrentState();
|
|
280
|
+
r.currentLooseValue = u, r.eventValue = this._intl.parseNumber(u), this.triggerChange(t, r);
|
|
241
281
|
},
|
|
242
282
|
triggerChange(t, e) {
|
|
243
283
|
if (this.$props.disabled)
|
|
244
284
|
return;
|
|
245
|
-
this.$data.valueDuringOnChange = e.eventValue, this.$data.currentValue = e.eventValue
|
|
246
|
-
|
|
247
|
-
|
|
285
|
+
if (this.$data.valueDuringOnChange = e.eventValue, this.$data.currentValue = e.eventValue, this.isPlainNumberEditing)
|
|
286
|
+
e.valueIsOutOfRange = p(e.eventValue, this.$props.min, this.$props.max) !== e.eventValue;
|
|
287
|
+
else {
|
|
288
|
+
const n = f(p(e.eventValue, this.$props.min, this.$props.max), this.$props.format, this._intl), l = p(this.parseNumber(n), this.$props.min, this.$props.max);
|
|
289
|
+
l !== e.eventValue && (e.valueIsOutOfRange = !0, e.eventValue = l, this.$data.valueDuringOnChange = l, this.$data.currentValue = l);
|
|
290
|
+
}
|
|
291
|
+
if (e.valueIsCorrected) {
|
|
248
292
|
const n = this._elementWrapper;
|
|
249
293
|
n && n.className.indexOf("k-invalid") === -1 && (this.$data.isInvalid = !0, setTimeout(() => {
|
|
250
294
|
this.$data.isInvalid = !1;
|
|
251
295
|
}, 50));
|
|
252
296
|
}
|
|
253
|
-
const
|
|
254
|
-
this.$props.value !== void 0 ? this.$data.currentValue = this.$props.value : this.$props.modelValue !== void 0 ? this.$data.currentValue = this.$props.modelValue : this.$data.currentValue = this.$data.valueDuringOnChange, this.$data.prevLooseValue = e.prevLooseValue, this.$data.currentLooseValue = void 0, this.$data.currentLooseValue = e.currentLooseValue, this.$data.selectionStart = e.selectionStart, this.$data.selectionEnd = e.selectionEnd, this.$data.decimalSelect = e.decimalSelect, this.$data.valueIsCorrected = e.valueIsCorrected, this.$data.valueIsOutOfRange = e.valueIsOutOfRange, this.$data.focused = e.focused, this.$data.isPaste = e.isPaste
|
|
297
|
+
const i = this.$props.value !== e.eventValue;
|
|
298
|
+
this.$props.value !== void 0 ? this.$data.currentValue = this.$props.value : this.$props.modelValue !== void 0 ? this.$data.currentValue = this.$props.modelValue : this.$data.currentValue = this.$data.valueDuringOnChange, this.$data.prevLooseValue = e.prevLooseValue, this.$data.currentLooseValue = void 0, this.$data.currentLooseValue = e.currentLooseValue, this.$data.selectionStart = e.selectionStart, this.$data.selectionEnd = e.selectionEnd, this.$data.decimalSelect = e.decimalSelect, this.$data.valueIsCorrected = e.valueIsCorrected, this.$data.valueIsOutOfRange = e.valueIsOutOfRange, this.$data.focused = e.focused, this.$data.isPaste = e.isPaste;
|
|
299
|
+
const a = typeof e.currentLooseValue == "string" && e.currentLooseValue === e.prevLooseValue;
|
|
300
|
+
this._input && (e.valueIsCorrected || a) && (this._input.value = e.currentLooseValue, this._input.selectionStart = e.selectionStart, this._input.selectionEnd = e.selectionEnd), this.$data.forceUpdate = !this.$data.forceUpdate, i && (this.$emit("changemodel", this.$data.valueDuringOnChange), this.$emit("update:modelValue", this.$data.valueDuringOnChange), this.$emit("change", {
|
|
255
301
|
event: t,
|
|
256
302
|
value: this.$data.valueDuringOnChange,
|
|
257
303
|
component: this,
|
|
@@ -267,51 +313,80 @@ const G = "Please enter a valid value!", ae = /* @__PURE__ */ B({
|
|
|
267
313
|
},
|
|
268
314
|
increase(t) {
|
|
269
315
|
const e = this.getCurrentState();
|
|
270
|
-
|
|
316
|
+
E(this.isPlainNumberEditing ? this.$data.currentValue : this.parseNumber(String(e.currentLooseValue)), e, this.$props.step, this.$props.min, this.$props.max, this.$props.format, this._intl), this.triggerChange(t, this.toPlainNumberState(e));
|
|
271
317
|
},
|
|
272
318
|
decrease(t) {
|
|
273
319
|
const e = this.getCurrentState();
|
|
274
|
-
|
|
320
|
+
N(this.isPlainNumberEditing ? this.$data.currentValue : this.parseNumber(String(e.currentLooseValue)), e, this.$props.step, this.$props.min, this.$props.max, this.$props.format, this._intl), this.triggerChange(t, this.toPlainNumberState(e));
|
|
321
|
+
},
|
|
322
|
+
toPlainNumberState(t) {
|
|
323
|
+
return this.isPlainNumberEditing && (t.currentLooseValue = $(t.eventValue, this._intl.numberSymbols().decimal), t.selectionStart = t.selectionEnd = t.currentLooseValue.length), t;
|
|
275
324
|
},
|
|
276
325
|
wheel(t) {
|
|
277
326
|
!v || document.activeElement !== this._input || !this._input || (t.deltaY < 0 && (t.preventDefault(), this.increase(t)), t.deltaY > 0 && (t.preventDefault(), this.decrease(t)));
|
|
278
327
|
},
|
|
279
328
|
keyDown(t) {
|
|
280
|
-
|
|
281
|
-
|
|
329
|
+
if (this.isPlainNumberEditing) {
|
|
330
|
+
this.plainNumberKeyDown(t);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
let e = this.getCurrentState(), i, a, n, l;
|
|
334
|
+
const u = this.parseNumber(String(e.currentLooseValue));
|
|
282
335
|
if (e.selectionEnd > e.selectionStart && e.selectionEnd - e.selectionStart === String(e.currentLooseValue).length) {
|
|
283
|
-
const
|
|
284
|
-
this.$data.isPaste = !
|
|
336
|
+
const r = this._intl.numberSymbols(), o = r && t.key === r.minusSign, g = r && t.key === r.decimal;
|
|
337
|
+
this.$data.isPaste = !o && !g;
|
|
285
338
|
return;
|
|
286
339
|
}
|
|
287
340
|
switch (t.keyCode) {
|
|
288
341
|
case 38:
|
|
289
|
-
|
|
342
|
+
E(u, e, this.$props.step, this.$props.min, this.$props.max, this.$props.format, this._intl);
|
|
290
343
|
break;
|
|
291
344
|
case 40:
|
|
292
|
-
|
|
345
|
+
N(u, e, this.$props.step, this.$props.min, this.$props.max, this.$props.format, this._intl);
|
|
293
346
|
break;
|
|
294
347
|
case 13:
|
|
295
|
-
|
|
348
|
+
i = f(p(u, this.$props.min, this.$props.max), this.$props.format, this._intl), a = p(this.parseNumber(i), this.$props.min, this.$props.max), e.eventValue = a, e.currentLooseValue = f(a, this.$props.format, this._intl), e.selectionStart = e.selectionEnd = e.currentLooseValue.length;
|
|
296
349
|
break;
|
|
297
350
|
case 110:
|
|
298
|
-
|
|
351
|
+
n = this._input, l = this._intl.numberSymbols(), n && (e.currentLooseValue = e.currentLooseValue.slice(0, e.selectionStart) + l.decimal + e.currentLooseValue.slice(e.selectionEnd), e.selectionStart = e.selectionEnd = e.selectionStart + 1, e = L(e, this.$props.format, this._intl));
|
|
299
352
|
break;
|
|
300
353
|
default:
|
|
301
354
|
return;
|
|
302
355
|
}
|
|
303
356
|
t.preventDefault(), this.triggerChange(t, e);
|
|
304
357
|
},
|
|
358
|
+
plainNumberKeyDown(t) {
|
|
359
|
+
const e = this._input;
|
|
360
|
+
switch (t.keyCode) {
|
|
361
|
+
case 38:
|
|
362
|
+
t.preventDefault(), this.increase(t);
|
|
363
|
+
break;
|
|
364
|
+
case 40:
|
|
365
|
+
t.preventDefault(), this.decrease(t);
|
|
366
|
+
break;
|
|
367
|
+
case 110:
|
|
368
|
+
if (e) {
|
|
369
|
+
t.preventDefault();
|
|
370
|
+
const {
|
|
371
|
+
selectionStart: i,
|
|
372
|
+
selectionEnd: a,
|
|
373
|
+
value: n
|
|
374
|
+
} = e;
|
|
375
|
+
e.value = n.slice(0, i) + this._intl.numberSymbols().decimal + n.slice(a), e.setSelectionRange(i + 1, i + 1), this.plainNumberChange(t);
|
|
376
|
+
}
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
},
|
|
305
380
|
spinnersWrapperMouseDown(t) {
|
|
306
381
|
v && this._input && (t.preventDefault(), document.activeElement !== this._input && this._input.focus());
|
|
307
382
|
}
|
|
308
383
|
},
|
|
309
384
|
setup() {
|
|
310
|
-
const t =
|
|
385
|
+
const t = _(null), e = _(null), i = S("kendoLocalizationService", {}), a = S("kendoIntlService", {});
|
|
311
386
|
return {
|
|
312
387
|
inputRef: t,
|
|
313
388
|
elementWrapperRef: e,
|
|
314
|
-
kendoLocalizationService:
|
|
389
|
+
kendoLocalizationService: i,
|
|
315
390
|
kendoIntlService: a
|
|
316
391
|
};
|
|
317
392
|
},
|
|
@@ -319,37 +394,37 @@ const G = "Please enter a valid value!", ae = /* @__PURE__ */ B({
|
|
|
319
394
|
const {
|
|
320
395
|
iconName: t,
|
|
321
396
|
showValidationIcon: e,
|
|
322
|
-
showLoadingIcon:
|
|
397
|
+
showLoadingIcon: i,
|
|
323
398
|
showClearButton: a,
|
|
324
|
-
inputAttributes:
|
|
325
|
-
} = this.$props,
|
|
399
|
+
inputAttributes: n
|
|
400
|
+
} = this.$props, l = this.$props.id || this._inputId, u = T(this), r = j(this), o = this.validity().valid;
|
|
326
401
|
this.$props.value !== void 0 && this.$props.value !== this.$data.currentValue ? this.$data.currentValue = this.$props.value : this.$props.modelValue !== void 0 && this.$props.modelValue !== this.$data.currentValue && (this.$data.currentValue = this.$props.modelValue), this._prevLooseValue = this.looseValue;
|
|
327
|
-
const
|
|
328
|
-
h:
|
|
329
|
-
template:
|
|
402
|
+
const g = k.call(this, this.$props.inputPrefix, y.call(this)), O = k.call(this, this.$props.inputSuffix, y.call(this)), D = C.call(this, {
|
|
403
|
+
h: b,
|
|
404
|
+
template: g,
|
|
330
405
|
additionalProps: {
|
|
331
406
|
value: this.computedValue,
|
|
332
|
-
valid:
|
|
407
|
+
valid: o
|
|
333
408
|
}
|
|
334
|
-
}),
|
|
335
|
-
h:
|
|
336
|
-
template:
|
|
409
|
+
}), B = C.call(this, {
|
|
410
|
+
h: b,
|
|
411
|
+
template: O,
|
|
337
412
|
additionalProps: {
|
|
338
413
|
value: this.computedValue,
|
|
339
|
-
valid:
|
|
414
|
+
valid: o
|
|
340
415
|
}
|
|
341
|
-
}),
|
|
416
|
+
}), V = s("span", {
|
|
342
417
|
dir: this.$props.dir,
|
|
343
418
|
class: this.wrapperClassNames,
|
|
344
419
|
style: this.$attrs.style
|
|
345
|
-
}, [t &&
|
|
420
|
+
}, [t && s(h, {
|
|
346
421
|
name: t,
|
|
347
422
|
class: "k-input-icon"
|
|
348
|
-
}, null), this.$props.inputPrefix &&
|
|
423
|
+
}, null), this.$props.inputPrefix && s("span", {
|
|
349
424
|
class: "k-input-prefix k-input-prefix-horizontal"
|
|
350
|
-
}, [
|
|
425
|
+
}, [D]), this.$props.inputPrefix && s("span", {
|
|
351
426
|
class: "k-input-separator k-input-separator-vertical"
|
|
352
|
-
}, null),
|
|
427
|
+
}, null), s("input", R({
|
|
353
428
|
tabindex: this.$props.tabIndex,
|
|
354
429
|
accesskey: this.$props.accessKey,
|
|
355
430
|
disabled: this.$props.disabled,
|
|
@@ -364,7 +439,7 @@ const G = "Please enter a valid value!", ae = /* @__PURE__ */ B({
|
|
|
364
439
|
autocomplete: "off",
|
|
365
440
|
autocorrect: "off",
|
|
366
441
|
class: this.inputInnerClass,
|
|
367
|
-
id:
|
|
442
|
+
id: l,
|
|
368
443
|
role: "spinbutton",
|
|
369
444
|
value: this.looseValue,
|
|
370
445
|
name: this.$props.name,
|
|
@@ -374,67 +449,67 @@ const G = "Please enter a valid value!", ae = /* @__PURE__ */ B({
|
|
|
374
449
|
onFocus: this.emitFocus,
|
|
375
450
|
onBlur: this.emitBlur,
|
|
376
451
|
onPaste: this.onPasteHandler,
|
|
377
|
-
ref:
|
|
378
|
-
},
|
|
452
|
+
ref: z(this, "input")
|
|
453
|
+
}, n), null), this.$props.inputSuffix && s("span", {
|
|
379
454
|
class: "k-input-separator k-input-separator-vertical"
|
|
380
|
-
}, null), this.$props.inputSuffix &&
|
|
455
|
+
}, null), this.$props.inputSuffix && s("span", {
|
|
381
456
|
class: "k-input-suffix k-input-suffix-horizontal"
|
|
382
|
-
}, [
|
|
457
|
+
}, [B]), e && o && s(h, {
|
|
383
458
|
name: "check",
|
|
384
|
-
icon:
|
|
459
|
+
icon: Y,
|
|
385
460
|
class: "k-input-validation-icon"
|
|
386
|
-
}, null), e && !
|
|
461
|
+
}, null), e && !o && s(h, {
|
|
387
462
|
name: "exclamation-circle",
|
|
388
|
-
icon:
|
|
463
|
+
icon: w,
|
|
389
464
|
class: "k-input-validation-icon"
|
|
390
|
-
}, null),
|
|
465
|
+
}, null), i && s(h, {
|
|
391
466
|
name: "loading",
|
|
392
467
|
class: "k-input-loading-icon"
|
|
393
|
-
}, null), a && this.computedValue !== void 0 && this.computedValue !== null &&
|
|
468
|
+
}, null), a && this.computedValue !== void 0 && this.computedValue !== null && s("span", {
|
|
394
469
|
onClick: this.clearClick,
|
|
395
470
|
class: "k-clear-value"
|
|
396
|
-
}, [
|
|
471
|
+
}, [s(h, {
|
|
397
472
|
name: "x",
|
|
398
|
-
icon:
|
|
399
|
-
}, null)]),
|
|
473
|
+
icon: G
|
|
474
|
+
}, null)]), u, this.$props.spinners && s("span", {
|
|
400
475
|
class: "k-input-spinner k-spin-button",
|
|
401
476
|
onMousedown: this.spinnersWrapperMouseDown
|
|
402
|
-
}, [
|
|
477
|
+
}, [s(I, {
|
|
403
478
|
type: "button",
|
|
404
479
|
tabIndex: -1,
|
|
405
480
|
icon: "chevron-up",
|
|
406
|
-
svgIcon:
|
|
481
|
+
svgIcon: J,
|
|
407
482
|
class: "k-spinner-increase",
|
|
408
483
|
rounded: null,
|
|
409
484
|
disabled: this.$props.disabled,
|
|
410
|
-
"aria-label":
|
|
411
|
-
title:
|
|
485
|
+
"aria-label": r.toLanguageString(d, c[d]),
|
|
486
|
+
title: r.toLanguageString(d, c[d]),
|
|
412
487
|
onClick: this.increase
|
|
413
|
-
}, null),
|
|
488
|
+
}, null), s(I, {
|
|
414
489
|
type: "button",
|
|
415
490
|
tabIndex: -1,
|
|
416
491
|
class: "k-spinner-decrease",
|
|
417
492
|
icon: "chevron-down",
|
|
418
|
-
svgIcon:
|
|
493
|
+
svgIcon: Q,
|
|
419
494
|
rounded: null,
|
|
420
495
|
disabled: this.$props.disabled,
|
|
421
|
-
"aria-label":
|
|
422
|
-
title:
|
|
496
|
+
"aria-label": r.toLanguageString(m, c[m]),
|
|
497
|
+
title: r.toLanguageString(m, c[m]),
|
|
423
498
|
onClick: this.decrease
|
|
424
499
|
}, null)])]);
|
|
425
|
-
return this.$props.label ?
|
|
500
|
+
return this.$props.label ? s("span", {
|
|
426
501
|
class: this.spanClassNames,
|
|
427
502
|
onFocusin: this.handleFocus,
|
|
428
503
|
onFocusout: this.handleBlur,
|
|
429
504
|
dir: this.$props.dir
|
|
430
|
-
}, [
|
|
431
|
-
for:
|
|
505
|
+
}, [V, this.$props.label ? l ? s("label", {
|
|
506
|
+
for: l,
|
|
432
507
|
class: "k-floating-label"
|
|
433
|
-
}, [this.$props.label]) :
|
|
508
|
+
}, [this.$props.label]) : s("span", {
|
|
434
509
|
class: "k-label"
|
|
435
|
-
}, [this.$props.label]) : null]) :
|
|
510
|
+
}, [this.$props.label]) : null]) : V;
|
|
436
511
|
}
|
|
437
512
|
});
|
|
438
513
|
export {
|
|
439
|
-
|
|
514
|
+
re as NumericTextBox
|
|
440
515
|
};
|
|
@@ -19,6 +19,19 @@ export declare const getStateOrPropsValue: (value: number | null | undefined, st
|
|
|
19
19
|
* @hidden
|
|
20
20
|
*/
|
|
21
21
|
export declare const formatValue: (value: string | number | null | undefined, format: string | NumberFormatOptions | undefined, intlService: any) => string;
|
|
22
|
+
/**
|
|
23
|
+
* @hidden
|
|
24
|
+
* Currency formats are edited as a plain number while focused and formatted on blur.
|
|
25
|
+
*/
|
|
26
|
+
export declare const isCurrencyFormat: (format: string | NumberFormatOptions | undefined) => boolean;
|
|
27
|
+
/**
|
|
28
|
+
* @hidden
|
|
29
|
+
*/
|
|
30
|
+
export declare const formatInputValue: (value: number | null | undefined, decimalSeparator: string) => string;
|
|
31
|
+
/**
|
|
32
|
+
* @hidden
|
|
33
|
+
*/
|
|
34
|
+
export declare const numericInputRegex: (decimalSeparator: string) => RegExp;
|
|
22
35
|
/**
|
|
23
36
|
* @hidden
|
|
24
37
|
*/
|