@charcuterie/ui 4.30.0 → 4.31.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/README.md +7 -2
- package/docs/README.md +573 -0
- package/docs/building-an-app.md +231 -0
- package/docs/components/Accordion.md +106 -0
- package/docs/components/ActionMenu.md +63 -0
- package/docs/components/ActionTiles.md +233 -0
- package/docs/components/AdaptiveGrid.md +215 -0
- package/docs/components/Alert.md +99 -0
- package/docs/components/AnchorLink.md +23 -0
- package/docs/components/Avatar.md +153 -0
- package/docs/components/Badge.md +81 -0
- package/docs/components/BadgeButton.md +84 -0
- package/docs/components/Board.md +277 -0
- package/docs/components/Breadcrumbs.md +87 -0
- package/docs/components/Button.md +72 -0
- package/docs/components/ButtonLink.md +81 -0
- package/docs/components/Card.md +114 -0
- package/docs/components/CatalogPicker.md +250 -0
- package/docs/components/Chart.md +39 -0
- package/docs/components/Checkbox.md +197 -0
- package/docs/components/ColorPicker.md +99 -0
- package/docs/components/ColorSchemeSwitcher.md +92 -0
- package/docs/components/ColorSchemeToggle.md +98 -0
- package/docs/components/Combobox.md +175 -0
- package/docs/components/CommandPalette.md +120 -0
- package/docs/components/ComparisonChart.md +31 -0
- package/docs/components/CopyButton.md +112 -0
- package/docs/components/DataTable.md +170 -0
- package/docs/components/DatePicker.md +225 -0
- package/docs/components/Dialog.md +134 -0
- package/docs/components/DropRail.md +107 -0
- package/docs/components/EmptyState.md +65 -0
- package/docs/components/Field.md +215 -0
- package/docs/components/FieldGroup.md +45 -0
- package/docs/components/FileDropZone.md +98 -0
- package/docs/components/GroupedList.md +189 -0
- package/docs/components/Header.md +76 -0
- package/docs/components/HtmlEditor-html-editor.md +76 -0
- package/docs/components/HtmlView-html-editor.md +47 -0
- package/docs/components/HtmlView-html-view.md +47 -0
- package/docs/components/IconButton.md +52 -0
- package/docs/components/LaneTimeline.md +254 -0
- package/docs/components/Lightbox.md +101 -0
- package/docs/components/Listbox.md +109 -0
- package/docs/components/LiveStatusIndicator.md +60 -0
- package/docs/components/LogViewer.md +142 -0
- package/docs/components/Main.md +247 -0
- package/docs/components/MarkdownEditor.md +262 -0
- package/docs/components/MarkdownEditorCodeMirror-markdown-editor-codemirror.md +230 -0
- package/docs/components/MarkdownLine.md +187 -0
- package/docs/components/MarkdownView-markdown-editor-codemirror.md +235 -0
- package/docs/components/MediaTile.md +106 -0
- package/docs/components/Menu.md +209 -0
- package/docs/components/MetricCard.md +38 -0
- package/docs/components/Modal.md +89 -0
- package/docs/components/Nav.md +167 -0
- package/docs/components/NavBar.md +190 -0
- package/docs/components/Picker.md +132 -0
- package/docs/components/Popover.md +135 -0
- package/docs/components/PortraitTiles.md +169 -0
- package/docs/components/ProgressBar.md +70 -0
- package/docs/components/ProgressCard.md +65 -0
- package/docs/components/QueryBuilder.md +132 -0
- package/docs/components/RadioGroup.md +165 -0
- package/docs/components/Rail.md +79 -0
- package/docs/components/RangeSlider.md +144 -0
- package/docs/components/ReactRouterAdapter-react-router.md +27 -0
- package/docs/components/ReactRouterLink-react-router.md +23 -0
- package/docs/components/ReorderList.md +143 -0
- package/docs/components/RouterLinkProvider.md +33 -0
- package/docs/components/ScheduleBoard.md +41 -0
- package/docs/components/ScrollMemoryProvider.md +33 -0
- package/docs/components/SearchInput.md +46 -0
- package/docs/components/SegmentedControl.md +98 -0
- package/docs/components/Select.md +169 -0
- package/docs/components/Shell.md +162 -0
- package/docs/components/Skeleton.md +48 -0
- package/docs/components/Slider.md +128 -0
- package/docs/components/SortableTableHeader.md +84 -0
- package/docs/components/Spinner.md +50 -0
- package/docs/components/Stepper.md +121 -0
- package/docs/components/Swatch.md +79 -0
- package/docs/components/Switch.md +80 -0
- package/docs/components/TableColumns.md +29 -0
- package/docs/components/TableViewport.md +42 -0
- package/docs/components/Tabs.md +184 -0
- package/docs/components/TextLink.md +106 -0
- package/docs/components/TimecodeInput.md +222 -0
- package/docs/components/Toast.md +108 -0
- package/docs/components/ToastRegion.md +35 -0
- package/docs/components/Toolbar.md +118 -0
- package/docs/components/Tooltip.md +94 -0
- package/docs/components/UnstyledLink.md +21 -0
- package/docs/components/ValuePairs.md +30 -0
- package/docs/components/VirtualizedGrid.md +204 -0
- package/docs/components/VisuallyHidden.md +39 -0
- package/docs/components/WeekdayIndicator.md +39 -0
- package/docs/hooks/useAdaptiveColumns.md +111 -0
- package/docs/hooks/useCommandPalette.md +40 -0
- package/docs/hooks/useCommandPaletteHotkeys.md +33 -0
- package/docs/hooks/useDeploymentUpdate.md +39 -0
- package/docs/hooks/useLastPresentValue.md +23 -0
- package/docs/hooks/useListMotion.md +65 -0
- package/docs/hooks/useNavLayout.md +59 -0
- package/docs/hooks/usePresence.md +39 -0
- package/docs/hooks/useRouterLink.md +22 -0
- package/docs/hooks/useValueChangeMotion.md +28 -0
- package/package.json +7 -5
- package/skills/charcuterie/SKILL.md +17 -0
- package/skills/charcuterie/references/build-a-screen.md +6 -0
- package/skills/charcuterie/references/create-a-component.md +6 -0
- package/src/AdaptiveGrid/AdaptiveGrid.stories.tsx +1 -1
- package/src/Tabs/Tabs.stories.tsx +1 -1
- package/src/VirtualizedGrid/VirtualizedGrid.stories.tsx +65 -28
- package/src/VirtualizedGrid/VirtualizedGrid.test.tsx +29 -0
- package/src/shell.storyHelpers.tsx +3 -3
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Rail
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { Rail } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A side column — the app's sections, a filter panel, the selected job's detail. `side` places
|
|
8
|
+
it, `landmark` decides what it is, and `label` is required.
|
|
9
|
+
|
|
10
|
+
## `label` is required, and that is not pedantry
|
|
11
|
+
|
|
12
|
+
Two rails in one page are two landmarks of the same type. Unnamed, a screen reader
|
|
13
|
+
announces "complementary" twice with no way to tell them apart, axe files
|
|
14
|
+
`landmark-unique`, and `getByRole("navigation")` returns two matches — which is worse for an
|
|
15
|
+
agent than the rail not existing, because it picks one at random.
|
|
16
|
+
|
|
17
|
+
Named, the rail becomes the scope: `getByRole("navigation", { name: "Sections" })` is what
|
|
18
|
+
distinguishes its "Settings" link from the header's "Settings" button. Same trick `Card`'s
|
|
19
|
+
heading plays for one of nine identical "Start" buttons on a bay tower.
|
|
20
|
+
|
|
21
|
+
`landmark="navigation"` renders `<nav>`; the default `"complementary"` renders `<aside>`.
|
|
22
|
+
Pick the one the content actually is — a filter panel is not navigation.
|
|
23
|
+
|
|
24
|
+
## It collapses without duplicating itself
|
|
25
|
+
|
|
26
|
+
Below `md` (48rem, which is `screen.md`) the shell is one column and the rail becomes a
|
|
27
|
+
horizontally-scrolling strip: above the content for `side="start"`, below it for
|
|
28
|
+
`side="end"`. Above `md` it is a fixed-width column in the grid.
|
|
29
|
+
|
|
30
|
+
**The same element, restyled.** The fleet's habit is to render the whole thing twice behind
|
|
31
|
+
`hidden` and `lg:hidden` — mux-magic's `PageHeader` across two ~55-line blocks,
|
|
32
|
+
mail-sifter's `TriageQueue` again. The cost is not bytes: every control is in the DOM
|
|
33
|
+
**twice at every viewport**, so tests have to be defensively scoped with `within(toolbar)`,
|
|
34
|
+
any agent driving the page sees phantom controls it cannot click, and the two copies drift
|
|
35
|
+
apart. `Rail.test.tsx` counts the links at 390px and at 1440px and gets twelve both times.
|
|
36
|
+
|
|
37
|
+
A media query is enough here because only the rail's *position* changes, never its
|
|
38
|
+
contents. plex-channels' `App.tsx` shows the pattern for when that is not true — a
|
|
39
|
+
`useMediaQuery` over `matchMedia` through `useSyncExternalStore`, mounting exactly one
|
|
40
|
+
instance and relocating it — and it is strictly more machinery for the same guarantee.
|
|
41
|
+
|
|
42
|
+
The `md` breakpoint and `screen.md` agree by construction: Tailwind v4's default
|
|
43
|
+
`--breakpoint-*` scale and this repo's `screen.*` carry the same five values.
|
|
44
|
+
|
|
45
|
+
## The strip scrolls itself
|
|
46
|
+
|
|
47
|
+
Twelve sections on a phone is what makes a naive rail widen the page. `overflow-x-auto`
|
|
48
|
+
keeps the overflow inside an element that scrolls, and `min-w-0` is on it for the same
|
|
49
|
+
reason `Shell`'s middle track is `minmax(0, 1fr)`: a flex or grid child's automatic minimum
|
|
50
|
+
is its content, so one long unbroken string otherwise pushes the layout out of the viewport.
|
|
51
|
+
|
|
52
|
+
A scrolling region has to be keyboard-reachable. It is here because it is a landmark full of
|
|
53
|
+
links, which is what axe's `scrollable-region-focusable` accepts — **a rail of plain
|
|
54
|
+
non-focusable text would not be**, and that is the honest limit of the pattern. Content
|
|
55
|
+
like that belongs in `Main`.
|
|
56
|
+
|
|
57
|
+
## Width
|
|
58
|
+
|
|
59
|
+
`md:w-64` (16rem) by default, which is what the fleet's nav columns settle on. Override it
|
|
60
|
+
with `className` — the rail's track is `auto`, so it takes whatever definite width the
|
|
61
|
+
element is given, and the content column absorbs the difference through its `minmax(0, 1fr)`.
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
<Rail label="Job detail" side="end"><p>No job selected.</p></Rail>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Published TypeScript API
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
const Rail: ({ children, className, label, landmark, side, ...railProps }: RailProps) => ReactNode
|
|
71
|
+
|
|
72
|
+
type RailProps = ComponentPropsWithRef<"aside"> & {
|
|
73
|
+
label: string;
|
|
74
|
+
landmark?: RailLandmark;
|
|
75
|
+
side?: RailSide;
|
|
76
|
+
};
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
[Full declarations](../../dist/Rail/Rail.d.ts)
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# RangeSlider
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { RangeSlider } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A span picked out along a bar, with an independently focusable handle at each end.
|
|
8
|
+
|
|
9
|
+
It exists because QueuePilot plays **only a section** of a video: a user drags two handles
|
|
10
|
+
over a film's runtime to choose where a clip starts and ends, and has to see the section
|
|
11
|
+
they typed into a `TimecodeInput` beside it. So the shape this is built for is a media
|
|
12
|
+
timeline — a bar spanning the whole runtime, two thumbs, and the chosen span painted
|
|
13
|
+
between them.
|
|
14
|
+
|
|
15
|
+
## Why this is a component and not `Slider isRange`
|
|
16
|
+
|
|
17
|
+
`Combobox`'s `isMultiple` and `DatePicker`'s `isRange` are **modes**, and the test that
|
|
18
|
+
made them modes is written down: the widget's ARIA role does not change, and the two shapes
|
|
19
|
+
share nearly everything. Both halves of that test fail here.
|
|
20
|
+
|
|
21
|
+
[`Slider` puts `role="slider"`, the tab stop and the pointer target on the **track**](Slider.md),
|
|
22
|
+
because one track reports one value. Two values cannot live on one accessible object — so
|
|
23
|
+
here the role moves to the thumbs, the track becomes a `role="group"` carrying the label,
|
|
24
|
+
and the tab stops go from one to two. A mode that rewrote its own role would break
|
|
25
|
+
`getByRole("slider", { name })` in every consumer that had used the single-value one.
|
|
26
|
+
|
|
27
|
+
`Slider`'s own record says it plainly: *"a two-thumb range is a different widget with its
|
|
28
|
+
own focus model"*.
|
|
29
|
+
|
|
30
|
+
What the two genuinely share is the **arithmetic** (`Slider/sliderValue.ts`, called rather
|
|
31
|
+
than copied, so both snap on the same grid) and the **bar** (`sliderStyles.ts`). The test
|
|
32
|
+
compares the two thumbs as computed styles, not as class names.
|
|
33
|
+
|
|
34
|
+
## The thumbs clamp, they do not swap
|
|
35
|
+
|
|
36
|
+
A thumb dragged past its partner stops **on** it. The range collapses to zero width, both
|
|
37
|
+
handles keep their identities, and the next press opens it again from whichever side that
|
|
38
|
+
press lands on.
|
|
39
|
+
|
|
40
|
+
Swapping is the other defensible answer and is the wrong one here. The two handles are a
|
|
41
|
+
clip's start and its end, read alongside a field that names them; a drag that silently
|
|
42
|
+
renamed the handle under the pointer would move a number the user is reading somewhere
|
|
43
|
+
else. On the keyboard it is plainer still — swapping means one ArrowRight moves the *other*
|
|
44
|
+
thumb, and the element with focus is no longer the value that changed.
|
|
45
|
+
|
|
46
|
+
Each thumb reports the other as its own `aria-valuemin` / `aria-valuemax`, which is how a
|
|
47
|
+
screen reader is told where this handle stops.
|
|
48
|
+
|
|
49
|
+
## Drag does not commit
|
|
50
|
+
|
|
51
|
+
`onChange` fires on every movement — each arrow key, each pointer sample. `onChangeEnd`
|
|
52
|
+
fires once, on release or key up.
|
|
53
|
+
|
|
54
|
+
The same split `Slider` settled, for the same reason: a clip preview that re-seeks a player
|
|
55
|
+
from `onChange` issues one seek per pointer sample and arrives at the right frame **last**,
|
|
56
|
+
behind a queue of stale ones. While a drag is in flight the component paints from its own
|
|
57
|
+
value rather than from `value`, so a caller that commits on `onChangeEnd` alone still sees
|
|
58
|
+
the thumbs follow the pointer.
|
|
59
|
+
|
|
60
|
+
## The app owns the data
|
|
61
|
+
|
|
62
|
+
`valueFormat` turns a number into whatever the value **is** — `21:14`, `$40`, `3.5 km`. The
|
|
63
|
+
component never learns what a timecode is: it knows a number, and the app knows what the
|
|
64
|
+
number means. That one function feeds `aria-valuetext` and the shown span both.
|
|
65
|
+
|
|
66
|
+
`ticks` is the same division. A tick is `{ label?, value }` and nothing else, so a film's
|
|
67
|
+
chapters are the offsets the app already has. There is no chapter model in here, and the
|
|
68
|
+
marks are `aria-hidden` — each thumb already announces its own position, so a screen reader
|
|
69
|
+
reading the marks between them would be reading the picture.
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import { useState } from "react"
|
|
73
|
+
|
|
74
|
+
function SectionRange() {
|
|
75
|
+
const [value, setValue] = useState({ start: 25, end: 75 })
|
|
76
|
+
return <RangeSlider label="Section" value={value} onChange={setValue} />
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Published TypeScript API
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
const RangeSlider: ({ className, intent, isDisabled, isLabelVisible, isReadOnly, isValueShown, label, largeStep, max, min, onChange, onChangeEnd, size, step, ticks, value, valueFormat, ...divProps }: RangeSliderProps) => ReactNode
|
|
84
|
+
|
|
85
|
+
type RangeSliderProps = Omit<ComponentPropsWithRef<"div">, "children" | "defaultValue" | "onChange"> & {
|
|
86
|
+
intent?: IntentName;
|
|
87
|
+
isDisabled?: boolean;
|
|
88
|
+
isLabelVisible?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Read-only in the `aria-readonly` sense: focusable, full contrast,
|
|
91
|
+
* announced as unchangeable — the same distinction `Slider` draws.
|
|
92
|
+
* A clip already sent to a renderer is this, not `isDisabled`: the
|
|
93
|
+
* span is still worth reading.
|
|
94
|
+
*/
|
|
95
|
+
isReadOnly?: boolean;
|
|
96
|
+
isValueShown?: boolean;
|
|
97
|
+
/** Required. Each thumb's own name is built from it. */
|
|
98
|
+
label: string;
|
|
99
|
+
/** PageUp / PageDown. Defaults to a tenth of the range, as `Slider`'s does. */
|
|
100
|
+
largeStep?: number;
|
|
101
|
+
max?: number;
|
|
102
|
+
min?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Fires on every movement — each arrow key, and each pointer sample
|
|
105
|
+
* while dragging. Use it to paint. See `onChangeEnd` for committing.
|
|
106
|
+
*/
|
|
107
|
+
onChange?: (value: RangeSliderValue) => void;
|
|
108
|
+
/**
|
|
109
|
+
* Fires once, when the interaction ends: pointer release, or key up.
|
|
110
|
+
*
|
|
111
|
+
* The same split `Slider` settled, for the same reason. A clip
|
|
112
|
+
* preview that re-seeks a player from `onChange` issues one seek per
|
|
113
|
+
* pointer sample and arrives at the right frame **last**, behind a
|
|
114
|
+
* queue of stale ones.
|
|
115
|
+
*/
|
|
116
|
+
onChangeEnd?: (value: RangeSliderValue) => void;
|
|
117
|
+
size?: SliderSize;
|
|
118
|
+
step?: number;
|
|
119
|
+
/**
|
|
120
|
+
* Marks along the bar. Positions in the same units as `value`, so a
|
|
121
|
+
* film's chapters are the offsets the app already has.
|
|
122
|
+
*
|
|
123
|
+
* A `label` is centred on its own mark and clamped inside the bar at
|
|
124
|
+
* both ends. Two marks closer together than a label box will overlap:
|
|
125
|
+
* the component draws what it is given, and a caller with dense marks
|
|
126
|
+
* passes the words only where there is room for them.
|
|
127
|
+
*/
|
|
128
|
+
ticks?: readonly RangeSliderTick[];
|
|
129
|
+
/**
|
|
130
|
+
* Seeds the range; it does not control it. A drag paints from the
|
|
131
|
+
* component's own value, so a caller that commits on `onChangeEnd`
|
|
132
|
+
* alone still sees the thumbs follow the pointer.
|
|
133
|
+
*/
|
|
134
|
+
value?: RangeSliderValue;
|
|
135
|
+
/**
|
|
136
|
+
* How each end reads aloud and, when `isValueShown`, on screen.
|
|
137
|
+
* This is what keeps timecodes out of the library: the component
|
|
138
|
+
* knows a number, the app knows it is 21:14.
|
|
139
|
+
*/
|
|
140
|
+
valueFormat?: (value: number) => string;
|
|
141
|
+
};
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
[Full declarations](../../dist/RangeSlider/RangeSlider.d.ts)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# ReactRouterAdapter
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { ReactRouterAdapter } from "@charcuterie/ui/react-router"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Wrap the routed React tree to give Charcuterie real anchor navigation and per-entry scroll restoration. Use `RouterLinkProvider` to connect a different router. Keep the link text and href that users can navigate with or open in a new tab.
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { BrowserRouter } from "react-router"
|
|
11
|
+
|
|
12
|
+
<BrowserRouter>
|
|
13
|
+
<ReactRouterAdapter><h1>Projects</h1></ReactRouterAdapter>
|
|
14
|
+
</BrowserRouter>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Published TypeScript API
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
const ReactRouterAdapter: ({ children, }: ReactRouterAdapterProps) => ReactNode
|
|
21
|
+
|
|
22
|
+
type ReactRouterAdapterProps = {
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
};
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
[Full declarations](../../dist/reactRouter/ReactRouterAdapter.d.ts)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# ReactRouterLink
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { ReactRouterLink } from "@charcuterie/ui/react-router"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Use the React Router link adapter inside a custom `RouterLinkProvider` setup. Prefer `ReactRouterAdapter` when the application also uses `Main` scroll restoration. The link uses `href` and needs meaningful link text.
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
<ReactRouterLink href="/settings">Settings</ReactRouterLink>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Published TypeScript API
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
const ReactRouterLink: ({ href, ...linkProps }: RouterLinkProps) => ReactNode
|
|
17
|
+
|
|
18
|
+
type RouterLinkProps = Omit<ComponentPropsWithRef<"a">, "href"> & {
|
|
19
|
+
href: string;
|
|
20
|
+
};
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
[Full declarations](../../dist/reactRouter/ReactRouterLink.d.ts)
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# ReorderList
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { ReorderList } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A vertical list put in a different order — by two buttons, or by dragging a handle.
|
|
8
|
+
|
|
9
|
+
## Why the library owns this
|
|
10
|
+
|
|
11
|
+
The shape had been written four times before this file existed. Docket wrote it twice: a
|
|
12
|
+
subtask checklist on HTML5 `draggable`, and a phase queue with the buttons and no drag at
|
|
13
|
+
all. `Board` wrote it once, properly, on Pointer Events. Four implementations of one
|
|
14
|
+
behaviour is the case the fleet's build-it-here rule exists for.
|
|
15
|
+
|
|
16
|
+
So this component does not fork the geometry — it **calls** `useBoardDrag` with a single
|
|
17
|
+
registered lane and the item selector pointed at its own rows, the same way
|
|
18
|
+
`VirtualizedGrid` calls `useAdaptiveColumns`. The snapshot, the movement threshold, the
|
|
19
|
+
pointer capture and the drop-index arithmetic exist once in this package, and a fix to any
|
|
20
|
+
of them reaches the board and the list together.
|
|
21
|
+
|
|
22
|
+
## The buttons are primary, the drag is the enhancement
|
|
23
|
+
|
|
24
|
+
WCAG 2.5.7 requires a single-pointer alternative to any dragging movement, and the board's
|
|
25
|
+
[decision](https://github.com/Sawtaytoes/charcuterie/blob/master/docs/decisions/2026-08-19-the-board-owns-the-move-and-takes-no-drag-and-drop-dependency.md)
|
|
26
|
+
argues the stronger version: the buttons are not a fallback bolted onto a drag. They are the
|
|
27
|
+
only path that works from a keyboard, under a screen reader, or under a thumb in the Narrow
|
|
28
|
+
View.
|
|
29
|
+
|
|
30
|
+
`renderItem` therefore receives `moveBy`, `isFirst` and `isLast` **before** it receives
|
|
31
|
+
`gripProps`, and a host that draws no handle at all is a supported host.
|
|
32
|
+
|
|
33
|
+
## `draggable="true"` is the instinct this replaces
|
|
34
|
+
|
|
35
|
+
Native HTML5 drag-and-drop costs nothing and is the wrong answer. It **does not fire on
|
|
36
|
+
touch at all**, so a checklist built on it cannot be reordered on a tablet; its drag image is
|
|
37
|
+
a browser-drawn ghost with no styling hook worth using; and `dataTransfer` is readable only
|
|
38
|
+
inside a real `drop`, which makes a live drop indicator awkward for no gain.
|
|
39
|
+
|
|
40
|
+
Pointer Events cost the same — nothing — and are one code path for mouse, touch and pen.
|
|
41
|
+
`setPointerCapture` keeps the drag alive after the row has moved out from under the finger.
|
|
42
|
+
|
|
43
|
+
The handle carries `touch-action: none`. Without it the browser claims the gesture for a
|
|
44
|
+
scroll and the `pointermove` stream stops one frame in, which reads as "the drag works on my
|
|
45
|
+
desktop and not on my tablet".
|
|
46
|
+
|
|
47
|
+
## One row gets no controls
|
|
48
|
+
|
|
49
|
+
A single item cannot be put anywhere else. `gripProps` comes back empty and `moveBy` does
|
|
50
|
+
nothing, so a host cannot leave a dead handle on a one-row list by forgetting to check —
|
|
51
|
+
which is the part every hand-rolled copy of this shape did forget.
|
|
52
|
+
|
|
53
|
+
## What it deliberately does not render
|
|
54
|
+
|
|
55
|
+
No row, no handle, no buttons and no glyph. The host renders all four through `renderItem`,
|
|
56
|
+
which is what lets one component serve a checklist, a phase queue and a card list whose CSS
|
|
57
|
+
grids have nothing in common. The library ships no icons either, so the position number
|
|
58
|
+
doubling as the handle is the pattern to copy: a list that is ordered wants the number
|
|
59
|
+
printed anyway.
|
|
60
|
+
|
|
61
|
+
## The move is announced, with its position
|
|
62
|
+
|
|
63
|
+
Every commit writes a sentence into a named `role="status"` region: *"Moved Sand the cut
|
|
64
|
+
edge to position 2 of 5."* The **position** is there because "moved" leaves a screen-reader
|
|
65
|
+
user unable to tell the top of a list from the bottom of thirty — the one piece of feedback
|
|
66
|
+
a sighted user gets free from watching the row land, and the one every drag implementation
|
|
67
|
+
forgets to say out loud.
|
|
68
|
+
|
|
69
|
+
## `toIndex` is already corrected
|
|
70
|
+
|
|
71
|
+
`onReorder(fromIndex, toIndex)` hands back an index into `items` that has already accounted
|
|
72
|
+
for the row's own removal, so a handler is `splice(from, 1)` then `splice(to, 0, row)` with
|
|
73
|
+
no arithmetic of its own. That is `toSettledIndex`, shared with `Board`.
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import { Button } from "@charcuterie/ui"
|
|
77
|
+
|
|
78
|
+
function StepList({ items, reorder }: {
|
|
79
|
+
items: { key: string; label: string }[]
|
|
80
|
+
reorder: (from: number, to: number) => void
|
|
81
|
+
}) {
|
|
82
|
+
return <ReorderList items={items} label="Steps" onReorder={reorder}
|
|
83
|
+
renderItem={({ isFirst, isLast, item, moveBy }) => <>
|
|
84
|
+
{item.label}
|
|
85
|
+
<Button isDisabled={isFirst} onClick={() => moveBy(-1)}>Move {item.label} up</Button>
|
|
86
|
+
<Button isDisabled={isLast} onClick={() => moveBy(1)}>Move {item.label} down</Button>
|
|
87
|
+
</>} />
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Published TypeScript API
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
const ReorderList: <TItem extends ReorderListItem>({ className, elementRef, elementType, itemClassName, items, label, onReorder, renderItem, }: ReorderListProps<TItem>) => ReactNode
|
|
95
|
+
|
|
96
|
+
type ReorderListItem = {
|
|
97
|
+
key: string;
|
|
98
|
+
/**
|
|
99
|
+
* Plain text, and it is not optional. Every accessible name the
|
|
100
|
+
* component writes is built from it — "Move <label> earlier" —
|
|
101
|
+
* and so is the sentence the live region reads after a move. A
|
|
102
|
+
* button announced as "↑" names nothing.
|
|
103
|
+
*/
|
|
104
|
+
label: string;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
type ReorderListProps<TItem extends ReorderListItem> = {
|
|
108
|
+
className?: string;
|
|
109
|
+
/**
|
|
110
|
+
* The container element. `ul` by default, because an ordered
|
|
111
|
+
* pile of rows is a list; `div` for a host whose own CSS grid
|
|
112
|
+
* owns the shape and would have to undo list semantics to get
|
|
113
|
+
* it.
|
|
114
|
+
*/
|
|
115
|
+
elementType?: "div" | "ol" | "ul";
|
|
116
|
+
/**
|
|
117
|
+
* The container element, for a host that needs it too.
|
|
118
|
+
*
|
|
119
|
+
* The component keeps its own hold on that element — the drag
|
|
120
|
+
* measures its rows off it — so this is MERGED rather than
|
|
121
|
+
* forwarded. Docket plays a FLIP animation off the same
|
|
122
|
+
* element, and without this the two uses would have to fight
|
|
123
|
+
* over one `ref`.
|
|
124
|
+
*/
|
|
125
|
+
elementRef?: Ref<HTMLElement>;
|
|
126
|
+
itemClassName?: string;
|
|
127
|
+
items: readonly TItem[];
|
|
128
|
+
/** The list's accessible name. */
|
|
129
|
+
label: string;
|
|
130
|
+
/**
|
|
131
|
+
* `fromIndex` and `toIndex` are both indexes into `items`, and
|
|
132
|
+
* `toIndex` is already corrected for the row's own removal — so
|
|
133
|
+
* a handler is `splice(from, 1)` then `splice(to, 0, row)` with
|
|
134
|
+
* no arithmetic of its own.
|
|
135
|
+
*/
|
|
136
|
+
onReorder: (fromIndex: number, toIndex: number) => void;
|
|
137
|
+
renderItem: (renderArguments: ReorderListRenderArguments<TItem>) => ReactNode;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
TItem extends ReorderListItem
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
[Full declarations](../../dist/ReorderList/ReorderList.d.ts)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# RouterLinkProvider
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { RouterLinkProvider } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Inject an app's router link for Charcuterie components below this provider. Use `ReactRouterAdapter` for React Router. Your link implementation needs real hrefs, an accessible name, and native modifier-click behavior.
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import type { ComponentProps } from "react"
|
|
11
|
+
|
|
12
|
+
function AppRouter({ link, children }: ComponentProps<typeof RouterLinkProvider>) {
|
|
13
|
+
return <RouterLinkProvider link={link}>{children}</RouterLinkProvider>
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Published TypeScript API
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
const RouterLinkProvider: ({ children, link, }: {
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* The app's link component, taking `href`. `ReactRouterLink` from
|
|
24
|
+
* `@charcuterie/ui/react-router`, or the app's own four-line
|
|
25
|
+
* wrapper around whatever it routes with.
|
|
26
|
+
*/
|
|
27
|
+
link: RouterLinkComponent;
|
|
28
|
+
}) => ReactNode
|
|
29
|
+
|
|
30
|
+
type RouterLinkComponent = ComponentType<RouterLinkProps>;
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
[Full declarations](../../dist/RouterLink/RouterLinkProvider.d.ts)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# ScheduleBoard
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { ScheduleBoard } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A schedule with aligned time bands, an exact hour axis, and day cards. The app supplies day labels, minute offsets, sources, and formatted times. Bands group by start time; their height never claims duration. The hour layout shows duration and packs overlapping entries side by side. Short items keep a minimum visible height. Full labels remain available through the accessible name and the selection callback. Multi-day entries must be split into day segments by the app. A measured minimum column width switches to day cards, without horizontal scrolling.
|
|
8
|
+
|
|
9
|
+
## Layouts and states
|
|
10
|
+
|
|
11
|
+
## Narrow containers
|
|
12
|
+
|
|
13
|
+
## Keyboard interaction
|
|
14
|
+
|
|
15
|
+
Tab reaches each action. Enter or Space activates it. The display itself adds no tab stops.
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
<ScheduleBoard bands={[]} items={[]} label="Appointments" layout="hours"
|
|
19
|
+
days={[{ key: "mon", label: "Monday", dateLabel: "June 1" }]} />
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Published TypeScript API
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
const ScheduleBoard: ({ label, days, items, bands, layout, className, onSelect, formatHour, hourGridBlockSize, }: ScheduleBoardProps) => ReactNode
|
|
26
|
+
|
|
27
|
+
type ScheduleBoardProps = {
|
|
28
|
+
label: string;
|
|
29
|
+
days: readonly ScheduleDay[];
|
|
30
|
+
items: readonly ScheduleEntry[];
|
|
31
|
+
bands: readonly ScheduleBand[];
|
|
32
|
+
layout?: ScheduleLayout;
|
|
33
|
+
className?: string;
|
|
34
|
+
onSelect?: (key: string) => void;
|
|
35
|
+
formatHour?: (minute: number) => string;
|
|
36
|
+
/** Axis height, in pixels. A minimum preserves short appointments. */
|
|
37
|
+
hourGridBlockSize?: number;
|
|
38
|
+
};
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
[Full declarations](../../dist/ScheduleBoard/ScheduleBoard.d.ts)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# ScrollMemoryProvider
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { ScrollMemoryProvider } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Give `Main` its current history entry when wiring a custom router. The React Router adapter handles this automatically. Keep `Main` as the page landmark and use a distinct key for each history entry.
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import type { ComponentProps } from "react"
|
|
11
|
+
import { Main } from "@charcuterie/ui"
|
|
12
|
+
|
|
13
|
+
function RoutedPage({ entry, children }: ComponentProps<typeof ScrollMemoryProvider>) {
|
|
14
|
+
return <ScrollMemoryProvider entry={entry}><Main>{children}</Main></ScrollMemoryProvider>
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Published TypeScript API
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const ScrollMemoryProvider: ({ children, entry, }: ScrollMemoryProviderProps) => ReactNode
|
|
22
|
+
|
|
23
|
+
type ScrollMemoryProviderProps = {
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* The history entry the page is showing, and the path it belongs
|
|
27
|
+
* to. Under react-router both come straight off `useLocation()`.
|
|
28
|
+
*/
|
|
29
|
+
entry: ScrollEntry;
|
|
30
|
+
};
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
[Full declarations](../../dist/Main/ScrollMemoryProvider.d.ts)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# SearchInput
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { SearchInput } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
The search field with a labelled icon button for clearing its value. The app supplies the
|
|
8
|
+
glyph and owns the query. The component owns the field skin, the full control-sized target,
|
|
9
|
+
the native cancel-widget suppression, and focus return after a clear.
|
|
10
|
+
|
|
11
|
+
Search fields accept medium and large sizes. They do not offer the small control variant,
|
|
12
|
+
because the clear button is a primary pointer target rather than a compact toolbar action.
|
|
13
|
+
|
|
14
|
+
Use `Field` for a visible label, or pass `aria-label` when the surrounding layout already
|
|
15
|
+
names the search.
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { useState } from "react"
|
|
19
|
+
|
|
20
|
+
import type { ReactNode } from "react"
|
|
21
|
+
|
|
22
|
+
function ProjectSearch({ clearIcon }: { clearIcon: ReactNode }) {
|
|
23
|
+
const [value, setValue] = useState("")
|
|
24
|
+
return <SearchInput aria-label="Search projects" clearIcon={clearIcon} value={value}
|
|
25
|
+
onChange={(event) => setValue(event.currentTarget.value)} onClear={() => setValue("")} />
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Published TypeScript API
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
const SearchInput: ({ className, clearIcon, clearLabel, defaultValue, isClearVisible, onClear, ref, size, value, ...inputProps }: SearchInputProps) => ReactNode
|
|
33
|
+
|
|
34
|
+
type SearchInputProps = Omit<ComponentPropsWithRef<"input">, "size" | "type"> & {
|
|
35
|
+
/** The app-owned glyph inside the clear button. */
|
|
36
|
+
clearIcon: ReactNode;
|
|
37
|
+
clearLabel?: string;
|
|
38
|
+
/** Override value-derived visibility for an uncontrolled input. */
|
|
39
|
+
isClearVisible?: boolean;
|
|
40
|
+
onClear: () => void;
|
|
41
|
+
/** Search and clear targets are never smaller than the medium control size. */
|
|
42
|
+
size?: SearchInputSize;
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
[Full declarations](../../dist/SearchInput/SearchInput.d.ts)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# SegmentedControl
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { SegmentedControl } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
One choice out of a handful, all of them on screen at once.
|
|
8
|
+
|
|
9
|
+
This is `Tabs`' composition — `SinglePicker` + `RovingFocus` — **with the panels taken
|
|
10
|
+
away**, and it is here because taking the panels away used to be impossible. Under M4's
|
|
11
|
+
model a tab bar's selection *was* a group of visibilities, so a control that chooses
|
|
12
|
+
something without revealing anything had nothing to reuse and hand-rolled its own state.
|
|
13
|
+
rip-deck's `ColumnPicker` is that hand-roll
|
|
14
|
+
([decision](https://github.com/Sawtaytoes/charcuterie/blob/master/docs/decisions/2026-07-30-tab-selection-is-a-single-picker.md)).
|
|
15
|
+
|
|
16
|
+
## `radiogroup`, not a row of pressed buttons
|
|
17
|
+
|
|
18
|
+
rip-deck's version is five `<button aria-pressed>` inside a `<fieldset>` — the **toolbar of
|
|
19
|
+
independent toggles** pattern. Nothing in it says the five are mutually exclusive, so a
|
|
20
|
+
screen reader announces *"auto, pressed"* with no "1 of 5" and no clue that pressing
|
|
21
|
+
another one un-presses this one.
|
|
22
|
+
|
|
23
|
+
A single choice from a named set is a radio group, and ARIA has a pattern for it: a
|
|
24
|
+
`radiogroup` with an accessible name, `role="radio"` children carrying `aria-checked`, and
|
|
25
|
+
a roving tabindex so Tab enters and leaves the group once.
|
|
26
|
+
|
|
27
|
+
## Selection follows focus, and here that is correct
|
|
28
|
+
|
|
29
|
+
`Tabs` has two activation modes because a tab panel can cost a network request. A radio
|
|
30
|
+
group has one: APG says the arrow keys both move focus **and** check, and there is nothing
|
|
31
|
+
behind an option here to be expensive. So there is no `activation` prop — a `manual`
|
|
32
|
+
segmented control would be a control the arrow keys appear to do nothing in.
|
|
33
|
+
|
|
34
|
+
The two kinds are still separate underneath, which is what makes Space trivial rather than
|
|
35
|
+
a special case: it checks whatever focus is on, whether or not focus moved there by arrow.
|
|
36
|
+
`select` is idempotent, so it is one command and not a second code path.
|
|
37
|
+
|
|
38
|
+
## Registration is membership
|
|
39
|
+
|
|
40
|
+
A disabled option is out of the **focus** group and still one of the **options** — it can
|
|
41
|
+
even be the one a consumer names as the initial `selectedValue`, which is what a saved
|
|
42
|
+
preference pointing at a layout the window no longer fits looks like.
|
|
43
|
+
|
|
44
|
+
`SegmentedOption` is its own file for the same reason `TabTrigger` is: both registrations
|
|
45
|
+
are effects, and an effect cannot run in a loop.
|
|
46
|
+
|
|
47
|
+
## `selectedValue` is initial, not controlled
|
|
48
|
+
|
|
49
|
+
Read once, on the first render. There is no controlled mode and no prop-sync effect, which
|
|
50
|
+
is [the M2 decision](https://github.com/Sawtaytoes/charcuterie/blob/master/docs/decisions/2026-07-29-logic-hooks-are-uncontrolled.md).
|
|
51
|
+
|
|
52
|
+
The first paint reads `pendingValue` as well as `selectedValue`, and that fallback is
|
|
53
|
+
load-bearing: members register from an effect, so `selectedValue` is still `null` when the
|
|
54
|
+
group first paints. Reading only the former renders a group with nothing checked that
|
|
55
|
+
corrects itself a frame later — a flash on a desktop, a visible blank on a kiosk Pi.
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { useState } from "react"
|
|
59
|
+
|
|
60
|
+
function SortOrder() {
|
|
61
|
+
const [order, setOrder] = useState("newest")
|
|
62
|
+
return <SegmentedControl label="Sort order" selectedValue={order}
|
|
63
|
+
onChange={(value) => { if (value !== null) setOrder(value) }}
|
|
64
|
+
items={[{ label: "Newest", value: "newest" }, { label: "Oldest", value: "oldest" }]} />
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Published TypeScript API
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
const SegmentedControl: ({ className, isFullWidth, items, label, onChange, selectedValue, size, }: SegmentedControlProps) => ReactNode
|
|
72
|
+
|
|
73
|
+
type SegmentedControlProps = {
|
|
74
|
+
className?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Fill the available inline space, with every option claiming an
|
|
77
|
+
* equal share where label minimum widths allow. Options wrap
|
|
78
|
+
* onto another row before squeezing rich labels below their
|
|
79
|
+
* minimum content width. A board's Narrow View selector needs
|
|
80
|
+
* this: its options name the only lane on screen, so a content-width strip
|
|
81
|
+
* leaves the rest of the board looking disconnected.
|
|
82
|
+
*
|
|
83
|
+
* The default stays content-width. Most segmented controls choose
|
|
84
|
+
* a compact view or density, where stretching three short words
|
|
85
|
+
* across a whole toolbar would weaken their grouping.
|
|
86
|
+
*/
|
|
87
|
+
isFullWidth?: boolean;
|
|
88
|
+
items: readonly SegmentedItem[];
|
|
89
|
+
/** The group's accessible name. Required. */
|
|
90
|
+
label: string;
|
|
91
|
+
onChange?: (selectedValue: string | null) => void;
|
|
92
|
+
/** **Initial** only. Charcuterie owns it from then on. */
|
|
93
|
+
selectedValue?: string;
|
|
94
|
+
size?: ControlSize;
|
|
95
|
+
};
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
[Full declarations](../../dist/SegmentedControl/SegmentedControl.d.ts)
|