@tomny-dev/uzi 0.14.0-pr.111.381.1.1f0abc3 → 0.14.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 (130) hide show
  1. package/dist/index.cjs +14 -18
  2. package/dist/index.d.ts +0 -2
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +15 -16
  5. package/dist/index57.js +10 -21
  6. package/dist/index57.js.map +1 -1
  7. package/dist/index58.cjs +11 -30
  8. package/dist/index58.cjs.map +1 -1
  9. package/dist/index58.js +14 -101
  10. package/dist/index58.js.map +1 -1
  11. package/dist/index59.cjs +13 -104
  12. package/dist/index59.cjs.map +1 -1
  13. package/dist/index59.js +11 -10
  14. package/dist/index59.js.map +1 -1
  15. package/dist/index60.cjs +13 -11
  16. package/dist/index60.cjs.map +1 -1
  17. package/dist/index60.js +16 -13
  18. package/dist/index60.js.map +1 -1
  19. package/dist/index61.cjs +16 -13
  20. package/dist/index61.cjs.map +1 -1
  21. package/dist/index61.js +8 -10
  22. package/dist/index61.js.map +1 -1
  23. package/dist/index62.cjs +10 -11
  24. package/dist/index62.cjs.map +1 -1
  25. package/dist/index62.js +87 -15
  26. package/dist/index62.js.map +1 -1
  27. package/dist/index63.cjs +89 -15
  28. package/dist/index63.cjs.map +1 -1
  29. package/dist/index63.js +23 -9
  30. package/dist/index63.js.map +1 -1
  31. package/dist/index64.cjs +33 -12
  32. package/dist/index64.cjs.map +1 -1
  33. package/dist/index64.js +43 -89
  34. package/dist/index64.js.map +1 -1
  35. package/dist/index65.cjs +42 -88
  36. package/dist/index65.cjs.map +1 -1
  37. package/dist/index65.js +15 -23
  38. package/dist/index65.js.map +1 -1
  39. package/dist/index66.cjs +21 -33
  40. package/dist/index66.cjs.map +1 -1
  41. package/dist/index66.js +51 -44
  42. package/dist/index66.js.map +1 -1
  43. package/dist/index67.cjs +52 -43
  44. package/dist/index67.cjs.map +1 -1
  45. package/dist/index67.js +14 -14
  46. package/dist/index67.js.map +1 -1
  47. package/dist/index68.cjs +19 -19
  48. package/dist/index68.cjs.map +1 -1
  49. package/dist/index68.js +290 -49
  50. package/dist/index68.js.map +1 -1
  51. package/dist/index69.cjs +290 -51
  52. package/dist/index69.cjs.map +1 -1
  53. package/dist/index69.js +57 -15
  54. package/dist/index69.js.map +1 -1
  55. package/dist/index70.cjs +83 -20
  56. package/dist/index70.cjs.map +1 -1
  57. package/dist/index70.js +418 -276
  58. package/dist/index70.js.map +1 -1
  59. package/dist/index71.cjs +419 -275
  60. package/dist/index71.cjs.map +1 -1
  61. package/dist/index71.js +58 -56
  62. package/dist/index71.js.map +1 -1
  63. package/dist/index72.cjs +85 -82
  64. package/dist/index72.cjs.map +1 -1
  65. package/dist/index72.js +226 -420
  66. package/dist/index72.js.map +1 -1
  67. package/dist/index73.cjs +225 -421
  68. package/dist/index73.cjs.map +1 -1
  69. package/dist/index73.js +42 -58
  70. package/dist/index73.js.map +1 -1
  71. package/dist/index74.cjs +61 -85
  72. package/dist/index74.cjs.map +1 -1
  73. package/dist/index74.js +76 -236
  74. package/dist/index74.js.map +1 -1
  75. package/dist/index75.cjs +75 -235
  76. package/dist/index75.cjs.map +1 -1
  77. package/dist/index75.js +20 -42
  78. package/dist/index75.js.map +1 -1
  79. package/dist/index76.cjs +27 -60
  80. package/dist/index76.cjs.map +1 -1
  81. package/dist/index76.js +88 -73
  82. package/dist/index76.js.map +1 -1
  83. package/dist/index77.cjs +90 -73
  84. package/dist/index77.cjs.map +1 -1
  85. package/dist/index77.js +15 -17
  86. package/dist/index77.js.map +1 -1
  87. package/dist/index78.cjs +19 -22
  88. package/dist/index78.cjs.map +1 -1
  89. package/dist/index78.js +143 -85
  90. package/dist/index78.js.map +1 -1
  91. package/dist/index79.cjs +143 -87
  92. package/dist/index79.cjs.map +1 -1
  93. package/dist/index79.js +91 -19
  94. package/dist/index79.js.map +1 -1
  95. package/dist/index80.cjs +135 -27
  96. package/dist/index80.cjs.map +1 -1
  97. package/dist/index80.js +673 -140
  98. package/dist/index80.js.map +1 -1
  99. package/dist/index81.cjs +673 -140
  100. package/dist/index81.cjs.map +1 -1
  101. package/dist/index81.js +31 -91
  102. package/dist/index81.js.map +1 -1
  103. package/dist/index82.cjs +45 -135
  104. package/dist/index82.cjs.map +1 -1
  105. package/dist/index82.js +206 -667
  106. package/dist/index82.js.map +1 -1
  107. package/dist/index83.cjs +204 -667
  108. package/dist/index83.cjs.map +1 -1
  109. package/dist/index83.js +15 -31
  110. package/dist/index83.js.map +1 -1
  111. package/dist/index84.cjs +21 -45
  112. package/dist/index84.cjs.map +1 -1
  113. package/dist/index84.js +29 -224
  114. package/dist/index84.js.map +1 -1
  115. package/dist/index85.cjs +30 -224
  116. package/dist/index85.cjs.map +1 -1
  117. package/dist/style.css +0 -53
  118. package/package.json +1 -1
  119. package/dist/components/filter-workspace/FilterWorkspace.d.ts +0 -40
  120. package/dist/components/filter-workspace/FilterWorkspace.d.ts.map +0 -1
  121. package/dist/components/filter-workspace/FilterWorkspace.test.d.ts +0 -2
  122. package/dist/components/filter-workspace/FilterWorkspace.test.d.ts.map +0 -1
  123. package/dist/index85.js +0 -19
  124. package/dist/index85.js.map +0 -1
  125. package/dist/index86.cjs +0 -25
  126. package/dist/index86.cjs.map +0 -1
  127. package/dist/index86.js +0 -36
  128. package/dist/index86.js.map +0 -1
  129. package/dist/index87.cjs +0 -37
  130. package/dist/index87.cjs.map +0 -1
