shadcn-ui-react 0.5.2 → 0.6.0

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.cjs CHANGED
@@ -121,6 +121,7 @@ __export(index_exports, {
121
121
  ContextMenuSubContent: () => ContextMenuSubContent,
122
122
  ContextMenuSubTrigger: () => ContextMenuSubTrigger,
123
123
  ContextMenuTrigger: () => ContextMenuTrigger,
124
+ DATA_TABLE_TEMPLATES: () => DATA_TABLE_TEMPLATES,
124
125
  DataTable: () => DataTable,
125
126
  DataTableSkeleton: () => DataTableSkeleton,
126
127
  Dialog: () => Dialog,
@@ -8397,6 +8398,209 @@ var import_react_icons18 = require("@radix-ui/react-icons");
8397
8398
  var import_react_table = require("@tanstack/react-table");
8398
8399
  var import_lucide_react6 = require("lucide-react");
8399
8400
  var import_jsx_runtime48 = require("react/jsx-runtime");
8401
+ var TablePlain = import_react36.default.forwardRef((_a, ref) => {
8402
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
8403
+ return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8404
+ "table",
8405
+ __spreadValues({
8406
+ ref,
8407
+ className: cn("w-full caption-bottom text-sm", className)
8408
+ }, props)
8409
+ );
8410
+ });
8411
+ TablePlain.displayName = "TablePlain";
8412
+ var ACCENT_COLOR = {
8413
+ primary: "var(--primary)",
8414
+ emerald: "#10b981",
8415
+ indigo: "#6366f1",
8416
+ rose: "#f43f5e",
8417
+ amber: "#f59e0b",
8418
+ zinc: "#71717a"
8419
+ };
8420
+ function resolveAccent(accent, accentColor) {
8421
+ var _a;
8422
+ const custom = accentColor == null ? void 0 : accentColor.trim();
8423
+ if (custom) return custom;
8424
+ if (!accent) return void 0;
8425
+ return (_a = ACCENT_COLOR[accent]) != null ? _a : ACCENT_COLOR.primary;
8426
+ }
8427
+ var DATA_TABLE_TEMPLATES = {
8428
+ neo: {
8429
+ root: cn(
8430
+ "relative w-full overflow-hidden rounded-2xl border shadow-sm",
8431
+ "bg-background/70 supports-[backdrop-filter]:bg-background/45 backdrop-blur",
8432
+ "flex flex-col",
8433
+ "before:absolute before:inset-x-0 before:top-0 before:h-[2px] before:bg-transparent",
8434
+ "data-[accent=on]:before:bg-[color:var(--dt-accent)]"
8435
+ ),
8436
+ table: cn("w-full text-sm"),
8437
+ thead: "border-b",
8438
+ theadSticky: "sticky top-0 z-10 bg-background/85 supports-[backdrop-filter]:bg-background/60 backdrop-blur",
8439
+ trHead: "hover:bg-transparent",
8440
+ th: cn(
8441
+ "h-11 px-4 text-left align-middle whitespace-nowrap",
8442
+ "text-[11px] font-semibold uppercase tracking-wide text-muted-foreground"
8443
+ ),
8444
+ tbody: cn(
8445
+ "[&_tr:last-child]:border-0",
8446
+ "[&>tr:nth-child(even)]:bg-muted/20"
8447
+ ),
8448
+ tr: cn(
8449
+ "border-b transition-colors",
8450
+ "data-[state=selected]:bg-muted/35",
8451
+ "data-[accent=on]:data-[state=selected]:bg-[color:var(--dt-accent)]/10"
8452
+ ),
8453
+ trClickable: cn(
8454
+ "cursor-pointer",
8455
+ "hover:bg-muted/35 active:bg-muted/45",
8456
+ "data-[accent=on]:hover:bg-[color:var(--dt-accent)]/8",
8457
+ "data-[accent=on]:active:bg-[color:var(--dt-accent)]/12"
8458
+ ),
8459
+ td: "px-4 py-3 align-middle",
8460
+ footer: cn(
8461
+ "border-t",
8462
+ "bg-background/80 supports-[backdrop-filter]:bg-background/55 backdrop-blur"
8463
+ ),
8464
+ footerInner: "px-4 py-3",
8465
+ metaWrap: "flex flex-wrap items-center gap-x-3 gap-y-1 text-sm text-muted-foreground",
8466
+ controlsWrap: "flex flex-wrap items-center justify-between gap-3 sm:justify-end",
8467
+ pageSizeLabel: "text-sm font-medium whitespace-nowrap",
8468
+ pageSizeTrigger: cn(
8469
+ "h-8 w-[5rem]",
8470
+ "border-muted-foreground/20",
8471
+ "focus-visible:ring-2 focus-visible:ring-ring",
8472
+ "data-[accent=on]:focus-visible:ring-[color:var(--dt-accent)]/35"
8473
+ ),
8474
+ pageLabel: "hidden sm:flex min-w-[9.25rem] items-center justify-center text-sm font-medium",
8475
+ navButton: cn(
8476
+ "h-8 w-8 p-0 rounded-md",
8477
+ "border-muted-foreground/20",
8478
+ "hover:bg-muted/35 hover:border-muted-foreground/40",
8479
+ "focus-visible:ring-2 focus-visible:ring-ring",
8480
+ "data-[accent=on]:hover:border-[color:var(--dt-accent)]/45",
8481
+ "data-[accent=on]:hover:bg-[color:var(--dt-accent)]/10",
8482
+ "data-[accent=on]:focus-visible:ring-[color:var(--dt-accent)]/35"
8483
+ )
8484
+ },
8485
+ glass: {
8486
+ root: cn(
8487
+ "relative w-full overflow-hidden rounded-2xl border shadow-md",
8488
+ "bg-background/55 supports-[backdrop-filter]:bg-background/25 backdrop-blur-xl",
8489
+ "flex flex-col",
8490
+ "before:absolute before:inset-x-0 before:top-0 before:h-[2px] before:bg-transparent",
8491
+ "data-[accent=on]:before:bg-[color:var(--dt-accent)]"
8492
+ ),
8493
+ theadSticky: "sticky top-0 z-10 bg-background/70 supports-[backdrop-filter]:bg-background/35 backdrop-blur-xl",
8494
+ tbody: cn("[&_tr:last-child]:border-0", "[&>tr:nth-child(even)]:bg-background/20")
8495
+ },
8496
+ compact: {
8497
+ th: "h-10 px-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground whitespace-nowrap",
8498
+ td: "px-3 py-2 text-xs align-middle",
8499
+ pageSizeTrigger: "h-8 w-[4.5rem]"
8500
+ },
8501
+ minimal: {
8502
+ root: cn("relative w-full overflow-hidden rounded-xl border-0 shadow-none bg-transparent flex flex-col"),
8503
+ theadSticky: "sticky top-0 z-10 bg-background",
8504
+ footer: "border-t bg-transparent",
8505
+ tbody: "[&_tr:last-child]:border-0"
8506
+ },
8507
+ clean: {
8508
+ root: cn(
8509
+ "relative w-full overflow-hidden rounded-2xl border shadow-none",
8510
+ "bg-background flex flex-col",
8511
+ "before:absolute before:inset-x-0 before:top-0 before:h-[2px] before:bg-transparent",
8512
+ "data-[accent=on]:before:bg-[color:var(--dt-accent)]"
8513
+ ),
8514
+ theadSticky: "sticky top-0 z-10 bg-background",
8515
+ tbody: cn("[&_tr:last-child]:border-0", "[&>tr:nth-child(even)]:bg-transparent"),
8516
+ tr: cn(
8517
+ "border-b",
8518
+ "data-[state=selected]:bg-muted/35",
8519
+ "data-[accent=on]:data-[state=selected]:bg-[color:var(--dt-accent)]/10"
8520
+ ),
8521
+ trClickable: cn(
8522
+ "cursor-pointer",
8523
+ "hover:bg-muted/30 active:bg-muted/40",
8524
+ "data-[accent=on]:hover:bg-[color:var(--dt-accent)]/8",
8525
+ "data-[accent=on]:active:bg-[color:var(--dt-accent)]/12"
8526
+ )
8527
+ },
8528
+ elevated: {
8529
+ root: cn(
8530
+ "relative w-full overflow-hidden rounded-3xl border shadow-lg",
8531
+ "bg-card flex flex-col",
8532
+ "before:absolute before:inset-x-0 before:top-0 before:h-[2px] before:bg-transparent",
8533
+ "data-[accent=on]:before:bg-[color:var(--dt-accent)]"
8534
+ ),
8535
+ theadSticky: "sticky top-0 z-10 bg-card/95 supports-[backdrop-filter]:bg-card/75 backdrop-blur",
8536
+ tbody: cn("[&_tr:last-child]:border-0", "[&>tr:nth-child(even)]:bg-muted/10"),
8537
+ th: cn(
8538
+ "h-12 px-5 text-left align-middle whitespace-nowrap",
8539
+ "text-[11px] font-semibold uppercase tracking-wider text-muted-foreground"
8540
+ ),
8541
+ td: "px-5 py-3 align-middle"
8542
+ },
8543
+ grid: {
8544
+ root: cn("relative w-full overflow-hidden rounded-2xl border shadow-sm bg-background flex flex-col"),
8545
+ table: cn(
8546
+ "w-full text-sm border-separate border-spacing-0",
8547
+ "[&_th]:border-b [&_td]:border-b",
8548
+ "[&_th:not(:last-child)]:border-r [&_td:not(:last-child)]:border-r",
8549
+ "[&_th]:border-muted-foreground/15 [&_td]:border-muted-foreground/10"
8550
+ ),
8551
+ thead: "border-b-0",
8552
+ tbody: "[&_tr:last-child_td]:border-b-0",
8553
+ tr: cn(
8554
+ "transition-colors",
8555
+ "data-[state=selected]:bg-muted/35",
8556
+ "data-[accent=on]:data-[state=selected]:bg-[color:var(--dt-accent)]/10"
8557
+ ),
8558
+ trClickable: cn(
8559
+ "cursor-pointer",
8560
+ "hover:bg-muted/25 active:bg-muted/35",
8561
+ "data-[accent=on]:hover:bg-[color:var(--dt-accent)]/7",
8562
+ "data-[accent=on]:active:bg-[color:var(--dt-accent)]/10"
8563
+ )
8564
+ },
8565
+ cards: {
8566
+ root: cn("relative w-full overflow-hidden rounded-2xl border bg-transparent shadow-none flex flex-col"),
8567
+ table: cn(
8568
+ "w-full text-sm border-separate border-spacing-y-2",
8569
+ "[&_tbody_tr_td]:bg-background",
8570
+ "[&_tbody_tr_td:first-child]:rounded-l-xl",
8571
+ "[&_tbody_tr_td:last-child]:rounded-r-xl",
8572
+ "[&_tbody_tr_td]:shadow-sm",
8573
+ "[&_thead_tr]:border-b"
8574
+ ),
8575
+ theadSticky: "sticky top-0 z-10 bg-background",
8576
+ tr: cn(
8577
+ "border-0",
8578
+ "data-[state=selected]:opacity-100",
8579
+ "data-[state=selected]:[&_td]:ring-1 data-[state=selected]:[&_td]:ring-muted-foreground/15",
8580
+ "data-[accent=on]:data-[state=selected]:[&_td]:ring-[color:var(--dt-accent)]/25"
8581
+ ),
8582
+ trClickable: cn(
8583
+ "cursor-pointer",
8584
+ "[&_td]:transition-colors",
8585
+ "hover:[&_td]:bg-muted/25 active:[&_td]:bg-muted/35",
8586
+ "data-[accent=on]:hover:[&_td]:bg-[color:var(--dt-accent)]/7",
8587
+ "data-[accent=on]:active:[&_td]:bg-[color:var(--dt-accent)]/10"
8588
+ ),
8589
+ tbody: "[&_tr:last-child]:border-0"
8590
+ }
8591
+ };
8592
+ function mergeSlots(...parts) {
8593
+ const out = {};
8594
+ for (const p of parts) {
8595
+ if (!p) continue;
8596
+ for (const k of Object.keys(p)) {
8597
+ const v = p[k];
8598
+ if (!v) continue;
8599
+ out[k] = out[k] ? cn(out[k], v) : v;
8600
+ }
8601
+ }
8602
+ return out;
8603
+ }
8400
8604
  function DataTable({
8401
8605
  columns,
8402
8606
  data,
@@ -8410,132 +8614,138 @@ function DataTable({
8410
8614
  isRowsSelected = true,
8411
8615
  totalRows,
8412
8616
  rowsSelectedLabel = "row(s) selected",
8413
- className,
8617
+ template = "neo",
8618
+ classNames,
8619
+ accent = null,
8620
+ accentColor = null,
8414
8621
  emptyData,
8415
- bodyClassName,
8416
- cellClassName,
8417
- headerClassName,
8418
- rowClassName,
8419
- tableClassName,
8420
8622
  onPageChange,
8421
8623
  onClick,
8422
8624
  onPageSizeChange,
8423
8625
  animate = true,
8424
8626
  stickyHeader = true,
8627
+ headerScroll = false,
8425
8628
  heightClassName = "h-[clamp(22rem,80vh,44rem)] supports-[height:100dvh]:h-[clamp(22rem,80dvh,44rem)]"
8426
8629
  }) {
8427
8630
  const safePageCount = Math.max(pageCount != null ? pageCount : 1, 1);
8428
- const [pagination, setPagination] = import_react36.default.useState({
8429
- pageIndex: Math.max(page - 1, 0),
8430
- pageSize: perPage
8431
- });
8432
- (0, import_react36.useEffect)(() => {
8433
- setPagination((prev) => {
8434
- const nextIndex = Math.max(page - 1, 0);
8435
- const nextSize = perPage;
8436
- if (prev.pageIndex === nextIndex && prev.pageSize === nextSize) return prev;
8437
- return { pageIndex: nextIndex, pageSize: nextSize };
8438
- });
8439
- }, [page, perPage]);
8440
- (0, import_react36.useEffect)(() => {
8441
- setPagination((prev) => {
8442
- const maxIndex = Math.max(safePageCount - 1, 0);
8443
- const clamped = Math.min(prev.pageIndex, maxIndex);
8444
- if (clamped === prev.pageIndex) return prev;
8445
- return __spreadProps(__spreadValues({}, prev), { pageIndex: clamped });
8446
- });
8447
- }, [safePageCount]);
8631
+ const pageIndex = Math.min(Math.max(page - 1, 0), safePageCount - 1);
8632
+ const pageSize = Math.max(perPage, 1);
8633
+ const paginationState = (0, import_react36.useMemo)(
8634
+ () => ({ pageIndex, pageSize }),
8635
+ [pageIndex, pageSize]
8636
+ );
8448
8637
  const table = (0, import_react_table.useReactTable)({
8449
8638
  data,
8450
8639
  columns,
8451
8640
  pageCount: safePageCount,
8641
+ state: { pagination: paginationState },
8452
8642
  getCoreRowModel: (0, import_react_table.getCoreRowModel)(),
8453
8643
  getFilteredRowModel: (0, import_react_table.getFilteredRowModel)(),
8454
- state: { pagination },
8455
- onPaginationChange: setPagination,
8456
- getPaginationRowModel: (0, import_react_table.getPaginationRowModel)(),
8457
8644
  manualPagination: true,
8458
- manualFiltering: true
8645
+ manualFiltering: true,
8646
+ autoResetAll: false,
8647
+ autoResetPageIndex: false
8459
8648
  });
8460
8649
  const clickable = !!onClick;
8461
- (0, import_react36.useEffect)(() => {
8462
- onPageChange == null ? void 0 : onPageChange(pagination.pageIndex + 1);
8463
- }, [pagination.pageIndex, onPageChange]);
8464
8650
  const pageKey = (0, import_react36.useMemo)(
8465
- () => `${pagination.pageIndex}-${pagination.pageSize}-${data.length}`,
8466
- [pagination.pageIndex, pagination.pageSize, data.length]
8651
+ () => `${pageIndex}-${pageSize}-${data.length}`,
8652
+ [pageIndex, pageSize, data.length]
8467
8653
  );
8654
+ const goToPage = (nextPageIndex) => {
8655
+ const clamped = Math.min(Math.max(nextPageIndex, 0), safePageCount - 1);
8656
+ if (clamped === pageIndex) return;
8657
+ onPageChange == null ? void 0 : onPageChange(clamped + 1);
8658
+ };
8659
+ const changePageSize = (newSize) => {
8660
+ const size = Math.max(Number(newSize) || 1, 1);
8661
+ if (size === pageSize) return;
8662
+ onPageSizeChange == null ? void 0 : onPageSizeChange(size);
8663
+ onPageChange == null ? void 0 : onPageChange(1);
8664
+ };
8665
+ const ui = (0, import_react36.useMemo)(() => {
8666
+ var _a;
8667
+ const builtIn = (_a = DATA_TABLE_TEMPLATES[template]) != null ? _a : DATA_TABLE_TEMPLATES.neo;
8668
+ return mergeSlots(DATA_TABLE_TEMPLATES.neo, builtIn, classNames);
8669
+ }, [template, classNames]);
8670
+ const dtAccent = resolveAccent(accent, accentColor);
8671
+ const accentOn = !!dtAccent;
8672
+ const dataAccent = accentOn ? "on" : "off";
8673
+ const headerIsSticky = stickyHeader && !headerScroll;
8468
8674
  return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
8469
8675
  "div",
8470
8676
  {
8471
- className: cn(
8472
- "relative w-full overflow-hidden rounded-xl border bg-background/60 backdrop-blur supports-backdrop-filter:bg-background/40 shadow-sm",
8473
- "flex flex-col",
8474
- heightClassName,
8475
- className
8476
- ),
8677
+ "data-accent": dataAccent,
8678
+ className: cn(ui.root, heightClassName),
8679
+ style: accentOn ? { "--dt-accent": dtAccent } : void 0,
8477
8680
  children: [
8478
- /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "flex-1 min-h-0", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(ScrollArea, { className: "h-full", children: [
8479
- /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
8480
- Table,
8481
- {
8482
- containerClassName: "overflow-visible",
8483
- className: cn("w-full", tableClassName),
8484
- children: [
8485
- /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8486
- TableHeader,
8487
- {
8488
- className: cn(
8489
- headerClassName,
8490
- stickyHeader ? "sticky top-0 z-10 bg-background/80 backdrop-blur border-b" : ""
8491
- ),
8492
- children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableRow, { className: cn("hover:bg-transparent", rowClassName), children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableHead, { className: cn("whitespace-nowrap", headerClassName), children: header.isPlaceholder ? null : (0, import_react_table.flexRender)(header.column.columnDef.header, header.getContext()) }, header.id)) }, headerGroup.id))
8493
- }
8681
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(ScrollArea, { className: "h-full", children: [
8682
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "relative min-w-full w-max", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(TablePlain, { className: cn(ui.table), children: [
8683
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableHeader, { className: cn(ui.thead), children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableRow, { className: cn(ui.trHead), children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8684
+ TableHead,
8685
+ {
8686
+ className: cn(
8687
+ ui.th,
8688
+ headerIsSticky ? cn(ui.theadSticky, "z-20") : void 0
8494
8689
  ),
8495
- animate ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_framer_motion2.AnimatePresence, { mode: "wait", initial: false, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8496
- import_framer_motion2.motion.tbody,
8497
- {
8498
- className: cn("[&_tr:last-child]:border-0", bodyClassName),
8499
- initial: { opacity: 0, y: 6 },
8500
- animate: { opacity: 1, y: 0 },
8501
- exit: { opacity: 0, y: -6 },
8502
- transition: { duration: 0.18 },
8503
- children: table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8504
- TableRow,
8505
- {
8506
- "data-state": row.getIsSelected() ? "selected" : void 0,
8507
- onClick: () => onClick == null ? void 0 : onClick(row.original),
8508
- className: cn(
8509
- rowClassName,
8510
- clickable ? "cursor-pointer hover:bg-muted/60 active:bg-muted/80" : ""
8511
- ),
8512
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableCell, { className: cellClassName, children: (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
8513
- },
8514
- row.id
8515
- )) : emptyData || /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableCell, { colSpan: columns.length, className: "h-28 text-center text-muted-foreground", children: "No results." }) })
8516
- },
8517
- pageKey
8518
- ) }) : /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableBody, { className: bodyClassName, children: table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8690
+ children: header.isPlaceholder ? null : (0, import_react_table.flexRender)(
8691
+ header.column.columnDef.header,
8692
+ header.getContext()
8693
+ )
8694
+ },
8695
+ header.id
8696
+ )) }, headerGroup.id)) }),
8697
+ animate ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_framer_motion2.AnimatePresence, { mode: "wait", initial: false, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8698
+ import_framer_motion2.motion.tbody,
8699
+ {
8700
+ className: cn(ui.tbody),
8701
+ initial: { opacity: 0, y: 6 },
8702
+ animate: { opacity: 1, y: 0 },
8703
+ exit: { opacity: 0, y: -6 },
8704
+ transition: { duration: 0.18 },
8705
+ children: table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8519
8706
  TableRow,
8520
8707
  {
8708
+ "data-accent": dataAccent,
8521
8709
  "data-state": row.getIsSelected() ? "selected" : void 0,
8522
8710
  onClick: () => onClick == null ? void 0 : onClick(row.original),
8523
- className: cn(
8524
- rowClassName,
8525
- clickable ? "cursor-pointer hover:bg-muted/60 active:bg-muted/80" : ""
8526
- ),
8527
- children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableCell, { className: cn(cellClassName), children: (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
8711
+ className: cn(ui.tr, clickable ? ui.trClickable : void 0),
8712
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableCell, { className: cn(ui.td), children: (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
8528
8713
  },
8529
8714
  row.id
8530
- )) : emptyData || /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableCell, { colSpan: columns.length, className: "h-28 text-center text-muted-foreground", children: "No results." }) }) })
8531
- ]
8532
- }
8533
- ),
8715
+ )) : emptyData || /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableRow, { "data-accent": dataAccent, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8716
+ TableCell,
8717
+ {
8718
+ colSpan: columns.length,
8719
+ className: cn(ui.td, "text-muted-foreground h-28 text-center"),
8720
+ children: "No results."
8721
+ }
8722
+ ) })
8723
+ },
8724
+ pageKey
8725
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableBody, { className: cn(ui.tbody), children: table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8726
+ TableRow,
8727
+ {
8728
+ "data-accent": dataAccent,
8729
+ "data-state": row.getIsSelected() ? "selected" : void 0,
8730
+ onClick: () => onClick == null ? void 0 : onClick(row.original),
8731
+ className: cn(ui.tr, clickable ? ui.trClickable : void 0),
8732
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableCell, { className: cn(ui.td), children: (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
8733
+ },
8734
+ row.id
8735
+ )) : emptyData || /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(TableRow, { "data-accent": dataAccent, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8736
+ TableCell,
8737
+ {
8738
+ colSpan: columns.length,
8739
+ className: cn(ui.td, "text-muted-foreground h-28 text-center"),
8740
+ children: "No results."
8741
+ }
8742
+ ) }) })
8743
+ ] }) }),
8534
8744
  /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(ScrollBar, { orientation: "horizontal" })
