@itwin/presentation-hierarchies 2.0.0-alpha.12 → 2.0.0-alpha.14

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.
Files changed (121) hide show
  1. package/CHANGELOG.md +301 -16
  2. package/README.md +2 -2
  3. package/lib/cjs/hierarchies/HierarchyNode.d.ts +13 -11
  4. package/lib/cjs/hierarchies/HierarchyNode.d.ts.map +1 -1
  5. package/lib/cjs/hierarchies/HierarchyNode.js +18 -0
  6. package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -1
  7. package/lib/cjs/hierarchies/HierarchyNodeIdentifier.d.ts +2 -0
  8. package/lib/cjs/hierarchies/HierarchyNodeIdentifier.d.ts.map +1 -1
  9. package/lib/cjs/hierarchies/HierarchyNodeIdentifier.js +23 -6
  10. package/lib/cjs/hierarchies/HierarchyNodeIdentifier.js.map +1 -1
  11. package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts +5 -4
  12. package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
  13. package/lib/cjs/hierarchies/HierarchyNodeKey.js.map +1 -1
  14. package/lib/cjs/hierarchies/HierarchyProvider.d.ts +3 -3
  15. package/lib/cjs/hierarchies/HierarchyProvider.d.ts.map +1 -1
  16. package/lib/cjs/hierarchies/HierarchyProvider.js.map +1 -1
  17. package/lib/cjs/hierarchies/HierarchySearch.d.ts +206 -78
  18. package/lib/cjs/hierarchies/HierarchySearch.d.ts.map +1 -1
  19. package/lib/cjs/hierarchies/HierarchySearch.js +315 -113
  20. package/lib/cjs/hierarchies/HierarchySearch.js.map +1 -1
  21. package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts +2 -2
  22. package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
  23. package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
  24. package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.d.ts +3 -3
  25. package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.d.ts.map +1 -1
  26. package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.js.map +1 -1
  27. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts +9 -4
  28. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
  29. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +25 -16
  30. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
  31. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts +4 -4
  32. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
  33. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js +12 -9
  34. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
  35. package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts +3 -3
  36. package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts.map +1 -1
  37. package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.js.map +1 -1
  38. package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.d.ts +2 -2
  39. package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -1
  40. package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.js +31 -55
  41. package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -1
  42. package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts +2 -2
  43. package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
  44. package/lib/cjs/hierarchies/imodel/TreeNodesReader.js +1 -1
  45. package/lib/cjs/hierarchies/imodel/TreeNodesReader.js.map +1 -1
  46. package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
  47. package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
  48. package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js +4 -1
  49. package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
  50. package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts +1 -1
  51. package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
  52. package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
  53. package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.d.ts +2 -2
  54. package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.d.ts.map +1 -1
  55. package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.js.map +1 -1
  56. package/lib/cjs/hierarchies/internal/operators/Sorting.d.ts.map +1 -1
  57. package/lib/cjs/hierarchies/internal/operators/Sorting.js.map +1 -1
  58. package/lib/cjs/presentation-hierarchies.d.ts +1 -1
  59. package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
  60. package/lib/cjs/presentation-hierarchies.js +2 -1
  61. package/lib/cjs/presentation-hierarchies.js.map +1 -1
  62. package/lib/esm/hierarchies/HierarchyNode.d.ts +13 -11
  63. package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -1
  64. package/lib/esm/hierarchies/HierarchyNode.js +18 -0
  65. package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
  66. package/lib/esm/hierarchies/HierarchyNodeIdentifier.d.ts +2 -0
  67. package/lib/esm/hierarchies/HierarchyNodeIdentifier.d.ts.map +1 -1
  68. package/lib/esm/hierarchies/HierarchyNodeIdentifier.js +23 -6
  69. package/lib/esm/hierarchies/HierarchyNodeIdentifier.js.map +1 -1
  70. package/lib/esm/hierarchies/HierarchyNodeKey.d.ts +5 -4
  71. package/lib/esm/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
  72. package/lib/esm/hierarchies/HierarchyNodeKey.js.map +1 -1
  73. package/lib/esm/hierarchies/HierarchyProvider.d.ts +3 -3
  74. package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -1
  75. package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -1
  76. package/lib/esm/hierarchies/HierarchySearch.d.ts +206 -78
  77. package/lib/esm/hierarchies/HierarchySearch.d.ts.map +1 -1
  78. package/lib/esm/hierarchies/HierarchySearch.js +314 -111
  79. package/lib/esm/hierarchies/HierarchySearch.js.map +1 -1
  80. package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts +2 -2
  81. package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
  82. package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
  83. package/lib/esm/hierarchies/imodel/IModelHierarchyNode.d.ts +3 -3
  84. package/lib/esm/hierarchies/imodel/IModelHierarchyNode.d.ts.map +1 -1
  85. package/lib/esm/hierarchies/imodel/IModelHierarchyNode.js.map +1 -1
  86. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts +9 -4
  87. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
  88. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +26 -17
  89. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
  90. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts +4 -4
  91. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
  92. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js +13 -10
  93. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
  94. package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts +3 -3
  95. package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts.map +1 -1
  96. package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.js.map +1 -1
  97. package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.d.ts +2 -2
  98. package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -1
  99. package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.js +32 -56
  100. package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -1
  101. package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts +2 -2
  102. package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
  103. package/lib/esm/hierarchies/imodel/TreeNodesReader.js +2 -2
  104. package/lib/esm/hierarchies/imodel/TreeNodesReader.js.map +1 -1
  105. package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
  106. package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
  107. package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js +4 -1
  108. package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
  109. package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts +1 -1
  110. package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
  111. package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
  112. package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.d.ts +2 -2
  113. package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.d.ts.map +1 -1
  114. package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.js.map +1 -1
  115. package/lib/esm/hierarchies/internal/operators/Sorting.d.ts.map +1 -1
  116. package/lib/esm/hierarchies/internal/operators/Sorting.js.map +1 -1
  117. package/lib/esm/presentation-hierarchies.d.ts +1 -1
  118. package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
  119. package/lib/esm/presentation-hierarchies.js +1 -1
  120. package/lib/esm/presentation-hierarchies.js.map +1 -1
  121. package/package.json +10 -10
