dssoca 0.11.0 → 0.13.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 (49) hide show
  1. package/dist/components/Accordion.svelte +35 -15
  2. package/dist/components/Accordion.svelte.d.ts +7 -0
  3. package/dist/components/Avatar.svelte +5 -9
  4. package/dist/components/Badge.svelte +27 -53
  5. package/dist/components/Badge.svelte.d.ts +2 -5
  6. package/dist/components/BottomNav.svelte +2 -2
  7. package/dist/components/BoxPlot.svelte +2 -8
  8. package/dist/components/BumpChart.svelte +2 -8
  9. package/dist/components/Button.svelte +50 -34
  10. package/dist/components/Button.svelte.d.ts +8 -2
  11. package/dist/components/Chart.svelte +2 -8
  12. package/dist/components/DateField.svelte +1 -1
  13. package/dist/components/FileDrop.svelte +1 -1
  14. package/dist/components/Icon.svelte +29 -7
  15. package/dist/components/Icon.svelte.d.ts +14 -2
  16. package/dist/components/Input.svelte +1 -1
  17. package/dist/components/Kbd.svelte +120 -0
  18. package/dist/components/Kbd.svelte.d.ts +30 -0
  19. package/dist/components/LogStream.svelte +3 -3
  20. package/dist/components/Menu.svelte +1 -1
  21. package/dist/components/NumberField.svelte +1 -1
  22. package/dist/components/ScatterPlot.svelte +2 -8
  23. package/dist/components/SearchPalette.svelte +526 -0
  24. package/dist/components/SearchPalette.svelte.d.ts +82 -0
  25. package/dist/components/Select.svelte +1 -1
  26. package/dist/components/ServiceCard.svelte +13 -2
  27. package/dist/components/ShortcutsHelp.svelte +365 -0
  28. package/dist/components/ShortcutsHelp.svelte.d.ts +34 -0
  29. package/dist/components/Sidebar.svelte +1 -1
  30. package/dist/components/Spinner.svelte +26 -19
  31. package/dist/components/Spinner.svelte.d.ts +14 -4
  32. package/dist/components/Switch.svelte +32 -2
  33. package/dist/components/Switch.svelte.d.ts +5 -0
  34. package/dist/components/Textarea.svelte +1 -1
  35. package/dist/components/Topbar.svelte +41 -26
  36. package/dist/components/Topbar.svelte.d.ts +5 -2
  37. package/dist/config.d.ts +44 -3
  38. package/dist/config.js +52 -3
  39. package/dist/dssoca.config.d.ts +39 -2
  40. package/dist/dssoca.config.js +49 -0
  41. package/dist/index.d.ts +10 -5
  42. package/dist/index.js +11 -4
  43. package/dist/palette.d.ts +10 -0
  44. package/dist/palette.js +17 -0
  45. package/dist/shortcuts.svelte.d.ts +192 -0
  46. package/dist/shortcuts.svelte.js +633 -0
  47. package/dist/theme.css +158 -158
  48. package/dist/tokens.css +158 -158
  49. package/package.json +4 -3
@@ -11,6 +11,7 @@
11
11
  '<circle cx="12" cy="12" r="3"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1"/>',
12
12
  user: '<circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 4-7 8-7s8 3 8 7"/>',
13
13
  arrow: '<path d="M5 12h14M13 5l7 7-7 7"/>',
14
+ chevron: '<path d="M8 10l4 4 4-4"/>',
14
15
  external: '<path d="M7 17L17 7M9 7h8v8"/>',
15
16
  film: '<rect x="3" y="4" width="18" height="16"/><path d="M3 8h4M3 16h4M17 8h4M17 16h4M3 12h18"/>',
16
17
  note: '<rect x="4" y="3" width="16" height="18"/><path d="M8 8h8M8 12h8M8 16h6"/>',
@@ -62,14 +63,26 @@
62
63
  <script lang="ts">
63
64
  import { resolveComponentSize, type Size } from '../config.js'
64
65
 
