@glimstone/svelte 4.9.1 → 4.9.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.
@@ -18,6 +18,8 @@
18
18
  badges?: Snippet;
19
19
  /** More quiet lines under the status, such as what uses the connection. */
20
20
  children?: Snippet;
21
+ /** A switch of the row, such as whether a service shows on the sign-in page, at the end of the name's line above the buttons. */
22
+ control?: Snippet;
21
23
  /** Where the test stands: `busy` while it runs, then `tone` and a `title` with what it found. */
22
24
  test?: ConnectionTest;
23
25
  /** Buttons of the app's own, such as Mount, before Test, Edit and Remove, so those keep their places at the end. */
@@ -43,7 +45,7 @@
43
45
  // badges, one quiet line on how it stands, and at the end the app's own
44
46
  // actions, then its test, edit and remove. A built-in button stands only where
45
47
  // its handler is passed. The other props of a <div> go to the row.
46
- let { name, mark, status, badges, children, test, actions, text, labelKeys, onTest, onEdit, onRemove, class: className, ...rest }: ConnectionRowProps = $props();
48
+ let { name, mark, status, badges, children, control, test, actions, text, labelKeys, onTest, onEdit, onRemove, class: className, ...rest }: ConnectionRowProps = $props();
47
49
 
48
50
  // On a phone the buttons show their glyphs alone, so they keep to one line.
49
51
  const NARROW = 640;
@@ -67,6 +69,7 @@
67
69
  <div class="glim-connection-head">
68
70
  <span class="glim-connection-name">{name}</span>
69
71
  {#if badges}<span class="glim-connection-badges">{@render badges()}</span>{/if}
72
+ {@render control?.()}
70
73
  </div>
71
74
  <div class="glim-connection-foot">
72
75
  <div class="glim-connection-about">
@@ -14,6 +14,8 @@ export interface ConnectionRowProps extends Omit<HTMLAttributes<HTMLDivElement>,
14
14
  badges?: Snippet;
15
15
  /** More quiet lines under the status, such as what uses the connection. */
16
16
  children?: Snippet;
17
+ /** A switch of the row, such as whether a service shows on the sign-in page, at the end of the name's line above the buttons. */
18
+ control?: Snippet;
17
19
  /** Where the test stands: `busy` while it runs, then `tone` and a `title` with what it found. */
18
20
  test?: ConnectionTest;
19
21
  /** Buttons of the app's own, such as Mount, before Test, Edit and Remove, so those keep their places at the end. */
@@ -39,6 +39,7 @@
39
39
  type ListSort,
40
40
  } from "@glimstone/core";
41
41
  import Checkbox from "./Checkbox.svelte";
42
+ import InfoBubble from "./InfoBubble.svelte";
42
43
  import MarkSvg from "./MarkSvg.svelte";
43
44
  import Popover from "./Popover.svelte";
44
45
 
@@ -128,6 +129,7 @@
128
129
  }}
129
130
  />
130
131
  {/if}
132
+ <span class="glim-list-info"><InfoBubble tip={text.hint} /></span>
131
133
  <table bind:this={grid} role="grid" aria-label={label} aria-multiselectable="true" aria-describedby={hintId} class="glim-list-table">
132
134
  <thead>
133
135
  <tr>
@@ -170,7 +172,7 @@
170
172
  </tbody>
171
173
  </table>
