@itwin/presentation-hierarchies 2.0.0-alpha.12 → 2.0.0-alpha.13
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/CHANGELOG.md +268 -16
- package/README.md +2 -2
- package/lib/cjs/hierarchies/HierarchyNode.d.ts +13 -11
- package/lib/cjs/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNode.js +18 -0
- package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeIdentifier.d.ts +2 -0
- package/lib/cjs/hierarchies/HierarchyNodeIdentifier.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeIdentifier.js +23 -6
- package/lib/cjs/hierarchies/HierarchyNodeIdentifier.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts +5 -4
- package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeKey.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts +3 -3
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchySearch.d.ts +184 -78
- package/lib/cjs/hierarchies/HierarchySearch.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchySearch.js +305 -113
- package/lib/cjs/hierarchies/HierarchySearch.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts +2 -2
- package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.d.ts +3 -3
- package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts +9 -4
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +25 -16
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts +4 -4
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js +12 -9
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts +3 -3
- package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.d.ts +2 -2
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.js +31 -55
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts +2 -2
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.js +1 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js +4 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.d.ts +2 -2
- package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/Sorting.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/Sorting.js.map +1 -1
- package/lib/cjs/presentation-hierarchies.d.ts +1 -1
- package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies.js +2 -1
- package/lib/cjs/presentation-hierarchies.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNode.d.ts +13 -11
- package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNode.js +18 -0
- package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeIdentifier.d.ts +2 -0
- package/lib/esm/hierarchies/HierarchyNodeIdentifier.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeIdentifier.js +23 -6
- package/lib/esm/hierarchies/HierarchyNodeIdentifier.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeKey.d.ts +5 -4
- package/lib/esm/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeKey.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.d.ts +3 -3
- package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/HierarchySearch.d.ts +184 -78
- package/lib/esm/hierarchies/HierarchySearch.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchySearch.js +304 -111
- package/lib/esm/hierarchies/HierarchySearch.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts +2 -2
- package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyNode.d.ts +3 -3
- package/lib/esm/hierarchies/imodel/IModelHierarchyNode.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyNode.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts +9 -4
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +26 -17
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts +4 -4
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js +13 -10
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
- package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts +3 -3
- package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.d.ts +2 -2
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.js +32 -56
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts +2 -2
- package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/TreeNodesReader.js +2 -2
- package/lib/esm/hierarchies/imodel/TreeNodesReader.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js +4 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
- package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.d.ts +2 -2
- package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.js.map +1 -1
- package/lib/esm/hierarchies/internal/operators/Sorting.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/Sorting.js.map +1 -1
- package/lib/esm/presentation-hierarchies.d.ts +1 -1
- package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies.js +1 -1
- package/lib/esm/presentation-hierarchies.js.map +1 -1
- package/package.json +8 -8
|
@@ -1,70 +1,52 @@
|
|
|
1
1
|
import { HierarchyNodeIdentifier } from "./HierarchyNodeIdentifier.js";
|
|
2
|
-
import { HierarchyNodeKey } from "./HierarchyNodeKey.js";
|
|
3
2
|
import type { NonGroupingHierarchyNode } from "./HierarchyNode.js";
|
|
4
3
|
import type { HierarchyNodeIdentifiersPath } from "./HierarchyNodeIdentifier.js";
|
|
5
4
|
import type { GenericNodeKey, InstancesNodeKey } from "./HierarchyNodeKey.js";
|
|
6
5
|
/** @public */
|
|
7
|
-
export interface SearchPathRevealDepthInPath {
|
|
8
|
-
/**
|
|
9
|
-
* Index of the node in search path should be revealed in hierarchy by auto-expanding its ancestors.
|
|
10
|
-
*
|
|
11
|
-
* Use when you want to expand up to specific instance node and don't care about grouping nodes.
|
|
12
|
-
*
|
|
13
|
-
* **Use case example:**
|
|
14
|
-
*
|
|
15
|
-
* All nodes up to `Element1` should be expanded in the following hierarchy:
|
|
16
|
-
* - Node1
|
|
17
|
-
* - GroupingNode1
|
|
18
|
-
* - GroupingNode2
|
|
19
|
-
* - Element1
|
|
20
|
-
* - Element2
|
|
21
|
-
*
|
|
22
|
-
* Provide `{ path: [Node1, Element1], reveal: { depthInPath: 1 } }`
|
|
23
|
-
*
|
|
24
|
-
* **NOTE**: All nodes that are up to `depthInPath` will be expanded **except** search targets.
|
|
25
|
-
*/
|
|
26
|
-
depthInPath: number;
|
|
27
|
-
}
|
|
28
|
-
/** @public */
|
|
29
|
-
export interface SearchPathRevealDepthInHierarchy {
|
|
30
|
-
/**
|
|
31
|
-
* Considering the list of nodes from root to the target node, this is an index in that list, identifying the node that should be revealed in hierarchy by auto-expanding its ancestors.
|
|
32
|
-
*
|
|
33
|
-
* This should take into account the number of grouping nodes in hierarchy.
|
|
34
|
-
*
|
|
35
|
-
* **Use case example:**
|
|
36
|
-
*
|
|
37
|
-
* Only `Node1` and `GroupingNode1` should have `autoExpand` flag in the following hierarchy:
|
|
38
|
-
* - Node1
|
|
39
|
-
* - GroupingNode1
|
|
40
|
-
* - GroupingNode2
|
|
41
|
-
* - Element1
|
|
42
|
-
* - Element2
|
|
43
|
-
*
|
|
44
|
-
* Provide `{ path: [Node1, Element1], reveal: { depthInHierarchy: 2 } }`
|
|
45
|
-
*
|
|
46
|
-
* To get the correct depth use `HierarchyNode.parentKeys.length`.
|
|
47
|
-
*
|
|
48
|
-
* **NOTE**: All nodes that are up to `depthInHierarchy` will be expanded **except** search targets.
|
|
49
|
-
*/
|
|
50
|
-
depthInHierarchy: number;
|
|
51
|
-
}
|
|
52
|
-
/** @public */
|
|
53
6
|
export interface HierarchySearchPathOptions {
|
|
54
7
|
/**
|
|
55
8
|
* This option specifies the way `autoExpand` flag should be assigned to nodes in the searched hierarchy.
|
|
56
9
|
* - If it's `false` or `undefined`, nodes have no 'autoExpand' flag.
|
|
57
10
|
* - If it's `true`, then all nodes up to the search target will have `autoExpand` flag.
|
|
58
|
-
* - If it's
|
|
59
|
-
*
|
|
11
|
+
* - If it's a object with `groupingLevel` then `groupingLevel` determines the number of grouping levels to expand for
|
|
12
|
+
* the search target.
|
|
60
13
|
*/
|
|
61
|
-
reveal?: boolean |
|
|
14
|
+
reveal?: boolean | {
|
|
15
|
+
/**
|
|
16
|
+
* Index of the node in search path should be revealed in hierarchy by auto-expanding its ancestors.
|
|
17
|
+
*
|
|
18
|
+
* Use when you want to expand up to specific instance node and don't care about grouping nodes.
|
|
19
|
+
*
|
|
20
|
+
* **Use case example:**
|
|
21
|
+
*
|
|
22
|
+
* All nodes up to `Element1` should be expanded in the following hierarchy:
|
|
23
|
+
* - Node1
|
|
24
|
+
* - GroupingNode1
|
|
25
|
+
* - GroupingNode2
|
|
26
|
+
* - Element1
|
|
27
|
+
* - Element2
|
|
28
|
+
*
|
|
29
|
+
* Provide `{ path: [Node1, Element1], reveal: { depthInPath: 1 } }`
|
|
30
|
+
*
|
|
31
|
+
* **NOTE**: All nodes that are up to `depthInPath` will be expanded **except** search targets.
|
|
32
|
+
*/
|
|
33
|
+
depthInPath: number;
|
|
34
|
+
} | {
|
|
35
|
+
/**
|
|
36
|
+
* The number of grouping levels to expand for the search target. For example, if `groupingLevel` is set to `2`, then all grouping nodes up to the second level
|
|
37
|
+
* will have the `autoExpand` flag.
|
|
38
|
+
*
|
|
39
|
+
* **Note:** if search target has less grouping levels than specified by this attribute, then all grouping nodes up to the search target will have
|
|
40
|
+
* the `autoExpand` flag, but the search target itself won't have the `autoExpand` flag.
|
|
41
|
+
*/
|
|
42
|
+
groupingLevel: number;
|
|
43
|
+
};
|
|
62
44
|
/**
|
|
63
45
|
* This option specifies whether or not search target should be expanded.
|
|
64
46
|
* - If it's `false` or `undefined`, search target won't have 'autoExpand' flag.
|
|
65
47
|
* - If it's `true`, search target will have `autoExpand` flag.
|
|
66
48
|
*
|
|
67
|
-
* **
|
|
49
|
+
* **Note:** this attribute does not set `autoExpand` flag on nodes up to the search target. For that use `reveal`.
|
|
68
50
|
*/
|
|
69
51
|
autoExpand?: boolean;
|
|
70
52
|
}
|
|
@@ -91,20 +73,164 @@ export declare namespace HierarchySearchPath {
|
|
|
91
73
|
* - else if only one of the inputs is an object, return it,
|
|
92
74
|
* - else if both inputs are falsy, return `false` or `undefined`,
|
|
93
75
|
* - else:
|
|
94
|
-
* - if only one of the inputs has `
|
|
95
|
-
* - else
|
|
76
|
+
* - if only one of the inputs has `groupingLevel` set, return that one,
|
|
77
|
+
* - else compare by matching reveal type (`groupingLevel` or `depthInPath`) and return the deeper one.
|
|
96
78
|
*
|
|
97
79
|
* @public
|
|
98
80
|
*/
|
|
99
81
|
function mergeOptions(lhs: HierarchySearchPathOptions | undefined, rhs: HierarchySearchPathOptions | undefined): HierarchySearchPathOptions | undefined;
|
|
100
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* A tree structure representing hierarchy search paths. Each node in the tree corresponds
|
|
85
|
+
* to a hierarchy node identifier and may have children that represent deeper levels in the
|
|
86
|
+
* hierarchy.
|
|
87
|
+
*
|
|
88
|
+
* The `HierarchySearchTree.createBuilder` or `HierarchySearchTree.createFromPathsList` are
|
|
89
|
+
* typically used create this tree from a flat list of search paths.
|
|
90
|
+
*
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
export interface HierarchySearchTree {
|
|
94
|
+
/** Identifier of the hierarchy node this tree entry represents. */
|
|
95
|
+
identifier: HierarchyNodeIdentifier;
|
|
96
|
+
/**
|
|
97
|
+
* When `true`, indicates that this node is a search target.
|
|
98
|
+
*
|
|
99
|
+
* Note: A `HierarchySearchTree` node is considered a search target if it has no children, even if `isTarget` is not explicitly set to `true`. This
|
|
100
|
+
* is because a node with no children represents the end of a search path.
|
|
101
|
+
*/
|
|
102
|
+
isTarget?: boolean;
|
|
103
|
+
/** Provides options for handling this search tree entry, such as auto-expansion behavior. */
|
|
104
|
+
options?: {
|
|
105
|
+
/**
|
|
106
|
+
* - `true` to expand the node and its grouping nodes,
|
|
107
|
+
* - `{ groupingLevel: number }` to expand ancestor grouping nodes, e.g. for the following hierarchy:
|
|
108
|
+
* ```
|
|
109
|
+
* - Grouping node A
|
|
110
|
+
* - Instance node A
|
|
111
|
+
* - Grouping node B1
|
|
112
|
+
* - Grouping node B2
|
|
113
|
+
* - ...
|
|
114
|
+
* - Grouping node Bn
|
|
115
|
+
* - Instance node B
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* For "Instance node B" search tree entry:
|
|
119
|
+
* - `{ groupingLevel: 1 }` expands its first grouping node "Grouping node B1",
|
|
120
|
+
* - `{ groupingLevel: 2 }` expands two levels to "Grouping node B2".
|
|
121
|
+
* - `{ groupingLevel: Number.MAX_SAFE_INTEGER }` expands all grouping nodes of that instance node.
|
|
122
|
+
*
|
|
123
|
+
* Note that there's a slight difference between `HierarchySearchTree.options.autoExpand` and
|
|
124
|
+
* `HierarchySearchPath.options.reveal`. The latter option reveals the search target node by expanding its ancestors,
|
|
125
|
+
* while the `HierarchySearchTree.options.autoExpand` also expands the target node itself.
|
|
126
|
+
*/
|
|
127
|
+
autoExpand?: boolean | {
|
|
128
|
+
groupingLevel: number;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
/** Child search tree entries representing the next level(s) in the hierarchy search paths. */
|
|
132
|
+
children?: HierarchySearchTree[];
|
|
133
|
+
}
|
|
134
|
+
/** @public */
|
|
135
|
+
export declare namespace HierarchySearchTree {
|
|
136
|
+
/** @public */
|
|
137
|
+
type HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras extends Record<string, unknown>> = Readonly<Pick<HierarchySearchTree, "identifier" | "options"> & {
|
|
138
|
+
extras: TExtras;
|
|
139
|
+
}> & Pick<HierarchySearchTree, "isTarget">;
|
|
140
|
+
/** @public */
|
|
141
|
+
type HierarchySearchTreeBuilderAcceptHandlerTreeInput = Readonly<Pick<HierarchySearchTree, "identifier" | "isTarget" | "options"> & {
|
|
142
|
+
hasChildren: boolean;
|
|
143
|
+
}>;
|
|
144
|
+
/** @public */
|
|
145
|
+
interface HierarchySearchTreeBuilderAcceptHandler<TExtras extends Record<string, unknown>> {
|
|
146
|
+
/**
|
|
147
|
+
* Called when a new entry is added to the tree. Return `true` to accept the entry, `false` to reject it and all its children, if any.
|
|
148
|
+
*/
|
|
149
|
+
onNewEntry?: (props: {
|
|
150
|
+
/** The parent entries of the new entry being added, from root to immediate parent. It's allowed to mutate these entries. */
|
|
151
|
+
parentEntries: Array<HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras>>;
|
|
152
|
+
/** The new entry being added to the tree. */
|
|
153
|
+
inputEntry: HierarchySearchTreeBuilderAcceptHandlerTreeInput;
|
|
154
|
+
}) => boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Called when a new entry is added to the tree and accepted (either it's a new entry or it merges with an existing entry). This can be used to perform
|
|
157
|
+
* side effects such as assigning extra information to the tree entry.
|
|
158
|
+
*/
|
|
159
|
+
onEntryHandled?: (props: {
|
|
160
|
+
/** The parent entries of the new entry being added, from root to immediate parent. It's allowed to mutate these entries. */
|
|
161
|
+
parentEntries: Array<HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras>>;
|
|
162
|
+
/** The tree entry that has been handled. It's allowed to mutate this entry. */
|
|
163
|
+
treeEntry: HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TExtras>;
|
|
164
|
+
/** The input entry being added to the tree. */
|
|
165
|
+
inputEntry: HierarchySearchTreeBuilderAcceptHandlerTreeInput;
|
|
166
|
+
}) => void;
|
|
167
|
+
}
|
|
168
|
+
/** @public */
|
|
169
|
+
type HierarchySearchTreeBuilderAcceptProps<TAcceptHandlerExtras extends Record<string, unknown>> = ({
|
|
170
|
+
path: HierarchySearchPath;
|
|
171
|
+
} | {
|
|
172
|
+
tree: HierarchySearchTree;
|
|
173
|
+
}) & {
|
|
174
|
+
/** An optional handler for customizing the behavior of the builder when accepting new entries. */
|
|
175
|
+
handler?: HierarchySearchTreeBuilderAcceptHandler<TAcceptHandlerExtras>;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* An utility that accepts hierarchy search paths or search trees one by one and builds a `HierarchySearchTree` structure based on them.
|
|
179
|
+
* @public
|
|
180
|
+
*/
|
|
181
|
+
interface HierarchySearchTreeBuilder<TAcceptHandlerExtras extends Record<string, unknown>> {
|
|
182
|
+
/**
|
|
183
|
+
* Accepts a hierarchy search path or paths' tree and adds it to the builder's internal tree structure. Use `getTree()` to create
|
|
184
|
+
* a `HierarchySearchTree[]` from the added paths.
|
|
185
|
+
*/
|
|
186
|
+
accept(props: HierarchySearchTreeBuilderAcceptProps<TAcceptHandlerExtras>): HierarchySearchTreeBuilder<TAcceptHandlerExtras>;
|
|
187
|
+
/**
|
|
188
|
+
* Create `HierarchySearchTree[]` from currently added search paths.
|
|
189
|
+
*/
|
|
190
|
+
getTree(): HierarchySearchTree[];
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Create a `HierarchySearchTree` builder utility that accepts hierarchy search paths or search trees one by one and builds
|
|
194
|
+
* a `HierarchySearchTree` structure based on them.
|
|
195
|
+
*
|
|
196
|
+
* Usage example:
|
|
197
|
+
*
|
|
198
|
+
* ```ts
|
|
199
|
+
* const builder = HierarchySearchTree.createBuilder();
|
|
200
|
+
* for (const path of searchPaths) {
|
|
201
|
+
* builder.accept({ path });
|
|
202
|
+
* }
|
|
203
|
+
* const searchTree = builder.getTree();
|
|
204
|
+
* ```
|
|
205
|
+
*
|
|
206
|
+
* @public
|
|
207
|
+
*/
|
|
208
|
+
export function createBuilder<TAcceptHandlerExtras extends Record<string, unknown> = Record<string, unknown>>(): HierarchySearchTreeBuilder<TAcceptHandlerExtras>;
|
|
209
|
+
/**
|
|
210
|
+
* Builds a list of `HierarchySearchTree` nodes from an iterable of search paths. Shared
|
|
211
|
+
* path prefixes are merged so that each unique hierarchy node identifier appears only once
|
|
212
|
+
* per level. The resulting trees carry `isTarget`, `options`, and `children` attributes
|
|
213
|
+
* derived from the paths and their options (`autoExpand`, `reveal`).
|
|
214
|
+
*
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
export function createFromPathsList(paths: Iterable<HierarchySearchPath>): Promise<HierarchySearchTree[]>;
|
|
218
|
+
/**
|
|
219
|
+
* Merges two `HierarchySearchTree` option objects. For the `autoExpand` attribute,
|
|
220
|
+
* `true` takes precedence over `{ groupingLevel }`, and when both sides are
|
|
221
|
+
* `{ groupingLevel }` objects the larger value wins.
|
|
222
|
+
* @public
|
|
223
|
+
*/
|
|
224
|
+
export function mergeOptions(lhs: HierarchySearchTree["options"] | undefined, rhs: HierarchySearchTree["options"] | undefined): HierarchySearchTree["options"] | undefined;
|
|
225
|
+
export {};
|
|
226
|
+
}
|
|
101
227
|
/**
|
|
102
228
|
* Creates a set of utilities for making it easier to search the given hierarchy
|
|
103
229
|
* level.
|
|
104
230
|
*
|
|
105
231
|
* @public
|
|
106
232
|
*/
|
|
107
|
-
export declare function createHierarchySearchHelper(rootLevelSearchProps:
|
|
233
|
+
export declare function createHierarchySearchHelper(rootLevelSearchProps: HierarchySearchTree[] | undefined, parentNode: Pick<NonGroupingHierarchyNode, "search"> | undefined): {
|
|
108
234
|
/** Returns a flag indicating if the hierarchy level is filtered. */
|
|
109
235
|
hasSearch: boolean;
|
|
110
236
|
/**
|
|
@@ -129,41 +255,21 @@ export declare function createHierarchySearchHelper(rootLevelSearchProps: Hierar
|
|
|
129
255
|
* `nodeKey` prop can be used to check the whole identifier.
|
|
130
256
|
*
|
|
131
257
|
* There are multiple overloads of `createChildNodeProps`: depending on props type it returns different values:
|
|
132
|
-
* - `
|
|
133
|
-
* - `
|
|
134
|
-
* - props have `asyncPathMatcher` - returns either Promise or the regular return value based on whether or not `asyncPathMatcher` returns a promise.
|
|
258
|
+
* - `asyncPathMatcher` is provided - returns either Promise or the regular return value based on whether or not `asyncPathMatcher` returns a `Promise`.
|
|
259
|
+
* - `pathMatcher` or only `nodeKey` is provided - returns undefined **or** `search` and `autoExpand` prop from `HierarchyNode`;
|
|
135
260
|
*/
|
|
136
261
|
createChildNodeProps: {
|
|
137
262
|
(props: {
|
|
138
|
-
parentKeys?: undefined;
|
|
139
|
-
nodeKey: InstancesNodeKey | GenericNodeKey;
|
|
140
|
-
}): Pick<NonGroupingHierarchyNode, "search"> | undefined;
|
|
141
|
-
(props: {
|
|
142
|
-
parentKeys?: undefined;
|
|
143
|
-
pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;
|
|
144
|
-
}): Pick<NonGroupingHierarchyNode, "search"> | undefined;
|
|
145
|
-
(props: {
|
|
146
|
-
parentKeys?: undefined;
|
|
147
|
-
asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;
|
|
148
|
-
}): Promise<Pick<NonGroupingHierarchyNode, "search"> | undefined> | Pick<NonGroupingHierarchyNode, "search"> | undefined;
|
|
149
|
-
(props: {
|
|
150
|
-
parentKeys: HierarchyNodeKey[];
|
|
151
263
|
nodeKey: InstancesNodeKey | GenericNodeKey;
|
|
152
264
|
}): Pick<NonGroupingHierarchyNode, "search" | "autoExpand"> | undefined;
|
|
153
265
|
(props: {
|
|
154
|
-
|
|
266
|
+
nodeKey: InstancesNodeKey | GenericNodeKey;
|
|
155
267
|
pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;
|
|
156
268
|
}): Pick<NonGroupingHierarchyNode, "search" | "autoExpand"> | undefined;
|
|
157
269
|
(props: {
|
|
158
|
-
|
|
270
|
+
nodeKey: InstancesNodeKey | GenericNodeKey;
|
|
159
271
|
asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;
|
|
160
272
|
}): Promise<Pick<NonGroupingHierarchyNode, "search" | "autoExpand"> | undefined> | Pick<NonGroupingHierarchyNode, "search" | "autoExpand"> | undefined;
|
|
161
273
|
};
|
|
162
274
|
};
|
|
163
|
-
/** @internal */
|
|
164
|
-
export declare function shouldAutoExpandBasedOnReveal({ reveal, nodePositionInPath, nodePositionInHierarchy, }: {
|
|
165
|
-
reveal: HierarchySearchPathOptions["reveal"];
|
|
166
|
-
nodePositionInPath: number;
|
|
167
|
-
nodePositionInHierarchy: number;
|
|
168
|
-
}): boolean;
|
|
169
275
|
//# sourceMappingURL=HierarchySearch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchySearch.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchySearch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HierarchySearch.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchySearch.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAIvE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9E,cAAc;AACd,MAAM,WAAW,0BAA0B;IACzC;;;;;;OAMG;IACH,MAAM,CAAC,EACH,OAAO,GACP;QACE;;;;;;;;;;;;;;;;;WAiBG;QACH,WAAW,EAAE,MAAM,CAAC;KACrB,GACD;QACE;;;;;;WAMG;QACH,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACN;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,4BAA4B,GAAG;IAAE,IAAI,EAAE,4BAA4B,CAAC;IAAC,OAAO,CAAC,EAAE,0BAA0B,CAAA;CAAE,CAAC;AAC9I,cAAc;AAEd,yBAAiB,mBAAmB,CAAC;I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