@techzyapp/ui-library 1.0.33 → 1.0.35

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 (430) hide show
  1. package/dist/{AdminRoot-CwUHa2us.js → AdminRoot-C_SNXQkB.js} +9 -9
  2. package/dist/{AdminRoot-CwUHa2us.js.map → AdminRoot-C_SNXQkB.js.map} +1 -1
  3. package/dist/{AdminRoot-cjP_Ad4r.cjs → AdminRoot-D97qDVTM.cjs} +2 -2
  4. package/dist/{AdminRoot-cjP_Ad4r.cjs.map → AdminRoot-D97qDVTM.cjs.map} +1 -1
  5. package/dist/{Alert-LJDrtkJy.js → Alert-BXtQFAVl.js} +3 -3
  6. package/dist/{Alert-LJDrtkJy.js.map → Alert-BXtQFAVl.js.map} +1 -1
  7. package/dist/{Alert-CfjDmLR8.cjs → Alert-CggrNMn5.cjs} +2 -2
  8. package/dist/{Alert-CfjDmLR8.cjs.map → Alert-CggrNMn5.cjs.map} +1 -1
  9. package/dist/{AuthLayout-m1BQ6Ixx.js → AuthLayout-C47vXKYp.js} +2 -2
  10. package/dist/{AuthLayout-m1BQ6Ixx.js.map → AuthLayout-C47vXKYp.js.map} +1 -1
  11. package/dist/{AuthLayout-DIcR__vo.cjs → AuthLayout-Cl3tb4-E.cjs} +2 -2
  12. package/dist/{AuthLayout-DIcR__vo.cjs.map → AuthLayout-Cl3tb4-E.cjs.map} +1 -1
  13. package/dist/{Breadcrumbs-COb2zmDk.cjs → Breadcrumbs-Cpa_LSY2.cjs} +2 -2
  14. package/dist/{Breadcrumbs-COb2zmDk.cjs.map → Breadcrumbs-Cpa_LSY2.cjs.map} +1 -1
  15. package/dist/{Breadcrumbs-DYeVrOns.js → Breadcrumbs-D_QnKw8q.js} +3 -3
  16. package/dist/{Breadcrumbs-DYeVrOns.js.map → Breadcrumbs-D_QnKw8q.js.map} +1 -1
  17. package/dist/{Button-PBZnkRNn.js → Button-BQ7jsm5P.js} +2 -2
  18. package/dist/{Button-PBZnkRNn.js.map → Button-BQ7jsm5P.js.map} +1 -1
  19. package/dist/{Button-BD5wpg-t.cjs → Button-Cm64ROip.cjs} +2 -2
  20. package/dist/{Button-BD5wpg-t.cjs.map → Button-Cm64ROip.cjs.map} +1 -1
  21. package/dist/{Calendar-Bb5Ekbpr.js → Calendar-BrpJOBTt.js} +3 -3
  22. package/dist/{Calendar-Bb5Ekbpr.js.map → Calendar-BrpJOBTt.js.map} +1 -1
  23. package/dist/{Calendar-842vjtdN.cjs → Calendar-C2x9ZtPV.cjs} +2 -2
  24. package/dist/{Calendar-842vjtdN.cjs.map → Calendar-C2x9ZtPV.cjs.map} +1 -1
  25. package/dist/{Card-CV_rHego.js → Card-kizK1B7N.js} +2 -2
  26. package/dist/{Card-CV_rHego.js.map → Card-kizK1B7N.js.map} +1 -1
  27. package/dist/{Card-DL7XnkOA.cjs → Card-yhly3Xdp.cjs} +2 -2
  28. package/dist/{Card-DL7XnkOA.cjs.map → Card-yhly3Xdp.cjs.map} +1 -1
  29. package/dist/{Chip-CLPIPC9a.cjs → Chip-BPcnO5WI.cjs} +2 -2
  30. package/dist/{Chip-CLPIPC9a.cjs.map → Chip-BPcnO5WI.cjs.map} +1 -1
  31. package/dist/{Chip-DdOUVF0Z.js → Chip-BzyzLEeX.js} +2 -2
  32. package/dist/{Chip-DdOUVF0Z.js.map → Chip-BzyzLEeX.js.map} +1 -1
  33. package/dist/{ChoiceCardGroup-BTbKjJdp.js → ChoiceCardGroup-BBD8ai4s.js} +2 -2
  34. package/dist/{ChoiceCardGroup-BTbKjJdp.js.map → ChoiceCardGroup-BBD8ai4s.js.map} +1 -1
  35. package/dist/{ChoiceCardGroup-Bg2jtFpe.cjs → ChoiceCardGroup-BWsG_Vh5.cjs} +2 -2
  36. package/dist/{ChoiceCardGroup-Bg2jtFpe.cjs.map → ChoiceCardGroup-BWsG_Vh5.cjs.map} +1 -1
  37. package/dist/{CodeBlock-B35NXZzd.js → CodeBlock-BTt40oh5.js} +3 -3
  38. package/dist/{CodeBlock-B35NXZzd.js.map → CodeBlock-BTt40oh5.js.map} +1 -1
  39. package/dist/{CodeBlock-C0dbyxcl.cjs → CodeBlock-BgSum_bB.cjs} +2 -2
  40. package/dist/{CodeBlock-C0dbyxcl.cjs.map → CodeBlock-BgSum_bB.cjs.map} +1 -1
  41. package/dist/{ColorPicker-6UraVYFy.js → ColorPicker-BNM75F5E.js} +4 -4
  42. package/dist/{ColorPicker-6UraVYFy.js.map → ColorPicker-BNM75F5E.js.map} +1 -1
  43. package/dist/{ColorPicker-DmLGKaYF.cjs → ColorPicker-C33dlkhN.cjs} +2 -2
  44. package/dist/{ColorPicker-DmLGKaYF.cjs.map → ColorPicker-C33dlkhN.cjs.map} +1 -1
  45. package/dist/{ColorPickerPanel-WuxwwfCI.cjs → ColorPickerPanel-BZ_ZNu2B.cjs} +2 -2
  46. package/dist/{ColorPickerPanel-WuxwwfCI.cjs.map → ColorPickerPanel-BZ_ZNu2B.cjs.map} +1 -1
  47. package/dist/{ColorPickerPanel-DZ-W_wOI.js → ColorPickerPanel-Bh1K0YS8.js} +2 -2
  48. package/dist/{ColorPickerPanel-DZ-W_wOI.js.map → ColorPickerPanel-Bh1K0YS8.js.map} +1 -1
  49. package/dist/{ColorRamp-D_9gsqJl.cjs → ColorRamp-BJWNKzoX.cjs} +2 -2
  50. package/dist/{ColorRamp-D_9gsqJl.cjs.map → ColorRamp-BJWNKzoX.cjs.map} +1 -1
  51. package/dist/{ColorRamp-CSqzzHZx.js → ColorRamp-BnuXrSxa.js} +3 -3
  52. package/dist/{ColorRamp-CSqzzHZx.js.map → ColorRamp-BnuXrSxa.js.map} +1 -1
  53. package/dist/{ConfigProvider-tvLbKiqu.js → ConfigProvider-DZMtq2Fz.js} +2 -2
  54. package/dist/ConfigProvider-DZMtq2Fz.js.map +1 -0
  55. package/dist/{ConfigProvider-CVLHPXQm.cjs → ConfigProvider-th4GYhcU.cjs} +2 -2
  56. package/dist/ConfigProvider-th4GYhcU.cjs.map +1 -0
  57. package/dist/{CopyButton-0w4OToIy.cjs → CopyButton-C9oHGs6W.cjs} +2 -2
  58. package/dist/{CopyButton-0w4OToIy.cjs.map → CopyButton-C9oHGs6W.cjs.map} +1 -1
  59. package/dist/{CopyButton-B_mYxcXV.js → CopyButton-hZqLdXJq.js} +3 -3
  60. package/dist/{CopyButton-B_mYxcXV.js.map → CopyButton-hZqLdXJq.js.map} +1 -1
  61. package/dist/{DatePicker-Bt-M87zX.js → DatePicker-B6ZL_T-E.js} +5 -5
  62. package/dist/{DatePicker-Bt-M87zX.js.map → DatePicker-B6ZL_T-E.js.map} +1 -1
  63. package/dist/{DatePicker-D1uFIm3M.cjs → DatePicker-DXwJB4MH.cjs} +2 -2
  64. package/dist/{DatePicker-D1uFIm3M.cjs.map → DatePicker-DXwJB4MH.cjs.map} +1 -1
  65. package/dist/{DateTimePicker-zJUc9crs.js → DateTimePicker-BynW1Eeg.js} +8 -8
  66. package/dist/{DateTimePicker-zJUc9crs.js.map → DateTimePicker-BynW1Eeg.js.map} +1 -1
  67. package/dist/{DateTimePicker-DPt-LDVJ.cjs → DateTimePicker-CHi1H2k1.cjs} +2 -2
  68. package/dist/{DateTimePicker-DPt-LDVJ.cjs.map → DateTimePicker-CHi1H2k1.cjs.map} +1 -1
  69. package/dist/{DescriptionList-CPCbzU9b.cjs → DescriptionList-BqYwp08t.cjs} +2 -2
  70. package/dist/{DescriptionList-CPCbzU9b.cjs.map → DescriptionList-BqYwp08t.cjs.map} +1 -1
  71. package/dist/{DescriptionList-BLx9NfAW.js → DescriptionList-C6Gfk6I_.js} +5 -5
  72. package/dist/{DescriptionList-BLx9NfAW.js.map → DescriptionList-C6Gfk6I_.js.map} +1 -1
  73. package/dist/{EmptyState-BEVEGcLx.js → EmptyState-BvAA5mYO.js} +2 -2
  74. package/dist/{EmptyState-BEVEGcLx.js.map → EmptyState-BvAA5mYO.js.map} +1 -1
  75. package/dist/{EmptyState-C54C0Qwc.cjs → EmptyState-CZ6X5-Zy.cjs} +2 -2
  76. package/dist/{EmptyState-C54C0Qwc.cjs.map → EmptyState-CZ6X5-Zy.cjs.map} +1 -1
  77. package/dist/{ErrorBoundary-BSJL381Y.js → ErrorBoundary-BS0x9RVO.js} +14 -6
  78. package/dist/ErrorBoundary-BS0x9RVO.js.map +1 -0
  79. package/dist/ErrorBoundary-WwmJrL6o.cjs +2 -0
  80. package/dist/ErrorBoundary-WwmJrL6o.cjs.map +1 -0
  81. package/dist/ErrorState-BTSGKrJq.js +178 -0
  82. package/dist/ErrorState-BTSGKrJq.js.map +1 -0
  83. package/dist/ErrorState-DRXuV6na.cjs +4 -0
  84. package/dist/ErrorState-DRXuV6na.cjs.map +1 -0
  85. package/dist/{FileCard-R_sB8Qbx.js → FileCard-CxZ3o4BO.js} +4 -4
  86. package/dist/{FileCard-R_sB8Qbx.js.map → FileCard-CxZ3o4BO.js.map} +1 -1
  87. package/dist/{FileCard-B3dfdTVN.cjs → FileCard-ZZNd_tUN.cjs} +2 -2
  88. package/dist/{FileCard-B3dfdTVN.cjs.map → FileCard-ZZNd_tUN.cjs.map} +1 -1
  89. package/dist/{FileUploader-4UMy0urx.cjs → FileUploader-B--hPV3b.cjs} +2 -2
  90. package/dist/{FileUploader-4UMy0urx.cjs.map → FileUploader-B--hPV3b.cjs.map} +1 -1
  91. package/dist/{FileUploader-B55atuxq.js → FileUploader-CPah0hUe.js} +6 -6
  92. package/dist/{FileUploader-B55atuxq.js.map → FileUploader-CPah0hUe.js.map} +1 -1
  93. package/dist/{Flag-CFvJHC0u.cjs → Flag-C4La35rA.cjs} +2 -2
  94. package/dist/{Flag-CFvJHC0u.cjs.map → Flag-C4La35rA.cjs.map} +1 -1
  95. package/dist/{Flag-D7fmMqqy.js → Flag-DikEV1jI.js} +2 -2
  96. package/dist/{Flag-D7fmMqqy.js.map → Flag-DikEV1jI.js.map} +1 -1
  97. package/dist/{FullscreenToggle-CXmPqxJv.js → FullscreenToggle-CTt7_Kv_.js} +3 -3
  98. package/dist/{FullscreenToggle-CXmPqxJv.js.map → FullscreenToggle-CTt7_Kv_.js.map} +1 -1
  99. package/dist/{FullscreenToggle-D7tUPCNI.cjs → FullscreenToggle-ejjFFd9a.cjs} +2 -2
  100. package/dist/{FullscreenToggle-D7tUPCNI.cjs.map → FullscreenToggle-ejjFFd9a.cjs.map} +1 -1
  101. package/dist/{IconButton-sC_E_TXd.js → IconButton-BUmXN_lD.js} +2 -2
  102. package/dist/{IconButton-sC_E_TXd.js.map → IconButton-BUmXN_lD.js.map} +1 -1
  103. package/dist/{IconButton-BVrO9TBP.cjs → IconButton-CYMvszcM.cjs} +2 -2
  104. package/dist/{IconButton-BVrO9TBP.cjs.map → IconButton-CYMvszcM.cjs.map} +1 -1
  105. package/dist/{Loader-DNCEHqZb.cjs → Loader-DkwiCGbB.cjs} +2 -2
  106. package/dist/{Loader-DNCEHqZb.cjs.map → Loader-DkwiCGbB.cjs.map} +1 -1
  107. package/dist/{Loader-ChrouvaR.js → Loader-jh7XMRhy.js} +2 -2
  108. package/dist/{Loader-ChrouvaR.js.map → Loader-jh7XMRhy.js.map} +1 -1
  109. package/dist/{LocationPicker-DxiQ27k6.js → LocationPicker-Cdm7BCX5.js} +7 -7
  110. package/dist/{LocationPicker-DxiQ27k6.js.map → LocationPicker-Cdm7BCX5.js.map} +1 -1
  111. package/dist/{LocationPicker-CJ6bCJC4.cjs → LocationPicker-D-9mrCVD.cjs} +2 -2
  112. package/dist/{LocationPicker-CJ6bCJC4.cjs.map → LocationPicker-D-9mrCVD.cjs.map} +1 -1
  113. package/dist/{Modal-Do8pzyMl.js → Modal-CrvOHbNy.js} +3 -3
  114. package/dist/{Modal-Do8pzyMl.js.map → Modal-CrvOHbNy.js.map} +1 -1
  115. package/dist/{Modal-BL_XihC8.cjs → Modal-eI6QL-LM.cjs} +2 -2
  116. package/dist/{Modal-BL_XihC8.cjs.map → Modal-eI6QL-LM.cjs.map} +1 -1
  117. package/dist/{MultiSelect-BfsEdXNa.js → MultiSelect-BTilYrXp.js} +5 -5
  118. package/dist/{MultiSelect-BfsEdXNa.js.map → MultiSelect-BTilYrXp.js.map} +1 -1
  119. package/dist/{MultiSelect-WS5YNGRD.cjs → MultiSelect-B_Jenpgv.cjs} +2 -2
  120. package/dist/{MultiSelect-WS5YNGRD.cjs.map → MultiSelect-B_Jenpgv.cjs.map} +1 -1
  121. package/dist/{MultilineTextField-BgfBFeeF.js → MultilineTextField-DJ26nTdF.js} +2 -2
  122. package/dist/{MultilineTextField-BgfBFeeF.js.map → MultilineTextField-DJ26nTdF.js.map} +1 -1
  123. package/dist/{MultilineTextField-B6EYAdik.cjs → MultilineTextField-ihcPDX3D.cjs} +2 -2
  124. package/dist/{MultilineTextField-B6EYAdik.cjs.map → MultilineTextField-ihcPDX3D.cjs.map} +1 -1
  125. package/dist/{NumberField-P68n6q5m.js → NumberField-DEoaxFJj.js} +4 -4
  126. package/dist/{NumberField-P68n6q5m.js.map → NumberField-DEoaxFJj.js.map} +1 -1
  127. package/dist/{NumberField-CxiEfRAi.cjs → NumberField-czWHuAyt.cjs} +2 -2
  128. package/dist/{NumberField-CxiEfRAi.cjs.map → NumberField-czWHuAyt.cjs.map} +1 -1
  129. package/dist/{OtpField-XieJfl1y.cjs → OtpField-DK5KikOt.cjs} +2 -2
  130. package/dist/{OtpField-XieJfl1y.cjs.map → OtpField-DK5KikOt.cjs.map} +1 -1
  131. package/dist/{OtpField-DjTJH4Kh.js → OtpField-v2RuXdsE.js} +3 -3
  132. package/dist/{OtpField-DjTJH4Kh.js.map → OtpField-v2RuXdsE.js.map} +1 -1
  133. package/dist/PageError-CIVYNLTW.cjs +2 -0
  134. package/dist/{PageError-D7_Q8wz8.cjs.map → PageError-CIVYNLTW.cjs.map} +1 -1
  135. package/dist/PageError-CyMdVrxL.js +70 -0
  136. package/dist/{PageError-ClR7k0Zb.js.map → PageError-CyMdVrxL.js.map} +1 -1
  137. package/dist/{PageLayout-XQ_aQTf5.js → PageLayout-BtukUUfe.js} +2 -2
  138. package/dist/{PageLayout-XQ_aQTf5.js.map → PageLayout-BtukUUfe.js.map} +1 -1
  139. package/dist/{PageLayout-DTG83hLL.cjs → PageLayout-C_daDKkg.cjs} +2 -2
  140. package/dist/{PageLayout-DTG83hLL.cjs.map → PageLayout-C_daDKkg.cjs.map} +1 -1
  141. package/dist/{PageNotFound-D3wJ4Job.cjs → PageNotFound-CHb8DlqC.cjs} +2 -2
  142. package/dist/{PageNotFound-D3wJ4Job.cjs.map → PageNotFound-CHb8DlqC.cjs.map} +1 -1
  143. package/dist/{PageNotFound-CpwHMTxG.js → PageNotFound-DQ-OvU_O.js} +5 -5
  144. package/dist/{PageNotFound-CpwHMTxG.js.map → PageNotFound-DQ-OvU_O.js.map} +1 -1
  145. package/dist/{Pagination-Df-F9i2o.js → Pagination-BjufY1mt.js} +2 -2
  146. package/dist/{Pagination-Df-F9i2o.js.map → Pagination-BjufY1mt.js.map} +1 -1
  147. package/dist/{Pagination-BF8cmQMi.cjs → Pagination-jLyJa8iL.cjs} +2 -2
  148. package/dist/{Pagination-BF8cmQMi.cjs.map → Pagination-jLyJa8iL.cjs.map} +1 -1
  149. package/dist/{PaletteField-BFRPv7AC.cjs → PaletteField-DGaV7VJ9.cjs} +2 -2
  150. package/dist/{PaletteField-BFRPv7AC.cjs.map → PaletteField-DGaV7VJ9.cjs.map} +1 -1
  151. package/dist/{PaletteField-DUu4jz1c.js → PaletteField-DTfV8Lny.js} +3 -3
  152. package/dist/{PaletteField-DUu4jz1c.js.map → PaletteField-DTfV8Lny.js.map} +1 -1
  153. package/dist/{PhoneField-CXIQX_hR.js → PhoneField-BSIhBMW2.js} +5 -5
  154. package/dist/{PhoneField-CXIQX_hR.js.map → PhoneField-BSIhBMW2.js.map} +1 -1
  155. package/dist/{PhoneField-O5syyH7u.cjs → PhoneField-DchrnSiE.cjs} +2 -2
  156. package/dist/{PhoneField-O5syyH7u.cjs.map → PhoneField-DchrnSiE.cjs.map} +1 -1
  157. package/dist/{Popconfirm-bEoOPmZY.cjs → Popconfirm-l9au66oY.cjs} +2 -2
  158. package/dist/{Popconfirm-bEoOPmZY.cjs.map → Popconfirm-l9au66oY.cjs.map} +1 -1
  159. package/dist/{Popconfirm-D4J7tlk_.js → Popconfirm-p2O8Vmz0.js} +3 -3
  160. package/dist/{Popconfirm-D4J7tlk_.js.map → Popconfirm-p2O8Vmz0.js.map} +1 -1
  161. package/dist/{Progress-BxvqmmGS.js → Progress-C-VGs3yJ.js} +2 -2
  162. package/dist/{Progress-BxvqmmGS.js.map → Progress-C-VGs3yJ.js.map} +1 -1
  163. package/dist/{Progress-CqXX0rRp.cjs → Progress-Cqr2_BF1.cjs} +2 -2
  164. package/dist/{Progress-CqXX0rRp.cjs.map → Progress-Cqr2_BF1.cjs.map} +1 -1
  165. package/dist/{QrCode-osD23Vkt.js → QrCode-B9YbQNVc.js} +2 -2
  166. package/dist/{QrCode-osD23Vkt.js.map → QrCode-B9YbQNVc.js.map} +1 -1
  167. package/dist/{QrCode-BQ1eUiAJ.cjs → QrCode-CNVYpz9j.cjs} +2 -2
  168. package/dist/{QrCode-BQ1eUiAJ.cjs.map → QrCode-CNVYpz9j.cjs.map} +1 -1
  169. package/dist/{RadioGroup-CvC2yc4p.cjs → RadioGroup-687BVZ7k.cjs} +2 -2
  170. package/dist/{RadioGroup-CvC2yc4p.cjs.map → RadioGroup-687BVZ7k.cjs.map} +1 -1
  171. package/dist/{RadioGroup-CTAayuMv.js → RadioGroup-CD209tlb.js} +2 -2
  172. package/dist/{RadioGroup-CTAayuMv.js.map → RadioGroup-CD209tlb.js.map} +1 -1
  173. package/dist/{RemoveDialog-DH3eNUxC.js → RemoveDialog-BKgWohkG.js} +6 -6
  174. package/dist/{RemoveDialog-DH3eNUxC.js.map → RemoveDialog-BKgWohkG.js.map} +1 -1
  175. package/dist/{RemoveDialog-FrieNcjL.cjs → RemoveDialog-eGCbOuuM.cjs} +2 -2
  176. package/dist/{RemoveDialog-FrieNcjL.cjs.map → RemoveDialog-eGCbOuuM.cjs.map} +1 -1
  177. package/dist/{RichTextEditor-B-C4NPDk.cjs → RichTextEditor-BPAD4ISz.cjs} +2 -2
  178. package/dist/{RichTextEditor-B-C4NPDk.cjs.map → RichTextEditor-BPAD4ISz.cjs.map} +1 -1
  179. package/dist/{RichTextEditor-6frB2C5G.js → RichTextEditor-C24uBIWh.js} +8 -8
  180. package/dist/{RichTextEditor-6frB2C5G.js.map → RichTextEditor-C24uBIWh.js.map} +1 -1
  181. package/dist/RootLayout-BY_BxQ0C.cjs +2 -0
  182. package/dist/RootLayout-BY_BxQ0C.cjs.map +1 -0
  183. package/dist/RootLayout-CicjlAUF.js +641 -0
  184. package/dist/RootLayout-CicjlAUF.js.map +1 -0
  185. package/dist/{Select-Bjq_p8_e.cjs → Select-BbgueWwN.cjs} +2 -2
  186. package/dist/{Select-Bjq_p8_e.cjs.map → Select-BbgueWwN.cjs.map} +1 -1
  187. package/dist/{Select-DO3zDQYV.js → Select-DEi_ZUHR.js} +4 -4
  188. package/dist/{Select-DO3zDQYV.js.map → Select-DEi_ZUHR.js.map} +1 -1
  189. package/dist/{Sidebar-2oH285Xs.cjs → Sidebar-D-nR8Cu6.cjs} +2 -2
  190. package/dist/{Sidebar-2oH285Xs.cjs.map → Sidebar-D-nR8Cu6.cjs.map} +1 -1
  191. package/dist/{Sidebar-CKbSWc5q.js → Sidebar-nORfjIg8.js} +4 -4
  192. package/dist/{Sidebar-CKbSWc5q.js.map → Sidebar-nORfjIg8.js.map} +1 -1
  193. package/dist/{Slider-Cu1FhxR2.cjs → Slider-0joKXhPo.cjs} +2 -2
  194. package/dist/{Slider-Cu1FhxR2.cjs.map → Slider-0joKXhPo.cjs.map} +1 -1
  195. package/dist/{Slider-DoQJWgGU.js → Slider-CwZYxDO0.js} +2 -2
  196. package/dist/{Slider-DoQJWgGU.js.map → Slider-CwZYxDO0.js.map} +1 -1
  197. package/dist/{SpeedDial-BZK-z_r9.js → SpeedDial-BMpJtYP6.js} +2 -2
  198. package/dist/{SpeedDial-BZK-z_r9.js.map → SpeedDial-BMpJtYP6.js.map} +1 -1
  199. package/dist/{SpeedDial-KGf8b4Gq.cjs → SpeedDial-D5uk_E5v.cjs} +2 -2
  200. package/dist/{SpeedDial-KGf8b4Gq.cjs.map → SpeedDial-D5uk_E5v.cjs.map} +1 -1
  201. package/dist/{Stepper-s9Vah5R2.cjs → Stepper-BRksGDK1.cjs} +2 -2
  202. package/dist/{Stepper-s9Vah5R2.cjs.map → Stepper-BRksGDK1.cjs.map} +1 -1
  203. package/dist/{Stepper-BI3pjWf_.js → Stepper-D8bRyyhl.js} +2 -2
  204. package/dist/{Stepper-BI3pjWf_.js.map → Stepper-D8bRyyhl.js.map} +1 -1
  205. package/dist/{SwatchPicker-CpwVq0xp.cjs → SwatchPicker-BVW_yhRU.cjs} +2 -2
  206. package/dist/{SwatchPicker-CpwVq0xp.cjs.map → SwatchPicker-BVW_yhRU.cjs.map} +1 -1
  207. package/dist/{SwatchPicker-BAKslSY4.js → SwatchPicker-C-_wLaf6.js} +2 -2
  208. package/dist/{SwatchPicker-BAKslSY4.js.map → SwatchPicker-C-_wLaf6.js.map} +1 -1
  209. package/dist/{Table-PsNnKn_j.js → Table-C0RDylA0.js} +18 -18
  210. package/dist/{Table-PsNnKn_j.js.map → Table-C0RDylA0.js.map} +1 -1
  211. package/dist/{Table-CLjLsYYS.cjs → Table-CGIip6UL.cjs} +2 -2
  212. package/dist/{Table-CLjLsYYS.cjs.map → Table-CGIip6UL.cjs.map} +1 -1
  213. package/dist/{Tabs-DQoNP0QT.cjs → Tabs-BzbSNmBj.cjs} +2 -2
  214. package/dist/{Tabs-DQoNP0QT.cjs.map → Tabs-BzbSNmBj.cjs.map} +1 -1
  215. package/dist/{Tabs-B2WzlRXI.js → Tabs-CQvfqazt.js} +2 -2
  216. package/dist/{Tabs-B2WzlRXI.js.map → Tabs-CQvfqazt.js.map} +1 -1
  217. package/dist/{TagsField-pdvQU4zh.js → TagsField-BdM-xre0.js} +5 -5
  218. package/dist/{TagsField-pdvQU4zh.js.map → TagsField-BdM-xre0.js.map} +1 -1
  219. package/dist/{TagsField-CLfAAz4N.cjs → TagsField-CGL1oI7b.cjs} +2 -2
  220. package/dist/{TagsField-CLfAAz4N.cjs.map → TagsField-CGL1oI7b.cjs.map} +1 -1
  221. package/dist/{TextField-CgPfN-4d.cjs → TextField-D49Lpbjt.cjs} +2 -2
  222. package/dist/{TextField-CgPfN-4d.cjs.map → TextField-D49Lpbjt.cjs.map} +1 -1
  223. package/dist/{TextField-LONfx4jy.js → TextField-otYGVuwF.js} +4 -4
  224. package/dist/{TextField-LONfx4jy.js.map → TextField-otYGVuwF.js.map} +1 -1
  225. package/dist/{ThemeToggle-9RBaRALj.cjs → ThemeToggle-B8rkRTis.cjs} +2 -2
  226. package/dist/{ThemeToggle-9RBaRALj.cjs.map → ThemeToggle-B8rkRTis.cjs.map} +1 -1
  227. package/dist/{ThemeToggle-DTkFppOd.js → ThemeToggle-D33Tqv2F.js} +3 -3
  228. package/dist/{ThemeToggle-DTkFppOd.js.map → ThemeToggle-D33Tqv2F.js.map} +1 -1
  229. package/dist/{TimeColumns-B7af5Cbj.js → TimeColumns-DyjTpZbD.js} +2 -2
  230. package/dist/{TimeColumns-B7af5Cbj.js.map → TimeColumns-DyjTpZbD.js.map} +1 -1
  231. package/dist/{TimeColumns-CJ13uf3K.cjs → TimeColumns-qEHHZC1N.cjs} +2 -2
  232. package/dist/{TimeColumns-CJ13uf3K.cjs.map → TimeColumns-qEHHZC1N.cjs.map} +1 -1
  233. package/dist/{TimePicker-Dshko7IJ.cjs → TimePicker-DJrNO01U.cjs} +2 -2
  234. package/dist/{TimePicker-Dshko7IJ.cjs.map → TimePicker-DJrNO01U.cjs.map} +1 -1
  235. package/dist/{TimePicker-BitZ7wv-.js → TimePicker-yfYqLbj3.js} +6 -6
  236. package/dist/{TimePicker-BitZ7wv-.js.map → TimePicker-yfYqLbj3.js.map} +1 -1
  237. package/dist/{Toaster-8ynQTcc0.cjs → Toaster-B7Xd2IaM.cjs} +2 -2
  238. package/dist/{Toaster-8ynQTcc0.cjs.map → Toaster-B7Xd2IaM.cjs.map} +1 -1
  239. package/dist/{Toaster-CYVETXVZ.js → Toaster-D8cxkhwr.js} +2 -2
  240. package/dist/{Toaster-CYVETXVZ.js.map → Toaster-D8cxkhwr.js.map} +1 -1
  241. package/dist/{TranslatedFields-BKI3jrNd.cjs → TranslatedFields-BvqqdNWz.cjs} +2 -2
  242. package/dist/{TranslatedFields-BKI3jrNd.cjs.map → TranslatedFields-BvqqdNWz.cjs.map} +1 -1
  243. package/dist/{TranslatedFields-dmb-0Yn7.js → TranslatedFields-CsSsTrnF.js} +5 -5
  244. package/dist/{TranslatedFields-dmb-0Yn7.js.map → TranslatedFields-CsSsTrnF.js.map} +1 -1
  245. package/dist/Typography-ChSuxgkc.js +74 -0
  246. package/dist/Typography-ChSuxgkc.js.map +1 -0
  247. package/dist/Typography-d97DdbNd.cjs +2 -0
  248. package/dist/Typography-d97DdbNd.cjs.map +1 -0
  249. package/dist/{UserCard-pEJZqiDF.js → UserCard-CsZ4Ogac.js} +4 -4
  250. package/dist/{UserCard-pEJZqiDF.js.map → UserCard-CsZ4Ogac.js.map} +1 -1
  251. package/dist/{UserCard-ah6K1y0H.cjs → UserCard-Die7JV4z.cjs} +2 -2
  252. package/dist/{UserCard-ah6K1y0H.cjs.map → UserCard-Die7JV4z.cjs.map} +1 -1
  253. package/dist/components/Alert/index.cjs +1 -1
  254. package/dist/components/Alert/index.js +1 -1
  255. package/dist/components/AuthLayout/index.cjs +1 -1
  256. package/dist/components/AuthLayout/index.js +1 -1
  257. package/dist/components/Breadcrumbs/index.cjs +1 -1
  258. package/dist/components/Breadcrumbs/index.js +1 -1
  259. package/dist/components/Button/index.cjs +1 -1
  260. package/dist/components/Button/index.js +1 -1
  261. package/dist/components/Card/index.cjs +1 -1
  262. package/dist/components/Card/index.js +1 -1
  263. package/dist/components/Chip/index.cjs +1 -1
  264. package/dist/components/Chip/index.js +1 -1
  265. package/dist/components/ChoiceCard/index.cjs +1 -1
  266. package/dist/components/ChoiceCard/index.js +1 -1
  267. package/dist/components/CodeBlock/index.cjs +1 -1
  268. package/dist/components/CodeBlock/index.js +1 -1
  269. package/dist/components/ColorPicker/index.cjs +1 -1
  270. package/dist/components/ColorPicker/index.js +1 -1
  271. package/dist/components/ColorRamp/index.cjs +1 -1
  272. package/dist/components/ColorRamp/index.js +1 -1
  273. package/dist/components/CopyButton/index.cjs +1 -1
  274. package/dist/components/CopyButton/index.js +1 -1
  275. package/dist/components/DatePicker/index.cjs +1 -1
  276. package/dist/components/DatePicker/index.js +1 -1
  277. package/dist/components/DateTimePicker/index.cjs +1 -1
  278. package/dist/components/DateTimePicker/index.js +1 -1
  279. package/dist/components/DescriptionList/index.cjs +1 -1
  280. package/dist/components/DescriptionList/index.js +1 -1
  281. package/dist/components/EmptyState/index.cjs +1 -1
  282. package/dist/components/EmptyState/index.js +1 -1
  283. package/dist/components/ErrorState/ErrorDetailsModal.d.cts +12 -0
  284. package/dist/components/ErrorState/ErrorDetailsModal.d.ts +12 -0
  285. package/dist/components/ErrorState/ErrorState.d.cts +23 -24
  286. package/dist/components/ErrorState/ErrorState.d.ts +23 -24
  287. package/dist/components/ErrorState/QueryError.d.cts +3 -3
  288. package/dist/components/ErrorState/QueryError.d.ts +3 -3
  289. package/dist/components/ErrorState/index.cjs +1 -1
  290. package/dist/components/ErrorState/index.js +2 -2
  291. package/dist/components/FileCard/index.cjs +1 -1
  292. package/dist/components/FileCard/index.js +1 -1
  293. package/dist/components/FileUploader/index.cjs +1 -1
  294. package/dist/components/FileUploader/index.js +1 -1
  295. package/dist/components/Flag/index.cjs +1 -1
  296. package/dist/components/Flag/index.js +1 -1
  297. package/dist/components/FullscreenToggle/index.cjs +1 -1
  298. package/dist/components/FullscreenToggle/index.js +1 -1
  299. package/dist/components/IconButton/index.cjs +1 -1
  300. package/dist/components/IconButton/index.js +1 -1
  301. package/dist/components/Loader/index.cjs +1 -1
  302. package/dist/components/Loader/index.js +1 -1
  303. package/dist/components/LocationPicker/index.cjs +1 -1
  304. package/dist/components/LocationPicker/index.js +1 -1
  305. package/dist/components/Modal/index.cjs +1 -1
  306. package/dist/components/Modal/index.js +1 -1
  307. package/dist/components/MultiSelect/index.cjs +1 -1
  308. package/dist/components/MultiSelect/index.js +1 -1
  309. package/dist/components/MultilineTextField/index.cjs +1 -1
  310. package/dist/components/MultilineTextField/index.js +1 -1
  311. package/dist/components/NumberField/index.cjs +1 -1
  312. package/dist/components/NumberField/index.js +1 -1
  313. package/dist/components/OtpField/index.cjs +1 -1
  314. package/dist/components/OtpField/index.js +1 -1
  315. package/dist/components/PageError/index.cjs +1 -1
  316. package/dist/components/PageError/index.js +1 -1
  317. package/dist/components/PageLayout/index.cjs +1 -1
  318. package/dist/components/PageLayout/index.js +1 -1
  319. package/dist/components/PageNotFound/index.cjs +1 -1
  320. package/dist/components/PageNotFound/index.js +1 -1
  321. package/dist/components/Pagination/index.cjs +1 -1
  322. package/dist/components/Pagination/index.js +1 -1
  323. package/dist/components/PaletteField/index.cjs +1 -1
  324. package/dist/components/PaletteField/index.js +1 -1
  325. package/dist/components/PhoneField/index.cjs +1 -1
  326. package/dist/components/PhoneField/index.js +1 -1
  327. package/dist/components/Popconfirm/index.cjs +1 -1
  328. package/dist/components/Popconfirm/index.js +1 -1
  329. package/dist/components/Progress/index.cjs +1 -1
  330. package/dist/components/Progress/index.js +1 -1
  331. package/dist/components/QrCode/index.cjs +1 -1
  332. package/dist/components/QrCode/index.js +1 -1
  333. package/dist/components/Radio/index.cjs +1 -1
  334. package/dist/components/Radio/index.js +1 -1
  335. package/dist/components/RemoveDialog/index.cjs +1 -1
  336. package/dist/components/RemoveDialog/index.js +1 -1
  337. package/dist/components/RichTextEditor/index.cjs +1 -1
  338. package/dist/components/RichTextEditor/index.js +1 -1
  339. package/dist/components/RootLayout/RootLayout.d.cts +6 -1
  340. package/dist/components/RootLayout/RootLayout.d.ts +6 -1
  341. package/dist/components/RootLayout/index.cjs +1 -1
  342. package/dist/components/RootLayout/index.js +1 -1
  343. package/dist/components/Select/index.cjs +1 -1
  344. package/dist/components/Select/index.js +1 -1
  345. package/dist/components/Sidebar/index.cjs +1 -1
  346. package/dist/components/Sidebar/index.js +1 -1
  347. package/dist/components/Slider/index.cjs +1 -1
  348. package/dist/components/Slider/index.js +1 -1
  349. package/dist/components/SpeedDial/index.cjs +1 -1
  350. package/dist/components/SpeedDial/index.js +1 -1
  351. package/dist/components/Stepper/index.cjs +1 -1
  352. package/dist/components/Stepper/index.js +1 -1
  353. package/dist/components/SwatchPicker/index.cjs +1 -1
  354. package/dist/components/SwatchPicker/index.js +1 -1
  355. package/dist/components/Table/index.cjs +1 -1
  356. package/dist/components/Table/index.js +1 -1
  357. package/dist/components/Tabs/index.cjs +1 -1
  358. package/dist/components/Tabs/index.js +1 -1
  359. package/dist/components/TagsField/index.cjs +1 -1
  360. package/dist/components/TagsField/index.js +1 -1
  361. package/dist/components/TextField/index.cjs +1 -1
  362. package/dist/components/TextField/index.js +1 -1
  363. package/dist/components/ThemeToggle/index.cjs +1 -1
  364. package/dist/components/ThemeToggle/index.js +1 -1
  365. package/dist/components/TimePicker/index.cjs +1 -1
  366. package/dist/components/TimePicker/index.js +1 -1
  367. package/dist/components/Toast/index.cjs +1 -1
  368. package/dist/components/Toast/index.js +1 -1
  369. package/dist/components/TranslatedFields/index.cjs +1 -1
  370. package/dist/components/TranslatedFields/index.js +1 -1
  371. package/dist/components/Typography/Typography.d.cts +7 -1
  372. package/dist/components/Typography/Typography.d.ts +7 -1
  373. package/dist/components/Typography/index.cjs +1 -1
  374. package/dist/components/Typography/index.js +1 -1
  375. package/dist/components/UserCard/index.cjs +1 -1
  376. package/dist/components/UserCard/index.js +1 -1
  377. package/dist/entries/app.cjs +1 -1
  378. package/dist/entries/app.js +1 -1
  379. package/dist/entries/components.cjs +1 -1
  380. package/dist/entries/components.js +58 -58
  381. package/dist/entries/i18n.cjs +1 -1
  382. package/dist/entries/i18n.js +2 -2
  383. package/dist/entries/theme.cjs +1 -1
  384. package/dist/entries/theme.d.cts +1 -1
  385. package/dist/entries/theme.d.ts +1 -1
  386. package/dist/entries/theme.js +1 -1
  387. package/dist/i18n/messages.d.cts +6 -0
  388. package/dist/i18n/messages.d.ts +6 -0
  389. package/dist/index.cjs +1 -1
  390. package/dist/index.css +1 -1
  391. package/dist/index.js +61 -61
  392. package/dist/messages-DYXyWU3X.cjs +36 -0
  393. package/dist/messages-DYXyWU3X.cjs.map +1 -0
  394. package/dist/{messages-C1eTrGJy.js → messages-zarEtcsN.js} +25 -4
  395. package/dist/messages-zarEtcsN.js.map +1 -0
  396. package/dist/theme/ConfigProvider.d.cts +21 -2
  397. package/dist/theme/ConfigProvider.d.ts +21 -2
  398. package/dist/theme/index.d.cts +1 -1
  399. package/dist/theme/index.d.ts +1 -1
  400. package/dist/{useHomeTo-yTXajO22.js → useHomeTo-DVMyLZbb.js} +2 -2
  401. package/dist/{useHomeTo-yTXajO22.js.map → useHomeTo-DVMyLZbb.js.map} +1 -1
  402. package/dist/{useHomeTo-Cr6Usr_D.cjs → useHomeTo-Dnu6VAvU.cjs} +2 -2
  403. package/dist/{useHomeTo-Cr6Usr_D.cjs.map → useHomeTo-Dnu6VAvU.cjs.map} +1 -1
  404. package/dist/{useOptionMenu-DK0ixg-p.js → useOptionMenu-DNYlfNO_.js} +4 -4
  405. package/dist/{useOptionMenu-DK0ixg-p.js.map → useOptionMenu-DNYlfNO_.js.map} +1 -1
  406. package/dist/{useOptionMenu-DHGSbQmS.cjs → useOptionMenu-OAYGUWP_.cjs} +2 -2
  407. package/dist/{useOptionMenu-DHGSbQmS.cjs.map → useOptionMenu-OAYGUWP_.cjs.map} +1 -1
  408. package/package.json +1 -1
  409. package/dist/ConfigProvider-CVLHPXQm.cjs.map +0 -1
  410. package/dist/ConfigProvider-tvLbKiqu.js.map +0 -1
  411. package/dist/ErrorBoundary-8iu-mR5Y.cjs +0 -2
  412. package/dist/ErrorBoundary-8iu-mR5Y.cjs.map +0 -1
  413. package/dist/ErrorBoundary-BSJL381Y.js.map +0 -1
  414. package/dist/ErrorState-BXMjBWav.cjs +0 -4
  415. package/dist/ErrorState-BXMjBWav.cjs.map +0 -1
  416. package/dist/ErrorState-DKhZ4aJh.js +0 -142
  417. package/dist/ErrorState-DKhZ4aJh.js.map +0 -1
  418. package/dist/PageError-ClR7k0Zb.js +0 -69
  419. package/dist/PageError-D7_Q8wz8.cjs +0 -2
  420. package/dist/RootLayout-C7n79JjM.js +0 -621
  421. package/dist/RootLayout-C7n79JjM.js.map +0 -1
  422. package/dist/RootLayout-CtkpgPGV.cjs +0 -2
  423. package/dist/RootLayout-CtkpgPGV.cjs.map +0 -1
  424. package/dist/Typography-B6ASPrzT.cjs +0 -2
  425. package/dist/Typography-B6ASPrzT.cjs.map +0 -1
  426. package/dist/Typography-CJv5AnRP.js +0 -70
  427. package/dist/Typography-CJv5AnRP.js.map +0 -1
  428. package/dist/messages-C1eTrGJy.js.map +0 -1
  429. package/dist/messages-DCr7iFmv.cjs +0 -36
  430. package/dist/messages-DCr7iFmv.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"MultilineTextField-B6EYAdik.cjs","sources":["../src/components/MultilineTextField/MultilineTextField.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ChangeEvent,\n type CSSProperties,\n type FocusEvent,\n type ReactNode,\n type TextareaHTMLAttributes,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useFormContext } from '../../form/formContext'\nimport { Typography } from '../Typography'\nimport styles from './MultilineTextField.module.css'\n\nexport type MultilineTextFieldSize = 'sm' | 'md' | 'lg'\n\nexport interface MultilineTextFieldProps extends Omit<\n TextareaHTMLAttributes<HTMLTextAreaElement>,\n 'size' | 'rows'\n> {\n /** Label rendered above the field. */\n label?: ReactNode\n /** Preset size — drives the font size (the height is dynamic). */\n size?: MultilineTextFieldSize\n /** Marks the field invalid: red border/focus ring and the `helperText` shown in the error color. */\n error?: boolean\n /** Helper / validation text under the field. Adopts the error color while `error`. */\n helperText?: ReactNode\n /** Adds a red asterisk after the label (visual hint only — combine with native `required` if needed). */\n required?: boolean\n /** Stretches the field to fill its container width. Defaults to `true`. */\n fullWidth?: boolean\n /** Minimum visible rows — the field's starting (and smallest) height. Defaults to `3`. */\n minRows?: number\n /** Maximum rows before the field stops growing and scrolls instead. Defaults to `6` (pass `Infinity` for unbounded growth). */\n maxRows?: number\n}\n\n/**\n * A labeled multiline text input — the textarea sibling of `TextField`. It shares TextField's chrome\n * (label, helper/validation text, error state, sizes, `<Form>` binding by `name`), but renders a\n * `<textarea>` whose **height is dynamic**: it auto-grows with the content from `minRows` up to\n * `maxRows` (then scrolls). Works controlled (`value` + `onChange`) or uncontrolled\n * (`defaultValue`). Styling comes entirely from `--tz-*` tokens.\n */\nexport const MultilineTextField = forwardRef<HTMLTextAreaElement, MultilineTextFieldProps>(\n function MultilineTextField(\n {\n label,\n size = 'md',\n error,\n helperText,\n required = false,\n fullWidth = true,\n minRows = 3,\n maxRows = 6,\n name,\n value,\n defaultValue,\n onChange,\n onBlur,\n disabled = false,\n id: idProp,\n className,\n style,\n ...props\n },\n ref,\n ) {\n const reactId = useId()\n const id = idProp ?? reactId\n const helperId = `${id}-helper`\n\n // Auto-bind to a surrounding <Form> by `name` — pulls value/onChange/onBlur/error/helperText.\n // Explicit props still win.\n const form = useFormContext()\n const bound = form && name ? form.field(name) : undefined\n\n const resolvedError = error ?? bound?.error ?? false\n const resolvedHelperText = helperText ?? bound?.helperText\n\n const isControlled = value !== undefined || bound !== undefined\n const [internal, setInternal] = useState<string>(\n defaultValue != null ? String(defaultValue) : '',\n )\n const currentValue = value !== undefined ? value : bound ? bound.value : internal\n\n // Merge the forwarded ref with an internal one so we can measure/resize the textarea.\n const innerRef = useRef<HTMLTextAreaElement | null>(null)\n const setRef = useCallback(\n (node: HTMLTextAreaElement | null) => {\n innerRef.current = node\n if (typeof ref === 'function') ref(node)\n else if (ref) (ref as { current: HTMLTextAreaElement | null }).current = node\n },\n [ref],\n )\n\n // Dynamic height: collapse to `auto`, then grow to fit the content, capped at `maxRows`.\n const autosize = useCallback(() => {\n const el = innerRef.current\n if (!el) return\n el.style.height = 'auto'\n const cs = getComputedStyle(el)\n const fontSize = parseFloat(cs.fontSize) || 16\n const lineHeight = parseFloat(cs.lineHeight) || fontSize * 1.4\n const padV = parseFloat(cs.paddingTop) + parseFloat(cs.paddingBottom)\n let next = el.scrollHeight\n if (maxRows != null) {\n const maxH = lineHeight * maxRows + padV\n if (next > maxH) {\n next = maxH\n el.style.overflowY = 'auto'\n } else {\n el.style.overflowY = 'hidden'\n }\n }\n el.style.height = `${next}px`\n }, [maxRows])\n\n // Resize after every value change (no flash — runs before paint), and when the width changes.\n useLayoutEffect(() => {\n autosize()\n }, [autosize, currentValue, minRows])\n\n useEffect(() => {\n const onResize = () => autosize()\n window.addEventListener('resize', onResize)\n return () => window.removeEventListener('resize', onResize)\n }, [autosize])\n\n const handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {\n if (!isControlled) setInternal(event.target.value)\n // The form's field reads only `event.target.value`; a textarea event is shape-compatible.\n bound?.onChange(event as unknown as ChangeEvent<HTMLInputElement>)\n onChange?.(event)\n }\n\n const handleBlur = (event: FocusEvent<HTMLTextAreaElement>) => {\n bound?.onBlur(event as unknown as FocusEvent<HTMLInputElement>)\n onBlur?.(event)\n }\n\n return (\n <div\n className={clsx(\n styles.field,\n styles[size],\n fullWidth && styles.fullWidth,\n resolvedError && styles.error,\n disabled && styles.disabled,\n className,\n )}\n style={style as CSSProperties}\n >\n {label != null && (\n <label htmlFor={id} className={styles.label}>\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\">\n {label}\n </Typography>\n {required && (\n <span className={styles.required} aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n )}\n\n <div className={styles.control}>\n <textarea\n ref={setRef}\n id={id}\n name={name}\n rows={minRows}\n className={styles.textarea}\n value={currentValue}\n onChange={handleChange}\n onBlur={handleBlur}\n disabled={disabled}\n aria-invalid={resolvedError || undefined}\n aria-describedby={resolvedHelperText != null ? helperId : undefined}\n {...props}\n />\n </div>\n\n {resolvedHelperText != null && (\n <Typography\n as=\"span\"\n id={helperId}\n variant=\"bodySmall\"\n color={resolvedError ? 'error' : 'muted'}\n className={styles.helper}\n >\n {resolvedHelperText}\n </Typography>\n )}\n </div>\n )\n },\n)\n"],"names":["MultilineTextField","forwardRef","label","size","error","helperText","required","fullWidth","minRows","maxRows","name","value","defaultValue","onChange","onBlur","disabled","idProp","className","style","props","ref","reactId","useId","id","helperId","form","useFormContext","bound","resolvedError","resolvedHelperText","isControlled","internal","setInternal","useState","currentValue","innerRef","useRef","setRef","useCallback","node","autosize","el","cs","fontSize","lineHeight","padV","next","maxH","useLayoutEffect","useEffect","onResize","handleChange","event","handleBlur","jsxs","clsx","styles","jsx","Typography"],"mappings":"mhBAkDaA,GAAqBC,EAAAA,WAChC,SACE,CACE,MAAAC,EACA,KAAAC,EAAO,KACP,MAAAC,EACA,WAAAC,EACA,SAAAC,EAAW,GACX,UAAAC,EAAY,GACZ,QAAAC,EAAU,EACV,QAAAC,EAAU,EACV,KAAAC,EACA,MAAAC,EACA,aAAAC,EACA,SAAAC,EACA,OAAAC,EACA,SAAAC,EAAW,GACX,GAAIC,EACJ,UAAAC,EACA,MAAAC,EACA,GAAGC,CAAA,EAELC,EACA,CACA,MAAMC,EAAUC,EAAAA,MAAA,EACVC,EAAKP,GAAUK,EACfG,EAAW,GAAGD,CAAE,UAIhBE,EAAOC,EAAAA,eAAA,EACPC,EAAQF,GAAQf,EAAOe,EAAK,MAAMf,CAAI,EAAI,OAE1CkB,EAAgBxB,IAASuB,GAAA,YAAAA,EAAO,QAAS,GACzCE,EAAqBxB,IAAcsB,GAAA,YAAAA,EAAO,YAE1CG,EAAenB,IAAU,QAAagB,IAAU,OAChD,CAACI,EAAUC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,MAAAA,EAAWuC,EACb,EAEMC,EAAcD,GAA2C,CAC7DzB,GAAA,MAAAA,EAAO,OAAOyB,GACdtC,GAAA,MAAAA,EAASsC,EACX,EAEA,OACEE,EAAAA,KAAC,MAAA,CACC,UAAWC,EAAAA,KACTC,EAAO,MACPA,EAAOrD,CAAI,EACXI,GAAaiD,EAAO,UACpB5B,GAAiB4B,EAAO,MACxBzC,GAAYyC,EAAO,SACnBvC,CAAA,EAEF,MAAAC,EAEC,SAAA,CAAAhB,GAAS,MACRoD,OAAC,QAAA,CAAM,QAAS/B,EAAI,UAAWiC,EAAO,MACpC,SAAA,CAAAC,EAAAA,IAACC,EAAAA,YAAW,GAAG,OAAO,QAAQ,YAAY,MAAM,QAC7C,SAAAxD,CAAA,CACH,EACCI,SACE,OAAA,CAAK,UAAWkD,EAAO,SAAU,cAAY,OAAO,SAAA,GAAA,CAErD,CAAA,EAEJ,EAGFC,EAAAA,IAAC,MAAA,CAAI,UAAWD,EAAO,QACrB,SAAAC,EAAAA,IAAC,WAAA,CACC,IAAKpB,EACL,GAAAd,EACA,KAAAb,EACA,KAAMF,EACN,UAAWgD,EAAO,SAClB,MAAOtB,EACP,SAAUiB,EACV,OAAQE,EACR,SAAAtC,EACA,eAAca,GAAiB,OAC/B,mBAAkBC,GAAsB,KAAOL,EAAW,OACzD,GAAGL,CAAA,CAAA,EAER,EAECU,GAAsB,MACrB4B,EAAAA,IAACC,EAAAA,WAAA,CACC,GAAG,OACH,GAAIlC,EACJ,QAAQ,YACR,MAAOI,EAAgB,QAAU,QACjC,UAAW4B,EAAO,OAEjB,SAAA3B,CAAA,CAAA,CACH,CAAA,CAAA,CAIR,CACF"}
