@moontra/moonui-pro 2.27.2 → 2.27.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.mjs CHANGED
@@ -72964,7 +72964,7 @@ function DataTableBulkActions({
72964
72964
  /* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-2", className), children: [
72965
72965
  /* @__PURE__ */ jsxs(MoonUIBadgePro, { variant: "secondary", className: "gap-1", children: [
72966
72966
  /* @__PURE__ */ jsx("span", { className: "font-semibold", children: selectedCount }),
72967
- /* @__PURE__ */ jsx("span", { children: "selected" })
72967
+ /* @__PURE__ */ jsx("span", { children: " Selected" })
72968
72968
  ] }),
72969
72969
  /* @__PURE__ */ jsxs(MoonUIDropdownMenuPro, { children: [
72970
72970
  /* @__PURE__ */ jsx(MoonUIDropdownMenuTriggerPro, { asChild: true, children: /* @__PURE__ */ jsx(
@@ -73975,7 +73975,9 @@ function DataTable({
73975
73975
  const createSortingHandler = (columnId) => {
73976
73976
  return () => {
73977
73977
  const currentSorting = externalState?.sorting ?? sorting;
73978
- const currentSort = currentSorting.find((s) => s.id === columnId);
73978
+ const currentSort = currentSorting.find(
73979
+ (s) => s.id === columnId
73980
+ );
73979
73981
  let newSorting = [];
73980
73982
  if (!currentSort) {
73981
73983
  newSorting = [{ id: columnId, desc: false }];
@@ -73991,15 +73993,20 @@ function DataTable({
73991
73993
  };
73992
73994
  };
73993
73995
  const tableRef = t__default.useRef(null);
73994
- const handleRowSelectionChange = t__default.useCallback((updater) => {
73995
- const newSelection = typeof updater === "function" ? updater(rowSelection) : updater;
73996
- setRowSelection(newSelection);
73997
- if (onRowSelect && tableRef.current) {
73998
- const selectedRowIds = Object.keys(newSelection).filter((key) => newSelection[key]);
73999
- const selectedRows = tableRef.current.getRowModel().rows.filter((row) => selectedRowIds.includes(row.id)).map((row) => row.original);
74000
- onRowSelect(selectedRows);
74001
- }
74002
- }, [rowSelection, onRowSelect]);
73996
+ const handleRowSelectionChange = t__default.useCallback(
73997
+ (updater) => {
73998
+ const newSelection = typeof updater === "function" ? updater(rowSelection) : updater;
73999
+ setRowSelection(newSelection);
74000
+ if (onRowSelect && tableRef.current) {
74001
+ const selectedRowIds = Object.keys(newSelection).filter(
74002
+ (key) => newSelection[key]
74003
+ );
74004
+ const selectedRows = tableRef.current.getRowModel().rows.filter((row) => selectedRowIds.includes(row.id)).map((row) => row.original);
74005
+ onRowSelect(selectedRows);
74006
+ }
74007
+ },
74008
+ [rowSelection, onRowSelect]
74009
+ );
74003
74010
  const processedColumns = t__default.useMemo(() => {
74004
74011
  let cols = columns.map((col) => {
74005
74012
  if (!col.id && col.accessorKey) {
@@ -74218,7 +74225,10 @@ function DataTable({
74218
74225
  return;
74219
74226
  }
74220
74227
  const filename = typeof exportable === "object" && exportable.filename ? exportable.filename : "data-export";
74221
- const visibleColumns = getVisibleColumns(columns, columnVisibility);
74228
+ const visibleColumns = getVisibleColumns(
74229
+ columns,
74230
+ columnVisibility
74231
+ );
74222
74232
  await exportData2(dataToExport, {
74223
74233
  format: format8,
74224
74234
  filename,
@@ -74239,276 +74249,392 @@ function DataTable({
74239
74249
  const clearRowSelection = () => {
74240
74250
  table.resetRowSelection();
74241
74251
  };
74242
- return /* @__PURE__ */ jsxs("div", { className: cn("moonui-pro-datatable-container flex flex-col gap-4", className), children: [
74243
- /* @__PURE__ */ jsxs("div", { className: "moonui-pro-datatable-toolbar flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between", children: [
74244
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
74245
- searchable && /* @__PURE__ */ jsxs("div", { className: "relative", children: [
74246
- /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }) }),
74247
- /* @__PURE__ */ jsx(
74248
- MoonUIInputPro,
74252
+ return /* @__PURE__ */ jsxs(
74253
+ "div",
74254
+ {
74255
+ className: cn(
74256
+ "moonui-pro-datatable-container flex flex-col gap-4",
74257
+ className
74258
+ ),
74259
+ children: [
74260
+ selectable && table.getFilteredSelectedRowModel().rows.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded-md bg-muted/50 px-4 py-2", children: [
74261
+ /* @__PURE__ */ jsxs("span", { className: "text-sm text-muted-foreground", children: [
74262
+ table.getFilteredSelectedRowModel().rows.length,
74263
+ " Selected"
74264
+ ] }),
74265
+ bulkActions.length > 0 && /* @__PURE__ */ jsx(
74266
+ DataTableBulkActions,
74249
74267
  {
74250
- placeholder: filterPlaceholder,
74251
- value: globalFilter,
74252
- onChange: (e) => setGlobalFilter(e.target.value),
74253
- className: "pl-8 w-full sm:w-64"
74268
+ selectedRows: table.getFilteredSelectedRowModel().rows.map((row) => row.original),
74269
+ actions: bulkActions,
74270
+ onClearSelection: clearRowSelection
74254
74271
  }
74255
74272
  )
74256
74273
  ] }),
74257
- quickFilters.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: quickFilters.map((filter, index2) => /* @__PURE__ */ jsx(
74258
- DataTableQuickFilter,
74259
- {
74260
- table,
74261
- filter,
74262
- data
74263
- },
74264
- `quick-${filter.column}-${index2}`
74265
- )) }),
74266
- facetedFilters.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: facetedFilters.map((filter, index2) => {
74267
- const columnId = typeof filter === "string" ? filter : filter.column;
74268
- const label = typeof filter === "string" ? void 0 : filter.label;
74269
- return /* @__PURE__ */ jsx(
74270
- DataTableFacetedFilter,
74271
- {
74272
- table,
74273
- column: columnId,
74274
- title: label,
74275
- data
74276
- },
74277
- `faceted-${columnId}-${index2}`
74278
- );
74279
- }) }),
74280
- filterable && /* @__PURE__ */ jsxs(
74281
- MoonUIButtonPro,
74274
+ /* @__PURE__ */ jsxs("div", { className: "moonui-pro-datatable-toolbar flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between", children: [
74275
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
74276
+ searchable && /* @__PURE__ */ jsxs("div", { className: "relative", children: [
74277
+ /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }) }),
74278
+ /* @__PURE__ */ jsx(
74279
+ MoonUIInputPro,
74280
+ {
74281
+ placeholder: filterPlaceholder,
74282
+ value: globalFilter,
74283
+ onChange: (e) => setGlobalFilter(e.target.value),
74284
+ className: "pl-8 w-full sm:w-64"
74285
+ }
74286
+ )
74287
+ ] }),
74288
+ quickFilters.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: quickFilters.map((filter, index2) => /* @__PURE__ */ jsx(
74289
+ DataTableQuickFilter,
74290
+ {
74291
+ table,
74292
+ filter,
74293
+ data
74294
+ },
74295
+ `quick-${filter.column}-${index2}`
74296
+ )) }),
74297
+ facetedFilters.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: facetedFilters.map((filter, index2) => {
74298
+ const columnId = typeof filter === "string" ? filter : filter.column;
74299
+ const label = typeof filter === "string" ? void 0 : filter.label;
74300
+ return /* @__PURE__ */ jsx(
74301
+ DataTableFacetedFilter,
74302
+ {
74303
+ table,
74304
+ column: columnId,
74305
+ title: label,
74306
+ data
74307
+ },
74308
+ `faceted-${columnId}-${index2}`
74309
+ );
74310
+ }) }),
74311
+ filterable && /* @__PURE__ */ jsxs(
74312
+ MoonUIButtonPro,
74313
+ {
74314
+ variant: "outline",
74315
+ size: "sm",
74316
+ onClick: () => setFilterDrawerOpen(true),
74317
+ children: [
74318
+ /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Filter, { className: "mr-2 h-4 w-4" }) }),
74319
+ "Filters",
74320
+ 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 })
74321
+ ]
74322
+ }
74323
+ )
74324
+ ] }),
74325
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
74326
+ exportable && exportFormats.length > 0 && /* @__PURE__ */ jsxs(MoonUIDropdownMenuPro, { children: [
74327
+ /* @__PURE__ */ jsx(MoonUIDropdownMenuTriggerPro, { asChild: true, children: /* @__PURE__ */ jsxs(MoonUIButtonPro, { variant: "outline", size: "sm", children: [
74328
+ /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Download, { className: "mr-2 h-4 w-4" }) }),
74329
+ "Export"
74330
+ ] }) }),
74331
+ /* @__PURE__ */ jsxs(MoonUIDropdownMenuContentPro, { align: "end", children: [
74332
+ exportFormats.includes("csv") && /* @__PURE__ */ jsxs(
74333
+ MoonUIDropdownMenuItemPro,
74334
+ {
74335
+ onClick: () => handleExport("csv"),
74336
+ children: [
74337
+ /* @__PURE__ */ jsx(FileSpreadsheet, { className: "mr-2 h-4 w-4" }),
74338
+ "Export as CSV"
74339
+ ]
74340
+ }
74341
+ ),
74342
+ exportFormats.includes("json") && /* @__PURE__ */ jsxs(
74343
+ MoonUIDropdownMenuItemPro,
74344
+ {
74345
+ onClick: () => handleExport("json"),
74346
+ children: [
74347
+ /* @__PURE__ */ jsx(FileJson, { className: "mr-2 h-4 w-4" }),
74348
+ "Export as JSON"
74349
+ ]
74350
+ }
74351
+ ),
74352
+ exportFormats.includes("xlsx") && /* @__PURE__ */ jsxs(
74353
+ MoonUIDropdownMenuItemPro,
74354
+ {
74355
+ onClick: () => handleExport("xlsx"),
74356
+ children: [
74357
+ /* @__PURE__ */ jsx(FileDown, { className: "mr-2 h-4 w-4" }),
74358
+ "Export as Excel"
74359
+ ]
74360
+ }
74361
+ )
74362
+ ] })
74363
+ ] }),
74364
+ /* @__PURE__ */ jsx(DataTableColumnToggle, { table })
74365
+ ] })
74366
+ ] }),
74367
+ /* @__PURE__ */ jsx(
74368
+ "div",
74282
74369
  {
74283
- variant: "outline",
74284
- size: "sm",
74285
- onClick: () => setFilterDrawerOpen(true),
74286
- children: [
74287
- /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Filter, { className: "mr-2 h-4 w-4" }) }),
74288
- "Filters",
74289
- 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 })
74290
- ]
74370
+ className: "moonui-pro-datatable-wrapper rounded-md border overflow-hidden",
74371
+ style: { contain: "layout style" },
74372
+ children: /* @__PURE__ */ jsx("div", { style: { overflowX: "auto" }, children: /* @__PURE__ */ jsxs(
74373
+ "table",
74374
+ {
74375
+ className: "moonui-pro-datatable",
74376
+ style: { width: "100%", tableLayout: "auto" },
74377
+ children: [
74378
+ /* @__PURE__ */ jsx("thead", { className: "moonui-data-table-header", children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(
74379
+ "tr",
74380
+ {
74381
+ className: "moonui-data-table-row border-b",
74382
+ children: headerGroup.headers.filter(
74383
+ (header) => header.column.getIsVisible()
74384
+ ).map((header) => /* @__PURE__ */ jsx(
74385
+ "th",
74386
+ {
74387
+ className: "moonui-data-table-th h-12 px-4 text-left align-middle font-medium text-muted-foreground",
74388
+ children: header.isPlaceholder ? null : /* @__PURE__ */ jsxs(
74389
+ "div",
74390
+ {
74391
+ className: cn(
74392
+ "flex items-center space-x-2",
74393
+ header.column.getCanSort() && "cursor-pointer select-none"
74394
+ ),
74395
+ onClick: header.column.getCanSort() ? createSortingHandler(
74396
+ header.column.id
74397
+ ) : void 0,
74398
+ children: [
74399
+ flexRender(
74400
+ header.column.columnDef.header,
74401
+ header.getContext()
74402
+ ),
74403
+ header.column.getCanSort() && /* @__PURE__ */ jsx("div", { className: "ml-2", children: header.column.getIsSorted() === "asc" ? /* @__PURE__ */ jsx(
74404
+ "span",
74405
+ {
74406
+ suppressHydrationWarning: true,
74407
+ children: /* @__PURE__ */ jsx(ArrowUp, { className: "h-4 w-4" })
74408
+ }
74409
+ ) : header.column.getIsSorted() === "desc" ? /* @__PURE__ */ jsx(
74410
+ "span",
74411
+ {
74412
+ suppressHydrationWarning: true,
74413
+ children: /* @__PURE__ */ jsx(ArrowDown, { className: "h-4 w-4" })
74414
+ }
74415
+ ) : /* @__PURE__ */ jsx(
74416
+ "span",
74417
+ {
74418
+ suppressHydrationWarning: true,
74419
+ children: /* @__PURE__ */ jsx(ArrowUpDown, { className: "h-4 w-4" })
74420
+ }
74421
+ ) })
74422
+ ]
74423
+ }
74424
+ )
74425
+ },
74426
+ header.id
74427
+ ))
74428
+ },
74429
+ headerGroup.id
74430
+ )) }),
74431
+ /* @__PURE__ */ jsx("tbody", { className: "moonui-data-table-body", children: isPaginationLoading ? /* @__PURE__ */ jsx(
74432
+ motion.tr,
74433
+ {
74434
+ initial: { opacity: 0 },
74435
+ animate: { opacity: 1 },
74436
+ exit: { opacity: 0 },
74437
+ transition: { duration: 0.2 },
74438
+ children: /* @__PURE__ */ jsx(
74439
+ "td",
74440
+ {
74441
+ colSpan: table.getAllLeafColumns().filter(
74442
+ (col) => col.getIsVisible()
74443
+ ).length,
74444
+ className: "h-24 text-center",
74445
+ children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center space-x-2", children: [
74446
+ /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) }),
74447
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: "Loading..." })
74448
+ ] })
74449
+ }
74450
+ )
74451
+ },
74452
+ "loading"
74453
+ ) : rows?.length ? /* @__PURE__ */ jsx(Fragment, { children: rows.map((row, index2) => {
74454
+ const rowId = row.original.id || row.id;
74455
+ const isExpanded = enableExpandable && expandedRows.has(rowId);
74456
+ return /* @__PURE__ */ jsx(
74457
+ TableRow2,
74458
+ {
74459
+ row,
74460
+ columns,
74461
+ isExpanded,
74462
+ enableExpandable,
74463
+ renderSubComponent,
74464
+ visibilityState: table.getState().columnVisibility
74465
+ },
74466
+ rowId
74467
+ );
74468
+ }) }) : /* @__PURE__ */ jsx(
74469
+ motion.tr,
74470
+ {
74471
+ initial: { opacity: 0 },
74472
+ animate: { opacity: 1 },
74473
+ exit: { opacity: 0 },
74474
+ transition: { duration: 0.2 },
74475
+ children: /* @__PURE__ */ jsx(
74476
+ "td",
74477
+ {
74478
+ colSpan: table.getAllLeafColumns().filter(
74479
+ (col) => col.getIsVisible()
74480
+ ).length,
74481
+ className: "h-24 text-center",
74482
+ children: "No results found."
74483
+ }
74484
+ )
74485
+ },
74486
+ "no-results"
74487
+ ) })
74488
+ ]
74489
+ }
74490
+ ) })
74291
74491
  }
