dssoca 0.16.0 → 0.17.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.
Files changed (42) hide show
  1. package/README.md +19 -0
  2. package/dist/components/Icon.svelte +9 -61
  3. package/dist/components/Icon.svelte.d.ts +4 -47
  4. package/dist/components/LogStream.svelte +2 -2
  5. package/dist/components/MetricTile.svelte +2 -2
  6. package/dist/components/ServiceCard.svelte +2 -2
  7. package/dist/components/Spinner.svelte +7 -34
  8. package/dist/components/Spinner.svelte.d.ts +2 -59
  9. package/dist/icons.d.ts +54 -0
  10. package/dist/icons.js +56 -0
  11. package/dist/index.d.ts +4 -3
  12. package/dist/index.js +4 -2
  13. package/dist/spinner-frames.d.ts +59 -0
  14. package/dist/spinner-frames.js +15 -0
  15. package/dist/toast-core.d.ts +61 -0
  16. package/dist/toast-core.js +73 -0
  17. package/dist/toast.svelte.d.ts +2 -33
  18. package/dist/toast.svelte.js +3 -66
  19. package/dist/vanilla/accordion.d.ts +2 -0
  20. package/dist/vanilla/accordion.js +57 -0
  21. package/dist/vanilla/delegate.d.ts +16 -0
  22. package/dist/vanilla/delegate.js +33 -0
  23. package/dist/vanilla/fields.d.ts +6 -0
  24. package/dist/vanilla/fields.js +89 -0
  25. package/dist/vanilla/icons.d.ts +17 -0
  26. package/dist/vanilla/icons.js +78 -0
  27. package/dist/vanilla/index.d.ts +16 -0
  28. package/dist/vanilla/index.js +60 -0
  29. package/dist/vanilla/menu.d.ts +3 -0
  30. package/dist/vanilla/menu.js +133 -0
  31. package/dist/vanilla/modal.d.ts +3 -0
  32. package/dist/vanilla/modal.js +42 -0
  33. package/dist/vanilla/segmented.d.ts +2 -0
  34. package/dist/vanilla/segmented.js +62 -0
  35. package/dist/vanilla/switch.d.ts +2 -0
  36. package/dist/vanilla/switch.js +22 -0
  37. package/dist/vanilla/toast.d.ts +37 -0
  38. package/dist/vanilla/toast.js +196 -0
  39. package/dist/vanilla/tooltip.d.ts +3 -0
  40. package/dist/vanilla/tooltip.js +54 -0
  41. package/dist/vanilla.css +4433 -0
  42. package/package.json +14 -5
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Menu (DS-0148) — port of Menu.svelte's open/close + roving-focus model over the exact same
3
+ * DOM: `.ss-menu > .trigger[aria-expanded][aria-controls]` and `.panel[role=menu] > .item`.
4
+ * Outside pointerdown closes without returning focus; Escape / item activation return focus
5
+ * to the trigger. Emits `ss:select` on the root with `{ index, value }` (`value` is the
6
+ * item's `data-value`, when authored). For `menuitemradio` items the check marker moves to
7
+ * the activated item.
8
+ */
9
+ import { on, emit, all } from './delegate.js';
10
+ import { iconSvg } from './icons.js';
11
+ const TRIGGER = '.ss-menu > .trigger';
12
+ const PANEL = '.ss-menu > .panel[role="menu"]';
13
+ function parts(el) {
14
+ const root = el.closest('.ss-menu');
15
+ const trigger = root?.querySelector(':scope > .trigger') ?? null;
16
+ const panel = root?.querySelector(':scope > .panel') ?? null;
17
+ return { root, trigger, panel };
18
+ }
19
+ function items(panel) {
20
+ return all(panel, '.item').filter((i) => i.closest('.panel') === panel);
21
+ }
22
+ function enabled(panel) {
23
+ return items(panel).filter((i) => !i.disabled && i.getAttribute('aria-disabled') !== 'true');
24
+ }
25
+ function focusItem(panel, item) {
26
+ if (!item)
27
+ return;
28
+ for (const i of items(panel))
29
+ i.tabIndex = i === item ? 0 : -1;
30
+ item.focus();
31
+ }
32
+ export function openMenu(trigger, focus = 'first') {
33
+ const { panel } = parts(trigger);
34
+ if (!panel || trigger.getAttribute('aria-expanded') === 'true')
35
+ return;
36
+ trigger.setAttribute('aria-expanded', 'true');
37
+ panel.classList.add('open');
38
+ panel.setAttribute('aria-hidden', 'false');
39
+ queueMicrotask(() => {
40
+ const list = enabled(panel);
41
+ focusItem(panel, focus === 'first' ? list[0] : list[list.length - 1]);
42
+ });
43
+ }
44
+ export function closeMenu(trigger, returnFocus = true) {
45
+ const { panel } = parts(trigger);
46
+ if (!panel || trigger.getAttribute('aria-expanded') !== 'true')
47
+ return;
48
+ trigger.setAttribute('aria-expanded', 'false');
49
+ panel.classList.remove('open');
50
+ panel.setAttribute('aria-hidden', 'true');
51
+ for (const i of items(panel))
52
+ i.tabIndex = -1;
53
+ if (returnFocus)
54
+ trigger.focus();
55
+ }
56
+ function activate(item) {
57
+ const { root, trigger, panel } = parts(item);
58
+ if (!root || !trigger || !panel || item.disabled)
59
+ return;
60
+ if (item.getAttribute('role') === 'menuitemradio') {
61
+ for (const i of items(panel)) {
62
+ const on = i === item;
63
+ i.classList.toggle('selected', on);
64
+ i.setAttribute('aria-checked', String(on));
65
+ const marker = i.querySelector('.marker');
66
+ if (marker)
67
+ marker.innerHTML = on ? iconSvg('check') : '';
68
+ }
69
+ }
70
+ emit(root, 'ss:select', { index: items(panel).indexOf(item), value: item.dataset.value });
71
+ closeMenu(trigger);
72
+ }
73
+ export function installMenu() {
74
+ on('click', TRIGGER, (trigger) => {
75
+ if (trigger.getAttribute('aria-expanded') === 'true')
76
+ closeMenu(trigger);
77
+ else
78
+ openMenu(trigger, 'first');
79
+ });
80
+ on('keydown', TRIGGER, (trigger, e) => {
81
+ if (e.key === 'ArrowDown' || e.key === 'Enter' || e.key === ' ') {
82
+ e.preventDefault();
83
+ openMenu(trigger, 'first');
84
+ }
85
+ else if (e.key === 'ArrowUp') {
86
+ e.preventDefault();
87
+ openMenu(trigger, 'last');
88
+ }
89
+ });
90
+ on('keydown', PANEL, (panel, e) => {
91
+ const { trigger } = parts(panel);
92
+ if (!trigger)
93
+ return;
94
+ const list = enabled(panel);
95
+ const active = list.findIndex((i) => i === document.activeElement);
96
+ const pick = (i) => focusItem(panel, list[((i % list.length) + list.length) % list.length]);
97
+ switch (e.key) {
98
+ case 'ArrowDown':
99
+ e.preventDefault();
100
+ pick(active < 0 ? 0 : active + 1);
101
+ break;
102
+ case 'ArrowUp':
103
+ e.preventDefault();
104
+ pick(active < 0 ? list.length - 1 : active - 1);
105
+ break;
106
+ case 'Home':
107
+ e.preventDefault();
108
+ pick(0);
109
+ break;
110
+ case 'End':
111
+ e.preventDefault();
112
+ pick(list.length - 1);
113
+ break;
114
+ case 'Escape':
115
+ e.preventDefault();
116
+ closeMenu(trigger);
117
+ break;
118
+ case 'Tab':
119
+ closeMenu(trigger, false);
120
+ break;
121
+ }
122
+ });
123
+ on('click', `${PANEL} .item`, (item) => activate(item));
124
+ document.addEventListener('pointerdown', (e) => {
125
+ const t = e.target;
126
+ for (const trigger of all(document, `${TRIGGER}[aria-expanded="true"]`)) {
127
+ const root = trigger.closest('.ss-menu');
128
+ if (root && t && root.contains(t))
129
+ continue;
130
+ closeMenu(trigger, false);
131
+ }
132
+ }, true);
133
+ }
@@ -0,0 +1,3 @@
1
+ export declare function openModal(dialog: HTMLDialogElement): void;
2
+ export declare function closeModal(dialog: HTMLDialogElement): void;
3
+ export declare function installModal(): void;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Modal (DS-0148) — the component is a native `<dialog class="ss-modal">`, so the browser owns
3
+ * the focus trap, inertness and Escape. Vanilla only needs openers and closers:
4
+ *
5
+ * <button data-ss-modal="#confirm">Open</button>
6
+ * <dialog class="ss-modal" id="confirm"> … <button class="close" data-ss-dismiss>×</button>
7
+ *
8
+ * Backdrop pointerdown closes unless the dialog carries `data-ss-static`; Escape is blocked
9
+ * when it carries `data-ss-no-esc` (mirrors `closeOnBackdrop` / `closeOnEsc`).
10
+ */
11
+ import { on, byId } from './delegate.js';
12
+ export function openModal(dialog) {
13
+ if (!dialog.open)
14
+ dialog.showModal();
15
+ }
16
+ export function closeModal(dialog) {
17
+ if (dialog.open)
18
+ dialog.close();
19
+ }
20
+ export function installModal() {
21
+ on('click', '[data-ss-modal]', (opener, e) => {
22
+ const target = byId(opener.getAttribute('data-ss-modal'));
23
+ if (!(target instanceof HTMLDialogElement))
24
+ return;
25
+ e.preventDefault();
26
+ openModal(target);
27
+ });
28
+ on('click', 'dialog.ss-modal [data-ss-dismiss]', (btn) => {
29
+ const dialog = btn.closest('dialog.ss-modal');
30
+ if (dialog instanceof HTMLDialogElement)
31
+ closeModal(dialog);
32
+ });
33
+ on('pointerdown', 'dialog.ss-modal', (dialog, e) => {
34
+ if (e.target !== dialog || dialog.hasAttribute('data-ss-static'))
35
+ return;
36
+ closeModal(dialog);
37
+ });
38
+ // `cancel` does not bubble — capture it.
39
+ on('cancel', 'dialog.ss-modal[data-ss-no-esc]', (_dialog, e) => {
40
+ e.preventDefault();
41
+ }, { capture: true });
42
+ }
@@ -0,0 +1,2 @@
1
+ export declare function selectSegment(segment: HTMLButtonElement): void;
2
+ export declare function installSegmented(): void;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * SegmentedControl (DS-0148) — radio-group selection over `.ss-segmented > .segment[role=radio]`
3
+ * with the same roving model as SegmentedControl.svelte (Arrow/Home/End select + focus,
4
+ * wrapping over enabled segments). Emits `ss:change` on the root with `{ value, index }`;
5
+ * `value` is the segment's `data-value` (vanilla-only attribute) or its label text.
6
+ */
7
+ import { on, emit, all } from './delegate.js';
8
+ function segments(root) {
9
+ return all(root, '.segment[role="radio"]').filter((s) => s.closest('.ss-segmented') === root);
10
+ }
11
+ export function selectSegment(segment) {
12
+ const root = segment.closest('.ss-segmented');
13
+ if (!root || segment.disabled || root.getAttribute('aria-disabled') === 'true')
14
+ return;
15
+ const list = segments(root);
16
+ const already = segment.getAttribute('aria-checked') === 'true';
17
+ for (const s of list) {
18
+ const on = s === segment;
19
+ s.classList.toggle('selected', on);
20
+ s.setAttribute('aria-checked', String(on));
21
+ s.tabIndex = on ? 0 : -1;
22
+ }
23
+ if (already)
24
+ return;
25
+ const value = segment.dataset.value ?? segment.querySelector('.label')?.textContent?.trim() ?? '';
26
+ emit(root, 'ss:change', { value, index: list.indexOf(segment) });
27
+ }
28
+ export function installSegmented() {
29
+ on('click', '.ss-segmented .segment[role="radio"]', (s) => selectSegment(s));
30
+ on('keydown', '.ss-segmented .segment[role="radio"]', (segment, e) => {
31
+ const root = segment.closest('.ss-segmented');
32
+ if (!root)
33
+ return;
34
+ const enabled = segments(root).filter((s) => !s.disabled);
35
+ const pos = enabled.indexOf(segment);
36
+ const n = enabled.length;
37
+ let target;
38
+ switch (e.key) {
39
+ case 'ArrowRight':
40
+ case 'ArrowDown':
41
+ target = ((pos < 0 ? -1 : pos) + 1 + n) % n;
42
+ break;
43
+ case 'ArrowLeft':
44
+ case 'ArrowUp':
45
+ target = ((pos < 0 ? 0 : pos) - 1 + n) % n;
46
+ break;
47
+ case 'Home':
48
+ target = 0;
49
+ break;
50
+ case 'End':
51
+ target = n - 1;
52
+ break;
53
+ default:
54
+ return;
55
+ }
56
+ if (n === 0)
57
+ return;
58
+ e.preventDefault();
59
+ selectSegment(enabled[target]);
60
+ enabled[target].focus();
61
+ });
62
+ }
@@ -0,0 +1,2 @@
1
+ export declare function toggleSwitch(track: HTMLButtonElement): void;
2
+ export declare function installSwitch(): void;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Switch (DS-0148) — flips `aria-checked` + `.on` on `.ss-switch .track[role=switch]`; clicking
3
+ * the sibling `.label` toggles too (same target as the control, like Switch.svelte). Emits
4
+ * `ss:change` on the root with `{ checked }`.
5
+ */
6
+ import { on, emit } from './delegate.js';
7
+ export function toggleSwitch(track) {
8
+ if (track.disabled)
9
+ return;
10
+ const next = track.getAttribute('aria-checked') !== 'true';
11
+ track.setAttribute('aria-checked', String(next));
12
+ track.classList.toggle('on', next);
13
+ emit(track.closest('.ss-switch') ?? track, 'ss:change', { checked: next });
14
+ }
15
+ export function installSwitch() {
16
+ on('click', '.ss-switch .track[role="switch"]', (track) => toggleSwitch(track));
17
+ on('click', '.ss-switch .label', (label) => {
18
+ const track = label.closest('.ss-switch')?.querySelector('.track');
19
+ if (track)
20
+ toggleSwitch(track);
21
+ });
22
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Toasts (DS-0148) — framework-free port of `toast.svelte.ts` + Toaster.svelte that renders
3
+ * the exact Toaster DOM directly. Same API names as the Svelte one:
4
+ *
5
+ * toast.success('saved') toast.error('nope', { action: { label, onClick } })
6
+ * toast.loading('…') toast.promise(p, { loading, success, error })
7
+ * toasts.dismiss(id) / clear() / update(id, patch) / max
8
+ *
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, Escape and the
11
+ * × button dismiss, exit runs the `.leaving` CSS animation from vanilla.css. Swipe-to-dismiss
12
+ * is not ported.
13
+ */
14
+ import { type Toast, type ToastKind, type ToastOptions, type ToastPatch, type PromiseMessages } from '../toast-core.js';
15
+ export type { Toast, ToastKind, ToastOptions, ToastPatch, ToastAction, PromiseMessages, } from '../toast-core.js';
16
+ declare class VanillaToastStore {
17
+ #private;
18
+ max: number;
19
+ /** Visible toasts (read-only snapshot). */
20
+ get items(): Toast[];
21
+ get container(): HTMLElement;
22
+ push(kind: ToastKind, message: string, opts?: ToastOptions | number): number;
23
+ update(id: number, patch: ToastPatch): boolean;
24
+ pause(id: number): void;
25
+ resume(id: number): void;
26
+ dismiss(id: number): void;
27
+ clear(): void;
28
+ }
29
+ export declare const toasts: VanillaToastStore;
30
+ export declare const toast: {
31
+ success: (message: string, opts?: ToastOptions | number) => number;
32
+ error: (message: string, opts?: ToastOptions | number) => number;
33
+ info: (message: string, opts?: ToastOptions | number) => number;
34
+ loading: (message: string, opts?: ToastOptions | number) => number;
35
+ /** Push a sticky `loading` toast, then flip it to success/error when the promise settles. */
36
+ promise<T>(p: Promise<T>, messages: PromiseMessages<T>): Promise<T>;
37
+ };
@@ -0,0 +1,196 @@
1
+ /**
2
+ * Toasts (DS-0148) — framework-free port of `toast.svelte.ts` + Toaster.svelte that renders
3
+ * the exact Toaster DOM directly. Same API names as the Svelte one:
4
+ *
5
+ * toast.success('saved') toast.error('nope', { action: { label, onClick } })
6
+ * toast.loading('…') toast.promise(p, { loading, success, error })
7
+ * toasts.dismiss(id) / clear() / update(id, patch) / max
8
+ *
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, Escape and the
11
+ * × button dismiss, exit runs the `.leaving` CSS animation from vanilla.css. Swipe-to-dismiss
12
+ * is not ported.
13
+ */
14
+ import { DEFAULT_TIMEOUT, isSticky, resolveTimeout, normalizeOptions, ToastTimer, } from '../toast-core.js';
15
+ const GLYPH = { success: '✓', error: '✕', info: 'i', loading: '' };
16
+ const LEAVE_FALLBACK_MS = 400;
17
+ const reduceMotion = () => typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
18
+ class VanillaToastStore {
19
+ max = 3;
20
+ #seq = 0;
21
+ #live = [];
22
+ #queue = [];
23
+ #container = null;
24
+ /** Visible toasts (read-only snapshot). */
25
+ get items() {
26
+ return this.#live.map((l) => l.toast);
27
+ }
28
+ get container() {
29
+ if (this.#container?.isConnected)
30
+ return this.#container;
31
+ let el = document.querySelector('.ss-toaster');
32
+ if (!el) {
33
+ el = document.createElement('div');
34
+ el.className = 'ss-toaster';
35
+ el.setAttribute('aria-label', 'Notifications');
36
+ el.dataset.position = 'top-right';
37
+ document.body.appendChild(el);
38
+ }
39
+ this.#container = el;
40
+ return el;
41
+ }
42
+ push(kind, message, opts) {
43
+ const o = normalizeOptions(opts);
44
+ const id = ++this.#seq;
45
+ const t = { id, kind, message, timeout: resolveTimeout(kind, o), action: o?.action };
46
+ if (this.#live.length < this.max)
47
+ this.#show(t);
48
+ else
49
+ this.#queue.push(t);
50
+ return id;
51
+ }
52
+ #show(t) {
53
+ const el = document.createElement('div');
54
+ el.tabIndex = -1;
55
+ this.#render(el, t);
56
+ el.addEventListener('pointerenter', () => this.pause(t.id));
57
+ el.addEventListener('pointerleave', () => this.resume(t.id));
58
+ el.addEventListener('focusin', () => this.pause(t.id));
59
+ el.addEventListener('focusout', () => this.resume(t.id));
60
+ el.addEventListener('keydown', (e) => {
61
+ if (e.key === 'Escape') {
62
+ e.stopPropagation();
63
+ this.dismiss(t.id);
64
+ }
65
+ });
66
+ el.addEventListener('click', (e) => {
67
+ const btn = e.target.closest('button');
68
+ if (!btn)
69
+ return;
70
+ if (btn.classList.contains('x'))
71
+ this.dismiss(t.id);
72
+ else if (btn.classList.contains('action')) {
73
+ const keep = this.#find(t.id)?.toast.action?.onClick() === false;
74
+ if (!keep)
75
+ this.dismiss(t.id);
76
+ }
77
+ });
78
+ this.container.appendChild(el);
79
+ const live = { toast: t, el, timer: null };
80
+ this.#live.push(live);
81
+ this.#arm(live);
82
+ }
83
+ #render(el, t) {
84
+ el.className = `ss-toast ${t.kind}`;
85
+ el.setAttribute('role', t.kind === 'error' ? 'alert' : 'status');
86
+ el.setAttribute('aria-live', t.kind === 'error' ? 'assertive' : 'polite');
87
+ const ic = t.kind === 'loading'
88
+ ? `<span class="ic spinner${reduceMotion() ? ' still' : ''}" aria-hidden="true"></span>`
89
+ : `<span class="ic" aria-hidden="true">${GLYPH[t.kind]}</span>`;
90
+ const action = t.action
91
+ ? `<button class="action" type="button">${escapeHtml(t.action.label)}</button>`
92
+ : '';
93
+ el.innerHTML =
94
+ `${ic}<span class="msg">${escapeHtml(t.message)}</span>${action}` +
95
+ `<button class="x" type="button" aria-label="Dismiss">×</button>`;
96
+ }
97
+ #find(id) {
98
+ return this.#live.find((l) => l.toast.id === id);
99
+ }
100
+ #arm(live) {
101
+ live.timer?.cancel();
102
+ live.timer = isSticky(live.toast.timeout)
103
+ ? null
104
+ : new ToastTimer(live.toast.timeout, () => this.dismiss(live.toast.id));
105
+ }
106
+ update(id, patch) {
107
+ const live = this.#find(id);
108
+ const target = live?.toast ?? this.#queue.find((t) => t.id === id);
109
+ if (!target)
110
+ return false;
111
+ if (patch.kind !== undefined)
112
+ target.kind = patch.kind;
113
+ if (patch.message !== undefined)
114
+ target.message = patch.message;
115
+ if ('action' in patch)
116
+ target.action = patch.action;
117
+ if (patch.timeout !== undefined)
118
+ target.timeout = patch.timeout;
119
+ else if (patch.kind !== undefined)
120
+ target.timeout = DEFAULT_TIMEOUT[patch.kind];
121
+ if (live) {
122
+ this.#render(live.el, live.toast);
123
+ this.#arm(live);
124
+ }
125
+ return true;
126
+ }
127
+ pause(id) {
128
+ this.#find(id)?.timer?.pause();
129
+ }
130
+ resume(id) {
131
+ this.#find(id)?.timer?.resume();
132
+ }
133
+ dismiss(id) {
134
+ const i = this.#live.findIndex((l) => l.toast.id === id);
135
+ if (i !== -1) {
136
+ const [live] = this.#live.splice(i, 1);
137
+ live.timer?.cancel();
138
+ this.#leave(live.el);
139
+ this.#promote();
140
+ return;
141
+ }
142
+ const qi = this.#queue.findIndex((t) => t.id === id);
143
+ if (qi !== -1)
144
+ this.#queue.splice(qi, 1);
145
+ }
146
+ #leave(el) {
147
+ if (reduceMotion()) {
148
+ el.remove();
149
+ return;
150
+ }
151
+ let done = false;
152
+ const finish = () => {
153
+ if (done)
154
+ return;
155
+ done = true;
156
+ el.remove();
157
+ };
158
+ el.classList.add('leaving');
159
+ el.addEventListener('animationend', finish, { once: true });
160
+ setTimeout(finish, LEAVE_FALLBACK_MS);
161
+ }
162
+ #promote() {
163
+ while (this.#live.length < this.max && this.#queue.length > 0)
164
+ this.#show(this.#queue.shift());
165
+ }
166
+ clear() {
167
+ for (const l of this.#live) {
168
+ l.timer?.cancel();
169
+ l.el.remove();
170
+ }
171
+ this.#live = [];
172
+ this.#queue = [];
173
+ }
174
+ }
175
+ function escapeHtml(s) {
176
+ return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
177
+ }
178
+ export const toasts = new VanillaToastStore();
179
+ export const toast = {
180
+ success: (message, opts) => toasts.push('success', message, opts),
181
+ error: (message, opts) => toasts.push('error', message, opts),
182
+ info: (message, opts) => toasts.push('info', message, opts),
183
+ loading: (message, opts) => toasts.push('loading', message, opts),
184
+ /** Push a sticky `loading` toast, then flip it to success/error when the promise settles. */
185
+ promise(p, messages) {
186
+ const id = toasts.push('loading', messages.loading, { timeout: 0 });
187
+ p.then((value) => {
188
+ const msg = typeof messages.success === 'function' ? messages.success(value) : messages.success;
189
+ toasts.update(id, { kind: 'success', message: msg });
190
+ }, (err) => {
191
+ const msg = typeof messages.error === 'function' ? messages.error(err) : messages.error;
192
+ toasts.update(id, { kind: 'error', message: msg });
193
+ });
194
+ return p;
195
+ },
196
+ };
@@ -0,0 +1,3 @@
1
+ export declare function showTooltip(root: HTMLElement): void;
2
+ export declare function hideTooltip(root: HTMLElement): void;
3
+ export declare function installTooltip(): void;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Tooltip (DS-0148) — hover/focus reveal over Tooltip.svelte's DOM:
3
+ * `.ss-tooltip[data-placement] > .trigger + .tip[role=tooltip]`. Basic four-way placement
4
+ * only: the pre-rendered `data-placement` is honoured as-is (no collision engine). Escape
5
+ * hides. While open the wrapper carries `aria-describedby` → the tip (an id is generated when
6
+ * the markup has none).
7
+ */
8
+ import { on } from './delegate.js';
9
+ const ROOT = '.ss-tooltip';
10
+ let seq = 0;
11
+ function tipOf(root) {
12
+ return root.querySelector(':scope > .tip');
13
+ }
14
+ export function showTooltip(root) {
15
+ const tip = tipOf(root);
16
+ if (!tip)
17
+ return;
18
+ if (!tip.id)
19
+ tip.id = `ss-tip-${++seq}`;
20
+ tip.hidden = false;
21
+ tip.classList.add('open');
22
+ root.setAttribute('aria-describedby', tip.id);
23
+ }
24
+ export function hideTooltip(root) {
25
+ const tip = tipOf(root);
26
+ if (!tip)
27
+ return;
28
+ tip.hidden = true;
29
+ tip.classList.remove('open');
30
+ root.removeAttribute('aria-describedby');
31
+ }
32
+ export function installTooltip() {
33
+ // mouseenter/leave don't bubble; mouseover/out do — filter by relatedTarget.
34
+ on('mouseover', ROOT, (root, e) => {
35
+ const from = e.relatedTarget;
36
+ if (!from || !root.contains(from))
37
+ showTooltip(root);
38
+ });
39
+ on('mouseout', ROOT, (root, e) => {
40
+ const to = e.relatedTarget;
41
+ if (!to || !root.contains(to))
42
+ hideTooltip(root);
43
+ });
44
+ on('focusin', ROOT, (root) => showTooltip(root));
45
+ on('focusout', ROOT, (root, e) => {
46
+ const to = e.relatedTarget;
47
+ if (!to || !root.contains(to))
48
+ hideTooltip(root);
49
+ });
50
+ on('keydown', ROOT, (root, e) => {
51
+ if (e.key === 'Escape')
52
+ hideTooltip(root);
53
+ });
54
+ }