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,214 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ArrowLeftIcon, FingerprintIcon, KeyRoundIcon, MailIcon, MessageSquareIcon, ShieldCheckIcon, SmartphoneIcon } from "lucide-react";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { useDsMessages } from "../hooks/use-ds-messages.js";
|
|
6
|
+
import { formatCountdown, useAuthCountdown } from "../lib/auth.js";
|
|
7
|
+
import { dsFormat } from "../lib/i18n.js";
|
|
8
|
+
import { cn } from "../lib/utils.js";
|
|
9
|
+
import { AuthError, AuthHeader, AuthStagger } from "./auth-parts.js";
|
|
10
|
+
import { Button } from "./button.js";
|
|
11
|
+
import { Checkbox } from "./checkbox.js";
|
|
12
|
+
import { IconTile } from "./icon-tile.js";
|
|
13
|
+
import { Input } from "./input.js";
|
|
14
|
+
import { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot } from "./input-otp.js";
|
|
15
|
+
import { Label } from "./label.js";
|
|
16
|
+
import { Spinner } from "./spinner.js";
|
|
17
|
+
const ICONS = {
|
|
18
|
+
totp: /* @__PURE__ */ jsx(SmartphoneIcon, {}),
|
|
19
|
+
sms: /* @__PURE__ */ jsx(MessageSquareIcon, {}),
|
|
20
|
+
email: /* @__PURE__ */ jsx(MailIcon, {}),
|
|
21
|
+
"backup-code": /* @__PURE__ */ jsx(KeyRoundIcon, {}),
|
|
22
|
+
passkey: /* @__PURE__ */ jsx(FingerprintIcon, {})
|
|
23
|
+
};
|
|
24
|
+
function MfaChallenge({
|
|
25
|
+
preset = "totp",
|
|
26
|
+
methods,
|
|
27
|
+
destination,
|
|
28
|
+
codeLength = 6,
|
|
29
|
+
trustDevice = false,
|
|
30
|
+
onVerify,
|
|
31
|
+
onPasskey,
|
|
32
|
+
onResend,
|
|
33
|
+
onMethodChange,
|
|
34
|
+
resendAfter = 30,
|
|
35
|
+
onCancel,
|
|
36
|
+
error: errorProp,
|
|
37
|
+
title,
|
|
38
|
+
description,
|
|
39
|
+
className,
|
|
40
|
+
...props
|
|
41
|
+
}) {
|
|
42
|
+
const t = useDsMessages();
|
|
43
|
+
const [method, setMethod] = React.useState(preset);
|
|
44
|
+
const [choosing, setChoosing] = React.useState(false);
|
|
45
|
+
const [code, setCode] = React.useState("");
|
|
46
|
+
const [trust, setTrust] = React.useState(false);
|
|
47
|
+
const [pending, setPending] = React.useState(false);
|
|
48
|
+
const [error, setError] = React.useState(null);
|
|
49
|
+
const [fails, setFails] = React.useState(0);
|
|
50
|
+
const countdown = useAuthCountdown(preset === "sms" || preset === "email" ? resendAfter : 0);
|
|
51
|
+
const uid = React.useId();
|
|
52
|
+
const others = (methods ?? []).filter((m) => m !== method);
|
|
53
|
+
const label = {
|
|
54
|
+
totp: t.authMfaMethodTotp,
|
|
55
|
+
sms: t.authMfaMethodSms,
|
|
56
|
+
email: t.authMfaMethodEmail,
|
|
57
|
+
"backup-code": t.authMfaMethodBackup,
|
|
58
|
+
passkey: t.authMfaMethodPasskey
|
|
59
|
+
};
|
|
60
|
+
const body = {
|
|
61
|
+
totp: t.authMfaTotpBody,
|
|
62
|
+
sms: dsFormat(t.authMfaSmsBody, { destination: destination ?? "" }),
|
|
63
|
+
email: dsFormat(t.authMfaEmailBody, { destination: destination ?? "" }),
|
|
64
|
+
"backup-code": t.authMfaBackupBody,
|
|
65
|
+
passkey: t.authMfaPasskeyBody
|
|
66
|
+
};
|
|
67
|
+
async function run(task) {
|
|
68
|
+
setPending(true);
|
|
69
|
+
setError(null);
|
|
70
|
+
try {
|
|
71
|
+
const result = await task();
|
|
72
|
+
if (result?.error) {
|
|
73
|
+
setError(result.error);
|
|
74
|
+
setFails((n) => n + 1);
|
|
75
|
+
setCode("");
|
|
76
|
+
requestAnimationFrame(() => document.getElementById(`${uid}-code`)?.focus());
|
|
77
|
+
}
|
|
78
|
+
} catch {
|
|
79
|
+
setError("network");
|
|
80
|
+
} finally {
|
|
81
|
+
setPending(false);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const verify = (value) => {
|
|
85
|
+
if (pending || !onVerify) return;
|
|
86
|
+
void run(() => onVerify(value, { method, trustDevice: trust }));
|
|
87
|
+
};
|
|
88
|
+
const pick = (m) => {
|
|
89
|
+
setMethod(m);
|
|
90
|
+
setChoosing(false);
|
|
91
|
+
setCode("");
|
|
92
|
+
setError(null);
|
|
93
|
+
onMethodChange?.(m);
|
|
94
|
+
if (m === "sms" || m === "email") countdown.start(resendAfter);
|
|
95
|
+
};
|
|
96
|
+
if (choosing) {
|
|
97
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "mfa-challenge", "data-preset": preset, "data-method": "choose", className: cn("flex flex-col gap-(--ds-auth-gap)", className), ...props, children: [
|
|
98
|
+
/* @__PURE__ */ jsx(AuthHeader, { title: t.authMfaTryAnother }),
|
|
99
|
+
/* @__PURE__ */ jsx(AuthStagger, { index: 1, children: /* @__PURE__ */ jsx("ul", { "data-slot": "mfa-challenge-methods", className: "flex flex-col gap-2", children: others.map((m) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
100
|
+
"button",
|
|
101
|
+
{
|
|
102
|
+
type: "button",
|
|
103
|
+
onClick: () => pick(m),
|
|
104
|
+
className: "flex w-full items-center gap-3 rounded-(--ds-auth-radius) border border-(--ds-auth-border) p-3 text-start text-sm font-medium outline-none transition-colors duration-(--ds-motion-fast) hover:bg-(--ds-field-bg-hover) focus-visible:ring-(length:--ds-ring-width) focus-visible:ring-(--ds-ring-color)",
|
|
105
|
+
children: [
|
|
106
|
+
/* @__PURE__ */ jsx(IconTile, { size: "sm", tone: "neutral", children: ICONS[m] }),
|
|
107
|
+
label[m]
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
) }, m)) }) }),
|
|
111
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", variant: "ghost", size: "sm", className: "self-start", onClick: () => setChoosing(false), children: [
|
|
112
|
+
/* @__PURE__ */ jsx(ArrowLeftIcon, {}),
|
|
113
|
+
t.authBack
|
|
114
|
+
] })
|
|
115
|
+
] });
|
|
116
|
+
}
|
|
117
|
+
const isBackup = method === "backup-code";
|
|
118
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "mfa-challenge", "data-preset": preset, "data-method": method, className: cn("flex flex-col gap-(--ds-auth-gap)", className), ...props, children: [
|
|
119
|
+
/* @__PURE__ */ jsx(AuthHeader, { icon: /* @__PURE__ */ jsx(IconTile, { tone: "primary", size: "lg", children: method === "passkey" ? ICONS.passkey : /* @__PURE__ */ jsx(ShieldCheckIcon, {}) }), title: title ?? t.authMfaTitle, description: description ?? body[method] }),
|
|
120
|
+
/* @__PURE__ */ jsx(AuthError, { error: errorProp ?? error }),
|
|
121
|
+
/* @__PURE__ */ jsx(AuthStagger, { index: 1, children: /* @__PURE__ */ jsxs(
|
|
122
|
+
"form",
|
|
123
|
+
{
|
|
124
|
+
noValidate: true,
|
|
125
|
+
className: "flex flex-col gap-4",
|
|
126
|
+
onSubmit: (e) => {
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
if (method === "passkey") {
|
|
129
|
+
if (onPasskey) void run(onPasskey);
|
|
130
|
+
} else verify(code);
|
|
131
|
+
},
|
|
132
|
+
children: [
|
|
133
|
+
method === "passkey" ? null : isBackup ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
134
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${uid}-code`, children: t.authBackupCode }),
|
|
135
|
+
/* @__PURE__ */ jsx(
|
|
136
|
+
Input,
|
|
137
|
+
{
|
|
138
|
+
id: `${uid}-code`,
|
|
139
|
+
name: "code",
|
|
140
|
+
autoComplete: "off",
|
|
141
|
+
autoCapitalize: "none",
|
|
142
|
+
spellCheck: false,
|
|
143
|
+
autoFocus: true,
|
|
144
|
+
className: "font-mono tracking-widest",
|
|
145
|
+
value: code,
|
|
146
|
+
onChange: (e) => setCode(e.target.value),
|
|
147
|
+
"aria-invalid": error ? true : void 0
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
] }) : /* @__PURE__ */ jsxs("div", { "data-slot": "mfa-challenge-code", className: cn("flex flex-col items-center gap-2", fails > 0 && "animate-ds-auth-shake"), children: [
|
|
151
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${uid}-code`, className: "sr-only", children: t.authCode }),
|
|
152
|
+
/* @__PURE__ */ jsx(
|
|
153
|
+
InputOTP,
|
|
154
|
+
{
|
|
155
|
+
id: `${uid}-code`,
|
|
156
|
+
maxLength: codeLength,
|
|
157
|
+
value: code,
|
|
158
|
+
onChange: setCode,
|
|
159
|
+
onComplete: verify,
|
|
160
|
+
autoComplete: "one-time-code",
|
|
161
|
+
inputMode: "numeric",
|
|
162
|
+
autoFocus: true,
|
|
163
|
+
disabled: pending,
|
|
164
|
+
"aria-invalid": error ? true : void 0,
|
|
165
|
+
children: codeLength === 6 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
166
|
+
/* @__PURE__ */ jsxs(InputOTPGroup, { children: [
|
|
167
|
+
/* @__PURE__ */ jsx(InputOTPSlot, { index: 0 }),
|
|
168
|
+
/* @__PURE__ */ jsx(InputOTPSlot, { index: 1 }),
|
|
169
|
+
/* @__PURE__ */ jsx(InputOTPSlot, { index: 2 })
|
|
170
|
+
] }),
|
|
171
|
+
/* @__PURE__ */ jsx(InputOTPSeparator, {}),
|
|
172
|
+
/* @__PURE__ */ jsxs(InputOTPGroup, { children: [
|
|
173
|
+
/* @__PURE__ */ jsx(InputOTPSlot, { index: 3 }),
|
|
174
|
+
/* @__PURE__ */ jsx(InputOTPSlot, { index: 4 }),
|
|
175
|
+
/* @__PURE__ */ jsx(InputOTPSlot, { index: 5 })
|
|
176
|
+
] })
|
|
177
|
+
] }) : /* @__PURE__ */ jsx(InputOTPGroup, { children: Array.from({ length: codeLength }, (_, i) => /* @__PURE__ */ jsx(InputOTPSlot, { index: i }, i)) })
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
] }, fails),
|
|
181
|
+
trustDevice ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2.5", children: [
|
|
182
|
+
/* @__PURE__ */ jsx(Checkbox, { id: `${uid}-trust`, checked: trust, onCheckedChange: (v) => setTrust(v === true) }),
|
|
183
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${uid}-trust`, className: "text-sm font-normal", children: t.authMfaTrustDevice })
|
|
184
|
+
] }) : null,
|
|
185
|
+
/* @__PURE__ */ jsxs(Button, { type: "submit", className: "w-full", disabled: pending || method !== "passkey" && (isBackup ? !code.trim() : code.length < codeLength), children: [
|
|
186
|
+
pending ? /* @__PURE__ */ jsx(Spinner, {}) : method === "passkey" ? ICONS.passkey : null,
|
|
187
|
+
method === "passkey" ? t.authMfaPasskeyAction : t.authVerify
|
|
188
|
+
] })
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
) }),
|
|
192
|
+
/* @__PURE__ */ jsxs(AuthStagger, { index: 2, className: "flex flex-wrap items-center justify-center gap-x-4 gap-y-1", children: [
|
|
193
|
+
(method === "sms" || method === "email") && onResend ? /* @__PURE__ */ jsx(
|
|
194
|
+
Button,
|
|
195
|
+
{
|
|
196
|
+
type: "button",
|
|
197
|
+
variant: "link",
|
|
198
|
+
size: "sm",
|
|
199
|
+
disabled: countdown.running || pending,
|
|
200
|
+
onClick: async () => {
|
|
201
|
+
await onResend(method);
|
|
202
|
+
countdown.start(resendAfter);
|
|
203
|
+
},
|
|
204
|
+
children: countdown.running ? dsFormat(t.authResendIn, { time: formatCountdown(countdown.left) }) : t.authResend
|
|
205
|
+
}
|
|
206
|
+
) : null,
|
|
207
|
+
others.length ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "link", size: "sm", onClick: () => others.length === 1 ? pick(others[0]) : setChoosing(true), children: others.length === 1 ? label[others[0]] : t.authMfaTryAnother }) : null,
|
|
208
|
+
onCancel ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: onCancel, children: t.authCancel }) : null
|
|
209
|
+
] })
|
|
210
|
+
] });
|
|
211
|
+
}
|
|
212
|
+
export {
|
|
213
|
+
MfaChallenge
|
|
214
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { AuthResult } from './auth-form.js';
|
|
3
|
+
import '../lib/auth.js';
|
|
4
|
+
import '../lib/i18n.js';
|
|
5
|
+
|
|
6
|
+
type MfaSetupPreset = "totp" | "sms" | "backup-codes";
|
|
7
|
+
declare function MfaSetup({ preset, qr, secret, backupCodes, codeLength, onSendCode, onVerify, onDone, onCancel, resendAfter, fileName, error: errorProp, className, ...props }: React.ComponentProps<"div"> & {
|
|
8
|
+
preset?: MfaSetupPreset;
|
|
9
|
+
/** totp: el código QR (nodo de la app). */
|
|
10
|
+
qr?: React.ReactNode;
|
|
11
|
+
/** totp: la clave para teclearla a mano. */
|
|
12
|
+
secret?: string;
|
|
13
|
+
/** Códigos de respaldo (último paso de totp/sms, o el preset backup-codes). */
|
|
14
|
+
backupCodes?: string[];
|
|
15
|
+
codeLength?: number;
|
|
16
|
+
/** sms: envía el código al número. */
|
|
17
|
+
onSendCode?: (phone: string) => AuthResult | Promise<AuthResult>;
|
|
18
|
+
/** Confirma el código del método nuevo. */
|
|
19
|
+
onVerify?: (code: string) => AuthResult | Promise<AuthResult>;
|
|
20
|
+
/** Terminado (con los códigos guardados, si había). */
|
|
21
|
+
onDone?: () => void;
|
|
22
|
+
onCancel?: () => void;
|
|
23
|
+
resendAfter?: number;
|
|
24
|
+
/** Nombre del fichero al descargar los códigos. */
|
|
25
|
+
fileName?: string;
|
|
26
|
+
error?: React.ReactNode;
|
|
27
|
+
}): React.JSX.Element;
|
|
28
|
+
|
|
29
|
+
export { MfaSetup, type MfaSetupPreset };
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { CheckIcon, CopyIcon, DownloadIcon, KeyRoundIcon, MessageSquareIcon, SmartphoneIcon } from "lucide-react";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { useDsMessages } from "../hooks/use-ds-messages.js";
|
|
6
|
+
import { formatCountdown, useAuthCountdown } from "../lib/auth.js";
|
|
7
|
+
import { dsFormat } from "../lib/i18n.js";
|
|
8
|
+
import { cn } from "../lib/utils.js";
|
|
9
|
+
import { AuthError, AuthHeader, AuthStagger } from "./auth-parts.js";
|
|
10
|
+
import { Button } from "./button.js";
|
|
11
|
+
import { Checkbox } from "./checkbox.js";
|
|
12
|
+
import { CopyField } from "./copy-button.js";
|
|
13
|
+
import { IconTile } from "./icon-tile.js";
|
|
14
|
+
import { Input } from "./input.js";
|
|
15
|
+
import { InputOTP, InputOTPGroup, InputOTPSlot } from "./input-otp.js";
|
|
16
|
+
import { Label } from "./label.js";
|
|
17
|
+
import { Spinner } from "./spinner.js";
|
|
18
|
+
function MfaSetup({
|
|
19
|
+
preset = "totp",
|
|
20
|
+
qr,
|
|
21
|
+
secret,
|
|
22
|
+
backupCodes,
|
|
23
|
+
codeLength = 6,
|
|
24
|
+
onSendCode,
|
|
25
|
+
onVerify,
|
|
26
|
+
onDone,
|
|
27
|
+
onCancel,
|
|
28
|
+
resendAfter = 30,
|
|
29
|
+
fileName = "backup-codes.txt",
|
|
30
|
+
error: errorProp,
|
|
31
|
+
className,
|
|
32
|
+
...props
|
|
33
|
+
}) {
|
|
34
|
+
const t = useDsMessages();
|
|
35
|
+
const uid = React.useId();
|
|
36
|
+
const [step, setStep] = React.useState(preset === "backup-codes" ? "codes" : "start");
|
|
37
|
+
const [phone, setPhone] = React.useState("");
|
|
38
|
+
const [code, setCode] = React.useState("");
|
|
39
|
+
const [saved, setSaved] = React.useState(false);
|
|
40
|
+
const [copied, setCopied] = React.useState(false);
|
|
41
|
+
const [pending, setPending] = React.useState(false);
|
|
42
|
+
const [error, setError] = React.useState(null);
|
|
43
|
+
const [fails, setFails] = React.useState(0);
|
|
44
|
+
const countdown = useAuthCountdown(0);
|
|
45
|
+
async function run(task, onOk) {
|
|
46
|
+
setPending(true);
|
|
47
|
+
setError(null);
|
|
48
|
+
try {
|
|
49
|
+
const result = await task();
|
|
50
|
+
if (result?.error) {
|
|
51
|
+
setError(result.error);
|
|
52
|
+
setFails((n) => n + 1);
|
|
53
|
+
setCode("");
|
|
54
|
+
} else onOk();
|
|
55
|
+
} catch {
|
|
56
|
+
setError("network");
|
|
57
|
+
} finally {
|
|
58
|
+
setPending(false);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const finishOrCodes = () => backupCodes?.length ? setStep("codes") : onDone?.();
|
|
62
|
+
const verify = (value) => {
|
|
63
|
+
if (pending || !onVerify) return;
|
|
64
|
+
void run(() => onVerify(value), finishOrCodes);
|
|
65
|
+
};
|
|
66
|
+
const sendCode = () => {
|
|
67
|
+
if (!onSendCode || pending) return;
|
|
68
|
+
void run(
|
|
69
|
+
() => onSendCode(phone.trim()),
|
|
70
|
+
() => {
|
|
71
|
+
setStep("verify");
|
|
72
|
+
countdown.start(resendAfter);
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
const allCodes = (backupCodes ?? []).join("\n");
|
|
77
|
+
const copyAll = async () => {
|
|
78
|
+
try {
|
|
79
|
+
await navigator.clipboard.writeText(allCodes);
|
|
80
|
+
setCopied(true);
|
|
81
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const download = () => {
|
|
86
|
+
const url = URL.createObjectURL(new Blob([allCodes + "\n"], { type: "text/plain" }));
|
|
87
|
+
const a = document.createElement("a");
|
|
88
|
+
a.href = url;
|
|
89
|
+
a.download = fileName;
|
|
90
|
+
a.click();
|
|
91
|
+
URL.revokeObjectURL(url);
|
|
92
|
+
};
|
|
93
|
+
const otp = /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col items-center gap-2", fails > 0 && "animate-ds-auth-shake"), children: [
|
|
94
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${uid}-code`, children: t.authCode }),
|
|
95
|
+
/* @__PURE__ */ jsx(InputOTP, { id: `${uid}-code`, maxLength: codeLength, value: code, onChange: setCode, onComplete: verify, autoComplete: "one-time-code", inputMode: "numeric", disabled: pending, "aria-invalid": error ? true : void 0, children: /* @__PURE__ */ jsx(InputOTPGroup, { children: Array.from({ length: codeLength }, (_, i) => /* @__PURE__ */ jsx(InputOTPSlot, { index: i }, i)) }) })
|
|
96
|
+
] }, fails);
|
|
97
|
+
const actions = (primary) => /* @__PURE__ */ jsxs(AuthStagger, { index: 3, className: "flex flex-col gap-2", children: [
|
|
98
|
+
primary,
|
|
99
|
+
onCancel ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", className: "w-full", onClick: onCancel, children: t.authCancel }) : null
|
|
100
|
+
] });
|
|
101
|
+
let content;
|
|
102
|
+
if (step === "codes") {
|
|
103
|
+
content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
104
|
+
/* @__PURE__ */ jsx(AuthHeader, { icon: /* @__PURE__ */ jsx(IconTile, { tone: "warning", size: "lg", children: /* @__PURE__ */ jsx(KeyRoundIcon, {}) }), title: t.authMfaBackupTitle, description: t.authMfaBackupSetupBody }),
|
|
105
|
+
/* @__PURE__ */ jsxs(AuthStagger, { index: 1, className: "flex flex-col gap-3", children: [
|
|
106
|
+
/* @__PURE__ */ jsx("ol", { "data-slot": "mfa-setup-codes", className: "grid grid-cols-2 gap-2 rounded-(--ds-auth-radius) border border-(--ds-auth-border) bg-muted p-4 font-mono text-sm tracking-wider", children: (backupCodes ?? []).map((c) => /* @__PURE__ */ jsx("li", { className: "text-center", children: c }, c)) }),
|
|
107
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
|
|
108
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", onClick: copyAll, children: [
|
|
109
|
+
copied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {}),
|
|
110
|
+
copied ? t.copied : t.authCopyAll
|
|
111
|
+
] }),
|
|
112
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", onClick: download, children: [
|
|
113
|
+
/* @__PURE__ */ jsx(DownloadIcon, {}),
|
|
114
|
+
t.authDownload
|
|
115
|
+
] })
|
|
116
|
+
] }),
|
|
117
|
+
/* @__PURE__ */ jsx("span", { role: "status", className: "sr-only", children: copied ? t.copied : "" })
|
|
118
|
+
] }),
|
|
119
|
+
/* @__PURE__ */ jsxs(AuthStagger, { index: 2, className: "flex items-start gap-2.5", children: [
|
|
120
|
+
/* @__PURE__ */ jsx(Checkbox, { id: `${uid}-saved`, checked: saved, onCheckedChange: (v) => setSaved(v === true), className: "mt-0.5" }),
|
|
121
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${uid}-saved`, className: "text-sm font-normal", children: t.authMfaBackupConfirm })
|
|
122
|
+
] }),
|
|
123
|
+
actions(
|
|
124
|
+
/* @__PURE__ */ jsx(Button, { type: "button", className: "w-full", disabled: !saved, onClick: onDone, children: t.authDone })
|
|
125
|
+
)
|
|
126
|
+
] });
|
|
127
|
+
} else if (preset === "totp") {
|
|
128
|
+
content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
129
|
+
/* @__PURE__ */ jsx(AuthHeader, { icon: /* @__PURE__ */ jsx(IconTile, { tone: "primary", size: "lg", children: /* @__PURE__ */ jsx(SmartphoneIcon, {}) }), title: t.authMfaSetupTotpTitle, description: t.authMfaSetupTotpStep1 }),
|
|
130
|
+
/* @__PURE__ */ jsx(AuthError, { error: errorProp ?? error }),
|
|
131
|
+
/* @__PURE__ */ jsxs(AuthStagger, { index: 1, className: "flex flex-col items-center gap-3", children: [
|
|
132
|
+
qr ? /* @__PURE__ */ jsx("div", { "data-slot": "mfa-setup-qr", className: "rounded-(--ds-auth-radius) border border-(--ds-auth-border) bg-background p-3 [&_svg]:size-40 [&_canvas]:size-40 [&_img]:size-40", children: qr }) : null,
|
|
133
|
+
secret ? /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col items-center gap-1.5 text-center", children: [
|
|
134
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t.authMfaSetupManual }),
|
|
135
|
+
/* @__PURE__ */ jsx(CopyField, { value: secret.replace(/\s+/g, ""), className: "font-mono", children: secret })
|
|
136
|
+
] }) : null
|
|
137
|
+
] }),
|
|
138
|
+
/* @__PURE__ */ jsxs(AuthStagger, { index: 2, className: "flex flex-col gap-2", children: [
|
|
139
|
+
/* @__PURE__ */ jsx("p", { className: "text-center text-sm text-muted-foreground", children: t.authMfaSetupTotpStep2 }),
|
|
140
|
+
otp
|
|
141
|
+
] }),
|
|
142
|
+
actions(
|
|
143
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", className: "w-full", disabled: pending || code.length < codeLength, onClick: () => verify(code), children: [
|
|
144
|
+
pending ? /* @__PURE__ */ jsx(Spinner, {}) : null,
|
|
145
|
+
t.authActivate
|
|
146
|
+
] })
|
|
147
|
+
)
|
|
148
|
+
] });
|
|
149
|
+
} else if (step === "start") {
|
|
150
|
+
content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
151
|
+
/* @__PURE__ */ jsx(AuthHeader, { icon: /* @__PURE__ */ jsx(IconTile, { tone: "primary", size: "lg", children: /* @__PURE__ */ jsx(MessageSquareIcon, {}) }), title: t.authMfaSetupSmsTitle, description: t.authMfaSetupSmsBody }),
|
|
152
|
+
/* @__PURE__ */ jsx(AuthError, { error: errorProp ?? error }),
|
|
153
|
+
/* @__PURE__ */ jsx(AuthStagger, { index: 1, children: /* @__PURE__ */ jsxs(
|
|
154
|
+
"form",
|
|
155
|
+
{
|
|
156
|
+
noValidate: true,
|
|
157
|
+
className: "flex flex-col gap-4",
|
|
158
|
+
onSubmit: (e) => {
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
sendCode();
|
|
161
|
+
},
|
|
162
|
+
children: [
|
|
163
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
164
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${uid}-phone`, children: t.authPhone }),
|
|
165
|
+
/* @__PURE__ */ jsx(Input, { id: `${uid}-phone`, name: "phone", type: "tel", inputMode: "tel", autoComplete: "tel", autoFocus: true, value: phone, onChange: (e) => setPhone(e.target.value) })
|
|
166
|
+
] }),
|
|
167
|
+
/* @__PURE__ */ jsxs(Button, { type: "submit", className: "w-full", disabled: pending || phone.trim().length < 6, children: [
|
|
168
|
+
pending ? /* @__PURE__ */ jsx(Spinner, {}) : null,
|
|
169
|
+
t.authSendCode
|
|
170
|
+
] })
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
) }),
|
|
174
|
+
onCancel ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", className: "w-full", onClick: onCancel, children: t.authCancel }) : null
|
|
175
|
+
] });
|
|
176
|
+
} else {
|
|
177
|
+
content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
178
|
+
/* @__PURE__ */ jsx(AuthHeader, { icon: /* @__PURE__ */ jsx(IconTile, { tone: "primary", size: "lg", children: /* @__PURE__ */ jsx(MessageSquareIcon, {}) }), title: t.authMfaSetupSmsTitle, description: dsFormat(t.authMfaSmsBody, { destination: phone }) }),
|
|
179
|
+
/* @__PURE__ */ jsx(AuthError, { error: errorProp ?? error }),
|
|
180
|
+
/* @__PURE__ */ jsxs(AuthStagger, { index: 1, className: "flex flex-col items-center gap-2", children: [
|
|
181
|
+
otp,
|
|
182
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "link", size: "sm", disabled: countdown.running || pending, onClick: sendCode, children: countdown.running ? dsFormat(t.authResendIn, { time: formatCountdown(countdown.left) }) : t.authResend })
|
|
183
|
+
] }),
|
|
184
|
+
actions(
|
|
185
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", className: "w-full", disabled: pending || code.length < codeLength, onClick: () => verify(code), children: [
|
|
186
|
+
pending ? /* @__PURE__ */ jsx(Spinner, {}) : null,
|
|
187
|
+
t.authActivate
|
|
188
|
+
] })
|
|
189
|
+
)
|
|
190
|
+
] });
|
|
191
|
+
}
|
|
192
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "mfa-setup", "data-preset": preset, "data-step": step, className: cn("flex flex-col gap-(--ds-auth-gap)", className), ...props, children: content });
|
|
193
|
+
}
|
|
194
|
+
export {
|
|
195
|
+
MfaSetup
|
|
196
|
+
};
|
|
@@ -55,7 +55,7 @@ function NavigationMenuItem({
|
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
57
|
const navigationMenuTriggerStyle = cva(
|
|
58
|
-
"group/navigation-menu-trigger inline-flex h-(--ds-control-h-md) w-max items-center justify-center rounded-2xl px-4.5 py-2.5 text-sm font-(--ds-medium-weight) transition-all duration-(--ds-motion-snap) outline-none hover:bg-
|
|
58
|
+
"group/navigation-menu-trigger inline-flex h-(--ds-control-h-md) w-max items-center justify-center rounded-2xl px-4.5 py-2.5 text-sm font-(--ds-medium-weight) transition-all duration-(--ds-motion-snap) outline-none hover:bg-(--ds-hover-bg) focus:bg-muted focus-visible:ring-(length:--ds-ring-width) focus-visible:ring-(--ds-ring-color) focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-(--ds-disabled-opacity) data-popup-open:bg-muted/50 data-popup-open:hover:bg-(--ds-hover-bg) data-open:bg-muted/50 data-open:hover:bg-(--ds-hover-bg) data-open:focus:bg-muted"
|
|
59
59
|
);
|
|
60
60
|
function NavigationMenuTrigger({
|
|
61
61
|
className,
|
|
@@ -126,7 +126,7 @@ function NavigationMenuLink({
|
|
|
126
126
|
{
|
|
127
127
|
"data-slot": "navigation-menu-link",
|
|
128
128
|
className: cn(
|
|
129
|
-
"flex items-center gap-1.5 rounded-item p-3 text-sm transition-all duration-(--ds-motion-snap) outline-none hover:bg-
|
|
129
|
+
"flex items-center gap-1.5 rounded-item p-3 text-sm transition-all duration-(--ds-motion-snap) outline-none hover:bg-(--ds-hover-bg) focus:bg-muted focus-visible:ring-(length:--ds-ring-width) focus-visible:ring-(--ds-ring-color) focus-visible:outline-1 data-[active=true]:bg-muted/50 data-[active=true]:hover:bg-(--ds-hover-bg) data-[active=true]:focus:bg-muted [&_svg:not([class*='size-'])]:size-4",
|
|
130
130
|
className
|
|
131
131
|
),
|
|
132
132
|
...props
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { DsPresentation } from '../lib/presets.js';
|
|
3
3
|
import { NotificationTone, NotificationState } from './notifications.js';
|
|
4
|
+
import '../lib/header-control.js';
|
|
4
5
|
import './tabs.js';
|
|
5
6
|
import 'class-variance-authority/types';
|
|
6
7
|
import '@base-ui/react/tabs';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { HeaderControlTone } from '../lib/header-control.js';
|
|
2
3
|
import { Tabs, TabsContent } from './tabs.js';
|
|
3
4
|
import 'class-variance-authority/types';
|
|
4
5
|
import '@base-ui/react/tabs';
|
|
@@ -7,7 +8,16 @@ import 'class-variance-authority';
|
|
|
7
8
|
type NotificationTone = "info" | "success" | "warning" | "danger" | "neutral";
|
|
8
9
|
type NotificationState = "new" | "acknowledged" | "resolved" | (string & {});
|
|
9
10
|
type NotificationTab = "for-you" | "general" | "history";
|
|
10
|
-
|
|
11
|
+
type NotificationCenterPreset = "count" | "dot" | "compact";
|
|
12
|
+
type NotificationIndicator = "count" | "dot" | "none";
|
|
13
|
+
declare function NotificationCenter({ preset, indicator, density, tone, unreadCount, onMarkAllRead, title, open, defaultOpen, onOpenChange, align, className, triggerClassName, children, }: {
|
|
14
|
+
preset?: NotificationCenterPreset;
|
|
15
|
+
/** Cómo se anuncian los avisos sin leer sobre la campana. */
|
|
16
|
+
indicator?: NotificationIndicator;
|
|
17
|
+
/** Ancho del panel: default (--ds-notifications-w) o compact. */
|
|
18
|
+
density?: "default" | "compact";
|
|
19
|
+
/** Color de la campana: neutral, con la marca o con fondo suave. */
|
|
20
|
+
tone?: HeaderControlTone;
|
|
11
21
|
/** Avisos sin leer: contador de la campana y nombre accesible. */
|
|
12
22
|
unreadCount?: number;
|
|
13
23
|
/** Si se pasa, la cabecera muestra «Marcar todo como leído». */
|
|
@@ -68,4 +78,4 @@ declare function NotificationEmpty({ className, children, icon, ...props }: Reac
|
|
|
68
78
|
icon?: React.ReactNode;
|
|
69
79
|
}): React.JSX.Element;
|
|
70
80
|
|
|
71
|
-
export { NotificationCenter, NotificationEmpty, NotificationItem, NotificationList, type NotificationState, type NotificationTab, NotificationTabs, NotificationTabsContent, type NotificationTone, formatRelativeTime };
|
|
81
|
+
export { NotificationCenter, type NotificationCenterPreset, NotificationEmpty, type NotificationIndicator, NotificationItem, NotificationList, type NotificationState, type NotificationTab, NotificationTabs, NotificationTabsContent, type NotificationTone, formatRelativeTime };
|
package/dist/ui/notifications.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { BellIcon, BellOffIcon } from "lucide-react";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { useDsLocale, useDsMessages } from "../hooks/use-ds-messages.js";
|
|
6
|
+
import { headerControlClass } from "../lib/header-control.js";
|
|
6
7
|
import { dsFormat } from "../lib/i18n.js";
|
|
7
8
|
import { cn } from "../lib/utils.js";
|
|
8
9
|
import { Badge } from "./badge.js";
|
|
@@ -10,7 +11,16 @@ import { Button } from "./button.js";
|
|
|
10
11
|
import { IconTile } from "./icon-tile.js";
|
|
11
12
|
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
12
13
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./tabs.js";
|
|
14
|
+
const CENTER_PRESETS = {
|
|
15
|
+
count: { indicator: "count", density: "default" },
|
|
16
|
+
dot: { indicator: "dot", density: "default" },
|
|
17
|
+
compact: { indicator: "count", density: "compact" }
|
|
18
|
+
};
|
|
13
19
|
function NotificationCenter({
|
|
20
|
+
preset = "count",
|
|
21
|
+
indicator,
|
|
22
|
+
density,
|
|
23
|
+
tone = "neutral",
|
|
14
24
|
unreadCount = 0,
|
|
15
25
|
onMarkAllRead,
|
|
16
26
|
title,
|
|
@@ -23,6 +33,8 @@ function NotificationCenter({
|
|
|
23
33
|
children
|
|
24
34
|
}) {
|
|
25
35
|
const t = useDsMessages();
|
|
36
|
+
const ind = indicator ?? CENTER_PRESETS[preset].indicator;
|
|
37
|
+
const dens = density ?? CENTER_PRESETS[preset].density;
|
|
26
38
|
const unreadText = dsFormat(t.notificationsUnread, { n: unreadCount });
|
|
27
39
|
const label = unreadCount > 0 ? `${t.notifications}, ${unreadText}` : t.notifications;
|
|
28
40
|
return /* @__PURE__ */ jsxs(
|
|
@@ -36,25 +48,34 @@ function NotificationCenter({
|
|
|
36
48
|
PopoverTrigger,
|
|
37
49
|
{
|
|
38
50
|
"data-slot": "notification-trigger",
|
|
51
|
+
"data-preset": preset,
|
|
39
52
|
render: /* @__PURE__ */ jsx(
|
|
40
53
|
Button,
|
|
41
54
|
{
|
|
42
55
|
variant: "ghost",
|
|
43
56
|
size: "icon",
|
|
44
57
|
"aria-label": label,
|
|
45
|
-
className: cn("relative", triggerClassName)
|
|
58
|
+
className: cn("relative", headerControlClass(tone), triggerClassName)
|
|
46
59
|
}
|
|
47
60
|
),
|
|
48
61
|
children: [
|
|
49
62
|
/* @__PURE__ */ jsx(BellIcon, {}),
|
|
50
|
-
unreadCount > 0 ? /* @__PURE__ */ jsx(
|
|
63
|
+
unreadCount > 0 && ind === "count" ? /* @__PURE__ */ jsx(
|
|
51
64
|
Badge,
|
|
52
65
|
{
|
|
53
66
|
"data-slot": "notification-count",
|
|
54
67
|
"aria-hidden": "true",
|
|
55
|
-
className: "pointer-events-none absolute -top-1 -end-1 min-w-5 justify-center px-1 py-0 tabular-nums",
|
|
68
|
+
className: "pointer-events-none absolute -top-1 -end-1 min-w-5 justify-center bg-(--ds-header-control-badge-bg) px-1 py-0 text-(--ds-header-control-badge-fg) tabular-nums",
|
|
56
69
|
children: unreadCount > 99 ? "99+" : unreadCount
|
|
57
70
|
}
|
|
71
|
+
) : null,
|
|
72
|
+
unreadCount > 0 && ind === "dot" ? /* @__PURE__ */ jsx(
|
|
73
|
+
"span",
|
|
74
|
+
{
|
|
75
|
+
"data-slot": "notification-count-dot",
|
|
76
|
+
"aria-hidden": "true",
|
|
77
|
+
className: "pointer-events-none absolute top-1.5 end-1.5 size-(--ds-status-dot) rounded-full bg-(--ds-header-control-badge-bg)"
|
|
78
|
+
}
|
|
58
79
|
) : null
|
|
59
80
|
]
|
|
60
81
|
}
|
|
@@ -63,10 +84,12 @@ function NotificationCenter({
|
|
|
63
84
|
PopoverContent,
|
|
64
85
|
{
|
|
65
86
|
"data-slot": "notification-center",
|
|
87
|
+
"data-preset": preset,
|
|
88
|
+
"data-density": dens,
|
|
66
89
|
align,
|
|
67
90
|
"aria-label": t.notifications,
|
|
68
91
|
className: cn(
|
|
69
|
-
"w-(--ds-notifications-w) max-w-(--available-width) gap-0 p-0",
|
|
92
|
+
"w-(--ds-notifications-w) max-w-(--available-width) gap-0 p-0 data-[density=compact]:w-(--ds-notifications-w-compact)",
|
|
70
93
|
className
|
|
71
94
|
),
|
|
72
95
|
children: [
|
|
@@ -263,7 +286,7 @@ function NotificationItem({
|
|
|
263
286
|
"span",
|
|
264
287
|
{
|
|
265
288
|
"data-slot": "notification-dot",
|
|
266
|
-
className: "mt-1.5 size-(--ds-status-dot) shrink-0 rounded-full bg-
|
|
289
|
+
className: "mt-1.5 size-(--ds-status-dot) shrink-0 rounded-full bg-(--ds-header-control-badge-bg)",
|
|
267
290
|
children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: t.notificationUnread })
|
|
268
291
|
}
|
|
269
292
|
) : null
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { AuthResult } from './auth-form.js';
|
|
3
|
+
import '../lib/auth.js';
|
|
4
|
+
import '../lib/i18n.js';
|
|
5
|
+
|
|
6
|
+
type OAuthConsentPreset = "authorize" | "mcp" | "device";
|
|
7
|
+
type OAuthScope = {
|
|
8
|
+
id: string;
|
|
9
|
+
label: React.ReactNode;
|
|
10
|
+
description?: React.ReactNode;
|
|
11
|
+
icon?: React.ReactNode;
|
|
12
|
+
/** No se puede desmarcar (con `selectable`). */
|
|
13
|
+
required?: boolean;
|
|
14
|
+
/** Permiso delicado (escritura, borrar, datos personales): se señala. */
|
|
15
|
+
sensitive?: boolean;
|
|
16
|
+
};
|
|
17
|
+
type OAuthParty = {
|
|
18
|
+
name: string;
|
|
19
|
+
logo?: React.ReactNode;
|
|
20
|
+
url?: string;
|
|
21
|
+
verified?: boolean;
|
|
22
|
+
};
|
|
23
|
+
declare function OAuthConsent({ preset, client, app, account, onSwitchAccount, scopes, selectable, redirectUri, userCode, codeLength, onSubmitCode, onAllow, onDeny, error: errorProp, title, description, className, ...props }: Omit<React.ComponentProps<"div">, "title"> & {
|
|
24
|
+
preset?: OAuthConsentPreset;
|
|
25
|
+
/** Quien pide acceso (app, cliente MCP, dispositivo). */
|
|
26
|
+
client: OAuthParty;
|
|
27
|
+
/** Tu app (a la que se da acceso). */
|
|
28
|
+
app?: OAuthParty;
|
|
29
|
+
/** Cuenta con la que se autoriza. */
|
|
30
|
+
account?: {
|
|
31
|
+
name?: string;
|
|
32
|
+
email: string;
|
|
33
|
+
avatar?: string;
|
|
34
|
+
};
|
|
35
|
+
/** «¿No eres tú?»: cambiar de cuenta. */
|
|
36
|
+
onSwitchAccount?: () => void;
|
|
37
|
+
scopes?: OAuthScope[];
|
|
38
|
+
/** Consentimiento granular: los permisos no obligatorios se pueden desmarcar. */
|
|
39
|
+
selectable?: boolean;
|
|
40
|
+
/** URI de vuelta: se muestra su dominio (la persona sabe adónde vuelve). */
|
|
41
|
+
redirectUri?: string;
|
|
42
|
+
/** device: código ya conocido (enlace con ?user_code=…): llega escrito y la persona lo confirma (se valida con `onSubmitCode`). */
|
|
43
|
+
userCode?: string;
|
|
44
|
+
codeLength?: number;
|
|
45
|
+
/** device: comprueba el código; devuelve { error } si no vale. */
|
|
46
|
+
onSubmitCode?: (code: string) => AuthResult | Promise<AuthResult>;
|
|
47
|
+
onAllow: (scopes: string[]) => AuthResult | void | Promise<AuthResult | void>;
|
|
48
|
+
onDeny: () => void | Promise<void>;
|
|
49
|
+
error?: React.ReactNode;
|
|
50
|
+
title?: React.ReactNode;
|
|
51
|
+
description?: React.ReactNode;
|
|
52
|
+
}): React.JSX.Element;
|
|
53
|
+
|
|
54
|
+
export { OAuthConsent, type OAuthConsentPreset, type OAuthParty, type OAuthScope };
|