package/dist/index71.cjs CHANGED
@@ -1,300 +1,444 @@
1
1
  const require_runtime = require("./index2.cjs");
2
- const require_Button = require("./index6.cjs");
3
- const require_Input = require("./index22.cjs");
4
- const require_AuthCard = require("./index67.cjs");
5
- const require_AuthForm = require("./index69.cjs");
6
- const require_auth_page_module = require("./index70.cjs");
2
+ const require_cx = require("./index4.cjs");
3
+ const require_auth_pages_module = require("./index70.cjs");
7
4
  let react = require("react");
8
5
  react = require_runtime.__toESM(react, 1);
9
6
  let react_jsx_runtime = require("react/jsx-runtime");
10
- //#region src/components/auth-page/AuthPage.tsx
11
- /**
12
- * Complete app-neutral authentication UX. Uzi owns UI state and validation;
13
- * the consuming application owns credentials, sessions, API calls and redirects.
14
- */
15
- function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create your account", signInSubtitle, signUpSubtitle, signInIdentifier, signUpFields = [], requirePasswordConfirmation = true, initialError, footer, minSignInPasswordLength = 0, passwordMaxLength, defaultMode = "signin", mode: controlledMode, onModeChange, onSignIn, onSignUp, onError, initialEmail = "", disabled = false, minPasswordLength = 8, signUpOptions, forgotPasswordHref, className, layout = "fullscreen" }) {
16
- const [internalMode, setInternalMode] = react.useState(defaultMode);
17
- const mode = controlledMode ?? internalMode;
18
- const [email, setEmail] = react.useState(initialEmail);
7
+ //#region src/components/auth-pages/AuthPages.tsx
8
+ function EyeIcon({ open }) {
9
+ if (open) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
10
+ viewBox: "0 0 24 24",
11
+ fill: "none",
12
+ "aria-hidden": "true",
13
+ className: require_auth_pages_module.default.eyeIcon,
14
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
15
+ d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z",
16
+ stroke: "currentColor",
17
+ strokeWidth: "2"
18
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
19
+ cx: "12",
20
+ cy: "12",
21
+ r: "3",
22
+ stroke: "currentColor",
23
+ strokeWidth: "2"
24
+ })]
25
+ });
26
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
27
+ viewBox: "0 0 24 24",
28
+ fill: "none",
29
+ "aria-hidden": "true",
30
+ className: require_auth_pages_module.default.eyeIcon,
31
+ children: [
32
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
33
+ d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94",
34
+ stroke: "currentColor",
35
+ strokeWidth: "2"
36
+ }),
37
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
38
+ d: "M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19",
39
+ stroke: "currentColor",
40
+ strokeWidth: "2"
41
+ }),
42
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
43
+ x1: "1",
44
+ y1: "1",
45
+ x2: "23",
46
+ y2: "23",
47
+ stroke: "currentColor",
48
+ strokeWidth: "2"
49
+ })
50
+ ]
51
+ });
52
+ }
53
+ function Field({ label, id, children, error }) {
54
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
55
+ className: require_auth_pages_module.default.field,
56
+ children: [
57
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
58
+ htmlFor: id,
59
+ className: require_auth_pages_module.default.label,
60
+ children: label
61
+ }),
62
+ children,
63
+ error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
64
+ className: require_auth_pages_module.default.error,
65
+ children: error
66
+ })
67
+ ]
68
+ });
69
+ }
70
+ function PasswordField({ id, label, placeholder, value, onChange, error }) {
71
+ const [show, setShow] = react.useState(false);
72
+ const toggleRef = react.useRef(null);
73
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
74
+ label: label ?? "Password",
75
+ id,
76
+ error,
77
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
78
+ className: require_auth_pages_module.default.passwordWrapper,
79
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
80
+ id,
81
+ type: show ? "text" : "password",
82
+ placeholder,
83
+ value,
84
+ onChange,
85
+ className: require_auth_pages_module.default.input,
86
+ autoComplete: "current-password"
87
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
88
+ ref: toggleRef,
89
+ type: "button",
90
+ onClick: () => setShow((s) => !s),
91
+ className: require_auth_pages_module.default.toggle,
92
+ "aria-label": show ? "Hide password" : "Show password",
93
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EyeIcon, { open: show })
94
+ })]
95
+ })
96
+ });
97
+ }
98
+ function CheckboxRow({ label, linkText, linkHref, checked, onChange }) {
99
+ if (!label) return null;
100
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
101
+ className: require_auth_pages_module.default.checkboxRow,
102
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
103
+ className: require_auth_pages_module.default.checkboxLabel,
104
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
105
+ type: "checkbox",
106
+ className: require_auth_pages_module.default.checkbox,
107
+ checked,
108
+ onChange: (e) => onChange?.(e.target.checked)
109
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: label })]
110
+ }), linkHref && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
111
+ href: linkHref,
112
+ className: require_auth_pages_module.default.forgotLink,
113
+ children: linkText
114
+ })]
115
+ });
116
+ }
117
+ function SignInPage({ title = "Sign in", subtitle, footer, onSubmit, loading = false, brand, className, emailPlaceholder = "Email address", passwordPlaceholder = "Password", rememberLabel = "Remember me", forgotLinkText = "Forgot password?", forgotLinkHref }) {
118
+ const id = react.useId();
119
+ const [email, setEmail] = react.useState("");
19
120
  const [password, setPassword] = react.useState("");
20
- const [confirmPasswordValue, setConfirmPassword] = react.useState("");
21
- const [extraValues, setExtraValues] = react.useState({});
22
- const [acceptedTerms, setAcceptedTerms] = react.useState(false);
23
- const [showPassword, setShowPassword] = react.useState(false);
24
- const [pending, setPending] = react.useState(false);
25
- const pendingRef = react.useRef(false);
121
+ const [rememberMe, setRememberMe] = react.useState(false);
26
122
  const [errors, setErrors] = react.useState({});
27
- const [serverError, setServerError] = react.useState(initialError ?? "");
28
- const id = react.useId();
29
- const emailId = id + "-email";
30
- const passwordId = id + "-password";
31
- const confirmId = id + "-confirm";
32
- const termsId = id + "-terms";
33
- const signup = mode === "signup";
34
- const identifierIsEmail = signup || (signInIdentifier?.type ?? "email") === "email";
35
- const termsRequired = signup && !!signUpOptions?.requireTerms;
36
- const canSwitch = !!onModeChange || !!onSignIn && !!onSignUp;
37
- const fieldNames = signUpFields.map((field) => field.name).join("\\u0000");
38
- react.useEffect(() => {
39
- const activeNames = new Set(fieldNames.split("\\u0000").filter(Boolean));
40
- setExtraValues((previous) => {
41
- if (Object.keys(previous).every((name) => activeNames.has(name))) return previous;
42
- return Object.fromEntries(Object.entries(previous).filter(([name]) => activeNames.has(name)));
43
- });
44
- }, [fieldNames]);
45
- react.useEffect(() => {
46
- setServerError(initialError ?? "");
47
- }, [initialError]);
48
- react.useEffect(() => {
49
- if (initialEmail) setEmail((previous) => previous || initialEmail);
50
- }, [initialEmail]);
51
- const switchMode = (next) => {
52
- if (pendingRef.current || next === mode) return;
53
- setInternalMode(next);
54
- setPassword("");
55
- setConfirmPassword("");
56
- setShowPassword(false);
57
- setErrors({});
58
- setServerError("");
59
- onModeChange?.(next);
123
+ const [submitted, setSubmitted] = react.useState(false);
124
+ const validate = () => {
125
+ const newErrors = {};
126
+ if (!email.trim()) newErrors.email = "Email is required";
127
+ else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) newErrors.email = "Enter a valid email";
128
+ if (!password) newErrors.password = "Password is required";
129
+ setErrors(newErrors);
130
+ return Object.keys(newErrors).length === 0;
60
131
  };
61
- const submit = async (event) => {
62
- event.preventDefault();
63
- if (pendingRef.current || disabled) return;
64
- const nextErrors = {};
65
- const normalizedEmail = email.trim();
66
- if (!normalizedEmail) nextErrors.email = (signup ? "Email" : signInIdentifier?.label ?? "Email") + " is required";
67
- else if (identifierIsEmail && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(normalizedEmail)) nextErrors.email = "Enter a valid email address";
68
- if (!signup && signInIdentifier?.maxLength && normalizedEmail.length > signInIdentifier.maxLength) nextErrors.email = "Identifier is too long";
69
- if (!password) nextErrors.password = "Password is required";
70
- else if (signup && password.length < minPasswordLength) nextErrors.password = `Use at least ${minPasswordLength} characters`;
71
- if (signup && requirePasswordConfirmation && password !== confirmPasswordValue) nextErrors.confirm = "Passwords do not match";
72
- if (!signup && minSignInPasswordLength && password.length < minSignInPasswordLength) nextErrors.password = `Use at least ${minSignInPasswordLength} characters`;
73
- if (passwordMaxLength && password.length > passwordMaxLength) nextErrors.password = "Password is too long";
74
- if (signup) for (const field of signUpFields) {
75
- const value = (extraValues[field.name] ?? "").trim();
76
- if (field.required && !value) nextErrors[field.name] = field.label + " is required";
77
- else if (value && field.minLength && value.length < field.minLength) nextErrors[field.name] = field.label + " is too short";
78
- else if (field.maxLength && value.length > field.maxLength) nextErrors[field.name] = field.label + " is too long";
79
- else if (field.type === "email" && value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) nextErrors[field.name] = "Enter a valid email address";
80
- }
81
- if (termsRequired && !acceptedTerms) nextErrors.terms = "Accept the terms to continue";
82
- setErrors(nextErrors);
83
- setServerError("");
84
- if (Object.keys(nextErrors).length) return;
85
- pendingRef.current = true;
86
- setPending(true);
87
- try {
88
- const credentials = {
89
- email: normalizedEmail,
90
- password
91
- };
92
- if (!signup && signInIdentifier) credentials.identifier = normalizedEmail;
93
- if (signup && signUpFields.length) credentials.fields = Object.fromEntries(signUpFields.map((field) => [field.name, (extraValues[field.name] ?? "").trim()]));
94
- if (signup) {
95
- if (!onSignUp) return;
96
- await onSignUp(credentials);
97
- } else {
98
- if (!onSignIn) return;
99
- await onSignIn(credentials);
100
- }
101
- setPassword("");
102
- setConfirmPassword("");
103
- setExtraValues({});
104
- } catch (error) {
105
- setServerError(error instanceof Error && error.message ? error.message : "Unable to complete the request. Try again.");
106
- onError?.(error, mode);
107
- } finally {
108
- pendingRef.current = false;
109
- setPending(false);
110
- }
132
+ const handleSubmit = (e) => {
133
+ e.preventDefault();
134
+ setSubmitted(true);
135
+ if (!validate()) return;
136
+ onSubmit?.({
137
+ email,
138
+ password,
139
+ rememberMe
140
+ });
111
141
  };
112
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_AuthCard.AuthCard, {
113
- className,
114
- layout,
115
- brand,
116
- title: signup ? signUpTitle : signInTitle,
117
- subtitle: signup ? signUpSubtitle : signInSubtitle,
118
- footer,
119
- children: [canSwitch && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthForm.AuthModeSwitch, {
120
- mode,
121
- onModeChange: switchMode
122
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_AuthForm.AuthForm, {
123
- onSubmit: submit,
124
- noValidate: true,
125
- "aria-busy": pending,
142
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
143
+ className: require_cx.cx(require_auth_pages_module.default.authLayout, className),
144
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
145
+ className: require_auth_pages_module.default.authCard,
126
146
  children: [
127
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthForm.AuthField, {
128
- htmlFor: emailId,
129
- label: signup ? "Email" : signInIdentifier?.label ?? "Email",
130
- error: errors.email,
131
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Input.Input, {
132
- id: emailId,
133
- type: signup ? "email" : signInIdentifier?.type ?? "email",
134
- placeholder: signup ? "you@example.com" : signInIdentifier?.placeholder ?? "you@example.com",
135
- value: email,
136
- autoComplete: signup ? "email" : signInIdentifier?.autoComplete ?? "email",
137
- maxLength: signup ? 254 : signInIdentifier?.maxLength,
138
- required: true,
139
- disabled: disabled || pending,
140
- "aria-invalid": !!errors.email,
141
- "aria-describedby": errors.email ? emailId + "-error" : void 0,
142
- onChange: (event) => {
143
- setEmail(event.target.value);
144
- setErrors((old) => ({
145
- ...old,
146
- email: ""
147
- }));
148
- }
149
- })
150
- }),
151
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthForm.AuthField, {
152
- htmlFor: passwordId,
153
- label: "Password",
154
- error: errors.password,
155
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
156
- className: require_auth_page_module.default.passwordRow,
157
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Input.Input, {
158
- id: passwordId,
159
- type: showPassword ? "text" : "password",
160
- placeholder: signup ? "At least " + minPasswordLength + " characters" : "Enter your password",
161
- value: password,
162
- required: true,
163
- maxLength: passwordMaxLength,
164
- disabled: disabled || pending,
165
- autoComplete: signup ? "new-password" : "current-password",
166
- "aria-invalid": !!errors.password,
167
- "aria-describedby": errors.password ? passwordId + "-error" : void 0,
168
- onChange: (event) => {
169
- setPassword(event.target.value);
170
- setErrors((old) => ({
171
- ...old,
172
- password: ""
173
- }));
174
- }
175
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
176
- type: "button",
177
- className: require_auth_page_module.default.visibility,
178
- disabled: disabled || pending,
179
- "aria-label": showPassword ? "Hide password" : "Show password",
180
- "aria-controls": passwordId,
181
- "aria-pressed": showPassword,
182
- onClick: () => setShowPassword((old) => !old),
183
- children: showPassword ? "Hide" : "Show"
184
- })]
185
- })
147
+ brand && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
148
+ className: require_auth_pages_module.default.authBrand,
149
+ children: brand
186
150
  }),
