@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,102 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0 (2026-10-23)
4
+
5
+ ### Busy buttons keep focus (behavior to check when upgrading)
6
+
7
+ - **`Button` and `IconButton` `loading`** no longer set the native `disabled` attribute. A busy
8
+ button stays focusable, so pressing it from the keyboard leaves focus on it instead of dropping
9
+ to `body`. It is exposed as `aria-disabled="true"` plus `aria-busy="true"` (the status region
10
+ still announces the loading text), it ignores clicks, Enter and Space, and a `type="submit"`
11
+ button does not submit its form, including the implicit submit from Enter in one of its fields.
12
+ The dimmed `disabled` look no longer applies while loading; the spinner or loading label stays
13
+ and the cursor turns to `progress` (a button with neither a `loadingLabel` nor a spinner child
14
+ shows no other visible change, so give it one). Passing `disabled` keeps the native attribute and the dimmed
15
+ look as before, also while loading. Check code that read `button.disabled` or tests that expect
16
+ `toBeDisabled()` on a loading button: they now see `aria-disabled` instead.
17
+
18
+ ### Sign-in screen
19
+
20
+ New `@jcsoftdev/ui/auth` entry, additive and source compatible. Colors come only from the theme
21
+ tokens, so dark mode and every `data-accent` apply without extra code. Guide: `/docs/auth/`.
22
+
23
+ #### Added
24
+
25
+ - **Auth.** `AuthLayout` (`layout` `split`, `split-reverse`, `centered`, driven by its own container
26
+ width; parts `.Brand`, `.Art`, `.Panel`, `.Footer`; controlled or uncontrolled `state`,
27
+ `progress` and `activeIndex`; `useAuthLayout`), `AuthIllustration` (isometric portal slabs that
28
+ react to `state`, `progress` and `activeIndex` with CSS only; under reduced motion each state
29
+ keeps its pose without moving) and `LoginForm` (parts `.Header`, `.Portals`, `.Identifier`, `.Password`, `.Error`,
30
+ `.Submit`, `.Footer`; async `onSubmit`, `loading`, `error`, `success`; drives the surrounding
31
+ layout and works standalone). A field left empty is reported under that field; a failed sign-in
32
+ shows as a callout from `.Error`, placed above the fields in the default composition.
33
+ - **Auth compositions.** `AuthLayout` `panel` (`paper`, `solid`: a solid themed side panel with an
34
+ open form on the other side), `LoginForm` `appearance` (`card`, `open`), `LoginForm.Options`
35
+ (remember me, reported as `remember`, plus a help slot) and `LoginForm.Providers` (a labelled slot,
36
+ no providers included), and `AuthIllustration` `look` as the plug-in point for further looks.
37
+ - **Illustration motion.** Pointer parallax (fine pointers only, one CSS variable write per
38
+ frame), a hop per keystroke, an overshooting entrance, a cheer and burst on success, and an
39
+ error that settles back to the password state after `ERROR_HOLD_MS` (1.1s). Only `transform`
40
+ and `opacity` animate; reduced motion jumps straight to each state's pose (spread at rest, flung
41
+ apart on an error, assembled with a still burst on success) and turns the parallax off, also when
42
+ the setting changes while the page is open.
43
+ - **`Stack` look (`@jcsoftdev/ui/auth/stack`).** A tower of books that gains a book as the form fills,
44
+ wobbles on an error and plants a flag with the active portal's glyph on success; 4, 5 or 6
45
+ books by the width of its container.
46
+ - **`Mosaic` look (`@jcsoftdev/ui/auth/mosaic`).** A floor of isometric tiles that lights diagonally with
47
+ progress, glints per keystroke, glows under the pointer, flashes red on an error and ripples on
48
+ success; three tiles carry the portal glyphs and the active one stands raised.
49
+ - **`Character` look (`@jcsoftdev/ui/auth/character`).** A student on a hover board that follows the
50
+ pointer, looks toward the form while it is typed into, covers their eyes for the password,
51
+ shakes their head on an error and hops with a boost on success.
52
+ - **`Statement` look (`@jcsoftdev/ui/auth/statement`).** Kinetic type: `headline` rises word by word, an
53
+ optional `caption` and `action`, and a pill that fills toward its arrow as a progress meter;
54
+ on success the headline gives way to the new UI string `signedIn` (default headline
55
+ `welcomeBack`). Not hidden from assistive technology. `AuthLayout.Art` forwards `headline`,
56
+ `caption` and `action`.
57
+ - **One entry per look.** `AuthIllustration` takes the look as a component (`look`, default `Slabs`),
58
+ and each look is its own subpath (`@jcsoftdev/ui/auth/slabs`, `stack`, `mosaic`, `character`,
59
+ `statement`), so an app bundles only the looks it renders; each look carries only its own CSS. A look
60
+ is any component typed `AuthLook`, with optional static `variant` (the `data-variant` value) and
61
+ `text` (not hidden from assistive technology). `AuthLayout.Art` takes `look` too.
62
+ `AuthIllustrationAny` (`@jcsoftdev/ui/auth/looks`) keeps the string `variant` and imports all five
63
+ looks on purpose. The `ui/auth` size budget drops back from 32300 to its default-entry weight.
64
+ - **`PasswordInput`** (reveal toggle with `aria-pressed`) and **`Divider`** (optional label).
65
+ - **Icons.** `Eye`, `Mail`, `House` and `GraduationCap`.
66
+ - **UI strings** (en/es) for the sign-in screen and `showPassword`.
67
+
68
+ #### Fixed
69
+
70
+ - **Portal tiles.** A `LoginForm.Portals` tile lifts on keyboard focus as it does on hover, and the
71
+ selected tile shows a check badge besides its colour change, so the choice does not rest on
72
+ colour alone. The badge is decorative; the radio's `aria-checked` still carries the state.
73
+ - **Primary button hover contrast.** On hover the primary `Button` and `IconButton` (and so
74
+ `LoginForm.Submit`) turn their text to `--surface` on the darker `--accent-ink` fill. The text
75
+ kept `--on-accent`, made for the pale `--accent`, and fell to 2.4:1 in light themes for six of the
76
+ seven accents; it is now 5.7:1 or more in every accent, light and dark.
77
+ - **Portal tile edge.** An unselected portal tile draws its border in `--ink-3` instead of
78
+ `--line-strong`, which was 1.5:1 against the card; it is now 5.2:1 or more in light and dark.
79
+ - **Sign in shows it is busy.** `LoginForm.Submit` draws a spinner next to its label while the
80
+ request runs, since a loading button is no longer dimmed.
81
+ - **`Input`** with `start` or `end` draws one focus ring (the wrapper's) instead of a second square
82
+ ring on the inner input.
83
+ - **`LoginForm` posts by default.** The form carries `method="post"`, so a submit before hydration
84
+ can no longer put the identifier and the password in the URL (history, logs, Referer). Pass
85
+ `method` to override it.
86
+ - **Looks are client modules.** Each look and `AuthIllustrationAny` start with `"use client"`, so a
87
+ Server Component can pass `look={Stack}` to `AuthLayout.Art` or `AuthIllustration` without
88
+ Next.js rejecting a function prop.
89
+ - **`LoginForm` state.** The same failed sign-in twice in a row replays the error (a new submit
90
+ leaves the error state first). A controlled `success` or `error` returning to unset derives
91
+ idle, typing or password from focus again. Without portals the form no longer overrides
92
+ `AuthLayout` `defaultActiveIndex`.
93
+ - **`Statement` accessibility.** The visible line is the one assistive technology reads: "You're in."
94
+ replaces the headline on success, and the caption is hidden with it.
95
+ - **Password length no longer reaches the DOM.** `progress` counts the identifier by length but the
96
+ password only as filled or not (new pure `formProgress`), so styles and attributes do not mirror
97
+ how long the password is. The slabs tighten once the password is filled instead of per character,
98
+ and the keystroke hop no longer fires per password character.
99
+
3
100
  ## 0.4.0 (2026-10-21)
4
101
 
5
102
  ### Blocks for application screens
package/README.md CHANGED
@@ -147,7 +147,7 @@ older components already ship (NumberStepper, Carousel, AI set) are not routed t
147
147
 
148
148
  | Component | Added |
149
149
  | --- | --- |
150
- | `Button` | `loadingLabel` (shown instead of the children while `loading`, announced through a status region), `block` (full width), `size="lg"` (52px at normal density, scaled like the other controls). |
150
+ | `Button` | `loading` keeps the button focusable (`aria-disabled` and `aria-busy`, clicks and form submission ignored, not dimmed; `disabled` still disables natively), `loadingLabel` (shown instead of the children while `loading`, announced through a status region), `block` (full width), `size="lg"` (52px at normal density, scaled like the other controls). |
151
151
  | `Field` | `optional` appends the localized "(optional)" marker to the label; `error` also accepts `null`. |
152
152
  | `Banner` | `appearance="outline"` (page surface, only the border carries the tone; default `soft`), `title`; a default glyph per tone when `icon` is not passed (`icon={null}` hides it, so status never relies on color alone); only `danger` is `role="alert"`, the rest are `role="status"`; the `info` tone uses the `info` tokens. |
153
153
  | `Chip` | `icon`, `statusIcon` (prefixes `info`, `success`, `warning`, `danger` chips with their glyph), and an `info` tone. |
@@ -22,6 +22,13 @@ export declare function buttonClasses({ variant, size, block, className, }?: But
22
22
  export interface ButtonProps extends ComponentPropsWithRef<"button"> {
23
23
  variant?: ButtonVariant;
24
24
  size?: ButtonSize;
25
+ /**
26
+ * Busy state: the button keeps its focus and its full colour, ignores clicks (a submit button no
27
+ * longer submits, including the implicit submit from Enter in a field of its form) and is exposed
28
+ * as `aria-disabled` and `aria-busy`. It is not natively `disabled`, so keyboard focus stays on it
29
+ * while the work runs; pass `disabled` for a button that must leave the tab order. The visible
30
+ * cue is `loadingLabel` or a spinner among the children: without either only the cursor changes.
31
+ */
25
32
  loading?: boolean;
26
33
  /**
27
34
  * Replaces the children while `loading` and is announced to screen readers. Without it the
@@ -33,4 +40,4 @@ export interface ButtonProps extends ComponentPropsWithRef<"button"> {
33
40
  /** Render the child element (via Slot) instead of a `<button>`, e.g. a link. */
34
41
  asChild?: boolean;
35
42
  }
36
- export declare function Button({ variant, size, loading, loadingLabel, block, disabled, asChild, className, children, ...props }: ButtonProps): import("react").JSX.Element;
43
+ export declare function Button({ variant, size, loading, loadingLabel, block, disabled, asChild, className, children, onClick, ...props }: ButtonProps): import("react").JSX.Element;
@@ -9,7 +9,7 @@ import { useUiStrings } from "../../i18n/index.js";
9
9
  import { cn } from "../../utils/cn.js";
10
10
  import { Slot } from "../../utils/slot.js";
11
11
  const buttonVariantClasses = {
12
- primary: "bg-accent text-on-accent font-bold hover:bg-accent-ink",
12
+ primary: "bg-accent text-on-accent font-bold hover:bg-accent-ink hover:text-surface",
13
13
  secondary: "bg-surface-control text-ink shadow-control hover:bg-surface-2",
14
14
  ghost: "bg-transparent text-ink-2 hover:bg-surface-2 hover:text-ink",
15
15
  danger: "bg-danger-soft text-danger hover:bg-danger-soft/70"
@@ -19,7 +19,7 @@ const buttonSizeClasses = {
19
19
  md: "h-control px-control-x text-fs-130",
20
20
  lg: "h-control-lg px-control-x text-fs-140"
21
21
  };
22
- const baseClasses = "inline-flex min-w-0 max-w-full cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap rounded-button pressable focus-visible:focus-ring font-[650] no-underline disabled:cursor-not-allowed disabled:opacity-45 [&_svg]:shrink-0";
22
+ const baseClasses = "inline-flex min-w-0 max-w-full cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap rounded-button pressable focus-visible:focus-ring font-[650] no-underline disabled:cursor-not-allowed disabled:opacity-45 aria-busy:cursor-progress aria-busy:scale-none! [&_svg]:shrink-0";
23
23
  function buttonClasses({
24
24
  variant = "secondary",
25
25
  size = "md",
@@ -44,9 +44,11 @@ function Button({
44
44
  asChild,
45
45
  className,
46
46
  children,
47
+ onClick,
47
48
  ...props
48
49
  }) {
49
50
  const strings = useUiStrings();
51
+ const busy = Boolean(loading) && !disabled;
50
52
  const Comp = asChild ? Slot : "button";
51
53
  const showLoadingLabel = loading && loadingLabel !== void 0 && !asChild;
52
54
  const content = showLoadingLabel ? labelRun(loadingLabel) : asChild ? children : Children.map(children, labelRun);
@@ -55,9 +57,11 @@ function Button({
55
57
  {
56
58
  ...asChild ? {} : { type: "button" },
57
59
  "aria-busy": loading ? "true" : void 0,
58
- disabled: disabled || loading,
60
+ "aria-disabled": busy || void 0,
61
+ disabled,
59
62
  className: buttonClasses({ variant, size, block, className }),
60
63
  ...props,
64
+ onClick: busy ? ignoreClick : onClick,
61
65
  children: content
62
66
  }
63
67
  );
@@ -67,6 +71,9 @@ function Button({
67
71
  /* @__PURE__ */ jsx("span", { role: "status", className: "sr-only", children: loading ? loadingLabel ?? strings.loading : null })
68
72
  ] });
69
73
  }
74
+ function ignoreClick(event) {
75
+ event.preventDefault();
76
+ }
70
77
  function labelRun(child) {
71
78
  if (typeof child === "string" || typeof child === "number") {
72
79
  return /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: child });
@@ -0,0 +1,15 @@
1
+ import type { ComponentPropsWithoutRef, ReactNode } from "react";
2
+ import type { ClassNames } from "../../utils/class-names.js";
3
+ export type DividerPart = "root" | "line" | "label";
4
+ export interface DividerProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
5
+ /** Text centered on the rule. Without it the divider is a plain hairline. */
6
+ children?: ReactNode;
7
+ /** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root and is merged last. */
8
+ classNames?: ClassNames<DividerPart>;
9
+ }
10
+ /**
11
+ * Horizontal rule, optionally carrying a short label ("or", "with your account"). It is a
12
+ * separator for assistive technology, so the label is read as part of the separator's name
13
+ * rather than as page content.
14
+ */
15
+ export declare function Divider({ children, className, classNames, ...props }: DividerProps): import("react").JSX.Element;
@@ -0,0 +1,27 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { cn } from "../../utils/cn.js";
3
+ function Divider({ children, className, classNames, ...props }) {
4
+ const labelled = children !== void 0 && children !== null && children !== false;
5
+ const line = cn("h-px min-w-0 flex-1 bg-line", classNames?.line);
6
+ return (
7
+ // biome-ignore lint/a11y/useSemanticElements: an <hr> cannot carry the label between the two rules
8
+ /* @__PURE__ */ jsxs(
9
+ "div",
10
+ {
11
+ role: "separator",
12
+ "aria-orientation": "horizontal",
13
+ "aria-label": labelled && typeof children === "string" ? children : void 0,
14
+ ...props,
15
+ className: cn("flex items-center gap-3 text-ink-3 text-meta", classNames?.root, className),
16
+ children: [
17
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: line }),
18
+ labelled ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn("shrink-0", classNames?.label), children }) : null,
19
+ labelled ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: line }) : null
20
+ ]
21
+ }
22
+ )
23
+ );
24
+ }
25
+ export {
26
+ Divider
27
+ };
@@ -0,0 +1 @@
1
+ export * from "./divider.js";
@@ -0,0 +1 @@
1
+ export * from "./divider.js";
@@ -8,7 +8,7 @@ export interface IconButtonProps extends Omit<ComponentPropsWithRef<"button">, "
8
8
  label: string;
