@facter/ds-core 1.22.0 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +16 -26
- package/dist/index.d.ts +16 -26
- package/dist/index.js +38 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1110,7 +1110,8 @@ function useDataTableInternal({
|
|
|
1110
1110
|
columns,
|
|
1111
1111
|
getRowId,
|
|
1112
1112
|
manualPagination = false,
|
|
1113
|
-
pageCount: externalPageCount
|
|
1113
|
+
pageCount: externalPageCount,
|
|
1114
|
+
initialPageSize = 10
|
|
1114
1115
|
}) {
|
|
1115
1116
|
const [rowSelection, setRowSelection] = React10.useState({});
|
|
1116
1117
|
const [columnVisibility, setColumnVisibility] = React10.useState({});
|
|
@@ -1120,7 +1121,7 @@ function useDataTableInternal({
|
|
|
1120
1121
|
const [density, setDensity] = React10.useState("default");
|
|
1121
1122
|
const [pagination, setPagination] = React10.useState({
|
|
1122
1123
|
pageIndex: 0,
|
|
1123
|
-
pageSize:
|
|
1124
|
+
pageSize: initialPageSize
|
|
1124
1125
|
});
|
|
1125
1126
|
const table = useReactTable({
|
|
1126
1127
|
data,
|
|
@@ -1343,6 +1344,7 @@ function DataTableRoot({
|
|
|
1343
1344
|
getRowId,
|
|
1344
1345
|
manualPagination,
|
|
1345
1346
|
pageCount,
|
|
1347
|
+
initialPageSize,
|
|
1346
1348
|
className
|
|
1347
1349
|
}) {
|
|
1348
1350
|
const { table, meta, density, setDensity, pageIndex, pageSize } = useDataTableInternal({
|
|
@@ -1350,7 +1352,8 @@ function DataTableRoot({
|
|
|
1350
1352
|
columns,
|
|
1351
1353
|
getRowId,
|
|
1352
1354
|
manualPagination,
|
|
1353
|
-
pageCount
|
|
1355
|
+
pageCount,
|
|
1356
|
+
initialPageSize
|
|
1354
1357
|
});
|
|
1355
1358
|
return /* @__PURE__ */ jsx(
|
|
1356
1359
|
DataTableProvider,
|
|
@@ -1421,27 +1424,23 @@ function useAvailableHeight(options = {}) {
|
|
|
1421
1424
|
function useAutoPageSize(options = {}) {
|
|
1422
1425
|
const {
|
|
1423
1426
|
rowHeight = 49,
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
bottomOffset = 16,
|
|
1427
|
-
minRows = 5,
|
|
1427
|
+
bottomOffset = 64,
|
|
1428
|
+
minRows = 3,
|
|
1428
1429
|
maxRows = 50,
|
|
1429
1430
|
enabled = true
|
|
1430
1431
|
} = options;
|
|
1431
1432
|
const ref = useRef(null);
|
|
1432
1433
|
const [autoPerPage, setAutoPerPage] = useState(minRows);
|
|
1433
1434
|
const [userOverride, setUserOverride] = useState(null);
|
|
1434
|
-
const hasCalculated = useRef(false);
|
|
1435
1435
|
const calculate = useCallback(() => {
|
|
1436
1436
|
const el = ref.current;
|
|
1437
1437
|
if (!el || !enabled) return;
|
|
1438
1438
|
const rect = el.getBoundingClientRect();
|
|
1439
|
-
const availableHeight = window.innerHeight - rect.top -
|
|
1439
|
+
const availableHeight = window.innerHeight - rect.top - bottomOffset;
|
|
1440
1440
|
const rows = Math.floor(availableHeight / rowHeight);
|
|
1441
1441
|
const clamped = Math.max(minRows, Math.min(maxRows, rows));
|
|
1442
1442
|
setAutoPerPage(clamped);
|
|
1443
|
-
|
|
1444
|
-
}, [rowHeight, headerHeight, paginationHeight, bottomOffset, minRows, maxRows, enabled]);
|
|
1443
|
+
}, [rowHeight, bottomOffset, minRows, maxRows, enabled]);
|
|
1445
1444
|
useEffect(() => {
|
|
1446
1445
|
if (!enabled) return;
|
|
1447
1446
|
const frame = requestAnimationFrame(calculate);
|
|
@@ -1454,14 +1453,12 @@ function useAutoPageSize(options = {}) {
|
|
|
1454
1453
|
const setPerPage = useCallback((size) => {
|
|
1455
1454
|
setUserOverride(size);
|
|
1456
1455
|
}, []);
|
|
1457
|
-
const perPage = userOverride ?? autoPerPage;
|
|
1458
1456
|
return {
|
|
1459
1457
|
ref,
|
|
1460
|
-
perPage,
|
|
1458
|
+
perPage: userOverride ?? autoPerPage,
|
|
1461
1459
|
setPerPage,
|
|
1462
1460
|
autoPerPage,
|
|
1463
|
-
isAutoSized: userOverride === null
|
|
1464
|
-
isReady: hasCalculated.current
|
|
1461
|
+
isAutoSized: userOverride === null
|
|
1465
1462
|
};
|
|
1466
1463
|
}
|
|
1467
1464
|
var Table = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
@@ -1549,6 +1546,7 @@ var DataTableContent = React10.memo(function DataTableContent2({
|
|
|
1549
1546
|
onRowClick,
|
|
1550
1547
|
scrollable = false,
|
|
1551
1548
|
scrollBottomOffset = 68,
|
|
1549
|
+
autoPageSize = false,
|
|
1552
1550
|
className
|
|
1553
1551
|
}) {
|
|
1554
1552
|
const table = useDataTable();
|
|
@@ -1556,15 +1554,36 @@ var DataTableContent = React10.memo(function DataTableContent2({
|
|
|
1556
1554
|
const { density } = useDataTableDensity();
|
|
1557
1555
|
const { config: emptyStateConfig } = useDataTableEmptyStateConfig();
|
|
1558
1556
|
const { isLoading, skeletonRows } = useDataTableLoadingState();
|
|
1559
|
-
const {
|
|
1557
|
+
const { setPageSize } = useDataTablePagination();
|
|
1558
|
+
const tbodyRef = React10.useRef(null);
|
|
1559
|
+
const { ref: scrollRef, style: scrollStyle } = useAvailableHeight({
|
|
1560
1560
|
bottomOffset: scrollBottomOffset,
|
|
1561
1561
|
enabled: scrollable
|
|
1562
1562
|
});
|
|
1563
1563
|
const densityStyles = DENSITY_CONFIG[density];
|
|
1564
|
+
const rowHeight = densityStyles.rowHeight + 1;
|
|
1564
1565
|
const cellClasses = cn(densityStyles.padding, densityStyles.fontSize);
|
|
1565
1566
|
const columnCount = table.getVisibleLeafColumns().length;
|
|
1566
1567
|
const hasRows = table.getRowModel().rows?.length > 0;
|
|
1567
1568
|
const effectiveStickyHeader = stickyHeader || scrollable;
|
|
1569
|
+
React10.useEffect(() => {
|
|
1570
|
+
if (!autoPageSize) return;
|
|
1571
|
+
const calculate = () => {
|
|
1572
|
+
const tbody = tbodyRef.current;
|
|
1573
|
+
if (!tbody) return;
|
|
1574
|
+
const rect = tbody.getBoundingClientRect();
|
|
1575
|
+
const available = window.innerHeight - rect.top - 68;
|
|
1576
|
+
const rows = Math.floor(available / rowHeight);
|
|
1577
|
+
const clamped = Math.max(3, Math.min(50, rows));
|
|
1578
|
+
setPageSize(clamped);
|
|
1579
|
+
};
|
|
1580
|
+
const frame = requestAnimationFrame(calculate);
|
|
1581
|
+
window.addEventListener("resize", calculate);
|
|
1582
|
+
return () => {
|
|
1583
|
+
cancelAnimationFrame(frame);
|
|
1584
|
+
window.removeEventListener("resize", calculate);
|
|
1585
|
+
};
|
|
1586
|
+
}, [autoPageSize, rowHeight, setPageSize]);
|
|
1568
1587
|
if (!hasRows && isEmpty && !isLoading) {
|
|
1569
1588
|
return /* @__PURE__ */ jsx(
|
|
1570
1589
|
EmptyState,
|
|
@@ -1579,7 +1598,7 @@ var DataTableContent = React10.memo(function DataTableContent2({
|
|
|
1579
1598
|
return /* @__PURE__ */ jsx(
|
|
1580
1599
|
"div",
|
|
1581
1600
|
{
|
|
1582
|
-
ref,
|
|
1601
|
+
ref: scrollRef,
|
|
1583
1602
|
className: cn("rounded-md overflow-auto bg-card", className),
|
|
1584
1603
|
style: scrollStyle,
|
|
1585
1604
|
children: /* @__PURE__ */ jsxs(Table, { children: [
|
|
@@ -1603,7 +1622,7 @@ var DataTableContent = React10.memo(function DataTableContent2({
|
|
|
1603
1622
|
)) }, headerGroup.id))
|
|
1604
1623
|
}
|
|
1605
1624
|
),
|
|
1606
|
-
/* @__PURE__ */ jsx(TableBody, { children: isLoading ? Array.from({ length: skeletonRows }).map((_, index) => /* @__PURE__ */ jsx(TableRow, { className: "animate-pulse", children: Array.from({ length: columnCount || 4 }).map((_2, colIndex) => /* @__PURE__ */ jsx(TableCell, { className: cellClasses, children: /* @__PURE__ */ jsx("div", { className: "h-4 bg-muted rounded w-3/4" }) }, colIndex)) }, `skeleton-${index}`)) : table.getRowModel().rows.map((row, index) => /* @__PURE__ */ jsx(
|
|
1625
|
+
/* @__PURE__ */ jsx(TableBody, { ref: tbodyRef, children: isLoading ? Array.from({ length: skeletonRows }).map((_, index) => /* @__PURE__ */ jsx(TableRow, { className: "animate-pulse", children: Array.from({ length: columnCount || 4 }).map((_2, colIndex) => /* @__PURE__ */ jsx(TableCell, { className: cellClasses, children: /* @__PURE__ */ jsx("div", { className: "h-4 bg-muted rounded w-3/4" }) }, colIndex)) }, `skeleton-${index}`)) : table.getRowModel().rows.map((row, index) => /* @__PURE__ */ jsx(
|
|
1607
1626
|
TableRow,
|
|
1608
1627
|
{
|
|
1609
1628
|
"data-state": row.getIsSelected() && "selected",
|
|
@@ -1783,7 +1802,6 @@ var DataTablePagination = React10.memo(function DataTablePagination2({
|
|
|
1783
1802
|
firstPage,
|
|
1784
1803
|
lastPage
|
|
1785
1804
|
} = paginationHook;
|
|
1786
|
-
console.log("[DataTablePagination] render", { mode, pageIndex, pageSize, externalPageCount, internalPageCount });
|
|
1787
1805
|
const pageCount = mode === "server" && externalPageCount !== void 0 ? externalPageCount : internalPageCount;
|
|
1788
1806
|
const canGoPrevious = pageIndex > 0;
|
|
1789
1807
|
const canGoNext = pageIndex < pageCount - 1;
|
|
@@ -1861,11 +1879,7 @@ var DataTablePagination = React10.memo(function DataTablePagination2({
|
|
|
1861
1879
|
variant: "outline",
|
|
1862
1880
|
size: "icon-sm",
|
|
1863
1881
|
className: "h-8 w-8 p-0",
|
|
1864
|
-
onClick:
|
|
1865
|
-
console.log("[DataTablePagination] nextPage clicked, current pageIndex:", pageIndex);
|
|
1866
|
-
nextPage();
|
|
1867
|
-
console.log("[DataTablePagination] nextPage called");
|
|
1868
|
-
},
|
|
1882
|
+
onClick: nextPage,
|
|
1869
1883
|
disabled: !canGoNext,
|
|
1870
1884
|
"aria-label": "Pr\xF3xima p\xE1gina",
|
|
1871
1885
|
children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
|