@ac-kit/ui-common 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +210 -0
- package/README.md +383 -9
- package/dist/adapter/_anchor.d.ts +13 -0
- package/dist/adapter/_anchor.d.ts.map +1 -0
- package/dist/adapter/_anchor.js +39 -0
- package/dist/adapter/_anchor.js.map +1 -0
- package/dist/adapter/_dom.d.ts +14 -0
- package/dist/adapter/_dom.d.ts.map +1 -0
- package/dist/adapter/_dom.js +31 -0
- package/dist/adapter/_dom.js.map +1 -0
- package/dist/adapter/_live-announcer.d.ts +26 -0
- package/dist/adapter/_live-announcer.d.ts.map +1 -0
- package/dist/adapter/_live-announcer.js +101 -0
- package/dist/adapter/_live-announcer.js.map +1 -0
- package/dist/adapter/join-classes.d.ts.map +1 -0
- package/dist/adapter/join-classes.js.map +1 -0
- package/dist/anchored/anchored.d.ts +19 -0
- package/dist/anchored/anchored.d.ts.map +1 -0
- package/dist/anchored/anchored.js +2 -0
- package/dist/anchored/anchored.js.map +1 -0
- package/dist/bit-grid/bit-grid.d.ts +151 -0
- package/dist/bit-grid/bit-grid.d.ts.map +1 -0
- package/dist/bit-grid/bit-grid.js +201 -0
- package/dist/bit-grid/bit-grid.js.map +1 -0
- package/dist/focus/typeahead.d.ts +112 -0
- package/dist/focus/typeahead.d.ts.map +1 -0
- package/dist/focus/typeahead.js +178 -0
- package/dist/focus/typeahead.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/menu/menu.d.ts +157 -0
- package/dist/menu/menu.d.ts.map +1 -0
- package/dist/menu/menu.js +162 -0
- package/dist/menu/menu.js.map +1 -0
- package/dist/preact/bit-grid.d.ts +39 -0
- package/dist/preact/bit-grid.d.ts.map +1 -0
- package/dist/preact/bit-grid.js +72 -0
- package/dist/preact/bit-grid.js.map +1 -0
- package/dist/preact/button.d.ts.map +1 -1
- package/dist/preact/button.js +1 -1
- package/dist/preact/button.js.map +1 -1
- package/dist/preact/dialog.d.ts.map +1 -1
- package/dist/preact/dialog.js +1 -1
- package/dist/preact/dialog.js.map +1 -1
- package/dist/preact/index.d.ts +10 -1
- package/dist/preact/index.d.ts.map +1 -1
- package/dist/preact/index.js +10 -1
- package/dist/preact/index.js.map +1 -1
- package/dist/preact/knob.d.ts.map +1 -1
- package/dist/preact/knob.js +6 -14
- package/dist/preact/knob.js.map +1 -1
- package/dist/preact/menu-button.d.ts +117 -0
- package/dist/preact/menu-button.d.ts.map +1 -0
- package/dist/preact/menu-button.js +330 -0
- package/dist/preact/menu-button.js.map +1 -0
- package/dist/preact/meter.d.ts.map +1 -1
- package/dist/preact/meter.js +1 -1
- package/dist/preact/meter.js.map +1 -1
- package/dist/preact/progress-ring.d.ts +42 -0
- package/dist/preact/progress-ring.d.ts.map +1 -0
- package/dist/preact/progress-ring.js +26 -0
- package/dist/preact/progress-ring.js.map +1 -0
- package/dist/preact/radio-group.d.ts.map +1 -1
- package/dist/preact/radio-group.js +1 -1
- package/dist/preact/radio-group.js.map +1 -1
- package/dist/preact/readout.d.ts.map +1 -1
- package/dist/preact/readout.js +1 -1
- package/dist/preact/readout.js.map +1 -1
- package/dist/preact/slider.d.ts.map +1 -1
- package/dist/preact/slider.js +7 -5
- package/dist/preact/slider.js.map +1 -1
- package/dist/preact/spin-button.d.ts +67 -0
- package/dist/preact/spin-button.d.ts.map +1 -0
- package/dist/preact/spin-button.js +132 -0
- package/dist/preact/spin-button.js.map +1 -0
- package/dist/preact/swatch-strip.d.ts +30 -0
- package/dist/preact/swatch-strip.d.ts.map +1 -0
- package/dist/preact/swatch-strip.js +17 -0
- package/dist/preact/swatch-strip.js.map +1 -0
- package/dist/preact/switch.js +1 -1
- package/dist/preact/switch.js.map +1 -1
- package/dist/preact/tabs.d.ts +97 -0
- package/dist/preact/tabs.d.ts.map +1 -0
- package/dist/preact/tabs.js +264 -0
- package/dist/preact/tabs.js.map +1 -0
- package/dist/preact/toaster.d.ts +43 -0
- package/dist/preact/toaster.d.ts.map +1 -0
- package/dist/preact/toaster.js +356 -0
- package/dist/preact/toaster.js.map +1 -0
- package/dist/preact/toggle-button.d.ts.map +1 -1
- package/dist/preact/toggle-button.js +1 -1
- package/dist/preact/toggle-button.js.map +1 -1
- package/dist/preact/toolbar.d.ts.map +1 -1
- package/dist/preact/toolbar.js +3 -9
- package/dist/preact/toolbar.js.map +1 -1
- package/dist/preact/tooltip.d.ts +67 -0
- package/dist/preact/tooltip.d.ts.map +1 -0
- package/dist/preact/tooltip.js +165 -0
- package/dist/preact/tooltip.js.map +1 -0
- package/dist/preact/tree.d.ts +93 -0
- package/dist/preact/tree.d.ts.map +1 -0
- package/dist/preact/tree.js +399 -0
- package/dist/preact/tree.js.map +1 -0
- package/dist/progress/progress.d.ts +51 -0
- package/dist/progress/progress.d.ts.map +1 -0
- package/dist/progress/progress.js +43 -0
- package/dist/progress/progress.js.map +1 -0
- package/dist/react/_props.d.ts +22 -0
- package/dist/react/_props.d.ts.map +1 -0
- package/dist/react/_props.js +14 -0
- package/dist/react/_props.js.map +1 -0
- package/dist/react/bit-grid.d.ts +40 -0
- package/dist/react/bit-grid.d.ts.map +1 -0
- package/dist/react/bit-grid.js +71 -0
- package/dist/react/bit-grid.js.map +1 -0
- package/dist/react/button.d.ts +60 -0
- package/dist/react/button.d.ts.map +1 -0
- package/dist/react/button.js +34 -0
- package/dist/react/button.js.map +1 -0
- package/dist/react/dialog.d.ts +44 -0
- package/dist/react/dialog.d.ts.map +1 -0
- package/dist/react/dialog.js +91 -0
- package/dist/react/dialog.js.map +1 -0
- package/dist/react/index.d.ts +22 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +22 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/knob.d.ts +55 -0
- package/dist/react/knob.d.ts.map +1 -0
- package/dist/react/knob.js +144 -0
- package/dist/react/knob.js.map +1 -0
- package/dist/react/menu-button.d.ts +147 -0
- package/dist/react/menu-button.d.ts.map +1 -0
- package/dist/react/menu-button.js +342 -0
- package/dist/react/menu-button.js.map +1 -0
- package/dist/react/meter.d.ts +34 -0
- package/dist/react/meter.d.ts.map +1 -0
- package/dist/react/meter.js +23 -0
- package/dist/react/meter.js.map +1 -0
- package/dist/react/progress-ring.d.ts +42 -0
- package/dist/react/progress-ring.d.ts.map +1 -0
- package/dist/react/progress-ring.js +28 -0
- package/dist/react/progress-ring.js.map +1 -0
- package/dist/react/radio-group.d.ts +52 -0
- package/dist/react/radio-group.d.ts.map +1 -0
- package/dist/react/radio-group.js +30 -0
- package/dist/react/radio-group.js.map +1 -0
- package/dist/react/readout.d.ts +23 -0
- package/dist/react/readout.d.ts.map +1 -0
- package/dist/react/readout.js +13 -0
- package/dist/react/readout.js.map +1 -0
- package/dist/react/slider.d.ts +44 -0
- package/dist/react/slider.d.ts.map +1 -0
- package/dist/react/slider.js +167 -0
- package/dist/react/slider.js.map +1 -0
- package/dist/react/spin-button.d.ts +71 -0
- package/dist/react/spin-button.d.ts.map +1 -0
- package/dist/react/spin-button.js +132 -0
- package/dist/react/spin-button.js.map +1 -0
- package/dist/react/swatch-strip.d.ts +31 -0
- package/dist/react/swatch-strip.d.ts.map +1 -0
- package/dist/react/swatch-strip.js +17 -0
- package/dist/react/swatch-strip.js.map +1 -0
- package/dist/react/switch.d.ts +26 -0
- package/dist/react/switch.d.ts.map +1 -0
- package/dist/react/switch.js +19 -0
- package/dist/react/switch.js.map +1 -0
- package/dist/react/tabs.d.ts +95 -0
- package/dist/react/tabs.d.ts.map +1 -0
- package/dist/react/tabs.js +274 -0
- package/dist/react/tabs.js.map +1 -0
- package/dist/react/toaster.d.ts +43 -0
- package/dist/react/toaster.d.ts.map +1 -0
- package/dist/react/toaster.js +368 -0
- package/dist/react/toaster.js.map +1 -0
- package/dist/react/toggle-button.d.ts +37 -0
- package/dist/react/toggle-button.d.ts.map +1 -0
- package/dist/react/toggle-button.js +22 -0
- package/dist/react/toggle-button.js.map +1 -0
- package/dist/react/toolbar.d.ts +25 -0
- package/dist/react/toolbar.d.ts.map +1 -0
- package/dist/react/toolbar.js +143 -0
- package/dist/react/toolbar.js.map +1 -0
- package/dist/react/tooltip.d.ts +68 -0
- package/dist/react/tooltip.d.ts.map +1 -0
- package/dist/react/tooltip.js +165 -0
- package/dist/react/tooltip.js.map +1 -0
- package/dist/react/tree.d.ts +94 -0
- package/dist/react/tree.d.ts.map +1 -0
- package/dist/react/tree.js +422 -0
- package/dist/react/tree.js.map +1 -0
- package/dist/react/use-element-binding.d.ts +35 -0
- package/dist/react/use-element-binding.d.ts.map +1 -0
- package/dist/react/use-element-binding.js +51 -0
- package/dist/react/use-element-binding.js.map +1 -0
- package/dist/spin-button/spin-button.d.ts +110 -0
- package/dist/spin-button/spin-button.d.ts.map +1 -0
- package/dist/spin-button/spin-button.js +179 -0
- package/dist/spin-button/spin-button.js.map +1 -0
- package/dist/swatch-strip/swatch-strip.d.ts +60 -0
- package/dist/swatch-strip/swatch-strip.d.ts.map +1 -0
- package/dist/swatch-strip/swatch-strip.js +60 -0
- package/dist/swatch-strip/swatch-strip.js.map +1 -0
- package/dist/tabs/tabs.d.ts +157 -0
- package/dist/tabs/tabs.d.ts.map +1 -0
- package/dist/tabs/tabs.js +120 -0
- package/dist/tabs/tabs.js.map +1 -0
- package/dist/toast/toast-queue.d.ts +212 -0
- package/dist/toast/toast-queue.d.ts.map +1 -0
- package/dist/toast/toast-queue.js +290 -0
- package/dist/toast/toast-queue.js.map +1 -0
- package/dist/toast/toasts-obscure.d.ts +25 -0
- package/dist/toast/toasts-obscure.d.ts.map +1 -0
- package/dist/toast/toasts-obscure.js +30 -0
- package/dist/toast/toasts-obscure.js.map +1 -0
- package/dist/tooltip/tooltip.d.ts +183 -0
- package/dist/tooltip/tooltip.d.ts.map +1 -0
- package/dist/tooltip/tooltip.js +185 -0
- package/dist/tooltip/tooltip.js.map +1 -0
- package/dist/tree/tree.d.ts +302 -0
- package/dist/tree/tree.d.ts.map +1 -0
- package/dist/tree/tree.js +439 -0
- package/dist/tree/tree.js.map +1 -0
- package/package.json +47 -14
- package/styles.css +1084 -3
- package/dist/preact/join-classes.d.ts.map +0 -1
- package/dist/preact/join-classes.js.map +0 -1
- /package/dist/{preact → adapter}/join-classes.d.ts +0 -0
- /package/dist/{preact → adapter}/join-classes.js +0 -0
package/README.md
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Generic controls for the browser, touch first: a knob turned by dragging up
|
|
4
4
|
and down, a slider, a toggle button, a hardware-style readout, a level meter,
|
|
5
|
-
a switch, a radio group, buttons, a toolbar with roving focus
|
|
6
|
-
dialog
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
a switch, a radio group, buttons, a toolbar with roving focus, a modal
|
|
6
|
+
dialog, a menu button, a tooltip, toasts, tabs, a progress ring, a spin
|
|
7
|
+
button and a tree view, and two displays: a bit grid and a swatch strip. Each
|
|
8
|
+
one is a headless core — its
|
|
9
|
+
state and behaviour as plain functions and data, with no framework and no
|
|
10
|
+
DOM — and a component per framework over it, styled only through CSS custom
|
|
11
|
+
properties.
|
|
9
12
|
|
|
10
13
|
```tsx
|
|
11
14
|
import { Knob } from "@ac-kit/ui-common/preact";
|
|
@@ -64,10 +67,76 @@ tests anywhere. Every function is pure and every time is passed in.
|
|
|
64
67
|
arrow key, Home or End moves to, skipping disabled ones, wrapping or not,
|
|
65
68
|
mirrored in a right-to-left direction; `ownsArrowKeys` says whether an
|
|
66
69
|
element (its tag, input type, role, editable content) uses the arrow keys
|
|
67
|
-
itself, so a container leaves them to it.
|
|
70
|
+
itself, so a container leaves them to it. `Typeahead` gathers the characters
|
|
71
|
+
typed within 500 ms of each other, and `typeaheadIndex(labels, current,
|
|
72
|
+
query)` gives the item they reach: the next one starting with a character
|
|
73
|
+
typed alone or repeated, else the first from the current one starting with
|
|
74
|
+
the query, compared grapheme by grapheme as the locale's collation does,
|
|
75
|
+
ignoring case and accents; `isTypeaheadKey` tells a typed character from a
|
|
76
|
+
named key or a shortcut, and `typeaheadCharacter` the character a key adds
|
|
77
|
+
to a query (Space only while one is in progress); `Typeahead.find` types a
|
|
78
|
+
character and returns the item reached, in one call.
|
|
79
|
+
- **Menu.** `menuButtonAttributes` (`aria-haspopup`, `aria-expanded`,
|
|
80
|
+
`aria-controls`), `menuAttributes` (the `menu` role, named by its button,
|
|
81
|
+
with its side and alignment), `menuItemAttributes` (`menuitem`,
|
|
82
|
+
`menuitemcheckbox` or `menuitemradio`, checked, disabled but focusable);
|
|
83
|
+
`menuButtonKeyAction` (the item Enter, Space or an arrow opens the menu on)
|
|
84
|
+
and `menuKeyAction` (what a key does in an open menu: focus an item,
|
|
85
|
+
activate it, closing or not, close, leave with Tab, or type ahead).
|
|
86
|
+
- **Tooltip.** `tooltipAttributes`, `tooltipTriggerAttributes` (described or
|
|
87
|
+
named by the tooltip); `tooltipStep(state, input, time)`, the reducer of a
|
|
88
|
+
tooltip's visibility from hover, keyboard focus, presses, Escape and time,
|
|
89
|
+
with its show and hide delays and WCAG 1.4.13's rules; `TooltipGroup`, the
|
|
90
|
+
tooltips that show one at a time, the next without its delay.
|
|
91
|
+
- **Toasts.** `ToastQueue`: toasts shown a few at a time (`limit`), each until
|
|
92
|
+
its duration has run on a clock that only visible toasts run and pause
|
|
93
|
+
reasons stop, updated in place by id, a toast with an action kept until
|
|
94
|
+
dismissed; `toasterAttributes` (a named region), `toastAttributes`,
|
|
95
|
+
`toastAnnouncement` (the lines a screen reader hears); `toastsObscure`
|
|
96
|
+
(whether toasts cover part of the focused control, from its box and
|
|
97
|
+
theirs).
|
|
98
|
+
- **Anchored popovers.** `AnchoredSide` (`block-start`, `block-end`,
|
|
99
|
+
`inline-start`, `inline-end`) and `AnchoredAlign` (`start`, `center`,
|
|
100
|
+
`end`), the logical placement of a menu or tooltip against its trigger.
|
|
68
101
|
- **Meter.** `meterAttributes` — the `meter` role with its range and a value
|
|
69
102
|
kept inside it; `meterLitCount` maps a level to the lit segments of a scale
|
|
70
103
|
of `MeterSegment`s (a threshold and a tone each), in O(log n).
|
|
104
|
+
- **Bit grid.** `bitGridCells` — bytes as cells of bits (most or least
|
|
105
|
+
significant first) or hex bytes, each marked `changed` against a reference
|
|
106
|
+
and with the named field (`BitGridField`, a byte range) that holds it, in
|
|
107
|
+
O(n); `bitGridCellLabel`, what a screen reader says for a cell;
|
|
108
|
+
`bitGridKeyIndex`, the WAI-ARIA grid key map (arrows without wrapping,
|
|
109
|
+
Home and End, with Control the grid's ends); `bitGridAttributes`, the
|
|
110
|
+
`grid` role, read-only unless a cell can be activated.
|
|
111
|
+
- **Swatch strip.** `swatchStripGradient` — the CSS `linear-gradient()` of a
|
|
112
|
+
row of colours, with hard stops so the browser blends nothing, or blended in
|
|
113
|
+
a named colour space; `swatchStripItemLabel` and `swatchStripSummary`, the
|
|
114
|
+
names a screen reader reads for a swatch and for a whole gradient.
|
|
115
|
+
- **Tabs.** `tabListAttributes` (the `tablist` role, named,
|
|
116
|
+
`aria-orientation` when vertical), `tabAttributes` (`aria-selected`,
|
|
117
|
+
`aria-controls`, one tab stop, disabled but focusable),
|
|
118
|
+
`tabPanelAttributes` (named by its tab, a tab stop only when nothing inside
|
|
119
|
+
it is); `tabsKeyAction` (what a key does on a tab: focus another, going
|
|
120
|
+
round and mirrored right to left, selecting it when activation is
|
|
121
|
+
`automatic`; select on Enter or Space when `manual`; delete on Delete).
|
|
122
|
+
- **Progress.** `progressAttributes` — the `progressbar` role, from 0 to 100
|
|
123
|
+
by default, its value clamped, absent while indeterminate.
|
|
124
|
+
- **Spin button.** `SpinButtonRange` (`step`, and `min` and `max` when it has
|
|
125
|
+
them), `snapSpinButtonValue` (the nearest step, kept within the bounds;
|
|
126
|
+
`snapSliderValue` with both), `spinButtonValue` (the spin button keys:
|
|
127
|
+
Arrow Up and Down, Page Up and Down by ten steps, Home and End to the bounds
|
|
128
|
+
it has; `steppedValue` with both, Arrow Left and Right left to the caret),
|
|
129
|
+
`spinButtonAttributes` (the `spinbutton` role with the bounds it has).
|
|
130
|
+
- **Tree view.** `TreeSource` (roots, `childrenOf`, `isBranch` for lazy
|
|
131
|
+
children), `visibleTreeRows(source, isExpanded)` — the rows shown, with
|
|
132
|
+
each one's level, position, set size, parent, expansion and loading, a
|
|
133
|
+
node's row found in O(1), walked without recursion by `@ac-kit/algo`'s
|
|
134
|
+
`walkTree`; `treeKeyAction` (the WAI-ARIA tree view keys: move, expand,
|
|
135
|
+
collapse, `*`, Enter, Space, the multiple-selection keys, typeahead, mirrored
|
|
136
|
+
right to left), `nextTreeSelection` (replace, flip, a range, all or none,
|
|
137
|
+
never a disabled node), `expandTreeSiblings`, `treePath` and `treeTabStop`
|
|
138
|
+
(the focused row, else its nearest ancestor shown, else the first selected,
|
|
139
|
+
else the first), `treeAttributes` and `treeItemAttributes`.
|
|
71
140
|
- `ControlTone`, the colour role every lit control takes.
|
|
72
141
|
|
|
73
142
|
```ts
|
|
@@ -94,7 +163,20 @@ peer dependency: install the one you use, and nothing else is pulled in.
|
|
|
94
163
|
|
|
95
164
|
| subpath | framework | components |
|
|
96
165
|
| -------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
97
|
-
| `@ac-kit/ui-common/preact` | Preact 11 | `Knob`, `Slider`, `ToggleButton`, `Readout`, `Meter`, `Switch`, `RadioGroup`, `Button`, `IconButton`, `Toolbar`, `Dialog` |
|
|
166
|
+
| `@ac-kit/ui-common/preact` | Preact 11 | `Knob`, `Slider`, `ToggleButton`, `Readout`, `Meter`, `Switch`, `RadioGroup`, `Button`, `IconButton`, `Toolbar`, `Dialog`, `MenuButton` (with `MenuItem`, `MenuItemCheckbox`, `MenuItemRadio`, `MenuGroup`, `MenuSeparator`), `Tooltip`, `Toaster`, `Tabs` (with `TabList`, `Tab`, `TabPanel`), `ProgressRing`, `SpinButton`, `Tree`, `BitGrid`, `SwatchStrip` |
|
|
167
|
+
| `@ac-kit/ui-common/react` | React 18 and 19, with `react-dom` | the same components, props and anatomy |
|
|
168
|
+
|
|
169
|
+
Both subpaths also export `useElementBinding`, `useLatest` and `joinClasses`
|
|
170
|
+
for components of your own.
|
|
171
|
+
|
|
172
|
+
The React components take the Preact ones' props, `className` beside `class`
|
|
173
|
+
(both are added after the control's own classes), and render the same
|
|
174
|
+
classes, `data-*` and ARIA attributes. `onChange` keeps the meaning it has
|
|
175
|
+
here — once per gesture, a key or a committed entry — not React's form-field
|
|
176
|
+
one of every input; `onInput` follows a drag. `Button`, `IconButton`,
|
|
177
|
+
`ToggleButton` and `MenuButton` pass a `ref` to their button under React 18
|
|
178
|
+
too. Under `StrictMode`, a gesture binding is disposed and made again with its
|
|
179
|
+
element, as any effect is.
|
|
98
180
|
|
|
99
181
|
Every component is controlled: it shows `value` (or `isOn`) and reports what
|
|
100
182
|
the person asks for through a callback, typed with `@ac-kit/core`'s
|
|
@@ -112,6 +194,14 @@ the person asks for through a callback, typed with `@ac-kit/core`'s
|
|
|
112
194
|
changes.
|
|
113
195
|
- `Meter` — `value`, `min`, `max` (finite), a `label`, optional `segments` and
|
|
114
196
|
`valueText`; read-only.
|
|
197
|
+
- `BitGrid` — `label`, `bytes`, `unit` (`bit` or `byte`), `bitOrder`,
|
|
198
|
+
`columns`, a `reference` whose differing cells are filled, `fields` (named
|
|
199
|
+
byte ranges, tinted and listed in a legend), `selectedIndex`, and
|
|
200
|
+
`onActivate(index)` for a cell clicked or activated with Enter or Space;
|
|
201
|
+
without `onActivate` it is read-only and still navigable.
|
|
202
|
+
- `SwatchStrip` — `label`, `items` (`color`, optional `label` drawn under the
|
|
203
|
+
swatch and `description` read instead), `appearance` `swatches` (a list) or
|
|
204
|
+
`gradient` (one image, hard stops unless `interpolation` names a space).
|
|
115
205
|
- `Switch` — `label`, optional `description`, `isOn`, `onToggle(nextIsOn)`: a
|
|
116
206
|
setting that applies as it is flipped.
|
|
117
207
|
- `RadioGroup` — `label` (the legend, visually hidden unless `isLabelShown`),
|
|
@@ -132,6 +222,159 @@ the person asks for through a callback, typed with `@ac-kit/core`'s
|
|
|
132
222
|
`closeIcon`, `actions`. A native modal `<dialog>`, no portal. `onClose` is
|
|
133
223
|
asked once when Escape, the close button, a backdrop press or a
|
|
134
224
|
`<form method="dialog">` closes it; set `isOpen` to false in answer.
|
|
225
|
+
- `MenuButton` — `label` (the button's text and the menu's name;
|
|
226
|
+
`isLabelHidden` draws the `icon` alone), `variant`, `size`, `tone`, `side`,
|
|
227
|
+
`align`, `onOpenChange`; its children are the items: `MenuItem`
|
|
228
|
+
(`onSelect`), `MenuItemCheckbox` (`isChecked`, `onCheckedChange`),
|
|
229
|
+
`MenuItemRadio` (`isChecked`, `onSelect`, called only when it was not the
|
|
230
|
+
checked one), each with `icon`, `disabled` and `textValue` (the name
|
|
231
|
+
typeahead matches when the label is not plain text), grouped by `MenuGroup`
|
|
232
|
+
(`label`) and divided by `MenuSeparator`. The menu is a popover the browser
|
|
233
|
+
opens and closes (a press outside it or Escape closes it), so its open
|
|
234
|
+
state is its own and `onOpenChange` reports it. It closes before an item's
|
|
235
|
+
callback runs, focus back on the button, so an item that opens a `Dialog`
|
|
236
|
+
has the button as its opener. Other `<button>` attributes and a `ref` reach
|
|
237
|
+
the button.
|
|
238
|
+
- `Tooltip` — `content`, `relation` (`description`, the default, or `label`
|
|
239
|
+
for an icon-only trigger), `side`, `align`, `showDelayMs` (500),
|
|
240
|
+
`hideDelayMs` (200), `group`; its child is a function rendering the trigger
|
|
241
|
+
with the props it is given (a `ref` and the `aria-describedby` or
|
|
242
|
+
`aria-labelledby` linking it), which works with `Button`, `IconButton`,
|
|
243
|
+
`MenuButton` or any element. Give the trigger no `title`.
|
|
244
|
+
- `Toaster` — `queue` (your `ToastQueue`), `label` (the region's name, which
|
|
245
|
+
may name its shortcut), `closeLabel`, `position` (`top-start` …
|
|
246
|
+
`bottom-end`, default `bottom-end`), `hotkeys` (default `["F8"]`),
|
|
247
|
+
`closeIcon`. Render one per page, outside any dialog, and show toasts from
|
|
248
|
+
anywhere with `queue.show(content, performance.now(), options)`.
|
|
249
|
+
- `Tabs` — `selected` (a tab's `value`), `onSelectedChange(value)`,
|
|
250
|
+
`activation` (`automatic`, the default: a tab shows its panel as the arrows
|
|
251
|
+
reach it; `manual`: on Enter, Space or a click), `orientation`, and
|
|
252
|
+
`onDelete(value)` to let Delete close the focused tab (remove it in answer;
|
|
253
|
+
focus moves to the next tab, and the nearest enabled one is selected when
|
|
254
|
+
it was the selected tab). Its children are a `TabList` (`label` or
|
|
255
|
+
`labelledBy`) of `Tab`s (`value`, `icon`, `disabled`) and a `TabPanel`
|
|
256
|
+
(`value`) per tab. Every panel stays rendered, the hidden ones
|
|
257
|
+
`hidden="until-found"`, so they keep their state and the browser's find in
|
|
258
|
+
page selects the tab of a match.
|
|
259
|
+
- `ProgressRing` — `label` (not drawn) or `labelledBy`, `value` (`undefined`
|
|
260
|
+
while it cannot be told), `min` (0), `max` (100), `valueText`,
|
|
261
|
+
`isValueShown` to draw `valueText` inside, `tone`.
|
|
262
|
+
- `SpinButton` — `label` (`isLabelHidden`), `value`, `min` and `max` (either
|
|
263
|
+
may be omitted), `step` (1), `largeStep`, `format`, `onChange` once per key,
|
|
264
|
+
button press or entry, `decrementLabel` and `incrementLabel` (the buttons'
|
|
265
|
+
names), `decrementIcon`, `incrementIcon`, `disabled`, `tone`. With `parse`
|
|
266
|
+
(text to a number, or `undefined`), the value is also typed: Enter or
|
|
267
|
+
leaving the field commits it snapped, Escape goes back, text that is not a
|
|
268
|
+
number is marked invalid; `inputMode` picks the phone keyboard. For the
|
|
269
|
+
knob sheet's −, + and reset: a `SpinButton` and a `Button`.
|
|
270
|
+
- `Tree` — `label` or `labelledBy`, `roots`, `childrenOf` (a branch's
|
|
271
|
+
children; `undefined` for a leaf or for children not loaded yet),
|
|
272
|
+
`isBranch` (for lazy children), `textValueOf` (the name typeahead matches,
|
|
273
|
+
drawn without `renderItem`), `renderItem(node, state)`, `expanded` and
|
|
274
|
+
`onExpandedChange`, `selectionMode` (`single`, `multiple` or `none`),
|
|
275
|
+
`selected` and `onSelectedChange`, `selectionFollowsFocus`,
|
|
276
|
+
`onActivate(node)` (Enter and a click), `isDisabled`. Nodes are compared by
|
|
277
|
+
identity. Keep `childrenOf`, `isBranch`, `textValueOf` and `renderItem`
|
|
278
|
+
stable (module functions or `useCallback`): the rows are recomputed when
|
|
279
|
+
`roots`, `expanded`, `childrenOf` or `isBranch` change, and a row is drawn
|
|
280
|
+
again only when its own state changes, so a key costs one to two
|
|
281
|
+
milliseconds on 2 000 rows in current browsers. A click on a row's mark, or
|
|
282
|
+
a double click on a branch, expands or collapses it.
|
|
283
|
+
|
|
284
|
+
```tsx
|
|
285
|
+
import { ToastQueue } from "@ac-kit/ui-common";
|
|
286
|
+
import {
|
|
287
|
+
IconButton,
|
|
288
|
+
MenuButton,
|
|
289
|
+
MenuItem,
|
|
290
|
+
MenuItemCheckbox,
|
|
291
|
+
Toaster,
|
|
292
|
+
Tooltip,
|
|
293
|
+
} from "@ac-kit/ui-common/preact";
|
|
294
|
+
|
|
295
|
+
const toasts = new ToastQueue();
|
|
296
|
+
|
|
297
|
+
<>
|
|
298
|
+
<MenuButton label="Score">
|
|
299
|
+
<MenuItem onSelect={openRenameDialog}>Rename…</MenuItem>
|
|
300
|
+
<MenuItemCheckbox isChecked={isLooping} onCheckedChange={setIsLooping}>
|
|
301
|
+
Loop
|
|
302
|
+
</MenuItemCheckbox>
|
|
303
|
+
</MenuButton>
|
|
304
|
+
<Tooltip content="Back to the start" relation="label">
|
|
305
|
+
{(trigger) => (
|
|
306
|
+
<IconButton {...trigger} label="Back to the start" title={undefined}>
|
|
307
|
+
<RewindIcon />
|
|
308
|
+
</IconButton>
|
|
309
|
+
)}
|
|
310
|
+
</Tooltip>
|
|
311
|
+
<Toaster queue={toasts} label="Notifications (F8)" closeLabel="Dismiss" />
|
|
312
|
+
</>;
|
|
313
|
+
|
|
314
|
+
toasts.show(
|
|
315
|
+
{
|
|
316
|
+
title: "Score deleted",
|
|
317
|
+
action: { label: "Undo", onAction: restoreScore },
|
|
318
|
+
},
|
|
319
|
+
performance.now(),
|
|
320
|
+
);
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
```tsx
|
|
324
|
+
import {
|
|
325
|
+
SpinButton,
|
|
326
|
+
Tab,
|
|
327
|
+
TabList,
|
|
328
|
+
TabPanel,
|
|
329
|
+
Tabs,
|
|
330
|
+
Tree,
|
|
331
|
+
} from "@ac-kit/ui-common/preact";
|
|
332
|
+
|
|
333
|
+
// Module functions: stable, so the tree recomputes its rows only when
|
|
334
|
+
// `roots` or `expanded` change.
|
|
335
|
+
const childrenOf = (node: Asn1Node) => node.children;
|
|
336
|
+
const textValueOf = (node: Asn1Node) => describeNode(node);
|
|
337
|
+
|
|
338
|
+
<>
|
|
339
|
+
<Tabs selected={tab} onSelectedChange={setTab}>
|
|
340
|
+
<TabList label="Settings">
|
|
341
|
+
<Tab value="sound">Sound</Tab>
|
|
342
|
+
<Tab value="display">Display</Tab>
|
|
343
|
+
</TabList>
|
|
344
|
+
<TabPanel value="sound">
|
|
345
|
+
<SpinButton
|
|
346
|
+
label="Count-in bars"
|
|
347
|
+
value={bars}
|
|
348
|
+
min={0}
|
|
349
|
+
max={4}
|
|
350
|
+
onChange={setBars}
|
|
351
|
+
decrementLabel="Fewer bars"
|
|
352
|
+
incrementLabel="More bars"
|
|
353
|
+
/>
|
|
354
|
+
</TabPanel>
|
|
355
|
+
<TabPanel value="display">…</TabPanel>
|
|
356
|
+
</Tabs>
|
|
357
|
+
<Tree
|
|
358
|
+
labelledBy="structure-title"
|
|
359
|
+
roots={roots}
|
|
360
|
+
childrenOf={childrenOf}
|
|
361
|
+
textValueOf={textValueOf}
|
|
362
|
+
expanded={expanded}
|
|
363
|
+
onExpandedChange={setExpanded}
|
|
364
|
+
selected={selected}
|
|
365
|
+
onSelectedChange={setSelected}
|
|
366
|
+
selectionFollowsFocus
|
|
367
|
+
/>
|
|
368
|
+
</>;
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
Menus and tooltips are placed by CSS anchor positioning, which every current
|
|
372
|
+
browser has (Chromium 125, Firefox 147, Safari 26), over the Popover API
|
|
373
|
+
(Chromium 114, Firefox 125, Safari 17): no script measures anything. For an
|
|
374
|
+
older browser, load a polyfill such as
|
|
375
|
+
[`@oddbird/css-anchor-positioning`](https://github.com/oddbird/css-anchor-positioning);
|
|
376
|
+
without one, a menu or tooltip shows in the middle of the viewport, still
|
|
377
|
+
usable.
|
|
135
378
|
|
|
136
379
|
A `value` outside `min`–`max` is drawn, formatted and announced as the nearest
|
|
137
380
|
end. Disabling a `Knob` or a `Slider` mid-gesture drops the gesture: nothing is
|
|
@@ -163,9 +406,10 @@ panel, or on one control.
|
|
|
163
406
|
|
|
164
407
|
Every control root carries `ack-control` beside its own class (`ack-knob`,
|
|
165
408
|
`ack-slider`, …): the hook for what they share — the tone, the focus ring, the
|
|
166
|
-
disabled look, the touch target of the interactive ones (a `Readout
|
|
167
|
-
`Meter`
|
|
168
|
-
|
|
409
|
+
disabled look, the touch target of the interactive ones (a `Readout`, a
|
|
410
|
+
`Meter`, a `ProgressRing`, a `BitGrid` and a `SwatchStrip` are displays and
|
|
411
|
+
keep their own size) and, on the
|
|
412
|
+
controls a finger drags, no text
|
|
169
413
|
selection. The components also render stable part classes (`ack-knob-arc`,
|
|
170
414
|
`ack-slider-thumb`, …) and state attributes (`data-tone`, `data-state`,
|
|
171
415
|
`data-indicator`, `data-orientation`, `data-dragging`, `data-lit`,
|
|
@@ -223,6 +467,16 @@ Per control:
|
|
|
223
467
|
| `--ack-meter-gap` | `2px` | the space between segments |
|
|
224
468
|
| `--ack-meter-track` | `--ack-surface-raised` | an unlit bar or segment |
|
|
225
469
|
| `--ack-meter-fraction` | set by the component | the value from 0 to 1; read it, do not set it |
|
|
470
|
+
| `--ack-bit-grid-font-size` | `0.8125rem` | a bit grid's digits |
|
|
471
|
+
| `--ack-bit-grid-cell-min` | `1.1em` | a cell's least width |
|
|
472
|
+
| `--ack-bit-grid-cell-height` | `1.7em` | a cell's least height |
|
|
473
|
+
| `--ack-bit-grid-byte-gap` | `3px` | the extra space before each byte |
|
|
474
|
+
| `--ack-bit-grid-row-gap` | `2px` | the space between rows |
|
|
475
|
+
| `--ack-bit-grid-field-0` … `-5` | six distinct inks | the field tints, cycled by field |
|
|
476
|
+
| `--ack-bit-grid-columns` | set by the component | cells per row; read it, do not set it |
|
|
477
|
+
| `--ack-swatch-strip-height` | `2.25em` | a swatch's or a gradient's height |
|
|
478
|
+
| `--ack-swatch-strip-gap` | `2px` | the space between swatches |
|
|
479
|
+
| `--ack-swatch-strip-label-width` | `8em` | the column of the strip's name |
|
|
226
480
|
| `--ack-button-background` | `--ack-surface` | a button's body |
|
|
227
481
|
| `--ack-button-ink` | `--ack-lit-ink` | a primary button's text |
|
|
228
482
|
| `--ack-button-icon-size` | `20px` | the icon of a button, an icon button or a radio |
|
|
@@ -239,11 +493,56 @@ Per control:
|
|
|
239
493
|
| `--ack-dialog-text` | `CanvasText` | the panel's text |
|
|
240
494
|
| `--ack-dialog-backdrop` | `rgb(0 0 0 / 0.5)` | what dims the page behind |
|
|
241
495
|
| `--ack-dialog-padding` | `20px` | inside the panel |
|
|
496
|
+
| `--ack-menu-offset` | `4px` | the gap between a menu and its button |
|
|
497
|
+
| `--ack-menu-min-width` | `10rem` | a menu's least width; never narrower than its button |
|
|
498
|
+
| `--ack-menu-max-height` | `24rem` | a menu's greatest height before it scrolls |
|
|
499
|
+
| `--ack-menu-background` | `Canvas` | the menu |
|
|
500
|
+
| `--ack-menu-text` | `CanvasText` | the menu's text |
|
|
501
|
+
| `--ack-menu-shadow` | a soft drop shadow | the menu's shadow |
|
|
502
|
+
| `--ack-menu-item-focus` | text colour at 12 % | the focused item, also the one a mouse is over |
|
|
503
|
+
| `--ack-tooltip-offset` | `6px` | the gap between a tooltip and its trigger |
|
|
504
|
+
| `--ack-tooltip-max-width` | `18rem` | a tooltip's widest width before its text wraps |
|
|
505
|
+
| `--ack-tooltip-background` | `CanvasText` | the tooltip: the page's colours inverted |
|
|
506
|
+
| `--ack-tooltip-text` | `Canvas` | the tooltip's text |
|
|
507
|
+
| `--ack-toast-width` | `24rem` | the toaster's width, never wider than the viewport |
|
|
508
|
+
| `--ack-toaster-inset` | `16px` | the toaster's distance from the viewport's edges |
|
|
509
|
+
| `--ack-toast-gap` | `8px` | the space between toasts |
|
|
510
|
+
| `--ack-toast-background` | `Canvas` | a toast |
|
|
511
|
+
| `--ack-toast-text` | `CanvasText` | a toast's text |
|
|
512
|
+
| `--ack-toast-shadow` | a soft drop shadow | a toast's shadow |
|
|
513
|
+
| `--ack-toast-accent` | from the tone | a toast's leading edge; set it for a tone of your own |
|
|
514
|
+
| `--ack-toast-obscuring-opacity` | `0.2` | a toast's opacity while it covers the focused control |
|
|
515
|
+
| `--ack-tabs-gap` | `12px` | the space between a tab list and its panel |
|
|
516
|
+
| `--ack-tab-indicator` | `--ack-lit` | the bar under (or beside) the selected tab |
|
|
517
|
+
| `--ack-tab-indicator-thickness` | `3px` | that bar's thickness |
|
|
518
|
+
| `--ack-progress-ring-size` | `48px` | a progress ring's width and height |
|
|
519
|
+
| `--ack-progress-ring-thickness` | `4` | its track and arc width, in ring units of 48 |
|
|
520
|
+
| `--ack-progress-ring-track` | `--ack-surface-raised` | the unfilled track |
|
|
521
|
+
| `--ack-progress-ring-value-size` | `12px` | the value text drawn inside |
|
|
522
|
+
| `--ack-progress-fraction` | set by the component | the value from 0 to 1; read it, do not set it |
|
|
523
|
+
| `--ack-spin-button-background` | `--ack-surface` | a spin button's body |
|
|
524
|
+
| `--ack-spin-button-field-width` | `5em` | the value's width between the buttons |
|
|
525
|
+
| `--ack-tree-indent` | `1.25rem` | a tree row's indent per level |
|
|
526
|
+
| `--ack-tree-item-height` | `--ack-target` | a tree row's least height; keep it 24px or more (WCAG 2.5.8) |
|
|
527
|
+
| `--ack-tree-toggle-size` | `24px` | a branch's expand mark, a pointer target of its own |
|
|
528
|
+
| `--ack-tree-item-hover` | text colour at 6 % | the row under the pointer |
|
|
529
|
+
| `--ack-tree-item-selected` | `--ack-lit` at 16 % | a selected row, which also carries a bar in `--ack-lit` |
|
|
530
|
+
| `--ack-tree-level` | set by the component | the row's level from 1; read it, do not set it |
|
|
242
531
|
|
|
243
532
|
A dialog stops the page behind from scrolling while it is open
|
|
244
533
|
(`:root:has(dialog.ack-dialog[open])`), and its entry and exit are transitions
|
|
245
534
|
that `prefers-reduced-motion: reduce` turns off.
|
|
246
535
|
|
|
536
|
+
A menu and a tooltip take `data-side` and `data-align` from their props: the
|
|
537
|
+
stylesheet turns them into a `position-area` against the trigger, with
|
|
538
|
+
`position-try-fallbacks` flipping them to the other side when the viewport has
|
|
539
|
+
no room; along the trigger they shift to stay inside it. A menu is at least
|
|
540
|
+
as wide as its button. The toaster sits at the edge `data-position` names,
|
|
541
|
+
clear of the safe-area insets, and toasts take a leading edge in their tone
|
|
542
|
+
(`data-tone`) and a `data-state` of `open` or `closing` while they leave.
|
|
543
|
+
Their entries and exits, like the menu's and the tooltip's, are transitions
|
|
544
|
+
that `prefers-reduced-motion: reduce` turns off.
|
|
545
|
+
|
|
247
546
|
Without the stylesheet the components still work, unstyled; only the slider's
|
|
248
547
|
thumb and the meter's bar depend on it for their position.
|
|
249
548
|
|
|
@@ -266,9 +565,84 @@ thumb and the meter's bar depend on it for their position.
|
|
|
266
565
|
- `Dialog` is a native modal `<dialog>` named by its title and described by its
|
|
267
566
|
description: the page is inert, Escape closes it when dismissible, focus
|
|
268
567
|
returns to the opener.
|
|
568
|
+
- `MenuButton` follows the WAI-ARIA menu button and menu patterns: a button
|
|
569
|
+
with `aria-haspopup="menu"` and `aria-expanded`, a `menu` named by it, items
|
|
570
|
+
of the `menuitem`, `menuitemcheckbox` and `menuitemradio` roles with
|
|
571
|
+
`aria-checked`, in named `group`s and between `separator`s. Enter, Space and
|
|
572
|
+
Arrow Down open it on its first item, Arrow Up on its last; the arrows move
|
|
573
|
+
round, Home and End go to the ends, typing a name moves to it, Enter
|
|
574
|
+
chooses and closes, Space checks a checkbox or radio item and keeps it open,
|
|
575
|
+
Escape and a press outside close it, Tab closes it and moves on. Focus
|
|
576
|
+
returns to the button. A disabled item stays focusable and is announced as
|
|
577
|
+
disabled, as the practices advise, and is not chosen. Items are at least
|
|
578
|
+
`--ack-target` high.
|
|
579
|
+
- `Tooltip` follows the WAI-ARIA tooltip pattern and WCAG 2.2 success
|
|
580
|
+
criterion 1.4.13: the `tooltip` role, describing or naming its trigger
|
|
581
|
+
whether shown or not, shown on a mouse or pen hover after its delay and at
|
|
582
|
+
once on a keyboard focus (not on the focus a click gives); Escape hides it
|
|
583
|
+
without moving focus or the pointer (and does not close a dialog around
|
|
584
|
+
it), the pointer can move onto it, and it stays while hovered or focused. A
|
|
585
|
+
press of the trigger hides it. Touch does not hover: what a tooltip says
|
|
586
|
+
must be reachable another way on a touch screen, or be the name of an icon
|
|
587
|
+
that assistive technology reads.
|
|
588
|
+
- `Toaster` is a landmark region named by its `label`. Each toast is
|
|
589
|
+
announced as it shows by a visually hidden live region, `status` (polite)
|
|
590
|
+
or `alert` for an `assertive` toast, placed in the modal dialog holding
|
|
591
|
+
focus when one is open — which would otherwise leave the announcement, and
|
|
592
|
+
the toasts, inert; the toasts move into that dialog too, so they stay
|
|
593
|
+
operable. Toasts never take focus: F8 does, and F8 again goes back; Escape
|
|
594
|
+
dismisses the focused toast, focus moving to the next one. Their clocks stop
|
|
595
|
+
while the pointer is over them, focus is among them or the page is hidden,
|
|
596
|
+
and a toast with an action stays until dismissed (WCAG 2.2.1): give people a
|
|
597
|
+
setting for the queue's `durationMs` too. While toasts cover part of the
|
|
598
|
+
focused control, the toaster takes `data-obscuring` and they fade until
|
|
599
|
+
hovered or focused, so focus is never hidden behind them (WCAG 2.4.11).
|
|
269
600
|
- `Readout` is a group named once by its caption.
|
|
270
601
|
- `Meter` has the `meter` role with its range and value (and `valueText`), and
|
|
271
602
|
no keyboard.
|
|
603
|
+
- `BitGrid` follows the WAI-ARIA grid pattern: a named `grid` of `row`s and
|
|
604
|
+
`gridcell`s, one tab stop, the arrows within and between rows without
|
|
605
|
+
wrapping, Home and End to the row's ends and with Control to the grid's.
|
|
606
|
+
Every cell is named by its position, value, change and field; a changed
|
|
607
|
+
cell is filled, not only coloured. It is `aria-readonly` without
|
|
608
|
+
`onActivate`; with it, Enter, Space or a click activates a cell and the
|
|
609
|
+
selected one is `aria-selected`. A cell is smaller than a 24-pixel target,
|
|
610
|
+
so give an activatable grid an equivalent control of normal size (a field
|
|
611
|
+
or a slider for the index), as WCAG 2.5.8 allows.
|
|
612
|
+
- `SwatchStrip` is a named list whose swatches are each named by their label
|
|
613
|
+
and colour (or description); a gradient is one `img` named by its colours in
|
|
614
|
+
order. Colour is the content here, so every name says it in text.
|
|
615
|
+
- `Tabs` follow the WAI-ARIA tabs pattern: a named `tablist` of `tab`s with
|
|
616
|
+
`aria-selected` and `aria-controls`, each `tabpanel` named by its tab. The
|
|
617
|
+
tab list is one tab stop, on the selected tab; the arrows along it move
|
|
618
|
+
round (mirrored right to left), Home and End go to the ends, and the panel,
|
|
619
|
+
or its first control, is the next tab stop. A disabled tab is focusable and
|
|
620
|
+
announced, never selected. A tab list wider than its box scrolls without a
|
|
621
|
+
tab stop of its own. The selected tab carries a bar besides its colour, in
|
|
622
|
+
forced colours too.
|
|
623
|
+
- `ProgressRing` has the `progressbar` role, its value and `valueText`, no
|
|
624
|
+
value while indeterminate; its turning arc stands still under
|
|
625
|
+
`prefers-reduced-motion: reduce`, and forced colours draw it in system
|
|
626
|
+
colours.
|
|
627
|
+
- `SpinButton` follows the WAI-ARIA spinbutton pattern: the `spinbutton`
|
|
628
|
+
role with the bounds it has and its formatted value, Arrow Up and Down, Page
|
|
629
|
+
Up and Down, Home and End. Its − and + buttons are named, out of the tab
|
|
630
|
+
order, and never take focus, so a phone keyboard stays closed; pressed
|
|
631
|
+
while focus is elsewhere (a screen reader's virtual cursor), they announce
|
|
632
|
+
the new value through a polite live region. An entry that is not a number
|
|
633
|
+
is `aria-invalid`, shown by an outline and a wavy underline, not by colour
|
|
634
|
+
alone.
|
|
635
|
+
- `Tree` follows the WAI-ARIA tree view pattern: a named `tree`
|
|
636
|
+
(`aria-multiselectable` in multiple selection) of `treeitem`s, each stating
|
|
637
|
+
`aria-level`, `aria-posinset`, `aria-setsize` and, for a branch,
|
|
638
|
+
`aria-expanded` (`aria-busy` while its children load), so the flat list
|
|
639
|
+
reads as nested. Selection is stated on every item in multiple selection,
|
|
640
|
+
on the selected one only otherwise. One tab stop; the keys are the
|
|
641
|
+
pattern's, typeahead included, mirrored right to left. When the focused
|
|
642
|
+
row goes away, focus moves to its nearest row still shown rather than to
|
|
643
|
+
the page. A selected row carries a bar besides its background, in forced
|
|
644
|
+
colours too; rows are at least `--ack-target` high and a branch's mark is a
|
|
645
|
+
24px target of its own.
|
|
272
646
|
- Pointer input is touch first: pointers are captured for the length of a
|
|
273
647
|
gesture, `touch-action` keeps the page from scrolling under a knob's drag
|
|
274
648
|
(a slider lets it scroll across the track, and a scroll that starts cancels
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The anchor name of the popover with this id: a dashed ident unique to it, so
|
|
3
|
+
* a trigger can anchor several popovers (a menu and a tooltip) and one page
|
|
4
|
+
* many triggers.
|
|
5
|
+
*/
|
|
6
|
+
export declare function anchorNameOf_(popoverId: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Adds `name` to the element's inline `anchor-name` list, keeping the names
|
|
9
|
+
* already there, until the returned handle is disposed. A browser without
|
|
10
|
+
* anchor positioning ignores the property.
|
|
11
|
+
*/
|
|
12
|
+
export declare function addAnchorName_(element: HTMLElement, name: string): Disposable;
|
|
13
|
+
//# sourceMappingURL=_anchor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_anchor.d.ts","sourceRoot":"","sources":["../../src/adapter/_anchor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEvD;AAkBD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAc7E"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The anchor name of the popover with this id: a dashed ident unique to it, so
|
|
3
|
+
* a trigger can anchor several popovers (a menu and a tooltip) and one page
|
|
4
|
+
* many triggers.
|
|
5
|
+
*/
|
|
6
|
+
export function anchorNameOf_(popoverId) {
|
|
7
|
+
return `--ack-anchor-${CSS.escape(popoverId)}`;
|
|
8
|
+
}
|
|
9
|
+
function anchorNames_(element) {
|
|
10
|
+
const value = element.style.getPropertyValue("anchor-name").trim();
|
|
11
|
+
return value === "" || value === "none"
|
|
12
|
+
? []
|
|
13
|
+
: value.split(",").map((name) => name.trim());
|
|
14
|
+
}
|
|
15
|
+
function setAnchorNames_(element, names) {
|
|
16
|
+
if (names.length === 0) {
|
|
17
|
+
element.style.removeProperty("anchor-name");
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
element.style.setProperty("anchor-name", names.join(", "));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Adds `name` to the element's inline `anchor-name` list, keeping the names
|
|
25
|
+
* already there, until the returned handle is disposed. A browser without
|
|
26
|
+
* anchor positioning ignores the property.
|
|
27
|
+
*/
|
|
28
|
+
export function addAnchorName_(element, name) {
|
|
29
|
+
const names = anchorNames_(element);
|
|
30
|
+
if (!names.includes(name)) {
|
|
31
|
+
setAnchorNames_(element, [...names, name]);
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
[Symbol.dispose]() {
|
|
35
|
+
setAnchorNames_(element, anchorNames_(element).filter((candidate) => candidate !== name));
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=_anchor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_anchor.js","sourceRoot":"","sources":["../../src/adapter/_anchor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,SAAiB;IAC9C,OAAO,gBAAgB,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,YAAY,CAAC,OAAoB;IACzC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,CAAC;IAEnE,OAAO,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,MAAM;QACtC,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,eAAe,CAAC,OAAoB,EAAE,KAAwB;IACtE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC;SAAM,CAAC;QACP,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,aAAa,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5D,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,OAAoB,EAAE,IAAY;IAChE,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,eAAe,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO;QACN,CAAC,MAAM,CAAC,OAAO,CAAC;YACf,eAAe,CACd,OAAO,EACP,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,KAAK,IAAI,CAAC,CAC/D,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The elements that may take focus, before the checks of {@link isFocusable_}. */
|
|
2
|
+
export declare const FOCUSABLE_SELECTOR_ = "button, a[href], input:not([type=\"hidden\"]), select, textarea, [tabindex], [contenteditable]:not([contenteditable=\"false\"])";
|
|
3
|
+
/** Whether an element matching {@link FOCUSABLE_SELECTOR_} can take focus now. */
|
|
4
|
+
export declare function isFocusable_(element: HTMLElement): boolean;
|
|
5
|
+
/** Whether Tab reaches an element inside `container`. */
|
|
6
|
+
export declare function hasTabbable_(container: HTMLElement): boolean;
|
|
7
|
+
/** The reading direction an element is laid out in. */
|
|
8
|
+
export declare function directionOf_(element: Element): "ltr" | "rtl";
|
|
9
|
+
/**
|
|
10
|
+
* The language of an element's text, from the closest `lang` attribute; for the
|
|
11
|
+
* collation typeahead compares names with. `undefined` for the runtime's.
|
|
12
|
+
*/
|
|
13
|
+
export declare function localesOf_(element: Element): string | undefined;
|
|
14
|
+
//# sourceMappingURL=_dom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_dom.d.ts","sourceRoot":"","sources":["../../src/adapter/_dom.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,oIAC8F,CAAC;AAE/H,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAO1D;AAED,yDAAyD;AACzD,wBAAgB,YAAY,CAAC,SAAS,EAAE,WAAW,GAAG,OAAO,CAU5D;AAED,uDAAuD;AACvD,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK,GAAG,KAAK,CAE5D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAI/D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** The elements that may take focus, before the checks of {@link isFocusable_}. */
|
|
2
|
+
export const FOCUSABLE_SELECTOR_ = 'button, a[href], input:not([type="hidden"]), select, textarea, [tabindex], [contenteditable]:not([contenteditable="false"])';
|
|
3
|
+
/** Whether an element matching {@link FOCUSABLE_SELECTOR_} can take focus now. */
|
|
4
|
+
export function isFocusable_(element) {
|
|
5
|
+
return (!element.matches(":disabled") &&
|
|
6
|
+
element.getAttribute("aria-disabled") !== "true" &&
|
|
7
|
+
element.closest("[inert]") === null &&
|
|
8
|
+
element.checkVisibility({ visibilityProperty: true }));
|
|
9
|
+
}
|
|
10
|
+
/** Whether Tab reaches an element inside `container`. */
|
|
11
|
+
export function hasTabbable_(container) {
|
|
12
|
+
for (const element of container.querySelectorAll(FOCUSABLE_SELECTOR_)) {
|
|
13
|
+
if (element.tabIndex >= 0 && isFocusable_(element)) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
/** The reading direction an element is laid out in. */
|
|
20
|
+
export function directionOf_(element) {
|
|
21
|
+
return getComputedStyle(element).direction === "rtl" ? "rtl" : "ltr";
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The language of an element's text, from the closest `lang` attribute; for the
|
|
25
|
+
* collation typeahead compares names with. `undefined` for the runtime's.
|
|
26
|
+
*/
|
|
27
|
+
export function localesOf_(element) {
|
|
28
|
+
const lang = element.closest("[lang]")?.lang;
|
|
29
|
+
return lang === "" ? undefined : lang;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=_dom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_dom.js","sourceRoot":"","sources":["../../src/adapter/_dom.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,CAAC,MAAM,mBAAmB,GAC/B,6HAA6H,CAAC;AAE/H,kFAAkF;AAClF,MAAM,UAAU,YAAY,CAAC,OAAoB;IAChD,OAAO,CACN,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;QAC7B,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,KAAK,MAAM;QAChD,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,IAAI;QACnC,OAAO,CAAC,eAAe,CAAC,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CACrD,CAAC;AACH,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,YAAY,CAAC,SAAsB;IAClD,KAAK,MAAM,OAAO,IAAI,SAAS,CAAC,gBAAgB,CAC/C,mBAAmB,CACnB,EAAE,CAAC;QACH,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;YACpD,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,YAAY,CAAC,OAAgB;IAC5C,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AACtE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,OAAgB;IAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAc,QAAQ,CAAC,EAAE,IAAI,CAAC;IAE1D,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ToastUrgency } from "../toast/toast-queue.js";
|
|
2
|
+
/**
|
|
3
|
+
* Announces text to screen readers through visually hidden live regions, a
|
|
4
|
+
* polite `status` and an assertive `alert`. Each announcement is a node added
|
|
5
|
+
* to its region, so the same text twice is read twice, and a quick second one
|
|
6
|
+
* does not replace the first.
|
|
7
|
+
*
|
|
8
|
+
* While a modal dialog is open, the rest of the page is inert and hidden from
|
|
9
|
+
* assistive technology, live regions included: the announcement then goes to a
|
|
10
|
+
* region inside the open dialog that holds focus.
|
|
11
|
+
*
|
|
12
|
+
* Framework-free.
|
|
13
|
+
*/
|
|
14
|
+
export declare class LiveAnnouncer_ implements Disposable {
|
|
15
|
+
private readonly document_;
|
|
16
|
+
private readonly regions_;
|
|
17
|
+
private readonly timers_;
|
|
18
|
+
constructor(document: Document);
|
|
19
|
+
announce(lines: readonly string[], urgency: ToastUrgency): void;
|
|
20
|
+
[Symbol.dispose](): void;
|
|
21
|
+
/** The open dialog holding focus, or else the body. */
|
|
22
|
+
private host_;
|
|
23
|
+
private createRegions_;
|
|
24
|
+
private later_;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=_live-announcer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_live-announcer.d.ts","sourceRoot":"","sources":["../../src/adapter/_live-announcer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAiB5D;;;;;;;;;;;GAWG;AACH,qBAAa,cAAe,YAAW,UAAU;IAChD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgC;IACzD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4C;IAEpE,YAAY,QAAQ,EAAE,QAAQ,EAE7B;IAED,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAsB9D;IAED,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAUvB;IAED,uDAAuD;IACvD,OAAO,CAAC,KAAK;IAab,OAAO,CAAC,cAAc;IAoBtB,OAAO,CAAC,MAAM;CAOd"}
|