@overdoser/react-toolkit 0.18.0 → 0.19.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 (156) hide show
  1. package/AGENTS.md +51 -7
  2. package/CHANGELOG.md +129 -0
  3. package/components/Accordion/Accordion.d.ts +94 -0
  4. package/components/Accordion/Accordion.js +180 -0
  5. package/components/Accordion/Accordion.module.scss.js +36 -0
  6. package/components/Accordion/index.d.ts +2 -0
  7. package/components/Alert/Alert.d.ts +29 -1
  8. package/components/Alert/Alert.js +44 -30
  9. package/components/Alert/Alert.module.scss.js +24 -16
  10. package/components/Alert/index.d.ts +1 -1
  11. package/components/Card/Card.d.ts +86 -0
  12. package/components/Card/Card.js +132 -0
  13. package/components/Card/Card.module.scss.js +60 -0
  14. package/components/Card/index.d.ts +2 -0
  15. package/components/Chip/Chip.d.ts +86 -0
  16. package/components/Chip/Chip.js +141 -0
  17. package/components/Chip/Chip.module.scss.js +59 -0
  18. package/components/Chip/index.d.ts +2 -0
  19. package/components/CodeBlock/CodeBlock.d.ts +78 -0
  20. package/components/CodeBlock/CodeBlock.js +120 -0
  21. package/components/CodeBlock/CodeBlock.module.scss.js +43 -0
  22. package/components/CodeBlock/index.d.ts +2 -0
  23. package/components/CommandPalette/CommandPalette.d.ts +141 -0
  24. package/components/CommandPalette/CommandPalette.js +397 -0
  25. package/components/CommandPalette/CommandPalette.module.scss.js +49 -0
  26. package/components/CommandPalette/index.d.ts +2 -0
  27. package/components/ConfirmDialog/ConfirmDialog.d.ts +119 -0
  28. package/components/ConfirmDialog/ConfirmDialog.js +201 -0
  29. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +21 -0
  30. package/components/ConfirmDialog/index.d.ts +2 -0
  31. package/components/Drawer/Drawer.d.ts +1 -0
  32. package/components/Drawer/Drawer.js +35 -36
  33. package/components/Drawer/Drawer.module.scss.js +20 -18
  34. package/components/Dropdown/Dropdown.d.ts +47 -7
  35. package/components/Dropdown/Dropdown.js +174 -81
  36. package/components/Dropdown/Dropdown.module.scss.js +40 -22
  37. package/components/Dropdown/DropdownItem.d.ts +31 -2
  38. package/components/Dropdown/DropdownItem.js +54 -27
  39. package/components/Dropdown/DropdownLabel.d.ts +11 -0
  40. package/components/Dropdown/DropdownLabel.js +11 -0
  41. package/components/Dropdown/DropdownSeparator.d.ts +12 -0
  42. package/components/Dropdown/DropdownSeparator.js +11 -0
  43. package/components/Dropdown/dropdownContext.d.ts +6 -0
  44. package/components/Dropdown/dropdownContext.js +5 -0
  45. package/components/Dropdown/index.d.ts +8 -2
  46. package/components/Dropdown/useContextMenu.d.ts +32 -0
  47. package/components/Dropdown/useContextMenu.js +18 -0
  48. package/components/EmptyState/EmptyState.d.ts +53 -0
  49. package/components/EmptyState/EmptyState.js +55 -0
  50. package/components/EmptyState/EmptyState.module.scss.js +25 -0
  51. package/components/EmptyState/index.d.ts +2 -0
  52. package/components/Form/FormField.js +25 -24
  53. package/components/ImageViewer/ImageViewer.d.ts +105 -0
  54. package/components/ImageViewer/ImageViewer.js +201 -0
  55. package/components/ImageViewer/ImageViewer.module.scss.js +47 -0
  56. package/components/ImageViewer/index.d.ts +4 -0
  57. package/components/ImageViewer/useZoomPan.d.ts +94 -0
  58. package/components/ImageViewer/useZoomPan.js +141 -0
  59. package/components/Kbd/Kbd.d.ts +26 -0
  60. package/components/Kbd/Kbd.js +22 -0
  61. package/components/Kbd/Kbd.module.scss.js +17 -0
  62. package/components/Kbd/index.d.ts +2 -0
  63. package/components/KeyValueList/KeyValueList.d.ts +84 -0
  64. package/components/KeyValueList/KeyValueList.js +127 -0
  65. package/components/KeyValueList/KeyValueList.module.scss.js +43 -0
  66. package/components/KeyValueList/index.d.ts +2 -0
  67. package/components/Modal/Modal.d.ts +1 -0
  68. package/components/Modal/Modal.js +40 -41
  69. package/components/Modal/Modal.module.scss.js +18 -16
  70. package/components/PageHeader/PageHeader.d.ts +61 -0
  71. package/components/PageHeader/PageHeader.js +73 -0
  72. package/components/PageHeader/PageHeader.module.scss.js +43 -0
  73. package/components/PageHeader/index.d.ts +2 -0
  74. package/components/ProgressBar/ProgressBar.d.ts +74 -0
  75. package/components/ProgressBar/ProgressBar.js +90 -0
  76. package/components/ProgressBar/ProgressBar.module.scss.js +51 -0
  77. package/components/ProgressBar/index.d.ts +2 -0
  78. package/components/RelativeTime/RelativeTime.d.ts +45 -0
  79. package/components/RelativeTime/RelativeTime.js +43 -0
  80. package/components/RelativeTime/RelativeTime.module.scss.js +7 -0
  81. package/components/RelativeTime/index.d.ts +2 -0
  82. package/components/SegmentedControl/SegmentedControl.d.ts +84 -0
  83. package/components/SegmentedControl/SegmentedControl.js +131 -0
  84. package/components/SegmentedControl/SegmentedControl.module.scss.js +39 -0
  85. package/components/SegmentedControl/index.d.ts +2 -0
  86. package/components/SplitPane/SplitPane.d.ts +61 -0
  87. package/components/SplitPane/SplitPane.js +171 -0
  88. package/components/SplitPane/SplitPane.module.scss.js +25 -0
  89. package/components/SplitPane/index.d.ts +2 -0
  90. package/components/StatCard/StatCard.d.ts +105 -0
  91. package/components/StatCard/StatCard.js +127 -0
  92. package/components/StatCard/StatCard.module.scss.js +72 -0
  93. package/components/StatCard/index.d.ts +2 -0
  94. package/components/StatusDot/StatusDot.d.ts +33 -0
  95. package/components/StatusDot/StatusDot.js +39 -0
  96. package/components/StatusDot/StatusDot.module.scss.js +32 -0
  97. package/components/StatusDot/index.d.ts +2 -0
  98. package/components/Table/Table.d.ts +100 -2
  99. package/components/Table/Table.js +371 -210
  100. package/components/Table/Table.module.scss.js +68 -46
  101. package/components/Table/index.d.ts +1 -1
  102. package/components/ThemeToggle/ThemeToggle.d.ts +38 -0
  103. package/components/ThemeToggle/ThemeToggle.js +97 -0
  104. package/components/ThemeToggle/ThemeToggle.module.scss.js +23 -0
  105. package/components/ThemeToggle/index.d.ts +2 -0
  106. package/components/inputs/Checkbox/Checkbox.d.ts +2 -0
  107. package/components/inputs/Checkbox/Checkbox.js +29 -28
  108. package/components/inputs/Checkbox/Checkbox.module.scss.js +8 -6
  109. package/components/inputs/Input/Input.d.ts +33 -1
  110. package/components/inputs/Input/Input.js +94 -35
  111. package/components/inputs/Input/Input.module.scss.js +14 -12
  112. package/components/inputs/Radio/Radio.d.ts +5 -4
  113. package/components/inputs/Radio/Radio.js +55 -50
  114. package/components/inputs/Radio/Radio.module.scss.js +12 -10
  115. package/components/inputs/SearchInput/SearchInput.d.ts +57 -0
  116. package/components/inputs/SearchInput/SearchInput.js +116 -0
  117. package/components/inputs/SearchInput/SearchInput.module.scss.js +13 -0
  118. package/components/inputs/SearchInput/index.d.ts +2 -0
  119. package/components/inputs/Select/Select.d.ts +52 -0
  120. package/components/inputs/Select/Select.js +494 -385
  121. package/components/inputs/Select/Select.module.scss.js +34 -30
  122. package/components/inputs/Switch/Switch.d.ts +15 -0
  123. package/components/inputs/Switch/Switch.js +8 -0
  124. package/components/inputs/Switch/index.d.ts +2 -0
  125. package/hooks/useDebouncedValue.d.ts +15 -0
  126. package/hooks/useDebouncedValue.js +15 -0
  127. package/hooks/useElementSize.d.ts +20 -0
  128. package/hooks/useElementSize.js +23 -0
  129. package/hooks/useKeyboard.d.ts +49 -5
  130. package/hooks/useKeyboard.js +66 -16
  131. package/hooks/useMediaQuery.d.ts +14 -0
  132. package/hooks/useMediaQuery.js +16 -0
  133. package/hooks/useNow.d.ts +14 -0
  134. package/hooks/useNow.js +35 -0
  135. package/hooks/usePersistedState.d.ts +30 -0
  136. package/hooks/usePersistedState.js +96 -0
  137. package/hooks/useResizable.d.ts +66 -0
  138. package/hooks/useResizable.js +105 -0
  139. package/hooks/useTheme.d.ts +33 -0
  140. package/hooks/useTheme.js +27 -0
  141. package/index.css +1 -1
  142. package/index.d.ts +58 -4
  143. package/index.js +208 -132
  144. package/index.layered.css +1 -1
  145. package/llms.txt +619 -25
  146. package/manifest.json +1739 -91
  147. package/package.json +1 -1
  148. package/recipes/confirm-modal.tsx +65 -53
  149. package/recipes/floating-copy-button.tsx +32 -28
  150. package/utils/formatBytes.d.ts +21 -0
  151. package/utils/formatBytes.js +14 -0
  152. package/utils/index.d.ts +6 -0
  153. package/utils/themeScript.d.ts +17 -0
  154. package/utils/themeScript.js +9 -0
  155. package/utils/timeAgo.d.ts +33 -0
  156. package/utils/timeAgo.js +37 -0
