@overdoser/react-toolkit 0.20.0 → 0.22.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 (212) hide show
  1. package/AGENTS.md +2 -1
  2. package/CHANGELOG.md +41 -0
  3. package/components/Accordion/Accordion.js +160 -177
  4. package/components/Accordion/Accordion.module.scss.js +19 -35
  5. package/components/ActionButton/ActionButton.js +155 -209
  6. package/components/ActionButton/ActionButton.module.scss.js +24 -46
  7. package/components/ActionButton/CopyButton.js +52 -64
  8. package/components/Alert/Alert.js +93 -96
  9. package/components/Alert/Alert.module.scss.js +17 -32
  10. package/components/Avatar/Avatar.js +44 -55
  11. package/components/Avatar/Avatar.module.scss.js +22 -42
  12. package/components/Badge/Badge.js +15 -37
  13. package/components/Badge/Badge.module.scss.js +16 -30
  14. package/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  15. package/components/Breadcrumbs/Breadcrumbs.js +52 -48
  16. package/components/Breadcrumbs/Breadcrumbs.module.scss.js +9 -16
  17. package/components/Button/Button.js +35 -57
  18. package/components/Button/Button.module.scss.js +24 -46
  19. package/components/Card/Card.js +94 -131
  20. package/components/Card/Card.module.scss.js +34 -59
  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.scss.js +31 -60
  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 +45 -40
  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.scss.js +31 -58
  48. package/components/CodeBlock/CodeBlock.js +111 -119
  49. package/components/CodeBlock/CodeBlock.module.scss.js +22 -42
  50. package/components/CommandPalette/CommandPalette.js +387 -392
  51. package/components/CommandPalette/CommandPalette.module.scss.js +27 -48
  52. package/components/ConfirmDialog/ConfirmDialog.d.ts +1 -1
  53. package/components/ConfirmDialog/ConfirmDialog.js +184 -199
  54. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +11 -20
  55. package/components/Divider/Divider.js +25 -36
  56. package/components/Divider/Divider.module.scss.js +16 -30
  57. package/components/Draggable/Draggable.d.ts +1 -1
  58. package/components/Draggable/Draggable.js +157 -164
  59. package/components/Draggable/Draggable.module.scss.js +9 -16
  60. package/components/Drawer/Drawer.js +104 -126
  61. package/components/Drawer/Drawer.module.scss.js +65 -118
  62. package/components/Dropdown/Dropdown.js +175 -234
  63. package/components/Dropdown/Dropdown.module.scss.js +28 -52
  64. package/components/Dropdown/DropdownItem.js +55 -58
  65. package/components/Dropdown/DropdownLabel.js +14 -11
  66. package/components/Dropdown/DropdownSeparator.js +13 -11
  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.scss.js +11 -20
  71. package/components/EmptyState/EmptyState.js +57 -54
  72. package/components/EmptyState/EmptyState.module.scss.js +13 -24
  73. package/components/Form/Form.d.ts +1 -1
  74. package/components/Form/Form.js +31 -34
  75. package/components/Form/Form.module.scss.js +15 -28
  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.scss.js +25 -46
  83. package/components/ImageViewer/useZoomPan.js +206 -137
  84. package/components/Kbd/Kbd.js +24 -21
  85. package/components/Kbd/Kbd.module.scss.js +9 -16
  86. package/components/KeyValueList/KeyValueList.js +119 -123
  87. package/components/KeyValueList/KeyValueList.module.scss.js +22 -42
  88. package/components/Link/Link.js +45 -59
  89. package/components/Link/Link.module.scss.js +9 -15
  90. package/components/List/List.js +22 -46
  91. package/components/List/List.module.scss.js +11 -20
  92. package/components/Loader/Loader.js +152 -182
  93. package/components/Loader/Loader.module.scss.js +39 -69
  94. package/components/Modal/Modal.js +93 -105
  95. package/components/Modal/Modal.module.scss.js +17 -32
  96. package/components/PageHeader/PageHeader.js +79 -73
  97. package/components/PageHeader/PageHeader.module.scss.js +22 -42
  98. package/components/Pagination/Pagination.js +62 -83
  99. package/components/Pagination/Pagination.module.scss.js +12 -22
  100. package/components/Pagination/paginationRange.js +15 -22
  101. package/components/Popover/Popover.js +110 -134
  102. package/components/Popover/Popover.module.scss.js +11 -20
  103. package/components/ProgressBar/ProgressBar.d.ts +15 -1
  104. package/components/ProgressBar/ProgressBar.js +56 -89
  105. package/components/ProgressBar/ProgressBar.module.scss.js +28 -50
  106. package/components/RelativeTime/RelativeTime.js +36 -43
  107. package/components/RelativeTime/RelativeTime.module.scss.js +3 -7
  108. package/components/SegmentedControl/SegmentedControl.js +93 -129
  109. package/components/SegmentedControl/SegmentedControl.module.scss.js +20 -38
  110. package/components/Skeleton/Skeleton.js +36 -50
  111. package/components/Skeleton/Skeleton.module.scss.js +14 -24
  112. package/components/Spinner/Spinner.js +25 -25
  113. package/components/Spinner/Spinner.module.scss.js +11 -19
  114. package/components/SplitButton/SplitButton.js +149 -196
  115. package/components/SplitButton/SplitButton.module.scss.js +30 -56
  116. package/components/SplitPane/SplitPane.js +134 -170
  117. package/components/SplitPane/SplitPane.module.scss.js +13 -24
  118. package/components/StatCard/StatCard.js +132 -125
  119. package/components/StatCard/StatCard.module.scss.js +41 -71
  120. package/components/StatusDot/StatusDot.js +28 -39
  121. package/components/StatusDot/StatusDot.module.scss.js +17 -31
  122. package/components/Table/Table.d.ts +1 -1
  123. package/components/Table/Table.js +381 -451
  124. package/components/Table/Table.module.scss.js +41 -80
  125. package/components/Table/useTableSort.js +51 -42
  126. package/components/Tabs/Tabs.js +109 -161
  127. package/components/Tabs/Tabs.module.scss.js +27 -52
  128. package/components/ThemeToggle/ThemeToggle.js +122 -98
  129. package/components/ThemeToggle/ThemeToggle.module.scss.js +12 -22
  130. package/components/Timeline/GanttTimeline.js +357 -318
  131. package/components/Timeline/GanttTimeline.module.scss.js +28 -54
  132. package/components/Timeline/HistoryTimeline.js +486 -450
  133. package/components/Timeline/HistoryTimeline.module.scss.js +30 -58
  134. package/components/Timeline/Timeline.module.scss.js +75 -140
  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 +244 -177
  139. package/components/Timeline/TraceTimeline.js +823 -783
  140. package/components/Timeline/TraceTimeline.module.scss.js +97 -188
  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.scss.js +28 -54
  148. package/components/Toast/Toast.d.ts +1 -1
  149. package/components/Toast/Toast.js +128 -128
  150. package/components/Toast/Toast.module.scss.js +36 -61
  151. package/components/Toast/toastStore.js +58 -62
  152. package/components/ToggleIconButton/ToggleIconButton.js +36 -58
  153. package/components/ToggleIconButton/ToggleIconButton.module.scss.js +14 -26
  154. package/components/Tooltip/Tooltip.d.ts +1 -1
  155. package/components/Tooltip/Tooltip.js +76 -85
  156. package/components/Tooltip/Tooltip.module.scss.js +16 -29
  157. package/components/Typography/Typography.js +10 -35
  158. package/components/Typography/Typography.module.scss.js +29 -52
  159. package/components/inputs/Checkbox/Checkbox.js +27 -51
  160. package/components/inputs/Checkbox/Checkbox.module.scss.js +9 -16
  161. package/components/inputs/Checkbox/CheckboxGroup.js +53 -111
  162. package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +16 -30
  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.scss.js +22 -40
  166. package/components/inputs/DatePicker/DatePicker.js +115 -142
  167. package/components/inputs/DatePicker/DatePicker.module.scss.js +13 -24
  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.scss.js +19 -36
  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.scss.js +14 -26
  177. package/components/inputs/NumberInput/NumberInput.js +112 -132
  178. package/components/inputs/NumberInput/NumberInput.module.scss.js +13 -24
  179. package/components/inputs/Radio/Radio.js +50 -73
  180. package/components/inputs/Radio/Radio.module.scss.js +8 -14
  181. package/components/inputs/SearchInput/SearchInput.js +98 -115
  182. package/components/inputs/SearchInput/SearchInput.module.scss.js +7 -12
  183. package/components/inputs/Select/Select.d.ts +55 -3
  184. package/components/inputs/Select/Select.js +696 -682
  185. package/components/inputs/Select/Select.module.scss.js +49 -72
  186. package/components/inputs/Slider/Slider.js +97 -128
  187. package/components/inputs/Slider/Slider.module.scss.js +8 -14
  188. package/components/inputs/Switch/Switch.js +11 -8
  189. package/components/inputs/Textarea/Textarea.js +42 -58
  190. package/components/inputs/Textarea/Textarea.module.scss.js +13 -24
  191. package/hooks/useClickOutside.js +17 -14
  192. package/hooks/useDebouncedValue.js +13 -14
  193. package/hooks/useElementSize.js +27 -22
  194. package/hooks/useEscapeLayer.js +28 -29
  195. package/hooks/useFocusTrap.js +27 -38
  196. package/hooks/useKeyboard.js +76 -64
  197. package/hooks/useMediaQuery.js +10 -15
  198. package/hooks/useNow.js +28 -33
  199. package/hooks/usePersistedState.js +98 -94
  200. package/hooks/usePortalPosition.d.ts +2 -1
  201. package/hooks/usePortalPosition.js +28 -19
  202. package/hooks/useResizable.js +106 -104
  203. package/hooks/useTheme.js +28 -23
  204. package/index.css +2 -1
  205. package/index.js +96 -214
  206. package/index.layered.css +2 -3
  207. package/llms.txt +28 -4
  208. package/manifest.json +41 -4
  209. package/package.json +1 -1
  210. package/utils/formatBytes.js +29 -13
  211. package/utils/themeScript.js +6 -8
  212. package/utils/timeAgo.js +59 -32
