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.
Files changed (133) hide show
  1. package/README.md +3 -3
  2. package/dist/components/Accordion.svelte +23 -52
  3. package/dist/components/BottomNav.svelte +18 -28
  4. package/dist/components/BoxPlot.svelte +7 -6
  5. package/dist/components/BumpChart.svelte +9 -12
  6. package/dist/components/Chart.svelte +9 -12
  7. package/dist/components/Checkbox.svelte +210 -0
  8. package/dist/components/Checkbox.svelte.d.ts +38 -0
  9. package/dist/components/FileDrop.svelte +52 -83
  10. package/dist/components/FileDrop.svelte.d.ts +6 -2
  11. package/dist/components/Heatmap.svelte +8 -8
  12. package/dist/components/Image.svelte +44 -44
  13. package/dist/components/Input.svelte +8 -3
  14. package/dist/components/LogStream.svelte +15 -25
  15. package/dist/components/Menu.svelte +69 -94
  16. package/dist/components/Menu.svelte.d.ts +6 -0
  17. package/dist/components/Modal.svelte +61 -14
  18. package/dist/components/Modal.svelte.d.ts +7 -2
  19. package/dist/components/NumberField.svelte +18 -19
  20. package/dist/components/Pagination.svelte +47 -37
  21. package/dist/components/Pagination.svelte.d.ts +6 -2
  22. package/dist/components/Popover.svelte +404 -0
  23. package/dist/components/Popover.svelte.d.ts +55 -0
  24. package/dist/components/RadioGroup.svelte +227 -0
  25. package/dist/components/RadioGroup.svelte.d.ts +42 -0
  26. package/dist/components/ScatterPlot.svelte +11 -13
  27. package/dist/components/SearchPalette.svelte +124 -120
  28. package/dist/components/SearchPalette.svelte.d.ts +6 -4
  29. package/dist/components/SegmentedControl.svelte +41 -62
  30. package/dist/components/SegmentedControl.svelte.d.ts +7 -2
  31. package/dist/components/ShortcutsHelp.svelte +48 -47
  32. package/dist/components/Sidebar.svelte +48 -60
  33. package/dist/components/Switch.svelte +20 -10
  34. package/dist/components/Switch.svelte.d.ts +6 -2
  35. package/dist/components/Table.svelte +15 -37
  36. package/dist/components/Tabs.svelte +223 -0
  37. package/dist/components/Tabs.svelte.d.ts +51 -0
  38. package/dist/components/TierList.svelte +41 -38
  39. package/dist/components/TierList.svelte.d.ts +7 -3
  40. package/dist/components/Toaster.svelte +29 -29
  41. package/dist/components/Tooltip.svelte +37 -21
  42. package/dist/components/Topbar.svelte +13 -38
  43. package/dist/core/accordion.d.ts +32 -0
  44. package/dist/core/accordion.js +53 -0
  45. package/dist/core/behaviors/focusable.d.ts +5 -0
  46. package/dist/core/behaviors/focusable.js +14 -0
  47. package/dist/core/behaviors/roving.d.ts +13 -0
  48. package/dist/core/behaviors/roving.js +29 -0
  49. package/dist/core/bottom-nav.d.ts +36 -0
  50. package/dist/core/bottom-nav.js +33 -0
  51. package/dist/core/chart-nav.d.ts +53 -0
  52. package/dist/{chart-nav.js → core/chart-nav.js} +27 -0
  53. package/dist/core/checkbox.d.ts +36 -0
  54. package/dist/core/checkbox.js +29 -0
  55. package/dist/core/file-drop.d.ts +75 -0
  56. package/dist/core/file-drop.js +101 -0
  57. package/dist/core/image.d.ts +59 -0
  58. package/dist/core/image.js +64 -0
  59. package/dist/core/input.d.ts +21 -0
  60. package/dist/core/input.js +17 -0
  61. package/dist/core/log-stream.d.ts +51 -0
  62. package/dist/core/log-stream.js +50 -0
  63. package/dist/core/menu.d.ts +70 -0
  64. package/dist/core/menu.js +84 -0
  65. package/dist/core/modal.d.ts +59 -0
  66. package/dist/core/modal.js +44 -0
  67. package/dist/core/number-field.d.ts +47 -0
  68. package/dist/core/number-field.js +64 -0
  69. package/dist/core/pagination.d.ts +59 -0
  70. package/dist/core/pagination.js +65 -0
  71. package/dist/core/popover.d.ts +111 -0
  72. package/dist/core/popover.js +86 -0
  73. package/dist/core/radio.d.ts +36 -0
  74. package/dist/core/radio.js +48 -0
  75. package/dist/core/search-palette.d.ts +124 -0
  76. package/dist/core/search-palette.js +149 -0
  77. package/dist/core/segmented.d.ts +46 -0
  78. package/dist/core/segmented.js +66 -0
  79. package/dist/core/shortcuts-help.d.ts +56 -0
  80. package/dist/core/shortcuts-help.js +50 -0
  81. package/dist/core/sidebar.d.ts +63 -0
  82. package/dist/core/sidebar.js +84 -0
  83. package/dist/core/switch.d.ts +19 -0
  84. package/dist/core/switch.js +11 -0
  85. package/dist/core/table.d.ts +40 -0
  86. package/dist/core/table.js +57 -0
  87. package/dist/core/tabs.d.ts +84 -0
  88. package/dist/core/tabs.js +90 -0
  89. package/dist/{tierlist-core.d.ts → core/tierlist.d.ts} +62 -0
  90. package/dist/{tierlist-core.js → core/tierlist.js} +34 -0
  91. package/dist/core/toast.d.ts +112 -0
  92. package/dist/{toast-core.js → core/toast.js} +48 -2
  93. package/dist/core/tooltip.d.ts +47 -0
  94. package/dist/core/tooltip.js +51 -0
  95. package/dist/core/topbar.d.ts +41 -0
  96. package/dist/core/topbar.js +52 -0
  97. package/dist/dssoca.config.d.ts +1 -1
  98. package/dist/dssoca.config.js +4 -0
  99. package/dist/index.d.ts +14 -1
  100. package/dist/index.js +9 -1
  101. package/dist/theme.css +47 -0
  102. package/dist/toast.svelte.d.ts +2 -2
  103. package/dist/toast.svelte.js +1 -1
  104. package/dist/tokens.css +47 -0
  105. package/dist/vanilla/accordion.js +28 -29
  106. package/dist/vanilla/checkbox.d.ts +8 -0
  107. package/dist/vanilla/checkbox.js +43 -0
  108. package/dist/vanilla/delegate.d.ts +2 -0
  109. package/dist/vanilla/delegate.js +9 -0
  110. package/dist/vanilla/fields.js +37 -32
  111. package/dist/vanilla/index.d.ts +4 -0
  112. package/dist/vanilla/index.js +16 -3
  113. package/dist/vanilla/menu.js +92 -86
  114. package/dist/vanilla/modal.d.ts +3 -1
  115. package/dist/vanilla/modal.js +65 -15
  116. package/dist/vanilla/popover.d.ts +10 -0
  117. package/dist/vanilla/popover.js +199 -0
  118. package/dist/vanilla/radio.d.ts +3 -0
  119. package/dist/vanilla/radio.js +54 -0
  120. package/dist/vanilla/segmented.js +49 -51
  121. package/dist/vanilla/switch.d.ts +2 -1
  122. package/dist/vanilla/switch.js +13 -8
  123. package/dist/vanilla/tabs.d.ts +2 -0
  124. package/dist/vanilla/tabs.js +87 -0
  125. package/dist/vanilla/tierlist.d.ts +1 -1
  126. package/dist/vanilla/tierlist.js +32 -25
  127. package/dist/vanilla/toast.d.ts +2 -2
  128. package/dist/vanilla/toast.js +16 -14
  129. package/dist/vanilla/tooltip.js +35 -23
  130. package/dist/vanilla.css +364 -42
  131. package/package.json +1 -1
  132. package/dist/chart-nav.d.ts +0 -13
  133. package/dist/toast-core.d.ts +0 -61