187
- signup && requirePasswordConfirmation && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthForm.AuthField, {
188
- htmlFor: confirmId,
189
- label: "Confirm password",
190
- error: errors.confirm,
191
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Input.Input, {
192
- id: confirmId,
193
- type: "password",
194
- placeholder: "Re-enter password",
195
- value: confirmPasswordValue,
196
- autoComplete: "new-password",
197
- required: true,
198
- disabled: disabled || pending,
199
- "aria-invalid": !!errors.confirm,
200
- "aria-describedby": errors.confirm ? confirmId + "-error" : void 0,
201
- onChange: (event) => {
202
- setConfirmPassword(event.target.value);
203
- setErrors((old) => ({
204
- ...old,
205
- confirm: ""
206
- }));
207
- }
208
- })
151
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
152
+ className: require_auth_pages_module.default.authHeader,
153
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
154
+ className: require_auth_pages_module.default.authTitle,
155
+ children: title
156
+ }), subtitle && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
157
+ className: require_auth_pages_module.default.authSubtitle,
158
+ children: subtitle
159
+ })]
209
160
  }),
210
- signup && signUpFields.map((field) => {
211
- const fieldId = id + "-" + field.name;
212
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthForm.AuthField, {
213
- htmlFor: fieldId,
214
- label: field.label,
215
- error: errors[field.name],
216
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Input.Input, {
217
- id: fieldId,
218
- type: field.type ?? "text",
219
- value: extraValues[field.name] ?? "",
220
- placeholder: field.placeholder,
221
- autoComplete: field.autoComplete,
222
- required: field.required,
223
- minLength: field.minLength,
224
- maxLength: field.maxLength,
225
- disabled: disabled || pending,
226
- "aria-invalid": !!errors[field.name],
227
- "aria-describedby": errors[field.name] ? fieldId + "-error" : void 0,
228
- onChange: (event) => {
229
- setExtraValues((old) => ({
230
- ...old,
231
- [field.name]: event.target.value
232
- }));
233
- setErrors((old) => ({
234
- ...old,
235
- [field.name]: ""
236
- }));
161
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
162
+ onSubmit: handleSubmit,
163
+ className: require_auth_pages_module.default.authForm,
164
+ children: [
165
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
166
+ label: emailPlaceholder,
167
+ id: id + "-email",
168
+ error: submitted ? errors.email : void 0,
169
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
170
+ id: id + "-email",
171
+ type: "email",
172
+ placeholder: "you@example.com",
173
+ value: email,
174
+ onChange: (e) => setEmail(e.target.value),
175
+ className: require_auth_pages_module.default.input,
176
+ autoComplete: "email",
177
+ autoFocus: true
178
+ })
179
+ }),
180
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PasswordField, {
181
+ label: passwordPlaceholder,
182
+ id: id + "-password",
183
+ placeholder: passwordPlaceholder,
184
+ value: password,
185
+ onChange: (e) => {
186
+ setPassword(e.target.value);
187
+ if (submitted) setSubmitted(false);
188
+ },
189
+ error: submitted ? errors.password : void 0
190
+ }),
191
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckboxRow, {
192
+ label: rememberLabel,
193
+ linkText: forgotLinkText,
194
+ linkHref: forgotLinkHref,
195
+ checked: rememberMe,
196
+ onChange: (c) => {
197
+ setRememberMe(c);
198
+ if (submitted) setSubmitted(false);
237
199
  }
200
+ }),
201
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
202
+ type: "submit",
203
+ disabled: loading,
204
+ className: require_auth_pages_module.default.submitButton,
205
+ children: loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: require_auth_pages_module.default.spinner }), "Signing in..."] }) : "Sign in"
238
206
  })
