dssoca 0.8.2 → 0.9.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 (43) hide show
  1. package/README.md +39 -13
  2. package/dist/components/Accordion.svelte +22 -6
  3. package/dist/components/Accordion.svelte.d.ts +5 -1
  4. package/dist/components/Badge.svelte +3 -5
  5. package/dist/components/BottomNav.svelte +57 -19
  6. package/dist/components/BottomNav.svelte.d.ts +2 -0
  7. package/dist/components/Card.svelte +7 -1
  8. package/dist/components/Container.svelte +55 -0
  9. package/dist/components/Container.svelte.d.ts +16 -0
  10. package/dist/components/EmptyState.svelte +9 -3
  11. package/dist/components/EmptyState.svelte.d.ts +6 -0
  12. package/dist/components/Heading.svelte +83 -0
  13. package/dist/components/Heading.svelte.d.ts +17 -0
  14. package/dist/components/Icon.svelte +32 -23
  15. package/dist/components/Icon.svelte.d.ts +7 -0
  16. package/dist/components/Image.svelte +19 -21
  17. package/dist/components/Input.svelte +2 -3
  18. package/dist/components/Link.svelte +42 -7
  19. package/dist/components/Link.svelte.d.ts +7 -0
  20. package/dist/components/LogStream.svelte +46 -31
  21. package/dist/components/Menu.svelte +59 -6
  22. package/dist/components/Menu.svelte.d.ts +22 -2
  23. package/dist/components/MetricTile.svelte +4 -4
  24. package/dist/components/SegmentedControl.svelte +16 -4
  25. package/dist/components/SegmentedControl.svelte.d.ts +7 -0
  26. package/dist/components/ServiceCard.svelte +15 -15
  27. package/dist/components/Sidebar.svelte +47 -21
  28. package/dist/components/Sparkline.svelte +15 -13
  29. package/dist/components/Spinner.svelte +124 -0
  30. package/dist/components/Spinner.svelte.d.ts +74 -0
  31. package/dist/components/Textarea.svelte +214 -0
  32. package/dist/components/Textarea.svelte.d.ts +38 -0
  33. package/dist/components/Toaster.svelte +20 -4
  34. package/dist/components/Topbar.svelte +170 -50
  35. package/dist/components/Topbar.svelte.d.ts +30 -3
  36. package/dist/dssoca.config.d.ts +1 -1
  37. package/dist/dssoca.config.js +4 -0
  38. package/dist/index.d.ts +7 -1
  39. package/dist/index.js +7 -1
  40. package/dist/theme.css +177 -37
  41. package/dist/toast.svelte.js +3 -3
  42. package/dist/tokens.css +597 -0
  43. package/package.json +25 -4
@@ -2,23 +2,35 @@
2
2
  /** Curated glyph set. `target`'s centre dot is a filled circle in the *outline*
3
3
  * variant — handled by the `variant` switch in markup, not a per-glyph fill hack. */
