@moontra/moonui-pro 2.3.3 → 2.3.5

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 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;
@@ -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
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
- state: {
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", className), style: { display: "flex", flexDirection: "column", gap: "1rem" }, children: [
52247
- /* @__PURE__ */ jsxs("div", { className: "moonui-pro-datatable-toolbar", style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
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
- /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
52267
+ /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__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: "Search all columns...",
52271
+ placeholder: filterPlaceholder,
52255
52272
  value: globalFilter,
52256
52273
  onChange: (e) => setGlobalFilter(e.target.value),
52257
52274
  className: "pl-8 w-64"
@@ -52259,22 +52276,22 @@ function DataTable({
52259
52276
  )
52260
52277
  ] }),
52261
52278
  filterable && /* @__PURE__ */ jsxs(MoonUIButtonPro, { variant: "outline", size: "sm", children: [
52262
- /* @__PURE__ */ jsx(Filter, { className: "mr-2 h-4 w-4" }),
52279
+ /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Filter, { className: "mr-2 h-4 w-4" }) }),
52263
52280
  "Filters"
52264
52281
  ] })
52265
52282
  ] }),
52266
52283
  /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
52267
52284
  exportable && /* @__PURE__ */ jsxs(MoonUIButtonPro, { variant: "outline", size: "sm", onClick: handleExport, children: [
52268
- /* @__PURE__ */ jsx(Download, { className: "mr-2 h-4 w-4" }),
52285
+ /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Download, { className: "mr-2 h-4 w-4" }) }),
52269
52286
  "Export"
52270
52287
  ] }),
52271
52288
  /* @__PURE__ */ jsxs(MoonUIButtonPro, { variant: "outline", size: "sm", children: [
52272
- /* @__PURE__ */ jsx(Settings, { className: "mr-2 h-4 w-4" }),
52289
+ /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Settings, { className: "mr-2 h-4 w-4" }) }),
52273
52290
  "Columns"
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
  {
@@ -52289,7 +52306,7 @@ function DataTable({
52289
52306
  onClick: header.column.getToggleSortingHandler(),
52290
52307
  children: [
52291
52308
  flexRender(header.column.columnDef.header, header.getContext()),
52292
- header.column.getCanSort() && /* @__PURE__ */ jsx("div", { className: "ml-2", children: header.column.getIsSorted() === "asc" ? /* @__PURE__ */ jsx(ArrowUp, { className: "h-4 w-4" }) : header.column.getIsSorted() === "desc" ? /* @__PURE__ */ jsx(ArrowDown, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(ArrowUpDown, { className: "h-4 w-4" }) })
52309
+ header.column.getCanSort() && /* @__PURE__ */ jsx("div", { className: "ml-2", children: header.column.getIsSorted() === "asc" ? /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ArrowUp, { className: "h-4 w-4" }) }) : header.column.getIsSorted() === "desc" ? /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ArrowDown, { className: "h-4 w-4" }) }) : /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ArrowUpDown, { className: "h-4 w-4" }) }) })
52293
52310
  ]
52294
52311
  }
52295
52312
  )
@@ -52304,7 +52321,7 @@ function DataTable({
52304
52321
  exit: { opacity: 0 },
52305
52322
  transition: { duration: 0.2 },
52306
52323
  children: /* @__PURE__ */ jsx("td", { colSpan: columns.length, className: "h-24 text-center", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center space-x-2", children: [
52307
- /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }),
52324
+ /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) }),
52308
52325
  /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: "Loading..." })
52309
52326
  ] }) })
52310
52327
  },
@@ -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,13 +52415,17 @@ function DataTable({
52398
52415
  variant: "outline",
52399
52416
  className: "hidden h-8 w-8 p-0 lg:flex",
52400
52417
  onClick: async () => {
52401
- setIsPaginationLoading(true);
52402
- await new Promise((resolve) => setTimeout(resolve, 300));
52403
- table.setPageIndex(0);
52404
- setIsPaginationLoading(false);
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
- children: /* @__PURE__ */ jsx(ChevronsLeft, { className: "h-4 w-4" })
52428
+ children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronsLeft, { className: "h-4 w-4" }) })
52408
52429
  }
52409
52430
  ),
