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/icons.js
CHANGED
|
@@ -40,10 +40,45 @@ const BUILTIN_PATHS = {
|
|
|
40
40
|
* (`PATHS` is kept as the public name for backward compatibility.)
|
|
41
41
|
*/
|
|
42
42
|
export const PATHS = { ...BUILTIN_PATHS };
|
|
43
|
+
// Light defence-in-depth pass for the raw-markup escape hatches (`registerIcon`, Icon's
|
|
44
|
+
// `paths`, DS-0176). Removes the obvious script vectors and nothing a glyph needs: drawing
|
|
45
|
+
// elements, their attributes, `<g>`/`<defs>`/`<use>`/`<style>` all pass through untouched.
|
|
46
|
+
const SCRIPT_BLOCK = /<script\b[\s\S]*?<\/script\s*>/gi;
|
|
47
|
+
const FOREIGN_BLOCK = /<foreignObject\b[\s\S]*?<\/foreignObject\s*>/gi;
|
|
48
|
+
const STRAY_TAG = /<\/?(?:script|foreignObject)\b[^>]*>/gi;
|
|
49
|
+
const EVENT_ATTR = /([\s/])on[a-z0-9_.:-]*\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi;
|
|
50
|
+
const JS_URL_ATTR = /([\s/])((?:xlink:)?href)\s*=\s*(["']?)\s*javascript:[^"'\s>]*\3/gi;
|
|
51
|
+
/**
|
|
52
|
+
* Strip `<script>`, `<foreignObject>`, `on*` event-handler attributes and `javascript:`
|
|
53
|
+
* links from SVG inner markup. Repeats until stable so split-up payloads can't reassemble.
|
|
54
|
+
*
|
|
55
|
+
* This is a light filter, **not** a security boundary: a regex can't fully parse markup.
|
|
56
|
+
* Markup passed to `registerIcon` or Icon's `paths` must still be trusted (authored by you,
|
|
57
|
+
* never user input).
|
|
58
|
+
*/
|
|
59
|
+
export function sanitizeIconMarkup(markup) {
|
|
60
|
+
let prev;
|
|
61
|
+
let out = markup;
|
|
62
|
+
do {
|
|
63
|
+
prev = out;
|
|
64
|
+
out = out
|
|
65
|
+
.replace(SCRIPT_BLOCK, '')
|
|
66
|
+
.replace(FOREIGN_BLOCK, '')
|
|
67
|
+
.replace(STRAY_TAG, '')
|
|
68
|
+
.replace(EVENT_ATTR, '$1')
|
|
69
|
+
.replace(JS_URL_ATTR, '$1');
|
|
70
|
+
} while (out !== prev);
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
43
73
|
/**
|
|
44
74
|
* Register (or override) a glyph at runtime so `<Icon name="foo" />` resolves
|
|
45
75
|
* raw SVG inner markup that isn't part of the curated {@link IconName} union.
|
|
46
|
-
* The markup is rendered
|
|
76
|
+
* The markup is rendered inside the icon's `<svg viewBox="0 0 24 24">` after a light
|
|
77
|
+
* {@link sanitizeIconMarkup} pass.
|
|
78
|
+
*
|
|
79
|
+
* **Trust requirement:** `paths` is injected as HTML. Only pass markup you control (your own
|
|
80
|
+
* icon set, a vetted file); never user-supplied or third-party strings. The filter removes
|
|
81
|
+
* obvious script vectors but is not a substitute for that.
|
|
47
82
|
*
|
|
48
83
|
* registerIcon('heart', '<path d="M12 21 4 13a5 5 0 0 1 7-7l1 1 1-1a5 5 0 0 1 7 7z"/>')
|
|
49
84
|
* <Icon name={'heart' as IconName} />
|
|
@@ -51,7 +86,11 @@ export const PATHS = { ...BUILTIN_PATHS };
|
|
|
51
86
|
export function registerIcon(name, paths) {
|
|
52
87
|
PATHS[name] = paths;
|
|
53
88
|
}
|
|
54
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Look a glyph up; built-ins first, then runtime registrations. Registered markup comes back
|
|
91
|
+
* through {@link sanitizeIconMarkup} (also covers direct writes to the public `PATHS` record).
|
|
92
|
+
*/
|
|
55
93
|
export function resolveIcon(name) {
|
|
56
|
-
|
|
94
|
+
const found = PATHS[name];
|
|
95
|
+
return found == null ? undefined : sanitizeIconMarkup(found);
|
|
57
96
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export { default as Container } from './components/Container.svelte';
|
|
|
29
29
|
export { default as Textarea } from './components/Textarea.svelte';
|
|
30
30
|
export { default as Spinner } from './components/Spinner.svelte';
|
|
31
31
|
export { SPINNER_VARIANTS, type SpinnerFrames } from './spinner-frames.js';
|
|
32
|
-
export { default as Chart, type ChartSeries, type ChartPoint } from './components/Chart.svelte';
|
|
32
|
+
export { default as Chart, type ChartSeries, type ChartPoint, CHART_DASH_CYCLE, } from './components/Chart.svelte';
|
|
33
33
|
export { default as Table, type TableColumn, type TableSort } from './components/Table.svelte';
|
|
34
34
|
export { default as Select } from './components/Select.svelte';
|
|
35
35
|
export type { SelectOption, SelectOptGroup } from './components/Select.svelte';
|
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@ export { default as Textarea } from './components/Textarea.svelte';
|
|
|
36
36
|
export { default as Spinner } from './components/Spinner.svelte';
|
|
37
37
|
export { SPINNER_VARIANTS } from './spinner-frames.js';
|
|
38
38
|
// geossoca component gaps (DS-0090).
|
|
39
|
-
export { default as Chart } from './components/Chart.svelte';
|
|
39
|
+
export { default as Chart, CHART_DASH_CYCLE, } from './components/Chart.svelte';
|
|
40
40
|
export { default as Table } from './components/Table.svelte';
|
|
41
41
|
export { default as Select } from './components/Select.svelte';
|
|
42
42
|
export { default as Modal } from './components/Modal.svelte';
|
package/dist/tierlist-core.d.ts
CHANGED
|
@@ -52,9 +52,18 @@ export declare function moveItem(zones: TierListZones, itemId: string, toZone: s
|
|
|
52
52
|
/** The public placements: tiers only, in the given tier order; the tray is implicit. */
|
|
53
53
|
export declare function placementsOf(zones: TierListZones, tiers: readonly TierListTier[]): TierListPlacements;
|
|
54
54
|
export declare function zonesEqual(a: TierListZones, b: TierListZones): boolean;
|
|
55
|
-
export type TierListKeyMove = 'left' | 'right' | 'up' | 'down' | 'home' | 'end';
|
|
56
55
|
/**
|
|
57
|
-
*
|
|
56
|
+
* A keyboard sorting step. `prev`/`next` are positions in the row's reading order, not screen
|
|
57
|
+
* directions — {@link keyMoveFor} maps the physical arrow keys onto them per writing direction.
|
|
58
|
+
*/
|
|
59
|
+
export type TierListKeyMove = 'prev' | 'next' | 'up' | 'down' | 'home' | 'end';
|
|
60
|
+
/**
|
|
61
|
+
* The sorting step a key stands for, or `undefined` for any other key. In a right-to-left
|
|
62
|
+
* layout the row reads right to left, so ArrowLeft steps *forward* and ArrowRight back.
|
|
63
|
+
*/
|
|
64
|
+
export declare function keyMoveFor(key: string, rtl?: boolean): TierListKeyMove | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Keyboard sorting target: prev/next step within the zone (wrapping is deliberately off —
|
|
58
67
|
* the edges are meaningful), home/end jump within it, up/down move to the neighbouring zone
|
|
59
68
|
* keeping the same position (clamped). `zoneOrder` is the visual order, tray last.
|
|
60
69
|
* Returns `null` when the move is impossible (already at the edge).
|
|
@@ -72,10 +81,11 @@ export interface Box {
|
|
|
72
81
|
}
|
|
73
82
|
/**
|
|
74
83
|
* Insertion index for a pointer at (x, y) among wrapped tiles: every tile whose row ends above
|
|
75
|
-
* the pointer counts as "before", and on the pointer's own row every tile whose centre is
|
|
76
|
-
* of it
|
|
84
|
+
* the pointer counts as "before", and on the pointer's own row every tile whose centre is
|
|
85
|
+
* before it in reading order — left of it, or right of it when `rtl` (the row then flows right
|
|
86
|
+
* to left). The dragged tile's own box must not be in `cells`.
|
|
77
87
|
*/
|
|
78
|
-
export declare function insertionIndex(cells: readonly Box[], x: number, y: number): number;
|
|
88
|
+
export declare function insertionIndex(cells: readonly Box[], x: number, y: number, rtl?: boolean): number;
|
|
79
89
|
/** Copy for the polite live region — one sentence per step, position 1-based. */
|
|
80
90
|
export declare function announceText(kind: 'grab' | 'move' | 'drop' | 'cancel', d: {
|
|
81
91
|
label: string;
|
package/dist/tierlist-core.js
CHANGED
|
@@ -121,7 +121,28 @@ export function zonesEqual(a, b) {
|
|
|
121
121
|
return true;
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
124
|
-
*
|
|
124
|
+
* The sorting step a key stands for, or `undefined` for any other key. In a right-to-left
|
|
125
|
+
* layout the row reads right to left, so ArrowLeft steps *forward* and ArrowRight back.
|
|
126
|
+
*/
|
|
127
|
+
export function keyMoveFor(key, rtl = false) {
|
|
128
|
+
switch (key) {
|
|
129
|
+
case 'ArrowLeft':
|
|
130
|
+
return rtl ? 'next' : 'prev';
|
|
131
|
+
case 'ArrowRight':
|
|
132
|
+
return rtl ? 'prev' : 'next';
|
|
133
|
+
case 'ArrowUp':
|
|
134
|
+
return 'up';
|
|
135
|
+
case 'ArrowDown':
|
|
136
|
+
return 'down';
|
|
137
|
+
case 'Home':
|
|
138
|
+
return 'home';
|
|
139
|
+
case 'End':
|
|
140
|
+
return 'end';
|
|
141
|
+
}
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Keyboard sorting target: prev/next step within the zone (wrapping is deliberately off —
|
|
125
146
|
* the edges are meaningful), home/end jump within it, up/down move to the neighbouring zone
|
|
126
147
|
* keeping the same position (clamped). `zoneOrder` is the visual order, tray last.
|
|
127
148
|
* Returns `null` when the move is impossible (already at the edge).
|
|
@@ -133,9 +154,9 @@ export function keyboardTarget(zones, zoneOrder, itemId, move) {
|
|
|
133
154
|
const len = zones[at.zone].length;
|
|
134
155
|
const zi = zoneOrder.indexOf(at.zone);
|
|
135
156
|
switch (move) {
|
|
136
|
-
case '
|
|
157
|
+
case 'prev':
|
|
137
158
|
return at.index > 0 ? { zone: at.zone, index: at.index - 1 } : null;
|
|
138
|
-
case '
|
|
159
|
+
case 'next':
|
|
139
160
|
return at.index < len - 1 ? { zone: at.zone, index: at.index + 1 } : null;
|
|
140
161
|
case 'home':
|
|
141
162
|
return at.index > 0 ? { zone: at.zone, index: 0 } : null;
|
|
@@ -152,15 +173,17 @@ export function keyboardTarget(zones, zoneOrder, itemId, move) {
|
|
|
152
173
|
}
|
|
153
174
|
/**
|
|
154
175
|
* Insertion index for a pointer at (x, y) among wrapped tiles: every tile whose row ends above
|
|
155
|
-
* the pointer counts as "before", and on the pointer's own row every tile whose centre is
|
|
156
|
-
* of it
|
|
176
|
+
* the pointer counts as "before", and on the pointer's own row every tile whose centre is
|
|
177
|
+
* before it in reading order — left of it, or right of it when `rtl` (the row then flows right
|
|
178
|
+
* to left). The dragged tile's own box must not be in `cells`.
|
|
157
179
|
*/
|
|
158
|
-
export function insertionIndex(cells, x, y) {
|
|
180
|
+
export function insertionIndex(cells, x, y, rtl = false) {
|
|
159
181
|
let index = 0;
|
|
160
182
|
for (const c of cells) {
|
|
183
|
+
const centre = (c.left + c.right) / 2;
|
|
161
184
|
if (c.bottom <= y)
|
|
162
185
|
index++;
|
|
163
|
-
else if (c.top <= y && (
|
|
186
|
+
else if (c.top <= y && (rtl ? centre >= x : centre <= x))
|
|
164
187
|
index++;
|
|
165
188
|
}
|
|
166
189
|
return index;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Accordion (DS-0148) — toggles `hidden` on the panel referenced by each header's
|
|
2
|
+
* Accordion (DS-0148) — toggles `hidden` + `inert` on the panel referenced by each header's
|
|
3
3
|
* `aria-controls`, mirroring Accordion.svelte: single-open by default (opening one closes the
|
|
4
4
|
* others), `data-ss-multiple` on the root allows several, Arrow/Home/End rove between headers.
|
|
5
5
|
* Emits `ss:change` on the root with `{ value }` (open ids: string | string[] | undefined).
|
|
@@ -10,8 +10,12 @@ function setOpen(head, open) {
|
|
|
10
10
|
head.setAttribute('aria-expanded', String(open));
|
|
11
11
|
head.closest('.item')?.classList.toggle('open', open);
|
|
12
12
|
const panel = byId(head.getAttribute('aria-controls'));
|
|
13
|
-
if (panel)
|
|
14
|
-
|
|
13
|
+
if (!panel)
|
|
14
|
+
return;
|
|
15
|
+
panel.hidden = !open;
|
|
16
|
+
// A closed panel keeps `display: grid` (so the collapse animates); `inert` keeps its content
|
|
17
|
+
// out of the Tab order and a11y tree, matching Accordion.svelte (DS-0162).
|
|
18
|
+
panel.toggleAttribute('inert', !open);
|
|
15
19
|
}
|
|
16
20
|
export function toggleAccordion(head) {
|
|
17
21
|
if (head.getAttribute('aria-disabled') === 'true')
|
package/dist/vanilla/fields.js
CHANGED
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
* - Input `clearable`: `.ss-field .clear` empties `.ss-input`, refocuses it and hides itself;
|
|
5
5
|
* typing shows it again (Input.svelte removes the button entirely — vanilla toggles `hidden`).
|
|
6
6
|
* - NumberField steppers: `.ss-numberfield .step.dec/.inc` nudge by `step`, clamped to
|
|
7
|
-
* `min`/`max
|
|
7
|
+
* `min`/`max` (same `nudge`/`clamp` as the component). At a bound a stepper becomes an
|
|
8
|
+
* `aria-disabled` no-op (still focusable, so focus never drops to <body>); it is natively
|
|
9
|
+
* `disabled` only when the input is disabled/readonly. Each nudge writes the new value to
|
|
10
|
+
* the field's polite `.live` region.
|
|
8
11
|
* - Textarea autosize: `.ss-textarea .field.autosize` grows with content. Browsers with
|
|
9
12
|
* `field-sizing: content` do it in CSS; the JS `scrollHeight` sync is the fallback.
|
|
10
13
|
*/
|
|
@@ -37,14 +40,21 @@ function syncSteppers(input) {
|
|
|
37
40
|
const locked = input.disabled || input.readOnly;
|
|
38
41
|
const dec = control.querySelector('.step.dec');
|
|
39
42
|
const inc = control.querySelector('.step.inc');
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
const bound = (btn, atBound) => {
|
|
44
|
+
if (!btn)
|
|
45
|
+
return;
|
|
46
|
+
btn.disabled = locked;
|
|
47
|
+
if (!locked && atBound)
|
|
48
|
+
btn.setAttribute('aria-disabled', 'true');
|
|
49
|
+
else
|
|
50
|
+
btn.removeAttribute('aria-disabled');
|
|
51
|
+
};
|
|
52
|
+
bound(dec, v != null && min != null && v <= min);
|
|
53
|
+
bound(inc, v != null && max != null && v >= max);
|
|
44
54
|
}
|
|
45
55
|
export function nudgeNumber(btn) {
|
|
46
56
|
const input = btn.closest('.control')?.querySelector('.ss-input');
|
|
47
|
-
if (!input || btn.disabled)
|
|
57
|
+
if (!input || btn.disabled || btn.getAttribute('aria-disabled') === 'true')
|
|
48
58
|
return;
|
|
49
59
|
const dir = btn.classList.contains('inc') ? 1 : -1;
|
|
50
60
|
const min = num(input.getAttribute('min'));
|
|
@@ -61,6 +71,9 @@ export function nudgeNumber(btn) {
|
|
|
61
71
|
fire(input, 'input');
|
|
62
72
|
fire(input, 'change');
|
|
63
73
|
syncSteppers(input);
|
|
74
|
+
const live = input.closest('.ss-numberfield')?.querySelector('.live');
|
|
75
|
+
if (live)
|
|
76
|
+
live.textContent = input.value;
|
|
64
77
|
}
|
|
65
78
|
// ── Textarea autosize ──────────────────────────────────────────────────────
|
|
66
79
|
export const supportsFieldSizing = typeof CSS !== 'undefined' &&
|
package/dist/vanilla/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { toast, toasts } from './toast.js';
|
|
|
2
2
|
export type { Toast, ToastKind, ToastOptions, ToastPatch, ToastAction, PromiseMessages, } from './toast.js';
|
|
3
3
|
export { iconSvg, hydrateIcons, type IconOptions } from './icons.js';
|
|
4
4
|
export { registerIcon, type IconName } from '../icons.js';
|
|
5
|
-
export { openModal, closeModal } from './modal.js';
|
|
5
|
+
export { openModal, closeModal, lockScroll, unlockScroll } from './modal.js';
|
|
6
6
|
export { toggleAccordion } from './accordion.js';
|
|
7
7
|
export { openMenu, closeMenu } from './menu.js';
|
|
8
8
|
export { showTooltip, hideTooltip } from './tooltip.js';
|
package/dist/vanilla/index.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* consumption path. Importing this module wires every behaviour once via document-level event
|
|
4
4
|
* delegation (so markup added later just works) and runs `mount()` when the DOM is ready.
|
|
5
5
|
*
|
|
6
|
-
* <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.
|
|
7
|
-
* <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.
|
|
8
|
-
* <script type="module" src="https://cdn.jsdelivr.net/npm/dssoca@0.
|
|
6
|
+
* <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.20/dist/theme.css">
|
|
7
|
+
* <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.20/dist/vanilla.css">
|
|
8
|
+
* <script type="module" src="https://cdn.jsdelivr.net/npm/dssoca@0.20/dist/vanilla/index.js"></script>
|
|
9
9
|
*
|
|
10
10
|
* Call `mount(root)` after injecting HTML that contains `[data-ss-icon]` placeholders or
|
|
11
11
|
* autosizing textareas. Nothing here imports Svelte or a `.svelte` module.
|
|
@@ -22,7 +22,7 @@ import { hydrateIcons } from './icons.js';
|
|
|
22
22
|
export { toast, toasts } from './toast.js';
|
|
23
23
|
export { iconSvg, hydrateIcons } from './icons.js';
|
|
24
24
|
export { registerIcon } from '../icons.js';
|
|
25
|
-
export { openModal, closeModal } from './modal.js';
|
|
25
|
+
export { openModal, closeModal, lockScroll, unlockScroll } from './modal.js';
|
|
26
26
|
export { toggleAccordion } from './accordion.js';
|
|
27
27
|
export { openMenu, closeMenu } from './menu.js';
|
|
28
28
|
export { showTooltip, hideTooltip } from './tooltip.js';
|
package/dist/vanilla/menu.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* Outside pointerdown closes without returning focus; Escape / item activation return focus
|
|
5
5
|
* to the trigger. Emits `ss:select` on the root with `{ index, value }` (`value` is the
|
|
6
6
|
* item's `data-value`, when authored). For `menuitemradio` items the check marker moves to
|
|
7
|
-
* the activated item.
|
|
7
|
+
* the activated item. A panel with neither `aria-label` nor `aria-labelledby` gets
|
|
8
|
+
* `aria-labelledby` pointing at its trigger on first open (an id is minted if needed).
|
|
8
9
|
*/
|
|
9
10
|
import { on, emit, all } from './delegate.js';
|
|
10
11
|
import { iconSvg } from './icons.js';
|
|
@@ -29,10 +30,20 @@ function focusItem(panel, item) {
|
|
|
29
30
|
i.tabIndex = i === item ? 0 : -1;
|
|
30
31
|
item.focus();
|
|
31
32
|
}
|
|
33
|
+
let autoId = 0;
|
|
34
|
+
/** An unnamed `role="menu"` panel is named by its trigger (mirrors Menu.svelte's fallback). */
|
|
35
|
+
function ensureName(trigger, panel) {
|
|
36
|
+
if (panel.hasAttribute('aria-label') || panel.hasAttribute('aria-labelledby'))
|
|
37
|
+
return;
|
|
38
|
+
if (!trigger.id)
|
|
39
|
+
trigger.id = `ss-menu-trigger-${++autoId}`;
|
|
40
|
+
panel.setAttribute('aria-labelledby', trigger.id);
|
|
41
|
+
}
|
|
32
42
|
export function openMenu(trigger, focus = 'first') {
|
|
33
43
|
const { panel } = parts(trigger);
|
|
34
44
|
if (!panel || trigger.getAttribute('aria-expanded') === 'true')
|
|
35
45
|
return;
|
|
46
|
+
ensureName(trigger, panel);
|
|
36
47
|
trigger.setAttribute('aria-expanded', 'true');
|
|
37
48
|
panel.classList.add('open');
|
|
38
49
|
panel.setAttribute('aria-hidden', 'false');
|
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;
|
package/dist/vanilla/tierlist.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* implicit). `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, keyboardTarget, } from '../tierlist-core.js';
|
|
10
|
+
import { TRAY, announceText, insertionIndex, keyMoveFor, keyboardTarget, } from '../tierlist-core.js';
|
|
11
11
|
const ROOT = '.ss-tierlist';
|
|
12
12
|
const TILE = `${ROOT} .tile[data-item]`;
|
|
13
13
|
const DRAG_THRESHOLD = 4;
|
|
@@ -89,14 +89,10 @@ function change(root) {
|
|
|
89
89
|
emit(root, 'ss:change', { placements: readPlacements(root) });
|
|
90
90
|
}
|
|
91
91
|
const grabs = new WeakMap();
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
ArrowDown: 'down',
|
|
97
|
-
Home: 'home',
|
|
98
|
-
End: 'end',
|
|
99
|
-
};
|
|
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
|
+
}
|
|
100
96
|
function setGrabbed(root, tile) {
|
|
101
97
|
for (const t of all(root, '.tile[aria-pressed="true"]')) {
|
|
102
98
|
t.setAttribute('aria-pressed', 'false');
|
|
@@ -199,7 +195,7 @@ function moveDrag(d, x, y) {
|
|
|
199
195
|
const boxes = cellsOf(zone)
|
|
200
196
|
.filter((c) => c !== d.cell)
|
|
201
197
|
.map((c) => c.getBoundingClientRect());
|
|
202
|
-
placeCell(d.root, d.cell, zoneKey(zone), insertionIndex(boxes, x, y));
|
|
198
|
+
placeCell(d.root, d.cell, zoneKey(zone), insertionIndex(boxes, x, y, isRtl(zone)));
|
|
203
199
|
}
|
|
204
200
|
function endDrag(d, cancelled) {
|
|
205
201
|
d.ghost?.remove();
|
|
@@ -233,7 +229,7 @@ export function installTierlist() {
|
|
|
233
229
|
cancelGrab(root, true);
|
|
234
230
|
return;
|
|
235
231
|
}
|
|
236
|
-
const move =
|
|
232
|
+
const move = keyMoveFor(e.key, isRtl(tile));
|
|
237
233
|
if (move && grab?.tile === tile) {
|
|
238
234
|
e.preventDefault();
|
|
239
235
|
keyMove(root, tile, move);
|
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;
|