@sdxc/ui 2026.10.12 → 2026.10.13
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 +522 -668
- package/dist/animations/transitions.d.ts +45 -20
- package/dist/animations/transitions.js +104 -35
- package/dist/behaviors/announcer.js +2 -1
- package/dist/behaviors/toaster.js +2 -1
- package/dist/components/accordion.js +5 -9
- package/dist/components/alert-dialog.js +3 -3
- package/dist/components/alert.js +11 -2
- package/dist/components/attachment.js +1 -1
- package/dist/components/badge.js +2 -1
- package/dist/components/breadcrumbs.js +17 -9
- package/dist/components/bubble.js +6 -5
- package/dist/components/button.d.ts +14 -0
- package/dist/components/button.js +61 -20
- package/dist/components/calendar.js +12 -8
- package/dist/components/card.d.ts +5 -3
- package/dist/components/card.js +32 -14
- package/dist/components/carousel.js +4 -6
- package/dist/components/chart.js +5 -4
- package/dist/components/checkbox.js +2 -2
- package/dist/components/color-picker.js +8 -11
- package/dist/components/color-slider.js +16 -5
- package/dist/components/color-swatch-picker.js +7 -4
- package/dist/components/color-wheel.js +7 -9
- package/dist/components/combobox.js +5 -1
- package/dist/components/command.d.ts +3 -3
- package/dist/components/command.js +25 -28
- package/dist/components/context-menu.js +4 -4
- package/dist/components/date-field.js +2 -1
- package/dist/components/date-picker.js +12 -16
- package/dist/components/description.js +2 -2
- package/dist/components/dialog.js +19 -15
- package/dist/components/disclosure.js +15 -17
- package/dist/components/drawer.d.ts +5 -5
- package/dist/components/drawer.js +38 -33
- package/dist/components/drop-indicator.js +4 -10
- package/dist/components/empty.js +13 -6
- package/dist/components/field-error.js +2 -1
- package/dist/components/file-trigger.js +7 -10
- package/dist/components/grid-list.js +15 -16
- package/dist/components/group.js +5 -6
- package/dist/components/heading.js +2 -1
- package/dist/components/hover-card.js +4 -5
- package/dist/components/image-placeholder.js +17 -12
- package/dist/components/input.js +8 -11
- package/dist/components/item.js +4 -7
- package/dist/components/keyboard.js +9 -9
- package/dist/components/link-button.js +26 -8
- package/dist/components/listbox.d.ts +3 -2
- package/dist/components/listbox.js +9 -8
- package/dist/components/menu.js +6 -6
- package/dist/components/menubar.js +6 -5
- package/dist/components/message-scroller.js +4 -6
- package/dist/components/message.js +2 -2
- package/dist/components/meter.js +2 -2
- package/dist/components/modal.d.ts +2 -2
- package/dist/components/modal.js +12 -24
- package/dist/components/navigation-menu.js +5 -4
- package/dist/components/number-field.js +6 -6
- package/dist/components/overlay-arrow.js +2 -2
- package/dist/components/pagination.js +3 -1
- package/dist/components/popover.js +7 -19
- package/dist/components/progress-bar.js +2 -2
- package/dist/components/range-calendar.js +5 -3
- package/dist/components/resizable.js +8 -3
- package/dist/components/search-field.js +7 -7
- package/dist/components/select.js +26 -39
- package/dist/components/sheet.js +30 -22
- package/dist/components/shortcut-list.js +2 -2
- package/dist/components/sidebar.js +24 -22
- package/dist/components/slider.d.ts +3 -3
- package/dist/components/slider.js +18 -6
- package/dist/components/switch.js +2 -2
- package/dist/components/table.d.ts +15 -2
- package/dist/components/table.js +36 -14
- package/dist/components/tag-group.js +10 -5
- package/dist/components/text.js +2 -2
- package/dist/components/time-field.js +2 -1
- package/dist/components/toast.js +5 -2
- package/dist/components/toggle-button.js +28 -12
- package/dist/components/tree.js +9 -5
- package/dist/components/typeset.js +5 -2
- package/dist/mixins/carousel-controls.js +11 -15
- package/dist/mixins/clear-field.js +4 -5
- package/dist/mixins/context-menu.js +5 -8
- package/dist/mixins/grid-list-keys.js +5 -2
- package/dist/mixins/listbox-keys.js +1 -1
- package/dist/mixins/message-follow.js +7 -13
- package/dist/mixins/treeKeys.js +5 -3
- package/dist/styles/floating-surface.d.ts +62 -14
- package/dist/styles/floating-surface.js +67 -10
- package/dist/styles/hit-area.d.ts +36 -0
- package/dist/styles/hit-area.js +48 -0
- package/dist/styles/index.d.ts +1 -0
- package/dist/styles/index.js +1 -0
- package/dist/styles/output-caption-text.d.ts +3 -2
- package/dist/styles/output-caption-text.js +4 -3
- package/dist/styles/range-thumb-appearance.js +17 -18
- package/dist/utils/glyph-edges.d.ts +24 -0
- package/dist/utils/glyph-edges.js +46 -0
- package/package.json +5 -4
- package/src/reset.css +4 -1
- package/src/theme.css +49 -2
package/README.md
CHANGED
|
@@ -2,30 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
Styled, accessible `remix/component` components rendered as server HTML.
|
|
4
4
|
|
|
5
|
-
Every component is a plain function taking a `Handle<Props>` and rendered through JSX, with
|
|
6
|
-
variants, states and colors driven by a `data-*` attribute contract and a set of `--ui-*`
|
|
7
|
-
semantic color variables applied through `css()` mixins.
|
|
8
|
-
|
|
9
|
-
Baseline behavior comes from the platform itself — `<dialog>`, the Popover API, Invoker
|
|
10
|
-
Commands, `<details>` and native form controls — so a page built from these components works
|
|
11
|
-
before, and without, any client JavaScript.
|
|
12
|
-
|
|
13
5
|
## Installation
|
|
14
6
|
|
|
15
7
|
```bash
|
|
16
8
|
npm add @sdxc/ui
|
|
17
9
|
```
|
|
18
10
|
|
|
19
|
-
Components render through `remix`, draw their
|
|
20
|
-
[`@sdxc/icons`](https://www.npmjs.com/package/@sdxc/icons), and
|
|
21
|
-
|
|
22
|
-
package.
|
|
11
|
+
Components render through `remix`, draw their glyphs from
|
|
12
|
+
[`@sdxc/icons`](https://www.npmjs.com/package/@sdxc/icons), and build on
|
|
13
|
+
[`@sdxc/u`](https://www.npmjs.com/package/@sdxc/u); all three install alongside this package.
|
|
23
14
|
|
|
24
15
|
## Usage
|
|
25
16
|
|
|
26
|
-
### Render
|
|
17
|
+
### Render a component
|
|
27
18
|
|
|
28
|
-
Every component takes a `Handle<Props>` and
|
|
19
|
+
Every component takes a `Handle<Props>` and renders through JSX. Props such as `color` become
|
|
20
|
+
`data-*` attributes that the component's own `css()` styles key off, so this is static HTML with no
|
|
21
|
+
client JavaScript:
|
|
29
22
|
|
|
30
23
|
```tsx
|
|
31
24
|
import type { Handle } from "remix/component";
|
|
@@ -41,13 +34,13 @@ export function OrderStatus(handle: Handle<{ paid: boolean }>) {
|
|
|
41
34
|
}
|
|
42
35
|
```
|
|
43
36
|
|
|
44
|
-
|
|
45
|
-
paints the rest — no hydration, no client JavaScript.
|
|
37
|
+
The package ships no copy: every visible and accessible string is a prop or child you supply.
|
|
46
38
|
|
|
47
|
-
###
|
|
39
|
+
### Load the stylesheets
|
|
48
40
|
|
|
49
|
-
Import the reset and the theme ahead of your own styles, then define the five palette
|
|
50
|
-
|
|
41
|
+
Import the reset and the theme ahead of your own styles, then define the five palette scales
|
|
42
|
+
(`brand`, `neutral`, `danger`, `warning`, `success`, each `50` through `950`) the theme derives
|
|
43
|
+
every `--ui-*` variable from:
|
|
51
44
|
|
|
52
45
|
```css
|
|
53
46
|
@import "@sdxc/ui/reset.css";
|
|
@@ -57,53 +50,38 @@ scales the theme derives every semantic variable from:
|
|
|
57
50
|
--ui-color-brand-50: oklch(0.97 0.02 250);
|
|
58
51
|
--ui-color-brand-500: oklch(0.6 0.18 250);
|
|
59
52
|
--ui-color-brand-950: oklch(0.22 0.08 250);
|
|
60
|
-
|
|
61
|
-
/* the same 50-950 shape for neutral, danger, warning and success */
|
|
62
53
|
}
|
|
63
54
|
```
|
|
64
55
|
|
|
65
|
-
`reset.css`
|
|
66
|
-
|
|
67
|
-
opens with `@layer base, rmx;` so component styles always win. It leaves `<dialog>`'s
|
|
68
|
-
`::backdrop` and the `dialog`/`[popover]` margins alone, since overlays rely on that native
|
|
69
|
-
centering — an app shipping an equivalent reset can import `theme.css` on its own.
|
|
56
|
+
`reset.css` declares `@layer base, rmx;`, so component styles always win over it. `theme.css` is light
|
|
57
|
+
on `:root`, dark under a `.dark` class on `<html>`, and follows `prefers-color-scheme` under `.system`.
|
|
70
58
|
|
|
71
|
-
|
|
72
|
-
`<html>` for forced dark mode, a `.system` class that follows `prefers-color-scheme`, and
|
|
73
|
-
the `--ui-chart-1` through `--ui-chart-8` categorical sequence for multi-series charts. Two
|
|
74
|
-
apps supplying the same scales render the same design, because components read the derived
|
|
75
|
-
contract rather than any raw scale value.
|
|
59
|
+
### Open a dialog with a plain button
|
|
76
60
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
61
|
+
Overlays ride native `<dialog>`, the Popover API and
|
|
62
|
+
[Invoker Commands](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API), so a
|
|
63
|
+
trigger is an ordinary button and the page tracks no open state:
|
|
80
64
|
|
|
81
65
|
```tsx
|
|
82
66
|
import { Button, Dialog } from "@sdxc/ui";
|
|
83
67
|
|
|
84
|
-
<Button commandfor="invite
|
|
85
|
-
|
|
68
|
+
<Button commandfor="invite" command="show-modal">
|
|
69
|
+
Invite
|
|
86
70
|
</Button>
|
|
87
|
-
<Dialog id="invite
|
|
71
|
+
<Dialog id="invite">
|
|
88
72
|
<Dialog.Header>
|
|
89
|
-
<Dialog.Title>
|
|
73
|
+
<Dialog.Title>Invite a teammate</Dialog.Title>
|
|
90
74
|
</Dialog.Header>
|
|
91
75
|
<Dialog.Footer>
|
|
92
|
-
<Dialog.Close>
|
|
76
|
+
<Dialog.Close>Close</Dialog.Close>
|
|
93
77
|
</Dialog.Footer>
|
|
94
78
|
</Dialog>;
|
|
95
79
|
```
|
|
96
80
|
|
|
97
|
-
|
|
98
|
-
[Invoker Commands](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API)
|
|
99
|
-
against the native
|
|
100
|
-
[`<dialog>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dialog)
|
|
101
|
-
element, so the page needs no open-state bookkeeping.
|
|
102
|
-
|
|
103
|
-
### Add Behavior With A Mixin
|
|
81
|
+
### Add behavior with a mixin
|
|
104
82
|
|
|
105
|
-
|
|
106
|
-
|
|
83
|
+
Components never hydrate. Interactivity comes from a mixin applied through `mix` inside your own
|
|
84
|
+
`clientEntry` island, often paired with a headless behavior class that holds the state:
|
|
107
85
|
|
|
108
86
|
```tsx
|
|
109
87
|
import type { Handle } from "remix/component";
|
|
@@ -112,348 +90,362 @@ import { clientEntry } from "remix/component";
|
|
|
112
90
|
|
|
113
91
|
import { Command } from "@sdxc/ui";
|
|
114
92
|
import { FilterModel } from "@sdxc/ui/behaviors";
|
|
115
|
-
import { commandFilter } from "@sdxc/ui/mixins";
|
|
116
|
-
|
|
117
|
-
type Props = { pages: Array<{ id: string; title: string }> };
|
|
93
|
+
import { commandFilter, commandKeys } from "@sdxc/ui/mixins";
|
|
118
94
|
|
|
119
95
|
export default clientEntry(
|
|
120
|
-
"/
|
|
121
|
-
function SearchPalette(handle: Handle<
|
|
96
|
+
"/components/search-palette.tsx#default",
|
|
97
|
+
function SearchPalette(handle: Handle<{ pages: Array<{ id: string; title: string }> }>) {
|
|
122
98
|
let model = new FilterModel();
|
|
123
99
|
|
|
124
100
|
return () => (
|
|
125
|
-
<Command mix={commandFilter(model)}>
|
|
126
|
-
<Command.Input placeholder=
|
|
101
|
+
<Command mix={[commandFilter(model), commandKeys(model)]}>
|
|
102
|
+
<Command.Input placeholder="Search pages" />
|
|
127
103
|
<Command.List>
|
|
128
104
|
{handle.props.pages.map((page) => (
|
|
129
105
|
<Command.Item key={page.id} value={page.title}>
|
|
130
|
-
{page.title}
|
|
106
|
+
<a href={`/pages/${page.id}`}>{page.title}</a>
|
|
131
107
|
</Command.Item>
|
|
132
108
|
))}
|
|
133
109
|
</Command.List>
|
|
134
|
-
<Command.Empty>
|
|
110
|
+
<Command.Empty>No results</Command.Empty>
|
|
135
111
|
</Command>
|
|
136
112
|
);
|
|
137
113
|
},
|
|
138
114
|
);
|
|
139
115
|
```
|
|
140
116
|
|
|
141
|
-
|
|
142
|
-
behavior ships no library JavaScript at all. Every example here writes user-facing copy as
|
|
143
|
-
`t(key)`, standing in for whatever localization function your app has — the library ships no
|
|
144
|
-
copy of its own, so each visible or accessible string is a prop you supply.
|
|
117
|
+
A page that sticks to baseline behavior ships no library JavaScript at all.
|
|
145
118
|
|
|
146
119
|
## API
|
|
147
120
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
|
152
|
-
|
|
|
153
|
-
| `@sdxc/ui`
|
|
154
|
-
| `@sdxc/ui/
|
|
155
|
-
| `@sdxc/ui/
|
|
156
|
-
| `@sdxc/ui/
|
|
157
|
-
| `@sdxc/ui/
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
`
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
`
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
- `
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
- `
|
|
202
|
-
|
|
203
|
-
- `
|
|
204
|
-
and a
|
|
205
|
-
- `
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
- `
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
- `
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
- `
|
|
244
|
-
|
|
245
|
-
- `
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
- `
|
|
252
|
-
|
|
253
|
-
- `
|
|
254
|
-
|
|
255
|
-
- `
|
|
256
|
-
|
|
257
|
-
- `
|
|
258
|
-
|
|
259
|
-
- `
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
- `
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
- `ColorSwatch` — a preview box for one CSS color, backed by a checkerboard so translucent
|
|
274
|
-
values read correctly.
|
|
275
|
-
- `ColorArea`, `ColorWheel`, `ColorSlider` — a 2D saturation/brightness picker from two
|
|
276
|
-
overlaid range inputs, a circular hue picker from one, and a single-channel (`hue`,
|
|
277
|
-
`saturation`, `lightness`, `alpha`) control.
|
|
278
|
-
- `ColorSwatchPicker` — mutually exclusive preset colors built from native radios.
|
|
279
|
-
- `ColorField`, `ColorPicker` — a labeled, described, validated color text field with a live
|
|
280
|
-
swatch, and that field extended with a trigger and a popover-hosted picking surface.
|
|
281
|
-
|
|
282
|
-
### Components: Charts And Conversation
|
|
283
|
-
|
|
284
|
-
- `Chart` — the coordinate space every Cartesian series renders into, with `.Line`, `.Area`,
|
|
285
|
-
`.Pie`, `.Bar`, `.Legend` and `.Tooltip` parts.
|
|
286
|
-
- `Message`, `MessageScroller` — a conversational turn laid out with grid areas keyed off
|
|
287
|
-
each part's `data-slot`, and a scrollable log frame whose content is a `role="log"`.
|
|
288
|
-
- `Bubble`, `Marker`, `Attachment` — the framed surface inside a turn's content slot, an
|
|
289
|
-
inline row calling out a small event between turns, and a card for one attached file.
|
|
290
|
-
|
|
291
|
-
### Components: Layout And Content
|
|
292
|
-
|
|
293
|
-
- `Card` — a bordered, tinted panel grouping a header, content, and footer actions.
|
|
294
|
-
- `ImagePlaceholder` — a fixed-size image-with-fallback box; `Avatar` and `Logo` are its
|
|
295
|
-
circular and rounded-square presets.
|
|
296
|
-
- `AspectRatio`, `Resizable`, `ScrollArea`, `Carousel` — a ratio lock, a split-pane layout
|
|
297
|
-
of panels and handles, a bordered scrollable region, and a slide collection riding CSS
|
|
298
|
-
scroll snap.
|
|
299
|
-
- `Group`, `Section`, `Separator`, `Toolbar` — a cluster of related controls, a grouping
|
|
300
|
-
inside a listbox or menu, a divider, and a strip of controls along one axis.
|
|
301
|
-
- `Item` — a single-line row with leading media, title and description, and trailing
|
|
302
|
-
actions.
|
|
303
|
-
- `Text`, `Header`, `Keyboard`, `Typeset` — muted body copy, an uppercase section label in a
|
|
304
|
-
`<header>`, a shortcut hint in a `<kbd>`, and a typography layer for already-rendered
|
|
305
|
-
markup with `docs`, `chat` and `reading` presets.
|
|
306
|
-
- `ShortcutList` — a two-column `<dl>` pairing each action with the key caps that run it,
|
|
307
|
-
for a keyboard-shortcuts panel.
|
|
308
|
-
- `Highlight` — text split into `{ text, match }` segments, each match a tinted `<mark>`
|
|
309
|
-
that keeps the surrounding color and weight, for search results and filtered lists.
|
|
310
|
-
- `HeadingScope`, `Heading` — an ambient heading-depth scope and the heading that reads it.
|
|
311
|
-
- `SharedElement` — a host carrying a stable view-transition identity across page loads.
|
|
312
|
-
- `Calendar`, `RangeCalendar`, `DatePicker`, `DateRangePicker` — a month grid for one day or
|
|
313
|
-
a connected range, and either extended with a trigger and a popover-hosted calendar.
|
|
314
|
-
Rendered with no children, `Calendar` falls back to a native `<input type="date">`.
|
|
121
|
+
| Import | Contains |
|
|
122
|
+
| --------------------- | ------------------------------------------------------------------- |
|
|
123
|
+
| `@sdxc/ui` | Every component and its compound parts. |
|
|
124
|
+
| `@sdxc/ui/mixins` | Opt-in DOM behaviors applied through `mix`. |
|
|
125
|
+
| `@sdxc/ui/behaviors` | Headless state classes built on `TypedEventTarget`. |
|
|
126
|
+
| `@sdxc/ui/animations` | CSS-only motion factories and the `durations`/`easings` tokens. |
|
|
127
|
+
| `@sdxc/ui/styles` | Style recipes composed inside a `mix` array. |
|
|
128
|
+
| `@sdxc/ui/utils` | Framework-free color, chart, geometry, key and DOM helpers; types. |
|
|
129
|
+
| `@sdxc/ui/reset.css` | The base reset in `@layer base`. |
|
|
130
|
+
| `@sdxc/ui/theme.css` | The `--ui-*` semantic variables and the `--ui-chart-1`…`8` palette. |
|
|
131
|
+
|
|
132
|
+
Every export carries JSDoc, so the editor shows each full signature.
|
|
133
|
+
|
|
134
|
+
### Component contract
|
|
135
|
+
|
|
136
|
+
- A component's props type lives on its namespace (`Button.Props`, `Dialog.TitleProps`), and
|
|
137
|
+
compound parts hang off the root (`Dialog.Header`, `Chart.Legend.Item`).
|
|
138
|
+
- `color` takes a `SemanticColor`: `"brand"`, `"neutral"`, `"success"`, `"warning"` or `"danger"`.
|
|
139
|
+
- `mix` styles the host. A wrapper rendering several elements also takes `parts`, one `mix` per
|
|
140
|
+
named part.
|
|
141
|
+
- Every measurement reads `var(--ui-<component>-<property>, <default>)`, plus the shared
|
|
142
|
+
`--ui-radius-*` scale, so one declaration retunes a component.
|
|
143
|
+
- Title slots (`Dialog.Title`, `Alert.Title`, `Heading`) render the heading level of the nearest
|
|
144
|
+
`HeadingScope`.
|
|
145
|
+
- `prefers-reduced-motion`, `prefers-contrast: more` and `prefers-reduced-transparency` are handled
|
|
146
|
+
by the animations and the theme.
|
|
147
|
+
- Small controls reach a pointer target of `--ui-target-size` (24px, 44px on coarse pointers).
|
|
148
|
+
- In development, a missing accessible name or id linkage (an icon-only `Button`, a `Dialog` without
|
|
149
|
+
`id`, a `Command.Item` without `value`) logs a `console.warn`.
|
|
150
|
+
|
|
151
|
+
### Components: forms
|
|
152
|
+
|
|
153
|
+
- `Form` — a `<form>` taking `issues` from a `parseSafe` result; each field beneath reads its own
|
|
154
|
+
errors by `name`.
|
|
155
|
+
- `Label`, `Description`, `FieldError` — a caption, supporting copy for `aria-describedby`, and a
|
|
156
|
+
validation message.
|
|
157
|
+
- `Input`, `TextArea` — native text controls; the area grows with `field-sizing: content`.
|
|
158
|
+
- `TextField`, `DateField`, `TimeField` — labeled, described, validated wrappers around an input.
|
|
159
|
+
- `NumberField`, `OtpField` — a number input with step buttons, and a one-time-code field.
|
|
160
|
+
- `Checkbox`, `CheckboxGroup`, `RadioGroup`, `Switch` — native checked-state controls and their
|
|
161
|
+
groupings.
|
|
162
|
+
- `ToggleButton`, `ToggleButtonGroup` — a button carrying `aria-pressed`, and a row or column of
|
|
163
|
+
them.
|
|
164
|
+
- `Slider`, `Meter`, `ProgressBar` — a range input with a fill and `<output>`, and styled `<meter>`
|
|
165
|
+
and `<progress>` (indeterminate when `value` is unset).
|
|
166
|
+
- `Select`, `ComboBox`, `SearchField` — a native `<select>` with customizable-select styling, a
|
|
167
|
+
text input with a `<datalist>`, and a `<search>` landmark.
|
|
168
|
+
- `FileTrigger`, `DropZone` — a button opening the file picker, and a drop target, both over a
|
|
169
|
+
native file input.
|
|
170
|
+
|
|
171
|
+
### Components: overlays and menus
|
|
172
|
+
|
|
173
|
+
- `Dialog`, `AlertDialog` — modals on `<dialog>`; the alert variant ignores light dismiss.
|
|
174
|
+
- `Modal`, `Drawer`, `Sheet` — `Dialog` presets: pop-in, edge-docked, and a fixed side column.
|
|
175
|
+
- `Confirm` — a complete confirmation dialog; with `form` its confirm button submits a real form.
|
|
176
|
+
- `Popover`, `Tooltip`, `HoverCard` — an anchored popover, a label shown on hover or focus of the
|
|
177
|
+
preceding sibling, and a detail panel shown on hover or focus within.
|
|
178
|
+
- `Menu`, `Menubar`, `ContextMenu`, `NavigationMenu` — popover menus, a row of menu triggers, a
|
|
179
|
+
pointer-positioned menu, and a row of navigation panels.
|
|
180
|
+
- `Command` — a searchable list of actions with `.Input`, `.List`, `.Item` and `.Empty`.
|
|
181
|
+
- `OverlayArrow` — a pointer from a floating surface back to its trigger.
|
|
182
|
+
|
|
183
|
+
### Components: navigation and data
|
|
184
|
+
|
|
185
|
+
- `Button` — `color`, `variant`, `size`, and `isPending` to show a spinner at the same size.
|
|
186
|
+
- `Link`, `NavLink`, `LinkButton` — an inline anchor, a navigation link, and a link styled as a
|
|
187
|
+
button.
|
|
188
|
+
- `Tabs` — tabs driven by routing: the `.Tab` pointing at the current page is selected.
|
|
189
|
+
- `Breadcrumbs`, `Pagination`, `Sidebar` — a trail of parents, a pager landmark, and an app shell
|
|
190
|
+
rail whose collapse rides a checkbox's `:checked`.
|
|
191
|
+
- `Disclosure`, `Accordion` — `<details>` sections, alone or stacked.
|
|
192
|
+
- `Table` — a table whose `.Column` takes a sort `href` and whose `.LoadMore` row is a link.
|
|
193
|
+
- `GridList`, `Tree`, `ListBox` — an interactive row list, nested `<details>`, and selectable rows.
|
|
194
|
+
- `SelectionIndicator`, `DropIndicator`, `SentinelRow` — a selection marker, a drop-position bar,
|
|
195
|
+
and a muted row holding a loading or "load more" control.
|
|
196
|
+
|
|
197
|
+
### Components: feedback
|
|
198
|
+
|
|
199
|
+
- `Alert`, `Toast` — an inline status panel, and a notification stacked by `Toast.Region`.
|
|
200
|
+
- `Badge`, `TagGroup` — a status pill, and a labeled set of removable pills.
|
|
201
|
+
- `Skeleton`, `Spinner`, `Empty` — a loading block, a busy indicator, and an empty-state panel.
|
|
202
|
+
|
|
203
|
+
### Components: color
|
|
204
|
+
|
|
205
|
+
- `ColorSwatch`, `ColorSwatchPicker` — a color preview, and preset colors as native radios.
|
|
206
|
+
- `ColorArea`, `ColorWheel`, `ColorSlider` — saturation/brightness, hue, and single-channel pickers
|
|
207
|
+
built from range inputs.
|
|
208
|
+
- `ColorField`, `ColorPicker` — a color text field with a live swatch, and that field with a
|
|
209
|
+
popover (`ColorPicker.Dialog`) hosting any of the pickers above.
|
|
210
|
+
|
|
211
|
+
### Components: charts and conversation
|
|
212
|
+
|
|
213
|
+
- `Chart` — an SVG coordinate space (`width`, `height`, `xDomain`, `yDomain`) for `.Line` and
|
|
214
|
+
`.Area` series, plus standalone `.Bar` and `.Pie`, a `.Legend`, and the `.Tooltip` surface that
|
|
215
|
+
`chartTooltip()` drives; every point is a labeled, focusable marker.
|
|
216
|
+
- `MessageScroller` — a `role="log"` frame with `.Viewport`, `.Content`, `.Item` and a
|
|
217
|
+
jump-to-latest `.Button`.
|
|
218
|
+
- `Message`, `Bubble`, `Marker`, `Attachment` — a turn, its framed content, an inline event between
|
|
219
|
+
turns, and an attached-file card.
|
|
220
|
+
|
|
221
|
+
### Components: layout and content
|
|
222
|
+
|
|
223
|
+
- `Card`, `Item`, `Group`, `Section`, `Separator`, `Toolbar` — panels, rows, groupings and dividers.
|
|
224
|
+
- `ImagePlaceholder`, `Avatar`, `Logo` — an image with fallback, and its round and rounded-square
|
|
225
|
+
presets.
|
|
226
|
+
- `AspectRatio`, `Resizable`, `ScrollArea`, `Carousel` — a ratio lock, split panes, a scroll region,
|
|
227
|
+
and a scroll-snap slide set.
|
|
228
|
+
- `Text`, `Header`, `Keyboard`, `Typeset` — muted copy, a section label, a `<kbd>`, and typography
|
|
229
|
+
for rendered markup (`docs`, `chat`, `reading`).
|
|
230
|
+
- `ShortcutList` — a `<dl>` pairing actions with key caps.
|
|
231
|
+
- `Highlight` — `{ text, match }` segments rendered with each match in a `<mark>`.
|
|
232
|
+
- `HeadingScope`, `Heading` — a heading-depth scope, and the `<h1>`–`<h6>` that reads it.
|
|
233
|
+
- `SharedElement` — a host with a stable view-transition name across page loads.
|
|
234
|
+
- `Calendar`, `RangeCalendar`, `DatePicker`, `DateRangePicker` — month grids for a day or a range,
|
|
235
|
+
and popover pickers around them; `Calendar` without children renders `<input type="date">`.
|
|
236
|
+
|
|
237
|
+
### Component helpers
|
|
238
|
+
|
|
239
|
+
- `readFormContext(handle): Form.Context | undefined` and
|
|
240
|
+
`resolveFieldIssue(handle, name, errorMessage?): FieldIssueState` — how a custom field joins
|
|
241
|
+
`Form`'s issues.
|
|
242
|
+
- `readAmbientLevel(handle)`, `resolveHeadingLevel(handle, level?)` and `TAG_BY_LEVEL` — how a
|
|
243
|
+
custom heading joins `HeadingScope`.
|
|
244
|
+
- `tabIndicatorMix(orientation, activeIndex, tabSize)` — positions `Tabs.List`'s sliding indicator
|
|
245
|
+
for fixed-size tabs.
|
|
315
246
|
|
|
316
247
|
### Mixins
|
|
317
248
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
|
323
|
-
|
|
|
324
|
-
| `
|
|
325
|
-
| `
|
|
326
|
-
| `
|
|
327
|
-
| `
|
|
328
|
-
| `
|
|
329
|
-
| `
|
|
330
|
-
| `
|
|
331
|
-
| `
|
|
332
|
-
| `
|
|
333
|
-
| `
|
|
334
|
-
| `
|
|
335
|
-
| `
|
|
336
|
-
| `
|
|
337
|
-
| `
|
|
338
|
-
| `
|
|
339
|
-
| `
|
|
340
|
-
| `
|
|
341
|
-
| `
|
|
342
|
-
| `
|
|
343
|
-
| `
|
|
344
|
-
| `
|
|
345
|
-
| `
|
|
346
|
-
| `
|
|
347
|
-
| `
|
|
348
|
-
| `
|
|
349
|
-
| `
|
|
350
|
-
| `
|
|
351
|
-
| `
|
|
352
|
-
| `
|
|
353
|
-
| `
|
|
354
|
-
| `
|
|
355
|
-
| `
|
|
356
|
-
| `
|
|
357
|
-
| `
|
|
358
|
-
| `
|
|
359
|
-
| `
|
|
360
|
-
| `
|
|
361
|
-
| `
|
|
362
|
-
| `
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
- `
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
- `
|
|
249
|
+
Each mixin module documents why it needs JavaScript and what still works without it.
|
|
250
|
+
|
|
251
|
+
| Mixin | Host | Adds |
|
|
252
|
+
| ------------------------------- | -------------------------- | ----------------------------------------------------------------------- |
|
|
253
|
+
| `ariaChecked()` | checkbox, switch or radio | `aria-checked` kept in step with the live control. |
|
|
254
|
+
| `attachmentTrigger()` | `Attachment.Trigger` | The whole card as one activation target. |
|
|
255
|
+
| `calendarKeys(model)` | `Calendar.Grid` | Arrow/Page/Home/End navigation over a `CalendarModel`. |
|
|
256
|
+
| `carouselControls()` | `Carousel.Viewport` | `--ui-prev`, `--ui-next` and `--ui-goto` commands. |
|
|
257
|
+
| `channelSync()` | a `ColorSlider` group | Sibling channel gradients that follow each other. |
|
|
258
|
+
| `chartTooltip()` | a chart series | `Chart.Tooltip` filled from the nearest point to pointer or focus. |
|
|
259
|
+
| `clearField()` | `SearchField` clear button | Empties its `commandfor` input. |
|
|
260
|
+
| `colorAreaDrag()` | `ColorArea` | A 2D drag across the paired thumbs. |
|
|
261
|
+
| `colorPreview()` | `ColorField` | The swatch updated as the typed value parses. |
|
|
262
|
+
| `colorWheelDrag()` | `ColorWheel` | An angular drag around the ring. |
|
|
263
|
+
| `comboboxFilter()` | `ComboBox.Input` | As-you-type narrowing. |
|
|
264
|
+
| `commandFilter(model)` | `Command` | Items hidden by a `FilterModel` query. |
|
|
265
|
+
| `commandKeys(model)` | `Command` | Arrow keys over matches; Enter activates the active item's link/button. |
|
|
266
|
+
| `contextMenu(id, options?)` | `ContextMenu.Trigger` | Opens popover `id` at the pointer on right-click or the menu key. |
|
|
267
|
+
| `copyToClipboard()` | a button | Copies the text of its `commandfor` target. |
|
|
268
|
+
| `dismiss(options?)` | an alert or toast | Auto-dismiss countdown paused on hover, plus a `--ui-dismiss` command. |
|
|
269
|
+
| `dragReorder(session)` | `GridList` / `Tree` | Pointer reordering through a `DragSession`. |
|
|
270
|
+
| `dropZone(session)` | `DropZone` | File drag-and-drop through a `DragSession`. |
|
|
271
|
+
| `dualRange()` | a two-thumb `Slider` | Thumbs that cannot cross. |
|
|
272
|
+
| `gridListKeys(model)` | `GridList` | The ARIA grid keyboard pattern over a `SelectionModel`. |
|
|
273
|
+
| `headingLevelFallback(options)` | an island's `HeadingScope` | Reports the page's heading depth to `onLevel` once on attach. |
|
|
274
|
+
| `hotkey(combo)` | a `<dialog>`/`[popover]` | A document-wide shortcut toggling its host. |
|
|
275
|
+
| `imageFallback()` | an `Avatar`/`Logo` image | Shows the fallback when the image fails, cached images included. |
|
|
276
|
+
| `keymap(bindings)` | any host | Page-wide shortcuts that stand down in fields and foreign dialogs. |
|
|
277
|
+
| `listboxKeys()` | `ListBox` | Arrow, Home/End and typeahead navigation. |
|
|
278
|
+
| `longPress(options?)` | any element | Fires after a pointer holds still for `duration`. |
|
|
279
|
+
| `menuKeys(options?)` | `Menu` | The ARIA menu pattern: roving focus, arrows, typeahead. |
|
|
280
|
+
| `menubarKeys(options?)` | `Menubar` | The ARIA menubar pattern, handing off into each open `Menu`. |
|
|
281
|
+
| `messageFollow(model)` | `MessageScroller.Viewport` | Follows new turns through a `ScrollFollowModel`. |
|
|
282
|
+
| `mirrorSelectedOption()` | a `<selectedcontent>` | Keeps the customizable select's trigger showing the chosen option. |
|
|
283
|
+
| `otpSlots()` | an `OtpField` group | Focus moving across slots, and pasted codes split. |
|
|
284
|
+
| `persist(key)` | `Sidebar` | The collapsed state saved to a cookie, plus a `--ui-toggle` command. |
|
|
285
|
+
| `pressToggle()` | `ToggleButton` | Flips `aria-pressed` on click. |
|
|
286
|
+
| `rangePreview(model)` | `RangeCalendar.Grid` | Hover and focus preview of the pending range. |
|
|
287
|
+
| `resizeHandle(axis, session)` | `Resizable.Handle` | Pointer resizing through a `ResizeSession`. |
|
|
288
|
+
| `stepper(options?)` | `NumberField.Group` | Press-and-hold repeat on the step buttons. |
|
|
289
|
+
| `tabKeys(options?)` | `Tabs.List` | Arrow, Home/End tab activation. |
|
|
290
|
+
| `themeToggle(options?)` | any host | `--ui-theme-light`/`-dark`/`-system` commands saved to a cookie. |
|
|
291
|
+
| `treeKeys(model)` | `Tree` | The ARIA tree pattern over a `SelectionModel`. |
|
|
292
|
+
| `validate(schema)` | a form control | A `remix/data-schema` check through `setCustomValidity()`. |
|
|
293
|
+
| `viewTransition()` | a `SharedElement` island | A View Transition across a same-document reload. |
|
|
294
|
+
|
|
295
|
+
Helpers for writing your own:
|
|
296
|
+
|
|
297
|
+
- `whileLive(handle, subscribe)` — returns a function that subscribes to a model, session or frame
|
|
298
|
+
only while the mixin or island is live in a document, aborting on unmount.
|
|
299
|
+
- `trackHostNode(handle)` — returns a getter for the mixin's current host node.
|
|
300
|
+
- `bindKeymap(document, bindings, { signal, scope? })` — `keymap` without a host, with the same
|
|
301
|
+
stand-down rules as `isClaimedKeystroke(event, scope?)`.
|
|
302
|
+
- `syncAriaChecked(control)` — refreshes `ariaChecked` after a programmatic checked write or reset.
|
|
303
|
+
- `colorChannelProperty(channel)` and `getCommandItemId(item, index)` — the custom property and the
|
|
304
|
+
item id `channelSync` and `commandFilter` read.
|
|
305
|
+
|
|
306
|
+
Mixins that emit DOM events export their `Event` subclass (`DismissEvent`, `ReorderEvent`,
|
|
307
|
+
`ThemeChangeEvent`, …), and those that read markup export the `data-*` attribute and command names
|
|
308
|
+
they use (`DRAG_REORDER_ROW_ATTRIBUTE`, `SEARCH_FIELD_CLEAR_COMMAND`, …).
|
|
309
|
+
|
|
310
|
+
### Behavior classes
|
|
311
|
+
|
|
312
|
+
DOM-free state that dispatches `change`; an island subscribes and re-renders.
|
|
313
|
+
|
|
314
|
+
- `Announcer({ hold? })` — an `aria-live` queue: `announce(text, priority?)`, `current`, `next()`.
|
|
315
|
+
- `CalendarModel({ focusedDate?, min?, max?, isDateDisabled? })` — the focused day, visible month,
|
|
316
|
+
and an in-progress range (`beginRange`, `completeRange`).
|
|
317
|
+
- `DragSession<Data>()` — the dragged `source`, the `target` under the pointer with its
|
|
318
|
+
`"before" | "after" | "on"` position, and `drop()`.
|
|
319
|
+
- `FilterModel({ options?, query?, match? })` — query, `matches`, and the active match.
|
|
320
|
+
- `ResizeSession()` — panel sizes during a resize, cascading into neighbors at their limits.
|
|
321
|
+
- `ScrollFollowModel({ pinned? })` — whether the log follows the live edge, visible messages, and
|
|
322
|
+
pending scroll requests.
|
|
323
|
+
- `SelectionModel({ mode?, keys?, selectedKeys? })` — `toggle`, `selectRange`, `selectAll` over a
|
|
324
|
+
key set.
|
|
325
|
+
- `Toaster<Data>({ defaultDuration? })` — `add(data, options?)`, `toasts`, `dismiss(id)`,
|
|
326
|
+
`pause`/`resume`, with each toast's timer owned by the queue.
|
|
385
327
|
|
|
386
328
|
### Animations
|
|
387
329
|
|
|
388
|
-
CSS-only
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
- `
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
- `
|
|
396
|
-
|
|
397
|
-
- `
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
### Style Mixins
|
|
408
|
-
|
|
409
|
-
Recipes composed directly in a `mix` array.
|
|
410
|
-
|
|
411
|
-
- `floatingSurface()`, `panelChrome()`, `semanticColorPanel()` — the border, rounding, tint
|
|
412
|
-
and elevation a floating surface carries; the border and rounding a framed panel applies;
|
|
413
|
-
and the `&[data-color="…"]` branches a tinted panel keys its colors on.
|
|
414
|
-
- `interactiveTransition()` — the shared transition property, timing and duration for a
|
|
415
|
-
control's hover, focus, press and validity changes.
|
|
416
|
-
- `fieldStackLayout()`, `outputCaptionText()` — the single-column stacking every field
|
|
417
|
-
wrapper's host uses, and the muted caption typography every `<output>` shares.
|
|
418
|
-
- `graphicHostStyle()` — the flex-item layout and `currentColor` declarations a leading icon
|
|
419
|
-
or loading graphic shares, so the two swap without shifting layout.
|
|
420
|
-
- `rangeThumbAppearance(sizeVar, borderWidthVar)` — the circular range thumb: appearance
|
|
421
|
-
reset, fill and border, elevation, pressed scale, focus ring, disabled dimming.
|
|
422
|
-
- `rtlAwareGradientDirection(propertyName)` — a custom-property pairing behind a gradient
|
|
423
|
-
direction, flipped under `&:dir(rtl)`.
|
|
424
|
-
- `chartPalette(property, combinator?)`, `legendToggle()` — paints one property from
|
|
425
|
-
whichever of the `CHART_COLOR_SLOT_COUNT` `--ui-chart-*` slots an element's `data-color`
|
|
426
|
-
names, and the position-keyed rules pairing a chart root with a later-sibling legend.
|
|
330
|
+
CSS-only factories keyed off `[open]`/`:popover-open` (or a `when` selector), each collapsing to an
|
|
331
|
+
opacity fade under reduced motion.
|
|
332
|
+
|
|
333
|
+
- `enterExit(options?)` — the composer behind the rest; `exit` sets quieter leaving values.
|
|
334
|
+
- `fade(options?)`, `zoom(options?)`, `slide({ from, ... })` — a fade, a fade with scale, and a fade
|
|
335
|
+
with an offset from `"top" | "right" | "bottom" | "left"`.
|
|
336
|
+
- `spin()`, `pulse()`, `shimmer()`, `textShimmer()` — continuous motion for busy and loading states.
|
|
337
|
+
- `scrollShadow()`, `scrollProgress()`, `scrollFade()`, `viewReveal()` — scroll- and view-timeline
|
|
338
|
+
effects.
|
|
339
|
+
- `durations` — `fast` 150, `normal` 200, `slow` 300, `slower` 400 (ms); `easings` — `standard`,
|
|
340
|
+
`decelerate`, `accelerate`, `linear`.
|
|
341
|
+
|
|
342
|
+
### Styles
|
|
343
|
+
|
|
344
|
+
Recipes for a `mix` array: `floatingSurface()`, `surfaceInset()`, `hitArea()`, `panelChrome()`,
|
|
345
|
+
`semanticColorPanel()`, `interactiveTransition()`, `fieldStackLayout()`, `outputCaptionText()`,
|
|
346
|
+
`graphicHostStyle()`, `rangeThumbAppearance(sizeVar, borderWidthVar)`,
|
|
347
|
+
`rtlAwareGradientDirection(propertyName)`, `chartPalette(property, combinator?)` (one of
|
|
348
|
+
`CHART_COLOR_SLOT_COUNT` chart colors from `data-color`) and `legendToggle()`.
|
|
427
349
|
|
|
428
350
|
### Utilities
|
|
429
351
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
- **
|
|
433
|
-
`
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
`
|
|
439
|
-
- **Fields** — `resolveFieldWiring
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
`
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
352
|
+
- **Color** — `parseColor(input): RGBAColor | null`, `formatHex`, `formatRgb`, `formatHsl`,
|
|
353
|
+
`rgbToHsl`, `hslToRgb`, `rgbToHsv`, `hsvToRgb`, `clampChannel`, `roundChannel`.
|
|
354
|
+
- **Charts** — `linearScale(domain, range)`, `bandScale(domain, range)`, `ticks(domain, count)`,
|
|
355
|
+
`linePath`, `areaPath`, `arcPath`, `pieAngles`, `computeMarkerIndices`, `HUE_GRADIENT_STOPS`.
|
|
356
|
+
- **Geometry** — `normalizedPointerPosition`, `angleFromCenter`, `angleToHue`, `hueToAngle`,
|
|
357
|
+
`resolveFillPercent`, `FULL_TURN_RADIANS`.
|
|
358
|
+
- **Keys** — `parseKeyCombo`, `matchesKeyCombo(event, combo)`, `keyComboGlyphs(combo, apple)`,
|
|
359
|
+
`isTypingTarget`, `TYPING_TARGET_SELECTOR`. A combo is spelled once (`"mod+k"`, `"escape"`,
|
|
360
|
+
`"?"`); `mod` is Command on Apple keyboards and Control elsewhere.
|
|
361
|
+
- **Fields** — `resolveFieldWiring(id, options)`, `findPairedRangeInputs`.
|
|
362
|
+
- **DOM** — `asCommandEvent`, `dispatchChange`, `isNewPrimaryPress`, `isPrintableKey`, `focusItem`,
|
|
363
|
+
`queryItems`, `setRovingTabindex`, `labelFor`, `hasAccessibleText`, `mergeStyle`, `prefersReducedMotion`, `writeCookie(name, value, maxAgeSeconds?)`,
|
|
364
|
+
`DISABLED_SELECTOR`, `DEFAULT_ICON_ARIA_HIDDEN`, `ONE_YEAR_SECONDS`.
|
|
365
|
+
- **Accessibility checks** — `warnIfNoAccessibleName(props, children, message)` and
|
|
366
|
+
`warnIfNoAccessibleLabel(props, message)`, development-only warnings.
|
|
367
|
+
- **Panels** — `semanticColorPanelStyle(color)`, the border, background and text declarations for
|
|
368
|
+
one semantic color.
|
|
369
|
+
|
|
370
|
+
### Types
|
|
371
|
+
|
|
372
|
+
`SemanticColor`, `FieldColor`, `AnchorPlacement`, `AriaInvalid`, `AriaInvalidToken`, `CSSStyles`,
|
|
373
|
+
`StyleProp`, `StyleDeclarations`, `HeadingLevel`, `FieldIssueState`, `FieldWiring`,
|
|
374
|
+
`FieldWiringOptions`, `FieldPartsProps`, `AccessibleNameProps`, `SemanticColorPanelStyle`,
|
|
375
|
+
`KeyCombo`, `Point`, `Rect`, `RGBColor`, `RGBAColor`, `HSLColor`, `HSVColor`, and the option
|
|
376
|
+
namespaces `LinearScale`, `BandScale`, `ArcPath` and `PieAngles` from `./utils`. Each component,
|
|
377
|
+
mixin, behavior and animation also exposes its option types on its own namespace (`Toaster.Init`,
|
|
378
|
+
`Dismiss.Options`, `Fade.Options`).
|
|
379
|
+
|
|
380
|
+
## Pattern: A Validated Form
|
|
381
|
+
|
|
382
|
+
`Form` hands a failed parse's issues to each field by `name`; the field renders its `FieldError`,
|
|
383
|
+
sets `aria-invalid`, and the first invalid one takes focus. Native constraints still block bad
|
|
384
|
+
input before any JavaScript runs.
|
|
385
|
+
|
|
386
|
+
```tsx
|
|
387
|
+
import type { Handle } from "remix/component";
|
|
388
|
+
|
|
389
|
+
import * as s from "remix/data-schema";
|
|
390
|
+
import * as checks from "remix/data-schema/checks";
|
|
391
|
+
import * as f from "remix/data-schema/form-data";
|
|
392
|
+
|
|
393
|
+
import { Button, Form, TextField } from "@sdxc/ui";
|
|
394
|
+
|
|
395
|
+
export let ContactSchema = f.object({
|
|
396
|
+
email: f.field(s.string().pipe(checks.minLength(1), checks.email())),
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
export function ContactPage(handle: Handle<{ issues?: ReadonlyArray<Form.Issue> }>) {
|
|
400
|
+
return () => (
|
|
401
|
+
<Form method="post" issues={handle.props.issues}>
|
|
402
|
+
<TextField label="Email" name="email" type="email" required />
|
|
403
|
+
<Button type="submit">Send</Button>
|
|
404
|
+
</Form>
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// In the POST handler:
|
|
409
|
+
// let result = s.parseSafe(ContactSchema, formData);
|
|
410
|
+
// if (!result.success) render <ContactPage issues={result.issues} /> with status 400
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
Pass `errorMessage` to a field for a message the schema does not produce, or apply
|
|
414
|
+
`validate(schema)` from `@sdxc/ui/mixins` to check a control in the browser as the user types.
|
|
415
|
+
|
|
416
|
+
## Pattern: A Confirmed Destructive Action
|
|
417
|
+
|
|
418
|
+
`Confirm` with `form` wraps its buttons in a real `<form>`, so confirming is an ordinary POST and
|
|
419
|
+
cancelling only closes the dialog:
|
|
420
|
+
|
|
421
|
+
```tsx
|
|
422
|
+
import { Button, Confirm } from "@sdxc/ui";
|
|
423
|
+
|
|
424
|
+
<Button commandfor="revoke-session" command="show-modal" color="danger">
|
|
425
|
+
Revoke session
|
|
426
|
+
</Button>
|
|
427
|
+
<Confirm
|
|
428
|
+
id="revoke-session"
|
|
429
|
+
title="Revoke this session?"
|
|
430
|
+
description="The device is signed out immediately."
|
|
431
|
+
confirmLabel="Revoke"
|
|
432
|
+
cancelLabel="Cancel"
|
|
433
|
+
color="danger"
|
|
434
|
+
form={{
|
|
435
|
+
action: "/sessions/revoke",
|
|
436
|
+
method: "post",
|
|
437
|
+
fields: <input type="hidden" name="sessionId" value="42" />,
|
|
438
|
+
}}
|
|
439
|
+
/>;
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
Render it outside any other `<form>`. Without `form`, the confirm button closes the dialog and your
|
|
443
|
+
page decides what confirmation means; for anything else, compose `AlertDialog` and its parts.
|
|
444
|
+
|
|
445
|
+
## Pattern: A Toast Queue
|
|
446
|
+
|
|
447
|
+
A `Toaster` owns the queue and each toast's timer; an island subscribes with `whileLive` and
|
|
448
|
+
publishes the queue through context so any descendant can add to it:
|
|
457
449
|
|
|
458
450
|
```tsx
|
|
459
451
|
import type { Handle } from "remix/component";
|
|
@@ -464,79 +456,113 @@ import { Toast } from "@sdxc/ui";
|
|
|
464
456
|
import { Toaster } from "@sdxc/ui/behaviors";
|
|
465
457
|
import { whileLive } from "@sdxc/ui/mixins";
|
|
466
458
|
|
|
467
|
-
export
|
|
468
|
-
|
|
469
|
-
function AppToaster(handle: Handle) {
|
|
470
|
-
let toaster = new Toaster<{ title: string; color?: Toast.Color }>();
|
|
459
|
+
export let Toasts = clientEntry("/components/toasts.tsx#Toasts", function Toasts(handle: Handle) {
|
|
460
|
+
let toaster = new Toaster<{ title: string; color?: Toast.Color }>({ defaultDuration: 5000 });
|
|
471
461
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
462
|
+
whileLive(handle, (model: Toaster, signal) =>
|
|
463
|
+
model.addEventListener("change", () => handle.update(), { signal }),
|
|
464
|
+
)(toaster);
|
|
465
|
+
handle.context.set({ toaster });
|
|
476
466
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
467
|
+
return () => (
|
|
468
|
+
<Toast.Region aria-label="Notifications" placement="bottom-end">
|
|
469
|
+
{toaster.toasts.map((toast) => (
|
|
470
|
+
<Toast key={toast.id} color={toast.data.color}>
|
|
471
|
+
<Toast.Content>
|
|
472
|
+
<Toast.Title>{toast.data.title}</Toast.Title>
|
|
473
|
+
</Toast.Content>
|
|
474
|
+
</Toast>
|
|
475
|
+
))}
|
|
476
|
+
</Toast.Region>
|
|
477
|
+
);
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
// Anywhere below it:
|
|
481
|
+
// handle.context.get(Toasts).toaster.add({ title: "Saved", color: "success" });
|
|
490
482
|
```
|
|
491
483
|
|
|
492
|
-
|
|
493
|
-
|
|
484
|
+
## Pattern: Custom Commands From Static Buttons
|
|
485
|
+
|
|
486
|
+
A `command` starting with `--` reaches its `commandfor` target as a `CommandEvent` with no built-in
|
|
487
|
+
behavior, and mixins answer the `--ui-*` ones. The buttons stay server markup anywhere on the page,
|
|
488
|
+
outside the island that owns the target; parameters ride the button's `data-*` attributes:
|
|
494
489
|
|
|
495
|
-
|
|
490
|
+
```tsx
|
|
491
|
+
import { Button, Carousel } from "@sdxc/ui";
|
|
492
|
+
import { carouselControls, themeToggle } from "@sdxc/ui/mixins";
|
|
493
|
+
|
|
494
|
+
<Carousel aria-label="Product photos">
|
|
495
|
+
<Carousel.Viewport id="photos" mix={carouselControls()}>
|
|
496
|
+
<Carousel.Track>
|
|
497
|
+
<Carousel.Slide>
|
|
498
|
+
<img src="/front.jpg" alt="Front" />
|
|
499
|
+
</Carousel.Slide>
|
|
500
|
+
<Carousel.Slide>
|
|
501
|
+
<img src="/back.jpg" alt="Back" />
|
|
502
|
+
</Carousel.Slide>
|
|
503
|
+
</Carousel.Track>
|
|
504
|
+
</Carousel.Viewport>
|
|
505
|
+
<Carousel.Controls>
|
|
506
|
+
<Carousel.Previous commandfor="photos" aria-label="Previous photo" />
|
|
507
|
+
<Carousel.Next commandfor="photos" aria-label="Next photo" />
|
|
508
|
+
</Carousel.Controls>
|
|
509
|
+
</Carousel>
|
|
510
|
+
<Button commandfor="photos" command="--ui-goto" data-slide="1">
|
|
511
|
+
Show back
|
|
512
|
+
</Button>
|
|
513
|
+
|
|
514
|
+
<div id="theme" mix={themeToggle()}>
|
|
515
|
+
<Button commandfor="theme" command="--ui-theme-light">Light</Button>
|
|
516
|
+
<Button commandfor="theme" command="--ui-theme-dark">Dark</Button>
|
|
517
|
+
<Button commandfor="theme" command="--ui-theme-system">System</Button>
|
|
518
|
+
</div>;
|
|
519
|
+
```
|
|
496
520
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
521
|
+
`themeToggle` sets `.dark` or `.system` on `<html>` and writes the `ui:theme` cookie, so your server
|
|
522
|
+
can render the same class on the next request. `Button` and the invoker parts render
|
|
523
|
+
`type="button"` when they carry `command`; a hand-written `<button commandfor>` inside a `<form>`
|
|
524
|
+
needs `type="button"` before its `command` attributes, or the platform runs nothing.
|
|
525
|
+
|
|
526
|
+
## Pattern: Keyboard Shortcuts
|
|
527
|
+
|
|
528
|
+
`keymap` binds shortcuts on an island's host, a `Modal` lists them with `ShortcutList`, and an
|
|
529
|
+
`Announcer` paces what a live region reads:
|
|
502
530
|
|
|
503
531
|
```tsx
|
|
504
532
|
import type { Handle } from "remix/component";
|
|
505
533
|
|
|
506
|
-
import {
|
|
534
|
+
import { clientEntry } from "remix/component";
|
|
535
|
+
|
|
507
536
|
import { Button, Modal, ShortcutList } from "@sdxc/ui";
|
|
508
537
|
import { Announcer } from "@sdxc/ui/behaviors";
|
|
509
538
|
import { keymap, whileLive } from "@sdxc/ui/mixins";
|
|
510
539
|
import { keyComboGlyphs } from "@sdxc/ui/utils";
|
|
511
|
-
import { clientEntry } from "remix/component";
|
|
512
|
-
|
|
513
|
-
type Props = { apple: boolean };
|
|
514
540
|
|
|
515
541
|
export default clientEntry(
|
|
516
|
-
"/
|
|
517
|
-
function Shortcuts(handle: Handle<
|
|
542
|
+
"/components/shortcuts.tsx#default",
|
|
543
|
+
function Shortcuts(handle: Handle<{ apple: boolean }>) {
|
|
518
544
|
let announcer = new Announcer({ hold: 1200 });
|
|
519
545
|
whileLive(handle, (model: Announcer, signal) =>
|
|
520
546
|
model.addEventListener("change", () => handle.update(), { signal }),
|
|
521
547
|
)(announcer);
|
|
522
548
|
|
|
523
|
-
let
|
|
524
|
-
|
|
549
|
+
let save = () => announcer.announce("Saved");
|
|
550
|
+
let openHelp = () => document.querySelector<HTMLDialogElement>("#shortcuts")?.showModal();
|
|
525
551
|
|
|
526
552
|
return () => (
|
|
527
|
-
<div mix={
|
|
528
|
-
<Button
|
|
529
|
-
|
|
553
|
+
<div mix={keymap({ "mod+s": save, "?": openHelp })}>
|
|
554
|
+
<Button commandfor="shortcuts" command="show-modal">
|
|
555
|
+
Keyboard shortcuts
|
|
530
556
|
</Button>
|
|
531
|
-
<Modal id="shortcuts" aria-label=
|
|
557
|
+
<Modal id="shortcuts" aria-label="Keyboard shortcuts">
|
|
532
558
|
<ShortcutList>
|
|
533
559
|
<ShortcutList.Item keys={keyComboGlyphs("mod+s", handle.props.apple)}>
|
|
534
|
-
|
|
560
|
+
Save
|
|
535
561
|
</ShortcutList.Item>
|
|
536
|
-
<ShortcutList.Item keys={["
|
|
562
|
+
<ShortcutList.Item keys={["?"]}>Show shortcuts</ShortcutList.Item>
|
|
537
563
|
</ShortcutList>
|
|
538
564
|
</Modal>
|
|
539
|
-
<div role="status" aria-live="polite"
|
|
565
|
+
<div role="status" aria-live="polite">
|
|
540
566
|
{announcer.current?.text ?? ""}
|
|
541
567
|
</div>
|
|
542
568
|
</div>
|
|
@@ -545,312 +571,140 @@ export default clientEntry(
|
|
|
545
571
|
);
|
|
546
572
|
```
|
|
547
573
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
## Pattern: The Custom Command Trigger Contract
|
|
552
|
-
|
|
553
|
-
[Invoker Commands](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API)
|
|
554
|
-
go beyond the built-in `show-modal`, `close` and `toggle-popover` values: any `command`
|
|
555
|
-
prefixed with `--` dispatches a `CommandEvent` on its `commandfor` target with no built-in
|
|
556
|
-
behavior. That is the trigger contract between static server buttons and hydrated widgets.
|
|
557
|
-
|
|
558
|
-
A widget-root mixin listens for `command` on its host and switches on `event.command`.
|
|
559
|
-
Library commands carry the `--ui-` prefix (`--ui-next`, `--ui-dismiss`, `--ui-toggle`), and
|
|
560
|
-
unknown commands pass through, so an app's own `--` commands can target the same elements.
|
|
561
|
-
Trigger buttons stay static markup anywhere on the page, including outside the island that
|
|
562
|
-
owns the widget. Parameters ride the invoker — `event.source` is the triggering button, so
|
|
563
|
-
this carries its payload in `event.source.dataset`:
|
|
564
|
-
|
|
565
|
-
```tsx
|
|
566
|
-
<button commandfor="cart-carousel" command="--ui-goto" data-slide="3">
|
|
567
|
-
{t("carousel.goto", { slide: 3 })}
|
|
568
|
-
</button>
|
|
569
|
-
```
|
|
570
|
-
|
|
571
|
-
`Button` renders `type="button"` on its own whenever it carries `command` or `commandfor`,
|
|
572
|
-
as do `Dialog.Close`, `AlertDialog.Cancel` and the other invoker parts. A button inside a
|
|
573
|
-
`<form>` otherwise defaults to `"submit"`, and the platform then treats the pairing as
|
|
574
|
-
ambiguous and runs nothing. A hand-rolled `<button commandfor=…>` inside a form spells
|
|
575
|
-
`type="button"` out, written ahead of `command`/`commandfor`, since the platform judges the
|
|
576
|
-
pairing as it parses those attributes.
|
|
577
|
-
|
|
578
|
-
## Pattern: The Ambient Heading Scope
|
|
579
|
-
|
|
580
|
-
`HeadingScope` publishes a heading depth through `handle.context`, one level deeper than the
|
|
581
|
-
`HeadingScope` it is nested inside, or `1` where nothing wraps it. `Heading` — and every
|
|
582
|
-
title slot, such as `Dialog.Title`, `Alert.Title` and `Empty.Title` — reads that depth:
|
|
583
|
-
|
|
584
|
-
```tsx
|
|
585
|
-
<HeadingScope>
|
|
586
|
-
<Heading>{t("doc.title")}</Heading> {/* <h1>, no ancestor scope */}
|
|
587
|
-
<HeadingScope>
|
|
588
|
-
<Heading>{t("doc.section")}</Heading> {/* <h2>, one level deeper */}
|
|
589
|
-
</HeadingScope>
|
|
590
|
-
</HeadingScope>
|
|
591
|
-
```
|
|
592
|
-
|
|
593
|
-
An independently hydrated island has no ancestor context to read, even where the
|
|
594
|
-
server-rendered page nests it under a real scope. Threading the level down as an explicit
|
|
595
|
-
`level` prop is the first choice. Where that is impractical, apply
|
|
596
|
-
`headingLevelFallback({ onLevel })` to the island's own `HeadingScope`: it reads the
|
|
597
|
-
`data-heading-level` attribute `HeadingScope` and `Heading` already stamp on the DOM, hands
|
|
598
|
-
the detected `HeadingLevel` to the callback once on attach, and the island stores it and
|
|
599
|
-
re-renders with `level` set.
|
|
574
|
+
Bindings stand down while the user types in a field, composes with an IME, or works in a dialog
|
|
575
|
+
outside the host. `hotkey("mod+k")` on a `<dialog>` or popover is the one-shortcut shorthand.
|
|
600
576
|
|
|
601
|
-
## Pattern:
|
|
577
|
+
## Pattern: Restyling A Component
|
|
602
578
|
|
|
603
|
-
|
|
604
|
-
in one array:
|
|
579
|
+
`mix` adds declarations to a component's host, `parts` reaches the inner elements of a wrapper, and
|
|
580
|
+
the style recipes and animation factories compose with your own `css()` in one array:
|
|
605
581
|
|
|
606
582
|
```tsx
|
|
607
583
|
import { css } from "remix/component";
|
|
608
584
|
|
|
585
|
+
import { Card, TextField } from "@sdxc/ui";
|
|
609
586
|
import { zoom } from "@sdxc/ui/animations";
|
|
610
|
-
import { floatingSurface
|
|
587
|
+
import { floatingSurface } from "@sdxc/ui/styles";
|
|
588
|
+
|
|
589
|
+
<Card mix={css({ maxInlineSize: "32rem" })} style={{ "--ui-radius-lg": "1rem" }}>
|
|
590
|
+
<TextField
|
|
591
|
+
label="Username"
|
|
592
|
+
name="username"
|
|
593
|
+
parts={{ input: css({ fontFamily: "var(--ui-font-mono)" }) }}
|
|
594
|
+
/>
|
|
595
|
+
</Card>
|
|
611
596
|
|
|
612
597
|
<div
|
|
613
598
|
id="account-menu"
|
|
614
599
|
popover="auto"
|
|
615
|
-
mix={[
|
|
616
|
-
floatingSurface(),
|
|
617
|
-
interactiveTransition(),
|
|
618
|
-
zoom({ scale: 0.95, duration: 150 }),
|
|
619
|
-
css({ margin: "0", inset: "auto", paddingBlock: "0.5rem" }),
|
|
620
|
-
]}
|
|
600
|
+
mix={[floatingSurface(), zoom({ scale: 0.95 }), css({ paddingBlock: "0.5rem" })]}
|
|
621
601
|
>
|
|
622
|
-
|
|
602
|
+
Signed in as Ada
|
|
623
603
|
</div>;
|
|
624
604
|
```
|
|
625
605
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
Each entry compiles to one hashed class in its own cascade sublayer, and a class's layer
|
|
631
|
-
position is fixed the first time that exact declaration set appears on the page — so `mix`
|
|
632
|
-
is where declarations the component does not already set belong. To settle a declaration the
|
|
633
|
-
component already makes, four routes win outright: the `style` prop, an inline override of
|
|
634
|
-
the component's own token (`style={{ "--ui-text-2xl": "0.875rem" }}`), a `raw()` declaration
|
|
635
|
-
marked `!important`, or a rule in an app cascade layer declared after `rmx`.
|
|
636
|
-
|
|
637
|
-
## Pattern: Styling One Part Of A Wrapper
|
|
638
|
-
|
|
639
|
-
A wrapper rendering more than one host element takes a `parts` prop, one `mix` per named
|
|
640
|
-
part. `TextField`'s four — `label`, `input`, `description`, `error` — are the base shape
|
|
641
|
-
every field wrapper extends:
|
|
642
|
-
|
|
643
|
-
```tsx
|
|
644
|
-
import { css } from "remix/component";
|
|
645
|
-
|
|
646
|
-
import { TextField } from "@sdxc/ui";
|
|
647
|
-
|
|
648
|
-
<TextField
|
|
649
|
-
label={t("form.username.label")}
|
|
650
|
-
name="username"
|
|
651
|
-
parts={{ input: css({ fontFamily: "var(--ui-font-mono)" }) }}
|
|
652
|
-
/>;
|
|
653
|
-
```
|
|
654
|
-
|
|
655
|
-
`ColorField` adds `control` (the row wrapping input and swatch) and `swatch` to that base.
|
|
656
|
-
`Confirm` exposes parts matching each of its composed pieces — `header`, `title`,
|
|
657
|
-
`description`, `footer`, `cancel`, `action`, and `form` in submit mode. Where `parts` runs
|
|
658
|
-
out, composing the underlying components directly — `Label` plus `Input` plus `Description`
|
|
659
|
-
plus `FieldError`, or `AlertDialog` and its own parts — covers the rest.
|
|
660
|
-
|
|
661
|
-
## Pattern: A Confirmed Destructive Action
|
|
662
|
-
|
|
663
|
-
Given a `form` prop, `Confirm` wraps its content in a real `<form>` and the confirming
|
|
664
|
-
control becomes that form's submit button, so a destructive action runs as an ordinary form
|
|
665
|
-
post with no client JavaScript. `fields` renders the hidden inputs the submission needs:
|
|
666
|
-
|
|
667
|
-
```tsx
|
|
668
|
-
import { Button, Confirm } from "@sdxc/ui";
|
|
669
|
-
|
|
670
|
-
<Button commandfor="revoke-session" command="show-modal" color="danger">
|
|
671
|
-
{t("session.revoke")}
|
|
672
|
-
</Button>
|
|
673
|
-
<Confirm
|
|
674
|
-
id="revoke-session"
|
|
675
|
-
title={t("session.revokeTitle")}
|
|
676
|
-
confirmLabel={t("actions.revoke")}
|
|
677
|
-
cancelLabel={t("actions.cancel")}
|
|
678
|
-
form={{
|
|
679
|
-
action: revokeUrl,
|
|
680
|
-
fields: <input type="hidden" name="intent" value="revoke" />,
|
|
681
|
-
}}
|
|
682
|
-
/>;
|
|
683
|
-
```
|
|
684
|
-
|
|
685
|
-
Without `form`, the confirming control closes the panel and the page decides what a
|
|
686
|
-
confirmed decision means. The cancel control stays a close-command button in both modes, so
|
|
687
|
-
cancelling never submits. Submit mode renders a `<form>`, so the panel belongs outside any
|
|
688
|
-
other form's markup, per the platform's own nesting rule. For a shape this does not cover,
|
|
689
|
-
compose `AlertDialog` directly and give `AlertDialog.Action` a `type="submit"`: it then
|
|
690
|
-
submits the enclosing form instead of running a command.
|
|
606
|
+
To change a declaration the component already sets, override its `--ui-*` variable (as above), use
|
|
607
|
+
`style`, or write the rule in a cascade layer declared after `rmx`. When `parts` is not enough,
|
|
608
|
+
compose the underlying pieces (`Label`, `Input`, `Description`, `FieldError`) directly.
|
|
691
609
|
|
|
692
|
-
## Pattern: A
|
|
610
|
+
## Pattern: A Chart With A Legend
|
|
693
611
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
page with `issues` set:
|
|
612
|
+
Charts render as accessible SVG on the server: every point is a focusable marker whose `label` is its
|
|
613
|
+
native tooltip. A `Chart.Legend` placed after the chart pairs its items with the series by order:
|
|
697
614
|
|
|
698
615
|
```tsx
|
|
699
616
|
import type { Handle } from "remix/component";
|
|
700
617
|
|
|
701
|
-
import
|
|
702
|
-
import { parseSafe } from "remix/data-schema";
|
|
703
|
-
import * as checks from "remix/data-schema/checks";
|
|
704
|
-
import * as f from "remix/data-schema/form-data";
|
|
618
|
+
import { css } from "remix/component";
|
|
705
619
|
|
|
706
|
-
import {
|
|
620
|
+
import { Chart } from "@sdxc/ui";
|
|
707
621
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
622
|
+
interface Point {
|
|
623
|
+
x: number;
|
|
624
|
+
y: number;
|
|
625
|
+
label: string;
|
|
626
|
+
}
|
|
711
627
|
|
|
712
|
-
function
|
|
628
|
+
export function RevenueChart(handle: Handle<{ revenue: Point[]; refunds: Point[] }>) {
|
|
713
629
|
return () => (
|
|
714
|
-
|
|
715
|
-
<
|
|
716
|
-
|
|
717
|
-
|
|
630
|
+
<>
|
|
631
|
+
<Chart
|
|
632
|
+
width={480}
|
|
633
|
+
height={240}
|
|
634
|
+
xDomain={[0, 11]}
|
|
635
|
+
yDomain={[0, 5000]}
|
|
636
|
+
aria-label="Revenue by month"
|
|
637
|
+
>
|
|
638
|
+
<Chart.Line color={1} points={handle.props.revenue} />
|
|
639
|
+
<Chart.Line
|
|
640
|
+
color={3}
|
|
641
|
+
points={handle.props.refunds}
|
|
642
|
+
parts={{ path: css({ strokeDasharray: "4 4" }) }}
|
|
643
|
+
/>
|
|
644
|
+
</Chart>
|
|
645
|
+
<Chart.Legend aria-label="Series">
|
|
646
|
+
<Chart.Legend.Item color={1}>Revenue</Chart.Legend.Item>
|
|
647
|
+
<Chart.Legend.Item color={3}>Refunds</Chart.Legend.Item>
|
|
648
|
+
</Chart.Legend>
|
|
649
|
+
</>
|
|
718
650
|
);
|
|
719
651
|
}
|
|
720
|
-
|
|
721
|
-
// In the handler for the POST:
|
|
722
|
-
let result = parseSafe(ContactSchema, formData);
|
|
723
|
-
if (!result.success) return render(<ContactPage issues={result.issues} />, { status: 400 });
|
|
724
652
|
```
|
|
725
653
|
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
through a plain prop.
|
|
654
|
+
`color` picks one of the eight `--ui-chart-*` colors. `Chart.Area` plots inside a `Chart` the same
|
|
655
|
+
way; `Chart.Bar` and `Chart.Pie` are standalone SVGs sized by their own `width` and `height`.
|
|
729
656
|
|
|
730
|
-
|
|
731
|
-
`ColorField` each look their own message up by `name` through form context. A field found in
|
|
732
|
-
`issues` renders its `FieldError`, marks `aria-invalid`, wires `aria-describedby` at the
|
|
733
|
-
message, and — for the first invalid field of the render — picks up `autofocus`. An explicit
|
|
734
|
-
`errorMessage` or `autoFocus` decides that field instead, for a message the schema does not
|
|
735
|
-
produce.
|
|
657
|
+
## Pattern: A Message Thread That Follows New Turns
|
|
736
658
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
`Chart.Legend` renders as a later sibling of the chart root, and each `Chart.Legend.Item`
|
|
740
|
-
appears in the same order as its matching series: the toggle wiring keys off sibling
|
|
741
|
-
position rather than a series id.
|
|
659
|
+
`messageFollow` keeps the log pinned to the newest turn until the reader scrolls away, then reveals
|
|
660
|
+
the jump-to-latest button:
|
|
742
661
|
|
|
743
662
|
```tsx
|
|
744
|
-
import {
|
|
745
|
-
|
|
746
|
-
import { Chart } from "@sdxc/ui";
|
|
747
|
-
|
|
748
|
-
<>
|
|
749
|
-
<Chart
|
|
750
|
-
width={480}
|
|
751
|
-
height={240}
|
|
752
|
-
xDomain={[0, 11]}
|
|
753
|
-
yDomain={[0, 5000]}
|
|
754
|
-
aria-label={t("chart.label")}
|
|
755
|
-
>
|
|
756
|
-
<Chart.Line color={1} points={revenuePoints} />
|
|
757
|
-
<Chart.Line color={3} points={refundPoints} parts={{ path: css({ strokeDasharray: "4 4" }) }} />
|
|
758
|
-
</Chart>
|
|
759
|
-
<Chart.Legend aria-label={t("chart.legend")}>
|
|
760
|
-
<Chart.Legend.Item color={1}>{t("chart.series.revenue")}</Chart.Legend.Item>
|
|
761
|
-
<Chart.Legend.Item color={3}>{t("chart.series.refunds")}</Chart.Legend.Item>
|
|
762
|
-
</Chart.Legend>
|
|
763
|
-
</>;
|
|
764
|
-
```
|
|
765
|
-
|
|
766
|
-
Each point carries `x`, `y` and a `label` that becomes its native `<title>`, and every wedge,
|
|
767
|
-
bar and marker stays keyboard-reachable on its own — this chart needs no `clientEntry` at
|
|
768
|
-
all. `chartTooltip()` is the separate, opt-in mixin for a floating tooltip synced to the
|
|
769
|
-
nearest point under the pointer or focus.
|
|
770
|
-
|
|
771
|
-
## Pattern: A Message Thread
|
|
772
|
-
|
|
773
|
-
`MessageScroller`, `Message`, `Bubble` and `Marker` compose into a conversational thread, and
|
|
774
|
-
`messageFollow()` bridges the viewport to a `ScrollFollowModel` so the log follows new turns
|
|
775
|
-
until a person scrolls away from the live edge:
|
|
663
|
+
import type { Handle } from "remix/component";
|
|
776
664
|
|
|
777
|
-
|
|
778
|
-
import { css } from "remix/component";
|
|
665
|
+
import { clientEntry, css } from "remix/component";
|
|
779
666
|
|
|
780
667
|
import { Bubble, Message, MessageScroller } from "@sdxc/ui";
|
|
781
668
|
import { ScrollFollowModel } from "@sdxc/ui/behaviors";
|
|
782
669
|
import { messageFollow } from "@sdxc/ui/mixins";
|
|
783
670
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
{turns.map((turn, index) => (
|
|
790
|
-
<MessageScroller.Item key={turn.id} messageId={turn.id} scrollAnchor={index === 0}>
|
|
791
|
-
<Message>
|
|
792
|
-
<Message.Content>
|
|
793
|
-
<Bubble align={turn.isSelf ? "end" : "start"} variant="muted">
|
|
794
|
-
<Bubble.Content>{turn.text}</Bubble.Content>
|
|
795
|
-
</Bubble>
|
|
796
|
-
</Message.Content>
|
|
797
|
-
</Message>
|
|
798
|
-
</MessageScroller.Item>
|
|
799
|
-
))}
|
|
800
|
-
</MessageScroller.Content>
|
|
801
|
-
</MessageScroller.Viewport>
|
|
802
|
-
<MessageScroller.Button aria-label={t("chat.jumpToLatest")}>
|
|
803
|
-
{t("chat.jumpToLatest")}
|
|
804
|
-
</MessageScroller.Button>
|
|
805
|
-
</MessageScroller>;
|
|
806
|
-
```
|
|
807
|
-
|
|
808
|
-
`MessageScroller.Item`'s `messageId` is required and unique per turn.
|
|
809
|
-
`MessageScroller.Button` starts `hidden` and is revealed by the
|
|
810
|
-
`messageFollow()`/`ScrollFollowModel` pairing.
|
|
811
|
-
|
|
812
|
-
## Pattern: A ColorPicker Composition
|
|
671
|
+
interface Turn {
|
|
672
|
+
id: string;
|
|
673
|
+
text: string;
|
|
674
|
+
mine: boolean;
|
|
675
|
+
}
|
|
813
676
|
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
677
|
+
export default clientEntry(
|
|
678
|
+
"/components/thread.tsx#default",
|
|
679
|
+
function Thread(handle: Handle<{ turns: Turn[] }>) {
|
|
680
|
+
let model = new ScrollFollowModel({ pinned: true });
|
|
817
681
|
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
</
|
|
682
|
+
return () => (
|
|
683
|
+
<MessageScroller mix={css({ blockSize: "32rem" })}>
|
|
684
|
+
<MessageScroller.Viewport mix={messageFollow(model)}>
|
|
685
|
+
<MessageScroller.Content>
|
|
686
|
+
{handle.props.turns.map((turn) => (
|
|
687
|
+
<MessageScroller.Item key={turn.id} messageId={turn.id}>
|
|
688
|
+
<Message>
|
|
689
|
+
<Message.Content>
|
|
690
|
+
<Bubble align={turn.mine ? "end" : "start"} variant="muted">
|
|
691
|
+
<Bubble.Content>{turn.text}</Bubble.Content>
|
|
692
|
+
</Bubble>
|
|
693
|
+
</Message.Content>
|
|
694
|
+
</Message>
|
|
695
|
+
</MessageScroller.Item>
|
|
696
|
+
))}
|
|
697
|
+
</MessageScroller.Content>
|
|
698
|
+
</MessageScroller.Viewport>
|
|
699
|
+
<MessageScroller.Button aria-label="Jump to latest">Latest</MessageScroller.Button>
|
|
700
|
+
</MessageScroller>
|
|
701
|
+
);
|
|
702
|
+
},
|
|
703
|
+
);
|
|
837
704
|
```
|
|
838
705
|
|
|
839
|
-
`
|
|
840
|
-
|
|
841
|
-
`data-color-area-axis` so `colorAreaDrag()` can pair them. Server-rendered alone, each part
|
|
842
|
-
still works through keyboard and native range operation; the island is what keeps the
|
|
843
|
-
siblings in sync.
|
|
844
|
-
|
|
845
|
-
## Pattern: Development-Mode Contract Warnings
|
|
846
|
-
|
|
847
|
-
Where the type system cannot enforce a required accessibility wiring, a component logs a
|
|
848
|
-
`console.warn` gated behind `import.meta.env.DEV`, stripped entirely from production
|
|
849
|
-
bundles — an icon-only `Button` or `Menu.Item` with no visible text and no `aria-label`, a
|
|
850
|
-
`Command.Item` rendered without the `value` a filter matches against, a `Menubar`,
|
|
851
|
-
`Toast.Region` or `Table` rendered without the `aria-label`/`aria-labelledby` identifying the
|
|
852
|
-
landmark, a `Dialog` rendered without the `id` a trigger's `commandfor` targets. These are a
|
|
853
|
-
development-time nudge rather than runtime validation, so rendering continues either way.
|
|
706
|
+
`messageId` is unique per turn; `scrollAnchor` on an item keeps that turn in place while earlier ones
|
|
707
|
+
load above it.
|
|
854
708
|
|
|
855
709
|
## Versioning
|
|
856
710
|
|