nucleus-core-ts 0.8.7 → 0.8.9
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/client.js +1 -1
- package/dist/fe/components/AbstractAnimatedBackground/index.js +437 -0
- package/dist/fe/components/AuthorizationPage/components/AuthorizationPage.js +841 -0
- package/dist/fe/components/AuthorizationPage/components/ClaimList.js +100 -0
- package/dist/fe/components/AuthorizationPage/components/RoleClaimEditor.js +232 -0
- package/dist/fe/components/AuthorizationPage/components/RoleList.js +115 -0
- package/dist/fe/components/AuthorizationPage/index.js +6 -0
- package/dist/fe/components/AuthorizationPage/store/index.js +117 -0
- package/dist/fe/components/AuthorizationPage/theme/index.js +137 -0
- package/dist/fe/components/AuthorizationPage/types/index.js +1 -0
- package/dist/fe/components/Button/components/Button.js +158 -0
- package/dist/fe/components/Button/components/ButtonSpinner.js +52 -0
- package/dist/fe/components/Button/index.js +3 -0
- package/dist/fe/components/Button/theme/index.js +186 -0
- package/dist/fe/components/Button/types/index.js +1 -0
- package/dist/fe/components/Button/utils/cn.js +5 -0
- package/dist/fe/components/Captcha/components/Captcha.js +311 -0
- package/dist/fe/components/Captcha/index.js +2 -0
- package/dist/fe/components/Captcha/theme.js +52 -0
- package/dist/fe/components/Captcha/types.js +1 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordForm.js +242 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordHeader.js +39 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordPage.js +60 -0
- package/dist/fe/components/ChangePasswordPage/index.js +5 -0
- package/dist/fe/components/ChangePasswordPage/store/index.js +44 -0
- package/dist/fe/components/ChangePasswordPage/theme/index.js +87 -0
- package/dist/fe/components/ChangePasswordPage/types/index.js +1 -0
- package/dist/fe/components/Checkbox/components/Checkbox.js +115 -0
- package/dist/fe/components/Checkbox/components/CheckboxIcon.js +119 -0
- package/dist/fe/components/Checkbox/components/SwitchTrack.js +178 -0
- package/dist/fe/components/Checkbox/index.js +4 -0
- package/dist/fe/components/Checkbox/theme/index.js +221 -0
- package/dist/fe/components/Checkbox/types/index.js +1 -0
- package/dist/fe/components/Checkbox/utils/cn.js +5 -0
- package/dist/fe/components/DataTable/DataTable.js +225 -0
- package/dist/fe/components/DataTable/components/ActionCell.js +26 -0
- package/dist/fe/components/DataTable/components/DataCell.js +76 -0
- package/dist/fe/components/DataTable/components/EditableCell.js +221 -0
- package/dist/fe/components/DataTable/components/EmptyState.js +29 -0
- package/dist/fe/components/DataTable/components/HeaderCell.js +64 -0
- package/dist/fe/components/DataTable/components/InfiniteScrollTrigger.js +66 -0
- package/dist/fe/components/DataTable/components/LoadingSpinner.js +19 -0
- package/dist/fe/components/DataTable/components/ResizeHandle.js +41 -0
- package/dist/fe/components/DataTable/components/SelectionCell.js +105 -0
- package/dist/fe/components/DataTable/components/SkeletonRow.js +56 -0
- package/dist/fe/components/DataTable/components/SkeletonTable.js +83 -0
- package/dist/fe/components/DataTable/components/SortIcon.js +39 -0
- package/dist/fe/components/DataTable/components/TableHeader.js +49 -0
- package/dist/fe/components/DataTable/components/TableRow.js +118 -0
- package/dist/fe/components/DataTable/components/index.js +14 -0
- package/dist/fe/components/DataTable/hooks/index.js +2 -0
- package/dist/fe/components/DataTable/hooks/useAutoFitColumn.js +23 -0
- package/dist/fe/components/DataTable/hooks/useResizeColumn.js +122 -0
- package/dist/fe/components/DataTable/index.js +3 -0
- package/dist/fe/components/DataTable/store/index.js +97 -0
- package/dist/fe/components/DataTable/theme/index.js +144 -0
- package/dist/fe/components/DataTable/types/index.js +1 -0
- package/dist/fe/components/DataTable/utils/cn.js +5 -0
- package/dist/fe/components/DatePicker/components/CalendarGrid.js +95 -0
- package/dist/fe/components/DatePicker/components/CalendarHeader.js +152 -0
- package/dist/fe/components/DatePicker/components/DatePicker.js +381 -0
- package/dist/fe/components/DatePicker/components/MonthYearSelector.js +93 -0
- package/dist/fe/components/DatePicker/index.js +7 -0
- package/dist/fe/components/DatePicker/locales/index.js +1113 -0
- package/dist/fe/components/DatePicker/theme/index.js +315 -0
- package/dist/fe/components/DatePicker/types/index.js +1 -0
- package/dist/fe/components/DatePicker/utils/cn.js +5 -0
- package/dist/fe/components/DatePicker/utils/date.js +132 -0
- package/dist/fe/components/DevicesPage/components/DeviceCard.js +251 -0
- package/dist/fe/components/DevicesPage/components/DevicesHeader.js +42 -0
- package/dist/fe/components/DevicesPage/components/DevicesPage.js +450 -0
- package/dist/fe/components/DevicesPage/index.js +5 -0
- package/dist/fe/components/DevicesPage/store/index.js +55 -0
- package/dist/fe/components/DevicesPage/theme/index.js +131 -0
- package/dist/fe/components/DevicesPage/types/index.js +1 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordForm.js +214 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordHeader.js +42 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordPage.js +59 -0
- package/dist/fe/components/ForgotPasswordPage/index.js +5 -0
- package/dist/fe/components/ForgotPasswordPage/store/index.js +28 -0
- package/dist/fe/components/ForgotPasswordPage/theme/index.js +87 -0
- package/dist/fe/components/ForgotPasswordPage/types/index.js +1 -0
- package/dist/fe/components/FormBuilder/components/FormBuilder.js +156 -0
- package/dist/fe/components/FormBuilder/components/FormField.js +218 -0
- package/dist/fe/components/FormBuilder/hooks/useFormBuilder.js +152 -0
- package/dist/fe/components/FormBuilder/index.js +4 -0
- package/dist/fe/components/FormBuilder/theme/index.js +134 -0
- package/dist/fe/components/FormBuilder/types/index.js +1 -0
- package/dist/fe/components/FormBuilder/utils/cn.js +5 -0
- package/dist/fe/components/FormBuilder/utils/fieldMapping.js +216 -0
- package/dist/fe/components/FormBuilder/utils/validation.js +78 -0
- package/dist/fe/components/LoginPage/components/LoginForm.js +214 -0
- package/dist/fe/components/LoginPage/components/LoginHeader.js +24 -0
- package/dist/fe/components/LoginPage/components/LoginPage.js +138 -0
- package/dist/fe/components/LoginPage/index.js +5 -0
- package/dist/fe/components/LoginPage/store/index.js +59 -0
- package/dist/fe/components/LoginPage/theme/index.js +98 -0
- package/dist/fe/components/LoginPage/types/index.js +1 -0
- package/dist/fe/components/MagicLinkVerifyPage/components/MagicLinkVerifyPage.js +200 -0
- package/dist/fe/components/MagicLinkVerifyPage/index.js +3 -0
- package/dist/fe/components/MagicLinkVerifyPage/store.js +20 -0
- package/dist/fe/components/MagicLinkVerifyPage/theme.js +36 -0
- package/dist/fe/components/MagicLinkVerifyPage/types.js +1 -0
- package/dist/fe/components/NucleusEntityShowcase.js +1409 -0
- package/dist/fe/components/NucleusTextInput/components/FloatingLabel.js +56 -0
- package/dist/fe/components/NucleusTextInput/components/InputIcons.js +258 -0
- package/dist/fe/components/NucleusTextInput/components/NucleusTextInput.js +321 -0
- package/dist/fe/components/NucleusTextInput/components/PasswordStrengthIndicator.js +104 -0
- package/dist/fe/components/NucleusTextInput/components/TypewriterText.js +56 -0
- package/dist/fe/components/NucleusTextInput/index.js +7 -0
- package/dist/fe/components/NucleusTextInput/theme/index.js +121 -0
- package/dist/fe/components/NucleusTextInput/types/index.js +1 -0
- package/dist/fe/components/NucleusTextInput/utils/cn.js +5 -0
- package/dist/fe/components/NucleusTextInput/utils/format.js +62 -0
- package/dist/fe/components/NucleusTextInput/utils/validation.js +191 -0
- package/dist/fe/components/ProfilePage/components/AddressCard.js +196 -0
- package/dist/fe/components/ProfilePage/components/PhoneCard.js +206 -0
- package/dist/fe/components/ProfilePage/components/ProfileHeader.js +150 -0
- package/dist/fe/components/ProfilePage/components/ProfilePage.js +1336 -0
- package/dist/fe/components/ProfilePage/index.js +6 -0
- package/dist/fe/components/ProfilePage/store/index.js +115 -0
- package/dist/fe/components/ProfilePage/theme/index.js +168 -0
- package/dist/fe/components/ProfilePage/types/index.js +1 -0
- package/dist/fe/components/RangePicker/components/RangePicker.js +338 -0
- package/dist/fe/components/RangePicker/components/RangeThumb.js +68 -0
- package/dist/fe/components/RangePicker/components/RangeTooltip.js +45 -0
- package/dist/fe/components/RangePicker/components/RangeTrack.js +32 -0
- package/dist/fe/components/RangePicker/index.js +5 -0
- package/dist/fe/components/RangePicker/theme/index.js +88 -0
- package/dist/fe/components/RangePicker/types/index.js +1 -0
- package/dist/fe/components/RangePicker/utils/cn.js +3 -0
- package/dist/fe/components/RegisterPage/components/PasswordStrengthIndicator.js +107 -0
- package/dist/fe/components/RegisterPage/components/RegisterForm.js +322 -0
- package/dist/fe/components/RegisterPage/components/RegisterHeader.js +23 -0
- package/dist/fe/components/RegisterPage/components/RegisterPage.js +85 -0
- package/dist/fe/components/RegisterPage/index.js +6 -0
- package/dist/fe/components/RegisterPage/store/index.js +106 -0
- package/dist/fe/components/RegisterPage/theme/index.js +128 -0
- package/dist/fe/components/RegisterPage/types/index.js +1 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordForm.js +347 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordHeader.js +42 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordPage.js +61 -0
- package/dist/fe/components/ResetPasswordPage/index.js +5 -0
- package/dist/fe/components/ResetPasswordPage/store/index.js +36 -0
- package/dist/fe/components/ResetPasswordPage/theme/index.js +99 -0
- package/dist/fe/components/ResetPasswordPage/types/index.js +1 -0
- package/dist/fe/components/SearchBox/components/SearchBox.js +271 -0
- package/dist/fe/components/SearchBox/components/SearchBoxDropdown.js +87 -0
- package/dist/fe/components/SearchBox/index.js +5 -0
- package/dist/fe/components/SearchBox/theme/index.js +184 -0
- package/dist/fe/components/SearchBox/types/index.js +1 -0
- package/dist/fe/components/SearchBox/utils/cn.js +5 -0
- package/dist/fe/components/SearchBox/utils/debounce.js +22 -0
- package/dist/fe/components/SearchBox/utils/sanitize.js +48 -0
- package/dist/fe/components/SelectBox/components/SelectBox.js +364 -0
- package/dist/fe/components/SelectBox/components/SelectDropdown.js +92 -0
- package/dist/fe/components/SelectBox/components/SelectOptionItem.js +43 -0
- package/dist/fe/components/SelectBox/components/SelectTrigger.js +22 -0
- package/dist/fe/components/SelectBox/index.js +5 -0
- package/dist/fe/components/SelectBox/theme/index.js +98 -0
- package/dist/fe/components/SelectBox/types/index.js +1 -0
- package/dist/fe/components/SelectBox/utils/cn.js +3 -0
- package/dist/fe/components/SetPasswordPage/components/PasswordStrengthIndicator.js +107 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordForm.js +142 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordHeader.js +23 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordPage.js +263 -0
- package/dist/fe/components/SetPasswordPage/index.js +7 -0
- package/dist/fe/components/SetPasswordPage/store/index.js +79 -0
- package/dist/fe/components/SetPasswordPage/theme/index.js +98 -0
- package/dist/fe/components/SetPasswordPage/types/index.js +12 -0
- package/dist/fe/components/UsersPage/components/InviteUserModal.js +262 -0
- package/dist/fe/components/UsersPage/components/Pagination.js +147 -0
- package/dist/fe/components/UsersPage/components/RoleAssignmentModal.js +186 -0
- package/dist/fe/components/UsersPage/components/StatsCards.js +124 -0
- package/dist/fe/components/UsersPage/components/UserDetailDrawer.js +444 -0
- package/dist/fe/components/UsersPage/components/UserFilters.js +142 -0
- package/dist/fe/components/UsersPage/components/UserListItem.js +125 -0
- package/dist/fe/components/UsersPage/components/UserListSkeleton.js +40 -0
- package/dist/fe/components/UsersPage/components/UsersPage.js +556 -0
- package/dist/fe/components/UsersPage/index.js +10 -0
- package/dist/fe/components/UsersPage/store/index.js +151 -0
- package/dist/fe/components/UsersPage/theme/index.js +231 -0
- package/dist/fe/components/UsersPage/types/index.js +1 -0
- package/dist/fe/components/VerifyEmailPage/components/VerifyEmailPage.js +290 -0
- package/dist/fe/components/VerifyEmailPage/index.js +3 -0
- package/dist/fe/components/VerifyEmailPage/store/index.js +45 -0
- package/dist/fe/components/VerifyEmailPage/theme/index.js +52 -0
- package/dist/fe/components/VerifyEmailPage/types/index.js +1 -0
- package/dist/fe/hooks/useNucleusEntity.js +247 -0
- package/dist/fe/index.js +28 -157
- package/dist/fe/types/index.js +1 -0
- package/dist/fe/utils/cn.js +5 -0
- package/dist/fe/utils/columnUtils.js +189 -0
- package/dist/fe/utils/endpointKeys.js +44 -0
- package/dist/index.js +1 -1
- package/dist/nucleus.config.d.ts +2 -0
- package/dist/src/Client/ApiCaller/client.js +1 -0
- package/dist/src/Client/ApiCaller/examples/usage.example.js +1 -0
- package/dist/src/Client/ApiCaller/generator.js +1 -0
- package/dist/src/Client/ApiCaller/index.js +1 -0
- package/dist/src/Client/ApiCaller/server.js +1 -0
- package/dist/src/Client/ApiCaller/system-tables.js +1 -0
- package/dist/src/Client/ApiCaller/types.js +1 -0
- package/dist/src/Client/Proxy/httpProxy.js +1 -0
- package/dist/src/Client/Proxy/index.js +1 -1
- package/dist/src/Client/Proxy/server.js +1 -0
- package/dist/src/Client/Proxy/types.js +1 -0
- package/dist/src/Client/Proxy/utils.js +1 -0
- package/dist/src/Client/Proxy/wsProxy.js +1 -0
- package/dist/src/Client/ServerFetch/index.js +1 -0
- package/dist/src/Client/ServerFetch/types.js +1 -0
- package/dist/src/Client/index.js +1 -0
- package/package.json +1 -1
- package/scripts/build.ts +41 -16
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../../../utils/cn";
|
|
4
|
+
import { setPasswordPageTheme } from "../theme";
|
|
5
|
+
const CheckIcon = ()=>/*#__PURE__*/ _jsx("svg", {
|
|
6
|
+
className: "w-3 h-3",
|
|
7
|
+
fill: "currentColor",
|
|
8
|
+
viewBox: "0 0 20 20",
|
|
9
|
+
"aria-hidden": "true",
|
|
10
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
11
|
+
fillRule: "evenodd",
|
|
12
|
+
d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",
|
|
13
|
+
clipRule: "evenodd"
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
const CrossIcon = ()=>/*#__PURE__*/ _jsx("svg", {
|
|
17
|
+
className: "w-3 h-3",
|
|
18
|
+
fill: "currentColor",
|
|
19
|
+
viewBox: "0 0 20 20",
|
|
20
|
+
"aria-hidden": "true",
|
|
21
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
22
|
+
fillRule: "evenodd",
|
|
23
|
+
d: "M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",
|
|
24
|
+
clipRule: "evenodd"
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
export function PasswordStrengthIndicator({ strength, showRequirements = true, passwordMinLength = 8, requireUppercase = true, requireLowercase = true, requireNumber = true, requireSpecialChar = false }) {
|
|
28
|
+
const theme = setPasswordPageTheme.passwordStrength;
|
|
29
|
+
const getStrengthColor = (index)=>{
|
|
30
|
+
if (index >= strength.score) return theme.bar.inactive;
|
|
31
|
+
if (strength.score === 1) return theme.bar.active.weak;
|
|
32
|
+
if (strength.score === 2) return theme.bar.active.fair;
|
|
33
|
+
if (strength.score === 3) return theme.bar.active.good;
|
|
34
|
+
if (strength.score === 4) return theme.bar.active.strong;
|
|
35
|
+
return theme.bar.active.veryStrong;
|
|
36
|
+
};
|
|
37
|
+
const requirements = [
|
|
38
|
+
{
|
|
39
|
+
key: "minLength",
|
|
40
|
+
label: `At least ${passwordMinLength} characters`,
|
|
41
|
+
met: strength.hasMinLength,
|
|
42
|
+
show: true
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
key: "uppercase",
|
|
46
|
+
label: "One uppercase letter",
|
|
47
|
+
met: strength.hasUppercase,
|
|
48
|
+
show: requireUppercase
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
key: "lowercase",
|
|
52
|
+
label: "One lowercase letter",
|
|
53
|
+
met: strength.hasLowercase,
|
|
54
|
+
show: requireLowercase
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
key: "number",
|
|
58
|
+
label: "One number",
|
|
59
|
+
met: strength.hasNumber,
|
|
60
|
+
show: requireNumber
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
key: "special",
|
|
64
|
+
label: "One special character",
|
|
65
|
+
met: strength.hasSpecialChar,
|
|
66
|
+
show: requireSpecialChar
|
|
67
|
+
}
|
|
68
|
+
].filter((req)=>req.show);
|
|
69
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
70
|
+
className: theme.container,
|
|
71
|
+
children: [
|
|
72
|
+
/*#__PURE__*/ _jsx("div", {
|
|
73
|
+
className: theme.bar.wrapper,
|
|
74
|
+
role: "progressbar",
|
|
75
|
+
"aria-valuenow": strength.score,
|
|
76
|
+
"aria-valuemin": 0,
|
|
77
|
+
"aria-valuemax": 5,
|
|
78
|
+
"aria-label": "Password strength",
|
|
79
|
+
children: [
|
|
80
|
+
0,
|
|
81
|
+
1,
|
|
82
|
+
2,
|
|
83
|
+
3,
|
|
84
|
+
4
|
|
85
|
+
].map((index)=>/*#__PURE__*/ _jsx("div", {
|
|
86
|
+
className: cn(theme.bar.segment, getStrengthColor(index))
|
|
87
|
+
}, index))
|
|
88
|
+
}),
|
|
89
|
+
showRequirements && /*#__PURE__*/ _jsx("ul", {
|
|
90
|
+
className: theme.requirements.container,
|
|
91
|
+
"aria-label": "Password requirements",
|
|
92
|
+
children: requirements.map((req)=>/*#__PURE__*/ _jsxs("li", {
|
|
93
|
+
className: cn(theme.requirements.item, req.met ? theme.requirements.met : theme.requirements.unmet),
|
|
94
|
+
children: [
|
|
95
|
+
/*#__PURE__*/ _jsx("span", {
|
|
96
|
+
className: req.met ? theme.requirements.icon.met : theme.requirements.icon.unmet,
|
|
97
|
+
children: req.met ? /*#__PURE__*/ _jsx(CheckIcon, {}) : /*#__PURE__*/ _jsx(CrossIcon, {})
|
|
98
|
+
}),
|
|
99
|
+
/*#__PURE__*/ _jsx("span", {
|
|
100
|
+
children: req.label
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
}, req.key))
|
|
104
|
+
})
|
|
105
|
+
]
|
|
106
|
+
});
|
|
107
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { NucleusTextInput } from "../../NucleusTextInput";
|
|
4
|
+
import { useSetPasswordStore } from "../store";
|
|
5
|
+
import { setPasswordPageTheme } from "../theme";
|
|
6
|
+
import { DEFAULT_PASSWORD_POLICY } from "../types";
|
|
7
|
+
export function SetPasswordForm({ passwordChangeAction, passwordSetAction, isInvite = false, onSuccess, onBackToLogin, backToLoginHref, passwordPolicy = {} }) {
|
|
8
|
+
const theme = setPasswordPageTheme;
|
|
9
|
+
const store = useSetPasswordStore();
|
|
10
|
+
const policy = {
|
|
11
|
+
...DEFAULT_PASSWORD_POLICY,
|
|
12
|
+
...passwordPolicy
|
|
13
|
+
};
|
|
14
|
+
const activeAction = isInvite && passwordSetAction ? passwordSetAction : passwordChangeAction;
|
|
15
|
+
const validateForm = ()=>{
|
|
16
|
+
if (!store.newPassword) {
|
|
17
|
+
return "Password is required";
|
|
18
|
+
}
|
|
19
|
+
if (store.newPassword.length < policy.minLength) {
|
|
20
|
+
return `Password must be at least ${policy.minLength} characters`;
|
|
21
|
+
}
|
|
22
|
+
if (policy.maxLength && store.newPassword.length > policy.maxLength) {
|
|
23
|
+
return `Password must be at most ${policy.maxLength} characters`;
|
|
24
|
+
}
|
|
25
|
+
if (policy.requireUppercase && !/[A-Z]/.test(store.newPassword)) {
|
|
26
|
+
return "Password must contain at least one uppercase letter";
|
|
27
|
+
}
|
|
28
|
+
if (policy.requireLowercase && !/[a-z]/.test(store.newPassword)) {
|
|
29
|
+
return "Password must contain at least one lowercase letter";
|
|
30
|
+
}
|
|
31
|
+
if (policy.requireNumber && !/[0-9]/.test(store.newPassword)) {
|
|
32
|
+
return "Password must contain at least one number";
|
|
33
|
+
}
|
|
34
|
+
if (policy.requireSpecialChar) {
|
|
35
|
+
const specialCharsRegex = new RegExp(`[${policy.specialChars.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")}]`);
|
|
36
|
+
if (!specialCharsRegex.test(store.newPassword)) {
|
|
37
|
+
return "Password must contain at least one special character";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (!store.confirmPassword) {
|
|
41
|
+
return "Please confirm your password";
|
|
42
|
+
}
|
|
43
|
+
if (store.newPassword !== store.confirmPassword) {
|
|
44
|
+
return "Passwords do not match";
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
};
|
|
48
|
+
const handleSubmit = (e)=>{
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
const validationError = validateForm();
|
|
51
|
+
if (validationError) {
|
|
52
|
+
store.setError(validationError);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
store.setError(null);
|
|
56
|
+
if (!activeAction) {
|
|
57
|
+
store.setError("No action configured");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const onAfterHandle = ()=>{
|
|
61
|
+
store.setStep("success");
|
|
62
|
+
if (onSuccess) {
|
|
63
|
+
setTimeout(onSuccess, 2000);
|
|
64
|
+
} else if (onBackToLogin) {
|
|
65
|
+
setTimeout(onBackToLogin, 2000);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const onErrorHandle = (error)=>{
|
|
69
|
+
store.setError(error?.message || "Failed to set password");
|
|
70
|
+
};
|
|
71
|
+
if (isInvite && passwordSetAction && store.userId) {
|
|
72
|
+
passwordSetAction.start({
|
|
73
|
+
payload: {
|
|
74
|
+
newPassword: store.newPassword,
|
|
75
|
+
userId: store.userId
|
|
76
|
+
},
|
|
77
|
+
onAfterHandle,
|
|
78
|
+
onErrorHandle
|
|
79
|
+
});
|
|
80
|
+
} else if (passwordChangeAction) {
|
|
81
|
+
passwordChangeAction.start({
|
|
82
|
+
payload: {
|
|
83
|
+
currentPassword: "",
|
|
84
|
+
newPassword: store.newPassword
|
|
85
|
+
},
|
|
86
|
+
onAfterHandle,
|
|
87
|
+
onErrorHandle
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
return /*#__PURE__*/ _jsxs("form", {
|
|
92
|
+
onSubmit: handleSubmit,
|
|
93
|
+
className: theme.form.wrapper,
|
|
94
|
+
children: [
|
|
95
|
+
store.error && /*#__PURE__*/ _jsx("div", {
|
|
96
|
+
className: theme.alert.error,
|
|
97
|
+
role: "alert",
|
|
98
|
+
children: store.error
|
|
99
|
+
}),
|
|
100
|
+
/*#__PURE__*/ _jsx(NucleusTextInput, {
|
|
101
|
+
type: "password",
|
|
102
|
+
label: "New Password",
|
|
103
|
+
value: store.newPassword,
|
|
104
|
+
onChange: (val)=>store.setNewPassword(val, policy.minLength),
|
|
105
|
+
placeholder: "Enter your new password",
|
|
106
|
+
isNewPassword: true,
|
|
107
|
+
showPasswordStrength: policy.showStrengthIndicator,
|
|
108
|
+
maxInputLength: policy.maxLength,
|
|
109
|
+
enableValidation: false
|
|
110
|
+
}),
|
|
111
|
+
/*#__PURE__*/ _jsx(NucleusTextInput, {
|
|
112
|
+
type: "password",
|
|
113
|
+
label: "Confirm Password",
|
|
114
|
+
value: store.confirmPassword,
|
|
115
|
+
onChange: store.setConfirmPassword,
|
|
116
|
+
placeholder: "Confirm your new password",
|
|
117
|
+
isNewPassword: true,
|
|
118
|
+
confirmValue: store.newPassword,
|
|
119
|
+
enableValidation: false
|
|
120
|
+
}),
|
|
121
|
+
/*#__PURE__*/ _jsx("button", {
|
|
122
|
+
type: "submit",
|
|
123
|
+
disabled: activeAction?.state.isPending,
|
|
124
|
+
className: theme.form.submitButton,
|
|
125
|
+
children: activeAction?.state.isPending ? "Setting Password..." : "Set Password"
|
|
126
|
+
}),
|
|
127
|
+
/*#__PURE__*/ _jsx("div", {
|
|
128
|
+
className: theme.form.backLink,
|
|
129
|
+
children: backToLoginHref ? /*#__PURE__*/ _jsx("a", {
|
|
130
|
+
href: backToLoginHref,
|
|
131
|
+
className: theme.form.backLinkText,
|
|
132
|
+
children: "Back to login"
|
|
133
|
+
}) : onBackToLogin ? /*#__PURE__*/ _jsx("button", {
|
|
134
|
+
type: "button",
|
|
135
|
+
onClick: onBackToLogin,
|
|
136
|
+
className: theme.form.backLinkText,
|
|
137
|
+
children: "Back to login"
|
|
138
|
+
}) : null
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
});
|
|
142
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { setPasswordPageTheme } from "../theme";
|
|
4
|
+
export function SetPasswordHeader({ logo, title, subtitle }) {
|
|
5
|
+
const theme = setPasswordPageTheme;
|
|
6
|
+
return /*#__PURE__*/ _jsxs("header", {
|
|
7
|
+
className: theme.header.wrapper,
|
|
8
|
+
children: [
|
|
9
|
+
logo && /*#__PURE__*/ _jsx("div", {
|
|
10
|
+
className: theme.header.logo,
|
|
11
|
+
children: logo
|
|
12
|
+
}),
|
|
13
|
+
/*#__PURE__*/ _jsx("h1", {
|
|
14
|
+
className: theme.header.title,
|
|
15
|
+
children: title
|
|
16
|
+
}),
|
|
17
|
+
/*#__PURE__*/ _jsx("p", {
|
|
18
|
+
className: theme.header.subtitle,
|
|
19
|
+
children: subtitle
|
|
20
|
+
})
|
|
21
|
+
]
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useGSAP } from "@gsap/react";
|
|
4
|
+
import gsap from "gsap";
|
|
5
|
+
import { useEffect, useEffectEvent, useRef } from "react";
|
|
6
|
+
import { cn } from "../../../utils/cn";
|
|
7
|
+
import { AbstractAnimatedBackground } from "../../AbstractAnimatedBackground";
|
|
8
|
+
import { useSetPasswordStore } from "../store";
|
|
9
|
+
import { setPasswordPageTheme } from "../theme";
|
|
10
|
+
import { SetPasswordForm } from "./SetPasswordForm";
|
|
11
|
+
import { SetPasswordHeader } from "./SetPasswordHeader";
|
|
12
|
+
gsap.registerPlugin(useGSAP);
|
|
13
|
+
export function SetPasswordPage({ logo, title = "Set Password", subtitle = "Enter your new password below.", inviteTitle = "Set Your Password", inviteSubtitle = "Welcome! Please set your password to complete your account setup.", token, isInvite = false, magicLinkVerifyAction, passwordChangeAction, passwordSetAction, onBackToLogin, onSuccess, backToLoginHref, showBackground = true, className, passwordPolicy }) {
|
|
14
|
+
const theme = setPasswordPageTheme;
|
|
15
|
+
const containerRef = useRef(null);
|
|
16
|
+
const cardRef = useRef(null);
|
|
17
|
+
const store = useSetPasswordStore();
|
|
18
|
+
const verifyToken = useEffectEvent((tokenValue)=>{
|
|
19
|
+
if (!tokenValue) {
|
|
20
|
+
store.setStep("error");
|
|
21
|
+
store.setError("Invalid or missing token");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
magicLinkVerifyAction.start({
|
|
25
|
+
payload: {
|
|
26
|
+
token: tokenValue
|
|
27
|
+
},
|
|
28
|
+
onAfterHandle: (data)=>{
|
|
29
|
+
const response = data;
|
|
30
|
+
const userId = response?.data?.user?.id;
|
|
31
|
+
if (userId) {
|
|
32
|
+
store.setUserId(userId);
|
|
33
|
+
}
|
|
34
|
+
store.setStep("form");
|
|
35
|
+
},
|
|
36
|
+
onErrorHandle: (error)=>{
|
|
37
|
+
store.setStep("error");
|
|
38
|
+
store.setError(error?.message || "Token verification failed");
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
useEffect(()=>{
|
|
43
|
+
verifyToken(token);
|
|
44
|
+
return ()=>{
|
|
45
|
+
store.reset();
|
|
46
|
+
};
|
|
47
|
+
}, [
|
|
48
|
+
token
|
|
49
|
+
]);
|
|
50
|
+
useGSAP(()=>{
|
|
51
|
+
if (!cardRef.current) return;
|
|
52
|
+
gsap.fromTo(cardRef.current, {
|
|
53
|
+
opacity: 0,
|
|
54
|
+
y: 30,
|
|
55
|
+
scale: 0.95
|
|
56
|
+
}, {
|
|
57
|
+
opacity: 1,
|
|
58
|
+
y: 0,
|
|
59
|
+
scale: 1,
|
|
60
|
+
duration: 0.6,
|
|
61
|
+
ease: "power3.out"
|
|
62
|
+
});
|
|
63
|
+
}, {
|
|
64
|
+
scope: containerRef
|
|
65
|
+
});
|
|
66
|
+
const displayTitle = isInvite ? inviteTitle : title;
|
|
67
|
+
const displaySubtitle = isInvite ? inviteSubtitle : subtitle;
|
|
68
|
+
if (store.step === "verifying") {
|
|
69
|
+
return /*#__PURE__*/ _jsxs("main", {
|
|
70
|
+
ref: containerRef,
|
|
71
|
+
className: cn(theme.container.base, className),
|
|
72
|
+
children: [
|
|
73
|
+
showBackground && /*#__PURE__*/ _jsx(AbstractAnimatedBackground, {}),
|
|
74
|
+
/*#__PURE__*/ _jsx("div", {
|
|
75
|
+
className: theme.container.wrapper,
|
|
76
|
+
children: /*#__PURE__*/ _jsx("article", {
|
|
77
|
+
ref: cardRef,
|
|
78
|
+
className: cn(theme.card.base, theme.card.padding, theme.card.background, theme.card.border, theme.card.shadow, theme.card.rounded),
|
|
79
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
80
|
+
className: theme.states.verifying.wrapper,
|
|
81
|
+
children: [
|
|
82
|
+
/*#__PURE__*/ _jsx("div", {
|
|
83
|
+
className: theme.states.verifying.iconWrapper,
|
|
84
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
85
|
+
className: theme.states.verifying.spinner
|
|
86
|
+
})
|
|
87
|
+
}),
|
|
88
|
+
/*#__PURE__*/ _jsx("h1", {
|
|
89
|
+
className: theme.states.verifying.title,
|
|
90
|
+
children: "Verifying Invitation"
|
|
91
|
+
}),
|
|
92
|
+
/*#__PURE__*/ _jsx("p", {
|
|
93
|
+
className: theme.states.verifying.subtitle,
|
|
94
|
+
children: "Please wait while we verify your invitation link..."
|
|
95
|
+
})
|
|
96
|
+
]
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
if (store.step === "error") {
|
|
104
|
+
return /*#__PURE__*/ _jsxs("main", {
|
|
105
|
+
ref: containerRef,
|
|
106
|
+
className: cn(theme.container.base, className),
|
|
107
|
+
children: [
|
|
108
|
+
showBackground && /*#__PURE__*/ _jsx(AbstractAnimatedBackground, {}),
|
|
109
|
+
/*#__PURE__*/ _jsx("div", {
|
|
110
|
+
className: theme.container.wrapper,
|
|
111
|
+
children: /*#__PURE__*/ _jsxs("article", {
|
|
112
|
+
ref: cardRef,
|
|
113
|
+
className: cn(theme.card.base, theme.card.padding, theme.card.background, theme.card.border, theme.card.shadow, theme.card.rounded),
|
|
114
|
+
children: [
|
|
115
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
116
|
+
className: theme.layout.textCenter,
|
|
117
|
+
children: [
|
|
118
|
+
/*#__PURE__*/ _jsx("div", {
|
|
119
|
+
className: theme.states.error.iconWrapper,
|
|
120
|
+
children: /*#__PURE__*/ _jsx("svg", {
|
|
121
|
+
className: theme.states.error.icon,
|
|
122
|
+
fill: "none",
|
|
123
|
+
stroke: "currentColor",
|
|
124
|
+
viewBox: "0 0 24 24",
|
|
125
|
+
"aria-hidden": "true",
|
|
126
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
127
|
+
strokeLinecap: "round",
|
|
128
|
+
strokeLinejoin: "round",
|
|
129
|
+
strokeWidth: 2,
|
|
130
|
+
d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
}),
|
|
134
|
+
/*#__PURE__*/ _jsx("h1", {
|
|
135
|
+
className: theme.states.error.title,
|
|
136
|
+
children: "Invalid Link"
|
|
137
|
+
}),
|
|
138
|
+
/*#__PURE__*/ _jsx("p", {
|
|
139
|
+
className: theme.states.error.subtitle,
|
|
140
|
+
children: isInvite ? "This invitation link is invalid or has expired." : "This link is invalid or has expired."
|
|
141
|
+
}),
|
|
142
|
+
store.error && store.error !== "Token verification failed" && /*#__PURE__*/ _jsx("p", {
|
|
143
|
+
className: theme.states.error.errorMessage,
|
|
144
|
+
children: store.error
|
|
145
|
+
}),
|
|
146
|
+
/*#__PURE__*/ _jsx("p", {
|
|
147
|
+
className: theme.states.error.helpText,
|
|
148
|
+
children: isInvite ? "Please contact your administrator to request a new invitation." : "Please request a new link or contact support."
|
|
149
|
+
}),
|
|
150
|
+
/*#__PURE__*/ _jsx("div", {
|
|
151
|
+
className: theme.layout.buttonGroup,
|
|
152
|
+
children: backToLoginHref ? /*#__PURE__*/ _jsx("a", {
|
|
153
|
+
href: backToLoginHref,
|
|
154
|
+
className: theme.states.error.buttonPrimary,
|
|
155
|
+
children: "Go to Login"
|
|
156
|
+
}) : /*#__PURE__*/ _jsx("button", {
|
|
157
|
+
type: "button",
|
|
158
|
+
onClick: onBackToLogin,
|
|
159
|
+
className: theme.states.error.buttonPrimary,
|
|
160
|
+
children: "Go to Login"
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
]
|
|
164
|
+
}),
|
|
165
|
+
/*#__PURE__*/ _jsx("p", {
|
|
166
|
+
className: theme.footer,
|
|
167
|
+
children: "Need help? Contact your system administrator."
|
|
168
|
+
})
|
|
169
|
+
]
|
|
170
|
+
})
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
if (store.step === "success") {
|
|
176
|
+
return /*#__PURE__*/ _jsxs("main", {
|
|
177
|
+
ref: containerRef,
|
|
178
|
+
className: cn(theme.container.base, className),
|
|
179
|
+
children: [
|
|
180
|
+
showBackground && /*#__PURE__*/ _jsx(AbstractAnimatedBackground, {}),
|
|
181
|
+
/*#__PURE__*/ _jsx("div", {
|
|
182
|
+
className: theme.container.wrapper,
|
|
183
|
+
children: /*#__PURE__*/ _jsx("article", {
|
|
184
|
+
ref: cardRef,
|
|
185
|
+
className: cn(theme.card.base, theme.card.padding, theme.card.background, theme.card.border, theme.card.shadow, theme.card.rounded),
|
|
186
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
187
|
+
className: theme.layout.textCenter,
|
|
188
|
+
children: [
|
|
189
|
+
/*#__PURE__*/ _jsx("div", {
|
|
190
|
+
className: theme.states.success.iconWrapper,
|
|
191
|
+
children: /*#__PURE__*/ _jsx("svg", {
|
|
192
|
+
className: theme.states.success.icon,
|
|
193
|
+
fill: "none",
|
|
194
|
+
stroke: "currentColor",
|
|
195
|
+
viewBox: "0 0 24 24",
|
|
196
|
+
"aria-hidden": "true",
|
|
197
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
198
|
+
strokeLinecap: "round",
|
|
199
|
+
strokeLinejoin: "round",
|
|
200
|
+
strokeWidth: 2,
|
|
201
|
+
d: "M5 13l4 4L19 7"
|
|
202
|
+
})
|
|
203
|
+
})
|
|
204
|
+
}),
|
|
205
|
+
/*#__PURE__*/ _jsx("h1", {
|
|
206
|
+
className: theme.states.success.title,
|
|
207
|
+
children: "Password Set Successfully!"
|
|
208
|
+
}),
|
|
209
|
+
/*#__PURE__*/ _jsx("p", {
|
|
210
|
+
className: theme.states.success.subtitle,
|
|
211
|
+
children: "Your account is now ready. Redirecting you to login..."
|
|
212
|
+
}),
|
|
213
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
214
|
+
className: theme.layout.redirectWrapper,
|
|
215
|
+
children: [
|
|
216
|
+
/*#__PURE__*/ _jsx("div", {
|
|
217
|
+
className: theme.states.success.redirectSpinner
|
|
218
|
+
}),
|
|
219
|
+
/*#__PURE__*/ _jsx("span", {
|
|
220
|
+
className: theme.states.success.redirectText,
|
|
221
|
+
children: "Redirecting..."
|
|
222
|
+
})
|
|
223
|
+
]
|
|
224
|
+
})
|
|
225
|
+
]
|
|
226
|
+
})
|
|
227
|
+
})
|
|
228
|
+
})
|
|
229
|
+
]
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
return /*#__PURE__*/ _jsxs("main", {
|
|
233
|
+
ref: containerRef,
|
|
234
|
+
className: cn(theme.container.base, className),
|
|
235
|
+
"aria-label": "Set password page",
|
|
236
|
+
children: [
|
|
237
|
+
showBackground && /*#__PURE__*/ _jsx(AbstractAnimatedBackground, {}),
|
|
238
|
+
/*#__PURE__*/ _jsx("div", {
|
|
239
|
+
className: theme.container.wrapper,
|
|
240
|
+
children: /*#__PURE__*/ _jsxs("article", {
|
|
241
|
+
ref: cardRef,
|
|
242
|
+
className: cn(theme.card.base, theme.card.padding, theme.card.background, theme.card.border, theme.card.shadow, theme.card.rounded),
|
|
243
|
+
children: [
|
|
244
|
+
/*#__PURE__*/ _jsx(SetPasswordHeader, {
|
|
245
|
+
logo: logo,
|
|
246
|
+
title: displayTitle,
|
|
247
|
+
subtitle: displaySubtitle
|
|
248
|
+
}),
|
|
249
|
+
/*#__PURE__*/ _jsx(SetPasswordForm, {
|
|
250
|
+
passwordChangeAction: passwordChangeAction,
|
|
251
|
+
passwordSetAction: passwordSetAction,
|
|
252
|
+
isInvite: isInvite,
|
|
253
|
+
onSuccess: onSuccess,
|
|
254
|
+
onBackToLogin: onBackToLogin,
|
|
255
|
+
backToLoginHref: backToLoginHref,
|
|
256
|
+
passwordPolicy: passwordPolicy
|
|
257
|
+
})
|
|
258
|
+
]
|
|
259
|
+
})
|
|
260
|
+
})
|
|
261
|
+
]
|
|
262
|
+
});
|
|
263
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { PasswordStrengthIndicator } from "./components/PasswordStrengthIndicator";
|
|
2
|
+
export { SetPasswordForm } from "./components/SetPasswordForm";
|
|
3
|
+
export { SetPasswordHeader } from "./components/SetPasswordHeader";
|
|
4
|
+
export { SetPasswordPage } from "./components/SetPasswordPage";
|
|
5
|
+
export { useSetPasswordStore } from "./store";
|
|
6
|
+
export { extendSetPasswordPageTheme, setPasswordPageTheme } from "./theme";
|
|
7
|
+
export { DEFAULT_PASSWORD_POLICY } from "./types";
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { batch, createStore } from "h-state";
|
|
3
|
+
const calculatePasswordStrength = (password, minLength = 8)=>{
|
|
4
|
+
const hasMinLength = password.length >= minLength;
|
|
5
|
+
const hasUppercase = /[A-Z]/.test(password);
|
|
6
|
+
const hasLowercase = /[a-z]/.test(password);
|
|
7
|
+
const hasNumber = /[0-9]/.test(password);
|
|
8
|
+
const hasSpecialChar = /[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(password);
|
|
9
|
+
let score = 0;
|
|
10
|
+
if (hasMinLength) score += 1;
|
|
11
|
+
if (hasUppercase) score += 1;
|
|
12
|
+
if (hasLowercase) score += 1;
|
|
13
|
+
if (hasNumber) score += 1;
|
|
14
|
+
if (hasSpecialChar) score += 1;
|
|
15
|
+
return {
|
|
16
|
+
score,
|
|
17
|
+
hasMinLength,
|
|
18
|
+
hasUppercase,
|
|
19
|
+
hasLowercase,
|
|
20
|
+
hasNumber,
|
|
21
|
+
hasSpecialChar
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const initialState = {
|
|
25
|
+
newPassword: "",
|
|
26
|
+
confirmPassword: "",
|
|
27
|
+
step: "verifying",
|
|
28
|
+
error: null,
|
|
29
|
+
userId: null,
|
|
30
|
+
passwordStrength: {
|
|
31
|
+
score: 0,
|
|
32
|
+
hasMinLength: false,
|
|
33
|
+
hasUppercase: false,
|
|
34
|
+
hasLowercase: false,
|
|
35
|
+
hasNumber: false,
|
|
36
|
+
hasSpecialChar: false
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export const { useStore: useSetPasswordStore } = createStore(initialState, {
|
|
40
|
+
setNewPassword: (store)=>(password, minLength = 8)=>{
|
|
41
|
+
store.newPassword = password;
|
|
42
|
+
store.passwordStrength = calculatePasswordStrength(password, minLength);
|
|
43
|
+
if (store.error) {
|
|
44
|
+
store.error = null;
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
setConfirmPassword: (store)=>(password)=>{
|
|
48
|
+
store.confirmPassword = password;
|
|
49
|
+
if (store.error) {
|
|
50
|
+
store.error = null;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
setStep: (store)=>(step)=>{
|
|
54
|
+
store.step = step;
|
|
55
|
+
},
|
|
56
|
+
setError: (store)=>(error)=>{
|
|
57
|
+
store.error = error;
|
|
58
|
+
},
|
|
59
|
+
setUserId: (store)=>(userId)=>{
|
|
60
|
+
store.userId = userId;
|
|
61
|
+
},
|
|
62
|
+
reset: (store)=>()=>{
|
|
63
|
+
batch(()=>{
|
|
64
|
+
store.newPassword = "";
|
|
65
|
+
store.confirmPassword = "";
|
|
66
|
+
store.step = "verifying";
|
|
67
|
+
store.error = null;
|
|
68
|
+
store.userId = null;
|
|
69
|
+
store.passwordStrength = {
|
|
70
|
+
score: 0,
|
|
71
|
+
hasMinLength: false,
|
|
72
|
+
hasUppercase: false,
|
|
73
|
+
hasLowercase: false,
|
|
74
|
+
hasNumber: false,
|
|
75
|
+
hasSpecialChar: false
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|