dssoca 0.19.0 → 0.21.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 (155) hide show
  1. package/README.md +3 -3
  2. package/dist/components/Accordion.svelte +30 -54
  3. package/dist/components/Badge.svelte +12 -7
  4. package/dist/components/Badge.svelte.d.ts +2 -1
  5. package/dist/components/BottomNav.svelte +18 -28
  6. package/dist/components/BoxPlot.svelte +34 -7
  7. package/dist/components/BumpChart.svelte +65 -26
  8. package/dist/components/Button.svelte +23 -1
  9. package/dist/components/Button.svelte.d.ts +5 -1
  10. package/dist/components/Card.svelte +32 -14
  11. package/dist/components/Card.svelte.d.ts +4 -1
  12. package/dist/components/Chart.svelte +166 -32
  13. package/dist/components/Chart.svelte.d.ts +13 -1
  14. package/dist/components/Checkbox.svelte +210 -0
  15. package/dist/components/Checkbox.svelte.d.ts +38 -0
  16. package/dist/components/DateField.svelte +1 -1
  17. package/dist/components/FileDrop.svelte +113 -77
  18. package/dist/components/FileDrop.svelte.d.ts +12 -2
  19. package/dist/components/Heatmap.svelte +128 -50
  20. package/dist/components/Heatmap.svelte.d.ts +2 -1
  21. package/dist/components/Icon.svelte +12 -3
  22. package/dist/components/Icon.svelte.d.ts +4 -0
  23. package/dist/components/Image.svelte +44 -44
  24. package/dist/components/Input.svelte +11 -6
  25. package/dist/components/Link.svelte +25 -14
  26. package/dist/components/LogStream.svelte +48 -33
  27. package/dist/components/Menu.svelte +81 -102
  28. package/dist/components/Menu.svelte.d.ts +8 -2
  29. package/dist/components/MetricTile.svelte +11 -1
  30. package/dist/components/MetricTile.svelte.d.ts +6 -0
  31. package/dist/components/Modal.svelte +108 -21
  32. package/dist/components/Modal.svelte.d.ts +18 -5
  33. package/dist/components/NumberField.svelte +44 -22
  34. package/dist/components/Pagination.svelte +54 -41
  35. package/dist/components/Pagination.svelte.d.ts +6 -2
  36. package/dist/components/Popover.svelte +247 -0
  37. package/dist/components/Popover.svelte.d.ts +36 -0
  38. package/dist/components/RadioGroup.svelte +227 -0
  39. package/dist/components/RadioGroup.svelte.d.ts +42 -0
  40. package/dist/components/ScatterPlot.svelte +42 -7
  41. package/dist/components/SearchPalette.svelte +216 -136
  42. package/dist/components/SearchPalette.svelte.d.ts +11 -4
  43. package/dist/components/SegmentedControl.svelte +47 -59
  44. package/dist/components/SegmentedControl.svelte.d.ts +7 -2
  45. package/dist/components/Select.svelte +3 -4
  46. package/dist/components/ServiceCard.svelte +105 -68
  47. package/dist/components/ServiceCard.svelte.d.ts +8 -3
  48. package/dist/components/ShortcutsHelp.svelte +49 -48
  49. package/dist/components/Sidebar.svelte +88 -117
  50. package/dist/components/Switch.svelte +24 -18
  51. package/dist/components/Switch.svelte.d.ts +6 -2
  52. package/dist/components/Table.svelte +29 -44
  53. package/dist/components/Table.svelte.d.ts +6 -2
  54. package/dist/components/Tabs.svelte +223 -0
  55. package/dist/components/Tabs.svelte.d.ts +51 -0
  56. package/dist/components/Textarea.svelte +1 -1
  57. package/dist/components/TierList.svelte +45 -49
  58. package/dist/components/TierList.svelte.d.ts +7 -3
  59. package/dist/components/Toaster.svelte +154 -32
  60. package/dist/components/Tooltip.svelte +122 -18
  61. package/dist/components/Tooltip.svelte.d.ts +1 -1
  62. package/dist/components/Topbar.svelte +29 -49
  63. package/dist/core/accordion.d.ts +32 -0
  64. package/dist/core/accordion.js +53 -0
  65. package/dist/core/behaviors/focusable.d.ts +5 -0
  66. package/dist/core/behaviors/focusable.js +14 -0
  67. package/dist/core/behaviors/roving.d.ts +13 -0
  68. package/dist/core/behaviors/roving.js +29 -0
  69. package/dist/core/bottom-nav.d.ts +36 -0
  70. package/dist/core/bottom-nav.js +33 -0
  71. package/dist/core/chart-nav.d.ts +53 -0
  72. package/dist/core/chart-nav.js +62 -0
  73. package/dist/core/checkbox.d.ts +36 -0
  74. package/dist/core/checkbox.js +29 -0
  75. package/dist/core/file-drop.d.ts +75 -0
  76. package/dist/core/file-drop.js +101 -0
  77. package/dist/core/image.d.ts +59 -0
  78. package/dist/core/image.js +64 -0
  79. package/dist/core/input.d.ts +21 -0
  80. package/dist/core/input.js +17 -0
  81. package/dist/core/log-stream.d.ts +51 -0
  82. package/dist/core/log-stream.js +50 -0
  83. package/dist/core/menu.d.ts +70 -0
  84. package/dist/core/menu.js +84 -0
  85. package/dist/core/modal.d.ts +59 -0
  86. package/dist/core/modal.js +44 -0
  87. package/dist/core/number-field.d.ts +47 -0
  88. package/dist/core/number-field.js +64 -0
  89. package/dist/core/pagination.d.ts +59 -0
  90. package/dist/core/pagination.js +65 -0
  91. package/dist/core/popover.d.ts +68 -0
  92. package/dist/core/popover.js +55 -0
  93. package/dist/core/radio.d.ts +36 -0
  94. package/dist/core/radio.js +48 -0
  95. package/dist/core/search-palette.d.ts +124 -0
  96. package/dist/core/search-palette.js +149 -0
  97. package/dist/core/segmented.d.ts +46 -0
  98. package/dist/core/segmented.js +66 -0
  99. package/dist/core/shortcuts-help.d.ts +56 -0
  100. package/dist/core/shortcuts-help.js +50 -0
  101. package/dist/core/sidebar.d.ts +63 -0
  102. package/dist/core/sidebar.js +84 -0
  103. package/dist/core/switch.d.ts +19 -0
  104. package/dist/core/switch.js +11 -0
  105. package/dist/core/table.d.ts +40 -0
  106. package/dist/core/table.js +57 -0
  107. package/dist/core/tabs.d.ts +84 -0
  108. package/dist/core/tabs.js +90 -0
  109. package/dist/{tierlist-core.d.ts → core/tierlist.d.ts} +77 -5
  110. package/dist/{tierlist-core.js → core/tierlist.js} +64 -7
  111. package/dist/core/toast.d.ts +112 -0
  112. package/dist/{toast-core.js → core/toast.js} +48 -2
  113. package/dist/core/tooltip.d.ts +47 -0
  114. package/dist/core/tooltip.js +51 -0
  115. package/dist/core/topbar.d.ts +41 -0
  116. package/dist/core/topbar.js +52 -0
  117. package/dist/dssoca.config.d.ts +1 -1
  118. package/dist/dssoca.config.js +4 -0
  119. package/dist/icons.d.ts +19 -2
  120. package/dist/icons.js +42 -3
  121. package/dist/index.d.ts +15 -2
  122. package/dist/index.js +10 -2
  123. package/dist/theme.css +47 -0
  124. package/dist/toast.svelte.d.ts +2 -2
  125. package/dist/toast.svelte.js +1 -1
  126. package/dist/tokens.css +47 -0
  127. package/dist/vanilla/accordion.js +35 -32
  128. package/dist/vanilla/checkbox.d.ts +8 -0
  129. package/dist/vanilla/checkbox.js +43 -0
  130. package/dist/vanilla/delegate.d.ts +2 -0
  131. package/dist/vanilla/delegate.js +9 -0
  132. package/dist/vanilla/fields.js +46 -28
  133. package/dist/vanilla/index.d.ts +5 -1
  134. package/dist/vanilla/index.js +17 -4
  135. package/dist/vanilla/menu.js +101 -84
  136. package/dist/vanilla/modal.d.ts +7 -1
  137. package/dist/vanilla/modal.js +120 -15
  138. package/dist/vanilla/popover.d.ts +10 -0
  139. package/dist/vanilla/popover.js +129 -0
  140. package/dist/vanilla/radio.d.ts +3 -0
  141. package/dist/vanilla/radio.js +54 -0
  142. package/dist/vanilla/segmented.js +50 -43
  143. package/dist/vanilla/switch.d.ts +2 -1
  144. package/dist/vanilla/switch.js +13 -8
  145. package/dist/vanilla/tabs.d.ts +2 -0
  146. package/dist/vanilla/tabs.js +87 -0
  147. package/dist/vanilla/tierlist.d.ts +1 -1
  148. package/dist/vanilla/tierlist.js +34 -34
  149. package/dist/vanilla/toast.d.ts +13 -5
  150. package/dist/vanilla/toast.js +132 -16
  151. package/dist/vanilla/tooltip.d.ts +5 -1
  152. package/dist/vanilla/tooltip.js +78 -19
  153. package/dist/vanilla.css +675 -160
  154. package/package.json +1 -1
  155. package/dist/toast-core.d.ts +0 -61
