dssoca 0.17.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.
Files changed (81) hide show
  1. package/README.md +9 -6
  2. package/dist/chart-nav.d.ts +13 -0
  3. package/dist/chart-nav.js +35 -0
  4. package/dist/components/Accordion.svelte +7 -2
  5. package/dist/components/Badge.svelte +12 -7
  6. package/dist/components/Badge.svelte.d.ts +2 -1
  7. package/dist/components/BottomNav.svelte +4 -0
  8. package/dist/components/BoxPlot.svelte +33 -7
  9. package/dist/components/BumpChart.svelte +68 -26
  10. package/dist/components/Button.svelte +23 -1
  11. package/dist/components/Button.svelte.d.ts +5 -1
  12. package/dist/components/Card.svelte +48 -15
  13. package/dist/components/Card.svelte.d.ts +10 -1
  14. package/dist/components/Chart.svelte +169 -32
  15. package/dist/components/Chart.svelte.d.ts +13 -1
  16. package/dist/components/DateField.svelte +1 -1
  17. package/dist/components/FileDrop.svelte +81 -14
  18. package/dist/components/FileDrop.svelte.d.ts +6 -0
  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/Input.svelte +6 -3
  24. package/dist/components/Kbd.svelte +17 -1
  25. package/dist/components/Kbd.svelte.d.ts +9 -0
  26. package/dist/components/Link.svelte +25 -14
  27. package/dist/components/LogStream.svelte +34 -9
  28. package/dist/components/Menu.svelte +12 -8
  29. package/dist/components/Menu.svelte.d.ts +2 -2
  30. package/dist/components/MetricTile.svelte +16 -2
  31. package/dist/components/MetricTile.svelte.d.ts +6 -0
  32. package/dist/components/Modal.svelte +47 -7
  33. package/dist/components/Modal.svelte.d.ts +11 -3
  34. package/dist/components/NumberField.svelte +33 -10
  35. package/dist/components/Pagination.svelte +7 -4
  36. package/dist/components/ScatterPlot.svelte +44 -7
  37. package/dist/components/SearchPalette.svelte +102 -23
  38. package/dist/components/SearchPalette.svelte.d.ts +5 -0
  39. package/dist/components/SegmentedControl.svelte +14 -5
  40. package/dist/components/Select.svelte +3 -4
  41. package/dist/components/ServiceCard.svelte +108 -68
  42. package/dist/components/ServiceCard.svelte.d.ts +8 -3
  43. package/dist/components/ShortcutsHelp.svelte +3 -2
  44. package/dist/components/Sidebar.svelte +84 -59
  45. package/dist/components/Sidebar.svelte.d.ts +5 -0
  46. package/dist/components/Switch.svelte +4 -8
  47. package/dist/components/Table.svelte +20 -13
  48. package/dist/components/Table.svelte.d.ts +6 -2
  49. package/dist/components/Textarea.svelte +1 -1
  50. package/dist/components/TierList.svelte +598 -0
  51. package/dist/components/TierList.svelte.d.ts +37 -0
  52. package/dist/components/Toaster.svelte +144 -21
  53. package/dist/components/Tooltip.svelte +101 -13
  54. package/dist/components/Tooltip.svelte.d.ts +1 -1
  55. package/dist/components/Topbar.svelte +39 -16
  56. package/dist/dssoca.config.d.ts +1 -1
  57. package/dist/dssoca.config.js +1 -0
  58. package/dist/icons.d.ts +20 -2
  59. package/dist/icons.js +43 -3
  60. package/dist/index.d.ts +3 -1
  61. package/dist/index.js +4 -1
  62. package/dist/theme.css +25 -27
  63. package/dist/tierlist-core.d.ts +97 -0
  64. package/dist/tierlist-core.js +206 -0
  65. package/dist/tokens.css +25 -0
  66. package/dist/vanilla/accordion.js +7 -3
  67. package/dist/vanilla/fields.js +19 -6
  68. package/dist/vanilla/index.d.ts +2 -1
  69. package/dist/vanilla/index.js +7 -4
  70. package/dist/vanilla/menu.js +12 -1
  71. package/dist/vanilla/modal.d.ts +4 -0
  72. package/dist/vanilla/modal.js +57 -2
  73. package/dist/vanilla/segmented.js +13 -4
  74. package/dist/vanilla/tierlist.d.ts +8 -0
  75. package/dist/vanilla/tierlist.js +300 -0
  76. package/dist/vanilla/toast.d.ts +11 -3
  77. package/dist/vanilla/toast.js +125 -10
  78. package/dist/vanilla/tooltip.d.ts +5 -1
  79. package/dist/vanilla/tooltip.js +57 -10
  80. package/dist/vanilla.css +581 -158
  81. package/package.json +4 -1
