react-arborist 2.1.1 → 2.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.
@@ -42,6 +42,7 @@ export declare class TreeApi<T> {
42
42
  get height(): number;
43
43
  get indent(): number;
44
44
  get rowHeight(): number;
45
+ get overscanCount(): number;
45
46
  get searchTerm(): string;
46
47
  get matchFn(): (node: NodeApi<T>) => boolean;
47
48
  accessChildren(data: T): T[] | null;
package/dist/module.js CHANGED
@@ -471,8 +471,8 @@ class $096e74084443e9a3$export$d4b903da0f522dc8 {
471
471
  return this.tree.edit(this);
472
472
  }
473
473
  handleClick = (e)=>{
474
- if (e.metaKey) this.isSelected ? this.deselect() : this.selectMulti();
475
- else if (e.shiftKey) this.selectContiguous();
474
+ if (e.metaKey && !this.tree.props.disableMultiSelection) this.isSelected ? this.deselect() : this.selectMulti();
475
+ else if (e.shiftKey && !this.tree.props.disableMultiSelection) this.selectContiguous();
476
476
  else {
477
477
  this.select();
478
478
  this.activate();
@@ -1241,7 +1241,9 @@ const $8c3aed0a01f84486$export$a9754b3c8daa5172 = /*#__PURE__*/ (0, $g00cZ$react
1241
1241
  className: tree.props.rowClassName
1242
1242
  };
1243
1243
  (0, $g00cZ$useEffect)(()=>{
1244
- if (!node.isEditing && node.isFocused) el.current?.focus();
1244
+ if (!node.isEditing && node.isFocused) el.current?.focus({
1245
+ preventScroll: true
1246
+ });
1245
1247
  }, [
1246
1248
  node.isEditing,
1247
1249
  node.isFocused,
@@ -1320,36 +1322,39 @@ function $065a164934293bf2$export$ff4858a4110d9246() {
1320
1322
  (0, $0e6083160f4b36ed$export$33b47db07a82b2fb)(e.currentTarget);
1321
1323
  return;
1322
1324
  }
1323
- if (e.key === "ArrowDown" && !e.shiftKey && !e.metaKey) {
1325
+ if (e.key === "ArrowDown") {
1324
1326
  e.preventDefault();
1325
1327
  const next = tree.nextNode;
1326
- tree.focus(next);
1327
- return;
1328
- }
1329
- if (e.key === "ArrowDown" && e.shiftKey) {
1330
- e.preventDefault();
1331
- const next1 = tree.nextNode;
1332
- if (!next1) return;
1333
- const current = tree.focusedNode;
1334
- if (!current) tree.focus(tree.firstNode);
1335
- else if (current.isSelected) tree.selectContiguous(next1);
1336
- else tree.selectMulti(next1);
1337
- return;
1338
- }
1339
- if (e.key === "ArrowUp" && !e.shiftKey) {
1340
- e.preventDefault();
1341
- tree.focus(tree.prevNode);
1342
- return;
1328
+ if (e.metaKey) {
1329
+ tree.select(tree.focusedNode);
1330
+ tree.activate(tree.focusedNode);
1331
+ return;
1332
+ } else if (!e.shiftKey || tree.props.disableMultiSelection) {
1333
+ tree.focus(next);
1334
+ return;
1335
+ } else {
1336
+ if (!next) return;
1337
+ const current = tree.focusedNode;
1338
+ if (!current) tree.focus(tree.firstNode);
1339
+ else if (current.isSelected) tree.selectContiguous(next);
1340
+ else tree.selectMulti(next);
1341
+ return;
1342
+ }
1343
1343
  }
1344
- if (e.key === "ArrowUp" && e.shiftKey) {
1344
+ if (e.key === "ArrowUp") {
1345
1345
  e.preventDefault();
1346
1346
  const prev = tree.prevNode;
1347
- const current1 = tree.focusedNode;
1348
- if (!prev) return;
1349
- if (!current1) tree.focus(tree.lastNode); // ?
1350
- else if (current1.isSelected) tree.selectContiguous(prev);
1351
- else tree.selectMulti(prev);
1352
- return;
1347
+ if (!e.shiftKey || tree.props.disableMultiSelection) {
1348
+ tree.focus(prev);
1349
+ return;
1350
+ } else {
1351
+ if (!prev) return;
1352
+ const current1 = tree.focusedNode;
1353
+ if (!current1) tree.focus(tree.lastNode); // ?
1354
+ else if (current1.isSelected) tree.selectContiguous(prev);
1355
+ else tree.selectMulti(prev);
1356
+ return;
1357
+ }
1353
1358
  }
1354
1359
  if (e.key === "ArrowRight") {
1355
1360
  const node1 = tree.focusedNode;
@@ -1365,13 +1370,12 @@ function $065a164934293bf2$export$ff4858a4110d9246() {
1365
1370
  else if (!node2.parent?.isRoot) tree.focus(node2.parent);
1366
1371
  return;
1367
1372
  }
1368
- if (e.key === "a" && e.metaKey) {
1373
+ if (e.key === "a" && e.metaKey && !tree.props.disableMultiSelection) {
1369
1374
  e.preventDefault();
1370
1375
  tree.selectAll();
1371
1376
  return;
1372
1377
  }
1373
- if (e.key === "a" && !e.metaKey) {
1374
- if (!tree.props.onCreate) return;
1378
+ if (e.key === "a" && !e.metaKey && tree.props.onCreate) {
1375
1379
  tree.createLeaf();
1376
1380
  return;
1377
1381
  }
@@ -1415,12 +1419,6 @@ function $065a164934293bf2$export$ff4858a4110d9246() {
1415
1419
  tree.openSiblings(node4);
1416
1420
  return;
1417
1421
  }
1418
- if (e.key === "ArrowDown" && e.metaKey) {
1419
- e.preventDefault();
1420
- tree.select(tree.focusedNode);
1421
- tree.activate(tree.focusedNode);
1422
- return;
1423
- }
1424
1422
  if (e.key === "PageUp") {
1425
1423
  e.preventDefault();
1426
1424
  tree.pageUp();
@@ -1454,6 +1452,7 @@ function $065a164934293bf2$export$ff4858a4110d9246() {
1454
1452
  height: tree.height,
1455
1453
  width: tree.width,
1456
1454
  itemSize: tree.rowHeight,
1455
+ overscanCount: tree.overscanCount,
1457
1456
  itemKey: (index)=>tree.visibleNodes[index]?.id || index,
1458
1457
  outerElementType: (0, $05f64c7ebcbad8b5$export$70c2b8898b86d3ad),
1459
1458
  innerElementType: (0, $da9a6b47b6fff922$export$a9af0da3ae60cd00),
@@ -1551,6 +1550,9 @@ class $bfece7c4aed4e9c4$export$e2da3477247342d1 {
1551
1550
  get rowHeight() {
1552
1551
  return this.props.rowHeight ?? 24;
1553
1552
  }
1553
+ get overscanCount() {
1554
+ return this.props.overscanCount ?? 1;
1555
+ }
1554
1556
  get searchTerm() {
1555
1557
  return (this.props.searchTerm || "").trim();
1556
1558
  }
@@ -1873,7 +1875,7 @@ class $bfece7c4aed4e9c4$export$e2da3477247342d1 {
1873
1875
  if (index === undefined) return;
1874
1876
  this.list.current?.scrollToItem(index, align);
1875
1877
  }).catch(()=>{
1876
- console.log(`Id: ${id} never appeared in the list.`);
1878
+ // Id: ${id} never appeared in the list.
1877
1879
  });
1878
1880
  }
1879
1881
  /* State Checks */ get isEditing() {