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.
Files changed (51) hide show
  1. package/README.md +54 -18
  2. package/dist/components/Accordion.svelte +281 -0
  3. package/dist/components/Accordion.svelte.d.ts +47 -0
  4. package/dist/components/Badge.svelte +144 -7
  5. package/dist/components/Badge.svelte.d.ts +31 -2
  6. package/dist/components/BottomNav.svelte +216 -0
  7. package/dist/components/BottomNav.svelte.d.ts +30 -0
  8. package/dist/components/Button.svelte +187 -6
  9. package/dist/components/Button.svelte.d.ts +24 -4
  10. package/dist/components/Card.svelte +203 -8
  11. package/dist/components/Card.svelte.d.ts +21 -1
  12. package/dist/components/EmptyState.svelte +123 -36
  13. package/dist/components/EmptyState.svelte.d.ts +17 -1
  14. package/dist/components/Icon.svelte +191 -12
  15. package/dist/components/Icon.svelte.d.ts +69 -2
  16. package/dist/components/Image.svelte +430 -0
  17. package/dist/components/Image.svelte.d.ts +49 -0
  18. package/dist/components/Input.svelte +206 -18
  19. package/dist/components/Input.svelte.d.ts +29 -0
  20. package/dist/components/Link.svelte +148 -0
  21. package/dist/components/Link.svelte.d.ts +22 -0
  22. package/dist/components/LogStream.svelte +403 -21
  23. package/dist/components/LogStream.svelte.d.ts +37 -6
  24. package/dist/components/Menu.svelte +355 -0
  25. package/dist/components/Menu.svelte.d.ts +46 -0
  26. package/dist/components/MetricTile.svelte +161 -7
  27. package/dist/components/MetricTile.svelte.d.ts +23 -0
  28. package/dist/components/SegmentedControl.svelte +208 -0
  29. package/dist/components/SegmentedControl.svelte.d.ts +30 -0
  30. package/dist/components/ServiceCard.svelte +270 -9
  31. package/dist/components/ServiceCard.svelte.d.ts +16 -1
  32. package/dist/components/Sidebar.svelte +391 -25
  33. package/dist/components/Sidebar.svelte.d.ts +20 -6
  34. package/dist/components/Sparkline.svelte +213 -6
  35. package/dist/components/Sparkline.svelte.d.ts +24 -0
  36. package/dist/components/Toaster.svelte +273 -60
  37. package/dist/components/Toaster.svelte.d.ts +9 -16
  38. package/dist/components/Topbar.svelte +273 -17
  39. package/dist/components/Topbar.svelte.d.ts +23 -0
  40. package/dist/config.d.ts +32 -14
  41. package/dist/config.js +43 -17
  42. package/dist/dssoca.config.d.ts +50 -0
  43. package/dist/dssoca.config.js +45 -0
  44. package/dist/index.d.ts +12 -5
  45. package/dist/index.js +14 -4
  46. package/dist/theme.css +587 -382
  47. package/dist/toast.svelte.d.ts +49 -5
  48. package/dist/toast.svelte.js +165 -9
  49. package/package.json +17 -3
  50. package/dist/components/PassocaMark.svelte +0 -15
  51. package/dist/components/PassocaMark.svelte.d.ts +0 -7
