react-arborist 2.0.0-rc.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -21
- package/dist/components/cursor.d.ts +1 -1
- package/dist/components/default-cursor.d.ts +2 -2
- package/dist/index.js +112 -44
- package/dist/index.js.map +1 -1
- package/dist/interfaces/node-api.d.ts +9 -4
- package/dist/interfaces/tree-api.d.ts +11 -2
- package/dist/module.js +112 -44
- package/dist/module.js.map +1 -1
- package/dist/types/renderers.d.ts +1 -1
- package/dist/types/tree-props.d.ts +4 -1
- package/dist/utils.d.ts +4 -0
- package/package.json +13 -2
- package/src/components/cursor.tsx +1 -1
- package/src/components/default-cursor.tsx +2 -2
- package/src/components/list-outer-element.tsx +2 -5
- package/src/components/row-container.tsx +1 -0
- package/src/dnd/outer-drop-hook.ts +32 -6
- package/src/interfaces/node-api.ts +15 -4
- package/src/interfaces/tree-api.ts +54 -27
- package/src/types/renderers.ts +1 -1
- package/src/types/tree-props.ts +5 -1
- package/src/utils.ts +29 -0
|
@@ -27,21 +27,26 @@ export declare class NodeApi<T extends IdObj = IdObj> {
|
|
|
27
27
|
get isLeaf(): boolean;
|
|
28
28
|
get isInternal(): boolean;
|
|
29
29
|
get isOpen(): boolean;
|
|
30
|
+
get isClosed(): boolean;
|
|
30
31
|
get isEditing(): boolean;
|
|
31
32
|
get isSelected(): boolean;
|
|
33
|
+
get isOnlySelection(): boolean;
|
|
32
34
|
get isSelectedStart(): boolean;
|
|
33
35
|
get isSelectedEnd(): boolean;
|
|
34
36
|
get isFocused(): boolean;
|
|
35
37
|
get isDragging(): boolean;
|
|
36
38
|
get willReceiveDrop(): boolean;
|
|
37
39
|
get state(): {
|
|
38
|
-
|
|
40
|
+
isClosed: boolean;
|
|
39
41
|
isDragging: boolean;
|
|
40
|
-
|
|
41
|
-
isSelectedStart: boolean;
|
|
42
|
-
isSelectedEnd: boolean;
|
|
42
|
+
isEditing: boolean;
|
|
43
43
|
isFocused: boolean;
|
|
44
|
+
isInternal: boolean;
|
|
45
|
+
isLeaf: boolean;
|
|
44
46
|
isOpen: boolean;
|
|
47
|
+
isSelected: boolean;
|
|
48
|
+
isSelectedEnd: boolean;
|
|
49
|
+
isSelectedStart: boolean;
|
|
45
50
|
willReceiveDrop: boolean;
|
|
46
51
|
};
|
|
47
52
|
get childIndex(): number;
|
|
@@ -59,7 +59,11 @@ export declare class TreeApi<T extends IdObj> {
|
|
|
59
59
|
get editingId(): string | null;
|
|
60
60
|
createInternal(): Promise<void>;
|
|
61
61
|
createLeaf(): Promise<void>;
|
|
62
|
-
|
|
62
|
+
create(opts?: {
|
|
63
|
+
type?: "internal" | "leaf";
|
|
64
|
+
parentId?: null | string;
|
|
65
|
+
index?: null | number;
|
|
66
|
+
}): Promise<void>;
|
|
63
67
|
delete(node: string | IdObj | null | string[] | IdObj[]): Promise<void>;
|
|
64
68
|
edit(node: string | IdObj): Promise<EditResult>;
|
|
65
69
|
submit(node: Identity, value: string): Promise<void>;
|
|
@@ -90,10 +94,15 @@ export declare class TreeApi<T extends IdObj> {
|
|
|
90
94
|
toggle(identity: Identity): void;
|
|
91
95
|
openParents(identity: Identity): void;
|
|
92
96
|
openSiblings(node: NodeApi<T>): void;
|
|
97
|
+
openAll(): void;
|
|
98
|
+
closeAll(): void;
|
|
93
99
|
scrollTo(identity: Identity, align?: Align): Promise<void> | undefined;
|
|
94
100
|
get isEditing(): boolean;
|
|
95
101
|
get isFiltered(): boolean;
|
|
96
102
|
get hasFocus(): boolean;
|
|
103
|
+
get hasNoSelection(): boolean;
|
|
104
|
+
get hasOneSelection(): boolean;
|
|
105
|
+
get hasMultipleSelections(): boolean;
|
|
97
106
|
isSelected(id?: string): boolean;
|
|
98
107
|
isOpen(id?: string): boolean;
|
|
99
108
|
isDraggable(data: T): boolean;
|
|
@@ -109,5 +118,5 @@ export declare class TreeApi<T extends IdObj> {
|
|
|
109
118
|
get renderRow(): import("react").ElementType<import("..").RowRendererProps<T>> | typeof DefaultRow;
|
|
110
119
|
get renderNode(): import("react").ElementType<import("..").NodeRendererProps<T>> | typeof DefaultNode;
|
|
111
120
|
get renderDragPreview(): import("react").ComponentType<import("..").DragPreviewProps> | typeof DefaultDragPreview;
|
|
112
|
-
get renderCursor(): import("react").ComponentType<import("..").
|
|
121
|
+
get renderCursor(): import("react").ComponentType<import("..").CursorProps> | import("react").NamedExoticComponent<import("..").CursorProps>;
|
|
113
122
|
}
|
package/dist/module.js
CHANGED
|
@@ -51,6 +51,7 @@ $parcel$export($0e6083160f4b36ed$exports, "isDecendent", () => $0e6083160f4b36ed
|
|
|
51
51
|
$parcel$export($0e6083160f4b36ed$exports, "indexOf", () => $0e6083160f4b36ed$export$305f7d4e9d4624f2);
|
|
52
52
|
$parcel$export($0e6083160f4b36ed$exports, "noop", () => $0e6083160f4b36ed$export$8793edee2d425525);
|
|
53
53
|
$parcel$export($0e6083160f4b36ed$exports, "dfs", () => $0e6083160f4b36ed$export$51b654aff22fc5a6);
|
|
54
|
+
$parcel$export($0e6083160f4b36ed$exports, "walk", () => $0e6083160f4b36ed$export$588732934346abbf);
|
|
54
55
|
$parcel$export($0e6083160f4b36ed$exports, "focusNextElement", () => $0e6083160f4b36ed$export$3b0237e8566c8d65);
|
|
55
56
|
$parcel$export($0e6083160f4b36ed$exports, "focusPrevElement", () => $0e6083160f4b36ed$export$33b47db07a82b2fb);
|
|
56
57
|
$parcel$export($0e6083160f4b36ed$exports, "access", () => $0e6083160f4b36ed$export$9bb0e144ba4929ca);
|
|
@@ -59,6 +60,8 @@ $parcel$export($0e6083160f4b36ed$exports, "identify", () => $0e6083160f4b36ed$ex
|
|
|
59
60
|
$parcel$export($0e6083160f4b36ed$exports, "mergeRefs", () => $0e6083160f4b36ed$export$c9058316764c140e);
|
|
60
61
|
$parcel$export($0e6083160f4b36ed$exports, "safeRun", () => $0e6083160f4b36ed$export$c6d63370cef03886);
|
|
61
62
|
$parcel$export($0e6083160f4b36ed$exports, "waitFor", () => $0e6083160f4b36ed$export$9bbfceb27f687c1b);
|
|
63
|
+
$parcel$export($0e6083160f4b36ed$exports, "getInsertIndex", () => $0e6083160f4b36ed$export$e12bf2314d0bc2a9);
|
|
64
|
+
$parcel$export($0e6083160f4b36ed$exports, "getInsertParentId", () => $0e6083160f4b36ed$export$58fe32731f07ed56);
|
|
62
65
|
function $0e6083160f4b36ed$export$adf7c0fe6059d774(n, min, max) {
|
|
63
66
|
return Math.max(Math.min(n, max), min);
|
|
64
67
|
}
|
|
@@ -90,6 +93,10 @@ function $0e6083160f4b36ed$export$51b654aff22fc5a6(node, id) {
|
|
|
90
93
|
}
|
|
91
94
|
return null;
|
|
92
95
|
}
|
|
96
|
+
function $0e6083160f4b36ed$export$588732934346abbf(node, fn) {
|
|
97
|
+
fn(node);
|
|
98
|
+
if (node.children) for (let child of node.children)$0e6083160f4b36ed$export$588732934346abbf(child, fn);
|
|
99
|
+
}
|
|
93
100
|
function $0e6083160f4b36ed$export$3b0237e8566c8d65(target) {
|
|
94
101
|
const elements = $0e6083160f4b36ed$var$getFocusable(target);
|
|
95
102
|
let next;
|
|
@@ -162,6 +169,20 @@ function $0e6083160f4b36ed$export$9bbfceb27f687c1b(fn) {
|
|
|
162
169
|
check();
|
|
163
170
|
});
|
|
164
171
|
}
|
|
172
|
+
function $0e6083160f4b36ed$export$e12bf2314d0bc2a9(tree) {
|
|
173
|
+
const focus = tree.focusedNode;
|
|
174
|
+
if (!focus) return tree.root.children?.length ?? 0;
|
|
175
|
+
if (focus.isOpen) return 0;
|
|
176
|
+
if (focus.parent) return focus.childIndex + 1;
|
|
177
|
+
return 0;
|
|
178
|
+
}
|
|
179
|
+
function $0e6083160f4b36ed$export$58fe32731f07ed56(tree) {
|
|
180
|
+
const focus = tree.focusedNode;
|
|
181
|
+
if (!focus) return null;
|
|
182
|
+
if (focus.isOpen) return focus.id;
|
|
183
|
+
if (focus.parent) return focus.parent.id;
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
165
186
|
|
|
166
187
|
|
|
167
188
|
|
|
@@ -347,12 +368,18 @@ class $096e74084443e9a3$export$d4b903da0f522dc8 {
|
|
|
347
368
|
get isOpen() {
|
|
348
369
|
return this.isLeaf ? false : this.tree.isOpen(this.id);
|
|
349
370
|
}
|
|
371
|
+
get isClosed() {
|
|
372
|
+
return this.isLeaf ? false : !this.tree.isOpen(this.id);
|
|
373
|
+
}
|
|
350
374
|
get isEditing() {
|
|
351
375
|
return this.tree.editingId === this.id;
|
|
352
376
|
}
|
|
353
377
|
get isSelected() {
|
|
354
378
|
return this.tree.isSelected(this.id);
|
|
355
379
|
}
|
|
380
|
+
get isOnlySelection() {
|
|
381
|
+
return this.isSelected && this.tree.hasOneSelection;
|
|
382
|
+
}
|
|
356
383
|
get isSelectedStart() {
|
|
357
384
|
return this.isSelected && !this.prev?.isSelected;
|
|
358
385
|
}
|
|
@@ -370,13 +397,16 @@ class $096e74084443e9a3$export$d4b903da0f522dc8 {
|
|
|
370
397
|
}
|
|
371
398
|
get state() {
|
|
372
399
|
return {
|
|
373
|
-
|
|
400
|
+
isClosed: this.isClosed,
|
|
374
401
|
isDragging: this.isDragging,
|
|
375
|
-
|
|
376
|
-
isSelectedStart: this.isSelectedStart,
|
|
377
|
-
isSelectedEnd: this.isSelectedEnd,
|
|
402
|
+
isEditing: this.isEditing,
|
|
378
403
|
isFocused: this.isFocused,
|
|
404
|
+
isInternal: this.isInternal,
|
|
405
|
+
isLeaf: this.isLeaf,
|
|
379
406
|
isOpen: this.isOpen,
|
|
407
|
+
isSelected: this.isSelected,
|
|
408
|
+
isSelectedEnd: this.isSelectedEnd,
|
|
409
|
+
isSelectedStart: this.isSelectedStart,
|
|
380
410
|
willReceiveDrop: this.willReceiveDrop
|
|
381
411
|
};
|
|
382
412
|
}
|
|
@@ -812,7 +842,7 @@ const $77d34d95e44d2f58$var$PreviewNode = /*#__PURE__*/ (0, $g00cZ$memo)(functio
|
|
|
812
842
|
|
|
813
843
|
|
|
814
844
|
|
|
815
|
-
function $f608be224a71d6f5$export$
|
|
845
|
+
function $f608be224a71d6f5$export$b6a79797ad180576() {
|
|
816
846
|
const tree = (0, $89e93131aae74bd9$export$367b0f2231a90ba0)();
|
|
817
847
|
const state = (0, $89e93131aae74bd9$export$4930f6bf413be70e)();
|
|
818
848
|
const cursor = state.cursor;
|
|
@@ -855,10 +885,7 @@ const $05f64c7ebcbad8b5$var$DropContainer = ()=>{
|
|
|
855
885
|
left: "0",
|
|
856
886
|
right: "0"
|
|
857
887
|
},
|
|
858
|
-
|
|
859
|
-
console.log(e.currentTarget, e.target);
|
|
860
|
-
},
|
|
861
|
-
children: /*#__PURE__*/ (0, $g00cZ$jsx)((0, $f608be224a71d6f5$export$ef961593063b03e8), {})
|
|
888
|
+
children: /*#__PURE__*/ (0, $g00cZ$jsx)((0, $f608be224a71d6f5$export$b6a79797ad180576), {})
|
|
862
889
|
});
|
|
863
890
|
};
|
|
864
891
|
|
|
@@ -1207,7 +1234,8 @@ const $8c3aed0a01f84486$export$a9754b3c8daa5172 = /*#__PURE__*/ (0, $g00cZ$react
|
|
|
1207
1234
|
"aria-level": node.level,
|
|
1208
1235
|
"aria-selected": node.isSelected,
|
|
1209
1236
|
style: rowStyle,
|
|
1210
|
-
tabIndex: -1
|
|
1237
|
+
tabIndex: -1,
|
|
1238
|
+
className: tree.props.rowClassName
|
|
1211
1239
|
};
|
|
1212
1240
|
(0, $g00cZ$useEffect)(()=>{
|
|
1213
1241
|
if (!node.isEditing && node.isFocused) el.current?.focus();
|
|
@@ -1509,16 +1537,16 @@ class $bfece7c4aed4e9c4$export$e2da3477247342d1 {
|
|
|
1509
1537
|
return this.state.nodes.open.unfiltered;
|
|
1510
1538
|
}
|
|
1511
1539
|
/* Tree Props */ get width() {
|
|
1512
|
-
return this.props.width
|
|
1540
|
+
return this.props.width ?? 300;
|
|
1513
1541
|
}
|
|
1514
1542
|
get height() {
|
|
1515
|
-
return this.props.height
|
|
1543
|
+
return this.props.height ?? 500;
|
|
1516
1544
|
}
|
|
1517
1545
|
get indent() {
|
|
1518
|
-
return this.props.indent
|
|
1546
|
+
return this.props.indent ?? 24;
|
|
1519
1547
|
}
|
|
1520
1548
|
get rowHeight() {
|
|
1521
|
-
return this.props.rowHeight
|
|
1549
|
+
return this.props.rowHeight ?? 24;
|
|
1522
1550
|
}
|
|
1523
1551
|
get searchTerm() {
|
|
1524
1552
|
return (this.props.searchTerm || "").trim();
|
|
@@ -1588,31 +1616,20 @@ class $bfece7c4aed4e9c4$export$e2da3477247342d1 {
|
|
|
1588
1616
|
return this.state.nodes.edit.id;
|
|
1589
1617
|
}
|
|
1590
1618
|
createInternal() {
|
|
1591
|
-
return this.create(
|
|
1619
|
+
return this.create({
|
|
1620
|
+
type: "internal"
|
|
1621
|
+
});
|
|
1592
1622
|
}
|
|
1593
1623
|
createLeaf() {
|
|
1594
|
-
return this.create(
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
const focus = this.focusedNode;
|
|
1600
|
-
if (focus && focus.parent) {
|
|
1601
|
-
if (focus.isInternal && focus.isOpen) {
|
|
1602
|
-
parentId = focus.id;
|
|
1603
|
-
index = 0;
|
|
1604
|
-
} else {
|
|
1605
|
-
index = focus.childIndex + 1;
|
|
1606
|
-
parentId = focus.parent.isRoot ? null : focus.parent.id;
|
|
1607
|
-
}
|
|
1608
|
-
} else {
|
|
1609
|
-
index = this.root?.children?.length || -1;
|
|
1610
|
-
parentId = null;
|
|
1611
|
-
}
|
|
1624
|
+
return this.create({
|
|
1625
|
+
type: "leaf"
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
async create(opts = {}) {
|
|
1612
1629
|
const data = await $bfece7c4aed4e9c4$var$safeRun(this.props.onCreate, {
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1630
|
+
type: opts.type ?? "leaf",
|
|
1631
|
+
parentId: opts.parentId === undefined ? $0e6083160f4b36ed$exports.getInsertParentId(this) : opts.parentId,
|
|
1632
|
+
index: opts.index ?? $0e6083160f4b36ed$exports.getInsertIndex(this)
|
|
1616
1633
|
});
|
|
1617
1634
|
if (data) {
|
|
1618
1635
|
this.focus(data);
|
|
@@ -1695,6 +1712,7 @@ class $bfece7c4aed4e9c4$export$e2da3477247342d1 {
|
|
|
1695
1712
|
else {
|
|
1696
1713
|
this.dispatch((0, $c27b8e9863235052$export$d7ddd398f22d79ef)($bfece7c4aed4e9c4$var$identify(node)));
|
|
1697
1714
|
if (opts.scroll !== false) this.scrollTo(node);
|
|
1715
|
+
if (this.focusedNode) $bfece7c4aed4e9c4$var$safeRun(this.props.onFocus, this.focusedNode);
|
|
1698
1716
|
}
|
|
1699
1717
|
}
|
|
1700
1718
|
pageUp() {
|
|
@@ -1723,6 +1741,7 @@ class $bfece7c4aed4e9c4$export$e2da3477247342d1 {
|
|
|
1723
1741
|
this.dispatch((0, $37bc167debff36d2$export$e324594224ef24da).anchor(id));
|
|
1724
1742
|
this.dispatch((0, $37bc167debff36d2$export$e324594224ef24da).mostRecent(id));
|
|
1725
1743
|
this.scrollTo(id, opts.align);
|
|
1744
|
+
if (this.focusedNode) $bfece7c4aed4e9c4$var$safeRun(this.props.onFocus, this.focusedNode);
|
|
1726
1745
|
$bfece7c4aed4e9c4$var$safeRun(this.props.onSelect, this.selectedNodes);
|
|
1727
1746
|
}
|
|
1728
1747
|
deselect(node) {
|
|
@@ -1738,6 +1757,7 @@ class $bfece7c4aed4e9c4$export$e2da3477247342d1 {
|
|
|
1738
1757
|
this.dispatch((0, $37bc167debff36d2$export$e324594224ef24da).anchor(node.id));
|
|
1739
1758
|
this.dispatch((0, $37bc167debff36d2$export$e324594224ef24da).mostRecent(node.id));
|
|
1740
1759
|
this.scrollTo(node);
|
|
1760
|
+
if (this.focusedNode) $bfece7c4aed4e9c4$var$safeRun(this.props.onFocus, this.focusedNode);
|
|
1741
1761
|
$bfece7c4aed4e9c4$var$safeRun(this.props.onSelect, this.selectedNodes);
|
|
1742
1762
|
}
|
|
1743
1763
|
selectContiguous(identity) {
|
|
@@ -1749,6 +1769,7 @@ class $bfece7c4aed4e9c4$export$e2da3477247342d1 {
|
|
|
1749
1769
|
this.dispatch((0, $37bc167debff36d2$export$e324594224ef24da).add(this.nodesBetween(anchor, $bfece7c4aed4e9c4$var$identifyNull(id))));
|
|
1750
1770
|
this.dispatch((0, $37bc167debff36d2$export$e324594224ef24da).mostRecent(id));
|
|
1751
1771
|
this.scrollTo(id);
|
|
1772
|
+
if (this.focusedNode) $bfece7c4aed4e9c4$var$safeRun(this.props.onFocus, this.focusedNode);
|
|
1752
1773
|
$bfece7c4aed4e9c4$var$safeRun(this.props.onSelect, this.selectedNodes);
|
|
1753
1774
|
}
|
|
1754
1775
|
deselectAll() {
|
|
@@ -1762,6 +1783,7 @@ class $bfece7c4aed4e9c4$export$e2da3477247342d1 {
|
|
|
1762
1783
|
this.dispatch((0, $c27b8e9863235052$export$d7ddd398f22d79ef)(this.lastNode?.id));
|
|
1763
1784
|
this.dispatch((0, $37bc167debff36d2$export$e324594224ef24da).anchor(this.firstNode));
|
|
1764
1785
|
this.dispatch((0, $37bc167debff36d2$export$e324594224ef24da).mostRecent(this.lastNode));
|
|
1786
|
+
if (this.focusedNode) $bfece7c4aed4e9c4$var$safeRun(this.props.onFocus, this.focusedNode);
|
|
1765
1787
|
$bfece7c4aed4e9c4$var$safeRun(this.props.onSelect, this.selectedNodes);
|
|
1766
1788
|
}
|
|
1767
1789
|
/* Drag and Drop */ get cursorParentId() {
|
|
@@ -1787,12 +1809,16 @@ class $bfece7c4aed4e9c4$export$e2da3477247342d1 {
|
|
|
1787
1809
|
/* Visibility */ open(identity) {
|
|
1788
1810
|
const id = $bfece7c4aed4e9c4$var$identifyNull(identity);
|
|
1789
1811
|
if (!id) return;
|
|
1812
|
+
if (this.isOpen(id)) return;
|
|
1790
1813
|
this.dispatch((0, $3c0bad2888bcd4bc$export$e324594224ef24da).open(id, this.isFiltered));
|
|
1814
|
+
$bfece7c4aed4e9c4$var$safeRun(this.props.onToggle, id);
|
|
1791
1815
|
}
|
|
1792
1816
|
close(identity) {
|
|
1793
1817
|
const id = $bfece7c4aed4e9c4$var$identifyNull(identity);
|
|
1794
1818
|
if (!id) return;
|
|
1819
|
+
if (!this.isOpen(id)) return;
|
|
1795
1820
|
this.dispatch((0, $3c0bad2888bcd4bc$export$e324594224ef24da).close(id, this.isFiltered));
|
|
1821
|
+
$bfece7c4aed4e9c4$var$safeRun(this.props.onToggle, id);
|
|
1796
1822
|
}
|
|
1797
1823
|
toggle(identity) {
|
|
1798
1824
|
const id = $bfece7c4aed4e9c4$var$identifyNull(identity);
|
|
@@ -1818,6 +1844,16 @@ class $bfece7c4aed4e9c4$export$e2da3477247342d1 {
|
|
|
1818
1844
|
this.scrollTo(this.focusedNode);
|
|
1819
1845
|
}
|
|
1820
1846
|
}
|
|
1847
|
+
openAll() {
|
|
1848
|
+
$0e6083160f4b36ed$exports.walk(this.root, (node)=>{
|
|
1849
|
+
if (node.isInternal) node.open();
|
|
1850
|
+
});
|
|
1851
|
+
}
|
|
1852
|
+
closeAll() {
|
|
1853
|
+
$0e6083160f4b36ed$exports.walk(this.root, (node)=>{
|
|
1854
|
+
if (node.isInternal) node.close();
|
|
1855
|
+
});
|
|
1856
|
+
}
|
|
1821
1857
|
/* Scrolling */ scrollTo(identity, align = "smart") {
|
|
1822
1858
|
if (!identity) return;
|
|
1823
1859
|
const id = $bfece7c4aed4e9c4$var$identify(identity);
|
|
@@ -1839,6 +1875,15 @@ class $bfece7c4aed4e9c4$export$e2da3477247342d1 {
|
|
|
1839
1875
|
get hasFocus() {
|
|
1840
1876
|
return this.state.nodes.focus.treeFocused;
|
|
1841
1877
|
}
|
|
1878
|
+
get hasNoSelection() {
|
|
1879
|
+
return this.state.nodes.selection.ids.size === 0;
|
|
1880
|
+
}
|
|
1881
|
+
get hasOneSelection() {
|
|
1882
|
+
return this.state.nodes.selection.ids.size === 1;
|
|
1883
|
+
}
|
|
1884
|
+
get hasMultipleSelections() {
|
|
1885
|
+
return this.state.nodes.selection.ids.size > 1;
|
|
1886
|
+
}
|
|
1842
1887
|
isSelected(id) {
|
|
1843
1888
|
if (!id) return false;
|
|
1844
1889
|
return this.state.nodes.selection.ids.has(id);
|
|
@@ -2012,6 +2057,7 @@ function $dac24389e46ba09d$export$c49dab5eb1b4ce0c({ treeProps: treeProps , impe
|
|
|
2012
2057
|
|
|
2013
2058
|
|
|
2014
2059
|
|
|
2060
|
+
|
|
2015
2061
|
function $e739455e59c6aed3$export$5a6c424b1725f44f() {
|
|
2016
2062
|
const tree = (0, $89e93131aae74bd9$export$367b0f2231a90ba0)();
|
|
2017
2063
|
// In case we drop an item at the bottom of the list
|
|
@@ -2021,9 +2067,28 @@ function $e739455e59c6aed3$export$5a6c424b1725f44f() {
|
|
|
2021
2067
|
if (!m.isOver({
|
|
2022
2068
|
shallow: true
|
|
2023
2069
|
})) return;
|
|
2070
|
+
if (m.canDrop()) {
|
|
2071
|
+
const offset = m.getClientOffset();
|
|
2072
|
+
if (!tree.listEl.current || !offset) return;
|
|
2073
|
+
const { cursor: cursor } = (0, $2db980bfed6822da$export$f502ca02ebb85a1c)({
|
|
2074
|
+
element: tree.listEl.current,
|
|
2075
|
+
offset: offset,
|
|
2076
|
+
indent: tree.indent,
|
|
2077
|
+
node: null,
|
|
2078
|
+
prevNode: tree.visibleNodes[tree.visibleNodes.length - 1],
|
|
2079
|
+
nextNode: null
|
|
2080
|
+
});
|
|
2081
|
+
if (cursor) tree.showCursor(cursor);
|
|
2082
|
+
} else tree.hideCursor();
|
|
2083
|
+
},
|
|
2084
|
+
canDrop: (item, m)=>{
|
|
2085
|
+
if (!m.isOver({
|
|
2086
|
+
shallow: true
|
|
2087
|
+
})) return false;
|
|
2088
|
+
if (tree.isFiltered) return false;
|
|
2024
2089
|
const offset = m.getClientOffset();
|
|
2025
|
-
if (!tree.listEl.current || !offset) return;
|
|
2026
|
-
const {
|
|
2090
|
+
if (!tree.listEl.current || !offset) return false;
|
|
2091
|
+
const { drop: drop } = (0, $2db980bfed6822da$export$f502ca02ebb85a1c)({
|
|
2027
2092
|
element: tree.listEl.current,
|
|
2028
2093
|
offset: offset,
|
|
2029
2094
|
indent: tree.indent,
|
|
@@ -2031,12 +2096,15 @@ function $e739455e59c6aed3$export$5a6c424b1725f44f() {
|
|
|
2031
2096
|
prevNode: tree.visibleNodes[tree.visibleNodes.length - 1],
|
|
2032
2097
|
nextNode: null
|
|
2033
2098
|
});
|
|
2034
|
-
if (
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2099
|
+
if (!drop) return false;
|
|
2100
|
+
const dropParent = tree.get(drop.parentId) ?? tree.root;
|
|
2101
|
+
for (let id of item.dragIds){
|
|
2102
|
+
const drag = tree.get(id);
|
|
2103
|
+
if (!drag) return false;
|
|
2104
|
+
if (!dropParent) return false;
|
|
2105
|
+
if (drag.isInternal && (0, $0e6083160f4b36ed$export$1e38f72c6c546f70)(dropParent, drag)) return false;
|
|
2106
|
+
}
|
|
2107
|
+
return true;
|
|
2040
2108
|
},
|
|
2041
2109
|
drop: (item, m)=>{
|
|
2042
2110
|
if (m.didDrop()) return;
|