dssoca 0.8.2 → 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 +22 -6
- package/dist/components/Accordion.svelte.d.ts +5 -1
- package/dist/components/Badge.svelte +3 -5
- package/dist/components/BottomNav.svelte +57 -19
- package/dist/components/BottomNav.svelte.d.ts +2 -0
- package/dist/components/Card.svelte +7 -1
- package/dist/components/Container.svelte +55 -0
- package/dist/components/Container.svelte.d.ts +16 -0
- package/dist/components/EmptyState.svelte +9 -3
- package/dist/components/EmptyState.svelte.d.ts +6 -0
- package/dist/components/Heading.svelte +83 -0
- package/dist/components/Heading.svelte.d.ts +17 -0
- package/dist/components/Icon.svelte +32 -23
- package/dist/components/Icon.svelte.d.ts +7 -0
- package/dist/components/Image.svelte +19 -21
- package/dist/components/Input.svelte +2 -3
- package/dist/components/Link.svelte +42 -7
- package/dist/components/Link.svelte.d.ts +7 -0
- package/dist/components/LogStream.svelte +46 -31
- package/dist/components/Menu.svelte +59 -6
- package/dist/components/Menu.svelte.d.ts +22 -2
- package/dist/components/MetricTile.svelte +4 -4
- package/dist/components/SegmentedControl.svelte +16 -4
- package/dist/components/SegmentedControl.svelte.d.ts +7 -0
- package/dist/components/ServiceCard.svelte +15 -15
- package/dist/components/Sidebar.svelte +47 -21
- package/dist/components/Sparkline.svelte +15 -13
- 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 +20 -4
- package/dist/components/Topbar.svelte +170 -50
- package/dist/components/Topbar.svelte.d.ts +30 -3
- package/dist/dssoca.config.d.ts +1 -1
- package/dist/dssoca.config.js +4 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +7 -1
- package/dist/theme.css +177 -37
- package/dist/toast.svelte.js +3 -3
- package/dist/tokens.css +597 -0
- package/package.json +25 -4
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { resolveComponentSize, type Size } from '../config.js'
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
label?: string
|
|
6
|
+
id?: string
|
|
7
|
+
name?: string
|
|
8
|
+
value?: string
|
|
9
|
+
placeholder?: string
|
|
10
|
+
required?: boolean
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
oninput?: (e: Event & { currentTarget: HTMLTextAreaElement }) => 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
|
+
let {
|
|
37
|
+
label,
|
|
38
|
+
id,
|
|
39
|
+
name,
|
|
40
|
+
value = $bindable(''),
|
|
41
|
+
placeholder = '',
|
|
42
|
+
required = false,
|
|
43
|
+
disabled = false,
|
|
44
|
+
oninput,
|
|
45
|
+
size,
|
|
46
|
+
invalid,
|
|
47
|
+
describedby,
|
|
48
|
+
hint,
|
|
49
|
+
error,
|
|
50
|
+
readonly = false,
|
|
51
|
+
maxlength,
|
|
52
|
+
rows = 3,
|
|
53
|
+
autosize = false,
|
|
54
|
+
maxRows = 10,
|
|
55
|
+
...rest
|
|
56
|
+
}: Props = $props()
|
|
57
|
+
|
|
58
|
+
// Guarantee a label↔textarea association even when no `id` is passed.
|
|
59
|
+
const uid = $props.id()
|
|
60
|
+
const fieldId = $derived(id ?? uid)
|
|
61
|
+
const hintId = $derived(`${fieldId}-hint`)
|
|
62
|
+
const errorId = $derived(`${fieldId}-error`)
|
|
63
|
+
|
|
64
|
+
// error wins, then hint, then any caller-supplied describedby — order matters for AT.
|
|
65
|
+
const describedBy = $derived(
|
|
66
|
+
[error ? errorId : null, hint ? hintId : null, describedby].filter(Boolean).join(' ') ||
|
|
67
|
+
undefined,
|
|
68
|
+
)
|
|
69
|
+
const isInvalid = $derived(invalid || Boolean(error) || undefined)
|
|
70
|
+
// 'Textarea' is not in the ComponentName union yet (manifest is owned by the
|
|
71
|
+
// integration step) — cast until dssoca.config.ts registers it.
|
|
72
|
+
const resolvedSize = $derived(resolveComponentSize('Textarea', size))
|
|
73
|
+
|
|
74
|
+
// Autosize: prefer native `field-sizing: content` (see the scoped CSS); fall
|
|
75
|
+
// back to syncing the height to scrollHeight when the engine lacks it. The
|
|
76
|
+
// CSS max-height (from maxRows) clamps both paths.
|
|
77
|
+
let el = $state<HTMLTextAreaElement>()
|
|
78
|
+
const supportsFieldSizing =
|
|
79
|
+
typeof CSS !== 'undefined' &&
|
|
80
|
+
typeof CSS.supports === 'function' &&
|
|
81
|
+
CSS.supports('field-sizing', 'content')
|
|
82
|
+
|
|
83
|
+
$effect(() => {
|
|
84
|
+
void value // re-run on every value change (including programmatic ones)
|
|
85
|
+
if (!autosize || supportsFieldSizing || !el) return
|
|
86
|
+
el.style.height = 'auto'
|
|
87
|
+
el.style.height = `${el.scrollHeight}px`
|
|
88
|
+
})
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<div class="ss-textarea" data-size-variant={resolvedSize} class:invalid={isInvalid} class:disabled>
|
|
92
|
+
{#if label}
|
|
93
|
+
<label class="lbl" for={fieldId}>
|
|
94
|
+
{label}
|
|
95
|
+
{#if required}<span class="req" aria-hidden="true">*</span>{/if}
|
|
96
|
+
</label>
|
|
97
|
+
{/if}
|
|
98
|
+
|
|
99
|
+
<div class="control">
|
|
100
|
+
<textarea
|
|
101
|
+
bind:this={el}
|
|
102
|
+
class="field"
|
|
103
|
+
class:autosize
|
|
104
|
+
id={fieldId}
|
|
105
|
+
{name}
|
|
106
|
+
bind:value
|
|
107
|
+
{placeholder}
|
|
108
|
+
{required}
|
|
109
|
+
{disabled}
|
|
110
|
+
{readonly}
|
|
111
|
+
{maxlength}
|
|
112
|
+
{rows}
|
|
113
|
+
aria-invalid={isInvalid}
|
|
114
|
+
aria-describedby={describedBy}
|
|
115
|
+
style:max-height={autosize && maxRows
|
|
116
|
+
? `calc(${maxRows} * 1lh + 2 * var(--ss-input-py))`
|
|
117
|
+
: undefined}
|
|
118
|
+
{oninput}
|
|
119
|
+
{...rest}
|
|
120
|
+
></textarea>
|
|
121
|
+
</div>
|
|
122
|
+
|
|
123
|
+
{#if error}<span class="msg error" id={errorId} role="alert">{error}</span>{/if}
|
|
124
|
+
{#if hint}<span class="msg hint" id={hintId}>{hint}</span>{/if}
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<style>.ss-textarea {
|
|
128
|
+
display: flex;
|
|
129
|
+
flex-direction: column;
|
|
130
|
+
gap: 6px;
|
|
131
|
+
}
|
|
132
|
+
.ss-textarea .lbl {
|
|
133
|
+
font-family: var(--ss-font-mono);
|
|
134
|
+
font-size: var(--ss-ui-xs);
|
|
135
|
+
color: var(--ss-fg-muted);
|
|
136
|
+
text-transform: uppercase;
|
|
137
|
+
letter-spacing: 0.08em;
|
|
138
|
+
}
|
|
139
|
+
.ss-textarea .lbl .req {
|
|
140
|
+
color: var(--ss-red);
|
|
141
|
+
margin-left: 2px;
|
|
142
|
+
}
|
|
143
|
+
.ss-textarea .control {
|
|
144
|
+
display: flex;
|
|
145
|
+
align-items: stretch;
|
|
146
|
+
background: transparent;
|
|
147
|
+
color: var(--ss-fg);
|
|
148
|
+
border: 1px solid var(--ss-line);
|
|
149
|
+
padding: 0 var(--ss-input-px);
|
|
150
|
+
transition: border-color var(--ss-dur-fast) var(--ss-ease), box-shadow var(--ss-dur-fast) var(--ss-ease);
|
|
151
|
+
}
|
|
152
|
+
.ss-textarea .control:focus-within {
|
|
153
|
+
border-color: var(--ss-primary);
|
|
154
|
+
box-shadow: 0 0 0 3px var(--ss-primary-soft);
|
|
155
|
+
}
|
|
156
|
+
.ss-textarea.invalid .control {
|
|
157
|
+
border-color: var(--ss-red);
|
|
158
|
+
}
|
|
159
|
+
.ss-textarea.invalid .control:focus-within {
|
|
160
|
+
border-color: var(--ss-red);
|
|
161
|
+
box-shadow: 0 0 0 3px rgba(var(--ss-red-rgb), 0.22);
|
|
162
|
+
}
|
|
163
|
+
.ss-textarea.disabled .control {
|
|
164
|
+
border-color: var(--ss-line);
|
|
165
|
+
}
|
|
166
|
+
.ss-textarea .field {
|
|
167
|
+
font-family: var(--ss-font-body);
|
|
168
|
+
font-size: var(--ss-input-font);
|
|
169
|
+
line-height: 1.5;
|
|
170
|
+
background: transparent;
|
|
171
|
+
color: var(--ss-fg);
|
|
172
|
+
border: none;
|
|
173
|
+
padding: var(--ss-input-py) 0;
|
|
174
|
+
width: 100%;
|
|
175
|
+
min-width: 0;
|
|
176
|
+
resize: vertical;
|
|
177
|
+
transition: color var(--ss-dur-fast) var(--ss-ease);
|
|
178
|
+
}
|
|
179
|
+
.ss-textarea .field:focus {
|
|
180
|
+
outline: none;
|
|
181
|
+
}
|
|
182
|
+
.ss-textarea .field::placeholder {
|
|
183
|
+
font-style: italic;
|
|
184
|
+
color: var(--ss-fg-faint);
|
|
185
|
+
}
|
|
186
|
+
.ss-textarea .field[readonly] {
|
|
187
|
+
color: var(--ss-fg-muted);
|
|
188
|
+
cursor: default;
|
|
189
|
+
}
|
|
190
|
+
.ss-textarea .field:disabled {
|
|
191
|
+
color: var(--ss-fg-faint);
|
|
192
|
+
cursor: not-allowed;
|
|
193
|
+
-webkit-text-fill-color: var(--ss-fg-faint);
|
|
194
|
+
}
|
|
195
|
+
.ss-textarea .field.autosize {
|
|
196
|
+
resize: none;
|
|
197
|
+
overflow-y: auto;
|
|
198
|
+
}
|
|
199
|
+
@supports (field-sizing: content) {
|
|
200
|
+
.ss-textarea .field.autosize {
|
|
201
|
+
field-sizing: content;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
.ss-textarea .msg {
|
|
205
|
+
font-family: var(--ss-font-mono);
|
|
206
|
+
font-size: var(--ss-ui-xs);
|
|
207
|
+
letter-spacing: 0.02em;
|
|
208
|
+
}
|
|
209
|
+
.ss-textarea .msg.hint {
|
|
210
|
+
color: var(--ss-fg-faint);
|
|
211
|
+
}
|
|
212
|
+
.ss-textarea .msg.error {
|
|
213
|
+
color: var(--ss-red);
|
|
214
|
+
}</style>
|
|
@@ -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;
|
|
@@ -24,7 +24,24 @@
|
|
|
24
24
|
const glyph: Record<ToastKind, string> = { success: '✓', error: '✕', info: 'i', loading: '' }
|
|
25
25
|
// Honor prefers-reduced-motion: collapse the fly transition to an instant swap.
|
|
26
26
|
const reduce = $derived(prefersReducedMotion.current)
|
|
27
|
-
|
|
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)
|
|
28
45
|
// Bottom anchors slide in from below; centered ones come straight down/up.
|
|
29
46
|
const flyX = $derived(position.endsWith('center') ? 0 : position.endsWith('left') ? -16 : 16)
|
|
30
47
|
const flyY = $derived(position.endsWith('center') ? (position.startsWith('top') ? -16 : 16) : 0)
|
|
@@ -84,6 +101,7 @@
|
|
|
84
101
|
aria-label="Notifications"
|
|
85
102
|
data-position={position}
|
|
86
103
|
data-size-variant={resolveComponentSize('Toaster', size)}
|
|
104
|
+
bind:this={rootEl}
|
|
87
105
|
>
|
|
88
106
|
{#each toasts.items as t (t.id)}
|
|
89
107
|
<div
|
|
@@ -93,9 +111,7 @@
|
|
|
93
111
|
aria-live={t.kind === 'error' ? 'assertive' : 'polite'}
|
|
94
112
|
tabindex="-1"
|
|
95
113
|
style:transform={dragId === t.id ? `translateX(${dragDx}px)` : undefined}
|
|
96
|
-
style:opacity={dragId === t.id
|
|
97
|
-
? Math.max(0.3, 1 - Math.abs(dragDx) / 200)
|
|
98
|
-
: undefined}
|
|
114
|
+
style:opacity={dragId === t.id ? Math.max(0.3, 1 - Math.abs(dragDx) / 200) : undefined}
|
|
99
115
|
transition:fly={{ x: flyX, y: flyY, duration: flyDuration }}
|
|
100
116
|
onpointerenter={() => toasts.pause(t.id)}
|
|
101
117
|
onpointerleave={() => dragId !== t.id && toasts.resume(t.id)}
|
|
@@ -1,15 +1,43 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* One tab in the Topbar strip (DS-0080). The shorthand `string` form is
|
|
4
|
+
* equivalent to `{ id: s, label: s }`.
|
|
5
|
+
*/
|
|
6
|
+
export interface TopbarTab {
|
|
7
|
+
/** Stable id — matched against `active` and passed to `onTab`. */
|
|
8
|
+
id: string
|
|
9
|
+
/** Visible label; defaults to `id` (decouple for localized labels). */
|
|
10
|
+
label?: string
|
|
11
|
+
/** Optional URL — when set the tab renders as a real `<a href>`. */
|
|
12
|
+
href?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Services status summary shown in the right-side dot segment. */
|
|
16
|
+
export interface TopbarServices {
|
|
17
|
+
up: number
|
|
18
|
+
total: number
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
1
22
|
<script lang="ts">
|
|
2
23
|
import type { Snippet } from 'svelte'
|
|
3
24
|
import { resolveComponentSize, type Size } from '../config.js'
|
|
4
25
|
|
|
5
|
-
interface Stat {
|
|
26
|
+
interface Stat {
|
|
27
|
+
key: string
|
|
28
|
+
value: string
|
|
29
|
+
title?: string
|
|
30
|
+
}
|
|
6
31
|
|
|
7
32
|
interface Props {
|
|
8
33
|
active?: string
|
|
9
34
|
user?: string
|
|
10
|
-
|
|
35
|
+
/** Tab strip: plain strings (id = label) or `{ id, label?, href? }` objects. */
|
|
36
|
+
tabs?: Array<string | TopbarTab>
|
|
37
|
+
/** Fired with the tab id when a tab is activated (also for `href` tabs). */
|
|
11
38
|
onTab?: (tab: string) => void
|
|
12
|
-
/** Fired when the command menu is opened (chip click or Cmd/Ctrl+K).
|
|
39
|
+
/** Fired when the command menu is opened (chip click or Cmd/Ctrl+K).
|
|
40
|
+
* The ⌘K chip and the shortcut only exist when this handler is provided. */
|
|
13
41
|
onCommand?: () => void
|
|
14
42
|
/** Fired when the user chip is activated (when no `userMenu` snippet given). */
|
|
15
43
|
onUser?: () => void
|
|
@@ -17,12 +45,19 @@
|
|
|
17
45
|
userMenu?: Snippet
|
|
18
46
|
/** Custom brand mark + name; defaults to the built-in logo. */
|
|
19
47
|
brand?: Snippet
|
|
20
|
-
/** Right-aligned stat segments; defaults to the built-in homelab stats. */
|
|
48
|
+
/** Right-aligned stat segments; defaults to the built-in homelab stats. Pass `[]` to remove. */
|
|
21
49
|
stats?: Stat[]
|
|
50
|
+
/** Services status segment: `true` keeps the built-in 6/7 demo summary,
|
|
51
|
+
* `{ up, total }` renders real numbers, `false` removes the segment. */
|
|
52
|
+
services?: boolean | TopbarServices
|
|
53
|
+
/** Live clock segment; `false` removes it (and skips the interval). */
|
|
54
|
+
clock?: boolean
|
|
22
55
|
/** Anchor the skip link jumps to. */
|
|
23
56
|
skipTarget?: string
|
|
24
57
|
/** When true, the header sticks to the top of the viewport. */
|
|
25
58
|
sticky?: boolean
|
|
59
|
+
/** Accessible name for the tab-strip `<nav>` landmark (DS-0078). */
|
|
60
|
+
ariaLabel?: string
|
|
26
61
|
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
27
62
|
size?: Size
|
|
28
63
|
}
|
|
@@ -33,6 +68,8 @@
|
|
|
33
68
|
{ key: 'net', value: '↓1.2 ↑0.3', title: 'network' },
|
|
34
69
|
]
|
|
35
70
|
|
|
71
|
+
const DEFAULT_SERVICES: TopbarServices = { up: 6, total: 7 }
|
|
72
|
+
|
|
36
73
|
let {
|
|
37
74
|
active = 'overview',
|
|
38
75
|
user = 'admin@hub.home',
|
|
@@ -43,51 +80,96 @@
|
|
|
43
80
|
userMenu,
|
|
44
81
|
brand,
|
|
45
82
|
stats = DEFAULT_STATS,
|
|
83
|
+
services = true,
|
|
84
|
+
clock = true,
|
|
46
85
|
skipTarget = '#main',
|
|
47
86
|
sticky = true,
|
|
87
|
+
ariaLabel = 'Primary',
|
|
48
88
|
size,
|
|
49
89
|
}: Props = $props()
|
|
50
90
|
|
|
51
|
-
|
|
91
|
+
// SSR safety (DS-0067): same guard pattern as toast.svelte.ts — effects
|
|
92
|
+
// normally don't run on the server, but the guard is the house convention
|
|
93
|
+
// and protects against eager evaluation.
|
|
94
|
+
const hasWindow = typeof window !== 'undefined'
|
|
95
|
+
|
|
96
|
+
// DS-0080: normalize both tab shapes to one internal form. `string` tabs
|
|
97
|
+
// keep id === label; object tabs default `label` to `id`.
|
|
98
|
+
const items = $derived(
|
|
99
|
+
tabs.map((t): { id: string; label: string; href?: string } =>
|
|
100
|
+
typeof t === 'string'
|
|
101
|
+
? { id: t, label: t }
|
|
102
|
+
: { id: t.id, label: t.label ?? t.id, href: t.href },
|
|
103
|
+
),
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
// DS-0081: resolve the services prop to data-or-nothing.
|
|
107
|
+
const svc = $derived(services === true ? DEFAULT_SERVICES : services === false ? null : services)
|
|
108
|
+
|
|
109
|
+
function pad(n: number) {
|
|
110
|
+
return String(n).padStart(2, '0')
|
|
111
|
+
}
|
|
52
112
|
function nowStr() {
|
|
53
113
|
const d = new Date()
|
|
54
114
|
return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
|
|
55
115
|
}
|
|
56
116
|
|
|
57
|
-
let
|
|
117
|
+
let time = $state(nowStr())
|
|
58
118
|
|
|
59
119
|
$effect(() => {
|
|
60
|
-
const t =
|
|
120
|
+
const t = clock
|
|
121
|
+
? setInterval(() => {
|
|
122
|
+
time = nowStr()
|
|
123
|
+
}, 1000)
|
|
124
|
+
: undefined
|
|
61
125
|
const onKey = (e: KeyboardEvent) => {
|
|
62
|
-
|
|
126
|
+
// Only claim the Cmd/Ctrl+K shortcut when a command handler exists
|
|
127
|
+
// (DS-0081) — otherwise leave the browser's default alone.
|
|
128
|
+
if (onCommand && (e.metaKey || e.ctrlKey) && (e.key === 'k' || e.key === 'K')) {
|
|
63
129
|
e.preventDefault()
|
|
64
|
-
onCommand
|
|
130
|
+
onCommand()
|
|
65
131
|
}
|
|
66
132
|
}
|
|
67
|
-
window.addEventListener('keydown', onKey)
|
|
133
|
+
if (hasWindow) window.addEventListener('keydown', onKey)
|
|
68
134
|
return () => {
|
|
69
|
-
clearInterval(t)
|
|
70
|
-
window.removeEventListener('keydown', onKey)
|
|
135
|
+
if (t) clearInterval(t)
|
|
136
|
+
if (hasWindow) window.removeEventListener('keydown', onKey)
|
|
71
137
|
}
|
|
72
138
|
})
|
|
73
139
|
|
|
74
|
-
const [h, m, s] = $derived(
|
|
140
|
+
const [h, m, s] = $derived(time.split(':'))
|
|
75
141
|
|
|
76
142
|
// Roving tabindex: arrow keys move focus across the tab strip (wrapping),
|
|
77
|
-
// Home/End jump to the ends.
|
|
78
|
-
|
|
143
|
+
// Home/End jump to the ends. Button tabs keep the active tab as the single
|
|
144
|
+
// tab stop; link tabs stay in the natural tab order so they remain
|
|
145
|
+
// keyboard-reachable without JS (SSR, DS-0080).
|
|
146
|
+
let tabEls: (HTMLAnchorElement | HTMLButtonElement)[] = $state([])
|
|
79
147
|
function focusTab(i: number) {
|
|
80
|
-
const n =
|
|
148
|
+
const n = items.length
|
|
81
149
|
if (!n) return
|
|
82
150
|
const idx = ((i % n) + n) % n
|
|
83
151
|
tabEls[idx]?.focus()
|
|
84
152
|
}
|
|
85
153
|
function onTabKeydown(e: KeyboardEvent, i: number) {
|
|
86
154
|
switch (e.key) {
|
|
87
|
-
case 'ArrowRight':
|
|
88
|
-
case '
|
|
89
|
-
|
|
90
|
-
|
|
155
|
+
case 'ArrowRight':
|
|
156
|
+
case 'ArrowDown':
|
|
157
|
+
e.preventDefault()
|
|
158
|
+
focusTab(i + 1)
|
|
159
|
+
break
|
|
160
|
+
case 'ArrowLeft':
|
|
161
|
+
case 'ArrowUp':
|
|
162
|
+
e.preventDefault()
|
|
163
|
+
focusTab(i - 1)
|
|
164
|
+
break
|
|
165
|
+
case 'Home':
|
|
166
|
+
e.preventDefault()
|
|
167
|
+
focusTab(0)
|
|
168
|
+
break
|
|
169
|
+
case 'End':
|
|
170
|
+
e.preventDefault()
|
|
171
|
+
focusTab(items.length - 1)
|
|
172
|
+
break
|
|
91
173
|
}
|
|
92
174
|
}
|
|
93
175
|
</script>
|
|
@@ -99,7 +181,14 @@
|
|
|
99
181
|
{#if brand}
|
|
100
182
|
{@render brand()}
|
|
101
183
|
{:else}
|
|
102
|
-
<svg
|
|
184
|
+
<svg
|
|
185
|
+
class="mark"
|
|
186
|
+
viewBox="0 0 103 89"
|
|
187
|
+
fill="var(--ss-primary)"
|
|
188
|
+
width="14"
|
|
189
|
+
height="14"
|
|
190
|
+
aria-hidden="true"
|
|
191
|
+
>
|
|
103
192
|
<path
|
|
104
193
|
fill-rule="evenodd"
|
|
105
194
|
clip-rule="evenodd"
|
|
@@ -110,27 +199,45 @@
|
|
|
110
199
|
{/if}
|
|
111
200
|
</div>
|
|
112
201
|
|
|
113
|
-
<nav class="ws" aria-label=
|
|
114
|
-
{#each
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
202
|
+
<nav class="ws" aria-label={ariaLabel}>
|
|
203
|
+
{#each items as tab, i (tab.id)}
|
|
204
|
+
{@const current = tab.id === active}
|
|
205
|
+
{#if tab.href}
|
|
206
|
+
<a
|
|
207
|
+
bind:this={tabEls[i]}
|
|
208
|
+
class="tab {current ? 'active' : ''}"
|
|
209
|
+
href={tab.href}
|
|
210
|
+
aria-current={current ? 'page' : undefined}
|
|
211
|
+
onclick={() => onTab?.(tab.id)}
|
|
212
|
+
onkeydown={(e) => onTabKeydown(e, i)}
|
|
213
|
+
>
|
|
214
|
+
<span class="n" aria-hidden="true">{i + 1}</span>{tab.label}
|
|
215
|
+
</a>
|
|
216
|
+
{:else}
|
|
217
|
+
<button
|
|
218
|
+
bind:this={tabEls[i]}
|
|
219
|
+
type="button"
|
|
220
|
+
class="tab {current ? 'active' : ''}"
|
|
221
|
+
aria-current={current ? 'page' : undefined}
|
|
222
|
+
tabindex={current ? 0 : -1}
|
|
223
|
+
onclick={() => onTab?.(tab.id)}
|
|
224
|
+
onkeydown={(e) => onTabKeydown(e, i)}
|
|
225
|
+
>
|
|
226
|
+
<span class="n" aria-hidden="true">{i + 1}</span>{tab.label}
|
|
227
|
+
</button>
|
|
228
|
+
{/if}
|
|
125
229
|
{/each}
|
|
126
230
|
</nav>
|
|
127
231
|
|
|
128
232
|
<div class="grow"></div>
|
|
129
233
|
|
|
130
|
-
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
|
|
234
|
+
{#if svc}
|
|
235
|
+
<div class="seg right" title="services">
|
|
236
|
+
<span class="dot" aria-hidden="true"></span>
|
|
237
|
+
<span class="stat"><span class="v">{svc.up}</span><span class="k">/{svc.total} up</span></span
|
|
238
|
+
>
|
|
239
|
+
</div>
|
|
240
|
+
{/if}
|
|
134
241
|
|
|
135
242
|
{#each stats as st (st.key)}
|
|
136
243
|
<div class="seg right stat collapsible" title={st.title ?? st.key}>
|
|
@@ -138,14 +245,16 @@
|
|
|
138
245
|
</div>
|
|
139
246
|
{/each}
|
|
140
247
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
248
|
+
{#if onCommand}
|
|
249
|
+
<button
|
|
250
|
+
class="seg right click cmd"
|
|
251
|
+
aria-keyshortcuts="Meta+K Control+K"
|
|
252
|
+
aria-label="Open command menu"
|
|
253
|
+
onclick={() => onCommand?.()}
|
|
254
|
+
>
|
|
255
|
+
<span class="kbd" aria-hidden="true">⌘K</span>
|
|
256
|
+
</button>
|
|
257
|
+
{/if}
|
|
149
258
|
|
|
150
259
|
{#if userMenu}
|
|
151
260
|
<div class="seg right user-slot">{@render userMenu()}</div>
|
|
@@ -153,9 +262,13 @@
|
|
|
153
262
|
<button class="seg right click user-btn" onclick={() => onUser?.()}>{user}</button>
|
|
154
263
|
{/if}
|
|
155
264
|
|
|
156
|
-
|
|
157
|
-
<
|
|
158
|
-
|
|
265
|
+
{#if clock}
|
|
266
|
+
<div class="seg right clock">
|
|
267
|
+
<span>{h}</span><span class="sep">:</span><span>{m}</span><span class="sep">:</span><span
|
|
268
|
+
>{s}</span
|
|
269
|
+
>
|
|
270
|
+
</div>
|
|
271
|
+
{/if}
|
|
159
272
|
</header>
|
|
160
273
|
|
|
161
274
|
<style>.ss-topbar {
|
|
@@ -194,10 +307,11 @@
|
|
|
194
307
|
.ss-topbar .seg {
|
|
195
308
|
display: flex;
|
|
196
309
|
align-items: center;
|
|
197
|
-
gap:
|
|
310
|
+
gap: var(--ss-s-2);
|
|
198
311
|
padding: 0 var(--ss-panel-head-px);
|
|
199
312
|
border-right: 1px solid var(--ss-line);
|
|
200
313
|
cursor: default;
|
|
314
|
+
flex: none;
|
|
201
315
|
}
|
|
202
316
|
.ss-topbar .seg.right {
|
|
203
317
|
border-right: none;
|
|
@@ -237,10 +351,15 @@
|
|
|
237
351
|
.ss-topbar .ws {
|
|
238
352
|
display: flex;
|
|
239
353
|
align-items: stretch;
|
|
354
|
+
min-width: 0;
|
|
355
|
+
overflow-x: auto;
|
|
356
|
+
scrollbar-width: thin;
|
|
240
357
|
}
|
|
241
358
|
.ss-topbar .ws .tab {
|
|
242
359
|
display: flex;
|
|
243
360
|
align-items: center;
|
|
361
|
+
flex: none;
|
|
362
|
+
white-space: nowrap;
|
|
244
363
|
padding: 0 var(--ss-row-px);
|
|
245
364
|
min-height: var(--ss-s-6);
|
|
246
365
|
color: var(--ss-fg-faint);
|
|
@@ -251,6 +370,7 @@
|
|
|
251
370
|
border-top: 0;
|
|
252
371
|
border-bottom: 0;
|
|
253
372
|
border-left: 0;
|
|
373
|
+
text-decoration: none;
|
|
254
374
|
transition: all var(--ss-dur-fast) var(--ss-ease);
|
|
255
375
|
}
|
|
256
376
|
.ss-topbar .ws .tab:hover {
|
|
@@ -283,7 +403,7 @@
|
|
|
283
403
|
}
|
|
284
404
|
.ss-topbar .stat .k {
|
|
285
405
|
color: var(--ss-fg-faint);
|
|
286
|
-
margin-right:
|
|
406
|
+
margin-right: var(--ss-s-1);
|
|
287
407
|
}
|
|
288
408
|
.ss-topbar .stat .v {
|
|
289
409
|
color: var(--ss-fg);
|