react-arborist 2.2.0 → 3.0.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/README.md CHANGED
@@ -96,6 +96,7 @@ function App() {
96
96
  height={1000}
97
97
  indent={24}
98
98
  rowHeight={36}
99
+ overscanCount={1}
99
100
  paddingTop={30}
100
101
  paddingBottom={10}
101
102
  padding={25 /* sets both */}
@@ -264,24 +265,26 @@ These are all the props you can pass to the Tree component.
264
265
  ```ts
265
266
  interface TreeProps<T> {
266
267
  /* Data Options */
267
- data?: T[];
268
- initialData?: T[];
268
+ data?: readonly T[];
269
+ initialData?: readonly T[];
269
270
 
270
271
  /* Data Handlers */
271
- onCreate?: handlers.CreateHandler;
272
- onMove?: handlers.MoveHandler;
273
- onRename?: handlers.RenameHandler;
274
- onDelete?: handlers.DeleteHandler;
272
+ onCreate?: handlers.CreateHandler<T>;
273
+ onMove?: handlers.MoveHandler<T>;
274
+ onRename?: handlers.RenameHandler<T>;
275
+ onDelete?: handlers.DeleteHandler<T>;
275
276
 
276
277
  /* Renderers*/
277
278
  children?: ElementType<renderers.NodeRendererProps<T>>;
278
279
  renderRow?: ElementType<renderers.RowRendererProps<T>>;
279
280
  renderDragPreview?: ElementType<renderers.DragPreviewProps>;
280
281
  renderCursor?: ElementType<renderers.CursorProps>;
282
+ renderContainer?: ElementType<{}>;
281
283
 
282
284
  /* Sizes */
283
285
  rowHeight?: number;
284
- width?: number;
286
+ overscanCount?: number;
287
+ width?: number | string;
285
288
  height?: number;
286
289
  indent?: number;
287
290
  paddingTop?: number;
@@ -289,13 +292,21 @@ interface TreeProps<T> {
289
292
  padding?: number;
290
293
 
291
294
  /* Config */
295
+ childrenAccessor?: string | ((d: T) => T[] | null);
296
+ idAccessor?: string | ((d: T) => string);
292
297
  openByDefault?: boolean;
293
298
  selectionFollowsFocus?: boolean;
294
299
  disableMultiSelection?: boolean;
300
+ disableEdit?: string | boolean | BoolFunc<T>;
295
301
  disableDrag?: string | boolean | BoolFunc<T>;
296
- disableDrop?: string | boolean | BoolFunc<T>;
297
- childrenAccessor?: string | ((d: T) => T[]);
298
- idAccessor?: string | ((d: T) => string);
302
+ disableDrop?:
303
+ | string
304
+ | boolean
305
+ | ((args: {
306
+ parentNode: NodeApi<T>;
307
+ dragNodes: NodeApi<T>[];
308
+ index: number;
309
+ }) => boolean);
299
310
 
300
311
  /* Event Handlers */
301
312
  onActivate?: (node: NodeApi<T>) => void;
@@ -317,6 +328,7 @@ interface TreeProps<T> {
317
328
  /* Extra */
318
329
  className?: string | undefined;
319
330
  rowClassName?: string | undefined;
331
+
320
332
  dndRootElement?: globalThis.Node | null;
321
333
  onClick?: MouseEventHandler;
322
334
  onContextMenu?: MouseEventHandler;
@@ -1,2 +1,2 @@
1
1
  import React from "react";
2
- export declare const ListInnerElement: (props: any) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
2
+ export declare const ListInnerElement: React.ForwardRefExoticComponent<Pick<any, string | number | symbol> & React.RefAttributes<any>>;
@@ -1,2 +1,2 @@
1
1
  /// <reference types="react" />
2
- export declare const ListOuterElement: (props: import("react").HTMLProps<HTMLDivElement> & import("react").RefAttributes<unknown>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
2
+ export declare const ListOuterElement: import("react").ForwardRefExoticComponent<Pick<import("react").HTMLProps<HTMLDivElement>, "id" | "children" | "data" | "open" | "cite" | "form" | "label" | "slot" | "span" | "style" | "summary" | "title" | "pattern" | "start" | "hidden" | "color" | "content" | "size" | "default" | "wrap" | "multiple" | "disabled" | "onFocus" | "onClick" | "list" | "name" | "defaultValue" | "onBlur" | "onKeyDown" | "accessKey" | "dir" | "draggable" | "lang" | "translate" | "className" | "classID" | "value" | "defaultChecked" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "download" | "alt" | "coords" | "autoPlay" | "controls" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "dateTime" | "acceptCharset" | "action" | "autoComplete" | "encType" | "manifest" | "allowFullScreen" | "allowTransparency" | "frameBorder" | "accept" | "capture" | "checked" | "challenge" | "keyType" | "keyParams" | "htmlFor" | "as" | "charSet" | "httpEquiv" | "high" | "low" | "reversed" | "selected" | "async" | "cellPadding" | "cellSpacing" | "colSpan" | "headers" | "rowSpan" | "scope" | "cols" | "maxLength" | "minLength" | "kind" | "src" | "srcLang" | "preload" | "crossOrigin" | "defer" | "height" | "href" | "hrefLang" | "integrity" | "loop" | "marginHeight" | "marginWidth" | "max" | "media" | "mediaGroup" | "method" | "min" | "muted" | "nonce" | "noValidate" | "optimum" | "placeholder" | "playsInline" | "poster" | "readOnly" | "rel" | "required" | "rows" | "sandbox" | "scoped" | "scrolling" | "seamless" | "shape" | "sizes" | "srcDoc" | "srcSet" | "step" | "target" | "type" | "useMap" | "width" | "wmode" | "contentEditable" | "contextMenu" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key"> & import("react").RefAttributes<unknown>>;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { TreeApi } from "../interfaces/tree-api";
3
3
  import { TreeProps } from "../types/tree-props";
4
- export declare const Tree: <T>(props: TreeProps<T> & import("react").RefAttributes<TreeApi<T> | undefined>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
4
+ export declare const Tree: import("react").ForwardRefExoticComponent<TreeProps<unknown> & import("react").RefAttributes<TreeApi<unknown> | undefined>>;
package/dist/index.js CHANGED
@@ -201,7 +201,7 @@ function $eb5355379510ac9b$export$58fe32731f07ed56(tree) {
201
201
  const focus = tree.focusedNode;
202
202
  if (!focus) return null;
203
203
  if (focus.isOpen) return focus.id;
204
- if (focus.parent) return focus.parent.id;
204
+ if (focus.parent && !focus.parent.isRoot) return focus.parent.id;
205
205
  return null;
206
206
  }
207
207
 
@@ -374,7 +374,6 @@ class $9b37fe5960a1a3c6$export$d4b903da0f522dc8 {
374
374
  this.children = params.children;
375
375
  this.parent = params.parent;
376
376
  this.isDraggable = params.isDraggable;
377
- this.isDroppable = params.isDroppable;
378
377
  this.rowIndex = params.rowIndex;
379
378
  }
380
379
  get isRoot() {
@@ -392,6 +391,9 @@ class $9b37fe5960a1a3c6$export$d4b903da0f522dc8 {
392
391
  get isClosed() {
393
392
  return this.isLeaf ? false : !this.tree.isOpen(this.id);
394
393
  }
394
+ get isEditable() {
395
+ return this.tree.isEditable(this.data);
396
+ }
395
397
  get isEditing() {
396
398
  return this.tree.editingId === this.id;
397
399
  }
@@ -514,7 +516,6 @@ function $0d7f39915c1a8ae9$export$882461b6382ed46c(tree) {
514
516
  id: id,
515
517
  children: null,
516
518
  isDraggable: tree.isDraggable(data),
517
- isDroppable: tree.isDroppable(data),
518
519
  rowIndex: null
519
520
  });
520
521
  const children = tree.accessChildren(data);
@@ -532,7 +533,6 @@ function $0d7f39915c1a8ae9$export$882461b6382ed46c(tree) {
532
533
  parent: null,
533
534
  children: null,
534
535
  isDraggable: true,
535
- isDroppable: true,
536
536
  rowIndex: null
537
537
  });
538
538
  const data = tree.props.data ?? [];
@@ -635,7 +635,10 @@ const $9d556ecd8e421ffe$export$d4c72bab9d6cc13a = (props)=>({
635
635
  cursor: {
636
636
  type: "none"
637
637
  },
638
- dragId: null
638
+ dragId: null,
639
+ dragIds: [],
640
+ parentId: null,
641
+ index: -1
639
642
  }
640
643
  });
641
644
 
@@ -731,16 +734,24 @@ const $7d98f5b84ecaa66b$export$e324594224ef24da = {
731
734
  cursor: cursor
732
735
  };
733
736
  },
734
- dragStart (id) {
737
+ dragStart (id, dragIds) {
735
738
  return {
736
739
  type: "DND_DRAG_START",
737
- id: id
740
+ id: id,
741
+ dragIds: dragIds
738
742
  };
739
743
  },
740
744
  dragEnd () {
741
745
  return {
742
746
  type: "DND_DRAG_END"
743
747
  };
748
+ },
749
+ hovering (parentId, index) {
750
+ return {
751
+ type: "DND_HOVERING",
752
+ parentId: parentId,
753
+ index: index
754
+ };
744
755
  }
745
756
  };
746
757
  function $7d98f5b84ecaa66b$export$1650419e431d3ba3(state = (0, $9d556ecd8e421ffe$export$d4c72bab9d6cc13a)()["dnd"], action) {
@@ -753,12 +764,16 @@ function $7d98f5b84ecaa66b$export$1650419e431d3ba3(state = (0, $9d556ecd8e421ffe
753
764
  case "DND_DRAG_START":
754
765
  return {
755
766
  ...state,
756
- dragId: action.id
767
+ dragId: action.id,
768
+ dragIds: action.dragIds
757
769
  };
758
770
  case "DND_DRAG_END":
771
+ return (0, $9d556ecd8e421ffe$export$d4c72bab9d6cc13a)()["dnd"];
772
+ case "DND_HOVERING":
759
773
  return {
760
774
  ...state,
761
- dragId: null
775
+ parentId: action.parentId,
776
+ index: action.index
762
777
  };
763
778
  default:
764
779
  return state;
@@ -946,32 +961,32 @@ function $74bee24dbb0f3e2b$export$715c0d031ede7907(node) {
946
961
  const [_, ref, preview] = (0, $foSVk$reactdnd.useDrag)(()=>({
947
962
  canDrag: ()=>node.isDraggable,
948
963
  type: "NODE",
949
- item: ()=>({
950
- id: node.id,
951
- dragIds: tree.isSelected(node.id) ? Array.from(ids) : [
952
- node.id
953
- ]
954
- }),
955
- start: ()=>{
956
- tree.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).dragStart(node.id));
964
+ item: ()=>{
965
+ // This is fired once at the begging of a drag operation
966
+ const dragIds = tree.isSelected(node.id) ? Array.from(ids) : [
967
+ node.id
968
+ ];
969
+ tree.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).dragStart(node.id, dragIds));
970
+ return {
971
+ id: node.id
972
+ };
957
973
  },
958
- end: (item, monitor)=>{
959
- tree.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).dragEnd());
974
+ end: ()=>{
960
975
  tree.hideCursor();
961
- const drop = monitor.getDropResult();
976
+ let { parentId: parentId , index: index , dragIds: dragIds } = tree.state.dnd;
962
977
  // If they held down meta, we need to create a copy
963
978
  // if (drop.dropEffect === "copy")
964
- if (drop && drop.parentId) {
965
- const parentId = drop.parentId === (0, $0d7f39915c1a8ae9$export$ec71a3379b43ae5c) ? null : drop.parentId;
979
+ if (tree.canDrop()) {
966
980
  (0, $eb5355379510ac9b$export$c6d63370cef03886)(tree.props.onMove, {
967
- dragIds: item.dragIds,
968
- parentId: parentId,
969
- index: drop.index,
970
- dragNodes: item.dragIds.map((id)=>tree.get(id)),
971
- parentNode: tree.get(drop.parentId)
981
+ dragIds: dragIds,
982
+ parentId: parentId === (0, $0d7f39915c1a8ae9$export$ec71a3379b43ae5c) ? null : parentId,
983
+ index: index,
984
+ dragNodes: tree.dragNodes,
985
+ parentNode: tree.get(parentId)
972
986
  });
973
- tree.open(drop.parentId);
987
+ tree.open(parentId);
974
988
  }
989
+ tree.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).dragEnd());
975
990
  }
976
991
  }), [
977
992
  ids,
@@ -989,7 +1004,6 @@ function $74bee24dbb0f3e2b$export$715c0d031ede7907(node) {
989
1004
 
990
1005
 
991
1006
 
992
-
993
1007
  function $462841de7cc5b715$var$measureHover(el, offset) {
994
1008
  const rect = el.getBoundingClientRect();
995
1009
  const x = offset.x - Math.round(rect.x);
@@ -1056,16 +1070,6 @@ function $462841de7cc5b715$var$getDropLevel(hovering, aboveCursor, belowCursor,
1056
1070
  }
1057
1071
  return (0, $eb5355379510ac9b$export$adf7c0fe6059d774)(hoverLevel, min, max);
1058
1072
  }
1059
- function $462841de7cc5b715$var$canDrop(above, below) {
1060
- if (!above) return true;
1061
- let n = above;
1062
- if ((0, $eb5355379510ac9b$export$4210f5ea57fbae57)(above) && above !== below) n = above.parent;
1063
- while(n){
1064
- if (!n.isDroppable) return false;
1065
- n = n.parent;
1066
- }
1067
- return true;
1068
- }
1069
1073
  function $462841de7cc5b715$var$dropAt(parentId, index) {
1070
1074
  return {
1071
1075
  parentId: parentId || null,
@@ -1104,10 +1108,6 @@ function $462841de7cc5b715$export$f502ca02ebb85a1c(args) {
1104
1108
  const hover = $462841de7cc5b715$var$measureHover(args.element, args.offset);
1105
1109
  const { node: node , nextNode: nextNode , prevNode: prevNode } = args;
1106
1110
  const [above, below] = $462841de7cc5b715$var$getNodesAroundCursor(node, prevNode, nextNode, hover);
1107
- if (!$462841de7cc5b715$var$canDrop(above, below)) return {
1108
- drop: null,
1109
- cursor: $462841de7cc5b715$var$noCursor()
1110
- };
1111
1111
  /* Hovering over the middle of a folder */ if (node && node.isInternal && hover.inMiddle) return {
1112
1112
  drop: $462841de7cc5b715$var$dropAt(node.id, 0),
1113
1113
  cursor: $462841de7cc5b715$var$highlightCursor(node.id)
@@ -1130,15 +1130,16 @@ function $462841de7cc5b715$export$f502ca02ebb85a1c(args) {
1130
1130
  }
1131
1131
 
1132
1132
 
1133
+
1133
1134
  function $cf8ebdb33758b119$export$57afafec4637d997(el, node) {
1134
1135
  const tree = (0, $d5cb84d44d1b8acc$export$367b0f2231a90ba0)();
1135
1136
  const [_, dropRef] = (0, $foSVk$reactdnd.useDrop)(()=>({
1136
1137
  accept: "NODE",
1137
- canDrop: (item, m)=>{
1138
- if (node.tree.isFiltered) return false;
1138
+ canDrop: ()=>tree.canDrop(),
1139
+ hover: (_item, m)=>{
1139
1140
  const offset = m.getClientOffset();
1140
- if (!el.current || !offset) return false;
1141
- const { drop: drop } = (0, $462841de7cc5b715$export$f502ca02ebb85a1c)({
1141
+ if (!el.current || !offset) return;
1142
+ const { cursor: cursor , drop: drop } = (0, $462841de7cc5b715$export$f502ca02ebb85a1c)({
1142
1143
  element: el.current,
1143
1144
  offset: offset,
1144
1145
  indent: tree.indent,
@@ -1146,43 +1147,13 @@ function $cf8ebdb33758b119$export$57afafec4637d997(el, node) {
1146
1147
  prevNode: node.prev,
1147
1148
  nextNode: node.next
1148
1149
  });
1149
- if (!drop) return false;
1150
- const dropParent = tree.get(drop.parentId) ?? tree.root;
1151
- for (let id of item.dragIds){
1152
- const drag = tree.get(id);
1153
- if (!drag) return false;
1154
- if (!dropParent) return false;
1155
- if (drag.isInternal && (0, $eb5355379510ac9b$export$1e38f72c6c546f70)(dropParent, drag)) return false;
1156
- }
1157
- return true;
1158
- },
1159
- hover: (item, m)=>{
1150
+ if (drop) tree.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).hovering(drop.parentId, drop.index));
1160
1151
  if (m.canDrop()) {
1161
- const offset = m.getClientOffset();
1162
- if (!el.current || !offset) return;
1163
- const { cursor: cursor } = (0, $462841de7cc5b715$export$f502ca02ebb85a1c)({
1164
- element: el.current,
1165
- offset: offset,
1166
- indent: tree.indent,
1167
- node: node,
1168
- prevNode: node.prev,
1169
- nextNode: node.next
1170
- });
1171
1152
  if (cursor) tree.showCursor(cursor);
1172
1153
  } else tree.hideCursor();
1173
1154
  },
1174
- drop: (item, m)=>{
1175
- const offset = m.getClientOffset();
1176
- if (!el.current || !offset) return;
1177
- const { drop: drop } = (0, $462841de7cc5b715$export$f502ca02ebb85a1c)({
1178
- element: el.current,
1179
- offset: offset,
1180
- indent: tree.indent,
1181
- node: node,
1182
- prevNode: node.prev,
1183
- nextNode: node.next
1184
- });
1185
- return drop;
1155
+ drop: (_, m)=>{
1156
+ if (!m.canDrop()) return null;
1186
1157
  }
1187
1158
  }), [
1188
1159
  node,
@@ -1396,8 +1367,7 @@ function $bb9a1e34249689ac$export$ff4858a4110d9246() {
1396
1367
  tree.selectAll();
1397
1368
  return;
1398
1369
  }
1399
- if (e.key === "a" && !e.metaKey) {
1400
- if (!tree.props.onCreate) return;
1370
+ if (e.key === "a" && !e.metaKey && tree.props.onCreate) {
1401
1371
  tree.createLeaf();
1402
1372
  return;
1403
1373
  }
@@ -1419,26 +1389,28 @@ function $bb9a1e34249689ac$export$ff4858a4110d9246() {
1419
1389
  return;
1420
1390
  }
1421
1391
  if (e.key === "Enter") {
1422
- if (!tree.props.onRename) return;
1392
+ const node3 = tree.focusedNode;
1393
+ if (!node3) return;
1394
+ if (!node3.isEditable || !tree.props.onRename) return;
1423
1395
  setTimeout(()=>{
1424
- if (tree.focusedNode) tree.edit(tree.focusedNode);
1396
+ if (node3) tree.edit(node3);
1425
1397
  });
1426
1398
  return;
1427
1399
  }
1428
1400
  if (e.key === " ") {
1429
1401
  e.preventDefault();
1430
- const node3 = tree.focusedNode;
1431
- if (!node3) return;
1432
- if (node3.isLeaf) {
1433
- node3.select();
1434
- node3.activate();
1435
- } else node3.toggle();
1402
+ const node4 = tree.focusedNode;
1403
+ if (!node4) return;
1404
+ if (node4.isLeaf) {
1405
+ node4.select();
1406
+ node4.activate();
1407
+ } else node4.toggle();
1436
1408
  return;
1437
1409
  }
1438
1410
  if (e.key === "*") {
1439
- const node4 = tree.focusedNode;
1440
- if (!node4) return;
1441
- tree.openSiblings(node4);
1411
+ const node5 = tree.focusedNode;
1412
+ if (!node5) return;
1413
+ tree.openSiblings(node5);
1442
1414
  return;
1443
1415
  }
1444
1416
  if (e.key === "PageUp") {
@@ -1459,13 +1431,13 @@ function $bb9a1e34249689ac$export$ff4858a4110d9246() {
1459
1431
  $bb9a1e34249689ac$var$timeoutId = setTimeout(()=>{
1460
1432
  $bb9a1e34249689ac$var$focusSearchTerm = "";
1461
1433
  }, 600);
1462
- const node5 = tree.visibleNodes.find((n)=>{
1434
+ const node6 = tree.visibleNodes.find((n)=>{
1463
1435
  // @ts-ignore
1464
1436
  const name = n.data.name;
1465
1437
  if (typeof name === "string") return name.toLowerCase().startsWith($bb9a1e34249689ac$var$focusSearchTerm);
1466
1438
  else return false;
1467
1439
  });
1468
- if (node5) tree.focus(node5.id);
1440
+ if (node6) tree.focus(node6.id);
1469
1441
  },
1470
1442
  children: /*#__PURE__*/ (0, $foSVk$reactjsxruntime.jsx)((0, $foSVk$reactwindow.FixedSizeList), {
1471
1443
  className: tree.props.className,
@@ -1474,6 +1446,7 @@ function $bb9a1e34249689ac$export$ff4858a4110d9246() {
1474
1446
  height: tree.height,
1475
1447
  width: tree.width,
1476
1448
  itemSize: tree.rowHeight,
1449
+ overscanCount: tree.overscanCount,
1477
1450
  itemKey: (index)=>tree.visibleNodes[index]?.id || index,
1478
1451
  outerElementType: (0, $0e2adc7837d85ac3$export$70c2b8898b86d3ad),
1479
1452
  innerElementType: (0, $472f3c5b35f3bf96$export$a9af0da3ae60cd00),
@@ -1571,6 +1544,9 @@ class $5c74fef433be2b0a$export$e2da3477247342d1 {
1571
1544
  get rowHeight() {
1572
1545
  return this.props.rowHeight ?? 24;
1573
1546
  }
1547
+ get overscanCount() {
1548
+ return this.props.overscanCount ?? 1;
1549
+ }
1574
1550
  get searchTerm() {
1575
1551
  return (this.props.searchTerm || "").trim();
1576
1552
  }
@@ -1828,6 +1804,30 @@ class $5c74fef433be2b0a$export$e2da3477247342d1 {
1828
1804
  get cursorOverFolder() {
1829
1805
  return this.state.dnd.cursor.type === "highlight";
1830
1806
  }
1807
+ get dragNodes() {
1808
+ return this.state.dnd.dragIds.map((id)=>this.get(id)).filter((n)=>!!n);
1809
+ }
1810
+ canDrop() {
1811
+ if (this.isFiltered) return false;
1812
+ const parentNode = this.get(this.state.dnd.parentId) ?? this.root;
1813
+ const dragNodes = this.dragNodes;
1814
+ const check = this.props.disableDrop;
1815
+ for (const drag of dragNodes){
1816
+ if (!drag) return false;
1817
+ if (!parentNode) return false;
1818
+ if (drag.isInternal && $eb5355379510ac9b$exports.isDecendent(parentNode, drag)) return false;
1819
+ }
1820
+ // Allow the user to insert their own logic
1821
+ if (typeof check == "function") return check({
1822
+ parentNode: parentNode,
1823
+ dragNodes: this.dragNodes,
1824
+ index: this.state.dnd.index
1825
+ });
1826
+ else if (typeof check == "string") // @ts-ignore
1827
+ return !!parentNode.data[check];
1828
+ else if (typeof check === "boolean") return check;
1829
+ else return true;
1830
+ }
1831
1831
  hideCursor() {
1832
1832
  this.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).cursor({
1833
1833
  type: "none"
@@ -1925,12 +1925,12 @@ class $5c74fef433be2b0a$export$e2da3477247342d1 {
1925
1925
  if (this.isFiltered) return this.state.nodes.open.filtered[id] ?? true; // Filtered folders are always opened by default
1926
1926
  else return this.state.nodes.open.unfiltered[id] ?? def;
1927
1927
  }
1928
- isDraggable(data) {
1929
- const check = this.props.disableDrag || (()=>false);
1928
+ isEditable(data) {
1929
+ const check = this.props.disableEdit || (()=>false);
1930
1930
  return !$eb5355379510ac9b$exports.access(data, check) ?? true;
1931
1931
  }
1932
- isDroppable(data) {
1933
- const check = this.props.disableDrop || (()=>false);
1932
+ isDraggable(data) {
1933
+ const check = this.props.disableDrag || (()=>false);
1934
1934
  return !$eb5355379510ac9b$exports.access(data, check) ?? true;
1935
1935
  }
1936
1936
  isDragging(node) {
@@ -2093,54 +2093,19 @@ function $6c0a9a91d5e7ff45$export$5a6c424b1725f44f() {
2093
2093
  // In case we drop an item at the bottom of the list
2094
2094
  const [, drop] = (0, $foSVk$reactdnd.useDrop)(()=>({
2095
2095
  accept: "NODE",
2096
- hover: (item, m)=>{
2096
+ canDrop: (_item, m)=>{
2097
2097
  if (!m.isOver({
2098
2098
  shallow: true
2099
- })) return;
2100
- if (m.canDrop()) {
2101
- const offset = m.getClientOffset();
2102
- if (!tree.listEl.current || !offset) return;
2103
- const { cursor: cursor } = (0, $462841de7cc5b715$export$f502ca02ebb85a1c)({
2104
- element: tree.listEl.current,
2105
- offset: offset,
2106
- indent: tree.indent,
2107
- node: null,
2108
- prevNode: tree.visibleNodes[tree.visibleNodes.length - 1],
2109
- nextNode: null
2110
- });
2111
- if (cursor) tree.showCursor(cursor);
2112
- } else tree.hideCursor();
2099
+ })) return false;
2100
+ return tree.canDrop();
2113
2101
  },
2114
- canDrop: (item, m)=>{
2102
+ hover: (_item, m)=>{
2115
2103
  if (!m.isOver({
2116
2104
  shallow: true
2117
- })) return false;
2118
- if (tree.isFiltered) return false;
2119
- const offset = m.getClientOffset();
2120
- if (!tree.listEl.current || !offset) return false;
2121
- const { drop: drop } = (0, $462841de7cc5b715$export$f502ca02ebb85a1c)({
2122
- element: tree.listEl.current,
2123
- offset: offset,
2124
- indent: tree.indent,
2125
- node: null,
2126
- prevNode: tree.visibleNodes[tree.visibleNodes.length - 1],
2127
- nextNode: null
2128
- });
2129
- if (!drop) return false;
2130
- const dropParent = tree.get(drop.parentId) ?? tree.root;
2131
- for (let id of item.dragIds){
2132
- const drag = tree.get(id);
2133
- if (!drag) return false;
2134
- if (!dropParent) return false;
2135
- if (drag.isInternal && (0, $eb5355379510ac9b$export$1e38f72c6c546f70)(dropParent, drag)) return false;
2136
- }
2137
- return true;
2138
- },
2139
- drop: (item, m)=>{
2140
- if (m.didDrop()) return;
2105
+ })) return;
2141
2106
  const offset = m.getClientOffset();
2142
2107
  if (!tree.listEl.current || !offset) return;
2143
- const { drop: drop } = (0, $462841de7cc5b715$export$f502ca02ebb85a1c)({
2108
+ const { cursor: cursor , drop: drop } = (0, $462841de7cc5b715$export$f502ca02ebb85a1c)({
2144
2109
  element: tree.listEl.current,
2145
2110
  offset: offset,
2146
2111
  indent: tree.indent,
@@ -2148,7 +2113,10 @@ function $6c0a9a91d5e7ff45$export$5a6c424b1725f44f() {
2148
2113
  prevNode: tree.visibleNodes[tree.visibleNodes.length - 1],
2149
2114
  nextNode: null
2150
2115
  });
2151
- return drop;
2116
+ if (drop) tree.dispatch((0, $7d98f5b84ecaa66b$export$e324594224ef24da).hovering(drop.parentId, drop.index));
2117
+ if (m.canDrop()) {
2118
+ if (cursor) tree.showCursor(cursor);
2119
+ } else tree.hideCursor();
2152
2120
  }
2153
2121
  }), [
2154
2122
  tree