@@ -0,0 +1,216 @@
1
+ <script module lang="ts">
2
+ import type { IconName } from './Icon.svelte'
3
+
4
+ /** One tab in the bottom navigation bar. */
5
+ export interface BottomNavItem {
6
+ /** Stable id — matched against `active` and passed to `onSelect`. */
7
+ id: string
8
+ /** Visible label rendered under the icon. */
9
+ label: string
10
+ /** Leading glyph (shared `Icon` component). */
11
+ icon: IconName
12
+ /** Optional URL — when set the tab renders as a real `<a href>`. */
13
+ href?: string
14
+ /** Optional count/label rendered as a small square badge on the icon. */
15
+ badge?: string | number
16
+ }
17
+ </script>
18
+
19
+ <script lang="ts">
20
+ import Icon from './Icon.svelte'
21
+ import { resolveComponentSize, type Size } from '../config.js'
22
+
23
+ interface Props {
24
+ /** Tabs to render, left → right, in equal-width columns. */
25
+ items?: BottomNavItem[]
26
+ /** Id of the active tab; highlighted + `aria-current="page"`. */
27
+ active?: string
28
+ /** Fired with the tab id on activation (also fires for `href` tabs as an SPA fallback). */
29
+ onSelect?: (id: string) => void
30
+ /** Accessible name for the wrapping `<nav>` landmark. */
31
+ ariaLabel?: string
32
+ /** Token size (sm|md|lg); inherits the global size when unset. */
33
+ size?: Size
34
+ }
35
+
36
+ const DEFAULT_ITEMS: BottomNavItem[] = [
37
+ { id: 'home', label: 'Home', icon: 'grid' },
38
+ { id: 'services', label: 'Services', icon: 'database' },
39
+ { id: 'activity', label: 'Activity', icon: 'activity' },
40
+ { id: 'account', label: 'Account', icon: 'user' },
41
+ ]
42
+
43
+ let {
44
+ items = DEFAULT_ITEMS,
45
+ active,
46
+ onSelect,
47
+ ariaLabel = 'Primary',
48
+ size,
49
+ }: Props = $props()
50
+
51
+ const isActive = (item: BottomNavItem): boolean => item.id === active
52
+
53
+ const hasBadge = (item: BottomNavItem): boolean =>
54
+ item.badge != null && item.badge !== ''
55
+
56
+ /** Fold the count badge into the accessible name so it isn't lost to AT. */
57
+ function accessibleName(item: BottomNavItem): string {
58
+ return hasBadge(item) ? `${item.label}, ${item.badge}` : item.label
59
+ }
60
+
61
+ function activate(item: BottomNavItem, e: MouseEvent) {
62
+ // Real links navigate natively; intercept only the SPA (no-href) path so a
63
+ // plain <button> never submits/scrolls. onSelect fires either way.
64
+ if (!item.href) e.preventDefault()
65
+ onSelect?.(item.id)
66
+ }
67
+
68
+ const sizeAttr = $derived(resolveComponentSize('BottomNav', size))
69
+ </script>
70
+
71
+ <nav class="ss-bottom-nav" aria-label={ariaLabel} data-size-variant={sizeAttr}>
72
+ <ul class="list">
73
+ {#each items as item (item.id)}
74
+ {@const current = isActive(item)}
75
+ <li class="row">
76
+ {#if item.href}
77
+ <a
78
+ class="tab {current ? 'active' : ''}"
79
+ href={item.href}
80
+ aria-current={current ? 'page' : undefined}
81
+ aria-label={hasBadge(item) ? accessibleName(item) : undefined}
82
+ onclick={(e) => activate(item, e)}
83
+ >
84
+ <span class="glyph">
85
+ <Icon name={item.icon} px={20} />
86
+ {#if hasBadge(item)}
87
+ <span class="badge" aria-hidden="true">{item.badge}</span>
88
+ {/if}
89
+ </span>
90
+ <span class="label">{item.label}</span>
91
+ </a>
92
+ {:else}
93
+ <button
94
+ type="button"
95
+ class="tab {current ? 'active' : ''}"
96
+ aria-current={current ? 'page' : undefined}
97
+ aria-label={hasBadge(item) ? accessibleName(item) : undefined}
98
+ onclick={(e) => activate(item, e)}
99
+ >
100
+ <span class="glyph">
101
+ <Icon name={item.icon} px={20} />
102
+ {#if hasBadge(item)}
103
+ <span class="badge" aria-hidden="true">{item.badge}</span>
104
+ {/if}
105
+ </span>
106
+ <span class="label">{item.label}</span>
107
+ </button>
108
+ {/if}
109
+ </li>
110
+ {/each}
111
+ </ul>
112
+ </nav>
113
+
114
+ <style>.ss-bottom-nav {
115
+ --_bar-h: var(--ss-bottom-nav-h, var(--ss-shell-top-h, 48px));
116
+ --_pad-x: var(--ss-bottom-nav-px, var(--ss-s-2, 8px));
117
+ --_tab-py: var(--ss-bottom-nav-tab-py, var(--ss-s-1, 4px));
118
+ --_gap: var(--ss-bottom-nav-gap, 4px);
119
+ --_label-fs: var(--ss-bottom-nav-label-fs, var(--ss-ui-xs, 11px));
120
+ position: fixed;
121
+ left: 0;
122
+ right: 0;
123
+ bottom: 0;
124
+ z-index: 30;
125
+ box-sizing: border-box;
126
+ padding-bottom: env(safe-area-inset-bottom, 0px);
127
+ background: color-mix(in srgb, var(--ss-bg) 88%, transparent);
128
+ backdrop-filter: blur(14px);
129
+ -webkit-backdrop-filter: blur(14px);
130
+ border-top: 1px solid var(--ss-line);
131
+ font-family: var(--ss-font-mono);
132
+ }
133
+ .ss-bottom-nav .list {
134
+ list-style: none;
135
+ margin: 0;
136
+ padding: 0;
137
+ display: grid;
138
+ grid-auto-flow: column;
139
+ grid-auto-columns: 1fr;
140
+ align-items: stretch;
141
+ }
142
+ .ss-bottom-nav .row {
143
+ display: flex;
144
+ }
145
+ .ss-bottom-nav .tab {
146
+ flex: 1 1 auto;
147
+ display: flex;
148
+ flex-direction: column;
149
+ align-items: center;
150
+ justify-content: center;
151
+ gap: var(--_gap);
152
+ width: 100%;
153
+ min-height: max(var(--_bar-h), 44px);
154
+ padding: var(--_tab-py) var(--_pad-x);
155
+ box-sizing: border-box;
156
+ cursor: pointer;
157
+ text-decoration: none;
158
+ color: var(--ss-fg-faint);
159
+ background: none;
160
+ border: 0;
161
+ border-top: 2px solid transparent;
162
+ font: inherit;
163
+ transition: color var(--ss-dur-fast) var(--ss-ease), background var(--ss-dur-fast) var(--ss-ease);
164
+ }
165
+ .ss-bottom-nav .tab:hover {
166
+ color: var(--ss-fg);
167
+ }
168
+ .ss-bottom-nav .tab:focus-visible {
169
+ outline: 2px solid var(--ss-primary);
170
+ outline-offset: -2px;
171
+ }
172
+ .ss-bottom-nav .tab.active {
173
+ color: var(--ss-primary);
174
+ background: rgba(var(--ss-primary-rgb), 0.06);
175
+ border-top-color: var(--ss-primary);
176
+ }
177
+ .ss-bottom-nav .glyph {
178
+ position: relative;
179
+ display: inline-flex;
180
+ align-items: center;
181
+ justify-content: center;
182
+ line-height: 0;
183
+ }
184
+ .ss-bottom-nav .badge {
185
+ position: absolute;
186
+ top: -6px;
187
+ left: calc(50% + 6px);
188
+ min-width: 14px;
189
+ height: 14px;
190
+ padding: 0 3px;
191
+ box-sizing: border-box;
192
+ display: inline-flex;
193
+ align-items: center;
194
+ justify-content: center;
195
+ font-family: var(--ss-font-mono);
196
+ font-size: 9px;
197
+ line-height: 1;
198
+ font-variant-numeric: tabular-nums;
199
+ color: var(--ss-fg-on-primary, #001b04);
200
+ background: var(--ss-primary);
201
+ border-radius: 0;
202
+ }
203
+ .ss-bottom-nav .label {
204
+ font-size: var(--_label-fs);
205
+ line-height: 1;
206
+ letter-spacing: 0.02em;
207
+ max-width: 100%;
208
+ overflow: hidden;
209
+ text-overflow: ellipsis;
210
+ white-space: nowrap;
211
+ }
212
+ @media (prefers-reduced-motion: reduce) {
213
+ .ss-bottom-nav .tab {
214
+ transition: none;
215
+ }
216
+ }</style>
@@ -0,0 +1,30 @@
1
+ import type { IconName } from './Icon.svelte';
2
+ /** One tab in the bottom navigation bar. */
3
+ export interface BottomNavItem {
4
+ /** Stable id — matched against `active` and passed to `onSelect`. */
5
+ id: string;
6
+ /** Visible label rendered under the icon. */
7
+ label: string;
8
+ /** Leading glyph (shared `Icon` component). */
9
+ icon: IconName;
10
+ /** Optional URL — when set the tab renders as a real `<a href>`. */
11
+ href?: string;
12
+ /** Optional count/label rendered as a small square badge on the icon. */
13
+ badge?: string | number;
14
+ }
15
+ import { type Size } from '../config.js';
16
+ interface Props {
17
+ /** Tabs to render, left → right, in equal-width columns. */
18
+ items?: BottomNavItem[];
19
+ /** Id of the active tab; highlighted + `aria-current="page"`. */
20
+ active?: string;
21
+ /** Fired with the tab id on activation (also fires for `href` tabs as an SPA fallback). */
22
+ onSelect?: (id: string) => void;
23
+ /** Accessible name for the wrapping `<nav>` landmark. */
24
+ ariaLabel?: string;
25
+ /** Token size (sm|md|lg); inherits the global size when unset. */
26
+ size?: Size;
27
+ }
28
+ declare const BottomNav: import("svelte").Component<Props, {}, "">;
29
+ type BottomNav = ReturnType<typeof BottomNav>;
30
+ export default BottomNav;
@@ -1,16 +1,197 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte'
3
+ import type { HTMLButtonAttributes } from 'svelte/elements'
4
+ import { resolveComponentSize, type Size } from '../config.js'
3
5
 
4
- interface Props {
5
- variant?: 'primary' | 'secondary' | 'ghost'
6
+ interface Props extends HTMLButtonAttributes {
7
+ variant?: 'primary' | 'secondary' | 'ghost' | 'danger'
6
8
  type?: 'button' | 'submit' | 'reset'
7
9
  disabled?: boolean
10
+ /** Loading state: shows a spinner, blocks clicks, sets aria-busy; stays focusable. */
11
+ loading?: boolean
12
+ /** Accessible name while loading (keeps the name stable when the label is hidden). */
13
+ loadingLabel?: string
8
14
  onclick?: (e: MouseEvent) => void
9
- children: Snippet
15
+ /** Token size (sm|md|lg); inherits the global size when unset. */
16
+ size?: Size
17
+ /** Icon-only square button — `label` is required and becomes the aria-label. */
18
+ iconOnly?: boolean
19
+ /** Accessible name; required for icon-only buttons (→ aria-label). */
20
+ label?: string
21
+ /** Block-level: stretch to fill the inline axis and center the content. */
22
+ fullWidth?: boolean
23
+ /** Leading icon snippet, rendered before children. */
24
+ leading?: Snippet
25
+ /** Trailing icon snippet, rendered after children. */
26
+ trailing?: Snippet
27
+ children?: Snippet
28
+ /** Bound reference to the underlying <button>. */
29
+ el?: HTMLButtonElement
30
+ }
31
+ let {
32
+ variant = 'secondary',
33
+ type = 'button',
34
+ disabled = false,
35
+ loading = false,
36
+ loadingLabel,
37
+ onclick,
38
+ size,
39
+ iconOnly = false,
40
+ label,
41
+ fullWidth = false,
42
+ leading,
43
+ trailing,
44
+ children,
45
+ el = $bindable(),
46
+ ...rest
47
+ }: Props = $props()
48
+
49
+ // Soft-disable: keep the control focusable/announceable via aria-disabled while
50
+ // loading, but still emit native `disabled` so forms don't submit it.
51
+ let busy = $derived(loading)
52
+ let ariaLabel = $derived(iconOnly ? label : rest['aria-label'])
53
+ let accessibleName = $derived(loading ? (loadingLabel ?? ariaLabel) : ariaLabel)
54
+
55
+ function handleClick(e: MouseEvent) {
56
+ if (loading || disabled) {
57
+ e.preventDefault()
58
+ e.stopImmediatePropagation()
59
+ return
60
+ }
61
+ onclick?.(e)
10
62
  }
11
- let { variant = 'secondary', type = 'button', disabled = false, onclick, children }: Props = $props()
12
63
  </script>
13
64
 
14
- <button class="ss-btn {variant}" {type} {disabled} {onclick}>
15
- {@render children()}
65
+ <button
66
+ bind:this={el}
67
+ class="ss-btn {variant}"
68
+ class:icon-only={iconOnly}
69
+ class:full-width={fullWidth}
70
+ class:loading
71
+ {type}
72
+ {disabled}
73
+ aria-busy={busy ? 'true' : undefined}
74
+ aria-disabled={loading ? 'true' : undefined}
75
+ aria-label={accessibleName}
76
+ data-size-variant={resolveComponentSize('Button', size)}
77
+ {...rest}
78
+ onclick={handleClick}
79
+ >
80
+ {#if loading}
81
+ <span class="spinner" aria-hidden="true"></span>
82
+ {/if}
83
+ {#if leading}<span class="affix" aria-hidden="true">{@render leading()}</span>{/if}
84
+ {#if children}<span class="label">{@render children()}</span>{/if}
85
+ {#if trailing}<span class="affix" aria-hidden="true">{@render trailing()}</span>{/if}
16
86
  </button>
87
+
88
+ <style>.ss-btn {
89
+ font-family: var(--ss-font-body);
90
+ font-size: var(--ss-control-font);
91
+ line-height: 1;
92
+ font-weight: 500;
93
+ padding: var(--ss-control-py) var(--ss-control-px);
94
+ border: 1px solid var(--ss-line);
95
+ background: transparent;
96
+ color: var(--ss-fg);
97
+ cursor: pointer;
98
+ display: inline-flex;
99
+ align-items: center;
100
+ gap: var(--ss-gap-sm);
101
+ transition: all var(--ss-dur-fast) var(--ss-ease);
102
+ }
103
+ .ss-btn:not(:disabled):hover {
104
+ background: var(--ss-hover);
105
+ border-color: var(--ss-line-strong);
106
+ }
107
+ .ss-btn.primary {
108
+ background: var(--ss-primary);
109
+ color: var(--ss-fg-on-primary);
110
+ border-color: var(--ss-primary);
111
+ font-weight: 600;
112
+ }
113
+ .ss-btn.primary:not(:disabled):hover {
114
+ background: var(--ss-primary-hover);
115
+ border-color: var(--ss-primary-hover);
116
+ box-shadow: var(--ss-shadow-glow);
117
+ }
118
+ .ss-btn.danger {
119
+ background: var(--ss-danger);
120
+ color: var(--ss-fg-on-danger);
121
+ border-color: var(--ss-danger);
122
+ font-weight: 600;
123
+ }
124
+ .ss-btn.danger:not(:disabled):hover {
125
+ background: var(--ss-danger-hover);
126
+ border-color: var(--ss-danger-hover);
127
+ }
128
+ .ss-btn.ghost {
129
+ border-color: transparent;
130
+ color: var(--ss-fg-muted);
131
+ padding: var(--ss-control-py) var(--ss-gap-sm);
132
+ }
133
+ .ss-btn.ghost:not(:disabled):hover {
134
+ color: var(--ss-fg);
135
+ background: var(--ss-hover);
136
+ border-color: transparent;
137
+ }
138
+ .ss-btn {
139
+ /* Icon-only: square padding derived from the vertical control token. */
140
+ }
141
+ .ss-btn.icon-only {
142
+ padding: var(--ss-control-py);
143
+ gap: 0;
144
+ }
145
+ .ss-btn {
146
+ /* Block-level: fill the inline axis, center the content. */
147
+ }
148
+ .ss-btn.full-width {
149
+ width: 100%;
150
+ justify-content: center;
151
+ }
152
+ .ss-btn {
153
+ /* Soft-disabled while loading: keep focusable, dim, block the pointer. */
154
+ }
155
+ .ss-btn.loading {
156
+ cursor: progress;
157
+ opacity: 0.8;
158
+ }
159
+ .ss-btn:disabled {
160
+ cursor: not-allowed;
161
+ opacity: 0.5;
162
+ box-shadow: none;
163
+ }
164
+
165
+ .label {
166
+ display: inline-flex;
167
+ align-items: center;
168
+ }
169
+
170
+ .affix {
171
+ display: inline-flex;
172
+ align-items: center;
173
+ justify-content: center;
174
+ line-height: 0;
175
+ }
176
+
177
+ /* em-sized spinner so it tracks the button font; reduced-motion safe. */
178
+ .spinner {
179
+ display: inline-block;
180
+ width: 1em;
181
+ height: 1em;
182
+ border: 2px solid currentColor;
183
+ border-top-color: transparent;
184
+ box-sizing: border-box;
185
+ animation: ss-btn-spin var(--ss-dur-xslow) linear infinite;
186
+ }
187
+
188
+ @keyframes ss-btn-spin {
189
+ to {
190
+ transform: rotate(360deg);
191
+ }
192
+ }
193
+ @media (prefers-reduced-motion: reduce) {
194
+ .spinner {
195
+ animation: none;
196
+ }
197
+ }</style>
@@ -1,11 +1,31 @@
1
1
  import type { Snippet } from 'svelte';
2
- interface Props {
3
- variant?: 'primary' | 'secondary' | 'ghost';
2
+ import type { HTMLButtonAttributes } from 'svelte/elements';
3
+ import { type Size } from '../config.js';
4
+ interface Props extends HTMLButtonAttributes {
5
+ variant?: 'primary' | 'secondary' | 'ghost' | 'danger';
4
6
  type?: 'button' | 'submit' | 'reset';
5
7
  disabled?: boolean;
8
+ /** Loading state: shows a spinner, blocks clicks, sets aria-busy; stays focusable. */
9
+ loading?: boolean;
10
+ /** Accessible name while loading (keeps the name stable when the label is hidden). */
11
+ loadingLabel?: string;
6
12
  onclick?: (e: MouseEvent) => void;
7
- children: Snippet;
13
+ /** Token size (sm|md|lg); inherits the global size when unset. */
14
+ size?: Size;
15
+ /** Icon-only square button — `label` is required and becomes the aria-label. */
16
+ iconOnly?: boolean;
17
+ /** Accessible name; required for icon-only buttons (→ aria-label). */
18
+ label?: string;
19
+ /** Block-level: stretch to fill the inline axis and center the content. */
20
+ fullWidth?: boolean;
21
+ /** Leading icon snippet, rendered before children. */
22
+ leading?: Snippet;
23
+ /** Trailing icon snippet, rendered after children. */
24
+ trailing?: Snippet;
25
+ children?: Snippet;
26
+ /** Bound reference to the underlying <button>. */
27
+ el?: HTMLButtonElement;
8
28
  }
9
- declare const Button: import("svelte").Component<Props, {}, "">;
29
+ declare const Button: import("svelte").Component<Props, {}, "el">;
10
30
  type Button = ReturnType<typeof Button>;
11
31
  export default Button;