@tomny-dev/uzi 0.13.0 → 0.14.0-pr.109.376.1.629355f
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.
- package/dist/components/auth-page/AuthPage.d.ts +29 -1
- package/dist/components/auth-page/AuthPage.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index68.js +64 -12
- package/dist/index68.js.map +1 -1
- package/dist/index69.cjs +64 -12
- package/dist/index69.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,25 @@ import { type AuthMode } from "../auth-form/AuthForm";
|
|
|
3
3
|
export interface AuthCredentials {
|
|
4
4
|
email: string;
|
|
5
5
|
password: string;
|
|
6
|
+
identifier?: string;
|
|
7
|
+
fields?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
export interface AuthAdditionalField {
|
|
10
|
+
name: string;
|
|
11
|
+
label: string;
|
|
12
|
+
type?: "text" | "email";
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
autoComplete?: string;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
minLength?: number;
|
|
17
|
+
maxLength?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface AuthIdentifierOptions {
|
|
20
|
+
label?: string;
|
|
21
|
+
type?: "text" | "email";
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
autoComplete?: string;
|
|
24
|
+
maxLength?: number;
|
|
6
25
|
}
|
|
7
26
|
export interface AuthPageProps {
|
|
8
27
|
/** Brand/logo above the form. */
|
|
@@ -12,6 +31,15 @@ export interface AuthPageProps {
|
|
|
12
31
|
signUpTitle?: string;
|
|
13
32
|
signInSubtitle?: string;
|
|
14
33
|
signUpSubtitle?: string;
|
|
34
|
+
signInIdentifier?: AuthIdentifierOptions;
|
|
35
|
+
signUpFields?: AuthAdditionalField[];
|
|
36
|
+
/** Optional confirmation field; defaults to true. */
|
|
37
|
+
requirePasswordConfirmation?: boolean;
|
|
38
|
+
/** An app-supplied session verification error. */
|
|
39
|
+
initialError?: string;
|
|
40
|
+
footer?: React.ReactNode;
|
|
41
|
+
minSignInPasswordLength?: number;
|
|
42
|
+
passwordMaxLength?: number;
|
|
15
43
|
/** Initial tab; changes to this prop after mount do not reset the selected tab. */
|
|
16
44
|
defaultMode?: AuthMode;
|
|
17
45
|
/** Optional controlled tab, e.g. when sign-in and sign-up use separate routes. */
|
|
@@ -42,5 +70,5 @@ export interface AuthPageProps {
|
|
|
42
70
|
* Complete app-neutral authentication UX. Uzi owns UI state and validation;
|
|
43
71
|
* the consuming application owns credentials, sessions, API calls and redirects.
|
|
44
72
|
*/
|
|
45
|
-
export declare function AuthPage({ brand, signInTitle, signUpTitle, signInSubtitle, signUpSubtitle, defaultMode, mode: controlledMode, onModeChange, onSignIn, onSignUp, onError, initialEmail, disabled, minPasswordLength, signUpOptions, forgotPasswordHref, className, layout, }: AuthPageProps): import("react/jsx-runtime").JSX.Element;
|
|
73
|
+
export declare function AuthPage({ brand, signInTitle, signUpTitle, signInSubtitle, signUpSubtitle, signInIdentifier, signUpFields, requirePasswordConfirmation, initialError, footer, minSignInPasswordLength, passwordMaxLength, defaultMode, mode: controlledMode, onModeChange, onSignIn, onSignUp, onError, initialEmail, disabled, minPasswordLength, signUpOptions, forgotPasswordHref, className, layout, }: AuthPageProps): import("react/jsx-runtime").JSX.Element;
|
|
46
74
|
//# sourceMappingURL=AuthPage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthPage.d.ts","sourceRoot":"","sources":["../../../src/components/auth-page/AuthPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAuC,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAK3F,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"AuthPage.d.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AmC,EACnC,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,YAAiB,EACjB,2BAAkC,EAClC,YAAY,EACZ,MAAM,EACN,uBAA2B,EAC3B,iBAAiB,EACjB,WAAsB,EACtB,IAAI,EAAE,cAAc,EACpB,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,YAAiB,EACjB,QAAgB,EAChB,iBAAqB,EACrB,aAAa,EACb,kBAAkB,EAClB,SAAS,EACT,MAAqB,GACtB,EAAE,aAAa,2CAkLf"}
|
package/dist/index.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ export type { SelectProps, SelectOption } from "./components/select/Select";
|
|
|
59
59
|
export { Select } from "./components/select/Select";
|
|
60
60
|
export type { SegmentedToggleProps, SegmentedToggleOption } from "./components/segmented-toggle/SegmentedToggle";
|
|
61
61
|
export { SegmentedToggle } from "./components/segmented-toggle/SegmentedToggle";
|
|
62
|
-
export type { AuthPageProps, AuthCredentials } from "./components/auth-page/AuthPage";
|
|
62
|
+
export type { AuthPageProps, AuthCredentials, AuthAdditionalField, AuthIdentifierOptions } from "./components/auth-page/AuthPage";
|
|
63
63
|
export { AuthPage } from "./components/auth-page/AuthPage";
|
|
64
64
|
export type { AuthFormProps, AuthFieldProps, AuthMode, AuthModeSwitchProps } from "./components/auth-form/AuthForm";
|
|
65
65
|
export { AuthForm, AuthField, AuthModeSwitch } from "./components/auth-form/AuthForm";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,mBAAmB,CAAC;AAG3B,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,MA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,YAAY,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAC/G,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAG9E,YAAY,EACV,WAAW,EACX,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,EACzB,uBAAuB,EACvB,gBAAgB,EAChB,0BAA0B,EAC1B,4BAA4B,EAC5B,YAAY,EACZ,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACtF,YAAY,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,YAAY,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AACnH,YAAY,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,wDAAwD,CAAC"}
|
package/dist/index68.js
CHANGED
|
@@ -10,26 +10,31 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
10
10
|
* Complete app-neutral authentication UX. Uzi owns UI state and validation;
|
|
11
11
|
* the consuming application owns credentials, sessions, API calls and redirects.
|
|
12
12
|
*/
|
|
13
|
-
function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create your account", signInSubtitle, signUpSubtitle, defaultMode = "signin", mode: controlledMode, onModeChange, onSignIn, onSignUp, onError, initialEmail = "", disabled = false, minPasswordLength = 8, signUpOptions, forgotPasswordHref, className, layout = "fullscreen" }) {
|
|
13
|
+
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" }) {
|
|
14
14
|
const [internalMode, setInternalMode] = React.useState(defaultMode);
|
|
15
15
|
const mode = controlledMode ?? internalMode;
|
|
16
16
|
const [email, setEmail] = React.useState(initialEmail);
|
|
17
17
|
const [password, setPassword] = React.useState("");
|
|
18
|
-
const [
|
|
18
|
+
const [confirmPasswordValue, setConfirmPassword] = React.useState("");
|
|
19
|
+
const [extraValues, setExtraValues] = React.useState({});
|
|
19
20
|
const [acceptedTerms, setAcceptedTerms] = React.useState(false);
|
|
20
21
|
const [showPassword, setShowPassword] = React.useState(false);
|
|
21
22
|
const [pending, setPending] = React.useState(false);
|
|
22
23
|
const pendingRef = React.useRef(false);
|
|
23
24
|
const [errors, setErrors] = React.useState({});
|
|
24
|
-
const [serverError, setServerError] = React.useState("");
|
|
25
|
+
const [serverError, setServerError] = React.useState(initialError ?? "");
|
|
25
26
|
const id = React.useId();
|
|
26
27
|
const emailId = id + "-email";
|
|
27
28
|
const passwordId = id + "-password";
|
|
28
29
|
const confirmId = id + "-confirm";
|
|
29
30
|
const termsId = id + "-terms";
|
|
30
31
|
const signup = mode === "signup";
|
|
32
|
+
const identifierIsEmail = signup || (signInIdentifier?.type ?? "email") === "email";
|
|
31
33
|
const termsRequired = signup && !!signUpOptions?.requireTerms;
|
|
32
34
|
const canSwitch = !!onModeChange || !!onSignIn && !!onSignUp;
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
setServerError(initialError ?? "");
|
|
37
|
+
}, [initialError]);
|
|
33
38
|
React.useEffect(() => {
|
|
34
39
|
if (initialEmail) setEmail((previous) => previous || initialEmail);
|
|
35
40
|
}, [initialEmail]);
|
|
@@ -48,11 +53,21 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
48
53
|
if (pendingRef.current || disabled) return;
|
|
49
54
|
const nextErrors = {};
|
|
50
55
|
const normalizedEmail = email.trim();
|
|
51
|
-
if (!normalizedEmail) nextErrors.email = "Email is required";
|
|
52
|
-
else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(normalizedEmail)) nextErrors.email = "Enter a valid email address";
|
|
56
|
+
if (!normalizedEmail) nextErrors.email = signup || identifierIsEmail ? "Email is required" : "Identifier is required";
|
|
57
|
+
else if (identifierIsEmail && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(normalizedEmail)) nextErrors.email = "Enter a valid email address";
|
|
58
|
+
if (!signup && signInIdentifier?.maxLength && normalizedEmail.length > signInIdentifier.maxLength) nextErrors.email = "Identifier is too long";
|
|
53
59
|
if (!password) nextErrors.password = "Password is required";
|
|
54
60
|
else if (signup && password.length < minPasswordLength) nextErrors.password = `Use at least ${minPasswordLength} characters`;
|
|
55
|
-
if (signup && password !==
|
|
61
|
+
if (signup && requirePasswordConfirmation && password !== confirmPasswordValue) nextErrors.confirm = "Passwords do not match";
|
|
62
|
+
if (!signup && minSignInPasswordLength && password.length < minSignInPasswordLength) nextErrors.password = `Use at least ${minSignInPasswordLength} characters`;
|
|
63
|
+
if (passwordMaxLength && password.length > passwordMaxLength) nextErrors.password = "Password is too long";
|
|
64
|
+
if (signup) for (const field of signUpFields) {
|
|
65
|
+
const value = (extraValues[field.name] ?? "").trim();
|
|
66
|
+
if (field.required && !value) nextErrors[field.name] = field.label + " is required";
|
|
67
|
+
else if (value && field.minLength && value.length < field.minLength) nextErrors[field.name] = field.label + " is too short";
|
|
68
|
+
else if (field.maxLength && value.length > field.maxLength) nextErrors[field.name] = field.label + " is too long";
|
|
69
|
+
else if (field.type === "email" && value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) nextErrors[field.name] = "Enter a valid email address";
|
|
70
|
+
}
|
|
56
71
|
if (termsRequired && !acceptedTerms) nextErrors.terms = "Accept the terms to continue";
|
|
57
72
|
setErrors(nextErrors);
|
|
58
73
|
setServerError("");
|
|
@@ -64,6 +79,8 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
64
79
|
email: normalizedEmail,
|
|
65
80
|
password
|
|
66
81
|
};
|
|
82
|
+
if (!signup && signInIdentifier) credentials.identifier = normalizedEmail;
|
|
83
|
+
if (signup && signUpFields.length) credentials.fields = Object.fromEntries(signUpFields.map((field) => [field.name, (extraValues[field.name] ?? "").trim()]));
|
|
67
84
|
if (signup) {
|
|
68
85
|
if (!onSignUp) return;
|
|
69
86
|
await onSignUp(credentials);
|
|
@@ -73,6 +90,7 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
73
90
|
}
|
|
74
91
|
setPassword("");
|
|
75
92
|
setConfirmPassword("");
|
|
93
|
+
setExtraValues({});
|
|
76
94
|
} catch (error) {
|
|
77
95
|
setServerError(error instanceof Error && error.message ? error.message : "Unable to complete the request. Try again.");
|
|
78
96
|
onError?.(error, mode);
|
|
@@ -87,6 +105,7 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
87
105
|
brand,
|
|
88
106
|
title: signup ? signUpTitle : signInTitle,
|
|
89
107
|
subtitle: signup ? signUpSubtitle : signInSubtitle,
|
|
108
|
+
footer,
|
|
90
109
|
children: [canSwitch && /* @__PURE__ */ jsx(AuthModeSwitch, {
|
|
91
110
|
mode,
|
|
92
111
|
onModeChange: switchMode
|
|
@@ -97,14 +116,15 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
97
116
|
children: [
|
|
98
117
|
/* @__PURE__ */ jsx(AuthField, {
|
|
99
118
|
htmlFor: emailId,
|
|
100
|
-
label: "Email",
|
|
119
|
+
label: signup ? "Email" : signInIdentifier?.label ?? "Email",
|
|
101
120
|
error: errors.email,
|
|
102
121
|
children: /* @__PURE__ */ jsx(Input, {
|
|
103
122
|
id: emailId,
|
|
104
|
-
type: "email",
|
|
105
|
-
placeholder: "you@example.com",
|
|
123
|
+
type: signup ? "email" : signInIdentifier?.type ?? "email",
|
|
124
|
+
placeholder: signup ? "you@example.com" : signInIdentifier?.placeholder ?? "you@example.com",
|
|
106
125
|
value: email,
|
|
107
|
-
autoComplete: "email",
|
|
126
|
+
autoComplete: signup ? "email" : signInIdentifier?.autoComplete ?? "email",
|
|
127
|
+
maxLength: signup ? 254 : signInIdentifier?.maxLength,
|
|
108
128
|
required: true,
|
|
109
129
|
disabled: disabled || pending,
|
|
110
130
|
"aria-invalid": !!errors.email,
|
|
@@ -130,6 +150,7 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
130
150
|
placeholder: signup ? "At least " + minPasswordLength + " characters" : "Enter your password",
|
|
131
151
|
value: password,
|
|
132
152
|
required: true,
|
|
153
|
+
maxLength: passwordMaxLength,
|
|
133
154
|
disabled: disabled || pending,
|
|
134
155
|
autoComplete: signup ? "new-password" : "current-password",
|
|
135
156
|
"aria-invalid": !!errors.password,
|
|
@@ -153,7 +174,7 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
153
174
|
})]
|
|
154
175
|
})
|
|
155
176
|
}),
|
|
156
|
-
signup && /* @__PURE__ */ jsx(AuthField, {
|
|
177
|
+
signup && requirePasswordConfirmation && /* @__PURE__ */ jsx(AuthField, {
|
|
157
178
|
htmlFor: confirmId,
|
|
158
179
|
label: "Confirm password",
|
|
159
180
|
error: errors.confirm,
|
|
@@ -161,7 +182,7 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
161
182
|
id: confirmId,
|
|
162
183
|
type: "password",
|
|
163
184
|
placeholder: "Re-enter password",
|
|
164
|
-
value:
|
|
185
|
+
value: confirmPasswordValue,
|
|
165
186
|
autoComplete: "new-password",
|
|
166
187
|
required: true,
|
|
167
188
|
disabled: disabled || pending,
|
|
@@ -176,6 +197,37 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
176
197
|
}
|
|
177
198
|
})
|
|
178
199
|
}),
|
|
200
|
+
signup && signUpFields.map((field) => {
|
|
201
|
+
const fieldId = id + "-" + field.name;
|
|
202
|
+
return /* @__PURE__ */ jsx(AuthField, {
|
|
203
|
+
htmlFor: fieldId,
|
|
204
|
+
label: field.label,
|
|
205
|
+
error: errors[field.name],
|
|
206
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
207
|
+
id: fieldId,
|
|
208
|
+
type: field.type ?? "text",
|
|
209
|
+
value: extraValues[field.name] ?? "",
|
|
210
|
+
placeholder: field.placeholder,
|
|
211
|
+
autoComplete: field.autoComplete,
|
|
212
|
+
required: field.required,
|
|
213
|
+
minLength: field.minLength,
|
|
214
|
+
maxLength: field.maxLength,
|
|
215
|
+
disabled: disabled || pending,
|
|
216
|
+
"aria-invalid": !!errors[field.name],
|
|
217
|
+
"aria-describedby": errors[field.name] ? fieldId + "-error" : void 0,
|
|
218
|
+
onChange: (event) => {
|
|
219
|
+
setExtraValues((old) => ({
|
|
220
|
+
...old,
|
|
221
|
+
[field.name]: event.target.value
|
|
222
|
+
}));
|
|
223
|
+
setErrors((old) => ({
|
|
224
|
+
...old,
|
|
225
|
+
[field.name]: ""
|
|
226
|
+
}));
|
|
227
|
+
}
|
|
228
|
+
})
|
|
229
|
+
}, field.name);
|
|
230
|
+
}),
|
|
179
231
|
termsRequired && /* @__PURE__ */ jsxs("div", {
|
|
180
232
|
className: auth_page_module_default.terms,
|
|
181
233
|
children: [/* @__PURE__ */ jsxs("label", {
|
package/dist/index68.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index68.js","names":[],"sources":["../src/components/auth-page/AuthPage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { AuthCard } from \"../auth-card/AuthCard\";\nimport { AuthField, AuthForm, AuthModeSwitch, type AuthMode } from \"../auth-form/AuthForm\";\nimport { Input } from \"../input/Input\";\nimport { Button } from \"../button/Button\";\nimport styles from \"./auth-page.module.css\";\n\nexport interface AuthCredentials {\n email: string;\n password: string;\n}\n\nexport interface AuthPageProps {\n /** Brand/logo above the form. */\n brand?: React.ReactNode;\n /** Title for each mode. */\n signInTitle?: string;\n signUpTitle?: string;\n signInSubtitle?: string;\n signUpSubtitle?: string;\n /** Initial tab; changes to this prop after mount do not reset the selected tab. */\n defaultMode?: AuthMode;\n /** Optional controlled tab, e.g. when sign-in and sign-up use separate routes. */\n mode?: AuthMode;\n onModeChange?: (mode: AuthMode) => void;\n /** App-specific auth callbacks; throwing an Error displays an inline failure. */\n onSignIn?: (credentials: AuthCredentials) => Promise<unknown> | unknown;\n onSignUp?: (credentials: AuthCredentials) => Promise<unknown> | unknown;\n onError?: (error: unknown, mode: AuthMode) => void;\n /** Prefill email without ever populating a password. */\n initialEmail?: string;\n /** Prevent submission until the app's authentication provider is ready. */\n disabled?: boolean;\n /** Minimum password length for account creation; default 8. */\n minPasswordLength?: number;\n /** Optional terms requirement for sign-up only. */\n signUpOptions?: {\n requireTerms?: boolean;\n termsHref?: string;\n termsLabel?: string;\n };\n /** Optional app-owned password recovery route. */\n forgotPasswordHref?: string;\n className?: string;\n layout?: \"fullscreen\" | \"embedded\";\n}\n\n/**\n * Complete app-neutral authentication UX. Uzi owns UI state and validation;\n * the consuming application owns credentials, sessions, API calls and redirects.\n */\nexport function AuthPage({\n brand,\n signInTitle = \"Welcome back\",\n signUpTitle = \"Create your account\",\n signInSubtitle,\n signUpSubtitle,\n defaultMode = \"signin\",\n mode: controlledMode,\n onModeChange,\n onSignIn,\n onSignUp,\n onError,\n initialEmail = \"\",\n disabled = false,\n minPasswordLength = 8,\n signUpOptions,\n forgotPasswordHref,\n className,\n layout = \"fullscreen\",\n}: AuthPageProps) {\n const [internalMode, setInternalMode] = React.useState<AuthMode>(defaultMode);\n const mode = controlledMode ?? internalMode;\n const [email, setEmail] = React.useState(initialEmail);\n const [password, setPassword] = React.useState(\"\");\n const [confirmPassword, setConfirmPassword] = React.useState(\"\");\n const [acceptedTerms, setAcceptedTerms] = React.useState(false);\n const [showPassword, setShowPassword] = React.useState(false);\n const [pending, setPending] = React.useState(false);\n const pendingRef = React.useRef(false);\n const [errors, setErrors] = React.useState<Record<string, string>>({});\n const [serverError, setServerError] = React.useState(\"\");\n const id = React.useId();\n const emailId = id + \"-email\";\n const passwordId = id + \"-password\";\n const confirmId = id + \"-confirm\";\n const termsId = id + \"-terms\";\n const signup = mode === \"signup\";\n const termsRequired = signup && !!signUpOptions?.requireTerms;\n const canSwitch = !!onModeChange || (!!onSignIn && !!onSignUp);\n\n React.useEffect(() => {\n // Changes from an authenticated account may prefill the email after hydration.\n if (initialEmail) setEmail((previous) => previous || initialEmail);\n }, [initialEmail]);\n\n const switchMode = (next: AuthMode) => {\n if (pendingRef.current || next === mode) return;\n setInternalMode(next);\n setPassword(\"\");\n setConfirmPassword(\"\");\n setShowPassword(false);\n setErrors({});\n setServerError(\"\");\n onModeChange?.(next);\n };\n\n const submit = async (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n if (pendingRef.current || disabled) return;\n const nextErrors: Record<string, string> = {};\n const normalizedEmail = email.trim();\n if (!normalizedEmail) nextErrors.email = \"Email is required\";\n else if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(normalizedEmail)) nextErrors.email = \"Enter a valid email address\";\n if (!password) nextErrors.password = \"Password is required\";\n else if (signup && password.length < minPasswordLength) nextErrors.password = `Use at least ${minPasswordLength} characters`;\n if (signup && password !== confirmPassword) nextErrors.confirm = \"Passwords do not match\";\n if (termsRequired && !acceptedTerms) nextErrors.terms = \"Accept the terms to continue\";\n setErrors(nextErrors);\n setServerError(\"\");\n if (Object.keys(nextErrors).length) return;\n\n pendingRef.current = true;\n setPending(true);\n try {\n const credentials = { email: normalizedEmail, password };\n if (signup) {\n if (!onSignUp) return;\n await onSignUp(credentials);\n } else {\n if (!onSignIn) return;\n await onSignIn(credentials);\n }\n setPassword(\"\");\n setConfirmPassword(\"\");\n } catch (error) {\n setServerError(error instanceof Error && error.message ? error.message : \"Unable to complete the request. Try again.\");\n onError?.(error, mode);\n } finally {\n pendingRef.current = false;\n setPending(false);\n }\n };\n\n return (\n <AuthCard\n className={className}\n layout={layout}\n brand={brand}\n title={signup ? signUpTitle : signInTitle}\n subtitle={signup ? signUpSubtitle : signInSubtitle}\n >\n {canSwitch && <AuthModeSwitch mode={mode} onModeChange={switchMode} />}\n <AuthForm onSubmit={submit} noValidate aria-busy={pending}>\n <AuthField htmlFor={emailId} label=\"Email\" error={errors.email}>\n <Input\n id={emailId} type=\"email\" placeholder=\"you@example.com\" value={email}\n autoComplete=\"email\" required disabled={disabled || pending}\n aria-invalid={!!errors.email} aria-describedby={errors.email ? emailId + \"-error\" : undefined}\n onChange={(event) => { setEmail(event.target.value); setErrors((old) => ({ ...old, email: \"\" })); }}\n />\n </AuthField>\n <AuthField htmlFor={passwordId} label=\"Password\" error={errors.password}>\n <div className={styles.passwordRow}>\n <Input\n id={passwordId} type={showPassword ? \"text\" : \"password\"}\n placeholder={signup ? \"At least \" + minPasswordLength + \" characters\" : \"Enter your password\"}\n value={password} required disabled={disabled || pending}\n autoComplete={signup ? \"new-password\" : \"current-password\"}\n aria-invalid={!!errors.password} aria-describedby={errors.password ? passwordId + \"-error\" : undefined}\n onChange={(event) => { setPassword(event.target.value); setErrors((old) => ({ ...old, password: \"\" })); }}\n />\n <button type=\"button\" className={styles.visibility} disabled={disabled || pending}\n aria-label={showPassword ? \"Hide password\" : \"Show password\"}\n aria-controls={passwordId} aria-pressed={showPassword}\n onClick={() => setShowPassword((old) => !old)}>\n {showPassword ? \"Hide\" : \"Show\"}\n </button>\n </div>\n </AuthField>\n {signup && (\n <AuthField htmlFor={confirmId} label=\"Confirm password\" error={errors.confirm}>\n <Input id={confirmId} type=\"password\" placeholder=\"Re-enter password\" value={confirmPassword}\n autoComplete=\"new-password\" required disabled={disabled || pending}\n aria-invalid={!!errors.confirm} aria-describedby={errors.confirm ? confirmId + \"-error\" : undefined}\n onChange={(event) => { setConfirmPassword(event.target.value); setErrors((old) => ({ ...old, confirm: \"\" })); }} />\n </AuthField>\n )}\n {termsRequired && (\n <div className={styles.terms}>\n <label htmlFor={termsId} className={styles.termsLabel}>\n <input id={termsId} type=\"checkbox\" checked={acceptedTerms} disabled={disabled || pending}\n aria-invalid={!!errors.terms} aria-describedby={errors.terms ? termsId + \"-error\" : undefined}\n onChange={(event) => { setAcceptedTerms(event.target.checked); setErrors((old) => ({ ...old, terms: \"\" })); }} />\n <span>{signUpOptions?.termsLabel ?? \"I agree to the \"}\n {signUpOptions?.termsHref ? <a href={signUpOptions.termsHref}>Terms of Service</a> : \"Terms of Service\"}\n </span>\n </label>\n {errors.terms && <p className={styles.error} id={termsId + \"-error\"} role=\"alert\">{errors.terms}</p>}\n </div>\n )}\n {!signup && forgotPasswordHref && <a className={styles.forgot} href={forgotPasswordHref}>Forgot password?</a>}\n {serverError && <p className={styles.error} role=\"alert\">{serverError}</p>}\n {!(signup ? onSignUp : onSignIn) && (\n <p className={styles.error} role=\"status\">\n {signup ? \"Sign-up is not available.\" : \"Sign-in is not available.\"}\n </p>\n )}\n <Button type=\"submit\" variant=\"primary\" size=\"lg\" disabled={disabled || pending || (signup ? !onSignUp : !onSignIn)}>\n {pending ? (signup ? \"Creating account...\" : \"Signing in...\") : (signup ? \"Create account\" : \"Sign in\")}\n </Button>\n </AuthForm>\n </AuthCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAmDA,SAAgB,SAAS,EACvB,OACA,cAAc,gBACd,cAAc,uBACd,gBACA,gBACA,cAAc,UACd,MAAM,gBACN,cACA,UACA,UACA,SACA,eAAe,IACf,WAAW,OACX,oBAAoB,GACpB,eACA,oBACA,WACA,SAAS,gBACO;CAChB,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAmB,WAAW;CAC5E,MAAM,OAAO,kBAAkB;CAC/B,MAAM,CAAC,OAAO,YAAY,MAAM,SAAS,YAAY;CACrD,MAAM,CAAC,UAAU,eAA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SAAS;OAAe,UAAU,YAAY;OAChF,gBAAc,CAAC,CAAC,OAAO;OAAO,oBAAkB,OAAO,QAAQ,UAAU,WAAW,KAAA;OACpF,WAAW,UAAU;QAAE,iBAAiB,MAAM,OAAO,OAAO;QAAG,WAAW,SAAS;SAAE,GAAG;SAAK,OAAO;QAAG,EAAE;OAAG;MAAI,CAAA,GAClH,qBAAC,QAAD,EAAA,UAAA,CAAO,eAAe,cAAc,mBACjC,eAAe,YAAY,oBAAC,KAAD;OAAG,MAAM,cAAc;iBAAW;MAAmB,CAAA,IAAI,kBACjF,EAAA,CAAA,CACD;SACN,OAAO,SAAS,oBAAC,KAAD;MAAG,WAAW,yBAAO;MAAO,IAAI,UAAU;MAAU,MAAK;gBAAS,OAAO;KAAS,CAAA,CAChG;;IAEN,CAAC,UAAU,sBAAsB,oBAAC,KAAD;KAAG,WAAW,yBAAO;KAAQ,MAAM;eAAoB;IAAmB,CAAA;IAC3G,eAAe,oBAAC,KAAD;KAAG,WAAW,yBAAO;KAAO,MAAK;eAAS;IAAe,CAAA;IACxE,EAAE,SAAS,WAAW,aACrB,oBAAC,KAAD;KAAG,WAAW,yBAAO;KAAO,MAAK;eAC9B,SAAS,8BAA8B;IACvC,CAAA;IAEL,oBAAC,QAAD;KAAQ,MAAK;KAAS,SAAQ;KAAU,MAAK;KAAK,UAAU,YAAY,YAAY,SAAS,CAAC,WAAW,CAAC;eACvG,UAAW,SAAS,wBAAwB,kBAAoB,SAAS,mBAAmB;IACvF,CAAA;GACA;IACF;;AAEd"}
|
|
1
|
+
{"version":3,"file":"index68.js","names":[],"sources":["../src/components/auth-page/AuthPage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { AuthCard } from \"../auth-card/AuthCard\";\nimport { AuthField, AuthForm, AuthModeSwitch, type AuthMode } from \"../auth-form/AuthForm\";\nimport { Input } from \"../input/Input\";\nimport { Button } from \"../button/Button\";\nimport styles from \"./auth-page.module.css\";\n\nexport interface AuthCredentials {\n email: string;\n password: string;\n identifier?: string;\n fields?: Record<string, string>;\n}\n\nexport interface AuthAdditionalField {\n name: string;\n label: string;\n type?: \"text\" | \"email\";\n placeholder?: string;\n autoComplete?: string;\n required?: boolean;\n minLength?: number;\n maxLength?: number;\n}\n\nexport interface AuthIdentifierOptions {\n label?: string;\n type?: \"text\" | \"email\";\n placeholder?: string;\n autoComplete?: string;\n maxLength?: number;\n}\n\nexport interface AuthPageProps {\n /** Brand/logo above the form. */\n brand?: React.ReactNode;\n /** Title for each mode. */\n signInTitle?: string;\n signUpTitle?: string;\n signInSubtitle?: string;\n signUpSubtitle?: string;\n signInIdentifier?: AuthIdentifierOptions;\n signUpFields?: AuthAdditionalField[];\n /** Optional confirmation field; defaults to true. */\n requirePasswordConfirmation?: boolean;\n /** An app-supplied session verification error. */\n initialError?: string;\n footer?: React.ReactNode;\n minSignInPasswordLength?: number;\n passwordMaxLength?: number;\n /** Initial tab; changes to this prop after mount do not reset the selected tab. */\n defaultMode?: AuthMode;\n /** Optional controlled tab, e.g. when sign-in and sign-up use separate routes. */\n mode?: AuthMode;\n onModeChange?: (mode: AuthMode) => void;\n /** App-specific auth callbacks; throwing an Error displays an inline failure. */\n onSignIn?: (credentials: AuthCredentials) => Promise<unknown> | unknown;\n onSignUp?: (credentials: AuthCredentials) => Promise<unknown> | unknown;\n onError?: (error: unknown, mode: AuthMode) => void;\n /** Prefill email without ever populating a password. */\n initialEmail?: string;\n /** Prevent submission until the app's authentication provider is ready. */\n disabled?: boolean;\n /** Minimum password length for account creation; default 8. */\n minPasswordLength?: number;\n /** Optional terms requirement for sign-up only. */\n signUpOptions?: {\n requireTerms?: boolean;\n termsHref?: string;\n termsLabel?: string;\n };\n /** Optional app-owned password recovery route. */\n forgotPasswordHref?: string;\n className?: string;\n layout?: \"fullscreen\" | \"embedded\";\n}\n\n/**\n * Complete app-neutral authentication UX. Uzi owns UI state and validation;\n * the consuming application owns credentials, sessions, API calls and redirects.\n */\nexport function AuthPage({\n brand,\n signInTitle = \"Welcome back\",\n signUpTitle = \"Create your account\",\n signInSubtitle,\n signUpSubtitle,\n signInIdentifier,\n signUpFields = [],\n requirePasswordConfirmation = true,\n initialError,\n footer,\n minSignInPasswordLength = 0,\n passwordMaxLength,\n defaultMode = \"signin\",\n mode: controlledMode,\n onModeChange,\n onSignIn,\n onSignUp,\n onError,\n initialEmail = \"\",\n disabled = false,\n minPasswordLength = 8,\n signUpOptions,\n forgotPasswordHref,\n className,\n layout = \"fullscreen\",\n}: AuthPageProps) {\n const [internalMode, setInternalMode] = React.useState<AuthMode>(defaultMode);\n const mode = controlledMode ?? internalMode;\n const [email, setEmail] = React.useState(initialEmail);\n const [password, setPassword] = React.useState(\"\");\n const [confirmPasswordValue, setConfirmPassword] = React.useState(\"\");\n const [extraValues, setExtraValues] = React.useState<Record<string, string>>({});\n const [acceptedTerms, setAcceptedTerms] = React.useState(false);\n const [showPassword, setShowPassword] = React.useState(false);\n const [pending, setPending] = React.useState(false);\n const pendingRef = React.useRef(false);\n const [errors, setErrors] = React.useState<Record<string, string>>({});\n const [serverError, setServerError] = React.useState(initialError ?? \"\");\n const id = React.useId();\n const emailId = id + \"-email\";\n const passwordId = id + \"-password\";\n const confirmId = id + \"-confirm\";\n const termsId = id + \"-terms\";\n const signup = mode === \"signup\";\n const identifierIsEmail = signup || (signInIdentifier?.type ?? \"email\") === \"email\";\n const termsRequired = signup && !!signUpOptions?.requireTerms;\n const canSwitch = !!onModeChange || (!!onSignIn && !!onSignUp);\n\n React.useEffect(() => { setServerError(initialError ?? \"\"); }, [initialError]);\n\n React.useEffect(() => {\n // Changes from an authenticated account may prefill the email after hydration.\n if (initialEmail) setEmail((previous) => previous || initialEmail);\n }, [initialEmail]);\n\n const switchMode = (next: AuthMode) => {\n if (pendingRef.current || next === mode) return;\n setInternalMode(next);\n setPassword(\"\");\n setConfirmPassword(\"\");\n setShowPassword(false);\n setErrors({});\n setServerError(\"\");\n onModeChange?.(next);\n };\n\n const submit = async (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n if (pendingRef.current || disabled) return;\n const nextErrors: Record<string, string> = {};\n const normalizedEmail = email.trim();\n if (!normalizedEmail) nextErrors.email = signup || identifierIsEmail ? \"Email is required\" : \"Identifier is required\";\n else if (identifierIsEmail && !/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(normalizedEmail)) nextErrors.email = \"Enter a valid email address\";\n if (!signup && signInIdentifier?.maxLength && normalizedEmail.length > signInIdentifier.maxLength) nextErrors.email = \"Identifier is too long\";\n if (!password) nextErrors.password = \"Password is required\";\n else if (signup && password.length < minPasswordLength) nextErrors.password = `Use at least ${minPasswordLength} characters`;\n if (signup && requirePasswordConfirmation && password !== confirmPasswordValue) nextErrors.confirm = \"Passwords do not match\";\n if (!signup && minSignInPasswordLength && password.length < minSignInPasswordLength) nextErrors.password = `Use at least ${minSignInPasswordLength} characters`;\n if (passwordMaxLength && password.length > passwordMaxLength) nextErrors.password = \"Password is too long\";\n if (signup) {\n for (const field of signUpFields) {\n const value = (extraValues[field.name] ?? \"\").trim();\n if (field.required && !value) nextErrors[field.name] = field.label + \" is required\";\n else if (value && field.minLength && value.length < field.minLength) nextErrors[field.name] = field.label + \" is too short\";\n else if (field.maxLength && value.length > field.maxLength) nextErrors[field.name] = field.label + \" is too long\";\n else if (field.type === \"email\" && value && !/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(value)) nextErrors[field.name] = \"Enter a valid email address\";\n }\n }\n if (termsRequired && !acceptedTerms) nextErrors.terms = \"Accept the terms to continue\";\n setErrors(nextErrors);\n setServerError(\"\");\n if (Object.keys(nextErrors).length) return;\n\n pendingRef.current = true;\n setPending(true);\n try {\n const credentials: AuthCredentials = { email: normalizedEmail, password };\n if (!signup && signInIdentifier) credentials.identifier = normalizedEmail;\n if (signup && signUpFields.length) {\n credentials.fields = Object.fromEntries(signUpFields.map((field) => [field.name, (extraValues[field.name] ?? \"\").trim()]));\n }\n if (signup) {\n if (!onSignUp) return;\n await onSignUp(credentials);\n } else {\n if (!onSignIn) return;\n await onSignIn(credentials);\n }\n setPassword(\"\");\n setConfirmPassword(\"\");\n setExtraValues({});\n } catch (error) {\n setServerError(error instanceof Error && error.message ? error.message : \"Unable to complete the request. Try again.\");\n onError?.(error, mode);\n } finally {\n pendingRef.current = false;\n setPending(false);\n }\n };\n\n return (\n <AuthCard\n className={className}\n layout={layout}\n brand={brand}\n title={signup ? signUpTitle : signInTitle}\n subtitle={signup ? signUpSubtitle : signInSubtitle}\n footer={footer}\n >\n {canSwitch && <AuthModeSwitch mode={mode} onModeChange={switchMode} />}\n <AuthForm onSubmit={submit} noValidate aria-busy={pending}>\n <AuthField htmlFor={emailId} label={signup ? \"Email\" : signInIdentifier?.label ?? \"Email\"} error={errors.email}>\n <Input\n id={emailId} type={signup ? \"email\" : signInIdentifier?.type ?? \"email\"} placeholder={signup ? \"you@example.com\" : signInIdentifier?.placeholder ?? \"you@example.com\"} value={email}\n autoComplete={signup ? \"email\" : signInIdentifier?.autoComplete ?? \"email\"} maxLength={signup ? 254 : signInIdentifier?.maxLength} required disabled={disabled || pending}\n aria-invalid={!!errors.email} aria-describedby={errors.email ? emailId + \"-error\" : undefined}\n onChange={(event) => { setEmail(event.target.value); setErrors((old) => ({ ...old, email: \"\" })); }}\n />\n </AuthField>\n <AuthField htmlFor={passwordId} label=\"Password\" error={errors.password}>\n <div className={styles.passwordRow}>\n <Input\n id={passwordId} type={showPassword ? \"text\" : \"password\"}\n placeholder={signup ? \"At least \" + minPasswordLength + \" characters\" : \"Enter your password\"}\n value={password} required maxLength={passwordMaxLength} disabled={disabled || pending}\n autoComplete={signup ? \"new-password\" : \"current-password\"}\n aria-invalid={!!errors.password} aria-describedby={errors.password ? passwordId + \"-error\" : undefined}\n onChange={(event) => { setPassword(event.target.value); setErrors((old) => ({ ...old, password: \"\" })); }}\n />\n <button type=\"button\" className={styles.visibility} disabled={disabled || pending}\n aria-label={showPassword ? \"Hide password\" : \"Show password\"}\n aria-controls={passwordId} aria-pressed={showPassword}\n onClick={() => setShowPassword((old) => !old)}>\n {showPassword ? \"Hide\" : \"Show\"}\n </button>\n </div>\n </AuthField>\n {signup && requirePasswordConfirmation && (\n <AuthField htmlFor={confirmId} label=\"Confirm password\" error={errors.confirm}>\n <Input id={confirmId} type=\"password\" placeholder=\"Re-enter password\" value={confirmPasswordValue}\n autoComplete=\"new-password\" required disabled={disabled || pending}\n aria-invalid={!!errors.confirm} aria-describedby={errors.confirm ? confirmId + \"-error\" : undefined}\n onChange={(event) => { setConfirmPassword(event.target.value); setErrors((old) => ({ ...old, confirm: \"\" })); }} />\n </AuthField>\n )}\n {signup && signUpFields.map((field) => {\n const fieldId = id + \"-\" + field.name;\n return (\n <AuthField key={field.name} htmlFor={fieldId} label={field.label} error={errors[field.name]}>\n <Input id={fieldId} type={field.type ?? \"text\"} value={extraValues[field.name] ?? \"\"}\n placeholder={field.placeholder} autoComplete={field.autoComplete} required={field.required}\n minLength={field.minLength} maxLength={field.maxLength} disabled={disabled || pending}\n aria-invalid={!!errors[field.name]} aria-describedby={errors[field.name] ? fieldId + \"-error\" : undefined}\n onChange={(event) => { setExtraValues((old) => ({ ...old, [field.name]: event.target.value })); setErrors((old) => ({ ...old, [field.name]: \"\" })); }} />\n </AuthField>\n );\n })}\n {termsRequired && (\n <div className={styles.terms}>\n <label htmlFor={termsId} className={styles.termsLabel}>\n <input id={termsId} type=\"checkbox\" checked={acceptedTerms} disabled={disabled || pending}\n aria-invalid={!!errors.terms} aria-describedby={errors.terms ? termsId + \"-error\" : undefined}\n onChange={(event) => { setAcceptedTerms(event.target.checked); setErrors((old) => ({ ...old, terms: \"\" })); }} />\n <span>{signUpOptions?.termsLabel ?? \"I agree to the \"}\n {signUpOptions?.termsHref ? <a href={signUpOptions.termsHref}>Terms of Service</a> : \"Terms of Service\"}\n </span>\n </label>\n {errors.terms && <p className={styles.error} id={termsId + \"-error\"} role=\"alert\">{errors.terms}</p>}\n </div>\n )}\n {!signup && forgotPasswordHref && <a className={styles.forgot} href={forgotPasswordHref}>Forgot password?</a>}\n {serverError && <p className={styles.error} role=\"alert\">{serverError}</p>}\n {!(signup ? onSignUp : onSignIn) && (\n <p className={styles.error} role=\"status\">\n {signup ? \"Sign-up is not available.\" : \"Sign-in is not available.\"}\n </p>\n )}\n <Button type=\"submit\" variant=\"primary\" size=\"lg\" disabled={disabled || pending || (signup ? !onSignUp : !onSignIn)}>\n {pending ? (signup ? \"Creating account...\" : \"Signing in...\") : (signup ? \"Create account\" : \"Sign in\")}\n </Button>\n </AuthForm>\n </AuthCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAiFA,SAAgB,SAAS,EACvB,OACA,cAAc,gBACd,cAAc,uBACd,gBACA,gBACA,kBACA,eAAe,CAAC,GAChB,8BAA8B,MAC9B,cACA,QACA,0BAA0B,GAC1B,mBACA,cAAc,UACd,MAAM,gBACN,cACA,UACA,UACA,SACA,eAAe,IACf,WAAW,OACX,oBAAoB,GACpB,eACA,oBACA,WACA,SAAS,gBACO;CAChB,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAmB,WAAW;CAC5E,MAAM,OAAO,kBAAkB;CAC/B,MAAM,CAAC,OAAO,YAAY,MAAM,SAAS,YAAY;CACrD,MAAM,CAAC,UAAU,eAAe,MAAM,SAAS,EAAE;CACjD,MAAM,CAAC,sBAAsB,sBAAsB,MAAM,SAAS,EAAE;CACpE,MAAM,CAAC,aAAa,kBAAkB,MAAM,SAAiC,CAAC,CAAC;CAC/E,MAAM,CAAC,eAAe,oBAAoB,MAAM,SAAS,KAAK;CAC9D,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAS,KAAK;CAC5D,MAAM,CAAC,SAAS,cAAc,MAAM,SAAS,KAAK;CAClD,MAAM,aAAa,MAAM,OAAO,KAAK;CACrC,MAAM,CAAC,QAAQ,aAAa,MAAM,SAAiC,CAAC,CAAC;CACrE,MAAM,CAAC,aAAa,kBAAkB,MAAM,SAAS,gBAAgB,EAAE;CACvE,MAAM,KAAK,MA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ime");
|
|
|
12
12
|
* Complete app-neutral authentication UX. Uzi owns UI state and validation;
|
|
13
13
|
* the consuming application owns credentials, sessions, API calls and redirects.
|
|
14
14
|
*/
|
|
15
|
-
function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create your account", signInSubtitle, signUpSubtitle, defaultMode = "signin", mode: controlledMode, onModeChange, onSignIn, onSignUp, onError, initialEmail = "", disabled = false, minPasswordLength = 8, signUpOptions, forgotPasswordHref, className, layout = "fullscreen" }) {
|
|
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
16
|
const [internalMode, setInternalMode] = react.useState(defaultMode);
|
|
17
17
|
const mode = controlledMode ?? internalMode;
|
|
18
18
|
const [email, setEmail] = react.useState(initialEmail);
|
|
19
19
|
const [password, setPassword] = react.useState("");
|
|
20
|
-
const [
|
|
20
|
+
const [confirmPasswordValue, setConfirmPassword] = react.useState("");
|
|
21
|
+
const [extraValues, setExtraValues] = react.useState({});
|
|
21
22
|
const [acceptedTerms, setAcceptedTerms] = react.useState(false);
|
|
22
23
|
const [showPassword, setShowPassword] = react.useState(false);
|
|
23
24
|
const [pending, setPending] = react.useState(false);
|
|
24
25
|
const pendingRef = react.useRef(false);
|
|
25
26
|
const [errors, setErrors] = react.useState({});
|
|
26
|
-
const [serverError, setServerError] = react.useState("");
|
|
27
|
+
const [serverError, setServerError] = react.useState(initialError ?? "");
|
|
27
28
|
const id = react.useId();
|
|
28
29
|
const emailId = id + "-email";
|
|
29
30
|
const passwordId = id + "-password";
|
|
30
31
|
const confirmId = id + "-confirm";
|
|
31
32
|
const termsId = id + "-terms";
|
|
32
33
|
const signup = mode === "signup";
|
|
34
|
+
const identifierIsEmail = signup || (signInIdentifier?.type ?? "email") === "email";
|
|
33
35
|
const termsRequired = signup && !!signUpOptions?.requireTerms;
|
|
34
36
|
const canSwitch = !!onModeChange || !!onSignIn && !!onSignUp;
|
|
37
|
+
react.useEffect(() => {
|
|
38
|
+
setServerError(initialError ?? "");
|
|
39
|
+
}, [initialError]);
|
|
35
40
|
react.useEffect(() => {
|
|
36
41
|
if (initialEmail) setEmail((previous) => previous || initialEmail);
|
|
37
42
|
}, [initialEmail]);
|
|
@@ -50,11 +55,21 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
50
55
|
if (pendingRef.current || disabled) return;
|
|
51
56
|
const nextErrors = {};
|
|
52
57
|
const normalizedEmail = email.trim();
|
|
53
|
-
if (!normalizedEmail) nextErrors.email = "Email is required";
|
|
54
|
-
else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(normalizedEmail)) nextErrors.email = "Enter a valid email address";
|
|
58
|
+
if (!normalizedEmail) nextErrors.email = signup || identifierIsEmail ? "Email is required" : "Identifier is required";
|
|
59
|
+
else if (identifierIsEmail && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(normalizedEmail)) nextErrors.email = "Enter a valid email address";
|
|
60
|
+
if (!signup && signInIdentifier?.maxLength && normalizedEmail.length > signInIdentifier.maxLength) nextErrors.email = "Identifier is too long";
|
|
55
61
|
if (!password) nextErrors.password = "Password is required";
|
|
56
62
|
else if (signup && password.length < minPasswordLength) nextErrors.password = `Use at least ${minPasswordLength} characters`;
|
|
57
|
-
if (signup && password !==
|
|
63
|
+
if (signup && requirePasswordConfirmation && password !== confirmPasswordValue) nextErrors.confirm = "Passwords do not match";
|
|
64
|
+
if (!signup && minSignInPasswordLength && password.length < minSignInPasswordLength) nextErrors.password = `Use at least ${minSignInPasswordLength} characters`;
|
|
65
|
+
if (passwordMaxLength && password.length > passwordMaxLength) nextErrors.password = "Password is too long";
|
|
66
|
+
if (signup) for (const field of signUpFields) {
|
|
67
|
+
const value = (extraValues[field.name] ?? "").trim();
|
|
68
|
+
if (field.required && !value) nextErrors[field.name] = field.label + " is required";
|
|
69
|
+
else if (value && field.minLength && value.length < field.minLength) nextErrors[field.name] = field.label + " is too short";
|
|
70
|
+
else if (field.maxLength && value.length > field.maxLength) nextErrors[field.name] = field.label + " is too long";
|
|
71
|
+
else if (field.type === "email" && value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) nextErrors[field.name] = "Enter a valid email address";
|
|
72
|
+
}
|
|
58
73
|
if (termsRequired && !acceptedTerms) nextErrors.terms = "Accept the terms to continue";
|
|
59
74
|
setErrors(nextErrors);
|
|
60
75
|
setServerError("");
|
|
@@ -66,6 +81,8 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
66
81
|
email: normalizedEmail,
|
|
67
82
|
password
|
|
68
83
|
};
|
|
84
|
+
if (!signup && signInIdentifier) credentials.identifier = normalizedEmail;
|
|
85
|
+
if (signup && signUpFields.length) credentials.fields = Object.fromEntries(signUpFields.map((field) => [field.name, (extraValues[field.name] ?? "").trim()]));
|
|
69
86
|
if (signup) {
|
|
70
87
|
if (!onSignUp) return;
|
|
71
88
|
await onSignUp(credentials);
|
|
@@ -75,6 +92,7 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
75
92
|
}
|
|
76
93
|
setPassword("");
|
|
77
94
|
setConfirmPassword("");
|
|
95
|
+
setExtraValues({});
|
|
78
96
|
} catch (error) {
|
|
79
97
|
setServerError(error instanceof Error && error.message ? error.message : "Unable to complete the request. Try again.");
|
|
80
98
|
onError?.(error, mode);
|
|
@@ -89,6 +107,7 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
89
107
|
brand,
|
|
90
108
|
title: signup ? signUpTitle : signInTitle,
|
|
91
109
|
subtitle: signup ? signUpSubtitle : signInSubtitle,
|
|
110
|
+
footer,
|
|
92
111
|
children: [canSwitch && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthForm.AuthModeSwitch, {
|
|
93
112
|
mode,
|
|
94
113
|
onModeChange: switchMode
|
|
@@ -99,14 +118,15 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
99
118
|
children: [
|
|
100
119
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthForm.AuthField, {
|
|
101
120
|
htmlFor: emailId,
|
|
102
|
-
label: "Email",
|
|
121
|
+
label: signup ? "Email" : signInIdentifier?.label ?? "Email",
|
|
103
122
|
error: errors.email,
|
|
104
123
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Input.Input, {
|
|
105
124
|
id: emailId,
|
|
106
|
-
type: "email",
|
|
107
|
-
placeholder: "you@example.com",
|
|
125
|
+
type: signup ? "email" : signInIdentifier?.type ?? "email",
|
|
126
|
+
placeholder: signup ? "you@example.com" : signInIdentifier?.placeholder ?? "you@example.com",
|
|
108
127
|
value: email,
|
|
109
|
-
autoComplete: "email",
|
|
128
|
+
autoComplete: signup ? "email" : signInIdentifier?.autoComplete ?? "email",
|
|
129
|
+
maxLength: signup ? 254 : signInIdentifier?.maxLength,
|
|
110
130
|
required: true,
|
|
111
131
|
disabled: disabled || pending,
|
|
112
132
|
"aria-invalid": !!errors.email,
|
|
@@ -132,6 +152,7 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
132
152
|
placeholder: signup ? "At least " + minPasswordLength + " characters" : "Enter your password",
|
|
133
153
|
value: password,
|
|
134
154
|
required: true,
|
|
155
|
+
maxLength: passwordMaxLength,
|
|
135
156
|
disabled: disabled || pending,
|
|
136
157
|
autoComplete: signup ? "new-password" : "current-password",
|
|
137
158
|
"aria-invalid": !!errors.password,
|
|
@@ -155,7 +176,7 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
155
176
|
})]
|
|
156
177
|
})
|
|
157
178
|
}),
|
|
158
|
-
signup && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthForm.AuthField, {
|
|
179
|
+
signup && requirePasswordConfirmation && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthForm.AuthField, {
|
|
159
180
|
htmlFor: confirmId,
|
|
160
181
|
label: "Confirm password",
|
|
161
182
|
error: errors.confirm,
|
|
@@ -163,7 +184,7 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
163
184
|
id: confirmId,
|
|
164
185
|
type: "password",
|
|
165
186
|
placeholder: "Re-enter password",
|
|
166
|
-
value:
|
|
187
|
+
value: confirmPasswordValue,
|
|
167
188
|
autoComplete: "new-password",
|
|
168
189
|
required: true,
|
|
169
190
|
disabled: disabled || pending,
|
|
@@ -178,6 +199,37 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
178
199
|
}
|
|
179
200
|
})
|
|
180
201
|
}),
|
|
202
|
+
signup && signUpFields.map((field) => {
|
|
203
|
+
const fieldId = id + "-" + field.name;
|
|
204
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AuthForm.AuthField, {
|
|
205
|
+
htmlFor: fieldId,
|
|
206
|
+
label: field.label,
|
|
207
|
+
error: errors[field.name],
|
|
208
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Input.Input, {
|
|
209
|
+
id: fieldId,
|
|
210
|
+
type: field.type ?? "text",
|
|
211
|
+
value: extraValues[field.name] ?? "",
|
|
212
|
+
placeholder: field.placeholder,
|
|
213
|
+
autoComplete: field.autoComplete,
|
|
214
|
+
required: field.required,
|
|
215
|
+
minLength: field.minLength,
|
|
216
|
+
maxLength: field.maxLength,
|
|
217
|
+
disabled: disabled || pending,
|
|
218
|
+
"aria-invalid": !!errors[field.name],
|
|
219
|
+
"aria-describedby": errors[field.name] ? fieldId + "-error" : void 0,
|
|
220
|
+
onChange: (event) => {
|
|
221
|
+
setExtraValues((old) => ({
|
|
222
|
+
...old,
|
|
223
|
+
[field.name]: event.target.value
|
|
224
|
+
}));
|
|
225
|
+
setErrors((old) => ({
|
|
226
|
+
...old,
|
|
227
|
+
[field.name]: ""
|
|
228
|
+
}));
|
|
229
|
+
}
|
|
230
|
+
})
|
|
231
|
+
}, field.name);
|
|
232
|
+
}),
|
|
181
233
|
termsRequired && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
182
234
|
className: require_auth_page_module.default.terms,
|
|
183
235
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
package/dist/index69.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index69.cjs","names":[],"sources":["../src/components/auth-page/AuthPage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { AuthCard } from \"../auth-card/AuthCard\";\nimport { AuthField, AuthForm, AuthModeSwitch, type AuthMode } from \"../auth-form/AuthForm\";\nimport { Input } from \"../input/Input\";\nimport { Button } from \"../button/Button\";\nimport styles from \"./auth-page.module.css\";\n\nexport interface AuthCredentials {\n email: string;\n password: string;\n}\n\nexport interface AuthPageProps {\n /** Brand/logo above the form. */\n brand?: React.ReactNode;\n /** Title for each mode. */\n signInTitle?: string;\n signUpTitle?: string;\n signInSubtitle?: string;\n signUpSubtitle?: string;\n /** Initial tab; changes to this prop after mount do not reset the selected tab. */\n defaultMode?: AuthMode;\n /** Optional controlled tab, e.g. when sign-in and sign-up use separate routes. */\n mode?: AuthMode;\n onModeChange?: (mode: AuthMode) => void;\n /** App-specific auth callbacks; throwing an Error displays an inline failure. */\n onSignIn?: (credentials: AuthCredentials) => Promise<unknown> | unknown;\n onSignUp?: (credentials: AuthCredentials) => Promise<unknown> | unknown;\n onError?: (error: unknown, mode: AuthMode) => void;\n /** Prefill email without ever populating a password. */\n initialEmail?: string;\n /** Prevent submission until the app's authentication provider is ready. */\n disabled?: boolean;\n /** Minimum password length for account creation; default 8. */\n minPasswordLength?: number;\n /** Optional terms requirement for sign-up only. */\n signUpOptions?: {\n requireTerms?: boolean;\n termsHref?: string;\n termsLabel?: string;\n };\n /** Optional app-owned password recovery route. */\n forgotPasswordHref?: string;\n className?: string;\n layout?: \"fullscreen\" | \"embedded\";\n}\n\n/**\n * Complete app-neutral authentication UX. Uzi owns UI state and validation;\n * the consuming application owns credentials, sessions, API calls and redirects.\n */\nexport function AuthPage({\n brand,\n signInTitle = \"Welcome back\",\n signUpTitle = \"Create your account\",\n signInSubtitle,\n signUpSubtitle,\n defaultMode = \"signin\",\n mode: controlledMode,\n onModeChange,\n onSignIn,\n onSignUp,\n onError,\n initialEmail = \"\",\n disabled = false,\n minPasswordLength = 8,\n signUpOptions,\n forgotPasswordHref,\n className,\n layout = \"fullscreen\",\n}: AuthPageProps) {\n const [internalMode, setInternalMode] = React.useState<AuthMode>(defaultMode);\n const mode = controlledMode ?? internalMode;\n const [email, setEmail] = React.useState(initialEmail);\n const [password, setPassword] = React.useState(\"\");\n const [confirmPassword, setConfirmPassword] = React.useState(\"\");\n const [acceptedTerms, setAcceptedTerms] = React.useState(false);\n const [showPassword, setShowPassword] = React.useState(false);\n const [pending, setPending] = React.useState(false);\n const pendingRef = React.useRef(false);\n const [errors, setErrors] = React.useState<Record<string, string>>({});\n const [serverError, setServerError] = React.useState(\"\");\n const id = React.useId();\n const emailId = id + \"-email\";\n const passwordId = id + \"-password\";\n const confirmId = id + \"-confirm\";\n const termsId = id + \"-terms\";\n const signup = mode === \"signup\";\n const termsRequired = signup && !!signUpOptions?.requireTerms;\n const canSwitch = !!onModeChange || (!!onSignIn && !!onSignUp);\n\n React.useEffect(() => {\n // Changes from an authenticated account may prefill the email after hydration.\n if (initialEmail) setEmail((previous) => previous || initialEmail);\n }, [initialEmail]);\n\n const switchMode = (next: AuthMode) => {\n if (pendingRef.current || next === mode) return;\n setInternalMode(next);\n setPassword(\"\");\n setConfirmPassword(\"\");\n setShowPassword(false);\n setErrors({});\n setServerError(\"\");\n onModeChange?.(next);\n };\n\n const submit = async (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n if (pendingRef.current || disabled) return;\n const nextErrors: Record<string, string> = {};\n const normalizedEmail = email.trim();\n if (!normalizedEmail) nextErrors.email = \"Email is required\";\n else if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(normalizedEmail)) nextErrors.email = \"Enter a valid email address\";\n if (!password) nextErrors.password = \"Password is required\";\n else if (signup && password.length < minPasswordLength) nextErrors.password = `Use at least ${minPasswordLength} characters`;\n if (signup && password !== confirmPassword) nextErrors.confirm = \"Passwords do not match\";\n if (termsRequired && !acceptedTerms) nextErrors.terms = \"Accept the terms to continue\";\n setErrors(nextErrors);\n setServerError(\"\");\n if (Object.keys(nextErrors).length) return;\n\n pendingRef.current = true;\n setPending(true);\n try {\n const credentials = { email: normalizedEmail, password };\n if (signup) {\n if (!onSignUp) return;\n await onSignUp(credentials);\n } else {\n if (!onSignIn) return;\n await onSignIn(credentials);\n }\n setPassword(\"\");\n setConfirmPassword(\"\");\n } catch (error) {\n setServerError(error instanceof Error && error.message ? error.message : \"Unable to complete the request. Try again.\");\n onError?.(error, mode);\n } finally {\n pendingRef.current = false;\n setPending(false);\n }\n };\n\n return (\n <AuthCard\n className={className}\n layout={layout}\n brand={brand}\n title={signup ? signUpTitle : signInTitle}\n subtitle={signup ? signUpSubtitle : signInSubtitle}\n >\n {canSwitch && <AuthModeSwitch mode={mode} onModeChange={switchMode} />}\n <AuthForm onSubmit={submit} noValidate aria-busy={pending}>\n <AuthField htmlFor={emailId} label=\"Email\" error={errors.email}>\n <Input\n id={emailId} type=\"email\" placeholder=\"you@example.com\" value={email}\n autoComplete=\"email\" required disabled={disabled || pending}\n aria-invalid={!!errors.email} aria-describedby={errors.email ? emailId + \"-error\" : undefined}\n onChange={(event) => { setEmail(event.target.value); setErrors((old) => ({ ...old, email: \"\" })); }}\n />\n </AuthField>\n <AuthField htmlFor={passwordId} label=\"Password\" error={errors.password}>\n <div className={styles.passwordRow}>\n <Input\n id={passwordId} type={showPassword ? \"text\" : \"password\"}\n placeholder={signup ? \"At least \" + minPasswordLength + \" characters\" : \"Enter your password\"}\n value={password} required disabled={disabled || pending}\n autoComplete={signup ? \"new-password\" : \"current-password\"}\n aria-invalid={!!errors.password} aria-describedby={errors.password ? passwordId + \"-error\" : undefined}\n onChange={(event) => { setPassword(event.target.value); setErrors((old) => ({ ...old, password: \"\" })); }}\n />\n <button type=\"button\" className={styles.visibility} disabled={disabled || pending}\n aria-label={showPassword ? \"Hide password\" : \"Show password\"}\n aria-controls={passwordId} aria-pressed={showPassword}\n onClick={() => setShowPassword((old) => !old)}>\n {showPassword ? \"Hide\" : \"Show\"}\n </button>\n </div>\n </AuthField>\n {signup && (\n <AuthField htmlFor={confirmId} label=\"Confirm password\" error={errors.confirm}>\n <Input id={confirmId} type=\"password\" placeholder=\"Re-enter password\" value={confirmPassword}\n autoComplete=\"new-password\" required disabled={disabled || pending}\n aria-invalid={!!errors.confirm} aria-describedby={errors.confirm ? confirmId + \"-error\" : undefined}\n onChange={(event) => { setConfirmPassword(event.target.value); setErrors((old) => ({ ...old, confirm: \"\" })); }} />\n </AuthField>\n )}\n {termsRequired && (\n <div className={styles.terms}>\n <label htmlFor={termsId} className={styles.termsLabel}>\n <input id={termsId} type=\"checkbox\" checked={acceptedTerms} disabled={disabled || pending}\n aria-invalid={!!errors.terms} aria-describedby={errors.terms ? termsId + \"-error\" : undefined}\n onChange={(event) => { setAcceptedTerms(event.target.checked); setErrors((old) => ({ ...old, terms: \"\" })); }} />\n <span>{signUpOptions?.termsLabel ?? \"I agree to the \"}\n {signUpOptions?.termsHref ? <a href={signUpOptions.termsHref}>Terms of Service</a> : \"Terms of Service\"}\n </span>\n </label>\n {errors.terms && <p className={styles.error} id={termsId + \"-error\"} role=\"alert\">{errors.terms}</p>}\n </div>\n )}\n {!signup && forgotPasswordHref && <a className={styles.forgot} href={forgotPasswordHref}>Forgot password?</a>}\n {serverError && <p className={styles.error} role=\"alert\">{serverError}</p>}\n {!(signup ? onSignUp : onSignIn) && (\n <p className={styles.error} role=\"status\">\n {signup ? \"Sign-up is not available.\" : \"Sign-in is not available.\"}\n </p>\n )}\n <Button type=\"submit\" variant=\"primary\" size=\"lg\" disabled={disabled || pending || (signup ? !onSignUp : !onSignIn)}>\n {pending ? (signup ? \"Creating account...\" : \"Signing in...\") : (signup ? \"Create account\" : \"Sign in\")}\n </Button>\n </AuthForm>\n </AuthCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAmDA,SAAgB,SAAS,EACvB,OACA,cAAc,gBACd,cAAc,uBACd,gBACA,gBACA,cAAc,UACd,MAAM,gBACN,cACA,UACA,UACA,SACA,eAAe,IACf,WAAW,OACX,oBAAoB,GACpB,eACA,oBACA,WACA,SAAS,gBACO;CAChB,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAmB,WAAW;CAC5E,MAAM,OAAO,kBAAkB;CAC/B,MAAM,CAAC,OAAO,YAAY,MAAM,SAAS,YAAY;CACrD,MAAM,CAAC,UAAU,eAAe,MAAM,SAAS,EAAE;CACjD,MAAM,CAAC,iBAAiB,sBAAsB,MAAM,SAAS,EAAE;CAC/D,MAAM,CAAC,eAAe,oBAAoB,MAAM,SAAS,KAAK;CAC9D,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAS,KAAK;CAC5D,MAAM,CAAC,SAAS,cAAc,MAAM,SAAS,KAAK;CAClD,MAAM,aAAa,MAAM,OAAO,KAAK;CACrC,MAAM,CAAC,QAAQ,aAAa,MAAM,SAAiC,CAAC,CAAC;CACrE,MAAM,CAAC,aAAa,kBAAkB,MAAM,SAAS,EAAE;CACvD,MAAM,KAAK,MAAM,MAAM;CACvB,MAAM,UAAU,KAAK;CACrB,MAAM,aAAa,KAAK;CACxB,MAAM,YAAY,KAAK;CACvB,MAAM,UAAU,KAAK;CACrB,MAAM,SAAS,SAAS;CACxB,MAAM,gBAAgB,UAAU,CAAC,CAAC,eAAe;CACjD,MAAM,Y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,OAAO,OAAO;QAAG,WAAW,SAAS;SAAE,GAAG;SAAK,OAAO;QAAG,EAAE;OAAG;MAAI,CAAA,GAClH,iBAAA,GAAA,kBAAA,KAAA,CAAC,QAAD,EAAA,UAAA,CAAO,eAAe,cAAc,mBACjC,eAAe,YAAY,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;OAAG,MAAM,cAAc;iBAAW;MAAmB,CAAA,IAAI,kBACjF,EAAA,CAAA,CACD;SACN,OAAO,SAAS,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;MAAG,WAAW,yBAAA,QAAO;MAAO,IAAI,UAAU;MAAU,MAAK;gBAAS,OAAO;KAAS,CAAA,CAChG;;IAEN,CAAC,UAAU,sBAAsB,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;KAAG,WAAW,yBAAA,QAAO;KAAQ,MAAM;eAAoB;IAAmB,CAAA;IAC3G,eAAe,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;KAAG,WAAW,yBAAA,QAAO;KAAO,MAAK;eAAS;IAAe,CAAA;IACxE,EAAE,SAAS,WAAW,aACrB,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;KAAG,WAAW,yBAAA,QAAO;KAAO,MAAK;eAC9B,SAAS,8BAA8B;IACvC,CAAA;IAEL,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAA,QAAD;KAAQ,MAAK;KAAS,SAAQ;KAAU,MAAK;KAAK,UAAU,YAAY,YAAY,SAAS,CAAC,WAAW,CAAC;eACvG,UAAW,SAAS,wBAAwB,kBAAoB,SAAS,mBAAmB;IACvF,CAAA;GACA;IACF;;AAEd"}
|
|
1
|
+
{"version":3,"file":"index69.cjs","names":[],"sources":["../src/components/auth-page/AuthPage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { AuthCard } from \"../auth-card/AuthCard\";\nimport { AuthField, AuthForm, AuthModeSwitch, type AuthMode } from \"../auth-form/AuthForm\";\nimport { Input } from \"../input/Input\";\nimport { Button } from \"../button/Button\";\nimport styles from \"./auth-page.module.css\";\n\nexport interface AuthCredentials {\n email: string;\n password: string;\n identifier?: string;\n fields?: Record<string, string>;\n}\n\nexport interface AuthAdditionalField {\n name: string;\n label: string;\n type?: \"text\" | \"email\";\n placeholder?: string;\n autoComplete?: string;\n required?: boolean;\n minLength?: number;\n maxLength?: number;\n}\n\nexport interface AuthIdentifierOptions {\n label?: string;\n type?: \"text\" | \"email\";\n placeholder?: string;\n autoComplete?: string;\n maxLength?: number;\n}\n\nexport interface AuthPageProps {\n /** Brand/logo above the form. */\n brand?: React.ReactNode;\n /** Title for each mode. */\n signInTitle?: string;\n signUpTitle?: string;\n signInSubtitle?: string;\n signUpSubtitle?: string;\n signInIdentifier?: AuthIdentifierOptions;\n signUpFields?: AuthAdditionalField[];\n /** Optional confirmation field; defaults to true. */\n requirePasswordConfirmation?: boolean;\n /** An app-supplied session verification error. */\n initialError?: string;\n footer?: React.ReactNode;\n minSignInPasswordLength?: number;\n passwordMaxLength?: number;\n /** Initial tab; changes to this prop after mount do not reset the selected tab. */\n defaultMode?: AuthMode;\n /** Optional controlled tab, e.g. when sign-in and sign-up use separate routes. */\n mode?: AuthMode;\n onModeChange?: (mode: AuthMode) => void;\n /** App-specific auth callbacks; throwing an Error displays an inline failure. */\n onSignIn?: (credentials: AuthCredentials) => Promise<unknown> | unknown;\n onSignUp?: (credentials: AuthCredentials) => Promise<unknown> | unknown;\n onError?: (error: unknown, mode: AuthMode) => void;\n /** Prefill email without ever populating a password. */\n initialEmail?: string;\n /** Prevent submission until the app's authentication provider is ready. */\n disabled?: boolean;\n /** Minimum password length for account creation; default 8. */\n minPasswordLength?: number;\n /** Optional terms requirement for sign-up only. */\n signUpOptions?: {\n requireTerms?: boolean;\n termsHref?: string;\n termsLabel?: string;\n };\n /** Optional app-owned password recovery route. */\n forgotPasswordHref?: string;\n className?: string;\n layout?: \"fullscreen\" | \"embedded\";\n}\n\n/**\n * Complete app-neutral authentication UX. Uzi owns UI state and validation;\n * the consuming application owns credentials, sessions, API calls and redirects.\n */\nexport function AuthPage({\n brand,\n signInTitle = \"Welcome back\",\n signUpTitle = \"Create your account\",\n signInSubtitle,\n signUpSubtitle,\n signInIdentifier,\n signUpFields = [],\n requirePasswordConfirmation = true,\n initialError,\n footer,\n minSignInPasswordLength = 0,\n passwordMaxLength,\n defaultMode = \"signin\",\n mode: controlledMode,\n onModeChange,\n onSignIn,\n onSignUp,\n onError,\n initialEmail = \"\",\n disabled = false,\n minPasswordLength = 8,\n signUpOptions,\n forgotPasswordHref,\n className,\n layout = \"fullscreen\",\n}: AuthPageProps) {\n const [internalMode, setInternalMode] = React.useState<AuthMode>(defaultMode);\n const mode = controlledMode ?? internalMode;\n const [email, setEmail] = React.useState(initialEmail);\n const [password, setPassword] = React.useState(\"\");\n const [confirmPasswordValue, setConfirmPassword] = React.useState(\"\");\n const [extraValues, setExtraValues] = React.useState<Record<string, string>>({});\n const [acceptedTerms, setAcceptedTerms] = React.useState(false);\n const [showPassword, setShowPassword] = React.useState(false);\n const [pending, setPending] = React.useState(false);\n const pendingRef = React.useRef(false);\n const [errors, setErrors] = React.useState<Record<string, string>>({});\n const [serverError, setServerError] = React.useState(initialError ?? \"\");\n const id = React.useId();\n const emailId = id + \"-email\";\n const passwordId = id + \"-password\";\n const confirmId = id + \"-confirm\";\n const termsId = id + \"-terms\";\n const signup = mode === \"signup\";\n const identifierIsEmail = signup || (signInIdentifier?.type ?? \"email\") === \"email\";\n const termsRequired = signup && !!signUpOptions?.requireTerms;\n const canSwitch = !!onModeChange || (!!onSignIn && !!onSignUp);\n\n React.useEffect(() => { setServerError(initialError ?? \"\"); }, [initialError]);\n\n React.useEffect(() => {\n // Changes from an authenticated account may prefill the email after hydration.\n if (initialEmail) setEmail((previous) => previous || initialEmail);\n }, [initialEmail]);\n\n const switchMode = (next: AuthMode) => {\n if (pendingRef.current || next === mode) return;\n setInternalMode(next);\n setPassword(\"\");\n setConfirmPassword(\"\");\n setShowPassword(false);\n setErrors({});\n setServerError(\"\");\n onModeChange?.(next);\n };\n\n const submit = async (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n if (pendingRef.current || disabled) return;\n const nextErrors: Record<string, string> = {};\n const normalizedEmail = email.trim();\n if (!normalizedEmail) nextErrors.email = signup || identifierIsEmail ? \"Email is required\" : \"Identifier is required\";\n else if (identifierIsEmail && !/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(normalizedEmail)) nextErrors.email = \"Enter a valid email address\";\n if (!signup && signInIdentifier?.maxLength && normalizedEmail.length > signInIdentifier.maxLength) nextErrors.email = \"Identifier is too long\";\n if (!password) nextErrors.password = \"Password is required\";\n else if (signup && password.length < minPasswordLength) nextErrors.password = `Use at least ${minPasswordLength} characters`;\n if (signup && requirePasswordConfirmation && password !== confirmPasswordValue) nextErrors.confirm = \"Passwords do not match\";\n if (!signup && minSignInPasswordLength && password.length < minSignInPasswordLength) nextErrors.password = `Use at least ${minSignInPasswordLength} characters`;\n if (passwordMaxLength && password.length > passwordMaxLength) nextErrors.password = \"Password is too long\";\n if (signup) {\n for (const field of signUpFields) {\n const value = (extraValues[field.name] ?? \"\").trim();\n if (field.required && !value) nextErrors[field.name] = field.label + \" is required\";\n else if (value && field.minLength && value.length < field.minLength) nextErrors[field.name] = field.label + \" is too short\";\n else if (field.maxLength && value.length > field.maxLength) nextErrors[field.name] = field.label + \" is too long\";\n else if (field.type === \"email\" && value && !/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(value)) nextErrors[field.name] = \"Enter a valid email address\";\n }\n }\n if (termsRequired && !acceptedTerms) nextErrors.terms = \"Accept the terms to continue\";\n setErrors(nextErrors);\n setServerError(\"\");\n if (Object.keys(nextErrors).length) return;\n\n pendingRef.current = true;\n setPending(true);\n try {\n const credentials: AuthCredentials = { email: normalizedEmail, password };\n if (!signup && signInIdentifier) credentials.identifier = normalizedEmail;\n if (signup && signUpFields.length) {\n credentials.fields = Object.fromEntries(signUpFields.map((field) => [field.name, (extraValues[field.name] ?? \"\").trim()]));\n }\n if (signup) {\n if (!onSignUp) return;\n await onSignUp(credentials);\n } else {\n if (!onSignIn) return;\n await onSignIn(credentials);\n }\n setPassword(\"\");\n setConfirmPassword(\"\");\n setExtraValues({});\n } catch (error) {\n setServerError(error instanceof Error && error.message ? error.message : \"Unable to complete the request. Try again.\");\n onError?.(error, mode);\n } finally {\n pendingRef.current = false;\n setPending(false);\n }\n };\n\n return (\n <AuthCard\n className={className}\n layout={layout}\n brand={brand}\n title={signup ? signUpTitle : signInTitle}\n subtitle={signup ? signUpSubtitle : signInSubtitle}\n footer={footer}\n >\n {canSwitch && <AuthModeSwitch mode={mode} onModeChange={switchMode} />}\n <AuthForm onSubmit={submit} noValidate aria-busy={pending}>\n <AuthField htmlFor={emailId} label={signup ? \"Email\" : signInIdentifier?.label ?? \"Email\"} error={errors.email}>\n <Input\n id={emailId} type={signup ? \"email\" : signInIdentifier?.type ?? \"email\"} placeholder={signup ? \"you@example.com\" : signInIdentifier?.placeholder ?? \"you@example.com\"} value={email}\n autoComplete={signup ? \"email\" : signInIdentifier?.autoComplete ?? \"email\"} maxLength={signup ? 254 : signInIdentifier?.maxLength} required disabled={disabled || pending}\n aria-invalid={!!errors.email} aria-describedby={errors.email ? emailId + \"-error\" : undefined}\n onChange={(event) => { setEmail(event.target.value); setErrors((old) => ({ ...old, email: \"\" })); }}\n />\n </AuthField>\n <AuthField htmlFor={passwordId} label=\"Password\" error={errors.password}>\n <div className={styles.passwordRow}>\n <Input\n id={passwordId} type={showPassword ? \"text\" : \"password\"}\n placeholder={signup ? \"At least \" + minPasswordLength + \" characters\" : \"Enter your password\"}\n value={password} required maxLength={passwordMaxLength} disabled={disabled || pending}\n autoComplete={signup ? \"new-password\" : \"current-password\"}\n aria-invalid={!!errors.password} aria-describedby={errors.password ? passwordId + \"-error\" : undefined}\n onChange={(event) => { setPassword(event.target.value); setErrors((old) => ({ ...old, password: \"\" })); }}\n />\n <button type=\"button\" className={styles.visibility} disabled={disabled || pending}\n aria-label={showPassword ? \"Hide password\" : \"Show password\"}\n aria-controls={passwordId} aria-pressed={showPassword}\n onClick={() => setShowPassword((old) => !old)}>\n {showPassword ? \"Hide\" : \"Show\"}\n </button>\n </div>\n </AuthField>\n {signup && requirePasswordConfirmation && (\n <AuthField htmlFor={confirmId} label=\"Confirm password\" error={errors.confirm}>\n <Input id={confirmId} type=\"password\" placeholder=\"Re-enter password\" value={confirmPasswordValue}\n autoComplete=\"new-password\" required disabled={disabled || pending}\n aria-invalid={!!errors.confirm} aria-describedby={errors.confirm ? confirmId + \"-error\" : undefined}\n onChange={(event) => { setConfirmPassword(event.target.value); setErrors((old) => ({ ...old, confirm: \"\" })); }} />\n </AuthField>\n )}\n {signup && signUpFields.map((field) => {\n const fieldId = id + \"-\" + field.name;\n return (\n <AuthField key={field.name} htmlFor={fieldId} label={field.label} error={errors[field.name]}>\n <Input id={fieldId} type={field.type ?? \"text\"} value={extraValues[field.name] ?? \"\"}\n placeholder={field.placeholder} autoComplete={field.autoComplete} required={field.required}\n minLength={field.minLength} maxLength={field.maxLength} disabled={disabled || pending}\n aria-invalid={!!errors[field.name]} aria-describedby={errors[field.name] ? fieldId + \"-error\" : undefined}\n onChange={(event) => { setExtraValues((old) => ({ ...old, [field.name]: event.target.value })); setErrors((old) => ({ ...old, [field.name]: \"\" })); }} />\n </AuthField>\n );\n })}\n {termsRequired && (\n <div className={styles.terms}>\n <label htmlFor={termsId} className={styles.termsLabel}>\n <input id={termsId} type=\"checkbox\" checked={acceptedTerms} disabled={disabled || pending}\n aria-invalid={!!errors.terms} aria-describedby={errors.terms ? termsId + \"-error\" : undefined}\n onChange={(event) => { setAcceptedTerms(event.target.checked); setErrors((old) => ({ ...old, terms: \"\" })); }} />\n <span>{signUpOptions?.termsLabel ?? \"I agree to the \"}\n {signUpOptions?.termsHref ? <a href={signUpOptions.termsHref}>Terms of Service</a> : \"Terms of Service\"}\n </span>\n </label>\n {errors.terms && <p className={styles.error} id={termsId + \"-error\"} role=\"alert\">{errors.terms}</p>}\n </div>\n )}\n {!signup && forgotPasswordHref && <a className={styles.forgot} href={forgotPasswordHref}>Forgot password?</a>}\n {serverError && <p className={styles.error} role=\"alert\">{serverError}</p>}\n {!(signup ? onSignUp : onSignIn) && (\n <p className={styles.error} role=\"status\">\n {signup ? \"Sign-up is not available.\" : \"Sign-in is not available.\"}\n </p>\n )}\n <Button type=\"submit\" variant=\"primary\" size=\"lg\" disabled={disabled || pending || (signup ? !onSignUp : !onSignIn)}>\n {pending ? (signup ? \"Creating account...\" : \"Signing in...\") : (signup ? \"Create account\" : \"Sign in\")}\n </Button>\n </AuthForm>\n </AuthCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAiFA,SAAgB,SAAS,EACvB,OACA,cAAc,gBACd,cAAc,uBACd,gBACA,gBACA,kBACA,eAAe,CAAC,GAChB,8BAA8B,MAC9B,cACA,QACA,0BAA0B,GAC1B,mBACA,cAAc,UACd,MAAM,gBACN,cACA,UACA,UACA,SACA,eAAe,IACf,WAAW,OACX,oBAAoB,GACpB,eACA,oBACA,WACA,SAAS,gBACO;CAChB,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAmB,WAAW;CAC5E,MAAM,OAAO,kBAAkB;CAC/B,MAAM,CAAC,OAAO,YAAY,MAAM,SAAS,YAAY;CACrD,MAAM,CAAC,UAAU,eAAe,MAAM,SAAS,EAAE;CACjD,MAAM,CAAC,sBAAsB,sBAAsB,MAAM,SAAS,EAAE;CACpE,MAAM,CAAC,aAAa,kBAAkB,MAAM,SAAiC,CAAC,CAAC;CAC/E,MAAM,CAAC,eAAe,oBAAoB,MAAM,SAAS,KAAK;CAC9D,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAS,KAAK;CAC5D,MAAM,CAAC,SAAS,cAAc,MAAM,SAAS,KAAK;CAClD,MAAM,aAAa,MAAM,OAAO,KAAK;CACrC,MAAM,CAAC,QAAQ,aAAa,MAAM,SAAiC,CAAC,CAAC;CACrE,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