orbital-ds 0.28.0 → 0.29.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.
Files changed (65) hide show
  1. package/AGENTS.md +289 -273
  2. package/components.manifest.json +410 -7
  3. package/dist/hooks/use-ds-messages.d.ts +196 -0
  4. package/dist/lib/auth-better-auth.d.ts +29 -0
  5. package/dist/lib/auth-better-auth.js +60 -0
  6. package/dist/lib/auth-flow.d.ts +59 -0
  7. package/dist/lib/auth-flow.js +135 -0
  8. package/dist/lib/auth-providers.d.ts +194 -0
  9. package/dist/lib/auth-providers.js +64 -0
  10. package/dist/lib/auth.d.ts +68 -0
  11. package/dist/lib/auth.js +110 -0
  12. package/dist/lib/i18n.d.ts +196 -0
  13. package/dist/lib/i18n.js +597 -3
  14. package/dist/styles.css +419 -3
  15. package/dist/themes/lagoon.css +8 -8
  16. package/dist/themes/lagoon.meta.json +3 -2
  17. package/dist/themes/lagoon.scoped.css +8 -8
  18. package/dist/ui/auth-backdrop.d.ts +20 -0
  19. package/dist/ui/auth-backdrop.js +137 -0
  20. package/dist/ui/auth-form.d.ts +107 -0
  21. package/dist/ui/auth-form.js +526 -0
  22. package/dist/ui/auth-layout.d.ts +70 -0
  23. package/dist/ui/auth-layout.js +283 -0
  24. package/dist/ui/auth-parts.d.ts +43 -0
  25. package/dist/ui/auth-parts.js +159 -0
  26. package/dist/ui/auth-status.d.ts +23 -0
  27. package/dist/ui/auth-status.js +99 -0
  28. package/dist/ui/connected-accounts.d.ts +25 -0
  29. package/dist/ui/connected-accounts.js +89 -0
  30. package/dist/ui/empty-state.d.ts +10 -1
  31. package/dist/ui/empty-state.js +28 -7
  32. package/dist/ui/error-page.d.ts +10 -1
  33. package/dist/ui/error-page.js +74 -28
  34. package/dist/ui/icon-tile.d.ts +1 -1
  35. package/dist/ui/input-otp.js +2 -1
  36. package/dist/ui/mfa-challenge.d.ts +33 -0
  37. package/dist/ui/mfa-challenge.js +214 -0
  38. package/dist/ui/mfa-setup.d.ts +29 -0
  39. package/dist/ui/mfa-setup.js +196 -0
  40. package/dist/ui/oauth-consent.d.ts +54 -0
  41. package/dist/ui/oauth-consent.js +208 -0
  42. package/dist/ui/passkey-list.d.ts +17 -0
  43. package/dist/ui/passkey-list.js +112 -0
  44. package/dist/ui/password-input.d.ts +5 -0
  45. package/dist/ui/password-input.js +77 -0
  46. package/dist/ui/session-list.d.ts +19 -0
  47. package/dist/ui/session-list.js +70 -0
  48. package/dist/ui/session-timeout.d.ts +13 -0
  49. package/dist/ui/session-timeout.js +87 -0
  50. package/dist/ui/sidebar.d.ts +12 -4
  51. package/dist/ui/sidebar.js +35 -5
  52. package/dist/ui/sign-out-dialog.d.ts +17 -0
  53. package/dist/ui/sign-out-dialog.js +82 -0
  54. package/dist/ui/stat-group.d.ts +1 -1
  55. package/dist/ui/stat-group.js +6 -2
  56. package/dist/ui/stat.d.ts +24 -5
  57. package/dist/ui/stat.js +124 -19
  58. package/dist/ui/status-badge.d.ts +1 -1
  59. package/docs/designer/patrones.md +21 -0
  60. package/docs/designer/revision.md +8 -0
  61. package/package.json +187 -187
  62. package/scripts/brand-core.d.mts +2 -0
  63. package/scripts/brand-core.mjs +21 -1
  64. package/scripts/doctor.mjs +3 -0
  65. package/scripts/init.mjs +7 -3
