dssoca 0.5.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.
Files changed (46) hide show
  1. package/dist/components/Accordion.svelte +281 -0
  2. package/dist/components/Accordion.svelte.d.ts +47 -0
  3. package/dist/components/Badge.svelte +115 -18
  4. package/dist/components/Badge.svelte.d.ts +28 -2
  5. package/dist/components/BottomNav.svelte +216 -0
  6. package/dist/components/BottomNav.svelte.d.ts +30 -0
  7. package/dist/components/Button.svelte +147 -10
  8. package/dist/components/Button.svelte.d.ts +21 -4
  9. package/dist/components/Card.svelte +167 -8
  10. package/dist/components/Card.svelte.d.ts +16 -1
  11. package/dist/components/EmptyState.svelte +85 -9
  12. package/dist/components/EmptyState.svelte.d.ts +14 -3
  13. package/dist/components/Icon.svelte +179 -13
  14. package/dist/components/Icon.svelte.d.ts +63 -2
  15. package/dist/components/Image.svelte +430 -0
  16. package/dist/components/Image.svelte.d.ts +49 -0
  17. package/dist/components/Input.svelte +174 -39
  18. package/dist/components/Input.svelte.d.ts +22 -0
  19. package/dist/components/Link.svelte +148 -0
  20. package/dist/components/Link.svelte.d.ts +22 -0
  21. package/dist/components/LogStream.svelte +378 -37
  22. package/dist/components/LogStream.svelte.d.ts +35 -7
  23. package/dist/components/Menu.svelte +355 -0
  24. package/dist/components/Menu.svelte.d.ts +46 -0
  25. package/dist/components/MetricTile.svelte +124 -12
  26. package/dist/components/MetricTile.svelte.d.ts +20 -0
  27. package/dist/components/SegmentedControl.svelte +208 -0
  28. package/dist/components/SegmentedControl.svelte.d.ts +30 -0
  29. package/dist/components/ServiceCard.svelte +222 -26
  30. package/dist/components/ServiceCard.svelte.d.ts +13 -1
  31. package/dist/components/Sidebar.svelte +340 -29
  32. package/dist/components/Sidebar.svelte.d.ts +18 -7
  33. package/dist/components/Sparkline.svelte +196 -13
  34. package/dist/components/Sparkline.svelte.d.ts +20 -1
  35. package/dist/components/Toaster.svelte +193 -12
  36. package/dist/components/Toaster.svelte.d.ts +3 -0
  37. package/dist/components/Topbar.svelte +152 -21
  38. package/dist/components/Topbar.svelte.d.ts +20 -0
  39. package/dist/dssoca.config.d.ts +1 -1
  40. package/dist/dssoca.config.js +6 -0
  41. package/dist/index.d.ts +10 -3
  42. package/dist/index.js +12 -2
  43. package/dist/theme.css +242 -0
  44. package/dist/toast.svelte.d.ts +49 -5
  45. package/dist/toast.svelte.js +165 -9
  46. package/package.json +1 -1
@@ -1,4 +1,6 @@
1
1
  <script lang="ts">
2
+ import type { Snippet } from 'svelte'
3
+ import type { HTMLInputAttributes, FullAutoFill } from 'svelte/elements'
2
4
  import { resolveComponentSize, type Size } from '../config.js'
3
5
 
4
6
  interface Props {
@@ -17,6 +19,26 @@
17
19
  invalid?: boolean
18
20
  /** id(s) of element(s) describing the field (aria-describedby) — e.g. hint/error text. */
19
21
  describedby?: string
22
+ /** Supplementary helper text rendered under the input. */
23
+ hint?: string
24
+ /** Error text rendered under the input; its presence implies aria-invalid and is announced to AT. */
25
+ error?: string
26
+ /** Decorative leading content rendered inside the field, before the input. */
27
+ prefix?: Snippet
28
+ /** Decorative trailing content rendered inside the field, after the input. */
29
+ suffix?: Snippet
30
+ /** Renders a button to clear the value; hidden when empty/readonly/disabled. */
31
+ clearable?: boolean
32
+ /** Native readonly — value visible but not editable; rendered muted. */
33
+ readonly?: boolean
34
+ /** Native autocomplete hint. */
35
+ autocomplete?: FullAutoFill
36
+ /** Native inputmode hint for on-screen keyboards. */
37
+ inputmode?: HTMLInputAttributes['inputmode']
38
+ /** Native maxlength. */
39
+ maxlength?: number
40
+ /** Any remaining native input attributes / event handlers are forwarded. */
41
+ [key: string]: unknown
20
42
  }
