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,216 @@
1
+ const COLUMN_TYPE_MAP = {
2
+ integer: {
3
+ inputType: "number"
4
+ },
5
+ smallint: {
6
+ inputType: "number"
7
+ },
8
+ bigint: {
9
+ inputType: "number"
10
+ },
11
+ serial: {
12
+ inputType: "number"
13
+ },
14
+ smallserial: {
15
+ inputType: "number"
16
+ },
17
+ bigserial: {
18
+ inputType: "number"
19
+ },
20
+ real: {
21
+ inputType: "number"
22
+ },
23
+ doublePrecision: {
24
+ inputType: "number"
25
+ },
26
+ numeric: {
27
+ inputType: "number"
28
+ },
29
+ decimal: {
30
+ inputType: "number"
31
+ },
32
+ text: {
33
+ inputType: "textarea"
34
+ },
35
+ varchar: {
36
+ inputType: "text"
37
+ },
38
+ char: {
39
+ inputType: "text"
40
+ },
41
+ uuid: {
42
+ inputType: "text",
43
+ validationType: "uuid"
44
+ },
45
+ boolean: {
46
+ inputType: "checkbox"
47
+ },
48
+ date: {
49
+ inputType: "date",
50
+ validationType: "date"
51
+ },
52
+ time: {
53
+ inputType: "time",
54
+ validationType: "time"
55
+ },
56
+ timestamp: {
57
+ inputType: "datetime",
58
+ validationType: "datetime"
59
+ },
60
+ timestamptz: {
61
+ inputType: "datetime",
62
+ validationType: "datetime"
63
+ },
64
+ interval: {
65
+ inputType: "text"
66
+ },
67
+ json: {
68
+ inputType: "json"
69
+ },
70
+ jsonb: {
71
+ inputType: "json"
72
+ },
73
+ bytea: {
74
+ inputType: "hidden"
75
+ },
76
+ inet: {
77
+ inputType: "text",
78
+ validationType: "ipv4"
79
+ },
80
+ cidr: {
81
+ inputType: "text"
82
+ },
83
+ macaddr: {
84
+ inputType: "text"
85
+ },
86
+ macaddr8: {
87
+ inputType: "text"
88
+ },
89
+ bit: {
90
+ inputType: "text"
91
+ },
92
+ bitVarying: {
93
+ inputType: "text"
94
+ },
95
+ point: {
96
+ inputType: "text"
97
+ },
98
+ line: {
99
+ inputType: "text"
100
+ },
101
+ lseg: {
102
+ inputType: "text"
103
+ },
104
+ box: {
105
+ inputType: "text"
106
+ },
107
+ path: {
108
+ inputType: "text"
109
+ },
110
+ polygon: {
111
+ inputType: "text"
112
+ },
113
+ circle: {
114
+ inputType: "text"
115
+ },
116
+ tsvector: {
117
+ inputType: "text"
118
+ },
119
+ tsquery: {
120
+ inputType: "text"
121
+ },
122
+ xml: {
123
+ inputType: "textarea"
124
+ },
125
+ money: {
126
+ inputType: "number"
127
+ },
128
+ vector: {
129
+ inputType: "hidden"
130
+ },
131
+ geometry: {
132
+ inputType: "hidden"
133
+ },
134
+ geography: {
135
+ inputType: "hidden"
136
+ },
137
+ customType: {
138
+ inputType: "text"
139
+ }
140
+ };
141
+ export function getFieldMapping(column) {
142
+ if (column.enumValues || column.enum) {
143
+ return {
144
+ inputType: "select"
145
+ };
146
+ }
147
+ if (column.references) {
148
+ return {
149
+ inputType: "select"
150
+ };
151
+ }
152
+ const mapping = COLUMN_TYPE_MAP[column.type];
153
+ if (column.validation?.format) {
154
+ return {
155
+ ...mapping,
156
+ validationType: column.validation.format
157
+ };
158
+ }
159
+ return mapping;
160
+ }
161
+ export function getInputTypeFromFormat(format) {
162
+ switch(format){
163
+ case "email":
164
+ return "text";
165
+ case "url":
166
+ case "uri":
167
+ return "text";
168
+ case "date":
169
+ return "date";
170
+ case "datetime":
171
+ return "datetime";
172
+ case "time":
173
+ return "time";
174
+ default:
175
+ return "text";
176
+ }
177
+ }
178
+ export function shouldExcludeField(column) {
179
+ if (column.primaryKey && column.type === "serial") return true;
180
+ if (column.primaryKey && column.type === "bigserial") return true;
181
+ if (column.primaryKey && column.type === "smallserial") return true;
182
+ if (column.generatedAlwaysAs) return true;
183
+ if (column.generatedAlwaysAsIdentity) return true;
184
+ const autoFields = [
185
+ "created_at",
186
+ "updated_at",
187
+ "deleted_at"
188
+ ];
189
+ if (autoFields.includes(column.name)) return true;
190
+ return false;
191
+ }
192
+ export function getDefaultValue(column) {
193
+ if (column.default !== undefined) {
194
+ return column.default;
195
+ }
196
+ const mapping = getFieldMapping(column);
197
+ switch(mapping.inputType){
198
+ case "number":
199
+ return column.nullable ? null : 0;
200
+ case "checkbox":
201
+ return false;
202
+ case "date":
203
+ case "datetime":
204
+ case "time":
205
+ return null;
206
+ case "select":
207
+ return column.nullable ? null : "";
208
+ case "json":
209
+ return column.nullable ? null : {};
210
+ default:
211
+ return "";
212
+ }
213
+ }
214
+ export function formatLabel(name) {
215
+ return name.replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (char)=>char.toUpperCase());
216
+ }
@@ -0,0 +1,78 @@
1
+ const FORMAT_PATTERNS = {
2
+ email: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
3
+ url: /^https?:\/\/[^\s]+$/,
4
+ uri: /^[a-zA-Z][a-zA-Z\d+\-.]*:/,
5
+ uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,
6
+ date: /^\d{4}-\d{2}-\d{2}$/,
7
+ datetime: /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?(\.\d+)?(Z|[+-]\d{2}:\d{2})?$/,
8
+ time: /^\d{2}:\d{2}(:\d{2})?$/,
9
+ ipv4: /^(\d{1,3}\.){3}\d{1,3}$/,
10
+ ipv6: /^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/
11
+ };
12
+ const FORMAT_MESSAGES = {
13
+ email: "Please enter a valid email address",
14
+ url: "Please enter a valid URL",
15
+ uri: "Please enter a valid URI",
16
+ uuid: "Please enter a valid UUID",
17
+ date: "Please enter a valid date (YYYY-MM-DD)",
18
+ datetime: "Please enter a valid datetime",
19
+ time: "Please enter a valid time (HH:MM)",
20
+ ipv4: "Please enter a valid IPv4 address",
21
+ ipv6: "Please enter a valid IPv6 address"
22
+ };
23
+ export function validateField(column, value, isRequired) {
24
+ const isEmpty = value === undefined || value === null || value === "";
25
+ if (isEmpty) {
26
+ if (isRequired || column.notNull) {
27
+ return column.validation?.customMessage || "This field is required";
28
+ }
29
+ return undefined;
30
+ }
31
+ const validation = column.validation;
32
+ if (!validation) return undefined;
33
+ const stringValue = String(value);
34
+ if (validation.minLength !== undefined && stringValue.length < validation.minLength) {
35
+ return validation.customMessage || `Minimum ${validation.minLength} characters required`;
36
+ }
37
+ if (validation.maxLength !== undefined && stringValue.length > validation.maxLength) {
38
+ return validation.customMessage || `Maximum ${validation.maxLength} characters allowed`;
39
+ }
40
+ if (typeof value === "number") {
41
+ if (validation.min !== undefined && value < validation.min) {
42
+ return validation.customMessage || `Minimum value is ${validation.min}`;
43
+ }
44
+ if (validation.max !== undefined && value > validation.max) {
45
+ return validation.customMessage || `Maximum value is ${validation.max}`;
46
+ }
47
+ }
48
+ if (validation.pattern) {
49
+ const regex = new RegExp(validation.pattern);
50
+ if (!regex.test(stringValue)) {
51
+ return validation.customMessage || "Invalid format";
52
+ }
53
+ }
54
+ if (validation.format) {
55
+ const pattern = FORMAT_PATTERNS[validation.format];
56
+ if (pattern && !pattern.test(stringValue)) {
57
+ return validation.customMessage || FORMAT_MESSAGES[validation.format];
58
+ }
59
+ }
60
+ return undefined;
61
+ }
62
+ export function validateForm(columns, values, fieldConfigs) {
63
+ const errors = {};
64
+ for (const column of columns){
65
+ const fieldName = column.name;
66
+ const value = values[fieldName];
67
+ const config = fieldConfigs?.[fieldName];
68
+ const isRequired = config?.required ?? column.notNull ?? false;
69
+ const error = validateField(column, value, isRequired);
70
+ if (error) {
71
+ errors[fieldName] = error;
72
+ }
73
+ }
74
+ return errors;
75
+ }
76
+ export function isFormValid(errors) {
77
+ return Object.keys(errors).length === 0;
78
+ }
@@ -0,0 +1,214 @@
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 { Button } from "../../Button";
8
+ import { Captcha } from "../../Captcha";
9
+ import { Checkbox } from "../../Checkbox";
10
+ import { NucleusTextInput } from "../../NucleusTextInput";
11
+ import { useLoginStore } from "../store";
12
+ import { loginPageTheme } from "../theme";
13
+ gsap.registerPlugin(useGSAP);
14
+ export function LoginForm({ loginAction, captchaGenerateAction, captchaConfig, showRememberMe = true, showForgotPassword = true, showSignUp = true, forgotPasswordHref, signUpHref, onForgotPassword, onSignUp, onSuccess }) {
15
+ const theme = loginPageTheme;
16
+ const formRef = useRef(null);
17
+ const store = useLoginStore();
18
+ const { contextSafe } = useGSAP({
19
+ scope: formRef
20
+ });
21
+ const isLoading = loginAction.state.isPending;
22
+ const isCaptchaEnabled = captchaConfig?.enabled && captchaGenerateAction;
23
+ const handleSubmit = contextSafe((e)=>{
24
+ e.preventDefault();
25
+ if (!store.email || !store.password) {
26
+ store.setError("Please fill in all fields");
27
+ shakeForm();
28
+ return;
29
+ }
30
+ if (isCaptchaEnabled && (!store.captchaId || !store.captchaAnswer)) {
31
+ store.setError("Please complete the security check");
32
+ shakeForm();
33
+ return;
34
+ }
35
+ store.setError(null);
36
+ loginAction.start({
37
+ payload: {
38
+ email: store.email,
39
+ password: store.password,
40
+ rememberMe: store.rememberMe,
41
+ captchaId: store.captchaId ?? undefined,
42
+ captchaAnswer: store.captchaAnswer || undefined
43
+ },
44
+ onAfterHandle: (data)=>{
45
+ const response = data;
46
+ if (response.success === false) {
47
+ store.setError(response.message || "Login failed. Please try again.");
48
+ shakeForm();
49
+ } else if (response.success) {
50
+ store.reset();
51
+ onSuccess?.();
52
+ }
53
+ },
54
+ onErrorHandle: (err)=>{
55
+ const errorMessage = err instanceof Error ? err.message : "Login failed. Please try again.";
56
+ store.setError(errorMessage);
57
+ shakeForm();
58
+ }
59
+ });
60
+ });
61
+ const shakeForm = contextSafe(()=>{
62
+ if (!formRef.current) return;
63
+ gsap.fromTo(formRef.current, {
64
+ x: -10
65
+ }, {
66
+ x: 10,
67
+ duration: 0.08,
68
+ repeat: 5,
69
+ yoyo: true,
70
+ ease: "power2.inOut",
71
+ onComplete: ()=>{
72
+ gsap.set(formRef.current, {
73
+ x: 0
74
+ });
75
+ }
76
+ });
77
+ });
78
+ const handleForgotPasswordClick = ()=>{
79
+ if (onForgotPassword) {
80
+ onForgotPassword();
81
+ } else if (forgotPasswordHref) {
82
+ window.location.href = forgotPasswordHref;
83
+ }
84
+ };
85
+ const handleSignUpClick = ()=>{
86
+ if (onSignUp) {
87
+ onSignUp();
88
+ } else if (signUpHref) {
89
+ window.location.href = signUpHref;
90
+ }
91
+ };
92
+ return /*#__PURE__*/ _jsxs("form", {
93
+ ref: formRef,
94
+ onSubmit: handleSubmit,
95
+ className: theme.form.container,
96
+ noValidate: true,
97
+ children: [
98
+ store.error && /*#__PURE__*/ _jsx("div", {
99
+ className: theme.error.container,
100
+ role: "alert",
101
+ children: /*#__PURE__*/ _jsx("p", {
102
+ className: theme.error.text,
103
+ children: store.error
104
+ })
105
+ }),
106
+ /*#__PURE__*/ _jsxs("div", {
107
+ className: theme.form.spacing,
108
+ children: [
109
+ /*#__PURE__*/ _jsx("div", {
110
+ className: theme.input.wrapper,
111
+ children: /*#__PURE__*/ _jsx(NucleusTextInput, {
112
+ type: "email",
113
+ label: "Email",
114
+ placeholder: "you@example.com",
115
+ value: store.email,
116
+ onChange: store.setEmail,
117
+ disabled: isLoading,
118
+ enableValidation: false,
119
+ fullWidth: true,
120
+ wrapperClassName: "!bg-transparent border-zinc-300 dark:border-zinc-600",
121
+ inputClassName: "placeholder:text-zinc-400 dark:placeholder:text-zinc-500 !bg-transparent"
122
+ })
123
+ }),
124
+ /*#__PURE__*/ _jsx("div", {
125
+ className: theme.input.wrapper,
126
+ children: /*#__PURE__*/ _jsx(NucleusTextInput, {
127
+ type: "password",
128
+ label: "Password",
129
+ placeholder: "••••••••",
130
+ value: store.password,
131
+ onChange: store.setPassword,
132
+ disabled: isLoading,
133
+ enableValidation: false,
134
+ fullWidth: true,
135
+ wrapperClassName: "!bg-transparent border-zinc-300 dark:border-zinc-600",
136
+ inputClassName: "placeholder:text-zinc-400 dark:placeholder:text-zinc-500 !bg-transparent"
137
+ })
138
+ }),
139
+ isCaptchaEnabled && captchaGenerateAction && /*#__PURE__*/ _jsx(Captcha, {
140
+ generateAction: captchaGenerateAction,
141
+ config: captchaConfig,
142
+ onChallengeLoad: (challenge)=>{
143
+ store.setCaptchaId(challenge.challengeId);
144
+ store.setCaptchaAnswer("");
145
+ },
146
+ onAnswerChange: (_, answer)=>{
147
+ store.setCaptchaAnswer(answer);
148
+ },
149
+ disabled: isLoading,
150
+ autoGenerate: true
151
+ }),
152
+ (showRememberMe || showForgotPassword) && /*#__PURE__*/ _jsxs("div", {
153
+ className: theme.links.container,
154
+ children: [
155
+ showRememberMe && /*#__PURE__*/ _jsxs("div", {
156
+ className: theme.checkbox.wrapper,
157
+ children: [
158
+ /*#__PURE__*/ _jsx(Checkbox, {
159
+ checked: store.rememberMe,
160
+ onChange: store.setRememberMe,
161
+ disabled: isLoading,
162
+ size: "sm"
163
+ }),
164
+ /*#__PURE__*/ _jsx("button", {
165
+ type: "button",
166
+ className: theme.checkbox.label,
167
+ onClick: ()=>store.setRememberMe(!store.rememberMe),
168
+ children: "Remember me"
169
+ })
170
+ ]
171
+ }),
172
+ showForgotPassword && /*#__PURE__*/ _jsx("button", {
173
+ type: "button",
174
+ onClick: handleForgotPasswordClick,
175
+ className: cn(theme.links.forgotPassword),
176
+ disabled: isLoading,
177
+ children: "Forgot password?"
178
+ })
179
+ ]
180
+ }),
181
+ /*#__PURE__*/ _jsx("div", {
182
+ className: theme.button.wrapper,
183
+ children: /*#__PURE__*/ _jsx(Button, {
184
+ type: "submit",
185
+ variant: "nucleus",
186
+ size: "lg",
187
+ fullWidth: true,
188
+ loading: isLoading,
189
+ disabled: isLoading,
190
+ children: "Sign In"
191
+ })
192
+ }),
193
+ showSignUp && /*#__PURE__*/ _jsx("div", {
194
+ className: theme.links.signUp.wrapper,
195
+ children: /*#__PURE__*/ _jsxs("span", {
196
+ className: theme.links.signUp.text,
197
+ children: [
198
+ "Don't have an account?",
199
+ " ",
200
+ /*#__PURE__*/ _jsx("button", {
201
+ type: "button",
202
+ onClick: handleSignUpClick,
203
+ className: theme.links.signUp.link,
204
+ disabled: isLoading,
205
+ children: "Sign up"
206
+ })
207
+ ]
208
+ })
209
+ })
210
+ ]
211
+ })
212
+ ]
213
+ });
214
+ }
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { cn } from "../../../utils/cn";
4
+ import { loginPageTheme } from "../theme";
5
+ export function LoginHeader({ logo, title, subtitle }) {
6
+ const theme = loginPageTheme;
7
+ return /*#__PURE__*/ _jsxs("header", {
8
+ className: theme.header.container,
9
+ children: [
10
+ logo && /*#__PURE__*/ _jsx("div", {
11
+ className: theme.header.logoWrapper,
12
+ children: logo
13
+ }),
14
+ title && /*#__PURE__*/ _jsx("h1", {
15
+ className: cn(theme.header.title),
16
+ children: title
17
+ }),
18
+ subtitle && /*#__PURE__*/ _jsx("p", {
19
+ className: cn(theme.header.subtitle),
20
+ children: subtitle
21
+ })
22
+ ]
23
+ });
24
+ }
@@ -0,0 +1,138 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useGSAP } from "@gsap/react";
4
+ import gsap from "gsap";
5
+ import { useEffect, useEffectEvent, useRef } from "react";
6
+ import { cn } from "../../../utils/cn";
7
+ import { AbstractAnimatedBackground } from "../../AbstractAnimatedBackground";
8
+ import { Button } from "../../Button";
9
+ import { useLoginStore } from "../store";
10
+ import { loginPageTheme } from "../theme";
11
+ import { LoginForm } from "./LoginForm";
12
+ import { LoginHeader } from "./LoginHeader";
13
+ gsap.registerPlugin(useGSAP);
14
+ export function LoginPage({ variant: _variant = "default", logo, title = "Welcome Back", subtitle = "Sign in to your account to continue", loggedInTitle = "You're Logged In", showRememberMe = true, showForgotPassword = true, showSignUp = true, forgotPasswordHref, signUpHref, loginAction, meAction, logoutAction, captchaGenerateAction, config, onForgotPassword, onSignUp, onSuccess, onLogout, showBackground = true, className }) {
15
+ const theme = loginPageTheme;
16
+ const containerRef = useRef(null);
17
+ const cardRef = useRef(null);
18
+ const store = useLoginStore();
19
+ const checkAuth = useEffectEvent(()=>{
20
+ if (!meAction) return;
21
+ meAction.start({
22
+ payload: undefined,
23
+ onAfterHandle: (data)=>{
24
+ const response = data;
25
+ if (response.success && response.data?.user) {
26
+ store.setAuthenticated(true, response.data.user);
27
+ }
28
+ },
29
+ onErrorHandle: ()=>{
30
+ store.setAuthenticated(false, null);
31
+ }
32
+ });
33
+ });
34
+ useEffect(()=>{
35
+ checkAuth();
36
+ }, []);
37
+ const handleLogout = useEffectEvent(()=>{
38
+ if (!logoutAction) return;
39
+ logoutAction.start({
40
+ payload: undefined,
41
+ onAfterHandle: ()=>{
42
+ store.setAuthenticated(false, null);
43
+ store.reset();
44
+ onLogout?.();
45
+ },
46
+ onErrorHandle: ()=>{}
47
+ });
48
+ });
49
+ useGSAP(()=>{
50
+ if (!cardRef.current) return;
51
+ gsap.fromTo(cardRef.current, {
52
+ opacity: 0,
53
+ y: 30,
54
+ scale: 0.95
55
+ }, {
56
+ opacity: 1,
57
+ y: 0,
58
+ scale: 1,
59
+ duration: 0.6,
60
+ ease: "power3.out"
61
+ });
62
+ }, {
63
+ scope: containerRef
64
+ });
65
+ const isCheckingAuth = meAction?.state.isPending;
66
+ const isLoggingOut = logoutAction?.state.isPending;
67
+ return /*#__PURE__*/ _jsxs("main", {
68
+ ref: containerRef,
69
+ className: cn(theme.container.base, className),
70
+ "aria-label": "Login page",
71
+ children: [
72
+ showBackground && /*#__PURE__*/ _jsx(AbstractAnimatedBackground, {}),
73
+ /*#__PURE__*/ _jsx("div", {
74
+ className: theme.container.wrapper,
75
+ children: /*#__PURE__*/ _jsx("article", {
76
+ ref: cardRef,
77
+ className: cn(theme.card.base, theme.card.padding, theme.card.background, theme.card.border, theme.card.shadow, theme.card.rounded),
78
+ children: isCheckingAuth ? /*#__PURE__*/ _jsx("div", {
79
+ className: "flex items-center justify-center py-12",
80
+ children: /*#__PURE__*/ _jsx("div", {
81
+ className: "w-8 h-8 border-2 border-zinc-300 dark:border-zinc-600 border-t-blue-500 rounded-full animate-spin"
82
+ })
83
+ }) : store.isAuthenticated && store.user ? /*#__PURE__*/ _jsxs(_Fragment, {
84
+ children: [
85
+ /*#__PURE__*/ _jsx(LoginHeader, {
86
+ logo: logo,
87
+ title: loggedInTitle,
88
+ subtitle: `Signed in as ${store.user.email}`
89
+ }),
90
+ /*#__PURE__*/ _jsxs("div", {
91
+ className: "mt-6 space-y-4",
92
+ children: [
93
+ /*#__PURE__*/ _jsx(Button, {
94
+ variant: "nucleus",
95
+ size: "lg",
96
+ fullWidth: true,
97
+ onClick: onSuccess,
98
+ children: "Continue to Dashboard"
99
+ }),
100
+ logoutAction && /*#__PURE__*/ _jsx(Button, {
101
+ variant: "outline",
102
+ size: "lg",
103
+ fullWidth: true,
104
+ onClick: handleLogout,
105
+ loading: isLoggingOut,
106
+ disabled: isLoggingOut,
107
+ children: "Sign Out"
108
+ })
109
+ ]
110
+ })
111
+ ]
112
+ }) : /*#__PURE__*/ _jsxs(_Fragment, {
113
+ children: [
114
+ /*#__PURE__*/ _jsx(LoginHeader, {
115
+ logo: logo,
116
+ title: title,
117
+ subtitle: subtitle
118
+ }),
119
+ /*#__PURE__*/ _jsx(LoginForm, {
120
+ loginAction: loginAction,
121
+ captchaGenerateAction: captchaGenerateAction,
122
+ captchaConfig: config?.login?.captcha,
123
+ showRememberMe: showRememberMe,
124
+ showForgotPassword: showForgotPassword,
125
+ showSignUp: showSignUp,
126
+ forgotPasswordHref: forgotPasswordHref,
127
+ signUpHref: signUpHref,
128
+ onForgotPassword: onForgotPassword,
129
+ onSignUp: onSignUp,
130
+ onSuccess: onSuccess
131
+ })
132
+ ]
133
+ })
134
+ })
135
+ })
136
+ ]
137
+ });
138
+ }
@@ -0,0 +1,5 @@
1
+ export { LoginForm } from "./components/LoginForm";
2
+ export { LoginHeader } from "./components/LoginHeader";
3
+ export { LoginPage } from "./components/LoginPage";
4
+ export { useLoginStore } from "./store";
5
+ export { extendLoginPageTheme, loginPageTheme } from "./theme";