74292
74492
  ),
74293
- selectable && bulkActions.length > 0 && /* @__PURE__ */ jsx(
74294
- DataTableBulkActions,
74295
- {
74296
- selectedRows: table.getFilteredSelectedRowModel().rows.map((row) => row.original),
74297
- actions: bulkActions,
74298
- onClearSelection: clearRowSelection
74299
- }
74300
- )
74301
- ] }),
74302
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
74303
- exportable && exportFormats.length > 0 && /* @__PURE__ */ jsxs(MoonUIDropdownMenuPro, { children: [
74304
- /* @__PURE__ */ jsx(MoonUIDropdownMenuTriggerPro, { asChild: true, children: /* @__PURE__ */ jsxs(MoonUIButtonPro, { variant: "outline", size: "sm", children: [
74305
- /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Download, { className: "mr-2 h-4 w-4" }) }),
74306
- "Export"
74493
+ pagination && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-2", children: [
74494
+ /* @__PURE__ */ jsx("div", { className: "flex-1 text-sm text-muted-foreground", children: selectable && table.getFilteredSelectedRowModel().rows.length > 0 && /* @__PURE__ */ jsxs("span", { children: [
74495
+ table.getFilteredSelectedRowModel().rows.length,
74496
+ " ",
74497
+ "of ",
74498
+ table.getFilteredRowModel().rows.length,
74499
+ " ",
74500
+ "row(s) selected."
74307
74501
  ] }) }),
74308
- /* @__PURE__ */ jsxs(MoonUIDropdownMenuContentPro, { align: "end", children: [
74309
- exportFormats.includes("csv") && /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => handleExport("csv"), children: [
74310
- /* @__PURE__ */ jsx(FileSpreadsheet, { className: "mr-2 h-4 w-4" }),
74311
- "Export as CSV"
74502
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-6 lg:space-x-8", children: [
74503
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
74504
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: "Rows per page" }),
74505
+ /* @__PURE__ */ jsx(
74506
+ "select",
74507
+ {
74508
+ value: table.getState().pagination.pageSize,
74509
+ onChange: async (e) => {
74510
+ const newPageSize = Number(e.target.value);
74511
+ if (onPaginationChange) {
74512
+ onPaginationChange({
74513
+ pageIndex: table.getState().pagination.pageIndex,
74514
+ pageSize: newPageSize
74515
+ });
74516
+ } else {
74517
+ setIsPaginationLoading(true);
74518
+ await new Promise(
74519
+ (resolve) => setTimeout(resolve, 300)
74520
+ );
74521
+ table.setPageSize(newPageSize);
74522
+ setIsPaginationLoading(false);
74523
+ }
74524
+ },
74525
+ className: "h-8 w-[70px] rounded border border-input bg-background px-3 py-1 text-sm",
74526
+ disabled: isPaginationLoading,
74527
+ children: pageSizeOptions.map((size4) => /* @__PURE__ */ jsx("option", { value: size4, children: size4 }, size4))
74528
+ }
74529
+ )
74312
74530
  ] }),
74313
- exportFormats.includes("json") && /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => handleExport("json"), children: [
74314
- /* @__PURE__ */ jsx(FileJson, { className: "mr-2 h-4 w-4" }),
74315
- "Export as JSON"
74531
+ /* @__PURE__ */ jsxs("div", { className: "flex w-[100px] items-center justify-center text-sm font-medium", children: [
74532
+ "Page ",
74533
+ table.getState().pagination.pageIndex + 1,
74534
+ " of",
74535
+ " ",
74536
+ table.getPageCount()
74316
74537
  ] }),
74317
- exportFormats.includes("xlsx") && /* @__PURE__ */ jsxs(MoonUIDropdownMenuItemPro, { onClick: () => handleExport("xlsx"), children: [
74318
- /* @__PURE__ */ jsx(FileDown, { className: "mr-2 h-4 w-4" }),
74319
- "Export as Excel"
74320
- ] })
74321
- ] })
74322
- ] }),
74323
- /* @__PURE__ */ jsx(DataTableColumnToggle, { table })
74324
- ] })
74325
- ] }),
74326
- /* @__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: [
74327
- /* @__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.filter((header) => header.column.getIsVisible()).map((header) => /* @__PURE__ */ jsx(
74328
- "th",
74329
- {
74330
- className: "moonui-data-table-th h-12 px-4 text-left align-middle font-medium text-muted-foreground",
74331
- children: header.isPlaceholder ? null : /* @__PURE__ */ jsxs(
74332
- "div",
74333
- {
74334
- className: cn(
74335
- "flex items-center space-x-2",
74336
- header.column.getCanSort() && "cursor-pointer select-none"
74538
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
74539
+ /* @__PURE__ */ jsx(
74540
+ MoonUIButtonPro,
74541
+ {
74542
+ variant: "outline",
74543
+ className: "hidden h-8 w-8 p-0 lg:flex",
74544
+ onClick: async () => {
74545
+ if (onPaginationChange) {
74546
+ onPaginationChange({
74547
+ pageIndex: 0,
74548
+ pageSize: table.getState().pagination.pageSize
74549
+ });
74550
+ } else {
74551
+ setIsPaginationLoading(true);
74552
+ await new Promise(
74553
+ (resolve) => setTimeout(resolve, 300)
74554
+ );
74555
+ table.setPageIndex(0);
74556
+ setIsPaginationLoading(false);
74557
+ }
74558
+ },
74559
+ disabled: !table.getCanPreviousPage() || isPaginationLoading,
74560
+ children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronsLeft, { className: "h-4 w-4" }) })
74561
+ }
74337
74562
  ),
74338
- onClick: header.column.getCanSort() ? createSortingHandler(header.column.id) : void 0,
74339
- children: [
74340
- flexRender(header.column.columnDef.header, header.getContext()),
74341
- 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" }) }) })
74342
- ]
74343
- }
74344
- )
74345
- },
74346
- header.id
74347
- )) }, headerGroup.id)) }),
74348
- /* @__PURE__ */ jsx("tbody", { className: "moonui-data-table-body", children: isPaginationLoading ? /* @__PURE__ */ jsx(
74349
- motion.tr,
74350
- {
74351
- initial: { opacity: 0 },
74352
- animate: { opacity: 1 },
74353
- exit: { opacity: 0 },
74354
- transition: { duration: 0.2 },
74355
- children: /* @__PURE__ */ jsx("td", { colSpan: table.getAllLeafColumns().filter((col) => col.getIsVisible()).length, className: "h-24 text-center", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center space-x-2", children: [
74356
- /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) }),
74357
- /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: "Loading..." })
74358
- ] }) })
74359
- },
74360
- "loading"
74361
- ) : rows?.length ? /* @__PURE__ */ jsx(Fragment, { children: rows.map((row, index2) => {
74362
- const rowId = row.original.id || row.id;
74363
- const isExpanded = enableExpandable && expandedRows.has(rowId);
74364
- return /* @__PURE__ */ jsx(
74365
- TableRow2,
74366
- {
74367
- row,
74368
- columns,
74369
- isExpanded,
74370
- enableExpandable,
74371
- renderSubComponent,
74372
- visibilityState: table.getState().columnVisibility
74373
- },
74374
- rowId
74375
- );
74376
- }) }) : /* @__PURE__ */ jsx(
74377
- motion.tr,
74378
- {
74379
- initial: { opacity: 0 },
74380
- animate: { opacity: 1 },
74381
- exit: { opacity: 0 },
74382
- transition: { duration: 0.2 },
74383
- children: /* @__PURE__ */ jsx("td", { colSpan: table.getAllLeafColumns().filter((col) => col.getIsVisible()).length, className: "h-24 text-center", children: "No results found." })
74384
- },
74385
- "no-results"
74386
- ) })
74387
- ] }) }) }),
74388
- pagination && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-2", children: [
74389
- /* @__PURE__ */ jsx("div", { className: "flex-1 text-sm text-muted-foreground", children: selectable && table.getFilteredSelectedRowModel().rows.length > 0 && /* @__PURE__ */ jsxs("span", { children: [
74390
- table.getFilteredSelectedRowModel().rows.length,
74391
- " of",
74392
- " ",
74393
- table.getFilteredRowModel().rows.length,
74394
- " row(s) selected."
74395
- ] }) }),
74396
- /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-6 lg:space-x-8", children: [
74397
- /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
74398
- /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: "Rows per page" }),
74399
- /* @__PURE__ */ jsx(
74400
- "select",
74401
- {
74402
- value: table.getState().pagination.pageSize,
74403
- onChange: async (e) => {
74404
- const newPageSize = Number(e.target.value);
74405
- if (onPaginationChange) {
74406
- onPaginationChange({
74407
- pageIndex: table.getState().pagination.pageIndex,
74408
- pageSize: newPageSize
74409
- });
74410
- } else {
74411
- setIsPaginationLoading(true);
74412
- await new Promise((resolve) => setTimeout(resolve, 300));
74413
- table.setPageSize(newPageSize);
74414
- setIsPaginationLoading(false);
74563
+ /* @__PURE__ */ jsx(
74564
+ MoonUIButtonPro,
74565
+ {
74566
+ variant: "outline",
74567
+ className: "h-8 w-8 p-0",
74568
+ onClick: async () => {
74569
+ if (onPaginationChange) {
74570
+ const currentIndex = table.getState().pagination.pageIndex;
74571
+ onPaginationChange({
74572
+ pageIndex: currentIndex - 1,
74573
+ pageSize: table.getState().pagination.pageSize
74574
+ });
74575
+ } else {
74576
+ setIsPaginationLoading(true);
74577
+ await new Promise(
74578
+ (resolve) => setTimeout(resolve, 300)
74579
+ );
74580
+ table.previousPage();
74581
+ setIsPaginationLoading(false);
74582
+ }
74583
+ },
74584
+ disabled: !table.getCanPreviousPage() || isPaginationLoading,
74585
+ children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" }) })
74415
74586
  }
74416
- },
74417
- className: "h-8 w-[70px] rounded border border-input bg-background px-3 py-1 text-sm",
74418
- disabled: isPaginationLoading,
74419
- children: pageSizeOptions.map((size4) => /* @__PURE__ */ jsx("option", { value: size4, children: size4 }, size4))
74420
- }
74421
- )
74422
- ] }),
74423
- /* @__PURE__ */ jsxs("div", { className: "flex w-[100px] items-center justify-center text-sm font-medium", children: [
74424
- "Page ",
74425
- table.getState().pagination.pageIndex + 1,
74426
- " of",
74427
- " ",
74428
- table.getPageCount()
74429
- ] }),
74430
- /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
74431
- /* @__PURE__ */ jsx(
74432
- MoonUIButtonPro,
74433
- {
74434
- variant: "outline",
74435
- className: "hidden h-8 w-8 p-0 lg:flex",
74436
- onClick: async () => {
74437
- if (onPaginationChange) {
74438
- onPaginationChange({ pageIndex: 0, pageSize: table.getState().pagination.pageSize });
74439
- } else {
74440
- setIsPaginationLoading(true);
74441
- await new Promise((resolve) => setTimeout(resolve, 300));
74442
- table.setPageIndex(0);
74443
- setIsPaginationLoading(false);
74587
+ ),
74588
+ /* @__PURE__ */ jsx(
74589
+ MoonUIButtonPro,
74590
+ {
74591
+ variant: "outline",
74592
+ className: "h-8 w-8 p-0",
74593
+ onClick: async () => {
74594
+ setIsPaginationLoading(true);
74595
+ await new Promise(
74596
+ (resolve) => setTimeout(resolve, 300)
74597
+ );
74598
+ table.nextPage();
74599
+ setIsPaginationLoading(false);
74600
+ },
74601
+ disabled: !table.getCanNextPage() || isPaginationLoading,
74602
+ children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" }) })
74444
74603
  }
74445
- },
74446
- disabled: !table.getCanPreviousPage() || isPaginationLoading,
74447
- children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronsLeft, { className: "h-4 w-4" }) })
74448
- }
74449
- ),
74450
- /* @__PURE__ */ jsx(
74451
- MoonUIButtonPro,
74452
- {
74453
- variant: "outline",
74454
- className: "h-8 w-8 p-0",
74455
- onClick: async () => {
74456
- if (onPaginationChange) {
74457
- const currentIndex = table.getState().pagination.pageIndex;
74458
- onPaginationChange({ pageIndex: currentIndex - 1, pageSize: table.getState().pagination.pageSize });
74459
- } else {
74460
- setIsPaginationLoading(true);
74461
- await new Promise((resolve) => setTimeout(resolve, 300));
74462
- table.previousPage();
74463
- setIsPaginationLoading(false);
74604
+ ),
74605
+ /* @__PURE__ */ jsx(
74606
+ MoonUIButtonPro,
74607
+ {
74608
+ variant: "outline",
74609
+ className: "hidden h-8 w-8 p-0 lg:flex",
74610
+ onClick: async () => {
74611
+ setIsPaginationLoading(true);
74612
+ await new Promise(
74613
+ (resolve) => setTimeout(resolve, 300)
74614
+ );
74615
+ table.setPageIndex(
74616
+ table.getPageCount() - 1
74617
+ );
74618
+ setIsPaginationLoading(false);
74619
+ },
74620
+ disabled: !table.getCanNextPage() || isPaginationLoading,
74621
+ children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronsRight, { className: "h-4 w-4" }) })
74464
74622
  }
74465
- },
74466
- disabled: !table.getCanPreviousPage() || isPaginationLoading,
74467
- children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" }) })
74468
- }
74469
- ),
74470
- /* @__PURE__ */ jsx(
74471
- MoonUIButtonPro,
74472
- {
74473
- variant: "outline",
74474
- className: "h-8 w-8 p-0",
74475
- onClick: async () => {
74476
- setIsPaginationLoading(true);
74477
- await new Promise((resolve) => setTimeout(resolve, 300));
74478
- table.nextPage();
74479
- setIsPaginationLoading(false);
74480
- },
74481
- disabled: !table.getCanNextPage() || isPaginationLoading,
74482
- children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" }) })
74483
- }
74484
- ),
74485
- /* @__PURE__ */ jsx(
74486
- MoonUIButtonPro,
74487
- {
74488
- variant: "outline",
74489
- className: "hidden h-8 w-8 p-0 lg:flex",
74490
- onClick: async () => {
74491
- setIsPaginationLoading(true);
74492
- await new Promise((resolve) => setTimeout(resolve, 300));
74493
- table.setPageIndex(table.getPageCount() - 1);
74494
- setIsPaginationLoading(false);
74495
- },
74496
- disabled: !table.getCanNextPage() || isPaginationLoading,
74497
- children: /* @__PURE__ */ jsx("span", { suppressHydrationWarning: true, children: /* @__PURE__ */ jsx(ChevronsRight, { className: "h-4 w-4" }) })
74498
- }
74499
- )
74500
- ] })
74501
- ] })
74502
- ] }),
74503
- filterable && /* @__PURE__ */ jsx(
74504
- DataTableFilterDrawer,
74505
- {
74506
- table,
74507
- open: filterDrawerOpen,
74508
- onOpenChange: setFilterDrawerOpen
74509
- }
74510
- )
74511
- ] });
74623
+ )
74624
+ ] })
74625
+ ] })
74626
+ ] }),
74627
+ filterable && /* @__PURE__ */ jsx(
74628
+ DataTableFilterDrawer,
74629
+ {
74630
+ table,
74631
+ open: filterDrawerOpen,
74632
+ onOpenChange: setFilterDrawerOpen
74633
+ }
74634
+ )
74635
+ ]
74636
+ }
74637
+ );
74512
74638
  }
