dssoca 0.19.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/README.md +3 -3
  2. package/dist/components/Accordion.svelte +30 -54
  3. package/dist/components/Badge.svelte +12 -7
  4. package/dist/components/Badge.svelte.d.ts +2 -1
  5. package/dist/components/BottomNav.svelte +18 -28
  6. package/dist/components/BoxPlot.svelte +34 -7
  7. package/dist/components/BumpChart.svelte +65 -26
  8. package/dist/components/Button.svelte +23 -1
  9. package/dist/components/Button.svelte.d.ts +5 -1
  10. package/dist/components/Card.svelte +32 -14
  11. package/dist/components/Card.svelte.d.ts +4 -1
  12. package/dist/components/Chart.svelte +166 -32
  13. package/dist/components/Chart.svelte.d.ts +13 -1
  14. package/dist/components/Checkbox.svelte +210 -0
  15. package/dist/components/Checkbox.svelte.d.ts +38 -0
  16. package/dist/components/DateField.svelte +1 -1
  17. package/dist/components/FileDrop.svelte +113 -77
  18. package/dist/components/FileDrop.svelte.d.ts +12 -2
  19. package/dist/components/Heatmap.svelte +128 -50
  20. package/dist/components/Heatmap.svelte.d.ts +2 -1
  21. package/dist/components/Icon.svelte +12 -3
  22. package/dist/components/Icon.svelte.d.ts +4 -0
  23. package/dist/components/Image.svelte +44 -44
  24. package/dist/components/Input.svelte +11 -6
  25. package/dist/components/Link.svelte +25 -14
  26. package/dist/components/LogStream.svelte +48 -33
  27. package/dist/components/Menu.svelte +81 -102
  28. package/dist/components/Menu.svelte.d.ts +8 -2
  29. package/dist/components/MetricTile.svelte +11 -1
  30. package/dist/components/MetricTile.svelte.d.ts +6 -0
  31. package/dist/components/Modal.svelte +108 -21
  32. package/dist/components/Modal.svelte.d.ts +18 -5
  33. package/dist/components/NumberField.svelte +44 -22
  34. package/dist/components/Pagination.svelte +54 -41
  35. package/dist/components/Pagination.svelte.d.ts +6 -2
  36. package/dist/components/Popover.svelte +247 -0
  37. package/dist/components/Popover.svelte.d.ts +36 -0
  38. package/dist/components/RadioGroup.svelte +227 -0
  39. package/dist/components/RadioGroup.svelte.d.ts +42 -0
  40. package/dist/components/ScatterPlot.svelte +42 -7
  41. package/dist/components/SearchPalette.svelte +216 -136
  42. package/dist/components/SearchPalette.svelte.d.ts +11 -4
  43. package/dist/components/SegmentedControl.svelte +47 -59
  44. package/dist/components/SegmentedControl.svelte.d.ts +7 -2
  45. package/dist/components/Select.svelte +3 -4
  46. package/dist/components/ServiceCard.svelte +105 -68
  47. package/dist/components/ServiceCard.svelte.d.ts +8 -3
  48. package/dist/components/ShortcutsHelp.svelte +49 -48
  49. package/dist/components/Sidebar.svelte +88 -117
  50. package/dist/components/Switch.svelte +24 -18
  51. package/dist/components/Switch.svelte.d.ts +6 -2
  52. package/dist/components/Table.svelte +29 -44
  53. package/dist/components/Table.svelte.d.ts +6 -2
  54. package/dist/components/Tabs.svelte +223 -0
  55. package/dist/components/Tabs.svelte.d.ts +51 -0
  56. package/dist/components/Textarea.svelte +1 -1
  57. package/dist/components/TierList.svelte +45 -49
  58. package/dist/components/TierList.svelte.d.ts +7 -3
  59. package/dist/components/Toaster.svelte +154 -32
  60. package/dist/components/Tooltip.svelte +122 -18
  61. package/dist/components/Tooltip.svelte.d.ts +1 -1
  62. package/dist/components/Topbar.svelte +29 -49
  63. package/dist/core/accordion.d.ts +32 -0
  64. package/dist/core/accordion.js +53 -0
  65. package/dist/core/behaviors/focusable.d.ts +5 -0
  66. package/dist/core/behaviors/focusable.js +14 -0
  67. package/dist/core/behaviors/roving.d.ts +13 -0
  68. package/dist/core/behaviors/roving.js +29 -0
  69. package/dist/core/bottom-nav.d.ts +36 -0
  70. package/dist/core/bottom-nav.js +33 -0
  71. package/dist/core/chart-nav.d.ts +53 -0
  72. package/dist/core/chart-nav.js +62 -0
  73. package/dist/core/checkbox.d.ts +36 -0
  74. package/dist/core/checkbox.js +29 -0
  75. package/dist/core/file-drop.d.ts +75 -0
  76. package/dist/core/file-drop.js +101 -0
  77. package/dist/core/image.d.ts +59 -0
  78. package/dist/core/image.js +64 -0
  79. package/dist/core/input.d.ts +21 -0
  80. package/dist/core/input.js +17 -0
  81. package/dist/core/log-stream.d.ts +51 -0
  82. package/dist/core/log-stream.js +50 -0
  83. package/dist/core/menu.d.ts +70 -0
  84. package/dist/core/menu.js +84 -0
  85. package/dist/core/modal.d.ts +59 -0
  86. package/dist/core/modal.js +44 -0
  87. package/dist/core/number-field.d.ts +47 -0
  88. package/dist/core/number-field.js +64 -0
  89. package/dist/core/pagination.d.ts +59 -0
  90. package/dist/core/pagination.js +65 -0
  91. package/dist/core/popover.d.ts +68 -0
  92. package/dist/core/popover.js +55 -0
  93. package/dist/core/radio.d.ts +36 -0
  94. package/dist/core/radio.js +48 -0
  95. package/dist/core/search-palette.d.ts +124 -0
  96. package/dist/core/search-palette.js +149 -0
  97. package/dist/core/segmented.d.ts +46 -0
  98. package/dist/core/segmented.js +66 -0
  99. package/dist/core/shortcuts-help.d.ts +56 -0
  100. package/dist/core/shortcuts-help.js +50 -0
  101. package/dist/core/sidebar.d.ts +63 -0
  102. package/dist/core/sidebar.js +84 -0
  103. package/dist/core/switch.d.ts +19 -0
  104. package/dist/core/switch.js +11 -0
  105. package/dist/core/table.d.ts +40 -0
  106. package/dist/core/table.js +57 -0
  107. package/dist/core/tabs.d.ts +84 -0
  108. package/dist/core/tabs.js +90 -0
  109. package/dist/{tierlist-core.d.ts → core/tierlist.d.ts} +77 -5
  110. package/dist/{tierlist-core.js → core/tierlist.js} +64 -7
  111. package/dist/core/toast.d.ts +112 -0
  112. package/dist/{toast-core.js → core/toast.js} +48 -2
  113. package/dist/core/tooltip.d.ts +47 -0
  114. package/dist/core/tooltip.js +51 -0
  115. package/dist/core/topbar.d.ts +41 -0
  116. package/dist/core/topbar.js +52 -0
  117. package/dist/dssoca.config.d.ts +1 -1
  118. package/dist/dssoca.config.js +4 -0
  119. package/dist/icons.d.ts +19 -2
  120. package/dist/icons.js +42 -3
  121. package/dist/index.d.ts +15 -2
  122. package/dist/index.js +10 -2
  123. package/dist/theme.css +47 -0
  124. package/dist/toast.svelte.d.ts +2 -2
  125. package/dist/toast.svelte.js +1 -1
  126. package/dist/tokens.css +47 -0
  127. package/dist/vanilla/accordion.js +35 -32
  128. package/dist/vanilla/checkbox.d.ts +8 -0
  129. package/dist/vanilla/checkbox.js +43 -0
  130. package/dist/vanilla/delegate.d.ts +2 -0
  131. package/dist/vanilla/delegate.js +9 -0
  132. package/dist/vanilla/fields.js +46 -28
  133. package/dist/vanilla/index.d.ts +5 -1
  134. package/dist/vanilla/index.js +17 -4
  135. package/dist/vanilla/menu.js +101 -84
  136. package/dist/vanilla/modal.d.ts +7 -1
  137. package/dist/vanilla/modal.js +120 -15
  138. package/dist/vanilla/popover.d.ts +10 -0
  139. package/dist/vanilla/popover.js +129 -0
  140. package/dist/vanilla/radio.d.ts +3 -0
  141. package/dist/vanilla/radio.js +54 -0
  142. package/dist/vanilla/segmented.js +50 -43
  143. package/dist/vanilla/switch.d.ts +2 -1
  144. package/dist/vanilla/switch.js +13 -8
  145. package/dist/vanilla/tabs.d.ts +2 -0
  146. package/dist/vanilla/tabs.js +87 -0
  147. package/dist/vanilla/tierlist.d.ts +1 -1
  148. package/dist/vanilla/tierlist.js +34 -34
  149. package/dist/vanilla/toast.d.ts +13 -5
  150. package/dist/vanilla/toast.js +132 -16
  151. package/dist/vanilla/tooltip.d.ts +5 -1
  152. package/dist/vanilla/tooltip.js +78 -19
  153. package/dist/vanilla.css +675 -160
  154. package/package.json +1 -1
  155. package/dist/toast-core.d.ts +0 -61
