@mdigital_ui/ui 0.1.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 (205) hide show
  1. package/README.md +296 -0
  2. package/dist/accordion/index.js +5 -0
  3. package/dist/accordion/index.js.map +1 -0
  4. package/dist/badge/index.js +5 -0
  5. package/dist/badge/index.js.map +1 -0
  6. package/dist/button/index.js +6 -0
  7. package/dist/button/index.js.map +1 -0
  8. package/dist/card/index.js +4 -0
  9. package/dist/card/index.js.map +1 -0
  10. package/dist/carousel/index.js +3 -0
  11. package/dist/carousel/index.js.map +1 -0
  12. package/dist/cascader/index.js +4 -0
  13. package/dist/cascader/index.js.map +1 -0
  14. package/dist/chart/index.js +4 -0
  15. package/dist/chart/index.js.map +1 -0
  16. package/dist/checkbox/index.js +5 -0
  17. package/dist/checkbox/index.js.map +1 -0
  18. package/dist/checkbox-group/index.js +4 -0
  19. package/dist/checkbox-group/index.js.map +1 -0
  20. package/dist/chunk-2JGAYDZR.js +181 -0
  21. package/dist/chunk-2JGAYDZR.js.map +1 -0
  22. package/dist/chunk-3PFA3YG6.js +228 -0
  23. package/dist/chunk-3PFA3YG6.js.map +1 -0
  24. package/dist/chunk-4OMLQCUV.js +96 -0
  25. package/dist/chunk-4OMLQCUV.js.map +1 -0
  26. package/dist/chunk-4P5EMRFI.js +298 -0
  27. package/dist/chunk-4P5EMRFI.js.map +1 -0
  28. package/dist/chunk-5UEWVFF6.js +212 -0
  29. package/dist/chunk-5UEWVFF6.js.map +1 -0
  30. package/dist/chunk-5VCGW53O.js +332 -0
  31. package/dist/chunk-5VCGW53O.js.map +1 -0
  32. package/dist/chunk-75XESYGN.js +49 -0
  33. package/dist/chunk-75XESYGN.js.map +1 -0
  34. package/dist/chunk-7AEGBABZ.js +1102 -0
  35. package/dist/chunk-7AEGBABZ.js.map +1 -0
  36. package/dist/chunk-AOITJRSV.js +134 -0
  37. package/dist/chunk-AOITJRSV.js.map +1 -0
  38. package/dist/chunk-AWPKZYHT.js +152 -0
  39. package/dist/chunk-AWPKZYHT.js.map +1 -0
  40. package/dist/chunk-BNILRB4T.js +37 -0
  41. package/dist/chunk-BNILRB4T.js.map +1 -0
  42. package/dist/chunk-BP434VYV.js +448 -0
  43. package/dist/chunk-BP434VYV.js.map +1 -0
  44. package/dist/chunk-C7SXY3ZV.js +65 -0
  45. package/dist/chunk-C7SXY3ZV.js.map +1 -0
  46. package/dist/chunk-CLLQDCDR.js +560 -0
  47. package/dist/chunk-CLLQDCDR.js.map +1 -0
  48. package/dist/chunk-CWHFK7ZC.js +128 -0
  49. package/dist/chunk-CWHFK7ZC.js.map +1 -0
  50. package/dist/chunk-D3JWPGCA.js +123 -0
  51. package/dist/chunk-D3JWPGCA.js.map +1 -0
  52. package/dist/chunk-DOKTHDG3.js +55 -0
  53. package/dist/chunk-DOKTHDG3.js.map +1 -0
  54. package/dist/chunk-DPOSWW22.js +126 -0
  55. package/dist/chunk-DPOSWW22.js.map +1 -0
  56. package/dist/chunk-E2CYDDYC.js +39 -0
  57. package/dist/chunk-E2CYDDYC.js.map +1 -0
  58. package/dist/chunk-EYTOKUBM.js +401 -0
  59. package/dist/chunk-EYTOKUBM.js.map +1 -0
  60. package/dist/chunk-FGWSUPVW.js +356 -0
  61. package/dist/chunk-FGWSUPVW.js.map +1 -0
  62. package/dist/chunk-FPOXTCYV.js +166 -0
  63. package/dist/chunk-FPOXTCYV.js.map +1 -0
  64. package/dist/chunk-FTJOSVTY.js +104 -0
  65. package/dist/chunk-FTJOSVTY.js.map +1 -0
  66. package/dist/chunk-FYHQDFKE.js +164 -0
  67. package/dist/chunk-FYHQDFKE.js.map +1 -0
  68. package/dist/chunk-H2HIBD5Y.js +158 -0
  69. package/dist/chunk-H2HIBD5Y.js.map +1 -0
  70. package/dist/chunk-J3G5WWGR.js +53 -0
  71. package/dist/chunk-J3G5WWGR.js.map +1 -0
  72. package/dist/chunk-JZCHZ4B3.js +487 -0
  73. package/dist/chunk-JZCHZ4B3.js.map +1 -0
  74. package/dist/chunk-KBCBVH7B.js +51 -0
  75. package/dist/chunk-KBCBVH7B.js.map +1 -0
  76. package/dist/chunk-KNQ7UQ2W.js +143 -0
  77. package/dist/chunk-KNQ7UQ2W.js.map +1 -0
  78. package/dist/chunk-KTBPIEP2.js +102 -0
  79. package/dist/chunk-KTBPIEP2.js.map +1 -0
  80. package/dist/chunk-L3SP7GHC.js +1023 -0
  81. package/dist/chunk-L3SP7GHC.js.map +1 -0
  82. package/dist/chunk-LBJG2UWT.js +100 -0
  83. package/dist/chunk-LBJG2UWT.js.map +1 -0
  84. package/dist/chunk-MLDX3Z67.js +470 -0
  85. package/dist/chunk-MLDX3Z67.js.map +1 -0
  86. package/dist/chunk-NNSS366W.js +331 -0
  87. package/dist/chunk-NNSS366W.js.map +1 -0
  88. package/dist/chunk-OQANRZPV.js +197 -0
  89. package/dist/chunk-OQANRZPV.js.map +1 -0
  90. package/dist/chunk-OW5A5IIF.js +175 -0
  91. package/dist/chunk-OW5A5IIF.js.map +1 -0
  92. package/dist/chunk-R225A5II.js +187 -0
  93. package/dist/chunk-R225A5II.js.map +1 -0
  94. package/dist/chunk-ROR4E6IE.js +119 -0
  95. package/dist/chunk-ROR4E6IE.js.map +1 -0
  96. package/dist/chunk-RPAQAZTI.js +54 -0
  97. package/dist/chunk-RPAQAZTI.js.map +1 -0
  98. package/dist/chunk-RQBXZKTH.js +452 -0
  99. package/dist/chunk-RQBXZKTH.js.map +1 -0
  100. package/dist/chunk-S5XJXU52.js +178 -0
  101. package/dist/chunk-S5XJXU52.js.map +1 -0
  102. package/dist/chunk-SAVE5ACL.js +324 -0
  103. package/dist/chunk-SAVE5ACL.js.map +1 -0
  104. package/dist/chunk-SERJ3TZE.js +640 -0
  105. package/dist/chunk-SERJ3TZE.js.map +1 -0
  106. package/dist/chunk-SK5ECBBK.js +175 -0
  107. package/dist/chunk-SK5ECBBK.js.map +1 -0
  108. package/dist/chunk-SOV4PE3P.js +218 -0
  109. package/dist/chunk-SOV4PE3P.js.map +1 -0
  110. package/dist/chunk-W7BQYIXF.js +687 -0
  111. package/dist/chunk-W7BQYIXF.js.map +1 -0
  112. package/dist/chunk-XMAH5PDW.js +59 -0
  113. package/dist/chunk-XMAH5PDW.js.map +1 -0
  114. package/dist/chunk-XOBGEMQY.js +94 -0
  115. package/dist/chunk-XOBGEMQY.js.map +1 -0
  116. package/dist/chunk-YNNAOXU5.js +57 -0
  117. package/dist/chunk-YNNAOXU5.js.map +1 -0
  118. package/dist/chunk-YZVSDRJD.js +253 -0
  119. package/dist/chunk-YZVSDRJD.js.map +1 -0
  120. package/dist/collapse/index.js +4 -0
  121. package/dist/collapse/index.js.map +1 -0
  122. package/dist/command/index.js +5 -0
  123. package/dist/command/index.js.map +1 -0
  124. package/dist/date-picker/index.js +5 -0
  125. package/dist/date-picker/index.js.map +1 -0
  126. package/dist/descriptions/index.js +4 -0
  127. package/dist/descriptions/index.js.map +1 -0
  128. package/dist/drawer/index.js +4 -0
  129. package/dist/drawer/index.js.map +1 -0
  130. package/dist/dropdown/index.js +5 -0
  131. package/dist/dropdown/index.js.map +1 -0
  132. package/dist/empty/index.js +4 -0
  133. package/dist/empty/index.js.map +1 -0
  134. package/dist/fetching-overlay/index.js +5 -0
  135. package/dist/fetching-overlay/index.js.map +1 -0
  136. package/dist/image/index.js +4 -0
  137. package/dist/image/index.js.map +1 -0
  138. package/dist/index.d.ts +2672 -0
  139. package/dist/index.js +976 -0
  140. package/dist/index.js.map +1 -0
  141. package/dist/input/index.js +5 -0
  142. package/dist/input/index.js.map +1 -0
  143. package/dist/input-group/index.js +4 -0
  144. package/dist/input-group/index.js.map +1 -0
  145. package/dist/input-otp/index.js +4 -0
  146. package/dist/input-otp/index.js.map +1 -0
  147. package/dist/input-password/index.js +6 -0
  148. package/dist/input-password/index.js.map +1 -0
  149. package/dist/kbd/index.js +4 -0
  150. package/dist/kbd/index.js.map +1 -0
  151. package/dist/modal/index.js +4 -0
  152. package/dist/modal/index.js.map +1 -0
  153. package/dist/multi-select/index.js +5 -0
  154. package/dist/multi-select/index.js.map +1 -0
  155. package/dist/notification/index.js +4 -0
  156. package/dist/notification/index.js.map +1 -0
  157. package/dist/pagination/index.js +4 -0
  158. package/dist/pagination/index.js.map +1 -0
  159. package/dist/popover/index.js +4 -0
  160. package/dist/popover/index.js.map +1 -0
  161. package/dist/progress/index.js +4 -0
  162. package/dist/progress/index.js.map +1 -0
  163. package/dist/radio/index.js +4 -0
  164. package/dist/radio/index.js.map +1 -0
  165. package/dist/radio-group/index.js +4 -0
  166. package/dist/radio-group/index.js.map +1 -0
  167. package/dist/rating/index.js +4 -0
  168. package/dist/rating/index.js.map +1 -0
  169. package/dist/ribbon/index.js +4 -0
  170. package/dist/ribbon/index.js.map +1 -0
  171. package/dist/select/index.js +6 -0
  172. package/dist/select/index.js.map +1 -0
  173. package/dist/skeleton/index.js +4 -0
  174. package/dist/skeleton/index.js.map +1 -0
  175. package/dist/slider/index.js +4 -0
  176. package/dist/slider/index.js.map +1 -0
  177. package/dist/spinner/index.js +4 -0
  178. package/dist/spinner/index.js.map +1 -0
  179. package/dist/stepper/index.js +4 -0
  180. package/dist/stepper/index.js.map +1 -0
  181. package/dist/styles/base.css +161 -0
  182. package/dist/styles/global.css +633 -0
  183. package/dist/styles/themes/dark.css +84 -0
  184. package/dist/styles/themes/light.css +84 -0
  185. package/dist/switch/index.js +4 -0
  186. package/dist/switch/index.js.map +1 -0
  187. package/dist/table/index.js +12 -0
  188. package/dist/table/index.js.map +1 -0
  189. package/dist/tabs/index.js +5 -0
  190. package/dist/tabs/index.js.map +1 -0
  191. package/dist/textarea/index.js +4 -0
  192. package/dist/textarea/index.js.map +1 -0
  193. package/dist/toggle/index.js +4 -0
  194. package/dist/toggle/index.js.map +1 -0
  195. package/dist/toggle-group/index.js +4 -0
  196. package/dist/toggle-group/index.js.map +1 -0
  197. package/dist/tooltip/index.js +4 -0
  198. package/dist/tooltip/index.js.map +1 -0
  199. package/dist/transfer/index.js +6 -0
  200. package/dist/transfer/index.js.map +1 -0
  201. package/dist/tree/index.js +4 -0
  202. package/dist/tree/index.js.map +1 -0
  203. package/dist/tree-select/index.js +6 -0
  204. package/dist/tree-select/index.js.map +1 -0
  205. package/package.json +107 -0