package/AGENTS.md CHANGED
@@ -49,6 +49,7 @@ For exhaustive component reference (every prop, every variant, every signature),
49
49
  - Few options, native UX OK → `<Select options={...} />`.
50
50
  - Many options, want a search filter → `<Select searchable options={...} />`.
51
51
  - Multi-pick with chips → `<Select multiple options={...} onValuesChange={...} />`.
52
+ - Picking many values from a long list while filtering (AWS console log-group picker: checkboxes, selected rows stay visible, Select all matching) → `<Select multiple checklist maxVisibleChips={3} ... />`.
52
53
  - Options come from a server as the user types (async autocomplete / combobox) → `<Select searchable onSearch={fetch} loading={…} options={results} selectedLabels={…} />` (same for `multiple`). Don't build a Combobox.
53
54
  - You want it to look like a "menu trigger" instead of a form input → `<Dropdown options={...} value={...} onChange={...} />` (select-mode dropdown).
54
55
 
@@ -116,7 +117,7 @@ For exhaustive component reference (every prop, every variant, every signature),
116
117
 
117
118
  - **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
119
 
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.
120
+ - **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
121
 
121
122
  - **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
123
 
package/CHANGELOG.md CHANGED
@@ -4,6 +4,47 @@ 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.22.0]
8
+
9
+ ### Added
10
+
11
+ - **`Select` checklist mode.** `multiple checklist` is the AWS CloudWatch
12
+ log-group picker, for picking many values while filtering: the search box
13
+ moves into the menu, every row gets a checkbox, and selected options stay
14
+ listed when they don't match the query, in their `options` order. A row
15
+ unchecked while filtered stays put until the query changes, so nothing
16
+ jumps under the pointer. The header offers "Select all matching" and
17
+ "Deselect all" (`selectAllLabel`, `deselectAllLabel`). The menu stays open
18
+ while picking (`closeOnSelect` and `clearSearchOnSelect` default to
19
+ `false`) and closes on outside click, Escape or Tab. Chips show the plain
20
+ `label`, so a rich two-line `content` row stays in the menu.
21
+ - **`Select` `maxVisibleChips`.** Any multi mode can cap the chips in the
22
+ control; the rest collapse into a "+N more" chip whose tooltip lists them
23
+ (`moreChipsLabel` customises its text).
24
+
25
+ ### Fixed
26
+
27
+ - **Portaled menus** (`Select`, and everything else on `usePortalPosition`)
28
+ follow the trigger when it grows while open, instead of covering the new
29
+ chip rows, and no longer re-render on scrolls that move nothing.
30
+ - **`Select`** — option ids are scoped per instance, so two Selects with the
31
+ same values no longer share ids, and values containing spaces give valid
32
+ `aria-activedescendant` targets.
33
+
34
+ ## [0.21.0]
35
+
36
+ ### Added
37
+
38
+ - **`ProgressBar` clickable segments.** `onSegmentClick(index, event)` turns
39
+ every segment of a segmented bar into a keyboard-focusable
40
+ `<button type="button">` with hover and focus styles, and calls back with
41
+ the zero-based index, so a wizard or survey strip can jump to a step.
42
+ The track switches from `role="progressbar"` to a `role="group"` of
43
+ buttons (progressbar children are presentational to screen readers) and
44
+ the current step gets `aria-current="step"` when `showCurrent` is set.
45
+ `segmentLabel(index, segments)` customises the buttons' accessible names
46
+ (default `Step N of M`). Continuous and indeterminate bars ignore both.
47
+
7
48
  ## [0.20.0]