65
- /** Resolved px for each token size — used to keep absolute stroke optically constant. */
66
- const SIZE_PX: Record<Size, number> = { sm: 14, md: 16, lg: 20 }
66
+ /**
67
+ * Icon-local size scale (DS-0109). Distinct from the global `Size` axis
68
+ * (`sm | md | lg`): Icon adds an `xs` (12px) dense step that has *no* global
69
+ * `data-size-variant` counterpart — it pins directly via {@link SIZE_PX}. The
70
+ * named scale is fixed at xs 12 / sm 16 / md 20 / lg 24 px.
71
+ */
72
+ export type IconSize = 'xs' | Size
73
+
74
+ /** Fixed px for each named Icon size — used to keep absolute stroke optically constant. */
75
+ const SIZE_PX: Record<IconSize, number> = { xs: 12, sm: 16, md: 20, lg: 24 }
67
76
  const DEFAULT_PX = SIZE_PX.md
68
77
 
69
78
  interface Props {
70
79
  name: IconName
71
- /** Token-driven size (sm|md|lg); inherits the active size when unset. */
72
- size?: Size
80
+ /**
81
+ * Icon-local size (`xs | sm | md | lg`, a fixed px scale); inherits the
82
+ * active `--ss-icon` token when unset. `xs` (12px) is Icon-only and has no
83
+ * global size-variant equivalent.
84
+ */
85
+ size?: IconSize
73
86
  /** Explicit pixel size — overrides the token sizing. */
74
87
  px?: number
75
88
  /**
@@ -118,7 +131,12 @@
118
131
  class: cls = '',
119
132
  }: Props = $props()
120
133
 
121
- const dim = $derived(px != null ? `${px}px` : 'var(--ss-icon)')
134
+ // Box size: an explicit `px` wins; a named `size` pins to the fixed scale
135
+ // (incl. the Icon-only `xs` = 12px, which has no global token); when both are
136
+ // unset the icon inherits the active `--ss-icon` token through the cascade.
137
+ const dim = $derived(
138
+ px != null ? `${px}px` : size != null ? `${SIZE_PX[size]}px` : 'var(--ss-icon)',
139
+ )
122
140
 
123
141
  // Resolve the glyph: explicit `paths` escape hatch → registered/built-in → warn.
124
142
  const markup = $derived.by(() => {
@@ -134,12 +152,16 @@
134
152
  })
135
153
 
136
154
  // Optically-constant stroke: recompute weight from the resolved px so a
137
- // 2u stroke at the canonical 24-unit viewBox looks the same at 14/16/20px.
155
+ // 2u stroke at the canonical 24-unit viewBox looks the same at 12/16/20/24px.
138
156
  const resolvedPx = $derived(px != null ? px : (SIZE_PX[size ?? 'md'] ?? DEFAULT_PX))
139
157
  const stroke = $derived(absoluteStroke ? (strokeWidth * 24) / resolvedPx : strokeWidth)
140
158
 
141
159
  const isSolid = $derived(variant === 'solid')
142
160
 
161
+ // The global `data-size-variant` axis is sm|md|lg only; the Icon-local `xs`
162
+ // step has no axis equivalent (it pins via `dim` above), so it is omitted.
163
+ const axisSize = $derived<Size | undefined>(size === 'xs' ? undefined : size)
164
+
143
165
  // Decorative unless an explicit title (or explicit decorative=false) opts in.
144
166
  const isDecorative = $derived(decorative ?? title == null)
145
167
 
@@ -174,7 +196,7 @@
174
196
  class:spin
175
197
  class:flip-h={flip === 'horizontal'}
176
198
  class:flip-v={flip === 'vertical'}
177
- data-size-variant={resolveComponentSize('Icon', size)}
199
+ data-size-variant={resolveComponentSize('Icon', axisSize)}
178
200
  data-rotate={rotate || undefined}
179
201
  style="width:{dim};height:{dim}"
180
202
  role={labelled ? 'img' : undefined}
@@ -9,6 +9,7 @@ declare const BUILTIN_PATHS: {
9
9
  readonly settings: "<circle cx=\"12\" cy=\"12\" r=\"3\"/><path d=\"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1\"/>";
10
10
  readonly user: "<circle cx=\"12\" cy=\"8\" r=\"4\"/><path d=\"M4 21c0-4 4-7 8-7s8 3 8 7\"/>";
11
11
  readonly arrow: "<path d=\"M5 12h14M13 5l7 7-7 7\"/>";
12
+ readonly chevron: "<path d=\"M8 10l4 4 4-4\"/>";
12
13
  readonly external: "<path d=\"M7 17L17 7M9 7h8v8\"/>";
13
14
  readonly film: "<rect x=\"3\" y=\"4\" width=\"18\" height=\"16\"/><path d=\"M3 8h4M3 16h4M17 8h4M17 16h4M3 12h18\"/>";
14
15
  readonly note: "<rect x=\"4\" y=\"3\" width=\"16\" height=\"18\"/><path d=\"M8 8h8M8 12h8M8 16h6\"/>";
@@ -44,10 +45,21 @@ export declare function registerIcon(name: string, paths: string): void;
44
45
  /** Look a glyph up; built-ins first, then runtime registrations. */
45
46
  export declare function resolveIcon(name: string): string | undefined;
46
47
  import { type Size } from '../config.js';
48
+ /**
49
+ * Icon-local size scale (DS-0109). Distinct from the global `Size` axis
50
+ * (`sm | md | lg`): Icon adds an `xs` (12px) dense step that has *no* global
51
+ * `data-size-variant` counterpart — it pins directly via {@link SIZE_PX}. The
52
+ * named scale is fixed at xs 12 / sm 16 / md 20 / lg 24 px.
53
+ */
54
+ export type IconSize = 'xs' | Size;
47
55
  interface Props {
48
56
  name: IconName;
49
- /** Token-driven size (sm|md|lg); inherits the active size when unset. */
50
- size?: Size;
57
+ /**
58
+ * Icon-local size (`xs | sm | md | lg`, a fixed px scale); inherits the
59
+ * active `--ss-icon` token when unset. `xs` (12px) is Icon-only and has no
60
+ * global size-variant equivalent.
61
+ */
62
+ size?: IconSize;
51
63
  /** Explicit pixel size — overrides the token sizing. */
52
64
  px?: number;
53
65
  /**
@@ -163,7 +163,7 @@
163
163
  }
164
164
  .ss-field.invalid .control:focus-within {
165
165
  border-color: var(--ss-red);
166
- box-shadow: 0 0 0 3px rgba(var(--ss-red-rgb), 0.22);
166
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--ss-danger) 22%, transparent);
167
167
  }
168
168
  .ss-field.disabled .control {
169
169
  border-color: var(--ss-line);
@@ -0,0 +1,120 @@
1
+ <script lang="ts">
2
+ // ─────────────────────────────────────────────────────────────────────────
3
+ // Kbd (DS-0137). Display-only key-cap chip: renders a combo from the
4
+ // shortcut grammar (DS-0136) in house style. Registers nothing — pair the
5
+ // real binding with `shortcuts.add()` / `shortcut()` and put
6
+ // `ariaKeyshortcuts()` on the owning control.
7
+ //
8
+ // Markup follows MDN's nested-<kbd> convention: one outer <kbd> for the
9
+ // whole combo, one inner <kbd> per key, aria-hidden '+' separators between
10
+ // keys and a muted "or" between comma-alternatives.
11
+ // ─────────────────────────────────────────────────────────────────────────
12
+ import type { Snippet } from 'svelte'
13
+ import { resolveComponentSize, type Size } from '../config.js'
14
+ import {
15
+ detectPlatform,
16
+ formatShortcutParts,
17
+ type ShortcutFormat,
18
+ type ShortcutPlatform,
19
+ } from '../shortcuts.svelte.js'
20
+
21
+ interface Props {
22
+ /**
23
+ * Combo string in the shortcut grammar (`'mod+k'`, `'?, mod+/'`).
24
+ * `mod` renders as ⌘/Command on Apple platforms and Ctrl elsewhere.
25
+ * Malformed input throws (same parser as registration).
26
+ */
27
+ keys?: string
28
+ /**
29
+ * `'glyph'` (default): ⌘⇧⌥ + arrow/enter glyphs on Apple, words elsewhere.
30
+ * `'label'`: always full words. Glyph roots carry a full-word `aria-label`
31
+ * (⌘ and ↵ read poorly in assistive tech).
32
+ */
33
+ format?: ShortcutFormat
34
+ /**
35
+ * Override platform auto-detection. Defaults to `'other'` on the server
36
+ * and the first client render, corrected in an effect (no hydration
37
+ * mismatch); SSR apps can pass it explicitly for a stable first paint.
38
+ */
39
+ platform?: ShortcutPlatform
40
+ /** Token size (sm|md|lg); inherits the global size when unset. */
41
+ size?: Size
42
+ /** Raw-content escape hatch for keys the grammar can't express (`<Kbd>F12</Kbd>` sequences, chords…). Ignored when `keys` is set. */
43
+ children?: Snippet
44
+ }
45
+
46
+ let { keys, format = 'glyph', platform, size, children }: Props = $props()
47
+
48
+ // Hydration posture: 'other' on the server AND the first client render,
49
+ // corrected in an effect so server and client first paints agree. An
50
+ // explicit `platform` prop wins and skips the correction.
51
+ let detected = $state<ShortcutPlatform>('other')
52
+ $effect(() => {
53
+ if (platform === undefined) detected = detectPlatform()
54
+ })
55
+ const plat = $derived(platform ?? detected)
56
+
57
+ // One keycap-string array per comma-alternative.
58
+ const groups = $derived(keys ? formatShortcutParts(keys, { format, platform: plat }) : [])
59
+ // Apple glyphs concatenate (⌘K, the macOS convention) — no '+' separators.
60
+ const plus = $derived(!(format === 'glyph' && plat === 'apple'))
61
+ // Glyph roots carry the full-word combo; role="img" makes the aria-label
62
+ // valid on an otherwise generic element (Badge's label-less precedent) and
63
+ // presents the chip as one named unit instead of glyph soup.
64
+ const ariaLabel = $derived(
65
+ keys && format === 'glyph'
66
+ ? formatShortcutParts(keys, { format: 'label', platform: plat })
67
+ .map((group) => group.join(' '))
68
+ .join(' or ')
69
+ : undefined,
70
+ )
71
+ </script>
72
+
73
+ <kbd
74
+ class="ss-kbd"
75
+ data-size-variant={resolveComponentSize('Kbd', size)}
76
+ role={ariaLabel ? 'img' : undefined}
77
+ aria-label={ariaLabel}
78
+ >
79
+ {#if keys}
80
+ {#each groups as caps, g (g)}
81
+ {#if g > 0}<span class="or">or</span>{/if}
82
+ {#each caps as cap, i (i)}
83
+ {#if i > 0 && plus}<span class="sep" aria-hidden="true">+</span>{/if}
84
+ <kbd class="key">{cap}</kbd>
85
+ {/each}
86
+ {/each}
87
+ {:else if children}
88
+ <kbd class="key">{@render children()}</kbd>
89
+ {/if}
90
+ </kbd>
91
+
92
+ <style>.ss-kbd {
93
+ display: inline-flex;
94
+ align-items: center;
95
+ gap: calc(var(--ss-badge-gap) / 2);
96
+ font-family: var(--ss-font-mono);
97
+ font-size: var(--ss-size-xs);
98
+ }
99
+ .ss-kbd .key {
100
+ font-family: inherit;
101
+ font-size: inherit;
102
+ line-height: 1.6;
103
+ padding: 0 calc(var(--ss-badge-px) / 2);
104
+ min-width: 1.8em;
105
+ box-sizing: border-box;
106
+ text-align: center;
107
+ background: var(--ss-badge-neutral-bg);
108
+ color: var(--ss-badge-neutral-fg);
109
+ border: 1px solid var(--ss-badge-neutral-border);
110
+ border-bottom-color: var(--ss-line-strong);
111
+ }
112
+ .ss-kbd .sep,
113
+ .ss-kbd .or {
114
+ color: var(--ss-fg-muted);
115
+ flex: none;
116
+ }
117
+ .ss-kbd .or {
118
+ font-size: var(--ss-ui-xs);
119
+ letter-spacing: 0.05em;
120
+ }</style>
@@ -0,0 +1,30 @@
1
+ import type { Snippet } from 'svelte';
2
+ import { type Size } from '../config.js';
3
+ import { type ShortcutFormat, type ShortcutPlatform } from '../shortcuts.svelte.js';
4
+ interface Props {
5
+ /**
6
+ * Combo string in the shortcut grammar (`'mod+k'`, `'?, mod+/'`).
7
+ * `mod` renders as ⌘/Command on Apple platforms and Ctrl elsewhere.
8
+ * Malformed input throws (same parser as registration).
9
+ */
10
+ keys?: string;
11
+ /**
12
+ * `'glyph'` (default): ⌘⇧⌥ + arrow/enter glyphs on Apple, words elsewhere.
13
+ * `'label'`: always full words. Glyph roots carry a full-word `aria-label`
14
+ * (⌘ and ↵ read poorly in assistive tech).
15
+ */
16
+ format?: ShortcutFormat;
17
+ /**
18
+ * Override platform auto-detection. Defaults to `'other'` on the server
19
+ * and the first client render, corrected in an effect (no hydration
20
+ * mismatch); SSR apps can pass it explicitly for a stable first paint.
21
+ */
22
+ platform?: ShortcutPlatform;
23
+ /** Token size (sm|md|lg); inherits the global size when unset. */
24
+ size?: Size;
25
+ /** Raw-content escape hatch for keys the grammar can't express (`<Kbd>F12</Kbd>` sequences, chords…). Ignored when `keys` is set. */
26
+ children?: Snippet;
27
+ }
28
+ declare const Kbd: import("svelte").Component<Props, {}, "">;
29
+ type Kbd = ReturnType<typeof Kbd>;
30
+ export default Kbd;
@@ -316,7 +316,7 @@
316
316
  font-family: var(--ss-font-mono);
317
317
  font-size: var(--ss-ui-sm);
318
318
  line-height: 1;
319
- padding: var(--ss-badge-py) var(--ss-badge-px);
319
+ padding: var(--ss-chip-py) var(--ss-badge-px);
320
320
  border: 1px solid var(--ss-line);
321
321
  background: transparent;
322
322
  color: var(--ss-code-fg);
@@ -350,7 +350,7 @@
350
350
  min-width: 8ch;
351
351
  font-family: var(--ss-font-mono);
352
352
  font-size: var(--ss-ui-sm);
353
- padding: var(--ss-badge-py) var(--ss-gap-sm);
353
+ padding: var(--ss-chip-py) var(--ss-gap-sm);
354
354
  border: 1px solid var(--ss-line);
355
355
  background: transparent;
356
356
  color: var(--ss-code-fg);
@@ -442,7 +442,7 @@
442
442
  font-family: var(--ss-font-mono);
443
443
  font-size: var(--ss-ui-sm);
444
444
  line-height: 1;
445
- padding: var(--ss-badge-py) var(--ss-badge-px);
445
+ padding: var(--ss-chip-py) var(--ss-badge-px);
446
446
  border: 1px solid var(--ss-line-strong);
447
447
  background: var(--ss-bg-elev);
448
448
  color: var(--ss-fg);
@@ -369,7 +369,7 @@
369
369
  }
370
370
  .item.selected {
371
371
  color: var(--ss-fg);
372
- background: rgba(var(--ss-primary-rgb), 0.06);
372
+ background: color-mix(in srgb, var(--ss-accent) 6%, transparent);
373
373
  }
374
374
  .item:disabled, .item[aria-disabled=true] {
375
375
  color: var(--ss-fg-faint);
@@ -180,7 +180,7 @@
180
180
  }
181
181
  .ss-numberfield.invalid .control:focus-within {
182
182
  border-color: var(--ss-red);
183
- box-shadow: 0 0 0 3px rgba(var(--ss-red-rgb), 0.22);
183
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--ss-danger) 22%, transparent);
184
184
  }
185
185
  .ss-numberfield.disabled .control {
186
186
  border-color: var(--ss-line);
@@ -12,6 +12,7 @@
12
12
  </script>
13
13
 
14
14
  <script lang="ts">
15
+ import { CHART_PALETTE } from '../palette.js'
15
16
  import { scaleLinear, scaleSqrt } from 'd3-scale'
16
17
  import { extent, max } from 'd3-array'
17
18
  import { resolveComponentSize, type Size } from '../config.js'
@@ -73,14 +74,7 @@
73
74
  size,
74
75
  }: Props = $props()
75
76
 
76
- const PALETTE = [
77
- 'var(--ss-primary)',
78
- 'var(--ss-blue)',
79
- 'var(--ss-purple)',
80
- 'var(--ss-cyan)',
81
- 'var(--ss-yellow)',
82
- 'var(--ss-lime)',
83
- ]
77
+ const PALETTE = CHART_PALETTE
84
78
 
85
79
  const M = { top: 12, right: 16, bottom: 36, left: 48 }
86
80