@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,13 @@
1
+ import type { AuthVariantProps } from "../auth-illustration/look.js";
2
+ /**
3
+ * Kinetic type in the spirit of a product statement: the headline rises word by word and gives way
4
+ * to a short "signed in" line on success. Under it a pill is a progress meter, not a control: it
5
+ * fills toward the arrow at its end as the form fills, the arrow turns solid once the form is
6
+ * complete, and the pill pops on success. The text is real content, so this look is not hidden from assistive
7
+ * technology; `headline`, `caption` and `action` come from `AuthIllustration`.
8
+ */
9
+ export declare function Statement({ state, progress, headline, caption, action }: AuthVariantProps): import("react").JSX.Element;
10
+ export declare namespace Statement {
11
+ var variant: string;
12
+ var text: boolean;
13
+ }
@@ -0,0 +1,99 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useUiStrings } from "../../i18n/index.js";
4
+ const CSS = `
5
+ @keyframes ui-stm-shake{20%,60%{transform:translateX(-8px)}40%,80%{transform:translateX(8px)}}
6
+ @keyframes ui-stm-pop{40%{transform:scale(1.06)}}
7
+ .ui-stm{--stm-ink:var(--ink);--stm-soft:color-mix(in srgb,var(--ink) 66%,transparent);--stm-track:color-mix(in srgb,var(--accent) 26%,transparent);--stm-fill:var(--accent);--stm-goal:color-mix(in srgb,var(--ink) 10%,var(--surface));--stm-goal-arrow:color-mix(in srgb,var(--ink) 50%,var(--surface));--stm-knob:var(--ink);--stm-arrow:var(--surface);display:grid;gap:clamp(14px,4cqi,28px);justify-items:start;padding-block:clamp(8px,4cqi,32px);text-align:start;font-family:var(--font-sans)}
8
+ .ui-auth-art[data-panel=solid] .ui-stm{--stm-ink:var(--auth-art-ink);--stm-soft:var(--auth-art-ink);--stm-track:color-mix(in srgb,var(--auth-art-ink) 22%,transparent);--stm-fill:var(--auth-art-ink);--stm-goal:color-mix(in srgb,var(--auth-art-ink) 32%,var(--auth-art-bg));--stm-goal-arrow:var(--auth-art-ink);--stm-knob:var(--auth-art-bg);--stm-arrow:var(--auth-art-ink)}
9
+ .ui-stm-lines{display:grid;margin:0;color:var(--stm-ink);font-size:clamp(30px,12.5cqi,92px);font-weight:var(--text-page-title--font-weight,800);letter-spacing:-.035em;line-height:.98;text-wrap:balance}
10
+ .ui-stm-line{grid-area:1/1}
11
+ .ui-stm-mask{display:inline-block;overflow:clip;padding-bottom:.08em;vertical-align:top}
12
+ .ui-stm-word{display:inline-block;transform:translateY(0);transition:transform .7s cubic-bezier(.2,.8,.2,1);transition-delay:calc(var(--i) * 55ms)}
13
+ .ui-stm-line[data-line=done] .ui-stm-word{transform:translateY(140%)}
14
+ .ui-auth-art[data-state=success] .ui-stm-line[data-line=main] .ui-stm-word{transform:translateY(-140%);transition-delay:calc(var(--i) * 40ms)}
15
+ .ui-auth-art[data-state=success] .ui-stm-line[data-line=done] .ui-stm-word{transform:translateY(0);transition-delay:calc(.25s + var(--i) * 70ms)}
16
+ .ui-stm-enter .ui-stm-word{animation:ui-stm-rise .8s cubic-bezier(.2,.8,.2,1) backwards;animation-delay:calc(.1s + var(--i) * 70ms)}
17
+ @keyframes ui-stm-rise{from{transform:translateY(140%)}}
18
+ .ui-stm-caption{margin:0;max-width:34ch;color:var(--stm-soft);font-size:clamp(14px,3.6cqi,19px);line-height:1.45}
19
+ .ui-stm-row{display:flex;flex-wrap:wrap;align-items:center;gap:12px}
20
+ .ui-stm-pill{font-size:clamp(15px,4.4cqi,26px);--pad:.3em;--knob:2.1em;position:relative;display:block;overflow:hidden;width:clamp(140px,40cqi,260px);height:calc(var(--knob) + var(--pad) * 2);border-radius:999px;background:var(--stm-track)}
21
+ .ui-stm-fill{position:absolute;inset:0;border-radius:inherit;background:var(--stm-fill);transform:scaleX(var(--p));transform-origin:0 50%;transition:transform .5s cubic-bezier(.2,.8,.2,1)}
22
+ .ui-stm-knob{position:absolute;top:var(--pad);right:var(--pad);display:grid;place-items:center;width:var(--knob);height:var(--knob);border-radius:999px;background:var(--stm-knob);color:var(--stm-goal-arrow);isolation:isolate}
23
+ .ui-stm-knob::before{content:"";position:absolute;inset:0;z-index:-1;border-radius:inherit;background:var(--stm-goal);transition:opacity .35s linear}
24
+ .ui-stm-pill[data-ready] .ui-stm-knob{color:var(--stm-arrow)}
25
+ .ui-stm-pill[data-ready] .ui-stm-knob::before{opacity:0}
26
+ .ui-stm-knob svg{width:46%;height:46%}
27
+ .ui-auth-art[data-state=success] .ui-stm-pill{animation:ui-stm-pop .5s cubic-bezier(.34,1.5,.5,1) .35s}
28
+ .ui-auth-art[data-state=error] .ui-stm-pill{animation:ui-stm-shake .5s cubic-bezier(.2,.7,.2,1)}
29
+ .ui-auth-art[data-state=error] .ui-stm-fill{background:var(--danger)}
30
+ @media (prefers-reduced-motion:reduce){
31
+ .ui-stm *,.ui-auth-art[data-state] .ui-stm *{animation:none!important;transition:none!important}
32
+ }
33
+ `;
34
+ function Words({
35
+ text,
36
+ line,
37
+ hidden
38
+ }) {
39
+ const words = typeof text === "string" ? text.split(/\s+/).filter(Boolean) : [text];
40
+ return /* @__PURE__ */ jsx("span", { className: "ui-stm-line", "data-line": line, "aria-hidden": hidden || void 0, children: words.map((word, i) => (
41
+ // biome-ignore lint/suspicious/noArrayIndexKey: words repeat, their order is their identity
42
+ /* @__PURE__ */ jsxs("span", { children: [
43
+ /* @__PURE__ */ jsx("span", { className: "ui-stm-mask", children: /* @__PURE__ */ jsx("span", { className: "ui-stm-word", style: { "--i": i }, children: word }) }),
44
+ i < words.length - 1 ? " " : null
45
+ ] }, i)
46
+ )) });
47
+ }
48
+ function Statement({ state, progress, headline, caption, action }) {
49
+ const strings = useUiStrings();
50
+ const signedIn = state === "success";
51
+ const p = signedIn ? 1 : progress;
52
+ return /* @__PURE__ */ jsxs("div", { className: "ui-stm", children: [
53
+ /* @__PURE__ */ jsx("style", { href: "jcsoftdev-ui-auth-statement", precedence: "default", children: CSS }),
54
+ /* @__PURE__ */ jsxs("p", { className: "ui-stm-lines ui-stm-enter", children: [
55
+ /* @__PURE__ */ jsx(Words, { text: headline ?? strings.welcomeBack, line: "main", hidden: signedIn }),
56
+ /* @__PURE__ */ jsx(Words, { text: strings.signedIn, line: "done", hidden: !signedIn })
57
+ ] }),
58
+ caption != null ? /* @__PURE__ */ jsx(
59
+ "p",
60
+ {
61
+ className: "ui-stm-caption",
62
+ "aria-hidden": signedIn || void 0,
63
+ style: signedIn ? { visibility: "hidden" } : void 0,
64
+ children: caption
65
+ }
66
+ ) : null,
67
+ /* @__PURE__ */ jsxs("div", { className: "ui-stm-row", children: [
68
+ /* @__PURE__ */ jsxs(
69
+ "span",
70
+ {
71
+ className: "ui-stm-pill",
72
+ "aria-hidden": "true",
73
+ "data-ready": p >= 1 || void 0,
74
+ style: { "--p": p },
75
+ children: [
76
+ /* @__PURE__ */ jsx("span", { className: "ui-stm-fill" }),
77
+ /* @__PURE__ */ jsx("span", { className: "ui-stm-knob", children: /* @__PURE__ */ jsx(
78
+ "svg",
79
+ {
80
+ viewBox: "0 0 24 24",
81
+ fill: "none",
82
+ stroke: "currentColor",
83
+ strokeWidth: "2.6",
84
+ "aria-hidden": "true",
85
+ children: /* @__PURE__ */ jsx("path", { d: "M4 12h15M13 6l6 6-6 6", strokeLinecap: "round", strokeLinejoin: "round" })
86
+ }
87
+ ) })
88
+ ]
89
+ }
90
+ ),
91
+ action
92
+ ] })
93
+ ] });
94
+ }
95
+ Statement.variant = "statement";
96
+ Statement.text = true;
97
+ export {
98
+ Statement
99
+ };
@@ -16,6 +16,7 @@ export * from "./input-icon/index.js";
16
16
  export * from "./label/index.js";
