@antadesign/anta 0.3.19 → 0.3.21
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 +1 -1
- package/dist/anta_helpers.d.ts +11 -2
- package/dist/anta_helpers.js +9 -0
- package/dist/components/Banner.d.ts +3 -3
- package/dist/components/Button.d.ts +1 -1
- package/dist/components/Calendar.d.ts +11 -12
- package/dist/components/Card.d.ts +1 -1
- package/dist/components/Card.js +1 -1
- package/dist/components/Checkbox.d.ts +8 -9
- package/dist/components/Dialog.d.ts +1 -1
- package/dist/components/Expander.d.ts +5 -6
- package/dist/components/Input.d.ts +2 -2
- package/dist/components/Input.js +1 -1
- package/dist/components/InputAutocomplete.d.ts +8 -8
- package/dist/components/InputAutocomplete.js +24 -18
- package/dist/components/InputTime.d.ts +3 -3
- package/dist/components/InputTime.js +1 -1
- package/dist/components/Menu.d.ts +2 -2
- package/dist/components/MenuItem.d.ts +1 -1
- package/dist/components/MenuItem.js +1 -1
- package/dist/components/Progress.d.ts +1 -1
- package/dist/components/RadioGroup.d.ts +14 -15
- package/dist/components/RadioGroup.js +5 -2
- package/dist/components/Select.d.ts +33 -40
- package/dist/components/Select.js +6 -2
- package/dist/components/SelectFaceted.d.ts +27 -33
- package/dist/components/SelectFaceted.js +5 -1
- package/dist/components/Slider.d.ts +5 -5
- package/dist/components/Switch.d.ts +4 -4
- package/dist/components/TabPanel.d.ts +1 -2
- package/dist/components/TabPanel.js +0 -1
- package/dist/components/Tabs.d.ts +9 -9
- package/dist/components/Tabs.js +5 -2
- package/dist/components/Text.d.ts +5 -3
- package/dist/components/Text.js +7 -3
- package/dist/components/Title.d.ts +1 -1
- package/dist/components/Toaster.d.ts +1 -1
- package/dist/components/Tooltip.d.ts +1 -1
- package/dist/elements/a-card.css +1 -1
- package/dist/elements/a-dialog.css +1 -1
- package/dist/elements/a-expander.css +1 -1
- package/dist/elements/a-expander.d.ts +1 -0
- package/dist/elements/a-expander.js +12 -2
- package/dist/elements/a-menu.d.ts +1 -8
- package/dist/elements/a-menu.js +1 -40
- package/dist/elements/a-progress.css +1 -1
- package/dist/elements/a-text.d.ts +4 -0
- package/dist/elements/a-text.js +10 -3
- package/dist/elements/a-tooltip.css +1 -1
- package/dist/elements/a-tooltip.d.ts +8 -1
- package/dist/elements/a-tooltip.js +88 -15
- package/dist/elements/index.d.ts +1 -1
- package/dist/general_types.d.ts +33 -22
- package/dist/index.d.ts +3 -3
- package/dist/theme-anta.css +1 -1
- package/docs/accessibility.md +4 -4
- package/docs/changelog.md +40 -13
- package/docs/comparison.md +1 -1
- package/docs/components/banner.md +17 -17
- package/docs/components/button.md +6 -6
- package/docs/components/card.md +5 -6
- package/docs/components/checkbox.md +17 -18
- package/docs/components/dialog.md +2 -2
- package/docs/components/expander.md +27 -30
- package/docs/components/icon.md +1 -1
- package/docs/components/input-autocomplete.md +15 -16
- package/docs/components/input-date.md +54 -59
- package/docs/components/input-time.md +7 -7
- package/docs/components/input.md +14 -14
- package/docs/components/menu.md +72 -8
- package/docs/components/progress.md +2 -2
- package/docs/components/radio.md +28 -25
- package/docs/components/select-faceted.md +95 -100
- package/docs/components/select.md +113 -115
- package/docs/components/slider.md +15 -10
- package/docs/components/switch.md +13 -13
- package/docs/components/tabs.md +23 -23
- package/docs/components/tag.md +5 -5
- package/docs/components/text.md +31 -7
- package/docs/components/title.md +1 -1
- package/docs/components/toaster.md +4 -4
- package/docs/components/tooltip.md +2 -2
- package/docs/credits.md +0 -4
- package/docs/index.md +1 -1
- package/docs/install-config.md +12 -7
- package/docs/normalization.md +6 -9
- package/docs/overview.md +1 -1
- package/docs/packages/stickers.md +1 -1
- package/docs/theming.md +15 -0
- package/package.json +3 -8
|
@@ -20,14 +20,14 @@ or uncontrolled (`defaultValue`), and submits under `name` via the native form A
|
|
|
20
20
|
|
|
21
21
|
Focus a section and edit it with the keyboard: ↑/↓ to step (it
|
|
22
22
|
wraps), PageUp/PageDown for a larger jump on minutes,
|
|
23
|
-
or
|
|
23
|
+
or enter the digits. Home/End, selection, deletion, and
|
|
24
24
|
paste behave as they do in a native text input. Typing
|
|
25
25
|
`9` then `3` `0` lands `09:30` and moves across the sections on its own; an
|
|
26
26
|
out-of-range digit (a `6` in the minutes) commits and advances immediately.
|
|
27
27
|
Backspace on an empty section selects the previous one. The whole thing
|
|
28
28
|
reads as one field while preserving native caret behavior. In a
|
|
29
29
|
12-hour field, typing a 24-hour hour converts it and flips AM/PM — `18` becomes
|
|
30
|
-
`6 PM
|
|
30
|
+
`6 PM`, so pasted 24-hour times work.
|
|
31
31
|
|
|
32
32
|
```tsx
|
|
33
33
|
<InputTime label="Start time" defaultValue="09:30" onValueChange={(_, { value }) => save(value)} />
|
|
@@ -69,7 +69,7 @@ range is clamped to the nearest bound as you step or leave the field, and flags
|
|
|
69
69
|
| Prop | Type | Default | Description |
|
|
70
70
|
|------|------|---------|-------------|
|
|
71
71
|
| `children?` | ReactNode | — | Extra content rendered under the field, above the hint (a no-box child like
|
|
72
|
-
a `<Tooltip>` takes no space and
|
|
72
|
+
a `<Tooltip>` takes no space and anchors to the field). |
|
|
73
73
|
| `clearable?` | boolean | — | Show a clear button once the field has a value. |
|
|
74
74
|
| `defaultValue?` | string | — | Initial value for the uncontrolled case (24-hour `"HH:mm"`). |
|
|
75
75
|
| `dimActions?` | boolean | — | Dim the trailing adornments at rest; they brighten on hover / focus. |
|
|
@@ -101,12 +101,12 @@ range is clamped to the nearest bound as you step or leave the field, and flags
|
|
|
101
101
|
others are advisory. Omit (or `neutral`) for a plain field. |
|
|
102
102
|
| `statusIcon?` | (string & {}) \| false \| IconShape | — | Glyph before the `hint` when `status` is set (per-status default; pass a
|
|
103
103
|
shape to override, or `false` to drop it). |
|
|
104
|
-
| `tone?` | string | — | Custom accent
|
|
104
|
+
| `tone?` | string | — | Custom accent color — any literal CSS color tints the resting + hover
|
|
105
105
|
border (focus ring stays `--focus-ring`); `status` overrides for validation. |
|
|
106
106
|
| `trailing?` | ReactNode | — | Content pinned to the end of the field (after the clear button). |
|
|
107
107
|
| `value?` | string | — | Controlled value — 24-hour `"HH:mm"`. Pair with `onValueChange`. |
|
|
108
108
|
|
|
109
|
-
Use
|
|
109
|
+
Use the web component directly when you are not using React or Preact and a native control does not fit.
|
|
110
110
|
|
|
111
111
|
Slots supply the field label and leading icon.
|
|
112
112
|
|
|
@@ -165,9 +165,9 @@ tighter `1em` line:
|
|
|
165
165
|
`}</style>
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
-
For a one-off accent, `tone` takes **any literal CSS
|
|
168
|
+
For a one-off accent, `tone` takes **any literal CSS color** (e.g. `#7c3aed`) and
|
|
169
169
|
tints the resting + hover border — the focus ring stays the global ring. It's a
|
|
170
|
-
|
|
170
|
+
color, not a named tone; the named feedback tones live on `status`.
|
|
171
171
|
|
|
172
172
|
```tsx
|
|
173
173
|
<InputTime label="Accent" tone="#7c3aed" defaultValue="09:30" />
|
package/docs/components/input.md
CHANGED
|
@@ -24,7 +24,7 @@ Anta's text scale, so a field lines up with same-size `Text` / `Button`.
|
|
|
24
24
|
| `medium` | 28px | 15 / 20 | 16px |
|
|
25
25
|
| `large` | 32px | 17 / 22 | 18px |
|
|
26
26
|
|
|
27
|
-
## Label
|
|
27
|
+
## Label and hint
|
|
28
28
|
|
|
29
29
|
```tsx
|
|
30
30
|
<Input label="Display name" defaultValue="Ada Lovelace" />
|
|
@@ -75,8 +75,8 @@ recolors it.
|
|
|
75
75
|
|
|
76
76
|
It reuses the tone palette but isn't `tone`: **`status` is a validation *state*** (it
|
|
77
77
|
also carries the glyph and, for `critical`, validity), whereas `tone` — elsewhere in
|
|
78
|
-
Anta — is decorative
|
|
79
|
-
reserved for a one-off custom border
|
|
78
|
+
Anta — is decorative color. On `Input` the named tones live on `status`; `tone` is
|
|
79
|
+
reserved for a one-off custom border color.
|
|
80
80
|
|
|
81
81
|
Only `status="critical"` carries validity — it sets `aria-invalid`, flips the
|
|
82
82
|
`:state(invalid)` hook, and reports invalid to a surrounding `<form>` through
|
|
@@ -87,7 +87,7 @@ Each status has a default glyph (`critical` → `warning-diamond`, `warning` →
|
|
|
87
87
|
`circle-small-solid`). Override it with **`statusIcon`** (any shape), or drop it
|
|
88
88
|
with `statusIcon={false}`.
|
|
89
89
|
|
|
90
|
-
## Leading, trailing
|
|
90
|
+
## Leading, trailing, and clear
|
|
91
91
|
|
|
92
92
|
```tsx
|
|
93
93
|
{/* clearable — the clear button shows once there's a value */}
|
|
@@ -191,13 +191,13 @@ Autogrow uses CSS `field-sizing` where supported (Chromium, Safari ≥ 26.2) and
|
|
|
191
191
|
built-in JS resize everywhere else (Firefox, older Safari), so it grows in every
|
|
192
192
|
browser.
|
|
193
193
|
|
|
194
|
-
## Controlled
|
|
194
|
+
## Controlled and uncontrolled
|
|
195
195
|
|
|
196
196
|
```tsx
|
|
197
|
-
// Uncontrolled
|
|
197
|
+
// Uncontrolled: the element updates its value after input.
|
|
198
198
|
<Input label="Name" defaultValue="Ada" onChange={(e) => log(e.target.value)} />
|
|
199
199
|
|
|
200
|
-
// Controlled
|
|
200
|
+
// Controlled: application state supplies the value.
|
|
201
201
|
const [v, setV] = useState('')
|
|
202
202
|
<Input label="Name" value={v} onInput={(e) => setV(e.target.value)} />
|
|
203
203
|
```
|
|
@@ -251,7 +251,7 @@ Because `<a-input>` is form-associated, it submits with the surrounding
|
|
|
251
251
|
needed. `required` participates in native validity, and `<Button type="reset">`
|
|
252
252
|
restores the field to its `defaultValue` via `formResetCallback`.
|
|
253
253
|
|
|
254
|
-
## Types
|
|
254
|
+
## Types and validation
|
|
255
255
|
|
|
256
256
|
```tsx
|
|
257
257
|
<Input type="text" label="Text" />
|
|
@@ -263,7 +263,7 @@ restores the field to its `defaultValue` via `formResetCallback`.
|
|
|
263
263
|
```
|
|
264
264
|
|
|
265
265
|
`type` accepts `text` (default), `email`, `password`, `tel`, `url`, and
|
|
266
|
-
`number` — each gets the right mobile keyboard, autofill
|
|
266
|
+
`number` — each gets the right mobile keyboard, autofill behavior, and native
|
|
267
267
|
constraint validation. (`search` is omitted on purpose — see above.)
|
|
268
268
|
`number` also takes `min` / `max` / `step`.
|
|
269
269
|
|
|
@@ -433,7 +433,7 @@ wraps to fewer columns as it narrows. Resize the preview to see it reflow.
|
|
|
433
433
|
`username`, `current-password`, `new-password`, `one-time-code`, or `off`. |
|
|
434
434
|
| `children?` | ReactNode | — | Extra content rendered directly under the field, above the hint/error (it
|
|
435
435
|
pushes the message down). A no-box child like an Anta `<Tooltip>` takes no
|
|
436
|
-
space and
|
|
436
|
+
space and anchors to the field — consistent with how tooltips attach
|
|
437
437
|
to any other element. Use the named `leading` / `trailing` props for
|
|
438
438
|
in-field content. |
|
|
439
439
|
| `clearable?` | boolean | — | Show a clear button as the first trailing item once the field has a
|
|
@@ -508,7 +508,7 @@ wraps to fewer columns as it narrows. Resize the preview to see it reflow.
|
|
|
508
508
|
success → `circle-check`, info → `info`, brand → `circle-small-solid`); pass a
|
|
509
509
|
shape to override, or `false` to drop it. `neutral` has no default glyph. |
|
|
510
510
|
| `step?` | number \| string | — | |
|
|
511
|
-
| `tone?` | string | — | Custom accent
|
|
511
|
+
| `tone?` | string | — | Custom accent color — any literal CSS color tints the resting + hover
|
|
512
512
|
border (focus ring stays the global `--focus-ring`). For consistency with the
|
|
513
513
|
other controls' custom-tone knob; a `status` still overrides for validation. |
|
|
514
514
|
| `trailing?` | ReactNode | — | Content pinned to the end of the field (e.g. icons, buttons), after the
|
|
@@ -523,7 +523,7 @@ this; use `truncate` when an editable field should keep the same treatment. |
|
|
|
523
523
|
clear/search affordances never appear — Anta owns that chrome. |
|
|
524
524
|
| `value?` | string | — | Controlled value. Pair with `onChange` / `onInput`. |
|
|
525
525
|
|
|
526
|
-
Use
|
|
526
|
+
Use the web component directly when you are not using React or Preact and a native control does not fit.
|
|
527
527
|
|
|
528
528
|
Slots hold the label, hint, and controls around the native field.
|
|
529
529
|
|
|
@@ -563,7 +563,7 @@ their `size` attribute, so Anta does not reuse it. `round` and a custom-color
|
|
|
563
563
|
```
|
|
564
564
|
|
|
565
565
|
Reach for the props first: **`status`** sets a validation tone (border + message),
|
|
566
|
-
**`tone`** a custom accent
|
|
566
|
+
**`tone`** a custom accent color for the border (any CSS color), **`size`** the
|
|
567
567
|
dimensions. The focus ring is the global [`--focus-ring`](../colors.md#focus-ring).
|
|
568
568
|
|
|
569
569
|
```tsx
|
|
@@ -587,7 +587,7 @@ The border is drawn as an **inset `box-shadow`**, not a real `border`, so its wi
|
|
|
587
587
|
(`0.5px` → `1px` when a `status` is set) and placement never change the box size —
|
|
588
588
|
the field height stays locked to the matching Button. Drop the leading `inset` to
|
|
589
589
|
draw the border as an outset ring instead. You can also re-point an `--input-*`
|
|
590
|
-
|
|
590
|
+
color token on one instance (`style={{ '--input-border': 'var(--border-1)' }}`)
|
|
591
591
|
or a wrapping selector; the resolver lives in `@layer anta`, so any un-layered rule
|
|
592
592
|
of yours wins.
|
|
593
593
|
|
package/docs/components/menu.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Menu
|
|
2
2
|
|
|
3
|
-
A dropdown or context menu that anchors to
|
|
3
|
+
A dropdown or context menu that anchors to a target. Place
|
|
4
4
|
`<Menu>` immediately after the trigger — a button, an icon, a whole region —
|
|
5
5
|
and it opens on click, positions itself with room-aware flipping, and dismisses
|
|
6
6
|
on outside-click, `Escape`, or scroll. Rows are dedicated **`MenuItem`s** (not
|
|
@@ -12,7 +12,7 @@ Open state is uncontrolled by default — pass **`onStateChange`** (event-first:
|
|
|
12
12
|
observe it, or pass **`open`** to control it, applying `detail.next` to `open`
|
|
13
13
|
from your `onStateChange` handler (submenus stay uncontrolled). `statechange` is
|
|
14
14
|
**cancelable** and fires before the menu moves, so uncontrolled you can keep it
|
|
15
|
-
open with `event.preventDefault()`. You can also
|
|
15
|
+
open with `event.preventDefault()`. You can also keep a `ref` and call
|
|
16
16
|
`.open()` / `.close()` / `.toggle()`.
|
|
17
17
|
|
|
18
18
|
## Dropdown from a button
|
|
@@ -92,7 +92,7 @@ instead of its full border box. Anta's `Input` does this — it reports its fiel
|
|
|
92
92
|
box — so a `Menu` placed after an `<Input>` (as in `Select`) lines up with the
|
|
93
93
|
field, not the whole component (whose box also spans the label and hint).
|
|
94
94
|
|
|
95
|
-
##
|
|
95
|
+
## Open at the pointer
|
|
96
96
|
|
|
97
97
|
Pass `context` to open on right-click (the `contextmenu` event) of the region
|
|
98
98
|
the menu follows, positioned at the pointer — ideal for content surfaces like a
|
|
@@ -203,7 +203,7 @@ empty-state message (what `Select`'s `renderEmpty` uses).
|
|
|
203
203
|
</Menu>
|
|
204
204
|
```
|
|
205
205
|
|
|
206
|
-
## Pinned header
|
|
206
|
+
## Pinned header and footer
|
|
207
207
|
|
|
208
208
|
`a-menu-header` and `a-menu-footer` name fixed regions around the scrolling
|
|
209
209
|
items. Put `a-select-header` or `a-select-footer` in the same slots when a
|
|
@@ -225,7 +225,7 @@ footer stays the menu's divider.
|
|
|
225
225
|
</Menu>
|
|
226
226
|
```
|
|
227
227
|
|
|
228
|
-
## Custom content
|
|
228
|
+
## Custom content and the close behavior
|
|
229
229
|
|
|
230
230
|
The close decision is read straight from the DOM on click — never from whether a
|
|
231
231
|
handler called `preventDefault` — so it's safe in runtimes where event handlers
|
|
@@ -241,7 +241,7 @@ run off the UI thread. Walking out from the click, the nearest marker wins:
|
|
|
241
241
|
menu without being a `MenuItem`.
|
|
242
242
|
|
|
243
243
|
For programmatic open/close from app state, drive the `open` prop (the `state`
|
|
244
|
-
attribute, `"open"` / `"closed"`) and react via `onStateChange`, or
|
|
244
|
+
attribute, `"open"` / `"closed"`) and react via `onStateChange`, or keep a `ref`
|
|
245
245
|
and call `.open()` / `.close()` / `.toggle()`.
|
|
246
246
|
|
|
247
247
|
```tsx
|
|
@@ -313,7 +313,7 @@ a checkable menu.
|
|
|
313
313
|
<MenuItem selectionIndicator="checkbox" label="Show archived" selected data-menu-open />
|
|
314
314
|
```
|
|
315
315
|
|
|
316
|
-
## Badges, counters
|
|
316
|
+
## Badges, counters, and hints
|
|
317
317
|
|
|
318
318
|
Drop a `<Tag>` (or any element) as a **child** of a `MenuItem` for a trailing
|
|
319
319
|
counter or badge. Children render after the label but before the `kbd` hint and
|
|
@@ -356,6 +356,8 @@ navigating links.
|
|
|
356
356
|
|
|
357
357
|
| Prop | Type | Default | Description |
|
|
358
358
|
|------|------|---------|-------------|
|
|
359
|
+
| `children?` | ReactNode | — | Item content. With `label` set, children are extra content — most
|
|
360
|
+
notably the nested `<Menu>` for a submenu parent. |
|
|
359
361
|
| `copy?` | string | — | Text copied to the clipboard on activation. |
|
|
360
362
|
| `copyNode?` | boolean \| string | — | Copy a DOM node as rich text (`text/html`) + plain text. `true` copies
|
|
361
363
|
the nearest ancestor marked `data-copy-source`; a string is a CSS
|
|
@@ -363,11 +365,73 @@ navigating links.
|
|
|
363
365
|
from the copied output. |
|
|
364
366
|
| `copyUrl?` | true | — | Copy the current page URL (`location.href`). |
|
|
365
367
|
| `copyWithUrl?` | boolean | — | Prefix the copied text with `// URL: <current page URL>`. |
|
|
368
|
+
| `disabled?` | boolean | — | Disable the item: greyed out, not focusable for activation, no close. A
|
|
369
|
+
disabled link also drops its `href`, so it can't navigate. |
|
|
370
|
+
| `hint?` | ReactNode | — | Secondary text under the label — explanatory copy, like `RadioGroup`'s
|
|
371
|
+
option `hint`. Requires `label` (it stacks in a column beneath it). Muted
|
|
372
|
+
(`--text-3`) and tracks the row's `tone`. A string, or any node. |
|
|
373
|
+
| `icon?` | IconShape | — | Leading icon shape. |
|
|
374
|
+
| `iconTrailing?` | IconShape | — | A trailing icon. On a `submenu` item this **overrides** the default
|
|
375
|
+
chevron (omit it to keep the chevron); on a normal item it's the trailing
|
|
376
|
+
glyph (omit for none). |
|
|
377
|
+
| `indeterminate?` | boolean | — | Only meaningful with `selectionIndicator="checkbox"`: render the box in the
|
|
378
|
+
mixed state (`aria-checked="mixed"`) — e.g. a "Select all" row when some but
|
|
379
|
+
not all of its options are selected. |
|
|
380
|
+
| `indicator?` | React.ReactNode | — | Replace the built-in selection-indicator *visual* with your own node,
|
|
381
|
+
rendered at the **leading** edge (where the checkbox / radio sit). Pair with
|
|
382
|
+
`selectionIndicator` to keep the semantics — the row stays the control and
|
|
383
|
+
carries `role` + `aria-checked`; only the drawn mark changes. Suppresses the
|
|
384
|
+
built-in checkbox / radio and the trailing `check` glyph. The node is made
|
|
385
|
+
passive (aria-hidden, no pointer events) so the row receives the click. |
|
|
386
|
+
| `kbd?` | string | — | A trailing keyboard-shortcut hint, e.g. `"⌘E"`. |
|
|
387
|
+
| `label?` | ReactNode | — | The item's text. Usually a string, but any node is accepted — e.g. a filtered
|
|
388
|
+
`Select` bolds the matched substring. Omit and pass `children` for richer
|
|
389
|
+
content. |
|
|
366
390
|
| `onCopied?` | (ok) => void | — | Fires after the copy attempt with whether it succeeded. |
|
|
367
391
|
| `onCopyRequest?` | () => void | — | Compute the copy content lazily. Fires on pointerdown / keydown; update
|
|
368
392
|
`copy` (a state change) here and the activation copies the latest value.
|
|
369
393
|
The gap lets the update land even off the UI thread — only the
|
|
370
394
|
serializable `copy` string crosses. |
|
|
395
|
+
| `onMouseDown?` | (event) => void | — | Raw `mousedown` on the row. Mainly to `preventDefault()` so the row doesn't
|
|
396
|
+
take focus on a mouse press — e.g. a combobox option keeping focus in its
|
|
397
|
+
input field while the click still selects. |
|
|
398
|
+
| `onSelect?` | (event, detail) => void | — | Activation handler — fires when *this* item is chosen (click / Enter /
|
|
399
|
+
Space), unless it's `disabled`. It does **not** fire for a submenu parent
|
|
400
|
+
(clicking that opens the flyout, which isn't a selection) nor for a
|
|
401
|
+
selection bubbling up from a nested submenu. On a link item it fires
|
|
402
|
+
alongside the navigation. Receives the event plus a `{ value, label }`
|
|
403
|
+
detail. |
|
|
404
|
+
| `role?` | string | — | ARIA role override. Defaults to the role implied by `selectionIndicator`
|
|
405
|
+
(`menuitem` / `menuitemcheckbox` / `menuitemradio`); set it to reparent the
|
|
406
|
+
row under a different container role — e.g. `option` inside a `listbox`. |
|
|
407
|
+
| `selected?` | boolean | — | Mark the item as selected. On a plain row (no `selectionIndicator`) this is
|
|
408
|
+
a persistent background tint, the same resting fill a pressed row shows —
|
|
409
|
+
also the way to flag the current page on a link item. On a checkable row
|
|
410
|
+
(`selectionIndicator` set) it instead drives the leading `checkbox` / `radio`
|
|
411
|
+
indicator and the row's `aria-checked`. |
|
|
412
|
+
| `selectionIndicator?` | 'checkbox' \| 'radio' \| 'check' | — | Turn the row into a checkable item, driven by `selected` (the row stays the
|
|
413
|
+
control and carries `aria-checked`):
|
|
414
|
+
- `'checkbox'` → `role="menuitemcheckbox"`, a leading passive `<a-checkbox>`
|
|
415
|
+
(before `icon`); the tint is dropped (the box carries state).
|
|
416
|
+
- `'radio'` → `role="menuitemradio"`, a leading passive `<a-radio>`; tint dropped.
|
|
417
|
+
- `'check'` → `role="menuitemradio"`, a trailing check glyph on the selected
|
|
418
|
+
row *and* the background tint (the canonical single-select look).
|
|
419
|
+
Omit for a plain row (the default). |
|
|
420
|
+
| `submenu?` | boolean | — | Marks this item as a submenu parent: adds the trailing chevron and
|
|
421
|
+
`aria-haspopup="menu"`. Nest the flyout as a `<Menu>` child. |
|
|
422
|
+
| `tone?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | neutral | Semantic tone — colors the label, icon, and hover/selected tint (and the
|
|
423
|
+
`checkbox`/`radio` indicator, which adopts it). A named tone, or any literal
|
|
424
|
+
CSS color (`'#ff1493'`, `'rebeccapurple'`) for a one-off custom tone whose
|
|
425
|
+
hue + chroma are kept while the lightness is pinned to match the brand text.
|
|
426
|
+
`critical` is the destructive action; `neutral` (the default) is the standard
|
|
427
|
+
gray. |
|
|
428
|
+
| `toneSelected?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | neutral | Like `tone`, but applied only while the row is `selected` — an unselected row
|
|
429
|
+
stays neutral. The whole selected row (label, icon, tint, and the `checkbox` /
|
|
430
|
+
`radio` indicator) takes the tone. Same value set as `tone`; on a selected row
|
|
431
|
+
`toneSelected` wins over `tone` when both are set. |
|
|
432
|
+
| `value?` | string \| number | — | An opaque value identifying this item, handed back in `onSelect`'s detail
|
|
433
|
+
so a shared handler can tell which row was chosen without a per-item
|
|
434
|
+
closure. |
|
|
371
435
|
|
|
372
436
|
## Keyboard
|
|
373
437
|
|
|
@@ -401,7 +465,7 @@ call `event.preventDefault()` to keep the menu as-is (e.g. block a dismiss).
|
|
|
401
465
|
Controlled, the menu never self-moves — apply `detail.next` to `open` to accept,
|
|
402
466
|
or do nothing to reject. (Submenus are always uncontrolled, regardless of `open`.)
|
|
403
467
|
|
|
404
|
-
Use
|
|
468
|
+
Use the web component directly when you are not using React or Preact and a native control does not fit.
|
|
405
469
|
|
|
406
470
|
Put a focusable trigger immediately before `<a-menu>` and omit `state` for an
|
|
407
471
|
uncontrolled menu. Its light-DOM `<a-menu-item>` rows need their own `tabindex`
|
|
@@ -106,7 +106,7 @@ radius.
|
|
|
106
106
|
| `round?` | boolean \| number \| string | — | Fully-round track (`border-radius: 999px`); the fill is clipped to it. Pass a
|
|
107
107
|
`number` (px) or a CSS length string for a custom radius. |
|
|
108
108
|
| `size?` | 'small' \| 'medium' \| 'large' | medium | Size variant. Scales the track and the default label row together. |
|
|
109
|
-
| `tone?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | 'neutral' |
|
|
109
|
+
| `tone?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | 'neutral' | Color variant, or any literal CSS color for a one-off custom tone (the
|
|
110
110
|
surface / indicator / text are derived from it in oklch). Named tones track
|
|
111
111
|
light/dark automatically. |
|
|
112
112
|
| `value?` | number \| false | — | Current progress value. Omit this prop, or pass `false`, to show
|
|
@@ -171,7 +171,7 @@ a-progress.fancy::part(indicator) {
|
|
|
171
171
|
}
|
|
172
172
|
a-progress.fancy::part(indicator)::after { background: none; } /* hard right edge */
|
|
173
173
|
|
|
174
|
-
/* the percentage / label / hint are light-DOM children —
|
|
174
|
+
/* the percentage / label / hint are light-DOM children — recolor for the bar */
|
|
175
175
|
a-progress.fancy a-progress-number,
|
|
176
176
|
a-progress.fancy a-progress-text { color: #fff; }
|
|
177
177
|
a-progress.fancy a-progress-hint { color: var(--text-2); }
|
package/docs/components/radio.md
CHANGED
|
@@ -5,7 +5,7 @@ A single-select control. `RadioGroup` is the whole component — you pass it an
|
|
|
5
5
|
navigation, and the form value. There's no separate `Radio` component: options
|
|
6
6
|
are data, not markup.
|
|
7
7
|
|
|
8
|
-
## Options, label
|
|
8
|
+
## Options, label, and hint
|
|
9
9
|
|
|
10
10
|
```tsx
|
|
11
11
|
<RadioGroup
|
|
@@ -27,6 +27,10 @@ styled like `Input`'s hint.
|
|
|
27
27
|
The group's own `label` and `hint` form a header **above** the options: the
|
|
28
28
|
`label` first, the `hint` (an instruction for the whole set) directly under it.
|
|
29
29
|
|
|
30
|
+
Each option can also set `className`, `style`, and `data-*`.
|
|
31
|
+
`RadioGroup` forwards them to that option's `<a-radio>` so you can add
|
|
32
|
+
per-option presentation and application metadata.
|
|
33
|
+
|
|
30
34
|
## Tones
|
|
31
35
|
|
|
32
36
|
```tsx
|
|
@@ -42,12 +46,12 @@ The group's own `label` and `hint` form a header **above** the options: the
|
|
|
42
46
|
```
|
|
43
47
|
|
|
44
48
|
Six named tones — `neutral` (default), `brand`, `info`, `success`, `warning`,
|
|
45
|
-
`critical`. `tone`
|
|
49
|
+
`critical`. `tone` colors the **mark** in every state — the selected-ring fill + dot
|
|
46
50
|
and (for a tinted tone) the unselected ring border (a light shade of the fill that
|
|
47
51
|
darkens on hover and active; `neutral` keeps a grey ring). The label and hint stay
|
|
48
|
-
neutral —
|
|
49
|
-
the `RadioGroup` to
|
|
50
|
-
one. Any literal CSS
|
|
52
|
+
neutral — color them in plain CSS with the `--text-N-{tone}` tokens. Set `tone` on
|
|
53
|
+
the `RadioGroup` to color every option, or on a single option to override just that
|
|
54
|
+
one. Any literal CSS color works too, for a one-off custom tone.
|
|
51
55
|
|
|
52
56
|
## Selected-only tone
|
|
53
57
|
|
|
@@ -67,7 +71,7 @@ neutral grey. Reach for it instead of `tone` when a resting tinted border would
|
|
|
67
71
|
as a validation error. Same tone set; set it on the group, or on a single option to
|
|
68
72
|
override one.
|
|
69
73
|
|
|
70
|
-
To
|
|
74
|
+
To color the **label and hint**, there's no prop — add a `color` rule on the
|
|
71
75
|
option's `a-radio-label` / `a-radio-hint` with a `--text-N-{tone}` value.
|
|
72
76
|
|
|
73
77
|
## Size
|
|
@@ -89,7 +93,7 @@ Three sizes scale the control circle **and** the label + hint type together:
|
|
|
89
93
|
`large` (18px / 17px). Set it on the `RadioGroup`, or on a single option to
|
|
90
94
|
override one.
|
|
91
95
|
|
|
92
|
-
## Orientation
|
|
96
|
+
## Orientation and layout
|
|
93
97
|
|
|
94
98
|
```tsx
|
|
95
99
|
<RadioGroup
|
|
@@ -145,11 +149,11 @@ navigation and dropped from the tab order.
|
|
|
145
149
|
/>
|
|
146
150
|
```
|
|
147
151
|
|
|
148
|
-
`status`
|
|
152
|
+
`status` recolors the group `hint` for feedback — the same tone set as
|
|
149
153
|
[`Input`](./input.md): `critical`, `warning`, `success`, `info`, `brand`
|
|
150
154
|
(omit for neutral). It styles the message only; drive it from your own validation.
|
|
151
155
|
|
|
152
|
-
## Keyboard
|
|
156
|
+
## Keyboard and accessibility
|
|
153
157
|
|
|
154
158
|
The group is one Tab stop: `Tab` moves into the selected option (or the first
|
|
155
159
|
enabled one), the arrow keys (`↑`/`↓`/`←`/`→`) move the selection between enabled
|
|
@@ -250,8 +254,7 @@ element — `Input`, and the composed `Select` — skip it and expose only
|
|
|
250
254
|
|------|------|---------|-------------|
|
|
251
255
|
| `options` | RadioOption[] | — | The options. The wrapper renders one `<a-radio>` per entry and computes its
|
|
252
256
|
`selected` / roving `tabindex` / `role` declaratively. |
|
|
253
|
-
| `defaultValue?` | string | — | Initial selected value for
|
|
254
|
-
selection in local state). |
|
|
257
|
+
| `defaultValue?` | string | — | Initial selected value for uncontrolled use. |
|
|
255
258
|
| `disabled?` | boolean | — | Disable the whole group. |
|
|
256
259
|
| `hint?` | string | — | Plain-text description for the group, rendered directly under `label` (above
|
|
257
260
|
the options) — typically instructional copy. Per-option helper text goes on
|
|
@@ -272,27 +275,27 @@ element — `Input`, and the composed `Select` — skip it and expose only
|
|
|
272
275
|
(uncontrolled), or in controlled mode answer by updating `value` (reject by
|
|
273
276
|
doing nothing). `'reset'` (form reset) and `'restore'` (bfcache / autofill) are
|
|
274
277
|
not cancelable — filter on `reason` if you only track user picks. |
|
|
275
|
-
| `onValueChange?` | (event, attrs) => void | — | Like `onChange`, but with a `{ value, name }` snapshot as the
|
|
276
|
-
|
|
278
|
+
| `onValueChange?` | (event, attrs) => void | — | Like `onChange`, but with a `{ value, name }` snapshot as the second argument,
|
|
279
|
+
matching `Input`. |
|
|
277
280
|
| `orientation?` | 'vertical' \| 'horizontal' | 'vertical' | Layout + arrow-key axis. |
|
|
278
281
|
| `size?` | 'small' \| 'medium' \| 'large' | 'medium' | Size applied to every option (an option's own `size` wins). |
|
|
279
|
-
| `status?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' | 'neutral' | Validation/feedback tone for the group `hint` —
|
|
282
|
+
| `status?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' | 'neutral' | Validation/feedback tone for the group `hint` — recolors it (same tone set
|
|
280
283
|
as `Input`'s `status`). Use `critical` for an error message, etc.; omit for
|
|
281
284
|
the neutral default. |
|
|
282
285
|
| `tone?` | 'brand' \| 'neutral' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | 'neutral' | Mark tone applied to every option (an option's own `tone` wins), or any literal
|
|
283
|
-
CSS color for a one-off custom tone.
|
|
286
|
+
CSS color for a one-off custom tone. Colors the selected-ring fill + dot *and*
|
|
284
287
|
the unselected ring border. Named tones track light/dark mode. Use `toneSelected`
|
|
285
288
|
instead to tone only the selected option and leave the rest neutral. The option
|
|
286
|
-
text stays neutral —
|
|
287
|
-
| `toneSelected?` | 'brand' \| 'neutral' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | 'neutral' | Like `tone`, but
|
|
289
|
+
text stays neutral — recolor it in plain CSS via the `--text-N-{tone}` tokens. |
|
|
290
|
+
| `toneSelected?` | 'brand' \| 'neutral' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | 'neutral' | Like `tone`, but colored onto the **selected option only** — every unselected
|
|
288
291
|
ring stays neutral grey. Applied to every option (an option's own `toneSelected`
|
|
289
292
|
wins). Prefer this over `tone` when a resting tinted border would read as a
|
|
290
293
|
validation state. |
|
|
291
|
-
| `value?` | string | — | Controlled selected value.
|
|
292
|
-
|
|
293
|
-
|
|
294
|
+
| `value?` | string | — | Controlled selected value. The group follows this prop and reports a
|
|
295
|
+
requested change through `onStateChange`. Leave it undefined for
|
|
296
|
+
uncontrolled use. |
|
|
294
297
|
|
|
295
|
-
Use
|
|
298
|
+
Use the web component directly when you are not using React or Preact and a native control does not fit.
|
|
296
299
|
|
|
297
300
|
The group owns selection and the single tab stop. Put options in `<a-radio-list>`.
|
|
298
301
|
|
|
@@ -323,8 +326,8 @@ treatments.
|
|
|
323
326
|
</div>
|
|
324
327
|
```
|
|
325
328
|
|
|
326
|
-
Reach for the props first: **`tone`**
|
|
327
|
-
**`toneSelected`** only the selected option (any CSS
|
|
329
|
+
Reach for the props first: **`tone`** colors the mark in every state,
|
|
330
|
+
**`toneSelected`** only the selected option (any CSS color for a custom tone, set on
|
|
328
331
|
the group or a single option — derives the full curve in oklch), **`size`** the
|
|
329
332
|
dimensions + type. To tint the label + hint, add a `color` rule on the option's
|
|
330
333
|
`a-radio-label` / `a-radio-hint` with the `--text-N-{tone}` values — there's no
|
|
@@ -343,7 +346,7 @@ masked — same heart as the checkbox):
|
|
|
343
346
|
|
|
344
347
|
```css
|
|
345
348
|
/* Outlined — an unfilled selected ring: keep the ring background and paint the
|
|
346
|
-
border + dot in the tone
|
|
349
|
+
border + dot in the tone color (light-dark() tunes both themes at once). */
|
|
347
350
|
a-radio-group.outlined a-radio:state(selected)::before {
|
|
348
351
|
background: var(--radio-bg);
|
|
349
352
|
border-color: light-dark(#5f4bc3, #7460d7);
|
|
@@ -357,7 +360,7 @@ a-radio-group.square a-radio:state(selected)::before { background: light-dark(#0
|
|
|
357
360
|
a-radio-group.square a-radio:state(selected)::after { background: light-dark(#fff, #000); } /* contrasting dot */
|
|
358
361
|
|
|
359
362
|
/* Heart — a bigger ring with a heart mark (the dot ::after, masked) on a pink fill.
|
|
360
|
-
Same heart SVG as the checkbox; mask-size: contain
|
|
363
|
+
Same heart SVG as the checkbox; mask-size: contain centers it in the bigger ring. */
|
|
361
364
|
a-radio-group.heart a-radio::before { inline-size: 22px; block-size: 22px; } /* bigger ring */
|
|
362
365
|
a-radio-group.heart a-radio::after {
|
|
363
366
|
inline-size: 13px; block-size: 13px; border-radius: 0;
|