@timeax/form-palette 0.0.3 → 0.0.4

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 (503) hide show
  1. package/dist/adapters/axios.d.ts +21 -0
  2. package/dist/adapters/axios.d.ts.map +1 -0
  3. package/dist/adapters/axios.js +74 -0
  4. package/dist/adapters/axios.js.map +1 -0
  5. package/dist/adapters/index.d.ts +35 -0
  6. package/dist/adapters/index.d.ts.map +1 -0
  7. package/dist/adapters/index.js +74 -0
  8. package/dist/adapters/index.js.map +1 -0
  9. package/dist/adapters/inertia.d.ts +24 -0
  10. package/dist/adapters/inertia.d.ts.map +1 -0
  11. package/dist/adapters/inertia.js +126 -0
  12. package/dist/adapters/inertia.js.map +1 -0
  13. package/dist/core/adapter-registry.d.ts +30 -0
  14. package/dist/core/adapter-registry.d.ts.map +1 -0
  15. package/{src/core/adapter-registry.ts → dist/core/adapter-registry.js} +10 -28
  16. package/dist/core/adapter-registry.js.map +1 -0
  17. package/{src/core/bound/bind-host.ts → dist/core/bound/bind-host.d.ts} +2 -3
  18. package/dist/core/bound/bind-host.d.ts.map +1 -0
  19. package/dist/core/bound/bind-host.js +2 -0
  20. package/dist/core/bound/bind-host.js.map +1 -0
  21. package/dist/core/bound/observe-bound-field.d.ts +21 -0
  22. package/dist/core/bound/observe-bound-field.d.ts.map +1 -0
  23. package/dist/core/bound/observe-bound-field.js +116 -0
  24. package/dist/core/bound/observe-bound-field.js.map +1 -0
  25. package/dist/core/bound/wait-for-bound-field.d.ts +5 -0
  26. package/dist/core/bound/wait-for-bound-field.d.ts.map +1 -0
  27. package/dist/core/bound/wait-for-bound-field.js +35 -0
  28. package/dist/core/bound/wait-for-bound-field.js.map +1 -0
  29. package/{src/core/context.ts → dist/core/context.d.ts} +2 -6
  30. package/dist/core/context.d.ts.map +1 -0
  31. package/dist/core/context.js +11 -0
  32. package/dist/core/context.js.map +1 -0
  33. package/dist/core/core-provider.d.ts +22 -0
  34. package/dist/core/core-provider.d.ts.map +1 -0
  35. package/{src/core/core-provider.tsx → dist/core/core-provider.js} +209 -364
  36. package/dist/core/core-provider.js.map +1 -0
  37. package/dist/core/core-root.d.ts +26 -0
  38. package/dist/core/core-root.d.ts.map +1 -0
  39. package/dist/core/core-root.js +38 -0
  40. package/dist/core/core-root.js.map +1 -0
  41. package/dist/core/core-shell.d.ts +22 -0
  42. package/dist/core/core-shell.d.ts.map +1 -0
  43. package/dist/core/core-shell.js +8 -0
  44. package/dist/core/core-shell.js.map +1 -0
  45. package/{src/core/errors/error-strip.tsx → dist/core/errors/error-strip.d.ts} +2 -39
  46. package/dist/core/errors/error-strip.d.ts.map +1 -0
  47. package/dist/core/errors/error-strip.js +18 -0
  48. package/dist/core/errors/error-strip.js.map +1 -0
  49. package/dist/core/errors/index.d.ts +4 -0
  50. package/dist/core/errors/index.d.ts.map +1 -0
  51. package/dist/core/errors/index.js +4 -0
  52. package/dist/core/errors/index.js.map +1 -0
  53. package/dist/core/errors/map-error-bag.d.ts +24 -0
  54. package/dist/core/errors/map-error-bag.d.ts.map +1 -0
  55. package/{src/core/errors/map-error-bag.ts → dist/core/errors/map-error-bag.js} +10 -22
  56. package/dist/core/errors/map-error-bag.js.map +1 -0
  57. package/dist/core/errors/map-zod.d.ts +18 -0
  58. package/dist/core/errors/map-zod.d.ts.map +1 -0
  59. package/{src/core/errors/map-zod.ts → dist/core/errors/map-zod.js} +7 -19
  60. package/dist/core/errors/map-zod.js.map +1 -0
  61. package/dist/core/hooks/use-button.d.ts +73 -0
  62. package/dist/core/hooks/use-button.d.ts.map +1 -0
  63. package/dist/core/hooks/use-button.js +116 -0
  64. package/dist/core/hooks/use-button.js.map +1 -0
  65. package/dist/core/hooks/use-core-context.d.ts +9 -0
  66. package/dist/core/hooks/use-core-context.d.ts.map +1 -0
  67. package/{src/core/hooks/use-core-context.ts → dist/core/hooks/use-core-context.js} +3 -6
  68. package/dist/core/hooks/use-core-context.js.map +1 -0
  69. package/dist/core/hooks/use-core-utility.d.ts +1 -0
  70. package/dist/core/hooks/use-core-utility.d.ts.map +1 -0
  71. package/dist/core/hooks/use-core-utility.js +2 -0
  72. package/dist/core/hooks/use-core-utility.js.map +1 -0
  73. package/{src/core/hooks/use-core.ts → dist/core/hooks/use-core.d.ts} +9 -13
  74. package/dist/core/hooks/use-core.d.ts.map +1 -0
  75. package/dist/core/hooks/use-core.js +11 -0
  76. package/dist/core/hooks/use-core.js.map +1 -0
  77. package/dist/core/hooks/use-field.d.ts +141 -0
  78. package/dist/core/hooks/use-field.d.ts.map +1 -0
  79. package/dist/core/hooks/use-field.js +256 -0
  80. package/dist/core/hooks/use-field.js.map +1 -0
  81. package/dist/core/hooks/use-optional-field.d.ts +9 -0
  82. package/dist/core/hooks/use-optional-field.d.ts.map +1 -0
  83. package/dist/core/hooks/use-optional-field.js +146 -0
  84. package/dist/core/hooks/use-optional-field.js.map +1 -0
  85. package/dist/core/index.d.ts +11 -0
  86. package/dist/core/index.d.ts.map +1 -0
  87. package/dist/core/index.js +11 -0
  88. package/dist/core/index.js.map +1 -0
  89. package/dist/core/registry/binder-registry.d.ts +38 -0
  90. package/dist/core/registry/binder-registry.d.ts.map +1 -0
  91. package/dist/core/registry/binder-registry.js +52 -0
  92. package/dist/core/registry/binder-registry.js.map +1 -0
  93. package/dist/core/registry/field-registry.d.ts +86 -0
  94. package/dist/core/registry/field-registry.d.ts.map +1 -0
  95. package/{src/core/registry/field-registry.ts → dist/core/registry/field-registry.js} +56 -70
  96. package/dist/core/registry/field-registry.js.map +1 -0
  97. package/dist/core/test.d.ts +2 -0
  98. package/dist/core/test.d.ts.map +1 -0
  99. package/dist/core/test.js +9 -0
  100. package/dist/core/test.js.map +1 -0
  101. package/dist/index.d.ts +15 -0
  102. package/dist/index.d.ts.map +1 -0
  103. package/{src/index.ts → dist/index.js} +5 -47
  104. package/dist/index.js.map +1 -0
  105. package/{src/input/index.ts → dist/input/index.d.ts} +1 -2
  106. package/dist/input/index.d.ts.map +1 -0
  107. package/dist/input/index.js +3 -0
  108. package/dist/input/index.js.map +1 -0
  109. package/dist/input/input-field.d.ts +15 -0
  110. package/dist/input/input-field.d.ts.map +1 -0
  111. package/dist/input/input-field.js +413 -0
  112. package/dist/input/input-field.js.map +1 -0
  113. package/dist/input/input-layout-graph.d.ts +77 -0
  114. package/dist/input/input-layout-graph.d.ts.map +1 -0
  115. package/dist/input/input-layout-graph.js +108 -0
  116. package/dist/input/input-layout-graph.js.map +1 -0
  117. package/{src/input/input-props.ts → dist/input/input-props.d.ts} +22 -84
  118. package/dist/input/input-props.d.ts.map +1 -0
  119. package/dist/input/input-props.js +4 -0
  120. package/dist/input/input-props.js.map +1 -0
  121. package/dist/lib/get-global-countries.d.ts +3 -0
  122. package/dist/lib/get-global-countries.d.ts.map +1 -0
  123. package/dist/lib/get-global-countries.js +70 -0
  124. package/dist/lib/get-global-countries.js.map +1 -0
  125. package/dist/lib/utils.d.ts +3 -0
  126. package/dist/lib/utils.d.ts.map +1 -0
  127. package/dist/lib/utils.js +6 -0
  128. package/dist/lib/utils.js.map +1 -0
  129. package/dist/presets/index.d.ts +1 -0
  130. package/dist/presets/index.d.ts.map +1 -0
  131. package/dist/presets/index.js +2 -0
  132. package/dist/presets/index.js.map +1 -0
  133. package/dist/presets/shadcn-preset.d.ts +1 -0
  134. package/dist/presets/shadcn-preset.d.ts.map +1 -0
  135. package/dist/presets/shadcn-preset.js +2 -0
  136. package/dist/presets/shadcn-preset.js.map +1 -0
  137. package/dist/presets/shadcn-variants/checkbox.d.ts +212 -0
  138. package/dist/presets/shadcn-variants/checkbox.d.ts.map +1 -0
  139. package/dist/presets/shadcn-variants/checkbox.js +315 -0
  140. package/dist/presets/shadcn-variants/checkbox.js.map +1 -0
  141. package/dist/presets/shadcn-variants/chips.d.ts +154 -0
  142. package/dist/presets/shadcn-variants/chips.d.ts.map +1 -0
  143. package/dist/presets/shadcn-variants/chips.js +266 -0
  144. package/dist/presets/shadcn-variants/chips.js.map +1 -0
  145. package/dist/presets/shadcn-variants/color.d.ts +63 -0
  146. package/dist/presets/shadcn-variants/color.d.ts.map +1 -0
  147. package/dist/presets/shadcn-variants/color.js +96 -0
  148. package/dist/presets/shadcn-variants/color.js.map +1 -0
  149. package/dist/presets/shadcn-variants/custom.d.ts +94 -0
  150. package/dist/presets/shadcn-variants/custom.d.ts.map +1 -0
  151. package/dist/presets/shadcn-variants/custom.js +80 -0
  152. package/dist/presets/shadcn-variants/custom.js.map +1 -0
  153. package/dist/presets/shadcn-variants/date.d.ts +114 -0
  154. package/dist/presets/shadcn-variants/date.d.ts.map +1 -0
  155. package/dist/presets/shadcn-variants/date.js +414 -0
  156. package/dist/presets/shadcn-variants/date.js.map +1 -0
  157. package/dist/presets/shadcn-variants/file.d.ts +79 -0
  158. package/dist/presets/shadcn-variants/file.d.ts.map +1 -0
  159. package/dist/presets/shadcn-variants/file.js +289 -0
  160. package/dist/presets/shadcn-variants/file.js.map +1 -0
  161. package/dist/presets/shadcn-variants/keyvalue.d.ts +35 -0
  162. package/dist/presets/shadcn-variants/keyvalue.d.ts.map +1 -0
  163. package/dist/presets/shadcn-variants/keyvalue.js +215 -0
  164. package/dist/presets/shadcn-variants/keyvalue.js.map +1 -0
  165. package/dist/presets/shadcn-variants/multiselect.d.ts +210 -0
  166. package/dist/presets/shadcn-variants/multiselect.d.ts.map +1 -0
  167. package/dist/presets/shadcn-variants/multiselect.js +352 -0
  168. package/dist/presets/shadcn-variants/multiselect.js.map +1 -0
  169. package/dist/presets/shadcn-variants/number.d.ts +31 -0
  170. package/dist/presets/shadcn-variants/number.d.ts.map +1 -0
  171. package/dist/presets/shadcn-variants/number.js +64 -0
  172. package/dist/presets/shadcn-variants/number.js.map +1 -0
  173. package/dist/presets/shadcn-variants/password.d.ts +195 -0
  174. package/dist/presets/shadcn-variants/password.d.ts.map +1 -0
  175. package/dist/presets/shadcn-variants/password.js +296 -0
  176. package/dist/presets/shadcn-variants/password.js.map +1 -0
  177. package/dist/presets/shadcn-variants/phone.d.ts +69 -0
  178. package/dist/presets/shadcn-variants/phone.d.ts.map +1 -0
  179. package/dist/presets/shadcn-variants/phone.js +308 -0
  180. package/dist/presets/shadcn-variants/phone.js.map +1 -0
  181. package/dist/presets/shadcn-variants/radio.d.ts +172 -0
  182. package/dist/presets/shadcn-variants/radio.d.ts.map +1 -0
  183. package/dist/presets/shadcn-variants/radio.js +192 -0
  184. package/dist/presets/shadcn-variants/radio.js.map +1 -0
  185. package/dist/presets/shadcn-variants/select.d.ts +203 -0
  186. package/dist/presets/shadcn-variants/select.d.ts.map +1 -0
  187. package/dist/presets/shadcn-variants/select.js +285 -0
  188. package/dist/presets/shadcn-variants/select.js.map +1 -0
  189. package/dist/presets/shadcn-variants/slider.d.ts +131 -0
  190. package/dist/presets/shadcn-variants/slider.d.ts.map +1 -0
  191. package/dist/presets/shadcn-variants/slider.js +151 -0
  192. package/dist/presets/shadcn-variants/slider.js.map +1 -0
  193. package/dist/presets/shadcn-variants/text.d.ts +155 -0
  194. package/dist/presets/shadcn-variants/text.d.ts.map +1 -0
  195. package/dist/presets/shadcn-variants/text.js +98 -0
  196. package/dist/presets/shadcn-variants/text.js.map +1 -0
  197. package/dist/presets/shadcn-variants/textarea.d.ts +18 -0
  198. package/dist/presets/shadcn-variants/textarea.d.ts.map +1 -0
  199. package/dist/presets/shadcn-variants/textarea.js +24 -0
  200. package/dist/presets/shadcn-variants/textarea.js.map +1 -0
  201. package/dist/presets/shadcn-variants/toggle.d.ts +61 -0
  202. package/dist/presets/shadcn-variants/toggle.d.ts.map +1 -0
  203. package/dist/presets/shadcn-variants/toggle.js +67 -0
  204. package/dist/presets/shadcn-variants/toggle.js.map +1 -0
  205. package/dist/presets/shadcn-variants/treeselect.d.ts +81 -0
  206. package/dist/presets/shadcn-variants/treeselect.d.ts.map +1 -0
  207. package/dist/presets/shadcn-variants/treeselect.js +317 -0
  208. package/dist/presets/shadcn-variants/treeselect.js.map +1 -0
  209. package/dist/presets/ui/badge.d.ts +10 -0
  210. package/dist/presets/ui/badge.d.ts.map +1 -0
  211. package/dist/presets/ui/badge.js +23 -0
  212. package/dist/presets/ui/badge.js.map +1 -0
  213. package/dist/presets/ui/button.d.ts +11 -0
  214. package/dist/presets/ui/button.d.ts.map +1 -0
  215. package/dist/presets/ui/button.js +34 -0
  216. package/dist/presets/ui/button.js.map +1 -0
  217. package/dist/presets/ui/calendar.d.ts +9 -0
  218. package/dist/presets/ui/calendar.d.ts.map +1 -0
  219. package/dist/presets/ui/calendar.js +76 -0
  220. package/dist/presets/ui/calendar.js.map +1 -0
  221. package/dist/presets/ui/checkbox.d.ts +18 -0
  222. package/dist/presets/ui/checkbox.d.ts.map +1 -0
  223. package/dist/presets/ui/checkbox.js +61 -0
  224. package/dist/presets/ui/checkbox.js.map +1 -0
  225. package/dist/presets/ui/custom.d.ts +1 -0
  226. package/dist/presets/ui/custom.d.ts.map +1 -0
  227. package/dist/presets/ui/custom.js +2 -0
  228. package/dist/presets/ui/custom.js.map +1 -0
  229. package/dist/presets/ui/dialog.d.ts +16 -0
  230. package/dist/presets/ui/dialog.d.ts.map +1 -0
  231. package/dist/presets/ui/dialog.js +36 -0
  232. package/dist/presets/ui/dialog.js.map +1 -0
  233. package/dist/presets/ui/field.d.ts +25 -0
  234. package/dist/presets/ui/field.d.ts.map +1 -0
  235. package/dist/presets/ui/field.js +76 -0
  236. package/dist/presets/ui/field.js.map +1 -0
  237. package/dist/presets/ui/input-mask.d.ts +34 -0
  238. package/dist/presets/ui/input-mask.d.ts.map +1 -0
  239. package/dist/presets/ui/input-mask.js +561 -0
  240. package/dist/presets/ui/input-mask.js.map +1 -0
  241. package/dist/presets/ui/input-otp.d.ts +12 -0
  242. package/dist/presets/ui/input-otp.d.ts.map +1 -0
  243. package/dist/presets/ui/input-otp.js +22 -0
  244. package/dist/presets/ui/input-otp.js.map +1 -0
  245. package/dist/presets/ui/input.d.ts +83 -0
  246. package/dist/presets/ui/input.d.ts.map +1 -0
  247. package/dist/presets/ui/input.js +436 -0
  248. package/dist/presets/ui/input.js.map +1 -0
  249. package/dist/presets/ui/label.d.ts +5 -0
  250. package/dist/presets/ui/label.d.ts.map +1 -0
  251. package/dist/presets/ui/label.js +8 -0
  252. package/dist/presets/ui/label.js.map +1 -0
  253. package/dist/presets/ui/number.d.ts +60 -0
  254. package/dist/presets/ui/number.d.ts.map +1 -0
  255. package/dist/presets/ui/number.js +1078 -0
  256. package/dist/presets/ui/number.js.map +1 -0
  257. package/dist/presets/ui/popover.d.ts +8 -0
  258. package/dist/presets/ui/popover.d.ts.map +1 -0
  259. package/dist/presets/ui/popover.js +17 -0
  260. package/dist/presets/ui/popover.js.map +1 -0
  261. package/dist/presets/ui/radio-group.d.ts +6 -0
  262. package/dist/presets/ui/radio-group.d.ts.map +1 -0
  263. package/dist/presets/ui/radio-group.js +12 -0
  264. package/dist/presets/ui/radio-group.js.map +1 -0
  265. package/dist/presets/ui/scroll-area.d.ts +6 -0
  266. package/dist/presets/ui/scroll-area.d.ts.map +1 -0
  267. package/dist/presets/ui/scroll-area.js +13 -0
  268. package/dist/presets/ui/scroll-area.js.map +1 -0
  269. package/dist/presets/ui/select.d.ts +21 -0
  270. package/dist/presets/ui/select.d.ts.map +1 -0
  271. package/dist/presets/ui/select.js +38 -0
  272. package/dist/presets/ui/select.js.map +1 -0
  273. package/dist/presets/ui/separator.d.ts +5 -0
  274. package/dist/presets/ui/separator.d.ts.map +1 -0
  275. package/dist/presets/ui/separator.js +9 -0
  276. package/dist/presets/ui/separator.js.map +1 -0
  277. package/dist/presets/ui/slider.d.ts +5 -0
  278. package/dist/presets/ui/slider.d.ts.map +1 -0
  279. package/dist/presets/ui/slider.js +14 -0
  280. package/dist/presets/ui/slider.js.map +1 -0
  281. package/dist/presets/ui/switch.d.ts +7 -0
  282. package/dist/presets/ui/switch.d.ts.map +1 -0
  283. package/dist/presets/ui/switch.js +9 -0
  284. package/dist/presets/ui/switch.js.map +1 -0
  285. package/dist/presets/ui/textarea.d.ts +76 -0
  286. package/dist/presets/ui/textarea.d.ts.map +1 -0
  287. package/dist/presets/ui/textarea.js +291 -0
  288. package/dist/presets/ui/textarea.js.map +1 -0
  289. package/dist/presets/ui/time-dropdowns.d.ts +58 -0
  290. package/dist/presets/ui/time-dropdowns.d.ts.map +1 -0
  291. package/dist/presets/ui/time-dropdowns.js +133 -0
  292. package/dist/presets/ui/time-dropdowns.js.map +1 -0
  293. package/{src/schema/adapter.ts → dist/schema/adapter.d.ts} +7 -35
  294. package/dist/schema/adapter.d.ts.map +1 -0
  295. package/dist/schema/adapter.js +3 -0
  296. package/dist/schema/adapter.js.map +1 -0
  297. package/{src/schema/core.ts → dist/schema/core.d.ts} +17 -117
  298. package/dist/schema/core.d.ts.map +1 -0
  299. package/dist/schema/core.js +4 -0
  300. package/dist/schema/core.js.map +1 -0
  301. package/dist/schema/field-map.d.ts +1 -0
  302. package/dist/schema/field-map.d.ts.map +1 -0
  303. package/dist/schema/field-map.js +2 -0
  304. package/dist/schema/field-map.js.map +1 -0
  305. package/{src/schema/field.ts → dist/schema/field.d.ts} +1 -34
  306. package/dist/schema/field.d.ts.map +1 -0
  307. package/dist/schema/field.js +4 -0
  308. package/dist/schema/field.js.map +1 -0
  309. package/dist/schema/index.d.ts +1 -0
  310. package/dist/schema/index.d.ts.map +1 -0
  311. package/dist/schema/index.js +2 -0
  312. package/dist/schema/index.js.map +1 -0
  313. package/{src/schema/input-field.ts → dist/schema/input-field.d.ts} +6 -43
  314. package/dist/schema/input-field.d.ts.map +1 -0
  315. package/dist/schema/input-field.js +3 -0
  316. package/dist/schema/input-field.js.map +1 -0
  317. package/dist/schema/presets.d.ts +1 -0
  318. package/dist/schema/presets.d.ts.map +1 -0
  319. package/dist/schema/presets.js +2 -0
  320. package/dist/schema/presets.js.map +1 -0
  321. package/{src/schema/variant.ts → dist/schema/variant.d.ts} +24 -64
  322. package/dist/schema/variant.d.ts.map +1 -0
  323. package/dist/schema/variant.js +3 -0
  324. package/dist/schema/variant.js.map +1 -0
  325. package/dist/variants/core/checkbox.d.ts +15 -0
  326. package/dist/variants/core/checkbox.d.ts.map +1 -0
  327. package/dist/variants/core/checkbox.js +27 -0
  328. package/dist/variants/core/checkbox.js.map +1 -0
  329. package/dist/variants/core/chips.d.ts +3 -0
  330. package/dist/variants/core/chips.d.ts.map +1 -0
  331. package/dist/variants/core/chips.js +20 -0
  332. package/dist/variants/core/chips.js.map +1 -0
  333. package/dist/variants/core/color.d.ts +3 -0
  334. package/dist/variants/core/color.d.ts.map +1 -0
  335. package/dist/variants/core/color.js +14 -0
  336. package/dist/variants/core/color.js.map +1 -0
  337. package/dist/variants/core/custom.d.ts +11 -0
  338. package/dist/variants/core/custom.d.ts.map +1 -0
  339. package/{src/variants/core/custom.tsx → dist/variants/core/custom.js} +15 -18
  340. package/dist/variants/core/custom.js.map +1 -0
  341. package/dist/variants/core/date.d.ts +3 -0
  342. package/dist/variants/core/date.d.ts.map +1 -0
  343. package/dist/variants/core/date.js +20 -0
  344. package/dist/variants/core/date.js.map +1 -0
  345. package/dist/variants/core/file.d.ts +3 -0
  346. package/dist/variants/core/file.d.ts.map +1 -0
  347. package/dist/variants/core/file.js +6 -0
  348. package/dist/variants/core/file.js.map +1 -0
  349. package/dist/variants/core/keyvalue.d.ts +3 -0
  350. package/dist/variants/core/keyvalue.d.ts.map +1 -0
  351. package/dist/variants/core/keyvalue.js +9 -0
  352. package/dist/variants/core/keyvalue.js.map +1 -0
  353. package/dist/variants/core/multiselect.d.ts +11 -0
  354. package/dist/variants/core/multiselect.d.ts.map +1 -0
  355. package/dist/variants/core/multiselect.js +15 -0
  356. package/dist/variants/core/multiselect.js.map +1 -0
  357. package/dist/variants/core/number.d.ts +38 -0
  358. package/dist/variants/core/number.d.ts.map +1 -0
  359. package/dist/variants/core/number.js +62 -0
  360. package/dist/variants/core/number.js.map +1 -0
  361. package/dist/variants/core/password.d.ts +11 -0
  362. package/dist/variants/core/password.d.ts.map +1 -0
  363. package/dist/variants/core/password.js +29 -0
  364. package/dist/variants/core/password.js.map +1 -0
  365. package/dist/variants/core/phone.d.ts +3 -0
  366. package/dist/variants/core/phone.d.ts.map +1 -0
  367. package/dist/variants/core/phone.js +14 -0
  368. package/dist/variants/core/phone.js.map +1 -0
  369. package/dist/variants/core/radio.d.ts +8 -0
  370. package/dist/variants/core/radio.d.ts.map +1 -0
  371. package/dist/variants/core/radio.js +34 -0
  372. package/dist/variants/core/radio.js.map +1 -0
  373. package/dist/variants/core/select.d.ts +5 -0
  374. package/dist/variants/core/select.d.ts.map +1 -0
  375. package/dist/variants/core/select.js +11 -0
  376. package/dist/variants/core/select.js.map +1 -0
  377. package/dist/variants/core/slider.d.ts +19 -0
  378. package/dist/variants/core/slider.d.ts.map +1 -0
  379. package/dist/variants/core/slider.js +36 -0
  380. package/dist/variants/core/slider.js.map +1 -0
  381. package/dist/variants/core/text.d.ts +38 -0
  382. package/dist/variants/core/text.d.ts.map +1 -0
  383. package/{src/variants/core/text.tsx → dist/variants/core/text.js} +4 -56
  384. package/dist/variants/core/text.js.map +1 -0
  385. package/dist/variants/core/textarea.d.ts +3 -0
  386. package/dist/variants/core/textarea.d.ts.map +1 -0
  387. package/dist/variants/core/textarea.js +20 -0
  388. package/dist/variants/core/textarea.js.map +1 -0
  389. package/dist/variants/core/toggle.d.ts +6 -0
  390. package/dist/variants/core/toggle.d.ts.map +1 -0
  391. package/dist/variants/core/toggle.js +41 -0
  392. package/dist/variants/core/toggle.js.map +1 -0
  393. package/dist/variants/core/treeselect.d.ts +4 -0
  394. package/dist/variants/core/treeselect.d.ts.map +1 -0
  395. package/dist/variants/core/treeselect.js +7 -0
  396. package/dist/variants/core/treeselect.js.map +1 -0
  397. package/dist/variants/helpers/selection-summary.d.ts +24 -0
  398. package/dist/variants/helpers/selection-summary.d.ts.map +1 -0
  399. package/dist/variants/helpers/selection-summary.js +105 -0
  400. package/dist/variants/helpers/selection-summary.js.map +1 -0
  401. package/dist/variants/index.d.ts +16 -0
  402. package/dist/variants/index.d.ts.map +1 -0
  403. package/{src/variants/index.ts → dist/variants/index.js} +7 -27
  404. package/dist/variants/index.js.map +1 -0
  405. package/dist/variants/registry.d.ts +19 -0
  406. package/dist/variants/registry.d.ts.map +1 -0
  407. package/dist/variants/registry.js +29 -0
  408. package/dist/variants/registry.js.map +1 -0
  409. package/dist/variants/select-shared.d.ts +1 -0
  410. package/dist/variants/select-shared.d.ts.map +1 -0
  411. package/dist/variants/select-shared.js +2 -0
  412. package/dist/variants/select-shared.js.map +1 -0
  413. package/{src/variants/shared.ts → dist/variants/shared.d.ts} +3 -22
  414. package/dist/variants/shared.d.ts.map +1 -0
  415. package/dist/variants/shared.js +3 -0
  416. package/dist/variants/shared.js.map +1 -0
  417. package/package.json +4 -4
  418. package/.scaffold-cache.json +0 -537
  419. package/src/.scaffold-cache.json +0 -544
  420. package/src/adapters/axios.ts +0 -117
  421. package/src/adapters/index.ts +0 -91
  422. package/src/adapters/inertia.ts +0 -187
  423. package/src/core/bound/observe-bound-field.ts +0 -172
  424. package/src/core/bound/wait-for-bound-field.ts +0 -57
  425. package/src/core/core-root.tsx +0 -72
  426. package/src/core/core-shell.tsx +0 -44
  427. package/src/core/errors/index.ts +0 -2
  428. package/src/core/hooks/use-button.ts +0 -220
  429. package/src/core/hooks/use-core-utility.ts +0 -0
  430. package/src/core/hooks/use-field.ts +0 -497
  431. package/src/core/hooks/use-optional-field.ts +0 -28
  432. package/src/core/index.ts +0 -0
  433. package/src/core/registry/binder-registry.ts +0 -82
  434. package/src/core/test.tsx +0 -17
  435. package/src/global.d.ts +0 -14
  436. package/src/input/input-field.tsx +0 -854
  437. package/src/input/input-layout-graph.ts +0 -230
  438. package/src/lib/get-global-countries.ts +0 -87
  439. package/src/lib/utils.ts +0 -6
  440. package/src/presets/index.ts +0 -0
  441. package/src/presets/shadcn-preset.ts +0 -0
  442. package/src/presets/shadcn-variants/checkbox.tsx +0 -849
  443. package/src/presets/shadcn-variants/chips.tsx +0 -756
  444. package/src/presets/shadcn-variants/color.tsx +0 -284
  445. package/src/presets/shadcn-variants/custom.tsx +0 -227
  446. package/src/presets/shadcn-variants/date.tsx +0 -796
  447. package/src/presets/shadcn-variants/file.tsx +0 -764
  448. package/src/presets/shadcn-variants/keyvalue.tsx +0 -556
  449. package/src/presets/shadcn-variants/multiselect.tsx +0 -1132
  450. package/src/presets/shadcn-variants/number.tsx +0 -176
  451. package/src/presets/shadcn-variants/password.tsx +0 -737
  452. package/src/presets/shadcn-variants/phone.tsx +0 -628
  453. package/src/presets/shadcn-variants/radio.tsx +0 -578
  454. package/src/presets/shadcn-variants/select.tsx +0 -956
  455. package/src/presets/shadcn-variants/slider.tsx +0 -622
  456. package/src/presets/shadcn-variants/text.tsx +0 -343
  457. package/src/presets/shadcn-variants/textarea.tsx +0 -66
  458. package/src/presets/shadcn-variants/toggle.tsx +0 -218
  459. package/src/presets/shadcn-variants/treeselect.tsx +0 -784
  460. package/src/presets/ui/badge.tsx +0 -46
  461. package/src/presets/ui/button.tsx +0 -60
  462. package/src/presets/ui/calendar.tsx +0 -214
  463. package/src/presets/ui/checkbox.tsx +0 -115
  464. package/src/presets/ui/custom.tsx +0 -0
  465. package/src/presets/ui/dialog.tsx +0 -141
  466. package/src/presets/ui/field.tsx +0 -246
  467. package/src/presets/ui/input-mask.tsx +0 -739
  468. package/src/presets/ui/input-otp.tsx +0 -77
  469. package/src/presets/ui/input.tsx +0 -1011
  470. package/src/presets/ui/label.tsx +0 -22
  471. package/src/presets/ui/number.tsx +0 -1370
  472. package/src/presets/ui/popover.tsx +0 -46
  473. package/src/presets/ui/radio-group.tsx +0 -43
  474. package/src/presets/ui/scroll-area.tsx +0 -56
  475. package/src/presets/ui/select.tsx +0 -190
  476. package/src/presets/ui/separator.tsx +0 -28
  477. package/src/presets/ui/slider.tsx +0 -61
  478. package/src/presets/ui/switch.tsx +0 -32
  479. package/src/presets/ui/textarea.tsx +0 -634
  480. package/src/presets/ui/time-dropdowns.tsx +0 -350
  481. package/src/schema/field-map.ts +0 -0
  482. package/src/schema/index.ts +0 -0
  483. package/src/schema/presets.ts +0 -0
  484. package/src/variants/core/checkbox.tsx +0 -54
  485. package/src/variants/core/chips.tsx +0 -22
  486. package/src/variants/core/color.tsx +0 -16
  487. package/src/variants/core/date.tsx +0 -25
  488. package/src/variants/core/file.tsx +0 -9
  489. package/src/variants/core/keyvalue.tsx +0 -12
  490. package/src/variants/core/multiselect.tsx +0 -28
  491. package/src/variants/core/number.tsx +0 -115
  492. package/src/variants/core/password.tsx +0 -35
  493. package/src/variants/core/phone.tsx +0 -16
  494. package/src/variants/core/radio.tsx +0 -38
  495. package/src/variants/core/select.tsx +0 -15
  496. package/src/variants/core/slider.tsx +0 -55
  497. package/src/variants/core/textarea.tsx +0 -22
  498. package/src/variants/core/toggle.tsx +0 -50
  499. package/src/variants/core/treeselect.tsx +0 -11
  500. package/src/variants/helpers/selection-summary.tsx +0 -236
  501. package/src/variants/registry.ts +0 -38
  502. package/src/variants/select-shared.ts +0 -0
  503. package/tsconfig.json +0 -14