9
9
  variant?: ButtonVariant;
10
10
  size?: IconButtonSize;
11
- /** Swaps the icon for a spinner and disables the button; announces the localized `loading` string. */
11
+ /** Swaps the icon for a spinner and makes the button busy like `Button` `loading`: it keeps focus, ignores clicks and announces the localized `loading` string. */
12
12
  loading?: boolean;
13
13
  /** Render the child element (via Slot) instead of a `<button>`, e.g. a link wrapping the icon. */
14
14
  asChild?: boolean;
@@ -4,6 +4,7 @@ export * from "./big-date/index.js";
4
4
  export * from "./button/index.js";
5
5
  export * from "./checkbox/index.js";
6
6
  export * from "./chip/index.js";
7
+ export * from "./divider/index.js";
7
8
  export * from "./due-chip/index.js";
8
9
  export * from "./icon/index.js";
9
10
  export * from "./icon-button/index.js";
@@ -4,6 +4,7 @@ export * from "./big-date/index.js";
4
4
  export * from "./button/index.js";
5
5
  export * from "./checkbox/index.js";
6
6
  export * from "./chip/index.js";
7
+ export * from "./divider/index.js";
7
8
  export * from "./due-chip/index.js";
8
9
  export * from "./icon/index.js";
9
10
  export * from "./icon-button/index.js";
