primevue 3.12.6 → 3.13.0
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/README.md +4 -4
- package/autocomplete/AutoComplete.d.ts +5 -0
- package/autocomplete/AutoComplete.vue +15 -12
- package/autocomplete/autocomplete.cjs.js +128 -124
- package/autocomplete/autocomplete.cjs.min.js +1 -1
- package/autocomplete/autocomplete.esm.js +128 -125
- package/autocomplete/autocomplete.esm.min.js +1 -1
- package/autocomplete/autocomplete.js +129 -126
- package/autocomplete/autocomplete.min.js +1 -1
- package/calendar/Calendar.vue +22 -17
- package/calendar/calendar.cjs.js +377 -367
- package/calendar/calendar.cjs.min.js +1 -1
- package/calendar/calendar.esm.js +377 -368
- package/calendar/calendar.esm.min.js +1 -1
- package/calendar/calendar.js +378 -369
- package/calendar/calendar.min.js +1 -1
- package/carousel/Carousel.vue +1 -1
- package/carousel/carousel.cjs.js +1 -1
- package/carousel/carousel.cjs.min.js +1 -1
- package/carousel/carousel.esm.js +1 -1
- package/carousel/carousel.esm.min.js +1 -1
- package/carousel/carousel.js +1 -1
- package/carousel/carousel.min.js +1 -1
- package/cascadeselect/CascadeSelect.vue +7 -11
- package/cascadeselect/cascadeselect.cjs.js +47 -49
- package/cascadeselect/cascadeselect.cjs.min.js +1 -1
- package/cascadeselect/cascadeselect.esm.js +47 -50
- package/cascadeselect/cascadeselect.esm.min.js +1 -1
- package/cascadeselect/cascadeselect.js +48 -51
- package/cascadeselect/cascadeselect.min.js +1 -1
- package/colorpicker/ColorPicker.vue +9 -11
- package/colorpicker/colorpicker.cjs.js +62 -61
- package/colorpicker/colorpicker.cjs.min.js +1 -1
- package/colorpicker/colorpicker.esm.js +62 -62
- package/colorpicker/colorpicker.esm.min.js +1 -1
- package/colorpicker/colorpicker.js +63 -63
- package/colorpicker/colorpicker.min.js +1 -1
- package/column/Column.d.ts +4 -0
- package/confirmpopup/ConfirmPopup.vue +6 -4
- package/confirmpopup/confirmpopup.cjs.js +57 -50
- package/confirmpopup/confirmpopup.cjs.min.js +1 -1
- package/confirmpopup/confirmpopup.esm.js +57 -51
- package/confirmpopup/confirmpopup.esm.min.js +1 -1
- package/confirmpopup/confirmpopup.js +58 -52
- package/confirmpopup/confirmpopup.min.js +1 -1
- package/contextmenu/ContextMenu.vue +6 -4
- package/contextmenu/contextmenu.cjs.js +36 -29
- package/contextmenu/contextmenu.cjs.min.js +1 -1
- package/contextmenu/contextmenu.esm.js +36 -30
- package/contextmenu/contextmenu.esm.min.js +1 -1
- package/contextmenu/contextmenu.js +37 -31
- package/contextmenu/contextmenu.min.js +1 -1
- package/core/core.js +449 -377
- package/core/core.min.js +14 -9
- package/datatable/ColumnFilter.vue +6 -4
- package/datatable/DataTable.d.ts +4 -1
- package/datatable/DataTable.vue +17 -7
- package/datatable/HeaderCell.vue +6 -1
- package/datatable/TableBody.vue +1 -6
- package/datatable/TableHeader.vue +5 -1
- package/datatable/datatable.cjs.js +187 -175
- package/datatable/datatable.cjs.min.js +1 -1
- package/datatable/datatable.esm.js +187 -176
- package/datatable/datatable.esm.min.js +1 -1
- package/datatable/datatable.js +188 -177
- package/datatable/datatable.min.js +1 -1
- package/dialog/Dialog.vue +6 -8
- package/dialog/dialog.cjs.js +103 -103
- package/dialog/dialog.cjs.min.js +1 -1
- package/dialog/dialog.esm.js +103 -104
- package/dialog/dialog.esm.min.js +1 -1
- package/dialog/dialog.js +104 -105
- package/dialog/dialog.min.js +1 -1
- package/dropdown/Dropdown.vue +13 -15
- package/dropdown/dropdown.cjs.js +150 -150
- package/dropdown/dropdown.cjs.min.js +1 -1
- package/dropdown/dropdown.esm.js +150 -151
- package/dropdown/dropdown.esm.min.js +1 -1
- package/dropdown/dropdown.js +151 -152
- package/dropdown/dropdown.min.js +1 -1
- package/galleria/Galleria.vue +5 -3
- package/galleria/galleria.cjs.js +40 -36
- package/galleria/galleria.cjs.min.js +1 -1
- package/galleria/galleria.esm.js +40 -37
- package/galleria/galleria.esm.min.js +1 -1
- package/galleria/galleria.js +41 -38
- package/galleria/galleria.min.js +1 -1
- package/image/Image.vue +6 -2
- package/image/image.cjs.js +74 -61
- package/image/image.cjs.min.js +1 -1
- package/image/image.esm.js +71 -62
- package/image/image.esm.min.js +1 -1
- package/image/image.js +75 -63
- package/image/image.min.js +1 -1
- package/inputnumber/InputNumber.vue +2 -1
- package/inputnumber/inputnumber.cjs.js +2 -1
- package/inputnumber/inputnumber.cjs.min.js +1 -1
- package/inputnumber/inputnumber.esm.js +2 -1
- package/inputnumber/inputnumber.esm.min.js +1 -1
- package/inputnumber/inputnumber.js +2 -1
- package/inputnumber/inputnumber.min.js +1 -1
- package/inputtext/InputText.d.ts +2 -2
- package/inputtext/InputText.vue +1 -0
- package/inputtext/inputtext.cjs.js +1 -0
- package/inputtext/inputtext.cjs.min.js +1 -1
- package/inputtext/inputtext.esm.js +1 -0
- package/inputtext/inputtext.esm.min.js +1 -1
- package/inputtext/inputtext.js +1 -0
- package/inputtext/inputtext.min.js +1 -1
- package/menu/Menu.d.ts +0 -1
- package/menu/Menu.vue +6 -4
- package/menu/menu.cjs.js +87 -80
- package/menu/menu.cjs.min.js +1 -1
- package/menu/menu.esm.js +87 -81
- package/menu/menu.esm.min.js +1 -1
- package/menu/menu.js +88 -82
- package/menu/menu.min.js +1 -1
- package/multiselect/MultiSelect.vue +11 -15
- package/multiselect/multiselect.cjs.js +205 -207
- package/multiselect/multiselect.cjs.min.js +1 -1
- package/multiselect/multiselect.esm.js +205 -208
- package/multiselect/multiselect.esm.min.js +1 -1
- package/multiselect/multiselect.js +206 -209
- package/multiselect/multiselect.min.js +1 -1
- package/overlaypanel/OverlayPanel.vue +7 -3
- package/overlaypanel/overlaypanel.cjs.js +50 -41
- package/overlaypanel/overlaypanel.cjs.min.js +1 -1
- package/overlaypanel/overlaypanel.esm.js +50 -42
- package/overlaypanel/overlaypanel.esm.min.js +1 -1
- package/overlaypanel/overlaypanel.js +51 -43
- package/overlaypanel/overlaypanel.min.js +1 -1
- package/package.json +1 -1
- package/panelmenu/PanelMenuSub.vue +1 -1
- package/panelmenu/panelmenu.cjs.js +1 -1
- package/panelmenu/panelmenu.cjs.min.js +1 -1
- package/panelmenu/panelmenu.esm.js +1 -1
- package/panelmenu/panelmenu.esm.min.js +1 -1
- package/panelmenu/panelmenu.js +1 -1
- package/panelmenu/panelmenu.min.js +1 -1
- package/password/Password.d.ts +2 -2
- package/password/Password.vue +7 -11
- package/password/password.cjs.js +41 -43
- package/password/password.cjs.min.js +1 -1
- package/password/password.esm.js +41 -44
- package/password/password.esm.min.js +1 -1
- package/password/password.js +42 -45
- package/password/password.min.js +1 -1
- package/portal/Portal.d.ts +36 -0
- package/portal/Portal.vue +41 -0
- package/portal/package.json +9 -0
- package/portal/portal.cjs.js +48 -0
- package/portal/portal.cjs.min.js +1 -0
- package/portal/portal.esm.js +46 -0
- package/portal/portal.esm.min.js +1 -0
- package/portal/portal.js +49 -0
- package/portal/portal.min.js +1 -0
- package/progressspinner/ProgressSpinner.vue +3 -3
- package/progressspinner/progressspinner.cjs.js +1 -1
- package/progressspinner/progressspinner.cjs.min.js +1 -1
- package/progressspinner/progressspinner.esm.js +1 -1
- package/progressspinner/progressspinner.esm.min.js +1 -1
- package/progressspinner/progressspinner.js +1 -1
- package/progressspinner/progressspinner.min.js +1 -1
- package/radiobutton/RadioButton.vue +3 -3
- package/resources/themes/arya-blue/theme.css +5 -2
- package/resources/themes/arya-green/theme.css +5 -2
- package/resources/themes/arya-orange/theme.css +5 -2
- package/resources/themes/arya-purple/theme.css +5 -2
- package/resources/themes/bootstrap4-dark-blue/theme.css +5 -2
- package/resources/themes/bootstrap4-dark-purple/theme.css +5 -2
- package/resources/themes/bootstrap4-light-blue/theme.css +4 -1
- package/resources/themes/bootstrap4-light-purple/theme.css +4 -1
- package/resources/themes/fluent-light/theme.css +5 -2
- package/resources/themes/lara-dark-blue/theme.css +5 -2
- package/resources/themes/lara-dark-indigo/theme.css +5 -2
- package/resources/themes/lara-dark-purple/theme.css +5 -2
- package/resources/themes/lara-dark-teal/theme.css +5 -2
- package/resources/themes/lara-light-blue/theme.css +5 -2
- package/resources/themes/lara-light-indigo/theme.css +5 -2
- package/resources/themes/lara-light-purple/theme.css +5 -2
- package/resources/themes/lara-light-teal/theme.css +5 -2
- package/resources/themes/luna-amber/theme.css +5 -2
- package/resources/themes/luna-blue/theme.css +5 -2
- package/resources/themes/luna-green/theme.css +5 -2
- package/resources/themes/luna-pink/theme.css +5 -2
- package/resources/themes/md-dark-deeppurple/theme.css +5 -2
- package/resources/themes/md-dark-indigo/theme.css +5 -2
- package/resources/themes/md-light-deeppurple/theme.css +5 -2
- package/resources/themes/md-light-indigo/theme.css +5 -2
- package/resources/themes/mdc-dark-deeppurple/theme.css +5 -2
- package/resources/themes/mdc-dark-indigo/theme.css +5 -2
- package/resources/themes/mdc-light-deeppurple/theme.css +5 -2
- package/resources/themes/mdc-light-indigo/theme.css +5 -2
- package/resources/themes/nova/theme.css +5 -2
- package/resources/themes/nova-accent/theme.css +5 -2
- package/resources/themes/nova-alt/theme.css +5 -2
- package/resources/themes/nova-vue/theme.css +5 -2
- package/resources/themes/rhea/theme.css +5 -2
- package/resources/themes/saga-blue/theme.css +5 -2
- package/resources/themes/saga-green/theme.css +5 -2
- package/resources/themes/saga-orange/theme.css +5 -2
- package/resources/themes/saga-purple/theme.css +5 -2
- package/resources/themes/tailwind-light/theme.css +5 -2
- package/resources/themes/vela-blue/theme.css +5 -2
- package/resources/themes/vela-green/theme.css +5 -2
- package/resources/themes/vela-orange/theme.css +5 -2
- package/resources/themes/vela-purple/theme.css +5 -2
- package/sidebar/Sidebar.vue +6 -2
- package/sidebar/sidebar.cjs.js +53 -44
- package/sidebar/sidebar.cjs.min.js +1 -1
- package/sidebar/sidebar.esm.js +53 -45
- package/sidebar/sidebar.esm.min.js +1 -1
- package/sidebar/sidebar.js +54 -46
- package/sidebar/sidebar.min.js +1 -1
- package/slider/Slider.vue +1 -1
- package/slider/slider.cjs.js +1 -1
- package/slider/slider.cjs.min.js +1 -1
- package/slider/slider.esm.js +1 -1
- package/slider/slider.esm.min.js +1 -1
- package/slider/slider.js +1 -1
- package/slider/slider.min.js +1 -1
- package/steps/Steps.vue +1 -4
- package/steps/steps.cjs.js +1 -4
- package/steps/steps.cjs.min.js +1 -1
- package/steps/steps.esm.js +1 -4
- package/steps/steps.esm.min.js +1 -1
- package/steps/steps.js +1 -4
- package/steps/steps.min.js +1 -1
- package/tabmenu/TabMenu.vue +3 -3
- package/tabmenu/tabmenu.cjs.js +1 -1
- package/tabmenu/tabmenu.esm.js +1 -1
- package/tabmenu/tabmenu.js +1 -1
- package/textarea/Textarea.vue +2 -1
- package/textarea/textarea.cjs.js +2 -1
- package/textarea/textarea.cjs.min.js +1 -1
- package/textarea/textarea.esm.js +2 -1
- package/textarea/textarea.esm.min.js +1 -1
- package/textarea/textarea.js +2 -1
- package/textarea/textarea.min.js +1 -1
- package/tieredmenu/TieredMenu.d.ts +0 -1
- package/tieredmenu/TieredMenu.vue +6 -4
- package/tieredmenu/tieredmenu.cjs.js +41 -34
- package/tieredmenu/tieredmenu.cjs.min.js +1 -1
- package/tieredmenu/tieredmenu.esm.js +41 -35
- package/tieredmenu/tieredmenu.esm.min.js +1 -1
- package/tieredmenu/tieredmenu.js +42 -36
- package/tieredmenu/tieredmenu.min.js +1 -1
- package/toast/Toast.vue +5 -3
- package/toast/toast.cjs.js +33 -26
- package/toast/toast.cjs.min.js +1 -1
- package/toast/toast.esm.js +33 -27
- package/toast/toast.esm.min.js +1 -1
- package/toast/toast.js +34 -28
- package/toast/toast.min.js +1 -1
- package/toolbar/Toolbar.vue +2 -2
- package/tooltip/tooltip.cjs.js +7 -1
- package/tooltip/tooltip.cjs.min.js +1 -1
- package/tooltip/tooltip.esm.js +7 -1
- package/tooltip/tooltip.esm.min.js +1 -1
- package/tooltip/tooltip.js +7 -1
- package/tooltip/tooltip.min.js +1 -1
- package/treeselect/TreeSelect.vue +7 -11
- package/treeselect/treeselect.cjs.js +63 -65
- package/treeselect/treeselect.cjs.min.js +1 -1
- package/treeselect/treeselect.esm.js +63 -66
- package/treeselect/treeselect.esm.min.js +1 -1
- package/treeselect/treeselect.js +64 -67
- package/treeselect/treeselect.min.js +1 -1
- package/treetable/FooterCell.vue +1 -1
- package/treetable/TreeTableRow.vue +2 -2
- package/tristatecheckbox/TriStateCheckbox.vue +3 -3
- package/utils/Utils.d.ts +1 -0
- package/utils/utils.cjs.js +4 -0
- package/utils/utils.cjs.min.js +1 -1
- package/utils/utils.esm.js +4 -0
- package/utils/utils.esm.min.js +1 -1
- package/utils/utils.js +4 -0
- package/utils/utils.min.js +1 -1
- package/vetur-attributes.json +14 -2
- package/vetur-tags.json +8 -0
- package/web-types.json +47 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"primevue/inputtext";import e from"primevue/button";import{resolveComponent as n,openBlock as i,createElementBlock as s,normalizeClass as r,normalizeStyle as u,createVNode as l,mergeProps as a,toHandlers as o,createCommentVNode as p,createBlock as h}from"vue";var c={name:"InputNumber",inheritAttrs:!1,emits:["update:modelValue","input","focus","blur"],props:{modelValue:{type:Number,default:null},format:{type:Boolean,default:!0},showButtons:{type:Boolean,default:!1},buttonLayout:{type:String,default:"stacked"},incrementButtonClass:{type:String,default:null},decrementButtonClass:{type:String,default:null},incrementButtonIcon:{type:String,default:"pi pi-angle-up"},decrementButtonIcon:{type:String,default:"pi pi-angle-down"},locale:{type:String,default:void 0},localeMatcher:{type:String,default:void 0},mode:{type:String,default:"decimal"},prefix:{type:String,default:null},suffix:{type:String,default:null},currency:{type:String,default:void 0},currencyDisplay:{type:String,default:void 0},useGrouping:{type:Boolean,default:!0},minFractionDigits:{type:Number,default:void 0},maxFractionDigits:{type:Number,default:void 0},min:{type:Number,default:null},max:{type:Number,default:null},step:{type:Number,default:1},allowEmpty:{type:Boolean,default:!0},readonly:{type:Boolean,default:!1},style:null,class:null,inputStyle:null,inputClass:null},numberFormat:null,_numeral:null,_decimal:null,_group:null,_minusSign:null,_currency:null,_suffix:null,_prefix:null,_index:null,groupChar:"",isSpecialChar:null,prefixChar:null,suffixChar:null,timer:null,data(){return{d_modelValue:this.modelValue,focused:!1}},watch:{modelValue(t){this.d_modelValue=t},locale(t,e){this.updateConstructParser(t,e)},localeMatcher(t,e){this.updateConstructParser(t,e)},mode(t,e){this.updateConstructParser(t,e)},currency(t,e){this.updateConstructParser(t,e)},currencyDisplay(t,e){this.updateConstructParser(t,e)},useGrouping(t,e){this.updateConstructParser(t,e)},minFractionDigits(t,e){this.updateConstructParser(t,e)},maxFractionDigits(t,e){this.updateConstructParser(t,e)},suffix(t,e){this.updateConstructParser(t,e)},prefix(t,e){this.updateConstructParser(t,e)}},created(){this.constructParser()},methods:{getOptions(){return{localeMatcher:this.localeMatcher,style:this.mode,currency:this.currency,currencyDisplay:this.currencyDisplay,useGrouping:this.useGrouping,minimumFractionDigits:this.minFractionDigits,maximumFractionDigits:this.maxFractionDigits}},constructParser(){this.numberFormat=new Intl.NumberFormat(this.locale,this.getOptions());const t=[...new Intl.NumberFormat(this.locale,{useGrouping:!1}).format(9876543210)].reverse(),e=new Map(t.map(((t,e)=>[t,e])));this._numeral=new RegExp(`[${t.join("")}]`,"g"),this._group=this.getGroupingExpression(),this._minusSign=this.getMinusSignExpression(),this._currency=this.getCurrencyExpression(),this._decimal=this.getDecimalExpression(),this._suffix=this.getSuffixExpression(),this._prefix=this.getPrefixExpression(),this._index=t=>e.get(t)},updateConstructParser(t,e){t!==e&&this.constructParser()},escapeRegExp:t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),getDecimalExpression(){const t=new Intl.NumberFormat(this.locale,{...this.getOptions(),useGrouping:!1});return new RegExp(`[${t.format(1.1).replace(this._currency,"").trim().replace(this._numeral,"")}]`,"g")},getGroupingExpression(){const t=new Intl.NumberFormat(this.locale,{useGrouping:!0});return this.groupChar=t.format(1e6).trim().replace(this._numeral,"").charAt(0),new RegExp(`[${this.groupChar}]`,"g")},getMinusSignExpression(){const t=new Intl.NumberFormat(this.locale,{useGrouping:!1});return new RegExp(`[${t.format(-1).trim().replace(this._numeral,"")}]`,"g")},getCurrencyExpression(){if(this.currency){const t=new Intl.NumberFormat(this.locale,{style:"currency",currency:this.currency,currencyDisplay:this.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});return new RegExp(`[${t.format(1).replace(/\s/g,"").replace(this._numeral,"").replace(this._group,"")}]`,"g")}return new RegExp("[]","g")},getPrefixExpression(){if(this.prefix)this.prefixChar=this.prefix;else{const t=new Intl.NumberFormat(this.locale,{style:this.mode,currency:this.currency,currencyDisplay:this.currencyDisplay});this.prefixChar=t.format(1).split("1")[0]}return new RegExp(`${this.escapeRegExp(this.prefixChar||"")}`,"g")},getSuffixExpression(){if(this.suffix)this.suffixChar=this.suffix;else{const t=new Intl.NumberFormat(this.locale,{style:this.mode,currency:this.currency,currencyDisplay:this.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});this.suffixChar=t.format(1).split("1")[1]}return new RegExp(`${this.escapeRegExp(this.suffixChar||"")}`,"g")},formatValue(t){if(null!=t){if("-"===t)return t;if(this.format){let e=new Intl.NumberFormat(this.locale,this.getOptions()).format(t);return this.prefix&&(e=this.prefix+e),this.suffix&&(e+=this.suffix),e}return t.toString()}return""},parseValue(t){let e=t.replace(this._suffix,"").replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").replace(this._group,"").replace(this._minusSign,"-").replace(this._decimal,".").replace(this._numeral,this._index);if(e){if("-"===e)return e;let t=+e;return isNaN(t)?null:t}return null},repeat(t,e,n){if(this.readonly)return;let i=e||500;this.clearTimer(),this.timer=setTimeout((()=>{this.repeat(t,40,n)}),i),this.spin(t,n)},spin(t,e){if(this.$refs.input){let n=this.step*e,i=this.parseValue(this.$refs.input.$el.value)||0,s=this.validateValue(i+n);this.updateInput(s,null,"spin"),this.updateModel(t,s),this.handleOnInput(t,i,s)}},onUpButtonMouseDown(t){this.$attrs.disabled||(this.$refs.input.$el.focus(),this.repeat(t,null,1),t.preventDefault())},onUpButtonMouseUp(){this.$attrs.disabled||this.clearTimer()},onUpButtonMouseLeave(){this.$attrs.disabled||this.clearTimer()},onUpButtonKeyUp(){this.$attrs.disabled||this.clearTimer()},onUpButtonKeyDown(t){32!==t.keyCode&&13!==t.keyCode||this.repeat(t,null,1)},onDownButtonMouseDown(t){this.$attrs.disabled||(this.$refs.input.$el.focus(),this.repeat(t,null,-1),t.preventDefault())},onDownButtonMouseUp(){this.$attrs.disabled||this.clearTimer()},onDownButtonMouseLeave(){this.$attrs.disabled||this.clearTimer()},onDownButtonKeyUp(){this.$attrs.disabled||this.clearTimer()},onDownButtonKeyDown(t){32!==t.keyCode&&13!==t.keyCode||this.repeat(t,null,-1)},onUserInput(){this.isSpecialChar&&(this.$refs.input.$el.value=this.lastValue),this.isSpecialChar=!1},onInputKeyDown(t){if(this.readonly)return;if(this.lastValue=t.target.value,t.shiftKey||t.altKey)return void(this.isSpecialChar=!0);let e=t.target.selectionStart,n=t.target.selectionEnd,i=t.target.value,s=null;switch(t.altKey&&t.preventDefault(),t.which){case 38:this.spin(t,1),t.preventDefault();break;case 40:this.spin(t,-1),t.preventDefault();break;case 37:this.isNumeralChar(i.charAt(e-1))||t.preventDefault();break;case 39:this.isNumeralChar(i.charAt(e))||t.preventDefault();break;case 13:s=this.validateValue(this.parseValue(i)),this.$refs.input.$el.value=this.formatValue(s),this.$refs.input.$el.setAttribute("aria-valuenow",s),this.updateModel(t,s);break;case 8:if(t.preventDefault(),e===n){const n=i.charAt(e-1),{decimalCharIndex:r,decimalCharIndexWithoutPrefix:u}=this.getDecimalCharIndexes(i);if(this.isNumeralChar(n)){const t=this.getDecimalLength(i);if(this._group.test(n))this._group.lastIndex=0,s=i.slice(0,e-2)+i.slice(e-1);else if(this._decimal.test(n))this._decimal.lastIndex=0,t?this.$refs.input.$el.setSelectionRange(e-1,e-1):s=i.slice(0,e-1)+i.slice(e);else if(r>0&&e>r){const n=this.isDecimalMode()&&(this.minFractionDigits||0)<t?"":"0";s=i.slice(0,e-1)+n+i.slice(e)}else 1===u?(s=i.slice(0,e-1)+"0"+i.slice(e),s=this.parseValue(s)>0?s:""):s=i.slice(0,e-1)+i.slice(e)}this.updateValue(t,s,null,"delete-single")}else s=this.deleteRange(i,e,n),this.updateValue(t,s,null,"delete-range");break;case 46:if(t.preventDefault(),e===n){const n=i.charAt(e),{decimalCharIndex:r,decimalCharIndexWithoutPrefix:u}=this.getDecimalCharIndexes(i);if(this.isNumeralChar(n)){const t=this.getDecimalLength(i);if(this._group.test(n))this._group.lastIndex=0,s=i.slice(0,e)+i.slice(e+2);else if(this._decimal.test(n))this._decimal.lastIndex=0,t?this.$refs.input.$el.setSelectionRange(e+1,e+1):s=i.slice(0,e)+i.slice(e+1);else if(r>0&&e>r){const n=this.isDecimalMode()&&(this.minFractionDigits||0)<t?"":"0";s=i.slice(0,e)+n+i.slice(e+1)}else 1===u?(s=i.slice(0,e)+"0"+i.slice(e+1),s=this.parseValue(s)>0?s:""):s=i.slice(0,e)+i.slice(e+1)}this.updateValue(t,s,null,"delete-back-single")}else s=this.deleteRange(i,e,n),this.updateValue(t,s,null,"delete-range")}},onInputKeyPress(t){if(this.readonly)return;t.preventDefault();let e=t.which||t.keyCode,n=String.fromCharCode(e);const i=this.isDecimalSign(n),s=this.isMinusSign(n);(48<=e&&e<=57||s||i)&&this.insert(t,n,{isDecimalSign:i,isMinusSign:s})},onPaste(t){t.preventDefault();let e=(t.clipboardData||window.clipboardData).getData("Text");if(e){let n=this.parseValue(e);null!=n&&this.insert(t,n.toString())}},allowMinusSign(){return null===this.min||this.min<0},isMinusSign(t){return!(!this._minusSign.test(t)&&"-"!==t)&&(this._minusSign.lastIndex=0,!0)},isDecimalSign(t){return!!this._decimal.test(t)&&(this._decimal.lastIndex=0,!0)},isDecimalMode(){return"decimal"===this.mode},getDecimalCharIndexes(t){let e=t.search(this._decimal);this._decimal.lastIndex=0;const n=t.replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").search(this._decimal);return this._decimal.lastIndex=0,{decimalCharIndex:e,decimalCharIndexWithoutPrefix:n}},getCharIndexes(t){const e=t.search(this._decimal);this._decimal.lastIndex=0;const n=t.search(this._minusSign);this._minusSign.lastIndex=0;const i=t.search(this._suffix);this._suffix.lastIndex=0;const s=t.search(this._currency);return this._currency.lastIndex=0,{decimalCharIndex:e,minusCharIndex:n,suffixCharIndex:i,currencyCharIndex:s}},insert(t,e,n={isDecimalSign:!1,isMinusSign:!1}){const i=e.search(this._minusSign);if(this._minusSign.lastIndex=0,!this.allowMinusSign()&&-1!==i)return;const s=this.$refs.input.$el.selectionStart,r=this.$refs.input.$el.selectionEnd;let u=this.$refs.input.$el.value.trim();const{decimalCharIndex:l,minusCharIndex:a,suffixCharIndex:o,currencyCharIndex:p}=this.getCharIndexes(u);let h;if(n.isMinusSign)0===s&&(h=u,-1!==a&&0===r||(h=this.insertText(u,e,0,r)),this.updateValue(t,h,e,"insert"));else if(n.isDecimalSign)l>0&&s===l?this.updateValue(t,u,e,"insert"):(l>s&&l<r||-1===l&&this.maxFractionDigits)&&(h=this.insertText(u,e,s,r),this.updateValue(t,h,e,"insert"));else{const n=this.numberFormat.resolvedOptions().maximumFractionDigits,i=s!==r?"range-insert":"insert";if(l>0&&s>l){if(s+e.length-(l+1)<=n){const n=p>=s?p-1:o>=s?o:u.length;h=u.slice(0,s)+e+u.slice(s+e.length,n)+u.slice(n),this.updateValue(t,h,e,i)}}else h=this.insertText(u,e,s,r),this.updateValue(t,h,e,i)}},insertText(t,e,n,i){if(2===("."===e?e:e.split(".")).length){const s=t.slice(n,i).search(this._decimal);return this._decimal.lastIndex=0,s>0?t.slice(0,n)+this.formatValue(e)+t.slice(i):t||this.formatValue(e)}return i-n===t.length?this.formatValue(e):0===n?e+t.slice(i):i===t.length?t.slice(0,n)+e:t.slice(0,n)+e+t.slice(i)},deleteRange(t,e,n){let i;return i=n-e===t.length?"":0===e?t.slice(n):n===t.length?t.slice(0,e):t.slice(0,e)+t.slice(n),i},initCursor(){let t=this.$refs.input.$el.selectionStart,e=this.$refs.input.$el.value,n=e.length,i=null,s=(this.prefixChar||"").length;e=e.replace(this._prefix,""),t-=s;let r=e.charAt(t);if(this.isNumeralChar(r))return t+s;let u=t-1;for(;u>=0;){if(r=e.charAt(u),this.isNumeralChar(r)){i=u+s;break}u--}if(null!==i)this.$refs.input.$el.setSelectionRange(i+1,i+1);else{for(u=t;u<n;){if(r=e.charAt(u),this.isNumeralChar(r)){i=u+s;break}u++}null!==i&&this.$refs.input.$el.setSelectionRange(i,i)}return i||0},onInputClick(){this.readonly||this.initCursor()},isNumeralChar(t){return!(1!==t.length||!(this._numeral.test(t)||this._decimal.test(t)||this._group.test(t)||this._minusSign.test(t)))&&(this.resetRegex(),!0)},resetRegex(){this._numeral.lastIndex=0,this._decimal.lastIndex=0,this._group.lastIndex=0,this._minusSign.lastIndex=0},updateValue(t,e,n,i){let s=this.$refs.input.$el.value,r=null;null!=e&&(r=this.parseValue(e),r=r||this.allowEmpty?r:0,this.updateInput(r,n,i,e),this.handleOnInput(t,s,r))},handleOnInput(t,e,n){this.isValueChanged(e,n)&&this.$emit("input",{originalEvent:t,value:n})},isValueChanged(t,e){if(null===e&&null!==t)return!0;if(null!=e){return e!==("string"==typeof t?this.parseValue(t):t)}return!1},validateValue(t){return"-"===t||null==t?null:null!=this.min&&t<this.min?this.min:null!=this.max&&t>this.max?this.max:t},updateInput(t,e,n,i){e=e||"";let s=this.$refs.input.$el.value,r=this.formatValue(t),u=s.length;if(r!==i&&(r=this.concatValues(r,i)),0===u){this.$refs.input.$el.value=r,this.$refs.input.$el.setSelectionRange(0,0);const t=this.initCursor()+e.length;this.$refs.input.$el.setSelectionRange(t,t)}else{let t=this.$refs.input.$el.selectionStart,i=this.$refs.input.$el.selectionEnd;this.$refs.input.$el.value=r;let l=r.length;if("range-insert"===n){const n=this.parseValue((s||"").slice(0,t)),u=(null!==n?n.toString():"").split("").join(`(${this.groupChar})?`),l=new RegExp(u,"g");l.test(r);const a=e.split("").join(`(${this.groupChar})?`),o=new RegExp(a,"g");o.test(r.slice(l.lastIndex)),i=l.lastIndex+o.lastIndex,this.$refs.input.$el.setSelectionRange(i,i)}else if(l===u)"insert"===n||"delete-back-single"===n?this.$refs.input.$el.setSelectionRange(i+1,i+1):"delete-single"===n?this.$refs.input.$el.setSelectionRange(i-1,i-1):"delete-range"!==n&&"spin"!==n||this.$refs.input.$el.setSelectionRange(i,i);else if("delete-back-single"===n){let t=s.charAt(i-1),e=s.charAt(i),n=u-l,r=this._group.test(e);r&&1===n?i+=1:!r&&this.isNumeralChar(t)&&(i+=-1*n+1),this._group.lastIndex=0,this.$refs.input.$el.setSelectionRange(i,i)}else if("-"===s&&"insert"===n){this.$refs.input.$el.setSelectionRange(0,0);const t=this.initCursor()+e.length+1;this.$refs.input.$el.setSelectionRange(t,t)}else i+=l-u,this.$refs.input.$el.setSelectionRange(i,i)}this.$refs.input.$el.setAttribute("aria-valuenow",t)},concatValues(t,e){if(t&&e){let n=e.search(this._decimal);return this._decimal.lastIndex=0,-1!==n?t.split(this._decimal)[0]+e.slice(n):t}return t},getDecimalLength(t){if(t){const e=t.split(this._decimal);if(2===e.length)return e[1].replace(this._suffix,"").trim().replace(/\s/g,"").replace(this._currency,"").length}return 0},updateModel(t,e){this.d_modelValue=e,this.$emit("update:modelValue",e)},onInputFocus(t){this.focused=!0,this.$emit("focus",t)},onInputBlur(t){this.focused=!1;let e=t.target,n=this.validateValue(this.parseValue(e.value));this.$emit("blur",{originalEvent:t,value:e.value}),e.value=this.formatValue(n),e.setAttribute("aria-valuenow",n),this.updateModel(t,n)},clearTimer(){this.timer&&clearInterval(this.timer)},maxBoundry(){return this.d_modelValue>=this.max},minBoundry(){return this.d_modelValue<=this.min}},computed:{containerClass(){return["p-inputnumber p-component p-inputwrapper",this.class,{"p-inputwrapper-filled":this.filled,"p-inputwrapper-focus":this.focused,"p-inputnumber-buttons-stacked":this.showButtons&&"stacked"===this.buttonLayout,"p-inputnumber-buttons-horizontal":this.showButtons&&"horizontal"===this.buttonLayout,"p-inputnumber-buttons-vertical":this.showButtons&&"vertical"===this.buttonLayout}]},upButtonClass(){return["p-inputnumber-button p-inputnumber-button-up",this.incrementButtonClass,{"p-disabled":this.showButtons&&null!==this.max&&this.maxBoundry()}]},downButtonClass(){return["p-inputnumber-button p-inputnumber-button-down",this.decrementButtonClass,{"p-disabled":this.showButtons&&null!==this.min&&this.minBoundry()}]},filled(){return null!=this.modelValue&&this.modelValue.toString().length>0},upButtonListeners(){return{mousedown:t=>this.onUpButtonMouseDown(t),mouseup:t=>this.onUpButtonMouseUp(t),mouseleave:t=>this.onUpButtonMouseLeave(t),keydown:t=>this.onUpButtonKeyDown(t),keyup:t=>this.onUpButtonKeyUp(t)}},downButtonListeners(){return{mousedown:t=>this.onDownButtonMouseDown(t),mouseup:t=>this.onDownButtonMouseUp(t),mouseleave:t=>this.onDownButtonMouseLeave(t),keydown:t=>this.onDownButtonKeyDown(t),keyup:t=>this.onDownButtonKeyUp(t)}},formattedValue(){const t=this.modelValue||this.allowEmpty?this.modelValue:0;return this.formatValue(t)},getFormatter(){return this.numberFormat}},components:{INInputText:t,INButton:e}};const d={key:0,class:"p-inputnumber-button-group"};!function(t,e){void 0===e&&(e={});var n=e.insertAt;if(t&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===n&&i.firstChild?i.insertBefore(s,i.firstChild):i.appendChild(s),s.styleSheet?s.styleSheet.cssText=t:s.appendChild(document.createTextNode(t))}}("\n.p-inputnumber {\n display: -webkit-inline-box;\n display: -ms-inline-flexbox;\n display: inline-flex;\n}\n.p-inputnumber-button {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -webkit-box-flex: 0;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n}\n.p-inputnumber-buttons-stacked .p-button.p-inputnumber-button .p-button-label,\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button .p-button-label {\n display: none;\n}\n.p-inputnumber-buttons-stacked .p-button.p-inputnumber-button-up {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n padding: 0;\n}\n.p-inputnumber-buttons-stacked .p-inputnumber-input {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n.p-inputnumber-buttons-stacked .p-button.p-inputnumber-button-down {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n border-bottom-left-radius: 0;\n padding: 0;\n}\n.p-inputnumber-buttons-stacked .p-inputnumber-button-group {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n.p-inputnumber-buttons-stacked .p-inputnumber-button-group .p-button.p-inputnumber-button {\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n}\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-up {\n -webkit-box-ordinal-group: 4;\n -ms-flex-order: 3;\n order: 3;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n}\n.p-inputnumber-buttons-horizontal .p-inputnumber-input {\n -webkit-box-ordinal-group: 3;\n -ms-flex-order: 2;\n order: 2;\n border-radius: 0;\n}\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-down {\n -webkit-box-ordinal-group: 2;\n -ms-flex-order: 1;\n order: 1;\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n.p-inputnumber-buttons-vertical {\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n.p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-up {\n -webkit-box-ordinal-group: 2;\n -ms-flex-order: 1;\n order: 1;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n width: 100%;\n}\n.p-inputnumber-buttons-vertical .p-inputnumber-input {\n -webkit-box-ordinal-group: 3;\n -ms-flex-order: 2;\n order: 2;\n border-radius: 0;\n text-align: center;\n}\n.p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-down {\n -webkit-box-ordinal-group: 4;\n -ms-flex-order: 3;\n order: 3;\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n width: 100%;\n}\n.p-inputnumber-input {\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n}\n.p-fluid .p-inputnumber {\n width: 100%;\n}\n.p-fluid .p-inputnumber .p-inputnumber-input {\n width: 1%;\n}\n.p-fluid .p-inputnumber-buttons-vertical .p-inputnumber-input {\n width: 100%;\n}\n"),c.render=function(t,e,c,m,f,b){const g=n("INInputText"),x=n("INButton");return i(),s("span",{class:r(b.containerClass),style:u(c.style)},[l(g,a({ref:"input",class:["p-inputnumber-input",c.inputClass],style:c.inputStyle,value:b.formattedValue},t.$attrs,{"aria-valumin":c.min,"aria-valuemax":c.max,readonly:c.readonly,onInput:b.onUserInput,onKeydown:b.onInputKeyDown,onKeypress:b.onInputKeyPress,onPaste:b.onPaste,onClick:b.onInputClick,onFocus:b.onInputFocus,onBlur:b.onInputBlur}),null,16,["class","style","value","aria-valumin","aria-valuemax","readonly","onInput","onKeydown","onKeypress","onPaste","onClick","onFocus","onBlur"]),c.showButtons&&"stacked"===c.buttonLayout?(i(),s("span",d,[l(x,a({class:b.upButtonClass,icon:c.incrementButtonIcon},o(b.upButtonListeners),{disabled:t.$attrs.disabled}),null,16,["class","icon","disabled"]),l(x,a({class:b.downButtonClass,icon:c.decrementButtonIcon},o(b.downButtonListeners),{disabled:t.$attrs.disabled}),null,16,["class","icon","disabled"])])):p("",!0),c.showButtons&&"stacked"!==c.buttonLayout?(i(),h(x,a({key:1,class:b.upButtonClass,icon:c.incrementButtonIcon},o(b.upButtonListeners),{disabled:t.$attrs.disabled}),null,16,["class","icon","disabled"])):p("",!0),c.showButtons&&"stacked"!==c.buttonLayout?(i(),h(x,a({key:2,class:b.downButtonClass,icon:c.decrementButtonIcon},o(b.downButtonListeners),{disabled:t.$attrs.disabled}),null,16,["class","icon","disabled"])):p("",!0)],6)};export{c as default};
|
|
1
|
+
import t from"primevue/inputtext";import e from"primevue/button";import{resolveComponent as n,openBlock as i,createElementBlock as s,normalizeClass as r,normalizeStyle as u,createVNode as l,mergeProps as a,toHandlers as o,createCommentVNode as p,createBlock as h}from"vue";var c={name:"InputNumber",inheritAttrs:!1,emits:["update:modelValue","input","focus","blur"],props:{modelValue:{type:Number,default:null},format:{type:Boolean,default:!0},showButtons:{type:Boolean,default:!1},buttonLayout:{type:String,default:"stacked"},incrementButtonClass:{type:String,default:null},decrementButtonClass:{type:String,default:null},incrementButtonIcon:{type:String,default:"pi pi-angle-up"},decrementButtonIcon:{type:String,default:"pi pi-angle-down"},locale:{type:String,default:void 0},localeMatcher:{type:String,default:void 0},mode:{type:String,default:"decimal"},prefix:{type:String,default:null},suffix:{type:String,default:null},currency:{type:String,default:void 0},currencyDisplay:{type:String,default:void 0},useGrouping:{type:Boolean,default:!0},minFractionDigits:{type:Number,default:void 0},maxFractionDigits:{type:Number,default:void 0},min:{type:Number,default:null},max:{type:Number,default:null},step:{type:Number,default:1},allowEmpty:{type:Boolean,default:!0},readonly:{type:Boolean,default:!1},style:null,class:null,inputStyle:null,inputClass:null},numberFormat:null,_numeral:null,_decimal:null,_group:null,_minusSign:null,_currency:null,_suffix:null,_prefix:null,_index:null,groupChar:"",isSpecialChar:null,prefixChar:null,suffixChar:null,timer:null,data(){return{d_modelValue:this.modelValue,focused:!1}},watch:{modelValue(t){this.d_modelValue=t},locale(t,e){this.updateConstructParser(t,e)},localeMatcher(t,e){this.updateConstructParser(t,e)},mode(t,e){this.updateConstructParser(t,e)},currency(t,e){this.updateConstructParser(t,e)},currencyDisplay(t,e){this.updateConstructParser(t,e)},useGrouping(t,e){this.updateConstructParser(t,e)},minFractionDigits(t,e){this.updateConstructParser(t,e)},maxFractionDigits(t,e){this.updateConstructParser(t,e)},suffix(t,e){this.updateConstructParser(t,e)},prefix(t,e){this.updateConstructParser(t,e)}},created(){this.constructParser()},methods:{getOptions(){return{localeMatcher:this.localeMatcher,style:this.mode,currency:this.currency,currencyDisplay:this.currencyDisplay,useGrouping:this.useGrouping,minimumFractionDigits:this.minFractionDigits,maximumFractionDigits:this.maxFractionDigits}},constructParser(){this.numberFormat=new Intl.NumberFormat(this.locale,this.getOptions());const t=[...new Intl.NumberFormat(this.locale,{useGrouping:!1}).format(9876543210)].reverse(),e=new Map(t.map(((t,e)=>[t,e])));this._numeral=new RegExp(`[${t.join("")}]`,"g"),this._group=this.getGroupingExpression(),this._minusSign=this.getMinusSignExpression(),this._currency=this.getCurrencyExpression(),this._decimal=this.getDecimalExpression(),this._suffix=this.getSuffixExpression(),this._prefix=this.getPrefixExpression(),this._index=t=>e.get(t)},updateConstructParser(t,e){t!==e&&this.constructParser()},escapeRegExp:t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),getDecimalExpression(){const t=new Intl.NumberFormat(this.locale,{...this.getOptions(),useGrouping:!1});return new RegExp(`[${t.format(1.1).replace(this._currency,"").trim().replace(this._numeral,"")}]`,"g")},getGroupingExpression(){const t=new Intl.NumberFormat(this.locale,{useGrouping:!0});return this.groupChar=t.format(1e6).trim().replace(this._numeral,"").charAt(0),new RegExp(`[${this.groupChar}]`,"g")},getMinusSignExpression(){const t=new Intl.NumberFormat(this.locale,{useGrouping:!1});return new RegExp(`[${t.format(-1).trim().replace(this._numeral,"")}]`,"g")},getCurrencyExpression(){if(this.currency){const t=new Intl.NumberFormat(this.locale,{style:"currency",currency:this.currency,currencyDisplay:this.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});return new RegExp(`[${t.format(1).replace(/\s/g,"").replace(this._numeral,"").replace(this._group,"")}]`,"g")}return new RegExp("[]","g")},getPrefixExpression(){if(this.prefix)this.prefixChar=this.prefix;else{const t=new Intl.NumberFormat(this.locale,{style:this.mode,currency:this.currency,currencyDisplay:this.currencyDisplay});this.prefixChar=t.format(1).split("1")[0]}return new RegExp(`${this.escapeRegExp(this.prefixChar||"")}`,"g")},getSuffixExpression(){if(this.suffix)this.suffixChar=this.suffix;else{const t=new Intl.NumberFormat(this.locale,{style:this.mode,currency:this.currency,currencyDisplay:this.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});this.suffixChar=t.format(1).split("1")[1]}return new RegExp(`${this.escapeRegExp(this.suffixChar||"")}`,"g")},formatValue(t){if(null!=t){if("-"===t)return t;if(this.format){let e=new Intl.NumberFormat(this.locale,this.getOptions()).format(t);return this.prefix&&(e=this.prefix+e),this.suffix&&(e+=this.suffix),e}return t.toString()}return""},parseValue(t){let e=t.replace(this._suffix,"").replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").replace(this._group,"").replace(this._minusSign,"-").replace(this._decimal,".").replace(this._numeral,this._index);if(e){if("-"===e)return e;let t=+e;return isNaN(t)?null:t}return null},repeat(t,e,n){if(this.readonly)return;let i=e||500;this.clearTimer(),this.timer=setTimeout((()=>{this.repeat(t,40,n)}),i),this.spin(t,n)},spin(t,e){if(this.$refs.input){let n=this.step*e,i=this.parseValue(this.$refs.input.$el.value)||0,s=this.validateValue(i+n);this.updateInput(s,null,"spin"),this.updateModel(t,s),this.handleOnInput(t,i,s)}},onUpButtonMouseDown(t){this.$attrs.disabled||(this.$refs.input.$el.focus(),this.repeat(t,null,1),t.preventDefault())},onUpButtonMouseUp(){this.$attrs.disabled||this.clearTimer()},onUpButtonMouseLeave(){this.$attrs.disabled||this.clearTimer()},onUpButtonKeyUp(){this.$attrs.disabled||this.clearTimer()},onUpButtonKeyDown(t){32!==t.keyCode&&13!==t.keyCode||this.repeat(t,null,1)},onDownButtonMouseDown(t){this.$attrs.disabled||(this.$refs.input.$el.focus(),this.repeat(t,null,-1),t.preventDefault())},onDownButtonMouseUp(){this.$attrs.disabled||this.clearTimer()},onDownButtonMouseLeave(){this.$attrs.disabled||this.clearTimer()},onDownButtonKeyUp(){this.$attrs.disabled||this.clearTimer()},onDownButtonKeyDown(t){32!==t.keyCode&&13!==t.keyCode||this.repeat(t,null,-1)},onUserInput(){this.isSpecialChar&&(this.$refs.input.$el.value=this.lastValue),this.isSpecialChar=!1},onInputKeyDown(t){if(this.readonly)return;if(this.lastValue=t.target.value,t.shiftKey||t.altKey)return void(this.isSpecialChar=!0);let e=t.target.selectionStart,n=t.target.selectionEnd,i=t.target.value,s=null;switch(t.altKey&&t.preventDefault(),t.which){case 38:this.spin(t,1),t.preventDefault();break;case 40:this.spin(t,-1),t.preventDefault();break;case 37:this.isNumeralChar(i.charAt(e-1))||t.preventDefault();break;case 39:this.isNumeralChar(i.charAt(e))||t.preventDefault();break;case 9:case 13:s=this.validateValue(this.parseValue(i)),this.$refs.input.$el.value=this.formatValue(s),this.$refs.input.$el.setAttribute("aria-valuenow",s),this.updateModel(t,s);break;case 8:if(t.preventDefault(),e===n){const n=i.charAt(e-1),{decimalCharIndex:r,decimalCharIndexWithoutPrefix:u}=this.getDecimalCharIndexes(i);if(this.isNumeralChar(n)){const t=this.getDecimalLength(i);if(this._group.test(n))this._group.lastIndex=0,s=i.slice(0,e-2)+i.slice(e-1);else if(this._decimal.test(n))this._decimal.lastIndex=0,t?this.$refs.input.$el.setSelectionRange(e-1,e-1):s=i.slice(0,e-1)+i.slice(e);else if(r>0&&e>r){const n=this.isDecimalMode()&&(this.minFractionDigits||0)<t?"":"0";s=i.slice(0,e-1)+n+i.slice(e)}else 1===u?(s=i.slice(0,e-1)+"0"+i.slice(e),s=this.parseValue(s)>0?s:""):s=i.slice(0,e-1)+i.slice(e)}this.updateValue(t,s,null,"delete-single")}else s=this.deleteRange(i,e,n),this.updateValue(t,s,null,"delete-range");break;case 46:if(t.preventDefault(),e===n){const n=i.charAt(e),{decimalCharIndex:r,decimalCharIndexWithoutPrefix:u}=this.getDecimalCharIndexes(i);if(this.isNumeralChar(n)){const t=this.getDecimalLength(i);if(this._group.test(n))this._group.lastIndex=0,s=i.slice(0,e)+i.slice(e+2);else if(this._decimal.test(n))this._decimal.lastIndex=0,t?this.$refs.input.$el.setSelectionRange(e+1,e+1):s=i.slice(0,e)+i.slice(e+1);else if(r>0&&e>r){const n=this.isDecimalMode()&&(this.minFractionDigits||0)<t?"":"0";s=i.slice(0,e)+n+i.slice(e+1)}else 1===u?(s=i.slice(0,e)+"0"+i.slice(e+1),s=this.parseValue(s)>0?s:""):s=i.slice(0,e)+i.slice(e+1)}this.updateValue(t,s,null,"delete-back-single")}else s=this.deleteRange(i,e,n),this.updateValue(t,s,null,"delete-range")}},onInputKeyPress(t){if(this.readonly)return;t.preventDefault();let e=t.which||t.keyCode,n=String.fromCharCode(e);const i=this.isDecimalSign(n),s=this.isMinusSign(n);(48<=e&&e<=57||s||i)&&this.insert(t,n,{isDecimalSign:i,isMinusSign:s})},onPaste(t){t.preventDefault();let e=(t.clipboardData||window.clipboardData).getData("Text");if(e){let n=this.parseValue(e);null!=n&&this.insert(t,n.toString())}},allowMinusSign(){return null===this.min||this.min<0},isMinusSign(t){return!(!this._minusSign.test(t)&&"-"!==t)&&(this._minusSign.lastIndex=0,!0)},isDecimalSign(t){return!!this._decimal.test(t)&&(this._decimal.lastIndex=0,!0)},isDecimalMode(){return"decimal"===this.mode},getDecimalCharIndexes(t){let e=t.search(this._decimal);this._decimal.lastIndex=0;const n=t.replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").search(this._decimal);return this._decimal.lastIndex=0,{decimalCharIndex:e,decimalCharIndexWithoutPrefix:n}},getCharIndexes(t){const e=t.search(this._decimal);this._decimal.lastIndex=0;const n=t.search(this._minusSign);this._minusSign.lastIndex=0;const i=t.search(this._suffix);this._suffix.lastIndex=0;const s=t.search(this._currency);return this._currency.lastIndex=0,{decimalCharIndex:e,minusCharIndex:n,suffixCharIndex:i,currencyCharIndex:s}},insert(t,e,n={isDecimalSign:!1,isMinusSign:!1}){const i=e.search(this._minusSign);if(this._minusSign.lastIndex=0,!this.allowMinusSign()&&-1!==i)return;const s=this.$refs.input.$el.selectionStart,r=this.$refs.input.$el.selectionEnd;let u=this.$refs.input.$el.value.trim();const{decimalCharIndex:l,minusCharIndex:a,suffixCharIndex:o,currencyCharIndex:p}=this.getCharIndexes(u);let h;if(n.isMinusSign)0===s&&(h=u,-1!==a&&0===r||(h=this.insertText(u,e,0,r)),this.updateValue(t,h,e,"insert"));else if(n.isDecimalSign)l>0&&s===l?this.updateValue(t,u,e,"insert"):(l>s&&l<r||-1===l&&this.maxFractionDigits)&&(h=this.insertText(u,e,s,r),this.updateValue(t,h,e,"insert"));else{const n=this.numberFormat.resolvedOptions().maximumFractionDigits,i=s!==r?"range-insert":"insert";if(l>0&&s>l){if(s+e.length-(l+1)<=n){const n=p>=s?p-1:o>=s?o:u.length;h=u.slice(0,s)+e+u.slice(s+e.length,n)+u.slice(n),this.updateValue(t,h,e,i)}}else h=this.insertText(u,e,s,r),this.updateValue(t,h,e,i)}},insertText(t,e,n,i){if(2===("."===e?e:e.split(".")).length){const s=t.slice(n,i).search(this._decimal);return this._decimal.lastIndex=0,s>0?t.slice(0,n)+this.formatValue(e)+t.slice(i):t||this.formatValue(e)}return i-n===t.length?this.formatValue(e):0===n?e+t.slice(i):i===t.length?t.slice(0,n)+e:t.slice(0,n)+e+t.slice(i)},deleteRange(t,e,n){let i;return i=n-e===t.length?"":0===e?t.slice(n):n===t.length?t.slice(0,e):t.slice(0,e)+t.slice(n),i},initCursor(){let t=this.$refs.input.$el.selectionStart,e=this.$refs.input.$el.value,n=e.length,i=null,s=(this.prefixChar||"").length;e=e.replace(this._prefix,""),t-=s;let r=e.charAt(t);if(this.isNumeralChar(r))return t+s;let u=t-1;for(;u>=0;){if(r=e.charAt(u),this.isNumeralChar(r)){i=u+s;break}u--}if(null!==i)this.$refs.input.$el.setSelectionRange(i+1,i+1);else{for(u=t;u<n;){if(r=e.charAt(u),this.isNumeralChar(r)){i=u+s;break}u++}null!==i&&this.$refs.input.$el.setSelectionRange(i,i)}return i||0},onInputClick(){this.readonly||this.initCursor()},isNumeralChar(t){return!(1!==t.length||!(this._numeral.test(t)||this._decimal.test(t)||this._group.test(t)||this._minusSign.test(t)))&&(this.resetRegex(),!0)},resetRegex(){this._numeral.lastIndex=0,this._decimal.lastIndex=0,this._group.lastIndex=0,this._minusSign.lastIndex=0},updateValue(t,e,n,i){let s=this.$refs.input.$el.value,r=null;null!=e&&(r=this.parseValue(e),r=r||this.allowEmpty?r:0,this.updateInput(r,n,i,e),this.handleOnInput(t,s,r))},handleOnInput(t,e,n){this.isValueChanged(e,n)&&this.$emit("input",{originalEvent:t,value:n})},isValueChanged(t,e){if(null===e&&null!==t)return!0;if(null!=e){return e!==("string"==typeof t?this.parseValue(t):t)}return!1},validateValue(t){return"-"===t||null==t?null:null!=this.min&&t<this.min?this.min:null!=this.max&&t>this.max?this.max:t},updateInput(t,e,n,i){e=e||"";let s=this.$refs.input.$el.value,r=this.formatValue(t),u=s.length;if(r!==i&&(r=this.concatValues(r,i)),0===u){this.$refs.input.$el.value=r,this.$refs.input.$el.setSelectionRange(0,0);const t=this.initCursor()+e.length;this.$refs.input.$el.setSelectionRange(t,t)}else{let t=this.$refs.input.$el.selectionStart,i=this.$refs.input.$el.selectionEnd;this.$refs.input.$el.value=r;let l=r.length;if("range-insert"===n){const n=this.parseValue((s||"").slice(0,t)),u=(null!==n?n.toString():"").split("").join(`(${this.groupChar})?`),l=new RegExp(u,"g");l.test(r);const a=e.split("").join(`(${this.groupChar})?`),o=new RegExp(a,"g");o.test(r.slice(l.lastIndex)),i=l.lastIndex+o.lastIndex,this.$refs.input.$el.setSelectionRange(i,i)}else if(l===u)"insert"===n||"delete-back-single"===n?this.$refs.input.$el.setSelectionRange(i+1,i+1):"delete-single"===n?this.$refs.input.$el.setSelectionRange(i-1,i-1):"delete-range"!==n&&"spin"!==n||this.$refs.input.$el.setSelectionRange(i,i);else if("delete-back-single"===n){let t=s.charAt(i-1),e=s.charAt(i),n=u-l,r=this._group.test(e);r&&1===n?i+=1:!r&&this.isNumeralChar(t)&&(i+=-1*n+1),this._group.lastIndex=0,this.$refs.input.$el.setSelectionRange(i,i)}else if("-"===s&&"insert"===n){this.$refs.input.$el.setSelectionRange(0,0);const t=this.initCursor()+e.length+1;this.$refs.input.$el.setSelectionRange(t,t)}else i+=l-u,this.$refs.input.$el.setSelectionRange(i,i)}this.$refs.input.$el.setAttribute("aria-valuenow",t)},concatValues(t,e){if(t&&e){let n=e.search(this._decimal);return this._decimal.lastIndex=0,-1!==n?t.split(this._decimal)[0]+e.slice(n):t}return t},getDecimalLength(t){if(t){const e=t.split(this._decimal);if(2===e.length)return e[1].replace(this._suffix,"").trim().replace(/\s/g,"").replace(this._currency,"").length}return 0},updateModel(t,e){this.d_modelValue=e,this.$emit("update:modelValue",e)},onInputFocus(t){this.focused=!0,this.$emit("focus",t)},onInputBlur(t){this.focused=!1;let e=t.target,n=this.validateValue(this.parseValue(e.value));this.$emit("blur",{originalEvent:t,value:e.value}),e.value=this.formatValue(n),e.setAttribute("aria-valuenow",n),this.updateModel(t,n)},clearTimer(){this.timer&&clearInterval(this.timer)},maxBoundry(){return this.d_modelValue>=this.max},minBoundry(){return this.d_modelValue<=this.min}},computed:{containerClass(){return["p-inputnumber p-component p-inputwrapper",this.class,{"p-inputwrapper-filled":this.filled,"p-inputwrapper-focus":this.focused,"p-inputnumber-buttons-stacked":this.showButtons&&"stacked"===this.buttonLayout,"p-inputnumber-buttons-horizontal":this.showButtons&&"horizontal"===this.buttonLayout,"p-inputnumber-buttons-vertical":this.showButtons&&"vertical"===this.buttonLayout}]},upButtonClass(){return["p-inputnumber-button p-inputnumber-button-up",this.incrementButtonClass,{"p-disabled":this.showButtons&&null!==this.max&&this.maxBoundry()}]},downButtonClass(){return["p-inputnumber-button p-inputnumber-button-down",this.decrementButtonClass,{"p-disabled":this.showButtons&&null!==this.min&&this.minBoundry()}]},filled(){return null!=this.modelValue&&this.modelValue.toString().length>0},upButtonListeners(){return{mousedown:t=>this.onUpButtonMouseDown(t),mouseup:t=>this.onUpButtonMouseUp(t),mouseleave:t=>this.onUpButtonMouseLeave(t),keydown:t=>this.onUpButtonKeyDown(t),keyup:t=>this.onUpButtonKeyUp(t)}},downButtonListeners(){return{mousedown:t=>this.onDownButtonMouseDown(t),mouseup:t=>this.onDownButtonMouseUp(t),mouseleave:t=>this.onDownButtonMouseLeave(t),keydown:t=>this.onDownButtonKeyDown(t),keyup:t=>this.onDownButtonKeyUp(t)}},formattedValue(){const t=this.modelValue||this.allowEmpty?this.modelValue:0;return this.formatValue(t)},getFormatter(){return this.numberFormat}},components:{INInputText:t,INButton:e}};const d={key:0,class:"p-inputnumber-button-group"};!function(t,e){void 0===e&&(e={});var n=e.insertAt;if(t&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===n&&i.firstChild?i.insertBefore(s,i.firstChild):i.appendChild(s),s.styleSheet?s.styleSheet.cssText=t:s.appendChild(document.createTextNode(t))}}("\n.p-inputnumber {\n display: -webkit-inline-box;\n display: -ms-inline-flexbox;\n display: inline-flex;\n}\n.p-inputnumber-button {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -webkit-box-flex: 0;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n}\n.p-inputnumber-buttons-stacked .p-button.p-inputnumber-button .p-button-label,\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button .p-button-label {\n display: none;\n}\n.p-inputnumber-buttons-stacked .p-button.p-inputnumber-button-up {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n padding: 0;\n}\n.p-inputnumber-buttons-stacked .p-inputnumber-input {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n.p-inputnumber-buttons-stacked .p-button.p-inputnumber-button-down {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n border-bottom-left-radius: 0;\n padding: 0;\n}\n.p-inputnumber-buttons-stacked .p-inputnumber-button-group {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n.p-inputnumber-buttons-stacked .p-inputnumber-button-group .p-button.p-inputnumber-button {\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n}\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-up {\n -webkit-box-ordinal-group: 4;\n -ms-flex-order: 3;\n order: 3;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n}\n.p-inputnumber-buttons-horizontal .p-inputnumber-input {\n -webkit-box-ordinal-group: 3;\n -ms-flex-order: 2;\n order: 2;\n border-radius: 0;\n}\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-down {\n -webkit-box-ordinal-group: 2;\n -ms-flex-order: 1;\n order: 1;\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n.p-inputnumber-buttons-vertical {\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n.p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-up {\n -webkit-box-ordinal-group: 2;\n -ms-flex-order: 1;\n order: 1;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n width: 100%;\n}\n.p-inputnumber-buttons-vertical .p-inputnumber-input {\n -webkit-box-ordinal-group: 3;\n -ms-flex-order: 2;\n order: 2;\n border-radius: 0;\n text-align: center;\n}\n.p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-down {\n -webkit-box-ordinal-group: 4;\n -ms-flex-order: 3;\n order: 3;\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n width: 100%;\n}\n.p-inputnumber-input {\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n}\n.p-fluid .p-inputnumber {\n width: 100%;\n}\n.p-fluid .p-inputnumber .p-inputnumber-input {\n width: 1%;\n}\n.p-fluid .p-inputnumber-buttons-vertical .p-inputnumber-input {\n width: 100%;\n}\n"),c.render=function(t,e,c,m,f,b){const g=n("INInputText"),x=n("INButton");return i(),s("span",{class:r(b.containerClass),style:u(c.style)},[l(g,a({ref:"input",class:["p-inputnumber-input",c.inputClass],style:c.inputStyle,value:b.formattedValue},t.$attrs,{"aria-valumin":c.min,"aria-valuemax":c.max,readonly:c.readonly,onInput:b.onUserInput,onKeydown:b.onInputKeyDown,onKeypress:b.onInputKeyPress,onPaste:b.onPaste,onClick:b.onInputClick,onFocus:b.onInputFocus,onBlur:b.onInputBlur}),null,16,["class","style","value","aria-valumin","aria-valuemax","readonly","onInput","onKeydown","onKeypress","onPaste","onClick","onFocus","onBlur"]),c.showButtons&&"stacked"===c.buttonLayout?(i(),s("span",d,[l(x,a({class:b.upButtonClass,icon:c.incrementButtonIcon},o(b.upButtonListeners),{disabled:t.$attrs.disabled}),null,16,["class","icon","disabled"]),l(x,a({class:b.downButtonClass,icon:c.decrementButtonIcon},o(b.downButtonListeners),{disabled:t.$attrs.disabled}),null,16,["class","icon","disabled"])])):p("",!0),c.showButtons&&"stacked"!==c.buttonLayout?(i(),h(x,a({key:1,class:b.upButtonClass,icon:c.incrementButtonIcon},o(b.upButtonListeners),{disabled:t.$attrs.disabled}),null,16,["class","icon","disabled"])):p("",!0),c.showButtons&&"stacked"!==c.buttonLayout?(i(),h(x,a({key:2,class:b.downButtonClass,icon:c.decrementButtonIcon},o(b.downButtonListeners),{disabled:t.$attrs.disabled}),null,16,["class","icon","disabled"])):p("",!0)],6)};export{c as default};
|
|
@@ -425,7 +425,8 @@ this.primevue.inputnumber = (function (InputText, Button, vue) {
|
|
|
425
425
|
}
|
|
426
426
|
break;
|
|
427
427
|
|
|
428
|
-
//enter
|
|
428
|
+
//tab and enter
|
|
429
|
+
case 9:
|
|
429
430
|
case 13:
|
|
430
431
|
newValueStr = this.validateValue(this.parseValue(inputValue));
|
|
431
432
|
this.$refs.input.$el.value = this.formatValue(newValueStr);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
this.primevue=this.primevue||{},this.primevue.inputnumber=function(e,t,n){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(e),r=i(t),l={name:"InputNumber",inheritAttrs:!1,emits:["update:modelValue","input","focus","blur"],props:{modelValue:{type:Number,default:null},format:{type:Boolean,default:!0},showButtons:{type:Boolean,default:!1},buttonLayout:{type:String,default:"stacked"},incrementButtonClass:{type:String,default:null},decrementButtonClass:{type:String,default:null},incrementButtonIcon:{type:String,default:"pi pi-angle-up"},decrementButtonIcon:{type:String,default:"pi pi-angle-down"},locale:{type:String,default:void 0},localeMatcher:{type:String,default:void 0},mode:{type:String,default:"decimal"},prefix:{type:String,default:null},suffix:{type:String,default:null},currency:{type:String,default:void 0},currencyDisplay:{type:String,default:void 0},useGrouping:{type:Boolean,default:!0},minFractionDigits:{type:Number,default:void 0},maxFractionDigits:{type:Number,default:void 0},min:{type:Number,default:null},max:{type:Number,default:null},step:{type:Number,default:1},allowEmpty:{type:Boolean,default:!0},readonly:{type:Boolean,default:!1},style:null,class:null,inputStyle:null,inputClass:null},numberFormat:null,_numeral:null,_decimal:null,_group:null,_minusSign:null,_currency:null,_suffix:null,_prefix:null,_index:null,groupChar:"",isSpecialChar:null,prefixChar:null,suffixChar:null,timer:null,data(){return{d_modelValue:this.modelValue,focused:!1}},watch:{modelValue(e){this.d_modelValue=e},locale(e,t){this.updateConstructParser(e,t)},localeMatcher(e,t){this.updateConstructParser(e,t)},mode(e,t){this.updateConstructParser(e,t)},currency(e,t){this.updateConstructParser(e,t)},currencyDisplay(e,t){this.updateConstructParser(e,t)},useGrouping(e,t){this.updateConstructParser(e,t)},minFractionDigits(e,t){this.updateConstructParser(e,t)},maxFractionDigits(e,t){this.updateConstructParser(e,t)},suffix(e,t){this.updateConstructParser(e,t)},prefix(e,t){this.updateConstructParser(e,t)}},created(){this.constructParser()},methods:{getOptions(){return{localeMatcher:this.localeMatcher,style:this.mode,currency:this.currency,currencyDisplay:this.currencyDisplay,useGrouping:this.useGrouping,minimumFractionDigits:this.minFractionDigits,maximumFractionDigits:this.maxFractionDigits}},constructParser(){this.numberFormat=new Intl.NumberFormat(this.locale,this.getOptions());const e=[...new Intl.NumberFormat(this.locale,{useGrouping:!1}).format(9876543210)].reverse(),t=new Map(e.map(((e,t)=>[e,t])));this._numeral=new RegExp(`[${e.join("")}]`,"g"),this._group=this.getGroupingExpression(),this._minusSign=this.getMinusSignExpression(),this._currency=this.getCurrencyExpression(),this._decimal=this.getDecimalExpression(),this._suffix=this.getSuffixExpression(),this._prefix=this.getPrefixExpression(),this._index=e=>t.get(e)},updateConstructParser(e,t){e!==t&&this.constructParser()},escapeRegExp:e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),getDecimalExpression(){const e=new Intl.NumberFormat(this.locale,{...this.getOptions(),useGrouping:!1});return new RegExp(`[${e.format(1.1).replace(this._currency,"").trim().replace(this._numeral,"")}]`,"g")},getGroupingExpression(){const e=new Intl.NumberFormat(this.locale,{useGrouping:!0});return this.groupChar=e.format(1e6).trim().replace(this._numeral,"").charAt(0),new RegExp(`[${this.groupChar}]`,"g")},getMinusSignExpression(){const e=new Intl.NumberFormat(this.locale,{useGrouping:!1});return new RegExp(`[${e.format(-1).trim().replace(this._numeral,"")}]`,"g")},getCurrencyExpression(){if(this.currency){const e=new Intl.NumberFormat(this.locale,{style:"currency",currency:this.currency,currencyDisplay:this.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});return new RegExp(`[${e.format(1).replace(/\s/g,"").replace(this._numeral,"").replace(this._group,"")}]`,"g")}return new RegExp("[]","g")},getPrefixExpression(){if(this.prefix)this.prefixChar=this.prefix;else{const e=new Intl.NumberFormat(this.locale,{style:this.mode,currency:this.currency,currencyDisplay:this.currencyDisplay});this.prefixChar=e.format(1).split("1")[0]}return new RegExp(`${this.escapeRegExp(this.prefixChar||"")}`,"g")},getSuffixExpression(){if(this.suffix)this.suffixChar=this.suffix;else{const e=new Intl.NumberFormat(this.locale,{style:this.mode,currency:this.currency,currencyDisplay:this.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});this.suffixChar=e.format(1).split("1")[1]}return new RegExp(`${this.escapeRegExp(this.suffixChar||"")}`,"g")},formatValue(e){if(null!=e){if("-"===e)return e;if(this.format){let t=new Intl.NumberFormat(this.locale,this.getOptions()).format(e);return this.prefix&&(t=this.prefix+t),this.suffix&&(t+=this.suffix),t}return e.toString()}return""},parseValue(e){let t=e.replace(this._suffix,"").replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").replace(this._group,"").replace(this._minusSign,"-").replace(this._decimal,".").replace(this._numeral,this._index);if(t){if("-"===t)return t;let e=+t;return isNaN(e)?null:e}return null},repeat(e,t,n){if(this.readonly)return;let i=t||500;this.clearTimer(),this.timer=setTimeout((()=>{this.repeat(e,40,n)}),i),this.spin(e,n)},spin(e,t){if(this.$refs.input){let n=this.step*t,i=this.parseValue(this.$refs.input.$el.value)||0,s=this.validateValue(i+n);this.updateInput(s,null,"spin"),this.updateModel(e,s),this.handleOnInput(e,i,s)}},onUpButtonMouseDown(e){this.$attrs.disabled||(this.$refs.input.$el.focus(),this.repeat(e,null,1),e.preventDefault())},onUpButtonMouseUp(){this.$attrs.disabled||this.clearTimer()},onUpButtonMouseLeave(){this.$attrs.disabled||this.clearTimer()},onUpButtonKeyUp(){this.$attrs.disabled||this.clearTimer()},onUpButtonKeyDown(e){32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,1)},onDownButtonMouseDown(e){this.$attrs.disabled||(this.$refs.input.$el.focus(),this.repeat(e,null,-1),e.preventDefault())},onDownButtonMouseUp(){this.$attrs.disabled||this.clearTimer()},onDownButtonMouseLeave(){this.$attrs.disabled||this.clearTimer()},onDownButtonKeyUp(){this.$attrs.disabled||this.clearTimer()},onDownButtonKeyDown(e){32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,-1)},onUserInput(){this.isSpecialChar&&(this.$refs.input.$el.value=this.lastValue),this.isSpecialChar=!1},onInputKeyDown(e){if(this.readonly)return;if(this.lastValue=e.target.value,e.shiftKey||e.altKey)return void(this.isSpecialChar=!0);let t=e.target.selectionStart,n=e.target.selectionEnd,i=e.target.value,s=null;switch(e.altKey&&e.preventDefault(),e.which){case 38:this.spin(e,1),e.preventDefault();break;case 40:this.spin(e,-1),e.preventDefault();break;case 37:this.isNumeralChar(i.charAt(t-1))||e.preventDefault();break;case 39:this.isNumeralChar(i.charAt(t))||e.preventDefault();break;case 13:s=this.validateValue(this.parseValue(i)),this.$refs.input.$el.value=this.formatValue(s),this.$refs.input.$el.setAttribute("aria-valuenow",s),this.updateModel(e,s);break;case 8:if(e.preventDefault(),t===n){const n=i.charAt(t-1),{decimalCharIndex:r,decimalCharIndexWithoutPrefix:l}=this.getDecimalCharIndexes(i);if(this.isNumeralChar(n)){const e=this.getDecimalLength(i);if(this._group.test(n))this._group.lastIndex=0,s=i.slice(0,t-2)+i.slice(t-1);else if(this._decimal.test(n))this._decimal.lastIndex=0,e?this.$refs.input.$el.setSelectionRange(t-1,t-1):s=i.slice(0,t-1)+i.slice(t);else if(r>0&&t>r){const n=this.isDecimalMode()&&(this.minFractionDigits||0)<e?"":"0";s=i.slice(0,t-1)+n+i.slice(t)}else 1===l?(s=i.slice(0,t-1)+"0"+i.slice(t),s=this.parseValue(s)>0?s:""):s=i.slice(0,t-1)+i.slice(t)}this.updateValue(e,s,null,"delete-single")}else s=this.deleteRange(i,t,n),this.updateValue(e,s,null,"delete-range");break;case 46:if(e.preventDefault(),t===n){const n=i.charAt(t),{decimalCharIndex:r,decimalCharIndexWithoutPrefix:l}=this.getDecimalCharIndexes(i);if(this.isNumeralChar(n)){const e=this.getDecimalLength(i);if(this._group.test(n))this._group.lastIndex=0,s=i.slice(0,t)+i.slice(t+2);else if(this._decimal.test(n))this._decimal.lastIndex=0,e?this.$refs.input.$el.setSelectionRange(t+1,t+1):s=i.slice(0,t)+i.slice(t+1);else if(r>0&&t>r){const n=this.isDecimalMode()&&(this.minFractionDigits||0)<e?"":"0";s=i.slice(0,t)+n+i.slice(t+1)}else 1===l?(s=i.slice(0,t)+"0"+i.slice(t+1),s=this.parseValue(s)>0?s:""):s=i.slice(0,t)+i.slice(t+1)}this.updateValue(e,s,null,"delete-back-single")}else s=this.deleteRange(i,t,n),this.updateValue(e,s,null,"delete-range")}},onInputKeyPress(e){if(this.readonly)return;e.preventDefault();let t=e.which||e.keyCode,n=String.fromCharCode(t);const i=this.isDecimalSign(n),s=this.isMinusSign(n);(48<=t&&t<=57||s||i)&&this.insert(e,n,{isDecimalSign:i,isMinusSign:s})},onPaste(e){e.preventDefault();let t=(e.clipboardData||window.clipboardData).getData("Text");if(t){let n=this.parseValue(t);null!=n&&this.insert(e,n.toString())}},allowMinusSign(){return null===this.min||this.min<0},isMinusSign(e){return!(!this._minusSign.test(e)&&"-"!==e)&&(this._minusSign.lastIndex=0,!0)},isDecimalSign(e){return!!this._decimal.test(e)&&(this._decimal.lastIndex=0,!0)},isDecimalMode(){return"decimal"===this.mode},getDecimalCharIndexes(e){let t=e.search(this._decimal);this._decimal.lastIndex=0;const n=e.replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").search(this._decimal);return this._decimal.lastIndex=0,{decimalCharIndex:t,decimalCharIndexWithoutPrefix:n}},getCharIndexes(e){const t=e.search(this._decimal);this._decimal.lastIndex=0;const n=e.search(this._minusSign);this._minusSign.lastIndex=0;const i=e.search(this._suffix);this._suffix.lastIndex=0;const s=e.search(this._currency);return this._currency.lastIndex=0,{decimalCharIndex:t,minusCharIndex:n,suffixCharIndex:i,currencyCharIndex:s}},insert(e,t,n={isDecimalSign:!1,isMinusSign:!1}){const i=t.search(this._minusSign);if(this._minusSign.lastIndex=0,!this.allowMinusSign()&&-1!==i)return;const s=this.$refs.input.$el.selectionStart,r=this.$refs.input.$el.selectionEnd;let l=this.$refs.input.$el.value.trim();const{decimalCharIndex:u,minusCharIndex:a,suffixCharIndex:o,currencyCharIndex:p}=this.getCharIndexes(l);let h;if(n.isMinusSign)0===s&&(h=l,-1!==a&&0===r||(h=this.insertText(l,t,0,r)),this.updateValue(e,h,t,"insert"));else if(n.isDecimalSign)u>0&&s===u?this.updateValue(e,l,t,"insert"):(u>s&&u<r||-1===u&&this.maxFractionDigits)&&(h=this.insertText(l,t,s,r),this.updateValue(e,h,t,"insert"));else{const n=this.numberFormat.resolvedOptions().maximumFractionDigits,i=s!==r?"range-insert":"insert";if(u>0&&s>u){if(s+t.length-(u+1)<=n){const n=p>=s?p-1:o>=s?o:l.length;h=l.slice(0,s)+t+l.slice(s+t.length,n)+l.slice(n),this.updateValue(e,h,t,i)}}else h=this.insertText(l,t,s,r),this.updateValue(e,h,t,i)}},insertText(e,t,n,i){if(2===("."===t?t:t.split(".")).length){const s=e.slice(n,i).search(this._decimal);return this._decimal.lastIndex=0,s>0?e.slice(0,n)+this.formatValue(t)+e.slice(i):e||this.formatValue(t)}return i-n===e.length?this.formatValue(t):0===n?t+e.slice(i):i===e.length?e.slice(0,n)+t:e.slice(0,n)+t+e.slice(i)},deleteRange(e,t,n){let i;return i=n-t===e.length?"":0===t?e.slice(n):n===e.length?e.slice(0,t):e.slice(0,t)+e.slice(n),i},initCursor(){let e=this.$refs.input.$el.selectionStart,t=this.$refs.input.$el.value,n=t.length,i=null,s=(this.prefixChar||"").length;t=t.replace(this._prefix,""),e-=s;let r=t.charAt(e);if(this.isNumeralChar(r))return e+s;let l=e-1;for(;l>=0;){if(r=t.charAt(l),this.isNumeralChar(r)){i=l+s;break}l--}if(null!==i)this.$refs.input.$el.setSelectionRange(i+1,i+1);else{for(l=e;l<n;){if(r=t.charAt(l),this.isNumeralChar(r)){i=l+s;break}l++}null!==i&&this.$refs.input.$el.setSelectionRange(i,i)}return i||0},onInputClick(){this.readonly||this.initCursor()},isNumeralChar(e){return!(1!==e.length||!(this._numeral.test(e)||this._decimal.test(e)||this._group.test(e)||this._minusSign.test(e)))&&(this.resetRegex(),!0)},resetRegex(){this._numeral.lastIndex=0,this._decimal.lastIndex=0,this._group.lastIndex=0,this._minusSign.lastIndex=0},updateValue(e,t,n,i){let s=this.$refs.input.$el.value,r=null;null!=t&&(r=this.parseValue(t),r=r||this.allowEmpty?r:0,this.updateInput(r,n,i,t),this.handleOnInput(e,s,r))},handleOnInput(e,t,n){this.isValueChanged(t,n)&&this.$emit("input",{originalEvent:e,value:n})},isValueChanged(e,t){if(null===t&&null!==e)return!0;if(null!=t){return t!==("string"==typeof e?this.parseValue(e):e)}return!1},validateValue(e){return"-"===e||null==e?null:null!=this.min&&e<this.min?this.min:null!=this.max&&e>this.max?this.max:e},updateInput(e,t,n,i){t=t||"";let s=this.$refs.input.$el.value,r=this.formatValue(e),l=s.length;if(r!==i&&(r=this.concatValues(r,i)),0===l){this.$refs.input.$el.value=r,this.$refs.input.$el.setSelectionRange(0,0);const e=this.initCursor()+t.length;this.$refs.input.$el.setSelectionRange(e,e)}else{let e=this.$refs.input.$el.selectionStart,i=this.$refs.input.$el.selectionEnd;this.$refs.input.$el.value=r;let u=r.length;if("range-insert"===n){const n=this.parseValue((s||"").slice(0,e)),l=(null!==n?n.toString():"").split("").join(`(${this.groupChar})?`),u=new RegExp(l,"g");u.test(r);const a=t.split("").join(`(${this.groupChar})?`),o=new RegExp(a,"g");o.test(r.slice(u.lastIndex)),i=u.lastIndex+o.lastIndex,this.$refs.input.$el.setSelectionRange(i,i)}else if(u===l)"insert"===n||"delete-back-single"===n?this.$refs.input.$el.setSelectionRange(i+1,i+1):"delete-single"===n?this.$refs.input.$el.setSelectionRange(i-1,i-1):"delete-range"!==n&&"spin"!==n||this.$refs.input.$el.setSelectionRange(i,i);else if("delete-back-single"===n){let e=s.charAt(i-1),t=s.charAt(i),n=l-u,r=this._group.test(t);r&&1===n?i+=1:!r&&this.isNumeralChar(e)&&(i+=-1*n+1),this._group.lastIndex=0,this.$refs.input.$el.setSelectionRange(i,i)}else if("-"===s&&"insert"===n){this.$refs.input.$el.setSelectionRange(0,0);const e=this.initCursor()+t.length+1;this.$refs.input.$el.setSelectionRange(e,e)}else i+=u-l,this.$refs.input.$el.setSelectionRange(i,i)}this.$refs.input.$el.setAttribute("aria-valuenow",e)},concatValues(e,t){if(e&&t){let n=t.search(this._decimal);return this._decimal.lastIndex=0,-1!==n?e.split(this._decimal)[0]+t.slice(n):e}return e},getDecimalLength(e){if(e){const t=e.split(this._decimal);if(2===t.length)return t[1].replace(this._suffix,"").trim().replace(/\s/g,"").replace(this._currency,"").length}return 0},updateModel(e,t){this.d_modelValue=t,this.$emit("update:modelValue",t)},onInputFocus(e){this.focused=!0,this.$emit("focus",e)},onInputBlur(e){this.focused=!1;let t=e.target,n=this.validateValue(this.parseValue(t.value));this.$emit("blur",{originalEvent:e,value:t.value}),t.value=this.formatValue(n),t.setAttribute("aria-valuenow",n),this.updateModel(e,n)},clearTimer(){this.timer&&clearInterval(this.timer)},maxBoundry(){return this.d_modelValue>=this.max},minBoundry(){return this.d_modelValue<=this.min}},computed:{containerClass(){return["p-inputnumber p-component p-inputwrapper",this.class,{"p-inputwrapper-filled":this.filled,"p-inputwrapper-focus":this.focused,"p-inputnumber-buttons-stacked":this.showButtons&&"stacked"===this.buttonLayout,"p-inputnumber-buttons-horizontal":this.showButtons&&"horizontal"===this.buttonLayout,"p-inputnumber-buttons-vertical":this.showButtons&&"vertical"===this.buttonLayout}]},upButtonClass(){return["p-inputnumber-button p-inputnumber-button-up",this.incrementButtonClass,{"p-disabled":this.showButtons&&null!==this.max&&this.maxBoundry()}]},downButtonClass(){return["p-inputnumber-button p-inputnumber-button-down",this.decrementButtonClass,{"p-disabled":this.showButtons&&null!==this.min&&this.minBoundry()}]},filled(){return null!=this.modelValue&&this.modelValue.toString().length>0},upButtonListeners(){return{mousedown:e=>this.onUpButtonMouseDown(e),mouseup:e=>this.onUpButtonMouseUp(e),mouseleave:e=>this.onUpButtonMouseLeave(e),keydown:e=>this.onUpButtonKeyDown(e),keyup:e=>this.onUpButtonKeyUp(e)}},downButtonListeners(){return{mousedown:e=>this.onDownButtonMouseDown(e),mouseup:e=>this.onDownButtonMouseUp(e),mouseleave:e=>this.onDownButtonMouseLeave(e),keydown:e=>this.onDownButtonKeyDown(e),keyup:e=>this.onDownButtonKeyUp(e)}},formattedValue(){const e=this.modelValue||this.allowEmpty?this.modelValue:0;return this.formatValue(e)},getFormatter(){return this.numberFormat}},components:{INInputText:s.default,INButton:r.default}};const u={key:0,class:"p-inputnumber-button-group"};return function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===n&&i.firstChild?i.insertBefore(s,i.firstChild):i.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}("\n.p-inputnumber {\n display: -webkit-inline-box;\n display: -ms-inline-flexbox;\n display: inline-flex;\n}\n.p-inputnumber-button {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -webkit-box-flex: 0;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n}\n.p-inputnumber-buttons-stacked .p-button.p-inputnumber-button .p-button-label,\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button .p-button-label {\n display: none;\n}\n.p-inputnumber-buttons-stacked .p-button.p-inputnumber-button-up {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n padding: 0;\n}\n.p-inputnumber-buttons-stacked .p-inputnumber-input {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n.p-inputnumber-buttons-stacked .p-button.p-inputnumber-button-down {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n border-bottom-left-radius: 0;\n padding: 0;\n}\n.p-inputnumber-buttons-stacked .p-inputnumber-button-group {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n.p-inputnumber-buttons-stacked .p-inputnumber-button-group .p-button.p-inputnumber-button {\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n}\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-up {\n -webkit-box-ordinal-group: 4;\n -ms-flex-order: 3;\n order: 3;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n}\n.p-inputnumber-buttons-horizontal .p-inputnumber-input {\n -webkit-box-ordinal-group: 3;\n -ms-flex-order: 2;\n order: 2;\n border-radius: 0;\n}\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-down {\n -webkit-box-ordinal-group: 2;\n -ms-flex-order: 1;\n order: 1;\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n.p-inputnumber-buttons-vertical {\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n.p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-up {\n -webkit-box-ordinal-group: 2;\n -ms-flex-order: 1;\n order: 1;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n width: 100%;\n}\n.p-inputnumber-buttons-vertical .p-inputnumber-input {\n -webkit-box-ordinal-group: 3;\n -ms-flex-order: 2;\n order: 2;\n border-radius: 0;\n text-align: center;\n}\n.p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-down {\n -webkit-box-ordinal-group: 4;\n -ms-flex-order: 3;\n order: 3;\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n width: 100%;\n}\n.p-inputnumber-input {\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n}\n.p-fluid .p-inputnumber {\n width: 100%;\n}\n.p-fluid .p-inputnumber .p-inputnumber-input {\n width: 1%;\n}\n.p-fluid .p-inputnumber-buttons-vertical .p-inputnumber-input {\n width: 100%;\n}\n"),l.render=function(e,t,i,s,r,l){const a=n.resolveComponent("INInputText"),o=n.resolveComponent("INButton");return n.openBlock(),n.createElementBlock("span",{class:n.normalizeClass(l.containerClass),style:n.normalizeStyle(i.style)},[n.createVNode(a,n.mergeProps({ref:"input",class:["p-inputnumber-input",i.inputClass],style:i.inputStyle,value:l.formattedValue},e.$attrs,{"aria-valumin":i.min,"aria-valuemax":i.max,readonly:i.readonly,onInput:l.onUserInput,onKeydown:l.onInputKeyDown,onKeypress:l.onInputKeyPress,onPaste:l.onPaste,onClick:l.onInputClick,onFocus:l.onInputFocus,onBlur:l.onInputBlur}),null,16,["class","style","value","aria-valumin","aria-valuemax","readonly","onInput","onKeydown","onKeypress","onPaste","onClick","onFocus","onBlur"]),i.showButtons&&"stacked"===i.buttonLayout?(n.openBlock(),n.createElementBlock("span",u,[n.createVNode(o,n.mergeProps({class:l.upButtonClass,icon:i.incrementButtonIcon},n.toHandlers(l.upButtonListeners),{disabled:e.$attrs.disabled}),null,16,["class","icon","disabled"]),n.createVNode(o,n.mergeProps({class:l.downButtonClass,icon:i.decrementButtonIcon},n.toHandlers(l.downButtonListeners),{disabled:e.$attrs.disabled}),null,16,["class","icon","disabled"])])):n.createCommentVNode("",!0),i.showButtons&&"stacked"!==i.buttonLayout?(n.openBlock(),n.createBlock(o,n.mergeProps({key:1,class:l.upButtonClass,icon:i.incrementButtonIcon},n.toHandlers(l.upButtonListeners),{disabled:e.$attrs.disabled}),null,16,["class","icon","disabled"])):n.createCommentVNode("",!0),i.showButtons&&"stacked"!==i.buttonLayout?(n.openBlock(),n.createBlock(o,n.mergeProps({key:2,class:l.downButtonClass,icon:i.decrementButtonIcon},n.toHandlers(l.downButtonListeners),{disabled:e.$attrs.disabled}),null,16,["class","icon","disabled"])):n.createCommentVNode("",!0)],6)},l}(primevue.inputtext,primevue.button,Vue);
|
|
1
|
+
this.primevue=this.primevue||{},this.primevue.inputnumber=function(e,t,n){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(e),r=i(t),l={name:"InputNumber",inheritAttrs:!1,emits:["update:modelValue","input","focus","blur"],props:{modelValue:{type:Number,default:null},format:{type:Boolean,default:!0},showButtons:{type:Boolean,default:!1},buttonLayout:{type:String,default:"stacked"},incrementButtonClass:{type:String,default:null},decrementButtonClass:{type:String,default:null},incrementButtonIcon:{type:String,default:"pi pi-angle-up"},decrementButtonIcon:{type:String,default:"pi pi-angle-down"},locale:{type:String,default:void 0},localeMatcher:{type:String,default:void 0},mode:{type:String,default:"decimal"},prefix:{type:String,default:null},suffix:{type:String,default:null},currency:{type:String,default:void 0},currencyDisplay:{type:String,default:void 0},useGrouping:{type:Boolean,default:!0},minFractionDigits:{type:Number,default:void 0},maxFractionDigits:{type:Number,default:void 0},min:{type:Number,default:null},max:{type:Number,default:null},step:{type:Number,default:1},allowEmpty:{type:Boolean,default:!0},readonly:{type:Boolean,default:!1},style:null,class:null,inputStyle:null,inputClass:null},numberFormat:null,_numeral:null,_decimal:null,_group:null,_minusSign:null,_currency:null,_suffix:null,_prefix:null,_index:null,groupChar:"",isSpecialChar:null,prefixChar:null,suffixChar:null,timer:null,data(){return{d_modelValue:this.modelValue,focused:!1}},watch:{modelValue(e){this.d_modelValue=e},locale(e,t){this.updateConstructParser(e,t)},localeMatcher(e,t){this.updateConstructParser(e,t)},mode(e,t){this.updateConstructParser(e,t)},currency(e,t){this.updateConstructParser(e,t)},currencyDisplay(e,t){this.updateConstructParser(e,t)},useGrouping(e,t){this.updateConstructParser(e,t)},minFractionDigits(e,t){this.updateConstructParser(e,t)},maxFractionDigits(e,t){this.updateConstructParser(e,t)},suffix(e,t){this.updateConstructParser(e,t)},prefix(e,t){this.updateConstructParser(e,t)}},created(){this.constructParser()},methods:{getOptions(){return{localeMatcher:this.localeMatcher,style:this.mode,currency:this.currency,currencyDisplay:this.currencyDisplay,useGrouping:this.useGrouping,minimumFractionDigits:this.minFractionDigits,maximumFractionDigits:this.maxFractionDigits}},constructParser(){this.numberFormat=new Intl.NumberFormat(this.locale,this.getOptions());const e=[...new Intl.NumberFormat(this.locale,{useGrouping:!1}).format(9876543210)].reverse(),t=new Map(e.map(((e,t)=>[e,t])));this._numeral=new RegExp(`[${e.join("")}]`,"g"),this._group=this.getGroupingExpression(),this._minusSign=this.getMinusSignExpression(),this._currency=this.getCurrencyExpression(),this._decimal=this.getDecimalExpression(),this._suffix=this.getSuffixExpression(),this._prefix=this.getPrefixExpression(),this._index=e=>t.get(e)},updateConstructParser(e,t){e!==t&&this.constructParser()},escapeRegExp:e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),getDecimalExpression(){const e=new Intl.NumberFormat(this.locale,{...this.getOptions(),useGrouping:!1});return new RegExp(`[${e.format(1.1).replace(this._currency,"").trim().replace(this._numeral,"")}]`,"g")},getGroupingExpression(){const e=new Intl.NumberFormat(this.locale,{useGrouping:!0});return this.groupChar=e.format(1e6).trim().replace(this._numeral,"").charAt(0),new RegExp(`[${this.groupChar}]`,"g")},getMinusSignExpression(){const e=new Intl.NumberFormat(this.locale,{useGrouping:!1});return new RegExp(`[${e.format(-1).trim().replace(this._numeral,"")}]`,"g")},getCurrencyExpression(){if(this.currency){const e=new Intl.NumberFormat(this.locale,{style:"currency",currency:this.currency,currencyDisplay:this.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});return new RegExp(`[${e.format(1).replace(/\s/g,"").replace(this._numeral,"").replace(this._group,"")}]`,"g")}return new RegExp("[]","g")},getPrefixExpression(){if(this.prefix)this.prefixChar=this.prefix;else{const e=new Intl.NumberFormat(this.locale,{style:this.mode,currency:this.currency,currencyDisplay:this.currencyDisplay});this.prefixChar=e.format(1).split("1")[0]}return new RegExp(`${this.escapeRegExp(this.prefixChar||"")}`,"g")},getSuffixExpression(){if(this.suffix)this.suffixChar=this.suffix;else{const e=new Intl.NumberFormat(this.locale,{style:this.mode,currency:this.currency,currencyDisplay:this.currencyDisplay,minimumFractionDigits:0,maximumFractionDigits:0});this.suffixChar=e.format(1).split("1")[1]}return new RegExp(`${this.escapeRegExp(this.suffixChar||"")}`,"g")},formatValue(e){if(null!=e){if("-"===e)return e;if(this.format){let t=new Intl.NumberFormat(this.locale,this.getOptions()).format(e);return this.prefix&&(t=this.prefix+t),this.suffix&&(t+=this.suffix),t}return e.toString()}return""},parseValue(e){let t=e.replace(this._suffix,"").replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").replace(this._group,"").replace(this._minusSign,"-").replace(this._decimal,".").replace(this._numeral,this._index);if(t){if("-"===t)return t;let e=+t;return isNaN(e)?null:e}return null},repeat(e,t,n){if(this.readonly)return;let i=t||500;this.clearTimer(),this.timer=setTimeout((()=>{this.repeat(e,40,n)}),i),this.spin(e,n)},spin(e,t){if(this.$refs.input){let n=this.step*t,i=this.parseValue(this.$refs.input.$el.value)||0,s=this.validateValue(i+n);this.updateInput(s,null,"spin"),this.updateModel(e,s),this.handleOnInput(e,i,s)}},onUpButtonMouseDown(e){this.$attrs.disabled||(this.$refs.input.$el.focus(),this.repeat(e,null,1),e.preventDefault())},onUpButtonMouseUp(){this.$attrs.disabled||this.clearTimer()},onUpButtonMouseLeave(){this.$attrs.disabled||this.clearTimer()},onUpButtonKeyUp(){this.$attrs.disabled||this.clearTimer()},onUpButtonKeyDown(e){32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,1)},onDownButtonMouseDown(e){this.$attrs.disabled||(this.$refs.input.$el.focus(),this.repeat(e,null,-1),e.preventDefault())},onDownButtonMouseUp(){this.$attrs.disabled||this.clearTimer()},onDownButtonMouseLeave(){this.$attrs.disabled||this.clearTimer()},onDownButtonKeyUp(){this.$attrs.disabled||this.clearTimer()},onDownButtonKeyDown(e){32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,-1)},onUserInput(){this.isSpecialChar&&(this.$refs.input.$el.value=this.lastValue),this.isSpecialChar=!1},onInputKeyDown(e){if(this.readonly)return;if(this.lastValue=e.target.value,e.shiftKey||e.altKey)return void(this.isSpecialChar=!0);let t=e.target.selectionStart,n=e.target.selectionEnd,i=e.target.value,s=null;switch(e.altKey&&e.preventDefault(),e.which){case 38:this.spin(e,1),e.preventDefault();break;case 40:this.spin(e,-1),e.preventDefault();break;case 37:this.isNumeralChar(i.charAt(t-1))||e.preventDefault();break;case 39:this.isNumeralChar(i.charAt(t))||e.preventDefault();break;case 9:case 13:s=this.validateValue(this.parseValue(i)),this.$refs.input.$el.value=this.formatValue(s),this.$refs.input.$el.setAttribute("aria-valuenow",s),this.updateModel(e,s);break;case 8:if(e.preventDefault(),t===n){const n=i.charAt(t-1),{decimalCharIndex:r,decimalCharIndexWithoutPrefix:l}=this.getDecimalCharIndexes(i);if(this.isNumeralChar(n)){const e=this.getDecimalLength(i);if(this._group.test(n))this._group.lastIndex=0,s=i.slice(0,t-2)+i.slice(t-1);else if(this._decimal.test(n))this._decimal.lastIndex=0,e?this.$refs.input.$el.setSelectionRange(t-1,t-1):s=i.slice(0,t-1)+i.slice(t);else if(r>0&&t>r){const n=this.isDecimalMode()&&(this.minFractionDigits||0)<e?"":"0";s=i.slice(0,t-1)+n+i.slice(t)}else 1===l?(s=i.slice(0,t-1)+"0"+i.slice(t),s=this.parseValue(s)>0?s:""):s=i.slice(0,t-1)+i.slice(t)}this.updateValue(e,s,null,"delete-single")}else s=this.deleteRange(i,t,n),this.updateValue(e,s,null,"delete-range");break;case 46:if(e.preventDefault(),t===n){const n=i.charAt(t),{decimalCharIndex:r,decimalCharIndexWithoutPrefix:l}=this.getDecimalCharIndexes(i);if(this.isNumeralChar(n)){const e=this.getDecimalLength(i);if(this._group.test(n))this._group.lastIndex=0,s=i.slice(0,t)+i.slice(t+2);else if(this._decimal.test(n))this._decimal.lastIndex=0,e?this.$refs.input.$el.setSelectionRange(t+1,t+1):s=i.slice(0,t)+i.slice(t+1);else if(r>0&&t>r){const n=this.isDecimalMode()&&(this.minFractionDigits||0)<e?"":"0";s=i.slice(0,t)+n+i.slice(t+1)}else 1===l?(s=i.slice(0,t)+"0"+i.slice(t+1),s=this.parseValue(s)>0?s:""):s=i.slice(0,t)+i.slice(t+1)}this.updateValue(e,s,null,"delete-back-single")}else s=this.deleteRange(i,t,n),this.updateValue(e,s,null,"delete-range")}},onInputKeyPress(e){if(this.readonly)return;e.preventDefault();let t=e.which||e.keyCode,n=String.fromCharCode(t);const i=this.isDecimalSign(n),s=this.isMinusSign(n);(48<=t&&t<=57||s||i)&&this.insert(e,n,{isDecimalSign:i,isMinusSign:s})},onPaste(e){e.preventDefault();let t=(e.clipboardData||window.clipboardData).getData("Text");if(t){let n=this.parseValue(t);null!=n&&this.insert(e,n.toString())}},allowMinusSign(){return null===this.min||this.min<0},isMinusSign(e){return!(!this._minusSign.test(e)&&"-"!==e)&&(this._minusSign.lastIndex=0,!0)},isDecimalSign(e){return!!this._decimal.test(e)&&(this._decimal.lastIndex=0,!0)},isDecimalMode(){return"decimal"===this.mode},getDecimalCharIndexes(e){let t=e.search(this._decimal);this._decimal.lastIndex=0;const n=e.replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").search(this._decimal);return this._decimal.lastIndex=0,{decimalCharIndex:t,decimalCharIndexWithoutPrefix:n}},getCharIndexes(e){const t=e.search(this._decimal);this._decimal.lastIndex=0;const n=e.search(this._minusSign);this._minusSign.lastIndex=0;const i=e.search(this._suffix);this._suffix.lastIndex=0;const s=e.search(this._currency);return this._currency.lastIndex=0,{decimalCharIndex:t,minusCharIndex:n,suffixCharIndex:i,currencyCharIndex:s}},insert(e,t,n={isDecimalSign:!1,isMinusSign:!1}){const i=t.search(this._minusSign);if(this._minusSign.lastIndex=0,!this.allowMinusSign()&&-1!==i)return;const s=this.$refs.input.$el.selectionStart,r=this.$refs.input.$el.selectionEnd;let l=this.$refs.input.$el.value.trim();const{decimalCharIndex:u,minusCharIndex:a,suffixCharIndex:o,currencyCharIndex:p}=this.getCharIndexes(l);let h;if(n.isMinusSign)0===s&&(h=l,-1!==a&&0===r||(h=this.insertText(l,t,0,r)),this.updateValue(e,h,t,"insert"));else if(n.isDecimalSign)u>0&&s===u?this.updateValue(e,l,t,"insert"):(u>s&&u<r||-1===u&&this.maxFractionDigits)&&(h=this.insertText(l,t,s,r),this.updateValue(e,h,t,"insert"));else{const n=this.numberFormat.resolvedOptions().maximumFractionDigits,i=s!==r?"range-insert":"insert";if(u>0&&s>u){if(s+t.length-(u+1)<=n){const n=p>=s?p-1:o>=s?o:l.length;h=l.slice(0,s)+t+l.slice(s+t.length,n)+l.slice(n),this.updateValue(e,h,t,i)}}else h=this.insertText(l,t,s,r),this.updateValue(e,h,t,i)}},insertText(e,t,n,i){if(2===("."===t?t:t.split(".")).length){const s=e.slice(n,i).search(this._decimal);return this._decimal.lastIndex=0,s>0?e.slice(0,n)+this.formatValue(t)+e.slice(i):e||this.formatValue(t)}return i-n===e.length?this.formatValue(t):0===n?t+e.slice(i):i===e.length?e.slice(0,n)+t:e.slice(0,n)+t+e.slice(i)},deleteRange(e,t,n){let i;return i=n-t===e.length?"":0===t?e.slice(n):n===e.length?e.slice(0,t):e.slice(0,t)+e.slice(n),i},initCursor(){let e=this.$refs.input.$el.selectionStart,t=this.$refs.input.$el.value,n=t.length,i=null,s=(this.prefixChar||"").length;t=t.replace(this._prefix,""),e-=s;let r=t.charAt(e);if(this.isNumeralChar(r))return e+s;let l=e-1;for(;l>=0;){if(r=t.charAt(l),this.isNumeralChar(r)){i=l+s;break}l--}if(null!==i)this.$refs.input.$el.setSelectionRange(i+1,i+1);else{for(l=e;l<n;){if(r=t.charAt(l),this.isNumeralChar(r)){i=l+s;break}l++}null!==i&&this.$refs.input.$el.setSelectionRange(i,i)}return i||0},onInputClick(){this.readonly||this.initCursor()},isNumeralChar(e){return!(1!==e.length||!(this._numeral.test(e)||this._decimal.test(e)||this._group.test(e)||this._minusSign.test(e)))&&(this.resetRegex(),!0)},resetRegex(){this._numeral.lastIndex=0,this._decimal.lastIndex=0,this._group.lastIndex=0,this._minusSign.lastIndex=0},updateValue(e,t,n,i){let s=this.$refs.input.$el.value,r=null;null!=t&&(r=this.parseValue(t),r=r||this.allowEmpty?r:0,this.updateInput(r,n,i,t),this.handleOnInput(e,s,r))},handleOnInput(e,t,n){this.isValueChanged(t,n)&&this.$emit("input",{originalEvent:e,value:n})},isValueChanged(e,t){if(null===t&&null!==e)return!0;if(null!=t){return t!==("string"==typeof e?this.parseValue(e):e)}return!1},validateValue(e){return"-"===e||null==e?null:null!=this.min&&e<this.min?this.min:null!=this.max&&e>this.max?this.max:e},updateInput(e,t,n,i){t=t||"";let s=this.$refs.input.$el.value,r=this.formatValue(e),l=s.length;if(r!==i&&(r=this.concatValues(r,i)),0===l){this.$refs.input.$el.value=r,this.$refs.input.$el.setSelectionRange(0,0);const e=this.initCursor()+t.length;this.$refs.input.$el.setSelectionRange(e,e)}else{let e=this.$refs.input.$el.selectionStart,i=this.$refs.input.$el.selectionEnd;this.$refs.input.$el.value=r;let u=r.length;if("range-insert"===n){const n=this.parseValue((s||"").slice(0,e)),l=(null!==n?n.toString():"").split("").join(`(${this.groupChar})?`),u=new RegExp(l,"g");u.test(r);const a=t.split("").join(`(${this.groupChar})?`),o=new RegExp(a,"g");o.test(r.slice(u.lastIndex)),i=u.lastIndex+o.lastIndex,this.$refs.input.$el.setSelectionRange(i,i)}else if(u===l)"insert"===n||"delete-back-single"===n?this.$refs.input.$el.setSelectionRange(i+1,i+1):"delete-single"===n?this.$refs.input.$el.setSelectionRange(i-1,i-1):"delete-range"!==n&&"spin"!==n||this.$refs.input.$el.setSelectionRange(i,i);else if("delete-back-single"===n){let e=s.charAt(i-1),t=s.charAt(i),n=l-u,r=this._group.test(t);r&&1===n?i+=1:!r&&this.isNumeralChar(e)&&(i+=-1*n+1),this._group.lastIndex=0,this.$refs.input.$el.setSelectionRange(i,i)}else if("-"===s&&"insert"===n){this.$refs.input.$el.setSelectionRange(0,0);const e=this.initCursor()+t.length+1;this.$refs.input.$el.setSelectionRange(e,e)}else i+=u-l,this.$refs.input.$el.setSelectionRange(i,i)}this.$refs.input.$el.setAttribute("aria-valuenow",e)},concatValues(e,t){if(e&&t){let n=t.search(this._decimal);return this._decimal.lastIndex=0,-1!==n?e.split(this._decimal)[0]+t.slice(n):e}return e},getDecimalLength(e){if(e){const t=e.split(this._decimal);if(2===t.length)return t[1].replace(this._suffix,"").trim().replace(/\s/g,"").replace(this._currency,"").length}return 0},updateModel(e,t){this.d_modelValue=t,this.$emit("update:modelValue",t)},onInputFocus(e){this.focused=!0,this.$emit("focus",e)},onInputBlur(e){this.focused=!1;let t=e.target,n=this.validateValue(this.parseValue(t.value));this.$emit("blur",{originalEvent:e,value:t.value}),t.value=this.formatValue(n),t.setAttribute("aria-valuenow",n),this.updateModel(e,n)},clearTimer(){this.timer&&clearInterval(this.timer)},maxBoundry(){return this.d_modelValue>=this.max},minBoundry(){return this.d_modelValue<=this.min}},computed:{containerClass(){return["p-inputnumber p-component p-inputwrapper",this.class,{"p-inputwrapper-filled":this.filled,"p-inputwrapper-focus":this.focused,"p-inputnumber-buttons-stacked":this.showButtons&&"stacked"===this.buttonLayout,"p-inputnumber-buttons-horizontal":this.showButtons&&"horizontal"===this.buttonLayout,"p-inputnumber-buttons-vertical":this.showButtons&&"vertical"===this.buttonLayout}]},upButtonClass(){return["p-inputnumber-button p-inputnumber-button-up",this.incrementButtonClass,{"p-disabled":this.showButtons&&null!==this.max&&this.maxBoundry()}]},downButtonClass(){return["p-inputnumber-button p-inputnumber-button-down",this.decrementButtonClass,{"p-disabled":this.showButtons&&null!==this.min&&this.minBoundry()}]},filled(){return null!=this.modelValue&&this.modelValue.toString().length>0},upButtonListeners(){return{mousedown:e=>this.onUpButtonMouseDown(e),mouseup:e=>this.onUpButtonMouseUp(e),mouseleave:e=>this.onUpButtonMouseLeave(e),keydown:e=>this.onUpButtonKeyDown(e),keyup:e=>this.onUpButtonKeyUp(e)}},downButtonListeners(){return{mousedown:e=>this.onDownButtonMouseDown(e),mouseup:e=>this.onDownButtonMouseUp(e),mouseleave:e=>this.onDownButtonMouseLeave(e),keydown:e=>this.onDownButtonKeyDown(e),keyup:e=>this.onDownButtonKeyUp(e)}},formattedValue(){const e=this.modelValue||this.allowEmpty?this.modelValue:0;return this.formatValue(e)},getFormatter(){return this.numberFormat}},components:{INInputText:s.default,INButton:r.default}};const u={key:0,class:"p-inputnumber-button-group"};return function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===n&&i.firstChild?i.insertBefore(s,i.firstChild):i.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}("\n.p-inputnumber {\n display: -webkit-inline-box;\n display: -ms-inline-flexbox;\n display: inline-flex;\n}\n.p-inputnumber-button {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -webkit-box-flex: 0;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n}\n.p-inputnumber-buttons-stacked .p-button.p-inputnumber-button .p-button-label,\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button .p-button-label {\n display: none;\n}\n.p-inputnumber-buttons-stacked .p-button.p-inputnumber-button-up {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n padding: 0;\n}\n.p-inputnumber-buttons-stacked .p-inputnumber-input {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n.p-inputnumber-buttons-stacked .p-button.p-inputnumber-button-down {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n border-bottom-left-radius: 0;\n padding: 0;\n}\n.p-inputnumber-buttons-stacked .p-inputnumber-button-group {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n.p-inputnumber-buttons-stacked .p-inputnumber-button-group .p-button.p-inputnumber-button {\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n}\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-up {\n -webkit-box-ordinal-group: 4;\n -ms-flex-order: 3;\n order: 3;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n}\n.p-inputnumber-buttons-horizontal .p-inputnumber-input {\n -webkit-box-ordinal-group: 3;\n -ms-flex-order: 2;\n order: 2;\n border-radius: 0;\n}\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-down {\n -webkit-box-ordinal-group: 2;\n -ms-flex-order: 1;\n order: 1;\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n.p-inputnumber-buttons-vertical {\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n.p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-up {\n -webkit-box-ordinal-group: 2;\n -ms-flex-order: 1;\n order: 1;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n width: 100%;\n}\n.p-inputnumber-buttons-vertical .p-inputnumber-input {\n -webkit-box-ordinal-group: 3;\n -ms-flex-order: 2;\n order: 2;\n border-radius: 0;\n text-align: center;\n}\n.p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-down {\n -webkit-box-ordinal-group: 4;\n -ms-flex-order: 3;\n order: 3;\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n width: 100%;\n}\n.p-inputnumber-input {\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n}\n.p-fluid .p-inputnumber {\n width: 100%;\n}\n.p-fluid .p-inputnumber .p-inputnumber-input {\n width: 1%;\n}\n.p-fluid .p-inputnumber-buttons-vertical .p-inputnumber-input {\n width: 100%;\n}\n"),l.render=function(e,t,i,s,r,l){const a=n.resolveComponent("INInputText"),o=n.resolveComponent("INButton");return n.openBlock(),n.createElementBlock("span",{class:n.normalizeClass(l.containerClass),style:n.normalizeStyle(i.style)},[n.createVNode(a,n.mergeProps({ref:"input",class:["p-inputnumber-input",i.inputClass],style:i.inputStyle,value:l.formattedValue},e.$attrs,{"aria-valumin":i.min,"aria-valuemax":i.max,readonly:i.readonly,onInput:l.onUserInput,onKeydown:l.onInputKeyDown,onKeypress:l.onInputKeyPress,onPaste:l.onPaste,onClick:l.onInputClick,onFocus:l.onInputFocus,onBlur:l.onInputBlur}),null,16,["class","style","value","aria-valumin","aria-valuemax","readonly","onInput","onKeydown","onKeypress","onPaste","onClick","onFocus","onBlur"]),i.showButtons&&"stacked"===i.buttonLayout?(n.openBlock(),n.createElementBlock("span",u,[n.createVNode(o,n.mergeProps({class:l.upButtonClass,icon:i.incrementButtonIcon},n.toHandlers(l.upButtonListeners),{disabled:e.$attrs.disabled}),null,16,["class","icon","disabled"]),n.createVNode(o,n.mergeProps({class:l.downButtonClass,icon:i.decrementButtonIcon},n.toHandlers(l.downButtonListeners),{disabled:e.$attrs.disabled}),null,16,["class","icon","disabled"])])):n.createCommentVNode("",!0),i.showButtons&&"stacked"!==i.buttonLayout?(n.openBlock(),n.createBlock(o,n.mergeProps({key:1,class:l.upButtonClass,icon:i.incrementButtonIcon},n.toHandlers(l.upButtonListeners),{disabled:e.$attrs.disabled}),null,16,["class","icon","disabled"])):n.createCommentVNode("",!0),i.showButtons&&"stacked"!==i.buttonLayout?(n.openBlock(),n.createBlock(o,n.mergeProps({key:2,class:l.downButtonClass,icon:i.decrementButtonIcon},n.toHandlers(l.downButtonListeners),{disabled:e.$attrs.disabled}),null,16,["class","icon","disabled"])):n.createCommentVNode("",!0)],6)},l}(primevue.inputtext,primevue.button,Vue);
|
package/inputtext/InputText.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { InputHTMLAttributes } from 'vue';
|
|
2
|
-
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
|
2
|
+
import { ClassComponent, GlobalComponentConstructor, Nullable } from '../ts-helpers';
|
|
3
3
|
|
|
4
4
|
export interface InputTextProps extends InputHTMLAttributes {
|
|
5
5
|
/**
|
|
6
6
|
* Value of the component.
|
|
7
7
|
*/
|
|
8
|
-
modelValue?: string
|
|
8
|
+
modelValue?: Nullable<string>;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface InputTextSlots {
|
package/inputtext/InputText.vue
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("vue"),t={name:"InputText",emits:["update:modelValue"],props:{modelValue:null},methods:{onInput(e){this.$emit("update:modelValue",e.target.value)}},computed:{filled(){return null!=this.modelValue&&this.modelValue.toString().length>0}}};const l=["value"];t.render=function(t,u,n,o,p
|
|
1
|
+
"use strict";var e=require("vue"),t={name:"InputText",inheritAttrs:!1,emits:["update:modelValue"],props:{modelValue:null},methods:{onInput(e){this.$emit("update:modelValue",e.target.value)}},computed:{filled(){return null!=this.modelValue&&this.modelValue.toString().length>0}}};const l=["value"];t.render=function(t,u,n,o,r,p){return e.openBlock(),e.createElementBlock("input",e.mergeProps({class:["p-inputtext p-component",{"p-filled":p.filled}],value:n.modelValue,onInput:u[0]||(u[0]=(...e)=>p.onInput&&p.onInput(...e))},t.$attrs),null,16,l)},module.exports=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{openBlock as e,createElementBlock as t,mergeProps as l}from"vue";var u={name:"InputText",emits:["update:modelValue"],props:{modelValue:null},methods:{onInput(e){this.$emit("update:modelValue",e.target.value)}},computed:{filled(){return null!=this.modelValue&&this.modelValue.toString().length>0}}};const n=["value"];u.render=function(u,o,a,p,d
|
|
1
|
+
import{openBlock as e,createElementBlock as t,mergeProps as l}from"vue";var u={name:"InputText",inheritAttrs:!1,emits:["update:modelValue"],props:{modelValue:null},methods:{onInput(e){this.$emit("update:modelValue",e.target.value)}},computed:{filled(){return null!=this.modelValue&&this.modelValue.toString().length>0}}};const n=["value"];u.render=function(u,o,a,p,r,d){return e(),t("input",l({class:["p-inputtext p-component",{"p-filled":d.filled}],value:a.modelValue,onInput:o[0]||(o[0]=(...e)=>d.onInput&&d.onInput(...e))},u.$attrs),null,16,n)};export{u as default};
|
package/inputtext/inputtext.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
this.primevue=this.primevue||{},this.primevue.inputtext=function(e){"use strict";var t={name:"InputText",emits:["update:modelValue"],props:{modelValue:null},methods:{onInput(e){this.$emit("update:modelValue",e.target.value)}},computed:{filled(){return null!=this.modelValue&&this.modelValue.toString().length>0}}};const u=["value"];return t.render=function(t,l,n,o,p
|
|
1
|
+
this.primevue=this.primevue||{},this.primevue.inputtext=function(e){"use strict";var t={name:"InputText",inheritAttrs:!1,emits:["update:modelValue"],props:{modelValue:null},methods:{onInput(e){this.$emit("update:modelValue",e.target.value)}},computed:{filled(){return null!=this.modelValue&&this.modelValue.toString().length>0}}};const u=["value"];return t.render=function(t,l,n,i,o,p){return e.openBlock(),e.createElementBlock("input",e.mergeProps({class:["p-inputtext p-component",{"p-filled":p.filled}],value:n.modelValue,onInput:l[0]||(l[0]=(...e)=>p.onInput&&p.onInput(...e))},t.$attrs),null,16,u)},t}(Vue);
|
package/menu/Menu.d.ts
CHANGED
package/menu/Menu.vue
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<Portal :appendTo="appendTo" :disabled="!popup">
|
|
3
3
|
<transition name="p-connected-overlay" @enter="onEnter" @leave="onLeave" @after-leave="onAfterLeave">
|
|
4
4
|
<div :ref="containerRef" :class="containerClass" v-if="popup ? overlayVisible : true" v-bind="$attrs" @click="onOverlayClick">
|
|
5
5
|
<ul class="p-menu-list p-reset" role="menu">
|
|
@@ -19,13 +19,14 @@
|
|
|
19
19
|
</ul>
|
|
20
20
|
</div>
|
|
21
21
|
</transition>
|
|
22
|
-
</
|
|
22
|
+
</Portal>
|
|
23
23
|
</template>
|
|
24
24
|
|
|
25
25
|
<script>
|
|
26
26
|
import {ConnectedOverlayScrollHandler,DomHandler,ZIndexUtils} from 'primevue/utils';
|
|
27
27
|
import OverlayEventBus from 'primevue/overlayeventbus';
|
|
28
28
|
import Menuitem from './Menuitem.vue';
|
|
29
|
+
import Portal from 'primevue/portal';
|
|
29
30
|
|
|
30
31
|
export default {
|
|
31
32
|
name: 'Menu',
|
|
@@ -175,7 +176,7 @@ export default {
|
|
|
175
176
|
bindResizeListener() {
|
|
176
177
|
if (!this.resizeListener) {
|
|
177
178
|
this.resizeListener = () => {
|
|
178
|
-
if (this.overlayVisible) {
|
|
179
|
+
if (this.overlayVisible && !DomHandler.isTouchDevice()) {
|
|
179
180
|
this.hide();
|
|
180
181
|
}
|
|
181
182
|
};
|
|
@@ -220,7 +221,8 @@ export default {
|
|
|
220
221
|
}
|
|
221
222
|
},
|
|
222
223
|
components: {
|
|
223
|
-
'Menuitem': Menuitem
|
|
224
|
+
'Menuitem': Menuitem,
|
|
225
|
+
'Portal': Portal
|
|
224
226
|
}
|
|
225
227
|
}
|
|
226
228
|
</script>
|
package/menu/menu.cjs.js
CHANGED
|
@@ -4,11 +4,13 @@ var utils = require('primevue/utils');
|
|
|
4
4
|
var OverlayEventBus = require('primevue/overlayeventbus');
|
|
5
5
|
var Ripple = require('primevue/ripple');
|
|
6
6
|
var vue = require('vue');
|
|
7
|
+
var Portal = require('primevue/portal');
|
|
7
8
|
|
|
8
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
10
|
|
|
10
11
|
var OverlayEventBus__default = /*#__PURE__*/_interopDefaultLegacy(OverlayEventBus);
|
|
11
12
|
var Ripple__default = /*#__PURE__*/_interopDefaultLegacy(Ripple);
|
|
13
|
+
var Portal__default = /*#__PURE__*/_interopDefaultLegacy(Portal);
|
|
12
14
|
|
|
13
15
|
var script$1 = {
|
|
14
16
|
name: 'Menuitem',
|
|
@@ -270,7 +272,7 @@ var script = {
|
|
|
270
272
|
bindResizeListener() {
|
|
271
273
|
if (!this.resizeListener) {
|
|
272
274
|
this.resizeListener = () => {
|
|
273
|
-
if (this.overlayVisible) {
|
|
275
|
+
if (this.overlayVisible && !utils.DomHandler.isTouchDevice()) {
|
|
274
276
|
this.hide();
|
|
275
277
|
}
|
|
276
278
|
};
|
|
@@ -315,7 +317,8 @@ var script = {
|
|
|
315
317
|
}
|
|
316
318
|
},
|
|
317
319
|
components: {
|
|
318
|
-
'Menuitem': script$1
|
|
320
|
+
'Menuitem': script$1,
|
|
321
|
+
'Portal': Portal__default["default"]
|
|
319
322
|
}
|
|
320
323
|
};
|
|
321
324
|
|
|
@@ -330,86 +333,90 @@ const _hoisted_2 = {
|
|
|
330
333
|
|
|
331
334
|
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
332
335
|
const _component_Menuitem = vue.resolveComponent("Menuitem");
|
|
336
|
+
const _component_Portal = vue.resolveComponent("Portal");
|
|
333
337
|
|
|
334
|
-
return (vue.openBlock(), vue.createBlock(
|
|
335
|
-
|
|
338
|
+
return (vue.openBlock(), vue.createBlock(_component_Portal, {
|
|
339
|
+
appendTo: $props.appendTo,
|
|
336
340
|
disabled: !$props.popup
|
|
337
|
-
},
|
|
338
|
-
vue.
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
vue.
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
341
|
+
}, {
|
|
342
|
+
default: vue.withCtx(() => [
|
|
343
|
+
vue.createVNode(vue.Transition, {
|
|
344
|
+
name: "p-connected-overlay",
|
|
345
|
+
onEnter: $options.onEnter,
|
|
346
|
+
onLeave: $options.onLeave,
|
|
347
|
+
onAfterLeave: $options.onAfterLeave
|
|
348
|
+
}, {
|
|
349
|
+
default: vue.withCtx(() => [
|
|
350
|
+
($props.popup ? $data.overlayVisible : true)
|
|
351
|
+
? (vue.openBlock(), vue.createElementBlock("div", vue.mergeProps({
|
|
352
|
+
key: 0,
|
|
353
|
+
ref: $options.containerRef,
|
|
354
|
+
class: $options.containerClass
|
|
355
|
+
}, _ctx.$attrs, {
|
|
356
|
+
onClick: _cache[0] || (_cache[0] = (...args) => ($options.onOverlayClick && $options.onOverlayClick(...args)))
|
|
357
|
+
}), [
|
|
358
|
+
vue.createElementVNode("ul", _hoisted_1, [
|
|
359
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList($props.model, (item, i) => {
|
|
360
|
+
return (vue.openBlock(), vue.createElementBlock(vue.Fragment, {
|
|
361
|
+
key: $options.label(item) + i.toString()
|
|
362
|
+
}, [
|
|
363
|
+
(item.items && $options.visible(item) && !item.separator)
|
|
364
|
+
? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
|
|
365
|
+
(item.items)
|
|
366
|
+
? (vue.openBlock(), vue.createElementBlock("li", _hoisted_2, [
|
|
367
|
+
vue.renderSlot(_ctx.$slots, "item", { item: item }, () => [
|
|
368
|
+
vue.createTextVNode(vue.toDisplayString($options.label(item)), 1)
|
|
369
|
+
])
|
|
370
|
+
]))
|
|
371
|
+
: vue.createCommentVNode("", true),
|
|
372
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(item.items, (child, j) => {
|
|
373
|
+
return (vue.openBlock(), vue.createElementBlock(vue.Fragment, {
|
|
374
|
+
key: child.label + i + j
|
|
375
|
+
}, [
|
|
376
|
+
($options.visible(child) && !child.separator)
|
|
377
|
+
? (vue.openBlock(), vue.createBlock(_component_Menuitem, {
|
|
378
|
+
key: 0,
|
|
379
|
+
item: child,
|
|
380
|
+
onClick: $options.itemClick,
|
|
381
|
+
template: _ctx.$slots.item,
|
|
382
|
+
exact: $props.exact
|
|
383
|
+
}, null, 8, ["item", "onClick", "template", "exact"]))
|
|
384
|
+
: ($options.visible(child) && child.separator)
|
|
385
|
+
? (vue.openBlock(), vue.createElementBlock("li", {
|
|
386
|
+
class: vue.normalizeClass(['p-menu-separator', child.class]),
|
|
387
|
+
style: vue.normalizeStyle(child.style),
|
|
388
|
+
key: 'separator' + i + j,
|
|
389
|
+
role: "separator"
|
|
390
|
+
}, null, 6))
|
|
391
|
+
: vue.createCommentVNode("", true)
|
|
392
|
+
], 64))
|
|
393
|
+
}), 128))
|
|
394
|
+
], 64))
|
|
395
|
+
: ($options.visible(item) && item.separator)
|
|
396
|
+
? (vue.openBlock(), vue.createElementBlock("li", {
|
|
397
|
+
class: vue.normalizeClass(['p-menu-separator', item.class]),
|
|
398
|
+
style: vue.normalizeStyle(item.style),
|
|
399
|
+
key: 'separator' + i.toString(),
|
|
400
|
+
role: "separator"
|
|
401
|
+
}, null, 6))
|
|
402
|
+
: (vue.openBlock(), vue.createBlock(_component_Menuitem, {
|
|
403
|
+
key: $options.label(item) + i.toString(),
|
|
404
|
+
item: item,
|
|
405
|
+
onClick: $options.itemClick,
|
|
406
|
+
template: _ctx.$slots.item,
|
|
407
|
+
exact: $props.exact
|
|
408
|
+
}, null, 8, ["item", "onClick", "template", "exact"]))
|
|
409
|
+
], 64))
|
|
410
|
+
}), 128))
|
|
411
|
+
])
|
|
412
|
+
], 16))
|
|
413
|
+
: vue.createCommentVNode("", true)
|
|
414
|
+
]),
|
|
415
|
+
_: 3
|
|
416
|
+
}, 8, ["onEnter", "onLeave", "onAfterLeave"])
|
|
417
|
+
]),
|
|
418
|
+
_: 3
|
|
419
|
+
}, 8, ["appendTo", "disabled"]))
|
|
413
420
|
}
|
|
414
421
|
|
|
415
422
|
function styleInject(css, ref) {
|