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
package/dist/dssoca.config.js
CHANGED
package/dist/icons.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ declare const BUILTIN_PATHS: {
|
|
|
33
33
|
readonly linkedin: "<rect x=\"3\" y=\"3\" width=\"18\" height=\"18\"/><path d=\"M8 16v-5M8 8v.01M12 16v-5h2l2 2v3\"/>";
|
|
34
34
|
readonly language: "<circle cx=\"12\" cy=\"12\" r=\"9\"/><path d=\"M3 12h18M12 3L8 12l4 9M12 3l4 9-4 9\"/>";
|
|
35
35
|
readonly 'color-swatch': "<rect x=\"3\" y=\"3\" width=\"8\" height=\"18\"/><path d=\"M7 17v.01\"/><path d=\"M11 19l8-8 2 2-8 8\"/><path d=\"M13 21h8\"/>";
|
|
36
|
+
readonly search: "<circle cx=\"10.5\" cy=\"10.5\" r=\"6.5\"/><path d=\"M15.5 15.5L21 21\"/>";
|
|
36
37
|
};
|
|
37
38
|
export type IconName = keyof typeof BUILTIN_PATHS;
|
|
38
39
|
/**
|
package/dist/icons.js
CHANGED
|
@@ -33,6 +33,7 @@ const BUILTIN_PATHS = {
|
|
|
33
33
|
linkedin: '<rect x="3" y="3" width="18" height="18"/><path d="M8 16v-5M8 8v.01M12 16v-5h2l2 2v3"/>',
|
|
34
34
|
language: '<circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3L8 12l4 9M12 3l4 9-4 9"/>',
|
|
35
35
|
'color-swatch': '<rect x="3" y="3" width="8" height="18"/><path d="M7 17v.01"/><path d="M11 19l8-8 2 2-8 8"/><path d="M13 21h8"/>',
|
|
36
|
+
search: '<circle cx="10.5" cy="10.5" r="6.5"/><path d="M15.5 15.5L21 21"/>',
|
|
36
37
|
};
|
|
37
38
|
/**
|
|
38
39
|
* The curated built-in glyphs plus any runtime-registered ones.
|
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ export { default as ScatterPlot, type ScatterPoint } from './components/ScatterP
|
|
|
46
46
|
export { default as BoxPlot, type BoxGroup } from './components/BoxPlot.svelte';
|
|
47
47
|
export { default as BumpChart, type BumpSeries } from './components/BumpChart.svelte';
|
|
48
48
|
export { default as Heatmap } from './components/Heatmap.svelte';
|
|
49
|
+
export { default as TierList } from './components/TierList.svelte';
|
|
50
|
+
export { DEFAULT_TIERS as TIERLIST_DEFAULT_TIERS, type TierListTier, type TierListItem, type TierListPlacements, } from './tierlist-core.js';
|
|
49
51
|
export { default as Kbd } from './components/Kbd.svelte';
|
|
50
52
|
export { default as ShortcutsHelp } from './components/ShortcutsHelp.svelte';
|
|
51
53
|
export { shortcuts, shortcut, formatShortcut, ariaKeyshortcuts, type ShortcutOptions, type ShortcutInfo, type ShortcutOverride, type ShortcutOverrides, type ShortcutScope, type ShortcutPlatform, type ShortcutFormat, type FormatShortcutOptions, } from './shortcuts.svelte.js';
|
package/dist/index.js
CHANGED
|
@@ -53,6 +53,9 @@ export { default as ScatterPlot } from './components/ScatterPlot.svelte';
|
|
|
53
53
|
export { default as BoxPlot } from './components/BoxPlot.svelte';
|
|
54
54
|
export { default as BumpChart } from './components/BumpChart.svelte';
|
|
55
55
|
export { default as Heatmap } from './components/Heatmap.svelte';
|
|
56
|
+
// TierList (DS-0159): ranked rows + tray with pointer and keyboard sorting.
|
|
57
|
+
export { default as TierList } from './components/TierList.svelte';
|
|
58
|
+
export { DEFAULT_TIERS as TIERLIST_DEFAULT_TIERS, } from './tierlist-core.js';
|
|
56
59
|
// Keyboard-shortcuts feature (DS-0135): registry core + display chip.
|
|
57
60
|
export { default as Kbd } from './components/Kbd.svelte';
|
|
58
61
|
export { default as ShortcutsHelp } from './components/ShortcutsHelp.svelte';
|
package/dist/theme.css
CHANGED
|
@@ -611,6 +611,31 @@
|
|
|
611
611
|
--ss-spinner-font: 22px;
|
|
612
612
|
}
|
|
613
613
|
|
|
614
|
+
:root,
|
|
615
|
+
[data-size-variant=md] {
|
|
616
|
+
--ss-tier-tile-w: 108px;
|
|
617
|
+
--ss-tier-tile-h: 108px;
|
|
618
|
+
--ss-tier-label-w: 44px;
|
|
619
|
+
--ss-tier-label-font: var(--ss-ui-lg);
|
|
620
|
+
--ss-tier-gap: 6px;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
[data-size-variant=sm] {
|
|
624
|
+
--ss-tier-tile-w: 84px;
|
|
625
|
+
--ss-tier-tile-h: 84px;
|
|
626
|
+
--ss-tier-label-w: 36px;
|
|
627
|
+
--ss-tier-label-font: var(--ss-ui-md);
|
|
628
|
+
--ss-tier-gap: var(--ss-s-1);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
[data-size-variant=lg] {
|
|
632
|
+
--ss-tier-tile-w: 132px;
|
|
633
|
+
--ss-tier-tile-h: 132px;
|
|
634
|
+
--ss-tier-label-w: 56px;
|
|
635
|
+
--ss-tier-label-font: var(--ss-size-h3);
|
|
636
|
+
--ss-tier-gap: var(--ss-s-2);
|
|
637
|
+
}
|
|
638
|
+
|
|
614
639
|
html {
|
|
615
640
|
font-family: var(--ss-font-body);
|
|
616
641
|
font-size: clamp(16px, 1vw + 12px, 20px);
|
|
@@ -916,33 +941,6 @@ pre {
|
|
|
916
941
|
margin-top: 6px;
|
|
917
942
|
}
|
|
918
943
|
|
|
919
|
-
.ss-table {
|
|
920
|
-
width: 100%;
|
|
921
|
-
border-collapse: collapse;
|
|
922
|
-
}
|
|
923
|
-
.ss-table th,
|
|
924
|
-
.ss-table td {
|
|
925
|
-
text-align: left;
|
|
926
|
-
padding: var(--ss-row-py) var(--ss-row-px);
|
|
927
|
-
font-size: var(--ss-ui-md);
|
|
928
|
-
border-bottom: 1px solid var(--ss-line);
|
|
929
|
-
font-family: var(--ss-font-mono);
|
|
930
|
-
}
|
|
931
|
-
.ss-table th {
|
|
932
|
-
font-size: var(--ss-ui-xs);
|
|
933
|
-
color: var(--ss-fg-faint);
|
|
934
|
-
text-transform: uppercase;
|
|
935
|
-
letter-spacing: 0.1em;
|
|
936
|
-
font-weight: 400;
|
|
937
|
-
padding: var(--ss-row-py) var(--ss-row-px);
|
|
938
|
-
}
|
|
939
|
-
.ss-table tr:hover td {
|
|
940
|
-
background: var(--ss-hover);
|
|
941
|
-
}
|
|
942
|
-
.ss-table .mono {
|
|
943
|
-
color: var(--ss-fg-muted);
|
|
944
|
-
}
|
|
945
|
-
|
|
946
944
|
.ss-footer {
|
|
947
945
|
margin-top: var(--ss-s-3);
|
|
948
946
|
padding-top: var(--ss-s-2);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TierList core (DS-0159) — the framework-free half of the component: the data model, the pure
|
|
3
|
+
* move/keyboard/hit-test math and the live-region wording. `TierList.svelte` and the plain-HTML
|
|
4
|
+
* behaviour (`vanilla/tierlist.ts`) both run on this module, so the two paths cannot drift.
|
|
5
|
+
* No DOM, no Svelte, no runes.
|
|
6
|
+
*/
|
|
7
|
+
/** A row of the list. `color` is any CSS colour (a token `var(--ss-…)` preferred). */
|
|
8
|
+
export interface TierListTier {
|
|
9
|
+
id: string;
|
|
10
|
+
/** Short row label — the "S", "A", "B" letter (or a word). */
|
|
11
|
+
label: string;
|
|
12
|
+
/** Row accent; defaults to a palette slot by row index (see {@link tierColor}). */
|
|
13
|
+
color?: string;
|
|
14
|
+
}
|
|
15
|
+
/** A rankable item. `label` is the tile's accessible name and the default tile text. */
|
|
16
|
+
export interface TierListItem {
|
|
17
|
+
id: string;
|
|
18
|
+
label: string;
|
|
19
|
+
}
|
|
20
|
+
/** Tier id → item ids in row order. Items in no tier sit in the unranked tray. */
|
|
21
|
+
export type TierListPlacements = Record<string, string[]>;
|
|
22
|
+
/** Internal zone map: every tier id plus the tray, each an ordered list of item ids. */
|
|
23
|
+
export type TierListZones = Record<string, string[]>;
|
|
24
|
+
/** Zone key of the unranked tray. Never a valid tier id. */
|
|
25
|
+
export declare const TRAY = "__tray__";
|
|
26
|
+
/** The classic five rows. */
|
|
27
|
+
export declare const DEFAULT_TIERS: readonly TierListTier[];
|
|
28
|
+
/**
|
|
29
|
+
* Default row accents by index: palette slots, never literals (DS-0125). The first five mirror
|
|
30
|
+
* the reference app (accent → cyan → yellow → muted → red); longer lists cycle through the rest.
|
|
31
|
+
*/
|
|
32
|
+
export declare const TIER_COLOR_VARS: readonly string[];
|
|
33
|
+
/** The CSS colour a row uses: its own `color`, else the slot for its index. */
|
|
34
|
+
export declare function tierColor(tier: Pick<TierListTier, 'color'>, index: number): string;
|
|
35
|
+
/**
|
|
36
|
+
* Build the zone map from props. Placement ids that name no item are dropped, an item placed
|
|
37
|
+
* in two tiers keeps its first placement, and everything unplaced goes to the tray — in the
|
|
38
|
+
* order the previous zones had it (so a tray reorder survives a re-render), then `items` order.
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildZones(tiers: readonly TierListTier[], items: readonly TierListItem[], placements?: TierListPlacements, previous?: TierListZones): TierListZones;
|
|
41
|
+
/** Where an item currently sits. `null` when it is in no zone. */
|
|
42
|
+
export declare function locate(zones: TierListZones, itemId: string): {
|
|
43
|
+
zone: string;
|
|
44
|
+
index: number;
|
|
45
|
+
} | null;
|
|
46
|
+
/**
|
|
47
|
+
* Move an item to `toZone` at `toIndex` (clamped to the zone's length, counted after the item
|
|
48
|
+
* has been lifted out). Returns the same object when nothing changes, so callers can compare
|
|
49
|
+
* by identity.
|
|
50
|
+
*/
|
|
51
|
+
export declare function moveItem(zones: TierListZones, itemId: string, toZone: string, toIndex: number): TierListZones;
|
|
52
|
+
/** The public placements: tiers only, in the given tier order; the tray is implicit. */
|
|
53
|
+
export declare function placementsOf(zones: TierListZones, tiers: readonly TierListTier[]): TierListPlacements;
|
|
54
|
+
export declare function zonesEqual(a: TierListZones, b: TierListZones): boolean;
|
|
55
|
+
export type TierListKeyMove = 'left' | 'right' | 'up' | 'down' | 'home' | 'end';
|
|
56
|
+
/**
|
|
57
|
+
* Keyboard sorting target: left/right step within the zone (wrapping is deliberately off —
|
|
58
|
+
* the edges are meaningful), home/end jump within it, up/down move to the neighbouring zone
|
|
59
|
+
* keeping the same position (clamped). `zoneOrder` is the visual order, tray last.
|
|
60
|
+
* Returns `null` when the move is impossible (already at the edge).
|
|
61
|
+
*/
|
|
62
|
+
export declare function keyboardTarget(zones: TierListZones, zoneOrder: readonly string[], itemId: string, move: TierListKeyMove): {
|
|
63
|
+
zone: string;
|
|
64
|
+
index: number;
|
|
65
|
+
} | null;
|
|
66
|
+
/** Axis-aligned box, as `getBoundingClientRect()` gives it. */
|
|
67
|
+
export interface Box {
|
|
68
|
+
left: number;
|
|
69
|
+
right: number;
|
|
70
|
+
top: number;
|
|
71
|
+
bottom: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Insertion index for a pointer at (x, y) among wrapped tiles: every tile whose row ends above
|
|
75
|
+
* the pointer counts as "before", and on the pointer's own row every tile whose centre is left
|
|
76
|
+
* of it. The dragged tile's own box must not be in `cells`.
|
|
77
|
+
*/
|
|
78
|
+
export declare function insertionIndex(cells: readonly Box[], x: number, y: number): number;
|
|
79
|
+
/** Copy for the polite live region — one sentence per step, position 1-based. */
|
|
80
|
+
export declare function announceText(kind: 'grab' | 'move' | 'drop' | 'cancel', d: {
|
|
81
|
+
label: string;
|
|
82
|
+
zone: string;
|
|
83
|
+
index: number;
|
|
84
|
+
count: number;
|
|
85
|
+
}): string;
|
|
86
|
+
/** Screen-reader instructions attached to every tile. */
|
|
87
|
+
export declare const TILE_INSTRUCTIONS = "Press Space to pick up the tile, then the arrow keys to move it between positions and tiers, Space again to drop it, or Escape to cancel.";
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TierList core (DS-0159) — the framework-free half of the component: the data model, the pure
|
|
3
|
+
* move/keyboard/hit-test math and the live-region wording. `TierList.svelte` and the plain-HTML
|
|
4
|
+
* behaviour (`vanilla/tierlist.ts`) both run on this module, so the two paths cannot drift.
|
|
5
|
+
* No DOM, no Svelte, no runes.
|
|
6
|
+
*/
|
|
7
|
+
/** Zone key of the unranked tray. Never a valid tier id. */
|
|
8
|
+
export const TRAY = '__tray__';
|
|
9
|
+
/** The classic five rows. */
|
|
10
|
+
export const DEFAULT_TIERS = Object.freeze([
|
|
11
|
+
{ id: 'S', label: 'S' },
|
|
12
|
+
{ id: 'A', label: 'A' },
|
|
13
|
+
{ id: 'B', label: 'B' },
|
|
14
|
+
{ id: 'C', label: 'C' },
|
|
15
|
+
{ id: 'D', label: 'D' },
|
|
16
|
+
]);
|
|
17
|
+
/**
|
|
18
|
+
* Default row accents by index: palette slots, never literals (DS-0125). The first five mirror
|
|
19
|
+
* the reference app (accent → cyan → yellow → muted → red); longer lists cycle through the rest.
|
|
20
|
+
*/
|
|
21
|
+
export const TIER_COLOR_VARS = Object.freeze([
|
|
22
|
+
'--ss-accent',
|
|
23
|
+
'--ss-cyan',
|
|
24
|
+
'--ss-yellow',
|
|
25
|
+
'--ss-fg-muted',
|
|
26
|
+
'--ss-red',
|
|
27
|
+
'--ss-blue',
|
|
28
|
+
'--ss-magenta',
|
|
29
|
+
'--ss-green',
|
|
30
|
+
]);
|
|
31
|
+
/** The CSS colour a row uses: its own `color`, else the slot for its index. */
|
|
32
|
+
export function tierColor(tier, index) {
|
|
33
|
+
return tier.color ?? `var(${TIER_COLOR_VARS[index % TIER_COLOR_VARS.length]})`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Build the zone map from props. Placement ids that name no item are dropped, an item placed
|
|
37
|
+
* in two tiers keeps its first placement, and everything unplaced goes to the tray — in the
|
|
38
|
+
* order the previous zones had it (so a tray reorder survives a re-render), then `items` order.
|
|
39
|
+
*/
|
|
40
|
+
export function buildZones(tiers, items, placements, previous) {
|
|
41
|
+
const known = new Set(items.map((i) => i.id));
|
|
42
|
+
const placed = new Set();
|
|
43
|
+
const zones = {};
|
|
44
|
+
for (const tier of tiers) {
|
|
45
|
+
const ids = [];
|
|
46
|
+
for (const id of placements?.[tier.id] ?? []) {
|
|
47
|
+
if (!known.has(id) || placed.has(id))
|
|
48
|
+
continue;
|
|
49
|
+
placed.add(id);
|
|
50
|
+
ids.push(id);
|
|
51
|
+
}
|
|
52
|
+
zones[tier.id] = ids;
|
|
53
|
+
}
|
|
54
|
+
const tray = [];
|
|
55
|
+
for (const id of previous?.[TRAY] ?? []) {
|
|
56
|
+
if (known.has(id) && !placed.has(id)) {
|
|
57
|
+
placed.add(id);
|
|
58
|
+
tray.push(id);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (const item of items) {
|
|
62
|
+
if (!placed.has(item.id)) {
|
|
63
|
+
placed.add(item.id);
|
|
64
|
+
tray.push(item.id);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
zones[TRAY] = tray;
|
|
68
|
+
return zones;
|
|
69
|
+
}
|
|
70
|
+
/** Where an item currently sits. `null` when it is in no zone. */
|
|
71
|
+
export function locate(zones, itemId) {
|
|
72
|
+
for (const zone of Object.keys(zones)) {
|
|
73
|
+
const index = zones[zone].indexOf(itemId);
|
|
74
|
+
if (index >= 0)
|
|
75
|
+
return { zone, index };
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Move an item to `toZone` at `toIndex` (clamped to the zone's length, counted after the item
|
|
81
|
+
* has been lifted out). Returns the same object when nothing changes, so callers can compare
|
|
82
|
+
* by identity.
|
|
83
|
+
*/
|
|
84
|
+
export function moveItem(zones, itemId, toZone, toIndex) {
|
|
85
|
+
const from = locate(zones, itemId);
|
|
86
|
+
if (!from || !(toZone in zones))
|
|
87
|
+
return zones;
|
|
88
|
+
const lifted = zones[from.zone].filter((id) => id !== itemId);
|
|
89
|
+
const target = from.zone === toZone ? lifted : zones[toZone].slice();
|
|
90
|
+
const index = Math.max(0, Math.min(toIndex, target.length));
|
|
91
|
+
if (from.zone === toZone && index === from.index)
|
|
92
|
+
return zones;
|
|
93
|
+
target.splice(index, 0, itemId);
|
|
94
|
+
return {
|
|
95
|
+
...zones,
|
|
96
|
+
[from.zone]: from.zone === toZone ? target : lifted,
|
|
97
|
+
[toZone]: target,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/** The public placements: tiers only, in the given tier order; the tray is implicit. */
|
|
101
|
+
export function placementsOf(zones, tiers) {
|
|
102
|
+
const out = {};
|
|
103
|
+
for (const tier of tiers)
|
|
104
|
+
out[tier.id] = (zones[tier.id] ?? []).slice();
|
|
105
|
+
return out;
|
|
106
|
+
}
|
|
107
|
+
export function zonesEqual(a, b) {
|
|
108
|
+
const ka = Object.keys(a);
|
|
109
|
+
const kb = Object.keys(b);
|
|
110
|
+
if (ka.length !== kb.length)
|
|
111
|
+
return false;
|
|
112
|
+
for (const k of ka) {
|
|
113
|
+
const x = a[k];
|
|
114
|
+
const y = b[k];
|
|
115
|
+
if (!y || x.length !== y.length)
|
|
116
|
+
return false;
|
|
117
|
+
for (let i = 0; i < x.length; i++)
|
|
118
|
+
if (x[i] !== y[i])
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Keyboard sorting target: left/right step within the zone (wrapping is deliberately off —
|
|
125
|
+
* the edges are meaningful), home/end jump within it, up/down move to the neighbouring zone
|
|
126
|
+
* keeping the same position (clamped). `zoneOrder` is the visual order, tray last.
|
|
127
|
+
* Returns `null` when the move is impossible (already at the edge).
|
|
128
|
+
*/
|
|
129
|
+
export function keyboardTarget(zones, zoneOrder, itemId, move) {
|
|
130
|
+
const at = locate(zones, itemId);
|
|
131
|
+
if (!at)
|
|
132
|
+
return null;
|
|
133
|
+
const len = zones[at.zone].length;
|
|
134
|
+
const zi = zoneOrder.indexOf(at.zone);
|
|
135
|
+
switch (move) {
|
|
136
|
+
case 'left':
|
|
137
|
+
return at.index > 0 ? { zone: at.zone, index: at.index - 1 } : null;
|
|
138
|
+
case 'right':
|
|
139
|
+
return at.index < len - 1 ? { zone: at.zone, index: at.index + 1 } : null;
|
|
140
|
+
case 'home':
|
|
141
|
+
return at.index > 0 ? { zone: at.zone, index: 0 } : null;
|
|
142
|
+
case 'end':
|
|
143
|
+
return at.index < len - 1 ? { zone: at.zone, index: len - 1 } : null;
|
|
144
|
+
case 'up':
|
|
145
|
+
case 'down': {
|
|
146
|
+
const next = zoneOrder[zi + (move === 'up' ? -1 : 1)];
|
|
147
|
+
if (next === undefined)
|
|
148
|
+
return null;
|
|
149
|
+
return { zone: next, index: Math.min(at.index, zones[next].length) };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Insertion index for a pointer at (x, y) among wrapped tiles: every tile whose row ends above
|
|
155
|
+
* the pointer counts as "before", and on the pointer's own row every tile whose centre is left
|
|
156
|
+
* of it. The dragged tile's own box must not be in `cells`.
|
|
157
|
+
*/
|
|
158
|
+
export function insertionIndex(cells, x, y) {
|
|
159
|
+
let index = 0;
|
|
160
|
+
for (const c of cells) {
|
|
161
|
+
if (c.bottom <= y)
|
|
162
|
+
index++;
|
|
163
|
+
else if (c.top <= y && (c.left + c.right) / 2 <= x)
|
|
164
|
+
index++;
|
|
165
|
+
}
|
|
166
|
+
return index;
|
|
167
|
+
}
|
|
168
|
+
/** Copy for the polite live region — one sentence per step, position 1-based. */
|
|
169
|
+
export function announceText(kind, d) {
|
|
170
|
+
const where = `${d.zone}, position ${d.index + 1} of ${d.count}`;
|
|
171
|
+
switch (kind) {
|
|
172
|
+
case 'grab':
|
|
173
|
+
return `Picked up ${d.label}, ${where}. Use the arrow keys to move it, Space to drop, Escape to cancel.`;
|
|
174
|
+
case 'move':
|
|
175
|
+
return `${d.label} moved to ${where}.`;
|
|
176
|
+
case 'drop':
|
|
177
|
+
return `Dropped ${d.label} in ${where}.`;
|
|
178
|
+
case 'cancel':
|
|
179
|
+
return `Cancelled. ${d.label} returned to ${where}.`;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/** Screen-reader instructions attached to every tile. */
|
|
183
|
+
export const TILE_INSTRUCTIONS = 'Press Space to pick up the tile, then the arrow keys to move it between positions and tiers, Space again to drop it, or Escape to cancel.';
|
package/dist/tokens.css
CHANGED
|
@@ -595,3 +595,28 @@
|
|
|
595
595
|
[data-size-variant=lg] {
|
|
596
596
|
--ss-spinner-font: 22px;
|
|
597
597
|
}
|
|
598
|
+
|
|
599
|
+
:root,
|
|
600
|
+
[data-size-variant=md] {
|
|
601
|
+
--ss-tier-tile-w: 108px;
|
|
602
|
+
--ss-tier-tile-h: 108px;
|
|
603
|
+
--ss-tier-label-w: 44px;
|
|
604
|
+
--ss-tier-label-font: var(--ss-ui-lg);
|
|
605
|
+
--ss-tier-gap: 6px;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
[data-size-variant=sm] {
|
|
609
|
+
--ss-tier-tile-w: 84px;
|
|
610
|
+
--ss-tier-tile-h: 84px;
|
|
611
|
+
--ss-tier-label-w: 36px;
|
|
612
|
+
--ss-tier-label-font: var(--ss-ui-md);
|
|
613
|
+
--ss-tier-gap: var(--ss-s-1);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
[data-size-variant=lg] {
|
|
617
|
+
--ss-tier-tile-w: 132px;
|
|
618
|
+
--ss-tier-tile-h: 132px;
|
|
619
|
+
--ss-tier-label-w: 56px;
|
|
620
|
+
--ss-tier-label-font: var(--ss-size-h3);
|
|
621
|
+
--ss-tier-gap: var(--ss-s-2);
|
|
622
|
+
}
|
package/dist/vanilla/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { openMenu, closeMenu } from './menu.js';
|
|
|
8
8
|
export { showTooltip, hideTooltip } from './tooltip.js';
|
|
9
9
|
export { toggleSwitch } from './switch.js';
|
|
10
10
|
export { selectSegment } from './segmented.js';
|
|
11
|
+
export { toggleGrab, readPlacements } from './tierlist.js';
|
|
11
12
|
export { clearInput, nudgeNumber, autosize } from './fields.js';
|
|
12
13
|
export { applyDesignConfig, designAttributes, getDesignConfig, paletteToCss, type DesignConfig, type ColorTheme, type Size, } from '../config.js';
|
|
13
14
|
/** Hydrate icon placeholders and initialise setup-type behaviours under `root`. */
|
package/dist/vanilla/index.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* consumption path. Importing this module wires every behaviour once via document-level event
|
|
4
4
|
* delegation (so markup added later just works) and runs `mount()` when the DOM is ready.
|
|
5
5
|
*
|
|
6
|
-
* <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.
|
|
7
|
-
* <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.
|
|
8
|
-
* <script type="module" src="https://cdn.jsdelivr.net/npm/dssoca@0.
|
|
6
|
+
* <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.19/dist/theme.css">
|
|
7
|
+
* <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.19/dist/vanilla.css">
|
|
8
|
+
* <script type="module" src="https://cdn.jsdelivr.net/npm/dssoca@0.19/dist/vanilla/index.js"></script>
|
|
9
9
|
*
|
|
10
10
|
* Call `mount(root)` after injecting HTML that contains `[data-ss-icon]` placeholders or
|
|
11
11
|
* autosizing textareas. Nothing here imports Svelte or a `.svelte` module.
|
|
@@ -16,6 +16,7 @@ import { installMenu } from './menu.js';
|
|
|
16
16
|
import { installTooltip } from './tooltip.js';
|
|
17
17
|
import { installSwitch } from './switch.js';
|
|
18
18
|
import { installSegmented } from './segmented.js';
|
|
19
|
+
import { installTierlist } from './tierlist.js';
|
|
19
20
|
import { installFields, mountFields } from './fields.js';
|
|
20
21
|
import { hydrateIcons } from './icons.js';
|
|
21
22
|
export { toast, toasts } from './toast.js';
|
|
@@ -27,6 +28,7 @@ export { openMenu, closeMenu } from './menu.js';
|
|
|
27
28
|
export { showTooltip, hideTooltip } from './tooltip.js';
|
|
28
29
|
export { toggleSwitch } from './switch.js';
|
|
29
30
|
export { selectSegment } from './segmented.js';
|
|
31
|
+
export { toggleGrab, readPlacements } from './tierlist.js';
|
|
30
32
|
export { clearInput, nudgeNumber, autosize } from './fields.js';
|
|
31
33
|
export { applyDesignConfig, designAttributes, getDesignConfig, paletteToCss, } from '../config.js';
|
|
32
34
|
/** Hydrate icon placeholders and initialise setup-type behaviours under `root`. */
|
|
@@ -49,6 +51,7 @@ export function install() {
|
|
|
49
51
|
installTooltip();
|
|
50
52
|
installSwitch();
|
|
51
53
|
installSegmented();
|
|
54
|
+
installTierlist();
|
|
52
55
|
installFields();
|
|
53
56
|
if (document.readyState === 'loading') {
|
|
54
57
|
document.addEventListener('DOMContentLoaded', () => mount(), { once: true });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type TierListPlacements, type TierListZones } from '../tierlist-core.js';
|
|
2
|
+
/** The zone map as the DOM currently has it. */
|
|
3
|
+
export declare function readZones(root: HTMLElement): TierListZones;
|
|
4
|
+
/** Public placements read from the DOM: every non-tray zone, in DOM order. */
|
|
5
|
+
export declare function readPlacements(root: HTMLElement): TierListPlacements;
|
|
6
|
+
/** Pick a tile up (or drop it when it is already grabbed). */
|
|
7
|
+
export declare function toggleGrab(tile: HTMLElement): void;
|
|
8
|
+
export declare function installTierlist(): void;
|