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