@@ -0,0 +1,526 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { ArrowLeftIcon, Building2Icon, CheckIcon, CircleIcon, MailCheckIcon } from "lucide-react";
4
+ import * as React from "react";
5
+ import { useDsMessages } from "../hooks/use-ds-messages.js";
6
+ import {
7
+ authErrorMessage,
8
+ checkPassword,
9
+ formatCountdown,
10
+ isAuthErrorCode,
11
+ isValidEmail,
12
+ passwordScore,
13
+ useAuthCountdown
14
+ } from "../lib/auth.js";
15
+ import { dsFormat } from "../lib/i18n.js";
16
+ import { dsWarn } from "../lib/presets.js";
17
+ import { cn } from "../lib/utils.js";
18
+ import { AuthAnchor, AuthDivider, AuthError, AuthHeader, AuthPasskeyButton, AuthProviders, AuthStagger } from "./auth-parts.js";
19
+ import { Button } from "./button.js";
20
+ import { Checkbox } from "./checkbox.js";
21
+ import { IconTile } from "./icon-tile.js";
22
+ import { Input } from "./input.js";
23
+ import { InputOTP, InputOTPGroup, InputOTPSlot } from "./input-otp.js";
24
+ import { Label } from "./label.js";
25
+ import { PasswordInput } from "./password-input.js";
26
+ import { PasswordStrength } from "./password-strength.js";
27
+ import { Spinner } from "./spinner.js";
28
+ const PRESETS = {
29
+ "sign-in": { fields: ["identifier", "password"], identifierFirst: false, afterSubmit: null, strength: false },
30
+ social: { fields: [], identifierFirst: false, afterSubmit: null, strength: false },
31
+ "sign-up": { fields: ["name", "identifier", "password", "terms"], identifierFirst: false, afterSubmit: null, strength: true },
32
+ "magic-link": { fields: ["identifier"], identifierFirst: false, afterSubmit: "sent", strength: false },
33
+ "email-code": { fields: ["identifier"], identifierFirst: false, afterSubmit: "code", strength: false },
34
+ sso: { fields: ["identifier"], identifierFirst: false, afterSubmit: "redirecting", strength: false },
35
+ "forgot-password": { fields: ["identifier"], identifierFirst: false, afterSubmit: "sent", strength: false },
36
+ "reset-password": { fields: ["password", "confirmPassword"], identifierFirst: false, afterSubmit: null, strength: true }
37
+ };
38
+ function AuthForm({
39
+ preset = "sign-in",
40
+ title,
41
+ description,
42
+ icon,
43
+ identifier = "email",
44
+ defaultIdentifier = "",
45
+ identifierFirst,
46
+ onIdentify,
47
+ fields,
48
+ extraFields,
49
+ passwordRules,
50
+ showStrength,
51
+ remember = false,
52
+ providers,
53
+ onProvider,
54
+ providersPlacement = "top",
55
+ providersLayout,
56
+ onPasskey,
57
+ onSso,
58
+ ssoBy = "email",
59
+ lastUsed,
60
+ onSubmit,
61
+ onVerifyCode,
62
+ onResend,
63
+ resendAfter = 30,
64
+ codeLength = 6,
65
+ error: errorProp,
66
+ fieldErrors: fieldErrorsProp,
67
+ links = {},
68
+ submitLabel,
69
+ footer,
70
+ className,
71
+ ...props
72
+ }) {
73
+ const t = useDsMessages();
74
+ const d = PRESETS[preset];
75
+ const list = fields ?? d.fields;
76
+ const stepFirst = preset === "sign-in" && (identifierFirst ?? d.identifierFirst);
77
+ const strength = showStrength ?? d.strength;
78
+ const uid = React.useId();
79
+ const ids = (f) => `${uid}-${f}`;
80
+ const [view, setView] = React.useState(preset === "sso" ? "sso" : "form");
81
+ const [values, setValues] = React.useState({ identifier: defaultIdentifier, password: "", name: "", confirmPassword: "", remember: false, terms: false });
82
+ const [code, setCode] = React.useState("");
83
+ const [errors, setErrors] = React.useState({});
84
+ const [error, setError] = React.useState(null);
85
+ const [fails, setFails] = React.useState(0);
86
+ const [pending, setPending] = React.useState(null);
87
+ const [organizations, setOrganizations] = React.useState([]);
88
+ const countdown = useAuthCountdown(0);
89
+ const formRef = React.useRef(null);
90
+ if (preset === "sign-up" && !list.includes("identifier")) dsWarn("AuthForm", 'preset "sign-up" without "identifier" in `fields`.');
91
+ if (preset === "email-code" && !onVerifyCode) dsWarn("AuthForm", 'preset "email-code" expects `onVerifyCode`.');
92
+ if (preset === "sso" && !onSso) dsWarn("AuthForm", 'preset "sso" expects `onSso`.');
93
+ const shownError = errorProp ?? error;
94
+ const fieldError = (f) => fieldErrorsProp?.[f] ?? errors[f];
95
+ const text = (m) => isAuthErrorCode(m) ? authErrorMessage(t, m) : m;
96
+ const set = (key, value) => {
97
+ setValues((v) => ({ ...v, [key]: value }));
98
+ if (errors[key]) setErrors((e) => ({ ...e, [key]: void 0 }));
99
+ };
100
+ const focusField = (f) => requestAnimationFrame(() => document.getElementById(ids(f))?.focus());
101
+ const go = (next) => {
102
+ setView(next);
103
+ setError(null);
104
+ if (next === "password") focusField("password");
105
+ if (next === "code") focusField("code");
106
+ if (next === "sent" || next === "code") countdown.start(resendAfter);
107
+ };
108
+ async function run(key, task) {
109
+ setPending(key);
110
+ setError(null);
111
+ try {
112
+ return await task();
113
+ } catch {
114
+ setError("network");
115
+ return void 0;
116
+ } finally {
117
+ setPending(null);
118
+ }
119
+ }
120
+ const apply = (result, fallback) => {
121
+ if (result && (result.error || result.fieldErrors)) {
122
+ if (result.error) {
123
+ setError(result.error);
124
+ setFails((n) => n + 1);
125
+ }
126
+ if (result.fieldErrors) {
127
+ setErrors(result.fieldErrors);
128
+ const first = Object.keys(result.fieldErrors)[0];
129
+ if (first) focusField(first);
130
+ }
131
+ return;
132
+ }
133
+ const next = result?.next ?? fallback;
134
+ if (next) go(next);
135
+ };
136
+ const visibleFields = view === "password" ? ["password"] : view === "sso" ? ["identifier"] : stepFirst && view === "form" ? ["identifier"] : list;
137
+ function validate() {
138
+ const next = {};
139
+ for (const f of visibleFields) {
140
+ if (f === "identifier") {
141
+ if (!values.identifier.trim()) next.identifier = t.authRequired;
142
+ else if ((view === "sso" ? ssoBy === "email" : identifier === "email") && !isValidEmail(values.identifier)) next.identifier = t.authInvalidEmail;
143
+ }
144
+ if (f === "name" && !values.name.trim()) next.name = t.authRequired;
145
+ if (f === "password") {
146
+ if (!values.password) next.password = t.authRequired;
147
+ else if (preset !== "sign-in" && !checkPassword(values.password, passwordRules).valid) next.password = authErrorMessage(t, "weak-password");
148
+ }
149
+ if (f === "confirmPassword" && values.confirmPassword !== values.password) next.confirmPassword = t.authPasswordMismatch;
150
+ if (f === "terms" && !values.terms) next.terms = t.authTermsRequired;
151
+ }
152
+ setErrors(next);
153
+ const first = visibleFields.find((f) => next[f]);
154
+ if (first) {
155
+ focusField(first);
156
+ return false;
157
+ }
158
+ return true;
159
+ }
160
+ async function startSso(organization) {
161
+ if (!onSso) return;
162
+ const result = await run("sso", () => onSso({ identifier: values.identifier.trim(), organization }));
163
+ if (result && "organizations" in result && result.organizations?.length) {
164
+ setOrganizations(result.organizations);
165
+ setView("organizations");
166
+ return;
167
+ }
168
+ apply(result, "redirecting");
169
+ }
170
+ async function handleSubmit(event) {
171
+ event.preventDefault();
172
+ if (pending || !validate()) return;
173
+ if (view === "sso") return startSso();
174
+ if (stepFirst && view === "form") {
175
+ if (!onIdentify) return go("password");
176
+ const route = await run("identify", () => onIdentify(values.identifier.trim()));
177
+ if (!route) return go("password");
178
+ if (route.error) return setError(route.error);
179
+ if (route.method === "sso") {
180
+ if (route.organizations && route.organizations.length > 1) {
181
+ setOrganizations(route.organizations);
182
+ return setView("organizations");
183
+ }
184
+ return startSso(route.organizations?.[0]?.id);
185
+ }
186
+ if (route.method === "passkey" && onPasskey) {
187
+ const r = await run("passkey", onPasskey);
188
+ return apply(r ?? void 0, null);
189
+ }
190
+ if (route.method === "email-code" || route.method === "magic-link") {
191
+ const r = await run("submit", () => onSubmit?.(collect()));
192
+ return apply(r ?? void 0, route.method === "email-code" ? "code" : "sent");
193
+ }
194
+ return go("password");
195
+ }
196
+ const result = await run("submit", () => onSubmit?.(collect()));
197
+ apply(result ?? void 0, d.afterSubmit);
198
+ }
199
+ const collect = () => ({
200
+ ...values,
201
+ identifier: values.identifier.trim(),
202
+ formData: formRef.current ? new FormData(formRef.current) : new FormData()
203
+ });
204
+ async function verify(value) {
205
+ if (!onVerifyCode || pending) return;
206
+ const result = await run("verify", () => onVerifyCode(value, { identifier: values.identifier.trim() }));
207
+ if (result && (result.error || result.fieldErrors)) {
208
+ setCode("");
209
+ focusField("code");
210
+ }
211
+ apply(result ?? void 0, null);
212
+ }
213
+ async function resend() {
214
+ if (countdown.running || !onResend) return;
215
+ await run("resend", () => onResend({ identifier: values.identifier.trim() }));
216
+ countdown.start(resendAfter);
217
+ }
218
+ const identifierLabel = view === "sso" && ssoBy === "organization" ? t.authOrganization : view === "sso" ? t.authWorkEmail : identifier === "email" ? t.authEmail : identifier === "username" ? t.authUsername : t.authEmailOrUsername;
219
+ const errorOf = (f) => {
220
+ const e = fieldError(f);
221
+ return e ? /* @__PURE__ */ jsx("p", { id: ids(`${f}-error`), "data-slot": "auth-form-field-error", className: "animate-ds-auth-reveal text-sm text-destructive", children: text(e) }, String(e)) : null;
222
+ };
223
+ const aria = (f, extra) => ({
224
+ id: ids(f),
225
+ "aria-invalid": fieldError(f) ? true : void 0,
226
+ "aria-describedby": [fieldError(f) ? ids(`${f}-error`) : null, extra].filter(Boolean).join(" ") || void 0
227
+ });
228
+ const fieldWrap = (f, children) => /* @__PURE__ */ jsxs("div", { "data-slot": "auth-form-field", "data-field": f, "data-invalid": fieldError(f) ? "" : void 0, className: "flex flex-col gap-2", children: [
229
+ children,
230
+ errorOf(f)
231
+ ] }, f);
232
+ const rules = checkPassword(values.password, passwordRules);
233
+ const ruleItems = [
234
+ { key: "minLength", label: dsFormat(t.authRuleMinLength, { n: rules.rules.minLength }), on: true },
235
+ { key: "lowercase", label: t.authRuleLowercase, on: rules.rules.lowercase },
236
+ { key: "uppercase", label: t.authRuleUppercase, on: rules.rules.uppercase },
237
+ { key: "number", label: t.authRuleNumber, on: rules.rules.number },
238
+ { key: "symbol", label: t.authRuleSymbol, on: rules.rules.symbol }
239
+ ].filter((r) => r.on);
240
+ const isNew = preset === "sign-up" || preset === "reset-password";
241
+ function renderField(f) {
242
+ switch (f) {
243
+ case "identifier": {
244
+ const passkeyAutofill = onPasskey && preset === "sign-in" ? " webauthn" : "";
245
+ const isEmail = view === "sso" ? ssoBy === "email" : identifier === "email";
246
+ return fieldWrap(
247
+ f,
248
+ /* @__PURE__ */ jsxs(Fragment, { children: [
249
+ /* @__PURE__ */ jsx(Label, { htmlFor: ids(f), children: identifierLabel }),
250
+ /* @__PURE__ */ jsx(
251
+ Input,
252
+ {
253
+ ...aria(f),
254
+ name: view === "sso" && ssoBy === "organization" ? "organization" : identifier === "username" ? "username" : "email",
255
+ type: isEmail ? "email" : "text",
256
+ inputMode: isEmail ? "email" : void 0,
257
+ autoComplete: view === "sso" && ssoBy === "organization" ? "organization" : `${identifier === "username" ? "username" : isEmail ? "email" : "username"}${passkeyAutofill}`,
258
+ autoCapitalize: "none",
259
+ spellCheck: false,
260
+ autoFocus: !values.identifier,
261
+ value: values.identifier,
262
+ onChange: (e) => set("identifier", e.target.value)
263
+ }
264
+ )
265
+ ] })
266
+ );
267
+ }
268
+ case "name":
269
+ return fieldWrap(
270
+ f,
271
+ /* @__PURE__ */ jsxs(Fragment, { children: [
272
+ /* @__PURE__ */ jsx(Label, { htmlFor: ids(f), children: t.authName }),
273
+ /* @__PURE__ */ jsx(Input, { ...aria(f), name: "name", autoComplete: "name", value: values.name, onChange: (e) => set("name", e.target.value) })
274
+ ] })
275
+ );
276
+ case "password":
277
+ return fieldWrap(
278
+ f,
279
+ /* @__PURE__ */ jsxs(Fragment, { children: [
280
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
281
+ /* @__PURE__ */ jsx(Label, { htmlFor: ids(f), children: isNew ? t.authNewPassword : t.authPassword }),
282
+ preset === "sign-in" && links.forgotPassword ? /* @__PURE__ */ jsx(AuthAnchor, { to: links.forgotPassword, className: "text-sm", children: t.authForgotLink }) : null
283
+ ] }),
284
+ /* @__PURE__ */ jsx(
285
+ PasswordInput,
286
+ {
287
+ ...aria(f, isNew ? ids("rules") : void 0),
288
+ name: "password",
289
+ autoComplete: isNew ? "new-password" : "current-password",
290
+ value: values.password,
291
+ onChange: (e) => set("password", e.target.value)
292
+ }
293
+ ),
294
+ isNew ? /* @__PURE__ */ jsxs("div", { id: ids("rules"), "data-slot": "auth-form-rules", className: "flex flex-col gap-2", children: [
295
+ strength && values.password ? /* @__PURE__ */ jsx(PasswordStrength, { value: passwordScore(values.password) }) : null,
296
+ /* @__PURE__ */ jsx("ul", { "aria-label": t.authPasswordRules, className: "grid gap-1 text-xs @[22rem]/auth-form:grid-cols-2", children: ruleItems.map((r) => {
297
+ const ok = rules.checks[r.key];
298
+ return /* @__PURE__ */ jsxs(
299
+ "li",
300
+ {
301
+ "data-met": ok || void 0,
302
+ className: cn("flex items-center gap-1.5 transition-colors duration-(--ds-motion-fast)", ok ? "text-[color:var(--ds-on-soft,var(--success))]" : "text-muted-foreground"),
303
+ children: [
304
+ ok ? /* @__PURE__ */ jsx(CheckIcon, { "aria-hidden": "true", className: "size-3.5" }) : /* @__PURE__ */ jsx(CircleIcon, { "aria-hidden": "true", className: "size-3.5" }),
305
+ /* @__PURE__ */ jsx("span", { children: r.label }),
306
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: ok ? t.authRuleMet : t.authRulePending })
307
+ ]
308
+ },
309
+ r.key
310
+ );
311
+ }) })
312
+ ] }) : null
313
+ ] })
314
+ );
315
+ case "confirmPassword":
316
+ return fieldWrap(
317
+ f,
318
+ /* @__PURE__ */ jsxs(Fragment, { children: [
319
+ /* @__PURE__ */ jsx(Label, { htmlFor: ids(f), children: t.authConfirmPassword }),
320
+ /* @__PURE__ */ jsx(PasswordInput, { ...aria(f), name: "confirmPassword", autoComplete: "new-password", value: values.confirmPassword, onChange: (e) => set("confirmPassword", e.target.value) })
321
+ ] })
322
+ );
323
+ case "terms":
324
+ return fieldWrap(
325
+ f,
326
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2.5", children: [
327
+ /* @__PURE__ */ jsx(
328
+ Checkbox,
329
+ {
330
+ id: ids(f),
331
+ name: "terms",
332
+ checked: values.terms,
333
+ onCheckedChange: (v) => set("terms", v === true),
334
+ "aria-invalid": fieldError(f) ? true : void 0,
335
+ "aria-describedby": fieldError(f) ? ids(`${f}-error`) : void 0,
336
+ className: "mt-0.5"
337
+ }
338
+ ),
339
+ /* @__PURE__ */ jsxs(Label, { htmlFor: ids(f), className: "inline text-sm leading-snug font-normal text-muted-foreground", children: [
340
+ t.authTermsAccept,
341
+ " ",
342
+ links.terms ? /* @__PURE__ */ jsx(AuthAnchor, { to: links.terms, children: t.authTermsLink }) : t.authTermsLink,
343
+ links.privacy ? /* @__PURE__ */ jsxs(Fragment, { children: [
344
+ " ",
345
+ t.authAnd,
346
+ " ",
347
+ /* @__PURE__ */ jsx(AuthAnchor, { to: links.privacy, children: t.authPrivacyLink })
348
+ ] }) : null
349
+ ] })
350
+ ] })
351
+ );
352
+ default:
353
+ return null;
354
+ }
355
+ }
356
+ const head = {
357
+ "sign-in": [t.authSignInTitle, t.authSignInDescription],
358
+ social: [t.authSignInTitle, t.authSocialDescription],
359
+ "sign-up": [t.authSignUpTitle, t.authSignUpDescription],
360
+ "magic-link": [t.authMagicLinkTitle, t.authMagicLinkDescription],
361
+ "email-code": [t.authEmailCodeTitle, t.authEmailCodeDescription],
362
+ sso: [t.authSsoTitle, ssoBy === "organization" ? t.authSsoOrgDescription : t.authSsoDescription],
363
+ "forgot-password": [t.authForgotTitle, t.authForgotDescription],
364
+ "reset-password": [t.authResetTitle, t.authResetDescription]
365
+ };
366
+ const submitText = {
367
+ "sign-in": t.authSignInSubmit,
368
+ social: t.authContinue,
369
+ "sign-up": t.authSignUpSubmit,
370
+ "magic-link": t.authSendLink,
371
+ "email-code": t.authSendCode,
372
+ sso: t.authSsoSubmit,
373
+ "forgot-password": t.authSendReset,
374
+ "reset-password": t.authResetSubmit
375
+ };
376
+ const email = values.identifier.trim();
377
+ const providersBlock = (providers?.length || onPasskey) && view === "form" && (preset === "sign-in" || preset === "social" || preset === "sign-up") ? /* @__PURE__ */ jsxs(AuthStagger, { index: providersPlacement === "top" ? 1 : 3, className: "flex flex-col gap-2", children: [
378
+ providers?.length ? /* @__PURE__ */ jsx(AuthProviders, { providers, onProvider: (id) => void run(id, async () => apply(await onProvider?.(id) ?? void 0, null)), pending, lastUsed, layout: providersLayout ?? (preset === "social" ? "stack" : void 0) }) : null,
379
+ onPasskey && (preset === "sign-in" || preset === "social") ? /* @__PURE__ */ jsx(AuthPasskeyButton, { pending: pending === "passkey", disabled: pending != null && pending !== "passkey", lastUsed: lastUsed === "passkey", onClick: () => void run("passkey", async () => apply(await onPasskey() ?? void 0, null)) }) : null
380
+ ] }) : null;
381
+ const divider = providersBlock && preset !== "social" ? /* @__PURE__ */ jsx(AuthStagger, { index: 2, children: /* @__PURE__ */ jsx(AuthDivider, {}) }) : null;
382
+ const backToForm = /* @__PURE__ */ jsxs(Button, { type: "button", variant: "ghost", size: "sm", className: "self-start", onClick: () => go(preset === "sso" ? "sso" : "form"), children: [
383
+ /* @__PURE__ */ jsx(ArrowLeftIcon, {}),
384
+ t.authUseDifferentEmail
385
+ ] });
386
+ let content;
387
+ if (view === "sent") {
388
+ content = /* @__PURE__ */ jsxs(Fragment, { children: [
389
+ /* @__PURE__ */ jsx(
390
+ AuthHeader,
391
+ {
392
+ icon: /* @__PURE__ */ jsx(IconTile, { tone: "primary", size: "lg", children: /* @__PURE__ */ jsx(MailCheckIcon, {}) }),
393
+ title: t.authCheckEmailTitle,
394
+ description: dsFormat(preset === "forgot-password" ? t.authResetSentBody : t.authLinkSentBody, { email })
395
+ }
396
+ ),
397
+ /* @__PURE__ */ jsx(AuthError, { error: shownError }),
398
+ /* @__PURE__ */ jsxs(AuthStagger, { index: 1, className: "flex flex-col gap-3", children: [
399
+ onResend ? /* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", className: "w-full", disabled: countdown.running || pending != null, onClick: resend, children: [
400
+ pending === "resend" ? /* @__PURE__ */ jsx(Spinner, {}) : null,
401
+ countdown.running ? dsFormat(t.authResendIn, { time: formatCountdown(countdown.left) }) : t.authResend
402
+ ] }) : null,
403
+ backToForm
404
+ ] })
405
+ ] });
406
+ } else if (view === "code") {
407
+ content = /* @__PURE__ */ jsxs(Fragment, { children: [
408
+ /* @__PURE__ */ jsx(AuthHeader, { title: t.authCheckEmailTitle, description: dsFormat(t.authCodeSentBody, { email }) }),
409
+ /* @__PURE__ */ jsx(AuthError, { error: shownError }),
410
+ /* @__PURE__ */ jsxs(AuthStagger, { index: 1, className: "flex flex-col items-center gap-4", children: [
411
+ /* @__PURE__ */ jsx(Label, { htmlFor: ids("code"), className: "sr-only", children: t.authCode }),
412
+ /* @__PURE__ */ jsx("div", { "data-slot": "auth-form-code", className: cn(fails > 0 && "animate-ds-auth-shake"), children: /* @__PURE__ */ jsx(
413
+ InputOTP,
414
+ {
415
+ id: ids("code"),
416
+ maxLength: codeLength,
417
+ value: code,
418
+ onChange: setCode,
419
+ onComplete: verify,
420
+ autoComplete: "one-time-code",
421
+ inputMode: "numeric",
422
+ disabled: pending === "verify",
423
+ "aria-invalid": fieldError("code") || shownError ? true : void 0,
424
+ children: /* @__PURE__ */ jsx(InputOTPGroup, { children: Array.from({ length: codeLength }, (_, i) => /* @__PURE__ */ jsx(InputOTPSlot, { index: i }, i)) })
425
+ }
426
+ ) }, fails),
427
+ errorOf("code"),
428
+ /* @__PURE__ */ jsxs(Button, { type: "button", className: "w-full", disabled: code.length < codeLength || pending != null, onClick: () => verify(code), children: [
429
+ pending === "verify" ? /* @__PURE__ */ jsx(Spinner, {}) : null,
430
+ t.authVerify
431
+ ] }),
432
+ onResend ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "link", size: "sm", disabled: countdown.running || pending != null, onClick: resend, children: countdown.running ? dsFormat(t.authResendIn, { time: formatCountdown(countdown.left) }) : t.authResend }) : null,
433
+ backToForm
434
+ ] })
435
+ ] });
436
+ } else if (view === "organizations") {
437
+ content = /* @__PURE__ */ jsxs(Fragment, { children: [
438
+ /* @__PURE__ */ jsx(AuthHeader, { title: t.authChooseOrganization, description: email }),
439
+ /* @__PURE__ */ jsx(AuthError, { error: shownError }),
440
+ /* @__PURE__ */ jsx(AuthStagger, { index: 1, children: /* @__PURE__ */ jsx("ul", { "data-slot": "auth-form-organizations", className: "flex flex-col gap-2", children: organizations.map((o) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
441
+ "button",
442
+ {
443
+ type: "button",
444
+ disabled: pending != null,
445
+ onClick: () => startSso(o.id),
446
+ className: "flex w-full items-center gap-3 rounded-(--ds-auth-radius) border border-(--ds-auth-border) p-3 text-start 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) disabled:opacity-(--ds-disabled-opacity)",
447
+ children: [
448
+ o.icon ?? /* @__PURE__ */ jsx(IconTile, { size: "sm", children: /* @__PURE__ */ jsx(Building2Icon, {}) }),
449
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [
450
+ /* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium", children: o.label }),
451
+ o.description ? /* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: o.description }) : null
452
+ ] }),
453
+ pending === "sso" ? /* @__PURE__ */ jsx(Spinner, {}) : null
454
+ ]
455
+ }
456
+ ) }, o.id)) }) }),
457
+ backToForm
458
+ ] });
459
+ } else if (view === "redirecting") {
460
+ content = /* @__PURE__ */ jsxs("div", { "data-slot": "auth-form-redirecting", role: "status", className: "flex flex-col items-center gap-4 py-6 text-center", children: [
461
+ /* @__PURE__ */ jsx(Spinner, { className: "size-6" }),
462
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t.authSsoRedirecting })
463
+ ] });
464
+ } else {
465
+ const ssoView = view === "sso";
466
+ const [hTitle, hDesc] = ssoView ? head.sso : head[preset];
467
+ content = /* @__PURE__ */ jsxs(Fragment, { children: [
468
+ /* @__PURE__ */ jsx(AuthHeader, { icon, title: title ?? hTitle, description: description ?? hDesc }),
469
+ providersPlacement === "top" ? /* @__PURE__ */ jsxs(Fragment, { children: [
470
+ providersBlock,
471
+ divider
472
+ ] }) : null,
473
+ preset === "social" && !ssoView ? /* @__PURE__ */ jsx(AuthError, { error: shownError }) : /* @__PURE__ */ jsx(AuthStagger, { index: 3, children: /* @__PURE__ */ jsxs("form", { ref: formRef, noValidate: true, onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [
474
+ /* @__PURE__ */ jsx(AuthError, { error: shownError }),
475
+ view === "password" ? /* @__PURE__ */ jsxs("div", { "data-slot": "auth-form-identity", className: "flex items-center justify-between gap-2 rounded-(--ds-auth-radius) border border-(--ds-auth-border) px-3 py-2 text-sm", children: [
476
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: email }),
477
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "link", size: "sm", onClick: () => go("form"), children: t.authChange }),
478
+ /* @__PURE__ */ jsx("input", { type: "hidden", name: "username", autoComplete: "username", value: email })
479
+ ] }) : null,
480
+ visibleFields.map(renderField),
481
+ !ssoView && extraFields && !(stepFirst && view === "form") ? extraFields : null,
482
+ remember && preset === "sign-in" && !(stepFirst && view === "form") ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2.5", children: [
483
+ /* @__PURE__ */ jsx(Checkbox, { id: ids("remember"), name: "remember", checked: values.remember, onCheckedChange: (v) => set("remember", v === true) }),
484
+ /* @__PURE__ */ jsx(Label, { htmlFor: ids("remember"), className: "text-sm font-normal", children: t.authRemember })
485
+ ] }) : null,
486
+ /* @__PURE__ */ jsxs(Button, { type: "submit", className: "w-full", disabled: pending != null, "aria-busy": pending === "submit" || pending === "identify" || void 0, children: [
487
+ pending === "submit" || pending === "identify" || pending === "sso" ? /* @__PURE__ */ jsx(Spinner, {}) : null,
488
+ ssoView ? t.authSsoSubmit : stepFirst && view === "form" ? t.authContinue : submitLabel ?? submitText[preset]
489
+ ] })
490
+ ] }) }),
491
+ preset === "social" && !ssoView && links.email ? /* @__PURE__ */ jsx(AuthStagger, { index: 3, className: "flex justify-center", children: /* @__PURE__ */ jsx(AuthAnchor, { to: links.email, children: t.authContinueWithEmail }) }) : null,
492
+ providersPlacement === "bottom" ? /* @__PURE__ */ jsxs(Fragment, { children: [
493
+ divider,
494
+ providersBlock
495
+ ] }) : null,
496
+ (preset === "sign-in" || preset === "social") && onSso && !ssoView ? /* @__PURE__ */ jsx(AuthStagger, { index: 4, className: "flex justify-center", children: /* @__PURE__ */ jsxs(Button, { type: "button", variant: "ghost", size: "sm", "data-last-used": lastUsed === "sso" || void 0, onClick: () => go("sso"), children: [
497
+ /* @__PURE__ */ jsx(Building2Icon, {}),
498
+ t.authUseSso
499
+ ] }) }) : null,
500
+ ssoView && (preset === "sign-in" || preset === "social") ? /* @__PURE__ */ jsxs(Button, { type: "button", variant: "ghost", size: "sm", className: "self-center", onClick: () => go("form"), children: [
501
+ /* @__PURE__ */ jsx(ArrowLeftIcon, {}),
502
+ t.authBackToSignIn
503
+ ] }) : null
504
+ ] });
505
+ }
506
+ const footerLinks = footer ?? (view === "form" || view === "sso" ? (preset === "sign-in" || preset === "social") && links.signUp ? /* @__PURE__ */ jsxs(Fragment, { children: [
507
+ t.authNoAccount,
508
+ " ",
509
+ /* @__PURE__ */ jsx(AuthAnchor, { to: links.signUp, children: t.authSignUpLink })
510
+ ] }) : (preset === "sign-in" || preset === "social" || preset === "sso") && links.requestAccess ? /* @__PURE__ */ jsxs(Fragment, { children: [
511
+ t.authNoAccess,
512
+ " ",
513
+ /* @__PURE__ */ jsx(AuthAnchor, { to: links.requestAccess, children: t.authRequestAccessLink })
514
+ ] }) : preset === "sign-up" && links.signIn ? /* @__PURE__ */ jsxs(Fragment, { children: [
515
+ t.authHaveAccount,
516
+ " ",
517
+ /* @__PURE__ */ jsx(AuthAnchor, { to: links.signIn, children: t.authSignInLink })
518
+ ] }) : preset !== "sign-in" && preset !== "social" && preset !== "sign-up" && links.signIn ? /* @__PURE__ */ jsx(AuthAnchor, { to: links.signIn, children: t.authBackToSignIn }) : null : null);
519
+ return /* @__PURE__ */ jsxs("div", { "data-slot": "auth-form", "data-preset": preset, "data-view": view, className: cn("@container/auth-form flex flex-col gap-(--ds-auth-gap)", className), ...props, children: [
520
+ content,
521
+ footerLinks ? /* @__PURE__ */ jsx(AuthStagger, { index: 5, "data-slot": "auth-form-footer", className: "text-center text-sm text-muted-foreground", children: footerLinks }) : null
522
+ ] });
523
+ }
524
+ export {
525
+ AuthForm
526
+ };
@@ -0,0 +1,70 @@
1
+ import * as React from 'react';
2
+ import { AuthBackdropVariant } from './auth-backdrop.js';
3
+
4
+ type AuthLayoutPreset = "centered" | "split" | "cover" | "banner" | "minimal";
5
+ type AuthSurface = "solid" | "glass" | "elevated" | "plain";
6
+ type AuthShape = "rounded" | "soft" | "sharp";
7
+ type AuthMotion = "full" | "entrance" | "off";
8
+ /** Movimiento de la pantalla de acceso (para que el contenido anime igual que la maqueta). */
9
+ declare function useAuthMotion(): AuthMotion;
10
+ /** Cómo se tiñe una imagen o vídeo de fondo con la marca: none = tal cual · brand = tono del
11
+ * primario (conserva luces y sombras) · duotone = blanco y negro en dos tintas de la paleta. */
12
+ type AuthMediaTint = "none" | "brand" | "duotone";
13
+ declare function AuthLayout({ preset, surface, shape, backdrop, backdropMedia, backdropGlass, asideBackdrop, interactive, motion, side, logo, aside, media, mediaTint, toolbar, footer, className, children, ...props }: React.ComponentProps<"div"> & {
14
+ preset?: AuthLayoutPreset;
15
+ /** Superficie de la tarjeta. */
16
+ surface?: AuthSurface;
17
+ /** Forma de la tarjeta. */
18
+ shape?: AuthShape;
19
+ /** Fondo animado del lienzo. */
20
+ backdrop?: AuthBackdropVariant;
21
+ /** backdrop="image": la foto o el vídeo del lienzo (si falta, usa `media`). Se tiñe con `mediaTint`. */
22
+ backdropMedia?: React.ReactNode;
23
+ /** Cristal esmerilado sobre el fondo del lienzo («mesh + glass», «image + glass»). */
24
+ backdropGlass?: boolean;
25
+ /** Fondo animado del panel de marca (split, banner). */
26
+ asideBackdrop?: AuthBackdropVariant;
27
+ /** Foco que sigue al puntero en el fondo. */
28
+ interactive?: boolean;
29
+ /** full = fondo animado y entrada · entrance = solo la entrada · off = quieto. */
30
+ motion?: AuthMotion;
31
+ /** split: lado del panel de marca · cover: lado de la tarjeta. */
32
+ side?: "start" | "end";
33
+ /** Logo de la app (imagen o SVG; su alto lo fija --ds-auth-logo-h). */
34
+ logo?: React.ReactNode;
35
+ /** Panel de marca (split, banner): normalmente <AuthAside>. */
36
+ aside?: React.ReactNode;
37
+ /** cover: imagen o vídeo de fondo (la app lo pone; se recorta a pantalla completa). */
38
+ media?: React.ReactNode;
39
+ /** cover: tinte de marca sobre `media` (la foto se adapta al color de la marca). */
40
+ mediaTint?: AuthMediaTint;
41
+ /** Esquina superior: idioma y tema, siempre visibles. */
42
+ toolbar?: React.ReactNode;
43
+ /** Pie: enlaces legales, versión, soporte. */
44
+ footer?: React.ReactNode;
45
+ }): React.JSX.Element;
46
+ declare function AuthAside({ logo, backdrop, media, mediaTint, className, children, ...props }: React.ComponentProps<"aside"> & {
47
+ /** Logo arriba del panel (en split, la maqueta lo quita del formulario en ancho). */
48
+ logo?: React.ReactNode;
49
+ /** Fondo animado del panel (por defecto, el del preset). */
50
+ backdrop?: AuthBackdropVariant;
51
+ /** Imagen o vídeo del panel (sustituye al degradado; el texto se lee sobre un velo de la marca). */
52
+ media?: React.ReactNode;
53
+ /** Tinte de marca sobre `media` (por defecto brand: la foto toma el color de la marca). */
54
+ mediaTint?: AuthMediaTint;
55
+ }): React.JSX.Element;
56
+ declare function AuthAsideEyebrow({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
57
+ declare function AuthAsideTitle({ className, ...props }: React.ComponentProps<"h2">): React.JSX.Element;
58
+ declare function AuthAsideText({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
59
+ declare function AuthAsidePoints({ className, ...props }: React.ComponentProps<"ul">): React.JSX.Element;
60
+ declare function AuthAsidePoint({ icon, className, children, ...props }: React.ComponentProps<"li"> & {
61
+ icon?: React.ReactNode;
62
+ }): React.JSX.Element;
63
+ declare function AuthAsideQuote({ author, role, avatar, className, children, ...props }: React.ComponentProps<"figure"> & {
64
+ author?: React.ReactNode;
65
+ role?: React.ReactNode;
66
+ avatar?: React.ReactNode;
67
+ }): React.JSX.Element;
68
+ declare function AuthAsideFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
69
+
70
+ export { AuthAside, AuthAsideEyebrow, AuthAsideFooter, AuthAsidePoint, AuthAsidePoints, AuthAsideQuote, AuthAsideText, AuthAsideTitle, AuthLayout, type AuthLayoutPreset, type AuthMediaTint, type AuthMotion, type AuthShape, type AuthSurface, useAuthMotion };