@prediktif/ui 0.1.18 → 0.1.20

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
@@ -496,6 +496,57 @@ function DropdownMenuItem(_a) {
496
496
  }, props)
497
497
  );
498
498
  }
499
+ function DropdownMenuCheckboxItem(_a) {
500
+ var _b = _a, {
501
+ className,
502
+ children,
503
+ checked,
504
+ inset
505
+ } = _b, props = __objRest(_b, [
506
+ "className",
507
+ "children",
508
+ "checked",
509
+ "inset"
510
+ ]);
511
+ return /* @__PURE__ */ jsxs3(
512
+ MenuPrimitive.CheckboxItem,
513
+ __spreadProps(__spreadValues({
514
+ "data-slot": "dropdown-menu-checkbox-item",
515
+ "data-inset": inset,
516
+ className: cn5(
517
+ "relative flex min-h-7 cursor-default items-center gap-2 rounded-md py-1.5 pr-8 pl-2 text-xs outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7.5 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
518
+ className
519
+ ),
520
+ checked
521
+ }, props), {
522
+ children: [
523
+ /* @__PURE__ */ jsx5(
524
+ "span",
525
+ {
526
+ className: "pointer-events-none absolute right-2 flex items-center justify-center",
527
+ "data-slot": "dropdown-menu-checkbox-item-indicator",
528
+ children: /* @__PURE__ */ jsx5(MenuPrimitive.CheckboxItemIndicator, { children: /* @__PURE__ */ jsx5(CheckIcon, {}) })
529
+ }
530
+ ),
531
+ children
532
+ ]
533
+ })
534
+ );
535
+ }
536
+ function DropdownMenuSeparator(_a) {
537
+ var _b = _a, {
538
+ className
539
+ } = _b, props = __objRest(_b, [
540
+ "className"
541
+ ]);
542
+ return /* @__PURE__ */ jsx5(
543
+ MenuPrimitive.Separator,
544
+ __spreadValues({
545
+ "data-slot": "dropdown-menu-separator",
546
+ className: cn5("-mx-1 my-1 h-px bg-border/50", className)
547
+ }, props)
548
+ );
549
+ }
499
550
 
500
551
  // src/components/ui/separator.tsx
501
552
  import { Separator as SeparatorPrimitive } from "@base-ui/react/separator";
@@ -534,6 +585,20 @@ import * as React2 from "react";
534
585
  import { Input as InputPrimitive } from "@base-ui/react/input";
535
586
  import { cn as cn7 } from "cn";
536
587
  import { jsx as jsx7 } from "react/jsx-runtime";
588
+ function Input(_a) {
589
+ var _b = _a, { className, type } = _b, props = __objRest(_b, ["className", "type"]);
590
+ return /* @__PURE__ */ jsx7(
591
+ InputPrimitive,
592
+ __spreadValues({
593
+ type,
594
+ "data-slot": "input",
595
+ className: cn7(
596
+ "h-7 w-full min-w-0 rounded-md border border-input bg-input/20 px-2 py-0.5 text-sm transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-xs/relaxed file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-xs/relaxed dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
597
+ className
598
+ )
599
+ }, props)
600
+ );
601
+ }
537
602
 
538
603
  // src/components/ui/sheet.tsx
539
604
  import { Dialog as SheetPrimitive } from "@base-ui/react/dialog";
@@ -1406,155 +1471,28 @@ var AppSidebar = memo(function AppSidebar2({
1406
1471
  ] });
1407
1472
  });
1408
1473
 
1409
- // src/components/composed/header-tabs.tsx
1410
- import Link2 from "next/link";
1411
- import { usePathname as usePathname2 } from "next/navigation";
1474
+ // src/components/composed/data-table/data-table.tsx
1475
+ import {
1476
+ flexRender as flexRender3,
1477
+ useTable
1478
+ } from "@tanstack/react-table";
1479
+ import { FolderOpenIcon } from "lucide-react";
1480
+ import { useMemo as useMemo3, useState as useState5 } from "react";
1481
+
1482
+ // src/components/composed/state-empty.tsx
1412
1483
  import { memo as memo2 } from "react";
1413
1484
 
1414
- // src/components/ui/tabs.tsx
1415
- import { Tabs as TabsPrimitive } from "@base-ui/react/tabs";
1485
+ // src/components/ui/empty.tsx
1416
1486
  import { cva as cva3 } from "class-variance-authority";
1417
1487
  import { cn as cn12 } from "cn";
1418
1488
  import { jsx as jsx13 } from "react/jsx-runtime";
