@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,235 @@
|
|
|
1
|
+
# MarkdownView
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { MarkdownView } from "@charcuterie/ui/markdown-editor-codemirror"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Rendered markdown, with **no toolbar in the DOM** and nothing to type into. The same
|
|
8
|
+
document, drawn the same way, as the editor beside it.
|
|
9
|
+
|
|
10
|
+
It is **opt-in**, from the same subpath as the editor:
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { MarkdownView } from "@charcuterie/ui/markdown-editor-codemirror"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Which of the three you want
|
|
17
|
+
|
|
18
|
+
| | `MarkdownEditor` | `MarkdownEditorCodeMirror` | `MarkdownView` |
|
|
19
|
+
| --- | --- | --- | --- |
|
|
20
|
+
| For | typing markdown | typing markdown, rendered | **reading** markdown |
|
|
21
|
+
| Surface | `<textarea>` + painted layer | CodeMirror 6 | CodeMirror 6 |
|
|
22
|
+
| New dependency | none | ~176 KB gz, optional peer | the same one |
|
|
23
|
+
| Toolbar | nine buttons | nine buttons + a switch | **none, ever** |
|
|
24
|
+
| Value | `defaultValue` | `defaultValue` | **`value`, controlled** |
|
|
25
|
+
| Content role | `textbox` | `textbox` | **`article`** |
|
|
26
|
+
|
|
27
|
+
`isReadOnly` on either editor is **not** this. It means *an editor you cannot type in*: the
|
|
28
|
+
nine formatting buttons are still there, still in the accessibility tree, drawn in their
|
|
29
|
+
disabled colours above a document nobody is editing. That is right for a form field that is
|
|
30
|
+
temporarily locked, and wrong for reading a file — which is what this exists for.
|
|
31
|
+
|
|
32
|
+
## No toolbar means no toolbar
|
|
33
|
+
|
|
34
|
+
`queryAllByRole("toolbar")` returns nothing here, and so does `queryAllByRole("button")`.
|
|
35
|
+
That is asserted rather than described, because the workaround it replaces was a CSS rule
|
|
36
|
+
in a consuming app keyed on `role="toolbar"`, and CSS is a poor place to keep a promise:
|
|
37
|
+
`visibility: hidden` leaves the buttons in the accessibility tree, `opacity: 0` leaves them
|
|
38
|
+
in the tab order, and even `display: none` leaves the *overflow menu button* the toolbar
|
|
39
|
+
collapses into at narrow widths.
|
|
40
|
+
|
|
41
|
+
## It renders what the editor renders
|
|
42
|
+
|
|
43
|
+
One string, two surfaces, side by side. They agree because they **are the same code** —
|
|
44
|
+
`livePreviewRanges.ts` decides what every construct looks like and both call it, over the
|
|
45
|
+
same GFM parse, under the same theme.
|
|
46
|
+
|
|
47
|
+
That is the whole reason this lives in the CodeMirror subpath instead of being a
|
|
48
|
+
`react-markdown` reader in the main barrel. A second renderer agrees on the day it is
|
|
49
|
+
written and drifts afterwards, one construct at a time, and the bug arrives six months later
|
|
50
|
+
as *"the table changed when I saved it"*. There is no second renderer here to drift.
|
|
51
|
+
|
|
52
|
+
The cost is honest and worth stating: a consumer who wants **only** the reader still installs
|
|
53
|
+
CodeMirror. For an app that renders markdown in three places and edits it in one, that is the
|
|
54
|
+
right way round — the dependency is paid once.
|
|
55
|
+
|
|
56
|
+
## It is controlled, and the editors are not
|
|
57
|
+
|
|
58
|
+
`value` in, and that is it. Fetch a file at a different commit hash, pass the new string, and
|
|
59
|
+
the page changes — no `key`, no remount, no stale document sitting above a new title.
|
|
60
|
+
|
|
61
|
+
The editors take `defaultValue` because reassigning an `EditorView`'s document from outside
|
|
62
|
+
throws away the undo history that belonged to it, which is a real cost and is why they ask
|
|
63
|
+
for a `key` instead. A view has no undo history and no caret to protect, so it has nothing to
|
|
64
|
+
lose by simply rendering what it is given.
|
|
65
|
+
|
|
66
|
+
## A `- [ ]` box is inert unless you say where the tick goes
|
|
67
|
+
|
|
68
|
+
Pass `onToggleTask` and the checkboxes are operable; leave it out and they render
|
|
69
|
+
**disabled**. The state is still on screen either way — that is a fact about the document
|
|
70
|
+
and belongs there — but nothing pretends the reader can change it.
|
|
71
|
+
|
|
72
|
+
This is the same shape as `onUploadImage` on the editors: omit the handler and the capability
|
|
73
|
+
is simply not offered, which beats offering one that half works. Two of the three surfaces
|
|
74
|
+
this component was built for — a rendered comment, and a repo file fetched at a commit hash —
|
|
75
|
+
have nowhere to put a tick, and a box that visibly toggles and then loses the change on
|
|
76
|
+
reload is worse than one that says up front it cannot.
|
|
77
|
+
|
|
78
|
+
`onToggleTask` hands back the **whole next markdown document**, exactly like the editors'
|
|
79
|
+
`onChange`, so one autosave wires to both. The view applies the tick to its own document
|
|
80
|
+
immediately so the box responds under the pointer; if the consumer rejects the change, the
|
|
81
|
+
next `value` puts it back.
|
|
82
|
+
|
|
83
|
+
## Link text that carries its own markup
|
|
84
|
+
|
|
85
|
+
A link whose text is a code span, a bolded phrase or an emphasised one is ordinary in a
|
|
86
|
+
docs file, and until 2026-08-24 one of them took the whole surface down. The closing `]`
|
|
87
|
+
was read as *the sibling after the opening bracket*, which is true only while the text is
|
|
88
|
+
plain words — put an `InlineCode` in it and that sibling is the code span, so
|
|
89
|
+
``[`a`](url)`` produced a link-text mark with `from === to`. CodeMirror refuses an empty
|
|
90
|
+
mark decoration and throws out of the whole `ViewPlugin`, so **every** decoration in the
|
|
91
|
+
document is lost and the reader gets raw markdown.
|
|
92
|
+
|
|
93
|
+
The failure looks nothing like a link bug, which is why the story is here: one frame where
|
|
94
|
+
every link is a link, and a heading above them that has nothing to do with links and
|
|
95
|
+
stopped rendering anyway.
|
|
96
|
+
|
|
97
|
+
## Hostile markdown
|
|
98
|
+
|
|
99
|
+
This will render files fetched from a git host, so the document is untrusted by default.
|
|
100
|
+
|
|
101
|
+
**Raw HTML in the source is never parsed as HTML.** There is no `innerHTML` in this subpath,
|
|
102
|
+
no `dangerouslySetInnerHTML`, and no sanitiser to have a bug in. CodeMirror's state holds the
|
|
103
|
+
source as *text* and every rendered node is `createElement` plus `textContent`, so a
|
|
104
|
+
`<script>` in a fetched README is drawn as the characters `<script>`. It is not stripped,
|
|
105
|
+
not escaped and not "sanitised" — there is simply no code path that would turn it into an
|
|
106
|
+
element.
|
|
107
|
+
|
|
108
|
+
**A URL is checked before it is used as one.** That was the one place the document reached the
|
|
109
|
+
platform, and it was live in the editor too: `[click](javascript:…)` concealed its markup,
|
|
110
|
+
painted as a link, and `window.open` ran it in this origin. Both components now go through an
|
|
111
|
+
allowlist that normalises the way a browser does, so `JaVaScript:` and a tab in the middle of
|
|
112
|
+
the word are the same URL to it. A rejected link is **left as source** — brackets, parentheses
|
|
113
|
+
and all — rather than repainted as a link-coloured word that silently refuses to work.
|
|
114
|
+
Images take `http:`, `https:` and `data:image/*` only; `data:text/html` is not an image.
|
|
115
|
+
|
|
116
|
+
**The reader is not a beacon.** Remote images carry `referrerpolicy="no-referrer"`, so an
|
|
117
|
+
image in somebody else's file cannot learn which page loaded it.
|
|
118
|
+
|
|
119
|
+
What is *not* claimed: nothing here stops a document linking somewhere unpleasant, and the
|
|
120
|
+
images the markdown names are still fetched — that is what rendering them means.
|
|
121
|
+
|
|
122
|
+
## Accessibility
|
|
123
|
+
|
|
124
|
+
The content is `role="article"`, not the `role="textbox"` CodeMirror writes by default, and
|
|
125
|
+
that swap is the difference between reading a document and being trapped in a text field: a
|
|
126
|
+
screen reader entering a textbox switches to forms mode and reads the contents as one flat
|
|
127
|
+
string, with no heading navigation and no table navigation.
|
|
128
|
+
|
|
129
|
+
So the structure has to be real, and two pieces of it are:
|
|
130
|
+
|
|
131
|
+
- **Headings carry `role="heading"` and an `aria-level`**, so the H key steps between
|
|
132
|
+
sections. The editor deliberately has none of this — ARIA flattens a textbox's contents, so
|
|
133
|
+
a heading role inside one would be a decoration that lies about what it does.
|
|
134
|
+
- **Links are real `<a href>` elements**, in the tab order, activated by Enter, with an
|
|
135
|
+
address the browser will show and copy. The editor cannot have these: an anchor inside a
|
|
136
|
+
`contenteditable` competes with the caret for its line, which is why the editor paints a
|
|
137
|
+
span and translates a `mousedown` instead — and why clicking link text *there* cannot place
|
|
138
|
+
a caret.
|
|
139
|
+
|
|
140
|
+
**The document itself is not a tab stop.** There is nothing in it to operate, and a reading
|
|
141
|
+
surface that swallowed a Tab would be one more thing between the reader and the next control.
|
|
142
|
+
Every link inside it is reachable, in document order.
|
|
143
|
+
|
|
144
|
+
List structure is **visual only**, and worth knowing rather than discovering: the `-` bullet
|
|
145
|
+
is drawn as a dimmed marker rather than concealed, the same way it is in the editor, so a
|
|
146
|
+
list reads as a list on screen but is not a `<ul>` in the tree. Tables are real `<table>`
|
|
147
|
+
elements with real `<th>`s, because the table widget builds one.
|
|
148
|
+
|
|
149
|
+
## The Narrow View
|
|
150
|
+
|
|
151
|
+
A table too wide for its column scrolls **inside its own block** rather than pushing the
|
|
152
|
+
column sideways, and an image is capped at the width it is given. Nothing here is keyed to a
|
|
153
|
+
viewport width; a column in a three-up board is narrow on a 4K display.
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
<MarkdownView label="Project notes" value="## Next steps" />
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Published TypeScript API
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
const MarkdownView: ({ className, label, onToggleTask, resolveUrl, value, ...receivedSlotProps }: MarkdownViewProps) => ReactNode
|
|
163
|
+
|
|
164
|
+
type MarkdownViewProps = SlotProps & {
|
|
165
|
+
className?: string;
|
|
166
|
+
/**
|
|
167
|
+
* The accessible name of the region, as `aria-label`.
|
|
168
|
+
*
|
|
169
|
+
* Worth passing on anything that is not the only thing on the
|
|
170
|
+
* page. A read view is announced as an article, and "article" with
|
|
171
|
+
* no name tells a reader stepping through the page nothing about
|
|
172
|
+
* which article it is.
|
|
173
|
+
*/
|
|
174
|
+
label?: string;
|
|
175
|
+
/**
|
|
176
|
+
* Called when the reader ticks a `- [ ]` box, with the **whole**
|
|
177
|
+
* next markdown document — the same shape the editors' `onChange`
|
|
178
|
+
* hands back, so the same autosave wires to both.
|
|
179
|
+
*
|
|
180
|
+
* **Passing it is what makes the checkboxes operable at all.**
|
|
181
|
+
* Leave it out and they render disabled: the state is still on
|
|
182
|
+
* screen, and nothing pretends the reader can change it. That is
|
|
183
|
+
* deliberate rather than defensive. Two of the three surfaces this
|
|
184
|
+
* component was built for — a rendered comment, and a repo file
|
|
185
|
+
* fetched at a commit hash — have nowhere to put a tick, and a
|
|
186
|
+
* checkbox that visibly toggles and then loses the change on
|
|
187
|
+
* reload is worse than one that says up front it cannot.
|
|
188
|
+
*
|
|
189
|
+
* The view still applies the tick to its own document
|
|
190
|
+
* immediately, so the box responds under the pointer. If the
|
|
191
|
+
* consumer rejects the change, the next `value` it passes puts it
|
|
192
|
+
* back.
|
|
193
|
+
*/
|
|
194
|
+
onToggleTask?: (nextValue: string) => void;
|
|
195
|
+
/**
|
|
196
|
+
* Re-point a link before it becomes an `href`, for a document
|
|
197
|
+
* whose paths mean something only the app knows.
|
|
198
|
+
*
|
|
199
|
+
* The case it exists for is a **relative** path in a fetched or
|
|
200
|
+
* imported file. `the runbook` is resolved
|
|
201
|
+
* by the browser against the page the reader is on — the app —
|
|
202
|
+
* so it lands on nothing. Return the URL it should point at
|
|
203
|
+
* instead, or `undefined` to leave the link exactly as written.
|
|
204
|
+
*
|
|
205
|
+
* The document's own URL has already been through the scheme
|
|
206
|
+
* guard when it arrives, so `javascript:` never reaches this.
|
|
207
|
+
* What comes back is the app's own string and is used as given.
|
|
208
|
+
*
|
|
209
|
+
* **Links only.** An image's `src` is deliberately not offered:
|
|
210
|
+
* an app that maps a document path to a page URL would turn a
|
|
211
|
+
* working image into a broken one.
|
|
212
|
+
*
|
|
213
|
+
* Read once, at mount, through a ref — so a resolver defined
|
|
214
|
+
* inline in a render does not rebuild the view and lose the
|
|
215
|
+
* reader's scroll position.
|
|
216
|
+
*/
|
|
217
|
+
resolveUrl?: (url: string) => string | undefined;
|
|
218
|
+
/**
|
|
219
|
+
* The markdown to render, and **controlled** — unlike either
|
|
220
|
+
* editor.
|
|
221
|
+
*
|
|
222
|
+
* The editors take `defaultValue` because reassigning their
|
|
223
|
+
* document from outside would throw away the undo history that
|
|
224
|
+
* belonged to it, which is a real cost and is why they ask for a
|
|
225
|
+
* `key` instead. A view has no undo history and no caret to
|
|
226
|
+
* protect, so it has nothing to lose by simply rendering what it
|
|
227
|
+
* is given: fetch a file at a different commit hash, pass the new
|
|
228
|
+
* string, and the page changes. No remount, no `key`, no stale
|
|
229
|
+
* document above a new title.
|
|
230
|
+
*/
|
|
231
|
+
value: string;
|
|
232
|
+
};
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
[Full declarations](../../dist/markdownEditorCodeMirror/MarkdownView.d.ts)
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# MediaTile
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { MediaTile } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Three repos, and shipping one of these is what makes plex-channels, image-viewer, and
|
|
8
|
+
gallery-downloader look like one family instead of three.
|
|
9
|
+
|
|
10
|
+
## The three states no hand-rolled version models
|
|
11
|
+
|
|
12
|
+
| State | What it does | Why |
|
|
13
|
+
| --- | --- | --- |
|
|
14
|
+
| loading | `Skeleton` at the tile's exact aspect ratio | A 200-poster grid that reflows on load loses the user's place |
|
|
15
|
+
| error | Keeps the box, keeps the name (`role="img"` with the same `alt`) | A broken `<img>` collapses to a glyph and takes the row height with it |
|
|
16
|
+
| cached | Checks `complete`/`naturalWidth` on mount and on every `src` change | A `complete` image never fires `load`, so an `onLoad`-only tile shimmers over a perfectly good poster forever |
|
|
17
|
+
|
|
18
|
+
Those are a `useStatus` machine rather than a `useState<string>`, which is what makes
|
|
19
|
+
`loaded → error` impossible instead of merely unlikely — see `mediaStatus.ts`. A browser
|
|
20
|
+
does not fire `error` on an image it has already decoded, so an app that thinks it saw that
|
|
21
|
+
is misreading its own event wiring, and the machine throws rather than flickering a fallback
|
|
22
|
+
over a good poster.
|
|
23
|
+
|
|
24
|
+
## Sizing
|
|
25
|
+
|
|
26
|
+
The tile is a container query (the caption's type steps up past `--cq-sm`), which means it
|
|
27
|
+
may not be sized by its own contents: put it in a grid track or give it a definite inline
|
|
28
|
+
size. In a shrink-to-fit parent it collapses to min-content — the same constraint `Card`
|
|
29
|
+
carries, and for the same reason.
|
|
30
|
+
|
|
31
|
+
## Names
|
|
32
|
+
|
|
33
|
+
`alt` is required. When `href` or `onClick` is set, the control carries
|
|
34
|
+
`aria-label={title}` (or `alt` if `title` is empty) and the image goes `alt=""` — an agent
|
|
35
|
+
writing `getByRole("link", { name: "Blade Runner" })` or `getByRole("button", { name: "Change cover for Blade Runner" })`
|
|
36
|
+
should not have to know whether a subtitle happened to be rendered, and two names for one
|
|
37
|
+
control is a screen reader reading it twice.
|
|
38
|
+
|
|
39
|
+
`onClick` is the button form of that same chrome: pointer cursor, hover fade, focus-visible
|
|
40
|
+
ring. Do not wrap `MediaTile` in a bare `<button>` — Tailwind's preflight leaves a text
|
|
41
|
+
cursor and no hover, which is how a Collection thumbnail looked inert.
|
|
42
|
+
|
|
43
|
+
The caption's type steps up past `--cq-sm`, so a tile in a dense 8-across grid and the same
|
|
44
|
+
tile in a 3-across one are both legible.
|
|
45
|
+
|
|
46
|
+
## Cards and compact rows
|
|
47
|
+
|
|
48
|
+
`layout="horizontal"` places a bounded thumbnail beside the caption. Use
|
|
49
|
+
`imageFit="contain"` for product images that must remain uncropped, and
|
|
50
|
+
`isTitleTruncated={false}` to wrap distinguishing model names. `details` accepts
|
|
51
|
+
wrapped metadata beneath the caption; it must not contain controls when the tile is a link
|
|
52
|
+
or button. Links use the shared router adapter. An absent source shows the fallback
|
|
53
|
+
immediately, while a supplied source retains the loading and failure states.
|
|
54
|
+
|
|
55
|
+
## Example from the stories
|
|
56
|
+
|
|
57
|
+
See the full [story example](../../src/MediaTile/MediaTile.stories.tsx).
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
<MediaTile
|
|
61
|
+
alt="No cover added"
|
|
62
|
+
subtitle="Add a cover when one is available"
|
|
63
|
+
title="No cover"
|
|
64
|
+
/>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Published TypeScript API
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
const MediaTile: ({ alt, aspectRatio, badge, className, fallback, details, imageFit, layout, isTitleTruncated, href, isDisabled, onClick, src, subtitle, title, ...figureProps }: MediaTileProps) => ReactNode
|
|
71
|
+
|
|
72
|
+
type MediaTileProps = Omit<ComponentPropsWithRef<"figure">, "children"> & {
|
|
73
|
+
/**
|
|
74
|
+
* Required. The one thing three hand-rolled poster grids all
|
|
75
|
+
* omit — and a 200-tile page of unnamed images is unnavigable
|
|
76
|
+
* rather than merely imperfect.
|
|
77
|
+
*/
|
|
78
|
+
alt: string;
|
|
79
|
+
aspectRatio?: MediaTileRatio;
|
|
80
|
+
/** A `Badge`, usually. Pinned inside the media box. */
|
|
81
|
+
badge?: ReactNode;
|
|
82
|
+
/** Shown in place of the image when it fails. */
|
|
83
|
+
fallback?: ReactNode;
|
|
84
|
+
/** Untruncated content beneath the title and subtitle. No nested controls in an interactive tile. */
|
|
85
|
+
details?: ReactNode;
|
|
86
|
+
/** Keep the entire object visible, or fill the frame. */
|
|
87
|
+
imageFit?: "cover" | "contain";
|
|
88
|
+
/** Put a thumbnail beside the caption for a compact list. */
|
|
89
|
+
layout?: "vertical" | "horizontal";
|
|
90
|
+
isTitleTruncated?: boolean;
|
|
91
|
+
href?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Makes the tile a button. Hover, focus-visible and
|
|
94
|
+
* `cursor-pointer` come with it — wrapping `MediaTile` in a
|
|
95
|
+
* bare `<button>` is how a poster ends up with a text cursor
|
|
96
|
+
* and no hover at all. `href` wins if both are set.
|
|
97
|
+
*/
|
|
98
|
+
isDisabled?: boolean;
|
|
99
|
+
onClick?: ComponentPropsWithRef<"button">["onClick"];
|
|
100
|
+
src?: string;
|
|
101
|
+
subtitle?: ReactNode;
|
|
102
|
+
title: string;
|
|
103
|
+
};
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
[Full declarations](../../dist/MediaTile/MediaTile.d.ts)
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Menu
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { Menu } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A menu is **not** a listbox, and mux-magic's `TypePicker` is the fleet's one attempt at
|
|
8
|
+
telling them apart — it renders `role="menu"` over items that set a value, which is a
|
|
9
|
+
listbox wearing the wrong role.
|
|
10
|
+
|
|
11
|
+
## `menuitem` versus `option`
|
|
12
|
+
|
|
13
|
+
| | `menuitem` | `option` |
|
|
14
|
+
| --- | --- | --- |
|
|
15
|
+
| What it is | an **action** — Retry, Skip, Eject | a **value** you are choosing |
|
|
16
|
+
| Announced as | "menu, 3 items" | "listbox, selected, 2 of 4" |
|
|
17
|
+
| Leaves state behind | no | yes |
|
|
18
|
+
| Lives in | this component | `Select` |
|
|
19
|
+
|
|
20
|
+
The last row is why it matters to an agent driving the app: after choosing an `option` it
|
|
21
|
+
needs to know what the control now holds. After invoking a `menuitem` there is nothing to
|
|
22
|
+
read back. Getting the role wrong is invisible in a browser and invisible to axe.
|
|
23
|
+
|
|
24
|
+
## Portalled, and no `[popover]` machinery
|
|
25
|
+
|
|
26
|
+
The panel renders in a `FloatingPortal` at `document.body`, through the same
|
|
27
|
+
`useAnchoredOverlay` `Popover` uses
|
|
28
|
+
([decision](https://github.com/Sawtaytoes/charcuterie/blob/master/docs/decisions/2026-08-03-overlays-portal-to-the-body-not-the-top-layer.md)).
|
|
29
|
+
A portalled node is visible when mounted, so the whole `popover="manual"` /
|
|
30
|
+
`showPopover()` / `isConnected`-guard class of "a `[popover]` that was never shown is
|
|
31
|
+
`display: none`" bug is simply gone. The menu keeps its roving focus, its arrow/Home/End
|
|
32
|
+
keymap, its seed-first-item-on-open effect, and its `MenuAction` items. A scoped query for
|
|
33
|
+
the panel now reaches for `body`; `useRole` names it by pointing `aria-labelledby` at the
|
|
34
|
+
trigger, so the link survives the boundary.
|
|
35
|
+
|
|
36
|
+
## There is no `label` prop, and that corrects a lesson
|
|
37
|
+
|
|
38
|
+
`Spinner` (M3), `Popover` and `Modal` (M4) all take a **required** name, because a
|
|
39
|
+
`role="status"` and a `role="dialog"` take none from their content. The obvious move here was
|
|
40
|
+
a `label` prop doing the same job — it was written that way first, and then measured as
|
|
41
|
+
doing **nothing**.
|
|
42
|
+
|
|
43
|
+
`useRole(context, { role: "menu" })` puts `aria-labelledby` on the panel pointing at the
|
|
44
|
+
trigger, and `aria-labelledby` beats `aria-label`. The menu was already named "Bay 3", from
|
|
45
|
+
the button, and the prop was silently discarded. That is also the APG menu-button pattern.
|
|
46
|
+
|
|
47
|
+
So the rule the other three teach is narrower than it looked:
|
|
48
|
+
|
|
49
|
+
> An overlay with **no trigger relationship** needs its own name.
|
|
50
|
+
|
|
51
|
+
A menu has one, so the requirement moves to the trigger — which `Button` and `IconButton`
|
|
52
|
+
already enforce.
|
|
53
|
+
|
|
54
|
+
## A context menu is this component with no trigger
|
|
55
|
+
|
|
56
|
+
Press and hold a card on a phone and the menu opens at the finger. That is the same
|
|
57
|
+
component in **anchor mode**: `anchorRef` replaces `trigger`, and the panel hangs off a
|
|
58
|
+
**virtual element** — an object that knows only its own rectangle, which here is the
|
|
59
|
+
zero-sized rect at the point pressed. `flip` and `shift` treat it exactly like a button,
|
|
60
|
+
so a press near the bottom of the window still gets a menu that fits.
|
|
61
|
+
|
|
62
|
+
`useLongPress` in `@charcuterie/logic` is the other half. It watches the pointer, cancels
|
|
63
|
+
on a 10px drift so a scroll that starts on the card is a scroll, and hands back the point.
|
|
64
|
+
Two details in it are not obvious:
|
|
65
|
+
|
|
66
|
+
- **The native `contextmenu` is a second trigger, not only something to suppress.** Chrome
|
|
67
|
+
on Android recognises its own long press at about the same 500ms and fires `pointercancel`
|
|
68
|
+
at the sequence, which clears the timer a beat before it would have run. Whichever arrives
|
|
69
|
+
first fires the callback, once.
|
|
70
|
+
- **Touch and pen only, by default.** A mouse already has a context menu, and the browser's
|
|
71
|
+
own carries "Open link in new tab" and "Copy link address" — taking that over to show four
|
|
72
|
+
app actions is a loss on a desktop and a gain on a phone. Pass `["mouse"]` deliberately,
|
|
73
|
+
for a surface that is not a link.
|
|
74
|
+
|
|
75
|
+
The CSS half belongs to the consumer: `-webkit-touch-callout: none` on the pressed element,
|
|
76
|
+
or iOS shows its link preview sheet over the menu. Safari fires no `contextmenu`, so no
|
|
77
|
+
handler can reach it.
|
|
78
|
+
|
|
79
|
+
**`label` is required here**, and that is the rule above read from the other side. With the
|
|
80
|
+
trigger gone nothing names the panel, so the prop that was inert in trigger mode becomes the
|
|
81
|
+
only name the menu has. The type enforces it: `anchorRef` and `trigger` are mutually
|
|
82
|
+
exclusive, and `label` belongs to exactly one of them.
|
|
83
|
+
|
|
84
|
+
Dismissal needs no special case. floating-ui watches `pointerdown` for an outside press, and
|
|
85
|
+
the press that opened a context menu is over before the panel exists — so it cannot close
|
|
86
|
+
itself on the way in.
|
|
87
|
+
|
|
88
|
+
## One kind, and that is the other half of the `Tabs` argument
|
|
89
|
+
|
|
90
|
+
`Tabs` needed **two** state kinds because a tab is chosen *and* focused, and in `manual`
|
|
91
|
+
activation those two disagree on purpose. A menu needs **one** — `RovingFocus` — because a
|
|
92
|
+
menu item is never selected, only invoked.
|
|
93
|
+
|
|
94
|
+
Two components, opposite conclusions, same model. That is the composition claim being paid
|
|
95
|
+
off rather than asserted.
|
|
96
|
+
|
|
97
|
+
## Focus moves in, once
|
|
98
|
+
|
|
99
|
+
A menu is one of the few patterns where focus must jump on open, or the keyboard user who
|
|
100
|
+
pressed Enter is still on the trigger with a menu they cannot reach.
|
|
101
|
+
|
|
102
|
+
It happens in the panel's own effect rather than through `FloatingFocusManager`'s
|
|
103
|
+
`initialFocus`, because the element to focus is whichever one `RovingFocus` says is active —
|
|
104
|
+
and that is not known until the items have registered. `initialFocus={-1}` turns the
|
|
105
|
+
manager's own aim off, so there is one owner for the caret.
|
|
106
|
+
|
|
107
|
+
`modal={false}`, so Tab **leaves** the menu and lands on the next control in the page, which
|
|
108
|
+
is what closes it. A trapped menu is a dialog.
|
|
109
|
+
|
|
110
|
+
## Registration is membership
|
|
111
|
+
|
|
112
|
+
A disabled item never registers with the roving group, so the arrow keys skip it with
|
|
113
|
+
nothing in `RovingFocus` knowing what "disabled" means. It stays in the DOM and stays
|
|
114
|
+
announced — "not right now", rather than "does not exist".
|
|
115
|
+
|
|
116
|
+
## No type-ahead, deliberately
|
|
117
|
+
|
|
118
|
+
The APG lists type-ahead as **optional** for a menu and **required** for a listbox, and none
|
|
119
|
+
of the fleet's menus are long enough to need it — the largest has six items. Adding it means
|
|
120
|
+
a keystroke buffer and a timer in a component that has neither, for a menu you can cross in
|
|
121
|
+
three arrow presses.
|
|
122
|
+
|
|
123
|
+
## One trigger, two slots
|
|
124
|
+
|
|
125
|
+
A `Menu` and a `Tooltip` on the same button — the obvious thing to write, and until 1.0.1
|
|
126
|
+
it did not work.
|
|
127
|
+
|
|
128
|
+
Both components clone onto the trigger and both hand it a floating-ui
|
|
129
|
+
`refs.setReference` — the element each of them positions its panel against. Every merge in
|
|
130
|
+
the library was last-write-wins, so the inner `Tooltip` wrote its ref and the `Menu`'s was
|
|
131
|
+
gone. A menu with no reference element is not an error: floating-ui simply leaves the panel
|
|
132
|
+
at `left: 0; top: 0`, in the corner of the viewport, which reads as a CSS bug.
|
|
133
|
+
|
|
134
|
+
A `ref` is a subscription and an `on*` is a listener, and neither survives being replaced.
|
|
135
|
+
So both are **merged** now — between two slots by `mergeSlotWiring`, and between a slot and
|
|
136
|
+
the element you wrote by `useClonedChild`, which is what makes
|
|
137
|
+
`<Menu trigger={<Button ref={buttonRef} onClick={toggle} />} />` keep your ref *and* your
|
|
138
|
+
handler.
|
|
139
|
+
|
|
140
|
+
`SharedTrigger` is padded so the trigger sits away from the viewport origin: at the corner,
|
|
141
|
+
an anchored panel and an unanchored one land in the same place, and the test asserts that
|
|
142
|
+
padding is still there before it asserts anything else.
|
|
143
|
+
|
|
144
|
+
## The row is a click target, so it is `lg` by default
|
|
145
|
+
|
|
146
|
+
`itemSize` takes the same `sm` / `md` / `lg` a `Button` takes, from the same
|
|
147
|
+
density-aware `--control-height-*` tokens — so a `md` menu item and a `md` `Button`
|
|
148
|
+
measure the same, and the `kiosk` density grows both together.
|
|
149
|
+
|
|
150
|
+
It **defaults to `lg`**, which nothing else in the library does. The asymmetry is the
|
|
151
|
+
decision rather than an oversight: a menu item is a *pointer* target before it is a list
|
|
152
|
+
row. It is read once and then aimed at, usually in a hurry, and a menu rarely holds more
|
|
153
|
+
than about eight items — so it can spend the height a dense list cannot. At `comfortable`
|
|
154
|
+
density `lg` is 2.75rem, which is also the 44px WCAG 2.5.5 target; on the `kiosk` density
|
|
155
|
+
it is 3.75rem with no prop change.
|
|
156
|
+
|
|
157
|
+
The floor is a **minimum**, not a fixed height (`min-h-`, where a `Button` uses `h-`), so a
|
|
158
|
+
long label that wraps to a second line still grows past it.
|
|
159
|
+
|
|
160
|
+
## A short window steps the size back down, and the panel scrolls
|
|
161
|
+
|
|
162
|
+
Two separate protections, because they answer different failures.
|
|
163
|
+
|
|
164
|
+
A window shorter than **40rem** drops every panel row one step, and one shorter than
|
|
165
|
+
**30rem** takes them to `sm` — so a `lg` menu is never the reason its own last item is off
|
|
166
|
+
the screen. That is `usePanelItemSize`, a `matchMedia` read rather than a CSS media query:
|
|
167
|
+
`text-sm` → `text-md` is a Tailwind bridge onto `--font-size-*` rather than a variable a
|
|
168
|
+
media query can reassign, so stepping the whole `ControlSize` in JS is what keeps one
|
|
169
|
+
literal class string per size. It costs a re-render on resize, which is not the axis the
|
|
170
|
+
library keeps as a repaint.
|
|
171
|
+
|
|
172
|
+
Independently, the panel is now clamped to the space the viewport actually left it and
|
|
173
|
+
scrolls inside that. A menu had **no** clamp before — survivable at a 32px row, and not at
|
|
174
|
+
44px, where nine items are 400px and the panel simply ran off the bottom of the screen with
|
|
175
|
+
no way to reach the last one.
|
|
176
|
+
|
|
177
|
+
## A long label wraps, rather than pushing the panel off screen
|
|
178
|
+
|
|
179
|
+
A portalled panel is `position: fixed`, so its shrink-to-fit width stops at the
|
|
180
|
+
**viewport** — not at the space `shift` left it. A label long enough to reach that cap
|
|
181
|
+
therefore produced a menu exactly as wide as the window, positioned 8px in, with 8px of
|
|
182
|
+
itself off the right edge: clipped and unreachable. Measured at 390px.
|
|
183
|
+
|
|
184
|
+
That was pre-existing and size-independent, but a `lg` row's larger type is what makes a
|
|
185
|
+
real label reach it, so the clamp lands in the same change. `isWidthClamped` caps the panel
|
|
186
|
+
at floating-ui's shifted `availableWidth`, and the label wraps inside its row — which is
|
|
187
|
+
also why a row's height is a `min-h-` rather than an `h-`.
|
|
188
|
+
|
|
189
|
+
```tsx
|
|
190
|
+
import { Button } from "@charcuterie/ui"
|
|
191
|
+
import { useVisibility } from "@charcuterie/logic"
|
|
192
|
+
|
|
193
|
+
function ProjectMenu({ archive }: { archive: () => void }) {
|
|
194
|
+
const { isVisible, toggle, hide } = useVisibility()
|
|
195
|
+
return <Menu isVisible={isVisible} onDismiss={hide}
|
|
196
|
+
trigger={<Button onClick={toggle}>Project actions</Button>}
|
|
197
|
+
items={[{ key: "archive", label: "Archive", onSelect: archive }]} />
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Published TypeScript API
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
const Menu: ({ anchorRef, className, emptyState, isVisible, items, itemSize: requestedItemSize, label, onDismiss, placement, trigger, }: MenuProps) => ReactNode
|
|
205
|
+
|
|
206
|
+
type MenuProps = MenuBaseProps & (MenuAnchorProps | MenuTriggerProps);
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
[Full declarations](../../dist/Menu/Menu.d.ts)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# MetricCard
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { MetricCard } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A prominent measure with a stable category colour on its optional app-supplied icon and leading edge. The heading remains text, so colour is additional information. Apps format the value and supply supporting content. A zero and an unavailable reading remain different values.
|
|
8
|
+
|
|
9
|
+
## Categories and available space
|
|
10
|
+
|
|
11
|
+
## Actions
|
|
12
|
+
|
|
13
|
+
Place actions in the inherited Card footer. Decorative icons are hidden from assistive technology; use the visible heading to identify the metric.
|
|
14
|
+
|
|
15
|
+
## Example from the stories
|
|
16
|
+
|
|
17
|
+
See the full [story example](../../src/MetricCard/MetricCard.stories.tsx).
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
<MetricCard heading="Print time" value="14.5 h" />
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Published TypeScript API
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
const MetricCard: ({ categorical, children, icon, value, ...cardProps }: MetricCardProps) => ReactNode
|
|
27
|
+
|
|
28
|
+
type MetricCardProps = Omit<CardProps, "actions"> & {
|
|
29
|
+
/** A stable category colour, independent of success/failure intent. */
|
|
30
|
+
categorical?: CategoricalIndex;
|
|
31
|
+
/** App-supplied decoration; the visible heading names the metric. */
|
|
32
|
+
icon?: ReactNode;
|
|
33
|
+
/** Already formatted by the app, including the unit when needed. */
|
|
34
|
+
value: ReactNode;
|
|
35
|
+
};
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
[Full declarations](../../dist/MetricCard/MetricCard.d.ts)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Modal
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { Modal } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
The **base layer**: a backdrop, a focus trap, Escape, and an outside press — and no
|
|
8
|
+
chrome. A dialog is one kind of modal; so is a confirmation, a media lightbox, and
|
|
9
|
+
anything else that wants a scrim over the page. `Modal` is that foundation, and
|
|
10
|
+
[`Dialog`](Dialog.md) is `Modal` plus the
|
|
11
|
+
heading/Close/footer/size chrome the component shipped with before the M8 rebuild.
|
|
12
|
+
|
|
13
|
+
## Portalled, not the top layer
|
|
14
|
+
|
|
15
|
+
`Modal` renders an `OverlayPanel`, which portals to `document.body`. The old `Modal` rode
|
|
16
|
+
the platform top layer (`<dialog>.showModal()`); this one supersedes that
|
|
17
|
+
([decision](https://github.com/Sawtaytoes/charcuterie/blob/master/docs/decisions/2026-08-03-overlays-portal-to-the-body-not-the-top-layer.md)),
|
|
18
|
+
because the top layer cannot escape an `overflow: hidden` ancestor's clipping in every
|
|
19
|
+
case the fleet hit, and a portal does. The objection a portal used to raise — that it
|
|
20
|
+
moves the node out of a scoped query — is answered by `useRole` writing `aria-controls` /
|
|
21
|
+
`aria-labelledby` across the boundary, and by stories scoping panel queries to
|
|
22
|
+
`within(document.body)`.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
`onClose` is every route out — Escape, a backdrop press — so there is one place to wire
|
|
27
|
+
and no way to end up with the element shut and the state still open.
|
|
28
|
+
|
|
29
|
+
## One accessible name, required
|
|
30
|
+
|
|
31
|
+
A `role="dialog"` takes no name from its content, so pass exactly one of `aria-label` or
|
|
32
|
+
`aria-labelledby`. Missing both is a dev-time warning, not a throw.
|
|
33
|
+
|
|
34
|
+
## Stacking is zero-config, until it is not
|
|
35
|
+
|
|
36
|
+
A lone `Modal` renders its own scrim with no setup. Only when modals **stack** — one
|
|
37
|
+
opened from inside another — does the app need an `OverlayStackProvider` at its root, so
|
|
38
|
+
the N of them share **one** scrim, keep the top live, mark the rest `inert`, and dismiss
|
|
39
|
+
top-first. The scroll lock is ref-counted through the stack, so the page frees only when
|
|
40
|
+
the last modal closes.
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { Button } from "@charcuterie/ui"
|
|
44
|
+
import { useVisibility } from "@charcuterie/logic"
|
|
45
|
+
|
|
46
|
+
function ProjectNotes() {
|
|
47
|
+
const { isVisible, show, hide } = useVisibility()
|
|
48
|
+
return <>
|
|
49
|
+
<Button onClick={show}>Open notes</Button>
|
|
50
|
+
<Modal aria-label="Project notes" isVisible={isVisible} onClose={hide}>
|
|
51
|
+
<Button onClick={hide}>Close notes</Button>
|
|
52
|
+
</Modal>
|
|
53
|
+
</>
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Published TypeScript API
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
const Modal: ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children, className, hasMotion, initialFocus, isDismissable, isVisible, onClose, role, }: ModalProps) => ReactNode
|
|
61
|
+
|
|
62
|
+
type ModalProps = {
|
|
63
|
+
"aria-label"?: string;
|
|
64
|
+
"aria-labelledby"?: string;
|
|
65
|
+
children: ReactNode;
|
|
66
|
+
className?: string;
|
|
67
|
+
/** Which element takes the caret when the modal opens. Without
|
|
68
|
+
* it the focus manager takes the first tabbable element — the
|
|
69
|
+
* Close button on anything with chrome. */
|
|
70
|
+
initialFocus?: RefObject<HTMLElement | null>;
|
|
71
|
+
/**
|
|
72
|
+
* `false` only for a caller that animates the panel itself, as
|
|
73
|
+
* `TableViewport` does when it grows a table out of the page. Every
|
|
74
|
+
* other panel keeps the library's enter and exit motion.
|
|
75
|
+
*/
|
|
76
|
+
hasMotion?: boolean;
|
|
77
|
+
/** Escape and a backdrop press both close. */
|
|
78
|
+
isDismissable?: boolean;
|
|
79
|
+
isVisible: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Every route out lands here: Escape, a backdrop press. Wire it to a
|
|
82
|
+
* `useVisibility()`'s `hide`.
|
|
83
|
+
*/
|
|
84
|
+
onClose: () => void;
|
|
85
|
+
role?: "alertdialog" | "dialog";
|
|
86
|
+
};
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
[Full declarations](../../dist/Modal/Modal.d.ts)
|