@alepha/ui 0.25.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.
Files changed (136) hide show
  1. package/README.md +12 -0
  2. package/components.json +20 -0
  3. package/package.json +85 -0
  4. package/src/components/action-error-toaster/action-error-toaster.tsx +70 -0
  5. package/src/components/admin/admin-audits.tsx +247 -0
  6. package/src/components/admin/admin-files.tsx +346 -0
  7. package/src/components/admin/admin-jobs-executions-panel.tsx +235 -0
  8. package/src/components/admin/admin-jobs-status-badge.tsx +33 -0
  9. package/src/components/admin/admin-jobs.tsx +294 -0
  10. package/src/components/admin/admin-keys.tsx +162 -0
  11. package/src/components/admin/admin-notifications.tsx +130 -0
  12. package/src/components/admin/admin-page.tsx +24 -0
  13. package/src/components/admin/admin-parameters.tsx +864 -0
  14. package/src/components/admin/admin-payments.tsx +93 -0
  15. package/src/components/admin/admin-sessions.tsx +174 -0
  16. package/src/components/admin/admin-user-detail-audits-tab.tsx +82 -0
  17. package/src/components/admin/admin-user-detail-identity-aside.tsx +218 -0
  18. package/src/components/admin/admin-user-detail-overview-tab.tsx +87 -0
  19. package/src/components/admin/admin-user-detail-password-dialog.tsx +85 -0
  20. package/src/components/admin/admin-user-detail-password-schema.ts +11 -0
  21. package/src/components/admin/admin-user-detail-profile-schema.ts +19 -0
  22. package/src/components/admin/admin-user-detail-provider-labels.ts +15 -0
  23. package/src/components/admin/admin-user-detail-security-tab.tsx +146 -0
  24. package/src/components/admin/admin-user-detail-sessions-tab.tsx +93 -0
  25. package/src/components/admin/admin-user-detail.tsx +606 -0
  26. package/src/components/admin/admin-users-roles-picker.tsx +126 -0
  27. package/src/components/admin/admin-users-status-filter.tsx +51 -0
  28. package/src/components/admin/admin-users.tsx +518 -0
  29. package/src/components/admin/diff-lines.spec.ts +58 -0
  30. package/src/components/admin/diff-lines.ts +58 -0
  31. package/src/components/admin/parameter-diff-dialog.tsx +119 -0
  32. package/src/components/admin/parameter-history-item.tsx +252 -0
  33. package/src/components/admin/parameter-json-dialog.tsx +93 -0
  34. package/src/components/admin/parameter-save-dialog.tsx +126 -0
  35. package/src/components/admin/use-confirmed-action.tsx +93 -0
  36. package/src/components/alepha-table/__tests__/use-table-selection.browser.spec.tsx +92 -0
  37. package/src/components/alepha-table/alepha-table.tsx +1158 -0
  38. package/src/components/alepha-table/use-table-selection.ts +95 -0
  39. package/src/components/app-shell/app-shell.tsx +568 -0
  40. package/src/components/auth/__tests__/auth-router.spec.ts +52 -0
  41. package/src/components/auth/auth-login.tsx +382 -0
  42. package/src/components/auth/auth-register.tsx +786 -0
  43. package/src/components/auth/auth-reset-password.tsx +349 -0
  44. package/src/components/auth/auth-router.tsx +126 -0
  45. package/src/components/auth/auth-verify-email.tsx +179 -0
  46. package/src/components/auto-form/auto-form.tsx +867 -0
  47. package/src/components/brand-icon/brand-icon.tsx +104 -0
  48. package/src/components/button-dark/button-dark.tsx +78 -0
  49. package/src/components/button-language/button-language.tsx +98 -0
  50. package/src/components/button-theme/button-theme.tsx +148 -0
  51. package/src/components/button-user/button-user.tsx +214 -0
  52. package/src/components/captcha/turnstile-widget.tsx +157 -0
  53. package/src/components/control/control.tsx +735 -0
  54. package/src/components/control-array/control-array.tsx +700 -0
  55. package/src/components/control-base/__tests__/form-field-a11y.browser.spec.tsx +93 -0
  56. package/src/components/control-base/field-i18n.ts +60 -0
  57. package/src/components/control-base/form-field.tsx +275 -0
  58. package/src/components/control-base/grid.tsx +59 -0
  59. package/src/components/control-base/icon-hint.tsx +64 -0
  60. package/src/components/control-date/control-date.tsx +190 -0
  61. package/src/components/control-number/control-number.tsx +136 -0
  62. package/src/components/control-object/control-object.tsx +200 -0
  63. package/src/components/control-select/control-select.tsx +774 -0
  64. package/src/components/control-upload/control-upload.tsx +475 -0
  65. package/src/components/file-image/file-image.tsx +52 -0
  66. package/src/components/language-toggle/language-toggle.tsx +66 -0
  67. package/src/components/markdown-view/markdown-view.css +114 -0
  68. package/src/components/markdown-view/markdown-view.tsx +92 -0
  69. package/src/components/nav-shell/nav-page.tsx +56 -0
  70. package/src/components/nav-shell/nav-shell.tsx +72 -0
  71. package/src/components/nav-shell/nav-tree-util.ts +62 -0
  72. package/src/components/nav-shell/spotlight.tsx +163 -0
  73. package/src/components/nav-shell/use-nav-breadcrumbs.ts +52 -0
  74. package/src/components/nav-shell/use-nav-entries.ts +101 -0
  75. package/src/components/nav-shell/use-nav-tree.ts +61 -0
  76. package/src/components/ui/accordion.tsx +77 -0
  77. package/src/components/ui/alert-dialog.tsx +186 -0
  78. package/src/components/ui/alert.tsx +75 -0
  79. package/src/components/ui/aspect-ratio.tsx +22 -0
  80. package/src/components/ui/avatar.tsx +106 -0
  81. package/src/components/ui/badge.tsx +51 -0
  82. package/src/components/ui/breadcrumb.tsx +121 -0
  83. package/src/components/ui/button-group.tsx +86 -0
  84. package/src/components/ui/button.tsx +83 -0
  85. package/src/components/ui/calendar.tsx +235 -0
  86. package/src/components/ui/card.tsx +102 -0
  87. package/src/components/ui/carousel.tsx +241 -0
  88. package/src/components/ui/chart.tsx +370 -0
  89. package/src/components/ui/checkbox.tsx +27 -0
  90. package/src/components/ui/collapsible.tsx +19 -0
  91. package/src/components/ui/combobox.tsx +298 -0
  92. package/src/components/ui/command.tsx +196 -0
  93. package/src/components/ui/context-menu.tsx +271 -0
  94. package/src/components/ui/dialog.tsx +153 -0
  95. package/src/components/ui/direction.tsx +4 -0
  96. package/src/components/ui/drawer.tsx +130 -0
  97. package/src/components/ui/dropdown-menu.tsx +269 -0
  98. package/src/components/ui/empty.tsx +100 -0
  99. package/src/components/ui/hover-card.tsx +50 -0
  100. package/src/components/ui/input-group.tsx +157 -0
  101. package/src/components/ui/input-otp.tsx +83 -0
  102. package/src/components/ui/input.tsx +19 -0
  103. package/src/components/ui/item.tsx +200 -0
  104. package/src/components/ui/kbd.tsx +26 -0
  105. package/src/components/ui/label.tsx +19 -0
  106. package/src/components/ui/menubar.tsx +283 -0
  107. package/src/components/ui/navigation-menu.tsx +170 -0
  108. package/src/components/ui/pagination.tsx +133 -0
  109. package/src/components/ui/popover.tsx +87 -0
  110. package/src/components/ui/progress.tsx +82 -0
  111. package/src/components/ui/radio-group.tsx +35 -0
  112. package/src/components/ui/resizable.tsx +49 -0
  113. package/src/components/ui/scroll-area.tsx +51 -0
  114. package/src/components/ui/segmented.tsx +232 -0
  115. package/src/components/ui/select.tsx +201 -0
  116. package/src/components/ui/separator.tsx +22 -0
  117. package/src/components/ui/sheet.tsx +133 -0
  118. package/src/components/ui/sidebar.tsx +723 -0
  119. package/src/components/ui/skeleton.tsx +13 -0
  120. package/src/components/ui/slider.tsx +51 -0
  121. package/src/components/ui/sonner.tsx +46 -0
  122. package/src/components/ui/spinner.tsx +15 -0
  123. package/src/components/ui/switch.tsx +29 -0
  124. package/src/components/ui/table.tsx +115 -0
  125. package/src/components/ui/tabs.tsx +79 -0
  126. package/src/components/ui/textarea.tsx +17 -0
  127. package/src/components/ui/toggle-group.tsx +86 -0
  128. package/src/components/ui/toggle.tsx +44 -0
  129. package/src/components/ui/tooltip.tsx +63 -0
  130. package/src/components/use-dialog/use-dialog.tsx +244 -0
  131. package/src/components/use-toast/use-toast.tsx +89 -0
  132. package/src/hooks/use-mobile.ts +21 -0
  133. package/src/lib/__tests__/i18n-fr.spec.ts +72 -0
  134. package/src/lib/i18n-fr.ts +500 -0
  135. package/src/lib/utils.ts +6 -0
  136. package/src/styles.css +129 -0
