@glimstone/svelte 4.8.5 → 4.9.1

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.
@@ -8,6 +8,10 @@
8
8
  tip?: string | null;
9
9
  /** Sets the name in monospace, for a path. */
10
10
  mono?: boolean;
11
+ /** A quiet line under the name, such as when it was made or where it comes from. */
12
+ meta?: string;
13
+ /** Keeps the buttons in view at rest, for a short list of the person's own things, where each row's buttons are the point. */
14
+ steady?: boolean;
11
15
  /** The glyph at the row's start, which fills with the accent while the row is reached. */
12
16
  tile?: Snippet;
13
17
  /** What stands at the row's end at rest. */
@@ -24,7 +28,7 @@
24
28
  // One row of a list: a glyph tile, the name, badges and buttons that come in on
25
29
  // hover and focus (rule 6). A click handler makes the whole row a way into its
26
30
  // object, by keyboard too. The other props of a <div> go to the row.
27
- let { name, tip, mono, tile, badges, actions, class: className, onclick, onkeydown, ...rest }: ListRowProps = $props();
31
+ let { name, tip, mono, meta, steady, tile, badges, actions, class: className, onclick, onkeydown, ...rest }: ListRowProps = $props();
28
32
 
29
33
  const stay = (e: MouseEvent) => e.stopPropagation();
30
34
 
@@ -34,17 +38,28 @@
34
38
  e.preventDefault();
35
39
  e.currentTarget.click();
36
40
  }
37
- const classes = $derived(["glim-list-row", onclick && "glim-list-row--opens", className].filter(Boolean).join(" "));
41
+ const classes = $derived(["glim-list-row", onclick && "glim-list-row--opens", steady && "glim-list-row--steady", className].filter(Boolean).join(" "));
38
42
  </script>
39
43
 
