@jcsoftdev/ui 0.4.0 → 0.5.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 (131) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/README.md +1 -1
  3. package/dist/atoms/button/button.d.ts +8 -1
  4. package/dist/atoms/button/button.js +10 -3
  5. package/dist/atoms/divider/divider.d.ts +15 -0
  6. package/dist/atoms/divider/divider.js +27 -0
  7. package/dist/atoms/divider/index.d.ts +1 -0
  8. package/dist/atoms/divider/index.js +1 -0
  9. package/dist/atoms/icon-button/icon-button.d.ts +1 -1
  10. package/dist/atoms/index.d.ts +1 -0
  11. package/dist/atoms/index.js +1 -0
  12. package/dist/auth/auth-illustration/auth-illustration.d.ts +35 -0
  13. package/dist/auth/auth-illustration/auth-illustration.js +72 -0
  14. package/dist/auth/auth-illustration/index.d.ts +3 -0
  15. package/dist/auth/auth-illustration/index.js +11 -0
  16. package/dist/auth/auth-illustration/look.d.ts +30 -0
  17. package/dist/auth/auth-illustration/look.js +0 -0
  18. package/dist/auth/auth-illustration/model.d.ts +133 -0
  19. package/dist/auth/auth-illustration/model.js +202 -0
  20. package/dist/auth/auth-illustration/use-art-pointer.d.ts +9 -0
  21. package/dist/auth/auth-illustration/use-art-pointer.js +69 -0
  22. package/dist/auth/auth-layout/auth-layout.d.ts +80 -0
  23. package/dist/auth/auth-layout/auth-layout.js +190 -0
  24. package/dist/auth/auth-layout/index.d.ts +1 -0
  25. package/dist/auth/auth-layout/index.js +1 -0
  26. package/dist/auth/character/character.d.ts +12 -0
  27. package/dist/auth/character/character.js +333 -0
  28. package/dist/auth/character/index.d.ts +1 -0
  29. package/dist/auth/character/index.js +1 -0
  30. package/dist/auth/index.d.ts +4 -0
  31. package/dist/auth/index.js +4 -0
  32. package/dist/auth/internal/auth-context.d.ts +17 -0
  33. package/dist/auth/internal/auth-context.js +10 -0
  34. package/dist/auth/internal/auth-styles.d.ts +1 -0
  35. package/dist/auth/internal/auth-styles.js +29 -0
  36. package/dist/auth/internal/portal-glyphs.d.ts +6 -0
  37. package/dist/auth/internal/portal-glyphs.js +39 -0
  38. package/dist/auth/login-form/context.d.ts +51 -0
  39. package/dist/auth/login-form/context.js +12 -0
  40. package/dist/auth/login-form/index.d.ts +2 -0
  41. package/dist/auth/login-form/index.js +23 -0
  42. package/dist/auth/login-form/login-form.d.ts +66 -0
  43. package/dist/auth/login-form/login-form.js +233 -0
  44. package/dist/auth/login-form/parts.d.ts +71 -0
  45. package/dist/auth/login-form/parts.js +371 -0
  46. package/dist/auth/looks/auth-illustration-any.d.ts +16 -0
  47. package/dist/auth/looks/auth-illustration-any.js +24 -0
  48. package/dist/auth/looks/index.d.ts +1 -0
  49. package/dist/auth/looks/index.js +1 -0
  50. package/dist/auth/mosaic/index.d.ts +1 -0
  51. package/dist/auth/mosaic/index.js +1 -0
  52. package/dist/auth/mosaic/mosaic.d.ts +11 -0
  53. package/dist/auth/mosaic/mosaic.js +195 -0
  54. package/dist/auth/slabs/index.d.ts +1 -0
  55. package/dist/auth/slabs/index.js +1 -0
  56. package/dist/auth/slabs/slabs.d.ts +13 -0
  57. package/dist/auth/slabs/slabs.js +136 -0
  58. package/dist/auth/stack/index.d.ts +1 -0
  59. package/dist/auth/stack/index.js +1 -0
  60. package/dist/auth/stack/stack.d.ts +6 -0
  61. package/dist/auth/stack/stack.js +222 -0
  62. package/dist/auth/statement/index.d.ts +1 -0
  63. package/dist/auth/statement/index.js +1 -0
  64. package/dist/auth/statement/statement.d.ts +13 -0
  65. package/dist/auth/statement/statement.js +99 -0
  66. package/dist/forms/index.d.ts +1 -0
  67. package/dist/forms/index.js +1 -0
  68. package/dist/forms/input/input.js +2 -1
  69. package/dist/forms/password-input/index.d.ts +1 -0
  70. package/dist/forms/password-input/index.js +1 -0
  71. package/dist/forms/password-input/password-input.d.ts +16 -0
  72. package/dist/forms/password-input/password-input.js +45 -0
  73. package/dist/i18n/strings.d.ts +64 -0
  74. package/dist/i18n/strings.js +34 -2
  75. package/dist/icons/eye.d.ts +2 -0
  76. package/dist/icons/eye.js +11 -0
  77. package/dist/icons/graduation-cap.d.ts +2 -0
  78. package/dist/icons/graduation-cap.js +12 -0
  79. package/dist/icons/house.d.ts +2 -0
  80. package/dist/icons/house.js +11 -0
  81. package/dist/icons/index.d.ts +4 -0
  82. package/dist/icons/index.js +8 -0
  83. package/dist/icons/mail.d.ts +2 -0
  84. package/dist/icons/mail.js +11 -0
  85. package/icons/svg/eye.svg +4 -0
  86. package/icons/svg/graduation-cap.svg +5 -0
  87. package/icons/svg/house.svg +4 -0
  88. package/icons/svg/mail.svg +4 -0
  89. package/package.json +2 -2
  90. package/src/atoms/button/button.tsx +25 -3
  91. package/src/atoms/divider/divider.tsx +40 -0
  92. package/src/atoms/divider/index.ts +1 -0
  93. package/src/atoms/icon-button/icon-button.tsx +1 -1
  94. package/src/atoms/index.ts +1 -0
  95. package/src/auth/auth-illustration/auth-illustration.tsx +100 -0
  96. package/src/auth/auth-illustration/index.ts +8 -0
  97. package/src/auth/auth-illustration/look.ts +32 -0
  98. package/src/auth/auth-illustration/model.ts +330 -0
  99. package/src/auth/auth-illustration/use-art-pointer.ts +78 -0
  100. package/src/auth/auth-layout/auth-layout.tsx +282 -0
  101. package/src/auth/auth-layout/index.ts +1 -0
  102. package/src/auth/character/character.tsx +346 -0
  103. package/src/auth/character/index.ts +1 -0
  104. package/src/auth/index.ts +4 -0
  105. package/src/auth/internal/auth-context.ts +26 -0
  106. package/src/auth/internal/auth-styles.tsx +39 -0
  107. package/src/auth/internal/portal-glyphs.tsx +32 -0
  108. package/src/auth/login-form/context.ts +78 -0
  109. package/src/auth/login-form/index.ts +21 -0
  110. package/src/auth/login-form/login-form.tsx +330 -0
  111. package/src/auth/login-form/parts.tsx +457 -0
  112. package/src/auth/looks/auth-illustration-any.tsx +38 -0
  113. package/src/auth/looks/index.ts +1 -0
  114. package/src/auth/mosaic/index.ts +1 -0
  115. package/src/auth/mosaic/mosaic.tsx +255 -0
  116. package/src/auth/slabs/index.ts +1 -0
  117. package/src/auth/slabs/slabs.tsx +181 -0
  118. package/src/auth/stack/index.ts +1 -0
  119. package/src/auth/stack/stack.tsx +267 -0
  120. package/src/auth/statement/index.ts +1 -0
  121. package/src/auth/statement/statement.tsx +122 -0
  122. package/src/forms/index.ts +1 -0
  123. package/src/forms/input/input.tsx +2 -0
  124. package/src/forms/password-input/index.ts +1 -0
  125. package/src/forms/password-input/password-input.tsx +57 -0
  126. package/src/i18n/strings.ts +64 -0
  127. package/src/icons/eye.tsx +12 -0
  128. package/src/icons/graduation-cap.tsx +13 -0
  129. package/src/icons/house.tsx +12 -0
  130. package/src/icons/index.ts +4 -0
  131. package/src/icons/mail.tsx +12 -0
