@overdoser/react-toolkit 0.19.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.
- package/AGENTS.md +2 -2
- package/CHANGELOG.md +47 -0
- package/components/Accordion/Accordion.js +160 -177
- package/components/Accordion/Accordion.module.js +20 -0
- package/components/ActionButton/ActionButton.js +155 -209
- package/components/ActionButton/ActionButton.module.js +25 -0
- package/components/ActionButton/CopyButton.js +52 -64
- package/components/Alert/Alert.js +92 -95
- package/components/Alert/Alert.module.js +18 -0
- package/components/Avatar/Avatar.js +44 -55
- package/components/Avatar/Avatar.module.js +23 -0
- package/components/Badge/Badge.js +16 -38
- package/components/Badge/Badge.module.js +17 -0
- package/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/components/Breadcrumbs/Breadcrumbs.js +52 -48
- package/components/Breadcrumbs/Breadcrumbs.module.js +10 -0
- package/components/Button/Button.js +35 -57
- package/components/Button/Button.module.js +25 -0
- package/components/Card/Card.js +94 -131
- package/components/Card/Card.module.js +35 -0
- 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.js +32 -0
- 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 +46 -41
- 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.js +32 -0
- package/components/CodeBlock/CodeBlock.js +111 -119
- package/components/CodeBlock/CodeBlock.module.js +23 -0
- package/components/CommandPalette/CommandPalette.js +387 -392
- package/components/CommandPalette/CommandPalette.module.js +28 -0
- package/components/ConfirmDialog/ConfirmDialog.d.ts +1 -1
- package/components/ConfirmDialog/ConfirmDialog.js +184 -199
- package/components/ConfirmDialog/ConfirmDialog.module.js +12 -0
- package/components/Divider/Divider.js +25 -36
- package/components/Divider/Divider.module.js +17 -0
- package/components/Draggable/Draggable.d.ts +1 -1
- package/components/Draggable/Draggable.js +157 -164
- package/components/Draggable/Draggable.module.js +10 -0
- package/components/Drawer/Drawer.js +104 -126
- package/components/Drawer/Drawer.module.js +66 -0
- package/components/Dropdown/Dropdown.js +175 -234
- package/components/Dropdown/Dropdown.module.js +29 -0
- package/components/Dropdown/DropdownItem.js +55 -58
- package/components/Dropdown/DropdownLabel.js +14 -11
- package/components/Dropdown/DropdownSeparator.js +12 -10
- 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.js +12 -0
- package/components/EmptyState/EmptyState.js +58 -55
- package/components/EmptyState/EmptyState.module.js +14 -0
- package/components/Form/Form.d.ts +1 -1
- package/components/Form/Form.js +32 -35
- package/components/Form/Form.module.js +16 -0
- 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.js +26 -0
- package/components/ImageViewer/useZoomPan.js +206 -137
- package/components/Kbd/Kbd.js +25 -22
- package/components/Kbd/Kbd.module.js +10 -0
- package/components/KeyValueList/KeyValueList.js +119 -123
- package/components/KeyValueList/KeyValueList.module.js +23 -0
- package/components/Link/Link.js +45 -59
- package/components/Link/Link.module.js +10 -0
- package/components/List/List.js +22 -46
- package/components/List/List.module.js +12 -0
- package/components/Loader/Loader.js +152 -182
- package/components/Loader/Loader.module.js +40 -0
- package/components/Modal/Modal.js +93 -105
- package/components/Modal/Modal.module.js +18 -0
- package/components/PageHeader/PageHeader.js +78 -72
- package/components/PageHeader/PageHeader.module.js +23 -0
- package/components/Pagination/Pagination.js +63 -84
- package/components/Pagination/Pagination.module.js +13 -0
- package/components/Pagination/paginationRange.js +15 -22
- package/components/Popover/Popover.js +110 -134
- package/components/Popover/Popover.module.js +12 -0
- package/components/ProgressBar/ProgressBar.d.ts +15 -1
- package/components/ProgressBar/ProgressBar.js +57 -90
- package/components/ProgressBar/ProgressBar.module.js +29 -0
- package/components/RelativeTime/RelativeTime.js +36 -43
- package/components/RelativeTime/RelativeTime.module.js +3 -0
- package/components/SegmentedControl/SegmentedControl.js +94 -130
- package/components/SegmentedControl/SegmentedControl.module.js +21 -0
- package/components/Skeleton/Skeleton.js +36 -50
- package/components/Skeleton/Skeleton.module.js +15 -0
- package/components/Spinner/Spinner.js +25 -25
- package/components/Spinner/Spinner.module.js +12 -0
- package/components/SplitButton/SplitButton.js +149 -196
- package/components/SplitButton/SplitButton.module.js +31 -0
- package/components/SplitPane/SplitPane.js +134 -170
- package/components/SplitPane/SplitPane.module.js +14 -0
- package/components/StatCard/StatCard.js +132 -125
- package/components/StatCard/StatCard.module.js +42 -0
- package/components/StatusDot/StatusDot.js +28 -39
- package/components/StatusDot/StatusDot.module.js +18 -0
- package/components/Table/Table.d.ts +41 -16
- package/components/Table/Table.js +383 -442
- package/components/Table/Table.module.js +42 -0
- package/components/Table/index.d.ts +1 -1
- package/components/Table/useTableSort.d.ts +1 -1
- package/components/Table/useTableSort.js +51 -42
- package/components/Tabs/Tabs.js +109 -161
- package/components/Tabs/Tabs.module.js +28 -0
- package/components/ThemeToggle/ThemeToggle.d.ts +2 -0
- package/components/ThemeToggle/ThemeToggle.js +122 -97
- package/components/ThemeToggle/ThemeToggle.module.js +13 -0
- package/components/Timeline/GanttTimeline.js +357 -318
- package/components/Timeline/GanttTimeline.module.js +29 -0
- package/components/Timeline/HistoryTimeline.js +486 -450
- package/components/Timeline/HistoryTimeline.module.js +31 -0
- package/components/Timeline/Timeline.module.js +76 -0
- 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 +245 -178
- package/components/Timeline/TraceTimeline.js +823 -783
- package/components/Timeline/TraceTimeline.module.js +98 -0
- 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.js +29 -0
- package/components/Toast/Toast.d.ts +1 -1
- package/components/Toast/Toast.js +128 -128
- package/components/Toast/Toast.module.js +37 -0
- package/components/Toast/toastStore.js +58 -62
- package/components/ToggleIconButton/ToggleIconButton.js +35 -57
- package/components/ToggleIconButton/ToggleIconButton.module.js +15 -0
- package/components/Tooltip/Tooltip.d.ts +1 -1
- package/components/Tooltip/Tooltip.js +76 -85
- package/components/Tooltip/Tooltip.module.js +17 -0
- package/components/Typography/Typography.js +11 -36
- package/components/Typography/Typography.module.js +30 -0
- package/components/inputs/Checkbox/Checkbox.js +27 -51
- package/components/inputs/Checkbox/Checkbox.module.js +10 -0
- package/components/inputs/Checkbox/CheckboxGroup.js +53 -111
- package/components/inputs/Checkbox/CheckboxGroup.module.js +17 -0
- package/components/inputs/DatePicker/CalendarPanel.d.ts +1 -1
- package/components/inputs/DatePicker/CalendarPanel.js +263 -286
- package/components/inputs/DatePicker/CalendarPanel.module.js +23 -0
- package/components/inputs/DatePicker/DatePicker.js +115 -142
- package/components/inputs/DatePicker/DatePicker.module.js +14 -0
- package/components/inputs/DatePicker/dateUtils.js +32 -41
- package/components/inputs/DateTimePicker/DateTimePicker.js +226 -232
- package/components/inputs/DateTimePicker/DateTimePicker.module.js +20 -0
- 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.js +15 -0
- package/components/inputs/NumberInput/NumberInput.js +112 -132
- package/components/inputs/NumberInput/NumberInput.module.js +14 -0
- package/components/inputs/Radio/Radio.js +50 -73
- package/components/inputs/Radio/Radio.module.js +9 -0
- package/components/inputs/SearchInput/SearchInput.js +98 -115
- package/components/inputs/SearchInput/SearchInput.module.js +8 -0
- package/components/inputs/Select/Select.js +555 -682
- package/components/inputs/Select/Select.module.js +38 -0
- package/components/inputs/Slider/Slider.js +97 -128
- package/components/inputs/Slider/Slider.module.js +9 -0
- package/components/inputs/Switch/Switch.js +11 -8
- package/components/inputs/Textarea/Textarea.js +42 -58
- package/components/inputs/Textarea/Textarea.module.js +14 -0
- 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 -91
- package/hooks/usePortalPosition.js +25 -19
- package/hooks/useResizable.js +106 -104
- package/hooks/useTheme.d.ts +2 -2
- package/hooks/useTheme.js +28 -25
- package/index.css +2 -1
- package/index.d.ts +1 -1
- package/index.js +97 -215
- package/index.layered.css +2 -3
- package/llms.txt +9 -6
- package/manifest.json +66 -10
- package/package.json +1 -1
- package/utils/formatBytes.js +29 -13
- package/utils/themeScript.d.ts +2 -0
- package/utils/themeScript.js +6 -8
- package/utils/timeAgo.js +59 -32
- package/components/Accordion/Accordion.module.scss.js +0 -36
- package/components/ActionButton/ActionButton.module.scss.js +0 -47
- package/components/Alert/Alert.module.scss.js +0 -33
- package/components/Avatar/Avatar.module.scss.js +0 -43
- package/components/Badge/Badge.module.scss.js +0 -31
- package/components/Breadcrumbs/Breadcrumbs.module.scss.js +0 -17
- package/components/Button/Button.module.scss.js +0 -47
- package/components/Card/Card.module.scss.js +0 -60
- package/components/Chart/Chart.module.scss.js +0 -61
- package/components/Chip/Chip.module.scss.js +0 -59
- package/components/CodeBlock/CodeBlock.module.scss.js +0 -43
- package/components/CommandPalette/CommandPalette.module.scss.js +0 -49
- package/components/ConfirmDialog/ConfirmDialog.module.scss.js +0 -21
- package/components/Divider/Divider.module.scss.js +0 -31
- package/components/Draggable/Draggable.module.scss.js +0 -17
- package/components/Drawer/Drawer.module.scss.js +0 -119
- package/components/Dropdown/Dropdown.module.scss.js +0 -53
- package/components/Dropzone/Dropzone.module.scss.js +0 -21
- package/components/EmptyState/EmptyState.module.scss.js +0 -25
- package/components/Form/Form.module.scss.js +0 -29
- package/components/ImageViewer/ImageViewer.module.scss.js +0 -47
- package/components/Kbd/Kbd.module.scss.js +0 -17
- package/components/KeyValueList/KeyValueList.module.scss.js +0 -43
- package/components/Link/Link.module.scss.js +0 -16
- package/components/List/List.module.scss.js +0 -21
- package/components/Loader/Loader.module.scss.js +0 -70
- package/components/Modal/Modal.module.scss.js +0 -33
- package/components/PageHeader/PageHeader.module.scss.js +0 -43
- package/components/Pagination/Pagination.module.scss.js +0 -23
- package/components/Popover/Popover.module.scss.js +0 -21
- package/components/ProgressBar/ProgressBar.module.scss.js +0 -51
- package/components/RelativeTime/RelativeTime.module.scss.js +0 -7
- package/components/SegmentedControl/SegmentedControl.module.scss.js +0 -39
- package/components/Skeleton/Skeleton.module.scss.js +0 -25
- package/components/Spinner/Spinner.module.scss.js +0 -20
- package/components/SplitButton/SplitButton.module.scss.js +0 -57
- package/components/SplitPane/SplitPane.module.scss.js +0 -25
- package/components/StatCard/StatCard.module.scss.js +0 -72
- package/components/StatusDot/StatusDot.module.scss.js +0 -32
- package/components/Table/Table.module.scss.js +0 -81
- package/components/Tabs/Tabs.module.scss.js +0 -53
- package/components/ThemeToggle/ThemeToggle.module.scss.js +0 -23
- package/components/Timeline/GanttTimeline.module.scss.js +0 -55
- package/components/Timeline/HistoryTimeline.module.scss.js +0 -59
- package/components/Timeline/Timeline.module.scss.js +0 -141
- package/components/Timeline/TraceTimeline.module.scss.js +0 -189
- package/components/Timer/Timer.module.scss.js +0 -55
- package/components/Toast/Toast.module.scss.js +0 -62
- package/components/ToggleIconButton/ToggleIconButton.module.scss.js +0 -27
- package/components/Tooltip/Tooltip.module.scss.js +0 -30
- package/components/Typography/Typography.module.scss.js +0 -53
- package/components/inputs/Checkbox/Checkbox.module.scss.js +0 -17
- package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +0 -31
- package/components/inputs/DatePicker/CalendarPanel.module.scss.js +0 -41
- package/components/inputs/DatePicker/DatePicker.module.scss.js +0 -25
- package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +0 -37
- package/components/inputs/Input/Input.module.scss.js +0 -27
- package/components/inputs/NumberInput/NumberInput.module.scss.js +0 -25
- package/components/inputs/Radio/Radio.module.scss.js +0 -15
- package/components/inputs/SearchInput/SearchInput.module.scss.js +0 -13
- package/components/inputs/Select/Select.module.scss.js +0 -73
- package/components/inputs/Slider/Slider.module.scss.js +0 -15
- package/components/inputs/Textarea/Textarea.module.scss.js +0 -25
package/AGENTS.md
CHANGED
|
@@ -25,7 +25,7 @@ For exhaustive component reference (every prop, every variant, every signature),
|
|
|
25
25
|
```
|
|
26
26
|
It wraps all toolkit CSS in a `crk` cascade layer, so any of your own *unlayered* rules beat it deterministically. See "Customizing styles" below.
|
|
27
27
|
|
|
28
|
-
4. **Dark mode (optional):** put `THEME_INIT_SCRIPT` in `<head>`
|
|
28
|
+
4. **Dark mode (optional, opt-in):** with no `data-theme` the toolkit is light, so upgrading never changes an app's look. To offer dark mode put `THEME_INIT_SCRIPT` in `<head>` (applies the stored choice before first paint; writes `system` when nothing is stored) and drop `<ThemeToggle />` in the header. A dark-only app just sets `data-theme="dark"` on `<html>`. `data-theme` on any element forces a theme for that subtree. Never hand-roll a theme switch or a second token set.
|
|
29
29
|
|
|
30
30
|
## Import rules
|
|
31
31
|
|
|
@@ -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,53 @@ 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
|
+
|
|
21
|
+
## [0.20.0]
|
|
22
|
+
|
|
23
|
+
Follow-ups from rolling 0.19.0 out to sixteen apps. Dark mode becomes opt-in
|
|
24
|
+
(a light-only app no longer turns dark on a dark-OS machine), the accent
|
|
25
|
+
tokens follow the app's primary, and `Table` gets a proper display-column
|
|
26
|
+
type. Apps that relied on 0.19.0 following the OS with no attribute must now
|
|
27
|
+
set `data-theme="system"` on `<html>`.
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- **Dark mode is opt-in.** With no `data-theme` the toolkit is light again;
|
|
32
|
+
`data-theme="system"` on `<html>` follows the OS. 0.19.0 followed the OS
|
|
33
|
+
by default, which flipped light-only apps to dark on dark-OS machines.
|
|
34
|
+
`useTheme`, `ThemeToggle` and `THEME_INIT_SCRIPT` now write `system`
|
|
35
|
+
instead of removing the attribute, so apps that adopted them are
|
|
36
|
+
unaffected. `ThemeToggle` and `getThemeInitScript` take `defaultTheme`.
|
|
37
|
+
- **`Table`** — `ColumnDef` is now `DataColumnDef | DisplayColumnDef`: a
|
|
38
|
+
data column keeps `key: keyof T` (a misspelled key is a type error again), a
|
|
39
|
+
column with no backing field (`'actions'`) is `{ id, render(row, index) }`
|
|
40
|
+
with a required renderer and row-typed callbacks. Rows may be any `object`
|
|
41
|
+
(interface-typed rows no longer fail `Record<string, unknown>`);
|
|
42
|
+
`useTableSort` is relaxed the same way.
|
|
43
|
+
|
|
44
|
+
### Fixed
|
|
45
|
+
|
|
46
|
+
- **Tokens** — `--crk-color-primary-text` and `--crk-color-primary-selected`
|
|
47
|
+
derive from `--crk-color-primary` with `color-mix` instead of fixed indigo,
|
|
48
|
+
so an app's accent carries into tints and dark mode.
|
|
49
|
+
- **`THEME_INIT_SCRIPT`** — a storage read that throws (blocked cookies,
|
|
50
|
+
sandboxed iframe) no longer skips the fallback theme.
|
|
51
|
+
- **`usePersistedState`** — two hooks on the same empty key each got the
|
|
52
|
+
first hook's initial value; each now falls back to its own.
|
|
53
|
+
|
|
7
54
|
## [0.19.0]
|
|
8
55
|
|
|
9
56
|
The survey release: everything the ~/GITCRK projects kept hand-rolling, plus
|
|
@@ -1,180 +1,163 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
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 = 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 };
|