nucleus-core-ts 0.8.6 → 0.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/dist/client.js +1 -1
  2. package/dist/dist/index.d.ts +475 -12
  3. package/dist/fe/components/AbstractAnimatedBackground/index.js +437 -0
  4. package/dist/fe/components/AuthorizationPage/components/AuthorizationPage.js +841 -0
  5. package/dist/fe/components/AuthorizationPage/components/ClaimList.js +100 -0
  6. package/dist/fe/components/AuthorizationPage/components/RoleClaimEditor.js +232 -0
  7. package/dist/fe/components/AuthorizationPage/components/RoleList.js +115 -0
  8. package/dist/fe/components/AuthorizationPage/index.js +6 -0
  9. package/dist/fe/components/AuthorizationPage/store/index.js +117 -0
  10. package/dist/fe/components/AuthorizationPage/theme/index.js +137 -0
  11. package/dist/fe/components/AuthorizationPage/types/index.js +1 -0
  12. package/dist/fe/components/Button/components/Button.js +158 -0
  13. package/dist/fe/components/Button/components/ButtonSpinner.js +52 -0
  14. package/dist/fe/components/Button/index.js +3 -0
  15. package/dist/fe/components/Button/theme/index.js +186 -0
  16. package/dist/fe/components/Button/types/index.js +1 -0
  17. package/dist/fe/components/Button/utils/cn.js +5 -0
  18. package/dist/fe/components/Captcha/components/Captcha.js +311 -0
  19. package/dist/fe/components/Captcha/index.js +2 -0
  20. package/dist/fe/components/Captcha/theme.js +52 -0
  21. package/dist/fe/components/Captcha/types.js +1 -0
  22. package/dist/fe/components/ChangePasswordPage/components/ChangePasswordForm.js +242 -0
  23. package/dist/fe/components/ChangePasswordPage/components/ChangePasswordHeader.js +39 -0
  24. package/dist/fe/components/ChangePasswordPage/components/ChangePasswordPage.js +60 -0
  25. package/dist/fe/components/ChangePasswordPage/index.js +5 -0
  26. package/dist/fe/components/ChangePasswordPage/store/index.js +44 -0
  27. package/dist/fe/components/ChangePasswordPage/theme/index.js +87 -0
  28. package/dist/fe/components/ChangePasswordPage/types/index.js +1 -0
  29. package/dist/fe/components/Checkbox/components/Checkbox.js +115 -0
  30. package/dist/fe/components/Checkbox/components/CheckboxIcon.js +119 -0
  31. package/dist/fe/components/Checkbox/components/SwitchTrack.js +178 -0
  32. package/dist/fe/components/Checkbox/index.js +4 -0
  33. package/dist/fe/components/Checkbox/theme/index.js +221 -0
  34. package/dist/fe/components/Checkbox/types/index.js +1 -0
  35. package/dist/fe/components/Checkbox/utils/cn.js +5 -0
  36. package/dist/fe/components/DataTable/DataTable.js +225 -0
  37. package/dist/fe/components/DataTable/components/ActionCell.js +26 -0
  38. package/dist/fe/components/DataTable/components/DataCell.js +76 -0
  39. package/dist/fe/components/DataTable/components/EditableCell.js +221 -0
  40. package/dist/fe/components/DataTable/components/EmptyState.js +29 -0
  41. package/dist/fe/components/DataTable/components/HeaderCell.js +64 -0
  42. package/dist/fe/components/DataTable/components/InfiniteScrollTrigger.js +66 -0
  43. package/dist/fe/components/DataTable/components/LoadingSpinner.js +19 -0
  44. package/dist/fe/components/DataTable/components/ResizeHandle.js +41 -0
  45. package/dist/fe/components/DataTable/components/SelectionCell.js +105 -0
  46. package/dist/fe/components/DataTable/components/SkeletonRow.js +56 -0
  47. package/dist/fe/components/DataTable/components/SkeletonTable.js +83 -0
  48. package/dist/fe/components/DataTable/components/SortIcon.js +39 -0
  49. package/dist/fe/components/DataTable/components/TableHeader.js +49 -0
  50. package/dist/fe/components/DataTable/components/TableRow.js +118 -0
  51. package/dist/fe/components/DataTable/components/index.js +14 -0
  52. package/dist/fe/components/DataTable/hooks/index.js +2 -0
  53. package/dist/fe/components/DataTable/hooks/useAutoFitColumn.js +23 -0
  54. package/dist/fe/components/DataTable/hooks/useResizeColumn.js +122 -0
  55. package/dist/fe/components/DataTable/index.js +3 -0
  56. package/dist/fe/components/DataTable/store/index.js +97 -0
  57. package/dist/fe/components/DataTable/theme/index.js +144 -0
  58. package/dist/fe/components/DataTable/types/index.js +1 -0
  59. package/dist/fe/components/DataTable/utils/cn.js +5 -0
  60. package/dist/fe/components/DatePicker/components/CalendarGrid.js +95 -0
  61. package/dist/fe/components/DatePicker/components/CalendarHeader.js +152 -0
  62. package/dist/fe/components/DatePicker/components/DatePicker.js +381 -0
  63. package/dist/fe/components/DatePicker/components/MonthYearSelector.js +93 -0
  64. package/dist/fe/components/DatePicker/index.js +7 -0
  65. package/dist/fe/components/DatePicker/locales/index.js +1113 -0
  66. package/dist/fe/components/DatePicker/theme/index.js +315 -0
  67. package/dist/fe/components/DatePicker/types/index.js +1 -0
  68. package/dist/fe/components/DatePicker/utils/cn.js +5 -0
  69. package/dist/fe/components/DatePicker/utils/date.js +132 -0
  70. package/dist/fe/components/DevicesPage/components/DeviceCard.js +251 -0
  71. package/dist/fe/components/DevicesPage/components/DevicesHeader.js +42 -0
  72. package/dist/fe/components/DevicesPage/components/DevicesPage.js +450 -0
  73. package/dist/fe/components/DevicesPage/index.js +5 -0
  74. package/dist/fe/components/DevicesPage/store/index.js +55 -0
  75. package/dist/fe/components/DevicesPage/theme/index.js +131 -0
  76. package/dist/fe/components/DevicesPage/types/index.js +1 -0
  77. package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordForm.js +214 -0
  78. package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordHeader.js +42 -0
  79. package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordPage.js +59 -0
  80. package/dist/fe/components/ForgotPasswordPage/index.js +5 -0
  81. package/dist/fe/components/ForgotPasswordPage/store/index.js +28 -0
  82. package/dist/fe/components/ForgotPasswordPage/theme/index.js +87 -0
  83. package/dist/fe/components/ForgotPasswordPage/types/index.js +1 -0
  84. package/dist/fe/components/FormBuilder/components/FormBuilder.js +156 -0
  85. package/dist/fe/components/FormBuilder/components/FormField.js +218 -0
  86. package/dist/fe/components/FormBuilder/hooks/useFormBuilder.js +152 -0
  87. package/dist/fe/components/FormBuilder/index.js +4 -0
  88. package/dist/fe/components/FormBuilder/theme/index.js +134 -0
  89. package/dist/fe/components/FormBuilder/types/index.js +1 -0
  90. package/dist/fe/components/FormBuilder/utils/cn.js +5 -0
  91. package/dist/fe/components/FormBuilder/utils/fieldMapping.js +216 -0
  92. package/dist/fe/components/FormBuilder/utils/validation.js +78 -0
  93. package/dist/fe/components/LoginPage/components/LoginForm.js +214 -0
  94. package/dist/fe/components/LoginPage/components/LoginHeader.js +24 -0
  95. package/dist/fe/components/LoginPage/components/LoginPage.js +138 -0
  96. package/dist/fe/components/LoginPage/index.js +5 -0
  97. package/dist/fe/components/LoginPage/store/index.js +59 -0
  98. package/dist/fe/components/LoginPage/theme/index.js +98 -0
  99. package/dist/fe/components/LoginPage/types/index.js +1 -0
  100. package/dist/fe/components/MagicLinkVerifyPage/components/MagicLinkVerifyPage.js +200 -0
  101. package/dist/fe/components/MagicLinkVerifyPage/index.js +3 -0
  102. package/dist/fe/components/MagicLinkVerifyPage/store.js +20 -0
  103. package/dist/fe/components/MagicLinkVerifyPage/theme.js +36 -0
  104. package/dist/fe/components/MagicLinkVerifyPage/types.js +1 -0
  105. package/dist/fe/components/NucleusEntityShowcase.js +1409 -0
  106. package/dist/fe/components/NucleusTextInput/components/FloatingLabel.js +56 -0
  107. package/dist/fe/components/NucleusTextInput/components/InputIcons.js +258 -0
  108. package/dist/fe/components/NucleusTextInput/components/NucleusTextInput.js +321 -0
  109. package/dist/fe/components/NucleusTextInput/components/PasswordStrengthIndicator.js +104 -0
  110. package/dist/fe/components/NucleusTextInput/components/TypewriterText.js +56 -0
  111. package/dist/fe/components/NucleusTextInput/index.js +7 -0
  112. package/dist/fe/components/NucleusTextInput/theme/index.js +121 -0
  113. package/dist/fe/components/NucleusTextInput/types/index.js +1 -0
  114. package/dist/fe/components/NucleusTextInput/utils/cn.js +5 -0
  115. package/dist/fe/components/NucleusTextInput/utils/format.js +62 -0
  116. package/dist/fe/components/NucleusTextInput/utils/validation.js +191 -0
  117. package/dist/fe/components/ProfilePage/components/AddressCard.js +196 -0
  118. package/dist/fe/components/ProfilePage/components/PhoneCard.js +206 -0
  119. package/dist/fe/components/ProfilePage/components/ProfileHeader.js +150 -0
  120. package/dist/fe/components/ProfilePage/components/ProfilePage.js +1336 -0
  121. package/dist/fe/components/ProfilePage/index.js +6 -0
  122. package/dist/fe/components/ProfilePage/store/index.js +115 -0
  123. package/dist/fe/components/ProfilePage/theme/index.js +168 -0
  124. package/dist/fe/components/ProfilePage/types/index.js +1 -0
  125. package/dist/fe/components/RangePicker/components/RangePicker.js +338 -0
  126. package/dist/fe/components/RangePicker/components/RangeThumb.js +68 -0
  127. package/dist/fe/components/RangePicker/components/RangeTooltip.js +45 -0
  128. package/dist/fe/components/RangePicker/components/RangeTrack.js +32 -0
  129. package/dist/fe/components/RangePicker/index.js +5 -0
  130. package/dist/fe/components/RangePicker/theme/index.js +88 -0
  131. package/dist/fe/components/RangePicker/types/index.js +1 -0
  132. package/dist/fe/components/RangePicker/utils/cn.js +3 -0
  133. package/dist/fe/components/RegisterPage/components/PasswordStrengthIndicator.js +107 -0
  134. package/dist/fe/components/RegisterPage/components/RegisterForm.js +322 -0
  135. package/dist/fe/components/RegisterPage/components/RegisterHeader.js +23 -0
  136. package/dist/fe/components/RegisterPage/components/RegisterPage.js +85 -0
  137. package/dist/fe/components/RegisterPage/index.js +6 -0
  138. package/dist/fe/components/RegisterPage/store/index.js +106 -0
  139. package/dist/fe/components/RegisterPage/theme/index.js +128 -0
  140. package/dist/fe/components/RegisterPage/types/index.js +1 -0
  141. package/dist/fe/components/ResetPasswordPage/components/ResetPasswordForm.js +347 -0
  142. package/dist/fe/components/ResetPasswordPage/components/ResetPasswordHeader.js +42 -0
  143. package/dist/fe/components/ResetPasswordPage/components/ResetPasswordPage.js +61 -0
  144. package/dist/fe/components/ResetPasswordPage/index.js +5 -0
  145. package/dist/fe/components/ResetPasswordPage/store/index.js +36 -0
  146. package/dist/fe/components/ResetPasswordPage/theme/index.js +99 -0
  147. package/dist/fe/components/ResetPasswordPage/types/index.js +1 -0
  148. package/dist/fe/components/SearchBox/components/SearchBox.js +271 -0
  149. package/dist/fe/components/SearchBox/components/SearchBoxDropdown.js +87 -0
  150. package/dist/fe/components/SearchBox/index.js +5 -0
  151. package/dist/fe/components/SearchBox/theme/index.js +184 -0
  152. package/dist/fe/components/SearchBox/types/index.js +1 -0
  153. package/dist/fe/components/SearchBox/utils/cn.js +5 -0
  154. package/dist/fe/components/SearchBox/utils/debounce.js +22 -0
  155. package/dist/fe/components/SearchBox/utils/sanitize.js +48 -0
  156. package/dist/fe/components/SelectBox/components/SelectBox.js +364 -0
  157. package/dist/fe/components/SelectBox/components/SelectDropdown.js +92 -0
  158. package/dist/fe/components/SelectBox/components/SelectOptionItem.js +43 -0
  159. package/dist/fe/components/SelectBox/components/SelectTrigger.js +22 -0
  160. package/dist/fe/components/SelectBox/index.js +5 -0
  161. package/dist/fe/components/SelectBox/theme/index.js +98 -0
  162. package/dist/fe/components/SelectBox/types/index.js +1 -0
  163. package/dist/fe/components/SelectBox/utils/cn.js +3 -0
  164. package/dist/fe/components/SetPasswordPage/components/PasswordStrengthIndicator.js +107 -0
  165. package/dist/fe/components/SetPasswordPage/components/SetPasswordForm.js +142 -0
  166. package/dist/fe/components/SetPasswordPage/components/SetPasswordHeader.js +23 -0
  167. package/dist/fe/components/SetPasswordPage/components/SetPasswordPage.js +263 -0
  168. package/dist/fe/components/SetPasswordPage/index.js +7 -0
  169. package/dist/fe/components/SetPasswordPage/store/index.js +79 -0
  170. package/dist/fe/components/SetPasswordPage/theme/index.js +98 -0
  171. package/dist/fe/components/SetPasswordPage/types/index.js +12 -0
  172. package/dist/fe/components/UsersPage/components/InviteUserModal.js +262 -0
  173. package/dist/fe/components/UsersPage/components/Pagination.js +147 -0
  174. package/dist/fe/components/UsersPage/components/RoleAssignmentModal.js +186 -0
  175. package/dist/fe/components/UsersPage/components/StatsCards.js +124 -0
  176. package/dist/fe/components/UsersPage/components/UserDetailDrawer.js +444 -0
  177. package/dist/fe/components/UsersPage/components/UserFilters.js +142 -0
  178. package/dist/fe/components/UsersPage/components/UserListItem.js +125 -0
  179. package/dist/fe/components/UsersPage/components/UserListSkeleton.js +40 -0
  180. package/dist/fe/components/UsersPage/components/UsersPage.js +556 -0
  181. package/dist/fe/components/UsersPage/index.js +10 -0
  182. package/dist/fe/components/UsersPage/store/index.js +151 -0
  183. package/dist/fe/components/UsersPage/theme/index.js +231 -0
  184. package/dist/fe/components/UsersPage/types/index.js +1 -0
  185. package/dist/fe/components/VerifyEmailPage/components/VerifyEmailPage.js +290 -0
  186. package/dist/fe/components/VerifyEmailPage/index.js +3 -0
  187. package/dist/fe/components/VerifyEmailPage/store/index.js +45 -0
  188. package/dist/fe/components/VerifyEmailPage/theme/index.js +52 -0
  189. package/dist/fe/components/VerifyEmailPage/types/index.js +1 -0
  190. package/dist/fe/hooks/useNucleusEntity.js +247 -0
  191. package/dist/fe/index.js +28 -110
  192. package/dist/fe/types/index.js +1 -0
  193. package/dist/fe/utils/cn.js +5 -0
  194. package/dist/fe/utils/columnUtils.js +189 -0
  195. package/dist/fe/utils/endpointKeys.js +44 -0
  196. package/dist/index.js +1 -1
  197. package/dist/nucleus.config.d.ts +3 -0
  198. package/dist/src/Client/Proxy/httpProxy.js +1 -0
  199. package/dist/src/Client/Proxy/index.js +1 -1
  200. package/dist/src/Client/Proxy/server.js +1 -0
  201. package/dist/src/Client/Proxy/types.js +1 -0
  202. package/dist/src/Client/Proxy/utils.js +1 -0
  203. package/dist/src/Client/Proxy/wsProxy.js +1 -0
  204. package/package.json +1 -1
  205. package/scripts/build.ts +78 -8
  206. package/dist/dist/index-0yyw12k6.d.ts +0 -8
  207. package/dist/dist/index-tv67j5qd.d.ts +0 -488
  208. package/dist/index-0yyw12k6.js +0 -1
  209. package/dist/index-tv67j5qd.js +0 -1
