react-arborist 1.1.0 → 1.2.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/module.js CHANGED
@@ -1,15 +1,57 @@
1
- import {jsxs as $g00cZ$jsxs, jsx as $g00cZ$jsx} from "react/jsx-runtime";
2
- import $g00cZ$react, {forwardRef as $g00cZ$forwardRef, useMemo as $g00cZ$useMemo, useRef as $g00cZ$useRef, createContext as $g00cZ$createContext, useContext as $g00cZ$useContext, useReducer as $g00cZ$useReducer, useImperativeHandle as $g00cZ$useImperativeHandle, useEffect as $g00cZ$useEffect, useLayoutEffect as $g00cZ$useLayoutEffect, memo as $g00cZ$memo, useCallback as $g00cZ$useCallback} from "react";
3
- import {DndProvider as $g00cZ$DndProvider, useDrop as $g00cZ$useDrop, useDragLayer as $g00cZ$useDragLayer, useDrag as $g00cZ$useDrag} from "react-dnd";
1
+ import {jsx as $g00cZ$jsx, jsxs as $g00cZ$jsxs} from "react/jsx-runtime";
2
+ import $g00cZ$react, {forwardRef as $g00cZ$forwardRef, useMemo as $g00cZ$useMemo, useReducer as $g00cZ$useReducer, useRef as $g00cZ$useRef, useLayoutEffect as $g00cZ$useLayoutEffect, useImperativeHandle as $g00cZ$useImperativeHandle, createContext as $g00cZ$createContext, useContext as $g00cZ$useContext, useEffect as $g00cZ$useEffect, memo as $g00cZ$memo, useCallback as $g00cZ$useCallback} from "react";
3
+ import {DndProvider as $g00cZ$DndProvider, useDragLayer as $g00cZ$useDragLayer, useDrop as $g00cZ$useDrop, useDrag as $g00cZ$useDrag} from "react-dnd";
4
4
  import {HTML5Backend as $g00cZ$HTML5Backend, getEmptyImage as $g00cZ$getEmptyImage} from "react-dnd-html5-backend";
5
- import {FixedSizeList as $g00cZ$FixedSizeList} from "react-window";
6
5
  import $g00cZ$memoizeone from "memoize-one";
7
6
  import $g00cZ$reactdom from "react-dom";
7
+ import {FixedSizeList as $g00cZ$FixedSizeList} from "react-window";
8
+
9
+
10
+
11
+
12
+
13
+ function $1e5818ce7991d06d$var$createNode(model, level, parent, children, isOpen, isDraggable, isDroppable) {
14
+ return {
15
+ id: model.id,
16
+ level: level,
17
+ parent: parent,
18
+ children: children,
19
+ isOpen: isOpen,
20
+ isDraggable: isDraggable,
21
+ isDroppable: isDroppable,
22
+ model: model,
23
+ rowIndex: null
24
+ };
25
+ }
26
+ function $1e5818ce7991d06d$var$access(obj, accessor) {
27
+ if (typeof accessor === "boolean") return accessor;
28
+ if (typeof accessor === "string") return obj[accessor];
29
+ return accessor(obj);
30
+ }
31
+ function $1e5818ce7991d06d$export$9c537176392280a0(model1, hideRoot = false, getChildren = "children", isOpen = "isOpen", disableDrag = false, disableDrop = false, openByDefault = true) {
32
+ function visitSelfAndChildren(model, level, parent) {
33
+ const open = $1e5818ce7991d06d$var$access(model, isOpen);
34
+ const draggable = !$1e5818ce7991d06d$var$access(model, disableDrag);
35
+ const droppable = !$1e5818ce7991d06d$var$access(model, disableDrop);
36
+ const node = $1e5818ce7991d06d$var$createNode(model, level, parent, null, open === undefined ? openByDefault : open, draggable, droppable);
37
+ const children = $1e5818ce7991d06d$var$access(model, getChildren);
38
+ if (children) node.children = children.map((child)=>visitSelfAndChildren(child, level + 1, node)
39
+ );
40
+ return node;
41
+ }
42
+ return visitSelfAndChildren(model1, hideRoot ? -1 : 0, null);
43
+ }
8
44
 
9
45
 
10
46
 
11
47
 
12
48
 
49
+ const $3273af3fe11a7001$export$feef243b04ff4151 = /*#__PURE__*/ $g00cZ$createContext(null);
50
+ function $3273af3fe11a7001$export$367b0f2231a90ba0() {
51
+ const value = $g00cZ$useContext($3273af3fe11a7001$export$feef243b04ff4151);
52
+ if (value === null) throw new Error("No Tree Api Provided");
53
+ return value;
54
+ }
13
55
 
14
56
 