21
43
  let {
22
44
  label,
@@ -31,17 +53,55 @@
31
53
  size,
32
54
  invalid,
33
55
  describedby,
56
+ hint,
57
+ error,
58
+ prefix,
59
+ suffix,
60
+ clearable = false,
61
+ readonly = false,
62
+ autocomplete,
63
+ inputmode,
64
+ maxlength,
65
+ ...rest
34
66
  }: Props = $props()
35
67
 
36
68
  // Guarantee a label↔input association even when no `id` is passed.
37
69
  const uid = $props.id()
38
70
  const inputId = $derived(id ?? uid)
71
+ const hintId = $derived(`${inputId}-hint`)
72
+ const errorId = $derived(`${inputId}-error`)
73
+
74
+ // error wins, then hint, then any caller-supplied describedby — order matters for AT.
75
+ const describedBy = $derived(
76
+ [error ? errorId : null, hint ? hintId : null, describedby]
77
+ .filter(Boolean)
78
+ .join(' ') || undefined,
79
+ )
80
+ const isInvalid = $derived(invalid || Boolean(error) || undefined)
81
+ const resolvedSize = $derived(resolveComponentSize('Input', size))
82
+
83
+ // The .ss-field wrapper carries the border/focus ring; show the clear button only when useful.
84
+ const showClear = $derived(clearable && !!value && !readonly && !disabled)
85
+
86
+ let inputEl = $state<HTMLInputElement>()
87
+ function clear() {
88
+ value = ''
89
+ inputEl?.focus()
90
+ }
39
91
  </script>
40
92
 
