@codefast/ui 0.9.0 → 0.9.2

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 (579) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/LICENSE +1 -1
  3. package/README.md +78 -39
  4. package/dist/components/accordion.d.ts +1 -2
  5. package/dist/components/accordion.js +1 -2
  6. package/dist/components/alert-dialog.d.ts +1 -2
  7. package/dist/components/alert-dialog.js +1 -2
  8. package/dist/components/alert.d.ts +1 -2
  9. package/dist/components/alert.js +1 -2
  10. package/dist/components/aspect-ratio.d.ts +1 -2
  11. package/dist/components/aspect-ratio.js +1 -2
  12. package/dist/components/attachment.d.ts +1 -2
  13. package/dist/components/attachment.js +1 -2
  14. package/dist/components/avatar.d.ts +1 -2
  15. package/dist/components/avatar.js +1 -2
  16. package/dist/components/badge.d.ts +1 -2
  17. package/dist/components/badge.js +1 -2
  18. package/dist/components/breadcrumb.d.ts +1 -2
  19. package/dist/components/breadcrumb.js +1 -2
  20. package/dist/components/bubble.d.ts +1 -2
  21. package/dist/components/bubble.js +1 -2
  22. package/dist/components/button-group.d.ts +1 -2
  23. package/dist/components/button-group.js +1 -2
  24. package/dist/components/button.d.ts +1 -2
  25. package/dist/components/button.js +1 -2
  26. package/dist/components/calendar.d.ts +2 -3
  27. package/dist/components/calendar.js +1 -2
  28. package/dist/components/card.d.ts +1 -2
  29. package/dist/components/card.js +1 -2
  30. package/dist/components/carousel.d.ts +1 -2
  31. package/dist/components/carousel.js +1 -2
  32. package/dist/components/chart.d.ts +1 -2
  33. package/dist/components/chart.js +1 -2
  34. package/dist/components/checkbox-cards.d.ts +1 -2
  35. package/dist/components/checkbox-cards.js +1 -2
  36. package/dist/components/checkbox-group.d.ts +1 -2
  37. package/dist/components/checkbox-group.js +1 -2
  38. package/dist/components/checkbox.d.ts +1 -2
  39. package/dist/components/checkbox.js +1 -2
  40. package/dist/components/collapsible.d.ts +1 -2
  41. package/dist/components/collapsible.js +1 -2
  42. package/dist/components/command.d.ts +1 -2
  43. package/dist/components/command.js +1 -2
  44. package/dist/components/context-menu.d.ts +2 -3
  45. package/dist/components/context-menu.js +3 -4
  46. package/dist/components/dialog.d.ts +1 -2
  47. package/dist/components/dialog.js +1 -2
  48. package/dist/components/direction.d.ts +1 -2
  49. package/dist/components/direction.js +1 -2
  50. package/dist/components/drawer.d.ts +1 -2
  51. package/dist/components/drawer.js +1 -2
  52. package/dist/components/dropdown-menu.d.ts +2 -3
  53. package/dist/components/dropdown-menu.js +3 -4
  54. package/dist/components/empty.d.ts +1 -2
  55. package/dist/components/empty.js +1 -2
  56. package/dist/components/field.d.ts +1 -2
  57. package/dist/components/field.js +1 -2
  58. package/dist/components/form.d.ts +1 -2
  59. package/dist/components/form.js +1 -2
  60. package/dist/components/hover-card.d.ts +1 -2
  61. package/dist/components/hover-card.js +1 -2
  62. package/dist/components/input-group.d.ts +1 -2
  63. package/dist/components/input-group.js +1 -2
  64. package/dist/components/input-number.d.ts +1 -2
  65. package/dist/components/input-number.js +1 -2
  66. package/dist/components/input-otp.d.ts +1 -2
  67. package/dist/components/input-otp.js +1 -2
  68. package/dist/components/input-password.d.ts +1 -2
  69. package/dist/components/input-password.js +1 -2
  70. package/dist/components/input-search.d.ts +1 -2
  71. package/dist/components/input-search.js +2 -3
  72. package/dist/components/input.d.ts +1 -2
  73. package/dist/components/input.js +1 -2
  74. package/dist/components/item.d.ts +1 -2
  75. package/dist/components/item.js +1 -2
  76. package/dist/components/kbd.d.ts +1 -2
  77. package/dist/components/kbd.js +1 -2
  78. package/dist/components/label.d.ts +1 -2
  79. package/dist/components/label.js +1 -2
  80. package/dist/components/marker.d.ts +1 -2
  81. package/dist/components/marker.js +1 -2
  82. package/dist/components/menubar.d.ts +2 -3
  83. package/dist/components/menubar.js +3 -4
  84. package/dist/components/message-scroller.d.ts +1 -2
  85. package/dist/components/message-scroller.js +1 -2
  86. package/dist/components/message.d.ts +1 -2
  87. package/dist/components/message.js +1 -2
  88. package/dist/components/native-select.d.ts +1 -2
  89. package/dist/components/native-select.js +1 -2
  90. package/dist/components/navigation-menu.d.ts +1 -2
  91. package/dist/components/navigation-menu.js +1 -2
  92. package/dist/components/pagination.d.ts +1 -2
  93. package/dist/components/pagination.js +1 -2
  94. package/dist/components/popover.d.ts +1 -2
  95. package/dist/components/popover.js +1 -2
  96. package/dist/components/progress-circle.d.ts +1 -2
  97. package/dist/components/progress-circle.js +1 -2
  98. package/dist/components/progress.d.ts +1 -2
  99. package/dist/components/progress.js +1 -2
  100. package/dist/components/radio-cards.d.ts +1 -2
  101. package/dist/components/radio-cards.js +1 -2
  102. package/dist/components/radio-group.d.ts +1 -2
  103. package/dist/components/radio-group.js +1 -2
  104. package/dist/components/radio.d.ts +1 -2
  105. package/dist/components/radio.js +1 -2
  106. package/dist/components/resizable.d.ts +1 -2
  107. package/dist/components/resizable.js +1 -2
  108. package/dist/components/scroll-area.d.ts +1 -2
  109. package/dist/components/scroll-area.js +2 -3
  110. package/dist/components/select.d.ts +1 -2
  111. package/dist/components/select.js +1 -2
  112. package/dist/components/separator.d.ts +1 -2
  113. package/dist/components/separator.js +2 -3
  114. package/dist/components/sheet.d.ts +1 -2
  115. package/dist/components/sheet.js +1 -2
  116. package/dist/components/sidebar.d.ts +1 -2
  117. package/dist/components/sidebar.js +1 -2
  118. package/dist/components/skeleton.d.ts +1 -2
  119. package/dist/components/skeleton.js +1 -2
  120. package/dist/components/slider.d.ts +1 -2
  121. package/dist/components/slider.js +2 -3
  122. package/dist/components/sonner.d.ts +1 -2
  123. package/dist/components/sonner.js +1 -2
  124. package/dist/components/spinner.d.ts +1 -2
  125. package/dist/components/spinner.js +1 -2
  126. package/dist/components/switch.d.ts +1 -2
  127. package/dist/components/switch.js +1 -2
  128. package/dist/components/table.d.ts +1 -2
  129. package/dist/components/table.js +1 -2
  130. package/dist/components/tabs.d.ts +1 -2
  131. package/dist/components/tabs.js +1 -2
  132. package/dist/components/textarea.d.ts +1 -2
  133. package/dist/components/textarea.js +1 -2
  134. package/dist/components/toggle-group.d.ts +1 -2
  135. package/dist/components/toggle-group.js +1 -2
  136. package/dist/components/toggle.d.ts +1 -2
  137. package/dist/components/toggle.js +1 -2
  138. package/dist/components/tooltip.d.ts +1 -2
  139. package/dist/components/tooltip.js +1 -2
  140. package/dist/hooks/use-animated-value.d.ts +1 -2
  141. package/dist/hooks/use-animated-value.js +1 -2
  142. package/dist/hooks/use-copy-to-clipboard.d.ts +1 -2
  143. package/dist/hooks/use-copy-to-clipboard.js +1 -2
  144. package/dist/hooks/use-has-hydrated.d.ts +1 -2
  145. package/dist/hooks/use-has-hydrated.js +1 -2
  146. package/dist/hooks/use-is-mobile.d.ts +1 -2
  147. package/dist/hooks/use-is-mobile.js +1 -2
  148. package/dist/hooks/use-latest.d.ts +1 -2
  149. package/dist/hooks/use-latest.js +1 -2
  150. package/dist/hooks/use-media-query.d.ts +1 -2
  151. package/dist/hooks/use-media-query.js +1 -2
  152. package/dist/hooks/use-message-scroller-commands.d.ts +1 -2
  153. package/dist/hooks/use-message-scroller-commands.js +1 -2
  154. package/dist/hooks/use-message-scroller-controller.d.ts +1 -2
  155. package/dist/hooks/use-message-scroller-controller.js +1 -2
  156. package/dist/hooks/use-message-scroller-refs.d.ts +2 -3
  157. package/dist/hooks/use-message-scroller-refs.js +1 -2
  158. package/dist/hooks/use-mutation-observer.d.ts +1 -2
  159. package/dist/hooks/use-mutation-observer.js +1 -2
  160. package/dist/hooks/use-pagination.d.ts +1 -2
  161. package/dist/hooks/use-pagination.js +1 -2
  162. package/dist/index.d.ts +1 -2
  163. package/dist/index.js +1 -2
  164. package/dist/lib/message-scroller/geometry.d.ts +1 -2
  165. package/dist/lib/message-scroller/geometry.js +1 -2
  166. package/dist/lib/message-scroller/stores.d.ts +1 -2
  167. package/dist/lib/message-scroller/stores.js +1 -2
  168. package/dist/lib/message-scroller/types.d.ts +4 -5
  169. package/dist/lib/message-scroller/types.js +1 -2
  170. package/dist/lib/use-render.d.ts +2 -3
  171. package/dist/lib/use-render.js +1 -2
  172. package/dist/lib/utils.d.ts +1 -2
  173. package/dist/lib/utils.js +1 -2
  174. package/dist/primitives/checkbox-group.d.ts +2 -3
  175. package/dist/primitives/checkbox-group.js +3 -4
  176. package/dist/primitives/input-number.d.ts +1 -2
  177. package/dist/primitives/input-number.js +2 -3
  178. package/dist/primitives/input.d.ts +1 -2
  179. package/dist/primitives/input.js +1 -2
  180. package/dist/primitives/message-scroller.d.ts +1 -2
  181. package/dist/primitives/message-scroller.js +1 -2
  182. package/dist/primitives/progress-circle.d.ts +1 -2
  183. package/dist/primitives/progress-circle.js +1 -2
  184. package/dist/variants/alert.d.ts +1 -2
  185. package/dist/variants/alert.js +1 -2
  186. package/dist/variants/attachment.d.ts +1 -2
  187. package/dist/variants/attachment.js +1 -2
  188. package/dist/variants/badge.d.ts +1 -2
  189. package/dist/variants/badge.js +1 -2
  190. package/dist/variants/bubble.d.ts +1 -2
  191. package/dist/variants/bubble.js +1 -2
  192. package/dist/variants/button-group.d.ts +1 -2
  193. package/dist/variants/button-group.js +1 -2
  194. package/dist/variants/button.d.ts +1 -2
  195. package/dist/variants/button.js +1 -2
  196. package/dist/variants/empty.d.ts +1 -2
  197. package/dist/variants/empty.js +1 -2
  198. package/dist/variants/field.d.ts +1 -2
  199. package/dist/variants/field.js +1 -2
  200. package/dist/variants/input-group.d.ts +1 -2
  201. package/dist/variants/input-group.js +1 -2
  202. package/dist/variants/item.d.ts +1 -2
  203. package/dist/variants/item.js +1 -2
  204. package/dist/variants/marker.d.ts +1 -2
  205. package/dist/variants/marker.js +1 -2
  206. package/dist/variants/navigation-menu.d.ts +1 -2
  207. package/dist/variants/navigation-menu.js +1 -2
  208. package/dist/variants/progress-circle.d.ts +1 -2
  209. package/dist/variants/progress-circle.js +1 -2
  210. package/dist/variants/scroll-area.d.ts +1 -2
  211. package/dist/variants/scroll-area.js +1 -2
  212. package/dist/variants/separator.d.ts +1 -2
  213. package/dist/variants/separator.js +1 -2
  214. package/dist/variants/sheet.d.ts +1 -2
  215. package/dist/variants/sheet.js +1 -2
  216. package/dist/variants/sidebar.d.ts +1 -2
  217. package/dist/variants/sidebar.js +1 -2
  218. package/dist/variants/tabs.d.ts +1 -2
  219. package/dist/variants/tabs.js +1 -2
  220. package/dist/variants/toggle.d.ts +1 -2
  221. package/dist/variants/toggle.js +1 -2
  222. package/package.json +6 -160
  223. package/dist/components/accordion.d.ts.map +0 -1
  224. package/dist/components/accordion.js.map +0 -1
  225. package/dist/components/alert-dialog.d.ts.map +0 -1
  226. package/dist/components/alert-dialog.js.map +0 -1
  227. package/dist/components/alert.d.ts.map +0 -1
  228. package/dist/components/alert.js.map +0 -1
  229. package/dist/components/aspect-ratio.d.ts.map +0 -1
  230. package/dist/components/aspect-ratio.js.map +0 -1
  231. package/dist/components/attachment.d.ts.map +0 -1
  232. package/dist/components/attachment.js.map +0 -1
  233. package/dist/components/avatar.d.ts.map +0 -1
  234. package/dist/components/avatar.js.map +0 -1
  235. package/dist/components/badge.d.ts.map +0 -1
  236. package/dist/components/badge.js.map +0 -1
  237. package/dist/components/breadcrumb.d.ts.map +0 -1
  238. package/dist/components/breadcrumb.js.map +0 -1
  239. package/dist/components/bubble.d.ts.map +0 -1
  240. package/dist/components/bubble.js.map +0 -1
  241. package/dist/components/button-group.d.ts.map +0 -1
  242. package/dist/components/button-group.js.map +0 -1
  243. package/dist/components/button.d.ts.map +0 -1
  244. package/dist/components/button.js.map +0 -1
  245. package/dist/components/calendar.d.ts.map +0 -1
  246. package/dist/components/calendar.js.map +0 -1
  247. package/dist/components/card.d.ts.map +0 -1
  248. package/dist/components/card.js.map +0 -1
  249. package/dist/components/carousel.d.ts.map +0 -1
  250. package/dist/components/carousel.js.map +0 -1
  251. package/dist/components/chart.d.ts.map +0 -1
  252. package/dist/components/chart.js.map +0 -1
  253. package/dist/components/checkbox-cards.d.ts.map +0 -1
  254. package/dist/components/checkbox-cards.js.map +0 -1
  255. package/dist/components/checkbox-group.d.ts.map +0 -1
  256. package/dist/components/checkbox-group.js.map +0 -1
  257. package/dist/components/checkbox.d.ts.map +0 -1
  258. package/dist/components/checkbox.js.map +0 -1
  259. package/dist/components/collapsible.d.ts.map +0 -1
  260. package/dist/components/collapsible.js.map +0 -1
  261. package/dist/components/command.d.ts.map +0 -1
  262. package/dist/components/command.js.map +0 -1
  263. package/dist/components/context-menu.d.ts.map +0 -1
  264. package/dist/components/context-menu.js.map +0 -1
  265. package/dist/components/dialog.d.ts.map +0 -1
  266. package/dist/components/dialog.js.map +0 -1
  267. package/dist/components/direction.d.ts.map +0 -1
  268. package/dist/components/direction.js.map +0 -1
  269. package/dist/components/drawer.d.ts.map +0 -1
  270. package/dist/components/drawer.js.map +0 -1
  271. package/dist/components/dropdown-menu.d.ts.map +0 -1
  272. package/dist/components/dropdown-menu.js.map +0 -1
  273. package/dist/components/empty.d.ts.map +0 -1
  274. package/dist/components/empty.js.map +0 -1
  275. package/dist/components/field.d.ts.map +0 -1
  276. package/dist/components/field.js.map +0 -1
  277. package/dist/components/form.d.ts.map +0 -1
  278. package/dist/components/form.js.map +0 -1
  279. package/dist/components/hover-card.d.ts.map +0 -1
  280. package/dist/components/hover-card.js.map +0 -1
  281. package/dist/components/input-group.d.ts.map +0 -1
  282. package/dist/components/input-group.js.map +0 -1
  283. package/dist/components/input-number.d.ts.map +0 -1
  284. package/dist/components/input-number.js.map +0 -1
  285. package/dist/components/input-otp.d.ts.map +0 -1
  286. package/dist/components/input-otp.js.map +0 -1
  287. package/dist/components/input-password.d.ts.map +0 -1
  288. package/dist/components/input-password.js.map +0 -1
  289. package/dist/components/input-search.d.ts.map +0 -1
  290. package/dist/components/input-search.js.map +0 -1
  291. package/dist/components/input.d.ts.map +0 -1
  292. package/dist/components/input.js.map +0 -1
  293. package/dist/components/item.d.ts.map +0 -1
  294. package/dist/components/item.js.map +0 -1
  295. package/dist/components/kbd.d.ts.map +0 -1
  296. package/dist/components/kbd.js.map +0 -1
  297. package/dist/components/label.d.ts.map +0 -1
  298. package/dist/components/label.js.map +0 -1
  299. package/dist/components/marker.d.ts.map +0 -1
  300. package/dist/components/marker.js.map +0 -1
  301. package/dist/components/menubar.d.ts.map +0 -1
  302. package/dist/components/menubar.js.map +0 -1
  303. package/dist/components/message-scroller.d.ts.map +0 -1
  304. package/dist/components/message-scroller.js.map +0 -1
  305. package/dist/components/message.d.ts.map +0 -1
  306. package/dist/components/message.js.map +0 -1
  307. package/dist/components/native-select.d.ts.map +0 -1
  308. package/dist/components/native-select.js.map +0 -1
  309. package/dist/components/navigation-menu.d.ts.map +0 -1
  310. package/dist/components/navigation-menu.js.map +0 -1
  311. package/dist/components/pagination.d.ts.map +0 -1
  312. package/dist/components/pagination.js.map +0 -1
  313. package/dist/components/popover.d.ts.map +0 -1
  314. package/dist/components/popover.js.map +0 -1
  315. package/dist/components/progress-circle.d.ts.map +0 -1
  316. package/dist/components/progress-circle.js.map +0 -1
  317. package/dist/components/progress.d.ts.map +0 -1
  318. package/dist/components/progress.js.map +0 -1
  319. package/dist/components/radio-cards.d.ts.map +0 -1
  320. package/dist/components/radio-cards.js.map +0 -1
  321. package/dist/components/radio-group.d.ts.map +0 -1
  322. package/dist/components/radio-group.js.map +0 -1
  323. package/dist/components/radio.d.ts.map +0 -1
  324. package/dist/components/radio.js.map +0 -1
  325. package/dist/components/resizable.d.ts.map +0 -1
  326. package/dist/components/resizable.js.map +0 -1
  327. package/dist/components/scroll-area.d.ts.map +0 -1
  328. package/dist/components/scroll-area.js.map +0 -1
  329. package/dist/components/select.d.ts.map +0 -1
  330. package/dist/components/select.js.map +0 -1
  331. package/dist/components/separator.d.ts.map +0 -1
  332. package/dist/components/separator.js.map +0 -1
  333. package/dist/components/sheet.d.ts.map +0 -1
  334. package/dist/components/sheet.js.map +0 -1
  335. package/dist/components/sidebar.d.ts.map +0 -1
  336. package/dist/components/sidebar.js.map +0 -1
  337. package/dist/components/skeleton.d.ts.map +0 -1
  338. package/dist/components/skeleton.js.map +0 -1
  339. package/dist/components/slider.d.ts.map +0 -1
  340. package/dist/components/slider.js.map +0 -1
  341. package/dist/components/sonner.d.ts.map +0 -1
  342. package/dist/components/sonner.js.map +0 -1
  343. package/dist/components/spinner.d.ts.map +0 -1
  344. package/dist/components/spinner.js.map +0 -1
  345. package/dist/components/switch.d.ts.map +0 -1
  346. package/dist/components/switch.js.map +0 -1
  347. package/dist/components/table.d.ts.map +0 -1
  348. package/dist/components/table.js.map +0 -1
  349. package/dist/components/tabs.d.ts.map +0 -1
  350. package/dist/components/tabs.js.map +0 -1
  351. package/dist/components/textarea.d.ts.map +0 -1
  352. package/dist/components/textarea.js.map +0 -1
  353. package/dist/components/toggle-group.d.ts.map +0 -1
  354. package/dist/components/toggle-group.js.map +0 -1
  355. package/dist/components/toggle.d.ts.map +0 -1
  356. package/dist/components/toggle.js.map +0 -1
  357. package/dist/components/tooltip.d.ts.map +0 -1
  358. package/dist/components/tooltip.js.map +0 -1
  359. package/dist/hooks/use-animated-value.d.ts.map +0 -1
  360. package/dist/hooks/use-animated-value.js.map +0 -1
  361. package/dist/hooks/use-copy-to-clipboard.d.ts.map +0 -1
  362. package/dist/hooks/use-copy-to-clipboard.js.map +0 -1
  363. package/dist/hooks/use-has-hydrated.d.ts.map +0 -1
  364. package/dist/hooks/use-has-hydrated.js.map +0 -1
  365. package/dist/hooks/use-is-mobile.d.ts.map +0 -1
  366. package/dist/hooks/use-is-mobile.js.map +0 -1
  367. package/dist/hooks/use-latest.d.ts.map +0 -1
  368. package/dist/hooks/use-latest.js.map +0 -1
  369. package/dist/hooks/use-media-query.d.ts.map +0 -1
  370. package/dist/hooks/use-media-query.js.map +0 -1
  371. package/dist/hooks/use-message-scroller-commands.d.ts.map +0 -1
  372. package/dist/hooks/use-message-scroller-commands.js.map +0 -1
  373. package/dist/hooks/use-message-scroller-controller.d.ts.map +0 -1
  374. package/dist/hooks/use-message-scroller-controller.js.map +0 -1
  375. package/dist/hooks/use-message-scroller-refs.d.ts.map +0 -1
  376. package/dist/hooks/use-message-scroller-refs.js.map +0 -1
  377. package/dist/hooks/use-mutation-observer.d.ts.map +0 -1
  378. package/dist/hooks/use-mutation-observer.js.map +0 -1
  379. package/dist/hooks/use-pagination.d.ts.map +0 -1
  380. package/dist/hooks/use-pagination.js.map +0 -1
  381. package/dist/index.d.ts.map +0 -1
  382. package/dist/index.js.map +0 -1
  383. package/dist/lib/message-scroller/geometry.d.ts.map +0 -1
  384. package/dist/lib/message-scroller/geometry.js.map +0 -1
  385. package/dist/lib/message-scroller/stores.d.ts.map +0 -1
  386. package/dist/lib/message-scroller/stores.js.map +0 -1
  387. package/dist/lib/message-scroller/types.d.ts.map +0 -1
  388. package/dist/lib/message-scroller/types.js.map +0 -1
  389. package/dist/lib/use-render.d.ts.map +0 -1
  390. package/dist/lib/use-render.js.map +0 -1
  391. package/dist/lib/utils.d.ts.map +0 -1
  392. package/dist/lib/utils.js.map +0 -1
  393. package/dist/primitives/checkbox-group.d.ts.map +0 -1
  394. package/dist/primitives/checkbox-group.js.map +0 -1
  395. package/dist/primitives/input-number.d.ts.map +0 -1
  396. package/dist/primitives/input-number.js.map +0 -1
  397. package/dist/primitives/input.d.ts.map +0 -1
  398. package/dist/primitives/input.js.map +0 -1
  399. package/dist/primitives/message-scroller.d.ts.map +0 -1
  400. package/dist/primitives/message-scroller.js.map +0 -1
  401. package/dist/primitives/progress-circle.d.ts.map +0 -1
  402. package/dist/primitives/progress-circle.js.map +0 -1
  403. package/dist/variants/alert.d.ts.map +0 -1
  404. package/dist/variants/alert.js.map +0 -1
  405. package/dist/variants/attachment.d.ts.map +0 -1
  406. package/dist/variants/attachment.js.map +0 -1
  407. package/dist/variants/badge.d.ts.map +0 -1
  408. package/dist/variants/badge.js.map +0 -1
  409. package/dist/variants/bubble.d.ts.map +0 -1
  410. package/dist/variants/bubble.js.map +0 -1
  411. package/dist/variants/button-group.d.ts.map +0 -1
  412. package/dist/variants/button-group.js.map +0 -1
  413. package/dist/variants/button.d.ts.map +0 -1
  414. package/dist/variants/button.js.map +0 -1
  415. package/dist/variants/empty.d.ts.map +0 -1
  416. package/dist/variants/empty.js.map +0 -1
  417. package/dist/variants/field.d.ts.map +0 -1
  418. package/dist/variants/field.js.map +0 -1
  419. package/dist/variants/input-group.d.ts.map +0 -1
  420. package/dist/variants/input-group.js.map +0 -1
  421. package/dist/variants/item.d.ts.map +0 -1
  422. package/dist/variants/item.js.map +0 -1
  423. package/dist/variants/marker.d.ts.map +0 -1
  424. package/dist/variants/marker.js.map +0 -1
  425. package/dist/variants/navigation-menu.d.ts.map +0 -1
  426. package/dist/variants/navigation-menu.js.map +0 -1
  427. package/dist/variants/progress-circle.d.ts.map +0 -1
  428. package/dist/variants/progress-circle.js.map +0 -1
  429. package/dist/variants/scroll-area.d.ts.map +0 -1
  430. package/dist/variants/scroll-area.js.map +0 -1
  431. package/dist/variants/separator.d.ts.map +0 -1
  432. package/dist/variants/separator.js.map +0 -1
  433. package/dist/variants/sheet.d.ts.map +0 -1
  434. package/dist/variants/sheet.js.map +0 -1
  435. package/dist/variants/sidebar.d.ts.map +0 -1
  436. package/dist/variants/sidebar.js.map +0 -1
  437. package/dist/variants/tabs.d.ts.map +0 -1
  438. package/dist/variants/tabs.js.map +0 -1
  439. package/dist/variants/toggle.d.ts.map +0 -1
  440. package/dist/variants/toggle.js.map +0 -1
  441. package/src/components/accordion.tsx +0 -104
  442. package/src/components/alert-dialog.tsx +0 -274
  443. package/src/components/alert.tsx +0 -84
  444. package/src/components/aspect-ratio.tsx +0 -21
  445. package/src/components/attachment.tsx +0 -264
  446. package/src/components/avatar.tsx +0 -157
  447. package/src/components/badge.tsx +0 -31
  448. package/src/components/breadcrumb.tsx +0 -170
  449. package/src/components/bubble.tsx +0 -106
  450. package/src/components/button-group.tsx +0 -89
  451. package/src/components/button.tsx +0 -51
  452. package/src/components/calendar.tsx +0 -210
  453. package/src/components/card.tsx +0 -153
  454. package/src/components/carousel.tsx +0 -344
  455. package/src/components/chart.tsx +0 -514
  456. package/src/components/checkbox-cards.tsx +0 -67
  457. package/src/components/checkbox-group.tsx +0 -55
  458. package/src/components/checkbox.tsx +0 -41
  459. package/src/components/collapsible.tsx +0 -49
  460. package/src/components/command.tsx +0 -276
  461. package/src/components/context-menu.tsx +0 -378
  462. package/src/components/dialog.tsx +0 -226
  463. package/src/components/direction.tsx +0 -28
  464. package/src/components/drawer.tsx +0 -191
  465. package/src/components/dropdown-menu.tsx +0 -387
  466. package/src/components/empty.tsx +0 -141
  467. package/src/components/field.tsx +0 -307
  468. package/src/components/form.tsx +0 -238
  469. package/src/components/hover-card.tsx +0 -83
  470. package/src/components/input-group.tsx +0 -171
  471. package/src/components/input-number.tsx +0 -191
  472. package/src/components/input-otp.tsx +0 -122
  473. package/src/components/input-password.tsx +0 -46
  474. package/src/components/input-search.tsx +0 -77
  475. package/src/components/input.tsx +0 -32
  476. package/src/components/item.tsx +0 -244
  477. package/src/components/kbd.tsx +0 -43
  478. package/src/components/label.tsx +0 -32
  479. package/src/components/marker.tsx +0 -86
  480. package/src/components/menubar.tsx +0 -406
  481. package/src/components/message-scroller.tsx +0 -199
  482. package/src/components/message.tsx +0 -159
  483. package/src/components/native-select.tsx +0 -79
  484. package/src/components/navigation-menu.tsx +0 -217
  485. package/src/components/pagination.tsx +0 -182
  486. package/src/components/popover.tsx +0 -152
  487. package/src/components/progress-circle.tsx +0 -179
  488. package/src/components/progress.tsx +0 -37
  489. package/src/components/radio-cards.tsx +0 -60
  490. package/src/components/radio-group.tsx +0 -55
  491. package/src/components/radio.tsx +0 -36
  492. package/src/components/resizable.tsx +0 -70
  493. package/src/components/scroll-area.tsx +0 -87
  494. package/src/components/select.tsx +0 -274
  495. package/src/components/separator.tsx +0 -54
  496. package/src/components/sheet.tsx +0 -221
  497. package/src/components/sidebar.tsx +0 -891
  498. package/src/components/skeleton.tsx +0 -31
  499. package/src/components/slider.tsx +0 -62
  500. package/src/components/sonner.tsx +0 -53
  501. package/src/components/spinner.tsx +0 -62
  502. package/src/components/switch.tsx +0 -40
  503. package/src/components/table.tsx +0 -165
  504. package/src/components/tabs.tsx +0 -100
  505. package/src/components/textarea.tsx +0 -31
  506. package/src/components/toggle-group.tsx +0 -129
  507. package/src/components/toggle.tsx +0 -26
  508. package/src/components/tooltip.tsx +0 -103
  509. package/src/css/foundation/base.css +0 -68
  510. package/src/css/foundation/motion.css +0 -65
  511. package/src/css/foundation/source.css +0 -10
  512. package/src/css/foundation/tokens.css +0 -83
  513. package/src/css/foundation/utilities.css +0 -451
  514. package/src/css/foundation/variants.css +0 -108
  515. package/src/css/preset.css +0 -14
  516. package/src/css/style.css +0 -11
  517. package/src/css/themes/amber.css +0 -105
  518. package/src/css/themes/blue.css +0 -105
  519. package/src/css/themes/cyan.css +0 -105
  520. package/src/css/themes/emerald.css +0 -105
  521. package/src/css/themes/fuchsia.css +0 -105
  522. package/src/css/themes/gray.css +0 -105
  523. package/src/css/themes/green.css +0 -105
  524. package/src/css/themes/indigo.css +0 -105
  525. package/src/css/themes/lime.css +0 -105
  526. package/src/css/themes/neutral.css +0 -105
  527. package/src/css/themes/orange.css +0 -105
  528. package/src/css/themes/pink.css +0 -105
  529. package/src/css/themes/purple.css +0 -105
  530. package/src/css/themes/red.css +0 -105
  531. package/src/css/themes/rose.css +0 -105
  532. package/src/css/themes/sky.css +0 -105
  533. package/src/css/themes/slate.css +0 -105
  534. package/src/css/themes/stone.css +0 -105
  535. package/src/css/themes/teal.css +0 -105
  536. package/src/css/themes/violet.css +0 -105
  537. package/src/css/themes/yellow.css +0 -105
  538. package/src/css/themes/zinc.css +0 -105
  539. package/src/hooks/use-animated-value.ts +0 -95
  540. package/src/hooks/use-copy-to-clipboard.ts +0 -58
  541. package/src/hooks/use-has-hydrated.ts +0 -22
  542. package/src/hooks/use-is-mobile.ts +0 -25
  543. package/src/hooks/use-latest.ts +0 -23
  544. package/src/hooks/use-media-query.ts +0 -69
  545. package/src/hooks/use-message-scroller-commands.ts +0 -351
  546. package/src/hooks/use-message-scroller-controller.ts +0 -733
  547. package/src/hooks/use-message-scroller-refs.ts +0 -163
  548. package/src/hooks/use-mutation-observer.ts +0 -51
  549. package/src/hooks/use-pagination.ts +0 -166
  550. package/src/index.ts +0 -751
  551. package/src/lib/message-scroller/geometry.ts +0 -401
  552. package/src/lib/message-scroller/stores.ts +0 -88
  553. package/src/lib/message-scroller/types.ts +0 -349
  554. package/src/lib/use-render.ts +0 -201
  555. package/src/lib/utils.ts +0 -5
  556. package/src/primitives/checkbox-group.tsx +0 -335
  557. package/src/primitives/input-number.tsx +0 -1030
  558. package/src/primitives/input.tsx +0 -221
  559. package/src/primitives/message-scroller.tsx +0 -414
  560. package/src/primitives/progress-circle.tsx +0 -489
  561. package/src/variants/alert.ts +0 -30
  562. package/src/variants/attachment.ts +0 -67
  563. package/src/variants/badge.ts +0 -35
  564. package/src/variants/bubble.ts +0 -75
  565. package/src/variants/button-group.ts +0 -32
  566. package/src/variants/button.ts +0 -51
  567. package/src/variants/empty.ts +0 -30
  568. package/src/variants/field.ts +0 -33
  569. package/src/variants/input-group.ts +0 -72
  570. package/src/variants/item.ts +0 -62
  571. package/src/variants/marker.ts +0 -34
  572. package/src/variants/navigation-menu.ts +0 -21
  573. package/src/variants/progress-circle.ts +0 -42
  574. package/src/variants/scroll-area.ts +0 -69
  575. package/src/variants/separator.ts +0 -36
  576. package/src/variants/sheet.ts +0 -33
  577. package/src/variants/sidebar.ts +0 -37
  578. package/src/variants/tabs.ts +0 -30
  579. package/src/variants/toggle.ts +0 -36
