dssoca 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/components/Accordion.svelte +23 -52
- package/dist/components/BottomNav.svelte +18 -28
- package/dist/components/BoxPlot.svelte +7 -6
- package/dist/components/BumpChart.svelte +9 -12
- package/dist/components/Chart.svelte +9 -12
- package/dist/components/Checkbox.svelte +210 -0
- package/dist/components/Checkbox.svelte.d.ts +38 -0
- package/dist/components/FileDrop.svelte +52 -83
- package/dist/components/FileDrop.svelte.d.ts +6 -2
- package/dist/components/Heatmap.svelte +8 -8
- package/dist/components/Image.svelte +44 -44
- package/dist/components/Input.svelte +8 -3
- package/dist/components/LogStream.svelte +15 -25
- package/dist/components/Menu.svelte +69 -94
- package/dist/components/Menu.svelte.d.ts +6 -0
- package/dist/components/Modal.svelte +61 -14
- package/dist/components/Modal.svelte.d.ts +7 -2
- package/dist/components/NumberField.svelte +18 -19
- package/dist/components/Pagination.svelte +47 -37
- package/dist/components/Pagination.svelte.d.ts +6 -2
- package/dist/components/Popover.svelte +404 -0
- package/dist/components/Popover.svelte.d.ts +55 -0
- package/dist/components/RadioGroup.svelte +227 -0
- package/dist/components/RadioGroup.svelte.d.ts +42 -0
- package/dist/components/ScatterPlot.svelte +11 -13
- package/dist/components/SearchPalette.svelte +124 -120
- package/dist/components/SearchPalette.svelte.d.ts +6 -4
- package/dist/components/SegmentedControl.svelte +41 -62
- package/dist/components/SegmentedControl.svelte.d.ts +7 -2
- package/dist/components/ShortcutsHelp.svelte +48 -47
- package/dist/components/Sidebar.svelte +48 -60
- package/dist/components/Switch.svelte +20 -10
- package/dist/components/Switch.svelte.d.ts +6 -2
- package/dist/components/Table.svelte +15 -37
- package/dist/components/Tabs.svelte +223 -0
- package/dist/components/Tabs.svelte.d.ts +51 -0
- package/dist/components/TierList.svelte +41 -38
- package/dist/components/TierList.svelte.d.ts +7 -3
- package/dist/components/Toaster.svelte +29 -29
- package/dist/components/Tooltip.svelte +37 -21
- package/dist/components/Topbar.svelte +13 -38
- package/dist/core/accordion.d.ts +32 -0
- package/dist/core/accordion.js +53 -0
- package/dist/core/behaviors/focusable.d.ts +5 -0
- package/dist/core/behaviors/focusable.js +14 -0
- package/dist/core/behaviors/roving.d.ts +13 -0
- package/dist/core/behaviors/roving.js +29 -0
- package/dist/core/bottom-nav.d.ts +36 -0
- package/dist/core/bottom-nav.js +33 -0
- package/dist/core/chart-nav.d.ts +53 -0
- package/dist/{chart-nav.js → core/chart-nav.js} +27 -0
- package/dist/core/checkbox.d.ts +36 -0
- package/dist/core/checkbox.js +29 -0
- package/dist/core/file-drop.d.ts +75 -0
- package/dist/core/file-drop.js +101 -0
- package/dist/core/image.d.ts +59 -0
- package/dist/core/image.js +64 -0
- package/dist/core/input.d.ts +21 -0
- package/dist/core/input.js +17 -0
- package/dist/core/log-stream.d.ts +51 -0
- package/dist/core/log-stream.js +50 -0
- package/dist/core/menu.d.ts +70 -0
- package/dist/core/menu.js +84 -0
- package/dist/core/modal.d.ts +59 -0
- package/dist/core/modal.js +44 -0
- package/dist/core/number-field.d.ts +47 -0
- package/dist/core/number-field.js +64 -0
- package/dist/core/pagination.d.ts +59 -0
- package/dist/core/pagination.js +65 -0
- package/dist/core/popover.d.ts +111 -0
- package/dist/core/popover.js +86 -0
- package/dist/core/radio.d.ts +36 -0
- package/dist/core/radio.js +48 -0
- package/dist/core/search-palette.d.ts +124 -0
- package/dist/core/search-palette.js +149 -0
- package/dist/core/segmented.d.ts +46 -0
- package/dist/core/segmented.js +66 -0
- package/dist/core/shortcuts-help.d.ts +56 -0
- package/dist/core/shortcuts-help.js +50 -0
- package/dist/core/sidebar.d.ts +63 -0
- package/dist/core/sidebar.js +84 -0
- package/dist/core/switch.d.ts +19 -0
- package/dist/core/switch.js +11 -0
- package/dist/core/table.d.ts +40 -0
- package/dist/core/table.js +57 -0
- package/dist/core/tabs.d.ts +84 -0
- package/dist/core/tabs.js +90 -0
- package/dist/{tierlist-core.d.ts → core/tierlist.d.ts} +62 -0
- package/dist/{tierlist-core.js → core/tierlist.js} +34 -0
- package/dist/core/toast.d.ts +112 -0
- package/dist/{toast-core.js → core/toast.js} +48 -2
- package/dist/core/tooltip.d.ts +47 -0
- package/dist/core/tooltip.js +51 -0
- package/dist/core/topbar.d.ts +41 -0
- package/dist/core/topbar.js +52 -0
- package/dist/dssoca.config.d.ts +1 -1
- package/dist/dssoca.config.js +4 -0
- package/dist/index.d.ts +14 -1
- package/dist/index.js +9 -1
- package/dist/theme.css +47 -0
- package/dist/toast.svelte.d.ts +2 -2
- package/dist/toast.svelte.js +1 -1
- package/dist/tokens.css +47 -0
- package/dist/vanilla/accordion.js +28 -29
- package/dist/vanilla/checkbox.d.ts +8 -0
- package/dist/vanilla/checkbox.js +43 -0
- package/dist/vanilla/delegate.d.ts +2 -0
- package/dist/vanilla/delegate.js +9 -0
- package/dist/vanilla/fields.js +37 -32
- package/dist/vanilla/index.d.ts +4 -0
- package/dist/vanilla/index.js +16 -3
- package/dist/vanilla/menu.js +92 -86
- package/dist/vanilla/modal.d.ts +3 -1
- package/dist/vanilla/modal.js +65 -15
- package/dist/vanilla/popover.d.ts +10 -0
- package/dist/vanilla/popover.js +199 -0
- package/dist/vanilla/radio.d.ts +3 -0
- package/dist/vanilla/radio.js +54 -0
- package/dist/vanilla/segmented.js +49 -51
- package/dist/vanilla/switch.d.ts +2 -1
- package/dist/vanilla/switch.js +13 -8
- package/dist/vanilla/tabs.d.ts +2 -0
- package/dist/vanilla/tabs.js +87 -0
- package/dist/vanilla/tierlist.d.ts +1 -1
- package/dist/vanilla/tierlist.js +32 -25
- package/dist/vanilla/toast.d.ts +2 -2
- package/dist/vanilla/toast.js +16 -14
- package/dist/vanilla/tooltip.js +35 -23
- package/dist/vanilla.css +364 -42
- package/package.json +1 -1
- package/dist/chart-nav.d.ts +0 -13
- package/dist/toast-core.d.ts +0 -61
|
@@ -26,6 +26,14 @@
|
|
|
26
26
|
formatShortcut,
|
|
27
27
|
type ShortcutInfo,
|
|
28
28
|
} from '../shortcuts.svelte.js'
|
|
29
|
+
import {
|
|
30
|
+
SHORTCUTS_FALLBACK_GROUP as FALLBACK_GROUP,
|
|
31
|
+
shortcutsHelpGroups,
|
|
32
|
+
shortcutsHelpRecordKey,
|
|
33
|
+
shortcutsHelpRecordPress,
|
|
34
|
+
type ShortcutComboVerdict,
|
|
35
|
+
type ShortcutsHelpGroup,
|
|
36
|
+
} from '../core/shortcuts-help.js'
|
|
29
37
|
|
|
30
38
|
interface Props {
|
|
31
39
|
/** Whether the overlay is shown. Bindable — control it, or let the hotkey manage it. */
|
|
@@ -67,8 +75,6 @@
|
|
|
67
75
|
children,
|
|
68
76
|
}: Props = $props()
|
|
69
77
|
|
|
70
|
-
const FALLBACK_GROUP = 'General'
|
|
71
|
-
|
|
72
78
|
// Self-registration. `add()` returns the disposer, which doubles as the
|
|
73
79
|
// effect's cleanup: unmount unregisters, a `hotkey` change re-registers.
|
|
74
80
|
// Effects never run on the server, so SSR stays registration-free.
|
|
@@ -85,33 +91,15 @@
|
|
|
85
91
|
})
|
|
86
92
|
})
|
|
87
93
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
items: ShortcutInfo[]
|
|
91
|
-
}
|
|
94
|
+
// Behaviour lives in `core/shortcuts-help.ts`: the sectioning below and what a key does
|
|
95
|
+
// while recording are decided there; the registry stays the source of the shortcuts.
|
|
92
96
|
|
|
93
97
|
// Live grouping of the registry: buckets in first-appearance order with
|
|
94
98
|
// "General" forced last; an explicit `groupOrder` lists its named groups
|
|
95
99
|
// first and the rest keep the default order.
|
|
96
|
-
const groups:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const name = item.group ?? FALLBACK_GROUP
|
|
100
|
-
const bucket = buckets.find((g) => g.name === name)
|
|
101
|
-
if (bucket) bucket.items.push(item)
|
|
102
|
-
else buckets.push({ name, items: [item] })
|
|
103
|
-
}
|
|
104
|
-
let ordered = buckets.filter((g) => g.name !== FALLBACK_GROUP)
|
|
105
|
-
const general = buckets.find((g) => g.name === FALLBACK_GROUP)
|
|
106
|
-
if (general) ordered.push(general)
|
|
107
|
-
if (groupOrder?.length) {
|
|
108
|
-
const explicit = groupOrder
|
|
109
|
-
.map((n) => ordered.find((g) => g.name === n))
|
|
110
|
-
.filter((g): g is Group => g !== undefined)
|
|
111
|
-
ordered = [...explicit, ...ordered.filter((g) => !explicit.includes(g))]
|
|
112
|
-
}
|
|
113
|
-
return ordered
|
|
114
|
-
})
|
|
100
|
+
const groups: ShortcutsHelpGroup<ShortcutInfo>[] = $derived(
|
|
101
|
+
shortcutsHelpGroups(shortcuts.items, groupOrder),
|
|
102
|
+
)
|
|
115
103
|
|
|
116
104
|
// ── Editable mode (DS-0141) — remap recorder + live announcements ────────
|
|
117
105
|
// One shortcut records at a time; `status` feeds the visible role="status"
|
|
@@ -132,6 +120,20 @@
|
|
|
132
120
|
status = 'Shortcut change cancelled.'
|
|
133
121
|
}
|
|
134
122
|
|
|
123
|
+
function toggleRecording(item: ShortcutInfo) {
|
|
124
|
+
if (shortcutsHelpRecordPress(recordingId, item.id).type === 'start') startRecording(item)
|
|
125
|
+
else cancelRecording()
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// The registry's own judgement of a combo (its parser throws on what it cannot bind).
|
|
129
|
+
function verdict(combo: string): ShortcutComboVerdict {
|
|
130
|
+
try {
|
|
131
|
+
return isReservedCombo(combo) ? 'reserved' : 'ok'
|
|
132
|
+
} catch {
|
|
133
|
+
return 'invalid'
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
135
137
|
function resetRow(item: ShortcutInfo) {
|
|
136
138
|
shortcuts.remap(item.id, null)
|
|
137
139
|
status = `"${item.label}" restored to ${spoken(item.defaultKeys)}.`
|
|
@@ -157,27 +159,27 @@
|
|
|
157
159
|
const onKeydown = (event: KeyboardEvent) => {
|
|
158
160
|
event.preventDefault()
|
|
159
161
|
event.stopPropagation()
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
162
|
+
const action = shortcutsHelpRecordKey(comboFromEvent(event), verdict)
|
|
163
|
+
switch (action.type) {
|
|
164
|
+
case 'wait':
|
|
165
|
+
break
|
|
166
|
+
case 'cancel':
|
|
167
|
+
cancelRecording()
|
|
168
|
+
break
|
|
169
|
+
case 'reject':
|
|
170
|
+
status =
|
|
171
|
+
action.why === 'invalid'
|
|
172
|
+
? 'That key cannot be used — try another combination.'
|
|
173
|
+
: `${spoken(action.combo)} is reserved by the browser — try another combination.`
|
|
174
|
+
break
|
|
175
|
+
case 'remap': {
|
|
176
|
+
const label = shortcuts.items.find((i) => i.id === id)?.label ?? id
|
|
177
|
+
shortcuts.remap(id, action.combo)
|
|
178
|
+
recordingId = null
|
|
179
|
+
status = `"${label}" is now ${spoken(action.combo)}.`
|
|
180
|
+
break
|
|
181
|
+
}
|
|
177
182
|
}
|
|
178
|
-
shortcuts.remap(id, combo)
|
|
179
|
-
recordingId = null
|
|
180
|
-
status = `"${label}" is now ${spoken(combo)}.`
|
|
181
183
|
}
|
|
182
184
|
window.addEventListener('keydown', onKeydown, true)
|
|
183
185
|
return () => window.removeEventListener('keydown', onKeydown, true)
|
|
@@ -239,8 +241,7 @@
|
|
|
239
241
|
aria-label={recordingId === item.id
|
|
240
242
|
? `Recording a new shortcut for "${item.label}" — press keys, Escape cancels`
|
|
241
243
|
: `Change the shortcut for "${item.label}"`}
|
|
242
|
-
onclick={() =>
|
|
243
|
-
recordingId === item.id ? cancelRecording() : startRecording(item)}
|
|
244
|
+
onclick={() => toggleRecording(item)}
|
|
244
245
|
>
|
|
245
246
|
{recordingId === item.id ? 'Cancel' : 'Change'}
|
|
246
247
|
</Button>
|
|
@@ -29,6 +29,20 @@
|
|
|
29
29
|
<script lang="ts">
|
|
30
30
|
import Icon from './Icon.svelte'
|
|
31
31
|
import { resolveComponentSize, type Size } from '../config.js'
|
|
32
|
+
import {
|
|
33
|
+
SIDEBAR_STATUS_WORD as STATUS_WORD,
|
|
34
|
+
sidebarActiveWithin,
|
|
35
|
+
sidebarCollapsePress,
|
|
36
|
+
sidebarDisclosureAttrs,
|
|
37
|
+
sidebarDisclosureOpen,
|
|
38
|
+
sidebarDisclosurePress,
|
|
39
|
+
sidebarHasBadge,
|
|
40
|
+
sidebarIsActive,
|
|
41
|
+
sidebarItemAttrs,
|
|
42
|
+
sidebarItemKey,
|
|
43
|
+
sidebarItemName,
|
|
44
|
+
sidebarToggleAttrs,
|
|
45
|
+
} from '../core/sidebar.js'
|
|
32
46
|
|
|
33
47
|
interface Props {
|
|
34
48
|
active?: string
|
|
@@ -70,40 +84,30 @@
|
|
|
70
84
|
onToggleCollapsed,
|
|
71
85
|
}: Props = $props()
|
|
72
86
|
|
|
73
|
-
//
|
|
87
|
+
// Behaviour lives in `core/sidebar.ts`: which item is active, whether a disclosure is
|
|
88
|
+
// open, how an item is named in the collapsed rail and what a key does are decided there.
|
|
74
89
|
|
|
75
|
-
const
|
|
76
|
-
up: '',
|
|
77
|
-
deg: 'degraded',
|
|
78
|
-
down: 'down',
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/** Compose the accessible name so collapsed/icon-only rails and AT users
|
|
82
|
-
* keep the label, the degraded/down status, and the badge count. */
|
|
83
|
-
function accessibleName(item: SideItem): string {
|
|
84
|
-
const parts = [item.label]
|
|
85
|
-
if (item.status && STATUS_WORD[item.status]) parts.push(STATUS_WORD[item.status])
|
|
86
|
-
if (item.badge != null && item.badge !== '') parts.push(`${item.badge}`)
|
|
87
|
-
if (item.external) parts.push('opens in a new tab')
|
|
88
|
-
return parts.join(', ')
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function isActive(item: SideItem): boolean {
|
|
92
|
-
return item.id === active
|
|
93
|
-
}
|
|
90
|
+
const isActive = (item: SideItem): boolean => sidebarIsActive(item, active)
|
|
94
91
|
|
|
95
92
|
/** A parent disclosure is "active-within" when it or any child is active. */
|
|
96
|
-
|
|
97
|
-
return isActive(item) || !!item.children?.some(isActive)
|
|
98
|
-
}
|
|
93
|
+
const hasActiveDescendant = (item: SideItem): boolean => sidebarActiveWithin(item, active)
|
|
99
94
|
|
|
100
95
|
// Per-disclosure open state. Auto-expanded when a descendant is active;
|
|
101
96
|
// user toggles override afterwards.
|
|
102
97
|
let openState = $state<Record<string, boolean>>({})
|
|
103
|
-
const isOpen = (item: SideItem): boolean =>
|
|
98
|
+
const isOpen = (item: SideItem): boolean =>
|
|
99
|
+
sidebarDisclosureOpen(item, active, openState[item.id])
|
|
104
100
|
|
|
105
101
|
function toggleOpen(item: SideItem) {
|
|
106
|
-
openState[item.id] =
|
|
102
|
+
openState[item.id] = sidebarDisclosurePress(item, active, openState[item.id])
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Enter / Space on a button-like (no-href) item selects it, like a native button.
|
|
106
|
+
function onItemKeydown(item: SideItem, e: KeyboardEvent) {
|
|
107
|
+
const result = sidebarItemKey(e.key)
|
|
108
|
+
if (!result) return
|
|
109
|
+
if (result.preventDefault) e.preventDefault()
|
|
110
|
+
onSelect?.(item.id)
|
|
107
111
|
}
|
|
108
112
|
|
|
109
113
|
function selectIfSpa(item: SideItem, e: Event) {
|
|
@@ -145,8 +149,8 @@
|
|
|
145
149
|
type="button"
|
|
146
150
|
class="rail-toggle"
|
|
147
151
|
aria-label="Sidebar"
|
|
148
|
-
|
|
149
|
-
onclick={() => onToggleCollapsed?.(
|
|
152
|
+
{...sidebarToggleAttrs(collapsed)}
|
|
153
|
+
onclick={() => onToggleCollapsed?.(sidebarCollapsePress(collapsed))}
|
|
150
154
|
>
|
|
151
155
|
<Icon name="arrow" px={13} />
|
|
152
156
|
</button>
|
|
@@ -164,15 +168,14 @@
|
|
|
164
168
|
<button
|
|
165
169
|
type="button"
|
|
166
170
|
class="item disclosure {hasActiveDescendant(item) ? 'active' : ''}"
|
|
167
|
-
|
|
168
|
-
aria-
|
|
169
|
-
|
|
170
|
-
title={collapsed ? accessibleName(item) : undefined}
|
|
171
|
+
{...sidebarDisclosureAttrs(open, panelId)}
|
|
172
|
+
aria-label={collapsed ? sidebarItemName(item) : undefined}
|
|
173
|
+
title={collapsed ? sidebarItemName(item) : undefined}
|
|
171
174
|
onclick={() => toggleOpen(item)}
|
|
172
175
|
>
|
|
173
176
|
{#if item.icon}<Icon name={item.icon} px={13} />{/if}
|
|
174
177
|
<span class="label">{item.label}</span>
|
|
175
|
-
{#if item.badge
|
|
178
|
+
{#if sidebarHasBadge(item.badge)}
|
|
176
179
|
<span class="badge">{item.badge}</span>
|
|
177
180
|
{/if}
|
|
178
181
|
{@render statusDot(item.status)}
|
|
@@ -187,9 +190,7 @@
|
|
|
187
190
|
href={child.href}
|
|
188
191
|
target={child.external ? '_blank' : undefined}
|
|
189
192
|
rel={child.external ? 'noopener noreferrer' : undefined}
|
|
190
|
-
|
|
191
|
-
aria-label={collapsed ? accessibleName(child) : undefined}
|
|
192
|
-
title={collapsed ? accessibleName(child) : undefined}
|
|
193
|
+
{...sidebarItemAttrs(child, active, collapsed)}
|
|
193
194
|
onclick={(e) => selectIfSpa(child, e)}
|
|
194
195
|
>
|
|
195
196
|
{#if child.icon}<Icon name={child.icon} px={13} />{/if}
|
|
@@ -198,7 +199,7 @@
|
|
|
198
199
|
<span class="ext" aria-hidden="true"><Icon name="external" px={11} /></span>
|
|
199
200
|
<span class="sr-only">(opens in a new tab)</span>
|
|
200
201
|
{/if}
|
|
201
|
-
{#if child.badge
|
|
202
|
+
{#if sidebarHasBadge(child.badge)}
|
|
202
203
|
<span class="badge">{child.badge}</span>
|
|
203
204
|
{/if}
|
|
204
205
|
{@render statusDot(child.status)}
|
|
@@ -208,20 +209,13 @@
|
|
|
208
209
|
class="item child {isActive(child) ? 'active' : ''}"
|
|
209
210
|
role="button"
|
|
210
211
|
tabindex="0"
|
|
211
|
-
|
|
212
|
-
aria-label={collapsed ? accessibleName(child) : undefined}
|
|
213
|
-
title={collapsed ? accessibleName(child) : undefined}
|
|
212
|
+
{...sidebarItemAttrs(child, active, collapsed)}
|
|
214
213
|
onclick={() => onSelect?.(child.id)}
|
|
215
|
-
onkeydown={(e) =>
|
|
216
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
217
|
-
e.preventDefault()
|
|
218
|
-
onSelect?.(child.id)
|
|
219
|
-
}
|
|
220
|
-
}}
|
|
214
|
+
onkeydown={(e) => onItemKeydown(child, e)}
|
|
221
215
|
>
|
|
222
216
|
{#if child.icon}<Icon name={child.icon} px={13} />{/if}
|
|
223
217
|
<span class="label">{child.label}</span>
|
|
224
|
-
{#if child.badge
|
|
218
|
+
{#if sidebarHasBadge(child.badge)}
|
|
225
219
|
<span class="badge">{child.badge}</span>
|
|
226
220
|
{/if}
|
|
227
221
|
{@render statusDot(child.status)}
|
|
@@ -236,9 +230,7 @@
|
|
|
236
230
|
href={item.href}
|
|
237
231
|
target={item.external ? '_blank' : undefined}
|
|
238
232
|
rel={item.external ? 'noopener noreferrer' : undefined}
|
|
239
|
-
|
|
240
|
-
aria-label={collapsed ? accessibleName(item) : undefined}
|
|
241
|
-
title={collapsed ? accessibleName(item) : undefined}
|
|
233
|
+
{...sidebarItemAttrs(item, active, collapsed)}
|
|
242
234
|
onclick={(e) => selectIfSpa(item, e)}
|
|
243
235
|
>
|
|
244
236
|
{#if item.icon}<Icon name={item.icon} px={13} />{/if}
|
|
@@ -247,7 +239,7 @@
|
|
|
247
239
|
<span class="ext" aria-hidden="true"><Icon name="external" px={11} /></span>
|
|
248
240
|
<span class="sr-only">(opens in a new tab)</span>
|
|
249
241
|
{/if}
|
|
250
|
-
{#if item.badge
|
|
242
|
+
{#if sidebarHasBadge(item.badge)}
|
|
251
243
|
<span class="badge">{item.badge}</span>
|
|
252
244
|
{/if}
|
|
253
245
|
{@render statusDot(item.status)}
|
|
@@ -257,20 +249,13 @@
|
|
|
257
249
|
class="item {isActive(item) ? 'active' : ''}"
|
|
258
250
|
role="button"
|
|
259
251
|
tabindex="0"
|
|
260
|
-
|
|
261
|
-
aria-label={collapsed ? accessibleName(item) : undefined}
|
|
262
|
-
title={collapsed ? accessibleName(item) : undefined}
|
|
252
|
+
{...sidebarItemAttrs(item, active, collapsed)}
|
|
263
253
|
onclick={() => onSelect?.(item.id)}
|
|
264
|
-
onkeydown={(e) =>
|
|
265
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
266
|
-
e.preventDefault()
|
|
267
|
-
onSelect?.(item.id)
|
|
268
|
-
}
|
|
269
|
-
}}
|
|
254
|
+
onkeydown={(e) => onItemKeydown(item, e)}
|
|
270
255
|
>
|
|
271
256
|
{#if item.icon}<Icon name={item.icon} px={13} />{/if}
|
|
272
257
|
<span class="label">{item.label}</span>
|
|
273
|
-
{#if item.badge
|
|
258
|
+
{#if sidebarHasBadge(item.badge)}
|
|
274
259
|
<span class="badge">{item.badge}</span>
|
|
275
260
|
{/if}
|
|
276
261
|
{@render statusDot(item.status)}
|
|
@@ -330,6 +315,9 @@
|
|
|
330
315
|
.ss-side .sublist {
|
|
331
316
|
padding-inline-start: var(--ss-s-3);
|
|
332
317
|
}
|
|
318
|
+
.ss-side .sublist[hidden] {
|
|
319
|
+
display: none;
|
|
320
|
+
}
|
|
333
321
|
.ss-side .row {
|
|
334
322
|
display: block;
|
|
335
323
|
}
|
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
// `label` (clicking it toggles too), size-token density.
|
|
9
9
|
// ─────────────────────────────────────────────────────────────────────────
|
|
10
10
|
import { resolveComponentSize, type Size } from '../config.js'
|
|
11
|
+
import {
|
|
12
|
+
switchToggle,
|
|
13
|
+
switchTrackAttrs,
|
|
14
|
+
type SwitchChangeDetails,
|
|
15
|
+
type SwitchReason,
|
|
16
|
+
} from '../core/switch.js'
|
|
11
17
|
|
|
12
18
|
interface Props {
|
|
13
19
|
/** On/off state (bindable). */
|
|
@@ -29,8 +35,11 @@
|
|
|
29
35
|
size?: Size
|
|
30
36
|
/** Id of an element that further describes the switch (→ aria-describedby). */
|
|
31
37
|
describedby?: string
|
|
32
|
-
/**
|
|
33
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Fired after `checked` flips, with the new value and what flipped it
|
|
40
|
+
* (`details.reason`: track · label).
|
|
41
|
+
*/
|
|
42
|
+
onchange?: (checked: boolean, details: SwitchChangeDetails) => void
|
|
34
43
|
}
|
|
35
44
|
|
|
36
45
|
let {
|
|
@@ -52,10 +61,12 @@
|
|
|
52
61
|
const buttonId = $derived(id ?? uid)
|
|
53
62
|
const labelId = $derived(`${buttonId}-label`)
|
|
54
63
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
// The decision lives in `core/switch.ts` (shared with vanilla/switch.ts).
|
|
65
|
+
function toggle(reason: SwitchReason) {
|
|
66
|
+
const next = switchToggle({ checked, disabled })
|
|
67
|
+
if (next === null) return
|
|
68
|
+
checked = next
|
|
69
|
+
onchange?.(next, { reason })
|
|
59
70
|
}
|
|
60
71
|
|
|
61
72
|
const sizeAttr = $derived(resolveComponentSize('Switch', size))
|
|
@@ -69,15 +80,14 @@
|
|
|
69
80
|
<button
|
|
70
81
|
id={buttonId}
|
|
71
82
|
type="button"
|
|
72
|
-
|
|
83
|
+
{...switchTrackAttrs(checked)}
|
|
73
84
|
class="track"
|
|
74
85
|
class:on={checked}
|
|
75
|
-
aria-checked={checked}
|
|
76
86
|
aria-labelledby={label != null ? labelId : undefined}
|
|
77
87
|
aria-describedby={describedby}
|
|
78
88
|
data-name={name}
|
|
79
89
|
{disabled}
|
|
80
|
-
onclick={toggle}
|
|
90
|
+
onclick={() => toggle('track')}
|
|
81
91
|
>
|
|
82
92
|
<span class="thumb" aria-hidden="true"></span>
|
|
83
93
|
</button>
|
|
@@ -87,7 +97,7 @@
|
|
|
87
97
|
id={labelId}
|
|
88
98
|
class="label"
|
|
89
99
|
class:sr-only={labelHidden}
|
|
90
|
-
onclick={toggle}
|
|
100
|
+
onclick={() => toggle('label')}
|
|
91
101
|
role="presentation">{label}</span
|
|
92
102
|
>
|
|
93
103
|
{/if}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Size } from '../config.js';
|
|
2
|
+
import { type SwitchChangeDetails } from '../core/switch.js';
|
|
2
3
|
interface Props {
|
|
3
4
|
/** On/off state (bindable). */
|
|
4
5
|
checked?: boolean;
|
|
@@ -19,8 +20,11 @@ interface Props {
|
|
|
19
20
|
size?: Size;
|
|
20
21
|
/** Id of an element that further describes the switch (→ aria-describedby). */
|
|
21
22
|
describedby?: string;
|
|
22
|
-
/**
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Fired after `checked` flips, with the new value and what flipped it
|
|
25
|
+
* (`details.reason`: track · label).
|
|
26
|
+
*/
|
|
27
|
+
onchange?: (checked: boolean, details: SwitchChangeDetails) => void;
|
|
24
28
|
}
|
|
25
29
|
declare const Switch: import("svelte").Component<Props, {}, "checked">;
|
|
26
30
|
type Switch = ReturnType<typeof Switch>;
|
|
@@ -41,6 +41,13 @@
|
|
|
41
41
|
|
|
42
42
|
<script lang="ts">
|
|
43
43
|
import { resolveComponentSize, type Size } from '../config.js'
|
|
44
|
+
import {
|
|
45
|
+
tableAriaSort,
|
|
46
|
+
tableColumnAlign,
|
|
47
|
+
tableSortIndicator,
|
|
48
|
+
tableSortRows,
|
|
49
|
+
tableToggleSort,
|
|
50
|
+
} from '../core/table.js'
|
|
44
51
|
|
|
45
52
|
interface Props {
|
|
46
53
|
/** Column definitions. */
|
|
@@ -74,33 +81,12 @@
|
|
|
74
81
|
|
|
75
82
|
const resolvedSize = $derived(resolveComponentSize('Table', size))
|
|
76
83
|
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const col = columns.find((c) => c.key === sort!.key)
|
|
81
|
-
if (!col) return rows
|
|
82
|
-
const dir = sort.dir === 'desc' ? -1 : 1
|
|
83
|
-
const copy = [...rows]
|
|
84
|
-
copy.sort((a, b) => {
|
|
85
|
-
const av = a?.[sort!.key]
|
|
86
|
-
const bv = b?.[sort!.key]
|
|
87
|
-
if (col.numeric) return (Number(av) - Number(bv)) * dir
|
|
88
|
-
return String(av ?? '').localeCompare(String(bv ?? '')) * dir
|
|
89
|
-
})
|
|
90
|
-
return copy
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
function ariaSort(key: string): 'ascending' | 'descending' | 'none' {
|
|
94
|
-
if (!sort || sort.key !== key) return 'none'
|
|
95
|
-
return sort.dir === 'asc' ? 'ascending' : 'descending'
|
|
96
|
-
}
|
|
84
|
+
// Sorting lives in `core/table.ts`: what a header press does, the row order and the
|
|
85
|
+
// attributes that reflect the sort. This file holds the bound `sort` and applies the result.
|
|
86
|
+
const sortedRows = $derived(tableSortRows(rows, columns, sort))
|
|
97
87
|
|
|
98
88
|
function toggleSort(key: string) {
|
|
99
|
-
|
|
100
|
-
const next: TableSort =
|
|
101
|
-
sort && sort.key === key
|
|
102
|
-
? { key, dir: sort.dir === 'asc' ? 'desc' : 'asc' }
|
|
103
|
-
: { key, dir: 'asc' }
|
|
89
|
+
const next = tableToggleSort(sort, key)
|
|
104
90
|
sort = next
|
|
105
91
|
onsort?.(next)
|
|
106
92
|
}
|
|
@@ -110,14 +96,6 @@
|
|
|
110
96
|
return col.format ? col.format(value, row) : String(value ?? '')
|
|
111
97
|
}
|
|
112
98
|
|
|
113
|
-
// Logical alignment: legacy `left`/`right` map to `start`/`end` so RTL mirrors.
|
|
114
|
-
function colAlign(col: TableColumn): 'start' | 'end' | 'center' {
|
|
115
|
-
const a = col.align ?? (col.numeric ? 'end' : 'start')
|
|
116
|
-
if (a === 'left') return 'start'
|
|
117
|
-
if (a === 'right') return 'end'
|
|
118
|
-
return a
|
|
119
|
-
}
|
|
120
|
-
|
|
121
99
|
const isEmpty = $derived(rows.length === 0)
|
|
122
100
|
</script>
|
|
123
101
|
|
|
@@ -130,14 +108,14 @@
|
|
|
130
108
|
scope="col"
|
|
131
109
|
class="head"
|
|
132
110
|
class:numeric={col.numeric}
|
|
133
|
-
data-align={
|
|
134
|
-
aria-sort={col.sortable ?
|
|
111
|
+
data-align={tableColumnAlign(col)}
|
|
112
|
+
aria-sort={col.sortable ? tableAriaSort(sort, col.key) : undefined}
|
|
135
113
|
>
|
|
136
114
|
{#if col.sortable}
|
|
137
115
|
<button type="button" class="sort" onclick={() => toggleSort(col.key)}>
|
|
138
116
|
<span class="label">{col.label}</span>
|
|
139
117
|
<span class="indicator" aria-hidden="true">
|
|
140
|
-
{
|
|
118
|
+
{tableSortIndicator(sort, col.key)}
|
|
141
119
|
</span>
|
|
142
120
|
</button>
|
|
143
121
|
{:else}
|
|
@@ -158,7 +136,7 @@
|
|
|
158
136
|
{#each sortedRows as row, i (getRowKey ? getRowKey(row, i) : i)}
|
|
159
137
|
<tr class="row">
|
|
160
138
|
{#each columns as col (col.key)}
|
|
161
|
-
<td class="cell" class:numeric={col.numeric} data-align={
|
|
139
|
+
<td class="cell" class:numeric={col.numeric} data-align={tableColumnAlign(col)}>
|
|
162
140
|
{#if col.cell}{@render col.cell(row)}{:else}{display(col, row)}{/if}
|
|
163
141
|
</td>
|
|
164
142
|
{/each}
|