primevue 3.24.0 → 3.26.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.
Files changed (212) hide show
  1. package/README.md +64 -176
  2. package/api/Api.d.ts +284 -292
  3. package/autocomplete/AutoComplete.d.ts +5 -5
  4. package/autocomplete/AutoComplete.vue +5 -5
  5. package/autocomplete/autocomplete.cjs.js +5 -5
  6. package/autocomplete/autocomplete.cjs.min.js +1 -1
  7. package/autocomplete/autocomplete.esm.js +5 -5
  8. package/autocomplete/autocomplete.esm.min.js +1 -1
  9. package/autocomplete/autocomplete.js +5 -5
  10. package/autocomplete/autocomplete.min.js +1 -1
  11. package/blockui/BlockUI.d.ts +2 -0
  12. package/calendar/Calendar.d.ts +4 -4
  13. package/calendar/Calendar.vue +71 -17
  14. package/calendar/calendar.cjs.js +58 -20
  15. package/calendar/calendar.cjs.min.js +1 -1
  16. package/calendar/calendar.esm.js +58 -20
  17. package/calendar/calendar.esm.min.js +1 -1
  18. package/calendar/calendar.js +58 -20
  19. package/calendar/calendar.min.js +1 -1
  20. package/cascadeselect/CascadeSelect.d.ts +4 -4
  21. package/cascadeselect/CascadeSelect.vue +4 -4
  22. package/cascadeselect/cascadeselect.cjs.js +4 -4
  23. package/cascadeselect/cascadeselect.cjs.min.js +1 -1
  24. package/cascadeselect/cascadeselect.esm.js +4 -4
  25. package/cascadeselect/cascadeselect.esm.min.js +1 -1
  26. package/cascadeselect/cascadeselect.js +4 -4
  27. package/cascadeselect/cascadeselect.min.js +1 -1
  28. package/checkbox/Checkbox.d.ts +2 -2
  29. package/checkbox/Checkbox.vue +2 -2
  30. package/checkbox/checkbox.cjs.js +2 -2
  31. package/checkbox/checkbox.cjs.min.js +1 -1
  32. package/checkbox/checkbox.esm.js +2 -2
  33. package/checkbox/checkbox.esm.min.js +1 -1
  34. package/checkbox/checkbox.js +2 -2
  35. package/checkbox/checkbox.min.js +1 -1
  36. package/chips/Chips.d.ts +4 -3
  37. package/chips/Chips.vue +2 -2
  38. package/chips/chips.cjs.js +2 -2
  39. package/chips/chips.cjs.min.js +1 -1
  40. package/chips/chips.esm.js +2 -2
  41. package/chips/chips.esm.min.js +1 -1
  42. package/chips/chips.js +2 -2
  43. package/chips/chips.min.js +1 -1
  44. package/column/Column.d.ts +9 -0
  45. package/confirmationoptions/ConfirmationOptions.d.ts +1 -0
  46. package/confirmdialog/ConfirmDialog.d.ts +5 -0
  47. package/confirmdialog/ConfirmDialog.vue +17 -1
  48. package/confirmdialog/confirmdialog.cjs.js +7 -2
  49. package/confirmdialog/confirmdialog.cjs.min.js +1 -1
  50. package/confirmdialog/confirmdialog.esm.js +7 -2
  51. package/confirmdialog/confirmdialog.esm.min.js +1 -1
  52. package/confirmdialog/confirmdialog.js +7 -2
  53. package/confirmdialog/confirmdialog.min.js +1 -1
  54. package/confirmpopup/ConfirmPopup.vue +3 -0
  55. package/confirmpopup/confirmpopup.cjs.js +3 -0
  56. package/confirmpopup/confirmpopup.cjs.min.js +1 -1
  57. package/confirmpopup/confirmpopup.esm.js +3 -0
  58. package/confirmpopup/confirmpopup.esm.min.js +1 -1
  59. package/confirmpopup/confirmpopup.js +3 -0
  60. package/confirmpopup/confirmpopup.min.js +1 -1
  61. package/core/core.js +22 -15
  62. package/core/core.min.js +4 -4
  63. package/datatable/DataTable.d.ts +9 -9
  64. package/datatable/FooterCell.vue +2 -2
  65. package/datatable/TableBody.vue +6 -1
  66. package/datatable/datatable.cjs.js +8 -3
  67. package/datatable/datatable.cjs.min.js +1 -1
  68. package/datatable/datatable.esm.js +8 -3
  69. package/datatable/datatable.esm.min.js +1 -1
  70. package/datatable/datatable.js +8 -3
  71. package/datatable/datatable.min.js +1 -1
  72. package/dialog/Dialog.vue +24 -7
  73. package/dialog/dialog.cjs.js +14 -7
  74. package/dialog/dialog.cjs.min.js +1 -1
  75. package/dialog/dialog.esm.js +14 -7
  76. package/dialog/dialog.esm.min.js +1 -1
  77. package/dialog/dialog.js +14 -7
  78. package/dialog/dialog.min.js +1 -1
  79. package/dropdown/Dropdown.d.ts +10 -4
  80. package/dropdown/Dropdown.vue +5 -5
  81. package/dropdown/dropdown.cjs.js +5 -5
  82. package/dropdown/dropdown.cjs.min.js +1 -1
  83. package/dropdown/dropdown.esm.js +5 -5
  84. package/dropdown/dropdown.esm.min.js +1 -1
  85. package/dropdown/dropdown.js +5 -5
  86. package/dropdown/dropdown.min.js +1 -1
  87. package/dynamicdialog/DynamicDialog.vue +1 -1
  88. package/dynamicdialog/dynamicdialog.cjs.js +1 -1
  89. package/dynamicdialog/dynamicdialog.cjs.min.js +1 -1
  90. package/dynamicdialog/dynamicdialog.esm.js +2 -2
  91. package/dynamicdialog/dynamicdialog.esm.min.js +1 -1
  92. package/dynamicdialog/dynamicdialog.js +1 -1
  93. package/dynamicdialog/dynamicdialog.min.js +1 -1
  94. package/editor/Editor.d.ts +1 -0
  95. package/inplace/Inplace.vue +5 -1
  96. package/inplace/inplace.cjs.js +10 -2
  97. package/inplace/inplace.cjs.min.js +1 -1
  98. package/inplace/inplace.esm.js +10 -3
  99. package/inplace/inplace.esm.min.js +1 -1
  100. package/inplace/inplace.js +11 -4
  101. package/inplace/inplace.min.js +1 -1
  102. package/inputmask/InputMask.vue +59 -49
  103. package/inputmask/inputmask.cjs.js +59 -49
  104. package/inputmask/inputmask.cjs.min.js +1 -1
  105. package/inputmask/inputmask.esm.js +59 -49
  106. package/inputmask/inputmask.esm.min.js +1 -1
  107. package/inputmask/inputmask.js +59 -49
  108. package/inputmask/inputmask.min.js +1 -1
  109. package/inputnumber/InputNumber.d.ts +2 -2
  110. package/inputnumber/InputNumber.vue +2 -2
  111. package/inputnumber/inputnumber.cjs.js +2 -2
  112. package/inputnumber/inputnumber.cjs.min.js +1 -1
  113. package/inputnumber/inputnumber.esm.js +2 -2
  114. package/inputnumber/inputnumber.esm.min.js +1 -1
  115. package/inputnumber/inputnumber.js +2 -2
  116. package/inputnumber/inputnumber.min.js +1 -1
  117. package/inputswitch/InputSwitch.d.ts +3 -2
  118. package/inputswitch/InputSwitch.vue +2 -2
  119. package/inputswitch/inputswitch.cjs.js +2 -2
  120. package/inputswitch/inputswitch.cjs.min.js +1 -1
  121. package/inputswitch/inputswitch.esm.js +2 -2
  122. package/inputswitch/inputswitch.esm.min.js +1 -1
  123. package/inputswitch/inputswitch.js +2 -2
  124. package/inputswitch/inputswitch.min.js +1 -1
  125. package/menuitem/MenuItem.d.ts +1 -1
  126. package/organizationchart/OrganizationChart.d.ts +3 -2
  127. package/package.json +1 -1
  128. package/panel/Panel.d.ts +4 -2
  129. package/password/Password.d.ts +4 -4
  130. package/password/Password.vue +4 -4
  131. package/password/password.cjs.js +4 -4
  132. package/password/password.cjs.min.js +1 -1
  133. package/password/password.esm.js +4 -4
  134. package/password/password.esm.min.js +1 -1
  135. package/password/password.js +4 -4
  136. package/password/password.min.js +1 -1
  137. package/portal/Portal.d.ts +1 -0
  138. package/radiobutton/RadioButton.d.ts +3 -2
  139. package/radiobutton/RadioButton.vue +2 -2
  140. package/radiobutton/radiobutton.cjs.js +2 -2
  141. package/radiobutton/radiobutton.cjs.min.js +1 -1
  142. package/radiobutton/radiobutton.esm.js +2 -2
  143. package/radiobutton/radiobutton.esm.min.js +1 -1
  144. package/radiobutton/radiobutton.js +2 -2
  145. package/radiobutton/radiobutton.min.js +1 -1
  146. package/row/Row.d.ts +1 -1
  147. package/selectbutton/SelectButton.d.ts +1 -1
  148. package/selectbutton/SelectButton.vue +2 -2
  149. package/selectbutton/selectbutton.cjs.js +2 -2
  150. package/selectbutton/selectbutton.cjs.min.js +1 -1
  151. package/selectbutton/selectbutton.esm.js +2 -2
  152. package/selectbutton/selectbutton.esm.min.js +1 -1
  153. package/selectbutton/selectbutton.js +2 -2
  154. package/selectbutton/selectbutton.min.js +1 -1
  155. package/slider/Slider.vue +3 -14
  156. package/slider/slider.cjs.js +3 -14
  157. package/slider/slider.cjs.min.js +1 -1
  158. package/slider/slider.esm.js +3 -14
  159. package/slider/slider.esm.min.js +1 -1
  160. package/slider/slider.js +3 -14
  161. package/slider/slider.min.js +1 -1
  162. package/splitbutton/SplitButton.vue +4 -2
  163. package/splitbutton/splitbutton.cjs.js +6 -4
  164. package/splitbutton/splitbutton.cjs.min.js +1 -1
  165. package/splitbutton/splitbutton.esm.js +6 -4
  166. package/splitbutton/splitbutton.esm.min.js +1 -1
  167. package/splitbutton/splitbutton.js +6 -4
  168. package/splitbutton/splitbutton.min.js +1 -1
  169. package/textarea/Textarea.d.ts +1 -0
  170. package/tieredmenu/TieredMenu.d.ts +2 -0
  171. package/toast/Toast.d.ts +0 -1
  172. package/togglebutton/ToggleButton.d.ts +2 -2
  173. package/togglebutton/ToggleButton.vue +2 -2
  174. package/togglebutton/togglebutton.cjs.js +2 -2
  175. package/togglebutton/togglebutton.cjs.min.js +1 -1
  176. package/togglebutton/togglebutton.esm.js +2 -2
  177. package/togglebutton/togglebutton.esm.min.js +1 -1
  178. package/togglebutton/togglebutton.js +2 -2
  179. package/togglebutton/togglebutton.min.js +1 -1
  180. package/tooltip/tooltip.cjs.js +1 -1
  181. package/tooltip/tooltip.cjs.min.js +1 -1
  182. package/tooltip/tooltip.esm.js +1 -1
  183. package/tooltip/tooltip.esm.min.js +1 -1
  184. package/tooltip/tooltip.js +1 -1
  185. package/tooltip/tooltip.min.js +1 -1
  186. package/tree/Tree.d.ts +3 -0
  187. package/treeselect/TreeSelect.d.ts +2 -2
  188. package/treeselect/TreeSelect.vue +3 -3
  189. package/treeselect/treeselect.cjs.js +3 -3
  190. package/treeselect/treeselect.cjs.min.js +1 -1
  191. package/treeselect/treeselect.esm.js +3 -3
  192. package/treeselect/treeselect.esm.min.js +1 -1
  193. package/treeselect/treeselect.js +3 -3
  194. package/treeselect/treeselect.min.js +1 -1
  195. package/treetable/TreeTable.d.ts +2 -0
  196. package/treetable/TreeTable.vue +3 -3
  197. package/treetable/treetable.cjs.js +3 -3
  198. package/treetable/treetable.cjs.min.js +1 -1
  199. package/treetable/treetable.esm.js +3 -3
  200. package/treetable/treetable.esm.min.js +1 -1
  201. package/treetable/treetable.js +3 -3
  202. package/treetable/treetable.min.js +1 -1
  203. package/tristatecheckbox/TriStateCheckbox.vue +1 -1
  204. package/tristatecheckbox/tristatecheckbox.cjs.js +1 -1
  205. package/tristatecheckbox/tristatecheckbox.cjs.min.js +1 -1
  206. package/tristatecheckbox/tristatecheckbox.esm.js +1 -1
  207. package/tristatecheckbox/tristatecheckbox.esm.min.js +1 -1
  208. package/tristatecheckbox/tristatecheckbox.js +1 -1
  209. package/tristatecheckbox/tristatecheckbox.min.js +1 -1
  210. package/vetur-attributes.json +32 -28
  211. package/vetur-tags.json +2 -1
  212. package/web-types.json +40 -30