@@ -0,0 +1,598 @@
1
+ <script module lang="ts">
2
+ // Public types, re-exported from the framework-free core so `import { TierList, type
3
+ // TierListTier } from 'dssoca'` reads naturally (aliases: the svelte eslint plugin misreads a
4
+ // bare `export type … from` in a module script as an import assignment).
5
+ import type {
6
+ TierListTier as CoreTier,
7
+ TierListItem as CoreItem,
8
+ TierListPlacements as CorePlacements,
9
+ } from '../tierlist-core.js'
10
+ export type TierListTier = CoreTier
11
+ export type TierListItem = CoreItem
12
+ export type TierListPlacements = CorePlacements
13
+ </script>
14
+
15
+ <script lang="ts">
16
+ // ─────────────────────────────────────────────────────────────────────────
17
+ // TierList (DS-0159). Labelled tier rows (S/A/B/C/D … + an unranked tray)
18
+ // holding draggable tiles. Presentational and token-driven: it owns the rows,
19
+ // the tiles, pointer drag-and-drop between/within rows and the keyboard
20
+ // equivalent (WCAG 2.2 SC 2.5.7 needs a non-drag path), and hands the
21
+ // consumer the resulting placements. What a tile *shows* is the consumer's
22
+ // `tile` snippet; persistence, export and the like stay outside.
23
+ //
24
+ // Interaction model (mirrors dnd-kit's keyboard sensor): Space picks a tile
25
+ // up, arrows move it — left/right within the row, up/down to the neighbouring
26
+ // row — Space drops, Escape cancels; every step is read out by a polite live
27
+ // region. Pointer drag (Pointer Events, so touch works too) reorders live
28
+ // with a ghost under the pointer and commits on release. Enter activates
29
+ // `onselect` when given (a details view), else behaves like Space.
30
+ //
31
+ // Data: `placements` is tier id → ordered item ids; items in no tier sit in
32
+ // the tray. Controlled-with-callback (`bind:placements` + `onchange`), like
33
+ // the rest of the library; unmanaged when neither is passed.
34
+ // ─────────────────────────────────────────────────────────────────────────
35
+ import { tick, untrack, type Snippet } from 'svelte'
36
+ import { flip } from 'svelte/animate'
37
+ import { prefersReducedMotion } from 'svelte/motion'
38
+ import { resolveComponentSize, type Size } from '../config.js'
39
+ import {
40
+ DEFAULT_TIERS,
41
+ TILE_INSTRUCTIONS,
42
+ TRAY,
43
+ announceText,
44
+ buildZones,
45
+ insertionIndex,
46
+ keyMoveFor,
47
+ keyboardTarget,
48
+ locate,
49
+ moveItem,
50
+ placementsOf,
51
+ tierColor,
52
+ zonesEqual,
53
+ type TierListZones,
54
+ } from '../tierlist-core.js'
55
+
56
+ interface Props {
57
+ /** The rows, top to bottom. Defaults to S / A / B / C / D. */
58
+ tiers?: readonly TierListTier[]
59
+ /** Every rankable item. Items in no tier are shown in the tray. */
60
+ items: readonly TierListItem[]
61
+ /**
62
+ * Tier id → ordered item ids (bindable). Omit to let the component manage the
63
+ * order itself; the tray is never part of it.
64
+ */
65
+ placements?: TierListPlacements
66
+ /** Fired after every drop / keyboard drop with the new placements. */
67
+ onchange?: (placements: TierListPlacements) => void
68
+ /**
69
+ * Activation (Enter, or a click that isn't a drag) — e.g. open a details view.
70
+ * When omitted, Enter picks the tile up like Space.
71
+ */
72
+ onselect?: (item: TierListItem) => void
73
+ /** Tile content. Defaults to the item's label; images/cards go here. */
74
+ tile?: Snippet<[TierListItem]>
75
+ /** Label of the unranked tray, or `false` to hide the tray (every item must then be placed). */
76
+ tray?: string | false
77
+ /** Accessible name of the whole list. */
78
+ label?: string
79
+ /** Display only: no drag, no keyboard sorting; tiles are plain boxes. */
80
+ readonly?: boolean
81
+ /** Token size (sm|md|lg); inherits the global size when unset. */
82
+ size?: Size
83
+ }
84
+
85
+ let {
86
+ tiers = DEFAULT_TIERS,
87
+ items,
88
+ placements = $bindable(),
89
+ onchange,
90
+ onselect,
91
+ tile,
92
+ tray = 'Unranked',
93
+ label = 'Tier list',
94
+ readonly = false,
95
+ size,
96
+ }: Props = $props()
97
+
98
+ const uid = $props.id()
99
+ const hintId = `ss-tier-${uid}-hint`
100
+ const letterId = (tier: TierListTier) => `ss-tier-${uid}-${tier.id}`
101
+
102
+ // --- zones ---------------------------------------------------------------
103
+ // The working order. Re-derived from props whenever they change (a bound
104
+ // `placements` echoing our own commit lands on an equal map, so no churn);
105
+ // the tray keeps the order the user gave it.
106
+ let zones = $state<TierListZones>(untrack(() => buildZones(tiers, items, placements)))
107
+ $effect(() => {
108
+ const current = untrack(() => zones)
109
+ const next = buildZones(tiers, items, placements ?? placementsOf(current, tiers), current)
110
+ if (!zonesEqual(next, current)) zones = next
111
+ })
112
+
113
+ const byId = $derived(new Map(items.map((i) => [i.id, i])))
114
+ const zoneOrder = $derived([...tiers.map((t) => t.id), ...(tray === false ? [] : [TRAY])])
115
+ const zoneLabel = (zone: string): string =>
116
+ zone === TRAY ? tray || 'Unranked' : (tiers.find((t) => t.id === zone)?.label ?? zone)
117
+ const zoneItems = (zone: string): TierListItem[] =>
118
+ (zones[zone] ?? []).flatMap((id) => {
119
+ const it = byId.get(id)
120
+ return it ? [it] : []
121
+ })
122
+
123
+ function commit(next: TierListZones) {
124
+ zones = next
125
+ const p = placementsOf(next, tiers)
126
+ if (placements !== undefined) placements = p
127
+ onchange?.(p)
128
+ }
129
+
130
+ function describe(id: string) {
131
+ const at = locate(zones, id)!
132
+ return {
133
+ label: byId.get(id)?.label ?? id,
134
+ zone: zoneLabel(at.zone),
135
+ index: at.index,
136
+ count: zones[at.zone].length,
137
+ }
138
+ }
139
+
140
+ // --- live region ---------------------------------------------------------
141
+ let announcement = $state('')
142
+ const announce = (text: string) => (announcement = text)
143
+
144
+ // --- keyboard sorting ----------------------------------------------------
145
+ let grabbed = $state<{ id: string; origin: TierListZones } | null>(null)
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'
148
+
149
+ function toggleGrab(id: string) {
150
+ if (grabbed?.id === id) {
151
+ const origin = grabbed.origin
152
+ grabbed = null
153
+ announce(announceText('drop', describe(id)))
154
+ if (!zonesEqual(origin, zones)) commit(zones)
155
+ return
156
+ }
157
+ grabbed = { id, origin: zones }
158
+ announce(announceText('grab', describe(id)))
159
+ }
160
+
161
+ // `focusBack`: Escape keeps the user on the tile; a cancel caused by focus leaving
162
+ // (Tab, a click elsewhere) must not pull focus back — that would be a trap.
163
+ function cancelGrab(focusBack: boolean) {
164
+ if (!grabbed) return
165
+ const { id, origin } = grabbed
166
+ grabbed = null
167
+ zones = origin
168
+ announce(announceText('cancel', describe(id)))
169
+ if (focusBack) void refocus(id)
170
+ }
171
+
172
+ // Every keyboard move re-inserts the tile's node (a row change even re-creates it in the
173
+ // other row's keyed block), and browsers blur a node that leaves the document — so focus is
174
+ // put back after the DOM settles, and the blur that causes must not read as a cancel.
175
+ let refocusing = false
176
+ async function refocus(id: string) {
177
+ refocusing = true
178
+ await tick()
179
+ root?.querySelector<HTMLElement>(`.tile[data-item="${CSS.escape(id)}"]`)?.focus()
180
+ refocusing = false
181
+ }
182
+
183
+ function onTileKeydown(e: KeyboardEvent, item: TierListItem) {
184
+ if (readonly) return
185
+ if (e.key === ' ' || (e.key === 'Enter' && !onselect)) {
186
+ e.preventDefault()
187
+ toggleGrab(item.id)
188
+ return
189
+ }
190
+ if (e.key === 'Enter') {
191
+ e.preventDefault()
192
+ onselect?.(item)
193
+ return
194
+ }
195
+ if (grabbed?.id !== item.id) return
196
+ if (e.key === 'Escape') {
197
+ e.preventDefault()
198
+ cancelGrab(true)
199
+ return
200
+ }
201
+ const move = keyMoveFor(e.key, isRtl(e.currentTarget as Element))
202
+ if (!move) return
203
+ e.preventDefault()
204
+ const target = keyboardTarget(zones, zoneOrder, item.id, move)
205
+ if (!target) return
206
+ zones = moveItem(zones, item.id, target.zone, target.index)
207
+ announce(announceText('move', describe(item.id)))
208
+ void refocus(item.id)
209
+ }
210
+
211
+ // Leaving the tile while it is picked up (Tab, a click elsewhere) cancels —
212
+ // the WAI-ARIA convention; nothing moves without an explicit drop. Checked a
213
+ // beat later: a cross-row move re-creates the node (blur, then our refocus),
214
+ // and browsers differ on whether removal even fires blur, so only a focus
215
+ // that has really left the tile counts.
216
+ function onTileBlur(item: TierListItem) {
217
+ if (grabbed?.id !== item.id) return
218
+ setTimeout(() => {
219
+ if (grabbed?.id !== item.id || refocusing) return
220
+ const el = root?.querySelector<HTMLElement>(`.tile[data-item="${CSS.escape(item.id)}"]`)
221
+ if (el && document.activeElement === el) return
222
+ cancelGrab(false)
223
+ }, 0)
224
+ }
225
+
226
+ // --- pointer drag --------------------------------------------------------
227
+ interface Drag {
228
+ id: string
229
+ origin: TierListZones
230
+ startX: number
231
+ startY: number
232
+ active: boolean
233
+ x: number
234
+ y: number
235
+ dx: number
236
+ dy: number
237
+ w: number
238
+ h: number
239
+ zone: string | null
240
+ }
241
+ let drag = $state<Drag | null>(null)
242
+ let root: HTMLElement | undefined = $state()
243
+ const DRAG_THRESHOLD = 4
244
+ let suppressClick = false
245
+
246
+ // The drag listens on `window`, not the tile: the live preview moves the
247
+ // dragged item between rows, and a row change re-creates its node — pointer
248
+ // capture on the old node would die with it and the drag would hang.
249
+ function listen() {
250
+ window.addEventListener('pointermove', onPointerMove)
251
+ window.addEventListener('pointerup', onPointerUp)
252
+ window.addEventListener('pointercancel', onPointerCancel)
253
+ }
254
+ function unlisten() {
255
+ window.removeEventListener('pointermove', onPointerMove)
256
+ window.removeEventListener('pointerup', onPointerUp)
257
+ window.removeEventListener('pointercancel', onPointerCancel)
258
+ }
259
+ $effect(() => unlisten)
260
+
261
+ function onPointerDown(e: PointerEvent, item: TierListItem) {
262
+ if (readonly || e.button !== 0 || grabbed) return
263
+ const tileEl = e.currentTarget as HTMLElement
264
+ const rect = tileEl.getBoundingClientRect()
265
+ listen()
266
+ drag = {
267
+ id: item.id,
268
+ origin: zones,
269
+ startX: e.clientX,
270
+ startY: e.clientY,
271
+ active: false,
272
+ x: e.clientX,
273
+ y: e.clientY,
274
+ dx: e.clientX - rect.left,
275
+ dy: e.clientY - rect.top,
276
+ w: rect.width,
277
+ h: rect.height,
278
+ zone: null,
279
+ }
280
+ }
281
+
282
+ function zoneAt(x: number, y: number): string | null {
283
+ if (!root || typeof document.elementsFromPoint !== 'function') return null
284
+ for (const el of document.elementsFromPoint(x, y)) {
285
+ const zone = el.closest<HTMLElement>('[data-zone]')
286
+ if (zone && root.contains(zone)) {
287
+ return zone.hasAttribute('data-tray') ? TRAY : (zone.dataset.zone as string)
288
+ }
289
+ }
290
+ return null
291
+ }
292
+
293
+ function onPointerMove(e: PointerEvent) {
294
+ if (!drag) return
295
+ if (!drag.active) {
296
+ if (Math.hypot(e.clientX - drag.startX, e.clientY - drag.startY) < DRAG_THRESHOLD) return
297
+ drag.active = true
298
+ }
299
+ e.preventDefault()
300
+ drag.x = e.clientX
301
+ drag.y = e.clientY
302
+ const zone = zoneAt(e.clientX, e.clientY)
303
+ if (!zone || !root) return
304
+ drag.zone = zone
305
+ const zoneEl = root.querySelector<HTMLElement>(
306
+ zone === TRAY ? '[data-zone][data-tray]' : `[data-zone="${CSS.escape(zone)}"]`,
307
+ )
308
+ if (!zoneEl) return
309
+ const boxes = Array.from(zoneEl.querySelectorAll<HTMLElement>(':scope > .cell'))
310
+ .filter((c) => c.dataset.item !== drag!.id)
311
+ .map((c) => c.getBoundingClientRect())
312
+ const index = insertionIndex(boxes, e.clientX, e.clientY, isRtl(zoneEl))
313
+ const next = moveItem(zones, drag.id, zone, index)
314
+ if (next !== zones) zones = next
315
+ }
316
+
317
+ function onPointerUp() {
318
+ if (!drag) return
319
+ const d = drag
320
+ drag = null
321
+ unlisten()
322
+ if (!d.active) return
323
+ suppressClick = true
324
+ if (zonesEqual(d.origin, zones)) return
325
+ announce(announceText('drop', describe(d.id)))
326
+ commit(zones)
327
+ }
328
+
329
+ function onPointerCancel() {
330
+ if (!drag) return
331
+ const d = drag
332
+ drag = null
333
+ unlisten()
334
+ if (d.active) zones = d.origin
335
+ }
336
+
337
+ function onTileClick(item: TierListItem) {
338
+ if (suppressClick) {
339
+ suppressClick = false
340
+ return
341
+ }
342
+ if (!readonly) onselect?.(item)
343
+ }
344
+
345
+ const draggedItem = $derived(drag?.active ? byId.get(drag.id) : undefined)
346
+ const sizeAttr = $derived(resolveComponentSize('TierList', size))
347
+ </script>
348
+
349
+ {#snippet tileBody(item: TierListItem)}
350
+ {#if tile}
351
+ {@render tile(item)}
352
+ {:else}
353
+ <span class="name">{item.label}</span>
354
+ {/if}
355
+ {/snippet}
356
+
357
+ {#snippet zone(key: string, isTray: boolean)}
358
+ <ul
359
+ class="zone"
360
+ class:tray={isTray}
361
+ class:target={drag?.active && drag.zone === key}
362
+ data-zone={key}
363
+ data-tray={isTray ? '' : undefined}
364
+ aria-label={zoneLabel(key)}
365
+ >
366
+ {#each zoneItems(key) as item (item.id)}
367
+ <li
368
+ class="cell"
369
+ class:shadow={drag?.active && drag.id === item.id}
370
+ class:grabbed={grabbed?.id === item.id}
371
+ data-item={item.id}
372
+ animate:flip={{ duration: prefersReducedMotion.current ? 0 : 150 }}
373
+ >
374
+ {#if readonly}
375
+ <div class="tile" data-item={item.id} aria-label={item.label} role="img">
376
+ {@render tileBody(item)}
377
+ </div>
378
+ {:else}
379
+ <button
380
+ type="button"
381
+ class="tile"
382
+ data-item={item.id}
383
+ data-ss-activate={onselect ? '' : undefined}
384
+ aria-label={item.label}
385
+ aria-describedby={hintId}
386
+ aria-pressed={grabbed?.id === item.id}
387
+ aria-roledescription="draggable tile"
388
+ onkeydown={(e) => onTileKeydown(e, item)}
389
+ onblur={() => onTileBlur(item)}
390
+ onpointerdown={(e) => onPointerDown(e, item)}
391
+ onclick={() => onTileClick(item)}
392
+ >
393
+ {@render tileBody(item)}
394
+ </button>
395
+ {/if}
396
+ </li>
397
+ {/each}
398
+ </ul>
399
+ {/snippet}
400
+
401
+ <div
402
+ bind:this={root}
403
+ class="ss-tierlist"
404
+ class:sorting={grabbed !== null}
405
+ class:dragging={drag?.active}
406
+ role="group"
407
+ aria-label={label}
408
+ data-size-variant={sizeAttr}
409
+ data-ss-readonly={readonly ? '' : undefined}
410
+ >
411
+ {#if !readonly}
412
+ <p class="sr-only" id={hintId}>{TILE_INSTRUCTIONS}</p>
413
+ <div class="live sr-only" role="status" aria-live="polite" aria-atomic="true">
414
+ {announcement}
415
+ </div>
416
+ {/if}
417
+
418
+ {#each tiers as tier, i (tier.id)}
419
+ <div class="row" data-tier={tier.id} style:--ss-tier-color={tierColor(tier, i)}>
420
+ <div class="letter" id={letterId(tier)}>{tier.label}</div>
421
+ {@render zone(tier.id, false)}
422
+ </div>
423
+ {/each}
424
+
425
+ {#if tray !== false}
426
+ <div class="tray-row">
427
+ <span class="tray-label">{tray}</span>
428
+ {@render zone(TRAY, true)}
429
+ </div>
430
+ {/if}
431
+
432
+ {#if drag?.active && draggedItem}
433
+ <div
434
+ class="tile ghost"
435
+ aria-hidden="true"
436
+ style="width: {drag.w}px; height: {drag.h}px; transform: translate({drag.x -
437
+ drag.dx}px, {drag.y - drag.dy}px)"
438
+ >
439
+ {@render tileBody(draggedItem)}
440
+ </div>
441
+ {/if}
442
+ </div>
443
+
444
+ <style>.ss-tierlist {
445
+ position: relative;
446
+ display: flex;
447
+ flex-direction: column;
448
+ gap: var(--ss-tier-gap);
449
+ font-family: var(--ss-font-body);
450
+ }
451
+ .ss-tierlist .row {
452
+ display: flex;
453
+ align-items: stretch;
454
+ gap: var(--ss-tier-gap);
455
+ }
456
+ .ss-tierlist .letter {
457
+ flex: none;
458
+ width: var(--ss-tier-label-w);
459
+ display: flex;
460
+ align-items: center;
461
+ justify-content: center;
462
+ font-family: var(--ss-font-display);
463
+ font-size: var(--ss-tier-label-font);
464
+ color: var(--ss-tier-color);
465
+ border: 1px solid color-mix(in srgb, var(--ss-tier-color) 40%, transparent);
466
+ background: color-mix(in srgb, var(--ss-tier-color) 12%, transparent);
467
+ overflow-wrap: anywhere;
468
+ text-align: center;
469
+ }
470
+ .ss-tierlist .zone {
471
+ flex: 1;
472
+ min-width: 0;
473
+ display: flex;
474
+ flex-wrap: wrap;
475
+ align-items: center;
476
+ align-content: flex-start;
477
+ gap: var(--ss-tier-gap);
478
+ min-height: calc(var(--ss-tier-tile-h) + 2 * var(--ss-tier-gap) + 2px);
479
+ margin: 0;
480
+ padding: var(--ss-tier-gap);
481
+ list-style: none;
482
+ border: 1px solid var(--ss-line);
483
+ background: var(--ss-bg-elev);
484
+ box-sizing: border-box;
485
+ transition: outline-color var(--ss-dur-fast) var(--ss-ease);
486
+ }
487
+ .ss-tierlist .zone.target {
488
+ outline: 1px dashed var(--ss-accent);
489
+ outline-offset: 2px;
490
+ }
491
+ .ss-tierlist .tray-row {
492
+ display: flex;
493
+ flex-direction: column;
494
+ gap: var(--ss-s-1);
495
+ margin-top: var(--ss-s-1);
496
+ padding-top: var(--ss-s-2);
497
+ border-top: 1px solid var(--ss-line);
498
+ }
499
+ .ss-tierlist .tray-label {
500
+ font-family: var(--ss-font-mono);
501
+ font-size: var(--ss-ui-xs);
502
+ letter-spacing: 0.04em;
503
+ text-transform: uppercase;
504
+ color: var(--ss-fg-faint);
505
+ }
506
+ .ss-tierlist .zone.tray {
507
+ background: var(--ss-bg-inset);
508
+ }
509
+ .ss-tierlist .cell {
510
+ display: block;
511
+ list-style: none;
512
+ }
513
+ .ss-tierlist .tile {
514
+ width: var(--ss-tier-tile-w);
515
+ height: var(--ss-tier-tile-h);
516
+ display: flex;
517
+ align-items: flex-end;
518
+ padding: 0;
519
+ margin: 0;
520
+ border: 1px solid var(--ss-line);
521
+ border-radius: 0;
522
+ background: var(--ss-bg-inset);
523
+ color: inherit;
524
+ font: inherit;
525
+ text-align: start;
526
+ overflow: hidden;
527
+ cursor: grab;
528
+ touch-action: none;
529
+ user-select: none;
530
+ -webkit-user-select: none;
531
+ transition: border-color var(--ss-dur-fast) var(--ss-ease), box-shadow var(--ss-dur-fast) var(--ss-ease);
532
+ }
533
+ .ss-tierlist .tile:hover {
534
+ border-color: var(--ss-line-strong);
535
+ }
536
+ .ss-tierlist .tile :global(img),
537
+ .ss-tierlist .tile :global(svg),
538
+ .ss-tierlist .tile :global(video) {
539
+ display: block;
540
+ width: 100%;
541
+ height: 100%;
542
+ object-fit: cover;
543
+ }
544
+ .ss-tierlist .name {
545
+ padding: var(--ss-s-1);
546
+ font-family: var(--ss-font-mono);
547
+ font-size: var(--ss-ui-xs);
548
+ line-height: 1.3;
549
+ color: var(--ss-fg-muted);
550
+ overflow: hidden;
551
+ display: -webkit-box;
552
+ -webkit-box-orient: vertical;
553
+ -webkit-line-clamp: 4;
554
+ line-clamp: 4;
555
+ word-break: break-word;
556
+ }
557
+ .ss-tierlist .cell.grabbed .tile {
558
+ border-color: var(--ss-accent);
559
+ box-shadow: var(--ss-shadow-pop);
560
+ }
561
+ .ss-tierlist .cell.shadow {
562
+ opacity: 0.4;
563
+ }
564
+ .ss-tierlist .cell.shadow .tile {
565
+ border-style: dashed;
566
+ border-color: var(--ss-accent);
567
+ }
568
+ .ss-tierlist .ghost {
569
+ position: fixed;
570
+ left: 0;
571
+ top: 0;
572
+ z-index: 50;
573
+ pointer-events: none;
574
+ border-color: var(--ss-accent);
575
+ box-shadow: var(--ss-shadow-pop);
576
+ opacity: 0.92;
577
+ cursor: grabbing;
578
+ }
579
+ .ss-tierlist.dragging {
580
+ user-select: none;
581
+ }
582
+ .ss-tierlist.dragging .tile {
583
+ cursor: grabbing;
584
+ }
585
+ .ss-tierlist[data-ss-readonly] .tile {
586
+ cursor: default;
587
+ }
588
+ .ss-tierlist .sr-only {
589
+ position: absolute;
590
+ width: 1px;
591
+ height: 1px;
592
+ padding: 0;
593
+ margin: -1px;
594
+ overflow: hidden;
595
+ clip: rect(0 0 0 0);
596
+ white-space: nowrap;
597
+ border: 0;
598
+ }</style>
@@ -0,0 +1,37 @@
1
+ import type { TierListTier as CoreTier, TierListItem as CoreItem, TierListPlacements as CorePlacements } from '../tierlist-core.js';
2
+ export type TierListTier = CoreTier;
3
+ export type TierListItem = CoreItem;
4
+ export type TierListPlacements = CorePlacements;
5
+ import { type Snippet } from 'svelte';
6
+ import { type Size } from '../config.js';
7
+ interface Props {
8
+ /** The rows, top to bottom. Defaults to S / A / B / C / D. */
9
+ tiers?: readonly TierListTier[];
10
+ /** Every rankable item. Items in no tier are shown in the tray. */
11
+ items: readonly TierListItem[];
12
+ /**
13
+ * Tier id → ordered item ids (bindable). Omit to let the component manage the
14
+ * order itself; the tray is never part of it.
15
+ */
16
+ placements?: TierListPlacements;
17
+ /** Fired after every drop / keyboard drop with the new placements. */
18
+ onchange?: (placements: TierListPlacements) => void;
19
+ /**
20
+ * Activation (Enter, or a click that isn't a drag) — e.g. open a details view.
21
+ * When omitted, Enter picks the tile up like Space.
22
+ */
23
+ onselect?: (item: TierListItem) => void;
24
+ /** Tile content. Defaults to the item's label; images/cards go here. */
25
+ tile?: Snippet<[TierListItem]>;
26
+ /** Label of the unranked tray, or `false` to hide the tray (every item must then be placed). */
27
+ tray?: string | false;
28
+ /** Accessible name of the whole list. */
29
+ label?: string;
30
+ /** Display only: no drag, no keyboard sorting; tiles are plain boxes. */
31
+ readonly?: boolean;
32
+ /** Token size (sm|md|lg); inherits the global size when unset. */
33
+ size?: Size;
34
+ }
35
+ declare const TierList: import("svelte").Component<Props, {}, "placements">;
36
+ type TierList = ReturnType<typeof TierList>;
37
+ export default TierList;