172
174
  {#if view.length === 0}<p class="glim-list-empty">{text.noMatch}</p>{/if}
173
- <p id={hintId} class="glim-list-hint">{text.hint}</p>
175
+ <p id={hintId} class="glim-sr-only">{text.hint}</p>
174
176
  {#if open && filterOpen}
175
177
  <Popover open anchor={filterOpen.at} label={text.filterOf(open.label)} onClose={() => (filterOpen = null)}>
176
178
  <div class="glim-list-filter-values">
@@ -0,0 +1,155 @@
1
+ <script lang="ts" module>
2
+ import type { MultiSelectText } from "@glimstone/core";
3
+ import type { SelectOption } from "./selectParts.svelte.js";
4
+
5
+ export type { MultiSelectText } from "@glimstone/core";
6
+
7
+ export interface MultiSelectProps {
8
+ label?: string;
9
+ hideLabel?: boolean;
10
+ options: SelectOption[];
11
+ /** The picked values, bound with `bind:value`, in the order they were picked. */
12
+ value: string[];
13
+ onChange?: (value: string[]) => void;
14
+ /** Shown while nothing is picked. */
15
+ placeholder?: string;
16
+ /** How many choices the list shows before the field takes a search, seven unless given. */
17
+ searchAfter?: number;
18
+ disabled?: boolean;
19
+ text?: Partial<MultiSelectText>;
20
+ }
21
+ </script>
22
+
23
+ <script lang="ts">
24
+ import * as combobox from "@zag-js/combobox";
25
+ import { normalizeProps, useMachine } from "@zag-js/svelte";
26
+ import {
27
+ MULTI_SELECT_SEARCH_AFTER,
28
+ MULTI_SELECT_TEXT,
29
+ multiSelectMatches,
30
+ multiSelectSearches,
31
+ multiSelectWithout,
32
+ pageDir,
33
+ } from "@glimstone/core";
34
+ import { useFieldName } from "./fieldName.js";
35
+ import { IconCheck, IconClose, IconExpand } from "./glyphs.js";
36
+ import { lift } from "./lift.js";
37
+
38
+ // A field that picks several choices from a list and keeps them as tags,
39
+ // each with its own remove mark. It is Zag's combobox in multiple mode, so
40
+ // focus stays in the field while the arrows move through the list, and a
41
+ // pick keeps the list open for the next. A short list takes no typing and
42
+ // answers Space the way a Select does; a long one filters as somebody types.
43
+ let {
44
+ label,
45
+ hideLabel,
46
+ options,
47
+ value = $bindable(),
48
+ onChange,
49
+ placeholder,
50
+ searchAfter,
51
+ disabled = false,
52
+ text,
53
+ }: MultiSelectProps = $props();
54
+
55
+ const name = useFieldName(() => label);
56
+ const words = $derived({ ...MULTI_SELECT_TEXT, ...text });
57
+ const searches = $derived(multiSelectSearches(options.length, searchAfter ?? MULTI_SELECT_SEARCH_AFTER));
58
+ let query = $state("");
59
+ const shown = $derived(searches ? multiSelectMatches(options, query) : options);
60
+ let field: HTMLInputElement | undefined = $state();
61
+ const id = $props.id();
62
+
63
+ function pick(next: string[]) {
64
+ value = next;
65
+ onChange?.(next);
66
+ }
67
+
68
+ const service = useMachine(combobox.machine, () => ({
69
+ id,
70
+ dir: pageDir(),
71
+ collection: combobox.collection({
72
+ items: shown,
73
+ itemToValue: (o: SelectOption) => o.value,
74
+ itemToString: (o: SelectOption) => o.label,
75
+ isItemDisabled: (o: SelectOption) => !!o.disabled,
76
+ }),
77
+ value,
78
+ multiple: true,
79
+ disabled,
80
+ openOnClick: true,
81
+ selectionBehavior: "clear" as const,
82
+ positioning: { sameWidth: true, gutter: 6 },
83
+ onOpenChange: ({ open }: { open: boolean }) => {
84
+ if (!open) query = "";
85
+ },
86
+ onInputValueChange: ({ inputValue }: { inputValue: string }) => (query = inputValue),
87
+ onValueChange: (d: { value: string[] }) => pick(d.value),
88
+ }));
89
+ const api = $derived(combobox.connect(service, normalizeProps));
90
+ const labelOf = (v: string) => options.find((o) => o.value === v)?.label ?? v;
91
+ const input = $derived.by(() => {
92
+ const { onkeydown, ...rest } = api.getInputProps() as Record<string, unknown> & { onkeydown?: (e: KeyboardEvent) => void };
93
+ return { rest, onkeydown };
94
+ });
95
+
96
+ function onkeydown(e: KeyboardEvent) {
97
+ if (e.key === "Backspace" && api.inputValue === "" && value.length > 0) {
98
+ e.preventDefault();
99
+ pick(value.slice(0, -1));
100
+ return;
101
+ }
102
+ if (!searches && e.key === " ") {
103
+ e.preventDefault();
104
+ if (!api.open) api.setOpen(true);
105
+ else if (api.highlightedValue) api.selectValue(api.highlightedValue);
106
+ return;
107
+ }
108
+ input.onkeydown?.(e);
109
+ }
110
+
111
+ function remove(v: string) {
112
+ pick(multiSelectWithout(value, v));
113
+ field?.focus();
114
+ }
115
+ </script>
116
+
117
+ <div data-glim="MultiSelect" {...api.getRootProps()} class="glim-tags">
118
+ <label {...api.getLabelProps()} class={hideLabel || label === undefined ? "glim-sr-only" : "glim-field-label"}>{name()}</label>
119
+ <div {...api.getControlProps()} class={searches ? "glim-tags-control" : "glim-tags-control glim-tags-control--pick"}>
120
+ {#each value as v (v)}
121
+ <span class="glim-tag-item">
122
+ <span class="glim-tag">
123
+ <span class="glim-tag-text">{labelOf(v)}</span>
124
+ <button type="button" {disabled} aria-label={words.remove(labelOf(v))} onclick={() => remove(v)} class="glim-tag-remove">
125
+ {@render IconClose()}
126
+ </button>
127
+ </span>
128
+ </span>
129
+ {/each}
130
+ <input
131
+ {...input.rest}
132
+ bind:this={field}
133
+ readonly={!searches}
134
+ placeholder={value.length === 0 ? placeholder : searches ? words.search : undefined}
135
+ {onkeydown}
136
+ class="glim-tags-input"
137
+ />
138
+ <button {...api.getTriggerProps()} aria-label={words.toggle} class="glim-combobox-toggle">
139
+ <span class="glim-select-indicator" data-state={api.open ? "open" : "closed"}>{@render IconExpand()}</span>
140
+ </button>
141
+ </div>
142
+ <div {@attach lift} {...api.getPositionerProps()} class="glim-select-positioner">
143
+ <ul {...api.getContentProps()} class="glim-select-content">
144
+ {#if shown.length === 0}
145
+ <li class="glim-select-empty">{words.empty}</li>
146
+ {/if}
147
+ {#each shown as item (item.value)}
148
+ <li {...api.getItemProps({ item })} class="glim-select-item">
149
+ <span {...api.getItemTextProps({ item })}>{item.label}</span>
150
+ <span {...api.getItemIndicatorProps({ item })} class="glim-select-check">{@render IconCheck()}</span>
151
+ </li>
152
+ {/each}
153
+ </ul>
154
+ </div>
155
+ </div>
@@ -0,0 +1,20 @@
1
+ import type { MultiSelectText } from "@glimstone/core";
2
+ import type { SelectOption } from "./selectParts.svelte.js";
3
+ export type { MultiSelectText } from "@glimstone/core";
4
+ export interface MultiSelectProps {
5
+ label?: string;
6
+ hideLabel?: boolean;
7
+ options: SelectOption[];
8
+ /** The picked values, bound with `bind:value`, in the order they were picked. */
9
+ value: string[];
10
+ onChange?: (value: string[]) => void;
11
+ /** Shown while nothing is picked. */
12
+ placeholder?: string;
13
+ /** How many choices the list shows before the field takes a search, seven unless given. */
14
+ searchAfter?: number;
15
+ disabled?: boolean;
16
+ text?: Partial<MultiSelectText>;
17
+ }
18
+ declare const MultiSelect: import("svelte").Component<MultiSelectProps, {}, "value">;
19
+ type MultiSelect = ReturnType<typeof MultiSelect>;
20
+ export default MultiSelect;
@@ -19,13 +19,14 @@
19
19
  <script lang="ts">
20
20
  import * as pagination from "@zag-js/pagination";
21
21
  import { normalizeProps, useMachine } from "@zag-js/svelte";
22
- import { PAGINATION_TEXT, pageDir } from "@glimstone/core";
22
+ import { PAGINATION_TEXT, pageDir, watchPaginationFit } from "@glimstone/core";
23
23
  import Button from "./Button.svelte";
24
24
  import { IconBack, IconForward } from "./glyphs.js";
25
25
 
26
26
  // The pages of a long list, for the place a list cannot show every row at once.
27
27
  // The page in force is filled with the accent, as anything chosen is, and the
28
- // two steps follow the label mode like every other button.
28
+ // two steps follow the label mode like every other button. Where the row has
29
+ // no room, the steps stand as glyphs around "3 / 20" (watchPaginationFit).
29
30
  let { count, pageSize = 10, page = $bindable(), onPageChange, siblingCount = 1, text }: PaginationProps = $props();
30
31
 
31
32
  const words = $derived({ ...PAGINATION_TEXT, ...text });
@@ -47,10 +48,14 @@
47
48
  },
48
49
  }));
49
50
  const api = $derived(pagination.connect(service, normalizeProps));
51
+
52
+ let nav: HTMLElement;
53
+ $effect(() => watchPaginationFit(nav));
50
54
  </script>
51
55
 
52
- <nav data-glim="Pagination" {...api.getRootProps()} class="glim-pagination">
53
- <Button label={words.previous} labelKey={null} glyph={IconBack} variant="icon" disabled={api.previousPage === null} onClick={() => api.goToPrevPage()} />
56
+ <nav bind:this={nav} data-glim="Pagination" {...api.getRootProps()} class="glim-pagination">
57
+ <Button class="glim-page-step" label={words.previous} labelKey={null} glyph={IconBack} variant="icon" disabled={api.previousPage === null} onClick={() => api.goToPrevPage()} />
58
+ <Button class="glim-page-step-short" label={words.previous} labelKey={null} glyph={IconBack} compact disabled={api.previousPage === null} onClick={() => api.goToPrevPage()} />
54
59
  {#each api.pages as p, index (p.type === "page" ? p.value : `gap-${index}`)}
55
60
  {#if p.type === "page"}
56
61
  <button {...api.getItemProps(p)} class="glim-page glim-num">{p.value}</button>
@@ -58,5 +63,10 @@
58
63
  <span {...api.getEllipsisProps({ index })} class="glim-page-gap">…</span>
59
64
  {/if}
60
65
  {/each}
61
- <Button label={words.next} labelKey={null} glyph={IconForward} variant="icon" disabled={api.nextPage === null} onClick={() => api.goToNextPage()} />
66
+ <span class="glim-page-status glim-num">
67
+ <span aria-hidden="true">{words.status(api.page, api.totalPages)}</span>
68
+ <span class="glim-sr-only">{words.page(api.page, api.totalPages)}</span>
69
+ </span>
70
+ <Button class="glim-page-step" label={words.next} labelKey={null} glyph={IconForward} variant="icon" disabled={api.nextPage === null} onClick={() => api.goToNextPage()} />
71
+ <Button class="glim-page-step-short" label={words.next} labelKey={null} glyph={IconForward} compact disabled={api.nextPage === null} onClick={() => api.goToNextPage()} />
62
72
  </nav>
@@ -34,7 +34,6 @@
34
34
  import { onDestroy, onMount, untrack } from "svelte";
35
35
  import {
36
36
  accountFacts,
37
- connectionTestFace,
38
37
  createSignInTileFlow,
39
38
  fill,
40
39
  passkeyFacts,
@@ -52,6 +51,7 @@
52
51
  signInTileCards,
53
52
  signInWhen,
54
53
  signInCardNotice,
54
+ signInPasswordAsks,
55
55
  signInPasswordElsewhere,
56
56
  signInShortHint,
57
57
  tokenFacts,
@@ -61,18 +61,16 @@
61
61
  import Badge from "./Badge.svelte";
62
62
  import Button from "./Button.svelte";
63
63
  import Card from "./Card.svelte";
64
- import BrandMark from "./BrandMark.svelte";
64
+ import ConnectionRow from "./ConnectionRow.svelte";
65
65
  import EmptyState from "./EmptyState.svelte";
66
66
  import FieldRow from "./FieldRow.svelte";
67
67
  import FieldRowGroup from "./FieldRowGroup.svelte";
68
- import GlyphTile from "./GlyphTile.svelte";
69
- import ListRow from "./ListRow.svelte";
70
68
  import PasswordField from "./PasswordField.svelte";
71
69
  import SignInTileWindow from "./SignInTileWindow.svelte";
72
70
  import Toggle from "./Toggle.svelte";
73
71
  import UnavailableNotice from "./UnavailableNotice.svelte";
74
72
  import { useConfirm } from "./confirm.svelte.js";
75
- import { glyphFor, IconCancel, IconCheck, IconClose, IconPencil, IconTrash } from "./glyphs.js";
73
+ import { glyphFor, IconCancel } from "./glyphs.js";
76
74
 
77
75
  // The settings tile "Sign-in" ("The sign-in tile" in the design language):
78
76
  // the password, the question before sensitive changes, two-factor, passkeys,
@@ -128,7 +126,10 @@
128
126
  const notice = (card: "askPassword" | "twoFactor" | "passkeys" | "tokens" | "services" | "sessions" | "accounts") => signInCardNotice(text, s, card);
129
127
  const elsewhere = $derived(signInPasswordElsewhere(text, s));
130
128
  const had = $derived(!!s.me?.password);
129
+ const asks = $derived(signInPasswordAsks(s, cards) && !s.editing);
131
130
  const glyph = (key: string) => glyphFor(key)!;
131
+ // The words of a row's own buttons: a service's test, edit and remove, and a passkey's rename in place of edit.
132
+ const rowText = (edit = text.services.edit) => ({ test: text.services.test, edit, remove: text.remove });
132
133
 
133
134
  function remove(what: SignInTileRemoval, id: string, name: string) {
134
135
  const q = removalQuestion(text, what, name);
@@ -142,6 +143,12 @@
142
143
  <UnavailableNotice title={n.title} reason={n.reason} />
143
144
  {/snippet}
144
145
 
146
+ {#snippet askPasswordRow()}
147
+ <FieldRow label={text.askPassword.label} hint={text.askPassword.when}>
148
+ <Toggle bind:checked={() => !!s.settings?.askPassword, (on) => void flow.setAskPassword(on)} data-signin-tile="ask-password" />
149
+ </FieldRow>
150
+ {/snippet}
151
+
145
152
  <div data-glim="SignInTile" class="glim-signin-tile">
146
153
  {#each shown as c, i (c)}
147
154
  {@const hue = hueStart + i}
@@ -149,10 +156,20 @@
149
156
  {@const t = text.password}
150
157
  <Card title={t.title} hint={s.me?.via === "open" ? t.openHint : fill(t.hint, { min: s.offer?.minPassword ?? 12 })} hueIndex={hue} data-signin-card="password">
151
158
  {#if elsewhere}
152
- <p class="glim-signin-tile-text">{elsewhere}</p>
159
+ <div class="glim-signin-tile-body">
160
+ <p class="glim-signin-tile-text">{elsewhere}</p>
161
+ {#if asks}{@render askPasswordRow()}{/if}
162
+ </div>
153
163
  {:else}
154
164
  <div class="glim-signin-tile-body">
155
- <FieldRow label={t.state} value={had ? t.set : t.none} tone={had ? undefined : "warn"} />
165
+ {#if had}
166
+ <FieldRowGroup>
167
+ <FieldRow label={t.state} value={t.set} />
168
+ {#if asks}{@render askPasswordRow()}{/if}
169
+ </FieldRowGroup>
170
+ {:else if !s.editing}
171
+ <EmptyState nested glyph={glyph(keys.setPassword)} title={t.none} hint={t.noneHint} />
172
+ {/if}
156
173
  {#if s.editing}
157
174
  <FieldRowGroup>
158
175
  {#if had}
@@ -205,9 +222,7 @@
205
222
  {#if notice("askPassword")}
206
223
  {@render cardNotice(notice("askPassword")!)}
207
224
  {:else}
208
- <FieldRow label={t.label} hint={t.when}>
209
- <Toggle bind:checked={() => !!s.settings?.askPassword, (on) => void flow.setAskPassword(on)} data-signin-tile="ask-password" />
210
- </FieldRow>
225
+ {@render askPasswordRow()}
211
226
  {/if}
212
227
  </Card>
213
228
  {:else if c === "twoFactor"}
@@ -218,10 +233,14 @@
218
233
  {@render cardNotice(notice("twoFactor")!)}
219
234
  {:else}
220
235
  <div class="glim-signin-tile-body">
221
- <FieldRowGroup>
222
- <FieldRow label={t.state} value={on ? t.on : t.off} tone={on ? "ok" : undefined} />
223
- {#if on}<FieldRow label={t.codesLeft} value={plural(lang, t.codesLeftValue, s.me?.recoveryLeft ?? 0)} />{/if}
224
- </FieldRowGroup>
236
+ {#if on}
237
+ <FieldRowGroup>
238
+ <FieldRow label={t.state} value={t.on} tone="ok" />
239
+ <FieldRow label={t.codesLeft} value={plural(lang, t.codesLeftValue, s.me?.recoveryLeft ?? 0)} />
240
+ </FieldRowGroup>
241
+ {:else}
242
+ <EmptyState nested glyph={glyph(keys.setUp)} title={t.none} hint={t.noneHint} />
243
+ {/if}
225
244
  <div class="glim-signin-tile-foot">
226
245
  {#if on}
227
246
  <Button label={t.newCodes} labelKey={keys.newCodes} busy={s.busy === "two-factor-codes"} data-signin-tile="two-factor-codes" onClick={() => void flow.newCodes()} />
@@ -243,15 +262,20 @@
243
262
  <div class="glim-signin-tile-body">
244
263
  {#if !here}<UnavailableNotice title={t.unavailableTitle} reason={t.unavailable} />{/if}
245
264
  {#if s.passkeys.length > 0}
246
- <div class="glim-list glim-signin-tile-rows">
265
+ <div class="glim-signin-tile-rows">
247
266
  {#each s.passkeys as p (p.id)}
248
- <ListRow steady name={p.name} meta={passkeyFacts(text, p, when).added} tip={passkeyFacts(text, p, when).more}>
249
- {#snippet tile()}<GlyphTile glyph={glyph(keys.passkey)} />{/snippet}
250
- {#snippet actions()}
251
- <Button compact tone="subtle" label={t.rename} labelKey={keys.rename} glyph={IconPencil} data-signin-tile={`passkey-rename-${p.id}`} onClick={() => flow.askRenamePasskey(p.id)} />
252
- <Button compact tone="subtle" label={text.remove} labelKey={keys.remove} glyph={IconTrash} data-signin-tile={`remove-passkey-${p.id}`} onClick={() => remove("passkey", p.id, p.name)} />
253
- {/snippet}
254
- </ListRow>
267
+ {@const facts = passkeyFacts(text, p, when)}
268
+ <ConnectionRow
269
+ name={p.name}
270
+ mark={glyph(keys.passkey)}
271
+ status={facts.added}
272
+ text={rowText(t.rename)}
273
+ labelKeys={{ edit: keys.rename, remove: keys.remove }}
274
+ onEdit={() => flow.askRenamePasskey(p.id)}
275
+ onRemove={() => remove("passkey", p.id, p.name)}
276
+ >
277
+ <p class="glim-connection-status">{facts.more}</p>
278
+ </ConnectionRow>
255
279
  {/each}
256
280
  </div>
257
281
  {:else if here}
@@ -272,29 +296,17 @@
272
296
  {@render cardNotice(notice("sessions")!)}
273
297
  {:else}
274
298
  <div class="glim-signin-tile-body">
275
- <div class="glim-list glim-signin-tile-rows">
299
+ <div class="glim-signin-tile-rows">
276
300
  {#each s.sessions as x (x.id)}
277
301
  {@const device = signInDevice(x.agent, t)}
278
- {#snippet tile()}<GlyphTile glyph={glyph(device.phone ? keys.phone : keys.laptop)} />{/snippet}
279
302
  {#snippet badges()}<Badge size="small" tone="active">{t.current}</Badge>{/snippet}
280
- {#snippet end()}
281
- <Button
282
- compact
283
- tone="subtle"
284
- label={t.end}
285
- labelKey={keys.end}
286
- busy={s.busy === `session-end-${x.id}`}
287
- data-signin-tile={`session-end-${x.id}`}
288
- onClick={() => void flow.endSession(x.id)}
289
- />
290
- {/snippet}
291
- <ListRow
292
- steady
303
+ <ConnectionRow
293
304
  name={device.name}
294
- meta={sessionFacts(text, x, s.serviceLabels, when).join(" · ")}
295
- {tile}
305
+ mark={glyph(device.phone ? keys.phone : keys.laptop)}
306
+ status={sessionFacts(text, x, s.serviceLabels, when).join(" · ")}
296
307
  badges={x.current ? badges : undefined}
297
- actions={x.current ? undefined : end}
308
+ text={rowText()}
309
+ actions={x.current ? [] : [{ id: "end", label: t.end, labelKey: keys.end, busy: s.busy === `session-end-${x.id}`, onClick: () => void flow.endSession(x.id) }]}
298
310
  />
299
311
  {/each}
300
312
  </div>
@@ -320,16 +332,19 @@
320
332
  {:else}
321
333
  <div class="glim-signin-tile-body">
322
334
  {#if s.tokens.length > 0}
323
- <div class="glim-list glim-signin-tile-rows">
335
+ <div class="glim-signin-tile-rows">
324
336
  {#each s.tokens as k (k.id)}
325
- {#snippet tile()}<GlyphTile glyph={glyph(keys.token)} />{/snippet}
326
337
  {#snippet scopes()}
327
338
  {#each k.scopes as scope (scope)}<Badge size="small">{t.scopes[scope] ?? scope}</Badge>{/each}
328
339
  {/snippet}
329
- {#snippet actions()}
330
- <Button compact tone="subtle" label={t.revoke} labelKey={keys.revoke} data-signin-tile={`remove-token-${k.id}`} onClick={() => remove("token", k.id, k.name)} />
331
- {/snippet}
332
- <ListRow steady name={k.name} meta={tokenFacts(text, k, when).join(" · ")} {tile} badges={k.scopes.length > 0 ? scopes : undefined} {actions} />
340
+ <ConnectionRow
341
+ name={k.name}
342
+ mark={glyph(keys.token)}
343
+ status={tokenFacts(text, k, when).join(" · ")}
344
+ badges={k.scopes.length > 0 ? scopes : undefined}
345
+ text={rowText()}
346
+ actions={[{ id: "revoke", label: t.revoke, labelKey: keys.revoke, onClick: () => remove("token", k.id, k.name) }]}
347
+ />
333
348
  {/each}
334
349
  </div>
335
350
  {:else}
@@ -349,46 +364,36 @@
349
364
  {:else}
350
365
  <div class="glim-signin-tile-body">
351
366
  {#if (s.services?.length ?? 0) > 0}
352
- <div class="glim-list glim-signin-tile-rows">
367
+ <div class="glim-signin-tile-rows">
353
368
  {#each s.services ?? [] as x (x.id)}
354
369
  {@const badge = signInServiceBadge(text, x)}
355
370
  {@const label = signInServiceLabel(x, providers, text)}
356
- {@const face = connectionTestFace(s.rowTests[x.id])}
357
- {#snippet brand()}<BrandMark svg={label.mark?.svg ?? ""} />{/snippet}
358
- <ListRow steady name={label.name} meta={signInServiceStatus(text, x, when)} data-signin-service={x.provider}>
359
- {#snippet tile()}<GlyphTile glyph={label.mark ? brand : glyph(keys.service)} />{/snippet}
360
- {#snippet badges()}<Badge size="small" tone={badge.tone}>{badge.label}</Badge>{/snippet}
361
- {#snippet actions()}
362
- {#if !x.fromConfig}
363
- <Toggle
364
- bind:checked={() => x.on, (on) => void flow.setServiceOn(x.id, on)}
365
- label={t.show}
366
- hideLabel
367
- refused={!x.tested || x.paused ? t.mustTest : undefined}
368
- data-signin-tile={`service-on-${x.id}`}
369
- />
370
- {/if}
371
- {#each signInServiceActions(text, x, s, keys.turnOn, (id) => void flow.confirmService(id)) as a (a.id)}
372
- <Button compact tone="subtle" label={a.label} labelKey={a.labelKey} busy={a.busy} data-signin-tile={`service-${a.id}-${x.id}`} onClick={a.onClick} />
373
- {/each}
374
- {#if !x.fromConfig}
375
- <Button
376
- compact
377
- tone={face.tone === "neutral" ? "subtle" : face.tone}
378
- label={t.test}
379
- labelKey={keys.test}
380
- glyph={face.outcome === "cross" ? IconClose : IconCheck}
381
- busy={s.rowTests[x.id]?.busy}
382
- title={s.rowTests[x.id]?.title}
383
- class={face.shake ? "glim-shake" : undefined}
384
- data-signin-tile={`service-test-${x.id}`}
385
- onClick={() => void flow.testService(x.id)}
386
- />
387
- <Button compact tone="subtle" label={t.edit} labelKey={keys.edit} glyph={IconPencil} data-signin-tile={`service-edit-${x.id}`} onClick={() => flow.editService(x.id)} />
388
- <Button compact tone="subtle" label={text.remove} labelKey={keys.remove} glyph={IconTrash} data-signin-tile={`remove-service-${x.id}`} onClick={() => remove("service", x.id, label.name)} />
389
- {/if}
390
- {/snippet}
391
- </ListRow>
371
+ {@const mine = !x.fromConfig}
372
+ {#snippet stands()}{#if badge}<Badge size="small" tone={badge.tone}>{badge.label}</Badge>{/if}{/snippet}
373
+ {#snippet shown()}
374
+ <Toggle
375
+ bind:checked={() => x.on, (on) => void flow.setServiceOn(x.id, on)}
376
+ label={t.show}
377
+ hideLabel
378
+ refused={!x.tested || x.paused ? t.mustTest : undefined}
379
+ data-signin-tile={`service-on-${x.id}`}
380
+ />
381
+ {/snippet}
382
+ <ConnectionRow
383
+ name={label.name}
384
+ mark={label.mark ?? glyph(keys.service)}
385
+ status={signInServiceStatus(text, x, when)}
386
+ badges={badge ? stands : undefined}
387
+ data-signin-service={x.provider}
388
+ control={mine ? shown : undefined}
389
+ text={rowText()}
390
+ labelKeys={{ test: keys.test, edit: keys.edit, remove: keys.remove }}
391
+ actions={signInServiceActions(text, x, s, keys.turnOn, (id) => void flow.confirmService(id))}
392
+ test={s.rowTests[x.id]}
393
+ onTest={mine ? () => void flow.testService(x.id) : undefined}
394
+ onEdit={mine ? () => flow.editService(x.id) : undefined}
395
+ onRemove={mine ? () => remove("service", x.id, label.name) : undefined}
396
+ />
392
397
  {/each}
393
398
  </div>
394
399
  {/if}
@@ -404,32 +409,32 @@
404
409
  {#if notice("accounts")}
405
410
  {@render cardNotice(notice("accounts")!)}
406
411
  {:else}
407
- <div class="glim-list glim-signin-tile-rows">
412
+ <div class="glim-signin-tile-rows">
408
413
  {#each s.accounts ?? [] as a (a.id)}
409
- {#snippet tile()}<GlyphTile glyph={glyph(keys.account)} />{/snippet}
414
+ {@const mine = a.owner || a.id === s.me?.account}
410
415
  {#snippet badges()}
411
416
  {#if a.owner}<Badge size="small">{t.owner}</Badge>{/if}
412
417
  {#if a.blocked}<Badge size="small" tone="warn">{t.blocked}</Badge>{/if}
413
418
  {/snippet}
414
- {#snippet manage()}
415
- <Button
416
- compact
417
- tone="subtle"
418
- label={a.blocked ? t.unblock : t.block}
419
- labelKey={a.blocked ? keys.unblock : keys.block}
420
- busy={s.busy === `account-block-${a.id}`}
421
- data-signin-tile={`account-block-${a.id}`}
422
- onClick={() => void flow.block(a.id, !a.blocked)}
423
- />
424
- <Button compact tone="subtle" label={text.remove} labelKey={keys.remove} glyph={IconTrash} data-signin-tile={`remove-account-${a.id}`} onClick={() => remove("account", a.id, a.name)} />
425
- {/snippet}
426
- <ListRow
427
- steady
419
+ <ConnectionRow
428
420
  name={a.name}
429
- meta={accountFacts(text, a, s.serviceLabels, when).join(" · ")}
430
- {tile}
421
+ mark={glyph(keys.account)}
422
+ status={accountFacts(text, a, s.serviceLabels, when).join(" · ")}
431
423
  badges={a.owner || a.blocked ? badges : undefined}
432
- actions={!a.owner && a.id !== s.me?.account ? manage : undefined}
424
+ text={rowText()}
425
+ labelKeys={{ remove: keys.remove }}
426
+ actions={mine
427
+ ? []
428
+ : [
429
+ {
430
+ id: "block",
431
+ label: a.blocked ? t.unblock : t.block,
432
+ labelKey: a.blocked ? keys.unblock : keys.block,
433
+ busy: s.busy === `account-block-${a.id}`,
434
+ onClick: () => void flow.block(a.id, !a.blocked),
435
+ },
436
+ ]}
437
+ onRemove={mine ? undefined : () => remove("account", a.id, a.name)}
433
438
  />
434
439
  {/each}
435
440
  </div>
@@ -0,0 +1 @@
1
+ export { default as MultiSelect, type MultiSelectProps, type MultiSelectText } from "../MultiSelect.svelte";
@@ -0,0 +1,2 @@
1
+ // Its own entry, so an app that uses none of the Zag controls needs none of the Zag packages.
2
+ export { default as MultiSelect } from "../MultiSelect.svelte";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glimstone/svelte",
3
- "version": "4.9.1",
3
+ "version": "4.9.2",
4
4
  "description": "GlimStone's components for Svelte",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -28,6 +28,11 @@
28
28
  "svelte": "./dist/entries/combobox.js",
29
29
  "default": "./dist/entries/combobox.js"
30
30
  },
31
+ "./MultiSelect": {
32
+ "types": "./dist/entries/multiselect.d.ts",
33
+ "svelte": "./dist/entries/multiselect.js",
34
+ "default": "./dist/entries/multiselect.js"
35
+ },
31
36
  "./Slider": {
32
37
  "types": "./dist/entries/slider.d.ts",
33
38
  "svelte": "./dist/entries/slider.js",
@@ -141,7 +146,7 @@
141
146
  "build": "svelte-package -i src -o dist"
142
147
  },
143
148
  "dependencies": {
144
- "@glimstone/core": "4.9.1"
149
+ "@glimstone/core": "4.9.2"
145
150
  },
146
151
  "peerDependencies": {
147
152
  "@internationalized/date": "^3.12.4",