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.
Files changed (203) hide show
  1. package/dist/client.js +1 -1
  2. package/dist/fe/components/AbstractAnimatedBackground/index.js +437 -0
  3. package/dist/fe/components/AuthorizationPage/components/AuthorizationPage.js +841 -0
  4. package/dist/fe/components/AuthorizationPage/components/ClaimList.js +100 -0
  5. package/dist/fe/components/AuthorizationPage/components/RoleClaimEditor.js +232 -0
  6. package/dist/fe/components/AuthorizationPage/components/RoleList.js +115 -0
  7. package/dist/fe/components/AuthorizationPage/index.js +6 -0
  8. package/dist/fe/components/AuthorizationPage/store/index.js +117 -0
  9. package/dist/fe/components/AuthorizationPage/theme/index.js +137 -0
  10. package/dist/fe/components/AuthorizationPage/types/index.js +1 -0
  11. package/dist/fe/components/Button/components/Button.js +158 -0
  12. package/dist/fe/components/Button/components/ButtonSpinner.js +52 -0
  13. package/dist/fe/components/Button/index.js +3 -0
  14. package/dist/fe/components/Button/theme/index.js +186 -0
  15. package/dist/fe/components/Button/types/index.js +1 -0
  16. package/dist/fe/components/Button/utils/cn.js +5 -0
  17. package/dist/fe/components/Captcha/components/Captcha.js +311 -0
  18. package/dist/fe/components/Captcha/index.js +2 -0
  19. package/dist/fe/components/Captcha/theme.js +52 -0
  20. package/dist/fe/components/Captcha/types.js +1 -0
  21. package/dist/fe/components/ChangePasswordPage/components/ChangePasswordForm.js +242 -0
  22. package/dist/fe/components/ChangePasswordPage/components/ChangePasswordHeader.js +39 -0
  23. package/dist/fe/components/ChangePasswordPage/components/ChangePasswordPage.js +60 -0
  24. package/dist/fe/components/ChangePasswordPage/index.js +5 -0
  25. package/dist/fe/components/ChangePasswordPage/store/index.js +44 -0
  26. package/dist/fe/components/ChangePasswordPage/theme/index.js +87 -0
  27. package/dist/fe/components/ChangePasswordPage/types/index.js +1 -0
  28. package/dist/fe/components/Checkbox/components/Checkbox.js +115 -0
  29. package/dist/fe/components/Checkbox/components/CheckboxIcon.js +119 -0
  30. package/dist/fe/components/Checkbox/components/SwitchTrack.js +178 -0
  31. package/dist/fe/components/Checkbox/index.js +4 -0
  32. package/dist/fe/components/Checkbox/theme/index.js +221 -0
  33. package/dist/fe/components/Checkbox/types/index.js +1 -0
  34. package/dist/fe/components/Checkbox/utils/cn.js +5 -0
  35. package/dist/fe/components/DataTable/DataTable.js +225 -0
  36. package/dist/fe/components/DataTable/components/ActionCell.js +26 -0
  37. package/dist/fe/components/DataTable/components/DataCell.js +76 -0
  38. package/dist/fe/components/DataTable/components/EditableCell.js +221 -0
  39. package/dist/fe/components/DataTable/components/EmptyState.js +29 -0
  40. package/dist/fe/components/DataTable/components/HeaderCell.js +64 -0
  41. package/dist/fe/components/DataTable/components/InfiniteScrollTrigger.js +66 -0
  42. package/dist/fe/components/DataTable/components/LoadingSpinner.js +19 -0
  43. package/dist/fe/components/DataTable/components/ResizeHandle.js +41 -0
  44. package/dist/fe/components/DataTable/components/SelectionCell.js +105 -0
  45. package/dist/fe/components/DataTable/components/SkeletonRow.js +56 -0
  46. package/dist/fe/components/DataTable/components/SkeletonTable.js +83 -0
  47. package/dist/fe/components/DataTable/components/SortIcon.js +39 -0
  48. package/dist/fe/components/DataTable/components/TableHeader.js +49 -0
  49. package/dist/fe/components/DataTable/components/TableRow.js +118 -0
  50. package/dist/fe/components/DataTable/components/index.js +14 -0
  51. package/dist/fe/components/DataTable/hooks/index.js +2 -0
  52. package/dist/fe/components/DataTable/hooks/useAutoFitColumn.js +23 -0
  53. package/dist/fe/components/DataTable/hooks/useResizeColumn.js +122 -0
  54. package/dist/fe/components/DataTable/index.js +3 -0
  55. package/dist/fe/components/DataTable/store/index.js +97 -0
  56. package/dist/fe/components/DataTable/theme/index.js +144 -0
  57. package/dist/fe/components/DataTable/types/index.js +1 -0
  58. package/dist/fe/components/DataTable/utils/cn.js +5 -0
  59. package/dist/fe/components/DatePicker/components/CalendarGrid.js +95 -0
  60. package/dist/fe/components/DatePicker/components/CalendarHeader.js +152 -0
  61. package/dist/fe/components/DatePicker/components/DatePicker.js +381 -0
  62. package/dist/fe/components/DatePicker/components/MonthYearSelector.js +93 -0
  63. package/dist/fe/components/DatePicker/index.js +7 -0
  64. package/dist/fe/components/DatePicker/locales/index.js +1113 -0
  65. package/dist/fe/components/DatePicker/theme/index.js +315 -0
  66. package/dist/fe/components/DatePicker/types/index.js +1 -0
  67. package/dist/fe/components/DatePicker/utils/cn.js +5 -0
  68. package/dist/fe/components/DatePicker/utils/date.js +132 -0
  69. package/dist/fe/components/DevicesPage/components/DeviceCard.js +251 -0
  70. package/dist/fe/components/DevicesPage/components/DevicesHeader.js +42 -0
  71. package/dist/fe/components/DevicesPage/components/DevicesPage.js +450 -0
  72. package/dist/fe/components/DevicesPage/index.js +5 -0
  73. package/dist/fe/components/DevicesPage/store/index.js +55 -0
  74. package/dist/fe/components/DevicesPage/theme/index.js +131 -0
  75. package/dist/fe/components/DevicesPage/types/index.js +1 -0
  76. package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordForm.js +214 -0
  77. package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordHeader.js +42 -0
  78. package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordPage.js +59 -0
  79. package/dist/fe/components/ForgotPasswordPage/index.js +5 -0
  80. package/dist/fe/components/ForgotPasswordPage/store/index.js +28 -0
  81. package/dist/fe/components/ForgotPasswordPage/theme/index.js +87 -0
  82. package/dist/fe/components/ForgotPasswordPage/types/index.js +1 -0
  83. package/dist/fe/components/FormBuilder/components/FormBuilder.js +156 -0
  84. package/dist/fe/components/FormBuilder/components/FormField.js +218 -0
  85. package/dist/fe/components/FormBuilder/hooks/useFormBuilder.js +152 -0
  86. package/dist/fe/components/FormBuilder/index.js +4 -0
  87. package/dist/fe/components/FormBuilder/theme/index.js +134 -0
  88. package/dist/fe/components/FormBuilder/types/index.js +1 -0
  89. package/dist/fe/components/FormBuilder/utils/cn.js +5 -0
  90. package/dist/fe/components/FormBuilder/utils/fieldMapping.js +216 -0
  91. package/dist/fe/components/FormBuilder/utils/validation.js +78 -0
  92. package/dist/fe/components/LoginPage/components/LoginForm.js +214 -0
  93. package/dist/fe/components/LoginPage/components/LoginHeader.js +24 -0
  94. package/dist/fe/components/LoginPage/components/LoginPage.js +138 -0
  95. package/dist/fe/components/LoginPage/index.js +5 -0
  96. package/dist/fe/components/LoginPage/store/index.js +59 -0
  97. package/dist/fe/components/LoginPage/theme/index.js +98 -0
  98. package/dist/fe/components/LoginPage/types/index.js +1 -0
  99. package/dist/fe/components/MagicLinkVerifyPage/components/MagicLinkVerifyPage.js +200 -0
  100. package/dist/fe/components/MagicLinkVerifyPage/index.js +3 -0
  101. package/dist/fe/components/MagicLinkVerifyPage/store.js +20 -0
  102. package/dist/fe/components/MagicLinkVerifyPage/theme.js +36 -0
  103. package/dist/fe/components/MagicLinkVerifyPage/types.js +1 -0
  104. package/dist/fe/components/NucleusEntityShowcase.js +1409 -0
  105. package/dist/fe/components/NucleusTextInput/components/FloatingLabel.js +56 -0
  106. package/dist/fe/components/NucleusTextInput/components/InputIcons.js +258 -0
  107. package/dist/fe/components/NucleusTextInput/components/NucleusTextInput.js +321 -0
  108. package/dist/fe/components/NucleusTextInput/components/PasswordStrengthIndicator.js +104 -0
  109. package/dist/fe/components/NucleusTextInput/components/TypewriterText.js +56 -0
  110. package/dist/fe/components/NucleusTextInput/index.js +7 -0
  111. package/dist/fe/components/NucleusTextInput/theme/index.js +121 -0
  112. package/dist/fe/components/NucleusTextInput/types/index.js +1 -0
  113. package/dist/fe/components/NucleusTextInput/utils/cn.js +5 -0
  114. package/dist/fe/components/NucleusTextInput/utils/format.js +62 -0
  115. package/dist/fe/components/NucleusTextInput/utils/validation.js +191 -0
  116. package/dist/fe/components/ProfilePage/components/AddressCard.js +196 -0
  117. package/dist/fe/components/ProfilePage/components/PhoneCard.js +206 -0
  118. package/dist/fe/components/ProfilePage/components/ProfileHeader.js +150 -0
  119. package/dist/fe/components/ProfilePage/components/ProfilePage.js +1336 -0
  120. package/dist/fe/components/ProfilePage/index.js +6 -0
  121. package/dist/fe/components/ProfilePage/store/index.js +115 -0
  122. package/dist/fe/components/ProfilePage/theme/index.js +168 -0
  123. package/dist/fe/components/ProfilePage/types/index.js +1 -0
  124. package/dist/fe/components/RangePicker/components/RangePicker.js +338 -0
  125. package/dist/fe/components/RangePicker/components/RangeThumb.js +68 -0
  126. package/dist/fe/components/RangePicker/components/RangeTooltip.js +45 -0
  127. package/dist/fe/components/RangePicker/components/RangeTrack.js +32 -0
  128. package/dist/fe/components/RangePicker/index.js +5 -0
  129. package/dist/fe/components/RangePicker/theme/index.js +88 -0
  130. package/dist/fe/components/RangePicker/types/index.js +1 -0
  131. package/dist/fe/components/RangePicker/utils/cn.js +3 -0
  132. package/dist/fe/components/RegisterPage/components/PasswordStrengthIndicator.js +107 -0
  133. package/dist/fe/components/RegisterPage/components/RegisterForm.js +322 -0
  134. package/dist/fe/components/RegisterPage/components/RegisterHeader.js +23 -0
  135. package/dist/fe/components/RegisterPage/components/RegisterPage.js +85 -0
  136. package/dist/fe/components/RegisterPage/index.js +6 -0
  137. package/dist/fe/components/RegisterPage/store/index.js +106 -0
  138. package/dist/fe/components/RegisterPage/theme/index.js +128 -0
  139. package/dist/fe/components/RegisterPage/types/index.js +1 -0
  140. package/dist/fe/components/ResetPasswordPage/components/ResetPasswordForm.js +347 -0
  141. package/dist/fe/components/ResetPasswordPage/components/ResetPasswordHeader.js +42 -0
  142. package/dist/fe/components/ResetPasswordPage/components/ResetPasswordPage.js +61 -0
  143. package/dist/fe/components/ResetPasswordPage/index.js +5 -0
  144. package/dist/fe/components/ResetPasswordPage/store/index.js +36 -0
  145. package/dist/fe/components/ResetPasswordPage/theme/index.js +99 -0
  146. package/dist/fe/components/ResetPasswordPage/types/index.js +1 -0
  147. package/dist/fe/components/SearchBox/components/SearchBox.js +271 -0
  148. package/dist/fe/components/SearchBox/components/SearchBoxDropdown.js +87 -0
  149. package/dist/fe/components/SearchBox/index.js +5 -0
  150. package/dist/fe/components/SearchBox/theme/index.js +184 -0
  151. package/dist/fe/components/SearchBox/types/index.js +1 -0
  152. package/dist/fe/components/SearchBox/utils/cn.js +5 -0
  153. package/dist/fe/components/SearchBox/utils/debounce.js +22 -0
  154. package/dist/fe/components/SearchBox/utils/sanitize.js +48 -0
  155. package/dist/fe/components/SelectBox/components/SelectBox.js +364 -0
  156. package/dist/fe/components/SelectBox/components/SelectDropdown.js +92 -0
  157. package/dist/fe/components/SelectBox/components/SelectOptionItem.js +43 -0
  158. package/dist/fe/components/SelectBox/components/SelectTrigger.js +22 -0
  159. package/dist/fe/components/SelectBox/index.js +5 -0
  160. package/dist/fe/components/SelectBox/theme/index.js +98 -0
  161. package/dist/fe/components/SelectBox/types/index.js +1 -0
  162. package/dist/fe/components/SelectBox/utils/cn.js +3 -0
  163. package/dist/fe/components/SetPasswordPage/components/PasswordStrengthIndicator.js +107 -0
  164. package/dist/fe/components/SetPasswordPage/components/SetPasswordForm.js +142 -0
  165. package/dist/fe/components/SetPasswordPage/components/SetPasswordHeader.js +23 -0
  166. package/dist/fe/components/SetPasswordPage/components/SetPasswordPage.js +263 -0
  167. package/dist/fe/components/SetPasswordPage/index.js +7 -0
  168. package/dist/fe/components/SetPasswordPage/store/index.js +79 -0
  169. package/dist/fe/components/SetPasswordPage/theme/index.js +98 -0
  170. package/dist/fe/components/SetPasswordPage/types/index.js +12 -0
  171. package/dist/fe/components/UsersPage/components/InviteUserModal.js +262 -0
  172. package/dist/fe/components/UsersPage/components/Pagination.js +147 -0
  173. package/dist/fe/components/UsersPage/components/RoleAssignmentModal.js +186 -0
  174. package/dist/fe/components/UsersPage/components/StatsCards.js +124 -0
  175. package/dist/fe/components/UsersPage/components/UserDetailDrawer.js +444 -0
  176. package/dist/fe/components/UsersPage/components/UserFilters.js +142 -0
  177. package/dist/fe/components/UsersPage/components/UserListItem.js +125 -0
  178. package/dist/fe/components/UsersPage/components/UserListSkeleton.js +40 -0
  179. package/dist/fe/components/UsersPage/components/UsersPage.js +556 -0
  180. package/dist/fe/components/UsersPage/index.js +10 -0
  181. package/dist/fe/components/UsersPage/store/index.js +151 -0
  182. package/dist/fe/components/UsersPage/theme/index.js +231 -0
  183. package/dist/fe/components/UsersPage/types/index.js +1 -0
  184. package/dist/fe/components/VerifyEmailPage/components/VerifyEmailPage.js +290 -0
  185. package/dist/fe/components/VerifyEmailPage/index.js +3 -0
  186. package/dist/fe/components/VerifyEmailPage/store/index.js +45 -0
  187. package/dist/fe/components/VerifyEmailPage/theme/index.js +52 -0
  188. package/dist/fe/components/VerifyEmailPage/types/index.js +1 -0
  189. package/dist/fe/hooks/useNucleusEntity.js +247 -0
  190. package/dist/fe/index.js +28 -157
  191. package/dist/fe/types/index.js +1 -0
  192. package/dist/fe/utils/cn.js +5 -0
  193. package/dist/fe/utils/columnUtils.js +189 -0
  194. package/dist/fe/utils/endpointKeys.js +44 -0
  195. package/dist/index.js +1 -1
  196. package/dist/src/Client/Proxy/httpProxy.js +1 -0
  197. package/dist/src/Client/Proxy/index.js +1 -1
  198. package/dist/src/Client/Proxy/server.js +1 -0
  199. package/dist/src/Client/Proxy/types.js +1 -0
  200. package/dist/src/Client/Proxy/utils.js +1 -0
  201. package/dist/src/Client/Proxy/wsProxy.js +1 -0
  202. package/package.json +1 -1
  203. package/scripts/build.ts +32 -16