@@ -37,6 +37,27 @@
37
37
  import { tick, type Snippet } from 'svelte'
38
38
  import { resolveComponentSize, type Size } from '../config.js'
39
39
  import { shortcuts } from '../shortcuts.svelte.js'
40
+ import { lockScroll, unlockScroll } from '../vanilla/modal.js'
41
+ import {
42
+ searchBackdropPress,
43
+ searchClosePress,
44
+ searchFilter,
45
+ searchFirstActive,
46
+ searchFlat,
47
+ searchGroups,
48
+ searchHover,
49
+ searchInputAttrs,
50
+ searchInputKey,
51
+ searchItemPress,
52
+ searchOptionAttrs,
53
+ searchShortcut,
54
+ searchStatus,
55
+ searchValidActive,
56
+ type SearchPaletteAction,
57
+ type SearchPaletteOpenDetails,
58
+ type SearchPaletteReason,
59
+ type SearchPaletteState,
60
+ } from '../core/search-palette.js'
40
61
 
41
62
  interface Props {
42
63
  /** Whether the palette is shown. Bindable — sync it from caller state. */
@@ -58,6 +79,11 @@
58
79
  'aria-label'?: string
59
80
  /** No-results text (used when the `empty` snippet is absent). @default 'No results' */
60
81
  emptyText?: string
82
+ /** Screen-reader announcement of the result count while a query is typed.
83
+ * @default (n) => `${n} result(s)` */
84
+ resultsText?: (count: number) => string
85
+ /** Accessible name of the close button (shown on small, full-screen viewports). @default 'Close' */
86
+ closeLabel?: string
61
87
  /** Footer hint row; false hides it. A `footer` snippet replaces it. @default '↑↓ navigate · ↵ open · esc close' */
62
88
  footerText?: string | false
63
89
  /** Clear the query and selection when the palette closes. @default true */
@@ -66,10 +92,11 @@
66
92
  size?: Size
67
93
  /** Called with the chosen item on Enter/click. Return false to keep the palette open. */
68
94
  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
95
+ /** Called after the palette opens, with why (`details.reason`: shortcut · prop). */
96
+ onopen?: (details: SearchPaletteOpenDetails) => void
97
+ /** Called after the palette closes, with why (`details.reason`: escape · backdrop ·
98
+ * close-button · select · shortcut · prop). */
99
+ onclose?: (details: SearchPaletteOpenDetails) => void
73
100
  /** Replaces the default option row body (label + hint). */
74
101
  item?: Snippet<[T, { active: boolean }]>
75
102
  /** Replaces the default no-results state; receives the current query. */
@@ -87,6 +114,8 @@
87
114
  placeholder = 'Search…',
88
115
  'aria-label': ariaLabel = 'Search',
89
116
  emptyText = 'No results',
117
+ resultsText = (n: number) => `${n} ${n === 1 ? 'result' : 'results'}`,
118
+ closeLabel = 'Close',
90
119
  footerText = '↑↓ navigate · ↵ open · esc close',
91
120
  resetOnClose = true,
92
121
  size,
@@ -107,50 +136,32 @@
107
136
  const listId = `${uid}-listbox`
108
137
  const optionId = (index: number) => `${uid}-option-${index}`
109
138
 
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
- })
139
+ // Behaviour lives in `core/search-palette.ts`: filtering, grouping, the active-option
140
+ // movement, what a key does and why the palette opens/closes are decided there; this
141
+ // file holds the state and applies the result.
142
+ const filtered = $derived(filter ? searchFilter(items, query) : items)
123
143
 
