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,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { batch, createStore } from "h-state";
|
|
3
|
+
const initialState = {
|
|
4
|
+
email: "",
|
|
5
|
+
password: "",
|
|
6
|
+
rememberMe: false,
|
|
7
|
+
isLoading: false,
|
|
8
|
+
error: null,
|
|
9
|
+
captchaId: null,
|
|
10
|
+
captchaAnswer: "",
|
|
11
|
+
isAuthenticated: false,
|
|
12
|
+
user: null
|
|
13
|
+
};
|
|
14
|
+
export const { useStore: useLoginStore } = createStore(initialState, {
|
|
15
|
+
setEmail: (store)=>(email)=>{
|
|
16
|
+
store.email = email;
|
|
17
|
+
if (store.error) {
|
|
18
|
+
store.error = null;
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
setPassword: (store)=>(password)=>{
|
|
22
|
+
store.password = password;
|
|
23
|
+
if (store.error) {
|
|
24
|
+
store.error = null;
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
setRememberMe: (store)=>(value)=>{
|
|
28
|
+
store.rememberMe = value;
|
|
29
|
+
},
|
|
30
|
+
setLoading: (store)=>(value)=>{
|
|
31
|
+
store.isLoading = value;
|
|
32
|
+
},
|
|
33
|
+
setError: (store)=>(error)=>{
|
|
34
|
+
store.error = error;
|
|
35
|
+
},
|
|
36
|
+
setCaptchaId: (store)=>(id)=>{
|
|
37
|
+
store.captchaId = id;
|
|
38
|
+
},
|
|
39
|
+
setCaptchaAnswer: (store)=>(answer)=>{
|
|
40
|
+
store.captchaAnswer = answer;
|
|
41
|
+
},
|
|
42
|
+
setAuthenticated: (store)=>(isAuthenticated, user)=>{
|
|
43
|
+
batch(()=>{
|
|
44
|
+
store.isAuthenticated = isAuthenticated;
|
|
45
|
+
store.user = user ?? null;
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
reset: (store)=>()=>{
|
|
49
|
+
batch(()=>{
|
|
50
|
+
store.email = "";
|
|
51
|
+
store.password = "";
|
|
52
|
+
store.rememberMe = false;
|
|
53
|
+
store.isLoading = false;
|
|
54
|
+
store.error = null;
|
|
55
|
+
store.captchaId = null;
|
|
56
|
+
store.captchaAnswer = "";
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export const loginPageTheme = {
|
|
2
|
+
container: {
|
|
3
|
+
base: "relative min-h-screen w-full flex items-center justify-center",
|
|
4
|
+
wrapper: "relative z-10 w-full max-w-md px-4 sm:px-0"
|
|
5
|
+
},
|
|
6
|
+
card: {
|
|
7
|
+
base: "w-full",
|
|
8
|
+
padding: "p-6 sm:p-8",
|
|
9
|
+
background: "bg-white/80 dark:bg-zinc-900/80 backdrop-blur-xl",
|
|
10
|
+
border: "border border-white/20 dark:border-zinc-800/50",
|
|
11
|
+
shadow: "shadow-2xl shadow-black/10 dark:shadow-black/30",
|
|
12
|
+
rounded: "rounded-2xl sm:rounded-3xl"
|
|
13
|
+
},
|
|
14
|
+
header: {
|
|
15
|
+
container: "flex flex-col items-center mb-8",
|
|
16
|
+
logoWrapper: "mb-4",
|
|
17
|
+
title: "text-2xl sm:text-3xl font-bold text-zinc-900 dark:text-white text-center",
|
|
18
|
+
subtitle: "mt-2 text-sm sm:text-base text-zinc-600 dark:text-zinc-400 text-center"
|
|
19
|
+
},
|
|
20
|
+
form: {
|
|
21
|
+
container: "w-full",
|
|
22
|
+
spacing: "space-y-4"
|
|
23
|
+
},
|
|
24
|
+
input: {
|
|
25
|
+
wrapper: "w-full"
|
|
26
|
+
},
|
|
27
|
+
checkbox: {
|
|
28
|
+
wrapper: "flex items-center",
|
|
29
|
+
label: "ml-2 text-sm text-zinc-600 dark:text-zinc-400 select-none cursor-pointer"
|
|
30
|
+
},
|
|
31
|
+
links: {
|
|
32
|
+
container: "flex items-center justify-between mt-1",
|
|
33
|
+
forgotPassword: "text-sm text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors cursor-pointer",
|
|
34
|
+
signUp: {
|
|
35
|
+
wrapper: "mt-6 text-center",
|
|
36
|
+
text: "text-sm text-zinc-600 dark:text-zinc-400",
|
|
37
|
+
link: "text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium transition-colors cursor-pointer"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
button: {
|
|
41
|
+
wrapper: "mt-6"
|
|
42
|
+
},
|
|
43
|
+
error: {
|
|
44
|
+
container: "mb-4 p-3 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800",
|
|
45
|
+
text: "text-sm text-red-600 dark:text-red-400 text-center"
|
|
46
|
+
},
|
|
47
|
+
divider: {
|
|
48
|
+
container: "relative my-6",
|
|
49
|
+
line: "absolute inset-0 flex items-center",
|
|
50
|
+
text: "relative flex justify-center text-sm"
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
export function extendLoginPageTheme(overrides) {
|
|
54
|
+
return {
|
|
55
|
+
...loginPageTheme,
|
|
56
|
+
...overrides,
|
|
57
|
+
container: {
|
|
58
|
+
...loginPageTheme.container,
|
|
59
|
+
...overrides.container
|
|
60
|
+
},
|
|
61
|
+
card: {
|
|
62
|
+
...loginPageTheme.card,
|
|
63
|
+
...overrides.card
|
|
64
|
+
},
|
|
65
|
+
header: {
|
|
66
|
+
...loginPageTheme.header,
|
|
67
|
+
...overrides.header
|
|
68
|
+
},
|
|
69
|
+
form: {
|
|
70
|
+
...loginPageTheme.form,
|
|
71
|
+
...overrides.form
|
|
72
|
+
},
|
|
73
|
+
input: {
|
|
74
|
+
...loginPageTheme.input,
|
|
75
|
+
...overrides.input
|
|
76
|
+
},
|
|
77
|
+
checkbox: {
|
|
78
|
+
...loginPageTheme.checkbox,
|
|
79
|
+
...overrides.checkbox
|
|
80
|
+
},
|
|
81
|
+
links: {
|
|
82
|
+
...loginPageTheme.links,
|
|
83
|
+
...overrides.links
|
|
84
|
+
},
|
|
85
|
+
button: {
|
|
86
|
+
...loginPageTheme.button,
|
|
87
|
+
...overrides.button
|
|
88
|
+
},
|
|
89
|
+
error: {
|
|
90
|
+
...loginPageTheme.error,
|
|
91
|
+
...overrides.error
|
|
92
|
+
},
|
|
93
|
+
divider: {
|
|
94
|
+
...loginPageTheme.divider,
|
|
95
|
+
...overrides.divider
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } 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 { useMagicLinkVerifyStore } from "../store";
|
|
8
|
+
import { magicLinkVerifyPageTheme } from "../theme";
|
|
9
|
+
gsap.registerPlugin(useGSAP);
|
|
10
|
+
function parseErrorMessage(error, defaultMsg) {
|
|
11
|
+
if (!error?.message) return defaultMsg;
|
|
12
|
+
try {
|
|
13
|
+
const parsed = JSON.parse(error.message);
|
|
14
|
+
const msg = parsed.message || "";
|
|
15
|
+
if (msg.includes("Failed query") || msg.includes("select") || msg.includes("params:")) {
|
|
16
|
+
return "An error occurred. Please try again later.";
|
|
17
|
+
}
|
|
18
|
+
return msg || defaultMsg;
|
|
19
|
+
} catch {
|
|
20
|
+
if (error.message.includes("Failed query") || error.message.includes("select")) {
|
|
21
|
+
return "An error occurred. Please try again later.";
|
|
22
|
+
}
|
|
23
|
+
return error.message;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function MagicLinkVerifyPage({ token, verifyAction, onSuccess, onError, onBackToLogin, backToLoginHref, redirectDelay = 2000, className, texts }) {
|
|
27
|
+
const theme = magicLinkVerifyPageTheme;
|
|
28
|
+
const containerRef = useRef(null);
|
|
29
|
+
const cardRef = useRef(null);
|
|
30
|
+
const hasVerified = useRef(false);
|
|
31
|
+
const store = useMagicLinkVerifyStore();
|
|
32
|
+
const verifyToken = useEffectEvent((tokenValue)=>{
|
|
33
|
+
if (!tokenValue) {
|
|
34
|
+
store.setStep("error");
|
|
35
|
+
store.setMessage("Invalid magic link. No token provided.");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (hasVerified.current) return;
|
|
39
|
+
hasVerified.current = true;
|
|
40
|
+
verifyAction.start({
|
|
41
|
+
payload: {
|
|
42
|
+
token: tokenValue
|
|
43
|
+
},
|
|
44
|
+
onAfterHandle: (response)=>{
|
|
45
|
+
if (!response) {
|
|
46
|
+
store.setStep("error");
|
|
47
|
+
store.setMessage("Verification failed. Please try again.");
|
|
48
|
+
onError?.();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (response.success && response.data) {
|
|
52
|
+
store.setStep("success");
|
|
53
|
+
store.setMessage(texts?.successSubtitle || "You have been logged in successfully!");
|
|
54
|
+
setTimeout(()=>{
|
|
55
|
+
onSuccess?.(response);
|
|
56
|
+
}, redirectDelay);
|
|
57
|
+
} else {
|
|
58
|
+
store.setStep("error");
|
|
59
|
+
store.setMessage("Verification failed. The link may be expired or invalid.");
|
|
60
|
+
onError?.();
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
onErrorHandle: (error)=>{
|
|
64
|
+
store.setStep("error");
|
|
65
|
+
store.setMessage(parseErrorMessage(error, "Verification failed. The link may be expired or invalid."));
|
|
66
|
+
onError?.();
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
useEffect(()=>{
|
|
71
|
+
if (token) {
|
|
72
|
+
verifyToken(token);
|
|
73
|
+
} else {
|
|
74
|
+
store.setStep("error");
|
|
75
|
+
store.setMessage("Invalid magic link. No token provided.");
|
|
76
|
+
}
|
|
77
|
+
return ()=>{
|
|
78
|
+
store.reset();
|
|
79
|
+
};
|
|
80
|
+
}, [
|
|
81
|
+
token
|
|
82
|
+
]);
|
|
83
|
+
useGSAP(()=>{
|
|
84
|
+
if (!cardRef.current) return;
|
|
85
|
+
gsap.fromTo(cardRef.current, {
|
|
86
|
+
opacity: 0,
|
|
87
|
+
y: 30,
|
|
88
|
+
scale: 0.95
|
|
89
|
+
}, {
|
|
90
|
+
opacity: 1,
|
|
91
|
+
y: 0,
|
|
92
|
+
scale: 1,
|
|
93
|
+
duration: 0.6,
|
|
94
|
+
ease: "power3.out"
|
|
95
|
+
});
|
|
96
|
+
}, {
|
|
97
|
+
scope: containerRef
|
|
98
|
+
});
|
|
99
|
+
const handleBackToLogin = ()=>{
|
|
100
|
+
if (onBackToLogin) {
|
|
101
|
+
onBackToLogin();
|
|
102
|
+
} else if (backToLoginHref) {
|
|
103
|
+
window.location.href = backToLoginHref;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
return /*#__PURE__*/ _jsx("main", {
|
|
107
|
+
ref: containerRef,
|
|
108
|
+
className: cn(theme.container.base, className),
|
|
109
|
+
children: /*#__PURE__*/ _jsx("article", {
|
|
110
|
+
ref: cardRef,
|
|
111
|
+
className: cn(theme.card.base, theme.card.background, theme.card.border, theme.card.shadow, theme.card.rounded),
|
|
112
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
113
|
+
className: theme.content.wrapper,
|
|
114
|
+
children: [
|
|
115
|
+
store.step === "verifying" && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
116
|
+
children: [
|
|
117
|
+
/*#__PURE__*/ _jsx("div", {
|
|
118
|
+
className: theme.states.verifying.spinner
|
|
119
|
+
}),
|
|
120
|
+
/*#__PURE__*/ _jsx("h1", {
|
|
121
|
+
className: theme.states.verifying.title,
|
|
122
|
+
children: texts?.verifyingTitle || "Verifying Magic Link"
|
|
123
|
+
}),
|
|
124
|
+
/*#__PURE__*/ _jsx("p", {
|
|
125
|
+
className: theme.states.verifying.subtitle,
|
|
126
|
+
children: texts?.verifyingSubtitle || store.message
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
}),
|
|
130
|
+
store.step === "success" && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
131
|
+
children: [
|
|
132
|
+
/*#__PURE__*/ _jsx("div", {
|
|
133
|
+
className: theme.states.success.iconWrapper,
|
|
134
|
+
children: /*#__PURE__*/ _jsx("svg", {
|
|
135
|
+
className: theme.states.success.icon,
|
|
136
|
+
fill: "none",
|
|
137
|
+
stroke: "currentColor",
|
|
138
|
+
viewBox: "0 0 24 24",
|
|
139
|
+
"aria-hidden": "true",
|
|
140
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
141
|
+
strokeLinecap: "round",
|
|
142
|
+
strokeLinejoin: "round",
|
|
143
|
+
strokeWidth: 2,
|
|
144
|
+
d: "M5 13l4 4L19 7"
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
}),
|
|
148
|
+
/*#__PURE__*/ _jsx("h1", {
|
|
149
|
+
className: theme.states.success.title,
|
|
150
|
+
children: texts?.successTitle || "Login Successful!"
|
|
151
|
+
}),
|
|
152
|
+
/*#__PURE__*/ _jsx("p", {
|
|
153
|
+
className: theme.states.success.subtitle,
|
|
154
|
+
children: store.message
|
|
155
|
+
}),
|
|
156
|
+
/*#__PURE__*/ _jsx("p", {
|
|
157
|
+
className: theme.states.success.redirectText,
|
|
158
|
+
children: "Redirecting..."
|
|
159
|
+
})
|
|
160
|
+
]
|
|
161
|
+
}),
|
|
162
|
+
store.step === "error" && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
163
|
+
children: [
|
|
164
|
+
/*#__PURE__*/ _jsx("div", {
|
|
165
|
+
className: theme.states.error.iconWrapper,
|
|
166
|
+
children: /*#__PURE__*/ _jsx("svg", {
|
|
167
|
+
className: theme.states.error.icon,
|
|
168
|
+
fill: "none",
|
|
169
|
+
stroke: "currentColor",
|
|
170
|
+
viewBox: "0 0 24 24",
|
|
171
|
+
"aria-hidden": "true",
|
|
172
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
173
|
+
strokeLinecap: "round",
|
|
174
|
+
strokeLinejoin: "round",
|
|
175
|
+
strokeWidth: 2,
|
|
176
|
+
d: "M6 18L18 6M6 6l12 12"
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
}),
|
|
180
|
+
/*#__PURE__*/ _jsx("h1", {
|
|
181
|
+
className: theme.states.error.title,
|
|
182
|
+
children: texts?.errorTitle || "Verification Failed"
|
|
183
|
+
}),
|
|
184
|
+
/*#__PURE__*/ _jsx("p", {
|
|
185
|
+
className: theme.states.error.subtitle,
|
|
186
|
+
children: store.message
|
|
187
|
+
}),
|
|
188
|
+
(onBackToLogin || backToLoginHref) && /*#__PURE__*/ _jsx("button", {
|
|
189
|
+
type: "button",
|
|
190
|
+
onClick: handleBackToLogin,
|
|
191
|
+
className: theme.backButton,
|
|
192
|
+
children: texts?.backToLogin || "Back to Login"
|
|
193
|
+
})
|
|
194
|
+
]
|
|
195
|
+
})
|
|
196
|
+
]
|
|
197
|
+
})
|
|
198
|
+
})
|
|
199
|
+
});
|
|
200
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { batch, createStore } from "h-state";
|
|
3
|
+
const initialState = {
|
|
4
|
+
step: "verifying",
|
|
5
|
+
message: "Please wait while we verify your magic link..."
|
|
6
|
+
};
|
|
7
|
+
export const { useStore: useMagicLinkVerifyStore } = createStore(initialState, {
|
|
8
|
+
setStep: (store)=>(step)=>{
|
|
9
|
+
store.step = step;
|
|
10
|
+
},
|
|
11
|
+
setMessage: (store)=>(message)=>{
|
|
12
|
+
store.message = message;
|
|
13
|
+
},
|
|
14
|
+
reset: (store)=>()=>{
|
|
15
|
+
batch(()=>{
|
|
16
|
+
store.step = "verifying";
|
|
17
|
+
store.message = "Please wait while we verify your magic link...";
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const magicLinkVerifyPageTheme = {
|
|
2
|
+
container: {
|
|
3
|
+
base: "min-h-screen flex items-center justify-center p-4 bg-gradient-to-br from-zinc-50 via-white to-zinc-100 dark:from-zinc-950 dark:via-zinc-900 dark:to-zinc-950"
|
|
4
|
+
},
|
|
5
|
+
card: {
|
|
6
|
+
base: "w-full max-w-md p-8",
|
|
7
|
+
background: "bg-white dark:bg-zinc-900",
|
|
8
|
+
border: "border border-zinc-200 dark:border-zinc-800",
|
|
9
|
+
shadow: "shadow-xl shadow-zinc-200/50 dark:shadow-zinc-950/50",
|
|
10
|
+
rounded: "rounded-2xl"
|
|
11
|
+
},
|
|
12
|
+
content: {
|
|
13
|
+
wrapper: "flex flex-col items-center text-center space-y-4"
|
|
14
|
+
},
|
|
15
|
+
states: {
|
|
16
|
+
verifying: {
|
|
17
|
+
spinner: "w-12 h-12 border-4 border-zinc-200 dark:border-zinc-700 border-t-blue-500 rounded-full animate-spin",
|
|
18
|
+
title: "text-xl font-semibold text-zinc-900 dark:text-zinc-100",
|
|
19
|
+
subtitle: "text-sm text-zinc-500 dark:text-zinc-400"
|
|
20
|
+
},
|
|
21
|
+
success: {
|
|
22
|
+
iconWrapper: "w-16 h-16 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",
|
|
23
|
+
icon: "w-8 h-8 text-green-600 dark:text-green-400",
|
|
24
|
+
title: "text-xl font-semibold text-zinc-900 dark:text-zinc-100",
|
|
25
|
+
subtitle: "text-sm text-green-600 dark:text-green-400",
|
|
26
|
+
redirectText: "text-xs text-zinc-400 dark:text-zinc-500 animate-pulse"
|
|
27
|
+
},
|
|
28
|
+
error: {
|
|
29
|
+
iconWrapper: "w-16 h-16 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",
|
|
30
|
+
icon: "w-8 h-8 text-red-600 dark:text-red-400",
|
|
31
|
+
title: "text-xl font-semibold text-zinc-900 dark:text-zinc-100",
|
|
32
|
+
subtitle: "text-sm text-red-600 dark:text-red-400"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
backButton: "mt-6 px-6 py-2.5 text-sm font-medium text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-lg transition-colors duration-200"
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|