package/AGENTS.md CHANGED
@@ -25,6 +25,8 @@ 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>` so the stored choice applies before first paint, and drop `<ThemeToggle />` in the header. No attribute = follow the OS; `data-theme="dark"` on any element forces it for that subtree. Never hand-roll a theme switch or a second token set.
29
+
28
30
  ## Import rules
29
31
 
30
32
  - Always import from the package root: `import { Button } from '@overdoser/react-toolkit'`. Do **not** reach into subpaths (`@overdoser/react-toolkit/dist/...`) — they're not part of the public API.
@@ -47,21 +49,22 @@ For exhaustive component reference (every prop, every variant, every signature),
47
49
  - Few options, native UX OK → `<Select options={...} />`.
48
50
  - Many options, want a search filter → `<Select searchable options={...} />`.
49
51
  - Multi-pick with chips → `<Select multiple options={...} onValuesChange={...} />`.
52
+ - 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.
50
53
  - You want it to look like a "menu trigger" instead of a form input → `<Dropdown options={...} value={...} onChange={...} />` (select-mode dropdown).
51
54
 
52
55
  - **Need to pick several values from a small fixed set?** → `<CheckboxGroup options={...} value={...} onChange={...} />` (a checkbox list, or `variant="chips"` for toggle chips). For a large/searchable set, prefer `<Select multiple>` instead.
53
56
 
54
- - **Need a menu (Edit / Delete / Archive)?** → `<Dropdown trigger={...}>` with `<DropdownItem>` children.
57
+ - **Need a menu (Edit / Delete / Archive)?** → `<Dropdown trigger={...}>` with `<DropdownItem>` children — `icon`, `shortcut={<Kbd …/>}`, `description`, `danger` for destructive items, `checked` for toggles; `<DropdownSeparator>` and `<DropdownLabel>` for structure. **Right-click menu?** → `const menu = useContextMenu()`; put `menu.onContextMenu` on the area and `anchor={menu.anchor} open={menu.open} onOpenChange={menu.onOpenChange}` on the `Dropdown`.
55
58
 
56
59
  - **Need row actions with one default exposed (table "Operations" column)?** → `<SplitButton actions={[...]} />` — flat list of `{ label, onClick?, href?, danger?, disabled? }`; the first action is the visible button, the rest live behind the chevron. `href` actions render as real anchors. Use `Dropdown` menu mode instead when all actions are equal-weight.
57
60
 
58
- - **Need a copy-to-clipboard button?** → `<CopyButton value={text} />` (icon + "Copy"→"Copied" morph), or `<CopyButton value={text} iconOnly aria-label="Copy" />` for icon-only. **Other one-shot actions with success feedback (send, download, delete-with-confirm)?** → `<ActionButton icon label successLabel onAction />` — async `onAction` gets a pending spinner; call `context.setProgress(0–100)` inside it for a determinate % + fill bar (downloads); `confirmLabel` adds a two-step confirm for destructive actions. Use plain `Button` when no phase feedback is needed.
61
+ - **Need a copy-to-clipboard button?** → `<CopyButton value={text} />` (icon + "Copy"→"Copied" morph; `value` may be a function returning a string or a `Promise<string>` for lazy/async text, `onCopied` fires after), or `<CopyButton value={text} iconOnly aria-label="Copy" />` for icon-only. **Other one-shot actions with success feedback (send, download, delete-with-confirm)?** → `<ActionButton icon label successLabel onAction />` — async `onAction` gets a pending spinner; call `context.setProgress(0–100)` inside it for a determinate % + fill bar (downloads); `confirmLabel` adds a two-step confirm for destructive actions. Use plain `Button` when no phase feedback is needed.
59
62
 
60
63
  - **Need a like/save/bookmark toggle?** → `<ToggleIconButton icon={<HeartIcon />} aria-label="Like" />` — round icon-only toggle with `aria-pressed`, fill + pop on toggle, optional `burst` ring, `activeColor` for semantic colors. Controlled (`pressed` + `onPressedChange`, optimistic) or uncontrolled (`defaultPressed`). Not for text toggles — it's icon-only by design.
61
64
 
62
65
  - **Need a tooltip / hover card / contextual panel?** → `<Popover trigger={...} content={...} />`.
63
66
 
64
- - **Need a confirm prompt or a full dialog?** → `<Modal>` with `Modal.Header`/`Body`/`Footer`. Always provide either `aria-label` or use a `Modal.Header` (it's auto-wired as `aria-labelledby`).
67
+ - **Need a confirm prompt ("Delete this?")?** → mount `<ConfirmProvider>` once, then `const confirm = useConfirm(); if (await confirm({ title, description, danger: true, confirmLabel: 'Delete', onConfirm: () => api.remove(id) })) …` — never `window.confirm`. `requireText` adds type-to-confirm. The controlled `<ConfirmDialog open onConfirm onCancel>` exists for custom flows; `ActionButton confirmLabel` covers an inline two-step confirm on a button. **A full dialog?** → `<Modal>` with `Modal.Header`/`Body`/`Footer`. Always provide either `aria-label` or use a `Modal.Header` (it's auto-wired as `aria-labelledby`).
65
68
 
66
69
  - **Need a slide-in side panel?** → `<Drawer open onClose side="right">` with `Drawer.Header`/`Body`/`Footer`. Same focus-trap/scroll-lock/Escape behavior as `Modal`, but anchored to a screen edge. Use `Modal` for centered dialogs, `Drawer` for side panels.
67
70
 
@@ -81,17 +84,57 @@ For exhaustive component reference (every prop, every variant, every signature),
81
84
 
82
85
  - **Need a countdown / stopwatch / elapsed display?** → `<Timer mode="countdown|stopwatch" duration={…} variant="digital|ring" label="…" />`. Drive it with `autoStart` + an imperative ref (`start`/`pause`/`reset`/`restart`), or make it display-only with `value`.
83
86
 
87
+ - **Need a lightbox / image gallery viewer?** → `<ImageViewer open onClose items index onIndexChange showThumbnails />`. Zoom/pan elsewhere → `useZoomPan()`.
88
+
89
+ - **Need a resizable sidebar / editor-preview / terminal split?** → `<SplitPane defaultSize minSize collapsible persistKey>` with two children (nest for 3-way). Custom resizable panel → `useResizable()` and spread `handleProps` on your handle.
90
+
84
91
  - **Need a movable panel / floating widget the user can drag around?** → `<Draggable>` wrapping any content. Add a `<Draggable.Handle>` (e.g. a title bar) to restrict the grab area; without one the whole surface drags. Uncontrolled by default (`defaultPosition`); pass `position` + `onDrag` to control it. It's a free-move/reposition primitive — not a sortable list or drag-and-drop-between-zones helper.
85
92
 
86
93
  - **Need transient notifications (toasts)?** → Mount `<ToastProvider>` once near the root (sets `position` / `duration` / `max`); it's the renderer and owns the portal/stack — do NOT render toast JSX yourself. To trigger, import the standalone `toast({ variant, title, description })` and call it from anywhere (no hook/context needed); `toast.dismiss(id)` / `toast.dismissAll()` are attached. A `useToast()` hook returns the same `{ toast, dismiss, dismissAll }` if you prefer hook style.
87
94
 
88
95
  - **Need to switch between sections of content?** → `<Tabs>` with `Tabs.List` / `Tabs.Tab` / `Tabs.Panel`. Each `Tab` and its `Panel` share a `value`. Uncontrolled via `defaultValue` or controlled via `value` + `onValueChange`. Keyboard nav is built in.
89
96
 
90
- - **Need an inline status message?** → `<Alert variant="info|success|warning|danger">`. Add `title` for a heading, `onClose` to make it dismissible. For *transient* feedback prefer Toast; use Alert for persistent, in-flow messaging.
97
+ - **Need an inline status message?** → `<Alert variant="info|success|warning|danger">`. Add `title` for a heading, `onClose` to make it dismissible, `action` for a Retry/Undo button. **A full-width page banner (trial ending, offline)?** → `<Alert layout="banner" action onClose>`. For *transient* feedback prefer Toast; use Alert for persistent, in-flow messaging.
98
+
99
+ - **Need a view / period / mode switcher (pill buttons, no panels)?** → `<SegmentedControl options value onChange aria-label />`. Don't use panel-less `Tabs` for it. Multi-select version → `<CheckboxGroup variant="chips">`.
100
+
101
+ - **Need removable / selectable tags (filters, labels, recipients)?** → `<Chip onRemove />`, `<Chip selected onSelectedChange />`, grouped with `<ChipGroup max expandable>`. Read-only status pills stay `<Badge>`.
102
+
103
+ - **Need the page title block (title + actions + breadcrumbs + tabs)?** → `<PageHeader title actions breadcrumbs tabs onBack />`.
104
+
105
+ - **Need collapsible sections / FAQ?** → `<Accordion>` with `Accordion.Item` / `Trigger` / `Content` (or `items={[…]}`).
106
+
107
+ - **Need a label/value detail panel (profile, request headers, config)?** → `<KeyValueList items={[{ label, value, copyable, masked, href }]} layout="rows|grid|inline" />`. Not a `Table`.
108
+
109
+ - **Need KPI tiles?** → `<StatGrid><StatCard label value delta chart={<Sparkline />} /></StatGrid>`; `trendColor="positive-down"` for latency / cost.
110
+
111
+ - **Need a ⌘K command palette?** → `const palette = useCommandPalette(); <CommandPalette {...palette.paletteProps} items={[…]} recentIds={…} />` — groups, nested pages, shortcuts, `href` items, `filter={null}` + `loading` for remote results.
112
+
113
+ - **Need a search box?** → `<SearchInput onSearch hotkey="/" loading />` (debounce, clear, Escape, Kbd hint built in). Don't wire `Input` + `useDebouncedValue` by hand for this.
114
+
115
+ - **Need a toggle switch (on/off setting)?** → `<Switch label="…" checked onChange />` — the same control as `<Checkbox variant="switch">`; binds in `FormField` for a boolean field. Don't hand-roll one.
116
+
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
+
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
+
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
+
123
+ - **Need a "3 minutes ago" timestamp?** → `<RelativeTime value={date} />` (live, shared timer; `maxAge` to switch to an absolute date). The plain function is `timeAgo()`.
124
+
125
+ - **Need a light/dark switch?** → `<ThemeToggle />` (+ `THEME_INIT_SCRIPT` in `<head>`); read it with `useTheme()`. See the setup checklist.
126
+
127
+ - **Need a shortcut hint?** → `<Kbd keys={['⌘', 'K']} />` or `<Kbd>Esc</Kbd>`. **Need the shortcut itself?** → `useKeyboard({ 'mod+k': open })` (chords, skips inputs for plain keys).
128
+
129
+ - **Need a persisted preference (sidebar collapsed, theme, column visibility)?** → `usePersistedState(key, initial)`. **Debounced search text?** → `useDebouncedValue`. **Responsive branch?** → `useMediaQuery`. **Element size?** → `useElementSize`. **File sizes?** → `formatBytes`.
130
+
131
+ - **Need a status pill / count / tag?** → `<Badge>`. **A bare coloured status dot (online / degraded / saving…)?** → `<StatusDot status label pulse />`. For loading states: `<Loader>` (page / container loading — wrap content to overlay it without a height jump, `mode="overlay"` drop-in, or `mode="fullscreen"`; variants `dots|pulse|spinner|grid|morph`), `<Spinner>` (small inline indicator for buttons and text, inherits text color) and `<Skeleton>` (content placeholder — `variant="text|circle|rect"`, `lines` for multi-line text).
132
+
133
+ - **Need a code snippet?** → `<CodeBlock code language title lineNumbers />` (built-in copy button; `highlight` prop to plug a highlighter) and `<Code>` for inline. Don't hand-roll a `<pre>` + CopyButton.
91
134
 
92
- - **Need a status pill / count / tag?** → `<Badge>`. For loading states: `<Loader>` (page / container loading — wrap content to overlay it without a height jump, `mode="overlay"` drop-in, or `mode="fullscreen"`; variants `dots|pulse|spinner|grid|morph`), `<Spinner>` (small inline indicator for buttons and text, inherits text color) and `<Skeleton>` (content placeholder — `variant="text|circle|rect"`, `lines` for multi-line text).
135
+ - **Need a password field?** → `<Input type="password" revealable />`. **A text field with a clear button?** → `<Input clearable />`.
93
136
 
94
- - **Need a data table?** → `<Table>`.
137
+ - **Need a data table?** → `<Table>`. Row links/navigation → `onRowClick`; bulk operations → `selectable` + `rowKey` + `bulkActions`; async data → `loading`; column picker → `columnVisibility`; live-updating cells → `layout="fixed"`.
95
138
  - All data in memory → don't pass `onSort`; pass `pagination` (without `totalRows`) for client-side paging.
96
139
  - Data from a server → pass `sortConfig` + `onSort`, and `pagination` with `totalRows`.
97
140
  - Wide table / comparison matrix → `scrollable` (horizontal scroll), `dragScroll` (middle/right-button drag-to-pan, implies scrollable; left button keeps selection/clicks), `sticky: true` on the first column to pin it. Per-cell shading via `cellClassName`/`cellStyle` on the column def; `defaultSortDirection: 'desc'` for highest-first columns; remove buttons can live in `header` (call `e.stopPropagation()` when the column is sortable). See [recipes/comparison-table.tsx](./recipes/comparison-table.tsx).
@@ -171,7 +214,7 @@ Full copy-paste-able files live alongside this doc. Each is one self-contained f
171
214
  - [recipes/paginated-table.tsx](./recipes/paginated-table.tsx) — Client-side sortable + paginated table.
172
215
  - [recipes/server-side-table.tsx](./recipes/server-side-table.tsx) — Server-driven sort & pagination.
173
216
  - [recipes/comparison-table.tsx](./recipes/comparison-table.tsx) — Wide comparison matrix: sticky first column, drag-to-scroll, per-cell %DV bucket shading, removable columns, desc-first sort.
174
- - [recipes/confirm-modal.tsx](./recipes/confirm-modal.tsx) — Reusable destructive-action confirm dialog.
217
+ - [recipes/confirm-modal.tsx](./recipes/confirm-modal.tsx) — `ConfirmProvider` + `useConfirm()` wiring: provider at the root, async delete with toast, type-to-confirm.
175
218
  - [recipes/searchable-multi-select.tsx](./recipes/searchable-multi-select.tsx) — Multi-select with search and form integration.
176
219
  - [recipes/dropdown-menu.tsx](./recipes/dropdown-menu.tsx) — Row action menu with `Dropdown` + `DropdownItem`.
177
220
  - [recipes/dashboard-charts.tsx](./recipes/dashboard-charts.tsx) — Multi-chart dashboard layout with KPI tiles + Sparkline.
@@ -182,6 +225,7 @@ Full copy-paste-able files live alongside this doc. Each is one self-contained f
182
225
  - [recipes/trading-chart.tsx](./recipes/trading-chart.tsx) — Full-stack `TradingChart` with a resolution selector, in-memory datafeed adapter, and the SMA/EMA/Bollinger/RSI/Volume indicator stack. Swap `createMemoryDatafeed` for your own REST/WebSocket adapter; everything else carries over.
183
226
  - [recipes/tag-input.tsx](./recipes/tag-input.tsx) — Tag-input pattern via `<Select multiple allowCreate>`: pick from existing tags or type a new one + Enter to create. `onCreate` persists the new tag back into the options list. Wired through `<FormField>` for react-hook-form integration.
184
227
  - [recipes/live-timeline-feed.tsx](./recipes/live-timeline-feed.tsx) — Live event feeds into `TraceTimeline` / `HistoryTimeline` / `GanttTimeline`: consumer-side push/complete merge hooks (start appends with `end: null`, complete merges response fields + stamps `end`), optional WebSocket source, and consumer-side correlation filtering.
228
+ - [recipes/floating-copy-button.tsx](./recipes/floating-copy-button.tsx) — Copy button floating over a non-code box (solid wrapper surface trick); code itself goes through `<CodeBlock>`.
185
229
  - [recipes/multi-select-in-modal.tsx](./recipes/multi-select-in-modal.tsx) — `<Select multiple>` inside `<Modal size="sm">`. Default `portal={true}` lets the menu escape the modal's `overflow: hidden` and sit above the modal via `--crk-z-floating`, so the modal does NOT need to be sized to contain the menu. Pair with `closeOnBackdrop={false}` so a backdrop click closes the open menu only, not the modal.
186
230
 
187
231
  ## Anti-patterns to refuse
package/CHANGELOG.md CHANGED
@@ -4,6 +4,135 @@ 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.19.0]
8
+
9
+ The survey release: everything the ~/GITCRK projects kept hand-rolling, plus
10
+ dark mode. Twenty-one new components, a hooks/utils bundle, and upgrades to
11
+ Dropdown, Table, Select, Alert and Input. Two behaviour changes are listed
12
+ under *Changed* (Dropdown items close the menu; `useKeyboard` skips plain keys
13
+ while typing).
14
+
15
+ ### Added
16
+
17
+ - **Dark mode** — the stylesheet now ships a full dark token set. No
18
+ attribute follows the OS; `data-theme="light" | "dark"` on `<html>` (or on
19
+ any element, for a subtree) forces one. New tokens for text-on-tint
20
+ (`--crk-color-*-text`), backdrops and hover overlays; hard-coded surface
21
+ colours in Checkbox, Radio, Modal, Drawer, Badge, Chip, Alert, Toast,
22
+ Dropdown, SplitButton and the Timelines now use tokens (light output
23
+ unchanged). **`ThemeToggle`**, **`useTheme()`** and
24
+ **`THEME_INIT_SCRIPT`** (a pre-paint `<head>` script) complete it.
25
+ - **`Switch`** — the toggle switch as its own export (an alias of
26
+ `<Checkbox variant="switch">`, same a11y/form behaviour) so it is findable.
27
+ - **`Kbd`** — keyboard key cap; `keys={['⌘', 'K']}` renders a combination.
28
+ - **`EmptyState`** — centered placeholder for empty lists / no results / load
29
+ errors: icon (built-in per variant), title, description, `action` slot,
30
+ `variant="error"` (role=alert), sizes, `bordered` dashed frame.
31
+ - **`StatusDot`** — coloured indicator dot with `status`, `pulse`, optional
32
+ `label`, sizes and a `color` override.
33
+ - **`ProgressBar`** — determinate / indeterminate, `label` + `showValue`,
34
+ `thresholds` (colour by value), `segments` (discrete steps, `showCurrent`
35
+ for done / current / remaining shades, `shape="square"` for a flat strip),
36
+ sizes, variants.
37
+ - **`Card`** — surface with `Card.Header` / `Card.Title` / `Card.Body` /
38
+ `Card.Footer`; `variant` outlined / elevated / filled, `padding`,
39
+ `interactive` (keyboard-operable with `onClick`, anchor with `href`),
40
+ `selected`, `accent` stripe.
41
+ - **`RelativeTime`** — live "3 minutes ago" `<time>` element via
42
+ `Intl.RelativeTimeFormat`, with `maxAge` fallback to an absolute date.
43
+ - **`CommandPalette`** + **`useCommandPalette`** — ⌘K palette with fuzzy
44
+ filtering and match highlighting, groups, recent items, nested pages,
45
+ `Kbd` shortcuts, `href` items, and a remote mode (`filter={null}` +
46
+ `loading`).
47
+ - **`ConfirmDialog`** + **`ConfirmProvider`** / **`useConfirm()`** — the
48
+ confirm-modal recipe as a component: `danger`, `requireText`
49
+ (type-to-confirm), async `onConfirm` with loading + error display, and a
50
+ promise API (`if (await confirm({ … })) …`) to replace `window.confirm`.
51
+ - **`CodeBlock`** + **`Code`** — `<pre><code>` with a built-in copy button
52
+ (floating or in a title/language header), line numbers with highlighted
53
+ lines, wrap toggle, `maxHeight`, and a `highlight` hook for an external
54
+ highlighter. The floating-copy-button recipe now points here.
55
+ - **`Dropdown`** — menu items grow `danger`, `icon`, `shortcut`, `description`
56
+ and `checked` (menuitemcheckbox); new `DropdownSeparator` and
57
+ `DropdownLabel`; keyboard navigation (arrows wrap, Home/End, typeahead);
58
+ controlled `open` / `onOpenChange`; and a context-menu mode via
59
+ `anchor={{ x, y }}` with a `useContextMenu()` helper.
60
+ - **`Table`** — `loading` (overlay, rows keep their height; skeleton rows
61
+ when empty), `onRowClick` (keyboard-operable rows; inner buttons keep
62
+ working), row selection (`selectable`, `selectedKeys` /
63
+ `onSelectionChange`, `isRowSelectable`, page-scoped select-all, Shift-range)
64
+ with a `bulkActions` bar, `columnVisibility`, and `layout="fixed"`.
65
+ - **`Alert`** — `action` slot, `layout="banner"` for full-width page
66
+ banners, `size="sm"`.
67
+ - **`Input`** — `revealable` password toggle (controlled via `revealed` /
68
+ `onRevealedChange`) and `clearable` (fires `onChange` with `''` + `onClear`).
69
+ - **`Modal`** / **`Drawer`** — `headerTitle` class on the new title wrapper.
70
+ - **`SegmentedControl`** — single-select button group (`role="radiogroup"`,
71
+ roving tabindex, icons, counts, tooltips, `href` items, sizes, shapes,
72
+ filled / outlined).
73
+ - **`Chip`** + **`ChipGroup`** — interactive tags: removable, toggleable
74
+ (`selected`), clickable, colours / outline / sizes; `ChipGroup max` with a
75
+ `+N` overflow that can expand.
76
+ - **`PageHeader`** — breadcrumbs, back link, title + badge, subtitle /
77
+ description / meta, actions slot, tabs slot, sticky.
78
+ - **`Accordion`** — single / multiple, controlled, `collapsible`,
79
+ `keepMounted`, three variants, `items` shorthand, keyboard navigation,
80
+ CSS-grid height animation.
81
+ - **`KeyValueList`** — `<dl>` rows / grid / inline layouts with copyable,
82
+ masked, monospace and linked values, hints and empty fallbacks.
83
+ - **`StatCard`** + **`StatGrid`** — KPI tile with delta + trend colour
84
+ (`positive-down` for latency-style metrics), icon / sparkline / footer
85
+ slots, loading skeleton, and a responsive grid.
86
+ - **`SearchInput`** — `Input` preconfigured for search: debounced
87
+ `onSearch`, Enter bypass, clear, `loading`, focus `hotkey` with a `Kbd`
88
+ hint, Escape-to-clear.
89
+ - **`Select`** (searchable / multi) — remote search: `onSearch` (debounced,
90
+ `searchDebounce`, `minSearchLength` + `searchPrompt`), `loading` /
91
+ `loadingMessage`, `noResultsMessage`, `highlightMatches` (local mode) and
92
+ `selectedLabels` so chips stay labelled when results move on. No separate
93
+ Combobox needed.
94
+ - **`ImageViewer`** + **`useZoomPan`** — lightbox with prev/next, counter,
95
+ thumbnails, zoom/pan (wheel, pinch, double-click, keyboard), caption and
96
+ download; `renderSlide` for non-image slides.
97
+ - **`SplitPane`** + **`useResizable`** — drag / keyboard resizable split
98
+ (horizontal or vertical, collapsible, `persistKey`), with the engine
99
+ exported as a hook.
100
+ - **Hooks** — `usePersistedState` (localStorage/sessionStorage, SSR- and
101
+ private-mode-safe, cross-tab sync), `useDebouncedValue`, `useMediaQuery`,
102
+ `useElementSize`, `useNow` (shared timer per interval).
103
+ - **Utils** — `formatBytes`, `timeAgo`.
104
+ - **`Checkbox`**, **`Radio`**, **`RadioGroup`** — `error?: boolean` prop (danger
105
+ border, like `Input`). `RadioGroup` applies it to every `Radio` inside and now
106
+ forwards its ref to the group element, so react-hook-form can focus it.
107
+
108
+ ### Changed
109
+
110
+ - **`Dropdown`** — activating a `DropdownItem` now closes the menu (as
111
+ `onClose`'s docs always said); checkable items stay open. `closeOnSelect`
112
+ on the item overrides either way.
113
+ - **`useKeyboard`** — accepts chords (`'mod+k'`, `'ctrl+shift+z'`), an
114
+ options object (`active`, `ignoreEditable`, `preventDefault`, `target`), and
115
+ reads handlers through a ref so inline objects no longer re-subscribe the
116
+ listener on every render. Plain printable keys are now skipped while typing
117
+ in an editable element (pass `ignoreEditable: false` for the old behaviour);
118
+ bare keys no longer fire while Ctrl/Alt/Meta is held. The old
119
+ `useKeyboard(handlers, active)` signature still works.
120
+
121
+ ### Fixed
122
+
123
+ - **`Modal`** / **`Drawer`** — the auto `aria-labelledby` pointed at the whole
124
+ header, so a dialog with a close button was announced as "Title ×". The id
125
+ now sits on a title wrapper.
126
+ - **`FormField`** — `Checkbox` and `Radio` children received `error` and (for a
127
+ boolean field) `value` as raw DOM attributes: React warned about a non-boolean
128
+ attribute and the checkbox submitted `value="false"`/`"true"`. Both inputs now
129
+ accept `error` and a boolean field value is bridged to `checked` only.
130
+ - **`Select`** (native) — `onValuesChange` and the other multi-only props
131
+ (`allowCreate`, `onCreate`, `createLabel`, `closeOnSelect`,
132
+ `clearSearchOnSelect`, `portal`) were spread onto the native `<select>`,
133
+ tripping React's "Unknown event handler property" warning on every
134
+ `<FormField><Select /></FormField>`. They are dropped in native mode.
135
+
7
136
  ## [0.18.0]
8
137
 
9
138
  A loader for pages and containers.
@@ -0,0 +1,94 @@
1
+ import { ComponentPropsWithRef, ReactNode } from 'react';
2
+ export type AccordionType = 'single' | 'multiple';
3
+ export type AccordionVariant = 'default' | 'bordered' | 'separated';
4
+ export type AccordionSize = 'sm' | 'md';
5
+ export interface AccordionClasses {
6
+ root: string;
7
+ item: string;
8
+ itemOpen: string;
9
+ header: string;
10
+ trigger: string;
11
+ icon: string;
12
+ content: string;
13
+ contentInner: string;
14
+ }
15
+ export interface AccordionItemData {
16
+ /** Identifier of the item (used in `value`). */
17
+ value: string;
18
+ /** Trigger content. */
19
+ title: ReactNode;
20
+ /** Panel content. */
21
+ content: ReactNode;
22
+ /** Non-interactive when true. */
23
+ disabled?: boolean;
24
+ }
25
+ export interface AccordionProps extends Omit<ComponentPropsWithRef<'div'>, 'onChange'> {
26
+ /** One open item at a time, or any number. @default 'single' */
27
+ type?: AccordionType;
28
+ /** Controlled open value(s): a `string` for `single`, `string[]` for `multiple`. */
29
+ value?: string | string[];
30
+ /** Uncontrolled initial open value(s). */
31
+ defaultValue?: string | string[];
32
+ /** Called with the next value (`string` for `single`, `string[]` for `multiple`). */
33
+ onValueChange?: (value: string | string[]) => void;
34
+ /** In `single` mode, let the open item be closed by clicking it again. @default true */
35
+ collapsible?: boolean;
36
+ /** Keep closed panels mounted (and `hidden`) instead of unmounting them. @default false */
37
+ keepMounted?: boolean;
38
+ /** Item separation style. @default 'default' */
39
+ variant?: AccordionVariant;
40
+ /** Trigger/content sizing. @default 'md' */
41
+ size?: AccordionSize;
42
+ /** Disables every item. @default false */
43
+ disabled?: boolean;
44
+ /** Heading level wrapping each trigger. @default 3 */
45
+ headingLevel?: 2 | 3 | 4;
46
+ /** Data-driven shorthand instead of `Accordion.Item` children. */
47
+ items?: AccordionItemData[];
48
+ /** Override class names on internal elements. */
49
+ classes?: Partial<AccordionClasses>;
50
+ }
51
+ declare const AccordionRoot: import('react').ForwardRefExoticComponent<Omit<AccordionProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
52
+ export interface AccordionItemProps extends ComponentPropsWithRef<'div'> {
53
+ /** Identifier of this item (matches `value` on the root). */
54
+ value: string;
55
+ /** Non-interactive when true. @default false */
56
+ disabled?: boolean;
57
+ }
58
+ declare const AccordionItem: import('react').ForwardRefExoticComponent<Omit<AccordionItemProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
59
+ export interface AccordionTriggerProps extends ComponentPropsWithRef<'button'> {
60
+ /** Trailing chevron (rotates when open). Pass a node to replace it, `false` to hide. @default chevron */
61
+ icon?: ReactNode | false;
62
+ /** Side of the icon. @default 'end' */
63
+ iconPosition?: 'start' | 'end';
64
+ }
65
+ declare const AccordionTrigger: import('react').ForwardRefExoticComponent<Omit<AccordionTriggerProps, "ref"> & import('react').RefAttributes<HTMLButtonElement>>;
66
+ export interface AccordionContentProps extends ComponentPropsWithRef<'div'> {
67
+ children?: ReactNode;
68
+ }
69
+ declare const AccordionContent: import('react').ForwardRefExoticComponent<Omit<AccordionContentProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
70
+ type AccordionComponent = typeof AccordionRoot & {
71
+ Item: typeof AccordionItem;
72
+ Trigger: typeof AccordionTrigger;
73
+ Content: typeof AccordionContent;
74
+ };
75
+ /**
76
+ * Vertically stacked disclosure sections. One open at a time (`type="single"`)
77
+ * or any number (`type="multiple"`); controlled or uncontrolled. Each trigger
78
+ * is a real `<button>` inside a heading with `aria-expanded` / `aria-controls`;
79
+ * ArrowUp / ArrowDown / Home / End move focus between triggers.
80
+ *
81
+ * @example
82
+ * <Accordion defaultValue="shipping">
83
+ * <Accordion.Item value="shipping">
84
+ * <Accordion.Trigger>Shipping</Accordion.Trigger>
85
+ * <Accordion.Content>Orders ship within 2 business days.</Accordion.Content>
86
+ * </Accordion.Item>
87
+ * <Accordion.Item value="returns">
88
+ * <Accordion.Trigger>Returns</Accordion.Trigger>
89
+ * <Accordion.Content>30-day return window.</Accordion.Content>
90
+ * </Accordion.Item>
91
+ * </Accordion>
92
+ */
93
+ export declare const Accordion: AccordionComponent;
94
+ export {};
@@ -0,0 +1,180 @@
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;
10
+ }
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;
15
+ }
16
+ function O(t) {
17
+ return t === void 0 ? [] : Array.isArray(t) ? t : [t];
18
+ }
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
+ };
@@ -0,0 +1,36 @@
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
36
+ };
@@ -0,0 +1,2 @@
1
+ export { Accordion } from './Accordion';
2
+ export type { AccordionProps, AccordionClasses, AccordionItemProps, AccordionTriggerProps, AccordionContentProps, AccordionItemData, AccordionType, AccordionVariant, AccordionSize, } from './Accordion';
@@ -6,8 +6,11 @@ export interface AlertClasses {
6
6
  content: string;
7
7
  title: string;
8
8
  message: string;
9
+ action: string;
9
10
  close: string;
10
11
  }
12
+ export type AlertLayout = 'inline' | 'banner';
13
+ export type AlertSize = 'sm' | 'md';
11
14
  export interface AlertProps extends Omit<ComponentPropsWithRef<'div'>, 'title'> {
12
15
  /** Color/semantics. @default 'info' */
13
16
  variant?: AlertVariant;
@@ -19,16 +22,41 @@ export interface AlertProps extends Omit<ComponentPropsWithRef<'div'>, 'title'>
19
22
  onClose?: () => void;
20
23
  /** Accessible label for the dismiss button. @default 'Dismiss' */
21
24
  closeLabel?: string;
25
+ /**
26
+ * Slot for a button or link rendered after the message (a "Retry",
27
+ * "Undo", "View details"). Inline layout places it at the end of the
28
+ * content and lets it wrap under the message on narrow widths; banner
29
+ * layout pushes it to the right edge, before the dismiss button.
30
+ */
31
+ action?: ReactNode;
32
+ /**
33
+ * `'inline'` is the in-flow card (rounded, accent left border).
34
+ * `'banner'` is a full-width strip for the top of a page or app shell: no
35
+ * radius, no side border, everything on one row (icon · text · action ·
36
+ * close). @default 'inline'
37
+ */
38
+ layout?: AlertLayout;
39
+ /** `'sm'` tightens padding and uses the small font size — for hints inside forms and cards. @default 'md' */
40
+ size?: AlertSize;
22
41
  /** Override class names on internal elements. */
23
42
  classes?: Partial<AlertClasses>;
24
43
  }
25
44
  /**
26
45
  * Inline status message — info, success, warning, or danger. Optionally titled,
27
- * dismissible, and with a leading icon.
46
+ * dismissible, with a leading icon and an `action` slot. `layout="banner"`
47
+ * turns it into a full-width strip for the top of a page.
48
+ *
49
+ * The root has `role="alert"`; pass `role="status"` for non-urgent
50
+ * messages that should not interrupt a screen reader.
28
51
  *
29
52
  * @example
30
53
  * <Alert variant="success" title="Saved" onClose={() => setShown(false)}>
31
54
  * Your changes were saved.
32
55
  * </Alert>
56
+ *
57
+ * @example
58
+ * <Alert layout="banner" variant="warning" action={<Button size="sm">Renew</Button>} onClose={dismiss}>
59
+ * Your trial ends in 3 days.
60
+ * </Alert>
33
61
  */
34
62
  export declare const Alert: import('react').ForwardRefExoticComponent<Omit<AlertProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;