40
- <!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
41
- <div data-glim="ListRow" role="group" aria-label={name} tabindex={onclick ? 0 : undefined} {...rest} {onclick} onkeydown={keys} class={classes}>
42
- {#if tile}<span class="glim-list-row-tile">{@render tile()}</span>{/if}
44
+ {#snippet nameLine()}
43
45
  <span class={mono ? "glim-list-row-name glim-list-row-name--mono" : "glim-list-row-name"}>
44
46
  <span class="glim-list-row-title">{name}</span>
45
47
  <!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
46
48
  {#if tip}<span class="glim-list-row-tip" onclick={stay}><InfoBubble {tip} /></span>{/if}
47
49
  </span>
50
+ {/snippet}
51
+
52
+ <!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
53
+ <div data-glim="ListRow" role="group" aria-label={name} tabindex={onclick ? 0 : undefined} {...rest} {onclick} onkeydown={keys} class={classes}>
54
+ {#if tile}<span class="glim-list-row-tile">{@render tile()}</span>{/if}
55
+ {#if meta}
56
+ <span class="glim-list-row-text">
57
+ {@render nameLine()}
58
+ <span class="glim-list-row-meta">{meta}</span>
59
+ </span>
60
+ {:else}
61
+ {@render nameLine()}
62
+ {/if}
48
63
  {#if badges}<span class="glim-list-row-badges">{@render badges()}</span>{/if}
49
64
  <!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
50
65
  {#if actions}<span class="glim-list-row-actions" onclick={stay}>{@render actions()}</span>{/if}
@@ -6,6 +6,10 @@ export interface ListRowProps extends Omit<HTMLAttributes<HTMLDivElement>, "chil
6
6
  tip?: string | null;
7
7
  /** Sets the name in monospace, for a path. */
8
8
  mono?: boolean;
9
+ /** A quiet line under the name, such as when it was made or where it comes from. */
10
+ meta?: string;
11
+ /** Keeps the buttons in view at rest, for a short list of the person's own things, where each row's buttons are the point. */
12
+ steady?: boolean;
9
13
  /** The glyph at the row's start, which fills with the accent while the row is reached. */
10
14
  tile?: Snippet;
11
15
  /** What stands at the row's end at rest. */
@@ -0,0 +1,147 @@
1
+ <script lang="ts" module>
2
+ import type { Catalog, NotifyApi, NotifyCardLabelKeys, NotifyCardText, NotifyChoice, NotifyKind, ToastSeverity } from "@glimstone/core";
3
+
4
+ export type { NotifyCardLabelKeys, NotifyCardText } from "@glimstone/core";
5
+
6
+ export interface NotifyCardProps {
7
+ /** Loads, saves and tests the channels in the kit's notify format. */
8
+ api: NotifyApi;
9
+ /** The card's words, `notifyCardText(lang)` or the app's own. */
10
+ text: NotifyCardText;
11
+ /** The app's name, for the sentences that say it. */
12
+ app: string;
13
+ /** The interface language, which sorts the picker. */
14
+ lang: string;
15
+ /** The notification catalog, `NOTIFY_PROVIDERS`. */
16
+ providers: Catalog;
17
+ /** The kinds the app sends to, every kind of the kit by default. */
18
+ kinds?: readonly NotifyKind[];
19
+ /** The event kinds the app sends, which each channel can choose among. */
20
+ events?: readonly NotifyChoice[];
21
+ /** The keys a Healthchecks channel can give a check of their own, such as a job. */
22
+ checks?: readonly NotifyChoice[];
23
+ /** Kinds that send nothing where the app runs, with the sentence that says why. */
24
+ unavailable?: Partial<Record<NotifyKind, string>>;
25
+ /** Puts what a change did, or why it failed, into the app's toasts. */
26
+ notify?: (message: string, severity: ToastSeverity) => void;
27
+ /** The card's rainbow position. */
28
+ hueIndex?: number;
29
+ labelKeys?: Partial<NotifyCardLabelKeys>;
30
+ }
31
+ </script>
32
+
33
+ <script lang="ts">
34
+ import { onDestroy, onMount, untrack, type Snippet } from "svelte";
35
+ import { connectionTestFace, createNotifyCardFlow, fill, notifyGlyphKey, notifyRemoval, notifyRows, showNotifyRefusal, NOTIFY_CARD_KEYS, NOTIFY_KINDS } from "@glimstone/core";
36
+ import Badge from "./Badge.svelte";
37
+ import BrandMark from "./BrandMark.svelte";
38
+ import Button from "./Button.svelte";
39
+ import Card from "./Card.svelte";
40
+ import EmptyState from "./EmptyState.svelte";
41
+ import GlyphTile from "./GlyphTile.svelte";
42
+ import ListRow from "./ListRow.svelte";
43
+ import NotifyCardWindow from "./NotifyCardWindow.svelte";
44
+ import Toggle from "./Toggle.svelte";
45
+ import { useConfirm } from "./confirm.svelte.js";
46
+ import { glyphFor, IconCheck, IconClose, IconPencil, IconTrash } from "./glyphs.js";
47
+
48
+ // The settings card "Notifications" ("The notification card" in the design
49
+ // language): the app's channels as rows, each with its switch, its test, Edit
50
+ // and Remove, and the catalog's picker to add one. The flow lives in the core
51
+ // and talks to the app through three calls, so the card names no app or route.
52
+ let { api, text, app, lang, providers, kinds = NOTIFY_KINDS, events = [], checks = [], unavailable = {}, notify, hueIndex, labelKeys }: NotifyCardProps = $props();
53
+
54
+ const flow = createNotifyCardFlow(() => ({ api, text, app, lang, providers, kinds, events, checks, unavailable, notify }));
55
+ let s = $state.raw(flow.state());
56
+ onDestroy(flow.subscribe(() => (s = flow.state())));
57
+ onMount(() => flow.start());
58
+ const refusals = $derived(s.refusal?.count);
59
+ $effect(() => {
60
+ void refusals;
61
+ return untrack(() => showNotifyRefusal(s.refusal));
62
+ });
63
+ const ask = useConfirm({
64
+ get title() {
65
+ return text.remove;
66
+ },
67
+ get cancel() {
68
+ return text.cancel;
69
+ },
70
+ get confirm() {
71
+ return text.remove;
72
+ },
73
+ });
74
+
75
+ const keys = $derived<NotifyCardLabelKeys>({ ...NOTIFY_CARD_KEYS, ...labelKeys });
76
+ const rows = $derived(notifyRows(s, { text, providers, unavailable }));
77
+ const glyph = (kind: NotifyKind): Snippet => glyphFor(notifyGlyphKey(kind, keys))!;
78
+ const markOf = (kind: NotifyKind) => providers.entries.find((e) => e.id === kind)?.mark;
79
+
80
+ function remove(id: string) {
81
+ const c = s.channels.find((x) => x.id === id);
82
+ if (!c) return;
83
+ const q = notifyRemoval(text, c);
84
+ void ask.confirm(q.message, { confirmLabel: q.confirm, confirmLabelKey: keys.remove }).then((yes) => {
85
+ if (yes) void flow.remove(id);
86
+ });
87
+ }
88
+ </script>
89
+
90
+ <div data-glim="NotifyCard">
91
+ <Card title={text.title} hint={text.hint} {hueIndex}>
92
+ <div class="glim-notify-body">
93
+ {#if s.loadFailed}
94
+ <p class="glim-notify-said glim-notify-said--fail" role="alert">{text.notLoaded}</p>
95
+ {/if}
96
+ {#if rows.length > 0}
97
+ <div class="glim-list glim-notify-rows">
98
+ {#each rows as row (row.id)}
99
+ {@const test = s.rowTests[row.id]}
100
+ {@const face = connectionTestFace(test)}
101
+ {@const m = markOf(row.kind)}
102
+ {#snippet brand()}<BrandMark svg={m?.svg ?? ""} />{/snippet}
103
+ {#snippet idle()}<Badge size="small" tone="warn">{text.idle}</Badge>{/snippet}
104
+ <ListRow steady name={row.name} meta={row.meta} badges={row.idle ? idle : undefined} data-notify-channel={row.id}>
105
+ {#snippet tile()}<GlyphTile glyph={m ? brand : glyph(row.kind)} />{/snippet}
106
+ {#snippet actions()}
107
+ <Toggle bind:checked={() => row.enabled, (on) => void flow.setEnabled(row.id, on)} label={row.name} hideLabel data-notify={`switch-${row.id}`} />
108
+ <Button
109
+ compact
110
+ tone={face.tone === "neutral" ? "subtle" : face.tone}
111
+ label={text.test}
112
+ labelKey={keys.test}
113
+ glyph={face.outcome === "cross" ? IconClose : IconCheck}
114
+ busy={test?.busy}
115
+ title={test?.title}
116
+ class={face.shake ? "glim-shake" : undefined}
117
+ data-notify={`test-${row.id}`}
118
+ onClick={() => void flow.testRow(row.id)}
119
+ />
120
+ <Button compact tone="subtle" label={text.edit} labelKey={keys.edit} glyph={IconPencil} data-notify={`edit-${row.id}`} onClick={() => flow.edit(row.id)} />
121
+ <Button
122
+ compact
123
+ tone="subtle"
124
+ label={text.remove}
125
+ labelKey={keys.remove}
126
+ glyph={IconTrash}
127
+ busy={s.busy === `remove-${row.id}`}
128
+ data-notify={`remove-${row.id}`}
129
+ onClick={() => remove(row.id)}
130
+ />
131
+ {/snippet}
132
+ </ListRow>
133
+ {/each}
134
+ </div>
135
+ {:else if s.loaded}
136
+ <EmptyState nested title={fill(text.empty, { app })} />
137
+ {/if}
138
+ <div class="glim-notify-foot">
139
+ <Button label={text.add} labelKey={keys.add} disabled={!s.loaded} data-notify="add" onClick={flow.pick} />
140
+ </div>
141
+ </div>
142
+ </Card>
143
+ {#if s.window}
144
+ <NotifyCardWindow {flow} flowState={s} {text} {app} {lang} {providers} {kinds} {events} {checks} {unavailable} {keys} {glyph} />
145
+ {/if}
146
+ <ask.confirmDialog />
147
+ </div>
@@ -0,0 +1,30 @@
1
+ import type { Catalog, NotifyApi, NotifyCardLabelKeys, NotifyCardText, NotifyChoice, NotifyKind, ToastSeverity } from "@glimstone/core";
2
+ export type { NotifyCardLabelKeys, NotifyCardText } from "@glimstone/core";
3
+ export interface NotifyCardProps {
4
+ /** Loads, saves and tests the channels in the kit's notify format. */
5
+ api: NotifyApi;
6
+ /** The card's words, `notifyCardText(lang)` or the app's own. */
7
+ text: NotifyCardText;
8
+ /** The app's name, for the sentences that say it. */
9
+ app: string;
10
+ /** The interface language, which sorts the picker. */
11
+ lang: string;
12
+ /** The notification catalog, `NOTIFY_PROVIDERS`. */
13
+ providers: Catalog;
14
+ /** The kinds the app sends to, every kind of the kit by default. */
15
+ kinds?: readonly NotifyKind[];
16
+ /** The event kinds the app sends, which each channel can choose among. */
17
+ events?: readonly NotifyChoice[];
18
+ /** The keys a Healthchecks channel can give a check of their own, such as a job. */
19
+ checks?: readonly NotifyChoice[];
20
+ /** Kinds that send nothing where the app runs, with the sentence that says why. */
21
+ unavailable?: Partial<Record<NotifyKind, string>>;
22
+ /** Puts what a change did, or why it failed, into the app's toasts. */
23
+ notify?: (message: string, severity: ToastSeverity) => void;
24
+ /** The card's rainbow position. */
25
+ hueIndex?: number;
26
+ labelKeys?: Partial<NotifyCardLabelKeys>;
27
+ }
28
+ declare const NotifyCard: import("svelte").Component<NotifyCardProps, {}, "">;
29
+ type NotifyCard = ReturnType<typeof NotifyCard>;
30
+ export default NotifyCard;
@@ -0,0 +1,206 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from "svelte";
3
+ import {
4
+ connectionTestFace,
5
+ fill,
6
+ notifyChannelName,
7
+ notifyForm,
8
+ notifyPicker,
9
+ NOTIFY_REDACTED,
10
+ type Catalog,
11
+ type NotifyCardFlow,
12
+ type NotifyCardLabelKeys,
13
+ type NotifyCardState,
14
+ type NotifyCardText,
15
+ type NotifyChoice,
16
+ type NotifyField,
17
+ type NotifyKind,
18
+ } from "@glimstone/core";
19
+ import Button from "./Button.svelte";
20
+ import Checkbox from "./Checkbox.svelte";
21
+ import FieldRow from "./FieldRow.svelte";
22
+ import FieldRowGroup from "./FieldRowGroup.svelte";
23
+ import NumberField from "./NumberField.svelte";
24
+ import PasswordField from "./PasswordField.svelte";
25
+ import PickerWindow from "./PickerWindow.svelte";
26
+ import Select from "./Select.svelte";
27
+ import Selector from "./Selector.svelte";
28
+ import TextArea from "./TextArea.svelte";
29
+ import TextField from "./TextField.svelte";
30
+ import UnavailableNotice from "./UnavailableNotice.svelte";
31
+ import Window, { type WindowAction } from "./Window.svelte";
32
+ import { IconCheck, IconClose, IconTrash } from "./glyphs.js";
33
+
34
+ // The notification card's window: the picker, and the form of the channel
35
+ // being added or edited.
36
+ let {
37
+ flow,
38
+ flowState: s,
39
+ text,
40
+ app,
41
+ lang,
42
+ providers,
43
+ kinds,
44
+ events,
45
+ checks,
46
+ unavailable,
47
+ keys,
48
+ glyph,
49
+ }: {
50
+ flow: NotifyCardFlow;
51
+ flowState: NotifyCardState;
52
+ text: NotifyCardText;
53
+ app: string;
54
+ lang: string;
55
+ providers: Catalog;
56
+ kinds: readonly NotifyKind[];
57
+ events: readonly NotifyChoice[];
58
+ checks: readonly NotifyChoice[];
59
+ unavailable: Partial<Record<NotifyKind, string>>;
60
+ keys: NotifyCardLabelKeys;
61
+ glyph: (kind: NotifyKind) => Snippet;
62
+ } = $props();
63
+
64
+ const w = $derived(s.window!);
65
+ const picker = $derived(notifyPicker(providers, text, lang, kinds, glyph));
66
+ const pickerText = $derived({ search: text.search, none: text.noMatch, clear: text.clear, close: text.close, cancel: text.cancel, back: text.back });
67
+ const form = $derived(w.kind === "form" ? notifyForm(s, { text, app, events, checks, unavailable }) : null);
68
+ const eye = $derived({ show: text.show, hide: text.hide });
69
+ const title = $derived(s.draft ? fill(text.editTitle, { name: notifyChannelName(text, s.draft) }) : "");
70
+ const actions = $derived.by<WindowAction[]>(() => {
71
+ const test = s.formTest;
72
+ const face = connectionTestFace(test);
73
+ return [
74
+ {
75
+ label: text.test,
76
+ labelKey: keys.test,
77
+ glyph: face.outcome === "cross" ? IconClose : face.outcome === "check" ? IconCheck : undefined,
78
+ tone: test?.busy ? undefined : test?.tone,
79
+ busy: !!test?.busy,
80
+ title: test?.title,
81
+ attrs: { "data-notify": "form-test" },
82
+ onClick: () => {
83
+ void flow.test();
84
+ return false;
85
+ },
86
+ },
87
+ {
88
+ label: text.save,
89
+ labelKey: keys.save,
90
+ primary: true,
91
+ busy: s.busy === "save",
92
+ attrs: { "data-notify": "save" },
93
+ onClick: () => {
94
+ void flow.save();
95
+ return false;
96
+ },
97
+ },
98
+ ];
99
+ });
100
+ const items = (options: NotifyField["options"]) => (options ?? []).map((o) => ({ id: o.value, label: o.label }));
101
+ const port = (v: string) => (v === "" ? null : Number(v));
102
+ </script>
103
+
104
+ {#snippet problem(f: NotifyField)}
105
+ {#if f.error}
106
+ <p class="glim-notify-problem" role="alert">{f.error}</p>
107
+ {/if}
108
+ {/snippet}
109
+
110
+ {#snippet body()}
111
+ {#if form}
112
+ <div class="glim-notify-form" data-notify-form={form.kind}>
113
+ {#if form.hint}
114
+ <p class="glim-notify-text">{form.hint}</p>
115
+ {/if}
116
+ {#if form.unavailable}
117
+ <UnavailableNotice title={text.idle} reason={form.unavailable} />
118
+ {/if}
119
+ {#each form.loose as line, i (i)}
120
+ <p class="glim-notify-problem" role="alert">{line}</p>
121
+ {/each}
122
+ <FieldRowGroup>
123
+ {#each form.fields as f (f.path)}
124
+ <FieldRow label={f.label} hint={f.hint}>
125
+ {#if f.control === "secret"}
126
+ <PasswordField autocomplete="new-password" value={f.value} text={eye} note={f.note} error={f.error} oninput={(e) => flow.set(f.path, e.currentTarget.value)} />
127
+ {:else if f.control === "number"}
128
+ <NumberField
129
+ min={1}
130
+ max={65535}
131
+ value={port(f.value)}
132
+ placeholder={f.placeholder}
133
+ error={f.error}
134
+ onChange={(e) => flow.set(f.path, e.currentTarget.value)}
135
+ />
136
+ {:else if f.control === "area"}
137
+ <TextArea mono={f.mono} value={f.value} placeholder={f.placeholder} error={f.error} oninput={(e) => flow.set(f.path, e.currentTarget.value)} />
138
+ {:else if f.control === "select"}
139
+ <Select value={f.value} options={(f.options ?? []).map((o) => ({ value: o.value, label: o.label }))} onChange={(v) => flow.set(f.path, v)} />
140
+ {@render problem(f)}
141
+ {:else if f.control === "segments"}
142
+ <Selector inline activation="manual" value={f.value} items={items(f.options)} onChange={(v) => flow.set(f.path, v)} />
143
+ {@render problem(f)}
144
+ {:else if f.control === "checks"}
145
+ <div class="glim-notify-checks" data-notify="events">
146
+ {#each f.options ?? [] as o (o.value)}
147
+ <Checkbox bind:checked={() => !!o.checked, (on) => flow.setEvent(o.value, on)} label={o.label} />
148
+ {/each}
149
+ </div>
150
+ {:else if f.control === "headers"}
151
+ <div class="glim-notify-headers">
152
+ {#each s.headers as h, i (i)}
153
+ <div class="glim-notify-header">
154
+ <TextField mono label={text.fields.headerName} value={h.name} placeholder="Authorization" oninput={(e) => flow.setHeader(i, "name", e.currentTarget.value)} />
155
+ <PasswordField
156
+ autocomplete="new-password"
157
+ aria-label={text.fields.headerValue}
158
+ value={h.value === NOTIFY_REDACTED ? "" : h.value}
159
+ text={eye}
160
+ oninput={(e) => flow.setHeader(i, "value", e.currentTarget.value)}
161
+ />
162
+ <Button compact tone="subtle" label={text.fields.headerRemove} labelKey={keys.remove} glyph={IconTrash} onClick={() => flow.removeHeader(i)} />
163
+ </div>
164
+ {/each}
165
+ <div>
166
+ <Button label={text.fields.headerAdd} labelKey={keys.add} onClick={flow.addHeader} />
167
+ </div>
168
+ {#if f.note}
169
+ <p class="glim-notify-text">{f.note}</p>
170
+ {/if}
171
+ {@render problem(f)}
172
+ </div>
173
+ {:else}
174
+ <TextField mono={f.mono} value={f.value} placeholder={f.placeholder} error={f.error} oninput={(e) => flow.set(f.path, e.currentTarget.value)} />
175
+ {/if}
176
+ </FieldRow>
177
+ {/each}
178
+ </FieldRowGroup>
179
+ {#if s.said}
180
+ <p class={s.said.ok ? "glim-notify-said" : "glim-notify-said glim-notify-said--fail"} role={s.said.ok ? "status" : "alert"}>{s.said.message}</p>
181
+ {/if}
182
+ </div>
183
+ {/if}
184
+ {/snippet}
185
+
186
+ {#if w.kind === "pick"}
187
+ <PickerWindow title={text.add} hint={text.hint} items={picker.items} groups={picker.groups} text={pickerText} onPick={flow.choose} onClose={flow.close} />
188
+ {:else if form && w.adding}
189
+ <PickerWindow
190
+ title={text.add}
191
+ items={picker.items}
192
+ groups={picker.groups}
193
+ text={pickerText}
194
+ selected={form.kind}
195
+ {actions}
196
+ onPick={flow.choose}
197
+ onBack={flow.pick}
198
+ onClose={flow.close}
199
+ >
200
+ {@render body()}
201
+ </PickerWindow>
202
+ {:else if form}
203
+ <Window {title} text={{ cancel: text.cancel, close: text.close }} closeOnBackdrop={false} {actions} onClose={flow.close}>
204
+ {@render body()}
205
+ </Window>
206
+ {/if}
@@ -0,0 +1,19 @@
1
+ import type { Snippet } from "svelte";
2
+ import { type Catalog, type NotifyCardFlow, type NotifyCardLabelKeys, type NotifyCardState, type NotifyCardText, type NotifyChoice, type NotifyKind } from "@glimstone/core";
3
+ type $$ComponentProps = {
4
+ flow: NotifyCardFlow;
5
+ flowState: NotifyCardState;
6
+ text: NotifyCardText;
7
+ app: string;
8
+ lang: string;
9
+ providers: Catalog;
10
+ kinds: readonly NotifyKind[];
11
+ events: readonly NotifyChoice[];
12
+ checks: readonly NotifyChoice[];
13
+ unavailable: Partial<Record<NotifyKind, string>>;
14
+ keys: NotifyCardLabelKeys;
15
+ glyph: (kind: NotifyKind) => Snippet;
16
+ };
17
+ declare const NotifyCardWindow: import("svelte").Component<$$ComponentProps, {}, "">;
18
+ type NotifyCardWindow = ReturnType<typeof NotifyCardWindow>;
19
+ export default NotifyCardWindow;
@@ -10,6 +10,8 @@
10
10
  text?: Partial<PasswordFieldText>;
11
11
  /** Why the value cannot stand, as a line under the field until it is fixed. */
12
12
  error?: string;
13
+ /** A quiet line under the field that only informs, such as a hint about the value. An error takes its place. */
14
+ note?: string;
13
15
  /** Asks for the password again in a second field, which stands once the first holds something. */
14
16
  confirm?: boolean;
15
17
  /** Whether both fields hold the same password, each time that changes. Set password waits for true. */
@@ -22,7 +24,7 @@
22
24
  </script>
23
25
 
24
26
  <script lang="ts">
25
- import { fieldErrorView, fieldWidthClass, PASSWORD_FIELD_TEXT, passwordConfirmView } from "@glimstone/core";
27
+ import { fieldErrorView, fieldNoteView, fieldWidthClass, PASSWORD_FIELD_TEXT, passwordConfirmView } from "@glimstone/core";
26
28
  import FieldError from "./FieldError.svelte";
27
29
  import { useFieldName } from "./fieldName.js";
28
30
  import { IconEye, IconEyeOff } from "./glyphs.js";
@@ -38,6 +40,7 @@
38
40
  eyeAttrs,
39
41
  text,
40
42
  error,
43
+ note,
41
44
  confirm = false,
42
45
  onConfirmedChange,
43
46
  class: className,
@@ -56,7 +59,8 @@
56
59
  const name = useFieldName(() => ariaLabel ?? undefined);
57
60
  const own = $props.id();
58
61
  const id = $derived(rest.id ?? own);
59
- const err = $derived(fieldErrorView(error, id, describedBy ?? undefined));
62
+ const quiet = $derived(fieldNoteView(note, error, id, describedBy ?? undefined));
63
+ const err = $derived(fieldErrorView(error, id, quiet.describedBy));
60
64
  const view = $derived(passwordConfirmView(value == null ? "" : String(value), repeat));
61
65
  const mismatch = $derived(fieldErrorView(view.mismatch ? words.mismatch : undefined, `${id}-confirm`));
62
66
  $effect(() => {
@@ -85,6 +89,7 @@
85
89
  </IconTipButton>
86
90
  </span>
87
91
  {#if err.errorId}<FieldError id={err.errorId}>{error}</FieldError>{/if}
92
+ {#if quiet.noteId}<span id={quiet.noteId} class="glim-field-note">{note}</span>{/if}
88
93
  {#if confirm && view.shown}
89
94
  <span class="glim-secret-confirm">
90
95
  <label for="{id}-confirm" class="glim-secret-confirm-label">{words.confirm}</label>
@@ -8,6 +8,8 @@ export interface PasswordFieldProps extends Omit<HTMLInputAttributes, "type" | "
8
8
  text?: Partial<PasswordFieldText>;
9
9
  /** Why the value cannot stand, as a line under the field until it is fixed. */
10
10
  error?: string;
11
+ /** A quiet line under the field that only informs, such as a hint about the value. An error takes its place. */
12
+ note?: string;
11
13
  /** Asks for the password again in a second field, which stands once the first holds something. */
12
14
  confirm?: boolean;
13
15
  /** Whether both fields hold the same password, each time that changes. Set password waits for true. */
@@ -62,7 +62,9 @@
62
62
  const name = useFieldName(() => label);
63
63
  let box: HTMLSpanElement;
64
64
  let tight = $state(false);
65
+ // Measured once on mount as well, so the button's look is right before anything reads or paints it.
65
66
  $effect(() => {
67
+ tight = box.getBoundingClientRect().width < PATH_ROOM_PX;
66
68
  const watcher = new ResizeObserver(([entry]) => (tight = entry!.contentRect.width < PATH_ROOM_PX));
67
69
  watcher.observe(box);
68
70
  return () => watcher.disconnect();