@@ -27,57 +27,15 @@ var script = {
27
27
  default: false
28
28
  }
29
29
  },
30
- mounted() {
31
- this.tests = [];
32
- this.partialPosition = this.mask.length;
33
- this.len = this.mask.length;
34
- this.firstNonMaskPos = null;
35
- this.defs = {
36
- 9: '[0-9]',
37
- a: '[A-Za-z]',
38
- '*': '[A-Za-z0-9]'
39
- };
40
-
41
- let ua = DomHandler.getUserAgent();
42
-
43
- this.androidChrome = /chrome/i.test(ua) && /android/i.test(ua);
44
-
45
- let maskTokens = this.mask.split('');
46
-
47
- for (let i = 0; i < maskTokens.length; i++) {
48
- let c = maskTokens[i];
49
-
50
- if (c === '?') {
51
- this.len--;
52
- this.partialPosition = i;
53
- } else if (this.defs[c]) {
54
- this.tests.push(new RegExp(this.defs[c]));
55
-
56
- if (this.firstNonMaskPos === null) {
57
- this.firstNonMaskPos = this.tests.length - 1;
58
- }
59
-
60
- if (i < this.partialPosition) {
61
- this.lastRequiredNonMaskPos = this.tests.length - 1;
62
- }
63
- } else {
64
- this.tests.push(null);
65
- }
66
- }
67
-
68
- this.buffer = [];
69
-
70
- for (let i = 0; i < maskTokens.length; i++) {
71
- let c = maskTokens[i];
72
-
73
- if (c !== '?') {
74
- if (this.defs[c]) this.buffer.push(this.getPlaceholder(i));
75
- else this.buffer.push(c);
30
+ watch: {
31
+ mask(newMask, oldMask) {
32
+ if (oldMask !== newMask) {
33
+ this.initMask();
76
34
  }
77
35
  }
78
-
79
- this.defaultBuffer = this.buffer.join('');
80
- this.updateValue(false);
36
+ },
37
+ mounted() {
38
+ this.initMask();
81
39
  },
82
40
  updated() {
83
41
  if (this.isValueUpdated()) {
@@ -496,6 +454,58 @@ var script = {
496
454
  this.focusText = this.$el.value;
497
455
  }
498
456
  },
457
+ initMask() {
458
+ this.tests = [];
459
+ this.partialPosition = this.mask.length;
460
+ this.len = this.mask.length;
461
+ this.firstNonMaskPos = null;
462
+ this.defs = {
463
+ 9: '[0-9]',
464
+ a: '[A-Za-z]',
465
+ '*': '[A-Za-z0-9]'
466
+ };
467
+
468
+ let ua = DomHandler.getUserAgent();
469
+
470
+ this.androidChrome = /chrome/i.test(ua) && /android/i.test(ua);
471
+
472
+ let maskTokens = this.mask.split('');
473
+
474
+ for (let i = 0; i < maskTokens.length; i++) {
475
+ let c = maskTokens[i];
476
+
477
+ if (c === '?') {
478
+ this.len--;
479
+ this.partialPosition = i;
480
+ } else if (this.defs[c]) {
481
+ this.tests.push(new RegExp(this.defs[c]));
482
+
483
+ if (this.firstNonMaskPos === null) {
484
+ this.firstNonMaskPos = this.tests.length - 1;
485
+ }
486
+
487
+ if (i < this.partialPosition) {
488
+ this.lastRequiredNonMaskPos = this.tests.length - 1;
489
+ }
490
+ } else {
491
+ this.tests.push(null);
492
+ }
493
+ }
494
+
495
+ this.buffer = [];
496
+
497
+ for (let i = 0; i < maskTokens.length; i++) {
498
+ let c = maskTokens[i];
499
+
500
+ if (c !== '?') {
501
+ if (this.defs[c]) this.buffer.push(this.getPlaceholder(i));
502
+ else this.buffer.push(c);
503
+ }
504
+ }
505
+
506
+ this.defaultBuffer = this.buffer.join('');
507
+ this.updateValue(false);
508
+ },
499
509
  isValueUpdated() {
500
510
  return this.unmask ? this.modelValue != this.getUnmaskedValue() : this.defaultBuffer !== this.$el.value && this.$el.value !== this.modelValue;
501
511
  }
@@ -1 +1 @@
1
- import{DomHandler as e}from"primevue/utils";import{openBlock as t,createElementBlock as s,normalizeClass as i}from"vue";var h={name:"InputMask",emits:["update:modelValue","focus","blur","keydown","complete","keypress","paste"],props:{modelValue:null,slotChar:{type:String,default:"_"},mask:{type:String,default:null},autoClear:{type:Boolean,default:!0},unmask:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1}},mounted(){this.tests=[],this.partialPosition=this.mask.length,this.len=this.mask.length,this.firstNonMaskPos=null,this.defs={9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"};let t=e.getUserAgent();this.androidChrome=/chrome/i.test(t)&&/android/i.test(t);let s=this.mask.split("");for(let e=0;e<s.length;e++){let t=s[e];"?"===t?(this.len--,this.partialPosition=e):this.defs[t]?(this.tests.push(new RegExp(this.defs[t])),null===this.firstNonMaskPos&&(this.firstNonMaskPos=this.tests.length-1),e<this.partialPosition&&(this.lastRequiredNonMaskPos=this.tests.length-1)):this.tests.push(null)}this.buffer=[];for(let e=0;e<s.length;e++){let t=s[e];"?"!==t&&(this.defs[t]?this.buffer.push(this.getPlaceholder(e)):this.buffer.push(t))}this.defaultBuffer=this.buffer.join(""),this.updateValue(!1)},updated(){this.isValueUpdated()&&this.updateValue()},methods:{onInput(e){this.androidChrome?this.handleAndroidInput(e):this.handleInputChange(e),this.$emit("update:modelValue",e.target.value)},onFocus(e){if(this.readonly)return;let t;this.focus=!0,clearTimeout(this.caretTimeoutId),this.focusText=this.$el.value,t=this.checkVal(),this.caretTimeoutId=setTimeout((()=>{this.$el===document.activeElement&&(this.writeBuffer(),t===this.mask.replace("?","").length?this.caret(0,t):this.caret(t))}),10),this.$emit("focus",e)},onBlur(e){if(this.focus=!1,this.checkVal(),this.updateModel(e),this.$el.value!==this.focusText){let e=document.createEvent("HTMLEvents");e.initEvent("change",!0,!1),this.$el.dispatchEvent(e)}this.$emit("blur",e)},onKeyDown(t){if(this.readonly)return;let s,i,h,l=t.which||t.keyCode,a=/iphone/i.test(e.getUserAgent());this.oldVal=this.$el.value,8===l||46===l||a&&127===l?(s=this.caret(),i=s.begin,h=s.end,h-i==0&&(i=46!==l?this.seekPrev(i):h=this.seekNext(i-1),h=46===l?this.seekNext(h):h),this.clearBuffer(i,h),this.shiftL(i,h-1),this.updateModel(t),t.preventDefault()):13===l?(this.$el.blur(),this.updateModel(t)):27===l&&(this.$el.value=this.focusText,this.caret(0,this.checkVal()),this.updateModel(t),t.preventDefault()),this.$emit("keydown",t)},onKeyPress(t){if(!this.readonly){var s,i,h,l,a=t.which||t.keyCode,n=this.caret();if(!(t.ctrlKey||t.altKey||t.metaKey||a<32)){if(a&&13!==a){if(n.end-n.begin!=0&&(this.clearBuffer(n.begin,n.end),this.shiftL(n.begin,n.end-1)),(s=this.seekNext(n.begin-1))<this.len&&(i=String.fromCharCode(a),this.tests[s].test(i))){if(this.shiftR(s),this.buffer[s]=i,this.writeBuffer(),h=this.seekNext(s),/android/i.test(e.getUserAgent())){setTimeout((()=>{this.caret(h)}),0)}else this.caret(h);n.begin<=this.lastRequiredNonMaskPos&&(l=this.isCompleted())}t.preventDefault()}this.updateModel(t),l&&this.$emit("complete",t),this.$emit("keypress",t)}}},onPaste(e){this.handleInputChange(e),this.$emit("paste",e)},caret(e,t){let s,i,h;if(this.$el.offsetParent&&this.$el===document.activeElement)return"number"!=typeof e?(this.$el.setSelectionRange?(i=this.$el.selectionStart,h=this.$el.selectionEnd):document.selection&&document.selection.createRange&&(s=document.selection.createRange(),i=0-s.duplicate().moveStart("character",-1e5),h=i+s.text.length),{begin:i,end:h}):(i=e,h="number"==typeof t?t:i,void(this.$el.setSelectionRange?this.$el.setSelectionRange(i,h):this.$el.createTextRange&&(s=this.$el.createTextRange(),s.collapse(!0),s.moveEnd("character",h),s.moveStart("character",i),s.select())))},isCompleted(){for(let e=this.firstNonMaskPos;e<=this.lastRequiredNonMaskPos;e++)if(this.tests[e]&&this.buffer[e]===this.getPlaceholder(e))return!1;return!0},getPlaceholder(e){return e<this.slotChar.length?this.slotChar.charAt(e):this.slotChar.charAt(0)},seekNext(e){for(;++e<this.len&&!this.tests[e];);return e},seekPrev(e){for(;--e>=0&&!this.tests[e];);return e},shiftL(e,t){let s,i;if(!(e<0)){for(s=e,i=this.seekNext(t);s<this.len;s++)if(this.tests[s]){if(!(i<this.len&&this.tests[s].test(this.buffer[i])))break;this.buffer[s]=this.buffer[i],this.buffer[i]=this.getPlaceholder(i),i=this.seekNext(i)}this.writeBuffer(),this.caret(Math.max(this.firstNonMaskPos,e))}},shiftR(e){let t,s,i,h;for(t=e,s=this.getPlaceholder(e);t<this.len;t++)if(this.tests[t]){if(i=this.seekNext(t),h=this.buffer[t],this.buffer[t]=s,!(i<this.len&&this.tests[i].test(h)))break;s=h}},handleAndroidInput(e){var t=this.$el.value,s=this.caret();if(this.oldVal&&this.oldVal.length&&this.oldVal.length>t.length){for(this.checkVal(!0);s.begin>0&&!this.tests[s.begin-1];)s.begin--;if(0===s.begin)for(;s.begin<this.firstNonMaskPos&&!this.tests[s.begin];)s.begin++;this.caret(s.begin,s.begin)}else{for(this.checkVal(!0);s.begin<this.len&&!this.tests[s.begin];)s.begin++;this.caret(s.begin,s.begin)}this.isCompleted()&&this.$emit("complete",e)},clearBuffer(e,t){let s;for(s=e;s<t&&s<this.len;s++)this.tests[s]&&(this.buffer[s]=this.getPlaceholder(s))},writeBuffer(){this.$el.value=this.buffer.join("")},checkVal(e){this.isValueChecked=!0;let t,s,i,h=this.$el.value,l=-1;for(t=0,i=0;t<this.len;t++)if(this.tests[t]){for(this.buffer[t]=this.getPlaceholder(t);i++<h.length;)if(s=h.charAt(i-1),this.tests[t].test(s)){this.buffer[t]=s,l=t;break}if(i>h.length){this.clearBuffer(t+1,this.len);break}}else this.buffer[t]===h.charAt(i)&&i++,t<this.partialPosition&&(l=t);return e?this.writeBuffer():l+1<this.partialPosition?this.autoClear||this.buffer.join("")===this.defaultBuffer?(this.$el.value&&(this.$el.value=""),this.clearBuffer(0,this.len)):this.writeBuffer():(this.writeBuffer(),this.$el.value=this.$el.value.substring(0,l+1)),this.partialPosition?t:this.firstNonMaskPos},handleInputChange(e){if(!this.readonly){var t=this.checkVal(!0);this.caret(t),this.updateModel(e),this.isCompleted()&&this.$emit("complete",e)}},getUnmaskedValue(){let e=[];for(let t=0;t<this.buffer.length;t++){let s=this.buffer[t];this.tests[t]&&s!==this.getPlaceholder(t)&&e.push(s)}return e.join("")},updateModel(e){let t=this.unmask?this.getUnmaskedValue():e.target.value;this.$emit("update:modelValue",this.defaultBuffer!==t?t:"")},updateValue(e=!0){this.$el&&(null==this.modelValue?(this.$el.value="",e&&this.$emit("update:modelValue","")):(this.$el.value=this.modelValue,this.checkVal(),setTimeout((()=>{if(this.$el&&(this.writeBuffer(),this.checkVal(),e)){let e=this.unmask?this.getUnmaskedValue():this.$el.value;this.$emit("update:modelValue",this.defaultBuffer!==e?e:"")}}),10)),this.focusText=this.$el.value)},isValueUpdated(){return this.unmask?this.modelValue!=this.getUnmaskedValue():this.defaultBuffer!==this.$el.value&&this.$el.value!==this.modelValue}},computed:{filled(){return null!=this.modelValue&&this.modelValue.toString().length>0},inputClass(){return["p-inputmask p-inputtext p-component",{"p-filled":this.filled}]}}};const l=["readonly"];h.render=function(e,h,a,n,r,o){return t(),s("input",{class:i(o.inputClass),readonly:a.readonly,onInput:h[0]||(h[0]=(...e)=>o.onInput&&o.onInput(...e)),onFocus:h[1]||(h[1]=(...e)=>o.onFocus&&o.onFocus(...e)),onBlur:h[2]||(h[2]=(...e)=>o.onBlur&&o.onBlur(...e)),onKeydown:h[3]||(h[3]=(...e)=>o.onKeyDown&&o.onKeyDown(...e)),onKeypress:h[4]||(h[4]=(...e)=>o.onKeyPress&&o.onKeyPress(...e)),onPaste:h[5]||(h[5]=(...e)=>o.onPaste&&o.onPaste(...e))},null,42,l)};export{h as default};
1
+ import{DomHandler as e}from"primevue/utils";import{openBlock as t,createElementBlock as s,normalizeClass as i}from"vue";var h={name:"InputMask",emits:["update:modelValue","focus","blur","keydown","complete","keypress","paste"],props:{modelValue:null,slotChar:{type:String,default:"_"},mask:{type:String,default:null},autoClear:{type:Boolean,default:!0},unmask:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1}},watch:{mask(e,t){t!==e&&this.initMask()}},mounted(){this.initMask()},updated(){this.isValueUpdated()&&this.updateValue()},methods:{onInput(e){this.androidChrome?this.handleAndroidInput(e):this.handleInputChange(e),this.$emit("update:modelValue",e.target.value)},onFocus(e){if(this.readonly)return;let t;this.focus=!0,clearTimeout(this.caretTimeoutId),this.focusText=this.$el.value,t=this.checkVal(),this.caretTimeoutId=setTimeout((()=>{this.$el===document.activeElement&&(this.writeBuffer(),t===this.mask.replace("?","").length?this.caret(0,t):this.caret(t))}),10),this.$emit("focus",e)},onBlur(e){if(this.focus=!1,this.checkVal(),this.updateModel(e),this.$el.value!==this.focusText){let e=document.createEvent("HTMLEvents");e.initEvent("change",!0,!1),this.$el.dispatchEvent(e)}this.$emit("blur",e)},onKeyDown(t){if(this.readonly)return;let s,i,h,l=t.which||t.keyCode,a=/iphone/i.test(e.getUserAgent());this.oldVal=this.$el.value,8===l||46===l||a&&127===l?(s=this.caret(),i=s.begin,h=s.end,h-i==0&&(i=46!==l?this.seekPrev(i):h=this.seekNext(i-1),h=46===l?this.seekNext(h):h),this.clearBuffer(i,h),this.shiftL(i,h-1),this.updateModel(t),t.preventDefault()):13===l?(this.$el.blur(),this.updateModel(t)):27===l&&(this.$el.value=this.focusText,this.caret(0,this.checkVal()),this.updateModel(t),t.preventDefault()),this.$emit("keydown",t)},onKeyPress(t){if(!this.readonly){var s,i,h,l,a=t.which||t.keyCode,n=this.caret();if(!(t.ctrlKey||t.altKey||t.metaKey||a<32)){if(a&&13!==a){if(n.end-n.begin!=0&&(this.clearBuffer(n.begin,n.end),this.shiftL(n.begin,n.end-1)),(s=this.seekNext(n.begin-1))<this.len&&(i=String.fromCharCode(a),this.tests[s].test(i))){if(this.shiftR(s),this.buffer[s]=i,this.writeBuffer(),h=this.seekNext(s),/android/i.test(e.getUserAgent())){setTimeout((()=>{this.caret(h)}),0)}else this.caret(h);n.begin<=this.lastRequiredNonMaskPos&&(l=this.isCompleted())}t.preventDefault()}this.updateModel(t),l&&this.$emit("complete",t),this.$emit("keypress",t)}}},onPaste(e){this.handleInputChange(e),this.$emit("paste",e)},caret(e,t){let s,i,h;if(this.$el.offsetParent&&this.$el===document.activeElement)return"number"!=typeof e?(this.$el.setSelectionRange?(i=this.$el.selectionStart,h=this.$el.selectionEnd):document.selection&&document.selection.createRange&&(s=document.selection.createRange(),i=0-s.duplicate().moveStart("character",-1e5),h=i+s.text.length),{begin:i,end:h}):(i=e,h="number"==typeof t?t:i,void(this.$el.setSelectionRange?this.$el.setSelectionRange(i,h):this.$el.createTextRange&&(s=this.$el.createTextRange(),s.collapse(!0),s.moveEnd("character",h),s.moveStart("character",i),s.select())))},isCompleted(){for(let e=this.firstNonMaskPos;e<=this.lastRequiredNonMaskPos;e++)if(this.tests[e]&&this.buffer[e]===this.getPlaceholder(e))return!1;return!0},getPlaceholder(e){return e<this.slotChar.length?this.slotChar.charAt(e):this.slotChar.charAt(0)},seekNext(e){for(;++e<this.len&&!this.tests[e];);return e},seekPrev(e){for(;--e>=0&&!this.tests[e];);return e},shiftL(e,t){let s,i;if(!(e<0)){for(s=e,i=this.seekNext(t);s<this.len;s++)if(this.tests[s]){if(!(i<this.len&&this.tests[s].test(this.buffer[i])))break;this.buffer[s]=this.buffer[i],this.buffer[i]=this.getPlaceholder(i),i=this.seekNext(i)}this.writeBuffer(),this.caret(Math.max(this.firstNonMaskPos,e))}},shiftR(e){let t,s,i,h;for(t=e,s=this.getPlaceholder(e);t<this.len;t++)if(this.tests[t]){if(i=this.seekNext(t),h=this.buffer[t],this.buffer[t]=s,!(i<this.len&&this.tests[i].test(h)))break;s=h}},handleAndroidInput(e){var t=this.$el.value,s=this.caret();if(this.oldVal&&this.oldVal.length&&this.oldVal.length>t.length){for(this.checkVal(!0);s.begin>0&&!this.tests[s.begin-1];)s.begin--;if(0===s.begin)for(;s.begin<this.firstNonMaskPos&&!this.tests[s.begin];)s.begin++;this.caret(s.begin,s.begin)}else{for(this.checkVal(!0);s.begin<this.len&&!this.tests[s.begin];)s.begin++;this.caret(s.begin,s.begin)}this.isCompleted()&&this.$emit("complete",e)},clearBuffer(e,t){let s;for(s=e;s<t&&s<this.len;s++)this.tests[s]&&(this.buffer[s]=this.getPlaceholder(s))},writeBuffer(){this.$el.value=this.buffer.join("")},checkVal(e){this.isValueChecked=!0;let t,s,i,h=this.$el.value,l=-1;for(t=0,i=0;t<this.len;t++)if(this.tests[t]){for(this.buffer[t]=this.getPlaceholder(t);i++<h.length;)if(s=h.charAt(i-1),this.tests[t].test(s)){this.buffer[t]=s,l=t;break}if(i>h.length){this.clearBuffer(t+1,this.len);break}}else this.buffer[t]===h.charAt(i)&&i++,t<this.partialPosition&&(l=t);return e?this.writeBuffer():l+1<this.partialPosition?this.autoClear||this.buffer.join("")===this.defaultBuffer?(this.$el.value&&(this.$el.value=""),this.clearBuffer(0,this.len)):this.writeBuffer():(this.writeBuffer(),this.$el.value=this.$el.value.substring(0,l+1)),this.partialPosition?t:this.firstNonMaskPos},handleInputChange(e){if(!this.readonly){var t=this.checkVal(!0);this.caret(t),this.updateModel(e),this.isCompleted()&&this.$emit("complete",e)}},getUnmaskedValue(){let e=[];for(let t=0;t<this.buffer.length;t++){let s=this.buffer[t];this.tests[t]&&s!==this.getPlaceholder(t)&&e.push(s)}return e.join("")},updateModel(e){let t=this.unmask?this.getUnmaskedValue():e.target.value;this.$emit("update:modelValue",this.defaultBuffer!==t?t:"")},updateValue(e=!0){this.$el&&(null==this.modelValue?(this.$el.value="",e&&this.$emit("update:modelValue","")):(this.$el.value=this.modelValue,this.checkVal(),setTimeout((()=>{if(this.$el&&(this.writeBuffer(),this.checkVal(),e)){let e=this.unmask?this.getUnmaskedValue():this.$el.value;this.$emit("update:modelValue",this.defaultBuffer!==e?e:"")}}),10)),this.focusText=this.$el.value)},initMask(){this.tests=[],this.partialPosition=this.mask.length,this.len=this.mask.length,this.firstNonMaskPos=null,this.defs={9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"};let t=e.getUserAgent();this.androidChrome=/chrome/i.test(t)&&/android/i.test(t);let s=this.mask.split("");for(let e=0;e<s.length;e++){let t=s[e];"?"===t?(this.len--,this.partialPosition=e):this.defs[t]?(this.tests.push(new RegExp(this.defs[t])),null===this.firstNonMaskPos&&(this.firstNonMaskPos=this.tests.length-1),e<this.partialPosition&&(this.lastRequiredNonMaskPos=this.tests.length-1)):this.tests.push(null)}this.buffer=[];for(let e=0;e<s.length;e++){let t=s[e];"?"!==t&&(this.defs[t]?this.buffer.push(this.getPlaceholder(e)):this.buffer.push(t))}this.defaultBuffer=this.buffer.join(""),this.updateValue(!1)},isValueUpdated(){return this.unmask?this.modelValue!=this.getUnmaskedValue():this.defaultBuffer!==this.$el.value&&this.$el.value!==this.modelValue}},computed:{filled(){return null!=this.modelValue&&this.modelValue.toString().length>0},inputClass(){return["p-inputmask p-inputtext p-component",{"p-filled":this.filled}]}}};const l=["readonly"];h.render=function(e,h,a,n,r,o){return t(),s("input",{class:i(o.inputClass),readonly:a.readonly,onInput:h[0]||(h[0]=(...e)=>o.onInput&&o.onInput(...e)),onFocus:h[1]||(h[1]=(...e)=>o.onFocus&&o.onFocus(...e)),onBlur:h[2]||(h[2]=(...e)=>o.onBlur&&o.onBlur(...e)),onKeydown:h[3]||(h[3]=(...e)=>o.onKeyDown&&o.onKeyDown(...e)),onKeypress:h[4]||(h[4]=(...e)=>o.onKeyPress&&o.onKeyPress(...e)),onPaste:h[5]||(h[5]=(...e)=>o.onPaste&&o.onPaste(...e))},null,42,l)};export{h as default};
@@ -28,57 +28,15 @@ this.primevue.inputmask = (function (utils, vue) {
28
28
  default: false
29
29
  }
30
30
  },
31
- mounted() {
32
- this.tests = [];
33
- this.partialPosition = this.mask.length;
34
- this.len = this.mask.length;
35
- this.firstNonMaskPos = null;
36
- this.defs = {
37
- 9: '[0-9]',
38
- a: '[A-Za-z]',
39
- '*': '[A-Za-z0-9]'
40
- };
41
-
42
- let ua = utils.DomHandler.getUserAgent();
43
-
44
- this.androidChrome = /chrome/i.test(ua) && /android/i.test(ua);
45
-
46
- let maskTokens = this.mask.split('');
47
-
48
- for (let i = 0; i < maskTokens.length; i++) {
49
- let c = maskTokens[i];
50
-
51
- if (c === '?') {
52
- this.len--;
53
- this.partialPosition = i;
54
- } else if (this.defs[c]) {
55
- this.tests.push(new RegExp(this.defs[c]));
56
-
57
- if (this.firstNonMaskPos === null) {
58
- this.firstNonMaskPos = this.tests.length - 1;
59
- }
60
-
61
- if (i < this.partialPosition) {
62
- this.lastRequiredNonMaskPos = this.tests.length - 1;
63
- }
64
- } else {
65
- this.tests.push(null);
66
- }
67
- }
68
-
69
- this.buffer = [];
70
-
71
- for (let i = 0; i < maskTokens.length; i++) {
72
- let c = maskTokens[i];
73
-
74
- if (c !== '?') {
75
- if (this.defs[c]) this.buffer.push(this.getPlaceholder(i));
76
- else this.buffer.push(c);
31
+ watch: {
32
+ mask(newMask, oldMask) {
33
+ if (oldMask !== newMask) {
34
+ this.initMask();
77
35
  }
78
36
  }
79
-
80
- this.defaultBuffer = this.buffer.join('');
81
- this.updateValue(false);
37
+ },
38
+ mounted() {
39
+ this.initMask();
82
40
  },
83
41
  updated() {
84
42
  if (this.isValueUpdated()) {
@@ -497,6 +455,58 @@ this.primevue.inputmask = (function (utils, vue) {
497
455
  this.focusText = this.$el.value;
498
456
  }
499
457
  },
458
+ initMask() {
459
+ this.tests = [];
460
+ this.partialPosition = this.mask.length;
461
+ this.len = this.mask.length;
462
+ this.firstNonMaskPos = null;
463
+ this.defs = {
464
+ 9: '[0-9]',
465
+ a: '[A-Za-z]',
466
+ '*': '[A-Za-z0-9]'
467
+ };
468
+
469
+ let ua = utils.DomHandler.getUserAgent();
470
+
471
+ this.androidChrome = /chrome/i.test(ua) && /android/i.test(ua);
472
+
473
+ let maskTokens = this.mask.split('');
474
+
475
+ for (let i = 0; i < maskTokens.length; i++) {
476
+ let c = maskTokens[i];
477
+
478
+ if (c === '?') {
479
+ this.len--;
480
+ this.partialPosition = i;
481
+ } else if (this.defs[c]) {
482
+ this.tests.push(new RegExp(this.defs[c]));
483
+
484
+ if (this.firstNonMaskPos === null) {
485
+ this.firstNonMaskPos = this.tests.length - 1;
486
+ }
487
+
488
+ if (i < this.partialPosition) {
489
+ this.lastRequiredNonMaskPos = this.tests.length - 1;
490
+ }
491
+ } else {
492
+ this.tests.push(null);
493
+ }
494
+ }
495
+
496
+ this.buffer = [];
497
+
498
+ for (let i = 0; i < maskTokens.length; i++) {
499
+ let c = maskTokens[i];
500
+
501
+ if (c !== '?') {
502
+ if (this.defs[c]) this.buffer.push(this.getPlaceholder(i));
503
+ else this.buffer.push(c);
504
+ }
505
+ }
506
+
507
+ this.defaultBuffer = this.buffer.join('');
508
+ this.updateValue(false);
509
+ },
500
510
  isValueUpdated() {
501
511
  return this.unmask ? this.modelValue != this.getUnmaskedValue() : this.defaultBuffer !== this.$el.value && this.$el.value !== this.modelValue;
502
512
  }
@@ -1 +1 @@
1
- this.primevue=this.primevue||{},this.primevue.inputmask=function(e,t){"use strict";var s={name:"InputMask",emits:["update:modelValue","focus","blur","keydown","complete","keypress","paste"],props:{modelValue:null,slotChar:{type:String,default:"_"},mask:{type:String,default:null},autoClear:{type:Boolean,default:!0},unmask:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1}},mounted(){this.tests=[],this.partialPosition=this.mask.length,this.len=this.mask.length,this.firstNonMaskPos=null,this.defs={9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"};let t=e.DomHandler.getUserAgent();this.androidChrome=/chrome/i.test(t)&&/android/i.test(t);let s=this.mask.split("");for(let e=0;e<s.length;e++){let t=s[e];"?"===t?(this.len--,this.partialPosition=e):this.defs[t]?(this.tests.push(new RegExp(this.defs[t])),null===this.firstNonMaskPos&&(this.firstNonMaskPos=this.tests.length-1),e<this.partialPosition&&(this.lastRequiredNonMaskPos=this.tests.length-1)):this.tests.push(null)}this.buffer=[];for(let e=0;e<s.length;e++){let t=s[e];"?"!==t&&(this.defs[t]?this.buffer.push(this.getPlaceholder(e)):this.buffer.push(t))}this.defaultBuffer=this.buffer.join(""),this.updateValue(!1)},updated(){this.isValueUpdated()&&this.updateValue()},methods:{onInput(e){this.androidChrome?this.handleAndroidInput(e):this.handleInputChange(e),this.$emit("update:modelValue",e.target.value)},onFocus(e){if(this.readonly)return;let t;this.focus=!0,clearTimeout(this.caretTimeoutId),this.focusText=this.$el.value,t=this.checkVal(),this.caretTimeoutId=setTimeout((()=>{this.$el===document.activeElement&&(this.writeBuffer(),t===this.mask.replace("?","").length?this.caret(0,t):this.caret(t))}),10),this.$emit("focus",e)},onBlur(e){if(this.focus=!1,this.checkVal(),this.updateModel(e),this.$el.value!==this.focusText){let e=document.createEvent("HTMLEvents");e.initEvent("change",!0,!1),this.$el.dispatchEvent(e)}this.$emit("blur",e)},onKeyDown(t){if(this.readonly)return;let s,i,h,l=t.which||t.keyCode,a=/iphone/i.test(e.DomHandler.getUserAgent());this.oldVal=this.$el.value,8===l||46===l||a&&127===l?(s=this.caret(),i=s.begin,h=s.end,h-i==0&&(i=46!==l?this.seekPrev(i):h=this.seekNext(i-1),h=46===l?this.seekNext(h):h),this.clearBuffer(i,h),this.shiftL(i,h-1),this.updateModel(t),t.preventDefault()):13===l?(this.$el.blur(),this.updateModel(t)):27===l&&(this.$el.value=this.focusText,this.caret(0,this.checkVal()),this.updateModel(t),t.preventDefault()),this.$emit("keydown",t)},onKeyPress(t){if(!this.readonly){var s,i,h,l,a=t.which||t.keyCode,n=this.caret();if(!(t.ctrlKey||t.altKey||t.metaKey||a<32)){if(a&&13!==a){if(n.end-n.begin!=0&&(this.clearBuffer(n.begin,n.end),this.shiftL(n.begin,n.end-1)),(s=this.seekNext(n.begin-1))<this.len&&(i=String.fromCharCode(a),this.tests[s].test(i))){if(this.shiftR(s),this.buffer[s]=i,this.writeBuffer(),h=this.seekNext(s),/android/i.test(e.DomHandler.getUserAgent())){setTimeout((()=>{this.caret(h)}),0)}else this.caret(h);n.begin<=this.lastRequiredNonMaskPos&&(l=this.isCompleted())}t.preventDefault()}this.updateModel(t),l&&this.$emit("complete",t),this.$emit("keypress",t)}}},onPaste(e){this.handleInputChange(e),this.$emit("paste",e)},caret(e,t){let s,i,h;if(this.$el.offsetParent&&this.$el===document.activeElement)return"number"!=typeof e?(this.$el.setSelectionRange?(i=this.$el.selectionStart,h=this.$el.selectionEnd):document.selection&&document.selection.createRange&&(s=document.selection.createRange(),i=0-s.duplicate().moveStart("character",-1e5),h=i+s.text.length),{begin:i,end:h}):(i=e,h="number"==typeof t?t:i,void(this.$el.setSelectionRange?this.$el.setSelectionRange(i,h):this.$el.createTextRange&&(s=this.$el.createTextRange(),s.collapse(!0),s.moveEnd("character",h),s.moveStart("character",i),s.select())))},isCompleted(){for(let e=this.firstNonMaskPos;e<=this.lastRequiredNonMaskPos;e++)if(this.tests[e]&&this.buffer[e]===this.getPlaceholder(e))return!1;return!0},getPlaceholder(e){return e<this.slotChar.length?this.slotChar.charAt(e):this.slotChar.charAt(0)},seekNext(e){for(;++e<this.len&&!this.tests[e];);return e},seekPrev(e){for(;--e>=0&&!this.tests[e];);return e},shiftL(e,t){let s,i;if(!(e<0)){for(s=e,i=this.seekNext(t);s<this.len;s++)if(this.tests[s]){if(!(i<this.len&&this.tests[s].test(this.buffer[i])))break;this.buffer[s]=this.buffer[i],this.buffer[i]=this.getPlaceholder(i),i=this.seekNext(i)}this.writeBuffer(),this.caret(Math.max(this.firstNonMaskPos,e))}},shiftR(e){let t,s,i,h;for(t=e,s=this.getPlaceholder(e);t<this.len;t++)if(this.tests[t]){if(i=this.seekNext(t),h=this.buffer[t],this.buffer[t]=s,!(i<this.len&&this.tests[i].test(h)))break;s=h}},handleAndroidInput(e){var t=this.$el.value,s=this.caret();if(this.oldVal&&this.oldVal.length&&this.oldVal.length>t.length){for(this.checkVal(!0);s.begin>0&&!this.tests[s.begin-1];)s.begin--;if(0===s.begin)for(;s.begin<this.firstNonMaskPos&&!this.tests[s.begin];)s.begin++;this.caret(s.begin,s.begin)}else{for(this.checkVal(!0);s.begin<this.len&&!this.tests[s.begin];)s.begin++;this.caret(s.begin,s.begin)}this.isCompleted()&&this.$emit("complete",e)},clearBuffer(e,t){let s;for(s=e;s<t&&s<this.len;s++)this.tests[s]&&(this.buffer[s]=this.getPlaceholder(s))},writeBuffer(){this.$el.value=this.buffer.join("")},checkVal(e){this.isValueChecked=!0;let t,s,i,h=this.$el.value,l=-1;for(t=0,i=0;t<this.len;t++)if(this.tests[t]){for(this.buffer[t]=this.getPlaceholder(t);i++<h.length;)if(s=h.charAt(i-1),this.tests[t].test(s)){this.buffer[t]=s,l=t;break}if(i>h.length){this.clearBuffer(t+1,this.len);break}}else this.buffer[t]===h.charAt(i)&&i++,t<this.partialPosition&&(l=t);return e?this.writeBuffer():l+1<this.partialPosition?this.autoClear||this.buffer.join("")===this.defaultBuffer?(this.$el.value&&(this.$el.value=""),this.clearBuffer(0,this.len)):this.writeBuffer():(this.writeBuffer(),this.$el.value=this.$el.value.substring(0,l+1)),this.partialPosition?t:this.firstNonMaskPos},handleInputChange(e){if(!this.readonly){var t=this.checkVal(!0);this.caret(t),this.updateModel(e),this.isCompleted()&&this.$emit("complete",e)}},getUnmaskedValue(){let e=[];for(let t=0;t<this.buffer.length;t++){let s=this.buffer[t];this.tests[t]&&s!==this.getPlaceholder(t)&&e.push(s)}return e.join("")},updateModel(e){let t=this.unmask?this.getUnmaskedValue():e.target.value;this.$emit("update:modelValue",this.defaultBuffer!==t?t:"")},updateValue(e=!0){this.$el&&(null==this.modelValue?(this.$el.value="",e&&this.$emit("update:modelValue","")):(this.$el.value=this.modelValue,this.checkVal(),setTimeout((()=>{if(this.$el&&(this.writeBuffer(),this.checkVal(),e)){let e=this.unmask?this.getUnmaskedValue():this.$el.value;this.$emit("update:modelValue",this.defaultBuffer!==e?e:"")}}),10)),this.focusText=this.$el.value)},isValueUpdated(){return this.unmask?this.modelValue!=this.getUnmaskedValue():this.defaultBuffer!==this.$el.value&&this.$el.value!==this.modelValue}},computed:{filled(){return null!=this.modelValue&&this.modelValue.toString().length>0},inputClass(){return["p-inputmask p-inputtext p-component",{"p-filled":this.filled}]}}};const i=["readonly"];return s.render=function(e,s,h,l,a,n){return t.openBlock(),t.createElementBlock("input",{class:t.normalizeClass(n.inputClass),readonly:h.readonly,onInput:s[0]||(s[0]=(...e)=>n.onInput&&n.onInput(...e)),onFocus:s[1]||(s[1]=(...e)=>n.onFocus&&n.onFocus(...e)),onBlur:s[2]||(s[2]=(...e)=>n.onBlur&&n.onBlur(...e)),onKeydown:s[3]||(s[3]=(...e)=>n.onKeyDown&&n.onKeyDown(...e)),onKeypress:s[4]||(s[4]=(...e)=>n.onKeyPress&&n.onKeyPress(...e)),onPaste:s[5]||(s[5]=(...e)=>n.onPaste&&n.onPaste(...e))},null,42,i)},s}(primevue.utils,Vue);
1
+ this.primevue=this.primevue||{},this.primevue.inputmask=function(e,t){"use strict";var s={name:"InputMask",emits:["update:modelValue","focus","blur","keydown","complete","keypress","paste"],props:{modelValue:null,slotChar:{type:String,default:"_"},mask:{type:String,default:null},autoClear:{type:Boolean,default:!0},unmask:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1}},watch:{mask(e,t){t!==e&&this.initMask()}},mounted(){this.initMask()},updated(){this.isValueUpdated()&&this.updateValue()},methods:{onInput(e){this.androidChrome?this.handleAndroidInput(e):this.handleInputChange(e),this.$emit("update:modelValue",e.target.value)},onFocus(e){if(this.readonly)return;let t;this.focus=!0,clearTimeout(this.caretTimeoutId),this.focusText=this.$el.value,t=this.checkVal(),this.caretTimeoutId=setTimeout((()=>{this.$el===document.activeElement&&(this.writeBuffer(),t===this.mask.replace("?","").length?this.caret(0,t):this.caret(t))}),10),this.$emit("focus",e)},onBlur(e){if(this.focus=!1,this.checkVal(),this.updateModel(e),this.$el.value!==this.focusText){let e=document.createEvent("HTMLEvents");e.initEvent("change",!0,!1),this.$el.dispatchEvent(e)}this.$emit("blur",e)},onKeyDown(t){if(this.readonly)return;let s,i,h,l=t.which||t.keyCode,a=/iphone/i.test(e.DomHandler.getUserAgent());this.oldVal=this.$el.value,8===l||46===l||a&&127===l?(s=this.caret(),i=s.begin,h=s.end,h-i==0&&(i=46!==l?this.seekPrev(i):h=this.seekNext(i-1),h=46===l?this.seekNext(h):h),this.clearBuffer(i,h),this.shiftL(i,h-1),this.updateModel(t),t.preventDefault()):13===l?(this.$el.blur(),this.updateModel(t)):27===l&&(this.$el.value=this.focusText,this.caret(0,this.checkVal()),this.updateModel(t),t.preventDefault()),this.$emit("keydown",t)},onKeyPress(t){if(!this.readonly){var s,i,h,l,a=t.which||t.keyCode,n=this.caret();if(!(t.ctrlKey||t.altKey||t.metaKey||a<32)){if(a&&13!==a){if(n.end-n.begin!=0&&(this.clearBuffer(n.begin,n.end),this.shiftL(n.begin,n.end-1)),(s=this.seekNext(n.begin-1))<this.len&&(i=String.fromCharCode(a),this.tests[s].test(i))){if(this.shiftR(s),this.buffer[s]=i,this.writeBuffer(),h=this.seekNext(s),/android/i.test(e.DomHandler.getUserAgent())){setTimeout((()=>{this.caret(h)}),0)}else this.caret(h);n.begin<=this.lastRequiredNonMaskPos&&(l=this.isCompleted())}t.preventDefault()}this.updateModel(t),l&&this.$emit("complete",t),this.$emit("keypress",t)}}},onPaste(e){this.handleInputChange(e),this.$emit("paste",e)},caret(e,t){let s,i,h;if(this.$el.offsetParent&&this.$el===document.activeElement)return"number"!=typeof e?(this.$el.setSelectionRange?(i=this.$el.selectionStart,h=this.$el.selectionEnd):document.selection&&document.selection.createRange&&(s=document.selection.createRange(),i=0-s.duplicate().moveStart("character",-1e5),h=i+s.text.length),{begin:i,end:h}):(i=e,h="number"==typeof t?t:i,void(this.$el.setSelectionRange?this.$el.setSelectionRange(i,h):this.$el.createTextRange&&(s=this.$el.createTextRange(),s.collapse(!0),s.moveEnd("character",h),s.moveStart("character",i),s.select())))},isCompleted(){for(let e=this.firstNonMaskPos;e<=this.lastRequiredNonMaskPos;e++)if(this.tests[e]&&this.buffer[e]===this.getPlaceholder(e))return!1;return!0},getPlaceholder(e){return e<this.slotChar.length?this.slotChar.charAt(e):this.slotChar.charAt(0)},seekNext(e){for(;++e<this.len&&!this.tests[e];);return e},seekPrev(e){for(;--e>=0&&!this.tests[e];);return e},shiftL(e,t){let s,i;if(!(e<0)){for(s=e,i=this.seekNext(t);s<this.len;s++)if(this.tests[s]){if(!(i<this.len&&this.tests[s].test(this.buffer[i])))break;this.buffer[s]=this.buffer[i],this.buffer[i]=this.getPlaceholder(i),i=this.seekNext(i)}this.writeBuffer(),this.caret(Math.max(this.firstNonMaskPos,e))}},shiftR(e){let t,s,i,h;for(t=e,s=this.getPlaceholder(e);t<this.len;t++)if(this.tests[t]){if(i=this.seekNext(t),h=this.buffer[t],this.buffer[t]=s,!(i<this.len&&this.tests[i].test(h)))break;s=h}},handleAndroidInput(e){var t=this.$el.value,s=this.caret();if(this.oldVal&&this.oldVal.length&&this.oldVal.length>t.length){for(this.checkVal(!0);s.begin>0&&!this.tests[s.begin-1];)s.begin--;if(0===s.begin)for(;s.begin<this.firstNonMaskPos&&!this.tests[s.begin];)s.begin++;this.caret(s.begin,s.begin)}else{for(this.checkVal(!0);s.begin<this.len&&!this.tests[s.begin];)s.begin++;this.caret(s.begin,s.begin)}this.isCompleted()&&this.$emit("complete",e)},clearBuffer(e,t){let s;for(s=e;s<t&&s<this.len;s++)this.tests[s]&&(this.buffer[s]=this.getPlaceholder(s))},writeBuffer(){this.$el.value=this.buffer.join("")},checkVal(e){this.isValueChecked=!0;let t,s,i,h=this.$el.value,l=-1;for(t=0,i=0;t<this.len;t++)if(this.tests[t]){for(this.buffer[t]=this.getPlaceholder(t);i++<h.length;)if(s=h.charAt(i-1),this.tests[t].test(s)){this.buffer[t]=s,l=t;break}if(i>h.length){this.clearBuffer(t+1,this.len);break}}else this.buffer[t]===h.charAt(i)&&i++,t<this.partialPosition&&(l=t);return e?this.writeBuffer():l+1<this.partialPosition?this.autoClear||this.buffer.join("")===this.defaultBuffer?(this.$el.value&&(this.$el.value=""),this.clearBuffer(0,this.len)):this.writeBuffer():(this.writeBuffer(),this.$el.value=this.$el.value.substring(0,l+1)),this.partialPosition?t:this.firstNonMaskPos},handleInputChange(e){if(!this.readonly){var t=this.checkVal(!0);this.caret(t),this.updateModel(e),this.isCompleted()&&this.$emit("complete",e)}},getUnmaskedValue(){let e=[];for(let t=0;t<this.buffer.length;t++){let s=this.buffer[t];this.tests[t]&&s!==this.getPlaceholder(t)&&e.push(s)}return e.join("")},updateModel(e){let t=this.unmask?this.getUnmaskedValue():e.target.value;this.$emit("update:modelValue",this.defaultBuffer!==t?t:"")},updateValue(e=!0){this.$el&&(null==this.modelValue?(this.$el.value="",e&&this.$emit("update:modelValue","")):(this.$el.value=this.modelValue,this.checkVal(),setTimeout((()=>{if(this.$el&&(this.writeBuffer(),this.checkVal(),e)){let e=this.unmask?this.getUnmaskedValue():this.$el.value;this.$emit("update:modelValue",this.defaultBuffer!==e?e:"")}}),10)),this.focusText=this.$el.value)},initMask(){this.tests=[],this.partialPosition=this.mask.length,this.len=this.mask.length,this.firstNonMaskPos=null,this.defs={9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"};let t=e.DomHandler.getUserAgent();this.androidChrome=/chrome/i.test(t)&&/android/i.test(t);let s=this.mask.split("");for(let e=0;e<s.length;e++){let t=s[e];"?"===t?(this.len--,this.partialPosition=e):this.defs[t]?(this.tests.push(new RegExp(this.defs[t])),null===this.firstNonMaskPos&&(this.firstNonMaskPos=this.tests.length-1),e<this.partialPosition&&(this.lastRequiredNonMaskPos=this.tests.length-1)):this.tests.push(null)}this.buffer=[];for(let e=0;e<s.length;e++){let t=s[e];"?"!==t&&(this.defs[t]?this.buffer.push(this.getPlaceholder(e)):this.buffer.push(t))}this.defaultBuffer=this.buffer.join(""),this.updateValue(!1)},isValueUpdated(){return this.unmask?this.modelValue!=this.getUnmaskedValue():this.defaultBuffer!==this.$el.value&&this.$el.value!==this.modelValue}},computed:{filled(){return null!=this.modelValue&&this.modelValue.toString().length>0},inputClass(){return["p-inputmask p-inputtext p-component",{"p-filled":this.filled}]}}};const i=["readonly"];return s.render=function(e,s,h,l,a,n){return t.openBlock(),t.createElementBlock("input",{class:t.normalizeClass(n.inputClass),readonly:h.readonly,onInput:s[0]||(s[0]=(...e)=>n.onInput&&n.onInput(...e)),onFocus:s[1]||(s[1]=(...e)=>n.onFocus&&n.onFocus(...e)),onBlur:s[2]||(s[2]=(...e)=>n.onBlur&&n.onBlur(...e)),onKeydown:s[3]||(s[3]=(...e)=>n.onKeyDown&&n.onKeyDown(...e)),onKeypress:s[4]||(s[4]=(...e)=>n.onKeyPress&&n.onKeyPress(...e)),onPaste:s[5]||(s[5]=(...e)=>n.onPaste&&n.onPaste(...e))},null,42,i)},s}(primevue.utils,Vue);
@@ -173,11 +173,11 @@ export interface InputNumberProps {
173
173
  /**
174
174
  * Style class of the input field.
175
175
  */
176
- inputClass?: any | undefined;
176
+ inputClass?: string | object | undefined;
177
177
  /**
178
178
  * Inline style of the input field.
179
179
  */
180
- inputStyle?: any | undefined;
180
+ inputStyle?: object | undefined;
181
181
  /**
182
182
  * Uses to pass all properties of the HTMLInputElement to the focusable input element inside the component.
183
183
  */
@@ -152,11 +152,11 @@ export default {
152
152
  default: null
153
153
  },
154
154
  inputClass: {
155
- type: String,
155
+ type: [String, Object],
156
156
  default: null
157
157
  },
158
158
  inputStyle: {
159
- type: null,
159
+ type: Object,
160
160
  default: null
161
161
  },
162
162
  inputProps: {
@@ -123,11 +123,11 @@ var script = {
123
123
  default: null
124
124
  },
125
125
  inputClass: {
126
- type: String,
126
+ type: [String, Object],
127
127
  default: null
128
128
  },
129
129
  inputStyle: {
130
- type: null,
130
+ type: Object,
131
131
  default: null
132
132
  },
133
133
  inputProps: {
@@ -1 +1 @@
1
- "use strict";var e=require("primevue/button"),t=require("primevue/inputtext"),n=require("primevue/utils"),i=require("vue");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=s(e),l={name:"InputNumber",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},highlightOnFocus:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},placeholder:{type:String,default:null},inputId:{type:String,default:null},inputClass:{type:String,default:null},inputStyle:{type:null,default:null},inputProps:{type:null,default:null},incrementButtonProps:{type:null,default:null},decrementButtonProps:{type:null,default:null},"aria-labelledby":{type:String,default:null},"aria-label":{type:String,default: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.disabled||(this.$refs.input.$el.focus(),this.repeat(e,null,1),e.preventDefault())},onUpButtonMouseUp(){this.disabled||this.clearTimer()},onUpButtonMouseLeave(){this.disabled||this.clearTimer()},onUpButtonKeyUp(){this.disabled||this.clearTimer()},onUpButtonKeyDown(e){32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,1)},onDownButtonMouseDown(e){this.disabled||(this.$refs.input.$el.focus(),this.repeat(e,null,-1),e.preventDefault())},onDownButtonMouseUp(){this.disabled||this.clearTimer()},onDownButtonMouseLeave(){this.disabled||this.clearTimer()},onDownButtonKeyUp(){this.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.code){case"ArrowUp":this.spin(e,1),e.preventDefault();break;case"ArrowDown":this.spin(e,-1),e.preventDefault();break;case"ArrowLeft":this.isNumeralChar(i.charAt(t-1))||e.preventDefault();break;case"ArrowRight":this.isNumeralChar(i.charAt(t))||e.preventDefault();break;case"Tab":case"Enter":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"Backspace":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"Delete":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");break;case"Home":this.min&&(this.updateModel(e,this.min),e.preventDefault());break;case"End":this.max&&(this.updateModel(e,this.max),e.preventDefault())}},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(){const e=this.$refs.input.$el.value;this.readonly||e===n.DomHandler.getSelection()||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,formattedValue:t})},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,this.suffixChar?e.replace(this.suffixChar,"").split(this._decimal)[0]+t.replace(this.suffixChar,"").slice(n)+this.suffixChar:-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.disabled||this.readonly||this.$refs.input.$el.value===n.DomHandler.getSelection()||!this.highlightOnFocus||e.target.select(),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",{"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(t).default,INButton:r.default}};const u={key:0,class:"p-inputnumber-button-group"};!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: inline-flex;\n}\n.p-inputnumber-button {\n display: flex;\n align-items: center;\n justify-content: center;\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: flex;\n flex-direction: column;\n}\n.p-inputnumber-buttons-stacked .p-inputnumber-button-group .p-button.p-inputnumber-button {\n flex: 1 1 auto;\n}\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-up {\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 order: 2;\n border-radius: 0;\n}\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-down {\n order: 1;\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n.p-inputnumber-buttons-vertical {\n flex-direction: column;\n}\n.p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-up {\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 order: 2;\n border-radius: 0;\n text-align: center;\n}\n.p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-down {\n order: 3;\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n width: 100%;\n}\n.p-inputnumber-input {\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,n,s,r,l){const a=i.resolveComponent("INInputText"),o=i.resolveComponent("INButton");return i.openBlock(),i.createElementBlock("span",{class:i.normalizeClass(l.containerClass)},[i.createVNode(a,i.mergeProps({ref:"input",id:n.inputId,class:["p-inputnumber-input",n.inputClass],role:"spinbutton",style:n.inputStyle,value:l.formattedValue,"aria-valuemin":n.min,"aria-valuemax":n.max,"aria-valuenow":n.modelValue,disabled:n.disabled,readonly:n.readonly,placeholder:n.placeholder,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,onInput:l.onUserInput,onKeydown:l.onInputKeyDown,onKeypress:l.onInputKeyPress,onPaste:l.onPaste,onClick:l.onInputClick,onFocus:l.onInputFocus,onBlur:l.onInputBlur},n.inputProps),null,16,["id","class","style","value","aria-valuemin","aria-valuemax","aria-valuenow","disabled","readonly","placeholder","aria-labelledby","aria-label","onInput","onKeydown","onKeypress","onPaste","onClick","onFocus","onBlur"]),n.showButtons&&"stacked"===n.buttonLayout?(i.openBlock(),i.createElementBlock("span",u,[i.createVNode(o,i.mergeProps({class:l.upButtonClass,icon:n.incrementButtonIcon},i.toHandlers(l.upButtonListeners),{disabled:n.disabled,tabindex:-1,"aria-hidden":"true"},n.incrementButtonProps),null,16,["class","icon","disabled"]),i.createVNode(o,i.mergeProps({class:l.downButtonClass,icon:n.decrementButtonIcon},i.toHandlers(l.downButtonListeners),{disabled:n.disabled,tabindex:-1,"aria-hidden":"true"},n.decrementButtonProps),null,16,["class","icon","disabled"])])):i.createCommentVNode("",!0),n.showButtons&&"stacked"!==n.buttonLayout?(i.openBlock(),i.createBlock(o,i.mergeProps({key:1,class:l.upButtonClass,icon:n.incrementButtonIcon},i.toHandlers(l.upButtonListeners),{disabled:n.disabled,tabindex:-1,"aria-hidden":"true"},n.incrementButtonProps),null,16,["class","icon","disabled"])):i.createCommentVNode("",!0),n.showButtons&&"stacked"!==n.buttonLayout?(i.openBlock(),i.createBlock(o,i.mergeProps({key:2,class:l.downButtonClass,icon:n.decrementButtonIcon},i.toHandlers(l.downButtonListeners),{disabled:n.disabled,tabindex:-1,"aria-hidden":"true"},n.decrementButtonProps),null,16,["class","icon","disabled"])):i.createCommentVNode("",!0)],2)},module.exports=l;
1
+ "use strict";var e=require("primevue/button"),t=require("primevue/inputtext"),n=require("primevue/utils"),i=require("vue");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=s(e),l={name:"InputNumber",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},highlightOnFocus:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},placeholder:{type:String,default:null},inputId:{type:String,default:null},inputClass:{type:[String,Object],default:null},inputStyle:{type:Object,default:null},inputProps:{type:null,default:null},incrementButtonProps:{type:null,default:null},decrementButtonProps:{type:null,default:null},"aria-labelledby":{type:String,default:null},"aria-label":{type:String,default: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.disabled||(this.$refs.input.$el.focus(),this.repeat(e,null,1),e.preventDefault())},onUpButtonMouseUp(){this.disabled||this.clearTimer()},onUpButtonMouseLeave(){this.disabled||this.clearTimer()},onUpButtonKeyUp(){this.disabled||this.clearTimer()},onUpButtonKeyDown(e){32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,1)},onDownButtonMouseDown(e){this.disabled||(this.$refs.input.$el.focus(),this.repeat(e,null,-1),e.preventDefault())},onDownButtonMouseUp(){this.disabled||this.clearTimer()},onDownButtonMouseLeave(){this.disabled||this.clearTimer()},onDownButtonKeyUp(){this.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.code){case"ArrowUp":this.spin(e,1),e.preventDefault();break;case"ArrowDown":this.spin(e,-1),e.preventDefault();break;case"ArrowLeft":this.isNumeralChar(i.charAt(t-1))||e.preventDefault();break;case"ArrowRight":this.isNumeralChar(i.charAt(t))||e.preventDefault();break;case"Tab":case"Enter":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"Backspace":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"Delete":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");break;case"Home":this.min&&(this.updateModel(e,this.min),e.preventDefault());break;case"End":this.max&&(this.updateModel(e,this.max),e.preventDefault())}},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(){const e=this.$refs.input.$el.value;this.readonly||e===n.DomHandler.getSelection()||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,formattedValue:t})},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,this.suffixChar?e.replace(this.suffixChar,"").split(this._decimal)[0]+t.replace(this.suffixChar,"").slice(n)+this.suffixChar:-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.disabled||this.readonly||this.$refs.input.$el.value===n.DomHandler.getSelection()||!this.highlightOnFocus||e.target.select(),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",{"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(t).default,INButton:r.default}};const u={key:0,class:"p-inputnumber-button-group"};!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: inline-flex;\n}\n.p-inputnumber-button {\n display: flex;\n align-items: center;\n justify-content: center;\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: flex;\n flex-direction: column;\n}\n.p-inputnumber-buttons-stacked .p-inputnumber-button-group .p-button.p-inputnumber-button {\n flex: 1 1 auto;\n}\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-up {\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 order: 2;\n border-radius: 0;\n}\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-down {\n order: 1;\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n.p-inputnumber-buttons-vertical {\n flex-direction: column;\n}\n.p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-up {\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 order: 2;\n border-radius: 0;\n text-align: center;\n}\n.p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-down {\n order: 3;\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n width: 100%;\n}\n.p-inputnumber-input {\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,n,s,r,l){const a=i.resolveComponent("INInputText"),o=i.resolveComponent("INButton");return i.openBlock(),i.createElementBlock("span",{class:i.normalizeClass(l.containerClass)},[i.createVNode(a,i.mergeProps({ref:"input",id:n.inputId,class:["p-inputnumber-input",n.inputClass],role:"spinbutton",style:n.inputStyle,value:l.formattedValue,"aria-valuemin":n.min,"aria-valuemax":n.max,"aria-valuenow":n.modelValue,disabled:n.disabled,readonly:n.readonly,placeholder:n.placeholder,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,onInput:l.onUserInput,onKeydown:l.onInputKeyDown,onKeypress:l.onInputKeyPress,onPaste:l.onPaste,onClick:l.onInputClick,onFocus:l.onInputFocus,onBlur:l.onInputBlur},n.inputProps),null,16,["id","class","style","value","aria-valuemin","aria-valuemax","aria-valuenow","disabled","readonly","placeholder","aria-labelledby","aria-label","onInput","onKeydown","onKeypress","onPaste","onClick","onFocus","onBlur"]),n.showButtons&&"stacked"===n.buttonLayout?(i.openBlock(),i.createElementBlock("span",u,[i.createVNode(o,i.mergeProps({class:l.upButtonClass,icon:n.incrementButtonIcon},i.toHandlers(l.upButtonListeners),{disabled:n.disabled,tabindex:-1,"aria-hidden":"true"},n.incrementButtonProps),null,16,["class","icon","disabled"]),i.createVNode(o,i.mergeProps({class:l.downButtonClass,icon:n.decrementButtonIcon},i.toHandlers(l.downButtonListeners),{disabled:n.disabled,tabindex:-1,"aria-hidden":"true"},n.decrementButtonProps),null,16,["class","icon","disabled"])])):i.createCommentVNode("",!0),n.showButtons&&"stacked"!==n.buttonLayout?(i.openBlock(),i.createBlock(o,i.mergeProps({key:1,class:l.upButtonClass,icon:n.incrementButtonIcon},i.toHandlers(l.upButtonListeners),{disabled:n.disabled,tabindex:-1,"aria-hidden":"true"},n.incrementButtonProps),null,16,["class","icon","disabled"])):i.createCommentVNode("",!0),n.showButtons&&"stacked"!==n.buttonLayout?(i.openBlock(),i.createBlock(o,i.mergeProps({key:2,class:l.downButtonClass,icon:n.decrementButtonIcon},i.toHandlers(l.downButtonListeners),{disabled:n.disabled,tabindex:-1,"aria-hidden":"true"},n.decrementButtonProps),null,16,["class","icon","disabled"])):i.createCommentVNode("",!0)],2)},module.exports=l;
@@ -116,11 +116,11 @@ var script = {
116
116
  default: null
117
117
  },
118
118
  inputClass: {
119
- type: String,
119
+ type: [String, Object],
120
120
  default: null
121
121
  },
122
122
  inputStyle: {
123
- type: null,
123
+ type: Object,
124
124
  default: null
125
125
  },
126
126
  inputProps: {
@@ -1 +1 @@
1
- import e from"primevue/button";import t from"primevue/inputtext";import{DomHandler as i}from"primevue/utils";import{resolveComponent as n,openBlock as s,createElementBlock as r,normalizeClass as u,createVNode as l,mergeProps as a,toHandlers as o,createCommentVNode as p,createBlock as h}from"vue";var c={name:"InputNumber",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},highlightOnFocus:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},placeholder:{type:String,default:null},inputId:{type:String,default:null},inputClass:{type:String,default:null},inputStyle:{type:null,default:null},inputProps:{type:null,default:null},incrementButtonProps:{type:null,default:null},decrementButtonProps:{type:null,default:null},"aria-labelledby":{type:String,default:null},"aria-label":{type:String,default: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,i){if(this.readonly)return;let n=t||500;this.clearTimer(),this.timer=setTimeout((()=>{this.repeat(e,40,i)}),n),this.spin(e,i)},spin(e,t){if(this.$refs.input){let i=this.step*t,n=this.parseValue(this.$refs.input.$el.value)||0,s=this.validateValue(n+i);this.updateInput(s,null,"spin"),this.updateModel(e,s),this.handleOnInput(e,n,s)}},onUpButtonMouseDown(e){this.disabled||(this.$refs.input.$el.focus(),this.repeat(e,null,1),e.preventDefault())},onUpButtonMouseUp(){this.disabled||this.clearTimer()},onUpButtonMouseLeave(){this.disabled||this.clearTimer()},onUpButtonKeyUp(){this.disabled||this.clearTimer()},onUpButtonKeyDown(e){32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,1)},onDownButtonMouseDown(e){this.disabled||(this.$refs.input.$el.focus(),this.repeat(e,null,-1),e.preventDefault())},onDownButtonMouseUp(){this.disabled||this.clearTimer()},onDownButtonMouseLeave(){this.disabled||this.clearTimer()},onDownButtonKeyUp(){this.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,i=e.target.selectionEnd,n=e.target.value,s=null;switch(e.altKey&&e.preventDefault(),e.code){case"ArrowUp":this.spin(e,1),e.preventDefault();break;case"ArrowDown":this.spin(e,-1),e.preventDefault();break;case"ArrowLeft":this.isNumeralChar(n.charAt(t-1))||e.preventDefault();break;case"ArrowRight":this.isNumeralChar(n.charAt(t))||e.preventDefault();break;case"Tab":case"Enter":s=this.validateValue(this.parseValue(n)),this.$refs.input.$el.value=this.formatValue(s),this.$refs.input.$el.setAttribute("aria-valuenow",s),this.updateModel(e,s);break;case"Backspace":if(e.preventDefault(),t===i){const i=n.charAt(t-1),{decimalCharIndex:r,decimalCharIndexWithoutPrefix:u}=this.getDecimalCharIndexes(n);if(this.isNumeralChar(i)){const e=this.getDecimalLength(n);if(this._group.test(i))this._group.lastIndex=0,s=n.slice(0,t-2)+n.slice(t-1);else if(this._decimal.test(i))this._decimal.lastIndex=0,e?this.$refs.input.$el.setSelectionRange(t-1,t-1):s=n.slice(0,t-1)+n.slice(t);else if(r>0&&t>r){const i=this.isDecimalMode()&&(this.minFractionDigits||0)<e?"":"0";s=n.slice(0,t-1)+i+n.slice(t)}else 1===u?(s=n.slice(0,t-1)+"0"+n.slice(t),s=this.parseValue(s)>0?s:""):s=n.slice(0,t-1)+n.slice(t)}this.updateValue(e,s,null,"delete-single")}else s=this.deleteRange(n,t,i),this.updateValue(e,s,null,"delete-range");break;case"Delete":if(e.preventDefault(),t===i){const i=n.charAt(t),{decimalCharIndex:r,decimalCharIndexWithoutPrefix:u}=this.getDecimalCharIndexes(n);if(this.isNumeralChar(i)){const e=this.getDecimalLength(n);if(this._group.test(i))this._group.lastIndex=0,s=n.slice(0,t)+n.slice(t+2);else if(this._decimal.test(i))this._decimal.lastIndex=0,e?this.$refs.input.$el.setSelectionRange(t+1,t+1):s=n.slice(0,t)+n.slice(t+1);else if(r>0&&t>r){const i=this.isDecimalMode()&&(this.minFractionDigits||0)<e?"":"0";s=n.slice(0,t)+i+n.slice(t+1)}else 1===u?(s=n.slice(0,t)+"0"+n.slice(t+1),s=this.parseValue(s)>0?s:""):s=n.slice(0,t)+n.slice(t+1)}this.updateValue(e,s,null,"delete-back-single")}else s=this.deleteRange(n,t,i),this.updateValue(e,s,null,"delete-range");break;case"Home":this.min&&(this.updateModel(e,this.min),e.preventDefault());break;case"End":this.max&&(this.updateModel(e,this.max),e.preventDefault())}},onInputKeyPress(e){if(this.readonly)return;e.preventDefault();let t=e.which||e.keyCode,i=String.fromCharCode(t);const n=this.isDecimalSign(i),s=this.isMinusSign(i);(48<=t&&t<=57||s||n)&&this.insert(e,i,{isDecimalSign:n,isMinusSign:s})},onPaste(e){e.preventDefault();let t=(e.clipboardData||window.clipboardData).getData("Text");if(t){let i=this.parseValue(t);null!=i&&this.insert(e,i.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 i=e.replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").search(this._decimal);return this._decimal.lastIndex=0,{decimalCharIndex:t,decimalCharIndexWithoutPrefix:i}},getCharIndexes(e){const t=e.search(this._decimal);this._decimal.lastIndex=0;const i=e.search(this._minusSign);this._minusSign.lastIndex=0;const n=e.search(this._suffix);this._suffix.lastIndex=0;const s=e.search(this._currency);return this._currency.lastIndex=0,{decimalCharIndex:t,minusCharIndex:i,suffixCharIndex:n,currencyCharIndex:s}},insert(e,t,i={isDecimalSign:!1,isMinusSign:!1}){const n=t.search(this._minusSign);if(this._minusSign.lastIndex=0,!this.allowMinusSign()&&-1!==n)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(i.isMinusSign)0===s&&(h=u,-1!==a&&0===r||(h=this.insertText(u,t,0,r)),this.updateValue(e,h,t,"insert"));else if(i.isDecimalSign)l>0&&s===l?this.updateValue(e,u,t,"insert"):(l>s&&l<r||-1===l&&this.maxFractionDigits)&&(h=this.insertText(u,t,s,r),this.updateValue(e,h,t,"insert"));else{const i=this.numberFormat.resolvedOptions().maximumFractionDigits,n=s!==r?"range-insert":"insert";if(l>0&&s>l){if(s+t.length-(l+1)<=i){const i=p>=s?p-1:o>=s?o:u.length;h=u.slice(0,s)+t+u.slice(s+t.length,i)+u.slice(i),this.updateValue(e,h,t,n)}}else h=this.insertText(u,t,s,r),this.updateValue(e,h,t,n)}},insertText(e,t,i,n){if(2===("."===t?t:t.split(".")).length){const s=e.slice(i,n).search(this._decimal);return this._decimal.lastIndex=0,s>0?e.slice(0,i)+this.formatValue(t)+e.slice(n):e||this.formatValue(t)}return n-i===e.length?this.formatValue(t):0===i?t+e.slice(n):n===e.length?e.slice(0,i)+t:e.slice(0,i)+t+e.slice(n)},deleteRange(e,t,i){let n;return n=i-t===e.length?"":0===t?e.slice(i):i===e.length?e.slice(0,t):e.slice(0,t)+e.slice(i),n},initCursor(){let e=this.$refs.input.$el.selectionStart,t=this.$refs.input.$el.value,i=t.length,n=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 u=e-1;for(;u>=0;){if(r=t.charAt(u),this.isNumeralChar(r)){n=u+s;break}u--}if(null!==n)this.$refs.input.$el.setSelectionRange(n+1,n+1);else{for(u=e;u<i;){if(r=t.charAt(u),this.isNumeralChar(r)){n=u+s;break}u++}null!==n&&this.$refs.input.$el.setSelectionRange(n,n)}return n||0},onInputClick(){const e=this.$refs.input.$el.value;this.readonly||e===i.getSelection()||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,i,n){let s=this.$refs.input.$el.value,r=null;null!=t&&(r=this.parseValue(t),r=r||this.allowEmpty?r:0,this.updateInput(r,i,n,t),this.handleOnInput(e,s,r))},handleOnInput(e,t,i){this.isValueChanged(t,i)&&this.$emit("input",{originalEvent:e,value:i,formattedValue:t})},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,i,n){t=t||"";let s=this.$refs.input.$el.value,r=this.formatValue(e),u=s.length;if(r!==n&&(r=this.concatValues(r,n)),0===u){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,n=this.$refs.input.$el.selectionEnd;this.$refs.input.$el.value=r;let l=r.length;if("range-insert"===i){const i=this.parseValue((s||"").slice(0,e)),u=(null!==i?i.toString():"").split("").join(`(${this.groupChar})?`),l=new RegExp(u,"g");l.test(r);const a=t.split("").join(`(${this.groupChar})?`),o=new RegExp(a,"g");o.test(r.slice(l.lastIndex)),n=l.lastIndex+o.lastIndex,this.$refs.input.$el.setSelectionRange(n,n)}else if(l===u)"insert"===i||"delete-back-single"===i?this.$refs.input.$el.setSelectionRange(n+1,n+1):"delete-single"===i?this.$refs.input.$el.setSelectionRange(n-1,n-1):"delete-range"!==i&&"spin"!==i||this.$refs.input.$el.setSelectionRange(n,n);else if("delete-back-single"===i){let e=s.charAt(n-1),t=s.charAt(n),i=u-l,r=this._group.test(t);r&&1===i?n+=1:!r&&this.isNumeralChar(e)&&(n+=-1*i+1),this._group.lastIndex=0,this.$refs.input.$el.setSelectionRange(n,n)}else if("-"===s&&"insert"===i){this.$refs.input.$el.setSelectionRange(0,0);const e=this.initCursor()+t.length+1;this.$refs.input.$el.setSelectionRange(e,e)}else n+=l-u,this.$refs.input.$el.setSelectionRange(n,n)}this.$refs.input.$el.setAttribute("aria-valuenow",e)},concatValues(e,t){if(e&&t){let i=t.search(this._decimal);return this._decimal.lastIndex=0,this.suffixChar?e.replace(this.suffixChar,"").split(this._decimal)[0]+t.replace(this.suffixChar,"").slice(i)+this.suffixChar:-1!==i?e.split(this._decimal)[0]+t.slice(i):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.disabled||this.readonly||this.$refs.input.$el.value===i.getSelection()||!this.highlightOnFocus||e.target.select(),this.$emit("focus",e)},onInputBlur(e){this.focused=!1;let t=e.target,i=this.validateValue(this.parseValue(t.value));this.$emit("blur",{originalEvent:e,value:t.value}),t.value=this.formatValue(i),t.setAttribute("aria-valuenow",i),this.updateModel(e,i)},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",{"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:t,INButton:e}};const d={key:0,class:"p-inputnumber-button-group"};!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===i&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}("\n.p-inputnumber {\n display: inline-flex;\n}\n.p-inputnumber-button {\n display: flex;\n align-items: center;\n justify-content: center;\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: flex;\n flex-direction: column;\n}\n.p-inputnumber-buttons-stacked .p-inputnumber-button-group .p-button.p-inputnumber-button {\n flex: 1 1 auto;\n}\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-up {\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 order: 2;\n border-radius: 0;\n}\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-down {\n order: 1;\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n.p-inputnumber-buttons-vertical {\n flex-direction: column;\n}\n.p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-up {\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 order: 2;\n border-radius: 0;\n text-align: center;\n}\n.p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-down {\n order: 3;\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n width: 100%;\n}\n.p-inputnumber-input {\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(e,t,i,c,m,f){const g=n("INInputText"),b=n("INButton");return s(),r("span",{class:u(f.containerClass)},[l(g,a({ref:"input",id:i.inputId,class:["p-inputnumber-input",i.inputClass],role:"spinbutton",style:i.inputStyle,value:f.formattedValue,"aria-valuemin":i.min,"aria-valuemax":i.max,"aria-valuenow":i.modelValue,disabled:i.disabled,readonly:i.readonly,placeholder:i.placeholder,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,onInput:f.onUserInput,onKeydown:f.onInputKeyDown,onKeypress:f.onInputKeyPress,onPaste:f.onPaste,onClick:f.onInputClick,onFocus:f.onInputFocus,onBlur:f.onInputBlur},i.inputProps),null,16,["id","class","style","value","aria-valuemin","aria-valuemax","aria-valuenow","disabled","readonly","placeholder","aria-labelledby","aria-label","onInput","onKeydown","onKeypress","onPaste","onClick","onFocus","onBlur"]),i.showButtons&&"stacked"===i.buttonLayout?(s(),r("span",d,[l(b,a({class:f.upButtonClass,icon:i.incrementButtonIcon},o(f.upButtonListeners),{disabled:i.disabled,tabindex:-1,"aria-hidden":"true"},i.incrementButtonProps),null,16,["class","icon","disabled"]),l(b,a({class:f.downButtonClass,icon:i.decrementButtonIcon},o(f.downButtonListeners),{disabled:i.disabled,tabindex:-1,"aria-hidden":"true"},i.decrementButtonProps),null,16,["class","icon","disabled"])])):p("",!0),i.showButtons&&"stacked"!==i.buttonLayout?(s(),h(b,a({key:1,class:f.upButtonClass,icon:i.incrementButtonIcon},o(f.upButtonListeners),{disabled:i.disabled,tabindex:-1,"aria-hidden":"true"},i.incrementButtonProps),null,16,["class","icon","disabled"])):p("",!0),i.showButtons&&"stacked"!==i.buttonLayout?(s(),h(b,a({key:2,class:f.downButtonClass,icon:i.decrementButtonIcon},o(f.downButtonListeners),{disabled:i.disabled,tabindex:-1,"aria-hidden":"true"},i.decrementButtonProps),null,16,["class","icon","disabled"])):p("",!0)],2)};export{c as default};
1
+ import e from"primevue/button";import t from"primevue/inputtext";import{DomHandler as i}from"primevue/utils";import{resolveComponent as n,openBlock as s,createElementBlock as r,normalizeClass as u,createVNode as l,mergeProps as a,toHandlers as o,createCommentVNode as p,createBlock as h}from"vue";var c={name:"InputNumber",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},highlightOnFocus:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},placeholder:{type:String,default:null},inputId:{type:String,default:null},inputClass:{type:[String,Object],default:null},inputStyle:{type:Object,default:null},inputProps:{type:null,default:null},incrementButtonProps:{type:null,default:null},decrementButtonProps:{type:null,default:null},"aria-labelledby":{type:String,default:null},"aria-label":{type:String,default: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,i){if(this.readonly)return;let n=t||500;this.clearTimer(),this.timer=setTimeout((()=>{this.repeat(e,40,i)}),n),this.spin(e,i)},spin(e,t){if(this.$refs.input){let i=this.step*t,n=this.parseValue(this.$refs.input.$el.value)||0,s=this.validateValue(n+i);this.updateInput(s,null,"spin"),this.updateModel(e,s),this.handleOnInput(e,n,s)}},onUpButtonMouseDown(e){this.disabled||(this.$refs.input.$el.focus(),this.repeat(e,null,1),e.preventDefault())},onUpButtonMouseUp(){this.disabled||this.clearTimer()},onUpButtonMouseLeave(){this.disabled||this.clearTimer()},onUpButtonKeyUp(){this.disabled||this.clearTimer()},onUpButtonKeyDown(e){32!==e.keyCode&&13!==e.keyCode||this.repeat(e,null,1)},onDownButtonMouseDown(e){this.disabled||(this.$refs.input.$el.focus(),this.repeat(e,null,-1),e.preventDefault())},onDownButtonMouseUp(){this.disabled||this.clearTimer()},onDownButtonMouseLeave(){this.disabled||this.clearTimer()},onDownButtonKeyUp(){this.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,i=e.target.selectionEnd,n=e.target.value,s=null;switch(e.altKey&&e.preventDefault(),e.code){case"ArrowUp":this.spin(e,1),e.preventDefault();break;case"ArrowDown":this.spin(e,-1),e.preventDefault();break;case"ArrowLeft":this.isNumeralChar(n.charAt(t-1))||e.preventDefault();break;case"ArrowRight":this.isNumeralChar(n.charAt(t))||e.preventDefault();break;case"Tab":case"Enter":s=this.validateValue(this.parseValue(n)),this.$refs.input.$el.value=this.formatValue(s),this.$refs.input.$el.setAttribute("aria-valuenow",s),this.updateModel(e,s);break;case"Backspace":if(e.preventDefault(),t===i){const i=n.charAt(t-1),{decimalCharIndex:r,decimalCharIndexWithoutPrefix:u}=this.getDecimalCharIndexes(n);if(this.isNumeralChar(i)){const e=this.getDecimalLength(n);if(this._group.test(i))this._group.lastIndex=0,s=n.slice(0,t-2)+n.slice(t-1);else if(this._decimal.test(i))this._decimal.lastIndex=0,e?this.$refs.input.$el.setSelectionRange(t-1,t-1):s=n.slice(0,t-1)+n.slice(t);else if(r>0&&t>r){const i=this.isDecimalMode()&&(this.minFractionDigits||0)<e?"":"0";s=n.slice(0,t-1)+i+n.slice(t)}else 1===u?(s=n.slice(0,t-1)+"0"+n.slice(t),s=this.parseValue(s)>0?s:""):s=n.slice(0,t-1)+n.slice(t)}this.updateValue(e,s,null,"delete-single")}else s=this.deleteRange(n,t,i),this.updateValue(e,s,null,"delete-range");break;case"Delete":if(e.preventDefault(),t===i){const i=n.charAt(t),{decimalCharIndex:r,decimalCharIndexWithoutPrefix:u}=this.getDecimalCharIndexes(n);if(this.isNumeralChar(i)){const e=this.getDecimalLength(n);if(this._group.test(i))this._group.lastIndex=0,s=n.slice(0,t)+n.slice(t+2);else if(this._decimal.test(i))this._decimal.lastIndex=0,e?this.$refs.input.$el.setSelectionRange(t+1,t+1):s=n.slice(0,t)+n.slice(t+1);else if(r>0&&t>r){const i=this.isDecimalMode()&&(this.minFractionDigits||0)<e?"":"0";s=n.slice(0,t)+i+n.slice(t+1)}else 1===u?(s=n.slice(0,t)+"0"+n.slice(t+1),s=this.parseValue(s)>0?s:""):s=n.slice(0,t)+n.slice(t+1)}this.updateValue(e,s,null,"delete-back-single")}else s=this.deleteRange(n,t,i),this.updateValue(e,s,null,"delete-range");break;case"Home":this.min&&(this.updateModel(e,this.min),e.preventDefault());break;case"End":this.max&&(this.updateModel(e,this.max),e.preventDefault())}},onInputKeyPress(e){if(this.readonly)return;e.preventDefault();let t=e.which||e.keyCode,i=String.fromCharCode(t);const n=this.isDecimalSign(i),s=this.isMinusSign(i);(48<=t&&t<=57||s||n)&&this.insert(e,i,{isDecimalSign:n,isMinusSign:s})},onPaste(e){e.preventDefault();let t=(e.clipboardData||window.clipboardData).getData("Text");if(t){let i=this.parseValue(t);null!=i&&this.insert(e,i.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 i=e.replace(this._prefix,"").trim().replace(/\s/g,"").replace(this._currency,"").search(this._decimal);return this._decimal.lastIndex=0,{decimalCharIndex:t,decimalCharIndexWithoutPrefix:i}},getCharIndexes(e){const t=e.search(this._decimal);this._decimal.lastIndex=0;const i=e.search(this._minusSign);this._minusSign.lastIndex=0;const n=e.search(this._suffix);this._suffix.lastIndex=0;const s=e.search(this._currency);return this._currency.lastIndex=0,{decimalCharIndex:t,minusCharIndex:i,suffixCharIndex:n,currencyCharIndex:s}},insert(e,t,i={isDecimalSign:!1,isMinusSign:!1}){const n=t.search(this._minusSign);if(this._minusSign.lastIndex=0,!this.allowMinusSign()&&-1!==n)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(i.isMinusSign)0===s&&(h=u,-1!==a&&0===r||(h=this.insertText(u,t,0,r)),this.updateValue(e,h,t,"insert"));else if(i.isDecimalSign)l>0&&s===l?this.updateValue(e,u,t,"insert"):(l>s&&l<r||-1===l&&this.maxFractionDigits)&&(h=this.insertText(u,t,s,r),this.updateValue(e,h,t,"insert"));else{const i=this.numberFormat.resolvedOptions().maximumFractionDigits,n=s!==r?"range-insert":"insert";if(l>0&&s>l){if(s+t.length-(l+1)<=i){const i=p>=s?p-1:o>=s?o:u.length;h=u.slice(0,s)+t+u.slice(s+t.length,i)+u.slice(i),this.updateValue(e,h,t,n)}}else h=this.insertText(u,t,s,r),this.updateValue(e,h,t,n)}},insertText(e,t,i,n){if(2===("."===t?t:t.split(".")).length){const s=e.slice(i,n).search(this._decimal);return this._decimal.lastIndex=0,s>0?e.slice(0,i)+this.formatValue(t)+e.slice(n):e||this.formatValue(t)}return n-i===e.length?this.formatValue(t):0===i?t+e.slice(n):n===e.length?e.slice(0,i)+t:e.slice(0,i)+t+e.slice(n)},deleteRange(e,t,i){let n;return n=i-t===e.length?"":0===t?e.slice(i):i===e.length?e.slice(0,t):e.slice(0,t)+e.slice(i),n},initCursor(){let e=this.$refs.input.$el.selectionStart,t=this.$refs.input.$el.value,i=t.length,n=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 u=e-1;for(;u>=0;){if(r=t.charAt(u),this.isNumeralChar(r)){n=u+s;break}u--}if(null!==n)this.$refs.input.$el.setSelectionRange(n+1,n+1);else{for(u=e;u<i;){if(r=t.charAt(u),this.isNumeralChar(r)){n=u+s;break}u++}null!==n&&this.$refs.input.$el.setSelectionRange(n,n)}return n||0},onInputClick(){const e=this.$refs.input.$el.value;this.readonly||e===i.getSelection()||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,i,n){let s=this.$refs.input.$el.value,r=null;null!=t&&(r=this.parseValue(t),r=r||this.allowEmpty?r:0,this.updateInput(r,i,n,t),this.handleOnInput(e,s,r))},handleOnInput(e,t,i){this.isValueChanged(t,i)&&this.$emit("input",{originalEvent:e,value:i,formattedValue:t})},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,i,n){t=t||"";let s=this.$refs.input.$el.value,r=this.formatValue(e),u=s.length;if(r!==n&&(r=this.concatValues(r,n)),0===u){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,n=this.$refs.input.$el.selectionEnd;this.$refs.input.$el.value=r;let l=r.length;if("range-insert"===i){const i=this.parseValue((s||"").slice(0,e)),u=(null!==i?i.toString():"").split("").join(`(${this.groupChar})?`),l=new RegExp(u,"g");l.test(r);const a=t.split("").join(`(${this.groupChar})?`),o=new RegExp(a,"g");o.test(r.slice(l.lastIndex)),n=l.lastIndex+o.lastIndex,this.$refs.input.$el.setSelectionRange(n,n)}else if(l===u)"insert"===i||"delete-back-single"===i?this.$refs.input.$el.setSelectionRange(n+1,n+1):"delete-single"===i?this.$refs.input.$el.setSelectionRange(n-1,n-1):"delete-range"!==i&&"spin"!==i||this.$refs.input.$el.setSelectionRange(n,n);else if("delete-back-single"===i){let e=s.charAt(n-1),t=s.charAt(n),i=u-l,r=this._group.test(t);r&&1===i?n+=1:!r&&this.isNumeralChar(e)&&(n+=-1*i+1),this._group.lastIndex=0,this.$refs.input.$el.setSelectionRange(n,n)}else if("-"===s&&"insert"===i){this.$refs.input.$el.setSelectionRange(0,0);const e=this.initCursor()+t.length+1;this.$refs.input.$el.setSelectionRange(e,e)}else n+=l-u,this.$refs.input.$el.setSelectionRange(n,n)}this.$refs.input.$el.setAttribute("aria-valuenow",e)},concatValues(e,t){if(e&&t){let i=t.search(this._decimal);return this._decimal.lastIndex=0,this.suffixChar?e.replace(this.suffixChar,"").split(this._decimal)[0]+t.replace(this.suffixChar,"").slice(i)+this.suffixChar:-1!==i?e.split(this._decimal)[0]+t.slice(i):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.disabled||this.readonly||this.$refs.input.$el.value===i.getSelection()||!this.highlightOnFocus||e.target.select(),this.$emit("focus",e)},onInputBlur(e){this.focused=!1;let t=e.target,i=this.validateValue(this.parseValue(t.value));this.$emit("blur",{originalEvent:e,value:t.value}),t.value=this.formatValue(i),t.setAttribute("aria-valuenow",i),this.updateModel(e,i)},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",{"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:t,INButton:e}};const d={key:0,class:"p-inputnumber-button-group"};!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===i&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}("\n.p-inputnumber {\n display: inline-flex;\n}\n.p-inputnumber-button {\n display: flex;\n align-items: center;\n justify-content: center;\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: flex;\n flex-direction: column;\n}\n.p-inputnumber-buttons-stacked .p-inputnumber-button-group .p-button.p-inputnumber-button {\n flex: 1 1 auto;\n}\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-up {\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 order: 2;\n border-radius: 0;\n}\n.p-inputnumber-buttons-horizontal .p-button.p-inputnumber-button-down {\n order: 1;\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n}\n.p-inputnumber-buttons-vertical {\n flex-direction: column;\n}\n.p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-up {\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 order: 2;\n border-radius: 0;\n text-align: center;\n}\n.p-inputnumber-buttons-vertical .p-button.p-inputnumber-button-down {\n order: 3;\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n width: 100%;\n}\n.p-inputnumber-input {\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(e,t,i,c,m,f){const g=n("INInputText"),b=n("INButton");return s(),r("span",{class:u(f.containerClass)},[l(g,a({ref:"input",id:i.inputId,class:["p-inputnumber-input",i.inputClass],role:"spinbutton",style:i.inputStyle,value:f.formattedValue,"aria-valuemin":i.min,"aria-valuemax":i.max,"aria-valuenow":i.modelValue,disabled:i.disabled,readonly:i.readonly,placeholder:i.placeholder,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,onInput:f.onUserInput,onKeydown:f.onInputKeyDown,onKeypress:f.onInputKeyPress,onPaste:f.onPaste,onClick:f.onInputClick,onFocus:f.onInputFocus,onBlur:f.onInputBlur},i.inputProps),null,16,["id","class","style","value","aria-valuemin","aria-valuemax","aria-valuenow","disabled","readonly","placeholder","aria-labelledby","aria-label","onInput","onKeydown","onKeypress","onPaste","onClick","onFocus","onBlur"]),i.showButtons&&"stacked"===i.buttonLayout?(s(),r("span",d,[l(b,a({class:f.upButtonClass,icon:i.incrementButtonIcon},o(f.upButtonListeners),{disabled:i.disabled,tabindex:-1,"aria-hidden":"true"},i.incrementButtonProps),null,16,["class","icon","disabled"]),l(b,a({class:f.downButtonClass,icon:i.decrementButtonIcon},o(f.downButtonListeners),{disabled:i.disabled,tabindex:-1,"aria-hidden":"true"},i.decrementButtonProps),null,16,["class","icon","disabled"])])):p("",!0),i.showButtons&&"stacked"!==i.buttonLayout?(s(),h(b,a({key:1,class:f.upButtonClass,icon:i.incrementButtonIcon},o(f.upButtonListeners),{disabled:i.disabled,tabindex:-1,"aria-hidden":"true"},i.incrementButtonProps),null,16,["class","icon","disabled"])):p("",!0),i.showButtons&&"stacked"!==i.buttonLayout?(s(),h(b,a({key:2,class:f.downButtonClass,icon:i.decrementButtonIcon},o(f.downButtonListeners),{disabled:i.disabled,tabindex:-1,"aria-hidden":"true"},i.decrementButtonProps),null,16,["class","icon","disabled"])):p("",!0)],2)};export{c as default};