@moontra/moonui-pro 2.4.1 → 2.4.3

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
@@ -1617,7 +1617,7 @@ interface DataTableProps<TData, TValue> {
1617
1617
  filterButton?: string;
1618
1618
  };
1619
1619
  }
1620
- declare function DataTable<TData, TValue>({ columns, data, searchable, filterable, exportable, selectable, pagination, pageSize, className, onRowSelect, onExport, enableExpandable, renderSubComponent, expandedRows: controlledExpandedRows, onRowExpandChange, bulkActions, 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;
1620
+ declare function DataTable<TData, TValue>({ columns: originalColumns, data, searchable, filterable, exportable, selectable, pagination, pageSize, className, onRowSelect, onExport, enableExpandable, renderSubComponent, expandedRows: controlledExpandedRows, onRowExpandChange, bulkActions, 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;
1621
1621
  /**
1622
1622
  * Helper function to create an expandable column
1623
1623
  * @param expandedRows - Set of expanded row IDs
package/dist/index.mjs CHANGED
@@ -53043,7 +53043,7 @@ function FilterConditionRow({
53043
53043
  ] });
53044
53044
  }
53045
53045
  function DataTable({
53046
- columns,
53046
+ columns: originalColumns,
53047
53047
  data,
53048
53048
  searchable = true,
53049
53049
  filterable = true,
@@ -53077,6 +53077,12 @@ function DataTable({
53077
53077
  onColumnFiltersChange,
53078
53078
  state: externalState
53079
53079
  }) {
53080
+ const columns = t__default.useMemo(() => {
53081
+ return originalColumns.map((col) => ({
53082
+ ...col,
53083
+ enableHiding: col.enableHiding !== false
53084
+ }));
53085
+ }, [originalColumns]);
53080
53086
  const { hasProAccess, isLoading } = useSubscription();
53081
53087
  if (!isLoading && !hasProAccess) {
53082
53088
  return /* @__PURE__ */ jsx(MoonUICardPro, { className: cn("w-full", className), children: /* @__PURE__ */ jsx(MoonUICardContentPro, { className: "py-12 text-center", children: /* @__PURE__ */ jsxs("div", { className: "max-w-md mx-auto space-y-4", children: [
@@ -53117,6 +53123,9 @@ function DataTable({
53117
53123
  globalFilterFn: "includesString",
53118
53124
  manualPagination,
53119
53125
  pageCount,
53126
+ enableColumnFilters: true,
53127
+ enableSorting: true,
53128
+ enableHiding: true,
53120
53129
  state: externalState || {
53121
53130
  sorting,
53122
53131
  columnFilters,
@@ -53256,27 +53265,31 @@ function DataTable({
53256
53265
  ] })
53257
53266
  ] }),
53258
53267
  /* @__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: [
53259
- /* @__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(
53260
- "th",
53261
- {
53262
- className: "moonui-data-table-th h-12 px-4 text-left align-middle font-medium text-muted-foreground",
53263
- children: header.isPlaceholder ? null : /* @__PURE__ */ jsxs(
53264
- "div",
53265
- {
53266
- className: cn(
53267
- "flex items-center space-x-2",
53268
- header.column.getCanSort() && "cursor-pointer select-none"
53269
- ),
53270
- onClick: header.column.getToggleSortingHandler(),
53271
- children: [
53272
- flexRender(header.column.columnDef.header, header.getContext()),
53273
- 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" }) }) })
53274
- ]
53275
- }
53276
- )
53277
- },
53278
- header.id
53279
- )) }, headerGroup.id)) }),
53268
+ /* @__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) => {
53269
+ if (!header.column.getIsVisible())
53270
+ return null;
53271
+ return /* @__PURE__ */ jsx(
53272
+ "th",
53273
+ {
53274
+ className: "moonui-data-table-th h-12 px-4 text-left align-middle font-medium text-muted-foreground",
53275
+ children: header.isPlaceholder ? null : /* @__PURE__ */ jsxs(
53276
+ "div",
53277
+ {
53278
+ className: cn(
53279
+ "flex items-center space-x-2",
53280
+ header.column.getCanSort() && "cursor-pointer select-none"
53281
+ ),
53282
+ onClick: header.column.getToggleSortingHandler(),
53283
+ children: [
53284
+ flexRender(header.column.columnDef.header, header.getContext()),
53285
+ 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" }) }) })
53286
+ ]
53287
+ }
53288
+ )
53289
+ },
53290
+ header.id
53291
+ );
53292
+ }) }, headerGroup.id)) }),
53280
53293
  /* @__PURE__ */ jsx("tbody", { className: "moonui-data-table-body", children: isPaginationLoading ? /* @__PURE__ */ jsx(
53281
53294
  motion.tr,
53282
53295
  {
@@ -53284,7 +53297,7 @@ function DataTable({
53284
53297
  animate: { opacity: 1 },
53285
53298
  exit: { opacity: 0 },
53286
53299
  transition: { duration: 0.2 },
53287
- 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: [
53300
+ children: /* @__PURE__ */ jsx("td", { colSpan: table.getVisibleLeafColumns().length, className: "h-24 text-center", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center space-x-2", children: [
53288
53301
  /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) }),
53289
53302
  /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: "Loading..." })
53290
53303
  ] }) })
