react-table-craft 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.
package/dist/index.mjs ADDED
@@ -0,0 +1,3431 @@
1
+ import * as React22 from 'react';
2
+ import React22__default, { forwardRef, createContext, useState, useEffect, useMemo, useContext } from 'react';
3
+ import { flexRender, useReactTable, getFacetedUniqueValues, getFacetedRowModel, getSortedRowModel, getPaginationRowModel, getFilteredRowModel, getCoreRowModel } from '@tanstack/react-table';
4
+ import { clsx } from 'clsx';
5
+ import { twMerge } from 'tailwind-merge';
6
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
+ import { ChevronDown, Check, Search, ChevronRight, Circle, ChevronLeft, Filter, PlusCircle, Columns3, Edit, Eye, Download, Trash2Icon, XCircle, MoreVertical, TableIcon, LayoutGrid, CalendarIcon, Trash2, Sheet, Loader2, Plus, RotateCcw, SearchX, ListFilter, Rows3, Type, X, GripVertical, MoreHorizontal, Copy, ArrowDown, ArrowUp, SortAsc, ArrowUpIcon, ArrowDownIcon, EyeOffIcon, TrashIcon, ChevronsUpDown } from 'lucide-react';
8
+ import { Slot } from '@radix-ui/react-slot';
9
+ import { cva } from 'class-variance-authority';
10
+ import * as SelectPrimitive from '@radix-ui/react-select';
11
+ import { format } from 'date-fns';
12
+ import { ar, enUS } from 'date-fns/locale';
13
+ import { mkConfig, generateCsv, download } from 'export-to-csv';
14
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
15
+ import * as PopoverPrimitive from '@radix-ui/react-popover';
16
+ import { Command as Command$1 } from 'cmdk';
17
+ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
18
+ import { DropdownMenuTrigger as DropdownMenuTrigger$1 } from '@radix-ui/react-dropdown-menu';
19
+ import * as TooltipPrimitive from '@radix-ui/react-tooltip';
20
+ import { Drawer as Drawer$1 } from 'vaul';
21
+
22
+ // src/components/data-table.tsx
23
+ function useDebounce(value, delay) {
24
+ const [debouncedValue, setDebouncedValue] = useState(value);
25
+ useEffect(() => {
26
+ const handler = setTimeout(() => {
27
+ setDebouncedValue(value);
28
+ }, delay);
29
+ return () => {
30
+ clearTimeout(handler);
31
+ };
32
+ }, [value, delay]);
33
+ return debouncedValue;
34
+ }
35
+ function cn(...inputs) {
36
+ return twMerge(clsx(inputs));
37
+ }
38
+ var Table = React22.forwardRef(
39
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsx(
40
+ "table",
41
+ {
42
+ ref,
43
+ className: cn("w-full caption-bottom text-sm", className),
44
+ ...props
45
+ }
46
+ ) })
47
+ );
48
+ Table.displayName = "Table";
49
+ var TableHeader = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
50
+ TableHeader.displayName = "TableHeader";
51
+ var TableBody = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("tbody", { ref, className: cn("[&_tr:last-child]:border-0", className), ...props }));
52
+ TableBody.displayName = "TableBody";
53
+ var TableFooter = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
54
+ "tfoot",
55
+ {
56
+ ref,
57
+ className: cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className),
58
+ ...props
59
+ }
60
+ ));
61
+ TableFooter.displayName = "TableFooter";
62
+ var TableRow = React22.forwardRef(
63
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
64
+ "tr",
65
+ {
66
+ ref,
67
+ className: cn(
68
+ "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
69
+ className
70
+ ),
71
+ ...props
72
+ }
73
+ )
74
+ );
75
+ TableRow.displayName = "TableRow";
76
+ var TableHead = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
77
+ "th",
78
+ {
79
+ ref,
80
+ className: cn(
81
+ "h-10 px-4 text-start align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pe-0 [&>[role=checkbox]]:translate-y-[2px]",
82
+ className
83
+ ),
84
+ ...props
85
+ }
86
+ ));
87
+ TableHead.displayName = "TableHead";
88
+ var TableCell = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
89
+ "td",
90
+ {
91
+ ref,
92
+ className: cn(
93
+ "px-4 py-2.5 align-middle [&:has([role=checkbox])]:pe-0 [&>[role=checkbox]]:translate-y-[2px]",
94
+ className
95
+ ),
96
+ ...props
97
+ }
98
+ ));
99
+ TableCell.displayName = "TableCell";
100
+ var TableCaption = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("caption", { ref, className: cn("mt-4 text-sm text-muted-foreground", className), ...props }));
101
+ TableCaption.displayName = "TableCaption";
102
+ var buttonVariants = cva(
103
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-lg text-sm font-medium transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 cursor-pointer",
104
+ {
105
+ variants: {
106
+ variant: {
107
+ default: "bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm",
108
+ brand: "bg-brand text-brand-foreground hover:bg-brand/90 shadow-sm shadow-brand/25",
109
+ outline: "border border-border bg-background hover:bg-accent hover:text-accent-foreground",
110
+ ghost: "hover:bg-accent hover:text-accent-foreground",
111
+ link: "text-brand underline-offset-4 hover:underline"
112
+ },
113
+ size: {
114
+ default: "h-10 px-4 py-2",
115
+ sm: "h-9 rounded-md px-3 text-xs",
116
+ lg: "h-12 rounded-xl px-8 text-base",
117
+ icon: "h-10 w-10"
118
+ }
119
+ },
120
+ defaultVariants: {
121
+ variant: "default",
122
+ size: "default"
123
+ }
124
+ }
125
+ );
126
+ var Button = forwardRef(
127
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
128
+ const Comp = asChild ? Slot : "button";
129
+ return /* @__PURE__ */ jsx(
130
+ Comp,
131
+ {
132
+ className: cn(buttonVariants({ variant, size, className })),
133
+ ref,
134
+ ...props
135
+ }
136
+ );
137
+ }
138
+ );
139
+ Button.displayName = "Button";
140
+ var Select = SelectPrimitive.Root;
141
+ var SelectGroup = SelectPrimitive.Group;
142
+ var SelectValue = SelectPrimitive.Value;
143
+ var SelectTrigger = React22.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
144
+ SelectPrimitive.Trigger,
145
+ {
146
+ ref,
147
+ className: cn(
148
+ "flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
149
+ className
150
+ ),
151
+ ...props,
152
+ children: [
153
+ children,
154
+ /* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 opacity-50" }) })
155
+ ]
156
+ }
157
+ ));
158
+ SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
159
+ var SelectContent = React22.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsx(
160
+ SelectPrimitive.Content,
161
+ {
162
+ ref,
163
+ className: cn(
164
+ "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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",
165
+ position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
166
+ className
167
+ ),
168
+ position,
169
+ ...props,
170
+ children: /* @__PURE__ */ jsx(
171
+ SelectPrimitive.Viewport,
172
+ {
173
+ className: cn(
174
+ "p-1",
175
+ position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
176
+ ),
177
+ children
178
+ }
179
+ )
180
+ }
181
+ ) }));
182
+ SelectContent.displayName = SelectPrimitive.Content.displayName;
183
+ var SelectItem = React22.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
184
+ SelectPrimitive.Item,
185
+ {
186
+ ref,
187
+ className: cn(
188
+ "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pe-8 ps-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
189
+ className
190
+ ),
191
+ ...props,
192
+ children: [
193
+ /* @__PURE__ */ jsx("span", { className: "absolute end-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) }) }),
194
+ /* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children })
195
+ ]
196
+ }
197
+ ));
198
+ SelectItem.displayName = SelectPrimitive.Item.displayName;
199
+ var SelectSeparator = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
200
+ SelectPrimitive.Separator,
201
+ {
202
+ ref,
203
+ className: cn("-mx-1 my-1 h-px bg-muted", className),
204
+ ...props
205
+ }
206
+ ));
207
+ SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
208
+
209
+ // src/config/defaults.ts
210
+ var DEFAULT_TABLE_CONFIG = Object.freeze({
211
+ features: Object.freeze({
212
+ search: true,
213
+ filter: true,
214
+ pagination: true,
215
+ columnVisibility: true,
216
+ csvExport: true,
217
+ rowSelection: true,
218
+ viewToggle: true,
219
+ floatingBar: false,
220
+ advancedFilter: false,
221
+ sorting: true
222
+ }),
223
+ pagination: Object.freeze({
224
+ pageSizeOptions: Object.freeze([10, 20, 30, 40, 50]),
225
+ defaultPageSize: 10
226
+ }),
227
+ search: Object.freeze({
228
+ debounceMs: 500,
229
+ minSearchLength: 0
230
+ }),
231
+ i18n: Object.freeze({
232
+ locale: "en",
233
+ direction: "auto",
234
+ translationFn: void 0,
235
+ namespace: "table"
236
+ }),
237
+ performance: Object.freeze({
238
+ memoStrategy: "smart",
239
+ virtualizationOverscan: 5,
240
+ batchUpdates: true
241
+ }),
242
+ enterprise: Object.freeze({
243
+ strictAccessibility: false,
244
+ errorRecovery: false,
245
+ debugMode: false
246
+ }),
247
+ dev: Object.freeze({
248
+ warnings: true,
249
+ performanceHints: false,
250
+ renderCostThresholdMs: 16
251
+ }),
252
+ plugins: [],
253
+ router: void 0
254
+ });
255
+
256
+ // src/config/merge.ts
257
+ function deepMergeConfig(base, overrides) {
258
+ const result = { ...base };
259
+ for (const key of Object.keys(overrides)) {
260
+ const overrideValue = overrides[key];
261
+ if (overrideValue === void 0) continue;
262
+ if (Array.isArray(overrideValue)) {
263
+ result[key] = overrideValue;
264
+ } else if (overrideValue !== null && typeof overrideValue === "object" && !Array.isArray(base[key]) && typeof base[key] === "object" && base[key] !== null) {
265
+ const baseObj = base[key];
266
+ const overrideObj = overrideValue;
267
+ const merged = { ...baseObj };
268
+ for (const subKey of Object.keys(overrideObj)) {
269
+ if (overrideObj[subKey] !== void 0) {
270
+ merged[subKey] = overrideObj[subKey];
271
+ }
272
+ }
273
+ result[key] = merged;
274
+ } else {
275
+ result[key] = overrideValue;
276
+ }
277
+ }
278
+ return result;
279
+ }
280
+
281
+ // src/config/context.ts
282
+ var TableConfigContext = createContext(null);
283
+ function TableProvider({ config, children }) {
284
+ const resolvedConfig = useMemo(
285
+ () => deepMergeConfig(DEFAULT_TABLE_CONFIG, config),
286
+ [config]
287
+ );
288
+ return React22__default.createElement(
289
+ TableConfigContext.Provider,
290
+ { value: resolvedConfig },
291
+ children
292
+ );
293
+ }
294
+ function useGlobalTableConfig() {
295
+ const context = useContext(TableConfigContext);
296
+ return context != null ? context : DEFAULT_TABLE_CONFIG;
297
+ }
298
+
299
+ // src/hooks/use-table-translations.ts
300
+ var DEFAULT_TRANSLATIONS = {
301
+ // Toolbar
302
+ "Filter": "Filter",
303
+ "filter-by": "Filter by",
304
+ "Reset": "Reset",
305
+ "add": "Add",
306
+ "add-filter": "Add filter",
307
+ "new": "New",
308
+ "columns": "Columns",
309
+ "Toggle-Visibility": "Toggle Visibility",
310
+ "export-csv": "Export CSV",
311
+ "tableView": "Table",
312
+ "cardView": "Cards",
313
+ "Apply": "Apply",
314
+ "data-table-filter": "Use filters to narrow down results.",
315
+ // Search
316
+ "search": "Search",
317
+ // Sorting
318
+ "asc": "Asc",
319
+ "desc": "Desc",
320
+ "Hide": "Hide",
321
+ "sorted-desc": "Sorted descending",
322
+ "sorted-asc": "Sorted ascending",
323
+ "not-sorted": "Not sorted",
324
+ "sort-ascending": "Sort ascending",
325
+ "sort-descending": "Sort descending",
326
+ "hide-column": "Hide column",
327
+ // Pagination
328
+ "pagination": "Pagination",
329
+ "showing": "Showing",
330
+ "of": "of",
331
+ "records": "records",
332
+ "Rows Per Page": "Rows per page",
333
+ "previous": "Previous",
334
+ "next": "Next",
335
+ // Selection
336
+ "select": "Select",
337
+ "clear-selection": "Clear selection",
338
+ "row(s) selected": "row(s) selected",
339
+ "delete-selected": "Delete selected",
340
+ // Empty state
341
+ "no-records-found": "No records found",
342
+ "no-records-hint": "Try adjusting your search or filter criteria.",
343
+ "reset-filters": "Reset filters",
344
+ // Filters
345
+ "no-items-found": "No items found.",
346
+ "clear-filters": "Clear filters",
347
+ "all": "All",
348
+ "advanced-filter": "Advanced filter",
349
+ // Actions
350
+ "actions": "Actions",
351
+ "edit": "Edit",
352
+ "show": "Show",
353
+ "delete": "Delete",
354
+ "download": "Download",
355
+ "cancel": "Cancel",
356
+ // Date
357
+ "datePlaceholder": "Pick a date",
358
+ // Client-side table
359
+ "row-number": "#"
360
+ };
361
+ function useTableTranslations() {
362
+ const config = useGlobalTableConfig();
363
+ if (config.i18n.translationFn) {
364
+ return config.i18n.translationFn;
365
+ }
366
+ return (key) => {
367
+ var _a;
368
+ return (_a = DEFAULT_TRANSLATIONS[key]) != null ? _a : key;
369
+ };
370
+ }
371
+
372
+ // src/config/create-config.ts
373
+ function createTableConfig(input) {
374
+ if (!input) return DEFAULT_TABLE_CONFIG;
375
+ const merged = deepMergeConfig(DEFAULT_TABLE_CONFIG, input);
376
+ return Object.freeze(merged);
377
+ }
378
+
379
+ // src/config/dev-warnings.ts
380
+ function runDevValidation(config) {
381
+ if (process.env.NODE_ENV !== "development") return;
382
+ if (!config.dev.warnings) return;
383
+ if (!config.pagination.pageSizeOptions.includes(config.pagination.defaultPageSize)) {
384
+ console.warn(
385
+ `[TableCraft] defaultPageSize (${config.pagination.defaultPageSize}) is not in pageSizeOptions [${config.pagination.pageSizeOptions.join(", ")}]. The page size dropdown may not show the default selection.`
386
+ );
387
+ }
388
+ if (config.search.debounceMs < 0) {
389
+ console.warn(
390
+ `[TableCraft] search.debounceMs is negative (${config.search.debounceMs}). This will be treated as 0.`
391
+ );
392
+ }
393
+ if (config.features.advancedFilter && !config.features.filter) {
394
+ console.warn(
395
+ `[TableCraft] features.advancedFilter is enabled but features.filter is disabled. Advanced filter will have no effect.`
396
+ );
397
+ }
398
+ if (config.i18n.direction === "auto" && !config.i18n.locale) {
399
+ console.warn(
400
+ `[TableCraft] i18n.direction is 'auto' but i18n.locale is empty. Direction detection may not work correctly. Set an explicit direction or locale.`
401
+ );
402
+ }
403
+ }
404
+
405
+ // src/config/use-resolved-config.ts
406
+ function useResolvedTableConfig(instanceConfig) {
407
+ const globalConfig = useGlobalTableConfig();
408
+ const resolved = useMemo(() => {
409
+ var _a;
410
+ let config = instanceConfig ? deepMergeConfig(globalConfig, instanceConfig) : globalConfig;
411
+ if (config.plugins.length > 0) {
412
+ const sortedPlugins = [...config.plugins].sort((a, b) => a.priority - b.priority);
413
+ for (const plugin of sortedPlugins) {
414
+ config = deepMergeConfig(config, plugin.config);
415
+ }
416
+ for (const plugin of sortedPlugins) {
417
+ (_a = plugin.onResolve) == null ? void 0 : _a.call(plugin, config);
418
+ }
419
+ }
420
+ return config;
421
+ }, [globalConfig, instanceConfig]);
422
+ if (process.env.NODE_ENV === "development") {
423
+ runDevValidation(resolved);
424
+ }
425
+ return resolved;
426
+ }
427
+ function useTableConfig(selector) {
428
+ const config = useGlobalTableConfig();
429
+ return useMemo(() => {
430
+ if (selector) return selector(config);
431
+ return config;
432
+ }, [config, selector]);
433
+ }
434
+ function getVisiblePages(currentPage, totalPages) {
435
+ if (totalPages <= 5) {
436
+ return Array.from({ length: totalPages }, (_, i) => i + 1);
437
+ }
438
+ const pages = [];
439
+ if (currentPage <= 3) {
440
+ pages.push(1, 2, 3, 4, "ellipsis", totalPages);
441
+ } else if (currentPage >= totalPages - 2) {
442
+ pages.push(1, "ellipsis", totalPages - 3, totalPages - 2, totalPages - 1, totalPages);
443
+ } else {
444
+ pages.push(1, "ellipsis", currentPage - 1, currentPage, currentPage + 1, "ellipsis", totalPages);
445
+ }
446
+ return pages;
447
+ }
448
+ function DataTablePagination({
449
+ table,
450
+ pageSizeOptions,
451
+ isQueryPagination = false,
452
+ paginationData
453
+ }) {
454
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
455
+ const t = useTableTranslations();
456
+ const config = useTableConfig();
457
+ const isArabic = config.i18n.direction === "rtl" || config.i18n.direction === "auto" && config.i18n.locale === "ar";
458
+ const resolvedPageSizeOptions = pageSizeOptions != null ? pageSizeOptions : config.pagination.pageSizeOptions;
459
+ const currentPage = isQueryPagination ? (_c = (_b = (_a = paginationData == null ? void 0 : paginationData.paginationResponse) == null ? void 0 : _a.meta) == null ? void 0 : _b.current_page) != null ? _c : 1 : table.getState().pagination.pageIndex + 1;
460
+ const totalPages = isQueryPagination ? (_f = (_e = (_d = paginationData == null ? void 0 : paginationData.paginationResponse) == null ? void 0 : _d.meta) == null ? void 0 : _e.last_page) != null ? _f : 1 : table.getPageCount();
461
+ const pageSize = isQueryPagination ? (_i = (_h = (_g = paginationData == null ? void 0 : paginationData.paginationResponse) == null ? void 0 : _g.meta) == null ? void 0 : _h.per_page) != null ? _i : 10 : table.getState().pagination.pageSize;
462
+ const totalItems = isQueryPagination ? (_l = (_k = (_j = paginationData == null ? void 0 : paginationData.paginationResponse) == null ? void 0 : _j.meta) == null ? void 0 : _k.total) != null ? _l : 0 : table.getFilteredRowModel().rows.length;
463
+ const from = totalItems === 0 ? 0 : (currentPage - 1) * pageSize + 1;
464
+ const to = Math.min(currentPage * pageSize, totalItems);
465
+ const goToPage = (page) => {
466
+ if (isQueryPagination && paginationData) {
467
+ paginationData.onPageChange(page);
468
+ } else {
469
+ table.setPageIndex(page - 1);
470
+ }
471
+ };
472
+ const visiblePages = getVisiblePages(currentPage, totalPages);
473
+ return /* @__PURE__ */ jsxs("nav", { role: "navigation", "aria-label": t("pagination"), className: "flex w-full flex-col gap-4 border-t px-4 py-4 sm:flex-row sm:items-center sm:justify-between", children: [
474
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-4", children: [
475
+ /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", children: [
476
+ t("showing"),
477
+ " ",
478
+ /* @__PURE__ */ jsxs("span", { className: "font-semibold text-foreground", children: [
479
+ from,
480
+ "-",
481
+ to
482
+ ] }),
483
+ " ",
484
+ t("of"),
485
+ " ",
486
+ /* @__PURE__ */ jsx("span", { className: "font-semibold text-foreground", children: totalItems }),
487
+ " ",
488
+ t("records")
489
+ ] }),
490
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
491
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("Rows Per Page") }),
492
+ /* @__PURE__ */ jsxs(
493
+ Select,
494
+ {
495
+ value: `${pageSize}`,
496
+ onValueChange: (value) => {
497
+ const newSize = Number(value);
498
+ if (isQueryPagination && paginationData) {
499
+ paginationData.onPageSizeChange(newSize);
500
+ } else {
501
+ table.setPageSize(newSize);
502
+ }
503
+ },
504
+ children: [
505
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "h-8 w-[70px]", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: pageSize }) }),
506
+ /* @__PURE__ */ jsx(SelectContent, { side: "top", children: resolvedPageSizeOptions.map((size) => /* @__PURE__ */ jsx(SelectItem, { value: `${size}`, children: size }, size)) })
507
+ ]
508
+ }
509
+ )
510
+ ] })
511
+ ] }),
512
+ totalPages > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
513
+ /* @__PURE__ */ jsxs(
514
+ Button,
515
+ {
516
+ variant: "outline",
517
+ size: "sm",
518
+ className: "h-8 gap-1 px-3 text-sm",
519
+ onClick: (e) => {
520
+ e.preventDefault();
521
+ goToPage(currentPage - 1);
522
+ },
523
+ disabled: currentPage === 1,
524
+ children: [
525
+ /* @__PURE__ */ jsx(ChevronLeft, { className: cn("size-4", isArabic && "rotate-180") }),
526
+ t("previous")
527
+ ]
528
+ }
529
+ ),
530
+ /* @__PURE__ */ jsx("div", { className: "hidden items-center gap-1 sm:flex", children: visiblePages.map(
531
+ (page, idx) => page === "ellipsis" ? /* @__PURE__ */ jsx("span", { className: "px-1 text-sm text-muted-foreground", children: "..." }, `ellipsis-${idx}`) : /* @__PURE__ */ jsx(
532
+ Button,
533
+ {
534
+ variant: page === currentPage ? "default" : "ghost",
535
+ size: "sm",
536
+ className: cn(
537
+ "size-8 p-0 text-sm",
538
+ page === currentPage && "bg-brand text-brand-foreground hover:bg-brand/90"
539
+ ),
540
+ onClick: (e) => {
541
+ e.preventDefault();
542
+ goToPage(page);
543
+ },
544
+ ...page === currentPage ? { "aria-current": "page" } : {},
545
+ children: page
546
+ },
547
+ page
548
+ )
549
+ ) }),
550
+ /* @__PURE__ */ jsxs("span", { className: "text-sm text-muted-foreground sm:hidden", children: [
551
+ currentPage,
552
+ " / ",
553
+ totalPages
554
+ ] }),
555
+ /* @__PURE__ */ jsxs(
556
+ Button,
557
+ {
558
+ variant: "outline",
559
+ size: "sm",
560
+ className: "h-8 gap-1 px-3 text-sm",
561
+ onClick: (e) => {
562
+ e.preventDefault();
563
+ goToPage(currentPage + 1);
564
+ },
565
+ disabled: currentPage === totalPages,
566
+ children: [
567
+ t("next"),
568
+ /* @__PURE__ */ jsx(ChevronRight, { className: cn("size-4", isArabic && "rotate-180") })
569
+ ]
570
+ }
571
+ )
572
+ ] })
573
+ ] });
574
+ }
575
+ var DEFAULT_IGNORED_COLUMNS = ["actions", "select"];
576
+ function createCsvConfig(options = {}) {
577
+ return mkConfig({
578
+ fieldSeparator: ",",
579
+ decimalSeparator: ".",
580
+ useKeysAsHeaders: true,
581
+ filename: options.fileName || "table-export"
582
+ });
583
+ }
584
+ function exportSelectedRowsCsv(table, options = {}) {
585
+ const selectedRows = table.getSelectedRowModel().rows;
586
+ if (selectedRows.length === 0) {
587
+ return;
588
+ }
589
+ const ignoredColumns = [
590
+ ...DEFAULT_IGNORED_COLUMNS,
591
+ ...options.ignoredCols || []
592
+ ];
593
+ const csvConfig = createCsvConfig(options);
594
+ try {
595
+ const tableData = selectedRows.map((row) => {
596
+ return row._getAllVisibleCells().reduce(
597
+ (acc, cell) => {
598
+ if (!ignoredColumns.includes(cell.column.id)) {
599
+ const rawValue = cell.getValue();
600
+ const original = cell.row.original;
601
+ const value = rawValue != null ? rawValue : original[cell.column.id];
602
+ if (value !== void 0 && value !== null && value !== "") {
603
+ const headerKey = typeof cell.column.columnDef.header === "string" ? cell.column.columnDef.header : cell.column.id;
604
+ acc[headerKey] = String(value);
605
+ }
606
+ }
607
+ return acc;
608
+ },
609
+ {}
610
+ );
611
+ });
612
+ if (tableData.length === 0) {
613
+ return;
614
+ }
615
+ const csv = generateCsv(csvConfig)(tableData);
616
+ download(csvConfig)(csv);
617
+ } catch (error) {
618
+ console.error("CSV export failed:", error);
619
+ }
620
+ }
621
+ var Input = React22.forwardRef(
622
+ ({ className, type, ...props }, ref) => {
623
+ return /* @__PURE__ */ jsx(
624
+ "input",
625
+ {
626
+ type,
627
+ className: cn(
628
+ "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
629
+ className
630
+ ),
631
+ ref,
632
+ ...props
633
+ }
634
+ );
635
+ }
636
+ );
637
+ Input.displayName = "Input";
638
+ function Calendar({ className, mode = "single", selected, onSelect }) {
639
+ const [currentMonth, setCurrentMonth] = React22.useState(() => selected || /* @__PURE__ */ new Date());
640
+ const year = currentMonth.getFullYear();
641
+ const month = currentMonth.getMonth();
642
+ const firstDay = new Date(year, month, 1);
643
+ const lastDay = new Date(year, month + 1, 0);
644
+ const startDayOfWeek = firstDay.getDay();
645
+ const daysInMonth = lastDay.getDate();
646
+ const prevMonth = () => setCurrentMonth(new Date(year, month - 1, 1));
647
+ const nextMonth = () => setCurrentMonth(new Date(year, month + 1, 1));
648
+ const monthName = currentMonth.toLocaleString("default", { month: "long", year: "numeric" });
649
+ const dayNames = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
650
+ const isSelected = (day) => {
651
+ if (!selected) return false;
652
+ return selected.getFullYear() === year && selected.getMonth() === month && selected.getDate() === day;
653
+ };
654
+ const isToday = (day) => {
655
+ const today = /* @__PURE__ */ new Date();
656
+ return today.getFullYear() === year && today.getMonth() === month && today.getDate() === day;
657
+ };
658
+ const handleSelect = (day) => {
659
+ const date = new Date(year, month, day);
660
+ onSelect == null ? void 0 : onSelect(date);
661
+ };
662
+ const cells = [];
663
+ for (let i = 0; i < startDayOfWeek; i++) cells.push(null);
664
+ for (let d = 1; d <= daysInMonth; d++) cells.push(d);
665
+ return /* @__PURE__ */ jsxs("div", { className: cn("p-3", className), children: [
666
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-2", children: [
667
+ /* @__PURE__ */ jsx(Button, { variant: "outline", size: "icon", className: "h-7 w-7", onClick: prevMonth, children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" }) }),
668
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: monthName }),
669
+ /* @__PURE__ */ jsx(Button, { variant: "outline", size: "icon", className: "h-7 w-7", onClick: nextMonth, children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" }) })
670
+ ] }),
671
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-7 gap-1 text-center text-xs text-muted-foreground mb-1", children: dayNames.map((d) => /* @__PURE__ */ jsx("div", { className: "py-1", children: d }, d)) }),
672
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-7 gap-1", children: cells.map(
673
+ (day, i) => day === null ? /* @__PURE__ */ jsx("div", {}, `empty-${i}`) : /* @__PURE__ */ jsx(
674
+ "button",
675
+ {
676
+ type: "button",
677
+ onClick: () => handleSelect(day),
678
+ className: cn(
679
+ "h-8 w-8 rounded-md text-sm transition-colors hover:bg-accent mx-auto flex items-center justify-center",
680
+ isSelected(day) && "bg-primary text-primary-foreground hover:bg-primary/90",
681
+ isToday(day) && !isSelected(day) && "bg-accent text-accent-foreground"
682
+ ),
683
+ children: day
684
+ },
685
+ day
686
+ )
687
+ ) })
688
+ ] });
689
+ }
690
+ var Checkbox = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
691
+ CheckboxPrimitive.Root,
692
+ {
693
+ ref,
694
+ className: cn(
695
+ "peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
696
+ className
697
+ ),
698
+ ...props,
699
+ children: /* @__PURE__ */ jsx(CheckboxPrimitive.Indicator, { className: cn("flex items-center justify-center text-current"), children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) })
700
+ }
701
+ ));
702
+ Checkbox.displayName = CheckboxPrimitive.Root.displayName;
703
+ var Label = React22.forwardRef(
704
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
705
+ "label",
706
+ {
707
+ ref,
708
+ className: cn(
709
+ "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
710
+ className
711
+ ),
712
+ ...props
713
+ }
714
+ )
715
+ );
716
+ Label.displayName = "Label";
717
+ var Popover = PopoverPrimitive.Root;
718
+ var PopoverTrigger = PopoverPrimitive.Trigger;
719
+ var PopoverContent = React22.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
720
+ PopoverPrimitive.Content,
721
+ {
722
+ ref,
723
+ align,
724
+ sideOffset,
725
+ className: cn(
726
+ "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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",
727
+ className
728
+ ),
729
+ ...props
730
+ }
731
+ ) }));
732
+ PopoverContent.displayName = PopoverPrimitive.Content.displayName;
733
+ var badgeVariants = cva(
734
+ "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors",
735
+ {
736
+ variants: {
737
+ variant: {
738
+ default: "border-transparent bg-primary text-primary-foreground",
739
+ secondary: "border-transparent bg-secondary text-secondary-foreground",
740
+ brand: "border-transparent bg-brand-muted text-brand",
741
+ outline: "text-foreground"
742
+ }
743
+ },
744
+ defaultVariants: {
745
+ variant: "default"
746
+ }
747
+ }
748
+ );
749
+ function Badge({ className, variant, ...props }) {
750
+ return /* @__PURE__ */ jsx("div", { className: cn(badgeVariants({ variant }), className), ...props });
751
+ }
752
+ var Command = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
753
+ Command$1,
754
+ {
755
+ ref,
756
+ className: cn(
757
+ "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
758
+ className
759
+ ),
760
+ ...props
761
+ }
762
+ ));
763
+ Command.displayName = Command$1.displayName;
764
+ var CommandInput = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs("div", { className: "flex items-center border-b px-3", "cmdk-input-wrapper": "", children: [
765
+ /* @__PURE__ */ jsx(Search, { className: "me-2 h-4 w-4 shrink-0 opacity-50" }),
766
+ /* @__PURE__ */ jsx(
767
+ Command$1.Input,
768
+ {
769
+ ref,
770
+ className: cn(
771
+ "flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
772
+ className
773
+ ),
774
+ ...props
775
+ }
776
+ )
777
+ ] }));
778
+ CommandInput.displayName = Command$1.Input.displayName;
779
+ var CommandList = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
780
+ Command$1.List,
781
+ {
782
+ ref,
783
+ className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className),
784
+ ...props
785
+ }
786
+ ));
787
+ CommandList.displayName = Command$1.List.displayName;
788
+ var CommandEmpty = React22.forwardRef((props, ref) => /* @__PURE__ */ jsx(Command$1.Empty, { ref, className: "py-6 text-center text-sm", ...props }));
789
+ CommandEmpty.displayName = Command$1.Empty.displayName;
790
+ var CommandGroup = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
791
+ Command$1.Group,
792
+ {
793
+ ref,
794
+ className: cn(
795
+ "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
796
+ className
797
+ ),
798
+ ...props
799
+ }
800
+ ));
801
+ CommandGroup.displayName = Command$1.Group.displayName;
802
+ var CommandSeparator = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
803
+ Command$1.Separator,
804
+ {
805
+ ref,
806
+ className: cn("-mx-1 h-px bg-border", className),
807
+ ...props
808
+ }
809
+ ));
810
+ CommandSeparator.displayName = Command$1.Separator.displayName;
811
+ var CommandItem = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
812
+ Command$1.Item,
813
+ {
814
+ ref,
815
+ className: cn(
816
+ "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50",
817
+ className
818
+ ),
819
+ ...props
820
+ }
821
+ ));
822
+ CommandItem.displayName = Command$1.Item.displayName;
823
+ var Separator2 = React22.forwardRef(
824
+ ({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ jsx(
825
+ "div",
826
+ {
827
+ ref,
828
+ role: decorative ? "none" : "separator",
829
+ "aria-orientation": !decorative ? orientation : void 0,
830
+ className: cn(
831
+ "shrink-0 bg-border",
832
+ orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
833
+ className
834
+ ),
835
+ ...props
836
+ }
837
+ )
838
+ );
839
+ Separator2.displayName = "Separator";
840
+ function DataTableFacetedFilter({
841
+ column,
842
+ title,
843
+ options,
844
+ variant = "popover",
845
+ className,
846
+ isQueryFilter = false,
847
+ handleFilterChange,
848
+ currentValue
849
+ }) {
850
+ const t = useTableTranslations();
851
+ const [selectedValues, setSelectedValues] = useState(/* @__PURE__ */ new Set());
852
+ useEffect(() => {
853
+ let filterValue = [];
854
+ if (isQueryFilter) {
855
+ filterValue = currentValue ? [currentValue] : [];
856
+ } else if (column) {
857
+ const columnFilterValue = column == null ? void 0 : column.getFilterValue();
858
+ filterValue = Array.isArray(columnFilterValue) ? columnFilterValue : [];
859
+ }
860
+ setSelectedValues(new Set(filterValue));
861
+ }, [currentValue, column, isQueryFilter]);
862
+ const handleValueChange = (value) => {
863
+ if (isQueryFilter) {
864
+ setSelectedValues(/* @__PURE__ */ new Set([value]));
865
+ } else {
866
+ const newSelectedValues = new Set(selectedValues);
867
+ if (newSelectedValues.has(value)) {
868
+ newSelectedValues.delete(value);
869
+ } else {
870
+ newSelectedValues.add(value);
871
+ }
872
+ setSelectedValues(newSelectedValues);
873
+ }
874
+ if (isQueryFilter && handleFilterChange && column) {
875
+ handleFilterChange(String(column.id), value);
876
+ } else if (!isQueryFilter && column) {
877
+ const newSelectedValues = new Set(selectedValues);
878
+ if (newSelectedValues.has(value)) {
879
+ newSelectedValues.delete(value);
880
+ } else {
881
+ newSelectedValues.add(value);
882
+ }
883
+ const filterValues = Array.from(newSelectedValues);
884
+ const finalValue = filterValues.length > 0 ? filterValues : void 0;
885
+ column.setFilterValue(finalValue);
886
+ }
887
+ };
888
+ const clearFilters = () => {
889
+ if (isQueryFilter && handleFilterChange && column) {
890
+ handleFilterChange(String(column.id), void 0);
891
+ } else if (!isQueryFilter && column) {
892
+ column.setFilterValue(void 0);
893
+ }
894
+ };
895
+ const renderBadges = () => {
896
+ if (selectedValues.size === 0) return null;
897
+ const filteredOptions = options.filter((option) => selectedValues.has(option.value));
898
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
899
+ /* @__PURE__ */ jsx(Separator2, { orientation: "vertical", className: "mx-2 h-4" }),
900
+ /* @__PURE__ */ jsx("div", { className: "flex space-x-1", children: filteredOptions.map((option) => /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "rounded-sm px-1 font-normal", children: option.label }, option.value)) })
901
+ ] });
902
+ };
903
+ const renderCommandItems = () => /* @__PURE__ */ jsxs(Fragment, { children: [
904
+ /* @__PURE__ */ jsx(CommandGroup, { children: options.map((option) => {
905
+ const isSelected = selectedValues.has(option.value);
906
+ return /* @__PURE__ */ jsxs(CommandItem, { onSelect: () => handleValueChange(option.value), children: [
907
+ /* @__PURE__ */ jsx(
908
+ "div",
909
+ {
910
+ className: cn(
911
+ "me-2 flex size-4 items-center justify-center rounded-sm border border-primary",
912
+ isSelected ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"
913
+ ),
914
+ children: /* @__PURE__ */ jsx(Check, { className: cn("size-4"), "aria-hidden": "true" })
915
+ }
916
+ ),
917
+ option.icon && /* @__PURE__ */ jsx(option.icon, { className: "me-2 size-4 text-muted-foreground", "aria-hidden": "true" }),
918
+ /* @__PURE__ */ jsx("span", { children: option.label })
919
+ ] }, option.value);
920
+ }) }),
921
+ selectedValues.size > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
922
+ /* @__PURE__ */ jsx(CommandSeparator, {}),
923
+ /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsx(CommandItem, { onSelect: clearFilters, className: "justify-center text-center", children: t("clear-filters") }) })
924
+ ] })
925
+ ] });
926
+ if (variant === "command") {
927
+ return /* @__PURE__ */ jsxs(Command, { className: "p-1", children: [
928
+ /* @__PURE__ */ jsx(
929
+ CommandInput,
930
+ {
931
+ placeholder: title,
932
+ autoFocus: true,
933
+ className: "flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
934
+ }
935
+ ),
936
+ /* @__PURE__ */ jsxs(CommandList, { className: "mt-1", children: [
937
+ /* @__PURE__ */ jsx(CommandEmpty, { children: t("no-items-found") }),
938
+ renderCommandItems()
939
+ ] })
940
+ ] });
941
+ }
942
+ return /* @__PURE__ */ jsxs(Popover, { children: [
943
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", className: `${className} h-8 border-dashed`, children: [
944
+ /* @__PURE__ */ jsx(Filter, { className: "me-2 size-4" }),
945
+ title,
946
+ renderBadges()
947
+ ] }) }),
948
+ /* @__PURE__ */ jsx(PopoverContent, { className: "w-[200px] p-0", align: "start", children: /* @__PURE__ */ jsxs(Command, { children: [
949
+ /* @__PURE__ */ jsx(CommandInput, { placeholder: title }),
950
+ /* @__PURE__ */ jsxs(CommandList, { children: [
951
+ /* @__PURE__ */ jsx(CommandEmpty, { children: t("no-items-found") }),
952
+ renderCommandItems()
953
+ ] })
954
+ ] }) })
955
+ ] });
956
+ }
957
+ function DataTableSingleSelectFilter({
958
+ column,
959
+ title,
960
+ options,
961
+ className,
962
+ isQueryFilter = false,
963
+ handleFilterChange,
964
+ currentValue
965
+ }) {
966
+ var _a;
967
+ const t = useTableTranslations();
968
+ const [open, setOpen] = useState(false);
969
+ const [selectedValue, setSelectedValue] = useState("");
970
+ const columnFilterValue = column && "getFilterValue" in column ? column.getFilterValue() : void 0;
971
+ useEffect(() => {
972
+ let filterValue = "";
973
+ if (isQueryFilter) {
974
+ filterValue = currentValue || "";
975
+ } else if (column) {
976
+ if (Array.isArray(columnFilterValue) && columnFilterValue.length > 0) {
977
+ filterValue = columnFilterValue[0] || "";
978
+ } else if (typeof columnFilterValue === "string") {
979
+ filterValue = columnFilterValue;
980
+ } else {
981
+ filterValue = "";
982
+ }
983
+ }
984
+ setSelectedValue(filterValue);
985
+ }, [currentValue, column, isQueryFilter, columnFilterValue]);
986
+ const handleValueChange = (value) => {
987
+ const newValue = value === selectedValue ? "" : value;
988
+ setSelectedValue(newValue);
989
+ setOpen(false);
990
+ if (isQueryFilter && handleFilterChange && column) {
991
+ handleFilterChange(String(column.id), newValue || void 0);
992
+ } else if (!isQueryFilter && column) {
993
+ const filterValue = newValue ? [newValue] : void 0;
994
+ column.setFilterValue(filterValue);
995
+ }
996
+ };
997
+ const selectedOptionLabel = (_a = options.find((option) => option.value === selectedValue)) == null ? void 0 : _a.label;
998
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
999
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
1000
+ Button,
1001
+ {
1002
+ variant: "outline",
1003
+ size: "sm",
1004
+ className: cn("h-8 border-dashed", className),
1005
+ children: [
1006
+ /* @__PURE__ */ jsx(PlusCircle, { className: "me-2 h-4 w-4" }),
1007
+ title,
1008
+ selectedValue && /* @__PURE__ */ jsxs(Fragment, { children: [
1009
+ /* @__PURE__ */ jsx(Separator2, { orientation: "vertical", className: "mx-2 h-4" }),
1010
+ /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "rounded-sm px-1 font-normal lg:hidden", children: "1" }),
1011
+ /* @__PURE__ */ jsx("div", { className: "hidden space-x-1 lg:flex", children: /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "rounded-sm px-1 font-normal", children: selectedOptionLabel }) })
1012
+ ] })
1013
+ ]
1014
+ }
1015
+ ) }),
1016
+ /* @__PURE__ */ jsx(PopoverContent, { className: "w-[200px] p-0", align: "start", children: /* @__PURE__ */ jsx(Command, { children: /* @__PURE__ */ jsx(CommandList, { children: /* @__PURE__ */ jsxs(CommandGroup, { children: [
1017
+ /* @__PURE__ */ jsxs(CommandItem, { onSelect: () => handleValueChange(""), className: "justify-between", children: [
1018
+ t("all") || "All",
1019
+ /* @__PURE__ */ jsx(
1020
+ Check,
1021
+ {
1022
+ className: cn("h-4 w-4", selectedValue === "" ? "opacity-100" : "opacity-0")
1023
+ }
1024
+ )
1025
+ ] }),
1026
+ /* @__PURE__ */ jsx(CommandSeparator, {}),
1027
+ options.map((option) => {
1028
+ const isSelected = selectedValue === option.value;
1029
+ return /* @__PURE__ */ jsxs(
1030
+ CommandItem,
1031
+ {
1032
+ onSelect: () => handleValueChange(option.value),
1033
+ className: "justify-between",
1034
+ children: [
1035
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
1036
+ option.icon && /* @__PURE__ */ jsx(
1037
+ option.icon,
1038
+ {
1039
+ className: "me-2 h-4 w-4 text-muted-foreground",
1040
+ "aria-hidden": "true"
1041
+ }
1042
+ ),
1043
+ /* @__PURE__ */ jsx("span", { children: option.label })
1044
+ ] }),
1045
+ /* @__PURE__ */ jsx(Check, { className: cn("h-4 w-4", isSelected ? "opacity-100" : "opacity-0") })
1046
+ ]
1047
+ },
1048
+ option.value
1049
+ );
1050
+ })
1051
+ ] }) }) }) })
1052
+ ] });
1053
+ }
1054
+ var DropdownMenu = DropdownMenuPrimitive.Root;
1055
+ var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
1056
+ var DropdownMenuGroup = DropdownMenuPrimitive.Group;
1057
+ var DropdownMenuSubTrigger = React22.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxs(
1058
+ DropdownMenuPrimitive.SubTrigger,
1059
+ {
1060
+ ref,
1061
+ className: cn(
1062
+ "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
1063
+ inset && "ps-8",
1064
+ className
1065
+ ),
1066
+ ...props,
1067
+ children: [
1068
+ children,
1069
+ /* @__PURE__ */ jsx(ChevronRight, { className: "ms-auto h-4 w-4" })
1070
+ ]
1071
+ }
1072
+ ));
1073
+ DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
1074
+ var DropdownMenuSubContent = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1075
+ DropdownMenuPrimitive.SubContent,
1076
+ {
1077
+ ref,
1078
+ className: cn(
1079
+ "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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",
1080
+ className
1081
+ ),
1082
+ ...props
1083
+ }
1084
+ ));
1085
+ DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
1086
+ var DropdownMenuContent = React22.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(
1087
+ DropdownMenuPrimitive.Content,
1088
+ {
1089
+ ref,
1090
+ sideOffset,
1091
+ className: cn(
1092
+ "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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",
1093
+ className
1094
+ ),
1095
+ ...props
1096
+ }
1097
+ ) }));
1098
+ DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
1099
+ var DropdownMenuItem = React22.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
1100
+ DropdownMenuPrimitive.Item,
1101
+ {
1102
+ ref,
1103
+ className: cn(
1104
+ "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
1105
+ inset && "ps-8",
1106
+ className
1107
+ ),
1108
+ ...props
1109
+ }
1110
+ ));
1111
+ DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
1112
+ var DropdownMenuCheckboxItem = React22.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxs(
1113
+ DropdownMenuPrimitive.CheckboxItem,
1114
+ {
1115
+ ref,
1116
+ className: cn(
1117
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pe-2 ps-8 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
1118
+ className
1119
+ ),
1120
+ checked,
1121
+ ...props,
1122
+ children: [
1123
+ /* @__PURE__ */ jsx("span", { className: "absolute start-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) }) }),
1124
+ children
1125
+ ]
1126
+ }
1127
+ ));
1128
+ DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
1129
+ var DropdownMenuRadioItem = React22.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
1130
+ DropdownMenuPrimitive.RadioItem,
1131
+ {
1132
+ ref,
1133
+ className: cn(
1134
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pe-2 ps-8 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
1135
+ className
1136
+ ),
1137
+ ...props,
1138
+ children: [
1139
+ /* @__PURE__ */ jsx("span", { className: "absolute start-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Circle, { className: "h-2 w-2 fill-current" }) }) }),
1140
+ children
1141
+ ]
1142
+ }
1143
+ ));
1144
+ DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
1145
+ var DropdownMenuLabel = React22.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
1146
+ DropdownMenuPrimitive.Label,
1147
+ {
1148
+ ref,
1149
+ className: cn("px-2 py-1.5 text-sm font-semibold", inset && "ps-8", className),
1150
+ ...props
1151
+ }
1152
+ ));
1153
+ DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
1154
+ var DropdownMenuSeparator = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1155
+ DropdownMenuPrimitive.Separator,
1156
+ {
1157
+ ref,
1158
+ className: cn("-mx-1 my-1 h-px bg-muted", className),
1159
+ ...props
1160
+ }
1161
+ ));
1162
+ DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
1163
+ var DropdownMenuShortcut = ({ className, ...props }) => {
1164
+ return /* @__PURE__ */ jsx("span", { className: cn("ms-auto text-xs tracking-widest opacity-60", className), ...props });
1165
+ };
1166
+ DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
1167
+ function DataTableViewOptions({ table }) {
1168
+ const t = useTableTranslations();
1169
+ const config = useTableConfig();
1170
+ const language = config.i18n.direction === "rtl" || config.i18n.direction === "auto" && config.i18n.locale === "ar" ? "ar" : "en";
1171
+ return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
1172
+ /* @__PURE__ */ jsx(DropdownMenuTrigger$1, { asChild: true, children: /* @__PURE__ */ jsxs(
1173
+ Button,
1174
+ {
1175
+ variant: "outline",
1176
+ size: "sm",
1177
+ className: "flex h-9 items-center justify-center gap-2 px-4",
1178
+ children: [
1179
+ t("columns"),
1180
+ /* @__PURE__ */ jsx(Columns3, { className: "size-4" })
1181
+ ]
1182
+ }
1183
+ ) }),
1184
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "max-w-sm", children: [
1185
+ /* @__PURE__ */ jsx(
1186
+ DropdownMenuLabel,
1187
+ {
1188
+ style: {
1189
+ direction: language === "ar" ? "rtl" : "ltr"
1190
+ },
1191
+ children: t("Toggle-Visibility")
1192
+ }
1193
+ ),
1194
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
1195
+ table.getAllColumns().filter((column) => typeof column.accessorFn !== "undefined" && column.getCanHide()).map((column) => {
1196
+ return /* @__PURE__ */ jsx(
1197
+ DropdownMenuCheckboxItem,
1198
+ {
1199
+ className: "cursor-pointer capitalize",
1200
+ checked: column.getIsVisible(),
1201
+ onCheckedChange: (value) => column.toggleVisibility(!!value),
1202
+ style: {
1203
+ direction: language === "ar" ? "rtl" : "ltr"
1204
+ },
1205
+ children: typeof column.columnDef.header === "string" ? String(column.columnDef.header) : column.id
1206
+ },
1207
+ column.id
1208
+ );
1209
+ })
1210
+ ] })
1211
+ ] });
1212
+ }
1213
+ var TooltipProvider = TooltipPrimitive.Provider;
1214
+ var Tooltip = ({ children, ...props }) => /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx(TooltipPrimitive.Root, { ...props, children }) });
1215
+ var TooltipTrigger = TooltipPrimitive.Trigger;
1216
+ var TooltipContent = React22.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsx(
1217
+ TooltipPrimitive.Content,
1218
+ {
1219
+ ref,
1220
+ sideOffset,
1221
+ className: cn(
1222
+ "z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 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",
1223
+ className
1224
+ ),
1225
+ ...props
1226
+ }
1227
+ ) }));
1228
+ TooltipContent.displayName = TooltipPrimitive.Content.displayName;
1229
+ var ButtonTooltip = ({ content }) => {
1230
+ return /* @__PURE__ */ jsxs(Tooltip, { children: [
1231
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "absolute inset-0" }) }),
1232
+ /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-96 text-wrap", children: content })
1233
+ ] });
1234
+ };
1235
+ var ActionButton = ({
1236
+ onClick,
1237
+ disabled,
1238
+ className,
1239
+ icon,
1240
+ tooltip,
1241
+ variant = "default"
1242
+ }) => {
1243
+ return /* @__PURE__ */ jsxs(
1244
+ Button,
1245
+ {
1246
+ onClick,
1247
+ size: "icon",
1248
+ variant,
1249
+ className: `relative ${className} ${disabled ? "cursor-not-allowed" : ""}`,
1250
+ disabled,
1251
+ children: [
1252
+ icon,
1253
+ tooltip && /* @__PURE__ */ jsx(ButtonTooltip, { content: tooltip })
1254
+ ]
1255
+ }
1256
+ );
1257
+ };
1258
+ var TableActionsRow = ({
1259
+ editAction,
1260
+ showAction,
1261
+ deleteAction,
1262
+ downloadAction,
1263
+ className,
1264
+ customButtons,
1265
+ text,
1266
+ dropMoreActions,
1267
+ useDropdown = true,
1268
+ cancelAction
1269
+ }) => {
1270
+ const t = useTableTranslations();
1271
+ const config = useTableConfig();
1272
+ const isArabic = config.i18n.direction === "rtl" || config.i18n.direction === "auto" && config.i18n.locale === "ar";
1273
+ const commonActions = [
1274
+ editAction && {
1275
+ text: t("edit"),
1276
+ icon: /* @__PURE__ */ jsx(Edit, { className: "text-tab-teal size-4" }),
1277
+ function: editAction.action,
1278
+ disabled: editAction.disabled,
1279
+ className: "bg-tab-teal hover:bg-tab-teal-800",
1280
+ tooltip: t("edit")
1281
+ },
1282
+ showAction && {
1283
+ text: t("show"),
1284
+ icon: /* @__PURE__ */ jsx(Eye, { className: "size-4" }),
1285
+ function: showAction.action,
1286
+ disabled: showAction.disabled,
1287
+ className: "bg-tab-turquoise hover:bg-tab-turquoise-800",
1288
+ tooltip: t("show")
1289
+ },
1290
+ downloadAction && {
1291
+ text: t("download"),
1292
+ icon: /* @__PURE__ */ jsx(Download, { className: "text-main size-4" }),
1293
+ function: downloadAction.action,
1294
+ disabled: downloadAction.disabled,
1295
+ className: "outline outline-1 outline-main",
1296
+ tooltip: t("download"),
1297
+ variant: "ghost"
1298
+ },
1299
+ deleteAction && {
1300
+ text: t("delete"),
1301
+ icon: /* @__PURE__ */ jsx(Trash2Icon, { className: "size-4 text-rose-700" }),
1302
+ function: deleteAction.action,
1303
+ disabled: deleteAction.disabled,
1304
+ className: "outline outline-1 outline-rose-700",
1305
+ tooltip: t("delete"),
1306
+ variant: "ghost"
1307
+ },
1308
+ cancelAction && {
1309
+ text: t("cancel"),
1310
+ icon: /* @__PURE__ */ jsx(XCircle, { className: "size-4 text-rose-600" }),
1311
+ function: cancelAction.action,
1312
+ disabled: cancelAction.disabled,
1313
+ className: "outline outline-1 outline-rose-600",
1314
+ tooltip: cancelAction.tooltip || t("cancel"),
1315
+ variant: "ghost"
1316
+ }
1317
+ ].filter(Boolean);
1318
+ const renderActionButtons = () => {
1319
+ if (useDropdown) {
1320
+ return /* @__PURE__ */ jsxs(DropdownMenu, { dir: isArabic ? "rtl" : "ltr", children: [
1321
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "outline", size: "icon", type: "button", children: /* @__PURE__ */ jsx(MoreVertical, { size: 20 }) }) }),
1322
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-56", children: [
1323
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: t("actions") }),
1324
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
1325
+ /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
1326
+ commonActions.map((action, index) => /* @__PURE__ */ jsxs(
1327
+ DropdownMenuItem,
1328
+ {
1329
+ disabled: action == null ? void 0 : action.disabled,
1330
+ className: "flex !justify-between",
1331
+ onClick: action == null ? void 0 : action.function,
1332
+ children: [
1333
+ /* @__PURE__ */ jsx("span", { children: action == null ? void 0 : action.text }),
1334
+ /* @__PURE__ */ jsx(DropdownMenuShortcut, { children: action == null ? void 0 : action.icon })
1335
+ ]
1336
+ },
1337
+ index
1338
+ )),
1339
+ dropMoreActions == null ? void 0 : dropMoreActions.map((item, index) => /* @__PURE__ */ jsxs(
1340
+ DropdownMenuItem,
1341
+ {
1342
+ disabled: item.disabled,
1343
+ className: "flex !justify-between",
1344
+ onClick: item.function,
1345
+ ...item == null ? void 0 : item.attr,
1346
+ children: [
1347
+ /* @__PURE__ */ jsx("span", { children: item.text }),
1348
+ /* @__PURE__ */ jsx(DropdownMenuShortcut, { children: item.icon }),
1349
+ item.toolTip && /* @__PURE__ */ jsx(ButtonTooltip, { content: item.toolTip })
1350
+ ]
1351
+ },
1352
+ `more-${index}`
1353
+ ))
1354
+ ] })
1355
+ ] })
1356
+ ] });
1357
+ }
1358
+ return /* @__PURE__ */ jsx(Fragment, { children: commonActions.map((action, index) => /* @__PURE__ */ jsx(
1359
+ ActionButton,
1360
+ {
1361
+ onClick: action == null ? void 0 : action.function,
1362
+ disabled: action == null ? void 0 : action.disabled,
1363
+ className: (action == null ? void 0 : action.className) || "",
1364
+ icon: action == null ? void 0 : action.icon,
1365
+ tooltip: action == null ? void 0 : action.tooltip,
1366
+ variant: action == null ? void 0 : action.variant
1367
+ },
1368
+ index
1369
+ )) });
1370
+ };
1371
+ return /* @__PURE__ */ jsxs("div", { className: `${className} flex flex-row items-center gap-1 text-center md:gap-3`, children: [
1372
+ renderActionButtons(),
1373
+ customButtons && Array.isArray(customButtons) ? customButtons.filter((customButton) => Object.keys(customButton).length !== 0).map((customButton, index) => /* @__PURE__ */ jsxs(
1374
+ Button,
1375
+ {
1376
+ onClick: customButton == null ? void 0 : customButton.function,
1377
+ className: `${customButton.className || ""} relative flex justify-center gap-2`,
1378
+ ...customButton.attr,
1379
+ children: [
1380
+ customButton.toolTip && /* @__PURE__ */ jsx(ButtonTooltip, { content: customButton.toolTip }),
1381
+ customButton.text,
1382
+ customButton.icon,
1383
+ customButton.children
1384
+ ]
1385
+ },
1386
+ index
1387
+ )) : React22__default.isValidElement(customButtons) ? customButtons : null,
1388
+ text && /* @__PURE__ */ jsx("span", { children: text }),
1389
+ !useDropdown && dropMoreActions && /* @__PURE__ */ jsxs(DropdownMenu, { dir: isArabic ? "rtl" : "ltr", children: [
1390
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "outline", size: "icon", children: /* @__PURE__ */ jsx(MoreVertical, { size: 20 }) }) }),
1391
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-56", children: [
1392
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: t("actions") }),
1393
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
1394
+ /* @__PURE__ */ jsx(DropdownMenuGroup, { children: dropMoreActions.filter((action) => Object.keys(action).length !== 0).map((item, index) => /* @__PURE__ */ jsxs(
1395
+ DropdownMenuItem,
1396
+ {
1397
+ disabled: item.disabled,
1398
+ className: "flex !justify-between",
1399
+ onClick: item.function,
1400
+ children: [
1401
+ /* @__PURE__ */ jsx("span", { children: item.text }),
1402
+ /* @__PURE__ */ jsx(DropdownMenuShortcut, { children: item.icon })
1403
+ ]
1404
+ },
1405
+ index
1406
+ )) })
1407
+ ] })
1408
+ ] })
1409
+ ] });
1410
+ };
1411
+ var table_actions_row_default = TableActionsRow;
1412
+ function DataTableToolbar({
1413
+ table,
1414
+ viewMode,
1415
+ onViewModeChange,
1416
+ filterableColumns = [],
1417
+ searchableColumns = [],
1418
+ newRowLink,
1419
+ addItemPagePath,
1420
+ deleteRowsAction,
1421
+ isShowExportButtons = {
1422
+ isShow: true,
1423
+ ignoredCols: [],
1424
+ fileName: ""
1425
+ },
1426
+ customButtons,
1427
+ isQuerySearch = false,
1428
+ searchableQuery,
1429
+ isQueryFilter = false,
1430
+ handleFilterChange,
1431
+ filterableQuery,
1432
+ currentFilters,
1433
+ onClearFilters,
1434
+ customCss = ""
1435
+ }) {
1436
+ const isFiltered = table.getState().columnFilters.length > 0;
1437
+ const isQueryFiltered = isQueryFilter && currentFilters && Object.keys(currentFilters).length > 0;
1438
+ const hasActiveFilters = isFiltered || isQueryFiltered;
1439
+ const [isPending, startTransition] = React22.useTransition();
1440
+ const [isGoPath, setGoPath] = React22.useState(false);
1441
+ const t = useTableTranslations();
1442
+ const config = useTableConfig();
1443
+ const router = config.router;
1444
+ const [date, setDate] = React22.useState();
1445
+ const isArabic = config.i18n.direction === "rtl" || config.i18n.direction === "auto" && config.i18n.locale === "ar";
1446
+ const goAddItemPage = () => {
1447
+ setGoPath(true);
1448
+ if (addItemPagePath && router) {
1449
+ router.push(addItemPagePath.url);
1450
+ }
1451
+ };
1452
+ const handleExportSelectedRowsCSV = () => {
1453
+ exportSelectedRowsCsv(table, {
1454
+ fileName: isShowExportButtons.fileName,
1455
+ ignoredCols: isShowExportButtons.ignoredCols
1456
+ });
1457
+ };
1458
+ const activeFilterColumns = isQueryFilter ? filterableQuery || [] : filterableColumns;
1459
+ const hasFilters = activeFilterColumns.length > 0;
1460
+ isQuerySearch ? searchableQuery && searchableQuery.length > 0 : searchableColumns.length > 0;
1461
+ return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-3", children: [
1462
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
1463
+ config.features.viewToggle && viewMode && onViewModeChange && /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-lg border bg-muted/30 p-0.5", children: [
1464
+ /* @__PURE__ */ jsxs(
1465
+ "button",
1466
+ {
1467
+ onClick: () => onViewModeChange("table"),
1468
+ className: cn(
1469
+ "inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-colors",
1470
+ viewMode === "table" ? "bg-primary text-primary-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"
1471
+ ),
1472
+ children: [
1473
+ /* @__PURE__ */ jsx(TableIcon, { className: "size-4" }),
1474
+ t("tableView")
1475
+ ]
1476
+ }
1477
+ ),
1478
+ /* @__PURE__ */ jsxs(
1479
+ "button",
1480
+ {
1481
+ onClick: () => onViewModeChange("cards"),
1482
+ className: cn(
1483
+ "inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-colors",
1484
+ viewMode === "cards" ? "bg-primary text-primary-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"
1485
+ ),
1486
+ children: [
1487
+ /* @__PURE__ */ jsx(LayoutGrid, { className: "size-4" }),
1488
+ t("cardView")
1489
+ ]
1490
+ }
1491
+ )
1492
+ ] }),
1493
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 items-center gap-3", children: [
1494
+ config.features.search && isQuerySearch && searchableQuery && searchableQuery.length > 0 && /* @__PURE__ */ jsx(Fragment, { children: searchableQuery.map((column) => /* @__PURE__ */ jsxs("div", { className: "relative flex-1 max-w-sm", children: [
1495
+ /* @__PURE__ */ jsx(Search, { className: "absolute start-3 top-2.5 h-4 w-4 text-muted-foreground" }),
1496
+ /* @__PURE__ */ jsx(
1497
+ Input,
1498
+ {
1499
+ id: String(column.id),
1500
+ type: (column == null ? void 0 : column.type) || "text",
1501
+ placeholder: `${t("Filter")} ${column.title}...`,
1502
+ onChange: column.handleInputChange,
1503
+ defaultValue: column.defaultSearch || "",
1504
+ className: "ps-9"
1505
+ }
1506
+ )
1507
+ ] }, String(column.id))) }),
1508
+ config.features.search && !isQuerySearch && searchableColumns.length > 0 && searchableColumns.map(
1509
+ (column) => {
1510
+ var _a, _b, _c, _d, _e;
1511
+ return table.getColumn(column.id ? String(column.id) : "") && /* @__PURE__ */ jsx("div", { className: "flex-1 max-w-sm", children: (column == null ? void 0 : column.type) === "checkbox" ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1512
+ /* @__PURE__ */ jsx(
1513
+ Checkbox,
1514
+ {
1515
+ id: String(column.id),
1516
+ checked: ((_a = table.getColumn(String(column.id))) == null ? void 0 : _a.getFilterValue()) === "true",
1517
+ onCheckedChange: (value) => {
1518
+ var _a2;
1519
+ return (_a2 = table.getColumn(String(column.id))) == null ? void 0 : _a2.setFilterValue(value ? "true" : "false");
1520
+ },
1521
+ "aria-label": `Filter ${column.title}`,
1522
+ className: "size-4"
1523
+ }
1524
+ ),
1525
+ /* @__PURE__ */ jsx(Label, { className: "cursor-pointer text-sm", htmlFor: String(column.id), children: column.title })
1526
+ ] }) : (column == null ? void 0 : column.type) === "date" ? /* @__PURE__ */ jsxs(Popover, { children: [
1527
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
1528
+ Button,
1529
+ {
1530
+ variant: "outline",
1531
+ className: cn(
1532
+ "w-full justify-start text-start font-normal",
1533
+ !date && "text-muted-foreground"
1534
+ ),
1535
+ children: [
1536
+ /* @__PURE__ */ jsx(CalendarIcon, { className: "me-2 size-4" }),
1537
+ date ? (() => {
1538
+ var _a2;
1539
+ const filterValue = (_a2 = table.getColumn(String(column.id))) == null ? void 0 : _a2.getFilterValue();
1540
+ const parsedDate = filterValue ? new Date(filterValue) : null;
1541
+ return parsedDate && !isNaN(parsedDate.getTime()) ? format(parsedDate, "PPP", {
1542
+ locale: isArabic ? ar : enUS
1543
+ }) : t("datePlaceholder");
1544
+ })() : t("datePlaceholder")
1545
+ ]
1546
+ }
1547
+ ) }),
1548
+ /* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", children: /* @__PURE__ */ jsx(
1549
+ Calendar,
1550
+ {
1551
+ className: "py-2 text-sm",
1552
+ mode: "single",
1553
+ selected: ((_b = table.getColumn(String(column.id))) == null ? void 0 : _b.getFilterValue()) ? new Date(
1554
+ (_c = table.getColumn(String(column.id))) == null ? void 0 : _c.getFilterValue()
1555
+ ) : void 0,
1556
+ onSelect: (selectedDate) => {
1557
+ var _a2;
1558
+ if (selectedDate && !isNaN(selectedDate.getTime())) {
1559
+ (_a2 = table.getColumn(String(column.id))) == null ? void 0 : _a2.setFilterValue(format(selectedDate, "yyyy-MM-dd"));
1560
+ setDate(selectedDate);
1561
+ }
1562
+ },
1563
+ initialFocus: true
1564
+ }
1565
+ ) })
1566
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "relative", children: [
1567
+ /* @__PURE__ */ jsx(Search, { className: "absolute start-3 top-2.5 h-4 w-4 text-muted-foreground" }),
1568
+ /* @__PURE__ */ jsx(
1569
+ Input,
1570
+ {
1571
+ id: String(column.id),
1572
+ type: (column == null ? void 0 : column.type) || "text",
1573
+ placeholder: `${t("Filter")} ${column.title}...`,
1574
+ value: (_e = (_d = table.getColumn(String(column.id))) == null ? void 0 : _d.getFilterValue()) != null ? _e : "",
1575
+ onChange: (event) => {
1576
+ var _a2;
1577
+ return (_a2 = table.getColumn(String(column.id))) == null ? void 0 : _a2.setFilterValue(event.target.value);
1578
+ },
1579
+ className: `ps-9 ${customCss}`
1580
+ },
1581
+ String(column.id)
1582
+ )
1583
+ ] }) }, String(column.id));
1584
+ }
1585
+ )
1586
+ ] }),
1587
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1588
+ deleteRowsAction && table.getSelectedRowModel().rows.length > 0 ? /* @__PURE__ */ jsxs(
1589
+ Button,
1590
+ {
1591
+ "aria-label": "Delete selected rows",
1592
+ variant: "outline",
1593
+ size: "sm",
1594
+ className: "h-9",
1595
+ onClick: (event) => {
1596
+ startTransition(() => {
1597
+ table.toggleAllPageRowsSelected(false);
1598
+ deleteRowsAction(event);
1599
+ });
1600
+ },
1601
+ disabled: isPending,
1602
+ children: [
1603
+ /* @__PURE__ */ jsx(Trash2, { className: "me-2 size-4", "aria-hidden": "true" }),
1604
+ t("Delete")
1605
+ ]
1606
+ }
1607
+ ) : newRowLink ? /* @__PURE__ */ jsxs(
1608
+ "a",
1609
+ {
1610
+ "aria-label": "Create new row",
1611
+ href: newRowLink,
1612
+ className: cn(
1613
+ buttonVariants({
1614
+ variant: "outline",
1615
+ size: "sm",
1616
+ className: "h-9"
1617
+ })
1618
+ ),
1619
+ children: [
1620
+ /* @__PURE__ */ jsx(PlusCircle, { className: "me-2 size-4", "aria-hidden": "true" }),
1621
+ t("new")
1622
+ ]
1623
+ }
1624
+ ) : null,
1625
+ config.features.columnVisibility && /* @__PURE__ */ jsx(DataTableViewOptions, { table }),
1626
+ config.features.csvExport && isShowExportButtons.isShow && /* @__PURE__ */ jsxs(
1627
+ Button,
1628
+ {
1629
+ disabled: !table.getSelectedRowModel().rows.length,
1630
+ "aria-label": "Export CSV",
1631
+ title: "Export CSV",
1632
+ variant: "outline",
1633
+ size: "sm",
1634
+ className: "h-9 gap-1.5",
1635
+ onClick: handleExportSelectedRowsCSV,
1636
+ children: [
1637
+ /* @__PURE__ */ jsx(Sheet, { className: "size-4", "aria-hidden": "true" }),
1638
+ t("export-csv")
1639
+ ]
1640
+ }
1641
+ ),
1642
+ customButtons && Array.isArray(customButtons) ? customButtons.filter((customButton) => Object.keys(customButton).length !== 0).map((customButton, index) => /* @__PURE__ */ jsxs(
1643
+ Button,
1644
+ {
1645
+ onClick: customButton.function,
1646
+ size: "sm",
1647
+ className: `${customButton.className ? customButton.className : ""} relative h-9 gap-1.5`,
1648
+ ...customButton.attr,
1649
+ children: [
1650
+ customButton.toolTip && /* @__PURE__ */ jsx(ButtonTooltip, { content: customButton.toolTip }),
1651
+ customButton.icon,
1652
+ customButton.text,
1653
+ customButton.children
1654
+ ]
1655
+ },
1656
+ index
1657
+ )) : React22.isValidElement(customButtons) ? customButtons : null,
1658
+ addItemPagePath ? (addItemPagePath == null ? void 0 : addItemPagePath.url) ? /* @__PURE__ */ jsxs(
1659
+ Button,
1660
+ {
1661
+ onClick: goAddItemPage,
1662
+ size: "sm",
1663
+ className: "h-9",
1664
+ disabled: isGoPath,
1665
+ children: [
1666
+ isGoPath ? /* @__PURE__ */ jsx(Loader2, { size: 20, className: "animate-spin" }) : /* @__PURE__ */ jsx(Plus, { size: 20 }),
1667
+ addItemPagePath.text ? addItemPagePath.text : t("add")
1668
+ ]
1669
+ }
1670
+ ) : null : null
1671
+ ] })
1672
+ ] }),
1673
+ config.features.filter && hasFilters && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
1674
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground whitespace-nowrap", children: t("filter-by") }),
1675
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
1676
+ !isQueryFilter && filterableColumns.length > 0 && /* @__PURE__ */ jsx(Fragment, { children: filterableColumns.map((column) => {
1677
+ const columnId = String(column.id);
1678
+ if (column.isSingleSelect) {
1679
+ return /* @__PURE__ */ jsx(
1680
+ DataTableSingleSelectFilter,
1681
+ {
1682
+ column: table.getColumn(columnId),
1683
+ title: column.title,
1684
+ options: column.options,
1685
+ className: ""
1686
+ },
1687
+ columnId
1688
+ );
1689
+ }
1690
+ return /* @__PURE__ */ jsx(
1691
+ DataTableFacetedFilter,
1692
+ {
1693
+ column: table.getColumn(columnId),
1694
+ title: column.title,
1695
+ options: column.options
1696
+ },
1697
+ columnId
1698
+ );
1699
+ }) }),
1700
+ isQueryFilter && filterableQuery && filterableQuery.length > 0 && /* @__PURE__ */ jsx(Fragment, { children: filterableQuery.map((column) => {
1701
+ if (column.isSingleSelect) {
1702
+ return /* @__PURE__ */ jsx(
1703
+ DataTableSingleSelectFilter,
1704
+ {
1705
+ column,
1706
+ title: column.title,
1707
+ options: column.options,
1708
+ isQueryFilter,
1709
+ handleFilterChange,
1710
+ currentValue: currentFilters == null ? void 0 : currentFilters[column.id],
1711
+ className: "w-[180px]"
1712
+ },
1713
+ String(column.id)
1714
+ );
1715
+ }
1716
+ return /* @__PURE__ */ jsx(
1717
+ DataTableFacetedFilter,
1718
+ {
1719
+ column,
1720
+ title: column.title,
1721
+ options: column.options,
1722
+ isQueryFilter,
1723
+ handleFilterChange,
1724
+ currentValue: currentFilters == null ? void 0 : currentFilters[column.id]
1725
+ },
1726
+ String(column.id)
1727
+ );
1728
+ }) }),
1729
+ hasActiveFilters && /* @__PURE__ */ jsxs(
1730
+ Button,
1731
+ {
1732
+ "aria-label": "Reset filters",
1733
+ variant: "ghost",
1734
+ size: "sm",
1735
+ className: "h-8 gap-1.5 text-muted-foreground hover:text-foreground",
1736
+ onClick: () => {
1737
+ if (isQueryFilter && onClearFilters) {
1738
+ onClearFilters();
1739
+ } else {
1740
+ table.resetColumnFilters();
1741
+ }
1742
+ },
1743
+ children: [
1744
+ /* @__PURE__ */ jsx(RotateCcw, { className: "size-3.5", "aria-hidden": "true" }),
1745
+ t("Reset")
1746
+ ]
1747
+ }
1748
+ )
1749
+ ] })
1750
+ ] })
1751
+ ] });
1752
+ }
1753
+ var Card = React22.forwardRef(
1754
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1755
+ "div",
1756
+ {
1757
+ ref,
1758
+ className: cn("rounded-xl border bg-card text-card-foreground shadow-sm", className),
1759
+ ...props
1760
+ }
1761
+ )
1762
+ );
1763
+ Card.displayName = "Card";
1764
+ var CardHeader = React22.forwardRef(
1765
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("flex flex-col space-y-1.5 p-6", className), ...props })
1766
+ );
1767
+ CardHeader.displayName = "CardHeader";
1768
+ var CardTitle = React22.forwardRef(
1769
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("font-semibold leading-none tracking-tight", className), ...props })
1770
+ );
1771
+ CardTitle.displayName = "CardTitle";
1772
+ var CardDescription = React22.forwardRef(
1773
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("text-sm text-muted-foreground", className), ...props })
1774
+ );
1775
+ CardDescription.displayName = "CardDescription";
1776
+ var CardContent = React22.forwardRef(
1777
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("p-6 pt-0", className), ...props })
1778
+ );
1779
+ CardContent.displayName = "CardContent";
1780
+ var CardFooter = React22.forwardRef(
1781
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("flex items-center p-6 pt-0", className), ...props })
1782
+ );
1783
+ CardFooter.displayName = "CardFooter";
1784
+ function DataTableCardView({ table }) {
1785
+ const t = useTableTranslations();
1786
+ const rows = table.getRowModel().rows;
1787
+ if (!rows.length) {
1788
+ return /* @__PURE__ */ jsx(Card, { className: "mt-3", children: /* @__PURE__ */ jsx(CardContent, { className: "py-16", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-3", children: [
1789
+ /* @__PURE__ */ jsx(SearchX, { className: "size-10 text-muted-foreground/50", "aria-hidden": "true" }),
1790
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1 text-center", children: [
1791
+ /* @__PURE__ */ jsx("p", { className: "font-semibold", children: t("no-records-found") }),
1792
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("no-records-hint") })
1793
+ ] }),
1794
+ table.getState().columnFilters.length > 0 && /* @__PURE__ */ jsxs(
1795
+ Button,
1796
+ {
1797
+ variant: "outline",
1798
+ size: "sm",
1799
+ className: "mt-1 gap-1.5",
1800
+ onClick: () => table.resetColumnFilters(),
1801
+ children: [
1802
+ /* @__PURE__ */ jsx(RotateCcw, { className: "size-3.5", "aria-hidden": "true" }),
1803
+ t("reset-filters")
1804
+ ]
1805
+ }
1806
+ )
1807
+ ] }) }) });
1808
+ }
1809
+ return /* @__PURE__ */ jsx("div", { className: "mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3", children: rows.map((row) => {
1810
+ const visibleCells = row.getVisibleCells();
1811
+ return /* @__PURE__ */ jsx(
1812
+ Card,
1813
+ {
1814
+ "data-state": row.getIsSelected() && "selected",
1815
+ className: "transition-colors data-[state=selected]:border-primary/50 data-[state=selected]:bg-primary/5",
1816
+ children: /* @__PURE__ */ jsxs(CardContent, { className: "p-4", children: [
1817
+ /* @__PURE__ */ jsxs("div", { className: "mb-3 flex items-center gap-2", children: [
1818
+ /* @__PURE__ */ jsx(
1819
+ Checkbox,
1820
+ {
1821
+ checked: row.getIsSelected(),
1822
+ onCheckedChange: (value) => row.toggleSelected(!!value),
1823
+ "aria-label": t("select"),
1824
+ className: "size-4"
1825
+ }
1826
+ ),
1827
+ /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
1828
+ "#",
1829
+ row.index + 1
1830
+ ] })
1831
+ ] }),
1832
+ /* @__PURE__ */ jsx("div", { className: "space-y-2", children: visibleCells.map((cell) => {
1833
+ if (cell.column.id === "select") return null;
1834
+ const header = cell.column.columnDef.header;
1835
+ const headerLabel = typeof header === "string" ? header : cell.column.id;
1836
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
1837
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground capitalize shrink-0", children: headerLabel }),
1838
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-end", children: flexRender(cell.column.columnDef.cell, cell.getContext()) })
1839
+ ] }, cell.id);
1840
+ }) })
1841
+ ] })
1842
+ },
1843
+ row.id
1844
+ );
1845
+ }) });
1846
+ }
1847
+ function DataTableAdvancedFilter({
1848
+ options,
1849
+ selectedOptions,
1850
+ setSelectedOptions,
1851
+ children
1852
+ }) {
1853
+ const [value, setValue] = React22.useState("");
1854
+ const [open, setOpen] = React22.useState(false);
1855
+ const [selectedOption, setSelectedOption] = React22.useState(options[0]);
1856
+ const t = useTableTranslations();
1857
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
1858
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: children != null ? children : /* @__PURE__ */ jsxs(
1859
+ Button,
1860
+ {
1861
+ variant: "outline",
1862
+ size: "sm",
1863
+ role: "combobox",
1864
+ className: "h-9 gap-1.5",
1865
+ children: [
1866
+ /* @__PURE__ */ jsx(ListFilter, { className: "size-4" }),
1867
+ t("Filter"),
1868
+ /* @__PURE__ */ jsx(ChevronDown, { className: "size-3.5 opacity-50" })
1869
+ ]
1870
+ }
1871
+ ) }),
1872
+ /* @__PURE__ */ jsx(PopoverContent, { className: "w-[220px] p-0", align: "end", children: /* @__PURE__ */ jsxs(Command, { children: [
1873
+ /* @__PURE__ */ jsx(CommandInput, { placeholder: t("filter-by") }),
1874
+ /* @__PURE__ */ jsx(CommandEmpty, { children: t("no-items-found") }),
1875
+ /* @__PURE__ */ jsx(CommandGroup, { heading: t("Filter"), children: options.map((option) => {
1876
+ const isSelected = selectedOptions.some(
1877
+ (sel) => sel.value === option.value && !sel.isMulti
1878
+ );
1879
+ return /* @__PURE__ */ jsxs(
1880
+ CommandItem,
1881
+ {
1882
+ className: "gap-2 capitalize",
1883
+ value: String(option.value),
1884
+ onSelect: (currentValue) => {
1885
+ setValue(currentValue === value ? "" : currentValue);
1886
+ setOpen(false);
1887
+ setSelectedOption(option);
1888
+ setSelectedOptions((prev) => {
1889
+ if (isSelected) {
1890
+ return prev.filter(
1891
+ (item) => item.value !== option.value || item.isMulti
1892
+ );
1893
+ } else {
1894
+ return [...prev, option];
1895
+ }
1896
+ });
1897
+ },
1898
+ children: [
1899
+ option.items.length > 0 ? /* @__PURE__ */ jsx(Rows3, { className: "size-4 text-muted-foreground" }) : /* @__PURE__ */ jsx(Type, { className: "size-4 text-muted-foreground" }),
1900
+ /* @__PURE__ */ jsx("span", { className: "flex-1", children: option.label }),
1901
+ isSelected && /* @__PURE__ */ jsx(Check, { className: "size-4 text-primary" })
1902
+ ]
1903
+ },
1904
+ String(option.value)
1905
+ );
1906
+ }) }),
1907
+ /* @__PURE__ */ jsx(CommandSeparator, {}),
1908
+ /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsxs(
1909
+ CommandItem,
1910
+ {
1911
+ className: "gap-2",
1912
+ onSelect: () => {
1913
+ var _a;
1914
+ setOpen(false);
1915
+ setSelectedOptions([
1916
+ ...selectedOptions,
1917
+ {
1918
+ id: crypto.randomUUID(),
1919
+ label: String(selectedOption == null ? void 0 : selectedOption.label),
1920
+ value: String(selectedOption == null ? void 0 : selectedOption.value),
1921
+ items: (_a = selectedOption == null ? void 0 : selectedOption.items) != null ? _a : [],
1922
+ isMulti: true
1923
+ }
1924
+ ]);
1925
+ },
1926
+ children: [
1927
+ /* @__PURE__ */ jsx(Rows3, { className: "size-4 text-muted-foreground" }),
1928
+ t("advanced-filter")
1929
+ ]
1930
+ }
1931
+ ) })
1932
+ ] }) })
1933
+ ] });
1934
+ }
1935
+ function DataTableAdvancedFilterItem({
1936
+ table,
1937
+ selectedOption,
1938
+ setSelectedOptions
1939
+ }) {
1940
+ var _a;
1941
+ const config = useTableConfig();
1942
+ const router = config.router;
1943
+ const searchParams = router ? router.getSearchParams() : new URLSearchParams();
1944
+ const pathname = router ? router.getPathname() : "";
1945
+ const [value, setValue] = React22.useState("");
1946
+ const debounceValue = useDebounce(value, 500);
1947
+ const [open, setOpen] = React22.useState(true);
1948
+ const selectedValues = selectedOption.items.length > 0 ? Array.from(
1949
+ new Set(
1950
+ (_a = table.getColumn(String(selectedOption.value))) == null ? void 0 : _a.getFilterValue()
1951
+ )
1952
+ ) : [];
1953
+ const filterVarieties = selectedOption.items.length > 0 ? ["is", "is not"] : ["contains", "does not contain", "is", "is not"];
1954
+ const [filterVariety, setFilterVariety] = React22.useState(filterVarieties[0]);
1955
+ const createQueryString = React22.useCallback(
1956
+ (params) => {
1957
+ const newSearchParams = new URLSearchParams(searchParams.toString());
1958
+ for (const [key, value2] of Object.entries(params)) {
1959
+ if (value2 === null) {
1960
+ newSearchParams.delete(key);
1961
+ } else {
1962
+ newSearchParams.set(key, String(value2));
1963
+ }
1964
+ }
1965
+ return newSearchParams.toString();
1966
+ },
1967
+ [searchParams]
1968
+ );
1969
+ React22.useEffect(() => {
1970
+ if (!router) return;
1971
+ if (debounceValue.length > 0) {
1972
+ router.push(
1973
+ `${pathname}?${createQueryString({
1974
+ [selectedOption.value]: `${debounceValue}${debounceValue.length > 0 ? `.${filterVariety}` : ""}`
1975
+ })}`
1976
+ );
1977
+ }
1978
+ if (debounceValue.length === 0) {
1979
+ router.push(
1980
+ `${pathname}?${createQueryString({
1981
+ [selectedOption.value]: null
1982
+ })}`
1983
+ );
1984
+ }
1985
+ }, [debounceValue, filterVariety, selectedOption.value]);
1986
+ const handleRemove = () => {
1987
+ if (router) {
1988
+ router.push(
1989
+ `${pathname}?${createQueryString({
1990
+ [selectedOption.value]: null
1991
+ })}`
1992
+ );
1993
+ }
1994
+ setSelectedOptions(
1995
+ (prev) => prev.filter((item) => item.value !== selectedOption.value)
1996
+ );
1997
+ };
1998
+ const hasValue = value.length > 0 || selectedValues.length > 0;
1999
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
2000
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
2001
+ Button,
2002
+ {
2003
+ variant: "outline",
2004
+ size: "sm",
2005
+ className: cn(
2006
+ "h-8 gap-1.5 rounded-full border-dashed",
2007
+ hasValue && "border-solid border-primary/30 bg-primary/5 text-primary hover:bg-primary/10"
2008
+ ),
2009
+ children: [
2010
+ /* @__PURE__ */ jsx("span", { className: "font-medium capitalize", children: selectedOption.label }),
2011
+ hasValue && /* @__PURE__ */ jsxs(Fragment, { children: [
2012
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: filterVariety }),
2013
+ selectedValues.length > 0 ? /* @__PURE__ */ jsx("span", { className: "font-semibold", children: selectedValues.length > 2 ? `${selectedValues.length} selected` : selectedValues.join(", ") }) : /* @__PURE__ */ jsx("span", { className: "max-w-[100px] truncate font-semibold", children: value })
2014
+ ] }),
2015
+ /* @__PURE__ */ jsx(
2016
+ X,
2017
+ {
2018
+ className: "size-3.5 shrink-0 opacity-50 hover:opacity-100",
2019
+ onClick: (e) => {
2020
+ e.stopPropagation();
2021
+ handleRemove();
2022
+ }
2023
+ }
2024
+ )
2025
+ ]
2026
+ }
2027
+ ) }),
2028
+ /* @__PURE__ */ jsxs(PopoverContent, { className: "w-64 space-y-2 p-3 text-xs", align: "start", children: [
2029
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
2030
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 text-sm font-medium capitalize", children: selectedOption.label }),
2031
+ /* @__PURE__ */ jsxs(Select, { onValueChange: (value2) => setFilterVariety(value2), children: [
2032
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "h-7 w-fit shrink-0 gap-1 rounded-md border-none bg-muted/50 px-2 text-xs font-medium hover:bg-muted", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: filterVarieties[0] }) }),
2033
+ /* @__PURE__ */ jsx(SelectContent, { children: /* @__PURE__ */ jsx(SelectGroup, { children: filterVarieties.map((variety) => /* @__PURE__ */ jsx(SelectItem, { value: variety, className: "text-xs", children: variety }, variety)) }) })
2034
+ ] }),
2035
+ /* @__PURE__ */ jsx("div", { className: "flex-1" }),
2036
+ /* @__PURE__ */ jsx(
2037
+ Button,
2038
+ {
2039
+ "aria-label": "Remove filter",
2040
+ variant: "ghost",
2041
+ size: "icon",
2042
+ className: "size-7 shrink-0 text-muted-foreground hover:text-destructive",
2043
+ onClick: handleRemove,
2044
+ children: /* @__PURE__ */ jsx(Trash2, { className: "size-3.5" })
2045
+ }
2046
+ )
2047
+ ] }),
2048
+ selectedOption.items.length > 0 ? table.getColumn(
2049
+ selectedOption.value ? String(selectedOption.value) : ""
2050
+ ) && /* @__PURE__ */ jsx(
2051
+ DataTableFacetedFilter,
2052
+ {
2053
+ column: table.getColumn(
2054
+ selectedOption.value ? String(selectedOption.value) : ""
2055
+ ),
2056
+ title: selectedOption.label,
2057
+ options: selectedOption.items,
2058
+ variant: "command"
2059
+ },
2060
+ String(selectedOption.value)
2061
+ ) : /* @__PURE__ */ jsx(
2062
+ Input,
2063
+ {
2064
+ placeholder: "Type here...",
2065
+ className: "h-8 text-xs",
2066
+ value,
2067
+ onChange: (event) => setValue(event.target.value),
2068
+ autoFocus: true
2069
+ }
2070
+ )
2071
+ ] })
2072
+ ] });
2073
+ }
2074
+ var operators = [
2075
+ { label: "And", value: "and" },
2076
+ { label: "Or", value: "or" }
2077
+ ];
2078
+ function DataTableMultiFilter({
2079
+ table,
2080
+ allOptions,
2081
+ options,
2082
+ setSelectedOptions
2083
+ }) {
2084
+ const [open, setOpen] = React22.useState(true);
2085
+ const [operator, setOperator] = React22.useState(operators[0]);
2086
+ const t = useTableTranslations();
2087
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
2088
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
2089
+ Button,
2090
+ {
2091
+ variant: "outline",
2092
+ size: "sm",
2093
+ className: "h-8 gap-1.5 rounded-full border-dashed",
2094
+ children: [
2095
+ /* @__PURE__ */ jsx(GripVertical, { className: "size-3.5 text-muted-foreground" }),
2096
+ /* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
2097
+ options.length,
2098
+ " ",
2099
+ options.length === 1 ? "rule" : "rules"
2100
+ ] })
2101
+ ]
2102
+ }
2103
+ ) }),
2104
+ /* @__PURE__ */ jsxs(PopoverContent, { className: "w-fit min-w-[420px] p-0", align: "start", children: [
2105
+ /* @__PURE__ */ jsx("div", { className: "space-y-2 p-4", children: options.map((option, i) => {
2106
+ var _a;
2107
+ return /* @__PURE__ */ jsx(
2108
+ MultiFilterRow,
2109
+ {
2110
+ i,
2111
+ option,
2112
+ table,
2113
+ allOptions,
2114
+ options,
2115
+ setSelectedOptions,
2116
+ operator,
2117
+ setOperator
2118
+ },
2119
+ (_a = option.id) != null ? _a : i
2120
+ );
2121
+ }) }),
2122
+ /* @__PURE__ */ jsx(Separator2, {}),
2123
+ /* @__PURE__ */ jsx("div", { className: "p-2", children: /* @__PURE__ */ jsxs(
2124
+ Button,
2125
+ {
2126
+ "aria-label": "Delete filter",
2127
+ variant: "ghost",
2128
+ size: "sm",
2129
+ className: "w-full justify-start gap-2 text-muted-foreground hover:text-destructive",
2130
+ onClick: () => {
2131
+ setSelectedOptions((prev) => prev.filter((item) => !item.isMulti));
2132
+ },
2133
+ children: [
2134
+ /* @__PURE__ */ jsx(Trash2, { className: "size-3.5" }),
2135
+ t("delete")
2136
+ ]
2137
+ }
2138
+ ) })
2139
+ ] })
2140
+ ] });
2141
+ }
2142
+ function MultiFilterRow({
2143
+ i,
2144
+ table,
2145
+ option,
2146
+ allOptions,
2147
+ options,
2148
+ setSelectedOptions,
2149
+ operator,
2150
+ setOperator
2151
+ }) {
2152
+ const config = useTableConfig();
2153
+ const router = config.router;
2154
+ const searchParams = router ? router.getSearchParams() : new URLSearchParams();
2155
+ const pathname = router ? router.getPathname() : "";
2156
+ const [value, setValue] = React22.useState("");
2157
+ const debounceValue = useDebounce(value, 500);
2158
+ const [selectedOption, setSelectedOption] = React22.useState(options[0]);
2159
+ const filterVarieties = (selectedOption == null ? void 0 : selectedOption.items.length) ? ["is", "is not"] : ["contains", "does not contain", "is", "is not"];
2160
+ const [filterVariety, setFilterVariety] = React22.useState(filterVarieties[0]);
2161
+ React22.useEffect(() => {
2162
+ if (selectedOption == null ? void 0 : selectedOption.items.length) {
2163
+ setFilterVariety("is");
2164
+ }
2165
+ }, [selectedOption == null ? void 0 : selectedOption.items.length]);
2166
+ const createQueryString = React22.useCallback(
2167
+ (params) => {
2168
+ const newSearchParams = new URLSearchParams(searchParams.toString());
2169
+ for (const [key, value2] of Object.entries(params)) {
2170
+ if (value2 === null) {
2171
+ newSearchParams.delete(key);
2172
+ } else {
2173
+ newSearchParams.set(key, String(value2));
2174
+ }
2175
+ }
2176
+ return newSearchParams.toString();
2177
+ },
2178
+ [searchParams]
2179
+ );
2180
+ React22.useEffect(() => {
2181
+ var _a, _b;
2182
+ if (!router) return;
2183
+ if (debounceValue.length > 0) {
2184
+ router.push(
2185
+ `${pathname}?${createQueryString({
2186
+ [(_a = selectedOption == null ? void 0 : selectedOption.value) != null ? _a : ""]: `${debounceValue}${debounceValue.length > 0 ? `.${filterVariety}` : ""}`
2187
+ })}`
2188
+ );
2189
+ }
2190
+ if (debounceValue.length === 0) {
2191
+ router.push(
2192
+ `${pathname}?${createQueryString({
2193
+ [(_b = selectedOption == null ? void 0 : selectedOption.value) != null ? _b : ""]: null
2194
+ })}`
2195
+ );
2196
+ }
2197
+ }, [debounceValue, filterVariety, selectedOption == null ? void 0 : selectedOption.value]);
2198
+ React22.useEffect(() => {
2199
+ if (!router) return;
2200
+ if (operator == null ? void 0 : operator.value) {
2201
+ router.push(
2202
+ `${pathname}?${createQueryString({
2203
+ operator: operator.value
2204
+ })}`
2205
+ );
2206
+ }
2207
+ }, [operator == null ? void 0 : operator.value]);
2208
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
2209
+ /* @__PURE__ */ jsx("div", { className: "w-[60px] shrink-0", children: i === 0 ? /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: "Where" }) : i === 1 ? /* @__PURE__ */ jsxs(
2210
+ Select,
2211
+ {
2212
+ value: operator == null ? void 0 : operator.value,
2213
+ onValueChange: (value2) => {
2214
+ const found = operators.find((o) => o.value === value2);
2215
+ if (found) setOperator(found);
2216
+ },
2217
+ children: [
2218
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "h-8 w-[60px] text-xs", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: operator == null ? void 0 : operator.label }) }),
2219
+ /* @__PURE__ */ jsx(SelectContent, { children: /* @__PURE__ */ jsx(SelectGroup, { children: operators.map((op) => /* @__PURE__ */ jsx(
2220
+ SelectItem,
2221
+ {
2222
+ value: op.value,
2223
+ className: "text-xs",
2224
+ children: op.label
2225
+ },
2226
+ op.value
2227
+ )) }) })
2228
+ ]
2229
+ }
2230
+ ) : /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: operator == null ? void 0 : operator.label }, operator == null ? void 0 : operator.value) }),
2231
+ /* @__PURE__ */ jsxs(
2232
+ Select,
2233
+ {
2234
+ value: String(selectedOption == null ? void 0 : selectedOption.value),
2235
+ onValueChange: (value2) => {
2236
+ setSelectedOption(allOptions.find((option2) => option2.value === value2));
2237
+ setSelectedOptions(
2238
+ (prev) => prev.map((item) => {
2239
+ if (item.id === option.id) {
2240
+ return { ...item, value: value2 };
2241
+ } else {
2242
+ return item;
2243
+ }
2244
+ })
2245
+ );
2246
+ },
2247
+ children: [
2248
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "h-8 w-[120px] text-xs capitalize", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: selectedOption == null ? void 0 : selectedOption.label }) }),
2249
+ /* @__PURE__ */ jsx(SelectContent, { children: /* @__PURE__ */ jsx(SelectGroup, { children: allOptions.map((opt) => /* @__PURE__ */ jsx(
2250
+ SelectItem,
2251
+ {
2252
+ value: String(opt.value),
2253
+ className: "text-xs capitalize",
2254
+ children: opt.label
2255
+ },
2256
+ String(opt.value)
2257
+ )) }) })
2258
+ ]
2259
+ }
2260
+ ),
2261
+ /* @__PURE__ */ jsxs(
2262
+ Select,
2263
+ {
2264
+ value: filterVariety,
2265
+ onValueChange: (value2) => setFilterVariety(value2),
2266
+ children: [
2267
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "h-8 w-[140px] text-xs", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: filterVarieties[0] }) }),
2268
+ /* @__PURE__ */ jsx(SelectContent, { children: /* @__PURE__ */ jsx(SelectGroup, { children: filterVarieties.map((variety) => /* @__PURE__ */ jsx(SelectItem, { value: variety, className: "text-xs", children: variety }, variety)) }) })
2269
+ ]
2270
+ }
2271
+ ),
2272
+ (selectedOption == null ? void 0 : selectedOption.items.length) ? table.getColumn(selectedOption.value ? String(option.value) : "") && /* @__PURE__ */ jsx(
2273
+ DataTableFacetedFilter,
2274
+ {
2275
+ column: table.getColumn(
2276
+ selectedOption.value ? String(selectedOption.value) : ""
2277
+ ),
2278
+ title: selectedOption.label,
2279
+ options: selectedOption.items
2280
+ },
2281
+ selectedOption.id
2282
+ ) : /* @__PURE__ */ jsx(
2283
+ Input,
2284
+ {
2285
+ placeholder: "Type here...",
2286
+ className: "h-8 min-w-[120px] text-xs",
2287
+ value,
2288
+ onChange: (event) => setValue(event.target.value),
2289
+ autoFocus: true
2290
+ }
2291
+ ),
2292
+ /* @__PURE__ */ jsxs(DropdownMenu, { children: [
2293
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "size-8 shrink-0", children: /* @__PURE__ */ jsx(MoreHorizontal, { className: "size-4" }) }) }),
2294
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", children: [
2295
+ /* @__PURE__ */ jsxs(
2296
+ DropdownMenuItem,
2297
+ {
2298
+ className: "gap-2 text-destructive focus:text-destructive",
2299
+ onClick: () => {
2300
+ setSelectedOptions(
2301
+ (prev) => prev.filter((item) => item.id !== option.id)
2302
+ );
2303
+ },
2304
+ children: [
2305
+ /* @__PURE__ */ jsx(Trash2, { className: "size-3.5" }),
2306
+ "Remove"
2307
+ ]
2308
+ }
2309
+ ),
2310
+ /* @__PURE__ */ jsxs(
2311
+ DropdownMenuItem,
2312
+ {
2313
+ className: "gap-2",
2314
+ onClick: () => {
2315
+ setSelectedOptions((prev) => {
2316
+ var _a;
2317
+ return [
2318
+ ...prev,
2319
+ {
2320
+ id: crypto.randomUUID(),
2321
+ label: String(selectedOption == null ? void 0 : selectedOption.label),
2322
+ value: String(selectedOption == null ? void 0 : selectedOption.value),
2323
+ isMulti: true,
2324
+ items: (_a = selectedOption == null ? void 0 : selectedOption.items) != null ? _a : []
2325
+ }
2326
+ ];
2327
+ });
2328
+ },
2329
+ children: [
2330
+ /* @__PURE__ */ jsx(Copy, { className: "size-3.5" }),
2331
+ "Duplicate"
2332
+ ]
2333
+ }
2334
+ )
2335
+ ] })
2336
+ ] })
2337
+ ] });
2338
+ }
2339
+ function DataTableAdvancedToolbar({
2340
+ table,
2341
+ filterableColumns = [],
2342
+ searchableColumns = [],
2343
+ addItemPagePath
2344
+ }) {
2345
+ const [selectedOptions, setSelectedOptions] = React22.useState([]);
2346
+ const [open, setOpen] = React22.useState(false);
2347
+ const t = useTableTranslations();
2348
+ const config = useTableConfig();
2349
+ const router = config.router;
2350
+ React22.useEffect(() => {
2351
+ if (selectedOptions.length > 0) {
2352
+ setOpen(true);
2353
+ }
2354
+ }, [selectedOptions]);
2355
+ const options = React22.useMemo(() => {
2356
+ const searchableOptions = searchableColumns.map((column) => {
2357
+ var _a;
2358
+ return {
2359
+ id: crypto.randomUUID(),
2360
+ label: (_a = column.title) != null ? _a : String(column.id),
2361
+ value: column.id,
2362
+ items: []
2363
+ };
2364
+ });
2365
+ const filterableOptions = filterableColumns.map((column) => ({
2366
+ id: crypto.randomUUID(),
2367
+ label: column.title,
2368
+ value: column.id,
2369
+ items: column.options
2370
+ }));
2371
+ return [...searchableOptions, ...filterableOptions];
2372
+ }, [filterableColumns, searchableColumns]);
2373
+ const goAddItemPage = () => {
2374
+ if (addItemPagePath && router) {
2375
+ router.push(addItemPagePath);
2376
+ }
2377
+ };
2378
+ const handleClearAll = () => {
2379
+ var _a, _b;
2380
+ setSelectedOptions([]);
2381
+ setOpen(false);
2382
+ for (const col of searchableColumns) {
2383
+ (_a = table.getColumn(String(col.id))) == null ? void 0 : _a.setFilterValue("");
2384
+ }
2385
+ for (const col of filterableColumns) {
2386
+ (_b = table.getColumn(String(col.id))) == null ? void 0 : _b.setFilterValue(void 0);
2387
+ }
2388
+ };
2389
+ const hasActiveFilters = selectedOptions.length > 0 || searchableColumns.some(
2390
+ (col) => {
2391
+ var _a;
2392
+ return !!((_a = table.getColumn(String(col.id))) == null ? void 0 : _a.getFilterValue());
2393
+ }
2394
+ );
2395
+ return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-3", children: [
2396
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
2397
+ /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center gap-3", children: searchableColumns.length > 0 && searchableColumns.map(
2398
+ (column) => {
2399
+ var _a, _b, _c;
2400
+ return table.getColumn(column.id ? String(column.id) : "") && /* @__PURE__ */ jsxs("div", { className: "relative flex-1 max-w-sm", children: [
2401
+ /* @__PURE__ */ jsx(Search, { className: "absolute start-3 top-2.5 size-4 text-muted-foreground" }),
2402
+ /* @__PURE__ */ jsx(
2403
+ Input,
2404
+ {
2405
+ placeholder: `${t("Filter")} ${(_a = column.title) != null ? _a : String(column.id)}...`,
2406
+ value: (_c = (_b = table.getColumn(String(column.id))) == null ? void 0 : _b.getFilterValue()) != null ? _c : "",
2407
+ onChange: (event) => {
2408
+ var _a2;
2409
+ return (_a2 = table.getColumn(String(column.id))) == null ? void 0 : _a2.setFilterValue(event.target.value);
2410
+ },
2411
+ className: "ps-9"
2412
+ }
2413
+ )
2414
+ ] }, String(column.id));
2415
+ }
2416
+ ) }),
2417
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
2418
+ selectedOptions.length > 0 ? /* @__PURE__ */ jsxs(
2419
+ Button,
2420
+ {
2421
+ variant: "outline",
2422
+ size: "sm",
2423
+ className: "h-9 gap-1.5",
2424
+ onClick: () => setOpen((prev) => !prev),
2425
+ children: [
2426
+ /* @__PURE__ */ jsx(ListFilter, { className: "size-4" }),
2427
+ t("Filter"),
2428
+ /* @__PURE__ */ jsx("span", { className: "flex size-5 items-center justify-center rounded-full bg-primary text-[10px] font-bold text-primary-foreground", children: selectedOptions.length })
2429
+ ]
2430
+ }
2431
+ ) : /* @__PURE__ */ jsx(
2432
+ DataTableAdvancedFilter,
2433
+ {
2434
+ options: options.filter(
2435
+ (option) => !selectedOptions.some(
2436
+ (selectedOption) => selectedOption.value === option.value
2437
+ )
2438
+ ),
2439
+ selectedOptions,
2440
+ setSelectedOptions
2441
+ }
2442
+ ),
2443
+ /* @__PURE__ */ jsx(DataTableViewOptions, { table }),
2444
+ addItemPagePath && /* @__PURE__ */ jsxs(
2445
+ Button,
2446
+ {
2447
+ onClick: goAddItemPage,
2448
+ size: "sm",
2449
+ className: "h-9",
2450
+ children: [
2451
+ /* @__PURE__ */ jsx(Plus, { className: "size-4" }),
2452
+ t("add")
2453
+ ]
2454
+ }
2455
+ )
2456
+ ] })
2457
+ ] }),
2458
+ open && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
2459
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-muted-foreground whitespace-nowrap", children: t("filter-by") }),
2460
+ selectedOptions.some((option) => option.isMulti) && /* @__PURE__ */ jsx(
2461
+ DataTableMultiFilter,
2462
+ {
2463
+ table,
2464
+ allOptions: options,
2465
+ options: selectedOptions.filter((option) => option.isMulti),
2466
+ setSelectedOptions
2467
+ }
2468
+ ),
2469
+ selectedOptions.filter((option) => !option.isMulti).map((selectedOption) => /* @__PURE__ */ jsx(
2470
+ DataTableAdvancedFilterItem,
2471
+ {
2472
+ table,
2473
+ selectedOption,
2474
+ setSelectedOptions
2475
+ },
2476
+ String(selectedOption.value)
2477
+ )),
2478
+ /* @__PURE__ */ jsx(
2479
+ DataTableAdvancedFilter,
2480
+ {
2481
+ options,
2482
+ selectedOptions,
2483
+ setSelectedOptions,
2484
+ children: /* @__PURE__ */ jsxs(
2485
+ Button,
2486
+ {
2487
+ variant: "outline",
2488
+ size: "sm",
2489
+ role: "combobox",
2490
+ className: "h-8 gap-1.5 rounded-full border-dashed text-muted-foreground hover:text-foreground",
2491
+ children: [
2492
+ /* @__PURE__ */ jsx(Plus, { className: "size-3.5" }),
2493
+ t("add-filter")
2494
+ ]
2495
+ }
2496
+ )
2497
+ }
2498
+ ),
2499
+ hasActiveFilters && /* @__PURE__ */ jsxs(
2500
+ Button,
2501
+ {
2502
+ variant: "ghost",
2503
+ size: "sm",
2504
+ className: "h-8 gap-1.5 text-muted-foreground hover:text-foreground",
2505
+ onClick: handleClearAll,
2506
+ children: [
2507
+ /* @__PURE__ */ jsx(RotateCcw, { className: "size-3.5" }),
2508
+ t("Reset")
2509
+ ]
2510
+ }
2511
+ )
2512
+ ] })
2513
+ ] });
2514
+ }
2515
+ var Drawer = ({ shouldScaleBackground = true, ...props }) => /* @__PURE__ */ jsx(Drawer$1.Root, { shouldScaleBackground, ...props });
2516
+ Drawer.displayName = "Drawer";
2517
+ var DrawerTrigger = Drawer$1.Trigger;
2518
+ var DrawerPortal = Drawer$1.Portal;
2519
+ var DrawerClose = Drawer$1.Close;
2520
+ var DrawerOverlay = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2521
+ Drawer$1.Overlay,
2522
+ {
2523
+ ref,
2524
+ className: cn("fixed inset-0 z-50 bg-black/80", className),
2525
+ ...props
2526
+ }
2527
+ ));
2528
+ DrawerOverlay.displayName = Drawer$1.Overlay.displayName;
2529
+ var DrawerContent = React22.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(DrawerPortal, { children: [
2530
+ /* @__PURE__ */ jsx(DrawerOverlay, {}),
2531
+ /* @__PURE__ */ jsxs(
2532
+ Drawer$1.Content,
2533
+ {
2534
+ ref,
2535
+ className: cn(
2536
+ "fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",
2537
+ className
2538
+ ),
2539
+ ...props,
2540
+ children: [
2541
+ /* @__PURE__ */ jsx("div", { className: "mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" }),
2542
+ children
2543
+ ]
2544
+ }
2545
+ )
2546
+ ] }));
2547
+ DrawerContent.displayName = "DrawerContent";
2548
+ var DrawerHeader = ({ className, ...props }) => /* @__PURE__ */ jsx("div", { className: cn("grid gap-1.5 p-4 text-center sm:text-start", className), ...props });
2549
+ DrawerHeader.displayName = "DrawerHeader";
2550
+ var DrawerFooter = ({ className, ...props }) => /* @__PURE__ */ jsx("div", { className: cn("mt-auto flex flex-col gap-2 p-4", className), ...props });
2551
+ DrawerFooter.displayName = "DrawerFooter";
2552
+ var DrawerTitle = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2553
+ Drawer$1.Title,
2554
+ {
2555
+ ref,
2556
+ className: cn("text-lg font-semibold leading-none tracking-tight", className),
2557
+ ...props
2558
+ }
2559
+ ));
2560
+ DrawerTitle.displayName = Drawer$1.Title.displayName;
2561
+ var DrawerDescription = React22.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
2562
+ Drawer$1.Description,
2563
+ {
2564
+ ref,
2565
+ className: cn("text-sm text-muted-foreground", className),
2566
+ ...props
2567
+ }
2568
+ ));
2569
+ DrawerDescription.displayName = Drawer$1.Description.displayName;
2570
+ function DataTableMobileToolbar({
2571
+ table,
2572
+ filterableColumns = [],
2573
+ searchableColumns = [],
2574
+ addItemPagePath,
2575
+ isShowExportButtons = {
2576
+ isShow: true,
2577
+ ignoredCols: [],
2578
+ fileName: ""
2579
+ },
2580
+ customButtons
2581
+ }) {
2582
+ const isFiltered = table.getState().columnFilters.length > 0;
2583
+ const [isGoPath, setGoPath] = React22.useState(false);
2584
+ const t = useTableTranslations();
2585
+ const config = useTableConfig();
2586
+ const router = config.router;
2587
+ const [date, setDate] = React22.useState();
2588
+ const isArabic = config.i18n.direction === "rtl" || config.i18n.direction === "auto" && config.i18n.locale === "ar";
2589
+ const goAddItemPage = () => {
2590
+ setGoPath(true);
2591
+ if (addItemPagePath && router) {
2592
+ router.push(addItemPagePath.url);
2593
+ }
2594
+ };
2595
+ const handleExportSelectedRowsCSV = () => {
2596
+ exportSelectedRowsCsv(table, {
2597
+ fileName: isShowExportButtons.fileName,
2598
+ ignoredCols: isShowExportButtons.ignoredCols
2599
+ });
2600
+ };
2601
+ return /* @__PURE__ */ jsxs(Drawer, { children: [
2602
+ /* @__PURE__ */ jsx(DrawerTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", className: "h-8 px-2", children: [
2603
+ isFiltered ? /* @__PURE__ */ jsx("span", { className: "bg-main me-2 inline-flex size-3 rounded-full" }) : /* @__PURE__ */ jsx(Filter, { className: "me-2 size-4", "aria-hidden": "true" }),
2604
+ t("Filter")
2605
+ ] }) }),
2606
+ isShowExportButtons.isShow && /* @__PURE__ */ jsxs(
2607
+ Button,
2608
+ {
2609
+ disabled: !table.getSelectedRowModel().rows.length,
2610
+ "aria-label": t("export-csv"),
2611
+ title: t("export-csv"),
2612
+ variant: "outline",
2613
+ className: "h-8 px-2 text-sm",
2614
+ onClick: handleExportSelectedRowsCSV,
2615
+ children: [
2616
+ /* @__PURE__ */ jsx(Sheet, { className: "me-2 size-4", "aria-hidden": "true" }),
2617
+ t("export-csv")
2618
+ ]
2619
+ }
2620
+ ),
2621
+ addItemPagePath ? (addItemPagePath == null ? void 0 : addItemPagePath.url) ? /* @__PURE__ */ jsxs(
2622
+ Button,
2623
+ {
2624
+ onClick: goAddItemPage,
2625
+ size: "sm",
2626
+ className: "flex h-8 flex-row gap-3 px-2 text-sm",
2627
+ disabled: isGoPath,
2628
+ children: [
2629
+ isGoPath ? /* @__PURE__ */ jsx(Loader2, { size: 20, className: "animate-spin" }) : /* @__PURE__ */ jsx(Plus, { size: 20 }),
2630
+ addItemPagePath.text ? addItemPagePath.text : t("add")
2631
+ ]
2632
+ }
2633
+ ) : null : null,
2634
+ /* @__PURE__ */ jsx(DrawerContent, { children: /* @__PURE__ */ jsxs("div", { className: "mx-auto size-full max-w-sm text-sm", children: [
2635
+ /* @__PURE__ */ jsxs(DrawerHeader, { children: [
2636
+ /* @__PURE__ */ jsx(DrawerTitle, { children: t("Filter") }),
2637
+ /* @__PURE__ */ jsx(DrawerDescription, { children: t("data-table-filter") })
2638
+ ] }),
2639
+ /* @__PURE__ */ jsx("div", { className: "p-4 pb-0 text-sm", children: /* @__PURE__ */ jsx("div", { className: "mt-3", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-4", children: [
2640
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-end gap-2", children: [
2641
+ searchableColumns.length > 0 && searchableColumns.map(
2642
+ (column) => {
2643
+ var _a, _b, _c, _d, _e;
2644
+ return table.getColumn(column.id ? String(column.id) : "") && /* @__PURE__ */ jsx("div", { className: "w-full space-y-2", children: (column == null ? void 0 : column.type) === "checkbox" ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex justify-between gap-2", children: [
2645
+ /* @__PURE__ */ jsx(Label, { className: "cursor-pointer", htmlFor: String(column.id), children: column.title }),
2646
+ /* @__PURE__ */ jsx(
2647
+ Checkbox,
2648
+ {
2649
+ id: String(column.id),
2650
+ checked: ((_a = table.getColumn(String(column.id))) == null ? void 0 : _a.getFilterValue()) === "true",
2651
+ onCheckedChange: (value) => {
2652
+ var _a2;
2653
+ return (_a2 = table.getColumn(String(column.id))) == null ? void 0 : _a2.setFilterValue(value ? "true" : "false");
2654
+ },
2655
+ "aria-label": `Filter ${column.title}`,
2656
+ className: "size-4"
2657
+ }
2658
+ )
2659
+ ] }) : (column == null ? void 0 : column.type) === "date" ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-start gap-2", children: [
2660
+ /* @__PURE__ */ jsx(Label, { htmlFor: String(column.id), children: column.title }),
2661
+ /* @__PURE__ */ jsxs(Popover, { children: [
2662
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
2663
+ Button,
2664
+ {
2665
+ variant: "outline",
2666
+ className: cn(
2667
+ "w-full justify-start text-start font-normal",
2668
+ !date && "text-muted-foreground"
2669
+ ),
2670
+ children: [
2671
+ /* @__PURE__ */ jsx(CalendarIcon, { className: "mx-2 size-4" }),
2672
+ date ? (() => {
2673
+ var _a2;
2674
+ const filterValue = (_a2 = table.getColumn(String(column.id))) == null ? void 0 : _a2.getFilterValue();
2675
+ const parsedDate = filterValue && !isNaN(new Date(filterValue).getTime()) ? new Date(filterValue) : null;
2676
+ return parsedDate ? format(parsedDate, "PPP", {
2677
+ locale: isArabic ? ar : enUS
2678
+ }) : `${t("Filter")} ${column.title}...`;
2679
+ })() : `${t("Filter")} ${column.title}...`
2680
+ ]
2681
+ }
2682
+ ) }),
2683
+ /* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", children: /* @__PURE__ */ jsx(
2684
+ Calendar,
2685
+ {
2686
+ className: "py-2 text-sm",
2687
+ mode: "single",
2688
+ selected: ((_b = table.getColumn(String(column.id))) == null ? void 0 : _b.getFilterValue()) ? new Date(
2689
+ (_c = table.getColumn(String(column.id))) == null ? void 0 : _c.getFilterValue()
2690
+ ) : void 0,
2691
+ onSelect: (selectedDate) => {
2692
+ var _a2;
2693
+ if (selectedDate && !isNaN(selectedDate.getTime())) {
2694
+ (_a2 = table.getColumn(String(column.id))) == null ? void 0 : _a2.setFilterValue(format(selectedDate, "yyyy-MM-dd"));
2695
+ setDate(selectedDate);
2696
+ }
2697
+ },
2698
+ initialFocus: true
2699
+ }
2700
+ ) })
2701
+ ] })
2702
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2703
+ /* @__PURE__ */ jsx(Label, { htmlFor: String(column.id), children: column.title }),
2704
+ /* @__PURE__ */ jsx(
2705
+ Input,
2706
+ {
2707
+ id: String(column.id),
2708
+ type: (column == null ? void 0 : column.type) || "text",
2709
+ placeholder: `${t("Filter")} ${column.title}...`,
2710
+ value: (_e = (_d = table.getColumn(String(column.id))) == null ? void 0 : _d.getFilterValue()) != null ? _e : "",
2711
+ onChange: (event) => {
2712
+ var _a2;
2713
+ return (_a2 = table.getColumn(String(column.id))) == null ? void 0 : _a2.setFilterValue(event.target.value);
2714
+ },
2715
+ className: "h-8 w-full py-0"
2716
+ },
2717
+ String(column.id)
2718
+ )
2719
+ ] }) }, String(column.id));
2720
+ }
2721
+ ),
2722
+ /* @__PURE__ */ jsx(Separator2, { className: "bg-main-300 my-2 h-px w-full" }),
2723
+ /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col gap-4", children: filterableColumns.length > 0 && filterableColumns.map(
2724
+ (column) => table.getColumn(column.id ? String(column.id) : "") && /* @__PURE__ */ jsx(
2725
+ DataTableFacetedFilter,
2726
+ {
2727
+ className: "justify-start",
2728
+ column: table.getColumn(column.id ? String(column.id) : ""),
2729
+ title: column.title,
2730
+ options: column.options
2731
+ },
2732
+ String(column.id)
2733
+ )
2734
+ ) }),
2735
+ /* @__PURE__ */ jsx(Separator2, { className: "bg-main-300 my-2 h-px w-full" })
2736
+ ] }),
2737
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-4", children: [
2738
+ /* @__PURE__ */ jsx(DataTableViewOptions, { table }),
2739
+ customButtons && Array.isArray(customButtons) ? customButtons.filter((customButton) => Object.keys(customButton).length !== 0).map((customButton, index) => /* @__PURE__ */ jsxs(
2740
+ Button,
2741
+ {
2742
+ onClick: customButton.function,
2743
+ variant: "outline",
2744
+ className: `${customButton.className ? customButton.className : ""} relative flex justify-center gap-2 text-nowrap text-sm`,
2745
+ ...customButton.attr,
2746
+ children: [
2747
+ customButton.toolTip && /* @__PURE__ */ jsx(ButtonTooltip, { content: customButton.toolTip }),
2748
+ customButton.text,
2749
+ customButton.icon,
2750
+ customButton.children
2751
+ ]
2752
+ },
2753
+ index
2754
+ )) : React22.isValidElement(customButtons) ? customButtons : null
2755
+ ] })
2756
+ ] }) }) }),
2757
+ /* @__PURE__ */ jsxs(DrawerFooter, { className: "grid grid-cols-2", children: [
2758
+ /* @__PURE__ */ jsx(Separator2, { className: "bg-main-300 col-span-2 my-2 h-px" }),
2759
+ /* @__PURE__ */ jsx(DrawerClose, { asChild: true, children: /* @__PURE__ */ jsx(Button, { disabled: !isFiltered, children: t("Apply") }) }),
2760
+ /* @__PURE__ */ jsxs(
2761
+ Button,
2762
+ {
2763
+ "aria-label": "Reset filters",
2764
+ variant: "outline",
2765
+ disabled: !isFiltered,
2766
+ onClick: () => table.resetColumnFilters(),
2767
+ children: [
2768
+ t("Reset"),
2769
+ /* @__PURE__ */ jsx(X, { className: "ms-2 size-4", "aria-hidden": "true" })
2770
+ ]
2771
+ }
2772
+ )
2773
+ ] })
2774
+ ] }) })
2775
+ ] });
2776
+ }
2777
+ var EMPTY_DATA = [];
2778
+ function DataTable({
2779
+ columns,
2780
+ data,
2781
+ pageCount,
2782
+ pageSize: defaultPageSize,
2783
+ filterableColumns = [],
2784
+ searchableColumns = [],
2785
+ showFilter,
2786
+ showPagination,
2787
+ floatingBar,
2788
+ deleteRowsAction,
2789
+ addItemPagePath,
2790
+ isShowExportButtons = {
2791
+ isShow: true,
2792
+ ignoredCols: [],
2793
+ fileName: ""
2794
+ },
2795
+ customButtons,
2796
+ isQueryPagination = false,
2797
+ paginationData,
2798
+ isQuerySearch = false,
2799
+ searchableQuery = [],
2800
+ isLoading,
2801
+ isQueryFilter = false,
2802
+ handleFilterChange,
2803
+ filterableQuery,
2804
+ currentFilters,
2805
+ onClearFilters,
2806
+ customCss,
2807
+ isShowAdvancedFilter,
2808
+ config: instanceConfig
2809
+ }) {
2810
+ var _a, _b, _c, _d, _e, _f;
2811
+ const t = useTableTranslations();
2812
+ const resolvedConfig = useResolvedTableConfig(instanceConfig);
2813
+ const router = resolvedConfig.router;
2814
+ const shouldShowFilter = showFilter != null ? showFilter : resolvedConfig.features.filter;
2815
+ const shouldShowPagination = showPagination != null ? showPagination : resolvedConfig.features.pagination;
2816
+ floatingBar != null ? floatingBar : resolvedConfig.features.floatingBar;
2817
+ const shouldShowAdvancedFilter = isShowAdvancedFilter != null ? isShowAdvancedFilter : resolvedConfig.features.advancedFilter;
2818
+ const resolvedPageSize = defaultPageSize != null ? defaultPageSize : resolvedConfig.pagination.defaultPageSize;
2819
+ const isManualFiltering = isQuerySearch || isQueryFilter;
2820
+ const isManualPagination = isQueryPagination;
2821
+ const isManualSorting = isQueryPagination || isQuerySearch || isQueryFilter;
2822
+ const searchParams = router ? router.getSearchParams() : new URLSearchParams();
2823
+ const pathname = router ? router.getPathname() : "";
2824
+ const page = (_a = searchParams.get("page")) != null ? _a : "1";
2825
+ const pageAsNumber = Number(page);
2826
+ const fallbackPage = isNaN(pageAsNumber) || pageAsNumber < 1 ? 1 : pageAsNumber;
2827
+ const per_page = (_b = searchParams.get("per_page")) != null ? _b : "10";
2828
+ const perPageAsNumber = Number(per_page);
2829
+ const fallbackPerPage = isNaN(perPageAsNumber) ? resolvedPageSize : perPageAsNumber;
2830
+ const sort = searchParams.get("sort");
2831
+ const [column, order] = (_c = sort == null ? void 0 : sort.split(".")) != null ? _c : [];
2832
+ const createQueryString = React22.useCallback(
2833
+ (params) => {
2834
+ const newSearchParams = new URLSearchParams(searchParams.toString());
2835
+ for (const [key, value] of Object.entries(params)) {
2836
+ if (value === null) {
2837
+ newSearchParams.delete(key);
2838
+ } else {
2839
+ newSearchParams.set(key, String(value));
2840
+ }
2841
+ }
2842
+ return newSearchParams.toString();
2843
+ },
2844
+ [searchParams]
2845
+ );
2846
+ const [viewMode, setViewMode] = React22.useState("table");
2847
+ const [rowSelection, setRowSelection] = React22.useState({});
2848
+ const [columnVisibility, setColumnVisibility] = React22.useState({});
2849
+ const initializeColumnFilters = React22.useCallback(() => {
2850
+ const filters = [];
2851
+ if (!isQuerySearch && searchableColumns.length > 0) {
2852
+ for (const col of searchableColumns) {
2853
+ const urlValue = searchParams.get(String(col.id));
2854
+ if (urlValue) {
2855
+ filters.push({ id: String(col.id), value: urlValue });
2856
+ }
2857
+ }
2858
+ }
2859
+ if (!isQueryFilter && filterableColumns.length > 0) {
2860
+ for (const col of filterableColumns) {
2861
+ const urlValue = searchParams.get(String(col.id));
2862
+ if (urlValue) {
2863
+ filters.push({ id: String(col.id), value: urlValue.split(".") });
2864
+ }
2865
+ }
2866
+ }
2867
+ return filters;
2868
+ }, [searchParams, searchableColumns, filterableColumns, isQuerySearch, isQueryFilter]);
2869
+ const [columnFilters, setColumnFilters] = React22.useState(initializeColumnFilters);
2870
+ React22.useEffect(() => {
2871
+ const urlFilters = initializeColumnFilters();
2872
+ setColumnFilters((prevFilters) => {
2873
+ const urlFilterString = JSON.stringify(urlFilters);
2874
+ const prevFilterString = JSON.stringify(prevFilters);
2875
+ if (urlFilterString !== prevFilterString) {
2876
+ return urlFilters;
2877
+ }
2878
+ return prevFilters;
2879
+ });
2880
+ }, [initializeColumnFilters]);
2881
+ const [{ pageIndex, pageSize }, setPagination] = React22.useState({
2882
+ pageIndex: fallbackPage - 1,
2883
+ pageSize: fallbackPerPage
2884
+ });
2885
+ const pagination = React22.useMemo(
2886
+ () => ({ pageIndex, pageSize }),
2887
+ [pageIndex, pageSize]
2888
+ );
2889
+ React22.useEffect(() => {
2890
+ setPagination({
2891
+ pageIndex: fallbackPage - 1,
2892
+ pageSize: fallbackPerPage
2893
+ });
2894
+ }, [fallbackPage, fallbackPerPage]);
2895
+ const paginationMountRef = React22.useRef(true);
2896
+ React22.useEffect(() => {
2897
+ if (isQueryPagination || !router) return;
2898
+ if (paginationMountRef.current) {
2899
+ paginationMountRef.current = false;
2900
+ return;
2901
+ }
2902
+ const replaceUrl = router.replace || router.push;
2903
+ replaceUrl(`${pathname}?${createQueryString({ page: pageIndex + 1, per_page: pageSize })}`);
2904
+ }, [pageIndex, pageSize, isQueryPagination]);
2905
+ const [sorting, setSorting] = React22.useState(
2906
+ column ? [{ id: column, desc: order === "desc" }] : []
2907
+ );
2908
+ const sortingMountRef = React22.useRef(true);
2909
+ React22.useEffect(() => {
2910
+ var _a2, _b2, _c2;
2911
+ if (!router) return;
2912
+ if (sortingMountRef.current) {
2913
+ sortingMountRef.current = false;
2914
+ return;
2915
+ }
2916
+ const replaceUrl = router.replace || router.push;
2917
+ replaceUrl(
2918
+ `${pathname}?${createQueryString({
2919
+ page,
2920
+ sort: ((_a2 = sorting[0]) == null ? void 0 : _a2.id) ? `${(_b2 = sorting[0]) == null ? void 0 : _b2.id}.${((_c2 = sorting[0]) == null ? void 0 : _c2.desc) ? "desc" : "asc"}` : null
2921
+ })}`
2922
+ );
2923
+ }, [sorting]);
2924
+ const searchableColumnFilters = React22.useMemo(
2925
+ () => columnFilters.filter((filter) => searchableColumns.find((col) => col.id === filter.id)),
2926
+ [columnFilters, searchableColumns]
2927
+ );
2928
+ const debouncedSearchableColumnFilters = useDebounce(searchableColumnFilters, resolvedConfig.search.debounceMs);
2929
+ const filterableColumnFilters = React22.useMemo(
2930
+ () => columnFilters.filter((filter) => filterableColumns.find((col) => col.id === filter.id)),
2931
+ [columnFilters, filterableColumns]
2932
+ );
2933
+ const debouncedSearchableString = JSON.stringify(debouncedSearchableColumnFilters);
2934
+ const filterableString = JSON.stringify(filterableColumnFilters);
2935
+ React22.useEffect(() => {
2936
+ if (isQuerySearch || !router) return;
2937
+ const currentDebouncedFilters = JSON.parse(debouncedSearchableString);
2938
+ const updates = {};
2939
+ let hasChanges = false;
2940
+ for (const col of currentDebouncedFilters) {
2941
+ if (typeof col.value === "string" && col.value.trim()) {
2942
+ const newValue = col.value.trim();
2943
+ updates[col.id] = newValue;
2944
+ if (searchParams.get(String(col.id)) !== newValue) {
2945
+ hasChanges = true;
2946
+ }
2947
+ }
2948
+ }
2949
+ for (const key of Array.from(searchParams.keys())) {
2950
+ if (searchableColumns.find((col) => String(col.id) === key) && !currentDebouncedFilters.find((col) => col.id === key)) {
2951
+ updates[key] = null;
2952
+ hasChanges = true;
2953
+ }
2954
+ }
2955
+ if (hasChanges) {
2956
+ updates.page = 1;
2957
+ }
2958
+ const newQueryString = createQueryString(updates);
2959
+ const currentQueryString = searchParams.toString() || "";
2960
+ if (newQueryString !== currentQueryString && hasChanges) {
2961
+ const replaceUrl = router.replace || router.push;
2962
+ replaceUrl(`${pathname}?${newQueryString}`);
2963
+ }
2964
+ }, [debouncedSearchableString, isQuerySearch]);
2965
+ React22.useEffect(() => {
2966
+ if (isQueryFilter || !router) return;
2967
+ const currentFilterableFilters = JSON.parse(filterableString);
2968
+ const updates = {};
2969
+ let hasChanges = false;
2970
+ for (const col of currentFilterableFilters) {
2971
+ if (typeof col.value === "object" && Array.isArray(col.value) && col.value.length > 0) {
2972
+ const newValue = col.value.join(".");
2973
+ updates[col.id] = newValue;
2974
+ if (searchParams.get(String(col.id)) !== newValue) {
2975
+ hasChanges = true;
2976
+ }
2977
+ }
2978
+ }
2979
+ for (const key of Array.from(searchParams.keys())) {
2980
+ if (filterableColumns.find((col) => String(col.id) === key) && !currentFilterableFilters.find((col) => col.id === key)) {
2981
+ updates[key] = null;
2982
+ hasChanges = true;
2983
+ }
2984
+ }
2985
+ if (hasChanges) {
2986
+ updates.page = 1;
2987
+ }
2988
+ const newQueryString = createQueryString(updates);
2989
+ const currentQueryString = searchParams.toString() || "";
2990
+ if (newQueryString !== currentQueryString && hasChanges) {
2991
+ const replaceUrl = router.replace || router.push;
2992
+ replaceUrl(`${pathname}?${newQueryString}`);
2993
+ }
2994
+ }, [filterableString, isQueryFilter]);
2995
+ const table = useReactTable({
2996
+ data: data != null ? data : EMPTY_DATA,
2997
+ columns,
2998
+ pageCount: pageCount != null ? pageCount : -1,
2999
+ state: {
3000
+ pagination,
3001
+ sorting,
3002
+ columnVisibility,
3003
+ rowSelection,
3004
+ columnFilters
3005
+ },
3006
+ enableRowSelection: resolvedConfig.features.rowSelection,
3007
+ enableSorting: resolvedConfig.features.sorting,
3008
+ onRowSelectionChange: setRowSelection,
3009
+ onPaginationChange: setPagination,
3010
+ onSortingChange: setSorting,
3011
+ onColumnFiltersChange: setColumnFilters,
3012
+ onColumnVisibilityChange: setColumnVisibility,
3013
+ getCoreRowModel: getCoreRowModel(),
3014
+ getFilteredRowModel: getFilteredRowModel(),
3015
+ getPaginationRowModel: getPaginationRowModel(),
3016
+ getSortedRowModel: getSortedRowModel(),
3017
+ getFacetedRowModel: getFacetedRowModel(),
3018
+ getFacetedUniqueValues: getFacetedUniqueValues(),
3019
+ manualPagination: isManualPagination,
3020
+ manualSorting: isManualSorting,
3021
+ manualFiltering: isManualFiltering
3022
+ });
3023
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3024
+ shouldShowFilter ? /* @__PURE__ */ jsxs(Fragment, { children: [
3025
+ /* @__PURE__ */ jsx("div", { className: "max-md:hidden", children: shouldShowAdvancedFilter && !isQuerySearch && !isQueryFilter ? /* @__PURE__ */ jsx(
3026
+ DataTableAdvancedToolbar,
3027
+ {
3028
+ table,
3029
+ searchableColumns,
3030
+ filterableColumns,
3031
+ addItemPagePath: addItemPagePath == null ? void 0 : addItemPagePath.url
3032
+ }
3033
+ ) : /* @__PURE__ */ jsx(
3034
+ DataTableToolbar,
3035
+ {
3036
+ table,
3037
+ viewMode,
3038
+ onViewModeChange: setViewMode,
3039
+ addItemPagePath,
3040
+ isShowExportButtons,
3041
+ customButtons,
3042
+ customCss,
3043
+ ...isQuerySearch === true ? {
3044
+ isQuerySearch,
3045
+ searchableQuery
3046
+ } : {
3047
+ isQuerySearch,
3048
+ searchableColumns
3049
+ },
3050
+ ...isQueryFilter && handleFilterChange ? {
3051
+ isQueryFilter: true,
3052
+ handleFilterChange,
3053
+ filterableQuery: filterableQuery || [],
3054
+ currentFilters,
3055
+ onClearFilters
3056
+ } : {
3057
+ isQueryFilter: false,
3058
+ filterableColumns
3059
+ }
3060
+ }
3061
+ ) }),
3062
+ /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between md:hidden", children: /* @__PURE__ */ jsx(
3063
+ DataTableMobileToolbar,
3064
+ {
3065
+ table,
3066
+ filterableColumns,
3067
+ searchableColumns,
3068
+ addItemPagePath,
3069
+ isShowExportButtons,
3070
+ customButtons
3071
+ }
3072
+ ) })
3073
+ ] }) : null,
3074
+ viewMode === "cards" ? /* @__PURE__ */ jsxs(Fragment, { children: [
3075
+ /* @__PURE__ */ jsx(DataTableCardView, { table }),
3076
+ shouldShowPagination ? /* @__PURE__ */ jsx(Card, { className: "mt-3 overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "space-y-2.5", children: isQueryPagination && paginationData ? /* @__PURE__ */ jsx(
3077
+ DataTablePagination,
3078
+ {
3079
+ table,
3080
+ isQueryPagination: true,
3081
+ paginationData
3082
+ }
3083
+ ) : /* @__PURE__ */ jsx(DataTablePagination, { table, isQueryPagination: false }) }) }) : null
3084
+ ] }) : /* @__PURE__ */ jsxs(Card, { className: "mt-3 overflow-hidden", children: [
3085
+ /* @__PURE__ */ jsx(CardContent, { className: "p-0", children: /* @__PURE__ */ jsxs(Table, { children: [
3086
+ /* @__PURE__ */ jsx(TableHeader, { className: "bg-muted/50", children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, { children: headerGroup.headers.map((header) => {
3087
+ const sortDirection = header.column.getIsSorted();
3088
+ return /* @__PURE__ */ jsx(
3089
+ TableHead,
3090
+ {
3091
+ className: "text-nowrap",
3092
+ "aria-sort": sortDirection === "asc" ? "ascending" : sortDirection === "desc" ? "descending" : void 0,
3093
+ children: header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())
3094
+ },
3095
+ header.id
3096
+ );
3097
+ }) }, headerGroup.id)) }),
3098
+ /* @__PURE__ */ jsx(TableBody, { children: ((_e = (_d = table.getRowModel()) == null ? void 0 : _d.rows) == null ? void 0 : _e.length) ? (_f = table.getRowModel()) == null ? void 0 : _f.rows.map((row, rowIndex) => /* @__PURE__ */ jsx(
3099
+ TableRow,
3100
+ {
3101
+ "data-state": row.getIsSelected() && "selected",
3102
+ "aria-rowindex": pageIndex * pageSize + rowIndex + 2,
3103
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(TableCell, { className: "max-w-60 text-ellipsis text-nowrap", children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
3104
+ },
3105
+ row.id
3106
+ )) : /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colSpan: columns.length, className: "py-16 text-center", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-3", children: [
3107
+ /* @__PURE__ */ jsx(SearchX, { className: "size-10 text-muted-foreground/50", "aria-hidden": "true" }),
3108
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
3109
+ /* @__PURE__ */ jsx("p", { className: "font-semibold", children: t("no-records-found") }),
3110
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("no-records-hint") })
3111
+ ] }),
3112
+ (table.getState().columnFilters.length > 0 || isQueryFilter && currentFilters && Object.keys(currentFilters).length > 0) && /* @__PURE__ */ jsxs(
3113
+ Button,
3114
+ {
3115
+ variant: "outline",
3116
+ size: "sm",
3117
+ className: "mt-1 gap-1.5",
3118
+ onClick: () => {
3119
+ if (isQueryFilter && onClearFilters) {
3120
+ onClearFilters();
3121
+ } else {
3122
+ table.resetColumnFilters();
3123
+ }
3124
+ },
3125
+ children: [
3126
+ /* @__PURE__ */ jsx(RotateCcw, { className: "size-3.5", "aria-hidden": "true" }),
3127
+ t("reset-filters")
3128
+ ]
3129
+ }
3130
+ )
3131
+ ] }) }) }) })
3132
+ ] }) }),
3133
+ shouldShowPagination ? /* @__PURE__ */ jsx("div", { className: "space-y-2.5", children: isQueryPagination && paginationData ? /* @__PURE__ */ jsx(
3134
+ DataTablePagination,
3135
+ {
3136
+ table,
3137
+ isQueryPagination: true,
3138
+ paginationData
3139
+ }
3140
+ ) : /* @__PURE__ */ jsx(DataTablePagination, { table, isQueryPagination: false }) }) : null
3141
+ ] })
3142
+ ] });
3143
+ }
3144
+ function DataTableColumnHeader({
3145
+ column,
3146
+ title,
3147
+ className
3148
+ }) {
3149
+ const t = useTableTranslations();
3150
+ if (!column.getCanSort()) {
3151
+ return /* @__PURE__ */ jsx("div", { className: cn(className), children: title });
3152
+ }
3153
+ return /* @__PURE__ */ jsx("div", { className: cn("flex items-center gap-2", className), children: /* @__PURE__ */ jsxs(DropdownMenu, { children: [
3154
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
3155
+ Button,
3156
+ {
3157
+ "aria-label": column.getIsSorted() === "desc" ? t("sorted-desc") : column.getIsSorted() === "asc" ? t("sorted-asc") : t("not-sorted"),
3158
+ variant: "ghost",
3159
+ size: "sm",
3160
+ className: "-ms-3 h-8 data-[state=open]:bg-accent",
3161
+ children: [
3162
+ /* @__PURE__ */ jsx("span", { children: title }),
3163
+ column.getIsSorted() === "desc" ? /* @__PURE__ */ jsx(ArrowDown, { className: "ms-2 size-4", "aria-hidden": "true" }) : column.getIsSorted() === "asc" ? /* @__PURE__ */ jsx(ArrowUp, { className: "ms-2 size-4", "aria-hidden": "true" }) : /* @__PURE__ */ jsx(SortAsc, { className: "ms-2 size-4", "aria-hidden": "true" })
3164
+ ]
3165
+ }
3166
+ ) }),
3167
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "start", children: [
3168
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { "aria-label": t("sort-ascending"), onClick: () => column.toggleSorting(false), children: [
3169
+ /* @__PURE__ */ jsx(ArrowUpIcon, { className: "me-2 size-3.5 text-muted-foreground/70", "aria-hidden": "true" }),
3170
+ t("asc")
3171
+ ] }),
3172
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { "aria-label": t("sort-descending"), onClick: () => column.toggleSorting(true), children: [
3173
+ /* @__PURE__ */ jsx(ArrowDownIcon, { className: "me-2 size-3.5 text-muted-foreground/70", "aria-hidden": "true" }),
3174
+ t("desc")
3175
+ ] }),
3176
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
3177
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { "aria-label": t("hide-column"), onClick: () => column.toggleVisibility(false), children: [
3178
+ /* @__PURE__ */ jsx(EyeOffIcon, { className: "me-2 size-3.5 text-muted-foreground/70", "aria-hidden": "true" }),
3179
+ t("Hide")
3180
+ ] })
3181
+ ] })
3182
+ ] }) });
3183
+ }
3184
+ function ClientSideTable({
3185
+ data,
3186
+ pageCount,
3187
+ pageSize = 10,
3188
+ columns: initialColumns,
3189
+ searchableColumns = [],
3190
+ showFilter = true,
3191
+ showPagination = true,
3192
+ filterableColumns = [],
3193
+ addItemPagePath,
3194
+ isShowExportButtons = {
3195
+ isShow: true,
3196
+ ignoredCols: [],
3197
+ fileName: ""
3198
+ },
3199
+ customButtons,
3200
+ withIndex = true,
3201
+ isQueryPagination = false,
3202
+ paginationData,
3203
+ isLoading = false,
3204
+ isQuerySearch = false,
3205
+ searchableQuery = [],
3206
+ isQueryFilter = false,
3207
+ handleFilterChange,
3208
+ filterableQuery,
3209
+ currentFilters,
3210
+ onClearFilters,
3211
+ customCss,
3212
+ isShowAdvancedFilter = false,
3213
+ config
3214
+ }) {
3215
+ const t = useTableTranslations();
3216
+ const columns = React22.useMemo(() => {
3217
+ return [
3218
+ ...withIndex ? [
3219
+ {
3220
+ accessorKey: "i",
3221
+ header: ({ column }) => /* @__PURE__ */ jsx(DataTableColumnHeader, { column, title: t("row-number") }),
3222
+ cell: ({ row, table }) => /* @__PURE__ */ jsx("div", { className: "w-full", children: table.getState().pagination.pageIndex + 1 === 1 ? row.index + 1 : table.getState().pagination.pageIndex + 1 > 1 ? table.getState().pagination.pageIndex * table.getState().pagination.pageSize + (row.index + 1) : row.index + 1 }),
3223
+ enableSorting: false,
3224
+ enableHiding: false
3225
+ }
3226
+ ] : [],
3227
+ ...initialColumns
3228
+ ];
3229
+ }, [initialColumns, withIndex, t]);
3230
+ return /* @__PURE__ */ jsx(
3231
+ DataTable,
3232
+ {
3233
+ columns,
3234
+ data,
3235
+ pageCount,
3236
+ pageSize,
3237
+ showFilter,
3238
+ showPagination,
3239
+ addItemPagePath,
3240
+ isShowExportButtons,
3241
+ customButtons,
3242
+ floatingBar: true,
3243
+ isLoading,
3244
+ customCss,
3245
+ isShowAdvancedFilter,
3246
+ config,
3247
+ ...isQuerySearch ? { isQuerySearch: true, searchableQuery } : {
3248
+ isQuerySearch: false,
3249
+ searchableColumns
3250
+ },
3251
+ ...isQueryPagination && paginationData ? { isQueryPagination: true, paginationData } : { isQueryPagination: false },
3252
+ ...isQueryFilter && handleFilterChange ? {
3253
+ isQueryFilter: true,
3254
+ handleFilterChange,
3255
+ filterableQuery: filterableQuery || [],
3256
+ currentFilters,
3257
+ onClearFilters
3258
+ } : {
3259
+ isQueryFilter: false,
3260
+ filterableColumns: filterableColumns || []
3261
+ }
3262
+ }
3263
+ );
3264
+ }
3265
+ function DataTableFloatingBar({
3266
+ table,
3267
+ deleteRowsAction,
3268
+ className,
3269
+ ...props
3270
+ }) {
3271
+ const t = useTableTranslations();
3272
+ if (table.getFilteredSelectedRowModel().rows.length <= 0) return null;
3273
+ return /* @__PURE__ */ jsxs(
3274
+ "div",
3275
+ {
3276
+ className: cn(
3277
+ "mx-auto flex w-fit items-center gap-2 rounded-md bg-zinc-900 px-4 py-2 text-white",
3278
+ className
3279
+ ),
3280
+ ...props,
3281
+ children: [
3282
+ /* @__PURE__ */ jsx(
3283
+ Button,
3284
+ {
3285
+ "aria-label": t("clear-selection"),
3286
+ title: t("clear-selection"),
3287
+ className: "h-auto bg-transparent p-1 text-white hover:bg-zinc-700",
3288
+ onClick: () => table.toggleAllRowsSelected(false),
3289
+ children: /* @__PURE__ */ jsx(X, { className: "size-4", "aria-hidden": "true" })
3290
+ }
3291
+ ),
3292
+ /* @__PURE__ */ jsxs("span", { children: [
3293
+ table.getFilteredSelectedRowModel().rows.length,
3294
+ " ",
3295
+ t("row(s) selected")
3296
+ ] }),
3297
+ deleteRowsAction && /* @__PURE__ */ jsx(
3298
+ Button,
3299
+ {
3300
+ "aria-label": t("delete-selected"),
3301
+ title: t("delete"),
3302
+ className: "h-auto bg-transparent p-1 text-white hover:bg-zinc-700",
3303
+ onClick: (event) => {
3304
+ table.toggleAllPageRowsSelected(false);
3305
+ deleteRowsAction(event);
3306
+ },
3307
+ children: /* @__PURE__ */ jsx(TrashIcon, { className: "size-4", "aria-hidden": "true" })
3308
+ }
3309
+ )
3310
+ ]
3311
+ }
3312
+ );
3313
+ }
3314
+ function DataTableRoleFilter({
3315
+ column,
3316
+ title,
3317
+ options,
3318
+ paramKey
3319
+ }) {
3320
+ var _a;
3321
+ const config = useTableConfig();
3322
+ const router = config.router;
3323
+ const t = useTableTranslations();
3324
+ const resolvedParamKey = paramKey != null ? paramKey : column ? String(column.id) : "role";
3325
+ const searchParams = router ? router.getSearchParams() : new URLSearchParams();
3326
+ const currentValue = router ? searchParams.get(resolvedParamKey) || void 0 : column == null ? void 0 : column.getFilterValue();
3327
+ const handleSelect = (value) => {
3328
+ if (router) {
3329
+ const newParams = new URLSearchParams(searchParams.toString());
3330
+ if (value) {
3331
+ newParams.set(resolvedParamKey, value);
3332
+ } else {
3333
+ newParams.delete(resolvedParamKey);
3334
+ }
3335
+ newParams.set("page", "1");
3336
+ router.push(`?${newParams.toString()}`);
3337
+ }
3338
+ column == null ? void 0 : column.setFilterValue(value);
3339
+ };
3340
+ return /* @__PURE__ */ jsxs(Popover, { children: [
3341
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", className: "h-8 border-dashed", children: [
3342
+ /* @__PURE__ */ jsx(ChevronsUpDown, { className: "me-2 h-4 w-4 opacity-50" }),
3343
+ title,
3344
+ currentValue && /* @__PURE__ */ jsxs(Fragment, { children: [
3345
+ /* @__PURE__ */ jsx("span", { className: "mx-2 text-muted-foreground", children: "|" }),
3346
+ /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "rounded-sm px-1 font-normal", children: (_a = options.find((opt) => opt.value === currentValue)) == null ? void 0 : _a.label })
3347
+ ] })
3348
+ ] }) }),
3349
+ /* @__PURE__ */ jsx(PopoverContent, { className: "w-[200px] p-0", align: "start", children: /* @__PURE__ */ jsxs(Command, { children: [
3350
+ /* @__PURE__ */ jsx(CommandInput, { placeholder: `${t("Filter")} ${title}...` }),
3351
+ /* @__PURE__ */ jsx(CommandEmpty, { children: t("no-items-found") }),
3352
+ /* @__PURE__ */ jsxs(CommandGroup, { className: "max-h-64 overflow-auto", children: [
3353
+ /* @__PURE__ */ jsxs(CommandItem, { onSelect: () => handleSelect(void 0), className: "cursor-pointer", children: [
3354
+ /* @__PURE__ */ jsx(
3355
+ "div",
3356
+ {
3357
+ className: cn(
3358
+ "me-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
3359
+ !currentValue ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"
3360
+ ),
3361
+ children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" })
3362
+ }
3363
+ ),
3364
+ /* @__PURE__ */ jsx("span", { children: t("all") })
3365
+ ] }),
3366
+ options.map((option) => {
3367
+ const isSelected = currentValue === option.value;
3368
+ return /* @__PURE__ */ jsxs(
3369
+ CommandItem,
3370
+ {
3371
+ onSelect: () => handleSelect(option.value),
3372
+ className: "cursor-pointer",
3373
+ children: [
3374
+ /* @__PURE__ */ jsx(
3375
+ "div",
3376
+ {
3377
+ className: cn(
3378
+ "me-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
3379
+ isSelected ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"
3380
+ ),
3381
+ children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" })
3382
+ }
3383
+ ),
3384
+ /* @__PURE__ */ jsx("span", { children: option.label })
3385
+ ]
3386
+ },
3387
+ option.value
3388
+ );
3389
+ })
3390
+ ] })
3391
+ ] }) })
3392
+ ] });
3393
+ }
3394
+ function Skeleton({ className, ...props }) {
3395
+ return /* @__PURE__ */ jsx("div", { className: cn("animate-pulse rounded-md bg-primary/10", className), ...props });
3396
+ }
3397
+ var DataTableLoading = React22__default.memo(function DataTableLoading2({ columnCount, rowCount = 10 }) {
3398
+ return /* @__PURE__ */ jsxs("div", { className: "w-full space-y-3 overflow-auto", role: "status", "aria-busy": "true", "aria-label": "Loading data", children: [
3399
+ /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2 overflow-auto p-1", children: [
3400
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 items-center gap-2", children: [
3401
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-[150px] lg:w-[250px]" }),
3402
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-[70px] border-dashed" })
3403
+ ] }),
3404
+ /* @__PURE__ */ jsx(Skeleton, { className: "ms-auto hidden h-7 w-[70px] lg:flex" })
3405
+ ] }),
3406
+ /* @__PURE__ */ jsx("div", { className: "rounded-md border", children: /* @__PURE__ */ jsxs(Table, { children: [
3407
+ /* @__PURE__ */ jsx(TableHeader, { children: Array.from({ length: 1 }).map((_, i) => /* @__PURE__ */ jsx(TableRow, { className: "hover:bg-transparent", children: Array.from({ length: columnCount }).map((_2, j) => /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-6 w-full" }) }, j)) }, i)) }),
3408
+ /* @__PURE__ */ jsx(TableBody, { children: Array.from({ length: rowCount }).map((_, i) => /* @__PURE__ */ jsx(TableRow, { className: "hover:bg-transparent", children: Array.from({ length: columnCount }).map((_2, j) => /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-6 w-full" }) }, j)) }, i)) })
3409
+ ] }) }),
3410
+ /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col items-center justify-between gap-4 overflow-auto px-2 py-1 sm:flex-row sm:gap-8", children: [
3411
+ /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-40" }) }),
3412
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-4 sm:flex-row sm:gap-6 lg:gap-8", children: [
3413
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
3414
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-24" }),
3415
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-[70px]" })
3416
+ ] }),
3417
+ /* @__PURE__ */ jsx("div", { className: "flex w-[100px] items-center justify-center text-sm font-medium", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-20" }) }),
3418
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
3419
+ /* @__PURE__ */ jsx(Skeleton, { className: "hidden size-8 lg:block" }),
3420
+ /* @__PURE__ */ jsx(Skeleton, { className: "size-8" }),
3421
+ /* @__PURE__ */ jsx(Skeleton, { className: "size-8" }),
3422
+ /* @__PURE__ */ jsx(Skeleton, { className: "hidden size-8 lg:block" })
3423
+ ] })
3424
+ ] })
3425
+ ] })
3426
+ ] });
3427
+ });
3428
+
3429
+ export { ButtonTooltip, ClientSideTable, DEFAULT_TABLE_CONFIG, DataTable, DataTableAdvancedFilter, DataTableAdvancedFilterItem, DataTableAdvancedToolbar, DataTableCardView, DataTableColumnHeader, DataTableFacetedFilter, DataTableFloatingBar, DataTableLoading, DataTableMobileToolbar, DataTableMultiFilter, DataTablePagination, DataTableRoleFilter, DataTableSingleSelectFilter, DataTableToolbar, DataTableViewOptions, MultiFilterRow, table_actions_row_default as TableActionsRow, TableProvider, cn, createCsvConfig, createTableConfig, deepMergeConfig, exportSelectedRowsCsv, useDebounce, useGlobalTableConfig, useResolvedTableConfig, useTableConfig, useTableTranslations };
3430
+ //# sourceMappingURL=index.mjs.map
3431
+ //# sourceMappingURL=index.mjs.map