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,283 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { dsWarn } from "../lib/presets.js";
5
+ import { cn } from "../lib/utils.js";
6
+ import { AuthBackdrop } from "./auth-backdrop.js";
7
+ const PRESETS = {
8
+ centered: { surface: "solid", backdrop: "glow", asideBackdrop: "rings" },
9
+ split: { surface: "plain", backdrop: "none", asideBackdrop: "rings" },
10
+ cover: { surface: "glass", backdrop: "none", asideBackdrop: "none" },
11
+ banner: { surface: "elevated", backdrop: "dots", asideBackdrop: "beams" },
12
+ minimal: { surface: "plain", backdrop: "none", asideBackdrop: "none" }
13
+ };
14
+ const AuthLayoutContext = React.createContext({ motion: "full", asideBackdrop: "rings", interactive: false });
15
+ function useAuthMotion() {
16
+ return React.useContext(AuthLayoutContext).motion;
17
+ }
18
+ const SURFACE = {
19
+ solid: "border border-(--ds-auth-border) bg-(--ds-auth-surface) text-(--ds-auth-surface-fg) shadow-(--ds-auth-shadow)",
20
+ elevated: "border border-(--ds-auth-border) bg-(--ds-auth-surface) text-(--ds-auth-surface-fg) shadow-(--ds-auth-shadow-elevated)",
21
+ glass: "border border-(--ds-auth-border) bg-(--ds-auth-glass) text-(--ds-auth-surface-fg) shadow-(--ds-auth-shadow-elevated) [backdrop-filter:var(--ds-auth-glass-filter)]",
22
+ plain: ""
23
+ };
24
+ const SHAPE = {
25
+ rounded: "rounded-(--ds-auth-radius)",
26
+ soft: "rounded-[calc(var(--ds-auth-radius)*2)]",
27
+ sharp: "rounded-none"
28
+ };
29
+ function AuthMedia({ tint = "none", veil, children }) {
30
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
31
+ /* @__PURE__ */ jsx(
32
+ "div",
33
+ {
34
+ "data-slot": "auth-media",
35
+ "data-tint": tint,
36
+ className: cn("absolute inset-0 -z-10 [&>*]:size-full [&>img]:object-cover [&>video]:object-cover", tint === "duotone" && "grayscale contrast-125"),
37
+ children
38
+ }
39
+ ),
40
+ tint === "brand" ? /* @__PURE__ */ jsx("div", { "aria-hidden": "true", className: "absolute inset-0 -z-10 bg-(--ds-auth-media-tint) mix-blend-color" }) : null,
41
+ tint === "duotone" ? /* @__PURE__ */ jsxs(Fragment, { children: [
42
+ /* @__PURE__ */ jsx("div", { "aria-hidden": "true", className: "absolute inset-0 -z-10 bg-(--ds-auth-media-duo-dark) mix-blend-screen" }),
43
+ /* @__PURE__ */ jsx("div", { "aria-hidden": "true", className: "absolute inset-0 -z-10 bg-(--ds-auth-media-duo-light) mix-blend-multiply" })
44
+ ] }) : null,
45
+ /* @__PURE__ */ jsx("div", { "aria-hidden": "true", className: cn("absolute inset-0 -z-10", veil) })
46
+ ] });
47
+ }
48
+ function AuthLayout({
49
+ preset = "centered",
50
+ surface,
51
+ shape = "rounded",
52
+ backdrop,
53
+ backdropMedia,
54
+ backdropGlass = false,
55
+ asideBackdrop,
56
+ interactive = false,
57
+ motion = "full",
58
+ side = "start",
59
+ logo,
60
+ aside,
61
+ media,
62
+ mediaTint = "none",
63
+ toolbar,
64
+ footer,
65
+ className,
66
+ children,
67
+ ...props
68
+ }) {
69
+ const base = PRESETS[preset];
70
+ const skin = surface ?? base.surface;
71
+ const fx = backdrop ?? base.backdrop;
72
+ const ctx = React.useMemo(
73
+ () => ({ motion, asideBackdrop: asideBackdrop ?? base.asideBackdrop, interactive }),
74
+ [motion, asideBackdrop, base.asideBackdrop, interactive]
75
+ );
76
+ if ((preset === "split" || preset === "banner") && !aside) dsWarn("AuthLayout", `preset "${preset}" expects an \`aside\` (brand panel).`);
77
+ if (preset === "cover" && !media) dsWarn("AuthLayout", 'preset "cover" expects `media` (image or video).');
78
+ if (fx === "image" && !(backdropMedia ?? media)) dsWarn("AuthLayout", 'backdrop="image" expects `backdropMedia` (image or video).');
79
+ const canvasFx = /* @__PURE__ */ jsx(
80
+ AuthBackdrop,
81
+ {
82
+ variant: fx,
83
+ media: backdropMedia ?? media,
84
+ mediaTint,
85
+ glass: backdropGlass,
86
+ interactive,
87
+ animated: motion === "full"
88
+ }
89
+ );
90
+ const enter = motion === "off" ? "" : "animate-ds-auth-enter motion-reduce:animate-none";
91
+ const brandLogo = logo ? /* @__PURE__ */ jsx("div", { "data-slot": "auth-layout-logo", className: "flex h-(--ds-auth-logo-h) items-center [&_img]:h-full [&_img]:w-auto [&_svg]:h-full [&_svg]:w-auto", children: logo }) : null;
92
+ const panel = /* @__PURE__ */ jsxs(
93
+ "div",
94
+ {
95
+ "data-slot": "auth-layout-panel",
96
+ className: cn(
97
+ "relative flex w-full max-w-(--ds-auth-max-w) flex-col gap-(--ds-auth-gap)",
98
+ skin !== "plain" && "p-(--ds-auth-p-sm) @[32rem]/auth:p-(--ds-auth-p)",
99
+ SURFACE[skin],
100
+ SHAPE[shape],
101
+ enter
102
+ ),
103
+ children: [
104
+ preset === "split" ? /* @__PURE__ */ jsx("div", { className: "@[56rem]/auth:hidden", children: brandLogo }) : preset === "banner" ? null : brandLogo,
105
+ children
106
+ ]
107
+ }
108
+ );
109
+ const chrome = /* @__PURE__ */ jsx(Fragment, { children: toolbar ? /* @__PURE__ */ jsx("div", { "data-slot": "auth-layout-toolbar", className: "absolute end-(--ds-auth-p-sm) top-(--ds-auth-p-sm) z-(--ds-z-raised) flex items-center gap-2", children: toolbar }) : null });
110
+ const foot = footer ? /* @__PURE__ */ jsx("footer", { "data-slot": "auth-layout-footer", className: "w-full max-w-(--ds-auth-max-w) text-center text-xs text-muted-foreground [&_a]:underline-offset-4 [&_a:hover]:underline", children: footer }) : null;
111
+ let body;
112
+ if (preset === "split") {
113
+ body = /* @__PURE__ */ jsxs("div", { className: "grid flex-1 @[56rem]/auth:grid-cols-[minmax(var(--ds-auth-aside-min-w),1fr)_minmax(0,1fr)]", children: [
114
+ /* @__PURE__ */ jsx("div", { className: cn("relative hidden @[56rem]/auth:flex", side === "end" && "@[56rem]/auth:order-last"), children: React.isValidElement(aside) ? aside : /* @__PURE__ */ jsx(AuthAside, { logo, children: aside }) }),
115
+ /* @__PURE__ */ jsxs("div", { className: "relative isolate flex flex-col items-center justify-center gap-(--ds-auth-gap) overflow-hidden px-(--ds-auth-p-sm) py-(--ds-auth-p)", children: [
116
+ canvasFx,
117
+ panel,
118
+ foot
119
+ ] })
120
+ ] });
121
+ } else if (preset === "banner") {
122
+ body = /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col items-center", children: [
123
+ /* @__PURE__ */ jsx("div", { className: "relative w-full", children: /* @__PURE__ */ jsx(AuthBanner, { logo, children: aside }) }),
124
+ /* @__PURE__ */ jsxs(
125
+ "div",
126
+ {
127
+ className: cn(
128
+ "relative isolate flex w-full flex-1 flex-col items-center gap-(--ds-auth-gap) px-(--ds-auth-p-sm) pb-(--ds-auth-p)",
129
+ // Sin superficie, el texto no puede montar sobre la franja: se pone debajo.
130
+ skin === "plain" ? "pt-(--ds-auth-p)" : "-mt-[calc(var(--ds-auth-banner-h)/2)]"
131
+ ),
132
+ children: [
133
+ panel,
134
+ foot
135
+ ]
136
+ }
137
+ )
138
+ ] });
139
+ } else if (preset === "cover") {
140
+ body = /* @__PURE__ */ jsxs(
141
+ "div",
142
+ {
143
+ className: cn(
144
+ "relative isolate flex flex-1 flex-col items-center justify-center gap-(--ds-auth-gap) overflow-hidden px-(--ds-auth-p-sm) py-(--ds-auth-p)",
145
+ "@[56rem]/auth:px-[calc(var(--ds-auth-p)*2)]",
146
+ side === "start" ? "@[56rem]/auth:items-start" : side === "end" ? "@[56rem]/auth:items-end" : ""
147
+ ),
148
+ children: [
149
+ /* @__PURE__ */ jsx(AuthMedia, { tint: mediaTint, veil: skin === "plain" ? "bg-(--ds-auth-media-overlay-plain)" : "bg-(--ds-auth-media-overlay)", children: media }),
150
+ canvasFx,
151
+ panel,
152
+ foot
153
+ ]
154
+ }
155
+ );
156
+ } else {
157
+ body = /* @__PURE__ */ jsxs("div", { className: "relative isolate flex flex-1 flex-col items-center justify-center gap-(--ds-auth-gap) overflow-hidden px-(--ds-auth-p-sm) py-(--ds-auth-p)", children: [
158
+ canvasFx,
159
+ panel,
160
+ foot
161
+ ] });
162
+ }
163
+ return /* @__PURE__ */ jsx(AuthLayoutContext.Provider, { value: ctx, children: /* @__PURE__ */ jsxs(
164
+ "div",
165
+ {
166
+ "data-slot": "auth-layout",
167
+ "data-preset": preset,
168
+ "data-surface": skin,
169
+ "data-shape": shape,
170
+ "data-motion": motion,
171
+ className: cn("@container/auth relative isolate flex min-h-(--ds-auth-min-h) flex-col bg-(--ds-auth-canvas) text-foreground", className),
172
+ ...props,
173
+ children: [
174
+ chrome,
175
+ body
176
+ ]
177
+ }
178
+ ) });
179
+ }
180
+ function AuthBanner({ logo, children }) {
181
+ const { motion, asideBackdrop, interactive } = React.useContext(AuthLayoutContext);
182
+ return /* @__PURE__ */ jsxs(
183
+ "div",
184
+ {
185
+ "data-slot": "auth-aside",
186
+ "data-placement": "banner",
187
+ className: "relative isolate flex h-(--ds-auth-banner-h) w-full items-start justify-center overflow-hidden bg-(--ds-auth-aside-bg) bg-(image:--ds-auth-aside-image) pt-(--ds-auth-p) text-(--ds-auth-aside-fg)",
188
+ children: [
189
+ /* @__PURE__ */ jsx(AuthBackdrop, { variant: asideBackdrop, ink: "brand", interactive, animated: motion === "full" }),
190
+ logo ? /* @__PURE__ */ jsx("div", { className: "flex h-(--ds-auth-logo-h) items-center [&_img]:h-full [&_svg]:h-full", children: logo }) : children
191
+ ]
192
+ }
193
+ );
194
+ }
195
+ function AuthAside({
196
+ logo,
197
+ backdrop,
198
+ media,
199
+ mediaTint = "brand",
200
+ className,
201
+ children,
202
+ ...props
203
+ }) {
204
+ const { motion, asideBackdrop, interactive } = React.useContext(AuthLayoutContext);
205
+ return /* @__PURE__ */ jsxs(
206
+ "aside",
207
+ {
208
+ "data-slot": "auth-aside",
209
+ className: cn(
210
+ "relative isolate flex w-full flex-col justify-between gap-(--ds-auth-gap) overflow-hidden p-[calc(var(--ds-auth-p)*1.5)]",
211
+ "bg-(--ds-auth-aside-bg) bg-(image:--ds-auth-aside-image) text-(--ds-auth-aside-fg)",
212
+ className
213
+ ),
214
+ ...props,
215
+ children: [
216
+ media ? /* @__PURE__ */ jsx(AuthMedia, { tint: mediaTint, veil: "bg-(--ds-auth-aside-media-overlay)", children: media }) : null,
217
+ /* @__PURE__ */ jsx(AuthBackdrop, { variant: backdrop ?? asideBackdrop, ink: "brand", interactive, animated: motion === "full" }),
218
+ logo ? /* @__PURE__ */ jsx("div", { "data-slot": "auth-aside-logo", className: "flex h-(--ds-auth-logo-h) items-center [&_img]:h-full [&_img]:w-auto [&_svg]:h-full [&_svg]:w-auto", children: logo }) : null,
219
+ /* @__PURE__ */ jsx("div", { className: "flex max-w-lg flex-col gap-4", children })
220
+ ]
221
+ }
222
+ );
223
+ }
224
+ function AuthAsideEyebrow({ className, ...props }) {
225
+ return /* @__PURE__ */ jsx("p", { "data-slot": "auth-aside-eyebrow", className: cn("text-xs font-semibold uppercase tracking-widest opacity-80", className), ...props });
226
+ }
227
+ function AuthAsideTitle({ className, ...props }) {
228
+ return /* @__PURE__ */ jsx("h2", { "data-slot": "auth-aside-title", className: cn("text-3xl font-semibold tracking-tight text-balance @[72rem]/auth:text-4xl", className), ...props });
229
+ }
230
+ function AuthAsideText({ className, ...props }) {
231
+ return /* @__PURE__ */ jsx("p", { "data-slot": "auth-aside-text", className: cn("text-base text-pretty opacity-85", className), ...props });
232
+ }
233
+ function AuthAsidePoints({ className, ...props }) {
234
+ return /* @__PURE__ */ jsx("ul", { "data-slot": "auth-aside-points", className: cn("flex flex-col gap-3 pt-2", className), ...props });
235
+ }
236
+ function AuthAsidePoint({ icon, className, children, ...props }) {
237
+ return /* @__PURE__ */ jsxs("li", { "data-slot": "auth-aside-point", className: cn("flex items-start gap-3 text-sm", className), ...props, children: [
238
+ icon ? /* @__PURE__ */ jsx("span", { className: "grid size-8 shrink-0 place-items-center rounded-control bg-[color-mix(in_oklch,var(--ds-auth-aside-fg)_14%,transparent)] [&_svg]:size-4", children: icon }) : null,
239
+ /* @__PURE__ */ jsx("span", { className: "pt-1.5", children })
240
+ ] });
241
+ }
242
+ function AuthAsideQuote({
243
+ author,
244
+ role,
245
+ avatar,
246
+ className,
247
+ children,
248
+ ...props
249
+ }) {
250
+ return /* @__PURE__ */ jsxs(
251
+ "figure",
252
+ {
253
+ "data-slot": "auth-aside-quote",
254
+ className: cn("flex flex-col gap-3 rounded-(--ds-auth-radius) border border-[color-mix(in_oklch,var(--ds-auth-aside-fg)_18%,transparent)] bg-[color-mix(in_oklch,var(--ds-auth-aside-fg)_8%,transparent)] p-5", className),
255
+ ...props,
256
+ children: [
257
+ /* @__PURE__ */ jsx("blockquote", { className: "text-base text-pretty", children }),
258
+ author ? /* @__PURE__ */ jsxs("figcaption", { className: "flex items-center gap-3 text-sm", children: [
259
+ avatar ? /* @__PURE__ */ jsx("span", { className: "size-8 shrink-0 overflow-hidden rounded-full [&_img]:size-full [&_img]:object-cover", children: avatar }) : null,
260
+ /* @__PURE__ */ jsxs("span", { className: "flex flex-col", children: [
261
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: author }),
262
+ role ? /* @__PURE__ */ jsx("span", { className: "opacity-80", children: role }) : null
263
+ ] })
264
+ ] }) : null
265
+ ]
266
+ }
267
+ );
268
+ }
269
+ function AuthAsideFooter({ className, ...props }) {
270
+ return /* @__PURE__ */ jsx("div", { "data-slot": "auth-aside-footer", className: cn("mt-auto text-xs opacity-80", className), ...props });
271
+ }
272
+ export {
273
+ AuthAside,
274
+ AuthAsideEyebrow,
275
+ AuthAsideFooter,
276
+ AuthAsidePoint,
277
+ AuthAsidePoints,
278
+ AuthAsideQuote,
279
+ AuthAsideText,
280
+ AuthAsideTitle,
281
+ AuthLayout,
282
+ useAuthMotion
283
+ };
@@ -0,0 +1,43 @@
1
+ import * as React from 'react';
2
+ import { AuthLink, AuthErrorCode, AuthProviderOption } from '../lib/auth.js';
3
+ import { Button } from './button.js';
4
+ import '../lib/i18n.js';
5
+ import 'class-variance-authority/types';
6
+ import '@base-ui/react/use-render';
7
+ import 'class-variance-authority';
8
+
9
+ /** Bloque que entra en cascada según el `motion` de AuthLayout (índice = orden). */
10
+ declare function AuthStagger({ index, className, style, ...props }: React.ComponentProps<"div"> & {
11
+ index?: number;
12
+ }): React.JSX.Element;
13
+ declare function AuthHeader({ icon, title, description, align, className, ...props }: Omit<React.ComponentProps<"div">, "title"> & {
14
+ icon?: React.ReactNode;
15
+ title: React.ReactNode;
16
+ description?: React.ReactNode;
17
+ align?: "start" | "center";
18
+ }): React.JSX.Element;
19
+ declare function AuthDivider({ children, className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
20
+ declare function AuthProviders({ providers, onProvider, pending, lastUsed, layout, className, ...props }: Omit<React.ComponentProps<"div">, "onSelect"> & {
21
+ providers: AuthProviderOption[];
22
+ onProvider?: (id: string) => void;
23
+ /** Proveedor en curso (muestra el spinner y bloquea los demás). */
24
+ pending?: string | null;
25
+ /** Último método usado en este dispositivo (lo guarda la app): lleva una etiqueta. */
26
+ lastUsed?: string | null;
27
+ /** stack = uno por fila con texto · grid = dos columnas · icons = solo iconos. Por defecto: stack hasta 2, grid desde 3. */
28
+ layout?: "stack" | "grid" | "icons";
29
+ }): React.JSX.Element;
30
+ declare function AuthPasskeyButton({ pending, lastUsed, variant, children, ...props }: React.ComponentProps<typeof Button> & {
31
+ pending?: boolean;
32
+ lastUsed?: boolean;
33
+ }): React.JSX.Element;
34
+ /** Error de acceso: un código (texto del catálogo) o un nodo de la app. Se anuncia (role="alert"). */
35
+ declare function AuthError({ error, className, ...props }: Omit<React.ComponentProps<"div">, "children"> & {
36
+ error?: AuthErrorCode | React.ReactNode;
37
+ }): React.JSX.Element | null;
38
+ /** Enlace de acceso: URL → <a>; función → botón con aspecto de enlace (router de la app). */
39
+ declare function AuthAnchor({ to, className, children, ...props }: Omit<React.ComponentProps<"a">, "href" | "onClick"> & {
40
+ to: AuthLink;
41
+ }): React.JSX.Element;
42
+
43
+ export { AuthAnchor, AuthDivider, AuthError, AuthHeader, AuthPasskeyButton, AuthProviders, AuthStagger };
@@ -0,0 +1,159 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { CircleAlertIcon, KeyRoundIcon } from "lucide-react";
4
+ import { useDsMessages } from "../hooks/use-ds-messages.js";
5
+ import { authErrorMessage, isAuthErrorCode } from "../lib/auth.js";
6
+ import { dsFormat } from "../lib/i18n.js";
7
+ import { cn } from "../lib/utils.js";
8
+ import { useAuthMotion } from "./auth-layout.js";
9
+ import { Button } from "./button.js";
10
+ import { Spinner } from "./spinner.js";
11
+ function AuthStagger({ index = 0, className, style, ...props }) {
12
+ const motion = useAuthMotion();
13
+ return /* @__PURE__ */ jsx(
14
+ "div",
15
+ {
16
+ "data-slot": "auth-stagger",
17
+ className: cn(motion !== "off" && "animate-ds-auth-enter motion-reduce:animate-none", className),
18
+ style: { ["--ds-auth-i"]: index, ...style },
19
+ ...props
20
+ }
21
+ );
22
+ }
23
+ function AuthHeader({
24
+ icon,
25
+ title,
26
+ description,
27
+ align = "start",
28
+ className,
29
+ ...props
30
+ }) {
31
+ return /* @__PURE__ */ jsxs(
32
+ AuthStagger,
33
+ {
34
+ "data-slot": "auth-header",
35
+ "data-align": align,
36
+ className: cn("flex flex-col gap-2", align === "center" && "items-center text-center", className),
37
+ ...props,
38
+ children: [
39
+ icon ? /* @__PURE__ */ jsx("div", { className: "mb-2", children: icon }) : null,
40
+ /* @__PURE__ */ jsx("h1", { className: "text-(length:--ds-auth-title-size) leading-tight font-semibold tracking-tight text-balance", children: title }),
41
+ description ? /* @__PURE__ */ jsx("p", { className: "text-sm text-pretty text-muted-foreground", children: description }) : null
42
+ ]
43
+ }
44
+ );
45
+ }
46
+ function AuthDivider({ children, className, ...props }) {
47
+ const t = useDsMessages();
48
+ return /* @__PURE__ */ jsxs("div", { "data-slot": "auth-divider", role: "separator", className: cn("flex items-center gap-3 text-xs text-muted-foreground uppercase", className), ...props, children: [
49
+ /* @__PURE__ */ jsx("span", { className: "h-px flex-1 bg-border" }),
50
+ /* @__PURE__ */ jsx("span", { children: children ?? t.authOr }),
51
+ /* @__PURE__ */ jsx("span", { className: "h-px flex-1 bg-border" })
52
+ ] });
53
+ }
54
+ function AuthProviders({
55
+ providers,
56
+ onProvider,
57
+ pending,
58
+ lastUsed,
59
+ layout,
60
+ className,
61
+ ...props
62
+ }) {
63
+ const t = useDsMessages();
64
+ const mode = layout ?? (providers.length <= 2 ? "stack" : "grid");
65
+ return /* @__PURE__ */ jsx(
66
+ "div",
67
+ {
68
+ "data-slot": "auth-providers",
69
+ "data-layout": mode,
70
+ className: cn(
71
+ "grid gap-2",
72
+ mode === "grid" && "@[22rem]/auth-form:grid-cols-2",
73
+ mode === "icons" && "grid-flow-col auto-cols-fr",
74
+ className
75
+ ),
76
+ ...props,
77
+ children: providers.map((p) => {
78
+ const busy = pending === p.id;
79
+ const last = lastUsed === p.id;
80
+ const label = typeof p.label === "string" ? dsFormat(t.authContinueWith, { provider: p.label }) : void 0;
81
+ return /* @__PURE__ */ jsxs(
82
+ Button,
83
+ {
84
+ type: "button",
85
+ variant: "outline",
86
+ "data-slot": "auth-provider",
87
+ "data-provider": p.id,
88
+ "data-last-used": last || void 0,
89
+ disabled: p.disabled || pending != null && !busy,
90
+ "aria-busy": busy || void 0,
91
+ "aria-label": mode === "icons" ? label : void 0,
92
+ title: mode === "icons" ? label : void 0,
93
+ onClick: () => onProvider?.(p.id),
94
+ className: "relative w-full justify-center",
95
+ children: [
96
+ busy ? /* @__PURE__ */ jsx(Spinner, {}) : p.icon,
97
+ mode === "icons" ? null : /* @__PURE__ */ jsx("span", { className: "truncate", children: p.label }),
98
+ last && mode !== "icons" ? /* @__PURE__ */ jsx("span", { "data-slot": "auth-last-used", className: "absolute -top-2 end-2 rounded-full border border-(--ds-auth-border) bg-(--ds-auth-surface) px-1.5 text-xs leading-4 text-muted-foreground", children: t.authLastUsed }) : null
99
+ ]
100
+ },
101
+ p.id
102
+ );
103
+ })
104
+ }
105
+ );
106
+ }
107
+ function AuthPasskeyButton({
108
+ pending,
109
+ lastUsed,
110
+ variant = "outline",
111
+ children,
112
+ ...props
113
+ }) {
114
+ const t = useDsMessages();
115
+ return /* @__PURE__ */ jsxs(Button, { type: "button", variant, "data-slot": "auth-passkey", "data-last-used": lastUsed || void 0, "aria-busy": pending || void 0, className: "relative w-full", ...props, children: [
116
+ pending ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsx(KeyRoundIcon, {}),
117
+ children ?? t.authPasskey,
118
+ lastUsed ? /* @__PURE__ */ jsx("span", { "data-slot": "auth-last-used", className: "absolute -top-2 end-2 rounded-full border border-(--ds-auth-border) bg-(--ds-auth-surface) px-1.5 text-xs leading-4 text-muted-foreground", children: t.authLastUsed }) : null
119
+ ] });
120
+ }
121
+ function AuthError({ error, className, ...props }) {
122
+ const t = useDsMessages();
123
+ if (error == null || error === false || error === "") return null;
124
+ const text = isAuthErrorCode(error) ? authErrorMessage(t, error) : error;
125
+ return /* @__PURE__ */ jsxs(
126
+ "div",
127
+ {
128
+ role: "alert",
129
+ "data-slot": "auth-error",
130
+ "data-code": isAuthErrorCode(error) ? error : void 0,
131
+ className: cn(
132
+ "flex items-start gap-2 rounded-(--ds-radius-alert) border border-danger/30 bg-[color:var(--ds-alert-bg,var(--danger-soft))] px-3 py-2.5 text-sm text-[color:var(--ds-on-soft,var(--danger))]",
133
+ "animate-ds-auth-enter motion-reduce:animate-none [&_svg]:mt-0.5 [&_svg]:size-4 [&_svg]:shrink-0",
134
+ className
135
+ ),
136
+ ...props,
137
+ children: [
138
+ /* @__PURE__ */ jsx(CircleAlertIcon, { "aria-hidden": "true" }),
139
+ /* @__PURE__ */ jsx("div", { className: "min-w-0", children: text })
140
+ ]
141
+ }
142
+ );
143
+ }
144
+ function AuthAnchor({ to, className, children, ...props }) {
145
+ const cls = cn("font-medium text-link underline-offset-4 outline-none hover:underline focus-visible:underline focus-visible:ring-(length:--ds-ring-width) focus-visible:ring-(--ds-ring-color) rounded-xs", className);
146
+ if (typeof to === "string") {
147
+ return /* @__PURE__ */ jsx("a", { "data-slot": "auth-anchor", href: to, className: cls, ...props, children });
148
+ }
149
+ return /* @__PURE__ */ jsx("button", { type: "button", "data-slot": "auth-anchor", onClick: to, className: cls, children });
150
+ }
151
+ export {
152
+ AuthAnchor,
153
+ AuthDivider,
154
+ AuthError,
155
+ AuthHeader,
156
+ AuthPasskeyButton,
157
+ AuthProviders,
158
+ AuthStagger
159
+ };
@@ -0,0 +1,23 @@
1
+ import * as React from 'react';
2
+ import { AuthLink } from '../lib/auth.js';
3
+ import '../lib/i18n.js';
4
+
5
+ type AuthStatusPreset = "signed-out" | "session-expired" | "check-email" | "verify-email" | "email-verified" | "password-changed" | "account-locked" | "link-expired" | "access-denied";
6
+ declare function AuthStatus({ preset, title, description, icon, email, action, actionLabel, secondaryAction, secondaryLabel, onResend, resendAfter, align, children, className, ...props }: Omit<React.ComponentProps<"div">, "title"> & {
7
+ preset?: AuthStatusPreset;
8
+ title?: React.ReactNode;
9
+ description?: React.ReactNode;
10
+ icon?: React.ReactNode;
11
+ /** check-email, verify-email: a qué correo se envió. */
12
+ email?: string;
13
+ /** Acción principal (URL o función del router). */
14
+ action?: AuthLink;
15
+ actionLabel?: React.ReactNode;
16
+ secondaryAction?: AuthLink;
17
+ secondaryLabel?: React.ReactNode;
18
+ onResend?: () => void | Promise<void>;
19
+ resendAfter?: number;
20
+ align?: "start" | "center";
21
+ }): React.JSX.Element;
22
+
23
+ export { AuthStatus, type AuthStatusPreset };
@@ -0,0 +1,99 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { BadgeCheckIcon, ClockIcon, LinkIcon, LockIcon, LogOutIcon, MailCheckIcon, MailIcon, ShieldCheckIcon, ShieldXIcon } 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 { AuthHeader, AuthStagger } from "./auth-parts.js";
10
+ import { Button } from "./button.js";
11
+ import { IconTile } from "./icon-tile.js";
12
+ import { Spinner } from "./spinner.js";
13
+ const LOOK = {
14
+ "signed-out": { tone: "neutral", icon: /* @__PURE__ */ jsx(LogOutIcon, {}) },
15
+ "session-expired": { tone: "warning", icon: /* @__PURE__ */ jsx(ClockIcon, {}) },
16
+ "check-email": { tone: "primary", icon: /* @__PURE__ */ jsx(MailCheckIcon, {}) },
17
+ "verify-email": { tone: "primary", icon: /* @__PURE__ */ jsx(MailIcon, {}) },
18
+ "email-verified": { tone: "success", icon: /* @__PURE__ */ jsx(BadgeCheckIcon, {}) },
19
+ "password-changed": { tone: "success", icon: /* @__PURE__ */ jsx(ShieldCheckIcon, {}) },
20
+ "account-locked": { tone: "danger", icon: /* @__PURE__ */ jsx(LockIcon, {}) },
21
+ "link-expired": { tone: "warning", icon: /* @__PURE__ */ jsx(LinkIcon, {}) },
22
+ "access-denied": { tone: "danger", icon: /* @__PURE__ */ jsx(ShieldXIcon, {}) }
23
+ };
24
+ function AuthStatus({
25
+ preset = "signed-out",
26
+ title,
27
+ description,
28
+ icon,
29
+ email,
30
+ action,
31
+ actionLabel,
32
+ secondaryAction,
33
+ secondaryLabel,
34
+ onResend,
35
+ resendAfter = 30,
36
+ align = "center",
37
+ children,
38
+ className,
39
+ ...props
40
+ }) {
41
+ const t = useDsMessages();
42
+ const look = LOOK[preset];
43
+ const countdown = useAuthCountdown(preset === "check-email" || preset === "verify-email" ? resendAfter : 0);
44
+ const [pending, setPending] = React.useState(false);
45
+ const copy = {
46
+ "signed-out": [t.authSignedOutTitle, t.authSignedOutBody, t.authSignInAgain],
47
+ "session-expired": [t.authSessionExpiredTitle, t.authSessionExpiredBody, t.authSignInAgain],
48
+ "check-email": [t.authCheckEmailTitle, dsFormat(t.authLinkSentBody, { email: email ?? "" }), t.authBackToSignIn],
49
+ "verify-email": [t.authVerifyEmailTitle, dsFormat(t.authVerifyEmailBody, { email: email ?? "" }), t.authBackToSignIn],
50
+ "email-verified": [t.authEmailVerifiedTitle, t.authEmailVerifiedBody, t.authContinue],
51
+ "password-changed": [t.authPasswordChangedTitle, t.authPasswordChangedBody, t.authSignInLink],
52
+ "account-locked": [t.authAccountLockedTitle, t.authAccountLockedBody, t.authResetPasswordAction],
53
+ "link-expired": [t.authLinkExpiredTitle, t.authLinkExpiredBody, t.authRequestNewLink],
54
+ "access-denied": [t.authAccessDeniedTitle, t.authAccessDeniedBody, t.authBackHome]
55
+ };
56
+ const [defTitle, defBody, defAction] = copy[preset];
57
+ const link = (to, label, variant) => typeof to === "string" ? /* @__PURE__ */ jsx(Button, { variant, className: "w-full", render: /* @__PURE__ */ jsx("a", { href: to }), children: label }) : /* @__PURE__ */ jsx(Button, { type: "button", variant, className: "w-full", onClick: to, children: label });
58
+ return /* @__PURE__ */ jsxs("div", { "data-slot": "auth-status", "data-preset": preset, "data-tone": look.tone, className: cn("flex flex-col gap-(--ds-auth-gap)", className), ...props, children: [
59
+ /* @__PURE__ */ jsx(
60
+ AuthHeader,
61
+ {
62
+ align,
63
+ icon: icon ?? /* @__PURE__ */ jsx(IconTile, { "data-slot": "auth-status-icon", tone: look.tone, size: "lg", className: "animate-ds-auth-pop", children: look.icon }, preset),
64
+ title: title ?? defTitle,
65
+ description: description ?? defBody
66
+ }
67
+ ),
68
+ children ? /* @__PURE__ */ jsx(AuthStagger, { index: 1, children }) : null,
69
+ /* @__PURE__ */ jsxs(AuthStagger, { index: 2, "data-slot": "auth-status-actions", className: "flex flex-col gap-2", children: [
70
+ onResend ? /* @__PURE__ */ jsxs(
71
+ Button,
72
+ {
73
+ type: "button",
74
+ variant: action ? "outline" : "default",
75
+ className: "w-full",
76
+ disabled: countdown.running || pending,
77
+ onClick: async () => {
78
+ setPending(true);
79
+ try {
80
+ await onResend();
81
+ countdown.start(resendAfter);
82
+ } finally {
83
+ setPending(false);
84
+ }
85
+ },
86
+ children: [
87
+ pending ? /* @__PURE__ */ jsx(Spinner, {}) : null,
88
+ countdown.running ? dsFormat(t.authResendIn, { time: formatCountdown(countdown.left) }) : t.authResend
89
+ ]
90
+ }
91
+ ) : null,
92
+ action ? link(action, actionLabel ?? defAction, onResend ? "ghost" : "default") : null,
93
+ secondaryAction ? link(secondaryAction, secondaryLabel ?? t.authBackToSignIn, "ghost") : null
94
+ ] })
95
+ ] });
96
+ }
97
+ export {
98
+ AuthStatus
99
+ };
@@ -0,0 +1,25 @@
1
+ import * as React from 'react';
2
+
3
+ type ConnectedAccountsPreset = "social" | "integrations";
4
+ type ConnectionStatus = "connected" | "disconnected" | "expired" | "error" | "pending";
5
+ type ConnectionItem = {
6
+ id: string;
7
+ label: React.ReactNode;
8
+ icon?: React.ReactNode;
9
+ description?: React.ReactNode;
10
+ status: ConnectionStatus;
11
+ /** Cuenta enlazada («ana@gmail.com», «workspace Acme»). */
12
+ account?: React.ReactNode;
13
+ /** Permisos concedidos o detalle (integraciones). */
14
+ detail?: React.ReactNode;
15
+ };
16
+ declare function ConnectedAccounts({ preset, items, onConnect, onDisconnect, keepOne, className, ...props }: React.ComponentProps<"div"> & {
17
+ preset?: ConnectedAccountsPreset;
18
+ items: ConnectionItem[];
19
+ onConnect?: (id: string) => void | Promise<void>;
20
+ onDisconnect?: (id: string) => void | Promise<void>;
21
+ /** No dejar quitar la última conexión (por defecto, en social). Si la persona tiene contraseña, pásalo a false. */
22
+ keepOne?: boolean;
23
+ }): React.JSX.Element;
24
+
25
+ export { ConnectedAccounts, type ConnectedAccountsPreset, type ConnectionItem, type ConnectionStatus };