124
144
  // Buckets in first-appearance order, ungrouped (label null) always first;
125
145
  // 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
146
+ const groups = $derived(searchGroups(filtered))
147
+ const flat = $derived(searchFlat(groups))
148
+
149
+ const palette = $derived<SearchPaletteState>({ open, active, items: flat })
150
+
151
+ // Why the next open/close happens. Set when the palette changes `open` itself (or the
152
+ // native dialog reports Esc through `cancel`); left null when the consumer flips the
153
+ // prop, which reports as 'prop'.
154
+ let pending: SearchPaletteReason | null = null
155
+ const takeReason = (): SearchPaletteReason => {
156
+ const reason = pending ?? 'prop'
157
+ pending = null
158
+ return reason
149
159
  }
150
160
 
151
161
  // Keep the active index valid as the list changes (typing, items swapped).
152
162
  $effect(() => {
153
- if (active >= flat.length || flat[active]?.disabled) active = firstSelectable()
163
+ const valid = searchValidActive(palette)
164
+ if (valid !== active) active = valid
154
165
  })
155
166
 
156
167
  // Mirror `open` onto the native dialog (same guard dance as Modal), then
@@ -161,12 +172,54 @@
161
172
  if (open && !el.open) {
162
173
  el.showModal()
163
174
  input?.focus()
164
- onopen?.()
175
+ onopen?.({ reason: takeReason() })
165
176
  } else if (!open && el.open) {
166
177
  el.close()
167
178
  }
