@elliemae/ds-treeview 2.2.0-alpha.2 → 2.2.0-next.1
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 +27 -49
- package/cjs/TreeViewContext.js +37 -61
- package/cjs/config/cssClassesConstants.js +13 -41
- package/cjs/config/useTreeview.js +78 -116
- package/cjs/hoc/DnDTreeContext.js +18 -0
- package/cjs/hoc/SortableItemContext.js +21 -0
- package/cjs/hoc/WithConditionalDnDContext.js +138 -0
- package/cjs/hoc/WithDnDSortableItemContext.js +70 -0
- package/cjs/index.js +26 -37
- package/cjs/parts/CheckboxSelectable.js +59 -70
- package/cjs/parts/ChildrenCountDisplayer.js +28 -45
- package/cjs/parts/DnDHandle.js +46 -0
- package/cjs/parts/DropIndicator.js +75 -0
- 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 +141 -147
- package/cjs/parts/TreeItemText.js +95 -88
- package/cjs/parts/TreeList.js +130 -119
- package/cjs/plugins/dnd/TreeDndPlugin.js +7 -59
- package/cjs/plugins/dnd/index.js +9 -28
- package/cjs/plugins/index.js +21 -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 +54 -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/group-expands-helpers.js +59 -86
- package/cjs/utils/keyboard-helpers.js +90 -85
- 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 +161 -105
- package/cjs/utils/useInstanceRefActions.js +43 -54
- package/cjs/utils/useTree.js +80 -76
- package/esm/TreeView.js +16 -18
- package/esm/TreeViewContext.js +31 -32
- package/esm/config/cssClassesConstants.js +6 -12
- package/esm/config/useTreeview.js +56 -73
- package/esm/hoc/DnDTreeContext.js +14 -0
- package/esm/hoc/SortableItemContext.js +17 -0
- package/esm/hoc/WithConditionalDnDContext.js +128 -0
- package/esm/hoc/WithDnDSortableItemContext.js +61 -0
- package/esm/index.js +9 -8
- package/esm/parts/CheckboxSelectable.js +46 -36
- package/esm/parts/ChildrenCountDisplayer.js +20 -16
- package/esm/parts/DnDHandle.js +38 -0
- package/esm/parts/DropIndicator.js +68 -0
- 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 +125 -114
- package/esm/parts/TreeItemText.js +85 -58
- package/esm/parts/TreeList.js +119 -91
- package/esm/plugins/dnd/TreeDndPlugin.js +3 -30
- 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 +44 -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/group-expands-helpers.js +46 -56
- package/esm/utils/keyboard-helpers.js +74 -46
- 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 +143 -73
- package/esm/utils/useInstanceRefActions.js +35 -21
- package/esm/utils/useTree.js +59 -35
- package/package.json +35 -19
- package/types/hoc/DnDTreeContext.d.ts +14 -0
- package/types/hoc/SortableItemContext.d.ts +19 -0
- package/types/hoc/WithConditionalDnDContext.d.ts +4 -0
- package/types/hoc/WithDnDSortableItemContext.d.ts +4 -0
- package/types/parts/DnDHandle.d.ts +6 -0
- package/types/parts/DropIndicator.d.ts +10 -0
- package/types/parts/TreeItem.d.ts +4 -11
- package/types/parts/TreeList.d.ts +0 -4
- package/types/plugins/dnd/TreeDndPlugin.d.ts +0 -2
- package/types/react-desc-prop-types.d.ts +17 -3
- package/types/sharedTypes.d.ts +1 -8
- package/types/utils/keyboard-helpers.d.ts +2 -1
- package/types/utils/refs-helpers.d.ts +1 -1
- package/types/utils/tree-helpers.d.ts +4 -1
- package/types/utils/useTree.d.ts +1 -0
- 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 +0 -146
- 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 +0 -199
- 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 +0 -117
- 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 +0 -170
- package/esm/utils/useDnDHelpers.js.map +0 -7
- package/esm/utils/useInstanceRefActions.js.map +0 -7
- package/esm/utils/useTree.js.map +0 -7
- package/types/utils/dnd-helpers.d.ts +0 -39
- package/types/utils/useDnDHelpers.d.ts +0 -26
|
@@ -1,135 +1,205 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.find.js';
|
|
7
|
+
import 'core-js/modules/esnext.async-iterator.every.js';
|
|
8
|
+
import 'core-js/modules/esnext.iterator.every.js';
|
|
9
|
+
import { createRef } from 'react';
|
|
10
|
+
import { standardizeSearchQueryString } from './string-helpers.js';
|
|
11
|
+
|
|
12
|
+
const walkVisibles = function (node, callback) {
|
|
13
|
+
let skipRoot = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
14
|
+
let highlightOnlyQuery = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
15
|
+
const {
|
|
16
|
+
children,
|
|
17
|
+
model
|
|
18
|
+
} = node;
|
|
19
|
+
const {
|
|
20
|
+
name,
|
|
21
|
+
isExpanded,
|
|
22
|
+
childrenMatchesSearchQuery,
|
|
23
|
+
matchesSearchQuery
|
|
24
|
+
} = model;
|
|
25
|
+
const shouldSkipBecauseIsRoot = skipRoot && name === '__root';
|
|
8
26
|
const queryRestrictionsPassed = !!(highlightOnlyQuery || childrenMatchesSearchQuery || matchesSearchQuery);
|
|
9
|
-
if (!shouldSkipBecauseIsRoot && queryRestrictionsPassed)
|
|
10
|
-
callback(node);
|
|
27
|
+
if (!shouldSkipBecauseIsRoot && queryRestrictionsPassed) callback(node);
|
|
11
28
|
const shouldWalkChildren = !!(children.length > 0 && isExpanded && queryRestrictionsPassed);
|
|
29
|
+
|
|
12
30
|
if (shouldWalkChildren) {
|
|
13
|
-
children.forEach(
|
|
31
|
+
children.forEach(childNode => {
|
|
14
32
|
walkVisibles(childNode, callback, skipRoot, highlightOnlyQuery);
|
|
15
33
|
});
|
|
16
34
|
}
|
|
17
35
|
};
|
|
18
|
-
const walkParents = (nodePath, callback
|
|
36
|
+
const walkParents = function (nodePath, callback) {
|
|
37
|
+
let skipRoot = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
19
38
|
const parents = [...nodePath].reverse();
|
|
20
|
-
parents.shift();
|
|
21
|
-
|
|
22
|
-
|
|
39
|
+
parents.shift(); // remove current node from the parents array
|
|
40
|
+
|
|
41
|
+
if (skipRoot) parents.pop(); // remove the root from the parents if skipping root
|
|
42
|
+
|
|
23
43
|
parents.forEach(callback);
|
|
24
44
|
};
|
|
25
|
-
const walkAllNodeChildren = (node, callback
|
|
26
|
-
|
|
45
|
+
const walkAllNodeChildren = function (node, callback) {
|
|
46
|
+
let isFirst = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
47
|
+
const {
|
|
48
|
+
children = []
|
|
49
|
+
} = node;
|
|
27
50
|
const shouldWalkChildren = children.length;
|
|
28
|
-
if (!isFirst)
|
|
29
|
-
|
|
51
|
+
if (!isFirst) callback(node);
|
|
52
|
+
|
|
30
53
|
if (shouldWalkChildren) {
|
|
31
|
-
children.forEach(
|
|
54
|
+
children.forEach(childNode => {
|
|
32
55
|
walkAllNodeChildren(childNode, callback, false);
|
|
33
56
|
});
|
|
34
57
|
}
|
|
35
58
|
};
|
|
36
59
|
const getNodeById = (treeRoot, id) => {
|
|
37
|
-
const nodes = treeRoot.all(
|
|
60
|
+
const nodes = treeRoot.all(node => node.model.id === id);
|
|
38
61
|
return nodes[0];
|
|
39
62
|
};
|
|
40
63
|
const cloneNode = (tree, node) => tree.parse(node.model);
|
|
41
|
-
const itemsShareSameParent = (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (items.length === 1)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const firstExistingItemPath = firstExistingItem.node.getPath();
|
|
64
|
+
const itemsShareSameParent = function () {
|
|
65
|
+
let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
66
|
+
if (items.length === 0) throw new Error('Received empty items for comparison');
|
|
67
|
+
if (items.length === 1) return true; // when moving in first position we receive [undefined,...{items}]
|
|
68
|
+
// when moving in last position we receive [...{items}, undefined]
|
|
69
|
+
|
|
70
|
+
const firstExistingItem = items.find(item => !!item);
|
|
71
|
+
if (!firstExistingItem) throw new Error("Received no items, can't retrieve parent");
|
|
72
|
+
const firstExistingItemPath = firstExistingItem.node.getPath(); // path is like [rootParent, ...[parentsNodes], currentNode]
|
|
73
|
+
// length -1 is the current-node
|
|
74
|
+
// length -2 is the parent-node
|
|
75
|
+
// root node is not printed and is always present so minimum path length is 2 (root + currentNode)
|
|
76
|
+
|
|
50
77
|
const directParentNode = firstExistingItemPath[firstExistingItemPath.length - 2];
|
|
51
|
-
return items.every(
|
|
52
|
-
|
|
53
|
-
|
|
78
|
+
return items.every(item => {
|
|
79
|
+
// undefined nodes count as having the same parent
|
|
80
|
+
if (!item) return true;
|
|
54
81
|
const itemPath = item.node.getPath();
|
|
55
82
|
const itemDirectParent = itemPath[itemPath.length - 2];
|
|
56
83
|
return directParentNode === itemDirectParent;
|
|
57
84
|
});
|
|
58
85
|
};
|
|
59
|
-
const getItemsParentNode = (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
86
|
+
const getItemsParentNode = function () {
|
|
87
|
+
let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
88
|
+
let skipSameParentCheck = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
89
|
+
if (items.length === 0) throw new Error("Received empty items, can't retrieve parent"); // in case we already know the items compared shares the same parent
|
|
90
|
+
|
|
91
|
+
if (!skipSameParentCheck) if (!itemsShareSameParent(items)) // if we don't know (default, we don't) check if they share the parent
|
|
92
|
+
throw new Error("Received items don't share the same parent, can't retrieve parent"); // when moving in first position we receive [undefined,...{items}]
|
|
93
|
+
// when moving in last position we receive [...{items}, undefined]
|
|
94
|
+
|
|
95
|
+
const firstExistingItem = items.find(item => !!item);
|
|
96
|
+
if (!firstExistingItem) throw new Error("Received no items, can't retrieve parent");
|
|
97
|
+
const firstExistingItemPath = firstExistingItem.node.getPath(); // path is like [rootParent, ...[parentsNodes], currentNode]
|
|
98
|
+
// length -1 is the current-node
|
|
99
|
+
// length -2 is the parent-node
|
|
100
|
+
// root node is not printed and is always present so minimum path length is 2 (root + currentNode)
|
|
101
|
+
|
|
70
102
|
const directParentNode = firstExistingItemPath[firstExistingItemPath.length - 2];
|
|
71
103
|
return directParentNode;
|
|
72
104
|
};
|
|
73
|
-
const getNodeMatchesSearchQuery = (node
|
|
105
|
+
const getNodeMatchesSearchQuery = function (node) {
|
|
106
|
+
let searchQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
74
107
|
const standardizedName = standardizeSearchQueryString(node.model.name);
|
|
75
108
|
const standardizedSearchQuery = standardizeSearchQueryString(searchQuery);
|
|
76
109
|
return standardizedName.includes(standardizedSearchQuery);
|
|
77
110
|
};
|
|
78
|
-
const getChildrenMatchesSearchQuery = (parentNode
|
|
111
|
+
const getChildrenMatchesSearchQuery = function (parentNode) {
|
|
112
|
+
let searchQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
79
113
|
let anyChildMatch = false;
|
|
80
|
-
walkAllNodeChildren(parentNode,
|
|
81
|
-
if (getNodeMatchesSearchQuery(node, searchQuery))
|
|
82
|
-
anyChildMatch = true;
|
|
114
|
+
walkAllNodeChildren(parentNode, node => {
|
|
115
|
+
if (getNodeMatchesSearchQuery(node, searchQuery)) anyChildMatch = true;
|
|
83
116
|
});
|
|
84
117
|
return anyChildMatch;
|
|
85
118
|
};
|
|
86
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Mutate in place a node from tree-model normalizing object properties like "isGroup" even if user didn't specify it explicitly,
|
|
121
|
+
* after execution the node will have "nodePath" "treeDepth" "nodeItemRef" "isGroup" "isExpanded"
|
|
122
|
+
* (optionally, based on the provided arguments) "matchesSearchQuery" "childrenMatchesSearchQuery" "isChecked"
|
|
123
|
+
*
|
|
124
|
+
* @param {Object} node - node (based on 'tree-model' lib) that you wish to mutate with extra props
|
|
125
|
+
* @param {string} [searchQuery=''] - optional string used to parse "matchesSearchQuery"/"childrenMatchesSearchQuery" properties
|
|
126
|
+
* @param {Object} [selection=null] - optional selection hashmap used to parse "isChecked" properties
|
|
127
|
+
* @param {Object} [expanded=null] - optional expanded hashmap used to parse "isExpanded" properties
|
|
128
|
+
*/
|
|
129
|
+
|
|
130
|
+
const enrichNodeModelInPlace = function (node) {
|
|
131
|
+
var _node$model$children$, _node$model, _node$model$children;
|
|
132
|
+
|
|
133
|
+
let searchQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
134
|
+
let selection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
135
|
+
let expanded = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
87
136
|
const path = node.getPath();
|
|
88
137
|
const depth = path.length - 1;
|
|
89
138
|
node.model.nodePath = path;
|
|
90
139
|
node.model.treeDepth = depth;
|
|
140
|
+
|
|
91
141
|
if (!node.model.nodeItemRef) {
|
|
92
|
-
node.model.nodeItemRef = createRef();
|
|
93
|
-
}
|
|
94
|
-
|
|
142
|
+
node.model.nodeItemRef = /*#__PURE__*/createRef();
|
|
143
|
+
} // if a node has children but was not marked as isGroup, force-mark as group
|
|
144
|
+
// this is useful to avoid having to always check both the flag and the children.length...
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
if (typeof node.model.isGroup !== 'boolean' && ((_node$model$children$ = (_node$model = node.model) === null || _node$model === void 0 ? void 0 : (_node$model$children = _node$model.children) === null || _node$model$children === void 0 ? void 0 : _node$model$children.length) !== null && _node$model$children$ !== void 0 ? _node$model$children$ : 0) > 0) {
|
|
95
148
|
node.model.isGroup = true;
|
|
96
149
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
else if (typeof node.model.isExpanded !== "boolean") {
|
|
150
|
+
|
|
151
|
+
if (node.model.isGroup && node.model.id !== '__ds_tree_root') {
|
|
152
|
+
if (expanded) node.model.isExpanded = !!expanded[node.model.id];else if (typeof node.model.isExpanded !== 'boolean') {
|
|
101
153
|
node.model.isExpanded = false;
|
|
102
154
|
}
|
|
103
155
|
}
|
|
156
|
+
|
|
104
157
|
node.model.matchesSearchQuery = true;
|
|
105
158
|
node.model.childrenMatchesSearchQuery = false;
|
|
106
159
|
const partiallyEnrichedNode = node;
|
|
160
|
+
|
|
107
161
|
if (searchQuery) {
|
|
108
162
|
partiallyEnrichedNode.model.matchesSearchQuery = getNodeMatchesSearchQuery(partiallyEnrichedNode, searchQuery);
|
|
163
|
+
|
|
109
164
|
if (partiallyEnrichedNode.model.isGroup === true) {
|
|
110
165
|
partiallyEnrichedNode.model.childrenMatchesSearchQuery = getChildrenMatchesSearchQuery(partiallyEnrichedNode, searchQuery);
|
|
111
|
-
if (partiallyEnrichedNode.model.childrenMatchesSearchQuery)
|
|
112
|
-
partiallyEnrichedNode.model.isExpanded = true;
|
|
166
|
+
if (partiallyEnrichedNode.model.childrenMatchesSearchQuery) partiallyEnrichedNode.model.isExpanded = true;
|
|
113
167
|
}
|
|
114
168
|
}
|
|
169
|
+
|
|
115
170
|
if (selection && selection[partiallyEnrichedNode.model.id]) {
|
|
116
171
|
partiallyEnrichedNode.model.isChecked = selection[partiallyEnrichedNode.model.id];
|
|
117
172
|
}
|
|
118
173
|
};
|
|
119
|
-
const focusItem =
|
|
120
|
-
|
|
174
|
+
const focusItem = item => {
|
|
175
|
+
var _item$nodeItemRef, _item$nodeItemRef$cur;
|
|
176
|
+
|
|
177
|
+
item === null || item === void 0 ? void 0 : (_item$nodeItemRef = item.nodeItemRef) === null || _item$nodeItemRef === void 0 ? void 0 : (_item$nodeItemRef$cur = _item$nodeItemRef.current) === null || _item$nodeItemRef$cur === void 0 ? void 0 : _item$nodeItemRef$cur.focus();
|
|
121
178
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
179
|
+
const flattenTreeForDnD = function (data) {
|
|
180
|
+
let shouldDescend = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => true;
|
|
181
|
+
const flattenedTree = [];
|
|
182
|
+
let index = 0;
|
|
183
|
+
|
|
184
|
+
const doit = function (node) {
|
|
185
|
+
var _node$children$length, _node$children, _node$children2;
|
|
186
|
+
|
|
187
|
+
let depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
188
|
+
let parentId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
189
|
+
flattenedTree.push({
|
|
190
|
+
uid: node.id.toString(),
|
|
191
|
+
depth,
|
|
192
|
+
realIndex: index,
|
|
193
|
+
childrenCount: (_node$children$length = (_node$children = node.children) === null || _node$children === void 0 ? void 0 : _node$children.length) !== null && _node$children$length !== void 0 ? _node$children$length : 0,
|
|
194
|
+
parentId: parentId !== null ? parentId.toString() : null,
|
|
195
|
+
original: node
|
|
196
|
+
});
|
|
197
|
+
index += 1;
|
|
198
|
+
if (shouldDescend(node)) (_node$children2 = node.children) === null || _node$children2 === void 0 ? void 0 : _node$children2.forEach(child => doit(child, depth + 1, node.id.toString()));
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
data.forEach(datum => doit(datum));
|
|
202
|
+
return flattenedTree;
|
|
134
203
|
};
|
|
135
|
-
|
|
204
|
+
|
|
205
|
+
export { cloneNode, enrichNodeModelInPlace, flattenTreeForDnD, focusItem, getChildrenMatchesSearchQuery, getItemsParentNode, getNodeById, getNodeMatchesSearchQuery, itemsShareSameParent, walkAllNodeChildren, walkParents, walkVisibles };
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { focusItem } from
|
|
4
|
-
import { toggleExpandAllHelper } from
|
|
5
|
-
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
+
import { useRef, useMemo, useState, useEffect, useCallback } from 'react';
|
|
3
|
+
import { focusItem } from './tree-helpers.js';
|
|
4
|
+
import { toggleExpandAllHelper } from './group-expands-helpers.js';
|
|
5
|
+
|
|
6
|
+
const useInstanceRefActions = (_ref, ctx) => {
|
|
7
|
+
let {
|
|
8
|
+
actions
|
|
9
|
+
} = _ref;
|
|
6
10
|
const {
|
|
7
|
-
props: {
|
|
11
|
+
props: {
|
|
12
|
+
onItemFocus
|
|
13
|
+
},
|
|
8
14
|
virtualListHelpers,
|
|
9
15
|
treeRoot,
|
|
10
16
|
visibleItems,
|
|
@@ -14,8 +20,12 @@ const useInstanceRefActions = ({ actions }, ctx) => {
|
|
|
14
20
|
setFocusedItem,
|
|
15
21
|
setLatestToggledItem
|
|
16
22
|
} = ctx;
|
|
17
|
-
const {
|
|
18
|
-
|
|
23
|
+
const {
|
|
24
|
+
current: promises
|
|
25
|
+
} = useRef({});
|
|
26
|
+
const {
|
|
27
|
+
scrollToIndex
|
|
28
|
+
} = useMemo(() => virtualListHelpers, [virtualListHelpers]);
|
|
19
29
|
const [expandPromise, setPromise] = useState();
|
|
20
30
|
useEffect(() => {
|
|
21
31
|
if (expandPromise && promises.expandResolve) {
|
|
@@ -24,30 +34,36 @@ const useInstanceRefActions = ({ actions }, ctx) => {
|
|
|
24
34
|
setPromise(null);
|
|
25
35
|
}
|
|
26
36
|
}, [visibleItems, expandPromise, promises]);
|
|
27
|
-
actions.toggleExpandAll = useCallback(
|
|
28
|
-
const p = new Promise(
|
|
37
|
+
actions.toggleExpandAll = useCallback(isExpand => {
|
|
38
|
+
const p = new Promise(resolve => {
|
|
29
39
|
promises.expandResolve = resolve;
|
|
30
|
-
if (treeRoot)
|
|
31
|
-
toggleExpandAllHelper(isExpand, treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);
|
|
40
|
+
if (treeRoot) toggleExpandAllHelper(isExpand, treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);
|
|
32
41
|
});
|
|
33
42
|
setPromise(p);
|
|
34
43
|
return p;
|
|
35
44
|
}, [promises, treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState]);
|
|
36
|
-
actions.scrollTo = useCallback((indx
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
actions.scrollTo = useCallback(function (indx) {
|
|
46
|
+
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
47
|
+
align: 'start'
|
|
48
|
+
};
|
|
49
|
+
if (scrollToIndex) scrollToIndex(indx, opts);
|
|
39
50
|
}, [scrollToIndex]);
|
|
40
|
-
actions.setSelectedItemByVirtualIndex = useCallback(
|
|
51
|
+
actions.setSelectedItemByVirtualIndex = useCallback(index => {
|
|
41
52
|
const itemByIndex = visibleItems[index];
|
|
42
53
|
setSelectedItem(itemByIndex);
|
|
43
54
|
}, [visibleItems, setSelectedItem]);
|
|
44
|
-
actions.setFocusedItemByVirtualIndex = useCallback((index
|
|
55
|
+
actions.setFocusedItemByVirtualIndex = useCallback(function (index) {
|
|
56
|
+
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
57
|
+
align: 'start',
|
|
58
|
+
withScroll: false
|
|
59
|
+
};
|
|
45
60
|
const itemByIndex = visibleItems[index];
|
|
46
61
|
const onItemFocusParams = {
|
|
47
62
|
itemIndex: itemByIndex.virtualIndex,
|
|
48
63
|
scrollToItem: () => scrollToIndex(index, opts),
|
|
49
64
|
item: itemByIndex
|
|
50
65
|
};
|
|
66
|
+
|
|
51
67
|
if (opts.withScroll && scrollToIndex) {
|
|
52
68
|
scrollToIndex(index, opts);
|
|
53
69
|
setTimeout(() => {
|
|
@@ -63,7 +79,5 @@ const useInstanceRefActions = ({ actions }, ctx) => {
|
|
|
63
79
|
}, [visibleItems, scrollToIndex, setFocusedItem, onItemFocus]);
|
|
64
80
|
return actions;
|
|
65
81
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
};
|
|
69
|
-
//# sourceMappingURL=useInstanceRefActions.js.map
|
|
82
|
+
|
|
83
|
+
export { useInstanceRefActions };
|
package/esm/utils/useTree.js
CHANGED
|
@@ -1,67 +1,93 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
8
|
+
import { useMemo, useState, useEffect, useCallback } from 'react';
|
|
9
|
+
import TreeModel from 'tree-model';
|
|
10
|
+
import { cloneDeep } from 'lodash';
|
|
11
|
+
import { enrichNodeModelInPlace, walkVisibles, flattenTreeForDnD } from './tree-helpers.js';
|
|
12
|
+
import { updateExpandedState } from './group-expands-helpers.js';
|
|
13
|
+
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
17
|
const useTree = (data, props, states) => {
|
|
8
|
-
const {
|
|
9
|
-
|
|
18
|
+
const {
|
|
19
|
+
setExpandedGroups
|
|
20
|
+
} = states;
|
|
21
|
+
const unfrozenData = useMemo(() => cloneDeep(data), [data]); // convert data into a TreeModel with extra isExpanded prop
|
|
22
|
+
// root element type is an exception, children model is based on what the dev passed on
|
|
23
|
+
// since root is an excepcion we must typecast
|
|
24
|
+
|
|
10
25
|
const tree = useMemo(() => new TreeModel(), []);
|
|
11
26
|
const [treeData, setTreeData] = useState({
|
|
12
|
-
id:
|
|
13
|
-
name:
|
|
27
|
+
id: '__ds_tree_root',
|
|
28
|
+
name: '__root',
|
|
14
29
|
isExpanded: true,
|
|
15
30
|
children: unfrozenData
|
|
16
31
|
});
|
|
17
32
|
useEffect(() => {
|
|
18
33
|
setTreeData({
|
|
19
|
-
id:
|
|
20
|
-
name:
|
|
34
|
+
id: '__ds_tree_root',
|
|
35
|
+
name: '__root',
|
|
21
36
|
isExpanded: true,
|
|
22
37
|
children: unfrozenData
|
|
23
38
|
});
|
|
24
|
-
}, [unfrozenData]);
|
|
39
|
+
}, [unfrozenData]); // expose a way to rerender the tree
|
|
40
|
+
// used for expand functionality
|
|
41
|
+
|
|
25
42
|
const [rerenderItems, setRerenderItems] = useState({});
|
|
26
43
|
const triggerTreeRerender = useCallback(() => {
|
|
27
44
|
setRerenderItems({});
|
|
28
|
-
}, []);
|
|
45
|
+
}, []); // when re-rendering we re-parse the list
|
|
46
|
+
|
|
29
47
|
const [treeRoot, setTreeRoot] = useState(tree.parse(treeData));
|
|
30
48
|
useEffect(() => {
|
|
31
49
|
setTreeRoot(tree.parse(treeData));
|
|
32
50
|
}, [treeData, rerenderItems, tree]);
|
|
33
51
|
const [visibleItems, setVisibleItems] = useState([]);
|
|
34
|
-
const {
|
|
52
|
+
const {
|
|
53
|
+
searchQuery,
|
|
54
|
+
highlightOnlyQuery,
|
|
55
|
+
onVisibleItemsChange,
|
|
56
|
+
selection,
|
|
57
|
+
expanded,
|
|
58
|
+
onExpandChange
|
|
59
|
+
} = props;
|
|
35
60
|
const updateUserExpandedState = useCallback(() => {
|
|
36
61
|
updateExpandedState(treeRoot, onExpandChange);
|
|
37
|
-
}, [treeRoot, onExpandChange]);
|
|
62
|
+
}, [treeRoot, onExpandChange]); // we add missing properties to the received Items
|
|
63
|
+
// not the best of the patterns, but it works
|
|
64
|
+
// this is where we convert "SimpleItems" to "Items"
|
|
65
|
+
// this was done to avoid breaking changes back in v1
|
|
66
|
+
|
|
38
67
|
useEffect(() => {
|
|
39
68
|
const parsedVisibleItems = [];
|
|
40
69
|
const newExpandedHashMap = {};
|
|
41
|
-
|
|
42
|
-
|
|
70
|
+
const shouldContinueWalking = true; // tree-model ask we return true if we want to continue walking
|
|
71
|
+
|
|
72
|
+
treeRoot.walk(node => {
|
|
43
73
|
enrichNodeModelInPlace(node, searchQuery, selection, expanded);
|
|
44
|
-
if (node.model.id && node.model.isGroup && node.model.isExpanded)
|
|
45
|
-
newExpandedHashMap[node.model.id] = true;
|
|
74
|
+
if (node.model.id && node.model.isGroup && node.model.isExpanded) newExpandedHashMap[node.model.id] = true;
|
|
46
75
|
return shouldContinueWalking;
|
|
47
76
|
});
|
|
48
|
-
walkVisibles(treeRoot,
|
|
49
|
-
parsedVisibleItems.push({
|
|
77
|
+
walkVisibles(treeRoot, node => {
|
|
78
|
+
parsedVisibleItems.push(_objectSpread(_objectSpread({}, node.model), {}, {
|
|
79
|
+
node
|
|
80
|
+
}));
|
|
50
81
|
}, true, highlightOnlyQuery);
|
|
51
82
|
setVisibleItems(parsedVisibleItems);
|
|
52
83
|
onVisibleItemsChange(parsedVisibleItems);
|
|
53
|
-
setExpandedGroups(newExpandedHashMap);
|
|
54
|
-
}, [
|
|
55
|
-
treeRoot,
|
|
56
|
-
rerenderItems,
|
|
57
|
-
searchQuery,
|
|
58
|
-
highlightOnlyQuery,
|
|
59
|
-
selection,
|
|
60
|
-
expanded,
|
|
61
|
-
setExpandedGroups
|
|
84
|
+
setExpandedGroups(newExpandedHashMap); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
85
|
+
}, [treeRoot, rerenderItems, searchQuery, highlightOnlyQuery, selection, expanded, setExpandedGroups // onVisibleItemsChange // evaluate potential performance hit?
|
|
62
86
|
]);
|
|
87
|
+
const flattenedItems = useMemo(() => flattenTreeForDnD(data), [data]);
|
|
63
88
|
return {
|
|
64
89
|
visibleItems,
|
|
90
|
+
flattenedItems,
|
|
65
91
|
tree,
|
|
66
92
|
treeRoot,
|
|
67
93
|
rerenderItems,
|
|
@@ -69,7 +95,5 @@ const useTree = (data, props, states) => {
|
|
|
69
95
|
updateUserExpandedState
|
|
70
96
|
};
|
|
71
97
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
75
|
-
//# sourceMappingURL=useTree.js.map
|
|
98
|
+
|
|
99
|
+
export { useTree };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-treeview",
|
|
3
|
-
"version": "2.2.0-
|
|
3
|
+
"version": "2.2.0-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Tree View",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -19,10 +19,6 @@
|
|
|
19
19
|
"import": "./esm/utils/useInstanceRefActions.js",
|
|
20
20
|
"require": "./cjs/utils/useInstanceRefActions.js"
|
|
21
21
|
},
|
|
22
|
-
"./utils/useDnDHelpers": {
|
|
23
|
-
"import": "./esm/utils/useDnDHelpers.js",
|
|
24
|
-
"require": "./cjs/utils/useDnDHelpers.js"
|
|
25
|
-
},
|
|
26
22
|
"./utils/tree-helpers": {
|
|
27
23
|
"import": "./esm/utils/tree-helpers.js",
|
|
28
24
|
"require": "./cjs/utils/tree-helpers.js"
|
|
@@ -51,10 +47,6 @@
|
|
|
51
47
|
"import": "./esm/utils/group-expands-helpers.js",
|
|
52
48
|
"require": "./cjs/utils/group-expands-helpers.js"
|
|
53
49
|
},
|
|
54
|
-
"./utils/dnd-helpers": {
|
|
55
|
-
"import": "./esm/utils/dnd-helpers.js",
|
|
56
|
-
"require": "./cjs/utils/dnd-helpers.js"
|
|
57
|
-
},
|
|
58
50
|
"./utils/array-helpers": {
|
|
59
51
|
"import": "./esm/utils/array-helpers.js",
|
|
60
52
|
"require": "./cjs/utils/array-helpers.js"
|
|
@@ -167,6 +159,14 @@
|
|
|
167
159
|
"import": "./esm/parts/ExpandCaret.js",
|
|
168
160
|
"require": "./cjs/parts/ExpandCaret.js"
|
|
169
161
|
},
|
|
162
|
+
"./parts/DropIndicator": {
|
|
163
|
+
"import": "./esm/parts/DropIndicator.js",
|
|
164
|
+
"require": "./cjs/parts/DropIndicator.js"
|
|
165
|
+
},
|
|
166
|
+
"./parts/DnDHandle": {
|
|
167
|
+
"import": "./esm/parts/DnDHandle.js",
|
|
168
|
+
"require": "./cjs/parts/DnDHandle.js"
|
|
169
|
+
},
|
|
170
170
|
"./parts/ChildrenCountDisplayer": {
|
|
171
171
|
"import": "./esm/parts/ChildrenCountDisplayer.js",
|
|
172
172
|
"require": "./cjs/parts/ChildrenCountDisplayer.js"
|
|
@@ -175,6 +175,22 @@
|
|
|
175
175
|
"import": "./esm/parts/CheckboxSelectable.js",
|
|
176
176
|
"require": "./cjs/parts/CheckboxSelectable.js"
|
|
177
177
|
},
|
|
178
|
+
"./hoc/WithDnDSortableItemContext": {
|
|
179
|
+
"import": "./esm/hoc/WithDnDSortableItemContext.js",
|
|
180
|
+
"require": "./cjs/hoc/WithDnDSortableItemContext.js"
|
|
181
|
+
},
|
|
182
|
+
"./hoc/WithConditionalDnDContext": {
|
|
183
|
+
"import": "./esm/hoc/WithConditionalDnDContext.js",
|
|
184
|
+
"require": "./cjs/hoc/WithConditionalDnDContext.js"
|
|
185
|
+
},
|
|
186
|
+
"./hoc/SortableItemContext": {
|
|
187
|
+
"import": "./esm/hoc/SortableItemContext.js",
|
|
188
|
+
"require": "./cjs/hoc/SortableItemContext.js"
|
|
189
|
+
},
|
|
190
|
+
"./hoc/DnDTreeContext": {
|
|
191
|
+
"import": "./esm/hoc/DnDTreeContext.js",
|
|
192
|
+
"require": "./cjs/hoc/DnDTreeContext.js"
|
|
193
|
+
},
|
|
178
194
|
"./config/useTreeview": {
|
|
179
195
|
"import": "./esm/config/useTreeview.js",
|
|
180
196
|
"require": "./cjs/config/useTreeview.js"
|
|
@@ -211,16 +227,16 @@
|
|
|
211
227
|
"generateSubmodules": true
|
|
212
228
|
},
|
|
213
229
|
"dependencies": {
|
|
214
|
-
"@elliemae/ds-button": "2.2.0-
|
|
215
|
-
"@elliemae/ds-circular-progress-indicator": "2.2.0-
|
|
216
|
-
"@elliemae/ds-classnames": "2.2.0-
|
|
217
|
-
"@elliemae/ds-
|
|
218
|
-
"@elliemae/ds-
|
|
219
|
-
"@elliemae/ds-
|
|
220
|
-
"@elliemae/ds-
|
|
221
|
-
"@elliemae/ds-
|
|
222
|
-
"@elliemae/ds-
|
|
223
|
-
"@elliemae/
|
|
230
|
+
"@elliemae/ds-button": "2.2.0-next.1",
|
|
231
|
+
"@elliemae/ds-circular-progress-indicator": "2.2.0-next.1",
|
|
232
|
+
"@elliemae/ds-classnames": "2.2.0-next.1",
|
|
233
|
+
"@elliemae/ds-drag-and-drop": "2.2.0-next.1",
|
|
234
|
+
"@elliemae/ds-form": "2.2.0-next.1",
|
|
235
|
+
"@elliemae/ds-icons": "2.2.0-next.1",
|
|
236
|
+
"@elliemae/ds-props-helpers": "2.2.0-next.1",
|
|
237
|
+
"@elliemae/ds-shared": "2.2.0-next.1",
|
|
238
|
+
"@elliemae/ds-truncated-tooltip-text": "2.2.0-next.1",
|
|
239
|
+
"@elliemae/ds-utilities": "2.2.0-next.1",
|
|
224
240
|
"react-desc": "~4.1.3",
|
|
225
241
|
"react-highlight-words": "~0.17.0",
|
|
226
242
|
"react-virtual": "~2.3.2",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DSTreeviewT } from '../react-desc-prop-types';
|
|
3
|
+
import { DropIndicatorPosition } from './SortableItemContext';
|
|
4
|
+
declare type DnDTreeContextType = {
|
|
5
|
+
depth: number | undefined;
|
|
6
|
+
activeIndex: number | undefined;
|
|
7
|
+
visibleItems: DSTreeviewT.Item[] | undefined;
|
|
8
|
+
dropIndicatorPosition: DropIndicatorPosition;
|
|
9
|
+
lastActiveId: string | undefined;
|
|
10
|
+
setLastActiveId: React.Dispatch<React.SetStateAction<string>> | undefined;
|
|
11
|
+
isDropValid: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare const DnDTreeContext: import("react").Context<DnDTreeContextType>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { useSortable } from '@dnd-kit/sortable';
|
|
3
|
+
export declare enum DropIndicatorPosition {
|
|
4
|
+
None = 0,
|
|
5
|
+
Before = 1,
|
|
6
|
+
After = 2,
|
|
7
|
+
Inside = 3
|
|
8
|
+
}
|
|
9
|
+
export declare type SortableItemContextType = {
|
|
10
|
+
draggableProps: false | (ReturnType<typeof useSortable> & {
|
|
11
|
+
dropIndicatorPosition: DropIndicatorPosition;
|
|
12
|
+
shouldShowDropIndicatorPosition: boolean;
|
|
13
|
+
lastActiveId?: string;
|
|
14
|
+
setLastActiveId?: React.Dispatch<React.SetStateAction<string>>;
|
|
15
|
+
isDropValid: boolean;
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
/** Context for cross component communication */
|
|
19
|
+
export declare const SortableItemContext: import("react").Context<SortableItemContextType>;
|