@wealthx/shadcn 0.0.2 → 1.0.0

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 (188) hide show
  1. package/.turbo/turbo-build.log +135 -11
  2. package/CHANGELOG.md +6 -0
  3. package/CHANGES.md +345 -0
  4. package/dist/chunk-2WZVSBAY.mjs +232 -0
  5. package/dist/chunk-2Y7YJKPE.mjs +47 -0
  6. package/dist/chunk-3U7SD3MS.mjs +55 -0
  7. package/dist/chunk-3VQNJ235.mjs +114 -0
  8. package/dist/chunk-55CEW76V.mjs +35 -0
  9. package/dist/chunk-6AFMNC42.mjs +146 -0
  10. package/dist/chunk-6OJF6XRN.mjs +117 -0
  11. package/dist/chunk-7LDIMXGM.mjs +181 -0
  12. package/dist/chunk-AMJ23O53.mjs +122 -0
  13. package/dist/chunk-BBJBJSXQ.mjs +44 -0
  14. package/dist/chunk-BGP2N52Z.mjs +126 -0
  15. package/dist/chunk-BMFN37JH.mjs +41 -0
  16. package/dist/chunk-CGOKTPXU.mjs +79 -0
  17. package/dist/chunk-CZ3BW5GL.mjs +81 -0
  18. package/dist/chunk-DBHJ5KC3.mjs +55 -0
  19. package/dist/chunk-DDPA2XXS.mjs +97 -0
  20. package/dist/chunk-DS2AMHN2.mjs +30 -0
  21. package/dist/chunk-E3K6O4FZ.mjs +57 -0
  22. package/dist/chunk-FWCSY2DS.mjs +37 -0
  23. package/dist/chunk-GPRJQ24C.mjs +28 -0
  24. package/dist/chunk-HS7TFG7V.mjs +24 -0
  25. package/dist/chunk-HUVTPUV2.mjs +256 -0
  26. package/dist/chunk-IAOOZCUY.mjs +90 -0
  27. package/dist/chunk-JF4PHPD5.mjs +111 -0
  28. package/dist/chunk-JU2RUWHF.mjs +123 -0
  29. package/dist/chunk-KKHTJNMM.mjs +86 -0
  30. package/dist/chunk-MJIEMGRD.mjs +266 -0
  31. package/dist/chunk-MKFL5MNH.mjs +372 -0
  32. package/dist/chunk-MQ72DIBH.mjs +105 -0
  33. package/dist/chunk-NGYG2EA6.mjs +148 -0
  34. package/dist/chunk-NWZ46DJL.mjs +213 -0
  35. package/dist/chunk-OXQQNQZI.mjs +75 -0
  36. package/dist/chunk-PMKODV6M.mjs +161 -0
  37. package/dist/chunk-QOJ2DQD6.mjs +57 -0
  38. package/dist/chunk-RL772EH7.mjs +126 -0
  39. package/dist/chunk-SLWCCURD.mjs +99 -0
  40. package/dist/chunk-V7CNWJT3.mjs +10 -0
  41. package/dist/chunk-VG6UF6UT.mjs +68 -0
  42. package/dist/chunk-VYMHBV6D.mjs +123 -0
  43. package/dist/chunk-VZ2NR7L3.mjs +195 -0
  44. package/dist/chunk-YN5SYTOO.mjs +117 -0
  45. package/dist/chunk-Z3MK2KKZ.mjs +83 -0
  46. package/dist/chunk-ZN2QKLF6.mjs +187 -0
  47. package/dist/chunk-ZZV5JVNW.mjs +34 -0
  48. package/dist/components/ui/accordion.js +142 -0
  49. package/dist/components/ui/accordion.mjs +14 -0
  50. package/dist/components/ui/alert-dialog.js +413 -0
  51. package/dist/components/ui/alert-dialog.mjs +34 -0
  52. package/dist/components/ui/alert.js +134 -0
  53. package/dist/components/ui/alert.mjs +12 -0
  54. package/dist/components/ui/avatar.js +173 -0
  55. package/dist/components/ui/avatar.mjs +18 -0
  56. package/dist/components/ui/badge.js +163 -0
  57. package/dist/components/ui/badge.mjs +11 -0
  58. package/dist/components/ui/button.js +198 -0
  59. package/dist/components/ui/button.mjs +11 -0
  60. package/dist/components/ui/calendar.js +408 -0
  61. package/dist/components/ui/calendar.mjs +12 -0
  62. package/dist/components/ui/card.js +156 -0
  63. package/dist/components/ui/card.mjs +20 -0
  64. package/dist/components/ui/checkbox.js +166 -0
  65. package/dist/components/ui/checkbox.mjs +11 -0
  66. package/dist/components/ui/chip.js +199 -0
  67. package/dist/components/ui/chip.mjs +10 -0
  68. package/dist/components/ui/data-table.js +925 -0
  69. package/dist/components/ui/data-table.mjs +29 -0
  70. package/dist/components/ui/date-picker.js +561 -0
  71. package/dist/components/ui/date-picker.mjs +15 -0
  72. package/dist/components/ui/dialog.js +378 -0
  73. package/dist/components/ui/dialog.mjs +30 -0
  74. package/dist/components/ui/drawer.js +213 -0
  75. package/dist/components/ui/drawer.mjs +28 -0
  76. package/dist/components/ui/dropdown-menu.js +338 -0
  77. package/dist/components/ui/dropdown-menu.mjs +38 -0
  78. package/dist/components/ui/empty.js +173 -0
  79. package/dist/components/ui/empty.mjs +18 -0
  80. package/dist/components/ui/field.js +359 -0
  81. package/dist/components/ui/field.mjs +28 -0
  82. package/dist/components/ui/input-group.js +406 -0
  83. package/dist/components/ui/input-group.mjs +22 -0
  84. package/dist/components/ui/input-otp.js +149 -0
  85. package/dist/components/ui/input-otp.mjs +14 -0
  86. package/dist/components/ui/input.js +81 -0
  87. package/dist/components/ui/input.mjs +8 -0
  88. package/dist/components/ui/label.js +85 -0
  89. package/dist/components/ui/label.mjs +8 -0
  90. package/dist/components/ui/pagination.js +333 -0
  91. package/dist/components/ui/pagination.mjs +22 -0
  92. package/dist/components/ui/popover.js +167 -0
  93. package/dist/components/ui/popover.mjs +22 -0
  94. package/dist/components/ui/progress.js +97 -0
  95. package/dist/components/ui/progress.mjs +8 -0
  96. package/dist/components/ui/radio-group.js +178 -0
  97. package/dist/components/ui/radio-group.mjs +12 -0
  98. package/dist/components/ui/select.js +262 -0
  99. package/dist/components/ui/select.mjs +28 -0
  100. package/dist/components/ui/separator.js +86 -0
  101. package/dist/components/ui/separator.mjs +8 -0
  102. package/dist/components/ui/sheet.js +227 -0
  103. package/dist/components/ui/sheet.mjs +26 -0
  104. package/dist/components/ui/skeleton.js +75 -0
  105. package/dist/components/ui/skeleton.mjs +8 -0
  106. package/dist/components/ui/sonner.js +86 -0
  107. package/dist/components/ui/sonner.mjs +7 -0
  108. package/dist/components/ui/spinner.js +93 -0
  109. package/dist/components/ui/spinner.mjs +10 -0
  110. package/dist/components/ui/switch.js +178 -0
  111. package/dist/components/ui/switch.mjs +11 -0
  112. package/dist/components/ui/table.js +184 -0
  113. package/dist/components/ui/table.mjs +22 -0
  114. package/dist/components/ui/tabs.js +181 -0
  115. package/dist/components/ui/tabs.mjs +16 -0
  116. package/dist/components/ui/textarea.js +79 -0
  117. package/dist/components/ui/textarea.mjs +8 -0
  118. package/dist/components/ui/toggle-group.js +184 -0
  119. package/dist/components/ui/toggle-group.mjs +12 -0
  120. package/dist/components/ui/toggle.js +108 -0
  121. package/dist/components/ui/toggle.mjs +11 -0
  122. package/dist/components/ui/tooltip.js +140 -0
  123. package/dist/components/ui/tooltip.mjs +16 -0
  124. package/dist/index.js +4312 -90
  125. package/dist/index.mjs +459 -158
  126. package/dist/lib/colors.js +84 -0
  127. package/dist/lib/colors.mjs +13 -0
  128. package/dist/lib/theme-provider.js +150 -0
  129. package/dist/lib/theme-provider.mjs +13 -0
  130. package/dist/lib/typography.js +157 -0
  131. package/dist/lib/typography.mjs +25 -0
  132. package/dist/lib/utils.js +34 -0
  133. package/dist/lib/utils.mjs +7 -0
  134. package/dist/styles.css +1 -1
  135. package/package.json +228 -11
  136. package/scripts/build-css.ts +15 -9
  137. package/src/components/index.tsx +443 -0
  138. package/src/components/ui/accordion.tsx +99 -0
  139. package/src/components/ui/alert-dialog.tsx +239 -0
  140. package/src/components/ui/alert.tsx +81 -0
  141. package/src/components/ui/avatar.tsx +130 -0
  142. package/src/components/ui/badge.tsx +57 -0
  143. package/src/components/ui/button.tsx +69 -37
  144. package/src/components/ui/calendar.tsx +252 -0
  145. package/src/components/ui/card.tsx +106 -0
  146. package/src/components/ui/checkbox.tsx +111 -0
  147. package/src/components/ui/chip.tsx +65 -0
  148. package/src/components/ui/data-table.tsx +490 -0
  149. package/src/components/ui/date-picker.tsx +133 -0
  150. package/src/components/ui/dialog.tsx +195 -0
  151. package/src/components/ui/drawer.tsx +169 -0
  152. package/src/components/ui/dropdown-menu.tsx +315 -0
  153. package/src/components/ui/empty.tsx +128 -0
  154. package/src/components/ui/field.tsx +273 -0
  155. package/src/components/ui/input-group.tsx +190 -0
  156. package/src/components/ui/input-otp.tsx +90 -0
  157. package/src/components/ui/input.tsx +28 -0
  158. package/src/components/ui/label.tsx +24 -0
  159. package/src/components/ui/pagination.tsx +148 -0
  160. package/src/components/ui/popover.tsx +112 -0
  161. package/src/components/ui/progress.tsx +40 -0
  162. package/src/components/ui/radio-group.tsx +129 -0
  163. package/src/components/ui/select.tsx +201 -0
  164. package/src/components/ui/separator.tsx +26 -0
  165. package/src/components/ui/sheet.tsx +182 -0
  166. package/src/components/ui/skeleton.tsx +22 -0
  167. package/src/components/ui/sonner.tsx +48 -0
  168. package/src/components/ui/spinner.tsx +41 -0
  169. package/src/components/ui/switch.tsx +126 -0
  170. package/src/components/ui/table.tsx +143 -0
  171. package/src/components/ui/tabs.tsx +119 -0
  172. package/src/components/ui/textarea.tsx +28 -0
  173. package/src/components/ui/toggle-group.tsx +94 -0
  174. package/src/components/ui/toggle.tsx +59 -0
  175. package/src/components/ui/tooltip.tsx +80 -0
  176. package/src/index.ts +15 -3
  177. package/src/lib/colors.ts +74 -0
  178. package/src/lib/slot.tsx +68 -0
  179. package/src/lib/theme-provider.tsx +134 -0
  180. package/src/lib/typography.ts +153 -0
  181. package/src/lib/utils.ts +1 -1
  182. package/src/styles/globals.css +377 -107
  183. package/src/styles/styles-css.ts +1 -1
  184. package/tsup.config.ts +48 -2
  185. package/dist/index.d.mts +0 -27
  186. package/dist/index.d.ts +0 -27
  187. package/src/provider/ShadcnProvider.tsx +0 -89
  188. package/src/provider/index.ts +0 -2
