@tomny-dev/uzi 0.14.0 → 0.15.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.
- package/dist/components/filter-workspace/FilterWorkspace.d.ts +40 -0
- package/dist/components/filter-workspace/FilterWorkspace.d.ts.map +1 -0
- package/dist/components/filter-workspace/FilterWorkspace.test.d.ts +2 -0
- package/dist/components/filter-workspace/FilterWorkspace.test.d.ts.map +1 -0
- package/dist/index.cjs +18 -14
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -15
- package/dist/index57.js +21 -10
- package/dist/index57.js.map +1 -1
- package/dist/index58.cjs +30 -11
- package/dist/index58.cjs.map +1 -1
- package/dist/index58.js +101 -14
- package/dist/index58.js.map +1 -1
- package/dist/index59.cjs +104 -13
- package/dist/index59.cjs.map +1 -1
- package/dist/index59.js +10 -11
- package/dist/index59.js.map +1 -1
- package/dist/index60.cjs +11 -13
- package/dist/index60.cjs.map +1 -1
- package/dist/index60.js +13 -16
- package/dist/index60.js.map +1 -1
- package/dist/index61.cjs +13 -16
- package/dist/index61.cjs.map +1 -1
- package/dist/index61.js +10 -8
- package/dist/index61.js.map +1 -1
- package/dist/index62.cjs +11 -10
- package/dist/index62.cjs.map +1 -1
- package/dist/index62.js +15 -87
- package/dist/index62.js.map +1 -1
- package/dist/index63.cjs +15 -89
- package/dist/index63.cjs.map +1 -1
- package/dist/index63.js +9 -23
- package/dist/index63.js.map +1 -1
- package/dist/index64.cjs +12 -33
- package/dist/index64.cjs.map +1 -1
- package/dist/index64.js +89 -43
- package/dist/index64.js.map +1 -1
- package/dist/index65.cjs +88 -42
- package/dist/index65.cjs.map +1 -1
- package/dist/index65.js +23 -15
- package/dist/index65.js.map +1 -1
- package/dist/index66.cjs +33 -21
- package/dist/index66.cjs.map +1 -1
- package/dist/index66.js +44 -51
- package/dist/index66.js.map +1 -1
- package/dist/index67.cjs +43 -52
- package/dist/index67.cjs.map +1 -1
- package/dist/index67.js +14 -14
- package/dist/index67.js.map +1 -1
- package/dist/index68.cjs +19 -19
- package/dist/index68.cjs.map +1 -1
- package/dist/index68.js +49 -290
- package/dist/index68.js.map +1 -1
- package/dist/index69.cjs +51 -290
- package/dist/index69.cjs.map +1 -1
- package/dist/index69.js +15 -57
- package/dist/index69.js.map +1 -1
- package/dist/index70.cjs +20 -83
- package/dist/index70.cjs.map +1 -1
- package/dist/index70.js +276 -418
- package/dist/index70.js.map +1 -1
- package/dist/index71.cjs +275 -419
- package/dist/index71.cjs.map +1 -1
- package/dist/index71.js +56 -58
- package/dist/index71.js.map +1 -1
- package/dist/index72.cjs +82 -85
- package/dist/index72.cjs.map +1 -1
- package/dist/index72.js +420 -226
- package/dist/index72.js.map +1 -1
- package/dist/index73.cjs +421 -225
- package/dist/index73.cjs.map +1 -1
- package/dist/index73.js +58 -42
- package/dist/index73.js.map +1 -1
- package/dist/index74.cjs +85 -61
- package/dist/index74.cjs.map +1 -1
- package/dist/index74.js +236 -76
- package/dist/index74.js.map +1 -1
- package/dist/index75.cjs +235 -75
- package/dist/index75.cjs.map +1 -1
- package/dist/index75.js +42 -20
- package/dist/index75.js.map +1 -1
- package/dist/index76.cjs +60 -27
- package/dist/index76.cjs.map +1 -1
- package/dist/index76.js +73 -88
- package/dist/index76.js.map +1 -1
- package/dist/index77.cjs +73 -90
- package/dist/index77.cjs.map +1 -1
- package/dist/index77.js +17 -15
- package/dist/index77.js.map +1 -1
- package/dist/index78.cjs +22 -19
- package/dist/index78.cjs.map +1 -1
- package/dist/index78.js +85 -143
- package/dist/index78.js.map +1 -1
- package/dist/index79.cjs +87 -143
- package/dist/index79.cjs.map +1 -1
- package/dist/index79.js +19 -91
- package/dist/index79.js.map +1 -1
- package/dist/index80.cjs +27 -135
- package/dist/index80.cjs.map +1 -1
- package/dist/index80.js +140 -673
- package/dist/index80.js.map +1 -1
- package/dist/index81.cjs +140 -673
- package/dist/index81.cjs.map +1 -1
- package/dist/index81.js +91 -31
- package/dist/index81.js.map +1 -1
- package/dist/index82.cjs +135 -45
- package/dist/index82.cjs.map +1 -1
- package/dist/index82.js +667 -206
- package/dist/index82.js.map +1 -1
- package/dist/index83.cjs +667 -204
- package/dist/index83.cjs.map +1 -1
- package/dist/index83.js +31 -15
- package/dist/index83.js.map +1 -1
- package/dist/index84.cjs +45 -21
- package/dist/index84.cjs.map +1 -1
- package/dist/index84.js +224 -29
- package/dist/index84.js.map +1 -1
- package/dist/index85.cjs +224 -30
- package/dist/index85.cjs.map +1 -1
- package/dist/index85.js +19 -0
- package/dist/index85.js.map +1 -0
- package/dist/index86.cjs +25 -0
- package/dist/index86.cjs.map +1 -0
- package/dist/index86.js +36 -0
- package/dist/index86.js.map +1 -0
- package/dist/index87.cjs +37 -0
- package/dist/index87.cjs.map +1 -0
- package/dist/style.css +53 -0
- package/package.json +1 -1
package/dist/index71.cjs
CHANGED
|
@@ -1,444 +1,300 @@
|
|
|
1
1
|
const require_runtime = require("./index2.cjs");
|
|
2
|
-
const
|
|
3
|
-
const
|
|
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");
|
|
4
7
|
let react = require("react");
|
|
5
8
|
react = require_runtime.__toESM(react, 1);
|
|
6
9
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
-
//#region src/components/auth-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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("");
|
|
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);
|
|
120
19
|
const [password, setPassword] = react.useState("");
|
|
121
|
-
const [
|
|
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);
|
|
122
26
|
const [errors, setErrors] = react.useState({});
|
|
123
|
-
const [
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
rememberMe
|
|
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)));
|
|
140
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);
|
|
60
|
+
};
|
|
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
|
+
}
|
|
141
111
|
};
|
|
142
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
143
|
-
className
|
|
144
|
-
|
|
145
|
-
|
|
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,
|
|
146
126
|
children: [
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
+
})
|
|
160
150
|
}),
|
|
161
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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,
|
|
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",
|
|
184
161
|
value: password,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
setRememberMe(c);
|
|
198
|
-
if (submitted) setSubmitted(false);
|
|
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
|
+
}));
|
|
199
174
|
}
|
|
200
|
-
}),
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
disabled:
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
|
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
|
+
})
|
|
254
186
|
}),
|
|
255
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
+
})
|
|
264
209
|
}),
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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"
|
|
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
|
+
}));
|
|
237
|
+
}
|
|
342
238
|
})
|
|
343
|
-
|
|
239
|
+
}, field.name);
|
|
344
240
|
}),
|
|
345
|
-
|
|
346
|
-
className:
|
|
347
|
-
children:
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
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
|
|
379
|
-
}),
|
|
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
|
|
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
|
|
388
269
|
})]
|
|
389
270
|
}),
|
|
390
|
-
|
|
391
|
-
className:
|
|
392
|
-
|
|
393
|
-
|
|
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
|
-
})]
|
|
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?"
|
|
430
275
|
}),
|
|
431
|
-
|
|
432
|
-
className:
|
|
433
|
-
|
|
434
|
-
|
|
276
|
+
serverError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
277
|
+
className: require_auth_page_module.default.error,
|
|
278
|
+
role: "alert",
|
|
279
|
+
children: serverError
|
|
280
|
+
}),
|
|
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."
|
|
285
|
+
}),
|
|
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
|
+
})
|
|
435
293
|
]
|
|
436
|
-
})
|
|
294
|
+
})]
|
|
437
295
|
});
|
|
438
296
|
}
|
|
439
297
|
//#endregion
|
|
440
|
-
exports.
|
|
441
|
-
exports.SignInPage = SignInPage;
|
|
442
|
-
exports.SignUpPage = SignUpPage;
|
|
298
|
+
exports.AuthPage = AuthPage;
|
|
443
299
|
|
|
444
300
|
//# sourceMappingURL=index71.cjs.map
|