@moontra/moonui-pro 2.3.2 → 2.3.4
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 +21 -8
- package/dist/index.mjs +44 -18
- package/package.json +3 -2
- package/src/components/data-table/index.tsx +61 -17
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
|
21
21
|
import * as ToastPrimitives from '@radix-ui/react-toast';
|
|
22
22
|
import * as TogglePrimitive from '@radix-ui/react-toggle';
|
|
23
23
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
24
|
-
import { ColumnDef } from '@tanstack/react-table';
|
|
24
|
+
import { ColumnDef, OnChangeFn, SortingState, ColumnFiltersState } from '@tanstack/react-table';
|
|
25
25
|
export { ColumnDef } from '@tanstack/react-table';
|
|
26
26
|
|
|
27
27
|
declare function cn(...inputs: ClassValue[]): string;
|
|
@@ -309,7 +309,7 @@ interface MoonUIDialogContentProProps extends Omit<React$1.ComponentPropsWithout
|
|
|
309
309
|
/** Özel onClose handler */
|
|
310
310
|
onClose?: () => void;
|
|
311
311
|
}
|
|
312
|
-
declare const MoonUIDialogContentPro: React$1.ForwardRefExoticComponent<MoonUIDialogContentProProps & React$1.RefAttributes<
|
|
312
|
+
declare const MoonUIDialogContentPro: React$1.ForwardRefExoticComponent<MoonUIDialogContentProProps & React$1.RefAttributes<never>>;
|
|
313
313
|
declare const MoonUIDialogHeaderPro: {
|
|
314
314
|
({ className, ...props }: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
315
315
|
displayName: string;
|
|
@@ -318,8 +318,8 @@ declare const MoonUIDialogFooterPro: {
|
|
|
318
318
|
({ className, ...props }: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
319
319
|
displayName: string;
|
|
320
320
|
};
|
|
321
|
-
declare const MoonUIDialogTitlePro: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & React$1.RefAttributes<HTMLHeadingElement>, "ref"> & React$1.RefAttributes<
|
|
322
|
-
declare const MoonUIDialogDescriptionPro: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & React$1.RefAttributes<HTMLParagraphElement>, "ref"> & React$1.RefAttributes<
|
|
321
|
+
declare const MoonUIDialogTitlePro: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & React$1.RefAttributes<HTMLHeadingElement>, "ref"> & React$1.RefAttributes<never>>;
|
|
322
|
+
declare const MoonUIDialogDescriptionPro: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & React$1.RefAttributes<HTMLParagraphElement>, "ref"> & React$1.RefAttributes<never>>;
|
|
323
323
|
|
|
324
324
|
/**
|
|
325
325
|
* Command (Komut Paleti) Bileşeni
|
|
@@ -1547,6 +1547,19 @@ interface DataTableProps<TData, TValue> {
|
|
|
1547
1547
|
}) => React__default.ReactNode;
|
|
1548
1548
|
expandedRows?: Set<string>;
|
|
1549
1549
|
onRowExpandChange?: (expandedRows: Set<string>) => void;
|
|
1550
|
+
enableSorting?: boolean;
|
|
1551
|
+
enableFiltering?: boolean;
|
|
1552
|
+
enablePagination?: boolean;
|
|
1553
|
+
enableColumnVisibility?: boolean;
|
|
1554
|
+
enableRowSelection?: boolean;
|
|
1555
|
+
filterPlaceholder?: string;
|
|
1556
|
+
defaultPageSize?: number;
|
|
1557
|
+
manualPagination?: boolean;
|
|
1558
|
+
pageCount?: number;
|
|
1559
|
+
onPaginationChange?: (updater: any) => void;
|
|
1560
|
+
onSortingChange?: OnChangeFn<SortingState>;
|
|
1561
|
+
onColumnFiltersChange?: OnChangeFn<ColumnFiltersState>;
|
|
1562
|
+
state?: any;
|
|
1550
1563
|
features?: {
|
|
1551
1564
|
sorting?: boolean;
|
|
1552
1565
|
filtering?: boolean;
|
|
@@ -1577,7 +1590,7 @@ interface DataTableProps<TData, TValue> {
|
|
|
1577
1590
|
filterButton?: string;
|
|
1578
1591
|
};
|
|
1579
1592
|
}
|
|
1580
|
-
declare function DataTable<TData, TValue>({ columns, data, searchable, filterable, exportable, selectable, pagination, pageSize, className, onRowSelect, onExport, enableExpandable, renderSubComponent, expandedRows: controlledExpandedRows, onRowExpandChange, features, theme, texts, }: DataTableProps<TData, TValue>): react_jsx_runtime.JSX.Element;
|
|
1593
|
+
declare function DataTable<TData, TValue>({ columns, data, searchable, filterable, exportable, selectable, pagination, pageSize, className, onRowSelect, onExport, enableExpandable, renderSubComponent, expandedRows: controlledExpandedRows, onRowExpandChange, features, theme, texts, enableSorting, enableFiltering, enablePagination, enableColumnVisibility, enableRowSelection, filterPlaceholder, defaultPageSize, manualPagination, pageCount, onPaginationChange, onSortingChange, onColumnFiltersChange, state: externalState, }: DataTableProps<TData, TValue>): react_jsx_runtime.JSX.Element;
|
|
1581
1594
|
/**
|
|
1582
1595
|
* Helper function to create an expandable column
|
|
1583
1596
|
* @param expandedRows - Set of expanded row IDs
|
|
@@ -1644,7 +1657,7 @@ interface DialogProContentProps extends React$1.ComponentPropsWithoutRef<typeof
|
|
|
1644
1657
|
overlay?: boolean;
|
|
1645
1658
|
overlayProps?: DialogProOverlayProps;
|
|
1646
1659
|
}
|
|
1647
|
-
declare const DialogProContent: React$1.ForwardRefExoticComponent<DialogProContentProps & React$1.RefAttributes<
|
|
1660
|
+
declare const DialogProContent: React$1.ForwardRefExoticComponent<DialogProContentProps & React$1.RefAttributes<never>>;
|
|
1648
1661
|
declare const DialogProHeader: {
|
|
1649
1662
|
({ className, ...props }: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
1650
1663
|
displayName: string;
|
|
@@ -1653,8 +1666,8 @@ declare const DialogProFooter: {
|
|
|
1653
1666
|
({ className, ...props }: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
1654
1667
|
displayName: string;
|
|
1655
1668
|
};
|
|
1656
|
-
declare const DialogProTitle: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & React$1.RefAttributes<HTMLHeadingElement>, "ref"> & React$1.RefAttributes<
|
|
1657
|
-
declare const DialogProDescription: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & React$1.RefAttributes<HTMLParagraphElement>, "ref"> & React$1.RefAttributes<
|
|
1669
|
+
declare const DialogProTitle: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & React$1.RefAttributes<HTMLHeadingElement>, "ref"> & React$1.RefAttributes<never>>;
|
|
1670
|
+
declare const DialogProDescription: React$1.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & React$1.RefAttributes<HTMLParagraphElement>, "ref"> & React$1.RefAttributes<never>>;
|
|
1658
1671
|
|
|
1659
1672
|
declare const badgeVariants: (props?: ({
|
|
1660
1673
|
variant?: "default" | "success" | "warning" | "outline" | "secondary" | "destructive" | "pro" | null | undefined;
|
package/dist/index.mjs
CHANGED
|
@@ -52171,7 +52171,21 @@ function DataTable({
|
|
|
52171
52171
|
onRowExpandChange,
|
|
52172
52172
|
features = {},
|
|
52173
52173
|
theme = {},
|
|
52174
|
-
texts = {}
|
|
52174
|
+
texts = {},
|
|
52175
|
+
// Additional props
|
|
52176
|
+
enableSorting = true,
|
|
52177
|
+
enableFiltering = true,
|
|
52178
|
+
enablePagination = true,
|
|
52179
|
+
enableColumnVisibility = true,
|
|
52180
|
+
enableRowSelection,
|
|
52181
|
+
filterPlaceholder = "Search all columns...",
|
|
52182
|
+
defaultPageSize,
|
|
52183
|
+
manualPagination = false,
|
|
52184
|
+
pageCount,
|
|
52185
|
+
onPaginationChange,
|
|
52186
|
+
onSortingChange,
|
|
52187
|
+
onColumnFiltersChange,
|
|
52188
|
+
state: externalState
|
|
52175
52189
|
}) {
|
|
52176
52190
|
const { hasProAccess, isLoading } = useSubscription();
|
|
52177
52191
|
if (!isLoading && !hasProAccess) {
|
|
@@ -52195,11 +52209,12 @@ function DataTable({
|
|
|
52195
52209
|
const [isPaginationLoading, setIsPaginationLoading] = t__default.useState(false);
|
|
52196
52210
|
const [internalExpandedRows, setInternalExpandedRows] = t__default.useState(/* @__PURE__ */ new Set());
|
|
52197
52211
|
const expandedRows = controlledExpandedRows || internalExpandedRows;
|
|
52212
|
+
const actualPageSize = defaultPageSize || pageSize;
|
|
52198
52213
|
const table = useReactTable({
|
|
52199
52214
|
data,
|
|
52200
52215
|
columns,
|
|
52201
|
-
onSortingChange: setSorting,
|
|
52202
|
-
onColumnFiltersChange: setColumnFilters,
|
|
52216
|
+
onSortingChange: onSortingChange !== void 0 ? onSortingChange : setSorting,
|
|
52217
|
+
onColumnFiltersChange: onColumnFiltersChange !== void 0 ? onColumnFiltersChange : setColumnFilters,
|
|
52203
52218
|
getCoreRowModel: getCoreRowModel(),
|
|
52204
52219
|
getPaginationRowModel: getPaginationRowModel(),
|
|
52205
52220
|
getSortedRowModel: getSortedRowModel(),
|
|
@@ -52208,7 +52223,9 @@ function DataTable({
|
|
|
52208
52223
|
onRowSelectionChange: setRowSelection,
|
|
52209
52224
|
onGlobalFilterChange: setGlobalFilter,
|
|
52210
52225
|
globalFilterFn: "includesString",
|
|
52211
|
-
|
|
52226
|
+
manualPagination,
|
|
52227
|
+
pageCount,
|
|
52228
|
+
state: externalState || {
|
|
52212
52229
|
sorting,
|
|
52213
52230
|
columnFilters,
|
|
52214
52231
|
columnVisibility,
|
|
@@ -52217,7 +52234,7 @@ function DataTable({
|
|
|
52217
52234
|
},
|
|
52218
52235
|
initialState: {
|
|
52219
52236
|
pagination: {
|
|
52220
|
-
pageSize
|
|
52237
|
+
pageSize: actualPageSize
|
|
52221
52238
|
}
|
|
52222
52239
|
}
|
|
52223
52240
|
});
|
|
@@ -52243,15 +52260,15 @@ function DataTable({
|
|
|
52243
52260
|
onExport(dataToExport);
|
|
52244
52261
|
}
|
|
52245
52262
|
};
|
|
52246
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("moonui-pro-datatable-container
|
|
52247
|
-
/* @__PURE__ */ jsxs("div", { className: "moonui-pro-datatable-toolbar
|
|
52263
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("moonui-pro-datatable-container flex flex-col gap-4", className), children: [
|
|
52264
|
+
/* @__PURE__ */ jsxs("div", { className: "moonui-pro-datatable-toolbar flex items-center justify-between", children: [
|
|
52248
52265
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
52249
52266
|
searchable && /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
52250
52267
|
/* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
|
|
52251
52268
|
/* @__PURE__ */ jsx(
|
|
52252
52269
|
MoonUIInputPro,
|
|
52253
52270
|
{
|
|
52254
|
-
placeholder:
|
|
52271
|
+
placeholder: filterPlaceholder,
|
|
52255
52272
|
value: globalFilter,
|
|
52256
52273
|
onChange: (e) => setGlobalFilter(e.target.value),
|
|
52257
52274
|
className: "pl-8 w-64"
|
|
@@ -52274,7 +52291,7 @@ function DataTable({
|
|
|
52274
52291
|
] })
|
|
52275
52292
|
] })
|
|
52276
52293
|
] }),
|
|
52277
|
-
/* @__PURE__ */ jsx("div", { className: "moonui-pro-datatable-wrapper rounded-md border overflow-hidden", children: /* @__PURE__ */ jsxs("table", { className: "moonui-pro-datatable", style: { width: "100%" }, children: [
|
|
52294
|
+
/* @__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: [
|
|
52278
52295
|
/* @__PURE__ */ jsx("thead", { className: "moonui-data-table-header", children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx("tr", { className: "moonui-data-table-row border-b", children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx(
|
|
52279
52296
|
"th",
|
|
52280
52297
|
{
|
|
@@ -52356,7 +52373,7 @@ function DataTable({
|
|
|
52356
52373
|
},
|
|
52357
52374
|
"no-results"
|
|
52358
52375
|
) }) })
|
|
52359
|
-
] }) }),
|
|
52376
|
+
] }) }) }),
|
|
52360
52377
|
pagination && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-2", children: [
|
|
52361
52378
|
/* @__PURE__ */ jsx("div", { className: "flex-1 text-sm text-muted-foreground", children: selectable && table.getFilteredSelectedRowModel().rows.length > 0 && /* @__PURE__ */ jsxs("span", { children: [
|
|
52362
52379
|
table.getFilteredSelectedRowModel().rows.length,
|
|
@@ -52398,10 +52415,14 @@ function DataTable({
|
|
|
52398
52415
|
variant: "outline",
|
|
52399
52416
|
className: "hidden h-8 w-8 p-0 lg:flex",
|
|
52400
52417
|
onClick: async () => {
|
|
52401
|
-
|
|
52402
|
-
|
|
52403
|
-
|
|
52404
|
-
|
|
52418
|
+
if (onPaginationChange) {
|
|
52419
|
+
onPaginationChange({ pageIndex: 0, pageSize: table.getState().pagination.pageSize });
|
|
52420
|
+
} else {
|
|
52421
|
+
setIsPaginationLoading(true);
|
|
52422
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
52423
|
+
table.setPageIndex(0);
|
|
52424
|
+
setIsPaginationLoading(false);
|
|
52425
|
+
}
|
|
52405
52426
|
},
|
|
52406
52427
|
disabled: !table.getCanPreviousPage() || isPaginationLoading,
|
|
52407
52428
|
children: /* @__PURE__ */ jsx(ChevronsLeft, { className: "h-4 w-4" })
|
|
@@ -52413,10 +52434,15 @@ function DataTable({
|
|
|
52413
52434
|
variant: "outline",
|
|
52414
52435
|
className: "h-8 w-8 p-0",
|
|
52415
52436
|
onClick: async () => {
|
|
52416
|
-
|
|
52417
|
-
|
|
52418
|
-
|
|
52419
|
-
|
|
52437
|
+
if (onPaginationChange) {
|
|
52438
|
+
const currentIndex = table.getState().pagination.pageIndex;
|
|
52439
|
+
onPaginationChange({ pageIndex: currentIndex - 1, pageSize: table.getState().pagination.pageSize });
|
|
52440
|
+
} else {
|
|
52441
|
+
setIsPaginationLoading(true);
|
|
52442
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
52443
|
+
table.previousPage();
|
|
52444
|
+
setIsPaginationLoading(false);
|
|
52445
|
+
}
|
|
52420
52446
|
},
|
|
52421
52447
|
disabled: !table.getCanPreviousPage() || isPaginationLoading,
|
|
52422
52448
|
children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moontra/moonui-pro",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.4",
|
|
4
4
|
"description": "Premium React components for MoonUI - Advanced UI library with 50+ pro components including performance, interactive, and gesture components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"react-dom": ">=18.0.0 || ^19.0.0"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
+
"@moontra/moonui-pro": "^2.3.3",
|
|
78
79
|
"@radix-ui/react-accordion": "^1.2.11",
|
|
79
80
|
"@radix-ui/react-avatar": "^1.1.10",
|
|
80
81
|
"@radix-ui/react-checkbox": "^1.3.2",
|
|
@@ -94,7 +95,7 @@
|
|
|
94
95
|
"clsx": "^2.1.1",
|
|
95
96
|
"date-fns": "^3.6.0",
|
|
96
97
|
"framer-motion": "^11.11.17",
|
|
97
|
-
"lucide-react": "^0.
|
|
98
|
+
"lucide-react": "^0.525.0",
|
|
98
99
|
"react-dropzone": "^14.3.5",
|
|
99
100
|
"react-hook-form": "^7.53.2",
|
|
100
101
|
"react-intersection-observer": "^9.13.1",
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
SortingState,
|
|
13
13
|
ColumnFiltersState,
|
|
14
14
|
VisibilityState,
|
|
15
|
+
OnChangeFn,
|
|
15
16
|
} from '@tanstack/react-table'
|
|
16
17
|
import { Button } from '../ui/button'
|
|
17
18
|
import { Input } from '../ui/input'
|
|
@@ -53,6 +54,20 @@ interface DataTableProps<TData, TValue> {
|
|
|
53
54
|
renderSubComponent?: (props: { row: { original: TData; id: string } }) => React.ReactNode
|
|
54
55
|
expandedRows?: Set<string>
|
|
55
56
|
onRowExpandChange?: (expandedRows: Set<string>) => void
|
|
57
|
+
// Additional props for compatibility
|
|
58
|
+
enableSorting?: boolean
|
|
59
|
+
enableFiltering?: boolean
|
|
60
|
+
enablePagination?: boolean
|
|
61
|
+
enableColumnVisibility?: boolean
|
|
62
|
+
enableRowSelection?: boolean
|
|
63
|
+
filterPlaceholder?: string
|
|
64
|
+
defaultPageSize?: number
|
|
65
|
+
manualPagination?: boolean
|
|
66
|
+
pageCount?: number
|
|
67
|
+
onPaginationChange?: (updater: any) => void
|
|
68
|
+
onSortingChange?: OnChangeFn<SortingState>
|
|
69
|
+
onColumnFiltersChange?: OnChangeFn<ColumnFiltersState>
|
|
70
|
+
state?: any
|
|
56
71
|
features?: {
|
|
57
72
|
sorting?: boolean
|
|
58
73
|
filtering?: boolean
|
|
@@ -103,6 +118,20 @@ export function DataTable<TData, TValue>({
|
|
|
103
118
|
features = {},
|
|
104
119
|
theme = {},
|
|
105
120
|
texts = {},
|
|
121
|
+
// Additional props
|
|
122
|
+
enableSorting = true,
|
|
123
|
+
enableFiltering = true,
|
|
124
|
+
enablePagination = true,
|
|
125
|
+
enableColumnVisibility = true,
|
|
126
|
+
enableRowSelection,
|
|
127
|
+
filterPlaceholder = "Search all columns...",
|
|
128
|
+
defaultPageSize,
|
|
129
|
+
manualPagination = false,
|
|
130
|
+
pageCount,
|
|
131
|
+
onPaginationChange,
|
|
132
|
+
onSortingChange,
|
|
133
|
+
onColumnFiltersChange,
|
|
134
|
+
state: externalState,
|
|
106
135
|
}: DataTableProps<TData, TValue>) {
|
|
107
136
|
// Check if we're in docs mode or have pro access
|
|
108
137
|
const { hasProAccess, isLoading } = useSubscription()
|
|
@@ -151,11 +180,13 @@ export function DataTable<TData, TValue>({
|
|
|
151
180
|
(newExpanded: Set<string>) => onRowExpandChange(newExpanded) :
|
|
152
181
|
setInternalExpandedRows
|
|
153
182
|
|
|
183
|
+
const actualPageSize = defaultPageSize || pageSize
|
|
184
|
+
|
|
154
185
|
const table = useReactTable({
|
|
155
186
|
data,
|
|
156
187
|
columns,
|
|
157
|
-
onSortingChange: setSorting,
|
|
158
|
-
onColumnFiltersChange: setColumnFilters,
|
|
188
|
+
onSortingChange: onSortingChange !== undefined ? onSortingChange : setSorting,
|
|
189
|
+
onColumnFiltersChange: onColumnFiltersChange !== undefined ? onColumnFiltersChange : setColumnFilters,
|
|
159
190
|
getCoreRowModel: getCoreRowModel(),
|
|
160
191
|
getPaginationRowModel: getPaginationRowModel(),
|
|
161
192
|
getSortedRowModel: getSortedRowModel(),
|
|
@@ -164,7 +195,9 @@ export function DataTable<TData, TValue>({
|
|
|
164
195
|
onRowSelectionChange: setRowSelection,
|
|
165
196
|
onGlobalFilterChange: setGlobalFilter,
|
|
166
197
|
globalFilterFn: 'includesString',
|
|
167
|
-
|
|
198
|
+
manualPagination,
|
|
199
|
+
pageCount,
|
|
200
|
+
state: externalState || {
|
|
168
201
|
sorting,
|
|
169
202
|
columnFilters,
|
|
170
203
|
columnVisibility,
|
|
@@ -173,7 +206,7 @@ export function DataTable<TData, TValue>({
|
|
|
173
206
|
},
|
|
174
207
|
initialState: {
|
|
175
208
|
pagination: {
|
|
176
|
-
pageSize,
|
|
209
|
+
pageSize: actualPageSize,
|
|
177
210
|
},
|
|
178
211
|
},
|
|
179
212
|
})
|
|
@@ -207,15 +240,15 @@ export function DataTable<TData, TValue>({
|
|
|
207
240
|
}
|
|
208
241
|
|
|
209
242
|
return (
|
|
210
|
-
<div className={cn("moonui-pro-datatable-container
|
|
243
|
+
<div className={cn("moonui-pro-datatable-container flex flex-col gap-4", className)}>
|
|
211
244
|
{/* Toolbar */}
|
|
212
|
-
<div className="moonui-pro-datatable-toolbar
|
|
245
|
+
<div className="moonui-pro-datatable-toolbar flex items-center justify-between">
|
|
213
246
|
<div className="flex items-center space-x-2">
|
|
214
247
|
{searchable && (
|
|
215
248
|
<div className="relative">
|
|
216
249
|
<Search className="absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" />
|
|
217
250
|
<Input
|
|
218
|
-
placeholder=
|
|
251
|
+
placeholder={filterPlaceholder}
|
|
219
252
|
value={globalFilter}
|
|
220
253
|
onChange={(e) => setGlobalFilter(e.target.value)}
|
|
221
254
|
className="pl-8 w-64"
|
|
@@ -247,8 +280,9 @@ export function DataTable<TData, TValue>({
|
|
|
247
280
|
</div>
|
|
248
281
|
|
|
249
282
|
{/* Table */}
|
|
250
|
-
<div className="moonui-pro-datatable-wrapper rounded-md border overflow-hidden">
|
|
251
|
-
<
|
|
283
|
+
<div className="moonui-pro-datatable-wrapper rounded-md border overflow-hidden" style={{ contain: 'layout style' }}>
|
|
284
|
+
<div style={{ overflowX: 'auto' }}>
|
|
285
|
+
<table className="moonui-pro-datatable" style={{ width: '100%', tableLayout: 'auto' }}>
|
|
252
286
|
<thead className="moonui-data-table-header">
|
|
253
287
|
{table.getHeaderGroups().map((headerGroup) => (
|
|
254
288
|
<tr key={headerGroup.id} className="moonui-data-table-row border-b">
|
|
@@ -366,6 +400,7 @@ export function DataTable<TData, TValue>({
|
|
|
366
400
|
</AnimatePresence>
|
|
367
401
|
</tbody>
|
|
368
402
|
</table>
|
|
403
|
+
</div>
|
|
369
404
|
</div>
|
|
370
405
|
|
|
371
406
|
{/* Pagination */}
|
|
@@ -409,10 +444,14 @@ export function DataTable<TData, TValue>({
|
|
|
409
444
|
variant="outline"
|
|
410
445
|
className="hidden h-8 w-8 p-0 lg:flex"
|
|
411
446
|
onClick={async () => {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
447
|
+
if (onPaginationChange) {
|
|
448
|
+
onPaginationChange({ pageIndex: 0, pageSize: table.getState().pagination.pageSize })
|
|
449
|
+
} else {
|
|
450
|
+
setIsPaginationLoading(true)
|
|
451
|
+
await new Promise(resolve => setTimeout(resolve, 300))
|
|
452
|
+
table.setPageIndex(0)
|
|
453
|
+
setIsPaginationLoading(false)
|
|
454
|
+
}
|
|
416
455
|
}}
|
|
417
456
|
disabled={!table.getCanPreviousPage() || isPaginationLoading}
|
|
418
457
|
>
|
|
@@ -422,10 +461,15 @@ export function DataTable<TData, TValue>({
|
|
|
422
461
|
variant="outline"
|
|
423
462
|
className="h-8 w-8 p-0"
|
|
424
463
|
onClick={async () => {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
464
|
+
if (onPaginationChange) {
|
|
465
|
+
const currentIndex = table.getState().pagination.pageIndex
|
|
466
|
+
onPaginationChange({ pageIndex: currentIndex - 1, pageSize: table.getState().pagination.pageSize })
|
|
467
|
+
} else {
|
|
468
|
+
setIsPaginationLoading(true)
|
|
469
|
+
await new Promise(resolve => setTimeout(resolve, 300))
|
|
470
|
+
table.previousPage()
|
|
471
|
+
setIsPaginationLoading(false)
|
|
472
|
+
}
|
|
429
473
|
}}
|
|
430
474
|
disabled={!table.getCanPreviousPage() || isPaginationLoading}
|
|
431
475
|
>
|