next-data-kit 8.2.2 → 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 +23 -1
- package/dist/client/components/data-kit-table.js.map +1 -1
- package/dist/index.cjs +23 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -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({
|