168
179
  })
169
180
 
181
+ // Lock the page behind the palette while open (the dialog's own .results
182
+ // already has overscroll-behavior: contain). Shares Modal's reference-counted
183
+ // lock, so a palette opened over a modal (or vice versa) unwinds correctly.
184
+ $effect(() => {
185
+ if (!open) return
186
+ lockScroll()
187
+ return unlockScroll
188
+ })
189
+
190
+ // Polite live text for the always-rendered status node: silent until the
191
+ // user types, then the result count (or the no-results text).
192
+ const status = $derived(searchStatus(query, flat.length, resultsText, emptyText))
193
+
194
+ function run(action: SearchPaletteAction | null) {
195
+ if (!action) return
196
+ switch (action.type) {
197
+ case 'open':
198
+ pending = action.reason
199
+ open = true
200
+ break
201
+ case 'close':
202
+ pending = action.reason
203
+ open = false
204
+ break
205
+ case 'move':
206
+ active = action.index
207
+ void tick().then(() => optionAt(active)?.scrollIntoView({ block: 'nearest' }))
208
+ break
209
+ case 'activate':
210
+ // href options: click the real anchor so the router/native semantics
211
+ // apply — its click handler runs choose() for us.
212
+ if (action.via === 'anchor') optionAt(action.index)?.click()
213
+ else choose(action.index)
214
+ break
215
+ }
216
+ }
217
+
218
+ // Esc on the native dialog fires `cancel` right before `close`.
219
+ function onDialogCancel() {
220
+ pending = 'escape'
221
+ }
222
+
170
223
  // Native `close` (Esc, .close()) → sync state, optionally reset, notify.