@@ -0,0 +1,1078 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { Input } from "./input";
4
+ export const InputNumber = React.memo(React.forwardRef((inProps, ref) => {
5
+ const props = {
6
+ allowEmpty: true,
7
+ autoFocus: false,
8
+ format: true,
9
+ locale: undefined,
10
+ localeMatcher: undefined,
11
+ mode: "decimal",
12
+ useGrouping: true,
13
+ step: 1,
14
+ roundingMode: undefined,
15
+ type: "text",
16
+ ...inProps,
17
+ };
18
+ const [focusedState, setFocusedState] = React.useState(false);
19
+ const elementRef = React.useRef(null);
20
+ const inputRef = React.useRef(null);
21
+ const timer = React.useRef(undefined);
22
+ const lastValue = React.useRef("");
23
+ const numberFormat = React.useRef(null);
24
+ const groupChar = React.useRef("");
25
+ const prefixChar = React.useRef("");
26
+ const suffixChar = React.useRef("");
27
+ const _numeral = React.useRef(null);
28
+ const _group = React.useRef(null);
29
+ const _minusSign = React.useRef(null);
30
+ const _currency = React.useRef(null);
31
+ const _decimal = React.useRef(null);
32
+ const _decimalSeparator = React.useRef(".");
33
+ const _suffix = React.useRef(null);
34
+ const _prefix = React.useRef(null);
35
+ const _index = React.useRef(() => 0);
36
+ const isFocusedByClick = React.useRef(false);
37
+ const resolveLocale = React.useCallback(() => {
38
+ if (props.locale)
39
+ return props.locale;
40
+ if (typeof navigator !== "undefined" && navigator.language) {
41
+ return navigator.language;
42
+ }
43
+ return "en-US";
44
+ }, [props.locale]);
45
+ const _locale = resolveLocale();
46
+ const inputMode = props.inputMode ||
47
+ (props.mode === "decimal" && !props.minFractionDigits && !props.maxFractionDigits
48
+ ? "numeric"
49
+ : "decimal");
50
+ const getOptions = React.useCallback(() => {
51
+ return {
52
+ localeMatcher: props.localeMatcher,
53
+ style: props.mode,
54
+ currency: props.currency,
55
+ currencyDisplay: props.currencyDisplay,
56
+ useGrouping: props.useGrouping,
57
+ minimumFractionDigits: props.minFractionDigits !== undefined ? props.minFractionDigits : undefined,
58
+ maximumFractionDigits: props.maxFractionDigits !== undefined ? props.maxFractionDigits : undefined,
59
+ roundingMode: props.roundingMode,
60
+ };
61
+ }, [
62
+ props.localeMatcher,
63
+ props.mode,
64
+ props.currency,
65
+ props.currencyDisplay,
66
+ props.useGrouping,
67
+ props.minFractionDigits,
68
+ props.maxFractionDigits,
69
+ props.roundingMode,
70
+ ]);
71
+ const escapeRegExp = (text) => text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
72
+ const constructParser = React.useCallback(() => {
73
+ const loc = _locale;
74
+ numberFormat.current = new Intl.NumberFormat(loc, getOptions());
75
+ // numerals
76
+ const numerals = [
77
+ ...new Intl.NumberFormat(loc, { useGrouping: false }).format(9876543210),
78
+ ].reverse();
79
+ const index = new Map(numerals.map((d, i) => [d, i]));
80
+ _numeral.current = new RegExp("[" + numerals.join("") + "]", "g");
81
+ _index.current = (d) => index.get(d) ?? 0;
82
+ // grouping
83
+ const formatterGroup = new Intl.NumberFormat(loc, { useGrouping: true });
84
+ groupChar.current = formatterGroup
85
+ .format(1000000)
86
+ .trim()
87
+ .replace(_numeral.current, "")
88
+ .charAt(0);
89
+ _group.current = new RegExp("[" + groupChar.current + "]", "g");
90
+ // minus
91
+ const formatterMinus = new Intl.NumberFormat(loc, { useGrouping: false });
92
+ const minusString = formatterMinus
93
+ .format(-1)
94
+ .trim()
95
+ .replace(_numeral.current, "");
96
+ _minusSign.current = new RegExp("[" + minusString + "]", "g");
97
+ // currency
98
+ if (props.currency) {
99
+ const formatterCurrency = new Intl.NumberFormat(loc, {
100
+ style: "currency",
101
+ currency: props.currency,
102
+ currencyDisplay: props.currencyDisplay,
103
+ minimumFractionDigits: 0,
104
+ maximumFractionDigits: 0,
105
+ roundingMode: props.roundingMode,
106
+ });
107
+ _currency.current = new RegExp("[" +
108
+ formatterCurrency
109
+ .format(1)
110
+ .replace(/\s/g, "")
111
+ .replace(_numeral.current, "")
112
+ .replace(_group.current, "") +
113
+ "]", "g");
114
+ }
115
+ else {
116
+ _currency.current = new RegExp("[]", "g");
117
+ }
118
+ // decimal separator + expression
119
+ const formatterDecimal = new Intl.NumberFormat(loc, {
120
+ useGrouping: false,
121
+ });
122
+ const decSample = formatterDecimal.format(1.1).trim().replace(_numeral.current, "");
123
+ _decimalSeparator.current = decSample || ".";
124
+ const formatterDecOptions = new Intl.NumberFormat(loc, {
125
+ ...getOptions(),
126
+ useGrouping: false,
127
+ });
128
+ _decimal.current = new RegExp("[" +
129
+ formatterDecOptions
130
+ .format(1.1)
131
+ .replace(_currency.current, "")
132
+ .trim()
133
+ .replace(_numeral.current, "") +
134
+ "]", "g");
135
+ // prefix
136
+ if (props.prefix) {
137
+ prefixChar.current = props.prefix;
138
+ }
139
+ else {
140
+ const formatterPrefix = new Intl.NumberFormat(loc, {
141
+ style: props.mode,
142
+ currency: props.currency,
143
+ currencyDisplay: props.currencyDisplay,
144
+ });
145
+ prefixChar.current = formatterPrefix.format(1).split("1")[0];
146
+ }
147
+ _prefix.current = new RegExp(escapeRegExp(prefixChar.current || ""), "g");
148
+ // suffix
149
+ if (props.suffix) {
150
+ suffixChar.current = props.suffix;
151
+ }
152
+ else {
153
+ const formatterSuffix = new Intl.NumberFormat(loc, {
154
+ style: props.mode,
155
+ currency: props.currency,
156
+ currencyDisplay: props.currencyDisplay,
157
+ minimumFractionDigits: 0,
158
+ maximumFractionDigits: 0,
159
+ roundingMode: props.roundingMode,
160
+ });
161
+ suffixChar.current = formatterSuffix.format(1).split("1")[1];
162
+ }
163
+ _suffix.current = new RegExp(escapeRegExp(suffixChar.current || ""), "g");
164
+ }, [
165
+ _locale,
166
+ getOptions,
167
+ props.currency,
168
+ props.currencyDisplay,
169
+ props.mode,
170
+ props.prefix,
171
+ props.roundingMode,
172
+ props.suffix,
173
+ ]);
174
+ const formatValue = React.useCallback((value) => {
175
+ if (value == null)
176
+ return "";
177
+ if (value === "-")
178
+ return "-";
179
+ const numeric = typeof value === "number"
180
+ ? value
181
+ : typeof value === "string"
182
+ ? Number(value)
183
+ : Number.NaN;
184
+ if (Number.isNaN(numeric))
185
+ return "";
186
+ if (props.format) {
187
+ const formatter = numberFormat.current || new Intl.NumberFormat(_locale, getOptions());
188
+ let formatted = formatter.format(numeric);
189
+ if (props.prefix) {
190
+ formatted = props.prefix + formatted;
191
+ }
192
+ if (props.suffix) {
193
+ formatted = formatted + props.suffix;
194
+ }
195
+ return formatted;
196
+ }
197
+ return numeric.toString();
198
+ }, [getOptions, _locale, props.format, props.prefix, props.suffix]);
199
+ const parseValue = React.useCallback((text) => {
200
+ if (!text)
201
+ return null;
202
+ let filteredText = text;
203
+ if (_suffix.current) {
204
+ filteredText = filteredText.replace(_suffix.current, "");
205
+ }
206
+ if (_prefix.current) {
207
+ filteredText = filteredText.replace(_prefix.current, "");
208
+ }
209
+ filteredText = filteredText
210
+ .trim()
211
+ .replace(/\s/g, "")
212
+ .replace(_currency.current, "")
213
+ .replace(_group.current, "")
214
+ .replace(_minusSign.current, "-")
215
+ .replace(_decimal.current, ".")
216
+ .replace(_numeral.current, (d) => String(_index.current(d) ?? ""));
217
+ if (!filteredText)
218
+ return null;
219
+ if (filteredText === "-") {
220
+ return "-";
221
+ }
222
+ const parsedValue = +filteredText;
223
+ return Number.isNaN(parsedValue) ? null : parsedValue;
224
+ }, []);
225
+ const addWithPrecision = (base, increment, precision = 10) => Math.round((base + increment) * precision) / precision;
226
+ const clearTimer = () => {
227
+ if (timer.current != null) {
228
+ window.clearInterval(timer.current);
229
+ timer.current = undefined;
230
+ }
231
+ };
232
+ const allowMinusSign = () => props.min == null || props.min < 0;
233
+ const isMinusSign = (ch) => {
234
+ if ((_minusSign.current && _minusSign.current.test(ch)) || ch === "-") {
235
+ _minusSign.current && (_minusSign.current.lastIndex = 0);
236
+ return true;
237
+ }
238
+ return false;
239
+ };
240
+ const isDecimalMode = () => props.mode === "decimal";
241
+ const isFloat = (val) => {
242
+ const formatter = new Intl.NumberFormat(_locale, getOptions());
243
+ const parsed = parseValue(formatter.format(val));
244
+ if (parsed === null || typeof parsed !== "number") {
245
+ return false;
246
+ }
247
+ return parsed % 1 !== 0;
248
+ };
249
+ const replaceDecimalSeparator = (val) => {
250
+ if (typeof val === "number" && isFloat(val)) {
251
+ return val.toString().replace(/\.(?=[^.]*$)/, _decimalSeparator.current);
252
+ }
253
+ return val;
254
+ };
255
+ const isDecimalSign = (ch) => {
256
+ if (_decimal.current && (_decimal.current.test(ch) || isFloat(Number(ch)))) {
257
+ _decimal.current.lastIndex = 0;
258
+ return true;
259
+ }
260
+ return false;
261
+ };
262
+ const getDecimalCharIndexes = (val) => {
263
+ let decimalCharIndex = -1;
264
+ let decimalCharIndexWithoutPrefix = -1;
265
+ if (_decimal.current) {
266
+ decimalCharIndex = val.search(_decimal.current);
267
+ _decimal.current.lastIndex = 0;
268
+ let filteredVal = val;
269
+ if (_prefix.current) {
270
+ filteredVal = filteredVal.replace(_prefix.current, "");
271
+ }
272
+ filteredVal = filteredVal.trim().replace(/\s/g, "").replace(_currency.current, "");
273
+ decimalCharIndexWithoutPrefix = filteredVal.search(_decimal.current);
274
+ _decimal.current.lastIndex = 0;
275
+ }
276
+ return { decimalCharIndex, decimalCharIndexWithoutPrefix };
277
+ };
278
+ const getCharIndexes = (val) => {
279
+ let decimalCharIndex = -1;
280
+ let minusCharIndex = -1;
281
+ let suffixCharIndex = -1;
282
+ let currencyCharIndex = -1;
283
+ if (_decimal.current) {
284
+ decimalCharIndex = val.search(_decimal.current);
285
+ _decimal.current.lastIndex = 0;
286
+ }
287
+ if (_minusSign.current) {
288
+ minusCharIndex = val.search(_minusSign.current);
289
+ _minusSign.current.lastIndex = 0;
290
+ }
291
+ if (_suffix.current) {
292
+ suffixCharIndex = val.search(_suffix.current);
293
+ _suffix.current.lastIndex = 0;
294
+ }
295
+ if (_currency.current) {
296
+ currencyCharIndex = val.search(_currency.current);
297
+ if (currencyCharIndex === 0 && prefixChar.current && prefixChar.current.length > 1) {
298
+ currencyCharIndex = prefixChar.current.trim().length;
299
+ }
300
+ _currency.current.lastIndex = 0;
301
+ }
302
+ return { decimalCharIndex, minusCharIndex, suffixCharIndex, currencyCharIndex };
303
+ };
304
+ const resetRegex = () => {
305
+ if (_numeral.current)
306
+ _numeral.current.lastIndex = 0;
307
+ if (_decimal.current)
308
+ _decimal.current.lastIndex = 0;
309
+ if (_group.current)
310
+ _group.current.lastIndex = 0;
311
+ if (_minusSign.current)
312
+ _minusSign.current.lastIndex = 0;
313
+ };
314
+ const isNumeralChar = (ch) => {
315
+ if (ch.length === 1 &&
316
+ ((_numeral.current && _numeral.current.test(ch)) ||
317
+ (_decimal.current && _decimal.current.test(ch)) ||
318
+ (_group.current && _group.current.test(ch)) ||
319
+ (_minusSign.current && _minusSign.current.test(ch)))) {
320
+ resetRegex();
321
+ return true;
322
+ }
323
+ return false;
324
+ };
325
+ const evaluateEmpty = (newValue) => {
326
+ if ((newValue == null || newValue === "") && !props.allowEmpty) {
327
+ return props.min ?? 0;
328
+ }
329
+ return newValue;
330
+ };
331
+ const validateValueByLimit = (value) => {
332
+ if (value === "-" || value === null || value === "") {
333
+ return null;
334
+ }
335
+ let num = typeof value === "number" ? value : Number(value);
336
+ if (Number.isNaN(num)) {
337
+ return null;
338
+ }
339
+ if (props.min != null && num < props.min)
340
+ num = props.min;
341
+ if (props.max != null && num > props.max)
342
+ num = props.max;
343
+ return num;
344
+ };
345
+ const validateValue = (value) => {
346
+ if (value === "-")
347
+ return null;
348
+ return validateValueByLimit(value);
349
+ };
350
+ const formattedValue = (val) => {
351
+ const newVal = evaluateEmpty(val);
352
+ return formatValue(newVal);
353
+ };
354
+ const updateModel = (event, value) => {
355
+ const finalValue = value;
356
+ if (props.onValueChange) {
357
+ props.onValueChange({
358
+ originalEvent: event,
359
+ value: finalValue,
360
+ stopPropagation() {
361
+ event?.stopPropagation();
362
+ },
363
+ preventDefault() {
364
+ event?.preventDefault();
365
+ },
366
+ target: {
367
+ name: props.name ?? null,
368
+ id: props.id ?? null,
369
+ value: finalValue,
370
+ },
371
+ });
372
+ }
373
+ if (props.onChange && event) {
374
+ props.onChange({ originalEvent: event, value: finalValue });
375
+ }
376
+ };
377
+ const handleOnChange = (event, currentValue, newValue) => {
378
+ if (!props.onChange)
379
+ return;
380
+ const parsedCurrent = typeof currentValue === "string" ? parseValue(currentValue) : null;
381
+ const changed = newValue !== parsedCurrent;
382
+ if (changed) {
383
+ props.onChange({ originalEvent: event, value: newValue });
384
+ }
385
+ };
386
+ const concatValues = (val1, val2) => {
387
+ if (val1 && val2) {
388
+ const decimalCharIndex = val2.search(_decimal.current);
389
+ _decimal.current.lastIndex = 0;
390
+ const newVal1 = replaceDecimalSeparator(val1);
391
+ const base = newVal1.split(_decimal.current)[0].replace(_suffix.current, "").trim();
392
+ return decimalCharIndex !== -1 ? base + val2.slice(decimalCharIndex) : val1;
393
+ }
394
+ return val1;
395
+ };
396
+ const getDecimalLength = (value) => {
397
+ if (value) {
398
+ const valueSplit = value.split(_decimal.current);
399
+ if (valueSplit.length === 2) {
400
+ return valueSplit[1].replace(_suffix.current, "").length;
401
+ }
402
+ }
403
+ return 0;
404
+ };
405
+ const deleteRange = (value, start, end) => {
406
+ if (end - start === value.length) {
407
+ return "";
408
+ }
409
+ else if (start === 0) {
410
+ return value.slice(end);
411
+ }
412
+ else if (end === value.length) {
413
+ return value.slice(0, start);
414
+ }
415
+ return value.slice(0, start) + value.slice(end);
416
+ };
417
+ const replaceSuffix = (value) => value
418
+ ? value
419
+ .replace(_suffix.current, "")
420
+ .trim()
421
+ .replace(/\s/g, "")
422
+ .replace(_currency.current, "")
423
+ : value;
424
+ const insertText = (value, text, start, end) => {
425
+ const textSplit = isDecimalSign(text) ? text : text.split(_decimal.current);
426
+ if (textSplit.length === 2) {
427
+ const local = value.slice(start, end);
428
+ const decimalCharIndex = local.search(_decimal.current);
429
+ _decimal.current.lastIndex = 0;
430
+ return decimalCharIndex > 0
431
+ ? value.slice(0, start) + formatValue(text) + replaceSuffix(value).slice(end)
432
+ : value || formatValue(text);
433
+ }
434
+ if (isDecimalSign(text) && value.length === 0) {
435
+ return formatValue("0.");
436
+ }
437
+ if (end - start === value.length) {
438
+ return formatValue(text);
439
+ }
440
+ if (start === 0) {
441
+ const suffix = /[A-Za-z]$/.test(value[end]) ? end - 1 : end;
442
+ return text + value.slice(suffix);
443
+ }
444
+ if (end === value.length) {
445
+ return value.slice(0, start) + text;
446
+ }
447
+ const selectionValue = value.slice(start, end);
448
+ const space = /\s$/.test(selectionValue) ? " " : "";
449
+ return value.slice(0, start) + text + space + value.slice(end);
450
+ };
451
+ const evaluateEmptyForUpdate = (newValue) => evaluateEmpty(newValue);
452
+ const updateInput = (value, insertedValueStr, operation, valueStr) => {
453
+ insertedValueStr = insertedValueStr || "";
454
+ const inputEl = inputRef.current;
455
+ if (!inputEl)
456
+ return;
457
+ const inputValue = inputEl.value;
458
+ let newValue = formatValue(value);
459
+ const currentLength = inputValue.length;
460
+ if (newValue !== valueStr && valueStr != null) {
461
+ newValue = concatValues(newValue, valueStr);
462
+ }
463
+ if (currentLength === 0) {
464
+ inputEl.value = newValue;
465
+ inputEl.setSelectionRange(0, 0);
466
+ const index = initCursor();
467
+ const selectionEnd = index + insertedValueStr.length + (isDecimalSign(insertedValueStr) ? 1 : 0);
468
+ inputEl.setSelectionRange(selectionEnd, selectionEnd);
469
+ }
470
+ else {
471
+ let selectionStart = inputEl.selectionStart ?? 0;
472
+ let selectionEnd = inputEl.selectionEnd ?? 0;
473
+ if (props.maxLength && props.maxLength < newValue.length) {
474
+ return;
475
+ }
476
+ inputEl.value = newValue;
477
+ const newLength = newValue.length;
478
+ if (operation === "range-insert") {
479
+ const startValue = parseValue((inputValue || "").slice(0, selectionStart));
480
+ const startValueStr = startValue != null ? String(startValue) : "";
481
+ const startExpr = startValueStr.split("").join("(" + groupChar.current + ")?");
482
+ const sRegex = new RegExp(startExpr, "g");
483
+ sRegex.test(newValue);
484
+ const tExpr = insertedValueStr.split("").join("(" + groupChar.current + ")?");
485
+ const tRegex = new RegExp(tExpr, "g");
486
+ tRegex.test(newValue.slice(sRegex.lastIndex));
487
+ selectionEnd = sRegex.lastIndex + tRegex.lastIndex;
488
+ inputEl.setSelectionRange(selectionEnd, selectionEnd);
489
+ }
490
+ else if (newLength === currentLength) {
491
+ if (operation === "insert" || operation === "delete-back-single") {
492
+ let newSelectionEnd = selectionEnd;
493
+ if (insertedValueStr === "0") {
494
+ newSelectionEnd = selectionEnd + 1;
495
+ }
496
+ else {
497
+ newSelectionEnd =
498
+ newSelectionEnd + Number(isDecimalSign(value) || isDecimalSign(insertedValueStr));
499
+ }
500
+ inputEl.setSelectionRange(newSelectionEnd, newSelectionEnd);
501
+ }
502
+ else if (operation === "delete-single") {
503
+ inputEl.setSelectionRange(selectionEnd - 1, selectionEnd - 1);
504
+ }
505
+ else if (operation === "delete-range" || operation === "spin") {
506
+ inputEl.setSelectionRange(selectionEnd, selectionEnd);
507
+ }
508
+ }
509
+ else if (operation === "delete-back-single") {
510
+ const prevChar = inputValue.charAt(selectionEnd - 1);
511
+ const nextChar = inputValue.charAt(selectionEnd);
512
+ const diff = currentLength - newLength;
513
+ const isGroupChar = _group.current.test(nextChar);
514
+ if (isGroupChar && diff === 1) {
515
+ selectionEnd = selectionEnd + 1;
516
+ }
517
+ else if (!isGroupChar && isNumeralChar(prevChar)) {
518
+ selectionEnd = selectionEnd + (-1 * diff + 1);
519
+ }
520
+ _group.current.lastIndex = 0;
521
+ inputEl.setSelectionRange(selectionEnd, selectionEnd);
522
+ }
523
+ else if (inputValue === "-" && operation === "insert") {
524
+ inputEl.setSelectionRange(0, 0);
525
+ const idx = initCursor();
526
+ const end = idx + insertedValueStr.length + 1;
527
+ inputEl.setSelectionRange(end, end);
528
+ }
529
+ else {
530
+ selectionEnd = selectionEnd + (newLength - currentLength);
531
+ inputEl.setSelectionRange(selectionEnd, selectionEnd);
532
+ }
533
+ }
534
+ inputEl.setAttribute("aria-valuenow", value == null ? "" : String(value));
535
+ };
536
+ const updateInputValue = (newValue) => {
537
+ const evaluated = evaluateEmptyForUpdate(newValue);
538
+ const inputEl = inputRef.current;
539
+ if (!inputEl)
540
+ return;
541
+ const current = inputEl.value;
542
+ const formatted = formattedValue(evaluated);
543
+ if (current !== formatted) {
544
+ inputEl.value = formatted;
545
+ inputEl.setAttribute("aria-valuenow", evaluated == null ? "" : String(evaluated));
546
+ }
547
+ };
548
+ const isValueChanged = (currentValue, newValue) => {
549
+ if (newValue == null && currentValue != null)
550
+ return true;
551
+ if (newValue != null) {
552
+ const parsedCurrent = typeof currentValue === "string" ? parseValue(currentValue) : null;
553
+ return newValue !== parsedCurrent;
554
+ }
555
+ return false;
556
+ };
557
+ const updateValue = (event, valueStr, insertedValueStr, operation) => {
558
+ const inputEl = inputRef.current;
559
+ if (!inputEl)
560
+ return;
561
+ const currentValue = inputEl.value;
562
+ if (valueStr != null) {
563
+ const parsed = parseValue(valueStr);
564
+ const newValue = evaluateEmpty(parsed);
565
+ const limited = validateValueByLimit(parsed);
566
+ updateInput(limited, insertedValueStr, operation, valueStr);
567
+ if (event &&
568
+ typeof currentValue === "string" &&
569
+ typeof limited === "number" &&
570
+ isValueChanged(currentValue, limited)) {
571
+ handleOnChange(event, currentValue, limited);
572
+ }
573
+ // update model immediately for spin/insert/delete etc
574
+ updateModel(event, limited);
575
+ }
576
+ };
577
+ const spin = (event, dir) => {
578
+ const inputEl = inputRef.current;
579
+ if (!inputEl)
580
+ return;
581
+ const step = (props.step ?? 1) * dir;
582
+ const currentValue = parseValue(inputEl.value) ?? 0;
583
+ const newValue = validateValue(addWithPrecision(currentValue, step));
584
+ if (newValue == null)
585
+ return;
586
+ if (props.maxLength && props.maxLength < formatValue(newValue).length) {
587
+ return;
588
+ }
589
+ // onChange before onValueChange, like Prime
590
+ handleOnChange(event, inputEl.value, newValue);
591
+ updateInput(newValue, null, "spin");
592
+ updateModel(event, newValue);
593
+ };
594
+ const _repeat = (event, interval, dir) => {
595
+ const i = interval ?? 500;
596
+ clearTimer();
597
+ timer.current = window.setTimeout(() => {
598
+ _repeat(event, 40, dir);
599
+ }, i);
600
+ spin(event, dir);
601
+ };
602
+ const insert = (event, text, sign = {
603
+ isDecimalSign: false,
604
+ isMinusSign: false,
605
+ }) => {
606
+ const inputEl = inputRef.current;
607
+ if (!inputEl)
608
+ return;
609
+ const minusCharIndexOnText = text.search(_minusSign.current);
610
+ _minusSign.current.lastIndex = 0;
611
+ if (!allowMinusSign() && minusCharIndexOnText !== -1) {
612
+ return;
613
+ }
614
+ let selectionStart = inputEl.selectionStart ?? 0;
615
+ let selectionEnd = inputEl.selectionEnd ?? 0;
616
+ const inputValue = inputEl.value.trim();
617
+ const { decimalCharIndex, minusCharIndex, suffixCharIndex, currencyCharIndex } = getCharIndexes(inputValue);
618
+ const maxFractionDigits = numberFormat.current?.resolvedOptions().maximumFractionDigits ?? 0;
619
+ const hasBoundOrAffix = !!(props.min || props.max || props.suffix || props.prefix);
620
+ let newValueStr = null;
621
+ if (sign.isMinusSign) {
622
+ const isNewMinusSign = minusCharIndex === -1;
623
+ if (selectionStart === 0 || selectionStart === currencyCharIndex + 1) {
624
+ newValueStr = inputValue;
625
+ if (isNewMinusSign || selectionEnd !== 0) {
626
+ newValueStr = insertText(inputValue, text, 0, selectionEnd);
627
+ }
628
+ updateValue(event, newValueStr, text, "insert");
629
+ }
630
+ }
631
+ else if (sign.isDecimalSign) {
632
+ if (decimalCharIndex > 0 && selectionStart === decimalCharIndex) {
633
+ updateValue(event, inputValue, text, "insert");
634
+ }
635
+ else if (decimalCharIndex > selectionStart && decimalCharIndex < selectionEnd) {
636
+ newValueStr = insertText(inputValue, text, selectionStart, selectionEnd);
637
+ updateValue(event, newValueStr, text, "insert");
638
+ }
639
+ else if (decimalCharIndex === -1 && (maxFractionDigits || props.maxFractionDigits)) {
640
+ const allowedDecimal = inputMode !== "numeric" || (inputMode === "numeric" && hasBoundOrAffix);
641
+ if (allowedDecimal) {
642
+ newValueStr = insertText(inputValue, text, selectionStart, selectionEnd);
643
+ updateValue(event, newValueStr, text, "insert");
644
+ }
645
+ }
646
+ }
647
+ else {
648
+ const operation = selectionStart !== selectionEnd ? "range-insert" : "insert";
649
+ if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) {
650
+ if (selectionStart + text.length - (decimalCharIndex + 1) <= maxFractionDigits) {
651
+ const charIndex = currencyCharIndex >= selectionStart
652
+ ? currencyCharIndex - 1
653
+ : suffixCharIndex >= selectionStart
654
+ ? suffixCharIndex
655
+ : inputValue.length;
656
+ newValueStr =
657
+ inputValue.slice(0, selectionStart) +
658
+ text +
659
+ inputValue.slice(selectionStart + text.length, charIndex) +
660
+ inputValue.slice(charIndex);
661
+ updateValue(event, newValueStr, text, operation);
662
+ }
663
+ }
664
+ else {
665
+ newValueStr = insertText(inputValue, text, selectionStart, selectionEnd);
666
+ updateValue(event, newValueStr, text, operation);
667
+ }
668
+ }
669
+ };
670
+ const initCursor = () => {
671
+ const inputEl = inputRef.current;
672
+ if (!inputEl)
673
+ return 0;
674
+ let selectionStart = inputEl.selectionStart ?? 0;
675
+ let inputValue = inputEl.value;
676
+ const valueLength = inputValue.length;
677
+ let index = null;
678
+ const prefixLength = (prefixChar.current || "").length;
679
+ inputValue = inputValue.replace(_prefix.current, "");
680
+ selectionStart = selectionStart - prefixLength;
681
+ let ch = inputValue.charAt(selectionStart);
682
+ if (isNumeralChar(ch)) {
683
+ return selectionStart + prefixLength;
684
+ }
685
+ // search left
686
+ let i = selectionStart - 1;
687
+ while (i >= 0) {
688
+ ch = inputValue.charAt(i);
689
+ if (isNumeralChar(ch)) {
690
+ index = i + prefixLength;
691
+ break;
692
+ }
693
+ i--;
694
+ }
695
+ if (index != null) {
696
+ inputEl.setSelectionRange(index + 1, index + 1);
697
+ }
698
+ else {
699
+ i = selectionStart;
700
+ while (i < valueLength) {
701
+ ch = inputValue.charAt(i);
702
+ if (isNumeralChar(ch)) {
703
+ index = i + prefixLength;
704
+ break;
705
+ }
706
+ i++;
707
+ }
708
+ if (index != null) {
709
+ inputEl.setSelectionRange(index, index);
710
+ }
711
+ }
712
+ return index ?? 0;
713
+ };
714
+ const onInputPointerDown = () => {
715
+ isFocusedByClick.current = true;
716
+ };
717
+ const onInputClick = () => {
718
+ initCursor();
719
+ };
720
+ const onInput = (event) => {
721
+ if (props.disabled || props.readOnly)
722
+ return;
723
+ if (utilsIsSpecialChar.current) {
724
+ event.currentTarget.value = lastValue.current;
725
+ utilsIsSpecialChar.current = false;
726
+ }
727
+ // Chrome accent-dead fix is in nativeEvent.data; we can skip deep check here
728
+ };
729
+ // track special char for alt/ctrl/meta + keys
730
+ const utilsIsSpecialChar = React.useRef(false);
731
+ const onInputAndroidKey = (event) => {
732
+ const isAndroid = /Android/i.test(navigator.userAgent);
733
+ if (!isAndroid || props.disabled || props.readOnly)
734
+ return;
735
+ props.onKeyUp?.(event);
736
+ if (event.defaultPrevented)
737
+ return;
738
+ const code = event.which || event.keyCode;
739
+ if (code !== 13) {
740
+ event.preventDefault();
741
+ }
742
+ const ch = String.fromCharCode(code);
743
+ const decimal = isDecimalSign(ch);
744
+ const minus = isMinusSign(ch);
745
+ if ((code >= 48 && code <= 57) || minus || decimal) {
746
+ insert(event, ch, { isDecimalSign: decimal, isMinusSign: minus });
747
+ }
748
+ else {
749
+ const inputVal = event.target.value;
750
+ updateValue(event, inputVal, null, "delete-single");
751
+ }
752
+ };
753
+ const onInputKeyDown = (event) => {
754
+ if (props.disabled || props.readOnly)
755
+ return;
756
+ if (event.altKey || event.ctrlKey || event.metaKey) {
757
+ // cut is treated as normal char
758
+ if (event.key.toLowerCase() === "x" && (event.ctrlKey || event.metaKey)) {
759
+ utilsIsSpecialChar.current = false;
760
+ }
761
+ else {
762
+ utilsIsSpecialChar.current = true;
763
+ }
764
+ return;
765
+ }
766
+ props.onKeyDown?.(event);
767
+ if (event.defaultPrevented)
768
+ return;
769
+ const inputEl = event.currentTarget;
770
+ lastValue.current = inputEl.value;
771
+ const isAndroid = /Android/i.test(navigator.userAgent);
772
+ if (isAndroid)
773
+ return;
774
+ let selectionStart = inputEl.selectionStart ?? 0;
775
+ let selectionEnd = inputEl.selectionEnd ?? 0;
776
+ const inputValue = inputEl.value;
777
+ let newValueStr = null;
778
+ switch (event.code) {
779
+ case "ArrowUp":
780
+ spin(event, 1);
781
+ event.preventDefault();
782
+ break;
783
+ case "ArrowDown":
784
+ spin(event, -1);
785
+ event.preventDefault();
786
+ break;
787
+ case "ArrowLeft": {
788
+ const charPrev = inputValue.charAt(selectionStart - 1);
789
+ if (!isNumeralChar(charPrev)) {
790
+ event.preventDefault();
791
+ }
792
+ break;
793
+ }
794
+ case "ArrowRight": {
795
+ const charNext = inputValue.charAt(selectionStart);
796
+ if (!isNumeralChar(charNext)) {
797
+ event.preventDefault();
798
+ }
799
+ break;
800
+ }
801
+ case "Tab":
802
+ case "Enter":
803
+ case "NumpadEnter": {
804
+ const parsedVal = validateValue(parseValue(inputValue));
805
+ inputRef.current.value = formatValue(parsedVal);
806
+ inputRef.current.setAttribute("aria-valuenow", parsedVal == null ? "" : String(parsedVal));
807
+ updateModel(event, parsedVal);
808
+ break;
809
+ }
810
+ case "Backspace": {
811
+ event.preventDefault();
812
+ if (selectionStart === selectionEnd) {
813
+ const deleteChar = inputValue.charAt(selectionStart - 1);
814
+ if (isNumeralChar(deleteChar)) {
815
+ const { decimalCharIndex, decimalCharIndexWithoutPrefix, } = getDecimalCharIndexes(inputValue);
816
+ const decimalLength = getDecimalLength(inputValue);
817
+ if (_group.current.test(deleteChar)) {
818
+ _group.current.lastIndex = 0;
819
+ newValueStr =
820
+ inputValue.slice(0, selectionStart - 2) + inputValue.slice(selectionStart - 1);
821
+ }
822
+ else if (_decimal.current.test(deleteChar)) {
823
+ _decimal.current.lastIndex = 0;
824
+ if (decimalLength) {
825
+ inputRef.current.setSelectionRange(selectionStart - 1, selectionStart - 1);
826
+ }
827
+ else {
828
+ newValueStr =
829
+ inputValue.slice(0, selectionStart - 1) + inputValue.slice(selectionStart);
830
+ }
831
+ }
832
+ else if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) {
833
+ const insertedText = isDecimalMode() && (props.minFractionDigits || 0) < decimalLength ? "" : "0";
834
+ newValueStr =
835
+ inputValue.slice(0, selectionStart - 1) +
836
+ insertedText +
837
+ inputValue.slice(selectionStart);
838
+ }
839
+ else if (decimalCharIndexWithoutPrefix === 1) {
840
+ newValueStr =
841
+ inputValue.slice(0, selectionStart - 1) +
842
+ "0" +
843
+ inputValue.slice(selectionStart);
844
+ newValueStr = parseValue(newValueStr) > 0 ? newValueStr : "";
845
+ }
846
+ else {
847
+ newValueStr =
848
+ inputValue.slice(0, selectionStart - 1) + inputValue.slice(selectionStart);
849
+ }
850
+ }
851
+ else if (_currency.current.test(deleteChar)) {
852
+ const { minusCharIndex, currencyCharIndex, } = getCharIndexes(inputValue);
853
+ if (minusCharIndex === currencyCharIndex - 1) {
854
+ newValueStr =
855
+ inputValue.slice(0, minusCharIndex) + inputValue.slice(selectionStart);
856
+ }
857
+ }
858
+ updateValue(event, newValueStr, null, "delete-single");
859
+ }
860
+ else {
861
+ newValueStr = deleteRange(inputValue, selectionStart, selectionEnd);
862
+ updateValue(event, newValueStr, null, "delete-range");
863
+ }
864
+ break;
865
+ }
866
+ case "Delete": {
867
+ event.preventDefault();
868
+ if (selectionStart === selectionEnd) {
869
+ const deleteChar = inputValue.charAt(selectionStart);
870
+ const { decimalCharIndex, decimalCharIndexWithoutPrefix, } = getDecimalCharIndexes(inputValue);
871
+ if (isNumeralChar(deleteChar)) {
872
+ const decimalLength = getDecimalLength(inputValue);
873
+ if (_group.current.test(deleteChar)) {
874
+ _group.current.lastIndex = 0;
875
+ newValueStr =
876
+ inputValue.slice(0, selectionStart) + inputValue.slice(selectionStart + 2);
877
+ }
878
+ else if (_decimal.current.test(deleteChar)) {
879
+ _decimal.current.lastIndex = 0;
880
+ if (decimalLength) {
881
+ inputRef.current.setSelectionRange(selectionStart + 1, selectionStart + 1);
882
+ }
883
+ else {
884
+ newValueStr =
885
+ inputValue.slice(0, selectionStart) + inputValue.slice(selectionStart + 1);
886
+ }
887
+ }
888
+ else if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) {
889
+ const insertedText = isDecimalMode() && (props.minFractionDigits || 0) < decimalLength ? "" : "0";
890
+ newValueStr =
891
+ inputValue.slice(0, selectionStart) +
892
+ insertedText +
893
+ inputValue.slice(selectionStart + 1);
894
+ }
895
+ else if (decimalCharIndexWithoutPrefix === 1) {
896
+ newValueStr =
897
+ inputValue.slice(0, selectionStart) +
898
+ "0" +
899
+ inputValue.slice(selectionStart + 1);
900
+ newValueStr = parseValue(newValueStr) > 0 ? newValueStr : "";
901
+ }
902
+ else {
903
+ newValueStr =
904
+ inputValue.slice(0, selectionStart) + inputValue.slice(selectionStart + 1);
905
+ }
906
+ }
907
+ updateValue(event, newValueStr, null, "delete-back-single");
908
+ }
909
+ else {
910
+ newValueStr = deleteRange(inputValue, selectionStart, selectionEnd);
911
+ updateValue(event, newValueStr, null, "delete-range");
912
+ }
913
+ break;
914
+ }
915
+ case "End":
916
+ event.preventDefault();
917
+ if (props.max != null) {
918
+ updateModel(event, props.max);
919
+ updateInputValue(props.max);
920
+ }
921
+ break;
922
+ case "Home":
923
+ event.preventDefault();
924
+ if (props.min != null) {
925
+ updateModel(event, props.min);
926
+ updateInputValue(props.min);
927
+ }
928
+ break;
929
+ default: {
930
+ event.preventDefault();
931
+ let ch = event.key;
932
+ if (!ch)
933
+ break;
934
+ if (ch === ".") {
935
+ ch = _decimalSeparator.current;
936
+ }
937
+ const decimal = isDecimalSign(ch);
938
+ const minus = isMinusSign(ch);
939
+ if ((ch >= "0" && ch <= "9") || minus || decimal) {
940
+ insert(event, ch, { isDecimalSign: decimal, isMinusSign: minus });
941
+ }
942
+ break;
943
+ }
944
+ }
945
+ };
946
+ const onPaste = (event) => {
947
+ event.preventDefault();
948
+ if (props.disabled || props.readOnly)
949
+ return;
950
+ const data = (event.clipboardData || window.clipboardData).getData("Text");
951
+ if (!data)
952
+ return;
953
+ const filteredData = parseValue(data);
954
+ if (filteredData != null) {
955
+ if (typeof filteredData === "number" && isFloat(filteredData)) {
956
+ const formatted = formatValue(filteredData);
957
+ if (inputRef.current) {
958
+ inputRef.current.value = formatted;
959
+ }
960
+ updateModel(event, filteredData);
961
+ }
962
+ else {
963
+ insert(event, String(filteredData));
964
+ }
965
+ }
966
+ };
967
+ const onInputFocus = (event) => {
968
+ setFocusedState(true);
969
+ props.onFocus?.(event);
970
+ if ((props.suffix || props.currency || props.prefix) && inputRef.current && !isFocusedByClick.current) {
971
+ const inputValue = inputRef.current.value;
972
+ const prefixLength = (prefixChar.current || "").length;
973
+ const suffixLength = (suffixChar.current || "").length;
974
+ const end = inputValue.length === 0 ? 0 : inputValue.length - suffixLength;
975
+ inputRef.current.setSelectionRange(prefixLength, end);
976
+ }
977
+ };
978
+ const onInputBlur = (event) => {
979
+ setFocusedState(false);
980
+ isFocusedByClick.current = false;
981
+ if (inputRef.current) {
982
+ const currentValue = inputRef.current.value;
983
+ if (isValueChanged(currentValue, props.value ?? null)) {
984
+ const newValue = validateValue(parseValue(currentValue));
985
+ updateInputValue(newValue);
986
+ updateModel(event, newValue);
987
+ }
988
+ }
989
+ props.onBlur?.(event);
990
+ };
991
+ const changeValue = () => {
992
+ const val = validateValueByLimit(props.value);
993
+ updateInputValue(props.format ? val : replaceDecimalSeparator(val));
994
+ const newValue = validateValue(props.value);
995
+ if (props.value != null && props.value !== newValue) {
996
+ updateModel(null, newValue);
997
+ }
998
+ };
999
+ React.useImperativeHandle(ref, () => inputRef.current);
1000
+ // attach provided inputRef
1001
+ React.useEffect(() => {
1002
+ if (props.inputRef) {
1003
+ if (typeof props.inputRef === "function") {
1004
+ props.inputRef(inputRef.current);
1005
+ }
1006
+ else {
1007
+ props.inputRef.current =
1008
+ inputRef.current;
1009
+ }
1010
+ }
1011
+ }, [props.inputRef]);
1012
+ // unmount cleanup
1013
+ React.useEffect(() => () => {
1014
+ clearTimer();
1015
+ }, []);
1016
+ // mount init
1017
+ React.useEffect(() => {
1018
+ constructParser();
1019
+ const newValue = validateValue(props.value);
1020
+ if (props.value != null && props.value !== newValue) {
1021
+ updateModel(null, newValue);
1022
+ }
1023
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1024
+ }, []);
1025
+ // update on locale/options changes
1026
+ React.useEffect(() => {
1027
+ constructParser();
1028
+ changeValue();
1029
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1030
+ }, [
1031
+ _locale,
1032
+ props.locale,
1033
+ props.localeMatcher,
1034
+ props.mode,
1035
+ props.currency,
1036
+ props.currencyDisplay,
1037
+ props.useGrouping,
1038
+ props.minFractionDigits,
1039
+ props.maxFractionDigits,
1040
+ props.suffix,
1041
+ props.prefix,
1042
+ ]);
1043
+ // update on value changes
1044
+ React.useEffect(() => {
1045
+ changeValue();
1046
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1047
+ }, [props.value]);
1048
+ // disable timer if disabled
1049
+ React.useEffect(() => {
1050
+ if (props.disabled)
1051
+ clearTimer();
1052
+ }, [props.disabled]);
1053
+ // ---- render ----
1054
+ const inputClassName = [
1055
+ props.inputClassName,
1056
+ props.invalid ? "p-invalid" : undefined,
1057
+ ]
1058
+ .filter(Boolean)
1059
+ .join(" ");
1060
+ const valueToRender = formattedValue(props.value ?? null);
1061
+ // Destructure once near the top of your render/component:
1062
+ const { inputId, inputStyle, leadingControl, trailingControl, leadingControlClassName, trailingControlClassName, value, icon, iconGap,
1063
+ // anything you *don’t* want to pass down can be pulled out here too
1064
+ // e.g. internal-only props
1065
+ ...passThroughProps // everything else goes straight to ShadcnTextVariant
1066
+ } = props;
1067
+ return (
1068
+ //@ts-ignore
1069
+ _jsx(Input, { value: value, ref: inputRef, ...passThroughProps,
1070
+ // 2. override / shape the ones we control
1071
+ id: inputId ?? props.id, style: inputStyle ?? props.style, role: "spinbutton", className: inputClassName || props.className, defaultValue: valueToRender, type: props.type ?? "text", inputMode: inputMode,
1072
+ // 3. internal event handlers (your logic wins over anything from props)
1073
+ onKeyDown: onInputKeyDown, onKeyPress: onInputAndroidKey, onInput: onInput, onClick: onInputClick, onPointerDown: onInputPointerDown, onBlur: onInputBlur, onFocus: onInputFocus, onPaste: onPaste,
1074
+ // 4. controls / adornments
1075
+ leadingControl: leadingControl, trailingControl: trailingControl, leadingControlClassName: leadingControlClassName, trailingControlClassName: trailingControlClassName, icon: icon, iconGap: iconGap }));
1076
+ }));
1077
+ InputNumber.displayName = "InputNumber";
1078
+ //# sourceMappingURL=number.js.map