dssoca 0.20.0 → 0.22.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/components/Accordion.svelte +23 -52
- package/dist/components/BottomNav.svelte +18 -28
- package/dist/components/BoxPlot.svelte +7 -6
- package/dist/components/BumpChart.svelte +9 -12
- package/dist/components/Chart.svelte +9 -12
- package/dist/components/Checkbox.svelte +210 -0
- package/dist/components/Checkbox.svelte.d.ts +38 -0
- package/dist/components/FileDrop.svelte +52 -83
- package/dist/components/FileDrop.svelte.d.ts +6 -2
- package/dist/components/Heatmap.svelte +8 -8
- package/dist/components/Image.svelte +44 -44
- package/dist/components/Input.svelte +8 -3
- package/dist/components/LogStream.svelte +15 -25
- package/dist/components/Menu.svelte +69 -94
- package/dist/components/Menu.svelte.d.ts +6 -0
- package/dist/components/Modal.svelte +61 -14
- package/dist/components/Modal.svelte.d.ts +7 -2
- package/dist/components/NumberField.svelte +18 -19
- package/dist/components/Pagination.svelte +47 -37
- package/dist/components/Pagination.svelte.d.ts +6 -2
- package/dist/components/Popover.svelte +404 -0
- package/dist/components/Popover.svelte.d.ts +55 -0
- package/dist/components/RadioGroup.svelte +227 -0
- package/dist/components/RadioGroup.svelte.d.ts +42 -0
- package/dist/components/ScatterPlot.svelte +11 -13
- package/dist/components/SearchPalette.svelte +124 -120
- package/dist/components/SearchPalette.svelte.d.ts +6 -4
- package/dist/components/SegmentedControl.svelte +41 -62
- package/dist/components/SegmentedControl.svelte.d.ts +7 -2
- package/dist/components/ShortcutsHelp.svelte +48 -47
- package/dist/components/Sidebar.svelte +48 -60
- package/dist/components/Switch.svelte +20 -10
- package/dist/components/Switch.svelte.d.ts +6 -2
- package/dist/components/Table.svelte +15 -37
- package/dist/components/Tabs.svelte +223 -0
- package/dist/components/Tabs.svelte.d.ts +51 -0
- package/dist/components/TierList.svelte +41 -38
- package/dist/components/TierList.svelte.d.ts +7 -3
- package/dist/components/Toaster.svelte +29 -29
- package/dist/components/Tooltip.svelte +37 -21
- package/dist/components/Topbar.svelte +13 -38
- package/dist/core/accordion.d.ts +32 -0
- package/dist/core/accordion.js +53 -0
- package/dist/core/behaviors/focusable.d.ts +5 -0
- package/dist/core/behaviors/focusable.js +14 -0
- package/dist/core/behaviors/roving.d.ts +13 -0
- package/dist/core/behaviors/roving.js +29 -0
- package/dist/core/bottom-nav.d.ts +36 -0
- package/dist/core/bottom-nav.js +33 -0
- package/dist/core/chart-nav.d.ts +53 -0
- package/dist/{chart-nav.js → core/chart-nav.js} +27 -0
- package/dist/core/checkbox.d.ts +36 -0
- package/dist/core/checkbox.js +29 -0
- package/dist/core/file-drop.d.ts +75 -0
- package/dist/core/file-drop.js +101 -0
- package/dist/core/image.d.ts +59 -0
- package/dist/core/image.js +64 -0
- package/dist/core/input.d.ts +21 -0
- package/dist/core/input.js +17 -0
- package/dist/core/log-stream.d.ts +51 -0
- package/dist/core/log-stream.js +50 -0
- package/dist/core/menu.d.ts +70 -0
- package/dist/core/menu.js +84 -0
- package/dist/core/modal.d.ts +59 -0
- package/dist/core/modal.js +44 -0
- package/dist/core/number-field.d.ts +47 -0
- package/dist/core/number-field.js +64 -0
- package/dist/core/pagination.d.ts +59 -0
- package/dist/core/pagination.js +65 -0
- package/dist/core/popover.d.ts +111 -0
- package/dist/core/popover.js +86 -0
- package/dist/core/radio.d.ts +36 -0
- package/dist/core/radio.js +48 -0
- package/dist/core/search-palette.d.ts +124 -0
- package/dist/core/search-palette.js +149 -0
- package/dist/core/segmented.d.ts +46 -0
- package/dist/core/segmented.js +66 -0
- package/dist/core/shortcuts-help.d.ts +56 -0
- package/dist/core/shortcuts-help.js +50 -0
- package/dist/core/sidebar.d.ts +63 -0
- package/dist/core/sidebar.js +84 -0
- package/dist/core/switch.d.ts +19 -0
- package/dist/core/switch.js +11 -0
- package/dist/core/table.d.ts +40 -0
- package/dist/core/table.js +57 -0
- package/dist/core/tabs.d.ts +84 -0
- package/dist/core/tabs.js +90 -0
- package/dist/{tierlist-core.d.ts → core/tierlist.d.ts} +62 -0
- package/dist/{tierlist-core.js → core/tierlist.js} +34 -0
- package/dist/core/toast.d.ts +112 -0
- package/dist/{toast-core.js → core/toast.js} +48 -2
- package/dist/core/tooltip.d.ts +47 -0
- package/dist/core/tooltip.js +51 -0
- package/dist/core/topbar.d.ts +41 -0
- package/dist/core/topbar.js +52 -0
- package/dist/dssoca.config.d.ts +1 -1
- package/dist/dssoca.config.js +4 -0
- package/dist/index.d.ts +14 -1
- package/dist/index.js +9 -1
- package/dist/theme.css +47 -0
- package/dist/toast.svelte.d.ts +2 -2
- package/dist/toast.svelte.js +1 -1
- package/dist/tokens.css +47 -0
- package/dist/vanilla/accordion.js +28 -29
- package/dist/vanilla/checkbox.d.ts +8 -0
- package/dist/vanilla/checkbox.js +43 -0
- package/dist/vanilla/delegate.d.ts +2 -0
- package/dist/vanilla/delegate.js +9 -0
- package/dist/vanilla/fields.js +37 -32
- package/dist/vanilla/index.d.ts +4 -0
- package/dist/vanilla/index.js +16 -3
- package/dist/vanilla/menu.js +92 -86
- package/dist/vanilla/modal.d.ts +3 -1
- package/dist/vanilla/modal.js +65 -15
- package/dist/vanilla/popover.d.ts +10 -0
- package/dist/vanilla/popover.js +199 -0
- package/dist/vanilla/radio.d.ts +3 -0
- package/dist/vanilla/radio.js +54 -0
- package/dist/vanilla/segmented.js +49 -51
- package/dist/vanilla/switch.d.ts +2 -1
- package/dist/vanilla/switch.js +13 -8
- package/dist/vanilla/tabs.d.ts +2 -0
- package/dist/vanilla/tabs.js +87 -0
- package/dist/vanilla/tierlist.d.ts +1 -1
- package/dist/vanilla/tierlist.js +32 -25
- package/dist/vanilla/toast.d.ts +2 -2
- package/dist/vanilla/toast.js +16 -14
- package/dist/vanilla/tooltip.js +35 -23
- package/dist/vanilla.css +364 -42
- package/package.json +1 -1
- package/dist/chart-nav.d.ts +0 -13
- package/dist/toast-core.d.ts +0 -61
|
@@ -1,71 +1,69 @@
|
|
|
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; Left/Right mirror under RTL).
|
|
5
|
-
*
|
|
4
|
+
* wrapping over enabled segments; Left/Right mirror under RTL). The behaviour itself comes from
|
|
5
|
+
* `../core/segmented.js`, shared with the Svelte component (DS-0197): this file reads the state
|
|
6
|
+
* from the DOM, asks the core, and writes the result back. Emits `ss:change` on the root with
|
|
7
|
+
* `{ value, index, reason }`; `value` is the segment's `data-value` (vanilla-only attribute) or
|
|
8
|
+
* its label text, `reason` is `'press'` or `'key'`.
|
|
6
9
|
*/
|
|
7
|
-
import { on, emit, all } from './delegate.js';
|
|
10
|
+
import { on, emit, all, setAttrs } from './delegate.js';
|
|
11
|
+
import { segmentedItemAttrs, segmentedKey, segmentedPress, segmentedTabStop, } from '../core/segmented.js';
|
|
12
|
+
const SEGMENT = '.ss-segmented .segment[role="radio"]';
|
|
8
13
|
function segments(root) {
|
|
9
14
|
return all(root, '.segment[role="radio"]').filter((s) => s.closest('.ss-segmented') === root);
|
|
10
15
|
}
|
|
16
|
+
/** The group's state, read from the DOM (the DOM is the store on the plain-HTML path). */
|
|
17
|
+
function read(root, list) {
|
|
18
|
+
const groupDisabled = root.getAttribute('aria-disabled') === 'true';
|
|
19
|
+
return {
|
|
20
|
+
selected: list.findIndex((s) => s.getAttribute('aria-checked') === 'true'),
|
|
21
|
+
enabled: groupDisabled
|
|
22
|
+
? []
|
|
23
|
+
: list.map((s, index) => (s.disabled ? -1 : index)).filter((index) => index >= 0),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** Apply a core action to the DOM. */
|
|
27
|
+
function run(root, list, action) {
|
|
28
|
+
if (!action)
|
|
29
|
+
return;
|
|
30
|
+
const segment = list[action.index];
|
|
31
|
+
if (!segment)
|
|
32
|
+
return;
|
|
33
|
+
const tabStop = segmentedTabStop({ ...read(root, list), selected: action.index });
|
|
34
|
+
list.forEach((s, index) => {
|
|
35
|
+
s.classList.toggle('selected', index === action.index);
|
|
36
|
+
setAttrs(s, segmentedItemAttrs(index, action.index, tabStop));
|
|
37
|
+
});
|
|
38
|
+
if (action.changed) {
|
|
39
|
+
const value = segment.dataset.value ?? segment.querySelector('.label')?.textContent?.trim() ?? '';
|
|
40
|
+
emit(root, 'ss:change', { value, index: action.index, reason: action.reason });
|
|
41
|
+
}
|
|
42
|
+
if (action.focus)
|
|
43
|
+
segment.focus();
|
|
44
|
+
}
|
|
11
45
|
export function selectSegment(segment) {
|
|
12
46
|
const root = segment.closest('.ss-segmented');
|
|
13
|
-
if (!root
|
|
47
|
+
if (!root)
|
|
14
48
|
return;
|
|
15
49
|
const list = segments(root);
|
|
16
|
-
|
|
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) });
|
|
50
|
+
run(root, list, segmentedPress(read(root, list), list.indexOf(segment)));
|
|
27
51
|
}
|
|
28
52
|
export function installSegmented() {
|
|
29
|
-
on('click',
|
|
30
|
-
on('keydown',
|
|
53
|
+
on('click', SEGMENT, (s) => selectSegment(s));
|
|
54
|
+
on('keydown', SEGMENT, (segment, e) => {
|
|
31
55
|
const root = segment.closest('.ss-segmented');
|
|
32
56
|
if (!root)
|
|
33
57
|
return;
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
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.
|
|
58
|
+
const list = segments(root);
|
|
59
|
+
// RTL: the row runs right-to-left, so ArrowLeft points at the NEXT segment. Read the
|
|
60
|
+
// inherited computed direction at keydown time and hand it to the core.
|
|
41
61
|
const rtl = getComputedStyle(segment).direction === 'rtl';
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
case 'ArrowRight':
|
|
45
|
-
target = rtl ? prev : next;
|
|
46
|
-
break;
|
|
47
|
-
case 'ArrowLeft':
|
|
48
|
-
target = rtl ? next : prev;
|
|
49
|
-
break;
|
|
50
|
-
case 'ArrowDown':
|
|
51
|
-
target = next;
|
|
52
|
-
break;
|
|
53
|
-
case 'ArrowUp':
|
|
54
|
-
target = prev;
|
|
55
|
-
break;
|
|
56
|
-
case 'Home':
|
|
57
|
-
target = 0;
|
|
58
|
-
break;
|
|
59
|
-
case 'End':
|
|
60
|
-
target = n - 1;
|
|
61
|
-
break;
|
|
62
|
-
default:
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (n === 0)
|
|
62
|
+
const result = segmentedKey(read(root, list), list.indexOf(segment), e.key, rtl);
|
|
63
|
+
if (!result)
|
|
66
64
|
return;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
if (result.preventDefault)
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
run(root, list, result.action);
|
|
70
68
|
});
|
|
71
69
|
}
|
package/dist/vanilla/switch.d.ts
CHANGED
package/dist/vanilla/switch.js
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Switch (DS-0148) — flips `aria-checked` + `.on` on `.ss-switch .track[role=switch]`; clicking
|
|
3
3
|
* the sibling `.label` toggles too (same target as the control, like Switch.svelte). Emits
|
|
4
|
-
* `ss:change` on the root with `{ checked }`.
|
|
4
|
+
* `ss:change` on the root with `{ checked, reason }`. The decision comes from
|
|
5
|
+
* `../core/switch.js`, shared with the Svelte component (DS-0198); state is read from the DOM.
|
|
5
6
|
*/
|
|
6
|
-
import { on, emit } from './delegate.js';
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import { on, emit, setAttrs } from './delegate.js';
|
|
8
|
+
import { switchToggle, switchTrackAttrs } from '../core/switch.js';
|
|
9
|
+
export function toggleSwitch(track, reason = 'track') {
|
|
10
|
+
const next = switchToggle({
|
|
11
|
+
checked: track.getAttribute('aria-checked') === 'true',
|
|
12
|
+
disabled: track.disabled,
|
|
13
|
+
});
|
|
14
|
+
if (next === null)
|
|
9
15
|
return;
|
|
10
|
-
|
|
11
|
-
track.setAttribute('aria-checked', String(next));
|
|
16
|
+
setAttrs(track, switchTrackAttrs(next));
|
|
12
17
|
track.classList.toggle('on', next);
|
|
13
|
-
emit(track.closest('.ss-switch') ?? track, 'ss:change', { checked: next });
|
|
18
|
+
emit(track.closest('.ss-switch') ?? track, 'ss:change', { checked: next, reason });
|
|
14
19
|
}
|
|
15
20
|
export function installSwitch() {
|
|
16
21
|
on('click', '.ss-switch .track[role="switch"]', (track) => toggleSwitch(track));
|
|
17
22
|
on('click', '.ss-switch .label', (label) => {
|
|
18
23
|
const track = label.closest('.ss-switch')?.querySelector('.track');
|
|
19
24
|
if (track)
|
|
20
|
-
toggleSwitch(track);
|
|
25
|
+
toggleSwitch(track, 'label');
|
|
21
26
|
});
|
|
22
27
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tabs (DS-0197) — the WAI-ARIA tabs pattern over the exact DOM Tabs.svelte renders:
|
|
3
|
+
* `.ss-tabs > .list[role=tablist] > .tab[role=tab]` plus one `.panel[role=tabpanel]` per tab
|
|
4
|
+
* (each tab's `aria-controls` names its panel; without it the n-th tab owns the n-th panel).
|
|
5
|
+
* The behaviour itself comes from `../core/tabs.js`, shared with the Svelte component: this file
|
|
6
|
+
* reads the state from the DOM, asks the core, and writes the result back — the selected tab's
|
|
7
|
+
* panel is shown, the others get `hidden`. `data-activation="manual"` on the root makes the
|
|
8
|
+
* arrows move focus only (Enter / Space select). Emits `ss:change` on the root with
|
|
9
|
+
* `{ value, index, reason }`; `value` is the tab's `data-value` (vanilla-only attribute) or its
|
|
10
|
+
* label text, `reason` is `'press'` or `'key'`.
|
|
11
|
+
*/
|
|
12
|
+
import { on, emit, all, byId, setAttrs } from './delegate.js';
|
|
13
|
+
import { tabsKey, tabsPress, tabsTabAttrs, tabsTabStop, } from '../core/tabs.js';
|
|
14
|
+
const TAB = '.ss-tabs > .list[role="tablist"] > .tab[role="tab"]';
|
|
15
|
+
function parts(el) {
|
|
16
|
+
const root = el.closest('.ss-tabs');
|
|
17
|
+
if (!root)
|
|
18
|
+
return null;
|
|
19
|
+
const tabs = all(root, ':scope > .list > .tab[role="tab"]');
|
|
20
|
+
const own = all(root, ':scope > .panel');
|
|
21
|
+
const panels = tabs.map((t, i) => byId(t.getAttribute('aria-controls')) ?? own[i] ?? null);
|
|
22
|
+
return { root, tabs, panels };
|
|
23
|
+
}
|
|
24
|
+
/** The list's state, read from the DOM (the DOM is the store on the plain-HTML path). */
|
|
25
|
+
function read({ tabs }) {
|
|
26
|
+
return {
|
|
27
|
+
selected: tabs.findIndex((t) => t.getAttribute('aria-selected') === 'true'),
|
|
28
|
+
enabled: tabs
|
|
29
|
+
.map((t, index) => (t.disabled || t.getAttribute('aria-disabled') === 'true' ? -1 : index))
|
|
30
|
+
.filter((index) => index >= 0),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Apply a core action to the DOM. */
|
|
34
|
+
function run(p, action) {
|
|
35
|
+
if (!action)
|
|
36
|
+
return;
|
|
37
|
+
const tab = p.tabs[action.index];
|
|
38
|
+
if (!tab)
|
|
39
|
+
return;
|
|
40
|
+
if (action.type === 'select') {
|
|
41
|
+
const tabStop = tabsTabStop({ ...read(p), selected: action.index });
|
|
42
|
+
p.tabs.forEach((t, index) => {
|
|
43
|
+
t.classList.toggle('selected', index === action.index);
|
|
44
|
+
setAttrs(t, {
|
|
45
|
+
...tabsTabAttrs({ index, selected: action.index, tabStop }),
|
|
46
|
+
// Authored wiring stays as it is.
|
|
47
|
+
'aria-controls': t.getAttribute('aria-controls') ?? undefined,
|
|
48
|
+
});
|
|
49
|
+
const panel = p.panels[index];
|
|
50
|
+
if (panel)
|
|
51
|
+
panel.hidden = index !== action.index;
|
|
52
|
+
});
|
|
53
|
+
if (action.changed) {
|
|
54
|
+
const value = tab.dataset.value ?? tab.querySelector('.label')?.textContent?.trim() ?? '';
|
|
55
|
+
emit(p.root, 'ss:change', { value, index: action.index, reason: action.reason });
|
|
56
|
+
}
|
|
57
|
+
if (!action.focus)
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
tab.focus();
|
|
61
|
+
}
|
|
62
|
+
export function selectTab(tab) {
|
|
63
|
+
const p = parts(tab);
|
|
64
|
+
if (p)
|
|
65
|
+
run(p, tabsPress(read(p), p.tabs.indexOf(tab)));
|
|
66
|
+
}
|
|
67
|
+
export function installTabs() {
|
|
68
|
+
on('click', TAB, (t) => selectTab(t));
|
|
69
|
+
on('keydown', TAB, (tab, e) => {
|
|
70
|
+
const p = parts(tab);
|
|
71
|
+
if (!p)
|
|
72
|
+
return;
|
|
73
|
+
// RTL: the list runs right-to-left, so ArrowLeft points at the NEXT tab. Read the inherited
|
|
74
|
+
// computed direction at keydown time and hand it to the core.
|
|
75
|
+
const rtl = getComputedStyle(tab).direction === 'rtl';
|
|
76
|
+
const activation = p.root.dataset.activation === 'manual' ? 'manual' : 'auto';
|
|
77
|
+
const result = tabsKey(read(p), p.tabs.indexOf(tab), e.key, {
|
|
78
|
+
rtl,
|
|
79
|
+
activation,
|
|
80
|
+
});
|
|
81
|
+
if (!result)
|
|
82
|
+
return;
|
|
83
|
+
if (result.preventDefault)
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
run(p, result.action);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TierListPlacements, type TierListZones } from '../tierlist
|
|
1
|
+
import { type TierListPlacements, type TierListZones } from '../core/tierlist.js';
|
|
2
2
|
/** The zone map as the DOM currently has it. */
|
|
3
3
|
export declare function readZones(root: HTMLElement): TierListZones;
|
|
4
4
|
/** Public placements read from the DOM: every non-tray zone, in DOM order. */
|
package/dist/vanilla/tierlist.js
CHANGED
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
* TierList (DS-0159) — plain-HTML behaviour for the markup `TierList.svelte` renders: pointer
|
|
3
3
|
* drag between/within rows (Pointer Events, so touch works) and the keyboard path (Space picks
|
|
4
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
|
|
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.
|
|
5
|
+
* math and the wording come from `../core/tierlist.js`, shared with the Svelte component.
|
|
6
|
+
* Emits `ss:change` on the root with `{ placements, reason }` (tier id → item ids; the tray is
|
|
7
|
+
* implicit; `reason` is `'pointer'` or `'keyboard'`). `data-ss-readonly` on the root makes the list inert.
|
|
8
8
|
*/
|
|
9
9
|
import { on, emit, all } from './delegate.js';
|
|
10
|
-
import { TRAY, announceText, insertionIndex,
|
|
10
|
+
import { TRAY, announceText, insertionIndex, keyboardTarget, tierListDragStarts, tierListPressArmsDrag, tierListTileKey, } from '../core/tierlist.js';
|
|
11
11
|
const ROOT = '.ss-tierlist';
|
|
12
12
|
const TILE = `${ROOT} .tile[data-item]`;
|
|
13
|
-
const DRAG_THRESHOLD = 4;
|
|
14
13
|
function rootOf(el) {
|
|
15
14
|
return el.closest(ROOT);
|
|
16
15
|
}
|
|
@@ -85,8 +84,8 @@ function describe(root, tile) {
|
|
|
85
84
|
count: cells.length,
|
|
86
85
|
};
|
|
87
86
|
}
|
|
88
|
-
function change(root) {
|
|
89
|
-
emit(root, 'ss:change', { placements: readPlacements(root) });
|
|
87
|
+
function change(root, reason) {
|
|
88
|
+
emit(root, 'ss:change', { placements: readPlacements(root), reason });
|
|
90
89
|
}
|
|
91
90
|
const grabs = new WeakMap();
|
|
92
91
|
/** Read at event time: `dir` may sit on any ancestor and change after install. */
|
|
@@ -114,7 +113,7 @@ export function toggleGrab(tile) {
|
|
|
114
113
|
grabs.delete(root);
|
|
115
114
|
setGrabbed(root, null);
|
|
116
115
|
announce(root, announceText('drop', describe(root, tile)));
|
|
117
|
-
change(root);
|
|
116
|
+
change(root, 'keyboard');
|
|
118
117
|
return;
|
|
119
118
|
}
|
|
120
119
|
const d = describe(root, tile);
|
|
@@ -210,30 +209,32 @@ function endDrag(d, cancelled) {
|
|
|
210
209
|
const now = describe(d.root, d.tile);
|
|
211
210
|
if (zoneKey(d.cell.parentElement) !== d.zone || now.index !== d.index) {
|
|
212
211
|
announce(d.root, announceText('drop', now));
|
|
213
|
-
change(d.root);
|
|
212
|
+
change(d.root, 'pointer');
|
|
214
213
|
}
|
|
215
214
|
}
|
|
216
215
|
export function installTierlist() {
|
|
217
216
|
on('keydown', TILE, (tile, e) => {
|
|
218
217
|
const root = rootOf(tile);
|
|
219
|
-
if (!root
|
|
218
|
+
if (!root)
|
|
220
219
|
return;
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
220
|
+
const result = tierListTileKey({
|
|
221
|
+
readonly: isReadonly(root),
|
|
222
|
+
grabbed: grabs.get(root)?.tile === tile,
|
|
223
|
+
// An activatable tile keeps Enter for the host: its native click does the activating.
|
|
224
|
+
select: tile.hasAttribute('data-ss-activate') ? 'native' : 'none',
|
|
225
|
+
rtl: isRtl(tile),
|
|
226
|
+
}, e.key);
|
|
227
|
+
if (!result)
|
|
225
228
|
return;
|
|
226
|
-
|
|
227
|
-
if (e.key === 'Escape' && grab?.tile === tile) {
|
|
229
|
+
if (result.preventDefault)
|
|
228
230
|
e.preventDefault();
|
|
231
|
+
const { action } = result;
|
|
232
|
+
if (action.type === 'toggle')
|
|
233
|
+
toggleGrab(tile);
|
|
234
|
+
else if (action.type === 'cancel')
|
|
229
235
|
cancelGrab(root, true);
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const move = keyMoveFor(e.key, isRtl(tile));
|
|
233
|
-
if (move && grab?.tile === tile) {
|
|
234
|
-
e.preventDefault();
|
|
235
|
-
keyMove(root, tile, move);
|
|
236
|
-
}
|
|
236
|
+
else if (action.type === 'move')
|
|
237
|
+
keyMove(root, tile, action.move);
|
|
237
238
|
});
|
|
238
239
|
// Cancel when focus has really left a grabbed tile — checked a beat later, because moving
|
|
239
240
|
// the node (a row change re-inserts it) blurs it in some browsers before it is re-focused.
|
|
@@ -248,9 +249,15 @@ export function installTierlist() {
|
|
|
248
249
|
cancelGrab(root, false);
|
|
249
250
|
}, 0);
|
|
250
251
|
});
|
|
252
|
+
// A native drag (an <img> inside the tile) would fire pointercancel and kill the
|
|
253
|
+
// pointer drag — the tile moves by pointer events only (DS-0207).
|
|
254
|
+
on('dragstart', TILE, (_tile, e) => e.preventDefault());
|
|
251
255
|
on('pointerdown', TILE, (tile, e) => {
|
|
252
256
|
const root = rootOf(tile);
|
|
253
|
-
if (!root
|
|
257
|
+
if (!root)
|
|
258
|
+
return;
|
|
259
|
+
const press = { readonly: isReadonly(root), button: e.button, grabbing: grabs.has(root) };
|
|
260
|
+
if (!tierListPressArmsDrag(press))
|
|
254
261
|
return;
|
|
255
262
|
const cell = tile.closest('.cell');
|
|
256
263
|
const zone = cell.parentElement;
|
|
@@ -274,7 +281,7 @@ export function installTierlist() {
|
|
|
274
281
|
if (!drag)
|
|
275
282
|
return;
|
|
276
283
|
if (!drag.dragging) {
|
|
277
|
-
if (
|
|
284
|
+
if (!tierListDragStarts(e.clientX - drag.startX, e.clientY - drag.startY))
|
|
278
285
|
return;
|
|
279
286
|
startDrag(drag);
|
|
280
287
|
}
|
package/dist/vanilla/toast.d.ts
CHANGED
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* renders; author them in the markup or they are added on DOM ready / first use). Each visible
|
|
18
18
|
* toast mirrors its message into one of them; the toasts themselves carry no live role.
|
|
19
19
|
*/
|
|
20
|
-
import { type Toast, type ToastKind, type ToastOptions, type ToastPatch, type PromiseMessages } from '../toast
|
|
21
|
-
export type { Toast, ToastKind, ToastOptions, ToastPatch, ToastAction, PromiseMessages, } from '../toast
|
|
20
|
+
import { type Toast, type ToastKind, type ToastOptions, type ToastPatch, type PromiseMessages } from '../core/toast.js';
|
|
21
|
+
export type { Toast, ToastKind, ToastOptions, ToastPatch, ToastAction, PromiseMessages, } from '../core/toast.js';
|
|
22
22
|
declare class VanillaToastStore {
|
|
23
23
|
#private;
|
|
24
24
|
max: number;
|
package/dist/vanilla/toast.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* renders; author them in the markup or they are added on DOM ready / first use). Each visible
|
|
18
18
|
* toast mirrors its message into one of them; the toasts themselves carry no live role.
|
|
19
19
|
*/
|
|
20
|
-
import { DEFAULT_TIMEOUT, isSticky, resolveTimeout, normalizeOptions, ToastTimer, } from '../toast
|
|
20
|
+
import { DEFAULT_TIMEOUT, isSticky, resolveTimeout, normalizeOptions, toastActionDismisses, toastFocusAfterDismiss, toastKey, toastShouldResume, ToastTimer, } from '../core/toast.js';
|
|
21
21
|
const GLYPH = { success: '✓', error: '✕', info: 'i', loading: '' };
|
|
22
22
|
const LEAVE_FALLBACK_MS = 400;
|
|
23
23
|
/** Screen readers need a moment to register a fresh live region before it changes. */
|
|
@@ -129,22 +129,24 @@ class VanillaToastStore {
|
|
|
129
129
|
live.hovered = true;
|
|
130
130
|
this.pause(t.id);
|
|
131
131
|
});
|
|
132
|
+
const resumeIfFree = (focused) => {
|
|
133
|
+
if (toastShouldResume({ hovered: live.hovered, focused }))
|
|
134
|
+
this.resume(t.id);
|
|
135
|
+
};
|
|
132
136
|
el.addEventListener('pointerleave', () => {
|
|
133
137
|
live.hovered = false;
|
|
134
|
-
|
|
135
|
-
this.resume(t.id);
|
|
138
|
+
resumeIfFree(holdsFocus(live));
|
|
136
139
|
});
|
|
137
140
|
el.addEventListener('focusin', () => this.pause(t.id));
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return;
|
|
141
|
-
this.resume(t.id);
|
|
142
|
-
});
|
|
141
|
+
// Focus is only leaving when it lands outside the toast.
|
|
142
|
+
el.addEventListener('focusout', (e) => resumeIfFree(el.contains(e.relatedTarget)));
|
|
143
143
|
el.addEventListener('keydown', (e) => {
|
|
144
|
-
|
|
144
|
+
const result = toastKey(e.key);
|
|
145
|
+
if (!result)
|
|
146
|
+
return;
|
|
147
|
+
if (result.stopPropagation)
|
|
145
148
|
e.stopPropagation();
|
|
146
|
-
|
|
147
|
-
}
|
|
149
|
+
this.dismiss(t.id);
|
|
148
150
|
});
|
|
149
151
|
el.addEventListener('click', (e) => {
|
|
150
152
|
const btn = e.target.closest('button');
|
|
@@ -153,8 +155,7 @@ class VanillaToastStore {
|
|
|
153
155
|
if (btn.classList.contains('x'))
|
|
154
156
|
this.dismiss(t.id);
|
|
155
157
|
else if (btn.classList.contains('action')) {
|
|
156
|
-
|
|
157
|
-
if (!keep)
|
|
158
|
+
if (toastActionDismisses(this.#find(t.id)?.toast.action?.onClick()))
|
|
158
159
|
this.dismiss(t.id);
|
|
159
160
|
}
|
|
160
161
|
});
|
|
@@ -238,7 +239,8 @@ class VanillaToastStore {
|
|
|
238
239
|
}
|
|
239
240
|
/** Move focus off the toast at `i` (about to be removed): next toast, previous, or origin. */
|
|
240
241
|
#moveFocusFrom(i) {
|
|
241
|
-
const
|
|
242
|
+
const order = this.#live.map((l) => l.toast.id);
|
|
243
|
+
const next = this.#find(toastFocusAfterDismiss(order, order[i]) ?? -1);
|
|
242
244
|
if (next)
|
|
243
245
|
next.el.focus();
|
|
244
246
|
else if (this.#returnFocus?.isConnected) {
|
package/dist/vanilla/tooltip.js
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
* hides any open tip wherever focus is (WCAG 1.4.13). While open the focusable trigger inside
|
|
6
6
|
* `.trigger` (not the wrapper) carries `aria-describedby` → the tip (an id is generated when
|
|
7
7
|
* the markup has none); the token is added alongside any description the trigger already has
|
|
8
|
-
* (DS-0163).
|
|
8
|
+
* (DS-0163). Which event shows or hides a tip is decided in `core/tooltip.ts`, the same
|
|
9
|
+
* functions Tooltip.svelte calls.
|
|
9
10
|
*/
|
|
10
11
|
import { on, all } from './delegate.js';
|
|
12
|
+
import { tooltipDescribedBy, tooltipFocusIn, tooltipFocusOut, tooltipKey, tooltipPointerEnter, tooltipPointerLeave, } from '../core/tooltip.js';
|
|
11
13
|
const ROOT = '.ss-tooltip';
|
|
12
14
|
const FOCUSABLE = 'a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"]), [contenteditable="true"]';
|
|
13
15
|
let seq = 0;
|
|
@@ -27,19 +29,36 @@ function describedTarget(root, from) {
|
|
|
27
29
|
trigger.firstElementChild ??
|
|
28
30
|
trigger);
|
|
29
31
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
+
function setDescribedBy(el, tipId, open) {
|
|
33
|
+
const value = tooltipDescribedBy(el.getAttribute('aria-describedby'), tipId, open);
|
|
34
|
+
if (value === undefined)
|
|
35
|
+
el.removeAttribute('aria-describedby');
|
|
36
|
+
else
|
|
37
|
+
el.setAttribute('aria-describedby', value);
|
|
38
|
+
}
|
|
39
|
+
/** The core's state, read from the DOM. */
|
|
40
|
+
function stateOf(root) {
|
|
41
|
+
return { open: Boolean(tipOf(root)?.classList.contains('open')) };
|
|
42
|
+
}
|
|
43
|
+
/** The other end of a pointer or focus move is still inside `root`. */
|
|
44
|
+
function within(root, node) {
|
|
45
|
+
return node instanceof Node && root.contains(node);
|
|
46
|
+
}
|
|
47
|
+
/** Apply a core action to the DOM. */
|
|
48
|
+
function run(root, action, from) {
|
|
49
|
+
if (!action)
|
|
50
|
+
return;
|
|
51
|
+
if (action.type === 'show')
|
|
52
|
+
showTooltip(root, from);
|
|
53
|
+
else
|
|
54
|
+
hideTooltip(root);
|
|
32
55
|
}
|
|
33
56
|
function undescribe(root, tipId) {
|
|
34
57
|
const el = described.get(root);
|
|
35
58
|
described.delete(root);
|
|
36
59
|
if (!el)
|
|
37
60
|
return;
|
|
38
|
-
|
|
39
|
-
if (rest.length)
|
|
40
|
-
el.setAttribute('aria-describedby', rest.join(' '));
|
|
41
|
-
else
|
|
42
|
-
el.removeAttribute('aria-describedby');
|
|
61
|
+
setDescribedBy(el, tipId, false);
|
|
43
62
|
}
|
|
44
63
|
/**
|
|
45
64
|
* Open `root`'s tip. `from` is the element that triggered it (the focused element on
|
|
@@ -56,9 +75,7 @@ export function showTooltip(root, from) {
|
|
|
56
75
|
const target = describedTarget(root, from);
|
|
57
76
|
if (described.get(root) !== target) {
|
|
58
77
|
undescribe(root, tip.id);
|
|
59
|
-
|
|
60
|
-
if (!cur.includes(tip.id))
|
|
61
|
-
target.setAttribute('aria-describedby', [...cur, tip.id].join(' '));
|
|
78
|
+
setDescribedBy(target, tip.id, true);
|
|
62
79
|
described.set(root, target);
|
|
63
80
|
}
|
|
64
81
|
}
|
|
@@ -73,29 +90,24 @@ export function hideTooltip(root) {
|
|
|
73
90
|
export function installTooltip() {
|
|
74
91
|
// mouseenter/leave don't bubble; mouseover/out do — filter by relatedTarget.
|
|
75
92
|
on('mouseover', ROOT, (root, e) => {
|
|
76
|
-
|
|
77
|
-
if (!from || !root.contains(from))
|
|
78
|
-
showTooltip(root);
|
|
93
|
+
run(root, tooltipPointerEnter(stateOf(root), { within: within(root, e.relatedTarget) }));
|
|
79
94
|
});
|
|
80
95
|
on('mouseout', ROOT, (root, e) => {
|
|
81
|
-
|
|
82
|
-
if (!to || !root.contains(to))
|
|
83
|
-
hideTooltip(root);
|
|
96
|
+
run(root, tooltipPointerLeave(stateOf(root), { within: within(root, e.relatedTarget) }));
|
|
84
97
|
});
|
|
85
|
-
on('focusin', ROOT, (root, e) =>
|
|
98
|
+
on('focusin', ROOT, (root, e) => run(root, tooltipFocusIn(stateOf(root)), e.target));
|
|
86
99
|
on('focusout', ROOT, (root, e) => {
|
|
87
|
-
|
|
88
|
-
if (!to || !root.contains(to))
|
|
89
|
-
hideTooltip(root);
|
|
100
|
+
run(root, tooltipFocusOut(stateOf(root), { within: within(root, e.relatedTarget) }));
|
|
90
101
|
});
|
|
91
102
|
// Document-level Escape: a tip opened by hover closes even when focus is elsewhere.
|
|
92
103
|
document.addEventListener('keydown', (e) => {
|
|
93
|
-
|
|
104
|
+
// Cheap exit for every key that could not dismiss a tip, before touching the DOM.
|
|
105
|
+
if (!tooltipKey({ open: true }, e.key))
|
|
94
106
|
return;
|
|
95
107
|
for (const tip of all(document, `${ROOT} > .tip.open`)) {
|
|
96
108
|
const root = tip.parentElement;
|
|
97
109
|
if (root)
|
|
98
|
-
|
|
110
|
+
run(root, tooltipKey(stateOf(root), e.key));
|
|
99
111
|
}
|
|
100
112
|
});
|
|
101
113
|
}
|