@moontra/moonui-pro 2.3.8 → 2.4.1
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.d.ts +30 -3
- package/dist/index.mjs +1045 -91
- package/package.json +4 -3
- package/scripts/postinstall.js +26 -0
- package/src/components/data-table/data-table-bulk-actions.tsx +204 -0
- package/src/components/data-table/data-table-column-toggle.tsx +166 -0
- package/src/components/data-table/data-table-export.ts +156 -0
- package/src/components/data-table/data-table-filter-drawer.tsx +442 -0
- package/src/components/data-table/index.tsx +218 -87
- package/src/components/ui/alert-dialog.tsx +141 -0
package/dist/index.mjs
CHANGED
|
@@ -3,15 +3,16 @@ import { twMerge } from 'tailwind-merge';
|
|
|
3
3
|
import * as t from 'react';
|
|
4
4
|
import t__default, { useState, useRef, useCallback, forwardRef, createContext, useContext, useMemo, useEffect, useDebugValue, Component, useLayoutEffect } from 'react';
|
|
5
5
|
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
6
|
-
import { ChevronDown, Info, AlertCircle, AlertTriangle, Check, X, MoreHorizontal, Loader2, Minus, Search, ChevronRight, Circle, ChevronUp, Lock, Sparkles, Plus, ChevronLeft, Calendar, Edit, Trash2, Clock, MapPin, User, GripVertical, MessageCircle, Paperclip, Bold as Bold$1, Italic as Italic$1, Underline as Underline$1, Strikethrough, Code as Code$1, Type, Heading1, Heading2, Heading3, AlignLeft, AlignCenter, AlignRight, AlignJustify, List, ListOrdered, CheckSquare, Quote, Palette, Highlighter, Link2, Image as Image$1, Table as Table$1, Settings, Undo, Redo, Eye, RefreshCw, Wand2, Maximize, FileText, Languages, TrendingUp, TrendingDown, Download, Maximize2, Activity, Star, Upload, CheckCircle2, Filter, ArrowUp, ArrowDown, ArrowUpDown, ChevronsLeft, ChevronsRight, ExternalLink, BarChart3, Users, DollarSign, Github, GitFork, Server, EyeOff, ZoomOut, ZoomIn, RotateCw, Zap, Monitor, Timer, Cpu, MemoryStick, HardDrive, Network, CheckCircle, Video, Music, Archive, File, XCircle, ArrowDownRight, ArrowUpRight } from 'lucide-react';
|
|
6
|
+
import { ChevronDown, Info, AlertCircle, AlertTriangle, Check, X, MoreHorizontal, Loader2, Minus, Search, ChevronRight, Circle, ChevronUp, Lock, Sparkles, Plus, ChevronLeft, Calendar, Edit, Trash2, Clock, MapPin, User, GripVertical, MessageCircle, Paperclip, Bold as Bold$1, Italic as Italic$1, Underline as Underline$1, Strikethrough, Code as Code$1, Type, Heading1, Heading2, Heading3, AlignLeft, AlignCenter, AlignRight, AlignJustify, List, ListOrdered, CheckSquare, Quote, Palette, Highlighter, Link2, Image as Image$1, Table as Table$1, Settings, Undo, Redo, Eye, RefreshCw, Wand2, Maximize, FileText, Languages, TrendingUp, TrendingDown, Download, Maximize2, Activity, Star, Upload, CheckCircle2, Filter, FileSpreadsheet, FileJson, FileDown, ArrowUp, ArrowDown, ArrowUpDown, ChevronsLeft, ChevronsRight, ExternalLink, BarChart3, Users, DollarSign, Github, GitFork, Server, EyeOff, ZoomOut, ZoomIn, RotateCw, Zap, Monitor, Timer, Cpu, MemoryStick, HardDrive, Network, CheckCircle, Video, Music, Archive, File, Columns, XCircle, ArrowDownRight, ArrowUpRight } from 'lucide-react';
|
|
7
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
8
|
import { cva } from 'class-variance-authority';
|
|
9
9
|
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
10
10
|
import { motion, AnimatePresence, useMotionValue, useSpring, useTransform, animate } from 'framer-motion';
|
|
11
11
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
12
12
|
import ReactDOM3 from 'react-dom';
|
|
13
|
-
import { createSlot } from '@radix-ui/react-slot';
|
|
13
|
+
import { createSlot, createSlottable } from '@radix-ui/react-slot';
|
|
14
14
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
15
|
+
import { createDialogScope } from '@radix-ui/react-dialog';
|
|
15
16
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
16
17
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
17
18
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
@@ -26,7 +27,7 @@ import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/w
|
|
|
26
27
|
import { ResponsiveContainer, ScatterChart, CartesianGrid, XAxis, YAxis, Tooltip, Legend, Scatter, PieChart, Pie, Cell, AreaChart, Area, ReferenceLine, Brush, BarChart, Bar, LineChart, Line, ReferenceArea } from 'recharts';
|
|
27
28
|
import { DragDropContext, Droppable, Draggable } from '@hello-pangea/dnd';
|
|
28
29
|
import { useForm } from 'react-hook-form';
|
|
29
|
-
import { useReactTable, getCoreRowModel, getPaginationRowModel, getSortedRowModel, getFilteredRowModel
|
|
30
|
+
import { flexRender, useReactTable, getCoreRowModel, getPaginationRowModel, getSortedRowModel, getFilteredRowModel } from '@tanstack/react-table';
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* @moontra/moonui-pro v2.0.9
|
|
@@ -3790,7 +3791,7 @@ var me = t.forwardRef((r2, o) => {
|
|
|
3790
3791
|
var e;
|
|
3791
3792
|
return Array.from(((e = I.current) == null ? void 0 : e.querySelectorAll(ce)) || []);
|
|
3792
3793
|
}
|
|
3793
|
-
function
|
|
3794
|
+
function X13(e) {
|
|
3794
3795
|
let s = V()[e];
|
|
3795
3796
|
s && E.setState("value", s.getAttribute(T));
|
|
3796
3797
|
}
|
|
@@ -3805,10 +3806,10 @@ var me = t.forwardRef((r2, o) => {
|
|
|
3805
3806
|
s = e > 0 ? we(s, N) : De(s, N), i = s == null ? void 0 : s.querySelector(ce);
|
|
3806
3807
|
i ? E.setState("value", i.getAttribute(T)) : Q(e);
|
|
3807
3808
|
}
|
|
3808
|
-
let oe = () =>
|
|
3809
|
+
let oe = () => X13(V().length - 1), ie3 = (e) => {
|
|
3809
3810
|
e.preventDefault(), e.metaKey ? oe() : e.altKey ? re(1) : Q(1);
|
|
3810
3811
|
}, se = (e) => {
|
|
3811
|
-
e.preventDefault(), e.metaKey ?
|
|
3812
|
+
e.preventDefault(), e.metaKey ? X13(0) : e.altKey ? re(-1) : Q(-1);
|
|
3812
3813
|
};
|
|
3813
3814
|
return t.createElement(Primitive2.div, { ref: o, tabIndex: -1, ...O, "cmdk-root": "", onKeyDown: (e) => {
|
|
3814
3815
|
var s;
|
|
@@ -3835,7 +3836,7 @@ var me = t.forwardRef((r2, o) => {
|
|
|
3835
3836
|
break;
|
|
3836
3837
|
}
|
|
3837
3838
|
case "Home": {
|
|
3838
|
-
e.preventDefault(),
|
|
3839
|
+
e.preventDefault(), X13(0);
|
|
3839
3840
|
break;
|
|
3840
3841
|
}
|
|
3841
3842
|
case "End": {
|
|
@@ -51095,7 +51096,7 @@ var PerformanceDebuggerInternal = ({
|
|
|
51095
51096
|
return /* @__PURE__ */ jsx(Activity, { className: "h-4 w-4 text-muted-foreground" });
|
|
51096
51097
|
}
|
|
51097
51098
|
};
|
|
51098
|
-
const
|
|
51099
|
+
const exportData2 = () => {
|
|
51099
51100
|
const data = {
|
|
51100
51101
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
51101
51102
|
entries,
|
|
@@ -51173,7 +51174,7 @@ var PerformanceDebuggerInternal = ({
|
|
|
51173
51174
|
{
|
|
51174
51175
|
variant: "outline",
|
|
51175
51176
|
size: "sm",
|
|
51176
|
-
onClick:
|
|
51177
|
+
onClick: exportData2,
|
|
51177
51178
|
children: /* @__PURE__ */ jsx(Download, { className: "h-4 w-4" })
|
|
51178
51179
|
}
|
|
51179
51180
|
),
|
|
@@ -52153,6 +52154,894 @@ function FileUpload({
|
|
|
52153
52154
|
] })
|
|
52154
52155
|
] });
|
|
52155
52156
|
}
|
|
52157
|
+
function DataTableColumnToggle({ table, trigger }) {
|
|
52158
|
+
const [search, setSearch] = t__default.useState("");
|
|
52159
|
+
const columns = table.getAllColumns().filter((column) => column.getCanHide());
|
|
52160
|
+
const filteredColumns = t__default.useMemo(() => {
|
|
52161
|
+
if (!search)
|
|
52162
|
+
return columns;
|
|
52163
|
+
return columns.filter((column) => {
|
|
52164
|
+
const header = column.columnDef.header;
|
|
52165
|
+
const headerText = typeof header === "string" ? header : column.id;
|
|
52166
|
+
return headerText.toLowerCase().includes(search.toLowerCase());
|
|
52167
|
+
});
|
|
52168
|
+
}, [columns, search]);
|
|
52169
|
+
const visibleCount = columns.filter((col) => col.getIsVisible()).length;
|
|
52170
|
+
const handleToggleAll = (visible) => {
|
|
52171
|
+
columns.forEach((column) => {
|
|
52172
|
+
column.toggleVisibility(visible);
|
|
52173
|
+
});
|
|
52174
|
+
};
|
|
52175
|
+
return /* @__PURE__ */ jsxs(MoonUIDropdownMenuPro, { children: [
|
|
52176
|
+
/* @__PURE__ */ jsx(MoonUIDropdownMenuTriggerPro, { asChild: true, children: trigger || /* @__PURE__ */ jsxs(MoonUIButtonPro, { variant: "outline", size: "sm", className: "gap-2", children: [
|
|
52177
|
+
/* @__PURE__ */ jsx(Columns, { className: "h-4 w-4" }),
|
|
52178
|
+
"Columns",
|
|
52179
|
+
visibleCount < columns.length && /* @__PURE__ */ jsxs("span", { className: "ml-1 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs", children: [
|
|
52180
|
+
visibleCount,
|
|
52181
|
+
"/",
|
|
52182
|
+
columns.length
|
|
52183
|
+
] })
|
|
52184
|
+
] }) }),
|
|
52185
|
+
/* @__PURE__ */ jsxs(MoonUIDropdownMenuContentPro, { align: "end", className: "w-56", children: [
|
|
52186
|
+
/* @__PURE__ */ jsx(MoonUIDropdownMenuLabelPro, { children: "Toggle Columns" }),
|
|
52187
|
+
columns.length > 5 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
52188
|
+
/* @__PURE__ */ jsx("div", { className: "px-2 py-1.5", children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
52189
|
+
/* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-3 w-3 text-muted-foreground" }),
|
|
52190
|
+
/* @__PURE__ */ jsx(
|
|
52191
|
+
MoonUIInputPro,
|
|
52192
|
+
{
|
|
52193
|
+
placeholder: "Search columns...",
|
|
52194
|
+
value: search,
|
|
52195
|
+
onChange: (e) => setSearch(e.target.value),
|
|
52196
|
+
className: "h-8 pl-7 text-xs"
|
|
52197
|
+
}
|
|
52198
|
+
)
|
|
52199
|
+
] }) }),
|
|
52200
|
+
/* @__PURE__ */ jsx(MoonUIDropdownMenuSeparatorPro, {})
|
|
52201
|
+
] }),
|
|
52202
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-2 py-1.5", children: [
|
|
52203
|
+
/* @__PURE__ */ jsx(
|
|
52204
|
+
MoonUIButtonPro,
|
|
52205
|
+
{
|
|
52206
|
+
variant: "ghost",
|
|
52207
|
+
size: "sm",
|
|
52208
|
+
className: "h-7 text-xs",
|
|
52209
|
+
onClick: () => handleToggleAll(true),
|
|
52210
|
+
children: "Show all"
|
|
52211
|
+
}
|
|
52212
|
+
),
|
|
52213
|
+
/* @__PURE__ */ jsx(
|
|
52214
|
+
MoonUIButtonPro,
|
|
52215
|
+
{
|
|
52216
|
+
variant: "ghost",
|
|
52217
|
+
size: "sm",
|
|
52218
|
+
className: "h-7 text-xs",
|
|
52219
|
+
onClick: () => handleToggleAll(false),
|
|
52220
|
+
children: "Hide all"
|
|
52221
|
+
}
|
|
52222
|
+
)
|
|
52223
|
+
] }),
|
|
52224
|
+
/* @__PURE__ */ jsx(MoonUIDropdownMenuSeparatorPro, {}),
|
|
52225
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-64 overflow-y-auto", children: filteredColumns.length === 0 ? /* @__PURE__ */ jsx("div", { className: "px-2 py-4 text-center text-xs text-muted-foreground", children: "No columns found" }) : filteredColumns.map((column) => {
|
|
52226
|
+
const isVisible = column.getIsVisible();
|
|
52227
|
+
const header = column.columnDef.header;
|
|
52228
|
+
const headerText = typeof header === "string" ? header : column.id;
|
|
52229
|
+
return /* @__PURE__ */ jsx(
|
|
52230
|
+
MoonUIDropdownMenuItemPro,
|
|
52231
|
+
{
|
|
52232
|
+
className: cn(
|
|
52233
|
+
"cursor-pointer",
|
|
52234
|
+
!isVisible && "text-muted-foreground"
|
|
52235
|
+
),
|
|
52236
|
+
onSelect: (e) => {
|
|
52237
|
+
e.preventDefault();
|
|
52238
|
+
column.toggleVisibility();
|
|
52239
|
+
},
|
|
52240
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-1", children: [
|
|
52241
|
+
/* @__PURE__ */ jsx("div", { className: cn(
|
|
52242
|
+
"flex h-4 w-4 items-center justify-center rounded-sm border",
|
|
52243
|
+
isVisible ? "border-primary bg-primary text-primary-foreground" : "border-muted-foreground"
|
|
52244
|
+
), children: isVisible && /* @__PURE__ */ jsx(Check, { className: "h-3 w-3" }) }),
|
|
52245
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: headerText })
|
|
52246
|
+
] })
|
|
52247
|
+
},
|
|
52248
|
+
column.id
|
|
52249
|
+
);
|
|
52250
|
+
}) }),
|
|
52251
|
+
columns.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
52252
|
+
/* @__PURE__ */ jsx(MoonUIDropdownMenuSeparatorPro, {}),
|
|
52253
|
+
/* @__PURE__ */ jsxs("div", { className: "px-2 py-1.5 text-xs text-muted-foreground text-center", children: [
|
|
52254
|
+
visibleCount,
|
|
52255
|
+
" of ",
|
|
52256
|
+
columns.length,
|
|
52257
|
+
" columns visible"
|
|
52258
|
+
] })
|
|
52259
|
+
] })
|
|
52260
|
+
] })
|
|
52261
|
+
] });
|
|
52262
|
+
}
|
|
52263
|
+
var ROOT_NAME = "AlertDialog";
|
|
52264
|
+
var [createAlertDialogContext, createAlertDialogScope] = createContextScope(ROOT_NAME, [
|
|
52265
|
+
createDialogScope
|
|
52266
|
+
]);
|
|
52267
|
+
var useDialogScope = createDialogScope();
|
|
52268
|
+
var AlertDialog = (props) => {
|
|
52269
|
+
const { __scopeAlertDialog, ...alertDialogProps } = props;
|
|
52270
|
+
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
52271
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Root, { ...dialogScope, ...alertDialogProps, modal: true });
|
|
52272
|
+
};
|
|
52273
|
+
AlertDialog.displayName = ROOT_NAME;
|
|
52274
|
+
var TRIGGER_NAME2 = "AlertDialogTrigger";
|
|
52275
|
+
var AlertDialogTrigger = t.forwardRef(
|
|
52276
|
+
(props, forwardedRef) => {
|
|
52277
|
+
const { __scopeAlertDialog, ...triggerProps } = props;
|
|
52278
|
+
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
52279
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Trigger, { ...dialogScope, ...triggerProps, ref: forwardedRef });
|
|
52280
|
+
}
|
|
52281
|
+
);
|
|
52282
|
+
AlertDialogTrigger.displayName = TRIGGER_NAME2;
|
|
52283
|
+
var PORTAL_NAME = "AlertDialogPortal";
|
|
52284
|
+
var AlertDialogPortal = (props) => {
|
|
52285
|
+
const { __scopeAlertDialog, ...portalProps } = props;
|
|
52286
|
+
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
52287
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Portal, { ...dialogScope, ...portalProps });
|
|
52288
|
+
};
|
|
52289
|
+
AlertDialogPortal.displayName = PORTAL_NAME;
|
|
52290
|
+
var OVERLAY_NAME = "AlertDialogOverlay";
|
|
52291
|
+
var AlertDialogOverlay = t.forwardRef(
|
|
52292
|
+
(props, forwardedRef) => {
|
|
52293
|
+
const { __scopeAlertDialog, ...overlayProps } = props;
|
|
52294
|
+
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
52295
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Overlay, { ...dialogScope, ...overlayProps, ref: forwardedRef });
|
|
52296
|
+
}
|
|
52297
|
+
);
|
|
52298
|
+
AlertDialogOverlay.displayName = OVERLAY_NAME;
|
|
52299
|
+
var CONTENT_NAME2 = "AlertDialogContent";
|
|
52300
|
+
var [AlertDialogContentProvider, useAlertDialogContentContext] = createAlertDialogContext(CONTENT_NAME2);
|
|
52301
|
+
var Slottable = createSlottable("AlertDialogContent");
|
|
52302
|
+
var AlertDialogContent = t.forwardRef(
|
|
52303
|
+
(props, forwardedRef) => {
|
|
52304
|
+
const { __scopeAlertDialog, children, ...contentProps } = props;
|
|
52305
|
+
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
52306
|
+
const contentRef = t.useRef(null);
|
|
52307
|
+
const composedRefs = useComposedRefs(forwardedRef, contentRef);
|
|
52308
|
+
const cancelRef = t.useRef(null);
|
|
52309
|
+
return /* @__PURE__ */ jsx(
|
|
52310
|
+
DialogPrimitive.WarningProvider,
|
|
52311
|
+
{
|
|
52312
|
+
contentName: CONTENT_NAME2,
|
|
52313
|
+
titleName: TITLE_NAME,
|
|
52314
|
+
docsSlug: "alert-dialog",
|
|
52315
|
+
children: /* @__PURE__ */ jsx(AlertDialogContentProvider, { scope: __scopeAlertDialog, cancelRef, children: /* @__PURE__ */ jsxs(
|
|
52316
|
+
DialogPrimitive.Content,
|
|
52317
|
+
{
|
|
52318
|
+
role: "alertdialog",
|
|
52319
|
+
...dialogScope,
|
|
52320
|
+
...contentProps,
|
|
52321
|
+
ref: composedRefs,
|
|
52322
|
+
onOpenAutoFocus: composeEventHandlers(contentProps.onOpenAutoFocus, (event) => {
|
|
52323
|
+
event.preventDefault();
|
|
52324
|
+
cancelRef.current?.focus({ preventScroll: true });
|
|
52325
|
+
}),
|
|
52326
|
+
onPointerDownOutside: (event) => event.preventDefault(),
|
|
52327
|
+
onInteractOutside: (event) => event.preventDefault(),
|
|
52328
|
+
children: [
|
|
52329
|
+
/* @__PURE__ */ jsx(Slottable, { children }),
|
|
52330
|
+
/* @__PURE__ */ jsx(DescriptionWarning, { contentRef })
|
|
52331
|
+
]
|
|
52332
|
+
}
|
|
52333
|
+
) })
|
|
52334
|
+
}
|
|
52335
|
+
);
|
|
52336
|
+
}
|
|
52337
|
+
);
|
|
52338
|
+
AlertDialogContent.displayName = CONTENT_NAME2;
|
|
52339
|
+
var TITLE_NAME = "AlertDialogTitle";
|
|
52340
|
+
var AlertDialogTitle = t.forwardRef(
|
|
52341
|
+
(props, forwardedRef) => {
|
|
52342
|
+
const { __scopeAlertDialog, ...titleProps } = props;
|
|
52343
|
+
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
52344
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Title, { ...dialogScope, ...titleProps, ref: forwardedRef });
|
|
52345
|
+
}
|
|
52346
|
+
);
|
|
52347
|
+
AlertDialogTitle.displayName = TITLE_NAME;
|
|
52348
|
+
var DESCRIPTION_NAME = "AlertDialogDescription";
|
|
52349
|
+
var AlertDialogDescription = t.forwardRef((props, forwardedRef) => {
|
|
52350
|
+
const { __scopeAlertDialog, ...descriptionProps } = props;
|
|
52351
|
+
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
52352
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Description, { ...dialogScope, ...descriptionProps, ref: forwardedRef });
|
|
52353
|
+
});
|
|
52354
|
+
AlertDialogDescription.displayName = DESCRIPTION_NAME;
|
|
52355
|
+
var ACTION_NAME = "AlertDialogAction";
|
|
52356
|
+
var AlertDialogAction = t.forwardRef(
|
|
52357
|
+
(props, forwardedRef) => {
|
|
52358
|
+
const { __scopeAlertDialog, ...actionProps } = props;
|
|
52359
|
+
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
52360
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Close, { ...dialogScope, ...actionProps, ref: forwardedRef });
|
|
52361
|
+
}
|
|
52362
|
+
);
|
|
52363
|
+
AlertDialogAction.displayName = ACTION_NAME;
|
|
52364
|
+
var CANCEL_NAME = "AlertDialogCancel";
|
|
52365
|
+
var AlertDialogCancel = t.forwardRef(
|
|
52366
|
+
(props, forwardedRef) => {
|
|
52367
|
+
const { __scopeAlertDialog, ...cancelProps } = props;
|
|
52368
|
+
const { cancelRef } = useAlertDialogContentContext(CANCEL_NAME, __scopeAlertDialog);
|
|
52369
|
+
const dialogScope = useDialogScope(__scopeAlertDialog);
|
|
52370
|
+
const ref = useComposedRefs(forwardedRef, cancelRef);
|
|
52371
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Close, { ...dialogScope, ...cancelProps, ref });
|
|
52372
|
+
}
|
|
52373
|
+
);
|
|
52374
|
+
AlertDialogCancel.displayName = CANCEL_NAME;
|
|
52375
|
+
var DescriptionWarning = ({ contentRef }) => {
|
|
52376
|
+
const MESSAGE = `\`${CONTENT_NAME2}\` requires a description for the component to be accessible for screen reader users.
|
|
52377
|
+
|
|
52378
|
+
You can add a description to the \`${CONTENT_NAME2}\` by passing a \`${DESCRIPTION_NAME}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
|
|
52379
|
+
|
|
52380
|
+
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${CONTENT_NAME2}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
52381
|
+
|
|
52382
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;
|
|
52383
|
+
t.useEffect(() => {
|
|
52384
|
+
const hasDescription = document.getElementById(
|
|
52385
|
+
contentRef.current?.getAttribute("aria-describedby")
|
|
52386
|
+
);
|
|
52387
|
+
if (!hasDescription)
|
|
52388
|
+
console.warn(MESSAGE);
|
|
52389
|
+
}, [MESSAGE, contentRef]);
|
|
52390
|
+
return null;
|
|
52391
|
+
};
|
|
52392
|
+
var Root22 = AlertDialog;
|
|
52393
|
+
var Portal22 = AlertDialogPortal;
|
|
52394
|
+
var Overlay22 = AlertDialogOverlay;
|
|
52395
|
+
var Content22 = AlertDialogContent;
|
|
52396
|
+
var Action2 = AlertDialogAction;
|
|
52397
|
+
var Cancel = AlertDialogCancel;
|
|
52398
|
+
var Title22 = AlertDialogTitle;
|
|
52399
|
+
var Description22 = AlertDialogDescription;
|
|
52400
|
+
var AlertDialog2 = Root22;
|
|
52401
|
+
var AlertDialogPortal2 = Portal22;
|
|
52402
|
+
var AlertDialogOverlay2 = t.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
52403
|
+
Overlay22,
|
|
52404
|
+
{
|
|
52405
|
+
className: cn(
|
|
52406
|
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
52407
|
+
className
|
|
52408
|
+
),
|
|
52409
|
+
...props,
|
|
52410
|
+
ref
|
|
52411
|
+
}
|
|
52412
|
+
));
|
|
52413
|
+
AlertDialogOverlay2.displayName = Overlay22.displayName;
|
|
52414
|
+
var AlertDialogContent2 = t.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs(AlertDialogPortal2, { children: [
|
|
52415
|
+
/* @__PURE__ */ jsx(AlertDialogOverlay2, {}),
|
|
52416
|
+
/* @__PURE__ */ jsx(
|
|
52417
|
+
Content22,
|
|
52418
|
+
{
|
|
52419
|
+
ref,
|
|
52420
|
+
className: cn(
|
|
52421
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
52422
|
+
className
|
|
52423
|
+
),
|
|
52424
|
+
...props
|
|
52425
|
+
}
|
|
52426
|
+
)
|
|
52427
|
+
] }));
|
|
52428
|
+
AlertDialogContent2.displayName = Content22.displayName;
|
|
52429
|
+
var AlertDialogHeader = ({
|
|
52430
|
+
className,
|
|
52431
|
+
...props
|
|
52432
|
+
}) => /* @__PURE__ */ jsx(
|
|
52433
|
+
"div",
|
|
52434
|
+
{
|
|
52435
|
+
className: cn(
|
|
52436
|
+
"flex flex-col space-y-2 text-center sm:text-left",
|
|
52437
|
+
className
|
|
52438
|
+
),
|
|
52439
|
+
...props
|
|
52440
|
+
}
|
|
52441
|
+
);
|
|
52442
|
+
AlertDialogHeader.displayName = "AlertDialogHeader";
|
|
52443
|
+
var AlertDialogFooter = ({
|
|
52444
|
+
className,
|
|
52445
|
+
...props
|
|
52446
|
+
}) => /* @__PURE__ */ jsx(
|
|
52447
|
+
"div",
|
|
52448
|
+
{
|
|
52449
|
+
className: cn(
|
|
52450
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
52451
|
+
className
|
|
52452
|
+
),
|
|
52453
|
+
...props
|
|
52454
|
+
}
|
|
52455
|
+
);
|
|
52456
|
+
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
52457
|
+
var AlertDialogTitle2 = t.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
52458
|
+
Title22,
|
|
52459
|
+
{
|
|
52460
|
+
ref,
|
|
52461
|
+
className: cn("text-lg font-semibold", className),
|
|
52462
|
+
...props
|
|
52463
|
+
}
|
|
52464
|
+
));
|
|
52465
|
+
AlertDialogTitle2.displayName = Title22.displayName;
|
|
52466
|
+
var AlertDialogDescription2 = t.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
52467
|
+
Description22,
|
|
52468
|
+
{
|
|
52469
|
+
ref,
|
|
52470
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
52471
|
+
...props
|
|
52472
|
+
}
|
|
52473
|
+
));
|
|
52474
|
+
AlertDialogDescription2.displayName = Description22.displayName;
|
|
52475
|
+
var AlertDialogAction2 = t.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
52476
|
+
Action2,
|
|
52477
|
+
{
|
|
52478
|
+
ref,
|
|
52479
|
+
className: cn(moonUIButtonProVariants(), className),
|
|
52480
|
+
...props
|
|
52481
|
+
}
|
|
52482
|
+
));
|
|
52483
|
+
AlertDialogAction2.displayName = Action2.displayName;
|
|
52484
|
+
var AlertDialogCancel2 = t.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
52485
|
+
Cancel,
|
|
52486
|
+
{
|
|
52487
|
+
ref,
|
|
52488
|
+
className: cn(
|
|
52489
|
+
moonUIButtonProVariants({ variant: "outline" }),
|
|
52490
|
+
"mt-2 sm:mt-0",
|
|
52491
|
+
className
|
|
52492
|
+
),
|
|
52493
|
+
...props
|
|
52494
|
+
}
|
|
52495
|
+
));
|
|
52496
|
+
AlertDialogCancel2.displayName = Cancel.displayName;
|
|
52497
|
+
function DataTableBulkActions({
|
|
52498
|
+
selectedRows,
|
|
52499
|
+
actions,
|
|
52500
|
+
onClearSelection,
|
|
52501
|
+
className
|
|
52502
|
+
}) {
|
|
52503
|
+
const [isLoading, setIsLoading] = t__default.useState(false);
|
|
52504
|
+
const [pendingAction, setPendingAction] = t__default.useState(null);
|
|
52505
|
+
const selectedCount = selectedRows.length;
|
|
52506
|
+
const handleAction = async (action) => {
|
|
52507
|
+
if (action.confirmMessage) {
|
|
52508
|
+
setPendingAction(action);
|
|
52509
|
+
return;
|
|
52510
|
+
}
|
|
52511
|
+
await executeAction(action);
|
|
52512
|
+
};
|
|
52513
|
+
const executeAction = async (action) => {
|
|
52514
|
+
setIsLoading(true);
|
|
52515
|
+
try {
|
|
52516
|
+
await action.action(selectedRows);
|
|
52517
|
+
if (onClearSelection) {
|
|
52518
|
+
onClearSelection();
|
|
52519
|
+
}
|
|
52520
|
+
} catch (error) {
|
|
52521
|
+
console.error("Bulk action failed:", error);
|
|
52522
|
+
} finally {
|
|
52523
|
+
setIsLoading(false);
|
|
52524
|
+
setPendingAction(null);
|
|
52525
|
+
}
|
|
52526
|
+
};
|
|
52527
|
+
const handleConfirm = async () => {
|
|
52528
|
+
if (pendingAction) {
|
|
52529
|
+
await executeAction(pendingAction);
|
|
52530
|
+
}
|
|
52531
|
+
};
|
|
52532
|
+
if (selectedCount === 0) {
|
|
52533
|
+
return null;
|
|
52534
|
+
}
|
|
52535
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
52536
|
+
/* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-2", className), children: [
|
|
52537
|
+
/* @__PURE__ */ jsxs(MoonUIBadgePro, { variant: "secondary", className: "gap-1", children: [
|
|
52538
|
+
/* @__PURE__ */ jsx("span", { className: "font-semibold", children: selectedCount }),
|
|
52539
|
+
/* @__PURE__ */ jsx("span", { children: "selected" })
|
|
52540
|
+
] }),
|
|
52541
|
+
/* @__PURE__ */ jsxs(MoonUIDropdownMenuPro, { children: [
|
|
52542
|
+
/* @__PURE__ */ jsx(MoonUIDropdownMenuTriggerPro, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
52543
|
+
MoonUIButtonPro,
|
|
52544
|
+
{
|
|
52545
|
+
variant: "outline",
|
|
52546
|
+
size: "sm",
|
|
52547
|
+
disabled: isLoading,
|
|
52548
|
+
className: "gap-2",
|
|
52549
|
+
children: isLoading ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
52550
|
+
/* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }),
|
|
52551
|
+
"Processing..."
|
|
52552
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
52553
|
+
/* @__PURE__ */ jsx(MoreHorizontal, { className: "h-4 w-4" }),
|
|
52554
|
+
"Bulk Actions"
|
|
52555
|
+
] })
|
|
52556
|
+
}
|
|
52557
|
+
) }),
|
|
52558
|
+
/* @__PURE__ */ jsxs(MoonUIDropdownMenuContentPro, { align: "end", className: "w-48", children: [
|
|
52559
|
+
actions.map((action, index) => {
|
|
52560
|
+
const isDisabled = typeof action.disabled === "function" ? action.disabled(selectedRows) : action.disabled;
|
|
52561
|
+
return /* @__PURE__ */ jsxs(
|
|
52562
|
+
MoonUIDropdownMenuItemPro,
|
|
52563
|
+
{
|
|
52564
|
+
disabled: isDisabled || isLoading,
|
|
52565
|
+
onSelect: () => handleAction(action),
|
|
52566
|
+
className: cn(
|
|
52567
|
+
"cursor-pointer",
|
|
52568
|
+
action.variant === "destructive" && "text-destructive focus:text-destructive"
|
|
52569
|
+
),
|
|
52570
|
+
children: [
|
|
52571
|
+
action.icon && /* @__PURE__ */ jsx("span", { className: "mr-2 h-4 w-4", children: action.icon }),
|
|
52572
|
+
action.label
|
|
52573
|
+
]
|
|
52574
|
+
},
|
|
52575
|
+
index
|
|
52576
|
+
);
|
|
52577
|
+
}),
|
|
52578
|
+
onClearSelection && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
52579
|
+
/* @__PURE__ */ jsx(MoonUIDropdownMenuSeparatorPro, {}),
|
|
52580
|
+
/* @__PURE__ */ jsx(
|
|
52581
|
+
MoonUIDropdownMenuItemPro,
|
|
52582
|
+
{
|
|
52583
|
+
onSelect: onClearSelection,
|
|
52584
|
+
className: "cursor-pointer text-muted-foreground",
|
|
52585
|
+
children: "Clear selection"
|
|
52586
|
+
}
|
|
52587
|
+
)
|
|
52588
|
+
] })
|
|
52589
|
+
] })
|
|
52590
|
+
] })
|
|
52591
|
+
] }),
|
|
52592
|
+
/* @__PURE__ */ jsx(
|
|
52593
|
+
AlertDialog2,
|
|
52594
|
+
{
|
|
52595
|
+
open: !!pendingAction,
|
|
52596
|
+
onOpenChange: (open) => !open && setPendingAction(null),
|
|
52597
|
+
children: /* @__PURE__ */ jsxs(AlertDialogContent2, { children: [
|
|
52598
|
+
/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
|
|
52599
|
+
/* @__PURE__ */ jsxs(AlertDialogTitle2, { className: "flex items-center gap-2", children: [
|
|
52600
|
+
pendingAction?.variant === "destructive" && /* @__PURE__ */ jsx(AlertTriangle, { className: "h-5 w-5 text-destructive" }),
|
|
52601
|
+
pendingAction?.confirmTitle || "Confirm Action"
|
|
52602
|
+
] }),
|
|
52603
|
+
/* @__PURE__ */ jsx(AlertDialogDescription2, { children: pendingAction?.confirmMessage || `This action will affect ${selectedCount} selected item${selectedCount > 1 ? "s" : ""}. This action cannot be undone.` })
|
|
52604
|
+
] }),
|
|
52605
|
+
/* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
|
|
52606
|
+
/* @__PURE__ */ jsx(AlertDialogCancel2, { disabled: isLoading, children: "Cancel" }),
|
|
52607
|
+
/* @__PURE__ */ jsx(
|
|
52608
|
+
AlertDialogAction2,
|
|
52609
|
+
{
|
|
52610
|
+
onClick: handleConfirm,
|
|
52611
|
+
disabled: isLoading,
|
|
52612
|
+
className: cn(
|
|
52613
|
+
pendingAction?.variant === "destructive" && "bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
|
52614
|
+
),
|
|
52615
|
+
children: isLoading ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
52616
|
+
/* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
52617
|
+
"Processing..."
|
|
52618
|
+
] }) : "Confirm"
|
|
52619
|
+
}
|
|
52620
|
+
)
|
|
52621
|
+
] })
|
|
52622
|
+
] })
|
|
52623
|
+
}
|
|
52624
|
+
)
|
|
52625
|
+
] });
|
|
52626
|
+
}
|
|
52627
|
+
|
|
52628
|
+
// src/components/data-table/data-table-export.ts
|
|
52629
|
+
function dataToCSV(data, columns, includeHeaders = true) {
|
|
52630
|
+
if (data.length === 0)
|
|
52631
|
+
return "";
|
|
52632
|
+
const cols = columns || Object.keys(data[0]);
|
|
52633
|
+
const rows = [];
|
|
52634
|
+
if (includeHeaders) {
|
|
52635
|
+
const headers = cols.map((col) => {
|
|
52636
|
+
const value = String(col);
|
|
52637
|
+
return value.includes(",") || value.includes('"') || value.includes("\n") ? `"${value.replace(/"/g, '""')}"` : value;
|
|
52638
|
+
});
|
|
52639
|
+
rows.push(headers.join(","));
|
|
52640
|
+
}
|
|
52641
|
+
data.forEach((item) => {
|
|
52642
|
+
const row = cols.map((col) => {
|
|
52643
|
+
const value = item[col];
|
|
52644
|
+
if (value === null || value === void 0)
|
|
52645
|
+
return "";
|
|
52646
|
+
if (value instanceof Date)
|
|
52647
|
+
return value.toISOString();
|
|
52648
|
+
if (typeof value === "object")
|
|
52649
|
+
return JSON.stringify(value);
|
|
52650
|
+
const stringValue = String(value);
|
|
52651
|
+
return stringValue.includes(",") || stringValue.includes('"') || stringValue.includes("\n") ? `"${stringValue.replace(/"/g, '""')}"` : stringValue;
|
|
52652
|
+
});
|
|
52653
|
+
rows.push(row.join(","));
|
|
52654
|
+
});
|
|
52655
|
+
return rows.join("\n");
|
|
52656
|
+
}
|
|
52657
|
+
function dataToJSON(data, columns) {
|
|
52658
|
+
if (!columns || columns.length === 0) {
|
|
52659
|
+
return JSON.stringify(data, null, 2);
|
|
52660
|
+
}
|
|
52661
|
+
const filteredData = data.map((item) => {
|
|
52662
|
+
const filtered = {};
|
|
52663
|
+
columns.forEach((col) => {
|
|
52664
|
+
if (col in item) {
|
|
52665
|
+
filtered[col] = item[col];
|
|
52666
|
+
}
|
|
52667
|
+
});
|
|
52668
|
+
return filtered;
|
|
52669
|
+
});
|
|
52670
|
+
return JSON.stringify(filteredData, null, 2);
|
|
52671
|
+
}
|
|
52672
|
+
function downloadFile(content, filename, mimeType) {
|
|
52673
|
+
const blob = new Blob([content], { type: mimeType });
|
|
52674
|
+
const url = URL.createObjectURL(blob);
|
|
52675
|
+
const link = document.createElement("a");
|
|
52676
|
+
link.href = url;
|
|
52677
|
+
link.download = filename;
|
|
52678
|
+
document.body.appendChild(link);
|
|
52679
|
+
link.click();
|
|
52680
|
+
document.body.removeChild(link);
|
|
52681
|
+
URL.revokeObjectURL(url);
|
|
52682
|
+
}
|
|
52683
|
+
async function exportData(data, options) {
|
|
52684
|
+
const { format, filename = "data-export", columns, includeHeaders = true } = options;
|
|
52685
|
+
let content;
|
|
52686
|
+
let mimeType;
|
|
52687
|
+
let extension;
|
|
52688
|
+
switch (format) {
|
|
52689
|
+
case "csv":
|
|
52690
|
+
content = dataToCSV(data, columns, includeHeaders);
|
|
52691
|
+
mimeType = "text/csv;charset=utf-8;";
|
|
52692
|
+
extension = "csv";
|
|
52693
|
+
break;
|
|
52694
|
+
case "json":
|
|
52695
|
+
content = dataToJSON(data, columns);
|
|
52696
|
+
mimeType = "application/json;charset=utf-8;";
|
|
52697
|
+
extension = "json";
|
|
52698
|
+
break;
|
|
52699
|
+
case "xlsx":
|
|
52700
|
+
throw new Error("XLSX export requires additional dependencies. Use CSV format instead.");
|
|
52701
|
+
default:
|
|
52702
|
+
throw new Error(`Unsupported export format: ${format}`);
|
|
52703
|
+
}
|
|
52704
|
+
const finalFilename = `${filename}-${( new Date()).toISOString().split("T")[0]}.${extension}`;
|
|
52705
|
+
downloadFile(content, finalFilename, mimeType);
|
|
52706
|
+
}
|
|
52707
|
+
function getVisibleColumns(columns, columnVisibility) {
|
|
52708
|
+
return columns.filter((col) => {
|
|
52709
|
+
const key = col.id || col.accessorKey;
|
|
52710
|
+
return key && columnVisibility[key] !== false;
|
|
52711
|
+
}).map((col) => col.id || col.accessorKey).filter(Boolean);
|
|
52712
|
+
}
|
|
52713
|
+
var operatorLabels = {
|
|
52714
|
+
equals: "Equals",
|
|
52715
|
+
notEquals: "Not equals",
|
|
52716
|
+
contains: "Contains",
|
|
52717
|
+
notContains: "Not contains",
|
|
52718
|
+
startsWith: "Starts with",
|
|
52719
|
+
endsWith: "Ends with",
|
|
52720
|
+
greaterThan: "Greater than",
|
|
52721
|
+
lessThan: "Less than",
|
|
52722
|
+
greaterThanOrEqual: "Greater than or equal",
|
|
52723
|
+
lessThanOrEqual: "Less than or equal",
|
|
52724
|
+
between: "Between",
|
|
52725
|
+
in: "In",
|
|
52726
|
+
notIn: "Not in",
|
|
52727
|
+
isNull: "Is empty",
|
|
52728
|
+
isNotNull: "Is not empty"
|
|
52729
|
+
};
|
|
52730
|
+
function getOperatorsForColumnType(columnType) {
|
|
52731
|
+
switch (columnType) {
|
|
52732
|
+
case "number":
|
|
52733
|
+
return ["equals", "notEquals", "greaterThan", "lessThan", "greaterThanOrEqual", "lessThanOrEqual", "between", "isNull", "isNotNull"];
|
|
52734
|
+
case "date":
|
|
52735
|
+
return ["equals", "notEquals", "greaterThan", "lessThan", "greaterThanOrEqual", "lessThanOrEqual", "between", "isNull", "isNotNull"];
|
|
52736
|
+
case "boolean":
|
|
52737
|
+
return ["equals", "notEquals", "isNull", "isNotNull"];
|
|
52738
|
+
case "select":
|
|
52739
|
+
return ["equals", "notEquals", "in", "notIn", "isNull", "isNotNull"];
|
|
52740
|
+
default:
|
|
52741
|
+
return ["equals", "notEquals", "contains", "notContains", "startsWith", "endsWith", "isNull", "isNotNull"];
|
|
52742
|
+
}
|
|
52743
|
+
}
|
|
52744
|
+
function DataTableFilterDrawer({
|
|
52745
|
+
table,
|
|
52746
|
+
open,
|
|
52747
|
+
onOpenChange,
|
|
52748
|
+
position = "right",
|
|
52749
|
+
width = "400px",
|
|
52750
|
+
filters: externalFilters,
|
|
52751
|
+
onFiltersChange,
|
|
52752
|
+
customFilters
|
|
52753
|
+
}) {
|
|
52754
|
+
const [internalFilters, setInternalFilters] = useState([]);
|
|
52755
|
+
const [matchAll, setMatchAll] = useState(true);
|
|
52756
|
+
const filters = externalFilters || internalFilters;
|
|
52757
|
+
const setFilters = onFiltersChange || setInternalFilters;
|
|
52758
|
+
const filterableColumns = useMemo(() => {
|
|
52759
|
+
return table.getAllColumns().filter((column) => {
|
|
52760
|
+
if (column.id === "select" || column.id === "actions" || column.id === "expander") {
|
|
52761
|
+
return false;
|
|
52762
|
+
}
|
|
52763
|
+
return column.getCanFilter();
|
|
52764
|
+
});
|
|
52765
|
+
}, [table]);
|
|
52766
|
+
const addFilter = () => {
|
|
52767
|
+
const firstColumn = filterableColumns[0];
|
|
52768
|
+
if (!firstColumn)
|
|
52769
|
+
return;
|
|
52770
|
+
const newFilter = {
|
|
52771
|
+
column: firstColumn.id,
|
|
52772
|
+
operator: "contains",
|
|
52773
|
+
value: ""
|
|
52774
|
+
};
|
|
52775
|
+
setFilters([...filters, newFilter]);
|
|
52776
|
+
};
|
|
52777
|
+
const updateFilter = (index, updates) => {
|
|
52778
|
+
const newFilters = [...filters];
|
|
52779
|
+
newFilters[index] = { ...newFilters[index], ...updates };
|
|
52780
|
+
setFilters(newFilters);
|
|
52781
|
+
};
|
|
52782
|
+
const removeFilter = (index) => {
|
|
52783
|
+
setFilters(filters.filter((_, i) => i !== index));
|
|
52784
|
+
};
|
|
52785
|
+
const clearAllFilters = () => {
|
|
52786
|
+
setFilters([]);
|
|
52787
|
+
table.resetColumnFilters();
|
|
52788
|
+
};
|
|
52789
|
+
const applyFilters = () => {
|
|
52790
|
+
table.resetColumnFilters();
|
|
52791
|
+
filters.forEach((filter) => {
|
|
52792
|
+
const column = table.getColumn(filter.column);
|
|
52793
|
+
if (!column)
|
|
52794
|
+
return;
|
|
52795
|
+
switch (filter.operator) {
|
|
52796
|
+
case "equals":
|
|
52797
|
+
column.setFilterValue(filter.value);
|
|
52798
|
+
break;
|
|
52799
|
+
case "notEquals":
|
|
52800
|
+
column.setFilterValue((value) => value !== filter.value);
|
|
52801
|
+
break;
|
|
52802
|
+
case "contains":
|
|
52803
|
+
column.setFilterValue(
|
|
52804
|
+
(value) => String(value).toLowerCase().includes(String(filter.value).toLowerCase())
|
|
52805
|
+
);
|
|
52806
|
+
break;
|
|
52807
|
+
case "notContains":
|
|
52808
|
+
column.setFilterValue(
|
|
52809
|
+
(value) => !String(value).toLowerCase().includes(String(filter.value).toLowerCase())
|
|
52810
|
+
);
|
|
52811
|
+
break;
|
|
52812
|
+
case "startsWith":
|
|
52813
|
+
column.setFilterValue(
|
|
52814
|
+
(value) => String(value).toLowerCase().startsWith(String(filter.value).toLowerCase())
|
|
52815
|
+
);
|
|
52816
|
+
break;
|
|
52817
|
+
case "endsWith":
|
|
52818
|
+
column.setFilterValue(
|
|
52819
|
+
(value) => String(value).toLowerCase().endsWith(String(filter.value).toLowerCase())
|
|
52820
|
+
);
|
|
52821
|
+
break;
|
|
52822
|
+
case "greaterThan":
|
|
52823
|
+
column.setFilterValue((value) => Number(value) > Number(filter.value));
|
|
52824
|
+
break;
|
|
52825
|
+
case "lessThan":
|
|
52826
|
+
column.setFilterValue((value) => Number(value) < Number(filter.value));
|
|
52827
|
+
break;
|
|
52828
|
+
case "greaterThanOrEqual":
|
|
52829
|
+
column.setFilterValue((value) => Number(value) >= Number(filter.value));
|
|
52830
|
+
break;
|
|
52831
|
+
case "lessThanOrEqual":
|
|
52832
|
+
column.setFilterValue((value) => Number(value) <= Number(filter.value));
|
|
52833
|
+
break;
|
|
52834
|
+
case "isNull":
|
|
52835
|
+
column.setFilterValue((value) => value == null || value === "");
|
|
52836
|
+
break;
|
|
52837
|
+
case "isNotNull":
|
|
52838
|
+
column.setFilterValue((value) => value != null && value !== "");
|
|
52839
|
+
break;
|
|
52840
|
+
}
|
|
52841
|
+
});
|
|
52842
|
+
onOpenChange(false);
|
|
52843
|
+
};
|
|
52844
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
52845
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: open && /* @__PURE__ */ jsx(
|
|
52846
|
+
motion.div,
|
|
52847
|
+
{
|
|
52848
|
+
initial: { opacity: 0 },
|
|
52849
|
+
animate: { opacity: 1 },
|
|
52850
|
+
exit: { opacity: 0 },
|
|
52851
|
+
className: "fixed inset-0 bg-black/20 z-40",
|
|
52852
|
+
onClick: () => onOpenChange(false)
|
|
52853
|
+
}
|
|
52854
|
+
) }),
|
|
52855
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: open && /* @__PURE__ */ jsx(
|
|
52856
|
+
motion.div,
|
|
52857
|
+
{
|
|
52858
|
+
initial: { x: position === "right" ? "100%" : "-100%" },
|
|
52859
|
+
animate: { x: 0 },
|
|
52860
|
+
exit: { x: position === "right" ? "100%" : "-100%" },
|
|
52861
|
+
transition: { type: "spring", damping: 30, stiffness: 300 },
|
|
52862
|
+
className: cn(
|
|
52863
|
+
"fixed top-0 bottom-0 z-50 bg-background border-l shadow-xl",
|
|
52864
|
+
position === "right" ? "right-0" : "left-0"
|
|
52865
|
+
),
|
|
52866
|
+
style: { width },
|
|
52867
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
|
|
52868
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between p-4 border-b", children: [
|
|
52869
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
52870
|
+
/* @__PURE__ */ jsx(Filter, { className: "h-5 w-5" }),
|
|
52871
|
+
/* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold", children: "Filters" }),
|
|
52872
|
+
filters.length > 0 && /* @__PURE__ */ jsxs("span", { className: "text-sm text-muted-foreground", children: [
|
|
52873
|
+
"(",
|
|
52874
|
+
filters.length,
|
|
52875
|
+
" active)"
|
|
52876
|
+
] })
|
|
52877
|
+
] }),
|
|
52878
|
+
/* @__PURE__ */ jsx(
|
|
52879
|
+
MoonUIButtonPro,
|
|
52880
|
+
{
|
|
52881
|
+
variant: "ghost",
|
|
52882
|
+
size: "icon",
|
|
52883
|
+
onClick: () => onOpenChange(false),
|
|
52884
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
|
|
52885
|
+
}
|
|
52886
|
+
)
|
|
52887
|
+
] }),
|
|
52888
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 overflow-y-auto p-4", children: [
|
|
52889
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-6", children: [
|
|
52890
|
+
/* @__PURE__ */ jsx(MoonUILabelPro, { className: "text-sm font-medium mb-2 block", children: "Match conditions" }),
|
|
52891
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
52892
|
+
/* @__PURE__ */ jsx(
|
|
52893
|
+
MoonUIButtonPro,
|
|
52894
|
+
{
|
|
52895
|
+
variant: matchAll ? "primary" : "outline",
|
|
52896
|
+
size: "sm",
|
|
52897
|
+
onClick: () => setMatchAll(true),
|
|
52898
|
+
className: "flex-1",
|
|
52899
|
+
children: "Match all"
|
|
52900
|
+
}
|
|
52901
|
+
),
|
|
52902
|
+
/* @__PURE__ */ jsx(
|
|
52903
|
+
MoonUIButtonPro,
|
|
52904
|
+
{
|
|
52905
|
+
variant: !matchAll ? "primary" : "outline",
|
|
52906
|
+
size: "sm",
|
|
52907
|
+
onClick: () => setMatchAll(false),
|
|
52908
|
+
className: "flex-1",
|
|
52909
|
+
children: "Match any"
|
|
52910
|
+
}
|
|
52911
|
+
)
|
|
52912
|
+
] })
|
|
52913
|
+
] }),
|
|
52914
|
+
/* @__PURE__ */ jsx(MoonUISeparatorPro, { className: "mb-6" }),
|
|
52915
|
+
customFilters && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
52916
|
+
customFilters,
|
|
52917
|
+
/* @__PURE__ */ jsx(MoonUISeparatorPro, { className: "my-6" })
|
|
52918
|
+
] }),
|
|
52919
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-4", children: filters.map((filter, index) => /* @__PURE__ */ jsx(
|
|
52920
|
+
FilterConditionRow,
|
|
52921
|
+
{
|
|
52922
|
+
filter,
|
|
52923
|
+
columns: filterableColumns,
|
|
52924
|
+
onUpdate: (updates) => updateFilter(index, updates),
|
|
52925
|
+
onRemove: () => removeFilter(index)
|
|
52926
|
+
},
|
|
52927
|
+
index
|
|
52928
|
+
)) }),
|
|
52929
|
+
/* @__PURE__ */ jsxs(
|
|
52930
|
+
MoonUIButtonPro,
|
|
52931
|
+
{
|
|
52932
|
+
variant: "outline",
|
|
52933
|
+
size: "sm",
|
|
52934
|
+
onClick: addFilter,
|
|
52935
|
+
className: "w-full mt-4",
|
|
52936
|
+
children: [
|
|
52937
|
+
/* @__PURE__ */ jsx(Plus, { className: "h-4 w-4 mr-2" }),
|
|
52938
|
+
"Add filter"
|
|
52939
|
+
]
|
|
52940
|
+
}
|
|
52941
|
+
)
|
|
52942
|
+
] }),
|
|
52943
|
+
/* @__PURE__ */ jsx("div", { className: "p-4 border-t space-y-2", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
52944
|
+
/* @__PURE__ */ jsxs(
|
|
52945
|
+
MoonUIButtonPro,
|
|
52946
|
+
{
|
|
52947
|
+
variant: "outline",
|
|
52948
|
+
onClick: clearAllFilters,
|
|
52949
|
+
disabled: filters.length === 0,
|
|
52950
|
+
className: "flex-1",
|
|
52951
|
+
children: [
|
|
52952
|
+
/* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4 mr-2" }),
|
|
52953
|
+
"Clear all"
|
|
52954
|
+
]
|
|
52955
|
+
}
|
|
52956
|
+
),
|
|
52957
|
+
/* @__PURE__ */ jsx(MoonUIButtonPro, { onClick: applyFilters, className: "flex-1", children: "Apply filters" })
|
|
52958
|
+
] }) })
|
|
52959
|
+
] })
|
|
52960
|
+
}
|
|
52961
|
+
) })
|
|
52962
|
+
] });
|
|
52963
|
+
}
|
|
52964
|
+
function FilterConditionRow({
|
|
52965
|
+
filter,
|
|
52966
|
+
columns,
|
|
52967
|
+
onUpdate,
|
|
52968
|
+
onRemove
|
|
52969
|
+
}) {
|
|
52970
|
+
const selectedColumn = columns.find((col) => col.id === filter.column);
|
|
52971
|
+
const columnDef = selectedColumn?.columnDef;
|
|
52972
|
+
const columnType = columnDef?.meta?.filterType || "string";
|
|
52973
|
+
const availableOperators = getOperatorsForColumnType(columnType);
|
|
52974
|
+
const needsValue = filter.operator !== "isNull" && filter.operator !== "isNotNull";
|
|
52975
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2 p-3 border rounded-lg bg-muted/30", children: [
|
|
52976
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
52977
|
+
/* @__PURE__ */ jsxs(
|
|
52978
|
+
MoonUISelectPro,
|
|
52979
|
+
{
|
|
52980
|
+
value: filter.column,
|
|
52981
|
+
onValueChange: (value) => onUpdate({ column: value }),
|
|
52982
|
+
children: [
|
|
52983
|
+
/* @__PURE__ */ jsx(MoonUISelectTriggerPro, { className: "flex-1", children: /* @__PURE__ */ jsx(MoonUISelectValuePro, {}) }),
|
|
52984
|
+
/* @__PURE__ */ jsx(MoonUISelectContentPro, { children: columns.map((column) => {
|
|
52985
|
+
const header = column.columnDef.header;
|
|
52986
|
+
const label = typeof header === "function" ? column.id : header || column.id;
|
|
52987
|
+
return /* @__PURE__ */ jsx(MoonUISelectItemPro, { value: column.id, children: label }, column.id);
|
|
52988
|
+
}) })
|
|
52989
|
+
]
|
|
52990
|
+
}
|
|
52991
|
+
),
|
|
52992
|
+
/* @__PURE__ */ jsx(
|
|
52993
|
+
MoonUIButtonPro,
|
|
52994
|
+
{
|
|
52995
|
+
variant: "ghost",
|
|
52996
|
+
size: "icon",
|
|
52997
|
+
onClick: onRemove,
|
|
52998
|
+
className: "h-8 w-8",
|
|
52999
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
|
|
53000
|
+
}
|
|
53001
|
+
)
|
|
53002
|
+
] }),
|
|
53003
|
+
/* @__PURE__ */ jsxs(
|
|
53004
|
+
MoonUISelectPro,
|
|
53005
|
+
{
|
|
53006
|
+
value: filter.operator,
|
|
53007
|
+
onValueChange: (value) => onUpdate({ operator: value }),
|
|
53008
|
+
children: [
|
|
53009
|
+
/* @__PURE__ */ jsx(MoonUISelectTriggerPro, { children: /* @__PURE__ */ jsx(MoonUISelectValuePro, {}) }),
|
|
53010
|
+
/* @__PURE__ */ jsx(MoonUISelectContentPro, { children: availableOperators.map((operator2) => /* @__PURE__ */ jsx(MoonUISelectItemPro, { value: operator2, children: operatorLabels[operator2] }, operator2)) })
|
|
53011
|
+
]
|
|
53012
|
+
}
|
|
53013
|
+
),
|
|
53014
|
+
needsValue && /* @__PURE__ */ jsx("div", { children: columnType === "boolean" ? /* @__PURE__ */ jsxs(
|
|
53015
|
+
MoonUISelectPro,
|
|
53016
|
+
{
|
|
53017
|
+
value: String(filter.value),
|
|
53018
|
+
onValueChange: (value) => onUpdate({ value: value === "true" }),
|
|
53019
|
+
children: [
|
|
53020
|
+
/* @__PURE__ */ jsx(MoonUISelectTriggerPro, { children: /* @__PURE__ */ jsx(MoonUISelectValuePro, {}) }),
|
|
53021
|
+
/* @__PURE__ */ jsxs(MoonUISelectContentPro, { children: [
|
|
53022
|
+
/* @__PURE__ */ jsx(MoonUISelectItemPro, { value: "true", children: "True" }),
|
|
53023
|
+
/* @__PURE__ */ jsx(MoonUISelectItemPro, { value: "false", children: "False" })
|
|
53024
|
+
] })
|
|
53025
|
+
]
|
|
53026
|
+
}
|
|
53027
|
+
) : columnType === "number" ? /* @__PURE__ */ jsx(
|
|
53028
|
+
MoonUIInputPro,
|
|
53029
|
+
{
|
|
53030
|
+
type: "number",
|
|
53031
|
+
value: filter.value || "",
|
|
53032
|
+
onChange: (e) => onUpdate({ value: e.target.value }),
|
|
53033
|
+
placeholder: "Enter value..."
|
|
53034
|
+
}
|
|
53035
|
+
) : /* @__PURE__ */ jsx(
|
|
53036
|
+
MoonUIInputPro,
|
|
53037
|
+
{
|
|
53038
|
+
value: filter.value || "",
|
|
53039
|
+
onChange: (e) => onUpdate({ value: e.target.value }),
|
|
53040
|
+
placeholder: "Enter value..."
|
|
53041
|
+
}
|
|
53042
|
+
) })
|
|
53043
|
+
] });
|
|
53044
|
+
}
|
|
52156
53045
|
function DataTable({
|
|
52157
53046
|
columns,
|
|
52158
53047
|
data,
|
|
@@ -52169,6 +53058,7 @@ function DataTable({
|
|
|
52169
53058
|
renderSubComponent,
|
|
52170
53059
|
expandedRows: controlledExpandedRows,
|
|
52171
53060
|
onRowExpandChange,
|
|
53061
|
+
bulkActions = [],
|
|
52172
53062
|
features = {},
|
|
52173
53063
|
theme = {},
|
|
52174
53064
|
texts = {},
|
|
@@ -52208,6 +53098,7 @@ function DataTable({
|
|
|
52208
53098
|
const [globalFilter, setGlobalFilter] = t__default.useState("");
|
|
52209
53099
|
const [isPaginationLoading, setIsPaginationLoading] = t__default.useState(false);
|
|
52210
53100
|
const [internalExpandedRows, setInternalExpandedRows] = t__default.useState(/* @__PURE__ */ new Set());
|
|
53101
|
+
const [filterDrawerOpen, setFilterDrawerOpen] = t__default.useState(false);
|
|
52211
53102
|
const expandedRows = controlledExpandedRows || internalExpandedRows;
|
|
52212
53103
|
const actualPageSize = defaultPageSize || pageSize;
|
|
52213
53104
|
const stableData = t__default.useMemo(() => data, [data]);
|
|
@@ -52237,7 +53128,12 @@ function DataTable({
|
|
|
52237
53128
|
pagination: {
|
|
52238
53129
|
pageSize: actualPageSize
|
|
52239
53130
|
}
|
|
52240
|
-
}
|
|
53131
|
+
},
|
|
53132
|
+
// Prevent re-renders on state changes
|
|
53133
|
+
autoResetAll: false,
|
|
53134
|
+
autoResetPageIndex: false,
|
|
53135
|
+
autoResetExpanded: false,
|
|
53136
|
+
getRowId: (row) => row.id || row.orderId || Math.random().toString()
|
|
52241
53137
|
});
|
|
52242
53138
|
t__default.useEffect(() => {
|
|
52243
53139
|
if (onRowSelect && selectable) {
|
|
@@ -52245,12 +53141,17 @@ function DataTable({
|
|
|
52245
53141
|
onRowSelect(selectedRows);
|
|
52246
53142
|
}
|
|
52247
53143
|
}, [rowSelection, onRowSelect, selectable, table]);
|
|
52248
|
-
|
|
52249
|
-
const
|
|
52250
|
-
|
|
52251
|
-
|
|
52252
|
-
|
|
52253
|
-
|
|
53144
|
+
table.getState();
|
|
53145
|
+
const rowModel = table.getRowModel();
|
|
53146
|
+
const rowsRef = t__default.useRef(rowModel.rows);
|
|
53147
|
+
t__default.useMemo(() => {
|
|
53148
|
+
const changed = rowsRef.current !== rowModel.rows;
|
|
53149
|
+
if (changed) {
|
|
53150
|
+
rowsRef.current = rowModel.rows;
|
|
53151
|
+
}
|
|
53152
|
+
return changed;
|
|
53153
|
+
}, [rowModel.rows]);
|
|
53154
|
+
const rows = rowsRef.current;
|
|
52254
53155
|
({
|
|
52255
53156
|
sorting: features.sorting !== false,
|
|
52256
53157
|
filtering: features.filtering !== false || filterable,
|
|
@@ -52260,12 +53161,38 @@ function DataTable({
|
|
|
52260
53161
|
rowSelection: features.rowSelection !== false || selectable,
|
|
52261
53162
|
export: features.export !== false || exportable
|
|
52262
53163
|
});
|
|
52263
|
-
const handleExport = () => {
|
|
53164
|
+
const handleExport = async (format) => {
|
|
53165
|
+
const selectedRows = table.getFilteredSelectedRowModel().rows;
|
|
53166
|
+
const dataToExport = selectedRows.length > 0 ? selectedRows.map((row) => row.original) : table.getFilteredRowModel().rows.map((row) => row.original);
|
|
53167
|
+
if (typeof exportable === "object" && exportable.onExport) {
|
|
53168
|
+
exportable.onExport(dataToExport, format);
|
|
53169
|
+
return;
|
|
53170
|
+
}
|
|
52264
53171
|
if (onExport) {
|
|
52265
|
-
const selectedRows = table.getFilteredSelectedRowModel().rows;
|
|
52266
|
-
const dataToExport = selectedRows.length > 0 ? selectedRows.map((row) => row.original) : table.getFilteredRowModel().rows.map((row) => row.original);
|
|
52267
53172
|
onExport(dataToExport);
|
|
53173
|
+
return;
|
|
52268
53174
|
}
|
|
53175
|
+
const filename = typeof exportable === "object" && exportable.filename ? exportable.filename : "data-export";
|
|
53176
|
+
const visibleColumns = getVisibleColumns(columns, columnVisibility);
|
|
53177
|
+
await exportData(dataToExport, {
|
|
53178
|
+
format,
|
|
53179
|
+
filename,
|
|
53180
|
+
columns: visibleColumns,
|
|
53181
|
+
includeHeaders: true
|
|
53182
|
+
});
|
|
53183
|
+
};
|
|
53184
|
+
const exportFormats = t__default.useMemo(() => {
|
|
53185
|
+
if (!exportable)
|
|
53186
|
+
return [];
|
|
53187
|
+
if (exportable === true)
|
|
53188
|
+
return ["csv", "json"];
|
|
53189
|
+
if (typeof exportable === "object" && exportable.formats) {
|
|
53190
|
+
return exportable.formats;
|
|
53191
|
+
}
|
|
53192
|
+
return ["csv", "json"];
|
|
53193
|
+
}, [exportable]);
|
|
53194
|
+
const clearRowSelection = () => {
|
|
53195
|
+
table.resetRowSelection();
|
|
52269
53196
|
};
|
|
52270
53197
|
return /* @__PURE__ */ jsxs("div", { className: cn("moonui-pro-datatable-container flex flex-col gap-4", className), children: [
|
|
52271
53198
|
/* @__PURE__ */ jsxs("div", { className: "moonui-pro-datatable-toolbar flex items-center justify-between", children: [
|
|
@@ -52282,20 +53209,50 @@ function DataTable({
|
|
|
52282
53209
|
}
|
|
52283
53210
|
)
|
|
52284
53211
|
] }),
|
|
52285
|
-
filterable && /* @__PURE__ */ jsxs(
|
|
52286
|
-
|
|
52287
|
-
|
|
52288
|
-
|
|
53212
|
+
filterable && /* @__PURE__ */ jsxs(
|
|
53213
|
+
MoonUIButtonPro,
|
|
53214
|
+
{
|
|
53215
|
+
variant: "outline",
|
|
53216
|
+
size: "sm",
|
|
53217
|
+
onClick: () => setFilterDrawerOpen(true),
|
|
53218
|
+
children: [
|
|
53219
|
+
/* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Filter, { className: "mr-2 h-4 w-4" }) }),
|
|
53220
|
+
"Filters",
|
|
53221
|
+
columnFilters.length > 0 && /* @__PURE__ */ jsx("span", { className: "ml-2 rounded-full bg-primary px-2 py-0.5 text-xs text-primary-foreground", children: columnFilters.length })
|
|
53222
|
+
]
|
|
53223
|
+
}
|
|
53224
|
+
),
|
|
53225
|
+
selectable && bulkActions.length > 0 && /* @__PURE__ */ jsx(
|
|
53226
|
+
DataTableBulkActions,
|
|
53227
|
+
{
|
|
53228
|
+
selectedRows: table.getFilteredSelectedRowModel().rows.map((row) => row.original),
|
|
53229
|
+
actions: bulkActions,
|
|
53230
|
+
onClearSelection: clearRowSelection
|
|
53231
|
+
}
|
|
53232
|
+
)
|
|
52289
53233
|
] }),
|
|
52290
53234
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
52291
|
-
exportable && /* @__PURE__ */ jsxs(
|
|
52292
|
-
/* @__PURE__ */ jsx(
|
|
52293
|
-
|
|
53235
|
+
exportable && exportFormats.length > 0 && /* @__PURE__ */ jsxs(MoonUIDropdownMenuPro, { children: [
|
|
53236
|
+
/* @__PURE__ */ jsx(MoonUIDropdownMenuTriggerPro, { asChild: true, children: /* @__PURE__ */ jsxs(MoonUIButtonPro, { variant: "outline", size: "sm", children: [
|
|
53237
|
+
/* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Download, { className: "mr-2 h-4 w-4" }) }),
|
|
53238
|
+
"Export"
|
|
53239
|
+
] }) }),
|
|
53240
|
+
/* @__PURE__ */ jsxs(MoonUIDropdownMenuContentPro, { align: "end", children: [
|
|
53241
|
+
exportFormats.includes("csv") && /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => handleExport("csv"), children: [
|
|
53242
|
+
/* @__PURE__ */ jsx(FileSpreadsheet, { className: "mr-2 h-4 w-4" }),
|
|
53243
|
+
"Export as CSV"
|
|
53244
|
+
] }),
|
|
53245
|
+
exportFormats.includes("json") && /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => handleExport("json"), children: [
|
|
53246
|
+
/* @__PURE__ */ jsx(FileJson, { className: "mr-2 h-4 w-4" }),
|
|
53247
|
+
"Export as JSON"
|
|
53248
|
+
] }),
|
|
53249
|
+
exportFormats.includes("xlsx") && /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => handleExport("xlsx"), children: [
|
|
53250
|
+
/* @__PURE__ */ jsx(FileDown, { className: "mr-2 h-4 w-4" }),
|
|
53251
|
+
"Export as Excel"
|
|
53252
|
+
] })
|
|
53253
|
+
] })
|
|
52294
53254
|
] }),
|
|
52295
|
-
/* @__PURE__ */
|
|
52296
|
-
/* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Settings, { className: "mr-2 h-4 w-4" }) }),
|
|
52297
|
-
"Columns"
|
|
52298
|
-
] })
|
|
53255
|
+
/* @__PURE__ */ jsx(DataTableColumnToggle, { table })
|
|
52299
53256
|
] })
|
|
52300
53257
|
] }),
|
|
52301
53258
|
/* @__PURE__ */ jsx("div", { className: "moonui-pro-datatable-wrapper rounded-md border overflow-hidden", style: { contain: "layout style" }, children: /* @__PURE__ */ jsx("div", { style: { overflowX: "auto" }, children: /* @__PURE__ */ jsxs("table", { className: "moonui-pro-datatable", style: { width: "100%", tableLayout: "auto" }, children: [
|
|
@@ -52336,66 +53293,17 @@ function DataTable({
|
|
|
52336
53293
|
) : rows?.length ? /* @__PURE__ */ jsx(Fragment, { children: rows.map((row, index) => {
|
|
52337
53294
|
const rowId = row.original.id || row.id;
|
|
52338
53295
|
const isExpanded = enableExpandable && expandedRows.has(rowId);
|
|
52339
|
-
return /* @__PURE__ */
|
|
52340
|
-
|
|
52341
|
-
|
|
52342
|
-
|
|
52343
|
-
|
|
52344
|
-
|
|
52345
|
-
|
|
52346
|
-
|
|
52347
|
-
|
|
52348
|
-
|
|
52349
|
-
|
|
52350
|
-
),
|
|
52351
|
-
/* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: isExpanded && renderSubComponent && /* @__PURE__ */ jsx(
|
|
52352
|
-
motion.tr,
|
|
52353
|
-
{
|
|
52354
|
-
initial: { height: 0, opacity: 0 },
|
|
52355
|
-
animate: {
|
|
52356
|
-
height: "auto",
|
|
52357
|
-
opacity: 1,
|
|
52358
|
-
transition: {
|
|
52359
|
-
height: {
|
|
52360
|
-
duration: 0.3,
|
|
52361
|
-
ease: "easeOut"
|
|
52362
|
-
},
|
|
52363
|
-
opacity: {
|
|
52364
|
-
duration: 0.2,
|
|
52365
|
-
delay: 0.1
|
|
52366
|
-
}
|
|
52367
|
-
}
|
|
52368
|
-
},
|
|
52369
|
-
exit: {
|
|
52370
|
-
height: 0,
|
|
52371
|
-
opacity: 0,
|
|
52372
|
-
transition: {
|
|
52373
|
-
height: {
|
|
52374
|
-
duration: 0.3,
|
|
52375
|
-
ease: "easeIn"
|
|
52376
|
-
},
|
|
52377
|
-
opacity: {
|
|
52378
|
-
duration: 0.2
|
|
52379
|
-
}
|
|
52380
|
-
}
|
|
52381
|
-
},
|
|
52382
|
-
style: { overflow: "hidden" },
|
|
52383
|
-
className: "border-b",
|
|
52384
|
-
children: /* @__PURE__ */ jsx("td", { colSpan: columns.length, className: "p-0", children: /* @__PURE__ */ jsx(
|
|
52385
|
-
motion.div,
|
|
52386
|
-
{
|
|
52387
|
-
initial: { y: -10 },
|
|
52388
|
-
animate: { y: 0 },
|
|
52389
|
-
exit: { y: -10 },
|
|
52390
|
-
transition: { duration: 0.2 },
|
|
52391
|
-
className: "border-t border-border/50",
|
|
52392
|
-
children: renderSubComponent({ row: { original: row.original, id: rowId } })
|
|
52393
|
-
}
|
|
52394
|
-
) })
|
|
52395
|
-
},
|
|
52396
|
-
`${row.id}-expanded`
|
|
52397
|
-
) })
|
|
52398
|
-
] }, rowId);
|
|
53296
|
+
return /* @__PURE__ */ jsx(
|
|
53297
|
+
TableRow2,
|
|
53298
|
+
{
|
|
53299
|
+
row,
|
|
53300
|
+
columns,
|
|
53301
|
+
isExpanded,
|
|
53302
|
+
enableExpandable,
|
|
53303
|
+
renderSubComponent
|
|
53304
|
+
},
|
|
53305
|
+
rowId
|
|
53306
|
+
);
|
|
52399
53307
|
}) }) : /* @__PURE__ */ jsx(
|
|
52400
53308
|
motion.tr,
|
|
52401
53309
|
{
|
|
@@ -52514,7 +53422,15 @@ function DataTable({
|
|
|
52514
53422
|
)
|
|
52515
53423
|
] })
|
|
52516
53424
|
] })
|
|
52517
|
-
] })
|
|
53425
|
+
] }),
|
|
53426
|
+
filterable && /* @__PURE__ */ jsx(
|
|
53427
|
+
DataTableFilterDrawer,
|
|
53428
|
+
{
|
|
53429
|
+
table,
|
|
53430
|
+
open: filterDrawerOpen,
|
|
53431
|
+
onOpenChange: setFilterDrawerOpen
|
|
53432
|
+
}
|
|
53433
|
+
)
|
|
52518
53434
|
] });
|
|
52519
53435
|
}
|
|
52520
53436
|
function getExpandableColumn(expandedRows, onToggle) {
|
|
@@ -52567,6 +53483,44 @@ function useExpandableRows(initialExpanded = /* @__PURE__ */ new Set()) {
|
|
|
52567
53483
|
collapseAll
|
|
52568
53484
|
};
|
|
52569
53485
|
}
|
|
53486
|
+
var TableRow2 = t__default.memo(({
|
|
53487
|
+
row,
|
|
53488
|
+
columns,
|
|
53489
|
+
isExpanded,
|
|
53490
|
+
enableExpandable,
|
|
53491
|
+
renderSubComponent
|
|
53492
|
+
}) => {
|
|
53493
|
+
const rowId = row.original.id || row.id;
|
|
53494
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
53495
|
+
/* @__PURE__ */ jsx(
|
|
53496
|
+
"tr",
|
|
53497
|
+
{
|
|
53498
|
+
className: cn(
|
|
53499
|
+
"border-b transition-colors hover:bg-muted/50",
|
|
53500
|
+
row.getIsSelected() && "bg-muted",
|
|
53501
|
+
isExpanded && "border-b-0"
|
|
53502
|
+
),
|
|
53503
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx("td", { className: "moonui-data-table-td p-4 align-middle", children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
|
|
53504
|
+
}
|
|
53505
|
+
),
|
|
53506
|
+
isExpanded && renderSubComponent && /* @__PURE__ */ jsx("tr", { className: "border-b", children: /* @__PURE__ */ jsx("td", { colSpan: columns.length, className: "p-0 overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
53507
|
+
"div",
|
|
53508
|
+
{
|
|
53509
|
+
className: "transition-all duration-300 ease-out",
|
|
53510
|
+
style: {
|
|
53511
|
+
maxHeight: isExpanded ? "1000px" : "0",
|
|
53512
|
+
opacity: isExpanded ? 1 : 0
|
|
53513
|
+
},
|
|
53514
|
+
children: /* @__PURE__ */ jsx("div", { className: "border-t border-border/50", children: renderSubComponent({ row: { original: row.original, id: rowId } }) })
|
|
53515
|
+
}
|
|
53516
|
+
) }) })
|
|
53517
|
+
] });
|
|
53518
|
+
}, (prevProps, nextProps) => {
|
|
53519
|
+
const prevRowId = prevProps.row.original.id || prevProps.row.id;
|
|
53520
|
+
const nextRowId = nextProps.row.original.id || nextProps.row.id;
|
|
53521
|
+
return prevRowId === nextRowId && prevProps.isExpanded === nextProps.isExpanded && prevProps.row.getIsSelected() === nextProps.row.getIsSelected();
|
|
53522
|
+
});
|
|
53523
|
+
TableRow2.displayName = "TableRow";
|
|
52570
53524
|
|
|
52571
53525
|
// src/components/enhanced/index.ts
|
|
52572
53526
|
var enhanced_exports = {};
|