nucleus-core-ts 0.8.7 → 0.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) 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/nucleus.config.d.ts +2 -0
  197. package/dist/src/Client/ApiCaller/client.js +1 -0
  198. package/dist/src/Client/ApiCaller/examples/usage.example.js +1 -0
  199. package/dist/src/Client/ApiCaller/generator.js +1 -0
  200. package/dist/src/Client/ApiCaller/index.js +1 -0
  201. package/dist/src/Client/ApiCaller/server.js +1 -0
  202. package/dist/src/Client/ApiCaller/system-tables.js +1 -0
  203. package/dist/src/Client/ApiCaller/types.js +1 -0
  204. package/dist/src/Client/Proxy/httpProxy.js +1 -0
  205. package/dist/src/Client/Proxy/index.js +1 -1
  206. package/dist/src/Client/Proxy/server.js +1 -0
  207. package/dist/src/Client/Proxy/types.js +1 -0
  208. package/dist/src/Client/Proxy/utils.js +1 -0
  209. package/dist/src/Client/Proxy/wsProxy.js +1 -0
  210. package/dist/src/Client/ServerFetch/index.js +1 -0
  211. package/dist/src/Client/ServerFetch/types.js +1 -0
  212. package/dist/src/Client/index.js +1 -0
  213. package/package.json +1 -1
  214. package/scripts/build.ts +41 -16
