@ac-kit/ui-common 0.0.0-stage → 0.2.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 +244 -0
- package/LICENSE +28 -0
- package/README.md +633 -2
- 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/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/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 +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -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/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/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/_anchor.d.ts +13 -0
- package/dist/preact/_anchor.d.ts.map +1 -0
- package/dist/preact/_anchor.js +39 -0
- package/dist/preact/_anchor.js.map +1 -0
- package/dist/preact/_dom.d.ts +14 -0
- package/dist/preact/_dom.d.ts.map +1 -0
- package/dist/preact/_dom.js +31 -0
- package/dist/preact/_dom.js.map +1 -0
- package/dist/preact/_live-announcer.d.ts +26 -0
- package/dist/preact/_live-announcer.d.ts.map +1 -0
- package/dist/preact/_live-announcer.js +101 -0
- package/dist/preact/_live-announcer.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 +20 -0
- package/dist/preact/index.d.ts.map +1 -0
- package/dist/preact/index.js +20 -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 +144 -0
- package/dist/preact/knob.js.map +1 -0
- 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 +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/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 +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 +164 -0
- package/dist/preact/slider.js.map +1 -0
- 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/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/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 +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 +142 -0
- package/dist/preact/toolbar.js.map +1 -0
- 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/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/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/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/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/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/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/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/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 +110 -3
- package/styles.css +1883 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { type CallableNoArgs } from "@ac-kit/core";
|
|
2
|
+
import type { ControlTone } from "../tone.js";
|
|
3
|
+
/**
|
|
4
|
+
* How a toast is announced: `polite` waits for the screen reader to finish
|
|
5
|
+
* (`status`), `assertive` interrupts it (`alert`), for what needs attention
|
|
6
|
+
* now, such as a failure.
|
|
7
|
+
*/
|
|
8
|
+
export type ToastUrgency = "polite" | "assertive";
|
|
9
|
+
/** The one action a toast offers, such as Undo. */
|
|
10
|
+
export type ToastAction = {
|
|
11
|
+
readonly label: string;
|
|
12
|
+
/** Called when it is pressed; the toast is dismissed then. */
|
|
13
|
+
readonly onAction: CallableNoArgs;
|
|
14
|
+
};
|
|
15
|
+
/** What a toast says. Every text is the caller's: the library ships none. */
|
|
16
|
+
export type ToastContent = {
|
|
17
|
+
readonly title: string;
|
|
18
|
+
readonly description?: string;
|
|
19
|
+
readonly tone?: ControlTone;
|
|
20
|
+
/**
|
|
21
|
+
* A toast with an action stays until dismissed, unless given a duration: a
|
|
22
|
+
* person who needs longer to reach it, through the keyboard or a screen
|
|
23
|
+
* reader, still can.
|
|
24
|
+
*/
|
|
25
|
+
readonly action?: ToastAction;
|
|
26
|
+
/** Defaults to `polite`. */
|
|
27
|
+
readonly urgency?: ToastUrgency;
|
|
28
|
+
};
|
|
29
|
+
/** A toast in a {@link ToastQueue}. */
|
|
30
|
+
export type Toast = ToastContent & {
|
|
31
|
+
readonly id: string;
|
|
32
|
+
/** How long it shows once visible, clocks paused excepted, in ms. */
|
|
33
|
+
readonly durationMs: number;
|
|
34
|
+
/**
|
|
35
|
+
* Grows each time the toast is shown again with its id, so an adapter
|
|
36
|
+
* announces the new content.
|
|
37
|
+
*/
|
|
38
|
+
readonly revision: number;
|
|
39
|
+
};
|
|
40
|
+
/** Options of {@link ToastQueue.show}. */
|
|
41
|
+
export type ToastShowOptions = {
|
|
42
|
+
/**
|
|
43
|
+
* Shows it in place of the toast with this id, if there is one, with its time
|
|
44
|
+
* started again: "Saving…" becoming "Saved". Defaults to a new id.
|
|
45
|
+
*/
|
|
46
|
+
readonly id?: string;
|
|
47
|
+
/**
|
|
48
|
+
* How long it shows once visible, in ms; `Infinity` until dismissed. Defaults
|
|
49
|
+
* to the queue's, or `Infinity` for a toast with an action.
|
|
50
|
+
*/
|
|
51
|
+
readonly durationMs?: number;
|
|
52
|
+
};
|
|
53
|
+
/** Options of {@link ToastQueue}. */
|
|
54
|
+
export type ToastQueueOptions = {
|
|
55
|
+
/** How many toasts show at once; the others wait their turn. Defaults to 3. */
|
|
56
|
+
readonly limit?: number;
|
|
57
|
+
/**
|
|
58
|
+
* How long a toast shows by default, in ms; `Infinity` until dismissed.
|
|
59
|
+
* Defaults to 6000. Let people lengthen it (WCAG 2.2.1, timing adjustable).
|
|
60
|
+
*/
|
|
61
|
+
readonly durationMs?: number;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Brief messages about what an application did — saved, sent, failed — shown a
|
|
65
|
+
* few at a time, each until its duration has run or it is dismissed. The
|
|
66
|
+
* framework-free state of a toaster: an adapter renders `visible`, announces
|
|
67
|
+
* each toast as it becomes visible, runs a timer to `deadline` and calls
|
|
68
|
+
* `advance` then. Every time is passed in, in ms of one clock.
|
|
69
|
+
*
|
|
70
|
+
* Only visible toasts' clocks run, and none while a reason pauses the queue:
|
|
71
|
+
* the pointer over the toasts, focus among them, the page hidden. So a person
|
|
72
|
+
* reading or reaching a toast does not see it go.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* const toasts = new ToastQueue();
|
|
76
|
+
* const id = toasts.show({ title: "Saving…" }, performance.now(), {
|
|
77
|
+
* durationMs: Infinity,
|
|
78
|
+
* });
|
|
79
|
+
* toasts.show({ title: "Saved", tone: "positive" }, performance.now(), {
|
|
80
|
+
* id,
|
|
81
|
+
* });
|
|
82
|
+
*/
|
|
83
|
+
export declare class ToastQueue {
|
|
84
|
+
private readonly limit_;
|
|
85
|
+
private readonly durationMs_;
|
|
86
|
+
private readonly entries_;
|
|
87
|
+
private readonly pauses_;
|
|
88
|
+
private readonly listeners_;
|
|
89
|
+
private nextId_;
|
|
90
|
+
private revision_;
|
|
91
|
+
private toasts_;
|
|
92
|
+
/**
|
|
93
|
+
* @throws {RangeError} When `limit` is not a positive safe integer, or
|
|
94
|
+
* `durationMs` is negative or `NaN`.
|
|
95
|
+
*/
|
|
96
|
+
constructor(options?: ToastQueueOptions);
|
|
97
|
+
/** Every toast, in the order shown: the visible ones first. */
|
|
98
|
+
get toasts(): readonly Toast[];
|
|
99
|
+
/** The toasts on screen: the first `limit`. */
|
|
100
|
+
get visible(): readonly Toast[];
|
|
101
|
+
/** Whether a reason pauses every clock. */
|
|
102
|
+
get isPaused(): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* When the next visible toast's time runs out, in the caller's clock;
|
|
105
|
+
* `undefined` while paused, or when no visible toast has a finite duration.
|
|
106
|
+
*/
|
|
107
|
+
get deadline(): number | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Shows `content` at `time`, after the toasts already queued, or in place of
|
|
110
|
+
* the toast with `options.id`. Returns its id.
|
|
111
|
+
*
|
|
112
|
+
* @throws {RangeError} When `time` is not finite, `durationMs` is negative or
|
|
113
|
+
* `NaN`, or `id` is empty.
|
|
114
|
+
*/
|
|
115
|
+
show(content: ToastContent, time: number, options?: ToastShowOptions): string;
|
|
116
|
+
/**
|
|
117
|
+
* Removes the toast with `id` at `time`; the next waiting one shows then.
|
|
118
|
+
* Returns whether the queue had it.
|
|
119
|
+
*
|
|
120
|
+
* @throws {RangeError} When `time` is not finite.
|
|
121
|
+
*/
|
|
122
|
+
dismiss(id: string, time: number): boolean;
|
|
123
|
+
/** Removes every toast. No clock is left to restart, so it takes no time. */
|
|
124
|
+
clear(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Pauses every clock for `reason` at `time`, or lifts that reason; the clocks
|
|
127
|
+
* run while no reason is left. Reasons are the caller's names, such as
|
|
128
|
+
* `"hover"`, `"focus"` and `"hidden"`.
|
|
129
|
+
*
|
|
130
|
+
* @throws {RangeError} When `time` is not finite.
|
|
131
|
+
*/
|
|
132
|
+
setPaused(reason: string, isPaused: boolean, time: number): void;
|
|
133
|
+
/**
|
|
134
|
+
* Removes, at `time`, the visible toasts whose time has run out, and starts
|
|
135
|
+
* the clocks of those that show in their place.
|
|
136
|
+
*
|
|
137
|
+
* @throws {RangeError} When `time` is not finite.
|
|
138
|
+
*/
|
|
139
|
+
advance(time: number): void;
|
|
140
|
+
/**
|
|
141
|
+
* Calls `listener` after each change of the toasts or their clocks, until the
|
|
142
|
+
* returned subscription is disposed or `options.signal` aborts.
|
|
143
|
+
*/
|
|
144
|
+
subscribe(listener: CallableNoArgs, options?: {
|
|
145
|
+
readonly signal?: AbortSignal;
|
|
146
|
+
}): Disposable;
|
|
147
|
+
private generateId_;
|
|
148
|
+
/** Stops or starts each clock as visibility and pauses say. */
|
|
149
|
+
private startClocks_;
|
|
150
|
+
private settle_;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Where the toasts gather on the screen: its top or bottom, at the start,
|
|
154
|
+
* centre or end of a line.
|
|
155
|
+
*/
|
|
156
|
+
export type ToasterPosition = "top-start" | "top-center" | "top-end" | "bottom-start" | "bottom-center" | "bottom-end";
|
|
157
|
+
/** The attributes of a toaster, the region holding the toasts. */
|
|
158
|
+
export type ToasterAttributes = {
|
|
159
|
+
role: "region";
|
|
160
|
+
"aria-label": string;
|
|
161
|
+
tabindex: -1;
|
|
162
|
+
"data-position": ToasterPosition;
|
|
163
|
+
};
|
|
164
|
+
/** Input of {@link toasterAttributes}. */
|
|
165
|
+
export type ToasterAttributesInput = {
|
|
166
|
+
/** Its accessible name, which may say its shortcut: "Notifications (F8)". */
|
|
167
|
+
label: string;
|
|
168
|
+
/** Defaults to `bottom-end`. */
|
|
169
|
+
position?: ToasterPosition;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* The attributes of a toaster: a landmark region named by `label`, so a screen
|
|
173
|
+
* reader user finds the toasts, and focusable by script, so a shortcut can take
|
|
174
|
+
* focus to them.
|
|
175
|
+
*
|
|
176
|
+
* Time complexity: O(1). Memory: O(1).
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* toasterAttributes({ label: "Notifications" });
|
|
180
|
+
* // { role: "region", "aria-label": "Notifications", tabindex: -1,
|
|
181
|
+
* // "data-position": "bottom-end" }
|
|
182
|
+
*/
|
|
183
|
+
export declare function toasterAttributes(input: ToasterAttributesInput): ToasterAttributes;
|
|
184
|
+
/** The attributes of one toast, keyed by their HTML attribute names. */
|
|
185
|
+
export type ToastAttributes = {
|
|
186
|
+
"data-urgency": ToastUrgency;
|
|
187
|
+
"data-tone"?: string;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* The attributes of one toast: its urgency and its tone, for the stylesheet.
|
|
191
|
+
*
|
|
192
|
+
* Time complexity: O(1). Memory: O(1).
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* toastAttributes({ title: "Failed", tone: "negative", urgency: "assertive" });
|
|
196
|
+
* // { "data-urgency": "assertive", "data-tone": "negative" }
|
|
197
|
+
*/
|
|
198
|
+
export declare function toastAttributes(content: ToastContent): ToastAttributes;
|
|
199
|
+
/**
|
|
200
|
+
* What a screen reader announces of a toast, one line each: its title, its
|
|
201
|
+
* description, its action's label (so a person knows there is one to reach). A
|
|
202
|
+
* live region reads them as they appear; the toast itself is not one, so it is
|
|
203
|
+
* not read twice.
|
|
204
|
+
*
|
|
205
|
+
* Time complexity: O(1). Memory: O(1).
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* toastAnnouncement({ title: "Deleted", description: "3 files" });
|
|
209
|
+
* // ["Deleted", "3 files"]
|
|
210
|
+
*/
|
|
211
|
+
export declare function toastAnnouncement(content: ToastContent): readonly string[];
|
|
212
|
+
//# sourceMappingURL=toast-queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast-queue.d.ts","sourceRoot":"","sources":["../../src/toast/toast-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,cAAc,EACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,WAAW,CAAC;AAElD,mDAAmD;AACnD,MAAM,MAAM,WAAW,GAAG;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,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AAiB,GAAG;IAC/B,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,CAAC,CAAC;IACb,eAAe,EAAE,eAAe,CAAC;CACjC,CAAC;AAEF,0CAA0C;AAC1C,MAAM,MAAM,sBAAsB,GAAG;IACpC,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,sBAAsB,GAC3B,iBAAiB,CAOnB;AAED,wEAAwE;AACxE,MAAM,MAAM,eAAe,GAAG;IAC7B,cAAc,EAAE,YAAY,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,eAAe,CAStE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,MAAM,EAAE,CAU1E"}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { assertFinite, assertInteger, assertNonNegative, } from "@ac-kit/core";
|
|
2
|
+
/**
|
|
3
|
+
* Brief messages about what an application did — saved, sent, failed — shown a
|
|
4
|
+
* few at a time, each until its duration has run or it is dismissed. The
|
|
5
|
+
* framework-free state of a toaster: an adapter renders `visible`, announces
|
|
6
|
+
* each toast as it becomes visible, runs a timer to `deadline` and calls
|
|
7
|
+
* `advance` then. Every time is passed in, in ms of one clock.
|
|
8
|
+
*
|
|
9
|
+
* Only visible toasts' clocks run, and none while a reason pauses the queue:
|
|
10
|
+
* the pointer over the toasts, focus among them, the page hidden. So a person
|
|
11
|
+
* reading or reaching a toast does not see it go.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const toasts = new ToastQueue();
|
|
15
|
+
* const id = toasts.show({ title: "Saving…" }, performance.now(), {
|
|
16
|
+
* durationMs: Infinity,
|
|
17
|
+
* });
|
|
18
|
+
* toasts.show({ title: "Saved", tone: "positive" }, performance.now(), {
|
|
19
|
+
* id,
|
|
20
|
+
* });
|
|
21
|
+
*/
|
|
22
|
+
export class ToastQueue {
|
|
23
|
+
limit_;
|
|
24
|
+
durationMs_;
|
|
25
|
+
entries_ = [];
|
|
26
|
+
pauses_ = new Set();
|
|
27
|
+
listeners_ = new Set();
|
|
28
|
+
nextId_ = 1;
|
|
29
|
+
revision_ = 0;
|
|
30
|
+
toasts_ = [];
|
|
31
|
+
/**
|
|
32
|
+
* @throws {RangeError} When `limit` is not a positive safe integer, or
|
|
33
|
+
* `durationMs` is negative or `NaN`.
|
|
34
|
+
*/
|
|
35
|
+
constructor(options = {}) {
|
|
36
|
+
const { limit = 3, durationMs = 6000 } = options;
|
|
37
|
+
assertInteger(limit, "limit", 1);
|
|
38
|
+
assertNonNegative(durationMs, "durationMs", { isInfinityAllowed: true });
|
|
39
|
+
this.limit_ = limit;
|
|
40
|
+
this.durationMs_ = durationMs;
|
|
41
|
+
}
|
|
42
|
+
/** Every toast, in the order shown: the visible ones first. */
|
|
43
|
+
get toasts() {
|
|
44
|
+
return this.toasts_;
|
|
45
|
+
}
|
|
46
|
+
/** The toasts on screen: the first `limit`. */
|
|
47
|
+
get visible() {
|
|
48
|
+
return this.toasts_.slice(0, this.limit_);
|
|
49
|
+
}
|
|
50
|
+
/** Whether a reason pauses every clock. */
|
|
51
|
+
get isPaused() {
|
|
52
|
+
return this.pauses_.size > 0;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* When the next visible toast's time runs out, in the caller's clock;
|
|
56
|
+
* `undefined` while paused, or when no visible toast has a finite duration.
|
|
57
|
+
*/
|
|
58
|
+
get deadline() {
|
|
59
|
+
let deadline;
|
|
60
|
+
for (const { remainingMs, runningSince } of this.entries_) {
|
|
61
|
+
if (runningSince !== undefined && remainingMs < Infinity) {
|
|
62
|
+
const end = runningSince + remainingMs;
|
|
63
|
+
if (deadline === undefined || end < deadline) {
|
|
64
|
+
deadline = end;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return deadline;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Shows `content` at `time`, after the toasts already queued, or in place of
|
|
72
|
+
* the toast with `options.id`. Returns its id.
|
|
73
|
+
*
|
|
74
|
+
* @throws {RangeError} When `time` is not finite, `durationMs` is negative or
|
|
75
|
+
* `NaN`, or `id` is empty.
|
|
76
|
+
*/
|
|
77
|
+
show(content, time, options = {}) {
|
|
78
|
+
assertFinite(time, "time");
|
|
79
|
+
const { id: requestedId, durationMs: requested } = options;
|
|
80
|
+
if (requestedId === "") {
|
|
81
|
+
throw new RangeError("id must not be empty");
|
|
82
|
+
}
|
|
83
|
+
const durationMs = requested ?? (content.action === undefined ? this.durationMs_ : Infinity);
|
|
84
|
+
assertNonNegative(durationMs, "durationMs", { isInfinityAllowed: true });
|
|
85
|
+
this.revision_ += 1;
|
|
86
|
+
const existing = requestedId === undefined
|
|
87
|
+
? undefined
|
|
88
|
+
: this.entries_.find((entry) => entry.toast.id === requestedId);
|
|
89
|
+
const id = requestedId ?? this.generateId_();
|
|
90
|
+
const toast = {
|
|
91
|
+
...content,
|
|
92
|
+
id,
|
|
93
|
+
durationMs,
|
|
94
|
+
revision: this.revision_,
|
|
95
|
+
};
|
|
96
|
+
if (existing === undefined) {
|
|
97
|
+
this.entries_.push({
|
|
98
|
+
toast,
|
|
99
|
+
remainingMs: durationMs,
|
|
100
|
+
runningSince: undefined,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
existing.toast = toast;
|
|
105
|
+
existing.remainingMs = durationMs;
|
|
106
|
+
existing.runningSince = undefined;
|
|
107
|
+
}
|
|
108
|
+
this.settle_(time);
|
|
109
|
+
return id;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Removes the toast with `id` at `time`; the next waiting one shows then.
|
|
113
|
+
* Returns whether the queue had it.
|
|
114
|
+
*
|
|
115
|
+
* @throws {RangeError} When `time` is not finite.
|
|
116
|
+
*/
|
|
117
|
+
dismiss(id, time) {
|
|
118
|
+
assertFinite(time, "time");
|
|
119
|
+
const index = this.entries_.findIndex((entry) => entry.toast.id === id);
|
|
120
|
+
if (index === -1) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
this.entries_.splice(index, 1);
|
|
124
|
+
this.settle_(time);
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
/** Removes every toast. No clock is left to restart, so it takes no time. */
|
|
128
|
+
clear() {
|
|
129
|
+
if (this.entries_.length === 0) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
this.entries_.length = 0;
|
|
133
|
+
this.settle_(0);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Pauses every clock for `reason` at `time`, or lifts that reason; the clocks
|
|
137
|
+
* run while no reason is left. Reasons are the caller's names, such as
|
|
138
|
+
* `"hover"`, `"focus"` and `"hidden"`.
|
|
139
|
+
*
|
|
140
|
+
* @throws {RangeError} When `time` is not finite.
|
|
141
|
+
*/
|
|
142
|
+
setPaused(reason, isPaused, time) {
|
|
143
|
+
assertFinite(time, "time");
|
|
144
|
+
const wasPaused = this.isPaused;
|
|
145
|
+
if (isPaused) {
|
|
146
|
+
this.pauses_.add(reason);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
this.pauses_.delete(reason);
|
|
150
|
+
}
|
|
151
|
+
if (wasPaused !== this.isPaused) {
|
|
152
|
+
this.settle_(time);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Removes, at `time`, the visible toasts whose time has run out, and starts
|
|
157
|
+
* the clocks of those that show in their place.
|
|
158
|
+
*
|
|
159
|
+
* @throws {RangeError} When `time` is not finite.
|
|
160
|
+
*/
|
|
161
|
+
advance(time) {
|
|
162
|
+
assertFinite(time, "time");
|
|
163
|
+
let isChanged = false;
|
|
164
|
+
for (;;) {
|
|
165
|
+
const index = this.entries_.findIndex(({ remainingMs, runningSince }) => runningSince !== undefined && runningSince + remainingMs <= time);
|
|
166
|
+
if (index === -1) {
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
this.entries_.splice(index, 1);
|
|
170
|
+
this.startClocks_(time);
|
|
171
|
+
isChanged = true;
|
|
172
|
+
}
|
|
173
|
+
if (isChanged) {
|
|
174
|
+
this.settle_(time);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Calls `listener` after each change of the toasts or their clocks, until the
|
|
179
|
+
* returned subscription is disposed or `options.signal` aborts.
|
|
180
|
+
*/
|
|
181
|
+
subscribe(listener, options = {}) {
|
|
182
|
+
const { signal } = options;
|
|
183
|
+
const unsubscribe = () => {
|
|
184
|
+
this.listeners_.delete(listener);
|
|
185
|
+
};
|
|
186
|
+
if (signal?.aborted === true) {
|
|
187
|
+
return { [Symbol.dispose]: unsubscribe };
|
|
188
|
+
}
|
|
189
|
+
this.listeners_.add(listener);
|
|
190
|
+
signal?.addEventListener("abort", unsubscribe, { once: true });
|
|
191
|
+
return {
|
|
192
|
+
[Symbol.dispose]() {
|
|
193
|
+
signal?.removeEventListener("abort", unsubscribe);
|
|
194
|
+
unsubscribe();
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
generateId_() {
|
|
199
|
+
for (;;) {
|
|
200
|
+
const id = `toast-${String(this.nextId_)}`;
|
|
201
|
+
this.nextId_ += 1;
|
|
202
|
+
if (!this.entries_.some((entry) => entry.toast.id === id)) {
|
|
203
|
+
return id;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/** Stops or starts each clock as visibility and pauses say. */
|
|
208
|
+
startClocks_(time) {
|
|
209
|
+
const isRunning = !this.isPaused;
|
|
210
|
+
for (const [index, entry] of this.entries_.entries()) {
|
|
211
|
+
const shouldRun = isRunning && index < this.limit_;
|
|
212
|
+
if (shouldRun && entry.runningSince === undefined) {
|
|
213
|
+
entry.runningSince = time;
|
|
214
|
+
}
|
|
215
|
+
else if (!shouldRun && entry.runningSince !== undefined) {
|
|
216
|
+
entry.remainingMs = Math.max(0, entry.remainingMs - (time - entry.runningSince));
|
|
217
|
+
entry.runningSince = undefined;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
settle_(time) {
|
|
222
|
+
this.startClocks_(time);
|
|
223
|
+
this.toasts_ = this.entries_.map((entry) => entry.toast);
|
|
224
|
+
// A copy: a listener may unsubscribe while they are called.
|
|
225
|
+
for (const listener of Array.from(this.listeners_)) {
|
|
226
|
+
listener();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* The attributes of a toaster: a landmark region named by `label`, so a screen
|
|
232
|
+
* reader user finds the toasts, and focusable by script, so a shortcut can take
|
|
233
|
+
* focus to them.
|
|
234
|
+
*
|
|
235
|
+
* Time complexity: O(1). Memory: O(1).
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* toasterAttributes({ label: "Notifications" });
|
|
239
|
+
* // { role: "region", "aria-label": "Notifications", tabindex: -1,
|
|
240
|
+
* // "data-position": "bottom-end" }
|
|
241
|
+
*/
|
|
242
|
+
export function toasterAttributes(input) {
|
|
243
|
+
return {
|
|
244
|
+
role: "region",
|
|
245
|
+
"aria-label": input.label,
|
|
246
|
+
tabindex: -1,
|
|
247
|
+
"data-position": input.position ?? "bottom-end",
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* The attributes of one toast: its urgency and its tone, for the stylesheet.
|
|
252
|
+
*
|
|
253
|
+
* Time complexity: O(1). Memory: O(1).
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* toastAttributes({ title: "Failed", tone: "negative", urgency: "assertive" });
|
|
257
|
+
* // { "data-urgency": "assertive", "data-tone": "negative" }
|
|
258
|
+
*/
|
|
259
|
+
export function toastAttributes(content) {
|
|
260
|
+
const attributes = {
|
|
261
|
+
"data-urgency": content.urgency ?? "polite",
|
|
262
|
+
};
|
|
263
|
+
if (content.tone !== undefined) {
|
|
264
|
+
attributes["data-tone"] = content.tone;
|
|
265
|
+
}
|
|
266
|
+
return attributes;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* What a screen reader announces of a toast, one line each: its title, its
|
|
270
|
+
* description, its action's label (so a person knows there is one to reach). A
|
|
271
|
+
* live region reads them as they appear; the toast itself is not one, so it is
|
|
272
|
+
* not read twice.
|
|
273
|
+
*
|
|
274
|
+
* Time complexity: O(1). Memory: O(1).
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* toastAnnouncement({ title: "Deleted", description: "3 files" });
|
|
278
|
+
* // ["Deleted", "3 files"]
|
|
279
|
+
*/
|
|
280
|
+
export function toastAnnouncement(content) {
|
|
281
|
+
const lines = [content.title];
|
|
282
|
+
if (content.description !== undefined) {
|
|
283
|
+
lines.push(content.description);
|
|
284
|
+
}
|
|
285
|
+
if (content.action !== undefined) {
|
|
286
|
+
lines.push(content.action.label);
|
|
287
|
+
}
|
|
288
|
+
return lines;
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=toast-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast-queue.js","sourceRoot":"","sources":["../../src/toast/toast-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,EACZ,aAAa,EACb,iBAAiB,GAEjB,MAAM,cAAc,CAAC;AA6EtB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,UAAU;IACL,MAAM,CAAS;IACf,WAAW,CAAS;IACpB,QAAQ,GAAa,EAAE,CAAC;IACxB,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAC5B,UAAU,GAAG,IAA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I,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A box on the screen: a `DOMRectReadOnly` from `getBoundingClientRect()` fits,
|
|
3
|
+
* or any record of the same numbers.
|
|
4
|
+
*/
|
|
5
|
+
export type ScreenRect = {
|
|
6
|
+
readonly x: number;
|
|
7
|
+
readonly y: number;
|
|
8
|
+
readonly width: number;
|
|
9
|
+
readonly height: number;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Whether any of the `toasts` covers part of `target`, the focused control: the
|
|
13
|
+
* toaster then fades its toasts, so a focused control is never hidden by them
|
|
14
|
+
* (WCAG 2.2 success criterion 2.4.11, focus not obscured). Edges that only
|
|
15
|
+
* touch do not cover; an empty box covers nothing.
|
|
16
|
+
*
|
|
17
|
+
* Time complexity: O(n) for n toasts. Memory: O(1).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* toastsObscure({ x: 0, y: 0, width: 10, height: 10 }, [
|
|
21
|
+
* { x: 5, y: 5, width: 10, height: 10 },
|
|
22
|
+
* ]); // true
|
|
23
|
+
*/
|
|
24
|
+
export declare function toastsObscure(target: ScreenRect, toasts: Iterable<ScreenRect>): boolean;
|
|
25
|
+
//# sourceMappingURL=toasts-obscure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toasts-obscure.d.ts","sourceRoot":"","sources":["../../src/toast/toasts-obscure.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACxB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB,CAAC;AAOF;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAC5B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,GAC1B,OAAO,CAWT"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { box2Area, box2Create, box2FromXywh, box2Intersection, } from "@ac-kit/math-geometry";
|
|
2
|
+
// Scratch boxes: the call allocates nothing.
|
|
3
|
+
const TARGET_ = box2Create();
|
|
4
|
+
const COVER_ = box2Create();
|
|
5
|
+
const COMMON_ = box2Create();
|
|
6
|
+
/**
|
|
7
|
+
* Whether any of the `toasts` covers part of `target`, the focused control: the
|
|
8
|
+
* toaster then fades its toasts, so a focused control is never hidden by them
|
|
9
|
+
* (WCAG 2.2 success criterion 2.4.11, focus not obscured). Edges that only
|
|
10
|
+
* touch do not cover; an empty box covers nothing.
|
|
11
|
+
*
|
|
12
|
+
* Time complexity: O(n) for n toasts. Memory: O(1).
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* toastsObscure({ x: 0, y: 0, width: 10, height: 10 }, [
|
|
16
|
+
* { x: 5, y: 5, width: 10, height: 10 },
|
|
17
|
+
* ]); // true
|
|
18
|
+
*/
|
|
19
|
+
export function toastsObscure(target, toasts) {
|
|
20
|
+
box2FromXywh(TARGET_, target.x, target.y, target.width, target.height);
|
|
21
|
+
for (const toast of toasts) {
|
|
22
|
+
box2FromXywh(COVER_, toast.x, toast.y, toast.width, toast.height);
|
|
23
|
+
box2Intersection(COMMON_, TARGET_, COVER_);
|
|
24
|
+
if (box2Area(COMMON_) > 0) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=toasts-obscure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toasts-obscure.js","sourceRoot":"","sources":["../../src/toast/toasts-obscure.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,gBAAgB,GAChB,MAAM,uBAAuB,CAAC;AAa/B,6CAA6C;AAC7C,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAC7B,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;AAC5B,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAE7B;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAC5B,MAAkB,EAClB,MAA4B;IAE5B,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACvE,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC5B,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAClE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAC3C,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ControlTone } from "../tone.js";
|
|
2
|
+
/**
|
|
3
|
+
* Whether a toggle button draws a light: the hardware look of a mute or loop
|
|
4
|
+
* button, or none.
|
|
5
|
+
*/
|
|
6
|
+
export type ToggleButtonIndicator = "light" | "none";
|
|
7
|
+
/**
|
|
8
|
+
* The attributes of a toggle button, keyed by their HTML attribute names: a
|
|
9
|
+
* `button` announced as pressed or not, and the state, indicator and tone the
|
|
10
|
+
* stylesheet draws it by.
|
|
11
|
+
*/
|
|
12
|
+
export type ToggleButtonAttributes = {
|
|
13
|
+
"aria-pressed": "true" | "false";
|
|
14
|
+
"data-state": "on" | "off";
|
|
15
|
+
"data-indicator": ToggleButtonIndicator;
|
|
16
|
+
"data-tone"?: string;
|
|
17
|
+
};
|
|
18
|
+
/** Input of {@link toggleButtonAttributes}. */
|
|
19
|
+
export type ToggleButtonAttributesInput = {
|
|
20
|
+
isOn: boolean;
|
|
21
|
+
tone?: ControlTone;
|
|
22
|
+
/** Defaults to `none`. */
|
|
23
|
+
indicator?: ToggleButtonIndicator;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The attributes of a latching toggle button — one press turns it on, the next
|
|
27
|
+
* turns it off, like a hardware mute, loop or metronome button. Render it as a
|
|
28
|
+
* native `<button type="button">`, whose Space and Enter activation the toggle
|
|
29
|
+
* relies on; activating it reports `!isOn` and leaves the caller to pass the
|
|
30
|
+
* new state back.
|
|
31
|
+
*
|
|
32
|
+
* Time complexity: O(1). Memory: O(1).
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* toggleButtonAttributes({
|
|
36
|
+
* isOn: true,
|
|
37
|
+
* tone: "warning",
|
|
38
|
+
* indicator: "light",
|
|
39
|
+
* });
|
|
40
|
+
* // { "aria-pressed": "true", "data-state": "on", "data-indicator": "light",
|
|
41
|
+
* // "data-tone": "warning" }
|
|
42
|
+
*/
|
|
43
|
+
export declare function toggleButtonAttributes(input: ToggleButtonAttributesInput): ToggleButtonAttributes;
|
|
44
|
+
//# sourceMappingURL=toggle-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle-button.d.ts","sourceRoot":"","sources":["../../src/toggle-button/toggle-button.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,MAAM,CAAC;AAErD;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACpC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC;IACjC,YAAY,EAAE,IAAI,GAAG,KAAK,CAAC;IAC3B,gBAAgB,EAAE,qBAAqB,CAAC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,+CAA+C;AAC/C,MAAM,MAAM,2BAA2B,GAAG;IACzC,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,0BAA0B;IAC1B,SAAS,CAAC,EAAE,qBAAqB,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,2BAA2B,GAChC,sBAAsB,CAYxB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The attributes of a latching toggle button — one press turns it on, the next
|
|
3
|
+
* turns it off, like a hardware mute, loop or metronome button. Render it as a
|
|
4
|
+
* native `<button type="button">`, whose Space and Enter activation the toggle
|
|
5
|
+
* relies on; activating it reports `!isOn` and leaves the caller to pass the
|
|
6
|
+
* new state back.
|
|
7
|
+
*
|
|
8
|
+
* Time complexity: O(1). Memory: O(1).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* toggleButtonAttributes({
|
|
12
|
+
* isOn: true,
|
|
13
|
+
* tone: "warning",
|
|
14
|
+
* indicator: "light",
|
|
15
|
+
* });
|
|
16
|
+
* // { "aria-pressed": "true", "data-state": "on", "data-indicator": "light",
|
|
17
|
+
* // "data-tone": "warning" }
|
|
18
|
+
*/
|
|
19
|
+
export function toggleButtonAttributes(input) {
|
|
20
|
+
const { isOn, tone, indicator = "none" } = input;
|
|
21
|
+
const attributes = {
|
|
22
|
+
"aria-pressed": isOn ? "true" : "false",
|
|
23
|
+
"data-state": isOn ? "on" : "off",
|
|
24
|
+
"data-indicator": indicator,
|
|
25
|
+
};
|
|
26
|
+
if (tone !== undefined) {
|
|
27
|
+
attributes["data-tone"] = tone;
|
|
28
|
+
}
|
|
29
|
+
return attributes;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=toggle-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle-button.js","sourceRoot":"","sources":["../../src/toggle-button/toggle-button.ts"],"names":[],"mappings":"AA4BA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,sBAAsB,CACrC,KAAkC;IAElC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC;IACjD,MAAM,UAAU,GAA2B;QAC1C,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;QACvC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;QACjC,gBAAgB,EAAE,SAAS;KAC3B,CAAC;IACF,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;IAChC,CAAC;IAED,OAAO,UAAU,CAAC;AACnB,CAAC"}
|