@@ -1,1030 +0,0 @@
1
- import { composeEventHandlers } from "radix-ui/internal";
2
- import { Context } from "radix-ui/internal";
3
- import { useControllableState } from "radix-ui/internal";
4
- import type {
5
- ComponentProps,
6
- FocusEventHandler,
7
- JSX,
8
- KeyboardEvent,
9
- KeyboardEventHandler,
10
- MouseEventHandler,
11
- PointerEventHandler,
12
- RefObject,
13
- } from "react";
14
- import { useCallback, useEffect, useMemo, useRef } from "react";
15
-
16
- import * as InputPrimitive from "#/primitives/input";
17
- import { createInputScope } from "#/primitives/input";
18
-
19
- // ── Context: InputNumber ─────────────────────────────────────────────────────────────────────────────────────────────
20
-
21
- /**
22
- * The name of the InputNumber component constant.
23
- */
24
- const NUMBER_INPUT_NAME = "InputNumber";
25
-
26
- /**
27
- * Props that include an optional scope for the InputNumber component.
28
- */
29
- type ScopedProps<P> = P & {
30
- /**
31
- * Optional scope for the InputNumber component context
32
- */
33
- __scopeInputNumber?: Context.Scope;
34
- };
35
-
36
- const [createInputNumberContext, createInputNumberScope] = Context.createContextScope(NUMBER_INPUT_NAME, [
37
- createInputScope,
38
- ]);
39
- const useInputScope = createInputScope();
40
-
41
- /**
42
- * Context value for the InputNumber component.
43
- */
44
- interface InputNumberContextValue {
45
- /**
46
- * Formatting options for displaying the number value
47
- */
48
- formatOptions: Intl.NumberFormatOptions;
49
-
50
- /**
51
- * Function to format a number value as a string
52
- */
53
- formatValue: (value?: number) => string;
54
-
55
- /**
56
- * Reference to the input element
57
- */
58
- inputRef: RefObject<HTMLInputElement | null>;
59
-
60
- /**
61
- * Handler for when the value changes
62
- */
63
- onChange: (value?: number) => void;
64
-
65
- /**
66
- * Handler to decrement the value
67
- */
68
- onDecrement: () => void;
69
-
70
- /**
71
- * Handler to decrement the value to the minimum allowed
72
- */
73
- onDecrementToMin: () => void;
74
-
75
- /**
76
- * Handler to increment the value
77
- */
78
- onIncrement: () => void;
79
-
80
- /**
81
- * Handler to increment the value to the maximum allowed
82
- */
83
- onIncrementToMax: () => void;
84
-
85
- /**
86
- * Function to parse a value into a number
87
- */
88
- parseValue: (value: number | ReadonlyArray<string> | string | undefined) => number;
89
-
90
- /**
91
- * Accessible label for the decrement button
92
- */
93
- ariaDecrementLabel?: string;
94
-
95
- /**
96
- * Accessible label for the increment button
97
- */
98
- ariaIncrementLabel?: string;
99
-
100
- /**
101
- * Initial value used when the input is uncontrolled
102
- */
103
- defaultValue?: number;
104
-
105
- /**
106
- * Whether the input is disabled
107
- */
108
- disabled?: boolean;
109
-
110
- /**
111
- * Unique identifier for the input
112
- */
113
- id?: string;
114
-
115
- /**
116
- * Maximum allowed value
117
- */
118
- max?: number;
119
-
120
- /**
121
- * Minimum allowed value
122
- */
123
- min?: number;
124
-
125
- /**
126
- * Whether the input is read-only
127
- */
128
- readOnly?: boolean;
129
-
130
- /**
131
- * Step value for increments/decrements
132
- */
133
- step?: number;
134
-
135
- /**
136
- * Current value of the input
137
- */
138
- value?: number;
139
- }
140
-
141
- const [InputNumberContextProvider, useInputNumberContext] =
142
- createInputNumberContext<InputNumberContextValue>(NUMBER_INPUT_NAME);
143
-
144
- // ── Component: InputNumber ───────────────────────────────────────────────────────────────────────────────────────────
145
-
146
- /**
147
- * Props for the main InputNumber component.
148
- *
149
- * @since 0.3.16-canary.0
150
- */
151
- interface InputNumberProps extends ComponentProps<typeof InputPrimitive.Root> {
152
- /**
153
- * Accessible label for the decrement button
154
- */
155
- ariaDecrementLabel?: string;
156
-
157
- /**
158
- * Accessible label for the increment button
159
- */
160
- ariaIncrementLabel?: string;
161
-
162
- /**
163
- * Initial value when uncontrolled
164
- */
165
- defaultValue?: number;
166
-
167
- /**
168
- * Options for number formatting
169
- */
170
- formatOptions?: Intl.NumberFormatOptions;
171
-
172
- /**
173
- * Unique identifier for the input
174
- */
175
- id?: string;
176
-
177
- /**
178
- * Locale used for number formatting
179
- */
180
- locale?: string;
181
-
182
- /**
183
- * Maximum allowed value
184
- */
185
- max?: number;
186
-
187
- /**
188
- * Minimum allowed value
189
- */
190
- min?: number;
191
-
192
- /**
193
- * Handler called when the value changes
194
- */
195
- onChange?: (value?: number) => void;
196
-
197
- /**
198
- * Step value for increments/decrements
199
- */
200
- step?: number;
201
-
202
- /**
203
- * Current value when controlled
204
- */
205
- value?: number;
206
- }
207
-
208
- /**
209
- * @since 0.3.16-canary.0
210
- */
211
- function InputNumber(numberInputProps: ScopedProps<InputNumberProps>): JSX.Element {
212
- const {
213
- __scopeInputNumber,
214
- ariaDecrementLabel,
215
- ariaIncrementLabel,
216
- defaultValue,
217
- formatOptions = { minimumFractionDigits: 0, style: "decimal" },
218
- id,
219
- locale,
220
- max,
221
- min,
222
- onChange,
223
- step = 1,
224
- value: valueProperty,
225
- ...props
226
- } = numberInputProps;
227
-
228
- /**
229
- * Context.Scope for the input component
230
- */
231
- const inputScope = useInputScope(__scopeInputNumber);
232
-
233
- /**
234
- * Reference to the input element
235
- */
236
- const inputRef = useRef<HTMLInputElement>(null);
237
-
238
- /**
239
- * Controlled or uncontrolled value state
240
- */
241
- const [value, setValue] = useControllableState<number | undefined>({
242
- defaultProp: defaultValue,
243
- onChange,
244
- prop: valueProperty,
245
- });
246
-
247
- /**
248
- * Separators used for number formatting based on locale
249
- */
250
- const { decimalSeparator, thousandSeparator } = useMemo(() => getNumberFormatSeparators(locale), [locale]);
251
-
252
- // Stable reference so an inline `formatOptions` literal doesn't churn the format callbacks every render.
253
- const formatOptionsKey = JSON.stringify(formatOptions);
254
- const stableFormatOptions = useMemo<Intl.NumberFormatOptions>(
255
- () => JSON.parse(formatOptionsKey) as Intl.NumberFormatOptions,
256
- [formatOptionsKey],
257
- );
258
-
259
- /**
260
- * Formats a number value into a string representation
261
- * @param inputValue - The number to format
262
- * @returns A formatted string representation of the number
263
- */
264
- const formatValue = useCallback(
265
- (inputValue?: number): string => {
266
- if (inputValue === undefined || Number.isNaN(inputValue)) {
267
- return "";
268
- }
269
-
270
- return new Intl.NumberFormat(locale, stableFormatOptions).format(inputValue);
271
- },
272
- [stableFormatOptions, locale],
273
- );
274
-
275
- /**
276
- * Parses a string or number input into a normalized number value
277
- * @param inputValue - The value to parse
278
- * @returns The parsed number value, clamped between min and max
279
- */
280
- const parseValue = useCallback(
281
- (inputValue: number | ReadonlyArray<string> | string | undefined): number => {
282
- if (typeof inputValue === "number") {
283
- return clamp(inputValue, min, max);
284
- }
285
-
286
- if (typeof inputValue !== "string") {
287
- return Number.NaN;
288
- }
289
-
290
- const cleanedValue = inputValue.trim().replaceAll(/[^\d.,\-()]/g, "");
291
-
292
- if (cleanedValue === "") {
293
- return Number.NaN;
294
- }
295
-
296
- const normalizedValue = normalizeInputValue(cleanedValue, thousandSeparator, decimalSeparator);
297
- let parsedValue = Number.parseFloat(normalizedValue);
298
-
299
- if (stableFormatOptions.style === "percent") {
300
- parsedValue /= 100;
301
- }
302
-
303
- return Number.isNaN(parsedValue) ? 0 : clamp(parsedValue, min, max);
304
- },
305
- [decimalSeparator, stableFormatOptions.style, max, min, thousandSeparator],
306
- );
307
-
308
- /**
309
- * Changes the current value based on a provided operation
310
- * @param operation - Function that takes the current value and returns a new value
311
- */
312
- const changeNumberValue = useCallback(
313
- (operation: (number: number) => number) => {
314
- const inputElement = inputRef.current;
315
-
316
- if (!inputElement || props.disabled || props.readOnly) {
317
- return;
318
- }
319
-
320
- const parsedValue = parseValue(inputElement.value);
321
- const currentValue = Number.isNaN(parsedValue) ? 0 : parsedValue;
322
- const newValue = clamp(roundToStep(operation(currentValue), step), min, max);
323
-
324
- inputElement.value = formatValue(newValue);
325
- setValue(newValue);
326
- },
327
- [props.disabled, formatValue, max, min, parseValue, props.readOnly, setValue, step],
328
- );
329
-
330
- /**
331
- * Increments the current value by the step amount
332
- */
333
- const handleIncrement = useCallback(() => {
334
- changeNumberValue((number) => number + step);
335
- }, [changeNumberValue, step]);
336
-
337
- /**
338
- * Decrements the current value by the step amount
339
- */
340
- const handleDecrement = useCallback(() => {
341
- changeNumberValue((number) => number - step);
342
- }, [changeNumberValue, step]);
343
-
344
- /**
345
- * Sets the value to the maximum allowed
346
- */
347
- const handleIncrementToMax = useCallback(() => {
348
- changeNumberValue((number) => max ?? number + step);
349
- }, [changeNumberValue, max, step]);
350
-
351
- /**
352
- * Sets the value to the minimum allowed
353
- */
354
- const handleDecrementToMin = useCallback(() => {
355
- changeNumberValue((number) => min ?? number - step);
356
- }, [changeNumberValue, min, step]);
357
-
358
- return (
359
- <InputNumberContextProvider
360
- ariaDecrementLabel={ariaDecrementLabel}
361
- ariaIncrementLabel={ariaIncrementLabel}
362
- defaultValue={defaultValue}
363
- disabled={props.disabled}
364
- formatOptions={stableFormatOptions}
365
- formatValue={formatValue}
366
- id={id}
367
- inputRef={inputRef}
368
- max={max}
369
- min={min}
370
- parseValue={parseValue}
371
- readOnly={props.readOnly}
372
- scope={__scopeInputNumber}
373
- value={value}
374
- onChange={setValue}
375
- onDecrement={handleDecrement}
376
- onDecrementToMin={handleDecrementToMin}
377
- onIncrement={handleIncrement}
378
- onIncrementToMax={handleIncrementToMax}
379
- >
380
- <InputPrimitive.Root {...inputScope} {...props} />
381
- </InputNumberContextProvider>
382
- );
383
- }
384
-
385
- // ── Component: InputNumberField ──────────────────────────────────────────────────────────────────────────────────────
386
-
387
- /**
388
- * The name of the InputNumberField component constant.
389
- */
390
- const NUMBER_INPUT_FIELD_NAME = "InputNumberField";
391
-
392
- /**
393
- * Defines the props for the `InputNumberField` component.
394
- *
395
- * @since 0.3.16-canary.0
396
- */
397
- type InputNumberFieldProps = Omit<
398
- ComponentProps<typeof InputPrimitive.Field>,
399
- "defaultValue" | "disabled" | "id" | "max" | "min" | "onChange" | "prefix" | "readOnly" | "step" | "value"
400
- >;
401
-
402
- /**
403
- * @since 0.3.16-canary.0
404
- */
405
- function InputNumberField({
406
- __scopeInputNumber,
407
- onBlur,
408
- onKeyDown,
409
- ...props
410
- }: ScopedProps<InputNumberFieldProps>): JSX.Element {
411
- // Retrieve input number context and input scope
412
- const inputScope = useInputScope(__scopeInputNumber);
413
- const {
414
- defaultValue,
415
- disabled,
416
- formatValue,
417
- id,
418
- inputRef,
419
- max,
420
- min,
421
- onChange,
422
- onDecrement,
423
- onDecrementToMin,
424
- onIncrement,
425
- onIncrementToMax,
426
- parseValue,
427
- readOnly,
428
- step,
429
- value,
430
- } = useInputNumberContext(NUMBER_INPUT_FIELD_NAME, __scopeInputNumber);
431
-
432
- /**
433
- * Handles the blur event to format the value of the input.
434
- *
435
- * @param event - The blur event triggered when the input loses focus.
436
- */
437
- const handleBlur = useCallback<FocusEventHandler<HTMLInputElement>>(
438
- (event) => {
439
- const parsedValue = parseValue(event.target.value);
440
- const numericValue = Number.isNaN(parsedValue) ? undefined : parsedValue;
441
- const formattedValue = formatValue(numericValue);
442
-
443
- if (formattedValue !== event.target.value) {
444
- event.target.value = formattedValue;
445
- }
446
-
447
- onChange(numericValue);
448
- },
449
- [formatValue, onChange, parseValue],
450
- );
451
-
452
- /**
453
- * Handles keydown events to increment, decrement, or perform other actions.
454
- *
455
- * @param event - The keyboard event triggered by key presses.
456
- */
457
- const handleKeyDown = useCallback<KeyboardEventHandler<HTMLInputElement>>(
458
- (event) => {
459
- switch (event.key) {
460
- case "ArrowUp": {
461
- onIncrement();
462
- event.preventDefault();
463
- break;
464
- }
465
-
466
- case "PageUp": {
467
- onIncrementToMax();
468
- event.preventDefault();
469
- break;
470
- }
471
-
472
- case "ArrowDown": {
473
- onDecrement();
474
- event.preventDefault();
475
- break;
476
- }
477
-
478
- case "PageDown": {
479
- onDecrementToMin();
480
- event.preventDefault();
481
- break;
482
- }
483
-
484
- default: {
485
- break;
486
- }
487
- }
488
- },
489
- [onIncrement, onIncrementToMax, onDecrement, onDecrementToMin],
490
- );
491
-
492
- /**
493
- * Prevents invalid keyboard input for the numeric input field.
494
- *
495
- * @param event - The keyboard event to handle.
496
- */
497
- const handleKeyDownPrevent = useCallback<KeyboardEventHandler<HTMLInputElement>>(
498
- (event) => {
499
- switch (event.key) {
500
- case "ArrowUp":
501
-
502
- case "ArrowDown":
503
-
504
- case "ArrowLeft":
505
-
506
- case "ArrowRight":
507
-
508
- case "PageUp":
509
-
510
- case "PageDown":
511
-
512
- case "Tab":
513
-
514
- case "Escape":
515
-
516
- case "Enter":
517
-
518
- case "Backspace":
519
-
520
- case "Delete":
521
-
522
- case "Home":
523
-
524
- case "End":
525
-
526
- case "%": {
527
- return;
528
- }
529
-
530
- case ".":
531
-
532
- case ",": {
533
- // Allow at most one decimal separator unless the current one is inside the selection being replaced.
534
- const inputElement = inputRef.current;
535
-
536
- if (
537
- inputElement &&
538
- inputElement.selectionStart === inputElement.selectionEnd &&
539
- /[.,]/.test(inputElement.value)
540
- ) {
541
- event.preventDefault();
542
- }
543
-
544
- return;
545
- }
546
-
547
- case "-": {
548
- // Allow a single leading sign only.
549
- const inputElement = inputRef.current;
550
-
551
- if (
552
- inputElement &&
553
- (inputElement.selectionStart !== 0 ||
554
- (inputElement.value.includes("-") && inputElement.selectionStart === inputElement.selectionEnd))
555
- ) {
556
- event.preventDefault();
557
- }
558
-
559
- return;
560
- }
561
-
562
- default: {
563
- if (isNumberKey(event.key) || isModifierKey(event) || isFunctionKey(event.key)) {
564
- return;
565
- }
566
-
567
- event.preventDefault();
568
- }
569
- }
570
- },
571
- [inputRef],
572
- );
573
-
574
- /**
575
- * Handles the Enter key to format the value of the input.
576
- *
577
- * @param event - The keyboard event triggered by pressing Enter.
578
- */
579
- const handleKeyDownEnter = useCallback<KeyboardEventHandler<HTMLInputElement>>(
580
- (event) => {
581
- const inputElement = inputRef.current;
582
-
583
- if (event.key !== "Enter" || !inputElement) {
584
- return;
585
- }
586
-
587
- const parsedValue = parseValue(inputElement.value);
588
- const numericValue = Number.isNaN(parsedValue) ? undefined : parsedValue;
589
- const formattedValue = formatValue(numericValue);
590
-
591
- if (formattedValue !== inputElement.value) {
592
- inputElement.value = formattedValue;
593
- }
594
-
595
- onChange(numericValue);
596
- },
597
- [formatValue, inputRef, onChange, parseValue],
598
- );
599
-
600
- /**
601
- * Creates a combined keydown event handler that processes keyboard events in sequence.
602
- *
603
- * The handler chain executes in the following order:
604
- * 1. User-provided onKeyDown handler (if any)
605
- * 2. handleKeyDownPrevent - Prevents non-numeric input
606
- * 3. handleKeyDown - Handles arrow keys and page up/down for value adjustments
607
- * 4. handleKeyDownEnter - Handles Enter key press to format and update the value
608
- *
609
- * @returns A composed event handler function for the onKeyDown event
610
- */
611
- const combinedKeyDownHandler = useCallback<KeyboardEventHandler<HTMLInputElement>>(
612
- (event) => {
613
- composeEventHandlers(onKeyDown, chain(handleKeyDownPrevent, handleKeyDown, handleKeyDownEnter))(event);
614
- },
615
- [onKeyDown, handleKeyDown, handleKeyDownEnter, handleKeyDownPrevent],
616
- );
617
-
618
- /**
619
- * Adds a listener to handle wheel events for incrementing or decrementing the value.
620
- */
621
- useEffect(() => {
622
- const handleWheel = (event: WheelEvent): void => {
623
- const inputElement = inputRef.current;
624
-
625
- if (!inputElement || disabled || readOnly || document.activeElement !== inputElement) {
626
- return;
627
- }
628
-
629
- event.preventDefault();
630
-
631
- // Match native number inputs: scroll up increases, scroll down decreases.
632
- if (event.deltaY < 0) {
633
- onIncrement();
634
- } else {
635
- onDecrement();
636
- }
637
- };
638
-
639
- const inputElement = inputRef.current;
640
-
641
- inputElement?.addEventListener("wheel", handleWheel);
642
-
643
- return (): void => {
644
- inputElement?.removeEventListener("wheel", handleWheel);
645
- };
646
- }, [onIncrement, onDecrement, inputRef, disabled, readOnly]);
647
-
648
- /**
649
- * Updates the input field's value when it changes in the context.
650
- */
651
- useEffect(() => {
652
- const inputElement = inputRef.current;
653
-
654
- if (inputElement && inputElement !== document.activeElement) {
655
- inputElement.value = formatValue(value);
656
- }
657
- }, [formatValue, inputRef, value]);
658
-
659
- /**
660
- * Adds a listener to handle form reset events by clearing the input value.
661
- */
662
- useEffect(() => {
663
- const inputElement = inputRef.current;
664
-
665
- if (!inputElement) {
666
- return;
667
- }
668
-
669
- const handleReset = (): void => {
670
- onChange(defaultValue === undefined ? undefined : parseValue(defaultValue));
671
- };
672
-
673
- const form = inputElement.form;
674
-
675
- form?.addEventListener("reset", handleReset);
676
-
677
- return (): void => {
678
- form?.removeEventListener("reset", handleReset);
679
- };
680
- }, [defaultValue, inputRef, onChange, parseValue]);
681
-
682
- const hasValue = value !== undefined && !Number.isNaN(value);
683
-
684
- return (
685
- <InputPrimitive.Field
686
- ref={inputRef}
687
- aria-valuemax={max}
688
- aria-valuemin={min}
689
- aria-valuenow={hasValue ? value : undefined}
690
- aria-valuetext={hasValue ? formatValue(value) : undefined}
691
- defaultValue={formatValue(value)}
692
- disabled={disabled}
693
- id={id}
694
- inputMode="decimal"
695
- max={max}
696
- min={min}
697
- readOnly={readOnly}
698
- role="spinbutton"
699
- step={step}
700
- onBlur={composeEventHandlers(onBlur, handleBlur)}
701
- onKeyDown={combinedKeyDownHandler}
702
- {...inputScope}
703
- {...props}
704
- />
705
- );
706
- }
707
-
708
- // ── Component: NumberStepperButton ───────────────────────────────────────────────────────────────────────────────────
709
-
710
- /**
711
- * The name of the NumberStepperButton component constant.
712
- */
713
- const NUMBER_STEPPER_BUTTON_NAME = "NumberStepperButton";
714
-
715
- /**
716
- * Props for the NumberStepperButton component.
717
- */
718
- interface NumberStepperButtonProps extends ComponentProps<"button"> {
719
- /**
720
- * The operation to perform when the button is pressed.
721
- * - `'increment'`: Increases the value.
722
- * - `'decrement'`: Decreases the value.
723
- */
724
- operation: "decrement" | "increment";
725
- }
726
-
727
- function NumberStepperButton({
728
- __scopeInputNumber,
729
- operation,
730
- ...props
731
- }: ScopedProps<NumberStepperButtonProps>): JSX.Element {
732
- // Destructures relevant context values for the button functionality.
733
- const { ariaDecrementLabel, ariaIncrementLabel, disabled, id, max, min, onDecrement, onIncrement, value } =
734
- useInputNumberContext(NUMBER_STEPPER_BUTTON_NAME, __scopeInputNumber);
735
-
736
- const isDisabled = useMemo(() => {
737
- if (disabled) {
738
- return true;
739
- }
740
-
741
- // Only the button that would push past a bound is disabled — the opposite one must stay usable.
742
- if (operation === "increment") {
743
- return max !== undefined && value !== undefined && value >= max;
744
- }
745
-
746
- return min !== undefined && value !== undefined && value <= min;
747
- }, [operation, min, max, value, disabled]);
748
-
749
- /**
750
- * Ref to store a timeout ID for managing repeated button actions.
751
- */
752
- const timeoutIdRef = useRef<ReturnType<typeof setTimeout>>(null);
753
-
754
- /**
755
- * Starts a repeated action at a regular interval.
756
- * The action begins immediately and then continues with a delay.
757
- *
758
- * @param callback - The callback function to execute repeatedly.
759
- */
760
- const startActionInterval = useCallback((callback: () => void) => {
761
- // Time between repeated actions (in milliseconds).
762
- const interval = 100;
763
-
764
- // Function to perform the action and set the next interval.
765
- const repeatAction = (): void => {
766
- callback();
767
- timeoutIdRef.current = setTimeout(repeatAction, interval);
768
- };
769
-
770
- callback();
771
- timeoutIdRef.current = setTimeout(repeatAction, interval * 2);
772
- }, []);
773
-
774
- /**
775
- * Clears any ongoing action intervals.
776
- */
777
- const clearActionInterval = useCallback(() => {
778
- if (timeoutIdRef.current) {
779
- clearTimeout(timeoutIdRef.current);
780
- timeoutIdRef.current = null;
781
- }
782
- }, []);
783
-
784
- // Stop repeating once the button hits its bound mid-hold (a disabled button never receives pointerup) and on unmount.
785
- useEffect(() => {
786
- if (isDisabled) {
787
- clearActionInterval();
788
- }
789
-
790
- return clearActionInterval;
791
- }, [isDisabled, clearActionInterval]);
792
-
793
- /**
794
- * Handles pointer down events and triggers the appropriate action
795
- * (`increment` or `decrement`).
796
- */
797
- const handlePointerDown = useCallback<PointerEventHandler<HTMLButtonElement>>(() => {
798
- const action = operation === "increment" ? onIncrement : onDecrement;
799
-
800
- startActionInterval(action);
801
- }, [onDecrement, onIncrement, operation, startActionInterval]);
802
-
803
- /**
804
- * Prevents the context menu from displaying when the button is right-clicked.
805
- *
806
- * @param event - The mouse event triggered by the right-click.
807
- */
808
- const handleContextMenu = useCallback<MouseEventHandler<HTMLButtonElement>>((event) => {
809
- event.preventDefault();
810
- }, []);
811
-
812
- /**
813
- * Handles keyboard events to support activation of the button using
814
- * keyboard navigation (Enter or Space).
815
- *
816
- * @param event - The keyboard event with the triggered key.
817
- */
818
- const handleKeyDown = useCallback<KeyboardEventHandler<HTMLButtonElement>>(
819
- (event) => {
820
- if (event.key === "Enter" || event.key === " ") {
821
- event.preventDefault();
822
-
823
- const action = operation === "increment" ? onIncrement : onDecrement;
824
-
825
- action();
826
- }
827
- },
828
- [onDecrement, onIncrement, operation],
829
- );
830
-
831
- return (
832
- <button
833
- aria-controls={id}
834
- aria-label={operation === "increment" ? ariaIncrementLabel : ariaDecrementLabel}
835
- disabled={isDisabled}
836
- type="button"
837
- onContextMenu={handleContextMenu}
838
- onKeyDown={handleKeyDown}
839
- onPointerCancel={clearActionInterval}
840
- onPointerDown={handlePointerDown}
841
- onPointerLeave={clearActionInterval}
842
- onPointerUp={clearActionInterval}
843
- {...props}
844
- />
845
- );
846
- }
847
-
848
- // ── Component: InputNumberIncrementButton ────────────────────────────────────────────────────────────────────────────
849
-
850
- /**
851
- * @since 0.3.16-canary.0
852
- */
853
- type InputNumberIncrementButtonProps = Omit<ComponentProps<typeof NumberStepperButton>, "operation">;
854
-
855
- /**
856
- * @since 0.3.16-canary.0
857
- */
858
- function InputNumberIncrementButton(props: InputNumberIncrementButtonProps): JSX.Element {
859
- return <NumberStepperButton operation="increment" {...props} />;
860
- }
861
-
862
- // ── Component: InputNumberDecrementButton ────────────────────────────────────────────────────────────────────────────
863
-
864
- /**
865
- * @since 0.3.16-canary.0
866
- */
867
- type InputNumberDecrementButtonProps = Omit<ComponentProps<typeof NumberStepperButton>, "operation">;
868
-
869
- /**
870
- * @since 0.3.16-canary.0
871
- */
872
- function InputNumberDecrementButton(props: InputNumberDecrementButtonProps): JSX.Element {
873
- return <NumberStepperButton operation="decrement" {...props} />;
874
- }
875
-
876
- // ── Utility Functions ────────────────────────────────────────────────────────────────────────────────────────────────
877
-
878
- /**
879
- * Chains multiple callbacks into a single function
880
- *
881
- * @param callbacks - Array of callback functions that will be executed in order
882
- * @returns A single function that executes all callbacks
883
- */
884
- function chain<T extends Array<unknown>>(...callbacks: Array<(...args: T) => void>): (...args: T) => void {
885
- return (...args: T) => {
886
- for (const callback of callbacks) {
887
- callback(...args);
888
- }
889
- };
890
- }
891
-
892
- /**
893
- * Interface for number formatting separators
894
- */
895
- interface NumberFormatSeparators {
896
- /**
897
- * The character used to separate decimal part (e.g., "." or ",")
898
- */
899
- decimalSeparator: string;
900
- /**
901
- * The character used to separate thousands (e.g., "," or ".")
902
- */
903
- thousandSeparator: string;
904
- }
905
-
906
- /**
907
- * Extracts decimal and a thousand separators from a given locale's number format
908
- *
909
- * @param locale - The locale string to use for number formatting (e.g., 'en-US', 'de-DE')
910
- * @returns Object containing decimal and a thousand separators
911
- */
912
- function getNumberFormatSeparators(locale?: string): NumberFormatSeparators {
913
- const numberFormat = new Intl.NumberFormat(locale);
914
- const parts = numberFormat.formatToParts(12_345.6);
915
- let thousandSeparator = "";
916
- let decimalSeparator = "";
917
-
918
- for (const part of parts) {
919
- if (part.type === "group") {
920
- thousandSeparator = part.value;
921
- }
922
-
923
- if (part.type === "decimal") {
924
- decimalSeparator = part.value;
925
- }
926
-
927
- // Stop early if you've found enough.
928
- if (thousandSeparator && decimalSeparator) {
929
- break;
930
- }
931
- }
932
-
933
- return { decimalSeparator, thousandSeparator };
934
- }
935
-
936
- /**
937
- * Normalizes an input value by removing formatting characters
938
- *
939
- * @param value - The input string to normalize
940
- * @param thousandSeparator - The thousand-separator character to remove
941
- * @param decimalSeparator - The decimal separator to convert to standard dot notation
942
- * @returns Normalized string value ready for numeric conversion
943
- */
944
- function normalizeInputValue(value: string, thousandSeparator: string, decimalSeparator: string): string {
945
- return value
946
- .replaceAll(new RegExp(`\\${thousandSeparator}`, "g"), "")
947
- .replace(new RegExp(`\\${decimalSeparator}`), ".")
948
- .replaceAll(/[()]/g, "-");
949
- }
950
-
951
- /**
952
- * Checks if a keyboard event includes modifier keys (Ctrl, Alt, Meta, Shift)
953
- *
954
- * @param event - The keyboard event to check
955
- * @returns True if any modifier key is pressed
956
- */
957
- function isModifierKey(event: KeyboardEvent<HTMLInputElement>): boolean {
958
- return event.ctrlKey || event.altKey || event.metaKey || event.shiftKey;
959
- }
960
-
961
- /**
962
- * Determines if a key is a function key (F1-F12)
963
- *
964
- * @param key - The key name to check
965
- * @returns True if the key is a function key
966
- */
967
- function isFunctionKey(key: string): boolean {
968
- return key.startsWith("F") && key.length > 1;
969
- }
970
-
971
- /**
972
- * Checks if a key represents a number (0-9)
973
- *
974
- * @param key - The key name to check
975
- * @returns True if the key represents a number
976
- */
977
- function isNumberKey(key: string): boolean {
978
- return !Number.isNaN(Number(key));
979
- }
980
-
981
- /**
982
- * Clamps a numeric value between a minimum and maximum
983
- *
984
- * @param value - The value to clamp
985
- * @param min - The minimum allowed value (defaults to \-Infinity)
986
- * @param max - The maximum allowed value (defaults to Infinity)
987
- * @returns The clamped value
988
- */
989
- function clamp(value: number, min = Number.NEGATIVE_INFINITY, max = Number.POSITIVE_INFINITY): number {
990
- return Math.min(Math.max(value, min), max);
991
- }
992
-
993
- /**
994
- * Rounds a value to the decimal precision implied by the step, avoiding floating-point drift
995
- * (e.g. `0.1 + 0.2`) when stepping with fractional increments.
996
- *
997
- * @param value - The value to round
998
- * @param step - The step whose fractional digit count sets the precision
999
- * @returns The value rounded to the step's precision
1000
- */
1001
- function roundToStep(value: number, step: number): number {
1002
- if (!Number.isFinite(step) || step <= 0) {
1003
- return value;
1004
- }
1005
-
1006
- const fractionDigits = String(step).split(".")[1]?.length ?? 0;
1007
-
1008
- return Number(value.toFixed(fractionDigits));
1009
- }
1010
-
1011
- // ── Exports ──────────────────────────────────────────────────────────────────────────────────────────────────────────
1012
-
1013
- export {
1014
- createInputNumberScope,
1015
- InputNumberDecrementButton as DecrementButton,
1016
- InputNumberField as Field,
1017
- InputNumberIncrementButton as IncrementButton,
1018
- InputNumber,
1019
- InputNumberDecrementButton,
1020
- InputNumberField,
1021
- InputNumberIncrementButton,
1022
- InputNumber as Root,
1023
- };
1024
-
1025
- export type {
1026
- InputNumberDecrementButtonProps,
1027
- InputNumberFieldProps,
1028
- InputNumberIncrementButtonProps,
1029
- InputNumberProps,
1030
- };