@jesusgm/react-components 0.0.0-stage → 0.1.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 (323) hide show
  1. package/Readme.md +158 -0
  2. package/dist/components/atoms/avatar/index.d.ts +19 -0
  3. package/dist/components/atoms/avatar/index.js +44 -0
  4. package/dist/components/atoms/avatar/index.js.map +1 -0
  5. package/dist/components/atoms/avatar/styles.css +50 -0
  6. package/dist/components/atoms/badge/index.d.ts +17 -0
  7. package/dist/components/atoms/badge/index.js +37 -0
  8. package/dist/components/atoms/badge/index.js.map +1 -0
  9. package/dist/components/atoms/badge/styles.css +83 -0
  10. package/dist/components/atoms/button/index.d.ts +16 -0
  11. package/dist/components/atoms/button/index.js +22 -0
  12. package/dist/components/atoms/button/index.js.map +1 -0
  13. package/dist/components/atoms/button/styles.css +77 -0
  14. package/dist/components/atoms/checkbox/index.d.ts +13 -0
  15. package/dist/components/atoms/checkbox/index.js +63 -0
  16. package/dist/components/atoms/checkbox/index.js.map +1 -0
  17. package/dist/components/atoms/checkbox/styles.css +87 -0
  18. package/dist/components/atoms/code-highlighter/index.d.ts +8 -0
  19. package/dist/components/atoms/code-highlighter/index.js +24 -0
  20. package/dist/components/atoms/code-highlighter/index.js.map +1 -0
  21. package/dist/components/atoms/code-highlighter/railscasts.css +1 -0
  22. package/dist/components/atoms/code-highlighter/styles.css +17 -0
  23. package/dist/components/atoms/divider/index.d.ts +10 -0
  24. package/dist/components/atoms/divider/index.js +25 -0
  25. package/dist/components/atoms/divider/index.js.map +1 -0
  26. package/dist/components/atoms/divider/styles.css +56 -0
  27. package/dist/components/atoms/icon/index.d.ts +23 -0
  28. package/dist/components/atoms/icon/index.js +20 -0
  29. package/dist/components/atoms/icon/index.js.map +1 -0
  30. package/dist/components/atoms/icon/styles.css +13 -0
  31. package/dist/components/atoms/kbd/index.d.ts +7 -0
  32. package/dist/components/atoms/kbd/index.js +26 -0
  33. package/dist/components/atoms/kbd/index.js.map +1 -0
  34. package/dist/components/atoms/kbd/styles.css +29 -0
  35. package/dist/components/atoms/label/index.d.ts +9 -0
  36. package/dist/components/atoms/label/index.js +18 -0
  37. package/dist/components/atoms/label/index.js.map +1 -0
  38. package/dist/components/atoms/label/styles.css +19 -0
  39. package/dist/components/atoms/link/index.d.ts +12 -0
  40. package/dist/components/atoms/link/index.js +32 -0
  41. package/dist/components/atoms/link/index.js.map +1 -0
  42. package/dist/components/atoms/link/styles.css +54 -0
  43. package/dist/components/atoms/progress-bar/index.d.ts +23 -0
  44. package/dist/components/atoms/progress-bar/index.js +45 -0
  45. package/dist/components/atoms/progress-bar/index.js.map +1 -0
  46. package/dist/components/atoms/progress-bar/styles.css +75 -0
  47. package/dist/components/atoms/radio/context.d.ts +9 -0
  48. package/dist/components/atoms/radio/context.js +9 -0
  49. package/dist/components/atoms/radio/context.js.map +1 -0
  50. package/dist/components/atoms/radio/index.d.ts +15 -0
  51. package/dist/components/atoms/radio/index.js +44 -0
  52. package/dist/components/atoms/radio/index.js.map +1 -0
  53. package/dist/components/atoms/radio/radio-group.d.ts +25 -0
  54. package/dist/components/atoms/radio/radio-group.js +49 -0
  55. package/dist/components/atoms/radio/radio-group.js.map +1 -0
  56. package/dist/components/atoms/radio/styles.css +110 -0
  57. package/dist/components/atoms/skeleton/index.d.ts +15 -0
  58. package/dist/components/atoms/skeleton/index.js +38 -0
  59. package/dist/components/atoms/skeleton/index.js.map +1 -0
  60. package/dist/components/atoms/skeleton/styles.css +57 -0
  61. package/dist/components/atoms/spinner/index.d.ts +11 -0
  62. package/dist/components/atoms/spinner/index.js +22 -0
  63. package/dist/components/atoms/spinner/index.js.map +1 -0
  64. package/dist/components/atoms/spinner/styles.css +51 -0
  65. package/dist/components/atoms/switch/index.d.ts +14 -0
  66. package/dist/components/atoms/switch/index.js +33 -0
  67. package/dist/components/atoms/switch/index.js.map +1 -0
  68. package/dist/components/atoms/switch/styles.css +99 -0
  69. package/dist/components/atoms/text-input/index.d.ts +20 -0
  70. package/dist/components/atoms/text-input/index.js +33 -0
  71. package/dist/components/atoms/text-input/index.js.map +1 -0
  72. package/dist/components/atoms/text-input/styles.css +80 -0
  73. package/dist/components/atoms/textarea/index.d.ts +14 -0
  74. package/dist/components/atoms/textarea/index.js +43 -0
  75. package/dist/components/atoms/textarea/index.js.map +1 -0
  76. package/dist/components/atoms/textarea/styles.css +49 -0
  77. package/dist/components/atoms/typography/index.d.ts +30 -0
  78. package/dist/components/atoms/typography/index.js +30 -0
  79. package/dist/components/atoms/typography/index.js.map +1 -0
  80. package/dist/components/atoms/typography/styles.css +50 -0
  81. package/dist/components/atoms/video-player/index.d.ts +9 -0
  82. package/dist/components/atoms/video-player/index.js +17 -0
  83. package/dist/components/atoms/video-player/index.js.map +1 -0
  84. package/dist/components/atoms/video-player/styles.css +18 -0
  85. package/dist/components/atoms/visually-hidden/index.d.ts +7 -0
  86. package/dist/components/atoms/visually-hidden/index.js +13 -0
  87. package/dist/components/atoms/visually-hidden/index.js.map +1 -0
  88. package/dist/components/atoms/visually-hidden/styles.css +12 -0
  89. package/dist/components/hooks/index.d.ts +3 -0
  90. package/dist/components/hooks/index.js +4 -0
  91. package/dist/components/hooks/use-click-outside.d.ts +6 -0
  92. package/dist/components/hooks/use-click-outside.js +30 -0
  93. package/dist/components/hooks/use-click-outside.js.map +1 -0
  94. package/dist/components/hooks/use-controllable-state.d.ts +5 -0
  95. package/dist/components/hooks/use-controllable-state.js +22 -0
  96. package/dist/components/hooks/use-controllable-state.js.map +1 -0
  97. package/dist/components/hooks/use-focus-trap.d.ts +8 -0
  98. package/dist/components/hooks/use-focus-trap.js +57 -0
  99. package/dist/components/hooks/use-focus-trap.js.map +1 -0
  100. package/dist/components/index.d.ts +122 -0
  101. package/dist/components/index.js +74 -0
  102. package/dist/components/molecules/accordion/index.d.ts +27 -0
  103. package/dist/components/molecules/accordion/index.js +98 -0
  104. package/dist/components/molecules/accordion/index.js.map +1 -0
  105. package/dist/components/molecules/accordion/styles.css +75 -0
  106. package/dist/components/molecules/alert/index.d.ts +18 -0
  107. package/dist/components/molecules/alert/index.js +91 -0
  108. package/dist/components/molecules/alert/index.js.map +1 -0
  109. package/dist/components/molecules/alert/styles.css +97 -0
  110. package/dist/components/molecules/binary-clock/index.d.ts +16 -0
  111. package/dist/components/molecules/binary-clock/index.js +66 -0
  112. package/dist/components/molecules/binary-clock/index.js.map +1 -0
  113. package/dist/components/molecules/binary-clock/styles.css +46 -0
  114. package/dist/components/molecules/breadcrumb/index.d.ts +23 -0
  115. package/dist/components/molecules/breadcrumb/index.js +79 -0
  116. package/dist/components/molecules/breadcrumb/index.js.map +1 -0
  117. package/dist/components/molecules/breadcrumb/styles.css +61 -0
  118. package/dist/components/molecules/card/index.d.ts +39 -0
  119. package/dist/components/molecules/card/index.js +60 -0
  120. package/dist/components/molecules/card/index.js.map +1 -0
  121. package/dist/components/molecules/card/styles.css +105 -0
  122. package/dist/components/molecules/chart/index.d.ts +14 -0
  123. package/dist/components/molecules/chart/index.js +104 -0
  124. package/dist/components/molecules/chart/index.js.map +1 -0
  125. package/dist/components/molecules/conflict-resolver/components/conflictItem.d.ts +8 -0
  126. package/dist/components/molecules/conflict-resolver/components/conflictItem.js +58 -0
  127. package/dist/components/molecules/conflict-resolver/components/conflictItem.js.map +1 -0
  128. package/dist/components/molecules/conflict-resolver/components/styles.css +64 -0
  129. package/dist/components/molecules/conflict-resolver/index.d.ts +10 -0
  130. package/dist/components/molecules/conflict-resolver/index.js +35 -0
  131. package/dist/components/molecules/conflict-resolver/index.js.map +1 -0
  132. package/dist/components/molecules/conflict-resolver/types.d.ts +10 -0
  133. package/dist/components/molecules/dropable-list/draggable.d.ts +9 -0
  134. package/dist/components/molecules/dropable-list/draggable.js +18 -0
  135. package/dist/components/molecules/dropable-list/draggable.js.map +1 -0
  136. package/dist/components/molecules/dropable-list/index.d.ts +20 -0
  137. package/dist/components/molecules/dropable-list/index.js +52 -0
  138. package/dist/components/molecules/dropable-list/index.js.map +1 -0
  139. package/dist/components/molecules/dropable-list/styles.css +63 -0
  140. package/dist/components/molecules/dropdown-menu/index.d.ts +43 -0
  141. package/dist/components/molecules/dropdown-menu/index.js +226 -0
  142. package/dist/components/molecules/dropdown-menu/index.js.map +1 -0
  143. package/dist/components/molecules/dropdown-menu/styles.css +94 -0
  144. package/dist/components/molecules/empty-state/index.d.ts +16 -0
  145. package/dist/components/molecules/empty-state/index.js +32 -0
  146. package/dist/components/molecules/empty-state/index.js.map +1 -0
  147. package/dist/components/molecules/empty-state/styles.css +64 -0
  148. package/dist/components/molecules/file-input/index.d.ts +39 -0
  149. package/dist/components/molecules/file-input/index.js +121 -0
  150. package/dist/components/molecules/file-input/index.js.map +1 -0
  151. package/dist/components/molecules/file-input/styles.css +86 -0
  152. package/dist/components/molecules/form-field/index.d.ts +38 -0
  153. package/dist/components/molecules/form-field/index.js +71 -0
  154. package/dist/components/molecules/form-field/index.js.map +1 -0
  155. package/dist/components/molecules/form-field/styles.css +43 -0
  156. package/dist/components/molecules/list/index.d.ts +25 -0
  157. package/dist/components/molecules/list/index.js +30 -0
  158. package/dist/components/molecules/list/index.js.map +1 -0
  159. package/dist/components/molecules/list/styles.css +28 -0
  160. package/dist/components/molecules/number-stepper/index.d.ts +31 -0
  161. package/dist/components/molecules/number-stepper/index.js +163 -0
  162. package/dist/components/molecules/number-stepper/index.js.map +1 -0
  163. package/dist/components/molecules/number-stepper/styles.css +69 -0
  164. package/dist/components/molecules/pagination/index.d.ts +39 -0
  165. package/dist/components/molecules/pagination/index.js +111 -0
  166. package/dist/components/molecules/pagination/index.js.map +1 -0
  167. package/dist/components/molecules/pagination/styles.css +41 -0
  168. package/dist/components/molecules/popover/index.d.ts +22 -0
  169. package/dist/components/molecules/popover/index.js +76 -0
  170. package/dist/components/molecules/popover/index.js.map +1 -0
  171. package/dist/components/molecules/popover/positioning.d.ts +40 -0
  172. package/dist/components/molecules/popover/positioning.js +115 -0
  173. package/dist/components/molecules/popover/positioning.js.map +1 -0
  174. package/dist/components/molecules/popover/styles.css +36 -0
  175. package/dist/components/molecules/rating/index.d.ts +33 -0
  176. package/dist/components/molecules/rating/index.js +117 -0
  177. package/dist/components/molecules/rating/index.js.map +1 -0
  178. package/dist/components/molecules/rating/styles.css +94 -0
  179. package/dist/components/molecules/search-input/index.d.ts +23 -0
  180. package/dist/components/molecules/search-input/index.js +118 -0
  181. package/dist/components/molecules/search-input/index.js.map +1 -0
  182. package/dist/components/molecules/search-input/styles.css +69 -0
  183. package/dist/components/molecules/segmented-control/button-group.d.ts +10 -0
  184. package/dist/components/molecules/segmented-control/button-group.js +15 -0
  185. package/dist/components/molecules/segmented-control/button-group.js.map +1 -0
  186. package/dist/components/molecules/segmented-control/index.d.ts +38 -0
  187. package/dist/components/molecules/segmented-control/index.js +80 -0
  188. package/dist/components/molecules/segmented-control/index.js.map +1 -0
  189. package/dist/components/molecules/segmented-control/styles.css +130 -0
  190. package/dist/components/molecules/select/index.d.ts +30 -0
  191. package/dist/components/molecules/select/index.js +48 -0
  192. package/dist/components/molecules/select/index.js.map +1 -0
  193. package/dist/components/molecules/select/styles.css +102 -0
  194. package/dist/components/molecules/tabs/index.d.ts +31 -0
  195. package/dist/components/molecules/tabs/index.js +87 -0
  196. package/dist/components/molecules/tabs/index.js.map +1 -0
  197. package/dist/components/molecules/tabs/styles.css +87 -0
  198. package/dist/components/molecules/tag-cloud/index.d.ts +16 -0
  199. package/dist/components/molecules/tag-cloud/index.js +133 -0
  200. package/dist/components/molecules/tag-cloud/index.js.map +1 -0
  201. package/dist/components/molecules/tag-cloud/styles.css +29 -0
  202. package/dist/components/molecules/tooltip/index.d.ts +22 -0
  203. package/dist/components/molecules/tooltip/index.js +83 -0
  204. package/dist/components/molecules/tooltip/index.js.map +1 -0
  205. package/dist/components/molecules/tooltip/styles.css +30 -0
  206. package/dist/components/molecules/virtualized-list/index.d.ts +5 -0
  207. package/dist/components/molecules/virtualized-list/index.js +3 -0
  208. package/dist/components/molecules/virtualized-list/lista/index.d.ts +11 -0
  209. package/dist/components/molecules/virtualized-list/lista/index.js +30 -0
  210. package/dist/components/molecules/virtualized-list/lista/index.js.map +1 -0
  211. package/dist/components/molecules/virtualized-list/lista/styles.css +27 -0
  212. package/dist/components/molecules/virtualized-list/lista-slow/index.d.ts +10 -0
  213. package/dist/components/molecules/virtualized-list/lista-slow/index.js +17 -0
  214. package/dist/components/molecules/virtualized-list/lista-slow/index.js.map +1 -0
  215. package/dist/components/molecules/virtualized-list/row/index.d.ts +9 -0
  216. package/dist/components/molecules/virtualized-list/row/index.js +30 -0
  217. package/dist/components/molecules/virtualized-list/row/index.js.map +1 -0
  218. package/dist/components/molecules/virtualized-list/types.d.ts +4 -0
  219. package/dist/components/organisms/combobox/index.d.ts +82 -0
  220. package/dist/components/organisms/combobox/index.js +386 -0
  221. package/dist/components/organisms/combobox/index.js.map +1 -0
  222. package/dist/components/organisms/combobox/styles.css +269 -0
  223. package/dist/components/organisms/command-palette/index.d.ts +49 -0
  224. package/dist/components/organisms/command-palette/index.js +239 -0
  225. package/dist/components/organisms/command-palette/index.js.map +1 -0
  226. package/dist/components/organisms/command-palette/score.d.ts +12 -0
  227. package/dist/components/organisms/command-palette/score.js +43 -0
  228. package/dist/components/organisms/command-palette/score.js.map +1 -0
  229. package/dist/components/organisms/command-palette/styles.css +212 -0
  230. package/dist/components/organisms/date-picker/calendar.d.ts +29 -0
  231. package/dist/components/organisms/date-picker/calendar.js +178 -0
  232. package/dist/components/organisms/date-picker/calendar.js.map +1 -0
  233. package/dist/components/organisms/date-picker/date-utils.d.ts +52 -0
  234. package/dist/components/organisms/date-picker/date-utils.js +139 -0
  235. package/dist/components/organisms/date-picker/date-utils.js.map +1 -0
  236. package/dist/components/organisms/date-picker/index.d.ts +54 -0
  237. package/dist/components/organisms/date-picker/index.js +173 -0
  238. package/dist/components/organisms/date-picker/index.js.map +1 -0
  239. package/dist/components/organisms/date-picker/styles.css +179 -0
  240. package/dist/components/organisms/drawer/index.d.ts +16 -0
  241. package/dist/components/organisms/drawer/index.js +15 -0
  242. package/dist/components/organisms/drawer/index.js.map +1 -0
  243. package/dist/components/organisms/drawer/styles.css +163 -0
  244. package/dist/components/organisms/editor/index.d.ts +13 -0
  245. package/dist/components/organisms/editor/index.js +56 -0
  246. package/dist/components/organisms/editor/index.js.map +1 -0
  247. package/dist/components/organisms/editor/styles.css +61 -0
  248. package/dist/components/organisms/form/context.d.ts +7 -0
  249. package/dist/components/organisms/form/context.js +11 -0
  250. package/dist/components/organisms/form/context.js.map +1 -0
  251. package/dist/components/organisms/form/field.d.ts +18 -0
  252. package/dist/components/organisms/form/field.js +98 -0
  253. package/dist/components/organisms/form/field.js.map +1 -0
  254. package/dist/components/organisms/form/form-actions.d.ts +8 -0
  255. package/dist/components/organisms/form/form-actions.js +13 -0
  256. package/dist/components/organisms/form/form-actions.js.map +1 -0
  257. package/dist/components/organisms/form/index.d.ts +24 -0
  258. package/dist/components/organisms/form/index.js +215 -0
  259. package/dist/components/organisms/form/index.js.map +1 -0
  260. package/dist/components/organisms/form/styles.css +29 -0
  261. package/dist/components/organisms/form/types.d.ts +95 -0
  262. package/dist/components/organisms/form/validation.d.ts +5 -0
  263. package/dist/components/organisms/form/validation.js +35 -0
  264. package/dist/components/organisms/form/validation.js.map +1 -0
  265. package/dist/components/organisms/header/index.d.ts +40 -0
  266. package/dist/components/organisms/header/index.js +186 -0
  267. package/dist/components/organisms/header/index.js.map +1 -0
  268. package/dist/components/organisms/header/styles.css +126 -0
  269. package/dist/components/organisms/modal/dialog-base.d.ts +31 -0
  270. package/dist/components/organisms/modal/dialog-base.js +123 -0
  271. package/dist/components/organisms/modal/dialog-base.js.map +1 -0
  272. package/dist/components/organisms/modal/index.d.ts +13 -0
  273. package/dist/components/organisms/modal/index.js +15 -0
  274. package/dist/components/organisms/modal/index.js.map +1 -0
  275. package/dist/components/organisms/modal/styles.css +143 -0
  276. package/dist/components/organisms/presenter/components/slides/simple/index.d.ts +13 -0
  277. package/dist/components/organisms/presenter/components/slides/simple/index.js +16 -0
  278. package/dist/components/organisms/presenter/components/slides/simple/index.js.map +1 -0
  279. package/dist/components/organisms/presenter/components/slides/simple/styles.css +6 -0
  280. package/dist/components/organisms/presenter/index.d.ts +17 -0
  281. package/dist/components/organisms/presenter/index.js +63 -0
  282. package/dist/components/organisms/presenter/index.js.map +1 -0
  283. package/dist/components/organisms/presenter/styles.css +75 -0
  284. package/dist/components/organisms/sidebar/index.d.ts +50 -0
  285. package/dist/components/organisms/sidebar/index.js +157 -0
  286. package/dist/components/organisms/sidebar/index.js.map +1 -0
  287. package/dist/components/organisms/sidebar/styles.css +197 -0
  288. package/dist/components/organisms/slider/index.d.ts +47 -0
  289. package/dist/components/organisms/slider/index.js +214 -0
  290. package/dist/components/organisms/slider/index.js.map +1 -0
  291. package/dist/components/organisms/slider/styles.css +110 -0
  292. package/dist/components/organisms/table/components/cell/index.d.ts +8 -0
  293. package/dist/components/organisms/table/components/cell/index.js +11 -0
  294. package/dist/components/organisms/table/components/cell/index.js.map +1 -0
  295. package/dist/components/organisms/table/index.d.ts +29 -0
  296. package/dist/components/organisms/table/index.js +105 -0
  297. package/dist/components/organisms/table/index.js.map +1 -0
  298. package/dist/components/organisms/table/styles.css +66 -0
  299. package/dist/components/organisms/terminal/index.d.ts +15 -0
  300. package/dist/components/organisms/terminal/index.js +111 -0
  301. package/dist/components/organisms/terminal/index.js.map +1 -0
  302. package/dist/components/organisms/terminal/styles.css +123 -0
  303. package/dist/components/organisms/toast/index.d.ts +66 -0
  304. package/dist/components/organisms/toast/index.js +142 -0
  305. package/dist/components/organisms/toast/index.js.map +1 -0
  306. package/dist/components/organisms/toast/styles.css +138 -0
  307. package/dist/components/organisms/wizard/index.d.ts +44 -0
  308. package/dist/components/organisms/wizard/index.js +171 -0
  309. package/dist/components/organisms/wizard/index.js.map +1 -0
  310. package/dist/components/organisms/wizard/styles.css +160 -0
  311. package/dist/components/utils/cx.d.ts +2 -0
  312. package/dist/components/utils/cx.js +8 -0
  313. package/dist/components/utils/cx.js.map +1 -0
  314. package/dist/components/utils/portal/index.d.ts +9 -0
  315. package/dist/components/utils/portal/index.js +13 -0
  316. package/dist/components/utils/portal/index.js.map +1 -0
  317. package/dist/components/utils/theme-provider/index.d.ts +22 -0
  318. package/dist/components/utils/theme-provider/index.js +36 -0
  319. package/dist/components/utils/theme-provider/index.js.map +1 -0
  320. package/dist/styles.css +743 -0
  321. package/dist/tokens.css +299 -0
  322. package/package.json +390 -4
  323. package/README.md +0 -3
