dssoca 0.17.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 +9 -6
- 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/BottomNav.svelte +4 -0
- 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 +48 -15
- package/dist/components/Card.svelte.d.ts +10 -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 +6 -3
- package/dist/components/Kbd.svelte +17 -1
- package/dist/components/Kbd.svelte.d.ts +9 -0
- 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 +16 -2
- 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 +102 -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 +108 -68
- package/dist/components/ServiceCard.svelte.d.ts +8 -3
- package/dist/components/ShortcutsHelp.svelte +3 -2
- package/dist/components/Sidebar.svelte +84 -59
- package/dist/components/Sidebar.svelte.d.ts +5 -0
- 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 +598 -0
- package/dist/components/TierList.svelte.d.ts +37 -0
- package/dist/components/Toaster.svelte +144 -21
- package/dist/components/Tooltip.svelte +101 -13
- package/dist/components/Tooltip.svelte.d.ts +1 -1
- package/dist/components/Topbar.svelte +39 -16
- package/dist/dssoca.config.d.ts +1 -1
- package/dist/dssoca.config.js +1 -0
- package/dist/icons.d.ts +20 -2
- package/dist/icons.js +43 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -1
- package/dist/theme.css +25 -27
- package/dist/tierlist-core.d.ts +97 -0
- package/dist/tierlist-core.js +206 -0
- package/dist/tokens.css +25 -0
- package/dist/vanilla/accordion.js +7 -3
- package/dist/vanilla/fields.js +19 -6
- package/dist/vanilla/index.d.ts +2 -1
- package/dist/vanilla/index.js +7 -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.d.ts +8 -0
- package/dist/vanilla/tierlist.js +300 -0
- package/dist/vanilla/toast.d.ts +11 -3
- package/dist/vanilla/toast.js +125 -10
- package/dist/vanilla/tooltip.d.ts +5 -1
- package/dist/vanilla/tooltip.js +57 -10
- package/dist/vanilla.css +581 -158
- package/package.json +4 -1
package/dist/vanilla/modal.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/** Lock page scrolling on `<html>` (ref-counted). Pair every call with `unlockScroll()`. */
|
|
2
|
+
export declare function lockScroll(): void;
|
|
3
|
+
/** Release one `lockScroll()`; the last release restores `<html>`'s previous `overflow`. */
|
|
4
|
+
export declare function unlockScroll(): void;
|
|
1
5
|
export declare function openModal(dialog: HTMLDialogElement): void;
|
|
2
6
|
export declare function closeModal(dialog: HTMLDialogElement): void;
|
|
3
7
|
export declare function installModal(): void;
|
package/dist/vanilla/modal.js
CHANGED
|
@@ -7,15 +7,64 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Backdrop pointerdown closes unless the dialog carries `data-ss-static`; Escape is blocked
|
|
9
9
|
* when it carries `data-ss-no-esc` (mirrors `closeOnBackdrop` / `closeOnEsc`).
|
|
10
|
+
*
|
|
11
|
+
* While a modal is open the page behind it must not scroll (DS-0178): `lockScroll()` sets
|
|
12
|
+
* `overflow: hidden` on `<html>` and `unlockScroll()` restores it. The lock is ref-counted on
|
|
13
|
+
* `<html data-ss-scroll-lock>` so stacked dialogs, and the Svelte component sharing this helper
|
|
14
|
+
* from a separate bundle, release it only when the last one closes.
|
|
10
15
|
*/
|
|
11
16
|
import { on, byId } from './delegate.js';
|
|
17
|
+
const COUNT = 'ssScrollLock';
|
|
18
|
+
const PREV = 'ssScrollLockPrev';
|
|
19
|
+
/** Lock page scrolling on `<html>` (ref-counted). Pair every call with `unlockScroll()`. */
|
|
20
|
+
export function lockScroll() {
|
|
21
|
+
if (typeof document === 'undefined')
|
|
22
|
+
return;
|
|
23
|
+
const root = document.documentElement;
|
|
24
|
+
const n = Number(root.dataset[COUNT] ?? 0) || 0;
|
|
25
|
+
if (n === 0) {
|
|
26
|
+
root.dataset[PREV] = root.style.overflow;
|
|
27
|
+
root.style.overflow = 'hidden';
|
|
28
|
+
}
|
|
29
|
+
root.dataset[COUNT] = String(n + 1);
|
|
30
|
+
}
|
|
31
|
+
/** Release one `lockScroll()`; the last release restores `<html>`'s previous `overflow`. */
|
|
32
|
+
export function unlockScroll() {
|
|
33
|
+
if (typeof document === 'undefined')
|
|
34
|
+
return;
|
|
35
|
+
const root = document.documentElement;
|
|
36
|
+
const n = Number(root.dataset[COUNT] ?? 0) || 0;
|
|
37
|
+
if (n <= 0)
|
|
38
|
+
return;
|
|
39
|
+
if (n > 1) {
|
|
40
|
+
root.dataset[COUNT] = String(n - 1);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
root.style.overflow = root.dataset[PREV] ?? '';
|
|
44
|
+
delete root.dataset[COUNT];
|
|
45
|
+
delete root.dataset[PREV];
|
|
46
|
+
}
|
|
47
|
+
// Dialogs that currently hold a scroll lock (so a lock is taken and released exactly once).
|
|
48
|
+
const locked = new WeakSet();
|
|
49
|
+
function release(dialog) {
|
|
50
|
+
if (!locked.has(dialog))
|
|
51
|
+
return;
|
|
52
|
+
locked.delete(dialog);
|
|
53
|
+
unlockScroll();
|
|
54
|
+
}
|
|
12
55
|
export function openModal(dialog) {
|
|
13
|
-
if (
|
|
14
|
-
|
|
56
|
+
if (dialog.open)
|
|
57
|
+
return;
|
|
58
|
+
dialog.showModal();
|
|
59
|
+
if (!locked.has(dialog)) {
|
|
60
|
+
locked.add(dialog);
|
|
61
|
+
lockScroll();
|
|
62
|
+
}
|
|
15
63
|
}
|
|
16
64
|
export function closeModal(dialog) {
|
|
17
65
|
if (dialog.open)
|
|
18
66
|
dialog.close();
|
|
67
|
+
release(dialog);
|
|
19
68
|
}
|
|
20
69
|
export function installModal() {
|
|
21
70
|
on('click', '[data-ss-modal]', (opener, e) => {
|
|
@@ -35,6 +84,12 @@ export function installModal() {
|
|
|
35
84
|
return;
|
|
36
85
|
closeModal(dialog);
|
|
37
86
|
});
|
|
87
|
+
// Native closes (Escape, `<form method="dialog">`, a direct `.close()`) release the scroll
|
|
88
|
+
// lock too. `close` does not bubble — capture it.
|
|
89
|
+
on('close', 'dialog.ss-modal', (dialog) => {
|
|
90
|
+
if (dialog instanceof HTMLDialogElement)
|
|
91
|
+
release(dialog);
|
|
92
|
+
}, { capture: true });
|
|
38
93
|
// `cancel` does not bubble — capture it.
|
|
39
94
|
on('cancel', 'dialog.ss-modal[data-ss-no-esc]', (_dialog, e) => {
|
|
40
95
|
e.preventDefault();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SegmentedControl (DS-0148) — radio-group selection over `.ss-segmented > .segment[role=radio]`
|
|
3
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 }`;
|
|
4
|
+
* wrapping over enabled segments; Left/Right mirror under RTL). Emits `ss:change` on the root with `{ value, index }`;
|
|
5
5
|
* `value` is the segment's `data-value` (vanilla-only attribute) or its label text.
|
|
6
6
|
*/
|
|
7
7
|
import { on, emit, all } from './delegate.js';
|
|
@@ -34,15 +34,24 @@ export function installSegmented() {
|
|
|
34
34
|
const enabled = segments(root).filter((s) => !s.disabled);
|
|
35
35
|
const pos = enabled.indexOf(segment);
|
|
36
36
|
const n = enabled.length;
|
|
37
|
+
const next = ((pos < 0 ? -1 : pos) + 1 + n) % n;
|
|
38
|
+
const prev = ((pos < 0 ? 0 : pos) - 1 + n) % n;
|
|
39
|
+
// RTL: the row runs right-to-left, so ArrowLeft points at the NEXT segment.
|
|
40
|
+
// Read the inherited computed direction at keydown time; Up/Down stay logical.
|
|
41
|
+
const rtl = getComputedStyle(segment).direction === 'rtl';
|
|
37
42
|
let target;
|
|
38
43
|
switch (e.key) {
|
|
39
44
|
case 'ArrowRight':
|
|
40
|
-
|
|
41
|
-
target = ((pos < 0 ? -1 : pos) + 1 + n) % n;
|
|
45
|
+
target = rtl ? prev : next;
|
|
42
46
|
break;
|
|
43
47
|
case 'ArrowLeft':
|
|
48
|
+
target = rtl ? next : prev;
|
|
49
|
+
break;
|
|
50
|
+
case 'ArrowDown':
|
|
51
|
+
target = next;
|
|
52
|
+
break;
|
|
44
53
|
case 'ArrowUp':
|
|
45
|
-
target =
|
|
54
|
+
target = prev;
|
|
46
55
|
break;
|
|
47
56
|
case 'Home':
|
|
48
57
|
target = 0;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type TierListPlacements, type TierListZones } from '../tierlist-core.js';
|
|
2
|
+
/** The zone map as the DOM currently has it. */
|
|
3
|
+
export declare function readZones(root: HTMLElement): TierListZones;
|
|
4
|
+
/** Public placements read from the DOM: every non-tray zone, in DOM order. */
|
|
5
|
+
export declare function readPlacements(root: HTMLElement): TierListPlacements;
|
|
6
|
+
/** Pick a tile up (or drop it when it is already grabbed). */
|
|
7
|
+
export declare function toggleGrab(tile: HTMLElement): void;
|
|
8
|
+
export declare function installTierlist(): void;
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TierList (DS-0159) — plain-HTML behaviour for the markup `TierList.svelte` renders: pointer
|
|
3
|
+
* drag between/within rows (Pointer Events, so touch works) and the keyboard path (Space picks
|
|
4
|
+
* a tile up, arrows move it, Space drops, Escape cancels) with a polite live region. The move
|
|
5
|
+
* math and the wording come from `../tierlist-core.js`, shared with the Svelte component.
|
|
6
|
+
* Emits `ss:change` on the root with `{ placements }` (tier id → item ids; the tray is
|
|
7
|
+
* implicit). `data-ss-readonly` on the root makes the list inert.
|
|
8
|
+
*/
|
|
9
|
+
import { on, emit, all } from './delegate.js';
|
|
10
|
+
import { TRAY, announceText, insertionIndex, keyMoveFor, keyboardTarget, } from '../tierlist-core.js';
|
|
11
|
+
const ROOT = '.ss-tierlist';
|
|
12
|
+
const TILE = `${ROOT} .tile[data-item]`;
|
|
13
|
+
const DRAG_THRESHOLD = 4;
|
|
14
|
+
function rootOf(el) {
|
|
15
|
+
return el.closest(ROOT);
|
|
16
|
+
}
|
|
17
|
+
function zonesOf(root) {
|
|
18
|
+
return all(root, '[data-zone]').filter((z) => rootOf(z) === root);
|
|
19
|
+
}
|
|
20
|
+
function zoneKey(zone) {
|
|
21
|
+
return zone.hasAttribute('data-tray') ? TRAY : zone.dataset.zone;
|
|
22
|
+
}
|
|
23
|
+
function zoneByKey(root, key) {
|
|
24
|
+
return zonesOf(root).find((z) => zoneKey(z) === key);
|
|
25
|
+
}
|
|
26
|
+
function zoneLabel(zone) {
|
|
27
|
+
return zone.getAttribute('aria-label') ?? zone.dataset.zoneLabel ?? zoneKey(zone);
|
|
28
|
+
}
|
|
29
|
+
function cellsOf(zone) {
|
|
30
|
+
return all(zone, ':scope > .cell');
|
|
31
|
+
}
|
|
32
|
+
/** The zone map as the DOM currently has it. */
|
|
33
|
+
export function readZones(root) {
|
|
34
|
+
const zones = {};
|
|
35
|
+
for (const zone of zonesOf(root)) {
|
|
36
|
+
zones[zoneKey(zone)] = cellsOf(zone).map((c) => c.querySelector('.tile[data-item]')?.dataset.item ?? '');
|
|
37
|
+
}
|
|
38
|
+
return zones;
|
|
39
|
+
}
|
|
40
|
+
/** Public placements read from the DOM: every non-tray zone, in DOM order. */
|
|
41
|
+
export function readPlacements(root) {
|
|
42
|
+
const out = {};
|
|
43
|
+
for (const zone of zonesOf(root)) {
|
|
44
|
+
const key = zoneKey(zone);
|
|
45
|
+
if (key !== TRAY)
|
|
46
|
+
out[key] = readZones(root)[key];
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
function isReadonly(root) {
|
|
51
|
+
return root.hasAttribute('data-ss-readonly');
|
|
52
|
+
}
|
|
53
|
+
function announce(root, text) {
|
|
54
|
+
const live = root.querySelector('.live');
|
|
55
|
+
if (live)
|
|
56
|
+
live.textContent = text;
|
|
57
|
+
}
|
|
58
|
+
// Re-inserting a focused node blurs it (browsers run the focus fixup on removal); while a
|
|
59
|
+
// keyboard move is in flight that blur must not read as "the user left the tile".
|
|
60
|
+
let moving = false;
|
|
61
|
+
/** Physically move a tile's cell to `zone` at `index` (clamped; the cell may already be there). */
|
|
62
|
+
function placeCell(root, cell, zone, index) {
|
|
63
|
+
const target = zoneByKey(root, zone);
|
|
64
|
+
if (!target)
|
|
65
|
+
return;
|
|
66
|
+
const siblings = cellsOf(target).filter((c) => c !== cell);
|
|
67
|
+
const before = siblings[Math.max(0, Math.min(index, siblings.length))] ?? null;
|
|
68
|
+
const was = moving;
|
|
69
|
+
moving = true;
|
|
70
|
+
try {
|
|
71
|
+
target.insertBefore(cell, before);
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
moving = was;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function describe(root, tile) {
|
|
78
|
+
const cell = tile.closest('.cell');
|
|
79
|
+
const zone = cell.parentElement;
|
|
80
|
+
const cells = cellsOf(zone);
|
|
81
|
+
return {
|
|
82
|
+
label: tile.getAttribute('aria-label') ?? tile.textContent?.trim() ?? '',
|
|
83
|
+
zone: zoneLabel(zone),
|
|
84
|
+
index: cells.indexOf(cell),
|
|
85
|
+
count: cells.length,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function change(root) {
|
|
89
|
+
emit(root, 'ss:change', { placements: readPlacements(root) });
|
|
90
|
+
}
|
|
91
|
+
const grabs = new WeakMap();
|
|
92
|
+
/** Read at event time: `dir` may sit on any ancestor and change after install. */
|
|
93
|
+
function isRtl(el) {
|
|
94
|
+
return getComputedStyle(el).direction === 'rtl';
|
|
95
|
+
}
|
|
96
|
+
function setGrabbed(root, tile) {
|
|
97
|
+
for (const t of all(root, '.tile[aria-pressed="true"]')) {
|
|
98
|
+
t.setAttribute('aria-pressed', 'false');
|
|
99
|
+
t.closest('.cell')?.classList.remove('grabbed');
|
|
100
|
+
}
|
|
101
|
+
root.classList.toggle('sorting', Boolean(tile));
|
|
102
|
+
if (tile) {
|
|
103
|
+
tile.setAttribute('aria-pressed', 'true');
|
|
104
|
+
tile.closest('.cell')?.classList.add('grabbed');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/** Pick a tile up (or drop it when it is already grabbed). */
|
|
108
|
+
export function toggleGrab(tile) {
|
|
109
|
+
const root = rootOf(tile);
|
|
110
|
+
if (!root || isReadonly(root))
|
|
111
|
+
return;
|
|
112
|
+
const grab = grabs.get(root);
|
|
113
|
+
if (grab?.tile === tile) {
|
|
114
|
+
grabs.delete(root);
|
|
115
|
+
setGrabbed(root, null);
|
|
116
|
+
announce(root, announceText('drop', describe(root, tile)));
|
|
117
|
+
change(root);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const d = describe(root, tile);
|
|
121
|
+
const cell = tile.closest('.cell');
|
|
122
|
+
grabs.set(root, { tile, zone: zoneKey(cell.parentElement), index: d.index });
|
|
123
|
+
setGrabbed(root, tile);
|
|
124
|
+
announce(root, announceText('grab', d));
|
|
125
|
+
}
|
|
126
|
+
/** `focusBack`: Escape keeps the user on the tile; a cancel caused by focus leaving must not pull it back. */
|
|
127
|
+
function cancelGrab(root, focusBack) {
|
|
128
|
+
const grab = grabs.get(root);
|
|
129
|
+
if (!grab)
|
|
130
|
+
return;
|
|
131
|
+
grabs.delete(root);
|
|
132
|
+
const cell = grab.tile.closest('.cell');
|
|
133
|
+
moving = true;
|
|
134
|
+
try {
|
|
135
|
+
placeCell(root, cell, grab.zone, grab.index);
|
|
136
|
+
setGrabbed(root, null);
|
|
137
|
+
if (focusBack)
|
|
138
|
+
grab.tile.focus();
|
|
139
|
+
}
|
|
140
|
+
finally {
|
|
141
|
+
moving = false;
|
|
142
|
+
}
|
|
143
|
+
announce(root, announceText('cancel', describe(root, grab.tile)));
|
|
144
|
+
}
|
|
145
|
+
function keyMove(root, tile, move) {
|
|
146
|
+
const zones = readZones(root);
|
|
147
|
+
const order = zonesOf(root).map(zoneKey);
|
|
148
|
+
const target = keyboardTarget(zones, order, tile.dataset.item, move);
|
|
149
|
+
if (!target)
|
|
150
|
+
return;
|
|
151
|
+
const cell = tile.closest('.cell');
|
|
152
|
+
moving = true;
|
|
153
|
+
try {
|
|
154
|
+
placeCell(root, cell, target.zone, target.index);
|
|
155
|
+
tile.focus();
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
moving = false;
|
|
159
|
+
}
|
|
160
|
+
announce(root, announceText('move', describe(root, tile)));
|
|
161
|
+
}
|
|
162
|
+
let drag = null;
|
|
163
|
+
function zoneAt(root, x, y) {
|
|
164
|
+
for (const el of document.elementsFromPoint(x, y)) {
|
|
165
|
+
const zone = el.closest('[data-zone]');
|
|
166
|
+
if (zone && rootOf(zone) === root)
|
|
167
|
+
return zone;
|
|
168
|
+
}
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
function startDrag(d) {
|
|
172
|
+
d.dragging = true;
|
|
173
|
+
const rect = d.tile.getBoundingClientRect();
|
|
174
|
+
d.dx = d.startX - rect.left;
|
|
175
|
+
d.dy = d.startY - rect.top;
|
|
176
|
+
const ghost = d.tile.cloneNode(true);
|
|
177
|
+
ghost.classList.add('ghost');
|
|
178
|
+
ghost.removeAttribute('id');
|
|
179
|
+
ghost.setAttribute('aria-hidden', 'true');
|
|
180
|
+
ghost.style.width = `${rect.width}px`;
|
|
181
|
+
ghost.style.height = `${rect.height}px`;
|
|
182
|
+
d.root.appendChild(ghost);
|
|
183
|
+
d.ghost = ghost;
|
|
184
|
+
d.cell.classList.add('shadow');
|
|
185
|
+
d.root.classList.add('dragging');
|
|
186
|
+
}
|
|
187
|
+
function moveDrag(d, x, y) {
|
|
188
|
+
if (d.ghost)
|
|
189
|
+
d.ghost.style.transform = `translate(${x - d.dx}px, ${y - d.dy}px)`;
|
|
190
|
+
const zone = zoneAt(d.root, x, y);
|
|
191
|
+
for (const z of zonesOf(d.root))
|
|
192
|
+
z.classList.toggle('target', z === zone);
|
|
193
|
+
if (!zone)
|
|
194
|
+
return;
|
|
195
|
+
const boxes = cellsOf(zone)
|
|
196
|
+
.filter((c) => c !== d.cell)
|
|
197
|
+
.map((c) => c.getBoundingClientRect());
|
|
198
|
+
placeCell(d.root, d.cell, zoneKey(zone), insertionIndex(boxes, x, y, isRtl(zone)));
|
|
199
|
+
}
|
|
200
|
+
function endDrag(d, cancelled) {
|
|
201
|
+
d.ghost?.remove();
|
|
202
|
+
d.cell.classList.remove('shadow');
|
|
203
|
+
d.root.classList.remove('dragging');
|
|
204
|
+
for (const z of zonesOf(d.root))
|
|
205
|
+
z.classList.remove('target');
|
|
206
|
+
if (cancelled) {
|
|
207
|
+
placeCell(d.root, d.cell, d.zone, d.index);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const now = describe(d.root, d.tile);
|
|
211
|
+
if (zoneKey(d.cell.parentElement) !== d.zone || now.index !== d.index) {
|
|
212
|
+
announce(d.root, announceText('drop', now));
|
|
213
|
+
change(d.root);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
export function installTierlist() {
|
|
217
|
+
on('keydown', TILE, (tile, e) => {
|
|
218
|
+
const root = rootOf(tile);
|
|
219
|
+
if (!root || isReadonly(root))
|
|
220
|
+
return;
|
|
221
|
+
const grab = grabs.get(root);
|
|
222
|
+
if (e.key === ' ' || (e.key === 'Enter' && !tile.hasAttribute('data-ss-activate'))) {
|
|
223
|
+
e.preventDefault();
|
|
224
|
+
toggleGrab(tile);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (e.key === 'Escape' && grab?.tile === tile) {
|
|
228
|
+
e.preventDefault();
|
|
229
|
+
cancelGrab(root, true);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const move = keyMoveFor(e.key, isRtl(tile));
|
|
233
|
+
if (move && grab?.tile === tile) {
|
|
234
|
+
e.preventDefault();
|
|
235
|
+
keyMove(root, tile, move);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
// Cancel when focus has really left a grabbed tile — checked a beat later, because moving
|
|
239
|
+
// the node (a row change re-inserts it) blurs it in some browsers before it is re-focused.
|
|
240
|
+
on('focusout', TILE, (tile) => {
|
|
241
|
+
if (moving)
|
|
242
|
+
return;
|
|
243
|
+
const root = rootOf(tile);
|
|
244
|
+
if (!root || grabs.get(root)?.tile !== tile)
|
|
245
|
+
return;
|
|
246
|
+
setTimeout(() => {
|
|
247
|
+
if (grabs.get(root)?.tile === tile && document.activeElement !== tile)
|
|
248
|
+
cancelGrab(root, false);
|
|
249
|
+
}, 0);
|
|
250
|
+
});
|
|
251
|
+
on('pointerdown', TILE, (tile, e) => {
|
|
252
|
+
const root = rootOf(tile);
|
|
253
|
+
if (!root || isReadonly(root) || e.button !== 0 || grabs.has(root))
|
|
254
|
+
return;
|
|
255
|
+
const cell = tile.closest('.cell');
|
|
256
|
+
const zone = cell.parentElement;
|
|
257
|
+
drag = {
|
|
258
|
+
root,
|
|
259
|
+
tile,
|
|
260
|
+
cell,
|
|
261
|
+
startX: e.clientX,
|
|
262
|
+
startY: e.clientY,
|
|
263
|
+
dragging: false,
|
|
264
|
+
ghost: null,
|
|
265
|
+
dx: 0,
|
|
266
|
+
dy: 0,
|
|
267
|
+
zone: zoneKey(zone),
|
|
268
|
+
index: cellsOf(zone).indexOf(cell),
|
|
269
|
+
};
|
|
270
|
+
});
|
|
271
|
+
// Document-level, not on the tile: re-inserting the cell while it moves between rows
|
|
272
|
+
// releases any pointer capture, so the rest of the drag must not depend on the tile.
|
|
273
|
+
document.addEventListener('pointermove', (e) => {
|
|
274
|
+
if (!drag)
|
|
275
|
+
return;
|
|
276
|
+
if (!drag.dragging) {
|
|
277
|
+
if (Math.hypot(e.clientX - drag.startX, e.clientY - drag.startY) < DRAG_THRESHOLD)
|
|
278
|
+
return;
|
|
279
|
+
startDrag(drag);
|
|
280
|
+
}
|
|
281
|
+
e.preventDefault();
|
|
282
|
+
moveDrag(drag, e.clientX, e.clientY);
|
|
283
|
+
});
|
|
284
|
+
document.addEventListener('pointerup', () => {
|
|
285
|
+
if (!drag)
|
|
286
|
+
return;
|
|
287
|
+
const d = drag;
|
|
288
|
+
drag = null;
|
|
289
|
+
if (d.dragging)
|
|
290
|
+
endDrag(d, false);
|
|
291
|
+
});
|
|
292
|
+
document.addEventListener('pointercancel', () => {
|
|
293
|
+
if (!drag)
|
|
294
|
+
return;
|
|
295
|
+
const d = drag;
|
|
296
|
+
drag = null;
|
|
297
|
+
if (d.dragging)
|
|
298
|
+
endDrag(d, true);
|
|
299
|
+
});
|
|
300
|
+
}
|
package/dist/vanilla/toast.d.ts
CHANGED
|
@@ -7,9 +7,15 @@
|
|
|
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 { type Toast, type ToastKind, type ToastOptions, type ToastPatch, type PromiseMessages } from '../toast-core.js';
|
|
15
21
|
export type { Toast, ToastKind, ToastOptions, ToastPatch, ToastAction, PromiseMessages, } from '../toast-core.js';
|
|
@@ -19,6 +25,8 @@ declare class VanillaToastStore {
|
|
|
19
25
|
/** Visible toasts (read-only snapshot). */
|
|
20
26
|
get items(): Toast[];
|
|
21
27
|
get container(): HTMLElement;
|
|
28
|
+
/** Prepare the live regions of an author-placed container ahead of the first toast. */
|
|
29
|
+
prepare(): void;
|
|
22
30
|
push(kind: ToastKind, message: string, opts?: ToastOptions | number): number;
|
|
23
31
|
update(id: number, patch: ToastPatch): boolean;
|
|
24
32
|
pause(id: number): void;
|