dssoca 0.19.0 → 0.21.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 +30 -54
- package/dist/components/Badge.svelte +12 -7
- package/dist/components/Badge.svelte.d.ts +2 -1
- package/dist/components/BottomNav.svelte +18 -28
- package/dist/components/BoxPlot.svelte +34 -7
- package/dist/components/BumpChart.svelte +65 -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 +166 -32
- package/dist/components/Chart.svelte.d.ts +13 -1
- package/dist/components/Checkbox.svelte +210 -0
- package/dist/components/Checkbox.svelte.d.ts +38 -0
- package/dist/components/DateField.svelte +1 -1
- package/dist/components/FileDrop.svelte +113 -77
- package/dist/components/FileDrop.svelte.d.ts +12 -2
- 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/Image.svelte +44 -44
- package/dist/components/Input.svelte +11 -6
- package/dist/components/Link.svelte +25 -14
- package/dist/components/LogStream.svelte +48 -33
- package/dist/components/Menu.svelte +81 -102
- package/dist/components/Menu.svelte.d.ts +8 -2
- package/dist/components/MetricTile.svelte +11 -1
- package/dist/components/MetricTile.svelte.d.ts +6 -0
- package/dist/components/Modal.svelte +108 -21
- package/dist/components/Modal.svelte.d.ts +18 -5
- package/dist/components/NumberField.svelte +44 -22
- package/dist/components/Pagination.svelte +54 -41
- package/dist/components/Pagination.svelte.d.ts +6 -2
- package/dist/components/Popover.svelte +247 -0
- package/dist/components/Popover.svelte.d.ts +36 -0
- package/dist/components/RadioGroup.svelte +227 -0
- package/dist/components/RadioGroup.svelte.d.ts +42 -0
- package/dist/components/ScatterPlot.svelte +42 -7
- package/dist/components/SearchPalette.svelte +216 -136
- package/dist/components/SearchPalette.svelte.d.ts +11 -4
- package/dist/components/SegmentedControl.svelte +47 -59
- package/dist/components/SegmentedControl.svelte.d.ts +7 -2
- 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 +49 -48
- package/dist/components/Sidebar.svelte +88 -117
- package/dist/components/Switch.svelte +24 -18
- package/dist/components/Switch.svelte.d.ts +6 -2
- package/dist/components/Table.svelte +29 -44
- package/dist/components/Table.svelte.d.ts +6 -2
- package/dist/components/Tabs.svelte +223 -0
- package/dist/components/Tabs.svelte.d.ts +51 -0
- package/dist/components/Textarea.svelte +1 -1
- package/dist/components/TierList.svelte +45 -49
- package/dist/components/TierList.svelte.d.ts +7 -3
- package/dist/components/Toaster.svelte +154 -32
- package/dist/components/Tooltip.svelte +122 -18
- package/dist/components/Tooltip.svelte.d.ts +1 -1
- package/dist/components/Topbar.svelte +29 -49
- 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/core/chart-nav.js +62 -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 +68 -0
- package/dist/core/popover.js +55 -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} +77 -5
- package/dist/{tierlist-core.js → core/tierlist.js} +64 -7
- 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/icons.d.ts +19 -2
- package/dist/icons.js +42 -3
- package/dist/index.d.ts +15 -2
- package/dist/index.js +10 -2
- 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 +35 -32
- 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 +46 -28
- package/dist/vanilla/index.d.ts +5 -1
- package/dist/vanilla/index.js +17 -4
- package/dist/vanilla/menu.js +101 -84
- package/dist/vanilla/modal.d.ts +7 -1
- package/dist/vanilla/modal.js +120 -15
- package/dist/vanilla/popover.d.ts +10 -0
- package/dist/vanilla/popover.js +129 -0
- package/dist/vanilla/radio.d.ts +3 -0
- package/dist/vanilla/radio.js +54 -0
- package/dist/vanilla/segmented.js +50 -43
- 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 +34 -34
- package/dist/vanilla/toast.d.ts +13 -5
- package/dist/vanilla/toast.js +132 -16
- package/dist/vanilla/tooltip.d.ts +5 -1
- package/dist/vanilla/tooltip.js +78 -19
- package/dist/vanilla.css +675 -160
- package/package.json +1 -1
- package/dist/toast-core.d.ts +0 -61
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** A tab as the consumer passes it: a plain string (id = label) or an object. */
|
|
2
|
+
export type TopbarTabInput = string | {
|
|
3
|
+
id: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
href?: string;
|
|
6
|
+
};
|
|
7
|
+
/** One normalized tab. */
|
|
8
|
+
export interface TopbarTabItem {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
href?: string;
|
|
12
|
+
}
|
|
13
|
+
/** Normalize both tab shapes: string tabs keep id === label, object tabs default `label` to `id`. */
|
|
14
|
+
export declare function topbarTabs(tabs: readonly TopbarTabInput[]): TopbarTabItem[];
|
|
15
|
+
/**
|
|
16
|
+
* The roving tab stop: the active tab, or — when `active` matches no tab — the first button
|
|
17
|
+
* tab, so the strip stays reachable by Tab. `-1` when there is neither.
|
|
18
|
+
*/
|
|
19
|
+
export declare function topbarRovingIndex(tabs: readonly TopbarTabItem[], active: string | undefined): number;
|
|
20
|
+
/**
|
|
21
|
+
* `tabindex` for a tab. Button tabs rove (one tab stop); link tabs return `undefined` and stay
|
|
22
|
+
* in the natural tab order, so they remain keyboard-reachable without JS.
|
|
23
|
+
*/
|
|
24
|
+
export declare function topbarTabTabindex(tab: TopbarTabItem, index: number, rovingIndex: number): 0 | -1 | undefined;
|
|
25
|
+
/** A key the tab strip handles: its action, and whether the browser default must be cancelled. */
|
|
26
|
+
export interface TopbarKeyResult {
|
|
27
|
+
action: {
|
|
28
|
+
type: 'focus';
|
|
29
|
+
index: number;
|
|
30
|
+
} | null;
|
|
31
|
+
preventDefault: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A key on tab `index` of `count` tabs: arrows move focus across the strip (wrapping), Home/End
|
|
35
|
+
* jump to the ends. `null` = not a tab-strip key, let it through.
|
|
36
|
+
*
|
|
37
|
+
* `rtl` = the strip's computed direction (the adapter reads it at keydown). The strip is laid
|
|
38
|
+
* out right-to-left there, so ArrowLeft points at the NEXT tab and ArrowRight at the previous
|
|
39
|
+
* one (DS-0204); Up/Down, Home and End stay logical.
|
|
40
|
+
*/
|
|
41
|
+
export declare function topbarTabKey(key: string, index: number, count: number, rtl?: boolean): TopbarKeyResult | null;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Topbar core (DS-0197) — the tab strip's decisions: the normalized tab list, which tab is the
|
|
3
|
+
* roving tab stop and where a key moves focus. Pure functions; Topbar.svelte owns the DOM focus
|
|
4
|
+
* call. No DOM, no Svelte.
|
|
5
|
+
*/
|
|
6
|
+
import { rovingStep, rovingTabindex } from './behaviors/roving.js';
|
|
7
|
+
/** Normalize both tab shapes: string tabs keep id === label, object tabs default `label` to `id`. */
|
|
8
|
+
export function topbarTabs(tabs) {
|
|
9
|
+
return tabs.map((t) => typeof t === 'string'
|
|
10
|
+
? { id: t, label: t }
|
|
11
|
+
: { id: t.id, label: t.label ?? t.id, href: t.href });
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The roving tab stop: the active tab, or — when `active` matches no tab — the first button
|
|
15
|
+
* tab, so the strip stays reachable by Tab. `-1` when there is neither.
|
|
16
|
+
*/
|
|
17
|
+
export function topbarRovingIndex(tabs, active) {
|
|
18
|
+
const i = tabs.findIndex((t) => t.id === active);
|
|
19
|
+
return i >= 0 ? i : tabs.findIndex((t) => !t.href);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* `tabindex` for a tab. Button tabs rove (one tab stop); link tabs return `undefined` and stay
|
|
23
|
+
* in the natural tab order, so they remain keyboard-reachable without JS.
|
|
24
|
+
*/
|
|
25
|
+
export function topbarTabTabindex(tab, index, rovingIndex) {
|
|
26
|
+
return tab.href ? undefined : rovingTabindex(index, rovingIndex);
|
|
27
|
+
}
|
|
28
|
+
const MOVES = {
|
|
29
|
+
ArrowRight: 'next',
|
|
30
|
+
ArrowDown: 'next',
|
|
31
|
+
ArrowLeft: 'prev',
|
|
32
|
+
ArrowUp: 'prev',
|
|
33
|
+
Home: 'first',
|
|
34
|
+
End: 'last',
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* A key on tab `index` of `count` tabs: arrows move focus across the strip (wrapping), Home/End
|
|
38
|
+
* jump to the ends. `null` = not a tab-strip key, let it through.
|
|
39
|
+
*
|
|
40
|
+
* `rtl` = the strip's computed direction (the adapter reads it at keydown). The strip is laid
|
|
41
|
+
* out right-to-left there, so ArrowLeft points at the NEXT tab and ArrowRight at the previous
|
|
42
|
+
* one (DS-0204); Up/Down, Home and End stay logical.
|
|
43
|
+
*/
|
|
44
|
+
export function topbarTabKey(key, index, count, rtl = false) {
|
|
45
|
+
if (!Object.hasOwn(MOVES, key))
|
|
46
|
+
return null;
|
|
47
|
+
const horizontal = key === 'ArrowLeft' || key === 'ArrowRight';
|
|
48
|
+
const move = rtl && horizontal ? (MOVES[key] === 'next' ? 'prev' : 'next') : MOVES[key];
|
|
49
|
+
const all = Array.from({ length: count }, (_, i) => i);
|
|
50
|
+
const target = rovingStep(all, index, move);
|
|
51
|
+
return { action: target >= 0 ? { type: 'focus', index: target } : null, preventDefault: true };
|
|
52
|
+
}
|
package/dist/dssoca.config.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ export interface Palette {
|
|
|
81
81
|
/** Size axis values — derived from the manifest (`'sm' | 'md' | 'lg'`). */
|
|
82
82
|
export type Size = (typeof dssocaConfig)['size']['values'][number];
|
|
83
83
|
/** Names of the components that accept a `size` prop / `componentsSize` entry. */
|
|
84
|
-
export declare const COMPONENT_NAMES: readonly ["Accordion", "Avatar", "Badge", "BottomNav", "Button", "Card", "Chart", "Container", "DateField", "EmptyState", "FileDrop", "Heading", "Icon", "Image", "Input", "Kbd", "Link", "LogStream", "Menu", "MetricTile", "Modal", "NumberField", "Pagination", "SearchPalette", "SegmentedControl", "Select", "ServiceCard", "Sidebar", "Sparkline", "Spinner", "Switch", "Table", "Textarea", "TierList", "Toaster", "Tooltip", "Topbar"];
|
|
84
|
+
export declare const COMPONENT_NAMES: readonly ["Accordion", "Avatar", "Badge", "BottomNav", "Button", "Card", "Chart", "Checkbox", "Container", "DateField", "EmptyState", "FileDrop", "Heading", "Icon", "Image", "Input", "Kbd", "Link", "LogStream", "Menu", "MetricTile", "Modal", "NumberField", "Pagination", "Popover", "RadioGroup", "SearchPalette", "SegmentedControl", "Select", "ServiceCard", "Sidebar", "Sparkline", "Spinner", "Switch", "Table", "Tabs", "Textarea", "TierList", "Toaster", "Tooltip", "Topbar"];
|
|
85
85
|
export type ComponentName = (typeof COMPONENT_NAMES)[number];
|
|
86
86
|
/** Per-component default sizes; any omitted component inherits `sizeVariant`. */
|
|
87
87
|
export type ComponentsSize = Partial<Record<ComponentName, Size>>;
|
package/dist/dssoca.config.js
CHANGED
|
@@ -77,6 +77,7 @@ export const COMPONENT_NAMES = [
|
|
|
77
77
|
'Button',
|
|
78
78
|
'Card',
|
|
79
79
|
'Chart',
|
|
80
|
+
'Checkbox',
|
|
80
81
|
'Container',
|
|
81
82
|
'DateField',
|
|
82
83
|
'EmptyState',
|
|
@@ -93,6 +94,8 @@ export const COMPONENT_NAMES = [
|
|
|
93
94
|
'Modal',
|
|
94
95
|
'NumberField',
|
|
95
96
|
'Pagination',
|
|
97
|
+
'Popover',
|
|
98
|
+
'RadioGroup',
|
|
96
99
|
'SearchPalette',
|
|
97
100
|
'SegmentedControl',
|
|
98
101
|
'Select',
|
|
@@ -102,6 +105,7 @@ export const COMPONENT_NAMES = [
|
|
|
102
105
|
'Spinner',
|
|
103
106
|
'Switch',
|
|
104
107
|
'Table',
|
|
108
|
+
'Tabs',
|
|
105
109
|
'Textarea',
|
|
106
110
|
'TierList',
|
|
107
111
|
'Toaster',
|
package/dist/icons.d.ts
CHANGED
|
@@ -41,15 +41,32 @@ export type IconName = keyof typeof BUILTIN_PATHS;
|
|
|
41
41
|
* (`PATHS` is kept as the public name for backward compatibility.)
|
|
42
42
|
*/
|
|
43
43
|
export declare const PATHS: Record<string, string>;
|
|
44
|
+
/**
|
|
45
|
+
* Strip `<script>`, `<foreignObject>`, `on*` event-handler attributes and `javascript:`
|
|
46
|
+
* links from SVG inner markup. Repeats until stable so split-up payloads can't reassemble.
|
|
47
|
+
*
|
|
48
|
+
* This is a light filter, **not** a security boundary: a regex can't fully parse markup.
|
|
49
|
+
* Markup passed to `registerIcon` or Icon's `paths` must still be trusted (authored by you,
|
|
50
|
+
* never user input).
|
|
51
|
+
*/
|
|
52
|
+
export declare function sanitizeIconMarkup(markup: string): string;
|
|
44
53
|
/**
|
|
45
54
|
* Register (or override) a glyph at runtime so `<Icon name="foo" />` resolves
|
|
46
55
|
* raw SVG inner markup that isn't part of the curated {@link IconName} union.
|
|
47
|
-
* The markup is rendered
|
|
56
|
+
* The markup is rendered inside the icon's `<svg viewBox="0 0 24 24">` after a light
|
|
57
|
+
* {@link sanitizeIconMarkup} pass.
|
|
58
|
+
*
|
|
59
|
+
* **Trust requirement:** `paths` is injected as HTML. Only pass markup you control (your own
|
|
60
|
+
* icon set, a vetted file); never user-supplied or third-party strings. The filter removes
|
|
61
|
+
* obvious script vectors but is not a substitute for that.
|
|
48
62
|
*
|
|
49
63
|
* registerIcon('heart', '<path d="M12 21 4 13a5 5 0 0 1 7-7l1 1 1-1a5 5 0 0 1 7 7z"/>')
|
|
50
64
|
* <Icon name={'heart' as IconName} />
|
|
51
65
|
*/
|
|
52
66
|
export declare function registerIcon(name: string, paths: string): void;
|
|
53
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Look a glyph up; built-ins first, then runtime registrations. Registered markup comes back
|
|
69
|
+
* through {@link sanitizeIconMarkup} (also covers direct writes to the public `PATHS` record).
|
|
70
|
+
*/
|
|
54
71
|
export declare function resolveIcon(name: string): string | undefined;
|
|
55
72
|
export {};
|
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
|
@@ -19,9 +19,11 @@ export { default as LogStream, type LogLevel, type LogLine } from './components/
|
|
|
19
19
|
export { default as Toaster } from './components/Toaster.svelte';
|
|
20
20
|
export { default as EmptyState } from './components/EmptyState.svelte';
|
|
21
21
|
export { default as Menu, type MenuItem } from './components/Menu.svelte';
|
|
22
|
+
export type { MenuReason, MenuOpenChangeDetails } from './core/menu.js';
|
|
22
23
|
export { default as Accordion, type AccordionItem } from './components/Accordion.svelte';
|
|
23
24
|
export { default as Link } from './components/Link.svelte';
|
|
24
25
|
export { default as SegmentedControl, type SegmentOption, } from './components/SegmentedControl.svelte';
|
|
26
|
+
export type { SegmentedReason, SegmentedChangeDetails } from './core/segmented.js';
|
|
25
27
|
export { default as BottomNav, type BottomNavItem } from './components/BottomNav.svelte';
|
|
26
28
|
export { default as Image, type ImageSource } from './components/Image.svelte';
|
|
27
29
|
export { default as Heading } from './components/Heading.svelte';
|
|
@@ -29,25 +31,36 @@ export { default as Container } from './components/Container.svelte';
|
|
|
29
31
|
export { default as Textarea } from './components/Textarea.svelte';
|
|
30
32
|
export { default as Spinner } from './components/Spinner.svelte';
|
|
31
33
|
export { SPINNER_VARIANTS, type SpinnerFrames } from './spinner-frames.js';
|
|
32
|
-
export { default as Chart, type ChartSeries, type ChartPoint } from './components/Chart.svelte';
|
|
34
|
+
export { default as Chart, type ChartSeries, type ChartPoint, CHART_DASH_CYCLE, } from './components/Chart.svelte';
|
|
33
35
|
export { default as Table, type TableColumn, type TableSort } from './components/Table.svelte';
|
|
34
36
|
export { default as Select } from './components/Select.svelte';
|
|
35
37
|
export type { SelectOption, SelectOptGroup } from './components/Select.svelte';
|
|
36
38
|
export { default as Modal } from './components/Modal.svelte';
|
|
39
|
+
export type { ModalReason, ModalCloseDetails } from './core/modal.js';
|
|
37
40
|
export { default as DateField } from './components/DateField.svelte';
|
|
38
41
|
export { default as FileDrop } from './components/FileDrop.svelte';
|
|
42
|
+
export type { FileDropReason, FileDropChangeDetails } from './core/file-drop.js';
|
|
39
43
|
export { default as NumberField } from './components/NumberField.svelte';
|
|
40
44
|
export { default as Tooltip } from './components/Tooltip.svelte';
|
|
41
45
|
export { default as Avatar } from './components/Avatar.svelte';
|
|
42
46
|
export { default as Pagination } from './components/Pagination.svelte';
|
|
47
|
+
export type { PaginationReason, PaginationChangeDetails } from './core/pagination.js';
|
|
43
48
|
export { default as Switch } from './components/Switch.svelte';
|
|
49
|
+
export type { SwitchReason, SwitchChangeDetails } from './core/switch.js';
|
|
44
50
|
export { default as SearchPalette, type SearchPaletteItem } from './components/SearchPalette.svelte';
|
|
51
|
+
export type { SearchPaletteReason, SearchPaletteOpenDetails } from './core/search-palette.js';
|
|
45
52
|
export { default as ScatterPlot, type ScatterPoint } from './components/ScatterPlot.svelte';
|
|
46
53
|
export { default as BoxPlot, type BoxGroup } from './components/BoxPlot.svelte';
|
|
47
54
|
export { default as BumpChart, type BumpSeries } from './components/BumpChart.svelte';
|
|
48
55
|
export { default as Heatmap } from './components/Heatmap.svelte';
|
|
49
56
|
export { default as TierList } from './components/TierList.svelte';
|
|
50
|
-
export { DEFAULT_TIERS as TIERLIST_DEFAULT_TIERS, type TierListTier, type TierListItem, type TierListPlacements, } from './tierlist
|
|
57
|
+
export { DEFAULT_TIERS as TIERLIST_DEFAULT_TIERS, type TierListTier, type TierListItem, type TierListPlacements, type TierListChangeDetails, type TierListChangeReason, } from './core/tierlist.js';
|
|
58
|
+
export { default as Checkbox } from './components/Checkbox.svelte';
|
|
59
|
+
export { default as RadioGroup, type RadioOption } from './components/RadioGroup.svelte';
|
|
60
|
+
export { default as Tabs, type TabItem } from './components/Tabs.svelte';
|
|
61
|
+
export type { TabsReason, TabsActivation, TabsChangeDetails } from './core/tabs.js';
|
|
62
|
+
export { default as Popover } from './components/Popover.svelte';
|
|
63
|
+
export type { PopoverReason, PopoverOpenChangeDetails } from './core/popover.js';
|
|
51
64
|
export { default as Kbd } from './components/Kbd.svelte';
|
|
52
65
|
export { default as ShortcutsHelp } from './components/ShortcutsHelp.svelte';
|
|
53
66
|
export { shortcuts, shortcut, formatShortcut, ariaKeyshortcuts, type ShortcutOptions, type ShortcutInfo, type ShortcutOverride, type ShortcutOverrides, type ShortcutScope, type ShortcutPlatform, type ShortcutFormat, type FormatShortcutOptions, } from './shortcuts.svelte.js';
|
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';
|
|
@@ -55,7 +55,15 @@ export { default as BumpChart } from './components/BumpChart.svelte';
|
|
|
55
55
|
export { default as Heatmap } from './components/Heatmap.svelte';
|
|
56
56
|
// TierList (DS-0159): ranked rows + tray with pointer and keyboard sorting.
|
|
57
57
|
export { default as TierList } from './components/TierList.svelte';
|
|
58
|
-
export { DEFAULT_TIERS as TIERLIST_DEFAULT_TIERS, } from './tierlist
|
|
58
|
+
export { DEFAULT_TIERS as TIERLIST_DEFAULT_TIERS, } from './core/tierlist.js';
|
|
59
|
+
// Checkbox (DS-0197): native checkbox with a mixed state.
|
|
60
|
+
export { default as Checkbox } from './components/Checkbox.svelte';
|
|
61
|
+
// RadioGroup (DS-0197): native radios in a named radiogroup.
|
|
62
|
+
export { default as RadioGroup } from './components/RadioGroup.svelte';
|
|
63
|
+
// Tabs (DS-0197): WAI-ARIA tablist + panels.
|
|
64
|
+
export { default as Tabs } from './components/Tabs.svelte';
|
|
65
|
+
// Popover (DS-0197): non-modal floating panel anchored to a trigger.
|
|
66
|
+
export { default as Popover } from './components/Popover.svelte';
|
|
59
67
|
// Keyboard-shortcuts feature (DS-0135): registry core + display chip.
|
|
60
68
|
export { default as Kbd } from './components/Kbd.svelte';
|
|
61
69
|
export { default as ShortcutsHelp } from './components/ShortcutsHelp.svelte';
|
package/dist/theme.css
CHANGED
|
@@ -636,6 +636,53 @@
|
|
|
636
636
|
--ss-tier-gap: var(--ss-s-2);
|
|
637
637
|
}
|
|
638
638
|
|
|
639
|
+
:root,
|
|
640
|
+
[data-size-variant=md] {
|
|
641
|
+
--ss-tabs-font: var(--ss-ui-md);
|
|
642
|
+
--ss-tabs-py: 9px;
|
|
643
|
+
--ss-tabs-px: 14px;
|
|
644
|
+
--ss-tabs-gap: 8px;
|
|
645
|
+
--ss-tabs-panel-py: 16px;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
[data-size-variant=sm] {
|
|
649
|
+
--ss-tabs-font: var(--ss-ui-sm);
|
|
650
|
+
--ss-tabs-py: 5px;
|
|
651
|
+
--ss-tabs-px: 10px;
|
|
652
|
+
--ss-tabs-gap: 6px;
|
|
653
|
+
--ss-tabs-panel-py: 10px;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
[data-size-variant=lg] {
|
|
657
|
+
--ss-tabs-font: var(--ss-ui-lg);
|
|
658
|
+
--ss-tabs-py: 12px;
|
|
659
|
+
--ss-tabs-px: 18px;
|
|
660
|
+
--ss-tabs-gap: 10px;
|
|
661
|
+
--ss-tabs-panel-py: 20px;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
:root,
|
|
665
|
+
[data-size-variant=md] {
|
|
666
|
+
--ss-popover-pad: 14px;
|
|
667
|
+
--ss-popover-min-w: 200px;
|
|
668
|
+
--ss-popover-max-w: 340px;
|
|
669
|
+
--ss-popover-offset: 6px;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
[data-size-variant=sm] {
|
|
673
|
+
--ss-popover-pad: 10px;
|
|
674
|
+
--ss-popover-min-w: 160px;
|
|
675
|
+
--ss-popover-max-w: 280px;
|
|
676
|
+
--ss-popover-offset: 5px;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
[data-size-variant=lg] {
|
|
680
|
+
--ss-popover-pad: 18px;
|
|
681
|
+
--ss-popover-min-w: 240px;
|
|
682
|
+
--ss-popover-max-w: 400px;
|
|
683
|
+
--ss-popover-offset: 8px;
|
|
684
|
+
}
|
|
685
|
+
|
|
639
686
|
html {
|
|
640
687
|
font-family: var(--ss-font-body);
|
|
641
688
|
font-size: clamp(16px, 1vw + 12px, 20px);
|
package/dist/toast.svelte.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Toast, type ToastKind, type ToastOptions, type ToastPatch, type PromiseMessages } from './toast
|
|
2
|
-
export type { Toast, ToastKind, ToastAction, ToastOptions, ToastPatch, PromiseMessages, } from './toast
|
|
1
|
+
import { type Toast, type ToastKind, type ToastOptions, type ToastPatch, type PromiseMessages } from './core/toast.js';
|
|
2
|
+
export type { Toast, ToastKind, ToastAction, ToastOptions, ToastPatch, PromiseMessages, } from './core/toast.js';
|
|
3
3
|
/**
|
|
4
4
|
* Module-singleton toast store (Svelte 5 runes). One instance is shared by
|
|
5
5
|
* every consumer of the package, so `toast.success(...)` from anywhere shows
|
package/dist/toast.svelte.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_TIMEOUT, isSticky, resolveTimeout, normalizeOptions, ToastTimer, } from './toast
|
|
1
|
+
import { DEFAULT_TIMEOUT, isSticky, resolveTimeout, normalizeOptions, ToastTimer, } from './core/toast.js';
|
|
2
2
|
/**
|
|
3
3
|
* Module-singleton toast store (Svelte 5 runes). One instance is shared by
|
|
4
4
|
* every consumer of the package, so `toast.success(...)` from anywhere shows
|
package/dist/tokens.css
CHANGED
|
@@ -620,3 +620,50 @@
|
|
|
620
620
|
--ss-tier-label-font: var(--ss-size-h3);
|
|
621
621
|
--ss-tier-gap: var(--ss-s-2);
|
|
622
622
|
}
|
|
623
|
+
|
|
624
|
+
:root,
|
|
625
|
+
[data-size-variant=md] {
|
|
626
|
+
--ss-tabs-font: var(--ss-ui-md);
|
|
627
|
+
--ss-tabs-py: 9px;
|
|
628
|
+
--ss-tabs-px: 14px;
|
|
629
|
+
--ss-tabs-gap: 8px;
|
|
630
|
+
--ss-tabs-panel-py: 16px;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
[data-size-variant=sm] {
|
|
634
|
+
--ss-tabs-font: var(--ss-ui-sm);
|
|
635
|
+
--ss-tabs-py: 5px;
|
|
636
|
+
--ss-tabs-px: 10px;
|
|
637
|
+
--ss-tabs-gap: 6px;
|
|
638
|
+
--ss-tabs-panel-py: 10px;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
[data-size-variant=lg] {
|
|
642
|
+
--ss-tabs-font: var(--ss-ui-lg);
|
|
643
|
+
--ss-tabs-py: 12px;
|
|
644
|
+
--ss-tabs-px: 18px;
|
|
645
|
+
--ss-tabs-gap: 10px;
|
|
646
|
+
--ss-tabs-panel-py: 20px;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
:root,
|
|
650
|
+
[data-size-variant=md] {
|
|
651
|
+
--ss-popover-pad: 14px;
|
|
652
|
+
--ss-popover-min-w: 200px;
|
|
653
|
+
--ss-popover-max-w: 340px;
|
|
654
|
+
--ss-popover-offset: 6px;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
[data-size-variant=sm] {
|
|
658
|
+
--ss-popover-pad: 10px;
|
|
659
|
+
--ss-popover-min-w: 160px;
|
|
660
|
+
--ss-popover-max-w: 280px;
|
|
661
|
+
--ss-popover-offset: 5px;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
[data-size-variant=lg] {
|
|
665
|
+
--ss-popover-pad: 18px;
|
|
666
|
+
--ss-popover-min-w: 240px;
|
|
667
|
+
--ss-popover-max-w: 400px;
|
|
668
|
+
--ss-popover-offset: 8px;
|
|
669
|
+
}
|
|
@@ -1,36 +1,47 @@
|
|
|
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).
|
|
6
|
+
* The behaviour itself comes from `../core/accordion.js`, shared with the Svelte component
|
|
7
|
+
* (DS-0197): this file reads the state from the DOM, asks the core, and writes the result back.
|
|
6
8
|
*/
|
|
7
|
-
import { on, emit,
|
|
9
|
+
import { on, emit, all, byId } from './delegate.js';
|
|
10
|
+
import { accordionHeaderAttrs, accordionHeaderKey, accordionToggle, accordionValue, } from '../core/accordion.js';
|
|
8
11
|
const HEAD = '.ss-accordion .head[aria-controls]';
|
|
12
|
+
/** The root's own headers (not those of a nested accordion), in DOM order. */
|
|
13
|
+
function heads(root) {
|
|
14
|
+
return all(root, '.head[aria-controls]').filter((h) => h.closest('.ss-accordion') === root);
|
|
15
|
+
}
|
|
16
|
+
const isOpen = (head) => head.getAttribute('aria-expanded') === 'true';
|
|
17
|
+
/** A section's id on the plain-HTML path is its panel id (`aria-controls`). */
|
|
18
|
+
const idOf = (head) => head.getAttribute('aria-controls');
|
|
9
19
|
function setOpen(head, open) {
|
|
10
|
-
head.setAttribute('aria-expanded',
|
|
20
|
+
head.setAttribute('aria-expanded', accordionHeaderAttrs(open)['aria-expanded']);
|
|
11
21
|
head.closest('.item')?.classList.toggle('open', open);
|
|
12
22
|
const panel = byId(head.getAttribute('aria-controls'));
|
|
13
|
-
if (panel)
|
|
14
|
-
|
|
23
|
+
if (!panel)
|
|
24
|
+
return;
|
|
25
|
+
panel.hidden = !open;
|
|
26
|
+
// A closed panel keeps `display: grid` (so the collapse animates); `inert` keeps its content
|
|
27
|
+
// out of the Tab order and a11y tree, matching Accordion.svelte (DS-0162).
|
|
28
|
+
panel.toggleAttribute('inert', !open);
|
|
15
29
|
}
|
|
16
30
|
export function toggleAccordion(head) {
|
|
17
|
-
if (head.getAttribute('aria-disabled') === 'true')
|
|
18
|
-
return;
|
|
19
31
|
const root = head.closest('.ss-accordion');
|
|
20
32
|
if (!root)
|
|
21
33
|
return;
|
|
22
34
|
const multiple = root.hasAttribute('data-ss-multiple');
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
emit(root, 'ss:change', { value: multiple ? openIds : openIds[0] });
|
|
35
|
+
const list = heads(root);
|
|
36
|
+
// The DOM is the store: read the open ids, ask the core, write the result back.
|
|
37
|
+
const next = accordionToggle({ open: list.filter(isOpen).map(idOf), multiple }, idOf(head), head.getAttribute('aria-disabled') === 'true');
|
|
38
|
+
if (!next)
|
|
39
|
+
return;
|
|
40
|
+
for (const h of list)
|
|
41
|
+
setOpen(h, next.includes(idOf(h)));
|
|
42
|
+
// Reported in DOM order, whatever order the sections were opened in.
|
|
43
|
+
const openIds = list.map(idOf).filter((id) => next.includes(id));
|
|
44
|
+
emit(root, 'ss:change', { value: accordionValue(openIds, multiple) });
|
|
34
45
|
}
|
|
35
46
|
export function installAccordion() {
|
|
36
47
|
on('click', HEAD, (head) => toggleAccordion(head));
|
|
@@ -38,20 +49,12 @@ export function installAccordion() {
|
|
|
38
49
|
const root = head.closest('.ss-accordion');
|
|
39
50
|
if (!root)
|
|
40
51
|
return;
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
if (e.key === 'ArrowDown')
|
|
45
|
-
target = wrap(i + 1, heads.length);
|
|
46
|
-
else if (e.key === 'ArrowUp')
|
|
47
|
-
target = wrap(i - 1, heads.length);
|
|
48
|
-
else if (e.key === 'Home')
|
|
49
|
-
target = 0;
|
|
50
|
-
else if (e.key === 'End')
|
|
51
|
-
target = heads.length - 1;
|
|
52
|
-
if (target < 0)
|
|
52
|
+
const list = heads(root);
|
|
53
|
+
const result = accordionHeaderKey(list.length, list.indexOf(head), e.key);
|
|
54
|
+
if (!result)
|
|
53
55
|
return;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
if (result.preventDefault)
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
list[result.focus]?.focus();
|
|
56
59
|
});
|
|
57
60
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Write a state to a checkbox (property + `data-indeterminate`). Emits nothing. */
|
|
2
|
+
export declare function setCheckbox(input: HTMLInputElement, state: {
|
|
3
|
+
checked?: boolean;
|
|
4
|
+
indeterminate?: boolean;
|
|
5
|
+
}): void;
|
|
6
|
+
/** Copy `data-indeterminate="true"` onto the `indeterminate` property under `root`. */
|
|
7
|
+
export declare function mountCheckboxes(root?: ParentNode): void;
|
|
8
|
+
export declare function installCheckbox(): void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkbox (DS-0197) — `.ss-checkbox .input[type=checkbox]` is a native checkbox, so toggling,
|
|
3
|
+
* Space, label presses and form submission need no script. This module adds what HTML cannot
|
|
4
|
+
* express: the mixed state (`data-indeterminate="true"` on the input → the `indeterminate`
|
|
5
|
+
* property, applied by `mount()`), the shared rule that a mixed checkbox toggles to checked, and
|
|
6
|
+
* an `ss:change` event on the root with `{ checked }`. No `reason`: the browser reports a press
|
|
7
|
+
* on the box, on the label and Space as the same `change` event. The decision comes from
|
|
8
|
+
* `../core/checkbox.js`, shared with the Svelte component; state is read from the DOM.
|
|
9
|
+
*/
|
|
10
|
+
import { on, emit, all, setAttrs } from './delegate.js';
|
|
11
|
+
import { checkboxInputAttrs, checkboxToggle } from '../core/checkbox.js';
|
|
12
|
+
const INPUT = '.ss-checkbox .input[type="checkbox"]';
|
|
13
|
+
/** Write a state to a checkbox (property + `data-indeterminate`). Emits nothing. */
|
|
14
|
+
export function setCheckbox(input, state) {
|
|
15
|
+
if (state.checked !== undefined)
|
|
16
|
+
input.checked = state.checked;
|
|
17
|
+
if (state.indeterminate !== undefined) {
|
|
18
|
+
input.indeterminate = state.indeterminate;
|
|
19
|
+
setAttrs(input, checkboxInputAttrs(state.indeterminate));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** Copy `data-indeterminate="true"` onto the `indeterminate` property under `root`. */
|
|
23
|
+
export function mountCheckboxes(root = document) {
|
|
24
|
+
for (const input of all(root, `${INPUT}[data-indeterminate="true"]`)) {
|
|
25
|
+
input.indeterminate = true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function installCheckbox() {
|
|
29
|
+
on('change', INPUT, (el) => {
|
|
30
|
+
const input = el;
|
|
31
|
+
// The browser has already flipped `checked` and cleared `indeterminate`; the state from
|
|
32
|
+
// before the press is the inverse value plus the attribute the markup still carries.
|
|
33
|
+
const next = checkboxToggle({
|
|
34
|
+
checked: !input.checked,
|
|
35
|
+
indeterminate: input.dataset.indeterminate === 'true',
|
|
36
|
+
disabled: input.disabled,
|
|
37
|
+
});
|
|
38
|
+
if (!next)
|
|
39
|
+
return;
|
|
40
|
+
setCheckbox(input, next);
|
|
41
|
+
emit(input.closest('.ss-checkbox') ?? input, 'ss:change', { checked: next.checked });
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -13,4 +13,6 @@ export declare function wrap(i: number, n: number): number;
|
|
|
13
13
|
export declare function all<E extends Element = HTMLElement>(root: ParentNode, selector: string): E[];
|
|
14
14
|
/** Resolve an `aria-controls` / `#id` reference, preferring the nearest root. */
|
|
15
15
|
export declare function byId(id: string | null): HTMLElement | null;
|
|
16
|
+
/** Write a core's attribute bag onto an element; `undefined` removes the attribute. */
|
|
17
|
+
export declare function setAttrs(el: Element, attrs: Record<string, string | number | undefined>): void;
|
|
16
18
|
export {};
|
package/dist/vanilla/delegate.js
CHANGED
|
@@ -31,3 +31,12 @@ export function byId(id) {
|
|
|
31
31
|
return null;
|
|
32
32
|
return document.getElementById(id.startsWith('#') ? id.slice(1) : id);
|
|
33
33
|
}
|
|
34
|
+
/** Write a core's attribute bag onto an element; `undefined` removes the attribute. */
|
|
35
|
+
export function setAttrs(el, attrs) {
|
|
36
|
+
for (const [name, value] of Object.entries(attrs)) {
|
|
37
|
+
if (value === undefined)
|
|
38
|
+
el.removeAttribute(name);
|
|
39
|
+
else
|
|
40
|
+
el.setAttribute(name, String(value));
|
|
41
|
+
}
|
|
42
|
+
}
|