171
224
  function onDialogClose() {
172
225
  if (open) open = false
@@ -174,13 +227,26 @@
174
227
  query = ''
175
228
  active = 0
176
229
  }
177
- onclose?.()
230
+ onclose?.({ reason: takeReason() })
178
231
  }
179
232
 
180
- // A pointerdown landing on the <dialog> itself (not the inner panel) is a
181
- // backdrop hit (Modal's detection).
233
+ // A press that starts on the <dialog> itself (not the inner panel) is a
234
+ // backdrop hit (Modal's detection). Remembering where the press began avoids
235
+ // closing on a drag that started inside the panel and was released on the
236
+ // backdrop.
237
+ //
238
+ // The dialog closes on the `click`, not on the pointerdown: closing hands
239
+ // focus back to the opener, and if that happened on pointerdown the same
240
+ // gesture's mousedown would then land on the page and blur it, leaving focus
241
+ // on <body>.
242
+ let pressedBackdrop = false
182
243
  function onPointerDown(e: PointerEvent) {
183
- if (e.target === dialog) open = false
244
+ pressedBackdrop = e.target === dialog
245
+ }
246
+ function onClick(e: MouseEvent) {
247
+ const hit = pressedBackdrop && e.target === dialog
248
+ pressedBackdrop = false
249
+ run(searchBackdropPress(palette, hit))
184
250
  }
185
251
 
186
252
  // DS-0139: the toggle chord goes through the shortcut registry (id
@@ -197,71 +263,35 @@
197
263
  label: 'Open search',
198
264
  keys: shortcut,
199
265
  allowInInputs: true, // chorded — must fire while typing (incl. the palette's own input)
200
- onPress: () => {
201
- open = !open
202
- },
266
+ onPress: () => run(searchShortcut(open)),
203
267
  }
204
268
  const el = dialog
205
269
  return open && el ? shortcuts.add({ ...options, scope: 'focus' }, el) : shortcuts.add(options)
206
270
  })
207
271
 
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
272
  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
- }
273
+ const result = searchInputKey(palette, e.key, e.isComposing)
274
+ if (!result) return
275
+ if (result.preventDefault) e.preventDefault()
276
+ run(result.action)
253
277
  }
254
278
 
