@boxcustodia/library 2.0.0-alpha.11 → 2.0.0-alpha.13

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 (352) hide show
  1. package/dist/index.cjs.js +38 -38
  2. package/dist/index.css +1 -1
  3. package/dist/index.d.ts +28 -29
  4. package/dist/index.es.js +6804 -6792
  5. package/package.json +4 -3
  6. package/src/__doc__/Changelog.mdx +6 -0
  7. package/src/__doc__/Components.mdx +73 -0
  8. package/src/__doc__/Examples.tsx +69 -0
  9. package/src/__doc__/Icons.mdx +41 -0
  10. package/src/__doc__/Intro.mdx +138 -0
  11. package/src/__doc__/MCP.mdx +71 -0
  12. package/src/__doc__/Migration.mdx +451 -0
  13. package/src/__doc__/Theme.mdx +132 -0
  14. package/src/__doc__/Types.mdx +252 -0
  15. package/src/components/alert/alert.stories.tsx +142 -0
  16. package/src/components/alert/alert.tsx +109 -0
  17. package/src/components/alert/index.ts +7 -0
  18. package/src/components/alert-dialog/alert-dialog.stories.tsx +173 -0
  19. package/src/components/alert-dialog/alert-dialog.test.tsx +49 -0
  20. package/src/components/alert-dialog/alert-dialog.tsx +265 -0
  21. package/src/components/alert-dialog/index.ts +1 -0
  22. package/src/components/auto-complete/auto-complete-primitives.tsx +155 -0
  23. package/src/components/auto-complete/auto-complete.stories.tsx +241 -0
  24. package/src/components/auto-complete/auto-complete.tsx +82 -0
  25. package/src/components/auto-complete/index.ts +2 -0
  26. package/src/components/avatar/avatar.stories.tsx +84 -0
  27. package/src/components/avatar/avatar.test.tsx +61 -0
  28. package/src/components/avatar/avatar.tsx +104 -0
  29. package/src/components/avatar/index.ts +1 -0
  30. package/src/components/background-image/background-image.stories.tsx +21 -0
  31. package/src/components/background-image/background-image.test.tsx +29 -0
  32. package/src/components/background-image/background-image.tsx +23 -0
  33. package/src/components/background-image/index.ts +1 -0
  34. package/src/components/button/button.stories.tsx +396 -0
  35. package/src/components/button/button.test.tsx +58 -0
  36. package/src/components/button/button.tsx +31 -0
  37. package/src/components/button/button.variants.ts +44 -0
  38. package/src/components/button/components/base-button.tsx +86 -0
  39. package/src/components/button/components/loader-overlay.tsx +21 -0
  40. package/src/components/button/components/loading-icon.tsx +47 -0
  41. package/src/components/button/index.ts +3 -0
  42. package/src/components/calendar/calendar.model.ts +86 -0
  43. package/src/components/calendar/calendar.stories.tsx +155 -0
  44. package/src/components/calendar/calendar.test.tsx +12 -0
  45. package/src/components/calendar/calendar.tsx +185 -0
  46. package/src/components/calendar/components/calendar-navigation.tsx +141 -0
  47. package/src/components/calendar/components/day.tsx +61 -0
  48. package/src/components/calendar/components/decade-view.tsx +45 -0
  49. package/src/components/calendar/components/index.ts +6 -0
  50. package/src/components/calendar/components/month-view.tsx +58 -0
  51. package/src/components/calendar/components/week-days.tsx +27 -0
  52. package/src/components/calendar/components/year-view.tsx +29 -0
  53. package/src/components/calendar/hooks/index.ts +4 -0
  54. package/src/components/calendar/hooks/use-calendar-navigation.ts +79 -0
  55. package/src/components/calendar/hooks/use-calendar.ts +90 -0
  56. package/src/components/calendar/hooks/use-multiple-calendar.ts +34 -0
  57. package/src/components/calendar/hooks/use-range-calendar.ts +91 -0
  58. package/src/components/calendar/hooks/use-single-calendar.ts +18 -0
  59. package/src/components/calendar/index.ts +1 -0
  60. package/src/components/calendar/utils/typeguards.ts +7 -0
  61. package/src/components/card/card.stories.tsx +116 -0
  62. package/src/components/card/card.tsx +74 -0
  63. package/src/components/card/index.ts +1 -0
  64. package/src/components/center/center.stories.tsx +81 -0
  65. package/src/components/center/center.tsx +24 -0
  66. package/src/components/center/index.ts +1 -0
  67. package/src/components/checkbox/checkbox.stories.tsx +307 -0
  68. package/src/components/checkbox/checkbox.tsx +273 -0
  69. package/src/components/checkbox/index.ts +1 -0
  70. package/src/components/checkbox-group/checkbox-group.stories.tsx +104 -0
  71. package/src/components/checkbox-group/checkbox-group.tsx +16 -0
  72. package/src/components/checkbox-group/index.ts +1 -0
  73. package/src/components/combobox/combobox.stories.tsx +339 -0
  74. package/src/components/combobox/combobox.tsx +898 -0
  75. package/src/components/combobox/index.ts +1 -0
  76. package/src/components/date-picker/date-input.stories.tsx +158 -0
  77. package/src/components/date-picker/date-input.tsx +163 -0
  78. package/src/components/date-picker/date-picker.model.ts +90 -0
  79. package/src/components/date-picker/date-picker.stories.tsx +200 -0
  80. package/src/components/date-picker/date-picker.test.tsx +23 -0
  81. package/src/components/date-picker/date-picker.tsx +298 -0
  82. package/src/components/date-picker/date-picker.utils.ts +260 -0
  83. package/src/components/date-picker/index.ts +3 -0
  84. package/src/components/date-picker/use-date-input-popover.ts +48 -0
  85. package/src/components/date-picker/use-date-input.ts +125 -0
  86. package/src/components/dialog/dialog.stories.tsx +171 -0
  87. package/src/components/dialog/dialog.test.tsx +68 -0
  88. package/src/components/dialog/dialog.tsx +277 -0
  89. package/src/components/dialog/index.ts +1 -0
  90. package/src/components/divider/divider.stories.tsx +139 -0
  91. package/src/components/divider/divider.test.tsx +22 -0
  92. package/src/components/divider/divider.tsx +23 -0
  93. package/src/components/divider/index.ts +1 -0
  94. package/src/components/dropzone/dropzone.stories.tsx +210 -0
  95. package/src/components/dropzone/dropzone.tsx +154 -0
  96. package/src/components/dropzone/file-types.ts +64 -0
  97. package/src/components/dropzone/index.ts +3 -0
  98. package/src/components/dropzone/upload-primitives.tsx +310 -0
  99. package/src/components/dropzone/use-dropzone.ts +122 -0
  100. package/src/components/empty-state/empty-state.stories.tsx +56 -0
  101. package/src/components/empty-state/empty-state.tsx +39 -0
  102. package/src/components/empty-state/index.ts +1 -0
  103. package/src/components/field/field.stories.tsx +223 -0
  104. package/src/components/field/field.tsx +229 -0
  105. package/src/components/field/index.ts +1 -0
  106. package/src/components/form/form.stories.tsx +594 -0
  107. package/src/components/form/form.tsx +30 -0
  108. package/src/components/form/index.ts +1 -0
  109. package/src/components/heading/heading.stories.tsx +74 -0
  110. package/src/components/heading/heading.tsx +28 -0
  111. package/src/components/heading/heading.variants.ts +27 -0
  112. package/src/components/heading/index.ts +1 -0
  113. package/src/components/index.ts +46 -0
  114. package/src/components/input/index.ts +1 -0
  115. package/src/components/input/input.stories.tsx +104 -0
  116. package/src/components/input/input.tsx +75 -0
  117. package/src/components/kbd/index.ts +1 -0
  118. package/src/components/kbd/kbd.stories.tsx +40 -0
  119. package/src/components/kbd/kbd.tsx +31 -0
  120. package/src/components/kbd/kbd.variants.ts +26 -0
  121. package/src/components/label/index.ts +1 -0
  122. package/src/components/label/label.stories.tsx +68 -0
  123. package/src/components/label/label.test.tsx +61 -0
  124. package/src/components/label/label.tsx +62 -0
  125. package/src/components/loader/index.ts +1 -0
  126. package/src/components/loader/loader.stories.tsx +60 -0
  127. package/src/components/loader/loader.test.tsx +26 -0
  128. package/src/components/loader/loader.tsx +60 -0
  129. package/src/components/menu/index.ts +2 -0
  130. package/src/components/menu/menu-primitives.tsx +248 -0
  131. package/src/components/menu/menu.stories.tsx +203 -0
  132. package/src/components/menu/menu.tsx +100 -0
  133. package/src/components/menu/util/render-menu-item.tsx +54 -0
  134. package/src/components/multi-select/hooks/use-multi-select.ts +66 -0
  135. package/src/components/multi-select/index.ts +1 -0
  136. package/src/components/multi-select/multi-select.stories.tsx +294 -0
  137. package/src/components/multi-select/multi-select.tsx +300 -0
  138. package/src/components/multi-select/multi-select.variants.ts +22 -0
  139. package/src/components/number-input/index.ts +1 -0
  140. package/src/components/number-input/number-input.stories.tsx +209 -0
  141. package/src/components/number-input/number-input.test.tsx +87 -0
  142. package/src/components/number-input/number-input.tsx +232 -0
  143. package/src/components/pagination/components/pagination-option.tsx +27 -0
  144. package/src/components/pagination/index.ts +1 -0
  145. package/src/components/pagination/pagination.stories.tsx +80 -0
  146. package/src/components/pagination/pagination.test.tsx +76 -0
  147. package/src/components/pagination/pagination.tsx +102 -0
  148. package/src/components/password/index.ts +1 -0
  149. package/src/components/password/password.stories.tsx +104 -0
  150. package/src/components/password/password.tsx +75 -0
  151. package/src/components/popover/index.ts +1 -0
  152. package/src/components/popover/popover.stories.tsx +213 -0
  153. package/src/components/popover/popover.tsx +203 -0
  154. package/src/components/progress/index.ts +1 -0
  155. package/src/components/progress/progress.stories.tsx +124 -0
  156. package/src/components/progress/progress.test.tsx +25 -0
  157. package/src/components/progress/progress.tsx +124 -0
  158. package/src/components/scroll-area/index.ts +1 -0
  159. package/src/components/scroll-area/scroll-area.stories.tsx +166 -0
  160. package/src/components/scroll-area/scroll-area.tsx +64 -0
  161. package/src/components/select/index.ts +1 -0
  162. package/src/components/select/select.stories.tsx +253 -0
  163. package/src/components/select/select.tsx +430 -0
  164. package/src/components/show/index.ts +1 -0
  165. package/src/components/show/show.stories.tsx +197 -0
  166. package/src/components/show/show.test.tsx +41 -0
  167. package/src/components/show/show.tsx +16 -0
  168. package/src/components/skeleton/index.ts +1 -0
  169. package/src/components/skeleton/skeleton.stories.tsx +36 -0
  170. package/src/components/skeleton/skeleton.test.tsx +14 -0
  171. package/src/components/skeleton/skeleton.tsx +15 -0
  172. package/src/components/stack/index.ts +1 -0
  173. package/src/components/stack/stack.stories.tsx +194 -0
  174. package/src/components/stack/stack.tsx +52 -0
  175. package/src/components/stepper/Stepper.tsx +190 -0
  176. package/src/components/stepper/context/stepper-context.tsx +11 -0
  177. package/src/components/stepper/index.ts +1 -0
  178. package/src/components/stepper/stepper.stories.tsx +130 -0
  179. package/src/components/stepper/stepper.test.tsx +91 -0
  180. package/src/components/switch/index.ts +1 -0
  181. package/src/components/switch/switch.stories.tsx +122 -0
  182. package/src/components/switch/switch.test.tsx +30 -0
  183. package/src/components/switch/switch.tsx +86 -0
  184. package/src/components/table/index.ts +3 -0
  185. package/src/components/table/table-primitives.tsx +122 -0
  186. package/src/components/table/table.model.ts +20 -0
  187. package/src/components/table/table.stories.tsx +169 -0
  188. package/src/components/table/table.test.tsx +91 -0
  189. package/src/components/table/table.tsx +109 -0
  190. package/src/components/table-pagination/index.ts +2 -0
  191. package/src/components/table-pagination/table-pagination.model.ts +2 -0
  192. package/src/components/table-pagination/table-pagination.stories.tsx +23 -0
  193. package/src/components/table-pagination/table-pagination.test.tsx +32 -0
  194. package/src/components/table-pagination/table-pagination.tsx +108 -0
  195. package/src/components/tabs/context/tabs-context.tsx +14 -0
  196. package/src/components/tabs/index.ts +1 -0
  197. package/src/components/tabs/tabs.stories.tsx +182 -0
  198. package/src/components/tabs/tabs.test.tsx +61 -0
  199. package/src/components/tabs/tabs.tsx +175 -0
  200. package/src/components/tag/index.ts +2 -0
  201. package/src/components/tag/tag.stories.tsx +170 -0
  202. package/src/components/tag/tag.test.tsx +18 -0
  203. package/src/components/tag/tag.tsx +99 -0
  204. package/src/components/tag/tag.variants.ts +31 -0
  205. package/src/components/textarea/index.ts +1 -0
  206. package/src/components/textarea/textarea.stories.tsx +73 -0
  207. package/src/components/textarea/textarea.tsx +105 -0
  208. package/src/components/timeline/index.ts +1 -0
  209. package/src/components/timeline/timeline-status.ts +5 -0
  210. package/src/components/timeline/timeline.stories.tsx +84 -0
  211. package/src/components/timeline/timeline.tsx +147 -0
  212. package/src/components/toast/index.ts +1 -0
  213. package/src/components/toast/toast.stories.tsx +392 -0
  214. package/src/components/toast/toast.test.tsx +50 -0
  215. package/src/components/toast/toast.tsx +411 -0
  216. package/src/components/tooltip/index.ts +1 -0
  217. package/src/components/tooltip/tooltip.stories.tsx +226 -0
  218. package/src/components/tooltip/tooltip.test.tsx +46 -0
  219. package/src/components/tooltip/tooltip.tsx +171 -0
  220. package/src/components/tree/hooks/use-controllable-tree-state.ts +80 -0
  221. package/src/components/tree/index.ts +2 -0
  222. package/src/components/tree/tree-primitives.tsx +126 -0
  223. package/src/components/tree/tree.stories.tsx +468 -0
  224. package/src/components/tree/tree.tsx +42 -0
  225. package/src/hooks/index.ts +26 -0
  226. package/src/hooks/useArray/__doc__/useArray.stories.tsx +100 -0
  227. package/src/hooks/useArray/__test__/useArray.test.tsx +88 -0
  228. package/src/hooks/useArray/index.ts +1 -0
  229. package/src/hooks/useArray/useArray.ts +76 -0
  230. package/src/hooks/useAsync/__doc__/useAsync.stories.tsx +149 -0
  231. package/src/hooks/useAsync/__test__/useAsync.test.tsx +68 -0
  232. package/src/hooks/useAsync/index.ts +1 -0
  233. package/src/hooks/useAsync/useAsync.ts +58 -0
  234. package/src/hooks/useClickOutside/__doc__/useClickOutside.stories.tsx +40 -0
  235. package/src/hooks/useClickOutside/__test__/useClickOutside.test.tsx +33 -0
  236. package/src/hooks/useClickOutside/index.ts +1 -0
  237. package/src/hooks/useClickOutside/useClickOutside.ts +26 -0
  238. package/src/hooks/useClipboard/__doc__/useClipboard.stories.tsx +45 -0
  239. package/src/hooks/useClipboard/__test__/useClipboard.test.tsx +19 -0
  240. package/src/hooks/useClipboard/index.ts +1 -0
  241. package/src/hooks/useClipboard/useClipboard.tsx +28 -0
  242. package/src/hooks/useDebounceCallback/__doc__/useDebouncedCallback.stories.tsx +84 -0
  243. package/src/hooks/useDebounceCallback/index.ts +1 -0
  244. package/src/hooks/useDebounceCallback/useDebouncedCallback.ts +23 -0
  245. package/src/hooks/useDebounceValue/__doc__/useDebouncedValue.stories.tsx +75 -0
  246. package/src/hooks/useDebounceValue/index.ts +1 -0
  247. package/src/hooks/useDebounceValue/useDebouncedValue.ts +17 -0
  248. package/src/hooks/useDisclosure/__doc__/useDisclosure.stories.tsx +39 -0
  249. package/src/hooks/useDisclosure/__test__/useDisclosure.test.ts +43 -0
  250. package/src/hooks/useDisclosure/index.ts +1 -0
  251. package/src/hooks/useDisclosure/useDisclosure.ts +37 -0
  252. package/src/hooks/useDocumentTitle/__doc__/useDocumentTitle.stories.tsx +26 -0
  253. package/src/hooks/useDocumentTitle/index.ts +1 -0
  254. package/src/hooks/useDocumentTitle/useDocumentTitle.tsx +11 -0
  255. package/src/hooks/useEventListener/__doc__/useEventListener.stories.tsx +28 -0
  256. package/src/hooks/useEventListener/__test__/useEventListener.test.tsx +26 -0
  257. package/src/hooks/useEventListener/index.ts +1 -0
  258. package/src/hooks/useEventListener/useEventListener.ts +25 -0
  259. package/src/hooks/useFocusTrap/__doc__/useFocusTrap.stories.tsx +37 -0
  260. package/src/hooks/useFocusTrap/index.ts +1 -0
  261. package/src/hooks/useFocusTrap/scopeTab.ts +38 -0
  262. package/src/hooks/useFocusTrap/tabbable.ts +70 -0
  263. package/src/hooks/useFocusTrap/useFocusTrap.ts +78 -0
  264. package/src/hooks/useHotkey/__docs__/useHotkey.stories.tsx +116 -0
  265. package/src/hooks/useHotkey/__test__/useHotkey.test.tsx +105 -0
  266. package/src/hooks/useHotkey/__utils__/create-hotkey-listener.ts +25 -0
  267. package/src/hooks/useHotkey/__utils__/index.ts +3 -0
  268. package/src/hooks/useHotkey/__utils__/is-input-field.ts +14 -0
  269. package/src/hooks/useHotkey/__utils__/match-key-modifiers.ts +25 -0
  270. package/src/hooks/useHotkey/index.ts +1 -0
  271. package/src/hooks/useHotkey/useHotkey.ts +34 -0
  272. package/src/hooks/useHover/__doc__/useHover.stories.tsx +41 -0
  273. package/src/hooks/useHover/__test__/useHover.test.tsx +45 -0
  274. package/src/hooks/useHover/index.ts +1 -0
  275. package/src/hooks/useHover/useHover.tsx +40 -0
  276. package/src/hooks/useIsVisible/__doc__/useIsVisible.stories.tsx +60 -0
  277. package/src/hooks/useIsVisible/index.ts +1 -0
  278. package/src/hooks/useIsVisible/useIsVisible.tsx +50 -0
  279. package/src/hooks/useLocalStorage/__doc__/useLocalStorage.stories.tsx +86 -0
  280. package/src/hooks/useLocalStorage/__test__/useLocalStorage.test.ts +85 -0
  281. package/src/hooks/useLocalStorage/index.ts +1 -0
  282. package/src/hooks/useLocalStorage/useLocalStorage.ts +57 -0
  283. package/src/hooks/useMediaQuery/__doc__/useMediaQuery.stories.tsx +39 -0
  284. package/src/hooks/useMediaQuery/index.ts +1 -0
  285. package/src/hooks/useMediaQuery/useMediaQuery.ts +22 -0
  286. package/src/hooks/useMemoizedFn/index.ts +1 -0
  287. package/src/hooks/useMemoizedFn/useMemoizedFn.ts +32 -0
  288. package/src/hooks/useMutation/__doc__/useMutation.stories.tsx +111 -0
  289. package/src/hooks/useMutation/__test__/useMutation.test.tsx +83 -0
  290. package/src/hooks/useMutation/index.ts +1 -0
  291. package/src/hooks/useMutation/useMutation.tsx +60 -0
  292. package/src/hooks/useObject/__doc__/useObject.stories.tsx +119 -0
  293. package/src/hooks/useObject/__test__/useObject.test.tsx +87 -0
  294. package/src/hooks/useObject/index.ts +1 -0
  295. package/src/hooks/useObject/useObject.tsx +48 -0
  296. package/src/hooks/usePagination/__doc__/usePagination.stories.tsx +72 -0
  297. package/src/hooks/usePagination/__test__/usePagination.test.tsx +98 -0
  298. package/src/hooks/usePagination/index.ts +2 -0
  299. package/src/hooks/usePagination/usePagination.tsx +74 -0
  300. package/src/hooks/usePortal/__doc__/usePortal.stories.tsx +19 -0
  301. package/src/hooks/usePortal/__test__/usePortal.test.tsx +20 -0
  302. package/src/hooks/usePortal/index.ts +1 -0
  303. package/src/hooks/usePortal/usePortal.ts +40 -0
  304. package/src/hooks/usePreventCloseWindow/__doc__/usePreventCloseWindow.stories.tsx +32 -0
  305. package/src/hooks/usePreventCloseWindow/index.ts +1 -0
  306. package/src/hooks/usePreventCloseWindow/usePreventCloseWindow.ts +33 -0
  307. package/src/hooks/useRangePagination/__test__/useRangePagination.test.tsx +63 -0
  308. package/src/hooks/useRangePagination/index.ts +2 -0
  309. package/src/hooks/useRangePagination/useRangePagination.tsx +72 -0
  310. package/src/hooks/useSelection/__doc__/useSelection.stories.tsx +140 -0
  311. package/src/hooks/useSelection/__test__/useSelection.test.tsx +57 -0
  312. package/src/hooks/useSelection/index.ts +1 -0
  313. package/src/hooks/useSelection/useSelection.ts +121 -0
  314. package/src/hooks/useStep/__doc__/useStep.stories.tsx +98 -0
  315. package/src/hooks/useStep/__test__/useStep.test.ts +51 -0
  316. package/src/hooks/useStep/index.ts +1 -0
  317. package/src/hooks/useStep/useStep.ts +57 -0
  318. package/src/hooks/useToggle/__doc__/useToggle.stories.tsx +25 -0
  319. package/src/hooks/useToggle/__test__/useToggle.test.tsx +43 -0
  320. package/src/hooks/useToggle/index.ts +1 -0
  321. package/src/hooks/useToggle/useToggle.ts +16 -0
  322. package/src/index.ts +6 -0
  323. package/src/lib/cn.ts +8 -0
  324. package/src/lib/index.ts +1 -0
  325. package/src/models/Generic.model.ts +67 -0
  326. package/src/models/index.ts +1 -0
  327. package/src/providers/index.ts +2 -0
  328. package/src/providers/library-provider.tsx +44 -0
  329. package/src/providers/theme/ThemeProvider.tsx +25 -0
  330. package/src/providers/theme/index.ts +3 -0
  331. package/src/providers/theme/types.ts +11 -0
  332. package/src/providers/theme/useThemeProps.ts +25 -0
  333. package/src/stores/theme.store.ts +31 -0
  334. package/src/styles/components.css +4 -0
  335. package/src/styles/index.css +2 -0
  336. package/src/styles/library.css +2 -0
  337. package/src/styles/theme.css +232 -0
  338. package/src/utils/dates/parseDateRange.utility.ts +39 -0
  339. package/src/utils/form.tsx +91 -0
  340. package/src/utils/functions/createSafeContext.ts +17 -0
  341. package/src/utils/functions/ensureReactElement.tsx +30 -0
  342. package/src/utils/functions/getFormData.ts +19 -0
  343. package/src/utils/functions/index.ts +4 -0
  344. package/src/utils/functions/mergeRefs.ts +18 -0
  345. package/src/utils/index.ts +3 -0
  346. package/src/utils/strings/extractInitials.utility.ts +10 -0
  347. package/src/utils/strings/index.ts +1 -0
  348. package/src/utils/tests/click.ts +3 -0
  349. package/src/utils/tests/index.ts +2 -0
  350. package/src/utils/tests/keyboard.ts +21 -0
  351. package/src/utils/tests/type.ts +6 -0
  352. package/dist/components.css +0 -2