@@ -0,0 +1,22 @@
1
+ import { useCallback, useRef, useState } from "react";
2
+ // src/components/hooks/use-controllable-state.ts
3
+ /**
4
+ * State that can be controlled (`value` + `onChange`) or uncontrolled (`defaultValue`).
5
+ * Returns `[value, setValue]`; `setValue` always calls `onChange`.
6
+ */
7
+ function useControllableState(value, defaultValue, onChange) {
8
+ const [internal, setInternal] = useState(defaultValue);
9
+ const isControlled = value !== void 0;
10
+ const current = isControlled ? value : internal;
11
+ const currentRef = useRef(current);
12
+ currentRef.current = current;
13
+ return [current, useCallback((next) => {
14
+ const resolved = typeof next === "function" ? next(currentRef.current) : next;
15
+ if (Object.is(resolved, currentRef.current)) return;
16
+ if (!isControlled) setInternal(resolved);
17
+ onChange?.(resolved);
18
+ }, [isControlled, onChange])];
19
+ }
20
+ export { useControllableState };
21
+
22
+ //# sourceMappingURL=use-controllable-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-controllable-state.js","names":[],"sources":["../../../src/components/hooks/use-controllable-state.ts"],"sourcesContent":["import { useCallback, useRef, useState } from \"react\";\n\n/**\n * State that can be controlled (`value` + `onChange`) or uncontrolled (`defaultValue`).\n * Returns `[value, setValue]`; `setValue` always calls `onChange`.\n */\nexport function useControllableState<T>(\n value: T | undefined,\n defaultValue: T,\n onChange?: (value: T) => void\n): [T, (next: T | ((prev: T) => T)) => void] {\n const [internal, setInternal] = useState<T>(defaultValue);\n const isControlled = value !== undefined;\n const current = isControlled ? value : internal;\n const currentRef = useRef(current);\n currentRef.current = current;\n\n const setValue = useCallback(\n (next: T | ((prev: T) => T)) => {\n const resolved = typeof next === \"function\" ? (next as (prev: T) => T)(currentRef.current) : next;\n if (Object.is(resolved, currentRef.current)) return;\n if (!isControlled) setInternal(resolved);\n onChange?.(resolved);\n },\n [isControlled, onChange]\n );\n\n return [current, setValue];\n}\n"],"mappings":";;;;;;AAMA,SAAgB,qBACd,OACA,cACA,UAC2C;CAC3C,MAAM,CAAC,UAAU,eAAe,SAAY,YAAY;CACxD,MAAM,eAAe,UAAU,KAAA;CAC/B,MAAM,UAAU,eAAe,QAAQ;CACvC,MAAM,aAAa,OAAO,OAAO;CACjC,WAAW,UAAU;CAYrB,OAAO,CAAC,SAVS,aACd,SAA+B;EAC9B,MAAM,WAAW,OAAO,SAAS,aAAc,KAAwB,WAAW,OAAO,IAAI;EAC7F,IAAI,OAAO,GAAG,UAAU,WAAW,OAAO,GAAG;EAC7C,IAAI,CAAC,cAAc,YAAY,QAAQ;EACvC,WAAW,QAAQ;CACrB,GACA,CAAC,cAAc,QAAQ,CAGR,CAAQ;AAC3B"}
@@ -0,0 +1,8 @@
1
+ import { type RefObject } from "react";
2
+ /** Focusable descendants of `container`, in DOM order. */
3
+ export declare function getFocusable(container: HTMLElement): HTMLElement[];
4
+ /**
5
+ * While `active`, keeps Tab / Shift+Tab focus inside `ref`, moves focus into it on activation
6
+ * and restores the previously focused element on deactivation.
7
+ */
8
+ export declare function useFocusTrap(ref: RefObject<HTMLElement | null>, active?: boolean): void;
@@ -0,0 +1,57 @@
1
+ import { useEffect } from "react";
2
+ // src/components/hooks/use-focus-trap.ts
3
+ var FOCUSABLE = [
4
+ "a[href]",
5
+ "area[href]",
6
+ "button:not([disabled])",
7
+ "input:not([disabled]):not([type='hidden'])",
8
+ "select:not([disabled])",
9
+ "textarea:not([disabled])",
10
+ "iframe",
11
+ "[contenteditable='true']",
12
+ "[tabindex]:not([tabindex='-1'])"
13
+ ].join(",");
14
+ /** Focusable descendants of `container`, in DOM order. */
15
+ function getFocusable(container) {
16
+ return Array.from(container.querySelectorAll(FOCUSABLE)).filter((el) => !el.hasAttribute("disabled") && el.getAttribute("aria-hidden") !== "true");
17
+ }
18
+ /**
19
+ * While `active`, keeps Tab / Shift+Tab focus inside `ref`, moves focus into it on activation
20
+ * and restores the previously focused element on deactivation.
21
+ */
22
+ function useFocusTrap(ref, active = true) {
23
+ useEffect(() => {
24
+ const container = ref.current;
25
+ if (!active || !container) return;
26
+ const previouslyFocused = document.activeElement;
27
+ const [first] = getFocusable(container);
28
+ (first ?? container).focus();
29
+ const onKeyDown = (event) => {
30
+ if (event.key !== "Tab") return;
31
+ const focusable = getFocusable(container);
32
+ if (focusable.length === 0) {
33
+ event.preventDefault();
34
+ container.focus();
35
+ return;
36
+ }
37
+ const firstEl = focusable[0];
38
+ const lastEl = focusable[focusable.length - 1];
39
+ const current = document.activeElement;
40
+ if (event.shiftKey && (current === firstEl || !container.contains(current))) {
41
+ event.preventDefault();
42
+ lastEl.focus();
43
+ } else if (!event.shiftKey && (current === lastEl || !container.contains(current))) {
44
+ event.preventDefault();
45
+ firstEl.focus();
46
+ }
47
+ };
48
+ document.addEventListener("keydown", onKeyDown);
49
+ return () => {
50
+ document.removeEventListener("keydown", onKeyDown);
51
+ previouslyFocused?.focus?.();
52
+ };
53
+ }, [ref, active]);
54
+ }
55
+ export { getFocusable, useFocusTrap };
56
+
57
+ //# sourceMappingURL=use-focus-trap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-focus-trap.js","names":[],"sources":["../../../src/components/hooks/use-focus-trap.ts"],"sourcesContent":["import { useEffect, type RefObject } from \"react\";\n\nconst FOCUSABLE = [\n \"a[href]\",\n \"area[href]\",\n \"button:not([disabled])\",\n \"input:not([disabled]):not([type='hidden'])\",\n \"select:not([disabled])\",\n \"textarea:not([disabled])\",\n \"iframe\",\n \"[contenteditable='true']\",\n \"[tabindex]:not([tabindex='-1'])\",\n].join(\",\");\n\n/** Focusable descendants of `container`, in DOM order. */\nexport function getFocusable(container: HTMLElement): HTMLElement[] {\n return Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE)).filter(\n (el) => !el.hasAttribute(\"disabled\") && el.getAttribute(\"aria-hidden\") !== \"true\"\n );\n}\n\n/**\n * While `active`, keeps Tab / Shift+Tab focus inside `ref`, moves focus into it on activation\n * and restores the previously focused element on deactivation.\n */\nexport function useFocusTrap(ref: RefObject<HTMLElement | null>, active = true) {\n useEffect(() => {\n const container = ref.current;\n if (!active || !container) return;\n\n const previouslyFocused = document.activeElement as HTMLElement | null;\n const [first] = getFocusable(container);\n (first ?? container).focus();\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key !== \"Tab\") return;\n const focusable = getFocusable(container);\n if (focusable.length === 0) {\n event.preventDefault();\n container.focus();\n return;\n }\n const firstEl = focusable[0];\n const lastEl = focusable[focusable.length - 1];\n const current = document.activeElement;\n if (event.shiftKey && (current === firstEl || !container.contains(current))) {\n event.preventDefault();\n lastEl.focus();\n } else if (!event.shiftKey && (current === lastEl || !container.contains(current))) {\n event.preventDefault();\n firstEl.focus();\n }\n };\n\n document.addEventListener(\"keydown\", onKeyDown);\n return () => {\n document.removeEventListener(\"keydown\", onKeyDown);\n previouslyFocused?.focus?.();\n };\n }, [ref, active]);\n}\n"],"mappings":";;AAEA,IAAM,YAAY;CAChB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,GAAG;;AAGV,SAAgB,aAAa,WAAuC;CAClE,OAAO,MAAM,KAAK,UAAU,iBAA8B,SAAS,CAAC,CAAC,CAAC,QACnE,OAAO,CAAC,GAAG,aAAa,UAAU,KAAK,GAAG,aAAa,aAAa,MAAM,MAC7E;AACF;;;;;AAMA,SAAgB,aAAa,KAAoC,SAAS,MAAM;CAC9E,gBAAgB;EACd,MAAM,YAAY,IAAI;EACtB,IAAI,CAAC,UAAU,CAAC,WAAW;EAE3B,MAAM,oBAAoB,SAAS;EACnC,MAAM,CAAC,SAAS,aAAa,SAAS;EACtC,CAAC,SAAS,UAAA,CAAW,MAAM;EAE3B,MAAM,aAAa,UAAyB;GAC1C,IAAI,MAAM,QAAQ,OAAO;GACzB,MAAM,YAAY,aAAa,SAAS;GACxC,IAAI,UAAU,WAAW,GAAG;IAC1B,MAAM,eAAe;IACrB,UAAU,MAAM;IAChB;GACF;GACA,MAAM,UAAU,UAAU;GAC1B,MAAM,SAAS,UAAU,UAAU,SAAS;GAC5C,MAAM,UAAU,SAAS;GACzB,IAAI,MAAM,aAAa,YAAY,WAAW,CAAC,UAAU,SAAS,OAAO,IAAI;IAC3E,MAAM,eAAe;IACrB,OAAO,MAAM;GACf,OAAO,IAAI,CAAC,MAAM,aAAa,YAAY,UAAU,CAAC,UAAU,SAAS,OAAO,IAAI;IAClF,MAAM,eAAe;IACrB,QAAQ,MAAM;GAChB;EACF;EAEA,SAAS,iBAAiB,WAAW,SAAS;EAC9C,aAAa;GACX,SAAS,oBAAoB,WAAW,SAAS;GACjD,mBAAmB,QAAQ;EAC7B;CACF,GAAG,CAAC,KAAK,MAAM,CAAC;AAClB"}
@@ -0,0 +1,122 @@
1
+ export { default as Button } from "./atoms/button";
2
+ export type { ButtonProps, ButtonVariant, ButtonSize } from "./atoms/button";
3
+ export { default as Icon } from "./atoms/icon";
4
+ export type { IconProps, IconFont, IconSize } from "./atoms/icon";
5
+ export { default as CodeHighlighter } from "./atoms/code-highlighter";
6
+ export type { CodeHighlighterProps } from "./atoms/code-highlighter";
7
+ export { default as VideoPlayer } from "./atoms/video-player";
8
+ export type { VideoPlayerProps } from "./atoms/video-player";
9
+ export { default as Spinner } from "./atoms/spinner";
10
+ export type { SpinnerProps, SpinnerSize } from "./atoms/spinner";
11
+ export { default as Badge } from "./atoms/badge";
12
+ export type { BadgeProps, BadgeVariant, BadgeSize } from "./atoms/badge";
13
+ export { default as Avatar, getInitials } from "./atoms/avatar";
14
+ export type { AvatarProps, AvatarSize, AvatarShape } from "./atoms/avatar";
15
+ export { default as Link } from "./atoms/link";
16
+ export type { LinkProps, LinkVariant } from "./atoms/link";
17
+ export { default as Text, Heading } from "./atoms/typography";
18
+ export type { TextProps, TextElement, TextSize, TextTone, TextWeight, HeadingProps, HeadingLevel, HeadingSize } from "./atoms/typography";
19
+ export { default as Skeleton } from "./atoms/skeleton";
20
+ export type { SkeletonProps, SkeletonVariant } from "./atoms/skeleton";
21
+ export { default as ProgressBar } from "./atoms/progress-bar";
22
+ export type { ProgressBarProps, ProgressBarVariant, ProgressBarSize } from "./atoms/progress-bar";
23
+ export { default as Divider } from "./atoms/divider";
24
+ export type { DividerProps, DividerOrientation } from "./atoms/divider";
25
+ export { default as Label } from "./atoms/label";
26
+ export type { LabelProps } from "./atoms/label";
27
+ export { default as TextInput } from "./atoms/text-input";
28
+ export type { TextInputProps, TextInputSize } from "./atoms/text-input";
29
+ export { default as Textarea } from "./atoms/textarea";
30
+ export type { TextareaProps, TextareaResize } from "./atoms/textarea";
31
+ export { default as Checkbox } from "./atoms/checkbox";
32
+ export type { CheckboxProps } from "./atoms/checkbox";
33
+ export { default as Radio, RadioGroup } from "./atoms/radio";
34
+ export type { RadioProps, RadioGroupProps, RadioGroupOrientation } from "./atoms/radio";
35
+ export { default as Switch } from "./atoms/switch";
36
+ export type { SwitchProps, SwitchSize } from "./atoms/switch";
37
+ export { default as VisuallyHidden } from "./atoms/visually-hidden";
38
+ export type { VisuallyHiddenProps } from "./atoms/visually-hidden";
39
+ export { default as Kbd } from "./atoms/kbd";
40
+ export type { KbdProps } from "./atoms/kbd";
41
+ export { default as BinaryClock } from "./molecules/binary-clock";
42
+ export { default as Chart } from "./molecules/chart";
43
+ export type { ChartProps, ChartDataset } from "./molecules/chart";
44
+ export { default as ConflictResolver } from "./molecules/conflict-resolver";
45
+ export type { ConflictResolverProps, Conflict, ConflictId, ConflictResolution } from "./molecules/conflict-resolver";
46
+ export { default as DropableList, Draggable } from "./molecules/dropable-list";
47
+ export type { DropableListProps, DropableItem, DraggableProps } from "./molecules/dropable-list";
48
+ export { default as FileInput } from "./molecules/file-input";
49
+ export type { FileInputProps, FileItem } from "./molecules/file-input";
50
+ export { default as List } from "./molecules/list";
51
+ export type { ListProps, ListItemProps } from "./molecules/list";
52
+ export { default as TagCloud } from "./molecules/tag-cloud";
53
+ export type { TagCloudProps, Tag } from "./molecules/tag-cloud";
54
+ export { default as VirtualizedList, SlowList } from "./molecules/virtualized-list";
55
+ export type { VirtualizedListProps, SlowListProps, RowData } from "./molecules/virtualized-list";
56
+ export { default as Tabs } from "./molecules/tabs";
57
+ export type { TabsProps, TabItem, TabsOrientation, TabsActivation } from "./molecules/tabs";
58
+ export { default as Pagination, getPageItems } from "./molecules/pagination";
59
+ export type { PaginationProps, PaginationLabels, PageItem } from "./molecules/pagination";
60
+ export { default as Card, CardHeader, CardBody, CardFooter, CardMedia } from "./molecules/card";
61
+ export type { CardProps, CardVariant, CardPadding, CardHeaderProps, CardBodyProps, CardFooterProps, CardMediaProps } from "./molecules/card";
62
+ export { default as Breadcrumb } from "./molecules/breadcrumb";
63
+ export type { BreadcrumbProps, BreadcrumbItem } from "./molecules/breadcrumb";
64
+ export { default as Accordion } from "./molecules/accordion";
65
+ export type { AccordionProps, AccordionItem } from "./molecules/accordion";
66
+ export { default as EmptyState } from "./molecules/empty-state";
67
+ export type { EmptyStateProps, EmptyStateSize } from "./molecules/empty-state";
68
+ export { default as Alert } from "./molecules/alert";
69
+ export type { AlertProps, AlertVariant } from "./molecules/alert";
70
+ export { default as Popover, computePosition } from "./molecules/popover";
71
+ export type { PopoverProps, Placement as PopoverPlacement, PlacementSide, PlacementAlign } from "./molecules/popover";
72
+ export { default as Tooltip } from "./molecules/tooltip";
73
+ export type { TooltipProps } from "./molecules/tooltip";
74
+ export { default as DropdownMenu } from "./molecules/dropdown-menu";
75
+ export type { DropdownMenuProps, DropdownMenuItem, DropdownMenuAction, DropdownMenuSeparator, DropdownMenuLabel } from "./molecules/dropdown-menu";
76
+ export { default as FormField } from "./molecules/form-field";
77
+ export type { FormFieldProps, FormFieldControlProps } from "./molecules/form-field";
78
+ export { default as Select } from "./molecules/select";
79
+ export type { SelectProps, SelectOption, SelectSize } from "./molecules/select";
80
+ export { default as SearchInput } from "./molecules/search-input";
81
+ export type { SearchInputProps } from "./molecules/search-input";
82
+ export { default as NumberStepper } from "./molecules/number-stepper";
83
+ export type { NumberStepperProps, NumberStepperSize } from "./molecules/number-stepper";
84
+ export { default as SegmentedControl, ButtonGroup } from "./molecules/segmented-control";
85
+ export type { SegmentedControlProps, SegmentedControlOption, SegmentedControlSize, ButtonGroupProps, ButtonGroupOrientation } from "./molecules/segmented-control";
86
+ export { default as Rating } from "./molecules/rating";
87
+ export type { RatingProps, RatingSize } from "./molecules/rating";
88
+ export { default as Editor } from "./organisms/editor";
89
+ export type { EditorProps } from "./organisms/editor";
90
+ export { default as Presenter } from "./organisms/presenter";
91
+ export type { PresenterProps, PresenterSlide } from "./organisms/presenter";
92
+ export { default as Slider } from "./organisms/slider";
93
+ export type { SliderProps, SliderImage, SliderLabels } from "./organisms/slider";
94
+ export { default as Table } from "./organisms/table";
95
+ export type { TableProps, TableRow, TablePagination } from "./organisms/table";
96
+ export { default as Terminal } from "./organisms/terminal";
97
+ export type { TerminalProps } from "./organisms/terminal";
98
+ export { default as Header } from "./organisms/header";
99
+ export type { HeaderProps, HeaderLink, HeaderLabels } from "./organisms/header";
100
+ export { default as Sidebar } from "./organisms/sidebar";
101
+ export type { SidebarProps, SidebarItem, SidebarLabels } from "./organisms/sidebar";
102
+ export { default as Wizard } from "./organisms/wizard";
103
+ export type { WizardProps, WizardStep, WizardLabels } from "./organisms/wizard";
104
+ export { default as Modal } from "./organisms/modal";
105
+ export type { ModalProps, ModalSize } from "./organisms/modal";
106
+ export { default as Drawer } from "./organisms/drawer";
107
+ export type { DrawerProps, DrawerSide, DrawerSize } from "./organisms/drawer";
108
+ export { default as ToastProvider, Toast, useToast } from "./organisms/toast";
109
+ export type { ToastProps, ToastOptions, ToastVariant, ToastPlacement, ToastAction, ToastApi, ToastProviderProps } from "./organisms/toast";
110
+ export { default as Form, useForm, Field, FormActions } from "./organisms/form";
111
+ export type { FormProps, FieldProps, FormActionsProps, FormActionsAlign, FieldRules, FieldLengthRule, FieldRenderProps, FormApi, FormErrors, FormSubmitHelpers, FormTouched, FormValidateOn, FormValues } from "./organisms/form";
112
+ export { default as Combobox } from "./organisms/combobox";
113
+ export type { ComboboxProps, ComboboxSingleProps, ComboboxMultipleProps, ComboboxBaseProps, ComboboxOption, ComboboxFilter, ComboboxSize } from "./organisms/combobox";
114
+ export { default as DatePicker, Calendar } from "./organisms/date-picker";
115
+ export type { DatePickerProps, CalendarProps, WeekStart } from "./organisms/date-picker";
116
+ export { default as CommandPalette, scoreCommand } from "./organisms/command-palette";
117
+ export type { CommandPaletteProps, CommandPaletteCommand, ScorableCommand } from "./organisms/command-palette";
118
+ export { default as Portal } from "./utils/portal";
119
+ export type { PortalProps } from "./utils/portal";
120
+ export { default as ThemeProvider, useTheme } from "./utils/theme-provider";
121
+ export type { Theme, ThemeContextValue, ThemeProviderProps } from "./utils/theme-provider";
122
+ export { useControllableState, useClickOutside, useFocusTrap, getFocusable } from "./hooks";
@@ -0,0 +1,74 @@
1
+ import Button from "./atoms/button/index.js";
2
+ import Icon from "./atoms/icon/index.js";
3
+ import CodeHighlighter from "./atoms/code-highlighter/index.js";
4
+ import VideoPlayer from "./atoms/video-player/index.js";
5
+ import Spinner from "./atoms/spinner/index.js";
6
+ import Badge from "./atoms/badge/index.js";
7
+ import Avatar, { getInitials } from "./atoms/avatar/index.js";
8
+ import Link from "./atoms/link/index.js";
9
+ import Text, { Heading } from "./atoms/typography/index.js";
10
+ import Skeleton from "./atoms/skeleton/index.js";
11
+ import ProgressBar from "./atoms/progress-bar/index.js";
12
+ import Divider from "./atoms/divider/index.js";
13
+ import Label from "./atoms/label/index.js";
14
+ import TextInput from "./atoms/text-input/index.js";
15
+ import Textarea from "./atoms/textarea/index.js";
16
+ import Checkbox from "./atoms/checkbox/index.js";
17
+ import Radio from "./atoms/radio/index.js";
18
+ import Switch from "./atoms/switch/index.js";
19
+ import VisuallyHidden from "./atoms/visually-hidden/index.js";
20
+ import { RadioGroup } from "./atoms/radio/radio-group.js";
21
+ import Kbd from "./atoms/kbd/index.js";
22
+ import BinaryClock from "./molecules/binary-clock/index.js";
23
+ import Chart from "./molecules/chart/index.js";
24
+ import ConflictResolver from "./molecules/conflict-resolver/index.js";
25
+ import DropableList from "./molecules/dropable-list/index.js";
26
+ import FileInput from "./molecules/file-input/index.js";
27
+ import List from "./molecules/list/index.js";
28
+ import Draggable from "./molecules/dropable-list/draggable.js";
29
+ import TagCloud from "./molecules/tag-cloud/index.js";
30
+ import VirtualizedList from "./molecules/virtualized-list/lista/index.js";
31
+ import SlowList from "./molecules/virtualized-list/lista-slow/index.js";
32
+ import Tabs from "./molecules/tabs/index.js";
33
+ import Pagination, { getPageItems } from "./molecules/pagination/index.js";
34
+ import Card, { CardBody, CardFooter, CardHeader, CardMedia } from "./molecules/card/index.js";
35
+ import Breadcrumb from "./molecules/breadcrumb/index.js";
36
+ import Accordion from "./molecules/accordion/index.js";
37
+ import EmptyState from "./molecules/empty-state/index.js";
38
+ import Alert from "./molecules/alert/index.js";
39
+ import Popover from "./molecules/popover/index.js";
40
+ import Tooltip from "./molecules/tooltip/index.js";
41
+ import DropdownMenu from "./molecules/dropdown-menu/index.js";
42
+ import FormField from "./molecules/form-field/index.js";
43
+ import { computePosition } from "./molecules/popover/positioning.js";
44
+ import Select from "./molecules/select/index.js";
45
+ import SearchInput from "./molecules/search-input/index.js";
46
+ import NumberStepper from "./molecules/number-stepper/index.js";
47
+ import SegmentedControl from "./molecules/segmented-control/index.js";
48
+ import Rating from "./molecules/rating/index.js";
49
+ import Editor from "./organisms/editor/index.js";
50
+ import Presenter from "./organisms/presenter/index.js";
51
+ import { ButtonGroup } from "./molecules/segmented-control/button-group.js";
52
+ import Slider from "./organisms/slider/index.js";
53
+ import Table from "./organisms/table/index.js";
54
+ import Terminal from "./organisms/terminal/index.js";
55
+ import Header from "./organisms/header/index.js";
56
+ import Sidebar from "./organisms/sidebar/index.js";
57
+ import Wizard from "./organisms/wizard/index.js";
58
+ import Modal from "./organisms/modal/index.js";
59
+ import Drawer from "./organisms/drawer/index.js";
60
+ import ToastProvider, { Toast, useToast } from "./organisms/toast/index.js";
61
+ import Form, { useForm } from "./organisms/form/index.js";
62
+ import Combobox from "./organisms/combobox/index.js";
63
+ import DatePicker from "./organisms/date-picker/index.js";
64
+ import CommandPalette from "./organisms/command-palette/index.js";
65
+ import Portal from "./utils/portal/index.js";
66
+ import { Field } from "./organisms/form/field.js";
67
+ import { FormActions } from "./organisms/form/form-actions.js";
68
+ import ThemeProvider, { useTheme } from "./utils/theme-provider/index.js";
69
+ import { useControllableState } from "./hooks/use-controllable-state.js";
70
+ import Calendar from "./organisms/date-picker/calendar.js";
71
+ import { useClickOutside } from "./hooks/use-click-outside.js";
72
+ import { scoreCommand } from "./organisms/command-palette/score.js";
73
+ import { getFocusable, useFocusTrap } from "./hooks/use-focus-trap.js";
74
+ export { Accordion, Alert, Avatar, Badge, BinaryClock, Breadcrumb, Button, ButtonGroup, Calendar, Card, CardBody, CardFooter, CardHeader, CardMedia, Chart, Checkbox, CodeHighlighter, Combobox, CommandPalette, ConflictResolver, DatePicker, Divider, Draggable, Drawer, DropableList, DropdownMenu, Editor, EmptyState, Field, FileInput, Form, FormActions, FormField, Header, Heading, Icon, Kbd, Label, Link, List, Modal, NumberStepper, Pagination, Popover, Portal, Presenter, ProgressBar, Radio, RadioGroup, Rating, SearchInput, SegmentedControl, Select, Sidebar, Skeleton, Slider, SlowList, Spinner, Switch, Table, Tabs, TagCloud, Terminal, Text, TextInput, Textarea, ThemeProvider, Toast, ToastProvider, Tooltip, VideoPlayer, VirtualizedList, VisuallyHidden, Wizard, computePosition, getFocusable, getInitials, getPageItems, scoreCommand, useClickOutside, useControllableState, useFocusTrap, useForm, useTheme, useToast };
@@ -0,0 +1,27 @@
1
+ import { type HTMLAttributes, type ReactNode } from "react";
2
+ export interface AccordionItem {
3
+ /** Unique id of the section, used in `value` */
4
+ id: string;
5
+ /** Header text or content */
6
+ title: ReactNode;
7
+ /** Panel content */
8
+ content: ReactNode;
9
+ /** The section cannot be toggled */
10
+ disabled?: boolean;
11
+ }
12
+ export interface AccordionProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange" | "defaultValue"> {
13
+ /** Sections to render, in order */
14
+ items: AccordionItem[];
15
+ /** Allow several sections open at once. Default false */
16
+ multiple?: boolean;
17
+ /** Ids of the open sections, controlled */
18
+ value?: string[];
19
+ /** Ids of the initially open sections, uncontrolled. Default [] */
20
+ defaultValue?: string[];
21
+ /** Called with the ids of the open sections */
22
+ onChange?: (value: string[]) => void;
23
+ /** Heading level wrapping each header button. Default 3 */
24
+ headingLevel?: 2 | 3 | 4 | 5 | 6;
25
+ }
26
+ declare function Accordion({ items, multiple, value, defaultValue, onChange, headingLevel, className, ...rest }: AccordionProps): import("react").JSX.Element;
27
+ export default Accordion;
@@ -0,0 +1,98 @@
1
+ import { useId, useRef } from "react";
2
+ import { useControllableState } from "../../hooks/use-controllable-state.js";
3
+ import { cx } from "../../utils/cx.js";
4
+ import './styles.css';/* empty css */
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/components/molecules/accordion/index.tsx
7
+ var EMPTY = [];
8
+ function Accordion({ items, multiple = false, value, defaultValue = EMPTY, onChange, headingLevel = 3, className, ...rest }) {
9
+ const baseId = useId();
10
+ const [open, setOpen] = useControllableState(value, defaultValue, onChange);
11
+ const buttonRefs = useRef(/* @__PURE__ */ new Map());
12
+ const toggle = (id) => {
13
+ if (open.includes(id)) setOpen(open.filter((v) => v !== id));
14
+ else setOpen(multiple ? [...open, id] : [id]);
15
+ };
16
+ const onKeyDown = (event, id) => {
17
+ const enabled = items.filter((item) => !item.disabled);
18
+ const index = enabled.findIndex((item) => item.id === id);
19
+ let target;
20
+ switch (event.key) {
21
+ case "ArrowDown":
22
+ target = enabled[(index + 1) % enabled.length];
23
+ break;
24
+ case "ArrowUp":
25
+ target = enabled[(index - 1 + enabled.length) % enabled.length];
26
+ break;
27
+ case "Home":
28
+ target = enabled[0];
29
+ break;
30
+ case "End":
31
+ target = enabled[enabled.length - 1];
32
+ break;
33
+ default: return;
34
+ }
35
+ event.preventDefault();
36
+ if (target) buttonRefs.current.get(target.id)?.focus();
37
+ };
38
+ const Heading = `h${headingLevel}`;
39
+ return /* @__PURE__ */ jsx("div", {
40
+ className: cx("ds-accordion", className),
41
+ ...rest,
42
+ children: items.map((item) => {
43
+ const isOpen = open.includes(item.id);
44
+ const buttonId = `${baseId}-header-${item.id}`;
45
+ const panelId = `${baseId}-panel-${item.id}`;
46
+ return /* @__PURE__ */ jsxs("div", {
47
+ className: cx("ds-accordion__item", isOpen && "ds-accordion__item--open"),
48
+ children: [/* @__PURE__ */ jsx(Heading, {
49
+ className: "ds-accordion__heading",
50
+ children: /* @__PURE__ */ jsxs("button", {
51
+ ref: (el) => {
52
+ if (el) buttonRefs.current.set(item.id, el);
53
+ else buttonRefs.current.delete(item.id);
54
+ },
55
+ type: "button",
56
+ id: buttonId,
57
+ className: "ds-accordion__trigger",
58
+ "aria-expanded": isOpen,
59
+ "aria-controls": panelId,
60
+ disabled: item.disabled,
61
+ onClick: () => toggle(item.id),
62
+ onKeyDown: (event) => onKeyDown(event, item.id),
63
+ children: [/* @__PURE__ */ jsx("span", {
64
+ className: "ds-accordion__title",
65
+ children: item.title
66
+ }), /* @__PURE__ */ jsx("svg", {
67
+ className: "ds-accordion__chevron",
68
+ viewBox: "0 0 16 16",
69
+ "aria-hidden": "true",
70
+ focusable: "false",
71
+ children: /* @__PURE__ */ jsx("path", {
72
+ d: "M4 6l4 4 4-4",
73
+ fill: "none",
74
+ stroke: "currentColor",
75
+ strokeWidth: "1.5",
76
+ strokeLinecap: "round",
77
+ strokeLinejoin: "round"
78
+ })
79
+ })]
80
+ })
81
+ }), /* @__PURE__ */ jsx("div", {
82
+ id: panelId,
83
+ role: "region",
84
+ "aria-labelledby": buttonId,
85
+ className: "ds-accordion__panel",
86
+ hidden: !isOpen,
87
+ children: /* @__PURE__ */ jsx("div", {
88
+ className: "ds-accordion__content",
89
+ children: item.content
90
+ })
91
+ })]
92
+ }, item.id);
93
+ })
94
+ });
95
+ }
96
+ export { Accordion as default };
97
+
98
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_jsx","_jsxs"],"sources":["../../../../src/components/molecules/accordion/index.tsx"],"sourcesContent":["import { useId, useRef, type HTMLAttributes, type KeyboardEvent, type ReactNode } from \"react\";\nimport { useControllableState } from \"../../hooks\";\nimport { cx } from \"../../utils/cx\";\nimport \"./styles.css\";\n\nexport interface AccordionItem {\n /** Unique id of the section, used in `value` */\n id: string;\n /** Header text or content */\n title: ReactNode;\n /** Panel content */\n content: ReactNode;\n /** The section cannot be toggled */\n disabled?: boolean;\n}\n\nexport interface AccordionProps extends Omit<HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\"> {\n /** Sections to render, in order */\n items: AccordionItem[];\n /** Allow several sections open at once. Default false */\n multiple?: boolean;\n /** Ids of the open sections, controlled */\n value?: string[];\n /** Ids of the initially open sections, uncontrolled. Default [] */\n defaultValue?: string[];\n /** Called with the ids of the open sections */\n onChange?: (value: string[]) => void;\n /** Heading level wrapping each header button. Default 3 */\n headingLevel?: 2 | 3 | 4 | 5 | 6;\n}\n\nconst EMPTY: string[] = [];\n\nfunction Accordion({\n items,\n multiple = false,\n value,\n defaultValue = EMPTY,\n onChange,\n headingLevel = 3,\n className,\n ...rest\n}: AccordionProps) {\n const baseId = useId();\n const [open, setOpen] = useControllableState<string[]>(value, defaultValue, onChange);\n const buttonRefs = useRef<Map<string, HTMLButtonElement>>(new Map());\n\n const toggle = (id: string) => {\n if (open.includes(id)) setOpen(open.filter((v) => v !== id));\n else setOpen(multiple ? [...open, id] : [id]);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>, id: string) => {\n const enabled = items.filter((item) => !item.disabled);\n const index = enabled.findIndex((item) => item.id === id);\n let target: AccordionItem | undefined;\n switch (event.key) {\n case \"ArrowDown\":\n target = enabled[(index + 1) % enabled.length];\n break;\n case \"ArrowUp\":\n target = enabled[(index - 1 + enabled.length) % enabled.length];\n break;\n case \"Home\":\n target = enabled[0];\n break;\n case \"End\":\n target = enabled[enabled.length - 1];\n break;\n default:\n return;\n }\n event.preventDefault();\n if (target) buttonRefs.current.get(target.id)?.focus();\n };\n\n const Heading = `h${headingLevel}` as const;\n\n return (\n <div className={cx(\"ds-accordion\", className)} {...rest}>\n {items.map((item) => {\n const isOpen = open.includes(item.id);\n const buttonId = `${baseId}-header-${item.id}`;\n const panelId = `${baseId}-panel-${item.id}`;\n return (\n <div key={item.id} className={cx(\"ds-accordion__item\", isOpen && \"ds-accordion__item--open\")}>\n <Heading className=\"ds-accordion__heading\">\n <button\n ref={(el) => {\n if (el) buttonRefs.current.set(item.id, el);\n else buttonRefs.current.delete(item.id);\n }}\n type=\"button\"\n id={buttonId}\n className=\"ds-accordion__trigger\"\n aria-expanded={isOpen}\n aria-controls={panelId}\n disabled={item.disabled}\n onClick={() => toggle(item.id)}\n onKeyDown={(event) => onKeyDown(event, item.id)}\n >\n <span className=\"ds-accordion__title\">{item.title}</span>\n <svg className=\"ds-accordion__chevron\" viewBox=\"0 0 16 16\" aria-hidden=\"true\" focusable=\"false\">\n <path d=\"M4 6l4 4 4-4\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n </button>\n </Heading>\n <div\n id={panelId}\n role=\"region\"\n aria-labelledby={buttonId}\n className=\"ds-accordion__panel\"\n hidden={!isOpen}\n >\n <div className=\"ds-accordion__content\">{item.content}</div>\n </div>\n </div>\n );\n })}\n </div>\n );\n}\n\nexport default Accordion;\n"],"mappings":";;;;;;AA+BA,IAAM,QAAkB,CAAC;AAEzB,SAAS,UAAU,EACjB,OACA,WAAW,OACX,OACA,eAAe,OACf,UACA,eAAe,GACf,WACA,GAAG,QACc;CACjB,MAAM,SAAS,MAAM;CACrB,MAAM,CAAC,MAAM,WAAW,qBAA+B,OAAO,cAAc,QAAQ;CACpF,MAAM,aAAa,uBAAuC,IAAI,IAAI,CAAC;CAEnE,MAAM,UAAU,OAAe;EAC7B,IAAI,KAAK,SAAS,EAAE,GAAG,QAAQ,KAAK,QAAQ,MAAM,MAAM,EAAE,CAAC;OACtD,QAAQ,WAAW,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;CAC9C;CAEA,MAAM,aAAa,OAAyC,OAAe;EACzE,MAAM,UAAU,MAAM,QAAQ,SAAS,CAAC,KAAK,QAAQ;EACrD,MAAM,QAAQ,QAAQ,WAAW,SAAS,KAAK,OAAO,EAAE;EACxD,IAAI;EACJ,QAAQ,MAAM,KAAd;GACE,KAAK;IACH,SAAS,SAAS,QAAQ,KAAK,QAAQ;IACvC;GACF,KAAK;IACH,SAAS,SAAS,QAAQ,IAAI,QAAQ,UAAU,QAAQ;IACxD;GACF,KAAK;IACH,SAAS,QAAQ;IACjB;GACF,KAAK;IACH,SAAS,QAAQ,QAAQ,SAAS;IAClC;GACF,SACE;EACJ;EACA,MAAM,eAAe;EACrB,IAAI,QAAQ,WAAW,QAAQ,IAAI,OAAO,EAAE,CAAC,EAAE,MAAM;CACvD;CAEA,MAAM,UAAU,IAAI;CAEpB,OACEA,oBAAC,OAAD;EAAK,WAAW,GAAG,gBAAgB,SAAS;EAAG,GAAI;EAChD,UAAA,MAAM,KAAK,SAAS;GACnB,MAAM,SAAS,KAAK,SAAS,KAAK,EAAE;GACpC,MAAM,WAAW,GAAG,OAAO,UAAU,KAAK;GAC1C,MAAM,UAAU,GAAG,OAAO,SAAS,KAAK;GACxC,OACEC,qBAAC,OAAD;IAAmB,WAAW,GAAG,sBAAsB,UAAU,0BAA0B;IAA3F,UAAA,CACED,oBAAC,SAAD;KAAS,WAAU;KACjB,UAAAC,qBAAC,UAAD;MACE,MAAM,OAAO;OACX,IAAI,IAAI,WAAW,QAAQ,IAAI,KAAK,IAAI,EAAE;YACrC,WAAW,QAAQ,OAAO,KAAK,EAAE;MACxC;MACA,MAAK;MACL,IAAI;MACJ,WAAU;MACV,iBAAe;MACf,iBAAe;MACf,UAAU,KAAK;MACf,eAAe,OAAO,KAAK,EAAE;MAC7B,YAAY,UAAU,UAAU,OAAO,KAAK,EAAE;MAZhD,UAAA,CAcED,oBAAC,QAAD;OAAM,WAAU;OAAuB,UAAA,KAAK;MAAY,CAAA,GACxDA,oBAAC,OAAD;OAAK,WAAU;OAAwB,SAAQ;OAAY,eAAY;OAAO,WAAU;OACtF,UAAAA,oBAAC,QAAD;QAAM,GAAE;QAAe,MAAK;QAAO,QAAO;QAAe,aAAY;QAAM,eAAc;QAAQ,gBAAe;OAAS,CAAA;MACtH,CAAA,CACC;;IACD,CAAA,GACTA,oBAAC,OAAD;KACE,IAAI;KACJ,MAAK;KACL,mBAAiB;KACjB,WAAU;KACV,QAAQ,CAAC;KAET,UAAAA,oBAAC,OAAD;MAAK,WAAU;MAAyB,UAAA,KAAK;KAAa,CAAA;IACvD,CAAA,CACF;GA/BK,GAAA,KAAK,EA+BV;EAET,CAAC;CACE,CAAA;AAET"}
@@ -0,0 +1,75 @@
1
+ .ds-accordion {
2
+ border: var(--border-width-1) solid var(--color-border);
3
+ border-radius: var(--radius-lg);
4
+ background: var(--color-surface);
5
+ color: var(--color-text);
6
+ font-family: var(--font-sans);
7
+ overflow: hidden;
8
+ }
9
+
10
+ .ds-accordion__item + .ds-accordion__item {
11
+ border-top: var(--border-width-1) solid var(--color-border);
12
+ }
13
+
14
+ .ds-accordion__heading {
15
+ margin: 0;
16
+ font-size: inherit;
17
+ font-weight: inherit;
18
+ }
19
+
20
+ .ds-accordion__trigger {
21
+ display: flex;
22
+ align-items: center;
23
+ justify-content: space-between;
24
+ gap: var(--space-3);
25
+ width: 100%;
26
+ padding: var(--space-3) var(--space-4);
27
+ border: 0;
28
+ background: transparent;
29
+ color: var(--color-text);
30
+ font-family: inherit;
31
+ font-size: var(--font-size-sm);
32
+ font-weight: var(--font-weight-medium);
33
+ text-align: left;
34
+ cursor: pointer;
35
+ transition: background-color var(--duration-fast) var(--easing-standard);
36
+ }
37
+
38
+ .ds-accordion__trigger:hover:not(:disabled) {
39
+ background: var(--color-neutral);
40
+ }
41
+
42
+ .ds-accordion__trigger:disabled {
43
+ color: var(--color-text-disabled);
44
+ cursor: not-allowed;
45
+ }
46
+
47
+ .ds-accordion__trigger:focus-visible {
48
+ outline: var(--border-width-2) solid var(--color-focus-ring);
49
+ outline-offset: -2px;
50
+ }
51
+
52
+ .ds-accordion__chevron {
53
+ flex-shrink: 0;
54
+ width: var(--icon-size-sm);
55
+ height: var(--icon-size-sm);
56
+ color: var(--color-text-muted);
57
+ transition: transform var(--duration-normal) var(--easing-standard);
58
+ }
59
+
60
+ .ds-accordion__item--open .ds-accordion__chevron {
61
+ transform: rotate(180deg);
62
+ }
63
+
64
+ .ds-accordion__content {
65
+ padding: 0 var(--space-4) var(--space-4);
66
+ color: var(--color-text-muted);
67
+ font-size: var(--font-size-sm);
68
+ line-height: var(--line-height-normal);
69
+ }
70
+
71
+ @media (prefers-reduced-motion: reduce) {
72
+ .ds-accordion__chevron {
73
+ transition: none;
74
+ }
75
+ }
@@ -0,0 +1,18 @@
1
+ import type { HTMLAttributes, ReactNode } from "react";
2
+ export type AlertVariant = "info" | "success" | "warning" | "danger";
3
+ export interface AlertProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
4
+ /** Tone of the message. "warning" and "danger" use role="alert", the rest role="status". Default "info" */
5
+ variant?: AlertVariant;
6
+ /** Bold heading of the message */
7
+ title?: ReactNode;
8
+ /** Icon shown on the left. Default: a built-in icon per variant. Pass `null` to hide it */
9
+ icon?: ReactNode;
10
+ /** Renders a close button that calls this handler */
11
+ onClose?: () => void;
12
+ /** Accessible label of the close button. Default "Close" */
13
+ closeLabel?: string;
14
+ /** Slot for actions, e.g. a Button, shown under the message */
15
+ action?: ReactNode;
16
+ }
17
+ declare function Alert({ variant, title, icon, onClose, closeLabel, action, className, children, ...rest }: AlertProps): import("react").JSX.Element;
18
+ export default Alert;
@@ -0,0 +1,91 @@
1
+ import { cx } from "../../utils/cx.js";
2
+ import './styles.css';/* empty css */
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ // src/components/molecules/alert/index.tsx
5
+ var svgProps = {
6
+ viewBox: "0 0 20 20",
7
+ fill: "none",
8
+ stroke: "currentColor",
9
+ strokeWidth: 1.6,
10
+ strokeLinecap: "round",
11
+ strokeLinejoin: "round",
12
+ "aria-hidden": true,
13
+ focusable: false
14
+ };
15
+ var icons = {
16
+ info: /* @__PURE__ */ jsxs("svg", {
17
+ ...svgProps,
18
+ children: [/* @__PURE__ */ jsx("circle", {
19
+ cx: "10",
20
+ cy: "10",
21
+ r: "7.5"
22
+ }), /* @__PURE__ */ jsx("path", { d: "M10 9v5M10 6.5v.01" })]
23
+ }),
24
+ success: /* @__PURE__ */ jsxs("svg", {
25
+ ...svgProps,
26
+ children: [/* @__PURE__ */ jsx("circle", {
27
+ cx: "10",
28
+ cy: "10",
29
+ r: "7.5"
30
+ }), /* @__PURE__ */ jsx("path", { d: "M6.5 10.25l2.25 2.25 4.75-4.75" })]
31
+ }),
32
+ warning: /* @__PURE__ */ jsxs("svg", {
33
+ ...svgProps,
34
+ children: [/* @__PURE__ */ jsx("path", { d: "M10 2.75l7.5 13.5h-15z" }), /* @__PURE__ */ jsx("path", { d: "M10 8v3.5M10 14v.01" })]
35
+ }),
36
+ danger: /* @__PURE__ */ jsxs("svg", {
37
+ ...svgProps,
38
+ children: [/* @__PURE__ */ jsx("circle", {
39
+ cx: "10",
40
+ cy: "10",
41
+ r: "7.5"
42
+ }), /* @__PURE__ */ jsx("path", { d: "M7.5 7.5l5 5M12.5 7.5l-5 5" })]
43
+ })
44
+ };
45
+ function Alert({ variant = "info", title, icon, onClose, closeLabel = "Close", action, className, children, ...rest }) {
46
+ const role = variant === "danger" || variant === "warning" ? "alert" : "status";
47
+ const shownIcon = icon === void 0 ? icons[variant] : icon;
48
+ return /* @__PURE__ */ jsxs("div", {
49
+ role,
50
+ className: cx("ds-alert", `ds-alert--${variant}`, className),
51
+ ...rest,
52
+ children: [
53
+ shownIcon != null && shownIcon !== false && /* @__PURE__ */ jsx("span", {
54
+ className: "ds-alert__icon",
55
+ "aria-hidden": "true",
56
+ children: shownIcon
57
+ }),
58
+ /* @__PURE__ */ jsxs("div", {
59
+ className: "ds-alert__body",
60
+ children: [
61
+ title != null && /* @__PURE__ */ jsx("div", {
62
+ className: "ds-alert__title",
63
+ children: title
64
+ }),
65
+ children != null && /* @__PURE__ */ jsx("div", {
66
+ className: "ds-alert__message",
67
+ children
68
+ }),
69
+ action != null && /* @__PURE__ */ jsx("div", {
70
+ className: "ds-alert__action",
71
+ children: action
72
+ })
73
+ ]
74
+ }),
75
+ onClose && /* @__PURE__ */ jsx("button", {
76
+ type: "button",
77
+ className: "ds-alert__close",
78
+ "aria-label": closeLabel,
79
+ onClick: onClose,
80
+ children: /* @__PURE__ */ jsx("svg", {
81
+ ...svgProps,
82
+ viewBox: "0 0 16 16",
83
+ children: /* @__PURE__ */ jsx("path", { d: "M4 4l8 8M12 4l-8 8" })
84
+ })
85
+ })
86
+ ]
87
+ });
88
+ }
89
+ export { Alert as default };
90
+
91
+ //# sourceMappingURL=index.js.map