@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
package/dist/SignInCard.svelte
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { Snippet } from "svelte";
|
|
3
|
-
import type { SignInHandlers, SignInLabelKeys, SignInText } from "@glimstone/core";
|
|
3
|
+
import type { SignInCardService, SignInHandlers, SignInLabelKeys, SignInText } from "@glimstone/core";
|
|
4
4
|
|
|
5
|
-
export type { ResetAnswer, SignInAnswer, SignInLabelKeys, SignInText } from "@glimstone/core";
|
|
5
|
+
export type { ResetAnswer, SignInAnswer, SignInCardService, SignInLabelKeys, SignInText } from "@glimstone/core";
|
|
6
6
|
|
|
7
7
|
export interface SignInCardProps extends SignInHandlers {
|
|
8
8
|
/** The app's logo, as an address or as an inline `<svg>` with a viewBox. It stands 7.5rem tall above the name, as wide as its shape asks. */
|
|
@@ -10,14 +10,22 @@
|
|
|
10
10
|
/** The page's heading. */
|
|
11
11
|
appName: string;
|
|
12
12
|
text: SignInText;
|
|
13
|
-
/**
|
|
13
|
+
/** Draws a passkey button, for a server without the browser's offer in the password field. `onPasskeyOffer` needs none. */
|
|
14
14
|
passkey?: boolean;
|
|
15
15
|
/** Offers Forgot password? and the reset form. */
|
|
16
16
|
reset?: boolean;
|
|
17
|
-
/**
|
|
17
|
+
/** Asks for the account's name in the reset form, in an app with several accounts (the kit's options say `owner: false`). */
|
|
18
|
+
resetName?: boolean;
|
|
19
|
+
/** The length, as the server says, under which the reset form suggests a longer password. It never refuses a shorter one. */
|
|
18
20
|
minPassword?: number;
|
|
19
21
|
/** One line at the top of the sign-in form, such as "You are signed out". */
|
|
20
22
|
note?: string;
|
|
23
|
+
/** A refusal from outside the card, such as a sign-in service that sent the person back, said above Sign in until the card's next try. */
|
|
24
|
+
error?: string;
|
|
25
|
+
/** The sign-in service whose button stands under Sign in, the one second way in the page offers. */
|
|
26
|
+
service?: SignInCardService;
|
|
27
|
+
/** Leaves for the sign-in service. */
|
|
28
|
+
onService?: () => void;
|
|
21
29
|
/** The app's own fields, above the password. */
|
|
22
30
|
fields?: Snippet;
|
|
23
31
|
/** The app's own buttons, under Sign in and the passkey. */
|
|
@@ -25,7 +33,7 @@
|
|
|
25
33
|
/** A step the app runs itself, in place of the card's forms. */
|
|
26
34
|
step?: Snippet;
|
|
27
35
|
labelKeys?: Partial<SignInLabelKeys>;
|
|
28
|
-
/** The start of the fields' ids: `-password`, `-code`, `-reset-code`, `-new` and `-confirm` follow it. */
|
|
36
|
+
/** The start of the fields' ids: `-password`, `-code`, `-reset-code`, `-reset-name`, `-new` and `-confirm` follow it. */
|
|
29
37
|
idPrefix?: string;
|
|
30
38
|
/** Puts the focus in the first empty field when the card opens. */
|
|
31
39
|
autoFocus?: boolean;
|
|
@@ -36,8 +44,10 @@
|
|
|
36
44
|
|
|
37
45
|
<script lang="ts">
|
|
38
46
|
import { onDestroy, untrack } from "svelte";
|
|
39
|
-
import { createSignInFlow, focusFirstField, resetBlocked, showRefusal, signInBlocked, signInStage } from "@glimstone/core";
|
|
47
|
+
import { createSignInFlow, focusFirstField, passkeyOfferKey, resetBlocked, showRefusal, signInBlocked, signInShortHint, signInStage } from "@glimstone/core";
|
|
48
|
+
import BrandMark from "./BrandMark.svelte";
|
|
40
49
|
import Button from "./Button.svelte";
|
|
50
|
+
import { glyphFor } from "./glyphs.js";
|
|
41
51
|
import PasswordField from "./PasswordField.svelte";
|
|
42
52
|
import SignInField from "./SignInField.svelte";
|
|
43
53
|
import TextField from "./TextField.svelte";
|
|
@@ -51,8 +61,12 @@
|
|
|
51
61
|
text,
|
|
52
62
|
passkey = false,
|
|
53
63
|
reset = false,
|
|
64
|
+
resetName = false,
|
|
54
65
|
minPassword = 12,
|
|
55
66
|
note,
|
|
67
|
+
error: outside,
|
|
68
|
+
service,
|
|
69
|
+
onService,
|
|
56
70
|
fields,
|
|
57
71
|
actions,
|
|
58
72
|
step,
|
|
@@ -62,6 +76,7 @@
|
|
|
62
76
|
class: className,
|
|
63
77
|
onSignIn,
|
|
64
78
|
onPasskey,
|
|
79
|
+
onPasskeyOffer,
|
|
65
80
|
onAskCode,
|
|
66
81
|
onSetPassword,
|
|
67
82
|
}: SignInCardProps = $props();
|
|
@@ -72,9 +87,10 @@
|
|
|
72
87
|
forgot: "forgotPassword",
|
|
73
88
|
back: "back",
|
|
74
89
|
setPassword: "setPassword",
|
|
90
|
+
service: "signIn",
|
|
75
91
|
};
|
|
76
92
|
|
|
77
|
-
const flow = createSignInFlow(() => ({ onSignIn, onPasskey, onAskCode, onSetPassword, text, minPassword }));
|
|
93
|
+
const flow = createSignInFlow(() => ({ onSignIn, onPasskey, onPasskeyOffer, onAskCode, onSetPassword, text, minPassword, resetName }));
|
|
78
94
|
let s = $state.raw(flow.state());
|
|
79
95
|
onDestroy(flow.subscribe(() => (s = flow.state())));
|
|
80
96
|
const ownId = $props.id();
|
|
@@ -100,14 +116,27 @@
|
|
|
100
116
|
if (refusal) return showRefusal(card, refusal);
|
|
101
117
|
});
|
|
102
118
|
|
|
119
|
+
const offers = $derived(!!onPasskeyOffer && !step);
|
|
120
|
+
const offer = $derived(offers ? passkeyOfferKey(s) : null);
|
|
121
|
+
$effect(() => {
|
|
122
|
+
if (!offer) return;
|
|
123
|
+
const stop = new AbortController();
|
|
124
|
+
untrack(() => void flow.offer(stop.signal));
|
|
125
|
+
return () => stop.abort();
|
|
126
|
+
});
|
|
127
|
+
|
|
103
128
|
function submit(e: SubmitEvent) {
|
|
104
129
|
e.preventDefault();
|
|
105
130
|
void flow.submit();
|
|
106
131
|
}
|
|
107
132
|
</script>
|
|
108
133
|
|
|
109
|
-
{#snippet
|
|
110
|
-
{#if
|
|
134
|
+
{#snippet said(line: string | null | undefined)}
|
|
135
|
+
{#if line}<p class="glim-signin-error" role="alert">{line}</p>{/if}
|
|
136
|
+
{/snippet}
|
|
137
|
+
|
|
138
|
+
{#snippet serviceMark()}
|
|
139
|
+
{#if service?.mark}<BrandMark svg={service.mark.svg} />{/if}
|
|
111
140
|
{/snippet}
|
|
112
141
|
|
|
113
142
|
{#snippet back()}
|
|
@@ -142,6 +171,19 @@
|
|
|
142
171
|
placeholder="XXXX-XXXX-XXXX"
|
|
143
172
|
/>
|
|
144
173
|
</SignInField>
|
|
174
|
+
{#if resetName}
|
|
175
|
+
<SignInField label={text.name} htmlFor={id("reset-name")}>
|
|
176
|
+
<TextField
|
|
177
|
+
id={id("reset-name")}
|
|
178
|
+
data-signin-field="resetName"
|
|
179
|
+
value={s.resetName}
|
|
180
|
+
oninput={(e) => flow.set("resetName", e.currentTarget.value)}
|
|
181
|
+
autocomplete="username"
|
|
182
|
+
autocapitalize="none"
|
|
183
|
+
spellcheck={false}
|
|
184
|
+
/>
|
|
185
|
+
</SignInField>
|
|
186
|
+
{/if}
|
|
145
187
|
<SignInField label={text.newPassword} htmlFor={id("new")}>
|
|
146
188
|
<PasswordField
|
|
147
189
|
id={id("new")}
|
|
@@ -150,6 +192,7 @@
|
|
|
150
192
|
oninput={(e) => flow.set("newPassword", e.currentTarget.value)}
|
|
151
193
|
autocomplete="new-password"
|
|
152
194
|
text={eye}
|
|
195
|
+
note={signInShortHint(text.shortHint, s.newPassword, minPassword)}
|
|
153
196
|
/>
|
|
154
197
|
</SignInField>
|
|
155
198
|
<SignInField label={text.confirmPassword} htmlFor={id("confirm")}>
|
|
@@ -162,7 +205,7 @@
|
|
|
162
205
|
text={eye}
|
|
163
206
|
/>
|
|
164
207
|
</SignInField>
|
|
165
|
-
{@render error
|
|
208
|
+
{@render said(s.error)}
|
|
166
209
|
<!-- Stacked, since the longer translations of the two labels do not fit side by side. -->
|
|
167
210
|
<Button
|
|
168
211
|
label={text.setPassword}
|
|
@@ -170,7 +213,7 @@
|
|
|
170
213
|
tone="accent"
|
|
171
214
|
type="submit"
|
|
172
215
|
data-signin="set-password"
|
|
173
|
-
disabled={resetBlocked(s)}
|
|
216
|
+
disabled={resetBlocked(s, resetName)}
|
|
174
217
|
busy={s.busy === "setPassword"}
|
|
175
218
|
title={s.busy === "setPassword" ? text.saving : undefined}
|
|
176
219
|
/>
|
|
@@ -187,7 +230,7 @@
|
|
|
187
230
|
data-signin-field="password"
|
|
188
231
|
value={s.password}
|
|
189
232
|
oninput={(e) => flow.set("password", e.currentTarget.value)}
|
|
190
|
-
autocomplete="current-password"
|
|
233
|
+
autocomplete={offers ? "current-password webauthn" : "current-password"}
|
|
191
234
|
text={eye}
|
|
192
235
|
/>
|
|
193
236
|
</SignInField>
|
|
@@ -208,7 +251,7 @@
|
|
|
208
251
|
<p class="glim-signin-hint">{text.codeHint}</p>
|
|
209
252
|
</div>
|
|
210
253
|
{/if}
|
|
211
|
-
{@render error()}
|
|
254
|
+
{@render said(s.error ?? (s.tried ? null : outside))}
|
|
212
255
|
<Button
|
|
213
256
|
label={text.signIn}
|
|
214
257
|
labelKey={keys.signIn}
|
|
@@ -231,19 +274,29 @@
|
|
|
231
274
|
onClick={() => void flow.passkey()}
|
|
232
275
|
/>
|
|
233
276
|
{/if}
|
|
277
|
+
{#if !s.needCode && service}
|
|
278
|
+
<Button
|
|
279
|
+
label={service.name}
|
|
280
|
+
labelKey={null}
|
|
281
|
+
glyph={service.mark ? serviceMark : glyphFor(keys.service)}
|
|
282
|
+
data-signin="service"
|
|
283
|
+
disabled={!!s.busy}
|
|
284
|
+
onClick={() => onService?.()}
|
|
285
|
+
/>
|
|
286
|
+
{/if}
|
|
234
287
|
{#if !s.needCode}{@render actions?.()}{/if}
|
|
288
|
+
<!-- A plain link, the last line of the card: nobody plans to forget a password. -->
|
|
235
289
|
{#if s.needCode}
|
|
236
290
|
{@render back()}
|
|
237
291
|
{:else if reset}
|
|
238
|
-
<
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
tone="subtle"
|
|
292
|
+
<button
|
|
293
|
+
type="button"
|
|
294
|
+
class="glim-signin-forgot"
|
|
242
295
|
data-signin="forgot"
|
|
243
296
|
disabled={!!s.busy}
|
|
244
|
-
busy={s.busy === "askCode"}
|
|
245
|
-
|
|
246
|
-
|
|
297
|
+
aria-busy={s.busy === "askCode" || undefined}
|
|
298
|
+
onclick={() => void flow.forgot()}>{text.forgot}</button
|
|
299
|
+
>
|
|
247
300
|
{/if}
|
|
248
301
|
</form>
|
|
249
302
|
{/if}
|
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import type { Snippet } from "svelte";
|
|
2
|
-
import type { SignInHandlers, SignInLabelKeys, SignInText } from "@glimstone/core";
|
|
3
|
-
export type { ResetAnswer, SignInAnswer, SignInLabelKeys, SignInText } from "@glimstone/core";
|
|
2
|
+
import type { SignInCardService, SignInHandlers, SignInLabelKeys, SignInText } from "@glimstone/core";
|
|
3
|
+
export type { ResetAnswer, SignInAnswer, SignInCardService, SignInLabelKeys, SignInText } from "@glimstone/core";
|
|
4
4
|
export interface SignInCardProps extends SignInHandlers {
|
|
5
5
|
/** The app's logo, as an address or as an inline `<svg>` with a viewBox. It stands 7.5rem tall above the name, as wide as its shape asks. */
|
|
6
6
|
logo?: string | Snippet;
|
|
7
7
|
/** The page's heading. */
|
|
8
8
|
appName: string;
|
|
9
9
|
text: SignInText;
|
|
10
|
-
/**
|
|
10
|
+
/** Draws a passkey button, for a server without the browser's offer in the password field. `onPasskeyOffer` needs none. */
|
|
11
11
|
passkey?: boolean;
|
|
12
12
|
/** Offers Forgot password? and the reset form. */
|
|
13
13
|
reset?: boolean;
|
|
14
|
-
/**
|
|
14
|
+
/** Asks for the account's name in the reset form, in an app with several accounts (the kit's options say `owner: false`). */
|
|
15
|
+
resetName?: boolean;
|
|
16
|
+
/** The length, as the server says, under which the reset form suggests a longer password. It never refuses a shorter one. */
|
|
15
17
|
minPassword?: number;
|
|
16
18
|
/** One line at the top of the sign-in form, such as "You are signed out". */
|
|
17
19
|
note?: string;
|
|
20
|
+
/** A refusal from outside the card, such as a sign-in service that sent the person back, said above Sign in until the card's next try. */
|
|
21
|
+
error?: string;
|
|
22
|
+
/** The sign-in service whose button stands under Sign in, the one second way in the page offers. */
|
|
23
|
+
service?: SignInCardService;
|
|
24
|
+
/** Leaves for the sign-in service. */
|
|
25
|
+
onService?: () => void;
|
|
18
26
|
/** The app's own fields, above the password. */
|
|
19
27
|
fields?: Snippet;
|
|
20
28
|
/** The app's own buttons, under Sign in and the passkey. */
|
|
@@ -22,7 +30,7 @@ export interface SignInCardProps extends SignInHandlers {
|
|
|
22
30
|
/** A step the app runs itself, in place of the card's forms. */
|
|
23
31
|
step?: Snippet;
|
|
24
32
|
labelKeys?: Partial<SignInLabelKeys>;
|
|
25
|
-
/** The start of the fields' ids: `-password`, `-code`, `-reset-code`, `-new` and `-confirm` follow it. */
|
|
33
|
+
/** The start of the fields' ids: `-password`, `-code`, `-reset-code`, `-reset-name`, `-new` and `-confirm` follow it. */
|
|
26
34
|
idPrefix?: string;
|
|
27
35
|
/** Puts the focus in the first empty field when the card opens. */
|
|
28
36
|
autoFocus?: boolean;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { SignInApi, SignInReauthText } from "@glimstone/core";
|
|
3
|
+
|
|
4
|
+
export type { SignInReauthText } from "@glimstone/core";
|
|
5
|
+
|
|
6
|
+
export interface SignInReauthWindowProps {
|
|
7
|
+
api: SignInApi;
|
|
8
|
+
text: SignInReauthText;
|
|
9
|
+
}
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { shake, signInReauthError, type SignInReauthState } from "@glimstone/core";
|
|
14
|
+
import FieldRow from "./FieldRow.svelte";
|
|
15
|
+
import PasswordField from "./PasswordField.svelte";
|
|
16
|
+
import Window from "./Window.svelte";
|
|
17
|
+
|
|
18
|
+
// The password question before a change the kit wants fresh ("The sign-in
|
|
19
|
+
// tile" in the design language). Mounted once beside the tiles, it opens when
|
|
20
|
+
// a change answers signInAgain with askPassword, and the change runs again
|
|
21
|
+
// once the password is confirmed. While it is mounted the client asks.
|
|
22
|
+
let { api, text }: SignInReauthWindowProps = $props();
|
|
23
|
+
|
|
24
|
+
const r = $derived(api.reauth);
|
|
25
|
+
let s = $state.raw<SignInReauthState | null>(null);
|
|
26
|
+
$effect(() => {
|
|
27
|
+
const reauth = r;
|
|
28
|
+
s = reauth.state();
|
|
29
|
+
return reauth.subscribe(() => (s = reauth.state()));
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const refused = $derived(s?.refused ?? 0);
|
|
33
|
+
$effect(() => {
|
|
34
|
+
if (refused === 0) return;
|
|
35
|
+
const button = document.querySelector<HTMLElement>('[data-signin-reauth="confirm"]');
|
|
36
|
+
if (button) return shake(button);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
function enter(e: KeyboardEvent) {
|
|
40
|
+
if (e.key !== "Enter") return;
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
void r.submit();
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
{#if s?.asking}
|
|
47
|
+
<Window
|
|
48
|
+
data-glim="SignInReauthWindow"
|
|
49
|
+
title={text.title}
|
|
50
|
+
text={{ cancel: text.cancel, close: text.close }}
|
|
51
|
+
closeOnBackdrop={false}
|
|
52
|
+
onClose={r.cancel}
|
|
53
|
+
actions={[
|
|
54
|
+
{
|
|
55
|
+
label: text.confirm,
|
|
56
|
+
labelKey: "confirm",
|
|
57
|
+
primary: true,
|
|
58
|
+
busy: s.busy,
|
|
59
|
+
disabled: s.password === "",
|
|
60
|
+
attrs: { "data-signin-reauth": "confirm" },
|
|
61
|
+
onClick: () => {
|
|
62
|
+
void r.submit();
|
|
63
|
+
return false;
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
]}
|
|
67
|
+
>
|
|
68
|
+
<div class="glim-signin-tile-body">
|
|
69
|
+
<p class="glim-signin-tile-text">{text.text}</p>
|
|
70
|
+
<FieldRow label={text.password}>
|
|
71
|
+
<PasswordField
|
|
72
|
+
autocomplete="current-password"
|
|
73
|
+
value={s.password}
|
|
74
|
+
oninput={(e) => r.set(e.currentTarget.value)}
|
|
75
|
+
onkeydown={enter}
|
|
76
|
+
text={{ show: text.show, hide: text.hide }}
|
|
77
|
+
error={signInReauthError(text, s.error)}
|
|
78
|
+
/>
|
|
79
|
+
</FieldRow>
|
|
80
|
+
</div>
|
|
81
|
+
</Window>
|
|
82
|
+
{/if}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SignInApi, SignInReauthText } from "@glimstone/core";
|
|
2
|
+
export type { SignInReauthText } from "@glimstone/core";
|
|
3
|
+
export interface SignInReauthWindowProps {
|
|
4
|
+
api: SignInApi;
|
|
5
|
+
text: SignInReauthText;
|
|
6
|
+
}
|
|
7
|
+
declare const SignInReauthWindow: import("svelte").Component<SignInReauthWindowProps, {}, "">;
|
|
8
|
+
type SignInReauthWindow = ReturnType<typeof SignInReauthWindow>;
|
|
9
|
+
export default SignInReauthWindow;
|