@@ -0,0 +1,52 @@
1
+ import { Alepha } from "alepha";
2
+ import { $page, AlephaReactRouter } from "alepha/react/router";
3
+ import { describe, expect, it } from "vitest";
4
+ import { AuthRouter } from "../auth-router.tsx";
5
+
6
+ /**
7
+ * Registering `AuthRouter` must be the whole integration.
8
+ *
9
+ * The four pages it mounts are what `@alepha/mantine/auth/AuthRouter` used to
10
+ * provide before it was deleted with Mantine and not ported — which is why both
11
+ * `apps/lore` and `apps/shop` ended up rebuilding the same screens by hand.
12
+ *
13
+ * The paths are asserted literally because they are a contract, not an
14
+ * implementation detail: the auth components fall back to exactly these strings
15
+ * (`props.loginPath ?? "/auth/login"`), so a path drifting here would silently
16
+ * turn every cross-link in the package into a 404. That failure is invisible to
17
+ * typecheck and to any test that reaches a page by URL.
18
+ *
19
+ * The names matter as much: `$secure`'s redirect and `ButtonUser`'s sign-in action
20
+ * both push a route called `login`.
21
+ */
22
+ describe("AuthRouter", () => {
23
+ const mount = async () => {
24
+ const alepha = Alepha.create().with(AlephaReactRouter);
25
+ alepha.inject(AuthRouter);
26
+ await alepha.start();
27
+ return alepha
28
+ .primitives($page)
29
+ .map((page) => ({ path: page.options.path, name: page.options.name }));
30
+ };
31
+
32
+ it("mounts the four authentication screens", async () => {
33
+ const pages = await mount();
34
+
35
+ expect(pages).toEqual(
36
+ expect.arrayContaining([
37
+ { path: "/auth/login", name: "login" },
38
+ { path: "/auth/register", name: "register" },
39
+ { path: "/auth/reset-password", name: "resetPassword" },
40
+ { path: "/auth/verify-email", name: "verifyEmail" },
41
+ ]),
42
+ );
43
+ });
44
+
45
+ it("names sign-in `login`, which is what the rest of the framework pushes", async () => {
46
+ const pages = await mount();
47
+
48
+ expect(pages.find((page) => page.name === "login")?.path).toBe(
49
+ "/auth/login",
50
+ );
51
+ });
52
+ });
@@ -0,0 +1,382 @@
1
+ import * as React from "react";
2
+
3
+ void React;
4
+
5
+ import { BrandIcon } from "@alepha/ui/components/brand-icon/brand-icon";
6
+ import { Control } from "@alepha/ui/components/control/control";
7
+ import { Alert, AlertDescription } from "@alepha/ui/components/ui/alert";
8
+ import { Button } from "@alepha/ui/components/ui/button";
9
+ import { Card, CardContent } from "@alepha/ui/components/ui/card";
10
+ import { Separator } from "@alepha/ui/components/ui/separator";
11
+ import { AlephaError, SchemaValidationError, z } from "alepha";
12
+ import type { RealmConfig } from "alepha/api/users";
13
+ import { useAuth } from "alepha/react/auth";
14
+ import { FormValidationError, useForm, useFormState } from "alepha/react/form";
15
+ import { useI18n } from "alepha/react/i18n";
16
+ import { useRouter } from "alepha/react/router";
17
+ import { HttpError } from "alepha/server";
18
+ import { AlertCircle, Mail, User } from "lucide-react";
19
+ import { type ReactNode, useEffect, useMemo } from "react";
20
+
21
+ export interface AuthLoginProps {
22
+ /**
23
+ * Realm configuration (credential providers + OAuth buttons that render).
24
+ */
25
+ realmConfig: RealmConfig;
26
+ /**
27
+ * Route to the registration page. When set, a "Sign up" link is shown.
28
+ */
29
+ registerPath?: string;
30
+ /**
31
+ * Route to the password-reset flow. When set, a "Forgot password?" link is shown.
32
+ */
33
+ resetPasswordPath?: string;
34
+ /**
35
+ * Layout variant.
36
+ * - `centered` (default): single column, form centered on the viewport.
37
+ * - `split`: two-pane on `lg`+ — branded background panel on the left, form on the right. Collapses to centered on small screens.
38
+ */
39
+ variant?: "centered" | "split";
40
+ /**
41
+ * Background panel configuration for the `split` variant. Ignored for `centered`.
42
+ * - `src`: image URL. When omitted, a neutral dot pattern is rendered.
43
+ * - `overlay`: optional content drawn over the background (logo, tagline).
44
+ */
45
+ background?: {
46
+ src?: string;
47
+ overlay?: ReactNode;
48
+ };
49
+ /**
50
+ * Custom logo node, rendered above the form. When provided, it replaces
51
+ * the default `settings.logoUrl` <img>. Use this to inject a branded
52
+ * component (e.g. with light/dark variants or an animation).
53
+ */
54
+ logo?: ReactNode;
55
+ }
56
+
57
+ /**
58
+ * Filter the `?redirect=` query param to a safe in-app destination:
59
+ * - Only accept same-origin absolute paths (must start with a single `/`).
60
+ * - Reject `//evil.com` / full URLs (open-redirect surface).
61
+ * - Reject `/auth/*` to avoid bouncing the user back into the auth flow.
62
+ */
63
+ const safeRedirect = (raw: string | string[] | undefined): string => {
64
+ if (typeof raw !== "string" || raw.length === 0) return "/";
65
+ if (!raw.startsWith("/") || raw.startsWith("//")) return "/";
66
+ if (raw.startsWith("/auth/")) return "/";
67
+ return raw;
68
+ };
69
+
70
+ export function AuthLogin(props: AuthLoginProps) {
71
+ const auth = useAuth();
72
+ const router = useRouter();
73
+ const { tr } = useI18n();
74
+ const redirect = safeRedirect(router.query.redirect);
75
+ const error = router.query.error;
76
+
77
+ const credentialsProvider = props.realmConfig.authenticationMethods.find(
78
+ (it) => it.type === "CREDENTIALS",
79
+ );
80
+ const settings = props.realmConfig.settings;
81
+
82
+ const loginMethods = useMemo(() => {
83
+ const methods: string[] = [];
84
+ // `username: "email"` means the username is auto-derived from the email
85
+ // server-side and never typed by the user — it's not a separate login
86
+ // method from the user's perspective.
87
+ if (settings.username !== "none" && settings.username !== "email") {
88
+ methods.push("username");
89
+ }
90
+ if (settings.email !== "none") methods.push("email");
91
+ if (settings.phoneNumber !== "none") methods.push("phone");
92
+ return methods;
93
+ }, [settings]);
94
+
95
+ const identifierLabel = useMemo(() => {
96
+ if (loginMethods.length <= 1) {
97
+ const m = loginMethods[0];
98
+ if (m === "email") return tr("auth.login.email", { default: "Email" });
99
+ if (m === "phone")
100
+ return tr("auth.login.phone", { default: "Phone number" });
101
+ return tr("auth.login.username", { default: "Username" });
102
+ }
103
+ return tr("auth.login.identifier", {
104
+ default: "Username, email or phone",
105
+ });
106
+ }, [loginMethods, tr]);
107
+
108
+ // Mail icon when the identifier is purely an email; otherwise default user icon.
109
+ const identifierIcon =
110
+ loginMethods.length === 1 && loginMethods[0] === "email" ? Mail : User;
111
+
112
+ // Pick the most-precise HTML autocomplete hint so password managers and
113
+ // browser autofill (especially iOS Keychain) pair the identifier with the
114
+ // saved password reliably. Mixed configs fall back to `username` — the
115
+ // WHATWG-canonical hint for "the account identifier".
116
+ const identifierAutoComplete =
117
+ loginMethods.length === 1
118
+ ? loginMethods[0] === "email"
119
+ ? "email"
120
+ : loginMethods[0] === "phone"
121
+ ? "tel"
122
+ : "username"
123
+ : "username";
124
+
125
+ const form = useForm({
126
+ schema: z.object({
127
+ identifier: z.string().min(1),
128
+ password: z.string().min(settings.passwordPolicy?.minLength || 6),
129
+ }),
130
+ handler: async (data) => {
131
+ if (!credentialsProvider) {
132
+ throw new AlephaError("Credentials provider not configured");
133
+ }
134
+ try {
135
+ await auth.login(credentialsProvider.name, {
136
+ username: data.identifier,
137
+ password: data.password,
138
+ realm: props.realmConfig.realmName,
139
+ });
140
+ // `force: true` recreates the whole page state so every parent-layout
141
+ // loader re-runs against the now-authenticated user. Without it, an
142
+ // SPA push to a sibling under the same layout reuses the cached layout
143
+ // layer and skips its loader — leaving `user`-gated bootstrap data
144
+ // (e.g. the campaign list) stale/empty after sign-in.
145
+ await router.push(safeRedirect(router.query.redirect), {
146
+ force: true,
147
+ });
148
+ } catch (err) {
149
+ if (
150
+ err instanceof HttpError &&
151
+ err.error === "InvalidCredentialsError"
152
+ ) {
153
+ throw new FormValidationError({
154
+ message: tr("auth.login.invalid", {
155
+ default: "Invalid identifier or password",
156
+ }),
157
+ path: "/password",
158
+ });
159
+ }
160
+ // Other 4xx are intentional, user-facing API errors — surface as-is.
161
+ if (err instanceof HttpError && err.status < 500) {
162
+ throw err;
163
+ }
164
+ // 5xx / unexpected: never show internals to the user. Log the real
165
+ // cause and surface a generic message.
166
+ console.error("Login failed:", err);
167
+ throw new FormValidationError({
168
+ message: tr("auth.login.error", {
169
+ default: "Something went wrong. Please try again.",
170
+ }),
171
+ path: "/password",
172
+ });
173
+ }
174
+ },
175
+ });
176
+
177
+ const externalMethods = props.realmConfig.authenticationMethods.filter(
178
+ (m) => m.type !== "CREDENTIALS",
179
+ );
180
+
181
+ // Autofocus the identifier field on mount — but only when credentials is the
182
+ // *sole* login method. With OAuth/external buttons present we don't steal
183
+ // focus (and trigger the browser's autofill popup) from a user who came to
184
+ // click "Continue with …". `<Control>` has no `autoFocus` prop, so we grab
185
+ // the id the form assigned and focus it.
186
+ const identifierId = form.input.identifier.props.id;
187
+ useEffect(() => {
188
+ if (!credentialsProvider || externalMethods.length > 0 || !identifierId) {
189
+ return;
190
+ }
191
+ (
192
+ document.getElementById(String(identifierId)) as HTMLInputElement | null
193
+ )?.focus();
194
+ }, [credentialsProvider, externalMethods.length, identifierId]);
195
+
196
+ const formState = useFormState(form, ["error", "loading"]);
197
+ const formError =
198
+ formState.error && !(formState.error instanceof SchemaValidationError)
199
+ ? formState.error.message
200
+ : undefined;
201
+ const showDivider = credentialsProvider && externalMethods.length > 0;
202
+ // Propagate BOTH realm and the post-auth redirect to the register / reset
203
+ // links — dropping `redirect` here strands a user who signs up mid-flow
204
+ // (e.g. an OIDC authorize continuation) on the home page. Mirrors the
205
+ // login-link construction in auth-register.
206
+ const realmBit = props.realmConfig.realmName
207
+ ? `realm=${encodeURIComponent(props.realmConfig.realmName)}`
208
+ : "";
209
+ const redirectBit =
210
+ typeof router.query.redirect === "string" && router.query.redirect
211
+ ? `redirect=${encodeURIComponent(router.query.redirect)}`
212
+ : "";
213
+ const linkQ = [realmBit, redirectBit].filter(Boolean).join("&");
214
+ const realmQuery = linkQ ? `?${linkQ}` : "";
215
+
216
+ const variant = props.variant ?? "centered";
217
+
218
+ const formColumn = (
219
+ <div className="flex w-full max-w-sm flex-col items-center gap-4">
220
+ {props.logo ??
221
+ (settings.logoUrl ? (
222
+ <img
223
+ src={settings.logoUrl}
224
+ alt={settings.displayName || props.realmConfig.realmName}
225
+ className="size-16 rounded-xl border bg-muted object-cover shadow-sm"
226
+ />
227
+ ) : null)}
228
+ <Card className="w-full">
229
+ <CardContent className="flex flex-col gap-4">
230
+ {(settings.displayName || settings.description) && (
231
+ <div className="flex flex-col items-center gap-1">
232
+ {settings.displayName && (
233
+ <h2 className="text-center text-lg font-semibold">
234
+ {settings.displayName}
235
+ </h2>
236
+ )}
237
+ {settings.description && (
238
+ <p className="text-muted-foreground text-center text-sm">
239
+ {settings.description}
240
+ </p>
241
+ )}
242
+ </div>
243
+ )}
244
+
245
+ {(error || formError) && (
246
+ <Alert variant="destructive">
247
+ <AlertCircle className="size-4" />
248
+ <AlertDescription>{error || formError}</AlertDescription>
249
+ </Alert>
250
+ )}
251
+
252
+ {credentialsProvider && (
253
+ <form {...form.props} className="flex flex-col gap-4">
254
+ <Control
255
+ label={identifierLabel}
256
+ input={form.input.identifier}
257
+ icon={identifierIcon}
258
+ autoComplete={identifierAutoComplete}
259
+ />
260
+ <Control
261
+ label={tr("auth.login.password", {
262
+ default: "Password",
263
+ })}
264
+ input={form.input.password}
265
+ password
266
+ />
267
+ <Button type="submit" loading={formState.loading}>
268
+ {tr("auth.login.submit", { default: "Sign in" })}
269
+ </Button>
270
+ {settings.resetPasswordAllowed && (
271
+ <a
272
+ href={`${props.resetPasswordPath ?? "/auth/reset-password"}${realmQuery}`}
273
+ className="text-muted-foreground hover:text-foreground text-center text-sm underline-offset-4 hover:underline"
274
+ >
275
+ {tr("auth.login.forgot", {
276
+ default: "Forgot password?",
277
+ })}
278
+ </a>
279
+ )}
280
+ </form>
281
+ )}
282
+
283
+ {showDivider && (
284
+ <div className="flex items-center gap-3">
285
+ <Separator className="flex-1" />
286
+ <span className="text-muted-foreground text-xs">
287
+ {tr("auth.login.or", { default: "OR" })}
288
+ </span>
289
+ <Separator className="flex-1" />
290
+ </div>
291
+ )}
292
+
293
+ {externalMethods.length > 0 && (
294
+ <div className="flex flex-col gap-2">
295
+ {externalMethods.map((method) => {
296
+ const provider =
297
+ method.name.charAt(0).toUpperCase() + method.name.slice(1);
298
+ return (
299
+ <Button
300
+ key={method.name}
301
+ variant="outline"
302
+ onClick={() =>
303
+ auth.login(method.name, {
304
+ redirect,
305
+ realm: props.realmConfig.realmName,
306
+ })
307
+ }
308
+ >
309
+ <BrandIcon provider={method.name} />
310
+ {tr("auth.login.continueWith", {
311
+ default: `Continue with ${provider}`,
312
+ args: [provider],
313
+ })}
314
+ </Button>
315
+ );
316
+ })}
317
+ </div>
318
+ )}
319
+
320
+ {settings.registrationAllowed && (
321
+ <p className="text-muted-foreground text-center text-sm">
322
+ {tr("auth.login.noAccount", {
323
+ default: "Don't have an account?",
324
+ })}{" "}
325
+ <a
326
+ href={`${props.registerPath ?? "/auth/register"}${realmQuery}`}
327
+ className="text-foreground underline-offset-4 hover:underline"
328
+ >
329
+ {tr("auth.login.signUp", { default: "Sign up" })}
330
+ </a>
331
+ </p>
332
+ )}
333
+ </CardContent>
334
+ </Card>
335
+ <Button variant="ghost" nativeButton={false} render={<a href="/" />}>
336
+ {tr("auth.login.cancel", { default: "Cancel" })}
337
+ </Button>
338
+ </div>
339
+ );
340
+
341
+ if (variant === "split") {
342
+ const bgSrc = props.background?.src;
343
+ const dotPattern =
344
+ "url(\"data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\")";
345
+ return (
346
+ <div className="flex min-h-svh">
347
+ <div
348
+ className="bg-muted relative hidden flex-col items-center justify-center overflow-hidden p-16 lg:flex lg:w-1/2"
349
+ style={
350
+ bgSrc
351
+ ? {
352
+ backgroundImage: `url(${JSON.stringify(bgSrc)})`,
353
+ backgroundSize: "cover",
354
+ backgroundPosition: "center",
355
+ }
356
+ : undefined
357
+ }
358
+ >
359
+ {!bgSrc && (
360
+ <div
361
+ aria-hidden
362
+ className="absolute inset-0 opacity-[0.04] dark:opacity-[0.08]"
363
+ style={{ backgroundImage: dotPattern }}
364
+ />
365
+ )}
366
+ {props.background?.overlay && (
367
+ <div className="relative z-10">{props.background.overlay}</div>
368
+ )}
369
+ </div>
370
+ <div className="bg-background flex flex-1 items-center justify-center p-6">
371
+ {formColumn}
372
+ </div>
373
+ </div>
374
+ );
375
+ }
376
+
377
+ return (
378
+ <div className="flex min-h-svh flex-1 items-center justify-center p-6">
379
+ {formColumn}
380
+ </div>
381
+ );
382
+ }