@@ -53311,7 +53324,7 @@ function DataTable({
53311
53324
  animate: { opacity: 1 },
53312
53325
  exit: { opacity: 0 },
53313
53326
  transition: { duration: 0.2 },
53314
- children: /* @__PURE__ */ jsx("td", { colSpan: columns.length, className: "h-24 text-center", children: "No results found." })
53327
+ children: /* @__PURE__ */ jsx("td", { colSpan: table.getVisibleLeafColumns().length, className: "h-24 text-center", children: "No results found." })
53315
53328
  },
53316
53329
  "no-results"
53317
53330
  ) })
@@ -53500,10 +53513,14 @@ var TableRow2 = t__default.memo(({
53500
53513
  row.getIsSelected() && "bg-muted",
53501
53514
  isExpanded && "border-b-0"
53502
53515
  ),
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))
53516
+ children: row.getVisibleCells().map((cell) => {
53517
+ if (!cell.column.getIsVisible())
53518
+ return null;
53519
+ return /* @__PURE__ */ jsx("td", { className: "moonui-data-table-td p-4 align-middle", children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id);
53520
+ })
53504
53521
  }
53505
53522
  ),
53506
- isExpanded && renderSubComponent && /* @__PURE__ */ jsx("tr", { className: "border-b", children: /* @__PURE__ */ jsx("td", { colSpan: columns.length, className: "p-0 overflow-hidden", children: /* @__PURE__ */ jsx(
53523
+ isExpanded && renderSubComponent && /* @__PURE__ */ jsx("tr", { className: "border-b", children: /* @__PURE__ */ jsx("td", { colSpan: row.getVisibleCells().filter((cell) => cell.column.getIsVisible()).length, className: "p-0 overflow-hidden", children: /* @__PURE__ */ jsx(
53507
53524
  "div",
53508
53525
  {
53509
53526
  className: "transition-all duration-300 ease-out",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.4.1",
3
+ "version": "2.4.3",
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",
@@ -119,7 +119,7 @@ interface DataTableProps<TData, TValue> {
119
119
  }
120
120
 
121
121
  export function DataTable<TData, TValue>({
122
- columns,
122
+ columns: originalColumns,
123
123
  data,
124
124
  searchable = true,
125
125
  filterable = true,
@@ -153,6 +153,13 @@ export function DataTable<TData, TValue>({
153
153
  onColumnFiltersChange,
154
154
  state: externalState,
155
155
  }: DataTableProps<TData, TValue>) {
156
+ // Process columns to ensure they can be hidden
157
+ const columns = React.useMemo(() => {
158
+ return originalColumns.map(col => ({
159
+ ...col,
160
+ enableHiding: col.enableHiding !== false,
161
+ }))
162
+ }, [originalColumns])
156
163
  // Check if we're in docs mode or have pro access
157
164
  const { hasProAccess, isLoading } = useSubscription()
158
165
 
@@ -221,6 +228,9 @@ export function DataTable<TData, TValue>({
221
228
  globalFilterFn: 'includesString',
222
229
  manualPagination,
223
230
  pageCount,
231
+ enableColumnFilters: true,
232
+ enableSorting: true,
233
+ enableHiding: true,
224
234
  state: externalState || {
225
235
  sorting,
226
236
  columnFilters,
@@ -411,35 +421,40 @@ export function DataTable<TData, TValue>({
411
421
  <thead className="moonui-data-table-header">
412
422
  {table.getHeaderGroups().map((headerGroup) => (
413
423
  <tr key={headerGroup.id} className="moonui-data-table-row border-b">
414
- {headerGroup.headers.map((header) => (
415
- <th
416
- key={header.id}
417
- className="moonui-data-table-th h-12 px-4 text-left align-middle font-medium text-muted-foreground"
418
- >
419
- {header.isPlaceholder ? null : (
420
- <div
421
- className={cn(
422
- "flex items-center space-x-2",
423
- header.column.getCanSort() && "cursor-pointer select-none"
424
- )}
425
- onClick={header.column.getToggleSortingHandler()}
426
- >
427
- {flexRender(header.column.columnDef.header, header.getContext())}
428
- {header.column.getCanSort() && (
429
- <div className="ml-2">
430
- {header.column.getIsSorted() === 'asc' ? (
431
- <span suppressHydrationWarning><ArrowUp className="h-4 w-4" /></span>
432
- ) : header.column.getIsSorted() === 'desc' ? (
433
- <span suppressHydrationWarning><ArrowDown className="h-4 w-4" /></span>
434
- ) : (
435
- <span suppressHydrationWarning><ArrowUpDown className="h-4 w-4" /></span>
436
- )}
437
- </div>
438
- )}
439
- </div>
440
- )}
441
- </th>
442
- ))}
424
+ {headerGroup.headers.map((header) => {
425
+ // Column visibility kontrolü
426
+ if (!header.column.getIsVisible()) return null;
427
+
428
+ return (
429
+ <th
430
+ key={header.id}
431
+ className="moonui-data-table-th h-12 px-4 text-left align-middle font-medium text-muted-foreground"
432
+ >
433
+ {header.isPlaceholder ? null : (
434
+ <div
435
+ className={cn(
436
+ "flex items-center space-x-2",
437
+ header.column.getCanSort() && "cursor-pointer select-none"
438
+ )}
439
+ onClick={header.column.getToggleSortingHandler()}
440
+ >
441
+ {flexRender(header.column.columnDef.header, header.getContext())}
442
+ {header.column.getCanSort() && (
443
+ <div className="ml-2">
444
+ {header.column.getIsSorted() === 'asc' ? (
445
+ <span suppressHydrationWarning><ArrowUp className="h-4 w-4" /></span>
446
+ ) : header.column.getIsSorted() === 'desc' ? (
447
+ <span suppressHydrationWarning><ArrowDown className="h-4 w-4" /></span>
448
+ ) : (
449
+ <span suppressHydrationWarning><ArrowUpDown className="h-4 w-4" /></span>
450
+ )}
451
+ </div>
452
+ )}
453
+ </div>
454
+ )}
455
+ </th>
456
+ );
457
+ })}
443
458
  </tr>
444
459
  ))}
445
460
  </thead>
@@ -452,7 +467,7 @@ export function DataTable<TData, TValue>({
452
467
  exit={{ opacity: 0 }}
453
468
  transition={{ duration: 0.2 }}
454
469
  >
455
- <td colSpan={columns.length} className="h-24 text-center">
470
+ <td colSpan={table.getVisibleLeafColumns().length} className="h-24 text-center">
456
471
  <div className="flex items-center justify-center space-x-2">
457
472
  <span suppressHydrationWarning><Loader2 className="h-4 w-4 animate-spin" /></span>
458
473
  <span className="text-sm text-muted-foreground">Loading...</span>
@@ -485,7 +500,7 @@ export function DataTable<TData, TValue>({
485
500
  exit={{ opacity: 0 }}
486
501
  transition={{ duration: 0.2 }}
487
502
  >
488
- <td colSpan={columns.length} className="h-24 text-center">
503
+ <td colSpan={table.getVisibleLeafColumns().length} className="h-24 text-center">
489
504
  No results found.
490
505
  </td>
491
506
  </motion.tr>
@@ -714,16 +729,21 @@ const TableRow = React.memo(({
714
729
  isExpanded && "border-b-0"
715
730
  )}
716
731
  >
717
- {row.getVisibleCells().map((cell) => (
718
- <td key={cell.id} className="moonui-data-table-td p-4 align-middle">
719
- {flexRender(cell.column.columnDef.cell, cell.getContext())}
720
- </td>
721
- ))}
732
+ {row.getVisibleCells().map((cell) => {
733
+ // Column visibility kontrolü
734
+ if (!cell.column.getIsVisible()) return null;
735
+
736
+ return (
737
+ <td key={cell.id} className="moonui-data-table-td p-4 align-middle">
738
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
739
+ </td>
740
+ );
741
+ })}
722
742
  </tr>
723
743
 
724
744
  {isExpanded && renderSubComponent && (
725
745
  <tr className="border-b">
726
- <td colSpan={columns.length} className="p-0 overflow-hidden">
746
+ <td colSpan={row.getVisibleCells().filter(cell => cell.column.getIsVisible()).length} className="p-0 overflow-hidden">
727
747
  <div
728
748
  className="transition-all duration-300 ease-out"
729
749
  style={{