@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.
- package/dist/ListRow.svelte +20 -5
- package/dist/ListRow.svelte.d.ts +4 -0
- package/dist/NotifyCard.svelte +147 -0
- package/dist/NotifyCard.svelte.d.ts +30 -0
- package/dist/NotifyCardWindow.svelte +206 -0
- package/dist/NotifyCardWindow.svelte.d.ts +19 -0
- package/dist/PasswordField.svelte +7 -2
- package/dist/PasswordField.svelte.d.ts +2 -0
- package/dist/PathField.svelte +2 -0
- package/dist/SignInCard.svelte +73 -20
- package/dist/SignInCard.svelte.d.ts +13 -5
- package/dist/SignInReauthWindow.svelte +82 -0
- package/dist/SignInReauthWindow.svelte.d.ts +9 -0
- package/dist/SignInTile.svelte +444 -0
- package/dist/SignInTile.svelte.d.ts +30 -0
- package/dist/SignInTileWindow.svelte +323 -0
- package/dist/SignInTileWindow.svelte.d.ts +14 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3 -0
- package/package.json +2 -2
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Catalog, SignInApi, SignInTileCard, SignInTileLabelKeys, SignInTileText, ToastSeverity } from "@glimstone/core";
|
|
3
|
+
|
|
4
|
+
export type { SignInTileCard, SignInTileLabelKeys, SignInTileText } from "@glimstone/core";
|
|
5
|
+
|
|
6
|
+
export interface SignInTileProps {
|
|
7
|
+
api: SignInApi;
|
|
8
|
+
text: SignInTileText;
|
|
9
|
+
/** The interface language, for counts, lists and dates. */
|
|
10
|
+
lang: string;
|
|
11
|
+
/** The identity catalog, `IDENTITY_PROVIDERS`, or the part of it the app offers. */
|
|
12
|
+
providers: Catalog;
|
|
13
|
+
/** The cards to draw, in the tile's own order. A card the account may not see stays out. */
|
|
14
|
+
cards?: readonly SignInTileCard[];
|
|
15
|
+
/** The scopes a new token can take, the narrowest first, as the app's kit knows them. */
|
|
16
|
+
scopes?: string[];
|
|
17
|
+
/** Puts what a change did, or why it failed, into the app's toasts. */
|
|
18
|
+
notify?: (message: string, severity: ToastSeverity) => void;
|
|
19
|
+
/** The path a test sign-in comes back to, where the tile stands. */
|
|
20
|
+
returnTo?: string;
|
|
21
|
+
/** The code a sign-in service sent back, from `takeSignInCode()`. */
|
|
22
|
+
arrived?: string | null;
|
|
23
|
+
/** Leaves the page for a test sign-in. Without it the browser goes there. */
|
|
24
|
+
onLeave?: (url: string) => void;
|
|
25
|
+
/** Formats a date the way the app writes them. */
|
|
26
|
+
time?: (iso: string) => string;
|
|
27
|
+
/** The rainbow position the first card takes. */
|
|
28
|
+
hueStart?: number;
|
|
29
|
+
labelKeys?: Partial<SignInTileLabelKeys>;
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<script lang="ts">
|
|
34
|
+
import { onDestroy, onMount, untrack } from "svelte";
|
|
35
|
+
import {
|
|
36
|
+
accountFacts,
|
|
37
|
+
connectionTestFace,
|
|
38
|
+
createSignInTileFlow,
|
|
39
|
+
fill,
|
|
40
|
+
passkeyFacts,
|
|
41
|
+
plural,
|
|
42
|
+
removalQuestion,
|
|
43
|
+
sessionFacts,
|
|
44
|
+
showTileRefusal,
|
|
45
|
+
SIGN_IN_TILE_CARDS,
|
|
46
|
+
SIGN_IN_TILE_KEYS,
|
|
47
|
+
signInDevice,
|
|
48
|
+
signInServiceActions,
|
|
49
|
+
signInServiceBadge,
|
|
50
|
+
signInServiceLabel,
|
|
51
|
+
signInServiceStatus,
|
|
52
|
+
signInTileCards,
|
|
53
|
+
signInWhen,
|
|
54
|
+
signInCardNotice,
|
|
55
|
+
signInPasswordElsewhere,
|
|
56
|
+
signInShortHint,
|
|
57
|
+
tokenFacts,
|
|
58
|
+
type SignInTileField,
|
|
59
|
+
type SignInTileRemoval,
|
|
60
|
+
} from "@glimstone/core";
|
|
61
|
+
import Badge from "./Badge.svelte";
|
|
62
|
+
import Button from "./Button.svelte";
|
|
63
|
+
import Card from "./Card.svelte";
|
|
64
|
+
import BrandMark from "./BrandMark.svelte";
|
|
65
|
+
import EmptyState from "./EmptyState.svelte";
|
|
66
|
+
import FieldRow from "./FieldRow.svelte";
|
|
67
|
+
import FieldRowGroup from "./FieldRowGroup.svelte";
|
|
68
|
+
import GlyphTile from "./GlyphTile.svelte";
|
|
69
|
+
import ListRow from "./ListRow.svelte";
|
|
70
|
+
import PasswordField from "./PasswordField.svelte";
|
|
71
|
+
import SignInTileWindow from "./SignInTileWindow.svelte";
|
|
72
|
+
import Toggle from "./Toggle.svelte";
|
|
73
|
+
import UnavailableNotice from "./UnavailableNotice.svelte";
|
|
74
|
+
import { useConfirm } from "./confirm.svelte.js";
|
|
75
|
+
import { glyphFor, IconCancel, IconCheck, IconClose, IconPencil, IconTrash } from "./glyphs.js";
|
|
76
|
+
|
|
77
|
+
// The settings tile "Sign-in" ("The sign-in tile" in the design language):
|
|
78
|
+
// the password, the question before sensitive changes, two-factor, passkeys,
|
|
79
|
+
// sessions, API tokens, sign-in services and accounts, each a card of its own.
|
|
80
|
+
// The flow lives in the core and talks to the kit through the client, so the
|
|
81
|
+
// tile reads what it shows itself; the app hands in the client and its words.
|
|
82
|
+
let {
|
|
83
|
+
api,
|
|
84
|
+
text,
|
|
85
|
+
lang,
|
|
86
|
+
providers,
|
|
87
|
+
cards = SIGN_IN_TILE_CARDS,
|
|
88
|
+
scopes = ["read", "all"],
|
|
89
|
+
notify,
|
|
90
|
+
returnTo,
|
|
91
|
+
arrived,
|
|
92
|
+
onLeave,
|
|
93
|
+
time,
|
|
94
|
+
hueStart = 0,
|
|
95
|
+
labelKeys,
|
|
96
|
+
}: SignInTileProps = $props();
|
|
97
|
+
|
|
98
|
+
const flow = createSignInTileFlow(() => ({ api, text, lang, cards, scopes, notify, returnTo, onLeave, providers }));
|
|
99
|
+
let s = $state.raw(flow.state());
|
|
100
|
+
onDestroy(flow.subscribe(() => (s = flow.state())));
|
|
101
|
+
onMount(() => flow.start());
|
|
102
|
+
$effect(() => {
|
|
103
|
+
const code = arrived;
|
|
104
|
+
if (code) untrack(() => flow.arrive(code));
|
|
105
|
+
});
|
|
106
|
+
const refusals = $derived(s.refusal?.count);
|
|
107
|
+
$effect(() => {
|
|
108
|
+
void refusals;
|
|
109
|
+
return untrack(() => showTileRefusal(s.refusal));
|
|
110
|
+
});
|
|
111
|
+
const ask = useConfirm({
|
|
112
|
+
get title() {
|
|
113
|
+
return text.confirm;
|
|
114
|
+
},
|
|
115
|
+
get cancel() {
|
|
116
|
+
return text.cancel;
|
|
117
|
+
},
|
|
118
|
+
get confirm() {
|
|
119
|
+
return text.confirm;
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const keys = $derived({ ...SIGN_IN_TILE_KEYS, ...labelKeys });
|
|
124
|
+
const when = $derived(time ?? signInWhen(lang));
|
|
125
|
+
const eye = $derived({ show: text.show, hide: text.hide, confirm: text.confirmPassword, mismatch: text.mismatch });
|
|
126
|
+
const err = (field: SignInTileField) => (s.invalid?.field === field ? s.invalid.message : undefined);
|
|
127
|
+
const shown = $derived(signInTileCards(s, cards));
|
|
128
|
+
const notice = (card: "askPassword" | "twoFactor" | "passkeys" | "tokens" | "services" | "sessions" | "accounts") => signInCardNotice(text, s, card);
|
|
129
|
+
const elsewhere = $derived(signInPasswordElsewhere(text, s));
|
|
130
|
+
const had = $derived(!!s.me?.password);
|
|
131
|
+
const glyph = (key: string) => glyphFor(key)!;
|
|
132
|
+
|
|
133
|
+
function remove(what: SignInTileRemoval, id: string, name: string) {
|
|
134
|
+
const q = removalQuestion(text, what, name);
|
|
135
|
+
void ask.confirm(q.message, { confirmLabel: q.confirm, confirmLabelKey: keys.remove }).then((yes) => {
|
|
136
|
+
if (yes) void flow.remove(what, id);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
</script>
|
|
140
|
+
|
|
141
|
+
{#snippet cardNotice(n: { title: string; reason: string })}
|
|
142
|
+
<UnavailableNotice title={n.title} reason={n.reason} />
|
|
143
|
+
{/snippet}
|
|
144
|
+
|
|
145
|
+
<div data-glim="SignInTile" class="glim-signin-tile">
|
|
146
|
+
{#each shown as c, i (c)}
|
|
147
|
+
{@const hue = hueStart + i}
|
|
148
|
+
{#if c === "password"}
|
|
149
|
+
{@const t = text.password}
|
|
150
|
+
<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
|
+
{#if elsewhere}
|
|
152
|
+
<p class="glim-signin-tile-text">{elsewhere}</p>
|
|
153
|
+
{:else}
|
|
154
|
+
<div class="glim-signin-tile-body">
|
|
155
|
+
<FieldRow label={t.state} value={had ? t.set : t.none} tone={had ? undefined : "warn"} />
|
|
156
|
+
{#if s.editing}
|
|
157
|
+
<FieldRowGroup>
|
|
158
|
+
{#if had}
|
|
159
|
+
<FieldRow label={t.current}>
|
|
160
|
+
<PasswordField
|
|
161
|
+
autocomplete="current-password"
|
|
162
|
+
value={s.draft.current}
|
|
163
|
+
oninput={(e) => flow.set("current", e.currentTarget.value)}
|
|
164
|
+
text={eye}
|
|
165
|
+
error={err("current")}
|
|
166
|
+
/>
|
|
167
|
+
</FieldRow>
|
|
168
|
+
{/if}
|
|
169
|
+
<FieldRow label={t.next}>
|
|
170
|
+
<PasswordField
|
|
171
|
+
confirm
|
|
172
|
+
value={s.draft.next}
|
|
173
|
+
oninput={(e) => flow.set("next", e.currentTarget.value)}
|
|
174
|
+
onConfirmedChange={flow.setConfirmed}
|
|
175
|
+
text={eye}
|
|
176
|
+
error={err("next")}
|
|
177
|
+
note={signInShortHint(t.shortHint, s.draft.next, s.offer?.minPassword ?? 12)}
|
|
178
|
+
/>
|
|
179
|
+
</FieldRow>
|
|
180
|
+
</FieldRowGroup>
|
|
181
|
+
{/if}
|
|
182
|
+
<div class="glim-signin-tile-foot">
|
|
183
|
+
{#if s.editing}
|
|
184
|
+
<Button label={text.cancel} labelKey="common.cancel" glyph={IconCancel} onClick={flow.cancelPassword} />
|
|
185
|
+
<Button
|
|
186
|
+
label={t.save}
|
|
187
|
+
labelKey={keys.savePassword}
|
|
188
|
+
tone="accent"
|
|
189
|
+
busy={s.busy === "save-password"}
|
|
190
|
+
disabled={!s.confirmed || (had && s.draft.current === "")}
|
|
191
|
+
data-signin-tile="save-password"
|
|
192
|
+
onClick={() => void flow.savePassword()}
|
|
193
|
+
/>
|
|
194
|
+
{:else}
|
|
195
|
+
{#if had}<Button label={t.remove} labelKey={keys.removePassword} data-signin-tile="ask-remove-password" onClick={flow.askRemovePassword} />{/if}
|
|
196
|
+
<Button label={had ? t.change : t.add} labelKey={had ? keys.change : keys.setPassword} data-signin-tile="edit-password" onClick={flow.editPassword} />
|
|
197
|
+
{/if}
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
{/if}
|
|
201
|
+
</Card>
|
|
202
|
+
{:else if c === "askPassword"}
|
|
203
|
+
{@const t = text.askPassword}
|
|
204
|
+
<Card title={t.title} hint={t.hint} hueIndex={hue} data-signin-card="askPassword">
|
|
205
|
+
{#if notice("askPassword")}
|
|
206
|
+
{@render cardNotice(notice("askPassword")!)}
|
|
207
|
+
{: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>
|
|
211
|
+
{/if}
|
|
212
|
+
</Card>
|
|
213
|
+
{:else if c === "twoFactor"}
|
|
214
|
+
{@const t = text.twoFactor}
|
|
215
|
+
{@const on = !!s.me?.twoFactor}
|
|
216
|
+
<Card title={t.title} hint={t.hint} hueIndex={hue} data-signin-card="twoFactor">
|
|
217
|
+
{#if notice("twoFactor")}
|
|
218
|
+
{@render cardNotice(notice("twoFactor")!)}
|
|
219
|
+
{:else}
|
|
220
|
+
<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>
|
|
225
|
+
<div class="glim-signin-tile-foot">
|
|
226
|
+
{#if on}
|
|
227
|
+
<Button label={t.newCodes} labelKey={keys.newCodes} busy={s.busy === "two-factor-codes"} data-signin-tile="two-factor-codes" onClick={() => void flow.newCodes()} />
|
|
228
|
+
<Button label={t.turnOff} labelKey={keys.turnOff} data-signin-tile="ask-two-factor-off" onClick={flow.askTwoFactorOff} />
|
|
229
|
+
{:else}
|
|
230
|
+
<Button label={t.setUp} labelKey={keys.setUp} busy={s.busy === "two-factor-set-up"} data-signin-tile="two-factor-set-up" onClick={() => void flow.setUpTwoFactor()} />
|
|
231
|
+
{/if}
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
{/if}
|
|
235
|
+
</Card>
|
|
236
|
+
{:else if c === "passkeys"}
|
|
237
|
+
{@const t = text.passkeys}
|
|
238
|
+
{@const here = s.passkeysHere}
|
|
239
|
+
<Card title={t.title} hint={t.hint} hueIndex={hue} data-signin-card="passkeys">
|
|
240
|
+
{#if notice("passkeys")}
|
|
241
|
+
{@render cardNotice(notice("passkeys")!)}
|
|
242
|
+
{:else}
|
|
243
|
+
<div class="glim-signin-tile-body">
|
|
244
|
+
{#if !here}<UnavailableNotice title={t.unavailableTitle} reason={t.unavailable} />{/if}
|
|
245
|
+
{#if s.passkeys.length > 0}
|
|
246
|
+
<div class="glim-list glim-signin-tile-rows">
|
|
247
|
+
{#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>
|
|
255
|
+
{/each}
|
|
256
|
+
</div>
|
|
257
|
+
{:else if here}
|
|
258
|
+
<EmptyState nested glyph={glyph(keys.passkey)} title={t.none} hint={t.noneHint} />
|
|
259
|
+
{/if}
|
|
260
|
+
{#if here}
|
|
261
|
+
<div class="glim-signin-tile-foot">
|
|
262
|
+
<Button label={t.add} labelKey={keys.add} data-signin-tile="passkey-ask-add" onClick={() => flow.askAddPasskey()} />
|
|
263
|
+
</div>
|
|
264
|
+
{/if}
|
|
265
|
+
</div>
|
|
266
|
+
{/if}
|
|
267
|
+
</Card>
|
|
268
|
+
{:else if c === "sessions"}
|
|
269
|
+
{@const t = text.sessions}
|
|
270
|
+
<Card title={t.title} hint={t.hint} hueIndex={hue} data-signin-card="sessions">
|
|
271
|
+
{#if notice("sessions")}
|
|
272
|
+
{@render cardNotice(notice("sessions")!)}
|
|
273
|
+
{:else}
|
|
274
|
+
<div class="glim-signin-tile-body">
|
|
275
|
+
<div class="glim-list glim-signin-tile-rows">
|
|
276
|
+
{#each s.sessions as x (x.id)}
|
|
277
|
+
{@const device = signInDevice(x.agent, t)}
|
|
278
|
+
{#snippet tile()}<GlyphTile glyph={glyph(device.phone ? keys.phone : keys.laptop)} />{/snippet}
|
|
279
|
+
{#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
|
|
293
|
+
name={device.name}
|
|
294
|
+
meta={sessionFacts(text, x, s.serviceLabels, when).join(" · ")}
|
|
295
|
+
{tile}
|
|
296
|
+
badges={x.current ? badges : undefined}
|
|
297
|
+
actions={x.current ? undefined : end}
|
|
298
|
+
/>
|
|
299
|
+
{/each}
|
|
300
|
+
</div>
|
|
301
|
+
{#if s.sessions.some((x) => !x.current)}
|
|
302
|
+
<div class="glim-signin-tile-foot">
|
|
303
|
+
<Button
|
|
304
|
+
label={t.endOthers}
|
|
305
|
+
labelKey={keys.endOthers}
|
|
306
|
+
busy={s.busy === "sessions-end-others"}
|
|
307
|
+
data-signin-tile="sessions-end-others"
|
|
308
|
+
onClick={() => void flow.endOtherSessions()}
|
|
309
|
+
/>
|
|
310
|
+
</div>
|
|
311
|
+
{/if}
|
|
312
|
+
</div>
|
|
313
|
+
{/if}
|
|
314
|
+
</Card>
|
|
315
|
+
{:else if c === "tokens"}
|
|
316
|
+
{@const t = text.tokens}
|
|
317
|
+
<Card title={t.title} hint={t.hint} hueIndex={hue} data-signin-card="tokens">
|
|
318
|
+
{#if notice("tokens")}
|
|
319
|
+
{@render cardNotice(notice("tokens")!)}
|
|
320
|
+
{:else}
|
|
321
|
+
<div class="glim-signin-tile-body">
|
|
322
|
+
{#if s.tokens.length > 0}
|
|
323
|
+
<div class="glim-list glim-signin-tile-rows">
|
|
324
|
+
{#each s.tokens as k (k.id)}
|
|
325
|
+
{#snippet tile()}<GlyphTile glyph={glyph(keys.token)} />{/snippet}
|
|
326
|
+
{#snippet scopes()}
|
|
327
|
+
{#each k.scopes as scope (scope)}<Badge size="small">{t.scopes[scope] ?? scope}</Badge>{/each}
|
|
328
|
+
{/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} />
|
|
333
|
+
{/each}
|
|
334
|
+
</div>
|
|
335
|
+
{:else}
|
|
336
|
+
<EmptyState nested glyph={glyph(keys.token)} title={t.none} hint={t.noneHint} />
|
|
337
|
+
{/if}
|
|
338
|
+
<div class="glim-signin-tile-foot">
|
|
339
|
+
<Button label={t.create} labelKey={keys.createToken} data-signin-tile="token-ask" onClick={flow.askToken} />
|
|
340
|
+
</div>
|
|
341
|
+
</div>
|
|
342
|
+
{/if}
|
|
343
|
+
</Card>
|
|
344
|
+
{:else if c === "services"}
|
|
345
|
+
{@const t = text.services}
|
|
346
|
+
<Card title={t.title} hint={t.hint} hueIndex={hue} data-signin-card="services">
|
|
347
|
+
{#if notice("services")}
|
|
348
|
+
{@render cardNotice(notice("services")!)}
|
|
349
|
+
{:else}
|
|
350
|
+
<div class="glim-signin-tile-body">
|
|
351
|
+
{#if (s.services?.length ?? 0) > 0}
|
|
352
|
+
<div class="glim-list glim-signin-tile-rows">
|
|
353
|
+
{#each s.services ?? [] as x (x.id)}
|
|
354
|
+
{@const badge = signInServiceBadge(text, x)}
|
|
355
|
+
{@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>
|
|
392
|
+
{/each}
|
|
393
|
+
</div>
|
|
394
|
+
{/if}
|
|
395
|
+
<div class="glim-signin-tile-foot">
|
|
396
|
+
<Button label={t.add} labelKey={keys.addService} data-signin-tile="service-pick" onClick={flow.pickService} />
|
|
397
|
+
</div>
|
|
398
|
+
</div>
|
|
399
|
+
{/if}
|
|
400
|
+
</Card>
|
|
401
|
+
{:else}
|
|
402
|
+
{@const t = text.accounts}
|
|
403
|
+
<Card title={t.title} hint={t.hint} hueIndex={hue} data-signin-card="accounts">
|
|
404
|
+
{#if notice("accounts")}
|
|
405
|
+
{@render cardNotice(notice("accounts")!)}
|
|
406
|
+
{:else}
|
|
407
|
+
<div class="glim-list glim-signin-tile-rows">
|
|
408
|
+
{#each s.accounts ?? [] as a (a.id)}
|
|
409
|
+
{#snippet tile()}<GlyphTile glyph={glyph(keys.account)} />{/snippet}
|
|
410
|
+
{#snippet badges()}
|
|
411
|
+
{#if a.owner}<Badge size="small">{t.owner}</Badge>{/if}
|
|
412
|
+
{#if a.blocked}<Badge size="small" tone="warn">{t.blocked}</Badge>{/if}
|
|
413
|
+
{/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
|
|
428
|
+
name={a.name}
|
|
429
|
+
meta={accountFacts(text, a, s.serviceLabels, when).join(" · ")}
|
|
430
|
+
{tile}
|
|
431
|
+
badges={a.owner || a.blocked ? badges : undefined}
|
|
432
|
+
actions={!a.owner && a.id !== s.me?.account ? manage : undefined}
|
|
433
|
+
/>
|
|
434
|
+
{/each}
|
|
435
|
+
</div>
|
|
436
|
+
{/if}
|
|
437
|
+
</Card>
|
|
438
|
+
{/if}
|
|
439
|
+
{/each}
|
|
440
|
+
{#if s.window}
|
|
441
|
+
<SignInTileWindow {flow} flowState={s} {api} {text} {lang} {scopes} {providers} {keys} />
|
|
442
|
+
{/if}
|
|
443
|
+
<ask.confirmDialog />
|
|
444
|
+
</div>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Catalog, SignInApi, SignInTileCard, SignInTileLabelKeys, SignInTileText, ToastSeverity } from "@glimstone/core";
|
|
2
|
+
export type { SignInTileCard, SignInTileLabelKeys, SignInTileText } from "@glimstone/core";
|
|
3
|
+
export interface SignInTileProps {
|
|
4
|
+
api: SignInApi;
|
|
5
|
+
text: SignInTileText;
|
|
6
|
+
/** The interface language, for counts, lists and dates. */
|
|
7
|
+
lang: string;
|
|
8
|
+
/** The identity catalog, `IDENTITY_PROVIDERS`, or the part of it the app offers. */
|
|
9
|
+
providers: Catalog;
|
|
10
|
+
/** The cards to draw, in the tile's own order. A card the account may not see stays out. */
|
|
11
|
+
cards?: readonly SignInTileCard[];
|
|
12
|
+
/** The scopes a new token can take, the narrowest first, as the app's kit knows them. */
|
|
13
|
+
scopes?: string[];
|
|
14
|
+
/** Puts what a change did, or why it failed, into the app's toasts. */
|
|
15
|
+
notify?: (message: string, severity: ToastSeverity) => void;
|
|
16
|
+
/** The path a test sign-in comes back to, where the tile stands. */
|
|
17
|
+
returnTo?: string;
|
|
18
|
+
/** The code a sign-in service sent back, from `takeSignInCode()`. */
|
|
19
|
+
arrived?: string | null;
|
|
20
|
+
/** Leaves the page for a test sign-in. Without it the browser goes there. */
|
|
21
|
+
onLeave?: (url: string) => void;
|
|
22
|
+
/** Formats a date the way the app writes them. */
|
|
23
|
+
time?: (iso: string) => string;
|
|
24
|
+
/** The rainbow position the first card takes. */
|
|
25
|
+
hueStart?: number;
|
|
26
|
+
labelKeys?: Partial<SignInTileLabelKeys>;
|
|
27
|
+
}
|
|
28
|
+
declare const SignInTile: import("svelte").Component<SignInTileProps, {}, "">;
|
|
29
|
+
type SignInTile = ReturnType<typeof SignInTile>;
|
|
30
|
+
export default SignInTile;
|