@customafk/lunas-ui 0.0.25 → 0.0.27

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 (364) hide show
  1. package/dist/{alert-dialog-D-oR0YW3.cjs → alert-dialog-26JyobJb.cjs} +1 -1
  2. package/dist/{alert-dialog-D-oR0YW3.cjs.map → alert-dialog-26JyobJb.cjs.map} +1 -1
  3. package/dist/{alert-dialog-CNHyP_A9.js → alert-dialog-Dv0cgymS.js} +1 -1
  4. package/dist/{alert-dialog-CNHyP_A9.js.map → alert-dialog-Dv0cgymS.js.map} +1 -1
  5. package/dist/{button-BmBtMriU.d.ts → button-CPBLm_02.d.ts} +5 -5
  6. package/dist/{button-tCnJHt8O.d.cts → button-ghXW1WTr.d.cts} +5 -5
  7. package/dist/{calendar-CbuOOMpK.js → calendar-B66UT_fu.js} +1 -1
  8. package/dist/{calendar-CbuOOMpK.js.map → calendar-B66UT_fu.js.map} +1 -1
  9. package/dist/{calendar-B8IKzrdN.cjs → calendar-DXegnGRJ.cjs} +1 -1
  10. package/dist/{calendar-B8IKzrdN.cjs.map → calendar-DXegnGRJ.cjs.map} +1 -1
  11. package/dist/{command-Dr2XmKV6.d.cts → command-CE_Qcgo7.d.ts} +12 -12
  12. package/dist/{command-Dvq-HZwH.d.ts → command-CiEjoEnP.d.cts} +12 -12
  13. package/dist/{command-TFZwJmux.js → command-Dbkg10QA.js} +2 -2
  14. package/dist/{command-TFZwJmux.js.map → command-Dbkg10QA.js.map} +1 -1
  15. package/dist/{command-CoB5R5FI.cjs → command-IL3ogESu.cjs} +2 -2
  16. package/dist/{command-CoB5R5FI.cjs.map → command-IL3ogESu.cjs.map} +1 -1
  17. package/dist/data-display/empty.d.cts +2 -2
  18. package/dist/data-display/statistic.d.cts +2 -2
  19. package/dist/data-display/statistic.d.ts +2 -2
  20. package/dist/{dialog-CSDDiHKO.js → dialog-BEdMA5Lp.js} +1 -1
  21. package/dist/{dialog-CSDDiHKO.js.map → dialog-BEdMA5Lp.js.map} +1 -1
  22. package/dist/{dialog-C-DYoapJ.d.ts → dialog-Bw_T5aco.d.cts} +12 -12
  23. package/dist/{dialog-_Cgij9NP.cjs → dialog-C4oHnJNN.cjs} +1 -1
  24. package/dist/{dialog-_Cgij9NP.cjs.map → dialog-C4oHnJNN.cjs.map} +1 -1
  25. package/dist/{dialog-CA0E_tNX.d.cts → dialog-CoH1pTBH.d.ts} +12 -12
  26. package/dist/dialogs/confirm-dialog.cjs +1 -1
  27. package/dist/dialogs/confirm-dialog.js +1 -1
  28. package/dist/dialogs/detail-dialog/component/sidebar.d.cts +4 -4
  29. package/dist/dialogs/detail-dialog/component/sidebar.d.ts +28 -28
  30. package/dist/dialogs/detail-dialog/index.cjs +1 -1
  31. package/dist/dialogs/detail-dialog/index.js +1 -1
  32. package/dist/dialogs/error-dialog.cjs +1 -1
  33. package/dist/dialogs/error-dialog.js +1 -1
  34. package/dist/dialogs/form-dialog.cjs +1 -1
  35. package/dist/dialogs/form-dialog.d.cts +2 -2
  36. package/dist/dialogs/form-dialog.d.ts +2 -2
  37. package/dist/dialogs/form-dialog.js +1 -1
  38. package/dist/dialogs/loading-dialog.cjs +1 -1
  39. package/dist/dialogs/loading-dialog.js +1 -1
  40. package/dist/{error-dialog-D5R5le-W.cjs → error-dialog-C0PDn-pj.cjs} +2 -2
  41. package/dist/{error-dialog-D5R5le-W.cjs.map → error-dialog-C0PDn-pj.cjs.map} +1 -1
  42. package/dist/{error-dialog-Q99thrSD.js → error-dialog-CCdQ8zbQ.js} +2 -2
  43. package/dist/{error-dialog-Q99thrSD.js.map → error-dialog-CCdQ8zbQ.js.map} +1 -1
  44. package/dist/{form-wrapper-CY-stRaQ.cjs → form-wrapper-Cd8c5MIL.cjs} +2 -2
  45. package/dist/{form-wrapper-CY-stRaQ.cjs.map → form-wrapper-Cd8c5MIL.cjs.map} +1 -1
  46. package/dist/{form-wrapper-C2xlvWx0.js → form-wrapper-DntbFqN1.js} +2 -2
  47. package/dist/{form-wrapper-C2xlvWx0.js.map → form-wrapper-DntbFqN1.js.map} +1 -1
  48. package/dist/forms/combobox-field.cjs +1 -1
  49. package/dist/forms/combobox-field.d.cts +2 -2
  50. package/dist/forms/combobox-field.d.ts +2 -2
  51. package/dist/forms/combobox-field.js +1 -1
  52. package/dist/forms/date-field.cjs +1 -1
  53. package/dist/forms/date-field.d.cts +2 -2
  54. package/dist/forms/date-field.d.ts +2 -2
  55. package/dist/forms/date-field.js +1 -1
  56. package/dist/forms/form-wrapper.cjs +1 -1
  57. package/dist/forms/form-wrapper.d.cts +2 -2
  58. package/dist/forms/form-wrapper.d.ts +2 -2
  59. package/dist/forms/form-wrapper.js +1 -1
  60. package/dist/forms/multi-select-field.cjs +1 -1
  61. package/dist/forms/multi-select-field.cjs.map +1 -1
  62. package/dist/forms/multi-select-field.d.cts +2 -2
  63. package/dist/forms/multi-select-field.d.ts +2 -2
  64. package/dist/forms/multi-select-field.js +1 -1
  65. package/dist/forms/number-field.d.cts +2 -2
  66. package/dist/forms/number-field.d.ts +2 -2
  67. package/dist/forms/password-field.d.cts +2 -2
  68. package/dist/forms/password-field.d.ts +2 -2
  69. package/dist/forms/select-field.d.cts +2 -2
  70. package/dist/forms/select-field.d.ts +2 -2
  71. package/dist/forms/switch-field.d.cts +2 -2
  72. package/dist/forms/switch-field.d.ts +2 -2
  73. package/dist/forms/text-field.d.cts +2 -2
  74. package/dist/forms/text-field.d.ts +2 -2
  75. package/dist/forms/textarea-field.d.cts +2 -2
  76. package/dist/forms/textarea-field.d.ts +2 -2
  77. package/dist/{input-CjNcnHb_.d.ts → input-CUDclgoU.d.ts} +3 -3
  78. package/dist/{input-BsXm0_Iq.d.cts → input-y_n-XGys.d.cts} +3 -3
  79. package/dist/layouts/app-layout/index.d.cts +5 -5
  80. package/dist/layouts/app-layout/index.d.ts +3 -3
  81. package/dist/layouts/flex.d.cts +4 -4
  82. package/dist/layouts/flex.d.ts +4 -4
  83. package/dist/layouts/main/index.d.cts +4 -4
  84. package/dist/layouts/main/index.d.ts +4 -4
  85. package/dist/{multi-select-Cjvm4tK5.cjs → multi-select-3yxD9gbY.cjs} +2 -2
  86. package/dist/{multi-select-Cjvm4tK5.cjs.map → multi-select-3yxD9gbY.cjs.map} +1 -1
  87. package/dist/{multi-select-D0bZVOnm.js → multi-select-Cb07NlA7.js} +2 -2
  88. package/dist/{multi-select-D0bZVOnm.js.map → multi-select-Cb07NlA7.js.map} +1 -1
  89. package/dist/{popover-CTFp7ZXi.js → popover-CqAD7HNo.js} +1 -1
  90. package/dist/{popover-CTFp7ZXi.js.map → popover-CqAD7HNo.js.map} +1 -1
  91. package/dist/{popover-DCcPvdz2.cjs → popover-Dd0acCEk.cjs} +1 -1
  92. package/dist/{popover-DCcPvdz2.cjs.map → popover-Dd0acCEk.cjs.map} +1 -1
  93. package/dist/{separator-5FdzRGaJ.d.ts → separator-BLYi41aC.d.ts} +3 -3
  94. package/dist/{separator-DpxrpK_H.d.cts → separator-ClGBPiYE.d.cts} +3 -3
  95. package/dist/table/index.d.cts +2 -2
  96. package/dist/table/index.d.ts +2 -2
  97. package/dist/{toggle-Cx9H5u3p.d.cts → toggle-BWQWsKMA.d.ts} +4 -4
  98. package/dist/{toggle-DH9IssyE.d.ts → toggle-DnGvFJh8.d.cts} +4 -4
  99. package/dist/{tooltip-Djh_dcy5.d.ts → tooltip-Bk8VwHdM.d.ts} +6 -6
  100. package/dist/{tooltip-BAtWdJyX.d.cts → tooltip-cisSpCHG.d.cts} +6 -6
  101. package/dist/typography/paragraph.d.cts +2 -2
  102. package/dist/typography/paragraph.d.ts +2 -2
  103. package/dist/typography/title.d.cts +2 -2
  104. package/dist/typography/title.d.ts +2 -2
  105. package/dist/ui/alert-dialog.cjs +1 -1
  106. package/dist/ui/alert-dialog.d.cts +12 -12
  107. package/dist/ui/alert-dialog.d.ts +12 -12
  108. package/dist/ui/alert-dialog.js +1 -1
  109. package/dist/ui/alert.d.cts +6 -6
  110. package/dist/ui/alert.d.ts +6 -6
  111. package/dist/ui/aspect-ratio.d.cts +2 -2
  112. package/dist/ui/aspect-ratio.d.ts +2 -2
  113. package/dist/ui/avatar.d.cts +4 -4
  114. package/dist/ui/avatar.d.ts +4 -4
  115. package/dist/ui/badge.d.cts +2 -2
  116. package/dist/ui/badge.d.ts +4 -4
  117. package/dist/ui/breadcrumb.d.cts +8 -8
  118. package/dist/ui/breadcrumb.d.ts +8 -8
  119. package/dist/ui/button.d.cts +1 -1
  120. package/dist/ui/button.d.ts +1 -1
  121. package/dist/ui/calendar.cjs +1 -1
  122. package/dist/ui/calendar.d.cts +4 -4
  123. package/dist/ui/calendar.d.ts +4 -4
  124. package/dist/ui/calendar.js +1 -1
  125. package/dist/ui/card.d.cts +8 -8
  126. package/dist/ui/card.d.ts +8 -8
  127. package/dist/ui/carousel.d.cts +7 -7
  128. package/dist/ui/carousel.d.ts +7 -7
  129. package/dist/ui/collapsible.d.cts +4 -4
  130. package/dist/ui/collapsible.d.ts +4 -4
  131. package/dist/ui/command.cjs +1 -1
  132. package/dist/ui/command.d.cts +2 -2
  133. package/dist/ui/command.d.ts +2 -2
  134. package/dist/ui/command.js +1 -1
  135. package/dist/ui/context-menu.d.cts +16 -16
  136. package/dist/ui/context-menu.d.ts +16 -16
  137. package/dist/ui/dialog.cjs +1 -1
  138. package/dist/ui/dialog.d.cts +1 -1
  139. package/dist/ui/dialog.d.ts +1 -1
  140. package/dist/ui/dialog.js +1 -1
  141. package/dist/ui/dropdown-menu.d.cts +16 -16
  142. package/dist/ui/dropdown-menu.d.ts +16 -16
  143. package/dist/ui/file-uploader.d.cts +2 -2
  144. package/dist/ui/file-uploader.d.ts +2 -2
  145. package/dist/ui/form.d.cts +7 -7
  146. package/dist/ui/form.d.ts +7 -7
  147. package/dist/ui/hover-card.d.cts +4 -4
  148. package/dist/ui/hover-card.d.ts +4 -4
  149. package/dist/ui/input-otp.d.cts +5 -5
  150. package/dist/ui/input-otp.d.ts +5 -5
  151. package/dist/ui/input.d.cts +1 -1
  152. package/dist/ui/input.d.ts +1 -1
  153. package/dist/ui/inputs/search-input.d.cts +1 -1
  154. package/dist/ui/inputs/search-input.d.ts +3 -3
  155. package/dist/ui/label.d.cts +2 -2
  156. package/dist/ui/label.d.ts +2 -2
  157. package/dist/ui/menubar.d.cts +17 -17
  158. package/dist/ui/menubar.d.ts +17 -17
  159. package/dist/ui/multi-select.cjs +1 -1
  160. package/dist/ui/multi-select.d.cts +2 -2
  161. package/dist/ui/multi-select.d.ts +2 -2
  162. package/dist/ui/multi-select.js +1 -1
  163. package/dist/ui/navigation-menu.d.cts +11 -11
  164. package/dist/ui/navigation-menu.d.ts +9 -9
  165. package/dist/ui/pagination.d.cts +9 -9
  166. package/dist/ui/pagination.d.ts +9 -9
  167. package/dist/ui/popover.cjs +1 -1
  168. package/dist/ui/popover.d.cts +5 -5
  169. package/dist/ui/popover.d.ts +5 -5
  170. package/dist/ui/popover.js +1 -1
  171. package/dist/ui/progress.d.cts +2 -2
  172. package/dist/ui/progress.d.ts +2 -2
  173. package/dist/ui/radio-group.d.cts +3 -3
  174. package/dist/ui/radio-group.d.ts +3 -3
  175. package/dist/ui/resizable.d.cts +4 -4
  176. package/dist/ui/resizable.d.ts +4 -4
  177. package/dist/ui/scroll-area.d.ts +3 -3
  178. package/dist/ui/select.d.cts +11 -11
  179. package/dist/ui/select.d.ts +11 -11
  180. package/dist/ui/separator.d.cts +1 -1
  181. package/dist/ui/separator.d.ts +1 -1
  182. package/dist/ui/sheet.d.cts +9 -9
  183. package/dist/ui/sheet.d.ts +9 -9
  184. package/dist/ui/sidebar.d.cts +30 -30
  185. package/dist/ui/sidebar.d.ts +30 -30
  186. package/dist/ui/skeleton.d.cts +2 -2
  187. package/dist/ui/skeleton.d.ts +2 -2
  188. package/dist/ui/slider.d.cts +2 -2
  189. package/dist/ui/slider.d.ts +2 -2
  190. package/dist/ui/sonner.d.cts +2 -2
  191. package/dist/ui/sonner.d.ts +2 -2
  192. package/dist/ui/switch.d.cts +2 -2
  193. package/dist/ui/switch.d.ts +2 -2
  194. package/dist/ui/table.d.cts +9 -9
  195. package/dist/ui/table.d.ts +9 -9
  196. package/dist/ui/tabs.d.cts +5 -5
  197. package/dist/ui/tabs.d.ts +5 -5
  198. package/dist/ui/textarea.d.cts +2 -2
  199. package/dist/ui/textarea.d.ts +2 -2
  200. package/dist/ui/toggle-group.d.cts +4 -4
  201. package/dist/ui/toggle-group.d.ts +4 -4
  202. package/dist/ui/toggle.d.cts +1 -1
  203. package/dist/ui/toggle.d.ts +1 -1
  204. package/dist/ui/tooltip.d.cts +1 -1
  205. package/dist/ui/tooltip.d.ts +1 -1
  206. package/package.json +2 -2
  207. package/styles/base.css +29 -0
  208. package/styles/loader.css +113 -0
  209. package/styles/theme.css +104 -0
  210. package/styles/typography.css +6 -0
  211. package/packages/components/cards/simple-card.tsx +0 -23
  212. package/packages/components/data-display/country.tsx +0 -53
  213. package/packages/components/data-display/data-list.tsx +0 -29
  214. package/packages/components/data-display/date-tooltip.tsx +0 -23
  215. package/packages/components/data-display/date.tsx +0 -157
  216. package/packages/components/data-display/empty.tsx +0 -13
  217. package/packages/components/data-display/name.tsx +0 -23
  218. package/packages/components/data-display/phone-number.tsx +0 -14
  219. package/packages/components/data-display/role-badge.tsx +0 -29
  220. package/packages/components/data-display/statistic.tsx +0 -139
  221. package/packages/components/dialogs/confirm-dialog.tsx +0 -44
  222. package/packages/components/dialogs/detail-dialog/component/header.tsx +0 -10
  223. package/packages/components/dialogs/detail-dialog/component/main.tsx +0 -35
  224. package/packages/components/dialogs/detail-dialog/component/sidebar.tsx +0 -618
  225. package/packages/components/dialogs/detail-dialog/component/wrapper.tsx +0 -15
  226. package/packages/components/dialogs/detail-dialog/index.tsx +0 -91
  227. package/packages/components/dialogs/error-dialog.tsx +0 -34
  228. package/packages/components/dialogs/form-dialog.tsx +0 -74
  229. package/packages/components/dialogs/loading-dialog.tsx +0 -20
  230. package/packages/components/forms/combobox-field.tsx +0 -104
  231. package/packages/components/forms/date-field.tsx +0 -62
  232. package/packages/components/forms/form-wrapper.tsx +0 -120
  233. package/packages/components/forms/multi-select-field.tsx +0 -56
  234. package/packages/components/forms/number-field.tsx +0 -54
  235. package/packages/components/forms/password-field.tsx +0 -38
  236. package/packages/components/forms/select-field.tsx +0 -58
  237. package/packages/components/forms/switch-field.tsx +0 -40
  238. package/packages/components/forms/text-field.tsx +0 -73
  239. package/packages/components/forms/textarea-field.tsx +0 -45
  240. package/packages/components/index.tsx +0 -0
  241. package/packages/components/layouts/app-layout/index.tsx +0 -74
  242. package/packages/components/layouts/app-layout/sidebar.tsx +0 -663
  243. package/packages/components/layouts/flex.tsx +0 -99
  244. package/packages/components/layouts/main/content.tsx +0 -11
  245. package/packages/components/layouts/main/header.tsx +0 -41
  246. package/packages/components/layouts/main/index.tsx +0 -3
  247. package/packages/components/layouts/main/wrapper.tsx +0 -5
  248. package/packages/components/table/data-table-pagination.tsx +0 -70
  249. package/packages/components/table/data-table.tsx +0 -241
  250. package/packages/components/table/index.tsx +0 -107
  251. package/packages/components/typography/paragraph.tsx +0 -29
  252. package/packages/components/typography/title.tsx +0 -31
  253. package/packages/components/ui/alert-dialog.tsx +0 -99
  254. package/packages/components/ui/alert.tsx +0 -44
  255. package/packages/components/ui/aspect-ratio.tsx +0 -11
  256. package/packages/components/ui/avatar.tsx +0 -25
  257. package/packages/components/ui/badge.tsx +0 -57
  258. package/packages/components/ui/breadcrumb.tsx +0 -74
  259. package/packages/components/ui/button.tsx +0 -205
  260. package/packages/components/ui/buttons/add-new.tsx +0 -19
  261. package/packages/components/ui/buttons/edit.tsx +0 -14
  262. package/packages/components/ui/buttons/refresh.tsx +0 -19
  263. package/packages/components/ui/buttons/trash.tsx +0 -14
  264. package/packages/components/ui/buttons/upload-image.tsx +0 -25
  265. package/packages/components/ui/calendar.tsx +0 -141
  266. package/packages/components/ui/card.tsx +0 -44
  267. package/packages/components/ui/carousel.tsx +0 -187
  268. package/packages/components/ui/checkbox.tsx +0 -34
  269. package/packages/components/ui/collapsible.tsx +0 -17
  270. package/packages/components/ui/command.tsx +0 -138
  271. package/packages/components/ui/context-menu.tsx +0 -196
  272. package/packages/components/ui/dialog.tsx +0 -119
  273. package/packages/components/ui/dropdown-menu.tsx +0 -249
  274. package/packages/components/ui/file-uploader.tsx +0 -314
  275. package/packages/components/ui/form.tsx +0 -104
  276. package/packages/components/ui/hover-card.tsx +0 -32
  277. package/packages/components/ui/input-otp.tsx +0 -67
  278. package/packages/components/ui/input.tsx +0 -59
  279. package/packages/components/ui/inputs/number-input.tsx +0 -317
  280. package/packages/components/ui/inputs/password-input.tsx +0 -29
  281. package/packages/components/ui/inputs/search-input.tsx +0 -24
  282. package/packages/components/ui/label.tsx +0 -26
  283. package/packages/components/ui/menubar.tsx +0 -212
  284. package/packages/components/ui/multi-select.tsx +0 -626
  285. package/packages/components/ui/navigation-menu.tsx +0 -124
  286. package/packages/components/ui/pagination.tsx +0 -70
  287. package/packages/components/ui/popover.tsx +0 -49
  288. package/packages/components/ui/progress.tsx +0 -19
  289. package/packages/components/ui/radio-group.tsx +0 -36
  290. package/packages/components/ui/resizable.tsx +0 -47
  291. package/packages/components/ui/scroll-area.tsx +0 -35
  292. package/packages/components/ui/select.tsx +0 -199
  293. package/packages/components/ui/separator.tsx +0 -25
  294. package/packages/components/ui/sheet.tsx +0 -119
  295. package/packages/components/ui/sidebar.tsx +0 -675
  296. package/packages/components/ui/skeleton.tsx +0 -8
  297. package/packages/components/ui/slider.tsx +0 -45
  298. package/packages/components/ui/sonner.tsx +0 -40
  299. package/packages/components/ui/switch.tsx +0 -46
  300. package/packages/components/ui/table.tsx +0 -66
  301. package/packages/components/ui/tabs.tsx +0 -53
  302. package/packages/components/ui/textarea.tsx +0 -46
  303. package/packages/components/ui/toggle-group.tsx +0 -63
  304. package/packages/components/ui/toggle.tsx +0 -34
  305. package/packages/components/ui/tooltip.tsx +0 -53
  306. package/packages/constants.tsx +0 -45
  307. package/packages/hooks/use-callback-ref.ts +0 -22
  308. package/packages/hooks/use-controllable-state.ts +0 -58
  309. package/packages/hooks/use-mobile.ts +0 -19
  310. package/packages/index.css +0 -133
  311. package/packages/lib/utils.ts +0 -24
  312. package/packages/stories/1.Guideline.mdx +0 -3
  313. package/packages/stories/2.Colors.mdx +0 -145
  314. package/packages/stories/3.Pypography.mdx +0 -51
  315. package/packages/stories/cards/simple-card.stories.tsx +0 -24
  316. package/packages/stories/data-display/data-list.stories.tsx +0 -22
  317. package/packages/stories/data-display/empty.stories.tsx +0 -13
  318. package/packages/stories/data-display/form-dialog.stories.tsx +0 -27
  319. package/packages/stories/data-display/name.stories.tsx +0 -25
  320. package/packages/stories/data-display/phone-number.stories.tsx +0 -17
  321. package/packages/stories/data-display/statistic.stories.tsx +0 -41
  322. package/packages/stories/dialogs/confirm-dialog.stories.tsx +0 -26
  323. package/packages/stories/dialogs/detail-dialog.stories.tsx +0 -34
  324. package/packages/stories/dialogs/error-dialog.stories.tsx +0 -27
  325. package/packages/stories/dialogs/loading-dialog.stories.tsx +0 -16
  326. package/packages/stories/forms/combobox-field.stories.tsx +0 -38
  327. package/packages/stories/forms/form-wrapper.stories.tsx +0 -59
  328. package/packages/stories/forms/multi-select-field.stories.tsx +0 -42
  329. package/packages/stories/forms/number-field.stories.tsx +0 -35
  330. package/packages/stories/forms/select-field.stories.tsx +0 -39
  331. package/packages/stories/forms/switch-field.stories.tsx +0 -36
  332. package/packages/stories/forms/text-field.stories.tsx +0 -41
  333. package/packages/stories/forms/textarea-field.stories.tsx +0 -34
  334. package/packages/stories/layouts/app-layout.stories.tsx +0 -49
  335. package/packages/stories/typography/paragraph.stories.tsx +0 -45
  336. package/packages/stories/typography/title.stories.tsx +0 -39
  337. package/packages/stories/ui/alert-dialog.stories.tsx +0 -49
  338. package/packages/stories/ui/alert.stories.tsx +0 -63
  339. package/packages/stories/ui/aspect-ratio.stories.tsx +0 -22
  340. package/packages/stories/ui/badge.stories.tsx +0 -170
  341. package/packages/stories/ui/breadcrumb.stories.tsx +0 -172
  342. package/packages/stories/ui/button.stories.tsx +0 -181
  343. package/packages/stories/ui/card.stories.tsx +0 -58
  344. package/packages/stories/ui/checkbox.stories.tsx +0 -48
  345. package/packages/stories/ui/command.stories.tsx +0 -58
  346. package/packages/stories/ui/dialog.stories.tsx +0 -55
  347. package/packages/stories/ui/dropdown-menu.stories.tsx +0 -89
  348. package/packages/stories/ui/file-uploader.stories.tsx +0 -18
  349. package/packages/stories/ui/input.stories.tsx +0 -38
  350. package/packages/stories/ui/label.stories.tsx +0 -17
  351. package/packages/stories/ui/multi-select.stories.tsx +0 -29
  352. package/packages/stories/ui/popover.stories.tsx +0 -52
  353. package/packages/stories/ui/progress.stories.tsx +0 -17
  354. package/packages/stories/ui/radio-group.stories.tsx +0 -31
  355. package/packages/stories/ui/select.stories.tsx +0 -31
  356. package/packages/stories/ui/separator.stories.tsx +0 -31
  357. package/packages/stories/ui/sheet.stories.tsx +0 -50
  358. package/packages/stories/ui/skeleton.stories.tsx +0 -27
  359. package/packages/stories/ui/switch.stories.tsx +0 -21
  360. package/packages/stories/ui/table.stories.tsx +0 -82
  361. package/packages/stories/ui/tabs.stories.tsx +0 -70
  362. package/packages/stories/ui/textarea.stories.tsx +0 -15
  363. package/packages/stories/ui/toaster.stories.tsx +0 -87
  364. package/packages/types.ts +0 -50
