@timeax/form-palette 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (425) hide show
  1. package/dist/{schema/adapter.d.ts → adapters.d.mts} +116 -13
  2. package/dist/adapters.d.ts +292 -0
  3. package/dist/adapters.js +13283 -0
  4. package/dist/adapters.js.map +1 -0
  5. package/dist/adapters.mjs +13269 -0
  6. package/dist/adapters.mjs.map +1 -0
  7. package/dist/index.d.mts +3828 -0
  8. package/dist/index.d.ts +3828 -15
  9. package/dist/index.js +43013 -25
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +42965 -0
  12. package/dist/index.mjs.map +1 -0
  13. package/package.json +22 -7
  14. package/dist/adapters/axios.d.ts +0 -21
  15. package/dist/adapters/axios.d.ts.map +0 -1
  16. package/dist/adapters/axios.js +0 -74
  17. package/dist/adapters/axios.js.map +0 -1
  18. package/dist/adapters/index.d.ts +0 -35
  19. package/dist/adapters/index.d.ts.map +0 -1
  20. package/dist/adapters/index.js +0 -74
  21. package/dist/adapters/index.js.map +0 -1
  22. package/dist/adapters/inertia.d.ts +0 -24
  23. package/dist/adapters/inertia.d.ts.map +0 -1
  24. package/dist/adapters/inertia.js +0 -126
  25. package/dist/adapters/inertia.js.map +0 -1
  26. package/dist/core/adapter-registry.d.ts +0 -30
  27. package/dist/core/adapter-registry.d.ts.map +0 -1
  28. package/dist/core/adapter-registry.js +0 -69
  29. package/dist/core/adapter-registry.js.map +0 -1
  30. package/dist/core/bound/bind-host.d.ts +0 -13
  31. package/dist/core/bound/bind-host.d.ts.map +0 -1
  32. package/dist/core/bound/bind-host.js +0 -2
  33. package/dist/core/bound/bind-host.js.map +0 -1
  34. package/dist/core/bound/observe-bound-field.d.ts +0 -21
  35. package/dist/core/bound/observe-bound-field.d.ts.map +0 -1
  36. package/dist/core/bound/observe-bound-field.js +0 -116
  37. package/dist/core/bound/observe-bound-field.js.map +0 -1
  38. package/dist/core/bound/wait-for-bound-field.d.ts +0 -5
  39. package/dist/core/bound/wait-for-bound-field.d.ts.map +0 -1
  40. package/dist/core/bound/wait-for-bound-field.js +0 -35
  41. package/dist/core/bound/wait-for-bound-field.js.map +0 -1
  42. package/dist/core/context.d.ts +0 -19
  43. package/dist/core/context.d.ts.map +0 -1
  44. package/dist/core/context.js +0 -11
  45. package/dist/core/context.js.map +0 -1
  46. package/dist/core/core-provider.d.ts +0 -22
  47. package/dist/core/core-provider.d.ts.map +0 -1
  48. package/dist/core/core-provider.js +0 -663
  49. package/dist/core/core-provider.js.map +0 -1
  50. package/dist/core/core-root.d.ts +0 -26
  51. package/dist/core/core-root.d.ts.map +0 -1
  52. package/dist/core/core-root.js +0 -38
  53. package/dist/core/core-root.js.map +0 -1
  54. package/dist/core/core-shell.d.ts +0 -22
  55. package/dist/core/core-shell.d.ts.map +0 -1
  56. package/dist/core/core-shell.js +0 -8
  57. package/dist/core/core-shell.js.map +0 -1
  58. package/dist/core/errors/error-strip.d.ts +0 -34
  59. package/dist/core/errors/error-strip.d.ts.map +0 -1
  60. package/dist/core/errors/error-strip.js +0 -18
  61. package/dist/core/errors/error-strip.js.map +0 -1
  62. package/dist/core/errors/index.d.ts +0 -4
  63. package/dist/core/errors/index.d.ts.map +0 -1
  64. package/dist/core/errors/index.js +0 -4
  65. package/dist/core/errors/index.js.map +0 -1
  66. package/dist/core/errors/map-error-bag.d.ts +0 -24
  67. package/dist/core/errors/map-error-bag.d.ts.map +0 -1
  68. package/dist/core/errors/map-error-bag.js +0 -39
  69. package/dist/core/errors/map-error-bag.js.map +0 -1
  70. package/dist/core/errors/map-zod.d.ts +0 -18
  71. package/dist/core/errors/map-zod.d.ts.map +0 -1
  72. package/dist/core/errors/map-zod.js +0 -27
  73. package/dist/core/errors/map-zod.js.map +0 -1
  74. package/dist/core/hooks/use-button.d.ts +0 -73
  75. package/dist/core/hooks/use-button.d.ts.map +0 -1
  76. package/dist/core/hooks/use-button.js +0 -116
  77. package/dist/core/hooks/use-button.js.map +0 -1
  78. package/dist/core/hooks/use-core-context.d.ts +0 -9
  79. package/dist/core/hooks/use-core-context.d.ts.map +0 -1
  80. package/dist/core/hooks/use-core-context.js +0 -17
  81. package/dist/core/hooks/use-core-context.js.map +0 -1
  82. package/dist/core/hooks/use-core-utility.d.ts +0 -1
  83. package/dist/core/hooks/use-core-utility.d.ts.map +0 -1
  84. package/dist/core/hooks/use-core-utility.js +0 -2
  85. package/dist/core/hooks/use-core-utility.js.map +0 -1
  86. package/dist/core/hooks/use-core.d.ts +0 -9
  87. package/dist/core/hooks/use-core.d.ts.map +0 -1
  88. package/dist/core/hooks/use-core.js +0 -11
  89. package/dist/core/hooks/use-core.js.map +0 -1
  90. package/dist/core/hooks/use-field.d.ts +0 -141
  91. package/dist/core/hooks/use-field.d.ts.map +0 -1
  92. package/dist/core/hooks/use-field.js +0 -256
  93. package/dist/core/hooks/use-field.js.map +0 -1
  94. package/dist/core/hooks/use-optional-field.d.ts +0 -9
  95. package/dist/core/hooks/use-optional-field.d.ts.map +0 -1
  96. package/dist/core/hooks/use-optional-field.js +0 -146
  97. package/dist/core/hooks/use-optional-field.js.map +0 -1
  98. package/dist/core/index.d.ts +0 -11
  99. package/dist/core/index.d.ts.map +0 -1
  100. package/dist/core/index.js +0 -11
  101. package/dist/core/index.js.map +0 -1
  102. package/dist/core/registry/binder-registry.d.ts +0 -38
  103. package/dist/core/registry/binder-registry.d.ts.map +0 -1
  104. package/dist/core/registry/binder-registry.js +0 -52
  105. package/dist/core/registry/binder-registry.js.map +0 -1
  106. package/dist/core/registry/field-registry.d.ts +0 -86
  107. package/dist/core/registry/field-registry.d.ts.map +0 -1
  108. package/dist/core/registry/field-registry.js +0 -173
  109. package/dist/core/registry/field-registry.js.map +0 -1
  110. package/dist/core/test.d.ts +0 -2
  111. package/dist/core/test.d.ts.map +0 -1
  112. package/dist/core/test.js +0 -9
  113. package/dist/core/test.js.map +0 -1
  114. package/dist/index.d.ts.map +0 -1
  115. package/dist/input/index.d.ts +0 -3
  116. package/dist/input/index.d.ts.map +0 -1
  117. package/dist/input/index.js +0 -3
  118. package/dist/input/index.js.map +0 -1
  119. package/dist/input/input-field.d.ts +0 -15
  120. package/dist/input/input-field.d.ts.map +0 -1
  121. package/dist/input/input-field.js +0 -413
  122. package/dist/input/input-field.js.map +0 -1
  123. package/dist/input/input-layout-graph.d.ts +0 -77
  124. package/dist/input/input-layout-graph.d.ts.map +0 -1
  125. package/dist/input/input-layout-graph.js +0 -108
  126. package/dist/input/input-layout-graph.js.map +0 -1
  127. package/dist/input/input-props.d.ts +0 -128
  128. package/dist/input/input-props.d.ts.map +0 -1
  129. package/dist/input/input-props.js +0 -4
  130. package/dist/input/input-props.js.map +0 -1
  131. package/dist/lib/get-global-countries.d.ts +0 -3
  132. package/dist/lib/get-global-countries.d.ts.map +0 -1
  133. package/dist/lib/get-global-countries.js +0 -70
  134. package/dist/lib/get-global-countries.js.map +0 -1
  135. package/dist/lib/utils.d.ts +0 -3
  136. package/dist/lib/utils.d.ts.map +0 -1
  137. package/dist/lib/utils.js +0 -6
  138. package/dist/lib/utils.js.map +0 -1
  139. package/dist/presets/index.d.ts +0 -1
  140. package/dist/presets/index.d.ts.map +0 -1
  141. package/dist/presets/index.js +0 -2
  142. package/dist/presets/index.js.map +0 -1
  143. package/dist/presets/shadcn-preset.d.ts +0 -1
  144. package/dist/presets/shadcn-preset.d.ts.map +0 -1
  145. package/dist/presets/shadcn-preset.js +0 -2
  146. package/dist/presets/shadcn-preset.js.map +0 -1
  147. package/dist/presets/shadcn-variants/checkbox.d.ts +0 -212
  148. package/dist/presets/shadcn-variants/checkbox.d.ts.map +0 -1
  149. package/dist/presets/shadcn-variants/checkbox.js +0 -315
  150. package/dist/presets/shadcn-variants/checkbox.js.map +0 -1
  151. package/dist/presets/shadcn-variants/chips.d.ts +0 -154
  152. package/dist/presets/shadcn-variants/chips.d.ts.map +0 -1
  153. package/dist/presets/shadcn-variants/chips.js +0 -266
  154. package/dist/presets/shadcn-variants/chips.js.map +0 -1
  155. package/dist/presets/shadcn-variants/color.d.ts +0 -63
  156. package/dist/presets/shadcn-variants/color.d.ts.map +0 -1
  157. package/dist/presets/shadcn-variants/color.js +0 -96
  158. package/dist/presets/shadcn-variants/color.js.map +0 -1
  159. package/dist/presets/shadcn-variants/custom.d.ts +0 -94
  160. package/dist/presets/shadcn-variants/custom.d.ts.map +0 -1
  161. package/dist/presets/shadcn-variants/custom.js +0 -80
  162. package/dist/presets/shadcn-variants/custom.js.map +0 -1
  163. package/dist/presets/shadcn-variants/date.d.ts +0 -114
  164. package/dist/presets/shadcn-variants/date.d.ts.map +0 -1
  165. package/dist/presets/shadcn-variants/date.js +0 -414
  166. package/dist/presets/shadcn-variants/date.js.map +0 -1
  167. package/dist/presets/shadcn-variants/file.d.ts +0 -79
  168. package/dist/presets/shadcn-variants/file.d.ts.map +0 -1
  169. package/dist/presets/shadcn-variants/file.js +0 -289
  170. package/dist/presets/shadcn-variants/file.js.map +0 -1
  171. package/dist/presets/shadcn-variants/keyvalue.d.ts +0 -35
  172. package/dist/presets/shadcn-variants/keyvalue.d.ts.map +0 -1
  173. package/dist/presets/shadcn-variants/keyvalue.js +0 -215
  174. package/dist/presets/shadcn-variants/keyvalue.js.map +0 -1
  175. package/dist/presets/shadcn-variants/multiselect.d.ts +0 -210
  176. package/dist/presets/shadcn-variants/multiselect.d.ts.map +0 -1
  177. package/dist/presets/shadcn-variants/multiselect.js +0 -352
  178. package/dist/presets/shadcn-variants/multiselect.js.map +0 -1
  179. package/dist/presets/shadcn-variants/number.d.ts +0 -31
  180. package/dist/presets/shadcn-variants/number.d.ts.map +0 -1
  181. package/dist/presets/shadcn-variants/number.js +0 -64
  182. package/dist/presets/shadcn-variants/number.js.map +0 -1
  183. package/dist/presets/shadcn-variants/password.d.ts +0 -195
  184. package/dist/presets/shadcn-variants/password.d.ts.map +0 -1
  185. package/dist/presets/shadcn-variants/password.js +0 -296
  186. package/dist/presets/shadcn-variants/password.js.map +0 -1
  187. package/dist/presets/shadcn-variants/phone.d.ts +0 -69
  188. package/dist/presets/shadcn-variants/phone.d.ts.map +0 -1
  189. package/dist/presets/shadcn-variants/phone.js +0 -308
  190. package/dist/presets/shadcn-variants/phone.js.map +0 -1
  191. package/dist/presets/shadcn-variants/radio.d.ts +0 -172
  192. package/dist/presets/shadcn-variants/radio.d.ts.map +0 -1
  193. package/dist/presets/shadcn-variants/radio.js +0 -192
  194. package/dist/presets/shadcn-variants/radio.js.map +0 -1
  195. package/dist/presets/shadcn-variants/select.d.ts +0 -203
  196. package/dist/presets/shadcn-variants/select.d.ts.map +0 -1
  197. package/dist/presets/shadcn-variants/select.js +0 -285
  198. package/dist/presets/shadcn-variants/select.js.map +0 -1
  199. package/dist/presets/shadcn-variants/slider.d.ts +0 -131
  200. package/dist/presets/shadcn-variants/slider.d.ts.map +0 -1
  201. package/dist/presets/shadcn-variants/slider.js +0 -151
  202. package/dist/presets/shadcn-variants/slider.js.map +0 -1
  203. package/dist/presets/shadcn-variants/text.d.ts +0 -155
  204. package/dist/presets/shadcn-variants/text.d.ts.map +0 -1
  205. package/dist/presets/shadcn-variants/text.js +0 -98
  206. package/dist/presets/shadcn-variants/text.js.map +0 -1
  207. package/dist/presets/shadcn-variants/textarea.d.ts +0 -18
  208. package/dist/presets/shadcn-variants/textarea.d.ts.map +0 -1
  209. package/dist/presets/shadcn-variants/textarea.js +0 -24
  210. package/dist/presets/shadcn-variants/textarea.js.map +0 -1
  211. package/dist/presets/shadcn-variants/toggle.d.ts +0 -61
  212. package/dist/presets/shadcn-variants/toggle.d.ts.map +0 -1
  213. package/dist/presets/shadcn-variants/toggle.js +0 -67
  214. package/dist/presets/shadcn-variants/toggle.js.map +0 -1
  215. package/dist/presets/shadcn-variants/treeselect.d.ts +0 -81
  216. package/dist/presets/shadcn-variants/treeselect.d.ts.map +0 -1
  217. package/dist/presets/shadcn-variants/treeselect.js +0 -317
  218. package/dist/presets/shadcn-variants/treeselect.js.map +0 -1
  219. package/dist/presets/ui/badge.d.ts +0 -10
  220. package/dist/presets/ui/badge.d.ts.map +0 -1
  221. package/dist/presets/ui/badge.js +0 -23
  222. package/dist/presets/ui/badge.js.map +0 -1
  223. package/dist/presets/ui/button.d.ts +0 -11
  224. package/dist/presets/ui/button.d.ts.map +0 -1
  225. package/dist/presets/ui/button.js +0 -34
  226. package/dist/presets/ui/button.js.map +0 -1
  227. package/dist/presets/ui/calendar.d.ts +0 -9
  228. package/dist/presets/ui/calendar.d.ts.map +0 -1
  229. package/dist/presets/ui/calendar.js +0 -76
  230. package/dist/presets/ui/calendar.js.map +0 -1
  231. package/dist/presets/ui/checkbox.d.ts +0 -18
  232. package/dist/presets/ui/checkbox.d.ts.map +0 -1
  233. package/dist/presets/ui/checkbox.js +0 -61
  234. package/dist/presets/ui/checkbox.js.map +0 -1
  235. package/dist/presets/ui/custom.d.ts +0 -1
  236. package/dist/presets/ui/custom.d.ts.map +0 -1
  237. package/dist/presets/ui/custom.js +0 -2
  238. package/dist/presets/ui/custom.js.map +0 -1
  239. package/dist/presets/ui/dialog.d.ts +0 -16
  240. package/dist/presets/ui/dialog.d.ts.map +0 -1
  241. package/dist/presets/ui/dialog.js +0 -36
  242. package/dist/presets/ui/dialog.js.map +0 -1
  243. package/dist/presets/ui/field.d.ts +0 -25
  244. package/dist/presets/ui/field.d.ts.map +0 -1
  245. package/dist/presets/ui/field.js +0 -76
  246. package/dist/presets/ui/field.js.map +0 -1
  247. package/dist/presets/ui/input-mask.d.ts +0 -34
  248. package/dist/presets/ui/input-mask.d.ts.map +0 -1
  249. package/dist/presets/ui/input-mask.js +0 -561
  250. package/dist/presets/ui/input-mask.js.map +0 -1
  251. package/dist/presets/ui/input-otp.d.ts +0 -12
  252. package/dist/presets/ui/input-otp.d.ts.map +0 -1
  253. package/dist/presets/ui/input-otp.js +0 -22
  254. package/dist/presets/ui/input-otp.js.map +0 -1
  255. package/dist/presets/ui/input.d.ts +0 -83
  256. package/dist/presets/ui/input.d.ts.map +0 -1
  257. package/dist/presets/ui/input.js +0 -436
  258. package/dist/presets/ui/input.js.map +0 -1
  259. package/dist/presets/ui/label.d.ts +0 -5
  260. package/dist/presets/ui/label.d.ts.map +0 -1
  261. package/dist/presets/ui/label.js +0 -8
  262. package/dist/presets/ui/label.js.map +0 -1
  263. package/dist/presets/ui/number.d.ts +0 -60
  264. package/dist/presets/ui/number.d.ts.map +0 -1
  265. package/dist/presets/ui/number.js +0 -1078
  266. package/dist/presets/ui/number.js.map +0 -1
  267. package/dist/presets/ui/popover.d.ts +0 -8
  268. package/dist/presets/ui/popover.d.ts.map +0 -1
  269. package/dist/presets/ui/popover.js +0 -17
  270. package/dist/presets/ui/popover.js.map +0 -1
  271. package/dist/presets/ui/radio-group.d.ts +0 -6
  272. package/dist/presets/ui/radio-group.d.ts.map +0 -1
  273. package/dist/presets/ui/radio-group.js +0 -12
  274. package/dist/presets/ui/radio-group.js.map +0 -1
  275. package/dist/presets/ui/scroll-area.d.ts +0 -6
  276. package/dist/presets/ui/scroll-area.d.ts.map +0 -1
  277. package/dist/presets/ui/scroll-area.js +0 -13
  278. package/dist/presets/ui/scroll-area.js.map +0 -1
  279. package/dist/presets/ui/select.d.ts +0 -21
  280. package/dist/presets/ui/select.d.ts.map +0 -1
  281. package/dist/presets/ui/select.js +0 -38
  282. package/dist/presets/ui/select.js.map +0 -1
  283. package/dist/presets/ui/separator.d.ts +0 -5
  284. package/dist/presets/ui/separator.d.ts.map +0 -1
  285. package/dist/presets/ui/separator.js +0 -9
  286. package/dist/presets/ui/separator.js.map +0 -1
  287. package/dist/presets/ui/slider.d.ts +0 -5
  288. package/dist/presets/ui/slider.d.ts.map +0 -1
  289. package/dist/presets/ui/slider.js +0 -14
  290. package/dist/presets/ui/slider.js.map +0 -1
  291. package/dist/presets/ui/switch.d.ts +0 -7
  292. package/dist/presets/ui/switch.d.ts.map +0 -1
  293. package/dist/presets/ui/switch.js +0 -9
  294. package/dist/presets/ui/switch.js.map +0 -1
  295. package/dist/presets/ui/textarea.d.ts +0 -76
  296. package/dist/presets/ui/textarea.d.ts.map +0 -1
  297. package/dist/presets/ui/textarea.js +0 -291
  298. package/dist/presets/ui/textarea.js.map +0 -1
  299. package/dist/presets/ui/time-dropdowns.d.ts +0 -58
  300. package/dist/presets/ui/time-dropdowns.d.ts.map +0 -1
  301. package/dist/presets/ui/time-dropdowns.js +0 -133
  302. package/dist/presets/ui/time-dropdowns.js.map +0 -1
  303. package/dist/schema/adapter.d.ts.map +0 -1
  304. package/dist/schema/adapter.js +0 -3
  305. package/dist/schema/adapter.js.map +0 -1
  306. package/dist/schema/core.d.ts +0 -329
  307. package/dist/schema/core.d.ts.map +0 -1
  308. package/dist/schema/core.js +0 -4
  309. package/dist/schema/core.js.map +0 -1
  310. package/dist/schema/field-map.d.ts +0 -1
  311. package/dist/schema/field-map.d.ts.map +0 -1
  312. package/dist/schema/field-map.js +0 -2
  313. package/dist/schema/field-map.js.map +0 -1
  314. package/dist/schema/field.d.ts +0 -191
  315. package/dist/schema/field.d.ts.map +0 -1
  316. package/dist/schema/field.js +0 -4
  317. package/dist/schema/field.js.map +0 -1
  318. package/dist/schema/index.d.ts +0 -1
  319. package/dist/schema/index.d.ts.map +0 -1
  320. package/dist/schema/index.js +0 -2
  321. package/dist/schema/index.js.map +0 -1
  322. package/dist/schema/input-field.d.ts +0 -223
  323. package/dist/schema/input-field.d.ts.map +0 -1
  324. package/dist/schema/input-field.js +0 -3
  325. package/dist/schema/input-field.js.map +0 -1
  326. package/dist/schema/presets.d.ts +0 -1
  327. package/dist/schema/presets.d.ts.map +0 -1
  328. package/dist/schema/presets.js +0 -2
  329. package/dist/schema/presets.js.map +0 -1
  330. package/dist/schema/variant.d.ts +0 -176
  331. package/dist/schema/variant.d.ts.map +0 -1
  332. package/dist/schema/variant.js +0 -3
  333. package/dist/schema/variant.js.map +0 -1
  334. package/dist/variants/core/checkbox.d.ts +0 -15
  335. package/dist/variants/core/checkbox.d.ts.map +0 -1
  336. package/dist/variants/core/checkbox.js +0 -27
  337. package/dist/variants/core/checkbox.js.map +0 -1
  338. package/dist/variants/core/chips.d.ts +0 -3
  339. package/dist/variants/core/chips.d.ts.map +0 -1
  340. package/dist/variants/core/chips.js +0 -20
  341. package/dist/variants/core/chips.js.map +0 -1
  342. package/dist/variants/core/color.d.ts +0 -3
  343. package/dist/variants/core/color.d.ts.map +0 -1
  344. package/dist/variants/core/color.js +0 -14
  345. package/dist/variants/core/color.js.map +0 -1
  346. package/dist/variants/core/custom.d.ts +0 -11
  347. package/dist/variants/core/custom.d.ts.map +0 -1
  348. package/dist/variants/core/custom.js +0 -15
  349. package/dist/variants/core/custom.js.map +0 -1
  350. package/dist/variants/core/date.d.ts +0 -3
  351. package/dist/variants/core/date.d.ts.map +0 -1
  352. package/dist/variants/core/date.js +0 -20
  353. package/dist/variants/core/date.js.map +0 -1
  354. package/dist/variants/core/file.d.ts +0 -3
  355. package/dist/variants/core/file.d.ts.map +0 -1
  356. package/dist/variants/core/file.js +0 -6
  357. package/dist/variants/core/file.js.map +0 -1
  358. package/dist/variants/core/keyvalue.d.ts +0 -3
  359. package/dist/variants/core/keyvalue.d.ts.map +0 -1
  360. package/dist/variants/core/keyvalue.js +0 -9
  361. package/dist/variants/core/keyvalue.js.map +0 -1
  362. package/dist/variants/core/multiselect.d.ts +0 -11
  363. package/dist/variants/core/multiselect.d.ts.map +0 -1
  364. package/dist/variants/core/multiselect.js +0 -15
  365. package/dist/variants/core/multiselect.js.map +0 -1
  366. package/dist/variants/core/number.d.ts +0 -38
  367. package/dist/variants/core/number.d.ts.map +0 -1
  368. package/dist/variants/core/number.js +0 -62
  369. package/dist/variants/core/number.js.map +0 -1
  370. package/dist/variants/core/password.d.ts +0 -11
  371. package/dist/variants/core/password.d.ts.map +0 -1
  372. package/dist/variants/core/password.js +0 -29
  373. package/dist/variants/core/password.js.map +0 -1
  374. package/dist/variants/core/phone.d.ts +0 -3
  375. package/dist/variants/core/phone.d.ts.map +0 -1
  376. package/dist/variants/core/phone.js +0 -14
  377. package/dist/variants/core/phone.js.map +0 -1
  378. package/dist/variants/core/radio.d.ts +0 -8
  379. package/dist/variants/core/radio.d.ts.map +0 -1
  380. package/dist/variants/core/radio.js +0 -34
  381. package/dist/variants/core/radio.js.map +0 -1
  382. package/dist/variants/core/select.d.ts +0 -5
  383. package/dist/variants/core/select.d.ts.map +0 -1
  384. package/dist/variants/core/select.js +0 -11
  385. package/dist/variants/core/select.js.map +0 -1
  386. package/dist/variants/core/slider.d.ts +0 -19
  387. package/dist/variants/core/slider.d.ts.map +0 -1
  388. package/dist/variants/core/slider.js +0 -36
  389. package/dist/variants/core/slider.js.map +0 -1
  390. package/dist/variants/core/text.d.ts +0 -38
  391. package/dist/variants/core/text.d.ts.map +0 -1
  392. package/dist/variants/core/text.js +0 -62
  393. package/dist/variants/core/text.js.map +0 -1
  394. package/dist/variants/core/textarea.d.ts +0 -3
  395. package/dist/variants/core/textarea.d.ts.map +0 -1
  396. package/dist/variants/core/textarea.js +0 -20
  397. package/dist/variants/core/textarea.js.map +0 -1
  398. package/dist/variants/core/toggle.d.ts +0 -6
  399. package/dist/variants/core/toggle.d.ts.map +0 -1
  400. package/dist/variants/core/toggle.js +0 -41
  401. package/dist/variants/core/toggle.js.map +0 -1
  402. package/dist/variants/core/treeselect.d.ts +0 -4
  403. package/dist/variants/core/treeselect.d.ts.map +0 -1
  404. package/dist/variants/core/treeselect.js +0 -7
  405. package/dist/variants/core/treeselect.js.map +0 -1
  406. package/dist/variants/helpers/selection-summary.d.ts +0 -24
  407. package/dist/variants/helpers/selection-summary.d.ts.map +0 -1
  408. package/dist/variants/helpers/selection-summary.js +0 -105
  409. package/dist/variants/helpers/selection-summary.js.map +0 -1
  410. package/dist/variants/index.d.ts +0 -16
  411. package/dist/variants/index.d.ts.map +0 -1
  412. package/dist/variants/index.js +0 -55
  413. package/dist/variants/index.js.map +0 -1
  414. package/dist/variants/registry.d.ts +0 -19
  415. package/dist/variants/registry.d.ts.map +0 -1
  416. package/dist/variants/registry.js +0 -29
  417. package/dist/variants/registry.js.map +0 -1
  418. package/dist/variants/select-shared.d.ts +0 -1
  419. package/dist/variants/select-shared.d.ts.map +0 -1
  420. package/dist/variants/select-shared.js +0 -2
  421. package/dist/variants/select-shared.js.map +0 -1
  422. package/dist/variants/shared.d.ts +0 -107
  423. package/dist/variants/shared.d.ts.map +0 -1
  424. package/dist/variants/shared.js +0 -3
  425. package/dist/variants/shared.js.map +0 -1
@@ -1,1078 +0,0 @@
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