@@ -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 an instance of `SearchPathRevealDepthInPath`, then all nodes up to `depthInPath` will have `autoExpand` flag.
59
- * - If it's an instance of `SearchPathRevealDepthInHierarchy`, then all nodes up to `depthInHierarchy` will have `autoExpand` flag.
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 | SearchPathRevealDepthInHierarchy | SearchPathRevealDepthInPath;
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
- * **NOTE**: this attribute does not set `autoExpand` flag on nodes up to the search target. For that use `reveal`.
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,186 @@ 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 `depthInHierarchy` set, return the other one,
95
- * - else return the one with greater `depthInPath` or `depthInHierarchy`.
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
+ /**
169
+ * Props supplied to HierarchySearchTreeBuilder.accept() method for accepting a hierarchy search path or tree with an optional handler for customizing
170
+ * the behavior of the builder when accepting new entries.
171
+ * @public
172
+ */
173
+ type HierarchySearchTreeBuilderAcceptProps<TAcceptHandlerExtras extends Record<string, unknown>> = ({
174
+ path: HierarchySearchPath;
175
+ } | {
176
+ tree: HierarchySearchTree;
177
+ }) & {
178
+ /** An optional handler for customizing the behavior of the builder when accepting new entries. */
179
+ handler?: HierarchySearchTreeBuilderAcceptHandler<TAcceptHandlerExtras>;
180
+ };
181
+ /**
182
+ * Props supplied to HierarchySearchTreeBuilder.getTree() method for customizing the resulting tree entries, e.g. by omitting some of them or
183
+ * assigning extra information to them.
184
+ * @public
185
+ */
186
+ interface HierarchySearchTreeBuilderFinalizeTreeProps<TAcceptHandlerExtras extends Record<string, unknown>> {
187
+ /**
188
+ * A function that can be used to process each tree entry before it's added to the final tree.
189
+ *
190
+ * Return `undefined` to omit the entry and its entire branch from the resulting tree.
191
+ */
192
+ processEntry?: (props: {
193
+ treeEntry: HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TAcceptHandlerExtras>;
194
+ parentEntries: Array<HierarchySearchTreeBuilderAcceptHandlerTreeEntry<TAcceptHandlerExtras>>;
195
+ }) => (Omit<HierarchySearchTree, "children"> & {
196
+ extras: TAcceptHandlerExtras;
197
+ }) | undefined;
198
+ }
199
+ /**
200
+ * An utility that accepts hierarchy search paths or search trees one by one and builds a `HierarchySearchTree` structure based on them.
201
+ * @public
202
+ */
203
+ interface HierarchySearchTreeBuilder<TAcceptHandlerExtras extends Record<string, unknown>> {
204
+ /**
205
+ * Accepts a hierarchy search path or paths' tree and adds it to the builder's internal tree structure. Use `getTree()` to create
206
+ * a `HierarchySearchTree[]` from the added paths.
207
+ */
208
+ accept(props: HierarchySearchTreeBuilderAcceptProps<TAcceptHandlerExtras>): HierarchySearchTreeBuilder<TAcceptHandlerExtras>;
209
+ /**
210
+ * Create `HierarchySearchTree[]` from currently added search paths.
211
+ */
212
+ getTree(props?: HierarchySearchTreeBuilderFinalizeTreeProps<TAcceptHandlerExtras>): HierarchySearchTree[];
213
+ }
214
+ /**
215
+ * Create a `HierarchySearchTree` builder utility that accepts hierarchy search paths or search trees one by one and builds
216
+ * a `HierarchySearchTree` structure based on them.
217
+ *
218
+ * Usage example:
219
+ *
220
+ * ```ts
221
+ * const builder = HierarchySearchTree.createBuilder();
222
+ * for (const path of searchPaths) {
223
+ * builder.accept({ path });
224
+ * }
225
+ * const searchTree = builder.getTree();
226
+ * ```
227
+ *
228
+ * @public
229
+ */
230
+ export function createBuilder<TAcceptHandlerExtras extends Record<string, unknown> = Record<string, unknown>>(): HierarchySearchTreeBuilder<TAcceptHandlerExtras>;
231
+ /**
232
+ * Builds a list of `HierarchySearchTree` nodes from an iterable of search paths. Shared
233
+ * path prefixes are merged so that each unique hierarchy node identifier appears only once
234
+ * per level. The resulting trees carry `isTarget`, `options`, and `children` attributes
235
+ * derived from the paths and their options (`autoExpand`, `reveal`).
236
+ *
237
+ * @public
238
+ */
239
+ export function createFromPathsList(paths: Iterable<HierarchySearchPath>): Promise<HierarchySearchTree[]>;
240
+ /**
241
+ * Merges two `HierarchySearchTree` option objects. For the `autoExpand` attribute,
242
+ * `true` takes precedence over `{ groupingLevel }`, and when both sides are
243
+ * `{ groupingLevel }` objects the larger value wins.
244
+ * @public
245
+ */
246
+ export function mergeOptions(lhs: HierarchySearchTree["options"] | undefined, rhs: HierarchySearchTree["options"] | undefined): HierarchySearchTree["options"] | undefined;
247
+ export {};
248
+ }
101
249
  /**
102
250
  * Creates a set of utilities for making it easier to search the given hierarchy
103
251
  * level.
104
252
  *
105
253
  * @public
106
254
  */
