@charcuterie/ui 4.30.0 → 4.31.1
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
- package/src/sourceRules.test.ts +16 -2
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# Select
|
|
2
|
+
|
|
3
|
+
> **Deprecated.** Reach for `Picker` — a `Listbox` with the trigger already attached, and a near drop-in for this component (`label`, `options`, `value`, `onChange`) — or `Combobox` when the list is long enough to want typing.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Select } from "@charcuterie/ui"
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Select renders the legacy native picker. Use Picker for new short lists, Listbox for a custom trigger, or Combobox for searchable choices.
|
|
10
|
+
|
|
11
|
+
Everything below is how the component works, for the call sites still on it.
|
|
12
|
+
|
|
13
|
+
Eighteen sites in the fleet, and they split cleanly in two: **twelve native `<select>`s**
|
|
14
|
+
that differ only in their Tailwind classes, and **six hand-rolled `role="listbox"`
|
|
15
|
+
controls**. This component is the first twelve. The other six are a different pattern —
|
|
16
|
+
see below.
|
|
17
|
+
|
|
18
|
+
## Sizing: `className` is the wrapper, `controlClassName` is the select
|
|
19
|
+
|
|
20
|
+
The chevron has to live somewhere, so this renders a wrapper around the native
|
|
21
|
+
`<select>` and positions the chevron against **that wrapper**. `className` therefore
|
|
22
|
+
lands on the wrapper and the `<select>` stays `w-full` inside it:
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
means "this control is 176px" — chevron included — which is what a caller writing a
|
|
27
|
+
width already assumes.
|
|
28
|
+
|
|
29
|
+
It did not used to. `className` reached only the inner element while the wrapper stayed
|
|
30
|
+
`w-full`, so the control shrank and the chevron stayed pinned to the row's right edge:
|
|
31
|
+
|
|
32
|
+
| | left | right | width |
|
|
33
|
+
| --- | --- | --- | --- |
|
|
34
|
+
| wrapper | 55 | 1128.7 | 1073.6 |
|
|
35
|
+
| select | 55 | 231 | 176 |
|
|
36
|
+
| chevron | 1100.7 | 1116.7 | — |
|
|
37
|
+
|
|
38
|
+
**869.6px** between the control and its own chevron, measured in mux-magic's DSL rules
|
|
39
|
+
builder, with the control's own text clipping at the same time (`setScriptInfo` →
|
|
40
|
+
`setScriptInfc`). The width never worked; `ui@2.16.0`'s `tailwind-merge` made half of it
|
|
41
|
+
work, which is what made the other half visible
|
|
42
|
+
([#112](https://github.com/Sawtaytoes/charcuterie/issues/112)).
|
|
43
|
+
|
|
44
|
+
`Select.test.tsx` asserts this as a **measurement** rather than a class-name check —
|
|
45
|
+
every class-name assertion passed while the chevron was 869.6px away, because `w-44`
|
|
46
|
+
really was present, on the element nobody was looking at.
|
|
47
|
+
|
|
48
|
+
### What goes where
|
|
49
|
+
|
|
50
|
+
| | Goes to | For |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| `className` | the wrapper | width, margin (`ms-auto`), display, position — the outer box |
|
|
53
|
+
| `controlClassName` | the `<select>` | `font-mono` on the option text, a `text-*`, a `bg-*` |
|
|
54
|
+
|
|
55
|
+
A width in `controlClassName` is the bug again by hand: it desynchronises the inner
|
|
56
|
+
element from the wrapper the chevron is measured against.
|
|
57
|
+
|
|
58
|
+
## There is no state kind here, and that is the finding
|
|
59
|
+
|
|
60
|
+
Every other interactive component in this package owns its state through
|
|
61
|
+
`@charcuterie/logic`. This one owns **none**, because the platform already does — a
|
|
62
|
+
`<select>` holds the chosen option in the DOM, and putting a `useSinglePicker` beside it
|
|
63
|
+
would create the exact conflict the state layer exists to prevent:
|
|
64
|
+
|
|
65
|
+
> Two things believing they hold `value`.
|
|
66
|
+
|
|
67
|
+
That is the Radix argument from `Popover`, pointed at ourselves. So `value` seeds
|
|
68
|
+
`defaultValue` and changes are reported outward.
|
|
69
|
+
|
|
70
|
+
The consequence worth knowing: **`Select` is uncontrolled and `Tabs` is not**, and a reader
|
|
71
|
+
should be able to tell why without asking. A tab bar's selection has no DOM representation,
|
|
72
|
+
so something has to hold it. A select's does.
|
|
73
|
+
|
|
74
|
+
## Native, and what that rules out
|
|
75
|
+
|
|
76
|
+
| Native gives you | A hand-rolled listbox rebuilds |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| Type-ahead | a keystroke buffer and a timer |
|
|
79
|
+
| Home / End / PageUp / PageDown | four more key handlers |
|
|
80
|
+
| The mobile wheel picker | nothing that feels native |
|
|
81
|
+
| Form submission and `:invalid` | a hidden input |
|
|
82
|
+
| Autofill | — |
|
|
83
|
+
|
|
84
|
+
What it cannot do is render a rich option — an icon, two lines, a badge — or filter.
|
|
85
|
+
mux-magic has six controls that need one of those (`CommandPicker`, `PathPicker`,
|
|
86
|
+
`LinkPicker`, `EnumPicker`, `AssFieldPicker`, `RenameTargetPicker`), and **every one of them
|
|
87
|
+
is a `Combobox`**: a text input that filters a listbox. Different pattern, different ARIA
|
|
88
|
+
contract, P2 in the plan.
|
|
89
|
+
|
|
90
|
+
Building a bare `Listbox` here that none of the six could adopt would have shipped a
|
|
91
|
+
component with no caller — the mistake this milestone was explicitly checking for.
|
|
92
|
+
|
|
93
|
+
## The placeholder is a disabled option
|
|
94
|
+
|
|
95
|
+
Not an empty-valued one. An enabled `<option value="">` looks identical, is selectable, and
|
|
96
|
+
silently posts `""`. Disabled, it reads as a prompt and can never be submitted.
|
|
97
|
+
|
|
98
|
+
## `appearance-none` takes the arrow away
|
|
99
|
+
|
|
100
|
+
Removing the UA's own chevron and forgetting to put one back leaves a control that looks
|
|
101
|
+
exactly like a text input. The replacement is `aria-hidden` decoration in the same grid
|
|
102
|
+
cell, with `pe-9` reserving room for it.
|
|
103
|
+
|
|
104
|
+
## Naming, once
|
|
105
|
+
|
|
106
|
+
Either `label` (which becomes `aria-label`) **or** a surrounding `Field` — never both. Two
|
|
107
|
+
naming mechanisms firing at once means the accessible name is whichever won, which is not a
|
|
108
|
+
thing a reader can predict.
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
<Select label="Report format" options={[{ label: "Summary", value: "summary" }]} />
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Published TypeScript API
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
const Select: ({ className, controlClassName, isDisabled, label, onChange, options, placeholder, size, value, ...selectProps }: SelectProps) => ReactNode
|
|
118
|
+
|
|
119
|
+
type SelectProps = Omit<ComponentPropsWithRef<"select">, "disabled" | "onChange" | "size" | "value"> & {
|
|
120
|
+
/**
|
|
121
|
+
* Goes on the **wrapper**, which is the box a caller means when
|
|
122
|
+
* they size a control. See the component docblock — the chevron
|
|
123
|
+
* is positioned against that wrapper, so a width anywhere else
|
|
124
|
+
* leaves it behind.
|
|
125
|
+
*/
|
|
126
|
+
className?: string;
|
|
127
|
+
/**
|
|
128
|
+
* The escape hatch for the inner `<select>` itself, for the
|
|
129
|
+
* things that genuinely are not the outer box: `font-mono` on the
|
|
130
|
+
* option text, a `text-*` override, a `bg-*`.
|
|
131
|
+
*
|
|
132
|
+
* Sizing does **not** belong here. The inner element is `w-full`
|
|
133
|
+
* and a width on it desynchronises it from the wrapper the
|
|
134
|
+
* chevron is pinned to, which is the whole of #112.
|
|
135
|
+
*/
|
|
136
|
+
controlClassName?: string;
|
|
137
|
+
isDisabled?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* The accessible name, when this is **not** inside a `Field`. A
|
|
140
|
+
* `<select>` with neither a `<label for>` nor an `aria-label` is
|
|
141
|
+
* announced as "combobox" and is unfindable by
|
|
142
|
+
* `getByRole("combobox", { name })` — twelve of the fleet's
|
|
143
|
+
* fourteen native selects are in exactly that state.
|
|
144
|
+
*/
|
|
145
|
+
label?: string;
|
|
146
|
+
onChange?: (value: string) => void;
|
|
147
|
+
/**
|
|
148
|
+
* `readonly`, because a caller's list is usually a constant and
|
|
149
|
+
* TypeScript will not hand a `readonly` array to a mutable
|
|
150
|
+
* parameter — image-viewer hit `TS4104` on an `as const` options
|
|
151
|
+
* table and had to spread a copy at every call. This component
|
|
152
|
+
* only ever `.map`s over it, so demanding a mutable array was
|
|
153
|
+
* asking for a permission it never uses.
|
|
154
|
+
*/
|
|
155
|
+
options: readonly SelectItem[];
|
|
156
|
+
/**
|
|
157
|
+
* A disabled first entry, not a real option. Reads as a prompt to
|
|
158
|
+
* a sighted user and cannot be submitted, which is what a
|
|
159
|
+
* placeholder should mean — unlike an empty-valued option, which
|
|
160
|
+
* is selectable and silently posts "".
|
|
161
|
+
*/
|
|
162
|
+
placeholder?: string;
|
|
163
|
+
size?: ControlSize;
|
|
164
|
+
/** **Initial** only, like every other value prop in this library. */
|
|
165
|
+
value?: string;
|
|
166
|
+
};
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
[Full declarations](../../dist/Select/Select.d.ts)
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Shell
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { Shell } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
**The fleet's largest duplicated surface.** Ten of twelve UI repos hand-roll the page
|
|
8
|
+
chrome, and three of them have a file literally named `AppShell.tsx` — mail-sifter's and
|
|
9
|
+
points-market's headers are a *byte-identical* string, arrived at independently:
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
<header className="sticky top-0 z-40 border-b border-border-subtle bg-surface-base/90 backdrop-blur-md">
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
board-games' is the same structure with `sticky` dropped. The other seven spell the same
|
|
16
|
+
idea as `PageChrome`, `Header`, `DashboardHeader`, `Layout` (twice), `TitleBar`, and
|
|
17
|
+
inline in `App.tsx`.
|
|
18
|
+
|
|
19
|
+
The owner's ask, verbatim:
|
|
20
|
+
|
|
21
|
+
> "We need a header component. Apps are all doing it differently, and there's no
|
|
22
|
+
> standardized way to do a sticky header + narrow view... A Unified App Shell basically."
|
|
23
|
+
|
|
24
|
+
## The three templates
|
|
25
|
+
|
|
26
|
+
The controls differ per app. The structure does not — so these are meant to be copied
|
|
27
|
+
whole, and the only edits are what goes in `actions`, in the rails, and in `Main`.
|
|
28
|
+
|
|
29
|
+
### 1. Header + main
|
|
30
|
+
|
|
31
|
+
Eight of the fleet's ten hand-rolled shells are this shape, and most apps need nothing
|
|
32
|
+
else.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### 2. Header + a start rail
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
`label` is required, and `landmark="navigation"` makes it a `<nav>`. Both matter the
|
|
41
|
+
moment there are two rails.
|
|
42
|
+
|
|
43
|
+
### 3. Header + both rails
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
Order the children the way they should be **read**: header, start rail, main, end rail.
|
|
48
|
+
Below `md` the grid is one column and that DOM order is the reading order; above it, the
|
|
49
|
+
`side` prop places each rail in its own track.
|
|
50
|
+
|
|
51
|
+
## One width, not two
|
|
52
|
+
|
|
53
|
+
`contentWidth` is stated once, on `Shell`, and `Header` and `Main` both read it. That is a
|
|
54
|
+
bug fix, not tidiness: **points-market's header is capped at 80rem and its `<main>` is not
|
|
55
|
+
capped at all**, so on a wide monitor the page title sits above content that starts to its
|
|
56
|
+
left and runs past its right. Nothing errors; the two values were simply written on
|
|
57
|
+
different days.
|
|
58
|
+
|
|
59
|
+
Either component still takes its own `contentWidth` for a real reason — a full-bleed hero
|
|
60
|
+
under a constrained header — but that now takes a prop somebody wrote on purpose.
|
|
61
|
+
|
|
62
|
+
The scale and how it composes with a runtime-computed cap are on the
|
|
63
|
+
[`Main`](Main.md) page.
|
|
64
|
+
|
|
65
|
+
## The rails collapse without duplicating
|
|
66
|
+
|
|
67
|
+
Below `md` the shell is a single column and each `Rail` becomes a horizontally-scrolling
|
|
68
|
+
strip. **The same element, restyled — never a second copy.** mux-magic's `PageHeader`
|
|
69
|
+
renders its entire control set twice (lines 290–345 and 356–410) behind `hidden` /
|
|
70
|
+
`lg:hidden`, and mail-sifter's `TriageQueue` does it again. The cost is not bytes: every
|
|
71
|
+
action exists twice in the DOM at *every* viewport, so tests must be defensively scoped
|
|
72
|
+
with `within(toolbar)`, an agent driving the page finds two of each button with no way to
|
|
73
|
+
tell which is visible, and the two copies drift.
|
|
74
|
+
|
|
75
|
+
plex-channels' `App.tsx` shows the pattern for when the contents genuinely have to differ
|
|
76
|
+
— a `useMediaQuery` over `matchMedia` through `useSyncExternalStore`, mounting exactly one
|
|
77
|
+
instance and relocating it. It is strictly more machinery for the same guarantee, so a
|
|
78
|
+
rail that only changes *position* uses a media query and nothing else.
|
|
79
|
+
|
|
80
|
+
## The page content scrolls; the frame stays available
|
|
81
|
+
|
|
82
|
+
The shell fills the viewport. `Main` is the only vertical scroll region, so a long page does
|
|
83
|
+
not scroll the header or either rail away. This keeps navigation actions available, including
|
|
84
|
+
an app's rail-collapse control. The rail is not a second vertical scroll area.
|
|
85
|
+
|
|
86
|
+
## It does not scroll sideways, and that is a test
|
|
87
|
+
|
|
88
|
+
Plex Channels' narrow view scrolls left and right as wide as its content area. The usual
|
|
89
|
+
causes are all shell faults: a grid track that ignores `min-width: 0`, a `100vw` that
|
|
90
|
+
counts the scrollbar gutter, or a sticky header whose inner container is wider than the
|
|
91
|
+
viewport.
|
|
92
|
+
|
|
93
|
+
There are **three** shapes of it, and each needs a different answer:
|
|
94
|
+
|
|
95
|
+
| Shape | Answer |
|
|
96
|
+
| --- | --- |
|
|
97
|
+
| A grid track sized to `min-content` | `minmax(0, 1fr)` on the middle track |
|
|
98
|
+
| Text ink from a long unbroken token | `wrap-anywhere` on `Main`'s column |
|
|
99
|
+
| A box parked off-screen by a transform | `position: relative` + `overflow-x: clip` here |
|
|
100
|
+
|
|
101
|
+
The third is the one that broke plex-channels: a closed panel at
|
|
102
|
+
`transform: translateX(110%)`. **A transform does not remove a box from the document's
|
|
103
|
+
scrollable overflow region**, and neither does `visibility: hidden` — so a drawer nobody can
|
|
104
|
+
see still makes the page scroll to it.
|
|
105
|
+
|
|
106
|
+
`clip`, not `hidden`: `overflow: hidden` creates a scroll container, which would become the
|
|
107
|
+
sticky containing block for `Header` and freeze it. `clip` creates no scrollport, and it is
|
|
108
|
+
the one value that may pair with `overflow-y: visible`.
|
|
109
|
+
|
|
110
|
+
The `relative` is not decoration. `overflow-x: clip` only clips descendants whose containing
|
|
111
|
+
block chain runs through the clipper, and an absolutely positioned box with no positioned
|
|
112
|
+
ancestor resolves against the *initial* containing block instead — sailing past every
|
|
113
|
+
`overflow` in the tree. Measured, before `Shell` took `relative`: `shellScroll: 390`,
|
|
114
|
+
`bodyScroll: 390`, **`docScroll: 742`** at a 390px viewport. The obvious candidate to own it
|
|
115
|
+
— `Main`'s content column — does not, because `container-type: inline-size` computes
|
|
116
|
+
`contain` to `none` in Chromium and establishes no containing block for absolute
|
|
117
|
+
positioning; the drawer's `offsetParent` was `BODY`.
|
|
118
|
+
|
|
119
|
+
`Shell.test.tsx` and `Main.test.tsx` assert
|
|
120
|
+
`document.documentElement.scrollWidth <= clientWidth` at a real 390px viewport against a
|
|
121
|
+
story carrying all three shapes at once, with each fixture separately asserted to actually
|
|
122
|
+
overflow. **`documentElement`, not `body`** — the parked-drawer case leaves
|
|
123
|
+
`document.body.scrollWidth` reading a clean 390 while the page scrolls, and it leaves no
|
|
124
|
+
overflowing element box for a `getBoundingClientRect()` assertion to catch either.
|
|
125
|
+
|
|
126
|
+
There is no grid `gap`: an absent rail is a zero-width `auto` track, but a gap beside it is
|
|
127
|
+
not, so a shell with no rails would carry two mystery gutters. `Rail` and `Main` bring
|
|
128
|
+
their own padding.
|
|
129
|
+
|
|
130
|
+
## The skip link
|
|
131
|
+
|
|
132
|
+
All ten hand-rolled shells are missing one, so on every one of those apps a keyboard user
|
|
133
|
+
starts each page by tabbing through the header. `Shell` renders it, points it at the
|
|
134
|
+
`<main>` it generated the id for, and `Main` carries `tabIndex={-1}` so activating it moves
|
|
135
|
+
**focus** rather than only the scroll position — an `href` at a non-focusable target leaves
|
|
136
|
+
the next Tab back in the header, which looks like a working skip link and is not.
|
|
137
|
+
|
|
138
|
+
It is hidden by a transform rather than by `sr-only`, because `focus-visible:not-sr-only`
|
|
139
|
+
and `focus-visible:fixed` both write `position` and which one wins is decided by Tailwind's
|
|
140
|
+
internal property order rather than by the order they are written in.
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
import { Header, Main } from "@charcuterie/ui"
|
|
144
|
+
|
|
145
|
+
<Shell>
|
|
146
|
+
<Header heading="Projects" />
|
|
147
|
+
<Main><h2>Recent projects</h2></Main>
|
|
148
|
+
</Shell>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Published TypeScript API
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
const Shell: ({ children, className, contentWidth, skipLinkLabel, ...divProps }: ShellProps) => ReactNode
|
|
155
|
+
|
|
156
|
+
type ShellProps = ComponentPropsWithRef<"div"> & {
|
|
157
|
+
contentWidth?: ContentWidth;
|
|
158
|
+
skipLinkLabel?: string;
|
|
159
|
+
};
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
[Full declarations](../../dist/Shell/Shell.d.ts)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Skeleton
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { Skeleton } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
**Also zero fleet-wide.** The counterpart to `Spinner`, and the better answer wherever the
|
|
8
|
+
shape of the incoming content is already known: a poster grid that skeletons does not
|
|
9
|
+
reflow when the images land, and layout shift is what users actually notice.
|
|
10
|
+
|
|
11
|
+
## `aria-hidden` is the contract, not an optimisation
|
|
12
|
+
|
|
13
|
+
A skeleton is decoration standing in for content that does not exist yet. Announcing it
|
|
14
|
+
means a screen reader reading three empty bars, and an agent finding a "loading" element it
|
|
15
|
+
cannot act on.
|
|
16
|
+
|
|
17
|
+
**The load has to be announced by the region that owns it** — a `Spinner`, or `aria-busy`
|
|
18
|
+
on the container. The `Playground` story asserts the skeleton is hidden from assistive
|
|
19
|
+
technology, and `Interactive` asserts it contributes no roles at all. Both are assertions
|
|
20
|
+
axe cannot make for you: there is nothing invalid about a visible placeholder.
|
|
21
|
+
|
|
22
|
+
## Example from the stories
|
|
23
|
+
|
|
24
|
+
See the full [story example](../../src/Skeleton/Skeleton.stories.tsx).
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
<Skeleton inlineSize="14rem" shape="text" />
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Published TypeScript API
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
const Skeleton: ({ blockSize, className, inlineSize, lineCount, shape, style, ...divProps }: SkeletonProps) => ReactNode
|
|
34
|
+
|
|
35
|
+
type SkeletonProps = Omit<ComponentPropsWithRef<"div">, "children"> & {
|
|
36
|
+
blockSize?: string;
|
|
37
|
+
inlineSize?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Text skeletons render this many bars, the last one short —
|
|
40
|
+
* because a paragraph placeholder whose every line is full width
|
|
41
|
+
* reads as a table, not as prose.
|
|
42
|
+
*/
|
|
43
|
+
lineCount?: number;
|
|
44
|
+
shape?: SkeletonShape;
|
|
45
|
+
};
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
[Full declarations](../../dist/Skeleton/Skeleton.d.ts)
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Slider
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { Slider } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A single-value range control: what `<input type="range">` is, without the OS painting it.
|
|
8
|
+
|
|
9
|
+
The fleet had no way to ask for a value along a range, so QueuePilot's Now-playing bar
|
|
10
|
+
could not have a scrubber and the choice was a native range input or a hand-rolled one in
|
|
11
|
+
a single app. `ProgressBar` looks like the answer and is not — it is **output**, it takes
|
|
12
|
+
no input, and `role="progressbar"` tells assistive technology exactly that.
|
|
13
|
+
|
|
14
|
+
## Why a `div` and not `<input type="range">`
|
|
15
|
+
|
|
16
|
+
The same reason [`Select` is deprecated](Select.md).
|
|
17
|
+
|
|
18
|
+
A range input's thumb and track are UA pseudo-elements — `::-webkit-slider-thumb`,
|
|
19
|
+
`::-moz-range-track` — and they are not one surface: the two engines disagree about which
|
|
20
|
+
of them the filled portion even belongs to, so a token-styled range is two stylesheets that
|
|
21
|
+
drift apart. Windows paints its own regardless.
|
|
22
|
+
|
|
23
|
+
`role="slider"` on a focusable `div` is the APG's own pattern, gets the same AT support, and
|
|
24
|
+
every pixel of it is ours.
|
|
25
|
+
|
|
26
|
+
## The role, the tab stop and the pointer target are all the track
|
|
27
|
+
|
|
28
|
+
Putting them on the thumb is what a hand-rolled slider usually does, because the thumb is
|
|
29
|
+
the part that looks draggable. It gives the widget a 16px box: a press on the bar does
|
|
30
|
+
nothing, and a Playwright bounding box is the handle rather than the control.
|
|
31
|
+
|
|
32
|
+
The hit area is a row taller than the bar, because a 2px track is not a pointer target.
|
|
33
|
+
|
|
34
|
+
## Drag does not commit
|
|
35
|
+
|
|
36
|
+
`onChange` fires on every movement — each arrow key, each pointer sample. `onChangeEnd`
|
|
37
|
+
fires once, on release or key up.
|
|
38
|
+
|
|
39
|
+
This split exists because the expensive consumer of a slider is almost never the paint. A
|
|
40
|
+
seek scrubber issuing its network call from `onChange` would send one request per pointer
|
|
41
|
+
sample and arrive at the right offset **last**, behind a queue of stale ones.
|
|
42
|
+
|
|
43
|
+
While a drag is in flight the component paints from its own local value rather than from
|
|
44
|
+
the `value` prop. Without that, a controlled slider whose owner only commits on
|
|
45
|
+
`onChangeEnd` would render the thumb pinned at the old position under the finger — the drag
|
|
46
|
+
would look broken while behaving correctly.
|
|
47
|
+
|
|
48
|
+
## Read-only is not disabled
|
|
49
|
+
|
|
50
|
+
A read-only slider keeps full contrast and stays focusable, so its value is still readable
|
|
51
|
+
and still reachable by a screen reader. A live stream's position is this: the number
|
|
52
|
+
matters and seeking is not offered.
|
|
53
|
+
|
|
54
|
+
## The arithmetic is a tested pure function
|
|
55
|
+
|
|
56
|
+
`sliderValue.ts`, in the node project. Steps anchor on `min` rather than on zero — a 7–19
|
|
57
|
+
range stepping by 4 anchored on zero can reach 8, 12 and 16, and neither end of its own
|
|
58
|
+
range is one of them. A snap never escapes the range, a float step does not accumulate
|
|
59
|
+
drift into `aria-valuenow`, and a `NaN` cannot reach the style attribute, where it would
|
|
60
|
+
render `inline-size: NaN%` and paint nothing with no error.
|
|
61
|
+
|
|
62
|
+
`fromFraction` takes an `isRtl` flag because `getBoundingClientRect()` is physical and knows
|
|
63
|
+
nothing about writing direction — without it a right-to-left slider runs backwards under the
|
|
64
|
+
pointer while its keyboard path stays correct.
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import { useState } from "react"
|
|
68
|
+
|
|
69
|
+
function VolumeControl() {
|
|
70
|
+
const [volume, setVolume] = useState(50)
|
|
71
|
+
return <Slider label="Volume" min={0} max={100} step={5} value={volume} onChange={setVolume} />
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Published TypeScript API
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
const Slider: ({ className, intent, isDisabled, isLabelVisible, isReadOnly, isValueShown, label, largeStep, max, min, onChange, onChangeEnd, size, step, value, valueFormat, ...divProps }: SliderProps) => ReactNode
|
|
79
|
+
|
|
80
|
+
type SliderProps = Omit<ComponentPropsWithRef<"div">, "children" | "defaultValue" | "onChange"> & {
|
|
81
|
+
intent?: IntentName;
|
|
82
|
+
isDisabled?: boolean;
|
|
83
|
+
isLabelVisible?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Read-only in the `aria-readonly` sense: focusable, full contrast,
|
|
86
|
+
* announced as unchangeable. A media scrubber for a stream with no
|
|
87
|
+
* seekable range is this, not `isDisabled` — the position is still
|
|
88
|
+
* worth reading.
|
|
89
|
+
*/
|
|
90
|
+
isReadOnly?: boolean;
|
|
91
|
+
isValueShown?: boolean;
|
|
92
|
+
/** Required. A slider with no name is an unlabelled number. */
|
|
93
|
+
label: string;
|
|
94
|
+
/**
|
|
95
|
+
* PageUp / PageDown. Defaults to ten steps, which is the APG's
|
|
96
|
+
* suggestion and the only sensible answer that does not need the
|
|
97
|
+
* caller to know the range.
|
|
98
|
+
*/
|
|
99
|
+
largeStep?: number;
|
|
100
|
+
max?: number;
|
|
101
|
+
min?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Fires on every movement — each arrow key, and each pointer sample
|
|
104
|
+
* while dragging. Use it to paint. See `onChangeEnd` for committing.
|
|
105
|
+
*/
|
|
106
|
+
onChange?: (value: number) => void;
|
|
107
|
+
/**
|
|
108
|
+
* Fires once, when the interaction ends: pointer release, or key up.
|
|
109
|
+
*
|
|
110
|
+
* This exists because the expensive consumer of a slider is almost
|
|
111
|
+
* never the paint. A seek scrubber that issued its network call from
|
|
112
|
+
* `onChange` would send one request per pointer sample and arrive at
|
|
113
|
+
* the right offset last, after a queue of stale ones.
|
|
114
|
+
*/
|
|
115
|
+
onChangeEnd?: (value: number) => void;
|
|
116
|
+
size?: SliderSize;
|
|
117
|
+
step?: number;
|
|
118
|
+
value?: number;
|
|
119
|
+
/**
|
|
120
|
+
* How the value reads aloud and, when `isValueShown`, on screen.
|
|
121
|
+
* Without it a scrubber announces "1274", which is a number of
|
|
122
|
+
* seconds nobody has.
|
|
123
|
+
*/
|
|
124
|
+
valueFormat?: (value: number) => string;
|
|
125
|
+
};
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
[Full declarations](../../dist/Slider/Slider.d.ts)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# SortableTableHeader
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { SortableTableHeader } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
**The header cell, and nothing else.** No `DataTable`, no rows, no comparator — the plan is
|
|
8
|
+
explicit about that, and the reason is that sorting *data* is app logic that differs per
|
|
9
|
+
column type, while announcing *that* a column is sorted is markup every table gets wrong the
|
|
10
|
+
same way.
|
|
11
|
+
|
|
12
|
+
## `aria-sort` does not exist anywhere in the fleet
|
|
13
|
+
|
|
14
|
+
Not in mux-magic, not in rip-deck, not in castkit. mux-magic's `FileExplorerModal` — the one
|
|
15
|
+
sortable table there is — renders the state as a character:
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
{sortDirection === "asc" ? "▲" : "▼"}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
A screen reader announces that as "black up-pointing triangle", if the font has it at all —
|
|
22
|
+
and this sandbox's headless Chromium does not, so the same glyph measures **blank** in a
|
|
23
|
+
screenshot. Sighted users see a direction; everyone else gets nothing.
|
|
24
|
+
|
|
25
|
+
No automated check anywhere reports it. **axe has no rule for a missing `aria-sort`**,
|
|
26
|
+
because a table with none is a table that is simply not sorted as far as the accessibility
|
|
27
|
+
tree knows.
|
|
28
|
+
|
|
29
|
+
This is therefore the one component in M6 whose payoff is not duplication — there is a
|
|
30
|
+
single site — but a class of failure invisible to every gate the fleet has.
|
|
31
|
+
|
|
32
|
+
## `none` is not the same as absent
|
|
33
|
+
|
|
34
|
+
| `aria-sort` | means |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| absent | this column **cannot** be sorted |
|
|
37
|
+
| `"none"` | sortable, not currently sorted |
|
|
38
|
+
| `"ascending"` / `"descending"` | this is the sorted column |
|
|
39
|
+
|
|
40
|
+
A table that omits the attribute on its unsorted columns tells a screen-reader user the other
|
|
41
|
+
four cannot be sorted at all. Exactly one column ever holds a direction.
|
|
42
|
+
|
|
43
|
+
## The cell announces, the button acts
|
|
44
|
+
|
|
45
|
+
`aria-sort` belongs on the `<th>`; the click target is a `<button>` inside it. Putting the
|
|
46
|
+
role on the button instead is the common mistake and it breaks the grid semantics — a `<th>`
|
|
47
|
+
that *is* a button is no longer a column header to anything reading the table structure.
|
|
48
|
+
|
|
49
|
+
## The name stays the column's name
|
|
50
|
+
|
|
51
|
+
It is tempting to append the state — "Title, sorted ascending" — and that duplicates what
|
|
52
|
+
`aria-sort` already says, so the column is announced twice **and**
|
|
53
|
+
`getByRole("columnheader", { name: "Title" })` stops matching the moment somebody sorts it.
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import type { ComponentProps } from "react"
|
|
57
|
+
|
|
58
|
+
function NameHeader({ onSort }: Pick<ComponentProps<typeof SortableTableHeader>, "onSort">) {
|
|
59
|
+
return <SortableTableHeader onSort={onSort}>Name</SortableTableHeader>
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Published TypeScript API
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
const SortableTableHeader: ({ children, className, direction, onSort, }: SortableTableHeaderProps) => ReactNode
|
|
67
|
+
|
|
68
|
+
type SortableTableHeaderProps = {
|
|
69
|
+
children: ReactNode;
|
|
70
|
+
className?: string;
|
|
71
|
+
/**
|
|
72
|
+
* The direction **this column** is sorted in, or `undefined` when
|
|
73
|
+
* it is not the sorted one. Undefined is not "ascending by
|
|
74
|
+
* default": a table has exactly one sorted column and every other
|
|
75
|
+
* header has to say `aria-sort="none"`, which is what tells a
|
|
76
|
+
* screen reader which one is live.
|
|
77
|
+
*/
|
|
78
|
+
direction?: SortDirection;
|
|
79
|
+
/** Called with the direction the header is asking to move to. */
|
|
80
|
+
onSort: (direction: SortDirection) => void;
|
|
81
|
+
};
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
[Full declarations](../../dist/SortableTableHeader/SortableTableHeader.d.ts)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Spinner
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { Spinner } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
**Zero of these exist anywhere in the fleet.** Not one repo has a spinner; every app
|
|
8
|
+
renders bare `"loading…"` text. Best effort-to-payoff component in M3.
|
|
9
|
+
|
|
10
|
+
## Three things a hand-rolled `animate-spin` does not do
|
|
11
|
+
|
|
12
|
+
1. **It is a live region.** `role="status"` with the label inside, so the load is
|
|
13
|
+
announced. A rotating `<div>` announces nothing.
|
|
14
|
+
2. **It stops.** The animation runs at `--duration-loop-fast`, which
|
|
15
|
+
`prefers-reduced-motion` zeroes and `@charcuterie/ui/styles.css` then switches off
|
|
16
|
+
outright. Tailwind's `animate-spin` hardcodes 1s straight past the media query.
|
|
17
|
+
3. **It is findable.** `role="status"` takes **no accessible name from its content** — it
|
|
18
|
+
is a live region, not a widget — so the component sets `aria-label` as well. Without
|
|
19
|
+
that, `getByRole("status", { name: "Loading…" })` matches nothing, and axe never
|
|
20
|
+
mentions it.
|
|
21
|
+
|
|
22
|
+
## Reduced motion
|
|
23
|
+
|
|
24
|
+
There is deliberately no "reduced motion" story: it is a browser state, not a prop. Toggle
|
|
25
|
+
it (DevTools → Rendering → Emulate `prefers-reduced-motion`) against `AllStates` — the
|
|
26
|
+
ring must stop, stay a ring, and keep its label.
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
<Spinner label="Loading projects" isLabelVisible />
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Published TypeScript API
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
const Spinner: ({ className, isLabelVisible, label, size, ...spanProps }: SpinnerProps) => ReactNode
|
|
36
|
+
|
|
37
|
+
type SpinnerProps = Omit<ComponentPropsWithRef<"span">, "children"> & {
|
|
38
|
+
/**
|
|
39
|
+
* Required by omission of a default that could be wrong.
|
|
40
|
+
* "Loading…" is right for a fetch and wrong for "Ripping disc 3",
|
|
41
|
+
* and the label is the *only* thing a screen-reader user gets —
|
|
42
|
+
* the animation says nothing.
|
|
43
|
+
*/
|
|
44
|
+
label?: string;
|
|
45
|
+
isLabelVisible?: boolean;
|
|
46
|
+
size?: ControlSize;
|
|
47
|
+
};
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
[Full declarations](../../dist/Spinner/Spinner.d.ts)
|