239
- }, field.name);
207
+ ]
240
208
  }),
241
- termsRequired && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
242
- className: require_auth_page_module.default.terms,
243
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
244
- htmlFor: termsId,
245
- className: require_auth_page_module.default.termsLabel,
246
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
247
- id: termsId,
248
- type: "checkbox",
249
- checked: acceptedTerms,
250
- disabled: disabled || pending,
251
- "aria-invalid": !!errors.terms,
252
- "aria-describedby": errors.terms ? termsId + "-error" : void 0,
253
- onChange: (event) => {
254
- setAcceptedTerms(event.target.checked);
255
- setErrors((old) => ({
256
- ...old,
257
- terms: ""
258
- }));
259
- }
260
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [signUpOptions?.termsLabel ?? "I agree to the ", signUpOptions?.termsHref ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
261
- href: signUpOptions.termsHref,
262
- children: "Terms of Service"
263
- }) : "Terms of Service"] })]
264
- }), errors.terms && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
265
- className: require_auth_page_module.default.error,
266
- id: termsId + "-error",
267
- role: "alert",
268
- children: errors.terms
209
+ footer && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("hr", { className: require_auth_pages_module.default.divider }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
210
+ className: require_auth_pages_module.default.authFooter,
211
+ children: footer
212
+ })] })
213
+ ]
214
+ })
215
+ });
216
+ }
217
+ function SignUpPage({ title = "Create an account", subtitle, footer, onSubmit, loading = false, brand, className, emailPlaceholder = "Email address", passwordPlaceholder = "Password", confirmPasswordPlaceholder = "Confirm password", checkboxLabel, checkboxLinkText, checkboxLinkHref }) {
218
+ const id = react.useId();
219
+ const [email, setEmail] = react.useState("");
220
+ const [password, setPassword] = react.useState("");
221
+ const [confirmPassword, setConfirmPassword] = react.useState("");
222
+ const [agreed, setAgreed] = react.useState(false);
223
+ const [errors, setErrors] = react.useState({});
224
+ const [submitted, setSubmitted] = react.useState(false);
225
+ const validate = () => {
226
+ const newErrors = {};
227
+ if (!email.trim()) newErrors.email = "Email is required";
228
+ else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) newErrors.email = "Enter a valid email";
229
+ if (!password) newErrors.password = "Password is required";
230
+ else if (password.length < 8) newErrors.password = "At least 8 characters";
231
+ if (password !== confirmPassword) newErrors.confirmPassword = "Passwords do not match";
232
+ if (checkboxLabel && !agreed) newErrors.agreed = "You must agree to continue";
233
+ setErrors(newErrors);
234
+ return Object.keys(newErrors).length === 0;
235
+ };
236
+ const handleSubmit = (e) => {
237
+ e.preventDefault();
238
+ setSubmitted(true);
239
+ if (!validate()) return;
240
+ onSubmit?.({
241
+ email,
242
+ password,
243
+ agreed
244
+ });
245
+ };
246
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
247
+ className: require_cx.cx(require_auth_pages_module.default.authLayout, className),
248
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
249
+ className: require_auth_pages_module.default.authCard,
250
+ children: [
251
+ brand && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
252
+ className: require_auth_pages_module.default.authBrand,
253
+ children: brand
254
+ }),
255
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
256
+ className: require_auth_pages_module.default.authHeader,
257
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
258
+ className: require_auth_pages_module.default.authTitle,
259
+ children: title
260
+ }), subtitle && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
261
+ className: require_auth_pages_module.default.authSubtitle,
262
+ children: subtitle
269
263
  })]