52410
52431
  /* @__PURE__ */ jsx(
@@ -52413,13 +52434,18 @@ function DataTable({
52413
52434
  variant: "outline",
52414
52435
  className: "h-8 w-8 p-0",
52415
52436
  onClick: async () => {
52416
- setIsPaginationLoading(true);
52417
- await new Promise((resolve) => setTimeout(resolve, 300));
52418
- table.previousPage();
52419
- setIsPaginationLoading(false);
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
- children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" })
52448
+ children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" }) })
52423
52449
  }
52424
52450
  ),
52425
52451
  /* @__PURE__ */ jsx(
@@ -52434,7 +52460,7 @@ function DataTable({
52434
52460
  setIsPaginationLoading(false);
52435
52461
  },
52436
52462
  disabled: !table.getCanNextPage() || isPaginationLoading,
52437
- children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
52463
+ children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" }) })
52438
52464
  }
52439
52465
  ),
52440
52466
  /* @__PURE__ */ jsx(
@@ -52449,7 +52475,7 @@ function DataTable({
52449
52475
  setIsPaginationLoading(false);
52450
52476
  },
52451
52477
  disabled: !table.getCanNextPage() || isPaginationLoading,
52452
- children: /* @__PURE__ */ jsx(ChevronsRight, { className: "h-4 w-4" })
52478
+ children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronsRight, { className: "h-4 w-4" }) })
52453
52479
  }
52454
52480
  )
52455
52481
  ] })
@@ -52474,7 +52500,7 @@ function getExpandableColumn(expandedRows, onToggle) {
52474
52500
  },
52475
52501
  className: "p-2 hover:bg-muted rounded-md transition-colors",
52476
52502
  "aria-label": isExpanded ? "Collapse row" : "Expand row",
52477
- children: isExpanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 text-muted-foreground" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 text-muted-foreground" })
52503
+ children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: isExpanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 text-muted-foreground" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 text-muted-foreground" }) })
52478
52504
  }
52479
52505
  );
