dssoca 0.19.0 → 0.20.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/README.md +3 -3
- package/dist/chart-nav.d.ts +13 -0
- package/dist/chart-nav.js +35 -0
- package/dist/components/Accordion.svelte +7 -2
- package/dist/components/Badge.svelte +12 -7
- package/dist/components/Badge.svelte.d.ts +2 -1
- package/dist/components/BoxPlot.svelte +33 -7
- package/dist/components/BumpChart.svelte +68 -26
- package/dist/components/Button.svelte +23 -1
- package/dist/components/Button.svelte.d.ts +5 -1
- package/dist/components/Card.svelte +32 -14
- package/dist/components/Card.svelte.d.ts +4 -1
- package/dist/components/Chart.svelte +169 -32
- package/dist/components/Chart.svelte.d.ts +13 -1
- package/dist/components/DateField.svelte +1 -1
- package/dist/components/FileDrop.svelte +81 -14
- package/dist/components/FileDrop.svelte.d.ts +6 -0
- package/dist/components/Heatmap.svelte +128 -50
- package/dist/components/Heatmap.svelte.d.ts +2 -1
- package/dist/components/Icon.svelte +12 -3
- package/dist/components/Icon.svelte.d.ts +4 -0
- package/dist/components/Input.svelte +3 -3
- package/dist/components/Link.svelte +25 -14
- package/dist/components/LogStream.svelte +34 -9
- package/dist/components/Menu.svelte +12 -8
- package/dist/components/Menu.svelte.d.ts +2 -2
- package/dist/components/MetricTile.svelte +11 -1
- package/dist/components/MetricTile.svelte.d.ts +6 -0
- package/dist/components/Modal.svelte +47 -7
- package/dist/components/Modal.svelte.d.ts +11 -3
- package/dist/components/NumberField.svelte +33 -10
- package/dist/components/Pagination.svelte +7 -4
- package/dist/components/ScatterPlot.svelte +44 -7
- package/dist/components/SearchPalette.svelte +99 -23
- package/dist/components/SearchPalette.svelte.d.ts +5 -0
- package/dist/components/SegmentedControl.svelte +14 -5
- package/dist/components/Select.svelte +3 -4
- package/dist/components/ServiceCard.svelte +105 -68
- package/dist/components/ServiceCard.svelte.d.ts +8 -3
- package/dist/components/ShortcutsHelp.svelte +1 -1
- package/dist/components/Sidebar.svelte +41 -58
- package/dist/components/Switch.svelte +4 -8
- package/dist/components/Table.svelte +20 -13
- package/dist/components/Table.svelte.d.ts +6 -2
- package/dist/components/Textarea.svelte +1 -1
- package/dist/components/TierList.svelte +9 -13
- package/dist/components/Toaster.svelte +143 -21
- package/dist/components/Tooltip.svelte +101 -13
- package/dist/components/Tooltip.svelte.d.ts +1 -1
- package/dist/components/Topbar.svelte +21 -16
- package/dist/icons.d.ts +19 -2
- package/dist/icons.js +42 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/tierlist-core.d.ts +15 -5
- package/dist/tierlist-core.js +30 -7
- package/dist/vanilla/accordion.js +7 -3
- package/dist/vanilla/fields.js +19 -6
- package/dist/vanilla/index.d.ts +1 -1
- package/dist/vanilla/index.js +4 -4
- package/dist/vanilla/menu.js +12 -1
- package/dist/vanilla/modal.d.ts +4 -0
- package/dist/vanilla/modal.js +57 -2
- package/dist/vanilla/segmented.js +13 -4
- package/dist/vanilla/tierlist.js +7 -11
- package/dist/vanilla/toast.d.ts +11 -3
- package/dist/vanilla/toast.js +124 -10
- package/dist/vanilla/tooltip.d.ts +5 -1
- package/dist/vanilla/tooltip.js +57 -10
- package/dist/vanilla.css +326 -118
- package/package.json +1 -1
package/dist/vanilla/toast.js
CHANGED
|
@@ -7,13 +7,21 @@
|
|
|
7
7
|
* toasts.dismiss(id) / clear() / update(id, patch) / max
|
|
8
8
|
*
|
|
9
9
|
* The stack lives in the first `.ss-toaster` on the page (author it to choose `data-position`
|
|
10
|
-
* / size) or in one auto-created under `<body>`. Hover/focus pause the timer
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* / size) or in one auto-created under `<body>`. Hover/focus pause the timer (it resumes only
|
|
11
|
+
* once the pointer has left AND focus is outside the toast), Escape and the × button dismiss,
|
|
12
|
+
* exit runs the `.leaving` CSS animation from vanilla.css. Dismissing the focused toast moves
|
|
13
|
+
* focus to a neighbouring toast, or back to where it came from. Swipe-to-dismiss is not ported.
|
|
14
|
+
*
|
|
15
|
+
* Announcements go through two persistent, visually hidden live regions inside the container
|
|
16
|
+
* (`.live[role=status]` polite, `.live[role=alert]` assertive — the same DOM Toaster.svelte
|
|
17
|
+
* renders; author them in the markup or they are added on DOM ready / first use). Each visible
|
|
18
|
+
* toast mirrors its message into one of them; the toasts themselves carry no live role.
|
|
13
19
|
*/
|
|
14
20
|
import { DEFAULT_TIMEOUT, isSticky, resolveTimeout, normalizeOptions, ToastTimer, } from '../toast-core.js';
|
|
15
21
|
const GLYPH = { success: '✓', error: '✕', info: 'i', loading: '' };
|
|
16
22
|
const LEAVE_FALLBACK_MS = 400;
|
|
23
|
+
/** Screen readers need a moment to register a fresh live region before it changes. */
|
|
24
|
+
const LIVE_READY_MS = 100;
|
|
17
25
|
const reduceMotion = () => typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
18
26
|
class VanillaToastStore {
|
|
19
27
|
max = 3;
|
|
@@ -21,6 +29,11 @@ class VanillaToastStore {
|
|
|
21
29
|
#live = [];
|
|
22
30
|
#queue = [];
|
|
23
31
|
#container = null;
|
|
32
|
+
#polite = null;
|
|
33
|
+
#assertive = null;
|
|
34
|
+
/** When the current live regions were created (content inserted earlier may be skipped). */
|
|
35
|
+
#liveSince = 0;
|
|
36
|
+
#returnFocus = null;
|
|
24
37
|
/** Visible toasts (read-only snapshot). */
|
|
25
38
|
get items() {
|
|
26
39
|
return this.#live.map((l) => l.toast);
|
|
@@ -38,8 +51,59 @@ class VanillaToastStore {
|
|
|
38
51
|
document.body.appendChild(el);
|
|
39
52
|
}
|
|
40
53
|
this.#container = el;
|
|
54
|
+
el.addEventListener('focusin', (e) => {
|
|
55
|
+
const from = e.relatedTarget;
|
|
56
|
+
if (from && !el.contains(from))
|
|
57
|
+
this.#returnFocus = from;
|
|
58
|
+
});
|
|
59
|
+
this.#ensureLive(el);
|
|
41
60
|
return el;
|
|
42
61
|
}
|
|
62
|
+
/** Make sure the container holds both persistent live regions (adds any that are missing). */
|
|
63
|
+
#ensureLive(el) {
|
|
64
|
+
const find = (role) => Array.from(el.children).find((c) => c.classList.contains('live') && c.getAttribute('role') === role) ?? null;
|
|
65
|
+
let polite = find('status');
|
|
66
|
+
let assertive = find('alert');
|
|
67
|
+
this.#liveSince = !polite || !assertive ? Date.now() : 0;
|
|
68
|
+
if (!polite) {
|
|
69
|
+
polite = document.createElement('div');
|
|
70
|
+
polite.className = 'live';
|
|
71
|
+
polite.setAttribute('role', 'status');
|
|
72
|
+
polite.setAttribute('aria-live', 'polite');
|
|
73
|
+
el.prepend(polite);
|
|
74
|
+
}
|
|
75
|
+
if (!assertive) {
|
|
76
|
+
assertive = document.createElement('div');
|
|
77
|
+
assertive.className = 'live';
|
|
78
|
+
assertive.setAttribute('role', 'alert');
|
|
79
|
+
assertive.setAttribute('aria-live', 'assertive');
|
|
80
|
+
polite.after(assertive);
|
|
81
|
+
}
|
|
82
|
+
this.#polite = polite;
|
|
83
|
+
this.#assertive = assertive;
|
|
84
|
+
}
|
|
85
|
+
/** Prepare the live regions of an author-placed container ahead of the first toast. */
|
|
86
|
+
prepare() {
|
|
87
|
+
if (document.querySelector('.ss-toaster'))
|
|
88
|
+
void this.container;
|
|
89
|
+
}
|
|
90
|
+
/** Write a toast's message into the live region matching its kind. */
|
|
91
|
+
#announce(live) {
|
|
92
|
+
const region = live.toast.kind === 'error' ? this.#assertive : this.#polite;
|
|
93
|
+
const text = live.toast.message;
|
|
94
|
+
const write = () => {
|
|
95
|
+
if (!this.#live.includes(live))
|
|
96
|
+
return;
|
|
97
|
+
if (live.say.parentElement !== region)
|
|
98
|
+
region.appendChild(live.say);
|
|
99
|
+
live.say.textContent = text;
|
|
100
|
+
};
|
|
101
|
+
const wait = this.#liveSince + LIVE_READY_MS - Date.now();
|
|
102
|
+
if (wait > 0)
|
|
103
|
+
setTimeout(write, wait);
|
|
104
|
+
else
|
|
105
|
+
write();
|
|
106
|
+
}
|
|
43
107
|
push(kind, message, opts) {
|
|
44
108
|
const o = normalizeOptions(opts);
|
|
45
109
|
const id = ++this.#seq;
|
|
@@ -54,10 +118,28 @@ class VanillaToastStore {
|
|
|
54
118
|
const el = document.createElement('div');
|
|
55
119
|
el.tabIndex = -1;
|
|
56
120
|
this.#render(el, t);
|
|
57
|
-
|
|
58
|
-
|
|
121
|
+
const live = {
|
|
122
|
+
toast: t,
|
|
123
|
+
el,
|
|
124
|
+
say: document.createElement('p'),
|
|
125
|
+
timer: null,
|
|
126
|
+
hovered: false,
|
|
127
|
+
};
|
|
128
|
+
el.addEventListener('pointerenter', () => {
|
|
129
|
+
live.hovered = true;
|
|
130
|
+
this.pause(t.id);
|
|
131
|
+
});
|
|
132
|
+
el.addEventListener('pointerleave', () => {
|
|
133
|
+
live.hovered = false;
|
|
134
|
+
if (!el.contains(document.activeElement))
|
|
135
|
+
this.resume(t.id);
|
|
136
|
+
});
|
|
59
137
|
el.addEventListener('focusin', () => this.pause(t.id));
|
|
60
|
-
el.addEventListener('focusout', () =>
|
|
138
|
+
el.addEventListener('focusout', (e) => {
|
|
139
|
+
if (el.contains(e.relatedTarget) || live.hovered)
|
|
140
|
+
return;
|
|
141
|
+
this.resume(t.id);
|
|
142
|
+
});
|
|
61
143
|
el.addEventListener('keydown', (e) => {
|
|
62
144
|
if (e.key === 'Escape') {
|
|
63
145
|
e.stopPropagation();
|
|
@@ -77,14 +159,16 @@ class VanillaToastStore {
|
|
|
77
159
|
}
|
|
78
160
|
});
|
|
79
161
|
this.container.appendChild(el);
|
|
80
|
-
const live = { toast: t, el, timer: null };
|
|
81
162
|
this.#live.push(live);
|
|
163
|
+
this.#announce(live);
|
|
82
164
|
this.#arm(live);
|
|
83
165
|
}
|
|
84
166
|
#render(el, t) {
|
|
85
167
|
el.className = `ss-toast ${t.kind}`;
|
|
86
|
-
|
|
87
|
-
|
|
168
|
+
// A focusable group named by its message (focus can land on the toast itself).
|
|
169
|
+
const msgId = `ss-toast-msg-${t.id}`;
|
|
170
|
+
el.setAttribute('role', 'group');
|
|
171
|
+
el.setAttribute('aria-labelledby', msgId);
|
|
88
172
|
const ic = t.kind === 'loading'
|
|
89
173
|
? `<span class="ic spinner${reduceMotion() ? ' still' : ''}" aria-hidden="true"></span>`
|
|
90
174
|
: `<span class="ic" aria-hidden="true">${GLYPH[t.kind]}</span>`;
|
|
@@ -92,7 +176,7 @@ class VanillaToastStore {
|
|
|
92
176
|
? `<button class="action" type="button">${escapeHtml(t.action.label)}</button>`
|
|
93
177
|
: '';
|
|
94
178
|
el.innerHTML =
|
|
95
|
-
`${ic}<span class="msg">${escapeHtml(t.message)}</span>${action}` +
|
|
179
|
+
`${ic}<span class="msg" id="${msgId}">${escapeHtml(t.message)}</span>${action}` +
|
|
96
180
|
`<button class="x" type="button" aria-label="Dismiss">×</button>`;
|
|
97
181
|
}
|
|
98
182
|
#find(id) {
|
|
@@ -120,7 +204,12 @@ class VanillaToastStore {
|
|
|
120
204
|
else if (patch.kind !== undefined)
|
|
121
205
|
target.timeout = DEFAULT_TIMEOUT[patch.kind];
|
|
122
206
|
if (live) {
|
|
207
|
+
// Re-rendering replaces the toast's buttons; keep focus inside it.
|
|
208
|
+
const hadFocus = live.el.contains(document.activeElement);
|
|
123
209
|
this.#render(live.el, live.toast);
|
|
210
|
+
if (hadFocus && !live.el.contains(document.activeElement))
|
|
211
|
+
live.el.focus();
|
|
212
|
+
this.#announce(live);
|
|
124
213
|
this.#arm(live);
|
|
125
214
|
}
|
|
126
215
|
return true;
|
|
@@ -134,8 +223,11 @@ class VanillaToastStore {
|
|
|
134
223
|
dismiss(id) {
|
|
135
224
|
const i = this.#live.findIndex((l) => l.toast.id === id);
|
|
136
225
|
if (i !== -1) {
|
|
226
|
+
if (holdsFocus(this.#live[i]))
|
|
227
|
+
this.#moveFocusFrom(i);
|
|
137
228
|
const [live] = this.#live.splice(i, 1);
|
|
138
229
|
live.timer?.cancel();
|
|
230
|
+
live.say.remove();
|
|
139
231
|
this.#leave(live.el);
|
|
140
232
|
this.#promote();
|
|
141
233
|
return;
|
|
@@ -144,6 +236,16 @@ class VanillaToastStore {
|
|
|
144
236
|
if (qi !== -1)
|
|
145
237
|
this.#queue.splice(qi, 1);
|
|
146
238
|
}
|
|
239
|
+
/** Move focus off the toast at `i` (about to be removed): next toast, previous, or origin. */
|
|
240
|
+
#moveFocusFrom(i) {
|
|
241
|
+
const next = this.#live[i + 1] ?? this.#live[i - 1];
|
|
242
|
+
if (next)
|
|
243
|
+
next.el.focus();
|
|
244
|
+
else if (this.#returnFocus?.isConnected) {
|
|
245
|
+
this.#returnFocus.focus();
|
|
246
|
+
this.#returnFocus = null;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
147
249
|
#leave(el) {
|
|
148
250
|
if (reduceMotion()) {
|
|
149
251
|
el.remove();
|
|
@@ -167,16 +269,28 @@ class VanillaToastStore {
|
|
|
167
269
|
clear() {
|
|
168
270
|
for (const l of this.#live) {
|
|
169
271
|
l.timer?.cancel();
|
|
272
|
+
l.say.remove();
|
|
170
273
|
l.el.remove();
|
|
171
274
|
}
|
|
172
275
|
this.#live = [];
|
|
173
276
|
this.#queue = [];
|
|
174
277
|
}
|
|
175
278
|
}
|
|
279
|
+
const holdsFocus = (l) => l.el.contains(document.activeElement);
|
|
176
280
|
function escapeHtml(s) {
|
|
177
281
|
return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
178
282
|
}
|
|
179
283
|
export const toasts = new VanillaToastStore();
|
|
284
|
+
// Give an author-placed `.ss-toaster` its live regions as soon as the DOM is ready, so they exist
|
|
285
|
+
// well before the first toast writes into them.
|
|
286
|
+
if (typeof document !== 'undefined') {
|
|
287
|
+
if (document.readyState === 'loading') {
|
|
288
|
+
document.addEventListener('DOMContentLoaded', () => toasts.prepare(), { once: true });
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
toasts.prepare();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
180
294
|
export const toast = {
|
|
181
295
|
success: (message, opts) => toasts.push('success', message, opts),
|
|
182
296
|
error: (message, opts) => toasts.push('error', message, opts),
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Open `root`'s tip. `from` is the element that triggered it (the focused element on
|
|
3
|
+
* focusin); `aria-describedby` goes on that element when it sits inside `.trigger`.
|
|
4
|
+
*/
|
|
5
|
+
export declare function showTooltip(root: HTMLElement, from?: EventTarget | null): void;
|
|
2
6
|
export declare function hideTooltip(root: HTMLElement): void;
|
|
3
7
|
export declare function installTooltip(): void;
|
package/dist/vanilla/tooltip.js
CHANGED
|
@@ -2,16 +2,50 @@
|
|
|
2
2
|
* Tooltip (DS-0148) — hover/focus reveal over Tooltip.svelte's DOM:
|
|
3
3
|
* `.ss-tooltip[data-placement] > .trigger + .tip[role=tooltip]`. Basic four-way placement
|
|
4
4
|
* only: the pre-rendered `data-placement` is honoured as-is (no collision engine). Escape
|
|
5
|
-
* hides
|
|
6
|
-
* the
|
|
5
|
+
* hides any open tip wherever focus is (WCAG 1.4.13). While open the focusable trigger inside
|
|
6
|
+
* `.trigger` (not the wrapper) carries `aria-describedby` → the tip (an id is generated when
|
|
7
|
+
* the markup has none); the token is added alongside any description the trigger already has
|
|
8
|
+
* (DS-0163).
|
|
7
9
|
*/
|
|
8
|
-
import { on } from './delegate.js';
|
|
10
|
+
import { on, all } from './delegate.js';
|
|
9
11
|
const ROOT = '.ss-tooltip';
|
|
12
|
+
const FOCUSABLE = 'a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"]), [contenteditable="true"]';
|
|
10
13
|
let seq = 0;
|
|
14
|
+
/** Element currently described by each open tooltip's tip. */
|
|
15
|
+
const described = new WeakMap();
|
|
11
16
|
function tipOf(root) {
|
|
12
17
|
return root.querySelector(':scope > .tip');
|
|
13
18
|
}
|
|
14
|
-
|
|
19
|
+
/** The focused trigger element, else the first focusable in `.trigger`, else its first element. */
|
|
20
|
+
function describedTarget(root, from) {
|
|
21
|
+
const trigger = root.querySelector(':scope > .trigger');
|
|
22
|
+
if (!trigger)
|
|
23
|
+
return root;
|
|
24
|
+
if (from instanceof HTMLElement && from !== trigger && trigger.contains(from))
|
|
25
|
+
return from;
|
|
26
|
+
return (trigger.querySelector(FOCUSABLE) ??
|
|
27
|
+
trigger.firstElementChild ??
|
|
28
|
+
trigger);
|
|
29
|
+
}
|
|
30
|
+
function ids(el) {
|
|
31
|
+
return (el.getAttribute('aria-describedby') ?? '').split(/\s+/).filter(Boolean);
|
|
32
|
+
}
|
|
33
|
+
function undescribe(root, tipId) {
|
|
34
|
+
const el = described.get(root);
|
|
35
|
+
described.delete(root);
|
|
36
|
+
if (!el)
|
|
37
|
+
return;
|
|
38
|
+
const rest = ids(el).filter((id) => id !== tipId);
|
|
39
|
+
if (rest.length)
|
|
40
|
+
el.setAttribute('aria-describedby', rest.join(' '));
|
|
41
|
+
else
|
|
42
|
+
el.removeAttribute('aria-describedby');
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Open `root`'s tip. `from` is the element that triggered it (the focused element on
|
|
46
|
+
* focusin); `aria-describedby` goes on that element when it sits inside `.trigger`.
|
|
47
|
+
*/
|
|
48
|
+
export function showTooltip(root, from) {
|
|
15
49
|
const tip = tipOf(root);
|
|
16
50
|
if (!tip)
|
|
17
51
|
return;
|
|
@@ -19,7 +53,14 @@ export function showTooltip(root) {
|
|
|
19
53
|
tip.id = `ss-tip-${++seq}`;
|
|
20
54
|
tip.hidden = false;
|
|
21
55
|
tip.classList.add('open');
|
|
22
|
-
root
|
|
56
|
+
const target = describedTarget(root, from);
|
|
57
|
+
if (described.get(root) !== target) {
|
|
58
|
+
undescribe(root, tip.id);
|
|
59
|
+
const cur = ids(target);
|
|
60
|
+
if (!cur.includes(tip.id))
|
|
61
|
+
target.setAttribute('aria-describedby', [...cur, tip.id].join(' '));
|
|
62
|
+
described.set(root, target);
|
|
63
|
+
}
|
|
23
64
|
}
|
|
24
65
|
export function hideTooltip(root) {
|
|
25
66
|
const tip = tipOf(root);
|
|
@@ -27,7 +68,7 @@ export function hideTooltip(root) {
|
|
|
27
68
|
return;
|
|
28
69
|
tip.hidden = true;
|
|
29
70
|
tip.classList.remove('open');
|
|
30
|
-
root.
|
|
71
|
+
undescribe(root, tip.id);
|
|
31
72
|
}
|
|
32
73
|
export function installTooltip() {
|
|
33
74
|
// mouseenter/leave don't bubble; mouseover/out do — filter by relatedTarget.
|
|
@@ -41,14 +82,20 @@ export function installTooltip() {
|
|
|
41
82
|
if (!to || !root.contains(to))
|
|
42
83
|
hideTooltip(root);
|
|
43
84
|
});
|
|
44
|
-
on('focusin', ROOT, (root) => showTooltip(root));
|
|
85
|
+
on('focusin', ROOT, (root, e) => showTooltip(root, e.target));
|
|
45
86
|
on('focusout', ROOT, (root, e) => {
|
|
46
87
|
const to = e.relatedTarget;
|
|
47
88
|
if (!to || !root.contains(to))
|
|
48
89
|
hideTooltip(root);
|
|
49
90
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
91
|
+
// Document-level Escape: a tip opened by hover closes even when focus is elsewhere.
|
|
92
|
+
document.addEventListener('keydown', (e) => {
|
|
93
|
+
if (e.key !== 'Escape')
|
|
94
|
+
return;
|
|
95
|
+
for (const tip of all(document, `${ROOT} > .tip.open`)) {
|
|
96
|
+
const root = tip.parentElement;
|
|
97
|
+
if (root)
|
|
98
|
+
hideTooltip(root);
|
|
99
|
+
}
|
|
53
100
|
});
|
|
54
101
|
}
|