15
57
  class $043ce40ea783107b$export$9a58ef0d7ad3278c {
@@ -193,82 +235,182 @@ class $5ee99f971bd267fd$export$52baac22726c72bf {
193
235
  }
194
236
 
195
237
 
196
- const $3273af3fe11a7001$export$7380e5d4146ff2ce = /*#__PURE__*/ $g00cZ$createContext(null);
197
- function $3273af3fe11a7001$export$8e294ac6de4c921f() {
198
- return $g00cZ$useContext($3273af3fe11a7001$export$7380e5d4146ff2ce);
199
- }
200
- const $3273af3fe11a7001$export$86fe4415b73783a1 = /*#__PURE__*/ $g00cZ$createContext(false);
201
- function $3273af3fe11a7001$export$f3ad962ff713505f() {
202
- return $g00cZ$useContext($3273af3fe11a7001$export$86fe4415b73783a1);
203
- }
204
- const $3273af3fe11a7001$export$76f51715425ee155 = /*#__PURE__*/ $g00cZ$createContext(null);
205
- function $3273af3fe11a7001$export$6c87584817ff2461() {
206
- return $g00cZ$useContext($3273af3fe11a7001$export$76f51715425ee155);
207
- }
208
- const $3273af3fe11a7001$export$c1b9a1d3af45b7b6 = /*#__PURE__*/ $g00cZ$createContext(null);
209
- function $3273af3fe11a7001$export$ea6c3ae2bd3a5510() {
210
- const value = $g00cZ$useContext($3273af3fe11a7001$export$c1b9a1d3af45b7b6);
211
- if (!value) throw new Error("Context must be in a provider");
212
- return value;
213
- }
214
- const $3273af3fe11a7001$export$f34e95fabff36a8f = /*#__PURE__*/ $g00cZ$createContext(null);
215
- function $3273af3fe11a7001$export$8ad76b76a4c905f8() {
216
- const dispatch = $g00cZ$useContext($3273af3fe11a7001$export$f34e95fabff36a8f);
217
- if (!dispatch) throw new Error("No dispatch provided");
218
- return dispatch;
238
+ const $b26f0eafd5701d7d$export$f6196a6c6bb539b4 = ()=>({
239
+ visibleIds: [],
240
+ cursor: {
241
+ type: "none"
242
+ },
243
+ editingId: null,
244
+ selection: {
245
+ data: null,
246
+ ids: []
247
+ }
248
+ })
249
+ ;
250
+ const $b26f0eafd5701d7d$export$e324594224ef24da = {
251
+ setCursorLocation: (cursor)=>({
252
+ type: "SET_CURSOR_LOCATION",
253
+ cursor: cursor
254
+ })
255
+ ,
256
+ setVisibleIds: (ids, idMap // id to index
257
+ )=>({
258
+ type: "SET_VISIBLE_IDS",
259
+ ids: ids,
260
+ idMap: idMap
261
+ })
262
+ ,
263
+ select: (index, meta, shift)=>({
264
+ type: "SELECT",
265
+ index: index,
266
+ meta: meta,
267
+ shift: shift
268
+ })
269
+ ,
270
+ selectId: (id)=>({
271
+ type: "SELECT_ID",
272
+ id: id
273
+ })
274
+ ,
275
+ edit: (id)=>({
276
+ type: "EDIT",
277
+ id: id
278
+ })
279
+ ,
280
+ stepUp: (shift, ids)=>({
281
+ type: "STEP_UP",
282
+ shift: shift
283
+ })
284
+ ,
285
+ stepDown: (shift, ids)=>({
286
+ type: "STEP_DOWN",
287
+ shift: shift
288
+ })
289
+ };
290
+ function $b26f0eafd5701d7d$export$1650419e431d3ba3(state, action) {
291
+ switch(action.type){
292
+ case "EDIT":
293
+ return {
294
+ ...state,
295
+ editingId: action.id
296
+ };
297
+ case "SET_CURSOR_LOCATION":
298
+ if ($b26f0eafd5701d7d$var$equal(state.cursor, action.cursor)) return state;
299
+ else return {
300
+ ...state,
301
+ cursor: action.cursor
302
+ };
303
+ case "SELECT":
304
+ var s = $5ee99f971bd267fd$export$52baac22726c72bf.parse(state.selection.data, state.visibleIds);
305
+ if (action.index === null) s.clear();
306
+ else if (action.meta) {
307
+ if (s.contains(action.index)) s.deselect(action.index);
308
+ else s.multiSelect(action.index);
309
+ } else if (action.shift) s.extend(action.index);
310
+ else s.select(action.index);
311
+ return {
312
+ ...state,
313
+ selection: {
314
+ data: s.serialize(),
315
+ ids: s.getSelectedItems()
316
+ }
317
+ };
318
+ case "SELECT_ID":
319
+ return {
320
+ ...state,
321
+ selection: {
322
+ ...state.selection,
323
+ ids: [
324
+ action.id
325
+ ]
326
+ }
327
+ };
328
+ case "STEP_UP":
329
+ var s3 = $5ee99f971bd267fd$export$52baac22726c72bf.parse(state.selection.data, state.visibleIds);
330
+ var f = s3.getFocus();
331
+ if (action.shift) s3.extend(f - 1);
332
+ else s3.select(f - 1);
333
+ return {
334
+ ...state,
335
+ selection: {
336
+ data: s3.serialize(),
337
+ ids: s3.getSelectedItems()
338
+ }
339
+ };
340
+ case "STEP_DOWN":
341
+ var s6 = $5ee99f971bd267fd$export$52baac22726c72bf.parse(state.selection.data, state.visibleIds);
342
+ var f2 = s6.getFocus();
343
+ if (action.shift) s6.extend(f2 + 1);
344
+ else s6.select(f2 + 1);
345
+ return {
346
+ ...state,
347
+ selection: {
348
+ data: s6.serialize(),
349
+ ids: s6.getSelectedItems()
350
+ }
351
+ };
352
+ case "SET_VISIBLE_IDS":
353
+ // The visible ids changed
354
+ var ids = state.selection.ids;
355
+ // Start with a blank selection
356
+ var s2 = new $5ee99f971bd267fd$export$52baac22726c72bf([], null, "none", state.visibleIds);
357
+ // Add each of the old selected ids to this new selection
358
+ for (let id of ids)if (id in action.idMap) s2.multiSelect(action.idMap[id]);
359
+ return {
360
+ ...state,
361
+ visibleIds: action.ids,
362
+ selection: {
363
+ ids: ids,
364
+ data: s2.serialize()
365
+ }
366
+ };
367
+ default:
368
+ return state;
369
+ }
219
370
  }
220
- const $3273af3fe11a7001$export$7c7a4fd7f1336e2c = /*#__PURE__*/ $g00cZ$createContext(null);
221
- function $3273af3fe11a7001$export$1c9b7756eccadc96() {
222
- const value = $g00cZ$useContext($3273af3fe11a7001$export$7c7a4fd7f1336e2c);
223
- if (!value) throw new Error("Must provide selection context");
224
- return value.ids;
371
+ function $b26f0eafd5701d7d$var$equal(a, b) {
372
+ if (a === null || b === null) return false;
373
+ return JSON.stringify(a) === JSON.stringify(b);
225
374
  }
226
- function $3273af3fe11a7001$export$fb40a80c530e5f2b() {
227
- const value = $g00cZ$useContext($3273af3fe11a7001$export$7c7a4fd7f1336e2c);
228
- if (!value) throw new Error("Must provide selection context");
229
- const s = $g00cZ$useMemo(()=>$5ee99f971bd267fd$export$52baac22726c72bf.parse(value.data, [])
230
- , [
231
- value.data
375
+
376
+
377
+
378
+ function $bafe08914d05476b$export$de605877a37dc399(ref, api) {
379
+ $g00cZ$useEffect(()=>{
380
+ const el = ref.current;
381
+ const cb = (e)=>{
382
+ if (e.code === "ArrowDown") {
383
+ e.preventDefault();
384
+ api.selectDownwards(e.shiftKey);
385
+ } else if (e.code === "ArrowUp") {
386
+ e.preventDefault();
387
+ api.selectUpwards(e.shiftKey);
388
+ }
389
+ };
390
+ el?.addEventListener("keydown", cb);
391
+ return ()=>{
392
+ el?.removeEventListener("keydown", cb);
393
+ };
394
+ }, [
395
+ ref,
396
+ api
232
397
  ]);
233
- return (i)=>s.contains(i)
234
- ;
235
- }
236
- const $3273af3fe11a7001$export$7f994e57c9e78355 = /*#__PURE__*/ $g00cZ$createContext(null);
237
- function $3273af3fe11a7001$export$9ab192f953c1b33b() {
238
- return $g00cZ$useContext($3273af3fe11a7001$export$7f994e57c9e78355);
239
398
  }
240
399
 
241
400
 
242
- function $1e5818ce7991d06d$var$createNode(model, level, parent, children, isOpen, isDraggable, isDroppable) {
243
- return {
244
- id: model.id,
245
- level: level,
246
- parent: parent,
247
- children: children,
248
- isOpen: isOpen,
249
- isDraggable: isDraggable,
250
- isDroppable: isDroppable,
251
- model: model,
252
- rowIndex: null
253
- };
254
- }
255
- function $1e5818ce7991d06d$var$access(obj, accessor) {
256
- if (typeof accessor === "boolean") return accessor;
257
- if (typeof accessor === "string") return obj[accessor];
258
- return accessor(obj);
259
- }
260
- function $1e5818ce7991d06d$export$9c537176392280a0(model1, hideRoot = false, getChildren = "children", isOpen = "isOpen", disableDrag = false, disableDrop = false, openByDefault = true) {
261
- function visitSelfAndChildren(model, level, parent) {
262
- const open = $1e5818ce7991d06d$var$access(model, isOpen);
263
- const draggable = !$1e5818ce7991d06d$var$access(model, disableDrag);
264
- const droppable = !$1e5818ce7991d06d$var$access(model, disableDrop);
265
- const node = $1e5818ce7991d06d$var$createNode(model, level, parent, null, open === undefined ? openByDefault : open, draggable, droppable);
266
- const children = $1e5818ce7991d06d$var$access(model, getChildren);
267
- if (children) node.children = children.map((child)=>visitSelfAndChildren(child, level + 1, node)
268
- );
269
- return node;
401
+
402
+ function $4dcb7be69f759cab$export$79f9fa345a841d8b(root) {
403
+ const list = [];
404
+ let index = 0;
405
+ function collect(node) {
406
+ if (node.level >= 0) {
407
+ node.rowIndex = index++;
408
+ list.push(node);
409
+ }
410
+ if (node.isOpen) node.children?.forEach(collect);
270
411
  }
271
- return visitSelfAndChildren(model1, hideRoot ? -1 : 0, null);
412
+ collect(root);
413
+ return list;
272
414
  }
273
415
 
274
416
 
@@ -303,582 +445,592 @@ function $0e6083160f4b36ed$export$8793edee2d425525() {
303
445
  }
304
446
 
305
447
 
306
- function $2db980bfed6822da$var$measureHover(el, offset) {
307
- const rect = el.getBoundingClientRect();
308
- const x = offset.x - Math.round(rect.x);
309
- const y = offset.y - Math.round(rect.y);
310
- const height = rect.height;
311
- const inTopHalf = y < height / 2;
312
- const inBottomHalf = !inTopHalf;
313
- const pad = height / 4;
314
- const inMiddle = y > pad && y < height - pad;
315
- const atTop = !inMiddle && inTopHalf;
316
- const atBottom = !inMiddle && inBottomHalf;
317
- return {
318
- x: x,
319
- inTopHalf: inTopHalf,
320
- inBottomHalf: inBottomHalf,
321
- inMiddle: inMiddle,
322
- atTop: atTop,
323
- atBottom: atBottom
324
- };
325
- }
326
- function $2db980bfed6822da$var$getNodesAroundCursor(node, prev, next, hover) {
327
- if (!node) // We're hoving over the empty part of the list, not over an item,
328
- // Put the cursor below the last item which is "prev"
329
- return [
330
- prev,
331
- null
332
- ];
333
- if ($0e6083160f4b36ed$export$769c5e872f5f8638(node)) {
334
- if (hover.atTop) return [
335
- prev,
336
- node
337
- ];
338
- else if (hover.inMiddle) return [
339
- node,
340
- node
341
- ];
342
- else return [
343
- node,
344
- next
345
- ];
346
- } else {
347
- if (hover.inTopHalf) return [
348
- prev,
349
- node
350
- ];
351
- else return [
352
- node,
353
- next
354
- ];
355
- }
356
- }
357
- function $2db980bfed6822da$var$getDropLevel(hovering, aboveCursor, belowCursor, indent) {
358
- const hoverLevel = Math.round(Math.max(0, hovering.x - indent) / indent);
359
- let min, max;
360
- if (!aboveCursor) {
361
- max = 0;
362
- min = 0;
363
- } else if (!belowCursor) {
364
- max = aboveCursor.level;
365
- min = 0;
366
- } else {
367
- max = aboveCursor.level;
368
- min = belowCursor.level;
369
- }
370
- return $0e6083160f4b36ed$export$adf7c0fe6059d774(hoverLevel, min, max);
371
- }
372
- function $2db980bfed6822da$var$canDrop(above, below) {
373
- if (!above) return true;
374
- let n = above;
375
- if ($0e6083160f4b36ed$export$4210f5ea57fbae57(above) && above !== below) n = above.parent;
376
- while(n){
377
- if (!n.isDroppable) return false;
378
- n = n.parent;
379
- }
380
- return true;
381
- }
382
- function $2db980bfed6822da$var$dropAt(parentId, index) {
383
- return {
384
- parentId: parentId || null,
385
- index: index
386
- };
387
- }
388
- function $2db980bfed6822da$var$lineCursor(index, level) {
389
- return {
390
- type: "line",
391
- index: index,
392
- level: level
393
- };
394
- }
395
- function $2db980bfed6822da$var$noCursor() {
396
- return {
397
- type: "none"
398
- };
399
- }
400
- function $2db980bfed6822da$var$highlightCursor(id) {
401
- return {
402
- type: "highlight",
403
- id: id
404
- };
405
- }
406
- function $2db980bfed6822da$var$walkUpFrom(node, level) {
407
- let drop = node;
408
- while(drop.parent && drop.level > level)drop = drop.parent;
409
- const parentId = drop.parent?.id || null;
410
- const index = $0e6083160f4b36ed$export$305f7d4e9d4624f2(drop) + 1;
411
- return {
412
- parentId: parentId,
413
- index: index
414
- };
415
- }
416
- function $2db980bfed6822da$export$f502ca02ebb85a1c(args) {
417
- const hover = $2db980bfed6822da$var$measureHover(args.element, args.offset);
418
- const { node: node , nextNode: nextNode , prevNode: prevNode } = args;
419
- const [above, below] = $2db980bfed6822da$var$getNodesAroundCursor(node, prevNode, nextNode, hover);
420
- if (!$2db980bfed6822da$var$canDrop(above, below)) return {
421
- drop: null,
422
- cursor: $2db980bfed6822da$var$noCursor()
423
- };
424
- /* Hovering over the middle of a folder */ if (node && $0e6083160f4b36ed$export$769c5e872f5f8638(node) && hover.inMiddle) return {
425
- drop: $2db980bfed6822da$var$dropAt(node.id, 0),
426
- cursor: $2db980bfed6822da$var$highlightCursor(node.id)
427
- };
428
- /* At the top of the list */ if (!above) return {
429
- drop: $2db980bfed6822da$var$dropAt(below?.parent?.id, 0),
430
- cursor: $2db980bfed6822da$var$lineCursor(0, 0)
431
- };
432
- /* The above node is an item or a closed folder */ if ($0e6083160f4b36ed$export$5318634f2ee07019(above) || $0e6083160f4b36ed$export$4210f5ea57fbae57(above)) {
433
- const level = $2db980bfed6822da$var$getDropLevel(hover, above, below, args.indent);
434
- return {
435
- drop: $2db980bfed6822da$var$walkUpFrom(above, level),
436
- cursor: $2db980bfed6822da$var$lineCursor(above.rowIndex + 1, level)
437
- };
438
- }
439
- /* The above node is an open folder */ return {
440
- drop: $2db980bfed6822da$var$dropAt(above?.id, 0),
441
- cursor: $2db980bfed6822da$var$lineCursor(above.rowIndex + 1, above.level + 1)
442
- };
443
- }
444
-
445
-
446
- function $e739455e59c6aed3$export$5a6c424b1725f44f() {
447
- const tree = $3273af3fe11a7001$export$ea6c3ae2bd3a5510();
448
- // In case we drop an item at the bottom of the list
449
- const [, drop1] = $g00cZ$useDrop(()=>({
450
- accept: "NODE",
451
- hover: (item, m)=>{
452
- if (!m.isOver({
453
- shallow: true
454
- })) return;
455
- const offset = m.getClientOffset();
456
- if (!tree.listEl.current || !offset) return;
457
- const { cursor: cursor } = $2db980bfed6822da$export$f502ca02ebb85a1c({
458
- element: tree.listEl.current,
459
- offset: offset,
460
- indent: tree.indent,
461
- node: null,
462
- prevNode: tree.api.visibleNodes[tree.api.visibleNodes.length - 1],
463
- nextNode: null
464
- });
465
- if (cursor) tree.api.showCursor(cursor);
466
- },
467
- canDrop: (item, m)=>{
468
- return m.isOver({
469
- shallow: true
470
- });
471
- },
472
- drop: (item, m)=>{
473
- if (m.didDrop()) return;
474
- const offset = m.getClientOffset();
475
- if (!tree.listEl.current || !offset) return;
476
- const { drop: drop } = $2db980bfed6822da$export$f502ca02ebb85a1c({
477
- element: tree.listEl.current,
478
- offset: offset,
479
- indent: tree.indent,
480
- node: null,
481
- prevNode: tree.api.visibleNodes[tree.api.visibleNodes.length - 1],
482
- nextNode: null
483
- });
484
- return drop;
485
- }
486
- })
487
- , [
488
- tree
489
- ]);
490
- drop1(tree.listEl);
491
- }
492
448
 
493
449
 
494
450
 
495
-
496
-
497
-
498
- const $b26f0eafd5701d7d$export$f6196a6c6bb539b4 = ()=>({
499
- visibleIds: [],
500
- cursor: {
501
- type: "none"
502
- },
503
- editingId: null,
504
- selection: {
505
- data: null,
506
- ids: []
507
- }
508
- })
509
- ;
510
- const $b26f0eafd5701d7d$export$e324594224ef24da = {
511
- setCursorLocation: (cursor)=>({
512
- type: "SET_CURSOR_LOCATION",
513
- cursor: cursor
514
- })
515
- ,
516
- setVisibleIds: (ids, idMap // id to index
517
- )=>({
518
- type: "SET_VISIBLE_IDS",
519
- ids: ids,
520
- idMap: idMap
521
- })
522
- ,
523
- select: (index, meta, shift)=>({
524
- type: "SELECT",
525
- index: index,
526
- meta: meta,
527
- shift: shift
528
- })
529
- ,
530
- selectId: (id)=>({
531
- type: "SELECT_ID",
532
- id: id
533
- })
534
- ,
535
- edit: (id)=>({
536
- type: "EDIT",
537
- id: id
538
- })
539
- ,
540
- stepUp: (shift, ids)=>({
541
- type: "STEP_UP",
542
- shift: shift
543
- })
544
- ,
545
- stepDown: (shift, ids)=>({
546
- type: "STEP_DOWN",
547
- shift: shift
548
- })
451
+ const $1b40c8f40669603d$var$placeholderStyle = {
452
+ display: "flex",
453
+ alignItems: "center"
549
454
  };
550
- function $b26f0eafd5701d7d$export$1650419e431d3ba3(state, action) {
551
- switch(action.type){
552
- case "EDIT":
553
- return {
554
- ...state,
555
- editingId: action.id
556
- };
557
- case "SET_CURSOR_LOCATION":
558
- if ($b26f0eafd5701d7d$var$equal(state.cursor, action.cursor)) return state;
559
- else return {
560
- ...state,
561
- cursor: action.cursor
562
- };
563
- case "SELECT":
564
- var s = $5ee99f971bd267fd$export$52baac22726c72bf.parse(state.selection.data, state.visibleIds);
565
- if (action.index === null) s.clear();
566
- else if (action.meta) {
567
- if (s.contains(action.index)) s.deselect(action.index);
568
- else s.multiSelect(action.index);
569
- } else if (action.shift) s.extend(action.index);
570
- else s.select(action.index);
571
- return {
572
- ...state,
573
- selection: {
574
- data: s.serialize(),
575
- ids: s.getSelectedItems()
576
- }
577
- };
578
- case "SELECT_ID":
579
- return {
580
- ...state,
581
- selection: {
582
- ...state.selection,
583
- ids: [
584
- action.id
585
- ]
586
- }
587
- };
588
- case "STEP_UP":
589
- var s3 = $5ee99f971bd267fd$export$52baac22726c72bf.parse(state.selection.data, state.visibleIds);
590
- var f = s3.getFocus();
591
- if (action.shift) s3.extend(f - 1);
592
- else s3.select(f - 1);
593
- return {
594
- ...state,
595
- selection: {
596
- data: s3.serialize(),
597
- ids: s3.getSelectedItems()
598
- }
599
- };
600
- case "STEP_DOWN":
601
- var s6 = $5ee99f971bd267fd$export$52baac22726c72bf.parse(state.selection.data, state.visibleIds);
602
- var f2 = s6.getFocus();
603
- if (action.shift) s6.extend(f2 + 1);
604
- else s6.select(f2 + 1);
605
- return {
606
- ...state,
607
- selection: {
608
- data: s6.serialize(),
609
- ids: s6.getSelectedItems()
455
+ const $1b40c8f40669603d$var$lineStyle = {
456
+ flex: 1,
457
+ height: "2px",
458
+ background: "#4B91E2",
459
+ borderRadius: "1px"
460
+ };
461
+ const $1b40c8f40669603d$var$circleStyle = {
462
+ width: "4px",
463
+ height: "4px",
464
+ boxShadow: "0 0 0 3px #4B91E2",
465
+ borderRadius: "50%"
466
+ };
467
+ function $1b40c8f40669603d$var$DefaultCursor({ top: top , left: left , indent: indent }) {
468
+ const style = {
469
+ position: "absolute",
470
+ pointerEvents: "none",
471
+ top: top - 2 + "px",
472
+ left: indent + left + "px",
473
+ right: indent + "px"
474
+ };
475
+ return(/*#__PURE__*/ $g00cZ$jsxs("div", {
476
+ style: {
477
+ ...$1b40c8f40669603d$var$placeholderStyle,
478
+ ...style
479
+ },
480
+ children: [
481
+ /*#__PURE__*/ $g00cZ$jsx("div", {
482
+ style: {
483
+ ...$1b40c8f40669603d$var$circleStyle
610
484
  }
611
- };
612
- case "SET_VISIBLE_IDS":
613
- // The visible ids changed
614
- var ids = state.selection.ids;
615
- // Start with a blank selection
616
- var s2 = new $5ee99f971bd267fd$export$52baac22726c72bf([], null, "none", state.visibleIds);
617
- // Add each of the old selected ids to this new selection
618
- for (let id of ids)if (id in action.idMap) s2.multiSelect(action.idMap[id]);
619
- return {
620
- ...state,
621
- visibleIds: action.ids,
622
- selection: {
623
- ids: ids,
624
- data: s2.serialize()
485
+ }),
486
+ /*#__PURE__*/ $g00cZ$jsx("div", {
487
+ style: {
488
+ ...$1b40c8f40669603d$var$lineStyle
625
489
  }
626
- };
627
- default:
628
- return state;
490
+ })
491
+ ]
492
+ }));
493
+ }
494
+ function $1b40c8f40669603d$export$61a6f16446012f00(props) {
495
+ return(/*#__PURE__*/ $g00cZ$jsx($1b40c8f40669603d$var$DefaultCursor, {
496
+ ...props
497
+ }));
498
+ }
499
+
500
+
501
+ class $40fcfa3e17312481$export$e2da3477247342d1 {
502
+ constructor(dispatch, state, props, list, listEl){
503
+ this.dispatch = dispatch;
504
+ this.state = state;
505
+ this.props = props;
506
+ this.list = list;
507
+ this.listEl = listEl;
508
+ this.edits = new Map();
509
+ }
510
+ sync(other) {
511
+ this.dispatch = other.dispatch;
512
+ this.state = other.state;
513
+ this.props = other.props;
514
+ this.list = other.list;
515
+ this.listEl = other.listEl;
516
+ }
517
+ getNode(id) {
518
+ if (id in this.idToIndex) return this.visibleNodes[this.idToIndex[id]] || null;
519
+ else return null;
520
+ }
521
+ getSelectedIds() {
522
+ return this.state.selection.ids;
523
+ }
524
+ edit(id) {
525
+ const sid = id.toString();
526
+ this.resolveEdit(sid, {
527
+ cancelled: true
528
+ });
529
+ this.scrollToId(sid);
530
+ this.dispatch($b26f0eafd5701d7d$export$e324594224ef24da.edit(sid));
531
+ return new Promise((resolve)=>this.edits.set(sid, resolve)
532
+ );
533
+ }
534
+ submit(id, value) {
535
+ const sid = id.toString();
536
+ this.onEdit(sid, value);
537
+ this.dispatch($b26f0eafd5701d7d$export$e324594224ef24da.edit(null));
538
+ this.resolveEdit(sid, {
539
+ cancelled: false,
540
+ value: value
541
+ });
542
+ }
543
+ reset(id) {
544
+ const sid = id.toString();
545
+ this.dispatch($b26f0eafd5701d7d$export$e324594224ef24da.edit(null));
546
+ this.resolveEdit(sid, {
547
+ cancelled: true
548
+ });
549
+ }
550
+ resolveEdit(id, value) {
551
+ const resolve = this.edits.get(id.toString());
552
+ if (resolve) resolve(value);
553
+ this.edits.delete(id);
554
+ }
555
+ select(index, meta = false, shift = false) {
556
+ this.dispatch($b26f0eafd5701d7d$export$e324594224ef24da.select(index, meta, shift));
557
+ }
558
+ selectById(id, meta = false, shift = false) {
559
+ const index = this.idToIndex[id];
560
+ this.select(index, meta, shift);
561
+ }
562
+ selectUpwards(shiftKey) {
563
+ this.dispatch($b26f0eafd5701d7d$export$e324594224ef24da.stepUp(shiftKey, this.visibleIds));
564
+ }
565
+ selectDownwards(shiftKey) {
566
+ this.dispatch($b26f0eafd5701d7d$export$e324594224ef24da.stepDown(shiftKey, this.visibleIds));
567
+ }
568
+ hideCursor() {
569
+ this.dispatch($b26f0eafd5701d7d$export$e324594224ef24da.setCursorLocation({
570
+ type: "none"
571
+ }));
572
+ }
573
+ showCursor(cursor) {
574
+ this.dispatch($b26f0eafd5701d7d$export$e324594224ef24da.setCursorLocation(cursor));
575
+ }
576
+ scrollToId(id) {
577
+ if (!this.list) return;
578
+ const index1 = this.idToIndex[id];
579
+ if (index1) this.list.current?.scrollToItem(index1);
580
+ else {
581
+ this.openParents(id);
582
+ $g00cZ$reactdom.flushSync(()=>{
583
+ const index = this.idToIndex[id];
584
+ if (index) this.list.current?.scrollToItem(index);
585
+ });
586
+ }
587
+ }
588
+ open(id) {
589
+ this.onToggle(id, true);
590
+ }
591
+ openParents(id) {
592
+ const node = $40fcfa3e17312481$var$dfs(this.props.root, id);
593
+ let parent = node?.parent;
594
+ while(parent){
595
+ this.open(parent.id);
596
+ parent = parent.parent;
597
+ }
598
+ }
599
+ get visibleIds() {
600
+ return $40fcfa3e17312481$var$getIds(this.visibleNodes);
601
+ }
602
+ get idToIndex() {
603
+ return $40fcfa3e17312481$var$createIndex(this.visibleNodes);
604
+ }
605
+ get visibleNodes() {
606
+ return $40fcfa3e17312481$var$createList(this.props.root);
607
+ }
608
+ get width() {
609
+ return this.props.treeProps.width || 300;
610
+ }
611
+ get height() {
612
+ return this.props.treeProps.height || 500;
613
+ }
614
+ get indent() {
615
+ return this.props.treeProps.indent || 24;
616
+ }
617
+ get renderer() {
618
+ return this.props.treeProps.children;
619
+ }
620
+ get onToggle() {
621
+ return this.props.treeProps.onToggle || $0e6083160f4b36ed$export$8793edee2d425525;
622
+ }
623
+ get rowHeight() {
624
+ return this.props.treeProps.rowHeight || 24;
625
+ }
626
+ get onClick() {
627
+ return this.props.treeProps.onClick || $0e6083160f4b36ed$export$8793edee2d425525;
628
+ }
629
+ get onContextMenu() {
630
+ return this.props.treeProps.onContextMenu || $0e6083160f4b36ed$export$8793edee2d425525;
631
+ }
632
+ get onMove() {
633
+ return this.props.treeProps.onMove || $0e6083160f4b36ed$export$8793edee2d425525;
634
+ }
635
+ get onEdit() {
636
+ return this.props.treeProps.onEdit || $0e6083160f4b36ed$export$8793edee2d425525;
637
+ }
638
+ get cursorParentId() {
639
+ const { cursor: cursor } = this.state;
640
+ switch(cursor.type){
641
+ case "highlight":
642
+ return cursor.id;
643
+ default:
644
+ return null;
645
+ }
646
+ }
647
+ get cursorOverFolder() {
648
+ return this.state.cursor.type === "highlight";
649
+ }
650
+ get editingId() {
651
+ return this.state.editingId;
652
+ }
653
+ isSelected(index) {
654
+ const selection = $5ee99f971bd267fd$export$52baac22726c72bf.parse(this.state.selection.data, []);
655
+ return selection.contains(index);
656
+ }
657
+ renderDropCursor(props) {
658
+ const render = this.props.treeProps.dropCursor || $1b40c8f40669603d$export$61a6f16446012f00;
659
+ return render(props);
629
660
  }
630
661
  }
631
- function $b26f0eafd5701d7d$var$equal(a, b) {
632
- if (a === null || b === null) return false;
633
- return JSON.stringify(a) === JSON.stringify(b);
662
+ const $40fcfa3e17312481$var$getIds = $g00cZ$memoizeone((nodes)=>nodes.map((n)=>n.id
663
+ )
664
+ );
665
+ const $40fcfa3e17312481$var$createIndex = $g00cZ$memoizeone((nodes)=>{
666
+ return nodes.reduce((map, node, index)=>{
667
+ map[node.id] = index;
668
+ return map;
669
+ }, {
670
+ });
671
+ });
672
+ const $40fcfa3e17312481$var$createList = $g00cZ$memoizeone($4dcb7be69f759cab$export$79f9fa345a841d8b);
673
+ function $40fcfa3e17312481$var$dfs(node, id) {
674
+ if (!node) return null;
675
+ if (node.id === id) return node;
676
+ if (node.children) for (let child of node.children){
677
+ const result = $40fcfa3e17312481$var$dfs(child, id);
678
+ if (result) return result;
679
+ }
680
+ return null;
634
681
  }
635
682
 
636
683
 
637
-
638
- function $bafe08914d05476b$export$de605877a37dc399(ref, api) {
639
- $g00cZ$useEffect(()=>{
640
- const el = ref.current;
641
- const cb = (e)=>{
642
- if (e.code === "ArrowDown") {
643
- e.preventDefault();
644
- api.selectDownwards(e.shiftKey);
645
- } else if (e.code === "ArrowUp") {
646
- e.preventDefault();
647
- api.selectUpwards(e.shiftKey);
648
- }
649
- };
650
- el?.addEventListener("keydown", cb);
651
- return ()=>{
652
- el?.removeEventListener("keydown", cb);
653
- };
684
+ function $3a48b0a92affa3e3$export$6a399b2f7f12632c(props) {
685
+ const [state, dispatch] = $g00cZ$useReducer($b26f0eafd5701d7d$export$1650419e431d3ba3, $b26f0eafd5701d7d$export$f6196a6c6bb539b4());
686
+ const list = $g00cZ$useRef(null);
687
+ const listEl = $g00cZ$useRef(null);
688
+ const api = $g00cZ$useMemo(()=>new $40fcfa3e17312481$export$e2da3477247342d1(dispatch, state, props, list, listEl)
689
+ , [
690
+ dispatch,
691
+ state,
692
+ props,
693
+ list,
694
+ listEl
695
+ ]);
696
+ /**
697
+ * This ensures that the selection remains correct even
698
+ * after opening and closing a folders
699
+ */ $g00cZ$useLayoutEffect(()=>{
700
+ dispatch($b26f0eafd5701d7d$export$e324594224ef24da.setVisibleIds(api.visibleIds, api.idToIndex));
654
701
  }, [
655
- ref,
656
- api
702
+ dispatch,
703
+ api.visibleIds,
704
+ api.idToIndex,
705
+ props.root
657
706
  ]);
707
+ $g00cZ$useImperativeHandle(props.imperativeHandle, ()=>api
708
+ );
709
+ $bafe08914d05476b$export$de605877a37dc399(listEl, api);
710
+ return(/*#__PURE__*/ $g00cZ$jsx($3273af3fe11a7001$export$feef243b04ff4151.Provider, {
711
+ value: api,
712
+ children: props.children
713
+ }));
658
714
  }
659
715
 
660
716
 
661
717
 
662
718
 
663
719
 
664
- function $4dcb7be69f759cab$export$79f9fa345a841d8b(root) {
665
- const list = [];
666
- let index = 0;
667
- function collect(node) {
668
- if (node.level >= 0) {
669
- node.rowIndex = index++;
670
- list.push(node);
671
- }
672
- if (node.isOpen) node.children?.forEach(collect);
673
- }
674
- collect(root);
675
- return list;
720
+
721
+ const $6d8109ab8cbcd5e7$var$layerStyles = {
722
+ position: "fixed",
723
+ pointerEvents: "none",
724
+ zIndex: 100,
725
+ left: 0,
726
+ top: 0,
727
+ width: "100%",
728
+ height: "100%"
729
+ };
730
+ const $6d8109ab8cbcd5e7$var$getStyle = (offset)=>{
731
+ if (!offset) return {
732
+ display: "none"
733
+ };
734
+ const { x: x , y: y } = offset;
735
+ return {
736
+ transform: `translate(${x}px, ${y}px)`
737
+ };
738
+ };
739
+ const $6d8109ab8cbcd5e7$var$getCountStyle = (offset)=>{
740
+ if (!offset) return {
741
+ display: "none"
742
+ };
743
+ const { x: x , y: y } = offset;
744
+ return {
745
+ transform: `translate(${x + 10}px, ${y + 10}px)`
746
+ };
747
+ };
748
+ function $6d8109ab8cbcd5e7$export$133773870222880f() {
749
+ const { offset: offset , mouse: mouse , item: item , isDragging: isDragging } = $g00cZ$useDragLayer((m)=>({
750
+ offset: m.getSourceClientOffset(),
751
+ mouse: m.getClientOffset(),
752
+ item: m.getItem(),
753
+ isDragging: m.isDragging()
754
+ })
755
+ );
756
+ return(/*#__PURE__*/ $g00cZ$jsxs($6d8109ab8cbcd5e7$var$Overlay, {
757
+ isDragging: isDragging,
758
+ children: [
759
+ /*#__PURE__*/ $g00cZ$jsx($6d8109ab8cbcd5e7$var$Position, {
760
+ offset: offset,
761
+ children: /*#__PURE__*/ $g00cZ$jsx($6d8109ab8cbcd5e7$var$PreviewNode, {
762
+ item: item
763
+ })
764
+ }),
765
+ /*#__PURE__*/ $g00cZ$jsx($6d8109ab8cbcd5e7$var$Count, {
766
+ mouse: mouse,
767
+ item: item
768
+ })
769
+ ]
770
+ }));
676
771
  }
772
+ const $6d8109ab8cbcd5e7$var$Overlay = /*#__PURE__*/ $g00cZ$memo(function Overlay(props) {
773
+ if (!props.isDragging) return null;
774
+ return(/*#__PURE__*/ $g00cZ$jsx("div", {
775
+ style: $6d8109ab8cbcd5e7$var$layerStyles,
776
+ children: props.children
777
+ }));
778
+ });
779
+ function $6d8109ab8cbcd5e7$var$Position(props) {
780
+ return(/*#__PURE__*/ $g00cZ$jsx("div", {
781
+ className: "row preview",
782
+ style: $6d8109ab8cbcd5e7$var$getStyle(props.offset),
783
+ children: props.children
784
+ }));
785
+ }
786
+ function $6d8109ab8cbcd5e7$var$Count(props) {
787
+ const { item: item , mouse: mouse } = props;
788
+ if (item?.dragIds?.length > 1) return(/*#__PURE__*/ $g00cZ$jsx("div", {
789
+ className: "selected-count",
790
+ style: $6d8109ab8cbcd5e7$var$getCountStyle(mouse),
791
+ children: item.dragIds.length
792
+ }));
793
+ else return null;
794
+ }
795
+ const $6d8109ab8cbcd5e7$var$PreviewNode = /*#__PURE__*/ $g00cZ$memo(function PreviewNode(props) {
796
+ const tree = $3273af3fe11a7001$export$367b0f2231a90ba0();
797
+ if (!props.item) return null;
798
+ const node = tree.getNode(props.item.id);
799
+ if (!node) return null;
800
+ return(/*#__PURE__*/ $g00cZ$jsx(tree.renderer, {
801
+ preview: true,
802
+ innerRef: ()=>{
803
+ },
804
+ data: node.model,
805
+ styles: {
806
+ row: {
807
+ },
808
+ indent: {
809
+ paddingLeft: node.level * tree.indent
810
+ }
811
+ },
812
+ tree: tree,
813
+ state: {
814
+ isDragging: false,
815
+ isEditing: false,
816
+ isSelected: false,
817
+ isSelectedStart: false,
818
+ isSelectedEnd: false,
819
+ isHoveringOverChild: false,
820
+ isOpen: node.isOpen
821
+ },
822
+ handlers: {
823
+ edit: ()=>Promise.resolve({
824
+ cancelled: true
825
+ })
826
+ ,
827
+ select: ()=>{
828
+ },
829
+ toggle: ()=>{
830
+ },
831
+ submit: ()=>{
832
+ },
833
+ reset: ()=>{
834
+ }
835
+ }
836
+ }));
837
+ });
838
+
677
839
 
678
840
 
679
841
 
680
842
 
681
- class $40fcfa3e17312481$export$e2da3477247342d1 {
682
- constructor(dispatch, state, props, list){
683
- this.dispatch = dispatch;
684
- this.state = state;
685
- this.props = props;
686
- this.list = list;
687
- this.edits = new Map();
688
- }
689
- assign(dispatch, state, props, list) {
690
- this.dispatch = dispatch;
691
- this.state = state;
692
- this.props = props;
693
- this.list = list;
694
- }
695
- getNode(id) {
696
- if (id in this.idToIndex) return this.visibleNodes[this.idToIndex[id]] || null;
697
- else return null;
698
- }
699
- getSelectedIds() {
700
- return this.state.selection.ids;
701
- }
702
- edit(id) {
703
- const sid = id.toString();
704
- this.resolveEdit(sid, {
705
- cancelled: true
706
- });
707
- this.scrollToId(sid);
708
- this.dispatch($b26f0eafd5701d7d$export$e324594224ef24da.edit(sid));
709
- return new Promise((resolve)=>this.edits.set(sid, resolve)
710
- );
711
- }
712
- submit(id, value) {
713
- const sid = id.toString();
714
- this.props.onEdit(sid, value);
715
- this.dispatch($b26f0eafd5701d7d$export$e324594224ef24da.edit(null));
716
- this.resolveEdit(sid, {
717
- cancelled: false,
718
- value: value
719
- });
720
- }
721
- reset(id) {
722
- const sid = id.toString();
723
- this.dispatch($b26f0eafd5701d7d$export$e324594224ef24da.edit(null));
724
- this.resolveEdit(sid, {
725
- cancelled: true
726
- });
727
- }
728
- resolveEdit(id, value) {
729
- const resolve = this.edits.get(id.toString());
730
- if (resolve) resolve(value);
731
- this.edits.delete(id);
732
- }
733
- select(index, meta = false, shift = false) {
734
- this.dispatch($b26f0eafd5701d7d$export$e324594224ef24da.select(index, meta, shift));
735
- }
736
- selectById(id, meta = false, shift = false) {
737
- const index = this.idToIndex[id];
738
- this.select(index, meta, shift);
739
- }
740
- selectUpwards(shiftKey) {
741
- this.dispatch($b26f0eafd5701d7d$export$e324594224ef24da.stepUp(shiftKey, this.visibleIds));
742
- }
743
- selectDownwards(shiftKey) {
744
- this.dispatch($b26f0eafd5701d7d$export$e324594224ef24da.stepDown(shiftKey, this.visibleIds));
745
- }
746
- hideCursor() {
747
- this.dispatch($b26f0eafd5701d7d$export$e324594224ef24da.setCursorLocation({
748
- type: "none"
749
- }));
750
- }
751
- showCursor(cursor) {
752
- this.dispatch($b26f0eafd5701d7d$export$e324594224ef24da.setCursorLocation(cursor));
753
- }
754
- scrollToId(id) {
755
- if (!this.list) return;
756
- const index1 = this.idToIndex[id];
757
- if (index1) this.list.scrollToItem(index1);
758
- else {
759
- this.openParents(id);
760
- $g00cZ$reactdom.flushSync(()=>{
761
- const index = this.idToIndex[id];
762
- if (index) this.list?.scrollToItem(index);
763
- });
764
- }
765
- }
766
- open(id) {
767
- this.props.onToggle(id, true);
768
- }
769
- openParents(id) {
770
- const node = $40fcfa3e17312481$var$dfs(this.props.root, id);
771
- let parent = node?.parent;
772
- while(parent){
773
- this.open(parent.id);
774
- parent = parent.parent;
775
- }
776
- }
777
- get visibleIds() {
778
- return $40fcfa3e17312481$var$getIds(this.visibleNodes);
779
- }
780
- get idToIndex() {
781
- return $40fcfa3e17312481$var$createIndex(this.visibleNodes);
843
+ function $2db980bfed6822da$var$measureHover(el, offset) {
844
+ const rect = el.getBoundingClientRect();
845
+ const x = offset.x - Math.round(rect.x);
846
+ const y = offset.y - Math.round(rect.y);
847
+ const height = rect.height;
848
+ const inTopHalf = y < height / 2;
849
+ const inBottomHalf = !inTopHalf;
850
+ const pad = height / 4;
851
+ const inMiddle = y > pad && y < height - pad;
852
+ const atTop = !inMiddle && inTopHalf;
853
+ const atBottom = !inMiddle && inBottomHalf;
854
+ return {
855
+ x: x,
856
+ inTopHalf: inTopHalf,
857
+ inBottomHalf: inBottomHalf,
858
+ inMiddle: inMiddle,
859
+ atTop: atTop,
860
+ atBottom: atBottom
861
+ };
862
+ }
863
+ function $2db980bfed6822da$var$getNodesAroundCursor(node, prev, next, hover) {
864
+ if (!node) // We're hoving over the empty part of the list, not over an item,
865
+ // Put the cursor below the last item which is "prev"
866
+ return [
867
+ prev,
868
+ null
869
+ ];
870
+ if ($0e6083160f4b36ed$export$769c5e872f5f8638(node)) {
871
+ if (hover.atTop) return [
872
+ prev,
873
+ node
874
+ ];
875
+ else if (hover.inMiddle) return [
876
+ node,
877
+ node
878
+ ];
879
+ else return [
880
+ node,
881
+ next
882
+ ];
883
+ } else {
884
+ if (hover.inTopHalf) return [
885
+ prev,
886
+ node
887
+ ];
888
+ else return [
889
+ node,
890
+ next
891
+ ];
782
892
  }
783
- get visibleNodes() {
784
- return $40fcfa3e17312481$var$createList(this.props.root);
893
+ }
894
+ function $2db980bfed6822da$var$getDropLevel(hovering, aboveCursor, belowCursor, indent) {
895
+ const hoverLevel = Math.round(Math.max(0, hovering.x - indent) / indent);
896
+ let min, max;
897
+ if (!aboveCursor) {
898
+ max = 0;
899
+ min = 0;
900
+ } else if (!belowCursor) {
901
+ max = aboveCursor.level;
902
+ min = 0;
903
+ } else {
904
+ max = aboveCursor.level;
905
+ min = belowCursor.level;
785
906
  }
907
+ return $0e6083160f4b36ed$export$adf7c0fe6059d774(hoverLevel, min, max);
786
908
  }
787
- const $40fcfa3e17312481$var$getIds = $g00cZ$memoizeone((nodes)=>nodes.map((n)=>n.id
788
- )
789
- );
790
- const $40fcfa3e17312481$var$createIndex = $g00cZ$memoizeone((nodes)=>{
791
- return nodes.reduce((map, node, index)=>{
792
- map[node.id] = index;
793
- return map;
794
- }, {
795
- });
796
- });
797
- const $40fcfa3e17312481$var$createList = $g00cZ$memoizeone($4dcb7be69f759cab$export$79f9fa345a841d8b);
798
- function $40fcfa3e17312481$var$dfs(node, id) {
799
- if (!node) return null;
800
- if (node.id === id) return node;
801
- if (node.children) for (let child of node.children){
802
- const result = $40fcfa3e17312481$var$dfs(child, id);
803
- if (result) return result;
909
+ function $2db980bfed6822da$var$canDrop(above, below) {
910
+ if (!above) return true;
911
+ let n = above;
912
+ if ($0e6083160f4b36ed$export$4210f5ea57fbae57(above) && above !== below) n = above.parent;
913
+ while(n){
914
+ if (!n.isDroppable) return false;
915
+ n = n.parent;
804
916
  }
805
- return null;
917
+ return true;
806
918
  }
807
-
808
-
809
- function $496a9613a893751e$export$367b0f2231a90ba0(state, dispatch, props, list) {
810
- /**
811
- * We only ever want one instance of the api object
812
- * It will get updated as the props change, but the
813
- * reference will not.
814
- */ const api = $g00cZ$useMemo(()=>new $40fcfa3e17312481$export$e2da3477247342d1(dispatch, state, props, list)
815
- , // eslint-disable-next-line
816
- []);
817
- api.assign(dispatch, state, props, list);
818
- /**
819
- * This ensures that the selection remains correct even
820
- * after opening and closing a folders
821
- */ $g00cZ$useLayoutEffect(()=>{
822
- dispatch($b26f0eafd5701d7d$export$e324594224ef24da.setVisibleIds(api.visibleIds, api.idToIndex));
823
- }, [
824
- dispatch,
825
- api,
826
- props.root
827
- ]);
828
- return api;
919
+ function $2db980bfed6822da$var$dropAt(parentId, index) {
920
+ return {
921
+ parentId: parentId || null,
922
+ index: index
923
+ };
924
+ }
925
+ function $2db980bfed6822da$var$lineCursor(index, level) {
926
+ return {
927
+ type: "line",
928
+ index: index,
929
+ level: level
930
+ };
931
+ }
932
+ function $2db980bfed6822da$var$noCursor() {
933
+ return {
934
+ type: "none"
935
+ };
936
+ }
937
+ function $2db980bfed6822da$var$highlightCursor(id) {
938
+ return {
939
+ type: "highlight",
940
+ id: id
941
+ };
942
+ }
943
+ function $2db980bfed6822da$var$walkUpFrom(node, level) {
944
+ let drop = node;
945
+ while(drop.parent && drop.level > level)drop = drop.parent;
946
+ const parentId = drop.parent?.id || null;
947
+ const index = $0e6083160f4b36ed$export$305f7d4e9d4624f2(drop) + 1;
948
+ return {
949
+ parentId: parentId,
950
+ index: index
951
+ };
952
+ }
953
+ function $2db980bfed6822da$export$f502ca02ebb85a1c(args) {
954
+ const hover = $2db980bfed6822da$var$measureHover(args.element, args.offset);
955
+ const { node: node , nextNode: nextNode , prevNode: prevNode } = args;
956
+ const [above, below] = $2db980bfed6822da$var$getNodesAroundCursor(node, prevNode, nextNode, hover);
957
+ if (!$2db980bfed6822da$var$canDrop(above, below)) return {
958
+ drop: null,
959
+ cursor: $2db980bfed6822da$var$noCursor()
960
+ };
961
+ /* Hovering over the middle of a folder */ if (node && $0e6083160f4b36ed$export$769c5e872f5f8638(node) && hover.inMiddle) return {
962
+ drop: $2db980bfed6822da$var$dropAt(node.id, 0),
963
+ cursor: $2db980bfed6822da$var$highlightCursor(node.id)
964
+ };
965
+ /* At the top of the list */ if (!above) return {
966
+ drop: $2db980bfed6822da$var$dropAt(below?.parent?.id, 0),
967
+ cursor: $2db980bfed6822da$var$lineCursor(0, 0)
968
+ };
969
+ /* The above node is an item or a closed folder */ if ($0e6083160f4b36ed$export$5318634f2ee07019(above) || $0e6083160f4b36ed$export$4210f5ea57fbae57(above)) {
970
+ const level = $2db980bfed6822da$var$getDropLevel(hover, above, below, args.indent);
971
+ return {
972
+ drop: $2db980bfed6822da$var$walkUpFrom(above, level),
973
+ cursor: $2db980bfed6822da$var$lineCursor(above.rowIndex + 1, level)
974
+ };
975
+ }
976
+ /* The above node is an open folder */ return {
977
+ drop: $2db980bfed6822da$var$dropAt(above?.id, 0),
978
+ cursor: $2db980bfed6822da$var$lineCursor(above.rowIndex + 1, above.level + 1)
979
+ };
829
980
  }
830
981
 
831
982
 
832
- function $3a48b0a92affa3e3$export$6a399b2f7f12632c(props) {
833
- const [state, dispatch] = $g00cZ$useReducer($b26f0eafd5701d7d$export$1650419e431d3ba3, $b26f0eafd5701d7d$export$f6196a6c6bb539b4());
834
- const list = $g00cZ$useRef();
835
- const api = $496a9613a893751e$export$367b0f2231a90ba0(state, dispatch, props, list.current);
836
- $g00cZ$useImperativeHandle(props.imperativeHandle, ()=>api
837
- );
838
- $bafe08914d05476b$export$de605877a37dc399(props.listEl, api);
839
- const staticValue = $g00cZ$useMemo(()=>({
840
- ...props,
841
- api: api,
842
- list: list
983
+ function $e739455e59c6aed3$export$5a6c424b1725f44f() {
984
+ const tree = $3273af3fe11a7001$export$367b0f2231a90ba0();
985
+ // In case we drop an item at the bottom of the list
986
+ const [, drop1] = $g00cZ$useDrop(()=>({
987
+ accept: "NODE",
988
+ hover: (item, m)=>{
989
+ if (!m.isOver({
990
+ shallow: true
991
+ })) return;
992
+ const offset = m.getClientOffset();
993
+ if (!tree.listEl.current || !offset) return;
994
+ const { cursor: cursor } = $2db980bfed6822da$export$f502ca02ebb85a1c({
995
+ element: tree.listEl.current,
996
+ offset: offset,
997
+ indent: tree.indent,
998
+ node: null,
999
+ prevNode: tree.visibleNodes[tree.visibleNodes.length - 1],
1000
+ nextNode: null
1001
+ });
1002
+ if (cursor) tree.showCursor(cursor);
1003
+ },
1004
+ canDrop: (item, m)=>{
1005
+ return m.isOver({
1006
+ shallow: true
1007
+ });
1008
+ },
1009
+ drop: (item, m)=>{
1010
+ if (m.didDrop()) return;
1011
+ const offset = m.getClientOffset();
1012
+ if (!tree.listEl.current || !offset) return;
1013
+ const { drop: drop } = $2db980bfed6822da$export$f502ca02ebb85a1c({
1014
+ element: tree.listEl.current,
1015
+ offset: offset,
1016
+ indent: tree.indent,
1017
+ node: null,
1018
+ prevNode: tree.visibleNodes[tree.visibleNodes.length - 1],
1019
+ nextNode: null
1020
+ });
1021
+ return drop;
1022
+ }
843
1023
  })
844
1024
  , [
845
- props,
846
- api,
847
- list
1025
+ tree
848
1026
  ]);
849
- /**
850
- * This context pattern is ridiculous, next time use redux.
851
- */ return(// @ts-ignore
852
- /*#__PURE__*/ $g00cZ$jsx($3273af3fe11a7001$export$c1b9a1d3af45b7b6.Provider, {
853
- value: staticValue,
854
- children: /*#__PURE__*/ $g00cZ$jsx($3273af3fe11a7001$export$7f994e57c9e78355.Provider, {
855
- value: state.editingId,
856
- children: /*#__PURE__*/ $g00cZ$jsx($3273af3fe11a7001$export$7c7a4fd7f1336e2c.Provider, {
857
- value: state.selection,
858
- children: /*#__PURE__*/ $g00cZ$jsx($3273af3fe11a7001$export$7380e5d4146ff2ce.Provider, {
859
- value: $3a48b0a92affa3e3$var$getParentId(state.cursor),
860
- children: /*#__PURE__*/ $g00cZ$jsx($3273af3fe11a7001$export$86fe4415b73783a1.Provider, {
861
- value: $3a48b0a92affa3e3$var$isOverFolder(state),
862
- children: /*#__PURE__*/ $g00cZ$jsx($3273af3fe11a7001$export$76f51715425ee155.Provider, {
863
- value: state.cursor,
864
- children: props.children
865
- })
866
- })
867
- })
868
- })
869
- })
870
- }));
871
- }
872
- function $3a48b0a92affa3e3$var$getParentId(cursor) {
873
- switch(cursor.type){
874
- case "highlight":
875
- return cursor.id;
876
- default:
877
- return null;
878
- }
1027
+ drop1(tree.listEl);
879
1028
  }
880
- function $3a48b0a92affa3e3$var$isOverFolder(state) {
881
- return state.cursor.type === "highlight";
1029
+
1030
+
1031
+ function $5d6a5680e6f62734$export$a6ee728c3c6ef11d(props) {
1032
+ $e739455e59c6aed3$export$5a6c424b1725f44f();
1033
+ return props.children;
882
1034
  }
883
1035
 
884
1036
 
@@ -886,181 +1038,49 @@ function $3a48b0a92affa3e3$var$isOverFolder(state) {
886
1038
 
887
1039
 
888
1040
 
1041
+
1042
+
1043
+
889
1044
  function $fe2fd2e13360ebf7$export$ef961593063b03e8() {
890
- const treeView = $3273af3fe11a7001$export$ea6c3ae2bd3a5510();
891
- const cursor = $3273af3fe11a7001$export$6c87584817ff2461();
1045
+ const tree = $3273af3fe11a7001$export$367b0f2231a90ba0();
1046
+ const cursor = tree.state.cursor;
892
1047
  if (!cursor || cursor.type !== "line") return null;
893
- const top = treeView.rowHeight * cursor.index;
894
- const left = treeView.indent * cursor.level;
895
- const style = {
896
- position: "absolute",
897
- pointerEvents: "none",
898
- top: top - 2 + "px",
899
- left: treeView.indent + left + "px",
900
- right: treeView.indent + "px"
901
- };
902
- return(/*#__PURE__*/ $g00cZ$jsx($fe2fd2e13360ebf7$var$DefaultCursor, {
903
- style: style
904
- }));
1048
+ const indent = tree.indent;
1049
+ const top = tree.rowHeight * cursor.index;
1050
+ const left = indent * cursor.level;
1051
+ return tree.renderDropCursor({
1052
+ top: top,
1053
+ left: left,
1054
+ indent: indent
1055
+ });
905
1056
  }
906
- const $fe2fd2e13360ebf7$var$placeholderStyle = {
907
- display: "flex",
908
- alignItems: "center"
909
- };
910
- const $fe2fd2e13360ebf7$var$lineStyle = {
911
- flex: 1,
912
- height: "2px",
913
- background: "#4B91E2",
914
- borderRadius: "1px"
915
- };
916
- const $fe2fd2e13360ebf7$var$circleStyle = {
917
- width: "4px",
918
- height: "4px",
919
- boxShadow: "0 0 0 3px #4B91E2",
920
- borderRadius: "50%"
921
- };
922
- function $fe2fd2e13360ebf7$var$DefaultCursor({ style: style }) {
1057
+
1058
+
1059
+ const $05f64c7ebcbad8b5$export$70c2b8898b86d3ad = /*#__PURE__*/ $g00cZ$forwardRef(function Outer(props, ref) {
1060
+ const { children: children , ...rest } = props;
1061
+ const tree = $3273af3fe11a7001$export$367b0f2231a90ba0();
923
1062
  return(/*#__PURE__*/ $g00cZ$jsxs("div", {
924
- style: {
925
- ...$fe2fd2e13360ebf7$var$placeholderStyle,
926
- ...style
927
- },
1063
+ // @ts-ignore
1064
+ ref: ref,
1065
+ ...rest,
1066
+ onClick: tree.onClick,
1067
+ onContextMenu: tree.onContextMenu,
928
1068
  children: [
929
1069
  /*#__PURE__*/ $g00cZ$jsx("div", {
930
1070
  style: {
931
- ...$fe2fd2e13360ebf7$var$circleStyle
932
- }
933
- }),
934
- /*#__PURE__*/ $g00cZ$jsx("div", {
935
- style: {
936
- ...$fe2fd2e13360ebf7$var$lineStyle
937
- }
938
- })
939
- ]
940
- }));
941
- }
942
-
943
-
944
-
945
-
946
-
947
-
948
- const $6d8109ab8cbcd5e7$var$layerStyles = {
949
- position: "fixed",
950
- pointerEvents: "none",
951
- zIndex: 100,
952
- left: 0,
953
- top: 0,
954
- width: "100%",
955
- height: "100%"
956
- };
957
- const $6d8109ab8cbcd5e7$var$getStyle = (offset)=>{
958
- if (!offset) return {
959
- display: "none"
960
- };
961
- const { x: x , y: y } = offset;
962
- return {
963
- transform: `translate(${x}px, ${y}px)`
964
- };
965
- };
966
- const $6d8109ab8cbcd5e7$var$getCountStyle = (offset)=>{
967
- if (!offset) return {
968
- display: "none"
969
- };
970
- const { x: x , y: y } = offset;
971
- return {
972
- transform: `translate(${x + 10}px, ${y + 10}px)`
973
- };
974
- };
975
- function $6d8109ab8cbcd5e7$export$133773870222880f() {
976
- const { offset: offset , mouse: mouse , item: item , isDragging: isDragging } = $g00cZ$useDragLayer((m)=>({
977
- offset: m.getSourceClientOffset(),
978
- mouse: m.getClientOffset(),
979
- item: m.getItem(),
980
- isDragging: m.isDragging()
981
- })
982
- );
983
- return(/*#__PURE__*/ $g00cZ$jsxs($6d8109ab8cbcd5e7$var$Overlay, {
984
- isDragging: isDragging,
985
- children: [
986
- /*#__PURE__*/ $g00cZ$jsx($6d8109ab8cbcd5e7$var$Position, {
987
- offset: offset,
988
- children: /*#__PURE__*/ $g00cZ$jsx($6d8109ab8cbcd5e7$var$PreviewNode, {
989
- item: item
1071
+ height: tree.visibleNodes.length * tree.rowHeight,
1072
+ width: "100%",
1073
+ overflow: "hidden",
1074
+ position: "absolute",
1075
+ left: "0",
1076
+ right: "0"
1077
+ },
1078
+ children: /*#__PURE__*/ $g00cZ$jsx($fe2fd2e13360ebf7$export$ef961593063b03e8, {
990
1079
  })
991
1080
  }),
992
- /*#__PURE__*/ $g00cZ$jsx($6d8109ab8cbcd5e7$var$Count, {
993
- mouse: mouse,
994
- item: item
995
- })
1081
+ children
996
1082
  ]
997
1083
  }));
998
- }
999
- const $6d8109ab8cbcd5e7$var$Overlay = /*#__PURE__*/ $g00cZ$memo(function Overlay(props) {
1000
- if (!props.isDragging) return null;
1001
- return(/*#__PURE__*/ $g00cZ$jsx("div", {
1002
- style: $6d8109ab8cbcd5e7$var$layerStyles,
1003
- children: props.children
1004
- }));
1005
- });
1006
- function $6d8109ab8cbcd5e7$var$Position(props) {
1007
- return(/*#__PURE__*/ $g00cZ$jsx("div", {
1008
- className: "row preview",
1009
- style: $6d8109ab8cbcd5e7$var$getStyle(props.offset),
1010
- children: props.children
1011
- }));
1012
- }
1013
- function $6d8109ab8cbcd5e7$var$Count(props) {
1014
- const { item: item , mouse: mouse } = props;
1015
- if (item?.dragIds?.length > 1) return(/*#__PURE__*/ $g00cZ$jsx("div", {
1016
- className: "selected-count",
1017
- style: $6d8109ab8cbcd5e7$var$getCountStyle(mouse),
1018
- children: item.dragIds.length
1019
- }));
1020
- else return null;
1021
- }
1022
- const $6d8109ab8cbcd5e7$var$PreviewNode = /*#__PURE__*/ $g00cZ$memo(function PreviewNode(props) {
1023
- const tree = $3273af3fe11a7001$export$ea6c3ae2bd3a5510();
1024
- if (!props.item) return null;
1025
- const node = tree.api.getNode(props.item.id);
1026
- if (!node) return null;
1027
- return(/*#__PURE__*/ $g00cZ$jsx(tree.renderer, {
1028
- preview: true,
1029
- innerRef: ()=>{
1030
- },
1031
- data: node.model,
1032
- styles: {
1033
- row: {
1034
- },
1035
- indent: {
1036
- paddingLeft: node.level * tree.indent
1037
- }
1038
- },
1039
- tree: tree.api,
1040
- state: {
1041
- isDragging: false,
1042
- isEditing: false,
1043
- isSelected: false,
1044
- isSelectedStart: false,
1045
- isSelectedEnd: false,
1046
- isHoveringOverChild: false,
1047
- isOpen: node.isOpen
1048
- },
1049
- handlers: {
1050
- edit: ()=>Promise.resolve({
1051
- cancelled: true
1052
- })
1053
- ,
1054
- select: ()=>{
1055
- },
1056
- toggle: ()=>{
1057
- },
1058
- submit: ()=>{
1059
- },
1060
- reset: ()=>{
1061
- }
1062
- }
1063
- }));
1064
1084
  });
1065
1085
 
1066
1086
 
@@ -1072,16 +1092,15 @@ const $6d8109ab8cbcd5e7$var$PreviewNode = /*#__PURE__*/ $g00cZ$memo(function Pre
1072
1092
 
1073
1093
 
1074
1094
  function $907e707a330ef23a$export$715c0d031ede7907(node) {
1075
- const tree = $3273af3fe11a7001$export$ea6c3ae2bd3a5510();
1076
- const isSelected = $3273af3fe11a7001$export$fb40a80c530e5f2b();
1077
- const ids = $3273af3fe11a7001$export$1c9b7756eccadc96();
1095
+ const tree = $3273af3fe11a7001$export$367b0f2231a90ba0();
1096
+ const ids = tree.getSelectedIds();
1078
1097
  const [{ isDragging: isDragging }, ref, preview] = $g00cZ$useDrag(()=>({
1079
1098
  canDrag: ()=>node.isDraggable
1080
1099
  ,
1081
1100
  type: "NODE",
1082
1101
  item: ()=>({
1083
1102
  id: node.id,
1084
- dragIds: isSelected(node.rowIndex) ? ids : [
1103
+ dragIds: tree.isSelected(node.rowIndex) ? ids : [
1085
1104
  node.id
1086
1105
  ]
1087
1106
  })
@@ -1091,7 +1110,7 @@ function $907e707a330ef23a$export$715c0d031ede7907(node) {
1091
1110
  })
1092
1111
  ,
1093
1112
  end: (item, monitor)=>{
1094
- tree.api.hideCursor();
1113
+ tree.hideCursor();
1095
1114
  const drop = monitor.getDropResult();
1096
1115
  if (drop && drop.parentId) {
1097
1116
  tree.onMove(item.dragIds, drop.parentId, drop.index);
@@ -1122,12 +1141,12 @@ function $907e707a330ef23a$export$715c0d031ede7907(node) {
1122
1141
 
1123
1142
 
1124
1143
  function $d38aa53467160173$export$57afafec4637d997(el, node, prev, next) {
1125
- const tree = $3273af3fe11a7001$export$ea6c3ae2bd3a5510();
1144
+ const tree = $3273af3fe11a7001$export$367b0f2231a90ba0();
1126
1145
  return $g00cZ$useDrop(()=>({
1127
1146
  accept: "NODE",
1128
1147
  canDrop: (item)=>{
1129
1148
  for (let id of item.dragIds){
1130
- const drag = tree.api.getNode(id);
1149
+ const drag = tree.getNode(id);
1131
1150
  if (!drag) return false;
1132
1151
  if ($0e6083160f4b36ed$export$769c5e872f5f8638(drag) && $0e6083160f4b36ed$export$1e38f72c6c546f70(node, drag)) return false;
1133
1152
  }
@@ -1145,8 +1164,8 @@ function $d38aa53467160173$export$57afafec4637d997(el, node, prev, next) {
1145
1164
  prevNode: prev,
1146
1165
  nextNode: next
1147
1166
  });
1148
- if (cursor) tree.api.showCursor(cursor);
1149
- } else tree.api.hideCursor();
1167
+ if (cursor) tree.showCursor(cursor);
1168
+ } else tree.hideCursor();
1150
1169
  },
1151
1170
  drop: (item, m)=>{
1152
1171
  const offset = m.getClientOffset();
@@ -1172,22 +1191,22 @@ function $d38aa53467160173$export$57afafec4637d997(el, node, prev, next) {
1172
1191
 
1173
1192
 
1174
1193
  const $2c0a5a237609003e$export$b59bdbef9ce70de2 = /*#__PURE__*/ $g00cZ$react.memo(function $2c0a5a237609003e$export$b59bdbef9ce70de2({ index: index , style: style }) {
1175
- const tree = $3273af3fe11a7001$export$ea6c3ae2bd3a5510();
1176
- const selected = $3273af3fe11a7001$export$fb40a80c530e5f2b();
1177
- const node = tree.api.visibleNodes[index];
1178
- const next = tree.api.visibleNodes[index + 1] || null;
1179
- const prev = tree.api.visibleNodes[index - 1] || null;
1180
- const cursorParentId = $3273af3fe11a7001$export$8e294ac6de4c921f();
1181
- const cursorOverFolder = $3273af3fe11a7001$export$f3ad962ff713505f();
1194
+ const realTree = $3273af3fe11a7001$export$367b0f2231a90ba0();
1195
+ const tree = $g00cZ$useMemo(()=>realTree
1196
+ , []);
1197
+ tree.sync(realTree);
1198
+ const node = tree.visibleNodes[index];
1199
+ const next = tree.visibleNodes[index + 1] || null;
1200
+ const prev = tree.visibleNodes[index - 1] || null;
1182
1201
  const el = $g00cZ$useRef(null);
1183
1202
  const [{ isDragging: isDragging }, dragRef] = $907e707a330ef23a$export$715c0d031ede7907(node);
1184
1203
  const [, dropRef] = $d38aa53467160173$export$57afafec4637d997(el, node, prev, next);
1185
- const isEditing = node.id === $3273af3fe11a7001$export$9ab192f953c1b33b();
1186
- const isSelected = selected(index);
1187
- const nextSelected = next && selected(index + 1);
1188
- const prevSelected = prev && selected(index - 1);
1189
- const isHoveringOverChild = node.id === cursorParentId;
1190
- const isOverFolder = node.id === cursorParentId && cursorOverFolder;
1204
+ const isEditing = node.id === tree.editingId;
1205
+ const isSelected = tree.isSelected(index);
1206
+ const nextSelected = next && tree.isSelected(index + 1);
1207
+ const prevSelected = prev && tree.isSelected(index - 1);
1208
+ const isHoveringOverChild = node.id === tree.cursorParentId;
1209
+ const isOverFolder = node.id === tree.cursorParentId && tree.cursorOverFolder;
1191
1210
  const isOpen = node.isOpen;
1192
1211
  const indent = tree.indent * node.level;
1193
1212
  const state = $g00cZ$useMemo(()=>{
@@ -1236,23 +1255,23 @@ const $2c0a5a237609003e$export$b59bdbef9ce70de2 = /*#__PURE__*/ $g00cZ$react.mem
1236
1255
  selectOnClick: true
1237
1256
  })=>{
1238
1257
  if (node.rowIndex === null) return;
1239
- if (args.selectOnClick || e.metaKey || e.shiftKey) tree.api.select(node.rowIndex, e.metaKey, e.shiftKey);
1240
- else tree.api.select(null, false, false);
1258
+ if (args.selectOnClick || e.metaKey || e.shiftKey) tree.select(node.rowIndex, e.metaKey, e.shiftKey);
1259
+ else tree.select(null, false, false);
1241
1260
  },
1242
1261
  toggle: (e)=>{
1243
1262
  e.stopPropagation();
1244
1263
  tree.onToggle(node.id, !node.isOpen);
1245
1264
  },
1246
- edit: ()=>tree.api.edit(node.id)
1265
+ edit: ()=>tree.edit(node.id)
1247
1266
  ,
1248
1267
  submit: (name)=>{
1249
- name.trim() ? tree.api.submit(node.id, name) : tree.api.reset(node.id);
1268
+ name.trim() ? tree.submit(node.id, name) : tree.reset(node.id);
1250
1269
  },
1251
- reset: ()=>tree.api.reset(node.id)
1270
+ reset: ()=>tree.reset(node.id)
1252
1271
  };
1253
1272
  }, [
1254
- tree,
1255
- node
1273
+ node,
1274
+ tree
1256
1275
  ]);
1257
1276
  const Renderer = $g00cZ$useMemo(()=>{
1258
1277
  return(/*#__PURE__*/ $g00cZ$react.memo(tree.renderer));
@@ -1266,39 +1285,13 @@ const $2c0a5a237609003e$export$b59bdbef9ce70de2 = /*#__PURE__*/ $g00cZ$react.mem
1266
1285
  state: state,
1267
1286
  handlers: handlers,
1268
1287
  preview: false,
1269
- tree: tree.api
1288
+ tree: tree
1270
1289
  }));
1271
1290
  });
1272
1291
 
1273
1292
 
1274
- const $2ba43033bb8eb39d$var$OuterElement = /*#__PURE__*/ $g00cZ$forwardRef(function Outer(props, ref) {
1275
- const { children: children , ...rest } = props;
1276
- const tree = $3273af3fe11a7001$export$ea6c3ae2bd3a5510();
1277
- return(/*#__PURE__*/ $g00cZ$jsxs("div", {
1278
- // @ts-ignore
1279
- ref: ref,
1280
- ...rest,
1281
- onClick: tree.onClick,
1282
- onContextMenu: tree.onContextMenu,
1283
- children: [
1284
- /*#__PURE__*/ $g00cZ$jsx("div", {
1285
- style: {
1286
- height: tree.api.visibleNodes.length * tree.rowHeight,
1287
- width: "100%",
1288
- overflow: "hidden",
1289
- position: "absolute",
1290
- left: "0",
1291
- right: "0"
1292
- },
1293
- children: /*#__PURE__*/ $g00cZ$jsx($fe2fd2e13360ebf7$export$ef961593063b03e8, {
1294
- })
1295
- }),
1296
- children
1297
- ]
1298
- }));
1299
- });
1300
- function $2ba43033bb8eb39d$var$List(props) {
1301
- const tree = $3273af3fe11a7001$export$ea6c3ae2bd3a5510();
1293
+ function $334f7345c929ac88$export$54c2e3dc7acea9f5(props) {
1294
+ const tree = $3273af3fe11a7001$export$367b0f2231a90ba0();
1302
1295
  return(/*#__PURE__*/ $g00cZ$jsx("div", {
1303
1296
  style: {
1304
1297
  height: tree.height,
@@ -1308,23 +1301,20 @@ function $2ba43033bb8eb39d$var$List(props) {
1308
1301
  children: /*#__PURE__*/ $g00cZ$jsx($g00cZ$FixedSizeList, {
1309
1302
  className: props.className,
1310
1303
  outerRef: tree.listEl,
1311
- itemCount: tree.api.visibleNodes.length,
1304
+ itemCount: tree.visibleNodes.length,
1312
1305
  height: tree.height,
1313
1306
  width: tree.width,
1314
1307
  itemSize: tree.rowHeight,
1315
- itemKey: (index)=>tree.api.visibleNodes[index]?.id || index
1308
+ itemKey: (index)=>tree.visibleNodes[index]?.id || index
1316
1309
  ,
1317
- outerElementType: $2ba43033bb8eb39d$var$OuterElement,
1318
- // @ts-ignore
1310
+ outerElementType: $05f64c7ebcbad8b5$export$70c2b8898b86d3ad,
1319
1311
  ref: tree.list,
1320
1312
  children: $2c0a5a237609003e$export$b59bdbef9ce70de2
1321
1313
  })
1322
1314
  }));
1323
1315
  }
1324
- function $2ba43033bb8eb39d$var$OuterDrop(props) {
1325
- $e739455e59c6aed3$export$5a6c424b1725f44f();
1326
- return props.children;
1327
- }
1316
+
1317
+
1328
1318
  const $2ba43033bb8eb39d$export$7fbedc92909ed28e = /*#__PURE__*/ $g00cZ$forwardRef(function $2ba43033bb8eb39d$export$7fbedc92909ed28e(props, ref) {
1329
1319
  const root = $g00cZ$useMemo(()=>$1e5818ce7991d06d$export$9c537176392280a0(props.data, props.hideRoot, props.getChildren, props.isOpen, props.disableDrag, props.disableDrop, props.openByDefault)
1330
1320
  , [
@@ -1337,27 +1327,17 @@ const $2ba43033bb8eb39d$export$7fbedc92909ed28e = /*#__PURE__*/ $g00cZ$forwardRe
1337
1327
  props.openByDefault,
1338
1328
  ]);
1339
1329
  return(/*#__PURE__*/ $g00cZ$jsx($3a48b0a92affa3e3$export$6a399b2f7f12632c, {
1330
+ treeProps: props,
1340
1331
  imperativeHandle: ref,
1341
1332
  root: root,
1342
- listEl: $g00cZ$useRef(null),
1343
- renderer: props.children,
1344
- width: props.width === undefined ? 300 : props.width,
1345
- height: props.height === undefined ? 500 : props.height,
1346
- indent: props.indent === undefined ? 24 : props.indent,
1347
- rowHeight: props.rowHeight === undefined ? 24 : props.rowHeight,
1348
- onMove: props.onMove || $0e6083160f4b36ed$export$8793edee2d425525,
1349
- onToggle: props.onToggle || $0e6083160f4b36ed$export$8793edee2d425525,
1350
- onEdit: props.onEdit || $0e6083160f4b36ed$export$8793edee2d425525,
1351
- onClick: props.onClick,
1352
- onContextMenu: props.onContextMenu,
1353
1333
  children: /*#__PURE__*/ $g00cZ$jsxs($g00cZ$DndProvider, {
1354
1334
  backend: $g00cZ$HTML5Backend,
1355
1335
  options: {
1356
1336
  rootElement: props.dndRootElement || undefined
1357
1337
  },
1358
1338
  children: [
1359
- /*#__PURE__*/ $g00cZ$jsx($2ba43033bb8eb39d$var$OuterDrop, {
1360
- children: /*#__PURE__*/ $g00cZ$jsx($2ba43033bb8eb39d$var$List, {
1339
+ /*#__PURE__*/ $g00cZ$jsx($5d6a5680e6f62734$export$a6ee728c3c6ef11d, {
1340
+ children: /*#__PURE__*/ $g00cZ$jsx($334f7345c929ac88$export$54c2e3dc7acea9f5, {
1361
1341
  className: props.className
1362
1342
  })
1363
1343
  }),