270
264
  }),
271
- !signup && forgotPasswordHref && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
272
- className: require_auth_page_module.default.forgot,
273
- href: forgotPasswordHref,
274
- children: "Forgot password?"
265
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
266
+ onSubmit: handleSubmit,
267
+ className: require_auth_pages_module.default.authForm,
268
+ children: [
269
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
270
+ label: emailPlaceholder,
271
+ id: id + "-email",
272
+ error: submitted ? errors.email : void 0,
273
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
274
+ id: id + "-email",
275
+ type: "email",
276
+ placeholder: "you@example.com",
277
+ value: email,
278
+ onChange: (e) => {
279
+ setEmail(e.target.value);
280
+ if (submitted) setSubmitted(false);
281
+ },
282
+ className: require_auth_pages_module.default.input,
283
+ autoComplete: "email",
284
+ autoFocus: true
285
+ })
286
+ }),
287
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PasswordField, {
288
+ label: passwordPlaceholder,
289
+ id: id + "-password",
290
+ placeholder: passwordPlaceholder,
291
+ value: password,
292
+ onChange: (e) => {
293
+ setPassword(e.target.value);
294
+ if (submitted) setSubmitted(false);
295
+ },
296
+ error: submitted ? errors.password : void 0
297
+ }),
298
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PasswordField, {
299
+ label: confirmPasswordPlaceholder,
300
+ id: id + "-confirm",
301
+ placeholder: confirmPasswordPlaceholder,
302
+ value: confirmPassword,
303
+ onChange: (e) => {
304
+ setConfirmPassword(e.target.value);
305
+ if (submitted) setSubmitted(false);
306
+ },
307
+ error: submitted ? errors.confirmPassword : void 0
308
+ }),
309
+ checkboxLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
310
+ className: require_auth_pages_module.default.checkboxRow,
311
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
312
+ className: require_auth_pages_module.default.checkboxLabel,
313
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
314
+ id: id + "-agreed",
315
+ type: "checkbox",
316
+ checked: agreed,
317
+ onChange: (e) => {
318
+ setAgreed(e.target.checked);
319
+ if (submitted) setSubmitted(false);
320
+ },
321
+ className: require_auth_pages_module.default.checkbox
322
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: checkboxLinkText ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
323
+ "I agree to the",
324
+ " ",
325
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
326
+ href: checkboxLinkHref,
327
+ className: require_auth_pages_module.default.checkboxLink,
328
+ children: checkboxLinkText
329
+ })
330
+ ] }) : checkboxLabel })]
331
+ })
332
+ }),
333
+ submitted && errors.agreed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
334
+ className: require_auth_pages_module.default.error,
335
+ children: errors.agreed
336
+ }),
337
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
338
+ type: "submit",
339
+ disabled: loading,
340
+ className: require_auth_pages_module.default.submitButton,
341
+ children: loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: require_auth_pages_module.default.spinner }), "Creating account..."] }) : "Create account"
342
+ })
343
+ ]
275
344
  }),
