@overdoser/react-toolkit 0.20.0 → 0.21.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 (273) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +14 -0
  3. package/components/Accordion/Accordion.js +160 -177
  4. package/components/Accordion/Accordion.module.js +20 -0
  5. package/components/ActionButton/ActionButton.js +155 -209
  6. package/components/ActionButton/ActionButton.module.js +25 -0
  7. package/components/ActionButton/CopyButton.js +52 -64
  8. package/components/Alert/Alert.js +92 -95
  9. package/components/Alert/Alert.module.js +18 -0
  10. package/components/Avatar/Avatar.js +44 -55
  11. package/components/Avatar/Avatar.module.js +23 -0
  12. package/components/Badge/Badge.js +16 -38
  13. package/components/Badge/Badge.module.js +17 -0
  14. package/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  15. package/components/Breadcrumbs/Breadcrumbs.js +52 -48
  16. package/components/Breadcrumbs/Breadcrumbs.module.js +10 -0
  17. package/components/Button/Button.js +35 -57
  18. package/components/Button/Button.module.js +25 -0
  19. package/components/Card/Card.js +94 -131
  20. package/components/Card/Card.module.js +35 -0
  21. package/components/Chart/AreaChart.d.ts +1 -1
  22. package/components/Chart/AreaChart.js +248 -249
  23. package/components/Chart/Axis.d.ts +2 -2
  24. package/components/Chart/Axis.js +34 -43
  25. package/components/Chart/BarChart.d.ts +1 -1
  26. package/components/Chart/BarChart.js +307 -348
  27. package/components/Chart/Chart.module.js +32 -0
  28. package/components/Chart/ChartContainer.js +33 -41
  29. package/components/Chart/ChartLegend.d.ts +1 -1
  30. package/components/Chart/ChartLegend.js +31 -30
  31. package/components/Chart/ChartTooltip.d.ts +1 -1
  32. package/components/Chart/ChartTooltip.js +46 -41
  33. package/components/Chart/LineChart.d.ts +1 -1
  34. package/components/Chart/LineChart.js +220 -232
  35. package/components/Chart/PieChart.d.ts +1 -1
  36. package/components/Chart/PieChart.js +224 -240
  37. package/components/Chart/RadarChart.d.ts +1 -1
  38. package/components/Chart/RadarChart.js +166 -215
  39. package/components/Chart/Sparkline.js +73 -68
  40. package/components/Chart/TradingChart.d.ts +1 -1
  41. package/components/Chart/TradingChart.js +804 -701
  42. package/components/Chart/scales.js +28 -35
  43. package/components/Chart/trading/indicators.js +61 -62
  44. package/components/Chart/trading/period.js +46 -68
  45. package/components/Chart/useChartDimensions.js +30 -22
  46. package/components/Chip/Chip.js +98 -141
  47. package/components/Chip/Chip.module.js +32 -0
  48. package/components/CodeBlock/CodeBlock.js +111 -119
  49. package/components/CodeBlock/CodeBlock.module.js +23 -0
  50. package/components/CommandPalette/CommandPalette.js +387 -392
  51. package/components/CommandPalette/CommandPalette.module.js +28 -0
  52. package/components/ConfirmDialog/ConfirmDialog.d.ts +1 -1
  53. package/components/ConfirmDialog/ConfirmDialog.js +184 -199
  54. package/components/ConfirmDialog/ConfirmDialog.module.js +12 -0
  55. package/components/Divider/Divider.js +25 -36
  56. package/components/Divider/Divider.module.js +17 -0
  57. package/components/Draggable/Draggable.d.ts +1 -1
  58. package/components/Draggable/Draggable.js +157 -164
  59. package/components/Draggable/Draggable.module.js +10 -0
  60. package/components/Drawer/Drawer.js +104 -126
  61. package/components/Drawer/Drawer.module.js +66 -0
  62. package/components/Dropdown/Dropdown.js +175 -234
  63. package/components/Dropdown/Dropdown.module.js +29 -0
  64. package/components/Dropdown/DropdownItem.js +55 -58
  65. package/components/Dropdown/DropdownLabel.js +14 -11
  66. package/components/Dropdown/DropdownSeparator.js +12 -10
  67. package/components/Dropdown/dropdownContext.js +4 -5
  68. package/components/Dropdown/useContextMenu.js +27 -17
  69. package/components/Dropzone/Dropzone.js +99 -105
  70. package/components/Dropzone/Dropzone.module.js +12 -0
  71. package/components/EmptyState/EmptyState.js +58 -55
  72. package/components/EmptyState/EmptyState.module.js +14 -0
  73. package/components/Form/Form.d.ts +1 -1
  74. package/components/Form/Form.js +32 -35
  75. package/components/Form/Form.module.js +16 -0
  76. package/components/Form/FormField.d.ts +1 -1
  77. package/components/Form/FormField.js +71 -75
  78. package/components/Form/FormRow.d.ts +1 -1
  79. package/components/Form/FormRow.js +11 -8
  80. package/components/Form/formFieldDefaults.js +4 -5
  81. package/components/ImageViewer/ImageViewer.js +312 -201
  82. package/components/ImageViewer/ImageViewer.module.js +26 -0
  83. package/components/ImageViewer/useZoomPan.js +206 -137
  84. package/components/Kbd/Kbd.js +25 -22
  85. package/components/Kbd/Kbd.module.js +10 -0
  86. package/components/KeyValueList/KeyValueList.js +119 -123
  87. package/components/KeyValueList/KeyValueList.module.js +23 -0
  88. package/components/Link/Link.js +45 -59
  89. package/components/Link/Link.module.js +10 -0
  90. package/components/List/List.js +22 -46
  91. package/components/List/List.module.js +12 -0
  92. package/components/Loader/Loader.js +152 -182
  93. package/components/Loader/Loader.module.js +40 -0
  94. package/components/Modal/Modal.js +93 -105
  95. package/components/Modal/Modal.module.js +18 -0
  96. package/components/PageHeader/PageHeader.js +78 -72
  97. package/components/PageHeader/PageHeader.module.js +23 -0
  98. package/components/Pagination/Pagination.js +63 -84
  99. package/components/Pagination/Pagination.module.js +13 -0
  100. package/components/Pagination/paginationRange.js +15 -22
  101. package/components/Popover/Popover.js +110 -134
  102. package/components/Popover/Popover.module.js +12 -0
  103. package/components/ProgressBar/ProgressBar.d.ts +15 -1
  104. package/components/ProgressBar/ProgressBar.js +57 -90
  105. package/components/ProgressBar/ProgressBar.module.js +29 -0
  106. package/components/RelativeTime/RelativeTime.js +36 -43
  107. package/components/RelativeTime/RelativeTime.module.js +3 -0
  108. package/components/SegmentedControl/SegmentedControl.js +94 -130
  109. package/components/SegmentedControl/SegmentedControl.module.js +21 -0
  110. package/components/Skeleton/Skeleton.js +36 -50
  111. package/components/Skeleton/Skeleton.module.js +15 -0
  112. package/components/Spinner/Spinner.js +25 -25
  113. package/components/Spinner/Spinner.module.js +12 -0
  114. package/components/SplitButton/SplitButton.js +149 -196
  115. package/components/SplitButton/SplitButton.module.js +31 -0
  116. package/components/SplitPane/SplitPane.js +134 -170
  117. package/components/SplitPane/SplitPane.module.js +14 -0
  118. package/components/StatCard/StatCard.js +132 -125
  119. package/components/StatCard/StatCard.module.js +42 -0
  120. package/components/StatusDot/StatusDot.js +28 -39
  121. package/components/StatusDot/StatusDot.module.js +18 -0
  122. package/components/Table/Table.d.ts +1 -1
  123. package/components/Table/Table.js +381 -451
  124. package/components/Table/Table.module.js +42 -0
  125. package/components/Table/useTableSort.js +51 -42
  126. package/components/Tabs/Tabs.js +109 -161
  127. package/components/Tabs/Tabs.module.js +28 -0
  128. package/components/ThemeToggle/ThemeToggle.js +122 -98
  129. package/components/ThemeToggle/ThemeToggle.module.js +13 -0
  130. package/components/Timeline/GanttTimeline.js +357 -318
  131. package/components/Timeline/GanttTimeline.module.js +29 -0
  132. package/components/Timeline/HistoryTimeline.js +486 -450
  133. package/components/Timeline/HistoryTimeline.module.js +31 -0
  134. package/components/Timeline/Timeline.module.js +76 -0
  135. package/components/Timeline/TimelineShared.d.ts +7 -7
  136. package/components/Timeline/TimelineShared.js +288 -279
  137. package/components/Timeline/TraceEventDetails.d.ts +3 -3
  138. package/components/Timeline/TraceEventDetails.js +245 -178
  139. package/components/Timeline/TraceTimeline.js +823 -783
  140. package/components/Timeline/TraceTimeline.module.js +98 -0
  141. package/components/Timeline/historyLayout.js +336 -263
  142. package/components/Timeline/timelineCore.js +208 -183
  143. package/components/Timeline/traceEvent.js +59 -61
  144. package/components/Timeline/traceLayout.js +101 -90
  145. package/components/Timeline/useTimeline.js +76 -79
  146. package/components/Timer/Timer.js +190 -156
  147. package/components/Timer/Timer.module.js +29 -0
  148. package/components/Toast/Toast.d.ts +1 -1
  149. package/components/Toast/Toast.js +128 -128
  150. package/components/Toast/Toast.module.js +37 -0
  151. package/components/Toast/toastStore.js +58 -62
  152. package/components/ToggleIconButton/ToggleIconButton.js +35 -57
  153. package/components/ToggleIconButton/ToggleIconButton.module.js +15 -0
  154. package/components/Tooltip/Tooltip.d.ts +1 -1
  155. package/components/Tooltip/Tooltip.js +76 -85
  156. package/components/Tooltip/Tooltip.module.js +17 -0
  157. package/components/Typography/Typography.js +11 -36
  158. package/components/Typography/Typography.module.js +30 -0
  159. package/components/inputs/Checkbox/Checkbox.js +27 -51
  160. package/components/inputs/Checkbox/Checkbox.module.js +10 -0
  161. package/components/inputs/Checkbox/CheckboxGroup.js +53 -111
  162. package/components/inputs/Checkbox/CheckboxGroup.module.js +17 -0
  163. package/components/inputs/DatePicker/CalendarPanel.d.ts +1 -1
  164. package/components/inputs/DatePicker/CalendarPanel.js +263 -286
  165. package/components/inputs/DatePicker/CalendarPanel.module.js +23 -0
  166. package/components/inputs/DatePicker/DatePicker.js +115 -142
  167. package/components/inputs/DatePicker/DatePicker.module.js +14 -0
  168. package/components/inputs/DatePicker/dateUtils.js +32 -41
  169. package/components/inputs/DateTimePicker/DateTimePicker.js +226 -232
  170. package/components/inputs/DateTimePicker/DateTimePicker.module.js +20 -0
  171. package/components/inputs/DateTimePicker/DateTimeSegments.js +273 -252
  172. package/components/inputs/DateTimePicker/TimeField.d.ts +1 -1
  173. package/components/inputs/DateTimePicker/TimeField.js +131 -132
  174. package/components/inputs/DateTimePicker/timeZoneUtils.js +95 -92
  175. package/components/inputs/Input/Input.js +98 -109
  176. package/components/inputs/Input/Input.module.js +15 -0
  177. package/components/inputs/NumberInput/NumberInput.js +112 -132
  178. package/components/inputs/NumberInput/NumberInput.module.js +14 -0
  179. package/components/inputs/Radio/Radio.js +50 -73
  180. package/components/inputs/Radio/Radio.module.js +9 -0
  181. package/components/inputs/SearchInput/SearchInput.js +98 -115
  182. package/components/inputs/SearchInput/SearchInput.module.js +8 -0
  183. package/components/inputs/Select/Select.js +555 -682
  184. package/components/inputs/Select/Select.module.js +38 -0
  185. package/components/inputs/Slider/Slider.js +97 -128
  186. package/components/inputs/Slider/Slider.module.js +9 -0
  187. package/components/inputs/Switch/Switch.js +11 -8
  188. package/components/inputs/Textarea/Textarea.js +42 -58
  189. package/components/inputs/Textarea/Textarea.module.js +14 -0
  190. package/hooks/useClickOutside.js +17 -14
  191. package/hooks/useDebouncedValue.js +13 -14
  192. package/hooks/useElementSize.js +27 -22
  193. package/hooks/useEscapeLayer.js +28 -29
  194. package/hooks/useFocusTrap.js +27 -38
  195. package/hooks/useKeyboard.js +76 -64
  196. package/hooks/useMediaQuery.js +10 -15
  197. package/hooks/useNow.js +28 -33
  198. package/hooks/usePersistedState.js +98 -94
  199. package/hooks/usePortalPosition.js +25 -19
  200. package/hooks/useResizable.js +106 -104
  201. package/hooks/useTheme.js +28 -23
  202. package/index.css +2 -1
  203. package/index.js +97 -215
  204. package/index.layered.css +2 -3
  205. package/llms.txt +3 -0
  206. package/manifest.json +8 -0
  207. package/package.json +1 -1
  208. package/utils/formatBytes.js +29 -13
  209. package/utils/themeScript.js +6 -8
  210. package/utils/timeAgo.js +59 -32
  211. package/components/Accordion/Accordion.module.scss.js +0 -36
  212. package/components/ActionButton/ActionButton.module.scss.js +0 -47
  213. package/components/Alert/Alert.module.scss.js +0 -33
  214. package/components/Avatar/Avatar.module.scss.js +0 -43
  215. package/components/Badge/Badge.module.scss.js +0 -31
  216. package/components/Breadcrumbs/Breadcrumbs.module.scss.js +0 -17
  217. package/components/Button/Button.module.scss.js +0 -47
  218. package/components/Card/Card.module.scss.js +0 -60
  219. package/components/Chart/Chart.module.scss.js +0 -61
  220. package/components/Chip/Chip.module.scss.js +0 -59
  221. package/components/CodeBlock/CodeBlock.module.scss.js +0 -43
  222. package/components/CommandPalette/CommandPalette.module.scss.js +0 -49
  223. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +0 -21
  224. package/components/Divider/Divider.module.scss.js +0 -31
  225. package/components/Draggable/Draggable.module.scss.js +0 -17
  226. package/components/Drawer/Drawer.module.scss.js +0 -119
  227. package/components/Dropdown/Dropdown.module.scss.js +0 -53
  228. package/components/Dropzone/Dropzone.module.scss.js +0 -21
  229. package/components/EmptyState/EmptyState.module.scss.js +0 -25
  230. package/components/Form/Form.module.scss.js +0 -29
  231. package/components/ImageViewer/ImageViewer.module.scss.js +0 -47
  232. package/components/Kbd/Kbd.module.scss.js +0 -17
  233. package/components/KeyValueList/KeyValueList.module.scss.js +0 -43
  234. package/components/Link/Link.module.scss.js +0 -16
  235. package/components/List/List.module.scss.js +0 -21
  236. package/components/Loader/Loader.module.scss.js +0 -70
  237. package/components/Modal/Modal.module.scss.js +0 -33
  238. package/components/PageHeader/PageHeader.module.scss.js +0 -43
  239. package/components/Pagination/Pagination.module.scss.js +0 -23
  240. package/components/Popover/Popover.module.scss.js +0 -21
  241. package/components/ProgressBar/ProgressBar.module.scss.js +0 -51
  242. package/components/RelativeTime/RelativeTime.module.scss.js +0 -7
  243. package/components/SegmentedControl/SegmentedControl.module.scss.js +0 -39
  244. package/components/Skeleton/Skeleton.module.scss.js +0 -25
  245. package/components/Spinner/Spinner.module.scss.js +0 -20
  246. package/components/SplitButton/SplitButton.module.scss.js +0 -57
  247. package/components/SplitPane/SplitPane.module.scss.js +0 -25
  248. package/components/StatCard/StatCard.module.scss.js +0 -72
  249. package/components/StatusDot/StatusDot.module.scss.js +0 -32
  250. package/components/Table/Table.module.scss.js +0 -81
  251. package/components/Tabs/Tabs.module.scss.js +0 -53
  252. package/components/ThemeToggle/ThemeToggle.module.scss.js +0 -23
  253. package/components/Timeline/GanttTimeline.module.scss.js +0 -55
  254. package/components/Timeline/HistoryTimeline.module.scss.js +0 -59
  255. package/components/Timeline/Timeline.module.scss.js +0 -141
  256. package/components/Timeline/TraceTimeline.module.scss.js +0 -189
  257. package/components/Timer/Timer.module.scss.js +0 -55
  258. package/components/Toast/Toast.module.scss.js +0 -62
  259. package/components/ToggleIconButton/ToggleIconButton.module.scss.js +0 -27
  260. package/components/Tooltip/Tooltip.module.scss.js +0 -30
  261. package/components/Typography/Typography.module.scss.js +0 -53
  262. package/components/inputs/Checkbox/Checkbox.module.scss.js +0 -17
  263. package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +0 -31
  264. package/components/inputs/DatePicker/CalendarPanel.module.scss.js +0 -41
  265. package/components/inputs/DatePicker/DatePicker.module.scss.js +0 -25
  266. package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +0 -37
  267. package/components/inputs/Input/Input.module.scss.js +0 -27
  268. package/components/inputs/NumberInput/NumberInput.module.scss.js +0 -25
  269. package/components/inputs/Radio/Radio.module.scss.js +0 -15
  270. package/components/inputs/SearchInput/SearchInput.module.scss.js +0 -13
  271. package/components/inputs/Select/Select.module.scss.js +0 -73
  272. package/components/inputs/Slider/Slider.module.scss.js +0 -15
  273. package/components/inputs/Textarea/Textarea.module.scss.js +0 -25
