dssoca 0.9.0 → 0.10.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/dist/components/Avatar.svelte +119 -0
- package/dist/components/Avatar.svelte.d.ts +18 -0
- package/dist/components/Chart.svelte +527 -0
- package/dist/components/Chart.svelte.d.ts +42 -0
- package/dist/components/DateField.svelte +188 -0
- package/dist/components/DateField.svelte.d.ts +37 -0
- package/dist/components/FileDrop.svelte +355 -0
- package/dist/components/FileDrop.svelte.d.ts +24 -0
- package/dist/components/Modal.svelte +223 -0
- package/dist/components/Modal.svelte.d.ts +29 -0
- package/dist/components/NumberField.svelte +260 -0
- package/dist/components/NumberField.svelte.d.ts +35 -0
- package/dist/components/Pagination.svelte +193 -0
- package/dist/components/Pagination.svelte.d.ts +22 -0
- package/dist/components/Select.svelte +224 -0
- package/dist/components/Select.svelte.d.ts +42 -0
- package/dist/components/Switch.svelte +144 -0
- package/dist/components/Switch.svelte.d.ts +22 -0
- package/dist/components/Table.svelte +267 -0
- package/dist/components/Table.svelte.d.ts +52 -0
- package/dist/components/Tooltip.svelte +162 -0
- package/dist/components/Tooltip.svelte.d.ts +17 -0
- package/dist/dssoca.config.d.ts +1 -1
- package/dist/dssoca.config.js +11 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/package.json +9 -1
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
3
|
+
// Modal (DS-0094). Built on the native <dialog> element so the platform
|
|
4
|
+
// hands us a focus trap, Esc-to-close and an inert ::backdrop for free.
|
|
5
|
+
//
|
|
6
|
+
// `open` is $bindable; an $effect mirrors it onto the dialog via
|
|
7
|
+
// showModal()/close(). The dialog's native `close` event syncs `open` back
|
|
8
|
+
// to false and fires `onclose`. Esc is native; when `closeOnEsc` is false we
|
|
9
|
+
// intercept the `cancel` event and preventDefault(). Backdrop click closes
|
|
10
|
+
// when `closeOnBackdrop` by detecting a pointerdown whose target IS the
|
|
11
|
+
// dialog itself (the inner .panel covers the dialog's content box, so any
|
|
12
|
+
// hit on the dialog element is the surrounding backdrop area).
|
|
13
|
+
//
|
|
14
|
+
// Zero radius; surface = --ss-bg-elev, border = --ss-line; tinted ::backdrop.
|
|
15
|
+
// Component metrics are inline var(--ss-modal-*, fallback) so no global SCSS
|
|
16
|
+
// is touched (DS-0094).
|
|
17
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
18
|
+
import type { Snippet } from 'svelte'
|
|
19
|
+
import { resolveComponentSize, type Size } from '../config.js'
|
|
20
|
+
|
|
21
|
+
interface Props {
|
|
22
|
+
/** Whether the modal is shown. Bindable — sync it from caller state. */
|
|
23
|
+
open?: boolean
|
|
24
|
+
/** Title rendered in the header; also wires `aria-labelledby`. */
|
|
25
|
+
title?: string
|
|
26
|
+
/** Token size (sm|md|lg); controls max-width. Inherits the global size when unset. */
|
|
27
|
+
size?: Size
|
|
28
|
+
/** Clicking the backdrop (outside the panel) closes the modal. @default true */
|
|
29
|
+
closeOnBackdrop?: boolean
|
|
30
|
+
/** Esc closes the modal. When false, Esc is swallowed (cancel prevented). @default true */
|
|
31
|
+
closeOnEsc?: boolean
|
|
32
|
+
/** Styling hint for destructive dialogs (tints the accent rail/title). @default false */
|
|
33
|
+
danger?: boolean
|
|
34
|
+
/** Accessible name when no `title` is set (maps to aria-label on the dialog). */
|
|
35
|
+
'aria-label'?: string
|
|
36
|
+
/** Called after the dialog has closed (any reason: Esc, backdrop, button). */
|
|
37
|
+
onclose?: () => void
|
|
38
|
+
/** Header content; replaces the default title row when provided. */
|
|
39
|
+
header?: Snippet
|
|
40
|
+
/** Footer content (typically action buttons). */
|
|
41
|
+
footer?: Snippet
|
|
42
|
+
/** Body content. */
|
|
43
|
+
children: Snippet
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let {
|
|
47
|
+
open = $bindable(false),
|
|
48
|
+
title,
|
|
49
|
+
size,
|
|
50
|
+
closeOnBackdrop = true,
|
|
51
|
+
closeOnEsc = true,
|
|
52
|
+
danger = false,
|
|
53
|
+
'aria-label': ariaLabel,
|
|
54
|
+
onclose,
|
|
55
|
+
header,
|
|
56
|
+
footer,
|
|
57
|
+
children,
|
|
58
|
+
}: Props = $props()
|
|
59
|
+
|
|
60
|
+
let dialog = $state<HTMLDialogElement | null>(null)
|
|
61
|
+
|
|
62
|
+
// Stable id so the dialog's `aria-labelledby` can point at the title element.
|
|
63
|
+
const uid = $props.id()
|
|
64
|
+
const titleId = $derived(`${uid}-title`)
|
|
65
|
+
|
|
66
|
+
// Mirror `open` onto the native dialog. showModal()/close() throw if called
|
|
67
|
+
// in the wrong state, so guard on dialog.open before flipping it.
|
|
68
|
+
$effect(() => {
|
|
69
|
+
const el = dialog
|
|
70
|
+
if (!el) return
|
|
71
|
+
if (open && !el.open) el.showModal()
|
|
72
|
+
else if (!open && el.open) el.close()
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
// Native `close` (Esc, form method=dialog, .close()) → sync state + notify.
|
|
76
|
+
function onDialogClose() {
|
|
77
|
+
if (open) open = false
|
|
78
|
+
onclose?.()
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Esc dispatches `cancel` before `close`; swallow it when Esc is disabled.
|
|
82
|
+
function onCancel(e: Event) {
|
|
83
|
+
if (!closeOnEsc) e.preventDefault()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// A pointerdown landing on the <dialog> itself (not the inner .panel) is a
|
|
87
|
+
// backdrop hit. Using pointerdown avoids closing on a drag that began inside
|
|
88
|
+
// the panel and released on the backdrop.
|
|
89
|
+
function onPointerDown(e: PointerEvent) {
|
|
90
|
+
if (!closeOnBackdrop) return
|
|
91
|
+
if (e.target === dialog) open = false
|
|
92
|
+
}
|
|
93
|
+
</script>
|
|
94
|
+
|
|
95
|
+
<dialog
|
|
96
|
+
bind:this={dialog}
|
|
97
|
+
class="ss-modal"
|
|
98
|
+
class:danger
|
|
99
|
+
data-size-variant={resolveComponentSize('Modal', size)}
|
|
100
|
+
aria-labelledby={title ? titleId : undefined}
|
|
101
|
+
aria-label={title ? undefined : ariaLabel}
|
|
102
|
+
onclose={onDialogClose}
|
|
103
|
+
oncancel={onCancel}
|
|
104
|
+
onpointerdown={onPointerDown}
|
|
105
|
+
>
|
|
106
|
+
<div class="panel">
|
|
107
|
+
<header class="head">
|
|
108
|
+
{#if header}
|
|
109
|
+
{@render header()}
|
|
110
|
+
{:else if title}
|
|
111
|
+
<h2 class="title" id={titleId}>{title}</h2>
|
|
112
|
+
{/if}
|
|
113
|
+
<button type="button" class="close" aria-label="Close" onclick={() => (open = false)}
|
|
114
|
+
>×</button
|
|
115
|
+
>
|
|
116
|
+
</header>
|
|
117
|
+
|
|
118
|
+
<div class="body">
|
|
119
|
+
{@render children()}
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
{#if footer}
|
|
123
|
+
<footer class="foot">
|
|
124
|
+
{@render footer()}
|
|
125
|
+
</footer>
|
|
126
|
+
{/if}
|
|
127
|
+
</div>
|
|
128
|
+
</dialog>
|
|
129
|
+
|
|
130
|
+
<style>.ss-modal {
|
|
131
|
+
padding: 0;
|
|
132
|
+
border: 1px solid var(--ss-line);
|
|
133
|
+
background: var(--ss-bg-elev);
|
|
134
|
+
color: var(--ss-fg);
|
|
135
|
+
box-shadow: var(--ss-shadow-pop);
|
|
136
|
+
width: var(--ss-modal-w, 32rem);
|
|
137
|
+
max-width: var(--ss-modal-max, calc(100vw - var(--ss-s-8)));
|
|
138
|
+
max-height: var(--ss-modal-max-h, calc(100vh - var(--ss-s-16)));
|
|
139
|
+
margin: auto;
|
|
140
|
+
overflow: hidden;
|
|
141
|
+
}
|
|
142
|
+
.ss-modal::backdrop {
|
|
143
|
+
background: var(--ss-modal-backdrop, rgba(0, 0, 0, 0.62));
|
|
144
|
+
}
|
|
145
|
+
.ss-modal[data-size-variant=sm] {
|
|
146
|
+
--ss-modal-w: 24rem;
|
|
147
|
+
}
|
|
148
|
+
.ss-modal[data-size-variant=lg] {
|
|
149
|
+
--ss-modal-w: 48rem;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.panel {
|
|
153
|
+
display: flex;
|
|
154
|
+
flex-direction: column;
|
|
155
|
+
max-height: inherit;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.head {
|
|
159
|
+
display: flex;
|
|
160
|
+
align-items: center;
|
|
161
|
+
gap: var(--ss-modal-head-gap, var(--ss-s-3));
|
|
162
|
+
padding: var(--ss-modal-pad-y, var(--ss-s-4)) var(--ss-modal-pad-x, var(--ss-s-5));
|
|
163
|
+
border-bottom: 1px solid var(--ss-line);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.title {
|
|
167
|
+
flex: 1 1 auto;
|
|
168
|
+
margin: 0;
|
|
169
|
+
min-width: 0;
|
|
170
|
+
font-family: var(--ss-font-display, var(--ss-font-body));
|
|
171
|
+
font-size: var(--ss-modal-title, var(--ss-size-h3));
|
|
172
|
+
line-height: 1.2;
|
|
173
|
+
color: var(--ss-fg);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.ss-modal.danger .title {
|
|
177
|
+
color: var(--ss-danger);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.close {
|
|
181
|
+
flex: none;
|
|
182
|
+
margin-left: auto;
|
|
183
|
+
appearance: none;
|
|
184
|
+
display: inline-flex;
|
|
185
|
+
align-items: center;
|
|
186
|
+
justify-content: center;
|
|
187
|
+
width: var(--ss-modal-close, var(--ss-s-8));
|
|
188
|
+
height: var(--ss-modal-close, var(--ss-s-8));
|
|
189
|
+
padding: 0;
|
|
190
|
+
background: transparent;
|
|
191
|
+
border: 1px solid transparent;
|
|
192
|
+
color: var(--ss-fg-muted);
|
|
193
|
+
font-size: var(--ss-size-h3);
|
|
194
|
+
line-height: 1;
|
|
195
|
+
cursor: pointer;
|
|
196
|
+
transition: color var(--ss-dur-fast) var(--ss-ease), border-color var(--ss-dur-fast) var(--ss-ease);
|
|
197
|
+
}
|
|
198
|
+
.close:hover {
|
|
199
|
+
color: var(--ss-fg);
|
|
200
|
+
border-color: var(--ss-line-strong);
|
|
201
|
+
}
|
|
202
|
+
.close:focus-visible {
|
|
203
|
+
outline: 2px solid var(--ss-primary);
|
|
204
|
+
outline-offset: 2px;
|
|
205
|
+
color: var(--ss-fg);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.body {
|
|
209
|
+
padding: var(--ss-modal-pad-y, var(--ss-s-4)) var(--ss-modal-pad-x, var(--ss-s-5));
|
|
210
|
+
overflow: auto;
|
|
211
|
+
color: var(--ss-fg);
|
|
212
|
+
font-family: var(--ss-font-body);
|
|
213
|
+
line-height: var(--ss-leading, 1.5);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.foot {
|
|
217
|
+
display: flex;
|
|
218
|
+
align-items: center;
|
|
219
|
+
justify-content: flex-end;
|
|
220
|
+
gap: var(--ss-modal-foot-gap, var(--ss-s-2));
|
|
221
|
+
padding: var(--ss-modal-pad-y, var(--ss-s-4)) var(--ss-modal-pad-x, var(--ss-s-5));
|
|
222
|
+
border-top: 1px solid var(--ss-line);
|
|
223
|
+
}</style>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type Size } from '../config.js';
|
|
3
|
+
interface Props {
|
|
4
|
+
/** Whether the modal is shown. Bindable — sync it from caller state. */
|
|
5
|
+
open?: boolean;
|
|
6
|
+
/** Title rendered in the header; also wires `aria-labelledby`. */
|
|
7
|
+
title?: string;
|
|
8
|
+
/** Token size (sm|md|lg); controls max-width. Inherits the global size when unset. */
|
|
9
|
+
size?: Size;
|
|
10
|
+
/** Clicking the backdrop (outside the panel) closes the modal. @default true */
|
|
11
|
+
closeOnBackdrop?: boolean;
|
|
12
|
+
/** Esc closes the modal. When false, Esc is swallowed (cancel prevented). @default true */
|
|
13
|
+
closeOnEsc?: boolean;
|
|
14
|
+
/** Styling hint for destructive dialogs (tints the accent rail/title). @default false */
|
|
15
|
+
danger?: boolean;
|
|
16
|
+
/** Accessible name when no `title` is set (maps to aria-label on the dialog). */
|
|
17
|
+
'aria-label'?: string;
|
|
18
|
+
/** Called after the dialog has closed (any reason: Esc, backdrop, button). */
|
|
19
|
+
onclose?: () => void;
|
|
20
|
+
/** Header content; replaces the default title row when provided. */
|
|
21
|
+
header?: Snippet;
|
|
22
|
+
/** Footer content (typically action buttons). */
|
|
23
|
+
footer?: Snippet;
|
|
24
|
+
/** Body content. */
|
|
25
|
+
children: Snippet;
|
|
26
|
+
}
|
|
27
|
+
declare const Modal: import("svelte").Component<Props, {}, "open">;
|
|
28
|
+
type Modal = ReturnType<typeof Modal>;
|
|
29
|
+
export default Modal;
|
|
@@ -0,0 +1,260 @@
|
|
|
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
|
+
/** Bindable current value; `null` when the input is empty. */
|
|
9
|
+
value?: number | null
|
|
10
|
+
min?: number
|
|
11
|
+
max?: number
|
|
12
|
+
/** Increment/decrement step for the steppers (and native arrows). */
|
|
13
|
+
step?: number
|
|
14
|
+
required?: boolean
|
|
15
|
+
disabled?: boolean
|
|
16
|
+
/** Native readonly — value visible but not editable; rendered muted. */
|
|
17
|
+
readonly?: boolean
|
|
18
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
19
|
+
size?: Size
|
|
20
|
+
/** Marks the field invalid for assistive tech (aria-invalid). */
|
|
21
|
+
invalid?: boolean
|
|
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
|
+
/** id(s) of element(s) describing the field (aria-describedby) — e.g. hint/error text. */
|
|
27
|
+
describedby?: string
|
|
28
|
+
placeholder?: string
|
|
29
|
+
onchange?: (e: Event & { currentTarget: HTMLInputElement }) => void
|
|
30
|
+
/** Any remaining native input attributes / event handlers are forwarded. */
|
|
31
|
+
[key: string]: unknown
|
|
32
|
+
}
|
|
33
|
+
let {
|
|
34
|
+
label,
|
|
35
|
+
id,
|
|
36
|
+
name,
|
|
37
|
+
value = $bindable(null),
|
|
38
|
+
min,
|
|
39
|
+
max,
|
|
40
|
+
step = 1,
|
|
41
|
+
required = false,
|
|
42
|
+
disabled = false,
|
|
43
|
+
readonly = false,
|
|
44
|
+
size,
|
|
45
|
+
invalid,
|
|
46
|
+
hint,
|
|
47
|
+
error,
|
|
48
|
+
describedby,
|
|
49
|
+
placeholder = '',
|
|
50
|
+
onchange,
|
|
51
|
+
...rest
|
|
52
|
+
}: Props = $props()
|
|
53
|
+
|
|
54
|
+
// Guarantee a label↔input association even when no `id` is passed.
|
|
55
|
+
const uid = $props.id()
|
|
56
|
+
const inputId = $derived(id ?? uid)
|
|
57
|
+
const hintId = $derived(`${inputId}-hint`)
|
|
58
|
+
const errorId = $derived(`${inputId}-error`)
|
|
59
|
+
|
|
60
|
+
// error wins, then hint, then any caller-supplied describedby — order matters for AT.
|
|
61
|
+
const describedBy = $derived(
|
|
62
|
+
[error ? errorId : null, hint ? hintId : null, describedby].filter(Boolean).join(' ') ||
|
|
63
|
+
undefined,
|
|
64
|
+
)
|
|
65
|
+
const isInvalid = $derived(invalid || Boolean(error) || undefined)
|
|
66
|
+
const resolvedSize = $derived(resolveComponentSize('NumberField', size))
|
|
67
|
+
|
|
68
|
+
// Steppers are inert at the bounds (and when the field can't be edited).
|
|
69
|
+
const atMin = $derived(value != null && min != null && value <= min)
|
|
70
|
+
const atMax = $derived(value != null && max != null && value >= max)
|
|
71
|
+
const decDisabled = $derived(disabled || readonly || atMin)
|
|
72
|
+
const incDisabled = $derived(disabled || readonly || atMax)
|
|
73
|
+
|
|
74
|
+
function clamp(n: number): number {
|
|
75
|
+
if (min != null && n < min) return min
|
|
76
|
+
if (max != null && n > max) return max
|
|
77
|
+
return n
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function onInput(e: Event & { currentTarget: HTMLInputElement }) {
|
|
81
|
+
const raw = e.currentTarget.value
|
|
82
|
+
value = raw === '' ? null : e.currentTarget.valueAsNumber
|
|
83
|
+
if (value != null && Number.isNaN(value)) value = null
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function nudge(dir: 1 | -1) {
|
|
87
|
+
const base = value ?? (dir > 0 ? (min ?? 0) : (max ?? 0))
|
|
88
|
+
value = clamp(base + dir * step)
|
|
89
|
+
}
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
<div
|
|
93
|
+
class="ss-numberfield"
|
|
94
|
+
data-size-variant={resolvedSize}
|
|
95
|
+
class:invalid={isInvalid}
|
|
96
|
+
class:disabled
|
|
97
|
+
>
|
|
98
|
+
{#if label}
|
|
99
|
+
<label class="lbl" for={inputId}>
|
|
100
|
+
{label}
|
|
101
|
+
{#if required}<span class="req" aria-hidden="true">*</span>{/if}
|
|
102
|
+
</label>
|
|
103
|
+
{/if}
|
|
104
|
+
|
|
105
|
+
<div class="control">
|
|
106
|
+
<button
|
|
107
|
+
type="button"
|
|
108
|
+
class="step dec"
|
|
109
|
+
aria-label="Decrease"
|
|
110
|
+
disabled={decDisabled}
|
|
111
|
+
onclick={() => nudge(-1)}
|
|
112
|
+
>
|
|
113
|
+
−
|
|
114
|
+
</button>
|
|
115
|
+
<input
|
|
116
|
+
class="ss-input"
|
|
117
|
+
id={inputId}
|
|
118
|
+
{name}
|
|
119
|
+
type="number"
|
|
120
|
+
inputmode="decimal"
|
|
121
|
+
value={value ?? ''}
|
|
122
|
+
{min}
|
|
123
|
+
{max}
|
|
124
|
+
{step}
|
|
125
|
+
{placeholder}
|
|
126
|
+
{required}
|
|
127
|
+
{disabled}
|
|
128
|
+
{readonly}
|
|
129
|
+
aria-invalid={isInvalid}
|
|
130
|
+
aria-describedby={describedBy}
|
|
131
|
+
oninput={onInput}
|
|
132
|
+
{onchange}
|
|
133
|
+
{...rest}
|
|
134
|
+
/>
|
|
135
|
+
<button
|
|
136
|
+
type="button"
|
|
137
|
+
class="step inc"
|
|
138
|
+
aria-label="Increase"
|
|
139
|
+
disabled={incDisabled}
|
|
140
|
+
onclick={() => nudge(1)}
|
|
141
|
+
>
|
|
142
|
+
+
|
|
143
|
+
</button>
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
{#if error}<span class="msg error" id={errorId} role="alert">{error}</span>{/if}
|
|
147
|
+
{#if hint}<span class="msg hint" id={hintId}>{hint}</span>{/if}
|
|
148
|
+
</div>
|
|
149
|
+
|
|
150
|
+
<style>.ss-numberfield {
|
|
151
|
+
display: flex;
|
|
152
|
+
flex-direction: column;
|
|
153
|
+
gap: 6px;
|
|
154
|
+
}
|
|
155
|
+
.ss-numberfield .lbl {
|
|
156
|
+
font-family: var(--ss-font-mono);
|
|
157
|
+
font-size: var(--ss-ui-xs);
|
|
158
|
+
color: var(--ss-fg-muted);
|
|
159
|
+
text-transform: uppercase;
|
|
160
|
+
letter-spacing: 0.08em;
|
|
161
|
+
}
|
|
162
|
+
.ss-numberfield .lbl .req {
|
|
163
|
+
color: var(--ss-red);
|
|
164
|
+
margin-left: 2px;
|
|
165
|
+
}
|
|
166
|
+
.ss-numberfield .control {
|
|
167
|
+
display: flex;
|
|
168
|
+
align-items: stretch;
|
|
169
|
+
background: transparent;
|
|
170
|
+
color: var(--ss-fg);
|
|
171
|
+
border: 1px solid var(--ss-line);
|
|
172
|
+
transition: border-color var(--ss-dur-fast) var(--ss-ease), box-shadow var(--ss-dur-fast) var(--ss-ease);
|
|
173
|
+
}
|
|
174
|
+
.ss-numberfield .control:focus-within {
|
|
175
|
+
border-color: var(--ss-primary);
|
|
176
|
+
box-shadow: 0 0 0 3px var(--ss-primary-soft);
|
|
177
|
+
}
|
|
178
|
+
.ss-numberfield.invalid .control {
|
|
179
|
+
border-color: var(--ss-red);
|
|
180
|
+
}
|
|
181
|
+
.ss-numberfield.invalid .control:focus-within {
|
|
182
|
+
border-color: var(--ss-red);
|
|
183
|
+
box-shadow: 0 0 0 3px rgba(var(--ss-red-rgb), 0.22);
|
|
184
|
+
}
|
|
185
|
+
.ss-numberfield.disabled .control {
|
|
186
|
+
border-color: var(--ss-line);
|
|
187
|
+
}
|
|
188
|
+
.ss-numberfield .step {
|
|
189
|
+
display: inline-flex;
|
|
190
|
+
align-items: center;
|
|
191
|
+
justify-content: center;
|
|
192
|
+
flex: none;
|
|
193
|
+
width: var(--ss-numberfield-step-w, 2.25em);
|
|
194
|
+
font-family: var(--ss-font-mono);
|
|
195
|
+
font-size: var(--ss-input-font);
|
|
196
|
+
line-height: 1;
|
|
197
|
+
background: transparent;
|
|
198
|
+
border: none;
|
|
199
|
+
color: var(--ss-fg-muted);
|
|
200
|
+
cursor: pointer;
|
|
201
|
+
transition: color var(--ss-dur-fast) var(--ss-ease);
|
|
202
|
+
}
|
|
203
|
+
.ss-numberfield .step:hover:not(:disabled) {
|
|
204
|
+
color: var(--ss-fg);
|
|
205
|
+
}
|
|
206
|
+
.ss-numberfield .step:focus-visible {
|
|
207
|
+
outline: none;
|
|
208
|
+
color: var(--ss-fg);
|
|
209
|
+
box-shadow: 0 0 0 2px var(--ss-primary-soft);
|
|
210
|
+
}
|
|
211
|
+
.ss-numberfield .step:disabled {
|
|
212
|
+
color: var(--ss-fg-faint);
|
|
213
|
+
cursor: not-allowed;
|
|
214
|
+
}
|
|
215
|
+
.ss-numberfield .msg {
|
|
216
|
+
font-family: var(--ss-font-mono);
|
|
217
|
+
font-size: var(--ss-ui-xs);
|
|
218
|
+
letter-spacing: 0.02em;
|
|
219
|
+
}
|
|
220
|
+
.ss-numberfield .msg.hint {
|
|
221
|
+
color: var(--ss-fg-faint);
|
|
222
|
+
}
|
|
223
|
+
.ss-numberfield .msg.error {
|
|
224
|
+
color: var(--ss-red);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.ss-input {
|
|
228
|
+
font-family: var(--ss-font-mono);
|
|
229
|
+
font-size: var(--ss-input-font);
|
|
230
|
+
background: transparent;
|
|
231
|
+
color: var(--ss-fg);
|
|
232
|
+
border: none;
|
|
233
|
+
padding: var(--ss-input-py) var(--ss-input-px);
|
|
234
|
+
width: 100%;
|
|
235
|
+
min-width: 0;
|
|
236
|
+
text-align: center;
|
|
237
|
+
transition: color var(--ss-dur-fast) var(--ss-ease);
|
|
238
|
+
-moz-appearance: textfield;
|
|
239
|
+
appearance: textfield;
|
|
240
|
+
}
|
|
241
|
+
.ss-input::-webkit-outer-spin-button, .ss-input::-webkit-inner-spin-button {
|
|
242
|
+
-webkit-appearance: none;
|
|
243
|
+
margin: 0;
|
|
244
|
+
}
|
|
245
|
+
.ss-input:focus {
|
|
246
|
+
outline: none;
|
|
247
|
+
}
|
|
248
|
+
.ss-input::placeholder {
|
|
249
|
+
font-style: italic;
|
|
250
|
+
color: var(--ss-fg-faint);
|
|
251
|
+
}
|
|
252
|
+
.ss-input[readonly] {
|
|
253
|
+
color: var(--ss-fg-muted);
|
|
254
|
+
cursor: default;
|
|
255
|
+
}
|
|
256
|
+
.ss-input:disabled {
|
|
257
|
+
color: var(--ss-fg-faint);
|
|
258
|
+
cursor: not-allowed;
|
|
259
|
+
-webkit-text-fill-color: var(--ss-fg-faint);
|
|
260
|
+
}</style>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type Size } from '../config.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
label?: string;
|
|
4
|
+
id?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
/** Bindable current value; `null` when the input is empty. */
|
|
7
|
+
value?: number | null;
|
|
8
|
+
min?: number;
|
|
9
|
+
max?: number;
|
|
10
|
+
/** Increment/decrement step for the steppers (and native arrows). */
|
|
11
|
+
step?: number;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/** Native readonly — value visible but not editable; rendered muted. */
|
|
15
|
+
readonly?: boolean;
|
|
16
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
17
|
+
size?: Size;
|
|
18
|
+
/** Marks the field invalid for assistive tech (aria-invalid). */
|
|
19
|
+
invalid?: boolean;
|
|
20
|
+
/** Supplementary helper text rendered under the input. */
|
|
21
|
+
hint?: string;
|
|
22
|
+
/** Error text rendered under the input; its presence implies aria-invalid and is announced to AT. */
|
|
23
|
+
error?: string;
|
|
24
|
+
/** id(s) of element(s) describing the field (aria-describedby) — e.g. hint/error text. */
|
|
25
|
+
describedby?: string;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
onchange?: (e: Event & {
|
|
28
|
+
currentTarget: HTMLInputElement;
|
|
29
|
+
}) => void;
|
|
30
|
+
/** Any remaining native input attributes / event handlers are forwarded. */
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
declare const NumberField: import("svelte").Component<Props, {}, "value">;
|
|
34
|
+
type NumberField = ReturnType<typeof NumberField>;
|
|
35
|
+
export default NumberField;
|