ivt 0.5.4 → 0.5.6

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 (258) hide show
  1. package/dist/accordion/index.mjs +15 -15
  2. package/dist/accordion-table/index.d.ts +13 -0
  3. package/dist/accordion-table/index.mjs +120 -0
  4. package/dist/accordion-table/index.mjs.map +1 -0
  5. package/dist/alert/index.mjs +2 -2
  6. package/dist/alert/index.mjs.map +1 -1
  7. package/dist/alert-dialog/index.mjs +17 -17
  8. package/dist/aspect-ratio/index.mjs +1 -1
  9. package/dist/avatar/index.mjs +7 -7
  10. package/dist/badge/index.mjs +3 -3
  11. package/dist/base/index.d.ts +42 -42
  12. package/dist/base/index.mjs +153 -188
  13. package/dist/base/index.mjs.map +1 -1
  14. package/dist/breadcrumb/index.mjs +5 -5
  15. package/dist/button/index.d.ts +1 -1
  16. package/dist/button/index.mjs +3 -3
  17. package/dist/button-group/index.mjs +8 -7
  18. package/dist/button-group/index.mjs.map +1 -1
  19. package/dist/calendar/index.mjs +9 -9
  20. package/dist/card/index.mjs +3 -3
  21. package/dist/carousel/index.mjs +7 -6
  22. package/dist/carousel/index.mjs.map +1 -1
  23. package/dist/chart/index.mjs +8 -8
  24. package/dist/chart/index.mjs.map +1 -1
  25. package/dist/checkbox/index.mjs +14 -14
  26. package/dist/chunks/{CalendarRange-B0vBSe1u.mjs → CalendarRange-Bag_yGEQ.mjs} +8 -8
  27. package/dist/chunks/CalendarRange-Bag_yGEQ.mjs.map +1 -0
  28. package/dist/chunks/{ComboboxField-CKWceOtP.mjs → ComboboxField-BLTT982W.mjs} +9 -9
  29. package/dist/chunks/{ComboboxField-CKWceOtP.mjs.map → ComboboxField-BLTT982W.mjs.map} +1 -1
  30. package/dist/chunks/{Container-uWXsY1MM.mjs → Container-CDOK_e_b.mjs} +2 -2
  31. package/dist/chunks/{Container-uWXsY1MM.mjs.map → Container-CDOK_e_b.mjs.map} +1 -1
  32. package/dist/chunks/DeleteConfirmationModal-BUcMwZqw.mjs +43 -0
  33. package/dist/chunks/DeleteConfirmationModal-BUcMwZqw.mjs.map +1 -0
  34. package/dist/chunks/{TooltipIndicator-BWl3fjQ1.mjs → TooltipIndicator-B23VyuOv.mjs} +4 -4
  35. package/dist/chunks/{TooltipIndicator-BWl3fjQ1.mjs.map → TooltipIndicator-B23VyuOv.mjs.map} +1 -1
  36. package/dist/chunks/{_commonjsHelpers-B0eMPDMg.mjs → _commonjsHelpers-4KUcxYfY.mjs} +1 -1
  37. package/dist/chunks/_commonjsHelpers-4KUcxYfY.mjs.map +1 -0
  38. package/dist/chunks/{accordion-C3d17V52.mjs → accordion-Cz5ayAWy.mjs} +11 -11
  39. package/dist/chunks/{accordion-C3d17V52.mjs.map → accordion-Cz5ayAWy.mjs.map} +1 -1
  40. package/dist/chunks/{badge-DWYbCUyP.mjs → badge-DcTK-GBP.mjs} +2 -2
  41. package/dist/chunks/{badge-DWYbCUyP.mjs.map → badge-DcTK-GBP.mjs.map} +1 -1
  42. package/dist/chunks/{bundle-mjs-CoKIHeQ0.mjs → bundle-mjs-CGLhO34T.mjs} +1 -1
  43. package/dist/chunks/{bundle-mjs-CoKIHeQ0.mjs.map → bundle-mjs-CGLhO34T.mjs.map} +1 -1
  44. package/dist/chunks/{button-DjpHcHp9.mjs → button-D_MnAjQl.mjs} +2 -2
  45. package/dist/chunks/{button-DjpHcHp9.mjs.map → button-D_MnAjQl.mjs.map} +1 -1
  46. package/dist/chunks/{calendar-BMfsKJ1l.mjs → calendar-DGNoWQgo.mjs} +476 -476
  47. package/dist/chunks/{calendar-BMfsKJ1l.mjs.map → calendar-DGNoWQgo.mjs.map} +1 -1
  48. package/dist/chunks/{calendar-days-DHMYK4Tw.mjs → calendar-days-CGnc9ko6.mjs} +2 -2
  49. package/dist/chunks/{calendar-days-DHMYK4Tw.mjs.map → calendar-days-CGnc9ko6.mjs.map} +1 -1
  50. package/dist/chunks/{card-BSProxXx.mjs → card-DZ3filVx.mjs} +2 -2
  51. package/dist/chunks/{card-BSProxXx.mjs.map → card-DZ3filVx.mjs.map} +1 -1
  52. package/dist/chunks/{check-B7kxFwPv.mjs → check-DEf9V4Nh.mjs} +2 -2
  53. package/dist/chunks/{check-B7kxFwPv.mjs.map → check-DEf9V4Nh.mjs.map} +1 -1
  54. package/dist/chunks/{checkbox-Bu-YSWv-.mjs → checkbox-DjzhCYqW.mjs} +11 -11
  55. package/dist/chunks/{checkbox-Bu-YSWv-.mjs.map → checkbox-DjzhCYqW.mjs.map} +1 -1
  56. package/dist/chunks/{chevron-down-BgxaTVhM.mjs → chevron-down-CNWi6KOF.mjs} +2 -2
  57. package/dist/chunks/{chevron-down-BgxaTVhM.mjs.map → chevron-down-CNWi6KOF.mjs.map} +1 -1
  58. package/dist/chunks/{chevron-left-uXOOSe-Y.mjs → chevron-left-Cla2-kGr.mjs} +2 -2
  59. package/dist/chunks/{chevron-left-uXOOSe-Y.mjs.map → chevron-left-Cla2-kGr.mjs.map} +1 -1
  60. package/dist/chunks/{chevron-right-4COrIxgm.mjs → chevron-right-C3X2iYjh.mjs} +2 -2
  61. package/dist/chunks/{chevron-right-4COrIxgm.mjs.map → chevron-right-C3X2iYjh.mjs.map} +1 -1
  62. package/dist/chunks/{chevrons-up-down-RbRxw-hy.mjs → chevrons-up-down-Dcziczc9.mjs} +2 -2
  63. package/dist/chunks/{chevrons-up-down-RbRxw-hy.mjs.map → chevrons-up-down-Dcziczc9.mjs.map} +1 -1
  64. package/dist/chunks/{command-lo6019zL.mjs → command-c98KtQLr.mjs} +8 -8
  65. package/dist/chunks/{command-lo6019zL.mjs.map → command-c98KtQLr.mjs.map} +1 -1
  66. package/dist/chunks/{createLucideIcon-C9WZwMpD.mjs → createLucideIcon-BQUZb4BK.mjs} +1 -1
  67. package/dist/chunks/{createLucideIcon-C9WZwMpD.mjs.map → createLucideIcon-BQUZb4BK.mjs.map} +1 -1
  68. package/dist/chunks/{date-BElRaOeu.mjs → date-BX6jqpaN.mjs} +2 -2
  69. package/dist/chunks/{date-BElRaOeu.mjs.map → date-BX6jqpaN.mjs.map} +1 -1
  70. package/dist/chunks/{dialog-L5zjDv2Y.mjs → dialog-Bzks3Ko4.mjs} +4 -4
  71. package/dist/chunks/{dialog-L5zjDv2Y.mjs.map → dialog-Bzks3Ko4.mjs.map} +1 -1
  72. package/dist/chunks/{ellipsis-DCgrnXbv.mjs → ellipsis-S2vrEUTX.mjs} +2 -2
  73. package/dist/chunks/{ellipsis-DCgrnXbv.mjs.map → ellipsis-S2vrEUTX.mjs.map} +1 -1
  74. package/dist/chunks/{form-ByCrgzBl.mjs → form-CwxoZkN0.mjs} +3 -3
  75. package/dist/chunks/{form-ByCrgzBl.mjs.map → form-CwxoZkN0.mjs.map} +1 -1
  76. package/dist/chunks/{format-Bs2dFpMr.mjs → format-6LfcNksm.mjs} +1 -1
  77. package/dist/chunks/{format-Bs2dFpMr.mjs.map → format-6LfcNksm.mjs.map} +1 -1
  78. package/dist/chunks/{format-numbers-BdN4Rqeh.mjs → format-numbers-NnQQahT8.mjs} +2 -2
  79. package/dist/chunks/{format-numbers-BdN4Rqeh.mjs.map → format-numbers-NnQQahT8.mjs.map} +1 -1
  80. package/dist/chunks/{hover-card-Bbe5z9j5.mjs → hover-card-5rT-1QMh.mjs} +11 -11
  81. package/dist/chunks/{hover-card-Bbe5z9j5.mjs.map → hover-card-5rT-1QMh.mjs.map} +1 -1
  82. package/dist/chunks/{index-Bq9EFhxl.mjs → index-4TCt3gOI.mjs} +3 -3
  83. package/dist/chunks/{index-Bq9EFhxl.mjs.map → index-4TCt3gOI.mjs.map} +1 -1
  84. package/dist/chunks/{index-DrUrHRZs.mjs → index-6boixHzs.mjs} +2 -2
  85. package/dist/chunks/{index-DrUrHRZs.mjs.map → index-6boixHzs.mjs.map} +1 -1
  86. package/dist/chunks/{index-fRaHexiK.mjs → index-AKiXR0pZ.mjs} +1 -1
  87. package/dist/chunks/{index-fRaHexiK.mjs.map → index-AKiXR0pZ.mjs.map} +1 -1
  88. package/dist/chunks/{index-Dl81wvXL.mjs → index-B2gDNmb8.mjs} +5 -5
  89. package/dist/chunks/{index-Dl81wvXL.mjs.map → index-B2gDNmb8.mjs.map} +1 -1
  90. package/dist/chunks/{index-CQpTi7qI.mjs → index-BCbVqu_3.mjs} +2 -2
  91. package/dist/chunks/{index-CQpTi7qI.mjs.map → index-BCbVqu_3.mjs.map} +1 -1
  92. package/dist/chunks/{index-CwEcu8pU.mjs → index-BQ-TEa5d.mjs} +1 -1
  93. package/dist/chunks/{index-CwEcu8pU.mjs.map → index-BQ-TEa5d.mjs.map} +1 -1
  94. package/dist/chunks/{index-BjsM1T5G.mjs → index-BUvLOcM1.mjs} +1 -1
  95. package/dist/chunks/{index-BjsM1T5G.mjs.map → index-BUvLOcM1.mjs.map} +1 -1
  96. package/dist/chunks/{index-DzlFODVj.mjs → index-BWnbRXP-.mjs} +7 -7
  97. package/dist/chunks/{index-DzlFODVj.mjs.map → index-BWnbRXP-.mjs.map} +1 -1
  98. package/dist/chunks/{index-Bc-FW7nZ.mjs → index-BjgE_yhl.mjs} +3 -3
  99. package/dist/chunks/{index-Bc-FW7nZ.mjs.map → index-BjgE_yhl.mjs.map} +1 -1
  100. package/dist/chunks/{index-CvfYTVGA.mjs → index-BmDvd1mU.mjs} +11 -11
  101. package/dist/chunks/{index-CvfYTVGA.mjs.map → index-BmDvd1mU.mjs.map} +1 -1
  102. package/dist/chunks/{index-DN0JnhbV.mjs → index-BmW-kojJ.mjs} +1 -1
  103. package/dist/chunks/{index-DN0JnhbV.mjs.map → index-BmW-kojJ.mjs.map} +1 -1
  104. package/dist/chunks/{index-Bfrnl72r.mjs → index-CGiXQ4Pe.mjs} +9 -9
  105. package/dist/chunks/{index-Bfrnl72r.mjs.map → index-CGiXQ4Pe.mjs.map} +1 -1
  106. package/dist/chunks/{index-MaWketU2.mjs → index-CY5xJaha.mjs} +1 -1
  107. package/dist/chunks/{index-MaWketU2.mjs.map → index-CY5xJaha.mjs.map} +1 -1
  108. package/dist/chunks/{index-B1XP410K.mjs → index-C_z2VNWo.mjs} +1 -1
  109. package/dist/chunks/{index-B1XP410K.mjs.map → index-C_z2VNWo.mjs.map} +1 -1
  110. package/dist/chunks/{index-CtKpqYOz.mjs → index-Cq-A6c3g.mjs} +1 -1
  111. package/dist/chunks/{index-CtKpqYOz.mjs.map → index-Cq-A6c3g.mjs.map} +1 -1
  112. package/dist/chunks/{index-DLRElLW_.mjs → index-Cs_8Iu2P.mjs} +1 -1
  113. package/dist/chunks/{index-DLRElLW_.mjs.map → index-Cs_8Iu2P.mjs.map} +1 -1
  114. package/dist/chunks/{index-DhKLdikH.mjs → index-DLownQDQ.mjs} +2 -2
  115. package/dist/chunks/{index-DhKLdikH.mjs.map → index-DLownQDQ.mjs.map} +1 -1
  116. package/dist/chunks/{index-CZgR4Irq.mjs → index-DSLICNwF.mjs} +1 -1
  117. package/dist/chunks/{index-CZgR4Irq.mjs.map → index-DSLICNwF.mjs.map} +1 -1
  118. package/dist/chunks/{index-Xa5WcG48.mjs → index-DkGvxlDJ.mjs} +2 -2
  119. package/dist/chunks/{index-Xa5WcG48.mjs.map → index-DkGvxlDJ.mjs.map} +1 -1
  120. package/dist/chunks/{index-DKu_lrG6.mjs → index-M3WHAYcQ.mjs} +5 -5
  121. package/dist/chunks/{index-DKu_lrG6.mjs.map → index-M3WHAYcQ.mjs.map} +1 -1
  122. package/dist/chunks/{index--AWuc67S.mjs → index-T-_ESk_G.mjs} +1 -1
  123. package/dist/chunks/{index--AWuc67S.mjs.map → index-T-_ESk_G.mjs.map} +1 -1
  124. package/dist/chunks/{index-BRVK36i6.mjs → index-UxueW3GO.mjs} +15 -15
  125. package/dist/chunks/{index-BRVK36i6.mjs.map → index-UxueW3GO.mjs.map} +1 -1
  126. package/dist/chunks/{index-S03iE7cB.mjs → index-wAh1wx6m.mjs} +9 -9
  127. package/dist/chunks/{index-S03iE7cB.mjs.map → index-wAh1wx6m.mjs.map} +1 -1
  128. package/dist/chunks/{input-8lHYxogf.mjs → input-DKrW5tuu.mjs} +2 -2
  129. package/dist/chunks/{input-8lHYxogf.mjs.map → input-DKrW5tuu.mjs.map} +1 -1
  130. package/dist/chunks/{label-Coz7vbrD.mjs → label-BuC6aAG0.mjs} +3 -3
  131. package/dist/chunks/{label-Coz7vbrD.mjs.map → label-BuC6aAG0.mjs.map} +1 -1
  132. package/dist/chunks/{loader-circle-C79itZUV.mjs → loader-circle-Df9_-0g-.mjs} +2 -2
  133. package/dist/chunks/{loader-circle-C79itZUV.mjs.map → loader-circle-Df9_-0g-.mjs.map} +1 -1
  134. package/dist/chunks/{multi-select-DbkX5eJh.mjs → multi-select--jT_ewJI.mjs} +12 -12
  135. package/dist/chunks/{multi-select-DbkX5eJh.mjs.map → multi-select--jT_ewJI.mjs.map} +1 -1
  136. package/dist/chunks/{pagination-D1_ls69P.mjs → pagination-m1KTCwr8.mjs} +6 -6
  137. package/dist/chunks/{pagination-D1_ls69P.mjs.map → pagination-m1KTCwr8.mjs.map} +1 -1
  138. package/dist/chunks/{popover-CwZj8e8_.mjs → popover-n__dGmWJ.mjs} +13 -13
  139. package/dist/chunks/{popover-CwZj8e8_.mjs.map → popover-n__dGmWJ.mjs.map} +1 -1
  140. package/dist/chunks/{progress-CHeMS6C5.mjs → progress-DzHu9qd2.mjs} +4 -4
  141. package/dist/chunks/{progress-CHeMS6C5.mjs.map → progress-DzHu9qd2.mjs.map} +1 -1
  142. package/dist/chunks/react-number-format.es-CmBAGhhQ.mjs +1542 -0
  143. package/dist/chunks/react-number-format.es-CmBAGhhQ.mjs.map +1 -0
  144. package/dist/chunks/{scroll-area-DD_iSFs6.mjs → scroll-area-DDlmn7ag.mjs} +11 -11
  145. package/dist/chunks/{scroll-area-DD_iSFs6.mjs.map → scroll-area-DDlmn7ag.mjs.map} +1 -1
  146. package/dist/chunks/{select-CJd-Zy4C.mjs → select-BdW90s0k.mjs} +5 -5
  147. package/dist/chunks/{select-CJd-Zy4C.mjs.map → select-BdW90s0k.mjs.map} +1 -1
  148. package/dist/chunks/{separator-B-gxoRcb.mjs → separator-CkJ0LBlz.mjs} +3 -3
  149. package/dist/chunks/{separator-B-gxoRcb.mjs.map → separator-CkJ0LBlz.mjs.map} +1 -1
  150. package/dist/chunks/{sheet-D90WmOXg.mjs → sheet-BLsRYTsa.mjs} +4 -4
  151. package/dist/chunks/{sheet-D90WmOXg.mjs.map → sheet-BLsRYTsa.mjs.map} +1 -1
  152. package/dist/chunks/{skeleton-CJEOoSbM.mjs → skeleton-CGj35I4b.mjs} +2 -2
  153. package/dist/chunks/skeleton-CGj35I4b.mjs.map +1 -0
  154. package/dist/chunks/{sortable-DoZCl2bh.mjs → sortable-CxR7dghC.mjs} +3 -3
  155. package/dist/chunks/{sortable-DoZCl2bh.mjs.map → sortable-CxR7dghC.mjs.map} +1 -1
  156. package/dist/chunks/{table-D6yKv2LD.mjs → table-YJw4-dig.mjs} +2 -2
  157. package/dist/chunks/{table-D6yKv2LD.mjs.map → table-YJw4-dig.mjs.map} +1 -1
  158. package/dist/chunks/{textarea-BtDGDi6_.mjs → textarea-uqJyF5jY.mjs} +2 -2
  159. package/dist/chunks/{textarea-BtDGDi6_.mjs.map → textarea-uqJyF5jY.mjs.map} +1 -1
  160. package/dist/chunks/{toggle-gSLS96EJ.mjs → toggle-DnllXBCB.mjs} +5 -5
  161. package/dist/chunks/{toggle-gSLS96EJ.mjs.map → toggle-DnllXBCB.mjs.map} +1 -1
  162. package/dist/chunks/{tooltip-ikD2NXuw.mjs → tooltip-kXkkJZem.mjs} +13 -13
  163. package/dist/chunks/{tooltip-ikD2NXuw.mjs.map → tooltip-kXkkJZem.mjs.map} +1 -1
  164. package/dist/chunks/{trash-2-Dmk0bwIZ.mjs → trash-2-CJs96X7u.mjs} +2 -2
  165. package/dist/chunks/{trash-2-Dmk0bwIZ.mjs.map → trash-2-CJs96X7u.mjs.map} +1 -1
  166. package/dist/chunks/{triangle-alert-CdjPlo2e.mjs → triangle-alert-CW5j-i5O.mjs} +2 -2
  167. package/dist/chunks/{triangle-alert-CdjPlo2e.mjs.map → triangle-alert-CW5j-i5O.mjs.map} +1 -1
  168. package/dist/chunks/{tslib.es6-BG2RIc9b.mjs → tslib.es6-dqPUMt5Y.mjs} +1 -1
  169. package/dist/chunks/{tslib.es6-BG2RIc9b.mjs.map → tslib.es6-dqPUMt5Y.mjs.map} +1 -1
  170. package/dist/chunks/{utils-htJ3fJDn.mjs → utils-D8c5tyzG.mjs} +2 -2
  171. package/dist/chunks/{utils-htJ3fJDn.mjs.map → utils-D8c5tyzG.mjs.map} +1 -1
  172. package/dist/chunks/{x-DqJAQ42C.mjs → x-DYQCuAK0.mjs} +2 -2
  173. package/dist/chunks/{x-DqJAQ42C.mjs.map → x-DYQCuAK0.mjs.map} +1 -1
  174. package/dist/collapsible/index.mjs +9 -9
  175. package/dist/combobox/index.mjs +26 -26
  176. package/dist/command/index.d.ts +7 -7
  177. package/dist/command/index.mjs +20 -20
  178. package/dist/context-menu/index.mjs +23 -23
  179. package/dist/dash/index.d.ts +6 -6
  180. package/dist/dash/index.mjs +34 -34
  181. package/dist/dash/index.mjs.map +1 -1
  182. package/dist/data-table/index.d.ts +40 -40
  183. package/dist/data-table/index.mjs +208 -208
  184. package/dist/data-table/index.mjs.map +1 -1
  185. package/dist/date-picker/index.d.ts +1 -1
  186. package/dist/date-picker/index.mjs +27 -27
  187. package/dist/date-picker/index.mjs.map +1 -1
  188. package/dist/dialog/index.mjs +19 -19
  189. package/dist/drawer/index.mjs +16 -16
  190. package/dist/dropdown-menu/index.mjs +23 -23
  191. package/dist/dropdown-menu/index.mjs.map +1 -1
  192. package/dist/dropzone/index.mjs +193 -193
  193. package/dist/dropzone/index.mjs.map +1 -1
  194. package/dist/editable-table/index.d.ts +28 -0
  195. package/dist/editable-table/index.mjs +151 -0
  196. package/dist/editable-table/index.mjs.map +1 -0
  197. package/dist/empty/index.mjs +2 -2
  198. package/dist/empty/index.mjs.map +1 -1
  199. package/dist/field/index.mjs +8 -7
  200. package/dist/field/index.mjs.map +1 -1
  201. package/dist/form/index.mjs +5 -5
  202. package/dist/form-fields/index.mjs +28 -28
  203. package/dist/hover-card/index.mjs +15 -15
  204. package/dist/icon/index.mjs +1 -1
  205. package/dist/index.css +1 -1
  206. package/dist/input/index.mjs +3 -3
  207. package/dist/input-group/index.mjs +12 -9
  208. package/dist/input-group/index.mjs.map +1 -1
  209. package/dist/input-otp/index.mjs +3 -3
  210. package/dist/item/index.mjs +7 -6
  211. package/dist/item/index.mjs.map +1 -1
  212. package/dist/ivt.css +1 -1
  213. package/dist/kbd/index.mjs +2 -2
  214. package/dist/kbd/index.mjs.map +1 -1
  215. package/dist/label/index.mjs +4 -4
  216. package/dist/layout/index.mjs +6 -6
  217. package/dist/layout/index.mjs.map +1 -1
  218. package/dist/menubar/index.mjs +23 -23
  219. package/dist/multi-select/index.mjs +31 -31
  220. package/dist/navigation-menu/index.mjs +17 -17
  221. package/dist/pagination/index.d.ts +1 -1
  222. package/dist/pagination/index.mjs +8 -8
  223. package/dist/popover/index.mjs +18 -18
  224. package/dist/progress/index.mjs +5 -5
  225. package/dist/radio-group/index.mjs +17 -17
  226. package/dist/resizable/index.mjs +3 -3
  227. package/dist/scroll-area/index.mjs +12 -12
  228. package/dist/select/index.mjs +6 -6
  229. package/dist/separator/index.mjs +4 -4
  230. package/dist/shared/index.d.ts +1 -1
  231. package/dist/shared/index.mjs +6 -6
  232. package/dist/shared/index.mjs.map +1 -1
  233. package/dist/sheet/index.mjs +19 -19
  234. package/dist/sidebar/index.mjs +28 -28
  235. package/dist/sidebar/index.mjs.map +1 -1
  236. package/dist/skeleton/index.mjs +3 -3
  237. package/dist/skeleton-component/index.mjs +4 -4
  238. package/dist/skeleton-component/index.mjs.map +1 -1
  239. package/dist/slider/index.mjs +12 -12
  240. package/dist/sortable/index.mjs +4 -4
  241. package/dist/spinner/index.mjs +4 -4
  242. package/dist/switch/index.mjs +10 -10
  243. package/dist/table/index.mjs +3 -3
  244. package/dist/table-filter/index.d.ts +1 -1
  245. package/dist/table-filter/index.mjs +54 -1591
  246. package/dist/table-filter/index.mjs.map +1 -1
  247. package/dist/tabs/index.mjs +13 -13
  248. package/dist/tabs/index.mjs.map +1 -1
  249. package/dist/textarea/index.mjs +3 -3
  250. package/dist/toast/index.mjs +15 -15
  251. package/dist/toast/index.mjs.map +1 -1
  252. package/dist/toggle/index.mjs +7 -7
  253. package/dist/toggle-group/index.mjs +13 -13
  254. package/dist/tooltip/index.mjs +17 -17
  255. package/package.json +462 -454
  256. package/dist/chunks/CalendarRange-B0vBSe1u.mjs.map +0 -1
  257. package/dist/chunks/_commonjsHelpers-B0eMPDMg.mjs.map +0 -1
  258. package/dist/chunks/skeleton-CJEOoSbM.mjs.map +0 -1