package/AGENTS.md CHANGED
@@ -116,7 +116,7 @@ For exhaustive component reference (every prop, every variant, every signature),
116
116
 
117
117
  - **Need an empty / no-results / load-error placeholder?** → `<EmptyState title description action={<Button>…</Button>} />` (`variant="error"` for failures, with a Retry button in `action`). Also the right thing to pass as `Table`'s `emptyMessage`.
118
118
 
119
- - **Need a progress bar?** → `<ProgressBar value max label showValue />` — omit `value` for indeterminate, `thresholds` for battery/quota colours, `segments` for wizard steps. `ActionButton` already has its own in-button fill for one-shot downloads.
119
+ - **Need a progress bar?** → `<ProgressBar value max label showValue />` — omit `value` for indeterminate, `thresholds` for battery/quota colours, `segments` for wizard steps (`onSegmentClick` makes them jump-to-step buttons). `ActionButton` already has its own in-button fill for one-shot downloads.
120
120
 
121
121
  - **Need a content container / tile?** → `<Card>` with `Card.Header` / `Card.Body` / `Card.Footer`; `interactive` + `onClick` for a clickable tile, `href` for a link card, `selected` for pick-one grids, `accent` for a colour stripe.
122
122
 
package/CHANGELOG.md CHANGED
@@ -4,6 +4,20 @@ All notable changes to `@overdoser/react-toolkit` are documented here.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/), and this
5
5
  project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [0.21.0]