@@ -0,0 +1,252 @@
1
+ import {
2
+ Canvas,
3
+ ColorItem,
4
+ ColorPalette,
5
+ Meta,
6
+ Source,
7
+ } from "@storybook/addon-docs/blocks";
8
+ import { BorderRadius } from "./Examples";
9
+
10
+ <Meta title="Documentation/Types" />
11
+
12
+ # Types
13
+
14
+ ## Extender interfaces de componentes
15
+
16
+ ```ts
17
+ // Se puede inferir utilizando la utilidad ComponentProps
18
+ import { Input } from "../../components";
19
+ type InputProps = ComponentProps<typeof Input>;
20
+ ```
21
+
22
+ ## Generic types
23
+
24
+ ### GenericObject
25
+
26
+ Interfaz de objeto genérico
27
+
28
+ ```ts
29
+ // Definición
30
+ type GenericObject<T = any> = { [key: string]: T };
31
+
32
+ const myObj: GenericObject = {
33
+ test: "TEST",
34
+ };
35
+
36
+ const myObj: GenericObject<number> = {
37
+ test: "TEST", // TS-Error
38
+ prop: 4,
39
+ };
40
+ ```
41
+
42
+ ### Nullable
43
+
44
+ Permite manejar valores que pueden ser null
45
+
46
+ ```ts
47
+ // Definición
48
+ type Nullable<T> = T | null;
49
+
50
+ const [myState, setMyState] = useState<Nullable<number>>(null);
51
+ setState(4);
52
+ ```
53
+
54
+ ### Maybe
55
+
56
+ Permite manejar valores que pueden ser undefined o null
57
+
58
+ ```ts
59
+ // Definición
60
+ type Maybe<T> = T | undefined | null;
61
+
62
+ interface APIResponse {
63
+ data: Maybe<string>; // string | undefined | null
64
+ error: Maybe<string>; // string | undefined | null
65
+ }
66
+ ```
67
+
68
+ ### State
69
+
70
+ Interfaz de hook `useState`
71
+
72
+ ```ts
73
+ // Definición
74
+ type SetState<T> = Dispatch<SetStateAction<T>>;
75
+ type State<T> = [T, SetState<T>];
76
+
77
+ interface MyComponentProps {
78
+ value: string;
79
+ setValue: SetState<string>;
80
+ otherState: State<boolean>;
81
+ }
82
+
83
+ function MyComponent({ value, setValue, otherState }: MyComponentProps) {
84
+ ...
85
+ }
86
+ ```
87
+
88
+ ### ClassName
89
+
90
+ interfaz simple para clases
91
+
92
+ ```ts
93
+ // Definición
94
+ type ClassName = string | undefined;
95
+
96
+ interface MyComponentProps {
97
+ className: ClassName
98
+ ...
99
+ }
100
+ ```
101
+
102
+ ### ID
103
+
104
+ interfaz para ids
105
+
106
+ ```ts
107
+ // Definición
108
+ type ID = string | number;
109
+
110
+ interface User {
111
+ id: ID;
112
+ }
113
+ ```
114
+
115
+ ### OverrideProps
116
+
117
+ Interfaz que sobrescribe las propiedades de un componente por la interfaz que se pase
118
+
119
+ ```ts
120
+ // Definición
121
+ type OverrideProps<T, TOverridden> = Omit<T, keyof TOverridden> & TOverridden;
122
+
123
+ type InputExtension = ComponentProps<"input">;
124
+ type MyCustomProps = { onChange: (value: string) => any };
125
+ type MyComponentProps = OverrideProps<InputExtension, MyCustomProps>; // onChange: (value: string) => any
126
+ ```
127
+
128
+ ### SafeOmit
129
+
130
+ Permite hacer omit de ciertas propiedades de una interfaz brindando autocompletado
131
+
132
+ ```ts
133
+ // Definición
134
+ type SafeOmit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
135
+
136
+ interface User {
137
+ name: string;
138
+ email: string;
139
+ age: number;
140
+ gender?: string;
141
+ }
142
+
143
+ type UserMetadata = Omit<User, "age" | "gender">;
144
+ ```
145
+
146
+ ### AtLeastOne
147
+
148
+ Define un array que debe contener al menos 1 elemento
149
+
150
+ ```ts
151
+ // Definición
152
+ type AtLeastOne<T> = [T, ...T[]];
153
+
154
+ const myArray: AtLeastOne<number> = []; // ❌ TS-ERROR
155
+ const myArray: AtLeastOne<number> = [1]; // ✅
156
+ ```
157
+
158
+ ### Loose
159
+
160
+ Autocompletado de ciertas opciones con la posibilidad de pasar cualquier string
161
+
162
+ ```ts
163
+ // Definición
164
+ type Loose<T> = T | (string & {});
165
+
166
+ type Size = "xs" | "md" | "xl";
167
+ type LooseSize = Loose<Size>;
168
+
169
+ // Autocompleta 'xs', 'md' y 'xl'
170
+ // Permite cualquier string
171
+ const IconSizes: LooseSize[] = ["xs", "md", "xl", "10px", "100px"];
172
+ ```
173
+
174
+ ### Controllable
175
+
176
+ Interfaz que sobrescribe las propiedades de un HTMLElement para hacerlo controlado
177
+
178
+ ```ts
179
+ // Definición
180
+ type Controllable<C, T extends {}> = OverrideProps<
181
+ HTMLProps<C>,
182
+ ControllableState<T>
183
+ >;
184
+
185
+ // ❌ sin usar interfaz
186
+ interface TabsProps
187
+ extends Omit<
188
+ HTMLProps<HTMLDivElement>,
189
+ "value" | "defaultValue" | "onChange"
190
+ > {
191
+ value?: string;
192
+ onChange?: (tab: string) => void;
193
+ defaultValue?: string;
194
+ }
195
+
196
+ // ✅ usando interfaz
197
+ type TabsProps = Controllable<HTMLDivElement, string>;
198
+ ```
199
+
200
+ ### ArrayUnion
201
+
202
+ Obtiene una unión de todos los elementos de un array
203
+
204
+ ```ts
205
+ // Definición
206
+ type ArrayUnion<V, T extends ReadonlyArray<V>> = T[number];
207
+
208
+ const routes = ["dashboard", "login", "settings"] as const;
209
+ type Route = ArrayUnion<string, typeof routes>; // "dashboard" | "login" | "settings"
210
+ ```
211
+
212
+ ### ValuesUnion
213
+
214
+ Obtiene una unión de todos los valores de un objeto
215
+
216
+ Las claves se pueden obtener con `keyof T`
217
+
218
+ ```ts
219
+ // Definición
220
+ type ValuesUnion<T extends Record<string, any>> = T[keyof T];
221
+
222
+ const methods = {
223
+ GET: "get",
224
+ POST: "post",
225
+ } as const;
226
+
227
+ type Method = ValuesUnion<typeof methods>; // "get" | "post"
228
+ ```
229
+
230
+ ### Entity
231
+
232
+ Representa una entidad en una base de datos
233
+
234
+ ```ts
235
+ // Definición
236
+ export type BaseEntity = {
237
+ id: string;
238
+ createdAt: number;
239
+ };
240
+
241
+ export type Entity<T> = {
242
+ [K in keyof T]: T[K];
243
+ } & BaseEntity;
244
+
245
+ // Uso
246
+ type User = Entity<{
247
+ firstName: string;
248
+ lastName: string;
249
+ email: string;
250
+ role: "ADMIN" | "USER";
251
+ }>;
252
+ ```
@@ -0,0 +1,142 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite";
2
+ import {
3
+ AlertCircleIcon,
4
+ CheckCircle2Icon,
5
+ InfoIcon,
6
+ TriangleAlert,
7
+ } from "lucide-react";
8
+ import { Button } from "../button";
9
+ import {
10
+ Alert,
11
+ AlertAction,
12
+ AlertDescription,
13
+ AlertRoot,
14
+ AlertTitle,
15
+ } from "./index";
16
+
17
+ /**
18
+ * Displays a contextual message to the user. Supports five semantic variants —
19
+ * `default`, `error`, `success`, `warning`, and `info` — each with matching border,
20
+ * background tint, and icon color.
21
+ *
22
+ * Accepts `title`, `description`, `icon`, and `action` as props for the common case.
23
+ * For full layout control, compose the primitives directly: `AlertRoot`, `AlertTitle`,
24
+ * `AlertDescription`, and `AlertAction`. Each prop also has an escape-hatch counterpart
25
+ * (`titleProps`, `descriptionProps`, `actionProps`) to override a specific primitive
26
+ * without rebuilding the whole structure.
27
+ */
28
+ const meta: Meta<typeof Alert> = {
29
+ title: "Components/Alert",
30
+ component: Alert,
31
+ subcomponents: {
32
+ AlertRoot: AlertRoot,
33
+ AlertTitle: AlertTitle,
34
+ AlertDescription: AlertDescription,
35
+ AlertAction: AlertAction,
36
+ },
37
+ args: {
38
+ title: "Heads up",
39
+ description: "You can change this in your account settings.",
40
+ variant: "default",
41
+ },
42
+ argTypes: {
43
+ variant: {
44
+ control: "select",
45
+ options: ["default", "error", "success", "warning", "info"],
46
+ },
47
+ title: { control: "text" },
48
+ description: { control: "text" },
49
+ },
50
+ };
51
+
52
+ export default meta;
53
+ type Story = StoryObj<typeof Alert>;
54
+
55
+ export const Default: Story = {};
56
+
57
+ /**
58
+ * Use `variant="error"` for validation failures or destructive outcomes.
59
+ * Pair with an icon to reinforce the severity.
60
+ */
61
+ export const Error: Story = {
62
+ args: {
63
+ variant: "error",
64
+ title: "Something went wrong",
65
+ description: "Your session has expired. Please sign in again.",
66
+ icon: <AlertCircleIcon className="size-4" />,
67
+ },
68
+ };
69
+
70
+ /**
71
+ * Use `variant="success"` to confirm a completed action.
72
+ */
73
+ export const Success: Story = {
74
+ args: {
75
+ variant: "success",
76
+ title: "Changes saved",
77
+ description: "Your profile has been updated successfully.",
78
+ icon: <CheckCircle2Icon className="size-4" />,
79
+ },
80
+ };
81
+
82
+ export const Warning: Story = {
83
+ args: {
84
+ variant: "warning",
85
+ title: "Storage almost full",
86
+ description:
87
+ "You've used 90% of your storage quota. Free up space to avoid disruptions.",
88
+ icon: <TriangleAlert className="size-4" />,
89
+ },
90
+ };
91
+
92
+ export const Info: Story = {
93
+ args: {
94
+ variant: "info",
95
+ title: "Scheduled maintenance",
96
+ description:
97
+ "The service will be unavailable on Saturday from 2:00 to 4:00 AM UTC.",
98
+ icon: <InfoIcon className="size-4" />,
99
+ },
100
+ };
101
+
102
+ /**
103
+ * The `action` prop renders inside `AlertAction`, positioned to the right.
104
+ * Useful for inline CTAs like "Retry", "Undo", or "Dismiss".
105
+ */
106
+ export const WithAction: Story = {
107
+ args: {
108
+ variant: "error",
109
+ title: "Connection failed",
110
+ description: "Unable to reach the server.",
111
+ icon: <AlertCircleIcon className="size-4" />,
112
+ action: (
113
+ <Button size="sm" variant="error">
114
+ Retry
115
+ </Button>
116
+ ),
117
+ },
118
+ };
119
+
120
+ /**
121
+ * Use the primitives directly when you need full control over layout or content structure.
122
+ * `AlertRoot` accepts `variant` and all standard div props.
123
+ */
124
+ export const Primitive: Story = {
125
+ render: () => (
126
+ <AlertRoot variant="error">
127
+ <AlertCircleIcon className="size-4" />
128
+ <AlertTitle>Payment failed</AlertTitle>
129
+ <AlertDescription>
130
+ Your card was declined. Check your billing details and try again.
131
+ </AlertDescription>
132
+ <AlertAction>
133
+ <Button size="sm" variant="outline">
134
+ Dismiss
135
+ </Button>
136
+ <Button size="sm" variant="error">
137
+ Update billing
138
+ </Button>
139
+ </AlertAction>
140
+ </AlertRoot>
141
+ ),
142
+ };
@@ -0,0 +1,109 @@
1
+ import { cva, type VariantProps } from "class-variance-authority";
2
+ import { type ComponentProps, type ReactNode } from "react";
3
+ import { cn } from "../../lib";
4
+
5
+ const alertVariants = cva(
6
+ "relative grid w-full items-start gap-x-2 gap-y-0.5 rounded-xl border px-3 py-3 text-card-foreground text-sm has-[>svg]:has-data-[slot=alert-action]:grid-cols-[calc(var(--spacing)*4)_1fr_auto] has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-data-[slot=alert-action]:grid-cols-[1fr_auto] has-[>svg]:gap-x-2 [&>svg]:h-lh [&>svg]:w-4",
7
+ {
8
+ defaultVariants: {
9
+ variant: "default",
10
+ },
11
+ variants: {
12
+ variant: {
13
+ default: "bg-transparent [&>svg]:text-muted-foreground",
14
+ error: "border-error/32 bg-error/4 [&>svg]:text-error",
15
+ success: "border-success/32 bg-success/4 [&>svg]:text-success",
16
+ warning: "border-warning/32 bg-warning/4 [&>svg]:text-warning",
17
+ info: "border-info/32 bg-info/4 [&>svg]:text-info",
18
+ },
19
+ },
20
+ },
21
+ );
22
+
23
+ export function AlertRoot({
24
+ className,
25
+ variant,
26
+ ...props
27
+ }: ComponentProps<"div"> & VariantProps<typeof alertVariants>) {
28
+ return (
29
+ <div
30
+ className={cn(alertVariants({ variant }), className)}
31
+ data-slot="alert"
32
+ role="alert"
33
+ {...props}
34
+ />
35
+ );
36
+ }
37
+
38
+ export function AlertTitle({ className, ...props }: ComponentProps<"div">) {
39
+ return (
40
+ <div
41
+ className={cn("font-medium [svg~&]:col-start-2", className)}
42
+ data-slot="alert-title"
43
+ {...props}
44
+ />
45
+ );
46
+ }
47
+
48
+ export function AlertDescription({
49
+ className,
50
+ ...props
51
+ }: ComponentProps<"div">) {
52
+ return (
53
+ <div
54
+ className={cn(
55
+ "flex flex-col gap-2.5 text-muted-foreground [svg~&]:col-start-2",
56
+ className,
57
+ )}
58
+ data-slot="alert-description"
59
+ {...props}
60
+ />
61
+ );
62
+ }
63
+
64
+ export function AlertAction({ className, ...props }: ComponentProps<"div">) {
65
+ return (
66
+ <div
67
+ className={cn(
68
+ "flex gap-1 max-sm:col-start-2 max-sm:mt-2 sm:row-start-1 sm:row-end-3 sm:self-center sm:[[data-slot=alert-description]~&]:col-start-2 sm:[[data-slot=alert-title]~&]:col-start-2 sm:[svg~&]:col-start-2 sm:[svg~[data-slot=alert-description]~&]:col-start-3 sm:[svg~[data-slot=alert-title]~&]:col-start-3",
69
+ className,
70
+ )}
71
+ data-slot="alert-action"
72
+ {...props}
73
+ />
74
+ );
75
+ }
76
+
77
+ interface AlertProps extends Omit<ComponentProps<typeof AlertRoot>, "title"> {
78
+ title?: ReactNode;
79
+ description?: ReactNode;
80
+ icon?: ReactNode;
81
+ action?: ReactNode;
82
+ titleProps?: ComponentProps<typeof AlertTitle>;
83
+ descriptionProps?: ComponentProps<typeof AlertDescription>;
84
+ actionProps?: ComponentProps<typeof AlertAction>;
85
+ }
86
+
87
+ export function Alert({
88
+ title,
89
+ description,
90
+ icon,
91
+ action,
92
+ titleProps,
93
+ descriptionProps,
94
+ actionProps,
95
+ children,
96
+ ...props
97
+ }: AlertProps) {
98
+ return (
99
+ <AlertRoot {...props}>
100
+ {icon}
101
+ {title && <AlertTitle {...titleProps}>{title}</AlertTitle>}
102
+ {description && (
103
+ <AlertDescription {...descriptionProps}>{description}</AlertDescription>
104
+ )}
105
+ {action && <AlertAction {...actionProps}>{action}</AlertAction>}
106
+ {children}
107
+ </AlertRoot>
108
+ );
109
+ }
@@ -0,0 +1,7 @@
1
+ export {
2
+ Alert,
3
+ AlertAction,
4
+ AlertDescription,
5
+ AlertRoot,
6
+ AlertTitle,
7
+ } from "./alert";
@@ -0,0 +1,173 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite";
2
+ import { Trash2 } from "lucide-react";
3
+ import { action } from "storybook/actions";
4
+ import {
5
+ AlertDialog,
6
+ AlertDialogClose,
7
+ AlertDialogFooter,
8
+ AlertDialogHeader,
9
+ AlertDialogPopup,
10
+ AlertDialogRoot,
11
+ AlertDialogTitle,
12
+ AlertDialogTrigger,
13
+ Button,
14
+ Tooltip,
15
+ } from "../../components";
16
+
17
+ /**
18
+ * Accessible confirmation dialog that requires the user to explicitly acknowledge
19
+ * a destructive or irreversible action before proceeding.
20
+ *
21
+ * The `trigger` prop uses Base UI's `render` prop — no DOM wrapper is added —
22
+ * so it composes cleanly with `<Tooltip>` via the primitive API (see **WithTooltip**).
23
+ *
24
+ * Use `open` + `onOpenChange` for programmatic control when there is no static trigger.
25
+ * For anything beyond the two-button layout, drop down to the exported primitives.
26
+ */
27
+ const meta: Meta<typeof AlertDialog> = {
28
+ title: "Components/AlertDialog",
29
+ component: AlertDialog,
30
+ parameters: {
31
+ layout: "centered",
32
+ },
33
+ args: {
34
+ trigger: <Button variant="outline">Open dialog</Button>,
35
+ title: "Are you sure?",
36
+ description: "This action cannot be undone.",
37
+ onClose: action("onClose"),
38
+ onAction: action("onAction"),
39
+ },
40
+ argTypes: {
41
+ trigger: { control: false },
42
+ title: { control: "text" },
43
+ description: { control: "text" },
44
+ closeText: { control: "text" },
45
+ actionText: { control: "text" },
46
+ variant: {
47
+ control: "select",
48
+ options: ["default", "error", "secondary", "outline", "ghost"],
49
+ },
50
+ },
51
+ };
52
+
53
+ export default meta;
54
+ type Story = StoryObj<typeof AlertDialog>;
55
+
56
+ export const Default: Story = {};
57
+
58
+ /**
59
+ * Use `variant="error"` for irreversible actions like deletes.
60
+ * The error button signals danger — reserve it for data loss scenarios.
61
+ */
62
+ export const Error: Story = {
63
+ args: {
64
+ trigger: <Button variant="error">Delete account</Button>,
65
+ title: "Delete account?",
66
+ description:
67
+ "Your account and all associated data will be permanently removed. This cannot be undone.",
68
+ variant: "error",
69
+ actionText: "Delete",
70
+ closeText: "Keep account",
71
+ },
72
+ };
73
+
74
+ /**
75
+ * `children` renders between the description and the footer buttons.
76
+ * Use it for detail lists, warnings, or any custom content that belongs
77
+ * inside the dialog body without replacing the standard header/footer layout.
78
+ */
79
+ export const WithBody: Story = {
80
+ args: {
81
+ trigger: <Button variant="outline">Transfer ownership</Button>,
82
+ title: "Transfer workspace ownership",
83
+ description:
84
+ "Transferring ownership will immediately revoke your admin access.",
85
+ children: (
86
+ <ul className="rounded-md border bg-muted/50 p-4 text-sm space-y-1.5 text-muted-foreground">
87
+ <li>• You will become a regular member</li>
88
+ <li>• Billing responsibility transfers to the new owner</li>
89
+ <li>• Active integrations will be re-authenticated</li>
90
+ </ul>
91
+ ),
92
+ actionText: "Transfer",
93
+ },
94
+ };
95
+
96
+ /**
97
+ * Use `open` and `onOpenChange` when the dialog is triggered programmatically —
98
+ * from a table row action, a keyboard shortcut, or a side-effect — without a
99
+ * static trigger element rendered next to the content.
100
+ */
101
+ export const Controlled: Story = {
102
+ render: (args) => {
103
+ return (
104
+ <div className="flex items-center gap-4">
105
+ <AlertDialog {...args} />
106
+ <span className="text-sm text-muted-foreground">
107
+ Dialog is controlled externally
108
+ </span>
109
+ </div>
110
+ );
111
+ },
112
+ args: {
113
+ trigger: <Button variant="outline">Open (controlled)</Button>,
114
+ title: "Controlled dialog",
115
+ description:
116
+ "This dialog's open state is managed by the parent. Useful for programmatic flows.",
117
+ },
118
+ };
119
+
120
+ /**
121
+ * Pass a `<Tooltip>` as the `trigger` to show a tooltip on hover and open the dialog
122
+ * on click — both bound to the same DOM element, no wrapper added.
123
+ *
124
+ * This works because `Tooltip` forwards unknown props to its internal trigger,
125
+ * so Base UI can chain the dialog's click handler through into the `<Button>`.
126
+ */
127
+ export const WithTooltip: Story = {
128
+ args: {
129
+ trigger: (
130
+ <Tooltip content="Permanently delete this item">
131
+ <Button variant="error">
132
+ <Trash2 className="size-4" />
133
+ Delete
134
+ </Button>
135
+ </Tooltip>
136
+ ),
137
+ title: "Delete item?",
138
+ description: "This action cannot be undone.",
139
+ variant: "error",
140
+ actionText: "Delete",
141
+ },
142
+ };
143
+
144
+ /**
145
+ * Direct composition with primitives for full structural control.
146
+ * Use this when the composite layout doesn't fit — custom headers, async actions,
147
+ * forms, or multi-step flows.
148
+ */
149
+ export const Primitive: Story = {
150
+ render: () => (
151
+ <AlertDialogRoot>
152
+ <AlertDialogTrigger>
153
+ <Button variant="outline">Open</Button>
154
+ </AlertDialogTrigger>
155
+ <AlertDialogPopup>
156
+ <AlertDialogHeader>
157
+ <AlertDialogTitle>Built with primitives</AlertDialogTitle>
158
+ </AlertDialogHeader>
159
+ <p className="text-sm text-muted-foreground">
160
+ Any layout is possible — forms, lists, custom footers.
161
+ </p>
162
+ <AlertDialogFooter>
163
+ <AlertDialogClose>
164
+ <Button variant="secondary">Cancel</Button>
165
+ </AlertDialogClose>
166
+ <AlertDialogClose>
167
+ <Button>Confirm</Button>
168
+ </AlertDialogClose>
169
+ </AlertDialogFooter>
170
+ </AlertDialogPopup>
171
+ </AlertDialogRoot>
172
+ ),
173
+ };