@ac-kit/ui-common 0.0.0-stage → 0.1.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 +89 -0
- package/LICENSE +28 -0
- package/README.md +315 -2
- package/dist/button/button.d.ts +35 -0
- package/dist/button/button.d.ts.map +1 -0
- package/dist/button/button.js +22 -0
- package/dist/button/button.js.map +1 -0
- package/dist/dialog/dialog.d.ts +33 -0
- package/dist/dialog/dialog.d.ts.map +1 -0
- package/dist/dialog/dialog.js +23 -0
- package/dist/dialog/dialog.js.map +1 -0
- package/dist/focus/owns-arrow-keys.d.ts +31 -0
- package/dist/focus/owns-arrow-keys.d.ts.map +1 -0
- package/dist/focus/owns-arrow-keys.js +64 -0
- package/dist/focus/owns-arrow-keys.js.map +1 -0
- package/dist/focus/roving-focus.d.ts +34 -0
- package/dist/focus/roving-focus.d.ts.map +1 -0
- package/dist/focus/roving-focus.js +72 -0
- package/dist/focus/roving-focus.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/knob/knob.d.ts +106 -0
- package/dist/knob/knob.d.ts.map +1 -0
- package/dist/knob/knob.js +116 -0
- package/dist/knob/knob.js.map +1 -0
- package/dist/meter/meter.d.ts +63 -0
- package/dist/meter/meter.d.ts.map +1 -0
- package/dist/meter/meter.js +57 -0
- package/dist/meter/meter.js.map +1 -0
- package/dist/preact/button.d.ts +40 -0
- package/dist/preact/button.d.ts.map +1 -0
- package/dist/preact/button.js +22 -0
- package/dist/preact/button.js.map +1 -0
- package/dist/preact/dialog.d.ts +43 -0
- package/dist/preact/dialog.d.ts.map +1 -0
- package/dist/preact/dialog.js +89 -0
- package/dist/preact/dialog.js.map +1 -0
- package/dist/preact/index.d.ts +13 -0
- package/dist/preact/index.d.ts.map +1 -0
- package/dist/preact/index.js +13 -0
- package/dist/preact/index.js.map +1 -0
- package/dist/preact/join-classes.d.ts +10 -0
- package/dist/preact/join-classes.d.ts.map +1 -0
- package/dist/preact/join-classes.js +12 -0
- package/dist/preact/join-classes.js.map +1 -0
- package/dist/preact/knob.d.ts +51 -0
- package/dist/preact/knob.d.ts.map +1 -0
- package/dist/preact/knob.js +152 -0
- package/dist/preact/knob.js.map +1 -0
- package/dist/preact/meter.d.ts +34 -0
- package/dist/preact/meter.d.ts.map +1 -0
- package/dist/preact/meter.js +21 -0
- package/dist/preact/meter.js.map +1 -0
- package/dist/preact/radio-group.d.ts +50 -0
- package/dist/preact/radio-group.d.ts.map +1 -0
- package/dist/preact/radio-group.js +42 -0
- package/dist/preact/radio-group.js.map +1 -0
- package/dist/preact/readout.d.ts +22 -0
- package/dist/preact/readout.d.ts.map +1 -0
- package/dist/preact/readout.js +13 -0
- package/dist/preact/readout.js.map +1 -0
- package/dist/preact/slider.d.ts +40 -0
- package/dist/preact/slider.d.ts.map +1 -0
- package/dist/preact/slider.js +162 -0
- package/dist/preact/slider.js.map +1 -0
- package/dist/preact/switch.d.ts +25 -0
- package/dist/preact/switch.d.ts.map +1 -0
- package/dist/preact/switch.js +19 -0
- package/dist/preact/switch.js.map +1 -0
- package/dist/preact/toggle-button.d.ts +26 -0
- package/dist/preact/toggle-button.d.ts.map +1 -0
- package/dist/preact/toggle-button.js +16 -0
- package/dist/preact/toggle-button.js.map +1 -0
- package/dist/preact/toolbar.d.ts +24 -0
- package/dist/preact/toolbar.d.ts.map +1 -0
- package/dist/preact/toolbar.js +148 -0
- package/dist/preact/toolbar.js.map +1 -0
- package/dist/preact/use-element-binding.d.ts +32 -0
- package/dist/preact/use-element-binding.d.ts.map +1 -0
- package/dist/preact/use-element-binding.js +51 -0
- package/dist/preact/use-element-binding.js.map +1 -0
- package/dist/readout/readout.d.ts +41 -0
- package/dist/readout/readout.d.ts.map +1 -0
- package/dist/readout/readout.js +26 -0
- package/dist/readout/readout.js.map +1 -0
- package/dist/slider/_clamped-value.d.ts +7 -0
- package/dist/slider/_clamped-value.d.ts.map +1 -0
- package/dist/slider/_clamped-value.js +9 -0
- package/dist/slider/_clamped-value.js.map +1 -0
- package/dist/slider/slider-attributes.d.ts +50 -0
- package/dist/slider/slider-attributes.d.ts.map +1 -0
- package/dist/slider/slider-attributes.js +38 -0
- package/dist/slider/slider-attributes.js.map +1 -0
- package/dist/slider/slider-range.d.ts +59 -0
- package/dist/slider/slider-range.d.ts.map +1 -0
- package/dist/slider/slider-range.js +73 -0
- package/dist/slider/slider-range.js.map +1 -0
- package/dist/slider/slider-track.d.ts +37 -0
- package/dist/slider/slider-track.d.ts.map +1 -0
- package/dist/slider/slider-track.js +35 -0
- package/dist/slider/slider-track.js.map +1 -0
- package/dist/slider/stepped-value.d.ts +31 -0
- package/dist/slider/stepped-value.d.ts.map +1 -0
- package/dist/slider/stepped-value.js +55 -0
- package/dist/slider/stepped-value.js.map +1 -0
- package/dist/switch/switch.d.ts +30 -0
- package/dist/switch/switch.d.ts.map +1 -0
- package/dist/switch/switch.js +26 -0
- package/dist/switch/switch.js.map +1 -0
- package/dist/toggle-button/toggle-button.d.ts +44 -0
- package/dist/toggle-button/toggle-button.d.ts.map +1 -0
- package/dist/toggle-button/toggle-button.js +31 -0
- package/dist/toggle-button/toggle-button.js.map +1 -0
- package/dist/tone.d.ts +8 -0
- package/dist/tone.d.ts.map +1 -0
- package/dist/tone.js +2 -0
- package/dist/tone.js.map +1 -0
- package/dist/toolbar/toolbar.d.ts +35 -0
- package/dist/toolbar/toolbar.d.ts.map +1 -0
- package/dist/toolbar/toolbar.js +23 -0
- package/dist/toolbar/toolbar.js.map +1 -0
- package/package.json +100 -3
- package/styles.css +992 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# @ac-kit/ui-common
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 34e8cfa: First release: knob, slider, toggle button, readout, meter, switch, radio
|
|
8
|
+
group, button, icon button, toolbar and modal dialog, as headless cores
|
|
9
|
+
(`switchAttributes`, `buttonAttributes`, `toolbarAttributes`,
|
|
10
|
+
`dialogAttributes`, `rovingFocusIndex`, `ownsArrowKeys`, …), Preact components
|
|
11
|
+
and one stylesheet themed through custom properties (`--ack-switch-*`,
|
|
12
|
+
`--ack-radio-*`, `--ack-button-*`, `--ack-toolbar-*`, `--ack-dialog-*`, …).
|
|
13
|
+
The stylesheet opens with the order statement `@layer ack.common, ack.music;`
|
|
14
|
+
and every control root carries `ack-control`.
|
|
15
|
+
|
|
16
|
+
Pointer input goes through `@ac-kit/ui-gesture/dom`, so capture, cancellation
|
|
17
|
+
and the browser's default actions behave the same in every control, and a
|
|
18
|
+
slider lets the page scroll across its track. A `Toolbar` has one tab stop and
|
|
19
|
+
moves between its controls with the arrow keys, Home and End, leaving the
|
|
20
|
+
arrows to a child that owns them (a radio group, a slider or knob, a text
|
|
21
|
+
field). A `Dialog` is a native modal `<dialog>`: Escape and a press that starts
|
|
22
|
+
and ends on the backdrop close it when `isDismissible`, and `onClose` is asked
|
|
23
|
+
once.
|
|
24
|
+
|
|
25
|
+
`@ac-kit/ui-common/preact` exports `useElementBinding` and `useLatest` for
|
|
26
|
+
components that bind a gesture of their own, and `joinClasses(base, extra)`,
|
|
27
|
+
which puts a caller's `class` after a component root's own classes, for
|
|
28
|
+
components built on the package such as `@ac-kit/ui-music`'s.
|
|
29
|
+
- 34e8cfa: `@ac-kit/ui-controls` is removed from the repository, and its npm deprecation
|
|
30
|
+
is pending the publication of these three packages; its last published
|
|
31
|
+
versions stay installable. Its generic controls moved to
|
|
32
|
+
`@ac-kit/ui-common`, its piano keyboard and dBFS meter scale to
|
|
33
|
+
`@ac-kit/ui-music`, and its `TapGesture` to `@ac-kit/ui-gesture`'s
|
|
34
|
+
`PressGesture`. Each package's README has a "Coming from `@ac-kit/ui-controls`"
|
|
35
|
+
table naming every renamed export, and the one stylesheet of `ui-controls`
|
|
36
|
+
becomes `@ac-kit/ui-common/styles.css` followed by `@ac-kit/ui-music/styles.css`.
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [34e8cfa]
|
|
41
|
+
- Updated dependencies [34e8cfa]
|
|
42
|
+
- Updated dependencies [34e8cfa]
|
|
43
|
+
- Updated dependencies [34e8cfa]
|
|
44
|
+
- Updated dependencies [34e8cfa]
|
|
45
|
+
- Updated dependencies [34e8cfa]
|
|
46
|
+
- Updated dependencies [34e8cfa]
|
|
47
|
+
- Updated dependencies [34e8cfa]
|
|
48
|
+
- Updated dependencies [34e8cfa]
|
|
49
|
+
- Updated dependencies [34e8cfa]
|
|
50
|
+
- Updated dependencies [34e8cfa]
|
|
51
|
+
- Updated dependencies [34e8cfa]
|
|
52
|
+
- Updated dependencies [34e8cfa]
|
|
53
|
+
- Updated dependencies [34e8cfa]
|
|
54
|
+
- Updated dependencies [34e8cfa]
|
|
55
|
+
- Updated dependencies [34e8cfa]
|
|
56
|
+
- Updated dependencies [34e8cfa]
|
|
57
|
+
- Updated dependencies [34e8cfa]
|
|
58
|
+
- Updated dependencies [34e8cfa]
|
|
59
|
+
- Updated dependencies [34e8cfa]
|
|
60
|
+
- Updated dependencies [34e8cfa]
|
|
61
|
+
- Updated dependencies [34e8cfa]
|
|
62
|
+
- Updated dependencies [34e8cfa]
|
|
63
|
+
- Updated dependencies [34e8cfa]
|
|
64
|
+
- Updated dependencies [34e8cfa]
|
|
65
|
+
- Updated dependencies [34e8cfa]
|
|
66
|
+
- Updated dependencies [34e8cfa]
|
|
67
|
+
- Updated dependencies [34e8cfa]
|
|
68
|
+
- Updated dependencies [34e8cfa]
|
|
69
|
+
- Updated dependencies [34e8cfa]
|
|
70
|
+
- Updated dependencies [34e8cfa]
|
|
71
|
+
- Updated dependencies [34e8cfa]
|
|
72
|
+
- Updated dependencies [34e8cfa]
|
|
73
|
+
- Updated dependencies [34e8cfa]
|
|
74
|
+
- Updated dependencies [34e8cfa]
|
|
75
|
+
- Updated dependencies [34e8cfa]
|
|
76
|
+
- Updated dependencies [34e8cfa]
|
|
77
|
+
- Updated dependencies [34e8cfa]
|
|
78
|
+
- Updated dependencies [34e8cfa]
|
|
79
|
+
- Updated dependencies [34e8cfa]
|
|
80
|
+
- Updated dependencies [34e8cfa]
|
|
81
|
+
- Updated dependencies [34e8cfa]
|
|
82
|
+
- Updated dependencies [34e8cfa]
|
|
83
|
+
- @ac-kit/algo@0.5.0
|
|
84
|
+
- @ac-kit/core@0.12.0
|
|
85
|
+
- @ac-kit/math-scalar@0.3.0
|
|
86
|
+
- @ac-kit/math-linear@0.3.0
|
|
87
|
+
- @ac-kit/format-svg@0.1.4
|
|
88
|
+
- @ac-kit/math-geometry@0.3.0
|
|
89
|
+
- @ac-kit/ui-gesture@0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Anthony Champagne and contributors
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,316 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ac-kit/ui-common
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Generic controls for the browser, touch first: a knob turned by dragging up
|
|
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 and a modal
|
|
6
|
+
dialog. Each one is a headless core — its state and behaviour as plain
|
|
7
|
+
functions and data, with no framework and no DOM — and a component per
|
|
8
|
+
framework over it, styled only through CSS custom properties.
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import { Knob } from "@ac-kit/ui-common/preact";
|
|
12
|
+
import "@ac-kit/ui-common/styles.css";
|
|
13
|
+
|
|
14
|
+
<Knob
|
|
15
|
+
label="Tempo"
|
|
16
|
+
value={tempo}
|
|
17
|
+
min={50}
|
|
18
|
+
max={100}
|
|
19
|
+
resetValue={100}
|
|
20
|
+
format={(value) => `${value} %`}
|
|
21
|
+
onChange={setTempo}
|
|
22
|
+
onRequestEntry={openTempoDialog}
|
|
23
|
+
/>;
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## What it is for
|
|
27
|
+
|
|
28
|
+
A panel of settings, a practice tool or a mixer needs controls that behave as
|
|
29
|
+
people expect and that work under a finger: a knob that does not have to be
|
|
30
|
+
turned around itself, a value that commits once the gesture ends rather than
|
|
31
|
+
on every pixel, a slider the page can still scroll across. The behaviour is
|
|
32
|
+
the hard part and is the same whatever draws it, so it lives in a core you can
|
|
33
|
+
test and reuse; the components only connect it to pointer and keyboard events.
|
|
34
|
+
Pointer gestures go through [`@ac-kit/ui-gesture/dom`](../ui-gesture), so
|
|
35
|
+
capture, cancellation and the browser's default actions are written once for
|
|
36
|
+
every framework.
|
|
37
|
+
|
|
38
|
+
## The core
|
|
39
|
+
|
|
40
|
+
`@ac-kit/ui-common` imports no framework and touches no DOM, so it runs and
|
|
41
|
+
tests anywhere. Every function is pure and every time is passed in.
|
|
42
|
+
|
|
43
|
+
- **Sliders.** `SliderRange` (`min`, `max`, `step`, as WAI-ARIA states them),
|
|
44
|
+
`snapSliderValue`, `sliderFraction`, `sliderValueAt`; `steppedValue` maps the
|
|
45
|
+
slider keys (arrows, Page Up/Down by ten steps, Home, End) to a value;
|
|
46
|
+
`sliderAttributes` gives the `slider` role and its `aria-value*` attributes;
|
|
47
|
+
`sliderTrackValueAt` reads the value under a pointer on a horizontal or
|
|
48
|
+
vertical track, the thumb kept inside it. The arithmetic is
|
|
49
|
+
`@ac-kit/math-scalar`'s (`quantize`, `lerp`, `inverseLerp`).
|
|
50
|
+
- **Knob.** `knobAngles` gives the pointer angle and the lit arc on a 270°
|
|
51
|
+
sweep (`KNOB_ARC`), lit from `min` or from a bipolar `origin`; `knobArcPath`
|
|
52
|
+
draws an arc of a `KnobDial` (`centerX`, `centerY`, `radius`) as SVG path
|
|
53
|
+
data, through `@ac-kit/math-geometry` and `@ac-kit/format-svg`;
|
|
54
|
+
`knobDragValue` turns a vertical drag into a value, with a fine mode.
|
|
55
|
+
- **Toggle button.** `toggleButtonAttributes` — a latching toggle,
|
|
56
|
+
`aria-pressed`, state, indicator and tone.
|
|
57
|
+
- **Readout.** `readoutAttributes` — a group named by its caption, optionally
|
|
58
|
+
announced as it changes.
|
|
59
|
+
- **Switch, button, toolbar, dialog.** `switchAttributes` (the `switch` role
|
|
60
|
+
and its state), `buttonAttributes` (variant, size, tone), `toolbarAttributes`
|
|
61
|
+
(the `toolbar` role, named, `aria-orientation` when vertical),
|
|
62
|
+
`dialogAttributes` (title and description ids, placement).
|
|
63
|
+
- **Focus.** `rovingFocusIndex(current, key, count, options)` gives the item an
|
|
64
|
+
arrow key, Home or End moves to, skipping disabled ones, wrapping or not,
|
|
65
|
+
mirrored in a right-to-left direction; `ownsArrowKeys` says whether an
|
|
66
|
+
element (its tag, input type, role, editable content) uses the arrow keys
|
|
67
|
+
itself, so a container leaves them to it.
|
|
68
|
+
- **Meter.** `meterAttributes` — the `meter` role with its range and a value
|
|
69
|
+
kept inside it; `meterLitCount` maps a level to the lit segments of a scale
|
|
70
|
+
of `MeterSegment`s (a threshold and a tone each), in O(log n).
|
|
71
|
+
- `ControlTone`, the colour role every lit control takes.
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { knobAngles, meterLitCount, steppedValue } from "@ac-kit/ui-common";
|
|
75
|
+
|
|
76
|
+
const tempo = { min: 50, max: 100, step: 1 };
|
|
77
|
+
|
|
78
|
+
steppedValue(80, "PageUp", tempo); // 90
|
|
79
|
+
knobAngles(75, tempo); // { pointer: 0, arcFrom: -135, arcTo: 0 }
|
|
80
|
+
|
|
81
|
+
const scale = [
|
|
82
|
+
{ threshold: -60, tone: "positive" },
|
|
83
|
+
{ threshold: -6, tone: "warning" },
|
|
84
|
+
{ threshold: 0, tone: "negative" },
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
meterLitCount(-10, scale); // 1
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Framework adapters
|
|
91
|
+
|
|
92
|
+
Each framework has its own subpath export, and the framework is an optional
|
|
93
|
+
peer dependency: install the one you use, and nothing else is pulled in.
|
|
94
|
+
|
|
95
|
+
| subpath | framework | components |
|
|
96
|
+
| -------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
97
|
+
| `@ac-kit/ui-common/preact` | Preact 11 | `Knob`, `Slider`, `ToggleButton`, `Readout`, `Meter`, `Switch`, `RadioGroup`, `Button`, `IconButton`, `Toolbar`, `Dialog` |
|
|
98
|
+
|
|
99
|
+
Every component is controlled: it shows `value` (or `isOn`) and reports what
|
|
100
|
+
the person asks for through a callback, typed with `@ac-kit/core`'s
|
|
101
|
+
`Callable`.
|
|
102
|
+
|
|
103
|
+
- `Knob` — `onChange` once per gesture, `onInput` while dragging, and
|
|
104
|
+
`onRequestEntry` when the person taps it or presses Enter: open your own
|
|
105
|
+
dialog, sheet or large `Slider` to type or pick a value. No surface is
|
|
106
|
+
bundled. A double tap goes back to `resetValue`.
|
|
107
|
+
- `Slider` — `orientation` `horizontal` or `vertical`; `onChange` once per
|
|
108
|
+
gesture, `onInput` while dragging; a drag never ends in a click.
|
|
109
|
+
- `ToggleButton` — `isOn`, `onToggle(nextIsOn)`, `indicator="light"` for the
|
|
110
|
+
hardware look; other `<button>` attributes pass through.
|
|
111
|
+
- `Readout` — `label` and the value as children; `live="polite"` announces
|
|
112
|
+
changes.
|
|
113
|
+
- `Meter` — `value`, `min`, `max` (finite), a `label`, optional `segments` and
|
|
114
|
+
`valueText`; read-only.
|
|
115
|
+
- `Switch` — `label`, optional `description`, `isOn`, `onToggle(nextIsOn)`: a
|
|
116
|
+
setting that applies as it is flipped.
|
|
117
|
+
- `RadioGroup` — `label` (the legend, visually hidden unless `isLabelShown`),
|
|
118
|
+
`options` (`value`, `label`, optional `description`, `icon`, `tone`,
|
|
119
|
+
`disabled`), `value`, `onChange(value)`; `appearance` `segmented` or
|
|
120
|
+
`cards`, `orientation`, `name`. Native radios in a `<fieldset>`: the browser
|
|
121
|
+
gives the arrow keys and form participation.
|
|
122
|
+
- `Button` — `variant` (`primary`, `secondary`, `ghost`), `size` (`regular`,
|
|
123
|
+
`large`), `tone`, `icon`; `type` defaults to `button`. `IconButton` — the
|
|
124
|
+
same with a required `label` naming and titling it, the icon as children.
|
|
125
|
+
- `Toolbar` — `label`, `orientation`; one tab stop over its children. Arrows,
|
|
126
|
+
Home and End move between them (Up and Down when vertical); a child that
|
|
127
|
+
owns the arrow keys — a radio group, a `Knob` or `Slider`, a text field —
|
|
128
|
+
keeps them, and only Tab leaves it. A radio group counts as one stop, its
|
|
129
|
+
checked radio.
|
|
130
|
+
- `Dialog` — `title`, `description`, `isOpen`, `onClose`, `placement`
|
|
131
|
+
(`center`, `bottom`, `side`, `sheet`), `isDismissible`, `closeLabel`,
|
|
132
|
+
`closeIcon`, `actions`. A native modal `<dialog>`, no portal. `onClose` is
|
|
133
|
+
asked once when Escape, the close button, a backdrop press or a
|
|
134
|
+
`<form method="dialog">` closes it; set `isOpen` to false in answer.
|
|
135
|
+
|
|
136
|
+
A `value` outside `min`–`max` is drawn, formatted and announced as the nearest
|
|
137
|
+
end. Disabling a `Knob` or a `Slider` mid-gesture drops the gesture: nothing is
|
|
138
|
+
committed. Only the primary button drives them, and a `Slider` follows one
|
|
139
|
+
pointer at a time.
|
|
140
|
+
|
|
141
|
+
`useElementBinding(bind, deps)`, `useLatest(value)` and `joinClasses(base, extra)`
|
|
142
|
+
are exported for your own components: the first returns the callback ref to put on your element, runs
|
|
143
|
+
a `@ac-kit/ui-gesture/dom` binding on it once mounted and disposes it, aborting
|
|
144
|
+
its signal, at unmount, when the element is replaced or before a re-run for
|
|
145
|
+
changed `deps`; the second gives handlers the latest props without rebinding;
|
|
146
|
+
the third puts a caller's `class` after a root's own classes.
|
|
147
|
+
|
|
148
|
+
Every component takes `class`, added after its own, and `tone` (`accent`,
|
|
149
|
+
`positive`, `warning`, `negative`, or a name of your own) where it has a lit
|
|
150
|
+
colour.
|
|
151
|
+
|
|
152
|
+
## Styling
|
|
153
|
+
|
|
154
|
+
Import `@ac-kit/ui-common/styles.css` once for the default look. Its rules sit
|
|
155
|
+
in the `ack.common` cascade layer, so any rule of yours wins without raising
|
|
156
|
+
specificity. The file opens with the order statement `@layer ack.common,
|
|
157
|
+
ack.music;` that every `ui-*` stylesheet shares, so `@ac-kit/ui-music`'s rules
|
|
158
|
+
follow these whichever file your bundler emits first; keep both names in any
|
|
159
|
+
order statement of your own. Every colour, size and font is a custom property
|
|
160
|
+
with a neutral default: surfaces and lines are mixed from the current text
|
|
161
|
+
colour, so the controls fit a light or a dark page. Set them on `:root`, on a
|
|
162
|
+
panel, or on one control.
|
|
163
|
+
|
|
164
|
+
Every control root carries `ack-control` beside its own class (`ack-knob`,
|
|
165
|
+
`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` and a
|
|
167
|
+
`Meter` are displays and keep their own size) and, on the controls a finger
|
|
168
|
+
drags, no text
|
|
169
|
+
selection. The components also render stable part classes (`ack-knob-arc`,
|
|
170
|
+
`ack-slider-thumb`, …) and state attributes (`data-tone`, `data-state`,
|
|
171
|
+
`data-indicator`, `data-orientation`, `data-dragging`, `data-lit`,
|
|
172
|
+
`aria-pressed`, `aria-disabled`), which you may select on; the custom
|
|
173
|
+
properties are the supported way to theme them.
|
|
174
|
+
|
|
175
|
+
Shared by every control:
|
|
176
|
+
|
|
177
|
+
| property | default | what it sets |
|
|
178
|
+
| ---------------------- | ----------------------- | ------------------------------------------------------------ |
|
|
179
|
+
| `--ack-accent` | `#2563c9` | the lit colour of the default tone |
|
|
180
|
+
| `--ack-tone-positive` | `#1f7a45` | the lit colour of `tone="positive"` |
|
|
181
|
+
| `--ack-tone-warning` | `#e08a12` | the lit colour of `tone="warning"` |
|
|
182
|
+
| `--ack-tone-negative` | `#c4372e` | the lit colour of `tone="negative"` |
|
|
183
|
+
| `--ack-lit` | from the tone | the lit colour of one control; set it for a tone of your own |
|
|
184
|
+
| `--ack-lit-ink` | `#ffffff`, `#1a1300` on warning | text on a lit control, 4.5:1 on the default tones; set it with `--ack-lit` for a tone of your own |
|
|
185
|
+
| `--ack-surface` | text colour at 10 % | a control's body |
|
|
186
|
+
| `--ack-surface-raised` | text colour at 18 % | tracks and thumbs |
|
|
187
|
+
| `--ack-line` | text colour at 28 % | borders |
|
|
188
|
+
| `--ack-muted` | text colour at 65 % | captions and an off button's text |
|
|
189
|
+
| `--ack-focus-ring` | `--ack-lit` | the focus outline |
|
|
190
|
+
| `--ack-radius` | `6px` | corner radius |
|
|
191
|
+
| `--ack-radius-small` | `4px` | a readout's and a meter bar's corner radius |
|
|
192
|
+
| `--ack-target` | `44px` | the smallest touch target of an interactive control |
|
|
193
|
+
| `--ack-font-mono` | `ui-monospace, monospace` | values |
|
|
194
|
+
| `--ack-motion` | `120ms ease-out` | transitions |
|
|
195
|
+
|
|
196
|
+
A tone of your own: `.ack-knob[data-tone="left-hand"] { --ack-lit: #ff8c0d; }`.
|
|
197
|
+
|
|
198
|
+
Per control:
|
|
199
|
+
|
|
200
|
+
| property | default | what it sets |
|
|
201
|
+
| ------------------------------ | ------------------------ | --------------------------------------------------------- |
|
|
202
|
+
| `--ack-knob-size` | `52px` | the dial's width and height |
|
|
203
|
+
| `--ack-knob-stroke` | `4` | the track and arc width, in dial units of 52 |
|
|
204
|
+
| `--ack-knob-track` | `--ack-surface-raised` | the unlit track |
|
|
205
|
+
| `--ack-knob-cap` | `--ack-surface` | the knob's cap |
|
|
206
|
+
| `--ack-knob-pointer` | `currentColor` | the pointer line |
|
|
207
|
+
| `--ack-slider-length` | `160px` | a horizontal slider's least width, a vertical one's height |
|
|
208
|
+
| `--ack-slider-track` | `--ack-surface-raised` | the unlit track |
|
|
209
|
+
| `--ack-slider-track-thickness` | `6px` | the track's thickness |
|
|
210
|
+
| `--ack-slider-thumb` | `--ack-surface-raised` | the thumb |
|
|
211
|
+
| `--ack-slider-thumb-length` | `20px` | the thumb along the track |
|
|
212
|
+
| `--ack-slider-thumb-thickness` | `34px` | the thumb across the track |
|
|
213
|
+
| `--ack-slider-fraction` | set by the component | the value from 0 to 1; read it, do not set it |
|
|
214
|
+
| `--ack-toggle-button-light-off` | text colour at 30 % | a toggle button's light while off |
|
|
215
|
+
| `--ack-toggle-button-ink` | `--ack-lit-ink` | a toggle button's text and light while on |
|
|
216
|
+
| `--ack-readout-background` | `#0d0f12` | a readout's display |
|
|
217
|
+
| `--ack-readout-text` | `--ack-lit` tinted white | a readout's value |
|
|
218
|
+
| `--ack-readout-glow` | `--ack-lit` at 55 % | the value's glow |
|
|
219
|
+
| `--ack-readout-label` | text colour at 60 % | the caption |
|
|
220
|
+
| `--ack-readout-min-width` | `92px` | a readout's least width |
|
|
221
|
+
| `--ack-meter-length` | `160px` | a meter's length |
|
|
222
|
+
| `--ack-meter-thickness` | `10px` | a meter's thickness |
|
|
223
|
+
| `--ack-meter-gap` | `2px` | the space between segments |
|
|
224
|
+
| `--ack-meter-track` | `--ack-surface-raised` | an unlit bar or segment |
|
|
225
|
+
| `--ack-meter-fraction` | set by the component | the value from 0 to 1; read it, do not set it |
|
|
226
|
+
| `--ack-button-background` | `--ack-surface` | a button's body |
|
|
227
|
+
| `--ack-button-ink` | `--ack-lit-ink` | a primary button's text |
|
|
228
|
+
| `--ack-button-icon-size` | `20px` | the icon of a button, an icon button or a radio |
|
|
229
|
+
| `--ack-switch-width` | `44px` | a switch's track width |
|
|
230
|
+
| `--ack-switch-height` | `24px` | a switch's track height; the thumb fills it |
|
|
231
|
+
| `--ack-switch-track` | `--ack-surface-raised` | an off switch's track |
|
|
232
|
+
| `--ack-switch-thumb` | `#fff` | the thumb |
|
|
233
|
+
| `--ack-radio-background` | `--ack-surface` | an unchosen option |
|
|
234
|
+
| `--ack-radio-ink` | `--ack-lit-ink` | the chosen option's text |
|
|
235
|
+
| `--ack-radio-gap` | `0`, `8px` for cards | the space between options |
|
|
236
|
+
| `--ack-toolbar-gap` | `8px` | the space between a toolbar's controls |
|
|
237
|
+
| `--ack-dialog-width` | `32rem` | a dialog's widest width; a sheet's when wide |
|
|
238
|
+
| `--ack-dialog-background` | `Canvas` | the panel |
|
|
239
|
+
| `--ack-dialog-text` | `CanvasText` | the panel's text |
|
|
240
|
+
| `--ack-dialog-backdrop` | `rgb(0 0 0 / 0.5)` | what dims the page behind |
|
|
241
|
+
| `--ack-dialog-padding` | `20px` | inside the panel |
|
|
242
|
+
|
|
243
|
+
A dialog stops the page behind from scrolling while it is open
|
|
244
|
+
(`:root:has(dialog.ack-dialog[open])`), and its entry and exit are transitions
|
|
245
|
+
that `prefers-reduced-motion: reduce` turns off.
|
|
246
|
+
|
|
247
|
+
Without the stylesheet the components still work, unstyled; only the slider's
|
|
248
|
+
thumb and the meter's bar depend on it for their position.
|
|
249
|
+
|
|
250
|
+
## Accessibility
|
|
251
|
+
|
|
252
|
+
- `Knob` and `Slider` are WAI-ARIA sliders: named by their label, announcing
|
|
253
|
+
the formatted value, stepped by the arrow keys, Page Up and Page Down by ten
|
|
254
|
+
steps, Home and End to the ends. A knob's value entry is reached with Enter
|
|
255
|
+
or Space as well as by a tap. A disabled one leaves the tab order and
|
|
256
|
+
announces `aria-disabled`.
|
|
257
|
+
- `ToggleButton` is a native button announced as a toggle, pressed or not.
|
|
258
|
+
- `Button` and `IconButton` are native buttons; an `IconButton` is named by its
|
|
259
|
+
`label`.
|
|
260
|
+
- `Switch` is a button with the `switch` role and `aria-checked`, flipped with
|
|
261
|
+
Space or Enter, its description linked by `aria-describedby`.
|
|
262
|
+
- `RadioGroup` is a native radio group in a `<fieldset>` and `<legend>`: arrows
|
|
263
|
+
move and choose, Tab leaves.
|
|
264
|
+
- `Toolbar` is the `toolbar` role with one tab stop and arrow-key movement,
|
|
265
|
+
leaving the arrows to the controls that own them.
|
|
266
|
+
- `Dialog` is a native modal `<dialog>` named by its title and described by its
|
|
267
|
+
description: the page is inert, Escape closes it when dismissible, focus
|
|
268
|
+
returns to the opener.
|
|
269
|
+
- `Readout` is a group named once by its caption.
|
|
270
|
+
- `Meter` has the `meter` role with its range and value (and `valueText`), and
|
|
271
|
+
no keyboard.
|
|
272
|
+
- Pointer input is touch first: pointers are captured for the length of a
|
|
273
|
+
gesture, `touch-action` keeps the page from scrolling under a knob's drag
|
|
274
|
+
(a slider lets it scroll across the track, and a scroll that starts cancels
|
|
275
|
+
the press), and interactive controls' touch targets are at least
|
|
276
|
+
`--ack-target` wide and high (a readout and a meter are displays, exempt).
|
|
277
|
+
|
|
278
|
+
## Coming from `@ac-kit/ui-controls`
|
|
279
|
+
|
|
280
|
+
`@ac-kit/ui-controls` is replaced by this package, `@ac-kit/ui-music` (the
|
|
281
|
+
keyboard and the dBFS meter scale) and `@ac-kit/ui-gesture` (`TapGesture`).
|
|
282
|
+
What moved here:
|
|
283
|
+
|
|
284
|
+
| `@ac-kit/ui-controls` | here | change |
|
|
285
|
+
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------- |
|
|
286
|
+
| `FaderOrientation`, `FaderTrack`, `faderValueAt` | `SliderOrientation`, `SliderTrack`, `sliderTrackValueAt` | renamed |
|
|
287
|
+
| `KnobArc`, `KNOB_ARC`, `KnobAngles`, `KnobAnglesOptions`, `knobAngles`, `KnobDragOptions`, `knobDragValue` | same names | none |
|
|
288
|
+
| `knobArcPath` | `knobArcPath` | `dial` is a `KnobDial` (`centerX`, `centerY`, `radius`), not a `Circle2` |
|
|
289
|
+
| `LedButtonAttributes`, `LedButtonAttributesInput`, `ledButtonAttributes` | `ToggleButtonAttributes`, `ToggleButtonAttributesInput`, `toggleButtonAttributes` | renamed; `indicator` in, `data-indicator` out |
|
|
290
|
+
| `MeterZone` | — | removed: segments carry a `ControlTone` |
|
|
291
|
+
| `MeterSegment` | `MeterSegment` | `zone` → `tone` |
|
|
292
|
+
| `METER_SEGMENTS` | `@ac-kit/ui-music`'s `PEAK_METER_SEGMENTS` | moved and renamed; zones → tones |
|
|
293
|
+
| `meterLitCount` | `meterLitCount` | none |
|
|
294
|
+
| `ReadoutLive`, `ReadoutAttributes`, `ReadoutAttributesInput`, `readoutAttributes`, `ControlTone` | same names | none |
|
|
295
|
+
| `SliderAttributes`, `SliderAttributesInput`, `sliderAttributes`, `SliderRange`, `snapSliderValue`, `sliderFraction`, `sliderValueAt`, `SteppedValueOptions`, `steppedValue` | same names | none |
|
|
296
|
+
| `/preact`: `Fader`, `FaderProps` | `Slider`, `SliderProps` | renamed; pointer input through `ui-gesture/dom`; only the primary button drives it, a drag never ends in a click |
|
|
297
|
+
| `/preact`: `Knob`, `KnobProps` | same names | props unchanged; pointer input through `ui-gesture/dom`; only the primary button drives it |
|
|
298
|
+
| `/preact`: `LedButton`, `LedButtonProps` | `ToggleButton`, `ToggleButtonProps` | renamed; pass `indicator="light"` for the light |
|
|
299
|
+
| `/preact`: `Readout`, `ReadoutProps` | same names | none |
|
|
300
|
+
| `/styles.css` | `@ac-kit/ui-common/styles.css`, then `@ac-kit/ui-music/styles.css` | layer and class renames below |
|
|
301
|
+
|
|
302
|
+
The stylesheet's contract changed with the names:
|
|
303
|
+
|
|
304
|
+
| `@ac-kit/ui-controls` | here |
|
|
305
|
+
| ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
|
|
306
|
+
| layer `ack-controls` | `ack.common` (and `ack.music`), after the order statement `@layer ack.common, ack.music;` |
|
|
307
|
+
| — | `ack-control` on every root |
|
|
308
|
+
| `.ack-fader`, `.ack-fader-header`, `-label`, `-value`, `-control`, `-track`, `-range`, `-thumb` | `.ack-slider`, `.ack-slider-header`, `-label`, `-value`, `-control`, `-track`, `-range`, `-thumb` |
|
|
309
|
+
| `--ack-fader-length`, `-track`, `-track-thickness`, `-thumb`, `-thumb-length`, `-thumb-thickness`, `-fraction` | `--ack-slider-length`, `-track`, `-track-thickness`, `-thumb`, `-thumb-length`, `-thumb-thickness`, `-fraction` |
|
|
310
|
+
| `.ack-led-button`, `.ack-led-button-light` | `.ack-toggle-button`, `.ack-toggle-button-light` (drawn only with `indicator="light"`) |
|
|
311
|
+
| `--ack-led-off`, `--ack-led-ink` | `--ack-toggle-button-light-off`, `--ack-toggle-button-ink` |
|
|
312
|
+
| knob and readout classes and properties, shared tokens, `data-*` attributes | unchanged |
|
|
313
|
+
|
|
314
|
+
See the
|
|
315
|
+
[generated API docs](https://anthochamp.pages.grenadine.io/node-essentials/api/ui-common/)
|
|
316
|
+
for the full reference.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ControlTone } from "../tone.js";
|
|
2
|
+
/** How prominent a button is: the main action, a secondary one, or a bare one. */
|
|
3
|
+
export type ButtonVariant = "primary" | "secondary" | "ghost";
|
|
4
|
+
/** A button's size: `large` for a main action on a touch screen. */
|
|
5
|
+
export type ButtonSize = "regular" | "large";
|
|
6
|
+
/**
|
|
7
|
+
* The attributes of a button, keyed by their HTML attribute names: the variant,
|
|
8
|
+
* size and tone the stylesheet draws it by. `data-size` is present for `large`
|
|
9
|
+
* only.
|
|
10
|
+
*/
|
|
11
|
+
export type ButtonAttributes = {
|
|
12
|
+
"data-variant": ButtonVariant;
|
|
13
|
+
"data-size"?: "large";
|
|
14
|
+
"data-tone"?: string;
|
|
15
|
+
};
|
|
16
|
+
/** Input of {@link buttonAttributes}. */
|
|
17
|
+
export type ButtonAttributesInput = {
|
|
18
|
+
/** Defaults to `secondary`. */
|
|
19
|
+
variant?: ButtonVariant;
|
|
20
|
+
/** Defaults to `regular`. */
|
|
21
|
+
size?: ButtonSize;
|
|
22
|
+
tone?: ControlTone;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The attributes of a push button (WAI-ARIA button pattern), for a native
|
|
26
|
+
* `<button>` whose role, focus and activation the browser provides.
|
|
27
|
+
*
|
|
28
|
+
* Time complexity: O(1). Memory: O(1).
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* buttonAttributes({ variant: "primary", size: "large" });
|
|
32
|
+
* // { "data-variant": "primary", "data-size": "large" }
|
|
33
|
+
*/
|
|
34
|
+
export declare function buttonAttributes(input?: ButtonAttributesInput): ButtonAttributes;
|
|
35
|
+
//# sourceMappingURL=button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/button/button.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,kFAAkF;AAClF,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;AAE9D,oEAAoE;AACpE,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;AAE7C;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC9B,cAAc,EAAE,aAAa,CAAC;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,yCAAyC;AACzC,MAAM,MAAM,qBAAqB,GAAG;IACnC,+BAA+B;IAC/B,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,WAAW,CAAC;CACnB,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,GAAE,qBAA0B,GAC/B,gBAAgB,CAWlB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The attributes of a push button (WAI-ARIA button pattern), for a native
|
|
3
|
+
* `<button>` whose role, focus and activation the browser provides.
|
|
4
|
+
*
|
|
5
|
+
* Time complexity: O(1). Memory: O(1).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* buttonAttributes({ variant: "primary", size: "large" });
|
|
9
|
+
* // { "data-variant": "primary", "data-size": "large" }
|
|
10
|
+
*/
|
|
11
|
+
export function buttonAttributes(input = {}) {
|
|
12
|
+
const { variant = "secondary", size = "regular", tone } = input;
|
|
13
|
+
const attributes = { "data-variant": variant };
|
|
14
|
+
if (size === "large") {
|
|
15
|
+
attributes["data-size"] = "large";
|
|
16
|
+
}
|
|
17
|
+
if (tone !== undefined) {
|
|
18
|
+
attributes["data-tone"] = tone;
|
|
19
|
+
}
|
|
20
|
+
return attributes;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/button/button.ts"],"names":[],"mappings":"AA4BA;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAC/B,KAAK,GAA0B,EAAE;IAEjC,MAAM,EAAE,OAAO,GAAG,WAAW,EAAE,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAChE,MAAM,UAAU,GAAqB,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;IACjE,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACtB,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC;IACnC,CAAC;IACD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;IAChC,CAAC;IAED,OAAO,UAAU,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a dialog sits: centred, along the bottom edge, along the inline end, or
|
|
3
|
+
* a sheet (the bottom when narrow, the side when wide).
|
|
4
|
+
*/
|
|
5
|
+
export type DialogPlacement = "center" | "bottom" | "side" | "sheet";
|
|
6
|
+
/** The attributes of a dialog, keyed by their HTML attribute names. */
|
|
7
|
+
export type DialogAttributes = {
|
|
8
|
+
"aria-labelledby": string;
|
|
9
|
+
"aria-describedby"?: string;
|
|
10
|
+
"data-placement": DialogPlacement;
|
|
11
|
+
};
|
|
12
|
+
/** Input of {@link dialogAttributes}. */
|
|
13
|
+
export type DialogAttributesInput = {
|
|
14
|
+
/** The id of the element holding the title. */
|
|
15
|
+
titleId: string;
|
|
16
|
+
/** The id of the element holding the description, when there is one. */
|
|
17
|
+
descriptionId?: string;
|
|
18
|
+
/** Defaults to `center`. */
|
|
19
|
+
placement?: DialogPlacement;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The attributes of a modal dialog (WAI-ARIA dialog pattern), for a native
|
|
23
|
+
* `<dialog>` opened with `showModal()`, whose role, inert page, Escape key and
|
|
24
|
+
* focus return the browser provides.
|
|
25
|
+
*
|
|
26
|
+
* Time complexity: O(1). Memory: O(1).
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* dialogAttributes({ titleId: "t", placement: "sheet" });
|
|
30
|
+
* // { "aria-labelledby": "t", "data-placement": "sheet" }
|
|
31
|
+
*/
|
|
32
|
+
export declare function dialogAttributes(input: DialogAttributesInput): DialogAttributes;
|
|
33
|
+
//# sourceMappingURL=dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/dialog/dialog.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAErE,uEAAuE;AACvE,MAAM,MAAM,gBAAgB,GAAG;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,eAAe,CAAC;CAClC,CAAC;AAEF,yCAAyC;AACzC,MAAM,MAAM,qBAAqB,GAAG;IACnC,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,eAAe,CAAC;CAC5B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,qBAAqB,GAC1B,gBAAgB,CAWlB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The attributes of a modal dialog (WAI-ARIA dialog pattern), for a native
|
|
3
|
+
* `<dialog>` opened with `showModal()`, whose role, inert page, Escape key and
|
|
4
|
+
* focus return the browser provides.
|
|
5
|
+
*
|
|
6
|
+
* Time complexity: O(1). Memory: O(1).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* dialogAttributes({ titleId: "t", placement: "sheet" });
|
|
10
|
+
* // { "aria-labelledby": "t", "data-placement": "sheet" }
|
|
11
|
+
*/
|
|
12
|
+
export function dialogAttributes(input) {
|
|
13
|
+
const { titleId, descriptionId, placement = "center" } = input;
|
|
14
|
+
const attributes = {
|
|
15
|
+
"aria-labelledby": titleId,
|
|
16
|
+
"data-placement": placement,
|
|
17
|
+
};
|
|
18
|
+
if (descriptionId !== undefined) {
|
|
19
|
+
attributes["aria-describedby"] = descriptionId;
|
|
20
|
+
}
|
|
21
|
+
return attributes;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/dialog/dialog.ts"],"names":[],"mappings":"AAuBA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAC/B,KAA4B;IAE5B,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,GAAG,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC/D,MAAM,UAAU,GAAqB;QACpC,iBAAiB,EAAE,OAAO;QAC1B,gBAAgB,EAAE,SAAS;KAC3B,CAAC;IACF,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QACjC,UAAU,CAAC,kBAAkB,CAAC,GAAG,aAAa,CAAC;IAChD,CAAC;IAED,OAAO,UAAU,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What {@link ownsArrowKeys} reads of an element: plain data, so the core needs
|
|
3
|
+
* no DOM.
|
|
4
|
+
*/
|
|
5
|
+
export type ArrowKeyOwnerInput = {
|
|
6
|
+
/** Lower-case tag name: `input`, `textarea`, `select`, `div`, … */
|
|
7
|
+
readonly tagName: string;
|
|
8
|
+
/** An `<input>`'s `type`. */
|
|
9
|
+
readonly type?: string;
|
|
10
|
+
/** The explicit `role` attribute. */
|
|
11
|
+
readonly role?: string;
|
|
12
|
+
readonly isContentEditable?: boolean;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Whether an element uses the arrow keys itself, so a container's roving focus
|
|
16
|
+
* must leave them to it: text-entry inputs (`text`, `search`, `email`, `url`,
|
|
17
|
+
* `tel`, `password`, `number`, the date and time types), `range`, `radio`,
|
|
18
|
+
* `<textarea>`, `<select>`, editable content, and the roles `slider`,
|
|
19
|
+
* `spinbutton`, `radio`, `radiogroup`, `combobox`, `listbox`, `menu`,
|
|
20
|
+
* `menubar`, `tablist`, `tree`, `treegrid`, `grid`, `textbox`. An `<input>`
|
|
21
|
+
* with no `type` is a text input.
|
|
22
|
+
*
|
|
23
|
+
* Time complexity: O(1). Memory: O(1).
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ownsArrowKeys({ tagName: "input", type: "range" }); // true
|
|
27
|
+
* ownsArrowKeys({ tagName: "button" }); // false
|
|
28
|
+
* ownsArrowKeys({ tagName: "div", role: "slider" }); // true
|
|
29
|
+
*/
|
|
30
|
+
export declare function ownsArrowKeys(input: ArrowKeyOwnerInput): boolean;
|
|
31
|
+
//# sourceMappingURL=owns-arrow-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owns-arrow-keys.d.ts","sourceRoot":"","sources":["../../src/focus/owns-arrow-keys.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAChC,mEAAmE;IACnE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6BAA6B;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,qCAAqC;IACrC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CACrC,CAAC;AAmCF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAkBhE"}
|