4
4
  const BUILTIN_PATHS = {
5
- grid: '<rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/>',
5
+ grid: '<rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/>',
6
6
  activity: '<path d="M3 12h4l3-8 4 16 3-8h4"/>',
7
7
  database: '<rect x="3" y="4" width="18" height="16"/><path d="M3 9h18M8 4v5"/>',
8
- logs: '<path d="M4 6h16M4 12h16M4 18h10"/>',
8
+ logs: '<path d="M4 6h16M4 12h16M4 18h10"/>',
9
9
  terminal: '<rect x="3" y="5" width="18" height="14"/><path d="M3 9h18M7 14h4"/>',
10
- 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"/>',
11
- user: '<circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 4-7 8-7s8 3 8 7"/>',
12
- arrow: '<path d="M5 12h14M13 5l7 7-7 7"/>',
10
+ settings:
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
+ user: '<circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 4-7 8-7s8 3 8 7"/>',
13
+ arrow: '<path d="M5 12h14M13 5l7 7-7 7"/>',
13
14
  external: '<path d="M7 17L17 7M9 7h8v8"/>',
14
- film: '<rect x="3" y="4" width="18" height="16"/><path d="M3 8h4M3 16h4M17 8h4M17 16h4M3 12h18"/>',
15
- note: '<rect x="4" y="3" width="16" height="18"/><path d="M8 8h8M8 12h8M8 16h6"/>',
16
- book: '<path d="M6 4h11a1 1 0 011 1v15H7a1 1 0 01-1-1z"/><path d="M17 20a2 2 0 002-2V6a2 2 0 00-2-2"/><path d="M9 8h5"/>',
17
- check: '<path d="M5 12l4 4L19 6"/>',
18
- cup: '<path d="M4 8h12v6a4 4 0 01-4 4H8a4 4 0 01-4-4z"/><path d="M16 10h2a2 2 0 010 4h-2M6 4v2M10 4v2M14 4v2"/>',
19
- wallet: '<rect x="3" y="6" width="18" height="14"/><path d="M3 10h18M17 14h2"/>',
20
- target: '<circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="5"/><circle cx="12" cy="12" r="1.5" class="ss-icon-dot"/>',
21
- spinner: '<path d="M12 3a9 9 0 1 0 9 9" stroke-linecap="round"/>',
15
+ film: '<rect x="3" y="4" width="18" height="16"/><path d="M3 8h4M3 16h4M17 8h4M17 16h4M3 12h18"/>',
16
+ note: '<rect x="4" y="3" width="16" height="18"/><path d="M8 8h8M8 12h8M8 16h6"/>',
17
+ book: '<path d="M6 4h11a1 1 0 011 1v15H7a1 1 0 01-1-1z"/><path d="M17 20a2 2 0 002-2V6a2 2 0 00-2-2"/><path d="M9 8h5"/>',
18
+ check: '<path d="M5 12l4 4L19 6"/>',
19
+ cup: '<path d="M4 8h12v6a4 4 0 01-4 4H8a4 4 0 01-4-4z"/><path d="M16 10h2a2 2 0 010 4h-2M6 4v2M10 4v2M14 4v2"/>',
20
+ wallet: '<rect x="3" y="6" width="18" height="14"/><path d="M3 10h18M17 14h2"/>',
21
+ target:
22
+ '<circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="5"/><circle cx="12" cy="12" r="1.5" class="ss-icon-dot"/>',
23
+ spinner: '<path d="M12 3a9 9 0 1 0 9 9" stroke-linecap="round"/>',
24
+ home: '<path d="M4 11l8-8 8 8"/><path d="M6 9v12h12V9"/><path d="M10 21v-6h4v6"/>',
25
+ briefcase: '<rect x="3" y="7" width="18" height="13"/><path d="M9 7V4h6v3M3 12h18"/>',
26
+ folder: '<path d="M3 5h7l2 3h9v13H3z"/><path d="M3 8h9"/>',
27
+ github:
28
+ '<path d="M7 3h10l2 2v6l-2 3h-4l1 2v5h-4v-5l1-2H7l-2-3V5l2-2z"/><path d="M9 8h1M14 8h1"/>',
29
+ linkedin:
30
+ '<rect x="3" y="3" width="18" height="18"/><path d="M8 16v-5M8 8v.01M12 16v-5h2l2 2v3"/>',
31
+ language: '<circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3L8 12l4 9M12 3l4 9-4 9"/>',
32
+ 'color-swatch':
33
+ '<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"/>',
22
34
  } as const
23
35
 
24
36
  export type IconName = keyof typeof BUILTIN_PATHS
@@ -114,17 +126,17 @@
114
126
  const found = resolveIcon(name)
115
127
  if (found != null) return found
116
128
  if (typeof console !== 'undefined') {
117
- console.warn(`[dssoca] Icon: unknown name "${name}" (no registered glyph). Rendering empty; pass \`paths\` or call registerIcon().`)
129
+ console.warn(
130
+ `[dssoca] Icon: unknown name "${name}" (no registered glyph). Rendering empty; pass \`paths\` or call registerIcon().`,
131
+ )
118
132
  }
119
133
  return ''
120
134
  })
121
135
 
122
136
  // Optically-constant stroke: recompute weight from the resolved px so a
123
137
  // 2u stroke at the canonical 24-unit viewBox looks the same at 14/16/20px.
124
- const resolvedPx = $derived(px != null ? px : SIZE_PX[size ?? 'md'] ?? DEFAULT_PX)
125
- const stroke = $derived(
126
- absoluteStroke ? (strokeWidth * 24) / resolvedPx : strokeWidth,
127
- )
138
+ const resolvedPx = $derived(px != null ? px : (SIZE_PX[size ?? 'md'] ?? DEFAULT_PX))
139
+ const stroke = $derived(absoluteStroke ? (strokeWidth * 24) / resolvedPx : strokeWidth)
128
140
 
129
141
  const isSolid = $derived(variant === 'solid')
130
142
 
@@ -135,13 +147,10 @@
135
147
  const uid = $props.id()
136
148
  const titleId = $derived(title ? `${uid}-t` : undefined)
137
149
  const descId = $derived(desc ? `${uid}-d` : undefined)
138
- const labelledBy = $derived(
139
- [titleId, descId].filter(Boolean).join(' ') || undefined,
140
- )
150
+ const labelledBy = $derived([titleId, descId].filter(Boolean).join(' ') || undefined)
141
151
  const labelled = $derived(!isDecorative && labelledBy != null)
