dssoca 0.5.0 → 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.
- package/README.md +39 -13
- package/dist/components/Accordion.svelte +297 -0
- package/dist/components/Accordion.svelte.d.ts +51 -0
- package/dist/components/Badge.svelte +113 -18
- package/dist/components/Badge.svelte.d.ts +28 -2
- package/dist/components/BottomNav.svelte +254 -0
- package/dist/components/BottomNav.svelte.d.ts +32 -0
- package/dist/components/Button.svelte +147 -10
- package/dist/components/Button.svelte.d.ts +21 -4
- package/dist/components/Card.svelte +173 -8
- package/dist/components/Card.svelte.d.ts +16 -1
- package/dist/components/Container.svelte +55 -0
- package/dist/components/Container.svelte.d.ts +16 -0
- package/dist/components/EmptyState.svelte +91 -9
- package/dist/components/EmptyState.svelte.d.ts +20 -3
- package/dist/components/Heading.svelte +83 -0
- package/dist/components/Heading.svelte.d.ts +17 -0
- package/dist/components/Icon.svelte +199 -24
- package/dist/components/Icon.svelte.d.ts +70 -2
- package/dist/components/Image.svelte +428 -0
- package/dist/components/Image.svelte.d.ts +49 -0
- package/dist/components/Input.svelte +173 -39
- package/dist/components/Input.svelte.d.ts +22 -0
- package/dist/components/Link.svelte +183 -0
- package/dist/components/Link.svelte.d.ts +29 -0
- package/dist/components/LogStream.svelte +403 -47
- package/dist/components/LogStream.svelte.d.ts +35 -7
- package/dist/components/Menu.svelte +408 -0
- package/dist/components/Menu.svelte.d.ts +66 -0
- package/dist/components/MetricTile.svelte +124 -12
- package/dist/components/MetricTile.svelte.d.ts +20 -0
- package/dist/components/SegmentedControl.svelte +220 -0
- package/dist/components/SegmentedControl.svelte.d.ts +37 -0
- package/dist/components/ServiceCard.svelte +226 -30
- package/dist/components/ServiceCard.svelte.d.ts +13 -1
- package/dist/components/Sidebar.svelte +377 -40
- package/dist/components/Sidebar.svelte.d.ts +18 -7
- package/dist/components/Sparkline.svelte +198 -13
- package/dist/components/Sparkline.svelte.d.ts +20 -1
- package/dist/components/Spinner.svelte +124 -0
- package/dist/components/Spinner.svelte.d.ts +74 -0
- package/dist/components/Textarea.svelte +214 -0
- package/dist/components/Textarea.svelte.d.ts +38 -0
- package/dist/components/Toaster.svelte +209 -12
- package/dist/components/Toaster.svelte.d.ts +3 -0
- package/dist/components/Topbar.svelte +293 -42
- package/dist/components/Topbar.svelte.d.ts +48 -1
- package/dist/dssoca.config.d.ts +1 -1
- package/dist/dssoca.config.js +10 -0
- package/dist/index.d.ts +16 -3
- package/dist/index.js +18 -2
- package/dist/theme.css +406 -24
- package/dist/toast.svelte.d.ts +49 -5
- package/dist/toast.svelte.js +165 -9
- package/dist/tokens.css +597 -0
- package/package.json +25 -4
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type Size } from '../config.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
label?: string;
|
|
4
|
+
id?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
oninput?: (e: Event & {
|
|
11
|
+
currentTarget: HTMLTextAreaElement;
|
|
12
|
+
}) => void;
|
|
13
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
14
|
+
size?: Size;
|
|
15
|
+
/** Marks the field invalid for assistive tech (aria-invalid). */
|
|
16
|
+
invalid?: boolean;
|
|
17
|
+
/** id(s) of element(s) describing the field (aria-describedby) — e.g. hint/error text. */
|
|
18
|
+
describedby?: string;
|
|
19
|
+
/** Supplementary helper text rendered under the textarea. */
|
|
20
|
+
hint?: string;
|
|
21
|
+
/** Error text rendered under the textarea; its presence implies aria-invalid and is announced to AT. */
|
|
22
|
+
error?: string;
|
|
23
|
+
/** Native readonly — value visible but not editable; rendered muted. */
|
|
24
|
+
readonly?: boolean;
|
|
25
|
+
/** Native maxlength. */
|
|
26
|
+
maxlength?: number;
|
|
27
|
+
/** Visible rows; acts as the minimum height (also while autosizing). */
|
|
28
|
+
rows?: number;
|
|
29
|
+
/** Grow with content: `field-sizing: content` where supported, JS fallback elsewhere. */
|
|
30
|
+
autosize?: boolean;
|
|
31
|
+
/** Row cap while autosizing — the field scrolls beyond it. */
|
|
32
|
+
maxRows?: number;
|
|
33
|
+
/** Any remaining native textarea attributes / event handlers are forwarded. */
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
}
|
|
36
|
+
declare const Textarea: import("svelte").Component<Props, {}, "value">;
|
|
37
|
+
type Textarea = ReturnType<typeof Textarea>;
|
|
38
|
+
export default Textarea;
|
|
@@ -1,46 +1,185 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { fly } from 'svelte/transition'
|
|
3
3
|
import { prefersReducedMotion } from 'svelte/motion'
|
|
4
|
-
import { toasts, type ToastKind } from '../toast.svelte.js'
|
|
4
|
+
import { toasts, type Toast, type ToastKind } from '../toast.svelte.js'
|
|
5
5
|
import { resolveComponentSize, type Size } from '../config.js'
|
|
6
6
|
|
|
7
|
+
type Position =
|
|
8
|
+
| 'top-right'
|
|
9
|
+
| 'top-left'
|
|
10
|
+
| 'bottom-right'
|
|
11
|
+
| 'bottom-left'
|
|
12
|
+
| 'top-center'
|
|
13
|
+
| 'bottom-center'
|
|
14
|
+
|
|
7
15
|
interface Props {
|
|
8
16
|
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
9
17
|
size?: Size
|
|
18
|
+
/** Where the stack anchors on screen. @default 'top-right' */
|
|
19
|
+
position?: Position
|
|
10
20
|
}
|
|
11
21
|
|
|
12
|
-
let { size }: Props = $props()
|
|
22
|
+
let { size, position = 'top-right' }: Props = $props()
|
|
13
23
|
|
|
14
|
-
const glyph: Record<ToastKind, string> = { success: '✓', error: '✕', info: 'i' }
|
|
24
|
+
const glyph: Record<ToastKind, string> = { success: '✓', error: '✕', info: 'i', loading: '' }
|
|
15
25
|
// Honor prefers-reduced-motion: collapse the fly transition to an instant swap.
|
|
16
|
-
const
|
|
26
|
+
const reduce = $derived(prefersReducedMotion.current)
|
|
27
|
+
|
|
28
|
+
// Fly duration reads the motion token (DS-0068) — the JS transition tracks
|
|
29
|
+
// `--ss-dur-fast` so theme/motion overrides apply, instead of a hardcoded
|
|
30
|
+
// 180ms. Falls back to 180ms (the previous value) when the stylesheet isn't
|
|
31
|
+
// present (e.g. jsdom, or the token entry not loaded).
|
|
32
|
+
let rootEl = $state<HTMLElement>()
|
|
33
|
+
function parseMs(raw: string): number | undefined {
|
|
34
|
+
const v = raw.trim()
|
|
35
|
+
if (!v) return undefined
|
|
36
|
+
const n = parseFloat(v)
|
|
37
|
+
if (!Number.isFinite(n) || n < 0) return undefined
|
|
38
|
+
return v.endsWith('ms') ? n : v.endsWith('s') ? n * 1000 : n
|
|
39
|
+
}
|
|
40
|
+
const tokenDuration = $derived.by(() => {
|
|
41
|
+
if (!rootEl || typeof getComputedStyle !== 'function') return 180
|
|
42
|
+
return parseMs(getComputedStyle(rootEl).getPropertyValue('--ss-dur-fast')) ?? 180
|
|
43
|
+
})
|
|
44
|
+
const flyDuration = $derived(reduce ? 0 : tokenDuration)
|
|
45
|
+
// Bottom anchors slide in from below; centered ones come straight down/up.
|
|
46
|
+
const flyX = $derived(position.endsWith('center') ? 0 : position.endsWith('left') ? -16 : 16)
|
|
47
|
+
const flyY = $derived(position.endsWith('center') ? (position.startsWith('top') ? -16 : 16) : 0)
|
|
48
|
+
|
|
49
|
+
// ── swipe-to-dismiss ──────────────────────────────────────────────
|
|
50
|
+
let dragId = $state<number | null>(null)
|
|
51
|
+
let dragDx = $state(0)
|
|
52
|
+
let dragStartX = 0
|
|
53
|
+
let dragPointer: number | null = null
|
|
54
|
+
|
|
55
|
+
const SWIPE_THRESHOLD = 64
|
|
56
|
+
|
|
57
|
+
function onPointerDown(e: PointerEvent, t: Toast) {
|
|
58
|
+
if (reduce || e.button !== 0) return
|
|
59
|
+
// Ignore drags that start on the controls (buttons own their clicks).
|
|
60
|
+
if ((e.target as HTMLElement).closest('button')) return
|
|
61
|
+
dragId = t.id
|
|
62
|
+
dragDx = 0
|
|
63
|
+
dragStartX = e.clientX
|
|
64
|
+
dragPointer = e.pointerId
|
|
65
|
+
toasts.pause(t.id)
|
|
66
|
+
;(e.currentTarget as HTMLElement).setPointerCapture(e.pointerId)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function onPointerMove(e: PointerEvent, t: Toast) {
|
|
70
|
+
if (dragId !== t.id || e.pointerId !== dragPointer) return
|
|
71
|
+
dragDx = e.clientX - dragStartX
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function endDrag(e: PointerEvent, t: Toast) {
|
|
75
|
+
if (dragId !== t.id || e.pointerId !== dragPointer) return
|
|
76
|
+
const passed = Math.abs(dragDx) >= SWIPE_THRESHOLD
|
|
77
|
+
dragId = null
|
|
78
|
+
dragPointer = null
|
|
79
|
+
if (passed) toasts.dismiss(t.id)
|
|
80
|
+
else {
|
|
81
|
+
dragDx = 0
|
|
82
|
+
toasts.resume(t.id)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function runAction(t: Toast) {
|
|
87
|
+
const keep = t.action?.onClick() === false
|
|
88
|
+
if (!keep) toasts.dismiss(t.id)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function onKeydown(e: KeyboardEvent, t: Toast) {
|
|
92
|
+
if (e.key === 'Escape') {
|
|
93
|
+
e.stopPropagation()
|
|
94
|
+
toasts.dismiss(t.id)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
17
97
|
</script>
|
|
18
98
|
|
|
19
|
-
<div
|
|
99
|
+
<div
|
|
100
|
+
class="ss-toaster"
|
|
101
|
+
aria-label="Notifications"
|
|
102
|
+
data-position={position}
|
|
103
|
+
data-size-variant={resolveComponentSize('Toaster', size)}
|
|
104
|
+
bind:this={rootEl}
|
|
105
|
+
>
|
|
20
106
|
{#each toasts.items as t (t.id)}
|
|
21
107
|
<div
|
|
22
108
|
class="ss-toast {t.kind}"
|
|
109
|
+
class:dragging={dragId === t.id}
|
|
23
110
|
role={t.kind === 'error' ? 'alert' : 'status'}
|
|
24
111
|
aria-live={t.kind === 'error' ? 'assertive' : 'polite'}
|
|
25
|
-
|
|
112
|
+
tabindex="-1"
|
|
113
|
+
style:transform={dragId === t.id ? `translateX(${dragDx}px)` : undefined}
|
|
114
|
+
style:opacity={dragId === t.id ? Math.max(0.3, 1 - Math.abs(dragDx) / 200) : undefined}
|
|
115
|
+
transition:fly={{ x: flyX, y: flyY, duration: flyDuration }}
|
|
116
|
+
onpointerenter={() => toasts.pause(t.id)}
|
|
117
|
+
onpointerleave={() => dragId !== t.id && toasts.resume(t.id)}
|
|
118
|
+
onfocusin={() => toasts.pause(t.id)}
|
|
119
|
+
onfocusout={() => toasts.resume(t.id)}
|
|
120
|
+
onpointerdown={(e) => onPointerDown(e, t)}
|
|
121
|
+
onpointermove={(e) => onPointerMove(e, t)}
|
|
122
|
+
onpointerup={(e) => endDrag(e, t)}
|
|
123
|
+
onpointercancel={(e) => endDrag(e, t)}
|
|
124
|
+
onkeydown={(e) => onKeydown(e, t)}
|
|
26
125
|
>
|
|
27
|
-
|
|
126
|
+
{#if t.kind === 'loading'}
|
|
127
|
+
<span class="ic spinner" class:still={reduce} aria-hidden="true"></span>
|
|
128
|
+
{:else}
|
|
129
|
+
<span class="ic" aria-hidden="true">{glyph[t.kind]}</span>
|
|
130
|
+
{/if}
|
|
28
131
|
<span class="msg">{t.message}</span>
|
|
29
|
-
|
|
132
|
+
{#if t.action}
|
|
133
|
+
<button class="action" type="button" onclick={() => runAction(t)}>
|
|
134
|
+
{t.action.label}
|
|
135
|
+
</button>
|
|
136
|
+
{/if}
|
|
137
|
+
<button class="x" type="button" aria-label="Dismiss" onclick={() => toasts.dismiss(t.id)}
|
|
138
|
+
>×</button
|
|
139
|
+
>
|
|
30
140
|
</div>
|
|
31
141
|
{/each}
|
|
32
142
|
</div>
|
|
33
143
|
|
|
34
144
|
<style>.ss-toaster {
|
|
35
145
|
position: fixed;
|
|
36
|
-
top: var(--ss-s-4);
|
|
37
|
-
right: var(--ss-s-4);
|
|
38
146
|
z-index: 1000;
|
|
39
147
|
display: flex;
|
|
40
148
|
flex-direction: column;
|
|
41
149
|
gap: var(--ss-s-2);
|
|
42
150
|
max-width: min(360px, 100vw - var(--ss-s-8));
|
|
43
151
|
pointer-events: none;
|
|
152
|
+
top: var(--ss-s-4);
|
|
153
|
+
right: var(--ss-s-4);
|
|
154
|
+
}
|
|
155
|
+
.ss-toaster[data-position=top-left] {
|
|
156
|
+
right: auto;
|
|
157
|
+
left: var(--ss-s-4);
|
|
158
|
+
}
|
|
159
|
+
.ss-toaster[data-position=bottom-right] {
|
|
160
|
+
top: auto;
|
|
161
|
+
bottom: var(--ss-s-4);
|
|
162
|
+
flex-direction: column-reverse;
|
|
163
|
+
}
|
|
164
|
+
.ss-toaster[data-position=bottom-left] {
|
|
165
|
+
top: auto;
|
|
166
|
+
right: auto;
|
|
167
|
+
bottom: var(--ss-s-4);
|
|
168
|
+
left: var(--ss-s-4);
|
|
169
|
+
flex-direction: column-reverse;
|
|
170
|
+
}
|
|
171
|
+
.ss-toaster[data-position=top-center] {
|
|
172
|
+
right: auto;
|
|
173
|
+
left: 50%;
|
|
174
|
+
transform: translateX(-50%);
|
|
175
|
+
}
|
|
176
|
+
.ss-toaster[data-position=bottom-center] {
|
|
177
|
+
top: auto;
|
|
178
|
+
right: auto;
|
|
179
|
+
bottom: var(--ss-s-4);
|
|
180
|
+
left: 50%;
|
|
181
|
+
transform: translateX(-50%);
|
|
182
|
+
flex-direction: column-reverse;
|
|
44
183
|
}
|
|
45
184
|
|
|
46
185
|
.ss-toast {
|
|
@@ -56,6 +195,15 @@
|
|
|
56
195
|
font-family: var(--ss-font-mono);
|
|
57
196
|
font-size: var(--ss-ui-md);
|
|
58
197
|
color: var(--ss-fg);
|
|
198
|
+
touch-action: pan-y;
|
|
199
|
+
outline: none;
|
|
200
|
+
}
|
|
201
|
+
.ss-toast:focus-visible {
|
|
202
|
+
border-color: var(--ss-line-strong);
|
|
203
|
+
box-shadow: var(--ss-shadow-pop), 0 0 0 2px var(--ss-primary);
|
|
204
|
+
}
|
|
205
|
+
.ss-toast:not(.dragging) {
|
|
206
|
+
transition: transform var(--ss-dur-fast) var(--ss-ease);
|
|
59
207
|
}
|
|
60
208
|
.ss-toast.success {
|
|
61
209
|
border-left-color: var(--ss-primary);
|
|
@@ -66,12 +214,15 @@
|
|
|
66
214
|
.ss-toast.info {
|
|
67
215
|
border-left-color: var(--ss-cyan);
|
|
68
216
|
}
|
|
217
|
+
.ss-toast.loading {
|
|
218
|
+
border-left-color: var(--ss-fg-faint);
|
|
219
|
+
}
|
|
69
220
|
.ss-toast .ic {
|
|
70
221
|
display: inline-flex;
|
|
71
222
|
align-items: center;
|
|
72
223
|
justify-content: center;
|
|
73
|
-
width:
|
|
74
|
-
height:
|
|
224
|
+
width: var(--ss-toast-ic);
|
|
225
|
+
height: var(--ss-toast-ic);
|
|
75
226
|
font-size: var(--ss-ui-sm);
|
|
76
227
|
color: var(--ss-fg-on-primary);
|
|
77
228
|
flex: none;
|
|
@@ -85,10 +236,40 @@
|
|
|
85
236
|
.ss-toast.info .ic {
|
|
86
237
|
background: var(--ss-cyan);
|
|
87
238
|
}
|
|
239
|
+
.ss-toast .spinner {
|
|
240
|
+
box-sizing: border-box;
|
|
241
|
+
background: transparent;
|
|
242
|
+
border: 2px solid var(--ss-line-strong);
|
|
243
|
+
border-top-color: var(--ss-cyan);
|
|
244
|
+
animation: ss-toast-spin 0.7s linear infinite;
|
|
245
|
+
}
|
|
246
|
+
.ss-toast .spinner.still {
|
|
247
|
+
animation: none;
|
|
248
|
+
border-color: var(--ss-cyan);
|
|
249
|
+
}
|
|
88
250
|
.ss-toast .msg {
|
|
89
251
|
flex: 1;
|
|
90
252
|
line-height: 1.3;
|
|
91
253
|
}
|
|
254
|
+
.ss-toast .action {
|
|
255
|
+
flex: none;
|
|
256
|
+
background: none;
|
|
257
|
+
border: 1px solid var(--ss-line-strong);
|
|
258
|
+
color: var(--ss-fg);
|
|
259
|
+
cursor: pointer;
|
|
260
|
+
font-family: inherit;
|
|
261
|
+
font-size: var(--ss-ui-sm);
|
|
262
|
+
line-height: 1;
|
|
263
|
+
padding: var(--ss-s-1) var(--ss-s-2);
|
|
264
|
+
}
|
|
265
|
+
.ss-toast .action:hover {
|
|
266
|
+
background: var(--ss-hover);
|
|
267
|
+
border-color: var(--ss-fg-faint);
|
|
268
|
+
}
|
|
269
|
+
.ss-toast .action:focus-visible {
|
|
270
|
+
outline: 2px solid var(--ss-primary);
|
|
271
|
+
outline-offset: 1px;
|
|
272
|
+
}
|
|
92
273
|
.ss-toast .x {
|
|
93
274
|
flex: none;
|
|
94
275
|
background: none;
|
|
@@ -101,4 +282,20 @@
|
|
|
101
282
|
}
|
|
102
283
|
.ss-toast .x:hover {
|
|
103
284
|
color: var(--ss-fg);
|
|
285
|
+
}
|
|
286
|
+
.ss-toast .x:focus-visible {
|
|
287
|
+
outline: 2px solid var(--ss-primary);
|
|
288
|
+
outline-offset: 1px;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
@keyframes ss-toast-spin {
|
|
292
|
+
to {
|
|
293
|
+
transform: rotate(360deg);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
@media (prefers-reduced-motion: reduce) {
|
|
297
|
+
.ss-toast .spinner {
|
|
298
|
+
animation: none;
|
|
299
|
+
border-color: var(--ss-cyan);
|
|
300
|
+
}
|
|
104
301
|
}</style>
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { type Size } from '../config.js';
|
|
2
|
+
type Position = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';
|
|
2
3
|
interface Props {
|
|
3
4
|
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
4
5
|
size?: Size;
|
|
6
|
+
/** Where the stack anchors on screen. @default 'top-right' */
|
|
7
|
+
position?: Position;
|
|
5
8
|
}
|
|
6
9
|
declare const Toaster: import("svelte").Component<Props, {}, "">;
|
|
7
10
|
type Toaster = ReturnType<typeof Toaster>;
|