1
+ {"version":3,"file":"MultilineTextField-ihcPDX3D.cjs","sources":["../src/components/MultilineTextField/MultilineTextField.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ChangeEvent,\n type CSSProperties,\n type FocusEvent,\n type ReactNode,\n type TextareaHTMLAttributes,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useFormContext } from '../../form/formContext'\nimport { Typography } from '../Typography'\nimport styles from './MultilineTextField.module.css'\n\nexport type MultilineTextFieldSize = 'sm' | 'md' | 'lg'\n\nexport interface MultilineTextFieldProps extends Omit<\n TextareaHTMLAttributes<HTMLTextAreaElement>,\n 'size' | 'rows'\n> {\n /** Label rendered above the field. */\n label?: ReactNode\n /** Preset size — drives the font size (the height is dynamic). */\n size?: MultilineTextFieldSize\n /** Marks the field invalid: red border/focus ring and the `helperText` shown in the error color. */\n error?: boolean\n /** Helper / validation text under the field. Adopts the error color while `error`. */\n helperText?: ReactNode\n /** Adds a red asterisk after the label (visual hint only — combine with native `required` if needed). */\n required?: boolean\n /** Stretches the field to fill its container width. Defaults to `true`. */\n fullWidth?: boolean\n /** Minimum visible rows — the field's starting (and smallest) height. Defaults to `3`. */\n minRows?: number\n /** Maximum rows before the field stops growing and scrolls instead. Defaults to `6` (pass `Infinity` for unbounded growth). */\n maxRows?: number\n}\n\n/**\n * A labeled multiline text input — the textarea sibling of `TextField`. It shares TextField's chrome\n * (label, helper/validation text, error state, sizes, `<Form>` binding by `name`), but renders a\n * `<textarea>` whose **height is dynamic**: it auto-grows with the content from `minRows` up to\n * `maxRows` (then scrolls). Works controlled (`value` + `onChange`) or uncontrolled\n * (`defaultValue`). Styling comes entirely from `--tz-*` tokens.\n */\nexport const MultilineTextField = forwardRef<HTMLTextAreaElement, MultilineTextFieldProps>(\n function MultilineTextField(\n {\n label,\n size = 'md',\n error,\n helperText,\n required = false,\n fullWidth = true,\n minRows = 3,\n maxRows = 6,\n name,\n value,\n defaultValue,\n onChange,\n onBlur,\n disabled = false,\n id: idProp,\n className,\n style,\n ...props\n },\n ref,\n ) {\n const reactId = useId()\n const id = idProp ?? reactId\n const helperId = `${id}-helper`\n\n // Auto-bind to a surrounding <Form> by `name` — pulls value/onChange/onBlur/error/helperText.\n // Explicit props still win.\n const form = useFormContext()\n const bound = form && name ? form.field(name) : undefined\n\n const resolvedError = error ?? bound?.error ?? false\n const resolvedHelperText = helperText ?? bound?.helperText\n\n const isControlled = value !== undefined || bound !== undefined\n const [internal, setInternal] = useState<string>(\n defaultValue != null ? String(defaultValue) : '',\n )\n const currentValue = value !== undefined ? value : bound ? bound.value : internal\n\n // Merge the forwarded ref with an internal one so we can measure/resize the textarea.\n const innerRef = useRef<HTMLTextAreaElement | null>(null)\n const setRef = useCallback(\n (node: HTMLTextAreaElement | null) => {\n innerRef.current = node\n if (typeof ref === 'function') ref(node)\n else if (ref) (ref as { current: HTMLTextAreaElement | null }).current = node\n },\n [ref],\n )\n\n // Dynamic height: collapse to `auto`, then grow to fit the content, capped at `maxRows`.\n const autosize = useCallback(() => {\n const el = innerRef.current\n if (!el) return\n el.style.height = 'auto'\n const cs = getComputedStyle(el)\n const fontSize = parseFloat(cs.fontSize) || 16\n const lineHeight = parseFloat(cs.lineHeight) || fontSize * 1.4\n const padV = parseFloat(cs.paddingTop) + parseFloat(cs.paddingBottom)\n let next = el.scrollHeight\n if (maxRows != null) {\n const maxH = lineHeight * maxRows + padV\n if (next > maxH) {\n next = maxH\n el.style.overflowY = 'auto'\n } else {\n el.style.overflowY = 'hidden'\n }\n }\n el.style.height = `${next}px`\n }, [maxRows])\n\n // Resize after every value change (no flash — runs before paint), and when the width changes.\n useLayoutEffect(() => {\n autosize()\n }, [autosize, currentValue, minRows])\n\n useEffect(() => {\n const onResize = () => autosize()\n window.addEventListener('resize', onResize)\n return () => window.removeEventListener('resize', onResize)\n }, [autosize])\n\n const handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {\n if (!isControlled) setInternal(event.target.value)\n // The form's field reads only `event.target.value`; a textarea event is shape-compatible.\n bound?.onChange(event as unknown as ChangeEvent<HTMLInputElement>)\n onChange?.(event)\n }\n\n const handleBlur = (event: FocusEvent<HTMLTextAreaElement>) => {\n bound?.onBlur(event as unknown as FocusEvent<HTMLInputElement>)\n onBlur?.(event)\n }\n\n return (\n <div\n className={clsx(\n styles.field,\n styles[size],\n fullWidth && styles.fullWidth,\n resolvedError && styles.error,\n disabled && styles.disabled,\n className,\n )}\n style={style as CSSProperties}\n >\n {label != null && (\n <label htmlFor={id} className={styles.label}>\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\">\n {label}\n </Typography>\n {required && (\n <span className={styles.required} aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n )}\n\n <div className={styles.control}>\n <textarea\n ref={setRef}\n id={id}\n name={name}\n rows={minRows}\n className={styles.textarea}\n value={currentValue}\n onChange={handleChange}\n onBlur={handleBlur}\n disabled={disabled}\n aria-invalid={resolvedError || undefined}\n aria-describedby={resolvedHelperText != null ? helperId : undefined}\n {...props}\n />\n </div>\n\n {resolvedHelperText != null && (\n <Typography\n as=\"span\"\n id={helperId}\n variant=\"bodySmall\"\n color={resolvedError ? 'error' : 'muted'}\n className={styles.helper}\n >\n {resolvedHelperText}\n </Typography>\n )}\n </div>\n )\n },\n)\n"],"names":["MultilineTextField","forwardRef","label","size","error","helperText","required","fullWidth","minRows","maxRows","name","value","defaultValue","onChange","onBlur","disabled","idProp","className","style","props","ref","reactId","useId","id","helperId","form","useFormContext","bound","resolvedError","resolvedHelperText","isControlled","internal","setInternal","useState","currentValue","innerRef","useRef","setRef","useCallback","node","autosize","el","cs","fontSize","lineHeight","padV","next","maxH","useLayoutEffect","useEffect","onResize","handleChange","event","handleBlur","jsxs","clsx","styles","jsx","Typography"],"mappings":"mhBAkDaA,GAAqBC,EAAAA,WAChC,SACE,CACE,MAAAC,EACA,KAAAC,EAAO,KACP,MAAAC,EACA,WAAAC,EACA,SAAAC,EAAW,GACX,UAAAC,EAAY,GACZ,QAAAC,EAAU,EACV,QAAAC,EAAU,EACV,KAAAC,EACA,MAAAC,EACA,aAAAC,EACA,SAAAC,EACA,OAAAC,EACA,SAAAC,EAAW,GACX,GAAIC,EACJ,UAAAC,EACA,MAAAC,EACA,GAAGC,CAAA,EAELC,EACA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J,QAAQ,YACR,MAAOI,EAAgB,QAAU,QACjC,UAAW4B,EAAO,OAEjB,SAAA3B,CAAA,CAAA,CACH,CAAA,CAAA,CAIR,CACF"}
@@ -3,10 +3,10 @@ import { forwardRef as ye, useId as be, useState as J, useEffect as Ie, useRef a
3
3
  import { clsx as O } from "clsx";
4
4
  import { u as Fe } from "./formContext-B7ln1Miy.js";
5
5
  import { I as Q } from "./Icon-CGQ5yGSZ.js";
6
- import { I as X } from "./IconButton-sC_E_TXd.js";
7
- import { T as Y } from "./Typography-CJv5AnRP.js";
6
+ import { I as X } from "./IconButton-BUmXN_lD.js";
7
+ import { T as Y } from "./Typography-ChSuxgkc.js";
8
8
  import { f as r } from "./TextField.module-6gYcR9TL.js";
9
- import { a as Me } from "./ConfigProvider-tvLbKiqu.js";
9
+ import { a as Me } from "./ConfigProvider-DZMtq2Fz.js";
10
10
  const Z = /^-?\d*\.?\d*$/;
11
11
  function V(t) {
12
12
  if (t === "" || t === "-" || t === "." || t === "-.") return null;
@@ -180,4 +180,4 @@ const We = ye(function({
180
180
  export {
181
181
  We as N
182
182
  };
183
- //# sourceMappingURL=NumberField-P68n6q5m.js.map
183
+ //# sourceMappingURL=NumberField-DEoaxFJj.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NumberField-P68n6q5m.js","sources":["../src/components/NumberField/NumberField.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ChangeEvent,\n type CSSProperties,\n type FocusEvent,\n type InputHTMLAttributes,\n type ReactNode,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useFormContext } from '../../form/formContext'\nimport { useT } from '../../theme'\nimport { Icon } from '../Icon'\nimport { IconButton } from '../IconButton'\nimport { Typography } from '../Typography'\n// shared field chrome (label/control/helper) AND the `.control .iconButton` styling for the steppers\nimport fieldStyles from '../TextField/TextField.module.css'\n\nexport type NumberFieldSize = 'sm' | 'md' | 'lg'\n\n/** Allowed while typing — digits, an optional leading `-`, and one decimal point. */\nconst NUMERIC_RE = /^-?\\d*\\.?\\d*$/\n\n/** Parses the display string to a number, treating empty / in-progress input (`\"\"`, `\"-\"`, `\".\"`) as null. */\nfunction parseValue(raw: string): number | null {\n if (raw === '' || raw === '-' || raw === '.' || raw === '-.') return null\n const n = Number(raw)\n return Number.isNaN(n) ? null : n\n}\n\nfunction clampValue(n: number, min?: number, max?: number): number {\n if (min != null && n < min) return min\n if (max != null && n > max) return max\n return n\n}\n\n/** Kills binary float drift from repeated stepping (e.g. 0.1 + 0.2). */\nfunction roundStep(n: number): number {\n return Math.round(n * 1e6) / 1e6\n}\n\n/** Groups the integer part with `separator` for display (e.g. 32345345 → \"32.345.345\"). */\nfunction groupThousands(value: number, separator: string): string {\n const [intPart, decPart] = String(value).split('.')\n const sign = intPart.startsWith('-') ? '-' : ''\n const digits = sign ? intPart.slice(1) : intPart\n const grouped = digits.replace(/\\B(?=(\\d{3})+(?!\\d))/g, separator)\n return decPart != null ? `${sign}${grouped}.${decPart}` : `${sign}${grouped}`\n}\n\n/** Counts the \"significant\" (non-separator) chars — used to keep the caret stable across regrouping. */\nfunction countExcept(s: string, sep: string): number {\n let n = 0\n for (const c of s) if (c !== sep) n++\n return n\n}\n\n/** Index just after the `n`-th non-separator char in `str` (where the caret should land after regrouping). */\nfunction positionAfterExcept(str: string, sep: string, n: number): number {\n if (n <= 0) return 0\n let count = 0\n for (let i = 0; i < str.length; i++) {\n if (str[i] !== sep) {\n count += 1\n if (count === n) return i + 1\n }\n }\n return str.length\n}\n\nexport interface NumberFieldProps extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'size' | 'value' | 'defaultValue' | 'onChange' | 'type' | 'min' | 'max' | 'step' | 'prefix'\n> {\n /** Label rendered above the field. */\n label?: ReactNode\n /** Preset size — drives the control height, font size and padding. */\n size?: NumberFieldSize\n /** Marks the field invalid: red border/focus ring + the `helperText` in the error color. */\n error?: boolean\n /** Helper / validation text under the field. Adopts the error color while `error`. */\n helperText?: ReactNode\n /** Adds a red asterisk after the label. */\n required?: boolean\n /** Stretches the field to fill its container width. Defaults to `true`. */\n fullWidth?: boolean\n /** Controlled numeric value (`null` = empty). */\n value?: number | null\n /** Initial value for uncontrolled use (`null` = empty). Defaults to `null`. */\n defaultValue?: number | null\n /** Fires with the parsed numeric value (or `null` when the field is empty). */\n onChange?: (value: number | null) => void\n /** Minimum value — clamps on blur and on the stepper, and disables `−` at the floor. Defaults to `0`; pass a negative `min` to allow negatives. */\n min?: number\n /** Maximum value — clamps on blur and on the stepper, and disables `+` at the ceiling. */\n max?: number\n /** Amount the `+`/`−` buttons add or subtract. Defaults to `1`. */\n step?: number\n /** Hides the `+`/`−` stepper buttons (keyboard entry only). */\n hideStepper?: boolean\n /**\n * Thousands-group separator shown **live** as you type, e.g. `\".\"` displays `32345345` as\n * `32.345.345` (or `\",\"`). The caret is preserved across regrouping; the `value`/`onChange`/form\n * value stay a plain `number`. Best for integers — with `\".\"` decimals aren't supported (the dot is\n * the group separator).\n */\n thousandSeparator?: string\n}\n\n/**\n * A numeric input with `+`/`−` stepper buttons. Supports `min`/`max` clamping, a `step` amount,\n * controlled (`value` + `onChange`) or uncontrolled (`defaultValue`) use, optional live thousands\n * grouping, and — like `TextField` — binds to a surrounding `<Form>` by `name` (its form value is a\n * real `number`, validated by the Zod schema). `onChange` emits a `number` or `null` (empty). Shares\n * `TextField`'s field chrome, so label, sizing, error and focus styling are identical.\n */\nexport const NumberField = forwardRef<HTMLInputElement, NumberFieldProps>(function NumberField(\n {\n label,\n size = 'md',\n error,\n helperText,\n required = false,\n fullWidth = true,\n value,\n defaultValue = null,\n onChange,\n min = 0,\n max,\n step = 1,\n hideStepper = false,\n thousandSeparator,\n name,\n onBlur,\n disabled = false,\n id: idProp,\n className,\n style,\n ...props\n },\n ref,\n) {\n const t = useT()\n const reactId = useId()\n const id = idProp ?? reactId\n const helperId = `${id}-helper`\n\n // Auto-bind to a surrounding <Form> by `name`. The form stores a real number; we use field() for\n // touched/error/helper and read/write the numeric value through values/setValue.\n const form = useFormContext()\n const isFormBound = Boolean(form && name)\n const bound = form && name ? form.field(name) : undefined\n\n const externalValue: number | null | undefined =\n value !== undefined\n ? value\n : isFormBound\n ? ((form!.values[name!] as number | null | undefined) ?? null)\n : undefined\n const isControlled = externalValue !== undefined\n const [internal, setInternal] = useState<number | null>(defaultValue)\n const numValue: number | null = isControlled ? externalValue! : internal\n\n // number <-> display string, applying live thousands grouping when `thousandSeparator` is set.\n const toDisplay = (v: number | null): string =>\n v == null ? '' : thousandSeparator != null ? groupThousands(v, thousandSeparator) : String(v)\n const fromDisplay = (raw: string): number | null =>\n parseValue(thousandSeparator != null ? raw.split(thousandSeparator).join('') : raw)\n\n // The display string mirrors `numValue` but tolerates in-progress input (\"-\", \"1.\" …).\n const [text, setText] = useState<string>(() => toDisplay(numValue))\n useEffect(() => {\n if (fromDisplay(text) !== numValue) setText(toDisplay(numValue))\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [numValue]) // re-sync only when the value changes from the outside (stepper, form, reset)\n\n // Caret restoration after regrouping (the formatted string length changes as separators move).\n const innerRef = useRef<HTMLInputElement>(null)\n const pendingCaret = useRef<number | null>(null)\n const setInputRef = useCallback(\n (node: HTMLInputElement | null) => {\n innerRef.current = node\n if (typeof ref === 'function') ref(node)\n else if (ref) ref.current = node\n },\n [ref],\n )\n useLayoutEffect(() => {\n const pos = pendingCaret.current\n if (pos == null) return\n pendingCaret.current = null\n innerRef.current?.setSelectionRange(pos, pos)\n })\n\n const resolvedError = error ?? bound?.error ?? false\n const resolvedHelperText = helperText ?? bound?.helperText\n\n const commit = (next: number | null) => {\n if (!isControlled) setInternal(next)\n if (isFormBound) form!.setValue(name!, next)\n onChange?.(next)\n }\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const el = event.target\n const raw = el.value\n\n if (thousandSeparator == null) {\n if (raw !== '' && !NUMERIC_RE.test(raw)) return // reject non-numeric keystrokes\n setText(raw)\n commit(parseValue(raw))\n return\n }\n\n // Live grouping: strip separators, validate, regroup, and remember where the caret should land.\n const sep = thousandSeparator\n const cleaned = raw.split(sep).join('')\n if (cleaned !== '' && !NUMERIC_RE.test(cleaned)) return\n const caret = el.selectionStart ?? raw.length\n const significantBefore = countExcept(raw.slice(0, caret), sep)\n const next = parseValue(cleaned)\n const formatted = next == null ? cleaned : groupThousands(next, sep)\n setText(formatted)\n commit(next)\n pendingCaret.current = positionAfterExcept(formatted, sep, significantBefore)\n }\n\n const handleBlur = (event: FocusEvent<HTMLInputElement>) => {\n if (numValue != null) {\n const clamped = clampValue(numValue, min, max)\n if (clamped !== numValue) commit(clamped)\n }\n bound?.onBlur(event)\n onBlur?.(event)\n }\n\n const stepBy = (direction: 1 | -1) => {\n const base = numValue ?? min ?? 0\n commit(clampValue(roundStep(base + direction * step), min, max))\n }\n\n const atMax = max != null && numValue != null && numValue >= max\n const atMin = min != null && numValue != null && numValue <= min\n\n return (\n <div\n className={clsx(\n fieldStyles.field,\n fieldStyles[size],\n fullWidth && fieldStyles.fullWidth,\n resolvedError && fieldStyles.error,\n disabled && fieldStyles.disabled,\n className,\n )}\n style={style as CSSProperties}\n >\n {label != null && (\n <label htmlFor={id} className={fieldStyles.label}>\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\">\n {label}\n </Typography>\n {required && (\n <span className={fieldStyles.required} aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n )}\n\n <div className={clsx(fieldStyles.control, !hideStepper && fieldStyles.hasRightAdornment)}>\n <input\n ref={setInputRef}\n id={id}\n name={name}\n type=\"text\"\n inputMode=\"decimal\"\n className={fieldStyles.input}\n value={text}\n onChange={handleChange}\n onBlur={handleBlur}\n disabled={disabled}\n aria-invalid={resolvedError || undefined}\n aria-describedby={resolvedHelperText != null ? helperId : undefined}\n {...props}\n />\n {!hideStepper && (\n <>\n {/* Filled icon buttons, sized via the shared `.control .iconButton` rule (flush square,\n stretched to the control height, scaled). The minus glyph is nudged for optical centering. */}\n <IconButton\n variant=\"filled\"\n color=\"primary\"\n className={fieldStyles.iconButton}\n style={{ marginRight: -2 }}\n disabled={disabled || atMin}\n aria-label={t('numberField.decrease')}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => stepBy(-1)}\n >\n <Icon name=\"Minus\" />\n </IconButton>\n <IconButton\n variant=\"filled\"\n color=\"primary\"\n className={fieldStyles.iconButton}\n disabled={disabled || atMax}\n aria-label={t('numberField.increase')}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => stepBy(1)}\n >\n <Icon name=\"Add\" />\n </IconButton>\n </>\n )}\n </div>\n\n {resolvedHelperText != null && (\n <Typography\n as=\"span\"\n id={helperId}\n variant=\"bodySmall\"\n color={resolvedError ? 'error' : 'muted'}\n className={fieldStyles.helper}\n >\n {resolvedHelperText}\n </Typography>\n )}\n </div>\n )\n})\n"],"names":["NUMERIC_RE","parseValue","raw","clampValue","n","min","max","roundStep","groupThousands","value","separator","intPart","decPart","sign","grouped","countExcept","s","sep","c","positionAfterExcept","str","count","i","NumberField","forwardRef","label","size","error","helperText","required","fullWidth","defaultValue","onChange","step","hideStepper","thousandSeparator","name","onBlur","disabled","idProp","className","style","props","ref","t","useT","reactId","useId","id","helperId","form","useFormContext","isFormBound","bound","externalValue","isControlled","internal","setInternal","useState","numValue","toDisplay","v","fromDisplay","text","setText","useEffect","innerRef","useRef","pendingCaret","setInputRef","useCallback","node","useLayoutEffect","pos","_a","resolvedError","resolvedHelperText","commit","next","handleChange","event","el","cleaned","caret","significantBefore","formatted","handleBlur","clamped","stepBy","direction","atMax","atMin","jsxs","clsx","fieldStyles","jsx","Typography","Fragment","IconButton","Icon"],"mappings":";;;;;;;;;AA0BA,MAAMA,IAAa;AAGnB,SAASC,EAAWC,GAA4B;AAC9C,MAAIA,MAAQ,MAAMA,MAAQ,OAAOA,MAAQ,OAAOA,MAAQ,KAAM,QAAO;AACrE,QAAM,IAAI,OAAOA,CAAG;AACpB,SAAO,OAAO,MAAM,C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R,CAAC;"}
1
+ {"version":3,"file":"NumberField-DEoaxFJj.js","sources":["../src/components/NumberField/NumberField.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ChangeEvent,\n type CSSProperties,\n type FocusEvent,\n type InputHTMLAttributes,\n type ReactNode,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useFormContext } from '../../form/formContext'\nimport { useT } from '../../theme'\nimport { Icon } from '../Icon'\nimport { IconButton } from '../IconButton'\nimport { Typography } from '../Typography'\n// shared field chrome (label/control/helper) AND the `.control .iconButton` styling for the steppers\nimport fieldStyles from '../TextField/TextField.module.css'\n\nexport type NumberFieldSize = 'sm' | 'md' | 'lg'\n\n/** Allowed while typing — digits, an optional leading `-`, and one decimal point. */\nconst NUMERIC_RE = /^-?\\d*\\.?\\d*$/\n\n/** Parses the display string to a number, treating empty / in-progress input (`\"\"`, `\"-\"`, `\".\"`) as null. */\nfunction parseValue(raw: string): number | null {\n if (raw === '' || raw === '-' || raw === '.' || raw === '-.') return null\n const n = Number(raw)\n return Number.isNaN(n) ? null : n\n}\n\nfunction clampValue(n: number, min?: number, max?: number): number {\n if (min != null && n < min) return min\n if (max != null && n > max) return max\n return n\n}\n\n/** Kills binary float drift from repeated stepping (e.g. 0.1 + 0.2). */\nfunction roundStep(n: number): number {\n return Math.round(n * 1e6) / 1e6\n}\n\n/** Groups the integer part with `separator` for display (e.g. 32345345 → \"32.345.345\"). */\nfunction groupThousands(value: number, separator: string): string {\n const [intPart, decPart] = String(value).split('.')\n const sign = intPart.startsWith('-') ? '-' : ''\n const digits = sign ? intPart.slice(1) : intPart\n const grouped = digits.replace(/\\B(?=(\\d{3})+(?!\\d))/g, separator)\n return decPart != null ? `${sign}${grouped}.${decPart}` : `${sign}${grouped}`\n}\n\n/** Counts the \"significant\" (non-separator) chars — used to keep the caret stable across regrouping. */\nfunction countExcept(s: string, sep: string): number {\n let n = 0\n for (const c of s) if (c !== sep) n++\n return n\n}\n\n/** Index just after the `n`-th non-separator char in `str` (where the caret should land after regrouping). */\nfunction positionAfterExcept(str: string, sep: string, n: number): number {\n if (n <= 0) return 0\n let count = 0\n for (let i = 0; i < str.length; i++) {\n if (str[i] !== sep) {\n count += 1\n if (count === n) return i + 1\n }\n }\n return str.length\n}\n\nexport interface NumberFieldProps extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'size' | 'value' | 'defaultValue' | 'onChange' | 'type' | 'min' | 'max' | 'step' | 'prefix'\n> {\n /** Label rendered above the field. */\n label?: ReactNode\n /** Preset size — drives the control height, font size and padding. */\n size?: NumberFieldSize\n /** Marks the field invalid: red border/focus ring + the `helperText` in the error color. */\n error?: boolean\n /** Helper / validation text under the field. Adopts the error color while `error`. */\n helperText?: ReactNode\n /** Adds a red asterisk after the label. */\n required?: boolean\n /** Stretches the field to fill its container width. Defaults to `true`. */\n fullWidth?: boolean\n /** Controlled numeric value (`null` = empty). */\n value?: number | null\n /** Initial value for uncontrolled use (`null` = empty). Defaults to `null`. */\n defaultValue?: number | null\n /** Fires with the parsed numeric value (or `null` when the field is empty). */\n onChange?: (value: number | null) => void\n /** Minimum value — clamps on blur and on the stepper, and disables `−` at the floor. Defaults to `0`; pass a negative `min` to allow negatives. */\n min?: number\n /** Maximum value — clamps on blur and on the stepper, and disables `+` at the ceiling. */\n max?: number\n /** Amount the `+`/`−` buttons add or subtract. Defaults to `1`. */\n step?: number\n /** Hides the `+`/`−` stepper buttons (keyboard entry only). */\n hideStepper?: boolean\n /**\n * Thousands-group separator shown **live** as you type, e.g. `\".\"` displays `32345345` as\n * `32.345.345` (or `\",\"`). The caret is preserved across regrouping; the `value`/`onChange`/form\n * value stay a plain `number`. Best for integers — with `\".\"` decimals aren't supported (the dot is\n * the group separator).\n */\n thousandSeparator?: string\n}\n\n/**\n * A numeric input with `+`/`−` stepper buttons. Supports `min`/`max` clamping, a `step` amount,\n * controlled (`value` + `onChange`) or uncontrolled (`defaultValue`) use, optional live thousands\n * grouping, and — like `TextField` — binds to a surrounding `<Form>` by `name` (its form value is a\n * real `number`, validated by the Zod schema). `onChange` emits a `number` or `null` (empty). Shares\n * `TextField`'s field chrome, so label, sizing, error and focus styling are identical.\n */\nexport const NumberField = forwardRef<HTMLInputElement, NumberFieldProps>(function NumberField(\n {\n label,\n size = 'md',\n error,\n helperText,\n required = false,\n fullWidth = true,\n value,\n defaultValue = null,\n onChange,\n min = 0,\n max,\n step = 1,\n hideStepper = false,\n thousandSeparator,\n name,\n onBlur,\n disabled = false,\n id: idProp,\n className,\n style,\n ...props\n },\n ref,\n) {\n const t = useT()\n const reactId = useId()\n const id = idProp ?? reactId\n const helperId = `${id}-helper`\n\n // Auto-bind to a surrounding <Form> by `name`. The form stores a real number; we use field() for\n // touched/error/helper and read/write the numeric value through values/setValue.\n const form = useFormContext()\n const isFormBound = Boolean(form && name)\n const bound = form && name ? form.field(name) : undefined\n\n const externalValue: number | null | undefined =\n value !== undefined\n ? value\n : isFormBound\n ? ((form!.values[name!] as number | null | undefined) ?? null)\n : undefined\n const isControlled = externalValue !== undefined\n const [internal, setInternal] = useState<number | null>(defaultValue)\n const numValue: number | null = isControlled ? externalValue! : internal\n\n // number <-> display string, applying live thousands grouping when `thousandSeparator` is set.\n const toDisplay = (v: number | null): string =>\n v == null ? '' : thousandSeparator != null ? groupThousands(v, thousandSeparator) : String(v)\n const fromDisplay = (raw: string): number | null =>\n parseValue(thousandSeparator != null ? raw.split(thousandSeparator).join('') : raw)\n\n // The display string mirrors `numValue` but tolerates in-progress input (\"-\", \"1.\" …).\n const [text, setText] = useState<string>(() => toDisplay(numValue))\n useEffect(() => {\n if (fromDisplay(text) !== numValue) setText(toDisplay(numValue))\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [numValue]) // re-sync only when the value changes from the outside (stepper, form, reset)\n\n // Caret restoration after regrouping (the formatted string length changes as separators move).\n const innerRef = useRef<HTMLInputElement>(null)\n const pendingCaret = useRef<number | null>(null)\n const setInputRef = useCallback(\n (node: HTMLInputElement | null) => {\n innerRef.current = node\n if (typeof ref === 'function') ref(node)\n else if (ref) ref.current = node\n },\n [ref],\n )\n useLayoutEffect(() => {\n const pos = pendingCaret.current\n if (pos == null) return\n pendingCaret.current = null\n innerRef.current?.setSelectionRange(pos, pos)\n })\n\n const resolvedError = error ?? bound?.error ?? false\n const resolvedHelperText = helperText ?? bound?.helperText\n\n const commit = (next: number | null) => {\n if (!isControlled) setInternal(next)\n if (isFormBound) form!.setValue(name!, next)\n onChange?.(next)\n }\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const el = event.target\n const raw = el.value\n\n if (thousandSeparator == null) {\n if (raw !== '' && !NUMERIC_RE.test(raw)) return // reject non-numeric keystrokes\n setText(raw)\n commit(parseValue(raw))\n return\n }\n\n // Live grouping: strip separators, validate, regroup, and remember where the caret should land.\n const sep = thousandSeparator\n const cleaned = raw.split(sep).join('')\n if (cleaned !== '' && !NUMERIC_RE.test(cleaned)) return\n const caret = el.selectionStart ?? raw.length\n const significantBefore = countExcept(raw.slice(0, caret), sep)\n const next = parseValue(cleaned)\n const formatted = next == null ? cleaned : groupThousands(next, sep)\n setText(formatted)\n commit(next)\n pendingCaret.current = positionAfterExcept(formatted, sep, significantBefore)\n }\n\n const handleBlur = (event: FocusEvent<HTMLInputElement>) => {\n if (numValue != null) {\n const clamped = clampValue(numValue, min, max)\n if (clamped !== numValue) commit(clamped)\n }\n bound?.onBlur(event)\n onBlur?.(event)\n }\n\n const stepBy = (direction: 1 | -1) => {\n const base = numValue ?? min ?? 0\n commit(clampValue(roundStep(base + direction * step), min, max))\n }\n\n const atMax = max != null && numValue != null && numValue >= max\n const atMin = min != null && numValue != null && numValue <= min\n\n return (\n <div\n className={clsx(\n fieldStyles.field,\n fieldStyles[size],\n fullWidth && fieldStyles.fullWidth,\n resolvedError && fieldStyles.error,\n disabled && fieldStyles.disabled,\n className,\n )}\n style={style as CSSProperties}\n >\n {label != null && (\n <label htmlFor={id} className={fieldStyles.label}>\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\">\n {label}\n </Typography>\n {required && (\n <span className={fieldStyles.required} aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n )}\n\n <div className={clsx(fieldStyles.control, !hideStepper && fieldStyles.hasRightAdornment)}>\n <input\n ref={setInputRef}\n id={id}\n name={name}\n type=\"text\"\n inputMode=\"decimal\"\n className={fieldStyles.input}\n value={text}\n onChange={handleChange}\n onBlur={handleBlur}\n disabled={disabled}\n aria-invalid={resolvedError || undefined}\n aria-describedby={resolvedHelperText != null ? helperId : undefined}\n {...props}\n />\n {!hideStepper && (\n <>\n {/* Filled icon buttons, sized via the shared `.control .iconButton` rule (flush square,\n stretched to the control height, scaled). The minus glyph is nudged for optical centering. */}\n <IconButton\n variant=\"filled\"\n color=\"primary\"\n className={fieldStyles.iconButton}\n style={{ marginRight: -2 }}\n disabled={disabled || atMin}\n aria-label={t('numberField.decrease')}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => stepBy(-1)}\n >\n <Icon name=\"Minus\" />\n </IconButton>\n <IconButton\n variant=\"filled\"\n color=\"primary\"\n className={fieldStyles.iconButton}\n disabled={disabled || atMax}\n aria-label={t('numberField.increase')}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => stepBy(1)}\n >\n <Icon name=\"Add\" />\n </IconButton>\n </>\n )}\n </div>\n\n {resolvedHelperText != null && (\n <Typography\n as=\"span\"\n id={helperId}\n variant=\"bodySmall\"\n color={resolvedError ? 'error' : 'muted'}\n className={fieldStyles.helper}\n >\n {resolvedHelperText}\n </Typography>\n )}\n </div>\n )\n})\n"],"names":["NUMERIC_RE","parseValue","raw","clampValue","n","min","max","roundStep","groupThousands","value","separator","intPart","decPart","sign","grouped","countExcept","s","sep","c","positionAfterExcept","str","count","i","NumberField","forwardRef","label","size","error","helperText","required","fullWidth","defaultValue","onChange","step","hideStepper","thousandSeparator","name","onBlur","disabled","idProp","className","style","props","ref","t","useT","reactId","useId","id","helperId","form","useFormContext","isFormBound","bound","externalValue","isControlled","internal","setInternal","useState","numValue","toDisplay","v","fromDisplay","text","setText","useEffect","innerRef","useRef","pendingCaret","setInputRef","useCallback","node","useLayoutEffect","pos","_a","resolvedError","resolvedHelperText","commit","next","handleChange","event","el","cleaned","caret","significantBefore","formatted","handleBlur","clamped","stepBy","direction","atMax","atMin","jsxs","clsx","fieldStyles","jsx","Typography","Fragment","IconButton","Icon"],"mappings":";;;;;;;;;AA0BA,MAAMA,IAAa;AAGnB,SAASC,EAAWC,GAA4B;AAC9C,MAAIA,MAAQ,MAAMA,MAAQ,OAAOA,MAAQ,OAAOA,MAAQ,KAAM,QAAO;AACrE,QAAM,IAAI,OAAOA,CAAG;AACpB,SAAO,OAAO,MAAM,CAAC,IAAI,OAAO;AAClC;AAEA,SAASC,EAAWC,GAAWC,GAAcC,GAAsB;AACjE,SAAID,KAAO,QAAQD,IAAIC,IAAYA,IAC/BC,KAAO,QAAQF,IAAIE,IAAYA,IAC5BF;AACT;AAGA,SAASG,GAAUH,GAAmB;AACpC,SAAO,KAAK,MAAMA,IAAI,GAAG,IAAI;AAC/B;AAGA,SAASI,GAAeC,GAAeC,GAA2B;AAChE,QAAM,CAACC,GAASC,CAAO,IAAI,OAAOH,CAAK,EAAE,MAAM,GAAG,GAC5CI,IAAOF,EAAQ,WAAW,GAAG,IAAI,MAAM,IAEvCG,KADSD,IAAOF,EAAQ,MAAM,CAAC,IAAIA,GAClB,QAAQ,yBAAyBD,CAAS;AACjE,SAAOE,KAAW,OAAO,GAAGC,CAAI,GAAGC,CAAO,IAAIF,CAAO,KAAK,GAAGC,CAAI,GAAGC,CAAO;AAC7E;AAGA,SAASC,GAAYC,GAAWC,GAAqB;AACnD,MAAIb,IAAI;AACR,aAAWc,KAAKF,EAAG,CAAIE,MAAMD,KAAKb;AAClC,SAAOA;AACT;AAGA,SAASe,GAAoBC,GAAaH,GAAab,GAAmB;AACxE,MAAIA,KAAK,EAAG,QAAO;AACnB,MAAIi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gBACpC,aAAa,CAACoC,MAAUA,EAAM,eAAA;AAAA,gBAC9B,SAAS,MAAMQ,EAAO,CAAC;AAAA,gBAEvB,UAAA,gBAAAO,EAACI,GAAA,EAAK,MAAK,MAAA,CAAM;AAAA,cAAA;AAAA,YAAA;AAAA,UACnB,EAAA,CACF;AAAA,QAAA,GAEJ;AAAA,QAECvB,KAAsB,QACrB,gBAAAmB;AAAA,UAACC;AAAA,UAAA;AAAA,YACC,IAAG;AAAA,YACH,IAAI/C;AAAA,YACJ,SAAQ;AAAA,YACR,OAAO0B,IAAgB,UAAU;AAAA,YACjC,WAAWmB,EAAY;AAAA,YAEtB,UAAAlB;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
@@ -1,2 +1,2 @@
1
- "use strict";const s=require("react/jsx-runtime"),d=require("react"),J=require("clsx"),he=require("./formContext-bTWrqdEV.cjs"),K=require("./Icon-BUP5_kRs.cjs"),O=require("./IconButton-BVrO9TBP.cjs"),Q=require("./Typography-B6ASPrzT.cjs"),r=require("./TextField.module-DsNCo8vN.cjs"),xe=require("./ConfigProvider-CVLHPXQm.cjs"),X=/^-?\d*\.?\d*$/;function E(t){if(t===""||t==="-"||t==="."||t==="-.")return null;const l=Number(t);return Number.isNaN(l)?null:l}function Y(t,l,n){return l!=null&&t<l?l:n!=null&&t>n?n:t}function ge(t){return Math.round(t*1e6)/1e6}function Z(t,l){const[n,o]=String(t).split("."),c=n.startsWith("-")?"-":"",g=(c?n.slice(1):n).replace(/\B(?=(\d{3})+(?!\d))/g,l);return o!=null?`${c}${g}.${o}`:`${c}${g}`}function ve(t,l){let n=0;for(const o of t)o!==l&&n++;return n}function Ne(t,l,n){if(n<=0)return 0;let o=0;for(let c=0;c<t.length;c++)if(t[c]!==l&&(o+=1,o===n))return c+1;return t.length}const Se=d.forwardRef(function({label:l,size:n="md",error:o,helperText:c,required:$=!1,fullWidth:g=!0,value:D,defaultValue:w=null,onChange:I,min:m=0,max:v,step:ee=1,hideStepper:V=!1,thousandSeparator:p,name:y,onBlur:R,disabled:N=!1,id:te,className:le,style:ne,...se},h){const k=xe.useT(),re=d.useId(),q=te??re,A=`${q}-helper`,x=he.useFormContext(),P=!!(x&&y),u=x&&y?x.field(y):void 0,W=D!==void 0?D:P?x.values[y]??null:void 0,_=W!==void 0,[ie,ce]=d.useState(w),i=_?W:ie,H=e=>e==null?"":p!=null?Z(e,p):String(e),oe=e=>E(p!=null?e.split(p).join(""):e),[L,F]=d.useState(()=>H(i));d.useEffect(()=>{oe(L)!==i&&F(H(i))},[i]);const U=d.useRef(null),B=d.useRef(null),ue=d.useCallback(e=>{U.current=e,typeof h=="function"?h(e):h&&(h.current=e)},[h]);d.useLayoutEffect(()=>{var a;const e=B.current;e!=null&&(B.current=null,(a=U.current)==null||a.setSelectionRange(e,e))});const T=o??(u==null?void 0:u.error)??!1,M=c??(u==null?void 0:u.helperText),S=e=>{_||ce(e),P&&x.setValue(y,e),I==null||I(e)},ae=e=>{const a=e.target,f=a.value;if(p==null){if(f!==""&&!X.test(f))return;F(f),S(E(f));return}const j=p,b=f.split(j).join("");if(b!==""&&!X.test(b))return;const ye=a.selectionStart??f.length,me=ve(f.slice(0,ye),j),C=E(b),G=C==null?b:Z(C,j);F(G),S(C),B.current=Ne(G,j,me)},de=e=>{if(i!=null){const a=Y(i,m,v);a!==i&&S(a)}u==null||u.onBlur(e),R==null||R(e)},z=e=>{S(Y(ge((i??m??0)+e*ee),m,v))},fe=v!=null&&i!=null&&i>=v,pe=m!=null&&i!=null&&i<=m;return s.jsxs("div",{className:J.clsx(r.fieldStyles.field,r.fieldStyles[n],g&&r.fieldStyles.fullWidth,T&&r.fieldStyles.error,N&&r.fieldStyles.disabled,le),style:ne,children:[l!=null&&s.jsxs("label",{htmlFor:q,className:r.fieldStyles.label,children:[s.jsx(Q.Typography,{as:"span",variant:"bodySmall",color:"muted",children:l}),$&&s.jsx("span",{className:r.fieldStyles.required,"aria-hidden":"true",children:"*"})]}),s.jsxs("div",{className:J.clsx(r.fieldStyles.control,!V&&r.fieldStyles.hasRightAdornment),children:[s.jsx("input",{ref:ue,id:q,name:y,type:"text",inputMode:"decimal",className:r.fieldStyles.input,value:L,onChange:ae,onBlur:de,disabled:N,"aria-invalid":T||void 0,"aria-describedby":M!=null?A:void 0,...se}),!V&&s.jsxs(s.Fragment,{children:[s.jsx(O.IconButton,{variant:"filled",color:"primary",className:r.fieldStyles.iconButton,style:{marginRight:-2},disabled:N||pe,"aria-label":k("numberField.decrease"),onMouseDown:e=>e.preventDefault(),onClick:()=>z(-1),children:s.jsx(K.Icon,{name:"Minus"})}),s.jsx(O.IconButton,{variant:"filled",color:"primary",className:r.fieldStyles.iconButton,disabled:N||fe,"aria-label":k("numberField.increase"),onMouseDown:e=>e.preventDefault(),onClick:()=>z(1),children:s.jsx(K.Icon,{name:"Add"})})]})]}),M!=null&&s.jsx(Q.Typography,{as:"span",id:A,variant:"bodySmall",color:T?"error":"muted",className:r.fieldStyles.helper,children:M})]})});exports.NumberField=Se;
2
- //# sourceMappingURL=NumberField-CxiEfRAi.cjs.map
1
+ "use strict";const s=require("react/jsx-runtime"),d=require("react"),J=require("clsx"),he=require("./formContext-bTWrqdEV.cjs"),K=require("./Icon-BUP5_kRs.cjs"),O=require("./IconButton-CYMvszcM.cjs"),Q=require("./Typography-d97DdbNd.cjs"),r=require("./TextField.module-DsNCo8vN.cjs"),xe=require("./ConfigProvider-th4GYhcU.cjs"),X=/^-?\d*\.?\d*$/;function E(t){if(t===""||t==="-"||t==="."||t==="-.")return null;const l=Number(t);return Number.isNaN(l)?null:l}function Y(t,l,n){return l!=null&&t<l?l:n!=null&&t>n?n:t}function ge(t){return Math.round(t*1e6)/1e6}function Z(t,l){const[n,o]=String(t).split("."),c=n.startsWith("-")?"-":"",g=(c?n.slice(1):n).replace(/\B(?=(\d{3})+(?!\d))/g,l);return o!=null?`${c}${g}.${o}`:`${c}${g}`}function ve(t,l){let n=0;for(const o of t)o!==l&&n++;return n}function Ne(t,l,n){if(n<=0)return 0;let o=0;for(let c=0;c<t.length;c++)if(t[c]!==l&&(o+=1,o===n))return c+1;return t.length}const Se=d.forwardRef(function({label:l,size:n="md",error:o,helperText:c,required:$=!1,fullWidth:g=!0,value:D,defaultValue:w=null,onChange:I,min:m=0,max:v,step:ee=1,hideStepper:V=!1,thousandSeparator:p,name:y,onBlur:R,disabled:N=!1,id:te,className:le,style:ne,...se},h){const k=xe.useT(),re=d.useId(),q=te??re,A=`${q}-helper`,x=he.useFormContext(),P=!!(x&&y),u=x&&y?x.field(y):void 0,W=D!==void 0?D:P?x.values[y]??null:void 0,_=W!==void 0,[ie,ce]=d.useState(w),i=_?W:ie,H=e=>e==null?"":p!=null?Z(e,p):String(e),oe=e=>E(p!=null?e.split(p).join(""):e),[L,F]=d.useState(()=>H(i));d.useEffect(()=>{oe(L)!==i&&F(H(i))},[i]);const U=d.useRef(null),B=d.useRef(null),ue=d.useCallback(e=>{U.current=e,typeof h=="function"?h(e):h&&(h.current=e)},[h]);d.useLayoutEffect(()=>{var a;const e=B.current;e!=null&&(B.current=null,(a=U.current)==null||a.setSelectionRange(e,e))});const T=o??(u==null?void 0:u.error)??!1,M=c??(u==null?void 0:u.helperText),S=e=>{_||ce(e),P&&x.setValue(y,e),I==null||I(e)},ae=e=>{const a=e.target,f=a.value;if(p==null){if(f!==""&&!X.test(f))return;F(f),S(E(f));return}const j=p,b=f.split(j).join("");if(b!==""&&!X.test(b))return;const ye=a.selectionStart??f.length,me=ve(f.slice(0,ye),j),C=E(b),G=C==null?b:Z(C,j);F(G),S(C),B.current=Ne(G,j,me)},de=e=>{if(i!=null){const a=Y(i,m,v);a!==i&&S(a)}u==null||u.onBlur(e),R==null||R(e)},z=e=>{S(Y(ge((i??m??0)+e*ee),m,v))},fe=v!=null&&i!=null&&i>=v,pe=m!=null&&i!=null&&i<=m;return s.jsxs("div",{className:J.clsx(r.fieldStyles.field,r.fieldStyles[n],g&&r.fieldStyles.fullWidth,T&&r.fieldStyles.error,N&&r.fieldStyles.disabled,le),style:ne,children:[l!=null&&s.jsxs("label",{htmlFor:q,className:r.fieldStyles.label,children:[s.jsx(Q.Typography,{as:"span",variant:"bodySmall",color:"muted",children:l}),$&&s.jsx("span",{className:r.fieldStyles.required,"aria-hidden":"true",children:"*"})]}),s.jsxs("div",{className:J.clsx(r.fieldStyles.control,!V&&r.fieldStyles.hasRightAdornment),children:[s.jsx("input",{ref:ue,id:q,name:y,type:"text",inputMode:"decimal",className:r.fieldStyles.input,value:L,onChange:ae,onBlur:de,disabled:N,"aria-invalid":T||void 0,"aria-describedby":M!=null?A:void 0,...se}),!V&&s.jsxs(s.Fragment,{children:[s.jsx(O.IconButton,{variant:"filled",color:"primary",className:r.fieldStyles.iconButton,style:{marginRight:-2},disabled:N||pe,"aria-label":k("numberField.decrease"),onMouseDown:e=>e.preventDefault(),onClick:()=>z(-1),children:s.jsx(K.Icon,{name:"Minus"})}),s.jsx(O.IconButton,{variant:"filled",color:"primary",className:r.fieldStyles.iconButton,disabled:N||fe,"aria-label":k("numberField.increase"),onMouseDown:e=>e.preventDefault(),onClick:()=>z(1),children:s.jsx(K.Icon,{name:"Add"})})]})]}),M!=null&&s.jsx(Q.Typography,{as:"span",id:A,variant:"bodySmall",color:T?"error":"muted",className:r.fieldStyles.helper,children:M})]})});exports.NumberField=Se;
2
+ //# sourceMappingURL=NumberField-czWHuAyt.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"NumberField-CxiEfRAi.cjs","sources":["../src/components/NumberField/NumberField.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ChangeEvent,\n type CSSProperties,\n type FocusEvent,\n type InputHTMLAttributes,\n type ReactNode,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useFormContext } from '../../form/formContext'\nimport { useT } from '../../theme'\nimport { Icon } from '../Icon'\nimport { IconButton } from '../IconButton'\nimport { Typography } from '../Typography'\n// shared field chrome (label/control/helper) AND the `.control .iconButton` styling for the steppers\nimport fieldStyles from '../TextField/TextField.module.css'\n\nexport type NumberFieldSize = 'sm' | 'md' | 'lg'\n\n/** Allowed while typing — digits, an optional leading `-`, and one decimal point. */\nconst NUMERIC_RE = /^-?\\d*\\.?\\d*$/\n\n/** Parses the display string to a number, treating empty / in-progress input (`\"\"`, `\"-\"`, `\".\"`) as null. */\nfunction parseValue(raw: string): number | null {\n if (raw === '' || raw === '-' || raw === '.' || raw === '-.') return null\n const n = Number(raw)\n return Number.isNaN(n) ? null : n\n}\n\nfunction clampValue(n: number, min?: number, max?: number): number {\n if (min != null && n < min) return min\n if (max != null && n > max) return max\n return n\n}\n\n/** Kills binary float drift from repeated stepping (e.g. 0.1 + 0.2). */\nfunction roundStep(n: number): number {\n return Math.round(n * 1e6) / 1e6\n}\n\n/** Groups the integer part with `separator` for display (e.g. 32345345 → \"32.345.345\"). */\nfunction groupThousands(value: number, separator: string): string {\n const [intPart, decPart] = String(value).split('.')\n const sign = intPart.startsWith('-') ? '-' : ''\n const digits = sign ? intPart.slice(1) : intPart\n const grouped = digits.replace(/\\B(?=(\\d{3})+(?!\\d))/g, separator)\n return decPart != null ? `${sign}${grouped}.${decPart}` : `${sign}${grouped}`\n}\n\n/** Counts the \"significant\" (non-separator) chars — used to keep the caret stable across regrouping. */\nfunction countExcept(s: string, sep: string): number {\n let n = 0\n for (const c of s) if (c !== sep) n++\n return n\n}\n\n/** Index just after the `n`-th non-separator char in `str` (where the caret should land after regrouping). */\nfunction positionAfterExcept(str: string, sep: string, n: number): number {\n if (n <= 0) return 0\n let count = 0\n for (let i = 0; i < str.length; i++) {\n if (str[i] !== sep) {\n count += 1\n if (count === n) return i + 1\n }\n }\n return str.length\n}\n\nexport interface NumberFieldProps extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'size' | 'value' | 'defaultValue' | 'onChange' | 'type' | 'min' | 'max' | 'step' | 'prefix'\n> {\n /** Label rendered above the field. */\n label?: ReactNode\n /** Preset size — drives the control height, font size and padding. */\n size?: NumberFieldSize\n /** Marks the field invalid: red border/focus ring + the `helperText` in the error color. */\n error?: boolean\n /** Helper / validation text under the field. Adopts the error color while `error`. */\n helperText?: ReactNode\n /** Adds a red asterisk after the label. */\n required?: boolean\n /** Stretches the field to fill its container width. Defaults to `true`. */\n fullWidth?: boolean\n /** Controlled numeric value (`null` = empty). */\n value?: number | null\n /** Initial value for uncontrolled use (`null` = empty). Defaults to `null`. */\n defaultValue?: number | null\n /** Fires with the parsed numeric value (or `null` when the field is empty). */\n onChange?: (value: number | null) => void\n /** Minimum value — clamps on blur and on the stepper, and disables `−` at the floor. Defaults to `0`; pass a negative `min` to allow negatives. */\n min?: number\n /** Maximum value — clamps on blur and on the stepper, and disables `+` at the ceiling. */\n max?: number\n /** Amount the `+`/`−` buttons add or subtract. Defaults to `1`. */\n step?: number\n /** Hides the `+`/`−` stepper buttons (keyboard entry only). */\n hideStepper?: boolean\n /**\n * Thousands-group separator shown **live** as you type, e.g. `\".\"` displays `32345345` as\n * `32.345.345` (or `\",\"`). The caret is preserved across regrouping; the `value`/`onChange`/form\n * value stay a plain `number`. Best for integers — with `\".\"` decimals aren't supported (the dot is\n * the group separator).\n */\n thousandSeparator?: string\n}\n\n/**\n * A numeric input with `+`/`−` stepper buttons. Supports `min`/`max` clamping, a `step` amount,\n * controlled (`value` + `onChange`) or uncontrolled (`defaultValue`) use, optional live thousands\n * grouping, and — like `TextField` — binds to a surrounding `<Form>` by `name` (its form value is a\n * real `number`, validated by the Zod schema). `onChange` emits a `number` or `null` (empty). Shares\n * `TextField`'s field chrome, so label, sizing, error and focus styling are identical.\n */\nexport const NumberField = forwardRef<HTMLInputElement, NumberFieldProps>(function NumberField(\n {\n label,\n size = 'md',\n error,\n helperText,\n required = false,\n fullWidth = true,\n value,\n defaultValue = null,\n onChange,\n min = 0,\n max,\n step = 1,\n hideStepper = false,\n thousandSeparator,\n name,\n onBlur,\n disabled = false,\n id: idProp,\n className,\n style,\n ...props\n },\n ref,\n) {\n const t = useT()\n const reactId = useId()\n const id = idProp ?? reactId\n const helperId = `${id}-helper`\n\n // Auto-bind to a surrounding <Form> by `name`. The form stores a real number; we use field() for\n // touched/error/helper and read/write the numeric value through values/setValue.\n const form = useFormContext()\n const isFormBound = Boolean(form && name)\n const bound = form && name ? form.field(name) : undefined\n\n const externalValue: number | null | undefined =\n value !== undefined\n ? value\n : isFormBound\n ? ((form!.values[name!] as number | null | undefined) ?? null)\n : undefined\n const isControlled = externalValue !== undefined\n const [internal, setInternal] = useState<number | null>(defaultValue)\n const numValue: number | null = isControlled ? externalValue! : internal\n\n // number <-> display string, applying live thousands grouping when `thousandSeparator` is set.\n const toDisplay = (v: number | null): string =>\n v == null ? '' : thousandSeparator != null ? groupThousands(v, thousandSeparator) : String(v)\n const fromDisplay = (raw: string): number | null =>\n parseValue(thousandSeparator != null ? raw.split(thousandSeparator).join('') : raw)\n\n // The display string mirrors `numValue` but tolerates in-progress input (\"-\", \"1.\" …).\n const [text, setText] = useState<string>(() => toDisplay(numValue))\n useEffect(() => {\n if (fromDisplay(text) !== numValue) setText(toDisplay(numValue))\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [numValue]) // re-sync only when the value changes from the outside (stepper, form, reset)\n\n // Caret restoration after regrouping (the formatted string length changes as separators move).\n const innerRef = useRef<HTMLInputElement>(null)\n const pendingCaret = useRef<number | null>(null)\n const setInputRef = useCallback(\n (node: HTMLInputElement | null) => {\n innerRef.current = node\n if (typeof ref === 'function') ref(node)\n else if (ref) ref.current = node\n },\n [ref],\n )\n useLayoutEffect(() => {\n const pos = pendingCaret.current\n if (pos == null) return\n pendingCaret.current = null\n innerRef.current?.setSelectionRange(pos, pos)\n })\n\n const resolvedError = error ?? bound?.error ?? false\n const resolvedHelperText = helperText ?? bound?.helperText\n\n const commit = (next: number | null) => {\n if (!isControlled) setInternal(next)\n if (isFormBound) form!.setValue(name!, next)\n onChange?.(next)\n }\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const el = event.target\n const raw = el.value\n\n if (thousandSeparator == null) {\n if (raw !== '' && !NUMERIC_RE.test(raw)) return // reject non-numeric keystrokes\n setText(raw)\n commit(parseValue(raw))\n return\n }\n\n // Live grouping: strip separators, validate, regroup, and remember where the caret should land.\n const sep = thousandSeparator\n const cleaned = raw.split(sep).join('')\n if (cleaned !== '' && !NUMERIC_RE.test(cleaned)) return\n const caret = el.selectionStart ?? raw.length\n const significantBefore = countExcept(raw.slice(0, caret), sep)\n const next = parseValue(cleaned)\n const formatted = next == null ? cleaned : groupThousands(next, sep)\n setText(formatted)\n commit(next)\n pendingCaret.current = positionAfterExcept(formatted, sep, significantBefore)\n }\n\n const handleBlur = (event: FocusEvent<HTMLInputElement>) => {\n if (numValue != null) {\n const clamped = clampValue(numValue, min, max)\n if (clamped !== numValue) commit(clamped)\n }\n bound?.onBlur(event)\n onBlur?.(event)\n }\n\n const stepBy = (direction: 1 | -1) => {\n const base = numValue ?? min ?? 0\n commit(clampValue(roundStep(base + direction * step), min, max))\n }\n\n const atMax = max != null && numValue != null && numValue >= max\n const atMin = min != null && numValue != null && numValue <= min\n\n return (\n <div\n className={clsx(\n fieldStyles.field,\n fieldStyles[size],\n fullWidth && fieldStyles.fullWidth,\n resolvedError && fieldStyles.error,\n disabled && fieldStyles.disabled,\n className,\n )}\n style={style as CSSProperties}\n >\n {label != null && (\n <label htmlFor={id} className={fieldStyles.label}>\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\">\n {label}\n </Typography>\n {required && (\n <span className={fieldStyles.required} aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n )}\n\n <div className={clsx(fieldStyles.control, !hideStepper && fieldStyles.hasRightAdornment)}>\n <input\n ref={setInputRef}\n id={id}\n name={name}\n type=\"text\"\n inputMode=\"decimal\"\n className={fieldStyles.input}\n value={text}\n onChange={handleChange}\n onBlur={handleBlur}\n disabled={disabled}\n aria-invalid={resolvedError || undefined}\n aria-describedby={resolvedHelperText != null ? helperId : undefined}\n {...props}\n />\n {!hideStepper && (\n <>\n {/* Filled icon buttons, sized via the shared `.control .iconButton` rule (flush square,\n stretched to the control height, scaled). The minus glyph is nudged for optical centering. */}\n <IconButton\n variant=\"filled\"\n color=\"primary\"\n className={fieldStyles.iconButton}\n style={{ marginRight: -2 }}\n disabled={disabled || atMin}\n aria-label={t('numberField.decrease')}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => stepBy(-1)}\n >\n <Icon name=\"Minus\" />\n </IconButton>\n <IconButton\n variant=\"filled\"\n color=\"primary\"\n className={fieldStyles.iconButton}\n disabled={disabled || atMax}\n aria-label={t('numberField.increase')}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => stepBy(1)}\n >\n <Icon name=\"Add\" />\n </IconButton>\n </>\n )}\n </div>\n\n {resolvedHelperText != null && (\n <Typography\n as=\"span\"\n id={helperId}\n variant=\"bodySmall\"\n color={resolvedError ? 'error' : 'muted'}\n className={fieldStyles.helper}\n >\n {resolvedHelperText}\n </Typography>\n )}\n </div>\n )\n})\n"],"names":["NUMERIC_RE","parseValue","raw","n","clampValue","min","max","roundStep","groupThousands","value","separator","intPart","decPart","sign","grouped","countExcept","s","sep","c","positionAfterExcept","str","count","i","NumberField","forwardRef","label","size","error","helperText","required","fullWidth","defaultValue","onChange","step","hideStepper","thousandSeparator","name","onBlur","disabled","idProp","className","style","props","ref","t","useT","reactId","useId","id","helperId","form","useFormContext","isFormBound","bound","externalValue","isControlled","internal","setInternal","useState","numValue","toDisplay","v","fromDisplay","text","setText","useEffect","innerRef","useRef","pendingCaret","setInputRef","useCallback","node","useLayoutEffect","pos","_a","resolvedError","resolvedHelperText","commit","next","handleChange","event","el","cleaned","caret","significantBefore","formatted","handleBlur","clamped","stepBy","direction","atMax","atMin","jsxs","clsx","fieldStyles","jsx","Typography","Fragment","IconButton","Icon"],"mappings":"wUA0BMA,EAAa,gBAGnB,SAASC,EAAWC,EAA4B,CAC9C,GAAIA,I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,MAAM,UACN,UAAWJ,EAAAA,YAAY,WACvB,MAAO,CAAE,YAAa,EAAA,EACtB,SAAUxD,GAAYqD,GACtB,aAAY/C,EAAE,sBAAsB,EACpC,YAAcoC,GAAUA,EAAM,eAAA,EAC9B,QAAS,IAAMQ,EAAO,EAAE,EAExB,SAAAO,EAAAA,IAACI,EAAAA,KAAA,CAAK,KAAK,OAAA,CAAQ,CAAA,CAAA,EAErBJ,EAAAA,IAACG,EAAAA,WAAA,CACC,QAAQ,SACR,MAAM,UACN,UAAWJ,EAAAA,YAAY,WACvB,SAAUxD,GAAYoD,GACtB,aAAY9C,EAAE,sBAAsB,EACpC,YAAcoC,GAAUA,EAAM,eAAA,EAC9B,QAAS,IAAMQ,EAAO,CAAC,EAEvB,SAAAO,EAAAA,IAACI,EAAAA,KAAA,CAAK,KAAK,KAAA,CAAM,CAAA,CAAA,CACnB,CAAA,CACF,CAAA,EAEJ,EAECvB,GAAsB,MACrBmB,EAAAA,IAACC,EAAAA,WAAA,CACC,GAAG,OACH,GAAI/C,EACJ,QAAQ,YACR,MAAO0B,EAAgB,QAAU,QACjC,UAAWmB,EAAAA,YAAY,OAEtB,SAAAlB,CAAA,CAAA,CACH,CAAA,CAAA,CAIR,CAAC"}
1
+ {"version":3,"file":"NumberField-czWHuAyt.cjs","sources":["../src/components/NumberField/NumberField.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ChangeEvent,\n type CSSProperties,\n type FocusEvent,\n type InputHTMLAttributes,\n type ReactNode,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useFormContext } from '../../form/formContext'\nimport { useT } from '../../theme'\nimport { Icon } from '../Icon'\nimport { IconButton } from '../IconButton'\nimport { Typography } from '../Typography'\n// shared field chrome (label/control/helper) AND the `.control .iconButton` styling for the steppers\nimport fieldStyles from '../TextField/TextField.module.css'\n\nexport type NumberFieldSize = 'sm' | 'md' | 'lg'\n\n/** Allowed while typing — digits, an optional leading `-`, and one decimal point. */\nconst NUMERIC_RE = /^-?\\d*\\.?\\d*$/\n\n/** Parses the display string to a number, treating empty / in-progress input (`\"\"`, `\"-\"`, `\".\"`) as null. */\nfunction parseValue(raw: string): number | null {\n if (raw === '' || raw === '-' || raw === '.' || raw === '-.') return null\n const n = Number(raw)\n return Number.isNaN(n) ? null : n\n}\n\nfunction clampValue(n: number, min?: number, max?: number): number {\n if (min != null && n < min) return min\n if (max != null && n > max) return max\n return n\n}\n\n/** Kills binary float drift from repeated stepping (e.g. 0.1 + 0.2). */\nfunction roundStep(n: number): number {\n return Math.round(n * 1e6) / 1e6\n}\n\n/** Groups the integer part with `separator` for display (e.g. 32345345 → \"32.345.345\"). */\nfunction groupThousands(value: number, separator: string): string {\n const [intPart, decPart] = String(value).split('.')\n const sign = intPart.startsWith('-') ? '-' : ''\n const digits = sign ? intPart.slice(1) : intPart\n const grouped = digits.replace(/\\B(?=(\\d{3})+(?!\\d))/g, separator)\n return decPart != null ? `${sign}${grouped}.${decPart}` : `${sign}${grouped}`\n}\n\n/** Counts the \"significant\" (non-separator) chars — used to keep the caret stable across regrouping. */\nfunction countExcept(s: string, sep: string): number {\n let n = 0\n for (const c of s) if (c !== sep) n++\n return n\n}\n\n/** Index just after the `n`-th non-separator char in `str` (where the caret should land after regrouping). */\nfunction positionAfterExcept(str: string, sep: string, n: number): number {\n if (n <= 0) return 0\n let count = 0\n for (let i = 0; i < str.length; i++) {\n if (str[i] !== sep) {\n count += 1\n if (count === n) return i + 1\n }\n }\n return str.length\n}\n\nexport interface NumberFieldProps extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'size' | 'value' | 'defaultValue' | 'onChange' | 'type' | 'min' | 'max' | 'step' | 'prefix'\n> {\n /** Label rendered above the field. */\n label?: ReactNode\n /** Preset size — drives the control height, font size and padding. */\n size?: NumberFieldSize\n /** Marks the field invalid: red border/focus ring + the `helperText` in the error color. */\n error?: boolean\n /** Helper / validation text under the field. Adopts the error color while `error`. */\n helperText?: ReactNode\n /** Adds a red asterisk after the label. */\n required?: boolean\n /** Stretches the field to fill its container width. Defaults to `true`. */\n fullWidth?: boolean\n /** Controlled numeric value (`null` = empty). */\n value?: number | null\n /** Initial value for uncontrolled use (`null` = empty). Defaults to `null`. */\n defaultValue?: number | null\n /** Fires with the parsed numeric value (or `null` when the field is empty). */\n onChange?: (value: number | null) => void\n /** Minimum value — clamps on blur and on the stepper, and disables `−` at the floor. Defaults to `0`; pass a negative `min` to allow negatives. */\n min?: number\n /** Maximum value — clamps on blur and on the stepper, and disables `+` at the ceiling. */\n max?: number\n /** Amount the `+`/`−` buttons add or subtract. Defaults to `1`. */\n step?: number\n /** Hides the `+`/`−` stepper buttons (keyboard entry only). */\n hideStepper?: boolean\n /**\n * Thousands-group separator shown **live** as you type, e.g. `\".\"` displays `32345345` as\n * `32.345.345` (or `\",\"`). The caret is preserved across regrouping; the `value`/`onChange`/form\n * value stay a plain `number`. Best for integers — with `\".\"` decimals aren't supported (the dot is\n * the group separator).\n */\n thousandSeparator?: string\n}\n\n/**\n * A numeric input with `+`/`−` stepper buttons. Supports `min`/`max` clamping, a `step` amount,\n * controlled (`value` + `onChange`) or uncontrolled (`defaultValue`) use, optional live thousands\n * grouping, and — like `TextField` — binds to a surrounding `<Form>` by `name` (its form value is a\n * real `number`, validated by the Zod schema). `onChange` emits a `number` or `null` (empty). Shares\n * `TextField`'s field chrome, so label, sizing, error and focus styling are identical.\n */\nexport const NumberField = forwardRef<HTMLInputElement, NumberFieldProps>(function NumberField(\n {\n label,\n size = 'md',\n error,\n helperText,\n required = false,\n fullWidth = true,\n value,\n defaultValue = null,\n onChange,\n min = 0,\n max,\n step = 1,\n hideStepper = false,\n thousandSeparator,\n name,\n onBlur,\n disabled = false,\n id: idProp,\n className,\n style,\n ...props\n },\n ref,\n) {\n const t = useT()\n const reactId = useId()\n const id = idProp ?? reactId\n const helperId = `${id}-helper`\n\n // Auto-bind to a surrounding <Form> by `name`. The form stores a real number; we use field() for\n // touched/error/helper and read/write the numeric value through values/setValue.\n const form = useFormContext()\n const isFormBound = Boolean(form && name)\n const bound = form && name ? form.field(name) : undefined\n\n const externalValue: number | null | undefined =\n value !== undefined\n ? value\n : isFormBound\n ? ((form!.values[name!] as number | null | undefined) ?? null)\n : undefined\n const isControlled = externalValue !== undefined\n const [internal, setInternal] = useState<number | null>(defaultValue)\n const numValue: number | null = isControlled ? externalValue! : internal\n\n // number <-> display string, applying live thousands grouping when `thousandSeparator` is set.\n const toDisplay = (v: number | null): string =>\n v == null ? '' : thousandSeparator != null ? groupThousands(v, thousandSeparator) : String(v)\n const fromDisplay = (raw: string): number | null =>\n parseValue(thousandSeparator != null ? raw.split(thousandSeparator).join('') : raw)\n\n // The display string mirrors `numValue` but tolerates in-progress input (\"-\", \"1.\" …).\n const [text, setText] = useState<string>(() => toDisplay(numValue))\n useEffect(() => {\n if (fromDisplay(text) !== numValue) setText(toDisplay(numValue))\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [numValue]) // re-sync only when the value changes from the outside (stepper, form, reset)\n\n // Caret restoration after regrouping (the formatted string length changes as separators move).\n const innerRef = useRef<HTMLInputElement>(null)\n const pendingCaret = useRef<number | null>(null)\n const setInputRef = useCallback(\n (node: HTMLInputElement | null) => {\n innerRef.current = node\n if (typeof ref === 'function') ref(node)\n else if (ref) ref.current = node\n },\n [ref],\n )\n useLayoutEffect(() => {\n const pos = pendingCaret.current\n if (pos == null) return\n pendingCaret.current = null\n innerRef.current?.setSelectionRange(pos, pos)\n })\n\n const resolvedError = error ?? bound?.error ?? false\n const resolvedHelperText = helperText ?? bound?.helperText\n\n const commit = (next: number | null) => {\n if (!isControlled) setInternal(next)\n if (isFormBound) form!.setValue(name!, next)\n onChange?.(next)\n }\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const el = event.target\n const raw = el.value\n\n if (thousandSeparator == null) {\n if (raw !== '' && !NUMERIC_RE.test(raw)) return // reject non-numeric keystrokes\n setText(raw)\n commit(parseValue(raw))\n return\n }\n\n // Live grouping: strip separators, validate, regroup, and remember where the caret should land.\n const sep = thousandSeparator\n const cleaned = raw.split(sep).join('')\n if (cleaned !== '' && !NUMERIC_RE.test(cleaned)) return\n const caret = el.selectionStart ?? raw.length\n const significantBefore = countExcept(raw.slice(0, caret), sep)\n const next = parseValue(cleaned)\n const formatted = next == null ? cleaned : groupThousands(next, sep)\n setText(formatted)\n commit(next)\n pendingCaret.current = positionAfterExcept(formatted, sep, significantBefore)\n }\n\n const handleBlur = (event: FocusEvent<HTMLInputElement>) => {\n if (numValue != null) {\n const clamped = clampValue(numValue, min, max)\n if (clamped !== numValue) commit(clamped)\n }\n bound?.onBlur(event)\n onBlur?.(event)\n }\n\n const stepBy = (direction: 1 | -1) => {\n const base = numValue ?? min ?? 0\n commit(clampValue(roundStep(base + direction * step), min, max))\n }\n\n const atMax = max != null && numValue != null && numValue >= max\n const atMin = min != null && numValue != null && numValue <= min\n\n return (\n <div\n className={clsx(\n fieldStyles.field,\n fieldStyles[size],\n fullWidth && fieldStyles.fullWidth,\n resolvedError && fieldStyles.error,\n disabled && fieldStyles.disabled,\n className,\n )}\n style={style as CSSProperties}\n >\n {label != null && (\n <label htmlFor={id} className={fieldStyles.label}>\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\">\n {label}\n </Typography>\n {required && (\n <span className={fieldStyles.required} aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n )}\n\n <div className={clsx(fieldStyles.control, !hideStepper && fieldStyles.hasRightAdornment)}>\n <input\n ref={setInputRef}\n id={id}\n name={name}\n type=\"text\"\n inputMode=\"decimal\"\n className={fieldStyles.input}\n value={text}\n onChange={handleChange}\n onBlur={handleBlur}\n disabled={disabled}\n aria-invalid={resolvedError || undefined}\n aria-describedby={resolvedHelperText != null ? helperId : undefined}\n {...props}\n />\n {!hideStepper && (\n <>\n {/* Filled icon buttons, sized via the shared `.control .iconButton` rule (flush square,\n stretched to the control height, scaled). The minus glyph is nudged for optical centering. */}\n <IconButton\n variant=\"filled\"\n color=\"primary\"\n className={fieldStyles.iconButton}\n style={{ marginRight: -2 }}\n disabled={disabled || atMin}\n aria-label={t('numberField.decrease')}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => stepBy(-1)}\n >\n <Icon name=\"Minus\" />\n </IconButton>\n <IconButton\n variant=\"filled\"\n color=\"primary\"\n className={fieldStyles.iconButton}\n disabled={disabled || atMax}\n aria-label={t('numberField.increase')}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => stepBy(1)}\n >\n <Icon name=\"Add\" />\n </IconButton>\n </>\n )}\n </div>\n\n {resolvedHelperText != null && (\n <Typography\n as=\"span\"\n id={helperId}\n variant=\"bodySmall\"\n color={resolvedError ? 'error' : 'muted'}\n className={fieldStyles.helper}\n >\n {resolvedHelperText}\n </Typography>\n )}\n </div>\n )\n})\n"],"names":["NUMERIC_RE","parseValue","raw","n","clampValue","min","max","roundStep","groupThousands","value","separator","intPart","decPart","sign","grouped","countExcept","s","sep","c","positionAfterExcept","str","count","i","NumberField","forwardRef","label","size","error","helperText","required","fullWidth","defaultValue","onChange","step","hideStepper","thousandSeparator","name","onBlur","disabled","idProp","className","style","props","ref","t","useT","reactId","useId","id","helperId","form","useFormContext","isFormBound","bound","externalValue","isControlled","internal","setInternal","useState","numValue","toDisplay","v","fromDisplay","text","setText","useEffect","innerRef","useRef","pendingCaret","setInputRef","useCallback","node","useLayoutEffect","pos","_a","resolvedError","resolvedHelperText","commit","next","handleChange","event","el","cleaned","caret","significantBefore","formatted","handleBlur","clamped","stepBy","direction","atMax","atMin","jsxs","clsx","fieldStyles","jsx","Typography","Fragment","IconButton","Icon"],"mappings":"wUA0BMA,EAAa,gBAGnB,SAASC,EAAWC,EAA4B,CAC9C,GAAIA,IAAQ,IAAMA,IAAQ,KAAOA,IAAQ,KAAOA,IAAQ,KAAM,OAAO,KACrE,MAAMC,EAAI,OAAOD,CAAG,EACpB,OAAO,OAAO,MAAMC,CAAC,EAAI,KA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UA,EAAM,eAAA,EAC9B,QAAS,IAAMQ,EAAO,EAAE,EAExB,SAAAO,EAAAA,IAACI,EAAAA,KAAA,CAAK,KAAK,OAAA,CAAQ,CAAA,CAAA,EAErBJ,EAAAA,IAACG,EAAAA,WAAA,CACC,QAAQ,SACR,MAAM,UACN,UAAWJ,EAAAA,YAAY,WACvB,SAAUxD,GAAYoD,GACtB,aAAY9C,EAAE,sBAAsB,EACpC,YAAcoC,GAAUA,EAAM,eAAA,EAC9B,QAAS,IAAMQ,EAAO,CAAC,EAEvB,SAAAO,EAAAA,IAACI,EAAAA,KAAA,CAAK,KAAK,KAAA,CAAM,CAAA,CAAA,CACnB,CAAA,CACF,CAAA,EAEJ,EAECvB,GAAsB,MACrBmB,EAAAA,IAACC,EAAAA,WAAA,CACC,GAAG,OACH,GAAI/C,EACJ,QAAQ,YACR,MAAO0B,EAAgB,QAAU,QACjC,UAAWmB,EAAAA,YAAY,OAEtB,SAAAlB,CAAA,CAAA,CACH,CAAA,CAAA,CAIR,CAAC"}
@@ -1,2 +1,2 @@
1
- "use strict";const n=require("react/jsx-runtime"),_=require("react"),k=require("clsx"),ee=require("./formContext-bTWrqdEV.cjs"),R=require("./Typography-B6ASPrzT.cjs"),u=require("./TextField.module-DsNCo8vN.cjs"),te=require("./ConfigProvider-CVLHPXQm.cjs"),se="_row_1bbms_2",re="_center_1bbms_14",oe="_end_1bbms_15",le="_sm_1bbms_27",ce="_md_1bbms_31",ne="_lg_1bbms_35",ae="_box_1bbms_41",ie="_filled_1bbms_65",de="_invalid_1bbms_82",m={row:se,center:re,end:oe,sm:le,md:ce,lg:ne,box:ae,filled:ie,invalid:de},fe={numeric:/[0-9]/,alphabetic:/[A-Za-z]/,alphanumeric:/[A-Za-z0-9]/};function ue(S,l){const a=[...S].slice(0,l);for(;a.length<l;)a.push("");return a}const me=_.forwardRef(function({length:l=4,type:a="numeric",value:v,defaultValue:A,onChange:g,onComplete:T,name:i,label:y,helperText:I,error:z,required:O=!1,disabled:q=!1,autoFocus:P=!1,placeholder:C,size:E="md",align:M="start",color:V="primary",className:K,style:Z},$){const H=te.useT(),F=`${_.useId()}-helper`,B=fe[a],p=ee.useFormContext(),w=!!(p&&i),o=p&&i?p.field(i):void 0,L=v!==void 0?v:w?p.values[i]:void 0,N=v!==void 0||w,[G,J]=_.useState(A??""),Q=N?L??"":G,x=z??(o==null?void 0:o.error)??!1,D=I??(o==null?void 0:o.helperText),d=ue(Q,l),j=_.useRef([]);_.useEffect(()=>{var t;P&&((t=j.current[0])==null||t.focus())},[]);const f=t=>{const e=j.current[Math.max(0,Math.min(t,l-1))];e==null||e.focus(),e==null||e.select()},b=t=>{const e=t.join("");N||J(e),w&&p.setValue(i,e),g==null||g(e),t.every(s=>s!=="")&&(T==null||T(e))},U=(t,e)=>{const s=[...e].filter(r=>B.test(r));if(e!==""&&s.length===0)return;const c=[...d];if(s.length<=1)c[t]=s[0]??"",b(c),s[0]&&f(t+1);else{let r=t;for(const h of s){if(r>=l)break;c[r]=h,r++}b(c),f(r)}},W=(t,e)=>{if(e.key==="Backspace"){if(d[t]===""&&t>0){e.preventDefault();const s=[...d];s[t-1]="",b(s),f(t-1)}}else if(e.key==="ArrowLeft")e.preventDefault(),f(t-1);else if(e.key==="ArrowRight")e.preventDefault(),f(t+1);else if(e.key==="Delete"){e.preventDefault();const s=[...d];s[t]="",b(s)}},X=(t,e)=>{e.preventDefault();const s=[...e.clipboardData.getData("text")].filter(h=>B.test(h));if(s.length===0)return;const c=[...d];let r=t;for(const h of s){if(r>=l)break;c[r]=h,r++}b(c),f(r)},Y=t=>{t.currentTarget.contains(t.relatedTarget)||o==null||o.onBlur(t)};return n.jsxs("div",{ref:$,className:k.clsx(u.fieldStyles.field,x&&u.fieldStyles.error,q&&u.fieldStyles.disabled,K),style:{"--tz-btn-rgb":`var(--tz-color-${V}-rgb)`,...Z},children:[y!=null&&n.jsxs("span",{className:u.fieldStyles.label,children:[n.jsx(R.Typography,{as:"span",variant:"bodySmall",color:"muted",children:y}),O&&n.jsx("span",{className:u.fieldStyles.required,"aria-hidden":"true",children:"*"})]}),n.jsx("div",{role:"group","aria-label":typeof y=="string"?y:"One-time code","aria-invalid":x||void 0,"aria-describedby":D!=null?F:void 0,className:k.clsx(m.row,m[E],m[M],x&&m.invalid),onBlur:Y,children:d.map((t,e)=>n.jsx("input",{ref:s=>{j.current[e]=s},name:e===0?i:void 0,type:"text",inputMode:a==="numeric"?"numeric":"text",autoComplete:e===0?"one-time-code":"off","aria-label":H("otpField.digit",{index:e+1,total:l}),className:k.clsx(m.box,t!==""&&m.filled),value:t,placeholder:C,disabled:q,onChange:s=>U(e,s.target.value),onKeyDown:s=>W(e,s),onPaste:s=>X(e,s),onFocus:s=>s.target.select()},e))}),D!=null&&n.jsx(R.Typography,{as:"span",id:F,variant:"bodySmall",color:x?"error":"muted",className:u.fieldStyles.helper,children:D})]})});exports.OtpField=me;
2
- //# sourceMappingURL=OtpField-XieJfl1y.cjs.map
1
+ "use strict";const n=require("react/jsx-runtime"),_=require("react"),k=require("clsx"),ee=require("./formContext-bTWrqdEV.cjs"),R=require("./Typography-d97DdbNd.cjs"),u=require("./TextField.module-DsNCo8vN.cjs"),te=require("./ConfigProvider-th4GYhcU.cjs"),se="_row_1bbms_2",re="_center_1bbms_14",oe="_end_1bbms_15",le="_sm_1bbms_27",ce="_md_1bbms_31",ne="_lg_1bbms_35",ae="_box_1bbms_41",ie="_filled_1bbms_65",de="_invalid_1bbms_82",m={row:se,center:re,end:oe,sm:le,md:ce,lg:ne,box:ae,filled:ie,invalid:de},fe={numeric:/[0-9]/,alphabetic:/[A-Za-z]/,alphanumeric:/[A-Za-z0-9]/};function ue(S,l){const a=[...S].slice(0,l);for(;a.length<l;)a.push("");return a}const me=_.forwardRef(function({length:l=4,type:a="numeric",value:v,defaultValue:A,onChange:g,onComplete:T,name:i,label:y,helperText:I,error:z,required:O=!1,disabled:q=!1,autoFocus:P=!1,placeholder:C,size:E="md",align:M="start",color:V="primary",className:K,style:Z},$){const H=te.useT(),F=`${_.useId()}-helper`,B=fe[a],p=ee.useFormContext(),w=!!(p&&i),o=p&&i?p.field(i):void 0,L=v!==void 0?v:w?p.values[i]:void 0,N=v!==void 0||w,[G,J]=_.useState(A??""),Q=N?L??"":G,x=z??(o==null?void 0:o.error)??!1,D=I??(o==null?void 0:o.helperText),d=ue(Q,l),j=_.useRef([]);_.useEffect(()=>{var t;P&&((t=j.current[0])==null||t.focus())},[]);const f=t=>{const e=j.current[Math.max(0,Math.min(t,l-1))];e==null||e.focus(),e==null||e.select()},b=t=>{const e=t.join("");N||J(e),w&&p.setValue(i,e),g==null||g(e),t.every(s=>s!=="")&&(T==null||T(e))},U=(t,e)=>{const s=[...e].filter(r=>B.test(r));if(e!==""&&s.length===0)return;const c=[...d];if(s.length<=1)c[t]=s[0]??"",b(c),s[0]&&f(t+1);else{let r=t;for(const h of s){if(r>=l)break;c[r]=h,r++}b(c),f(r)}},W=(t,e)=>{if(e.key==="Backspace"){if(d[t]===""&&t>0){e.preventDefault();const s=[...d];s[t-1]="",b(s),f(t-1)}}else if(e.key==="ArrowLeft")e.preventDefault(),f(t-1);else if(e.key==="ArrowRight")e.preventDefault(),f(t+1);else if(e.key==="Delete"){e.preventDefault();const s=[...d];s[t]="",b(s)}},X=(t,e)=>{e.preventDefault();const s=[...e.clipboardData.getData("text")].filter(h=>B.test(h));if(s.length===0)return;const c=[...d];let r=t;for(const h of s){if(r>=l)break;c[r]=h,r++}b(c),f(r)},Y=t=>{t.currentTarget.contains(t.relatedTarget)||o==null||o.onBlur(t)};return n.jsxs("div",{ref:$,className:k.clsx(u.fieldStyles.field,x&&u.fieldStyles.error,q&&u.fieldStyles.disabled,K),style:{"--tz-btn-rgb":`var(--tz-color-${V}-rgb)`,...Z},children:[y!=null&&n.jsxs("span",{className:u.fieldStyles.label,children:[n.jsx(R.Typography,{as:"span",variant:"bodySmall",color:"muted",children:y}),O&&n.jsx("span",{className:u.fieldStyles.required,"aria-hidden":"true",children:"*"})]}),n.jsx("div",{role:"group","aria-label":typeof y=="string"?y:"One-time code","aria-invalid":x||void 0,"aria-describedby":D!=null?F:void 0,className:k.clsx(m.row,m[E],m[M],x&&m.invalid),onBlur:Y,children:d.map((t,e)=>n.jsx("input",{ref:s=>{j.current[e]=s},name:e===0?i:void 0,type:"text",inputMode:a==="numeric"?"numeric":"text",autoComplete:e===0?"one-time-code":"off","aria-label":H("otpField.digit",{index:e+1,total:l}),className:k.clsx(m.box,t!==""&&m.filled),value:t,placeholder:C,disabled:q,onChange:s=>U(e,s.target.value),onKeyDown:s=>W(e,s),onPaste:s=>X(e,s),onFocus:s=>s.target.select()},e))}),D!=null&&n.jsx(R.Typography,{as:"span",id:F,variant:"bodySmall",color:x?"error":"muted",className:u.fieldStyles.helper,children:D})]})});exports.OtpField=me;
2
+ //# sourceMappingURL=OtpField-DK5KikOt.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"OtpField-XieJfl1y.cjs","sources":["../src/components/OtpField/OtpField.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useId,\n useRef,\n useState,\n type ClipboardEvent,\n type CSSProperties,\n type FocusEvent,\n type KeyboardEvent,\n type ReactNode,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useFormContext } from '../../form/formContext'\nimport { useT, type ThemeColor } from '../../theme'\nimport { Typography } from '../Typography'\nimport fieldStyles from '../TextField/TextField.module.css'\nimport styles from './OtpField.module.css'\n\nexport type OtpFieldSize = 'sm' | 'md' | 'lg'\n/** Which characters the code accepts. */\nexport type OtpFieldType = 'numeric' | 'alphabetic' | 'alphanumeric'\n\nexport type OtpFieldAlign = 'start' | 'center' | 'end'\n\n/** Allowed-character matcher per `type`. */\nconst PATTERN: Record<OtpFieldType, RegExp> = {\n numeric: /[0-9]/,\n alphabetic: /[A-Za-z]/,\n alphanumeric: /[A-Za-z0-9]/,\n}\n\n/** Split a code string into exactly `length` single-char slots, padded with empties. */\nfunction toChars(value: string, length: number): string[] {\n const out = [...value].slice(0, length)\n while (out.length < length) out.push('')\n return out\n}\n\nexport interface OtpFieldProps {\n /** Number of input boxes (the code length). Defaults to `4`. */\n length?: number\n /** Which characters are accepted (also drives the mobile keyboard). Defaults to `'numeric'`. */\n type?: OtpFieldType\n /** Controlled value — the concatenated code string. */\n value?: string\n /** Initial value for uncontrolled use. */\n defaultValue?: string\n /** Fires with the full code string on every change. */\n onChange?: (value: string) => void\n /** Fires with the code once every box is filled. */\n onComplete?: (value: string) => void\n /** Field name — the `<Form>` binding key (form value is the code `string`). */\n name?: string\n /** Label rendered above the boxes. */\n label?: ReactNode\n /** Helper / error text under the boxes (shown in the error color while `error`). */\n helperText?: ReactNode\n /** Marks the field invalid — reddens the boxes + helper. */\n error?: boolean\n /** Adds a red asterisk after the label. */\n required?: boolean\n /** Disables every box. */\n disabled?: boolean\n /** Focus the first box on mount. */\n autoFocus?: boolean\n /** Placeholder character shown in empty boxes (e.g. `'•'`). */\n placeholder?: string\n /** Preset size. Defaults to `'md'`. */\n size?: OtpFieldSize\n /** Horizontal alignment of the boxes within the field. Defaults to `'start'` (left). */\n align?: OtpFieldAlign\n /** Theme palette token for the focus ring / active box. Defaults to `'primary'`. */\n color?: ThemeColor\n className?: string\n style?: CSSProperties\n}\n\n/**\n * A one-time-passcode input — a row of single-character boxes for verification codes. **`length`**\n * (default `4`) sets the box count; **`type`** (`'numeric'` default · `'alphabetic'` · `'alphanumeric'`)\n * restricts the accepted characters and the mobile keyboard. Typing advances to the next box, Backspace\n * clears + steps back, Arrows navigate, and **paste / SMS autofill** (`autocomplete=\"one-time-code\"`)\n * distributes the whole code across the boxes. The value is the concatenated string — controlled\n * (`value` + `onChange`) or uncontrolled (`defaultValue`); **`onComplete`** fires when all boxes are\n * filled. Shares the field-family chrome (`label` · `error` + `helperText` · `required` · `disabled` ·\n * `size`) and binds to a surrounding `<Form>` by **`name`** (form value = the code string; validate with\n * e.g. `z.string().length(4)` or a `type`-matching regex). Tinted by `color` via the shared\n * `--tz-btn-rgb` pattern; `role=\"group\"` with per-box `aria-label`s. Own CSS module (+ TextField's for\n * the label/helper chrome).\n */\nexport const OtpField = forwardRef<HTMLDivElement, OtpFieldProps>(function OtpField(\n {\n length = 4,\n type = 'numeric',\n value,\n defaultValue,\n onChange,\n onComplete,\n name,\n label,\n helperText,\n error,\n required = false,\n disabled = false,\n autoFocus = false,\n placeholder,\n size = 'md',\n align = 'start',\n color = 'primary',\n className,\n style,\n },\n ref,\n) {\n const t = useT()\n const reactId = useId()\n const helperId = `${reactId}-helper`\n const allowed = PATTERN[type]\n\n // bind to a surrounding <Form> by `name` — form value is the code string; error/touched via field()\n const form = useFormContext()\n const isFormBound = Boolean(form && name)\n const bound = form && name ? form.field(name) : undefined\n\n const externalValue =\n value !== undefined ? value : isFormBound ? (form!.values[name!] as string) : undefined\n const isControlled = value !== undefined || isFormBound\n const [internal, setInternal] = useState<string>(defaultValue ?? '')\n const currentValue = isControlled ? (externalValue ?? '') : internal\n\n const resolvedError = error ?? bound?.error ?? false\n const resolvedHelperText = helperText ?? bound?.helperText\n\n // the code split into exactly `length` single-char slots (padded with empties)\n const chars = toChars(currentValue, length)\n\n const inputsRef = useRef<(HTMLInputElement | null)[]>([])\n\n useEffect(() => {\n if (autoFocus) inputsRef.current[0]?.focus()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n const focusBox = (i: number) => {\n const el = inputsRef.current[Math.max(0, Math.min(i, length - 1))]\n el?.focus()\n el?.select()\n }\n\n const commit = (nextChars: string[]) => {\n const next = nextChars.join('')\n if (!isControlled) setInternal(next)\n if (isFormBound) form!.setValue(name!, next)\n onChange?.(next)\n if (nextChars.every((c) => c !== '')) onComplete?.(next)\n }\n\n const handleChange = (index: number, raw: string) => {\n const filtered = [...raw].filter((c) => allowed.test(c))\n // a disallowed keystroke (raw non-empty but nothing survives the filter) is ignored\n if (raw !== '' && filtered.length === 0) return\n const nextChars = [...chars]\n if (filtered.length <= 1) {\n // a single typed char (boxes select-on-focus, so this replaces) — or a clear ('')\n nextChars[index] = filtered[0] ?? ''\n commit(nextChars)\n if (filtered[0]) focusBox(index + 1)\n } else {\n // multiple chars (SMS autofill dumps the whole code into one box) → distribute from here\n let k = index\n for (const ch of filtered) {\n if (k >= length) break\n nextChars[k] = ch\n k++\n }\n commit(nextChars)\n focusBox(k)\n }\n }\n\n const handleKeyDown = (index: number, event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Backspace') {\n if (chars[index] === '' && index > 0) {\n // empty box → step back and clear the previous one\n event.preventDefault()\n const nextChars = [...chars]\n nextChars[index - 1] = ''\n commit(nextChars)\n focusBox(index - 1)\n }\n // a non-empty box lets the native delete run → onChange fires with '' (stays put)\n } else if (event.key === 'ArrowLeft') {\n event.preventDefault()\n focusBox(index - 1)\n } else if (event.key === 'ArrowRight') {\n event.preventDefault()\n focusBox(index + 1)\n } else if (event.key === 'Delete') {\n event.preventDefault()\n const nextChars = [...chars]\n nextChars[index] = ''\n commit(nextChars)\n }\n }\n\n const handlePaste = (index: number, event: ClipboardEvent<HTMLInputElement>) => {\n event.preventDefault()\n const filtered = [...event.clipboardData.getData('text')].filter((c) => allowed.test(c))\n if (filtered.length === 0) return\n const nextChars = [...chars]\n let k = index\n for (const ch of filtered) {\n if (k >= length) break\n nextChars[k] = ch\n k++\n }\n commit(nextChars)\n focusBox(k)\n }\n\n // mark the field touched when focus leaves the whole widget (not when it hops between boxes)\n const handleBlur = (event: FocusEvent<HTMLDivElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) {\n bound?.onBlur(event as unknown as FocusEvent<HTMLInputElement>)\n }\n }\n\n return (\n <div\n ref={ref}\n className={clsx(\n fieldStyles.field,\n resolvedError && fieldStyles.error,\n disabled && fieldStyles.disabled,\n className,\n )}\n style={\n {\n '--tz-btn-rgb': `var(--tz-color-${color}-rgb)`,\n ...style,\n } as CSSProperties\n }\n >\n {label != null && (\n <span className={fieldStyles.label}>\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\">\n {label}\n </Typography>\n {required && (\n <span className={fieldStyles.required} aria-hidden=\"true\">\n *\n </span>\n )}\n </span>\n )}\n\n <div\n role=\"group\"\n aria-label={typeof label === 'string' ? label : 'One-time code'}\n aria-invalid={resolvedError || undefined}\n aria-describedby={resolvedHelperText != null ? helperId : undefined}\n className={clsx(styles.row, styles[size], styles[align], resolvedError && styles.invalid)}\n onBlur={handleBlur}\n >\n {chars.map((char, i) => (\n <input\n key={i}\n ref={(el) => {\n inputsRef.current[i] = el\n }}\n // the name goes on the first box only, so the form's scroll-to-error can target it\n name={i === 0 ? name : undefined}\n type=\"text\"\n inputMode={type === 'numeric' ? 'numeric' : 'text'}\n autoComplete={i === 0 ? 'one-time-code' : 'off'}\n aria-label={t('otpField.digit', { index: i + 1, total: length })}\n className={clsx(styles.box, char !== '' && styles.filled)}\n value={char}\n placeholder={placeholder}\n disabled={disabled}\n onChange={(e) => handleChange(i, e.target.value)}\n onKeyDown={(e) => handleKeyDown(i, e)}\n onPaste={(e) => handlePaste(i, e)}\n onFocus={(e) => e.target.select()}\n />\n ))}\n </div>\n\n {resolvedHelperText != null && (\n <Typography\n as=\"span\"\n id={helperId}\n variant=\"bodySmall\"\n color={resolvedError ? 'error' : 'muted'}\n className={fieldStyles.helper}\n >\n {resolvedHelperText}\n </Typography>\n )}\n </div>\n )\n})\n"],"names":["PATTERN","toChars","value","length","out","OtpField","forwardRef","type","defaultValue","onChange","onComplete","name","label","helperText","error","required","disabled","autoFocus","placeholder","size","align","color","className","style","ref","t","useT","helperId","useId","allowed","form","useFormContext","isFormBound","bound","externalValue","isControlled","internal","setInternal","useState","currentValue","resolvedError","resolvedHelperText","chars","inputsRef","useRef","useEffect","_a","focusBox","i","el","commit","nextChars","next","c","handleChange","index","raw","filtered","k","ch","handleKeyDown","event","handlePaste","handleBlur","jsxs","clsx","fieldStyles","jsx","Typography","styles","char","e"],"mappings":"2fA0BMA,GAAwC,CAC5C,QAAS,QACT,WAAY,WACZ,aAAc,aAChB,E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AAK,QACL,aAAY,OAAOvD,GAAU,SAAWA,EAAQ,gBAChD,eAAc4B,GAAiB,OAC/B,mBAAkBC,GAAsB,KAAOd,EAAW,OAC1D,UAAWsC,EAAAA,KAAKI,EAAO,IAAKA,EAAOlD,CAAI,EAAGkD,EAAOjD,CAAK,EAAGoB,GAAiB6B,EAAO,OAAO,EACxF,OAAQN,EAEP,SAAArB,EAAM,IAAI,CAAC4B,EAAMtB,IAChBmB,EAAAA,IAAC,QAAA,CAEC,IAAMlB,GAAO,CACXN,EAAU,QAAQK,CAAC,EAAIC,CACzB,EAEA,KAAMD,IAAM,EAAIrC,EAAO,OACvB,KAAK,OACL,UAAWJ,IAAS,UAAY,UAAY,OAC5C,aAAcyC,IAAM,EAAI,gBAAkB,MAC1C,aAAYvB,EAAE,iBAAkB,CAAE,MAAOuB,EAAI,EAAG,MAAO7C,EAAQ,EAC/D,UAAW8D,EAAAA,KAAKI,EAAO,IAAKC,IAAS,IAAMD,EAAO,MAAM,EACxD,MAAOC,EACP,YAAApD,EACA,SAAAF,EACA,SAAWuD,GAAMjB,EAAaN,EAAGuB,EAAE,OAAO,KAAK,EAC/C,UAAYA,GAAMX,EAAcZ,EAAGuB,CAAC,EACpC,QAAUA,GAAMT,EAAYd,EAAGuB,CAAC,EAChC,QAAUA,GAAMA,EAAE,OAAO,OAAA,CAAO,EAjB3BvB,CAAA,CAmBR,CAAA,CAAA,EAGFP,GAAsB,MACrB0B,EAAAA,IAACC,EAAAA,WAAA,CACC,GAAG,OACH,GAAIzC,EACJ,QAAQ,YACR,MAAOa,EAAgB,QAAU,QACjC,UAAW0B,EAAAA,YAAY,OAEtB,SAAAzB,CAAA,CAAA,CACH,CAAA,CAAA,CAIR,CAAC"}
1
+ {"version":3,"file":"OtpField-DK5KikOt.cjs","sources":["../src/components/OtpField/OtpField.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useId,\n useRef,\n useState,\n type ClipboardEvent,\n type CSSProperties,\n type FocusEvent,\n type KeyboardEvent,\n type ReactNode,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useFormContext } from '../../form/formContext'\nimport { useT, type ThemeColor } from '../../theme'\nimport { Typography } from '../Typography'\nimport fieldStyles from '../TextField/TextField.module.css'\nimport styles from './OtpField.module.css'\n\nexport type OtpFieldSize = 'sm' | 'md' | 'lg'\n/** Which characters the code accepts. */\nexport type OtpFieldType = 'numeric' | 'alphabetic' | 'alphanumeric'\n\nexport type OtpFieldAlign = 'start' | 'center' | 'end'\n\n/** Allowed-character matcher per `type`. */\nconst PATTERN: Record<OtpFieldType, RegExp> = {\n numeric: /[0-9]/,\n alphabetic: /[A-Za-z]/,\n alphanumeric: /[A-Za-z0-9]/,\n}\n\n/** Split a code string into exactly `length` single-char slots, padded with empties. */\nfunction toChars(value: string, length: number): string[] {\n const out = [...value].slice(0, length)\n while (out.length < length) out.push('')\n return out\n}\n\nexport interface OtpFieldProps {\n /** Number of input boxes (the code length). Defaults to `4`. */\n length?: number\n /** Which characters are accepted (also drives the mobile keyboard). Defaults to `'numeric'`. */\n type?: OtpFieldType\n /** Controlled value — the concatenated code string. */\n value?: string\n /** Initial value for uncontrolled use. */\n defaultValue?: string\n /** Fires with the full code string on every change. */\n onChange?: (value: string) => void\n /** Fires with the code once every box is filled. */\n onComplete?: (value: string) => void\n /** Field name — the `<Form>` binding key (form value is the code `string`). */\n name?: string\n /** Label rendered above the boxes. */\n label?: ReactNode\n /** Helper / error text under the boxes (shown in the error color while `error`). */\n helperText?: ReactNode\n /** Marks the field invalid — reddens the boxes + helper. */\n error?: boolean\n /** Adds a red asterisk after the label. */\n required?: boolean\n /** Disables every box. */\n disabled?: boolean\n /** Focus the first box on mount. */\n autoFocus?: boolean\n /** Placeholder character shown in empty boxes (e.g. `'•'`). */\n placeholder?: string\n /** Preset size. Defaults to `'md'`. */\n size?: OtpFieldSize\n /** Horizontal alignment of the boxes within the field. Defaults to `'start'` (left). */\n align?: OtpFieldAlign\n /** Theme palette token for the focus ring / active box. Defaults to `'primary'`. */\n color?: ThemeColor\n className?: string\n style?: CSSProperties\n}\n\n/**\n * A one-time-passcode input — a row of single-character boxes for verification codes. **`length`**\n * (default `4`) sets the box count; **`type`** (`'numeric'` default · `'alphabetic'` · `'alphanumeric'`)\n * restricts the accepted characters and the mobile keyboard. Typing advances to the next box, Backspace\n * clears + steps back, Arrows navigate, and **paste / SMS autofill** (`autocomplete=\"one-time-code\"`)\n * distributes the whole code across the boxes. The value is the concatenated string — controlled\n * (`value` + `onChange`) or uncontrolled (`defaultValue`); **`onComplete`** fires when all boxes are\n * filled. Shares the field-family chrome (`label` · `error` + `helperText` · `required` · `disabled` ·\n * `size`) and binds to a surrounding `<Form>` by **`name`** (form value = the code string; validate with\n * e.g. `z.string().length(4)` or a `type`-matching regex). Tinted by `color` via the shared\n * `--tz-btn-rgb` pattern; `role=\"group\"` with per-box `aria-label`s. Own CSS module (+ TextField's for\n * the label/helper chrome).\n */\nexport const OtpField = forwardRef<HTMLDivElement, OtpFieldProps>(function OtpField(\n {\n length = 4,\n type = 'numeric',\n value,\n defaultValue,\n onChange,\n onComplete,\n name,\n label,\n helperText,\n error,\n required = false,\n disabled = false,\n autoFocus = false,\n placeholder,\n size = 'md',\n align = 'start',\n color = 'primary',\n className,\n style,\n },\n ref,\n) {\n const t = useT()\n const reactId = useId()\n const helperId = `${reactId}-helper`\n const allowed = PATTERN[type]\n\n // bind to a surrounding <Form> by `name` — form value is the code string; error/touched via field()\n const form = useFormContext()\n const isFormBound = Boolean(form && name)\n const bound = form && name ? form.field(name) : undefined\n\n const externalValue =\n value !== undefined ? value : isFormBound ? (form!.values[name!] as string) : undefined\n const isControlled = value !== undefined || isFormBound\n const [internal, setInternal] = useState<string>(defaultValue ?? '')\n const currentValue = isControlled ? (externalValue ?? '') : internal\n\n const resolvedError = error ?? bound?.error ?? false\n const resolvedHelperText = helperText ?? bound?.helperText\n\n // the code split into exactly `length` single-char slots (padded with empties)\n const chars = toChars(currentValue, length)\n\n const inputsRef = useRef<(HTMLInputElement | null)[]>([])\n\n useEffect(() => {\n if (autoFocus) inputsRef.current[0]?.focus()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n const focusBox = (i: number) => {\n const el = inputsRef.current[Math.max(0, Math.min(i, length - 1))]\n el?.focus()\n el?.select()\n }\n\n const commit = (nextChars: string[]) => {\n const next = nextChars.join('')\n if (!isControlled) setInternal(next)\n if (isFormBound) form!.setValue(name!, next)\n onChange?.(next)\n if (nextChars.every((c) => c !== '')) onComplete?.(next)\n }\n\n const handleChange = (index: number, raw: string) => {\n const filtered = [...raw].filter((c) => allowed.test(c))\n // a disallowed keystroke (raw non-empty but nothing survives the filter) is ignored\n if (raw !== '' && filtered.length === 0) return\n const nextChars = [...chars]\n if (filtered.length <= 1) {\n // a single typed char (boxes select-on-focus, so this replaces) — or a clear ('')\n nextChars[index] = filtered[0] ?? ''\n commit(nextChars)\n if (filtered[0]) focusBox(index + 1)\n } else {\n // multiple chars (SMS autofill dumps the whole code into one box) → distribute from here\n let k = index\n for (const ch of filtered) {\n if (k >= length) break\n nextChars[k] = ch\n k++\n }\n commit(nextChars)\n focusBox(k)\n }\n }\n\n const handleKeyDown = (index: number, event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Backspace') {\n if (chars[index] === '' && index > 0) {\n // empty box → step back and clear the previous one\n event.preventDefault()\n const nextChars = [...chars]\n nextChars[index - 1] = ''\n commit(nextChars)\n focusBox(index - 1)\n }\n // a non-empty box lets the native delete run → onChange fires with '' (stays put)\n } else if (event.key === 'ArrowLeft') {\n event.preventDefault()\n focusBox(index - 1)\n } else if (event.key === 'ArrowRight') {\n event.preventDefault()\n focusBox(index + 1)\n } else if (event.key === 'Delete') {\n event.preventDefault()\n const nextChars = [...chars]\n nextChars[index] = ''\n commit(nextChars)\n }\n }\n\n const handlePaste = (index: number, event: ClipboardEvent<HTMLInputElement>) => {\n event.preventDefault()\n const filtered = [...event.clipboardData.getData('text')].filter((c) => allowed.test(c))\n if (filtered.length === 0) return\n const nextChars = [...chars]\n let k = index\n for (const ch of filtered) {\n if (k >= length) break\n nextChars[k] = ch\n k++\n }\n commit(nextChars)\n focusBox(k)\n }\n\n // mark the field touched when focus leaves the whole widget (not when it hops between boxes)\n const handleBlur = (event: FocusEvent<HTMLDivElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) {\n bound?.onBlur(event as unknown as FocusEvent<HTMLInputElement>)\n }\n }\n\n return (\n <div\n ref={ref}\n className={clsx(\n fieldStyles.field,\n resolvedError && fieldStyles.error,\n disabled && fieldStyles.disabled,\n className,\n )}\n style={\n {\n '--tz-btn-rgb': `var(--tz-color-${color}-rgb)`,\n ...style,\n } as CSSProperties\n }\n >\n {label != null && (\n <span className={fieldStyles.label}>\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\">\n {label}\n </Typography>\n {required && (\n <span className={fieldStyles.required} aria-hidden=\"true\">\n *\n </span>\n )}\n </span>\n )}\n\n <div\n role=\"group\"\n aria-label={typeof label === 'string' ? label : 'One-time code'}\n aria-invalid={resolvedError || undefined}\n aria-describedby={resolvedHelperText != null ? helperId : undefined}\n className={clsx(styles.row, styles[size], styles[align], resolvedError && styles.invalid)}\n onBlur={handleBlur}\n >\n {chars.map((char, i) => (\n <input\n key={i}\n ref={(el) => {\n inputsRef.current[i] = el\n }}\n // the name goes on the first box only, so the form's scroll-to-error can target it\n name={i === 0 ? name : undefined}\n type=\"text\"\n inputMode={type === 'numeric' ? 'numeric' : 'text'}\n autoComplete={i === 0 ? 'one-time-code' : 'off'}\n aria-label={t('otpField.digit', { index: i + 1, total: length })}\n className={clsx(styles.box, char !== '' && styles.filled)}\n value={char}\n placeholder={placeholder}\n disabled={disabled}\n onChange={(e) => handleChange(i, e.target.value)}\n onKeyDown={(e) => handleKeyDown(i, e)}\n onPaste={(e) => handlePaste(i, e)}\n onFocus={(e) => e.target.select()}\n />\n ))}\n </div>\n\n {resolvedHelperText != null && (\n <Typography\n as=\"span\"\n id={helperId}\n variant=\"bodySmall\"\n color={resolvedError ? 'error' : 'muted'}\n className={fieldStyles.helper}\n >\n {resolvedHelperText}\n </Typography>\n )}\n </div>\n )\n})\n"],"names":["PATTERN","toChars","value","length","out","OtpField","forwardRef","type","defaultValue","onChange","onComplete","name","label","helperText","error","required","disabled","autoFocus","placeholder","size","align","color","className","style","ref","t","useT","helperId","useId","allowed","form","useFormContext","isFormBound","bound","externalValue","isControlled","internal","setInternal","useState","currentValue","resolvedError","resolvedHelperText","chars","inputsRef","useRef","useEffect","_a","focusBox","i","el","commit","nextChars","next","c","handleChange","index","raw","filtered","k","ch","handleKeyDown","event","handlePaste","handleBlur","jsxs","clsx","fieldStyles","jsx","Typography","styles","char","e"],"mappings":"2fA0BMA,GAAwC,CAC5C,QAAS,QACT,WAAY,WACZ,aAAc,aAChB,EAGA,SAASC,GAAQC,EAAeC,EAA0B,CACxD,MAAMC,EAAM,CAAC,GAAGF,CAAK,EAAE,MAAM,EAAGC,CAAM,EACtC,KAAOC,EAAI,OAASD,GAAQC,EAAI,KAAK,EAAE,EACvC,OAAOA,CACT,CAsDO,MAAMC,GAAWC,EAAAA,WAA0C,SAChE,CACE,OAAAH,EAAS,EACT,KAAAI,EAAO,UACP,MAAAL,EACA,aAAAM,EACA,SAAAC,EACA,WAAAC,EACA,KAAAC,EACA,MAAAC,EACA,WAAAC,EACA,MAAAC,EACA,SAAAC,EAAW,GACX,SAAAC,EAAW,GACX,UAAAC,EAAY,GACZ,YAAAC,EACA,KAAAC,EAAO,KACP,MAAAC,EAAQ,QACR,MAAAC,EAAQ,UACR,UAAAC,EACA,MAAAC,CACF,EACAC,EACA,CACA,MAAMC,EAAIC,GAAAA,KAAA,EAEJC,EAAW,GADDC,EAAAA,MAAA,CACW,UACrBC,EAAU7B,GAAQO,CAAI,EAGtBuB,EAAOC,GAAAA,eAAA,EACPC,EAAc,GAAQF,GAAQnB,GAC9BsB,EAAQH,GAAQnB,EAAOmB,EAAK,MAAMnB,CAAI,EAAI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GAAMX,EAAcZ,EAAGuB,CAAC,EACpC,QAAUA,GAAMT,EAAYd,EAAGuB,CAAC,EAChC,QAAUA,GAAMA,EAAE,OAAO,OAAA,CAAO,EAjB3BvB,CAAA,CAmBR,CAAA,CAAA,EAGFP,GAAsB,MACrB0B,EAAAA,IAACC,EAAAA,WAAA,CACC,GAAG,OACH,GAAIzC,EACJ,QAAQ,YACR,MAAOa,EAAgB,QAAU,QACjC,UAAW0B,EAAAA,YAAY,OAEtB,SAAAzB,CAAA,CAAA,CACH,CAAA,CAAA,CAIR,CAAC"}
@@ -2,9 +2,9 @@ import { jsxs as R, jsx as _ } from "react/jsx-runtime";
2
2
  import { forwardRef as ee, useId as te, useState as re, useRef as se, useEffect as oe } from "react";
3
3
  import { clsx as T } from "clsx";
4
4
  import { u as ae } from "./formContext-B7ln1Miy.js";
5
- import { T as z } from "./Typography-CJv5AnRP.js";
5
+ import { T as z } from "./Typography-ChSuxgkc.js";
6
6
  import { f as d } from "./TextField.module-6gYcR9TL.js";
7
- import { a as le } from "./ConfigProvider-tvLbKiqu.js";
7
+ import { a as le } from "./ConfigProvider-DZMtq2Fz.js";
8
8
  const ce = "_row_1bbms_2", ne = "_center_1bbms_14", ie = "_end_1bbms_15", fe = "_sm_1bbms_27", de = "_md_1bbms_31", me = "_lg_1bbms_35", ue = "_box_1bbms_41", pe = "_filled_1bbms_65", be = "_invalid_1bbms_82", m = {
9
9
  row: ce,
10
10
  center: ne,
@@ -171,4 +171,4 @@ const Be = ee(function({
171
171
  export {
172
172
  Be as O
173
173
  };
174
- //# sourceMappingURL=OtpField-DjTJH4Kh.js.map
174
+ //# sourceMappingURL=OtpField-v2RuXdsE.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OtpField-DjTJH4Kh.js","sources":["../src/components/OtpField/OtpField.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useId,\n useRef,\n useState,\n type ClipboardEvent,\n type CSSProperties,\n type FocusEvent,\n type KeyboardEvent,\n type ReactNode,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useFormContext } from '../../form/formContext'\nimport { useT, type ThemeColor } from '../../theme'\nimport { Typography } from '../Typography'\nimport fieldStyles from '../TextField/TextField.module.css'\nimport styles from './OtpField.module.css'\n\nexport type OtpFieldSize = 'sm' | 'md' | 'lg'\n/** Which characters the code accepts. */\nexport type OtpFieldType = 'numeric' | 'alphabetic' | 'alphanumeric'\n\nexport type OtpFieldAlign = 'start' | 'center' | 'end'\n\n/** Allowed-character matcher per `type`. */\nconst PATTERN: Record<OtpFieldType, RegExp> = {\n numeric: /[0-9]/,\n alphabetic: /[A-Za-z]/,\n alphanumeric: /[A-Za-z0-9]/,\n}\n\n/** Split a code string into exactly `length` single-char slots, padded with empties. */\nfunction toChars(value: string, length: number): string[] {\n const out = [...value].slice(0, length)\n while (out.length < length) out.push('')\n return out\n}\n\nexport interface OtpFieldProps {\n /** Number of input boxes (the code length). Defaults to `4`. */\n length?: number\n /** Which characters are accepted (also drives the mobile keyboard). Defaults to `'numeric'`. */\n type?: OtpFieldType\n /** Controlled value — the concatenated code string. */\n value?: string\n /** Initial value for uncontrolled use. */\n defaultValue?: string\n /** Fires with the full code string on every change. */\n onChange?: (value: string) => void\n /** Fires with the code once every box is filled. */\n onComplete?: (value: string) => void\n /** Field name — the `<Form>` binding key (form value is the code `string`). */\n name?: string\n /** Label rendered above the boxes. */\n label?: ReactNode\n /** Helper / error text under the boxes (shown in the error color while `error`). */\n helperText?: ReactNode\n /** Marks the field invalid — reddens the boxes + helper. */\n error?: boolean\n /** Adds a red asterisk after the label. */\n required?: boolean\n /** Disables every box. */\n disabled?: boolean\n /** Focus the first box on mount. */\n autoFocus?: boolean\n /** Placeholder character shown in empty boxes (e.g. `'•'`). */\n placeholder?: string\n /** Preset size. Defaults to `'md'`. */\n size?: OtpFieldSize\n /** Horizontal alignment of the boxes within the field. Defaults to `'start'` (left). */\n align?: OtpFieldAlign\n /** Theme palette token for the focus ring / active box. Defaults to `'primary'`. */\n color?: ThemeColor\n className?: string\n style?: CSSProperties\n}\n\n/**\n * A one-time-passcode input — a row of single-character boxes for verification codes. **`length`**\n * (default `4`) sets the box count; **`type`** (`'numeric'` default · `'alphabetic'` · `'alphanumeric'`)\n * restricts the accepted characters and the mobile keyboard. Typing advances to the next box, Backspace\n * clears + steps back, Arrows navigate, and **paste / SMS autofill** (`autocomplete=\"one-time-code\"`)\n * distributes the whole code across the boxes. The value is the concatenated string — controlled\n * (`value` + `onChange`) or uncontrolled (`defaultValue`); **`onComplete`** fires when all boxes are\n * filled. Shares the field-family chrome (`label` · `error` + `helperText` · `required` · `disabled` ·\n * `size`) and binds to a surrounding `<Form>` by **`name`** (form value = the code string; validate with\n * e.g. `z.string().length(4)` or a `type`-matching regex). Tinted by `color` via the shared\n * `--tz-btn-rgb` pattern; `role=\"group\"` with per-box `aria-label`s. Own CSS module (+ TextField's for\n * the label/helper chrome).\n */\nexport const OtpField = forwardRef<HTMLDivElement, OtpFieldProps>(function OtpField(\n {\n length = 4,\n type = 'numeric',\n value,\n defaultValue,\n onChange,\n onComplete,\n name,\n label,\n helperText,\n error,\n required = false,\n disabled = false,\n autoFocus = false,\n placeholder,\n size = 'md',\n align = 'start',\n color = 'primary',\n className,\n style,\n },\n ref,\n) {\n const t = useT()\n const reactId = useId()\n const helperId = `${reactId}-helper`\n const allowed = PATTERN[type]\n\n // bind to a surrounding <Form> by `name` — form value is the code string; error/touched via field()\n const form = useFormContext()\n const isFormBound = Boolean(form && name)\n const bound = form && name ? form.field(name) : undefined\n\n const externalValue =\n value !== undefined ? value : isFormBound ? (form!.values[name!] as string) : undefined\n const isControlled = value !== undefined || isFormBound\n const [internal, setInternal] = useState<string>(defaultValue ?? '')\n const currentValue = isControlled ? (externalValue ?? '') : internal\n\n const resolvedError = error ?? bound?.error ?? false\n const resolvedHelperText = helperText ?? bound?.helperText\n\n // the code split into exactly `length` single-char slots (padded with empties)\n const chars = toChars(currentValue, length)\n\n const inputsRef = useRef<(HTMLInputElement | null)[]>([])\n\n useEffect(() => {\n if (autoFocus) inputsRef.current[0]?.focus()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n const focusBox = (i: number) => {\n const el = inputsRef.current[Math.max(0, Math.min(i, length - 1))]\n el?.focus()\n el?.select()\n }\n\n const commit = (nextChars: string[]) => {\n const next = nextChars.join('')\n if (!isControlled) setInternal(next)\n if (isFormBound) form!.setValue(name!, next)\n onChange?.(next)\n if (nextChars.every((c) => c !== '')) onComplete?.(next)\n }\n\n const handleChange = (index: number, raw: string) => {\n const filtered = [...raw].filter((c) => allowed.test(c))\n // a disallowed keystroke (raw non-empty but nothing survives the filter) is ignored\n if (raw !== '' && filtered.length === 0) return\n const nextChars = [...chars]\n if (filtered.length <= 1) {\n // a single typed char (boxes select-on-focus, so this replaces) — or a clear ('')\n nextChars[index] = filtered[0] ?? ''\n commit(nextChars)\n if (filtered[0]) focusBox(index + 1)\n } else {\n // multiple chars (SMS autofill dumps the whole code into one box) → distribute from here\n let k = index\n for (const ch of filtered) {\n if (k >= length) break\n nextChars[k] = ch\n k++\n }\n commit(nextChars)\n focusBox(k)\n }\n }\n\n const handleKeyDown = (index: number, event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Backspace') {\n if (chars[index] === '' && index > 0) {\n // empty box → step back and clear the previous one\n event.preventDefault()\n const nextChars = [...chars]\n nextChars[index - 1] = ''\n commit(nextChars)\n focusBox(index - 1)\n }\n // a non-empty box lets the native delete run → onChange fires with '' (stays put)\n } else if (event.key === 'ArrowLeft') {\n event.preventDefault()\n focusBox(index - 1)\n } else if (event.key === 'ArrowRight') {\n event.preventDefault()\n focusBox(index + 1)\n } else if (event.key === 'Delete') {\n event.preventDefault()\n const nextChars = [...chars]\n nextChars[index] = ''\n commit(nextChars)\n }\n }\n\n const handlePaste = (index: number, event: ClipboardEvent<HTMLInputElement>) => {\n event.preventDefault()\n const filtered = [...event.clipboardData.getData('text')].filter((c) => allowed.test(c))\n if (filtered.length === 0) return\n const nextChars = [...chars]\n let k = index\n for (const ch of filtered) {\n if (k >= length) break\n nextChars[k] = ch\n k++\n }\n commit(nextChars)\n focusBox(k)\n }\n\n // mark the field touched when focus leaves the whole widget (not when it hops between boxes)\n const handleBlur = (event: FocusEvent<HTMLDivElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) {\n bound?.onBlur(event as unknown as FocusEvent<HTMLInputElement>)\n }\n }\n\n return (\n <div\n ref={ref}\n className={clsx(\n fieldStyles.field,\n resolvedError && fieldStyles.error,\n disabled && fieldStyles.disabled,\n className,\n )}\n style={\n {\n '--tz-btn-rgb': `var(--tz-color-${color}-rgb)`,\n ...style,\n } as CSSProperties\n }\n >\n {label != null && (\n <span className={fieldStyles.label}>\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\">\n {label}\n </Typography>\n {required && (\n <span className={fieldStyles.required} aria-hidden=\"true\">\n *\n </span>\n )}\n </span>\n )}\n\n <div\n role=\"group\"\n aria-label={typeof label === 'string' ? label : 'One-time code'}\n aria-invalid={resolvedError || undefined}\n aria-describedby={resolvedHelperText != null ? helperId : undefined}\n className={clsx(styles.row, styles[size], styles[align], resolvedError && styles.invalid)}\n onBlur={handleBlur}\n >\n {chars.map((char, i) => (\n <input\n key={i}\n ref={(el) => {\n inputsRef.current[i] = el\n }}\n // the name goes on the first box only, so the form's scroll-to-error can target it\n name={i === 0 ? name : undefined}\n type=\"text\"\n inputMode={type === 'numeric' ? 'numeric' : 'text'}\n autoComplete={i === 0 ? 'one-time-code' : 'off'}\n aria-label={t('otpField.digit', { index: i + 1, total: length })}\n className={clsx(styles.box, char !== '' && styles.filled)}\n value={char}\n placeholder={placeholder}\n disabled={disabled}\n onChange={(e) => handleChange(i, e.target.value)}\n onKeyDown={(e) => handleKeyDown(i, e)}\n onPaste={(e) => handlePaste(i, e)}\n onFocus={(e) => e.target.select()}\n />\n ))}\n </div>\n\n {resolvedHelperText != null && (\n <Typography\n as=\"span\"\n id={helperId}\n variant=\"bodySmall\"\n color={resolvedError ? 'error' : 'muted'}\n className={fieldStyles.helper}\n >\n {resolvedHelperText}\n </Typography>\n )}\n </div>\n )\n})\n"],"names":["PATTERN","toChars","value","length","out","OtpField","forwardRef","type","defaultValue","onChange","onComplete","name","label","helperText","error","required","disabled","autoFocus","placeholder","size","align","color","className","style","ref","t","useT","helperId","useId","allowed","form","useFormContext","isFormBound","bound","externalValue","isControlled","internal","setInternal","useState","currentValue","resolvedError","resolvedHelperText","chars","inputsRef","useRef","useEffect","_a","focusBox","i","el","commit","nextChars","next","c","handleChange","index","raw","filtered","k","ch","handleKeyDown","event","handlePaste","handleBlur","jsxs","clsx","fieldStyles","jsx","Typography","styles","char","e"],"mappings":";;;;;;;;;;;;;;;;;GA0BMA,KAAwC;AAAA,EAC5C,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,cAAc;AAChB;AAGA,SAASC,GAAQC,GAAeC,GAA0B;AACxD,QAAMC,IAAM,CAAC,GAAGF,CAAK,EAAE,MAAM,GAAGC,CAAM;AACtC,SAAOC,EAAI,SAASD,IAAQ,CAAAC,EAAI,KAAK,EAAE;AACvC,SAAOA;AACT;AAsDO,MAAMC,KAAWC,GAA0C,SAChE;AAAA,EACE,QAAAH,IAAS;AAAA,EACT,MAAAI,IAAO;AAAA,EACP,OAAAL;AAAA,EACA,cAAAM;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,UAAAC,IAAW;AAAA,EACX,WAAAC,IAAY;AAAA,EACZ,aAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,OAAAC,IAAQ;AAAA,EACR,OAAAC,IAAQ;AAAA,EACR,WAAAC;AAAA,EACA,OAAAC;AACF,GACAC,GACA;AACA,QAAMC,IAAIC,GAAA,GAEJC,IAAW,GADDC,GAAA,CACW,WACrBC,IAAU7B,GAAQO,CA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AAAmB;AAAA,cAAC;AAAA,cAAA;AAAA,gBAEC,KAAK,CAAClB,MAAO;AACX,kBAAAN,EAAU,QAAQK,CAAC,IAAIC;AAAA,gBACzB;AAAA,gBAEA,MAAMD,MAAM,IAAIrC,IAAO;AAAA,gBACvB,MAAK;AAAA,gBACL,WAAWJ,MAAS,YAAY,YAAY;AAAA,gBAC5C,cAAcyC,MAAM,IAAI,kBAAkB;AAAA,gBAC1C,cAAYvB,EAAE,kBAAkB,EAAE,OAAOuB,IAAI,GAAG,OAAO7C,GAAQ;AAAA,gBAC/D,WAAW8D,EAAKI,EAAO,KAAKC,MAAS,MAAMD,EAAO,MAAM;AAAA,gBACxD,OAAOC;AAAA,gBACP,aAAApD;AAAA,gBACA,UAAAF;AAAA,gBACA,UAAU,CAACuD,MAAMjB,EAAaN,GAAGuB,EAAE,OAAO,KAAK;AAAA,gBAC/C,WAAW,CAACA,MAAMX,EAAcZ,GAAGuB,CAAC;AAAA,gBACpC,SAAS,CAACA,MAAMT,EAAYd,GAAGuB,CAAC;AAAA,gBAChC,SAAS,CAACA,MAAMA,EAAE,OAAO,OAAA;AAAA,cAAO;AAAA,cAjB3BvB;AAAA,YAAA,CAmBR;AAAA,UAAA;AAAA,QAAA;AAAA,QAGFP,KAAsB,QACrB,gBAAA0B;AAAA,UAACC;AAAA,UAAA;AAAA,YACC,IAAG;AAAA,YACH,IAAIzC;AAAA,YACJ,SAAQ;AAAA,YACR,OAAOa,IAAgB,UAAU;AAAA,YACjC,WAAW0B,EAAY;AAAA,YAEtB,UAAAzB;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
1
+ {"version":3,"file":"OtpField-v2RuXdsE.js","sources":["../src/components/OtpField/OtpField.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useId,\n useRef,\n useState,\n type ClipboardEvent,\n type CSSProperties,\n type FocusEvent,\n type KeyboardEvent,\n type ReactNode,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useFormContext } from '../../form/formContext'\nimport { useT, type ThemeColor } from '../../theme'\nimport { Typography } from '../Typography'\nimport fieldStyles from '../TextField/TextField.module.css'\nimport styles from './OtpField.module.css'\n\nexport type OtpFieldSize = 'sm' | 'md' | 'lg'\n/** Which characters the code accepts. */\nexport type OtpFieldType = 'numeric' | 'alphabetic' | 'alphanumeric'\n\nexport type OtpFieldAlign = 'start' | 'center' | 'end'\n\n/** Allowed-character matcher per `type`. */\nconst PATTERN: Record<OtpFieldType, RegExp> = {\n numeric: /[0-9]/,\n alphabetic: /[A-Za-z]/,\n alphanumeric: /[A-Za-z0-9]/,\n}\n\n/** Split a code string into exactly `length` single-char slots, padded with empties. */\nfunction toChars(value: string, length: number): string[] {\n const out = [...value].slice(0, length)\n while (out.length < length) out.push('')\n return out\n}\n\nexport interface OtpFieldProps {\n /** Number of input boxes (the code length). Defaults to `4`. */\n length?: number\n /** Which characters are accepted (also drives the mobile keyboard). Defaults to `'numeric'`. */\n type?: OtpFieldType\n /** Controlled value — the concatenated code string. */\n value?: string\n /** Initial value for uncontrolled use. */\n defaultValue?: string\n /** Fires with the full code string on every change. */\n onChange?: (value: string) => void\n /** Fires with the code once every box is filled. */\n onComplete?: (value: string) => void\n /** Field name — the `<Form>` binding key (form value is the code `string`). */\n name?: string\n /** Label rendered above the boxes. */\n label?: ReactNode\n /** Helper / error text under the boxes (shown in the error color while `error`). */\n helperText?: ReactNode\n /** Marks the field invalid — reddens the boxes + helper. */\n error?: boolean\n /** Adds a red asterisk after the label. */\n required?: boolean\n /** Disables every box. */\n disabled?: boolean\n /** Focus the first box on mount. */\n autoFocus?: boolean\n /** Placeholder character shown in empty boxes (e.g. `'•'`). */\n placeholder?: string\n /** Preset size. Defaults to `'md'`. */\n size?: OtpFieldSize\n /** Horizontal alignment of the boxes within the field. Defaults to `'start'` (left). */\n align?: OtpFieldAlign\n /** Theme palette token for the focus ring / active box. Defaults to `'primary'`. */\n color?: ThemeColor\n className?: string\n style?: CSSProperties\n}\n\n/**\n * A one-time-passcode input — a row of single-character boxes for verification codes. **`length`**\n * (default `4`) sets the box count; **`type`** (`'numeric'` default · `'alphabetic'` · `'alphanumeric'`)\n * restricts the accepted characters and the mobile keyboard. Typing advances to the next box, Backspace\n * clears + steps back, Arrows navigate, and **paste / SMS autofill** (`autocomplete=\"one-time-code\"`)\n * distributes the whole code across the boxes. The value is the concatenated string — controlled\n * (`value` + `onChange`) or uncontrolled (`defaultValue`); **`onComplete`** fires when all boxes are\n * filled. Shares the field-family chrome (`label` · `error` + `helperText` · `required` · `disabled` ·\n * `size`) and binds to a surrounding `<Form>` by **`name`** (form value = the code string; validate with\n * e.g. `z.string().length(4)` or a `type`-matching regex). Tinted by `color` via the shared\n * `--tz-btn-rgb` pattern; `role=\"group\"` with per-box `aria-label`s. Own CSS module (+ TextField's for\n * the label/helper chrome).\n */\nexport const OtpField = forwardRef<HTMLDivElement, OtpFieldProps>(function OtpField(\n {\n length = 4,\n type = 'numeric',\n value,\n defaultValue,\n onChange,\n onComplete,\n name,\n label,\n helperText,\n error,\n required = false,\n disabled = false,\n autoFocus = false,\n placeholder,\n size = 'md',\n align = 'start',\n color = 'primary',\n className,\n style,\n },\n ref,\n) {\n const t = useT()\n const reactId = useId()\n const helperId = `${reactId}-helper`\n const allowed = PATTERN[type]\n\n // bind to a surrounding <Form> by `name` — form value is the code string; error/touched via field()\n const form = useFormContext()\n const isFormBound = Boolean(form && name)\n const bound = form && name ? form.field(name) : undefined\n\n const externalValue =\n value !== undefined ? value : isFormBound ? (form!.values[name!] as string) : undefined\n const isControlled = value !== undefined || isFormBound\n const [internal, setInternal] = useState<string>(defaultValue ?? '')\n const currentValue = isControlled ? (externalValue ?? '') : internal\n\n const resolvedError = error ?? bound?.error ?? false\n const resolvedHelperText = helperText ?? bound?.helperText\n\n // the code split into exactly `length` single-char slots (padded with empties)\n const chars = toChars(currentValue, length)\n\n const inputsRef = useRef<(HTMLInputElement | null)[]>([])\n\n useEffect(() => {\n if (autoFocus) inputsRef.current[0]?.focus()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n const focusBox = (i: number) => {\n const el = inputsRef.current[Math.max(0, Math.min(i, length - 1))]\n el?.focus()\n el?.select()\n }\n\n const commit = (nextChars: string[]) => {\n const next = nextChars.join('')\n if (!isControlled) setInternal(next)\n if (isFormBound) form!.setValue(name!, next)\n onChange?.(next)\n if (nextChars.every((c) => c !== '')) onComplete?.(next)\n }\n\n const handleChange = (index: number, raw: string) => {\n const filtered = [...raw].filter((c) => allowed.test(c))\n // a disallowed keystroke (raw non-empty but nothing survives the filter) is ignored\n if (raw !== '' && filtered.length === 0) return\n const nextChars = [...chars]\n if (filtered.length <= 1) {\n // a single typed char (boxes select-on-focus, so this replaces) — or a clear ('')\n nextChars[index] = filtered[0] ?? ''\n commit(nextChars)\n if (filtered[0]) focusBox(index + 1)\n } else {\n // multiple chars (SMS autofill dumps the whole code into one box) → distribute from here\n let k = index\n for (const ch of filtered) {\n if (k >= length) break\n nextChars[k] = ch\n k++\n }\n commit(nextChars)\n focusBox(k)\n }\n }\n\n const handleKeyDown = (index: number, event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Backspace') {\n if (chars[index] === '' && index > 0) {\n // empty box → step back and clear the previous one\n event.preventDefault()\n const nextChars = [...chars]\n nextChars[index - 1] = ''\n commit(nextChars)\n focusBox(index - 1)\n }\n // a non-empty box lets the native delete run → onChange fires with '' (stays put)\n } else if (event.key === 'ArrowLeft') {\n event.preventDefault()\n focusBox(index - 1)\n } else if (event.key === 'ArrowRight') {\n event.preventDefault()\n focusBox(index + 1)\n } else if (event.key === 'Delete') {\n event.preventDefault()\n const nextChars = [...chars]\n nextChars[index] = ''\n commit(nextChars)\n }\n }\n\n const handlePaste = (index: number, event: ClipboardEvent<HTMLInputElement>) => {\n event.preventDefault()\n const filtered = [...event.clipboardData.getData('text')].filter((c) => allowed.test(c))\n if (filtered.length === 0) return\n const nextChars = [...chars]\n let k = index\n for (const ch of filtered) {\n if (k >= length) break\n nextChars[k] = ch\n k++\n }\n commit(nextChars)\n focusBox(k)\n }\n\n // mark the field touched when focus leaves the whole widget (not when it hops between boxes)\n const handleBlur = (event: FocusEvent<HTMLDivElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) {\n bound?.onBlur(event as unknown as FocusEvent<HTMLInputElement>)\n }\n }\n\n return (\n <div\n ref={ref}\n className={clsx(\n fieldStyles.field,\n resolvedError && fieldStyles.error,\n disabled && fieldStyles.disabled,\n className,\n )}\n style={\n {\n '--tz-btn-rgb': `var(--tz-color-${color}-rgb)`,\n ...style,\n } as CSSProperties\n }\n >\n {label != null && (\n <span className={fieldStyles.label}>\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\">\n {label}\n </Typography>\n {required && (\n <span className={fieldStyles.required} aria-hidden=\"true\">\n *\n </span>\n )}\n </span>\n )}\n\n <div\n role=\"group\"\n aria-label={typeof label === 'string' ? label : 'One-time code'}\n aria-invalid={resolvedError || undefined}\n aria-describedby={resolvedHelperText != null ? helperId : undefined}\n className={clsx(styles.row, styles[size], styles[align], resolvedError && styles.invalid)}\n onBlur={handleBlur}\n >\n {chars.map((char, i) => (\n <input\n key={i}\n ref={(el) => {\n inputsRef.current[i] = el\n }}\n // the name goes on the first box only, so the form's scroll-to-error can target it\n name={i === 0 ? name : undefined}\n type=\"text\"\n inputMode={type === 'numeric' ? 'numeric' : 'text'}\n autoComplete={i === 0 ? 'one-time-code' : 'off'}\n aria-label={t('otpField.digit', { index: i + 1, total: length })}\n className={clsx(styles.box, char !== '' && styles.filled)}\n value={char}\n placeholder={placeholder}\n disabled={disabled}\n onChange={(e) => handleChange(i, e.target.value)}\n onKeyDown={(e) => handleKeyDown(i, e)}\n onPaste={(e) => handlePaste(i, e)}\n onFocus={(e) => e.target.select()}\n />\n ))}\n </div>\n\n {resolvedHelperText != null && (\n <Typography\n as=\"span\"\n id={helperId}\n variant=\"bodySmall\"\n color={resolvedError ? 'error' : 'muted'}\n className={fieldStyles.helper}\n >\n {resolvedHelperText}\n </Typography>\n )}\n </div>\n )\n})\n"],"names":["PATTERN","toChars","value","length","out","OtpField","forwardRef","type","defaultValue","onChange","onComplete","name","label","helperText","error","required","disabled","autoFocus","placeholder","size","align","color","className","style","ref","t","useT","helperId","useId","allowed","form","useFormContext","isFormBound","bound","externalValue","isControlled","internal","setInternal","useState","currentValue","resolvedError","resolvedHelperText","chars","inputsRef","useRef","useEffect","_a","focusBox","i","el","commit","nextChars","next","c","handleChange","index","raw","filtered","k","ch","handleKeyDown","event","handlePaste","handleBlur","jsxs","clsx","fieldStyles","jsx","Typography","styles","char","e"],"mappings":";;;;;;;;;;;;;;;;;GA0BMA,KAAwC;AAAA,EAC5C,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,cAAc;AAChB;AAGA,SAASC,GAAQC,GAAeC,GAA0B;AACxD,QAAMC,IAAM,CAAC,GAAGF,CAAK,EAAE,MAAM,GAAGC,CAAM;AACtC,SAAOC,EAAI,SAASD,IAAQ,CAAAC,EAAI,KAAK,EAAE;AACvC,SAAOA;AACT;AAsDO,MAAMC,KAAWC,GAA0C,SAChE;AAAA,EACE,QAAAH,IAAS;AAAA,EACT,MAAAI,IAAO;AAAA,EACP,OAAAL;AAAA,EACA,cAAAM;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,UAAAC,IAAW;AAAA,EACX,WAAAC,IAAY;AAAA,EACZ,aAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,OAAAC,IAAQ;AAAA,EACR,OAAAC,IAAQ;AAAA,EACR,WAAAC;AAAA,EACA,OAAAC;AACF,GACAC,GACA;AACA,QAAMC,IAAIC,GAAA,GAEJC,IAAW,GADDC,GAAA,CACW,WACrBC,IAAU7B,GAAQO,CAAI,GAGtBuB,IAAOC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AAAA,cAAA;AAAA,gBAEC,KAAK,CAAClB,MAAO;AACX,kBAAAN,EAAU,QAAQK,CAAC,IAAIC;AAAA,gBACzB;AAAA,gBAEA,MAAMD,MAAM,IAAIrC,IAAO;AAAA,gBACvB,MAAK;AAAA,gBACL,WAAWJ,MAAS,YAAY,YAAY;AAAA,gBAC5C,cAAcyC,MAAM,IAAI,kBAAkB;AAAA,gBAC1C,cAAYvB,EAAE,kBAAkB,EAAE,OAAOuB,IAAI,GAAG,OAAO7C,GAAQ;AAAA,gBAC/D,WAAW8D,EAAKI,EAAO,KAAKC,MAAS,MAAMD,EAAO,MAAM;AAAA,gBACxD,OAAOC;AAAA,gBACP,aAAApD;AAAA,gBACA,UAAAF;AAAA,gBACA,UAAU,CAACuD,MAAMjB,EAAaN,GAAGuB,EAAE,OAAO,KAAK;AAAA,gBAC/C,WAAW,CAACA,MAAMX,EAAcZ,GAAGuB,CAAC;AAAA,gBACpC,SAAS,CAACA,MAAMT,EAAYd,GAAGuB,CAAC;AAAA,gBAChC,SAAS,CAACA,MAAMA,EAAE,OAAO,OAAA;AAAA,cAAO;AAAA,cAjB3BvB;AAAA,YAAA,CAmBR;AAAA,UAAA;AAAA,QAAA;AAAA,QAGFP,KAAsB,QACrB,gBAAA0B;AAAA,UAACC;AAAA,UAAA;AAAA,YACC,IAAG;AAAA,YACH,IAAIzC;AAAA,YACJ,SAAQ;AAAA,YACR,OAAOa,IAAgB,UAAU;AAAA,YACjC,WAAW0B,EAAY;AAAA,YAEtB,UAAAzB;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
@@ -0,0 +1,2 @@
1
+ "use strict";const d=require("react/jsx-runtime"),t=require("react"),k=require("./Button-Cm64ROip.cjs"),B=require("./ErrorState-DRXuV6na.cjs"),s=require("./errorMessage-C7N4KvUS.cjs"),C=require("./useHomeTo-Dnu6VAvU.cjs"),D=require("./ConfigProvider-th4GYhcU.cjs"),H=t.forwardRef(function({error:r,reset:o,info:w,onRetry:n,showMessage:i,showHome:v=!0,title:g,description:E,icon:m,size:p,pattern:q,showDetails:P,...S},x){const c=D.useT(),{router:e,homeTo:a}=C.useHomeTo(),[y,f]=t.useState(!1),u=t.useRef(!0);t.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]);const l=t.useRef(void 0);t.useEffect(()=>{l.current!==r&&(l.current=r,console.error("[PageError]",r))},[r]);const T=typeof i=="function"?i(r):i==="dev"?s.isDev():i??(s.isServerError(r)||s.isDev()),j=async()=>{f(!0);try{await(n==null?void 0:n()),o==null||o(),await(e==null?void 0:e.invalidate())}finally{u.current&&f(!1)}},h=v&&e&&a!=null?d.jsx(k.Button,{size:"sm",variant:"text",color:"primary",onClick:()=>e.navigate({to:a}),children:c("pageError.home")}):void 0;return d.jsx(B.ErrorState,{ref:x,variant:"block",error:r,title:g??c("pageError.title"),description:E??(T?void 0:c("pageError.description")),icon:m,size:p,pattern:q,showDetails:P,onRetry:o||n||e?()=>void j():void 0,retrying:y,action:h,...S})});exports.PageError=H;
2
+ //# sourceMappingURL=PageError-CIVYNLTW.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PageError-D7_Q8wz8.cjs","sources":["../src/components/PageError/PageError.tsx"],"sourcesContent":["import { forwardRef, useEffect, useRef, useState, type HTMLAttributes, type ReactNode } from 'react'\nimport { type LinkProps } from '@tanstack/react-router'\nimport { useT } from '../../theme'\nimport type { IconName } from '../../icons/names'\nimport { Button } from '../Button'\nimport type { EmptyStateSize } from '../EmptyState'\nimport { ErrorState } from '../ErrorState/ErrorState'\nimport { isDev, isServerError } from '../ErrorState/errorMessage'\nimport { useHomeTo } from '../PageNotFound/useHomeTo'\n\nexport interface PageErrorProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'color'> {\n /** What the route threw (TanStack Router's `ErrorComponentProps.error`). */\n error: unknown\n /** Resets the route's error boundary (TanStack Router's `ErrorComponentProps.reset`). */\n reset?: () => void\n /** The React component stack (TanStack Router's `ErrorComponentProps.info`) — unused, accepted for typing. */\n info?: { componentStack: string }\n /**\n * Runs **before** the reset on \"Try Again\" (may be async) — where an app drops cached data, e.g.\n * `() => queryClient.resetQueries({ predicate: (q) => q.queryKey[0] !== 'session' })`. Without it, `reset()`\n * re-renders against the same cached response and throws on the same data again.\n */\n onRetry?: () => void | Promise<void>\n /**\n * Show the error's own message. Default: when it looks **server-originated** (a `traceId` or a numeric\n * `status` — written for people) or in development; otherwise the localized generic sentence (a render\n * crash's message is a developer's). `true` / `false` force it; `'dev'` = development only; a function decides\n * per error.\n */\n showMessage?: boolean | 'dev' | ((error: unknown) => boolean)\n /** A secondary \"Go to Home\" button to the first allowed menu page (RBAC-aware). Defaults to `true`. */\n showHome?: boolean\n /** Heading. Defaults to the localized \"This Page Could Not Be Shown\". */\n title?: ReactNode\n /** Overrides the description (the message / the generic sentence). */\n description?: ReactNode\n /** Leading icon — passed to `ErrorState` (`Danger` / `CloudCross` by default; `false` hides it). */\n icon?: IconName | ReactNode | false\n /** Size — passed to `ErrorState`. Defaults to `md`. */\n size?: EmptyStateSize\n /** Faded-grid hero backdrop — passed to `ErrorState`. Defaults to `true`. */\n pattern?: boolean\n /** The developer details panel (stack) — passed to `ErrorState`. Defaults to `'dev'`. */\n showDetails?: boolean | 'dev'\n}\n\n/**\n * The shared **route error page** — the twin of `PageNotFound`. Drop it into TanStack Router as the\n * `defaultErrorComponent`: TanStack wraps every route in its own error boundary (inside the shell's `<Outlet/>`),\n * so without it a crashing page shows the router's bare \"Something went wrong!\". Renders the full `ErrorState`\n * hero inside the shell with **Try Again** (`await onRetry?.()` → `reset()` → `router.invalidate()`, which re-runs\n * a throwing loader / `beforeLoad`), a **Go to Home** button, the server's `traceId`, and the error's message only\n * when it was written for people (`showMessage`). Every error is `console.error`ed once — in production the\n * screen hides the message, so the console is the record.\n *\n * @example\n * createRouter({ routeTree, defaultNotFoundComponent: PageNotFound, defaultErrorComponent: PageError })\n */\nexport const PageError = forwardRef<HTMLDivElement, PageErrorProps>(function PageError(\n {\n error,\n reset,\n info: _info,\n onRetry,\n showMessage,\n showHome = true,\n title,\n description,\n icon,\n size,\n pattern,\n showDetails,\n ...props\n },\n ref,\n) {\n const t = useT()\n const { router, homeTo } = useHomeTo()\n const [retrying, setRetrying] = useState(false)\n const mounted = useRef(true)\n useEffect(() => {\n mounted.current = true\n return () => {\n mounted.current = false\n }\n }, [])\n\n // log each distinct error once (StrictMode re-runs effects; a re-render with the same error isn't new)\n const logged = useRef<unknown>(undefined)\n useEffect(() => {\n if (logged.current === error) return\n logged.current = error\n console.error('[PageError]', error)\n }, [error])\n\n const messageShown =\n typeof showMessage === 'function'\n ? showMessage(error)\n : showMessage === 'dev'\n ? isDev()\n : (showMessage ?? (isServerError(error) || isDev()))\n\n const retry = async () => {\n setRetrying(true)\n try {\n await onRetry?.()\n reset?.()\n await router?.invalidate()\n } finally {\n if (mounted.current) setRetrying(false)\n }\n }\n\n const home =\n showHome && router && homeTo != null ? (\n <Button\n size=\"sm\"\n variant=\"text\"\n color=\"primary\"\n onClick={() => router.navigate({ to: homeTo as LinkProps['to'] })}\n >\n {t('pageError.home')}\n </Button>\n ) : undefined\n\n return (\n <ErrorState\n ref={ref}\n error={error}\n title={title ?? t('pageError.title')}\n // hidden message → the generic sentence (the trace id still shows: it's for support, not a leak)\n description={description ?? (messageShown ? undefined : t('pageError.description'))}\n icon={icon}\n size={size}\n pattern={pattern}\n showDetails={showDetails}\n onRetry={reset || onRetry || router ? () => void retry() : undefined}\n retrying={retrying}\n action={home}\n {...props}\n />\n )\n})\n"],"names":["PageError","forwardRef","error","reset","_info","onRetry","showMessage","showHome","title","description","icon","size","pattern","showDetails","props","ref","t","useT","router","homeTo","useHomeTo","retrying","setRetrying","useState","mounted","useRef","useEffect","logged","messageShown","isDev","isServerError","retry","home","jsx","Button","ErrorState"],"mappings":"yQA0DaA,EAAYC,EAAAA,WAA2C,SAClE,CACE,MAAAC,EACA,MAAAC,EACA,KAAMC,EACN,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AE,uBAAuB,GACjF,KAAAN,EACA,KAAAC,EACA,QAAAC,EACA,YAAAC,EACA,QAASV,GAASE,GAAWa,EAAS,IAAM,KAAKa,IAAU,OAC3D,SAAAV,EACA,OAAQW,EACP,GAAGlB,CAAA,CAAA,CAGV,CAAC"}
1
+ {"version":3,"file":"PageError-CIVYNLTW.cjs","sources":["../src/components/PageError/PageError.tsx"],"sourcesContent":["import { forwardRef, useEffect, useRef, useState, type HTMLAttributes, type ReactNode } from 'react'\nimport { type LinkProps } from '@tanstack/react-router'\nimport { useT } from '../../theme'\nimport type { IconName } from '../../icons/names'\nimport { Button } from '../Button'\nimport type { EmptyStateSize } from '../EmptyState'\nimport { ErrorState } from '../ErrorState/ErrorState'\nimport { isDev, isServerError } from '../ErrorState/errorMessage'\nimport { useHomeTo } from '../PageNotFound/useHomeTo'\n\nexport interface PageErrorProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'color'> {\n /** What the route threw (TanStack Router's `ErrorComponentProps.error`). */\n error: unknown\n /** Resets the route's error boundary (TanStack Router's `ErrorComponentProps.reset`). */\n reset?: () => void\n /** The React component stack (TanStack Router's `ErrorComponentProps.info`) — unused, accepted for typing. */\n info?: { componentStack: string }\n /**\n * Runs **before** the reset on \"Try Again\" (may be async) — where an app drops cached data, e.g.\n * `() => queryClient.resetQueries({ predicate: (q) => q.queryKey[0] !== 'session' })`. Without it, `reset()`\n * re-renders against the same cached response and throws on the same data again.\n */\n onRetry?: () => void | Promise<void>\n /**\n * Show the error's own message. Default: when it looks **server-originated** (a `traceId` or a numeric\n * `status` — written for people) or in development; otherwise the localized generic sentence (a render\n * crash's message is a developer's). `true` / `false` force it; `'dev'` = development only; a function decides\n * per error.\n */\n showMessage?: boolean | 'dev' | ((error: unknown) => boolean)\n /** A secondary \"Go to Home\" button to the first allowed menu page (RBAC-aware). Defaults to `true`. */\n showHome?: boolean\n /** Heading. Defaults to the localized \"This Page Could Not Be Shown\". */\n title?: ReactNode\n /** Overrides the description (the message / the generic sentence). */\n description?: ReactNode\n /** Leading icon — passed to `ErrorState` (`Danger` / `CloudCross` by default; `false` hides it). */\n icon?: IconName | ReactNode | false\n /** Size — passed to `ErrorState`. Defaults to `md`. */\n size?: EmptyStateSize\n /** Faded-grid hero backdrop — passed to `ErrorState`. Defaults to `true`. */\n pattern?: boolean\n /** The developer details panel (stack) — passed to `ErrorState`. Defaults to `'dev'`. */\n showDetails?: boolean | 'dev'\n}\n\n/**\n * The shared **route error page** — the twin of `PageNotFound`. Drop it into TanStack Router as the\n * `defaultErrorComponent`: TanStack wraps every route in its own error boundary (inside the shell's `<Outlet/>`),\n * so without it a crashing page shows the router's bare \"Something went wrong!\". Renders the full `ErrorState`\n * hero inside the shell with **Try Again** (`await onRetry?.()` → `reset()` → `router.invalidate()`, which re-runs\n * a throwing loader / `beforeLoad`), a **Go to Home** button, the server's `traceId`, and the error's message only\n * when it was written for people (`showMessage`). Every error is `console.error`ed once — in production the\n * screen hides the message, so the console is the record.\n *\n * @example\n * createRouter({ routeTree, defaultNotFoundComponent: PageNotFound, defaultErrorComponent: PageError })\n */\nexport const PageError = forwardRef<HTMLDivElement, PageErrorProps>(function PageError(\n {\n error,\n reset,\n info: _info,\n onRetry,\n showMessage,\n showHome = true,\n title,\n description,\n icon,\n size,\n pattern,\n showDetails,\n ...props\n },\n ref,\n) {\n const t = useT()\n const { router, homeTo } = useHomeTo()\n const [retrying, setRetrying] = useState(false)\n const mounted = useRef(true)\n useEffect(() => {\n mounted.current = true\n return () => {\n mounted.current = false\n }\n }, [])\n\n // log each distinct error once (StrictMode re-runs effects; a re-render with the same error isn't new)\n const logged = useRef<unknown>(undefined)\n useEffect(() => {\n if (logged.current === error) return\n logged.current = error\n console.error('[PageError]', error)\n }, [error])\n\n const messageShown =\n typeof showMessage === 'function'\n ? showMessage(error)\n : showMessage === 'dev'\n ? isDev()\n : (showMessage ?? (isServerError(error) || isDev()))\n\n const retry = async () => {\n setRetrying(true)\n try {\n await onRetry?.()\n reset?.()\n await router?.invalidate()\n } finally {\n if (mounted.current) setRetrying(false)\n }\n }\n\n const home =\n showHome && router && homeTo != null ? (\n <Button\n size=\"sm\"\n variant=\"text\"\n color=\"primary\"\n onClick={() => router.navigate({ to: homeTo as LinkProps['to'] })}\n >\n {t('pageError.home')}\n </Button>\n ) : undefined\n\n return (\n <ErrorState\n ref={ref}\n variant=\"block\"\n error={error}\n title={title ?? t('pageError.title')}\n // hidden message → the generic sentence (the trace id still shows: it's for support, not a leak)\n description={description ?? (messageShown ? undefined : t('pageError.description'))}\n icon={icon}\n size={size}\n pattern={pattern}\n showDetails={showDetails}\n onRetry={reset || onRetry || router ? () => void retry() : undefined}\n retrying={retrying}\n action={home}\n {...props}\n />\n )\n})\n"],"names":["PageError","forwardRef","error","reset","_info","onRetry","showMessage","showHome","title","description","icon","size","pattern","showDetails","props","ref","t","useT","router","homeTo","useHomeTo","retrying","setRetrying","useState","mounted","useRef","useEffect","logged","messageShown","isDev","isServerError","retry","home","jsx","Button","ErrorState"],"mappings":"yQA0DaA,EAAYC,EAAAA,WAA2C,SAClE,CACE,MAAAC,EACA,MAAAC,EACA,KAAMC,EACN,QAAAC,EACA,YAAAC,EACA,SAAAC,EAAW,GACX,MAAAC,EACA,YAAAC,EACA,KAAAC,EACA,KAAAC,EACA,QAAAC,EACA,YAAAC,EACA,GAAGC,CACL,EACAC,EACA,CACA,MAAMC,EAAIC,EAAAA,KAAA,EACJ,CAAE,OAAAC,EAAQ,OAAAC,CAAA,EAAWC,YAAA,EACrB,CAACC,EAAUC,CAAW,EAAIC,EAAAA,SAAS,EAAK,EACxCC,EAAUC,EAAAA,OAAO,EAAI,EAC3BC,EAAAA,UAAU,KACRF,EAAQ,QAAU,GACX,IAAM,CACXA,EAAQ,QAAU,EACpB,GACC,CAAA,CAAE,EAGL,MAAMG,EAASF,EAAAA,OAAgB,MAAS,EACxCC,EAAAA,UAAU,IAAM,CACVC,EAAO,UAAYzB,IACvByB,EAAO,QAAUzB,EACjB,QAAQ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