17
17
  export * from "./native-select/index.js";
18
18
  export * from "./number-stepper/index.js";
19
+ export * from "./password-input/index.js";
19
20
  export * from "./pin-input/index.js";
20
21
  export * from "./radio-button-group/index.js";
21
22
  export * from "./rating/index.js";
@@ -16,6 +16,7 @@ export * from "./input-icon/index.js";
16
16
  export * from "./label/index.js";
17
17
  export * from "./native-select/index.js";
18
18
  export * from "./number-stepper/index.js";
19
+ export * from "./password-input/index.js";
19
20
  export * from "./pin-input/index.js";
20
21
  export * from "./radio-button-group/index.js";
21
22
  export * from "./rating/index.js";
@@ -74,7 +74,8 @@ function Input({
74
74
  size === "lg" && "text-fs-140",
75
75
  classNames?.input
76
76
  ),
77
- ...props
77
+ ...props,
78
+ style: { outline: "none", ...props.style }
78
79
  }
79
80
  ),
80
81
  end != null ? /* @__PURE__ */ jsx("span", { className: cn(adornment, classNames?.end), children: end }) : null
@@ -0,0 +1 @@
1
+ export * from "./password-input.js";
@@ -0,0 +1 @@
1
+ export * from "./password-input.js";
@@ -0,0 +1,16 @@
1
+ import { type InputProps } from "../input/input.js";
2
+ export interface PasswordInputProps extends Omit<InputProps, "type" | "end"> {
3
+ /** Whether the password is shown as text. Controlled; omit it for an uncontrolled field. */
4
+ revealed?: boolean;
5
+ /** Initial visibility of an uncontrolled field. Defaults to hidden. */
6
+ defaultRevealed?: boolean;
7
+ onRevealedChange?: (revealed: boolean) => void;
8
+ /** Accessible name of the reveal toggle; defaults to the UI string `showPassword`. */
9
+ revealLabel?: string;
10
+ }
11
+ /**
12
+ * Password field with a reveal toggle at its end. The toggle keeps one name and reports the
13
+ * state through `aria-pressed`, so a screen reader hears "Show password, pressed" rather than a
14
+ * label that flips. Toggling never moves focus out of the field's row and never submits a form.
15
+ */
16
+ export declare function PasswordInput({ revealed: revealedProp, defaultRevealed, onRevealedChange, revealLabel, autoComplete, ...props }: PasswordInputProps): import("react").JSX.Element;
@@ -0,0 +1,45 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { IconButton } from "../../atoms/icon-button/icon-button.js";
4
+ import { useUiStrings } from "../../i18n/index.js";
5
+ import { Eye, EyeOff } from "../../icons/index.js";
6
+ import { useControllableState } from "../../utils/use-controllable-state.js";
7
+ import { Input } from "../input/input.js";
8
+ function PasswordInput({
9
+ revealed: revealedProp,
10
+ defaultRevealed = false,
11
+ onRevealedChange,
12
+ revealLabel,
13
+ autoComplete = "current-password",
14
+ ...props
15
+ }) {
16
+ const strings = useUiStrings();
17
+ const [revealed, setRevealed] = useControllableState({
18
+ prop: revealedProp,
19
+ defaultProp: defaultRevealed,
20
+ onChange: onRevealedChange
21
+ });
22
+ return /* @__PURE__ */ jsx(
23
+ Input,
24
+ {
25
+ ...props,
26
+ type: revealed ? "text" : "password",
27
+ autoComplete,
28
+ end: /* @__PURE__ */ jsx(
29
+ IconButton,
30
+ {
31
+ label: revealLabel ?? strings.showPassword,
32
+ "aria-pressed": revealed,
33
+ variant: "ghost",
34
+ size: "sm",
35
+ className: "-mr-1.5",
36
+ onClick: () => setRevealed((current) => !current),
37
+ children: revealed ? /* @__PURE__ */ jsx(EyeOff, {}) : /* @__PURE__ */ jsx(Eye, {})
38
+ }
39
+ )
40
+ }
41
+ );
42
+ }
43
+ export {
44
+ PasswordInput
45
+ };
@@ -56,6 +56,38 @@ export interface UiStrings {
56
56
  selectAll: string;
57
57
  /** Name of the overflow menu trigger of a `TableActionsCell`. */
58
58
  rowActions: string;
59
+ /** Name of the `PasswordInput` toggle; its pressed state says whether the password is visible. */
60
+ showPassword: string;
61
+ /** Default title of a `LoginForm`. */
62
+ signIn: string;
63
+ /** Label of the portal picker of a `LoginForm`. */
64
+ signInAs: string;
65
+ /** Divider between the portal picker and the credential fields. */
66
+ withYourAccount: string;
67
+ /** Default label and placeholder of the `LoginForm` identifier field. */
68
+ identifier: string;
69
+ /** Default label and placeholder of the `LoginForm` password field. */
70
+ password: string;
71
+ /** Default `LoginForm` link to recover a password. */
72
+ forgotPassword: string;
73
+ /** Submit button label of a `LoginForm`. */
74
+ signInAction: string;
75
+ /** Inline error of a `LoginForm` submitted without an identifier. */
76
+ enterIdentifier: string;
77
+ /** Inline error of a `LoginForm` submitted without a password. */
78
+ enterPassword: string;
79
+ /** Label of the remember-me checkbox of `LoginForm.Options`. */
80
+ rememberMe: string;
81
+ /** Default help link of `LoginForm.Options`. */
82
+ needHelp: string;
83
+ /** Default label of `LoginForm.Providers`. */
84
+ orLogInWith: string;
85
+ /** Message shown by a `LoginForm` when sign-in fails and the app gives none. */
86
+ signInFailed: string;
87
+ /** Default headline of the `statement` look of `AuthIllustration`. */
88
+ welcomeBack: string;
89
+ /** Line the `statement` look of `AuthIllustration` shows once sign-in succeeds. */
90
+ signedIn: string;
59
91
  }