142
152
 
143
- const esc = (s: string) =>
144
- s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
153
+ const esc = (s: string) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
145
154
 
146
155
  // <title>/<desc> are folded into the same @html string as the glyph so the
147
156
  // SVG carries no Svelte {#if} comment anchors (keeps innerHTML clean for AT
@@ -18,6 +18,13 @@ declare const BUILTIN_PATHS: {
18
18
  readonly wallet: "<rect x=\"3\" y=\"6\" width=\"18\" height=\"14\"/><path d=\"M3 10h18M17 14h2\"/>";
19
19
  readonly target: "<circle cx=\"12\" cy=\"12\" r=\"9\"/><circle cx=\"12\" cy=\"12\" r=\"5\"/><circle cx=\"12\" cy=\"12\" r=\"1.5\" class=\"ss-icon-dot\"/>";
20
20
  readonly spinner: "<path d=\"M12 3a9 9 0 1 0 9 9\" stroke-linecap=\"round\"/>";
21
+ readonly home: "<path d=\"M4 11l8-8 8 8\"/><path d=\"M6 9v12h12V9\"/><path d=\"M10 21v-6h4v6\"/>";
22
+ readonly briefcase: "<rect x=\"3\" y=\"7\" width=\"18\" height=\"13\"/><path d=\"M9 7V4h6v3M3 12h18\"/>";
23
+ readonly folder: "<path d=\"M3 5h7l2 3h9v13H3z\"/><path d=\"M3 8h9\"/>";
24
+ readonly github: "<path d=\"M7 3h10l2 2v6l-2 3h-4l1 2v5h-4v-5l1-2H7l-2-3V5l2-2z\"/><path d=\"M9 8h1M14 8h1\"/>";
25
+ readonly linkedin: "<rect x=\"3\" y=\"3\" width=\"18\" height=\"18\"/><path d=\"M8 16v-5M8 8v.01M12 16v-5h2l2 2v3\"/>";
26
+ readonly language: "<circle cx=\"12\" cy=\"12\" r=\"9\"/><path d=\"M3 12h18M12 3L8 12l4 9M12 3l4 9-4 9\"/>";
27
+ 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\"/>";
21
28
  };
22
29
  export type IconName = keyof typeof BUILTIN_PATHS;