@@ -0,0 +1,266 @@
1
+ import {
2
+ useThemeVars
3
+ } from "./chunk-OXQQNQZI.mjs";
4
+ import {
5
+ cn
6
+ } from "./chunk-V7CNWJT3.mjs";
7
+ import {
8
+ __objRest,
9
+ __spreadProps,
10
+ __spreadValues
11
+ } from "./chunk-FWCSY2DS.mjs";
12
+
13
+ // src/components/ui/dropdown-menu.tsx
14
+ import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";
15
+ import { Menu as MenuPrimitive } from "@base-ui/react/menu";
16
+ import { jsx, jsxs } from "react/jsx-runtime";
17
+ function DropdownMenu(_a) {
18
+ var props = __objRest(_a, []);
19
+ return /* @__PURE__ */ jsx(MenuPrimitive.Root, __spreadValues({ "data-slot": "dropdown-menu" }, props));
20
+ }
21
+ function DropdownMenuPortal(_a) {
22
+ var props = __objRest(_a, []);
23
+ return /* @__PURE__ */ jsx(MenuPrimitive.Portal, __spreadValues({ "data-slot": "dropdown-menu-portal" }, props));
24
+ }
25
+ function DropdownMenuTrigger(_a) {
26
+ var props = __objRest(_a, []);
27
+ return /* @__PURE__ */ jsx(
28
+ MenuPrimitive.Trigger,
29
+ __spreadValues({
30
+ "data-slot": "dropdown-menu-trigger"
31
+ }, props)
32
+ );
33
+ }
34
+ function DropdownMenuContent(_a) {
35
+ var _b = _a, {
36
+ className,
37
+ sideOffset = 4,
38
+ style
39
+ } = _b, props = __objRest(_b, [
40
+ "className",
41
+ "sideOffset",
42
+ "style"
43
+ ]);
44
+ const themeVars = useThemeVars();
45
+ return /* @__PURE__ */ jsx(MenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(MenuPrimitive.Positioner, { sideOffset, children: /* @__PURE__ */ jsx(
46
+ MenuPrimitive.Popup,
47
+ __spreadValues({
48
+ className: cn(
49
+ "z-50 min-w-[8rem] overflow-x-hidden overflow-y-auto rounded-none border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-ending-style:animate-out data-ending-style:fade-out-0 data-ending-style:zoom-out-95 data-ending-style:fill-mode-forwards data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95",
50
+ className
51
+ ),
52
+ "data-slot": "dropdown-menu-content",
53
+ style: __spreadValues(__spreadValues({}, themeVars), style)
54
+ }, props)
55
+ ) }) });
56
+ }
57
+ function DropdownMenuGroup(_a) {
58
+ var props = __objRest(_a, []);
59
+ return /* @__PURE__ */ jsx(MenuPrimitive.Group, __spreadValues({ "data-slot": "dropdown-menu-group" }, props));
60
+ }
61
+ function DropdownMenuItem(_a) {
62
+ var _b = _a, {
63
+ className,
64
+ inset,
65
+ variant = "default"
66
+ } = _b, props = __objRest(_b, [
67
+ "className",
68
+ "inset",
69
+ "variant"
70
+ ]);
71
+ return /* @__PURE__ */ jsx(
72
+ MenuPrimitive.Item,
73
+ __spreadValues({
74
+ className: cn(
75
+ "relative flex cursor-default items-center gap-2 rounded-none px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!",
76
+ className
77
+ ),
78
+ "data-inset": inset,
79
+ "data-slot": "dropdown-menu-item",
80
+ "data-variant": variant
81
+ }, props)
82
+ );
83
+ }
84
+ function DropdownMenuCheckboxItem(_a) {
85
+ var _b = _a, {
86
+ className,
87
+ children,
88
+ checked
89
+ } = _b, props = __objRest(_b, [
90
+ "className",
91
+ "children",
92
+ "checked"
93
+ ]);
94
+ return /* @__PURE__ */ jsxs(
95
+ MenuPrimitive.CheckboxItem,
96
+ __spreadProps(__spreadValues({
97
+ checked,
98
+ className: cn(
99
+ "relative flex cursor-default items-center gap-2 rounded-none py-1.5 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 data-checked:bg-primary/10 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
100
+ className
101
+ ),
102
+ "data-slot": "dropdown-menu-checkbox-item"
103
+ }, props), {
104
+ children: [
105
+ /* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute left-2 flex size-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(MenuPrimitive.CheckboxItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4" }) }) }),
106
+ children
107
+ ]
108
+ })
109
+ );
110
+ }
111
+ function DropdownMenuRadioGroup(_a) {
112
+ var props = __objRest(_a, []);
113
+ return /* @__PURE__ */ jsx(
114
+ MenuPrimitive.RadioGroup,
115
+ __spreadValues({
116
+ "data-slot": "dropdown-menu-radio-group"
117
+ }, props)
118
+ );
119
+ }
120
+ function DropdownMenuRadioItem(_a) {
121
+ var _b = _a, {
122
+ className,
123
+ children
124
+ } = _b, props = __objRest(_b, [
125
+ "className",
126
+ "children"
127
+ ]);
128
+ return /* @__PURE__ */ jsxs(
129
+ MenuPrimitive.RadioItem,
130
+ __spreadProps(__spreadValues({
131
+ className: cn(
132
+ "relative flex cursor-default items-center gap-2 rounded-none py-1.5 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 data-checked:bg-primary/10 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
133
+ className
134
+ ),
135
+ "data-slot": "dropdown-menu-radio-item"
136
+ }, props), {
137
+ children: [
138
+ /* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute left-2 flex size-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(MenuPrimitive.RadioItemIndicator, { children: /* @__PURE__ */ jsx(CircleIcon, { className: "size-2 fill-current" }) }) }),
139
+ children
140
+ ]
141
+ })
142
+ );
143
+ }
144
+ function DropdownMenuLabel(_a) {
145
+ var _b = _a, {
146
+ className,
147
+ inset
148
+ } = _b, props = __objRest(_b, [
149
+ "className",
150
+ "inset"
151
+ ]);
152
+ return /* @__PURE__ */ jsx(
153
+ MenuPrimitive.GroupLabel,
154
+ __spreadValues({
155
+ className: cn(
156
+ "px-2 py-1.5 text-sm font-medium data-inset:pl-8",
157
+ className
158
+ ),
159
+ "data-inset": inset,
160
+ "data-slot": "dropdown-menu-label"
161
+ }, props)
162
+ );
163
+ }
164
+ function DropdownMenuSeparator(_a) {
165
+ var _b = _a, {
166
+ className
167
+ } = _b, props = __objRest(_b, [
168
+ "className"
169
+ ]);
170
+ return /* @__PURE__ */ jsx(
171
+ MenuPrimitive.Separator,
172
+ __spreadValues({
173
+ className: cn("-mx-1 my-1 h-px bg-border", className),
174
+ "data-slot": "dropdown-menu-separator"
175
+ }, props)
176
+ );
177
+ }
178
+ function DropdownMenuShortcut(_a) {
179
+ var _b = _a, {
180
+ className
181
+ } = _b, props = __objRest(_b, [
182
+ "className"
183
+ ]);
184
+ return /* @__PURE__ */ jsx(
185
+ "span",
186
+ __spreadValues({
187
+ className: cn(
188
+ "ml-auto text-xs tracking-widest text-muted-foreground",
189
+ className
190
+ ),
191
+ "data-slot": "dropdown-menu-shortcut"
192
+ }, props)
193
+ );
194
+ }
195
+ function DropdownMenuSub(_a) {
196
+ var props = __objRest(_a, []);
197
+ return /* @__PURE__ */ jsx(MenuPrimitive.SubmenuRoot, __spreadValues({ "data-slot": "dropdown-menu-sub" }, props));
198
+ }
199
+ function DropdownMenuSubTrigger(_a) {
200
+ var _b = _a, {
201
+ className,
202
+ inset,
203
+ children
204
+ } = _b, props = __objRest(_b, [
205
+ "className",
206
+ "inset",
207
+ "children"
208
+ ]);
209
+ return /* @__PURE__ */ jsxs(
210
+ MenuPrimitive.SubmenuTrigger,
211
+ __spreadProps(__spreadValues({
212
+ className: cn(
213
+ "flex cursor-default items-center gap-2 rounded-none px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
214
+ className
215
+ ),
216
+ "data-inset": inset,
217
+ "data-slot": "dropdown-menu-sub-trigger"
218
+ }, props), {
219
+ children: [
220
+ children,
221
+ /* @__PURE__ */ jsx(ChevronRightIcon, { className: "ml-auto size-4" })
222
+ ]
223
+ })
224
+ );
225
+ }
226
+ function DropdownMenuSubContent(_a) {
227
+ var _b = _a, {
228
+ className,
229
+ sideOffset = 0,
230
+ style
231
+ } = _b, props = __objRest(_b, [
232
+ "className",
233
+ "sideOffset",
234
+ "style"
235
+ ]);
236
+ const themeVars = useThemeVars();
237
+ return /* @__PURE__ */ jsx(MenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(MenuPrimitive.Positioner, { sideOffset, children: /* @__PURE__ */ jsx(
238
+ MenuPrimitive.Popup,
239
+ __spreadValues({
240
+ className: cn(
241
+ "z-50 min-w-[8rem] overflow-hidden rounded-none border bg-popover p-1 text-popover-foreground shadow-lg data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-ending-style:animate-out data-ending-style:fade-out-0 data-ending-style:zoom-out-95 data-ending-style:fill-mode-forwards data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95",
242
+ className
243
+ ),
244
+ "data-slot": "dropdown-menu-sub-content",
245
+ style: __spreadValues(__spreadValues({}, themeVars), style)
246
+ }, props)
247
+ ) }) });
248
+ }
249
+
250
+ export {
251
+ DropdownMenu,
252
+ DropdownMenuPortal,
253
+ DropdownMenuTrigger,
254
+ DropdownMenuContent,
255
+ DropdownMenuGroup,
256
+ DropdownMenuItem,
257
+ DropdownMenuCheckboxItem,
258
+ DropdownMenuRadioGroup,
259
+ DropdownMenuRadioItem,
260
+ DropdownMenuLabel,
261
+ DropdownMenuSeparator,
262
+ DropdownMenuShortcut,
263
+ DropdownMenuSub,
264
+ DropdownMenuSubTrigger,
265
+ DropdownMenuSubContent
266
+ };
@@ -0,0 +1,372 @@
1
+ import {
2
+ Skeleton
3
+ } from "./chunk-HS7TFG7V.mjs";
4
+ import {
5
+ Table,
6
+ TableBody,
7
+ TableCell,
8
+ TableHead,
9
+ TableHeader,
10
+ TableRow
11
+ } from "./chunk-BGP2N52Z.mjs";
12
+ import {
13
+ Select,
14
+ SelectContent,
15
+ SelectItem,
16
+ SelectTrigger,
17
+ SelectValue
18
+ } from "./chunk-VZ2NR7L3.mjs";
19
+ import {
20
+ DropdownMenu,
21
+ DropdownMenuCheckboxItem,
22
+ DropdownMenuContent,
23
+ DropdownMenuGroup,
24
+ DropdownMenuLabel,
25
+ DropdownMenuSeparator,
26
+ DropdownMenuTrigger
27
+ } from "./chunk-MJIEMGRD.mjs";
28
+ import {
29
+ Input
30
+ } from "./chunk-DS2AMHN2.mjs";
31
+ import {
32
+ Checkbox
33
+ } from "./chunk-JF4PHPD5.mjs";
34
+ import {
35
+ Button
36
+ } from "./chunk-IAOOZCUY.mjs";
37
+ import {
38
+ cn
39
+ } from "./chunk-V7CNWJT3.mjs";
40
+
41
+ // src/components/ui/data-table.tsx
42
+ import * as React from "react";
43
+ import {
44
+ flexRender,
45
+ getCoreRowModel,
46
+ getFilteredRowModel,
47
+ getPaginationRowModel,
48
+ getSortedRowModel,
49
+ useReactTable
50
+ } from "@tanstack/react-table";
51
+ import {
52
+ ArrowUpDown,
53
+ ArrowUp,
54
+ ArrowDown,
55
+ ChevronLeftIcon,
56
+ ChevronRightIcon,
57
+ ChevronsLeftIcon,
58
+ ChevronsRightIcon,
59
+ SlidersHorizontal
60
+ } from "lucide-react";
61
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
62
+ function DataTableColumnHeader({
63
+ column,
64
+ title,
65
+ className
66
+ }) {
67
+ if (!column.getCanSort()) {
68
+ return /* @__PURE__ */ jsx("span", { className, children: title });
69
+ }
70
+ const sorted = column.getIsSorted();
71
+ let sortIcon;
72
+ if (sorted === "asc") {
73
+ sortIcon = /* @__PURE__ */ jsx(ArrowUp, { className: "ml-1 size-3.5" });
74
+ } else if (sorted === "desc") {
75
+ sortIcon = /* @__PURE__ */ jsx(ArrowDown, { className: "ml-1 size-3.5" });
76
+ } else {
77
+ sortIcon = /* @__PURE__ */ jsx(ArrowUpDown, { className: "ml-1 size-3.5" });
78
+ }
79
+ return /* @__PURE__ */ jsxs(
80
+ Button,
81
+ {
82
+ className: cn("-ml-3 h-8 font-medium text-muted-foreground hover:text-foreground", className),
83
+ onClick: () => {
84
+ column.toggleSorting(sorted === "asc");
85
+ },
86
+ size: "sm",
87
+ variant: "ghost",
88
+ children: [
89
+ title,
90
+ sortIcon
91
+ ]
92
+ }
93
+ );
94
+ }
95
+ function getSelectionColumn() {
96
+ return {
97
+ id: "select",
98
+ header: ({ table }) => /* @__PURE__ */ jsx(
99
+ Checkbox,
100
+ {
101
+ "aria-label": "Select all",
102
+ checked: table.getIsAllPageRowsSelected(),
103
+ indeterminate: table.getIsSomePageRowsSelected() && !table.getIsAllPageRowsSelected(),
104
+ onCheckedChange: (checked) => {
105
+ table.toggleAllPageRowsSelected(Boolean(checked));
106
+ }
107
+ }
108
+ ),
109
+ cell: ({ row }) => /* @__PURE__ */ jsx(
110
+ Checkbox,
111
+ {
112
+ "aria-label": "Select row",
113
+ checked: row.getIsSelected(),
114
+ onCheckedChange: (checked) => {
115
+ row.toggleSelected(Boolean(checked));
116
+ }
117
+ }
118
+ ),
119
+ enableSorting: false,
120
+ enableHiding: false
121
+ };
122
+ }
123
+ function DataTableToolbar({
124
+ table,
125
+ searchKey,
126
+ searchPlaceholder,
127
+ enableColumnVisibility
128
+ }) {
129
+ var _a;
130
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 py-4", "data-slot": "data-table-toolbar", children: [
131
+ /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center gap-2", children: searchKey ? /* @__PURE__ */ jsx(
132
+ Input,
133
+ {
134
+ className: "max-w-xs",
135
+ onChange: (e) => {
136
+ var _a2;
137
+ return (_a2 = table.getColumn(searchKey)) == null ? void 0 : _a2.setFilterValue(e.target.value);
138
+ },
139
+ placeholder: searchPlaceholder != null ? searchPlaceholder : `Filter ${searchKey}...`,
140
+ value: (_a = table.getColumn(searchKey)) == null ? void 0 : _a.getFilterValue()
141
+ }
142
+ ) : null }),
143
+ enableColumnVisibility ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
144
+ /* @__PURE__ */ jsxs(
145
+ DropdownMenuTrigger,
146
+ {
147
+ render: /* @__PURE__ */ jsx(Button, { className: "ml-auto h-8 gap-1.5", size: "sm", variant: "outline" }),
148
+ children: [
149
+ /* @__PURE__ */ jsx(SlidersHorizontal, { className: "size-3.5" }),
150
+ /* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: "Columns" })
151
+ ]
152
+ }
153
+ ),
154
+ /* @__PURE__ */ jsx(DropdownMenuContent, { children: /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
155
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: "Toggle columns" }),
156
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
157
+ table.getAllColumns().filter((col) => col.getCanHide()).map((col) => /* @__PURE__ */ jsx(
158
+ DropdownMenuCheckboxItem,
159
+ {
160
+ checked: col.getIsVisible(),
161
+ className: "capitalize",
162
+ onCheckedChange: (value) => {
163
+ col.toggleVisibility(Boolean(value));
164
+ },
165
+ children: col.id
166
+ },
167
+ col.id
168
+ ))
169
+ ] }) })
170
+ ] }) : null
171
+ ] });
172
+ }
173
+ function DataTablePagination({
174
+ table,
175
+ pageSizeOptions = [10, 20, 30, 50]
176
+ }) {
177
+ return /* @__PURE__ */ jsxs(
178
+ "div",
179
+ {
180
+ className: "flex items-center justify-between gap-4 py-4",
181
+ "data-slot": "data-table-pagination",
182
+ children: [
183
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: table.getFilteredSelectedRowModel().rows.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
184
+ table.getFilteredSelectedRowModel().rows.length,
185
+ " of",
186
+ " ",
187
+ table.getFilteredRowModel().rows.length,
188
+ " row(s) selected."
189
+ ] }) }),
190
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-6", children: [
191
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
192
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground whitespace-nowrap", children: "Rows per page" }),
193
+ /* @__PURE__ */ jsxs(
194
+ Select,
195
+ {
196
+ onValueChange: (value) => {
197
+ table.setPageSize(Number(value));
198
+ },
199
+ value: `${table.getState().pagination.pageSize}`,
200
+ children: [
201
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-[70px]", size: "sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: `${table.getState().pagination.pageSize}` }) }),
202
+ /* @__PURE__ */ jsx(SelectContent, { children: pageSizeOptions.map((pageSize) => /* @__PURE__ */ jsx(SelectItem, { value: `${pageSize}`, children: pageSize }, pageSize)) })
203
+ ]
204
+ }
205
+ )
206
+ ] }),
207
+ /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground whitespace-nowrap", children: [
208
+ "Page ",
209
+ table.getState().pagination.pageIndex + 1,
210
+ " of ",
211
+ table.getPageCount()
212
+ ] }),
213
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
214
+ /* @__PURE__ */ jsx(
215
+ Button,
216
+ {
217
+ "aria-label": "Go to first page",
218
+ disabled: !table.getCanPreviousPage(),
219
+ onClick: () => {
220
+ table.setPageIndex(0);
221
+ },
222
+ size: "icon-sm",
223
+ variant: "outline",
224
+ children: /* @__PURE__ */ jsx(ChevronsLeftIcon, { className: "size-4" })
225
+ }
226
+ ),
227
+ /* @__PURE__ */ jsx(
228
+ Button,
229
+ {
230
+ "aria-label": "Go to previous page",
231
+ disabled: !table.getCanPreviousPage(),
232
+ onClick: () => {
233
+ table.previousPage();
234
+ },
235
+ size: "icon-sm",
236
+ variant: "outline",
237
+ children: /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "size-4" })
238
+ }
239
+ ),
240
+ /* @__PURE__ */ jsx(
241
+ Button,
242
+ {
243
+ "aria-label": "Go to next page",
244
+ disabled: !table.getCanNextPage(),
245
+ onClick: () => {
246
+ table.nextPage();
247
+ },
248
+ size: "icon-sm",
249
+ variant: "outline",
250
+ children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "size-4" })
251
+ }
252
+ ),
253
+ /* @__PURE__ */ jsx(
254
+ Button,
255
+ {
256
+ "aria-label": "Go to last page",
257
+ disabled: !table.getCanNextPage(),
258
+ onClick: () => {
259
+ table.setPageIndex(table.getPageCount() - 1);
260
+ },
261
+ size: "icon-sm",
262
+ variant: "outline",
263
+ children: /* @__PURE__ */ jsx(ChevronsRightIcon, { className: "size-4" })
264
+ }
265
+ )
266
+ ] })
267
+ ] })
268
+ ]
269
+ }
270
+ );
271
+ }
272
+ function DataTableSkeleton({
273
+ columnCount,
274
+ rowCount = 5
275
+ }) {
276
+ return /* @__PURE__ */ jsx(Fragment, { children: Array.from({ length: rowCount }).map((_, rowIdx) => /* @__PURE__ */ jsx(TableRow, { children: Array.from({ length: columnCount }).map((_inner, colIdx) => /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-3/4" }) }, `skeleton-cell-${String(rowIdx)}-${String(colIdx)}`)) }, `skeleton-row-${String(rowIdx)}`)) });
277
+ }
278
+ function DataTable({
279
+ columns: userColumns,
280
+ data,
281
+ searchKey,
282
+ searchPlaceholder,
283
+ enableRowSelection = false,
284
+ enableColumnVisibility = false,
285
+ pageSizeOptions = [10, 20, 30, 50],
286
+ loading = false,
287
+ skeletonRows = 5,
288
+ onRowSelectionChange,
289
+ className,
290
+ toolbar,
291
+ emptyText = "No results."
292
+ }) {
293
+ const [sorting, setSorting] = React.useState([]);
294
+ const [columnFilters, setColumnFilters] = React.useState([]);
295
+ const [columnVisibility, setColumnVisibility] = React.useState({});
296
+ const [rowSelection, setRowSelection] = React.useState({});
297
+ const resolvedColumns = React.useMemo(() => {
298
+ if (!enableRowSelection) return userColumns;
299
+ return [getSelectionColumn(), ...userColumns];
300
+ }, [userColumns, enableRowSelection]);
301
+ const table = useReactTable({
302
+ data,
303
+ columns: resolvedColumns,
304
+ state: {
305
+ sorting,
306
+ columnFilters,
307
+ columnVisibility,
308
+ rowSelection
309
+ },
310
+ onSortingChange: setSorting,
311
+ onColumnFiltersChange: setColumnFilters,
312
+ onColumnVisibilityChange: setColumnVisibility,
313
+ onRowSelectionChange: (updater) => {
314
+ const next = typeof updater === "function" ? updater(rowSelection) : updater;
315
+ setRowSelection(next);
316
+ onRowSelectionChange == null ? void 0 : onRowSelectionChange(next);
317
+ },
318
+ getCoreRowModel: getCoreRowModel(),
319
+ getFilteredRowModel: getFilteredRowModel(),
320
+ getPaginationRowModel: getPaginationRowModel(),
321
+ getSortedRowModel: getSortedRowModel(),
322
+ enableRowSelection
323
+ });
324
+ function renderTableBody() {
325
+ if (loading) {
326
+ return /* @__PURE__ */ jsx(DataTableSkeleton, { columnCount: resolvedColumns.length, rowCount: skeletonRows });
327
+ }
328
+ if (table.getRowModel().rows.length) {
329
+ return /* @__PURE__ */ jsx(Fragment, { children: table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx(
330
+ TableRow,
331
+ {
332
+ "data-state": row.getIsSelected() ? "selected" : void 0,
333
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(TableCell, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
334
+ },
335
+ row.id
336
+ )) });
337
+ }
338
+ return /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(
339
+ TableCell,
340
+ {
341
+ className: "h-24 text-center text-muted-foreground",
342
+ colSpan: resolvedColumns.length,
343
+ children: emptyText
344
+ }
345
+ ) });
346
+ }
347
+ return /* @__PURE__ */ jsxs("div", { className: cn("w-full font-sans", className), "data-slot": "data-table", children: [
348
+ toolbar ? toolbar(table) : (searchKey || enableColumnVisibility) && /* @__PURE__ */ jsx(
349
+ DataTableToolbar,
350
+ {
351
+ enableColumnVisibility,
352
+ searchKey,
353
+ searchPlaceholder,
354
+ table
355
+ }
356
+ ),
357
+ /* @__PURE__ */ jsx("div", { className: "border border-border", children: /* @__PURE__ */ jsxs(Table, { children: [
358
+ /* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx(TableHead, { children: header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()) }, header.id)) }, headerGroup.id)) }),
359
+ /* @__PURE__ */ jsx(TableBody, { children: renderTableBody() })
360
+ ] }) }),
361
+ /* @__PURE__ */ jsx(DataTablePagination, { pageSizeOptions, table })
362
+ ] });
363
+ }
364
+
365
+ export {
366
+ DataTableColumnHeader,
367
+ getSelectionColumn,
368
+ DataTableToolbar,
369
+ DataTablePagination,
370
+ DataTableSkeleton,
371
+ DataTable
372
+ };