nucleus-core-ts 0.8.7 → 0.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +1 -1
- package/dist/fe/components/AbstractAnimatedBackground/index.js +437 -0
- package/dist/fe/components/AuthorizationPage/components/AuthorizationPage.js +841 -0
- package/dist/fe/components/AuthorizationPage/components/ClaimList.js +100 -0
- package/dist/fe/components/AuthorizationPage/components/RoleClaimEditor.js +232 -0
- package/dist/fe/components/AuthorizationPage/components/RoleList.js +115 -0
- package/dist/fe/components/AuthorizationPage/index.js +6 -0
- package/dist/fe/components/AuthorizationPage/store/index.js +117 -0
- package/dist/fe/components/AuthorizationPage/theme/index.js +137 -0
- package/dist/fe/components/AuthorizationPage/types/index.js +1 -0
- package/dist/fe/components/Button/components/Button.js +158 -0
- package/dist/fe/components/Button/components/ButtonSpinner.js +52 -0
- package/dist/fe/components/Button/index.js +3 -0
- package/dist/fe/components/Button/theme/index.js +186 -0
- package/dist/fe/components/Button/types/index.js +1 -0
- package/dist/fe/components/Button/utils/cn.js +5 -0
- package/dist/fe/components/Captcha/components/Captcha.js +311 -0
- package/dist/fe/components/Captcha/index.js +2 -0
- package/dist/fe/components/Captcha/theme.js +52 -0
- package/dist/fe/components/Captcha/types.js +1 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordForm.js +242 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordHeader.js +39 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordPage.js +60 -0
- package/dist/fe/components/ChangePasswordPage/index.js +5 -0
- package/dist/fe/components/ChangePasswordPage/store/index.js +44 -0
- package/dist/fe/components/ChangePasswordPage/theme/index.js +87 -0
- package/dist/fe/components/ChangePasswordPage/types/index.js +1 -0
- package/dist/fe/components/Checkbox/components/Checkbox.js +115 -0
- package/dist/fe/components/Checkbox/components/CheckboxIcon.js +119 -0
- package/dist/fe/components/Checkbox/components/SwitchTrack.js +178 -0
- package/dist/fe/components/Checkbox/index.js +4 -0
- package/dist/fe/components/Checkbox/theme/index.js +221 -0
- package/dist/fe/components/Checkbox/types/index.js +1 -0
- package/dist/fe/components/Checkbox/utils/cn.js +5 -0
- package/dist/fe/components/DataTable/DataTable.js +225 -0
- package/dist/fe/components/DataTable/components/ActionCell.js +26 -0
- package/dist/fe/components/DataTable/components/DataCell.js +76 -0
- package/dist/fe/components/DataTable/components/EditableCell.js +221 -0
- package/dist/fe/components/DataTable/components/EmptyState.js +29 -0
- package/dist/fe/components/DataTable/components/HeaderCell.js +64 -0
- package/dist/fe/components/DataTable/components/InfiniteScrollTrigger.js +66 -0
- package/dist/fe/components/DataTable/components/LoadingSpinner.js +19 -0
- package/dist/fe/components/DataTable/components/ResizeHandle.js +41 -0
- package/dist/fe/components/DataTable/components/SelectionCell.js +105 -0
- package/dist/fe/components/DataTable/components/SkeletonRow.js +56 -0
- package/dist/fe/components/DataTable/components/SkeletonTable.js +83 -0
- package/dist/fe/components/DataTable/components/SortIcon.js +39 -0
- package/dist/fe/components/DataTable/components/TableHeader.js +49 -0
- package/dist/fe/components/DataTable/components/TableRow.js +118 -0
- package/dist/fe/components/DataTable/components/index.js +14 -0
- package/dist/fe/components/DataTable/hooks/index.js +2 -0
- package/dist/fe/components/DataTable/hooks/useAutoFitColumn.js +23 -0
- package/dist/fe/components/DataTable/hooks/useResizeColumn.js +122 -0
- package/dist/fe/components/DataTable/index.js +3 -0
- package/dist/fe/components/DataTable/store/index.js +97 -0
- package/dist/fe/components/DataTable/theme/index.js +144 -0
- package/dist/fe/components/DataTable/types/index.js +1 -0
- package/dist/fe/components/DataTable/utils/cn.js +5 -0
- package/dist/fe/components/DatePicker/components/CalendarGrid.js +95 -0
- package/dist/fe/components/DatePicker/components/CalendarHeader.js +152 -0
- package/dist/fe/components/DatePicker/components/DatePicker.js +381 -0
- package/dist/fe/components/DatePicker/components/MonthYearSelector.js +93 -0
- package/dist/fe/components/DatePicker/index.js +7 -0
- package/dist/fe/components/DatePicker/locales/index.js +1113 -0
- package/dist/fe/components/DatePicker/theme/index.js +315 -0
- package/dist/fe/components/DatePicker/types/index.js +1 -0
- package/dist/fe/components/DatePicker/utils/cn.js +5 -0
- package/dist/fe/components/DatePicker/utils/date.js +132 -0
- package/dist/fe/components/DevicesPage/components/DeviceCard.js +251 -0
- package/dist/fe/components/DevicesPage/components/DevicesHeader.js +42 -0
- package/dist/fe/components/DevicesPage/components/DevicesPage.js +450 -0
- package/dist/fe/components/DevicesPage/index.js +5 -0
- package/dist/fe/components/DevicesPage/store/index.js +55 -0
- package/dist/fe/components/DevicesPage/theme/index.js +131 -0
- package/dist/fe/components/DevicesPage/types/index.js +1 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordForm.js +214 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordHeader.js +42 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordPage.js +59 -0
- package/dist/fe/components/ForgotPasswordPage/index.js +5 -0
- package/dist/fe/components/ForgotPasswordPage/store/index.js +28 -0
- package/dist/fe/components/ForgotPasswordPage/theme/index.js +87 -0
- package/dist/fe/components/ForgotPasswordPage/types/index.js +1 -0
- package/dist/fe/components/FormBuilder/components/FormBuilder.js +156 -0
- package/dist/fe/components/FormBuilder/components/FormField.js +218 -0
- package/dist/fe/components/FormBuilder/hooks/useFormBuilder.js +152 -0
- package/dist/fe/components/FormBuilder/index.js +4 -0
- package/dist/fe/components/FormBuilder/theme/index.js +134 -0
- package/dist/fe/components/FormBuilder/types/index.js +1 -0
- package/dist/fe/components/FormBuilder/utils/cn.js +5 -0
- package/dist/fe/components/FormBuilder/utils/fieldMapping.js +216 -0
- package/dist/fe/components/FormBuilder/utils/validation.js +78 -0
- package/dist/fe/components/LoginPage/components/LoginForm.js +214 -0
- package/dist/fe/components/LoginPage/components/LoginHeader.js +24 -0
- package/dist/fe/components/LoginPage/components/LoginPage.js +138 -0
- package/dist/fe/components/LoginPage/index.js +5 -0
- package/dist/fe/components/LoginPage/store/index.js +59 -0
- package/dist/fe/components/LoginPage/theme/index.js +98 -0
- package/dist/fe/components/LoginPage/types/index.js +1 -0
- package/dist/fe/components/MagicLinkVerifyPage/components/MagicLinkVerifyPage.js +200 -0
- package/dist/fe/components/MagicLinkVerifyPage/index.js +3 -0
- package/dist/fe/components/MagicLinkVerifyPage/store.js +20 -0
- package/dist/fe/components/MagicLinkVerifyPage/theme.js +36 -0
- package/dist/fe/components/MagicLinkVerifyPage/types.js +1 -0
- package/dist/fe/components/NucleusEntityShowcase.js +1409 -0
- package/dist/fe/components/NucleusTextInput/components/FloatingLabel.js +56 -0
- package/dist/fe/components/NucleusTextInput/components/InputIcons.js +258 -0
- package/dist/fe/components/NucleusTextInput/components/NucleusTextInput.js +321 -0
- package/dist/fe/components/NucleusTextInput/components/PasswordStrengthIndicator.js +104 -0
- package/dist/fe/components/NucleusTextInput/components/TypewriterText.js +56 -0
- package/dist/fe/components/NucleusTextInput/index.js +7 -0
- package/dist/fe/components/NucleusTextInput/theme/index.js +121 -0
- package/dist/fe/components/NucleusTextInput/types/index.js +1 -0
- package/dist/fe/components/NucleusTextInput/utils/cn.js +5 -0
- package/dist/fe/components/NucleusTextInput/utils/format.js +62 -0
- package/dist/fe/components/NucleusTextInput/utils/validation.js +191 -0
- package/dist/fe/components/ProfilePage/components/AddressCard.js +196 -0
- package/dist/fe/components/ProfilePage/components/PhoneCard.js +206 -0
- package/dist/fe/components/ProfilePage/components/ProfileHeader.js +150 -0
- package/dist/fe/components/ProfilePage/components/ProfilePage.js +1336 -0
- package/dist/fe/components/ProfilePage/index.js +6 -0
- package/dist/fe/components/ProfilePage/store/index.js +115 -0
- package/dist/fe/components/ProfilePage/theme/index.js +168 -0
- package/dist/fe/components/ProfilePage/types/index.js +1 -0
- package/dist/fe/components/RangePicker/components/RangePicker.js +338 -0
- package/dist/fe/components/RangePicker/components/RangeThumb.js +68 -0
- package/dist/fe/components/RangePicker/components/RangeTooltip.js +45 -0
- package/dist/fe/components/RangePicker/components/RangeTrack.js +32 -0
- package/dist/fe/components/RangePicker/index.js +5 -0
- package/dist/fe/components/RangePicker/theme/index.js +88 -0
- package/dist/fe/components/RangePicker/types/index.js +1 -0
- package/dist/fe/components/RangePicker/utils/cn.js +3 -0
- package/dist/fe/components/RegisterPage/components/PasswordStrengthIndicator.js +107 -0
- package/dist/fe/components/RegisterPage/components/RegisterForm.js +322 -0
- package/dist/fe/components/RegisterPage/components/RegisterHeader.js +23 -0
- package/dist/fe/components/RegisterPage/components/RegisterPage.js +85 -0
- package/dist/fe/components/RegisterPage/index.js +6 -0
- package/dist/fe/components/RegisterPage/store/index.js +106 -0
- package/dist/fe/components/RegisterPage/theme/index.js +128 -0
- package/dist/fe/components/RegisterPage/types/index.js +1 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordForm.js +347 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordHeader.js +42 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordPage.js +61 -0
- package/dist/fe/components/ResetPasswordPage/index.js +5 -0
- package/dist/fe/components/ResetPasswordPage/store/index.js +36 -0
- package/dist/fe/components/ResetPasswordPage/theme/index.js +99 -0
- package/dist/fe/components/ResetPasswordPage/types/index.js +1 -0
- package/dist/fe/components/SearchBox/components/SearchBox.js +271 -0
- package/dist/fe/components/SearchBox/components/SearchBoxDropdown.js +87 -0
- package/dist/fe/components/SearchBox/index.js +5 -0
- package/dist/fe/components/SearchBox/theme/index.js +184 -0
- package/dist/fe/components/SearchBox/types/index.js +1 -0
- package/dist/fe/components/SearchBox/utils/cn.js +5 -0
- package/dist/fe/components/SearchBox/utils/debounce.js +22 -0
- package/dist/fe/components/SearchBox/utils/sanitize.js +48 -0
- package/dist/fe/components/SelectBox/components/SelectBox.js +364 -0
- package/dist/fe/components/SelectBox/components/SelectDropdown.js +92 -0
- package/dist/fe/components/SelectBox/components/SelectOptionItem.js +43 -0
- package/dist/fe/components/SelectBox/components/SelectTrigger.js +22 -0
- package/dist/fe/components/SelectBox/index.js +5 -0
- package/dist/fe/components/SelectBox/theme/index.js +98 -0
- package/dist/fe/components/SelectBox/types/index.js +1 -0
- package/dist/fe/components/SelectBox/utils/cn.js +3 -0
- package/dist/fe/components/SetPasswordPage/components/PasswordStrengthIndicator.js +107 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordForm.js +142 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordHeader.js +23 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordPage.js +263 -0
- package/dist/fe/components/SetPasswordPage/index.js +7 -0
- package/dist/fe/components/SetPasswordPage/store/index.js +79 -0
- package/dist/fe/components/SetPasswordPage/theme/index.js +98 -0
- package/dist/fe/components/SetPasswordPage/types/index.js +12 -0
- package/dist/fe/components/UsersPage/components/InviteUserModal.js +262 -0
- package/dist/fe/components/UsersPage/components/Pagination.js +147 -0
- package/dist/fe/components/UsersPage/components/RoleAssignmentModal.js +186 -0
- package/dist/fe/components/UsersPage/components/StatsCards.js +124 -0
- package/dist/fe/components/UsersPage/components/UserDetailDrawer.js +444 -0
- package/dist/fe/components/UsersPage/components/UserFilters.js +142 -0
- package/dist/fe/components/UsersPage/components/UserListItem.js +125 -0
- package/dist/fe/components/UsersPage/components/UserListSkeleton.js +40 -0
- package/dist/fe/components/UsersPage/components/UsersPage.js +556 -0
- package/dist/fe/components/UsersPage/index.js +10 -0
- package/dist/fe/components/UsersPage/store/index.js +151 -0
- package/dist/fe/components/UsersPage/theme/index.js +231 -0
- package/dist/fe/components/UsersPage/types/index.js +1 -0
- package/dist/fe/components/VerifyEmailPage/components/VerifyEmailPage.js +290 -0
- package/dist/fe/components/VerifyEmailPage/index.js +3 -0
- package/dist/fe/components/VerifyEmailPage/store/index.js +45 -0
- package/dist/fe/components/VerifyEmailPage/theme/index.js +52 -0
- package/dist/fe/components/VerifyEmailPage/types/index.js +1 -0
- package/dist/fe/hooks/useNucleusEntity.js +247 -0
- package/dist/fe/index.js +28 -157
- package/dist/fe/types/index.js +1 -0
- package/dist/fe/utils/cn.js +5 -0
- package/dist/fe/utils/columnUtils.js +189 -0
- package/dist/fe/utils/endpointKeys.js +44 -0
- package/dist/index.js +1 -1
- package/dist/src/Client/Proxy/httpProxy.js +1 -0
- package/dist/src/Client/Proxy/index.js +1 -1
- package/dist/src/Client/Proxy/server.js +1 -0
- package/dist/src/Client/Proxy/types.js +1 -0
- package/dist/src/Client/Proxy/utils.js +1 -0
- package/dist/src/Client/Proxy/wsProxy.js +1 -0
- package/package.json +1 -1
- package/scripts/build.ts +32 -16
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
export const checkboxTheme = {
|
|
2
|
+
container: {
|
|
3
|
+
base: "flex flex-col",
|
|
4
|
+
spacing: "gap-1",
|
|
5
|
+
disabled: "pointer-events-none"
|
|
6
|
+
},
|
|
7
|
+
wrapper: {
|
|
8
|
+
base: "inline-flex items-center cursor-pointer select-none",
|
|
9
|
+
gap: {
|
|
10
|
+
sm: "gap-2",
|
|
11
|
+
md: "gap-2.5",
|
|
12
|
+
lg: "gap-3"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
label: {
|
|
16
|
+
base: "cursor-pointer",
|
|
17
|
+
text: {
|
|
18
|
+
size: {
|
|
19
|
+
sm: "text-sm",
|
|
20
|
+
md: "text-base",
|
|
21
|
+
lg: "text-lg"
|
|
22
|
+
},
|
|
23
|
+
color: {
|
|
24
|
+
light: "text-gray-700",
|
|
25
|
+
dark: "dark:text-gray-200"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
disabled: "opacity-50 cursor-not-allowed"
|
|
29
|
+
},
|
|
30
|
+
checkbox: {
|
|
31
|
+
base: "relative flex items-center justify-center overflow-hidden",
|
|
32
|
+
size: {
|
|
33
|
+
sm: "w-4 h-4",
|
|
34
|
+
md: "w-5 h-5",
|
|
35
|
+
lg: "w-6 h-6"
|
|
36
|
+
},
|
|
37
|
+
border: {
|
|
38
|
+
base: "border-2",
|
|
39
|
+
width: "border-2",
|
|
40
|
+
color: {
|
|
41
|
+
light: "border-gray-300",
|
|
42
|
+
dark: "dark:border-gray-600"
|
|
43
|
+
},
|
|
44
|
+
focused: "ring-2 ring-offset-2 ring-blue-500 dark:ring-offset-gray-900"
|
|
45
|
+
},
|
|
46
|
+
background: {
|
|
47
|
+
unchecked: {
|
|
48
|
+
light: "bg-white",
|
|
49
|
+
dark: "dark:bg-gray-800"
|
|
50
|
+
},
|
|
51
|
+
checked: {
|
|
52
|
+
primary: "bg-blue-500",
|
|
53
|
+
secondary: "bg-purple-500",
|
|
54
|
+
success: "bg-emerald-500",
|
|
55
|
+
warning: "bg-amber-500",
|
|
56
|
+
danger: "bg-red-500",
|
|
57
|
+
info: "bg-cyan-500"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
rounded: "rounded-md",
|
|
61
|
+
shadow: "shadow-sm",
|
|
62
|
+
transition: "transition-all duration-200",
|
|
63
|
+
disabled: {
|
|
64
|
+
opacity: "opacity-50",
|
|
65
|
+
cursor: "cursor-not-allowed"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
checkIcon: {
|
|
69
|
+
base: "absolute",
|
|
70
|
+
size: {
|
|
71
|
+
sm: "w-3 h-3",
|
|
72
|
+
md: "w-3.5 h-3.5",
|
|
73
|
+
lg: "w-4 h-4"
|
|
74
|
+
},
|
|
75
|
+
stroke: {
|
|
76
|
+
width: "stroke-[3]",
|
|
77
|
+
color: "stroke-white"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
indeterminateIcon: {
|
|
81
|
+
base: "absolute",
|
|
82
|
+
size: {
|
|
83
|
+
sm: {
|
|
84
|
+
width: "w-2",
|
|
85
|
+
height: "h-0.5"
|
|
86
|
+
},
|
|
87
|
+
md: {
|
|
88
|
+
width: "w-2.5",
|
|
89
|
+
height: "h-0.5"
|
|
90
|
+
},
|
|
91
|
+
lg: {
|
|
92
|
+
width: "w-3",
|
|
93
|
+
height: "h-0.5"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
background: "bg-white",
|
|
97
|
+
rounded: "rounded-full"
|
|
98
|
+
},
|
|
99
|
+
switch: {
|
|
100
|
+
track: {
|
|
101
|
+
base: "relative inline-flex items-center cursor-pointer",
|
|
102
|
+
size: {
|
|
103
|
+
sm: {
|
|
104
|
+
width: "w-8",
|
|
105
|
+
height: "h-4"
|
|
106
|
+
},
|
|
107
|
+
md: {
|
|
108
|
+
width: "w-11",
|
|
109
|
+
height: "h-6"
|
|
110
|
+
},
|
|
111
|
+
lg: {
|
|
112
|
+
width: "w-14",
|
|
113
|
+
height: "h-7"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
background: {
|
|
117
|
+
unchecked: {
|
|
118
|
+
light: "bg-gray-200",
|
|
119
|
+
dark: "dark:bg-gray-700"
|
|
120
|
+
},
|
|
121
|
+
checked: {
|
|
122
|
+
primary: "bg-blue-500",
|
|
123
|
+
secondary: "bg-purple-500",
|
|
124
|
+
success: "bg-emerald-500",
|
|
125
|
+
warning: "bg-amber-500",
|
|
126
|
+
danger: "bg-red-500",
|
|
127
|
+
info: "bg-cyan-500"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
border: {
|
|
131
|
+
base: "border",
|
|
132
|
+
color: {
|
|
133
|
+
light: "border-gray-300",
|
|
134
|
+
dark: "dark:border-gray-600"
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
rounded: "rounded-full",
|
|
138
|
+
shadow: "shadow-inner",
|
|
139
|
+
transition: "transition-all duration-300 ease-out",
|
|
140
|
+
disabled: {
|
|
141
|
+
opacity: "opacity-50",
|
|
142
|
+
cursor: "cursor-not-allowed"
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
thumb: {
|
|
146
|
+
base: "absolute flex items-center justify-center bg-white rounded-full shadow-lg",
|
|
147
|
+
size: {
|
|
148
|
+
sm: "w-3 h-3",
|
|
149
|
+
md: "w-5 h-5",
|
|
150
|
+
lg: "w-6 h-6"
|
|
151
|
+
},
|
|
152
|
+
background: {
|
|
153
|
+
light: "bg-white",
|
|
154
|
+
dark: "bg-white"
|
|
155
|
+
},
|
|
156
|
+
shadow: "shadow-md",
|
|
157
|
+
rounded: "rounded-full",
|
|
158
|
+
transition: "transition-all duration-300 ease-out",
|
|
159
|
+
position: {
|
|
160
|
+
sm: {
|
|
161
|
+
unchecked: "left-0.5",
|
|
162
|
+
checked: "left-[calc(100%-14px)]"
|
|
163
|
+
},
|
|
164
|
+
md: {
|
|
165
|
+
unchecked: "left-0.5",
|
|
166
|
+
checked: "left-[calc(100%-22px)]"
|
|
167
|
+
},
|
|
168
|
+
lg: {
|
|
169
|
+
unchecked: "left-0.5",
|
|
170
|
+
checked: "left-[calc(100%-26px)]"
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
icon: {
|
|
175
|
+
base: "absolute",
|
|
176
|
+
size: {
|
|
177
|
+
sm: "w-2 h-2",
|
|
178
|
+
md: "w-3 h-3",
|
|
179
|
+
lg: "w-3.5 h-3.5"
|
|
180
|
+
},
|
|
181
|
+
color: {
|
|
182
|
+
unchecked: {
|
|
183
|
+
light: "text-gray-400",
|
|
184
|
+
dark: "text-gray-500"
|
|
185
|
+
},
|
|
186
|
+
checked: "text-current"
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
ripple: {
|
|
191
|
+
base: "absolute inset-0 rounded-full opacity-0",
|
|
192
|
+
size: "scale-0",
|
|
193
|
+
color: {
|
|
194
|
+
primary: "bg-blue-400/30",
|
|
195
|
+
secondary: "bg-purple-400/30",
|
|
196
|
+
success: "bg-emerald-400/30",
|
|
197
|
+
warning: "bg-amber-400/30",
|
|
198
|
+
danger: "bg-red-400/30",
|
|
199
|
+
info: "bg-cyan-400/30"
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
errorText: {
|
|
203
|
+
base: "mt-1",
|
|
204
|
+
text: "text-sm",
|
|
205
|
+
color: "text-red-500"
|
|
206
|
+
},
|
|
207
|
+
helperText: {
|
|
208
|
+
base: "mt-1",
|
|
209
|
+
text: "text-sm",
|
|
210
|
+
color: {
|
|
211
|
+
light: "text-gray-500",
|
|
212
|
+
dark: "dark:text-gray-400"
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
export function extendCheckboxTheme(overrides) {
|
|
217
|
+
return {
|
|
218
|
+
...checkboxTheme,
|
|
219
|
+
...overrides
|
|
220
|
+
};
|
|
221
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,225 @@
|
|
|
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 { EmptyState } from "./components/EmptyState";
|
|
7
|
+
import { InfiniteScrollTrigger } from "./components/InfiniteScrollTrigger";
|
|
8
|
+
import { LoadingSpinner } from "./components/LoadingSpinner";
|
|
9
|
+
import { SkeletonTable } from "./components/SkeletonTable";
|
|
10
|
+
import { TableHeader } from "./components/TableHeader";
|
|
11
|
+
import { TableRow } from "./components/TableRow";
|
|
12
|
+
import { useAutoFitColumn } from "./hooks/useAutoFitColumn";
|
|
13
|
+
import { useResizeColumn } from "./hooks/useResizeColumn";
|
|
14
|
+
import { useDataTableStore } from "./store";
|
|
15
|
+
import { dataTableTheme } from "./theme";
|
|
16
|
+
import { cn } from "./utils/cn";
|
|
17
|
+
gsap.registerPlugin(useGSAP);
|
|
18
|
+
const DEFAULT_CONFIG = {
|
|
19
|
+
hasClickAction: false,
|
|
20
|
+
hasDoubleClickAction: false,
|
|
21
|
+
isFrontendSort: true,
|
|
22
|
+
enableInfiniteScroll: false,
|
|
23
|
+
infiniteScrollThreshold: 100,
|
|
24
|
+
pageSize: 20,
|
|
25
|
+
autoFetchUntilScroll: true,
|
|
26
|
+
defaultColumnWidth: 150,
|
|
27
|
+
defaultRowHeight: 48,
|
|
28
|
+
minColumnWidth: 60,
|
|
29
|
+
minRowHeight: 32,
|
|
30
|
+
enableSelection: false,
|
|
31
|
+
selectionColumnWidth: 48
|
|
32
|
+
};
|
|
33
|
+
export function DataTable({ data, columns, actionColumns, keyExtractor, callbacks, config: userConfig, className, headerMiddleware, cellMiddleware, isLoading, isPending, skeletonRowCount = 5, emptyMessage, selectionToolbar, isLoadingMore = false, hasMoreData = false }) {
|
|
34
|
+
const config = {
|
|
35
|
+
...DEFAULT_CONFIG,
|
|
36
|
+
...userConfig
|
|
37
|
+
};
|
|
38
|
+
const tableRef = useRef(null);
|
|
39
|
+
const scrollContainerRef = useRef(null);
|
|
40
|
+
const store = useDataTableStore();
|
|
41
|
+
const theme = dataTableTheme;
|
|
42
|
+
const { startResize, isJustResized } = useResizeColumn({
|
|
43
|
+
minWidth: config.minColumnWidth,
|
|
44
|
+
tableRef,
|
|
45
|
+
onResizeStart: (columnKey)=>{
|
|
46
|
+
store.setResizingColumn(columnKey);
|
|
47
|
+
},
|
|
48
|
+
onResizeEnd: (columnKey, width)=>{
|
|
49
|
+
store.setResizingColumn(null);
|
|
50
|
+
store.setColumnWidth(columnKey, width);
|
|
51
|
+
callbacks?.onColumnResize?.(columnKey, width);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const { autoFit } = useAutoFitColumn({
|
|
55
|
+
onAutoFit: (columnKey, contentWidth)=>{
|
|
56
|
+
store.autoFitColumn(columnKey, contentWidth);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const hasInitialized = useRef(false);
|
|
60
|
+
useGSAP(()=>{
|
|
61
|
+
if (!tableRef.current || hasInitialized.current) return;
|
|
62
|
+
gsap.fromTo(tableRef.current, {
|
|
63
|
+
opacity: 0
|
|
64
|
+
}, {
|
|
65
|
+
opacity: 1,
|
|
66
|
+
duration: 0.3,
|
|
67
|
+
ease: "power2.out"
|
|
68
|
+
});
|
|
69
|
+
hasInitialized.current = true;
|
|
70
|
+
}, []);
|
|
71
|
+
const handleSort = (columnKey)=>{
|
|
72
|
+
if (isJustResized()) return;
|
|
73
|
+
const column = columns.find((c)=>c.key === columnKey);
|
|
74
|
+
if (!column?.sortable) return;
|
|
75
|
+
let newDirection = "asc";
|
|
76
|
+
if (store.sortColumnKey === columnKey) {
|
|
77
|
+
if (store.sortDirection === "asc") {
|
|
78
|
+
newDirection = "desc";
|
|
79
|
+
} else if (store.sortDirection === "desc") {
|
|
80
|
+
newDirection = null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
store.setSortState(String(columnKey), newDirection);
|
|
84
|
+
if (!config.isFrontendSort) {
|
|
85
|
+
callbacks?.onSort?.(columnKey, newDirection);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const handleResizeStart = (columnKey, e)=>{
|
|
89
|
+
startResize(columnKey, e);
|
|
90
|
+
};
|
|
91
|
+
const handleColumnDoubleClick = (columnKey)=>{
|
|
92
|
+
autoFit(columnKey, tableRef.current);
|
|
93
|
+
};
|
|
94
|
+
const handleLoadMore = ()=>{
|
|
95
|
+
if (isLoadingMore) return;
|
|
96
|
+
callbacks?.onLoadMore?.();
|
|
97
|
+
};
|
|
98
|
+
const getSortedData = ()=>{
|
|
99
|
+
if (!config.isFrontendSort || !store.sortColumnKey || !store.sortDirection) {
|
|
100
|
+
return data;
|
|
101
|
+
}
|
|
102
|
+
const columnKey = store.sortColumnKey;
|
|
103
|
+
const direction = store.sortDirection;
|
|
104
|
+
return [
|
|
105
|
+
...data
|
|
106
|
+
].sort((a, b)=>{
|
|
107
|
+
const aValue = a[columnKey];
|
|
108
|
+
const bValue = b[columnKey];
|
|
109
|
+
if (aValue === bValue) return 0;
|
|
110
|
+
if (aValue === null || aValue === undefined) return 1;
|
|
111
|
+
if (bValue === null || bValue === undefined) return -1;
|
|
112
|
+
const comparison = aValue < bValue ? -1 : 1;
|
|
113
|
+
return direction === "asc" ? comparison : -comparison;
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
const sortedData = getSortedData();
|
|
117
|
+
const selectedData = store.selectedRows.map((index)=>sortedData[index]).filter((item)=>item !== undefined);
|
|
118
|
+
const hasSelection = store.selectedRows.length > 0;
|
|
119
|
+
if (isLoading) {
|
|
120
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
121
|
+
className: cn(theme.container.base, theme.container.border, theme.container.rounded, className),
|
|
122
|
+
children: /*#__PURE__*/ _jsx(LoadingSpinner, {})
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
if (isPending) {
|
|
126
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
127
|
+
className: cn(theme.container.base, theme.container.border, theme.container.rounded, theme.container.shadow, className),
|
|
128
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
129
|
+
className: cn(theme.scrollContainer.base, theme.scrollContainer.maxHeight, theme.scrollContainer.scrollbar),
|
|
130
|
+
children: /*#__PURE__*/ _jsx(SkeletonTable, {
|
|
131
|
+
columns: columns,
|
|
132
|
+
actionColumns: actionColumns,
|
|
133
|
+
rowCount: skeletonRowCount,
|
|
134
|
+
defaultColumnWidth: config.defaultColumnWidth
|
|
135
|
+
})
|
|
136
|
+
})
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
if (data.length === 0) {
|
|
140
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
141
|
+
className: cn(theme.container.base, theme.container.border, theme.container.rounded, className),
|
|
142
|
+
children: /*#__PURE__*/ _jsx(EmptyState, {
|
|
143
|
+
message: emptyMessage
|
|
144
|
+
})
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
148
|
+
className: cn(theme.container.base, theme.container.border, theme.container.rounded, theme.container.shadow, className),
|
|
149
|
+
children: [
|
|
150
|
+
config.enableSelection && hasSelection && selectionToolbar && /*#__PURE__*/ _jsxs("div", {
|
|
151
|
+
className: "flex items-center justify-between border-b border-gray-200 bg-blue-50 px-4 py-2 dark:border-gray-700 dark:bg-blue-900/20",
|
|
152
|
+
children: [
|
|
153
|
+
/*#__PURE__*/ _jsxs("span", {
|
|
154
|
+
className: "text-sm text-gray-600 dark:text-gray-300",
|
|
155
|
+
children: [
|
|
156
|
+
store.selectedRows.length,
|
|
157
|
+
" item selected"
|
|
158
|
+
]
|
|
159
|
+
}),
|
|
160
|
+
/*#__PURE__*/ _jsx("div", {
|
|
161
|
+
className: "flex items-center gap-2",
|
|
162
|
+
children: selectionToolbar({
|
|
163
|
+
selectedRows: store.selectedRows,
|
|
164
|
+
selectedData,
|
|
165
|
+
totalCount: sortedData.length,
|
|
166
|
+
onClearSelection: store.clearSelection
|
|
167
|
+
})
|
|
168
|
+
})
|
|
169
|
+
]
|
|
170
|
+
}),
|
|
171
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
172
|
+
ref: scrollContainerRef,
|
|
173
|
+
className: cn(theme.scrollContainer.base, theme.scrollContainer.maxHeight, theme.scrollContainer.scrollbar),
|
|
174
|
+
children: [
|
|
175
|
+
/*#__PURE__*/ _jsxs("table", {
|
|
176
|
+
ref: tableRef,
|
|
177
|
+
className: cn(theme.table.base, theme.table.layout),
|
|
178
|
+
children: [
|
|
179
|
+
/*#__PURE__*/ _jsx(TableHeader, {
|
|
180
|
+
columns: columns,
|
|
181
|
+
actionColumns: actionColumns,
|
|
182
|
+
columnWidths: store.columnWidths,
|
|
183
|
+
sortColumnKey: store.sortColumnKey,
|
|
184
|
+
sortDirection: store.sortDirection,
|
|
185
|
+
resizingColumn: store.resizingColumn,
|
|
186
|
+
defaultColumnWidth: config.defaultColumnWidth,
|
|
187
|
+
onSort: handleSort,
|
|
188
|
+
onResizeStart: handleResizeStart,
|
|
189
|
+
onColumnDoubleClick: handleColumnDoubleClick,
|
|
190
|
+
headerMiddleware: headerMiddleware,
|
|
191
|
+
enableSelection: config.enableSelection,
|
|
192
|
+
totalRows: sortedData.length
|
|
193
|
+
}),
|
|
194
|
+
/*#__PURE__*/ _jsx("tbody", {
|
|
195
|
+
className: theme.body.wrapper.base,
|
|
196
|
+
children: sortedData.map((row, rowIndex)=>/*#__PURE__*/ _jsx(TableRow, {
|
|
197
|
+
row: row,
|
|
198
|
+
rowIndex: rowIndex,
|
|
199
|
+
columns: columns,
|
|
200
|
+
actionColumns: actionColumns,
|
|
201
|
+
defaultColumnWidth: config.defaultColumnWidth,
|
|
202
|
+
hasClickAction: config.hasClickAction,
|
|
203
|
+
hasDoubleClickAction: config.hasDoubleClickAction,
|
|
204
|
+
onCellClick: callbacks?.onCellClick,
|
|
205
|
+
onCellDoubleClick: callbacks?.onCellDoubleClick,
|
|
206
|
+
onCellEdit: callbacks?.onCellEdit,
|
|
207
|
+
cellMiddleware: cellMiddleware,
|
|
208
|
+
animationDelay: rowIndex * theme.animation.row.stagger,
|
|
209
|
+
enableSelection: config.enableSelection
|
|
210
|
+
}, keyExtractor(row, rowIndex)))
|
|
211
|
+
})
|
|
212
|
+
]
|
|
213
|
+
}),
|
|
214
|
+
config.enableInfiniteScroll && /*#__PURE__*/ _jsx(InfiniteScrollTrigger, {
|
|
215
|
+
isLoading: isLoadingMore,
|
|
216
|
+
hasMoreData: hasMoreData,
|
|
217
|
+
onTrigger: handleLoadMore,
|
|
218
|
+
scrollContainerRef: scrollContainerRef,
|
|
219
|
+
autoFetchUntilScroll: config.autoFetchUntilScroll
|
|
220
|
+
})
|
|
221
|
+
]
|
|
222
|
+
})
|
|
223
|
+
]
|
|
224
|
+
});
|
|
225
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useRef } from "react";
|
|
4
|
+
import { dataTableTheme } from "../theme";
|
|
5
|
+
import { cn } from "../utils/cn";
|
|
6
|
+
export function ActionCell({ column, row, rowIndex, width }) {
|
|
7
|
+
const cellRef = useRef(null);
|
|
8
|
+
const theme = dataTableTheme.body.cell;
|
|
9
|
+
const params = {
|
|
10
|
+
row,
|
|
11
|
+
rowIndex,
|
|
12
|
+
columnKey: column.key
|
|
13
|
+
};
|
|
14
|
+
const renderContent = ()=>{
|
|
15
|
+
return column.renderer(params);
|
|
16
|
+
};
|
|
17
|
+
return /*#__PURE__*/ _jsx("td", {
|
|
18
|
+
ref: cellRef,
|
|
19
|
+
style: {
|
|
20
|
+
width: `${width}px`,
|
|
21
|
+
minWidth: column.minWidth
|
|
22
|
+
},
|
|
23
|
+
className: cn(theme.base, theme.padding, theme.text, theme.color, theme.transition, column.cellClassName),
|
|
24
|
+
children: renderContent()
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
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 DataCell({ column, row, rowIndex, width, isHovered, hasClickAction, hasDoubleClickAction, onClick, onDoubleClick, cellMiddleware }) {
|
|
10
|
+
const cellRef = useRef(null);
|
|
11
|
+
const theme = dataTableTheme.body.cell;
|
|
12
|
+
const { contextSafe } = useGSAP({
|
|
13
|
+
scope: cellRef
|
|
14
|
+
});
|
|
15
|
+
const handleMouseEnter = contextSafe(()=>{
|
|
16
|
+
if (!cellRef.current || !isHovered) return;
|
|
17
|
+
gsap.to(cellRef.current, {
|
|
18
|
+
scale: dataTableTheme.animation.cell.hover.scale,
|
|
19
|
+
duration: dataTableTheme.animation.cell.duration
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
const handleMouseLeave = contextSafe(()=>{
|
|
23
|
+
if (!cellRef.current) return;
|
|
24
|
+
gsap.to(cellRef.current, {
|
|
25
|
+
scale: 1,
|
|
26
|
+
duration: dataTableTheme.animation.cell.duration
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
const getValue = ()=>{
|
|
30
|
+
const key = column.key;
|
|
31
|
+
return row[key];
|
|
32
|
+
};
|
|
33
|
+
const renderContent = ()=>{
|
|
34
|
+
const value = getValue();
|
|
35
|
+
const params = {
|
|
36
|
+
value: value,
|
|
37
|
+
row,
|
|
38
|
+
rowIndex,
|
|
39
|
+
columnKey: column.key,
|
|
40
|
+
column
|
|
41
|
+
};
|
|
42
|
+
if (column.cellRenderer) {
|
|
43
|
+
return column.cellRenderer(params);
|
|
44
|
+
}
|
|
45
|
+
if (cellMiddleware) {
|
|
46
|
+
const middlewareResult = cellMiddleware(params);
|
|
47
|
+
if (middlewareResult !== undefined) {
|
|
48
|
+
return middlewareResult;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (value === null || value === undefined) {
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
return String(value);
|
|
55
|
+
};
|
|
56
|
+
return /*#__PURE__*/ _jsx("td", {
|
|
57
|
+
ref: cellRef,
|
|
58
|
+
"data-column-key": String(column.key),
|
|
59
|
+
style: {
|
|
60
|
+
width: `${width}px`,
|
|
61
|
+
minWidth: column.minWidth,
|
|
62
|
+
maxWidth: column.maxWidth
|
|
63
|
+
},
|
|
64
|
+
className: cn(theme.base, theme.padding, theme.text, theme.color, theme.truncate, theme.transition, (hasClickAction || hasDoubleClickAction) && "cursor-pointer", column.cellClassName),
|
|
65
|
+
onClick: hasClickAction ? onClick : undefined,
|
|
66
|
+
onDoubleClick: hasDoubleClickAction ? onDoubleClick : undefined,
|
|
67
|
+
onKeyDown: hasClickAction || hasDoubleClickAction ? (e)=>{
|
|
68
|
+
if (e.key === "Enter" && hasClickAction && onClick) {
|
|
69
|
+
onClick();
|
|
70
|
+
}
|
|
71
|
+
} : undefined,
|
|
72
|
+
onMouseEnter: handleMouseEnter,
|
|
73
|
+
onMouseLeave: handleMouseLeave,
|
|
74
|
+
children: renderContent()
|
|
75
|
+
});
|
|
76
|
+
}
|