ivt 0.5.4 → 0.5.5

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