8535
8745
  ] }) }),
8536
- /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "border-t bg-background/70 backdrop-blur supports-backdrop-filter:bg-background/50", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "px-4 py-3", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-[1fr_auto] sm:items-center", children: [
8537
- /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1", children: [
8538
- isRowsSelected && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "text-muted-foreground text-sm", children: [
8746
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: cn(ui.footer), children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: cn(ui.footerInner), children: /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-[1fr_auto] sm:items-center", children: [
8747
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: cn(ui.metaWrap), children: [
8748
+ isRowsSelected && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { children: [
8539
8749
  table.getFilteredSelectedRowModel().rows.length,
8540
8750
  " ",
8541
8751
  ofLabel,
@@ -8544,37 +8754,25 @@ function DataTable({
8544
8754
  " ",
8545
8755
  rowsSelectedLabel
8546
8756
  ] }),
8547
- typeof totalRows === "number" && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "text-sm text-muted-foreground", children: [
8757
+ typeof totalRows === "number" && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { children: [
8548
8758
  "Total: ",
8549
8759
  totalRows,
8550
8760
  " registros"
8551
8761
  ] })
8552
8762
  ] }),
8553
- /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-3 sm:justify-end", children: [
8763
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: cn(ui.controlsWrap), children: [
8554
8764
  /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex items-center gap-2", children: [
8555
- /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "text-sm font-medium whitespace-nowrap", children: rowPerPageLabel }),
8556
- /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
8557
- Select2,
8558
- {
8559
- value: `${pagination.pageSize}`,
8560
- onValueChange: (value) => {
8561
- const newSize = Number(value);
8562
- setPagination((p) => __spreadProps(__spreadValues({}, p), { pageSize: newSize, pageIndex: 0 }));
8563
- onPageSizeChange == null ? void 0 : onPageSizeChange(newSize);
8564
- onPageChange == null ? void 0 : onPageChange(1);
8565
- },
8566
- children: [
8567
- /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SelectTrigger, { className: "h-8 w-21", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SelectValue, { placeholder: pagination.pageSize }) }),
8568
- /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SelectContent, { side: "top", children: pageSizeOptions.map((size) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SelectItem, { value: `${size}`, children: size }, size)) })
8569
- ]
8570
- }
8571
- )
8765
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: cn(ui.pageSizeLabel), children: rowPerPageLabel }),
8766
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Select2, { value: `${pageSize}`, onValueChange: (v) => changePageSize(Number(v)), children: [
8767
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SelectTrigger, { "data-accent": dataAccent, className: cn(ui.pageSizeTrigger), children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SelectValue, { placeholder: `${pageSize}` }) }),
8768
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SelectContent, { side: "top", children: pageSizeOptions.map((size) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SelectItem, { value: `${size}`, children: size }, size)) })
8769
+ ] })
8572
8770
  ] }),