60
92
  export type UiLocale = "en" | "es";
61
93
  export declare const uiStrings: {
@@ -106,6 +138,22 @@ export declare const uiStrings: {
106
138
  readonly selectRow: "Select {row}";
107
139
  readonly selectAll: "Select all rows";
108
140
  readonly rowActions: "Row actions";
141
+ readonly showPassword: "Show password";
142
+ readonly signIn: "Sign in";
143
+ readonly signInAs: "Sign in as";
144
+ readonly withYourAccount: "with your account";
145
+ readonly identifier: "Email or ID";
146
+ readonly password: "Password";
147
+ readonly forgotPassword: "Forgot your password?";
148
+ readonly signInAction: "Sign in";
149
+ readonly enterIdentifier: "Enter your email or ID.";
150
+ readonly enterPassword: "Enter your password.";
151
+ readonly rememberMe: "Remember me";
152
+ readonly needHelp: "Need help?";
153
+ readonly orLogInWith: "Or log in with";
154
+ readonly signInFailed: "We could not sign you in. Check your details and try again.";
155
+ readonly welcomeBack: "Good to see you again.";
156
+ readonly signedIn: "You're in.";
109
157
  };
110
158
  readonly es: {
111
159
  readonly retry: "Reintentar";
@@ -154,5 +202,21 @@ export declare const uiStrings: {
154
202
  readonly selectRow: "Seleccionar {row}";
155
203
  readonly selectAll: "Seleccionar todas las filas";
156
204
  readonly rowActions: "Acciones de la fila";
205
+ readonly showPassword: "Mostrar contraseña";
206
+ readonly signIn: "Inicia sesión";
207
+ readonly signInAs: "Ingresar como";
208
+ readonly withYourAccount: "con tu cuenta";
209
+ readonly identifier: "Correo o documento";
210
+ readonly password: "Contraseña";
211
+ readonly forgotPassword: "¿Olvidaste tu contraseña?";
212
+ readonly signInAction: "Ingresar";
213
+ readonly enterIdentifier: "Escribe tu correo o documento.";
214
+ readonly enterPassword: "Escribe tu contraseña.";
215
+ readonly rememberMe: "Recordarme";
216
+ readonly needHelp: "¿Necesitas ayuda?";
217
+ readonly orLogInWith: "O ingresa con";
218
+ readonly signInFailed: "No pudimos iniciar tu sesión. Revisa tus datos e inténtalo de nuevo.";
219
+ readonly welcomeBack: "Qué bueno verte otra vez.";
220
+ readonly signedIn: "Ya estás dentro.";
157
221
  };
158
222
  };
@@ -45,7 +45,23 @@ const uiStrings = {
45
45
  stepError: "Has an error",
46
46
  selectRow: "Select {row}",
47
47
  selectAll: "Select all rows",
48
- rowActions: "Row actions"
48
+ rowActions: "Row actions",
49
+ showPassword: "Show password",
50
+ signIn: "Sign in",
51
+ signInAs: "Sign in as",
52
+ withYourAccount: "with your account",
53
+ identifier: "Email or ID",
54
+ password: "Password",
55
+ forgotPassword: "Forgot your password?",
56
+ signInAction: "Sign in",
57
+ enterIdentifier: "Enter your email or ID.",
58
+ enterPassword: "Enter your password.",
59
+ rememberMe: "Remember me",
60
+ needHelp: "Need help?",
61
+ orLogInWith: "Or log in with",
62
+ signInFailed: "We could not sign you in. Check your details and try again.",
63
+ welcomeBack: "Good to see you again.",
64
+ signedIn: "You're in."
49
65
  },
50
66
  es: {
51
67
  retry: "Reintentar",
@@ -93,7 +109,23 @@ const uiStrings = {
93
109
  stepError: "Tiene un error",
94
110
  selectRow: "Seleccionar {row}",
95
111
  selectAll: "Seleccionar todas las filas",
96
- rowActions: "Acciones de la fila"
112
+ rowActions: "Acciones de la fila",
113
+ showPassword: "Mostrar contrase\xF1a",
114
+ signIn: "Inicia sesi\xF3n",
115
+ signInAs: "Ingresar como",
116
+ withYourAccount: "con tu cuenta",
117
+ identifier: "Correo o documento",
118
+ password: "Contrase\xF1a",
119
+ forgotPassword: "\xBFOlvidaste tu contrase\xF1a?",
120
+ signInAction: "Ingresar",
121
+ enterIdentifier: "Escribe tu correo o documento.",
122
+ enterPassword: "Escribe tu contrase\xF1a.",
123
+ rememberMe: "Recordarme",
124
+ needHelp: "\xBFNecesitas ayuda?",
125
+ orLogInWith: "O ingresa con",
126
+ signInFailed: "No pudimos iniciar tu sesi\xF3n. Revisa tus datos e int\xE9ntalo de nuevo.",
127
+ welcomeBack: "Qu\xE9 bueno verte otra vez.",
128
+ signedIn: "Ya est\xE1s dentro."
97
129
  }
98
130
  };
99
131
  export {
@@ -0,0 +1,2 @@
1
+ import { type IconProps } from "./icon-base.js";
2
+ export declare function Eye(props: IconProps): import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { IconBase } from "./icon-base.js";
3
+ function Eye(props) {
4
+ return /* @__PURE__ */ jsxs(IconBase, { ...props, children: [
5
+ /* @__PURE__ */ jsx("path", { d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" }),
6
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "3" })
7
+ ] });
8
+ }
9
+ export {
10
+ Eye
11
+ };
@@ -0,0 +1,2 @@
1
+ import { type IconProps } from "./icon-base.js";
2
+ export declare function GraduationCap(props: IconProps): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { IconBase } from "./icon-base.js";
3
+ function GraduationCap(props) {
4
+ return /* @__PURE__ */ jsxs(IconBase, { ...props, children: [
5
+ /* @__PURE__ */ jsx("path", { d: "M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z" }),
6
+ /* @__PURE__ */ jsx("path", { d: "M22 10v6" }),
7
+ /* @__PURE__ */ jsx("path", { d: "M6 12.5V16a6 3 0 0 0 12 0v-3.5" })
8
+ ] });
9
+ }
10
+ export {
11
+ GraduationCap
12
+ };
@@ -0,0 +1,2 @@
1
+ import { type IconProps } from "./icon-base.js";
2
+ export declare function House(props: IconProps): import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { IconBase } from "./icon-base.js";
3
+ function House(props) {
4
+ return /* @__PURE__ */ jsxs(IconBase, { ...props, children: [
5
+ /* @__PURE__ */ jsx("path", { d: "M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8" }),
6
+ /* @__PURE__ */ jsx("path", { d: "M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" })
7
+ ] });
8
+ }
9
+ export {
10
+ House
11
+ };
@@ -53,6 +53,7 @@ export { CreditCard } from "./credit-card.js";
53
53
  export { Download } from "./download.js";
54
54
  export { EllipsisVertical } from "./ellipsis-vertical.js";
55
55
  export { ExternalLink } from "./external-link.js";
56
+ export { Eye } from "./eye.js";
56
57
  export { EyeOff } from "./eye-off.js";
57
58
  export { FaceSlightlySmiling } from "./face-slightly-smiling.js";
58
59
  export { FaceSlightlySmilingPlus } from "./face-slightly-smiling-plus.js";
@@ -65,8 +66,10 @@ export { Filter } from "./filter.js";
65
66
  export { Folder } from "./folder.js";
66
67
  export { FolderOpen } from "./folder-open.js";
67
68
  export { Funnel } from "./funnel.js";
69
+ export { GraduationCap } from "./graduation-cap.js";
68
70
  export { GripVertical } from "./grip-vertical.js";
69
71
  export { Heading2 } from "./heading-2.js";
72
+ export { House } from "./house.js";
70
73
  export { Inbox } from "./inbox.js";
71
74
  export { Info } from "./info.js";
72
75
  export { Italic } from "./italic.js";
@@ -83,6 +86,7 @@ export { ListOrdered } from "./list-ordered.js";
83
86
  export { LoaderCircle } from "./loader-circle.js";
84
87
  export { Lock } from "./lock.js";
85
88
  export { LogOut } from "./log-out.js";
89
+ export { Mail } from "./mail.js";
86
90
  export { MapPin } from "./map-pin.js";
87
91
  export { Menu } from "./menu.js";
88
92
  export { MessageCircle } from "./message-circle.js";
@@ -53,6 +53,7 @@ import { CreditCard } from "./credit-card.js";
53
53
  import { Download } from "./download.js";
54
54
  import { EllipsisVertical } from "./ellipsis-vertical.js";
55
55
  import { ExternalLink } from "./external-link.js";
56
+ import { Eye } from "./eye.js";
56
57
  import { EyeOff } from "./eye-off.js";
57
58
  import { FaceSlightlySmiling } from "./face-slightly-smiling.js";
58
59
  import { FaceSlightlySmilingPlus } from "./face-slightly-smiling-plus.js";
@@ -65,8 +66,10 @@ import { Filter } from "./filter.js";
65
66
  import { Folder } from "./folder.js";
66
67
  import { FolderOpen } from "./folder-open.js";
67
68
  import { Funnel } from "./funnel.js";
69
+ import { GraduationCap } from "./graduation-cap.js";
68
70
  import { GripVertical } from "./grip-vertical.js";
69
71
  import { Heading2 } from "./heading-2.js";
72
+ import { House } from "./house.js";
70
73
  import { Inbox } from "./inbox.js";
71
74
  import { Info } from "./info.js";
72
75
  import { Italic } from "./italic.js";
@@ -83,6 +86,7 @@ import { ListOrdered } from "./list-ordered.js";
83
86
  import { LoaderCircle } from "./loader-circle.js";
84
87
  import { Lock } from "./lock.js";
85
88
  import { LogOut } from "./log-out.js";
89
+ import { Mail } from "./mail.js";
86
90
  import { MapPin } from "./map-pin.js";
87
91
  import { Menu } from "./menu.js";
88
92
  import { MessageCircle } from "./message-circle.js";
@@ -200,6 +204,7 @@ export {
200
204
  Download,
201
205
  EllipsisVertical,
202
206
  ExternalLink,
207
+ Eye,
203
208
  EyeOff,
204
209
  FaceSlightlySmiling,
205
210
  FaceSlightlySmilingPlus,
@@ -212,8 +217,10 @@ export {
212
217
  Folder,
213
218
  FolderOpen,
214
219
  Funnel,
220
+ GraduationCap,
215
221
  GripVertical,
216
222
  Heading2,
223
+ House,
217
224
  Inbox,
218
225
  Info,
219
226
  Italic,
@@ -230,6 +237,7 @@ export {
230
237
  LoaderCircle,
231
238
  Lock,
232
239
  LogOut,
240
+ Mail,
233
241
  MapPin,
234
242
  Menu,
235
243
  MessageCircle,
@@ -0,0 +1,2 @@
1
+ import { type IconProps } from "./icon-base.js";
2
+ export declare function Mail(props: IconProps): import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { IconBase } from "./icon-base.js";
3
+ function Mail(props) {
4
+ return /* @__PURE__ */ jsxs(IconBase, { ...props, children: [
5
+ /* @__PURE__ */ jsx("path", { d: "m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7" }),
6
+ /* @__PURE__ */ jsx("rect", { x: "2", y: "4", width: "20", height: "16", rx: "2" })
7
+ ] });
8
+ }
9
+ export {
10
+ Mail
11
+ };
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2
+ <path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" />
3
+ <circle cx="12" cy="12" r="3" />
4
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2
+ <path d="M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z" />
3
+ <path d="M22 10v6" />
4
+ <path d="M6 12.5V16a6 3 0 0 0 12 0v-3.5" />
5
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2
+ <path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8" />
3
+ <path d="M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" />
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2
+ <path d="m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7" />
3
+ <rect x="2" y="4" width="20" height="16" rx="2" />
4
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcsoftdev/ui",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Token-driven React component library: React 19, Tailwind v4.",
5
5
  "author": "jcsoftdev",
6
6
  "license": "MIT",
@@ -102,7 +102,7 @@
102
102
  "typescript": "^5.5.4",
103
103
  "vite": "7.3.6",
104
104
  "vitest": "4.1.11",
105
- "@jcsoftdev/ui-tokens": "^0.4.0"
105
+ "@jcsoftdev/ui-tokens": "^0.5.0"
106
106
  },
107
107
  "publishConfig": {
108
108
  "access": "public"
@@ -5,6 +5,7 @@ import {
5
5
  type ComponentPropsWithRef,
6
6
  Fragment,
7
7
  isValidElement,
8
+ type MouseEvent,
8
9
  type ReactNode,
9
10
  } from "react";
10
11
  import { useUiStrings } from "../../i18n/index.js";
@@ -19,7 +20,7 @@ export type ButtonSize = "sm" | "md" | "lg";
19
20
  * `cn(buttonVariantClasses.primary, "bg-brand")` on a link, or `{ ...buttonVariantClasses, brand: "..." }`.
20
21
  */
21
22
  export const buttonVariantClasses: Readonly<Record<ButtonVariant, string>> = {
22
- primary: "bg-accent text-on-accent font-bold hover:bg-accent-ink",
23
+ primary: "bg-accent text-on-accent font-bold hover:bg-accent-ink hover:text-surface",
23
24
  secondary: "bg-surface-control text-ink shadow-control hover:bg-surface-2",
24
25
  ghost: "bg-transparent text-ink-2 hover:bg-surface-2 hover:text-ink",
25
26
  danger: "bg-danger-soft text-danger hover:bg-danger-soft/70",
@@ -33,7 +34,7 @@ export const buttonSizeClasses: Readonly<Record<ButtonSize, string>> = {
33
34
  };
34
35
 
35
36
  const baseClasses =
36
- "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";
37
+ "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";
37
38
 
38
39
  export interface ButtonClassOptions {
39
40
  variant?: ButtonVariant;
@@ -64,6 +65,13 @@ export function buttonClasses({
64
65
  export interface ButtonProps extends ComponentPropsWithRef<"button"> {
65
66
  variant?: ButtonVariant;
66
67
  size?: ButtonSize;
68
+ /**
69
+ * Busy state: the button keeps its focus and its full colour, ignores clicks (a submit button no
70
+ * longer submits, including the implicit submit from Enter in a field of its form) and is exposed
71
+ * as `aria-disabled` and `aria-busy`. It is not natively `disabled`, so keyboard focus stays on it
72
+ * while the work runs; pass `disabled` for a button that must leave the tab order. The visible
73
+ * cue is `loadingLabel` or a spinner among the children: without either only the cursor changes.
74
+ */
67
75
  loading?: boolean;
68
76
  /**
69
77
  * Replaces the children while `loading` and is announced to screen readers. Without it the
@@ -86,9 +94,12 @@ export function Button({
86
94
  asChild,
87
95
  className,
88
96
  children,
97
+ onClick,
89
98
  ...props
90
99
  }: ButtonProps) {
91
100
  const strings = useUiStrings();
101
+ // Natively disabled wins; a busy button stays focusable and swallows its activation instead.
102
+ const busy = Boolean(loading) && !disabled;
92
103
  const Comp = asChild ? Slot : "button";
93
104
  // Text runs get their own truncating span so a long label ends in "…" inside a narrow
94
105
  // container instead of overflowing; icons keep their size. Slot needs its single child as is.
@@ -102,9 +113,11 @@ export function Button({
102
113
  <Comp
103
114
  {...(asChild ? {} : { type: "button" })}
104
115
  aria-busy={loading ? "true" : undefined}
105
- disabled={disabled || loading}
116
+ aria-disabled={busy || undefined}
117
+ disabled={disabled}
106
118
  className={buttonClasses({ variant, size, block, className })}
107
119
  {...props}
120
+ onClick={busy ? ignoreClick : onClick}
108
121
  >
109
122
  {content}
110
123
  </Comp>
@@ -120,6 +133,15 @@ export function Button({
120
133
  );
121
134
  }
122
135
 
136
+ /**
137
+ * Cancels the activation of a busy button: no handler runs, a submit button does not submit (an
138
+ * implicit submit from Enter in a field is a click on this button too) and a slotted link does not
139
+ * navigate.
140
+ */
141
+ function ignoreClick(event: MouseEvent<HTMLElement>): void {
142
+ event.preventDefault();
143
+ }
144
+
123
145
  function labelRun(child: ReactNode): ReactNode {
124
146
  if (typeof child === "string" || typeof child === "number") {
125
147
  return <span className="min-w-0 truncate">{child}</span>;