@prediktif/ui 0.1.19 → 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.d.mts +19 -36
- package/dist/index.d.ts +19 -36
- package/dist/index.js +173 -191
- package/dist/index.mjs +207 -226
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -78,6 +78,7 @@ __export(index_exports, {
|
|
|
78
78
|
RowActions: () => RowActions,
|
|
79
79
|
StateEmpty: () => StateEmpty,
|
|
80
80
|
exportToCSV: () => exportToCSV,
|
|
81
|
+
exportToPDF: () => exportToPDF,
|
|
81
82
|
exportToXLSX: () => exportToXLSX,
|
|
82
83
|
features: () => features,
|
|
83
84
|
flexRender: () => import_react_table4.flexRender,
|
|
@@ -773,16 +774,6 @@ function SheetDescription(_a) {
|
|
|
773
774
|
// src/components/ui/skeleton.tsx
|
|
774
775
|
var import_cn9 = require("cn");
|
|
775
776
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
776
|
-
function Skeleton(_a) {
|
|
777
|
-
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
778
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
779
|
-
"div",
|
|
780
|
-
__spreadValues({
|
|
781
|
-
"data-slot": "skeleton",
|
|
782
|
-
className: (0, import_cn9.cn)("animate-pulse rounded-md bg-muted", className)
|
|
783
|
-
}, props)
|
|
784
|
-
);
|
|
785
|
-
}
|
|
786
777
|
|
|
787
778
|
// src/components/ui/tooltip.tsx
|
|
788
779
|
var import_tooltip = require("@base-ui/react/tooltip");
|
|
@@ -1540,7 +1531,7 @@ var AppSidebar = (0, import_react.memo)(function AppSidebar2({
|
|
|
1540
1531
|
|
|
1541
1532
|
// src/components/composed/data-table/data-table.tsx
|
|
1542
1533
|
var import_react_table4 = require("@tanstack/react-table");
|
|
1543
|
-
var
|
|
1534
|
+
var import_lucide_react18 = require("lucide-react");
|
|
1544
1535
|
var import_react6 = require("react");
|
|
1545
1536
|
|
|
1546
1537
|
// src/components/composed/state-empty.tsx
|
|
@@ -1644,6 +1635,9 @@ function EmptyContent(_a) {
|
|
|
1644
1635
|
);
|
|
1645
1636
|
}
|
|
1646
1637
|
|
|
1638
|
+
// src/lib/utils.ts
|
|
1639
|
+
var import_cn13 = require("cn");
|
|
1640
|
+
|
|
1647
1641
|
// src/components/composed/state-empty.tsx
|
|
1648
1642
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1649
1643
|
function renderStateIcon(icon) {
|
|
@@ -1659,31 +1653,41 @@ var StateEmpty = (0, import_react2.memo)(function StateEmpty2({
|
|
|
1659
1653
|
description,
|
|
1660
1654
|
buttonText,
|
|
1661
1655
|
onClick,
|
|
1662
|
-
render
|
|
1656
|
+
render,
|
|
1657
|
+
state = "default"
|
|
1663
1658
|
}) {
|
|
1659
|
+
const isFunctionAction = typeof render === "function";
|
|
1660
|
+
const actionHandler = isFunctionAction ? render : onClick;
|
|
1661
|
+
const buttonRender = isFunctionAction ? void 0 : render;
|
|
1664
1662
|
const hasAction = Boolean(buttonText || render || onClick);
|
|
1665
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1663
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1664
|
+
Empty,
|
|
1665
|
+
{
|
|
1666
|
+
className: (0, import_cn13.cn)("w-full", state === "outline" && "border border-dashed"),
|
|
1667
|
+
children: [
|
|
1668
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(EmptyHeader, { children: [
|
|
1669
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EmptyMedia, { variant: "icon", children: renderStateIcon(icon) }),
|
|
1670
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EmptyTitle, { children: title }),
|
|
1671
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EmptyDescription, { children: description })
|
|
1672
|
+
] }),
|
|
1673
|
+
hasAction && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EmptyContent, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1674
|
+
Button,
|
|
1675
|
+
{
|
|
1676
|
+
variant: "outline",
|
|
1677
|
+
size: "sm",
|
|
1678
|
+
nativeButton: !buttonRender,
|
|
1679
|
+
onClick: actionHandler,
|
|
1680
|
+
render: buttonRender,
|
|
1681
|
+
children: buttonText
|
|
1682
|
+
}
|
|
1683
|
+
) })
|
|
1684
|
+
]
|
|
1685
|
+
}
|
|
1686
|
+
);
|
|
1683
1687
|
});
|
|
1684
1688
|
|
|
1685
1689
|
// src/components/ui/table.tsx
|
|
1686
|
-
var
|
|
1690
|
+
var import_cn14 = require("cn");
|
|
1687
1691
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1688
1692
|
function Table(_a) {
|
|
1689
1693
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
@@ -1696,7 +1700,7 @@ function Table(_a) {
|
|
|
1696
1700
|
"table",
|
|
1697
1701
|
__spreadValues({
|
|
1698
1702
|
"data-slot": "table",
|
|
1699
|
-
className: (0,
|
|
1703
|
+
className: (0, import_cn14.cn)("w-full caption-bottom text-xs", className)
|
|
1700
1704
|
}, props)
|
|
1701
1705
|
)
|
|
1702
1706
|
}
|
|
@@ -1708,7 +1712,7 @@ function TableHeader(_a) {
|
|
|
1708
1712
|
"thead",
|
|
1709
1713
|
__spreadValues({
|
|
1710
1714
|
"data-slot": "table-header",
|
|
1711
|
-
className: (0,
|
|
1715
|
+
className: (0, import_cn14.cn)("[&_tr]:border-b", className)
|
|
1712
1716
|
}, props)
|
|
1713
1717
|
);
|
|
1714
1718
|
}
|
|
@@ -1718,7 +1722,7 @@ function TableBody(_a) {
|
|
|
1718
1722
|
"tbody",
|
|
1719
1723
|
__spreadValues({
|
|
1720
1724
|
"data-slot": "table-body",
|
|
1721
|
-
className: (0,
|
|
1725
|
+
className: (0, import_cn14.cn)("[&_tr:last-child]:border-0", className)
|
|
1722
1726
|
}, props)
|
|
1723
1727
|
);
|
|
1724
1728
|
}
|
|
@@ -1728,7 +1732,7 @@ function TableRow(_a) {
|
|
|
1728
1732
|
"tr",
|
|
1729
1733
|
__spreadValues({
|
|
1730
1734
|
"data-slot": "table-row",
|
|
1731
|
-
className: (0,
|
|
1735
|
+
className: (0, import_cn14.cn)(
|
|
1732
1736
|
"border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",
|
|
1733
1737
|
className
|
|
1734
1738
|
)
|
|
@@ -1741,7 +1745,7 @@ function TableHead(_a) {
|
|
|
1741
1745
|
"th",
|
|
1742
1746
|
__spreadValues({
|
|
1743
1747
|
"data-slot": "table-head",
|
|
1744
|
-
className: (0,
|
|
1748
|
+
className: (0, import_cn14.cn)(
|
|
1745
1749
|
"h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",
|
|
1746
1750
|
className
|
|
1747
1751
|
)
|
|
@@ -1754,7 +1758,7 @@ function TableCell(_a) {
|
|
|
1754
1758
|
"td",
|
|
1755
1759
|
__spreadValues({
|
|
1756
1760
|
"data-slot": "table-cell",
|
|
1757
|
-
className: (0,
|
|
1761
|
+
className: (0, import_cn14.cn)(
|
|
1758
1762
|
"p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",
|
|
1759
1763
|
className
|
|
1760
1764
|
)
|
|
@@ -1792,87 +1796,39 @@ var features = (0, import_react_table.tableFeatures)({
|
|
|
1792
1796
|
var import_react_table2 = require("@tanstack/react-table");
|
|
1793
1797
|
var import_lucide_react6 = require("lucide-react");
|
|
1794
1798
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1795
|
-
var SKELETON_ROWS = ["sk-1", "sk-2", "sk-3", "sk-4", "sk-5"];
|
|
1796
1799
|
function DataTableContentBody({
|
|
1797
1800
|
table,
|
|
1798
|
-
columns
|
|
1799
|
-
isLoading
|
|
1801
|
+
columns
|
|
1800
1802
|
}) {
|
|
1801
|
-
if (isLoading) {
|
|
1802
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TableBody, { children: SKELETON_ROWS.map((rowKey) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TableRow, { children: columns.map((col, idx) => {
|
|
1803
|
-
var _a;
|
|
1804
|
-
const colKey = (_a = col.id) != null ? _a : typeof col.accessorKey === "string" ? col.accessorKey : `col-${idx}`;
|
|
1805
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TableCell, { className: "py-3", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Skeleton, { className: "h-4 w-full" }) }, `${rowKey}-${colKey}`);
|
|
1806
|
-
}) }, rowKey)) });
|
|
1807
|
-
}
|
|
1808
1803
|
const rows = table.getRowModel().rows;
|
|
1809
1804
|
if (rows == null ? void 0 : rows.length) {
|
|
1810
1805
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TableBody, { children: rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TableRow, { children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TableCell, { children: (0, import_react_table2.flexRender)(cell.column.columnDef.cell, cell.getContext()) }, cell.id)) }, row.id)) });
|
|
1811
1806
|
}
|
|
1812
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TableBody, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TableCell, { colSpan: columns.length, className: "h-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
onClick: () => {
|
|
1823
|
-
table.resetGlobalFilter();
|
|
1824
|
-
table.resetColumnFilters();
|
|
1825
|
-
},
|
|
1826
|
-
children: "Clear search & filters"
|
|
1807
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TableBody, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TableCell, { colSpan: columns.length, className: "h-48 text-center", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1808
|
+
StateEmpty,
|
|
1809
|
+
{
|
|
1810
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react6.SearchXIcon, {}),
|
|
1811
|
+
title: "No matching results",
|
|
1812
|
+
description: "No records matched your search query or filter criteria.",
|
|
1813
|
+
buttonText: "Clear search & filters",
|
|
1814
|
+
render: () => {
|
|
1815
|
+
table.setGlobalFilter("");
|
|
1816
|
+
table.resetColumnFilters();
|
|
1827
1817
|
}
|
|
1828
|
-
|
|
1829
|
-
|
|
1818
|
+
}
|
|
1819
|
+
) }) }) });
|
|
1830
1820
|
}
|
|
1831
1821
|
|
|
1832
1822
|
// src/components/composed/data-table/table-content-header.tsx
|
|
1833
1823
|
var import_react_table3 = require("@tanstack/react-table");
|
|
1834
|
-
var import_lucide_react7 = require("lucide-react");
|
|
1835
|
-
|
|
1836
|
-
// src/lib/utils.ts
|
|
1837
|
-
var import_cn14 = require("cn");
|
|
1838
|
-
|
|
1839
|
-
// src/components/composed/data-table/table-content-header.tsx
|
|
1840
1824
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1841
1825
|
function DataTableContentHeader({
|
|
1842
1826
|
table
|
|
1843
1827
|
}) {
|
|
1844
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TableRow, { children: headerGroup.headers.map((header) => {
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
const canSort = header.column.getCanSort();
|
|
1849
|
-
const isSorted = header.column.getIsSorted();
|
|
1850
|
-
if (!canSort) {
|
|
1851
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TableHead, { children: (0, import_react_table3.flexRender)(
|
|
1852
|
-
header.column.columnDef.header,
|
|
1853
|
-
header.getContext()
|
|
1854
|
-
) }, header.id);
|
|
1855
|
-
}
|
|
1856
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TableHead, { className: "select-none", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
1857
|
-
"button",
|
|
1858
|
-
{
|
|
1859
|
-
type: "button",
|
|
1860
|
-
className: (0, import_cn14.cn)(
|
|
1861
|
-
"flex items-center gap-1.5 -ml-1 px-1 py-1 rounded hover:bg-muted/50 cursor-pointer font-medium text-xs transition-colors",
|
|
1862
|
-
isSorted && "text-foreground font-semibold"
|
|
1863
|
-
),
|
|
1864
|
-
onClick: header.column.getToggleSortingHandler(),
|
|
1865
|
-
"aria-label": `Sort by ${typeof header.column.columnDef.header === "string" ? header.column.columnDef.header : header.id}`,
|
|
1866
|
-
children: [
|
|
1867
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: (0, import_react_table3.flexRender)(
|
|
1868
|
-
header.column.columnDef.header,
|
|
1869
|
-
header.getContext()
|
|
1870
|
-
) }),
|
|
1871
|
-
isSorted === "asc" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react7.ArrowUpIcon, { className: "size-3 text-foreground shrink-0" }) : isSorted === "desc" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react7.ArrowDownIcon, { className: "size-3 text-foreground shrink-0" }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react7.ArrowUpDownIcon, { className: "size-3 text-muted-foreground/40 hover:text-muted-foreground shrink-0" })
|
|
1872
|
-
]
|
|
1873
|
-
}
|
|
1874
|
-
) }, header.id);
|
|
1875
|
-
}) }, headerGroup.id)) });
|
|
1828
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TableRow, { children: headerGroup.headers.map((header) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TableHead, { children: header.isPlaceholder ? null : (0, import_react_table3.flexRender)(
|
|
1829
|
+
header.column.columnDef.header,
|
|
1830
|
+
header.getContext()
|
|
1831
|
+
) }, header.id)) }, headerGroup.id)) });
|
|
1876
1832
|
}
|
|
1877
1833
|
|
|
1878
1834
|
// src/components/composed/data-table/table-footer-entries.tsx
|
|
@@ -1904,7 +1860,7 @@ function DataTableFooterEntries({
|
|
|
1904
1860
|
}
|
|
1905
1861
|
|
|
1906
1862
|
// src/components/composed/data-table/table-footer-pagination.tsx
|
|
1907
|
-
var
|
|
1863
|
+
var import_lucide_react7 = require("lucide-react");
|
|
1908
1864
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1909
1865
|
function DataTableFooterPagination({
|
|
1910
1866
|
table
|
|
@@ -1921,7 +1877,7 @@ function DataTableFooterPagination({
|
|
|
1921
1877
|
size: "icon-xs",
|
|
1922
1878
|
onClick: () => table.firstPage(),
|
|
1923
1879
|
disabled: !table.getCanPreviousPage(),
|
|
1924
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1880
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react7.ChevronsLeftIcon, {})
|
|
1925
1881
|
}
|
|
1926
1882
|
)
|
|
1927
1883
|
}
|
|
@@ -1939,7 +1895,7 @@ function DataTableFooterPagination({
|
|
|
1939
1895
|
size: "icon-xs",
|
|
1940
1896
|
onClick: () => table.previousPage(),
|
|
1941
1897
|
disabled: !table.getCanPreviousPage(),
|
|
1942
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1898
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react7.ChevronLeftIcon, {})
|
|
1943
1899
|
}
|
|
1944
1900
|
)
|
|
1945
1901
|
}
|
|
@@ -1957,7 +1913,7 @@ function DataTableFooterPagination({
|
|
|
1957
1913
|
size: "icon-xs",
|
|
1958
1914
|
onClick: () => table.nextPage(),
|
|
1959
1915
|
disabled: !table.getCanNextPage(),
|
|
1960
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1916
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react7.ChevronRightIcon, {})
|
|
1961
1917
|
}
|
|
1962
1918
|
)
|
|
1963
1919
|
}
|
|
@@ -1975,7 +1931,7 @@ function DataTableFooterPagination({
|
|
|
1975
1931
|
size: "icon-xs",
|
|
1976
1932
|
onClick: () => table.lastPage(),
|
|
1977
1933
|
disabled: !table.getCanNextPage(),
|
|
1978
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1934
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react7.ChevronsRightIcon, {})
|
|
1979
1935
|
}
|
|
1980
1936
|
)
|
|
1981
1937
|
}
|
|
@@ -1986,7 +1942,7 @@ function DataTableFooterPagination({
|
|
|
1986
1942
|
}
|
|
1987
1943
|
|
|
1988
1944
|
// src/components/composed/data-table/table-header-add.tsx
|
|
1989
|
-
var
|
|
1945
|
+
var import_lucide_react8 = require("lucide-react");
|
|
1990
1946
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1991
1947
|
function DataTableHeaderAdd({
|
|
1992
1948
|
onAdd,
|
|
@@ -1998,20 +1954,20 @@ function DataTableHeaderAdd({
|
|
|
1998
1954
|
TooltipTrigger,
|
|
1999
1955
|
{
|
|
2000
1956
|
className: "flex sm:hidden",
|
|
2001
|
-
render: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Button, { variant: "default", size: "icon", onClick: onAdd, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1957
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Button, { variant: "default", size: "icon", onClick: onAdd, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react8.PlusIcon, {}) })
|
|
2002
1958
|
}
|
|
2003
1959
|
),
|
|
2004
1960
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(TooltipContent, { children: addLabel != null ? addLabel : "Add" })
|
|
2005
1961
|
] }),
|
|
2006
1962
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(Button, { variant: "default", onClick: onAdd, className: "hidden sm:flex", children: [
|
|
2007
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1963
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react8.PlusIcon, {}),
|
|
2008
1964
|
addLabel != null ? addLabel : "Add"
|
|
2009
1965
|
] })
|
|
2010
1966
|
] });
|
|
2011
1967
|
}
|
|
2012
1968
|
|
|
2013
1969
|
// src/components/composed/data-table/table-header-download.tsx
|
|
2014
|
-
var
|
|
1970
|
+
var import_lucide_react9 = require("lucide-react");
|
|
2015
1971
|
|
|
2016
1972
|
// src/components/composed/data-table/export.ts
|
|
2017
1973
|
var XLSX = __toESM(require("xlsx"));
|
|
@@ -2072,6 +2028,41 @@ function exportToCSV(rows, filename = "data-export") {
|
|
|
2072
2028
|
URL.revokeObjectURL(url);
|
|
2073
2029
|
}, 1e3);
|
|
2074
2030
|
}
|
|
2031
|
+
async function exportToPDF(headers, rows, filename = "data-export", title = "Data Export") {
|
|
2032
|
+
const [{ jsPDF }, autoTableMod] = await Promise.all([
|
|
2033
|
+
import("jspdf"),
|
|
2034
|
+
import("jspdf-autotable")
|
|
2035
|
+
]);
|
|
2036
|
+
const autoTable = autoTableMod.autoTable || autoTableMod.default;
|
|
2037
|
+
const orientation = headers.length > 5 ? "landscape" : "portrait";
|
|
2038
|
+
const doc = new jsPDF({ orientation });
|
|
2039
|
+
doc.setFontSize(14);
|
|
2040
|
+
doc.setFont("helvetica", "bold");
|
|
2041
|
+
doc.text(title, 14, 15);
|
|
2042
|
+
doc.setFontSize(8);
|
|
2043
|
+
doc.setFont("helvetica", "normal");
|
|
2044
|
+
doc.setTextColor(120);
|
|
2045
|
+
doc.text(`Generated on ${(/* @__PURE__ */ new Date()).toLocaleString()}`, 14, 20);
|
|
2046
|
+
autoTable(doc, {
|
|
2047
|
+
head: [headers],
|
|
2048
|
+
body: rows,
|
|
2049
|
+
startY: 24,
|
|
2050
|
+
styles: {
|
|
2051
|
+
fontSize: 8,
|
|
2052
|
+
cellPadding: 2.5
|
|
2053
|
+
},
|
|
2054
|
+
headStyles: {
|
|
2055
|
+
fillColor: [40, 40, 40],
|
|
2056
|
+
textColor: [255, 255, 255],
|
|
2057
|
+
fontStyle: "bold"
|
|
2058
|
+
},
|
|
2059
|
+
alternateRowStyles: {
|
|
2060
|
+
fillColor: [248, 248, 248]
|
|
2061
|
+
}
|
|
2062
|
+
});
|
|
2063
|
+
const finalFilename = filename.endsWith(".pdf") ? filename : `${filename}.pdf`;
|
|
2064
|
+
doc.save(finalFilename);
|
|
2065
|
+
}
|
|
2075
2066
|
function printTable(headers, rows, title = "Data Export") {
|
|
2076
2067
|
let tableHtml = `<table style="width:100%; border-collapse:collapse; font-family:sans-serif; font-size:12px;"><thead><tr>`;
|
|
2077
2068
|
for (const header of headers) {
|
|
@@ -2167,7 +2158,7 @@ function DataTableHeaderDownload({
|
|
|
2167
2158
|
render: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2168
2159
|
TooltipTrigger,
|
|
2169
2160
|
{
|
|
2170
|
-
render: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { variant: "outline", size: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2161
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { variant: "outline", size: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react9.DownloadIcon, {}) })
|
|
2171
2162
|
}
|
|
2172
2163
|
)
|
|
2173
2164
|
}
|
|
@@ -2181,13 +2172,13 @@ function DataTableHeaderDownload({
|
|
|
2181
2172
|
DropdownMenuItem,
|
|
2182
2173
|
{
|
|
2183
2174
|
className: "hover:cursor-pointer",
|
|
2184
|
-
onClick: () => {
|
|
2175
|
+
onClick: async () => {
|
|
2185
2176
|
const { headers, rows } = getTableExportData(table);
|
|
2186
|
-
|
|
2177
|
+
await exportToPDF(headers, rows, exportFilename);
|
|
2187
2178
|
onDownload == null ? void 0 : onDownload();
|
|
2188
2179
|
},
|
|
2189
2180
|
children: [
|
|
2190
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2181
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react9.FileTextIcon, {}),
|
|
2191
2182
|
"Download PDF"
|
|
2192
2183
|
]
|
|
2193
2184
|
}
|
|
@@ -2202,7 +2193,7 @@ function DataTableHeaderDownload({
|
|
|
2202
2193
|
onDownload == null ? void 0 : onDownload();
|
|
2203
2194
|
},
|
|
2204
2195
|
children: [
|
|
2205
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2196
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react9.FileSpreadsheetIcon, {}),
|
|
2206
2197
|
"Download Excel"
|
|
2207
2198
|
]
|
|
2208
2199
|
}
|
|
@@ -2217,7 +2208,7 @@ function DataTableHeaderDownload({
|
|
|
2217
2208
|
onDownload == null ? void 0 : onDownload();
|
|
2218
2209
|
},
|
|
2219
2210
|
children: [
|
|
2220
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2211
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react9.FileCodeIcon, {}),
|
|
2221
2212
|
"Download CSV"
|
|
2222
2213
|
]
|
|
2223
2214
|
}
|
|
@@ -2232,7 +2223,7 @@ function DataTableHeaderDownload({
|
|
|
2232
2223
|
printTable(headers, rows, exportFilename);
|
|
2233
2224
|
},
|
|
2234
2225
|
children: [
|
|
2235
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2226
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react9.PrinterIcon, {}),
|
|
2236
2227
|
"Print Table"
|
|
2237
2228
|
]
|
|
2238
2229
|
}
|
|
@@ -2243,12 +2234,12 @@ function DataTableHeaderDownload({
|
|
|
2243
2234
|
|
|
2244
2235
|
// src/components/composed/data-table/table-header-filter.tsx
|
|
2245
2236
|
var import_date_fns = require("date-fns");
|
|
2246
|
-
var
|
|
2237
|
+
var import_lucide_react12 = require("lucide-react");
|
|
2247
2238
|
var import_react3 = require("react");
|
|
2248
2239
|
|
|
2249
2240
|
// src/components/ui/calendar.tsx
|
|
2250
2241
|
var import_cn15 = require("cn");
|
|
2251
|
-
var
|
|
2242
|
+
var import_lucide_react10 = require("lucide-react");
|
|
2252
2243
|
var React3 = __toESM(require("react"));
|
|
2253
2244
|
var import_react_day_picker = require("react-day-picker");
|
|
2254
2245
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
@@ -2388,17 +2379,17 @@ function Calendar(_a) {
|
|
|
2388
2379
|
Chevron: (_c) => {
|
|
2389
2380
|
var _d = _c, { className: className2, orientation } = _d, props2 = __objRest(_d, ["className", "orientation"]);
|
|
2390
2381
|
if (orientation === "left") {
|
|
2391
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2382
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react10.ChevronLeftIcon, __spreadValues({ className: (0, import_cn15.cn)("size-4", className2) }, props2));
|
|
2392
2383
|
}
|
|
2393
2384
|
if (orientation === "right") {
|
|
2394
2385
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2395
|
-
|
|
2386
|
+
import_lucide_react10.ChevronRightIcon,
|
|
2396
2387
|
__spreadValues({
|
|
2397
2388
|
className: (0, import_cn15.cn)("size-4", className2)
|
|
2398
2389
|
}, props2)
|
|
2399
2390
|
);
|
|
2400
2391
|
}
|
|
2401
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2392
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react10.ChevronDownIcon, __spreadValues({ className: (0, import_cn15.cn)("size-4", className2) }, props2));
|
|
2402
2393
|
},
|
|
2403
2394
|
DayButton: (_e) => {
|
|
2404
2395
|
var props2 = __objRest(_e, []);
|
|
@@ -2500,7 +2491,7 @@ function PopoverContent(_a) {
|
|
|
2500
2491
|
// src/components/ui/select.tsx
|
|
2501
2492
|
var import_select = require("@base-ui/react/select");
|
|
2502
2493
|
var import_cn17 = require("cn");
|
|
2503
|
-
var
|
|
2494
|
+
var import_lucide_react11 = require("lucide-react");
|
|
2504
2495
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2505
2496
|
var Select = import_select.Select.Root;
|
|
2506
2497
|
function SelectValue(_a) {
|
|
@@ -2538,7 +2529,7 @@ function SelectTrigger(_a) {
|
|
|
2538
2529
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2539
2530
|
import_select.Select.Icon,
|
|
2540
2531
|
{
|
|
2541
|
-
render: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2532
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react11.ChevronDownIcon, { className: "pointer-events-none size-3.5 text-muted-foreground" })
|
|
2542
2533
|
}
|
|
2543
2534
|
)
|
|
2544
2535
|
]
|
|
@@ -2615,7 +2606,7 @@ function SelectItem(_a) {
|
|
|
2615
2606
|
import_select.Select.ItemIndicator,
|
|
2616
2607
|
{
|
|
2617
2608
|
render: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "pointer-events-none absolute right-2 flex items-center justify-center" }),
|
|
2618
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2609
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react11.CheckIcon, { className: "pointer-events-none" })
|
|
2619
2610
|
}
|
|
2620
2611
|
)
|
|
2621
2612
|
]
|
|
@@ -2637,7 +2628,7 @@ function SelectScrollUpButton(_a) {
|
|
|
2637
2628
|
className
|
|
2638
2629
|
)
|
|
2639
2630
|
}, props), {
|
|
2640
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2631
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react11.ChevronUpIcon, {})
|
|
2641
2632
|
})
|
|
2642
2633
|
);
|
|
2643
2634
|
}
|
|
@@ -2656,7 +2647,7 @@ function SelectScrollDownButton(_a) {
|
|
|
2656
2647
|
className
|
|
2657
2648
|
)
|
|
2658
2649
|
}, props), {
|
|
2659
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2650
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react11.ChevronDownIcon, {})
|
|
2660
2651
|
})
|
|
2661
2652
|
);
|
|
2662
2653
|
}
|
|
@@ -2887,14 +2878,14 @@ function ColumnFilterInput({
|
|
|
2887
2878
|
Button,
|
|
2888
2879
|
{
|
|
2889
2880
|
variant: "outline",
|
|
2890
|
-
className: (0,
|
|
2881
|
+
className: (0, import_cn13.cn)(
|
|
2891
2882
|
"w-full justify-start",
|
|
2892
2883
|
!formattedDateLabel && "text-muted-foreground"
|
|
2893
2884
|
),
|
|
2894
2885
|
onKeyDown: (e) => e.stopPropagation(),
|
|
2895
2886
|
onPointerDown: (e) => e.stopPropagation(),
|
|
2896
2887
|
children: [
|
|
2897
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2888
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react12.CalendarIcon, { className: "mr-1 size-3 shrink-0" }),
|
|
2898
2889
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "truncate", children: formattedDateLabel || `Pick ${headerText.toLowerCase()}...` })
|
|
2899
2890
|
]
|
|
2900
2891
|
}
|
|
@@ -2964,7 +2955,7 @@ function DataTableHeaderFilter({
|
|
|
2964
2955
|
{
|
|
2965
2956
|
variant: columnFilters.length > 0 ? "secondary" : "outline",
|
|
2966
2957
|
size: "icon",
|
|
2967
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2958
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react12.ListFilterIcon, {})
|
|
2968
2959
|
}
|
|
2969
2960
|
)
|
|
2970
2961
|
}
|
|
@@ -3020,7 +3011,7 @@ function DataTableHeaderFilter({
|
|
|
3020
3011
|
}
|
|
3021
3012
|
|
|
3022
3013
|
// src/components/composed/data-table/table-header-refresh.tsx
|
|
3023
|
-
var
|
|
3014
|
+
var import_lucide_react13 = require("lucide-react");
|
|
3024
3015
|
var import_navigation2 = require("next/navigation");
|
|
3025
3016
|
var import_react4 = require("react");
|
|
3026
3017
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
@@ -3052,9 +3043,9 @@ function DataTableHeaderRefresh({
|
|
|
3052
3043
|
onClick: handleRefresh,
|
|
3053
3044
|
disabled: isRefreshing,
|
|
3054
3045
|
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3055
|
-
|
|
3046
|
+
import_lucide_react13.RotateCwIcon,
|
|
3056
3047
|
{
|
|
3057
|
-
className: (0,
|
|
3048
|
+
className: (0, import_cn13.cn)(
|
|
3058
3049
|
"transition-transform duration-750",
|
|
3059
3050
|
isRefreshing && "animate-spin"
|
|
3060
3051
|
)
|
|
@@ -3069,38 +3060,37 @@ function DataTableHeaderRefresh({
|
|
|
3069
3060
|
}
|
|
3070
3061
|
|
|
3071
3062
|
// src/components/composed/data-table/table-header-search.tsx
|
|
3072
|
-
var
|
|
3063
|
+
var import_lucide_react14 = require("lucide-react");
|
|
3073
3064
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3074
3065
|
function DataTableHeaderSearch({
|
|
3075
|
-
value,
|
|
3076
|
-
onChange
|
|
3077
|
-
placeholder = "Search..."
|
|
3066
|
+
value = "",
|
|
3067
|
+
onChange
|
|
3078
3068
|
}) {
|
|
3079
3069
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "relative flex items-center max-w-sm w-full", children: [
|
|
3080
3070
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3081
3071
|
Input,
|
|
3082
3072
|
{
|
|
3083
|
-
placeholder,
|
|
3084
|
-
value,
|
|
3073
|
+
placeholder: "Search...",
|
|
3074
|
+
value: value != null ? value : "",
|
|
3085
3075
|
onChange: (event) => onChange(event.target.value),
|
|
3086
3076
|
className: "pr-7"
|
|
3087
3077
|
}
|
|
3088
3078
|
),
|
|
3089
|
-
value && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3079
|
+
Boolean(value) && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3090
3080
|
"button",
|
|
3091
3081
|
{
|
|
3092
3082
|
type: "button",
|
|
3093
3083
|
onClick: () => onChange(""),
|
|
3094
3084
|
className: "absolute right-2 text-muted-foreground hover:text-foreground p-0.5 rounded cursor-pointer",
|
|
3095
3085
|
"aria-label": "Clear search text",
|
|
3096
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3086
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react14.XIcon, { className: "size-3.5" })
|
|
3097
3087
|
}
|
|
3098
3088
|
)
|
|
3099
3089
|
] });
|
|
3100
3090
|
}
|
|
3101
3091
|
|
|
3102
3092
|
// src/components/composed/data-table/table-header-sort.tsx
|
|
3103
|
-
var
|
|
3093
|
+
var import_lucide_react15 = require("lucide-react");
|
|
3104
3094
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3105
3095
|
function DataTableHeaderSort({
|
|
3106
3096
|
table,
|
|
@@ -3120,7 +3110,7 @@ function DataTableHeaderSort({
|
|
|
3120
3110
|
{
|
|
3121
3111
|
variant: sorting.length > 0 ? "secondary" : "outline",
|
|
3122
3112
|
size: "icon",
|
|
3123
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3113
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_lucide_react15.ArrowUpDownIcon, {})
|
|
3124
3114
|
}
|
|
3125
3115
|
)
|
|
3126
3116
|
}
|
|
@@ -3149,9 +3139,9 @@ function DataTableHeaderSort({
|
|
|
3149
3139
|
}
|
|
3150
3140
|
},
|
|
3151
3141
|
children: [
|
|
3152
|
-
|
|
3153
|
-
isSorted === "asc" && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3154
|
-
isSorted === "desc" && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3142
|
+
headerText,
|
|
3143
|
+
isSorted === "asc" && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_lucide_react15.ArrowUpIcon, { className: "size-3.5" }),
|
|
3144
|
+
isSorted === "desc" && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_lucide_react15.ArrowDownIcon, { className: "size-3.5" })
|
|
3155
3145
|
]
|
|
3156
3146
|
},
|
|
3157
3147
|
column.id
|
|
@@ -3164,7 +3154,7 @@ function DataTableHeaderSort({
|
|
|
3164
3154
|
{
|
|
3165
3155
|
className: "hover:cursor-pointer text-destructive focus:text-destructive",
|
|
3166
3156
|
onClick: () => table.resetSorting(),
|
|
3167
|
-
children: "Clear
|
|
3157
|
+
children: "Clear sorting"
|
|
3168
3158
|
}
|
|
3169
3159
|
)
|
|
3170
3160
|
] })
|
|
@@ -3173,7 +3163,7 @@ function DataTableHeaderSort({
|
|
|
3173
3163
|
}
|
|
3174
3164
|
|
|
3175
3165
|
// src/components/composed/data-table/table-header-toggle.tsx
|
|
3176
|
-
var
|
|
3166
|
+
var import_lucide_react16 = require("lucide-react");
|
|
3177
3167
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3178
3168
|
function DataTableHeaderToggle({
|
|
3179
3169
|
table
|
|
@@ -3186,7 +3176,7 @@ function DataTableHeaderToggle({
|
|
|
3186
3176
|
render: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3187
3177
|
TooltipTrigger,
|
|
3188
3178
|
{
|
|
3189
|
-
render: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Button, { variant: "outline", size: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3179
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Button, { variant: "outline", size: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react16.Columns3CogIcon, {}) })
|
|
3190
3180
|
}
|
|
3191
3181
|
)
|
|
3192
3182
|
}
|
|
@@ -3216,7 +3206,7 @@ function DataTableHeaderToggle({
|
|
|
3216
3206
|
}
|
|
3217
3207
|
|
|
3218
3208
|
// src/components/composed/data-table/data-row-actions.tsx
|
|
3219
|
-
var
|
|
3209
|
+
var import_lucide_react17 = require("lucide-react");
|
|
3220
3210
|
var import_react5 = require("react");
|
|
3221
3211
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
3222
3212
|
function RowActions({
|
|
@@ -3235,19 +3225,19 @@ function RowActions({
|
|
|
3235
3225
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
3236
3226
|
"div",
|
|
3237
3227
|
{
|
|
3238
|
-
className: (0,
|
|
3228
|
+
className: (0, import_cn13.cn)("flex items-center justify-end w-full", containerClassName),
|
|
3239
3229
|
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(DropdownMenu, { children: [
|
|
3240
3230
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
3241
3231
|
DropdownMenuTrigger,
|
|
3242
3232
|
{
|
|
3243
|
-
render: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Button, { variant: "ghost", size: "icon-xs", "aria-label": triggerLabel, children: triggerIcon != null ? triggerIcon : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
3233
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Button, { variant: "ghost", size: "icon-xs", "aria-label": triggerLabel, children: triggerIcon != null ? triggerIcon : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_lucide_react17.MoreHorizontal, { className: "size-4" }) })
|
|
3244
3234
|
}
|
|
3245
3235
|
),
|
|
3246
3236
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
3247
3237
|
DropdownMenuContent,
|
|
3248
3238
|
{
|
|
3249
3239
|
align,
|
|
3250
|
-
className: (0,
|
|
3240
|
+
className: (0, import_cn13.cn)("w-40", contentClassName),
|
|
3251
3241
|
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(DropdownMenuGroup, { children: [
|
|
3252
3242
|
label && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [
|
|
3253
3243
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(DropdownMenuLabel, { children: label }),
|
|
@@ -3264,7 +3254,7 @@ function RowActions({
|
|
|
3264
3254
|
{
|
|
3265
3255
|
onClick: item.onClick,
|
|
3266
3256
|
disabled: item.disabled,
|
|
3267
|
-
className: (0,
|
|
3257
|
+
className: (0, import_cn13.cn)(
|
|
3268
3258
|
"hover:cursor-pointer flex items-center gap-2",
|
|
3269
3259
|
isDestructive && "text-destructive focus:text-destructive",
|
|
3270
3260
|
item.className
|
|
@@ -3297,22 +3287,13 @@ function DataTable({
|
|
|
3297
3287
|
onRefresh,
|
|
3298
3288
|
onDownload,
|
|
3299
3289
|
exportFilename = "data-export",
|
|
3300
|
-
isLoading = false,
|
|
3301
|
-
searchPlaceholder = "Search...",
|
|
3302
3290
|
showSearchInput = true,
|
|
3303
3291
|
showRefreshButton = true,
|
|
3304
3292
|
showSortButton = true,
|
|
3305
3293
|
showFilterButton = true,
|
|
3306
3294
|
showDownloadButton = true,
|
|
3307
3295
|
showColumnToggleButton = true,
|
|
3308
|
-
showAddButton = true
|
|
3309
|
-
emptyIcon,
|
|
3310
|
-
emptyTitle,
|
|
3311
|
-
emptyDescription,
|
|
3312
|
-
emptyButtonText,
|
|
3313
|
-
emptyRender,
|
|
3314
|
-
onEmptyAction,
|
|
3315
|
-
renderEmptyState
|
|
3296
|
+
showAddButton = true
|
|
3316
3297
|
}) {
|
|
3317
3298
|
const [createOpen, setCreateOpen] = (0, import_react6.useState)(false);
|
|
3318
3299
|
const [sorting, setSorting] = (0, import_react6.useState)([]);
|
|
@@ -3328,30 +3309,38 @@ function DataTable({
|
|
|
3328
3309
|
features,
|
|
3329
3310
|
data,
|
|
3330
3311
|
columns: columnsWithSmartFilters,
|
|
3312
|
+
initialState: {
|
|
3313
|
+
globalFilter: ""
|
|
3314
|
+
},
|
|
3331
3315
|
onSortingChange: setSorting,
|
|
3332
3316
|
onColumnFiltersChange: setColumnFilters,
|
|
3333
3317
|
onColumnVisibilityChange: setColumnVisibility,
|
|
3334
|
-
onGlobalFilterChange:
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3318
|
+
onGlobalFilterChange: (updater) => {
|
|
3319
|
+
setGlobalFilter((prev) => {
|
|
3320
|
+
const next = typeof updater === "function" ? updater(prev) : updater;
|
|
3321
|
+
return next != null ? next : "";
|
|
3322
|
+
});
|
|
3323
|
+
},
|
|
3324
|
+
state: {
|
|
3325
|
+
sorting,
|
|
3326
|
+
columnFilters,
|
|
3327
|
+
columnVisibility,
|
|
3328
|
+
globalFilter: globalFilter != null ? globalFilter : ""
|
|
3343
3329
|
}
|
|
3344
|
-
|
|
3330
|
+
});
|
|
3331
|
+
if (data.length === 0) {
|
|
3332
|
+
const hasCreateAction = Boolean(renderCreateDialog);
|
|
3333
|
+
const hasRefreshAction = Boolean(onRefresh);
|
|
3345
3334
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "space-y-2", children: [
|
|
3346
3335
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3347
3336
|
StateEmpty,
|
|
3348
3337
|
{
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
render:
|
|
3338
|
+
state: "outline",
|
|
3339
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react18.FolderOpenIcon, { className: "size-6 text-muted-foreground" }),
|
|
3340
|
+
title: "No Data Available",
|
|
3341
|
+
description: "There are currently no records to display. Create a new record to get started.",
|
|
3342
|
+
buttonText: hasCreateAction ? addLabel != null ? addLabel : "Add Record" : hasRefreshAction ? "Refresh" : void 0,
|
|
3343
|
+
render: hasCreateAction ? () => setCreateOpen(true) : hasRefreshAction ? onRefresh : void 0
|
|
3355
3344
|
}
|
|
3356
3345
|
),
|
|
3357
3346
|
renderCreateDialog == null ? void 0 : renderCreateDialog(createOpen, setCreateOpen)
|
|
@@ -3363,8 +3352,7 @@ function DataTable({
|
|
|
3363
3352
|
DataTableHeaderSearch,
|
|
3364
3353
|
{
|
|
3365
3354
|
value: globalFilter,
|
|
3366
|
-
onChange: setGlobalFilter
|
|
3367
|
-
placeholder: searchPlaceholder
|
|
3355
|
+
onChange: setGlobalFilter
|
|
3368
3356
|
}
|
|
3369
3357
|
) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", {}),
|
|
3370
3358
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-row items-center gap-1", children: [
|
|
@@ -3398,14 +3386,7 @@ function DataTable({
|
|
|
3398
3386
|
renderCreateDialog == null ? void 0 : renderCreateDialog(createOpen, setCreateOpen),
|
|
3399
3387
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "overflow-hidden rounded-md border [&_[data-slot=table-container]]:no-scrollbar", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(Table, { children: [
|
|
3400
3388
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DataTableContentHeader, { table }),
|
|
3401
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3402
|
-
DataTableContentBody,
|
|
3403
|
-
{
|
|
3404
|
-
table,
|
|
3405
|
-
columns,
|
|
3406
|
-
isLoading
|
|
3407
|
-
}
|
|
3408
|
-
)
|
|
3389
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DataTableContentBody, { table, columns })
|
|
3409
3390
|
] }) }),
|
|
3410
3391
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex items-center justify-between px-2", children: [
|
|
3411
3392
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DataTableFooterEntries, { table }),
|
|
@@ -3568,6 +3549,7 @@ var HeaderTitle = (0, import_react8.memo)(function HeaderTitle2({
|
|
|
3568
3549
|
RowActions,
|
|
3569
3550
|
StateEmpty,
|
|
3570
3551
|
exportToCSV,
|
|
3552
|
+
exportToPDF,
|
|
3571
3553
|
exportToXLSX,
|
|
3572
3554
|
features,
|
|
3573
3555
|
flexRender,
|