dssoca 0.11.0 → 0.13.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/dist/components/Accordion.svelte +35 -15
- package/dist/components/Accordion.svelte.d.ts +7 -0
- package/dist/components/Avatar.svelte +5 -9
- package/dist/components/Badge.svelte +27 -53
- package/dist/components/Badge.svelte.d.ts +2 -5
- package/dist/components/BottomNav.svelte +2 -2
- package/dist/components/BoxPlot.svelte +2 -8
- package/dist/components/BumpChart.svelte +2 -8
- package/dist/components/Button.svelte +50 -34
- package/dist/components/Button.svelte.d.ts +8 -2
- package/dist/components/Chart.svelte +2 -8
- package/dist/components/DateField.svelte +1 -1
- package/dist/components/FileDrop.svelte +1 -1
- package/dist/components/Icon.svelte +29 -7
- package/dist/components/Icon.svelte.d.ts +14 -2
- package/dist/components/Input.svelte +1 -1
- package/dist/components/Kbd.svelte +120 -0
- package/dist/components/Kbd.svelte.d.ts +30 -0
- package/dist/components/LogStream.svelte +3 -3
- package/dist/components/Menu.svelte +1 -1
- package/dist/components/NumberField.svelte +1 -1
- package/dist/components/ScatterPlot.svelte +2 -8
- package/dist/components/SearchPalette.svelte +526 -0
- package/dist/components/SearchPalette.svelte.d.ts +82 -0
- package/dist/components/Select.svelte +1 -1
- package/dist/components/ServiceCard.svelte +13 -2
- package/dist/components/ShortcutsHelp.svelte +365 -0
- package/dist/components/ShortcutsHelp.svelte.d.ts +34 -0
- package/dist/components/Sidebar.svelte +1 -1
- package/dist/components/Spinner.svelte +26 -19
- package/dist/components/Spinner.svelte.d.ts +14 -4
- package/dist/components/Switch.svelte +32 -2
- package/dist/components/Switch.svelte.d.ts +5 -0
- package/dist/components/Textarea.svelte +1 -1
- package/dist/components/Topbar.svelte +41 -26
- package/dist/components/Topbar.svelte.d.ts +5 -2
- package/dist/config.d.ts +44 -3
- package/dist/config.js +52 -3
- package/dist/dssoca.config.d.ts +39 -2
- package/dist/dssoca.config.js +49 -0
- package/dist/index.d.ts +10 -5
- package/dist/index.js +11 -4
- package/dist/palette.d.ts +10 -0
- package/dist/palette.js +17 -0
- package/dist/shortcuts.svelte.d.ts +192 -0
- package/dist/shortcuts.svelte.js +633 -0
- package/dist/theme.css +158 -158
- package/dist/tokens.css +158 -158
- package/package.json +4 -3
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export interface SearchPaletteItem {
|
|
3
|
+
/** Stable unique id (keys the option and its DOM id). */
|
|
4
|
+
id: string
|
|
5
|
+
/** Primary text; also the default filter haystack. */
|
|
6
|
+
label: string
|
|
7
|
+
/** Secondary muted line under the label (default row rendering). */
|
|
8
|
+
hint?: string
|
|
9
|
+
/** When set, the option renders as a real <a>; Enter clicks it so routing stays native. */
|
|
10
|
+
href?: string
|
|
11
|
+
/** Group heading; groups render in first-appearance order, ungrouped items first. */
|
|
12
|
+
group?: string
|
|
13
|
+
/** Extra strings matched by the internal filter. */
|
|
14
|
+
keywords?: string[]
|
|
15
|
+
/** Rendered but not selectable; skipped by keyboard navigation. */
|
|
16
|
+
disabled?: boolean
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script lang="ts" generics="T extends SearchPaletteItem">
|
|
21
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
22
|
+
// SearchPalette (DS-0133). A Cmd/Ctrl+K search palette: modal combobox over
|
|
23
|
+
// a grouped listbox, generalized from passoca's app implementation.
|
|
24
|
+
//
|
|
25
|
+
// Built on the native <dialog> like Modal (DS-0094): showModal() gives us
|
|
26
|
+
// the focus trap, Esc-to-close (cancel → close), ::backdrop and top layer.
|
|
27
|
+
// Focus stays on the input the whole time (APG combobox pattern): options
|
|
28
|
+
// are referenced via aria-activedescendant, never DOM-focused.
|
|
29
|
+
//
|
|
30
|
+
// Enter on an item with `href` clicks the actually-rendered <a> instead of
|
|
31
|
+
// synthesizing navigation, so SvelteKit (or any router) intercepts it the
|
|
32
|
+
// same way as a pointer click.
|
|
33
|
+
//
|
|
34
|
+
// Component metrics are inline var(--ss-search-palette-*, fallback) so no
|
|
35
|
+
// global SCSS is touched (DS-0094 pattern).
|
|
36
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
37
|
+
import { tick, type Snippet } from 'svelte'
|
|
38
|
+
import { resolveComponentSize, type Size } from '../config.js'
|
|
39
|
+
import { shortcuts } from '../shortcuts.svelte.js'
|
|
40
|
+
|
|
41
|
+
interface Props {
|
|
42
|
+
/** Whether the palette is shown. Bindable — sync it from caller state. */
|
|
43
|
+
open?: boolean
|
|
44
|
+
/** Entries to show. With external filtering, pass the already-filtered list. */
|
|
45
|
+
items: T[]
|
|
46
|
+
/** Search text. Bindable — bind it when you own filtering (`filter={false}`). */
|
|
47
|
+
query?: string
|
|
48
|
+
/** Internal substring filter over label+keywords. Set false when the consumer filters. @default true */
|
|
49
|
+
filter?: boolean
|
|
50
|
+
/** Global toggle shortcut, registered through the shortcut registry as
|
|
51
|
+
* `ss:search-palette` (DS-0139) — listed in ShortcutsHelp, obeys
|
|
52
|
+
* `setEnabled`/`remap`. 'mod+k' = Cmd+K on mac, Ctrl+K elsewhere
|
|
53
|
+
* (platform modifier only); false disables. @default 'mod+k' */
|
|
54
|
+
shortcut?: 'mod+k' | false
|
|
55
|
+
/** Input placeholder. @default 'Search…' */
|
|
56
|
+
placeholder?: string
|
|
57
|
+
/** Accessible name for the dialog, input and listbox. @default 'Search' */
|
|
58
|
+
'aria-label'?: string
|
|
59
|
+
/** No-results text (used when the `empty` snippet is absent). @default 'No results' */
|
|
60
|
+
emptyText?: string
|
|
61
|
+
/** Footer hint row; false hides it. A `footer` snippet replaces it. @default '↑↓ navigate · ↵ open · esc close' */
|
|
62
|
+
footerText?: string | false
|
|
63
|
+
/** Clear the query and selection when the palette closes. @default true */
|
|
64
|
+
resetOnClose?: boolean
|
|
65
|
+
/** Token size (sm|md|lg); controls the panel width. Inherits the global size when unset. */
|
|
66
|
+
size?: Size
|
|
67
|
+
/** Called with the chosen item on Enter/click. Return false to keep the palette open. */
|
|
68
|
+
onselect?: (item: T) => void | boolean
|
|
69
|
+
/** Called after the palette opens. */
|
|
70
|
+
onopen?: () => void
|
|
71
|
+
/** Called after the palette closes (Esc, backdrop, selection). */
|
|
72
|
+
onclose?: () => void
|
|
73
|
+
/** Replaces the default option row body (label + hint). */
|
|
74
|
+
item?: Snippet<[T, { active: boolean }]>
|
|
75
|
+
/** Replaces the default no-results state; receives the current query. */
|
|
76
|
+
empty?: Snippet<[string]>
|
|
77
|
+
/** Replaces the footer text row. */
|
|
78
|
+
footer?: Snippet
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let {
|
|
82
|
+
open = $bindable(false),
|
|
83
|
+
items,
|
|
84
|
+
query = $bindable(''),
|
|
85
|
+
filter = true,
|
|
86
|
+
shortcut = 'mod+k',
|
|
87
|
+
placeholder = 'Search…',
|
|
88
|
+
'aria-label': ariaLabel = 'Search',
|
|
89
|
+
emptyText = 'No results',
|
|
90
|
+
footerText = '↑↓ navigate · ↵ open · esc close',
|
|
91
|
+
resetOnClose = true,
|
|
92
|
+
size,
|
|
93
|
+
onselect,
|
|
94
|
+
onopen,
|
|
95
|
+
onclose,
|
|
96
|
+
item: itemSnippet,
|
|
97
|
+
empty,
|
|
98
|
+
footer,
|
|
99
|
+
}: Props = $props()
|
|
100
|
+
|
|
101
|
+
let dialog = $state<HTMLDialogElement | null>(null)
|
|
102
|
+
let input = $state<HTMLInputElement | null>(null)
|
|
103
|
+
let list = $state<HTMLElement | null>(null)
|
|
104
|
+
let active = $state(0)
|
|
105
|
+
|
|
106
|
+
const uid = $props.id()
|
|
107
|
+
const listId = `${uid}-listbox`
|
|
108
|
+
const optionId = (index: number) => `${uid}-option-${index}`
|
|
109
|
+
|
|
110
|
+
// Case- and diacritic-insensitive fold ("São" matches "sao").
|
|
111
|
+
const fold = (s: string) =>
|
|
112
|
+
s
|
|
113
|
+
.normalize('NFD')
|
|
114
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
115
|
+
.toLowerCase()
|
|
116
|
+
|
|
117
|
+
const filtered = $derived.by(() => {
|
|
118
|
+
if (!filter) return items
|
|
119
|
+
const q = fold(query.trim())
|
|
120
|
+
if (!q) return items
|
|
121
|
+
return items.filter((it) => fold([it.label, ...(it.keywords ?? [])].join(' ')).includes(q))
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
// Buckets in first-appearance order, ungrouped (label null) always first;
|
|
125
|
+
// options carry a flat index so keyboard order equals DOM order.
|
|
126
|
+
const groups = $derived.by(() => {
|
|
127
|
+
const buckets: { label: string | null; bucket: T[] }[] = []
|
|
128
|
+
for (const it of filtered) {
|
|
129
|
+
const label = it.group ?? null
|
|
130
|
+
let b = buckets.find((entry) => entry.label === label)
|
|
131
|
+
if (!b) {
|
|
132
|
+
b = { label, bucket: [] }
|
|
133
|
+
buckets.push(b)
|
|
134
|
+
}
|
|
135
|
+
b.bucket.push(it)
|
|
136
|
+
}
|
|
137
|
+
buckets.sort((a, b) => Number(b.label === null) - Number(a.label === null))
|
|
138
|
+
let index = 0
|
|
139
|
+
return buckets.map(({ label, bucket }) => ({
|
|
140
|
+
label,
|
|
141
|
+
entries: bucket.map((entry) => ({ item: entry, index: index++ })),
|
|
142
|
+
}))
|
|
143
|
+
})
|
|
144
|
+
const flat = $derived(groups.flatMap((g) => g.entries.map((e) => e.item)))
|
|
145
|
+
|
|
146
|
+
function firstSelectable(): number {
|
|
147
|
+
const i = flat.findIndex((it) => !it.disabled)
|
|
148
|
+
return i === -1 ? 0 : i
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Keep the active index valid as the list changes (typing, items swapped).
|
|
152
|
+
$effect(() => {
|
|
153
|
+
if (active >= flat.length || flat[active]?.disabled) active = firstSelectable()
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
// Mirror `open` onto the native dialog (same guard dance as Modal), then
|
|
157
|
+
// land focus on the input — the dialog's default focus target is the panel.
|
|
158
|
+
$effect(() => {
|
|
159
|
+
const el = dialog
|
|
160
|
+
if (!el) return
|
|
161
|
+
if (open && !el.open) {
|
|
162
|
+
el.showModal()
|
|
163
|
+
input?.focus()
|
|
164
|
+
onopen?.()
|
|
165
|
+
} else if (!open && el.open) {
|
|
166
|
+
el.close()
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
// Native `close` (Esc, .close()) → sync state, optionally reset, notify.
|
|
171
|
+
function onDialogClose() {
|
|
172
|
+
if (open) open = false
|
|
173
|
+
if (resetOnClose) {
|
|
174
|
+
query = ''
|
|
175
|
+
active = 0
|
|
176
|
+
}
|
|
177
|
+
onclose?.()
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// A pointerdown landing on the <dialog> itself (not the inner panel) is a
|
|
181
|
+
// backdrop hit (Modal's detection).
|
|
182
|
+
function onPointerDown(e: PointerEvent) {
|
|
183
|
+
if (e.target === dialog) open = false
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// DS-0139: the toggle chord goes through the shortcut registry (id
|
|
187
|
+
// `ss:search-palette`) instead of a hand-rolled window listener — listed in
|
|
188
|
+
// ShortcutsHelp, disable/remap-able (WCAG 2.1.4), deterministic on
|
|
189
|
+
// collision. While the palette is open, its own modal <dialog> suppresses
|
|
190
|
+
// global shortcuts (SC 2.1.2), so the binding re-registers focus-scoped on
|
|
191
|
+
// the dialog; same id, so overrides follow both directions of the toggle.
|
|
192
|
+
// `add()` is SSR-safe (no-op without `window`).
|
|
193
|
+
$effect(() => {
|
|
194
|
+
if (shortcut === false) return
|
|
195
|
+
const options = {
|
|
196
|
+
id: 'ss:search-palette',
|
|
197
|
+
label: 'Open search',
|
|
198
|
+
keys: shortcut,
|
|
199
|
+
allowInInputs: true, // chorded — must fire while typing (incl. the palette's own input)
|
|
200
|
+
onPress: () => {
|
|
201
|
+
open = !open
|
|
202
|
+
},
|
|
203
|
+
}
|
|
204
|
+
const el = dialog
|
|
205
|
+
return open && el ? shortcuts.add({ ...options, scope: 'focus' }, el) : shortcuts.add(options)
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
// Step to the next non-disabled option, wrapping; delta 0 re-validates.
|
|
209
|
+
function move(delta: number, from = active) {
|
|
210
|
+
const len = flat.length
|
|
211
|
+
if (!len) return
|
|
212
|
+
let i = from
|
|
213
|
+
for (let step = 0; step < len; step++) {
|
|
214
|
+
i = (i + delta + len) % len
|
|
215
|
+
if (!flat[i].disabled) {
|
|
216
|
+
active = i
|
|
217
|
+
break
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
void tick().then(() =>
|
|
221
|
+
list?.querySelector(`#${CSS.escape(optionId(active))}`)?.scrollIntoView({ block: 'nearest' }),
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function onInputKeydown(e: KeyboardEvent) {
|
|
226
|
+
if (e.isComposing) return
|
|
227
|
+
if (e.key === 'ArrowDown') {
|
|
228
|
+
e.preventDefault()
|
|
229
|
+
move(1)
|
|
230
|
+
} else if (e.key === 'ArrowUp') {
|
|
231
|
+
e.preventDefault()
|
|
232
|
+
move(-1)
|
|
233
|
+
} else if (e.key === 'PageUp') {
|
|
234
|
+
// Home/End stay native (caret editing in the textbox, per APG combobox);
|
|
235
|
+
// PageUp/PageDown jump to the first/last option instead.
|
|
236
|
+
e.preventDefault()
|
|
237
|
+
move(1, -1)
|
|
238
|
+
} else if (e.key === 'PageDown') {
|
|
239
|
+
e.preventDefault()
|
|
240
|
+
move(-1, flat.length)
|
|
241
|
+
} else if (e.key === 'Enter') {
|
|
242
|
+
e.preventDefault()
|
|
243
|
+
const it = flat[active]
|
|
244
|
+
if (!it || it.disabled) return
|
|
245
|
+
// href options: click the real anchor so the router/native semantics
|
|
246
|
+
// apply — its click handler runs choose() for us.
|
|
247
|
+
if (it.href) anchorAt(active)?.click()
|
|
248
|
+
else choose(it)
|
|
249
|
+
} else if (e.key === 'Tab') {
|
|
250
|
+
// Focus stays on the input while the palette is open.
|
|
251
|
+
e.preventDefault()
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function anchorAt(index: number): HTMLAnchorElement | null {
|
|
256
|
+
return list?.querySelector(`#${CSS.escape(optionId(index))}`) as HTMLAnchorElement | null
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Shared select path for clicks and Enter; navigation (when any) has
|
|
260
|
+
// already been dispatched on the anchor itself.
|
|
261
|
+
function choose(it: T) {
|
|
262
|
+
if (it.disabled) return
|
|
263
|
+
const keep = onselect?.(it) === false
|
|
264
|
+
if (!keep) open = false
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Focus must never leave the input (aria-activedescendant pattern):
|
|
268
|
+
// swallow the focusing pointerdown on option rows before it lands.
|
|
269
|
+
function onRowPointerDown(e: PointerEvent) {
|
|
270
|
+
e.preventDefault()
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Reset the selection to the top whenever the query changes; after tick()
|
|
274
|
+
// the derived `flat` reflects the new query regardless of handler order.
|
|
275
|
+
async function onQueryInput() {
|
|
276
|
+
await tick()
|
|
277
|
+
active = firstSelectable()
|
|
278
|
+
}
|
|
279
|
+
</script>
|
|
280
|
+
|
|
281
|
+
<dialog
|
|
282
|
+
bind:this={dialog}
|
|
283
|
+
class="ss-search-palette"
|
|
284
|
+
data-size-variant={resolveComponentSize('SearchPalette', size)}
|
|
285
|
+
aria-label={ariaLabel}
|
|
286
|
+
onclose={onDialogClose}
|
|
287
|
+
onpointerdown={onPointerDown}
|
|
288
|
+
>
|
|
289
|
+
<div class="panel">
|
|
290
|
+
<input
|
|
291
|
+
bind:this={input}
|
|
292
|
+
bind:value={query}
|
|
293
|
+
oninput={onQueryInput}
|
|
294
|
+
onkeydown={onInputKeydown}
|
|
295
|
+
class="input"
|
|
296
|
+
type="text"
|
|
297
|
+
{placeholder}
|
|
298
|
+
spellcheck="false"
|
|
299
|
+
autocomplete="off"
|
|
300
|
+
role="combobox"
|
|
301
|
+
aria-label={ariaLabel}
|
|
302
|
+
aria-autocomplete="list"
|
|
303
|
+
aria-expanded={flat.length > 0}
|
|
304
|
+
aria-controls={listId}
|
|
305
|
+
aria-activedescendant={flat.length ? optionId(active) : undefined}
|
|
306
|
+
/>
|
|
307
|
+
|
|
308
|
+
<div class="results" bind:this={list}>
|
|
309
|
+
{#if flat.length === 0}
|
|
310
|
+
{#if empty}
|
|
311
|
+
{@render empty(query)}
|
|
312
|
+
{:else}
|
|
313
|
+
<p class="state">{emptyText}</p>
|
|
314
|
+
{/if}
|
|
315
|
+
{:else}
|
|
316
|
+
<ul id={listId} class="listbox" role="listbox" aria-label={ariaLabel}>
|
|
317
|
+
{#each groups as group (group.label)}
|
|
318
|
+
<li
|
|
319
|
+
class="group"
|
|
320
|
+
role={group.label ? 'group' : 'presentation'}
|
|
321
|
+
aria-label={group.label ?? undefined}
|
|
322
|
+
>
|
|
323
|
+
{#if group.label}
|
|
324
|
+
<span class="group-label" aria-hidden="true">{group.label}</span>
|
|
325
|
+
{/if}
|
|
326
|
+
<ul role="presentation">
|
|
327
|
+
{#each group.entries as { item: it, index } (it.id)}
|
|
328
|
+
<li role="presentation">
|
|
329
|
+
{#if it.href && !it.disabled}
|
|
330
|
+
<a
|
|
331
|
+
id={optionId(index)}
|
|
332
|
+
role="option"
|
|
333
|
+
aria-selected={index === active}
|
|
334
|
+
class="row"
|
|
335
|
+
class:active={index === active}
|
|
336
|
+
href={it.href}
|
|
337
|
+
tabindex="-1"
|
|
338
|
+
onpointerdown={onRowPointerDown}
|
|
339
|
+
onmousemove={() => (active = index)}
|
|
340
|
+
onclick={() => choose(it)}
|
|
341
|
+
>
|
|
342
|
+
{@render body(it, index)}
|
|
343
|
+
</a>
|
|
344
|
+
{:else}
|
|
345
|
+
<button
|
|
346
|
+
id={optionId(index)}
|
|
347
|
+
type="button"
|
|
348
|
+
role="option"
|
|
349
|
+
aria-selected={index === active}
|
|
350
|
+
aria-disabled={it.disabled || undefined}
|
|
351
|
+
class="row"
|
|
352
|
+
class:active={index === active}
|
|
353
|
+
class:disabled={it.disabled}
|
|
354
|
+
tabindex="-1"
|
|
355
|
+
onpointerdown={onRowPointerDown}
|
|
356
|
+
onmousemove={() => {
|
|
357
|
+
if (!it.disabled) active = index
|
|
358
|
+
}}
|
|
359
|
+
onclick={() => choose(it)}
|
|
360
|
+
>
|
|
361
|
+
{@render body(it, index)}
|
|
362
|
+
</button>
|
|
363
|
+
{/if}
|
|
364
|
+
</li>
|
|
365
|
+
{/each}
|
|
366
|
+
</ul>
|
|
367
|
+
</li>
|
|
368
|
+
{/each}
|
|
369
|
+
</ul>
|
|
370
|
+
{/if}
|
|
371
|
+
</div>
|
|
372
|
+
|
|
373
|
+
{#if footer}
|
|
374
|
+
<footer class="foot">{@render footer()}</footer>
|
|
375
|
+
{:else if footerText !== false && footerText !== ''}
|
|
376
|
+
<footer class="foot">{footerText}</footer>
|
|
377
|
+
{/if}
|
|
378
|
+
</div>
|
|
379
|
+
</dialog>
|
|
380
|
+
|
|
381
|
+
{#snippet body(it: T, index: number)}
|
|
382
|
+
{#if itemSnippet}
|
|
383
|
+
{@render itemSnippet(it, { active: index === active })}
|
|
384
|
+
{:else}
|
|
385
|
+
<span class="label">{it.label}</span>
|
|
386
|
+
{#if it.hint}
|
|
387
|
+
<span class="hint">{it.hint}</span>
|
|
388
|
+
{/if}
|
|
389
|
+
{/if}
|
|
390
|
+
{/snippet}
|
|
391
|
+
|
|
392
|
+
<style>.ss-search-palette {
|
|
393
|
+
padding: 0;
|
|
394
|
+
border: 1px solid var(--ss-line-strong);
|
|
395
|
+
background: var(--ss-bg-elev);
|
|
396
|
+
color: var(--ss-fg);
|
|
397
|
+
box-shadow: var(--ss-shadow-pop);
|
|
398
|
+
font-family: var(--ss-font-mono);
|
|
399
|
+
width: var(--ss-search-palette-w, 40rem);
|
|
400
|
+
max-width: var(--ss-search-palette-max, calc(100vw - var(--ss-s-8)));
|
|
401
|
+
margin: var(--ss-search-palette-top, 15vh) auto auto;
|
|
402
|
+
overflow: hidden;
|
|
403
|
+
}
|
|
404
|
+
.ss-search-palette::backdrop {
|
|
405
|
+
background: var(--ss-search-palette-backdrop, rgba(0, 0, 0, 0.62));
|
|
406
|
+
}
|
|
407
|
+
.ss-search-palette[data-size-variant=sm] {
|
|
408
|
+
--ss-search-palette-w: 32rem;
|
|
409
|
+
}
|
|
410
|
+
.ss-search-palette[data-size-variant=lg] {
|
|
411
|
+
--ss-search-palette-w: 48rem;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.panel {
|
|
415
|
+
display: flex;
|
|
416
|
+
flex-direction: column;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.input {
|
|
420
|
+
width: 100%;
|
|
421
|
+
padding: var(--ss-search-palette-input-pad, var(--ss-s-4)) var(--ss-s-4);
|
|
422
|
+
background: transparent;
|
|
423
|
+
border: none;
|
|
424
|
+
border-bottom: 1px solid var(--ss-line);
|
|
425
|
+
color: var(--ss-fg);
|
|
426
|
+
font-family: inherit;
|
|
427
|
+
font-size: var(--ss-search-palette-input-size, var(--ss-ui-lg, var(--ss-size-body)));
|
|
428
|
+
}
|
|
429
|
+
.input:focus {
|
|
430
|
+
outline: none;
|
|
431
|
+
border-bottom-color: var(--ss-primary);
|
|
432
|
+
}
|
|
433
|
+
.input::placeholder {
|
|
434
|
+
color: var(--ss-fg-muted);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.results {
|
|
438
|
+
overflow-y: auto;
|
|
439
|
+
max-height: var(--ss-search-palette-list-h, 60vh);
|
|
440
|
+
overscroll-behavior: contain;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
ul {
|
|
444
|
+
list-style: none;
|
|
445
|
+
margin: 0;
|
|
446
|
+
padding: 0;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
.state {
|
|
450
|
+
margin: 0;
|
|
451
|
+
padding: var(--ss-s-4);
|
|
452
|
+
font-size: var(--ss-ui-sm);
|
|
453
|
+
color: var(--ss-fg-muted);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.group-label {
|
|
457
|
+
display: block;
|
|
458
|
+
padding: var(--ss-s-3) var(--ss-s-4) var(--ss-s-1);
|
|
459
|
+
font-size: var(--ss-ui-xs);
|
|
460
|
+
text-transform: uppercase;
|
|
461
|
+
letter-spacing: 0.08em;
|
|
462
|
+
color: var(--ss-fg-muted);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
.row {
|
|
466
|
+
display: block;
|
|
467
|
+
width: 100%;
|
|
468
|
+
padding: var(--ss-s-2) var(--ss-s-4);
|
|
469
|
+
border: none;
|
|
470
|
+
border-left: 2px solid transparent;
|
|
471
|
+
padding-left: calc(var(--ss-s-4) - 2px);
|
|
472
|
+
background: transparent;
|
|
473
|
+
color: var(--ss-fg);
|
|
474
|
+
font-family: inherit;
|
|
475
|
+
text-align: left;
|
|
476
|
+
text-decoration: none;
|
|
477
|
+
cursor: pointer;
|
|
478
|
+
}
|
|
479
|
+
.row.active {
|
|
480
|
+
background: var(--ss-primary-soft);
|
|
481
|
+
border-left-color: var(--ss-primary);
|
|
482
|
+
}
|
|
483
|
+
.row.disabled {
|
|
484
|
+
color: var(--ss-fg-faint, var(--ss-fg-muted));
|
|
485
|
+
cursor: default;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
.label {
|
|
489
|
+
display: block;
|
|
490
|
+
font-size: var(--ss-ui-md);
|
|
491
|
+
line-height: var(--ss-leading, 1.5);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
.hint {
|
|
495
|
+
display: block;
|
|
496
|
+
margin-top: 2px;
|
|
497
|
+
font-size: var(--ss-ui-sm);
|
|
498
|
+
color: var(--ss-fg-muted);
|
|
499
|
+
white-space: nowrap;
|
|
500
|
+
overflow: hidden;
|
|
501
|
+
text-overflow: ellipsis;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
.foot {
|
|
505
|
+
padding: var(--ss-s-2) var(--ss-s-4);
|
|
506
|
+
border-top: 1px solid var(--ss-line);
|
|
507
|
+
font-size: var(--ss-ui-xs);
|
|
508
|
+
color: var(--ss-fg-muted);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
@media (max-width: 767px) {
|
|
512
|
+
.ss-search-palette {
|
|
513
|
+
margin: 0;
|
|
514
|
+
width: 100vw;
|
|
515
|
+
max-width: 100vw;
|
|
516
|
+
height: 100dvh;
|
|
517
|
+
max-height: 100dvh;
|
|
518
|
+
}
|
|
519
|
+
.panel {
|
|
520
|
+
height: 100%;
|
|
521
|
+
}
|
|
522
|
+
.results {
|
|
523
|
+
flex: 1;
|
|
524
|
+
max-height: none;
|
|
525
|
+
}
|
|
526
|
+
}</style>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export interface SearchPaletteItem {
|
|
2
|
+
/** Stable unique id (keys the option and its DOM id). */
|
|
3
|
+
id: string;
|
|
4
|
+
/** Primary text; also the default filter haystack. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Secondary muted line under the label (default row rendering). */
|
|
7
|
+
hint?: string;
|
|
8
|
+
/** When set, the option renders as a real <a>; Enter clicks it so routing stays native. */
|
|
9
|
+
href?: string;
|
|
10
|
+
/** Group heading; groups render in first-appearance order, ungrouped items first. */
|
|
11
|
+
group?: string;
|
|
12
|
+
/** Extra strings matched by the internal filter. */
|
|
13
|
+
keywords?: string[];
|
|
14
|
+
/** Rendered but not selectable; skipped by keyboard navigation. */
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
}
|
|
17
|
+
import { type Snippet } from 'svelte';
|
|
18
|
+
import { type Size } from '../config.js';
|
|
19
|
+
declare function $$render<T extends SearchPaletteItem>(): {
|
|
20
|
+
props: {
|
|
21
|
+
/** Whether the palette is shown. Bindable — sync it from caller state. */
|
|
22
|
+
open?: boolean;
|
|
23
|
+
/** Entries to show. With external filtering, pass the already-filtered list. */
|
|
24
|
+
items: T[];
|
|
25
|
+
/** Search text. Bindable — bind it when you own filtering (`filter={false}`). */
|
|
26
|
+
query?: string;
|
|
27
|
+
/** Internal substring filter over label+keywords. Set false when the consumer filters. @default true */
|
|
28
|
+
filter?: boolean;
|
|
29
|
+
/** Global toggle shortcut, registered through the shortcut registry as
|
|
30
|
+
* `ss:search-palette` (DS-0139) — listed in ShortcutsHelp, obeys
|
|
31
|
+
* `setEnabled`/`remap`. 'mod+k' = Cmd+K on mac, Ctrl+K elsewhere
|
|
32
|
+
* (platform modifier only); false disables. @default 'mod+k' */
|
|
33
|
+
shortcut?: "mod+k" | false;
|
|
34
|
+
/** Input placeholder. @default 'Search…' */
|
|
35
|
+
placeholder?: string;
|
|
36
|
+
/** Accessible name for the dialog, input and listbox. @default 'Search' */
|
|
37
|
+
'aria-label'?: string;
|
|
38
|
+
/** No-results text (used when the `empty` snippet is absent). @default 'No results' */
|
|
39
|
+
emptyText?: string;
|
|
40
|
+
/** Footer hint row; false hides it. A `footer` snippet replaces it. @default '↑↓ navigate · ↵ open · esc close' */
|
|
41
|
+
footerText?: string | false;
|
|
42
|
+
/** Clear the query and selection when the palette closes. @default true */
|
|
43
|
+
resetOnClose?: boolean;
|
|
44
|
+
/** Token size (sm|md|lg); controls the panel width. Inherits the global size when unset. */
|
|
45
|
+
size?: Size;
|
|
46
|
+
/** Called with the chosen item on Enter/click. Return false to keep the palette open. */
|
|
47
|
+
onselect?: (item: T) => void | boolean;
|
|
48
|
+
/** Called after the palette opens. */
|
|
49
|
+
onopen?: () => void;
|
|
50
|
+
/** Called after the palette closes (Esc, backdrop, selection). */
|
|
51
|
+
onclose?: () => void;
|
|
52
|
+
/** Replaces the default option row body (label + hint). */
|
|
53
|
+
item?: Snippet<[T, {
|
|
54
|
+
active: boolean;
|
|
55
|
+
}]>;
|
|
56
|
+
/** Replaces the default no-results state; receives the current query. */
|
|
57
|
+
empty?: Snippet<[string]>;
|
|
58
|
+
/** Replaces the footer text row. */
|
|
59
|
+
footer?: Snippet;
|
|
60
|
+
};
|
|
61
|
+
exports: {};
|
|
62
|
+
bindings: "open" | "query";
|
|
63
|
+
slots: {};
|
|
64
|
+
events: {};
|
|
65
|
+
};
|
|
66
|
+
declare class __sveltets_Render<T extends SearchPaletteItem> {
|
|
67
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
68
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
69
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
70
|
+
bindings(): "open" | "query";
|
|
71
|
+
exports(): {};
|
|
72
|
+
}
|
|
73
|
+
interface $$IsomorphicComponent {
|
|
74
|
+
new <T extends SearchPaletteItem>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
75
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
76
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
77
|
+
<T extends SearchPaletteItem>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
78
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
79
|
+
}
|
|
80
|
+
declare const SearchPalette: $$IsomorphicComponent;
|
|
81
|
+
type SearchPalette<T extends SearchPaletteItem> = InstanceType<typeof SearchPalette<T>>;
|
|
82
|
+
export default SearchPalette;
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
}
|
|
162
162
|
.ss-select.invalid .control:focus-within {
|
|
163
163
|
border-color: var(--ss-red);
|
|
164
|
-
box-shadow: 0 0 0 3px
|
|
164
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--ss-danger) 22%, transparent);
|
|
165
165
|
}
|
|
166
166
|
.ss-select.disabled .control {
|
|
167
167
|
border-color: var(--ss-line);
|
|
@@ -56,6 +56,17 @@
|
|
|
56
56
|
status === 'deg' ? 'degraded' : status === 'maint' ? 'maintenance' : status,
|
|
57
57
|
)
|
|
58
58
|
|
|
59
|
+
// Map the service status onto a Badge semantic tone (DS-0119).
|
|
60
|
+
const badgeTone = $derived(
|
|
61
|
+
status === 'deg'
|
|
62
|
+
? 'caution'
|
|
63
|
+
: status === 'down'
|
|
64
|
+
? 'critical'
|
|
65
|
+
: status === 'maint'
|
|
66
|
+
? 'brand'
|
|
67
|
+
: 'positive',
|
|
68
|
+
)
|
|
69
|
+
|
|
59
70
|
// Status is decorative on the dot/badge, but meaningful — fold it into the label.
|
|
60
71
|
const cardLabel = $derived(`${name}, ${statusLabel}`)
|
|
61
72
|
|
|
@@ -99,7 +110,7 @@
|
|
|
99
110
|
{#if loading}
|
|
100
111
|
<div class="sk sk-badge" aria-hidden="true"></div>
|
|
101
112
|
{:else}
|
|
102
|
-
<Badge tone={
|
|
113
|
+
<Badge tone={badgeTone}>{statusLabel}</Badge>
|
|
103
114
|
<div class="latency">{latency}</div>
|
|
104
115
|
{/if}
|
|
105
116
|
</div>
|
|
@@ -285,7 +296,7 @@ a.ss-svc:focus-visible,
|
|
|
285
296
|
|
|
286
297
|
.sk-badge {
|
|
287
298
|
width: 64px;
|
|
288
|
-
height: calc(var(--ss-ui-xs) + var(--ss-
|
|
299
|
+
height: calc(var(--ss-ui-xs) + var(--ss-chip-py) * 2);
|
|
289
300
|
}
|
|
290
301
|
|
|
291
302
|
.sk-spark {
|