41
- {#if label}
42
- <label class="ss-field" for={inputId} data-size-variant={resolveComponentSize('Input', size)}>
43
- <span class="lbl">{label}</span>
93
+ <div class="ss-field" data-size-variant={resolvedSize} class:invalid={isInvalid} class:disabled>
94
+ {#if label}
95
+ <label class="lbl" for={inputId}>
96
+ {label}
97
+ {#if required}<span class="req" aria-hidden="true">*</span>{/if}
98
+ </label>
99
+ {/if}
100
+
101
+ <div class="control">
102
+ {#if prefix}<span class="affix prefix" aria-hidden="true">{@render prefix()}</span>{/if}
44
103
  <input
104
+ bind:this={inputEl}
45
105
  class="ss-input"
46
106
  id={inputId}
47
107
  {name}
@@ -50,57 +110,132 @@
50
110
  {placeholder}
51
111
  {required}
52
112
  {disabled}
53
- aria-invalid={invalid || undefined}
54
- aria-describedby={describedby}
113
+ {readonly}
114
+ {autocomplete}
115
+ {inputmode}
116
+ {maxlength}
117
+ aria-invalid={isInvalid}
118
+ aria-describedby={describedBy}
55
119
  {oninput}
120
+ {...rest}
56
121
  />
57
- </label>
58
- {:else}
59
- <input
60
- class="ss-input"
61
- data-size-variant={resolveComponentSize('Input', size)}
62
- id={inputId}
63
- {name}
64
- {type}
65
- bind:value
66
- {placeholder}
67
- {required}
68
- {disabled}
69
- aria-invalid={invalid || undefined}
70
- aria-describedby={describedby}
71
- {oninput}
72
- />
73
- {/if}
122
+ {#if showClear}
123
+ <button type="button" class="clear" aria-label="Clear" onclick={clear}>×</button>
124
+ {/if}
125
+ {#if suffix}<span class="affix suffix" aria-hidden="true">{@render suffix()}</span>{/if}
126
+ </div>
127
+
128
+ {#if error}<span class="msg error" id={errorId} role="alert">{error}</span>{/if}
129
+ {#if hint}<span class="msg hint" id={hintId}>{hint}</span>{/if}
130
+ </div>
131
+
132
+ <style>.ss-field {
133
+ display: flex;
134
+ flex-direction: column;
135
+ gap: 6px;
136
+ }
137
+ .ss-field .lbl {
138
+ font-family: var(--ss-font-mono);
139
+ font-size: var(--ss-ui-xs);
140
+ color: var(--ss-fg-muted);
141
+ text-transform: uppercase;
142
+ letter-spacing: 0.08em;
143
+ }
144
+ .ss-field .lbl .req {
145
+ color: var(--ss-red);
146
+ margin-left: 2px;
147
+ }
148
+ .ss-field .control {
149
+ display: flex;
150
+ align-items: center;
151
+ gap: var(--ss-gap-sm);
152
+ background: transparent;
153
+ color: var(--ss-fg);
154
+ border: 1px solid var(--ss-line);
155
+ padding: 0 var(--ss-input-px);
156
+ transition: border-color var(--ss-dur-fast) var(--ss-ease), box-shadow var(--ss-dur-fast) var(--ss-ease);
157
+ }
158
+ .ss-field .control:focus-within {
159
+ border-color: var(--ss-primary);
160
+ box-shadow: 0 0 0 3px var(--ss-primary-soft);
161
+ }
162
+ .ss-field.invalid .control {
163
+ border-color: var(--ss-red);
164
+ }
165
+ .ss-field.invalid .control:focus-within {
166
+ border-color: var(--ss-red);
167
+ box-shadow: 0 0 0 3px rgba(var(--ss-red-rgb), 0.22);
168
+ }
169
+ .ss-field.disabled .control {
170
+ border-color: var(--ss-line);
171
+ }
172
+ .ss-field .affix {
173
+ display: inline-flex;
174
+ align-items: center;
175
+ flex: none;
176
+ color: var(--ss-fg-faint);
177
+ font-size: var(--ss-input-font);
178
+ }
179
+ .ss-field .clear {
180
+ display: inline-flex;
181
+ align-items: center;
182
+ justify-content: center;
183
+ flex: none;
184
+ font-family: var(--ss-font-body);
185
+ font-size: var(--ss-input-font);
186
+ line-height: 1;
187
+ background: transparent;
188
+ border: none;
189
+ color: var(--ss-fg-faint);
190
+ padding: 0;
191
+ margin: 0;
192
+ cursor: pointer;
193
+ transition: color var(--ss-dur-fast) var(--ss-ease);
194
+ }
195
+ .ss-field .clear:hover {
196
+ color: var(--ss-fg);
197
+ }
198
+ .ss-field .clear:focus-visible {
199
+ outline: none;
200
+ color: var(--ss-fg);
201
+ box-shadow: 0 0 0 2px var(--ss-primary-soft);
202
+ }
203
+ .ss-field .msg {
204
+ font-family: var(--ss-font-mono);
205
+ font-size: var(--ss-ui-xs);
206
+ letter-spacing: 0.02em;
207
+ }
208
+ .ss-field .msg.hint {
209
+ color: var(--ss-fg-faint);
210
+ }
211
+ .ss-field .msg.error {
212
+ color: var(--ss-red);
213
+ }
74
214
 
75
- <style>.ss-input {
215
+ .ss-input {
76
216
  font-family: var(--ss-font-body);
77
217
  font-size: var(--ss-input-font);
78
218
  background: transparent;
79
219
  color: var(--ss-fg);
80
- border: 1px solid var(--ss-line);
81
- padding: var(--ss-input-py) var(--ss-input-px);
220
+ border: none;
221
+ padding: var(--ss-input-py) 0;
82
222
  width: 100%;
83
- transition: all 0.2s var(--ss-ease);
223
+ min-width: 0;
224
+ transition: color var(--ss-dur-fast) var(--ss-ease);
84
225
  }
85
226
  .ss-input:focus {
86
227
  outline: none;
87
- border-color: var(--ss-primary);
88
- box-shadow: 0 0 0 3px var(--ss-primary-soft);
89
228
  }
90
229
  .ss-input::placeholder {
91
230
  font-style: italic;
92
231
  color: var(--ss-fg-faint);
93
232
  }
94
-
95
- .ss-field {
96
- display: flex;
97
- flex-direction: column;
98
- gap: 6px;
99
- }
100
- .ss-field .lbl {
101
- font-family: var(--ss-font-mono);
102
- font-size: var(--ss-ui-xs);
233
+ .ss-input[readonly] {
103
234
  color: var(--ss-fg-muted);
104
- text-transform: uppercase;
105
- letter-spacing: 0.08em;
235
+ cursor: default;
236
+ }
237
+ .ss-input:disabled {
238
+ color: var(--ss-fg-faint);
239
+ cursor: not-allowed;
240
+ -webkit-text-fill-color: var(--ss-fg-faint);
106
241
  }</style>
@@ -1,3 +1,5 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLInputAttributes, FullAutoFill } from 'svelte/elements';
1
3
  import { type Size } from '../config.js';
2
4
  interface Props {
3
5
  label?: string;
@@ -17,6 +19,26 @@ interface Props {
17
19
  invalid?: boolean;
18
20
  /** id(s) of element(s) describing the field (aria-describedby) — e.g. hint/error text. */
19
21
  describedby?: string;
22
+ /** Supplementary helper text rendered under the input. */
23
+ hint?: string;
24
+ /** Error text rendered under the input; its presence implies aria-invalid and is announced to AT. */
25
+ error?: string;
26
+ /** Decorative leading content rendered inside the field, before the input. */
27
+ prefix?: Snippet;
28
+ /** Decorative trailing content rendered inside the field, after the input. */
29
+ suffix?: Snippet;
30
+ /** Renders a button to clear the value; hidden when empty/readonly/disabled. */
31
+ clearable?: boolean;
32
+ /** Native readonly — value visible but not editable; rendered muted. */
33
+ readonly?: boolean;
34
+ /** Native autocomplete hint. */
35
+ autocomplete?: FullAutoFill;
36
+ /** Native inputmode hint for on-screen keyboards. */
37
+ inputmode?: HTMLInputAttributes['inputmode'];
38
+ /** Native maxlength. */
39
+ maxlength?: number;
40
+ /** Any remaining native input attributes / event handlers are forwarded. */
41
+ [key: string]: unknown;
20
42
  }
21
43
  declare const Input: import("svelte").Component<Props, {}, "value">;
22
44
  type Input = ReturnType<typeof Input>;
@@ -0,0 +1,148 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte'
3
+ import type { HTMLAnchorAttributes } from 'svelte/elements'
4
+ import { resolveComponentSize, type Size } from '../config.js'
5
+ import Icon from './Icon.svelte'
6
+
7
+ interface Props extends HTMLAnchorAttributes {
8
+ /** Visual treatment: `inline` (animated underline) or `button` (solid primary). */
9
+ variant?: 'inline' | 'button'
10
+ /**
11
+ * Open in a new tab with safe `rel`. Auto-detected for absolute http(s)
12
+ * URLs when left undefined; pass `false` to force same-tab even off-site.
13
+ */
14
+ external?: boolean
15
+ /** Token size (sm|md|lg); inherits the global size when unset. */
16
+ size?: Size
17
+ /** Destination URL. */
18
+ href?: string
19
+ children?: Snippet
20
+ /** Bound reference to the underlying <a>. */
21
+ el?: HTMLAnchorElement
22
+ }
23
+
24
+ let {
25
+ variant = 'inline',
26
+ external,
27
+ size,
28
+ href,
29
+ children,
30
+ el = $bindable(),
31
+ target,
32
+ rel,
33
+ ...rest
34
+ }: Props = $props()
35
+
36
+ // Off-site detection: absolute http(s) URL, or a protocol-relative one.
37
+ // 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)
42
+
43
+ // External links open in a new tab and carry the security rel; callers can
44
+ // still override target/rel explicitly via the forwarded attributes.
45
+ const resolvedTarget = $derived(target ?? (isExternal ? '_blank' : undefined))
46
+ const resolvedRel = $derived(rel ?? (isExternal ? 'noopener noreferrer' : undefined))
47
+ </script>
48
+
49
+ <a
50
+ bind:this={el}
51
+ {href}
52
+ class="ss-link {variant}"
53
+ class:external={isExternal}
54
+ data-size-variant={resolveComponentSize('Link', size)}
55
+ target={resolvedTarget}
56
+ rel={resolvedRel}
57
+ {...rest}
58
+ >
59
+ {#if children}<span class="label">{@render children()}</span>{/if}
60
+ {#if isExternal}
61
+ <Icon name="external" {size} class="ss-link-ext" />
62
+ <span class="sr-only"> (opens in a new tab)</span>
63
+ {/if}
64
+ </a>
65
+
66
+ <style>@charset "UTF-8";
67
+ .ss-link {
68
+ font-family: var(--ss-font-body);
69
+ font-weight: 600;
70
+ color: var(--ss-primary);
71
+ text-decoration: none;
72
+ position: relative;
73
+ display: inline-flex;
74
+ align-items: center;
75
+ gap: var(--ss-gap-sm);
76
+ cursor: pointer;
77
+ transition: color var(--ss-dur-fast) var(--ss-ease);
78
+ }
79
+ .ss-link:focus-visible {
80
+ outline: 2px solid var(--ss-primary);
81
+ outline-offset: 2px;
82
+ }
83
+
84
+ /* ── inline: animated underline that reveals on hover/focus, with a glow ── */
85
+ .ss-link.inline .label {
86
+ position: relative;
87
+ }
88
+ .ss-link.inline .label::after {
89
+ content: "";
90
+ position: absolute;
91
+ left: 0;
92
+ right: 0;
93
+ bottom: -1px;
94
+ height: 1px;
95
+ background: var(--ss-primary);
96
+ transform: scaleX(0);
97
+ transform-origin: left center;
98
+ transition: transform var(--ss-dur-slow) var(--ss-ease), height var(--ss-dur-fast) var(--ss-ease), box-shadow var(--ss-dur-slow) var(--ss-ease);
99
+ }
100
+ .ss-link.inline:hover .label::after, .ss-link.inline:focus-visible .label::after {
101
+ transform: scaleX(1);
102
+ height: 2px;
103
+ box-shadow: var(--ss-shadow-glow);
104
+ }
105
+ .ss-link.inline:visited {
106
+ color: var(--ss-fg-muted);
107
+ }
108
+ .ss-link.inline:visited .label::after {
109
+ background: var(--ss-fg-muted);
110
+ }
111
+
112
+ /* ── button: a link that looks like a solid primary button (no underline) ── */
113
+ .ss-link.button {
114
+ font-weight: 600;
115
+ color: var(--ss-fg-on-primary);
116
+ background: var(--ss-primary);
117
+ border: 1px solid var(--ss-primary);
118
+ padding: var(--ss-control-py) var(--ss-control-px);
119
+ line-height: 1;
120
+ transition: background var(--ss-dur-fast) var(--ss-ease), border-color var(--ss-dur-fast) var(--ss-ease), box-shadow var(--ss-dur-fast) var(--ss-ease);
121
+ }
122
+ .ss-link.button:hover {
123
+ background: var(--ss-primary-hover);
124
+ border-color: var(--ss-primary-hover);
125
+ box-shadow: var(--ss-shadow-glow);
126
+ }
127
+ .ss-link.button .label::after {
128
+ display: none;
129
+ }
130
+ .ss-link.button:visited {
131
+ color: var(--ss-fg-on-primary);
132
+ }
133
+
134
+ :global(.ss-link .ss-link-ext) {
135
+ color: currentColor;
136
+ }
137
+
138
+ .sr-only {
139
+ position: absolute;
140
+ width: 1px;
141
+ height: 1px;
142
+ padding: 0;
143
+ margin: -1px;
144
+ overflow: hidden;
145
+ clip: rect(0, 0, 0, 0);
146
+ white-space: nowrap;
147
+ border: 0;
148
+ }</style>
@@ -0,0 +1,22 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAnchorAttributes } from 'svelte/elements';
3
+ import { type Size } from '../config.js';
4
+ interface Props extends HTMLAnchorAttributes {
5
+ /** Visual treatment: `inline` (animated underline) or `button` (solid primary). */
6
+ variant?: 'inline' | 'button';
7
+ /**
8
+ * Open in a new tab with safe `rel`. Auto-detected for absolute http(s)
9
+ * URLs when left undefined; pass `false` to force same-tab even off-site.
10
+ */
11
+ external?: boolean;
12
+ /** Token size (sm|md|lg); inherits the global size when unset. */
13
+ size?: Size;
14
+ /** Destination URL. */
15
+ href?: string;
16
+ children?: Snippet;
17
+ /** Bound reference to the underlying <a>. */
18
+ el?: HTMLAnchorElement;
19
+ }
20
+ declare const Link: import("svelte").Component<Props, {}, "el">;
21
+ type Link = ReturnType<typeof Link>;
22
+ export default Link;