dssoca 0.2.0 → 0.8.2
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 +54 -18
- package/dist/components/Accordion.svelte +281 -0
- package/dist/components/Accordion.svelte.d.ts +47 -0
- package/dist/components/Badge.svelte +144 -7
- package/dist/components/Badge.svelte.d.ts +31 -2
- package/dist/components/BottomNav.svelte +216 -0
- package/dist/components/BottomNav.svelte.d.ts +30 -0
- package/dist/components/Button.svelte +187 -6
- package/dist/components/Button.svelte.d.ts +24 -4
- package/dist/components/Card.svelte +203 -8
- package/dist/components/Card.svelte.d.ts +21 -1
- package/dist/components/EmptyState.svelte +123 -36
- package/dist/components/EmptyState.svelte.d.ts +17 -1
- package/dist/components/Icon.svelte +191 -12
- package/dist/components/Icon.svelte.d.ts +69 -2
- package/dist/components/Image.svelte +430 -0
- package/dist/components/Image.svelte.d.ts +49 -0
- package/dist/components/Input.svelte +206 -18
- package/dist/components/Input.svelte.d.ts +29 -0
- package/dist/components/Link.svelte +148 -0
- package/dist/components/Link.svelte.d.ts +22 -0
- package/dist/components/LogStream.svelte +403 -21
- package/dist/components/LogStream.svelte.d.ts +37 -6
- package/dist/components/Menu.svelte +355 -0
- package/dist/components/Menu.svelte.d.ts +46 -0
- package/dist/components/MetricTile.svelte +161 -7
- package/dist/components/MetricTile.svelte.d.ts +23 -0
- package/dist/components/SegmentedControl.svelte +208 -0
- package/dist/components/SegmentedControl.svelte.d.ts +30 -0
- package/dist/components/ServiceCard.svelte +270 -9
- package/dist/components/ServiceCard.svelte.d.ts +16 -1
- package/dist/components/Sidebar.svelte +391 -25
- package/dist/components/Sidebar.svelte.d.ts +20 -6
- package/dist/components/Sparkline.svelte +213 -6
- package/dist/components/Sparkline.svelte.d.ts +24 -0
- package/dist/components/Toaster.svelte +273 -60
- package/dist/components/Toaster.svelte.d.ts +9 -16
- package/dist/components/Topbar.svelte +273 -17
- package/dist/components/Topbar.svelte.d.ts +23 -0
- package/dist/config.d.ts +32 -14
- package/dist/config.js +43 -17
- package/dist/dssoca.config.d.ts +50 -0
- package/dist/dssoca.config.js +45 -0
- package/dist/index.d.ts +12 -5
- package/dist/index.js +14 -4
- package/dist/theme.css +587 -382
- package/dist/toast.svelte.d.ts +49 -5
- package/dist/toast.svelte.js +165 -9
- package/package.json +17 -3
- package/dist/components/PassocaMark.svelte +0 -15
- package/dist/components/PassocaMark.svelte.d.ts +0 -7
|
@@ -1,26 +1,221 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte'
|
|
3
|
+
import { resolveComponentSize, type Size } from '../config.js'
|
|
3
4
|
|
|
4
5
|
interface Props {
|
|
5
|
-
title
|
|
6
|
+
/** Heading text, or a Snippet for inline icons/badges in the title. */
|
|
7
|
+
title?: string | Snippet
|
|
8
|
+
/** Secondary label rendered to the right of the title. */
|
|
6
9
|
meta?: string
|
|
10
|
+
/** Muted description rendered under the heading. */
|
|
11
|
+
description?: string
|
|
12
|
+
/** Header controls (buttons, menus) rendered to the right. */
|
|
7
13
|
action?: Snippet
|
|
14
|
+
/** Full-bleed visual rendered above the head (zero side padding). */
|
|
15
|
+
media?: Snippet
|
|
16
|
+
/** Footer band mirroring the head, rendered only when provided. */
|
|
17
|
+
footer?: Snippet
|
|
8
18
|
children: Snippet
|
|
19
|
+
/** Makes the whole card a primary link to this href. */
|
|
20
|
+
href?: string
|
|
21
|
+
/** Makes the whole card clickable; pairs with keyboard activation. */
|
|
22
|
+
onclick?: (e: MouseEvent | KeyboardEvent) => void
|
|
23
|
+
/** Surface style: outlined (default) or elevated (shadow tokens). */
|
|
24
|
+
variant?: 'outlined' | 'elevated'
|
|
25
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
26
|
+
size?: Size
|
|
27
|
+
/** Heading level for the title (aria-level), for correct document outline. */
|
|
28
|
+
titleLevel?: number
|
|
29
|
+
}
|
|
30
|
+
let {
|
|
31
|
+
title,
|
|
32
|
+
meta,
|
|
33
|
+
description,
|
|
34
|
+
action,
|
|
35
|
+
media,
|
|
36
|
+
footer,
|
|
37
|
+
children,
|
|
38
|
+
href,
|
|
39
|
+
onclick,
|
|
40
|
+
variant = 'outlined',
|
|
41
|
+
size,
|
|
42
|
+
titleLevel = 3,
|
|
43
|
+
}: Props = $props()
|
|
44
|
+
|
|
45
|
+
// A stable id so the region can be labelled by its title for assistive tech.
|
|
46
|
+
const titleId = $props.id()
|
|
47
|
+
|
|
48
|
+
const isTitleSnippet = $derived(typeof title === 'function')
|
|
49
|
+
const interactive = $derived(Boolean(href || onclick))
|
|
50
|
+
|
|
51
|
+
function onKeydown(e: KeyboardEvent) {
|
|
52
|
+
if (onclick && !href && (e.key === 'Enter' || e.key === ' ')) {
|
|
53
|
+
e.preventDefault()
|
|
54
|
+
onclick(e)
|
|
55
|
+
}
|
|
9
56
|
}
|
|
10
|
-
let { title, meta, action, children }: Props = $props()
|
|
11
57
|
</script>
|
|
12
58
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
59
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex -- role is set to "button" in the same condition -->
|
|
60
|
+
<div
|
|
61
|
+
class="ss-card"
|
|
62
|
+
class:elevated={variant === 'elevated'}
|
|
63
|
+
class:interactive
|
|
64
|
+
data-size-variant={resolveComponentSize('Card', size)}
|
|
65
|
+
role={interactive && !href ? 'button' : undefined}
|
|
66
|
+
tabindex={interactive && !href ? 0 : undefined}
|
|
67
|
+
aria-labelledby={title ? titleId : undefined}
|
|
68
|
+
onclick={!href ? onclick : undefined}
|
|
69
|
+
onkeydown={!href ? onKeydown : undefined}
|
|
70
|
+
>
|
|
71
|
+
{#if media}
|
|
72
|
+
<div class="media">{@render media()}</div>
|
|
73
|
+
{/if}
|
|
74
|
+
{#if title || meta || description || action}
|
|
75
|
+
<div class="head">
|
|
76
|
+
<div class="heading">
|
|
77
|
+
<div class="title" id={titleId} role="heading" aria-level={titleLevel}>
|
|
78
|
+
{#if isTitleSnippet}
|
|
79
|
+
{@render (title as Snippet)()}
|
|
80
|
+
{:else}
|
|
81
|
+
{title}
|
|
82
|
+
{/if}
|
|
83
|
+
</div>
|
|
84
|
+
{#if description}<div class="desc">{description}</div>{/if}
|
|
85
|
+
</div>
|
|
86
|
+
<div class="actions">
|
|
18
87
|
{#if meta}<div class="meta">{meta}</div>{/if}
|
|
19
88
|
{#if action}{@render action()}{/if}
|
|
20
89
|
</div>
|
|
21
90
|
</div>
|
|
22
91
|
{/if}
|
|
23
|
-
<div class="
|
|
92
|
+
<div class="body">
|
|
24
93
|
{@render children()}
|
|
25
94
|
</div>
|
|
95
|
+
{#if footer}
|
|
96
|
+
<div class="foot">{@render footer()}</div>
|
|
97
|
+
{/if}
|
|
98
|
+
{#if href}
|
|
99
|
+
<a class="overlay" {href} {onclick} onkeydown={onKeydown} aria-labelledby={title ? titleId : undefined}>
|
|
100
|
+
<span class="sr-only">{typeof title === 'string' ? title : 'Open'}</span>
|
|
101
|
+
</a>
|
|
102
|
+
{/if}
|
|
26
103
|
</div>
|
|
104
|
+
|
|
105
|
+
<style>.ss-card {
|
|
106
|
+
position: relative;
|
|
107
|
+
border: 1px solid var(--ss-line);
|
|
108
|
+
background: var(--ss-bg-elev);
|
|
109
|
+
border-radius: 0;
|
|
110
|
+
}
|
|
111
|
+
.ss-card.elevated {
|
|
112
|
+
border-color: transparent;
|
|
113
|
+
box-shadow: var(--ss-shadow-1);
|
|
114
|
+
}
|
|
115
|
+
.ss-card.interactive {
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
transition: box-shadow var(--ss-dur-fast) var(--ss-ease), border-color var(--ss-dur-fast) var(--ss-ease);
|
|
118
|
+
}
|
|
119
|
+
.ss-card.interactive:hover {
|
|
120
|
+
border-color: var(--ss-line-strong);
|
|
121
|
+
}
|
|
122
|
+
.ss-card.interactive.elevated:hover {
|
|
123
|
+
box-shadow: var(--ss-shadow-2);
|
|
124
|
+
}
|
|
125
|
+
.ss-card.interactive:focus-within {
|
|
126
|
+
border-color: var(--ss-line-strong);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.media {
|
|
130
|
+
display: block;
|
|
131
|
+
line-height: 0;
|
|
132
|
+
}
|
|
133
|
+
.media :global(img),
|
|
134
|
+
.media :global(svg),
|
|
135
|
+
.media :global(video) {
|
|
136
|
+
display: block;
|
|
137
|
+
width: 100%;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.head {
|
|
141
|
+
padding: var(--ss-panel-head-py) var(--ss-panel-head-px);
|
|
142
|
+
border-bottom: 1px solid var(--ss-line);
|
|
143
|
+
display: flex;
|
|
144
|
+
align-items: flex-start;
|
|
145
|
+
justify-content: space-between;
|
|
146
|
+
gap: var(--ss-gap-sm);
|
|
147
|
+
font-family: var(--ss-font-mono);
|
|
148
|
+
font-size: var(--ss-ui-sm);
|
|
149
|
+
color: var(--ss-fg-faint);
|
|
150
|
+
text-transform: uppercase;
|
|
151
|
+
letter-spacing: 0.06em;
|
|
152
|
+
}
|
|
153
|
+
.head .heading {
|
|
154
|
+
display: flex;
|
|
155
|
+
flex-direction: column;
|
|
156
|
+
gap: var(--ss-s-1);
|
|
157
|
+
min-width: 0;
|
|
158
|
+
}
|
|
159
|
+
.head .title {
|
|
160
|
+
color: var(--ss-fg);
|
|
161
|
+
letter-spacing: 0.06em;
|
|
162
|
+
}
|
|
163
|
+
.head .desc {
|
|
164
|
+
color: var(--ss-fg-muted);
|
|
165
|
+
text-transform: none;
|
|
166
|
+
letter-spacing: normal;
|
|
167
|
+
font-family: var(--ss-font-body);
|
|
168
|
+
}
|
|
169
|
+
.head .meta {
|
|
170
|
+
color: var(--ss-fg-faint);
|
|
171
|
+
text-transform: lowercase;
|
|
172
|
+
letter-spacing: 0.04em;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.actions {
|
|
176
|
+
position: relative;
|
|
177
|
+
z-index: 1;
|
|
178
|
+
display: flex;
|
|
179
|
+
gap: var(--ss-gap);
|
|
180
|
+
align-items: center;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.body {
|
|
184
|
+
padding: var(--ss-panel-body-py) var(--ss-panel-body-px);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.foot {
|
|
188
|
+
position: relative;
|
|
189
|
+
z-index: 1;
|
|
190
|
+
padding: var(--ss-panel-head-py) var(--ss-panel-head-px);
|
|
191
|
+
border-top: 1px solid var(--ss-line);
|
|
192
|
+
display: flex;
|
|
193
|
+
align-items: center;
|
|
194
|
+
justify-content: space-between;
|
|
195
|
+
gap: var(--ss-gap-sm);
|
|
196
|
+
font-family: var(--ss-font-mono);
|
|
197
|
+
font-size: var(--ss-ui-sm);
|
|
198
|
+
color: var(--ss-fg-faint);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.overlay {
|
|
202
|
+
position: static;
|
|
203
|
+
}
|
|
204
|
+
.overlay::after {
|
|
205
|
+
content: "";
|
|
206
|
+
position: absolute;
|
|
207
|
+
inset: 0;
|
|
208
|
+
z-index: 0;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.sr-only {
|
|
212
|
+
position: absolute;
|
|
213
|
+
width: 1px;
|
|
214
|
+
height: 1px;
|
|
215
|
+
padding: 0;
|
|
216
|
+
margin: -1px;
|
|
217
|
+
overflow: hidden;
|
|
218
|
+
clip: rect(0 0 0 0);
|
|
219
|
+
white-space: nowrap;
|
|
220
|
+
border: 0;
|
|
221
|
+
}</style>
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type Size } from '../config.js';
|
|
2
3
|
interface Props {
|
|
3
|
-
title
|
|
4
|
+
/** Heading text, or a Snippet for inline icons/badges in the title. */
|
|
5
|
+
title?: string | Snippet;
|
|
6
|
+
/** Secondary label rendered to the right of the title. */
|
|
4
7
|
meta?: string;
|
|
8
|
+
/** Muted description rendered under the heading. */
|
|
9
|
+
description?: string;
|
|
10
|
+
/** Header controls (buttons, menus) rendered to the right. */
|
|
5
11
|
action?: Snippet;
|
|
12
|
+
/** Full-bleed visual rendered above the head (zero side padding). */
|
|
13
|
+
media?: Snippet;
|
|
14
|
+
/** Footer band mirroring the head, rendered only when provided. */
|
|
15
|
+
footer?: Snippet;
|
|
6
16
|
children: Snippet;
|
|
17
|
+
/** Makes the whole card a primary link to this href. */
|
|
18
|
+
href?: string;
|
|
19
|
+
/** Makes the whole card clickable; pairs with keyboard activation. */
|
|
20
|
+
onclick?: (e: MouseEvent | KeyboardEvent) => void;
|
|
21
|
+
/** Surface style: outlined (default) or elevated (shadow tokens). */
|
|
22
|
+
variant?: 'outlined' | 'elevated';
|
|
23
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
24
|
+
size?: Size;
|
|
25
|
+
/** Heading level for the title (aria-level), for correct document outline. */
|
|
26
|
+
titleLevel?: number;
|
|
7
27
|
}
|
|
8
28
|
declare const Card: import("svelte").Component<Props, {}, "">;
|
|
9
29
|
type Card = ReturnType<typeof Card>;
|
|
@@ -1,50 +1,137 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte'
|
|
3
|
+
import { resolveComponentSize, type Size } from '../config.js'
|
|
3
4
|
|
|
4
5
|
interface Props {
|
|
5
|
-
variant?: 'empty' | 'error'
|
|
6
|
+
variant?: 'empty' | 'error' | 'no-results'
|
|
6
7
|
title: string
|
|
7
8
|
message?: string
|
|
9
|
+
/** Decorative glyph fallback when no `visual` snippet is given. */
|
|
8
10
|
icon?: string
|
|
11
|
+
/** Visual slot — drop in an <Icon>, illustration or <img>; rendered aria-hidden. */
|
|
12
|
+
visual?: Snippet
|
|
9
13
|
action?: Snippet
|
|
14
|
+
/** Secondary, lower-emphasis action rendered beside the primary one. */
|
|
15
|
+
secondaryAction?: Snippet
|
|
16
|
+
/** Low-emphasis footer (tertiary links) rendered below everything. */
|
|
17
|
+
footer?: Snippet
|
|
18
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
19
|
+
size?: Size
|
|
20
|
+
/** Heading level for the title (aria-level). `false` renders a plain <p> with no heading role. */
|
|
21
|
+
headingLevel?: number | false
|
|
22
|
+
/** Compact density — drops padding and shrinks the title for inline/cell use. */
|
|
23
|
+
compact?: boolean
|
|
24
|
+
/** Remove the centered max-width cap and span the container. */
|
|
25
|
+
fullWidth?: boolean
|
|
10
26
|
}
|
|
11
|
-
let {
|
|
27
|
+
let {
|
|
28
|
+
variant = 'empty',
|
|
29
|
+
title,
|
|
30
|
+
message,
|
|
31
|
+
icon,
|
|
32
|
+
visual,
|
|
33
|
+
action,
|
|
34
|
+
secondaryAction,
|
|
35
|
+
footer,
|
|
36
|
+
size,
|
|
37
|
+
headingLevel = 2,
|
|
38
|
+
compact = false,
|
|
39
|
+
fullWidth = false,
|
|
40
|
+
}: Props = $props()
|
|
41
|
+
|
|
42
|
+
// error → assertive alert; everything else announces politely without moving focus (WCAG 4.1.3).
|
|
43
|
+
const role = $derived(
|
|
44
|
+
variant === 'error' ? 'alert' : 'status'
|
|
45
|
+
)
|
|
12
46
|
</script>
|
|
13
47
|
|
|
14
|
-
<div
|
|
15
|
-
|
|
16
|
-
|
|
48
|
+
<div
|
|
49
|
+
class="ss-empty {variant}"
|
|
50
|
+
class:compact
|
|
51
|
+
class:full-width={fullWidth}
|
|
52
|
+
data-size-variant={resolveComponentSize('EmptyState', size)}
|
|
53
|
+
{role}
|
|
54
|
+
aria-atomic="true"
|
|
55
|
+
>
|
|
56
|
+
{#if visual}
|
|
57
|
+
<div class="ic" aria-hidden="true">{@render visual()}</div>
|
|
58
|
+
{:else if icon}
|
|
59
|
+
<div class="ic glyph" aria-hidden="true">{icon}</div>
|
|
60
|
+
{/if}
|
|
61
|
+
{#if headingLevel === false}
|
|
62
|
+
<p class="title">{title}</p>
|
|
63
|
+
{:else}
|
|
64
|
+
<p class="title" role="heading" aria-level={headingLevel}>{title}</p>
|
|
65
|
+
{/if}
|
|
17
66
|
{#if message}<p class="msg">{message}</p>{/if}
|
|
18
|
-
{#if action
|
|
67
|
+
{#if action || secondaryAction}
|
|
68
|
+
<div class="act">
|
|
69
|
+
{#if action}{@render action()}{/if}
|
|
70
|
+
{#if secondaryAction}{@render secondaryAction()}{/if}
|
|
71
|
+
</div>
|
|
72
|
+
{/if}
|
|
73
|
+
{#if footer}<div class="foot">{@render footer()}</div>{/if}
|
|
19
74
|
</div>
|
|
20
75
|
|
|
21
|
-
<style
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
76
|
+
<style>.ss-empty {
|
|
77
|
+
display: flex;
|
|
78
|
+
flex-direction: column;
|
|
79
|
+
align-items: center;
|
|
80
|
+
gap: var(--ss-s-3);
|
|
81
|
+
text-align: center;
|
|
82
|
+
padding: var(--ss-s-12) var(--ss-s-4);
|
|
83
|
+
max-width: var(--ss-empty-max-w);
|
|
84
|
+
margin-inline: auto;
|
|
85
|
+
}
|
|
86
|
+
.ss-empty.full-width {
|
|
87
|
+
max-width: none;
|
|
88
|
+
}
|
|
89
|
+
.ss-empty .ic {
|
|
90
|
+
line-height: 1;
|
|
91
|
+
margin-bottom: var(--ss-s-1);
|
|
92
|
+
}
|
|
93
|
+
.ss-empty .ic.glyph {
|
|
94
|
+
font-size: var(--ss-empty-glyph);
|
|
95
|
+
}
|
|
96
|
+
.ss-empty .title {
|
|
97
|
+
margin: 0;
|
|
98
|
+
font-family: var(--ss-font-display);
|
|
99
|
+
font-size: var(--ss-size-h2);
|
|
100
|
+
color: var(--ss-fg);
|
|
101
|
+
}
|
|
102
|
+
.ss-empty.error .title {
|
|
103
|
+
color: var(--ss-red);
|
|
104
|
+
}
|
|
105
|
+
.ss-empty .msg {
|
|
106
|
+
margin: 0;
|
|
107
|
+
color: var(--ss-fg-muted);
|
|
108
|
+
font-size: var(--ss-ui-md);
|
|
109
|
+
max-width: 40ch;
|
|
110
|
+
line-height: var(--ss-leading);
|
|
111
|
+
}
|
|
112
|
+
.ss-empty .act {
|
|
113
|
+
margin-top: var(--ss-s-4);
|
|
114
|
+
display: flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
justify-content: center;
|
|
117
|
+
gap: var(--ss-s-3);
|
|
118
|
+
flex-wrap: wrap;
|
|
119
|
+
}
|
|
120
|
+
.ss-empty .foot {
|
|
121
|
+
margin-top: var(--ss-s-2);
|
|
122
|
+
color: var(--ss-fg-faint);
|
|
123
|
+
font-size: var(--ss-ui-sm);
|
|
124
|
+
}
|
|
125
|
+
.ss-empty.compact {
|
|
126
|
+
gap: var(--ss-s-2);
|
|
127
|
+
padding: var(--ss-s-6) var(--ss-s-3);
|
|
128
|
+
}
|
|
129
|
+
.ss-empty.compact .title {
|
|
130
|
+
font-size: var(--ss-size-h3);
|
|
131
|
+
}
|
|
132
|
+
.ss-empty.compact .ic.glyph {
|
|
133
|
+
font-size: var(--ss-empty-glyph-compact);
|
|
134
|
+
}
|
|
135
|
+
.ss-empty.compact .act {
|
|
136
|
+
margin-top: var(--ss-s-3);
|
|
137
|
+
}</style>
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type Size } from '../config.js';
|
|
2
3
|
interface Props {
|
|
3
|
-
variant?: 'empty' | 'error';
|
|
4
|
+
variant?: 'empty' | 'error' | 'no-results';
|
|
4
5
|
title: string;
|
|
5
6
|
message?: string;
|
|
7
|
+
/** Decorative glyph fallback when no `visual` snippet is given. */
|
|
6
8
|
icon?: string;
|
|
9
|
+
/** Visual slot — drop in an <Icon>, illustration or <img>; rendered aria-hidden. */
|
|
10
|
+
visual?: Snippet;
|
|
7
11
|
action?: Snippet;
|
|
12
|
+
/** Secondary, lower-emphasis action rendered beside the primary one. */
|
|
13
|
+
secondaryAction?: Snippet;
|
|
14
|
+
/** Low-emphasis footer (tertiary links) rendered below everything. */
|
|
15
|
+
footer?: Snippet;
|
|
16
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
17
|
+
size?: Size;
|
|
18
|
+
/** Heading level for the title (aria-level). `false` renders a plain <p> with no heading role. */
|
|
19
|
+
headingLevel?: number | false;
|
|
20
|
+
/** Compact density — drops padding and shrinks the title for inline/cell use. */
|
|
21
|
+
compact?: boolean;
|
|
22
|
+
/** Remove the centered max-width cap and span the container. */
|
|
23
|
+
fullWidth?: boolean;
|
|
8
24
|
}
|
|
9
25
|
declare const EmptyState: import("svelte").Component<Props, {}, "">;
|
|
10
26
|
type EmptyState = ReturnType<typeof EmptyState>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
-
|
|
2
|
+
/** Curated glyph set. `target`'s centre dot is a filled circle in the *outline*
|
|
3
|
+
* variant — handled by the `variant` switch in markup, not a per-glyph fill hack. */
|
|
4
|
+
const BUILTIN_PATHS = {
|
|
3
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"/>',
|
|
4
6
|
activity: '<path d="M3 12h4l3-8 4 16 3-8h4"/>',
|
|
5
7
|
database: '<rect x="3" y="4" width="18" height="16"/><path d="M3 9h18M8 4v5"/>',
|
|
@@ -15,32 +17,209 @@
|
|
|
15
17
|
check: '<path d="M5 12l4 4L19 6"/>',
|
|
16
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"/>',
|
|
17
19
|
wallet: '<rect x="3" y="6" width="18" height="14"/><path d="M3 10h18M17 14h2"/>',
|
|
18
|
-
target: '<circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="5"/><circle cx="12" cy="12" r="1.5"
|
|
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"/>',
|
|
22
|
+
} as const
|
|
23
|
+
|
|
24
|
+
export type IconName = keyof typeof BUILTIN_PATHS
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The curated built-in glyphs plus any runtime-registered ones.
|
|
28
|
+
* (`PATHS` is kept as the public name for backward compatibility.)
|
|
29
|
+
*/
|
|
30
|
+
export const PATHS: Record<string, string> = { ...BUILTIN_PATHS }
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Register (or override) a glyph at runtime so `<Icon name="foo" />` resolves
|
|
34
|
+
* raw SVG inner markup that isn't part of the curated {@link IconName} union.
|
|
35
|
+
* The markup is rendered verbatim inside the icon's `<svg viewBox="0 0 24 24">`.
|
|
36
|
+
*
|
|
37
|
+
* registerIcon('heart', '<path d="M12 21 4 13a5 5 0 0 1 7-7l1 1 1-1a5 5 0 0 1 7 7z"/>')
|
|
38
|
+
* <Icon name={'heart' as IconName} />
|
|
39
|
+
*/
|
|
40
|
+
export function registerIcon(name: string, paths: string): void {
|
|
41
|
+
PATHS[name] = paths
|
|
19
42
|
}
|
|
20
43
|
|
|
21
|
-
|
|
44
|
+
/** Look a glyph up; built-ins first, then runtime registrations. */
|
|
45
|
+
export function resolveIcon(name: string): string | undefined {
|
|
46
|
+
return PATHS[name]
|
|
47
|
+
}
|
|
22
48
|
</script>
|
|
23
49
|
|
|
24
50
|
<script lang="ts">
|
|
51
|
+
import { resolveComponentSize, type Size } from '../config.js'
|
|
52
|
+
|
|
53
|
+
/** Resolved px for each token size — used to keep absolute stroke optically constant. */
|
|
54
|
+
const SIZE_PX: Record<Size, number> = { sm: 14, md: 16, lg: 20 }
|
|
55
|
+
const DEFAULT_PX = SIZE_PX.md
|
|
56
|
+
|
|
25
57
|
interface Props {
|
|
26
58
|
name: IconName
|
|
27
|
-
size
|
|
59
|
+
/** Token-driven size (sm|md|lg); inherits the active size when unset. */
|
|
60
|
+
size?: Size
|
|
61
|
+
/** Explicit pixel size — overrides the token sizing. */
|
|
62
|
+
px?: number
|
|
63
|
+
/**
|
|
64
|
+
* Raw SVG inner markup escape hatch — rendered when `name` is not a known
|
|
65
|
+
* (built-in or runtime-registered) glyph. Lets callers pass one-off icons
|
|
66
|
+
* without registering them globally.
|
|
67
|
+
*/
|
|
68
|
+
paths?: string
|
|
69
|
+
/** Accessible name; rendered as a real <title> and wired via aria-labelledby. */
|
|
70
|
+
title?: string
|
|
71
|
+
/** Extended description, rendered as <desc> and appended to aria-labelledby. */
|
|
72
|
+
desc?: string
|
|
73
|
+
/**
|
|
74
|
+
* Mark the icon purely decorative (aria-hidden, no a11y name). Defaults to
|
|
75
|
+
* true when no `title` is given, false when a `title` is present.
|
|
76
|
+
*/
|
|
77
|
+
decorative?: boolean
|
|
78
|
+
/** Spin the glyph (e.g. a loader). Honours prefers-reduced-motion. */
|
|
79
|
+
spin?: boolean
|
|
80
|
+
/** Quarter-turn rotation. */
|
|
81
|
+
rotate?: 0 | 90 | 180 | 270
|
|
82
|
+
/** Mirror the glyph. */
|
|
83
|
+
flip?: 'horizontal' | 'vertical'
|
|
84
|
+
/** outline (stroked, default) | solid (filled with currentColor). */
|
|
85
|
+
variant?: 'outline' | 'solid'
|
|
86
|
+
/** Stroke weight in viewBox units (default 2). */
|
|
87
|
+
strokeWidth?: number
|
|
88
|
+
/** Keep `strokeWidth` optically constant across sizes (recompute from resolved px). */
|
|
89
|
+
absoluteStroke?: boolean
|
|
28
90
|
class?: string
|
|
29
91
|
}
|
|
30
|
-
let {
|
|
92
|
+
let {
|
|
93
|
+
name,
|
|
94
|
+
size,
|
|
95
|
+
px,
|
|
96
|
+
paths,
|
|
97
|
+
title,
|
|
98
|
+
desc,
|
|
99
|
+
decorative,
|
|
100
|
+
spin = false,
|
|
101
|
+
rotate = 0,
|
|
102
|
+
flip,
|
|
103
|
+
variant = 'outline',
|
|
104
|
+
strokeWidth = 2,
|
|
105
|
+
absoluteStroke = false,
|
|
106
|
+
class: cls = '',
|
|
107
|
+
}: Props = $props()
|
|
108
|
+
|
|
109
|
+
const dim = $derived(px != null ? `${px}px` : 'var(--ss-icon)')
|
|
110
|
+
|
|
111
|
+
// Resolve the glyph: explicit `paths` escape hatch → registered/built-in → warn.
|
|
112
|
+
const markup = $derived.by(() => {
|
|
113
|
+
if (paths != null) return paths
|
|
114
|
+
const found = resolveIcon(name)
|
|
115
|
+
if (found != null) return found
|
|
116
|
+
if (typeof console !== 'undefined') {
|
|
117
|
+
console.warn(`[dssoca] Icon: unknown name "${name}" (no registered glyph). Rendering empty; pass \`paths\` or call registerIcon().`)
|
|
118
|
+
}
|
|
119
|
+
return ''
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
// Optically-constant stroke: recompute weight from the resolved px so a
|
|
123
|
+
// 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
|
+
)
|
|
128
|
+
|
|
129
|
+
const isSolid = $derived(variant === 'solid')
|
|
130
|
+
|
|
131
|
+
// Decorative unless an explicit title (or explicit decorative=false) opts in.
|
|
132
|
+
const isDecorative = $derived(decorative ?? title == null)
|
|
133
|
+
|
|
134
|
+
// Unique ids for <title>/<desc>, wired through aria-labelledby.
|
|
135
|
+
const uid = $props.id()
|
|
136
|
+
const titleId = $derived(title ? `${uid}-t` : undefined)
|
|
137
|
+
const descId = $derived(desc ? `${uid}-d` : undefined)
|
|
138
|
+
const labelledBy = $derived(
|
|
139
|
+
[titleId, descId].filter(Boolean).join(' ') || undefined,
|
|
140
|
+
)
|
|
141
|
+
const labelled = $derived(!isDecorative && labelledBy != null)
|
|
142
|
+
|
|
143
|
+
const esc = (s: string) =>
|
|
144
|
+
s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
145
|
+
|
|
146
|
+
// <title>/<desc> are folded into the same @html string as the glyph so the
|
|
147
|
+
// SVG carries no Svelte {#if} comment anchors (keeps innerHTML clean for AT
|
|
148
|
+
// and tests). a11y ids still resolve via aria-labelledby above.
|
|
149
|
+
const inner = $derived(
|
|
150
|
+
(title ? `<title id="${titleId}">${esc(title)}</title>` : '') +
|
|
151
|
+
(desc ? `<desc id="${descId}">${esc(desc)}</desc>` : '') +
|
|
152
|
+
markup,
|
|
153
|
+
)
|
|
31
154
|
</script>
|
|
32
155
|
|
|
33
156
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
34
157
|
<svg
|
|
35
158
|
viewBox="0 0 24 24"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
stroke="currentColor"
|
|
40
|
-
stroke-width="2"
|
|
159
|
+
fill={isSolid ? 'currentColor' : 'none'}
|
|
160
|
+
stroke={isSolid ? 'none' : 'currentColor'}
|
|
161
|
+
stroke-width={stroke}
|
|
41
162
|
stroke-linecap="square"
|
|
42
163
|
stroke-linejoin="miter"
|
|
43
|
-
class={cls}
|
|
164
|
+
class="ss-icon {cls}"
|
|
165
|
+
class:spin
|
|
166
|
+
class:flip-h={flip === 'horizontal'}
|
|
167
|
+
class:flip-v={flip === 'vertical'}
|
|
168
|
+
data-size-variant={resolveComponentSize('Icon', size)}
|
|
169
|
+
data-rotate={rotate || undefined}
|
|
170
|
+
style="width:{dim};height:{dim}"
|
|
171
|
+
role={labelled ? 'img' : undefined}
|
|
172
|
+
aria-labelledby={labelled ? labelledBy : undefined}
|
|
173
|
+
aria-hidden={isDecorative ? 'true' : undefined}
|
|
174
|
+
focusable="false"
|
|
44
175
|
>
|
|
45
|
-
{@html
|
|
176
|
+
{@html inner}
|
|
46
177
|
</svg>
|
|
178
|
+
|
|
179
|
+
<style>.ss-icon {
|
|
180
|
+
display: inline-block;
|
|
181
|
+
flex: none;
|
|
182
|
+
transform-origin: center;
|
|
183
|
+
}
|
|
184
|
+
.ss-icon :global(.ss-icon-dot) {
|
|
185
|
+
fill: currentColor;
|
|
186
|
+
stroke: none;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.ss-icon[data-rotate="90"] {
|
|
190
|
+
transform: rotate(90deg);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.ss-icon[data-rotate="180"] {
|
|
194
|
+
transform: rotate(180deg);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.ss-icon[data-rotate="270"] {
|
|
198
|
+
transform: rotate(270deg);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.ss-icon.flip-h {
|
|
202
|
+
transform: scaleX(-1);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.ss-icon.flip-v {
|
|
206
|
+
transform: scaleY(-1);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.ss-icon.spin {
|
|
210
|
+
animation: ss-icon-spin var(--ss-icon-spin-dur, 900ms) linear infinite;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
@keyframes ss-icon-spin {
|
|
214
|
+
from {
|
|
215
|
+
transform: rotate(0deg);
|
|
216
|
+
}
|
|
217
|
+
to {
|
|
218
|
+
transform: rotate(360deg);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
@media (prefers-reduced-motion: reduce) {
|
|
222
|
+
.ss-icon.spin {
|
|
223
|
+
animation: none;
|
|
224
|
+
}
|
|
225
|
+
}</style>
|