23
30
  /**
@@ -80,21 +80,17 @@
80
80
  // Reserve space before load → no layout shift (CLS). Prefer an explicit
81
81
  // ratio, else derive from intrinsic width/height. `null` → no box reserved.
82
82
  const aspect = $derived(
83
- ratio && ratio > 0
84
- ? ratio
85
- : width && height && height > 0
86
- ? width / height
87
- : null,
83
+ ratio && ratio > 0 ? ratio : width && height && height > 0 ? width / height : null,
88
84
  )
89
85
 
90
86
  type State = 'loading' | 'loaded' | 'error'
91
- let state = $state<State>('loading')
87
+ let loadState = $state<State>('loading')
92
88
 
93
89
  function onLoad() {
94
- state = 'loaded'
90
+ loadState = 'loaded'
95
91
  }
96
92
  function onError() {
97
- state = 'error'
93
+ loadState = 'error'
98
94
  }
99
95
 
100
96
  // ── Lightbox ───────────────────────────────────────────────────────────
@@ -103,7 +99,7 @@
103
99
  let dialog = $state<HTMLDivElement | null>(null)
104
100
  let closeBtn = $state<HTMLButtonElement | null>(null)
105
101
 
106
- const canOpen = $derived(lightbox && state !== 'error')
102
+ const canOpen = $derived(lightbox && loadState !== 'error')
107
103
 
108
104
  async function openLightbox() {
109
105
  if (!canOpen) return
@@ -127,8 +123,15 @@
127
123
  return
128
124
  }
129
125
  if (e.key !== 'Tab' || !dialog) return
126
+ // DS-0078: exclude disabled focusables (and anything opted out of the tab
127
+ // order with tabindex="-1", e.g. the backdrop button) so the trap never
128
+ // wraps relative to an element that cannot actually take tab focus.
130
129
  const focusables = dialog.querySelectorAll<HTMLElement>(
131
- 'button, [href], [tabindex]:not([tabindex="-1"])',
130
+ [
131
+ 'button:not([disabled]):not([aria-disabled="true"]):not([tabindex="-1"])',
132
+ '[href]:not([aria-disabled="true"]):not([tabindex="-1"])',
133
+ '[tabindex]:not([tabindex="-1"]):not([disabled]):not([aria-disabled="true"])',
134
+ ].join(', '),
132
135
  )
133
136
  if (focusables.length === 0) return
134
137
  const first = focusables[0]
@@ -146,22 +149,22 @@
146
149
 
147
150
  <figure
148
151
  class="ss-image {className ?? ''}"
149
- class:is-loading={state === 'loading'}
150
- class:is-error={state === 'error'}
152
+ class:is-loading={loadState === 'loading'}
153
+ class:is-error={loadState === 'error'}
151
154
  class:has-ratio={aspect != null}
152
155
  data-size-variant={resolveComponentSize('Image', size)}
153
156
  >
154
157
  <div
155
158
  class="frame"
156
159
  style:aspect-ratio={aspect != null ? `${aspect}` : undefined}
157
- aria-busy={state === 'loading'}
160
+ aria-busy={loadState === 'loading'}
158
161
  >
159
- {#if state === 'error'}
162
+ {#if loadState === 'error'}
160
163
  <div class="fallback" role="img" aria-label={alt || 'Image failed to load'}>
161
164
  <span class="glyph" aria-hidden="true">⊘</span>
162
165
  </div>
163
166
  {:else}
164
- {#if state === 'loading'}
167
+ {#if loadState === 'loading'}
165
168
  <div class="skeleton" aria-hidden="true"></div>
166
169
  {/if}
167
170
  {#if canOpen}
@@ -218,12 +221,7 @@
218
221
  tabindex="-1"
219
222
  onkeydown={onDialogKeydown}
220
223
  >
221
- <button
222
- type="button"
223
- class="backdrop"
224
- tabindex="-1"
225
- aria-hidden="true"
226
- onclick={closeLightbox}
224
+ <button type="button" class="backdrop" tabindex="-1" aria-hidden="true" onclick={closeLightbox}
227
225
  ></button>
228
226
  <div class="dialog-body">
229
227
  <button
@@ -73,9 +73,8 @@
73
73
 
74
74
  // error wins, then hint, then any caller-supplied describedby — order matters for AT.
75
75
  const describedBy = $derived(
76
- [error ? errorId : null, hint ? hintId : null, describedby]
77
- .filter(Boolean)
78
- .join(' ') || undefined,
76
+ [error ? errorId : null, hint ? hintId : null, describedby].filter(Boolean).join(' ') ||
77
+ undefined,
79
78
  )
80
79
  const isInvalid = $derived(invalid || Boolean(error) || undefined)
81
80
  const resolvedSize = $derived(resolveComponentSize('Input', size))
@@ -16,6 +16,13 @@
16
16
  size?: Size
17
17
  /** Destination URL. */
18
18
  href?: string
19
+ /**
20
+ * Render the link inert (DS-0078): the `href` is dropped (no navigation,
21
+ * out of the tab order), link semantics are kept via `role="link"`, and
22
+ * the state is communicated to AT with `aria-disabled="true"`. Forwarded
23
+ * `onclick` handlers do not fire while disabled.
24
+ */
25
+ disabled?: boolean
19
26
  children?: Snippet
20
27
  /** Bound reference to the underlying <a>. */
21
28
  el?: HTMLAnchorElement
@@ -26,34 +33,50 @@
26
33
  external,
27
34
  size,
28
35
  href,
36
+ disabled = false,
29
37
  children,
30
38
  el = $bindable(),
31
39
  target,
32
40
  rel,
41
+ onclick,
33
42
  ...rest
34
43
  }: Props = $props()
35
44
 
36
45
  // Off-site detection: absolute http(s) URL, or a protocol-relative one.
37
46
  // Honoured only when `external` is left undefined (explicit wins).
