next-data-kit 8.2.1 → 8.3.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/client/components/data-kit-table.d.ts.map +1 -1
- package/dist/client/components/data-kit-table.js +24 -2
- package/dist/client/components/data-kit-table.js.map +1 -1
- package/dist/client/components/ui/pagination.d.ts.map +1 -1
- package/dist/client/components/ui/pagination.js +1 -1
- package/dist/client/components/ui/pagination.js.map +1 -1
- package/dist/index.cjs +28 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1003,7 +1003,7 @@ function Pagination({ className, ...props }) {
|
|
|
1003
1003
|
role: "navigation",
|
|
1004
1004
|
"aria-label": "pagination",
|
|
1005
1005
|
"data-slot": "pagination",
|
|
1006
|
-
className: cn("
|
|
1006
|
+
className: cn("flex", className),
|
|
1007
1007
|
...props
|
|
1008
1008
|
}
|
|
1009
1009
|
);
|
|
@@ -1260,6 +1260,7 @@ var DataKitRoot = (props) => {
|
|
|
1260
1260
|
const [actionLoading, setActionLoading] = useState(null);
|
|
1261
1261
|
const [actionsMenuOpen, setActionsMenuOpen] = useState(false);
|
|
1262
1262
|
const [rowStates, setRowStates] = useState(/* @__PURE__ */ new Map());
|
|
1263
|
+
const [lastSelectedIndex, setLastSelectedIndex] = useState(null);
|
|
1263
1264
|
const overlayContainer = tableRef.current;
|
|
1264
1265
|
const getRowState = useCallback((rowId) => {
|
|
1265
1266
|
return rowStates.get(rowId) ?? initialState;
|
|
@@ -1335,6 +1336,24 @@ var DataKitRoot = (props) => {
|
|
|
1335
1336
|
});
|
|
1336
1337
|
}, [filters, dataKit.actions]);
|
|
1337
1338
|
const getSortFor = useCallback((path) => dataKit.sorts.find((s) => s.path === path)?.value ?? null, [dataKit.sorts]);
|
|
1339
|
+
const handleRowSelection = useCallback((rowIndex, event) => {
|
|
1340
|
+
if (event.shiftKey && lastSelectedIndex !== null) {
|
|
1341
|
+
const start = Math.min(lastSelectedIndex, rowIndex);
|
|
1342
|
+
const end = Math.max(lastSelectedIndex, rowIndex);
|
|
1343
|
+
for (let i = start; i <= end; i++) {
|
|
1344
|
+
const item = dataKit.items[i];
|
|
1345
|
+
if (item && item.id !== void 0 && !selection.isSelected(item.id)) {
|
|
1346
|
+
selection.select(item.id);
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
} else {
|
|
1350
|
+
const item = dataKit.items[rowIndex];
|
|
1351
|
+
if (item && item.id !== void 0) {
|
|
1352
|
+
selection.toggle(item.id);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
setLastSelectedIndex(rowIndex);
|
|
1356
|
+
}, [lastSelectedIndex, dataKit.items, selection]);
|
|
1338
1357
|
useEffect(() => {
|
|
1339
1358
|
if (controller) {
|
|
1340
1359
|
controller.current = {
|
|
@@ -1481,11 +1500,13 @@ var DataKitRoot = (props) => {
|
|
|
1481
1500
|
] }) }) : dataKit.items.length === 0 ? /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colSpan, className: "h-24 text-center text-muted-foreground", children: "No results found." }) }) : dataKit.items.map((item, idx) => {
|
|
1482
1501
|
const rowId = item.id ?? idx;
|
|
1483
1502
|
return /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1484
|
-
selectable?.enabled && /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(
|
|
1503
|
+
selectable?.enabled && /* @__PURE__ */ jsx(TableCell, { onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx(
|
|
1485
1504
|
Checkbox,
|
|
1486
1505
|
{
|
|
1487
1506
|
checked: selection.isSelected(item.id),
|
|
1488
|
-
onCheckedChange: () =>
|
|
1507
|
+
onCheckedChange: () => {
|
|
1508
|
+
},
|
|
1509
|
+
onClick: (e) => handleRowSelection(idx, e)
|
|
1489
1510
|
}
|
|
1490
1511
|
) }),
|
|
1491
1512
|
columns.map((col, colIdx) => /* @__PURE__ */ jsx(React2__default.Fragment, { children: col.body({
|
|
@@ -1499,7 +1520,7 @@ var DataKitRoot = (props) => {
|
|
|
1499
1520
|
] }, rowId);
|
|
1500
1521
|
}) })
|
|
1501
1522
|
] }) }),
|
|
1502
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between
|
|
1523
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 justify-between", children: [
|
|
1503
1524
|
/* @__PURE__ */ jsxs("div", { className: "min-w-[140px]", children: [
|
|
1504
1525
|
/* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", children: [
|
|
1505
1526
|
"Page ",
|
|
@@ -1513,7 +1534,7 @@ var DataKitRoot = (props) => {
|
|
|
1513
1534
|
] })
|
|
1514
1535
|
] }),
|
|
1515
1536
|
/* @__PURE__ */ jsx("div", { className: "flex-1" }),
|
|
1516
|
-
paginationType === "SIMPLE" ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
1537
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end w-full", children: paginationType === "SIMPLE" ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
1517
1538
|
/* @__PURE__ */ jsx(
|
|
1518
1539
|
Button,
|
|
1519
1540
|
{
|
|
@@ -1534,7 +1555,7 @@ var DataKitRoot = (props) => {
|
|
|
1534
1555
|
children: /* @__PURE__ */ jsx(ChevronRight, { className: "size-4" })
|
|
1535
1556
|
}
|
|
1536
1557
|
)
|
|
1537
|
-
] }) : /* @__PURE__ */ jsx(Pagination, { className: "
|
|
1558
|
+
] }) : /* @__PURE__ */ jsx(Pagination, { className: "w-auto", children: /* @__PURE__ */ jsxs(PaginationContent, { children: [
|
|
1538
1559
|
/* @__PURE__ */ jsx(PaginationItem, { className: "hidden sm:block", children: /* @__PURE__ */ jsx(
|
|
1539
1560
|
PaginationPrevious,
|
|
1540
1561
|
{
|
|
@@ -1575,7 +1596,7 @@ var DataKitRoot = (props) => {
|
|
|
1575
1596
|
children: /* @__PURE__ */ jsx(ChevronRight, { className: "size-4" })
|
|
1576
1597
|
}
|
|
1577
1598
|
) })
|
|
1578
|
-
] }) })
|
|
1599
|
+
] }) }) })
|
|
1579
1600
|
] })
|
|
1580
1601
|
] });
|
|
1581
1602
|
};
|