@elliemae/ds-treeview 2.2.0-alpha.2 → 2.2.0-beta.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/cjs/TreeView.js +31 -49
- package/cjs/TreeViewContext.js +35 -53
- package/cjs/config/cssClassesConstants.js +13 -41
- package/cjs/config/useTreeview.js +80 -108
- package/cjs/index.js +27 -37
- package/cjs/parts/CheckboxSelectable.js +59 -70
- package/cjs/parts/ChildrenCountDisplayer.js +28 -45
- package/cjs/parts/ExpandCaret.js +83 -85
- package/cjs/parts/Icon.js +31 -46
- package/cjs/parts/NestingSpace.js +35 -43
- package/cjs/parts/RadioSelectable.js +37 -52
- package/cjs/parts/TreeItem.js +147 -128
- package/cjs/parts/TreeItemText.js +95 -88
- package/cjs/parts/TreeList.js +130 -117
- package/cjs/plugins/dnd/TreeDndPlugin.js +36 -51
- package/cjs/plugins/dnd/index.js +10 -28
- package/cjs/plugins/index.js +22 -34
- package/cjs/plugins/roving/TreeRovingPlugin.js +7 -35
- package/cjs/plugins/roving/index.js +9 -28
- package/cjs/plugins/searchable/SearchableTreePlugin.js +7 -35
- package/cjs/plugins/searchable/index.js +9 -28
- package/cjs/plugins/selectable/SelectablePluginTree.js +7 -35
- package/cjs/plugins/selectable/index.js +9 -28
- package/cjs/plugins/toolbar/TreeToolbarPlugin.js +7 -35
- package/cjs/plugins/toolbar/index.js +9 -28
- package/cjs/plugins/tree/TreeDataPlugin.js +7 -35
- package/cjs/plugins/tree/index.js +9 -28
- package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js +7 -35
- package/cjs/plugins/virtualization/index.js +9 -28
- package/cjs/react-desc-prop-types.js +53 -82
- package/cjs/related-components/TreeViewSearchBar.js +40 -42
- package/cjs/sharedTypes.js +2 -27
- package/cjs/utils/array-helpers.js +11 -35
- package/cjs/utils/dnd-helpers.js +84 -90
- package/cjs/utils/group-expands-helpers.js +59 -86
- package/cjs/utils/keyboard-helpers.js +88 -84
- package/cjs/utils/object-helpers.js +36 -43
- package/cjs/utils/refs-helpers.js +22 -43
- package/cjs/utils/selectable-helper.js +53 -61
- package/cjs/utils/string-helpers.js +7 -35
- package/cjs/utils/tree-helpers.js +135 -105
- package/cjs/utils/useDnDHelpers.js +118 -97
- package/cjs/utils/useInstanceRefActions.js +43 -54
- package/cjs/utils/useTree.js +78 -76
- package/esm/TreeView.js +20 -18
- package/esm/TreeViewContext.js +29 -24
- package/esm/config/cssClassesConstants.js +6 -12
- package/esm/config/useTreeview.js +54 -61
- package/esm/index.js +9 -8
- package/esm/parts/CheckboxSelectable.js +46 -36
- package/esm/parts/ChildrenCountDisplayer.js +20 -16
- package/esm/parts/ExpandCaret.js +72 -54
- package/esm/parts/Icon.js +22 -16
- package/esm/parts/NestingSpace.js +27 -14
- package/esm/parts/RadioSelectable.js +28 -20
- package/esm/parts/TreeItem.js +127 -91
- package/esm/parts/TreeItemText.js +85 -58
- package/esm/parts/TreeList.js +117 -88
- package/esm/plugins/dnd/TreeDndPlugin.js +26 -21
- package/esm/plugins/dnd/index.js +1 -3
- package/esm/plugins/index.js +7 -9
- package/esm/plugins/roving/TreeRovingPlugin.js +3 -6
- package/esm/plugins/roving/index.js +1 -3
- package/esm/plugins/searchable/SearchableTreePlugin.js +3 -6
- package/esm/plugins/searchable/index.js +1 -3
- package/esm/plugins/selectable/SelectablePluginTree.js +3 -6
- package/esm/plugins/selectable/index.js +1 -3
- package/esm/plugins/toolbar/TreeToolbarPlugin.js +3 -6
- package/esm/plugins/toolbar/index.js +1 -3
- package/esm/plugins/tree/TreeDataPlugin.js +3 -6
- package/esm/plugins/tree/index.js +1 -3
- package/esm/plugins/virtualization/TreeVirtualizationPlugin.js +3 -6
- package/esm/plugins/virtualization/index.js +1 -3
- package/esm/react-desc-prop-types.js +43 -47
- package/esm/related-components/TreeViewSearchBar.js +32 -13
- package/esm/sharedTypes.js +1 -2
- package/esm/utils/array-helpers.js +6 -6
- package/esm/utils/dnd-helpers.js +73 -58
- package/esm/utils/group-expands-helpers.js +46 -56
- package/esm/utils/keyboard-helpers.js +72 -45
- package/esm/utils/object-helpers.js +31 -14
- package/esm/utils/refs-helpers.js +19 -15
- package/esm/utils/selectable-helper.js +43 -32
- package/esm/utils/string-helpers.js +3 -6
- package/esm/utils/tree-helpers.js +119 -74
- package/esm/utils/useDnDHelpers.js +106 -60
- package/esm/utils/useInstanceRefActions.js +35 -21
- package/esm/utils/useTree.js +57 -35
- package/package.json +10 -10
- package/types/TreeView.d.ts +1 -1
- package/cjs/TreeView.js.map +0 -7
- package/cjs/TreeViewContext.js.map +0 -7
- package/cjs/config/cssClassesConstants.js.map +0 -7
- package/cjs/config/useTreeview.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/parts/CheckboxSelectable.js.map +0 -7
- package/cjs/parts/ChildrenCountDisplayer.js.map +0 -7
- package/cjs/parts/ExpandCaret.js.map +0 -7
- package/cjs/parts/Icon.js.map +0 -7
- package/cjs/parts/NestingSpace.js.map +0 -7
- package/cjs/parts/RadioSelectable.js.map +0 -7
- package/cjs/parts/TreeItem.js.map +0 -7
- package/cjs/parts/TreeItemText.js.map +0 -7
- package/cjs/parts/TreeList.js.map +0 -7
- package/cjs/plugins/dnd/TreeDndPlugin.js.map +0 -7
- package/cjs/plugins/dnd/index.js.map +0 -7
- package/cjs/plugins/index.js.map +0 -7
- package/cjs/plugins/roving/TreeRovingPlugin.js.map +0 -7
- package/cjs/plugins/roving/index.js.map +0 -7
- package/cjs/plugins/searchable/SearchableTreePlugin.js.map +0 -7
- package/cjs/plugins/searchable/index.js.map +0 -7
- package/cjs/plugins/selectable/SelectablePluginTree.js.map +0 -7
- package/cjs/plugins/selectable/index.js.map +0 -7
- package/cjs/plugins/toolbar/TreeToolbarPlugin.js.map +0 -7
- package/cjs/plugins/toolbar/index.js.map +0 -7
- package/cjs/plugins/tree/TreeDataPlugin.js.map +0 -7
- package/cjs/plugins/tree/index.js.map +0 -7
- package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js.map +0 -7
- package/cjs/plugins/virtualization/index.js.map +0 -7
- package/cjs/react-desc-prop-types.js.map +0 -7
- package/cjs/related-components/TreeViewSearchBar.js.map +0 -7
- package/cjs/sharedTypes.js.map +0 -7
- package/cjs/utils/array-helpers.js.map +0 -7
- package/cjs/utils/dnd-helpers.js.map +0 -7
- package/cjs/utils/group-expands-helpers.js.map +0 -7
- package/cjs/utils/keyboard-helpers.js.map +0 -7
- package/cjs/utils/object-helpers.js.map +0 -7
- package/cjs/utils/refs-helpers.js.map +0 -7
- package/cjs/utils/selectable-helper.js.map +0 -7
- package/cjs/utils/string-helpers.js.map +0 -7
- package/cjs/utils/tree-helpers.js.map +0 -7
- package/cjs/utils/useDnDHelpers.js.map +0 -7
- package/cjs/utils/useInstanceRefActions.js.map +0 -7
- package/cjs/utils/useTree.js.map +0 -7
- package/esm/TreeView.js.map +0 -7
- package/esm/TreeViewContext.js.map +0 -7
- package/esm/config/cssClassesConstants.js.map +0 -7
- package/esm/config/useTreeview.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/parts/CheckboxSelectable.js.map +0 -7
- package/esm/parts/ChildrenCountDisplayer.js.map +0 -7
- package/esm/parts/ExpandCaret.js.map +0 -7
- package/esm/parts/Icon.js.map +0 -7
- package/esm/parts/NestingSpace.js.map +0 -7
- package/esm/parts/RadioSelectable.js.map +0 -7
- package/esm/parts/TreeItem.js.map +0 -7
- package/esm/parts/TreeItemText.js.map +0 -7
- package/esm/parts/TreeList.js.map +0 -7
- package/esm/plugins/dnd/TreeDndPlugin.js.map +0 -7
- package/esm/plugins/dnd/index.js.map +0 -7
- package/esm/plugins/index.js.map +0 -7
- package/esm/plugins/roving/TreeRovingPlugin.js.map +0 -7
- package/esm/plugins/roving/index.js.map +0 -7
- package/esm/plugins/searchable/SearchableTreePlugin.js.map +0 -7
- package/esm/plugins/searchable/index.js.map +0 -7
- package/esm/plugins/selectable/SelectablePluginTree.js.map +0 -7
- package/esm/plugins/selectable/index.js.map +0 -7
- package/esm/plugins/toolbar/TreeToolbarPlugin.js.map +0 -7
- package/esm/plugins/toolbar/index.js.map +0 -7
- package/esm/plugins/tree/TreeDataPlugin.js.map +0 -7
- package/esm/plugins/tree/index.js.map +0 -7
- package/esm/plugins/virtualization/TreeVirtualizationPlugin.js.map +0 -7
- package/esm/plugins/virtualization/index.js.map +0 -7
- package/esm/react-desc-prop-types.js.map +0 -7
- package/esm/related-components/TreeViewSearchBar.js.map +0 -7
- package/esm/sharedTypes.js.map +0 -7
- package/esm/utils/array-helpers.js.map +0 -7
- package/esm/utils/dnd-helpers.js.map +0 -7
- package/esm/utils/group-expands-helpers.js.map +0 -7
- package/esm/utils/keyboard-helpers.js.map +0 -7
- package/esm/utils/object-helpers.js.map +0 -7
- package/esm/utils/refs-helpers.js.map +0 -7
- package/esm/utils/selectable-helper.js.map +0 -7
- package/esm/utils/string-helpers.js.map +0 -7
- package/esm/utils/tree-helpers.js.map +0 -7
- package/esm/utils/useDnDHelpers.js.map +0 -7
- package/esm/utils/useInstanceRefActions.js.map +0 -7
- package/esm/utils/useTree.js.map +0 -7
|
@@ -1,38 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var array_helpers_exports = {};
|
|
29
|
-
__export(array_helpers_exports, {
|
|
30
|
-
arrayMove: () => arrayMove,
|
|
31
|
-
arrayMoveMutate: () => arrayMoveMutate
|
|
32
|
-
});
|
|
33
|
-
var React = __toESM(require("react"));
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
+
|
|
7
|
+
// https://github.com/sindresorhus/array-move/blob/master/index.js
|
|
34
8
|
const arrayMoveMutate = (array, from, to) => {
|
|
35
9
|
const startIndex = from < 0 ? array.length + from : from;
|
|
10
|
+
|
|
36
11
|
if (startIndex >= 0 && startIndex < array.length) {
|
|
37
12
|
const endIndex = to < 0 ? array.length + to : to;
|
|
38
13
|
const [item] = array.splice(from, 1);
|
|
@@ -44,5 +19,6 @@ const arrayMove = (array, from, to) => {
|
|
|
44
19
|
arrayMoveMutate(newArray, from, to);
|
|
45
20
|
return newArray;
|
|
46
21
|
};
|
|
47
|
-
|
|
48
|
-
|
|
22
|
+
|
|
23
|
+
exports.arrayMove = arrayMove;
|
|
24
|
+
exports.arrayMoveMutate = arrayMoveMutate;
|
package/cjs/utils/dnd-helpers.js
CHANGED
|
@@ -1,40 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var dnd_helpers_exports = {};
|
|
29
|
-
__export(dnd_helpers_exports, {
|
|
30
|
-
inferHoverItemKinshipDrop: () => inferHoverItemKinshipDrop,
|
|
31
|
-
inferKeyboardKinshipDrop: () => inferKeyboardKinshipDrop,
|
|
32
|
-
isDropValid: () => isDropValid,
|
|
33
|
-
keyCodes: () => keyCodes,
|
|
34
|
-
sameParentAsHoverItemDrop: () => sameParentAsHoverItemDrop
|
|
35
|
-
});
|
|
36
|
-
var React = __toESM(require("react"));
|
|
37
|
-
var import_tree_helpers = __toESM(require("./tree-helpers"));
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var treeHelpers = require('./tree-helpers.js');
|
|
6
|
+
|
|
7
|
+
/* eslint-disable max-lines */
|
|
38
8
|
const keyCodes = {
|
|
39
9
|
lift: [32, 13],
|
|
40
10
|
drop: [32, 13],
|
|
@@ -42,49 +12,58 @@ const keyCodes = {
|
|
|
42
12
|
up: [38, 37],
|
|
43
13
|
down: [40, 39]
|
|
44
14
|
};
|
|
45
|
-
const sameParentAsHoverItemDrop =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
15
|
+
const sameParentAsHoverItemDrop = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
isBefore,
|
|
18
|
+
isAfter,
|
|
19
|
+
draggedItem,
|
|
20
|
+
overItem,
|
|
21
|
+
movementDirection
|
|
22
|
+
} = _ref;
|
|
52
23
|
const hoveredItemNodeNestedIndex = overItem.node.getIndex();
|
|
53
|
-
let newParentNode =
|
|
54
|
-
const {
|
|
55
|
-
|
|
56
|
-
|
|
24
|
+
let newParentNode = treeHelpers.getItemsParentNode([overItem], true);
|
|
25
|
+
const {
|
|
26
|
+
treeDepth: draggedItemTreeDepth
|
|
27
|
+
} = draggedItem;
|
|
28
|
+
const {
|
|
29
|
+
treeDepth: overItemTreeDepth
|
|
30
|
+
} = overItem;
|
|
31
|
+
const directionOffset = // we don't apply the offset for direction
|
|
32
|
+
// if moving from less nested to more nested
|
|
33
|
+
// or moving bottom to top
|
|
34
|
+
// the offset is required when moving elemnts down in their nest level
|
|
35
|
+
draggedItemTreeDepth <= overItemTreeDepth && movementDirection === 'topToBottom' ? -1 : 0;
|
|
57
36
|
let newNestedIndex;
|
|
58
|
-
if (isBefore)
|
|
59
|
-
newNestedIndex =
|
|
60
|
-
|
|
61
|
-
newNestedIndex = hoveredItemNodeNestedIndex + 1 + directionOffset;
|
|
62
|
-
else {
|
|
63
|
-
newNestedIndex = overItem.children.length;
|
|
37
|
+
if (isBefore) newNestedIndex = hoveredItemNodeNestedIndex + directionOffset;else if (isAfter) newNestedIndex = hoveredItemNodeNestedIndex + 1 + directionOffset;else {
|
|
38
|
+
newNestedIndex = overItem.children.length; // append as last child of the group
|
|
39
|
+
|
|
64
40
|
newParentNode = overItem.node;
|
|
65
41
|
}
|
|
66
|
-
if (newNestedIndex < 0)
|
|
67
|
-
newNestedIndex = 0;
|
|
42
|
+
if (newNestedIndex < 0) newNestedIndex = 0;
|
|
68
43
|
return {
|
|
69
44
|
newNestedIndex,
|
|
70
45
|
newParentNode
|
|
71
46
|
};
|
|
72
47
|
};
|
|
73
|
-
const inferHoverItemKinshipDrop =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
48
|
+
const inferHoverItemKinshipDrop = _ref2 => {
|
|
49
|
+
let {
|
|
50
|
+
isBefore,
|
|
51
|
+
isAfter,
|
|
52
|
+
draggedItem,
|
|
53
|
+
overItem,
|
|
54
|
+
movementDirection
|
|
55
|
+
} = _ref2;
|
|
80
56
|
const hoverItemModel = overItem.node.model;
|
|
81
57
|
const isGroupAndIsExpanded = hoverItemModel.isExpanded && hoverItemModel.children.length > 0;
|
|
58
|
+
|
|
82
59
|
if (isAfter && isGroupAndIsExpanded) {
|
|
83
60
|
return {
|
|
84
61
|
newNestedIndex: 0,
|
|
62
|
+
// append after the group, so basically as first child
|
|
85
63
|
newParentNode: overItem.node
|
|
86
64
|
};
|
|
87
65
|
}
|
|
66
|
+
|
|
88
67
|
if (isBefore || isAfter && !isGroupAndIsExpanded) {
|
|
89
68
|
return sameParentAsHoverItemDrop({
|
|
90
69
|
isBefore,
|
|
@@ -93,54 +72,69 @@ const inferHoverItemKinshipDrop = ({
|
|
|
93
72
|
overItem,
|
|
94
73
|
movementDirection
|
|
95
74
|
});
|
|
96
|
-
}
|
|
75
|
+
} // drop inside
|
|
76
|
+
|
|
77
|
+
|
|
97
78
|
return {
|
|
98
79
|
newNestedIndex: overItem.children.length,
|
|
80
|
+
// append as last child of the group
|
|
99
81
|
newParentNode: overItem.node
|
|
100
82
|
};
|
|
101
83
|
};
|
|
102
|
-
const isDropValid =
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const {
|
|
84
|
+
const isDropValid = _ref3 => {
|
|
85
|
+
let {
|
|
86
|
+
isBefore,
|
|
87
|
+
isAfter,
|
|
88
|
+
draggedItem,
|
|
89
|
+
overItem,
|
|
90
|
+
restrictDragAndDrop
|
|
91
|
+
} = _ref3;
|
|
92
|
+
const {
|
|
93
|
+
id: movedId
|
|
94
|
+
} = draggedItem;
|
|
95
|
+
const {
|
|
96
|
+
id: hoverId
|
|
97
|
+
} = overItem;
|
|
111
98
|
const isInside = !isBefore && !isAfter;
|
|
112
|
-
if (movedId === hoverId)
|
|
113
|
-
|
|
99
|
+
if (movedId === hoverId) return false;
|
|
100
|
+
|
|
114
101
|
if (isInside && !overItem.isGroup) {
|
|
115
|
-
return false;
|
|
102
|
+
return false; // we can't drop inside an item that isn't a group
|
|
116
103
|
}
|
|
104
|
+
|
|
117
105
|
if (restrictDragAndDrop) {
|
|
118
|
-
if (isInside)
|
|
119
|
-
|
|
120
|
-
const sameParent =
|
|
121
|
-
if (overItem.node.model.isExpanded && isAfter)
|
|
122
|
-
|
|
123
|
-
if (!sameParent)
|
|
124
|
-
return false;
|
|
106
|
+
if (isInside) return false; // in this mode we can't drop inside another element
|
|
107
|
+
|
|
108
|
+
const sameParent = treeHelpers.itemsShareSameParent([draggedItem, overItem]);
|
|
109
|
+
if (overItem.node.model.isExpanded && isAfter) return false;
|
|
110
|
+
if (!sameParent) return false;
|
|
125
111
|
}
|
|
112
|
+
|
|
126
113
|
return true;
|
|
127
114
|
};
|
|
128
|
-
const inferKeyboardKinshipDrop =
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
115
|
+
const inferKeyboardKinshipDrop = _ref4 => {
|
|
116
|
+
let {
|
|
117
|
+
items,
|
|
118
|
+
newIndex
|
|
119
|
+
} = _ref4;
|
|
132
120
|
const kinship = {};
|
|
133
121
|
const itemBefore = items[newIndex];
|
|
134
122
|
const itemBeforeModel = itemBefore.node.model;
|
|
135
123
|
const isGroupAndIsExpanded = itemBeforeModel.isExpanded && itemBeforeModel.children.length > 0;
|
|
124
|
+
|
|
136
125
|
if (isGroupAndIsExpanded) {
|
|
137
126
|
kinship.newParentNode = itemBefore.node;
|
|
138
127
|
kinship.newNestedIndex = 0;
|
|
139
128
|
} else {
|
|
140
|
-
kinship.newParentNode =
|
|
129
|
+
kinship.newParentNode = treeHelpers.getItemsParentNode([itemBefore], true);
|
|
141
130
|
kinship.newNestedIndex = itemBefore.node.getIndex();
|
|
142
131
|
}
|
|
132
|
+
|
|
143
133
|
return kinship;
|
|
144
134
|
};
|
|
145
|
-
|
|
146
|
-
|
|
135
|
+
|
|
136
|
+
exports.inferHoverItemKinshipDrop = inferHoverItemKinshipDrop;
|
|
137
|
+
exports.inferKeyboardKinshipDrop = inferKeyboardKinshipDrop;
|
|
138
|
+
exports.isDropValid = isDropValid;
|
|
139
|
+
exports.keyCodes = keyCodes;
|
|
140
|
+
exports.sameParentAsHoverItemDrop = sameParentAsHoverItemDrop;
|
|
@@ -1,138 +1,111 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var group_expands_helpers_exports = {};
|
|
29
|
-
__export(group_expands_helpers_exports, {
|
|
30
|
-
collapseAll: () => collapseAll,
|
|
31
|
-
collapseItemModel: () => collapseItemModel,
|
|
32
|
-
expandAll: () => expandAll,
|
|
33
|
-
expandItemModel: () => expandItemModel,
|
|
34
|
-
getToggleExpandShouldExpand: () => getToggleExpandShouldExpand,
|
|
35
|
-
toggleExpandAllHelper: () => toggleExpandAllHelper,
|
|
36
|
-
toggleItemExpand: () => toggleItemExpand,
|
|
37
|
-
updateExpandedState: () => updateExpandedState,
|
|
38
|
-
useNotifyExpandedChange: () => useNotifyExpandedChange
|
|
39
|
-
});
|
|
40
|
-
var React = __toESM(require("react"));
|
|
41
|
-
var import_react = __toESM(require("react"));
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
/* eslint-disable max-params */
|
|
42
8
|
const updateExpandedState = (treeRoot, onExpandChange) => {
|
|
43
9
|
const shouldContinueWalking = true;
|
|
44
|
-
const newExpandedHashMap = {
|
|
45
|
-
|
|
10
|
+
const newExpandedHashMap = {
|
|
11
|
+
__ds_tree_root: true
|
|
12
|
+
};
|
|
13
|
+
treeRoot.walk(node => {
|
|
46
14
|
if (!node.isRoot() && node.model.isGroup && node.model.isExpanded) {
|
|
47
15
|
newExpandedHashMap[node.model.id] = true;
|
|
48
16
|
}
|
|
17
|
+
|
|
49
18
|
return shouldContinueWalking;
|
|
50
19
|
});
|
|
51
|
-
if (onExpandChange)
|
|
52
|
-
onExpandChange(newExpandedHashMap, null);
|
|
20
|
+
if (onExpandChange) onExpandChange(newExpandedHashMap, null);
|
|
53
21
|
};
|
|
54
|
-
const toggleItemExpand = (itemToToggle, triggerTreeRerender, updateUserExpandedState
|
|
55
|
-
|
|
22
|
+
const toggleItemExpand = function (itemToToggle, triggerTreeRerender, updateUserExpandedState) {
|
|
23
|
+
let scrollTo = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : () => {};
|
|
56
24
|
const {
|
|
57
25
|
node: {
|
|
58
|
-
model: {
|
|
26
|
+
model: {
|
|
27
|
+
isExpanded
|
|
28
|
+
}
|
|
59
29
|
},
|
|
60
30
|
virtualIndex
|
|
61
31
|
} = itemToToggle;
|
|
32
|
+
|
|
62
33
|
if (itemToToggle.node.model.isGroup) {
|
|
63
34
|
itemToToggle.node.model.isExpanded = !isExpanded;
|
|
64
35
|
triggerTreeRerender();
|
|
65
36
|
updateUserExpandedState();
|
|
66
37
|
setTimeout(() => {
|
|
67
|
-
if (typeof virtualIndex ===
|
|
68
|
-
|
|
38
|
+
if (typeof virtualIndex === 'number') scrollTo(virtualIndex, {
|
|
39
|
+
align: 'start'
|
|
40
|
+
});
|
|
69
41
|
});
|
|
70
42
|
}
|
|
71
43
|
};
|
|
72
|
-
const expandItemModel =
|
|
73
|
-
if (modelToExpand.isGroup)
|
|
74
|
-
modelToExpand.isExpanded = true;
|
|
44
|
+
const expandItemModel = modelToExpand => {
|
|
45
|
+
if (modelToExpand.isGroup) modelToExpand.isExpanded = true;
|
|
75
46
|
};
|
|
76
|
-
const collapseItemModel =
|
|
77
|
-
if (modelToCollapse.isGroup)
|
|
78
|
-
modelToCollapse.isExpanded = false;
|
|
47
|
+
const collapseItemModel = modelToCollapse => {
|
|
48
|
+
if (modelToCollapse.isGroup) modelToCollapse.isExpanded = false;
|
|
79
49
|
};
|
|
80
50
|
const expandAll = (treeRoot, triggerTreeRerender) => {
|
|
81
51
|
const shouldContinueWalking = true;
|
|
82
|
-
treeRoot.walk(
|
|
83
|
-
if (!node.isRoot())
|
|
84
|
-
expandItemModel(node.model);
|
|
52
|
+
treeRoot.walk(node => {
|
|
53
|
+
if (!node.isRoot()) expandItemModel(node.model);
|
|
85
54
|
return shouldContinueWalking;
|
|
86
55
|
});
|
|
87
56
|
triggerTreeRerender();
|
|
88
57
|
};
|
|
89
58
|
const collapseAll = (treeRoot, triggerTreeRerender) => {
|
|
90
|
-
const shouldContinueWalking = true;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
59
|
+
const shouldContinueWalking = true; // tree-model ask we return true if we want to continue walking
|
|
60
|
+
|
|
61
|
+
treeRoot.walk(node => {
|
|
62
|
+
if (!node.isRoot()) collapseItemModel(node.model);
|
|
94
63
|
return shouldContinueWalking;
|
|
95
64
|
});
|
|
96
65
|
triggerTreeRerender();
|
|
97
66
|
};
|
|
98
|
-
const getToggleExpandShouldExpand =
|
|
67
|
+
const getToggleExpandShouldExpand = treeRoot => {
|
|
99
68
|
let shouldExpand = false;
|
|
100
|
-
const shouldContinueWalking = true;
|
|
101
|
-
|
|
69
|
+
const shouldContinueWalking = true; // tree-model ask we return true if we want to continue walking
|
|
70
|
+
|
|
71
|
+
treeRoot.walk(node => {
|
|
102
72
|
if (!node.isRoot()) {
|
|
103
73
|
if (!node.model.isExpanded && node.model.isGroup) {
|
|
104
|
-
shouldExpand = true;
|
|
74
|
+
shouldExpand = true; // eslint-disable-next-line no-useless-return
|
|
75
|
+
|
|
105
76
|
return shouldContinueWalking;
|
|
106
77
|
}
|
|
107
78
|
}
|
|
79
|
+
|
|
108
80
|
return shouldContinueWalking;
|
|
109
81
|
});
|
|
110
82
|
return shouldExpand;
|
|
111
83
|
};
|
|
112
84
|
const toggleExpandAllHelper = (isExpand, treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState) => {
|
|
113
|
-
if (isExpand === true)
|
|
114
|
-
expandAll(treeRoot, triggerTreeRerender);
|
|
115
|
-
else if (isExpand === false)
|
|
116
|
-
collapseAll(treeRoot, triggerTreeRerender);
|
|
117
|
-
else {
|
|
85
|
+
if (isExpand === true) expandAll(treeRoot, triggerTreeRerender);else if (isExpand === false) collapseAll(treeRoot, triggerTreeRerender);else {
|
|
118
86
|
const shouldExpand = getToggleExpandShouldExpand(treeRoot);
|
|
119
|
-
if (shouldExpand === true)
|
|
120
|
-
expandAll(treeRoot, triggerTreeRerender);
|
|
121
|
-
else
|
|
122
|
-
collapseAll(treeRoot, triggerTreeRerender);
|
|
87
|
+
if (shouldExpand === true) expandAll(treeRoot, triggerTreeRerender);else collapseAll(treeRoot, triggerTreeRerender);
|
|
123
88
|
}
|
|
124
89
|
setLatestToggledItem(null);
|
|
125
90
|
updateUserExpandedState();
|
|
126
91
|
};
|
|
127
|
-
const useNotifyExpandedChange = (propsWithDefaults, {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
(0
|
|
133
|
-
|
|
134
|
-
|
|
92
|
+
const useNotifyExpandedChange = (propsWithDefaults, _ref) => {
|
|
93
|
+
let {
|
|
94
|
+
latestToggledItem,
|
|
95
|
+
expandedGroups
|
|
96
|
+
} = _ref;
|
|
97
|
+
const notifyExpandedChange = React.useCallback(expandedGroupHashmap => propsWithDefaults === null || propsWithDefaults === void 0 ? void 0 : propsWithDefaults.onExpandChange(expandedGroupHashmap || {}, latestToggledItem), [propsWithDefaults, latestToggledItem]);
|
|
98
|
+
React.useEffect(() => {
|
|
99
|
+
if (!propsWithDefaults.expanded) notifyExpandedChange(expandedGroups);
|
|
135
100
|
}, [expandedGroups, notifyExpandedChange, propsWithDefaults.expanded]);
|
|
136
101
|
};
|
|
137
|
-
|
|
138
|
-
|
|
102
|
+
|
|
103
|
+
exports.collapseAll = collapseAll;
|
|
104
|
+
exports.collapseItemModel = collapseItemModel;
|
|
105
|
+
exports.expandAll = expandAll;
|
|
106
|
+
exports.expandItemModel = expandItemModel;
|
|
107
|
+
exports.getToggleExpandShouldExpand = getToggleExpandShouldExpand;
|
|
108
|
+
exports.toggleExpandAllHelper = toggleExpandAllHelper;
|
|
109
|
+
exports.toggleItemExpand = toggleItemExpand;
|
|
110
|
+
exports.updateExpandedState = updateExpandedState;
|
|
111
|
+
exports.useNotifyExpandedChange = useNotifyExpandedChange;
|