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