38
- const looksExternal = $derived(
39
- typeof href === 'string' && /^(https?:)?\/\//i.test(href),
40
- )
41
- const isExternal = $derived(external ?? looksExternal)
47
+ const looksExternal = $derived(typeof href === 'string' && /^(https?:)?\/\//i.test(href))
48
+ // A disabled link gets no external affordances (it cannot navigate).
49
+ const isExternal = $derived(!disabled && (external ?? looksExternal))
42
50
 
43
51
  // External links open in a new tab and carry the security rel; callers can
44
52
  // still override target/rel explicitly via the forwarded attributes.
45
53
  const resolvedTarget = $derived(target ?? (isExternal ? '_blank' : undefined))
46
54
  const resolvedRel = $derived(rel ?? (isExternal ? 'noopener noreferrer' : undefined))
55
+
56
+ // Swallow activation while disabled; otherwise defer to a forwarded onclick.
57
+ function handleClick(e: MouseEvent) {
58
+ if (disabled) {
59
+ e.preventDefault()
60
+ e.stopPropagation()
61
+ return
62
+ }
63
+ onclick?.(e as MouseEvent & { currentTarget: EventTarget & HTMLAnchorElement })
64
+ }
47
65
  </script>
48
66
 
49
67
  <a
50
68
  bind:this={el}
51
- {href}
69
+ href={disabled ? undefined : href}
52
70
  class="ss-link {variant}"
53
71
  class:external={isExternal}
72
+ class:disabled
73
+ role={disabled ? 'link' : undefined}
74
+ aria-disabled={disabled ? 'true' : undefined}
75
+ tabindex={disabled ? -1 : undefined}
54
76
  data-size-variant={resolveComponentSize('Link', size)}
55
- target={resolvedTarget}
56
- rel={resolvedRel}
77
+ target={disabled ? undefined : resolvedTarget}
78
+ rel={disabled ? undefined : resolvedRel}
79
+ onclick={handleClick}
57
80
  {...rest}
58
81
  >
59
82
  {#if children}<span class="label">{@render children()}</span>{/if}
@@ -80,6 +103,10 @@
80
103
  outline: 2px solid var(--ss-primary);
81
104
  outline-offset: 2px;
82
105
  }
106
+ .ss-link.disabled {
107
+ cursor: not-allowed;
108
+ opacity: 0.45;
109
+ }
83
110
 
84
111
  /* ── inline: animated underline that reveals on hover/focus, with a glow ── */
85
112
  .ss-link.inline .label {
@@ -102,6 +129,9 @@
102
129
  height: 2px;
103
130
  box-shadow: var(--ss-shadow-glow);
104
131
  }
132
+ .ss-link.inline.disabled .label::after {
133
+ display: none;
134
+ }
105
135
  .ss-link.inline:visited {
106
136
  color: var(--ss-fg-muted);
107
137
  }
@@ -124,6 +154,11 @@
124
154
  border-color: var(--ss-primary-hover);
125
155
  box-shadow: var(--ss-shadow-glow);
126
156
  }
157
+ .ss-link.button.disabled:hover {
158
+ background: var(--ss-primary);
159
+ border-color: var(--ss-primary);
160
+ box-shadow: none;
161
+ }
127
162
  .ss-link.button .label::after {
128
163
  display: none;
129
164
  }
@@ -13,6 +13,13 @@ interface Props extends HTMLAnchorAttributes {
13
13
  size?: Size;
14
14
  /** Destination URL. */
15
15
  href?: string;
16
+ /**
17
+ * Render the link inert (DS-0078): the `href` is dropped (no navigation,
18
+ * out of the tab order), link semantics are kept via `role="link"`, and
19
+ * the state is communicated to AT with `aria-disabled="true"`. Forwarded
20
+ * `onclick` handlers do not fire while disabled.
21
+ */
22
+ disabled?: boolean;
16
23
  children?: Snippet;
17
24
  /** Bound reference to the underlying <a>. */
18
25
  el?: HTMLAnchorElement;
@@ -52,16 +52,18 @@
52
52
 
53
53
  const TEMPLATES: Omit<LogLine, 'id'>[] = [
54
54
  { lvl: 'info', svc: '[movies-api]', msg: 'GET /movies?status=to_watch — 3 rows · 4ms' },
55
- { lvl: 'ok', svc: '[hub]', msg: 'GET /api/auth/session — 8ms' },
56
- { lvl: 'info', svc: '[hub]', msg: 'session refresh — user=admin' },
57
- { lvl: 'warn', svc: '[caddy]', msg: 'tls internal renewing hub.home' },
58
- { lvl: 'err', svc: '[tasks-api]', msg: 'EADDRINUSE :3004 — retrying in 2s' },
59
- { lvl: 'info', svc: '[notes-api]', msg: 'slow query · 182ms · SELECT * FROM notes' },
60
- { lvl: 'ok', svc: '[meals-api]', msg: 'POST /meals — created id=m_a4f1 · 6ms' },
55
+ { lvl: 'ok', svc: '[hub]', msg: 'GET /api/auth/session — 8ms' },
56
+ { lvl: 'info', svc: '[hub]', msg: 'session refresh — user=admin' },
57
+ { lvl: 'warn', svc: '[caddy]', msg: 'tls internal renewing hub.home' },
58
+ { lvl: 'err', svc: '[tasks-api]', msg: 'EADDRINUSE :3004 — retrying in 2s' },
59
+ { lvl: 'info', svc: '[notes-api]', msg: 'slow query · 182ms · SELECT * FROM notes' },
60
+ { lvl: 'ok', svc: '[meals-api]', msg: 'POST /meals — created id=m_a4f1 · 6ms' },
61
61
  { lvl: 'info', svc: '[movies-api]', msg: 'drizzle migrated 0002 · runtime 12ms' },
62
62
  ]
63
63
 
64
- function pad(n: number) { return String(n).padStart(2, '0') }
64
+ function pad(n: number) {
65
+ return String(n).padStart(2, '0')
66
+ }
65
67
  function nowStr() {
66
68
  const d = new Date()
67
69
  return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
@@ -95,20 +97,18 @@
95
97
  // Internal demo buffer.
96
98
  const seed = untrack(() => initialLines ?? TEMPLATES)
97
99
  let counter = $state(seed.length)
98
- let demoLines = $state<LogLine[]>(
99
- seed.map((t, i) => ({ ...t, t: t.t || timeAgo(i * 4), id: i }))
100
- )
100
+ let demoLines = $state<LogLine[]>(seed.map((t, i) => ({ ...t, t: t.t || timeAgo(i * 4), id: i })))
101
101
 
102
102
  // The source of truth, capped to maxLines.
103
- const allLines = $derived(
104
- (controlled ? (lines as LogLine[]) : demoLines).slice(-maxLines)
105
- )
103
+ const allLines = $derived((controlled ? (lines as LogLine[]) : demoLines).slice(-maxLines))
106
104
 
107
105
  // --- toolbar state ---
108
106
  let activeLevels = $state<Set<LogLevel>>(new Set(LEVELS))
109
107
  let query = $state('')
110
108
  let wrapOn = $state(untrack(() => wrap))
111
- $effect(() => { wrapOn = wrap })
109
+ $effect(() => {
110
+ wrapOn = wrap
111
+ })
112
112
 
113
113
  const visibleLines = $derived(
114
114
  allLines.filter((l) => {
@@ -119,7 +119,7 @@
119
119
  if (!hay.includes(q)) return false
120
120
  }
121
121
  return true
122
- })
122
+ }),
123
123
  )