@@ -0,0 +1,457 @@
1
+ "use client";
2
+
3
+ import type { ComponentPropsWithoutRef, ReactNode } from "react";
4
+ import { Button, type ButtonProps } from "../../atoms/button/button.js";
5
+ import { Checkbox } from "../../atoms/checkbox/checkbox.js";
6
+ import { Divider } from "../../atoms/divider/divider.js";
7
+ import { RadioGroupItem, RadioGroupRoot } from "../../atoms/radio-group/radio-group-primitive.js";
8
+ import { Spinner } from "../../atoms/spinner/spinner.js";
9
+ import { Field } from "../../forms/field/field.js";
10
+ import { Input } from "../../forms/input/input.js";
11
+ import { PasswordInput } from "../../forms/password-input/password-input.js";
12
+ import { useUiStrings } from "../../i18n/index.js";
13
+ import {
14
+ BookOpen,
15
+ Check,
16
+ CircleAlert,
17
+ GraduationCap,
18
+ House,
19
+ Lock,
20
+ Mail,
21
+ } from "../../icons/index.js";
22
+ import { cn } from "../../utils/cn.js";
23
+ import {
24
+ type LoginField,
25
+ type LoginFormContextValue,
26
+ type LoginPortal,
27
+ useLoginForm,
28
+ } from "./context.js";
29
+
30
+ const FALLBACK_ICONS = [
31
+ <BookOpen key="book" />,
32
+ <House key="house" />,
33
+ <GraduationCap key="cap" />,
34
+ ];
35
+
36
+ export interface LoginFormHeaderProps extends Omit<ComponentPropsWithoutRef<"div">, "title"> {
37
+ /** Defaults to the localized "Sign in". */
38
+ title?: ReactNode;
39
+ /** Defaults to the description of the selected portal. */
40
+ description?: ReactNode;
41
+ /** Heading element of the title. Defaults to `h1`: the form is the point of the page. */
42
+ titleAs?: "h1" | "h2" | "h3";
43
+ }
44
+
45
+ export function LoginFormHeader({
46
+ title,
47
+ description,
48
+ titleAs: Title = "h1",
49
+ className,
50
+ ...props
51
+ }: LoginFormHeaderProps) {
52
+ const strings = useUiStrings();
53
+ const { portal, appearance, classNames } = useLoginForm("Header");
54
+ const open = appearance === "open";
55
+ const text = description ?? portal?.description;
56
+ return (
57
+ <div {...props} className={cn("grid gap-1.5", classNames?.header, className)}>
58
+ <Title
59
+ className={cn(
60
+ "m-0 font-extrabold tracking-tight",
61
+ open ? "text-4xl" : "text-center text-3xl",
62
+ classNames?.title,
63
+ )}
64
+ >
65
+ {title ?? strings.signIn}
66
+ </Title>
67
+ {text ? (
68
+ <p
69
+ className={cn(
70
+ "m-0 text-balance text-ink-3 text-control",
71
+ !open && "text-center",
72
+ classNames?.description,
73
+ )}
74
+ >
75
+ {text}
76
+ </p>
77
+ ) : null}
78
+ </div>
79
+ );
80
+ }
81
+
82
+ /**
83
+ * The tile lifts on hover (pointer devices only: Tailwind gates `hover` behind `(hover: hover)`) and
84
+ * the same way on keyboard focus. The checked tile changes colour and also shows a check badge, so
85
+ * the selection does not rest on a colour change alone.
86
+ */
87
+ const PORTAL_TILE =
88
+ "relative grid h-13 w-16 place-items-center rounded-input border-[1.5px] border-ink-3 bg-surface text-ink transition-[border-color,background-color,transform,box-shadow] duration-150 group-hover:-translate-y-0.5 group-focus-visible:-translate-y-0.5 group-data-[state=checked]:border-ink group-data-[state=checked]:bg-surface-2 group-data-[state=checked]:shadow-[0_2px_0_var(--ink)] [&>svg]:size-6";
89
+
90
+ /** Decorative check badge in the tile's corner; drawn inside the tile so it never moves the layout. */
91
+ const PORTAL_CHECK =
92
+ "absolute top-1 right-1 grid size-4 scale-50 place-items-center rounded-full bg-ink text-surface opacity-0 transition-[opacity,scale] duration-150 group-data-[state=checked]:scale-100 group-data-[state=checked]:opacity-100 [&>svg]:size-3 [&>svg]:stroke-3";
93
+
94
+ export interface LoginFormPortalsProps {
95
+ /** Visible heading of the picker. Defaults to the localized "Sign in as". */
96
+ label?: string;
97
+ className?: string;
98
+ }
99
+
100
+ /**
101
+ * Picker of the portal the person signs in through: a radio group of icon tiles with arrow-key
102
+ * navigation. Renders nothing when the form has fewer than two portals.
103
+ */
104
+ export function LoginFormPortals({ label, className }: LoginFormPortalsProps) {
105
+ const strings = useUiStrings();
106
+ const { portals, portal, setPortal, ids, appearance, classNames } = useLoginForm("Portals");
107
+ if (portals.length < 2) return null;
108
+ return (
109
+ <div className="grid gap-2.5">
110
+ <div
111
+ id={ids.portals}
112
+ className={cn(
113
+ "font-semibold text-ink text-control",
114
+ appearance === "card" && "text-center",
115
+ )}
116
+ >
117
+ {label ?? strings.signInAs}
118
+ </div>
119
+ <RadioGroupRoot
120
+ aria-labelledby={ids.portals}
121
+ value={portal?.value ?? ""}
122
+ onValueChange={setPortal}
123
+ orientation="horizontal"
124
+ className={cn("grid gap-2.5", classNames?.portals, className)}
125
+ style={{ gridTemplateColumns: `repeat(${portals.length}, minmax(0, 1fr))` }}
126
+ >
127
+ {portals.map((option: LoginPortal, index) => (
128
+ <RadioGroupItem
129
+ key={option.value}
130
+ value={option.value}
131
+ className={cn(
132
+ "group grid cursor-pointer justify-items-center gap-1.5 rounded-input bg-transparent p-0 font-medium text-control text-ink focus-visible:focus-ring",
133
+ classNames?.portal,
134
+ )}
135
+ >
136
+ <span aria-hidden="true" className={PORTAL_TILE}>
137
+ {option.icon ?? FALLBACK_ICONS[index]}
138
+ <span data-portal-check="" className={PORTAL_CHECK}>
139
+ <Check />
140
+ </span>
141
+ </span>
142
+ {option.label}
143
+ </RadioGroupItem>
144
+ ))}
145
+ </RadioGroupRoot>
146
+ <Divider className="mt-1.5">{strings.withYourAccount}</Divider>
147
+ </div>
148
+ );
149
+ }
150
+
151
+ export interface LoginFormFieldProps {
152
+ /** Visible label. The default design hides it visually and keeps it for assistive technology. */
153
+ label?: string;
154
+ placeholder?: string;
155
+ className?: string;
156
+ }
157
+
158
+ const fieldClasses = "[&_input]:text-fs-140";
159
+
160
+ /**
161
+ * How a field shows that it is the invalid one: its ring and icon turn to the danger colour, and the
162
+ * message under it starts with an alert icon, so the state does not rest on a border hue (with a
163
+ * red-like accent the focus ring and the danger border are hard to tell apart).
164
+ */
165
+ const INVALID_INPUT = {
166
+ root: "focus-within:outline-danger has-[input[aria-invalid=true]]:border-2",
167
+ start: "text-danger",
168
+ };
169
+
170
+ /** Error wiring of one field: invalid flag, what describes it, and whether its message sits under it. */
171
+ function fieldErrorOf(
172
+ field: LoginField,
173
+ { invalidField, errorPlacement, error, ids }: LoginFormContextValue,
174
+ ) {
175
+ const invalid = invalidField === field;
176
+ const below = invalid && errorPlacement === "field" ? error : null;
177
+ return {
178
+ invalid,
179
+ below,
180
+ describedBy: invalid ? (below ? ids.fieldError : ids.error) : undefined,
181
+ };
182
+ }
183
+
184
+ /** The message under an invalid field. */
185
+ function FieldError({ id, children }: { id: string; children: ReactNode }) {
186
+ return (
187
+ <p
188
+ id={id}
189
+ role="alert"
190
+ className="m-0 flex items-center gap-1.5 font-semibold text-danger text-meta [&>svg]:size-3.5 [&>svg]:shrink-0"
191
+ >
192
+ <CircleAlert aria-hidden="true" />
193
+ {children}
194
+ </p>
195
+ );
196
+ }
197
+
198
+ export function LoginFormIdentifier({ label, placeholder, className }: LoginFormFieldProps) {
199
+ const strings = useUiStrings();
200
+ const form = useLoginForm("Identifier");
201
+ const { ids, portal, identifier, setValue, identifierRef, appearance, classNames } = form;
202
+ const { invalid, below, describedBy } = fieldErrorOf("identifier", form);
203
+ const hideLabel = appearance === "card";
204
+ const text = label ?? portal?.identifierLabel ?? strings.identifier;
205
+ return (
206
+ <div className="grid gap-1.5" data-login-field="identifier">
207
+ <Field
208
+ label={text}
209
+ controlId={ids.identifier}
210
+ classNames={{ label: hideLabel ? "sr-only" : "" }}
211
+ className={cn(fieldClasses, classNames?.identifier, className)}
212
+ >
213
+ {/* biome-ignore lint/complexity/noUselessFragments: stops Field cloning empty aria props over the error wiring */}
214
+ <>
215
+ <Input
216
+ ref={identifierRef}
217
+ id={ids.identifier}
218
+ name="identifier"
219
+ size="lg"
220
+ autoComplete="username"
221
+ autoCapitalize="none"
222
+ spellCheck={false}
223
+ placeholder={placeholder ?? (hideLabel ? text : undefined)}
224
+ value={identifier}
225
+ onChange={(event) => setValue("identifier", event.currentTarget.value)}
226
+ start={<Mail />}
227
+ classNames={invalid ? INVALID_INPUT : undefined}
228
+ aria-invalid={invalid || undefined}
229
+ aria-describedby={describedBy}
230
+ />
231
+ </>
232
+ </Field>
233
+ {below ? <FieldError id={ids.fieldError}>{below}</FieldError> : null}
234
+ </div>
235
+ );
236
+ }
237
+
238
+ export interface LoginFormPasswordProps extends LoginFormFieldProps {
239
+ /** Adds a "Forgot your password?" link to this address. */
240
+ forgotHref?: string;
241
+ /** Replaces the forgot link with any node (a router link, a button). */
242
+ forgot?: ReactNode;
243
+ }
244
+
245
+ export function LoginFormPassword({
246
+ label,
247
+ placeholder,
248
+ forgotHref,
249
+ forgot,
250
+ className,
251
+ }: LoginFormPasswordProps) {
252
+ const strings = useUiStrings();
253
+ const form = useLoginForm("Password");
254
+ const { ids, password, setValue, passwordRef, appearance, classNames } = form;
255
+ const { invalid, below, describedBy } = fieldErrorOf("password", form);
256
+ const hideLabel = appearance === "card";
257
+ const text = label ?? strings.password;
258
+ const link =
259
+ forgot ??
260
+ (forgotHref ? (
261
+ <a
262
+ href={forgotHref}
263
+ className="font-medium text-accent-ink text-control underline underline-offset-3 focus-visible:focus-ring"
264
+ >
265
+ {strings.forgotPassword}
266
+ </a>
267
+ ) : null);
268
+ return (
269
+ <div className="grid gap-1.5" data-login-field="password">
270
+ <Field
271
+ label={text}
272
+ controlId={ids.password}
273
+ classNames={{ label: hideLabel ? "sr-only" : "" }}
274
+ className={cn(fieldClasses, classNames?.password, className)}
275
+ >
276
+ {/* biome-ignore lint/complexity/noUselessFragments: stops Field cloning empty aria props over the error wiring */}
277
+ <>
278
+ <PasswordInput
279
+ ref={passwordRef}
280
+ id={ids.password}
281
+ name="password"
282
+ size="lg"
283
+ start={<Lock />}
284
+ placeholder={placeholder ?? (hideLabel ? text : undefined)}
285
+ value={password}
286
+ onChange={(event) => setValue("password", event.currentTarget.value)}
287
+ classNames={invalid ? INVALID_INPUT : undefined}
288
+ aria-invalid={invalid || undefined}
289
+ aria-describedby={describedBy}
290
+ />
291
+ </>
292
+ </Field>
293
+ {below ? <FieldError id={ids.fieldError}>{below}</FieldError> : null}
294
+ {link ? <div className="justify-self-end">{link}</div> : null}
295
+ </div>
296
+ );
297
+ }
298
+
299
+ export interface LoginFormErrorProps extends Omit<ComponentPropsWithoutRef<"p">, "children"> {}
300
+
301
+ /**
302
+ * Live region for errors about the sign-in itself (wrong credentials, a server message), shown as a
303
+ * callout with an alert icon; place it above the fields. A field left empty is reported under that
304
+ * field instead. It stays in the page while empty so the message is announced.
305
+ */
306
+ export function LoginFormError({ className, ...props }: LoginFormErrorProps) {
307
+ const { ids, error, errorPlacement, classNames } = useLoginForm("Error");
308
+ const message = errorPlacement === "form" ? error : null;
309
+ return (
310
+ <p
311
+ {...props}
312
+ id={ids.error}
313
+ role="alert"
314
+ className={cn(
315
+ "m-0 empty:absolute",
316
+ message &&
317
+ "flex items-start gap-2 rounded-input bg-danger-soft px-3 py-2.5 font-semibold text-danger text-meta [&>svg]:mt-px [&>svg]:size-4 [&>svg]:shrink-0",
318
+ classNames?.error,
319
+ className,
320
+ )}
321
+ >
322
+ {message ? (
323
+ <>
324
+ <CircleAlert aria-hidden="true" />
325
+ {message}
326
+ </>
327
+ ) : null}
328
+ </p>
329
+ );
330
+ }
331
+
332
+ export interface LoginFormSubmitProps extends Omit<ButtonProps, "type" | "loading"> {}
333
+
334
+ export function LoginFormSubmit({ children, className, ...props }: LoginFormSubmitProps) {
335
+ const strings = useUiStrings();
336
+ const { loading, appearance, classNames } = useLoginForm("Submit");
337
+ return (
338
+ <Button
339
+ variant="primary"
340
+ size="lg"
341
+ block
342
+ {...props}
343
+ type="submit"
344
+ loading={loading}
345
+ className={cn(appearance === "open" && "rounded-pill", classNames?.submit, className)}
346
+ >
347
+ {/* The busy button keeps its colour, so the spinner is what shows the request is running. */}
348
+ {loading ? <Spinner size="sm" label={false} /> : null}
349
+ {children ?? strings.signInAction}
350
+ </Button>
351
+ );
352
+ }
353
+
354
+ export interface LoginFormFooterProps extends ComponentPropsWithoutRef<"div"> {}
355
+
356
+ /** Terms and privacy links under the form. In the card appearance it is a strip running edge to edge. */
357
+ export function LoginFormFooter({ className, ...props }: LoginFormFooterProps) {
358
+ const { appearance, classNames } = useLoginForm("Footer");
359
+ return (
360
+ <div
361
+ {...props}
362
+ className={cn(
363
+ "text-ink-3 text-meta [&_a]:text-inherit [&_a]:underline [&_a]:underline-offset-2",
364
+ appearance === "card"
365
+ ? "-mx-7 -mb-5.5 mt-1 border-t-divider px-5 py-3.5 text-center @max-md/auth:-mx-1 @max-md/auth:px-1"
366
+ : "text-center",
367
+ classNames?.footer,
368
+ className,
369
+ )}
370
+ />
371
+ );
372
+ }
373
+
374
+ export { Lock as LoginFormLockIcon };
375
+
376
+ export interface LoginFormOptionsProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
377
+ /** Label of the checkbox. Defaults to the localized "Remember me". */
378
+ rememberLabel?: string;
379
+ /** Help link or button at the end of the row. */
380
+ help?: ReactNode;
381
+ /** Adds the localized "Need help?" link to this address when `help` is not given. */
382
+ helpHref?: string;
383
+ }
384
+
385
+ /** Row under the fields with a remember-me checkbox (reported to `onSubmit` as `remember`) and a help slot. */
386
+ export function LoginFormOptions({
387
+ rememberLabel,
388
+ help,
389
+ helpHref,
390
+ className,
391
+ ...props
392
+ }: LoginFormOptionsProps) {
393
+ const strings = useUiStrings();
394
+ const { remember, setRemember, classNames } = useLoginForm("Options");
395
+ const link =
396
+ help ??
397
+ (helpHref ? (
398
+ <a
399
+ href={helpHref}
400
+ className="font-medium text-accent-ink text-control underline underline-offset-3 focus-visible:focus-ring"
401
+ >
402
+ {strings.needHelp}
403
+ </a>
404
+ ) : null);
405
+ return (
406
+ <div
407
+ {...props}
408
+ className={cn(
409
+ "flex flex-wrap items-center justify-between gap-x-4 gap-y-2",
410
+ classNames?.options,
411
+ className,
412
+ )}
413
+ >
414
+ <Checkbox
415
+ name="remember"
416
+ checked={remember}
417
+ onCheckedChange={(checked) => setRemember(checked === true)}
418
+ label={rememberLabel ?? strings.rememberMe}
419
+ classNames={{ wrapper: "-ml-2.75" }}
420
+ />
421
+ {link}
422
+ </div>
423
+ );
424
+ }
425
+
426
+ export interface LoginFormProvidersProps extends ComponentPropsWithoutRef<"div"> {
427
+ /** Text on the divider above the providers. Defaults to the localized "Or log in with". */
428
+ label?: string;
429
+ }
430
+
431
+ /**
432
+ * Labelled slot for alternative ways to sign in. The library ships no providers: it renders only
433
+ * the children you pass (buttons, links) in a wrapping row, and nothing when there are none.
434
+ */
435
+ export function LoginFormProviders({
436
+ label,
437
+ children,
438
+ className,
439
+ ...props
440
+ }: LoginFormProvidersProps) {
441
+ const strings = useUiStrings();
442
+ const { classNames } = useLoginForm("Providers");
443
+ if (children === undefined || children === null || children === false) return null;
444
+ const text = label ?? strings.orLogInWith;
445
+ return (
446
+ // biome-ignore lint/a11y/useSemanticElements: a fieldset would add a legend and form-disabling behaviour the slot does not want
447
+ <div
448
+ {...props}
449
+ role="group"
450
+ aria-label={text}
451
+ className={cn("grid gap-3", classNames?.providers, className)}
452
+ >
453
+ <Divider>{text}</Divider>
454
+ <div className="flex flex-wrap items-center justify-center gap-2.5">{children}</div>
455
+ </div>
456
+ );
457
+ }
@@ -0,0 +1,38 @@
1
+ "use client";
2
+
3
+ import {
4
+ AuthIllustration,
5
+ type AuthIllustrationProps,
6
+ } from "../auth-illustration/auth-illustration.js";
7
+ import type { AuthLook } from "../auth-illustration/look.js";
8
+ import { Character } from "../character/character.js";
9
+ import { Mosaic } from "../mosaic/mosaic.js";
10
+ import { Slabs } from "../slabs/slabs.js";
11
+ import { Stack } from "../stack/stack.js";
12
+ import { Statement } from "../statement/statement.js";
13
+
14
+ export type AuthIllustrationVariant = "slabs" | "stack" | "mosaic" | "character" | "statement";
15
+
16
+ /** The five looks by name. Importing this module keeps all of them in the bundle. */
17
+ export const AUTH_LOOKS: Readonly<Record<AuthIllustrationVariant, AuthLook>> = {
18
+ slabs: Slabs,
19
+ stack: Stack,
20
+ mosaic: Mosaic,
21
+ character: Character,
22
+ statement: Statement,
23
+ };
24
+
25
+ export interface AuthIllustrationAnyProps extends Omit<AuthIllustrationProps, "look"> {
26
+ /** The look by name. Defaults to `slabs`. */
27
+ variant?: AuthIllustrationVariant;
28
+ }
29
+
30
+ /**
31
+ * `AuthIllustration` with the look chosen by a string. It imports all five looks on purpose, so an
32
+ * app that renders it pays for every look in its bundle (about 2 to 3 KB gzip each). Apps that use
33
+ * one look should pass it to `AuthIllustration` from its own entry, for example
34
+ * `@jcsoftdev/ui/auth/stack`.
35
+ */
36
+ export function AuthIllustrationAny({ variant = "slabs", ...props }: AuthIllustrationAnyProps) {
37
+ return <AuthIllustration {...props} look={AUTH_LOOKS[variant]} />;
38
+ }
@@ -0,0 +1 @@
1
+ export * from "./auth-illustration-any.js";
@@ -0,0 +1 @@
1
+ export * from "./mosaic.js";