@@ -0,0 +1,35 @@
1
+ import { type ComponentPropsWithoutRef, type ReactNode } from "react";
2
+ import type { AuthLook } from "./look.js";
3
+ import { type AuthState } from "./model.js";
4
+ export interface AuthIllustrationProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
5
+ /**
6
+ * The look, a component from its own entry (`Stack` from `@jcsoftdev/ui/auth/stack`, and so on).
7
+ * Defaults to `Slabs`; looks you do not pass stay out of your bundle. For a string `variant`
8
+ * use `AuthIllustrationAny` from `@jcsoftdev/ui/auth/looks`.
9
+ */
10
+ look?: AuthLook;
11
+ /** What the screen is doing. Inside an `AuthLayout` it follows the layout's state. */
12
+ state?: AuthState;
13
+ /** Fill of the whole form, 0 to 1. Inside an `AuthLayout` it follows the layout's progress. */
14
+ progress?: number;
15
+ /** Index of the portal being used (0 to 2); that slab rises above the others. */
16
+ activeIndex?: number;
17
+ /**
18
+ * Accessible name of the image. Without it the illustration is decorative and hidden from
19
+ * assistive technology. Ignored by text looks (`Statement`): their text is the content, so they
20
+ * are never an `img` and never hidden.
21
+ */
22
+ label?: string;
23
+ /** Text looks (`Statement`) only: the headline (a string animates word by word). Defaults to the UI string `welcomeBack`. */
24
+ headline?: ReactNode;
25
+ /** Text looks only: a supporting line under the headline. */
26
+ caption?: ReactNode;
27
+ /** Text looks only: content beside the arrow pill, such as a link. */
28
+ action?: ReactNode;
29
+ }
30
+ /**
31
+ * Isometric illustration of the three portals that reacts to the sign-in state with CSS
32
+ * transitions only. Colours come from the theme tokens (`--accent`, `--surface`, `--ink`), so dark
33
+ * mode and every accent apply on their own. With reduced motion it rests assembled and still.
34
+ */
35
+ export declare function AuthIllustration({ look: Look, state: stateProp, progress: progressProp, activeIndex: activeIndexProp, label, headline, caption, action, className, ...props }: AuthIllustrationProps): import("react").JSX.Element;
@@ -0,0 +1,72 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import {
4
+ useEffect,
5
+ useId,
6
+ useRef,
7
+ useState
8
+ } from "react";
9
+ import { cn } from "../../utils/cn.js";
10
+ import { useOptionalAuth } from "../internal/auth-context.js";
11
+ import { AuthStyles } from "../internal/auth-styles.js";
12
+ import { Slabs } from "../slabs/slabs.js";
13
+ import { clamp01, ERROR_HOLD_MS, shownState } from "./model.js";
14
+ import { useArtPointer } from "./use-art-pointer.js";
15
+ function AuthIllustration({
16
+ look: Look = Slabs,
17
+ state: stateProp,
18
+ progress: progressProp,
19
+ activeIndex: activeIndexProp,
20
+ label,
21
+ headline,
22
+ caption,
23
+ action,
24
+ className,
25
+ ...props
26
+ }) {
27
+ const auth = useOptionalAuth();
28
+ const uid = useId().replace(/[^a-zA-Z0-9_-]/g, "");
29
+ const state = stateProp ?? auth?.state ?? "idle";
30
+ const progress = clamp01(progressProp ?? auth?.progress ?? 0);
31
+ const activeIndex = activeIndexProp ?? auth?.activeIndex ?? 0;
32
+ const ref = useRef(null);
33
+ useArtPointer(ref);
34
+ const [errorHeld, setErrorHeld] = useState(false);
35
+ useEffect(() => {
36
+ setErrorHeld(false);
37
+ if (state !== "error") return;
38
+ const timer = setTimeout(() => setErrorHeld(true), ERROR_HOLD_MS);
39
+ return () => clearTimeout(timer);
40
+ }, [state]);
41
+ const shown = shownState(state, errorHeld);
42
+ return /* @__PURE__ */ jsxs(
43
+ "div",
44
+ {
45
+ ...props,
46
+ ref,
47
+ ...Look.text ? {} : label ? { role: "img", "aria-label": label } : { "aria-hidden": true },
48
+ "data-state": shown,
49
+ "data-panel": auth?.panel,
50
+ "data-variant": Look.variant,
51
+ className: cn("ui-auth-art @container/art w-full min-w-0", className),
52
+ children: [
53
+ /* @__PURE__ */ jsx(AuthStyles, {}),
54
+ /* @__PURE__ */ jsx(
55
+ Look,
56
+ {
57
+ state: shown,
58
+ progress,
59
+ activeIndex,
60
+ uid,
61
+ headline,
62
+ caption,
63
+ action
64
+ }
65
+ )
66
+ ]
67
+ }
68
+ );
69
+ }
70
+ export {
71
+ AuthIllustration
72
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./auth-illustration.js";
2
+ export type { AuthLook, AuthVariantProps } from "./look.js";
3
+ export { AUTH_STATES, type AuthState, slabPlacement, slabSpread, } from "./model.js";
@@ -0,0 +1,11 @@
1
+ export * from "./auth-illustration.js";
2
+ import {
3
+ AUTH_STATES,
4
+ slabPlacement,
5
+ slabSpread
6
+ } from "./model.js";
7
+ export {
8
+ AUTH_STATES,
9
+ slabPlacement,
10
+ slabSpread
11
+ };
@@ -0,0 +1,30 @@
1
+ import type { ComponentType, ReactNode } from "react";
2
+ import type { AuthState } from "./model.js";
3
+ /** What every illustration look receives. State and progress come already clamped. */
4
+ export interface AuthVariantProps {
5
+ state: AuthState;
6
+ /** Fill of the whole form, 0 to 1. */
7
+ progress: number;
8
+ /** Index of the portal in use (0 to 2). */
9
+ activeIndex: number;
10
+ /** Unique per rendered illustration; use it to prefix SVG ids (patterns, gradients, clip paths). */
11
+ uid: string;
12
+ /** Text looks only (`statement`): the main line; a string animates word by word. */
13
+ headline?: ReactNode;
14
+ /** Text looks only: a supporting line under the headline. */
15
+ caption?: ReactNode;
16
+ /** Text looks only: content placed beside the arrow pill, such as a link. */
17
+ action?: ReactNode;
18
+ }
19
+ /**
20
+ * A look is a component with {@link AuthVariantProps}. It renders inside a `@container/art` element,
21
+ * so it adapts to the width it is given with `@sm/art:` classes or `@container art (min-width: ...)`
22
+ * rules, and it reads `data-state` from the wrapper for state-driven CSS. Two optional static
23
+ * properties describe it to `AuthIllustration` without a registry: `variant` is the name written
24
+ * to `data-variant`, and `text` marks a look made of text people read, which is then not hidden
25
+ * from assistive technology.
26
+ */
27
+ export type AuthLook = ComponentType<AuthVariantProps> & {
28
+ variant?: string;
29
+ text?: boolean;
30
+ };
File without changes
@@ -0,0 +1,133 @@
1
+ /** What the sign-in screen is doing. It is the only input of the illustration besides `progress`. */
2
+ export type AuthState = "idle" | "typing" | "password" | "error" | "success";
3
+ export declare const AUTH_STATES: readonly AuthState[];
4
+ export declare const clamp01: (value: number) => number;
5
+ /** `progress` is the fill of the whole form: the identifier is the first half, the password the second. */
6
+ export declare const IDENTIFIER_SHARE = 0.5;
7
+ /**
8
+ * How far the three slabs sit apart: 0 is assembled, 1 is the loose resting layout. The slabs
9
+ * drift together as the form fills (first the identifier, then the password), fly apart on an
10
+ * error and lock together on success.
11
+ */
12
+ export declare function slabSpread(state: AuthState, progress: number): number;
13
+ export declare const SLAB_COUNT = 3;
14
+ export interface SlabPlacement {
15
+ x: number;
16
+ y: number;
17
+ lift: number;
18
+ }
19
+ /** Position and height of one slab. The slab at `activeIndex` rises a little above the rest. */
20
+ export declare function slabPlacement(index: number, spread: number, activeIndex: number): SlabPlacement;
21
+ export interface SparkVector {
22
+ dx: number;
23
+ dy: number;
24
+ }
25
+ /** Offsets of the success burst. Deterministic, so server and client render the same markup. */
26
+ export declare function sparkVectors(count?: number): SparkVector[];
27
+ /** How long an error stays on screen before the illustration settles back to the password state. */
28
+ export declare const ERROR_HOLD_MS = 1100;
29
+ /** The state the art shows: an error that has been held long enough reads as `password` again. */
30
+ export declare function shownState(state: AuthState, errorHeld: boolean): AuthState;
31
+ /** Characters of the identifier at which its half of the form reads full; one keystroke moves `progress` by 1/(2 x this). */
32
+ export declare const KEYSTROKES_PER_FIELD = 10;
33
+ /**
34
+ * Fill of the whole form: the identifier grows its half by length, the password adds its half in
35
+ * one step as soon as it is not empty. The password's length never reaches `progress`, because
36
+ * `progress` is written to the DOM (styles, classes) where session-replay tools do not mask it.
37
+ */
38
+ export declare function formProgress(identifierLength: number, passwordFilled: boolean): number;
39
+ export interface Keystroke {
40
+ /** Keystrokes so far across both fields. */
41
+ count: number;
42
+ /** Which of the three pieces reacts to this keystroke. */
43
+ target: number;
44
+ /**
45
+ * Alternates every time the same piece reacts again, so CSS can swap between two identical
46
+ * keyframes and restart the animation without JavaScript timers.
47
+ */
48
+ phase: 0 | 1;
49
+ }
50
+ /** The keystroke a `progress` value stands for. */
51
+ export declare function keystroke(progress: number, pieces?: number): Keystroke;
52
+ export interface PointerOffset {
53
+ x: number;
54
+ y: number;
55
+ }
56
+ /**
57
+ * Where a pointer is relative to a box, as -1 to 1 on each axis from its center (clamped, so a
58
+ * pointer far over the form still reads as "all the way to that side").
59
+ */
60
+ export declare function pointerOffset(point: {
61
+ x: number;
62
+ y: number;
63
+ }, box: {
64
+ left: number;
65
+ top: number;
66
+ width: number;
67
+ height: number;
68
+ }): PointerOffset;
69
+ /** Screen position of a point in isometric space: `u` runs right-down, `v` left-down, `z` up. */
70
+ export declare function isoPoint(u: number, v: number, z?: number): {
71
+ x: number;
72
+ y: number;
73
+ };
74
+ export interface IsoBox {
75
+ top: string;
76
+ /** Face along the front-left edge (`v` at its maximum). */
77
+ left: string;
78
+ /** Face along the front-right edge (`u` at its maximum). */
79
+ right: string;
80
+ }
81
+ /** The three visible faces of a `w` by `d` by `h` box standing on the origin, centred on it. */
82
+ export declare function isoBox(w: number, d: number, h: number): IsoBox;
83
+ export interface StackBook {
84
+ /** Footprint along `u` and `v`, and thickness. */
85
+ w: number;
86
+ d: number;
87
+ h: number;
88
+ /** Offset from the tower's axis, in isometric units, so the pile looks hand stacked. */
89
+ du: number;
90
+ dv: number;
91
+ /** Colour role, 0 to 3. */
92
+ tone: number;
93
+ }
94
+ /** The books of the tower from the bottom up. Narrow containers show only the first ones. */
95
+ export declare const STACK_BOOKS: readonly StackBook[];
96
+ /** How many books a container shows: fewer when it is narrow. */
97
+ export declare const STACK_COUNTS: readonly [4, 5, 6];
98
+ export type StackCount = (typeof STACK_COUNTS)[number];
99
+ /**
100
+ * Books resting in a tower of `count`: the foundation is always there, the rest land one by one
101
+ * as the form fills, and all of them are down on success.
102
+ */
103
+ export declare function stackPlaced(state: AuthState, progress: number, count: number): number;
104
+ export interface StackSlot {
105
+ /** Screen offset of the book's ground centre from the tower's base. */
106
+ x: number;
107
+ y: number;
108
+ }
109
+ /** Where each book sits, from its offsets and the thickness of the books under it. */
110
+ export declare function stackSlots(books?: readonly StackBook[]): StackSlot[];
111
+ /** Top centre of the tower of `count` books, where the success flag is planted. */
112
+ export declare function stackTop(count: number, books?: readonly StackBook[]): StackSlot;
113
+ /** Tiles per side of the mosaic floor; its container picks one by width. */
114
+ export declare const MOSAIC_SIZES: readonly [4, 5, 6];
115
+ export type MosaicSize = (typeof MOSAIC_SIZES)[number];
116
+ /** Diagonals of an `n` by `n` floor that are lit: they fill from the back corner as the form fills. */
117
+ export declare function mosaicFilled(state: AuthState, progress: number, n: number): number;
118
+ export interface MosaicTile {
119
+ row: number;
120
+ col: number;
121
+ /** Diagonal from the back corner, 0 to 2n-2: the fill and the error sweep follow it. */
122
+ diagonal: number;
123
+ /** Steps from the centre: the success ripple follows it. */
124
+ ring: number;
125
+ }
126
+ export declare function mosaicTiles(n: number): MosaicTile[];
127
+ /** Row and column of the tile carrying each portal's glyph, for each floor size. */
128
+ export declare const MOSAIC_GLYPH_TILES: Readonly<Record<MosaicSize, readonly (readonly [number, number])[]>>;
129
+ /** The tile that glints on a keystroke: it jumps around the floor instead of marching in order. */
130
+ export declare function mosaicGlint(count: number, n: number): number;
131
+ /** Lamps along the character's board; they fill with progress. */
132
+ export declare const BOARD_LIGHTS = 5;
133
+ export declare function boardLit(state: AuthState, progress: number): number;