nucleus-core-ts 0.8.6 → 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.
Files changed (209) hide show
  1. package/dist/client.js +1 -1
  2. package/dist/dist/index.d.ts +475 -12
  3. package/dist/fe/components/AbstractAnimatedBackground/index.js +437 -0
  4. package/dist/fe/components/AuthorizationPage/components/AuthorizationPage.js +841 -0
  5. package/dist/fe/components/AuthorizationPage/components/ClaimList.js +100 -0
  6. package/dist/fe/components/AuthorizationPage/components/RoleClaimEditor.js +232 -0
  7. package/dist/fe/components/AuthorizationPage/components/RoleList.js +115 -0
  8. package/dist/fe/components/AuthorizationPage/index.js +6 -0
  9. package/dist/fe/components/AuthorizationPage/store/index.js +117 -0
  10. package/dist/fe/components/AuthorizationPage/theme/index.js +137 -0
  11. package/dist/fe/components/AuthorizationPage/types/index.js +1 -0
  12. package/dist/fe/components/Button/components/Button.js +158 -0
  13. package/dist/fe/components/Button/components/ButtonSpinner.js +52 -0
  14. package/dist/fe/components/Button/index.js +3 -0
  15. package/dist/fe/components/Button/theme/index.js +186 -0
  16. package/dist/fe/components/Button/types/index.js +1 -0
  17. package/dist/fe/components/Button/utils/cn.js +5 -0
  18. package/dist/fe/components/Captcha/components/Captcha.js +311 -0
  19. package/dist/fe/components/Captcha/index.js +2 -0
  20. package/dist/fe/components/Captcha/theme.js +52 -0
  21. package/dist/fe/components/Captcha/types.js +1 -0
  22. package/dist/fe/components/ChangePasswordPage/components/ChangePasswordForm.js +242 -0
  23. package/dist/fe/components/ChangePasswordPage/components/ChangePasswordHeader.js +39 -0
  24. package/dist/fe/components/ChangePasswordPage/components/ChangePasswordPage.js +60 -0
  25. package/dist/fe/components/ChangePasswordPage/index.js +5 -0
  26. package/dist/fe/components/ChangePasswordPage/store/index.js +44 -0
  27. package/dist/fe/components/ChangePasswordPage/theme/index.js +87 -0
  28. package/dist/fe/components/ChangePasswordPage/types/index.js +1 -0
  29. package/dist/fe/components/Checkbox/components/Checkbox.js +115 -0
  30. package/dist/fe/components/Checkbox/components/CheckboxIcon.js +119 -0
  31. package/dist/fe/components/Checkbox/components/SwitchTrack.js +178 -0
  32. package/dist/fe/components/Checkbox/index.js +4 -0
  33. package/dist/fe/components/Checkbox/theme/index.js +221 -0
  34. package/dist/fe/components/Checkbox/types/index.js +1 -0
  35. package/dist/fe/components/Checkbox/utils/cn.js +5 -0
  36. package/dist/fe/components/DataTable/DataTable.js +225 -0
  37. package/dist/fe/components/DataTable/components/ActionCell.js +26 -0
  38. package/dist/fe/components/DataTable/components/DataCell.js +76 -0
  39. package/dist/fe/components/DataTable/components/EditableCell.js +221 -0
  40. package/dist/fe/components/DataTable/components/EmptyState.js +29 -0
  41. package/dist/fe/components/DataTable/components/HeaderCell.js +64 -0
  42. package/dist/fe/components/DataTable/components/InfiniteScrollTrigger.js +66 -0
  43. package/dist/fe/components/DataTable/components/LoadingSpinner.js +19 -0
  44. package/dist/fe/components/DataTable/components/ResizeHandle.js +41 -0
  45. package/dist/fe/components/DataTable/components/SelectionCell.js +105 -0
  46. package/dist/fe/components/DataTable/components/SkeletonRow.js +56 -0
  47. package/dist/fe/components/DataTable/components/SkeletonTable.js +83 -0
  48. package/dist/fe/components/DataTable/components/SortIcon.js +39 -0
  49. package/dist/fe/components/DataTable/components/TableHeader.js +49 -0
  50. package/dist/fe/components/DataTable/components/TableRow.js +118 -0
  51. package/dist/fe/components/DataTable/components/index.js +14 -0
  52. package/dist/fe/components/DataTable/hooks/index.js +2 -0
  53. package/dist/fe/components/DataTable/hooks/useAutoFitColumn.js +23 -0
  54. package/dist/fe/components/DataTable/hooks/useResizeColumn.js +122 -0
  55. package/dist/fe/components/DataTable/index.js +3 -0
  56. package/dist/fe/components/DataTable/store/index.js +97 -0
  57. package/dist/fe/components/DataTable/theme/index.js +144 -0
  58. package/dist/fe/components/DataTable/types/index.js +1 -0
  59. package/dist/fe/components/DataTable/utils/cn.js +5 -0
  60. package/dist/fe/components/DatePicker/components/CalendarGrid.js +95 -0
  61. package/dist/fe/components/DatePicker/components/CalendarHeader.js +152 -0
  62. package/dist/fe/components/DatePicker/components/DatePicker.js +381 -0
  63. package/dist/fe/components/DatePicker/components/MonthYearSelector.js +93 -0
  64. package/dist/fe/components/DatePicker/index.js +7 -0
  65. package/dist/fe/components/DatePicker/locales/index.js +1113 -0
  66. package/dist/fe/components/DatePicker/theme/index.js +315 -0
  67. package/dist/fe/components/DatePicker/types/index.js +1 -0
  68. package/dist/fe/components/DatePicker/utils/cn.js +5 -0
  69. package/dist/fe/components/DatePicker/utils/date.js +132 -0
  70. package/dist/fe/components/DevicesPage/components/DeviceCard.js +251 -0
  71. package/dist/fe/components/DevicesPage/components/DevicesHeader.js +42 -0
  72. package/dist/fe/components/DevicesPage/components/DevicesPage.js +450 -0
  73. package/dist/fe/components/DevicesPage/index.js +5 -0
  74. package/dist/fe/components/DevicesPage/store/index.js +55 -0
  75. package/dist/fe/components/DevicesPage/theme/index.js +131 -0
  76. package/dist/fe/components/DevicesPage/types/index.js +1 -0
  77. package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordForm.js +214 -0
  78. package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordHeader.js +42 -0
  79. package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordPage.js +59 -0
  80. package/dist/fe/components/ForgotPasswordPage/index.js +5 -0
  81. package/dist/fe/components/ForgotPasswordPage/store/index.js +28 -0
  82. package/dist/fe/components/ForgotPasswordPage/theme/index.js +87 -0
  83. package/dist/fe/components/ForgotPasswordPage/types/index.js +1 -0
  84. package/dist/fe/components/FormBuilder/components/FormBuilder.js +156 -0
  85. package/dist/fe/components/FormBuilder/components/FormField.js +218 -0
  86. package/dist/fe/components/FormBuilder/hooks/useFormBuilder.js +152 -0
  87. package/dist/fe/components/FormBuilder/index.js +4 -0
  88. package/dist/fe/components/FormBuilder/theme/index.js +134 -0
  89. package/dist/fe/components/FormBuilder/types/index.js +1 -0
  90. package/dist/fe/components/FormBuilder/utils/cn.js +5 -0
  91. package/dist/fe/components/FormBuilder/utils/fieldMapping.js +216 -0
  92. package/dist/fe/components/FormBuilder/utils/validation.js +78 -0
  93. package/dist/fe/components/LoginPage/components/LoginForm.js +214 -0
  94. package/dist/fe/components/LoginPage/components/LoginHeader.js +24 -0
  95. package/dist/fe/components/LoginPage/components/LoginPage.js +138 -0
  96. package/dist/fe/components/LoginPage/index.js +5 -0
  97. package/dist/fe/components/LoginPage/store/index.js +59 -0
  98. package/dist/fe/components/LoginPage/theme/index.js +98 -0
  99. package/dist/fe/components/LoginPage/types/index.js +1 -0
  100. package/dist/fe/components/MagicLinkVerifyPage/components/MagicLinkVerifyPage.js +200 -0
  101. package/dist/fe/components/MagicLinkVerifyPage/index.js +3 -0
  102. package/dist/fe/components/MagicLinkVerifyPage/store.js +20 -0
  103. package/dist/fe/components/MagicLinkVerifyPage/theme.js +36 -0
  104. package/dist/fe/components/MagicLinkVerifyPage/types.js +1 -0
  105. package/dist/fe/components/NucleusEntityShowcase.js +1409 -0
  106. package/dist/fe/components/NucleusTextInput/components/FloatingLabel.js +56 -0
  107. package/dist/fe/components/NucleusTextInput/components/InputIcons.js +258 -0
  108. package/dist/fe/components/NucleusTextInput/components/NucleusTextInput.js +321 -0
  109. package/dist/fe/components/NucleusTextInput/components/PasswordStrengthIndicator.js +104 -0
  110. package/dist/fe/components/NucleusTextInput/components/TypewriterText.js +56 -0
  111. package/dist/fe/components/NucleusTextInput/index.js +7 -0
  112. package/dist/fe/components/NucleusTextInput/theme/index.js +121 -0
  113. package/dist/fe/components/NucleusTextInput/types/index.js +1 -0
  114. package/dist/fe/components/NucleusTextInput/utils/cn.js +5 -0
  115. package/dist/fe/components/NucleusTextInput/utils/format.js +62 -0
  116. package/dist/fe/components/NucleusTextInput/utils/validation.js +191 -0
  117. package/dist/fe/components/ProfilePage/components/AddressCard.js +196 -0
  118. package/dist/fe/components/ProfilePage/components/PhoneCard.js +206 -0
  119. package/dist/fe/components/ProfilePage/components/ProfileHeader.js +150 -0
  120. package/dist/fe/components/ProfilePage/components/ProfilePage.js +1336 -0
  121. package/dist/fe/components/ProfilePage/index.js +6 -0
  122. package/dist/fe/components/ProfilePage/store/index.js +115 -0
  123. package/dist/fe/components/ProfilePage/theme/index.js +168 -0
  124. package/dist/fe/components/ProfilePage/types/index.js +1 -0
  125. package/dist/fe/components/RangePicker/components/RangePicker.js +338 -0
  126. package/dist/fe/components/RangePicker/components/RangeThumb.js +68 -0
  127. package/dist/fe/components/RangePicker/components/RangeTooltip.js +45 -0
  128. package/dist/fe/components/RangePicker/components/RangeTrack.js +32 -0
  129. package/dist/fe/components/RangePicker/index.js +5 -0
  130. package/dist/fe/components/RangePicker/theme/index.js +88 -0
  131. package/dist/fe/components/RangePicker/types/index.js +1 -0
  132. package/dist/fe/components/RangePicker/utils/cn.js +3 -0
  133. package/dist/fe/components/RegisterPage/components/PasswordStrengthIndicator.js +107 -0
  134. package/dist/fe/components/RegisterPage/components/RegisterForm.js +322 -0
  135. package/dist/fe/components/RegisterPage/components/RegisterHeader.js +23 -0
  136. package/dist/fe/components/RegisterPage/components/RegisterPage.js +85 -0
  137. package/dist/fe/components/RegisterPage/index.js +6 -0
  138. package/dist/fe/components/RegisterPage/store/index.js +106 -0
  139. package/dist/fe/components/RegisterPage/theme/index.js +128 -0
  140. package/dist/fe/components/RegisterPage/types/index.js +1 -0
  141. package/dist/fe/components/ResetPasswordPage/components/ResetPasswordForm.js +347 -0
  142. package/dist/fe/components/ResetPasswordPage/components/ResetPasswordHeader.js +42 -0
  143. package/dist/fe/components/ResetPasswordPage/components/ResetPasswordPage.js +61 -0
  144. package/dist/fe/components/ResetPasswordPage/index.js +5 -0
  145. package/dist/fe/components/ResetPasswordPage/store/index.js +36 -0
  146. package/dist/fe/components/ResetPasswordPage/theme/index.js +99 -0
  147. package/dist/fe/components/ResetPasswordPage/types/index.js +1 -0
  148. package/dist/fe/components/SearchBox/components/SearchBox.js +271 -0
  149. package/dist/fe/components/SearchBox/components/SearchBoxDropdown.js +87 -0
  150. package/dist/fe/components/SearchBox/index.js +5 -0
  151. package/dist/fe/components/SearchBox/theme/index.js +184 -0
  152. package/dist/fe/components/SearchBox/types/index.js +1 -0
  153. package/dist/fe/components/SearchBox/utils/cn.js +5 -0
  154. package/dist/fe/components/SearchBox/utils/debounce.js +22 -0
  155. package/dist/fe/components/SearchBox/utils/sanitize.js +48 -0
  156. package/dist/fe/components/SelectBox/components/SelectBox.js +364 -0
  157. package/dist/fe/components/SelectBox/components/SelectDropdown.js +92 -0
  158. package/dist/fe/components/SelectBox/components/SelectOptionItem.js +43 -0
  159. package/dist/fe/components/SelectBox/components/SelectTrigger.js +22 -0
  160. package/dist/fe/components/SelectBox/index.js +5 -0
  161. package/dist/fe/components/SelectBox/theme/index.js +98 -0
  162. package/dist/fe/components/SelectBox/types/index.js +1 -0
  163. package/dist/fe/components/SelectBox/utils/cn.js +3 -0
  164. package/dist/fe/components/SetPasswordPage/components/PasswordStrengthIndicator.js +107 -0
  165. package/dist/fe/components/SetPasswordPage/components/SetPasswordForm.js +142 -0
  166. package/dist/fe/components/SetPasswordPage/components/SetPasswordHeader.js +23 -0
  167. package/dist/fe/components/SetPasswordPage/components/SetPasswordPage.js +263 -0
  168. package/dist/fe/components/SetPasswordPage/index.js +7 -0
  169. package/dist/fe/components/SetPasswordPage/store/index.js +79 -0
  170. package/dist/fe/components/SetPasswordPage/theme/index.js +98 -0
  171. package/dist/fe/components/SetPasswordPage/types/index.js +12 -0
  172. package/dist/fe/components/UsersPage/components/InviteUserModal.js +262 -0
  173. package/dist/fe/components/UsersPage/components/Pagination.js +147 -0
  174. package/dist/fe/components/UsersPage/components/RoleAssignmentModal.js +186 -0
  175. package/dist/fe/components/UsersPage/components/StatsCards.js +124 -0
  176. package/dist/fe/components/UsersPage/components/UserDetailDrawer.js +444 -0
  177. package/dist/fe/components/UsersPage/components/UserFilters.js +142 -0
  178. package/dist/fe/components/UsersPage/components/UserListItem.js +125 -0
  179. package/dist/fe/components/UsersPage/components/UserListSkeleton.js +40 -0
  180. package/dist/fe/components/UsersPage/components/UsersPage.js +556 -0
  181. package/dist/fe/components/UsersPage/index.js +10 -0
  182. package/dist/fe/components/UsersPage/store/index.js +151 -0
  183. package/dist/fe/components/UsersPage/theme/index.js +231 -0
  184. package/dist/fe/components/UsersPage/types/index.js +1 -0
  185. package/dist/fe/components/VerifyEmailPage/components/VerifyEmailPage.js +290 -0
  186. package/dist/fe/components/VerifyEmailPage/index.js +3 -0
  187. package/dist/fe/components/VerifyEmailPage/store/index.js +45 -0
  188. package/dist/fe/components/VerifyEmailPage/theme/index.js +52 -0
  189. package/dist/fe/components/VerifyEmailPage/types/index.js +1 -0
  190. package/dist/fe/hooks/useNucleusEntity.js +247 -0
  191. package/dist/fe/index.js +28 -110
  192. package/dist/fe/types/index.js +1 -0
  193. package/dist/fe/utils/cn.js +5 -0
  194. package/dist/fe/utils/columnUtils.js +189 -0
  195. package/dist/fe/utils/endpointKeys.js +44 -0
  196. package/dist/index.js +1 -1
  197. package/dist/nucleus.config.d.ts +3 -0
  198. package/dist/src/Client/Proxy/httpProxy.js +1 -0
  199. package/dist/src/Client/Proxy/index.js +1 -1
  200. package/dist/src/Client/Proxy/server.js +1 -0
  201. package/dist/src/Client/Proxy/types.js +1 -0
  202. package/dist/src/Client/Proxy/utils.js +1 -0
  203. package/dist/src/Client/Proxy/wsProxy.js +1 -0
  204. package/package.json +1 -1
  205. package/scripts/build.ts +78 -8
  206. package/dist/dist/index-0yyw12k6.d.ts +0 -8
  207. package/dist/dist/index-tv67j5qd.d.ts +0 -488
  208. package/dist/index-0yyw12k6.js +0 -1
  209. package/dist/index-tv67j5qd.js +0 -1
@@ -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,5 @@
1
+ import { clsx } from "clsx";
2
+ import { twMerge } from "tailwind-merge";
3
+ export function cn(...inputs) {
4
+ return twMerge(clsx(inputs));
5
+ }
@@ -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
+ }