orbital-ds 0.28.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +303 -273
- package/components.manifest.json +526 -12
- package/dist/hooks/use-ds-messages.d.ts +205 -0
- package/dist/lib/auth-better-auth.d.ts +29 -0
- package/dist/lib/auth-better-auth.js +60 -0
- package/dist/lib/auth-flow.d.ts +83 -0
- package/dist/lib/auth-flow.js +152 -0
- package/dist/lib/auth-providers.d.ts +194 -0
- package/dist/lib/auth-providers.js +64 -0
- package/dist/lib/auth.d.ts +68 -0
- package/dist/lib/auth.js +110 -0
- package/dist/lib/header-control.d.ts +4 -0
- package/dist/lib/header-control.js +14 -0
- package/dist/lib/i18n.d.ts +205 -0
- package/dist/lib/i18n.js +624 -3
- package/dist/ui/app-bar.d.ts +10 -0
- package/dist/ui/app-bar.js +51 -0
- package/dist/ui/attachment.js +1 -1
- package/dist/ui/auth-backdrop.d.ts +20 -0
- package/dist/ui/auth-backdrop.js +137 -0
- package/dist/ui/auth-form.d.ts +111 -0
- package/dist/ui/auth-form.js +531 -0
- package/dist/ui/auth-layout.d.ts +70 -0
- package/dist/ui/auth-layout.js +283 -0
- package/dist/ui/auth-parts.d.ts +43 -0
- package/dist/ui/auth-parts.js +159 -0
- package/dist/ui/auth-status.d.ts +23 -0
- package/dist/ui/auth-status.js +99 -0
- package/dist/ui/badge.js +2 -2
- package/dist/ui/button.js +1 -1
- package/dist/ui/connected-accounts.d.ts +25 -0
- package/dist/ui/connected-accounts.js +89 -0
- package/dist/ui/content-card.d.ts +6 -2
- package/dist/ui/content-card.js +27 -3
- package/dist/ui/dropzone.js +1 -1
- package/dist/ui/empty-state.d.ts +10 -1
- package/dist/ui/empty-state.js +28 -7
- package/dist/ui/error-page.d.ts +10 -1
- package/dist/ui/error-page.js +74 -28
- package/dist/ui/icon-tile.d.ts +1 -1
- package/dist/ui/input-otp.js +2 -1
- package/dist/ui/item.js +1 -1
- package/dist/ui/legend.js +1 -1
- package/dist/ui/locale-switcher.d.ts +19 -0
- package/dist/ui/locale-switcher.js +54 -0
- package/dist/ui/menubar.js +1 -1
- package/dist/ui/message-scroller.js +1 -1
- package/dist/ui/mfa-challenge.d.ts +33 -0
- package/dist/ui/mfa-challenge.js +214 -0
- package/dist/ui/mfa-setup.d.ts +29 -0
- package/dist/ui/mfa-setup.js +196 -0
- package/dist/ui/navigation-menu.js +2 -2
- package/dist/ui/notice-review.d.ts +1 -0
- package/dist/ui/notifications.d.ts +12 -2
- package/dist/ui/notifications.js +28 -5
- package/dist/ui/oauth-consent.d.ts +54 -0
- package/dist/ui/oauth-consent.js +208 -0
- package/dist/ui/passkey-list.d.ts +17 -0
- package/dist/ui/passkey-list.js +112 -0
- package/dist/ui/password-input.d.ts +5 -0
- package/dist/ui/password-input.js +77 -0
- package/dist/ui/session-list.d.ts +19 -0
- package/dist/ui/session-list.js +70 -0
- package/dist/ui/session-timeout.d.ts +13 -0
- package/dist/ui/session-timeout.js +87 -0
- package/dist/ui/sidebar.d.ts +27 -5
- package/dist/ui/sidebar.js +56 -11
- package/dist/ui/sign-out-dialog.d.ts +17 -0
- package/dist/ui/sign-out-dialog.js +82 -0
- package/dist/ui/stat-group.d.ts +1 -1
- package/dist/ui/stat-group.js +6 -2
- package/dist/ui/stat.d.ts +24 -5
- package/dist/ui/stat.js +124 -19
- package/dist/ui/status-badge.d.ts +1 -1
- package/dist/ui/theme-toggle.d.ts +14 -0
- package/dist/ui/theme-toggle.js +112 -0
- package/dist/ui/toggle.js +2 -2
- package/dist/ui/week-strip.js +1 -1
- package/docs/CONTRACT.md +1 -1
- package/docs/designer/patrones.md +27 -0
- package/docs/designer/revision.md +8 -0
- package/package.json +3 -2
- package/scripts/brand-core.d.mts +2 -0
- package/scripts/brand-core.mjs +21 -1
- package/scripts/cli.mjs +452 -452
- package/scripts/doctor.mjs +3 -0
- package/scripts/init.mjs +7 -3
- package/dist/motion.css +0 -146
- package/dist/styles.css +0 -1240
- package/dist/themes/fractalia.css +0 -549
- package/dist/themes/fractalia.fonts.css +0 -3
- package/dist/themes/fractalia.guide.md +0 -86
- package/dist/themes/fractalia.meta.json +0 -112
- package/dist/themes/fractalia.scoped.css +0 -549
- package/dist/themes/fractalia.tokens.json +0 -39
- package/dist/themes/friendly.css +0 -367
- package/dist/themes/friendly.fonts.css +0 -2
- package/dist/themes/friendly.guide.md +0 -38
- package/dist/themes/friendly.meta.json +0 -82
- package/dist/themes/friendly.scoped.css +0 -367
- package/dist/themes/friendly.tokens.json +0 -45
- package/dist/themes/lagoon.css +0 -348
- package/dist/themes/lagoon.fonts.css +0 -2
- package/dist/themes/lagoon.guide.md +0 -47
- package/dist/themes/lagoon.meta.json +0 -84
- package/dist/themes/lagoon.scoped.css +0 -348
- package/dist/themes/lagoon.tokens.json +0 -49
- package/dist/themes/liquid.css +0 -502
- package/dist/themes/liquid.fonts.css +0 -7
- package/dist/themes/liquid.guide.md +0 -82
- package/dist/themes/liquid.meta.json +0 -134
- package/dist/themes/liquid.scoped.css +0 -502
- package/dist/themes/liquid.tokens.json +0 -47
- package/dist/themes/qratia.css +0 -260
- package/dist/themes/qratia.fonts.css +0 -2
- package/dist/themes/qratia.guide.md +0 -34
- package/dist/themes/qratia.meta.json +0 -49
- package/dist/themes/qratia.scoped.css +0 -260
- package/dist/themes/qratia.tokens.json +0 -49
- package/dist/themes/tactile.css +0 -588
- package/dist/themes/tactile.fonts.css +0 -3
- package/dist/themes/tactile.guide.md +0 -82
- package/dist/themes/tactile.meta.json +0 -182
- package/dist/themes/tactile.scoped.css +0 -588
- package/dist/themes/tactile.tokens.json +0 -42
- package/dist/themes/twitter.css +0 -357
- package/dist/themes/twitter.fonts.css +0 -6
- package/dist/themes/twitter.guide.md +0 -35
- package/dist/themes/twitter.meta.json +0 -90
- package/dist/themes/twitter.scoped.css +0 -357
- package/dist/themes/twitter.tokens.json +0 -45
- package/dist/themes/zyro.css +0 -434
- package/dist/themes/zyro.fonts.css +0 -2
- package/dist/themes/zyro.guide.md +0 -33
- package/dist/themes/zyro.meta.json +0 -74
- package/dist/themes/zyro.scoped.css +0 -434
- package/dist/themes/zyro.tokens.json +0 -46
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { BotIcon, CheckIcon, ExternalLinkIcon, MonitorSmartphoneIcon, ShieldAlertIcon, ShieldCheckIcon } from "lucide-react";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { useDsMessages } from "../hooks/use-ds-messages.js";
|
|
6
|
+
import { dsFormat } from "../lib/i18n.js";
|
|
7
|
+
import { cn } from "../lib/utils.js";
|
|
8
|
+
import { AuthError, AuthHeader, AuthStagger } from "./auth-parts.js";
|
|
9
|
+
import { Avatar, AvatarFallback, AvatarImage } from "./avatar.js";
|
|
10
|
+
import { Button } from "./button.js";
|
|
11
|
+
import { Checkbox } from "./checkbox.js";
|
|
12
|
+
import { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot } from "./input-otp.js";
|
|
13
|
+
import { Label } from "./label.js";
|
|
14
|
+
import { Spinner } from "./spinner.js";
|
|
15
|
+
function Mark({ party, fallback }) {
|
|
16
|
+
return /* @__PURE__ */ jsx("div", { className: "flex size-(--ds-oauth-mark) items-center justify-center overflow-hidden rounded-(--ds-auth-radius) border border-(--ds-auth-border) bg-(--ds-auth-surface) shadow-card [&_img]:size-full [&_img]:object-contain [&_svg]:size-1/2", children: party?.logo ?? fallback });
|
|
17
|
+
}
|
|
18
|
+
const NARROW_GROUP = "@max-[22rem]/oauth:min-w-0 @max-[22rem]/oauth:flex-1";
|
|
19
|
+
const NARROW_SLOT = "@max-[22rem]/oauth:w-auto @max-[22rem]/oauth:min-w-0 @max-[22rem]/oauth:flex-1";
|
|
20
|
+
function OAuthConsent({
|
|
21
|
+
preset = "authorize",
|
|
22
|
+
client,
|
|
23
|
+
app,
|
|
24
|
+
account,
|
|
25
|
+
onSwitchAccount,
|
|
26
|
+
scopes = [],
|
|
27
|
+
selectable = false,
|
|
28
|
+
redirectUri,
|
|
29
|
+
userCode,
|
|
30
|
+
codeLength = 8,
|
|
31
|
+
onSubmitCode,
|
|
32
|
+
onAllow,
|
|
33
|
+
onDeny,
|
|
34
|
+
error: errorProp,
|
|
35
|
+
title,
|
|
36
|
+
description,
|
|
37
|
+
className,
|
|
38
|
+
...props
|
|
39
|
+
}) {
|
|
40
|
+
const t = useDsMessages();
|
|
41
|
+
const uid = React.useId();
|
|
42
|
+
const [step, setStep] = React.useState(preset === "device" ? "code" : "consent");
|
|
43
|
+
const [code, setCode] = React.useState(() => (userCode ?? "").replace(/[^A-Za-z0-9]/g, "").toUpperCase().slice(0, codeLength));
|
|
44
|
+
const [granted, setGranted] = React.useState(() => new Set(scopes.map((s) => s.id)));
|
|
45
|
+
const [pending, setPending] = React.useState(null);
|
|
46
|
+
const [error, setError] = React.useState(null);
|
|
47
|
+
const unverified = client.verified === false;
|
|
48
|
+
const domain = React.useMemo(() => {
|
|
49
|
+
if (!redirectUri) return null;
|
|
50
|
+
try {
|
|
51
|
+
return new URL(redirectUri).host;
|
|
52
|
+
} catch {
|
|
53
|
+
return redirectUri;
|
|
54
|
+
}
|
|
55
|
+
}, [redirectUri]);
|
|
56
|
+
async function run(kind, task) {
|
|
57
|
+
setPending(kind);
|
|
58
|
+
setError(null);
|
|
59
|
+
try {
|
|
60
|
+
const result = await task();
|
|
61
|
+
if (result && result.error) {
|
|
62
|
+
setError(result.error);
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
} catch {
|
|
67
|
+
setError("network");
|
|
68
|
+
return false;
|
|
69
|
+
} finally {
|
|
70
|
+
setPending(null);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const half = Math.ceil(codeLength / 2);
|
|
74
|
+
if (step === "code") {
|
|
75
|
+
const submit = (value) => {
|
|
76
|
+
if (pending) return;
|
|
77
|
+
if (!onSubmitCode) return setStep("consent");
|
|
78
|
+
void run("code", () => onSubmitCode(value)).then((ok) => ok && setStep("consent"));
|
|
79
|
+
};
|
|
80
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "oauth-consent", "data-preset": preset, "data-step": "code", className: cn("@container/oauth flex min-w-0 flex-col gap-(--ds-auth-gap) [overflow-wrap:anywhere]", className), ...props, children: [
|
|
81
|
+
/* @__PURE__ */ jsx(AuthHeader, { align: "center", icon: /* @__PURE__ */ jsx(Mark, { party: client, fallback: /* @__PURE__ */ jsx(MonitorSmartphoneIcon, {}) }), title: title ?? t.authOauthDeviceTitle, description: description ?? (userCode ? t.authOauthDeviceConfirm : t.authOauthDeviceBody) }),
|
|
82
|
+
/* @__PURE__ */ jsx(AuthError, { error: errorProp ?? error }),
|
|
83
|
+
/* @__PURE__ */ jsx(AuthStagger, { index: 1, children: /* @__PURE__ */ jsxs(
|
|
84
|
+
"form",
|
|
85
|
+
{
|
|
86
|
+
noValidate: true,
|
|
87
|
+
className: "flex flex-col items-center gap-4",
|
|
88
|
+
onSubmit: (e) => {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
submit(code);
|
|
91
|
+
},
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${uid}-code`, className: "sr-only", children: t.authOauthDeviceCode }),
|
|
94
|
+
/* @__PURE__ */ jsxs(
|
|
95
|
+
InputOTP,
|
|
96
|
+
{
|
|
97
|
+
id: `${uid}-code`,
|
|
98
|
+
maxLength: codeLength,
|
|
99
|
+
value: code,
|
|
100
|
+
onChange: (v) => setCode(v.toUpperCase()),
|
|
101
|
+
onComplete: submit,
|
|
102
|
+
pattern: "^[A-Za-z0-9]*$",
|
|
103
|
+
autoComplete: "off",
|
|
104
|
+
autoFocus: true,
|
|
105
|
+
disabled: pending != null,
|
|
106
|
+
containerClassName: "w-full justify-center",
|
|
107
|
+
children: [
|
|
108
|
+
/* @__PURE__ */ jsx(InputOTPGroup, { className: NARROW_GROUP, children: Array.from({ length: half }, (_, i) => /* @__PURE__ */ jsx(InputOTPSlot, { index: i, className: NARROW_SLOT }, i)) }),
|
|
109
|
+
/* @__PURE__ */ jsx(InputOTPSeparator, {}),
|
|
110
|
+
/* @__PURE__ */ jsx(InputOTPGroup, { className: NARROW_GROUP, children: Array.from({ length: codeLength - half }, (_, i) => /* @__PURE__ */ jsx(InputOTPSlot, { index: half + i, className: NARROW_SLOT }, i)) })
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
/* @__PURE__ */ jsxs(Button, { type: "submit", className: "w-full", disabled: pending != null || code.length < codeLength, children: [
|
|
115
|
+
pending === "code" ? /* @__PURE__ */ jsx(Spinner, {}) : null,
|
|
116
|
+
t.authContinue
|
|
117
|
+
] })
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
) })
|
|
121
|
+
] });
|
|
122
|
+
}
|
|
123
|
+
const isMcp = preset === "mcp";
|
|
124
|
+
const defTitle = dsFormat(isMcp ? t.authOauthMcpTitle : t.authOauthTitle, { client: client.name });
|
|
125
|
+
const defBody = isMcp ? dsFormat(t.authOauthMcpBody, { client: client.name }) : dsFormat(t.authOauthBody, { client: client.name });
|
|
126
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "oauth-consent", "data-preset": preset, "data-step": "consent", "data-verified": client.verified ?? void 0, className: cn("@container/oauth flex min-w-0 flex-col gap-(--ds-auth-gap) [overflow-wrap:anywhere]", className), ...props, children: [
|
|
127
|
+
/* @__PURE__ */ jsxs(AuthStagger, { index: 0, "data-slot": "oauth-consent-link", className: "flex items-center justify-center gap-3", children: [
|
|
128
|
+
/* @__PURE__ */ jsx(Mark, { party: client, fallback: isMcp ? /* @__PURE__ */ jsx(BotIcon, {}) : /* @__PURE__ */ jsx(MonitorSmartphoneIcon, {}) }),
|
|
129
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "ds-auth-fx-link h-(--ds-oauth-link-h) w-(--ds-oauth-link-w)" }),
|
|
130
|
+
/* @__PURE__ */ jsx(Mark, { party: app, fallback: /* @__PURE__ */ jsx(ShieldCheckIcon, {}) })
|
|
131
|
+
] }),
|
|
132
|
+
/* @__PURE__ */ jsx(AuthHeader, { align: "center", title: title ?? defTitle, description: description ?? defBody }),
|
|
133
|
+
client.verified ? /* @__PURE__ */ jsxs(AuthStagger, { index: 1, className: "-mt-3 flex items-center justify-center gap-1.5 text-xs text-muted-foreground", children: [
|
|
134
|
+
/* @__PURE__ */ jsx(ShieldCheckIcon, { "aria-hidden": "true", className: "size-3.5 text-success" }),
|
|
135
|
+
t.authOauthVerified
|
|
136
|
+
] }) : null,
|
|
137
|
+
account ? /* @__PURE__ */ jsxs(AuthStagger, { index: 1, className: "flex items-center gap-3 rounded-(--ds-auth-radius) border border-(--ds-auth-border) px-3 py-2", children: [
|
|
138
|
+
/* @__PURE__ */ jsxs(Avatar, { className: "size-8", children: [
|
|
139
|
+
account.avatar ? /* @__PURE__ */ jsx(AvatarImage, { src: account.avatar, alt: "" }) : null,
|
|
140
|
+
/* @__PURE__ */ jsx(AvatarFallback, { children: (account.name ?? account.email).slice(0, 1).toUpperCase() })
|
|
141
|
+
] }),
|
|
142
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 text-sm", children: [
|
|
143
|
+
account.name ? /* @__PURE__ */ jsx("p", { className: "truncate font-medium", children: account.name }) : null,
|
|
144
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-muted-foreground", children: account.email })
|
|
145
|
+
] }),
|
|
146
|
+
onSwitchAccount ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: onSwitchAccount, children: t.authOauthSwitchAccount }) : null
|
|
147
|
+
] }) : null,
|
|
148
|
+
unverified ? /* @__PURE__ */ jsxs(AuthStagger, { index: 2, role: "note", className: "flex items-start gap-2 rounded-(--ds-radius-alert) bg-warning-soft px-3 py-2.5 text-sm text-[color:var(--ds-on-soft,var(--warning))] [&_svg]:mt-0.5 [&_svg]:size-4 [&_svg]:shrink-0", children: [
|
|
149
|
+
/* @__PURE__ */ jsx(ShieldAlertIcon, { "aria-hidden": "true" }),
|
|
150
|
+
/* @__PURE__ */ jsx("span", { children: t.authOauthUnverified })
|
|
151
|
+
] }) : null,
|
|
152
|
+
/* @__PURE__ */ jsx(AuthError, { error: errorProp ?? error }),
|
|
153
|
+
scopes.length ? /* @__PURE__ */ jsxs(AuthStagger, { index: 2, className: "flex flex-col gap-2", children: [
|
|
154
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: dsFormat(t.authOauthPermissions, { client: client.name }) }),
|
|
155
|
+
/* @__PURE__ */ jsx("ul", { "data-slot": "oauth-consent-scopes", className: "flex flex-col divide-y divide-(--ds-auth-border) rounded-(--ds-auth-radius) border border-(--ds-auth-border)", children: scopes.map((s) => {
|
|
156
|
+
const optional = selectable && !s.required;
|
|
157
|
+
const on = granted.has(s.id);
|
|
158
|
+
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
159
|
+
/* @__PURE__ */ jsx("span", { className: "flex size-7 shrink-0 items-center justify-center rounded-control bg-muted text-muted-foreground [&_svg]:size-4", children: s.icon ?? /* @__PURE__ */ jsx(CheckIcon, {}) }),
|
|
160
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
|
|
161
|
+
/* @__PURE__ */ jsxs("span", { className: "flex flex-wrap items-center gap-2 text-sm font-medium", children: [
|
|
162
|
+
s.label,
|
|
163
|
+
s.sensitive ? /* @__PURE__ */ jsx("span", { className: "rounded-full bg-warning-soft px-1.5 text-xs leading-5 text-[color:var(--ds-on-soft,var(--warning))]", children: t.authOauthSensitive }) : null
|
|
164
|
+
] }),
|
|
165
|
+
s.description ? /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: s.description }) : null
|
|
166
|
+
] })
|
|
167
|
+
] });
|
|
168
|
+
return /* @__PURE__ */ jsx("li", { "data-slot": "oauth-consent-scope", "data-scope": s.id, "data-sensitive": s.sensitive || void 0, className: "flex items-start gap-3 p-3", children: optional ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
169
|
+
/* @__PURE__ */ jsx(
|
|
170
|
+
Checkbox,
|
|
171
|
+
{
|
|
172
|
+
id: `${uid}-${s.id}`,
|
|
173
|
+
checked: on,
|
|
174
|
+
onCheckedChange: (v) => setGranted((prev) => {
|
|
175
|
+
const next = new Set(prev);
|
|
176
|
+
if (v === true) next.add(s.id);
|
|
177
|
+
else next.delete(s.id);
|
|
178
|
+
return next;
|
|
179
|
+
}),
|
|
180
|
+
className: "mt-1.5"
|
|
181
|
+
}
|
|
182
|
+
),
|
|
183
|
+
/* @__PURE__ */ jsx("label", { htmlFor: `${uid}-${s.id}`, className: "flex min-w-0 flex-1 cursor-pointer items-start gap-3", children: body })
|
|
184
|
+
] }) : body }, s.id);
|
|
185
|
+
}) })
|
|
186
|
+
] }) : null,
|
|
187
|
+
/* @__PURE__ */ jsxs(AuthStagger, { index: 3, className: "grid gap-2 @[20rem]/oauth:grid-cols-2", children: [
|
|
188
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", disabled: pending != null, onClick: () => void run("deny", onDeny), children: [
|
|
189
|
+
pending === "deny" ? /* @__PURE__ */ jsx(Spinner, {}) : null,
|
|
190
|
+
t.authOauthDeny
|
|
191
|
+
] }),
|
|
192
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", disabled: pending != null, onClick: () => void run("allow", () => onAllow([...granted])), children: [
|
|
193
|
+
pending === "allow" ? /* @__PURE__ */ jsx(Spinner, {}) : null,
|
|
194
|
+
t.authOauthAllow
|
|
195
|
+
] })
|
|
196
|
+
] }),
|
|
197
|
+
/* @__PURE__ */ jsxs(AuthStagger, { index: 4, className: "flex flex-col items-center gap-1 text-center text-xs text-muted-foreground", children: [
|
|
198
|
+
domain ? /* @__PURE__ */ jsxs("p", { className: "flex max-w-full items-center gap-1", children: [
|
|
199
|
+
/* @__PURE__ */ jsx(ExternalLinkIcon, { "aria-hidden": "true", className: "size-3 shrink-0" }),
|
|
200
|
+
dsFormat(t.authOauthRedirect, { domain })
|
|
201
|
+
] }) : null,
|
|
202
|
+
/* @__PURE__ */ jsx("p", { children: t.authOauthRevokeNote })
|
|
203
|
+
] })
|
|
204
|
+
] });
|
|
205
|
+
}
|
|
206
|
+
export {
|
|
207
|
+
OAuthConsent
|
|
208
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type PasskeyInfo = {
|
|
4
|
+
id: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
createdAt?: string | number | Date;
|
|
7
|
+
lastUsed?: string | number | Date;
|
|
8
|
+
synced?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare function PasskeyList({ passkeys, onAdd, onRename, onDelete, className, ...props }: React.ComponentProps<"div"> & {
|
|
11
|
+
passkeys: PasskeyInfo[];
|
|
12
|
+
onAdd?: () => void | Promise<void>;
|
|
13
|
+
onRename?: (id: string, name: string) => void | Promise<void>;
|
|
14
|
+
onDelete?: (id: string) => void | Promise<void>;
|
|
15
|
+
}): React.JSX.Element;
|
|
16
|
+
|
|
17
|
+
export { type PasskeyInfo, PasskeyList };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { CheckIcon, CloudIcon, KeyRoundIcon, PencilIcon, PlusIcon, Trash2Icon, XIcon } from "lucide-react";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { useDsLocale, useDsMessages } from "../hooks/use-ds-messages.js";
|
|
6
|
+
import { formatAuthDate } from "../lib/auth.js";
|
|
7
|
+
import { dsFormat } from "../lib/i18n.js";
|
|
8
|
+
import { cn } from "../lib/utils.js";
|
|
9
|
+
import { Badge } from "./badge.js";
|
|
10
|
+
import { Button } from "./button.js";
|
|
11
|
+
import { IconTile } from "./icon-tile.js";
|
|
12
|
+
import { Input } from "./input.js";
|
|
13
|
+
import { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemMedia, ItemTitle } from "./item.js";
|
|
14
|
+
import { Spinner } from "./spinner.js";
|
|
15
|
+
function PasskeyList({
|
|
16
|
+
passkeys,
|
|
17
|
+
onAdd,
|
|
18
|
+
onRename,
|
|
19
|
+
onDelete,
|
|
20
|
+
className,
|
|
21
|
+
...props
|
|
22
|
+
}) {
|
|
23
|
+
const t = useDsMessages();
|
|
24
|
+
const locale = useDsLocale();
|
|
25
|
+
const uid = React.useId();
|
|
26
|
+
const [busy, setBusy] = React.useState(null);
|
|
27
|
+
const [editing, setEditing] = React.useState(null);
|
|
28
|
+
const [draft, setDraft] = React.useState("");
|
|
29
|
+
async function act(id, task) {
|
|
30
|
+
setBusy(id);
|
|
31
|
+
try {
|
|
32
|
+
await task();
|
|
33
|
+
} finally {
|
|
34
|
+
setBusy(null);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const add = onAdd ? /* @__PURE__ */ jsxs(Button, { type: "button", variant: passkeys.length ? "outline" : "default", className: "self-start", disabled: busy != null, onClick: () => void act("+", onAdd), children: [
|
|
38
|
+
busy === "+" ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsx(PlusIcon, {}),
|
|
39
|
+
t.authPasskeysAdd
|
|
40
|
+
] }) : null;
|
|
41
|
+
if (!passkeys.length) {
|
|
42
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "passkey-list", className: cn("flex flex-col gap-3", className), ...props, children: /* @__PURE__ */ jsxs("div", { "data-slot": "passkey-list-empty", className: "flex flex-col items-start gap-3 rounded-(--ds-auth-radius) border border-dashed border-(--ds-auth-border) p-(--ds-auth-p-sm)", children: [
|
|
43
|
+
/* @__PURE__ */ jsx(IconTile, { tone: "primary", children: /* @__PURE__ */ jsx(KeyRoundIcon, {}) }),
|
|
44
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
45
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: t.authPasskeysEmptyTitle }),
|
|
46
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t.authPasskeysEmptyBody })
|
|
47
|
+
] }),
|
|
48
|
+
add
|
|
49
|
+
] }) });
|
|
50
|
+
}
|
|
51
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "passkey-list", className: cn("flex flex-col gap-3", className), ...props, children: [
|
|
52
|
+
/* @__PURE__ */ jsx(ItemGroup, { className: "gap-2", children: passkeys.map((p) => {
|
|
53
|
+
const meta = [
|
|
54
|
+
p.createdAt != null ? dsFormat(t.authPasskeysCreated, { date: formatAuthDate(p.createdAt, locale) }) : null,
|
|
55
|
+
p.lastUsed != null ? dsFormat(t.authPasskeysLastUsed, { date: formatAuthDate(p.lastUsed, locale) }) : null
|
|
56
|
+
].filter(Boolean);
|
|
57
|
+
const isEditing = editing === p.id;
|
|
58
|
+
return /* @__PURE__ */ jsxs(Item, { variant: "card", size: "sm", "data-slot": "passkey-list-item", children: [
|
|
59
|
+
/* @__PURE__ */ jsx(ItemMedia, { variant: "image", className: "bg-muted text-muted-foreground [&_svg]:size-5", children: /* @__PURE__ */ jsx(KeyRoundIcon, {}) }),
|
|
60
|
+
/* @__PURE__ */ jsxs(ItemContent, { children: [
|
|
61
|
+
isEditing ? /* @__PURE__ */ jsxs(
|
|
62
|
+
"form",
|
|
63
|
+
{
|
|
64
|
+
className: "flex items-center gap-2",
|
|
65
|
+
onSubmit: (e) => {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
const name = draft.trim();
|
|
68
|
+
if (!name || !onRename) return;
|
|
69
|
+
void act(p.id, () => onRename(p.id, name)).then(() => setEditing(null));
|
|
70
|
+
},
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsx("label", { htmlFor: `${uid}-${p.id}`, className: "sr-only", children: t.authPasskeysName }),
|
|
73
|
+
/* @__PURE__ */ jsx(Input, { id: `${uid}-${p.id}`, autoFocus: true, value: draft, onChange: (e) => setDraft(e.target.value), className: "h-8" }),
|
|
74
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", size: "icon-sm", "aria-label": t.authPasskeysSave, disabled: busy != null, children: busy === p.id ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsx(CheckIcon, {}) }),
|
|
75
|
+
/* @__PURE__ */ jsx(Button, { type: "button", size: "icon-sm", variant: "ghost", "aria-label": t.authCancel, onClick: () => setEditing(null), children: /* @__PURE__ */ jsx(XIcon, {}) })
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
) : /* @__PURE__ */ jsxs(ItemTitle, { children: [
|
|
79
|
+
p.name || t.authMfaMethodPasskey,
|
|
80
|
+
p.synced ? /* @__PURE__ */ jsxs(Badge, { variant: "neutral", children: [
|
|
81
|
+
/* @__PURE__ */ jsx(CloudIcon, {}),
|
|
82
|
+
t.authPasskeysSynced
|
|
83
|
+
] }) : null
|
|
84
|
+
] }),
|
|
85
|
+
meta.length ? /* @__PURE__ */ jsx(ItemDescription, { children: meta.join(" \xB7 ") }) : null
|
|
86
|
+
] }),
|
|
87
|
+
isEditing ? null : /* @__PURE__ */ jsxs(ItemActions, { children: [
|
|
88
|
+
onRename ? /* @__PURE__ */ jsx(
|
|
89
|
+
Button,
|
|
90
|
+
{
|
|
91
|
+
type: "button",
|
|
92
|
+
size: "icon-sm",
|
|
93
|
+
variant: "ghost",
|
|
94
|
+
"aria-label": t.authPasskeysRename,
|
|
95
|
+
title: t.authPasskeysRename,
|
|
96
|
+
onClick: () => {
|
|
97
|
+
setDraft(p.name ?? "");
|
|
98
|
+
setEditing(p.id);
|
|
99
|
+
},
|
|
100
|
+
children: /* @__PURE__ */ jsx(PencilIcon, {})
|
|
101
|
+
}
|
|
102
|
+
) : null,
|
|
103
|
+
onDelete ? /* @__PURE__ */ jsx(Button, { type: "button", size: "icon-sm", variant: "ghost", "aria-label": t.authPasskeysDelete, title: t.authPasskeysDelete, disabled: busy != null, onClick: () => void act(p.id, () => onDelete(p.id)), children: busy === p.id ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsx(Trash2Icon, {}) }) : null
|
|
104
|
+
] })
|
|
105
|
+
] }, p.id);
|
|
106
|
+
}) }),
|
|
107
|
+
add
|
|
108
|
+
] });
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
PasskeyList
|
|
112
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { EyeIcon, EyeOffIcon } from "lucide-react";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { useDsMessages } from "../hooks/use-ds-messages.js";
|
|
6
|
+
import { cn } from "../lib/utils.js";
|
|
7
|
+
import { Input } from "./input.js";
|
|
8
|
+
function PasswordInput({
|
|
9
|
+
className,
|
|
10
|
+
onKeyUp,
|
|
11
|
+
onKeyDown,
|
|
12
|
+
onBlur,
|
|
13
|
+
disabled,
|
|
14
|
+
...props
|
|
15
|
+
}) {
|
|
16
|
+
const t = useDsMessages();
|
|
17
|
+
const [visible, setVisible] = React.useState(false);
|
|
18
|
+
const [caps, setCaps] = React.useState(false);
|
|
19
|
+
const capsId = React.useId();
|
|
20
|
+
const readCaps = (event) => {
|
|
21
|
+
if (typeof event.getModifierState === "function") setCaps(event.getModifierState("CapsLock"));
|
|
22
|
+
};
|
|
23
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "password-input", "data-visible": visible || void 0, className: cn("flex flex-col gap-1.5", className), children: [
|
|
24
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
25
|
+
/* @__PURE__ */ jsx(
|
|
26
|
+
Input,
|
|
27
|
+
{
|
|
28
|
+
type: visible ? "text" : "password",
|
|
29
|
+
spellCheck: false,
|
|
30
|
+
autoCapitalize: "none",
|
|
31
|
+
disabled,
|
|
32
|
+
className: "pe-(--ds-control-h-md)",
|
|
33
|
+
onKeyUp: (event) => {
|
|
34
|
+
readCaps(event);
|
|
35
|
+
onKeyUp?.(event);
|
|
36
|
+
},
|
|
37
|
+
onKeyDown: (event) => {
|
|
38
|
+
readCaps(event);
|
|
39
|
+
onKeyDown?.(event);
|
|
40
|
+
},
|
|
41
|
+
onBlur: (event) => {
|
|
42
|
+
setCaps(false);
|
|
43
|
+
onBlur?.(event);
|
|
44
|
+
},
|
|
45
|
+
...props,
|
|
46
|
+
"aria-describedby": [props["aria-describedby"], caps ? capsId : null].filter(Boolean).join(" ") || void 0
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
/* @__PURE__ */ jsx(
|
|
50
|
+
"button",
|
|
51
|
+
{
|
|
52
|
+
type: "button",
|
|
53
|
+
"data-slot": "password-input-toggle",
|
|
54
|
+
"aria-label": visible ? t.authHidePassword : t.authShowPassword,
|
|
55
|
+
"aria-pressed": visible,
|
|
56
|
+
disabled,
|
|
57
|
+
onClick: () => setVisible((v) => !v),
|
|
58
|
+
className: "absolute inset-y-0 end-0 grid w-(--ds-control-h-md) place-items-center rounded-control text-muted-foreground outline-none transition-colors duration-(--ds-motion-snap) hover:text-foreground focus-visible:ring-(length:--ds-ring-width) focus-visible:ring-(--ds-ring-color) disabled:pointer-events-none [&_svg]:size-4",
|
|
59
|
+
children: visible ? /* @__PURE__ */ jsx(EyeOffIcon, {}) : /* @__PURE__ */ jsx(EyeIcon, {})
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
] }),
|
|
63
|
+
/* @__PURE__ */ jsx(
|
|
64
|
+
"p",
|
|
65
|
+
{
|
|
66
|
+
id: capsId,
|
|
67
|
+
"data-slot": "password-input-caps",
|
|
68
|
+
"aria-live": "polite",
|
|
69
|
+
className: cn("text-xs text-[color:var(--ds-on-soft,var(--warning))]", !caps && "sr-only"),
|
|
70
|
+
children: caps ? t.authCapsLock : ""
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
] });
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
PasswordInput
|
|
77
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type SessionDeviceKind = "desktop" | "laptop" | "mobile" | "tablet";
|
|
4
|
+
type SessionInfo = {
|
|
5
|
+
id: string;
|
|
6
|
+
device?: React.ReactNode;
|
|
7
|
+
kind?: SessionDeviceKind;
|
|
8
|
+
location?: React.ReactNode;
|
|
9
|
+
ip?: string;
|
|
10
|
+
lastActive?: string | number | Date;
|
|
11
|
+
current?: boolean;
|
|
12
|
+
};
|
|
13
|
+
declare function SessionList({ sessions, onRevoke, onRevokeOthers, className, ...props }: React.ComponentProps<"div"> & {
|
|
14
|
+
sessions: SessionInfo[];
|
|
15
|
+
onRevoke?: (id: string) => void | Promise<void>;
|
|
16
|
+
onRevokeOthers?: () => void | Promise<void>;
|
|
17
|
+
}): React.JSX.Element;
|
|
18
|
+
|
|
19
|
+
export { type SessionDeviceKind, type SessionInfo, SessionList };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { LaptopIcon, MonitorIcon, SmartphoneIcon, TabletIcon } from "lucide-react";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { useDsLocale, useDsMessages } from "../hooks/use-ds-messages.js";
|
|
6
|
+
import { formatAuthDate } from "../lib/auth.js";
|
|
7
|
+
import { dsFormat } from "../lib/i18n.js";
|
|
8
|
+
import { cn } from "../lib/utils.js";
|
|
9
|
+
import { Badge } from "./badge.js";
|
|
10
|
+
import { Button } from "./button.js";
|
|
11
|
+
import { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemMedia, ItemTitle } from "./item.js";
|
|
12
|
+
import { Spinner } from "./spinner.js";
|
|
13
|
+
const KIND = {
|
|
14
|
+
desktop: /* @__PURE__ */ jsx(MonitorIcon, {}),
|
|
15
|
+
laptop: /* @__PURE__ */ jsx(LaptopIcon, {}),
|
|
16
|
+
mobile: /* @__PURE__ */ jsx(SmartphoneIcon, {}),
|
|
17
|
+
tablet: /* @__PURE__ */ jsx(TabletIcon, {})
|
|
18
|
+
};
|
|
19
|
+
function SessionList({
|
|
20
|
+
sessions,
|
|
21
|
+
onRevoke,
|
|
22
|
+
onRevokeOthers,
|
|
23
|
+
className,
|
|
24
|
+
...props
|
|
25
|
+
}) {
|
|
26
|
+
const t = useDsMessages();
|
|
27
|
+
const locale = useDsLocale();
|
|
28
|
+
const [busy, setBusy] = React.useState(null);
|
|
29
|
+
const sorted = [...sessions].sort((a, b) => Number(!!b.current) - Number(!!a.current));
|
|
30
|
+
const others = sessions.filter((s) => !s.current).length;
|
|
31
|
+
async function act(id, task) {
|
|
32
|
+
if (!task) return;
|
|
33
|
+
setBusy(id);
|
|
34
|
+
try {
|
|
35
|
+
await task();
|
|
36
|
+
} finally {
|
|
37
|
+
setBusy(null);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "session-list", className: cn("flex flex-col gap-3", className), ...props, children: [
|
|
41
|
+
/* @__PURE__ */ jsx(ItemGroup, { className: "gap-2", children: sorted.map((s) => {
|
|
42
|
+
const when = s.current ? t.authSessionActiveNow : s.lastActive != null ? dsFormat(t.authSessionLastActive, { time: formatAuthDate(s.lastActive, locale) }) : null;
|
|
43
|
+
const meta = [s.location, s.ip, when].filter(Boolean);
|
|
44
|
+
return /* @__PURE__ */ jsxs(Item, { variant: "card", size: "sm", "data-slot": "session-list-item", "data-current": s.current || void 0, children: [
|
|
45
|
+
/* @__PURE__ */ jsx(ItemMedia, { variant: "image", className: "bg-muted text-muted-foreground [&_svg]:size-5", children: KIND[s.kind ?? "desktop"] }),
|
|
46
|
+
/* @__PURE__ */ jsxs(ItemContent, { children: [
|
|
47
|
+
/* @__PURE__ */ jsxs(ItemTitle, { children: [
|
|
48
|
+
s.device ?? t.authSessionUnknownDevice,
|
|
49
|
+
s.current ? /* @__PURE__ */ jsx(Badge, { variant: "success", children: t.authSessionCurrent }) : null
|
|
50
|
+
] }),
|
|
51
|
+
meta.length ? /* @__PURE__ */ jsx(ItemDescription, { children: meta.map((m, i) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
52
|
+
i ? " \xB7 " : null,
|
|
53
|
+
m
|
|
54
|
+
] }, i)) }) : null
|
|
55
|
+
] }),
|
|
56
|
+
!s.current && onRevoke ? /* @__PURE__ */ jsx(ItemActions, { children: /* @__PURE__ */ jsxs(Button, { type: "button", size: "sm", variant: "ghost", disabled: busy != null, onClick: () => void act(s.id, () => onRevoke(s.id)), children: [
|
|
57
|
+
busy === s.id ? /* @__PURE__ */ jsx(Spinner, {}) : null,
|
|
58
|
+
t.authSessionRevoke
|
|
59
|
+
] }) }) : null
|
|
60
|
+
] }, s.id);
|
|
61
|
+
}) }),
|
|
62
|
+
onRevokeOthers && others > 0 ? /* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", className: "self-start", disabled: busy != null, onClick: () => void act("*", onRevokeOthers), children: [
|
|
63
|
+
busy === "*" ? /* @__PURE__ */ jsx(Spinner, {}) : null,
|
|
64
|
+
t.authSessionRevokeOthers
|
|
65
|
+
] }) : null
|
|
66
|
+
] });
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
SessionList
|
|
70
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
declare function SessionTimeout({ open, seconds, onExtend, onSignOut, onExpire, }: {
|
|
4
|
+
open: boolean;
|
|
5
|
+
/** Segundos que quedan al abrirse. */
|
|
6
|
+
seconds?: number;
|
|
7
|
+
/** Ampliar la sesión (renovar el token). */
|
|
8
|
+
onExtend: () => void | Promise<void>;
|
|
9
|
+
onSignOut?: () => void | Promise<void>;
|
|
10
|
+
onExpire?: () => void;
|
|
11
|
+
}): React.JSX.Element;
|
|
12
|
+
|
|
13
|
+
export { SessionTimeout };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ClockIcon } from "lucide-react";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { useDsMessages } from "../hooks/use-ds-messages.js";
|
|
6
|
+
import { formatCountdown } from "../lib/auth.js";
|
|
7
|
+
import { dsFormat } from "../lib/i18n.js";
|
|
8
|
+
import {
|
|
9
|
+
AlertDialog,
|
|
10
|
+
AlertDialogAction,
|
|
11
|
+
AlertDialogCancel,
|
|
12
|
+
AlertDialogContent,
|
|
13
|
+
AlertDialogDescription,
|
|
14
|
+
AlertDialogFooter,
|
|
15
|
+
AlertDialogHeader,
|
|
16
|
+
AlertDialogMedia,
|
|
17
|
+
AlertDialogTitle
|
|
18
|
+
} from "./alert-dialog.js";
|
|
19
|
+
import { Spinner } from "./spinner.js";
|
|
20
|
+
function SessionTimeout({
|
|
21
|
+
open,
|
|
22
|
+
seconds = 60,
|
|
23
|
+
onExtend,
|
|
24
|
+
onSignOut,
|
|
25
|
+
onExpire
|
|
26
|
+
}) {
|
|
27
|
+
const t = useDsMessages();
|
|
28
|
+
const [left, setLeft] = React.useState(seconds);
|
|
29
|
+
const [pending, setPending] = React.useState(false);
|
|
30
|
+
const expired = React.useRef(false);
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
if (!open) return;
|
|
33
|
+
setLeft(seconds);
|
|
34
|
+
expired.current = false;
|
|
35
|
+
const end = Date.now() + seconds * 1e3;
|
|
36
|
+
const id = setInterval(() => {
|
|
37
|
+
const rest = Math.max(0, Math.round((end - Date.now()) / 1e3));
|
|
38
|
+
setLeft(rest);
|
|
39
|
+
if (rest === 0 && !expired.current) {
|
|
40
|
+
expired.current = true;
|
|
41
|
+
clearInterval(id);
|
|
42
|
+
onExpire?.();
|
|
43
|
+
}
|
|
44
|
+
}, 1e3);
|
|
45
|
+
return () => clearInterval(id);
|
|
46
|
+
}, [open, seconds]);
|
|
47
|
+
const time = formatCountdown(left);
|
|
48
|
+
const announce = left <= 10 || left % 15 === 0;
|
|
49
|
+
const [spoken, setSpoken] = React.useState(time);
|
|
50
|
+
React.useEffect(() => {
|
|
51
|
+
if (announce) setSpoken(time);
|
|
52
|
+
}, [announce, time]);
|
|
53
|
+
return /* @__PURE__ */ jsx(AlertDialog, { open, children: /* @__PURE__ */ jsxs(AlertDialogContent, { "data-slot": "session-timeout", size: "sm", children: [
|
|
54
|
+
/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
|
|
55
|
+
/* @__PURE__ */ jsx(AlertDialogMedia, { children: /* @__PURE__ */ jsx(ClockIcon, {}) }),
|
|
56
|
+
/* @__PURE__ */ jsx(AlertDialogTitle, { children: t.authSessionTimeoutTitle }),
|
|
57
|
+
/* @__PURE__ */ jsx(AlertDialogDescription, { children: t.authSessionTimeoutBody }),
|
|
58
|
+
/* @__PURE__ */ jsx("p", { "data-slot": "session-timeout-time", "aria-hidden": "true", className: "text-(length:--ds-auth-title-size) font-semibold text-foreground tabular-nums", children: time }),
|
|
59
|
+
/* @__PURE__ */ jsx("span", { role: "status", className: "sr-only", children: dsFormat(t.authSessionTimeoutLeft, { time: spoken }) })
|
|
60
|
+
] }),
|
|
61
|
+
/* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
|
|
62
|
+
onSignOut ? /* @__PURE__ */ jsx(AlertDialogCancel, { disabled: pending, onClick: () => void onSignOut(), children: t.authSignOut }) : null,
|
|
63
|
+
/* @__PURE__ */ jsxs(
|
|
64
|
+
AlertDialogAction,
|
|
65
|
+
{
|
|
66
|
+
autoFocus: true,
|
|
67
|
+
disabled: pending,
|
|
68
|
+
onClick: async () => {
|
|
69
|
+
setPending(true);
|
|
70
|
+
try {
|
|
71
|
+
await onExtend();
|
|
72
|
+
} finally {
|
|
73
|
+
setPending(false);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
children: [
|
|
77
|
+
pending ? /* @__PURE__ */ jsx(Spinner, {}) : null,
|
|
78
|
+
t.authStaySignedIn
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
] })
|
|
83
|
+
] }) });
|
|
84
|
+
}
|
|
85
|
+
export {
|
|
86
|
+
SessionTimeout
|
|
87
|
+
};
|