276
- serverError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
277
- className: require_auth_page_module.default.error,
278
- role: "alert",
279
- children: serverError
345
+ footer && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("hr", { className: require_auth_pages_module.default.divider }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
346
+ className: require_auth_pages_module.default.authFooter,
347
+ children: footer
348
+ })] })
349
+ ]
350
+ })
351
+ });
352
+ }
353
+ function ForgotPasswordPage({ title = "Reset password", subtitle = "Enter your email and we'll send a reset link", footer, onSubmit, loading = false, brand, className, emailPlaceholder = "Email address", buttonText = "Send reset link", backLinkText = "Back to sign in", backLinkHref = "/signin" }) {
354
+ const id = react.useId();
355
+ const [email, setEmail] = react.useState("");
356
+ const [error, setError] = react.useState("");
357
+ const [sent, setSent] = react.useState(false);
358
+ const handleSubmit = (e) => {
359
+ e.preventDefault();
360
+ if (!email.trim()) {
361
+ setError("Email is required");
362
+ return;
363
+ }
364
+ if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
365
+ setError("Enter a valid email");
366
+ return;
367
+ }
368
+ onSubmit?.({ email });
369
+ setSent(true);
370
+ };
371
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
372
+ className: require_cx.cx(require_auth_pages_module.default.authLayout, className),
373
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
374
+ className: require_auth_pages_module.default.authCard,
375
+ children: [
376
+ brand && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
377
+ className: require_auth_pages_module.default.authBrand,
378
+ children: brand
280
379
  }),