@@ -0,0 +1,149 @@
1
+ /**
2
+ * SearchPalette core (DS-0197) — the one place the palette's behaviour is decided: which
3
+ * items match a query, how they group, where the active option moves, what a key does and
4
+ * why the palette opens or closes. Pure functions over a small state object; SearchPalette.svelte
5
+ * holds the state and applies the result. No DOM, no Svelte.
6
+ */
7
+ import { rovingStep } from './behaviors/roving.js';
8
+ // --- results ------------------------------------------------------------------
9
+ /** Case- and diacritic-insensitive fold ("São" matches "sao"). */
10
+ export function searchFold(text) {
11
+ return text.normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase();
12
+ }
13
+ /** Items whose label or keywords contain the query; a blank query keeps them all. */
14
+ export function searchFilter(items, query) {
15
+ const q = searchFold(query.trim());
16
+ if (!q)
17
+ return [...items];
18
+ return items.filter((it) => searchFold([it.label, ...(it.keywords ?? [])].join(' ')).includes(q));
19
+ }
20
+ /** Buckets in first-appearance order, the ungrouped one (label `null`) always first. */
21
+ export function searchGroups(items) {
22
+ const buckets = [];
23
+ for (const it of items) {
24
+ const label = it.group ?? null;
25
+ let b = buckets.find((entry) => entry.label === label);
26
+ if (!b) {
27
+ b = { label, bucket: [] };
28
+ buckets.push(b);
29
+ }
30
+ b.bucket.push(it);
31
+ }
32
+ buckets.sort((a, b) => Number(b.label === null) - Number(a.label === null));
33
+ let index = 0;
34
+ return buckets.map(({ label, bucket }) => ({
35
+ label,
36
+ entries: bucket.map((item) => ({ item, index: index++ })),
37
+ }));
38
+ }
39
+ /** The grouped items in display order — what the flat `index` of an entry points into. */
40
+ export function searchFlat(groups) {
41
+ return groups.flatMap((g) => g.entries.map((e) => e.item));
42
+ }
43
+ /** Live-region text: silent until the user types, then the count (or the no-results text). */
44
+ export function searchStatus(query, count, resultsText, emptyText) {
45
+ if (!query.trim())
46
+ return '';
47
+ return count ? resultsText(count) : emptyText;
48
+ }
49
+ const enabled = (state) => state.items.map((it, i) => (it.disabled ? -1 : i)).filter((i) => i >= 0);
50
+ /** The option a fresh list starts on: the first selectable one (0 when there is none). */
51
+ export function searchFirstActive(state) {
52
+ return Math.max(0, rovingStep(enabled(state), -1, 'first'));
53
+ }
54
+ /** `active` when it still points at a selectable option, else the first selectable one. */
55
+ export function searchValidActive(state) {
56
+ const { active, items } = state;
57
+ return active >= items.length || items[active]?.disabled ? searchFirstActive(state) : active;
58
+ }
59
+ /** The pointer moved over an option: it becomes active unless disabled (`null`). */
60
+ export function searchHover(state, index) {
61
+ return state.items[index] && !state.items[index].disabled ? index : null;
62
+ }
63
+ const close = (state, reason) => (state.open ? { type: 'close', reason } : null);
64
+ /** The toggle shortcut fired. */
65
+ export function searchShortcut(isOpen) {
66
+ return { type: isOpen ? 'close' : 'open', reason: 'shortcut' };
67
+ }
68
+ /**
69
+ * The backdrop was clicked; `onBackdrop` = the press both started and ended on the dialog
70
+ * itself, not the panel. Called on `click`, not `pointerdown`, for the same reason as
71
+ * `modalBackdropPress`: closing on the pointerdown lets the gesture's mousedown drop the
72
+ * returned focus on `<body>` (DS-0205).
73
+ */
74
+ export function searchBackdropPress(state, onBackdrop) {
75
+ return onBackdrop ? close(state, 'backdrop') : null;
76
+ }
77
+ /** The × close button was pressed. */
78
+ export function searchClosePress(state) {
79
+ return close(state, 'close-button');
80
+ }
81
+ /** An option was activated (click or Enter). `null` when it is disabled or missing. */
82
+ export function searchItemPress(state, index) {
83
+ const it = state.items[index];
84
+ if (!it || it.disabled)
85
+ return null;
86
+ return { close: close(state, 'select') };
87
+ }
88
+ /**
89
+ * A key on the input. `null` = not a palette key, let it through (typing, caret keys — Home/End
90
+ * stay native per the APG combobox; PageUp/PageDown jump to the first/last option instead).
91
+ * `composing` = an IME composition is in progress: every key belongs to it.
92
+ */
93
+ export function searchInputKey(state, key, composing = false) {
94
+ if (composing)
95
+ return null;
96
+ const move = (to) => {
97
+ const index = rovingStep(enabled(state), state.active, to);
98
+ // Nothing selectable: stay put (still revealing the active row), or do nothing when empty.
99
+ const target = index >= 0 ? index : state.items.length ? state.active : -1;
100
+ return {
101
+ action: target >= 0 ? { type: 'move', index: target } : null,
102
+ preventDefault: true,
103
+ };
104
+ };
105
+ switch (key) {
106
+ case 'ArrowDown':
107
+ return move('next');
108
+ case 'ArrowUp':
109
+ return move('prev');
110
+ case 'PageUp':
111
+ return move('first');
112
+ case 'PageDown':
113
+ return move('last');
114
+ case 'Enter': {
115
+ const it = state.items[state.active];
116
+ return {
117
+ action: it && !it.disabled
118
+ ? { type: 'activate', index: state.active, via: it.href ? 'anchor' : 'item' }
119
+ : null,
120
+ preventDefault: true,
121
+ };
122
+ }
123
+ case 'Tab':
124
+ // Focus stays on the input while the palette is open.
125
+ return { action: null, preventDefault: true };
126
+ default:
127
+ return null;
128
+ }
129
+ }
130
+ // --- attributes ---------------------------------------------------------------
131
+ // Strings, not booleans, so a spread writes the same DOM everywhere.
132
+ const bool = (value) => (value ? 'true' : 'false');
133
+ /** Combobox state on the input; `activeId` is the DOM id of the active option. */
134
+ export function searchInputAttrs(count, activeId) {
135
+ return {
136
+ role: 'combobox',
137
+ 'aria-autocomplete': 'list',
138
+ 'aria-expanded': bool(count > 0),
139
+ 'aria-activedescendant': count > 0 ? activeId : undefined,
140
+ };
141
+ }
142
+ export function searchOptionAttrs(option) {
143
+ return {
144
+ role: 'option',
145
+ 'aria-selected': bool(option.index === option.active),
146
+ 'aria-disabled': option.disabled ? 'true' : undefined,
147
+ tabindex: -1,
148
+ };
149
+ }
@@ -0,0 +1,46 @@
1
+ /** What moved the selection; passed to `onChange` / `ss:change`. */
2
+ export type SegmentedReason = 'press' | 'key';
3
+ export interface SegmentedChangeDetails {
4
+ reason: SegmentedReason;
5
+ }
6
+ export interface SegmentedState {
7
+ /** Index of the selected segment, `-1` when none. */
8
+ selected: number;
9
+ /** Indexes of the enabled segments, in DOM order (empty when the whole group is disabled). */
10
+ enabled: readonly number[];
11
+ }
12
+ /** Select segment `index`. `changed` is false when it already was the selection (no event). */
13
+ export interface SegmentedAction {
14
+ type: 'select';
15
+ index: number;
16
+ changed: boolean;
17
+ /** Move DOM focus to the segment too (keyboard: focus and selection travel together). */
18
+ focus: boolean;
19
+ reason: SegmentedReason;
20
+ }
21
+ /** A key the group handles: its action, and whether the browser default must be cancelled. */
22
+ export interface SegmentedKeyResult {
23
+ action: SegmentedAction;
24
+ preventDefault: boolean;
25
+ }
26
+ /** A segment was pressed. `null` when it (or the group) is disabled. */
27
+ export declare function segmentedPress(state: SegmentedState, index: number): SegmentedAction | null;
28
+ /**
29
+ * A key on segment `index`. Arrows / Home / End move over the enabled segments (wrapping) and
30
+ * select the target. `null` = not a group key, or nothing is enabled: let it through.
31
+ */
32
+ export declare function segmentedKey(state: SegmentedState, index: number, key: string, rtl?: boolean): SegmentedKeyResult | null;
33
+ /**
34
+ * The index that owns the group's single tab stop: the selected segment when it is enabled,
35
+ * otherwise the first enabled one; `-1` when nothing is enabled.
36
+ */
37
+ export declare function segmentedTabStop(state: SegmentedState): number;
38
+ export declare function segmentedGroupAttrs(disabled: boolean): {
39
+ readonly role: "radiogroup";
40
+ readonly 'aria-disabled': "true" | undefined;
41
+ };
42
+ export declare function segmentedItemAttrs(index: number, selected: number, tabStop: number): {
43
+ readonly role: "radio";
44
+ readonly 'aria-checked': "true" | "false";
45
+ readonly tabindex: 0 | -1;
46
+ };
@@ -0,0 +1,66 @@
1
+ /**
2
+ * SegmentedControl core (DS-0197) — the radiogroup's behaviour, decided once for
3
+ * SegmentedControl.svelte and `vanilla/segmented.ts`: what a press or a key selects, which
4
+ * segment owns the tab stop, and the state attributes. Pure functions: no DOM, no Svelte. The
5
+ * reading direction is read by the caller and passed in as `rtl`.
6
+ */
7
+ import { rovingStep, rovingTabindex } from './behaviors/roving.js';
8
+ const select = (state, index, focus, reason) => state.enabled.includes(index)
9
+ ? { type: 'select', index, changed: index !== state.selected, focus, reason }
10
+ : null;
11
+ /** A segment was pressed. `null` when it (or the group) is disabled. */
12
+ export function segmentedPress(state, index) {
13
+ return select(state, index, false, 'press');
14
+ }
15
+ function moveFor(key, rtl) {
16
+ switch (key) {
17
+ // Left/Right follow the visual order: under RTL the row runs right-to-left, so ArrowLeft
18
+ // points at the NEXT segment. Up/Down stay logical.
19
+ case 'ArrowRight':
20
+ return rtl ? 'prev' : 'next';
21
+ case 'ArrowLeft':
22
+ return rtl ? 'next' : 'prev';
23
+ case 'ArrowDown':
24
+ return 'next';
25
+ case 'ArrowUp':
26
+ return 'prev';
27
+ case 'Home':
28
+ return 'first';
29
+ case 'End':
30
+ return 'last';
31
+ default:
32
+ return null;
33
+ }
34
+ }
35
+ /**
36
+ * A key on segment `index`. Arrows / Home / End move over the enabled segments (wrapping) and
37
+ * select the target. `null` = not a group key, or nothing is enabled: let it through.
38
+ */
39
+ export function segmentedKey(state, index, key, rtl = false) {
40
+ const move = moveFor(key, rtl);
41
+ if (!move)
42
+ return null;
43
+ // A segment that is not enabled is no position to step from: fall back to an edge.
44
+ const from = state.enabled.includes(index) ? index : -1;
45
+ const action = select(state, rovingStep(state.enabled, from, move), true, 'key');
46
+ return action && { action, preventDefault: true };
47
+ }
48
+ /**
49
+ * The index that owns the group's single tab stop: the selected segment when it is enabled,
50
+ * otherwise the first enabled one; `-1` when nothing is enabled.
51
+ */
52
+ export function segmentedTabStop(state) {
53
+ return state.enabled.includes(state.selected) ? state.selected : (state.enabled[0] ?? -1);
54
+ }
55
+ // --- attributes ---------------------------------------------------------------
56
+ // Strings, not booleans, so the Svelte spread and the vanilla `setAttribute` write the same DOM.
57
+ export function segmentedGroupAttrs(disabled) {
58
+ return { role: 'radiogroup', 'aria-disabled': disabled ? 'true' : undefined };
59
+ }
60
+ export function segmentedItemAttrs(index, selected, tabStop) {
61
+ return {
62
+ role: 'radio',
63
+ 'aria-checked': index === selected ? 'true' : 'false',
64
+ tabindex: rovingTabindex(index, tabStop),
65
+ };
66
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * ShortcutsHelp core (DS-0197) — what the overlay decides beyond the shortcut registry itself:
3
+ * how the registered shortcuts are sectioned, and what a key pressed while recording a new
4
+ * binding does. Pure functions; ShortcutsHelp.svelte reads the registry and applies the result.
5
+ * No DOM, no Svelte.
6
+ */
7
+ /** The bucket for ungrouped shortcuts; sorted last by default. */
8
+ export declare const SHORTCUTS_FALLBACK_GROUP = "General";
9
+ export interface ShortcutsHelpGroup<T> {
10
+ name: string;
11
+ items: T[];
12
+ }
13
+ /**
14
+ * Section the shortcuts: buckets in first-appearance order with "General" forced last; an
15
+ * explicit `groupOrder` lists its named groups first and the rest keep the default order.
16
+ */
17
+ export declare function shortcutsHelpGroups<T extends {
18
+ group?: string;
19
+ }>(items: readonly T[], groupOrder?: readonly string[]): ShortcutsHelpGroup<T>[];
20
+ /** The row's Change / Cancel button: start recording that shortcut, or cancel if it already is. */
21
+ export declare function shortcutsHelpRecordPress(recordingId: string | null, id: string): {
22
+ type: 'start';
23
+ id: string;
24
+ } | {
25
+ type: 'cancel';
26
+ };
27
+ /**
28
+ * How the registry judged a pressed combo: usable, reserved by the browser, or not parseable
29
+ * as a binding at all.
30
+ */
31
+ export type ShortcutComboVerdict = 'ok' | 'reserved' | 'invalid';
32
+ export type ShortcutsHelpRecordAction =
33
+ /** Modifier-only press: a chord in progress, keep listening. */
34
+ {
35
+ type: 'wait';
36
+ }
37
+ /** Bare Escape: abandon the recording. */
38
+ | {
39
+ type: 'cancel';
40
+ }
41
+ /** The combo cannot be bound; recording stays live for another try. */
42
+ | {
43
+ type: 'reject';
44
+ why: 'reserved' | 'invalid';
45
+ combo: string;
46
+ }
47
+ /** Bind the combo and stop recording. */
48
+ | {
49
+ type: 'remap';
50
+ combo: string;
51
+ };
52
+ /**
53
+ * A keydown while recording. `combo` is the registry's normalized combo for the event (`null`
54
+ * for a modifier-only press); `verdict` is only asked for when the combo is a candidate.
55
+ */
56
+ export declare function shortcutsHelpRecordKey(combo: string | null, verdict: (combo: string) => ShortcutComboVerdict): ShortcutsHelpRecordAction;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * ShortcutsHelp core (DS-0197) — what the overlay decides beyond the shortcut registry itself:
3
+ * how the registered shortcuts are sectioned, and what a key pressed while recording a new
4
+ * binding does. Pure functions; ShortcutsHelp.svelte reads the registry and applies the result.
5
+ * No DOM, no Svelte.
6
+ */
7
+ /** The bucket for ungrouped shortcuts; sorted last by default. */
8
+ export const SHORTCUTS_FALLBACK_GROUP = 'General';
9
+ /**
10
+ * Section the shortcuts: buckets in first-appearance order with "General" forced last; an
11
+ * explicit `groupOrder` lists its named groups first and the rest keep the default order.
12
+ */
13
+ export function shortcutsHelpGroups(items, groupOrder) {
14
+ const buckets = [];
15
+ for (const item of items) {
16
+ const name = item.group ?? SHORTCUTS_FALLBACK_GROUP;
17
+ const bucket = buckets.find((g) => g.name === name);
18
+ if (bucket)
19
+ bucket.items.push(item);
20
+ else
21
+ buckets.push({ name, items: [item] });
22
+ }
23
+ let ordered = buckets.filter((g) => g.name !== SHORTCUTS_FALLBACK_GROUP);
24
+ const general = buckets.find((g) => g.name === SHORTCUTS_FALLBACK_GROUP);
25
+ if (general)
26
+ ordered.push(general);
27
+ if (groupOrder?.length) {
28
+ const explicit = groupOrder
29
+ .map((n) => ordered.find((g) => g.name === n))
30
+ .filter((g) => g !== undefined);
31
+ ordered = [...explicit, ...ordered.filter((g) => !explicit.includes(g))];
32
+ }
33
+ return ordered;
34
+ }
35
+ /** The row's Change / Cancel button: start recording that shortcut, or cancel if it already is. */
36
+ export function shortcutsHelpRecordPress(recordingId, id) {
37
+ return recordingId === id ? { type: 'cancel' } : { type: 'start', id };
38
+ }
39
+ /**
40
+ * A keydown while recording. `combo` is the registry's normalized combo for the event (`null`
41
+ * for a modifier-only press); `verdict` is only asked for when the combo is a candidate.
42
+ */
43
+ export function shortcutsHelpRecordKey(combo, verdict) {
44
+ if (combo === null)
45
+ return { type: 'wait' };
46
+ if (combo === 'escape')
47
+ return { type: 'cancel' };
48
+ const judged = verdict(combo);
49
+ return judged === 'ok' ? { type: 'remap', combo } : { type: 'reject', why: judged, combo };
50
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Sidebar core (DS-0197) — the decisions behind the nav rail: which item is active, whether a
3
+ * disclosure is open, what a key on a button-like item does, what the collapse toggle reports
4
+ * and how an item is named when the rail is icon-only. Pure functions; Sidebar.svelte holds the
5
+ * state and applies the result. No DOM, no Svelte.
6
+ */
7
+ export type SidebarStatus = 'up' | 'deg' | 'down';
8
+ /** The fields of a nav item the core reads. */
9
+ export interface SidebarItemLike {
10
+ id: string;
11
+ label: string;
12
+ status?: SidebarStatus;
13
+ external?: boolean;
14
+ badge?: string | number;
15
+ children?: readonly SidebarItemLike[];
16
+ }
17
+ /** The word announced next to a status dot; empty for `up` (the quiet default). */
18
+ export declare const SIDEBAR_STATUS_WORD: Record<SidebarStatus, string>;
19
+ /** Whether a badge value renders at all (`0` does, an empty string does not). */
20
+ export declare function sidebarHasBadge(badge: string | number | undefined | null): boolean;
21
+ /**
22
+ * The accessible name of an item in the collapsed (icon-only) rail: the label plus the
23
+ * degraded/down status, the badge and the new-tab hint, so nothing the expanded row shows is lost.
24
+ */
25
+ export declare function sidebarItemName(item: SidebarItemLike): string;
26
+ export declare function sidebarIsActive(item: SidebarItemLike, active: string | undefined): boolean;
27
+ /** A parent disclosure is "active-within" when it or any of its children is active. */
28
+ export declare function sidebarActiveWithin(item: SidebarItemLike, active: string | undefined): boolean;
29
+ /**
30
+ * Whether a disclosure is open. `toggled` is the user's own choice for it (`undefined` until
31
+ * they press it): before that it follows the active item, afterwards the choice wins.
32
+ */
33
+ export declare function sidebarDisclosureOpen(item: SidebarItemLike, active: string | undefined, toggled: boolean | undefined): boolean;
34
+ /** The disclosure button was pressed: the next value of its `toggled` choice. */
35
+ export declare function sidebarDisclosurePress(item: SidebarItemLike, active: string | undefined, toggled: boolean | undefined): boolean;
36
+ /** The collapse toggle was pressed: the `collapsed` value to report. */
37
+ export declare function sidebarCollapsePress(collapsed: boolean): boolean;
38
+ /** A key the sidebar handles: what it does, and whether the browser default must be cancelled. */
39
+ export interface SidebarKeyResult {
40
+ action: {
41
+ type: 'select';
42
+ };
43
+ preventDefault: boolean;
44
+ }
45
+ /**
46
+ * A key on a button-like item (`role="button"`, no `href`): Enter and Space select it, like a
47
+ * native button. `null` = not a sidebar key, let it through.
48
+ */
49
+ export declare function sidebarItemKey(key: string): SidebarKeyResult | null;
50
+ /** The collapse toggle: expanded is the opposite of collapsed. */
51
+ export declare function sidebarToggleAttrs(collapsed: boolean): {
52
+ readonly 'aria-expanded': "true" | "false";
53
+ };
54
+ export declare function sidebarDisclosureAttrs(open: boolean, panelId: string): {
55
+ readonly 'aria-expanded': "true" | "false";
56
+ readonly 'aria-controls': string;
57
+ };
58
+ /** State of a link / button-like item; the name is only forced in the collapsed rail. */
59
+ export declare function sidebarItemAttrs(item: SidebarItemLike, active: string | undefined, collapsed: boolean): {
60
+ readonly 'aria-current': "page" | undefined;
61
+ readonly 'aria-label': string | undefined;
62
+ readonly title: string | undefined;
63
+ };
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Sidebar core (DS-0197) — the decisions behind the nav rail: which item is active, whether a
3
+ * disclosure is open, what a key on a button-like item does, what the collapse toggle reports
4
+ * and how an item is named when the rail is icon-only. Pure functions; Sidebar.svelte holds the
5
+ * state and applies the result. No DOM, no Svelte.
6
+ */
7
+ /** The word announced next to a status dot; empty for `up` (the quiet default). */
8
+ export const SIDEBAR_STATUS_WORD = {
9
+ up: '',
10
+ deg: 'degraded',
11
+ down: 'down',
12
+ };
13
+ /** Whether a badge value renders at all (`0` does, an empty string does not). */
14
+ export function sidebarHasBadge(badge) {
15
+ return badge != null && badge !== '';
16
+ }
17
+ /**
18
+ * The accessible name of an item in the collapsed (icon-only) rail: the label plus the
19
+ * degraded/down status, the badge and the new-tab hint, so nothing the expanded row shows is lost.
20
+ */
21
+ export function sidebarItemName(item) {
22
+ const parts = [item.label];
23
+ if (item.status && SIDEBAR_STATUS_WORD[item.status])
24
+ parts.push(SIDEBAR_STATUS_WORD[item.status]);
25
+ if (sidebarHasBadge(item.badge))
26
+ parts.push(`${item.badge}`);
27
+ if (item.external)
28
+ parts.push('opens in a new tab');
29
+ return parts.join(', ');
30
+ }
31
+ export function sidebarIsActive(item, active) {
32
+ return item.id === active;
33
+ }
34
+ /** A parent disclosure is "active-within" when it or any of its children is active. */
35
+ export function sidebarActiveWithin(item, active) {
36
+ return sidebarIsActive(item, active) || !!item.children?.some((c) => sidebarIsActive(c, active));
37
+ }
38
+ /**
39
+ * Whether a disclosure is open. `toggled` is the user's own choice for it (`undefined` until
40
+ * they press it): before that it follows the active item, afterwards the choice wins.
41
+ */
42
+ export function sidebarDisclosureOpen(item, active, toggled) {
43
+ return toggled ?? sidebarActiveWithin(item, active);
44
+ }
45
+ /** The disclosure button was pressed: the next value of its `toggled` choice. */
46
+ export function sidebarDisclosurePress(item, active, toggled) {
47
+ return !sidebarDisclosureOpen(item, active, toggled);
48
+ }
49
+ /** The collapse toggle was pressed: the `collapsed` value to report. */
50
+ export function sidebarCollapsePress(collapsed) {
51
+ return !collapsed;
52
+ }
53
+ /**
54
+ * A key on a button-like item (`role="button"`, no `href`): Enter and Space select it, like a
55
+ * native button. `null` = not a sidebar key, let it through.
56
+ */
57
+ export function sidebarItemKey(key) {
58
+ switch (key) {
59
+ case 'Enter':
60
+ case ' ':
61
+ return { action: { type: 'select' }, preventDefault: true };
62
+ default:
63
+ return null;
64
+ }
65
+ }
66
+ // --- attributes ---------------------------------------------------------------
67
+ // Strings, not booleans, so a spread writes the same DOM everywhere.
68
+ const bool = (value) => (value ? 'true' : 'false');
69
+ /** The collapse toggle: expanded is the opposite of collapsed. */
70
+ export function sidebarToggleAttrs(collapsed) {
71
+ return { 'aria-expanded': bool(!collapsed) };
72
+ }
73
+ export function sidebarDisclosureAttrs(open, panelId) {
74
+ return { 'aria-expanded': bool(open), 'aria-controls': panelId };
75
+ }
76
+ /** State of a link / button-like item; the name is only forced in the collapsed rail. */
77
+ export function sidebarItemAttrs(item, active, collapsed) {
78
+ const name = collapsed ? sidebarItemName(item) : undefined;
79
+ return {
80
+ 'aria-current': sidebarIsActive(item, active) ? 'page' : undefined,
81
+ 'aria-label': name,
82
+ title: name,
83
+ };
84
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Switch core (DS-0198) — the toggle decision and the state attributes, shared by Switch.svelte
3
+ * and `vanilla/switch.ts`. No DOM, no Svelte.
4
+ */
5
+ /** What flipped the switch; passed to `onchange` / `ss:change`. */
6
+ export type SwitchReason = 'track' | 'label';
7
+ export interface SwitchChangeDetails {
8
+ reason: SwitchReason;
9
+ }
10
+ export interface SwitchState {
11
+ checked: boolean;
12
+ disabled: boolean;
13
+ }
14
+ /** The next `checked` value, or `null` when the switch is disabled and must not change. */
15
+ export declare function switchToggle(state: SwitchState): boolean | null;
16
+ export declare function switchTrackAttrs(checked: boolean): {
17
+ readonly role: "switch";
18
+ readonly 'aria-checked': "true" | "false";
19
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Switch core (DS-0198) — the toggle decision and the state attributes, shared by Switch.svelte
3
+ * and `vanilla/switch.ts`. No DOM, no Svelte.
4
+ */
5
+ /** The next `checked` value, or `null` when the switch is disabled and must not change. */
6
+ export function switchToggle(state) {
7
+ return state.disabled ? null : !state.checked;
8
+ }
9
+ export function switchTrackAttrs(checked) {
10
+ return { role: 'switch', 'aria-checked': checked ? 'true' : 'false' };
11
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Table core (DS-0197) — sorting: what a press on a sortable header does, the order of the rows
3
+ * and the attributes that reflect the sort. Pure functions; Table.svelte holds the bound `sort`
4
+ * and applies the result. No DOM, no Svelte.
5
+ */
6
+ export type TableSortDir = 'asc' | 'desc';
7
+ /** The active sort: a column key and a direction. */
8
+ export interface TableSortState {
9
+ key: string;
10
+ dir: TableSortDir;
11
+ }
12
+ /** What the sort needs to know about a column. */
13
+ export interface TableSortColumn {
14
+ key: string;
15
+ /** Compare the values as numbers rather than as strings. */
16
+ numeric?: boolean;
17
+ }
18
+ type Sort = TableSortState | undefined | null;
19
+ /** A sortable header was pressed: the same column flips direction, a new one starts ascending. */
20
+ export declare function tableToggleSort(sort: Sort, key: string): TableSortState;
21
+ /** `aria-sort` of a sortable column header. */
22
+ export declare function tableAriaSort(sort: Sort, key: string): 'ascending' | 'descending' | 'none';
23
+ /** The glyph in a sortable header: the active direction, or the "sortable" double arrow. */
24
+ export declare function tableSortIndicator(sort: Sort, key: string): '↑' | '↓' | '↕';
25
+ /**
26
+ * The rows in display order. Returns `rows` itself when there is no sort or it names an unknown
27
+ * column; otherwise a sorted copy (numeric columns compare as numbers, the rest as
28
+ * locale-aware strings with nullish values as `''`).
29
+ */
30
+ export declare function tableSortRows<Row>(rows: readonly Row[], columns: readonly TableSortColumn[], sort: Sort): readonly Row[];
31
+ export type TableAlign = 'start' | 'end' | 'left' | 'right' | 'center';
32
+ /**
33
+ * Logical alignment of a column: legacy `left` / `right` map to `start` / `end` so RTL mirrors,
34
+ * and a numeric column defaults to `end`.
35
+ */
36
+ export declare function tableColumnAlign(column: {
37
+ align?: TableAlign;
38
+ numeric?: boolean;
39
+ }): 'start' | 'end' | 'center';
40
+ export {};
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Table core (DS-0197) — sorting: what a press on a sortable header does, the order of the rows
3
+ * and the attributes that reflect the sort. Pure functions; Table.svelte holds the bound `sort`
4
+ * and applies the result. No DOM, no Svelte.
5
+ */
6
+ const sortsBy = (sort, key) => sort != null && sort.key === key;
7
+ /** A sortable header was pressed: the same column flips direction, a new one starts ascending. */
8
+ export function tableToggleSort(sort, key) {
9
+ return sortsBy(sort, key)
10
+ ? { key, dir: sort.dir === 'asc' ? 'desc' : 'asc' }
11
+ : { key, dir: 'asc' };
12
+ }
13
+ /** `aria-sort` of a sortable column header. */
14
+ export function tableAriaSort(sort, key) {
15
+ if (!sortsBy(sort, key))
16
+ return 'none';
17
+ return sort.dir === 'asc' ? 'ascending' : 'descending';
18
+ }
19
+ /** The glyph in a sortable header: the active direction, or the "sortable" double arrow. */
20
+ export function tableSortIndicator(sort, key) {
21
+ if (!sortsBy(sort, key))
22
+ return '↕';
23
+ return sort.dir === 'asc' ? '↑' : '↓';
24
+ }
25
+ /**
26
+ * The rows in display order. Returns `rows` itself when there is no sort or it names an unknown
27
+ * column; otherwise a sorted copy (numeric columns compare as numbers, the rest as
28
+ * locale-aware strings with nullish values as `''`).
29
+ */
30
+ export function tableSortRows(rows, columns, sort) {
31
+ if (!sort)
32
+ return rows;
33
+ const col = columns.find((c) => c.key === sort.key);
34
+ if (!col)
35
+ return rows;
36
+ const dir = sort.dir === 'desc' ? -1 : 1;
37
+ const value = (row) => row?.[sort.key];
38
+ return [...rows].sort((a, b) => {
39
+ const av = value(a);
40
+ const bv = value(b);
41
+ if (col.numeric)
42
+ return (Number(av) - Number(bv)) * dir;
43
+ return String(av ?? '').localeCompare(String(bv ?? '')) * dir;
44
+ });
45
+ }
46
+ /**
47
+ * Logical alignment of a column: legacy `left` / `right` map to `start` / `end` so RTL mirrors,
48
+ * and a numeric column defaults to `end`.
49
+ */
50
+ export function tableColumnAlign(column) {
51
+ const align = column.align ?? (column.numeric ? 'end' : 'start');
52
+ if (align === 'left')
53
+ return 'start';
54
+ if (align === 'right')
55
+ return 'end';
56
+ return align;
57
+ }