primevue 3.7.0 → 3.8.1

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 (229) hide show
  1. package/autocomplete/AutoComplete.d.ts +1 -0
  2. package/autocomplete/AutoComplete.vue +8 -1
  3. package/autocomplete/autocomplete.cjs.js +8 -1
  4. package/autocomplete/autocomplete.cjs.min.js +1 -1
  5. package/autocomplete/autocomplete.esm.js +8 -1
  6. package/autocomplete/autocomplete.esm.min.js +1 -1
  7. package/autocomplete/autocomplete.js +8 -1
  8. package/autocomplete/autocomplete.min.js +1 -1
  9. package/blockui/BlockUI.vue +1 -1
  10. package/blockui/blockui.cjs.js +1 -1
  11. package/blockui/blockui.cjs.min.js +1 -1
  12. package/blockui/blockui.esm.js +1 -1
  13. package/blockui/blockui.esm.min.js +1 -1
  14. package/blockui/blockui.js +1 -1
  15. package/blockui/blockui.min.js +1 -1
  16. package/breadcrumb/Breadcrumb.vue +4 -0
  17. package/breadcrumb/breadcrumb.cjs.js +1 -1
  18. package/breadcrumb/breadcrumb.cjs.min.js +1 -1
  19. package/breadcrumb/breadcrumb.esm.js +1 -1
  20. package/breadcrumb/breadcrumb.esm.min.js +1 -1
  21. package/breadcrumb/breadcrumb.js +1 -1
  22. package/breadcrumb/breadcrumb.min.js +1 -1
  23. package/confirmationservice/ConfirmationService.d.ts +3 -2
  24. package/core/core.js +7574 -0
  25. package/core/core.min.js +47 -0
  26. package/datatable/BodyCell.vue +36 -17
  27. package/datatable/ColumnFilter.vue +3 -3
  28. package/datatable/DataTable.d.ts +1 -1
  29. package/datatable/DataTable.vue +109 -69
  30. package/datatable/FooterCell.vue +2 -2
  31. package/datatable/HeaderCell.vue +2 -2
  32. package/datatable/TableBody.vue +10 -5
  33. package/datatable/TableFooter.vue +2 -1
  34. package/datatable/TableHeader.vue +3 -2
  35. package/datatable/datatable.cjs.js +192 -122
  36. package/datatable/datatable.cjs.min.js +1 -1
  37. package/datatable/datatable.esm.js +192 -122
  38. package/datatable/datatable.esm.min.js +1 -1
  39. package/datatable/datatable.js +192 -122
  40. package/datatable/datatable.min.js +1 -1
  41. package/dock/Dock.d.ts +1 -0
  42. package/dock/Dock.vue +1 -1
  43. package/dock/DockSub.vue +13 -8
  44. package/dock/dock.cjs.js +24 -10
  45. package/dock/dock.cjs.min.js +1 -1
  46. package/dock/dock.esm.js +20 -10
  47. package/dock/dock.esm.min.js +1 -1
  48. package/dock/dock.js +25 -12
  49. package/dock/dock.min.js +1 -1
  50. package/dropdown/Dropdown.vue +9 -8
  51. package/dropdown/dropdown.cjs.js +13 -11
  52. package/dropdown/dropdown.cjs.min.js +1 -1
  53. package/dropdown/dropdown.esm.js +13 -11
  54. package/dropdown/dropdown.esm.min.js +1 -1
  55. package/dropdown/dropdown.js +13 -11
  56. package/dropdown/dropdown.min.js +1 -1
  57. package/galleria/Galleria.vue +1 -0
  58. package/galleria/GalleriaContent.vue +10 -1
  59. package/galleria/galleria.cjs.js +11 -2
  60. package/galleria/galleria.cjs.min.js +1 -1
  61. package/galleria/galleria.esm.js +11 -2
  62. package/galleria/galleria.esm.min.js +1 -1
  63. package/galleria/galleria.js +11 -2
  64. package/galleria/galleria.min.js +1 -1
  65. package/inplace/Inplace.d.ts +1 -0
  66. package/inplace/Inplace.vue +12 -1
  67. package/inplace/inplace.cjs.js +13 -2
  68. package/inplace/inplace.cjs.min.js +1 -1
  69. package/inplace/inplace.esm.js +13 -2
  70. package/inplace/inplace.esm.min.js +1 -1
  71. package/inplace/inplace.js +13 -2
  72. package/inplace/inplace.min.js +1 -1
  73. package/inputnumber/InputNumber.d.ts +2 -0
  74. package/inputnumber/InputNumber.vue +84 -35
  75. package/inputnumber/inputnumber.cjs.js +84 -35
  76. package/inputnumber/inputnumber.cjs.min.js +1 -1
  77. package/inputnumber/inputnumber.esm.js +84 -35
  78. package/inputnumber/inputnumber.esm.min.js +1 -1
  79. package/inputnumber/inputnumber.js +84 -35
  80. package/inputnumber/inputnumber.min.js +1 -1
  81. package/inputswitch/InputSwitch.vue +6 -3
  82. package/inputswitch/inputswitch.cjs.js +6 -3
  83. package/inputswitch/inputswitch.cjs.min.js +1 -1
  84. package/inputswitch/inputswitch.esm.js +6 -3
  85. package/inputswitch/inputswitch.esm.min.js +1 -1
  86. package/inputswitch/inputswitch.js +6 -3
  87. package/inputswitch/inputswitch.min.js +1 -1
  88. package/knob/Knob.vue +1 -1
  89. package/knob/knob.cjs.js +1 -1
  90. package/knob/knob.esm.js +1 -1
  91. package/knob/knob.js +1 -1
  92. package/overlaypanel/OverlayPanel.d.ts +2 -0
  93. package/overlaypanel/OverlayPanel.vue +4 -1
  94. package/overlaypanel/overlaypanel.cjs.js +7 -3
  95. package/overlaypanel/overlaypanel.cjs.min.js +1 -1
  96. package/overlaypanel/overlaypanel.esm.js +7 -3
  97. package/overlaypanel/overlaypanel.esm.min.js +1 -1
  98. package/overlaypanel/overlaypanel.js +7 -3
  99. package/overlaypanel/overlaypanel.min.js +1 -1
  100. package/package.json +1 -1
  101. package/paginator/CurrentPageReport.vue +5 -1
  102. package/paginator/JumpToPageInput.vue +1 -1
  103. package/paginator/Paginator.vue +6 -3
  104. package/paginator/paginator.cjs.js +12 -4
  105. package/paginator/paginator.cjs.min.js +1 -1
  106. package/paginator/paginator.esm.js +12 -4
  107. package/paginator/paginator.esm.min.js +1 -1
  108. package/paginator/paginator.js +12 -4
  109. package/paginator/paginator.min.js +1 -1
  110. package/panelmenu/PanelMenuSub.vue +4 -4
  111. package/panelmenu/panelmenu.cjs.js +4 -4
  112. package/panelmenu/panelmenu.cjs.min.js +1 -1
  113. package/panelmenu/panelmenu.esm.js +4 -4
  114. package/panelmenu/panelmenu.esm.min.js +1 -1
  115. package/panelmenu/panelmenu.js +4 -4
  116. package/panelmenu/panelmenu.min.js +1 -1
  117. package/resources/primevue.css +3 -0
  118. package/resources/primevue.min.css +1 -1
  119. package/resources/themes/arya-blue/theme.css +6 -1
  120. package/resources/themes/arya-green/theme.css +6 -1
  121. package/resources/themes/arya-orange/theme.css +6 -1
  122. package/resources/themes/arya-purple/theme.css +6 -1
  123. package/resources/themes/bootstrap4-dark-blue/theme.css +6 -1
  124. package/resources/themes/bootstrap4-dark-purple/theme.css +6 -1
  125. package/resources/themes/bootstrap4-light-blue/theme.css +6 -1
  126. package/resources/themes/bootstrap4-light-purple/theme.css +6 -1
  127. package/resources/themes/fluent-light/theme.css +6 -1
  128. package/resources/themes/luna-amber/theme.css +6 -1
  129. package/resources/themes/luna-blue/theme.css +6 -1
  130. package/resources/themes/luna-green/theme.css +6 -1
  131. package/resources/themes/luna-pink/theme.css +6 -1
  132. package/resources/themes/md-dark-deeppurple/theme.css +6 -1
  133. package/resources/themes/md-dark-indigo/theme.css +6 -1
  134. package/resources/themes/md-light-deeppurple/theme.css +6 -1
  135. package/resources/themes/md-light-indigo/theme.css +6 -1
  136. package/resources/themes/mdc-dark-deeppurple/theme.css +6 -1
  137. package/resources/themes/mdc-dark-indigo/theme.css +6 -1
  138. package/resources/themes/mdc-light-deeppurple/theme.css +6 -1
  139. package/resources/themes/mdc-light-indigo/theme.css +6 -1
  140. package/resources/themes/nova/theme.css +6 -1
  141. package/resources/themes/nova-accent/theme.css +6 -1
  142. package/resources/themes/nova-alt/theme.css +6 -1
  143. package/resources/themes/nova-vue/theme.css +6 -1
  144. package/resources/themes/rhea/theme.css +6 -1
  145. package/resources/themes/saga-blue/theme.css +6 -1
  146. package/resources/themes/saga-green/theme.css +6 -1
  147. package/resources/themes/saga-orange/theme.css +6 -1
  148. package/resources/themes/saga-purple/theme.css +6 -1
  149. package/resources/themes/tailwind-light/fonts/Inter-Bold.woff +0 -0
  150. package/resources/themes/tailwind-light/fonts/Inter-Bold.woff2 +0 -0
  151. package/resources/themes/tailwind-light/fonts/Inter-Light.woff +0 -0
  152. package/resources/themes/tailwind-light/fonts/Inter-Light.woff2 +0 -0
  153. package/resources/themes/tailwind-light/fonts/Inter-Medium.woff +0 -0
  154. package/resources/themes/tailwind-light/fonts/Inter-Medium.woff2 +0 -0
  155. package/resources/themes/tailwind-light/fonts/Inter-Regular.woff +0 -0
  156. package/resources/themes/tailwind-light/fonts/Inter-Regular.woff2 +0 -0
  157. package/resources/themes/tailwind-light/fonts/Inter-SemiBold.woff +0 -0
  158. package/resources/themes/tailwind-light/fonts/Inter-SemiBold.woff2 +0 -0
  159. package/resources/themes/tailwind-light/theme.css +5440 -0
  160. package/resources/themes/vela-blue/theme.css +6 -1
  161. package/resources/themes/vela-green/theme.css +6 -1
  162. package/resources/themes/vela-orange/theme.css +6 -1
  163. package/resources/themes/vela-purple/theme.css +6 -1
  164. package/speeddial/SpeedDial.vue +2 -1
  165. package/speeddial/speeddial.cjs.js +2 -1
  166. package/speeddial/speeddial.cjs.min.js +1 -1
  167. package/speeddial/speeddial.esm.js +2 -1
  168. package/speeddial/speeddial.esm.min.js +1 -1
  169. package/speeddial/speeddial.js +2 -1
  170. package/speeddial/speeddial.min.js +1 -1
  171. package/splitter/Splitter.vue +5 -3
  172. package/splitter/splitter.cjs.js +4 -2
  173. package/splitter/splitter.cjs.min.js +1 -1
  174. package/splitter/splitter.esm.js +5 -3
  175. package/splitter/splitter.esm.min.js +1 -1
  176. package/splitter/splitter.js +4 -2
  177. package/splitter/splitter.min.js +1 -1
  178. package/tabmenu/TabMenu.vue +4 -0
  179. package/tabmenu/tabmenu.cjs.js +1 -1
  180. package/tabmenu/tabmenu.cjs.min.js +1 -1
  181. package/tabmenu/tabmenu.esm.js +1 -1
  182. package/tabmenu/tabmenu.esm.min.js +1 -1
  183. package/tabmenu/tabmenu.js +1 -1
  184. package/tabmenu/tabmenu.min.js +1 -1
  185. package/terminal/terminal.js +1 -1
  186. package/terminal/terminal.min.js +1 -1
  187. package/tieredmenu/TieredMenuSub.vue +1 -1
  188. package/tieredmenu/tieredmenu.cjs.js +1 -1
  189. package/tieredmenu/tieredmenu.cjs.min.js +1 -1
  190. package/tieredmenu/tieredmenu.esm.js +1 -1
  191. package/tieredmenu/tieredmenu.esm.min.js +1 -1
  192. package/tieredmenu/tieredmenu.js +1 -1
  193. package/tieredmenu/tieredmenu.min.js +1 -1
  194. package/toastservice/ToastService.d.ts +3 -2
  195. package/tooltip/tooltip.cjs.js +10 -3
  196. package/tooltip/tooltip.cjs.min.js +1 -1
  197. package/tooltip/tooltip.esm.js +10 -3
  198. package/tooltip/tooltip.esm.min.js +1 -1
  199. package/tooltip/tooltip.js +10 -3
  200. package/tooltip/tooltip.min.js +1 -1
  201. package/treetable/BodyCell.vue +2 -3
  202. package/treetable/FooterCell.vue +2 -2
  203. package/treetable/HeaderCell.vue +2 -2
  204. package/treetable/TreeTable.vue +2 -2
  205. package/treetable/TreeTableRow.vue +2 -2
  206. package/treetable/treetable.cjs.js +6 -6
  207. package/treetable/treetable.cjs.min.js +1 -1
  208. package/treetable/treetable.esm.js +7 -7
  209. package/treetable/treetable.esm.min.js +1 -1
  210. package/treetable/treetable.js +6 -6
  211. package/treetable/treetable.min.js +1 -1
  212. package/utils/Utils.d.ts +80 -0
  213. package/utils/package.json +3 -2
  214. package/utils/utils.cjs.js +126 -108
  215. package/utils/utils.cjs.min.js +1 -1
  216. package/utils/utils.esm.js +126 -108
  217. package/utils/utils.esm.min.js +1 -1
  218. package/utils/utils.js +126 -108
  219. package/utils/utils.min.js +1 -1
  220. package/vetur-attributes.json +12 -0
  221. package/vetur-tags.json +4 -1
  222. package/virtualscroller/VirtualScroller.vue +1 -1
  223. package/virtualscroller/virtualscroller.cjs.js +1 -1
  224. package/virtualscroller/virtualscroller.cjs.min.js +1 -1
  225. package/virtualscroller/virtualscroller.esm.js +1 -1
  226. package/virtualscroller/virtualscroller.esm.min.js +1 -1
  227. package/virtualscroller/virtualscroller.js +1 -1
  228. package/virtualscroller/virtualscroller.min.js +1 -1
  229. package/web-types.json +88 -5