@@ -0,0 +1,60 @@
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 { cn } from "../../../utils/cn";
7
+ import { AbstractAnimatedBackground } from "../../AbstractAnimatedBackground";
8
+ import { changePasswordPageTheme } from "../theme";
9
+ import { ChangePasswordForm } from "./ChangePasswordForm";
10
+ import { ChangePasswordHeader } from "./ChangePasswordHeader";
11
+ gsap.registerPlugin(useGSAP);
12
+ export function ChangePasswordPage({ logo, title = "Change Password", subtitle = "Enter your current password and choose a new one.", changePasswordAction, onSuccess, onCancel, cancelHref, showBackground = true, className }) {
13
+ const theme = changePasswordPageTheme;
14
+ const containerRef = useRef(null);
15
+ const cardRef = useRef(null);
16
+ useGSAP(()=>{
17
+ if (!cardRef.current) return;
18
+ gsap.fromTo(cardRef.current, {
19
+ opacity: 0,
20
+ y: 30,
21
+ scale: 0.95
22
+ }, {
23
+ opacity: 1,
24
+ y: 0,
25
+ scale: 1,
26
+ duration: 0.6,
27
+ ease: "power3.out"
28
+ });
29
+ }, {
30
+ scope: containerRef
31
+ });
32
+ return /*#__PURE__*/ _jsxs("main", {
33
+ ref: containerRef,
34
+ className: cn(theme.container.base, className),
35
+ "aria-label": "Change password page",
36
+ children: [
37
+ showBackground && /*#__PURE__*/ _jsx(AbstractAnimatedBackground, {}),
38
+ /*#__PURE__*/ _jsx("div", {
39
+ className: theme.container.wrapper,
40
+ children: /*#__PURE__*/ _jsxs("article", {
41
+ ref: cardRef,
42
+ className: cn(theme.card.base, theme.card.padding, theme.card.background, theme.card.border, theme.card.shadow, theme.card.rounded),
43
+ children: [
44
+ /*#__PURE__*/ _jsx(ChangePasswordHeader, {
45
+ logo: logo,
46
+ title: title,
47
+ subtitle: subtitle
48
+ }),
49
+ /*#__PURE__*/ _jsx(ChangePasswordForm, {
50
+ changePasswordAction: changePasswordAction,
51
+ onSuccess: onSuccess,
52
+ onCancel: onCancel,
53
+ cancelHref: cancelHref
54
+ })
55
+ ]
56
+ })
57
+ })
58
+ ]
59
+ });
60
+ }
@@ -0,0 +1,5 @@
1
+ export { ChangePasswordForm } from "./components/ChangePasswordForm";
2
+ export { ChangePasswordHeader } from "./components/ChangePasswordHeader";
3
+ export { ChangePasswordPage } from "./components/ChangePasswordPage";
4
+ export { useChangePasswordStore } from "./store";
5
+ export { changePasswordPageTheme, extendChangePasswordPageTheme } from "./theme";
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ import { batch, createStore } from "h-state";
3
+ const initialState = {
4
+ currentPassword: "",
5
+ newPassword: "",
6
+ confirmPassword: "",
7
+ step: "form",
8
+ error: null
9
+ };
10
+ export const { useStore: useChangePasswordStore } = createStore(initialState, {
11
+ setCurrentPassword: (store)=>(password)=>{
12
+ store.currentPassword = password;
13
+ if (store.error) {
14
+ store.error = null;
15
+ }
16
+ },
17
+ setNewPassword: (store)=>(password)=>{
18
+ store.newPassword = password;
19
+ if (store.error) {
20
+ store.error = null;
21
+ }
22
+ },
23
+ setConfirmPassword: (store)=>(password)=>{
24
+ store.confirmPassword = password;
25
+ if (store.error) {
26
+ store.error = null;
27
+ }
28
+ },
29
+ setStep: (store)=>(step)=>{
30
+ store.step = step;
31
+ },
32
+ setError: (store)=>(error)=>{
33
+ store.error = error;
34
+ },
35
+ reset: (store)=>()=>{
36
+ batch(()=>{
37
+ store.currentPassword = "";
38
+ store.newPassword = "";
39
+ store.confirmPassword = "";
40
+ store.step = "form";
41
+ store.error = null;
42
+ });
43
+ }
44
+ });
@@ -0,0 +1,87 @@
1
+ export const changePasswordPageTheme = {
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
+ iconWrapper: "mb-4 w-16 h-16 rounded-full bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center",
18
+ title: "text-2xl sm:text-3xl font-bold text-zinc-900 dark:text-white text-center",
19
+ subtitle: "mt-2 text-sm sm:text-base text-zinc-600 dark:text-zinc-400 text-center max-w-sm"
20
+ },
21
+ form: {
22
+ container: "w-full",
23
+ spacing: "space-y-4"
24
+ },
25
+ input: {
26
+ wrapper: "w-full"
27
+ },
28
+ button: {
29
+ wrapper: "mt-6"
30
+ },
31
+ links: {
32
+ container: "mt-6 text-center",
33
+ cancel: "text-sm text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-white font-medium transition-colors cursor-pointer inline-flex items-center gap-1"
34
+ },
35
+ error: {
36
+ container: "mb-4 p-3 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800",
37
+ text: "text-sm text-red-600 dark:text-red-400 text-center"
38
+ },
39
+ success: {
40
+ container: "flex flex-col items-center text-center",
41
+ iconWrapper: "mb-4 w-16 h-16 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",
42
+ title: "text-xl font-semibold text-zinc-900 dark:text-white mb-2",
43
+ message: "text-sm text-zinc-600 dark:text-zinc-400 max-w-sm"
44
+ }
45
+ };
46
+ export function extendChangePasswordPageTheme(overrides) {
47
+ return {
48
+ ...changePasswordPageTheme,
49
+ ...overrides,
50
+ container: {
51
+ ...changePasswordPageTheme.container,
52
+ ...overrides.container
53
+ },
54
+ card: {
55
+ ...changePasswordPageTheme.card,
56
+ ...overrides.card
57
+ },
58
+ header: {
59
+ ...changePasswordPageTheme.header,
60
+ ...overrides.header
61
+ },
62
+ form: {
63
+ ...changePasswordPageTheme.form,
64
+ ...overrides.form
65
+ },
66
+ input: {
67
+ ...changePasswordPageTheme.input,
68
+ ...overrides.input
69
+ },
70
+ button: {
71
+ ...changePasswordPageTheme.button,
72
+ ...overrides.button
73
+ },
74
+ links: {
75
+ ...changePasswordPageTheme.links,
76
+ ...overrides.links
77
+ },
78
+ error: {
79
+ ...changePasswordPageTheme.error,
80
+ ...overrides.error
81
+ },
82
+ success: {
83
+ ...changePasswordPageTheme.success,
84
+ ...overrides.success
85
+ }
86
+ };
87
+ }
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,115 @@
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 { useId, useRef } from "react";
6
+ import { checkboxTheme } from "../theme";
7
+ import { cn } from "../utils/cn";
8
+ import { CheckboxIcon } from "./CheckboxIcon";
9
+ import { SwitchTrack } from "./SwitchTrack";
10
+ gsap.registerPlugin(useGSAP);
11
+ export function Checkbox({ checked, onChange, variant = "checkbox", size = "md", color = "primary", label, labelPosition = "right", disabled = false, indeterminate = false, name, value, id, required = false, errorMessage, helperText, className, labelClassName, ariaLabel, ariaDescribedBy }) {
12
+ const containerRef = useRef(null);
13
+ const inputRef = useRef(null);
14
+ const wrapperRef = useRef(null);
15
+ const generatedId = useId();
16
+ const inputId = id || generatedId;
17
+ const theme = checkboxTheme;
18
+ const { contextSafe } = useGSAP({
19
+ scope: containerRef
20
+ });
21
+ const handleChange = contextSafe(()=>{
22
+ if (disabled) return;
23
+ if (wrapperRef.current) {
24
+ gsap.to(wrapperRef.current, {
25
+ scale: 0.97,
26
+ duration: 0.1,
27
+ ease: "power2.out",
28
+ onComplete: ()=>{
29
+ gsap.to(wrapperRef.current, {
30
+ scale: 1,
31
+ duration: 0.15,
32
+ ease: "elastic.out(1, 0.5)"
33
+ });
34
+ }
35
+ });
36
+ }
37
+ onChange(!checked);
38
+ });
39
+ const handleKeyDown = (e)=>{
40
+ if (e.key === " " || e.key === "Enter") {
41
+ e.preventDefault();
42
+ handleChange();
43
+ }
44
+ };
45
+ const renderControl = ()=>{
46
+ if (variant === "switch") {
47
+ return /*#__PURE__*/ _jsx(SwitchTrack, {
48
+ checked: checked,
49
+ size: size,
50
+ color: color,
51
+ disabled: disabled
52
+ });
53
+ }
54
+ return /*#__PURE__*/ _jsx(CheckboxIcon, {
55
+ checked: checked,
56
+ indeterminate: indeterminate,
57
+ size: size,
58
+ color: color,
59
+ disabled: disabled
60
+ });
61
+ };
62
+ const renderLabel = ()=>{
63
+ if (!label) return null;
64
+ return /*#__PURE__*/ _jsxs("span", {
65
+ className: cn(theme.label.base, theme.label.text.size[size], theme.label.text.color.light, theme.label.text.color.dark, disabled && theme.label.disabled, labelClassName),
66
+ children: [
67
+ label,
68
+ required && /*#__PURE__*/ _jsx("span", {
69
+ className: "text-red-500 ml-0.5",
70
+ children: "*"
71
+ })
72
+ ]
73
+ });
74
+ };
75
+ return /*#__PURE__*/ _jsxs("div", {
76
+ ref: containerRef,
77
+ className: cn(theme.container.base, theme.container.spacing, disabled && theme.container.disabled, className),
78
+ children: [
79
+ /*#__PURE__*/ _jsxs("label", {
80
+ ref: wrapperRef,
81
+ htmlFor: inputId,
82
+ className: cn(theme.wrapper.base, theme.wrapper.gap[size], disabled && "cursor-not-allowed", labelPosition === "left" && "flex-row-reverse"),
83
+ onKeyDown: handleKeyDown,
84
+ children: [
85
+ /*#__PURE__*/ _jsx("input", {
86
+ ref: inputRef,
87
+ type: "checkbox",
88
+ id: inputId,
89
+ name: name,
90
+ value: value,
91
+ checked: checked,
92
+ disabled: disabled,
93
+ required: required,
94
+ onChange: handleChange,
95
+ className: "sr-only",
96
+ "aria-label": ariaLabel || (typeof label === "string" ? label : undefined),
97
+ "aria-describedby": ariaDescribedBy,
98
+ "aria-checked": indeterminate ? "mixed" : checked,
99
+ "aria-invalid": !!errorMessage
100
+ }),
101
+ renderControl(),
102
+ renderLabel()
103
+ ]
104
+ }),
105
+ errorMessage && /*#__PURE__*/ _jsx("span", {
106
+ className: cn(theme.errorText.base, theme.errorText.text, theme.errorText.color),
107
+ children: errorMessage
108
+ }),
109
+ helperText && !errorMessage && /*#__PURE__*/ _jsx("span", {
110
+ className: cn(theme.helperText.base, theme.helperText.text, theme.helperText.color.light, theme.helperText.color.dark),
111
+ children: helperText
112
+ })
113
+ ]
114
+ });
115
+ }
@@ -0,0 +1,119 @@
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 { checkboxTheme } from "../theme";
7
+ import { cn } from "../utils/cn";
8
+ gsap.registerPlugin(useGSAP);
9
+ export function CheckboxIcon({ checked, indeterminate = false, size, color, disabled = false }) {
10
+ const containerRef = useRef(null);
11
+ const checkRef = useRef(null);
12
+ const indeterminateRef = useRef(null);
13
+ const rippleRef = useRef(null);
14
+ const theme = checkboxTheme;
15
+ useGSAP(()=>{
16
+ if (!containerRef.current) return;
17
+ const tl = gsap.timeline();
18
+ if (checked && !indeterminate) {
19
+ tl.to(containerRef.current, {
20
+ borderColor: "transparent",
21
+ duration: 0.15,
22
+ ease: "power2.out"
23
+ });
24
+ if (checkRef.current) {
25
+ const pathLength = checkRef.current.getTotalLength();
26
+ gsap.set(checkRef.current, {
27
+ strokeDasharray: pathLength,
28
+ strokeDashoffset: pathLength
29
+ });
30
+ tl.to(checkRef.current, {
31
+ strokeDashoffset: 0,
32
+ duration: 0.3,
33
+ ease: "power3.out"
34
+ }, "-=0.1");
35
+ }
36
+ if (rippleRef.current) {
37
+ tl.fromTo(rippleRef.current, {
38
+ scale: 0,
39
+ opacity: 0.6
40
+ }, {
41
+ scale: 2.5,
42
+ opacity: 0,
43
+ duration: 0.5,
44
+ ease: "power2.out"
45
+ }, "-=0.3");
46
+ }
47
+ } else if (indeterminate) {
48
+ tl.to(containerRef.current, {
49
+ borderColor: "transparent",
50
+ duration: 0.15,
51
+ ease: "power2.out"
52
+ });
53
+ if (indeterminateRef.current) {
54
+ tl.fromTo(indeterminateRef.current, {
55
+ scaleX: 0,
56
+ opacity: 0
57
+ }, {
58
+ scaleX: 1,
59
+ opacity: 1,
60
+ duration: 0.25,
61
+ ease: "back.out(2)"
62
+ }, "-=0.1");
63
+ }
64
+ } else {
65
+ if (checkRef.current) {
66
+ const pathLength = checkRef.current.getTotalLength();
67
+ tl.to(checkRef.current, {
68
+ strokeDashoffset: pathLength,
69
+ duration: 0.2,
70
+ ease: "power2.in"
71
+ });
72
+ }
73
+ if (indeterminateRef.current) {
74
+ tl.to(indeterminateRef.current, {
75
+ scaleX: 0,
76
+ opacity: 0,
77
+ duration: 0.15,
78
+ ease: "power2.in"
79
+ }, "<");
80
+ }
81
+ tl.to(containerRef.current, {
82
+ borderColor: "",
83
+ duration: 0.15,
84
+ ease: "power2.out"
85
+ }, "-=0.1");
86
+ }
87
+ }, [
88
+ checked,
89
+ indeterminate
90
+ ]);
91
+ return /*#__PURE__*/ _jsxs("div", {
92
+ ref: containerRef,
93
+ className: cn(theme.checkbox.base, theme.checkbox.size[size], theme.checkbox.border.base, theme.checkbox.rounded, theme.checkbox.shadow, theme.checkbox.transition, !checked && !indeterminate && theme.checkbox.border.color.light, !checked && !indeterminate && theme.checkbox.border.color.dark, !checked && !indeterminate && theme.checkbox.background.unchecked.light, !checked && !indeterminate && theme.checkbox.background.unchecked.dark, (checked || indeterminate) && theme.checkbox.background.checked[color], (checked || indeterminate) && "border-transparent", disabled && theme.checkbox.disabled.opacity, disabled && theme.checkbox.disabled.cursor),
94
+ children: [
95
+ /*#__PURE__*/ _jsx("div", {
96
+ ref: rippleRef,
97
+ className: cn(theme.ripple.base, theme.ripple.color[color])
98
+ }),
99
+ /*#__PURE__*/ _jsx("svg", {
100
+ viewBox: "0 0 24 24",
101
+ fill: "none",
102
+ className: cn(theme.checkIcon.base, theme.checkIcon.size[size], "opacity-0", checked && !indeterminate && "opacity-100"),
103
+ "aria-hidden": "true",
104
+ children: /*#__PURE__*/ _jsx("path", {
105
+ ref: checkRef,
106
+ d: "M4 12.5L9.5 18L20 6",
107
+ strokeLinecap: "round",
108
+ strokeLinejoin: "round",
109
+ className: cn(theme.checkIcon.stroke.width, theme.checkIcon.stroke.color),
110
+ fill: "none"
111
+ })
112
+ }),
113
+ /*#__PURE__*/ _jsx("div", {
114
+ ref: indeterminateRef,
115
+ className: cn(theme.indeterminateIcon.base, theme.indeterminateIcon.size[size].width, theme.indeterminateIcon.size[size].height, theme.indeterminateIcon.background, theme.indeterminateIcon.rounded, "opacity-0 scale-x-0", indeterminate && "opacity-100")
116
+ })
117
+ ]
118
+ });
119
+ }
@@ -0,0 +1,178 @@
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 { checkboxTheme } from "../theme";
7
+ import { cn } from "../utils/cn";
8
+ gsap.registerPlugin(useGSAP);
9
+ export function SwitchTrack({ checked, size, color, disabled = false }) {
10
+ const trackRef = useRef(null);
11
+ const thumbRef = useRef(null);
12
+ const checkIconRef = useRef(null);
13
+ const crossIconRef = useRef(null);
14
+ const glowRef = useRef(null);
15
+ const theme = checkboxTheme;
16
+ const getThumbPosition = (isChecked)=>{
17
+ const positions = {
18
+ sm: {
19
+ unchecked: 2,
20
+ checked: 18
21
+ },
22
+ md: {
23
+ unchecked: 2,
24
+ checked: 24
25
+ },
26
+ lg: {
27
+ unchecked: 2,
28
+ checked: 30
29
+ }
30
+ };
31
+ return positions[size][isChecked ? "checked" : "unchecked"];
32
+ };
33
+ useGSAP(()=>{
34
+ if (!thumbRef.current || !trackRef.current) return;
35
+ const tl = gsap.timeline();
36
+ if (checked) {
37
+ tl.to(thumbRef.current, {
38
+ x: getThumbPosition(true),
39
+ duration: 0.35,
40
+ ease: "elastic.out(1, 0.75)"
41
+ });
42
+ tl.to(thumbRef.current, {
43
+ scale: 1.1,
44
+ duration: 0.15,
45
+ ease: "power2.out"
46
+ }, "<");
47
+ tl.to(thumbRef.current, {
48
+ scale: 1,
49
+ duration: 0.2,
50
+ ease: "power2.inOut"
51
+ });
52
+ if (checkIconRef.current) {
53
+ tl.fromTo(checkIconRef.current, {
54
+ scale: 0,
55
+ rotate: -180,
56
+ opacity: 0
57
+ }, {
58
+ scale: 1,
59
+ rotate: 0,
60
+ opacity: 1,
61
+ duration: 0.3,
62
+ ease: "back.out(2)"
63
+ }, "-=0.4");
64
+ }
65
+ if (crossIconRef.current) {
66
+ tl.to(crossIconRef.current, {
67
+ scale: 0,
68
+ rotate: 90,
69
+ opacity: 0,
70
+ duration: 0.2,
71
+ ease: "power2.in"
72
+ }, "<-0.2");
73
+ }
74
+ if (glowRef.current) {
75
+ tl.fromTo(glowRef.current, {
76
+ opacity: 0,
77
+ scale: 0.8
78
+ }, {
79
+ opacity: 0.6,
80
+ scale: 1,
81
+ duration: 0.3,
82
+ ease: "power2.out"
83
+ }, "-=0.3").to(glowRef.current, {
84
+ opacity: 0,
85
+ duration: 0.5,
86
+ ease: "power2.inOut"
87
+ });
88
+ }
89
+ } else {
90
+ tl.to(thumbRef.current, {
91
+ x: getThumbPosition(false),
92
+ duration: 0.35,
93
+ ease: "elastic.out(1, 0.75)"
94
+ });
95
+ tl.to(thumbRef.current, {
96
+ scale: 0.9,
97
+ duration: 0.1,
98
+ ease: "power2.out"
99
+ }, "<");
100
+ tl.to(thumbRef.current, {
101
+ scale: 1,
102
+ duration: 0.15,
103
+ ease: "power2.inOut"
104
+ });
105
+ if (crossIconRef.current) {
106
+ tl.fromTo(crossIconRef.current, {
107
+ scale: 0,
108
+ rotate: -90,
109
+ opacity: 0
110
+ }, {
111
+ scale: 1,
112
+ rotate: 0,
113
+ opacity: 1,
114
+ duration: 0.25,
115
+ ease: "back.out(1.5)"
116
+ }, "-=0.35");
117
+ }
118
+ if (checkIconRef.current) {
119
+ tl.to(checkIconRef.current, {
120
+ scale: 0,
121
+ rotate: 180,
122
+ opacity: 0,
123
+ duration: 0.2,
124
+ ease: "power2.in"
125
+ }, "<-0.15");
126
+ }
127
+ }
128
+ }, [
129
+ checked,
130
+ size
131
+ ]);
132
+ return /*#__PURE__*/ _jsxs("div", {
133
+ ref: trackRef,
134
+ className: cn(theme.switch.track.base, theme.switch.track.size[size].width, theme.switch.track.size[size].height, theme.switch.track.rounded, theme.switch.track.shadow, theme.switch.track.transition, !checked && theme.switch.track.background.unchecked.light, !checked && theme.switch.track.background.unchecked.dark, checked && theme.switch.track.background.checked[color], disabled && theme.switch.track.disabled.opacity, disabled && theme.switch.track.disabled.cursor),
135
+ children: [
136
+ /*#__PURE__*/ _jsx("div", {
137
+ ref: glowRef,
138
+ className: cn("absolute inset-0 rounded-full blur-md opacity-0", checked && theme.switch.track.background.checked[color])
139
+ }),
140
+ /*#__PURE__*/ _jsxs("div", {
141
+ ref: thumbRef,
142
+ className: cn(theme.switch.thumb.base, theme.switch.thumb.size[size], theme.switch.thumb.background.light, theme.switch.thumb.shadow, theme.switch.thumb.rounded, "transform-gpu"),
143
+ style: {
144
+ x: getThumbPosition(checked)
145
+ },
146
+ children: [
147
+ /*#__PURE__*/ _jsx("svg", {
148
+ ref: checkIconRef,
149
+ viewBox: "0 0 24 24",
150
+ fill: "none",
151
+ className: cn(theme.switch.icon.base, theme.switch.icon.size[size], "text-emerald-500", "opacity-0"),
152
+ "aria-hidden": "true",
153
+ children: /*#__PURE__*/ _jsx("path", {
154
+ d: "M5 13l4 4L19 7",
155
+ stroke: "currentColor",
156
+ strokeWidth: "3",
157
+ strokeLinecap: "round",
158
+ strokeLinejoin: "round"
159
+ })
160
+ }),
161
+ /*#__PURE__*/ _jsx("svg", {
162
+ ref: crossIconRef,
163
+ viewBox: "0 0 24 24",
164
+ fill: "none",
165
+ className: cn(theme.switch.icon.base, theme.switch.icon.size[size], theme.switch.icon.color.unchecked.light, "opacity-100"),
166
+ "aria-hidden": "true",
167
+ children: /*#__PURE__*/ _jsx("path", {
168
+ d: "M6 6l12 12M6 18L18 6",
169
+ stroke: "currentColor",
170
+ strokeWidth: "2.5",
171
+ strokeLinecap: "round"
172
+ })
173
+ })
174
+ ]
175
+ })
176
+ ]
177
+ });
178
+ }
@@ -0,0 +1,4 @@
1
+ export { Checkbox } from "./components/Checkbox";
2
+ export { CheckboxIcon } from "./components/CheckboxIcon";
3
+ export { SwitchTrack } from "./components/SwitchTrack";
4
+ export { checkboxTheme, extendCheckboxTheme } from "./theme";