8
+
9
+ ### Added
10
+
11
+ - **`ProgressBar` clickable segments.** `onSegmentClick(index, event)` turns
12
+ every segment of a segmented bar into a keyboard-focusable
13
+ `<button type="button">` with hover and focus styles, and calls back with
14
+ the zero-based index, so a wizard or survey strip can jump to a step.
15
+ The track switches from `role="progressbar"` to a `role="group"` of
16
+ buttons (progressbar children are presentational to screen readers) and
17
+ the current step gets `aria-current="step"` when `showCurrent` is set.
18
+ `segmentLabel(index, segments)` customises the buttons' accessible names
19
+ (default `Step N of M`). Continuous and indeterminate bars ignore both.
20
+
7
21
  ## [0.20.0]
8
22
 
9
23
  Follow-ups from rolling 0.19.0 out to sixteen apps. Dark mode becomes opt-in
@@ -1,180 +1,163 @@
1
- import { jsx as o, jsxs as j } from "react/jsx-runtime";
2
- import { forwardRef as y, useId as Z, useRef as _, useState as ee, useCallback as L, createContext as E, useContext as S } from "react";
3
- import h from "clsx";
4
- import r from "./Accordion.module.scss.js";
5
- const H = E(null), K = E(null);
6
- function N(t) {
7
- const n = S(H);
8
- if (!n) throw new Error(`${t} must be rendered inside an <Accordion>.`);
9
- return n;
1
+ import e from "./Accordion.module.js";
2
+ import { createContext as t, forwardRef as n, useCallback as r, useContext as i, useId as a, useRef as o, useState as s } from "react";
3
+ import c from "clsx";
4
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
5
+ // src/components/Accordion/Accordion.tsx
6
+ var d = t(null), f = t(null);
7
+ function p(e) {
8
+ let t = i(d);
9
+ if (!t) throw Error(`${e} must be rendered inside an <Accordion>.`);
10
+ return t;
10
11
  }
11
- function M(t) {
12
- const n = S(K);
13
- if (!n) throw new Error(`${t} must be rendered inside an <Accordion.Item>.`);
14
- return n;
12
+ function m(e) {
13
+ let t = i(f);
14
+ if (!t) throw Error(`${e} must be rendered inside an <Accordion.Item>.`);
15
+ return t;
15
16
  }
16
- function O(t) {
17
- return t === void 0 ? [] : Array.isArray(t) ? t : [t];
17
+ function h(e) {
18
+ return e === void 0 ? [] : Array.isArray(e) ? e : [e];
18
19
  }
19
- const P = y(
20
- ({
21
- type: t = "single",
22
- value: n,
23
- defaultValue: f,
24
- onValueChange: g,
25
- collapsible: d = !0,
26
- keepMounted: i = !1,
27
- variant: a = "default",
28
- size: c = "md",
29
- disabled: s = !1,
30
- headingLevel: p = 3,
31
- items: m,
32
- classes: b,
33
- className: q,
34
- children: B,
35
- onKeyDown: U,
36
- ...V
37
- }, I) => {
38
- const W = Z(), R = _(null), C = n !== void 0, [z, F] = ee(() => O(f)), v = C ? O(n) : z, G = L(
39
- (e) => {
40
- const A = v.includes(e);
41
- let l;
42
- if (t === "multiple")
43
- l = A ? v.filter((u) => u !== e) : [...v, e];
44
- else if (A) {
45
- if (!d) return;
46
- l = [];
47
- } else
48
- l = [e];
49
- C || F(l), g?.(t === "multiple" ? l : l[0] ?? "");
50
- },
51
- [v, t, d, C, g]
52
- ), J = L(
53
- (e) => {
54
- R.current = e, typeof I == "function" ? I(e) : I && (I.current = e);
55
- },
56
- [I]
57
- ), Q = (e) => {
58
- if (U?.(e), e.defaultPrevented) return;
59
- const A = R.current;
60
- if (!A) return;
61
- const l = e.target;
62
- if (!l.matches("[data-accordion-trigger]")) return;
63
- const u = Array.from(
64
- A.querySelectorAll("[data-accordion-trigger]:not(:disabled)")
65
- ).filter((Y) => Y.closest("[data-accordion-root]") === A);
66
- if (u.length === 0) return;
67
- const T = u.indexOf(l);
68
- let x = null;
69
- e.key === "ArrowDown" ? x = (T + 1) % u.length : e.key === "ArrowUp" ? x = (T - 1 + u.length) % u.length : e.key === "Home" ? x = 0 : e.key === "End" && (x = u.length - 1), x !== null && (e.preventDefault(), u[x].focus());
70
- }, X = {
71
- openValues: v,
72
- toggle: G,
73
- baseId: W,
74
- keepMounted: i,
75
- disabled: s,
76
- headingLevel: p,
77
- classes: b
78
- };
79
- return /* @__PURE__ */ o(H.Provider, { value: X, children: /* @__PURE__ */ o(
80
- "div",
81
- {
82
- ref: J,
83
- "data-accordion-root": "",
84
- className: h(r.root, r[a], r[c], b?.root, q),
85
- onKeyDown: Q,
86
- ...V,
87
- children: m ? m.map((e) => /* @__PURE__ */ j(w, { value: e.value, disabled: e.disabled, children: [
88
- /* @__PURE__ */ o(k, { children: e.title }),
89
- /* @__PURE__ */ o($, { children: e.content })
90
- ] }, e.value)) : B
91
- }
92
- ) });
93
- }
94
- );
95
- P.displayName = "Accordion";
96
- const w = y(
97
- ({ value: t, disabled: n = !1, className: f, children: g, ...d }, i) => {
98
- const a = N("Accordion.Item"), c = a.openValues.includes(t), s = n || a.disabled, p = `${a.baseId}-${t}`, m = {
99
- value: t,
100
- open: c,
101
- disabled: s,
102
- triggerId: `${p}-trigger`,
103
- contentId: `${p}-content`
104
- };
105
- return /* @__PURE__ */ o(K.Provider, { value: m, children: /* @__PURE__ */ o(
106
- "div",
107
- {
108
- ref: i,
109
- "data-state": c ? "open" : "closed",
110
- "data-disabled": s || void 0,
111
- className: h(
112
- r.item,
113
- c && r.itemOpen,
114
- s && r.itemDisabled,
115
- a.classes?.item,
116
- c && a.classes?.itemOpen,
117
- f
118
- ),
119
- ...d,
120
- children: g
121
- }
122
- ) });
123
- }
124
- );
125
- w.displayName = "Accordion.Item";
126
- const te = /* @__PURE__ */ o("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "2", "aria-hidden": "true", width: "1em", height: "1em", children: /* @__PURE__ */ o("path", { d: "M5 8l5 5 5-5", strokeLinecap: "round", strokeLinejoin: "round" }) }), k = y(
127
- ({ icon: t = te, iconPosition: n = "end", className: f, children: g, onClick: d, ...i }, a) => {
128
- const c = N("Accordion.Trigger"), s = M("Accordion.Trigger"), p = `h${c.headingLevel}`, m = t === !1 ? null : /* @__PURE__ */ o("span", { className: h(r.icon, c.classes?.icon), "aria-hidden": "true", children: t });
129
- return /* @__PURE__ */ o(p, { className: h(r.header, c.classes?.header), children: /* @__PURE__ */ j(
130
- "button",
131
- {
132
- ref: a,
133
- type: "button",
134
- id: s.triggerId,
135
- "data-accordion-trigger": "",
136
- "aria-expanded": s.open,
137
- "aria-controls": s.contentId,
138
- disabled: s.disabled,
139
- className: h(r.trigger, n === "start" && r.iconStart, c.classes?.trigger, f),
140
- onClick: (b) => {
141
- d?.(b), !b.defaultPrevented && c.toggle(s.value);
142
- },
143
- ...i,
144
- children: [
145
- n === "start" && m,
146
- /* @__PURE__ */ o("span", { className: r.triggerLabel, children: g }),
147
- n === "end" && m
148
- ]
149
- }
150
- ) });
151
- }
152
- );
153
- k.displayName = "Accordion.Trigger";
154
- const $ = y(
155
- ({ className: t, children: n, ...f }, g) => {
156
- const d = N("Accordion.Content"), i = M("Accordion.Content");
157
- return !i.open && !d.keepMounted ? null : /* @__PURE__ */ o(
158
- "div",
159
- {
160
- ref: g,
161
- id: i.contentId,
162
- role: "region",
163
- "aria-labelledby": i.triggerId,
164
- hidden: !i.open,
165
- "data-state": i.open ? "open" : "closed",
166
- className: h(r.content, d.classes?.content, t),
167
- ...f,
168
- children: /* @__PURE__ */ o("div", { className: r.contentClip, children: /* @__PURE__ */ o("div", { className: h(r.contentInner, d.classes?.contentInner), children: n }) })
169
- }
170
- );
171
- }
172
- );
173
- $.displayName = "Accordion.Content";
174
- const D = P;
175
- D.Item = w;
176
- D.Trigger = k;
177
- D.Content = $;
178
- export {
179
- D as Accordion
180
- };
20
+ var g = n(({ type: t = "single", value: n, defaultValue: i, onValueChange: f, collapsible: p = !0, keepMounted: m = !1, variant: g = "default", size: v = "md", disabled: x = !1, headingLevel: S = 3, items: C, classes: w, className: T, children: E, onKeyDown: D, ...O }, k) => {
21
+ let A = a(), j = o(null), M = n !== void 0, [N, P] = s(() => h(i)), F = M ? h(n) : N, I = r((e) => {
22
+ let n = F.includes(e), r;
23
+ if (t === "multiple") r = n ? F.filter((t) => t !== e) : [...F, e];
24
+ else if (n) {
25
+ if (!p) return;
26
+ r = [];
27
+ } else r = [e];
28
+ M || P(r), f?.(t === "multiple" ? r : r[0] ?? "");
29
+ }, [
30
+ F,
31
+ t,
32
+ p,
33
+ M,
34
+ f
35
+ ]), L = r((e) => {
36
+ j.current = e, typeof k == "function" ? k(e) : k && (k.current = e);
37
+ }, [k]), R = (e) => {
38
+ if (D?.(e), e.defaultPrevented) return;
39
+ let t = j.current;
40
+ if (!t) return;
41
+ let n = e.target;
42
+ if (!n.matches("[data-accordion-trigger]")) return;
43
+ let r = Array.from(t.querySelectorAll("[data-accordion-trigger]:not(:disabled)")).filter((e) => e.closest("[data-accordion-root]") === t);
44
+ if (r.length === 0) return;
45
+ let i = r.indexOf(n), a = null;
46
+ e.key === "ArrowDown" ? a = (i + 1) % r.length : e.key === "ArrowUp" ? a = (i - 1 + r.length) % r.length : e.key === "Home" ? a = 0 : e.key === "End" && (a = r.length - 1), a !== null && (e.preventDefault(), r[a].focus());
47
+ }, z = {
48
+ openValues: F,
49
+ toggle: I,
50
+ baseId: A,
51
+ keepMounted: m,
52
+ disabled: x,
53
+ headingLevel: S,
54
+ classes: w
55
+ };
56
+ return /* @__PURE__ */ l(d.Provider, {
57
+ value: z,
58
+ children: /* @__PURE__ */ l("div", {
59
+ ref: L,
60
+ "data-accordion-root": "",
61
+ className: c(e.root, e[g], e[v], w?.root, T),
62
+ onKeyDown: R,
63
+ ...O,
64
+ children: C ? C.map((e) => /* @__PURE__ */ u(_, {
65
+ value: e.value,
66
+ disabled: e.disabled,
67
+ children: [/* @__PURE__ */ l(y, { children: e.title }), /* @__PURE__ */ l(b, { children: e.content })]
68
+ }, e.value)) : E
69
+ })
70
+ });
71
+ });
72
+ g.displayName = "Accordion";
73
+ var _ = n(({ value: t, disabled: n = !1, className: r, children: i, ...a }, o) => {
74
+ let s = p("Accordion.Item"), u = s.openValues.includes(t), d = n || s.disabled, m = `${s.baseId}-${t}`, h = {
75
+ value: t,
76
+ open: u,
77
+ disabled: d,
78
+ triggerId: `${m}-trigger`,
79
+ contentId: `${m}-content`
80
+ };
81
+ return /* @__PURE__ */ l(f.Provider, {
82
+ value: h,
83
+ children: /* @__PURE__ */ l("div", {
84
+ ref: o,
85
+ "data-state": u ? "open" : "closed",
86
+ "data-disabled": d || void 0,
87
+ className: c(e.item, u && e.itemOpen, d && e.itemDisabled, s.classes?.item, u && s.classes?.itemOpen, r),
88
+ ...a,
89
+ children: i
90
+ })
91
+ });
92
+ });
93
+ _.displayName = "Accordion.Item";
94
+ var v = /* @__PURE__ */ l("svg", {
95
+ viewBox: "0 0 20 20",
96
+ fill: "none",
97
+ stroke: "currentColor",
98
+ strokeWidth: "2",
99
+ "aria-hidden": "true",
100
+ width: "1em",
101
+ height: "1em",
102
+ children: /* @__PURE__ */ l("path", {
103
+ d: "M5 8l5 5 5-5",
104
+ strokeLinecap: "round",
105
+ strokeLinejoin: "round"
106
+ })
107
+ }), y = n(({ icon: t = v, iconPosition: n = "end", className: r, children: i, onClick: a, ...o }, s) => {
108
+ let d = p("Accordion.Trigger"), f = m("Accordion.Trigger"), h = `h${d.headingLevel}`, g = t === !1 ? null : /* @__PURE__ */ l("span", {
109
+ className: c(e.icon, d.classes?.icon),
110
+ "aria-hidden": "true",
111
+ children: t
112
+ });
113
+ return /* @__PURE__ */ l(h, {
114
+ className: c(e.header, d.classes?.header),
115
+ children: /* @__PURE__ */ u("button", {
116
+ ref: s,
117
+ type: "button",
118
+ id: f.triggerId,
119
+ "data-accordion-trigger": "",
120
+ "aria-expanded": f.open,
121
+ "aria-controls": f.contentId,
122
+ disabled: f.disabled,
123
+ className: c(e.trigger, n === "start" && e.iconStart, d.classes?.trigger, r),
124
+ onClick: (e) => {
125
+ a?.(e), e.defaultPrevented || d.toggle(f.value);
126
+ },
127
+ ...o,
128
+ children: [
129
+ n === "start" && g,
130
+ /* @__PURE__ */ l("span", {
131
+ className: e.triggerLabel,
132
+ children: i
133
+ }),
134
+ n === "end" && g
135
+ ]
136
+ })
137
+ });
138
+ });
139
+ y.displayName = "Accordion.Trigger";
140
+ var b = n(({ className: t, children: n, ...r }, i) => {
141
+ let a = p("Accordion.Content"), o = m("Accordion.Content");
142
+ return !o.open && !a.keepMounted ? null : /* @__PURE__ */ l("div", {
143
+ ref: i,
144
+ id: o.contentId,
145
+ role: "region",
146
+ "aria-labelledby": o.triggerId,
147
+ hidden: !o.open,
148
+ "data-state": o.open ? "open" : "closed",
149
+ className: c(e.content, a.classes?.content, t),
150
+ ...r,
151
+ children: /* @__PURE__ */ l("div", {
152
+ className: e.contentClip,
153
+ children: /* @__PURE__ */ l("div", {
154
+ className: c(e.contentInner, a.classes?.contentInner),
155
+ children: n
156
+ })
157
+ })
158
+ });
159
+ });
160
+ b.displayName = "Accordion.Content";
161
+ var x = g;
162
+ x.Item = _, x.Trigger = y, x.Content = b;
163
+ export { x as Accordion };
@@ -0,0 +1,20 @@
1
+ // src/components/Accordion/Accordion.module.scss
2
+ var e = "crk-root-cCog2", t = "crk-sm-xQI6G", n = "crk-item-YNNr-", r = "crk-bordered-PfF4R", i = "crk-separated-X-Y5o", a = "crk-itemDisabled-JQ4TD", o = "crk-header-AYOT5", s = "crk-trigger-sPQlj", c = "crk-iconStart-5fvpd", l = "crk-triggerLabel-FZx-J", u = "crk-icon-TdeJS", d = "crk-itemOpen-pU-Q4", f = "crk-content-RyBzl", p = "crk-contentClip-S5IS2", m = "crk-contentInner-gJF2F", h = {
3
+ root: e,
4
+ sm: t,
5
+ default: "crk-default-D79k9",
6
+ item: n,
7
+ bordered: r,
8
+ separated: i,
9
+ itemDisabled: a,
10
+ header: o,
11
+ trigger: s,
12
+ iconStart: c,
13
+ triggerLabel: l,
14
+ icon: u,
15
+ itemOpen: d,
16
+ content: f,
17
+ contentClip: p,
18
+ contentInner: m
19
+ };
20
+ export { r as bordered, f as content, p as contentClip, m as contentInner, h as default, o as header, u as icon, c as iconStart, n as item, a as itemDisabled, d as itemOpen, e as root, i as separated, t as sm, s as trigger, l as triggerLabel };