@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,121 @@
|
|
|
1
|
+
# Stepper
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { Stepper } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
An ordered sequence of steps, with **what belongs to each one** under it.
|
|
8
|
+
|
|
9
|
+
Docket asked for this. Its phases — *"these 3 cards have to be done in order"* — were a
|
|
10
|
+
hand-rolled numbered rail with a connector drawn in a `::before`, and a `ProgressBar` per
|
|
11
|
+
phase for the count. Neither says which things go together.
|
|
12
|
+
|
|
13
|
+
## Why a step carries content
|
|
14
|
+
|
|
15
|
+
This is the difference between a stepper and a progress bar with a legend. A bar says a
|
|
16
|
+
sequence is half done; only the contents say **which three things go together and which
|
|
17
|
+
one is next**.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## The four statuses, and why `blocked` is not a worse `upcoming`
|
|
22
|
+
|
|
23
|
+
| Status | Means |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| `done` | Finished. |
|
|
26
|
+
| `current` | Being worked on. |
|
|
27
|
+
| `upcoming` | Its turn has not come. |
|
|
28
|
+
| `blocked` | Its turn **has** come and something is in the way. |
|
|
29
|
+
|
|
30
|
+
The last two look alike and are not. `upcoming` is a thing to wait for; `blocked` is a
|
|
31
|
+
thing to go and fix, and collapsing them hides the second behind the first. Docket's case
|
|
32
|
+
is exact: a phase gated behind an *unfinished* phase is normal, and a phase gated behind an
|
|
33
|
+
**empty** one is a mistake somebody has to correct — the same grey pill for both is how
|
|
34
|
+
that sits unnoticed.
|
|
35
|
+
|
|
36
|
+
## Status is never colour alone
|
|
37
|
+
|
|
38
|
+
Four marker colours is four colours as far as assistive technology, a greyscale print and
|
|
39
|
+
the ePaper build are concerned — a WCAG 1.4.1 failure however clear it looks. So the status
|
|
40
|
+
reaches a screen reader as a **word**, in a `VisuallyHidden` beside the label, and gets a
|
|
41
|
+
second visual channel besides hue: a filled marker for finished work, an outlined one
|
|
42
|
+
ahead of it, and a connector that is solid behind and subdued in front.
|
|
43
|
+
|
|
44
|
+
## The marker is the ordinal, never a tick
|
|
45
|
+
|
|
46
|
+
This library
|
|
47
|
+
ships no icons and no symbol glyphs. A `✓` renders as
|
|
48
|
+
an empty box wherever the font lacks it — the sandbox chromium, the kiosk image, the ePaper
|
|
49
|
+
build — and an empty box in the "done" position reads as an *error*, which is the opposite
|
|
50
|
+
of what it meant. The ordinal always renders. An app that owns a glyph set passes one as
|
|
51
|
+
`marker`.
|
|
52
|
+
|
|
53
|
+
## `horizontal` is a request, not a promise
|
|
54
|
+
|
|
55
|
+
It collapses to the vertical column below `cq-md`. Four steps side by side in a narrow
|
|
56
|
+
container squash into `2. / De- / dupe` — measured, in the app this came out of, before any
|
|
57
|
+
of them contained anything. A step carrying `content` should stay vertical regardless: a
|
|
58
|
+
column cannot hold a list.
|
|
59
|
+
|
|
60
|
+
## There is nothing to focus
|
|
61
|
+
|
|
62
|
+
A stepper is a **document outline**, not a widget: an `<ol>` of headings. Advancing is the
|
|
63
|
+
app's operation and the component only reports where the sequence got to, so there is no
|
|
64
|
+
roving focus, no `aria-current` on a control, and nothing to arrow between. If your steps
|
|
65
|
+
are *navigable* — a checkout you can click back into — you want `Tabs`.
|
|
66
|
+
|
|
67
|
+
## Wizard navigation
|
|
68
|
+
|
|
69
|
+
Provide `onStepSelect` to make completed stages keyboard-accessible buttons.
|
|
70
|
+
Current and upcoming stages remain progress indicators. The caller owns the answers:
|
|
71
|
+
returning to an earlier stage should clear choices that depend on it.
|
|
72
|
+
|
|
73
|
+
Preact displays can use `getWizardSteps` from `@charcuterie/logic/core` to derive the
|
|
74
|
+
same numbered stages and backward navigation without importing React components.
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
<Stepper label="Setup progress" steps={[{ key: "start", label: "Start", status: "current" }]} />
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Published TypeScript API
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
const Stepper: ({ appearance, className, headingLevel, isResponsive, label, orientation, onStepSelect, steps, }: StepperProps) => import("react").JSX.Element
|
|
84
|
+
|
|
85
|
+
type StepperProps = {
|
|
86
|
+
/** `compact` is the dot-and-line ladder for short status labels in cards. */
|
|
87
|
+
readonly appearance?: "default" | "compact";
|
|
88
|
+
readonly className?: string;
|
|
89
|
+
/**
|
|
90
|
+
* What level the step labels are. The caller's, because only the
|
|
91
|
+
* caller knows what the stepper sits under — one below a page
|
|
92
|
+
* `<h1>` wants `2`, one inside an already-deep section wants `4`.
|
|
93
|
+
* Getting it wrong is an axe `heading-order` failure and a broken
|
|
94
|
+
* screen-reader outline.
|
|
95
|
+
*/
|
|
96
|
+
readonly headingLevel?: 2 | 3 | 4 | 5;
|
|
97
|
+
/** The list's accessible name. Required — an unnamed sequence of
|
|
98
|
+
* numbers is a sequence of numbers. */
|
|
99
|
+
readonly label: string;
|
|
100
|
+
/**
|
|
101
|
+
* Whether a requested horizontal sequence collapses below `cq-md`.
|
|
102
|
+
* Keep this on for prose-sized steps. Turn it off only when the
|
|
103
|
+
* caller supplies short labels that are designed to remain a compact
|
|
104
|
+
* ladder inside a card.
|
|
105
|
+
*/
|
|
106
|
+
readonly isResponsive?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* `horizontal` is a REQUEST, not a promise: it collapses to
|
|
109
|
+
* vertical below `cq-md`, because four steps side by side in a
|
|
110
|
+
* narrow container squash into unreadable slivers (`2. / De- /
|
|
111
|
+
* dupe`, measured). A step carrying `content` should stay
|
|
112
|
+
* vertical — a column cannot hold a list.
|
|
113
|
+
*/
|
|
114
|
+
readonly orientation?: StepperOrientation;
|
|
115
|
+
/** Completed stages become buttons; the caller resets dependent answers. */
|
|
116
|
+
readonly onStepSelect?: (key: string) => void;
|
|
117
|
+
readonly steps: readonly Step[];
|
|
118
|
+
};
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
[Full declarations](../../dist/Stepper/Stepper.d.ts)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Swatch
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { Swatch } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A colour presented **as content**, with a name attached. It is the one colour the design
|
|
8
|
+
system does not own: the red sticker on a game controller, the accent castkit pulls off an
|
|
9
|
+
album, a user's tag colour. Not a token — a value from data.
|
|
10
|
+
|
|
11
|
+
## Why it is not a `Badge` or a status dot
|
|
12
|
+
|
|
13
|
+
`Badge` and `LiveStatusIndicator` both take an `intent`, because both show a *state* whose
|
|
14
|
+
colour the system owns and can name — `danger` is red and is called "danger". A swatch
|
|
15
|
+
shows a colour the system cannot name, so the colour is a `color` prop that lands in an
|
|
16
|
+
inline `style`, and the meaning travels in a **required** `label`. A `background-color` is
|
|
17
|
+
nothing to a screen reader and nothing to `getByRole`, so the type asks for the name and
|
|
18
|
+
there is no way to render one without it.
|
|
19
|
+
|
|
20
|
+
`DOT_SIZE_CLASS` is exported so an app *can* hand-roll one of these — and three across the
|
|
21
|
+
fleet did, each without a name. This is that dot, named, and sized as content rather than
|
|
22
|
+
punctuation.
|
|
23
|
+
|
|
24
|
+
## `outline` — present but inactive
|
|
25
|
+
|
|
26
|
+
`outline` keeps the hue and drops the fill. It is the one visual state a status colour
|
|
27
|
+
cannot borrow from `intent`: a subject that is there but not active — a powered-off
|
|
28
|
+
controller beside its live siblings. The ring is drawn in the colour itself, so it survives
|
|
29
|
+
where a token could not follow.
|
|
30
|
+
|
|
31
|
+
## Findable, and white stays visible
|
|
32
|
+
|
|
33
|
+
It is a `role="img"` with an accessible name, so `getByRole("img", { name })` resolves in
|
|
34
|
+
both the dot-only and labelled forms — one stable handle whether or not the text is on
|
|
35
|
+
screen. The translucent inset ring on `solid` is what keeps a white or near-white swatch
|
|
36
|
+
from vanishing against `surface-raised` in one of the two schemes.
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
<Swatch color="#1565c0" label="Blue" size="sm" />
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Published TypeScript API
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
const Swatch: ({ appearance, className, color, isLabelVisible, label, size, ...spanProps }: SwatchProps) => ReactNode
|
|
46
|
+
|
|
47
|
+
type SwatchProps = Omit<ComponentPropsWithRef<"span">, "children" | "color"> & {
|
|
48
|
+
/**
|
|
49
|
+
* `outline` keeps the hue and drops the fill — for a swatch whose
|
|
50
|
+
* subject is present but inactive. It is the one visual state a
|
|
51
|
+
* status colour cannot borrow from `intent`, because the colour is
|
|
52
|
+
* not an intent.
|
|
53
|
+
*/
|
|
54
|
+
appearance?: SwatchAppearance;
|
|
55
|
+
/**
|
|
56
|
+
* Any CSS colour, and this is the whole reason the component
|
|
57
|
+
* exists: it is a **value from data** — a physical sticker, an
|
|
58
|
+
* album's extracted accent, a user-chosen tag — not a token. A
|
|
59
|
+
* design system owns `intent.danger`; it does not own the colour
|
|
60
|
+
* of the dot somebody stuck on a game controller, and re-theming
|
|
61
|
+
* that would be re-theming the hardware. So it is a prop and lands
|
|
62
|
+
* in an inline `style`, the one sanctioned escape hatch for a
|
|
63
|
+
* runtime value.
|
|
64
|
+
*/
|
|
65
|
+
color: string;
|
|
66
|
+
isLabelVisible?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Required, and it is the point. A colour is not a name: a screen
|
|
69
|
+
* reader gets nothing at all from a `background-color`, and
|
|
70
|
+
* `getByRole("img", { name })` — the query an agent writes — has
|
|
71
|
+
* nothing to match. So the type asks for the name and there is no
|
|
72
|
+
* way to render the component without one.
|
|
73
|
+
*/
|
|
74
|
+
label: string;
|
|
75
|
+
size?: SwatchSize;
|
|
76
|
+
};
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
[Full declarations](../../dist/Swatch/Swatch.d.ts)
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Switch
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { Switch } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A boolean that takes effect the moment it is flipped — a setting, not a form value.
|
|
8
|
+
|
|
9
|
+
A `Switch` and a [`Checkbox`](Checkbox.md) are the **same state kind and
|
|
10
|
+
a different affordance**, and the split is meaning rather than looks. A checkbox is a value
|
|
11
|
+
you submit — "delete originals", "I agree". A switch is a state you toggle and live with
|
|
12
|
+
immediately — "automatic imports on". ARIA gives the second its own role, and a screen
|
|
13
|
+
reader announces "on/off" for a `switch` where it announces "checked/unchecked" for a
|
|
14
|
+
checkbox.
|
|
15
|
+
|
|
16
|
+
## A `button role="switch"`, not an `input`
|
|
17
|
+
|
|
18
|
+
The sliding track and thumb are the whole affordance, and a `<button>` styles them without
|
|
19
|
+
fighting a native control's own rendering. It carries `aria-checked` and `aria-labelledby`
|
|
20
|
+
and nothing else the browser would try to own, so its keyboard path is the button's: Tab
|
|
21
|
+
reaches it, Space and Enter flip it.
|
|
22
|
+
|
|
23
|
+
The value lives in React state seeded once from `isChecked` — the switch is the store, the
|
|
24
|
+
same way the DOM is for `Checkbox`, and the same refusal of a controlled prop.
|
|
25
|
+
|
|
26
|
+
## The thumb changes colour, not just position
|
|
27
|
+
|
|
28
|
+
On `bg-intent-accent-solid`, off on `bg-surface-sunken`, and the thumb picks the token that
|
|
29
|
+
contrasts with whichever it is sitting on. A switch whose only signal was the thumb's
|
|
30
|
+
*position* loses that signal to a `daylight` theme in sunlight or to a colour-blind reader;
|
|
31
|
+
a filled track plus a contrasting thumb survives both, which is the same reason
|
|
32
|
+
`SegmentedControl` fills its checked option rather than tinting it.
|
|
33
|
+
|
|
34
|
+
## Disabled dims, read-only does not
|
|
35
|
+
|
|
36
|
+
`isDisabled` removes the switch from the tab order and the pointer and turns the whole
|
|
37
|
+
control down with `opacity-60` — a setting the user cannot currently change, a policy
|
|
38
|
+
forced from above, still fully visible. `isReadOnly` is the other half: full contrast so
|
|
39
|
+
the state stays legible, but the accent gives way to the **neutral** intent and the flip
|
|
40
|
+
is refused (`aria-readonly`, the `onClick` guarded). A read-only switch is a value you may
|
|
41
|
+
read here and change elsewhere; a disabled one is a control that is simply off-limits now.
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import { useState } from "react"
|
|
45
|
+
|
|
46
|
+
function NotificationsSwitch() {
|
|
47
|
+
const [hasNotifications, setHasNotifications] = useState(false)
|
|
48
|
+
return <Switch label="Enable notifications" isChecked={hasNotifications} onChange={setHasNotifications} />
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Published TypeScript API
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
const Switch: ({ className, isChecked, isDisabled, isReadOnly, label, onChange, size, }: SwitchProps) => ReactNode
|
|
56
|
+
|
|
57
|
+
type SwitchProps = {
|
|
58
|
+
className?: string;
|
|
59
|
+
/**
|
|
60
|
+
* **Initial** only. The `Switch` owns it from then on — the same
|
|
61
|
+
* uncontrolled contract as `Checkbox` and `SegmentedControl`, so
|
|
62
|
+
* `onChange` reports the new state and there is no controlled
|
|
63
|
+
* `checked` prop to keep in step.
|
|
64
|
+
*/
|
|
65
|
+
isChecked?: boolean;
|
|
66
|
+
isDisabled?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Shows the state at full contrast but refuses to flip it — a
|
|
69
|
+
* setting you may read here and change elsewhere. Unlike
|
|
70
|
+
* `isDisabled` it does not dim, and it announces `aria-readonly`.
|
|
71
|
+
*/
|
|
72
|
+
isReadOnly?: boolean;
|
|
73
|
+
/** The visible text, and the switch's accessible name. */
|
|
74
|
+
label: ReactNode;
|
|
75
|
+
onChange?: (isChecked: boolean) => void;
|
|
76
|
+
size?: ControlSize;
|
|
77
|
+
};
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
[Full declarations](../../dist/Switch/Switch.d.ts)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# TableColumns
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { TableColumns } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A reusable column visibility and ordering popover. The app supplies the ordered column choices and persists them if needed. Required columns cannot be hidden. Earlier and Later buttons make ordering keyboard accessible.
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import type { ComponentProps } from "react"
|
|
11
|
+
|
|
12
|
+
function ProjectColumns({ columns, onChange }: ComponentProps<typeof TableColumns>) {
|
|
13
|
+
return <TableColumns columns={columns} label="Project columns" onChange={onChange} />
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Published TypeScript API
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
const TableColumns: ({ columns, onChange, label, }: TableColumnsProps) => import("react").JSX.Element
|
|
21
|
+
|
|
22
|
+
type TableColumnsProps = {
|
|
23
|
+
columns: readonly TableColumnChoice[];
|
|
24
|
+
onChange: (columns: TableColumnChoice[]) => void;
|
|
25
|
+
label?: string;
|
|
26
|
+
};
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
[Full declarations](../../dist/TableColumns/TableColumns.d.ts)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# TableViewport
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { TableViewport } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A comparison table keeps its columns wide enough to read. The inline surface grows with
|
|
8
|
+
its rows and uses the page's vertical scroll. Expand table opens a full-window `Dialog`.
|
|
9
|
+
The dialog body is the only scroll surface; headers and the first column stay visible.
|
|
10
|
+
Escape and Close return focus to the trigger. Only one table is mounted, so links and IDs
|
|
11
|
+
are never duplicated. The inline height and horizontal position survive expansion.
|
|
12
|
+
Expansion fades and zooms in; dismissal reverses the animation before returning to the
|
|
13
|
+
document. Reduced-motion and zero-duration profiles skip the animation.
|
|
14
|
+
|
|
15
|
+
Apps provide the semantic table, its column count, and its accessible label. Sanitizing
|
|
16
|
+
Markdown HTML and delegating document links remain the app's responsibilities. Use
|
|
17
|
+
`DataTable` for interactive records that reflow into labeled rows; use this surface for
|
|
18
|
+
comparisons where columns must stay aligned.
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import type { ReactNode } from "react"
|
|
22
|
+
|
|
23
|
+
function ProjectComparison({ table }: { table: ReactNode }) {
|
|
24
|
+
return <TableViewport columnCount={5} label="Project comparison">{table}</TableViewport>
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Published TypeScript API
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
const TableViewport: ({ children, className, columnCount, label, }: TableViewportProps) => ReactNode
|
|
32
|
+
|
|
33
|
+
type TableViewportProps = {
|
|
34
|
+
/** A semantic table. Only one copy is mounted, including when expanded. */
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
className?: string;
|
|
37
|
+
columnCount: number;
|
|
38
|
+
label: string;
|
|
39
|
+
};
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
[Full declarations](../../dist/TableViewport/TableViewport.d.ts)
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# Tabs
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { Tabs } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
**The state layer's falsification test.** Tabs is P0 for that reason and no other — the
|
|
8
|
+
fifteen ad-hoc tab bars that used to justify it were in the withdrawn evidence. The plan
|
|
9
|
+
was explicit: if this came out ugly, stop and reconsider the state layer before building
|
|
10
|
+
fifteen more components.
|
|
11
|
+
|
|
12
|
+
It did not come out ugly. The composition is two hooks and one decision.
|
|
13
|
+
|
|
14
|
+
## Two bars, and the question is not "how does it look"
|
|
15
|
+
|
|
16
|
+
**Does this section have an address?**
|
|
17
|
+
|
|
18
|
+
| | Panel tab | Routed tab |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
| The item carries | `content` | `href` |
|
|
21
|
+
| Each trigger is | `<button role="tab">` | `<a href>` |
|
|
22
|
+
| The bar is | `role="tablist"` | `<nav aria-label>` |
|
|
23
|
+
| The section is drawn by | this component | the router, through your `<Outlet />` |
|
|
24
|
+
| Which one is on | `Tabs` owns it | the address does, via `activeHref` |
|
|
25
|
+
| Reload, Back, new tab | start over | land on the same section |
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
`activeHref` is the discriminant, and it is required in the routed mode. `tabs` alone
|
|
30
|
+
could not carry the split: TypeScript does not narrow a union by the shape of an array's
|
|
31
|
+
elements, so a bar mixing the two would type-check and then render half a navigation.
|
|
32
|
+
|
|
33
|
+
### The paint is shared, and that is the point
|
|
34
|
+
|
|
35
|
+
Docket had one of each on adjacent screens wearing **different paint** — a filled pill on
|
|
36
|
+
the project bar, this underline on Settings — because a routed section switcher had to be
|
|
37
|
+
built out of `Nav`, and `Nav`'s current item is a pill. `toTabTriggerClass` is now the one
|
|
38
|
+
definition both triggers read, and `Tabs.test.tsx` compares the two computed styles
|
|
39
|
+
property by property, because a screenshot cannot tell them apart on purpose.
|
|
40
|
+
[Decision](https://github.com/Sawtaytoes/charcuterie/blob/master/docs/decisions/2026-08-31-a-routed-tab-is-a-tab-with-an-href.md).
|
|
41
|
+
|
|
42
|
+
### The routed bar is not a `tablist`
|
|
43
|
+
|
|
44
|
+
`role="tab"` on an anchor **overrides** the link role. A screen reader announces a
|
|
45
|
+
disclosure, the reader waits for a panel to appear beside it, and instead the address
|
|
46
|
+
changes and the page under them is replaced. `aria-controls` has nothing to point at
|
|
47
|
+
either — the section's content comes from the router, somewhere this component cannot see.
|
|
48
|
+
|
|
49
|
+
So the routed bar is what it actually is: a named `<nav>` of real links with
|
|
50
|
+
`aria-current="page"` on the one you are on. Which one that is comes from `Nav`'s
|
|
51
|
+
`resolveActiveKey`, imported rather than restated — whole-segment matching, deepest match
|
|
52
|
+
wins, the root is exact, an external item is never current, and the query string is not
|
|
53
|
+
part of the answer.
|
|
54
|
+
|
|
55
|
+
A **disabled** routed tab is not a link at all. `<a>` has no `disabled` attribute, so the
|
|
56
|
+
tempting version — a real `href` plus `aria-disabled` — greys out and still navigates on
|
|
57
|
+
Enter and on a middle click; it renders as a `<span aria-disabled>` instead.
|
|
58
|
+
|
|
59
|
+
### This is sub-navigation. `Nav` is still the app's destinations
|
|
60
|
+
|
|
61
|
+
The header row, the side rail and the Narrow View's menu are `Nav` + `useNavLayout`, and
|
|
62
|
+
that has not moved.
|
|
63
|
+
[Decision](https://github.com/Sawtaytoes/charcuterie/blob/master/docs/decisions/2026-08-27-nav-is-the-one-navigation-component-and-navbar-is-deprecated.md).
|
|
64
|
+
A routed `Tabs` divides **one screen** into sections, so it renders no rail, no fold and
|
|
65
|
+
no menu — a bar inside a screen has nowhere to fold to.
|
|
66
|
+
|
|
67
|
+
## The composition
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
const selection = useSinglePicker({ selectedValue: initialKey }) // which tab is chosen
|
|
71
|
+
const focus = useRovingFocus({ activeValue: initialKey }) // which tab is tabbable
|
|
72
|
+
|
|
73
|
+
// `automatic` is this line. `manual` is its absence.
|
|
74
|
+
if (activation === "automatic") selection.select(focus.activeValue)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
That one line is the whole difference between the two ARIA activation modes, and it is
|
|
78
|
+
only that small because **focus and selection are separate kinds**. In `manual`, focus
|
|
79
|
+
lands on a tab that is *not* chosen — a state the original three-kind model could not
|
|
80
|
+
represent at all, because it had one notion of "the current one" doing both jobs. The
|
|
81
|
+
`Interactive` story asserts both halves against the same component.
|
|
82
|
+
|
|
83
|
+
## Selection, not visibility
|
|
84
|
+
|
|
85
|
+
M4 built this on `VisibilityGroup`, and the panels come out one-at-a-time either way: the
|
|
86
|
+
two cores are the same shape, deliberately. What settled it is **what registers**. The
|
|
87
|
+
thing that calls `register` here is the *tab*, not the panel, and the question a tab bar
|
|
88
|
+
asks is *which one did you pick* — so the kind that answers it is `SinglePicker`, and the
|
|
89
|
+
panel's `hidden` is derived from the answer rather than being the answer.
|
|
90
|
+
|
|
91
|
+
That is not bookkeeping. Reading it the other way made `aria-selected` a report about a
|
|
92
|
+
panel's visibility, so a tab bar with **no panels at all** — a segmented filter, a view
|
|
93
|
+
switcher that swaps a route — had to model its choice as a group of visibilities it did not
|
|
94
|
+
have. `SegmentedControl` is exactly that consumer, and it shares this core rather than
|
|
95
|
+
hand-rolling a fourth one.
|
|
96
|
+
[Decision](https://github.com/Sawtaytoes/charcuterie/blob/master/docs/decisions/2026-07-30-tab-selection-is-a-single-picker.md).
|
|
97
|
+
|
|
98
|
+
## What it does not use, and why that is the answer
|
|
99
|
+
|
|
100
|
+
The plan expected `createLinkedIds` here too, alongside Visibility, VisibilityGroup, and
|
|
101
|
+
RovingFocus. **It does not fit, and forcing it would have been wrong.**
|
|
102
|
+
|
|
103
|
+
That kind exists for a *dynamic* trigger↔target pair — a `Popover` whose panel mounts and
|
|
104
|
+
unmounts, where the multiset is what stops `aria-controls` pointing at a node React has
|
|
105
|
+
already removed. A tab bar's pairing is static and known at render, so the ids are derived
|
|
106
|
+
from one `useUniqueId` and cannot get out of step at all. Three of the four kinds, and a
|
|
107
|
+
specific reason for the fourth.
|
|
108
|
+
|
|
109
|
+
## Registration is membership
|
|
110
|
+
|
|
111
|
+
A disabled tab joins the **choice** — it is still one of the options, still owns a panel
|
|
112
|
+
and an id — and stays out of the **focus** group. That is all "disabled" means here: the
|
|
113
|
+
arrow keys skip it because it is not a member, and nothing in `RovingFocus` has to know the
|
|
114
|
+
word.
|
|
115
|
+
|
|
116
|
+
`TabTrigger` is its own file for a reason that is not style: both registrations are
|
|
117
|
+
effects, and an effect cannot run in a loop. Any member of a registering group ends up
|
|
118
|
+
shaped like this.
|
|
119
|
+
|
|
120
|
+
## `activeKey` is initial, not controlled
|
|
121
|
+
|
|
122
|
+
Read once, on the first render. A parent that needs to push a value calls the hook's own
|
|
123
|
+
setter; there is no controlled mode and no prop-sync effect, which is
|
|
124
|
+
[the M2 decision](https://github.com/Sawtaytoes/charcuterie/blob/master/docs/decisions/2026-07-29-logic-hooks-are-uncontrolled.md) and
|
|
125
|
+
the thing that keeps the fleet's existing echo loops out of this library.
|
|
126
|
+
|
|
127
|
+
## Focus is moved deliberately, and only then
|
|
128
|
+
|
|
129
|
+
`RovingFocus` is state; something still has to call `.focus()`. It happens only while the
|
|
130
|
+
tablist already contains the focused element — otherwise mounting a tab bar, or any parent
|
|
131
|
+
re-render that moved `activeValue`, yanks the caret out of whatever the user was doing.
|
|
132
|
+
|
|
133
|
+
## What Tabs found in M3's own testing helper
|
|
134
|
+
|
|
135
|
+
`expectAgentDrivable` rejected every tab outright:
|
|
136
|
+
|
|
137
|
+
> Not agent-drivable: role "tab" named "Log" has a negative tabindex, so it can be clicked
|
|
138
|
+
> but never reached with Tab.
|
|
139
|
+
|
|
140
|
+
Correct for a standalone button, wrong for a tab. **A roving group's whole design is that
|
|
141
|
+
exactly one member is in the tab order** and the arrow keys reach the rest; a tab list
|
|
142
|
+
where every tab had `tabindex="0"` would be the bug.
|
|
143
|
+
|
|
144
|
+
So the rejection was not skipped for composite widgets — it was **replaced by the roving
|
|
145
|
+
rule itself**, which is the stronger assertion: inside a `tablist` / `listbox` / `menu` /
|
|
146
|
+
`radiogroup` / `tree` / `grid` / `toolbar`, exactly one enabled member may be in the tab
|
|
147
|
+
order. Zero strands the widget; several mean the pattern was never implemented.
|
|
148
|
+
`AllStates` proves the failing half too, with a four-line stub standing in for the canvas —
|
|
149
|
+
`AgentQueries` is structural precisely so that it can.
|
|
150
|
+
|
|
151
|
+
## A tab bar scrolls, it does not wrap
|
|
152
|
+
|
|
153
|
+
A wrapped tablist puts tabs on two rows, which breaks the visual row and the mental model
|
|
154
|
+
the arrow keys give — "right" stops meaning right. `ContainerBoard` appears here as a width
|
|
155
|
+
harness rather than a container-query claim: `Tabs` declares no container, because nothing
|
|
156
|
+
about it needs to *know* its width. It only has to survive being narrow.
|
|
157
|
+
|
|
158
|
+
## Manual activation is the falsification test
|
|
159
|
+
|
|
160
|
+
`automatic` and `manual` differ only in whether moving focus also *chooses* — and that
|
|
161
|
+
difference is *one line*, because focus and selection are separate kinds. Arrow through the
|
|
162
|
+
bar below and the underline stays put until Enter: focus has moved to a tab that is not
|
|
163
|
+
selected, which is a state a three-kind model cannot represent at all.
|
|
164
|
+
|
|
165
|
+
## Current tabs in a narrow bar
|
|
166
|
+
|
|
167
|
+
An overflowing bar keeps its current tab in view on first render, route changes,
|
|
168
|
+
and reflow. It scrolls only itself, without moving focus or the surrounding page.
|
|
169
|
+
Manual panel activation keeps the focused tab visible even while another panel
|
|
170
|
+
remains selected. A reader can still scroll to other tabs.
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
<Tabs label="Project sections" tabs={[{ key: "overview", label: "Overview", content: <p>Project summary</p> }]} />
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Published TypeScript API
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
const Tabs: (props: TabsProps) => ReactNode
|
|
180
|
+
|
|
181
|
+
type TabsProps = TabsLinkProps | TabsPanelProps;
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
[Full declarations](../../dist/Tabs/Tabs.d.ts)
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# TextLink
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { TextLink } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
**Navigation that looks like a link.** Reach for it whenever pressing the thing takes the
|
|
8
|
+
user somewhere — another route, another page, another site. If it changes something on the
|
|
9
|
+
page instead, that is a `Button`
|
|
10
|
+
([decision](https://github.com/Sawtaytoes/charcuterie/blob/master/docs/decisions/2026-08-10-buttons-are-actions-links-are-navigation.md)).
|
|
11
|
+
|
|
12
|
+
Measured across the fleet before this shipped: **seven repos** hand-roll a back-link with a
|
|
13
|
+
literal `←`, each with its own hover rule and its own idea of whether focus is visible — and
|
|
14
|
+
points-market, which already consumes this library, reaches for a ghost `Button` for its
|
|
15
|
+
header home link because there was nothing else to reach for. All of them are an `<a href>`
|
|
16
|
+
here, so middle-click, ctrl-click, "open in new tab", "copy link address", and the browser's
|
|
17
|
+
status bar work without anybody implementing them.
|
|
18
|
+
|
|
19
|
+
## Two appearances
|
|
20
|
+
|
|
21
|
+
| | `inline` | `standalone` |
|
|
22
|
+
| --- | --- | --- |
|
|
23
|
+
| Where it lives | inside a sentence | on its own — a back-link, a nav item, a "view all" |
|
|
24
|
+
| Display | `inline`, so it wraps with the prose | `inline-flex`, with a gap for an icon |
|
|
25
|
+
| Underline | always | on hover |
|
|
26
|
+
| Type size | inherited — never its own | inherited |
|
|
27
|
+
|
|
28
|
+
The permanent underline on `inline` is not a taste call: inside a paragraph, colour alone
|
|
29
|
+
cannot be the only thing marking a link (WCAG 1.4.1). A standalone nav column has position
|
|
30
|
+
and spacing doing that work, so it underlines on hover instead — a column of permanently
|
|
31
|
+
underlined items reads as a mistake.
|
|
32
|
+
|
|
33
|
+
There is deliberately **no `size` prop**. Text takes the size of the text around it; a link
|
|
34
|
+
that resized itself would be a hole in whatever type scale it landed in.
|
|
35
|
+
|
|
36
|
+
## What it fixes
|
|
37
|
+
|
|
38
|
+
| Fleet behaviour today | Here |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| `<div onClick>` or `<button onClick={() => navigate(…)}>` as a nav item | a real `<a href>`, with everything the browser gives one |
|
|
41
|
+
| A `←` and its label as two siblings, so only the label is the tap target | one anchor, arrow inside it |
|
|
42
|
+
| `outline-none` with nothing put back | `focus-visible` at the variant's own ring width |
|
|
43
|
+
| `target="_blank"` with no `rel` and no warning | `isExternal` does all three |
|
|
44
|
+
| Seven spellings of the same hover | one |
|
|
45
|
+
|
|
46
|
+
## Accessibility contract
|
|
47
|
+
|
|
48
|
+
- The accessible name is the children. An `iconStart`/`iconEnd` is decoration inside the
|
|
49
|
+
same anchor, so the name stays the words.
|
|
50
|
+
- `isExternal` adds a visually-hidden **"(opens in a new tab)"** to the name, because a new
|
|
51
|
+
tab with no warning is a WCAG 3.2.5 surprise — and `rel="noopener noreferrer"`, because
|
|
52
|
+
`target="_blank"` alone hands the destination a live `window.opener` into the app.
|
|
53
|
+
- `isDisabled` **drops `href`** and sets `aria-disabled` with an explicit `role="link"`. An
|
|
54
|
+
anchor with no `href` is inert and out of the tab order by the platform's own rules,
|
|
55
|
+
which is the honest version of a state the platform does not have; the role keeps it
|
|
56
|
+
announced as an unavailable link rather than vanishing into a `<span>`. Reach for it
|
|
57
|
+
rarely — a dead link in a sentence usually reads better as plain text.
|
|
58
|
+
- Hover changes the **underline**, never the colour. There is no `intent.*.content-hover`
|
|
59
|
+
token, and an invented colour is one the contrast gate has never measured.
|
|
60
|
+
|
|
61
|
+
## Icons are the app's
|
|
62
|
+
|
|
63
|
+
The library ships **zero** SVGs and no symbol glyphs in a default
|
|
64
|
+
([decision](https://github.com/Sawtaytoes/charcuterie/blob/master/docs/decisions/2026-07-29-ship-no-icons-and-no-symbol-glyphs.md)) —
|
|
65
|
+
`←` and `↗` measure blank in this repo's headless Chromium and on the kiosk Pis, so the
|
|
66
|
+
component takes a `ReactNode` and the app passes the arrow it already owns.
|
|
67
|
+
|
|
68
|
+
## Routing
|
|
69
|
+
|
|
70
|
+
`TextLink` renders through whatever link component the app injected at its root, and a
|
|
71
|
+
plain `<a>` when nothing is injected. See **Guides/Routing**.
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
<TextLink appearance="standalone" href="/projects">Back to projects</TextLink>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Published TypeScript API
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
const TextLink: ({ appearance, children, className, href, iconEnd, iconStart, intent, isDisabled, isExternal, newTabLabel, ...anchorProps }: TextLinkProps) => ReactNode
|
|
81
|
+
|
|
82
|
+
type TextLinkProps = Omit<ComponentPropsWithRef<"a">, "href"> & {
|
|
83
|
+
appearance?: TextLinkAppearance;
|
|
84
|
+
/**
|
|
85
|
+
* Required, and required even when disabled — a navigation that
|
|
86
|
+
* cannot say where it goes is a button wearing a link's clothes.
|
|
87
|
+
*/
|
|
88
|
+
href: string;
|
|
89
|
+
iconEnd?: ReactNode;
|
|
90
|
+
/**
|
|
91
|
+
* The back-arrow, supplied by the app. The library ships no glyphs
|
|
92
|
+
* — see
|
|
93
|
+
* `docs/decisions/2026-07-29-ship-no-icons-and-no-symbol-glyphs.md`
|
|
94
|
+
* — and the seven repos that hand-roll a `← Back` today already own
|
|
95
|
+
* the character they want.
|
|
96
|
+
*/
|
|
97
|
+
iconStart?: ReactNode;
|
|
98
|
+
intent?: IntentName;
|
|
99
|
+
isDisabled?: boolean;
|
|
100
|
+
isExternal?: boolean;
|
|
101
|
+
/** What `isExternal` announces. Not shown. */
|
|
102
|
+
newTabLabel?: string;
|
|
103
|
+
};
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
[Full declarations](../../dist/TextLink/TextLink.d.ts)
|