@@ -1,45 +0,0 @@
1
- 'use client'
2
- import React from 'react'
3
- import { Slider as SliderPrimitive } from 'radix-ui'
4
-
5
- import { cn } from '@/lib/utils'
6
-
7
- function Slider({ className, defaultValue, value, min = 0, max = 100, ...props }: React.ComponentProps<typeof SliderPrimitive.Root>) {
8
- const _values = React.useMemo(() => (Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max]), [value, defaultValue, min, max])
9
-
10
- return (
11
- <SliderPrimitive.Root
12
- data-slot="slider"
13
- defaultValue={defaultValue}
14
- value={value}
15
- min={min}
16
- max={max}
17
- className={cn(
18
- 'relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col',
19
- className,
20
- )}
21
- {...props}
22
- >
23
- <SliderPrimitive.Track
24
- data-slot="slider-track"
25
- className={cn(
26
- 'bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5',
27
- )}
28
- >
29
- <SliderPrimitive.Range
30
- data-slot="slider-range"
31
- className={cn('bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full')}
32
- />
33
- </SliderPrimitive.Track>
34
- {Array.from({ length: _values.length }, (_, index) => (
35
- <SliderPrimitive.Thumb
36
- data-slot="slider-thumb"
37
- key={index}
38
- className="border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
39
- />
40
- ))}
41
- </SliderPrimitive.Root>
42
- )
43
- }
44
-
45
- export { Slider }
@@ -1,40 +0,0 @@
1
- 'use client'
2
- import { LoaderIcon } from 'lucide-react'
3
- import { useTheme } from 'next-themes'
4
- import { Toaster as Sonner, type ToasterProps } from 'sonner'
5
-
6
- const Toaster = () => {
7
- const { theme = 'system' } = useTheme()
8
-
9
- return (
10
- <Sonner
11
- richColors
12
- theme={theme as ToasterProps['theme']}
13
- expand={false}
14
- visibleToasts={5}
15
- closeButton={true}
16
- position="bottom-right"
17
- swipeDirections={['left', 'right']}
18
- icons={{
19
- loading: <LoaderIcon size={16} className="animate-spin" />,
20
- }}
21
- toastOptions={{
22
- classNames: {
23
- toast: '!text-white !border-none rounded-lg cursor-grab active:cursor-grabbing select-none z-99999',
24
- icon: '!size-6',
25
- title: '!text-sm !font-bold',
26
- description: '!text-xs !font-semibold !text-white/80',
27
- success: '!bg-success',
28
- info: '!bg-blue-700',
29
- loading: '!bg-slate-500',
30
- warning: '!bg-warning',
31
- error: '!bg-danger',
32
- closeButton: '!text-gray-400 hover:!text-gray-500 !bg-neutral-50 hover:!bg-gray-100 !border-none !shadow',
33
- },
34
- }}
35
- className="toaster group pointer-events-auto !z-999999"
36
- />
37
- )
38
- }
39
-
40
- export { Toaster }
@@ -1,46 +0,0 @@
1
- 'use client'
2
- import React from 'react'
3
- import { Switch as SwitchPrimitive } from 'radix-ui'
4
-
5
- import { cn } from '@/lib/utils'
6
-
7
- function Switch({ className, ...props }: React.ComponentProps<typeof SwitchPrimitive.Root>) {
8
- return (
9
- <SwitchPrimitive.Root
10
- data-slot="switch"
11
- className={cn(
12
- 'peer',
13
- 'w-8 shrink-0 cursor-pointer items-center rounded-full border border-transparent shadow-xs transition-all outline-none',
14
- 'inline-flex h-5',
15
- 'data-[state=checked]:bg-primary',
16
- 'data-[state=unchecked]:bg-border-muted',
17
- 'focus-visible:border-primary-strong',
18
- 'focus-visible:ring-primary-weak',
19
- 'focus-visible:ring-4',
20
- 'disabled:cursor-not-allowed',
21
- 'disabled:opacity-50',
22
- 'data-[state=unchecked]:border-border-weak',
23
- 'data-[state=unchecked]:[&_span]:bg-accent-weak',
24
- 'data-[state=unchecked]:bg-transparent',
25
- 'data-[state=unchecked]:[&_span]:size-4',
26
- 'data-[state=unchecked]:[&_span]:translate-x-0.5',
27
- 'data-[state=unchecked]:[&_span]:shadow-none',
28
- 'data-[state=unchecked]:[&_span]:rtl:-translate-x-0.5',
29
- className,
30
- )}
31
- {...props}
32
- >
33
- <SwitchPrimitive.Thumb
34
- data-slot="switch-thumb"
35
- className={cn(
36
- 'bg-background',
37
- 'pointer-events-none block size-4 rounded-full ring-0 transition-transform',
38
- 'data-[state=checked]:translate-x-[calc(100%-3px)]',
39
- 'data-[state=unchecked]:translate-x-0',
40
- )}
41
- />
42
- </SwitchPrimitive.Root>
43
- )
44
- }
45
-
46
- export { Switch }
@@ -1,66 +0,0 @@
1
- 'use client'
2
- import React from 'react'
3
-
4
- import { cn } from '@/lib/utils'
5
-
6
- function Table({ className, ...props }: React.ComponentProps<'table'>) {
7
- return (
8
- <div data-slot="table-container" className="relative w-full overflow-x-auto">
9
- <table data-slot="table" className={cn('w-full caption-bottom text-sm', className)} {...props} />
10
- </div>
11
- )
12
- }
13
-
14
- function TableHeader({ className, ...props }: React.ComponentProps<'thead'>) {
15
- return <thead data-slot="table-header" className={cn('bg-muted-muted border-border-weak [&_tr]:border-b', className)} {...props} />
16
- }
17
-
18
- function TableBody({ className, ...props }: React.ComponentProps<'tbody'>) {
19
- return <tbody data-slot="table-body" className={cn('[&_tr:last-child]:border-0', className)} {...props} />
20
- }
21
-
22
- function TableFooter({ className, ...props }: React.ComponentProps<'tfoot'>) {
23
- return <tfoot data-slot="table-footer" className={cn('bg-accent-muted border-t font-medium [&>tr]:last:border-b-0', className)} {...props} />
24
- }
25
-
26
- function TableRow({ className, ...props }: React.ComponentProps<'tr'>) {
27
- return (
28
- <tr
29
- data-slot="table-row"
30
- className={cn('hover:bg-muted-muted/50 active:bg-muted-muted data-[state=selected]:bg-muted border-border-weak border-b transition-colors', className)}
31
- {...props}
32
- />
33
- )
34
- }
35
-
36
- function TableHead({ className, ...props }: React.ComponentProps<'th'>) {
37
- return (
38
- <th
39
- data-slot="table-head"
40
- className={cn(
41
- 'text-text-positive-weak',
42
- 'h-10 px-2 text-left align-middle font-medium whitespace-nowrap',
43
- '[&:has([role=checkbox])]:pr-0',
44
- '[&>[role=checkbox]]:translate-y-0.5',
45
- className,
46
- )}
47
- {...props}
48
- />
49
- )
50
- }
51
-
52
- function TableCell({ className, ...props }: React.ComponentProps<'td'>) {
53
- return (
54
- <td
55
- data-slot="table-cell"
56
- className={cn('p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5', className)}
57
- {...props}
58
- />
59
- )
60
- }
61
-
62
- function TableCaption({ className, ...props }: React.ComponentProps<'caption'>) {
63
- return <caption data-slot="table-caption" className={cn('text-text-positive-muted mt-4 text-sm', className)} {...props} />
64
- }
65
-
66
- export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow }
@@ -1,53 +0,0 @@
1
- 'use client'
2
- import { Tabs as TabsPrimitive } from 'radix-ui'
3
-
4
- import { cn } from '@/lib/utils'
5
-
6
- function Tabs({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Root>) {
7
- return <TabsPrimitive.Root data-slot="tabs" className={cn('flex flex-col gap-2', className)} {...props} />
8
- }
9
-
10
- function TabsList({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.List>) {
11
- return (
12
- <TabsPrimitive.List
13
- data-slot="tabs-list"
14
- className={cn('bg-muted-muted inline-flex h-9 w-fit items-center justify-center rounded-full p-1', className)}
15
- {...props}
16
- />
17
- )
18
- }
19
-
20
- function TabsTrigger({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
21
- return (
22
- <TabsPrimitive.Trigger
23
- data-slot="tabs-trigger"
24
- className={cn(
25
- 'text-text-positive-weak',
26
- 'inline-flex h-[calc(100%-1px)] flex-1 cursor-pointer items-center justify-center gap-1.5',
27
- 'rounded-full',
28
- 'border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition',
29
- 'hover:bg-muted-weak',
30
- 'data-[state=active]:shadow-card',
31
- 'data-[state=active]:bg-background',
32
- 'disabled:opacity-50',
33
- 'disabled:pointer-events-none',
34
- 'focus-visible:border-primary',
35
- 'focus-visible:ring-4',
36
- 'focus-visible:ring-primary-weak',
37
- 'focus-visible:outline-1',
38
- 'focus-visible:outline-primary',
39
- '[&_svg]:pointer-events-none',
40
- '[&_svg]:shrink-0',
41
- "[&_svg:not([class*='size-'])]:size-4",
42
- className,
43
- )}
44
- {...props}
45
- />
46
- )
47
- }
48
-
49
- function TabsContent({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Content>) {
50
- return <TabsPrimitive.Content data-slot="tabs-content" className={cn('flex-1 outline-none', className)} {...props} />
51
- }
52
-
53
- export { Tabs, TabsContent, TabsList, TabsTrigger }
@@ -1,46 +0,0 @@
1
- 'use client'
2
- import React from 'react'
3
-
4
- import { cn } from '@/lib/utils'
5
-
6
- function Textarea({
7
- className,
8
- onChange,
9
- onValueChange,
10
- ...props
11
- }: React.ComponentProps<'textarea'> & {
12
- onValueChange?: (value: string) => void
13
- }) {
14
- const handleChange = React.useCallback(
15
- (e: React.ChangeEvent<HTMLTextAreaElement>) => {
16
- onChange?.(e)
17
- onValueChange?.(e.target.value)
18
- },
19
- [onChange, onValueChange],
20
- )
21
- return (
22
- <textarea
23
- data-slot="textarea"
24
- className={cn(
25
- 'border-border-weak caret-primary',
26
- 'flex min-h-16 w-full bg-transparent px-3 py-2',
27
- 'field-sizing-content',
28
- 'shadow-input rounded-md border',
29
- 'text-sm transition outline-none',
30
- 'placeholder:text-text-positive-muted',
31
- 'focus-visible:border-primary-strong',
32
- 'focus-visible:ring-primary-weak',
33
- 'focus-visible:ring-4',
34
- 'aria-invalid:ring-danger-weak',
35
- 'aria-invalid:border-danger-strong',
36
- 'disabled:cursor-not-allowed',
37
- 'disabled:opacity-50',
38
- className,
39
- )}
40
- {...props}
41
- onChange={handleChange}
42
- />
43
- )
44
- }
45
-
46
- export { Textarea }
@@ -1,63 +0,0 @@
1
- 'use client'
2
- import React from 'react'
3
- import { ToggleGroup as ToggleGroupPrimitive } from 'radix-ui'
4
- import { type VariantProps } from 'class-variance-authority'
5
-
6
- import { toggleVariants } from '@/components/ui/toggle'
7
- import { cn } from '@/lib/utils'
8
-
9
- const ToggleGroupContext = React.createContext<VariantProps<typeof toggleVariants>>({
10
- size: 'default',
11
- variant: 'default',
12
- })
13
-
14
- function ToggleGroup({
15
- className,
16
- variant,
17
- size,
18
- children,
19
- ...props
20
- }: React.ComponentProps<typeof ToggleGroupPrimitive.Root> & VariantProps<typeof toggleVariants>) {
21
- return (
22
- <ToggleGroupPrimitive.Root
23
- data-slot="toggle-group"
24
- data-variant={variant}
25
- data-size={size}
26
- className={cn('group/toggle-group flex w-fit items-center rounded-md data-[variant=outline]:shadow-xs', className)}
27
- {...props}
28
- >
29
- <ToggleGroupContext.Provider value={{ variant, size }}>{children}</ToggleGroupContext.Provider>
30
- </ToggleGroupPrimitive.Root>
31
- )
32
- }
33
-
34
- function ToggleGroupItem({
35
- className,
36
- children,
37
- variant,
38
- size,
39
- ...props
40
- }: React.ComponentProps<typeof ToggleGroupPrimitive.Item> & VariantProps<typeof toggleVariants>) {
41
- const context = React.useContext(ToggleGroupContext)
42
-
43
- return (
44
- <ToggleGroupPrimitive.Item
45
- data-slot="toggle-group-item"
46
- data-variant={context.variant || variant}
47
- data-size={context.size || size}
48
- className={cn(
49
- toggleVariants({
50
- variant: context.variant || variant,
51
- size: context.size || size,
52
- }),
53
- 'min-w-0 flex-1 shrink-0 rounded-none shadow-none first:rounded-l-md last:rounded-r-md focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:first:border-l',
54
- className,
55
- )}
56
- {...props}
57
- >
58
- {children}
59
- </ToggleGroupPrimitive.Item>
60
- )
61
- }
62
-
63
- export { ToggleGroup, ToggleGroupItem }
@@ -1,34 +0,0 @@
1
- 'use client'
2
- import React from 'react'
3
- import { Toggle as TogglePrimitive } from 'radix-ui'
4
- import { cva, type VariantProps } from 'class-variance-authority'
5
-
6
- import { cn } from '@/lib/utils'
7
-
8
- const toggleVariants = cva(
9
- "inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",
10
- {
11
- variants: {
12
- variant: {
13
- default: 'bg-transparent',
14
- outline: 'border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground',
15
- },
16
- size: {
17
- default: 'h-9 px-2 min-w-9',
18
- sm: 'h-8 px-1.5 min-w-8',
19
- lg: 'h-10 px-2.5 min-w-10',
20
- },
21
- },
22
- defaultVariants: {
23
- variant: 'default',
24
- size: 'default',
25
- },
26
- },
27
- )
28
-
29
- function Toggle({ className, variant, size, ...props }: React.ComponentProps<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>) {
30
- return <TogglePrimitive.Root data-slot="toggle" className={cn(toggleVariants({ variant, size, className }))} {...props} />
31
- }
32
-
33
- // eslint-disable-next-line react-refresh/only-export-components
34
- export { Toggle, toggleVariants }
@@ -1,53 +0,0 @@
1
- 'use client'
2
- import React from 'react'
3
- import { Tooltip as TooltipPrimitive } from 'radix-ui'
4
-
5
- import { cn } from '@/lib/utils'
6
-
7
- function TooltipProvider({ delayDuration = 0, ...props }: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
8
- return <TooltipPrimitive.Provider data-slot="tooltip-provider" delayDuration={delayDuration} {...props} />
9
- }
10
-
11
- function Tooltip({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Root>) {
12
- return (
13
- <TooltipProvider>
14
- <TooltipPrimitive.Root data-slot="tooltip" {...props} />
15
- </TooltipProvider>
16
- )
17
- }
18
-
19
- function TooltipTrigger({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
20
- return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
21
- }
22
-
23
- function TooltipContent({ className, sideOffset = 0, children, ...props }: React.ComponentProps<typeof TooltipPrimitive.Content>) {
24
- return (
25
- <TooltipPrimitive.Portal>
26
- <TooltipPrimitive.Content
27
- data-slot="tooltip-content"
28
- sideOffset={sideOffset}
29
- className={cn(
30
- 'bg-foreground text-text-negative-intense shadow-dropdown outline-none',
31
- 'animate-in fade-in-0 zoom-in-95',
32
- 'data-[state=closed]:animate-out',
33
- 'data-[state=closed]:fade-out-0',
34
- 'data-[state=closed]:zoom-out-95',
35
- 'data-[side=bottom]:slide-in-from-top-2',
36
- 'data-[side=left]:slide-in-from-right-2',
37
- 'data-[side=right]:slide-in-from-left-2',
38
- 'data-[side=top]:slide-in-from-bottom-2',
39
- 'z-50 w-fit',
40
- 'origin-(--radix-tooltip-content-transform-origin)',
41
- 'rounded-lg px-3 py-1.5 text-xs text-balance',
42
- className,
43
- )}
44
- {...props}
45
- >
46
- {children}
47
- <TooltipPrimitive.Arrow className="bg-foreground fill-foreground text-secondary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-xs" />
48
- </TooltipPrimitive.Content>
49
- </TooltipPrimitive.Portal>
50
- )
51
- }
52
-
53
- export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger }
@@ -1,45 +0,0 @@
1
- // Vietnamese locale configuration
2
- export const vietnameseLocale = {
3
- weekdays: ['Chủ Nhật', 'Thứ Hai', 'Thứ Ba', 'Thứ Tư', 'Thứ Năm', 'Thứ Sáu', 'Thứ Bảy'],
4
- weekdaysShort: ['CN', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7'],
5
- months: ['Tháng 1', 'Tháng 2', 'Tháng 3', 'Tháng 4', 'Tháng 5', 'Tháng 6', 'Tháng 7', 'Tháng 8', 'Tháng 9', 'Tháng 10', 'Tháng 11', 'Tháng 12'],
6
- monthsShort: ['T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'T9', 'T10', 'T11', 'T12'],
7
- }
8
-
9
- // Vietnamese holidays
10
- export const vietnameseHolidays = {
11
- '01-01': 'Tết Dương lịch',
12
- '03-08': 'Quốc tế Phụ nữ',
13
- '04-30': 'Ngày Giải phóng miền Nam',
14
- '05-01': 'Quốc tế Lao động',
15
- '09-02': 'Quốc khánh',
16
- '10-20': 'Ngày Phụ nữ Việt Nam',
17
- '11-20': 'Ngày Nhà giáo Việt Nam',
18
- }
19
-
20
- // Time Constants in milliseconds, seconds, and minutes
21
- export const TIME_IN_MS = Object.freeze({
22
- SECOND: 1000,
23
- MINUTE: 60 * 1000,
24
- HOUR: 60 * 60 * 1000,
25
- DAY: 24 * 60 * 60 * 1000,
26
- WEEK: 7 * 24 * 60 * 60 * 1000,
27
- MONTH: 30 * 24 * 60 * 60 * 1000, // Approximation for month length = 30 days
28
- YEAR: 365 * 24 * 60 * 60 * 1000,
29
- })
30
-
31
- export const TIME_IN_SECONDS = Object.freeze({
32
- MINUTE: 60,
33
- HOUR: 60 * 60,
34
- DAY: 24 * 60 * 60,
35
- WEEK: 7 * 24 * 60 * 60,
36
- MONTH: 30 * 24 * 60 * 60,
37
- YEAR: 365 * 24 * 60 * 60,
38
- })
39
-
40
- export const TIME_IN_MINUTES = Object.freeze({
41
- HOUR: 60,
42
- DAY: 24 * 60,
43
- WEEK: 7 * 24 * 60,
44
- MONTH: 30 * 24 * 60,
45
- })
@@ -1,22 +0,0 @@
1
- import React from 'react'
2
-
3
- /**
4
- * @see https://github.com/radix-ui/primitives/blob/main/packages/react/use-callback-ref/src/useCallbackRef.tsx
5
- */
6
-
7
- /**
8
- * A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a
9
- * prop or avoid re-executing effects when passed as a dependency
10
- */
11
- function useCallbackRef<T extends (...args: never[]) => unknown>(callback: T | undefined): T {
12
- const callbackRef = React.useRef(callback)
13
-
14
- React.useEffect(() => {
15
- callbackRef.current = callback
16
- })
17
-
18
- // https://github.com/facebook/react/issues/19240
19
- return React.useMemo(() => ((...args) => callbackRef.current?.(...args)) as T, [])
20
- }
21
-
22
- export { useCallbackRef }
@@ -1,58 +0,0 @@
1
- import React from 'react'
2
-
3
- import { useCallbackRef } from './use-callback-ref'
4
-
5
- /**
6
- * @see https://github.com/radix-ui/primitives/blob/main/packages/react/use-controllable-state/src/useControllableState.tsx
7
- */
8
-
9
- type UseControllableStateParams<T> = {
10
- prop?: T | undefined
11
- defaultProp?: T | undefined
12
- onChange?: (state: T) => void
13
- }
14
-
15
- type SetStateFn<T> = (prevState?: T) => T
16
-
17
- function useControllableState<T>({ prop, defaultProp, onChange = () => {} }: UseControllableStateParams<T>) {
18
- const [uncontrolledProp, setUncontrolledProp] = useUncontrolledState({
19
- defaultProp,
20
- onChange,
21
- })
22
- const isControlled = prop !== undefined
23
- const value = isControlled ? prop : uncontrolledProp
24
- const handleChange = useCallbackRef(onChange)
25
-
26
- const setValue: React.Dispatch<React.SetStateAction<T | undefined>> = React.useCallback(
27
- (nextValue) => {
28
- if (isControlled) {
29
- const setter = nextValue as SetStateFn<T>
30
- const value = typeof nextValue === 'function' ? setter(prop) : nextValue
31
- if (value !== prop) handleChange(value as T)
32
- } else {
33
- setUncontrolledProp(nextValue)
34
- }
35
- },
36
- [isControlled, prop, setUncontrolledProp, handleChange],
37
- )
38
-
39
- return [value, setValue] as const
40
- }
41
-
42
- function useUncontrolledState<T>({ defaultProp, onChange }: Omit<UseControllableStateParams<T>, 'prop'>) {
43
- const uncontrolledState = React.useState<T | undefined>(defaultProp)
44
- const [value] = uncontrolledState
45
- const prevValueRef = React.useRef(value)
46
- const handleChange = useCallbackRef(onChange)
47
-
48
- React.useEffect(() => {
49
- if (prevValueRef.current !== value) {
50
- handleChange(value as T)
51
- prevValueRef.current = value
52
- }
53
- }, [value, prevValueRef, handleChange])
54
-
55
- return uncontrolledState
56
- }
57
-
58
- export { useControllableState }
@@ -1,19 +0,0 @@
1
- import React from 'react'
2
-
3
- const MOBILE_BREAKPOINT = 768
4
-
5
- export function useIsMobile() {
6
- const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
7
-
8
- React.useEffect(() => {
9
- const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
10
- const onChange = () => {
11
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
12
- }
13
- mql.addEventListener('change', onChange)
14
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
15
- return () => mql.removeEventListener('change', onChange)
16
- }, [])
17
-
18
- return !!isMobile
19
- }