@@ -0,0 +1,104 @@
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
+ gsap.registerPlugin(useGSAP);
8
+ function calculateStrength(password) {
9
+ let score = 0;
10
+ if (!password) {
11
+ return {
12
+ level: "weak",
13
+ score: 0,
14
+ label: "",
15
+ color: "bg-gray-200"
16
+ };
17
+ }
18
+ if (password.length >= 8) score += 1;
19
+ if (password.length >= 12) score += 1;
20
+ if (password.length >= 16) score += 1;
21
+ if (/[a-z]/.test(password)) score += 1;
22
+ if (/[A-Z]/.test(password)) score += 1;
23
+ if (/[0-9]/.test(password)) score += 1;
24
+ if (/[^a-zA-Z0-9]/.test(password)) score += 1;
25
+ if (/(.)\1{2,}/.test(password)) score -= 1;
26
+ if (/^[a-zA-Z]+$/.test(password)) score -= 1;
27
+ if (/^[0-9]+$/.test(password)) score -= 1;
28
+ score = Math.max(0, Math.min(score, 7));
29
+ if (score <= 2) {
30
+ return {
31
+ level: "weak",
32
+ score,
33
+ label: "Weak",
34
+ color: "bg-red-500"
35
+ };
36
+ }
37
+ if (score <= 4) {
38
+ return {
39
+ level: "fair",
40
+ score,
41
+ label: "Fair",
42
+ color: "bg-orange-500"
43
+ };
44
+ }
45
+ if (score <= 5) {
46
+ return {
47
+ level: "good",
48
+ score,
49
+ label: "Good",
50
+ color: "bg-yellow-500"
51
+ };
52
+ }
53
+ return {
54
+ level: "strong",
55
+ score,
56
+ label: "Strong",
57
+ color: "bg-green-500"
58
+ };
59
+ }
60
+ export function PasswordStrengthIndicator({ password, className }) {
61
+ const barRef = useRef(null);
62
+ const strength = calculateStrength(password);
63
+ const percentage = password ? Math.min(strength.score / 7 * 100, 100) : 0;
64
+ useGSAP(()=>{
65
+ if (!barRef.current) return;
66
+ gsap.to(barRef.current, {
67
+ width: `${percentage}%`,
68
+ duration: 0.3,
69
+ ease: "power2.out"
70
+ });
71
+ }, [
72
+ percentage
73
+ ]);
74
+ if (!password) return null;
75
+ return /*#__PURE__*/ _jsxs("div", {
76
+ className: cn("mt-2 mb-4", className),
77
+ children: [
78
+ /*#__PURE__*/ _jsxs("div", {
79
+ className: "flex items-center justify-between mb-1",
80
+ children: [
81
+ /*#__PURE__*/ _jsx("span", {
82
+ className: "text-xs text-gray-500 dark:text-gray-400",
83
+ children: "Password strength"
84
+ }),
85
+ /*#__PURE__*/ _jsx("span", {
86
+ className: cn("text-xs font-medium", strength.level === "weak" && "text-red-500", strength.level === "fair" && "text-orange-500", strength.level === "good" && "text-yellow-600", strength.level === "strong" && "text-green-500"),
87
+ children: strength.label
88
+ })
89
+ ]
90
+ }),
91
+ /*#__PURE__*/ _jsx("div", {
92
+ className: "h-1.5 w-full bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",
93
+ children: /*#__PURE__*/ _jsx("div", {
94
+ ref: barRef,
95
+ className: cn("h-full rounded-full transition-colors duration-300", strength.color),
96
+ style: {
97
+ width: 0
98
+ }
99
+ })
100
+ })
101
+ ]
102
+ });
103
+ }
104
+ export { calculateStrength };
@@ -0,0 +1,56 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useGSAP } from "@gsap/react";
4
+ import gsap from "gsap";
5
+ import { TextPlugin } from "gsap/TextPlugin";
6
+ import { useEffect, useRef } from "react";
7
+ import { nucleusTextInputTheme } from "../theme";
8
+ import { cn } from "../utils/cn";
9
+ gsap.registerPlugin(useGSAP, TextPlugin);
10
+ export function TypewriterText({ text, className, onComplete }) {
11
+ const textRef = useRef(null);
12
+ const previousText = useRef("");
13
+ const theme = nucleusTextInputTheme.errorText;
14
+ const animConfig = nucleusTextInputTheme.animation.typewriter;
15
+ useGSAP(()=>{
16
+ if (!textRef.current || !text) {
17
+ if (textRef.current) {
18
+ textRef.current.textContent = "";
19
+ }
20
+ previousText.current = "";
21
+ return;
22
+ }
23
+ if (text === previousText.current) return;
24
+ gsap.killTweensOf(textRef.current);
25
+ textRef.current.textContent = "";
26
+ const duration = text.length * animConfig.charDelay;
27
+ gsap.to(textRef.current, {
28
+ duration,
29
+ text: {
30
+ value: text,
31
+ delimiter: ""
32
+ },
33
+ ease: animConfig.ease,
34
+ onComplete: ()=>{
35
+ previousText.current = text;
36
+ onComplete?.();
37
+ }
38
+ });
39
+ }, [
40
+ text
41
+ ]);
42
+ useEffect(()=>{
43
+ return ()=>{
44
+ if (textRef.current) {
45
+ gsap.killTweensOf(textRef.current);
46
+ }
47
+ };
48
+ }, []);
49
+ if (!text) return null;
50
+ return /*#__PURE__*/ _jsx("span", {
51
+ ref: textRef,
52
+ className: cn(theme.base, theme.text, theme.color, className),
53
+ role: "alert",
54
+ "aria-live": "polite"
55
+ });
56
+ }
@@ -0,0 +1,7 @@
1
+ export { FloatingLabel } from "./components/FloatingLabel";
2
+ export { NucleusTextInput } from "./components/NucleusTextInput";
3
+ export { calculateStrength, PasswordStrengthIndicator } from "./components/PasswordStrengthIndicator";
4
+ export { TypewriterText } from "./components/TypewriterText";
5
+ export { extendNucleusTextInputTheme, nucleusTextInputTheme } from "./theme";
6
+ export { formatNumberWithSeparator, formatPhoneNumber, parseFormattedNumber, unformatNumber, unformatPhone } from "./utils/format";
7
+ export { defaultValidators, getAutoCompleteForType, getInputModeForType, validateWithConfig } from "./utils/validation";
@@ -0,0 +1,121 @@
1
+ export const nucleusTextInputTheme = {
2
+ container: {
3
+ base: "relative w-full",
4
+ spacing: "mb-1"
5
+ },
6
+ wrapper: {
7
+ base: "relative flex items-center",
8
+ border: {
9
+ base: "border rounded-lg",
10
+ width: "border",
11
+ radius: "rounded-lg"
12
+ },
13
+ padding: "px-4 py-3",
14
+ transition: "transition-all duration-200 ease-out",
15
+ states: {
16
+ inactive: "border-gray-300 dark:border-gray-600",
17
+ hover: "border-gray-400 dark:border-gray-500",
18
+ focused: "border-blue-600 dark:border-blue-500",
19
+ error: "border-red-500 dark:border-red-400",
20
+ disabled: "border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50"
21
+ }
22
+ },
23
+ input: {
24
+ base: "w-full bg-transparent outline-none",
25
+ text: "text-base",
26
+ color: "text-gray-900 dark:text-gray-100",
27
+ placeholder: "placeholder:text-gray-400 dark:placeholder:text-gray-500",
28
+ disabled: "text-gray-400 dark:text-gray-500 cursor-not-allowed",
29
+ transition: "transition-colors duration-200"
30
+ },
31
+ label: {
32
+ base: "absolute pointer-events-none select-none",
33
+ text: "text-base",
34
+ transition: "transition-all duration-200 ease-out",
35
+ states: {
36
+ inactive: {
37
+ position: "left-3 top-1/2 -translate-y-1/2",
38
+ text: "text-base",
39
+ color: "text-gray-500 dark:text-gray-400",
40
+ background: "bg-transparent px-1"
41
+ },
42
+ floated: {
43
+ position: "left-3 -top-2.5 translate-y-0",
44
+ text: "text-xs",
45
+ color: "text-gray-600 dark:text-gray-300",
46
+ background: "bg-white/50 dark:bg-gray-900/50 px-1"
47
+ },
48
+ focused: {
49
+ color: "text-blue-600 dark:text-blue-500"
50
+ },
51
+ error: {
52
+ color: "text-red-500 dark:text-red-400"
53
+ },
54
+ disabled: {
55
+ color: "text-gray-400 dark:text-gray-500"
56
+ }
57
+ }
58
+ },
59
+ helperText: {
60
+ base: "mt-1.5 ml-1",
61
+ text: "text-xs",
62
+ color: "text-gray-500 dark:text-gray-400",
63
+ disabled: "text-gray-400 dark:text-gray-500"
64
+ },
65
+ errorText: {
66
+ base: "mt-1.5 ml-1",
67
+ text: "text-xs",
68
+ color: "text-red-500 dark:text-red-400",
69
+ minHeight: "min-h-[1.25rem]"
70
+ },
71
+ icon: {
72
+ base: "flex-shrink-0",
73
+ size: "w-5 h-5",
74
+ color: "text-gray-400 dark:text-gray-500",
75
+ spacing: {
76
+ left: "mr-2",
77
+ right: "ml-2"
78
+ },
79
+ states: {
80
+ focused: "text-blue-600 dark:text-blue-500",
81
+ error: "text-red-500 dark:text-red-400",
82
+ disabled: "text-gray-300 dark:text-gray-600"
83
+ }
84
+ },
85
+ animation: {
86
+ label: {
87
+ duration: 0.35,
88
+ ease: "power3.out",
89
+ floatY: -24,
90
+ floatScale: 0.75
91
+ },
92
+ typewriter: {
93
+ charDelay: 0.03,
94
+ ease: "none"
95
+ },
96
+ border: {
97
+ duration: 0.2,
98
+ ease: "power2.out"
99
+ }
100
+ }
101
+ };
102
+ export function extendNucleusTextInputTheme(overrides) {
103
+ return deepMerge(nucleusTextInputTheme, overrides);
104
+ }
105
+ function deepMerge(target, source) {
106
+ const output = {
107
+ ...target
108
+ };
109
+ for(const key in source){
110
+ if (Object.hasOwn(source, key)) {
111
+ const sourceValue = source[key];
112
+ const targetValue = target[key];
113
+ if (sourceValue !== undefined && typeof sourceValue === "object" && sourceValue !== null && !Array.isArray(sourceValue) && typeof targetValue === "object" && targetValue !== null && !Array.isArray(targetValue)) {
114
+ output[key] = deepMerge(targetValue, sourceValue);
115
+ } else if (sourceValue !== undefined) {
116
+ output[key] = sourceValue;
117
+ }
118
+ }
119
+ }
120
+ return output;
121
+ }
@@ -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,62 @@
1
+ export function formatNumberWithSeparator(value, separator = " ") {
2
+ const digitsOnly = value.replace(/\D/g, "");
3
+ if (!digitsOnly) return "";
4
+ return digitsOnly.replace(/\B(?=(\d{3})+(?!\d))/g, separator);
5
+ }
6
+ export function unformatNumber(value) {
7
+ return value.replace(/\D/g, "");
8
+ }
9
+ export function parseFormattedNumber(value) {
10
+ const digitsOnly = value.replace(/\D/g, "");
11
+ return digitsOnly ? Number.parseInt(digitsOnly, 10) : 0;
12
+ }
13
+ const PHONE_FORMATS = {
14
+ tr: {
15
+ pattern: [
16
+ 3,
17
+ 3,
18
+ 2,
19
+ 2
20
+ ],
21
+ prefix: ""
22
+ },
23
+ us: {
24
+ pattern: [
25
+ 3,
26
+ 3,
27
+ 4
28
+ ],
29
+ prefix: ""
30
+ },
31
+ eu: {
32
+ pattern: [
33
+ 2,
34
+ 3,
35
+ 3,
36
+ 2
37
+ ],
38
+ prefix: ""
39
+ }
40
+ };
41
+ export function formatPhoneNumber(value, format = "tr") {
42
+ const digitsOnly = value.replace(/\D/g, "");
43
+ if (!digitsOnly) return "";
44
+ const { pattern } = PHONE_FORMATS[format];
45
+ const parts = [];
46
+ let remaining = digitsOnly;
47
+ for (const groupSize of pattern){
48
+ if (remaining.length === 0) break;
49
+ parts.push(remaining.slice(0, groupSize));
50
+ remaining = remaining.slice(groupSize);
51
+ }
52
+ if (remaining.length > 0) {
53
+ parts.push(remaining);
54
+ }
55
+ return parts.join(" ");
56
+ }
57
+ export function unformatPhone(value) {
58
+ return value.replace(/\D/g, "");
59
+ }
60
+ export function getPhoneFormatPattern(format) {
61
+ return PHONE_FORMATS[format].pattern;
62
+ }
@@ -0,0 +1,191 @@
1
+ const EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
2
+ const URL_REGEX = /^(https?:\/\/)?([\da-z-]+\.)+[a-z]{2,6}(\/[^\s]*)?$/i;
3
+ const PHONE_REGEX = /^[+]?[(]?[0-9]{1,4}[)]?[-\s./0-9]{6,}$/;
4
+ const PASSWORD_RULES = {
5
+ minLength: 8,
6
+ hasUppercase: /[A-Z]/,
7
+ hasLowercase: /[a-z]/,
8
+ hasNumber: /[0-9]/,
9
+ hasSpecial: /[!@#$%^&*(),.?":{}|<>]/
10
+ };
11
+ export const defaultValidators = {
12
+ text: (value)=>{
13
+ if (!value.trim()) {
14
+ return {
15
+ isValid: true
16
+ };
17
+ }
18
+ return {
19
+ isValid: true
20
+ };
21
+ },
22
+ email: (value)=>{
23
+ if (!value.trim()) {
24
+ return {
25
+ isValid: true
26
+ };
27
+ }
28
+ if (!EMAIL_REGEX.test(value)) {
29
+ return {
30
+ isValid: false,
31
+ errorMessage: "Please enter a valid email address"
32
+ };
33
+ }
34
+ return {
35
+ isValid: true
36
+ };
37
+ },
38
+ password: (value)=>{
39
+ if (!value) {
40
+ return {
41
+ isValid: true
42
+ };
43
+ }
44
+ const errors = [];
45
+ if (value.length < PASSWORD_RULES.minLength) {
46
+ errors.push(`at least ${PASSWORD_RULES.minLength} characters`);
47
+ }
48
+ if (!PASSWORD_RULES.hasUppercase.test(value)) {
49
+ errors.push("one uppercase letter");
50
+ }
51
+ if (!PASSWORD_RULES.hasLowercase.test(value)) {
52
+ errors.push("one lowercase letter");
53
+ }
54
+ if (!PASSWORD_RULES.hasNumber.test(value)) {
55
+ errors.push("one number");
56
+ }
57
+ if (!PASSWORD_RULES.hasSpecial.test(value)) {
58
+ errors.push("one special character");
59
+ }
60
+ if (errors.length > 0) {
61
+ return {
62
+ isValid: false,
63
+ errorMessage: `Password must contain ${errors.join(", ")}`
64
+ };
65
+ }
66
+ return {
67
+ isValid: true
68
+ };
69
+ },
70
+ number: (value)=>{
71
+ if (!value.trim()) {
72
+ return {
73
+ isValid: true
74
+ };
75
+ }
76
+ const num = Number(value);
77
+ if (Number.isNaN(num)) {
78
+ return {
79
+ isValid: false,
80
+ errorMessage: "Please enter a valid number"
81
+ };
82
+ }
83
+ return {
84
+ isValid: true
85
+ };
86
+ },
87
+ tel: (value)=>{
88
+ if (!value.trim()) {
89
+ return {
90
+ isValid: true
91
+ };
92
+ }
93
+ const digitsOnly = value.replace(/\D/g, "");
94
+ if (digitsOnly.length < 7) {
95
+ return {
96
+ isValid: false,
97
+ errorMessage: "Phone number must have at least 7 digits"
98
+ };
99
+ }
100
+ if (!PHONE_REGEX.test(value)) {
101
+ return {
102
+ isValid: false,
103
+ errorMessage: "Please enter a valid phone number"
104
+ };
105
+ }
106
+ return {
107
+ isValid: true
108
+ };
109
+ },
110
+ url: (value)=>{
111
+ if (!value.trim()) {
112
+ return {
113
+ isValid: true
114
+ };
115
+ }
116
+ if (!URL_REGEX.test(value)) {
117
+ return {
118
+ isValid: false,
119
+ errorMessage: "Please enter a valid URL"
120
+ };
121
+ }
122
+ return {
123
+ isValid: true
124
+ };
125
+ }
126
+ };
127
+ export function validateWithConfig(value, inputType, config) {
128
+ if (config?.required && !value.trim()) {
129
+ return {
130
+ isValid: false,
131
+ errorMessage: config.requiredMessage || "This field is required"
132
+ };
133
+ }
134
+ if (config?.minLength && value.length < config.minLength) {
135
+ return {
136
+ isValid: false,
137
+ errorMessage: `Minimum ${config.minLength} characters required`
138
+ };
139
+ }
140
+ if (config?.maxLength && value.length > config.maxLength) {
141
+ return {
142
+ isValid: false,
143
+ errorMessage: `Maximum ${config.maxLength} characters allowed`
144
+ };
145
+ }
146
+ if (config?.pattern && !config.pattern.test(value)) {
147
+ return {
148
+ isValid: false,
149
+ errorMessage: config.patternMessage || "Invalid format"
150
+ };
151
+ }
152
+ if (config?.customRules) {
153
+ for (const rule of config.customRules){
154
+ if (!rule.validate(value)) {
155
+ return {
156
+ isValid: false,
157
+ errorMessage: rule.message
158
+ };
159
+ }
160
+ }
161
+ }
162
+ return defaultValidators[inputType](value);
163
+ }
164
+ export function getInputModeForType(inputType) {
165
+ switch(inputType){
166
+ case "email":
167
+ return "email";
168
+ case "number":
169
+ return "numeric";
170
+ case "tel":
171
+ return "tel";
172
+ case "url":
173
+ return "url";
174
+ default:
175
+ return "text";
176
+ }
177
+ }
178
+ export function getAutoCompleteForType(inputType, isNewPassword) {
179
+ switch(inputType){
180
+ case "email":
181
+ return "email";
182
+ case "password":
183
+ return isNewPassword ? "new-password" : "current-password";
184
+ case "tel":
185
+ return "tel";
186
+ case "url":
187
+ return "url";
188
+ default:
189
+ return "off";
190
+ }
191
+ }