@@ -0,0 +1,227 @@
1
+ <script module lang="ts">
2
+ /** One option in a {@link RadioGroup}. */
3
+ export interface RadioOption {
4
+ value: string
5
+ label: string
6
+ disabled?: boolean
7
+ }
8
+ </script>
9
+
10
+ <script lang="ts">
11
+ // ─────────────────────────────────────────────────────────────────────────
12
+ // RadioGroup — DS-0197. Native `<input type="radio">` elements sharing a
13
+ // `name` inside a `role="radiogroup"` named by its visible label. Arrow keys
14
+ // (wrapping, skipping disabled, mirrored under RTL), Space and form
15
+ // submission come from the platform, so this file handles no key at all.
16
+ // House rule: square radios (zero radius) — a filled inner square marks the
17
+ // selected one. Each input IS its box (`appearance: none`), so the base focus
18
+ // ring lands on it.
19
+ // ─────────────────────────────────────────────────────────────────────────
20
+ import { resolveComponentSize, type Size } from '../config.js'
21
+ import {
22
+ radioEnabled,
23
+ radioGroupAttrs,
24
+ radioInputAttrs,
25
+ radioPress,
26
+ radioTabStop,
27
+ type RadioState,
28
+ } from '../core/radio.js'
29
+
30
+ interface Props {
31
+ /** Mutually-exclusive options: { value, label, disabled? }. */
32
+ options?: RadioOption[]
33
+ /** Selected option value (bindable); unset = nothing selected. */
34
+ value?: string
35
+ /**
36
+ * Form field name shared by the radios (the selected value is submitted
37
+ * with the form). Defaults to a generated per-instance name, which is what
38
+ * makes the inputs one native group.
39
+ */
40
+ name?: string
41
+ /**
42
+ * Visible group label; names the radiogroup. Required (WCAG 2.2 AA): a
43
+ * radiogroup with no name leaves AT users without context for the choice.
44
+ */
45
+ label: string
46
+ /** Stack the options (`vertical`, default) or lay them out in a row. */
47
+ orientation?: 'vertical' | 'horizontal'
48
+ /**
49
+ * Disable the whole group: every radio is `disabled` and the group carries
50
+ * `aria-disabled="true"`. Per-option `disabled` still works on its own.
51
+ */
52
+ disabled?: boolean
53
+ /** Token size (sm|md|lg); inherits the global size when unset. */
54
+ size?: Size
55
+ /**
56
+ * Fired when the selection changes (after `value` updates), with the new
57
+ * value. There is no `details.reason`: the native inputs report a press and
58
+ * an arrow key as the same event.
59
+ */
60
+ onChange?: (value: string) => void
61
+ }
62
+
63
+ let {
64
+ options = [],
65
+ value = $bindable(),
66
+ name,
67
+ label,
68
+ orientation = 'vertical',
69
+ disabled = false,
70
+ size,
71
+ onChange,
72
+ }: Props = $props()
73
+
74
+ const uid = $props.id()
75
+ const labelId = `${uid}-label`
76
+ // Radios only form a native group (one selection, arrow keys) when they share a name.
77
+ const groupName = $derived(name ?? `${uid}-radio`)
78
+
79
+ let inputs = $state<(HTMLInputElement | undefined)[]>([])
80
+
81
+ // The group's state as `core/radio.ts` sees it. Every decision that is ours
82
+ // (enabled options, what a pick selects, the tab stop) is made there, shared
83
+ // with vanilla/radio.ts.
84
+ const group = $derived<RadioState>({
85
+ selected: options.findIndex((o) => o.value === value),
86
+ enabled: radioEnabled(
87
+ options.map((o) => Boolean(o.disabled)),
88
+ disabled,
89
+ ),
90
+ })
91
+ const tabStop = $derived(radioTabStop(group))
92
+
93
+ // The browser has already checked the input (press, Space or arrow key); the
94
+ // core confirms the pick and the result is written back.
95
+ function onPick(index: number) {
96
+ const action = radioPress(group, index)
97
+ const opt = options[index]
98
+ if (!action || !opt) {
99
+ // Not ours to select: put the DOM back on the current selection.
100
+ inputs.forEach((el, i) => {
101
+ if (el) el.checked = i === group.selected
102
+ })
103
+ return
104
+ }
105
+ if (action.changed) {
106
+ value = opt.value
107
+ onChange?.(opt.value)
108
+ }
109
+ }
110
+
111
+ const sizeAttr = $derived(resolveComponentSize('RadioGroup', size))
112
+ </script>
113
+
114
+ <div
115
+ class="ss-radio-group"
116
+ aria-labelledby={labelId}
117
+ data-orientation={orientation}
118
+ data-size-variant={sizeAttr}
119
+ {...radioGroupAttrs(disabled)}
120
+ >
121
+ <span id={labelId} class="legend">{label}</span>
122
+ <div class="options">
123
+ {#each options as opt, i (opt.value)}
124
+ <label class="option">
125
+ <span class="control">
126
+ <input
127
+ bind:this={inputs[i]}
128
+ class="input"
129
+ type="radio"
130
+ name={groupName}
131
+ value={opt.value}
132
+ checked={i === group.selected}
133
+ disabled={disabled || Boolean(opt.disabled)}
134
+ {...radioInputAttrs(i, tabStop)}
135
+ onchange={() => onPick(i)}
136
+ />
137
+ <span class="dot" aria-hidden="true"></span>
138
+ </span>
139
+ <span class="label">{opt.label}</span>
140
+ </label>
141
+ {/each}
142
+ </div>
143
+ </div>
144
+
145
+ <style>.ss-radio-group {
146
+ display: inline-flex;
147
+ flex-direction: column;
148
+ gap: var(--ss-gap-xs);
149
+ max-inline-size: 100%;
150
+ }
151
+ .ss-radio-group .legend {
152
+ font: 500 var(--ss-ui-sm)/1.3 var(--ss-font-body);
153
+ color: var(--ss-fg-muted);
154
+ }
155
+ .ss-radio-group .options {
156
+ display: flex;
157
+ flex-direction: column;
158
+ gap: var(--ss-radio-gap, var(--ss-gap-xs));
159
+ }
160
+ .ss-radio-group[data-orientation=horizontal] .options {
161
+ flex-flow: row wrap;
162
+ column-gap: var(--ss-gap);
163
+ }
164
+ .ss-radio-group .option {
165
+ display: inline-flex;
166
+ align-items: center;
167
+ gap: var(--ss-gap-sm);
168
+ min-inline-size: var(--ss-s-6);
169
+ min-block-size: var(--ss-s-6);
170
+ cursor: pointer;
171
+ }
172
+ .ss-radio-group .control {
173
+ position: relative;
174
+ flex: 0 0 auto;
175
+ display: inline-grid;
176
+ inline-size: var(--ss-radio-size, calc(var(--ss-control-font) + 4px));
177
+ block-size: var(--ss-radio-size, calc(var(--ss-control-font) + 4px));
178
+ }
179
+ .ss-radio-group .input {
180
+ grid-area: 1/1;
181
+ appearance: none;
182
+ box-sizing: border-box;
183
+ inline-size: 100%;
184
+ block-size: 100%;
185
+ margin: 0;
186
+ border-radius: 0;
187
+ border: 1px solid var(--ss-fg-faint);
188
+ background: var(--ss-bg);
189
+ cursor: inherit;
190
+ transition: border-color var(--ss-dur-fast) var(--ss-ease);
191
+ }
192
+ .ss-radio-group .input:not(:disabled):hover {
193
+ border-color: var(--ss-fg);
194
+ }
195
+ .ss-radio-group .input:checked {
196
+ border-color: var(--ss-primary);
197
+ }
198
+ .ss-radio-group .dot {
199
+ grid-area: 1/1;
200
+ place-self: center;
201
+ display: none;
202
+ inline-size: calc(var(--ss-radio-size, calc(var(--ss-control-font) + 4px)) - 8px);
203
+ block-size: calc(var(--ss-radio-size, calc(var(--ss-control-font) + 4px)) - 8px);
204
+ background: var(--ss-primary);
205
+ pointer-events: none;
206
+ }
207
+ .ss-radio-group .input:checked + .dot {
208
+ display: block;
209
+ }
210
+ .ss-radio-group .label {
211
+ font: 500 var(--ss-control-font)/1.3 var(--ss-font-body);
212
+ color: var(--ss-fg);
213
+ user-select: none;
214
+ }
215
+ .ss-radio-group .option:has(.input:disabled) {
216
+ cursor: not-allowed;
217
+ }
218
+ .ss-radio-group .option:has(.input:disabled) .control,
219
+ .ss-radio-group .option:has(.input:disabled) .label {
220
+ opacity: 0.45;
221
+ }
222
+
223
+ @media (prefers-reduced-motion: reduce) {
224
+ .ss-radio-group .input {
225
+ transition: none;
226
+ }
227
+ }</style>
@@ -0,0 +1,42 @@
1
+ /** One option in a {@link RadioGroup}. */
2
+ export interface RadioOption {
3
+ value: string;
4
+ label: string;
5
+ disabled?: boolean;
6
+ }
7
+ import { type Size } from '../config.js';
8
+ interface Props {
9
+ /** Mutually-exclusive options: { value, label, disabled? }. */
10
+ options?: RadioOption[];
11
+ /** Selected option value (bindable); unset = nothing selected. */
12
+ value?: string;
13
+ /**
14
+ * Form field name shared by the radios (the selected value is submitted
15
+ * with the form). Defaults to a generated per-instance name, which is what
16
+ * makes the inputs one native group.
17
+ */
18
+ name?: string;
19
+ /**
20
+ * Visible group label; names the radiogroup. Required (WCAG 2.2 AA): a
21
+ * radiogroup with no name leaves AT users without context for the choice.
22
+ */
23
+ label: string;
24
+ /** Stack the options (`vertical`, default) or lay them out in a row. */
25
+ orientation?: 'vertical' | 'horizontal';
26
+ /**
27
+ * Disable the whole group: every radio is `disabled` and the group carries
28
+ * `aria-disabled="true"`. Per-option `disabled` still works on its own.
29
+ */
30
+ disabled?: boolean;
31
+ /** Token size (sm|md|lg); inherits the global size when unset. */
32
+ size?: Size;
33
+ /**
34
+ * Fired when the selection changes (after `value` updates), with the new
35
+ * value. There is no `details.reason`: the native inputs report a press and
36
+ * an arrow key as the same event.
37
+ */
38
+ onChange?: (value: string) => void;
39
+ }
40
+ declare const RadioGroup: import("svelte").Component<Props, {}, "value">;
41
+ type RadioGroup = ReturnType<typeof RadioGroup>;
42
+ export default RadioGroup;
@@ -16,6 +16,7 @@
16
16
  import { scaleLinear, scaleSqrt } from 'd3-scale'
17
17
  import { extent, max } from 'd3-array'
18
18
  import { resolveComponentSize, type Size } from '../config.js'
19
+ import { chartMarkKey, chartTabStop, chartWindowKey } from '../core/chart-nav.js'
19
20
 
20
21
  interface Props {
21
22
  /** One dot per datum. Two encoded axes (x, y), optional `size` and `color`. */
@@ -165,11 +166,37 @@
165
166
  function hide() {
166
167
  active = null
167
168
  }
169
+
170
+ // Roving tabindex (DS-0161): the chart is ONE tab stop; arrow keys / Home / End move focus
171
+ // between points. The last-focused point keeps tabindex 0 (the first by default).
172
+ let focusIndex = $state(0)
173
+ const tabIndex = $derived(chartTabStop(focusIndex, marks.length))
174
+ let pointEls: (SVGCircleElement | null)[] = $state([])
175
+
176
+ function onPointKeydown(e: KeyboardEvent, i: number) {
177
+ const result = chartMarkKey(
178
+ { index: i, count: marks.length, escape: 'consume', tooltipOpen: active !== null },
179
+ e.key,
180
+ )
181
+ if (!result) return
182
+ if (result.preventDefault) e.preventDefault()
183
+ if (result.action.type === 'dismiss') return hide()
184
+ const next = result.action.index
185
+ focusIndex = next
186
+ pointEls[next]?.focus()
187
+ }
188
+
189
+ // WCAG 1.4.13: Escape dismisses a hover-opened tooltip too, wherever focus is.
190
+ function onWindowKeydown(e: KeyboardEvent) {
191
+ if (chartWindowKey(active !== null, e.key)) hide()
192
+ }
168
193
  function datumLabel(label: string, x: number, y: number): string {
169
194
  return `${label}: ${fmtX(x)}, ${fmtY(y)}`
170
195
  }
171
196
  </script>
172
197
 
198
+ <svelte:window onkeydown={onWindowKeydown} />
199
+
173
200
  <div
174
201
  class="ss-scatter"
175
202
  class:fluid
@@ -220,23 +247,31 @@
220
247
  {/each}
221
248
 
222
249
  <!-- points -->
223
- {#each marks as m}
250
+ {#each marks as m, i}
251
+ <!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
224
252
  <circle
253
+ bind:this={pointEls[i]}
225
254
  class="point"
226
255
  cx={m.cx}
227
256
  cy={m.cy}
228
257
  r={m.r}
229
258
  style="fill:{m.color}"
230
- tabindex="0"
231
- role="button"
259
+ tabindex={i === tabIndex ? 0 : -1}
260
+ role="img"
232
261
  aria-label={datumLabel(m.label, m.x, m.y)}
233
- onfocus={() => show(m.label, m.x, m.y, m.cx, m.cy)}
262
+ onkeydown={(e) => onPointKeydown(e, i)}
263
+ onfocus={() => {
264
+ focusIndex = i
265
+ show(m.label, m.x, m.y, m.cx, m.cy)
266
+ }}
234
267
  onblur={hide}
235
268
  onmouseenter={() => show(m.label, m.x, m.y, m.cx, m.cy)}
236
269
  onmouseleave={hide}
237
270
  />
238
271
  {#if showLabels}
239
- <text class="point-label" x={m.cx + m.r + 4} y={m.cy} dy="0.32em">{m.label}</text>
272
+ <text class="point-label" aria-hidden="true" x={m.cx + m.r + 4} y={m.cy} dy="0.32em"
273
+ >{m.label}</text
274
+ >
240
275
  {/if}
241
276
  {/each}
242
277
 
@@ -259,7 +294,7 @@
259
294
  {#if tooltip && active}
260
295
  <div
261
296
  class="tooltip"
262
- role="status"
297
+ aria-hidden="true"
263
298
  style="left:{((active.cx + M.left) / width) * 100}%;top:{((active.cy + M.top) / height) *
264
299
  100}%"
265
300
  >
@@ -352,7 +387,7 @@
352
387
  fill: var(--ss-fg-muted);
353
388
  }
354
389
  .ss-scatter .point {
355
- cursor: pointer;
390
+ cursor: default;
356
391
  fill-opacity: 0.85;
357
392
  transition: fill-opacity var(--ss-dur-fast) var(--ss-ease);
358
393
  }