@@ -0,0 +1,1542 @@
1
+ import React__default, { useRef, useState, useEffect, useLayoutEffect, useMemo } from 'react';
2
+
3
+ /******************************************************************************
4
+ Copyright (c) Microsoft Corporation.
5
+
6
+ Permission to use, copy, modify, and/or distribute this software for any
7
+ purpose with or without fee is hereby granted.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
16
+ ***************************************************************************** */ function __rest(s, e) {
17
+ var t = {};
18
+ for(var p in s){
19
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) {
20
+ t[p] = s[p];
21
+ }
22
+ }
23
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") {
24
+ for(var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++){
25
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) {
26
+ t[p[i]] = s[p[i]];
27
+ }
28
+ }
29
+ }
30
+ return t;
31
+ }
32
+ var SourceType;
33
+ (function(SourceType) {
34
+ SourceType["event"] = "event";
35
+ SourceType["props"] = "prop";
36
+ })(SourceType || (SourceType = {}));
37
+ // basic noop function
38
+ function noop() {}
39
+ function memoizeOnce(cb) {
40
+ var lastArgs;
41
+ var lastValue = undefined;
42
+ return function() {
43
+ var args = [], len = arguments.length;
44
+ while(len--)args[len] = arguments[len];
45
+ if (lastArgs && args.length === lastArgs.length && args.every(function(value, index) {
46
+ return value === lastArgs[index];
47
+ })) {
48
+ return lastValue;
49
+ }
50
+ lastArgs = args;
51
+ lastValue = cb.apply(void 0, args);
52
+ return lastValue;
53
+ };
54
+ }
55
+ function charIsNumber(char) {
56
+ return !!(char || '').match(/\d/);
57
+ }
58
+ function isNil(val) {
59
+ return val === null || val === undefined;
60
+ }
61
+ function isNanValue(val) {
62
+ return typeof val === 'number' && isNaN(val);
63
+ }
64
+ function isNotValidValue(val) {
65
+ return isNil(val) || isNanValue(val) || typeof val === 'number' && !isFinite(val);
66
+ }
67
+ function escapeRegExp(str) {
68
+ return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
69
+ }
70
+ function getThousandsGroupRegex(thousandsGroupStyle) {
71
+ switch(thousandsGroupStyle){
72
+ case 'lakh':
73
+ return /(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/g;
74
+ case 'wan':
75
+ return /(\d)(?=(\d{4})+(?!\d))/g;
76
+ case 'thousand':
77
+ default:
78
+ return /(\d)(?=(\d{3})+(?!\d))/g;
79
+ }
80
+ }
81
+ function applyThousandSeparator(str, thousandSeparator, thousandsGroupStyle) {
82
+ var thousandsGroupRegex = getThousandsGroupRegex(thousandsGroupStyle);
83
+ var index = str.search(/[1-9]/);
84
+ index = index === -1 ? str.length : index;
85
+ return str.substring(0, index) + str.substring(index, str.length).replace(thousandsGroupRegex, '$1' + thousandSeparator);
86
+ }
87
+ function usePersistentCallback(cb) {
88
+ var callbackRef = useRef(cb);
89
+ // keep the callback ref upto date
90
+ callbackRef.current = cb;
91
+ /**
92
+ * initialize a persistent callback which never changes
93
+ * through out the component lifecycle
94
+ */ var persistentCbRef = useRef(function() {
95
+ var args = [], len = arguments.length;
96
+ while(len--)args[len] = arguments[len];
97
+ return callbackRef.current.apply(callbackRef, args);
98
+ });
99
+ return persistentCbRef.current;
100
+ }
101
+ //spilt a float number into different parts beforeDecimal, afterDecimal, and negation
102
+ function splitDecimal(numStr, allowNegative) {
103
+ if (allowNegative === void 0) allowNegative = true;
104
+ var hasNegation = numStr[0] === '-';
105
+ var addNegation = hasNegation && allowNegative;
106
+ numStr = numStr.replace('-', '');
107
+ var parts = numStr.split('.');
108
+ var beforeDecimal = parts[0];
109
+ var afterDecimal = parts[1] || '';
110
+ return {
111
+ beforeDecimal: beforeDecimal,
112
+ afterDecimal: afterDecimal,
113
+ hasNegation: hasNegation,
114
+ addNegation: addNegation
115
+ };
116
+ }
117
+ function fixLeadingZero(numStr) {
118
+ if (!numStr) {
119
+ return numStr;
120
+ }
121
+ var isNegative = numStr[0] === '-';
122
+ if (isNegative) {
123
+ numStr = numStr.substring(1, numStr.length);
124
+ }
125
+ var parts = numStr.split('.');
126
+ var beforeDecimal = parts[0].replace(/^0+/, '') || '0';
127
+ var afterDecimal = parts[1] || '';
128
+ return "" + (isNegative ? '-' : '') + beforeDecimal + (afterDecimal ? "." + afterDecimal : '');
129
+ }
130
+ /**
131
+ * limit decimal numbers to given scale
132
+ * Not used .fixedTo because that will break with big numbers
133
+ */ function limitToScale(numStr, scale, fixedDecimalScale) {
134
+ var str = '';
135
+ var filler = fixedDecimalScale ? '0' : '';
136
+ for(var i = 0; i <= scale - 1; i++){
137
+ str += numStr[i] || filler;
138
+ }
139
+ return str;
140
+ }
141
+ function repeat(str, count) {
142
+ return Array(count + 1).join(str);
143
+ }
144
+ function toNumericString(num) {
145
+ var _num = num + ''; // typecast number to string
146
+ // store the sign and remove it from the number.
147
+ var sign = _num[0] === '-' ? '-' : '';
148
+ if (sign) {
149
+ _num = _num.substring(1);
150
+ }
151
+ // split the number into cofficient and exponent
152
+ var ref = _num.split(/[eE]/g);
153
+ var coefficient = ref[0];
154
+ var exponent = ref[1];
155
+ // covert exponent to number;
156
+ exponent = Number(exponent);
157
+ // if there is no exponent part or its 0, return the coffiecient with sign
158
+ if (!exponent) {
159
+ return sign + coefficient;
160
+ }
161
+ coefficient = coefficient.replace('.', '');
162
+ /**
163
+ * for scientific notation the current decimal index will be after first number (index 0)
164
+ * So effective decimal index will always be 1 + exponent value
165
+ */ var decimalIndex = 1 + exponent;
166
+ var coffiecientLn = coefficient.length;
167
+ if (decimalIndex < 0) {
168
+ // if decimal index is less then 0 add preceding 0s
169
+ // add 1 as join will have
170
+ coefficient = '0.' + repeat('0', Math.abs(decimalIndex)) + coefficient;
171
+ } else if (decimalIndex >= coffiecientLn) {
172
+ // if decimal index is less then 0 add leading 0s
173
+ coefficient = coefficient + repeat('0', decimalIndex - coffiecientLn);
174
+ } else {
175
+ // else add decimal point at proper index
176
+ coefficient = (coefficient.substring(0, decimalIndex) || '0') + '.' + coefficient.substring(decimalIndex);
177
+ }
178
+ return sign + coefficient;
179
+ }
180
+ /**
181
+ * This method is required to round prop value to given scale.
182
+ * Not used .round or .fixedTo because that will break with big numbers
183
+ */ function roundToPrecision(numStr, scale, fixedDecimalScale) {
184
+ //if number is empty don't do anything return empty string
185
+ if ([
186
+ '',
187
+ '-'
188
+ ].indexOf(numStr) !== -1) {
189
+ return numStr;
190
+ }
191
+ var shouldHaveDecimalSeparator = (numStr.indexOf('.') !== -1 || fixedDecimalScale) && scale;
192
+ var ref = splitDecimal(numStr);
193
+ var beforeDecimal = ref.beforeDecimal;
194
+ var afterDecimal = ref.afterDecimal;
195
+ var hasNegation = ref.hasNegation;
196
+ var floatValue = parseFloat("0." + (afterDecimal || '0'));
197
+ var floatValueStr = afterDecimal.length <= scale ? "0." + afterDecimal : floatValue.toFixed(scale);
198
+ var roundedDecimalParts = floatValueStr.split('.');
199
+ var intPart = beforeDecimal;
200
+ // if we have cary over from rounding decimal part, add that on before decimal
201
+ if (beforeDecimal && Number(roundedDecimalParts[0])) {
202
+ intPart = beforeDecimal.split('').reverse().reduce(function(roundedStr, current, idx) {
203
+ if (roundedStr.length > idx) {
204
+ return (Number(roundedStr[0]) + Number(current)).toString() + roundedStr.substring(1, roundedStr.length);
205
+ }
206
+ return current + roundedStr;
207
+ }, roundedDecimalParts[0]);
208
+ }
209
+ var decimalPart = limitToScale(roundedDecimalParts[1] || '', scale, fixedDecimalScale);
210
+ var negation = hasNegation ? '-' : '';
211
+ var decimalSeparator = shouldHaveDecimalSeparator ? '.' : '';
212
+ return "" + negation + intPart + decimalSeparator + decimalPart;
213
+ }
214
+ /** set the caret positon in an input field **/ function setCaretPosition(el, caretPos) {
215
+ el.value = el.value;
216
+ // ^ this is used to not only get 'focus', but
217
+ // to make sure we don't have it everything -selected-
218
+ // (it causes an issue in chrome, and having it doesn't hurt any other browser)
219
+ if (el !== null) {
220
+ /* @ts-ignore */ if (el.createTextRange) {
221
+ /* @ts-ignore */ var range = el.createTextRange();
222
+ range.move('character', caretPos);
223
+ range.select();
224
+ return true;
225
+ }
226
+ // (el.selectionStart === 0 added for Firefox bug)
227
+ if (el.selectionStart || el.selectionStart === 0) {
228
+ el.focus();
229
+ el.setSelectionRange(caretPos, caretPos);
230
+ return true;
231
+ }
232
+ // fail city, fortunately this never happens (as far as I've tested) :)
233
+ el.focus();
234
+ return false;
235
+ }
236
+ }
237
+ /**
238
+ * TODO: remove dependency of findChangeRange, findChangedRangeFromCaretPositions is better way to find what is changed
239
+ * currently this is mostly required by test and isCharacterSame util
240
+ * Given previous value and newValue it returns the index
241
+ * start - end to which values have changed.
242
+ * This function makes assumption about only consecutive
243
+ * characters are changed which is correct assumption for caret input.
244
+ */ var findChangeRange = memoizeOnce(function(prevValue, newValue) {
245
+ var i = 0, j = 0;
246
+ var prevLength = prevValue.length;
247
+ var newLength = newValue.length;
248
+ while(prevValue[i] === newValue[i] && i < prevLength){
249
+ i++;
250
+ }
251
+ //check what has been changed from last
252
+ while(prevValue[prevLength - 1 - j] === newValue[newLength - 1 - j] && newLength - j > i && prevLength - j > i){
253
+ j++;
254
+ }
255
+ return {
256
+ from: {
257
+ start: i,
258
+ end: prevLength - j
259
+ },
260
+ to: {
261
+ start: i,
262
+ end: newLength - j
263
+ }
264
+ };
265
+ });
266
+ var findChangedRangeFromCaretPositions = function(lastCaretPositions, currentCaretPosition) {
267
+ var startPosition = Math.min(lastCaretPositions.selectionStart, currentCaretPosition);
268
+ return {
269
+ from: {
270
+ start: startPosition,
271
+ end: lastCaretPositions.selectionEnd
272
+ },
273
+ to: {
274
+ start: startPosition,
275
+ end: currentCaretPosition
276
+ }
277
+ };
278
+ };
279
+ /*
280
+ Returns a number whose value is limited to the given range
281
+ */ function clamp(num, min, max) {
282
+ return Math.min(Math.max(num, min), max);
283
+ }
284
+ function geInputCaretPosition(el) {
285
+ /*Max of selectionStart and selectionEnd is taken for the patch of pixel and other mobile device caret bug*/ return Math.max(el.selectionStart, el.selectionEnd);
286
+ }
287
+ function addInputMode() {
288
+ return typeof navigator !== 'undefined' && !(navigator.platform && /iPhone|iPod/.test(navigator.platform));
289
+ }
290
+ function getDefaultChangeMeta(value) {
291
+ return {
292
+ from: {
293
+ start: 0,
294
+ end: 0
295
+ },
296
+ to: {
297
+ start: 0,
298
+ end: value.length
299
+ },
300
+ lastValue: ''
301
+ };
302
+ }
303
+ function getMaskAtIndex(mask, index) {
304
+ if (mask === void 0) mask = ' ';
305
+ if (typeof mask === 'string') {
306
+ return mask;
307
+ }
308
+ return mask[index] || ' ';
309
+ }
310
+ function defaultIsCharacterSame(ref) {
311
+ var currentValue = ref.currentValue;
312
+ var formattedValue = ref.formattedValue;
313
+ var currentValueIndex = ref.currentValueIndex;
314
+ var formattedValueIndex = ref.formattedValueIndex;
315
+ return currentValue[currentValueIndex] === formattedValue[formattedValueIndex];
316
+ }
317
+ function getCaretPosition(newFormattedValue, lastFormattedValue, curValue, curCaretPos, boundary, isValidInputCharacter, /**
318
+ * format function can change the character, the caret engine relies on mapping old value and new value
319
+ * In such case if character is changed, parent can tell which chars are equivalent
320
+ * Some example, all allowedDecimalCharacters are updated to decimalCharacters, 2nd case if user is coverting
321
+ * number to different numeric system.
322
+ */ isCharacterSame) {
323
+ if (isCharacterSame === void 0) isCharacterSame = defaultIsCharacterSame;
324
+ /**
325
+ * if something got inserted on empty value, add the formatted character before the current value,
326
+ * This is to avoid the case where typed character is present on format characters
327
+ */ var firstAllowedPosition = boundary.findIndex(function(b) {
328
+ return b;
329
+ });
330
+ var prefixFormat = newFormattedValue.slice(0, firstAllowedPosition);
331
+ if (!lastFormattedValue && !curValue.startsWith(prefixFormat)) {
332
+ lastFormattedValue = prefixFormat;
333
+ curValue = prefixFormat + curValue;
334
+ curCaretPos = curCaretPos + prefixFormat.length;
335
+ }
336
+ var curValLn = curValue.length;
337
+ var formattedValueLn = newFormattedValue.length;
338
+ // create index map
339
+ var addedIndexMap = {};
340
+ var indexMap = new Array(curValLn);
341
+ for(var i = 0; i < curValLn; i++){
342
+ indexMap[i] = -1;
343
+ for(var j = 0, jLn = formattedValueLn; j < jLn; j++){
344
+ var isCharSame = isCharacterSame({
345
+ currentValue: curValue,
346
+ lastValue: lastFormattedValue,
347
+ formattedValue: newFormattedValue,
348
+ currentValueIndex: i,
349
+ formattedValueIndex: j
350
+ });
351
+ if (isCharSame && addedIndexMap[j] !== true) {
352
+ indexMap[i] = j;
353
+ addedIndexMap[j] = true;
354
+ break;
355
+ }
356
+ }
357
+ }
358
+ /**
359
+ * For current caret position find closest characters (left and right side)
360
+ * which are properly mapped to formatted value.
361
+ * The idea is that the new caret position will exist always in the boundary of
362
+ * that mapped index
363
+ */ var pos = curCaretPos;
364
+ while(pos < curValLn && (indexMap[pos] === -1 || !isValidInputCharacter(curValue[pos]))){
365
+ pos++;
366
+ }
367
+ // if the caret position is on last keep the endIndex as last for formatted value
368
+ var endIndex = pos === curValLn || indexMap[pos] === -1 ? formattedValueLn : indexMap[pos];
369
+ pos = curCaretPos - 1;
370
+ while(pos > 0 && indexMap[pos] === -1){
371
+ pos--;
372
+ }
373
+ var startIndex = pos === -1 || indexMap[pos] === -1 ? 0 : indexMap[pos] + 1;
374
+ /**
375
+ * case where a char is added on suffix and removed from middle, example 2sq345 becoming $2,345 sq
376
+ * there is still a mapping but the order of start index and end index is changed
377
+ */ if (startIndex > endIndex) {
378
+ return endIndex;
379
+ }
380
+ /**
381
+ * given the current caret position if it closer to startIndex
382
+ * keep the new caret position on start index or keep it closer to endIndex
383
+ */ return curCaretPos - startIndex < endIndex - curCaretPos ? startIndex : endIndex;
384
+ }
385
+ /* This keeps the caret within typing area so people can't type in between prefix or suffix or format characters */ function getCaretPosInBoundary(value, caretPos, boundary, direction) {
386
+ var valLn = value.length;
387
+ // clamp caret position to [0, value.length]
388
+ caretPos = clamp(caretPos, 0, valLn);
389
+ if (direction === 'left') {
390
+ while(caretPos >= 0 && !boundary[caretPos]){
391
+ caretPos--;
392
+ }
393
+ // if we don't find any suitable caret position on left, set it on first allowed position
394
+ if (caretPos === -1) {
395
+ caretPos = boundary.indexOf(true);
396
+ }
397
+ } else {
398
+ while(caretPos <= valLn && !boundary[caretPos]){
399
+ caretPos++;
400
+ }
401
+ // if we don't find any suitable caret position on right, set it on last allowed position
402
+ if (caretPos > valLn) {
403
+ caretPos = boundary.lastIndexOf(true);
404
+ }
405
+ }
406
+ // if we still don't find caret position, set it at the end of value
407
+ if (caretPos === -1) {
408
+ caretPos = valLn;
409
+ }
410
+ return caretPos;
411
+ }
412
+ function caretUnknownFormatBoundary(formattedValue) {
413
+ var boundaryAry = Array.from({
414
+ length: formattedValue.length + 1
415
+ }).map(function() {
416
+ return true;
417
+ });
418
+ for(var i = 0, ln = boundaryAry.length; i < ln; i++){
419
+ // consider caret to be in boundary if it is before or after numeric value
420
+ boundaryAry[i] = Boolean(charIsNumber(formattedValue[i]) || charIsNumber(formattedValue[i - 1]));
421
+ }
422
+ return boundaryAry;
423
+ }
424
+ function useInternalValues(value, defaultValue, valueIsNumericString, format, removeFormatting, onValueChange) {
425
+ if (onValueChange === void 0) onValueChange = noop;
426
+ var getValues = usePersistentCallback(function(value, valueIsNumericString) {
427
+ var formattedValue, numAsString;
428
+ if (isNotValidValue(value)) {
429
+ numAsString = '';
430
+ formattedValue = '';
431
+ } else if (typeof value === 'number' || valueIsNumericString) {
432
+ numAsString = typeof value === 'number' ? toNumericString(value) : value;
433
+ formattedValue = format(numAsString);
434
+ } else {
435
+ numAsString = removeFormatting(value, undefined);
436
+ formattedValue = format(numAsString);
437
+ }
438
+ return {
439
+ formattedValue: formattedValue,
440
+ numAsString: numAsString
441
+ };
442
+ });
443
+ var ref = useState(function() {
444
+ return getValues(isNil(value) ? defaultValue : value, valueIsNumericString);
445
+ });
446
+ var values = ref[0];
447
+ var setValues = ref[1];
448
+ var _onValueChange = function(newValues, sourceInfo) {
449
+ if (newValues.formattedValue !== values.formattedValue) {
450
+ setValues({
451
+ formattedValue: newValues.formattedValue,
452
+ numAsString: newValues.value
453
+ });
454
+ }
455
+ // call parent on value change if only if formatted value is changed
456
+ onValueChange(newValues, sourceInfo);
457
+ };
458
+ // if value is switch from controlled to uncontrolled, use the internal state's value to format with new props
459
+ var _value = value;
460
+ var _valueIsNumericString = valueIsNumericString;
461
+ if (isNil(value)) {
462
+ _value = values.numAsString;
463
+ _valueIsNumericString = true;
464
+ }
465
+ var newValues = getValues(_value, _valueIsNumericString);
466
+ useMemo(function() {
467
+ setValues(newValues);
468
+ }, [
469
+ newValues.formattedValue
470
+ ]);
471
+ return [
472
+ values,
473
+ _onValueChange
474
+ ];
475
+ }
476
+ function defaultRemoveFormatting(value) {
477
+ return value.replace(/[^0-9]/g, '');
478
+ }
479
+ function defaultFormat(value) {
480
+ return value;
481
+ }
482
+ function NumberFormatBase(props) {
483
+ var type = props.type;
484
+ if (type === void 0) type = 'text';
485
+ var displayType = props.displayType;
486
+ if (displayType === void 0) displayType = 'input';
487
+ var customInput = props.customInput;
488
+ var renderText = props.renderText;
489
+ var getInputRef = props.getInputRef;
490
+ var format = props.format;
491
+ if (format === void 0) format = defaultFormat;
492
+ var removeFormatting = props.removeFormatting;
493
+ if (removeFormatting === void 0) removeFormatting = defaultRemoveFormatting;
494
+ var defaultValue = props.defaultValue;
495
+ var valueIsNumericString = props.valueIsNumericString;
496
+ var onValueChange = props.onValueChange;
497
+ var isAllowed = props.isAllowed;
498
+ var onChange = props.onChange;
499
+ if (onChange === void 0) onChange = noop;
500
+ var onKeyDown = props.onKeyDown;
501
+ if (onKeyDown === void 0) onKeyDown = noop;
502
+ var onMouseUp = props.onMouseUp;
503
+ if (onMouseUp === void 0) onMouseUp = noop;
504
+ var onFocus = props.onFocus;
505
+ if (onFocus === void 0) onFocus = noop;
506
+ var onBlur = props.onBlur;
507
+ if (onBlur === void 0) onBlur = noop;
508
+ var propValue = props.value;
509
+ var getCaretBoundary = props.getCaretBoundary;
510
+ if (getCaretBoundary === void 0) getCaretBoundary = caretUnknownFormatBoundary;
511
+ var isValidInputCharacter = props.isValidInputCharacter;
512
+ if (isValidInputCharacter === void 0) isValidInputCharacter = charIsNumber;
513
+ var isCharacterSame = props.isCharacterSame;
514
+ var otherProps = __rest(props, [
515
+ "type",
516
+ "displayType",
517
+ "customInput",
518
+ "renderText",
519
+ "getInputRef",
520
+ "format",
521
+ "removeFormatting",
522
+ "defaultValue",
523
+ "valueIsNumericString",
524
+ "onValueChange",
525
+ "isAllowed",
526
+ "onChange",
527
+ "onKeyDown",
528
+ "onMouseUp",
529
+ "onFocus",
530
+ "onBlur",
531
+ "value",
532
+ "getCaretBoundary",
533
+ "isValidInputCharacter",
534
+ "isCharacterSame"
535
+ ]);
536
+ var ref = useInternalValues(propValue, defaultValue, Boolean(valueIsNumericString), format, removeFormatting, onValueChange);
537
+ var ref_0 = ref[0];
538
+ var formattedValue = ref_0.formattedValue;
539
+ var numAsString = ref_0.numAsString;
540
+ var onFormattedValueChange = ref[1];
541
+ var caretPositionBeforeChange = useRef();
542
+ var lastUpdatedValue = useRef({
543
+ formattedValue: formattedValue,
544
+ numAsString: numAsString
545
+ });
546
+ var _onValueChange = function(values, source) {
547
+ lastUpdatedValue.current = {
548
+ formattedValue: values.formattedValue,
549
+ numAsString: values.value
550
+ };
551
+ onFormattedValueChange(values, source);
552
+ };
553
+ var ref$1 = useState(false);
554
+ var mounted = ref$1[0];
555
+ var setMounted = ref$1[1];
556
+ var focusedElm = useRef(null);
557
+ var timeout = useRef({
558
+ setCaretTimeout: null,
559
+ focusTimeout: null
560
+ });
561
+ useEffect(function() {
562
+ setMounted(true);
563
+ return function() {
564
+ clearTimeout(timeout.current.setCaretTimeout);
565
+ clearTimeout(timeout.current.focusTimeout);
566
+ };
567
+ }, []);
568
+ var _format = format;
569
+ var getValueObject = function(formattedValue, numAsString) {
570
+ var floatValue = parseFloat(numAsString);
571
+ return {
572
+ formattedValue: formattedValue,
573
+ value: numAsString,
574
+ floatValue: isNaN(floatValue) ? undefined : floatValue
575
+ };
576
+ };
577
+ var setPatchedCaretPosition = function(el, caretPos, currentValue) {
578
+ // don't reset the caret position when the whole input content is selected
579
+ if (el.selectionStart === 0 && el.selectionEnd === el.value.length) {
580
+ return;
581
+ }
582
+ /* setting caret position within timeout of 0ms is required for mobile chrome,
583
+ otherwise browser resets the caret position after we set it
584
+ We are also setting it without timeout so that in normal browser we don't see the flickering */ setCaretPosition(el, caretPos);
585
+ timeout.current.setCaretTimeout = setTimeout(function() {
586
+ if (el.value === currentValue && el.selectionStart !== caretPos) {
587
+ setCaretPosition(el, caretPos);
588
+ }
589
+ }, 0);
590
+ };
591
+ /* This keeps the caret within typing area so people can't type in between prefix or suffix */ var correctCaretPosition = function(value, caretPos, direction) {
592
+ return getCaretPosInBoundary(value, caretPos, getCaretBoundary(value), direction);
593
+ };
594
+ var getNewCaretPosition = function(inputValue, newFormattedValue, caretPos) {
595
+ var caretBoundary = getCaretBoundary(newFormattedValue);
596
+ var updatedCaretPos = getCaretPosition(newFormattedValue, formattedValue, inputValue, caretPos, caretBoundary, isValidInputCharacter, isCharacterSame);
597
+ //correct caret position if its outside of editable area
598
+ updatedCaretPos = getCaretPosInBoundary(newFormattedValue, updatedCaretPos, caretBoundary);
599
+ return updatedCaretPos;
600
+ };
601
+ var updateValueAndCaretPosition = function(params) {
602
+ var newFormattedValue = params.formattedValue;
603
+ if (newFormattedValue === void 0) newFormattedValue = '';
604
+ var input = params.input;
605
+ var source = params.source;
606
+ var event = params.event;
607
+ var numAsString = params.numAsString;
608
+ var caretPos;
609
+ if (input) {
610
+ var inputValue = params.inputValue || input.value;
611
+ var currentCaretPosition = geInputCaretPosition(input);
612
+ /**
613
+ * set the value imperatively, this is required for IE fix
614
+ * This is also required as if new caret position is beyond the previous value.
615
+ * Caret position will not be set correctly
616
+ */ input.value = newFormattedValue;
617
+ //get the caret position
618
+ caretPos = getNewCaretPosition(inputValue, newFormattedValue, currentCaretPosition);
619
+ //set caret position imperatively
620
+ if (caretPos !== undefined) {
621
+ setPatchedCaretPosition(input, caretPos, newFormattedValue);
622
+ }
623
+ }
624
+ if (newFormattedValue !== formattedValue) {
625
+ // trigger onValueChange synchronously, so parent is updated along with the number format. Fix for #277, #287
626
+ _onValueChange(getValueObject(newFormattedValue, numAsString), {
627
+ event: event,
628
+ source: source
629
+ });
630
+ }
631
+ };
632
+ /**
633
+ * if the formatted value is not synced to parent, or if the formatted value is different from last synced value sync it
634
+ * if the formatting props is removed, in which case last formatted value will be different from the numeric string value
635
+ * in such case we need to inform the parent.
636
+ */ useEffect(function() {
637
+ var ref = lastUpdatedValue.current;
638
+ var lastFormattedValue = ref.formattedValue;
639
+ var lastNumAsString = ref.numAsString;
640
+ if (formattedValue !== lastFormattedValue || numAsString !== lastNumAsString) {
641
+ _onValueChange(getValueObject(formattedValue, numAsString), {
642
+ event: undefined,
643
+ source: SourceType.props
644
+ });
645
+ }
646
+ }, [
647
+ formattedValue,
648
+ numAsString
649
+ ]);
650
+ // also if formatted value is changed from the props, we need to update the caret position
651
+ // keep the last caret position if element is focused
652
+ var currentCaretPosition = focusedElm.current ? geInputCaretPosition(focusedElm.current) : undefined;
653
+ // needed to prevent warning with useLayoutEffect on server
654
+ var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
655
+ useIsomorphicLayoutEffect(function() {
656
+ var input = focusedElm.current;
657
+ if (formattedValue !== lastUpdatedValue.current.formattedValue && input) {
658
+ var caretPos = getNewCaretPosition(lastUpdatedValue.current.formattedValue, formattedValue, currentCaretPosition);
659
+ /**
660
+ * set the value imperatively, as we set the caret position as well imperatively.
661
+ * This is to keep value and caret position in sync
662
+ */ input.value = formattedValue;
663
+ setPatchedCaretPosition(input, caretPos, formattedValue);
664
+ }
665
+ }, [
666
+ formattedValue
667
+ ]);
668
+ var formatInputValue = function(inputValue, event, source) {
669
+ var input = event.target;
670
+ var changeRange = caretPositionBeforeChange.current ? findChangedRangeFromCaretPositions(caretPositionBeforeChange.current, input.selectionEnd) : findChangeRange(formattedValue, inputValue);
671
+ var changeMeta = Object.assign(Object.assign({}, changeRange), {
672
+ lastValue: formattedValue
673
+ });
674
+ var _numAsString = removeFormatting(inputValue, changeMeta);
675
+ var _formattedValue = _format(_numAsString);
676
+ // formatting can remove some of the number chars, so we need to fine number string again
677
+ _numAsString = removeFormatting(_formattedValue, undefined);
678
+ if (isAllowed && !isAllowed(getValueObject(_formattedValue, _numAsString))) {
679
+ //reset the caret position
680
+ var input$1 = event.target;
681
+ var currentCaretPosition = geInputCaretPosition(input$1);
682
+ var caretPos = getNewCaretPosition(inputValue, formattedValue, currentCaretPosition);
683
+ input$1.value = formattedValue;
684
+ setPatchedCaretPosition(input$1, caretPos, formattedValue);
685
+ return false;
686
+ }
687
+ updateValueAndCaretPosition({
688
+ formattedValue: _formattedValue,
689
+ numAsString: _numAsString,
690
+ inputValue: inputValue,
691
+ event: event,
692
+ source: source,
693
+ input: event.target
694
+ });
695
+ return true;
696
+ };
697
+ var setCaretPositionInfoBeforeChange = function(el, endOffset) {
698
+ if (endOffset === void 0) endOffset = 0;
699
+ var selectionStart = el.selectionStart;
700
+ var selectionEnd = el.selectionEnd;
701
+ caretPositionBeforeChange.current = {
702
+ selectionStart: selectionStart,
703
+ selectionEnd: selectionEnd + endOffset
704
+ };
705
+ };
706
+ var _onChange = function(e) {
707
+ var el = e.target;
708
+ var inputValue = el.value;
709
+ var changed = formatInputValue(inputValue, e, SourceType.event);
710
+ if (changed) {
711
+ onChange(e);
712
+ }
713
+ // reset the position, as we have already handled the caret position
714
+ caretPositionBeforeChange.current = undefined;
715
+ };
716
+ var _onKeyDown = function(e) {
717
+ var el = e.target;
718
+ var key = e.key;
719
+ var selectionStart = el.selectionStart;
720
+ var selectionEnd = el.selectionEnd;
721
+ var value = el.value;
722
+ if (value === void 0) value = '';
723
+ var expectedCaretPosition;
724
+ //Handle backspace and delete against non numerical/decimal characters or arrow keys
725
+ if (key === 'ArrowLeft' || key === 'Backspace') {
726
+ expectedCaretPosition = Math.max(selectionStart - 1, 0);
727
+ } else if (key === 'ArrowRight') {
728
+ expectedCaretPosition = Math.min(selectionStart + 1, value.length);
729
+ } else if (key === 'Delete') {
730
+ expectedCaretPosition = selectionStart;
731
+ }
732
+ // if key is delete and text is not selected keep the end offset to 1, as it deletes one character
733
+ // this is required as selection is not changed on delete case, which changes the change range calculation
734
+ var endOffset = 0;
735
+ if (key === 'Delete' && selectionStart === selectionEnd) {
736
+ endOffset = 1;
737
+ }
738
+ var isArrowKey = key === 'ArrowLeft' || key === 'ArrowRight';
739
+ //if expectedCaretPosition is not set it means we don't want to Handle keyDown
740
+ // also if multiple characters are selected don't handle
741
+ if (expectedCaretPosition === undefined || selectionStart !== selectionEnd && !isArrowKey) {
742
+ onKeyDown(e);
743
+ // keep information of what was the caret position before keyDown
744
+ // set it after onKeyDown, in case parent updates the position manually
745
+ setCaretPositionInfoBeforeChange(el, endOffset);
746
+ return;
747
+ }
748
+ var newCaretPosition = expectedCaretPosition;
749
+ if (isArrowKey) {
750
+ var direction = key === 'ArrowLeft' ? 'left' : 'right';
751
+ newCaretPosition = correctCaretPosition(value, expectedCaretPosition, direction);
752
+ // arrow left or right only moves the caret, so no need to handle the event, if we are handling it manually
753
+ if (newCaretPosition !== expectedCaretPosition) {
754
+ e.preventDefault();
755
+ }
756
+ } else if (key === 'Delete' && !isValidInputCharacter(value[expectedCaretPosition])) {
757
+ // in case of delete go to closest caret boundary on the right side
758
+ newCaretPosition = correctCaretPosition(value, expectedCaretPosition, 'right');
759
+ } else if (key === 'Backspace' && !isValidInputCharacter(value[expectedCaretPosition])) {
760
+ // in case of backspace go to closest caret boundary on the left side
761
+ newCaretPosition = correctCaretPosition(value, expectedCaretPosition, 'left');
762
+ }
763
+ if (newCaretPosition !== expectedCaretPosition) {
764
+ setPatchedCaretPosition(el, newCaretPosition, value);
765
+ }
766
+ onKeyDown(e);
767
+ setCaretPositionInfoBeforeChange(el, endOffset);
768
+ };
769
+ /** required to handle the caret position when click anywhere within the input **/ var _onMouseUp = function(e) {
770
+ var el = e.target;
771
+ /**
772
+ * NOTE: we have to give default value for value as in case when custom input is provided
773
+ * value can come as undefined when nothing is provided on value prop.
774
+ */ var correctCaretPositionIfRequired = function() {
775
+ var selectionStart = el.selectionStart;
776
+ var selectionEnd = el.selectionEnd;
777
+ var value = el.value;
778
+ if (value === void 0) value = '';
779
+ if (selectionStart === selectionEnd) {
780
+ var caretPosition = correctCaretPosition(value, selectionStart);
781
+ if (caretPosition !== selectionStart) {
782
+ setPatchedCaretPosition(el, caretPosition, value);
783
+ }
784
+ }
785
+ };
786
+ correctCaretPositionIfRequired();
787
+ // try to correct after selection has updated by browser
788
+ // this case is required when user clicks on some position while a text is selected on input
789
+ requestAnimationFrame(function() {
790
+ correctCaretPositionIfRequired();
791
+ });
792
+ onMouseUp(e);
793
+ setCaretPositionInfoBeforeChange(el);
794
+ };
795
+ var _onFocus = function(e) {
796
+ // Workaround Chrome and Safari bug https://bugs.chromium.org/p/chromium/issues/detail?id=779328
797
+ // (onFocus event target selectionStart is always 0 before setTimeout)
798
+ if (e.persist) {
799
+ e.persist();
800
+ }
801
+ var el = e.target;
802
+ var currentTarget = e.currentTarget;
803
+ focusedElm.current = el;
804
+ timeout.current.focusTimeout = setTimeout(function() {
805
+ var selectionStart = el.selectionStart;
806
+ var selectionEnd = el.selectionEnd;
807
+ var value = el.value;
808
+ if (value === void 0) value = '';
809
+ var caretPosition = correctCaretPosition(value, selectionStart);
810
+ //setPatchedCaretPosition only when everything is not selected on focus (while tabbing into the field)
811
+ if (caretPosition !== selectionStart && !(selectionStart === 0 && selectionEnd === value.length)) {
812
+ setPatchedCaretPosition(el, caretPosition, value);
813
+ }
814
+ onFocus(Object.assign(Object.assign({}, e), {
815
+ currentTarget: currentTarget
816
+ }));
817
+ }, 0);
818
+ };
819
+ var _onBlur = function(e) {
820
+ focusedElm.current = null;
821
+ clearTimeout(timeout.current.focusTimeout);
822
+ clearTimeout(timeout.current.setCaretTimeout);
823
+ onBlur(e);
824
+ };
825
+ // add input mode on element based on format prop and device once the component is mounted
826
+ var inputMode = mounted && addInputMode() ? 'numeric' : undefined;
827
+ var inputProps = Object.assign({
828
+ inputMode: inputMode
829
+ }, otherProps, {
830
+ type: type,
831
+ value: formattedValue,
832
+ onChange: _onChange,
833
+ onKeyDown: _onKeyDown,
834
+ onMouseUp: _onMouseUp,
835
+ onFocus: _onFocus,
836
+ onBlur: _onBlur
837
+ });
838
+ if (displayType === 'text') {
839
+ return renderText ? React__default.createElement(React__default.Fragment, null, renderText(formattedValue, otherProps) || null) : React__default.createElement("span", Object.assign({}, otherProps, {
840
+ ref: getInputRef
841
+ }), formattedValue);
842
+ } else if (customInput) {
843
+ var CustomInput = customInput;
844
+ /* @ts-ignore */ return React__default.createElement(CustomInput, Object.assign({}, inputProps, {
845
+ ref: getInputRef
846
+ }));
847
+ }
848
+ return React__default.createElement("input", Object.assign({}, inputProps, {
849
+ ref: getInputRef
850
+ }));
851
+ }
852
+ function format(numStr, props) {
853
+ var decimalScale = props.decimalScale;
854
+ var fixedDecimalScale = props.fixedDecimalScale;
855
+ var prefix = props.prefix;
856
+ if (prefix === void 0) prefix = '';
857
+ var suffix = props.suffix;
858
+ if (suffix === void 0) suffix = '';
859
+ var allowNegative = props.allowNegative;
860
+ var thousandsGroupStyle = props.thousandsGroupStyle;
861
+ if (thousandsGroupStyle === void 0) thousandsGroupStyle = 'thousand';
862
+ // don't apply formatting on empty string or '-'
863
+ if (numStr === '' || numStr === '-') {
864
+ return numStr;
865
+ }
866
+ var ref = getSeparators(props);
867
+ var thousandSeparator = ref.thousandSeparator;
868
+ var decimalSeparator = ref.decimalSeparator;
869
+ /**
870
+ * Keep the decimal separator
871
+ * when decimalScale is not defined or non zero and the numStr has decimal in it
872
+ * Or if decimalScale is > 0 and fixeDecimalScale is true (even if numStr has no decimal)
873
+ */ var hasDecimalSeparator = decimalScale !== 0 && numStr.indexOf('.') !== -1 || decimalScale && fixedDecimalScale;
874
+ var ref$1 = splitDecimal(numStr, allowNegative);
875
+ var beforeDecimal = ref$1.beforeDecimal;
876
+ var afterDecimal = ref$1.afterDecimal;
877
+ var addNegation = ref$1.addNegation; // eslint-disable-line prefer-const
878
+ //apply decimal precision if its defined
879
+ if (decimalScale !== undefined) {
880
+ afterDecimal = limitToScale(afterDecimal, decimalScale, !!fixedDecimalScale);
881
+ }
882
+ if (thousandSeparator) {
883
+ beforeDecimal = applyThousandSeparator(beforeDecimal, thousandSeparator, thousandsGroupStyle);
884
+ }
885
+ //add prefix and suffix when there is a number present
886
+ if (prefix) {
887
+ beforeDecimal = prefix + beforeDecimal;
888
+ }
889
+ if (suffix) {
890
+ afterDecimal = afterDecimal + suffix;
891
+ }
892
+ //restore negation sign
893
+ if (addNegation) {
894
+ beforeDecimal = '-' + beforeDecimal;
895
+ }
896
+ numStr = beforeDecimal + (hasDecimalSeparator && decimalSeparator || '') + afterDecimal;
897
+ return numStr;
898
+ }
899
+ function getSeparators(props) {
900
+ var decimalSeparator = props.decimalSeparator;
901
+ if (decimalSeparator === void 0) decimalSeparator = '.';
902
+ var thousandSeparator = props.thousandSeparator;
903
+ var allowedDecimalSeparators = props.allowedDecimalSeparators;
904
+ if (thousandSeparator === true) {
905
+ thousandSeparator = ',';
906
+ }
907
+ if (!allowedDecimalSeparators) {
908
+ allowedDecimalSeparators = [
909
+ decimalSeparator,
910
+ '.'
911
+ ];
912
+ }
913
+ return {
914
+ decimalSeparator: decimalSeparator,
915
+ thousandSeparator: thousandSeparator,
916
+ allowedDecimalSeparators: allowedDecimalSeparators
917
+ };
918
+ }
919
+ function handleNegation(value, allowNegative) {
920
+ if (value === void 0) value = '';
921
+ var negationRegex = new RegExp('(-)');
922
+ var doubleNegationRegex = new RegExp('(-)(.)*(-)');
923
+ // Check number has '-' value
924
+ var hasNegation = negationRegex.test(value);
925
+ // Check number has 2 or more '-' values
926
+ var removeNegation = doubleNegationRegex.test(value);
927
+ //remove negation
928
+ value = value.replace(/-/g, '');
929
+ if (hasNegation && !removeNegation && allowNegative) {
930
+ value = '-' + value;
931
+ }
932
+ return value;
933
+ }
934
+ function getNumberRegex(decimalSeparator, global) {
935
+ return new RegExp("(^-)|[0-9]|" + escapeRegExp(decimalSeparator), 'g' );
936
+ }
937
+ function isNumericString(val, prefix, suffix) {
938
+ // for empty value we can always treat it as numeric string
939
+ if (val === '') {
940
+ return true;
941
+ }
942
+ return !(prefix === null || prefix === void 0 ? void 0 : prefix.match(/\d/)) && !(suffix === null || suffix === void 0 ? void 0 : suffix.match(/\d/)) && typeof val === 'string' && !isNaN(Number(val));
943
+ }
944
+ function removeFormatting(value, changeMeta, props) {
945
+ var assign;
946
+ if (changeMeta === void 0) changeMeta = getDefaultChangeMeta(value);
947
+ var allowNegative = props.allowNegative;
948
+ var prefix = props.prefix;
949
+ if (prefix === void 0) prefix = '';
950
+ var suffix = props.suffix;
951
+ if (suffix === void 0) suffix = '';
952
+ var decimalScale = props.decimalScale;
953
+ var from = changeMeta.from;
954
+ var to = changeMeta.to;
955
+ var start = to.start;
956
+ var end = to.end;
957
+ var ref = getSeparators(props);
958
+ var allowedDecimalSeparators = ref.allowedDecimalSeparators;
959
+ var decimalSeparator = ref.decimalSeparator;
960
+ var isBeforeDecimalSeparator = value[end] === decimalSeparator;
961
+ /**
962
+ * If only a number is added on empty input which matches with the prefix or suffix,
963
+ * then don't remove it, just return the same
964
+ */ if (charIsNumber(value) && (value === prefix || value === suffix) && changeMeta.lastValue === '') {
965
+ return value;
966
+ }
967
+ /** Check for any allowed decimal separator is added in the numeric format and replace it with decimal separator */ if (end - start === 1 && allowedDecimalSeparators.indexOf(value[start]) !== -1) {
968
+ var separator = decimalScale === 0 ? '' : decimalSeparator;
969
+ value = value.substring(0, start) + separator + value.substring(start + 1, value.length);
970
+ }
971
+ var stripNegation = function(value, start, end) {
972
+ /**
973
+ * if prefix starts with - we don't allow negative number to avoid confusion
974
+ * if suffix starts with - and the value length is same as suffix length, then the - sign is from the suffix
975
+ * In other cases, if the value starts with - then it is a negation
976
+ */ var hasNegation = false;
977
+ var hasDoubleNegation = false;
978
+ if (prefix.startsWith('-')) {
979
+ hasNegation = false;
980
+ } else if (value.startsWith('--')) {
981
+ hasNegation = false;
982
+ hasDoubleNegation = true;
983
+ } else if (suffix.startsWith('-') && value.length === suffix.length) {
984
+ hasNegation = false;
985
+ } else if (value[0] === '-') {
986
+ hasNegation = true;
987
+ }
988
+ var charsToRemove = hasNegation ? 1 : 0;
989
+ if (hasDoubleNegation) {
990
+ charsToRemove = 2;
991
+ }
992
+ // remove negation/double negation from start to simplify prefix logic as negation comes before prefix
993
+ if (charsToRemove) {
994
+ value = value.substring(charsToRemove);
995
+ // account for the removal of the negation for start and end index
996
+ start -= charsToRemove;
997
+ end -= charsToRemove;
998
+ }
999
+ return {
1000
+ value: value,
1001
+ start: start,
1002
+ end: end,
1003
+ hasNegation: hasNegation
1004
+ };
1005
+ };
1006
+ var toMetadata = stripNegation(value, start, end);
1007
+ var hasNegation = toMetadata.hasNegation;
1008
+ assign = toMetadata, value = assign.value, start = assign.start, end = assign.end;
1009
+ var ref$1 = stripNegation(changeMeta.lastValue, from.start, from.end);
1010
+ var fromStart = ref$1.start;
1011
+ var fromEnd = ref$1.end;
1012
+ var lastValue = ref$1.value;
1013
+ // if only prefix and suffix part is updated reset the value to last value
1014
+ // if the changed range is from suffix in the updated value, and the the suffix starts with the same characters, allow the change
1015
+ var updatedSuffixPart = value.substring(start, end);
1016
+ if (value.length && lastValue.length && (fromStart > lastValue.length - suffix.length || fromEnd < prefix.length) && !(updatedSuffixPart && suffix.startsWith(updatedSuffixPart))) {
1017
+ value = lastValue;
1018
+ }
1019
+ /**
1020
+ * remove prefix
1021
+ * Remove whole prefix part if its present on the value
1022
+ * If the prefix is partially deleted (in which case change start index will be less the prefix length)
1023
+ * Remove only partial part of prefix.
1024
+ */ var startIndex = 0;
1025
+ if (value.startsWith(prefix)) {
1026
+ startIndex += prefix.length;
1027
+ } else if (start < prefix.length) {
1028
+ startIndex = start;
1029
+ }
1030
+ value = value.substring(startIndex);
1031
+ // account for deleted prefix for end
1032
+ end -= startIndex;
1033
+ /**
1034
+ * Remove suffix
1035
+ * Remove whole suffix part if its present on the value
1036
+ * If the suffix is partially deleted (in which case change end index will be greater than the suffixStartIndex)
1037
+ * remove the partial part of suffix
1038
+ */ var endIndex = value.length;
1039
+ var suffixStartIndex = value.length - suffix.length;
1040
+ if (value.endsWith(suffix)) {
1041
+ endIndex = suffixStartIndex;
1042
+ } else if (end > suffixStartIndex) {
1043
+ endIndex = end;
1044
+ } else if (end > value.length - suffix.length) {
1045
+ endIndex = end;
1046
+ }
1047
+ value = value.substring(0, endIndex);
1048
+ // add the negation back and handle for double negation
1049
+ value = handleNegation(hasNegation ? "-" + value : value, allowNegative);
1050
+ // remove non numeric characters
1051
+ value = (value.match(getNumberRegex(decimalSeparator)) || []).join('');
1052
+ // replace the decimalSeparator with ., and only keep the first separator, ignore following ones
1053
+ var firstIndex = value.indexOf(decimalSeparator);
1054
+ value = value.replace(new RegExp(escapeRegExp(decimalSeparator), 'g'), function(match, index) {
1055
+ return index === firstIndex ? '.' : '';
1056
+ });
1057
+ //check if beforeDecimal got deleted and there is nothing after decimal,
1058
+ //clear all numbers in such case while keeping the - sign
1059
+ var ref$2 = splitDecimal(value, allowNegative);
1060
+ var beforeDecimal = ref$2.beforeDecimal;
1061
+ var afterDecimal = ref$2.afterDecimal;
1062
+ var addNegation = ref$2.addNegation; // eslint-disable-line prefer-const
1063
+ //clear only if something got deleted before decimal (cursor is before decimal)
1064
+ if (to.end - to.start < from.end - from.start && beforeDecimal === '' && isBeforeDecimalSeparator && !parseFloat(afterDecimal)) {
1065
+ value = addNegation ? '-' : '';
1066
+ }
1067
+ return value;
1068
+ }
1069
+ function getCaretBoundary(formattedValue, props) {
1070
+ var prefix = props.prefix;
1071
+ if (prefix === void 0) prefix = '';
1072
+ var suffix = props.suffix;
1073
+ if (suffix === void 0) suffix = '';
1074
+ var boundaryAry = Array.from({
1075
+ length: formattedValue.length + 1
1076
+ }).map(function() {
1077
+ return true;
1078
+ });
1079
+ var hasNegation = formattedValue[0] === '-';
1080
+ // fill for prefix and negation
1081
+ boundaryAry.fill(false, 0, prefix.length + (hasNegation ? 1 : 0));
1082
+ // fill for suffix
1083
+ var valLn = formattedValue.length;
1084
+ boundaryAry.fill(false, valLn - suffix.length + 1, valLn + 1);
1085
+ return boundaryAry;
1086
+ }
1087
+ function validateAndUpdateProps(props) {
1088
+ var ref = getSeparators(props);
1089
+ var thousandSeparator = ref.thousandSeparator;
1090
+ var decimalSeparator = ref.decimalSeparator;
1091
+ // eslint-disable-next-line prefer-const
1092
+ var prefix = props.prefix;
1093
+ if (prefix === void 0) prefix = '';
1094
+ var allowNegative = props.allowNegative;
1095
+ if (allowNegative === void 0) allowNegative = true;
1096
+ if (thousandSeparator === decimalSeparator) {
1097
+ throw new Error("\n Decimal separator can't be same as thousand separator.\n thousandSeparator: " + thousandSeparator + " (thousandSeparator = {true} is same as thousandSeparator = \",\")\n decimalSeparator: " + decimalSeparator + " (default value for decimalSeparator is .)\n ");
1098
+ }
1099
+ if (prefix.startsWith('-') && allowNegative) {
1100
+ // TODO: throw error in next major version
1101
+ console.error("\n Prefix can't start with '-' when allowNegative is true.\n prefix: " + prefix + "\n allowNegative: " + allowNegative + "\n ");
1102
+ allowNegative = false;
1103
+ }
1104
+ return Object.assign(Object.assign({}, props), {
1105
+ allowNegative: allowNegative
1106
+ });
1107
+ }
1108
+ function useNumericFormat(props) {
1109
+ // validate props
1110
+ props = validateAndUpdateProps(props);
1111
+ props.decimalSeparator;
1112
+ props.allowedDecimalSeparators;
1113
+ props.thousandsGroupStyle;
1114
+ var suffix = props.suffix;
1115
+ var allowNegative = props.allowNegative;
1116
+ var allowLeadingZeros = props.allowLeadingZeros;
1117
+ var onKeyDown = props.onKeyDown;
1118
+ if (onKeyDown === void 0) onKeyDown = noop;
1119
+ var onBlur = props.onBlur;
1120
+ if (onBlur === void 0) onBlur = noop;
1121
+ var thousandSeparator = props.thousandSeparator;
1122
+ var decimalScale = props.decimalScale;
1123
+ var fixedDecimalScale = props.fixedDecimalScale;
1124
+ var prefix = props.prefix;
1125
+ if (prefix === void 0) prefix = '';
1126
+ var defaultValue = props.defaultValue;
1127
+ var value = props.value;
1128
+ var valueIsNumericString = props.valueIsNumericString;
1129
+ var onValueChange = props.onValueChange;
1130
+ var restProps = __rest(props, [
1131
+ "decimalSeparator",
1132
+ "allowedDecimalSeparators",
1133
+ "thousandsGroupStyle",
1134
+ "suffix",
1135
+ "allowNegative",
1136
+ "allowLeadingZeros",
1137
+ "onKeyDown",
1138
+ "onBlur",
1139
+ "thousandSeparator",
1140
+ "decimalScale",
1141
+ "fixedDecimalScale",
1142
+ "prefix",
1143
+ "defaultValue",
1144
+ "value",
1145
+ "valueIsNumericString",
1146
+ "onValueChange"
1147
+ ]);
1148
+ // get derived decimalSeparator and allowedDecimalSeparators
1149
+ var ref = getSeparators(props);
1150
+ var decimalSeparator = ref.decimalSeparator;
1151
+ var allowedDecimalSeparators = ref.allowedDecimalSeparators;
1152
+ var _format = function(numStr) {
1153
+ return format(numStr, props);
1154
+ };
1155
+ var _removeFormatting = function(inputValue, changeMeta) {
1156
+ return removeFormatting(inputValue, changeMeta, props);
1157
+ };
1158
+ var _value = isNil(value) ? defaultValue : value;
1159
+ // try to figure out isValueNumericString based on format prop and value
1160
+ var _valueIsNumericString = valueIsNumericString !== null && valueIsNumericString !== void 0 ? valueIsNumericString : isNumericString(_value, prefix, suffix);
1161
+ if (!isNil(value)) {
1162
+ _valueIsNumericString = _valueIsNumericString || typeof value === 'number';
1163
+ } else if (!isNil(defaultValue)) {
1164
+ _valueIsNumericString = _valueIsNumericString || typeof defaultValue === 'number';
1165
+ }
1166
+ var roundIncomingValueToPrecision = function(value) {
1167
+ if (isNotValidValue(value)) {
1168
+ return value;
1169
+ }
1170
+ if (typeof value === 'number') {
1171
+ value = toNumericString(value);
1172
+ }
1173
+ /**
1174
+ * only round numeric or float string values coming through props,
1175
+ * we don't need to do it for onChange events, as we want to prevent typing there
1176
+ */ if (_valueIsNumericString && typeof decimalScale === 'number') {
1177
+ return roundToPrecision(value, decimalScale, Boolean(fixedDecimalScale));
1178
+ }
1179
+ return value;
1180
+ };
1181
+ var ref$1 = useInternalValues(roundIncomingValueToPrecision(value), roundIncomingValueToPrecision(defaultValue), Boolean(_valueIsNumericString), _format, _removeFormatting, onValueChange);
1182
+ var ref$1_0 = ref$1[0];
1183
+ var numAsString = ref$1_0.numAsString;
1184
+ var formattedValue = ref$1_0.formattedValue;
1185
+ var _onValueChange = ref$1[1];
1186
+ var _onKeyDown = function(e) {
1187
+ var el = e.target;
1188
+ var key = e.key;
1189
+ var selectionStart = el.selectionStart;
1190
+ var selectionEnd = el.selectionEnd;
1191
+ var value = el.value;
1192
+ if (value === void 0) value = '';
1193
+ // if user tries to delete partial prefix then ignore it
1194
+ if ((key === 'Backspace' || key === 'Delete') && selectionEnd < prefix.length) {
1195
+ e.preventDefault();
1196
+ return;
1197
+ }
1198
+ // if multiple characters are selected and user hits backspace, no need to handle anything manually
1199
+ if (selectionStart !== selectionEnd) {
1200
+ onKeyDown(e);
1201
+ return;
1202
+ }
1203
+ // if user hits backspace, while the cursor is before prefix, and the input has negation, remove the negation
1204
+ if (key === 'Backspace' && value[0] === '-' && selectionStart === prefix.length + 1 && allowNegative) {
1205
+ // bring the cursor to after negation
1206
+ setCaretPosition(el, 1);
1207
+ }
1208
+ // don't allow user to delete decimal separator when decimalScale and fixedDecimalScale is set
1209
+ if (decimalScale && fixedDecimalScale) {
1210
+ if (key === 'Backspace' && value[selectionStart - 1] === decimalSeparator) {
1211
+ setCaretPosition(el, selectionStart - 1);
1212
+ e.preventDefault();
1213
+ } else if (key === 'Delete' && value[selectionStart] === decimalSeparator) {
1214
+ e.preventDefault();
1215
+ }
1216
+ }
1217
+ // if user presses the allowed decimal separator before the separator, move the cursor after the separator
1218
+ if ((allowedDecimalSeparators === null || allowedDecimalSeparators === void 0 ? void 0 : allowedDecimalSeparators.includes(key)) && value[selectionStart] === decimalSeparator) {
1219
+ setCaretPosition(el, selectionStart + 1);
1220
+ }
1221
+ var _thousandSeparator = thousandSeparator === true ? ',' : thousandSeparator;
1222
+ // move cursor when delete or backspace is pressed before/after thousand separator
1223
+ if (key === 'Backspace' && value[selectionStart - 1] === _thousandSeparator) {
1224
+ setCaretPosition(el, selectionStart - 1);
1225
+ }
1226
+ if (key === 'Delete' && value[selectionStart] === _thousandSeparator) {
1227
+ setCaretPosition(el, selectionStart + 1);
1228
+ }
1229
+ onKeyDown(e);
1230
+ };
1231
+ var _onBlur = function(e) {
1232
+ var _value = numAsString;
1233
+ // if there no no numeric value, clear the input
1234
+ if (!_value.match(/\d/g)) {
1235
+ _value = '';
1236
+ }
1237
+ // clear leading 0s
1238
+ if (!allowLeadingZeros) {
1239
+ _value = fixLeadingZero(_value);
1240
+ }
1241
+ // apply fixedDecimalScale on blur event
1242
+ if (fixedDecimalScale && decimalScale) {
1243
+ _value = roundToPrecision(_value, decimalScale, fixedDecimalScale);
1244
+ }
1245
+ if (_value !== numAsString) {
1246
+ var formattedValue = format(_value, props);
1247
+ _onValueChange({
1248
+ formattedValue: formattedValue,
1249
+ value: _value,
1250
+ floatValue: parseFloat(_value)
1251
+ }, {
1252
+ event: e,
1253
+ source: SourceType.event
1254
+ });
1255
+ }
1256
+ onBlur(e);
1257
+ };
1258
+ var isValidInputCharacter = function(inputChar) {
1259
+ if (inputChar === decimalSeparator) {
1260
+ return true;
1261
+ }
1262
+ return charIsNumber(inputChar);
1263
+ };
1264
+ var isCharacterSame = function(ref) {
1265
+ var currentValue = ref.currentValue;
1266
+ var lastValue = ref.lastValue;
1267
+ var formattedValue = ref.formattedValue;
1268
+ var currentValueIndex = ref.currentValueIndex;
1269
+ var formattedValueIndex = ref.formattedValueIndex;
1270
+ var curChar = currentValue[currentValueIndex];
1271
+ var newChar = formattedValue[formattedValueIndex];
1272
+ /**
1273
+ * NOTE: as thousand separator and allowedDecimalSeparators can be same, we need to check on
1274
+ * typed range if we have typed any character from allowedDecimalSeparators, in that case we
1275
+ * consider different characters like , and . same within the range of updated value.
1276
+ */ var typedRange = findChangeRange(lastValue, currentValue);
1277
+ var to = typedRange.to;
1278
+ // handle corner case where if we user types a decimal separator with fixedDecimalScale
1279
+ // and pass back float value the cursor jumps. #851
1280
+ var getDecimalSeparatorIndex = function(value) {
1281
+ return _removeFormatting(value).indexOf('.') + prefix.length;
1282
+ };
1283
+ if (value === 0 && fixedDecimalScale && decimalScale && currentValue[to.start] === decimalSeparator && getDecimalSeparatorIndex(currentValue) < currentValueIndex && getDecimalSeparatorIndex(formattedValue) > formattedValueIndex) {
1284
+ return false;
1285
+ }
1286
+ if (currentValueIndex >= to.start && currentValueIndex < to.end && allowedDecimalSeparators && allowedDecimalSeparators.includes(curChar) && newChar === decimalSeparator) {
1287
+ return true;
1288
+ }
1289
+ return curChar === newChar;
1290
+ };
1291
+ return Object.assign(Object.assign({}, restProps), {
1292
+ value: formattedValue,
1293
+ valueIsNumericString: false,
1294
+ isValidInputCharacter: isValidInputCharacter,
1295
+ isCharacterSame: isCharacterSame,
1296
+ onValueChange: _onValueChange,
1297
+ format: _format,
1298
+ removeFormatting: _removeFormatting,
1299
+ getCaretBoundary: function(formattedValue) {
1300
+ return getCaretBoundary(formattedValue, props);
1301
+ },
1302
+ onKeyDown: _onKeyDown,
1303
+ onBlur: _onBlur
1304
+ });
1305
+ }
1306
+ function NumericFormat(props) {
1307
+ var numericFormatProps = useNumericFormat(props);
1308
+ return React__default.createElement(NumberFormatBase, Object.assign({}, numericFormatProps));
1309
+ }
1310
+ function format$1(numStr, props) {
1311
+ var format = props.format;
1312
+ var allowEmptyFormatting = props.allowEmptyFormatting;
1313
+ var mask = props.mask;
1314
+ var patternChar = props.patternChar;
1315
+ if (patternChar === void 0) patternChar = '#';
1316
+ if (numStr === '' && !allowEmptyFormatting) {
1317
+ return '';
1318
+ }
1319
+ var hashCount = 0;
1320
+ var formattedNumberAry = format.split('');
1321
+ for(var i = 0, ln = format.length; i < ln; i++){
1322
+ if (format[i] === patternChar) {
1323
+ formattedNumberAry[i] = numStr[hashCount] || getMaskAtIndex(mask, hashCount);
1324
+ hashCount += 1;
1325
+ }
1326
+ }
1327
+ return formattedNumberAry.join('');
1328
+ }
1329
+ function removeFormatting$1(value, changeMeta, props) {
1330
+ if (changeMeta === void 0) changeMeta = getDefaultChangeMeta(value);
1331
+ var format = props.format;
1332
+ var patternChar = props.patternChar;
1333
+ if (patternChar === void 0) patternChar = '#';
1334
+ var from = changeMeta.from;
1335
+ var to = changeMeta.to;
1336
+ var lastValue = changeMeta.lastValue;
1337
+ if (lastValue === void 0) lastValue = '';
1338
+ var isNumericSlot = function(caretPos) {
1339
+ return format[caretPos] === patternChar;
1340
+ };
1341
+ var removeFormatChar = function(string, startIndex) {
1342
+ var str = '';
1343
+ for(var i = 0; i < string.length; i++){
1344
+ if (isNumericSlot(startIndex + i) && charIsNumber(string[i])) {
1345
+ str += string[i];
1346
+ }
1347
+ }
1348
+ return str;
1349
+ };
1350
+ var extractNumbers = function(str) {
1351
+ return str.replace(/[^0-9]/g, '');
1352
+ };
1353
+ // if format doesn't have any number, remove all the non numeric characters
1354
+ if (!format.match(/\d/)) {
1355
+ return extractNumbers(value);
1356
+ }
1357
+ /**
1358
+ * if user paste the whole formatted text in an empty input or doing select all and paste, check if matches to the pattern
1359
+ * and remove the format characters, if there is a mismatch on the pattern, do plane number extract
1360
+ */ if ((lastValue === '' || from.end - from.start === lastValue.length) && value.length === format.length) {
1361
+ var str = '';
1362
+ for(var i = 0; i < value.length; i++){
1363
+ if (isNumericSlot(i)) {
1364
+ if (charIsNumber(value[i])) {
1365
+ str += value[i];
1366
+ }
1367
+ } else if (value[i] !== format[i]) {
1368
+ // if there is a mismatch on the pattern, do plane number extract
1369
+ return extractNumbers(value);
1370
+ }
1371
+ }
1372
+ return str;
1373
+ }
1374
+ /**
1375
+ * For partial change,
1376
+ * where ever there is a change on the input, we can break the number in three parts
1377
+ * 1st: left part which is unchanged
1378
+ * 2nd: middle part which is changed
1379
+ * 3rd: right part which is unchanged
1380
+ *
1381
+ * The first and third section will be same as last value, only the middle part will change
1382
+ * We can consider on the change part all the new characters are non format characters.
1383
+ * And on the first and last section it can have partial format characters.
1384
+ *
1385
+ * We pick first and last section from the lastValue (as that has 1-1 mapping with format)
1386
+ * and middle one from the update value.
1387
+ */ var firstSection = lastValue.substring(0, from.start);
1388
+ var middleSection = value.substring(to.start, to.end);
1389
+ var lastSection = lastValue.substring(from.end);
1390
+ return "" + removeFormatChar(firstSection, 0) + extractNumbers(middleSection) + removeFormatChar(lastSection, from.end);
1391
+ }
1392
+ function getCaretBoundary$1(formattedValue, props) {
1393
+ var format = props.format;
1394
+ var mask = props.mask;
1395
+ var patternChar = props.patternChar;
1396
+ if (patternChar === void 0) patternChar = '#';
1397
+ var boundaryAry = Array.from({
1398
+ length: formattedValue.length + 1
1399
+ }).map(function() {
1400
+ return true;
1401
+ });
1402
+ var hashCount = 0;
1403
+ var firstEmptySlot = -1;
1404
+ var maskAndIndexMap = {};
1405
+ format.split('').forEach(function(char, index) {
1406
+ var maskAtIndex = undefined;
1407
+ if (char === patternChar) {
1408
+ hashCount++;
1409
+ maskAtIndex = getMaskAtIndex(mask, hashCount - 1);
1410
+ if (firstEmptySlot === -1 && formattedValue[index] === maskAtIndex) {
1411
+ firstEmptySlot = index;
1412
+ }
1413
+ }
1414
+ maskAndIndexMap[index] = maskAtIndex;
1415
+ });
1416
+ var isPosAllowed = function(pos) {
1417
+ // the position is allowed if the position is not masked and valid number area
1418
+ return format[pos] === patternChar && formattedValue[pos] !== maskAndIndexMap[pos];
1419
+ };
1420
+ for(var i = 0, ln = boundaryAry.length; i < ln; i++){
1421
+ // consider caret to be in boundary if it is before or after numeric value
1422
+ // Note: on pattern based format its denoted by patternCharacter
1423
+ // we should also allow user to put cursor on first empty slot
1424
+ boundaryAry[i] = i === firstEmptySlot || isPosAllowed(i) || isPosAllowed(i - 1);
1425
+ }
1426
+ // the first patternChar position is always allowed
1427
+ boundaryAry[format.indexOf(patternChar)] = true;
1428
+ return boundaryAry;
1429
+ }
1430
+ function validateProps(props) {
1431
+ var mask = props.mask;
1432
+ if (mask) {
1433
+ var maskAsStr = mask === 'string' ? mask : mask.toString();
1434
+ if (maskAsStr.match(/\d/g)) {
1435
+ throw new Error("Mask " + mask + " should not contain numeric character;");
1436
+ }
1437
+ }
1438
+ }
1439
+ function isNumericString$1(val, format) {
1440
+ //we can treat empty string as numeric string
1441
+ if (val === '') {
1442
+ return true;
1443
+ }
1444
+ return !(format === null || format === void 0 ? void 0 : format.match(/\d/)) && typeof val === 'string' && (!!val.match(/^\d+$/) || val === '');
1445
+ }
1446
+ function usePatternFormat(props) {
1447
+ props.mask;
1448
+ props.allowEmptyFormatting;
1449
+ var formatProp = props.format;
1450
+ var inputMode = props.inputMode;
1451
+ if (inputMode === void 0) inputMode = 'numeric';
1452
+ var onKeyDown = props.onKeyDown;
1453
+ if (onKeyDown === void 0) onKeyDown = noop;
1454
+ var patternChar = props.patternChar;
1455
+ if (patternChar === void 0) patternChar = '#';
1456
+ var value = props.value;
1457
+ var defaultValue = props.defaultValue;
1458
+ var valueIsNumericString = props.valueIsNumericString;
1459
+ var restProps = __rest(props, [
1460
+ "mask",
1461
+ "allowEmptyFormatting",
1462
+ "format",
1463
+ "inputMode",
1464
+ "onKeyDown",
1465
+ "patternChar",
1466
+ "value",
1467
+ "defaultValue",
1468
+ "valueIsNumericString"
1469
+ ]);
1470
+ // validate props
1471
+ validateProps(props);
1472
+ var _getCaretBoundary = function(formattedValue) {
1473
+ return getCaretBoundary$1(formattedValue, props);
1474
+ };
1475
+ var _onKeyDown = function(e) {
1476
+ var key = e.key;
1477
+ var el = e.target;
1478
+ var selectionStart = el.selectionStart;
1479
+ var selectionEnd = el.selectionEnd;
1480
+ var value = el.value;
1481
+ // if multiple characters are selected and user hits backspace, no need to handle anything manually
1482
+ if (selectionStart !== selectionEnd) {
1483
+ onKeyDown(e);
1484
+ return;
1485
+ }
1486
+ // bring the cursor to closest numeric section
1487
+ var caretPos = selectionStart;
1488
+ // if backspace is pressed after the format characters, bring it to numeric section
1489
+ // if delete is pressed before the format characters, bring it to numeric section
1490
+ if (key === 'Backspace' || key === 'Delete') {
1491
+ var direction = 'right';
1492
+ if (key === 'Backspace') {
1493
+ while(caretPos > 0 && formatProp[caretPos - 1] !== patternChar){
1494
+ caretPos--;
1495
+ }
1496
+ direction = 'left';
1497
+ } else {
1498
+ var formatLn = formatProp.length;
1499
+ while(caretPos < formatLn && formatProp[caretPos] !== patternChar){
1500
+ caretPos++;
1501
+ }
1502
+ direction = 'right';
1503
+ }
1504
+ caretPos = getCaretPosInBoundary(value, caretPos, _getCaretBoundary(value), direction);
1505
+ } else if (formatProp[caretPos] !== patternChar && key !== 'ArrowLeft' && key !== 'ArrowRight') {
1506
+ // if user is typing on format character position, bring user to next allowed caret position
1507
+ caretPos = getCaretPosInBoundary(value, caretPos + 1, _getCaretBoundary(value), 'right');
1508
+ }
1509
+ // if we changing caret position, set the caret position
1510
+ if (caretPos !== selectionStart) {
1511
+ setCaretPosition(el, caretPos);
1512
+ }
1513
+ onKeyDown(e);
1514
+ };
1515
+ // try to figure out isValueNumericString based on format prop and value
1516
+ var _value = isNil(value) ? defaultValue : value;
1517
+ var isValueNumericString = valueIsNumericString !== null && valueIsNumericString !== void 0 ? valueIsNumericString : isNumericString$1(_value, formatProp);
1518
+ var _props = Object.assign(Object.assign({}, props), {
1519
+ valueIsNumericString: isValueNumericString
1520
+ });
1521
+ return Object.assign(Object.assign({}, restProps), {
1522
+ value: value,
1523
+ defaultValue: defaultValue,
1524
+ valueIsNumericString: isValueNumericString,
1525
+ inputMode: inputMode,
1526
+ format: function(numStr) {
1527
+ return format$1(numStr, _props);
1528
+ },
1529
+ removeFormatting: function(inputValue, changeMeta) {
1530
+ return removeFormatting$1(inputValue, changeMeta, _props);
1531
+ },
1532
+ getCaretBoundary: _getCaretBoundary,
1533
+ onKeyDown: _onKeyDown
1534
+ });
1535
+ }
1536
+ function PatternFormat(props) {
1537
+ var patternFormatProps = usePatternFormat(props);
1538
+ return React__default.createElement(NumberFormatBase, Object.assign({}, patternFormatProps));
1539
+ }
1540
+
1541
+ export { NumericFormat as N, PatternFormat as P };
1542
+ //# sourceMappingURL=react-number-format.es-CmBAGhhQ.mjs.map