8573
8771
  /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex items-center gap-2", children: [
8574
- /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "hidden sm:flex min-w-35 items-center justify-center text-sm font-medium", children: [
8772
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: cn(ui.pageLabel), children: [
8575
8773
  pageLabel,
8576
8774
  " ",
8577
- pagination.pageIndex + 1,
8775
+ pageIndex + 1,
8578
8776
  " ",
8579
8777
  ofLabel,
8580
8778
  " ",
@@ -8583,54 +8781,56 @@ function DataTable({
8583
8781
  /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8584
8782
  Button,
8585
8783
  {
8784
+ "data-accent": dataAccent,
8586
8785
  "aria-label": "Go to first page",
8587
8786
  variant: "outline",
8588
- className: "hidden h-8 w-8 p-0 lg:flex",
8589
- onClick: () => setPagination((p) => __spreadProps(__spreadValues({}, p), { pageIndex: 0 })),
8590
- disabled: pagination.pageIndex === 0,
8787
+ className: cn("hidden lg:flex", ui.navButton),
8788
+ onClick: () => goToPage(0),
8789
+ disabled: pageIndex === 0,
8591
8790
  children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react_icons18.DoubleArrowLeftIcon, { className: "h-4 w-4" })
8592
8791
  }
8593
8792
  ),
8594
8793
  /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8595
8794
  Button,
8596
8795
  {
8796
+ "data-accent": dataAccent,
8597
8797
  "aria-label": "Go to previous page",
8598
8798
  variant: "outline",
8599
- className: "h-8 w-8 p-0",
8600
- onClick: () => setPagination((p) => __spreadProps(__spreadValues({}, p), { pageIndex: Math.max(p.pageIndex - 1, 0) })),
8601
- disabled: pagination.pageIndex === 0,
8602
- children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_lucide_react6.ChevronLeftIcon, { className: "h-4 w-4" })
8799
+ className: cn(ui.navButton),
8800
+ onClick: () => goToPage(pageIndex - 1),
8801
+ disabled: pageIndex === 0,
8802
+ children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_lucide_react6.ChevronLeft, { className: "h-4 w-4" })
8603
8803
  }
