@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.
- package/AGENTS.md +2 -1
- package/CHANGELOG.md +41 -0
- package/components/Accordion/Accordion.js +160 -177
- package/components/Accordion/Accordion.module.scss.js +19 -35
- package/components/ActionButton/ActionButton.js +155 -209
- package/components/ActionButton/ActionButton.module.scss.js +24 -46
- package/components/ActionButton/CopyButton.js +52 -64
- package/components/Alert/Alert.js +93 -96
- package/components/Alert/Alert.module.scss.js +17 -32
- package/components/Avatar/Avatar.js +44 -55
- package/components/Avatar/Avatar.module.scss.js +22 -42
- package/components/Badge/Badge.js +15 -37
- package/components/Badge/Badge.module.scss.js +16 -30
- package/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/components/Breadcrumbs/Breadcrumbs.js +52 -48
- package/components/Breadcrumbs/Breadcrumbs.module.scss.js +9 -16
- package/components/Button/Button.js +35 -57
- package/components/Button/Button.module.scss.js +24 -46
- package/components/Card/Card.js +94 -131
- package/components/Card/Card.module.scss.js +34 -59
- package/components/Chart/AreaChart.d.ts +1 -1
- package/components/Chart/AreaChart.js +248 -249
- package/components/Chart/Axis.d.ts +2 -2
- package/components/Chart/Axis.js +34 -43
- package/components/Chart/BarChart.d.ts +1 -1
- package/components/Chart/BarChart.js +307 -348
- package/components/Chart/Chart.module.scss.js +31 -60
- package/components/Chart/ChartContainer.js +33 -41
- package/components/Chart/ChartLegend.d.ts +1 -1
- package/components/Chart/ChartLegend.js +31 -30
- package/components/Chart/ChartTooltip.d.ts +1 -1
- package/components/Chart/ChartTooltip.js +45 -40
- package/components/Chart/LineChart.d.ts +1 -1
- package/components/Chart/LineChart.js +220 -232
- package/components/Chart/PieChart.d.ts +1 -1
- package/components/Chart/PieChart.js +224 -240
- package/components/Chart/RadarChart.d.ts +1 -1
- package/components/Chart/RadarChart.js +166 -215
- package/components/Chart/Sparkline.js +73 -68
- package/components/Chart/TradingChart.d.ts +1 -1
- package/components/Chart/TradingChart.js +804 -701
- package/components/Chart/scales.js +28 -35
- package/components/Chart/trading/indicators.js +61 -62
- package/components/Chart/trading/period.js +46 -68
- package/components/Chart/useChartDimensions.js +30 -22
- package/components/Chip/Chip.js +98 -141
- package/components/Chip/Chip.module.scss.js +31 -58
- package/components/CodeBlock/CodeBlock.js +111 -119
- package/components/CodeBlock/CodeBlock.module.scss.js +22 -42
- package/components/CommandPalette/CommandPalette.js +387 -392
- package/components/CommandPalette/CommandPalette.module.scss.js +27 -48
- package/components/ConfirmDialog/ConfirmDialog.d.ts +1 -1
- package/components/ConfirmDialog/ConfirmDialog.js +184 -199
- package/components/ConfirmDialog/ConfirmDialog.module.scss.js +11 -20
- package/components/Divider/Divider.js +25 -36
- package/components/Divider/Divider.module.scss.js +16 -30
- package/components/Draggable/Draggable.d.ts +1 -1
- package/components/Draggable/Draggable.js +157 -164
- package/components/Draggable/Draggable.module.scss.js +9 -16
- package/components/Drawer/Drawer.js +104 -126
- package/components/Drawer/Drawer.module.scss.js +65 -118
- package/components/Dropdown/Dropdown.js +175 -234
- package/components/Dropdown/Dropdown.module.scss.js +28 -52
- package/components/Dropdown/DropdownItem.js +55 -58
- package/components/Dropdown/DropdownLabel.js +14 -11
- package/components/Dropdown/DropdownSeparator.js +13 -11
- package/components/Dropdown/dropdownContext.js +4 -5
- package/components/Dropdown/useContextMenu.js +27 -17
- package/components/Dropzone/Dropzone.js +99 -105
- package/components/Dropzone/Dropzone.module.scss.js +11 -20
- package/components/EmptyState/EmptyState.js +57 -54
- package/components/EmptyState/EmptyState.module.scss.js +13 -24
- package/components/Form/Form.d.ts +1 -1
- package/components/Form/Form.js +31 -34
- package/components/Form/Form.module.scss.js +15 -28
- package/components/Form/FormField.d.ts +1 -1
- package/components/Form/FormField.js +71 -75
- package/components/Form/FormRow.d.ts +1 -1
- package/components/Form/FormRow.js +11 -8
- package/components/Form/formFieldDefaults.js +4 -5
- package/components/ImageViewer/ImageViewer.js +312 -201
- package/components/ImageViewer/ImageViewer.module.scss.js +25 -46
- package/components/ImageViewer/useZoomPan.js +206 -137
- package/components/Kbd/Kbd.js +24 -21
- package/components/Kbd/Kbd.module.scss.js +9 -16
- package/components/KeyValueList/KeyValueList.js +119 -123
- package/components/KeyValueList/KeyValueList.module.scss.js +22 -42
- package/components/Link/Link.js +45 -59
- package/components/Link/Link.module.scss.js +9 -15
- package/components/List/List.js +22 -46
- package/components/List/List.module.scss.js +11 -20
- package/components/Loader/Loader.js +152 -182
- package/components/Loader/Loader.module.scss.js +39 -69
- package/components/Modal/Modal.js +93 -105
- package/components/Modal/Modal.module.scss.js +17 -32
- package/components/PageHeader/PageHeader.js +79 -73
- package/components/PageHeader/PageHeader.module.scss.js +22 -42
- package/components/Pagination/Pagination.js +62 -83
- package/components/Pagination/Pagination.module.scss.js +12 -22
- package/components/Pagination/paginationRange.js +15 -22
- package/components/Popover/Popover.js +110 -134
- package/components/Popover/Popover.module.scss.js +11 -20
- package/components/ProgressBar/ProgressBar.d.ts +15 -1
- package/components/ProgressBar/ProgressBar.js +56 -89
- package/components/ProgressBar/ProgressBar.module.scss.js +28 -50
- package/components/RelativeTime/RelativeTime.js +36 -43
- package/components/RelativeTime/RelativeTime.module.scss.js +3 -7
- package/components/SegmentedControl/SegmentedControl.js +93 -129
- package/components/SegmentedControl/SegmentedControl.module.scss.js +20 -38
- package/components/Skeleton/Skeleton.js +36 -50
- package/components/Skeleton/Skeleton.module.scss.js +14 -24
- package/components/Spinner/Spinner.js +25 -25
- package/components/Spinner/Spinner.module.scss.js +11 -19
- package/components/SplitButton/SplitButton.js +149 -196
- package/components/SplitButton/SplitButton.module.scss.js +30 -56
- package/components/SplitPane/SplitPane.js +134 -170
- package/components/SplitPane/SplitPane.module.scss.js +13 -24
- package/components/StatCard/StatCard.js +132 -125
- package/components/StatCard/StatCard.module.scss.js +41 -71
- package/components/StatusDot/StatusDot.js +28 -39
- package/components/StatusDot/StatusDot.module.scss.js +17 -31
- package/components/Table/Table.d.ts +1 -1
- package/components/Table/Table.js +381 -451
- package/components/Table/Table.module.scss.js +41 -80
- package/components/Table/useTableSort.js +51 -42
- package/components/Tabs/Tabs.js +109 -161
- package/components/Tabs/Tabs.module.scss.js +27 -52
- package/components/ThemeToggle/ThemeToggle.js +122 -98
- package/components/ThemeToggle/ThemeToggle.module.scss.js +12 -22
- package/components/Timeline/GanttTimeline.js +357 -318
- package/components/Timeline/GanttTimeline.module.scss.js +28 -54
- package/components/Timeline/HistoryTimeline.js +486 -450
- package/components/Timeline/HistoryTimeline.module.scss.js +30 -58
- package/components/Timeline/Timeline.module.scss.js +75 -140
- package/components/Timeline/TimelineShared.d.ts +7 -7
- package/components/Timeline/TimelineShared.js +288 -279
- package/components/Timeline/TraceEventDetails.d.ts +3 -3
- package/components/Timeline/TraceEventDetails.js +244 -177
- package/components/Timeline/TraceTimeline.js +823 -783
- package/components/Timeline/TraceTimeline.module.scss.js +97 -188
- package/components/Timeline/historyLayout.js +336 -263
- package/components/Timeline/timelineCore.js +208 -183
- package/components/Timeline/traceEvent.js +59 -61
- package/components/Timeline/traceLayout.js +101 -90
- package/components/Timeline/useTimeline.js +76 -79
- package/components/Timer/Timer.js +190 -156
- package/components/Timer/Timer.module.scss.js +28 -54
- package/components/Toast/Toast.d.ts +1 -1
- package/components/Toast/Toast.js +128 -128
- package/components/Toast/Toast.module.scss.js +36 -61
- package/components/Toast/toastStore.js +58 -62
- package/components/ToggleIconButton/ToggleIconButton.js +36 -58
- package/components/ToggleIconButton/ToggleIconButton.module.scss.js +14 -26
- package/components/Tooltip/Tooltip.d.ts +1 -1
- package/components/Tooltip/Tooltip.js +76 -85
- package/components/Tooltip/Tooltip.module.scss.js +16 -29
- package/components/Typography/Typography.js +10 -35
- package/components/Typography/Typography.module.scss.js +29 -52
- package/components/inputs/Checkbox/Checkbox.js +27 -51
- package/components/inputs/Checkbox/Checkbox.module.scss.js +9 -16
- package/components/inputs/Checkbox/CheckboxGroup.js +53 -111
- package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +16 -30
- package/components/inputs/DatePicker/CalendarPanel.d.ts +1 -1
- package/components/inputs/DatePicker/CalendarPanel.js +263 -286
- package/components/inputs/DatePicker/CalendarPanel.module.scss.js +22 -40
- package/components/inputs/DatePicker/DatePicker.js +115 -142
- package/components/inputs/DatePicker/DatePicker.module.scss.js +13 -24
- package/components/inputs/DatePicker/dateUtils.js +32 -41
- package/components/inputs/DateTimePicker/DateTimePicker.js +226 -232
- package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +19 -36
- package/components/inputs/DateTimePicker/DateTimeSegments.js +273 -252
- package/components/inputs/DateTimePicker/TimeField.d.ts +1 -1
- package/components/inputs/DateTimePicker/TimeField.js +131 -132
- package/components/inputs/DateTimePicker/timeZoneUtils.js +95 -92
- package/components/inputs/Input/Input.js +98 -109
- package/components/inputs/Input/Input.module.scss.js +14 -26
- package/components/inputs/NumberInput/NumberInput.js +112 -132
- package/components/inputs/NumberInput/NumberInput.module.scss.js +13 -24
- package/components/inputs/Radio/Radio.js +50 -73
- package/components/inputs/Radio/Radio.module.scss.js +8 -14
- package/components/inputs/SearchInput/SearchInput.js +98 -115
- package/components/inputs/SearchInput/SearchInput.module.scss.js +7 -12
- package/components/inputs/Select/Select.d.ts +55 -3
- package/components/inputs/Select/Select.js +696 -682
- package/components/inputs/Select/Select.module.scss.js +49 -72
- package/components/inputs/Slider/Slider.js +97 -128
- package/components/inputs/Slider/Slider.module.scss.js +8 -14
- package/components/inputs/Switch/Switch.js +11 -8
- package/components/inputs/Textarea/Textarea.js +42 -58
- package/components/inputs/Textarea/Textarea.module.scss.js +13 -24
- package/hooks/useClickOutside.js +17 -14
- package/hooks/useDebouncedValue.js +13 -14
- package/hooks/useElementSize.js +27 -22
- package/hooks/useEscapeLayer.js +28 -29
- package/hooks/useFocusTrap.js +27 -38
- package/hooks/useKeyboard.js +76 -64
- package/hooks/useMediaQuery.js +10 -15
- package/hooks/useNow.js +28 -33
- package/hooks/usePersistedState.js +98 -94
- package/hooks/usePortalPosition.d.ts +2 -1
- package/hooks/usePortalPosition.js +28 -19
- package/hooks/useResizable.js +106 -104
- package/hooks/useTheme.js +28 -23
- package/index.css +2 -1
- package/index.js +96 -214
- package/index.layered.css +2 -3
- package/llms.txt +28 -4
- package/manifest.json +41 -4
- package/package.json +1 -1
- package/utils/formatBytes.js +29 -13
- package/utils/themeScript.js +6 -8
- 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 {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
17
|
-
|
|
17
|
+
function h(e) {
|
|
18
|
+
return e === void 0 ? [] : Array.isArray(e) ? e : [e];
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 };
|