@@ -0,0 +1,221 @@
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 { useDataTableStore } from "../store";
7
+ import { dataTableTheme } from "../theme";
8
+ import { cn } from "../utils/cn";
9
+ export function EditableCell({ column, row, rowIndex, width, isHovered, onSave, cellMiddleware }) {
10
+ const cellRef = useRef(null);
11
+ const inputRef = useRef(null);
12
+ const iconRef = useRef(null);
13
+ const store = useDataTableStore();
14
+ const theme = dataTableTheme;
15
+ const columnKey = String(column.key);
16
+ const isEditing = store.editingCell?.row === rowIndex && store.editingCell?.column === columnKey;
17
+ const editConfig = column.editConfig ?? {
18
+ type: "text",
19
+ showIconOnHover: true
20
+ };
21
+ const getValue = ()=>{
22
+ const key = column.key;
23
+ return row[key];
24
+ };
25
+ const value = getValue();
26
+ const stringValue = value === null || value === undefined ? "" : String(value);
27
+ useGSAP(()=>{
28
+ if (!iconRef.current) return;
29
+ gsap.killTweensOf(iconRef.current);
30
+ if (isHovered && !isEditing && editConfig.showIconOnHover !== false) {
31
+ gsap.to(iconRef.current, {
32
+ opacity: 1,
33
+ scale: 1,
34
+ duration: 0.15,
35
+ ease: "power2.out",
36
+ overwrite: true
37
+ });
38
+ } else {
39
+ gsap.set(iconRef.current, {
40
+ opacity: 0,
41
+ scale: 0.8
42
+ });
43
+ }
44
+ }, [
45
+ isHovered,
46
+ isEditing,
47
+ editConfig.showIconOnHover
48
+ ]);
49
+ useGSAP(()=>{
50
+ if (isEditing && inputRef.current) {
51
+ gsap.fromTo(inputRef.current, {
52
+ opacity: 0,
53
+ scale: 0.95
54
+ }, {
55
+ opacity: 1,
56
+ scale: 1,
57
+ duration: 0.2,
58
+ ease: "power2.out"
59
+ });
60
+ inputRef.current.focus();
61
+ inputRef.current.select();
62
+ }
63
+ }, [
64
+ isEditing
65
+ ]);
66
+ const handleStartEdit = ()=>{
67
+ store.startEditing(rowIndex, columnKey, stringValue);
68
+ };
69
+ const handleSave = ()=>{
70
+ onSave(store.editValue);
71
+ store.cancelEditing();
72
+ };
73
+ const handleCancel = ()=>{
74
+ store.cancelEditing();
75
+ };
76
+ const handleKeyDown = (e)=>{
77
+ if (e.key === "Enter" && !e.shiftKey) {
78
+ e.preventDefault();
79
+ handleSave();
80
+ } else if (e.key === "Escape") {
81
+ handleCancel();
82
+ }
83
+ };
84
+ const renderContent = ()=>{
85
+ const params = {
86
+ value: value,
87
+ row,
88
+ rowIndex,
89
+ columnKey: column.key,
90
+ column
91
+ };
92
+ if (column.cellRenderer) {
93
+ return column.cellRenderer(params);
94
+ }
95
+ if (cellMiddleware) {
96
+ const middlewareResult = cellMiddleware(params);
97
+ if (middlewareResult !== undefined) {
98
+ return middlewareResult;
99
+ }
100
+ }
101
+ return stringValue;
102
+ };
103
+ const renderInput = ()=>{
104
+ const inputType = editConfig.type ?? "text";
105
+ if (inputType === "textarea") {
106
+ return /*#__PURE__*/ _jsx("textarea", {
107
+ ref: inputRef,
108
+ value: store.editValue,
109
+ onChange: (e)=>store.setEditValue(e.target.value),
110
+ onKeyDown: handleKeyDown,
111
+ placeholder: editConfig.placeholder,
112
+ maxLength: editConfig.maxLength,
113
+ className: cn("w-full resize-none rounded border border-blue-500 bg-white px-2 py-1 text-sm", "focus:outline-none focus:ring-2 focus:ring-blue-500", "dark:border-blue-400 dark:bg-zinc-800 dark:text-white"),
114
+ rows: 2
115
+ });
116
+ }
117
+ if (inputType === "select" && editConfig.selectOptions) {
118
+ return /*#__PURE__*/ _jsx("select", {
119
+ value: store.editValue,
120
+ onChange: (e)=>store.setEditValue(e.target.value),
121
+ onKeyDown: handleKeyDown,
122
+ className: cn("w-full rounded border border-blue-500 bg-white px-2 py-1 text-sm", "focus:outline-none focus:ring-2 focus:ring-blue-500", "dark:border-blue-400 dark:bg-zinc-800 dark:text-white"),
123
+ children: editConfig.selectOptions.map((option)=>/*#__PURE__*/ _jsx("option", {
124
+ value: option.value,
125
+ children: option.label
126
+ }, option.value))
127
+ });
128
+ }
129
+ return /*#__PURE__*/ _jsx("input", {
130
+ ref: inputRef,
131
+ type: inputType === "number" ? "number" : "text",
132
+ value: store.editValue,
133
+ onChange: (e)=>store.setEditValue(e.target.value),
134
+ onKeyDown: handleKeyDown,
135
+ placeholder: editConfig.placeholder,
136
+ maxLength: editConfig.maxLength,
137
+ className: cn("w-full rounded border border-blue-500 bg-white px-2 py-1 text-sm", "focus:outline-none focus:ring-2 focus:ring-blue-500", "dark:border-blue-400 dark:bg-zinc-800 dark:text-white")
138
+ });
139
+ };
140
+ if (isEditing) {
141
+ return /*#__PURE__*/ _jsx("td", {
142
+ ref: cellRef,
143
+ "data-column-key": columnKey,
144
+ style: {
145
+ width: `${width}px`,
146
+ minWidth: column.minWidth,
147
+ maxWidth: column.maxWidth
148
+ },
149
+ className: cn(theme.body.cell.base, "p-1", column.cellClassName),
150
+ children: /*#__PURE__*/ _jsxs("div", {
151
+ className: "flex flex-col gap-1",
152
+ children: [
153
+ renderInput(),
154
+ /*#__PURE__*/ _jsxs("div", {
155
+ className: "flex justify-end gap-1",
156
+ children: [
157
+ /*#__PURE__*/ _jsx("button", {
158
+ type: "button",
159
+ onClick: handleSave,
160
+ className: cn("rounded bg-green-500 px-2 py-0.5 text-xs text-white", "hover:bg-green-600 transition-colors"),
161
+ children: "Save"
162
+ }),
163
+ /*#__PURE__*/ _jsx("button", {
164
+ type: "button",
165
+ onClick: handleCancel,
166
+ className: cn("rounded bg-gray-400 px-2 py-0.5 text-xs text-white", "hover:bg-gray-500 transition-colors dark:bg-zinc-600 dark:hover:bg-zinc-500"),
167
+ children: "Cancel"
168
+ })
169
+ ]
170
+ })
171
+ ]
172
+ })
173
+ });
174
+ }
175
+ return /*#__PURE__*/ _jsx("td", {
176
+ ref: cellRef,
177
+ "data-column-key": columnKey,
178
+ style: {
179
+ width: `${width}px`,
180
+ minWidth: column.minWidth,
181
+ maxWidth: column.maxWidth
182
+ },
183
+ className: cn(theme.body.cell.base, theme.body.cell.padding, theme.body.cell.text, theme.body.cell.color, theme.body.cell.truncate, theme.body.cell.transition, "group relative", column.cellClassName),
184
+ children: /*#__PURE__*/ _jsxs("div", {
185
+ className: "flex items-center gap-2",
186
+ children: [
187
+ /*#__PURE__*/ _jsx("span", {
188
+ className: "flex-1 truncate",
189
+ children: renderContent()
190
+ }),
191
+ column.editable && /*#__PURE__*/ _jsx("button", {
192
+ ref: iconRef,
193
+ type: "button",
194
+ onClick: handleStartEdit,
195
+ "aria-label": "Edit cell",
196
+ className: cn("flex-shrink-0 rounded p-1 opacity-0", "text-gray-500 hover:bg-gray-200 hover:text-gray-700", "dark:text-gray-400 dark:hover:bg-zinc-700 dark:hover:text-gray-200", "transition-colors"),
197
+ children: /*#__PURE__*/ _jsxs("svg", {
198
+ xmlns: "http://www.w3.org/2000/svg",
199
+ width: "14",
200
+ height: "14",
201
+ viewBox: "0 0 24 24",
202
+ fill: "none",
203
+ stroke: "currentColor",
204
+ strokeWidth: "2",
205
+ strokeLinecap: "round",
206
+ strokeLinejoin: "round",
207
+ "aria-hidden": "true",
208
+ children: [
209
+ /*#__PURE__*/ _jsx("path", {
210
+ d: "M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"
211
+ }),
212
+ /*#__PURE__*/ _jsx("path", {
213
+ d: "m15 5 4 4"
214
+ })
215
+ ]
216
+ })
217
+ })
218
+ ]
219
+ })
220
+ });
221
+ }
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { dataTableTheme } from "../theme";
4
+ import { cn } from "../utils/cn";
5
+ export function EmptyState({ message = "No data available", className }) {
6
+ const theme = dataTableTheme.empty;
7
+ return /*#__PURE__*/ _jsxs("div", {
8
+ className: cn(theme.wrapper, className),
9
+ children: [
10
+ /*#__PURE__*/ _jsx("svg", {
11
+ className: theme.icon,
12
+ fill: "none",
13
+ viewBox: "0 0 24 24",
14
+ stroke: "currentColor",
15
+ "aria-hidden": "true",
16
+ children: /*#__PURE__*/ _jsx("path", {
17
+ strokeLinecap: "round",
18
+ strokeLinejoin: "round",
19
+ strokeWidth: 1.5,
20
+ d: "M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"
21
+ })
22
+ }),
23
+ /*#__PURE__*/ _jsx("p", {
24
+ className: theme.text,
25
+ children: message
26
+ })
27
+ ]
28
+ });
29
+ }
@@ -0,0 +1,64 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useRef } from "react";
4
+ import { dataTableTheme } from "../theme";
5
+ import { cn } from "../utils/cn";
6
+ import { ResizeHandle } from "./ResizeHandle";
7
+ import { SortIcon } from "./SortIcon";
8
+ export function HeaderCell({ column, width, sortDirection, isResizing, isSorted, onSort, onResizeStart, onDoubleClick, headerMiddleware }) {
9
+ const cellRef = useRef(null);
10
+ const contentRef = useRef(null);
11
+ const theme = dataTableTheme.header.cell;
12
+ const handleClick = ()=>{
13
+ if (column.sortable && onSort) {
14
+ onSort();
15
+ }
16
+ };
17
+ const renderContent = ()=>{
18
+ if (column.headerRenderer) {
19
+ return column.headerRenderer(column);
20
+ }
21
+ if (headerMiddleware) {
22
+ const middlewareResult = headerMiddleware(column, column.key);
23
+ if (middlewareResult !== undefined) {
24
+ return middlewareResult;
25
+ }
26
+ }
27
+ return column.header;
28
+ };
29
+ return /*#__PURE__*/ _jsxs("th", {
30
+ ref: cellRef,
31
+ scope: "col",
32
+ "data-column-key": String(column.key),
33
+ style: {
34
+ width: `${width}px`,
35
+ minWidth: column.minWidth,
36
+ maxWidth: column.maxWidth
37
+ },
38
+ className: cn(theme.base, theme.padding, theme.text, theme.color, theme.transition, theme.hover, column.sortable && theme.sortable, isSorted && theme.sorted, column.headerClassName),
39
+ onClick: handleClick,
40
+ onDoubleClick: onDoubleClick,
41
+ "aria-sort": isSorted ? sortDirection === "asc" ? "ascending" : "descending" : undefined,
42
+ children: [
43
+ /*#__PURE__*/ _jsxs("div", {
44
+ ref: contentRef,
45
+ className: "flex items-center",
46
+ children: [
47
+ /*#__PURE__*/ _jsx("span", {
48
+ className: "truncate",
49
+ children: renderContent()
50
+ }),
51
+ column.sortable && /*#__PURE__*/ _jsx(SortIcon, {
52
+ direction: sortDirection,
53
+ isActive: isSorted
54
+ })
55
+ ]
56
+ }),
57
+ column.resizable !== false && /*#__PURE__*/ _jsx(ResizeHandle, {
58
+ type: "column",
59
+ isActive: isResizing,
60
+ onResizeStart: onResizeStart
61
+ })
62
+ ]
63
+ });
64
+ }
@@ -0,0 +1,66 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useEffect, useRef } from "react";
4
+ import { dataTableTheme } from "../theme";
5
+ import { cn } from "../utils/cn";
6
+ import { LoadingSpinner } from "./LoadingSpinner";
7
+ export function InfiniteScrollTrigger({ isLoading, hasMoreData, onTrigger, scrollContainerRef, autoFetchUntilScroll = false, className }) {
8
+ const triggerRef = useRef(null);
9
+ const observerRef = useRef(null);
10
+ const hasCheckedOverflow = useRef(false);
11
+ const checkAndFetchIfNoScroll = ()=>{
12
+ if (!autoFetchUntilScroll || !scrollContainerRef.current || isLoading || !hasMoreData) return;
13
+ const container = scrollContainerRef.current;
14
+ const hasScroll = container.scrollHeight > container.clientHeight;
15
+ if (!hasScroll) {
16
+ onTrigger();
17
+ }
18
+ };
19
+ useEffect(()=>{
20
+ if (!autoFetchUntilScroll || !hasMoreData) return;
21
+ const timeoutId = setTimeout(()=>{
22
+ checkAndFetchIfNoScroll();
23
+ }, 100);
24
+ return ()=>clearTimeout(timeoutId);
25
+ }, [
26
+ autoFetchUntilScroll,
27
+ hasMoreData,
28
+ isLoading
29
+ ]);
30
+ useEffect(()=>{
31
+ hasCheckedOverflow.current = false;
32
+ }, []);
33
+ const setupObserver = (element)=>{
34
+ if (observerRef.current) {
35
+ observerRef.current.disconnect();
36
+ }
37
+ if (!element || !hasMoreData) return;
38
+ observerRef.current = new IntersectionObserver((entries)=>{
39
+ const entry = entries[0];
40
+ if (entry?.isIntersecting && !isLoading && hasMoreData) {
41
+ onTrigger();
42
+ }
43
+ }, {
44
+ threshold: 0.1,
45
+ rootMargin: "100px"
46
+ });
47
+ observerRef.current.observe(element);
48
+ };
49
+ const theme = dataTableTheme.infiniteScroll;
50
+ if (!hasMoreData && !isLoading) {
51
+ return null;
52
+ }
53
+ return /*#__PURE__*/ _jsx("div", {
54
+ ref: (el)=>{
55
+ triggerRef.current = el;
56
+ setupObserver(el);
57
+ },
58
+ className: cn(theme.trigger, className),
59
+ children: isLoading && /*#__PURE__*/ _jsx("div", {
60
+ className: theme.loader,
61
+ children: /*#__PURE__*/ _jsx(LoadingSpinner, {
62
+ text: "Loading more..."
63
+ })
64
+ })
65
+ });
66
+ }
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { dataTableTheme } from "../theme";
4
+ import { cn } from "../utils/cn";
5
+ export function LoadingSpinner({ text = "Loading...", className }) {
6
+ const theme = dataTableTheme.loading;
7
+ return /*#__PURE__*/ _jsxs("div", {
8
+ className: cn(theme.wrapper, className),
9
+ children: [
10
+ /*#__PURE__*/ _jsx("div", {
11
+ className: cn(theme.spinner.base, theme.spinner.size, theme.spinner.color)
12
+ }),
13
+ text && /*#__PURE__*/ _jsx("span", {
14
+ className: theme.text,
15
+ children: text
16
+ })
17
+ ]
18
+ });
19
+ }
@@ -0,0 +1,41 @@
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 { useRef } from "react";
6
+ import { dataTableTheme } from "../theme";
7
+ import { cn } from "../utils/cn";
8
+ gsap.registerPlugin(useGSAP);
9
+ export function ResizeHandle({ type, isActive, onResizeStart, className }) {
10
+ const handleRef = useRef(null);
11
+ useGSAP(()=>{
12
+ if (!handleRef.current) return;
13
+ if (isActive) {
14
+ gsap.to(handleRef.current, {
15
+ scaleY: type === "column" ? 1.1 : 1,
16
+ scaleX: type === "row" ? 1.1 : 1,
17
+ duration: dataTableTheme.animation.resize.duration,
18
+ ease: dataTableTheme.animation.resize.ease
19
+ });
20
+ } else {
21
+ gsap.to(handleRef.current, {
22
+ scaleY: 1,
23
+ scaleX: 1,
24
+ duration: dataTableTheme.animation.resize.duration,
25
+ ease: dataTableTheme.animation.resize.ease
26
+ });
27
+ }
28
+ }, [
29
+ isActive,
30
+ type
31
+ ]);
32
+ const theme = type === "column" ? dataTableTheme.header.resizeHandle : dataTableTheme.body.resizeHandle;
33
+ return /*#__PURE__*/ _jsx("button", {
34
+ ref: handleRef,
35
+ type: "button",
36
+ "aria-label": `Resize ${type}`,
37
+ className: cn(theme.base, isActive ? theme.active : theme.idle, theme.hitArea, "appearance-none border-none bg-transparent p-0", className),
38
+ onMouseDown: onResizeStart,
39
+ onTouchStart: onResizeStart
40
+ });
41
+ }
@@ -0,0 +1,105 @@
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 { useDataTableStore } from "../store";
7
+ import { dataTableTheme } from "../theme";
8
+ import { cn } from "../utils/cn";
9
+ export function SelectionCell({ rowIndex, isHovered, isHeader = false, totalRows = 0 }) {
10
+ const cellRef = useRef(null);
11
+ const numberRef = useRef(null);
12
+ const checkboxRef = useRef(null);
13
+ const store = useDataTableStore();
14
+ const theme = dataTableTheme;
15
+ const isSelected = isHeader ? false : store.selectedRows.includes(rowIndex);
16
+ const allSelected = isHeader && totalRows > 0 && store.selectedRows.length === totalRows;
17
+ const someSelected = isHeader && store.selectedRows.length > 0 && store.selectedRows.length < totalRows;
18
+ useGSAP(()=>{
19
+ if (!numberRef.current || !checkboxRef.current) return;
20
+ gsap.killTweensOf([
21
+ numberRef.current,
22
+ checkboxRef.current
23
+ ]);
24
+ if (isHovered || isSelected) {
25
+ gsap.set(numberRef.current, {
26
+ opacity: 0,
27
+ display: "none"
28
+ });
29
+ gsap.set(checkboxRef.current, {
30
+ opacity: 1,
31
+ display: "flex"
32
+ });
33
+ } else {
34
+ gsap.set(numberRef.current, {
35
+ opacity: 1,
36
+ display: "flex"
37
+ });
38
+ gsap.set(checkboxRef.current, {
39
+ opacity: 0,
40
+ display: "none"
41
+ });
42
+ }
43
+ }, [
44
+ isHovered,
45
+ isSelected
46
+ ]);
47
+ const handleToggle = (e)=>{
48
+ e.stopPropagation();
49
+ if (isHeader) {
50
+ if (allSelected || someSelected) {
51
+ store.clearSelection();
52
+ } else {
53
+ store.selectAllRows(totalRows);
54
+ }
55
+ } else {
56
+ store.toggleRowSelection(rowIndex);
57
+ }
58
+ };
59
+ if (isHeader) {
60
+ return /*#__PURE__*/ _jsx("th", {
61
+ ref: cellRef,
62
+ scope: "col",
63
+ className: cn(theme.header.cell.base, theme.header.cell.padding, theme.header.cell.text, theme.header.cell.color, "w-12 text-center"),
64
+ children: /*#__PURE__*/ _jsx("div", {
65
+ className: "flex items-center justify-center",
66
+ children: /*#__PURE__*/ _jsx("input", {
67
+ type: "checkbox",
68
+ checked: allSelected,
69
+ ref: checkboxRef,
70
+ onChange: ()=>{},
71
+ onClick: handleToggle,
72
+ className: cn("h-4 w-4 cursor-pointer rounded border-gray-300", "text-blue-600 focus:ring-blue-500", "dark:border-gray-600 dark:bg-zinc-700"),
73
+ style: {
74
+ opacity: someSelected ? 0.5 : 1
75
+ }
76
+ })
77
+ })
78
+ });
79
+ }
80
+ return /*#__PURE__*/ _jsx("td", {
81
+ ref: cellRef,
82
+ className: cn(theme.body.cell.base, theme.body.cell.padding, theme.body.cell.text, theme.body.cell.color, "w-12 text-center"),
83
+ children: /*#__PURE__*/ _jsxs("div", {
84
+ className: "flex items-center justify-center relative",
85
+ children: [
86
+ /*#__PURE__*/ _jsx("span", {
87
+ ref: numberRef,
88
+ className: "text-gray-400 dark:text-gray-500 text-xs font-medium",
89
+ children: rowIndex + 1
90
+ }),
91
+ /*#__PURE__*/ _jsx("input", {
92
+ ref: checkboxRef,
93
+ type: "checkbox",
94
+ checked: isSelected,
95
+ onChange: ()=>{},
96
+ onClick: handleToggle,
97
+ className: cn("absolute h-4 w-4 cursor-pointer rounded border-gray-300", "text-blue-600 focus:ring-blue-500", "dark:border-gray-600 dark:bg-zinc-700"),
98
+ style: {
99
+ display: "none"
100
+ }
101
+ })
102
+ ]
103
+ })
104
+ });
105
+ }
@@ -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 { useRef } from "react";
6
+ import { dataTableTheme } from "../theme";
7
+ import { cn } from "../utils/cn";
8
+ export function SkeletonRow({ columnCount, rowIndex, columnWidths, hasActionColumn }) {
9
+ const rowRef = useRef(null);
10
+ const theme = dataTableTheme;
11
+ useGSAP(()=>{
12
+ if (!rowRef.current) return;
13
+ gsap.fromTo(rowRef.current, {
14
+ opacity: 0,
15
+ y: 10
16
+ }, {
17
+ opacity: 1,
18
+ y: 0,
19
+ duration: 0.3,
20
+ delay: rowIndex * 0.05,
21
+ ease: "power2.out"
22
+ });
23
+ }, [
24
+ rowIndex
25
+ ]);
26
+ const totalColumns = hasActionColumn ? columnCount + 1 : columnCount;
27
+ return /*#__PURE__*/ _jsx("tr", {
28
+ ref: rowRef,
29
+ className: cn(theme.body.row.base, theme.body.row.transition, rowIndex % 2 === 0 ? theme.body.row.zebra.even : theme.body.row.zebra.odd),
30
+ children: Array.from({
31
+ length: totalColumns
32
+ }).map((_, colIndex)=>/*#__PURE__*/ _jsx("td", {
33
+ style: {
34
+ width: columnWidths[colIndex] ?? 150
35
+ },
36
+ className: cn(theme.body.cell.base, theme.body.cell.padding),
37
+ children: /*#__PURE__*/ _jsx(SkeletonCell, {})
38
+ }, colIndex))
39
+ });
40
+ }
41
+ function SkeletonCell() {
42
+ const cellRef = useRef(null);
43
+ useGSAP(()=>{
44
+ if (!cellRef.current) return;
45
+ gsap.to(cellRef.current, {
46
+ backgroundPosition: "200% 0",
47
+ duration: 1.5,
48
+ repeat: -1,
49
+ ease: "none"
50
+ });
51
+ }, []);
52
+ return /*#__PURE__*/ _jsx("div", {
53
+ ref: cellRef,
54
+ className: "h-4 w-3/4 rounded bg-gradient-to-r from-gray-200 via-gray-300 to-gray-200 bg-[length:200%_100%] dark:from-zinc-700 dark:via-zinc-600 dark:to-zinc-700"
55
+ });
56
+ }