107
- export declare function createHierarchySearchHelper(rootLevelSearchProps: HierarchySearchPath[] | undefined, parentNode: Pick<NonGroupingHierarchyNode, "search"> | undefined): {
255
+ export declare function createHierarchySearchHelper(rootLevelSearchProps: HierarchySearchTree[] | undefined, parentNode: Pick<NonGroupingHierarchyNode, "search"> | undefined): {
108
256
  /** Returns a flag indicating if the hierarchy level is filtered. */
109
257
  hasSearch: boolean;
110
258
  /**
@@ -129,41 +277,21 @@ export declare function createHierarchySearchHelper(rootLevelSearchProps: Hierar
129
277
  * `nodeKey` prop can be used to check the whole identifier.
130
278
  *
131
279
  * There are multiple overloads of `createChildNodeProps`: depending on props type it returns different values:
132
- * - `parentKeys` is defined and `pathMatcher` or `nodeKey` is provided - returns undefined **or** `search` and `autoExpand` prop from `HierarchyNode`;
133
- * - `parentKeys` is undefined - does not return `HierarchyNode.autoExpand` option;
134
- * - props have `asyncPathMatcher` - returns either Promise or the regular return value based on whether or not `asyncPathMatcher` returns a promise.
280
+ * - `asyncPathMatcher` is provided - returns either Promise or the regular return value based on whether or not `asyncPathMatcher` returns a `Promise`.
281
+ * - `pathMatcher` or only `nodeKey` is provided - returns undefined **or** `search` and `autoExpand` prop from `HierarchyNode`;
135
282
  */
136
283
  createChildNodeProps: {
137
284
  (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
285
  nodeKey: InstancesNodeKey | GenericNodeKey;
152
286
  }): Pick<NonGroupingHierarchyNode, "search" | "autoExpand"> | undefined;
153
287
  (props: {
154
- parentKeys: HierarchyNodeKey[];
288
+ nodeKey: InstancesNodeKey | GenericNodeKey;
155
289
  pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;
156
290
  }): Pick<NonGroupingHierarchyNode, "search" | "autoExpand"> | undefined;
157
291
  (props: {
158
- parentKeys: HierarchyNodeKey[];
292
+ nodeKey: InstancesNodeKey | GenericNodeKey;
159
293
  asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;
160
294
  }): Promise<Pick<NonGroupingHierarchyNode, "search" | "autoExpand"> | undefined> | Pick<NonGroupingHierarchyNode, "search" | "autoExpand"> | undefined;
161
295
  };
162
296
  };
163
- /** @internal */
164
- export declare function shouldAutoExpandBasedOnReveal({ reveal, nodePositionInPath, nodePositionInHierarchy, }: {
165
- reveal: HierarchySearchPathOptions["reveal"];
166
- nodePositionInPath: number;
167
- nodePositionInHierarchy: number;
168
- }): boolean;
169
297
  //# sourceMappingURL=HierarchySearch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchySearch.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchySearch.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,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,2BAA2B;IAC1C;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,cAAc;AACd,MAAM,WAAW,gCAAgC;IAC/C;;;;;;;;;;;;;;;;;;;OAmBG;IACH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