@kumix/ui 0.1.3 → 0.2.0

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 (497) hide show
  1. package/README.md +115 -95
  2. package/dist/components/reui/alert.d.ts +12 -0
  3. package/dist/components/reui/alert.d.ts.map +1 -0
  4. package/dist/components/reui/alert.js +58 -0
  5. package/dist/components/reui/alert.js.map +1 -0
  6. package/dist/components/reui/autocomplete.d.ts +43 -0
  7. package/dist/components/reui/autocomplete.d.ts.map +1 -0
  8. package/dist/components/reui/autocomplete.js +165 -0
  9. package/dist/components/reui/autocomplete.js.map +1 -0
  10. package/dist/components/reui/badge.d.ts +17 -0
  11. package/dist/components/reui/badge.d.ts.map +1 -0
  12. package/dist/components/reui/badge.js +75 -0
  13. package/dist/components/reui/badge.js.map +1 -0
  14. package/dist/components/reui/data-grid/data-grid-column-filter.d.ts +17 -0
  15. package/dist/components/reui/data-grid/data-grid-column-filter.d.ts.map +1 -0
  16. package/dist/components/reui/data-grid/data-grid-column-filter.js +127 -0
  17. package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -0
  18. package/dist/components/reui/data-grid/data-grid-column-header.d.ts +18 -0
  19. package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -0
  20. package/dist/components/reui/data-grid/data-grid-column-header.js +228 -0
  21. package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -0
  22. package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts +10 -0
  23. package/dist/components/reui/data-grid/data-grid-column-visibility.d.ts.map +1 -0
  24. package/dist/components/reui/data-grid/data-grid-column-visibility.js +28 -0
  25. package/dist/components/reui/data-grid/data-grid-column-visibility.js.map +1 -0
  26. package/dist/components/reui/data-grid/data-grid-pagination.d.ts +22 -0
  27. package/dist/components/reui/data-grid/data-grid-pagination.d.ts.map +1 -0
  28. package/dist/components/reui/data-grid/data-grid-pagination.js +144 -0
  29. package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -0
  30. package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts +12 -0
  31. package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -0
  32. package/dist/components/reui/data-grid/data-grid-scroll-area.js +289 -0
  33. package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -0
  34. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts +14 -0
  35. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -0
  36. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +166 -0
  37. package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -0
  38. package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts +10 -0
  39. package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts.map +1 -0
  40. package/dist/components/reui/data-grid/data-grid-table-dnd.js +171 -0
  41. package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -0
  42. package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts +29 -0
  43. package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts.map +1 -0
  44. package/dist/components/reui/data-grid/data-grid-table-virtual.js +269 -0
  45. package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -0
  46. package/dist/components/reui/data-grid/data-grid-table.d.ts +116 -0
  47. package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -0
  48. package/dist/components/reui/data-grid/data-grid-table.js +864 -0
  49. package/dist/components/reui/data-grid/data-grid-table.js.map +1 -0
  50. package/dist/components/reui/data-grid/data-grid.d.ts +112 -0
  51. package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -0
  52. package/dist/components/reui/data-grid/data-grid.js +134 -0
  53. package/dist/components/reui/data-grid/data-grid.js.map +1 -0
  54. package/dist/components/reui/date-selector.d.ts +131 -0
  55. package/dist/components/reui/date-selector.d.ts.map +1 -0
  56. package/dist/components/reui/date-selector.js +783 -0
  57. package/dist/components/reui/date-selector.js.map +1 -0
  58. package/dist/components/reui/event-calendar/event-calendar-agenda-view.d.ts +7 -0
  59. package/dist/components/reui/event-calendar/event-calendar-agenda-view.d.ts.map +1 -0
  60. package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +108 -0
  61. package/dist/components/reui/event-calendar/event-calendar-agenda-view.js.map +1 -0
  62. package/dist/components/reui/event-calendar/event-calendar-content.d.ts +15 -0
  63. package/dist/components/reui/event-calendar/event-calendar-content.d.ts.map +1 -0
  64. package/dist/components/reui/event-calendar/event-calendar-content.js +44 -0
  65. package/dist/components/reui/event-calendar/event-calendar-content.js.map +1 -0
  66. package/dist/components/reui/event-calendar/event-calendar-dnd.d.ts +30 -0
  67. package/dist/components/reui/event-calendar/event-calendar-dnd.d.ts.map +1 -0
  68. package/dist/components/reui/event-calendar/event-calendar-dnd.js +581 -0
  69. package/dist/components/reui/event-calendar/event-calendar-dnd.js.map +1 -0
  70. package/dist/components/reui/event-calendar/event-calendar-event.d.ts +73 -0
  71. package/dist/components/reui/event-calendar/event-calendar-event.d.ts.map +1 -0
  72. package/dist/components/reui/event-calendar/event-calendar-event.js +299 -0
  73. package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -0
  74. package/dist/components/reui/event-calendar/event-calendar-i18n.d.ts +103 -0
  75. package/dist/components/reui/event-calendar/event-calendar-i18n.d.ts.map +1 -0
  76. package/dist/components/reui/event-calendar/event-calendar-i18n.js +141 -0
  77. package/dist/components/reui/event-calendar/event-calendar-i18n.js.map +1 -0
  78. package/dist/components/reui/event-calendar/event-calendar-lib.d.ts +111 -0
  79. package/dist/components/reui/event-calendar/event-calendar-lib.d.ts.map +1 -0
  80. package/dist/components/reui/event-calendar/event-calendar-lib.js +398 -0
  81. package/dist/components/reui/event-calendar/event-calendar-lib.js.map +1 -0
  82. package/dist/components/reui/event-calendar/event-calendar-month-view.d.ts +29 -0
  83. package/dist/components/reui/event-calendar/event-calendar-month-view.d.ts.map +1 -0
  84. package/dist/components/reui/event-calendar/event-calendar-month-view.js +530 -0
  85. package/dist/components/reui/event-calendar/event-calendar-month-view.js.map +1 -0
  86. package/dist/components/reui/event-calendar/event-calendar-nav.d.ts +71 -0
  87. package/dist/components/reui/event-calendar/event-calendar-nav.d.ts.map +1 -0
  88. package/dist/components/reui/event-calendar/event-calendar-nav.js +319 -0
  89. package/dist/components/reui/event-calendar/event-calendar-nav.js.map +1 -0
  90. package/dist/components/reui/event-calendar/event-calendar-recurrence.d.ts +32 -0
  91. package/dist/components/reui/event-calendar/event-calendar-recurrence.d.ts.map +1 -0
  92. package/dist/components/reui/event-calendar/event-calendar-recurrence.js +300 -0
  93. package/dist/components/reui/event-calendar/event-calendar-recurrence.js.map +1 -0
  94. package/dist/components/reui/event-calendar/event-calendar-resource-view.d.ts +14 -0
  95. package/dist/components/reui/event-calendar/event-calendar-resource-view.d.ts.map +1 -0
  96. package/dist/components/reui/event-calendar/event-calendar-resource-view.js +355 -0
  97. package/dist/components/reui/event-calendar/event-calendar-resource-view.js.map +1 -0
  98. package/dist/components/reui/event-calendar/event-calendar-time-grid.d.ts +35 -0
  99. package/dist/components/reui/event-calendar/event-calendar-time-grid.d.ts.map +1 -0
  100. package/dist/components/reui/event-calendar/event-calendar-time-grid.js +651 -0
  101. package/dist/components/reui/event-calendar/event-calendar-time-grid.js.map +1 -0
  102. package/dist/components/reui/event-calendar/event-calendar-types.d.ts +236 -0
  103. package/dist/components/reui/event-calendar/event-calendar-types.d.ts.map +1 -0
  104. package/dist/components/reui/event-calendar/event-calendar-types.js +2 -0
  105. package/dist/components/reui/event-calendar/event-calendar.d.ts +561 -0
  106. package/dist/components/reui/event-calendar/event-calendar.d.ts.map +1 -0
  107. package/dist/components/reui/event-calendar/event-calendar.js +817 -0
  108. package/dist/components/reui/event-calendar/event-calendar.js.map +1 -0
  109. package/dist/components/reui/filters.d.ts +176 -0
  110. package/dist/components/reui/filters.d.ts.map +1 -0
  111. package/dist/components/reui/filters.js +1216 -0
  112. package/dist/components/reui/filters.js.map +1 -0
  113. package/dist/components/reui/frame.d.ts +32 -0
  114. package/dist/components/reui/frame.d.ts.map +1 -0
  115. package/dist/components/reui/frame.js +115 -0
  116. package/dist/components/reui/frame.js.map +1 -0
  117. package/dist/components/reui/gantt/gantt-bar.d.ts +44 -0
  118. package/dist/components/reui/gantt/gantt-bar.d.ts.map +1 -0
  119. package/dist/components/reui/gantt/gantt-bar.js +229 -0
  120. package/dist/components/reui/gantt/gantt-bar.js.map +1 -0
  121. package/dist/components/reui/gantt/gantt-dnd.d.ts +36 -0
  122. package/dist/components/reui/gantt/gantt-dnd.d.ts.map +1 -0
  123. package/dist/components/reui/gantt/gantt-dnd.js +615 -0
  124. package/dist/components/reui/gantt/gantt-dnd.js.map +1 -0
  125. package/dist/components/reui/gantt/gantt-i18n.d.ts +91 -0
  126. package/dist/components/reui/gantt/gantt-i18n.d.ts.map +1 -0
  127. package/dist/components/reui/gantt/gantt-i18n.js +131 -0
  128. package/dist/components/reui/gantt/gantt-i18n.js.map +1 -0
  129. package/dist/components/reui/gantt/gantt-lib.d.ts +123 -0
  130. package/dist/components/reui/gantt/gantt-lib.d.ts.map +1 -0
  131. package/dist/components/reui/gantt/gantt-lib.js +354 -0
  132. package/dist/components/reui/gantt/gantt-lib.js.map +1 -0
  133. package/dist/components/reui/gantt/gantt-nav.d.ts +60 -0
  134. package/dist/components/reui/gantt/gantt-nav.d.ts.map +1 -0
  135. package/dist/components/reui/gantt/gantt-nav.js +266 -0
  136. package/dist/components/reui/gantt/gantt-nav.js.map +1 -0
  137. package/dist/components/reui/gantt/gantt-recurrence.d.ts +37 -0
  138. package/dist/components/reui/gantt/gantt-recurrence.d.ts.map +1 -0
  139. package/dist/components/reui/gantt/gantt-recurrence.js +230 -0
  140. package/dist/components/reui/gantt/gantt-recurrence.js.map +1 -0
  141. package/dist/components/reui/gantt/gantt-types.d.ts +251 -0
  142. package/dist/components/reui/gantt/gantt-types.d.ts.map +1 -0
  143. package/dist/components/reui/gantt/gantt-types.js +2 -0
  144. package/dist/components/reui/gantt/gantt-view.d.ts +10 -0
  145. package/dist/components/reui/gantt/gantt-view.d.ts.map +1 -0
  146. package/dist/components/reui/gantt/gantt-view.js +2193 -0
  147. package/dist/components/reui/gantt/gantt-view.js.map +1 -0
  148. package/dist/components/reui/gantt/gantt.d.ts +602 -0
  149. package/dist/components/reui/gantt/gantt.d.ts.map +1 -0
  150. package/dist/components/reui/gantt/gantt.js +796 -0
  151. package/dist/components/reui/gantt/gantt.js.map +1 -0
  152. package/dist/components/reui/icon-stack.d.ts +7 -0
  153. package/dist/components/reui/icon-stack.d.ts.map +1 -0
  154. package/dist/components/reui/icon-stack.js +76 -0
  155. package/dist/components/reui/icon-stack.js.map +1 -0
  156. package/dist/components/reui/kanban.d.ts +70 -0
  157. package/dist/components/reui/kanban.d.ts.map +1 -0
  158. package/dist/components/reui/kanban.js +519 -0
  159. package/dist/components/reui/kanban.js.map +1 -0
  160. package/dist/components/reui/number-field.d.ts +29 -0
  161. package/dist/components/reui/number-field.d.ts.map +1 -0
  162. package/dist/components/reui/number-field.js +127 -0
  163. package/dist/components/reui/number-field.js.map +1 -0
  164. package/dist/components/reui/phone-input.d.ts +13 -0
  165. package/dist/components/reui/phone-input.d.ts.map +1 -0
  166. package/dist/components/reui/phone-input.js +126 -0
  167. package/dist/components/reui/phone-input.js.map +1 -0
  168. package/dist/components/reui/rating.d.ts +34 -0
  169. package/dist/components/reui/rating.d.ts.map +1 -0
  170. package/dist/components/reui/rating.js +94 -0
  171. package/dist/components/reui/rating.js.map +1 -0
  172. package/dist/components/reui/scrollspy.d.ts +17 -0
  173. package/dist/components/reui/scrollspy.d.ts.map +1 -0
  174. package/dist/components/reui/scrollspy.js +130 -0
  175. package/dist/components/reui/scrollspy.js.map +1 -0
  176. package/dist/components/reui/sortable.d.ts +48 -0
  177. package/dist/components/reui/sortable.d.ts.map +1 -0
  178. package/dist/components/reui/sortable.js +230 -0
  179. package/dist/components/reui/sortable.js.map +1 -0
  180. package/dist/components/reui/stepper.d.ts +63 -0
  181. package/dist/components/reui/stepper.d.ts.map +1 -0
  182. package/dist/components/reui/stepper.js +234 -0
  183. package/dist/components/reui/stepper.js.map +1 -0
  184. package/dist/components/reui/timeline.d.ts +24 -0
  185. package/dist/components/reui/timeline.d.ts.map +1 -0
  186. package/dist/components/reui/timeline.js +123 -0
  187. package/dist/components/reui/timeline.js.map +1 -0
  188. package/dist/components/reui/tree.d.ts +23 -0
  189. package/dist/components/reui/tree.d.ts.map +1 -0
  190. package/dist/components/reui/tree.js +115 -0
  191. package/dist/components/reui/tree.js.map +1 -0
  192. package/dist/components/ui/accordion.d.ts +9 -0
  193. package/dist/components/ui/accordion.d.ts.map +1 -0
  194. package/dist/components/ui/accordion.js +56 -0
  195. package/dist/components/ui/accordion.js.map +1 -0
  196. package/dist/components/ui/alert-dialog.d.ts +21 -0
  197. package/dist/components/ui/alert-dialog.d.ts.map +1 -0
  198. package/dist/components/ui/alert-dialog.js +96 -0
  199. package/dist/components/ui/alert-dialog.js.map +1 -0
  200. package/dist/components/ui/alert.d.ts +13 -0
  201. package/dist/components/ui/alert.d.ts.map +1 -0
  202. package/dist/components/ui/alert.js +45 -0
  203. package/dist/components/ui/alert.js.map +1 -0
  204. package/dist/components/ui/aspect-ratio.d.ts +8 -0
  205. package/dist/components/ui/aspect-ratio.d.ts.map +1 -0
  206. package/dist/components/ui/aspect-ratio.js +16 -0
  207. package/dist/components/ui/aspect-ratio.js.map +1 -0
  208. package/dist/components/ui/attachment.d.ts +26 -0
  209. package/dist/components/ui/attachment.d.ts.map +1 -0
  210. package/dist/components/ui/attachment.js +106 -0
  211. package/dist/components/ui/attachment.js.map +1 -0
  212. package/dist/components/ui/avatar.d.ts +14 -0
  213. package/dist/components/ui/avatar.d.ts.map +1 -0
  214. package/dist/components/ui/avatar.js +52 -0
  215. package/dist/components/ui/avatar.js.map +1 -0
  216. package/dist/components/ui/badge.d.ts +10 -0
  217. package/dist/components/ui/badge.d.ts.map +1 -0
  218. package/dist/components/ui/badge.js +32 -0
  219. package/dist/components/ui/badge.js.map +1 -0
  220. package/dist/components/ui/breadcrumb.d.ts +13 -0
  221. package/dist/components/ui/breadcrumb.d.ts.map +1 -0
  222. package/dist/components/ui/breadcrumb.js +72 -0
  223. package/dist/components/ui/breadcrumb.js.map +1 -0
  224. package/dist/components/ui/bubble.d.ts +19 -0
  225. package/dist/components/ui/bubble.d.ts.map +1 -0
  226. package/dist/components/ui/bubble.js +75 -0
  227. package/dist/components/ui/bubble.js.map +1 -0
  228. package/dist/components/ui/button-group.d.ts +14 -0
  229. package/dist/components/ui/button-group.d.ts.map +1 -0
  230. package/dist/components/ui/button-group.js +44 -0
  231. package/dist/components/ui/button-group.js.map +1 -0
  232. package/dist/components/ui/button.d.ts +11 -0
  233. package/dist/components/ui/button.d.ts.map +1 -0
  234. package/dist/components/ui/button.js +47 -0
  235. package/dist/components/ui/button.js.map +1 -0
  236. package/dist/components/ui/calendar.d.ts +13 -0
  237. package/dist/components/ui/calendar.d.ts.map +1 -0
  238. package/dist/components/ui/calendar.js +110 -0
  239. package/dist/components/ui/calendar.js.map +1 -0
  240. package/dist/components/ui/card.d.ts +14 -0
  241. package/dist/components/ui/card.d.ts.map +1 -0
  242. package/dist/components/ui/card.js +58 -0
  243. package/dist/components/ui/card.js.map +1 -0
  244. package/dist/components/ui/carousel.d.ts +31 -0
  245. package/dist/components/ui/carousel.d.ts.map +1 -0
  246. package/dist/components/ui/carousel.js +135 -0
  247. package/dist/components/ui/carousel.js.map +1 -0
  248. package/dist/components/ui/chart.d.ts +47 -0
  249. package/dist/components/ui/chart.d.ts.map +1 -0
  250. package/dist/components/ui/chart.js +151 -0
  251. package/dist/components/ui/chart.js.map +1 -0
  252. package/dist/components/ui/checkbox.d.ts +6 -0
  253. package/dist/components/ui/checkbox.d.ts.map +1 -0
  254. package/dist/components/ui/checkbox.js +22 -0
  255. package/dist/components/ui/checkbox.js.map +1 -0
  256. package/dist/components/ui/collapsible.d.ts +8 -0
  257. package/dist/components/ui/collapsible.d.ts.map +1 -0
  258. package/dist/components/ui/collapsible.js +26 -0
  259. package/dist/components/ui/collapsible.js.map +1 -0
  260. package/dist/components/ui/combobox.d.ts +27 -0
  261. package/dist/components/ui/combobox.d.ts.map +1 -0
  262. package/dist/components/ui/combobox.js +164 -0
  263. package/dist/components/ui/combobox.js.map +1 -0
  264. package/dist/components/ui/command.d.ts +22 -0
  265. package/dist/components/ui/command.d.ts.map +1 -0
  266. package/dist/components/ui/command.js +89 -0
  267. package/dist/components/ui/command.js.map +1 -0
  268. package/dist/components/ui/context-menu.d.ts +32 -0
  269. package/dist/components/ui/context-menu.d.ts.map +1 -0
  270. package/dist/components/ui/context-menu.js +134 -0
  271. package/dist/components/ui/context-menu.js.map +1 -0
  272. package/dist/components/ui/dialog.d.ts +20 -0
  273. package/dist/components/ui/dialog.d.ts.map +1 -0
  274. package/dist/components/ui/dialog.js +93 -0
  275. package/dist/components/ui/dialog.js.map +1 -0
  276. package/dist/components/ui/direction.d.ts +2 -0
  277. package/dist/components/ui/direction.js +3 -0
  278. package/dist/components/ui/drawer.d.ts +19 -0
  279. package/dist/components/ui/drawer.d.ts.map +1 -0
  280. package/dist/components/ui/drawer.js +125 -0
  281. package/dist/components/ui/drawer.js.map +1 -0
  282. package/dist/components/ui/dropdown-menu.d.ts +32 -0
  283. package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
  284. package/dist/components/ui/dropdown-menu.js +138 -0
  285. package/dist/components/ui/dropdown-menu.js.map +1 -0
  286. package/dist/components/ui/empty.d.ts +15 -0
  287. package/dist/components/ui/empty.d.ts.map +1 -0
  288. package/dist/components/ui/empty.js +62 -0
  289. package/dist/components/ui/empty.js.map +1 -0
  290. package/dist/components/ui/field.d.ts +28 -0
  291. package/dist/components/ui/field.d.ts.map +1 -0
  292. package/dist/components/ui/field.js +112 -0
  293. package/dist/components/ui/field.js.map +1 -0
  294. package/dist/components/ui/hover-card.d.ts +8 -0
  295. package/dist/components/ui/hover-card.d.ts.map +1 -0
  296. package/dist/components/ui/hover-card.js +38 -0
  297. package/dist/components/ui/hover-card.js.map +1 -0
  298. package/dist/components/ui/input-group.d.ts +21 -0
  299. package/dist/components/ui/input-group.d.ts.map +1 -0
  300. package/dist/components/ui/input-group.js +80 -0
  301. package/dist/components/ui/input-group.js.map +1 -0
  302. package/dist/components/ui/input-otp.d.ts +14 -0
  303. package/dist/components/ui/input-otp.d.ts.map +1 -0
  304. package/dist/components/ui/input-otp.js +49 -0
  305. package/dist/components/ui/input-otp.js.map +1 -0
  306. package/dist/components/ui/input.d.ts +6 -0
  307. package/dist/components/ui/input.d.ts.map +1 -0
  308. package/dist/components/ui/input.js +17 -0
  309. package/dist/components/ui/input.js.map +1 -0
  310. package/dist/components/ui/item.d.ts +25 -0
  311. package/dist/components/ui/item.d.ts.map +1 -0
  312. package/dist/components/ui/item.js +123 -0
  313. package/dist/components/ui/item.js.map +1 -0
  314. package/dist/components/ui/kbd.d.ts +7 -0
  315. package/dist/components/ui/kbd.d.ts.map +1 -0
  316. package/dist/components/ui/kbd.js +22 -0
  317. package/dist/components/ui/kbd.js.map +1 -0
  318. package/dist/components/ui/label.d.ts +6 -0
  319. package/dist/components/ui/label.d.ts.map +1 -0
  320. package/dist/components/ui/label.js +15 -0
  321. package/dist/components/ui/label.js.map +1 -0
  322. package/dist/components/ui/marker.d.ts +13 -0
  323. package/dist/components/ui/marker.d.ts.map +1 -0
  324. package/dist/components/ui/marker.js +45 -0
  325. package/dist/components/ui/marker.js.map +1 -0
  326. package/dist/components/ui/menubar.d.ts +32 -0
  327. package/dist/components/ui/menubar.d.ts.map +1 -0
  328. package/dist/components/ui/menubar.js +137 -0
  329. package/dist/components/ui/menubar.js.map +1 -0
  330. package/dist/components/ui/message-scroller.d.ts +13 -0
  331. package/dist/components/ui/message-scroller.d.ts.map +1 -0
  332. package/dist/components/ui/message-scroller.js +62 -0
  333. package/dist/components/ui/message-scroller.js.map +1 -0
  334. package/dist/components/ui/message.d.ts +13 -0
  335. package/dist/components/ui/message.d.ts.map +1 -0
  336. package/dist/components/ui/message.js +51 -0
  337. package/dist/components/ui/message.js.map +1 -0
  338. package/dist/components/ui/native-select.d.ts +11 -0
  339. package/dist/components/ui/native-select.d.ts.map +1 -0
  340. package/dist/components/ui/native-select.js +40 -0
  341. package/dist/components/ui/native-select.js.map +1 -0
  342. package/dist/components/ui/navigation-menu.d.ts +15 -0
  343. package/dist/components/ui/navigation-menu.d.ts.map +1 -0
  344. package/dist/components/ui/navigation-menu.js +85 -0
  345. package/dist/components/ui/navigation-menu.js.map +1 -0
  346. package/dist/components/ui/pagination.d.ts +20 -0
  347. package/dist/components/ui/pagination.d.ts.map +1 -0
  348. package/dist/components/ui/pagination.js +81 -0
  349. package/dist/components/ui/pagination.js.map +1 -0
  350. package/dist/components/ui/popover.d.ts +12 -0
  351. package/dist/components/ui/popover.d.ts.map +1 -0
  352. package/dist/components/ui/popover.js +56 -0
  353. package/dist/components/ui/popover.js.map +1 -0
  354. package/dist/components/ui/progress.d.ts +10 -0
  355. package/dist/components/ui/progress.d.ts.map +1 -0
  356. package/dist/components/ui/progress.js +46 -0
  357. package/dist/components/ui/progress.js.map +1 -0
  358. package/dist/components/ui/radio-group.d.ts +8 -0
  359. package/dist/components/ui/radio-group.d.ts.map +1 -0
  360. package/dist/components/ui/radio-group.js +29 -0
  361. package/dist/components/ui/radio-group.js.map +1 -0
  362. package/dist/components/ui/resizable.d.ts +10 -0
  363. package/dist/components/ui/resizable.d.ts.map +1 -0
  364. package/dist/components/ui/resizable.js +30 -0
  365. package/dist/components/ui/resizable.js.map +1 -0
  366. package/dist/components/ui/scroll-area.d.ts +7 -0
  367. package/dist/components/ui/scroll-area.d.ts.map +1 -0
  368. package/dist/components/ui/scroll-area.js +38 -0
  369. package/dist/components/ui/scroll-area.js.map +1 -0
  370. package/dist/components/ui/select.d.ts +18 -0
  371. package/dist/components/ui/select.d.ts.map +1 -0
  372. package/dist/components/ui/select.js +99 -0
  373. package/dist/components/ui/select.js.map +1 -0
  374. package/dist/components/ui/separator.d.ts +6 -0
  375. package/dist/components/ui/separator.d.ts.map +1 -0
  376. package/dist/components/ui/separator.js +17 -0
  377. package/dist/components/ui/separator.js.map +1 -0
  378. package/dist/components/ui/sheet.d.ts +17 -0
  379. package/dist/components/ui/sheet.d.ts.map +1 -0
  380. package/dist/components/ui/sheet.js +90 -0
  381. package/dist/components/ui/sheet.js.map +1 -0
  382. package/dist/components/ui/sidebar.d.ts +66 -0
  383. package/dist/components/ui/sidebar.d.ts.map +1 -0
  384. package/dist/components/ui/sidebar.js +383 -0
  385. package/dist/components/ui/sidebar.js.map +1 -0
  386. package/dist/components/ui/skeleton.d.ts +6 -0
  387. package/dist/components/ui/skeleton.d.ts.map +1 -0
  388. package/dist/components/ui/skeleton.js +15 -0
  389. package/dist/components/ui/skeleton.js.map +1 -0
  390. package/dist/components/ui/slider.d.ts +6 -0
  391. package/dist/components/ui/slider.d.ts.map +1 -0
  392. package/dist/components/ui/slider.js +36 -0
  393. package/dist/components/ui/slider.js.map +1 -0
  394. package/dist/components/ui/sonner.d.ts +7 -0
  395. package/dist/components/ui/sonner.d.ts.map +1 -0
  396. package/dist/components/ui/sonner.js +32 -0
  397. package/dist/components/ui/sonner.js.map +1 -0
  398. package/dist/components/ui/spinner.d.ts +6 -0
  399. package/dist/components/ui/spinner.d.ts.map +1 -0
  400. package/dist/components/ui/spinner.js +18 -0
  401. package/dist/components/ui/spinner.js.map +1 -0
  402. package/dist/components/ui/switch.d.ts +8 -0
  403. package/dist/components/ui/switch.d.ts.map +1 -0
  404. package/dist/components/ui/switch.js +21 -0
  405. package/dist/components/ui/switch.js.map +1 -0
  406. package/dist/components/ui/table.d.ts +13 -0
  407. package/dist/components/ui/table.d.ts.map +1 -0
  408. package/dist/components/ui/table.js +68 -0
  409. package/dist/components/ui/table.js.map +1 -0
  410. package/dist/components/ui/tabs.d.ts +13 -0
  411. package/dist/components/ui/tabs.d.ts.map +1 -0
  412. package/dist/components/ui/tabs.js +47 -0
  413. package/dist/components/ui/tabs.js.map +1 -0
  414. package/dist/components/ui/textarea.d.ts +6 -0
  415. package/dist/components/ui/textarea.d.ts.map +1 -0
  416. package/dist/components/ui/textarea.js +15 -0
  417. package/dist/components/ui/textarea.js.map +1 -0
  418. package/dist/components/ui/toggle-group.d.ts +14 -0
  419. package/dist/components/ui/toggle-group.d.ts.map +1 -0
  420. package/dist/components/ui/toggle-group.js +54 -0
  421. package/dist/components/ui/toggle-group.js.map +1 -0
  422. package/dist/components/ui/toggle.d.ts +11 -0
  423. package/dist/components/ui/toggle.d.ts.map +1 -0
  424. package/dist/components/ui/toggle.js +38 -0
  425. package/dist/components/ui/toggle.js.map +1 -0
  426. package/dist/components/ui/tooltip.d.ts +9 -0
  427. package/dist/components/ui/tooltip.d.ts.map +1 -0
  428. package/dist/components/ui/tooltip.js +43 -0
  429. package/dist/components/ui/tooltip.js.map +1 -0
  430. package/dist/hooks/use-body-classes.d.ts +27 -0
  431. package/dist/hooks/use-body-classes.d.ts.map +1 -0
  432. package/dist/hooks/use-body-classes.js +52 -0
  433. package/dist/hooks/use-body-classes.js.map +1 -0
  434. package/dist/hooks/use-copy-to-clipboard.d.ts +43 -0
  435. package/dist/hooks/use-copy-to-clipboard.d.ts.map +1 -0
  436. package/dist/hooks/use-copy-to-clipboard.js +69 -0
  437. package/dist/hooks/use-copy-to-clipboard.js.map +1 -0
  438. package/dist/hooks/use-file-upload.d.ts +49 -0
  439. package/dist/hooks/use-file-upload.d.ts.map +1 -0
  440. package/dist/hooks/use-file-upload.js +227 -0
  441. package/dist/hooks/use-file-upload.js.map +1 -0
  442. package/dist/hooks/use-hydrated.d.ts +37 -0
  443. package/dist/hooks/use-hydrated.d.ts.map +1 -0
  444. package/dist/hooks/use-hydrated.js +50 -0
  445. package/dist/hooks/use-hydrated.js.map +1 -0
  446. package/dist/hooks/use-intersection-observer.d.ts +55 -0
  447. package/dist/hooks/use-intersection-observer.d.ts.map +1 -0
  448. package/dist/hooks/use-intersection-observer.js +144 -0
  449. package/dist/hooks/use-intersection-observer.js.map +1 -0
  450. package/dist/hooks/use-is-mac.d.ts +28 -0
  451. package/dist/hooks/use-is-mac.d.ts.map +1 -0
  452. package/dist/hooks/use-is-mac.js +38 -0
  453. package/dist/hooks/use-is-mac.js.map +1 -0
  454. package/dist/hooks/use-media-query.d.ts +44 -0
  455. package/dist/hooks/use-media-query.d.ts.map +1 -0
  456. package/dist/hooks/use-media-query.js +58 -0
  457. package/dist/hooks/use-media-query.js.map +1 -0
  458. package/dist/hooks/use-meta-color.d.ts +78 -0
  459. package/dist/hooks/use-meta-color.d.ts.map +1 -0
  460. package/dist/hooks/use-meta-color.js +138 -0
  461. package/dist/hooks/use-meta-color.js.map +1 -0
  462. package/dist/hooks/use-mobile.d.ts +5 -0
  463. package/dist/hooks/use-mobile.d.ts.map +1 -0
  464. package/dist/hooks/use-mobile.js +21 -0
  465. package/dist/hooks/use-mobile.js.map +1 -0
  466. package/dist/hooks/use-mutation-observer.d.ts +61 -0
  467. package/dist/hooks/use-mutation-observer.d.ts.map +1 -0
  468. package/dist/hooks/use-mutation-observer.js +96 -0
  469. package/dist/hooks/use-mutation-observer.js.map +1 -0
  470. package/dist/hooks/use-scroll-position.d.ts +76 -0
  471. package/dist/hooks/use-scroll-position.d.ts.map +1 -0
  472. package/dist/hooks/use-scroll-position.js +97 -0
  473. package/dist/hooks/use-scroll-position.js.map +1 -0
  474. package/dist/hooks/use-slider-input.d.ts +94 -0
  475. package/dist/hooks/use-slider-input.d.ts.map +1 -0
  476. package/dist/hooks/use-slider-input.js +116 -0
  477. package/dist/hooks/use-slider-input.js.map +1 -0
  478. package/dist/hooks/use-viewport.d.ts +72 -0
  479. package/dist/hooks/use-viewport.d.ts.map +1 -0
  480. package/dist/hooks/use-viewport.js +91 -0
  481. package/dist/hooks/use-viewport.js.map +1 -0
  482. package/dist/style.css +0 -247
  483. package/dist/theme.css +244 -0
  484. package/dist/theme.css.d.ts +3 -0
  485. package/package.json +101 -40
  486. package/dist/hooks.d.ts +0 -957
  487. package/dist/hooks.d.ts.map +0 -1
  488. package/dist/hooks.js +0 -1391
  489. package/dist/hooks.js.map +0 -1
  490. package/dist/index.d.ts +0 -1993
  491. package/dist/index.d.ts.map +0 -1
  492. package/dist/index.js +0 -10647
  493. package/dist/index.js.map +0 -1
  494. package/dist/source.css +0 -1
  495. package/dist/source.css.d.ts +0 -3
  496. package/dist/use-is-mobile-Dln4-L1O.js +0 -210
  497. package/dist/use-is-mobile-Dln4-L1O.js.map +0 -1