@@ -104,6 +104,10 @@ export default {
104
104
  type: Number,
105
105
  default: 1
106
106
  },
107
+ allowEmpty: {
108
+ type: Boolean,
109
+ default: true
110
+ },
107
111
  style: null,
108
112
  class: null,
109
113
  inputStyle: null,
@@ -180,10 +184,10 @@ export default {
180
184
  const numerals = [...new Intl.NumberFormat(this.locale, {useGrouping: false}).format(9876543210)].reverse();
181
185
  const index = new Map(numerals.map((d, i) => [d, i]));
182
186
  this._numeral = new RegExp(`[${numerals.join('')}]`, 'g');
183
- this._decimal = this.getDecimalExpression();
184
187
  this._group = this.getGroupingExpression();
185
188
  this._minusSign = this.getMinusSignExpression();
186
189
  this._currency = this.getCurrencyExpression();
190
+ this._decimal = this.getDecimalExpression();
187
191
  this._suffix = this.getSuffixExpression();
188
192
  this._prefix = this.getPrefixExpression();
189
193
  this._index = d => index.get(d);
@@ -197,8 +201,8 @@ export default {
197
201
  return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
198
202
  },
199
203
  getDecimalExpression() {
200
- const formatter = new Intl.NumberFormat(this.locale, {useGrouping: false});
201
- return new RegExp(`[${formatter.format(1.1).trim().replace(this._numeral, '')}]`, 'g');
204
+ const formatter = new Intl.NumberFormat(this.locale, {...this.getOptions(), useGrouping: false});
205
+ return new RegExp(`[${formatter.format(1.1).replace(this._currency, '').trim().replace(this._numeral, '')}]`, 'g');
202
206
  },
203
207
  getGroupingExpression() {
204
208
  const formatter = new Intl.NumberFormat(this.locale, {useGrouping: true});
@@ -211,8 +215,9 @@ export default {
211
215
  },
212
216
  getCurrencyExpression() {
213
217
  if (this.currency) {
214
- const formatter = new Intl.NumberFormat(this.locale, {style: 'currency', currency: this.currency, currencyDisplay: this.currencyDisplay});
215
- return new RegExp(`[${formatter.format(1).replace(/\s/g, '').replace(this._numeral, '').replace(this._decimal, '').replace(this._group, '')}]`, 'g');
218
+ const formatter = new Intl.NumberFormat(this.locale, {style: 'currency', currency: this.currency, currencyDisplay: this.currencyDisplay,
219
+ minimumFractionDigits: 0, maximumFractionDigits: 0});
220
+ return new RegExp(`[${formatter.format(1).replace(/\s/g, '').replace(this._numeral, '').replace(this._group, '')}]`, 'g');
216
221
  }
217
222
 
218
223
  return new RegExp(`[]`,'g');
@@ -425,9 +430,8 @@ export default {
425
430
  event.preventDefault();
426
431
 
427
432
  if (selectionStart === selectionEnd) {
428
- let deleteChar = inputValue.charAt(selectionStart - 1);
429
- let decimalCharIndex = inputValue.search(this._decimal);
430
- this._decimal.lastIndex = 0;
433
+ const deleteChar = inputValue.charAt(selectionStart - 1);
434
+ const { decimalCharIndex, decimalCharIndexWithoutPrefix } = this.getDecimalCharIndexes(inputValue);
431
435
 
432
436
  if (this.isNumeralChar(deleteChar)) {
433
437
  const decimalLength = this.getDecimalLength(inputValue);
@@ -447,10 +451,10 @@ export default {
447
451
  }
448
452
  }
449
453
  else if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) {
450
- const insertedText = (this.minFractionDigits || 0) < decimalLength ? '' : '0';
454
+ const insertedText = this.isDecimalMode() && (this.minFractionDigits || 0) < decimalLength ? '' : '0';
451
455
  newValueStr = inputValue.slice(0, selectionStart - 1) + insertedText + inputValue.slice(selectionStart);
452
456
  }
453
- else if (decimalCharIndex > 0 && decimalCharIndex === 1) {
457
+ else if (decimalCharIndexWithoutPrefix === 1) {
454
458
  newValueStr = inputValue.slice(0, selectionStart - 1) + '0' + inputValue.slice(selectionStart);
455
459
  newValueStr = this.parseValue(newValueStr) > 0 ? newValueStr : '';
456
460
  }
@@ -474,9 +478,8 @@ export default {
474
478
  event.preventDefault();
475
479
 
476
480
  if (selectionStart === selectionEnd) {
477
- let deleteChar = inputValue.charAt(selectionStart);
478
- let decimalCharIndex = inputValue.search(this._decimal);
479
- this._decimal.lastIndex = 0;
481
+ const deleteChar = inputValue.charAt(selectionStart);
482
+ const { decimalCharIndex, decimalCharIndexWithoutPrefix } = this.getDecimalCharIndexes(inputValue);
480
483
 
481
484
  if (this.isNumeralChar(deleteChar)) {
482
485
  const decimalLength = this.getDecimalLength(inputValue);
@@ -496,10 +499,10 @@ export default {
496
499
  }
497
500
  }
498
501
  else if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) {
499
- const insertedText = (this.minFractionDigits || 0) < decimalLength ? '' : '0';
502
+ const insertedText = this.isDecimalMode() && (this.minFractionDigits || 0) < decimalLength ? '' : '0';
500
503
  newValueStr = inputValue.slice(0, selectionStart) + insertedText + inputValue.slice(selectionStart + 1);
501
504
  }
502
- else if (decimalCharIndex > 0 && decimalCharIndex === 1) {
505
+ else if (decimalCharIndexWithoutPrefix === 1) {
503
506
  newValueStr = inputValue.slice(0, selectionStart) + '0' + inputValue.slice(selectionStart + 1);
504
507
  newValueStr = this.parseValue(newValueStr) > 0 ? newValueStr : '';
505
508
  }
@@ -545,7 +548,7 @@ export default {
545
548
  return this.min === null || this.min < 0;
546
549
  },
547
550
  isMinusSign(char) {
548
- if (this._minusSign.test(char)) {
551
+ if (this._minusSign.test(char) || char === '-') {
549
552
  this._minusSign.lastIndex = 0;
550
553
  return true;
551
554
  }
@@ -560,6 +563,31 @@ export default {
560
563
 
561
564
  return false;
562
565
  },
566
+ isDecimalMode() {
567
+ return this.mode === 'decimal';
568
+ },
569
+ getDecimalCharIndexes(val) {
570
+ let decimalCharIndex = val.search(this._decimal);
571
+ this._decimal.lastIndex = 0;
572
+
573
+ const filteredVal = val.replace(this._prefix, '').trim().replace(/\s/g, '').replace(this._currency, '');
574
+ const decimalCharIndexWithoutPrefix = filteredVal.search(this._decimal);
575
+ this._decimal.lastIndex = 0;
576
+
577
+ return { decimalCharIndex, decimalCharIndexWithoutPrefix };
578
+ },
579
+ getCharIndexes(val) {
580
+ const decimalCharIndex = val.search(this._decimal);
581
+ this._decimal.lastIndex = 0;
582
+ const minusCharIndex = val.search(this._minusSign);
583
+ this._minusSign.lastIndex = 0;
584
+ const suffixCharIndex = val.search(this._suffix);
585
+ this._suffix.lastIndex = 0;
586
+ const currencyCharIndex = val.search(this._currency);
587
+ this._currency.lastIndex = 0;
588
+
589
+ return { decimalCharIndex, minusCharIndex, suffixCharIndex, currencyCharIndex };
590
+ },
563
591
  insert(event, text, sign = { isDecimalSign: false, isMinusSign: false }) {
564
592
  const minusCharIndexOnText = text.search(this._minusSign);
565
593
  this._minusSign.lastIndex = 0;
@@ -570,10 +598,7 @@ export default {
570
598
  const selectionStart = this.$refs.input.$el.selectionStart;
571
599
  const selectionEnd = this.$refs.input.$el.selectionEnd;
572
600
  let inputValue = this.$refs.input.$el.value.trim();
573
- const decimalCharIndex = inputValue.search(this._decimal);
574
- this._decimal.lastIndex = 0;
575
- const minusCharIndex = inputValue.search(this._minusSign);
576
- this._minusSign.lastIndex = 0;
601
+ const { decimalCharIndex, minusCharIndex, suffixCharIndex, currencyCharIndex } = this.getCharIndexes(inputValue);
577
602
  let newValueStr;
578
603
 
579
604
  if (sign.isMinusSign) {
@@ -605,7 +630,9 @@ export default {
605
630
 
606
631
  if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) {
607
632
  if ((selectionStart + text.length - (decimalCharIndex + 1)) <= maxFractionDigits) {
608
- newValueStr = inputValue.slice(0, selectionStart) + text + inputValue.slice(selectionStart + text.length);
633
+ const charIndex = currencyCharIndex >= selectionStart ? currencyCharIndex - 1 : (suffixCharIndex >= selectionStart ? suffixCharIndex : inputValue.length);
634
+
635
+ newValueStr = inputValue.slice(0, selectionStart) + text + inputValue.slice(selectionStart + text.length, charIndex) + inputValue.slice(charIndex);
609
636
  this.updateValue(event, newValueStr, text, operation);
610
637
  }
611
638
  }
@@ -656,9 +683,14 @@ export default {
656
683
  let valueLength = inputValue.length;
657
684
  let index = null;
658
685
 
686
+ // remove prefix
687
+ let prefixLength = (this.prefixChar || '').length;
688
+ inputValue = inputValue.replace(this._prefix, '');
689
+ selectionStart = selectionStart - prefixLength;
690
+
659
691
  let char = inputValue.charAt(selectionStart);
660
692
  if (this.isNumeralChar(char)) {
661
- return;
693
+ return selectionStart + prefixLength;
662
694
  }
663
695
 
664
696
  //left
@@ -666,7 +698,7 @@ export default {
666
698
  while (i >= 0) {
667
699
  char = inputValue.charAt(i);
668
700
  if (this.isNumeralChar(char)) {
669
- index = i;
701
+ index = i + prefixLength;
670
702
  break;
671
703
  }
672
704
  else {
@@ -678,11 +710,11 @@ export default {
678
710
  this.$refs.input.$el.setSelectionRange(index + 1, index + 1);
679
711
  }
680
712
  else {
681
- i = selectionStart + 1;
713
+ i = selectionStart;
682
714
  while (i < valueLength) {
683
715
  char = inputValue.charAt(i);
684
716
  if (this.isNumeralChar(char)) {
685
- index = i;
717
+ index = i + prefixLength;
686
718
  break;
687
719
  }
688
720
  else {
@@ -694,6 +726,8 @@ export default {
694
726
  this.$refs.input.$el.setSelectionRange(index, index);
695
727
  }
696
728
  }
729
+
730
+ return index || 0;
697
731
  },
698
732
  onInputClick() {
699
733
  this.initCursor();
@@ -718,6 +752,7 @@ export default {
718
752
 
719
753
  if (valueStr != null) {
720
754
  newValue = this.parseValue(valueStr);
755
+ newValue = !newValue && !this.allowEmpty ? 0 : newValue;
721
756
  this.updateInput(newValue, insertedValueStr, operation, valueStr);
722
757
 
723
758
  this.handleOnInput(event, currentValue, newValue);
@@ -741,6 +776,10 @@ export default {
741
776
  return false;
742
777
  },
743
778
  validateValue(value) {
779
+ if (value === '-' || value == null) {
780
+ return null;
781
+ }
782
+
744
783
  if (this.min != null && value < this.min) {
745
784
  return this.min;
746
785
  }
@@ -749,10 +788,6 @@ export default {
749
788
  return this.max;
750
789
  }
751
790
 
752
- if (value === '-') { // Minus sign
753
- return null;
754
- }
755
-
756
791
  return value;
757
792
  },
758
793
  updateInput(value, insertedValueStr, operation, valueStr) {
@@ -769,9 +804,8 @@ export default {
769
804
  if (currentLength === 0) {
770
805
  this.$refs.input.$el.value = newValue;
771
806
  this.$refs.input.$el.setSelectionRange(0, 0);
772
- this.initCursor();
773
- const prefixLength = (this.prefixChar || '').length;
774
- const selectionEnd = prefixLength + insertedValueStr.length;
807
+ const index = this.initCursor();
808
+ const selectionEnd = index + insertedValueStr.length;
775
809
  this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd);
776
810
  }
777
811
  else {
@@ -818,6 +852,12 @@ export default {
818
852
  this._group.lastIndex = 0;
819
853
  this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd);
820
854
  }
855
+ else if (inputValue === '-' && operation === 'insert') {
856
+ this.$refs.input.$el.setSelectionRange(0, 0);
857
+ const index = this.initCursor();
858
+ const selectionEnd = index + insertedValueStr.length + 1;
859
+ this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd);
860
+ }
821
861
  else {
822
862
  selectionEnd = selectionEnd + (newLength - currentLength);
823
863
  this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd);
@@ -831,7 +871,7 @@ export default {
831
871
  let decimalCharIndex = val2.search(this._decimal);
832
872
  this._decimal.lastIndex = 0;
833
873
 
834
- return val1.split(this._decimal)[0] + (decimalCharIndex !== -1 ? val2.slice(decimalCharIndex) : '');
874
+ return decimalCharIndex !== -1 ? (val1.split(this._decimal)[0] + val2.slice(decimalCharIndex)) : val1;
835
875
  }
836
876
 
837
877
  return val1;
@@ -840,7 +880,12 @@ export default {
840
880
  if (value) {
841
881
  const valueSplit = value.split(this._decimal);
842
882
 
843
- return valueSplit.length === 2 ? valueSplit[1].length : 0;
883
+ if (valueSplit.length === 2) {
884
+ return valueSplit[1].replace(this._suffix, '')
885
+ .trim()
886
+ .replace(/\s/g, '')
887
+ .replace(this._currency, '').length;
888
+ }
844
889
  }
845
890
 
846
891
  return 0;
@@ -904,7 +949,11 @@ export default {
904
949
  }
905
950
  },
906
951
  formattedValue() {
907
- return this.formatValue(this.modelValue);
952
+ const val = !this.modelValue && !this.allowEmpty ? 0 : this.modelValue;
953
+ return this.formatValue(val);
954
+ },
955
+ getFormatter() {
956
+ return this.numberFormat;
908
957
  }
909
958
  },
910
959
  components: {
@@ -98,6 +98,10 @@ var script = {
98
98
  type: Number,
99
99
  default: 1
100
100
  },
101
+ allowEmpty: {
102
+ type: Boolean,
103
+ default: true
104
+ },
101
105
  style: null,
102
106
  class: null,
103
107
  inputStyle: null,
@@ -174,10 +178,10 @@ var script = {
174
178
  const numerals = [...new Intl.NumberFormat(this.locale, {useGrouping: false}).format(9876543210)].reverse();
175
179
  const index = new Map(numerals.map((d, i) => [d, i]));
176
180
  this._numeral = new RegExp(`[${numerals.join('')}]`, 'g');
177
- this._decimal = this.getDecimalExpression();
178
181
  this._group = this.getGroupingExpression();
179
182
  this._minusSign = this.getMinusSignExpression();
180
183
  this._currency = this.getCurrencyExpression();
184
+ this._decimal = this.getDecimalExpression();
181
185
  this._suffix = this.getSuffixExpression();
182
186
  this._prefix = this.getPrefixExpression();
183
187
  this._index = d => index.get(d);
@@ -191,8 +195,8 @@ var script = {
191
195
  return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
192
196
  },
193
197
  getDecimalExpression() {
194
- const formatter = new Intl.NumberFormat(this.locale, {useGrouping: false});
195
- return new RegExp(`[${formatter.format(1.1).trim().replace(this._numeral, '')}]`, 'g');
198
+ const formatter = new Intl.NumberFormat(this.locale, {...this.getOptions(), useGrouping: false});
199
+ return new RegExp(`[${formatter.format(1.1).replace(this._currency, '').trim().replace(this._numeral, '')}]`, 'g');
196
200
  },
197
201
  getGroupingExpression() {
198
202
  const formatter = new Intl.NumberFormat(this.locale, {useGrouping: true});
@@ -205,8 +209,9 @@ var script = {
205
209
  },
206
210
  getCurrencyExpression() {
207
211
  if (this.currency) {
208
- const formatter = new Intl.NumberFormat(this.locale, {style: 'currency', currency: this.currency, currencyDisplay: this.currencyDisplay});
209
- return new RegExp(`[${formatter.format(1).replace(/\s/g, '').replace(this._numeral, '').replace(this._decimal, '').replace(this._group, '')}]`, 'g');
212
+ const formatter = new Intl.NumberFormat(this.locale, {style: 'currency', currency: this.currency, currencyDisplay: this.currencyDisplay,
213
+ minimumFractionDigits: 0, maximumFractionDigits: 0});
214
+ return new RegExp(`[${formatter.format(1).replace(/\s/g, '').replace(this._numeral, '').replace(this._group, '')}]`, 'g');
210
215
  }
211
216
 
212
217
  return new RegExp(`[]`,'g');
@@ -419,9 +424,8 @@ var script = {
419
424
  event.preventDefault();
420
425
 
421
426
  if (selectionStart === selectionEnd) {
422
- let deleteChar = inputValue.charAt(selectionStart - 1);
423
- let decimalCharIndex = inputValue.search(this._decimal);
424
- this._decimal.lastIndex = 0;
427
+ const deleteChar = inputValue.charAt(selectionStart - 1);
428
+ const { decimalCharIndex, decimalCharIndexWithoutPrefix } = this.getDecimalCharIndexes(inputValue);
425
429
 
426
430
  if (this.isNumeralChar(deleteChar)) {
427
431
  const decimalLength = this.getDecimalLength(inputValue);
@@ -441,10 +445,10 @@ var script = {
441
445
  }
442
446
  }
443
447
  else if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) {
444
- const insertedText = (this.minFractionDigits || 0) < decimalLength ? '' : '0';
448
+ const insertedText = this.isDecimalMode() && (this.minFractionDigits || 0) < decimalLength ? '' : '0';
445
449
  newValueStr = inputValue.slice(0, selectionStart - 1) + insertedText + inputValue.slice(selectionStart);
446
450
  }
447
- else if (decimalCharIndex > 0 && decimalCharIndex === 1) {
451
+ else if (decimalCharIndexWithoutPrefix === 1) {
448
452
  newValueStr = inputValue.slice(0, selectionStart - 1) + '0' + inputValue.slice(selectionStart);
449
453
  newValueStr = this.parseValue(newValueStr) > 0 ? newValueStr : '';
450
454
  }
@@ -468,9 +472,8 @@ var script = {
468
472
  event.preventDefault();
469
473
 
470
474
  if (selectionStart === selectionEnd) {
471
- let deleteChar = inputValue.charAt(selectionStart);
472
- let decimalCharIndex = inputValue.search(this._decimal);
473
- this._decimal.lastIndex = 0;
475
+ const deleteChar = inputValue.charAt(selectionStart);
476
+ const { decimalCharIndex, decimalCharIndexWithoutPrefix } = this.getDecimalCharIndexes(inputValue);
474
477
 
475
478
  if (this.isNumeralChar(deleteChar)) {
476
479
  const decimalLength = this.getDecimalLength(inputValue);
@@ -490,10 +493,10 @@ var script = {
490
493
  }
491
494
  }
492
495
  else if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) {
493
- const insertedText = (this.minFractionDigits || 0) < decimalLength ? '' : '0';
496
+ const insertedText = this.isDecimalMode() && (this.minFractionDigits || 0) < decimalLength ? '' : '0';
494
497
  newValueStr = inputValue.slice(0, selectionStart) + insertedText + inputValue.slice(selectionStart + 1);
495
498
  }
496
- else if (decimalCharIndex > 0 && decimalCharIndex === 1) {
499
+ else if (decimalCharIndexWithoutPrefix === 1) {
497
500
  newValueStr = inputValue.slice(0, selectionStart) + '0' + inputValue.slice(selectionStart + 1);
498
501
  newValueStr = this.parseValue(newValueStr) > 0 ? newValueStr : '';
499
502
  }
@@ -536,7 +539,7 @@ var script = {
536
539
  return this.min === null || this.min < 0;
537
540
  },
538
541
  isMinusSign(char) {
539
- if (this._minusSign.test(char)) {
542
+ if (this._minusSign.test(char) || char === '-') {
540
543
  this._minusSign.lastIndex = 0;
541
544
  return true;
542
545
  }
@@ -551,6 +554,31 @@ var script = {
551
554
 
552
555
  return false;
553
556
  },
557
+ isDecimalMode() {
558
+ return this.mode === 'decimal';
559
+ },
560
+ getDecimalCharIndexes(val) {
561
+ let decimalCharIndex = val.search(this._decimal);
562
+ this._decimal.lastIndex = 0;
563
+
564
+ const filteredVal = val.replace(this._prefix, '').trim().replace(/\s/g, '').replace(this._currency, '');
565
+ const decimalCharIndexWithoutPrefix = filteredVal.search(this._decimal);
566
+ this._decimal.lastIndex = 0;
567
+
568
+ return { decimalCharIndex, decimalCharIndexWithoutPrefix };
569
+ },
570
+ getCharIndexes(val) {
571
+ const decimalCharIndex = val.search(this._decimal);
572
+ this._decimal.lastIndex = 0;
573
+ const minusCharIndex = val.search(this._minusSign);
574
+ this._minusSign.lastIndex = 0;
575
+ const suffixCharIndex = val.search(this._suffix);
576
+ this._suffix.lastIndex = 0;
577
+ const currencyCharIndex = val.search(this._currency);
578
+ this._currency.lastIndex = 0;
579
+
580
+ return { decimalCharIndex, minusCharIndex, suffixCharIndex, currencyCharIndex };
581
+ },
554
582
  insert(event, text, sign = { isDecimalSign: false, isMinusSign: false }) {
555
583
  const minusCharIndexOnText = text.search(this._minusSign);
556
584
  this._minusSign.lastIndex = 0;
@@ -561,10 +589,7 @@ var script = {
561
589
  const selectionStart = this.$refs.input.$el.selectionStart;
562
590
  const selectionEnd = this.$refs.input.$el.selectionEnd;
563
591
  let inputValue = this.$refs.input.$el.value.trim();
564
- const decimalCharIndex = inputValue.search(this._decimal);
565
- this._decimal.lastIndex = 0;
566
- const minusCharIndex = inputValue.search(this._minusSign);
567
- this._minusSign.lastIndex = 0;
592
+ const { decimalCharIndex, minusCharIndex, suffixCharIndex, currencyCharIndex } = this.getCharIndexes(inputValue);
568
593
  let newValueStr;
569
594
 
570
595
  if (sign.isMinusSign) {
@@ -596,7 +621,9 @@ var script = {
596
621
 
597
622
  if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) {
598
623
  if ((selectionStart + text.length - (decimalCharIndex + 1)) <= maxFractionDigits) {
599
- newValueStr = inputValue.slice(0, selectionStart) + text + inputValue.slice(selectionStart + text.length);
624
+ const charIndex = currencyCharIndex >= selectionStart ? currencyCharIndex - 1 : (suffixCharIndex >= selectionStart ? suffixCharIndex : inputValue.length);
625
+
626
+ newValueStr = inputValue.slice(0, selectionStart) + text + inputValue.slice(selectionStart + text.length, charIndex) + inputValue.slice(charIndex);
600
627
  this.updateValue(event, newValueStr, text, operation);
601
628
  }
602
629
  }
@@ -647,9 +674,14 @@ var script = {
647
674
  let valueLength = inputValue.length;
648
675
  let index = null;
649
676
 
677
+ // remove prefix
678
+ let prefixLength = (this.prefixChar || '').length;
679
+ inputValue = inputValue.replace(this._prefix, '');
680
+ selectionStart = selectionStart - prefixLength;
681
+
650
682
  let char = inputValue.charAt(selectionStart);
651
683
  if (this.isNumeralChar(char)) {
652
- return;
684
+ return selectionStart + prefixLength;
653
685
  }
654
686
 
655
687
  //left
@@ -657,7 +689,7 @@ var script = {
657
689
  while (i >= 0) {
658
690
  char = inputValue.charAt(i);
659
691
  if (this.isNumeralChar(char)) {
660
- index = i;
692
+ index = i + prefixLength;
661
693
  break;
662
694
  }
663
695
  else {
@@ -669,11 +701,11 @@ var script = {
669
701
  this.$refs.input.$el.setSelectionRange(index + 1, index + 1);
670
702
  }
671
703
  else {
672
- i = selectionStart + 1;
704
+ i = selectionStart;
673
705
  while (i < valueLength) {
674
706
  char = inputValue.charAt(i);
675
707
  if (this.isNumeralChar(char)) {
676
- index = i;
708
+ index = i + prefixLength;
677
709
  break;
678
710
  }
679
711
  else {
@@ -685,6 +717,8 @@ var script = {
685
717
  this.$refs.input.$el.setSelectionRange(index, index);
686
718
  }
687
719
  }
720
+
721
+ return index || 0;
688
722
  },
689
723
  onInputClick() {
690
724
  this.initCursor();
@@ -709,6 +743,7 @@ var script = {
709
743
 
710
744
  if (valueStr != null) {
711
745
  newValue = this.parseValue(valueStr);
746
+ newValue = !newValue && !this.allowEmpty ? 0 : newValue;
712
747
  this.updateInput(newValue, insertedValueStr, operation, valueStr);
713
748
 
714
749
  this.handleOnInput(event, currentValue, newValue);
@@ -732,6 +767,10 @@ var script = {
732
767
  return false;
733
768
  },
734
769
  validateValue(value) {
770
+ if (value === '-' || value == null) {
771
+ return null;
772
+ }
773
+
735
774
  if (this.min != null && value < this.min) {
736
775
  return this.min;
737
776
  }
@@ -740,10 +779,6 @@ var script = {
740
779
  return this.max;
741
780
  }
742
781
 
743
- if (value === '-') { // Minus sign
744
- return null;
745
- }
746
-
747
782
  return value;
748
783
  },
749
784
  updateInput(value, insertedValueStr, operation, valueStr) {
@@ -760,9 +795,8 @@ var script = {
760
795
  if (currentLength === 0) {
761
796
  this.$refs.input.$el.value = newValue;
762
797
  this.$refs.input.$el.setSelectionRange(0, 0);
763
- this.initCursor();
764
- const prefixLength = (this.prefixChar || '').length;
765
- const selectionEnd = prefixLength + insertedValueStr.length;
798
+ const index = this.initCursor();
799
+ const selectionEnd = index + insertedValueStr.length;
766
800
  this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd);
767
801
  }
768
802
  else {
@@ -809,6 +843,12 @@ var script = {
809
843
  this._group.lastIndex = 0;
810
844
  this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd);
811
845
  }
846
+ else if (inputValue === '-' && operation === 'insert') {
847
+ this.$refs.input.$el.setSelectionRange(0, 0);
848
+ const index = this.initCursor();
849
+ const selectionEnd = index + insertedValueStr.length + 1;
850
+ this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd);
851
+ }
812
852
  else {
813
853
  selectionEnd = selectionEnd + (newLength - currentLength);
814
854
  this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd);
@@ -822,7 +862,7 @@ var script = {
822
862
  let decimalCharIndex = val2.search(this._decimal);
823
863
  this._decimal.lastIndex = 0;
824
864
 
825
- return val1.split(this._decimal)[0] + (decimalCharIndex !== -1 ? val2.slice(decimalCharIndex) : '');
865
+ return decimalCharIndex !== -1 ? (val1.split(this._decimal)[0] + val2.slice(decimalCharIndex)) : val1;
826
866
  }
827
867
 
828
868
  return val1;
@@ -831,7 +871,12 @@ var script = {
831
871
  if (value) {
832
872
  const valueSplit = value.split(this._decimal);
833
873
 
834
- return valueSplit.length === 2 ? valueSplit[1].length : 0;
874
+ if (valueSplit.length === 2) {
875
+ return valueSplit[1].replace(this._suffix, '')
876
+ .trim()
877
+ .replace(/\s/g, '')
878
+ .replace(this._currency, '').length;
879
+ }
835
880
  }
836
881
 
837
882
  return 0;
@@ -895,7 +940,11 @@ var script = {
895
940
  }
896
941
  },
897
942
  formattedValue() {
898
- return this.formatValue(this.modelValue);
943
+ const val = !this.modelValue && !this.allowEmpty ? 0 : this.modelValue;
944
+ return this.formatValue(val);
945
+ },
946
+ getFormatter() {
947
+ return this.numberFormat;
899
948
  }
900
949
  },
901
950
  components: {