@charcuterie/ui 4.29.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/dist/CatalogPicker/CatalogPicker.d.ts +7 -2
- package/dist/CatalogPicker/CatalogPicker.d.ts.map +1 -1
- package/dist/CatalogPicker/CatalogPicker.js +6 -3
- package/dist/CatalogPicker/CatalogPicker.js.map +1 -1
- package/dist/CatalogPicker/CatalogPickerOption.d.ts +1 -1
- package/dist/CatalogPicker/CatalogPickerOption.d.ts.map +1 -1
- package/dist/CatalogPicker/CatalogPickerOption.js +5 -4
- package/dist/CatalogPicker/CatalogPickerOption.js.map +1 -1
- package/dist/CatalogPicker/catalogPickerView.d.ts +13 -1
- package/dist/CatalogPicker/catalogPickerView.d.ts.map +1 -1
- package/dist/CatalogPicker/catalogPickerView.js +10 -0
- package/dist/CatalogPicker/catalogPickerView.js.map +1 -1
- 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/CatalogPicker/CatalogPicker.mdx +36 -1
- package/src/CatalogPicker/CatalogPicker.test.tsx +264 -24
- package/src/CatalogPicker/CatalogPicker.tsx +14 -3
- package/src/CatalogPicker/CatalogPickerOption.tsx +19 -6
- package/src/CatalogPicker/catalogPickerView.test.ts +19 -0
- package/src/CatalogPicker/catalogPickerView.ts +20 -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,169 @@
|
|
|
1
|
+
# PortraitTiles
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { PortraitTiles } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A set of **people** — or of anything else picked by its face — drawn as round pictures with a
|
|
8
|
+
name and one big number.
|
|
9
|
+
|
|
10
|
+
points-market's "Who's shopping?" is the shape this is taken from. It had been hand-rolled
|
|
11
|
+
there since the app was built, and it is the third tile shape the fleet grew on its own,
|
|
12
|
+
after mux-magic's and Gallery Downloader's "Pick a tool" cards.
|
|
13
|
+
|
|
14
|
+
## Why this is not an `ActionTiles` variant
|
|
15
|
+
|
|
16
|
+
The two answer different questions.
|
|
17
|
+
|
|
18
|
+
- [`ActionTiles`](ActionTiles.md) asks **what do you want to
|
|
19
|
+
do** — a name, a line of help, an icon that illustrates a verb.
|
|
20
|
+
- This asks **who is this** — a face, and one number that decides it. There is no
|
|
21
|
+
description, because a person is not explained.
|
|
22
|
+
|
|
23
|
+
Collapsing them would mean one component whose `icon` is sometimes a 20px glyph beside the
|
|
24
|
+
title and sometimes a 144px circle above it, with `hint` meaning "what this does" in one mode
|
|
25
|
+
and "points" in the other. That is two components wearing one name.
|
|
26
|
+
|
|
27
|
+
What they **do** share is the box: `tileStyles.ts` holds the border, the radius, the surface
|
|
28
|
+
and the `auto-fill` grid, and both read it. A page carrying both does not show two different
|
|
29
|
+
cards.
|
|
30
|
+
|
|
31
|
+
## It scales, and the scaling is the point
|
|
32
|
+
|
|
33
|
+
Two axes carry it, and neither is a pixel count in an app.
|
|
34
|
+
|
|
35
|
+
**The container.** `layout="auto"` is a row while the set is narrow and a column once it has
|
|
36
|
+
room, off a `cq-sm` (24rem) query on the set itself. Nothing reads the viewport, so a picker
|
|
37
|
+
in a 320px sidebar on a 2560px monitor gets the row form — which is right, and which a media
|
|
38
|
+
query would have got wrong.
|
|
39
|
+
|
|
40
|
+
**The density.** Every length is a token, so `data-density="kiosk"` grows the type ramp
|
|
41
|
+
underneath it: `text-2xl` is 30px at `comfortable` and 38px at `kiosk`. points-market runs
|
|
42
|
+
`kiosk` today, and that is where its big numbers come from.
|
|
43
|
+
|
|
44
|
+
The container and the element querying it **cannot be the same box** — a container query
|
|
45
|
+
matches descendants only. The set renders a wrapper for that reason, the same arrangement
|
|
46
|
+
`EmptyState` uses, and `className` stays on the outer element where a consumer expects it.
|
|
47
|
+
|
|
48
|
+
## The colour is the person's, not the position's
|
|
49
|
+
|
|
50
|
+
A portrait takes the next hue from the ten-wide
|
|
51
|
+
categorical palette when it names none, which costs a call
|
|
52
|
+
site nothing and is the right default for a list assembled on the fly.
|
|
53
|
+
|
|
54
|
+
It is the **wrong** default for a household. Add a fifth member and the first four change
|
|
55
|
+
colour — and their colour was the thing the picker was being read by, faster than the names
|
|
56
|
+
were. Any set whose subjects persist should store a `categorical` per subject and pass it,
|
|
57
|
+
the same call Docket makes for a project.
|
|
58
|
+
|
|
59
|
+
`categorical` and not `intent`: an intent is a claim the design system makes — `danger` says
|
|
60
|
+
what happens if you press the thing — and a person is not a warning.
|
|
61
|
+
|
|
62
|
+
### When the colour is not ours to choose
|
|
63
|
+
|
|
64
|
+
Some colours are not a design decision at all. points-market colours each child to match the
|
|
65
|
+
**NFC card they physically tap**, by a settled household decision, so the picker on the wall
|
|
66
|
+
and the card in their hand have to agree. Ten audited hues cannot promise that, and
|
|
67
|
+
re-theming the colour would be re-theming the card.
|
|
68
|
+
|
|
69
|
+
That is what `color` is for, and it is the same line
|
|
70
|
+
[`Swatch`](Swatch.md) draws: a colour that arrived from the world is
|
|
71
|
+
data, not a token. It reaches the paint through custom properties on the tile, because
|
|
72
|
+
Tailwind generates its CSS at build time from source text and a colour out of a database is
|
|
73
|
+
not in the source.
|
|
74
|
+
|
|
75
|
+
Three things happen to that one colour, and only the first uses it raw.
|
|
76
|
+
|
|
77
|
+
- The **fill** is the colour, exactly.
|
|
78
|
+
- The **initials** are black or white, whichever the fill can carry — which is why the third
|
|
79
|
+
portrait below has white letters and the other two have black. Pass six-digit hex:
|
|
80
|
+
`getReadableTextColour` measures hex and nothing else, and falls back to white on anything
|
|
81
|
+
it cannot parse rather than throwing inside your render.
|
|
82
|
+
- The **number** is the colour mixed toward the scheme's own text colour, so a pale card
|
|
83
|
+
colour is still readable on a pale surface — and, in the dark scheme, is pulled the other
|
|
84
|
+
way instead.
|
|
85
|
+
|
|
86
|
+
Reach for this arm only when the colour is a **fact about the subject**. A colour that is
|
|
87
|
+
merely a choice is `categorical`, and it gets re-theming and a contrast guarantee for free.
|
|
88
|
+
|
|
89
|
+
## A picture, and what happens when it 404s
|
|
90
|
+
|
|
91
|
+
`imageSrc` draws a photo; `initials` draws a letter on the hue's solid fill. A portrait grid
|
|
92
|
+
is the shape that cannot absorb a broken image — a missing `<img>` is a torn hole where a
|
|
93
|
+
face was, next to three that loaded — so a load error falls back to the initials the caller
|
|
94
|
+
already supplied.
|
|
95
|
+
|
|
96
|
+
The `<img>` is `alt=""` on purpose. The name is beside it inside the same tile, so an alt
|
|
97
|
+
here is the name announced twice.
|
|
98
|
+
|
|
99
|
+
## The keyboard is the platform's
|
|
100
|
+
|
|
101
|
+
`href` makes a portrait a real `<a href>`, routed through the injected `RouterLink` for a
|
|
102
|
+
same-origin destination — so middle-click, ctrl-click, "open in a new tab" and "copy link
|
|
103
|
+
address" come from the element rather than from the paint. Without one it is a `<button>`
|
|
104
|
+
that calls `onChoose`. A set may mix the two.
|
|
105
|
+
|
|
106
|
+
Tab reaches **each** portrait. There is no roving tabindex, for the same reason `ActionTiles`
|
|
107
|
+
has none: a radio group borrows one tab stop because exactly one of its options is true at a
|
|
108
|
+
time, and nothing here is true.
|
|
109
|
+
|
|
110
|
+
The group takes a required `label` naming the set — "Who's shopping?" — and `stat` is drawn
|
|
111
|
+
inside the tile with its `hint` so both are part of the accessible name. "1,240" on its own
|
|
112
|
+
tells a screen-reader user nothing.
|
|
113
|
+
|
|
114
|
+
## The lift, and who does not get it
|
|
115
|
+
|
|
116
|
+
Hovering raises the portrait and casts a shadow. It is the one piece of motion in this
|
|
117
|
+
library, kept because it is the thing the owner pointed at in points-market when this moved
|
|
118
|
+
in here.
|
|
119
|
+
|
|
120
|
+
`motion-reduce:hover:translate-y-0` turns the movement off for anyone who has asked the OS
|
|
121
|
+
for less. The shadow and the coloured border stay, so the hover is still legible without it.
|
|
122
|
+
|
|
123
|
+
## What this deliberately does not do
|
|
124
|
+
|
|
125
|
+
- **Hold a selection.** Nothing here is checked; the page moved on. A picker that keeps a
|
|
126
|
+
value is `RadioGroup itemShape="tile"`.
|
|
127
|
+
- **Guarantee contrast on a `color` you supply.** The palette arm is audited in both schemes;
|
|
128
|
+
the data arm cannot be, because the colour is not ours. The initials are picked to suit the
|
|
129
|
+
fill and the number is pulled toward readable, and that is the whole of what it can promise.
|
|
130
|
+
- **Crop or focus a face.** `object-fit: cover` centres, and that is all. An app that needs a
|
|
131
|
+
focal point owns the crop.
|
|
132
|
+
|
|
133
|
+
## Bounded choices fill their row
|
|
134
|
+
|
|
135
|
+
Use `isFillingRow` for a known set of people. Empty tracks collapse rather than reserving
|
|
136
|
+
space for another person. `minTileInlineSize` still decides when the next column fits.
|
|
137
|
+
The default continues to reserve empty tracks for a growing gallery.
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
function Reviewers({ assign }: { assign: (key: string) => void }) {
|
|
141
|
+
return <PortraitTiles label="Choose reviewer" onChoose={assign}
|
|
142
|
+
items={[{ initials: "AS", label: "Alex Smith", value: "alex" }]} />
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Published TypeScript API
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
const PortraitTiles: ({ className, items, label, layout, minTileInlineSize, isFillingRow, newTabLabel, onChoose, size, }: PortraitTilesProps) => ReactNode
|
|
150
|
+
|
|
151
|
+
type PortraitTilesProps = {
|
|
152
|
+
className?: string;
|
|
153
|
+
items: readonly PortraitTileItem[];
|
|
154
|
+
/** The set's accessible name. Required. */
|
|
155
|
+
label: string;
|
|
156
|
+
layout?: PortraitTilesLayout;
|
|
157
|
+
/** The narrowest a portrait track may be, in CSS px. */
|
|
158
|
+
minTileInlineSize?: number;
|
|
159
|
+
/** Fill available rows and center an incomplete final row without widening its tiles. */
|
|
160
|
+
isFillingRow?: boolean;
|
|
161
|
+
/** What `isExternal` announces. Not shown. */
|
|
162
|
+
newTabLabel?: string;
|
|
163
|
+
/** Fired by a portrait that carries no `href`. */
|
|
164
|
+
onChoose?: (value: string) => void;
|
|
165
|
+
size?: ControlSize;
|
|
166
|
+
};
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
[Full declarations](../../dist/PortraitTiles/PortraitTiles.d.ts)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# ProgressBar
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { ProgressBar } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Five repos hand-roll one and **only rip-deck's has `role="progressbar"`**. The other four
|
|
8
|
+
are a `<div>` with a percentage width: invisible to assistive technology and to
|
|
9
|
+
`getByRole("progressbar")`.
|
|
10
|
+
|
|
11
|
+
This is the union — rip-deck's ARIA and its indeterminate sweep, plus threshold colours
|
|
12
|
+
nobody has yet.
|
|
13
|
+
|
|
14
|
+
## Three corrections to rip-deck's version
|
|
15
|
+
|
|
16
|
+
1. **The role goes on the track, not the fill.** rip-deck puts `role="progressbar"` on the
|
|
17
|
+
filled element, so a 4% rip is a progressbar 4px wide as far as AT and a Playwright
|
|
18
|
+
bounding box are concerned.
|
|
19
|
+
2. **The name comes from a real label**, wired with `aria-labelledby` — visible or
|
|
20
|
+
`VisuallyHidden` — rather than a hardcoded `aria-label` that cannot be translated.
|
|
21
|
+
3. **`aria-valuenow` is omitted while indeterminate**, which is what says "unknown" rather
|
|
22
|
+
than "zero".
|
|
23
|
+
|
|
24
|
+
## Indeterminate means "no measurable progress yet"
|
|
25
|
+
|
|
26
|
+
Not zero, and not unknown-therefore-full. rip-deck's case is the AACS/BD+ preamble: ~25 s
|
|
27
|
+
of a real Blu-ray emitting nothing, where a full bar reads as a finished rip and an empty
|
|
28
|
+
one as a wedged drive. The sweep animates `inset-inline-start`, so it runs the other way in
|
|
29
|
+
RTL for free, and its reduced-motion fallback hatches the whole track rather than parking a
|
|
30
|
+
bar at one end.
|
|
31
|
+
|
|
32
|
+
## Values arrive from a log parser
|
|
33
|
+
|
|
34
|
+
`-1`, `101`, `NaN`, and `0 of 0` are all normal in this fleet, so clamping is a tested pure
|
|
35
|
+
function (`progressValue.ts`) and `aria-valuenow` is clamped in the value's own units —
|
|
36
|
+
never disagreeing with what is drawn.
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
<ProgressBar label="Import progress" value={45} isValueShown />
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Published TypeScript API
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
const ProgressBar: ({ className, intent, isIndeterminate, isLabelVisible, isValueShown, label, max, overlay, size, thresholds, value, ...divProps }: ProgressBarProps) => ReactNode
|
|
46
|
+
|
|
47
|
+
type ProgressBarProps = Omit<ComponentPropsWithRef<"div">, "children"> & {
|
|
48
|
+
intent?: IntentName;
|
|
49
|
+
/**
|
|
50
|
+
* Indeterminate means "working, no measurable progress yet" — not
|
|
51
|
+
* zero and not unknown-therefore-full. rip-deck's is the
|
|
52
|
+
* AACS/BD+ preamble: ~25 s of a real Blu-ray emitting nothing, in
|
|
53
|
+
* which a full bar reads as a finished rip and an empty one as a
|
|
54
|
+
* wedged drive.
|
|
55
|
+
*/
|
|
56
|
+
isIndeterminate?: boolean;
|
|
57
|
+
isLabelVisible?: boolean;
|
|
58
|
+
isValueShown?: boolean;
|
|
59
|
+
/** Required. A progressbar with no name is a grey rectangle. */
|
|
60
|
+
label: string;
|
|
61
|
+
max?: number;
|
|
62
|
+
/** Content above a full-height, muted track. It stays outside the ARIA widget. */
|
|
63
|
+
overlay?: ReactNode;
|
|
64
|
+
size?: ProgressBarSize;
|
|
65
|
+
thresholds?: readonly ProgressThreshold[];
|
|
66
|
+
value?: number;
|
|
67
|
+
};
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
[Full declarations](../../dist/ProgressBar/ProgressBar.d.ts)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# ProgressCard
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { ProgressCard } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A progress-first card with a large value over a filled band and distinct metric blocks.
|
|
8
|
+
Use it for transfers, imports, backups, or other measurable work. `Card` owns the shell;
|
|
9
|
+
`ProgressBar` owns clamping, the named ARIA widget, and indeterminate motion.
|
|
10
|
+
|
|
11
|
+
## Ownership
|
|
12
|
+
|
|
13
|
+
The library owns layout, responsive typography, metric contrast, and whole-card intent.
|
|
14
|
+
The app supplies identity, media, formatted values, actions, and meaningful issue text.
|
|
15
|
+
Neither an absent diagnosis nor a numeric percentage implies a warning here.
|
|
16
|
+
|
|
17
|
+
`intent` colors the entire card; `progressIntent` colors the fill independently.
|
|
18
|
+
`valueText` is app-formatted text, while `value` and `max` drive measurable progress.
|
|
19
|
+
Set `isIndeterminate` when progress cannot yet be measured and use a state such as
|
|
20
|
+
"Preparing" for `valueText`. Set `isValueEmphasized={false}` for terminal state text.
|
|
21
|
+
The band overlay stays outside the progressbar role so its content retains semantics.
|
|
22
|
+
|
|
23
|
+
## Layouts and states
|
|
24
|
+
|
|
25
|
+
`band` is the default. `hierarchy` places the same headline above a thin progress track.
|
|
26
|
+
Metrics stack when their own content area is narrow, even if media makes the whole card
|
|
27
|
+
wide. The viewport does not decide this. Labels should be unique.
|
|
28
|
+
|
|
29
|
+
## App-owned controls
|
|
30
|
+
|
|
31
|
+
Action slots use the same controls as the rest of the app. The card does not define cancel,
|
|
32
|
+
retry, or confirmation policy. Additional issue details belong in `children`.
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
<ProgressCard aria-label="Indexing files" header="Indexing files"
|
|
36
|
+
progressLabel="Indexing progress" value={72} max={100} valueText="72%" />
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Published TypeScript API
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
const ProgressCard: ({ actions, children, className, header, intent, isIndeterminate, isValueEmphasized, layout, max, media, metrics, progressIntent, progressLabel, status, value, valueText, ...cardProps }: ProgressCardProps) => ReactNode
|
|
43
|
+
|
|
44
|
+
type ProgressCardProps = Omit<CardProps, "heading" | "footer"> & {
|
|
45
|
+
"aria-label": string;
|
|
46
|
+
/** App-owned identity: a title, an identifier, or a format mark. */
|
|
47
|
+
header: ReactNode;
|
|
48
|
+
/** Whole-card intent is independent of the progress fill. */
|
|
49
|
+
intent?: IntentName;
|
|
50
|
+
isIndeterminate?: boolean;
|
|
51
|
+
isValueEmphasized?: boolean;
|
|
52
|
+
layout?: ProgressCardLayout;
|
|
53
|
+
max?: number;
|
|
54
|
+
media?: ReactNode;
|
|
55
|
+
metrics?: readonly ProgressCardMetric[];
|
|
56
|
+
progressIntent?: IntentName;
|
|
57
|
+
progressLabel: string;
|
|
58
|
+
status?: string;
|
|
59
|
+
value?: number;
|
|
60
|
+
/** App-formatted percentage or terminal state; never inferred from intent. */
|
|
61
|
+
valueText: string;
|
|
62
|
+
};
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
[Full declarations](../../dist/ProgressCard/ProgressCard.d.ts)
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# QueryBuilder
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { QueryBuilder } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
The generic, nestable **AND/OR — and any-combinator — group editor**. A recursive group of
|
|
8
|
+
conditions, each group carrying a combinator the app owns and each leaf carrying a value the
|
|
9
|
+
app owns. Two apps in the fleet grow the same widget from opposite ends: Mail Sifter's nested
|
|
10
|
+
mail rules (leaf = field/operator/value, combinators AND/OR) and mux-magic's job DSL
|
|
11
|
+
(non-uniform leaves, combinators any/all/none). So both the **leaf value** and the **group
|
|
12
|
+
combinator** are fully opaque here — `Combinator` and `Leaf` only ever pass through to the
|
|
13
|
+
consumer's `renderLeaf` and `combinatorOptions`.
|
|
14
|
+
|
|
15
|
+
## The state is a `Tree`, and the consumer owns it
|
|
16
|
+
|
|
17
|
+
`QueryBuilder` holds no state of its own. It takes a `Tree` core from
|
|
18
|
+
`useTree` and subscribes to it, the same way a `Listbox`'s
|
|
19
|
+
parent owns `useVisibility` and hands it down. That is what leaves `serialize()` — the
|
|
20
|
+
YAML/DB round-trip — and the initial tree in the consumer's hands.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
Because the tree is normalized and addressed by id, a `patchLeaf` deep in the tree re-renders
|
|
25
|
+
only the rows whose node identity changed — the same `useSyncExternalStore` identity
|
|
26
|
+
discipline the whole state layer rests on.
|
|
27
|
+
|
|
28
|
+
## Nesting, and depth
|
|
29
|
+
|
|
30
|
+
A group renders leaf rows and nested groups, recursively. The nested group wears a
|
|
31
|
+
semantic-token inline-start rail so depth reads without a raw palette colour, and it moves to
|
|
32
|
+
the sunken surface so it recedes rather than floating at the same level as its parent.
|
|
33
|
+
|
|
34
|
+
## Driving it
|
|
35
|
+
|
|
36
|
+
Every control is nameable, not a `data-testid`: the combinator picker is a `Listbox` whose
|
|
37
|
+
trigger is named `Match: <current combinator>`, the leaf controls by their own labels, and each
|
|
38
|
+
delete is an `IconButton` whose required `label` makes it findable. Add a condition, nest a
|
|
39
|
+
group, flip a combinator, delete a row — all reachable by role and name.
|
|
40
|
+
|
|
41
|
+
The picker is a `Listbox` rather than a native `Select`, per
|
|
42
|
+
[the 2026-08-10 demotion](https://github.com/Sawtaytoes/charcuterie/blob/master/docs/decisions/2026-08-10-listbox-and-combobox-are-the-default-and-select-is-demoted.md).
|
|
43
|
+
Its name carries the current value because the trigger's visible text *is* that value, and
|
|
44
|
+
WCAG 2.5.3 wants the visible text contained in the accessible name — so query it with
|
|
45
|
+
`getByRole("button", { name: /^Match: / })`, not by the bare caption. Rename the caption with
|
|
46
|
+
`labels.match`.
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { useTree } from "@charcuterie/logic"
|
|
50
|
+
|
|
51
|
+
function Filters() {
|
|
52
|
+
const tree = useTree<"and" | "or", string>({ defaultCombinator: "and" })
|
|
53
|
+
return <QueryBuilder tree={tree} createLeafValue={() => ""}
|
|
54
|
+
combinatorOptions={[{ label: "All", value: "and" }, { label: "Any", value: "or" }]}
|
|
55
|
+
renderLeaf={({ value, onChange }) =>
|
|
56
|
+
<input aria-label="Filter text" value={value} onChange={(event) => onChange(event.currentTarget.value)} />} />
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Published TypeScript API
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
const QueryBuilder: <Combinator, Leaf>({ combinatorOptions, createLeafValue, labels, renderCombinator, renderLeaf, tree, }: QueryBuilderProps<Combinator, Leaf>) => ReactNode
|
|
64
|
+
|
|
65
|
+
type QueryBuilderProps<Combinator, Leaf> = {
|
|
66
|
+
/**
|
|
67
|
+
* The combinator choices offered in every group's "Match" select.
|
|
68
|
+
* The `value` is opaque — `and`/`or` for a mail rule, `any`/`all`/
|
|
69
|
+
* `none` for a DSL — and the `label` is what a user reads.
|
|
70
|
+
*/
|
|
71
|
+
combinatorOptions: readonly {
|
|
72
|
+
label: string;
|
|
73
|
+
value: Combinator;
|
|
74
|
+
}[];
|
|
75
|
+
/** The value a fresh leaf is born with when "+ Condition" is pressed. */
|
|
76
|
+
createLeafValue: () => Leaf;
|
|
77
|
+
labels?: QueryBuilderLabels;
|
|
78
|
+
/**
|
|
79
|
+
* The group's combinator control, when one `Listbox` over a flat
|
|
80
|
+
* option list is the wrong shape for it.
|
|
81
|
+
*
|
|
82
|
+
* Optional, and the default is the right answer for most consumers:
|
|
83
|
+
* a combinator that is a plain enum reads as one picker. But a
|
|
84
|
+
* combinator can be a *composite* — mux-magic's is a quantifier
|
|
85
|
+
* (ANY/ALL/NO) crossed with a target (a nested group, a style row,
|
|
86
|
+
* a script-info block), and the legal pairs are asymmetric
|
|
87
|
+
* (`notAllScriptInfo` exists, `notAllStyle` does not). Flattened
|
|
88
|
+
* into one list that is nine options where the user is making two
|
|
89
|
+
* choices, and the illegal pairs are invisible until they are
|
|
90
|
+
* missing.
|
|
91
|
+
*
|
|
92
|
+
* So the combinator is app-ownable for the same reason `renderLeaf`
|
|
93
|
+
* is: `Combinator` is opaque here, and only the app knows whether
|
|
94
|
+
* its shape is an enum or a product. `options` and the current
|
|
95
|
+
* `value` are handed over unchanged; the app calls `onChange` with a
|
|
96
|
+
* real `Combinator`.
|
|
97
|
+
*/
|
|
98
|
+
renderCombinator?: (args: {
|
|
99
|
+
nodeId: string;
|
|
100
|
+
onChange: (combinator: Combinator) => void;
|
|
101
|
+
options: readonly {
|
|
102
|
+
label: string;
|
|
103
|
+
value: Combinator;
|
|
104
|
+
}[];
|
|
105
|
+
value: Combinator;
|
|
106
|
+
}) => ReactNode;
|
|
107
|
+
/**
|
|
108
|
+
* The leaf UI, owned by the app. `QueryBuilder` knows nothing about
|
|
109
|
+
* what a condition *is* — a field/operator/value triple, a
|
|
110
|
+
* non-uniform per-kind shape — only that it can be rendered and
|
|
111
|
+
* patched. The delete control around each leaf is the builder's.
|
|
112
|
+
*/
|
|
113
|
+
renderLeaf: (args: {
|
|
114
|
+
nodeId: string;
|
|
115
|
+
onChange: (value: Leaf) => void;
|
|
116
|
+
value: Leaf;
|
|
117
|
+
}) => ReactNode;
|
|
118
|
+
/**
|
|
119
|
+
* The `Tree` core from `useTree`, owned by the consumer — the same
|
|
120
|
+
* arrangement as a `Listbox`'s parent owning `useVisibility`.
|
|
121
|
+
* `QueryBuilder` subscribes to it and drives it; it never creates
|
|
122
|
+
* one, so a consumer keeps `serialize()` and the initial tree.
|
|
123
|
+
*/
|
|
124
|
+
tree: Tree<Combinator, Leaf>;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
Combinator
|
|
128
|
+
|
|
129
|
+
Leaf
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
[Full declarations](../../dist/QueryBuilder/QueryBuilder.d.ts)
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# RadioGroup
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { RadioGroup } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
One choice out of many, each on its own row with a label the size of prose.
|
|
8
|
+
|
|
9
|
+
`RadioGroup` and [`SegmentedControl`](SegmentedControl.md) are the
|
|
10
|
+
**same composition** — `SinglePicker` + `RovingFocus`, a `radiogroup` of `radio`s where
|
|
11
|
+
selection follows focus — and a different shape. The segmented strip is compact, for a
|
|
12
|
+
handful of short options that share a control row; the radio group is form-length, where
|
|
13
|
+
each option carries a real sentence and an in-line strip would wrap. Choosing between them
|
|
14
|
+
is layout, not behaviour, which is why the keyboard model is identical and lives in the same
|
|
15
|
+
two hooks.
|
|
16
|
+
|
|
17
|
+
## `radiogroup`, not a stack of checkboxes
|
|
18
|
+
|
|
19
|
+
A column of `<input type="checkbox">` is the **independent toggles** pattern: nothing in it
|
|
20
|
+
says the options are mutually exclusive, so a screen reader announces each as its own
|
|
21
|
+
on/off with no "1 of 4" and no clue that checking one unchecks the rest. A single choice
|
|
22
|
+
from a named set is a radio group, and ARIA has a pattern for it — which is the same
|
|
23
|
+
correction `SegmentedControl` makes to rip-deck's row of `aria-pressed` buttons.
|
|
24
|
+
|
|
25
|
+
## Selection follows focus
|
|
26
|
+
|
|
27
|
+
APG gives a radio group one activation mode: the arrow keys both move focus and check.
|
|
28
|
+
There is nothing behind an option here to be expensive — no panel, no request — so unlike
|
|
29
|
+
`Tabs` there is no `manual` mode and no prop, because a `manual` radio group is one the
|
|
30
|
+
arrow keys appear to do nothing in. Tab enters the group once (the roving-tabindex rule),
|
|
31
|
+
the arrows move and check together, Home and End jump to the ends, and the ends wrap.
|
|
32
|
+
|
|
33
|
+
A disabled option is simply **not registered** with the roving group, so the arrows skip it
|
|
34
|
+
without any command having to know what "disabled" means. It stays registered with the
|
|
35
|
+
picker — it is still one of the options, and still the one a saved `selectedValue` may point
|
|
36
|
+
at.
|
|
37
|
+
|
|
38
|
+
## `itemShape="tile"` — the choice tile
|
|
39
|
+
|
|
40
|
+
A bordered card carrying a name, a line of help and a selected surface, laid out in a grid
|
|
41
|
+
that gains columns with its **container**. It is a prop rather than a third component
|
|
42
|
+
because **only the box changes**: the element, the `radio` role, the roving tab stop,
|
|
43
|
+
selection-follows-focus and `isReadOnly` are the ones already tested on the row shape. A
|
|
44
|
+
tile with its border taken away is a row.
|
|
45
|
+
|
|
46
|
+
`SegmentedControl` earns its own file by being a different *control* — one connected strip,
|
|
47
|
+
no radio affordance, options too short to carry a sentence. A tile is this control with a
|
|
48
|
+
border, which is a different reason.
|
|
49
|
+
|
|
50
|
+
[`ActionTiles`](ActionTiles.md) is the same tile that **acts**
|
|
51
|
+
rather than holds a value, and it *does* earn its own file: invert every clause of the
|
|
52
|
+
paragraph above — no `radio` role, no roving tabindex, no selection-follows-focus, no
|
|
53
|
+
`isReadOnly` — and the box is all that is left in common. The two read it from one
|
|
54
|
+
`tileStyles.ts`. Ask what a press does: records a value something below reads, or goes
|
|
55
|
+
somewhere and is done.
|
|
56
|
+
|
|
57
|
+
Four apps in the fleet had each hand-painted this shape — ten instances between them — and
|
|
58
|
+
**not one carried `aria-checked`**. Every one was a bare `<button>` or `<a>` whose selection
|
|
59
|
+
was visible only as colour: correct to an eye, silent to a screen reader, and announced as
|
|
60
|
+
neither pressed nor "3 of 6". That is what this prop is for, and it is why the semantics are
|
|
61
|
+
not the part an app should be writing.
|
|
62
|
+
|
|
63
|
+
Eight of the ten had a **second line** under the name, which is also why none of them
|
|
64
|
+
reached for `RadioGroup`: a plain-text `label` could not express it. `hint` can, and it
|
|
65
|
+
renders on a row as readily as on a tile.
|
|
66
|
+
|
|
67
|
+
### The selected tile is an edge and a surface, never a fill
|
|
68
|
+
|
|
69
|
+
The chosen tile takes the accent on its **border** and lifts to `surface-overlay`; the radio
|
|
70
|
+
dot inside it is unchanged and is still the thing a screen reader reads. A state told in
|
|
71
|
+
colour alone is the one state a monochrome ePaper build cannot show at all — the same reason
|
|
72
|
+
`Stepper` refuses to say "done" with a hue.
|
|
73
|
+
|
|
74
|
+
### A tile may lead with an icon
|
|
75
|
+
|
|
76
|
+
`icon` is `tile` only — a row already leads with its radio, and a second mark either side of
|
|
77
|
+
it has nowhere to sit — and it is `aria-hidden` by construction, because the name it sits
|
|
78
|
+
above is inside the same button. The library still ships no icons; apps bring their own.
|
|
79
|
+
|
|
80
|
+
## The grid takes its columns from the container
|
|
81
|
+
|
|
82
|
+
`repeat(auto-fill, minmax(min(var(--charcuterie-tile-min-inline-size), 100%), 1fr))`, and
|
|
83
|
+
each of those three parts is load-bearing:
|
|
84
|
+
|
|
85
|
+
- **`auto-fill`, not `auto-fit`.** `auto-fit` collapses the empty tracks and lets the
|
|
86
|
+
survivors share the whole row, so six tiles in a 2560px container become six 420px slabs —
|
|
87
|
+
the full-width-row shape in a new costume. `auto-fill` keeps the empty tracks, so a tile
|
|
88
|
+
stays a tile and the grid simply has room to spare.
|
|
89
|
+
- **`min(…, 100%)`.** Without it the 200px floor overflows a container narrower than one
|
|
90
|
+
tile, which is a horizontal scrollbar in the Narrow View.
|
|
91
|
+
- **A custom property, not an interpolated class.** Tailwind scans source *text* for
|
|
92
|
+
complete class strings, so `` `grid-cols-[…${n}px…]` `` generates nothing, paints nothing
|
|
93
|
+
and reports nothing. `minTileInlineSize` lands in `--charcuterie-tile-min-inline-size`,
|
|
94
|
+
which one written-out literal reads.
|
|
95
|
+
|
|
96
|
+
This is **not** `useAdaptiveColumns`, and the difference is which question is being asked.
|
|
97
|
+
That hook buys a column with **height**, for an unbounded gallery that is going to scroll. A
|
|
98
|
+
radio group is a bounded set of options inside a form section, where the only question is
|
|
99
|
+
how many fit across the box it was handed.
|
|
100
|
+
|
|
101
|
+
## A read-only group shows the choice without moving it
|
|
102
|
+
|
|
103
|
+
`isReadOnly` severs the one link that defines this component — selection follows focus — so
|
|
104
|
+
the arrow keys and clicks still travel the options for reading but no longer move the
|
|
105
|
+
choice. The group announces `aria-readonly`, and the chosen option shows at full contrast
|
|
106
|
+
in the **neutral** intent: a value you may read here and change elsewhere. That is distinct
|
|
107
|
+
from a single **disabled** option, which is dimmed with `opacity-60` and dropped from the
|
|
108
|
+
focus group but stays selectable via `selectedValue`.
|
|
109
|
+
|
|
110
|
+
## `selectedValue` is the initial value, not a controlled one
|
|
111
|
+
|
|
112
|
+
It decides the first render and nothing after — Charcuterie owns the choice from then on,
|
|
113
|
+
and `onChange` reports it outward. Members register from an effect, so on the first paint
|
|
114
|
+
the value lives in the picker's `pendingValue` and the group paints already showing it
|
|
115
|
+
rather than flashing empty for a frame — a flash on a desktop, a visible blank on a kiosk
|
|
116
|
+
Pi.
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
import { useState } from "react"
|
|
120
|
+
|
|
121
|
+
function FormatChoice() {
|
|
122
|
+
const [format, setFormat] = useState("summary")
|
|
123
|
+
return <RadioGroup label="Report format" selectedValue={format}
|
|
124
|
+
onChange={(value) => { if (value !== null) setFormat(value) }}
|
|
125
|
+
items={[{ label: "Summary", value: "summary" }, { label: "Full", value: "full" }]} />
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Published TypeScript API
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
const RadioGroup: ({ className, itemShape, items, isReadOnly, label, minTileInlineSize, onChange, selectedValue, size, }: RadioGroupProps) => ReactNode
|
|
133
|
+
|
|
134
|
+
type RadioGroupProps = {
|
|
135
|
+
className?: string;
|
|
136
|
+
/**
|
|
137
|
+
* Draws each option as a card in a grid instead of a row in a
|
|
138
|
+
* stack. Defaults to `row`.
|
|
139
|
+
*/
|
|
140
|
+
itemShape?: RadioItemShape;
|
|
141
|
+
items: readonly RadioItem[];
|
|
142
|
+
/**
|
|
143
|
+
* Shows which option is chosen at full contrast but refuses to move
|
|
144
|
+
* the choice — the arrow keys and clicks no longer select, and the
|
|
145
|
+
* group announces `aria-readonly`. Focus can still travel the
|
|
146
|
+
* options so a keyboard user can read them.
|
|
147
|
+
*/
|
|
148
|
+
isReadOnly?: boolean;
|
|
149
|
+
/** The group's accessible name. Required. */
|
|
150
|
+
label: string;
|
|
151
|
+
/**
|
|
152
|
+
* The narrowest a tile track may be, in CSS px. `tile` only.
|
|
153
|
+
*
|
|
154
|
+
* It is the grid's floor and not the tile's width: tracks below it
|
|
155
|
+
* are not created, and the ones that are share the row evenly.
|
|
156
|
+
*/
|
|
157
|
+
minTileInlineSize?: number;
|
|
158
|
+
onChange?: (selectedValue: string | null) => void;
|
|
159
|
+
/** **Initial** only. Charcuterie owns it from then on. */
|
|
160
|
+
selectedValue?: string;
|
|
161
|
+
size?: ControlSize;
|
|
162
|
+
};
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
[Full declarations](../../dist/RadioGroup/RadioGroup.d.ts)
|