nucleus-core-ts 0.8.7 → 0.8.8
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/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/package.json +1 -1
- package/scripts/build.ts +32 -16
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
export const dataTableTheme = {
|
|
2
|
+
container: {
|
|
3
|
+
base: "w-full overflow-hidden",
|
|
4
|
+
border: "border border-gray-200 dark:border-gray-700",
|
|
5
|
+
rounded: "rounded-lg",
|
|
6
|
+
shadow: "shadow-sm"
|
|
7
|
+
},
|
|
8
|
+
scrollContainer: {
|
|
9
|
+
base: "overflow-auto",
|
|
10
|
+
maxHeight: "max-h-[70vh]",
|
|
11
|
+
scrollbar: "scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-gray-600 scrollbar-track-transparent"
|
|
12
|
+
},
|
|
13
|
+
table: {
|
|
14
|
+
base: "w-full border-collapse table-fixed",
|
|
15
|
+
layout: "min-w-full"
|
|
16
|
+
},
|
|
17
|
+
header: {
|
|
18
|
+
wrapper: {
|
|
19
|
+
base: "sticky top-0 z-10",
|
|
20
|
+
background: "bg-gray-50 dark:bg-gray-800"
|
|
21
|
+
},
|
|
22
|
+
row: {
|
|
23
|
+
base: "",
|
|
24
|
+
border: "border-b border-gray-200 dark:border-gray-700"
|
|
25
|
+
},
|
|
26
|
+
cell: {
|
|
27
|
+
base: "relative select-none bg-gray-50 dark:bg-gray-800",
|
|
28
|
+
padding: "px-4 py-3",
|
|
29
|
+
text: "text-left text-xs font-semibold uppercase tracking-wider",
|
|
30
|
+
color: "text-gray-600 dark:text-gray-300",
|
|
31
|
+
transition: "transition-colors duration-200",
|
|
32
|
+
hover: "hover:bg-gray-100 dark:hover:bg-gray-750",
|
|
33
|
+
sortable: "cursor-pointer",
|
|
34
|
+
sorted: "bg-gray-100 dark:bg-gray-750"
|
|
35
|
+
},
|
|
36
|
+
sortIcon: {
|
|
37
|
+
base: "inline-flex ml-1.5 transition-transform duration-300",
|
|
38
|
+
active: "text-primary-500 dark:text-primary-400",
|
|
39
|
+
inactive: "text-gray-400 dark:text-gray-500"
|
|
40
|
+
},
|
|
41
|
+
resizeHandle: {
|
|
42
|
+
base: "absolute right-0 top-0 h-full w-1 cursor-col-resize",
|
|
43
|
+
idle: "bg-transparent hover:bg-primary-400 dark:hover:bg-primary-500",
|
|
44
|
+
active: "bg-primary-500 dark:bg-primary-400",
|
|
45
|
+
hitArea: 'before:absolute before:right-[-4px] before:top-0 before:h-full before:w-[9px] before:content-[""]'
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
body: {
|
|
49
|
+
wrapper: {
|
|
50
|
+
base: ""
|
|
51
|
+
},
|
|
52
|
+
row: {
|
|
53
|
+
base: "group",
|
|
54
|
+
border: "border-b border-gray-100 dark:border-gray-700/50",
|
|
55
|
+
transition: "transition-colors duration-150",
|
|
56
|
+
hover: "hover:bg-gray-50 dark:hover:bg-gray-800/50",
|
|
57
|
+
zebra: {
|
|
58
|
+
even: "bg-white dark:bg-gray-900",
|
|
59
|
+
odd: "bg-gray-50/50 dark:bg-gray-800/30"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
cell: {
|
|
63
|
+
base: "relative",
|
|
64
|
+
padding: "px-4 py-3",
|
|
65
|
+
text: "text-sm",
|
|
66
|
+
color: "text-gray-900 dark:text-gray-100",
|
|
67
|
+
truncate: "truncate",
|
|
68
|
+
transition: "transition-all duration-150",
|
|
69
|
+
hover: "group-hover:bg-gray-50/50 dark:group-hover:bg-gray-800/30"
|
|
70
|
+
},
|
|
71
|
+
resizeHandle: {
|
|
72
|
+
base: "absolute bottom-0 left-0 w-full h-1 cursor-row-resize",
|
|
73
|
+
idle: "bg-transparent hover:bg-primary-400 dark:hover:bg-primary-500",
|
|
74
|
+
active: "bg-primary-500 dark:bg-primary-400",
|
|
75
|
+
hitArea: 'before:absolute before:bottom-[-4px] before:left-0 before:w-full before:h-[9px] before:content-[""]'
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
loading: {
|
|
79
|
+
wrapper: "flex items-center justify-center py-8",
|
|
80
|
+
spinner: {
|
|
81
|
+
base: "animate-spin rounded-full border-2",
|
|
82
|
+
size: "h-8 w-8",
|
|
83
|
+
color: "border-primary-500 border-t-transparent"
|
|
84
|
+
},
|
|
85
|
+
text: "ml-3 text-sm text-gray-500 dark:text-gray-400"
|
|
86
|
+
},
|
|
87
|
+
empty: {
|
|
88
|
+
wrapper: "flex flex-col items-center justify-center py-12",
|
|
89
|
+
icon: "h-12 w-12 text-gray-300 dark:text-gray-600 mb-4",
|
|
90
|
+
text: "text-sm text-gray-500 dark:text-gray-400"
|
|
91
|
+
},
|
|
92
|
+
infiniteScroll: {
|
|
93
|
+
trigger: "h-1 w-full",
|
|
94
|
+
loader: "flex items-center justify-center py-4"
|
|
95
|
+
},
|
|
96
|
+
animation: {
|
|
97
|
+
row: {
|
|
98
|
+
enter: {
|
|
99
|
+
opacity: 0,
|
|
100
|
+
y: 10
|
|
101
|
+
},
|
|
102
|
+
visible: {
|
|
103
|
+
opacity: 1,
|
|
104
|
+
y: 0
|
|
105
|
+
},
|
|
106
|
+
duration: 0.3,
|
|
107
|
+
stagger: 0.02
|
|
108
|
+
},
|
|
109
|
+
cell: {
|
|
110
|
+
hover: {
|
|
111
|
+
scale: 1.01
|
|
112
|
+
},
|
|
113
|
+
duration: 0.15
|
|
114
|
+
},
|
|
115
|
+
sort: {
|
|
116
|
+
duration: 0.3,
|
|
117
|
+
ease: "power2.out"
|
|
118
|
+
},
|
|
119
|
+
resize: {
|
|
120
|
+
duration: 0.1,
|
|
121
|
+
ease: "power1.out"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
export function extendTheme(overrides) {
|
|
126
|
+
return deepMerge(dataTableTheme, overrides);
|
|
127
|
+
}
|
|
128
|
+
function deepMerge(target, source) {
|
|
129
|
+
const output = {
|
|
130
|
+
...target
|
|
131
|
+
};
|
|
132
|
+
for(const key in source){
|
|
133
|
+
if (Object.hasOwn(source, key)) {
|
|
134
|
+
const sourceValue = source[key];
|
|
135
|
+
const targetValue = target[key];
|
|
136
|
+
if (sourceValue !== undefined && typeof sourceValue === "object" && sourceValue !== null && !Array.isArray(sourceValue) && typeof targetValue === "object" && targetValue !== null && !Array.isArray(targetValue)) {
|
|
137
|
+
output[key] = deepMerge(targetValue, sourceValue);
|
|
138
|
+
} else if (sourceValue !== undefined) {
|
|
139
|
+
output[key] = sourceValue;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return output;
|
|
144
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,95 @@
|
|
|
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 { useRef } from "react";
|
|
6
|
+
import { datePickerTheme } from "../theme";
|
|
7
|
+
import { cn } from "../utils/cn";
|
|
8
|
+
import { getCalendarDays, getWeekdaysForLocale, isDateDisabled, isDateInRange, isSameDay, isSameMonth, isToday } from "../utils/date";
|
|
9
|
+
gsap.registerPlugin(useGSAP);
|
|
10
|
+
export function CalendarGrid({ currentMonth, selectedDate, selectedRange, mode, locale, minDate, maxDate, disabledDates, disabledDaysOfWeek, firstDayOfWeek, onDateSelect, hoverDate, onHoverChange }) {
|
|
11
|
+
const gridRef = useRef(null);
|
|
12
|
+
const theme = datePickerTheme;
|
|
13
|
+
const days = getCalendarDays(currentMonth.getFullYear(), currentMonth.getMonth(), firstDayOfWeek);
|
|
14
|
+
const weekdays = getWeekdaysForLocale(locale, firstDayOfWeek);
|
|
15
|
+
useGSAP(()=>{
|
|
16
|
+
if (!gridRef.current) return;
|
|
17
|
+
const dayElements = gridRef.current.querySelectorAll("[data-day]");
|
|
18
|
+
gsap.fromTo(dayElements, {
|
|
19
|
+
opacity: 0,
|
|
20
|
+
scale: 0.8
|
|
21
|
+
}, {
|
|
22
|
+
opacity: 1,
|
|
23
|
+
scale: 1,
|
|
24
|
+
duration: 0.3,
|
|
25
|
+
stagger: {
|
|
26
|
+
amount: 0.15,
|
|
27
|
+
grid: [
|
|
28
|
+
6,
|
|
29
|
+
7
|
|
30
|
+
],
|
|
31
|
+
from: "start"
|
|
32
|
+
},
|
|
33
|
+
ease: "power2.out"
|
|
34
|
+
});
|
|
35
|
+
}, [
|
|
36
|
+
currentMonth
|
|
37
|
+
]);
|
|
38
|
+
const getDayClasses = (date)=>{
|
|
39
|
+
const isSelected = mode === "single" ? isSameDay(date, selectedDate) : selectedRange && (isSameDay(date, selectedRange.start) || isSameDay(date, selectedRange.end));
|
|
40
|
+
const isInCurrentMonth = isSameMonth(date, currentMonth);
|
|
41
|
+
const isDisabled = isDateDisabled(date, minDate, maxDate, disabledDates, disabledDaysOfWeek);
|
|
42
|
+
const isTodayDate = isToday(date);
|
|
43
|
+
const inRange = mode === "range" && selectedRange ? isDateInRange(date, selectedRange.start, selectedRange.end) || hoverDate && selectedRange.start && !selectedRange.end && isDateInRange(date, selectedRange.start, hoverDate) : false;
|
|
44
|
+
const isHoverRangeEnd = mode === "range" && selectedRange?.start && !selectedRange?.end && hoverDate && isSameDay(date, hoverDate);
|
|
45
|
+
return cn(theme.day.base, theme.day.size, theme.day.text.size, theme.day.rounded, theme.day.transition, !isSelected && !inRange && theme.day.text.color.light, !isSelected && !inRange && theme.day.text.color.dark, !isSelected && !inRange && !isDisabled && theme.day.states.hover.light, !isSelected && !inRange && !isDisabled && theme.day.states.hover.dark, !isInCurrentMonth && theme.day.states.otherMonth.opacity, isDisabled && theme.day.states.disabled.opacity, isDisabled && theme.day.states.disabled.cursor, isTodayDate && !isSelected && theme.day.states.today.border, isTodayDate && !isSelected && theme.day.states.today.text, isSelected && theme.day.states.selected.background, isSelected && theme.day.states.selected.text, isHoverRangeEnd && "ring-2 ring-blue-400 ring-inset");
|
|
46
|
+
};
|
|
47
|
+
const handleDayClick = (date)=>{
|
|
48
|
+
if (isDateDisabled(date, minDate, maxDate, disabledDates, disabledDaysOfWeek)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
onDateSelect(date);
|
|
52
|
+
};
|
|
53
|
+
const handleDayHover = (date)=>{
|
|
54
|
+
if (mode === "range") {
|
|
55
|
+
onHoverChange(date);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
59
|
+
children: [
|
|
60
|
+
/*#__PURE__*/ _jsx("div", {
|
|
61
|
+
className: cn(theme.weekdays.base, theme.weekdays.padding),
|
|
62
|
+
children: weekdays.map((day, index)=>/*#__PURE__*/ _jsx("div", {
|
|
63
|
+
className: cn("flex items-center justify-center", theme.day.size, theme.weekdays.text.size, theme.weekdays.text.weight, theme.weekdays.text.color.light, theme.weekdays.text.color.dark),
|
|
64
|
+
children: day
|
|
65
|
+
}, `weekday-${index}`))
|
|
66
|
+
}),
|
|
67
|
+
/*#__PURE__*/ _jsx("div", {
|
|
68
|
+
ref: gridRef,
|
|
69
|
+
className: cn(theme.grid.base, theme.grid.gap),
|
|
70
|
+
children: days.map((date, index)=>{
|
|
71
|
+
const isRangeStart = mode === "range" && selectedRange?.start && isSameDay(date, selectedRange.start);
|
|
72
|
+
const isRangeEnd = mode === "range" && selectedRange?.end && isSameDay(date, selectedRange.end);
|
|
73
|
+
const inRange = mode === "range" && selectedRange ? isDateInRange(date, selectedRange.start, selectedRange.end) || hoverDate && selectedRange.start && !selectedRange.end && isDateInRange(date, selectedRange.start, hoverDate) : false;
|
|
74
|
+
const isHoverEnd = mode === "range" && selectedRange?.start && !selectedRange?.end && hoverDate && isSameDay(date, hoverDate);
|
|
75
|
+
const showRangeBg = inRange || isRangeStart || isRangeEnd || isHoverEnd;
|
|
76
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
77
|
+
className: cn(theme.dayWrapper.base, showRangeBg && theme.dayWrapper.inRange.light, showRangeBg && theme.dayWrapper.inRange.dark, isRangeStart && theme.dayWrapper.rangeStart, (isRangeEnd || isHoverEnd) && theme.dayWrapper.rangeEnd, isRangeStart && !isRangeEnd && !isHoverEnd && "rounded-r-none", (isRangeEnd || isHoverEnd) && !isRangeStart && "rounded-l-none", inRange && !isRangeStart && !isRangeEnd && !isHoverEnd && "rounded-none"),
|
|
78
|
+
children: /*#__PURE__*/ _jsx("button", {
|
|
79
|
+
type: "button",
|
|
80
|
+
"data-day": true,
|
|
81
|
+
onClick: ()=>handleDayClick(date),
|
|
82
|
+
onMouseEnter: ()=>handleDayHover(date),
|
|
83
|
+
onMouseLeave: ()=>handleDayHover(null),
|
|
84
|
+
disabled: isDateDisabled(date, minDate, maxDate, disabledDates, disabledDaysOfWeek),
|
|
85
|
+
className: getDayClasses(date),
|
|
86
|
+
"aria-label": date.toLocaleDateString(locale),
|
|
87
|
+
"aria-pressed": mode === "single" ? isSameDay(date, selectedDate) : !!(selectedRange && (isSameDay(date, selectedRange.start) || isSameDay(date, selectedRange.end))),
|
|
88
|
+
children: date.getDate()
|
|
89
|
+
})
|
|
90
|
+
}, `day-${index}`);
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
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 { useRef } from "react";
|
|
6
|
+
import { getLocale } from "../locales";
|
|
7
|
+
import { datePickerTheme } from "../theme";
|
|
8
|
+
import { cn } from "../utils/cn";
|
|
9
|
+
gsap.registerPlugin(useGSAP);
|
|
10
|
+
export function CalendarHeader({ currentMonth, onPrevMonth, onNextMonth, onPrevYear, onNextYear, onMonthYearClick, locale, minDate, maxDate }) {
|
|
11
|
+
const titleRef = useRef(null);
|
|
12
|
+
const theme = datePickerTheme;
|
|
13
|
+
const localeConfig = getLocale(locale);
|
|
14
|
+
const monthName = localeConfig.months[currentMonth.getMonth()];
|
|
15
|
+
const year = currentMonth.getFullYear();
|
|
16
|
+
const canGoPrev = !minDate || currentMonth > minDate;
|
|
17
|
+
const canGoNext = !maxDate || currentMonth < maxDate;
|
|
18
|
+
useGSAP(()=>{
|
|
19
|
+
if (!titleRef.current) return;
|
|
20
|
+
gsap.fromTo(titleRef.current, {
|
|
21
|
+
opacity: 0,
|
|
22
|
+
y: -10
|
|
23
|
+
}, {
|
|
24
|
+
opacity: 1,
|
|
25
|
+
y: 0,
|
|
26
|
+
duration: 0.2,
|
|
27
|
+
ease: "power2.out"
|
|
28
|
+
});
|
|
29
|
+
}, [
|
|
30
|
+
currentMonth
|
|
31
|
+
]);
|
|
32
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
33
|
+
className: cn(theme.header.base, theme.header.padding),
|
|
34
|
+
children: [
|
|
35
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
36
|
+
className: "flex items-center gap-1",
|
|
37
|
+
children: [
|
|
38
|
+
/*#__PURE__*/ _jsx("button", {
|
|
39
|
+
type: "button",
|
|
40
|
+
onClick: onPrevYear,
|
|
41
|
+
disabled: !canGoPrev,
|
|
42
|
+
className: cn(theme.header.button.base, theme.header.button.size, theme.header.button.color.light, theme.header.button.color.dark, theme.header.button.hover.light, theme.header.button.hover.dark, theme.header.button.rounded, theme.header.button.transition, !canGoPrev && "opacity-30 cursor-not-allowed"),
|
|
43
|
+
"aria-label": "Previous year",
|
|
44
|
+
children: /*#__PURE__*/ _jsxs("svg", {
|
|
45
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
46
|
+
viewBox: "0 0 24 24",
|
|
47
|
+
fill: "none",
|
|
48
|
+
stroke: "currentColor",
|
|
49
|
+
strokeWidth: "2",
|
|
50
|
+
strokeLinecap: "round",
|
|
51
|
+
strokeLinejoin: "round",
|
|
52
|
+
className: "w-4 h-4",
|
|
53
|
+
"aria-hidden": "true",
|
|
54
|
+
children: [
|
|
55
|
+
/*#__PURE__*/ _jsx("polyline", {
|
|
56
|
+
points: "11 17 6 12 11 7"
|
|
57
|
+
}),
|
|
58
|
+
/*#__PURE__*/ _jsx("polyline", {
|
|
59
|
+
points: "18 17 13 12 18 7"
|
|
60
|
+
})
|
|
61
|
+
]
|
|
62
|
+
})
|
|
63
|
+
}),
|
|
64
|
+
/*#__PURE__*/ _jsx("button", {
|
|
65
|
+
type: "button",
|
|
66
|
+
onClick: onPrevMonth,
|
|
67
|
+
disabled: !canGoPrev,
|
|
68
|
+
className: cn(theme.header.button.base, theme.header.button.size, theme.header.button.color.light, theme.header.button.color.dark, theme.header.button.hover.light, theme.header.button.hover.dark, theme.header.button.rounded, theme.header.button.transition, !canGoPrev && "opacity-30 cursor-not-allowed"),
|
|
69
|
+
"aria-label": "Previous month",
|
|
70
|
+
children: /*#__PURE__*/ _jsx("svg", {
|
|
71
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
72
|
+
viewBox: "0 0 24 24",
|
|
73
|
+
fill: "none",
|
|
74
|
+
stroke: "currentColor",
|
|
75
|
+
strokeWidth: "2",
|
|
76
|
+
strokeLinecap: "round",
|
|
77
|
+
strokeLinejoin: "round",
|
|
78
|
+
className: "w-4 h-4",
|
|
79
|
+
"aria-hidden": "true",
|
|
80
|
+
children: /*#__PURE__*/ _jsx("polyline", {
|
|
81
|
+
points: "15 18 9 12 15 6"
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
]
|
|
86
|
+
}),
|
|
87
|
+
/*#__PURE__*/ _jsxs("button", {
|
|
88
|
+
ref: titleRef,
|
|
89
|
+
type: "button",
|
|
90
|
+
onClick: onMonthYearClick,
|
|
91
|
+
className: cn(theme.header.title.base, theme.header.title.text.size, theme.header.title.text.weight, theme.header.title.text.color.light, theme.header.title.text.color.dark, theme.header.title.hover.light, theme.header.title.hover.dark, theme.header.title.rounded, theme.header.title.padding, theme.header.title.transition),
|
|
92
|
+
children: [
|
|
93
|
+
monthName,
|
|
94
|
+
" ",
|
|
95
|
+
year
|
|
96
|
+
]
|
|
97
|
+
}),
|
|
98
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
99
|
+
className: "flex items-center gap-1",
|
|
100
|
+
children: [
|
|
101
|
+
/*#__PURE__*/ _jsx("button", {
|
|
102
|
+
type: "button",
|
|
103
|
+
onClick: onNextMonth,
|
|
104
|
+
disabled: !canGoNext,
|
|
105
|
+
className: cn(theme.header.button.base, theme.header.button.size, theme.header.button.color.light, theme.header.button.color.dark, theme.header.button.hover.light, theme.header.button.hover.dark, theme.header.button.rounded, theme.header.button.transition, !canGoNext && "opacity-30 cursor-not-allowed"),
|
|
106
|
+
"aria-label": "Next month",
|
|
107
|
+
children: /*#__PURE__*/ _jsx("svg", {
|
|
108
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
109
|
+
viewBox: "0 0 24 24",
|
|
110
|
+
fill: "none",
|
|
111
|
+
stroke: "currentColor",
|
|
112
|
+
strokeWidth: "2",
|
|
113
|
+
strokeLinecap: "round",
|
|
114
|
+
strokeLinejoin: "round",
|
|
115
|
+
className: "w-4 h-4",
|
|
116
|
+
"aria-hidden": "true",
|
|
117
|
+
children: /*#__PURE__*/ _jsx("polyline", {
|
|
118
|
+
points: "9 18 15 12 9 6"
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
}),
|
|
122
|
+
/*#__PURE__*/ _jsx("button", {
|
|
123
|
+
type: "button",
|
|
124
|
+
onClick: onNextYear,
|
|
125
|
+
disabled: !canGoNext,
|
|
126
|
+
className: cn(theme.header.button.base, theme.header.button.size, theme.header.button.color.light, theme.header.button.color.dark, theme.header.button.hover.light, theme.header.button.hover.dark, theme.header.button.rounded, theme.header.button.transition, !canGoNext && "opacity-30 cursor-not-allowed"),
|
|
127
|
+
"aria-label": "Next year",
|
|
128
|
+
children: /*#__PURE__*/ _jsxs("svg", {
|
|
129
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
130
|
+
viewBox: "0 0 24 24",
|
|
131
|
+
fill: "none",
|
|
132
|
+
stroke: "currentColor",
|
|
133
|
+
strokeWidth: "2",
|
|
134
|
+
strokeLinecap: "round",
|
|
135
|
+
strokeLinejoin: "round",
|
|
136
|
+
className: "w-4 h-4",
|
|
137
|
+
"aria-hidden": "true",
|
|
138
|
+
children: [
|
|
139
|
+
/*#__PURE__*/ _jsx("polyline", {
|
|
140
|
+
points: "6 17 11 12 6 7"
|
|
141
|
+
}),
|
|
142
|
+
/*#__PURE__*/ _jsx("polyline", {
|
|
143
|
+
points: "13 17 18 12 13 7"
|
|
144
|
+
})
|
|
145
|
+
]
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
]
|
|
149
|
+
})
|
|
150
|
+
]
|
|
151
|
+
});
|
|
152
|
+
}
|