8
49
 
9
50
  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 { createContext as e, forwardRef as t, useCallback as n, useContext as r, useId as i, useRef as a, useState as o } from "react";
2
+ import s from "clsx";
3
+ import c from "./Accordion.module.scss.js";
4
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
5
+ // src/components/Accordion/Accordion.tsx
6
+ var d = e(null), f = e(null);
7
+ function p(e) {
8
+ let t = r(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 = r(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 = t(({ type: e = "single", value: t, defaultValue: r, 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 = i(), j = a(null), M = t !== void 0, [N, P] = o(() => h(r)), F = M ? h(t) : N, I = n((t) => {
22
+ let n = F.includes(t), r;
23
+ if (e === "multiple") r = n ? F.filter((e) => e !== t) : [...F, t];
24
+ else if (n) {
25
+ if (!p) return;
26
+ r = [];
27
+ } else r = [t];
28
+ M || P(r), f?.(e === "multiple" ? r : r[0] ?? "");
29
+ }, [
30
+ F,
31
+ e,
32
+ p,
33
+ M,
34
+ f
35
+ ]), L = n((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: s(c.root, c[g], c[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 _ = t(({ value: e, disabled: t = !1, className: n, children: r, ...i }, a) => {
74
+ let o = p("Accordion.Item"), u = o.openValues.includes(e), d = t || o.disabled, m = `${o.baseId}-${e}`, h = {
75
+ value: e,
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: a,
85
+ "data-state": u ? "open" : "closed",
86
+ "data-disabled": d || void 0,
87
+ className: s(c.item, u && c.itemOpen, d && c.itemDisabled, o.classes?.item, u && o.classes?.itemOpen, n),
88
+ ...i,
89
+ children: r
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 = t(({ icon: e = v, iconPosition: t = "end", className: n, children: r, onClick: i, ...a }, o) => {
108
+ let d = p("Accordion.Trigger"), f = m("Accordion.Trigger"), h = `h${d.headingLevel}`, g = e === !1 ? null : /* @__PURE__ */ l("span", {
109
+ className: s(c.icon, d.classes?.icon),
110
+ "aria-hidden": "true",
111
+ children: e
112
+ });
113
+ return /* @__PURE__ */ l(h, {
114
+ className: s(c.header, d.classes?.header),
115
+ children: /* @__PURE__ */ u("button", {
116
+ ref: o,
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: s(c.trigger, t === "start" && c.iconStart, d.classes?.trigger, n),
124
+ onClick: (e) => {
125
+ i?.(e), e.defaultPrevented || d.toggle(f.value);
126
+ },
127
+ ...a,
128
+ children: [
129
+ t === "start" && g,
130
+ /* @__PURE__ */ l("span", {
131
+ className: c.triggerLabel,
132
+ children: r
133
+ }),
134
+ t === "end" && g
135
+ ]
136
+ })
137
+ });
138
+ });
139
+ y.displayName = "Accordion.Trigger";
140
+ var b = t(({ className: e, children: t, ...n }, r) => {
141
+ let i = p("Accordion.Content"), a = m("Accordion.Content");
142
+ return !a.open && !i.keepMounted ? null : /* @__PURE__ */ l("div", {
143
+ ref: r,
144
+ id: a.contentId,
145
+ role: "region",
146
+ "aria-labelledby": a.triggerId,
147
+ hidden: !a.open,
148
+ "data-state": a.open ? "open" : "closed",
149
+ className: s(c.content, i.classes?.content, e),
150
+ ...n,
151
+ children: /* @__PURE__ */ l("div", {
152
+ className: c.contentClip,
153
+ children: /* @__PURE__ */ l("div", {
154
+ className: s(c.contentInner, i.classes?.contentInner),
155
+ children: t
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 };
@@ -1,36 +1,20 @@
1
- const t = "crk-root-cCog2", e = "crk-sm-xQI6G", r = "crk-item-YNNr-", n = "crk-bordered-PfF4R", c = "crk-separated-X-Y5o", o = "crk-itemDisabled-JQ4TD", s = "crk-header-AYOT5", i = "crk-trigger-sPQlj", a = "crk-iconStart-5fvpd", d = "crk-triggerLabel-FZx-J", k = "crk-icon-TdeJS", l = "crk-itemOpen-pU-Q4", g = "crk-content-RyBzl", m = "crk-contentClip-S5IS2", p = "crk-contentInner-gJF2F", b = {
2
- root: t,
3
- sm: e,
4
- default: "crk-default-D79k9",
5
- item: r,
6
- bordered: n,
7
- separated: c,
8
- itemDisabled: o,
9
- header: s,
10
- trigger: i,
11
- iconStart: a,
12
- triggerLabel: d,
13
- icon: k,
14
- itemOpen: l,
15
- content: g,
16
- contentClip: m,
17
- contentInner: p
18
- };
19
- export {
20
- n as bordered,
21
- g as content,
22
- m as contentClip,
23
- p as contentInner,
24
- b as default,
25
- s as header,
26
- k as icon,
27
- a as iconStart,
28
- r as item,
29
- o as itemDisabled,
30
- l as itemOpen,
31
- t as root,
32
- c as separated,
33
- e as sm,
34
- i as trigger,
35
- d as triggerLabel
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
36
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 };