255
- function anchorAt(index: number): HTMLAnchorElement | null {
256
- return list?.querySelector(`#${CSS.escape(optionId(index))}`) as HTMLAnchorElement | null
279
+ function optionAt(index: number): HTMLElement | null {
280
+ return list?.querySelector<HTMLElement>(`#${CSS.escape(optionId(index))}`) ?? null
257
281
  }
258
282
 
259
283
  // Shared select path for clicks and Enter; navigation (when any) has
260
284
  // 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
285
+ function choose(index: number) {
286
+ const result = searchItemPress(palette, index)
287
+ if (!result) return
288
+ const keep = onselect?.(flat[index]) === false
289
+ if (!keep) run(result.close)
290
+ }
291
+
292
+ function hover(index: number) {
293
+ const next = searchHover(palette, index)
294
+ if (next !== null) active = next
265
295
  }
266
296
 
267
297
  // Focus must never leave the input (aria-activedescendant pattern):
@@ -274,7 +304,7 @@
274
304
  // the derived `flat` reflects the new query regardless of handler order.
275
305
  async function onQueryInput() {
276
306
  await tick()
277
- active = firstSelectable()
307
+ active = searchFirstActive(palette)
278
308
  }
279
309
  </script>
280
310
 
@@ -283,27 +313,38 @@
283
313
  class="ss-search-palette"
284
314
  data-size-variant={resolveComponentSize('SearchPalette', size)}
285
315
  aria-label={ariaLabel}
316
+ oncancel={onDialogCancel}
286
317
  onclose={onDialogClose}
287
318
  onpointerdown={onPointerDown}
319
+ onclick={onClick}
288
320
  >
289
321
  <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
- />
322
+ <div class="bar">
323
+ <input
324
+ bind:this={input}
325
+ bind:value={query}
326
+ oninput={onQueryInput}
327
+ onkeydown={onInputKeydown}
328
+ class="input"
329
+ type="text"
330
+ {placeholder}
331
+ spellcheck="false"
332
+ autocomplete="off"
333
+ aria-label={ariaLabel}
334
+ aria-controls={listId}
335
+ {...searchInputAttrs(flat.length, optionId(active))}
336
+ />
337
+ <!-- Touch exit for the full-screen small-viewport layout (no backdrop to
338
+ tap there); hidden on wider screens, where Esc/backdrop close it. -->
339
+ <button
340
+ type="button"
341
+ class="close"
342
+ aria-label={closeLabel}
343
+ onclick={() => run(searchClosePress(palette))}>×</button
344
+ >
345
+ </div>
346
+
347
+ <p class="sr-only" role="status">{status}</p>
307
348
 
308
349
  <div class="results" bind:this={list}>
309
350
  {#if flat.length === 0}
@@ -329,15 +370,13 @@
329
370
  {#if it.href && !it.disabled}
330
371
  <a
331
372
  id={optionId(index)}
332
- role="option"
333
- aria-selected={index === active}
334
373
  class="row"
335
374
  class:active={index === active}
336
375
  href={it.href}
337
- tabindex="-1"
376
+ {...searchOptionAttrs({ index, active })}
338
377
  onpointerdown={onRowPointerDown}
339
- onmousemove={() => (active = index)}
340
- onclick={() => choose(it)}
378
+ onmousemove={() => hover(index)}
379
+ onclick={() => choose(index)}
341
380
  >
342
381
  {@render body(it, index)}
343
382
  </a>
@@ -345,18 +384,13 @@
345
384
  <button
346
385
  id={optionId(index)}
347
386
  type="button"
348
- role="option"
349
- aria-selected={index === active}
350
- aria-disabled={it.disabled || undefined}
351
387
  class="row"
352
388
  class:active={index === active}
353
389
  class:disabled={it.disabled}
354
- tabindex="-1"
390
+ {...searchOptionAttrs({ index, active, disabled: it.disabled })}
355
391
  onpointerdown={onRowPointerDown}
356
- onmousemove={() => {
357
- if (!it.disabled) active = index
358
- }}
359
- onclick={() => choose(it)}
392
+ onmousemove={() => hover(index)}
393
+ onclick={() => choose(index)}
360
394
  >
361
395
  {@render body(it, index)}
362
396
  </button>
@@ -416,24 +450,67 @@
416
450
  flex-direction: column;
417
451
  }
418
452
 
453
+ .bar {
454
+ display: flex;
455
+ align-items: center;
456
+ border-bottom: 1px solid var(--ss-line);
457
+ }
458
+ .bar:focus-within {
459
+ border-bottom-color: var(--ss-primary);
460
+ }
461
+
419
462
  .input {
463
+ flex: 1;
464
+ min-width: 0;
420
465
  width: 100%;
421
466
  padding: var(--ss-search-palette-input-pad, var(--ss-s-4)) var(--ss-s-4);
422
467
  background: transparent;
423
468
  border: none;
424
- border-bottom: 1px solid var(--ss-line);
425
469
  color: var(--ss-fg);
426
470
  font-family: inherit;
427
471
  font-size: var(--ss-search-palette-input-size, var(--ss-ui-lg, var(--ss-size-body)));
428
472
  }
429
473
  .input:focus {
430
474
  outline: none;
431
- border-bottom-color: var(--ss-primary);
432
475
  }
433
476
  .input::placeholder {
434
477
  color: var(--ss-fg-muted);
435
478
  }
436
479
 
480
+ .close {
481
+ display: none;
482
+ flex: none;
483
+ align-items: center;
484
+ justify-content: center;
485
+ min-inline-size: var(--ss-s-10);
486
+ min-block-size: var(--ss-s-10);
487
+ margin-inline-end: var(--ss-s-2);
488
+ padding: 0;
489
+ background: transparent;
490
+ border: 1px solid transparent;
491
+ color: var(--ss-fg-muted);
492
+ font-family: inherit;
493
+ font-size: var(--ss-size-h3);
494
+ line-height: 1;
495
+ cursor: pointer;
496
+ }
497
+ .close:hover {
498
+ color: var(--ss-fg);
499
+ border-color: var(--ss-line-strong);
500
+ }
501
+
502
+ .sr-only {
503
+ position: absolute;
504
+ width: 1px;
505
+ height: 1px;
506
+ padding: 0;
507
+ margin: -1px;
508
+ overflow: hidden;
509
+ clip: rect(0, 0, 0, 0);
510
+ white-space: nowrap;
511
+ border: 0;
512
+ }
513
+
437
514
  .results {
438
515
  overflow-y: auto;
439
516
  max-height: var(--ss-search-palette-list-h, 60vh);
@@ -467,18 +544,18 @@ ul {
467
544
  width: 100%;
468
545
  padding: var(--ss-s-2) var(--ss-s-4);
469
546
  border: none;
470
- border-left: 2px solid transparent;
471
- padding-left: calc(var(--ss-s-4) - 2px);
547
+ border-inline-start: 2px solid transparent;
548
+ padding-inline-start: calc(var(--ss-s-4) - 2px);
472
549
  background: transparent;
473
550
  color: var(--ss-fg);
474
551
  font-family: inherit;
475
- text-align: left;
552
+ text-align: start;
476
553
  text-decoration: none;
477
554
  cursor: pointer;
478
555
  }
479
556
  .row.active {
480
557
  background: var(--ss-primary-soft);
481
- border-left-color: var(--ss-primary);
558
+ border-inline-start-color: var(--ss-primary);
482
559
  }
483
560
  .row.disabled {
484
561
  color: var(--ss-fg-faint, var(--ss-fg-muted));
@@ -523,6 +600,9 @@ ul {
523
600
  flex: 1;
524
601
  max-height: none;
525
602
  }
603
+ .close {
604
+ display: inline-flex;
605
+ }
526
606
  }
527
607
  .row::before {
528
608
  content: none;
@@ -16,6 +16,7 @@ export interface SearchPaletteItem {
16
16
  }
17
17
  import { type Snippet } from 'svelte';
18
18
  import { type Size } from '../config.js';
19
+ import { type SearchPaletteOpenDetails } from '../core/search-palette.js';
19
20
  declare function $$render<T extends SearchPaletteItem>(): {
20
21
  props: {
21
22
  /** Whether the palette is shown. Bindable — sync it from caller state. */
@@ -37,6 +38,11 @@ declare function $$render<T extends SearchPaletteItem>(): {
37
38
  'aria-label'?: string;
38
39
  /** No-results text (used when the `empty` snippet is absent). @default 'No results' */
39
40
  emptyText?: string;
41
+ /** Screen-reader announcement of the result count while a query is typed.
42
+ * @default (n) => `${n} result(s)` */
43
+ resultsText?: (count: number) => string;
44
+ /** Accessible name of the close button (shown on small, full-screen viewports). @default 'Close' */
45
+ closeLabel?: string;
40
46
  /** Footer hint row; false hides it. A `footer` snippet replaces it. @default '↑↓ navigate · ↵ open · esc close' */
41
47
  footerText?: string | false;
42
48
  /** Clear the query and selection when the palette closes. @default true */
@@ -45,10 +51,11 @@ declare function $$render<T extends SearchPaletteItem>(): {
45
51
  size?: Size;
46
52
  /** Called with the chosen item on Enter/click. Return false to keep the palette open. */
47
53
  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;
54
+ /** Called after the palette opens, with why (`details.reason`: shortcut · prop). */
55
+ onopen?: (details: SearchPaletteOpenDetails) => void;
56
+ /** Called after the palette closes, with why (`details.reason`: escape · backdrop ·
57
+ * close-button · select · shortcut · prop). */
58
+ onclose?: (details: SearchPaletteOpenDetails) => void;
52
59
  /** Replaces the default option row body (label + hint). */
53
60
  item?: Snippet<[T, {
54
61
  active: boolean;