281
- !(signup ? onSignUp : onSignIn) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
282
- className: require_auth_page_module.default.error,
283
- role: "status",
284
- children: signup ? "Sign-up is not available." : "Sign-in is not available."
380
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
381
+ className: require_auth_pages_module.default.authHeader,
382
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
383
+ className: require_auth_pages_module.default.authTitle,
384
+ children: title
385
+ }), subtitle && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
386
+ className: require_auth_pages_module.default.authSubtitle,
387
+ children: subtitle
388
+ })]
389
+ }),
390
+ sent ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
391
+ className: require_auth_pages_module.default.sentMessage,
392
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
393
+ className: require_auth_pages_module.default.sentText,
394
+ children: [
395
+ "If an account exists for ",
396
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: email }),
397
+ ", you'll receive a reset link shortly."
398
+ ]
399
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
400
+ href: backLinkHref,
401
+ className: require_auth_pages_module.default.backLink,
402
+ children: backLinkText
403
+ })]
404
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
405
+ onSubmit: handleSubmit,
406
+ className: require_auth_pages_module.default.authForm,
407
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
408
+ label: emailPlaceholder,
409
+ id: id + "-email",
410
+ error,
411
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
412
+ id: id + "-email",
413
+ type: "email",
414
+ placeholder: "you@example.com",
415
+ value: email,
416
+ onChange: (e) => {
417
+ setEmail(e.target.value);
418
+ setError("");
419
+ },
420
+ className: require_auth_pages_module.default.input,
421
+ autoComplete: "email",
422
+ autoFocus: true
423
+ })
424
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
425
+ type: "submit",
426
+ disabled: loading,
427
+ className: require_auth_pages_module.default.submitButton,
428
+ children: loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: require_auth_pages_module.default.spinner }), "Sending..."] }) : buttonText
429
+ })]
285
430
  }),
286
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Button.Button, {
287
- type: "submit",
288
- variant: "primary",
289
- size: "lg",
290
- disabled: disabled || pending || (signup ? !onSignUp : !onSignIn),
291
- children: pending ? signup ? "Creating account..." : "Signing in..." : signup ? "Create account" : "Sign in"
292
- })
431
+ footer && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("hr", { className: require_auth_pages_module.default.divider }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
432
+ className: require_auth_pages_module.default.authFooter,
433
+ children: footer
434
+ })] })
293
435
  ]
294
- })]
436
+ })
295
437
  });
296
438
  }
297
439
  //#endregion
298
- exports.AuthPage = AuthPage;
440
+ exports.ForgotPasswordPage = ForgotPasswordPage;
441
+ exports.SignInPage = SignInPage;
442
+ exports.SignUpPage = SignUpPage;
299
443
 
300
444
  //# sourceMappingURL=index71.cjs.map