@@ -0,0 +1,1023 @@
1
+ import { toggle_group_default } from './chunk-SK5ECBBK.js';
2
+ import { pagination_default } from './chunk-FGWSUPVW.js';
3
+ import { input_default } from './chunk-2JGAYDZR.js';
4
+ import { checkbox_default } from './chunk-H2HIBD5Y.js';
5
+ import { Popover, PopoverTrigger, PopoverContent } from './chunk-3PFA3YG6.js';
6
+ import { button_default } from './chunk-LBJG2UWT.js';
7
+ import { cn, iconSizes } from './chunk-YNNAOXU5.js';
8
+ import { useReactTable, getGroupedRowModel, getExpandedRowModel, getPaginationRowModel, getFilteredRowModel, getSortedRowModel, getCoreRowModel, flexRender } from '@tanstack/react-table';
9
+ import { useVirtualizer } from '@tanstack/react-virtual';
10
+ import { Search, Columns3, ChevronDown, ChevronsUpDown, PinOff, Pin, ChevronRight, Inbox } from 'lucide-react';
11
+ import { useState, useRef, useEffect, useMemo } from 'react';
12
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
13
+ import { cva } from 'class-variance-authority';
14
+
15
+ function EditableCell({
16
+ value,
17
+ onValueChange,
18
+ size = "md",
19
+ className
20
+ }) {
21
+ const [isEditing, setIsEditing] = useState(false);
22
+ const [editValue, setEditValue] = useState(String(value ?? ""));
23
+ const inputRef = useRef(null);
24
+ const containerRef = useRef(null);
25
+ useEffect(() => {
26
+ if (isEditing && inputRef.current) {
27
+ inputRef.current.focus();
28
+ inputRef.current.select();
29
+ }
30
+ }, [isEditing]);
31
+ useEffect(() => {
32
+ setEditValue(String(value ?? ""));
33
+ }, [value]);
34
+ const handleSave = () => {
35
+ setIsEditing(false);
36
+ if (editValue !== String(value ?? "")) {
37
+ onValueChange(editValue);
38
+ }
39
+ };
40
+ const handleKeyDown = (e) => {
41
+ if (e.key === "Enter") {
42
+ handleSave();
43
+ } else if (e.key === "Escape") {
44
+ setEditValue(String(value ?? ""));
45
+ setIsEditing(false);
46
+ }
47
+ };
48
+ const sizeClasses = {
49
+ xs: "text-xs py-0.5",
50
+ sm: "text-sm py-1",
51
+ md: "text-base py-1.5",
52
+ lg: "text-lg py-2"
53
+ };
54
+ const inputSizeMap = {
55
+ xs: "sm",
56
+ sm: "sm",
57
+ md: "md",
58
+ lg: "lg"
59
+ };
60
+ return /* @__PURE__ */ jsx(
61
+ "div",
62
+ {
63
+ ref: containerRef,
64
+ className: "relative w-full max-w-full overflow-hidden",
65
+ children: isEditing ? /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsx(
66
+ input_default,
67
+ {
68
+ ref: inputRef,
69
+ type: "text",
70
+ value: editValue,
71
+ onChange: (e) => setEditValue(e.target.value),
72
+ onBlur: handleSave,
73
+ onKeyDown: handleKeyDown,
74
+ size: inputSizeMap[size],
75
+ className: cn("w-full min-w-0 max-w-full", className)
76
+ }
77
+ ) }) : /* @__PURE__ */ jsx(
78
+ "div",
79
+ {
80
+ onClick: () => setIsEditing(true),
81
+ className: cn(
82
+ "cursor-text hover:bg-surface/50 rounded transition-colors min-h-[20px] px-3 w-full overflow-hidden text-ellipsis whitespace-nowrap",
83
+ sizeClasses[size],
84
+ className
85
+ ),
86
+ title: "Click to edit",
87
+ children: String(value ?? "")
88
+ }
89
+ )
90
+ }
91
+ );
92
+ }
93
+ EditableCell.displayName = "EditableCell";
94
+ function TableActions({
95
+ searchValue,
96
+ onSearchChange,
97
+ visibleColumns,
98
+ allColumns,
99
+ onVisibleColumnsChange,
100
+ size,
101
+ onSizeChange,
102
+ color = "default"
103
+ }) {
104
+ const handleColumnToggle = (columnId) => {
105
+ if (visibleColumns.includes(columnId)) {
106
+ onVisibleColumnsChange(visibleColumns.filter((id) => id !== columnId));
107
+ } else {
108
+ onVisibleColumnsChange([...visibleColumns, columnId]);
109
+ }
110
+ };
111
+ const sizeOptions = [
112
+ { value: "sm", label: "SM" },
113
+ { value: "md", label: "MD" },
114
+ { value: "lg", label: "LG" }
115
+ ];
116
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-4 rounded-md", children: [
117
+ /* @__PURE__ */ jsx("div", { className: "w-auto mr-auto", children: /* @__PURE__ */ jsx(
118
+ input_default,
119
+ {
120
+ type: "text",
121
+ placeholder: "Search...",
122
+ value: searchValue,
123
+ onChange: (e) => onSearchChange(e.target.value),
124
+ size: "sm",
125
+ rightIcon: /* @__PURE__ */ jsx(Search, { className: iconSizes[size] })
126
+ }
127
+ ) }),
128
+ /* @__PURE__ */ jsxs(Popover, { children: [
129
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
130
+ button_default,
131
+ {
132
+ variant: "outline",
133
+ size: "sm",
134
+ leftIcon: /* @__PURE__ */ jsx(Columns3, { className: iconSizes[size] }),
135
+ children: "Columns"
136
+ }
137
+ ) }),
138
+ /* @__PURE__ */ jsx(PopoverContent, { className: "w-56 p-2", children: /* @__PURE__ */ jsx("div", { className: "space-y-1 max-h-[300px] overflow-y-auto", children: allColumns.map((col) => /* @__PURE__ */ jsxs(
139
+ "label",
140
+ {
141
+ className: "flex items-center gap-2 px-3 py-2 hover:bg-surface rounded cursor-pointer",
142
+ children: [
143
+ /* @__PURE__ */ jsx(
144
+ checkbox_default,
145
+ {
146
+ checked: visibleColumns.includes(col.id),
147
+ onChange: () => handleColumnToggle(col.id),
148
+ color: color === "default" ? "primary" : color,
149
+ size: "sm"
150
+ }
151
+ ),
152
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-text-primary", children: col.label })
153
+ ]
154
+ },
155
+ col.id
156
+ )) }) })
157
+ ] }),
158
+ /* @__PURE__ */ jsx(
159
+ toggle_group_default,
160
+ {
161
+ options: sizeOptions,
162
+ value: size,
163
+ onChange: (value) => onSizeChange(value),
164
+ color,
165
+ size: "sm",
166
+ variant: "default"
167
+ }
168
+ )
169
+ ] });
170
+ }
171
+ TableActions.displayName = "TableActions";
172
+ cva("w-full border-collapse", {
173
+ variants: {
174
+ variant: {
175
+ outline: "",
176
+ line: "",
177
+ ghost: ""
178
+ }
179
+ },
180
+ defaultVariants: {
181
+ variant: "outline"
182
+ }
183
+ });
184
+ var cellVariants = cva("text-left transition-colors", {
185
+ variants: {
186
+ size: {
187
+ xs: "px-2 py-1 text-xs",
188
+ sm: "px-3 py-2 text-sm",
189
+ md: "px-4 py-3 text-base",
190
+ lg: "px-6 py-4 text-lg"
191
+ }
192
+ },
193
+ defaultVariants: {
194
+ size: "md"
195
+ }
196
+ });
197
+ var TableCell = ({
198
+ size = "md",
199
+ bordered = false,
200
+ fixed,
201
+ className,
202
+ children,
203
+ ...props
204
+ }) => {
205
+ return /* @__PURE__ */ jsx(
206
+ "td",
207
+ {
208
+ className: cn(
209
+ cellVariants({ size }),
210
+ "text-text-primary",
211
+ bordered && "border-r border-border last:border-r-0",
212
+ fixed === "left" && "sticky left-0 bg-background z-10",
213
+ fixed === "right" && "sticky right-0 bg-background z-10",
214
+ className
215
+ ),
216
+ ...props,
217
+ children
218
+ }
219
+ );
220
+ };
221
+ TableCell.displayName = "TableCell";
222
+ function TableHeaderCell({
223
+ header,
224
+ size = "md",
225
+ variant = "outline",
226
+ color = "default",
227
+ bordered = false,
228
+ enableColumnPinning = false,
229
+ className,
230
+ ...props
231
+ }) {
232
+ const isPinnedLeft = header.column.getIsPinned() === "left";
233
+ const isPinnedRight = header.column.getIsPinned() === "right";
234
+ const colorHoverClasses = {
235
+ default: "hover:bg-surface",
236
+ primary: "hover:bg-primary/10",
237
+ secondary: "hover:bg-secondary/10",
238
+ accent: "hover:bg-accent/10",
239
+ success: "hover:bg-success/10",
240
+ error: "hover:bg-error/10",
241
+ warning: "hover:bg-warning/10",
242
+ info: "hover:bg-info/10"
243
+ };
244
+ const colorIconClasses = {
245
+ default: "text-text-primary",
246
+ primary: "text-primary",
247
+ secondary: "text-secondary",
248
+ accent: "text-accent",
249
+ success: "text-success",
250
+ error: "text-error",
251
+ warning: "text-warning",
252
+ info: "text-info"
253
+ };
254
+ return /* @__PURE__ */ jsx(
255
+ "th",
256
+ {
257
+ className: cn(
258
+ cellVariants({ size }),
259
+ "font-semibold text-text-primary border-b border-border relative group",
260
+ variant === "line" && "border-b-2",
261
+ bordered && "border-r border-border last:border-r-0",
262
+ header.column.getCanSort() && "cursor-pointer select-none hover:bg-background",
263
+ isPinnedLeft && "sticky left-0 bg-surface z-20",
264
+ isPinnedRight && "sticky right-0 bg-surface z-20",
265
+ className
266
+ ),
267
+ onClick: header.column.getToggleSortingHandler(),
268
+ ...props,
269
+ children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
270
+ /* @__PURE__ */ jsx("span", { className: "flex-1", children: header.isPlaceholder ? null : typeof header.column.columnDef.header === "function" ? header.column.columnDef.header(header.getContext()) : header.column.columnDef.header }),
271
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
272
+ header.column.getCanSort() && /* @__PURE__ */ jsx(
273
+ "button",
274
+ {
275
+ onClick: (e) => {
276
+ e.stopPropagation();
277
+ header.column.toggleSorting();
278
+ },
279
+ className: cn(
280
+ "p-1 rounded transition-all",
281
+ header.column.getIsSorted() ? `opacity-100 ${colorHoverClasses[color]}` : `opacity-0 group-hover:opacity-100 ${colorHoverClasses[color]}`,
282
+ header.column.getIsSorted() && colorIconClasses[color]
283
+ ),
284
+ children: header.column.getIsSorted() === "asc" ? /* @__PURE__ */ jsx(ChevronDown, { className: "w-3.5 h-3.5 rotate-180" }) : header.column.getIsSorted() === "desc" ? /* @__PURE__ */ jsx(ChevronDown, { className: "w-3.5 h-3.5" }) : /* @__PURE__ */ jsx(ChevronsUpDown, { className: "w-3.5 h-3.5" })
285
+ }
286
+ ),
287
+ enableColumnPinning && header.column.getCanPin() && /* @__PURE__ */ jsx(
288
+ "button",
289
+ {
290
+ onClick: (e) => {
291
+ e.stopPropagation();
292
+ const isPinned = header.column.getIsPinned();
293
+ if (isPinned) {
294
+ header.column.pin(false);
295
+ } else {
296
+ header.column.pin("left");
297
+ }
298
+ },
299
+ className: cn(
300
+ "p-1 rounded transition-all",
301
+ isPinnedLeft || isPinnedRight ? `opacity-100 ${colorHoverClasses[color]} ${colorIconClasses[color]}` : `opacity-0 group-hover:opacity-100 ${colorHoverClasses[color]}`
302
+ ),
303
+ children: isPinnedLeft || isPinnedRight ? /* @__PURE__ */ jsx(PinOff, { className: "w-3.5 h-3.5" }) : /* @__PURE__ */ jsx(Pin, { className: "w-3.5 h-3.5" })
304
+ }
305
+ )
306
+ ] })
307
+ ] })
308
+ }
309
+ );
310
+ }
311
+ TableHeaderCell.displayName = "TableHeaderCell";
312
+ function TableRow({
313
+ row,
314
+ index,
315
+ striped = false,
316
+ hoverable = true,
317
+ onRowClick,
318
+ isPinned = false,
319
+ isExpanded = false,
320
+ className,
321
+ children,
322
+ ...props
323
+ }) {
324
+ const handleKeyDown = (e) => {
325
+ if (onRowClick && (e.key === "Enter" || e.key === " ")) {
326
+ e.preventDefault();
327
+ onRowClick(row.original);
328
+ }
329
+ };
330
+ return /* @__PURE__ */ jsx(
331
+ "tr",
332
+ {
333
+ className: cn(
334
+ "border-b border-border last:border-b-0",
335
+ striped && index % 2 === 1 && "bg-surface/50",
336
+ hoverable && "hover:bg-surface cursor-pointer",
337
+ onRowClick && "cursor-pointer",
338
+ isPinned && "bg-primary/5 border-primary/20",
339
+ row.getIsSelected() && "bg-primary/10",
340
+ className
341
+ ),
342
+ onClick: () => onRowClick?.(row.original),
343
+ onKeyDown: handleKeyDown,
344
+ tabIndex: onRowClick ? 0 : void 0,
345
+ role: onRowClick ? "button" : void 0,
346
+ ...props,
347
+ children
348
+ }
349
+ );
350
+ }
351
+ TableRow.displayName = "TableRow";
352
+ var TableSkeleton = ({
353
+ rows = 5,
354
+ columns,
355
+ size = "md"
356
+ }) => {
357
+ return /* @__PURE__ */ jsx(Fragment, { children: Array.from({ length: rows }).map((_, rowIndex) => /* @__PURE__ */ jsx(
358
+ "tr",
359
+ {
360
+ className: "border-b border-border",
361
+ children: Array.from({ length: columns }).map((_2, colIndex) => /* @__PURE__ */ jsx(
362
+ "td",
363
+ {
364
+ className: cn(cellVariants({ size })),
365
+ children: /* @__PURE__ */ jsx("div", { className: "animate-pulse", children: /* @__PURE__ */ jsx("div", { className: "h-4 bg-surface rounded w-full" }) })
366
+ },
367
+ colIndex
368
+ ))
369
+ },
370
+ rowIndex
371
+ )) });
372
+ };
373
+ TableSkeleton.displayName = "TableSkeleton";
374
+ function Table({
375
+ data,
376
+ columns,
377
+ columnGroups,
378
+ variant = "outline",
379
+ size: initialSize = "md",
380
+ color = "default",
381
+ striped = false,
382
+ hoverable = true,
383
+ bordered = false,
384
+ enableSorting = true,
385
+ enableFiltering = false,
386
+ enablePagination = false,
387
+ enableRowSelection = false,
388
+ enableMultiRowSelection = true,
389
+ enableRowPinning = false,
390
+ enableExpandable = false,
391
+ enableGrouping = false,
392
+ enableVirtualization = false,
393
+ enableClickToSelect = false,
394
+ enableColumnPinning = false,
395
+ enableActions = false,
396
+ paginationPosition = "bottomcenter",
397
+ expandedContent,
398
+ footer,
399
+ emptyState,
400
+ loading = false,
401
+ loadingRows = 5,
402
+ pageSize = 10,
403
+ pageSizeOptions = [5, 10, 20, 50],
404
+ onRowClick,
405
+ onSelectionChange,
406
+ onCellEdit,
407
+ pinnedRowIds = [],
408
+ onPinnedRowsChange,
409
+ className
410
+ }) {
411
+ const [sorting, setSorting] = useState([]);
412
+ const [columnFilters, setColumnFilters] = useState([]);
413
+ const [rowSelection, setRowSelection] = useState({});
414
+ const [expanded, setExpanded] = useState({});
415
+ const [grouping, setGrouping] = useState([]);
416
+ const [pinnedRows, setPinnedRows] = useState(pinnedRowIds);
417
+ const [columnPinning, setColumnPinning] = useState({
418
+ left: [],
419
+ right: []
420
+ });
421
+ const [columnVisibility, setColumnVisibility] = useState({});
422
+ const [searchValue, setSearchValue] = useState("");
423
+ const [size, setSize] = useState(initialSize);
424
+ const tableContainerRef = useRef(null);
425
+ const prevAutoPinnedIdsRef = useRef("");
426
+ const autoPinnedIds = useMemo(() => {
427
+ if (!enableRowPinning || data.length === 0) return [];
428
+ return data.map((row, index) => ({ row, id: String(index) })).filter(({ row }) => row.pin === true).map(({ id }) => id);
429
+ }, [data, enableRowPinning]);
430
+ useEffect(() => {
431
+ if (autoPinnedIds.length > 0) {
432
+ const combinedPinnedIds = [
433
+ .../* @__PURE__ */ new Set([...pinnedRowIds, ...autoPinnedIds])
434
+ ];
435
+ const autoPinnedIdsStr = autoPinnedIds.sort().join(",");
436
+ if (autoPinnedIdsStr !== prevAutoPinnedIdsRef.current) {
437
+ prevAutoPinnedIdsRef.current = autoPinnedIdsStr;
438
+ setPinnedRows(combinedPinnedIds);
439
+ }
440
+ }
441
+ }, [autoPinnedIds, pinnedRowIds]);
442
+ useEffect(() => {
443
+ if (enableColumnPinning && columns.length > 0) {
444
+ const leftPinned = columns.filter((col) => col.pin === "left").map(
445
+ (col) => col.id || col.accessorKey
446
+ );
447
+ const rightPinned = columns.filter((col) => col.pin === "right").map(
448
+ (col) => col.id || col.accessorKey
449
+ );
450
+ if (leftPinned.length > 0 || rightPinned.length > 0) {
451
+ setColumnPinning({
452
+ left: leftPinned,
453
+ right: rightPinned
454
+ });
455
+ }
456
+ }
457
+ }, [columns, enableColumnPinning]);
458
+ const enhancedColumns = useMemo(
459
+ () => enableRowSelection ? [
460
+ {
461
+ id: "select",
462
+ header: ({ table: table2 }) => enableMultiRowSelection ? /* @__PURE__ */ jsx(
463
+ checkbox_default,
464
+ {
465
+ checked: table2.getIsAllRowsSelected(),
466
+ indeterminate: table2.getIsSomeRowsSelected(),
467
+ onChange: table2.getToggleAllRowsSelectedHandler(),
468
+ size: "sm"
469
+ }
470
+ ) : null,
471
+ cell: ({ row }) => /* @__PURE__ */ jsx(
472
+ checkbox_default,
473
+ {
474
+ checked: row.getIsSelected(),
475
+ disabled: !row.getCanSelect(),
476
+ onChange: row.getToggleSelectedHandler(),
477
+ size: "sm"
478
+ }
479
+ ),
480
+ size: 50
481
+ },
482
+ ...columns
483
+ ] : columns,
484
+ [columns, enableRowSelection, enableMultiRowSelection]
485
+ );
486
+ const finalColumns = useMemo(
487
+ () => enableExpandable ? [
488
+ {
489
+ id: "expand",
490
+ header: () => null,
491
+ cell: ({ row }) => /* @__PURE__ */ jsx(
492
+ "button",
493
+ {
494
+ onClick: (e) => {
495
+ e.stopPropagation();
496
+ row.toggleExpanded();
497
+ },
498
+ className: "text-text-muted hover:text-text-primary transition-colors",
499
+ "aria-label": row.getIsExpanded() ? "Collapse row" : "Expand row",
500
+ "aria-expanded": row.getIsExpanded(),
501
+ children: row.getIsExpanded() ? /* @__PURE__ */ jsx(
502
+ ChevronDown,
503
+ {
504
+ className: iconSizes[size],
505
+ "aria-hidden": "true"
506
+ }
507
+ ) : /* @__PURE__ */ jsx(
508
+ ChevronRight,
509
+ {
510
+ className: iconSizes[size],
511
+ "aria-hidden": "true"
512
+ }
513
+ )
514
+ }
515
+ ),
516
+ size: 50
517
+ },
518
+ ...enhancedColumns
519
+ ] : enhancedColumns,
520
+ [enhancedColumns, enableExpandable]
521
+ );
522
+ const columnsWithPinning = useMemo(
523
+ () => enableRowPinning ? [
524
+ ...finalColumns,
525
+ {
526
+ id: "pin",
527
+ header: () => /* @__PURE__ */ jsx(Pin, { className: "w-4 h-4 text-text-muted" }),
528
+ cell: ({ row }) => {
529
+ const rowId = row.id;
530
+ const isPinned = pinnedRows.includes(rowId);
531
+ return /* @__PURE__ */ jsx(
532
+ "button",
533
+ {
534
+ onClick: (e) => {
535
+ e.stopPropagation();
536
+ const newPinnedRows = isPinned ? pinnedRows.filter((id) => id !== rowId) : [...pinnedRows, rowId];
537
+ setPinnedRows(newPinnedRows);
538
+ onPinnedRowsChange?.(newPinnedRows);
539
+ },
540
+ className: cn(
541
+ "text-text-muted hover:text-text-primary transition-colors",
542
+ isPinned && "text-primary"
543
+ ),
544
+ "aria-label": isPinned ? "Unpin row" : "Pin row",
545
+ "aria-pressed": isPinned,
546
+ children: isPinned ? /* @__PURE__ */ jsx(
547
+ PinOff,
548
+ {
549
+ className: iconSizes[size],
550
+ "aria-hidden": "true"
551
+ }
552
+ ) : /* @__PURE__ */ jsx(
553
+ Pin,
554
+ {
555
+ className: iconSizes[size],
556
+ "aria-hidden": "true"
557
+ }
558
+ )
559
+ }
560
+ );
561
+ },
562
+ size: 50
563
+ }
564
+ ] : finalColumns,
565
+ [finalColumns, enableRowPinning, pinnedRows, onPinnedRowsChange]
566
+ );
567
+ const columnsWithEditable = useMemo(
568
+ () => columnsWithPinning.map((col) => {
569
+ const colAny = col;
570
+ if (colAny.editable && onCellEdit) {
571
+ return {
572
+ ...col,
573
+ cell: ({ row, getValue }) => {
574
+ const value = getValue?.() ?? row.original[colAny.accessorKey];
575
+ return /* @__PURE__ */ jsx(
576
+ EditableCell,
577
+ {
578
+ value,
579
+ size,
580
+ onValueChange: (newValue) => {
581
+ onCellEdit({
582
+ rowIndex: row.index,
583
+ columnId: colAny.id || colAny.accessorKey,
584
+ value: newValue,
585
+ row: row.original
586
+ });
587
+ }
588
+ }
589
+ );
590
+ }
591
+ };
592
+ }
593
+ return col;
594
+ }),
595
+ [columnsWithPinning, onCellEdit, size]
596
+ );
597
+ const filteredData = useMemo(() => {
598
+ if (!enableActions || !searchValue.trim()) {
599
+ return data;
600
+ }
601
+ const searchLower = searchValue.toLowerCase();
602
+ return data.filter((row) => {
603
+ return Object.values(row).some(
604
+ (value) => String(value).toLowerCase().includes(searchLower)
605
+ );
606
+ });
607
+ }, [data, searchValue, enableActions]);
608
+ const allColumnsList = useMemo(() => {
609
+ return columns.map((col) => {
610
+ const colAny = col;
611
+ return {
612
+ id: col.id || colAny.accessorKey,
613
+ label: typeof colAny.header === "string" ? colAny.header : col.id || colAny.accessorKey
614
+ };
615
+ });
616
+ }, [columns]);
617
+ const visibleColumnIds = useMemo(() => {
618
+ return Object.keys(columnVisibility).length === 0 ? allColumnsList.map((c) => c.id) : allColumnsList.filter((c) => columnVisibility[c.id] !== false).map((c) => c.id);
619
+ }, [columnVisibility, allColumnsList]);
620
+ const table = useReactTable({
621
+ data: filteredData,
622
+ columns: columnsWithEditable,
623
+ getCoreRowModel: getCoreRowModel(),
624
+ getSortedRowModel: enableSorting ? getSortedRowModel() : void 0,
625
+ getFilteredRowModel: enableFiltering ? getFilteredRowModel() : void 0,
626
+ getPaginationRowModel: enablePagination && !enableVirtualization ? getPaginationRowModel() : void 0,
627
+ getExpandedRowModel: enableExpandable ? getExpandedRowModel() : void 0,
628
+ getGroupedRowModel: enableGrouping ? getGroupedRowModel() : void 0,
629
+ onSortingChange: setSorting,
630
+ onColumnFiltersChange: setColumnFilters,
631
+ onRowSelectionChange: setRowSelection,
632
+ onExpandedChange: setExpanded,
633
+ onGroupingChange: setGrouping,
634
+ onColumnPinningChange: setColumnPinning,
635
+ onColumnVisibilityChange: setColumnVisibility,
636
+ enableRowSelection,
637
+ enableMultiRowSelection,
638
+ enableGrouping,
639
+ enableColumnPinning,
640
+ getRowCanExpand: enableExpandable ? () => true : void 0,
641
+ state: {
642
+ sorting,
643
+ columnFilters,
644
+ rowSelection,
645
+ expanded,
646
+ grouping,
647
+ columnPinning,
648
+ columnVisibility
649
+ },
650
+ initialState: {
651
+ pagination: {
652
+ pageSize
653
+ }
654
+ }
655
+ });
656
+ useEffect(() => {
657
+ if (onSelectionChange) {
658
+ const selectedRows = table.getSelectedRowModel().rows.map((row) => row.original);
659
+ onSelectionChange(selectedRows);
660
+ }
661
+ }, [rowSelection, onSelectionChange, table]);
662
+ const rows = table.getRowModel().rows;
663
+ const pinnedRowsData = rows.filter((row) => pinnedRows.includes(row.id));
664
+ const unpinnedRows = rows.filter((row) => !pinnedRows.includes(row.id));
665
+ const allRowsOrdered = [...pinnedRowsData, ...unpinnedRows];
666
+ const rowVirtualizer = useVirtualizer({
667
+ count: allRowsOrdered.length,
668
+ getScrollElement: () => tableContainerRef.current,
669
+ estimateSize: () => size === "sm" ? 44 : size === "lg" ? 68 : 56,
670
+ overscan: 5,
671
+ enabled: enableVirtualization
672
+ });
673
+ const handleRowClick = (row, rowData) => {
674
+ if (enableClickToSelect && enableRowSelection) {
675
+ row.toggleSelected();
676
+ }
677
+ onRowClick?.(rowData);
678
+ };
679
+ const columnGroupsMap = /* @__PURE__ */ new Map();
680
+ if (columnGroups) {
681
+ columnGroups.forEach((group) => {
682
+ group.columns.forEach((colId) => {
683
+ columnGroupsMap.set(colId, {
684
+ header: group.header,
685
+ span: group.columns.length
686
+ });
687
+ });
688
+ });
689
+ }
690
+ const renderColumnGroups = () => {
691
+ if (!columnGroups || columnGroups.length === 0) return null;
692
+ const headerGroups = table.getHeaderGroups()[0];
693
+ if (!headerGroups) return null;
694
+ const groupedHeaders = [];
695
+ const processedCols = /* @__PURE__ */ new Set();
696
+ headerGroups.headers.forEach((header, index) => {
697
+ const colId = header.column.id;
698
+ if (processedCols.has(colId)) return;
699
+ const group = columnGroups.find((g) => g.columns.includes(colId));
700
+ if (group) {
701
+ group.columns.forEach((c) => processedCols.add(c));
702
+ groupedHeaders.push({
703
+ header: group.header,
704
+ span: group.columns.length,
705
+ startIndex: index
706
+ });
707
+ } else {
708
+ groupedHeaders.push({
709
+ header: "",
710
+ span: 1,
711
+ startIndex: index
712
+ });
713
+ }
714
+ });
715
+ return /* @__PURE__ */ jsx("tr", { className: "border-b border-border", children: groupedHeaders.map((group, idx) => /* @__PURE__ */ jsx(
716
+ "th",
717
+ {
718
+ colSpan: group.span,
719
+ className: cn(
720
+ cellVariants({ size }),
721
+ "font-bold text-text-primary bg-surface/70 border-border text-center",
722
+ bordered && "border-r border-border last:border-r-0"
723
+ ),
724
+ children: group.header
725
+ },
726
+ idx
727
+ )) });
728
+ };
729
+ const renderRows = () => {
730
+ if (loading) {
731
+ return /* @__PURE__ */ jsx(
732
+ TableSkeleton,
733
+ {
734
+ rows: loadingRows,
735
+ columns: columnsWithPinning.length,
736
+ size
737
+ }
738
+ );
739
+ }
740
+ if (allRowsOrdered.length === 0) {
741
+ return /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
742
+ "td",
743
+ {
744
+ colSpan: columnsWithPinning.length,
745
+ className: "px-4 py-12 text-center",
746
+ children: emptyState || /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-2 text-text-muted", children: [
747
+ /* @__PURE__ */ jsx(Inbox, { className: "w-12 h-12 opacity-20" }),
748
+ /* @__PURE__ */ jsx("p", { className: "text-sm", children: "No data available" })
749
+ ] })
750
+ }
751
+ ) });
752
+ }
753
+ if (enableVirtualization) {
754
+ const virtualRows = rowVirtualizer.getVirtualItems();
755
+ const paddingTop = virtualRows.length > 0 ? virtualRows[0]?.start || 0 : 0;
756
+ const paddingBottom = virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (virtualRows[virtualRows.length - 1]?.end || 0) : 0;
757
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
758
+ paddingTop > 0 && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
759
+ "td",
760
+ {
761
+ colSpan: columnsWithPinning.length,
762
+ style: { height: `${paddingTop}px`, padding: 0, border: 0 }
763
+ }
764
+ ) }),
765
+ virtualRows.map((virtualRow) => {
766
+ const row = allRowsOrdered[virtualRow.index];
767
+ if (!row) return null;
768
+ const isLastVirtualRow = virtualRow.index === allRowsOrdered.length - 1;
769
+ return /* @__PURE__ */ jsx(
770
+ TableRow,
771
+ {
772
+ row,
773
+ index: virtualRow.index,
774
+ striped,
775
+ hoverable,
776
+ onRowClick: () => handleRowClick(row, row.original),
777
+ isPinned: pinnedRows.includes(row.id),
778
+ className: cn(isLastVirtualRow && "border-b-0"),
779
+ children: row.getVisibleCells().map((cell) => {
780
+ const isPinnedLeft = cell.column.getIsPinned() === "left";
781
+ const isPinnedRight = cell.column.getIsPinned() === "right";
782
+ return /* @__PURE__ */ jsx(
783
+ TableCell,
784
+ {
785
+ size,
786
+ bordered,
787
+ fixed: isPinnedLeft ? "left" : isPinnedRight ? "right" : void 0,
788
+ children: cell.getIsGrouped() ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
789
+ /* @__PURE__ */ jsx(
790
+ "button",
791
+ {
792
+ onClick: (e) => {
793
+ e.stopPropagation();
794
+ row.toggleExpanded();
795
+ },
796
+ className: "text-text-muted hover:text-text-primary",
797
+ children: row.getIsExpanded() ? /* @__PURE__ */ jsx(ChevronDown, { className: iconSizes[size] }) : /* @__PURE__ */ jsx(ChevronRight, { className: iconSizes[size] })
798
+ }
799
+ ),
800
+ flexRender(
801
+ cell.column.columnDef.cell,
802
+ cell.getContext()
803
+ ),
804
+ " ",
805
+ "(",
806
+ row.subRows.length,
807
+ ")"
808
+ ] }) : cell.getIsAggregated() ? flexRender(
809
+ cell.column.columnDef.aggregatedCell ?? cell.column.columnDef.cell,
810
+ cell.getContext()
811
+ ) : cell.getIsPlaceholder() ? null : flexRender(
812
+ cell.column.columnDef.cell,
813
+ cell.getContext()
814
+ )
815
+ },
816
+ cell.id
817
+ );
818
+ })
819
+ },
820
+ row.id
821
+ );
822
+ }),
823
+ paddingBottom > 0 && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
824
+ "td",
825
+ {
826
+ colSpan: columnsWithPinning.length,
827
+ style: { height: `${paddingBottom}px`, padding: 0, border: 0 }
828
+ }
829
+ ) })
830
+ ] });
831
+ }
832
+ return allRowsOrdered.map((row, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
833
+ /* @__PURE__ */ jsx(
834
+ TableRow,
835
+ {
836
+ row,
837
+ index,
838
+ striped,
839
+ hoverable,
840
+ onRowClick: () => handleRowClick(row, row.original),
841
+ isPinned: pinnedRows.includes(row.id),
842
+ children: row.getVisibleCells().map((cell) => {
843
+ const isPinnedLeft = cell.column.getIsPinned() === "left";
844
+ const isPinnedRight = cell.column.getIsPinned() === "right";
845
+ return /* @__PURE__ */ jsx(
846
+ TableCell,
847
+ {
848
+ size,
849
+ bordered,
850
+ fixed: isPinnedLeft ? "left" : isPinnedRight ? "right" : void 0,
851
+ children: cell.getIsGrouped() ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
852
+ /* @__PURE__ */ jsx(
853
+ "button",
854
+ {
855
+ onClick: (e) => {
856
+ e.stopPropagation();
857
+ row.toggleExpanded();
858
+ },
859
+ className: "text-text-muted hover:text-text-primary",
860
+ children: row.getIsExpanded() ? /* @__PURE__ */ jsx(ChevronDown, { className: iconSizes[size] }) : /* @__PURE__ */ jsx(ChevronRight, { className: iconSizes[size] })
861
+ }
862
+ ),
863
+ flexRender(cell.column.columnDef.cell, cell.getContext()),
864
+ " ",
865
+ "(",
866
+ row.subRows.length,
867
+ ")"
868
+ ] }) : cell.getIsAggregated() ? flexRender(
869
+ cell.column.columnDef.aggregatedCell ?? cell.column.columnDef.cell,
870
+ cell.getContext()
871
+ ) : cell.getIsPlaceholder() ? null : flexRender(cell.column.columnDef.cell, cell.getContext())
872
+ },
873
+ cell.id
874
+ );
875
+ })
876
+ },
877
+ row.id
878
+ ),
879
+ enableExpandable && row.getIsExpanded() && expandedContent && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
880
+ "td",
881
+ {
882
+ colSpan: row.getVisibleCells().length,
883
+ className: "bg-surface/30 border-b border-border p-4",
884
+ children: expandedContent(row)
885
+ }
886
+ ) })
887
+ ] }));
888
+ };
889
+ const renderPagination = () => {
890
+ if (!enablePagination || table.getPageCount() === 0 || loading || enableVirtualization) {
891
+ return null;
892
+ }
893
+ const getPaginationPositionClasses = () => {
894
+ const positionClasses = {
895
+ topleft: "justify-start",
896
+ topcenter: "w-full justify-between",
897
+ topright: "justify-end",
898
+ bottomleft: "justify-start",
899
+ bottomcenter: "w-full justify-between",
900
+ bottomright: "justify-end"
901
+ };
902
+ return positionClasses[paginationPosition];
903
+ };
904
+ return /* @__PURE__ */ jsx(
905
+ pagination_default,
906
+ {
907
+ total: table.getFilteredRowModel().rows.length,
908
+ current: table.getState().pagination.pageIndex + 1,
909
+ pageSize: table.getState().pagination.pageSize,
910
+ onChange: (page, pageSize2) => {
911
+ table.setPageIndex(page - 1);
912
+ table.setPageSize(pageSize2);
913
+ },
914
+ showSizeChanger: true,
915
+ pageSizeOptions,
916
+ showTotal: (total, range) => /* @__PURE__ */ jsxs(Fragment, { children: [
917
+ "Showing ",
918
+ range[0],
919
+ "-",
920
+ range[1],
921
+ " of ",
922
+ total,
923
+ " rows"
924
+ ] }),
925
+ color,
926
+ size: "sm",
927
+ className: cn("flex", getPaginationPositionClasses())
928
+ }
929
+ );
930
+ };
931
+ const shouldShowTopPagination = paginationPosition.startsWith("top");
932
+ const shouldShowBottomPagination = paginationPosition.startsWith("bottom");
933
+ const handleVisibleColumnsChange = (newVisibleColumns) => {
934
+ const newVisibility = {};
935
+ allColumnsList.forEach((col) => {
936
+ newVisibility[col.id] = newVisibleColumns.includes(col.id);
937
+ });
938
+ setColumnVisibility(newVisibility);
939
+ };
940
+ return /* @__PURE__ */ jsxs("div", { className: "w-full space-y-4", children: [
941
+ enableActions && /* @__PURE__ */ jsx(
942
+ TableActions,
943
+ {
944
+ searchValue,
945
+ onSearchChange: setSearchValue,
946
+ visibleColumns: visibleColumnIds,
947
+ allColumns: allColumnsList,
948
+ onVisibleColumnsChange: handleVisibleColumnsChange,
949
+ size,
950
+ onSizeChange: setSize,
951
+ color
952
+ }
953
+ ),
954
+ shouldShowTopPagination && renderPagination(),
955
+ /* @__PURE__ */ jsx(
956
+ "div",
957
+ {
958
+ ref: tableContainerRef,
959
+ className: cn(
960
+ "overflow-auto rounded-md",
961
+ enableVirtualization && "max-h-[500px]",
962
+ variant === "outline" && "border border-border"
963
+ ),
964
+ children: /* @__PURE__ */ jsxs(
965
+ "table",
966
+ {
967
+ className: cn(
968
+ "w-full border-collapse",
969
+ variant === "line" && "border-0",
970
+ variant === "ghost" && "border-0",
971
+ className
972
+ ),
973
+ children: [
974
+ /* @__PURE__ */ jsxs("thead", { className: "bg-surface sticky top-0 z-30", children: [
975
+ renderColumnGroups(),
976
+ table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx("tr", { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx(
977
+ TableHeaderCell,
978
+ {
979
+ header,
980
+ size,
981
+ variant,
982
+ color,
983
+ bordered,
984
+ enableColumnPinning
985
+ },
986
+ header.id
987
+ )) }, headerGroup.id))
988
+ ] }),
989
+ /* @__PURE__ */ jsx("tbody", { children: renderRows() }),
990
+ footer && /* @__PURE__ */ jsx("tfoot", { className: "bg-surface border-t border-border sticky bottom-0 z-30", children: table.getFooterGroups().map((footerGroup) => /* @__PURE__ */ jsx("tr", { children: footerGroup.headers.map((header) => {
991
+ const isPinnedLeft = header.column.getIsPinned() === "left";
992
+ const isPinnedRight = header.column.getIsPinned() === "right";
993
+ return /* @__PURE__ */ jsx(
994
+ "th",
995
+ {
996
+ className: cn(
997
+ "px-4 py-3 text-left font-semibold text-text-primary",
998
+ bordered && "border-r border-border last:border-r-0",
999
+ isPinnedLeft && "sticky left-0 bg-surface z-20",
1000
+ isPinnedRight && "sticky right-0 bg-surface z-20"
1001
+ ),
1002
+ children: header.isPlaceholder ? null : flexRender(
1003
+ header.column.columnDef.footer,
1004
+ header.getContext()
1005
+ )
1006
+ },
1007
+ header.id
1008
+ );
1009
+ }) }, footerGroup.id)) })
1010
+ ]
1011
+ }
1012
+ )
1013
+ }
1014
+ ),
1015
+ shouldShowBottomPagination && renderPagination()
1016
+ ] });
1017
+ }
1018
+ Table.displayName = "Table";
1019
+ var table_default = Table;
1020
+
1021
+ export { EditableCell, TableActions, TableCell, TableHeaderCell, TableRow, TableSkeleton, table_default };
1022
+ //# sourceMappingURL=chunk-L3SP7GHC.js.map
1023
+ //# sourceMappingURL=chunk-L3SP7GHC.js.map