124
124
 
125
125
  function toggleLevel(lvl: LogLevel) {
@@ -202,8 +202,8 @@
202
202
  type="button"
203
203
  class="chip {lvl}"
204
204
  aria-pressed={activeLevels.has(lvl)}
205
- onclick={() => toggleLevel(lvl)}
206
- >{lvl.toUpperCase()}</button>
205
+ onclick={() => toggleLevel(lvl)}>{lvl.toUpperCase()}</button
206
+ >
207
207
  {/each}
208
208
  </div>
209
209
  <input
@@ -213,12 +213,9 @@
213
213
  aria-label="Filter log text"
214
214
  bind:value={query}
215
215
  />
216
- <button
217
- type="button"
218
- class="chip"
219
- aria-pressed={wrapOn}
220
- onclick={() => (wrapOn = !wrapOn)}
221
- >WRAP</button>
216
+ <button type="button" class="chip" aria-pressed={wrapOn} onclick={() => (wrapOn = !wrapOn)}
217
+ >WRAP</button
218
+ >
222
219
  <button type="button" class="chip" onclick={copyVisible}>COPY</button>
223
220
  {#if !controlled}
224
221
  <button type="button" class="chip" onclick={clear}>CLEAR</button>
@@ -250,7 +247,9 @@
250
247
  {:else}
251
248
  <EmptyState
252
249
  title="No log lines"
253
- message={allLines.length ? 'No lines match the current filters.' : 'Waiting for output…'}
250
+ message={allLines.length
251
+ ? 'No lines match the current filters.'
252
+ : 'Waiting for output…'}
254
253
  {size}
255
254
  />
256
255
  {/if}
@@ -267,14 +266,30 @@
267
266
  </div>
268
267
 
269
268
  {#if !following}
270
- <button type="button" class="jump" onclick={jumpToBottom}>
271
- Jump to bottom
272
- </button>
269
+ <button type="button" class="jump" onclick={jumpToBottom}> Jump to bottom </button>
273
270
  {/if}
274
271
  </div>
275
272
  </div>
276
273
 
277
274
  <style>.ss-logs {
275
+ --_min-h: var(--ss-log-min-h, 160px);
276
+ --_max-h: var(--ss-log-max-h, 240px);
277
+ --_t-w: var(--ss-log-t-w, 58px);
278
+ --_lvl-w: var(--ss-log-lvl-w, 38px);
279
+ }
280
+ .ss-logs[data-size-variant=sm] {
281
+ --_min-h: var(--ss-log-min-h, 120px);
282
+ --_max-h: var(--ss-log-max-h, 200px);
283
+ --_t-w: var(--ss-log-t-w, 52px);
284
+ --_lvl-w: var(--ss-log-lvl-w, 34px);
285
+ }
286
+ .ss-logs[data-size-variant=lg] {
287
+ --_min-h: var(--ss-log-min-h, 200px);
288
+ --_max-h: var(--ss-log-max-h, 320px);
289
+ --_t-w: var(--ss-log-t-w, 64px);
290
+ --_lvl-w: var(--ss-log-lvl-w, 42px);
291
+ }
292
+ .ss-logs {
278
293
  font-family: var(--ss-font-mono);
279
294
  background: var(--ss-code-bg);
280
295
  color: var(--ss-code-fg);
@@ -355,8 +370,8 @@
355
370
  .scroll {
356
371
  font-size: var(--ss-ui-md);
357
372
  padding: var(--ss-gap) var(--ss-panel-body-px);
358
- min-height: 160px;
359
- max-height: 240px;
373
+ min-height: var(--_min-h);
374
+ max-height: var(--_max-h);
360
375
  overflow: auto;
361
376
  }
362
377
  .scroll .ln {
@@ -373,11 +388,11 @@
373
388
  }
374
389
  .scroll .t {
375
390
  color: var(--ss-fg-faint);
376
- min-width: 58px;
391
+ min-width: var(--_t-w);
377
392
  flex: none;
378
393
  }
379
394
  .scroll .lvl {
380
- min-width: 38px;
395
+ min-width: var(--_lvl-w);
381
396
  flex: none;
382
397
  }
383
398
  .scroll .lvl.info {
@@ -1,12 +1,33 @@
1
1
  <script module lang="ts">
2
+ import type { Snippet } from 'svelte'
2
3
  import type { IconName } from './Icon.svelte'
3
4
 
4
- /** One selectable row in a {@link Menu}. */
5
+ /**
6
+ * One selectable row in a {@link Menu}.
7
+ *
8
+ * Leading visual (decorative; the `label` carries the semantics). When more
9
+ * than one is set, precedence is `leading` → `swatch` → `emoji` → `icon`.
10
+ */
5
11
  export interface MenuItem {
6
12
  id: string
7
13
  label: string
8
14
  /** Optional leading glyph. */
9
15
  icon?: IconName
16
+ /**
17
+ * Custom leading content as a Svelte 5 snippet — arbitrary markup rendered
18
+ * in the icon slot (aria-hidden; keep it decorative).
19
+ */
20
+ leading?: Snippet
21
+ /**
22
+ * Convenience leading visual: any CSS color, rendered as a token-sized
23
+ * square color chip (zero radius) — e.g. a theme-picker swatch.
24
+ */
25
+ swatch?: string
26
+ /**
27
+ * Convenience leading visual: a text glyph (e.g. an emoji flag for a
28
+ * language picker), rendered in the icon slot.
29
+ */
30
+ emoji?: string
10
31
  /** Disabled rows are skipped by keyboard navigation and not selectable. */
11
32
  disabled?: boolean
12
33
  /** Marks the active/checked row (renders a check marker, `aria-checked`). */
@@ -17,7 +38,6 @@
17
38
  </script>
18
39
 
19
40
  <script lang="ts">
20
- import type { Snippet } from 'svelte'
21
41
  import Icon from './Icon.svelte'
22
42
  import { resolveComponentSize, type Size } from '../config.js'
23
43
 
@@ -172,12 +192,20 @@
172
192
  function onDocPointerDown(e: PointerEvent) {
173
193
  if (!open) return
174
194
  const t = e.target as Node
175
- if (triggerEl?.contains(t) || panelEl?.contains(t)) return
195
+ // DS-0067 / DS-0078: triggerEl/panelEl may be unbound (pre-mount, SSR-ish
196
+ // eager evaluation) — null-check before .contains().
197
+ if (triggerEl && triggerEl.contains(t)) return
198
+ if (panelEl && panelEl.contains(t)) return
176
199
  closeMenu(false)
177
200
  }
178
201
 
202
+ // SSR safety (DS-0067): same guard pattern as toast.svelte.ts — effects
203
+ // normally don't run on the server, but the guard is the house convention
204
+ // and protects against eager evaluation.
205
+ const hasDocument = typeof document !== 'undefined'
206
+
179
207
  $effect(() => {
180
- if (!open) return
208
+ if (!open || !hasDocument) return
181
209
  document.addEventListener('pointerdown', onDocPointerDown, true)
182
210
  return () => document.removeEventListener('pointerdown', onDocPointerDown, true)
183
211
  })
@@ -223,9 +251,19 @@
223
251
  tabindex={i === activeIndex ? 0 : -1}
224
252
  onclick={() => activate(item)}
225
253
  >
226
- {#if item.icon}<Icon name={item.icon} />{/if}
254
+ {#if item.leading}
255
+ <span class="lead" aria-hidden="true">{@render item.leading()}</span>
256
+ {:else if item.swatch}
257
+ <span class="lead swatch" style="background:{item.swatch}" aria-hidden="true"></span>
258
+ {:else if item.emoji}
259
+ <span class="lead emoji" aria-hidden="true">{item.emoji}</span>
260
+ {:else if item.icon}
261
+ <Icon name={item.icon} />
262
+ {/if}
227
263
  <span class="label">{item.label}</span>
228
- <span class="marker" aria-hidden="true">{#if item.selected}<Icon name="check" />{/if}</span>
264
+ <span class="marker" aria-hidden="true"
265
+ >{#if item.selected}<Icon name="check" />{/if}</span
266
+ >
229
267
  </button>
230
268
  {/each}
231
269
  </div>
@@ -341,6 +379,21 @@
341
379
  background: transparent;
342
380
  color: var(--ss-fg-faint);
343
381
  }
382
+ .item .lead {
383
+ flex: 0 0 auto;
384
+ display: inline-flex;
385
+ align-items: center;
386
+ justify-content: center;
387
+ width: var(--ss-icon);
388
+ height: var(--ss-icon);
389
+ }
390
+ .item .lead.swatch {
391
+ border: 1px solid var(--ss-line);
392
+ }
393
+ .item .lead.emoji {
394
+ font-size: var(--ss-icon);
395
+ line-height: 1;
396
+ }
344
397
  .item .label {
345
398
  flex: 1 1 auto;
346
399
  min-width: 0;
@@ -1,10 +1,31 @@
1
+ import type { Snippet } from 'svelte';
1
2
  import type { IconName } from './Icon.svelte';
2
- /** One selectable row in a {@link Menu}. */
3
+ /**
4
+ * One selectable row in a {@link Menu}.
5
+ *
6
+ * Leading visual (decorative; the `label` carries the semantics). When more
7
+ * than one is set, precedence is `leading` → `swatch` → `emoji` → `icon`.
8
+ */
3
9
  export interface MenuItem {
4
10
  id: string;
5
11
  label: string;
6
12
  /** Optional leading glyph. */
7
13
  icon?: IconName;
14
+ /**
15
+ * Custom leading content as a Svelte 5 snippet — arbitrary markup rendered
16
+ * in the icon slot (aria-hidden; keep it decorative).
17
+ */
18
+ leading?: Snippet;
19
+ /**
20
+ * Convenience leading visual: any CSS color, rendered as a token-sized
21
+ * square color chip (zero radius) — e.g. a theme-picker swatch.
22
+ */
23
+ swatch?: string;
24
+ /**
25
+ * Convenience leading visual: a text glyph (e.g. an emoji flag for a
26
+ * language picker), rendered in the icon slot.
27
+ */
28
+ emoji?: string;
8
29
  /** Disabled rows are skipped by keyboard navigation and not selectable. */
9
30
  disabled?: boolean;
10
31
  /** Marks the active/checked row (renders a check marker, `aria-checked`). */
@@ -12,7 +33,6 @@ export interface MenuItem {
12
33
  /** Fired when the row is activated. */
13
34
  onSelect?: (id: string) => void;
14
35
  }
15
- import type { Snippet } from 'svelte';
16
36
  import { type Size } from '../config.js';
17
37
  /** Where the panel attaches relative to the trigger. */
18
38
  type Align = 'start' | 'end';
@@ -51,9 +51,7 @@
51
51
 
52
52
  // Worded delta description so colour/arrow isn't the only signal (WCAG 1.4.1).
53
53
  const deltaDescription = $derived(
54
- [`${dir === 'up' ? 'increased' : 'decreased'} ${delta}`, deltaLabel]
55
- .filter(Boolean)
56
- .join(' '),
54
+ [`${dir === 'up' ? 'increased' : 'decreased'} ${delta}`, deltaLabel].filter(Boolean).join(' '),
57
55
  )
58
56
  </script>
59
57
 
@@ -69,7 +67,9 @@
69
67
  {#if delta}<div class="skeleton skeleton-delta" aria-hidden="true"></div>{/if}
70
68
  {:else}
71
69
  <div class="val" role="status" aria-live="polite">
72
- {#if prefix}<span class="small">{prefix}</span>{/if}{value}{#if suffix}<span class="small">{suffix}</span>{/if}
70
+ {#if prefix}<span class="small">{prefix}</span>{/if}{value}{#if suffix}<span class="small"
71
+ >{suffix}</span
72
+ >{/if}
73
73
  </div>
74
74
  {#if delta}
75
75
  <div class="delta {sentiment}" class:emphasis role="img" aria-label={deltaDescription}>