74513
74639
  function getExpandableColumn(expandedRows, onToggle) {
74514
74640
  return {
@@ -74582,23 +74708,42 @@ var TableRow2 = ({
74582
74708
  const isVisible = visibilityState[cell.column.id] !== false;
74583
74709
  return isVisible;
74584
74710
  }).map((cell) => {
74585
- return /* @__PURE__ */ jsx("td", { className: "moonui-data-table-td p-4 align-middle", children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id);
74711
+ return /* @__PURE__ */ jsx(
74712
+ "td",
74713
+ {
74714
+ className: "moonui-data-table-td p-4 align-middle",
74715
+ children: flexRender(
74716
+ cell.column.columnDef.cell,
74717
+ cell.getContext()
74718
+ )
74719
+ },
74720
+ cell.id
74721
+ );
74586
74722
  })
74587
74723
  }
74588
74724
  ),
74589
- isExpanded && renderSubComponent && /* @__PURE__ */ jsx("tr", { className: "border-b", children: /* @__PURE__ */ jsx("td", { colSpan: row.getAllCells().filter(
74590
- (cell) => visibilityState[cell.column.id] !== false
74591
- ).length || 1, className: "p-0 overflow-hidden", children: /* @__PURE__ */ jsx(
74592
- "div",
74725
+ isExpanded && renderSubComponent && /* @__PURE__ */ jsx("tr", { className: "border-b", children: /* @__PURE__ */ jsx(
74726
+ "td",
74593
74727
  {
74594
- className: "transition-all duration-300 ease-out",
74595
- style: {
74596
- maxHeight: isExpanded ? "1000px" : "0",
74597
- opacity: isExpanded ? 1 : 0
74598
- },
74599
- children: /* @__PURE__ */ jsx("div", { className: "border-t border-border/50", children: renderSubComponent({ row: { original: row.original, id: rowId } }) })
74728
+ colSpan: row.getAllCells().filter(
74729
+ (cell) => visibilityState[cell.column.id] !== false
74730
+ ).length || 1,
74731
+ className: "p-0 overflow-hidden",
74732
+ children: /* @__PURE__ */ jsx(
74733
+ "div",
74734
+ {
74735
+ className: "transition-all duration-300 ease-out",
74736
+ style: {
74737
+ maxHeight: isExpanded ? "1000px" : "0",
74738
+ opacity: isExpanded ? 1 : 0
74739
+ },
74740
+ children: /* @__PURE__ */ jsx("div", { className: "border-t border-border/50", children: renderSubComponent({
74741
+ row: { original: row.original, id: rowId }
74742
+ }) })
74743
+ }
74744
+ )
74600
74745
  }
74601
- ) }) })
74746
+ ) })
74602
74747
  ] });
74603
74748
  };
74604
74749
  TableRow2.displayName = "TableRow";