dssoca 0.19.0 → 0.20.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/chart-nav.d.ts +13 -0
- package/dist/chart-nav.js +35 -0
- package/dist/components/Accordion.svelte +7 -2
- package/dist/components/Badge.svelte +12 -7
- package/dist/components/Badge.svelte.d.ts +2 -1
- package/dist/components/BoxPlot.svelte +33 -7
- package/dist/components/BumpChart.svelte +68 -26
- package/dist/components/Button.svelte +23 -1
- package/dist/components/Button.svelte.d.ts +5 -1
- package/dist/components/Card.svelte +32 -14
- package/dist/components/Card.svelte.d.ts +4 -1
- package/dist/components/Chart.svelte +169 -32
- package/dist/components/Chart.svelte.d.ts +13 -1
- package/dist/components/DateField.svelte +1 -1
- package/dist/components/FileDrop.svelte +81 -14
- package/dist/components/FileDrop.svelte.d.ts +6 -0
- package/dist/components/Heatmap.svelte +128 -50
- package/dist/components/Heatmap.svelte.d.ts +2 -1
- package/dist/components/Icon.svelte +12 -3
- package/dist/components/Icon.svelte.d.ts +4 -0
- package/dist/components/Input.svelte +3 -3
- package/dist/components/Link.svelte +25 -14
- package/dist/components/LogStream.svelte +34 -9
- package/dist/components/Menu.svelte +12 -8
- package/dist/components/Menu.svelte.d.ts +2 -2
- package/dist/components/MetricTile.svelte +11 -1
- package/dist/components/MetricTile.svelte.d.ts +6 -0
- package/dist/components/Modal.svelte +47 -7
- package/dist/components/Modal.svelte.d.ts +11 -3
- package/dist/components/NumberField.svelte +33 -10
- package/dist/components/Pagination.svelte +7 -4
- package/dist/components/ScatterPlot.svelte +44 -7
- package/dist/components/SearchPalette.svelte +99 -23
- package/dist/components/SearchPalette.svelte.d.ts +5 -0
- package/dist/components/SegmentedControl.svelte +14 -5
- package/dist/components/Select.svelte +3 -4
- package/dist/components/ServiceCard.svelte +105 -68
- package/dist/components/ServiceCard.svelte.d.ts +8 -3
- package/dist/components/ShortcutsHelp.svelte +1 -1
- package/dist/components/Sidebar.svelte +41 -58
- package/dist/components/Switch.svelte +4 -8
- package/dist/components/Table.svelte +20 -13
- package/dist/components/Table.svelte.d.ts +6 -2
- package/dist/components/Textarea.svelte +1 -1
- package/dist/components/TierList.svelte +9 -13
- package/dist/components/Toaster.svelte +143 -21
- package/dist/components/Tooltip.svelte +101 -13
- package/dist/components/Tooltip.svelte.d.ts +1 -1
- package/dist/components/Topbar.svelte +21 -16
- package/dist/icons.d.ts +19 -2
- package/dist/icons.js +42 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/tierlist-core.d.ts +15 -5
- package/dist/tierlist-core.js +30 -7
- package/dist/vanilla/accordion.js +7 -3
- package/dist/vanilla/fields.js +19 -6
- package/dist/vanilla/index.d.ts +1 -1
- package/dist/vanilla/index.js +4 -4
- package/dist/vanilla/menu.js +12 -1
- package/dist/vanilla/modal.d.ts +4 -0
- package/dist/vanilla/modal.js +57 -2
- package/dist/vanilla/segmented.js +13 -4
- package/dist/vanilla/tierlist.js +7 -11
- package/dist/vanilla/toast.d.ts +11 -3
- package/dist/vanilla/toast.js +124 -10
- package/dist/vanilla/tooltip.d.ts +5 -1
- package/dist/vanilla/tooltip.js +57 -10
- package/dist/vanilla.css +326 -118
- package/package.json +1 -1
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
// ─────────────────────────────────────────────────────────────────────────
|
|
35
35
|
import { tick, untrack, type Snippet } from 'svelte'
|
|
36
36
|
import { flip } from 'svelte/animate'
|
|
37
|
+
import { prefersReducedMotion } from 'svelte/motion'
|
|
37
38
|
import { resolveComponentSize, type Size } from '../config.js'
|
|
38
39
|
import {
|
|
39
40
|
DEFAULT_TIERS,
|
|
@@ -42,13 +43,13 @@
|
|
|
42
43
|
announceText,
|
|
43
44
|
buildZones,
|
|
44
45
|
insertionIndex,
|
|
46
|
+
keyMoveFor,
|
|
45
47
|
keyboardTarget,
|
|
46
48
|
locate,
|
|
47
49
|
moveItem,
|
|
48
50
|
placementsOf,
|
|
49
51
|
tierColor,
|
|
50
52
|
zonesEqual,
|
|
51
|
-
type TierListKeyMove,
|
|
52
53
|
type TierListZones,
|
|
53
54
|
} from '../tierlist-core.js'
|
|
54
55
|
|
|
@@ -142,14 +143,8 @@
|
|
|
142
143
|
|
|
143
144
|
// --- keyboard sorting ----------------------------------------------------
|
|
144
145
|
let grabbed = $state<{ id: string; origin: TierListZones } | null>(null)
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
ArrowRight: 'right',
|
|
148
|
-
ArrowUp: 'up',
|
|
149
|
-
ArrowDown: 'down',
|
|
150
|
-
Home: 'home',
|
|
151
|
-
End: 'end',
|
|
152
|
-
}
|
|
146
|
+
// Read at event time, not once: `dir` may be set on any ancestor and change later.
|
|
147
|
+
const isRtl = (el: Element) => getComputedStyle(el).direction === 'rtl'
|
|
153
148
|
|
|
154
149
|
function toggleGrab(id: string) {
|
|
155
150
|
if (grabbed?.id === id) {
|
|
@@ -203,7 +198,7 @@
|
|
|
203
198
|
cancelGrab(true)
|
|
204
199
|
return
|
|
205
200
|
}
|
|
206
|
-
const move =
|
|
201
|
+
const move = keyMoveFor(e.key, isRtl(e.currentTarget as Element))
|
|
207
202
|
if (!move) return
|
|
208
203
|
e.preventDefault()
|
|
209
204
|
const target = keyboardTarget(zones, zoneOrder, item.id, move)
|
|
@@ -314,7 +309,8 @@
|
|
|
314
309
|
const boxes = Array.from(zoneEl.querySelectorAll<HTMLElement>(':scope > .cell'))
|
|
315
310
|
.filter((c) => c.dataset.item !== drag!.id)
|
|
316
311
|
.map((c) => c.getBoundingClientRect())
|
|
317
|
-
const
|
|
312
|
+
const index = insertionIndex(boxes, e.clientX, e.clientY, isRtl(zoneEl))
|
|
313
|
+
const next = moveItem(zones, drag.id, zone, index)
|
|
318
314
|
if (next !== zones) zones = next
|
|
319
315
|
}
|
|
320
316
|
|
|
@@ -373,7 +369,7 @@
|
|
|
373
369
|
class:shadow={drag?.active && drag.id === item.id}
|
|
374
370
|
class:grabbed={grabbed?.id === item.id}
|
|
375
371
|
data-item={item.id}
|
|
376
|
-
animate:flip={{ duration: 150 }}
|
|
372
|
+
animate:flip={{ duration: prefersReducedMotion.current ? 0 : 150 }}
|
|
377
373
|
>
|
|
378
374
|
{#if readonly}
|
|
379
375
|
<div class="tile" data-item={item.id} aria-label={item.label} role="img">
|
|
@@ -526,7 +522,7 @@
|
|
|
526
522
|
background: var(--ss-bg-inset);
|
|
527
523
|
color: inherit;
|
|
528
524
|
font: inherit;
|
|
529
|
-
text-align:
|
|
525
|
+
text-align: start;
|
|
530
526
|
overflow: hidden;
|
|
531
527
|
cursor: grab;
|
|
532
528
|
touch-action: none;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { fly } from 'svelte/transition'
|
|
3
3
|
import { prefersReducedMotion } from 'svelte/motion'
|
|
4
|
+
import { untrack } from 'svelte'
|
|
4
5
|
import { toasts, type Toast, type ToastKind } from '../toast.svelte.js'
|
|
5
6
|
import { resolveComponentSize, type Size } from '../config.js'
|
|
6
7
|
|
|
@@ -20,6 +21,7 @@
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
let { size, position = 'top-right' }: Props = $props()
|
|
24
|
+
const uid = $props.id()
|
|
23
25
|
|
|
24
26
|
const glyph: Record<ToastKind, string> = { success: '✓', error: '✕', info: 'i', loading: '' }
|
|
25
27
|
// Honor prefers-reduced-motion: collapse the fly transition to an instant swap.
|
|
@@ -43,7 +45,16 @@
|
|
|
43
45
|
})
|
|
44
46
|
const flyDuration = $derived(reduce ? 0 : tokenDuration)
|
|
45
47
|
// Bottom anchors slide in from below; centered ones come straight down/up.
|
|
46
|
-
|
|
48
|
+
// `left`/`right` positions are logical (inline start/end), so in RTL the
|
|
49
|
+
// horizontal slide mirrors with them.
|
|
50
|
+
const rtl = $derived(
|
|
51
|
+
!!rootEl &&
|
|
52
|
+
typeof getComputedStyle === 'function' &&
|
|
53
|
+
getComputedStyle(rootEl).direction === 'rtl',
|
|
54
|
+
)
|
|
55
|
+
const flyX = $derived(
|
|
56
|
+
position.endsWith('center') ? 0 : (position.endsWith('left') ? -16 : 16) * (rtl ? -1 : 1),
|
|
57
|
+
)
|
|
47
58
|
const flyY = $derived(position.endsWith('center') ? (position.startsWith('top') ? -16 : 16) : 0)
|
|
48
59
|
|
|
49
60
|
// ── swipe-to-dismiss ──────────────────────────────────────────────
|
|
@@ -79,7 +90,8 @@
|
|
|
79
90
|
if (passed) toasts.dismiss(t.id)
|
|
80
91
|
else {
|
|
81
92
|
dragDx = 0
|
|
82
|
-
|
|
93
|
+
const el = e.currentTarget as HTMLElement
|
|
94
|
+
if (hoverId !== t.id && !el.contains(document.activeElement)) toasts.resume(t.id)
|
|
83
95
|
}
|
|
84
96
|
}
|
|
85
97
|
|
|
@@ -94,6 +106,93 @@
|
|
|
94
106
|
toasts.dismiss(t.id)
|
|
95
107
|
}
|
|
96
108
|
}
|
|
109
|
+
|
|
110
|
+
// ── pause / resume ────────────────────────────────────────────────
|
|
111
|
+
// Hover OR keyboard focus holds the timer; it only runs again once the
|
|
112
|
+
// pointer has left AND focus is outside the toast (a pointerleave must not
|
|
113
|
+
// restart the clock under a keyboard user, and vice versa).
|
|
114
|
+
let hoverId: number | null = null
|
|
115
|
+
|
|
116
|
+
function onPointerEnter(t: Toast) {
|
|
117
|
+
hoverId = t.id
|
|
118
|
+
toasts.pause(t.id)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function onPointerLeave(e: PointerEvent, t: Toast) {
|
|
122
|
+
if (hoverId === t.id) hoverId = null
|
|
123
|
+
if (dragId === t.id) return
|
|
124
|
+
const el = e.currentTarget as HTMLElement
|
|
125
|
+
if (el.contains(document.activeElement)) return
|
|
126
|
+
toasts.resume(t.id)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function onFocusOut(e: FocusEvent, t: Toast) {
|
|
130
|
+
const el = e.currentTarget as HTMLElement
|
|
131
|
+
if (el.contains(e.relatedTarget as Node | null)) return
|
|
132
|
+
if (hoverId === t.id || dragId === t.id) return
|
|
133
|
+
toasts.resume(t.id)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ── focus management ──────────────────────────────────────────────
|
|
137
|
+
// Dismissing the toast that holds focus would drop focus to <body>. Before
|
|
138
|
+
// the node goes, move focus to a neighbouring toast, or back to where focus
|
|
139
|
+
// came from before it entered the stack.
|
|
140
|
+
// Plain (non-reactive) bookkeeping: read only inside the pre-effect below.
|
|
141
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
142
|
+
const toastEls = new Map<number, HTMLElement>()
|
|
143
|
+
let order: number[] = []
|
|
144
|
+
let returnFocus: HTMLElement | null = null
|
|
145
|
+
|
|
146
|
+
function track(id: number) {
|
|
147
|
+
return (el: HTMLElement) => {
|
|
148
|
+
toastEls.set(id, el)
|
|
149
|
+
return () => {
|
|
150
|
+
if (toastEls.get(id) === el) toastEls.delete(id)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function onRootFocusIn(e: FocusEvent) {
|
|
156
|
+
const from = e.relatedTarget as HTMLElement | null
|
|
157
|
+
if (from && rootEl && !rootEl.contains(from)) returnFocus = from
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
$effect.pre(() => {
|
|
161
|
+
const ids = toasts.items.map((t) => t.id)
|
|
162
|
+
untrack(() => {
|
|
163
|
+
const alive = new Set(ids)
|
|
164
|
+
const active = typeof document === 'undefined' ? null : document.activeElement
|
|
165
|
+
if (active && rootEl?.contains(active)) {
|
|
166
|
+
const holder = order.find((id) => !alive.has(id) && toastEls.get(id)?.contains(active))
|
|
167
|
+
if (holder !== undefined) moveFocusFrom(holder, alive)
|
|
168
|
+
}
|
|
169
|
+
order = ids
|
|
170
|
+
})
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
function moveFocusFrom(id: number, alive: Set<number>) {
|
|
174
|
+
const i = order.indexOf(id)
|
|
175
|
+
const after = order.slice(i + 1).find((n) => alive.has(n) && toastEls.has(n))
|
|
176
|
+
const before = order
|
|
177
|
+
.slice(0, i)
|
|
178
|
+
.reverse()
|
|
179
|
+
.find((n) => alive.has(n) && toastEls.has(n))
|
|
180
|
+
const next = after ?? before
|
|
181
|
+
if (next !== undefined) {
|
|
182
|
+
toastEls.get(next)!.focus()
|
|
183
|
+
} else if (returnFocus?.isConnected) {
|
|
184
|
+
returnFocus.focus()
|
|
185
|
+
returnFocus = null
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Screen-reader announcements go through two live regions that are always
|
|
190
|
+
// rendered (a node inserted already carrying role=status/alert is often
|
|
191
|
+
// skipped by NVDA/JAWS). Each visible toast mirrors its message into the
|
|
192
|
+
// polite (status) or assertive (alert, errors) region; the visual toasts
|
|
193
|
+
// themselves carry no live semantics, so nothing is announced twice.
|
|
194
|
+
const politeItems = $derived(toasts.items.filter((t) => t.kind !== 'error'))
|
|
195
|
+
const assertiveItems = $derived(toasts.items.filter((t) => t.kind === 'error'))
|
|
97
196
|
</script>
|
|
98
197
|
|
|
99
198
|
<div
|
|
@@ -103,21 +202,31 @@
|
|
|
103
202
|
data-position={position}
|
|
104
203
|
data-size-variant={resolveComponentSize('Toaster', size)}
|
|
105
204
|
bind:this={rootEl}
|
|
205
|
+
onfocusin={onRootFocusIn}
|
|
106
206
|
>
|
|
207
|
+
<div class="live" role="status" aria-live="polite">
|
|
208
|
+
{#each politeItems as t (t.id)}<p>{t.message}</p>{/each}
|
|
209
|
+
</div>
|
|
210
|
+
<div class="live" role="alert" aria-live="assertive">
|
|
211
|
+
{#each assertiveItems as t (t.id)}<p>{t.message}</p>{/each}
|
|
212
|
+
</div>
|
|
107
213
|
{#each toasts.items as t (t.id)}
|
|
214
|
+
<!-- The pointer/key handlers are progressive extras (pause, swipe, Escape); the buttons inside are the real controls. -->
|
|
215
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
108
216
|
<div
|
|
109
217
|
class="ss-toast {t.kind}"
|
|
110
218
|
class:dragging={dragId === t.id}
|
|
111
|
-
role=
|
|
112
|
-
aria-
|
|
219
|
+
role="group"
|
|
220
|
+
aria-labelledby="{uid}-msg-{t.id}"
|
|
113
221
|
tabindex="-1"
|
|
222
|
+
{@attach track(t.id)}
|
|
114
223
|
style:transform={dragId === t.id ? `translateX(${dragDx}px)` : undefined}
|
|
115
224
|
style:opacity={dragId === t.id ? Math.max(0.3, 1 - Math.abs(dragDx) / 200) : undefined}
|
|
116
225
|
transition:fly={{ x: flyX, y: flyY, duration: flyDuration }}
|
|
117
|
-
onpointerenter={() =>
|
|
118
|
-
onpointerleave={() =>
|
|
226
|
+
onpointerenter={() => onPointerEnter(t)}
|
|
227
|
+
onpointerleave={(e) => onPointerLeave(e, t)}
|
|
119
228
|
onfocusin={() => toasts.pause(t.id)}
|
|
120
|
-
onfocusout={() =>
|
|
229
|
+
onfocusout={(e) => onFocusOut(e, t)}
|
|
121
230
|
onpointerdown={(e) => onPointerDown(e, t)}
|
|
122
231
|
onpointermove={(e) => onPointerMove(e, t)}
|
|
123
232
|
onpointerup={(e) => endDrag(e, t)}
|
|
@@ -129,7 +238,7 @@
|
|
|
129
238
|
{:else}
|
|
130
239
|
<span class="ic" aria-hidden="true">{glyph[t.kind]}</span>
|
|
131
240
|
{/if}
|
|
132
|
-
<span class="msg">{t.message}</span>
|
|
241
|
+
<span class="msg" id="{uid}-msg-{t.id}">{t.message}</span>
|
|
133
242
|
{#if t.action}
|
|
134
243
|
<button class="action" type="button" onclick={() => runAction(t)}>
|
|
135
244
|
{t.action.label}
|
|
@@ -148,14 +257,13 @@
|
|
|
148
257
|
display: flex;
|
|
149
258
|
flex-direction: column;
|
|
150
259
|
gap: var(--ss-s-2);
|
|
151
|
-
max-
|
|
260
|
+
max-inline-size: min(360px, 100vw - var(--ss-s-8));
|
|
152
261
|
pointer-events: none;
|
|
153
262
|
top: var(--ss-s-4);
|
|
154
|
-
|
|
263
|
+
inset-inline-end: var(--ss-s-4);
|
|
155
264
|
}
|
|
156
265
|
.ss-toaster[data-position=top-left] {
|
|
157
|
-
|
|
158
|
-
left: var(--ss-s-4);
|
|
266
|
+
inset-inline: var(--ss-s-4) auto;
|
|
159
267
|
}
|
|
160
268
|
.ss-toaster[data-position=bottom-right] {
|
|
161
269
|
top: auto;
|
|
@@ -164,24 +272,34 @@
|
|
|
164
272
|
}
|
|
165
273
|
.ss-toaster[data-position=bottom-left] {
|
|
166
274
|
top: auto;
|
|
167
|
-
right: auto;
|
|
168
275
|
bottom: var(--ss-s-4);
|
|
169
|
-
|
|
276
|
+
inset-inline: var(--ss-s-4) auto;
|
|
170
277
|
flex-direction: column-reverse;
|
|
171
278
|
}
|
|
172
279
|
.ss-toaster[data-position=top-center] {
|
|
173
|
-
|
|
280
|
+
inset-inline: auto;
|
|
174
281
|
left: 50%;
|
|
175
282
|
transform: translateX(-50%);
|
|
176
283
|
}
|
|
177
284
|
.ss-toaster[data-position=bottom-center] {
|
|
178
285
|
top: auto;
|
|
179
|
-
right: auto;
|
|
180
286
|
bottom: var(--ss-s-4);
|
|
287
|
+
inset-inline: auto;
|
|
181
288
|
left: 50%;
|
|
182
289
|
transform: translateX(-50%);
|
|
183
290
|
flex-direction: column-reverse;
|
|
184
291
|
}
|
|
292
|
+
.ss-toaster .live {
|
|
293
|
+
position: absolute;
|
|
294
|
+
inline-size: 1px;
|
|
295
|
+
block-size: 1px;
|
|
296
|
+
padding: 0;
|
|
297
|
+
margin: -1px;
|
|
298
|
+
overflow: hidden;
|
|
299
|
+
clip: rect(0 0 0 0);
|
|
300
|
+
white-space: nowrap;
|
|
301
|
+
border: 0;
|
|
302
|
+
}
|
|
185
303
|
|
|
186
304
|
.ss-toast {
|
|
187
305
|
pointer-events: auto;
|
|
@@ -191,7 +309,7 @@
|
|
|
191
309
|
padding: var(--ss-s-3) var(--ss-s-4);
|
|
192
310
|
background: var(--ss-bg-elev);
|
|
193
311
|
border: 1px solid var(--ss-line);
|
|
194
|
-
border-
|
|
312
|
+
border-inline-start: 3px solid var(--ss-fg-faint);
|
|
195
313
|
box-shadow: var(--ss-shadow-pop);
|
|
196
314
|
font-family: var(--ss-font-mono);
|
|
197
315
|
font-size: var(--ss-ui-md);
|
|
@@ -207,16 +325,16 @@
|
|
|
207
325
|
transition: transform var(--ss-dur-fast) var(--ss-ease);
|
|
208
326
|
}
|
|
209
327
|
.ss-toast.success {
|
|
210
|
-
border-
|
|
328
|
+
border-inline-start-color: var(--ss-primary);
|
|
211
329
|
}
|
|
212
330
|
.ss-toast.error {
|
|
213
|
-
border-
|
|
331
|
+
border-inline-start-color: var(--ss-red);
|
|
214
332
|
}
|
|
215
333
|
.ss-toast.info {
|
|
216
|
-
border-
|
|
334
|
+
border-inline-start-color: var(--ss-cyan);
|
|
217
335
|
}
|
|
218
336
|
.ss-toast.loading {
|
|
219
|
-
border-
|
|
337
|
+
border-inline-start-color: var(--ss-fg-faint);
|
|
220
338
|
}
|
|
221
339
|
.ss-toast .ic {
|
|
222
340
|
display: inline-flex;
|
|
@@ -280,6 +398,10 @@
|
|
|
280
398
|
font-size: var(--ss-size-h3);
|
|
281
399
|
line-height: 1;
|
|
282
400
|
padding: 0;
|
|
401
|
+
display: inline-grid;
|
|
402
|
+
place-items: center;
|
|
403
|
+
min-inline-size: var(--ss-s-6);
|
|
404
|
+
min-block-size: var(--ss-s-6);
|
|
283
405
|
}
|
|
284
406
|
.ss-toast .x:hover {
|
|
285
407
|
color: var(--ss-fg);
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* Tooltip content (the accessible description of the trigger): a plain string, or a
|
|
11
11
|
* snippet for a small rendered template. Snippets must stay **phrasing content**
|
|
12
12
|
* (`code`, `strong`, `kbd`, `br`, `Icon`, …) and must not contain interactive
|
|
13
|
-
* elements — the tip is
|
|
13
|
+
* elements — the tip is never focusable and is hidden while closed, per the
|
|
14
14
|
* WAI-ARIA tooltip pattern.
|
|
15
15
|
*/
|
|
16
16
|
text: string | Snippet
|
|
@@ -47,18 +47,70 @@
|
|
|
47
47
|
/** Cross-axis nudge in px (x for top/bottom, y for left/right). */
|
|
48
48
|
let shift = $state(0)
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
/** Focusable elements inside the trigger snippet, in the order a hover falls back on. */
|
|
51
|
+
const FOCUSABLE =
|
|
52
|
+
'a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"]), [contenteditable="true"]'
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The element that carries `aria-describedby` while open: the focused trigger on
|
|
56
|
+
* focusin, else the first focusable element in the trigger (a hover), else the
|
|
57
|
+
* trigger's first element. The wrapper `<span>` is never focused, so a description on
|
|
58
|
+
* it would never be read (DS-0163).
|
|
59
|
+
*/
|
|
60
|
+
let describedEl: HTMLElement | null = null
|
|
61
|
+
|
|
62
|
+
function describedTarget(from?: EventTarget | null): HTMLElement | null {
|
|
63
|
+
if (!triggerEl) return null
|
|
64
|
+
if (from instanceof HTMLElement && from !== triggerEl && triggerEl.contains(from)) return from
|
|
65
|
+
return (
|
|
66
|
+
triggerEl.querySelector<HTMLElement>(FOCUSABLE) ??
|
|
67
|
+
(triggerEl.firstElementChild as HTMLElement | null) ??
|
|
68
|
+
triggerEl
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Add/remove `tipId` as one token, so a trigger's own description (e.g. a hint) is kept. */
|
|
73
|
+
function describe(el: HTMLElement | null) {
|
|
74
|
+
if (describedEl === el) return
|
|
75
|
+
undescribe()
|
|
76
|
+
if (!el) return
|
|
77
|
+
const ids = (el.getAttribute('aria-describedby') ?? '').split(/\s+/).filter(Boolean)
|
|
78
|
+
if (!ids.includes(tipId)) el.setAttribute('aria-describedby', [...ids, tipId].join(' '))
|
|
79
|
+
describedEl = el
|
|
80
|
+
}
|
|
81
|
+
function undescribe() {
|
|
82
|
+
const el = describedEl
|
|
83
|
+
describedEl = null
|
|
84
|
+
if (!el) return
|
|
85
|
+
const ids = (el.getAttribute('aria-describedby') ?? '')
|
|
86
|
+
.split(/\s+/)
|
|
87
|
+
.filter((id) => id && id !== tipId)
|
|
88
|
+
if (ids.length) el.setAttribute('aria-describedby', ids.join(' '))
|
|
89
|
+
else el.removeAttribute('aria-describedby')
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function show(e?: Event) {
|
|
51
93
|
open = true
|
|
94
|
+
describe(describedTarget(e?.target))
|
|
52
95
|
}
|
|
53
96
|
function hide() {
|
|
54
97
|
open = false
|
|
98
|
+
undescribe()
|
|
55
99
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
100
|
+
|
|
101
|
+
// Escape dismisses the tooltip wherever focus is (WCAG 1.4.13, WAI-ARIA tooltip
|
|
102
|
+
// pattern): a document-level listener while open, so a hover-opened tip closes too.
|
|
103
|
+
$effect(() => {
|
|
104
|
+
if (!open) return
|
|
105
|
+
const onKeydown = (e: KeyboardEvent) => {
|
|
106
|
+
if (e.key === 'Escape') hide()
|
|
60
107
|
}
|
|
61
|
-
|
|
108
|
+
document.addEventListener('keydown', onKeydown)
|
|
109
|
+
return () => document.removeEventListener('keydown', onKeydown)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
// Unmounting while open must not leave a dangling id on the trigger.
|
|
113
|
+
$effect(() => () => undescribe())
|
|
62
114
|
|
|
63
115
|
const sizeAttr = $derived(resolveComponentSize('Tooltip', size))
|
|
64
116
|
|
|
@@ -173,9 +225,12 @@
|
|
|
173
225
|
<!--
|
|
174
226
|
Inline-block wrapper around the trigger snippet. Hover (mouseenter/leave) and
|
|
175
227
|
focus (focusin/out — bubbling, so a focusable child trigger counts) toggle the
|
|
176
|
-
tooltip; Escape dismisses it. While open
|
|
177
|
-
|
|
178
|
-
|
|
228
|
+
tooltip; Escape (a document-level listener while open) dismisses it. While open
|
|
229
|
+
the focusable trigger inside the snippet (not this wrapper) carries
|
|
230
|
+
aria-describedby pointing at the tooltip; the tip itself is kept in the DOM but
|
|
231
|
+
hidden (and given `hidden`) when closed so it is never announced. While open the
|
|
232
|
+
tip is hoverable (it is a child of the wrapper, and a pseudo-element bridges the
|
|
233
|
+
offset gap), so moving the pointer onto it does not close it (WCAG 1.4.13).
|
|
179
234
|
|
|
180
235
|
`text` is either a string or a snippet (DS-0144); a snippet renders inside the
|
|
181
236
|
same tip element, so the accessible description stays whatever the tip contains.
|
|
@@ -186,17 +241,15 @@
|
|
|
186
241
|
-->
|
|
187
242
|
<!-- svelte-ignore a11y_no_static_element_interactions -- the wrapper is a passive
|
|
188
243
|
container; the real interactive element is the trigger snippet inside it, and the
|
|
189
|
-
hover/focus
|
|
244
|
+
hover/focus handlers only react to that child's bubbling events. -->
|
|
190
245
|
<span
|
|
191
246
|
class="ss-tooltip"
|
|
192
247
|
data-size-variant={sizeAttr}
|
|
193
248
|
data-placement={resolved}
|
|
194
|
-
aria-describedby={open ? tipId : undefined}
|
|
195
249
|
onmouseenter={show}
|
|
196
250
|
onmouseleave={hide}
|
|
197
251
|
onfocusin={show}
|
|
198
252
|
onfocusout={hide}
|
|
199
|
-
onkeydown={onKeydown}
|
|
200
253
|
>
|
|
201
254
|
<span class="trigger" bind:this={triggerEl}>{@render children()}</span>
|
|
202
255
|
<span
|
|
@@ -241,9 +294,14 @@
|
|
|
241
294
|
transform: scale(0.98);
|
|
242
295
|
transition: opacity var(--ss-dur) var(--ss-ease), transform var(--ss-dur) var(--ss-ease), visibility 0s linear var(--ss-dur);
|
|
243
296
|
}
|
|
297
|
+
.tip::before {
|
|
298
|
+
content: "";
|
|
299
|
+
position: absolute;
|
|
300
|
+
}
|
|
244
301
|
.tip.open {
|
|
245
302
|
opacity: 1;
|
|
246
303
|
visibility: visible;
|
|
304
|
+
pointer-events: auto;
|
|
247
305
|
transform: scale(1);
|
|
248
306
|
transition: opacity var(--ss-dur) var(--ss-ease), transform var(--ss-dur) var(--ss-ease), visibility 0s linear 0s;
|
|
249
307
|
}
|
|
@@ -292,6 +350,36 @@
|
|
|
292
350
|
transform: translateY(calc(-50% + var(--shift))) scale(1);
|
|
293
351
|
}
|
|
294
352
|
|
|
353
|
+
.ss-tooltip[data-placement=top] .tip::before,
|
|
354
|
+
.ss-tooltip[data-placement=bottom] .tip::before {
|
|
355
|
+
left: 0;
|
|
356
|
+
right: 0;
|
|
357
|
+
height: var(--ss-tooltip-offset, 6px);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.ss-tooltip[data-placement=top] .tip::before {
|
|
361
|
+
top: 100%;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.ss-tooltip[data-placement=bottom] .tip::before {
|
|
365
|
+
bottom: 100%;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.ss-tooltip[data-placement=left] .tip::before,
|
|
369
|
+
.ss-tooltip[data-placement=right] .tip::before {
|
|
370
|
+
top: 0;
|
|
371
|
+
bottom: 0;
|
|
372
|
+
width: var(--ss-tooltip-offset, 6px);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
.ss-tooltip[data-placement=left] .tip::before {
|
|
376
|
+
left: 100%;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.ss-tooltip[data-placement=right] .tip::before {
|
|
380
|
+
right: 100%;
|
|
381
|
+
}
|
|
382
|
+
|
|
295
383
|
@media (prefers-reduced-motion: reduce) {
|
|
296
384
|
.tip,
|
|
297
385
|
.tip.open {
|
|
@@ -7,7 +7,7 @@ interface Props {
|
|
|
7
7
|
* Tooltip content (the accessible description of the trigger): a plain string, or a
|
|
8
8
|
* snippet for a small rendered template. Snippets must stay **phrasing content**
|
|
9
9
|
* (`code`, `strong`, `kbd`, `br`, `Icon`, …) and must not contain interactive
|
|
10
|
-
* elements — the tip is
|
|
10
|
+
* elements — the tip is never focusable and is hidden while closed, per the
|
|
11
11
|
* WAI-ARIA tooltip pattern.
|
|
12
12
|
*/
|
|
13
13
|
text: string | Snippet;
|
|
@@ -118,6 +118,13 @@
|
|
|
118
118
|
),
|
|
119
119
|
)
|
|
120
120
|
|
|
121
|
+
// DS-0182: the roving tab stop is the active tab; when `active` matches no
|
|
122
|
+
// tab, fall back to the first button tab so the strip stays reachable by Tab.
|
|
123
|
+
const rovingIdx = $derived.by(() => {
|
|
124
|
+
const i = items.findIndex((t) => t.id === active)
|
|
125
|
+
return i >= 0 ? i : items.findIndex((t) => !t.href)
|
|
126
|
+
})
|
|
127
|
+
|
|
121
128
|
// DS-0081: resolve the services prop to data-or-nothing.
|
|
122
129
|
const svc = $derived(services === true ? DEFAULT_SERVICES : services === false ? null : services)
|
|
123
130
|
|
|
@@ -239,7 +246,7 @@
|
|
|
239
246
|
type="button"
|
|
240
247
|
class="tab {current ? 'active' : ''}"
|
|
241
248
|
aria-current={current ? 'page' : undefined}
|
|
242
|
-
tabindex={
|
|
249
|
+
tabindex={i === rovingIdx ? 0 : -1}
|
|
243
250
|
onclick={() => onTab?.(tab.id)}
|
|
244
251
|
onkeydown={(e) => onTabKeydown(e, i)}
|
|
245
252
|
>
|
|
@@ -312,8 +319,8 @@
|
|
|
312
319
|
}
|
|
313
320
|
.ss-topbar .skip {
|
|
314
321
|
position: absolute;
|
|
315
|
-
|
|
316
|
-
|
|
322
|
+
inset-inline-start: var(--ss-s-1);
|
|
323
|
+
inset-block-start: var(--ss-s-1);
|
|
317
324
|
z-index: 20;
|
|
318
325
|
padding: var(--ss-chip-py) var(--ss-badge-px);
|
|
319
326
|
background: var(--ss-primary);
|
|
@@ -331,13 +338,13 @@
|
|
|
331
338
|
align-items: center;
|
|
332
339
|
gap: var(--ss-s-2);
|
|
333
340
|
padding: 0 var(--ss-panel-head-px);
|
|
334
|
-
border-
|
|
341
|
+
border-inline-end: 1px solid var(--ss-line);
|
|
335
342
|
cursor: default;
|
|
336
343
|
flex: none;
|
|
337
344
|
}
|
|
338
345
|
.ss-topbar .seg.right {
|
|
339
|
-
border-
|
|
340
|
-
border-
|
|
346
|
+
border-inline-end: none;
|
|
347
|
+
border-inline-start: 1px solid var(--ss-line);
|
|
341
348
|
}
|
|
342
349
|
.ss-topbar .seg.click {
|
|
343
350
|
cursor: pointer;
|
|
@@ -348,15 +355,14 @@
|
|
|
348
355
|
}
|
|
349
356
|
.ss-topbar button.seg {
|
|
350
357
|
background: transparent;
|
|
351
|
-
border-
|
|
352
|
-
border-
|
|
353
|
-
border-right: 0;
|
|
358
|
+
border-block: 0;
|
|
359
|
+
border-inline-end: 0;
|
|
354
360
|
color: inherit;
|
|
355
361
|
font: inherit;
|
|
356
362
|
min-height: var(--ss-s-6);
|
|
357
363
|
}
|
|
358
364
|
.ss-topbar button.seg.right {
|
|
359
|
-
border-
|
|
365
|
+
border-inline-start: 1px solid var(--ss-line);
|
|
360
366
|
}
|
|
361
367
|
.ss-topbar .logo {
|
|
362
368
|
color: var(--ss-fg);
|
|
@@ -385,13 +391,12 @@
|
|
|
385
391
|
padding: 0 var(--ss-row-px);
|
|
386
392
|
min-height: var(--ss-s-6);
|
|
387
393
|
color: var(--ss-fg-faint);
|
|
388
|
-
border-
|
|
394
|
+
border-inline-end: 1px solid var(--ss-line);
|
|
389
395
|
cursor: pointer;
|
|
390
396
|
font: 500 var(--ss-ui-md) var(--ss-font-mono);
|
|
391
397
|
background: transparent;
|
|
392
|
-
border-
|
|
393
|
-
border-
|
|
394
|
-
border-left: 0;
|
|
398
|
+
border-block: 0;
|
|
399
|
+
border-inline-start: 0;
|
|
395
400
|
text-decoration: none;
|
|
396
401
|
transition: all var(--ss-dur-fast) var(--ss-ease);
|
|
397
402
|
}
|
|
@@ -401,7 +406,7 @@
|
|
|
401
406
|
}
|
|
402
407
|
.ss-topbar .ws .tab .n {
|
|
403
408
|
color: var(--ss-fg-faint);
|
|
404
|
-
margin-
|
|
409
|
+
margin-inline-end: 6px;
|
|
405
410
|
}
|
|
406
411
|
.ss-topbar .ws .tab.active {
|
|
407
412
|
color: var(--ss-fg);
|
|
@@ -425,7 +430,7 @@
|
|
|
425
430
|
}
|
|
426
431
|
.ss-topbar .stat .k {
|
|
427
432
|
color: var(--ss-fg-faint);
|
|
428
|
-
margin-
|
|
433
|
+
margin-inline-end: var(--ss-s-1);
|
|
429
434
|
}
|
|
430
435
|
.ss-topbar .stat .v {
|
|
431
436
|
color: var(--ss-fg);
|
package/dist/icons.d.ts
CHANGED
|
@@ -41,15 +41,32 @@ export type IconName = keyof typeof BUILTIN_PATHS;
|
|
|
41
41
|
* (`PATHS` is kept as the public name for backward compatibility.)
|
|
42
42
|
*/
|
|
43
43
|
export declare const PATHS: Record<string, string>;
|
|
44
|
+
/**
|
|
45
|
+
* Strip `<script>`, `<foreignObject>`, `on*` event-handler attributes and `javascript:`
|
|
46
|
+
* links from SVG inner markup. Repeats until stable so split-up payloads can't reassemble.
|
|
47
|
+
*
|
|
48
|
+
* This is a light filter, **not** a security boundary: a regex can't fully parse markup.
|
|
49
|
+
* Markup passed to `registerIcon` or Icon's `paths` must still be trusted (authored by you,
|
|
50
|
+
* never user input).
|
|
51
|
+
*/
|
|
52
|
+
export declare function sanitizeIconMarkup(markup: string): string;
|
|
44
53
|
/**
|
|
45
54
|
* Register (or override) a glyph at runtime so `<Icon name="foo" />` resolves
|
|
46
55
|
* raw SVG inner markup that isn't part of the curated {@link IconName} union.
|
|
47
|
-
* The markup is rendered
|
|
56
|
+
* The markup is rendered inside the icon's `<svg viewBox="0 0 24 24">` after a light
|
|
57
|
+
* {@link sanitizeIconMarkup} pass.
|
|
58
|
+
*
|
|
59
|
+
* **Trust requirement:** `paths` is injected as HTML. Only pass markup you control (your own
|
|
60
|
+
* icon set, a vetted file); never user-supplied or third-party strings. The filter removes
|
|
61
|
+
* obvious script vectors but is not a substitute for that.
|
|
48
62
|
*
|
|
49
63
|
* registerIcon('heart', '<path d="M12 21 4 13a5 5 0 0 1 7-7l1 1 1-1a5 5 0 0 1 7 7z"/>')
|
|
50
64
|
* <Icon name={'heart' as IconName} />
|
|
51
65
|
*/
|
|
52
66
|
export declare function registerIcon(name: string, paths: string): void;
|
|
53
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Look a glyph up; built-ins first, then runtime registrations. Registered markup comes back
|
|
69
|
+
* through {@link sanitizeIconMarkup} (also covers direct writes to the public `PATHS` record).
|
|
70
|
+
*/
|
|
54
71
|
export declare function resolveIcon(name: string): string | undefined;
|
|
55
72
|
export {};
|