1419
- function Tabs(_a) {
1420
- var _b = _a, {
1421
- className,
1422
- orientation = "horizontal"
1423
- } = _b, props = __objRest(_b, [
1424
- "className",
1425
- "orientation"
1426
- ]);
1427
- return /* @__PURE__ */ jsx13(
1428
- TabsPrimitive.Root,
1429
- __spreadValues({
1430
- "data-slot": "tabs",
1431
- "data-orientation": orientation,
1432
- className: cn12(
1433
- "group/tabs flex gap-2 data-horizontal:flex-col",
1434
- className
1435
- )
1436
- }, props)
1437
- );
1438
- }
1439
- var tabsListVariants = cva3(
1440
- "group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none",
1441
- {
1442
- variants: {
1443
- variant: {
1444
- default: "bg-muted",
1445
- line: "gap-1 bg-transparent"
1446
- }
1447
- },
1448
- defaultVariants: {
1449
- variant: "default"
1450
- }
1451
- }
1452
- );
1453
- function TabsList(_a) {
1454
- var _b = _a, {
1455
- className,
1456
- variant = "default"
1457
- } = _b, props = __objRest(_b, [
1458
- "className",
1459
- "variant"
1460
- ]);
1461
- return /* @__PURE__ */ jsx13(
1462
- TabsPrimitive.List,
1463
- __spreadValues({
1464
- "data-slot": "tabs-list",
1465
- "data-variant": variant,
1466
- className: cn12(tabsListVariants({ variant }), className)
1467
- }, props)
1468
- );
1469
- }
1470
- function TabsTrigger(_a) {
1471
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1472
- return /* @__PURE__ */ jsx13(
1473
- TabsPrimitive.Tab,
1474
- __spreadValues({
1475
- "data-slot": "tabs-trigger",
1476
- className: cn12(
1477
- "relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-xs font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start group-data-vertical/tabs:py-[calc(--spacing(1.25))] hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
1478
- "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent",
1479
- "data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground",
1480
- "after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",
1481
- className
1482
- )
1483
- }, props)
1484
- );
1485
- }
1486
-
1487
- // src/components/composed/header-tabs.tsx
1488
- import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
1489
- function renderTabIcon(icon) {
1490
- if (!icon) return null;
1491
- if (typeof icon === "function" || typeof icon === "object" && icon !== null && "render" in icon) {
1492
- const IconComp = icon;
1493
- return /* @__PURE__ */ jsx14(IconComp, {});
1494
- }
1495
- return icon;
1496
- }
1497
- var HeaderTabs = memo2(function HeaderTabs2({
1498
- items,
1499
- value,
1500
- onValueChange,
1501
- children
1502
- }) {
1503
- var _a, _b;
1504
- const pathname = usePathname2();
1505
- const matchedItem = pathname ? items.find(
1506
- (item) => item.url === pathname || pathname.endsWith(item.url) || pathname.split("/").includes(item.value)
1507
- ) : void 0;
1508
- const activeTab = (_b = value != null ? value : matchedItem == null ? void 0 : matchedItem.value) != null ? _b : (_a = items[0]) == null ? void 0 : _a.value;
1509
- return /* @__PURE__ */ jsxs8(Tabs, { value: activeTab, onValueChange, className: "space-y-4", children: [
1510
- /* @__PURE__ */ jsx14("div", { className: "w-full overflow-x-auto overflow-y-hidden border-b no-scrollbar", children: /* @__PURE__ */ jsx14(TabsList, { variant: "line", className: "inline-flex w-max justify-start", children: items.map(({ title, value: tabValue, url, icon }) => /* @__PURE__ */ jsxs8(
1511
- TabsTrigger,
1512
- {
1513
- nativeButton: false,
1514
- render: /* @__PURE__ */ jsx14(Link2, { href: url }),
1515
- value: tabValue,
1516
- children: [
1517
- renderTabIcon(icon),
1518
- title
1519
- ]
1520
- },
1521
- tabValue
1522
- )) }) }),
1523
- children
1524
- ] });
1525
- });
1526
-
1527
- // src/components/composed/header-title.tsx
1528
- import { memo as memo3 } from "react";
1529
- import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
1530
- var HeaderTitle = memo3(function HeaderTitle2({
1531
- title,
1532
- subtitle,
1533
- children
1534
- }) {
1535
- return /* @__PURE__ */ jsxs9("div", { className: "w-full space-y-4", children: [
1536
- /* @__PURE__ */ jsxs9("div", { children: [
1537
- /* @__PURE__ */ jsx15("h1", { className: "font-semibold", children: title }),
1538
- /* @__PURE__ */ jsx15("p", { className: "text-xs text-muted-foreground", children: subtitle })
1539
- ] }),
1540
- children
1541
- ] });
1542
- });
1543
-
1544
- // src/components/composed/state-empty.tsx
1545
- import { memo as memo4 } from "react";
1546
-
1547
- // src/components/ui/empty.tsx
1548
- import { cva as cva4 } from "class-variance-authority";
1549
- import { cn as cn13 } from "cn";
1550
- import { jsx as jsx16 } from "react/jsx-runtime";
1551
1489
  function Empty(_a) {
1552
1490
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1553
- return /* @__PURE__ */ jsx16(
1491
+ return /* @__PURE__ */ jsx13(
1554
1492
  "div",
1555
1493
  __spreadValues({
1556
1494
  "data-slot": "empty",
1557
- className: cn13(
1495
+ className: cn12(
1558
1496
  "flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance",
1559
1497
  className
1560
1498
  )
@@ -1563,15 +1501,15 @@ function Empty(_a) {
1563
1501
  }
1564
1502
  function EmptyHeader(_a) {
1565
1503
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1566
- return /* @__PURE__ */ jsx16(
1504
+ return /* @__PURE__ */ jsx13(
1567
1505
  "div",
1568
1506
  __spreadValues({
1569
1507
  "data-slot": "empty-header",
1570
- className: cn13("flex max-w-sm flex-col items-center gap-1", className)
1508
+ className: cn12("flex max-w-sm flex-col items-center gap-1", className)
1571
1509
  }, props)
1572
1510
  );
1573
1511
  }
1574
- var emptyMediaVariants = cva4(
1512
+ var emptyMediaVariants = cva3(
1575
1513
  "mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",
1576
1514
  {
1577
1515
  variants: {
@@ -1593,22 +1531,22 @@ function EmptyMedia(_a) {
1593
1531
  "className",
1594
1532
  "variant"
1595
1533
  ]);
1596
- return /* @__PURE__ */ jsx16(
1534
+ return /* @__PURE__ */ jsx13(
1597
1535
  "div",
1598
1536
  __spreadValues({
1599
1537
  "data-slot": "empty-icon",
1600
1538
  "data-variant": variant,
1601
- className: cn13(emptyMediaVariants({ variant, className }))
1539
+ className: cn12(emptyMediaVariants({ variant, className }))
1602
1540
  }, props)
1603
1541
  );
1604
1542
  }
1605
1543
  function EmptyTitle(_a) {
1606
1544
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1607
- return /* @__PURE__ */ jsx16(
1545
+ return /* @__PURE__ */ jsx13(
1608
1546
  "div",
1609
1547
  __spreadValues({
1610
1548
  "data-slot": "empty-title",
1611
- className: cn13(
1549
+ className: cn12(
1612
1550
  "font-heading text-sm font-medium tracking-tight",
1613
1551
  className
1614
1552
  )
@@ -1617,11 +1555,11 @@ function EmptyTitle(_a) {
1617
1555
  }
1618
1556
  function EmptyDescription(_a) {
1619
1557
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1620
- return /* @__PURE__ */ jsx16(
1558
+ return /* @__PURE__ */ jsx13(
1621
1559
  "div",
1622
1560
  __spreadValues({
1623
1561
  "data-slot": "empty-description",
1624
- className: cn13(
1562
+ className: cn12(
1625
1563
  "text-xs/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
1626
1564
  className
1627
1565
  )
@@ -1630,11 +1568,11 @@ function EmptyDescription(_a) {
1630
1568
  }
1631
1569
  function EmptyContent(_a) {
1632
1570
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1633
- return /* @__PURE__ */ jsx16(
1571
+ return /* @__PURE__ */ jsx13(
1634
1572
  "div",
1635
1573
  __spreadValues({
1636
1574
  "data-slot": "empty-content",
1637
- className: cn13(
1575
+ className: cn12(
1638
1576
  "flex w-full max-w-sm min-w-0 flex-col items-center gap-2 text-xs/relaxed text-balance",
1639
1577
  className
1640
1578
  )
@@ -1642,43 +1580,1959 @@ function EmptyContent(_a) {
1642
1580
  );
1643
1581
  }
1644
1582
 
1583
+ // src/lib/utils.ts
1584
+ import { cn as cn13 } from "cn";
1585
+
1645
1586
  // src/components/composed/state-empty.tsx
1646
- import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
1587
+ import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
1647
1588
  function renderStateIcon(icon) {
1648
1589
  if (typeof icon === "function" || typeof icon === "object" && icon !== null && "render" in icon) {
1649
1590
  const IconComp = icon;
1650
- return /* @__PURE__ */ jsx17(IconComp, {});
1591
+ return /* @__PURE__ */ jsx14(IconComp, {});
1651
1592
  }
1652
1593
  return icon;
1653
1594
  }
1654
- var StateEmpty = memo4(function StateEmpty2({
1595
+ var StateEmpty = memo2(function StateEmpty2({
1655
1596
  icon,
1656
1597
  title,
1657
1598
  description,
1658
1599
  buttonText,
1659
- render
1600
+ onClick,
1601
+ render,
1602
+ state = "default"
1660
1603
  }) {
1661
- return /* @__PURE__ */ jsxs10(Empty, { className: "w-full border border-dashed", children: [
1662
- /* @__PURE__ */ jsxs10(EmptyHeader, { children: [
1663
- /* @__PURE__ */ jsx17(EmptyMedia, { variant: "icon", children: renderStateIcon(icon) }),
1664
- /* @__PURE__ */ jsx17(EmptyTitle, { children: title }),
1665
- /* @__PURE__ */ jsx17(EmptyDescription, { children: description })
1666
- ] }),
1667
- /* @__PURE__ */ jsx17(EmptyContent, { children: /* @__PURE__ */ jsx17(
1668
- Button,
1669
- {
1670
- variant: "outline",
1671
- size: "sm",
1672
- nativeButton: !render,
1673
- render,
1674
- children: buttonText
1604
+ const isFunctionAction = typeof render === "function";
1605
+ const actionHandler = isFunctionAction ? render : onClick;
1606
+ const buttonRender = isFunctionAction ? void 0 : render;
1607
+ const hasAction = Boolean(buttonText || render || onClick);
1608
+ return /* @__PURE__ */ jsxs8(
1609
+ Empty,
1610
+ {
1611
+ className: cn13("w-full", state === "outline" && "border border-dashed"),
1612
+ children: [
1613
+ /* @__PURE__ */ jsxs8(EmptyHeader, { children: [
1614
+ /* @__PURE__ */ jsx14(EmptyMedia, { variant: "icon", children: renderStateIcon(icon) }),
1615
+ /* @__PURE__ */ jsx14(EmptyTitle, { children: title }),
1616
+ /* @__PURE__ */ jsx14(EmptyDescription, { children: description })
1617
+ ] }),
1618
+ hasAction && /* @__PURE__ */ jsx14(EmptyContent, { children: /* @__PURE__ */ jsx14(
1619
+ Button,
1620
+ {
1621
+ variant: "outline",
1622
+ size: "sm",
1623
+ nativeButton: !buttonRender,
1624
+ onClick: actionHandler,
1625
+ render: buttonRender,
1626
+ children: buttonText
1627
+ }
1628
+ ) })
1629
+ ]
1630
+ }
1631
+ );
1632
+ });
1633
+
1634
+ // src/components/ui/table.tsx
1635
+ import { cn as cn14 } from "cn";
1636
+ import { jsx as jsx15 } from "react/jsx-runtime";
1637
+ function Table(_a) {
1638
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1639
+ return /* @__PURE__ */ jsx15(
1640
+ "div",
1641
+ {
1642
+ "data-slot": "table-container",
1643
+ className: "relative w-full overflow-x-auto",
1644
+ children: /* @__PURE__ */ jsx15(
1645
+ "table",
1646
+ __spreadValues({
1647
+ "data-slot": "table",
1648
+ className: cn14("w-full caption-bottom text-xs", className)
1649
+ }, props)
1650
+ )
1651
+ }
1652
+ );
1653
+ }
1654
+ function TableHeader(_a) {
1655
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1656
+ return /* @__PURE__ */ jsx15(
1657
+ "thead",
1658
+ __spreadValues({
1659
+ "data-slot": "table-header",
1660
+ className: cn14("[&_tr]:border-b", className)
1661
+ }, props)
1662
+ );
1663
+ }
1664
+ function TableBody(_a) {
1665
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1666
+ return /* @__PURE__ */ jsx15(
1667
+ "tbody",
1668
+ __spreadValues({
1669
+ "data-slot": "table-body",
1670
+ className: cn14("[&_tr:last-child]:border-0", className)
1671
+ }, props)
1672
+ );
1673
+ }
1674
+ function TableRow(_a) {
1675
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1676
+ return /* @__PURE__ */ jsx15(
1677
+ "tr",
1678
+ __spreadValues({
1679
+ "data-slot": "table-row",
1680
+ className: cn14(
1681
+ "border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",
1682
+ className
1683
+ )
1684
+ }, props)
1685
+ );
1686
+ }
1687
+ function TableHead(_a) {
1688
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1689
+ return /* @__PURE__ */ jsx15(
1690
+ "th",
1691
+ __spreadValues({
1692
+ "data-slot": "table-head",
1693
+ className: cn14(
1694
+ "h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",
1695
+ className
1696
+ )
1697
+ }, props)
1698
+ );
1699
+ }
1700
+ function TableCell(_a) {
1701
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1702
+ return /* @__PURE__ */ jsx15(
1703
+ "td",
1704
+ __spreadValues({
1705
+ "data-slot": "table-cell",
1706
+ className: cn14(
1707
+ "p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",
1708
+ className
1709
+ )
1710
+ }, props)
1711
+ );
1712
+ }
1713
+
1714
+ // src/components/composed/data-table/data-table-features.ts
1715
+ import {
1716
+ columnFilteringFeature,
1717
+ columnVisibilityFeature,
1718
+ createFilteredRowModel,
1719
+ createPaginatedRowModel,
1720
+ createSortedRowModel,
1721
+ filterFn_includesString,
1722
+ globalFilteringFeature,
1723
+ rowPaginationFeature,
1724
+ rowSelectionFeature,
1725
+ rowSortingFeature,
1726
+ sortFn_alphanumeric,
1727
+ sortFn_text,
1728
+ tableFeatures
1729
+ } from "@tanstack/react-table";
1730
+ var features = tableFeatures({
1731
+ // Filter features
1732
+ columnFilteringFeature,
1733
+ globalFilteringFeature,
1734
+ // Visibility & selection features
1735
+ columnVisibilityFeature,
1736
+ rowSelectionFeature,
1737
+ // Pagination & sorting features
1738
+ rowPaginationFeature,
1739
+ rowSortingFeature,
1740
+ // Row models
1741
+ filteredRowModel: createFilteredRowModel(),
1742
+ paginatedRowModel: createPaginatedRowModel(),
1743
+ sortedRowModel: createSortedRowModel(),
1744
+ // Custom/standard functions
1745
+ filterFns: {
1746
+ includesString: filterFn_includesString
1747
+ },
1748
+ sortFns: {
1749
+ alphanumeric: sortFn_alphanumeric,
1750
+ text: sortFn_text
1751
+ }
1752
+ });
1753
+
1754
+ // src/components/composed/data-table/table-content-body.tsx
1755
+ import {
1756
+ flexRender
1757
+ } from "@tanstack/react-table";
1758
+ import { SearchXIcon } from "lucide-react";
1759
+ import { jsx as jsx16 } from "react/jsx-runtime";
1760
+ function DataTableContentBody({
1761
+ table,
1762
+ columns
1763
+ }) {
1764
+ const rows = table.getRowModel().rows;
1765
+ if (rows == null ? void 0 : rows.length) {
1766
+ return /* @__PURE__ */ jsx16(TableBody, { children: rows.map((row) => /* @__PURE__ */ jsx16(TableRow, { children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx16(TableCell, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id)) }, row.id)) });
1767
+ }
1768
+ return /* @__PURE__ */ jsx16(TableBody, { children: /* @__PURE__ */ jsx16(TableRow, { children: /* @__PURE__ */ jsx16(TableCell, { colSpan: columns.length, className: "h-48 text-center", children: /* @__PURE__ */ jsx16(
1769
+ StateEmpty,
1770
+ {
1771
+ icon: /* @__PURE__ */ jsx16(SearchXIcon, {}),
1772
+ title: "No matching results",
1773
+ description: "No records matched your search query or filter criteria.",
1774
+ buttonText: "Clear search & filters",
1775
+ render: () => {
1776
+ table.setGlobalFilter("");
1777
+ table.resetColumnFilters();
1675
1778
  }
1676
- ) })
1779
+ }
1780
+ ) }) }) });
1781
+ }
1782
+
1783
+ // src/components/composed/data-table/table-content-header.tsx
1784
+ import { flexRender as flexRender2 } from "@tanstack/react-table";
1785
+ import { jsx as jsx17 } from "react/jsx-runtime";
1786
+ function DataTableContentHeader({
1787
+ table
1788
+ }) {
1789
+ return /* @__PURE__ */ jsx17(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx17(TableRow, { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx17(TableHead, { children: header.isPlaceholder ? null : flexRender2(
1790
+ header.column.columnDef.header,
1791
+ header.getContext()
1792
+ ) }, header.id)) }, headerGroup.id)) });
1793
+ }
1794
+
1795
+ // src/components/composed/data-table/table-footer-entries.tsx
1796
+ import { jsx as jsx18, jsxs as jsxs9 } from "react/jsx-runtime";
1797
+ function DataTableFooterEntries({
1798
+ table
1799
+ }) {
1800
+ var _a, _b, _c;
1801
+ const pagination = (_a = table.options.state) == null ? void 0 : _a.pagination;
1802
+ const pageIndex = (_b = pagination == null ? void 0 : pagination.pageIndex) != null ? _b : 0;
1803
+ const pageSize = (_c = pagination == null ? void 0 : pagination.pageSize) != null ? _c : 10;
1804
+ const totalRows = table.getFilteredRowModel().rows.length;
1805
+ const startRow = totalRows === 0 ? 0 : pageIndex * pageSize + 1;
1806
+ const endRow = Math.min((pageIndex + 1) * pageSize, totalRows);
1807
+ return /* @__PURE__ */ jsxs9("div", { className: "flex-1 text-xs text-muted-foreground", children: [
1808
+ "Showing",
1809
+ " ",
1810
+ /* @__PURE__ */ jsxs9("span", { className: "font-medium text-foreground", children: [
1811
+ startRow,
1812
+ "-",
1813
+ endRow
1814
+ ] }),
1815
+ " ",
1816
+ "of ",
1817
+ /* @__PURE__ */ jsx18("span", { className: "font-medium text-foreground", children: totalRows }),
1818
+ " ",
1819
+ "entries."
1820
+ ] });
1821
+ }
1822
+
1823
+ // src/components/composed/data-table/table-footer-pagination.tsx
1824
+ import {
1825
+ ChevronLeftIcon,
1826
+ ChevronRightIcon as ChevronRightIcon3,
1827
+ ChevronsLeftIcon,
1828
+ ChevronsRightIcon
1829
+ } from "lucide-react";
1830
+ import { jsx as jsx19, jsxs as jsxs10 } from "react/jsx-runtime";
1831
+ function DataTableFooterPagination({
1832
+ table
1833
+ }) {
1834
+ return /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-1", children: [
1835
+ /* @__PURE__ */ jsxs10(Tooltip, { children: [
1836
+ /* @__PURE__ */ jsx19(
1837
+ TooltipTrigger,
1838
+ {
1839
+ render: /* @__PURE__ */ jsx19(
1840
+ Button,
1841
+ {
1842
+ variant: "outline",
1843
+ size: "icon-xs",
1844
+ onClick: () => table.firstPage(),
1845
+ disabled: !table.getCanPreviousPage(),
1846
+ children: /* @__PURE__ */ jsx19(ChevronsLeftIcon, {})
1847
+ }
1848
+ )
1849
+ }
1850
+ ),
1851
+ /* @__PURE__ */ jsx19(TooltipContent, { children: "Go to first page" })
1852
+ ] }),
1853
+ /* @__PURE__ */ jsxs10(Tooltip, { children: [
1854
+ /* @__PURE__ */ jsx19(
1855
+ TooltipTrigger,
1856
+ {
1857
+ render: /* @__PURE__ */ jsx19(
1858
+ Button,
1859
+ {
1860
+ variant: "outline",
1861
+ size: "icon-xs",
1862
+ onClick: () => table.previousPage(),
1863
+ disabled: !table.getCanPreviousPage(),
1864
+ children: /* @__PURE__ */ jsx19(ChevronLeftIcon, {})
1865
+ }
1866
+ )
1867
+ }
1868
+ ),
1869
+ /* @__PURE__ */ jsx19(TooltipContent, { children: "Go to previous page" })
1870
+ ] }),
1871
+ /* @__PURE__ */ jsxs10(Tooltip, { children: [
1872
+ /* @__PURE__ */ jsx19(
1873
+ TooltipTrigger,
1874
+ {
1875
+ render: /* @__PURE__ */ jsx19(
1876
+ Button,
1877
+ {
1878
+ variant: "outline",
1879
+ size: "icon-xs",
1880
+ onClick: () => table.nextPage(),
1881
+ disabled: !table.getCanNextPage(),
1882
+ children: /* @__PURE__ */ jsx19(ChevronRightIcon3, {})
1883
+ }
1884
+ )
1885
+ }
1886
+ ),
1887
+ /* @__PURE__ */ jsx19(TooltipContent, { children: "Go to next page" })
1888
+ ] }),
1889
+ /* @__PURE__ */ jsxs10(Tooltip, { children: [
1890
+ /* @__PURE__ */ jsx19(
1891
+ TooltipTrigger,
1892
+ {
1893
+ render: /* @__PURE__ */ jsx19(
1894
+ Button,
1895
+ {
1896
+ variant: "outline",
1897
+ size: "icon-xs",
1898
+ onClick: () => table.lastPage(),
1899
+ disabled: !table.getCanNextPage(),
1900
+ children: /* @__PURE__ */ jsx19(ChevronsRightIcon, {})
1901
+ }
1902
+ )
1903
+ }
1904
+ ),
1905
+ /* @__PURE__ */ jsx19(TooltipContent, { children: "Go to last page" })
1906
+ ] })
1907
+ ] });
1908
+ }
1909
+
1910
+ // src/components/composed/data-table/table-header-add.tsx
1911
+ import { PlusIcon } from "lucide-react";
1912
+ import { Fragment, jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
1913
+ function DataTableHeaderAdd({
1914
+ onAdd,
1915
+ addLabel
1916
+ }) {
1917
+ return /* @__PURE__ */ jsxs11(Fragment, { children: [
1918
+ /* @__PURE__ */ jsxs11(Tooltip, { children: [
1919
+ /* @__PURE__ */ jsx20(
1920
+ TooltipTrigger,
1921
+ {
1922
+ className: "flex sm:hidden",
1923
+ render: /* @__PURE__ */ jsx20(Button, { variant: "default", size: "icon", onClick: onAdd, children: /* @__PURE__ */ jsx20(PlusIcon, {}) })
1924
+ }
1925
+ ),
1926
+ /* @__PURE__ */ jsx20(TooltipContent, { children: addLabel != null ? addLabel : "Add" })
1927
+ ] }),
1928
+ /* @__PURE__ */ jsxs11(Button, { variant: "default", onClick: onAdd, className: "hidden sm:flex", children: [
1929
+ /* @__PURE__ */ jsx20(PlusIcon, {}),
1930
+ addLabel != null ? addLabel : "Add"
1931
+ ] })
1932
+ ] });
1933
+ }
1934
+
1935
+ // src/components/composed/data-table/table-header-download.tsx
1936
+ import {
1937
+ DownloadIcon,
1938
+ FileCodeIcon,
1939
+ FileSpreadsheetIcon,
1940
+ FileTextIcon,
1941
+ PrinterIcon
1942
+ } from "lucide-react";
1943
+
1944
+ // src/components/composed/data-table/export.ts
1945
+ import * as XLSX from "xlsx";
1946
+ function normalizeRows(rows) {
1947
+ return rows.map((row) => {
1948
+ var _a, _b, _c;
1949
+ const flat = {};
1950
+ for (const [key, value] of Object.entries(row)) {
1951
+ if (value === null || value === void 0) {
1952
+ flat[key] = "";
1953
+ } else if (Array.isArray(value)) {
1954
+ flat[key] = value.map((item) => {
1955
+ var _a2, _b2, _c2;
1956
+ if (item === null || item === void 0) return "";
1957
+ if (typeof item === "object") {
1958
+ const record = item;
1959
+ return (_c2 = (_b2 = (_a2 = record.name) != null ? _a2 : record.label) != null ? _b2 : record.email) != null ? _c2 : JSON.stringify(item);
1960
+ }
1961
+ return String(item);
1962
+ }).filter(Boolean).join(", ");
1963
+ } else if (typeof value === "object") {
1964
+ const record = value;
1965
+ flat[key] = (_c = (_b = (_a = record.name) != null ? _a : record.label) != null ? _b : record.email) != null ? _c : JSON.stringify(value);
1966
+ } else {
1967
+ flat[key] = String(value);
1968
+ }
1969
+ }
1970
+ return flat;
1971
+ });
1972
+ }
1973
+ function escapeHtml(str) {
1974
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
1975
+ }
1976
+ function exportToXLSX(rows, filename = "data-export") {
1977
+ const normalized = normalizeRows(rows);
1978
+ const worksheet = XLSX.utils.json_to_sheet(normalized);
1979
+ const workbook = XLSX.utils.book_new();
1980
+ XLSX.utils.book_append_sheet(workbook, worksheet, "Sheet1");
1981
+ const finalFilename = filename.endsWith(".xlsx") ? filename : `${filename}.xlsx`;
1982
+ XLSX.writeFile(workbook, finalFilename);
1983
+ }
1984
+ function exportToCSV(rows, filename = "data-export") {
1985
+ const normalized = normalizeRows(rows);
1986
+ const worksheet = XLSX.utils.json_to_sheet(normalized);
1987
+ const csvString = XLSX.utils.sheet_to_csv(worksheet);
1988
+ const blob = new Blob([`\uFEFF${csvString}`], {
1989
+ type: "text/csv;charset=utf-8;"
1990
+ });
1991
+ const url = URL.createObjectURL(blob);
1992
+ const link = document.createElement("a");
1993
+ link.href = url;
1994
+ const finalFilename = filename.endsWith(".csv") ? filename : `${filename}.csv`;
1995
+ link.setAttribute("download", finalFilename);
1996
+ document.body.appendChild(link);
1997
+ link.click();
1998
+ document.body.removeChild(link);
1999
+ setTimeout(() => {
2000
+ URL.revokeObjectURL(url);
2001
+ }, 1e3);
2002
+ }
2003
+ async function exportToPDF(headers, rows, filename = "data-export", title = "Data Export") {
2004
+ const [{ jsPDF }, autoTableMod] = await Promise.all([
2005
+ import("jspdf"),
2006
+ import("jspdf-autotable")
2007
+ ]);
2008
+ const autoTable = autoTableMod.autoTable || autoTableMod.default;
2009
+ const orientation = headers.length > 5 ? "landscape" : "portrait";
2010
+ const doc = new jsPDF({ orientation });
2011
+ doc.setFontSize(14);
2012
+ doc.setFont("helvetica", "bold");
2013
+ doc.text(title, 14, 15);
2014
+ doc.setFontSize(8);
2015
+ doc.setFont("helvetica", "normal");
2016
+ doc.setTextColor(120);
2017
+ doc.text(`Generated on ${(/* @__PURE__ */ new Date()).toLocaleString()}`, 14, 20);
2018
+ autoTable(doc, {
2019
+ head: [headers],
2020
+ body: rows,
2021
+ startY: 24,
2022
+ styles: {
2023
+ fontSize: 8,
2024
+ cellPadding: 2.5
2025
+ },
2026
+ headStyles: {
2027
+ fillColor: [40, 40, 40],
2028
+ textColor: [255, 255, 255],
2029
+ fontStyle: "bold"
2030
+ },
2031
+ alternateRowStyles: {
2032
+ fillColor: [248, 248, 248]
2033
+ }
2034
+ });
2035
+ const finalFilename = filename.endsWith(".pdf") ? filename : `${filename}.pdf`;
2036
+ doc.save(finalFilename);
2037
+ }
2038
+ function printTable(headers, rows, title = "Data Export") {
2039
+ let tableHtml = `<table style="width:100%; border-collapse:collapse; font-family:sans-serif; font-size:12px;"><thead><tr>`;
2040
+ for (const header of headers) {
2041
+ tableHtml += `<th style="border:1px solid #ddd; padding:8px; background-color:#f8f9fa; text-align:left;">${escapeHtml(header)}</th>`;
2042
+ }
2043
+ tableHtml += `</tr></thead><tbody>`;
2044
+ for (const row of rows) {
2045
+ tableHtml += `<tr>`;
2046
+ for (const cell of row) {
2047
+ tableHtml += `<td style="border:1px solid #ddd; padding:8px;">${escapeHtml(cell != null ? cell : "")}</td>`;
2048
+ }
2049
+ tableHtml += `</tr>`;
2050
+ }
2051
+ tableHtml += `</tbody></table>`;
2052
+ const printWindow = window.open("", "_blank");
2053
+ if (!printWindow) return;
2054
+ printWindow.document.write(`
2055
+ <!DOCTYPE html>
2056
+ <html>
2057
+ <head>
2058
+ <title>${escapeHtml(title)}</title>
2059
+ <style>
2060
+ body { font-family: sans-serif; padding: 20px; color: #333; }
2061
+ h2 { margin-bottom: 6px; font-size: 18px; }
2062
+ .meta { font-size: 11px; color: #666; margin-bottom: 16px; }
2063
+ @page { size: auto; margin: 15mm; }
2064
+ </style>
2065
+ </head>
2066
+ <body>
2067
+ <h2>${escapeHtml(title)}</h2>
2068
+ <div class="meta">Generated on ${(/* @__PURE__ */ new Date()).toLocaleString()}</div>
2069
+ ${tableHtml}
2070
+ </body>
2071
+ </html>
2072
+ `);
2073
+ printWindow.document.close();
2074
+ printWindow.focus();
2075
+ setTimeout(() => {
2076
+ printWindow.print();
2077
+ printWindow.close();
2078
+ }, 250);
2079
+ }
2080
+
2081
+ // src/components/composed/data-table/table-header-download.tsx
2082
+ import { jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
2083
+ function getTableExportData(table) {
2084
+ const columns = table.getAllColumns().filter(
2085
+ (col) => typeof col.accessorFn !== "undefined" && col.getIsVisible()
2086
+ );
2087
+ const headers = columns.map(
2088
+ (col) => typeof col.columnDef.header === "string" ? col.columnDef.header : col.id
2089
+ );
2090
+ const filteredRows = table.getFilteredRowModel().rows;
2091
+ const rows = filteredRows.map(
2092
+ (row) => headers.map((_, i) => {
2093
+ var _a, _b;
2094
+ const col = columns[i];
2095
+ const value = row.getValue(col.id);
2096
+ if (value === null || value === void 0) return "";
2097
+ if (Array.isArray(value)) {
2098
+ return value.map(
2099
+ (item) => {
2100
+ var _a2, _b2;
2101
+ return typeof item === "object" && item !== null ? (_b2 = (_a2 = item.name) != null ? _a2 : item.email) != null ? _b2 : JSON.stringify(item) : String(item);
2102
+ }
2103
+ ).join(", ");
2104
+ }
2105
+ if (typeof value === "object") {
2106
+ return (_b = (_a = value.name) != null ? _a : value.email) != null ? _b : JSON.stringify(value);
2107
+ }
2108
+ return String(value);
2109
+ })
2110
+ );
2111
+ const rowObjects = filteredRows.map((_, rowIndex) => {
2112
+ const obj = {};
2113
+ for (let i = 0; i < columns.length; i++) {
2114
+ obj[headers[i]] = rows[rowIndex][i];
2115
+ }
2116
+ return obj;
2117
+ });
2118
+ return { headers, rows, rowObjects };
2119
+ }
2120
+ function DataTableHeaderDownload({
2121
+ table,
2122
+ exportFilename,
2123
+ onDownload
2124
+ }) {
2125
+ return /* @__PURE__ */ jsxs12(DropdownMenu, { children: [
2126
+ /* @__PURE__ */ jsxs12(Tooltip, { children: [
2127
+ /* @__PURE__ */ jsx21(
2128
+ DropdownMenuTrigger,
2129
+ {
2130
+ render: /* @__PURE__ */ jsx21(
2131
+ TooltipTrigger,
2132
+ {
2133
+ render: /* @__PURE__ */ jsx21(Button, { variant: "outline", size: "icon", children: /* @__PURE__ */ jsx21(DownloadIcon, {}) })
2134
+ }
2135
+ )
2136
+ }
2137
+ ),
2138
+ /* @__PURE__ */ jsx21(TooltipContent, { children: "Download options" })
2139
+ ] }),
2140
+ /* @__PURE__ */ jsx21(DropdownMenuContent, { align: "end", className: "w-48", children: /* @__PURE__ */ jsxs12(DropdownMenuGroup, { children: [
2141
+ /* @__PURE__ */ jsx21(DropdownMenuLabel, { children: "Download data" }),
2142
+ /* @__PURE__ */ jsx21(DropdownMenuSeparator, {}),
2143
+ /* @__PURE__ */ jsxs12(
2144
+ DropdownMenuItem,
2145
+ {
2146
+ className: "hover:cursor-pointer",
2147
+ onClick: async () => {
2148
+ const { headers, rows } = getTableExportData(table);
2149
+ await exportToPDF(headers, rows, exportFilename);
2150
+ onDownload == null ? void 0 : onDownload();
2151
+ },
2152
+ children: [
2153
+ /* @__PURE__ */ jsx21(FileTextIcon, {}),
2154
+ "Download PDF"
2155
+ ]
2156
+ }
2157
+ ),
2158
+ /* @__PURE__ */ jsxs12(
2159
+ DropdownMenuItem,
2160
+ {
2161
+ className: "hover:cursor-pointer",
2162
+ onClick: () => {
2163
+ const { rowObjects } = getTableExportData(table);
2164
+ exportToXLSX(rowObjects, exportFilename);
2165
+ onDownload == null ? void 0 : onDownload();
2166
+ },
2167
+ children: [
2168
+ /* @__PURE__ */ jsx21(FileSpreadsheetIcon, {}),
2169
+ "Download Excel"
2170
+ ]
2171
+ }
2172
+ ),
2173
+ /* @__PURE__ */ jsxs12(
2174
+ DropdownMenuItem,
2175
+ {
2176
+ className: "hover:cursor-pointer",
2177
+ onClick: () => {
2178
+ const { rowObjects } = getTableExportData(table);
2179
+ exportToCSV(rowObjects, exportFilename);
2180
+ onDownload == null ? void 0 : onDownload();
2181
+ },
2182
+ children: [
2183
+ /* @__PURE__ */ jsx21(FileCodeIcon, {}),
2184
+ "Download CSV"
2185
+ ]
2186
+ }
2187
+ ),
2188
+ /* @__PURE__ */ jsx21(DropdownMenuSeparator, {}),
2189
+ /* @__PURE__ */ jsxs12(
2190
+ DropdownMenuItem,
2191
+ {
2192
+ className: "hover:cursor-pointer",
2193
+ onClick: () => {
2194
+ const { headers, rows } = getTableExportData(table);
2195
+ printTable(headers, rows, exportFilename);
2196
+ },
2197
+ children: [
2198
+ /* @__PURE__ */ jsx21(PrinterIcon, {}),
2199
+ "Print Table"
2200
+ ]
2201
+ }
2202
+ )
2203
+ ] }) })
2204
+ ] });
2205
+ }
2206
+
2207
+ // src/components/composed/data-table/table-header-filter.tsx
2208
+ import { format } from "date-fns";
2209
+ import { CalendarIcon, ListFilterIcon } from "lucide-react";
2210
+ import { useMemo as useMemo2, useState as useState3 } from "react";
2211
+
2212
+ // src/components/ui/calendar.tsx
2213
+ import { cn as cn15 } from "cn";
2214
+ import {
2215
+ ChevronDownIcon,
2216
+ ChevronLeftIcon as ChevronLeftIcon2,
2217
+ ChevronRightIcon as ChevronRightIcon4
2218
+ } from "lucide-react";
2219
+ import * as React3 from "react";
2220
+ import {
2221
+ DayPicker,
2222
+ getDefaultClassNames
2223
+ } from "react-day-picker";
2224
+ import { jsx as jsx22 } from "react/jsx-runtime";
2225
+ function Calendar(_a) {
2226
+ var _b = _a, {
2227
+ className,
2228
+ classNames,
2229
+ showOutsideDays = true,
2230
+ captionLayout = "label",
2231
+ buttonVariant = "ghost",
2232
+ locale,
2233
+ formatters,
2234
+ components
2235
+ } = _b, props = __objRest(_b, [
2236
+ "className",
2237
+ "classNames",
2238
+ "showOutsideDays",
2239
+ "captionLayout",
2240
+ "buttonVariant",
2241
+ "locale",
2242
+ "formatters",
2243
+ "components"
2244
+ ]);
2245
+ const defaultClassNames = getDefaultClassNames();
2246
+ return /* @__PURE__ */ jsx22(
2247
+ DayPicker,
2248
+ __spreadValues({
2249
+ showOutsideDays,
2250
+ className: cn15(
2251
+ "group/calendar bg-background p-3 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(6)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent",
2252
+ String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
2253
+ String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
2254
+ className
2255
+ ),
2256
+ captionLayout,
2257
+ locale,
2258
+ formatters: __spreadValues({
2259
+ formatMonthDropdown: (date) => date.toLocaleString(locale == null ? void 0 : locale.code, { month: "short" })
2260
+ }, formatters),
2261
+ classNames: __spreadValues({
2262
+ root: cn15("w-fit", defaultClassNames.root),
2263
+ months: cn15(
2264
+ "relative flex flex-col gap-4 md:flex-row",
2265
+ defaultClassNames.months
2266
+ ),
2267
+ month: cn15("flex w-full flex-col gap-4", defaultClassNames.month),
2268
+ nav: cn15(
2269
+ "absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
2270
+ defaultClassNames.nav
2271
+ ),
2272
+ button_previous: cn15(
2273
+ buttonVariants({ variant: buttonVariant }),
2274
+ "size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
2275
+ defaultClassNames.button_previous
2276
+ ),
2277
+ button_next: cn15(
2278
+ buttonVariants({ variant: buttonVariant }),
2279
+ "size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
2280
+ defaultClassNames.button_next
2281
+ ),
2282
+ month_caption: cn15(
2283
+ "flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
2284
+ defaultClassNames.month_caption
2285
+ ),
2286
+ dropdowns: cn15(
2287
+ "flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
2288
+ defaultClassNames.dropdowns
2289
+ ),
2290
+ dropdown_root: cn15(
2291
+ "relative rounded-(--cell-radius)",
2292
+ defaultClassNames.dropdown_root
2293
+ ),
2294
+ dropdown: cn15(
2295
+ "absolute inset-0 bg-popover opacity-0",
2296
+ defaultClassNames.dropdown
2297
+ ),
2298
+ caption_label: cn15(
2299
+ "font-medium select-none",
2300
+ captionLayout === "label" ? "text-sm" : "flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
2301
+ defaultClassNames.caption_label
2302
+ ),
2303
+ month_grid: cn15("w-full border-collapse", defaultClassNames.month_grid),
2304
+ weekdays: cn15("flex", defaultClassNames.weekdays),
2305
+ weekday: cn15(
2306
+ "flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none",
2307
+ defaultClassNames.weekday
2308
+ ),
2309
+ week: cn15("mt-2 flex w-full", defaultClassNames.week),
2310
+ week_number_header: cn15(
2311
+ "w-(--cell-size) select-none",
2312
+ defaultClassNames.week_number_header
2313
+ ),
2314
+ week_number: cn15(
2315
+ "text-[0.8rem] text-muted-foreground select-none",
2316
+ defaultClassNames.week_number
2317
+ ),
2318
+ day: cn15(
2319
+ "group/day relative aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius)",
2320
+ props.showWeekNumber ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)" : "[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)",
2321
+ defaultClassNames.day
2322
+ ),
2323
+ range_start: cn15(
2324
+ "relative isolate z-0 rounded-l-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-muted",
2325
+ defaultClassNames.range_start
2326
+ ),
2327
+ range_middle: cn15("rounded-none", defaultClassNames.range_middle),
2328
+ range_end: cn15(
2329
+ "relative isolate z-0 rounded-r-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-muted",
2330
+ defaultClassNames.range_end
2331
+ ),
2332
+ today: cn15(
2333
+ "rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none",
2334
+ defaultClassNames.today
2335
+ ),
2336
+ outside: cn15(
2337
+ "text-muted-foreground aria-selected:text-muted-foreground",
2338
+ defaultClassNames.outside
2339
+ ),
2340
+ disabled: cn15(
2341
+ "text-muted-foreground opacity-50",
2342
+ defaultClassNames.disabled
2343
+ ),
2344
+ hidden: cn15("invisible", defaultClassNames.hidden)
2345
+ }, classNames),
2346
+ components: __spreadValues({
2347
+ Root: (_a2) => {
2348
+ var _b2 = _a2, { className: className2, rootRef } = _b2, props2 = __objRest(_b2, ["className", "rootRef"]);
2349
+ return /* @__PURE__ */ jsx22(
2350
+ "div",
2351
+ __spreadValues({
2352
+ "data-slot": "calendar",
2353
+ ref: rootRef,
2354
+ className: cn15(className2)
2355
+ }, props2)
2356
+ );
2357
+ },
2358
+ Chevron: (_c) => {
2359
+ var _d = _c, { className: className2, orientation } = _d, props2 = __objRest(_d, ["className", "orientation"]);
2360
+ if (orientation === "left") {
2361
+ return /* @__PURE__ */ jsx22(ChevronLeftIcon2, __spreadValues({ className: cn15("size-4", className2) }, props2));
2362
+ }
2363
+ if (orientation === "right") {
2364
+ return /* @__PURE__ */ jsx22(
2365
+ ChevronRightIcon4,
2366
+ __spreadValues({
2367
+ className: cn15("size-4", className2)
2368
+ }, props2)
2369
+ );
2370
+ }
2371
+ return /* @__PURE__ */ jsx22(ChevronDownIcon, __spreadValues({ className: cn15("size-4", className2) }, props2));
2372
+ },
2373
+ DayButton: (_e) => {
2374
+ var props2 = __objRest(_e, []);
2375
+ return /* @__PURE__ */ jsx22(CalendarDayButton, __spreadValues({ locale }, props2));
2376
+ },
2377
+ WeekNumber: (_f) => {
2378
+ var _g = _f, { children } = _g, props2 = __objRest(_g, ["children"]);
2379
+ return /* @__PURE__ */ jsx22("td", __spreadProps(__spreadValues({}, props2), { children: /* @__PURE__ */ jsx22("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children }) }));
2380
+ }
2381
+ }, components)
2382
+ }, props)
2383
+ );
2384
+ }
2385
+ function CalendarDayButton(_a) {
2386
+ var _b = _a, {
2387
+ className,
2388
+ day,
2389
+ modifiers,
2390
+ locale
2391
+ } = _b, props = __objRest(_b, [
2392
+ "className",
2393
+ "day",
2394
+ "modifiers",
2395
+ "locale"
2396
+ ]);
2397
+ const defaultClassNames = getDefaultClassNames();
2398
+ const ref = React3.useRef(null);
2399
+ React3.useEffect(() => {
2400
+ var _a2;
2401
+ if (modifiers.focused) (_a2 = ref.current) == null ? void 0 : _a2.focus();
2402
+ }, [modifiers.focused]);
2403
+ return /* @__PURE__ */ jsx22(
2404
+ Button,
2405
+ __spreadValues({
2406
+ variant: "ghost",
2407
+ size: "icon",
2408
+ "data-day": day.date.toLocaleDateString(locale == null ? void 0 : locale.code),
2409
+ "data-selected-single": modifiers.selected && !modifiers.range_start && !modifiers.range_end && !modifiers.range_middle,
2410
+ "data-range-start": modifiers.range_start,
2411
+ "data-range-end": modifiers.range_end,
2412
+ "data-range-middle": modifiers.range_middle,
2413
+ className: cn15(
2414
+ "relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-foreground [&>span]:text-xs [&>span]:opacity-70",
2415
+ defaultClassNames.day,
2416
+ className
2417
+ )
2418
+ }, props)
2419
+ );
2420
+ }
2421
+
2422
+ // src/components/ui/popover.tsx
2423
+ import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
2424
+ import { cn as cn16 } from "cn";
2425
+ import { jsx as jsx23 } from "react/jsx-runtime";
2426
+ function Popover(_a) {
2427
+ var props = __objRest(_a, []);
2428
+ return /* @__PURE__ */ jsx23(PopoverPrimitive.Root, __spreadValues({ "data-slot": "popover" }, props));
2429
+ }
2430
+ function PopoverTrigger(_a) {
2431
+ var props = __objRest(_a, []);
2432
+ return /* @__PURE__ */ jsx23(PopoverPrimitive.Trigger, __spreadValues({ "data-slot": "popover-trigger" }, props));
2433
+ }
2434
+ function PopoverContent(_a) {
2435
+ var _b = _a, {
2436
+ className,
2437
+ align = "center",
2438
+ alignOffset = 0,
2439
+ side = "bottom",
2440
+ sideOffset = 4
2441
+ } = _b, props = __objRest(_b, [
2442
+ "className",
2443
+ "align",
2444
+ "alignOffset",
2445
+ "side",
2446
+ "sideOffset"
2447
+ ]);
2448
+ return /* @__PURE__ */ jsx23(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx23(
2449
+ PopoverPrimitive.Positioner,
2450
+ {
2451
+ align,
2452
+ alignOffset,
2453
+ side,
2454
+ sideOffset,
2455
+ className: "isolate z-50",
2456
+ children: /* @__PURE__ */ jsx23(
2457
+ PopoverPrimitive.Popup,
2458
+ __spreadValues({
2459
+ "data-slot": "popover-content",
2460
+ className: cn16(
2461
+ "z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-lg bg-popover p-2.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
2462
+ className
2463
+ )
2464
+ }, props)
2465
+ )
2466
+ }
2467
+ ) });
2468
+ }
2469
+
2470
+ // src/components/ui/select.tsx
2471
+ import { Select as SelectPrimitive } from "@base-ui/react/select";
2472
+ import { cn as cn17 } from "cn";
2473
+ import { CheckIcon as CheckIcon2, ChevronDownIcon as ChevronDownIcon2, ChevronUpIcon } from "lucide-react";
2474
+ import { jsx as jsx24, jsxs as jsxs13 } from "react/jsx-runtime";
2475
+ var Select = SelectPrimitive.Root;
2476
+ function SelectValue(_a) {
2477
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
2478
+ return /* @__PURE__ */ jsx24(
2479
+ SelectPrimitive.Value,
2480
+ __spreadValues({
2481
+ "data-slot": "select-value",
2482
+ className: cn17("flex flex-1 text-left", className)
2483
+ }, props)
2484
+ );
2485
+ }
2486
+ function SelectTrigger(_a) {
2487
+ var _b = _a, {
2488
+ className,
2489
+ size = "default",
2490
+ children
2491
+ } = _b, props = __objRest(_b, [
2492
+ "className",
2493
+ "size",
2494
+ "children"
2495
+ ]);
2496
+ return /* @__PURE__ */ jsxs13(
2497
+ SelectPrimitive.Trigger,
2498
+ __spreadProps(__spreadValues({
2499
+ "data-slot": "select-trigger",
2500
+ "data-size": size,
2501
+ className: cn17(
2502
+ "flex w-fit items-center justify-between gap-1.5 rounded-md border border-input bg-input/20 px-2 py-1.5 text-xs/relaxed whitespace-nowrap transition-colors outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-7 data-[size=sm]:h-6 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
2503
+ className
2504
+ )
2505
+ }, props), {
2506
+ children: [
2507
+ children,
2508
+ /* @__PURE__ */ jsx24(
2509
+ SelectPrimitive.Icon,
2510
+ {
2511
+ render: /* @__PURE__ */ jsx24(ChevronDownIcon2, { className: "pointer-events-none size-3.5 text-muted-foreground" })
2512
+ }
2513
+ )
2514
+ ]
2515
+ })
2516
+ );
2517
+ }
2518
+ function SelectContent(_a) {
2519
+ var _b = _a, {
2520
+ className,
2521
+ children,
2522
+ side = "bottom",
2523
+ sideOffset = 4,
2524
+ align = "center",
2525
+ alignOffset = 0,
2526
+ alignItemWithTrigger = true
2527
+ } = _b, props = __objRest(_b, [
2528
+ "className",
2529
+ "children",
2530
+ "side",
2531
+ "sideOffset",
2532
+ "align",
2533
+ "alignOffset",
2534
+ "alignItemWithTrigger"
2535
+ ]);
2536
+ return /* @__PURE__ */ jsx24(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsx24(
2537
+ SelectPrimitive.Positioner,
2538
+ {
2539
+ side,
2540
+ sideOffset,
2541
+ align,
2542
+ alignOffset,
2543
+ alignItemWithTrigger,
2544
+ className: "isolate z-50",
2545
+ children: /* @__PURE__ */ jsxs13(
2546
+ SelectPrimitive.Popup,
2547
+ __spreadProps(__spreadValues({
2548
+ "data-slot": "select-content",
2549
+ "data-align-trigger": alignItemWithTrigger,
2550
+ className: cn17(
2551
+ "relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
2552
+ className
2553
+ )
2554
+ }, props), {
2555
+ children: [
2556
+ /* @__PURE__ */ jsx24(SelectScrollUpButton, {}),
2557
+ /* @__PURE__ */ jsx24(SelectPrimitive.List, { children }),
2558
+ /* @__PURE__ */ jsx24(SelectScrollDownButton, {})
2559
+ ]
2560
+ })
2561
+ )
2562
+ }
2563
+ ) });
2564
+ }
2565
+ function SelectItem(_a) {
2566
+ var _b = _a, {
2567
+ className,
2568
+ children
2569
+ } = _b, props = __objRest(_b, [
2570
+ "className",
2571
+ "children"
2572
+ ]);
2573
+ return /* @__PURE__ */ jsxs13(
2574
+ SelectPrimitive.Item,
2575
+ __spreadProps(__spreadValues({
2576
+ "data-slot": "select-item",
2577
+ className: cn17(
2578
+ "relative flex min-h-7 w-full cursor-default items-center gap-2 rounded-md px-2 py-1 text-xs/relaxed outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
2579
+ className
2580
+ )
2581
+ }, props), {
2582
+ children: [
2583
+ /* @__PURE__ */ jsx24(SelectPrimitive.ItemText, { className: "flex flex-1 shrink-0 gap-2 whitespace-nowrap", children }),
2584
+ /* @__PURE__ */ jsx24(
2585
+ SelectPrimitive.ItemIndicator,
2586
+ {
2587
+ render: /* @__PURE__ */ jsx24("span", { className: "pointer-events-none absolute right-2 flex items-center justify-center" }),
2588
+ children: /* @__PURE__ */ jsx24(CheckIcon2, { className: "pointer-events-none" })
2589
+ }
2590
+ )
2591
+ ]
2592
+ })
2593
+ );
2594
+ }
2595
+ function SelectScrollUpButton(_a) {
2596
+ var _b = _a, {
2597
+ className
2598
+ } = _b, props = __objRest(_b, [
2599
+ "className"
2600
+ ]);
2601
+ return /* @__PURE__ */ jsx24(
2602
+ SelectPrimitive.ScrollUpArrow,
2603
+ __spreadProps(__spreadValues({
2604
+ "data-slot": "select-scroll-up-button",
2605
+ className: cn17(
2606
+ "top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-3.5",
2607
+ className
2608
+ )
2609
+ }, props), {
2610
+ children: /* @__PURE__ */ jsx24(ChevronUpIcon, {})
2611
+ })
2612
+ );
2613
+ }
2614
+ function SelectScrollDownButton(_a) {
2615
+ var _b = _a, {
2616
+ className
2617
+ } = _b, props = __objRest(_b, [
2618
+ "className"
2619
+ ]);
2620
+ return /* @__PURE__ */ jsx24(
2621
+ SelectPrimitive.ScrollDownArrow,
2622
+ __spreadProps(__spreadValues({
2623
+ "data-slot": "select-scroll-down-button",
2624
+ className: cn17(
2625
+ "bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-3.5",
2626
+ className
2627
+ )
2628
+ }, props), {
2629
+ children: /* @__PURE__ */ jsx24(ChevronDownIcon2, {})
2630
+ })
2631
+ );
2632
+ }
2633
+
2634
+ // src/components/composed/data-table/table-header-filter.tsx
2635
+ import { Fragment as Fragment2, jsx as jsx25, jsxs as jsxs14 } from "react/jsx-runtime";
2636
+ function smartFilterFn(row, columnId, filterValue) {
2637
+ var _a, _b, _c;
2638
+ if (filterValue === void 0 || filterValue === null || filterValue === "" || filterValue === "all") {
2639
+ return true;
2640
+ }
2641
+ const rowValue = row.getValue(columnId);
2642
+ if (rowValue === void 0 || rowValue === null) {
2643
+ return false;
2644
+ }
2645
+ if (typeof rowValue === "boolean" || filterValue === "true" || filterValue === "false") {
2646
+ const rowBool = typeof rowValue === "boolean" ? rowValue : String(rowValue).toLowerCase() === "true" || rowValue === 1 || rowValue === "1";
2647
+ const targetBool = String(filterValue).toLowerCase() === "true";
2648
+ return rowBool === targetBool;
2649
+ }
2650
+ const isFilterDateString = typeof filterValue === "string" && /^\d{4}-\d{2}-\d{2}/.test(filterValue);
2651
+ const isFilterDateObj = filterValue instanceof Date;
2652
+ if (isFilterDateString || isFilterDateObj) {
2653
+ const targetDateStr = isFilterDateObj ? format(filterValue, "yyyy-MM-dd") : filterValue.slice(0, 10);
2654
+ let rowDateStr = "";
2655
+ if (rowValue instanceof Date) {
2656
+ rowDateStr = format(rowValue, "yyyy-MM-dd");
2657
+ } else if (typeof rowValue === "string" || typeof rowValue === "number") {
2658
+ const parsed = new Date(rowValue);
2659
+ if (!Number.isNaN(parsed.getTime())) {
2660
+ rowDateStr = format(parsed, "yyyy-MM-dd");
2661
+ }
2662
+ }
2663
+ if (rowDateStr) {
2664
+ return rowDateStr === targetDateStr;
2665
+ }
2666
+ }
2667
+ if (Array.isArray(rowValue)) {
2668
+ const targetStr2 = String(filterValue).toLowerCase();
2669
+ return rowValue.some((item) => {
2670
+ var _a2, _b2, _c2;
2671
+ if (item === null || item === void 0) return false;
2672
+ const itemStr = typeof item === "object" ? String(
2673
+ (_c2 = (_b2 = (_a2 = item.name) != null ? _a2 : item.label) != null ? _b2 : item.email) != null ? _c2 : JSON.stringify(item)
2674
+ ) : String(item);
2675
+ return itemStr.toLowerCase().includes(targetStr2);
2676
+ });
2677
+ }
2678
+ if (typeof rowValue === "object" && !(rowValue instanceof Date)) {
2679
+ const objStr = String(
2680
+ (_c = (_b = (_a = rowValue.name) != null ? _a : rowValue.label) != null ? _b : rowValue.email) != null ? _c : JSON.stringify(rowValue)
2681
+ );
2682
+ return objStr.toLowerCase().includes(String(filterValue).toLowerCase());
2683
+ }
2684
+ const rowStr = String(rowValue).toLowerCase();
2685
+ const targetStr = String(filterValue).toLowerCase();
2686
+ return rowStr.includes(targetStr);
2687
+ }
2688
+ function getColumnUniqueOptions(column, table) {
2689
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2690
+ const meta = column.columnDef.meta;
2691
+ if ((meta == null ? void 0 : meta.selectOptions) && meta.selectOptions.length > 0) {
2692
+ return meta.selectOptions;
2693
+ }
2694
+ const rows = (_d = (_c = (_a = table.getCoreRowModel) == null ? void 0 : _a.call(table).rows) != null ? _c : (_b = table.getPreFilteredRowModel) == null ? void 0 : _b.call(table).rows) != null ? _d : [];
2695
+ const uniqueSet = /* @__PURE__ */ new Set();
2696
+ const labelMap = /* @__PURE__ */ new Map();
2697
+ for (const row of rows) {
2698
+ const value = row.getValue(column.id);
2699
+ if (value === null || value === void 0 || value === "") continue;
2700
+ if (typeof value === "boolean") {
2701
+ const str = String(value);
2702
+ if (!uniqueSet.has(str)) {
2703
+ uniqueSet.add(str);
2704
+ labelMap.set(str, value ? "True / Yes" : "False / No");
2705
+ }
2706
+ } else if (Array.isArray(value)) {
2707
+ for (const item of value) {
2708
+ if (item === null || item === void 0 || item === "") continue;
2709
+ const itemStr = typeof item === "object" ? String(
2710
+ (_g = (_f = (_e = item.name) != null ? _e : item.label) != null ? _f : item.email) != null ? _g : JSON.stringify(item)
2711
+ ) : String(item);
2712
+ if (!uniqueSet.has(itemStr)) {
2713
+ uniqueSet.add(itemStr);
2714
+ labelMap.set(itemStr, itemStr);
2715
+ }
2716
+ }
2717
+ } else if (typeof value === "object") {
2718
+ const objStr = String(
2719
+ (_j = (_i = (_h = value.name) != null ? _h : value.label) != null ? _i : value.email) != null ? _j : JSON.stringify(value)
2720
+ );
2721
+ if (!uniqueSet.has(objStr)) {
2722
+ uniqueSet.add(objStr);
2723
+ labelMap.set(objStr, objStr);
2724
+ }
2725
+ } else {
2726
+ const str = String(value);
2727
+ if (!uniqueSet.has(str)) {
2728
+ uniqueSet.add(str);
2729
+ labelMap.set(str, str);
2730
+ }
2731
+ }
2732
+ if (uniqueSet.size >= 100) break;
2733
+ }
2734
+ return Array.from(uniqueSet).map((val) => {
2735
+ var _a2;
2736
+ return {
2737
+ value: String(val),
2738
+ label: String((_a2 = labelMap.get(val)) != null ? _a2 : val)
2739
+ };
2740
+ });
2741
+ }
2742
+ function getFilterVariant(column, table) {
2743
+ var _a, _b, _c, _d;
2744
+ const meta = column.columnDef.meta;
2745
+ if (meta == null ? void 0 : meta.filterVariant) return meta.filterVariant;
2746
+ const rows = (_d = (_c = (_a = table.getCoreRowModel) == null ? void 0 : _a.call(table).rows) != null ? _c : (_b = table.getPreFilteredRowModel) == null ? void 0 : _b.call(table).rows) != null ? _d : [];
2747
+ const sampleValues = [];
2748
+ for (const row of rows) {
2749
+ const val = row.getValue(column.id);
2750
+ if (val !== null && val !== void 0 && val !== "") {
2751
+ sampleValues.push(val);
2752
+ }
2753
+ if (sampleValues.length >= 100) break;
2754
+ }
2755
+ if (sampleValues.length === 0) return "text";
2756
+ const first = sampleValues[0];
2757
+ if (typeof first === "boolean" || sampleValues.every(
2758
+ (v) => typeof v === "boolean" || v === "true" || v === "false"
2759
+ )) {
2760
+ return "boolean";
2761
+ }
2762
+ if (first instanceof Date || typeof first === "string" && (first.match(/^\d{4}-\d{2}-\d{2}/) || !Number.isNaN(Date.parse(first)) && first.length >= 10 && (first.includes("-") || first.includes("/")))) {
2763
+ return "date";
2764
+ }
2765
+ const uniqueCount = new Set(sampleValues.map((v) => String(v))).size;
2766
+ if (uniqueCount > 0 && uniqueCount <= 20 && uniqueCount < sampleValues.length) {
2767
+ return "select";
2768
+ }
2769
+ return "text";
2770
+ }
2771
+ function ColumnFilterInput({
2772
+ column,
2773
+ table,
2774
+ headerText
2775
+ }) {
2776
+ const [calendarOpen, setCalendarOpen] = useState3(false);
2777
+ const filterValue = column.getFilterValue();
2778
+ const variant = useMemo2(
2779
+ () => getFilterVariant(column, table),
2780
+ [column, table]
2781
+ );
2782
+ const options = useMemo2(() => {
2783
+ if (variant === "boolean") {
2784
+ return [
2785
+ { label: "True / Yes", value: "true" },
2786
+ { label: "False / No", value: "false" }
2787
+ ];
2788
+ }
2789
+ if (variant === "select") {
2790
+ return getColumnUniqueOptions(column, table);
2791
+ }
2792
+ return [];
2793
+ }, [column, table, variant]);
2794
+ if (variant === "boolean" || variant === "select") {
2795
+ const currentValue = filterValue === void 0 || filterValue === null || filterValue === "" ? "all" : String(filterValue);
2796
+ return /* @__PURE__ */ jsx25("div", { className: "relative flex items-center w-full", children: /* @__PURE__ */ jsxs14(
2797
+ Select,
2798
+ {
2799
+ value: currentValue,
2800
+ onValueChange: (val) => {
2801
+ if (val === "all") {
2802
+ column.setFilterValue(void 0);
2803
+ } else {
2804
+ column.setFilterValue(val);
2805
+ }
2806
+ },
2807
+ children: [
2808
+ /* @__PURE__ */ jsx25(
2809
+ SelectTrigger,
2810
+ {
2811
+ className: "w-full",
2812
+ onKeyDown: (e) => e.stopPropagation(),
2813
+ onPointerDown: (e) => e.stopPropagation(),
2814
+ children: /* @__PURE__ */ jsx25(
2815
+ SelectValue,
2816
+ {
2817
+ placeholder: `Select ${headerText.toLowerCase()}...`,
2818
+ className: "capitalize"
2819
+ }
2820
+ )
2821
+ }
2822
+ ),
2823
+ /* @__PURE__ */ jsxs14(SelectContent, { align: "start", children: [
2824
+ /* @__PURE__ */ jsx25(SelectItem, { value: "all", children: "All" }),
2825
+ options.map((opt) => /* @__PURE__ */ jsx25(
2826
+ SelectItem,
2827
+ {
2828
+ value: opt.value,
2829
+ className: "capitalize",
2830
+ children: opt.label
2831
+ },
2832
+ opt.value
2833
+ ))
2834
+ ] })
2835
+ ]
2836
+ }
2837
+ ) });
2838
+ }
2839
+ if (variant === "date") {
2840
+ let dateObj;
2841
+ if (filterValue) {
2842
+ if (filterValue instanceof Date) {
2843
+ dateObj = filterValue;
2844
+ } else if (typeof filterValue === "string") {
2845
+ const parsed = new Date(filterValue);
2846
+ if (!Number.isNaN(parsed.getTime())) {
2847
+ dateObj = parsed;
2848
+ }
2849
+ }
2850
+ }
2851
+ const formattedDateLabel = dateObj ? format(dateObj, "yyyy-MM-dd") : "";
2852
+ return /* @__PURE__ */ jsx25("div", { className: "relative flex items-center w-full", children: /* @__PURE__ */ jsxs14(Popover, { open: calendarOpen, onOpenChange: setCalendarOpen, children: [
2853
+ /* @__PURE__ */ jsx25(
2854
+ PopoverTrigger,
2855
+ {
2856
+ render: /* @__PURE__ */ jsxs14(
2857
+ Button,
2858
+ {
2859
+ variant: "outline",
2860
+ className: cn13(
2861
+ "w-full justify-start",
2862
+ !formattedDateLabel && "text-muted-foreground"
2863
+ ),
2864
+ onKeyDown: (e) => e.stopPropagation(),
2865
+ onPointerDown: (e) => e.stopPropagation(),
2866
+ children: [
2867
+ /* @__PURE__ */ jsx25(CalendarIcon, { className: "mr-1 size-3 shrink-0" }),
2868
+ /* @__PURE__ */ jsx25("span", { className: "truncate", children: formattedDateLabel || `Pick ${headerText.toLowerCase()}...` })
2869
+ ]
2870
+ }
2871
+ )
2872
+ }
2873
+ ),
2874
+ /* @__PURE__ */ jsx25(
2875
+ PopoverContent,
2876
+ {
2877
+ className: "w-auto p-0",
2878
+ align: "start",
2879
+ onPointerDown: (e) => e.stopPropagation(),
2880
+ onKeyDown: (e) => e.stopPropagation(),
2881
+ children: /* @__PURE__ */ jsx25(
2882
+ Calendar,
2883
+ {
2884
+ mode: "single",
2885
+ selected: dateObj,
2886
+ onSelect: (date) => {
2887
+ if (date) {
2888
+ column.setFilterValue(format(date, "yyyy-MM-dd"));
2889
+ } else {
2890
+ column.setFilterValue(void 0);
2891
+ }
2892
+ setCalendarOpen(false);
2893
+ }
2894
+ }
2895
+ )
2896
+ }
2897
+ )
2898
+ ] }) });
2899
+ }
2900
+ return /* @__PURE__ */ jsx25("div", { className: "relative flex items-center w-full", children: /* @__PURE__ */ jsx25(
2901
+ Input,
2902
+ {
2903
+ id: `filter-${column.id}`,
2904
+ placeholder: `Filter ${headerText.toLowerCase()}...`,
2905
+ value: filterValue != null ? filterValue : "",
2906
+ onChange: (e) => column.setFilterValue(e.target.value || void 0),
2907
+ onKeyDown: (e) => e.stopPropagation(),
2908
+ onKeyUp: (e) => e.stopPropagation(),
2909
+ onPointerDown: (e) => e.stopPropagation()
2910
+ }
2911
+ ) });
2912
+ }
2913
+ function DataTableHeaderFilter({
2914
+ table,
2915
+ columnFilters
2916
+ }) {
2917
+ const filterableColumns = useMemo2(
2918
+ () => table.getAllColumns().filter(
2919
+ (column) => typeof column.accessorFn !== "undefined" && column.getCanFilter()
2920
+ ),
2921
+ [table]
2922
+ );
2923
+ if (filterableColumns.length === 0) return null;
2924
+ return /* @__PURE__ */ jsxs14(DropdownMenu, { children: [
2925
+ /* @__PURE__ */ jsxs14(Tooltip, { children: [
2926
+ /* @__PURE__ */ jsx25(
2927
+ DropdownMenuTrigger,
2928
+ {
2929
+ render: /* @__PURE__ */ jsx25(
2930
+ TooltipTrigger,
2931
+ {
2932
+ render: /* @__PURE__ */ jsx25(
2933
+ Button,
2934
+ {
2935
+ variant: columnFilters.length > 0 ? "secondary" : "outline",
2936
+ size: "icon",
2937
+ children: /* @__PURE__ */ jsx25(ListFilterIcon, {})
2938
+ }
2939
+ )
2940
+ }
2941
+ )
2942
+ }
2943
+ ),
2944
+ /* @__PURE__ */ jsx25(TooltipContent, { children: "Filter options" })
2945
+ ] }),
2946
+ /* @__PURE__ */ jsx25(DropdownMenuContent, { align: "end", className: "w-80", children: /* @__PURE__ */ jsxs14(DropdownMenuGroup, { children: [
2947
+ /* @__PURE__ */ jsx25(DropdownMenuLabel, { children: "Filter by column" }),
2948
+ /* @__PURE__ */ jsx25(DropdownMenuSeparator, {}),
2949
+ /* @__PURE__ */ jsx25("div", { className: "max-h-64 overflow-y-auto space-y-2.5 p-1", children: filterableColumns.map((column) => {
2950
+ const headerText = typeof column.columnDef.header === "string" ? column.columnDef.header : column.id;
2951
+ return /* @__PURE__ */ jsxs14(
2952
+ "div",
2953
+ {
2954
+ className: "flex items-center justify-between px-1",
2955
+ children: [
2956
+ /* @__PURE__ */ jsx25(
2957
+ "label",
2958
+ {
2959
+ htmlFor: `filter-${column.id}`,
2960
+ className: "capitalize shrink-0 min-w-20 text-xs font-medium text-muted-foreground",
2961
+ children: headerText
2962
+ }
2963
+ ),
2964
+ /* @__PURE__ */ jsx25("div", { className: "flex-1", children: /* @__PURE__ */ jsx25(
2965
+ ColumnFilterInput,
2966
+ {
2967
+ column,
2968
+ table,
2969
+ headerText
2970
+ }
2971
+ ) })
2972
+ ]
2973
+ },
2974
+ column.id
2975
+ );
2976
+ }) }),
2977
+ columnFilters.length > 0 && /* @__PURE__ */ jsxs14(Fragment2, { children: [
2978
+ /* @__PURE__ */ jsx25(DropdownMenuSeparator, {}),
2979
+ /* @__PURE__ */ jsx25(
2980
+ DropdownMenuItem,
2981
+ {
2982
+ className: "hover:cursor-pointer text-destructive focus:text-destructive",
2983
+ onClick: () => table.resetColumnFilters(),
2984
+ children: "Clear Filters"
2985
+ }
2986
+ )
2987
+ ] })
2988
+ ] }) })
2989
+ ] });
2990
+ }
2991
+
2992
+ // src/components/composed/data-table/table-header-refresh.tsx
2993
+ import { RotateCwIcon } from "lucide-react";
2994
+ import { useRouter } from "next/navigation";
2995
+ import { useState as useState4 } from "react";
2996
+ import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
2997
+ function DataTableHeaderRefresh({
2998
+ onRefresh
2999
+ }) {
3000
+ const router = useRouter();
3001
+ const [isRefreshing, setIsRefreshing] = useState4(false);
3002
+ const handleRefresh = () => {
3003
+ setIsRefreshing(true);
3004
+ if (onRefresh) {
3005
+ onRefresh();
3006
+ } else {
3007
+ router.refresh();
3008
+ }
3009
+ setTimeout(() => {
3010
+ setIsRefreshing(false);
3011
+ }, 750);
3012
+ };
3013
+ return /* @__PURE__ */ jsxs15(Tooltip, { children: [
3014
+ /* @__PURE__ */ jsx26(
3015
+ TooltipTrigger,
3016
+ {
3017
+ render: /* @__PURE__ */ jsx26(
3018
+ Button,
3019
+ {
3020
+ variant: "outline",
3021
+ size: "icon",
3022
+ onClick: handleRefresh,
3023
+ disabled: isRefreshing,
3024
+ children: /* @__PURE__ */ jsx26(
3025
+ RotateCwIcon,
3026
+ {
3027
+ className: cn13(
3028
+ "transition-transform duration-750",
3029
+ isRefreshing && "animate-spin"
3030
+ )
3031
+ }
3032
+ )
3033
+ }
3034
+ )
3035
+ }
3036
+ ),
3037
+ /* @__PURE__ */ jsx26(TooltipContent, { children: "Refresh data" })
3038
+ ] });
3039
+ }
3040
+
3041
+ // src/components/composed/data-table/table-header-search.tsx
3042
+ import { XIcon as XIcon2 } from "lucide-react";
3043
+ import { jsx as jsx27, jsxs as jsxs16 } from "react/jsx-runtime";
3044
+ function DataTableHeaderSearch({
3045
+ value = "",
3046
+ onChange
3047
+ }) {
3048
+ return /* @__PURE__ */ jsxs16("div", { className: "relative flex items-center max-w-sm w-full", children: [
3049
+ /* @__PURE__ */ jsx27(
3050
+ Input,
3051
+ {
3052
+ placeholder: "Search...",
3053
+ value: value != null ? value : "",
3054
+ onChange: (event) => onChange(event.target.value),
3055
+ className: "pr-7"
3056
+ }
3057
+ ),
3058
+ Boolean(value) && /* @__PURE__ */ jsx27(
3059
+ "button",
3060
+ {
3061
+ type: "button",
3062
+ onClick: () => onChange(""),
3063
+ className: "absolute right-2 text-muted-foreground hover:text-foreground p-0.5 rounded cursor-pointer",
3064
+ "aria-label": "Clear search text",
3065
+ children: /* @__PURE__ */ jsx27(XIcon2, { className: "size-3.5" })
3066
+ }
3067
+ )
3068
+ ] });
3069
+ }
3070
+
3071
+ // src/components/composed/data-table/table-header-sort.tsx
3072
+ import { ArrowDownIcon, ArrowUpDownIcon, ArrowUpIcon } from "lucide-react";
3073
+ import { Fragment as Fragment3, jsx as jsx28, jsxs as jsxs17 } from "react/jsx-runtime";
3074
+ function DataTableHeaderSort({
3075
+ table,
3076
+ sorting
3077
+ }) {
3078
+ const sortableColumns = table.getAllColumns().filter((column) => column.getCanSort());
3079
+ return /* @__PURE__ */ jsxs17(DropdownMenu, { children: [
3080
+ /* @__PURE__ */ jsxs17(Tooltip, { children: [
3081
+ /* @__PURE__ */ jsx28(
3082
+ DropdownMenuTrigger,
3083
+ {
3084
+ render: /* @__PURE__ */ jsx28(
3085
+ TooltipTrigger,
3086
+ {
3087
+ render: /* @__PURE__ */ jsx28(
3088
+ Button,
3089
+ {
3090
+ variant: sorting.length > 0 ? "secondary" : "outline",
3091
+ size: "icon",
3092
+ children: /* @__PURE__ */ jsx28(ArrowUpDownIcon, {})
3093
+ }
3094
+ )
3095
+ }
3096
+ )
3097
+ }
3098
+ ),
3099
+ /* @__PURE__ */ jsx28(TooltipContent, { children: "Sort options" })
3100
+ ] }),
3101
+ /* @__PURE__ */ jsx28(DropdownMenuContent, { align: "end", className: "w-48", children: /* @__PURE__ */ jsxs17(DropdownMenuGroup, { children: [
3102
+ /* @__PURE__ */ jsx28(DropdownMenuLabel, { children: "Sort by column" }),
3103
+ /* @__PURE__ */ jsx28(DropdownMenuSeparator, {}),
3104
+ sortableColumns.map((column) => {
3105
+ const isSorted = column.getIsSorted();
3106
+ const headerText = typeof column.columnDef.header === "string" ? column.columnDef.header : column.id;
3107
+ return /* @__PURE__ */ jsxs17(
3108
+ DropdownMenuItem,
3109
+ {
3110
+ className: "flex items-center justify-between hover:cursor-pointer capitalize",
3111
+ onClick: () => {
3112
+ if (isSorted === "asc") {
3113
+ column.toggleSorting(true);
3114
+ } else if (isSorted === "desc") {
3115
+ column.clearSorting();
3116
+ } else {
3117
+ column.toggleSorting(false);
3118
+ }
3119
+ },
3120
+ children: [
3121
+ headerText,
3122
+ isSorted === "asc" && /* @__PURE__ */ jsx28(ArrowUpIcon, { className: "size-3.5" }),
3123
+ isSorted === "desc" && /* @__PURE__ */ jsx28(ArrowDownIcon, { className: "size-3.5" })
3124
+ ]
3125
+ },
3126
+ column.id
3127
+ );
3128
+ }),
3129
+ sorting.length > 0 && /* @__PURE__ */ jsxs17(Fragment3, { children: [
3130
+ /* @__PURE__ */ jsx28(DropdownMenuSeparator, {}),
3131
+ /* @__PURE__ */ jsx28(
3132
+ DropdownMenuItem,
3133
+ {
3134
+ className: "hover:cursor-pointer text-destructive focus:text-destructive",
3135
+ onClick: () => table.resetSorting(),
3136
+ children: "Clear sorting"
3137
+ }
3138
+ )
3139
+ ] })
3140
+ ] }) })
3141
+ ] });
3142
+ }
3143
+
3144
+ // src/components/composed/data-table/table-header-toggle.tsx
3145
+ import { Columns3CogIcon } from "lucide-react";
3146
+ import { jsx as jsx29, jsxs as jsxs18 } from "react/jsx-runtime";
3147
+ function DataTableHeaderToggle({
3148
+ table
3149
+ }) {
3150
+ return /* @__PURE__ */ jsxs18(DropdownMenu, { children: [
3151
+ /* @__PURE__ */ jsxs18(Tooltip, { children: [
3152
+ /* @__PURE__ */ jsx29(
3153
+ DropdownMenuTrigger,
3154
+ {
3155
+ render: /* @__PURE__ */ jsx29(
3156
+ TooltipTrigger,
3157
+ {
3158
+ render: /* @__PURE__ */ jsx29(Button, { variant: "outline", size: "icon", children: /* @__PURE__ */ jsx29(Columns3CogIcon, {}) })
3159
+ }
3160
+ )
3161
+ }
3162
+ ),
3163
+ /* @__PURE__ */ jsx29(TooltipContent, { children: "Toggle columns" })
3164
+ ] }),
3165
+ /* @__PURE__ */ jsx29(DropdownMenuContent, { align: "end", className: "w-48", children: /* @__PURE__ */ jsxs18(DropdownMenuGroup, { children: [
3166
+ /* @__PURE__ */ jsx29(DropdownMenuLabel, { children: "Toggle columns" }),
3167
+ /* @__PURE__ */ jsx29(DropdownMenuSeparator, {}),
3168
+ table.getAllColumns().filter(
3169
+ (column) => typeof column.accessorFn !== "undefined" && column.getCanHide()
3170
+ ).map((column) => {
3171
+ const headerText = typeof column.columnDef.header === "string" ? column.columnDef.header : column.id;
3172
+ return /* @__PURE__ */ jsx29(
3173
+ DropdownMenuCheckboxItem,
3174
+ {
3175
+ className: "capitalize hover:cursor-pointer",
3176
+ checked: column.getIsVisible(),
3177
+ onCheckedChange: (value) => column.toggleVisibility(!!value),
3178
+ children: headerText
3179
+ },
3180
+ column.id
3181
+ );
3182
+ })
3183
+ ] }) })
3184
+ ] });
3185
+ }
3186
+
3187
+ // src/components/composed/data-table/data-row-actions.tsx
3188
+ import { MoreHorizontal } from "lucide-react";
3189
+ import { Fragment as Fragment4 } from "react";
3190
+ import { Fragment as Fragment5, jsx as jsx30, jsxs as jsxs19 } from "react/jsx-runtime";
3191
+ function RowActions({
3192
+ label = "Actions",
3193
+ items = [],
3194
+ triggerIcon,
3195
+ triggerLabel = "Open action menu",
3196
+ align = "end",
3197
+ containerClassName,
3198
+ contentClassName
3199
+ }) {
3200
+ const visibleItems = items.filter((item) => !item.hidden);
3201
+ if (visibleItems.length === 0) {
3202
+ return null;
3203
+ }
3204
+ return /* @__PURE__ */ jsx30(
3205
+ "div",
3206
+ {
3207
+ className: cn13("flex items-center justify-end w-full", containerClassName),
3208
+ children: /* @__PURE__ */ jsxs19(DropdownMenu, { children: [
3209
+ /* @__PURE__ */ jsx30(
3210
+ DropdownMenuTrigger,
3211
+ {
3212
+ render: /* @__PURE__ */ jsx30(Button, { variant: "ghost", size: "icon-xs", "aria-label": triggerLabel, children: triggerIcon != null ? triggerIcon : /* @__PURE__ */ jsx30(MoreHorizontal, { className: "size-4" }) })
3213
+ }
3214
+ ),
3215
+ /* @__PURE__ */ jsx30(
3216
+ DropdownMenuContent,
3217
+ {
3218
+ align,
3219
+ className: cn13("w-40", contentClassName),
3220
+ children: /* @__PURE__ */ jsxs19(DropdownMenuGroup, { children: [
3221
+ label && /* @__PURE__ */ jsxs19(Fragment5, { children: [
3222
+ /* @__PURE__ */ jsx30(DropdownMenuLabel, { children: label }),
3223
+ /* @__PURE__ */ jsx30(DropdownMenuSeparator, {})
3224
+ ] }),
3225
+ visibleItems.map((item, index) => {
3226
+ var _a;
3227
+ const itemKey = (_a = item.id) != null ? _a : `${item.label}-${index}`;
3228
+ const isDestructive = item.variant === "destructive";
3229
+ return /* @__PURE__ */ jsxs19(Fragment4, { children: [
3230
+ item.separatorBefore && /* @__PURE__ */ jsx30(DropdownMenuSeparator, {}),
3231
+ /* @__PURE__ */ jsxs19(
3232
+ DropdownMenuItem,
3233
+ {
3234
+ onClick: item.onClick,
3235
+ disabled: item.disabled,
3236
+ className: cn13(
3237
+ "hover:cursor-pointer flex items-center gap-2",
3238
+ isDestructive && "text-destructive focus:text-destructive",
3239
+ item.className
3240
+ ),
3241
+ children: [
3242
+ item.icon && /* @__PURE__ */ jsx30("span", { className: "size-4 shrink-0 flex items-center justify-center", children: item.icon }),
3243
+ /* @__PURE__ */ jsx30("span", { children: item.label })
3244
+ ]
3245
+ }
3246
+ ),
3247
+ item.separatorAfter && /* @__PURE__ */ jsx30(DropdownMenuSeparator, {})
3248
+ ] }, itemKey);
3249
+ })
3250
+ ] })
3251
+ }
3252
+ )
3253
+ ] })
3254
+ }
3255
+ );
3256
+ }
3257
+
3258
+ // src/components/composed/data-table/data-table.tsx
3259
+ import { jsx as jsx31, jsxs as jsxs20 } from "react/jsx-runtime";
3260
+ function DataTable({
3261
+ columns,
3262
+ data,
3263
+ initialColumnVisibility,
3264
+ renderCreateDialog,
3265
+ addLabel,
3266
+ onRefresh,
3267
+ onDownload,
3268
+ exportFilename = "data-export",
3269
+ showSearchInput = true,
3270
+ showRefreshButton = true,
3271
+ showSortButton = true,
3272
+ showFilterButton = true,
3273
+ showDownloadButton = true,
3274
+ showColumnToggleButton = true,
3275
+ showAddButton = true
3276
+ }) {
3277
+ const [createOpen, setCreateOpen] = useState5(false);
3278
+ const [sorting, setSorting] = useState5([]);
3279
+ const [columnFilters, setColumnFilters] = useState5([]);
3280
+ const [columnVisibility, setColumnVisibility] = useState5(initialColumnVisibility != null ? initialColumnVisibility : {});
3281
+ const [globalFilter, setGlobalFilter] = useState5("");
3282
+ const columnsWithSmartFilters = useMemo3(() => {
3283
+ return columns.map((col) => __spreadValues({
3284
+ filterFn: smartFilterFn
3285
+ }, col));
3286
+ }, [columns]);
3287
+ const table = useTable({
3288
+ features,
3289
+ data,
3290
+ columns: columnsWithSmartFilters,
3291
+ initialState: {
3292
+ globalFilter: ""
3293
+ },
3294
+ onSortingChange: setSorting,
3295
+ onColumnFiltersChange: setColumnFilters,
3296
+ onColumnVisibilityChange: setColumnVisibility,
3297
+ onGlobalFilterChange: (updater) => {
3298
+ setGlobalFilter((prev) => {
3299
+ const next = typeof updater === "function" ? updater(prev) : updater;
3300
+ return next != null ? next : "";
3301
+ });
3302
+ },
3303
+ state: {
3304
+ sorting,
3305
+ columnFilters,
3306
+ columnVisibility,
3307
+ globalFilter: globalFilter != null ? globalFilter : ""
3308
+ }
3309
+ });
3310
+ if (data.length === 0) {
3311
+ const hasCreateAction = Boolean(renderCreateDialog);
3312
+ const hasRefreshAction = Boolean(onRefresh);
3313
+ return /* @__PURE__ */ jsxs20("div", { className: "space-y-2", children: [
3314
+ /* @__PURE__ */ jsx31(
3315
+ StateEmpty,
3316
+ {
3317
+ state: "outline",
3318
+ icon: /* @__PURE__ */ jsx31(FolderOpenIcon, { className: "size-6 text-muted-foreground" }),
3319
+ title: "No Data Available",
3320
+ description: "There are currently no records to display. Create a new record to get started.",
3321
+ buttonText: hasCreateAction ? addLabel != null ? addLabel : "Add Record" : hasRefreshAction ? "Refresh" : void 0,
3322
+ render: hasCreateAction ? () => setCreateOpen(true) : hasRefreshAction ? onRefresh : void 0
3323
+ }
3324
+ ),
3325
+ renderCreateDialog == null ? void 0 : renderCreateDialog(createOpen, setCreateOpen)
3326
+ ] });
3327
+ }
3328
+ return /* @__PURE__ */ jsxs20("div", { className: "space-y-2", children: [
3329
+ /* @__PURE__ */ jsxs20("div", { className: "flex flex-row items-center justify-between gap-1", children: [
3330
+ showSearchInput ? /* @__PURE__ */ jsx31(
3331
+ DataTableHeaderSearch,
3332
+ {
3333
+ value: globalFilter,
3334
+ onChange: setGlobalFilter
3335
+ }
3336
+ ) : /* @__PURE__ */ jsx31("div", {}),
3337
+ /* @__PURE__ */ jsxs20("div", { className: "flex flex-row items-center gap-1", children: [
3338
+ showRefreshButton && /* @__PURE__ */ jsx31(DataTableHeaderRefresh, { onRefresh }),
3339
+ showSortButton && /* @__PURE__ */ jsx31(DataTableHeaderSort, { table, sorting }),
3340
+ showFilterButton && /* @__PURE__ */ jsx31(
3341
+ DataTableHeaderFilter,
3342
+ {
3343
+ table,
3344
+ columnFilters
3345
+ }
3346
+ ),
3347
+ showDownloadButton && /* @__PURE__ */ jsx31(
3348
+ DataTableHeaderDownload,
3349
+ {
3350
+ table,
3351
+ exportFilename,
3352
+ onDownload
3353
+ }
3354
+ ),
3355
+ showColumnToggleButton && /* @__PURE__ */ jsx31(DataTableHeaderToggle, { table }),
3356
+ showAddButton && renderCreateDialog && /* @__PURE__ */ jsx31(
3357
+ DataTableHeaderAdd,
3358
+ {
3359
+ onAdd: () => setCreateOpen(true),
3360
+ addLabel
3361
+ }
3362
+ )
3363
+ ] })
3364
+ ] }),
3365
+ renderCreateDialog == null ? void 0 : renderCreateDialog(createOpen, setCreateOpen),
3366
+ /* @__PURE__ */ jsx31("div", { className: "overflow-hidden rounded-md border [&_[data-slot=table-container]]:no-scrollbar", children: /* @__PURE__ */ jsxs20(Table, { children: [
3367
+ /* @__PURE__ */ jsx31(DataTableContentHeader, { table }),
3368
+ /* @__PURE__ */ jsx31(DataTableContentBody, { table, columns })
3369
+ ] }) }),
3370
+ /* @__PURE__ */ jsxs20("div", { className: "flex items-center justify-between px-2", children: [
3371
+ /* @__PURE__ */ jsx31(DataTableFooterEntries, { table }),
3372
+ /* @__PURE__ */ jsx31(DataTableFooterPagination, { table })
3373
+ ] })
3374
+ ] });
3375
+ }
3376
+
3377
+ // src/components/composed/header-tabs.tsx
3378
+ import Link2 from "next/link";
3379
+ import { usePathname as usePathname2 } from "next/navigation";
3380
+ import { memo as memo3 } from "react";
3381
+
3382
+ // src/components/ui/tabs.tsx
3383
+ import { Tabs as TabsPrimitive } from "@base-ui/react/tabs";
3384
+ import { cva as cva4 } from "class-variance-authority";
3385
+ import { cn as cn18 } from "cn";
3386
+ import { jsx as jsx32 } from "react/jsx-runtime";
3387
+ function Tabs(_a) {
3388
+ var _b = _a, {
3389
+ className,
3390
+ orientation = "horizontal"
3391
+ } = _b, props = __objRest(_b, [
3392
+ "className",
3393
+ "orientation"
3394
+ ]);
3395
+ return /* @__PURE__ */ jsx32(
3396
+ TabsPrimitive.Root,
3397
+ __spreadValues({
3398
+ "data-slot": "tabs",
3399
+ "data-orientation": orientation,
3400
+ className: cn18(
3401
+ "group/tabs flex gap-2 data-horizontal:flex-col",
3402
+ className
3403
+ )
3404
+ }, props)
3405
+ );
3406
+ }
3407
+ var tabsListVariants = cva4(
3408
+ "group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none",
3409
+ {
3410
+ variants: {
3411
+ variant: {
3412
+ default: "bg-muted",
3413
+ line: "gap-1 bg-transparent"
3414
+ }
3415
+ },
3416
+ defaultVariants: {
3417
+ variant: "default"
3418
+ }
3419
+ }
3420
+ );
3421
+ function TabsList(_a) {
3422
+ var _b = _a, {
3423
+ className,
3424
+ variant = "default"
3425
+ } = _b, props = __objRest(_b, [
3426
+ "className",
3427
+ "variant"
3428
+ ]);
3429
+ return /* @__PURE__ */ jsx32(
3430
+ TabsPrimitive.List,
3431
+ __spreadValues({
3432
+ "data-slot": "tabs-list",
3433
+ "data-variant": variant,
3434
+ className: cn18(tabsListVariants({ variant }), className)
3435
+ }, props)
3436
+ );
3437
+ }
3438
+ function TabsTrigger(_a) {
3439
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
3440
+ return /* @__PURE__ */ jsx32(
3441
+ TabsPrimitive.Tab,
3442
+ __spreadValues({
3443
+ "data-slot": "tabs-trigger",
3444
+ className: cn18(
3445
+ "relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-xs font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start group-data-vertical/tabs:py-[calc(--spacing(1.25))] hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
3446
+ "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent",
3447
+ "data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground",
3448
+ "after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",
3449
+ className
3450
+ )
3451
+ }, props)
3452
+ );
3453
+ }
3454
+
3455
+ // src/components/composed/header-tabs.tsx
3456
+ import { jsx as jsx33, jsxs as jsxs21 } from "react/jsx-runtime";
3457
+ function renderTabIcon(icon) {
3458
+ if (!icon) return null;
3459
+ if (typeof icon === "function" || typeof icon === "object" && icon !== null && "render" in icon) {
3460
+ const IconComp = icon;
3461
+ return /* @__PURE__ */ jsx33(IconComp, {});
3462
+ }
3463
+ return icon;
3464
+ }
3465
+ var HeaderTabs = memo3(function HeaderTabs2({
3466
+ items,
3467
+ value,
3468
+ onValueChange,
3469
+ children
3470
+ }) {
3471
+ var _a, _b;
3472
+ const pathname = usePathname2();
3473
+ const matchedItem = pathname ? items.find(
3474
+ (item) => item.url === pathname || pathname.endsWith(item.url) || pathname.split("/").includes(item.value)
3475
+ ) : void 0;
3476
+ const activeTab = (_b = value != null ? value : matchedItem == null ? void 0 : matchedItem.value) != null ? _b : (_a = items[0]) == null ? void 0 : _a.value;
3477
+ return /* @__PURE__ */ jsxs21(Tabs, { value: activeTab, onValueChange, className: "space-y-4", children: [
3478
+ /* @__PURE__ */ jsx33("div", { className: "w-full overflow-x-auto overflow-y-hidden border-b no-scrollbar", children: /* @__PURE__ */ jsx33(TabsList, { variant: "line", className: "inline-flex w-max justify-start", children: items.map(({ title, value: tabValue, url, icon }) => /* @__PURE__ */ jsxs21(
3479
+ TabsTrigger,
3480
+ {
3481
+ nativeButton: false,
3482
+ render: /* @__PURE__ */ jsx33(Link2, { href: url }),
3483
+ value: tabValue,
3484
+ children: [
3485
+ renderTabIcon(icon),
3486
+ title
3487
+ ]
3488
+ },
3489
+ tabValue
3490
+ )) }) }),
3491
+ children
3492
+ ] });
3493
+ });
3494
+
3495
+ // src/components/composed/header-title.tsx
3496
+ import { memo as memo4 } from "react";
3497
+ import { jsx as jsx34, jsxs as jsxs22 } from "react/jsx-runtime";
3498
+ var HeaderTitle = memo4(function HeaderTitle2({
3499
+ title,
3500
+ subtitle,
3501
+ children
3502
+ }) {
3503
+ return /* @__PURE__ */ jsxs22("div", { className: "w-full space-y-4", children: [
3504
+ /* @__PURE__ */ jsxs22("div", { children: [
3505
+ /* @__PURE__ */ jsx34("h1", { className: "font-semibold", children: title }),
3506
+ /* @__PURE__ */ jsx34("p", { className: "text-xs text-muted-foreground", children: subtitle })
3507
+ ] }),
3508
+ children
1677
3509
  ] });
1678
3510
  });
1679
3511
  export {
1680
3512
  AppSidebar,
3513
+ DataTable,
3514
+ DataTableContentBody,
3515
+ DataTableContentHeader,
3516
+ DataTableFooterEntries,
3517
+ DataTableFooterPagination,
3518
+ DataTableHeaderAdd,
3519
+ DataTableHeaderDownload,
3520
+ DataTableHeaderFilter,
3521
+ DataTableHeaderRefresh,
3522
+ DataTableHeaderSearch,
3523
+ DataTableHeaderSort,
3524
+ DataTableHeaderToggle,
1681
3525
  HeaderTabs,
1682
3526
  HeaderTitle,
1683
- StateEmpty
3527
+ RowActions,
3528
+ StateEmpty,
3529
+ exportToCSV,
3530
+ exportToPDF,
3531
+ exportToXLSX,
3532
+ features,
3533
+ flexRender3 as flexRender,
3534
+ getTableExportData,
3535
+ printTable,
3536
+ smartFilterFn,
3537
+ useTable
1684
3538
  };