@@ -0,0 +1,69 @@
1
+ "use client";
2
+ import * as React$1 from "react";
3
+ import { isDevelopment } from "@kumix/utils";
4
+ //#region src/hooks/use-copy-to-clipboard.ts
5
+ /**
6
+ * Clipboard copy functionality hook for React components.
7
+ */
8
+ /**
9
+ * Copies text to the clipboard and exposes temporary copied state.
10
+ *
11
+ * @param options - Configuration options for the hook
12
+ * @returns Object containing copied state and an async copy function. The copy
13
+ * function resolves to `true` when text is copied and `false` otherwise.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * const { copied, copy } = useCopyToClipboard({
18
+ * timeout: 3000,
19
+ * onCopy: () => toast.success('Copied to clipboard!')
20
+ * });
21
+ *
22
+ * return (
23
+ * <button onClick={() => copy('Hello World')}>
24
+ * {copied ? 'Copied!' : 'Copy Text'}
25
+ * </button>
26
+ * );
27
+ * ```
28
+ */
29
+ function useCopyToClipboard({ timeout = 2e3, onCopy } = {}) {
30
+ const [copied, setCopied] = React$1.useState(false);
31
+ const timerRef = React$1.useRef(null);
32
+ React$1.useEffect(() => {
33
+ return () => {
34
+ if (timerRef.current) clearTimeout(timerRef.current);
35
+ };
36
+ }, []);
37
+ return {
38
+ /** Whether text was recently copied (true for timeout duration) */
39
+ copied,
40
+ /** Function to copy text to clipboard */
41
+ copy: React$1.useCallback(async (value) => {
42
+ if (typeof window === "undefined" || !navigator.clipboard?.writeText) {
43
+ if (isDevelopment) console.warn("Clipboard API not supported in this environment");
44
+ return false;
45
+ }
46
+ if (!value) {
47
+ if (isDevelopment) console.warn("Cannot copy empty value to clipboard");
48
+ return false;
49
+ }
50
+ try {
51
+ await navigator.clipboard.writeText(value);
52
+ setCopied(true);
53
+ onCopy?.();
54
+ if (timerRef.current) clearTimeout(timerRef.current);
55
+ timerRef.current = setTimeout(() => {
56
+ setCopied(false);
57
+ }, timeout);
58
+ return true;
59
+ } catch (error) {
60
+ if (isDevelopment) console.error("Failed to copy text to clipboard:", error);
61
+ return false;
62
+ }
63
+ }, [timeout, onCopy])
64
+ };
65
+ }
66
+ //#endregion
67
+ export { useCopyToClipboard };
68
+
69
+ //# sourceMappingURL=use-copy-to-clipboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-copy-to-clipboard.js","names":["React"],"sources":["../../src/hooks/use-copy-to-clipboard.ts"],"sourcesContent":["/**\n * Clipboard copy functionality hook for React components.\n */\n\n\"use client\";\n\nimport * as React from \"react\";\n\nimport { isDevelopment } from \"@kumix/utils\";\n\n/**\n * Configuration options for the copy to clipboard hook\n */\ninterface UseCopyToClipboardOptions {\n /** Duration in milliseconds to show the copied state (default: 2000ms) */\n timeout?: number;\n /** Callback function executed after successful copy operation */\n onCopy?: () => void;\n}\n\n/**\n * Copies text to the clipboard and exposes temporary copied state.\n *\n * @param options - Configuration options for the hook\n * @returns Object containing copied state and an async copy function. The copy\n * function resolves to `true` when text is copied and `false` otherwise.\n *\n * @example\n * ```tsx\n * const { copied, copy } = useCopyToClipboard({\n * timeout: 3000,\n * onCopy: () => toast.success('Copied to clipboard!')\n * });\n *\n * return (\n * <button onClick={() => copy('Hello World')}>\n * {copied ? 'Copied!' : 'Copy Text'}\n * </button>\n * );\n * ```\n */\nexport function useCopyToClipboard({ timeout = 2000, onCopy }: UseCopyToClipboardOptions = {}) {\n const [copied, setCopied] = React.useState(false);\n const timerRef = React.useRef<ReturnType<typeof setTimeout>>(null);\n\n React.useEffect(() => {\n return () => {\n if (timerRef.current) clearTimeout(timerRef.current);\n };\n }, []);\n\n const copy = React.useCallback(\n async (value: string) => {\n if (typeof window === \"undefined\" || !navigator.clipboard?.writeText) {\n if (isDevelopment) {\n console.warn(\"Clipboard API not supported in this environment\");\n }\n return false;\n }\n\n if (!value) {\n if (isDevelopment) {\n console.warn(\"Cannot copy empty value to clipboard\");\n }\n return false;\n }\n\n try {\n await navigator.clipboard.writeText(value);\n setCopied(true);\n onCopy?.();\n\n if (timerRef.current) clearTimeout(timerRef.current);\n timerRef.current = setTimeout(() => {\n setCopied(false);\n }, timeout);\n return true;\n } catch (error) {\n if (isDevelopment) {\n console.error(\"Failed to copy text to clipboard:\", error);\n }\n return false;\n }\n },\n [timeout, onCopy],\n );\n\n return {\n /** Whether text was recently copied (true for timeout duration) */\n copied,\n /** Function to copy text to clipboard */\n copy,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,mBAAmB,EAAE,UAAU,KAAM,WAAsC,CAAC,GAAG;CAC7F,MAAM,CAAC,QAAQ,aAAaA,QAAM,SAAS,KAAK;CAChD,MAAM,WAAWA,QAAM,OAAsC,IAAI;CAEjE,QAAM,gBAAgB;EACpB,aAAa;GACX,IAAI,SAAS,SAAS,aAAa,SAAS,OAAO;EACrD;CACF,GAAG,CAAC,CAAC;CAsCL,OAAO;;EAEL;;EAEA,MAxCWA,QAAM,YACjB,OAAO,UAAkB;GACvB,IAAI,OAAO,WAAW,eAAe,CAAC,UAAU,WAAW,WAAW;IACpE,IAAI,eACF,QAAQ,KAAK,iDAAiD;IAEhE,OAAO;GACT;GAEA,IAAI,CAAC,OAAO;IACV,IAAI,eACF,QAAQ,KAAK,sCAAsC;IAErD,OAAO;GACT;GAEA,IAAI;IACF,MAAM,UAAU,UAAU,UAAU,KAAK;IACzC,UAAU,IAAI;IACd,SAAS;IAET,IAAI,SAAS,SAAS,aAAa,SAAS,OAAO;IACnD,SAAS,UAAU,iBAAiB;KAClC,UAAU,KAAK;IACjB,GAAG,OAAO;IACV,OAAO;GACT,SAAS,OAAO;IACd,IAAI,eACF,QAAQ,MAAM,qCAAqC,KAAK;IAE1D,OAAO;GACT;EACF,GACA,CAAC,SAAS,MAAM,CAOb;CACL;AACF"}
@@ -0,0 +1,49 @@
1
+ import React, { ChangeEvent, DragEvent, InputHTMLAttributes } from "react";
2
+ //#region src/hooks/use-file-upload.d.ts
3
+ type FileMetadata = {
4
+ name: string;
5
+ size: number;
6
+ type: string;
7
+ url: string;
8
+ id: string;
9
+ };
10
+ type FileWithPreview = {
11
+ file: File | FileMetadata;
12
+ id: string;
13
+ preview?: string;
14
+ };
15
+ type FileUploadOptions = {
16
+ maxFiles?: number;
17
+ maxSize?: number;
18
+ accept?: string;
19
+ multiple?: boolean;
20
+ initialFiles?: FileMetadata[];
21
+ onFilesChange?: (files: FileWithPreview[]) => void;
22
+ onFilesAdded?: (addedFiles: FileWithPreview[]) => void;
23
+ onError?: (errors: string[]) => void;
24
+ };
25
+ type FileUploadState = {
26
+ files: FileWithPreview[];
27
+ isDragging: boolean;
28
+ errors: string[];
29
+ };
30
+ type FileUploadActions = {
31
+ addFiles: (files: FileList | File[]) => void;
32
+ removeFile: (id: string) => void;
33
+ clearFiles: () => void;
34
+ clearErrors: () => void;
35
+ handleDragEnter: (e: DragEvent<HTMLElement>) => void;
36
+ handleDragLeave: (e: DragEvent<HTMLElement>) => void;
37
+ handleDragOver: (e: DragEvent<HTMLElement>) => void;
38
+ handleDrop: (e: DragEvent<HTMLElement>) => void;
39
+ handleFileChange: (e: ChangeEvent<HTMLInputElement>) => void;
40
+ openFileDialog: () => void;
41
+ getInputProps: (props?: InputHTMLAttributes<HTMLInputElement>) => InputHTMLAttributes<HTMLInputElement> & {
42
+ ref: React.Ref<HTMLInputElement>;
43
+ };
44
+ };
45
+ declare const useFileUpload: (options?: FileUploadOptions) => [FileUploadState, FileUploadActions];
46
+ declare const formatBytes: (bytes: number, decimals?: number) => string;
47
+ //#endregion
48
+ export { FileMetadata, FileUploadActions, FileUploadOptions, FileUploadState, FileWithPreview, formatBytes, useFileUpload };
49
+ //# sourceMappingURL=use-file-upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-file-upload.d.ts","names":[],"sources":["../../src/hooks/use-file-upload.ts"],"mappings":";;KAYY;EACV;EACA;EACA;EACA;EACA;;KAGU;EACV,MAAM,OAAO;EACb;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA,eAAe;EACf,iBAAiB,OAAO;EACxB,gBAAgB,YAAY;EAC5B,WAAW;;KAGD;EACV,OAAO;EACP;EACA;;KAGU;EACV,WAAW,OAAO,WAAW;EAC7B,aAAa;EACb;EACA;EACA,kBAAkB,GAAG,UAAU;EAC/B,kBAAkB,GAAG,UAAU;EAC/B,iBAAiB,GAAG,UAAU;EAC9B,aAAa,GAAG,UAAU;EAC1B,mBAAmB,GAAG,YAAY;EAClC;EACA,gBACE,QAAQ,oBAAoB,sBACzB,oBAAoB;IACvB,KAAK,MAAM,IAAI;;;cAIN,gBACX,UAAS,uBACP,iBAAiB;cAuUR,cAAe,eAAe"}
@@ -0,0 +1,227 @@
1
+ "use client";
2
+ import { useCallback, useRef, useState } from "react";
3
+ //#region src/hooks/use-file-upload.ts
4
+ const useFileUpload = (options = {}) => {
5
+ const { maxFiles = Number.POSITIVE_INFINITY, maxSize = Number.POSITIVE_INFINITY, accept = "*", multiple = false, initialFiles = [], onFilesChange, onFilesAdded, onError } = options;
6
+ const [state, setState] = useState({
7
+ files: initialFiles.map((file) => ({
8
+ file,
9
+ id: file.id,
10
+ preview: file.url
11
+ })),
12
+ isDragging: false,
13
+ errors: []
14
+ });
15
+ const inputRef = useRef(null);
16
+ const validateFile = useCallback((file) => {
17
+ if (file.size > maxSize) return `File "${file.name}" exceeds the maximum size of ${formatBytes(maxSize)}.`;
18
+ if (accept !== "*") {
19
+ const acceptedTypes = accept.split(",").map((type) => type.trim());
20
+ const fileType = file.type || "";
21
+ const fileExtension = `.${file.name.split(".").pop()}`;
22
+ if (!acceptedTypes.some((type) => {
23
+ if (type.startsWith(".")) return fileExtension.toLowerCase() === type.toLowerCase();
24
+ if (type.endsWith("/*")) {
25
+ const baseType = type.split("/")[0];
26
+ return fileType.startsWith(`${baseType}/`);
27
+ }
28
+ return fileType === type;
29
+ })) return `File "${file.name}" is not an accepted file type.`;
30
+ }
31
+ return null;
32
+ }, [accept, maxSize]);
33
+ const createPreview = useCallback((file) => {
34
+ if (file instanceof File) return URL.createObjectURL(file);
35
+ return file.url;
36
+ }, []);
37
+ const generateUniqueId = useCallback((file) => {
38
+ if (file instanceof File) return `${file.name}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
39
+ return file.id;
40
+ }, []);
41
+ const clearFiles = useCallback(() => {
42
+ setState((prev) => {
43
+ for (const file of prev.files) if (file.preview && file.file instanceof File && file.file.type.startsWith("image/")) URL.revokeObjectURL(file.preview);
44
+ if (inputRef.current) inputRef.current.value = "";
45
+ const newState = {
46
+ ...prev,
47
+ files: [],
48
+ errors: []
49
+ };
50
+ onFilesChange?.(newState.files);
51
+ return newState;
52
+ });
53
+ }, [onFilesChange]);
54
+ const addFiles = useCallback((newFiles) => {
55
+ if (!newFiles || newFiles.length === 0) return;
56
+ const newFilesArray = Array.from(newFiles);
57
+ const errors = [];
58
+ setState((prev) => ({
59
+ ...prev,
60
+ errors: []
61
+ }));
62
+ if (!multiple) clearFiles();
63
+ if (multiple && maxFiles !== Number.POSITIVE_INFINITY && state.files.length + newFilesArray.length > maxFiles) {
64
+ errors.push(`You can only upload a maximum of ${maxFiles} files.`);
65
+ onError?.(errors);
66
+ setState((prev) => ({
67
+ ...prev,
68
+ errors
69
+ }));
70
+ return;
71
+ }
72
+ const validFiles = [];
73
+ for (const file of newFilesArray) {
74
+ if (multiple) {
75
+ if (state.files.some((existingFile) => existingFile.file.name === file.name && existingFile.file.size === file.size)) continue;
76
+ }
77
+ if (file.size > maxSize) {
78
+ errors.push(multiple ? `Some files exceed the maximum size of ${formatBytes(maxSize)}.` : `File exceeds the maximum size of ${formatBytes(maxSize)}.`);
79
+ continue;
80
+ }
81
+ const error = validateFile(file);
82
+ if (error) errors.push(error);
83
+ else validFiles.push({
84
+ file,
85
+ id: generateUniqueId(file),
86
+ preview: createPreview(file)
87
+ });
88
+ }
89
+ if (validFiles.length > 0) {
90
+ onFilesAdded?.(validFiles);
91
+ setState((prev) => {
92
+ const newFiles = !multiple ? validFiles : [...prev.files, ...validFiles];
93
+ onFilesChange?.(newFiles);
94
+ return {
95
+ ...prev,
96
+ files: newFiles,
97
+ errors
98
+ };
99
+ });
100
+ } else if (errors.length > 0) {
101
+ onError?.(errors);
102
+ setState((prev) => ({
103
+ ...prev,
104
+ errors
105
+ }));
106
+ }
107
+ if (inputRef.current) inputRef.current.value = "";
108
+ }, [
109
+ state.files,
110
+ maxFiles,
111
+ multiple,
112
+ maxSize,
113
+ validateFile,
114
+ createPreview,
115
+ generateUniqueId,
116
+ clearFiles,
117
+ onFilesChange,
118
+ onFilesAdded,
119
+ onError
120
+ ]);
121
+ const removeFile = useCallback((id) => {
122
+ setState((prev) => {
123
+ const fileToRemove = prev.files.find((file) => file.id === id);
124
+ if (fileToRemove?.preview && fileToRemove.file instanceof File && fileToRemove.file.type.startsWith("image/")) URL.revokeObjectURL(fileToRemove.preview);
125
+ const newFiles = prev.files.filter((file) => file.id !== id);
126
+ onFilesChange?.(newFiles);
127
+ return {
128
+ ...prev,
129
+ files: newFiles,
130
+ errors: []
131
+ };
132
+ });
133
+ }, [onFilesChange]);
134
+ const clearErrors = useCallback(() => {
135
+ setState((prev) => ({
136
+ ...prev,
137
+ errors: []
138
+ }));
139
+ }, []);
140
+ const handleDragEnter = useCallback((e) => {
141
+ e.preventDefault();
142
+ e.stopPropagation();
143
+ setState((prev) => ({
144
+ ...prev,
145
+ isDragging: true
146
+ }));
147
+ }, []);
148
+ const handleDragLeave = useCallback((e) => {
149
+ e.preventDefault();
150
+ e.stopPropagation();
151
+ if (e.currentTarget.contains(e.relatedTarget)) return;
152
+ setState((prev) => ({
153
+ ...prev,
154
+ isDragging: false
155
+ }));
156
+ }, []);
157
+ const handleDragOver = useCallback((e) => {
158
+ e.preventDefault();
159
+ e.stopPropagation();
160
+ }, []);
161
+ const handleDrop = useCallback((e) => {
162
+ e.preventDefault();
163
+ e.stopPropagation();
164
+ setState((prev) => ({
165
+ ...prev,
166
+ isDragging: false
167
+ }));
168
+ if (inputRef.current?.disabled) return;
169
+ if (e.dataTransfer.files && e.dataTransfer.files.length > 0) if (!multiple) {
170
+ const file = e.dataTransfer.files[0];
171
+ addFiles([file]);
172
+ } else addFiles(e.dataTransfer.files);
173
+ }, [addFiles, multiple]);
174
+ const handleFileChange = useCallback((e) => {
175
+ if (e.target.files && e.target.files.length > 0) addFiles(e.target.files);
176
+ }, [addFiles]);
177
+ return [state, {
178
+ addFiles,
179
+ removeFile,
180
+ clearFiles,
181
+ clearErrors,
182
+ handleDragEnter,
183
+ handleDragLeave,
184
+ handleDragOver,
185
+ handleDrop,
186
+ handleFileChange,
187
+ openFileDialog: useCallback(() => {
188
+ if (inputRef.current) inputRef.current.click();
189
+ }, []),
190
+ getInputProps: useCallback((props = {}) => {
191
+ return {
192
+ ...props,
193
+ type: "file",
194
+ onChange: handleFileChange,
195
+ accept: props.accept || accept,
196
+ multiple: props.multiple !== void 0 ? props.multiple : multiple,
197
+ ref: inputRef
198
+ };
199
+ }, [
200
+ accept,
201
+ multiple,
202
+ handleFileChange
203
+ ])
204
+ }];
205
+ };
206
+ const formatBytes = (bytes, decimals = 2) => {
207
+ if (bytes === 0) return "0 Bytes";
208
+ const k = 1024;
209
+ const dm = decimals < 0 ? 0 : decimals;
210
+ const sizes = [
211
+ "Bytes",
212
+ "KB",
213
+ "MB",
214
+ "GB",
215
+ "TB",
216
+ "PB",
217
+ "EB",
218
+ "ZB",
219
+ "YB"
220
+ ];
221
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
222
+ return `${Number.parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;
223
+ };
224
+ //#endregion
225
+ export { formatBytes, useFileUpload };
226
+
227
+ //# sourceMappingURL=use-file-upload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-file-upload.js","names":[],"sources":["../../src/hooks/use-file-upload.ts"],"sourcesContent":["\"use client\";\n\nimport type React from \"react\";\nimport {\n type ChangeEvent,\n type DragEvent,\n type InputHTMLAttributes,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\nexport type FileMetadata = {\n name: string;\n size: number;\n type: string;\n url: string;\n id: string;\n};\n\nexport type FileWithPreview = {\n file: File | FileMetadata;\n id: string;\n preview?: string;\n};\n\nexport type FileUploadOptions = {\n maxFiles?: number; // Only used when multiple is true, defaults to Infinity\n maxSize?: number; // in bytes\n accept?: string;\n multiple?: boolean; // Defaults to false\n initialFiles?: FileMetadata[];\n onFilesChange?: (files: FileWithPreview[]) => void; // Callback when files change\n onFilesAdded?: (addedFiles: FileWithPreview[]) => void; // Callback when new files are added\n onError?: (errors: string[]) => void;\n};\n\nexport type FileUploadState = {\n files: FileWithPreview[];\n isDragging: boolean;\n errors: string[];\n};\n\nexport type FileUploadActions = {\n addFiles: (files: FileList | File[]) => void;\n removeFile: (id: string) => void;\n clearFiles: () => void;\n clearErrors: () => void;\n handleDragEnter: (e: DragEvent<HTMLElement>) => void;\n handleDragLeave: (e: DragEvent<HTMLElement>) => void;\n handleDragOver: (e: DragEvent<HTMLElement>) => void;\n handleDrop: (e: DragEvent<HTMLElement>) => void;\n handleFileChange: (e: ChangeEvent<HTMLInputElement>) => void;\n openFileDialog: () => void;\n getInputProps: (\n props?: InputHTMLAttributes<HTMLInputElement>,\n ) => InputHTMLAttributes<HTMLInputElement> & {\n ref: React.Ref<HTMLInputElement>;\n };\n};\n\nexport const useFileUpload = (\n options: FileUploadOptions = {},\n): [FileUploadState, FileUploadActions] => {\n const {\n maxFiles = Number.POSITIVE_INFINITY,\n maxSize = Number.POSITIVE_INFINITY,\n accept = \"*\",\n multiple = false,\n initialFiles = [],\n onFilesChange,\n onFilesAdded,\n onError,\n } = options;\n\n const [state, setState] = useState<FileUploadState>({\n files: initialFiles.map((file) => ({\n file,\n id: file.id,\n preview: file.url,\n })),\n isDragging: false,\n errors: [],\n });\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const validateFile = useCallback(\n (file: File | FileMetadata): string | null => {\n if (file.size > maxSize) {\n return `File \"${file.name}\" exceeds the maximum size of ${formatBytes(maxSize)}.`;\n }\n\n if (accept !== \"*\") {\n const acceptedTypes = accept.split(\",\").map((type) => type.trim());\n const fileType = file.type || \"\";\n const fileExtension = `.${file.name.split(\".\").pop()}`;\n\n const isAccepted = acceptedTypes.some((type) => {\n if (type.startsWith(\".\")) {\n return fileExtension.toLowerCase() === type.toLowerCase();\n }\n if (type.endsWith(\"/*\")) {\n const baseType = type.split(\"/\")[0];\n return fileType.startsWith(`${baseType}/`);\n }\n return fileType === type;\n });\n\n if (!isAccepted) {\n return `File \"${file.name}\" is not an accepted file type.`;\n }\n }\n\n return null;\n },\n [accept, maxSize],\n );\n\n const createPreview = useCallback((file: File | FileMetadata): string | undefined => {\n if (file instanceof File) {\n return URL.createObjectURL(file);\n }\n return file.url;\n }, []);\n\n const generateUniqueId = useCallback((file: File | FileMetadata): string => {\n if (file instanceof File) {\n return `${file.name}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;\n }\n return file.id;\n }, []);\n\n const clearFiles = useCallback(() => {\n setState((prev) => {\n // Clean up object URLs\n for (const file of prev.files) {\n if (file.preview && file.file instanceof File && file.file.type.startsWith(\"image/\")) {\n URL.revokeObjectURL(file.preview);\n }\n }\n\n if (inputRef.current) {\n inputRef.current.value = \"\";\n }\n\n const newState = {\n ...prev,\n files: [],\n errors: [],\n };\n\n onFilesChange?.(newState.files);\n return newState;\n });\n }, [onFilesChange]);\n\n const addFiles = useCallback(\n (newFiles: FileList | File[]) => {\n if (!newFiles || newFiles.length === 0) return;\n\n const newFilesArray = Array.from(newFiles);\n const errors: string[] = [];\n\n // Clear existing errors when new files are uploaded\n setState((prev) => ({ ...prev, errors: [] }));\n\n // In single file mode, clear existing files first\n if (!multiple) {\n clearFiles();\n }\n\n // Check if adding these files would exceed maxFiles (only in multiple mode)\n if (\n multiple &&\n maxFiles !== Number.POSITIVE_INFINITY &&\n state.files.length + newFilesArray.length > maxFiles\n ) {\n errors.push(`You can only upload a maximum of ${maxFiles} files.`);\n onError?.(errors);\n setState((prev) => ({ ...prev, errors }));\n return;\n }\n\n const validFiles: FileWithPreview[] = [];\n\n for (const file of newFilesArray) {\n // Only check for duplicates if multiple files are allowed\n if (multiple) {\n const isDuplicate = state.files.some(\n (existingFile) =>\n existingFile.file.name === file.name && existingFile.file.size === file.size,\n );\n\n // Skip duplicate files silently\n if (isDuplicate) {\n continue;\n }\n }\n\n // Check file size\n if (file.size > maxSize) {\n errors.push(\n multiple\n ? `Some files exceed the maximum size of ${formatBytes(maxSize)}.`\n : `File exceeds the maximum size of ${formatBytes(maxSize)}.`,\n );\n continue;\n }\n\n const error = validateFile(file);\n if (error) {\n errors.push(error);\n } else {\n validFiles.push({\n file,\n id: generateUniqueId(file),\n preview: createPreview(file),\n });\n }\n }\n\n // Only update state if we have valid files to add\n if (validFiles.length > 0) {\n // Call the onFilesAdded callback with the newly added valid files\n onFilesAdded?.(validFiles);\n\n setState((prev) => {\n const newFiles = !multiple ? validFiles : [...prev.files, ...validFiles];\n onFilesChange?.(newFiles);\n return {\n ...prev,\n files: newFiles,\n errors,\n };\n });\n } else if (errors.length > 0) {\n onError?.(errors);\n setState((prev) => ({\n ...prev,\n errors,\n }));\n }\n\n // Reset input value after handling files\n if (inputRef.current) {\n inputRef.current.value = \"\";\n }\n },\n [\n state.files,\n maxFiles,\n multiple,\n maxSize,\n validateFile,\n createPreview,\n generateUniqueId,\n clearFiles,\n onFilesChange,\n onFilesAdded,\n onError,\n ],\n );\n\n const removeFile = useCallback(\n (id: string) => {\n setState((prev) => {\n const fileToRemove = prev.files.find((file) => file.id === id);\n if (\n fileToRemove?.preview &&\n fileToRemove.file instanceof File &&\n fileToRemove.file.type.startsWith(\"image/\")\n ) {\n URL.revokeObjectURL(fileToRemove.preview);\n }\n\n const newFiles = prev.files.filter((file) => file.id !== id);\n onFilesChange?.(newFiles);\n\n return {\n ...prev,\n files: newFiles,\n errors: [],\n };\n });\n },\n [onFilesChange],\n );\n\n const clearErrors = useCallback(() => {\n setState((prev) => ({\n ...prev,\n errors: [],\n }));\n }, []);\n\n const handleDragEnter = useCallback((e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n setState((prev) => ({ ...prev, isDragging: true }));\n }, []);\n\n const handleDragLeave = useCallback((e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n\n if (e.currentTarget.contains(e.relatedTarget as Node)) {\n return;\n }\n\n setState((prev) => ({ ...prev, isDragging: false }));\n }, []);\n\n const handleDragOver = useCallback((e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n }, []);\n\n const handleDrop = useCallback(\n (e: DragEvent<HTMLElement>) => {\n e.preventDefault();\n e.stopPropagation();\n setState((prev) => ({ ...prev, isDragging: false }));\n\n // Don't process files if the input is disabled\n if (inputRef.current?.disabled) {\n return;\n }\n\n if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {\n // In single file mode, only use the first file\n if (!multiple) {\n const file = e.dataTransfer.files[0];\n addFiles([file]);\n } else {\n addFiles(e.dataTransfer.files);\n }\n }\n },\n [addFiles, multiple],\n );\n\n const handleFileChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.files && e.target.files.length > 0) {\n addFiles(e.target.files);\n }\n },\n [addFiles],\n );\n\n const openFileDialog = useCallback(() => {\n if (inputRef.current) {\n inputRef.current.click();\n }\n }, []);\n\n const getInputProps = useCallback(\n (props: InputHTMLAttributes<HTMLInputElement> = {}) => {\n return {\n ...props,\n type: \"file\" as const,\n onChange: handleFileChange,\n accept: props.accept || accept,\n multiple: props.multiple !== undefined ? props.multiple : multiple,\n ref: inputRef,\n };\n },\n [accept, multiple, handleFileChange],\n );\n\n return [\n state,\n {\n addFiles,\n removeFile,\n clearFiles,\n clearErrors,\n handleDragEnter,\n handleDragLeave,\n handleDragOver,\n handleDrop,\n handleFileChange,\n openFileDialog,\n getInputProps,\n },\n ];\n};\n\n// Helper function to format bytes to human-readable format\nexport const formatBytes = (bytes: number, decimals = 2): string => {\n if (bytes === 0) return \"0 Bytes\";\n\n const k = 1024;\n const dm = decimals < 0 ? 0 : decimals;\n const sizes = [\"Bytes\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"];\n\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n\n return `${Number.parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;\n};\n"],"mappings":";;;AA6DA,MAAa,iBACX,UAA6B,CAAC,MACW;CACzC,MAAM,EACJ,WAAW,OAAO,mBAClB,UAAU,OAAO,mBACjB,SAAS,KACT,WAAW,OACX,eAAe,CAAC,GAChB,eACA,cACA,YACE;CAEJ,MAAM,CAAC,OAAO,YAAY,SAA0B;EAClD,OAAO,aAAa,KAAK,UAAU;GACjC;GACA,IAAI,KAAK;GACT,SAAS,KAAK;EAChB,EAAE;EACF,YAAY;EACZ,QAAQ,CAAC;CACX,CAAC;CAED,MAAM,WAAW,OAAyB,IAAI;CAE9C,MAAM,eAAe,aAClB,SAA6C;EAC5C,IAAI,KAAK,OAAO,SACd,OAAO,SAAS,KAAK,KAAK,gCAAgC,YAAY,OAAO,EAAE;EAGjF,IAAI,WAAW,KAAK;GAClB,MAAM,gBAAgB,OAAO,MAAM,GAAG,CAAC,CAAC,KAAK,SAAS,KAAK,KAAK,CAAC;GACjE,MAAM,WAAW,KAAK,QAAQ;GAC9B,MAAM,gBAAgB,IAAI,KAAK,KAAK,MAAM,GAAG,CAAC,CAAC,IAAI;GAanD,IAAI,CAXe,cAAc,MAAM,SAAS;IAC9C,IAAI,KAAK,WAAW,GAAG,GACrB,OAAO,cAAc,YAAY,MAAM,KAAK,YAAY;IAE1D,IAAI,KAAK,SAAS,IAAI,GAAG;KACvB,MAAM,WAAW,KAAK,MAAM,GAAG,CAAC,CAAC;KACjC,OAAO,SAAS,WAAW,GAAG,SAAS,EAAE;IAC3C;IACA,OAAO,aAAa;GACtB,CAEc,GACZ,OAAO,SAAS,KAAK,KAAK;EAE9B;EAEA,OAAO;CACT,GACA,CAAC,QAAQ,OAAO,CAClB;CAEA,MAAM,gBAAgB,aAAa,SAAkD;EACnF,IAAI,gBAAgB,MAClB,OAAO,IAAI,gBAAgB,IAAI;EAEjC,OAAO,KAAK;CACd,GAAG,CAAC,CAAC;CAEL,MAAM,mBAAmB,aAAa,SAAsC;EAC1E,IAAI,gBAAgB,MAClB,OAAO,GAAG,KAAK,KAAK,GAAG,KAAK,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,UAAU,GAAG,CAAC;EAEhF,OAAO,KAAK;CACd,GAAG,CAAC,CAAC;CAEL,MAAM,aAAa,kBAAkB;EACnC,UAAU,SAAS;GAEjB,KAAK,MAAM,QAAQ,KAAK,OACtB,IAAI,KAAK,WAAW,KAAK,gBAAgB,QAAQ,KAAK,KAAK,KAAK,WAAW,QAAQ,GACjF,IAAI,gBAAgB,KAAK,OAAO;GAIpC,IAAI,SAAS,SACX,SAAS,QAAQ,QAAQ;GAG3B,MAAM,WAAW;IACf,GAAG;IACH,OAAO,CAAC;IACR,QAAQ,CAAC;GACX;GAEA,gBAAgB,SAAS,KAAK;GAC9B,OAAO;EACT,CAAC;CACH,GAAG,CAAC,aAAa,CAAC;CAElB,MAAM,WAAW,aACd,aAAgC;EAC/B,IAAI,CAAC,YAAY,SAAS,WAAW,GAAG;EAExC,MAAM,gBAAgB,MAAM,KAAK,QAAQ;EACzC,MAAM,SAAmB,CAAC;EAG1B,UAAU,UAAU;GAAE,GAAG;GAAM,QAAQ,CAAC;EAAE,EAAE;EAG5C,IAAI,CAAC,UACH,WAAW;EAIb,IACE,YACA,aAAa,OAAO,qBACpB,MAAM,MAAM,SAAS,cAAc,SAAS,UAC5C;GACA,OAAO,KAAK,oCAAoC,SAAS,QAAQ;GACjE,UAAU,MAAM;GAChB,UAAU,UAAU;IAAE,GAAG;IAAM;GAAO,EAAE;GACxC;EACF;EAEA,MAAM,aAAgC,CAAC;EAEvC,KAAK,MAAM,QAAQ,eAAe;GAEhC,IAAI,UACkB;QAAA,MAAM,MAAM,MAC7B,iBACC,aAAa,KAAK,SAAS,KAAK,QAAQ,aAAa,KAAK,SAAS,KAAK,IAI9D,GACZ;GAAA;GAKJ,IAAI,KAAK,OAAO,SAAS;IACvB,OAAO,KACL,WACI,yCAAyC,YAAY,OAAO,EAAE,KAC9D,oCAAoC,YAAY,OAAO,EAAE,EAC/D;IACA;GACF;GAEA,MAAM,QAAQ,aAAa,IAAI;GAC/B,IAAI,OACF,OAAO,KAAK,KAAK;QAEjB,WAAW,KAAK;IACd;IACA,IAAI,iBAAiB,IAAI;IACzB,SAAS,cAAc,IAAI;GAC7B,CAAC;EAEL;EAGA,IAAI,WAAW,SAAS,GAAG;GAEzB,eAAe,UAAU;GAEzB,UAAU,SAAS;IACjB,MAAM,WAAW,CAAC,WAAW,aAAa,CAAC,GAAG,KAAK,OAAO,GAAG,UAAU;IACvE,gBAAgB,QAAQ;IACxB,OAAO;KACL,GAAG;KACH,OAAO;KACP;IACF;GACF,CAAC;EACH,OAAO,IAAI,OAAO,SAAS,GAAG;GAC5B,UAAU,MAAM;GAChB,UAAU,UAAU;IAClB,GAAG;IACH;GACF,EAAE;EACJ;EAGA,IAAI,SAAS,SACX,SAAS,QAAQ,QAAQ;CAE7B,GACA;EACE,MAAM;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,MAAM,aAAa,aAChB,OAAe;EACd,UAAU,SAAS;GACjB,MAAM,eAAe,KAAK,MAAM,MAAM,SAAS,KAAK,OAAO,EAAE;GAC7D,IACE,cAAc,WACd,aAAa,gBAAgB,QAC7B,aAAa,KAAK,KAAK,WAAW,QAAQ,GAE1C,IAAI,gBAAgB,aAAa,OAAO;GAG1C,MAAM,WAAW,KAAK,MAAM,QAAQ,SAAS,KAAK,OAAO,EAAE;GAC3D,gBAAgB,QAAQ;GAExB,OAAO;IACL,GAAG;IACH,OAAO;IACP,QAAQ,CAAC;GACX;EACF,CAAC;CACH,GACA,CAAC,aAAa,CAChB;CAEA,MAAM,cAAc,kBAAkB;EACpC,UAAU,UAAU;GAClB,GAAG;GACH,QAAQ,CAAC;EACX,EAAE;CACJ,GAAG,CAAC,CAAC;CAEL,MAAM,kBAAkB,aAAa,MAA8B;EACjE,EAAE,eAAe;EACjB,EAAE,gBAAgB;EAClB,UAAU,UAAU;GAAE,GAAG;GAAM,YAAY;EAAK,EAAE;CACpD,GAAG,CAAC,CAAC;CAEL,MAAM,kBAAkB,aAAa,MAA8B;EACjE,EAAE,eAAe;EACjB,EAAE,gBAAgB;EAElB,IAAI,EAAE,cAAc,SAAS,EAAE,aAAqB,GAClD;EAGF,UAAU,UAAU;GAAE,GAAG;GAAM,YAAY;EAAM,EAAE;CACrD,GAAG,CAAC,CAAC;CAEL,MAAM,iBAAiB,aAAa,MAA8B;EAChE,EAAE,eAAe;EACjB,EAAE,gBAAgB;CACpB,GAAG,CAAC,CAAC;CAEL,MAAM,aAAa,aAChB,MAA8B;EAC7B,EAAE,eAAe;EACjB,EAAE,gBAAgB;EAClB,UAAU,UAAU;GAAE,GAAG;GAAM,YAAY;EAAM,EAAE;EAGnD,IAAI,SAAS,SAAS,UACpB;EAGF,IAAI,EAAE,aAAa,SAAS,EAAE,aAAa,MAAM,SAAS,GAExD,IAAI,CAAC,UAAU;GACb,MAAM,OAAO,EAAE,aAAa,MAAM;GAClC,SAAS,CAAC,IAAI,CAAC;EACjB,OACE,SAAS,EAAE,aAAa,KAAK;CAGnC,GACA,CAAC,UAAU,QAAQ,CACrB;CAEA,MAAM,mBAAmB,aACtB,MAAqC;EACpC,IAAI,EAAE,OAAO,SAAS,EAAE,OAAO,MAAM,SAAS,GAC5C,SAAS,EAAE,OAAO,KAAK;CAE3B,GACA,CAAC,QAAQ,CACX;CAsBA,OAAO,CACL,OACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,gBAhCmB,kBAAkB;GACvC,IAAI,SAAS,SACX,SAAS,QAAQ,MAAM;EAE3B,GAAG,CAAC,CA4Ba;EACb,eA3BkB,aACnB,QAA+C,CAAC,MAAM;GACrD,OAAO;IACL,GAAG;IACH,MAAM;IACN,UAAU;IACV,QAAQ,MAAM,UAAU;IACxB,UAAU,MAAM,aAAa,KAAA,IAAY,MAAM,WAAW;IAC1D,KAAK;GACP;EACF,GACA;GAAC;GAAQ;GAAU;EAAgB,CAgBrB;CACd,CACF;AACF;AAGA,MAAa,eAAe,OAAe,WAAW,MAAc;CAClE,IAAI,UAAU,GAAG,OAAO;CAExB,MAAM,IAAI;CACV,MAAM,KAAK,WAAW,IAAI,IAAI;CAC9B,MAAM,QAAQ;EAAC;EAAS;EAAM;EAAM;EAAM;EAAM;EAAM;EAAM;EAAM;CAAI;CAEtE,MAAM,IAAI,KAAK,MAAM,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,CAAC,CAAC;CAElD,OAAO,GAAG,OAAO,YAAY,QAAQ,KAAK,EAAA,CAAG,QAAQ,EAAE,CAAC,EAAE,GAAG,MAAM;AACrE"}
@@ -0,0 +1,37 @@
1
+ //#region src/hooks/use-hydrated.d.ts
2
+ /**
3
+ * Hydration state hook for React components
4
+ * Returns a boolean indicating whether the component is running on the client
5
+ * with SSR-safe behavior to prevent hydration mismatches.
6
+ *
7
+ * This hook leverages `useSyncExternalStore` to provide a stable value between
8
+ * server and client renders: `false` during SSR, `true` after client hydration.
9
+ * The external store does not emit updates because the hydration state is static
10
+ * for the lifetime of the component.
11
+ */
12
+ /**
13
+ * Hook that indicates whether code is executing on the client after hydration
14
+ *
15
+ * Features:
16
+ * - SSR-safe: returns `false` on the server to avoid hydration mismatches
17
+ * - Client-stable: returns `true` after hydration and remains stable
18
+ * - Minimal overhead: uses a no-op external store subscription
19
+ *
20
+ * @returns Boolean indicating hydration state (`true` on client, `false` on server)
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * // Conditionally render client-only components safely
25
+ * function ClientOnly() {
26
+ * const hydrated = useHydrated();
27
+ * if (!hydrated) return null;
28
+ * return <InteractiveChart />;
29
+ * }
30
+ * ```
31
+ *
32
+ * @since 1.0.0
33
+ */
34
+ declare function useHydrated(): boolean;
35
+ //#endregion
36
+ export { useHydrated };
37
+ //# sourceMappingURL=use-hydrated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-hydrated.d.ts","names":[],"sources":["../../src/hooks/use-hydrated.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqCgB"}
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ import { useSyncExternalStore } from "react";
3
+ //#region src/hooks/use-hydrated.ts
4
+ /**
5
+ * Hydration state hook for React components
6
+ * Returns a boolean indicating whether the component is running on the client
7
+ * with SSR-safe behavior to prevent hydration mismatches.
8
+ *
9
+ * This hook leverages `useSyncExternalStore` to provide a stable value between
10
+ * server and client renders: `false` during SSR, `true` after client hydration.
11
+ * The external store does not emit updates because the hydration state is static
12
+ * for the lifetime of the component.
13
+ */
14
+ /**
15
+ * Hook that indicates whether code is executing on the client after hydration
16
+ *
17
+ * Features:
18
+ * - SSR-safe: returns `false` on the server to avoid hydration mismatches
19
+ * - Client-stable: returns `true` after hydration and remains stable
20
+ * - Minimal overhead: uses a no-op external store subscription
21
+ *
22
+ * @returns Boolean indicating hydration state (`true` on client, `false` on server)
23
+ *
24
+ * @example
25
+ * ```tsx
26
+ * // Conditionally render client-only components safely
27
+ * function ClientOnly() {
28
+ * const hydrated = useHydrated();
29
+ * if (!hydrated) return null;
30
+ * return <InteractiveChart />;
31
+ * }
32
+ * ```
33
+ *
34
+ * @since 1.0.0
35
+ */
36
+ function useHydrated() {
37
+ return useSyncExternalStore(subscribe, () => true, () => false);
38
+ }
39
+ /**
40
+ * External store subscription used by `useHydrated`
41
+ * No updates are dispatched because hydration state is static.
42
+ * Returns an unsubscribe function for API conformity.
43
+ */
44
+ function subscribe() {
45
+ return () => {};
46
+ }
47
+ //#endregion
48
+ export { useHydrated };
49
+
50
+ //# sourceMappingURL=use-hydrated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-hydrated.js","names":[],"sources":["../../src/hooks/use-hydrated.ts"],"sourcesContent":["/**\n * Hydration state hook for React components\n * Returns a boolean indicating whether the component is running on the client\n * with SSR-safe behavior to prevent hydration mismatches.\n *\n * This hook leverages `useSyncExternalStore` to provide a stable value between\n * server and client renders: `false` during SSR, `true` after client hydration.\n * The external store does not emit updates because the hydration state is static\n * for the lifetime of the component.\n */\n\n\"use client\";\n\nimport { useSyncExternalStore } from \"react\";\n\n/**\n * Hook that indicates whether code is executing on the client after hydration\n *\n * Features:\n * - SSR-safe: returns `false` on the server to avoid hydration mismatches\n * - Client-stable: returns `true` after hydration and remains stable\n * - Minimal overhead: uses a no-op external store subscription\n *\n * @returns Boolean indicating hydration state (`true` on client, `false` on server)\n *\n * @example\n * ```tsx\n * // Conditionally render client-only components safely\n * function ClientOnly() {\n * const hydrated = useHydrated();\n * if (!hydrated) return null;\n * return <InteractiveChart />;\n * }\n * ```\n *\n * @since 1.0.0\n */\nexport function useHydrated() {\n return useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * External store subscription used by `useHydrated`\n * No updates are dispatched because hydration state is static.\n * Returns an unsubscribe function for API conformity.\n */\nfunction subscribe() {\n return () => {};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,cAAc;CAC5B,OAAO,qBACL,iBACM,YACA,KACR;AACF;;;;;;AAOA,SAAS,YAAY;CACnB,aAAa,CAAC;AAChB"}
@@ -0,0 +1,55 @@
1
+ import * as React$1 from "react";
2
+ //#region src/hooks/use-intersection-observer.d.ts
3
+ /**
4
+ * Configuration options for the `useIntersectionObserver` hook.
5
+ *
6
+ * Extends the native `IntersectionObserverInit` options with an additional
7
+ * convenience flag for freezing the observer state.
8
+ */
9
+ interface IntersectionObserverOptions extends IntersectionObserverInit {
10
+ /**
11
+ * When `true`, the hook stops observing once the element becomes visible
12
+ * and keeps returning `true` for subsequent renders.
13
+ *
14
+ * This is useful for one-time animations or lazy loading where you only
15
+ * care about the first time an element enters the viewport.
16
+ */
17
+ freezeOnceVisible?: boolean;
18
+ }
19
+ /**
20
+ * React hook that tracks whether a DOM element is currently intersecting the viewport.
21
+ *
22
+ * Features:
23
+ * - Uses a shared `IntersectionObserver` instance for better performance.
24
+ * - Supports custom `threshold`, `root`, and `rootMargin` options.
25
+ * - Optional `freezeOnceVisible` flag to stop observing after first intersection.
26
+ *
27
+ * @param elementRef - React ref pointing to the DOM element to observe.
28
+ * @param options - Optional observer configuration and behavior flags.
29
+ * @param options.threshold - Intersection threshold(s) for triggering visibility changes.
30
+ * @param options.root - Scrollable ancestor element to use as the viewport (defaults to browser viewport).
31
+ * @param options.rootMargin - Margin around the root, expressed in CSS units (e.g. `"0px 0px -20% 0px"`).
32
+ * @param options.freezeOnceVisible - When `true`, stops observing after the element first becomes visible.
33
+ *
34
+ * @returns `true` when the element is intersecting based on the given options, otherwise `false`.
35
+ *
36
+ * @example
37
+ * ```tsx
38
+ * const ref = React.useRef<HTMLDivElement | null>(null);
39
+ * const isVisible = useIntersectionObserver(ref, {
40
+ * threshold: 0.2,
41
+ * rootMargin: "0px 0px -10% 0px",
42
+ * freezeOnceVisible: true,
43
+ * });
44
+ *
45
+ * return (
46
+ * <div ref={ref} className={isVisible ? "animate-in" : "opacity-0"}>
47
+ * I will animate when I enter the viewport.
48
+ * </div>
49
+ * );
50
+ * ```
51
+ */
52
+ declare function useIntersectionObserver(elementRef: React$1.RefObject<Element | null>, { threshold, root, rootMargin, freezeOnceVisible }?: IntersectionObserverOptions): boolean;
53
+ //#endregion
54
+ export { useIntersectionObserver };
55
+ //# sourceMappingURL=use-intersection-observer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-intersection-observer.d.ts","names":[],"sources":["../../src/hooks/use-intersection-observer.ts"],"mappings":";;;;;;;;UAgBU,oCAAoC;;;;;;;;EAQ5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsHc,wBACd,YAAY,QAAM,UAAU,mBAE1B,WACA,MACA,YACA,sBACC"}