8604
8804
  ),
8605
8805
  /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8606
8806
  Button,
8607
8807
  {
8808
+ "data-accent": dataAccent,
8608
8809
  "aria-label": "Go to next page",
8609
8810
  variant: "outline",
8610
- className: "h-8 w-8 p-0",
8611
- onClick: () => setPagination((p) => __spreadProps(__spreadValues({}, p), {
8612
- pageIndex: Math.min(p.pageIndex + 1, safePageCount - 1)
8613
- })),
8614
- disabled: pagination.pageIndex + 1 >= safePageCount,
8615
- children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_lucide_react6.ChevronRightIcon, { className: "h-4 w-4" })
8811
+ className: cn(ui.navButton),
8812
+ onClick: () => goToPage(pageIndex + 1),
8813
+ disabled: pageIndex + 1 >= safePageCount,
8814
+ children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_lucide_react6.ChevronRight, { className: "h-4 w-4" })
8616
8815
  }
8617
8816
  ),
8618
8817
  /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
8619
8818
  Button,
8620
8819
  {
8820
+ "data-accent": dataAccent,
8621
8821
  "aria-label": "Go to last page",
8622
8822
  variant: "outline",
8623
- className: "hidden h-8 w-8 p-0 lg:flex",
8624
- onClick: () => setPagination((p) => __spreadProps(__spreadValues({}, p), { pageIndex: safePageCount - 1 })),
8625
- disabled: pagination.pageIndex + 1 >= safePageCount,
8823
+ className: cn("hidden lg:flex", ui.navButton),
8824
+ onClick: () => goToPage(safePageCount - 1),
8825
+ disabled: pageIndex + 1 >= safePageCount,
8626
8826
  children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_react_icons18.DoubleArrowRightIcon, { className: "h-4 w-4" })
8627
8827
  }
8628
8828
  )
8629
8829
  ] }),
8630
- /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "sm:hidden w-full text-center text-xs text-muted-foreground", children: [
8830
+ /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "text-muted-foreground w-full text-center text-xs sm:hidden", children: [
8631
8831
  pageLabel,
8632
8832
  " ",
8633
- pagination.pageIndex + 1,
8833
+ pageIndex + 1,
8634
8834
  " ",
8635
8835
  ofLabel,
8636
8836
  " ",
@@ -9121,6 +9321,7 @@ function UiInput(_a) {
9121
9321
  ContextMenuSubContent,
9122
9322
  ContextMenuSubTrigger,
9123
9323
  ContextMenuTrigger,
9324
+ DATA_TABLE_TEMPLATES,
9124
9325
  DataTable,
9125
9326
  DataTableSkeleton,
9126
9327
  Dialog,