52480
52506
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.3.3",
3
+ "version": "2.3.5",
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.4",
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",
@@ -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
- state: {
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,17 @@ export function DataTable<TData, TValue>({
207
240
  }
208
241
 
209
242
  return (
210
- <div className={cn("moonui-pro-datatable-container", className)} style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
243
+ <div className={cn("moonui-pro-datatable-container flex flex-col gap-4", className)}>
211
244
  {/* Toolbar */}
212
- <div className="moonui-pro-datatable-toolbar" style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
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
- <Search className="absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" />
249
+ <span suppressHydrationWarning>
250
+ <Search className="absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" />
251
+ </span>
217
252
  <Input
218
- placeholder="Search all columns..."
253
+ placeholder={filterPlaceholder}
219
254
  value={globalFilter}
220
255
  onChange={(e) => setGlobalFilter(e.target.value)}
221
256
  className="pl-8 w-64"
@@ -225,7 +260,7 @@ export function DataTable<TData, TValue>({
225
260
 
226
261
  {filterable && (
227
262
  <Button variant="outline" size="sm">
228
- <Filter className="mr-2 h-4 w-4" />
263
+ <span suppressHydrationWarning><Filter className="mr-2 h-4 w-4" /></span>
229
264
  Filters
230
265
  </Button>
231
266
  )}
@@ -234,21 +269,22 @@ export function DataTable<TData, TValue>({
234
269
  <div className="flex items-center space-x-2">
235
270
  {exportable && (
236
271
  <Button variant="outline" size="sm" onClick={handleExport}>
237
- <Download className="mr-2 h-4 w-4" />
272
+ <span suppressHydrationWarning><Download className="mr-2 h-4 w-4" /></span>
238
273
  Export
239
274
  </Button>
240
275
  )}
241
276
 
242
277
  <Button variant="outline" size="sm">
243
- <Settings className="mr-2 h-4 w-4" />
278
+ <span suppressHydrationWarning><Settings className="mr-2 h-4 w-4" /></span>
244
279
  Columns
245
280
  </Button>
246
281
  </div>
247
282
  </div>
248
283
 
249
284
  {/* Table */}
250
- <div className="moonui-pro-datatable-wrapper rounded-md border overflow-hidden">
251
- <table className="moonui-pro-datatable" style={{ width: '100%' }}>
285
+ <div className="moonui-pro-datatable-wrapper rounded-md border overflow-hidden" style={{ contain: 'layout style' }}>
286
+ <div style={{ overflowX: 'auto' }}>
287
+ <table className="moonui-pro-datatable" style={{ width: '100%', tableLayout: 'auto' }}>
252
288
  <thead className="moonui-data-table-header">
253
289
  {table.getHeaderGroups().map((headerGroup) => (
254
290
  <tr key={headerGroup.id} className="moonui-data-table-row border-b">
@@ -269,11 +305,11 @@ export function DataTable<TData, TValue>({
269
305
  {header.column.getCanSort() && (
270
306
  <div className="ml-2">
271
307
  {header.column.getIsSorted() === 'asc' ? (
272
- <ArrowUp className="h-4 w-4" />
308
+ <span suppressHydrationWarning><ArrowUp className="h-4 w-4" /></span>
273
309
  ) : header.column.getIsSorted() === 'desc' ? (
274
- <ArrowDown className="h-4 w-4" />
310
+ <span suppressHydrationWarning><ArrowDown className="h-4 w-4" /></span>
275
311
  ) : (
276
- <ArrowUpDown className="h-4 w-4" />
312
+ <span suppressHydrationWarning><ArrowUpDown className="h-4 w-4" /></span>
277
313
  )}
278
314
  </div>
279
315
  )}
@@ -296,7 +332,7 @@ export function DataTable<TData, TValue>({
296
332
  >
297
333
  <td colSpan={columns.length} className="h-24 text-center">
298
334
  <div className="flex items-center justify-center space-x-2">
299
- <Loader2 className="h-4 w-4 animate-spin" />
335
+ <span suppressHydrationWarning><Loader2 className="h-4 w-4 animate-spin" /></span>
300
336
  <span className="text-sm text-muted-foreground">Loading...</span>
301
337
  </div>
302
338
  </td>
@@ -366,6 +402,7 @@ export function DataTable<TData, TValue>({
366
402
  </AnimatePresence>
367
403
  </tbody>
368
404
  </table>
405
+ </div>
369
406
  </div>
370
407
 
371
408
  {/* Pagination */}
@@ -409,27 +446,36 @@ export function DataTable<TData, TValue>({
409
446
  variant="outline"
410
447
  className="hidden h-8 w-8 p-0 lg:flex"
411
448
  onClick={async () => {
412
- setIsPaginationLoading(true)
413
- await new Promise(resolve => setTimeout(resolve, 300))
414
- table.setPageIndex(0)
415
- setIsPaginationLoading(false)
449
+ if (onPaginationChange) {
450
+ onPaginationChange({ pageIndex: 0, pageSize: table.getState().pagination.pageSize })
451
+ } else {
452
+ setIsPaginationLoading(true)
453
+ await new Promise(resolve => setTimeout(resolve, 300))
454
+ table.setPageIndex(0)
455
+ setIsPaginationLoading(false)
456
+ }
416
457
  }}
417
458
  disabled={!table.getCanPreviousPage() || isPaginationLoading}
418
459
  >
419
- <ChevronsLeft className="h-4 w-4" />
460
+ <span suppressHydrationWarning><ChevronsLeft className="h-4 w-4" /></span>
420
461
  </Button>
421
462
  <Button
422
463
  variant="outline"
423
464
  className="h-8 w-8 p-0"
424
465
  onClick={async () => {
425
- setIsPaginationLoading(true)
426
- await new Promise(resolve => setTimeout(resolve, 300))
427
- table.previousPage()
428
- setIsPaginationLoading(false)
466
+ if (onPaginationChange) {
467
+ const currentIndex = table.getState().pagination.pageIndex
468
+ onPaginationChange({ pageIndex: currentIndex - 1, pageSize: table.getState().pagination.pageSize })
469
+ } else {
470
+ setIsPaginationLoading(true)
471
+ await new Promise(resolve => setTimeout(resolve, 300))
472
+ table.previousPage()
473
+ setIsPaginationLoading(false)
474
+ }
429
475
  }}
430
476
  disabled={!table.getCanPreviousPage() || isPaginationLoading}
431
477
  >
432
- <ChevronLeft className="h-4 w-4" />
478
+ <span suppressHydrationWarning><ChevronLeft className="h-4 w-4" /></span>
433
479
  </Button>
434
480
  <Button
435
481
  variant="outline"
@@ -442,7 +488,7 @@ export function DataTable<TData, TValue>({
442
488
  }}
443
489
  disabled={!table.getCanNextPage() || isPaginationLoading}
444
490
  >
445
- <ChevronRight className="h-4 w-4" />
491
+ <span suppressHydrationWarning><ChevronRight className="h-4 w-4" /></span>
446
492
  </Button>
447
493
  <Button
448
494
  variant="outline"
@@ -455,7 +501,7 @@ export function DataTable<TData, TValue>({
455
501
  }}
456
502
  disabled={!table.getCanNextPage() || isPaginationLoading}
457
503
  >
458
- <ChevronsRight className="h-4 w-4" />
504
+ <span suppressHydrationWarning><ChevronsRight className="h-4 w-4" /></span>
459
505
  </Button>
460
506
  </div>
461
507
  </div>
@@ -492,11 +538,13 @@ export function getExpandableColumn<TData>(
492
538
  className="p-2 hover:bg-muted rounded-md transition-colors"
493
539
  aria-label={isExpanded ? "Collapse row" : "Expand row"}
494
540
  >
495
- {isExpanded ? (
496
- <ChevronDown className="h-4 w-4 text-muted-foreground" />
497
- ) : (
498
- <ChevronRight className="h-4 w-4 text-muted-foreground" />
499
- )}
541
+ <span suppressHydrationWarning>
542
+ {isExpanded ? (
543
+ <ChevronDown className="h-4 w-4 text-muted-foreground" />
544
+ ) : (
545
+ <ChevronRight className="h-4 w-4 text-muted-foreground" />
546
+ )}
547
+ </span>
500
548
  </button>
501
549
  );
502
550
  },