@itwin/presentation-hierarchies 2.0.0-alpha.5 → 2.0.0-alpha.6

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 (82) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/lib/cjs/hierarchies/HierarchyFiltering.d.ts +77 -36
  3. package/lib/cjs/hierarchies/HierarchyFiltering.d.ts.map +1 -1
  4. package/lib/cjs/hierarchies/HierarchyFiltering.js +126 -98
  5. package/lib/cjs/hierarchies/HierarchyFiltering.js.map +1 -1
  6. package/lib/cjs/hierarchies/HierarchyMerge.d.ts +19 -0
  7. package/lib/cjs/hierarchies/HierarchyMerge.d.ts.map +1 -0
  8. package/lib/cjs/hierarchies/HierarchyMerge.js +43 -0
  9. package/lib/cjs/hierarchies/HierarchyMerge.js.map +1 -0
  10. package/lib/cjs/hierarchies/HierarchyNode.d.ts +2 -2
  11. package/lib/cjs/hierarchies/HierarchyNode.d.ts.map +1 -1
  12. package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -1
  13. package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
  14. package/lib/cjs/hierarchies/HierarchyNodeKey.js +8 -8
  15. package/lib/cjs/hierarchies/HierarchyNodeKey.js.map +1 -1
  16. package/lib/cjs/hierarchies/HierarchyProvider.d.ts +0 -18
  17. package/lib/cjs/hierarchies/HierarchyProvider.d.ts.map +1 -1
  18. package/lib/cjs/hierarchies/HierarchyProvider.js +0 -37
  19. package/lib/cjs/hierarchies/HierarchyProvider.js.map +1 -1
  20. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts +2 -0
  21. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +1 -1
  22. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js +45 -30
  23. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js.map +1 -1
  24. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts +42 -7
  25. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
  26. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +136 -45
  27. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
  28. package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
  29. package/lib/cjs/hierarchies/imodel/TreeNodesReader.js +8 -1
  30. package/lib/cjs/hierarchies/imodel/TreeNodesReader.js.map +1 -1
  31. package/lib/cjs/hierarchies/internal/Common.d.ts +3 -0
  32. package/lib/cjs/hierarchies/internal/Common.d.ts.map +1 -1
  33. package/lib/cjs/hierarchies/internal/Common.js +12 -1
  34. package/lib/cjs/hierarchies/internal/Common.js.map +1 -1
  35. package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -1
  36. package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js +2 -1
  37. package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -1
  38. package/lib/cjs/presentation-hierarchies.d.ts +3 -2
  39. package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
  40. package/lib/cjs/presentation-hierarchies.js +4 -3
  41. package/lib/cjs/presentation-hierarchies.js.map +1 -1
  42. package/lib/esm/hierarchies/HierarchyFiltering.d.ts +77 -36
  43. package/lib/esm/hierarchies/HierarchyFiltering.d.ts.map +1 -1
  44. package/lib/esm/hierarchies/HierarchyFiltering.js +125 -98
  45. package/lib/esm/hierarchies/HierarchyFiltering.js.map +1 -1
  46. package/lib/esm/hierarchies/HierarchyMerge.d.ts +19 -0
  47. package/lib/esm/hierarchies/HierarchyMerge.d.ts.map +1 -0
  48. package/lib/esm/hierarchies/HierarchyMerge.js +40 -0
  49. package/lib/esm/hierarchies/HierarchyMerge.js.map +1 -0
  50. package/lib/esm/hierarchies/HierarchyNode.d.ts +2 -2
  51. package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -1
  52. package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
  53. package/lib/esm/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
  54. package/lib/esm/hierarchies/HierarchyNodeKey.js +9 -9
  55. package/lib/esm/hierarchies/HierarchyNodeKey.js.map +1 -1
  56. package/lib/esm/hierarchies/HierarchyProvider.d.ts +0 -18
  57. package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -1
  58. package/lib/esm/hierarchies/HierarchyProvider.js +1 -36
  59. package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -1
  60. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts +2 -0
  61. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +1 -1
  62. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js +47 -32
  63. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js.map +1 -1
  64. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts +42 -7
  65. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
  66. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +138 -48
  67. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
  68. package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
  69. package/lib/esm/hierarchies/imodel/TreeNodesReader.js +8 -1
  70. package/lib/esm/hierarchies/imodel/TreeNodesReader.js.map +1 -1
  71. package/lib/esm/hierarchies/internal/Common.d.ts +3 -0
  72. package/lib/esm/hierarchies/internal/Common.d.ts.map +1 -1
  73. package/lib/esm/hierarchies/internal/Common.js +11 -1
  74. package/lib/esm/hierarchies/internal/Common.js.map +1 -1
  75. package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -1
  76. package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js +3 -2
  77. package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -1
  78. package/lib/esm/presentation-hierarchies.d.ts +3 -2
  79. package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
  80. package/lib/esm/presentation-hierarchies.js +2 -2
  81. package/lib/esm/presentation-hierarchies.js.map +1 -1
  82. package/package.json +7 -7
@@ -6,7 +6,7 @@ import { HierarchyNodeIdentifier } from "./HierarchyNodeIdentifier.js";
6
6
  import { HierarchyNodeKey } from "./HierarchyNodeKey.js";
7
7
  var HierarchyFilteringPathOptions;
8
8
  (function (HierarchyFilteringPathOptions) {
9
- function mergeAutoExpandOptions(lhs, rhs) {
9
+ function mergeRevealOptions(lhs, rhs) {
10
10
  if (rhs === true || lhs === true) {
11
11
  return true;
12
12
  }
@@ -28,7 +28,11 @@ var HierarchyFilteringPathOptions;
28
28
  }
29
29
  return lhsDepth > rhsDepth ? lhs : rhs;
30
30
  }
31
- HierarchyFilteringPathOptions.mergeAutoExpandOptions = mergeAutoExpandOptions;
31
+ HierarchyFilteringPathOptions.mergeRevealOptions = mergeRevealOptions;
32
+ function mergeAutoExpandOption(lhs, rhs) {
33
+ return lhs || rhs ? true : undefined;
34
+ }
35
+ HierarchyFilteringPathOptions.mergeAutoExpandOption = mergeAutoExpandOption;
32
36
  })(HierarchyFilteringPathOptions || (HierarchyFilteringPathOptions = {}));
33
37
  /** @public */
34
38
  // eslint-disable-next-line @typescript-eslint/no-redeclare
@@ -47,27 +51,26 @@ export var HierarchyFilteringPath;
47
51
  HierarchyFilteringPath.normalize = normalize;
48
52
  /**
49
53
  * Merges two given `HierarchyFilteringPathOptions` objects.
50
- * - if both inputs are `undefined`, `undefined` is returned,
51
- * - else if one of the inputs is `undefined`, the other one is returned.
52
- * - else, merge each option individually.
53
54
  *
54
- * For the `autoExpand` attribute, the merge chooses to auto-expand as deep as the deepest input:
55
+ * For the `reveal` attribute, the merge chooses to `reveal` as deep as the deepest input:
55
56
  * - if any one of the inputs is `true`, return `true`,
56
57
  * - else if only one of the inputs is an object, return it,
57
58
  * - else if both inputs are falsy, return `false` or `undefined`,
58
59
  * - else:
59
- * - if only one of the inputs has `includeGroupingNodes` set to `true` or `key` defined or `depthInHierarchy` set, return the other one,
60
- * - else return the one with greater `depth`, `depthInPath` or `depthInHierarchy`.
60
+ * - if only one of the inputs has `depthInHierarchy` set, return the other one,
61
+ * - else return the one with greater `depthInPath` or `depthInHierarchy`.
61
62
  *
62
63
  * @public
63
64
  */
64
65
  function mergeOptions(lhs, rhs) {
65
- if (!lhs || !rhs) {
66
- return lhs ?? rhs;
67
- }
68
- return {
69
- autoExpand: HierarchyFilteringPathOptions.mergeAutoExpandOptions(lhs.autoExpand, rhs.autoExpand),
70
- };
66
+ const reveal = HierarchyFilteringPathOptions.mergeRevealOptions(lhs?.reveal, rhs?.reveal);
67
+ const autoExpand = HierarchyFilteringPathOptions.mergeAutoExpandOption(lhs?.autoExpand, rhs?.autoExpand);
68
+ return reveal || autoExpand
69
+ ? {
70
+ ...(reveal !== undefined ? { reveal } : undefined),
71
+ ...(autoExpand !== undefined ? { autoExpand } : undefined),
72
+ }
73
+ : undefined;
71
74
  }
72
75
  HierarchyFilteringPath.mergeOptions = mergeOptions;
73
76
  })(HierarchyFilteringPath || (HierarchyFilteringPath = {}));
@@ -79,19 +82,24 @@ export var HierarchyFilteringPath;
79
82
  */
80
83
  /* c8 ignore start */
81
84
  export function extractFilteringProps(rootLevelFilteringProps, parentNode) {
82
- return extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);
85
+ const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);
86
+ return filteringProps?.filteredNodePaths !== undefined
87
+ ? {
88
+ filteredNodePaths: filteringProps.filteredNodePaths,
89
+ hasFilterTargetAncestor: filteringProps.hasFilterTargetAncestor,
90
+ }
91
+ : undefined;
83
92
  }
84
93
  /* c8 ignore end */
85
94
  function extractFilteringPropsInternal(rootLevelFilteringProps, parentNode) {
86
95
  if (!parentNode) {
87
96
  return rootLevelFilteringProps ? { filteredNodePaths: rootLevelFilteringProps, hasFilterTargetAncestor: false } : undefined;
88
97
  }
89
- return parentNode.filtering?.filteredChildrenIdentifierPaths
90
- ? {
91
- filteredNodePaths: parentNode.filtering.filteredChildrenIdentifierPaths,
92
- hasFilterTargetAncestor: !!parentNode.filtering.hasFilterTargetAncestor || !!parentNode.filtering.isFilterTarget,
93
- }
94
- : undefined;
98
+ const filteringProps = {
99
+ ...(parentNode.filtering?.filteredChildrenIdentifierPaths ? { filteredNodePaths: parentNode.filtering.filteredChildrenIdentifierPaths } : undefined),
100
+ hasFilterTargetAncestor: !!parentNode.filtering?.hasFilterTargetAncestor || !!parentNode.filtering?.isFilterTarget,
101
+ };
102
+ return filteringProps.filteredNodePaths || filteringProps.hasFilterTargetAncestor ? filteringProps : undefined;
95
103
  }
96
104
  /**
97
105
  * Creates a set of utilities for making it easier to filter the given hierarchy
@@ -102,10 +110,61 @@ function extractFilteringPropsInternal(rootLevelFilteringProps, parentNode) {
102
110
  export function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNode) {
103
111
  const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);
104
112
  const hasFilter = !!filteringProps;
113
+ function saveFilteringPropsFromPathsIntoReducer(extractionProps) {
114
+ // Passes down matching normalized paths to the reducer.
115
+ // It uses `nodeKey`, `pathMatcher` or `asyncPathMatcher` to check if `HierarchyNodeIdentifier` at the first position in filtering path matches the node
116
+ // and if it does, the path is passed down to the reducer.
117
+ // This function returns a promise only if asyncPathMatcher returns a promise.
118
+ if (!filteringProps?.filteredNodePaths) {
119
+ return;
120
+ }
121
+ const matchedPathPromises = new Array();
122
+ for (const filteredChildrenNodeIdentifierPath of filteringProps.filteredNodePaths) {
123
+ const normalizedPath = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);
124
+ /* c8 ignore next 3 */
125
+ if (normalizedPath.path.length === 0) {
126
+ continue;
127
+ }
128
+ if ("nodeKey" in extractionProps) {
129
+ if ((HierarchyNodeKey.isGeneric(extractionProps.nodeKey) && HierarchyNodeIdentifier.equal(normalizedPath.path[0], extractionProps.nodeKey)) ||
130
+ (HierarchyNodeKey.isInstances(extractionProps.nodeKey) &&
131
+ extractionProps.nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier.equal(normalizedPath.path[0], ik)))) {
132
+ extractionProps.pathsReducer.accept(normalizedPath);
133
+ }
134
+ continue;
135
+ }
136
+ const matchesPossiblyPromise = "pathMatcher" in extractionProps ? extractionProps.pathMatcher(normalizedPath.path[0]) : extractionProps.asyncPathMatcher(normalizedPath.path[0]);
137
+ if (matchesPossiblyPromise instanceof Promise) {
138
+ matchedPathPromises.push(matchesPossiblyPromise.then((matches) => (matches ? normalizedPath : undefined)));
139
+ continue;
140
+ }
141
+ if (matchesPossiblyPromise) {
142
+ extractionProps.pathsReducer.accept(normalizedPath);
143
+ }
144
+ }
145
+ if (matchedPathPromises.length === 0) {
146
+ return;
147
+ }
148
+ return Promise.all(matchedPathPromises).then((matchedPath) => matchedPath.forEach((normalizedPath) => normalizedPath && extractionProps.pathsReducer.accept(normalizedPath)));
149
+ }
150
+ function createChildNodeProps(props) {
151
+ if (!hasFilter) {
152
+ return undefined;
153
+ }
154
+ const reducer = new MatchingFilteringPathsReducer(filteringProps.hasFilterTargetAncestor);
155
+ if ("asyncPathMatcher" in props) {
156
+ const extractResult = saveFilteringPropsFromPathsIntoReducer({ pathsReducer: reducer, asyncPathMatcher: props.asyncPathMatcher });
157
+ if (extractResult instanceof Promise) {
158
+ return extractResult.then(() => reducer.getNodeProps(props.parentKeys));
159
+ }
160
+ }
161
+ else {
162
+ saveFilteringPropsFromPathsIntoReducer({ ...props, pathsReducer: reducer });
163
+ }
164
+ return reducer.getNodeProps(props.parentKeys);
165
+ }
105
166
  return {
106
- /**
107
- * Returns a flag indicating if the hierarchy level is filtered.
108
- */
167
+ /** Returns a flag indicating if the hierarchy level is filtered. */
109
168
  hasFilter,
110
169
  /**
111
170
  * Returns a flag indicating whether this hierarchy level has an ancestor node
@@ -119,7 +178,7 @@ export function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNo
119
178
  * hierarchy level. Returns `undefined` if filtering is not applied to this level.
120
179
  */
121
180
  getChildNodeFilteringIdentifiers: () => {
122
- if (!hasFilter) {
181
+ if (!filteringProps?.filteredNodePaths) {
123
182
  return undefined;
124
183
  }
125
184
  return filteringProps.filteredNodePaths
@@ -132,68 +191,33 @@ export function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNo
132
191
  * and `autoExpand`) to be set based on the filter paths and filtering options. This function calculates
133
192
  * these props for a child node based on its key or path matcher.
134
193
  *
135
- * When using `pathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies
194
+ * When using `pathMatcher` or `asyncPathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies
136
195
  * to their node. For example, only some parts of the identifier can be checked for improved performance. Otherwise, the
137
196
  * `nodeKey` prop can be used to check the whole identifier.
197
+ *
198
+ * There are multiple overloads of `createChildNodeProps`: depending on props type it returns different values:
199
+ * - `parentKeys` is defined and `pathMatcher` or `nodeKey` is provided - returns undefined **or** `filtering` and `autoExpand` prop from `HierarchyNode`;
200
+ * - `parentKeys` is undefined - does not return `HierarchyNode.autoExpand` option;
201
+ * - props have `asyncPathMatcher` - returns either Promise or the regular return value based on whether or not `asyncPathMatcher` returns a promise.
138
202
  */
139
- createChildNodeProps: (props) => {
140
- if (!hasFilter) {
141
- return undefined;
142
- }
143
- const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);
144
- filteringProps.filteredNodePaths.forEach((filteredPath) => {
145
- const normalizedPath = HierarchyFilteringPath.normalize(filteredPath);
146
- if ("nodeKey" in props &&
147
- ((HierarchyNodeKey.isGeneric(props.nodeKey) && HierarchyNodeIdentifier.equal(normalizedPath.path[0], props.nodeKey)) ||
148
- (HierarchyNodeKey.isInstances(props.nodeKey) && props.nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier.equal(normalizedPath.path[0], ik))))) {
149
- reducer.accept(normalizedPath);
150
- }
151
- else if ("pathMatcher" in props && props.pathMatcher(normalizedPath.path[0])) {
152
- reducer.accept(normalizedPath);
153
- }
154
- });
155
- return reducer.getNodeProps(parentNode);
156
- },
157
- /**
158
- * Similar to `createChildNodeProps`, but takes an async `pathMatcher` prop.
159
- */
160
- createChildNodePropsAsync: (props) => {
161
- if (!hasFilter) {
162
- return undefined;
163
- }
164
- const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);
165
- const matchedPathPromises = new Array();
166
- for (const filteredChildrenNodeIdentifierPath of filteringProps.filteredNodePaths) {
167
- const normalizedPath = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);
168
- /* c8 ignore next 3 */
169
- if (normalizedPath.path.length === 0) {
170
- continue;
171
- }
172
- const matchesPossiblyPromise = props.pathMatcher(normalizedPath.path[0]);
173
- if (matchesPossiblyPromise instanceof Promise) {
174
- matchedPathPromises.push(matchesPossiblyPromise.then((matches) => (matches ? normalizedPath : undefined)));
175
- continue;
176
- }
177
- if (!matchesPossiblyPromise) {
178
- continue;
179
- }
180
- reducer.accept(normalizedPath);
181
- }
182
- if (matchedPathPromises.length === 0) {
183
- return reducer.getNodeProps(parentNode);
184
- }
185
- return Promise.all(matchedPathPromises)
186
- .then((matchedPath) => matchedPath.forEach((normalizedPath) => normalizedPath && reducer.accept(normalizedPath)))
187
- .then(() => reducer.getNodeProps(parentNode));
188
- },
203
+ createChildNodeProps,
189
204
  };
190
205
  }
206
+ /**
207
+ * Extracts information from filtering paths and later returns `filtering` and `autoExpand` values from `HierarchyNode`.
208
+ *
209
+ * Saved values can be applied to a single `HierarchyNode` - this means that a new reducer should be created every time these props are requested for a `HierarchyNode`.
210
+ *
211
+ * Extracts information using `accept` function:
212
+ * - Determines if node is filter target, and if it is saves the options as `filterTargetOptions`
213
+ * - Saves `HierarchyFilteringPathOptions` and `filteredChildrenIdentifierPaths`
214
+ */
191
215
  class MatchingFilteringPathsReducer {
192
216
  _hasFilterTargetAncestor;
193
217
  _filteredChildrenIdentifierPaths = new Array();
194
218
  _isFilterTarget = false;
195
219
  _filterTargetOptions = undefined;
196
- _autoExpandOption = false;
220
+ _revealOption = false;
197
221
  constructor(_hasFilterTargetAncestor) {
198
222
  this._hasFilterTargetAncestor = _hasFilterTargetAncestor;
199
223
  }
@@ -205,28 +229,10 @@ class MatchingFilteringPathsReducer {
205
229
  }
206
230
  else if (path.length > 1) {
207
231
  this._filteredChildrenIdentifierPaths.push({ path: path.slice(1), options });
208
- this._autoExpandOption = HierarchyFilteringPathOptions.mergeAutoExpandOptions(options?.autoExpand, this._autoExpandOption);
232
+ this._revealOption = HierarchyFilteringPathOptions.mergeRevealOptions(options?.reveal, this._revealOption);
209
233
  }
210
234
  }
211
- getNeedsAutoExpand(parentNode) {
212
- if (this._autoExpandOption === true) {
213
- return true;
214
- }
215
- if (typeof this._autoExpandOption === "object") {
216
- const parentLength = !parentNode
217
- ? 0
218
- : "depthInHierarchy" in this._autoExpandOption
219
- ? 1 + parentNode.parentKeys.length
220
- : 1 + parentNode.parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length;
221
- const depth = "depthInHierarchy" in this._autoExpandOption
222
- ? this._autoExpandOption.depthInHierarchy
223
- : // With `depthInPath` option we don't want to expand node that is at the `depthInPath` position
224
- this._autoExpandOption.depthInPath - 1;
225
- return parentLength < depth;
226
- }
227
- return false;
228
- }
229
- getNodeProps(parentNode) {
235
+ getNodeProps(parentKeys) {
230
236
  return {
231
237
  ...(this._hasFilterTargetAncestor || this._isFilterTarget || this._filteredChildrenIdentifierPaths.length > 0
232
238
  ? {
@@ -237,8 +243,29 @@ class MatchingFilteringPathsReducer {
237
243
  },
238
244
  }
239
245
  : undefined),
240
- ...(this.getNeedsAutoExpand(parentNode) ? { autoExpand: true } : undefined),
246
+ ...(parentKeys &&
247
+ (shouldAutoExpandBasedOnReveal({
248
+ reveal: this._revealOption,
249
+ nodePositionInHierarchy: parentKeys.length,
250
+ nodePositionInPath: parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length,
251
+ }) ||
252
+ !!this._filterTargetOptions?.autoExpand)
253
+ ? { autoExpand: true }
254
+ : undefined),
241
255
  };
242
256
  }
243
257
  }
258
+ /** @internal */
259
+ export function shouldAutoExpandBasedOnReveal({ reveal, nodePositionInPath, nodePositionInHierarchy, }) {
260
+ if (!reveal) {
261
+ return false;
262
+ }
263
+ if (reveal === true) {
264
+ return true;
265
+ }
266
+ if ("depthInHierarchy" in reveal) {
267
+ return nodePositionInHierarchy < reveal.depthInHierarchy;
268
+ }
269
+ return nodePositionInPath < reveal.depthInPath;
270
+ }
244
271
  //# sourceMappingURL=HierarchyFiltering.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyFiltering.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyFiltering.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,uBAAuB,EAAgC,MAAM,8BAA8B,CAAC;AACrG,OAAO,EAAkB,gBAAgB,EAAoB,MAAM,uBAAuB,CAAC;AAkD3F,IAAU,6BAA6B,CA4BtC;AA5BD,WAAU,6BAA6B;IACrC,SAAgB,sBAAsB,CACpC,GAAgD,EAChD,GAAgD;QAEhD,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACjB,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QAC3B,CAAC;QAED,MAAM,QAAQ,GAAG,aAAa,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC;QAC/E,MAAM,QAAQ,GAAG,aAAa,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,gB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AgC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,+BAA+B,EAAE,IAAI,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;qBAC/I;iBACF;gBACH,CAAC,CAAC,SAAS,CAAC;YACd,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;SAC5E,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { HierarchyNode, NonGroupingHierarchyNode } from \"./HierarchyNode.js\";\nimport { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from \"./HierarchyNodeIdentifier.js\";\nimport { GenericNodeKey, HierarchyNodeKey, InstancesNodeKey } from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport interface FilteringPathAutoExpandDepthInPath {\n /**\n * Depth that tells which nodes in the filtering path should be expanded.\n *\n * Use when you want to expand up to specific instance node and don't care about grouping nodes.\n *\n * **NOTE**: All nodes that are up to `depthInPath` will be expanded. Node at the `depthInPath` position won't be expanded.\n */\n depthInPath: number;\n}\n\n/** @public */\nexport interface FilteringPathAutoExpandDepthInHierarchy {\n /**\n * Depth that tells which nodes in the hierarchy should be expanded.\n *\n * This should take into account the number of grouping nodes in hierarchy.\n *\n * * **Use case example:**\n *\n * You want to `autoExpand` only `Node1` and `GroupingNode1` in the following hierarchy:\n * - Node1\n * - GroupingNode1\n * - GroupingNode2\n * - Element1\n * - Element2\n * Then you provide `autoExpand: { depthInHierarchy: 2 }`\n *\n * To get the correct depth use `HierarchyNode.parentKeys.length`.\n *\n * **NOTE**: All nodes that are up to and including `depthInHierarchy` will be expanded.\n */\n depthInHierarchy: number;\n}\n\n/** @public */\nexport interface HierarchyFilteringPathOptions {\n /**\n * This option specifies the way `autoExpand` flag should be assigned to nodes in the filtered hierarchy.\n * - If it's `false` or `undefined`, nodes have no 'autoExpand' flag.\n * - If it's `true`, then all nodes up to the filter target will have `autoExpand` flag.\n * - If it's an instance of `FilteringPathAutoExpandDepthInPath`, then all nodes up to `depthInPath` will have `autoExpand` flag.\n * - If it's an instance of `FilteringPathAutoExpandDepthInHierarchy`, then all nodes up to and including `depthInHierarchy` will have `autoExpand` flag.\n */\n autoExpand?: boolean | FilteringPathAutoExpandDepthInHierarchy | FilteringPathAutoExpandDepthInPath;\n}\n\nnamespace HierarchyFilteringPathOptions {\n export function mergeAutoExpandOptions(\n lhs: HierarchyFilteringPathOptions[\"autoExpand\"],\n rhs: HierarchyFilteringPathOptions[\"autoExpand\"],\n ): HierarchyFilteringPathOptions[\"autoExpand\"] {\n if (rhs === true || lhs === true) {\n return true;\n }\n if (!rhs || !lhs) {\n return !!rhs ? rhs : lhs;\n }\n\n const lhsDepth = \"depthInPath\" in lhs ? lhs.depthInPath : lhs.depthInHierarchy;\n const rhsDepth = \"depthInPath\" in rhs ? rhs.depthInPath : rhs.depthInHierarchy;\n const isLhsDepthBasedOnPath = \"depthInPath\" in lhs;\n const isRhsDepthBasedOnPath = \"depthInPath\" in rhs;\n\n if (isLhsDepthBasedOnPath) {\n if (isRhsDepthBasedOnPath) {\n return lhsDepth > rhsDepth ? lhs : rhs;\n }\n return lhs;\n }\n if (isRhsDepthBasedOnPath) {\n return rhs;\n }\n return lhsDepth > rhsDepth ? lhs : rhs;\n }\n}\n\n/**\n * A path of hierarchy node identifiers for filtering the hierarchy with additional options.\n * @public\n */\nexport type HierarchyFilteringPath = HierarchyNodeIdentifiersPath | { path: HierarchyNodeIdentifiersPath; options?: HierarchyFilteringPathOptions };\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyFilteringPath {\n /**\n * Normalizes the hierarchy filtering path to the object form.\n * @public\n */\n export function normalize(source: HierarchyFilteringPath): Exclude<HierarchyFilteringPath, HierarchyNodeIdentifiersPath> {\n if (Array.isArray(source)) {\n return { path: source };\n }\n return source;\n }\n\n /**\n * Merges two given `HierarchyFilteringPathOptions` objects.\n * - if both inputs are `undefined`, `undefined` is returned,\n * - else if one of the inputs is `undefined`, the other one is returned.\n * - else, merge each option individually.\n *\n * For the `autoExpand` attribute, the merge chooses to auto-expand as deep as the deepest input:\n * - if any one of the inputs is `true`, return `true`,\n * - else if only one of the inputs is an object, return it,\n * - else if both inputs are falsy, return `false` or `undefined`,\n * - else:\n * - if only one of the inputs has `includeGroupingNodes` set to `true` or `key` defined or `depthInHierarchy` set, return the other one,\n * - else return the one with greater `depth`, `depthInPath` or `depthInHierarchy`.\n *\n * @public\n */\n export function mergeOptions(\n lhs: HierarchyFilteringPathOptions | undefined,\n rhs: HierarchyFilteringPathOptions | undefined,\n ): HierarchyFilteringPathOptions | undefined {\n if (!lhs || !rhs) {\n return lhs ?? rhs;\n }\n\n return {\n autoExpand: HierarchyFilteringPathOptions.mergeAutoExpandOptions(lhs.autoExpand, rhs.autoExpand),\n };\n }\n}\n\n/**\n * An utility that extracts filtering properties from given root level filtering props or\n * the parent node. Returns `undefined` if filtering props are not present.\n * @public\n * @deprecated in 1.3. Use `createHierarchyFilteringHelper` instead.\n */\n/* c8 ignore start */\nexport function extractFilteringProps(\n rootLevelFilteringProps: HierarchyFilteringPath[],\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n):\n | {\n filteredNodePaths: HierarchyFilteringPath[];\n hasFilterTargetAncestor: boolean;\n }\n | undefined {\n return extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);\n}\n/* c8 ignore end */\n\nfunction extractFilteringPropsInternal(\n rootLevelFilteringProps: HierarchyFilteringPath[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n):\n | {\n filteredNodePaths: HierarchyFilteringPath[];\n hasFilterTargetAncestor: boolean;\n }\n | undefined {\n if (!parentNode) {\n return rootLevelFilteringProps ? { filteredNodePaths: rootLevelFilteringProps, hasFilterTargetAncestor: false } : undefined;\n }\n return parentNode.filtering?.filteredChildrenIdentifierPaths\n ? {\n filteredNodePaths: parentNode.filtering.filteredChildrenIdentifierPaths,\n hasFilterTargetAncestor: !!parentNode.filtering.hasFilterTargetAncestor || !!parentNode.filtering.isFilterTarget,\n }\n : undefined;\n}\n\n/**\n * Creates a set of utilities for making it easier to filter the given hierarchy\n * level.\n *\n * @public\n */\nexport function createHierarchyFilteringHelper(\n rootLevelFilteringProps: HierarchyFilteringPath[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\" | \"parentKeys\"> | undefined,\n) {\n const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);\n const hasFilter = !!filteringProps;\n return {\n /**\n * Returns a flag indicating if the hierarchy level is filtered.\n */\n hasFilter,\n\n /**\n * Returns a flag indicating whether this hierarchy level has an ancestor node\n * that is a filter target. That generally means that this and all downstream hierarchy\n * levels should be displayed without filter being applied to them, even if filter paths\n * say otherwise.\n */\n hasFilterTargetAncestor: filteringProps?.hasFilterTargetAncestor ?? false,\n\n /**\n * Returns a list of hierarchy node identifiers that apply specifically for this\n * hierarchy level. Returns `undefined` if filtering is not applied to this level.\n */\n getChildNodeFilteringIdentifiers: () => {\n if (!hasFilter) {\n return undefined;\n }\n return filteringProps.filteredNodePaths\n .map(HierarchyFilteringPath.normalize)\n .filter(({ path }) => path.length > 0)\n .map(({ path }) => path[0]);\n },\n\n /**\n * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `filtering`\n * and `autoExpand`) to be set based on the filter paths and filtering options. This function calculates\n * these props for a child node based on its key or path matcher.\n *\n * When using `pathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies\n * to their node. For example, only some parts of the identifier can be checked for improved performance. Otherwise, the\n * `nodeKey` prop can be used to check the whole identifier.\n */\n createChildNodeProps: (\n props:\n | {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n }\n | {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n },\n ): Pick<HierarchyNode, \"autoExpand\" | \"filtering\"> | undefined => {\n if (!hasFilter) {\n return undefined;\n }\n const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);\n filteringProps.filteredNodePaths.forEach((filteredPath) => {\n const normalizedPath = HierarchyFilteringPath.normalize(filteredPath);\n if (\n \"nodeKey\" in props &&\n ((HierarchyNodeKey.isGeneric(props.nodeKey) && HierarchyNodeIdentifier.equal(normalizedPath.path[0], props.nodeKey)) ||\n (HierarchyNodeKey.isInstances(props.nodeKey) && props.nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier.equal(normalizedPath.path[0], ik))))\n ) {\n reducer.accept(normalizedPath);\n } else if (\"pathMatcher\" in props && props.pathMatcher(normalizedPath.path[0])) {\n reducer.accept(normalizedPath);\n }\n });\n return reducer.getNodeProps(parentNode);\n },\n\n /**\n * Similar to `createChildNodeProps`, but takes an async `pathMatcher` prop.\n */\n createChildNodePropsAsync: (props: {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): Promise<Pick<HierarchyNode, \"autoExpand\" | \"filtering\"> | undefined> | Pick<HierarchyNode, \"autoExpand\" | \"filtering\"> | undefined => {\n if (!hasFilter) {\n return undefined;\n }\n const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);\n const matchedPathPromises = new Array<Promise<NormalizedFilteringPath | undefined>>();\n for (const filteredChildrenNodeIdentifierPath of filteringProps.filteredNodePaths) {\n const normalizedPath = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);\n /* c8 ignore next 3 */\n if (normalizedPath.path.length === 0) {\n continue;\n }\n\n const matchesPossiblyPromise = props.pathMatcher(normalizedPath.path[0]);\n if (matchesPossiblyPromise instanceof Promise) {\n matchedPathPromises.push(matchesPossiblyPromise.then((matches) => (matches ? normalizedPath : undefined)));\n continue;\n }\n if (!matchesPossiblyPromise) {\n continue;\n }\n\n reducer.accept(normalizedPath);\n }\n if (matchedPathPromises.length === 0) {\n return reducer.getNodeProps(parentNode);\n }\n return Promise.all(matchedPathPromises)\n .then((matchedPath) => matchedPath.forEach((normalizedPath) => normalizedPath && reducer.accept(normalizedPath)))\n .then(() => reducer.getNodeProps(parentNode));\n },\n };\n}\n\ntype NormalizedFilteringPath = ReturnType<(typeof HierarchyFilteringPath)[\"normalize\"]>;\n\nclass MatchingFilteringPathsReducer {\n private _filteredChildrenIdentifierPaths = new Array<NormalizedFilteringPath>();\n private _isFilterTarget = false;\n private _filterTargetOptions = undefined as HierarchyFilteringPathOptions | undefined;\n private _autoExpandOption: HierarchyFilteringPathOptions[\"autoExpand\"] = false;\n\n public constructor(private _hasFilterTargetAncestor: boolean) {}\n\n public accept(normalizedPath: NormalizedFilteringPath): void {\n const { path, options } = normalizedPath;\n if (path.length === 1) {\n this._isFilterTarget = true;\n this._filterTargetOptions = HierarchyFilteringPath.mergeOptions(this._filterTargetOptions, options);\n } else if (path.length > 1) {\n this._filteredChildrenIdentifierPaths.push({ path: path.slice(1), options });\n this._autoExpandOption = HierarchyFilteringPathOptions.mergeAutoExpandOptions(options?.autoExpand, this._autoExpandOption);\n }\n }\n\n private getNeedsAutoExpand(parentNode: Pick<NonGroupingHierarchyNode, \"parentKeys\"> | undefined): boolean {\n if (this._autoExpandOption === true) {\n return true;\n }\n if (typeof this._autoExpandOption === \"object\") {\n const parentLength = !parentNode\n ? 0\n : \"depthInHierarchy\" in this._autoExpandOption\n ? 1 + parentNode.parentKeys.length\n : 1 + parentNode.parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length;\n const depth =\n \"depthInHierarchy\" in this._autoExpandOption\n ? this._autoExpandOption.depthInHierarchy\n : // With `depthInPath` option we don't want to expand node that is at the `depthInPath` position\n this._autoExpandOption.depthInPath - 1;\n\n return parentLength < depth;\n }\n return false;\n }\n\n public getNodeProps(parentNode: Pick<NonGroupingHierarchyNode, \"parentKeys\"> | undefined): Pick<HierarchyNode, \"autoExpand\" | \"filtering\"> {\n return {\n ...(this._hasFilterTargetAncestor || this._isFilterTarget || this._filteredChildrenIdentifierPaths.length > 0\n ? {\n filtering: {\n ...(this._hasFilterTargetAncestor ? { hasFilterTargetAncestor: true } : undefined),\n ...(this._isFilterTarget ? { isFilterTarget: true, filterTargetOptions: this._filterTargetOptions } : undefined),\n ...(this._filteredChildrenIdentifierPaths.length > 0 ? { filteredChildrenIdentifierPaths: this._filteredChildrenIdentifierPaths } : undefined),\n },\n }\n : undefined),\n ...(this.getNeedsAutoExpand(parentNode) ? { autoExpand: true } : undefined),\n };\n }\n}\n"]}
1
+ {"version":3,"file":"HierarchyFiltering.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyFiltering.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,uBAAuB,EAAgC,MAAM,8BAA8B,CAAC;AACrG,OAAO,EAAkB,gBAAgB,EAAoB,MAAM,uBAAuB,CAAC;AAsE3F,IAAU,6BAA6B,CAmCtC;AAnCD,WAAU,6BAA6B;IACrC,SAAgB,kBAAkB,CAChC,GAA4C,EAC5C,GAA4C;QAE5C,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACjB,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QAC3B,CAAC;QAED,MAAM,QAAQ,GAAG,aAAa,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC;QAC/E,MAAM,QAAQ,GAAG,aAAa,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CA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AAC,eAAe,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;wBAChH,GAAG,CAAC,IAAI,CAAC,gCAAgC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,+BAA+B,EAAE,IAAI,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;qBAC/I;iBACF;gBACH,CAAC,CAAC,SAAS,CAAC;YACd,GAAG,CAAC,UAAU;gBACd,CAAC,6BAA6B,CAAC;oBAC7B,MAAM,EAAE,IAAI,CAAC,aAAa;oBAC1B,uBAAuB,EAAE,UAAU,CAAC,MAAM;oBAC1C,kBAAkB,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,gBAAgB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM;iBACzF,CAAC;oBACA,CAAC,CAAC,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC;gBACxC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE;gBACtB,CAAC,CAAC,SAAS,CAAC;SACf,CAAC;IACJ,CAAC;CACF;AAED,gBAAgB;AAChB,MAAM,UAAU,6BAA6B,CAAC,EAC5C,MAAM,EACN,kBAAkB,EAClB,uBAAuB,GAKxB;IACC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,kBAAkB,IAAI,MAAM,EAAE,CAAC;QACjC,OAAO,uBAAuB,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAC3D,CAAC;IACD,OAAO,kBAAkB,GAAG,MAAM,CAAC,WAAW,CAAC;AACjD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { NonGroupingHierarchyNode } from \"./HierarchyNode.js\";\nimport { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from \"./HierarchyNodeIdentifier.js\";\nimport { GenericNodeKey, HierarchyNodeKey, InstancesNodeKey } from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport interface FilteringPathRevealDepthInPath {\n /**\n * Index of the node in filtering path should be revealed in hierarchy by auto-expanding its ancestors.\n *\n * Use when you want to expand up to specific instance node and don't care about grouping nodes.\n *\n * **Use case example:**\n *\n * All nodes up to `Element1` should be expanded in the following hierarchy:\n * - Node1\n * - GroupingNode1\n * - GroupingNode2\n * - Element1\n * - Element2\n *\n * Provide `{ path: [Node1, Element1], reveal: { depthInPath: 1 } }`\n *\n * **NOTE**: All nodes that are up to `depthInPath` will be expanded **except** filter targets.\n */\n depthInPath: number;\n}\n\n/** @public */\nexport interface FilteringPathRevealDepthInHierarchy {\n /**\n * 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.\n *\n * This should take into account the number of grouping nodes in hierarchy.\n *\n * **Use case example:**\n *\n * Only `Node1` and `GroupingNode1` should have `autoExpand` flag in the following hierarchy:\n * - Node1\n * - GroupingNode1\n * - GroupingNode2\n * - Element1\n * - Element2\n *\n * Provide `{ path: [Node1, Element1], reveal: { depthInHierarchy: 2 } }`\n *\n * To get the correct depth use `HierarchyNode.parentKeys.length`.\n *\n * **NOTE**: All nodes that are up to `depthInHierarchy` will be expanded **except** filter targets.\n */\n depthInHierarchy: number;\n}\n\n/** @public */\nexport interface HierarchyFilteringPathOptions {\n /**\n * This option specifies the way `autoExpand` flag should be assigned to nodes in the filtered hierarchy.\n * - If it's `false` or `undefined`, nodes have no 'autoExpand' flag.\n * - If it's `true`, then all nodes up to the filter target will have `autoExpand` flag.\n * - If it's an instance of `FilteringPathRevealDepthInPath`, then all nodes up to `depthInPath` will have `autoExpand` flag.\n * - If it's an instance of `FilteringPathRevealDepthInHierarchy`, then all nodes up to `depthInHierarchy` will have `autoExpand` flag.\n */\n reveal?: boolean | FilteringPathRevealDepthInHierarchy | FilteringPathRevealDepthInPath;\n /**\n * This option specifies whether or not filter target should be expanded.\n * - If it's `false` or `undefined`, filter target won't have 'autoExpand' flag.\n * - If it's `true`, filter target will have `autoExpand` flag.\n *\n * **NOTE**: this attribute does not set `autoExpand` flag on nodes up to the filter target. For that use `reveal`.\n */\n autoExpand?: boolean;\n}\n\nnamespace HierarchyFilteringPathOptions {\n export function mergeRevealOptions(\n lhs: HierarchyFilteringPathOptions[\"reveal\"],\n rhs: HierarchyFilteringPathOptions[\"reveal\"],\n ): HierarchyFilteringPathOptions[\"reveal\"] {\n if (rhs === true || lhs === true) {\n return true;\n }\n if (!rhs || !lhs) {\n return !!rhs ? rhs : lhs;\n }\n\n const lhsDepth = \"depthInPath\" in lhs ? lhs.depthInPath : lhs.depthInHierarchy;\n const rhsDepth = \"depthInPath\" in rhs ? rhs.depthInPath : rhs.depthInHierarchy;\n const isLhsDepthBasedOnPath = \"depthInPath\" in lhs;\n const isRhsDepthBasedOnPath = \"depthInPath\" in rhs;\n\n if (isLhsDepthBasedOnPath) {\n if (isRhsDepthBasedOnPath) {\n return lhsDepth > rhsDepth ? lhs : rhs;\n }\n return lhs;\n }\n if (isRhsDepthBasedOnPath) {\n return rhs;\n }\n return lhsDepth > rhsDepth ? lhs : rhs;\n }\n\n export function mergeAutoExpandOption(\n lhs: HierarchyFilteringPathOptions[\"autoExpand\"],\n rhs: HierarchyFilteringPathOptions[\"autoExpand\"],\n ): HierarchyFilteringPathOptions[\"autoExpand\"] {\n return lhs || rhs ? true : undefined;\n }\n}\n\n/**\n * A path of hierarchy node identifiers for filtering the hierarchy with additional options.\n * @public\n */\nexport type HierarchyFilteringPath = HierarchyNodeIdentifiersPath | { path: HierarchyNodeIdentifiersPath; options?: HierarchyFilteringPathOptions };\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyFilteringPath {\n /**\n * Normalizes the hierarchy filtering path to the object form.\n * @public\n */\n export function normalize(source: HierarchyFilteringPath): Exclude<HierarchyFilteringPath, HierarchyNodeIdentifiersPath> {\n if (Array.isArray(source)) {\n return { path: source };\n }\n return source;\n }\n\n /**\n * Merges two given `HierarchyFilteringPathOptions` objects.\n *\n * For the `reveal` attribute, the merge chooses to `reveal` as deep as the deepest input:\n * - if any one of the inputs is `true`, return `true`,\n * - else if only one of the inputs is an object, return it,\n * - else if both inputs are falsy, return `false` or `undefined`,\n * - else:\n * - if only one of the inputs has `depthInHierarchy` set, return the other one,\n * - else return the one with greater `depthInPath` or `depthInHierarchy`.\n *\n * @public\n */\n export function mergeOptions(\n lhs: HierarchyFilteringPathOptions | undefined,\n rhs: HierarchyFilteringPathOptions | undefined,\n ): HierarchyFilteringPathOptions | undefined {\n const reveal = HierarchyFilteringPathOptions.mergeRevealOptions(lhs?.reveal, rhs?.reveal);\n const autoExpand = HierarchyFilteringPathOptions.mergeAutoExpandOption(lhs?.autoExpand, rhs?.autoExpand);\n return reveal || autoExpand\n ? {\n ...(reveal !== undefined ? { reveal } : undefined),\n ...(autoExpand !== undefined ? { autoExpand } : undefined),\n }\n : undefined;\n }\n}\n\n/**\n * An utility that extracts filtering properties from given root level filtering props or\n * the parent node. Returns `undefined` if filtering props are not present.\n * @public\n * @deprecated in 1.3. Use `createHierarchyFilteringHelper` instead.\n */\n/* c8 ignore start */\nexport function extractFilteringProps(\n rootLevelFilteringProps: HierarchyFilteringPath[],\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n):\n | {\n filteredNodePaths: HierarchyFilteringPath[];\n hasFilterTargetAncestor: boolean;\n }\n | undefined {\n const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);\n return filteringProps?.filteredNodePaths !== undefined\n ? {\n filteredNodePaths: filteringProps.filteredNodePaths,\n hasFilterTargetAncestor: filteringProps.hasFilterTargetAncestor,\n }\n : undefined;\n}\n/* c8 ignore end */\n\nfunction extractFilteringPropsInternal(\n rootLevelFilteringProps: HierarchyFilteringPath[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n):\n | {\n filteredNodePaths?: HierarchyFilteringPath[];\n hasFilterTargetAncestor: boolean;\n }\n | undefined {\n if (!parentNode) {\n return rootLevelFilteringProps ? { filteredNodePaths: rootLevelFilteringProps, hasFilterTargetAncestor: false } : undefined;\n }\n const filteringProps: {\n filteredNodePaths?: HierarchyFilteringPath[];\n hasFilterTargetAncestor: boolean;\n } = {\n ...(parentNode.filtering?.filteredChildrenIdentifierPaths ? { filteredNodePaths: parentNode.filtering.filteredChildrenIdentifierPaths } : undefined),\n hasFilterTargetAncestor: !!parentNode.filtering?.hasFilterTargetAncestor || !!parentNode.filtering?.isFilterTarget,\n };\n return filteringProps.filteredNodePaths || filteringProps.hasFilterTargetAncestor ? filteringProps : undefined;\n}\n\n/**\n * Creates a set of utilities for making it easier to filter the given hierarchy\n * level.\n *\n * @public\n */\nexport function createHierarchyFilteringHelper(\n rootLevelFilteringProps: HierarchyFilteringPath[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n) {\n const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);\n const hasFilter = !!filteringProps;\n\n function saveFilteringPropsFromPathsIntoReducer(\n extractionProps: {\n pathsReducer: MatchingFilteringPathsReducer;\n } & (\n | {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n }\n | { pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean }\n ),\n ): void;\n function saveFilteringPropsFromPathsIntoReducer(extractionProps: {\n pathsReducer: MatchingFilteringPathsReducer;\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): void | Promise<void>;\n function saveFilteringPropsFromPathsIntoReducer(\n extractionProps: {\n pathsReducer: MatchingFilteringPathsReducer;\n } & (\n | {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n }\n | { pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean }\n | { asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean> }\n ),\n ): void | Promise<void> {\n // Passes down matching normalized paths to the reducer.\n // It uses `nodeKey`, `pathMatcher` or `asyncPathMatcher` to check if `HierarchyNodeIdentifier` at the first position in filtering path matches the node\n // and if it does, the path is passed down to the reducer.\n // This function returns a promise only if asyncPathMatcher returns a promise.\n if (!filteringProps?.filteredNodePaths) {\n return;\n }\n const matchedPathPromises = new Array<Promise<NormalizedFilteringPath | undefined>>();\n for (const filteredChildrenNodeIdentifierPath of filteringProps.filteredNodePaths) {\n const normalizedPath = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);\n /* c8 ignore next 3 */\n if (normalizedPath.path.length === 0) {\n continue;\n }\n if (\"nodeKey\" in extractionProps) {\n if (\n (HierarchyNodeKey.isGeneric(extractionProps.nodeKey) && HierarchyNodeIdentifier.equal(normalizedPath.path[0], extractionProps.nodeKey)) ||\n (HierarchyNodeKey.isInstances(extractionProps.nodeKey) &&\n extractionProps.nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier.equal(normalizedPath.path[0], ik)))\n ) {\n extractionProps.pathsReducer.accept(normalizedPath);\n }\n continue;\n }\n\n const matchesPossiblyPromise =\n \"pathMatcher\" in extractionProps ? extractionProps.pathMatcher(normalizedPath.path[0]) : extractionProps.asyncPathMatcher(normalizedPath.path[0]);\n if (matchesPossiblyPromise instanceof Promise) {\n matchedPathPromises.push(matchesPossiblyPromise.then((matches) => (matches ? normalizedPath : undefined)));\n continue;\n }\n if (matchesPossiblyPromise) {\n extractionProps.pathsReducer.accept(normalizedPath);\n }\n }\n if (matchedPathPromises.length === 0) {\n return;\n }\n return Promise.all(matchedPathPromises).then((matchedPath) =>\n matchedPath.forEach((normalizedPath) => normalizedPath && extractionProps.pathsReducer.accept(normalizedPath)),\n );\n }\n\n function createChildNodeProps(props: {\n parentKeys?: undefined;\n nodeKey: InstancesNodeKey | GenericNodeKey;\n }): Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined;\n function createChildNodeProps(props: {\n parentKeys?: undefined;\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }): Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined;\n function createChildNodeProps(props: {\n parentKeys?: undefined;\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): Promise<Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined> | Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined;\n function createChildNodeProps(props: {\n parentKeys: HierarchyNodeKey[];\n nodeKey: InstancesNodeKey | GenericNodeKey;\n }): Pick<NonGroupingHierarchyNode, \"filtering\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(props: {\n parentKeys: HierarchyNodeKey[];\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }): Pick<NonGroupingHierarchyNode, \"filtering\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(props: {\n parentKeys: HierarchyNodeKey[];\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): Promise<Pick<NonGroupingHierarchyNode, \"filtering\" | \"autoExpand\"> | undefined> | Pick<NonGroupingHierarchyNode, \"filtering\" | \"autoExpand\"> | undefined;\n function createChildNodeProps(\n props: { parentKeys?: HierarchyNodeKey[] } & (\n | {\n asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }\n | {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n }\n | {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n }\n ),\n ):\n | Promise<Pick<NonGroupingHierarchyNode, \"filtering\" | \"autoExpand\"> | Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined>\n | Pick<NonGroupingHierarchyNode, \"filtering\" | \"autoExpand\">\n | Pick<NonGroupingHierarchyNode, \"filtering\">\n | undefined {\n if (!hasFilter) {\n return undefined;\n }\n const reducer = new MatchingFilteringPathsReducer(filteringProps.hasFilterTargetAncestor);\n if (\"asyncPathMatcher\" in props) {\n const extractResult = saveFilteringPropsFromPathsIntoReducer({ pathsReducer: reducer, asyncPathMatcher: props.asyncPathMatcher });\n if (extractResult instanceof Promise) {\n return extractResult.then(() => reducer.getNodeProps(props.parentKeys));\n }\n } else {\n saveFilteringPropsFromPathsIntoReducer({ ...props, pathsReducer: reducer });\n }\n return reducer.getNodeProps(props.parentKeys);\n }\n return {\n /** Returns a flag indicating if the hierarchy level is filtered. */\n hasFilter,\n /**\n * Returns a flag indicating whether this hierarchy level has an ancestor node\n * that is a filter target. That generally means that this and all downstream hierarchy\n * levels should be displayed without filter being applied to them, even if filter paths\n * say otherwise.\n */\n hasFilterTargetAncestor: filteringProps?.hasFilterTargetAncestor ?? false,\n /**\n * Returns a list of hierarchy node identifiers that apply specifically for this\n * hierarchy level. Returns `undefined` if filtering is not applied to this level.\n */\n getChildNodeFilteringIdentifiers: () => {\n if (!filteringProps?.filteredNodePaths) {\n return undefined;\n }\n return filteringProps.filteredNodePaths\n .map(HierarchyFilteringPath.normalize)\n .filter(({ path }) => path.length > 0)\n .map(({ path }) => path[0]);\n },\n /**\n * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `filtering`\n * and `autoExpand`) to be set based on the filter paths and filtering options. This function calculates\n * these props for a child node based on its key or path matcher.\n *\n * When using `pathMatcher` or `asyncPathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies\n * to their node. For example, only some parts of the identifier can be checked for improved performance. Otherwise, the\n * `nodeKey` prop can be used to check the whole identifier.\n *\n * There are multiple overloads of `createChildNodeProps`: depending on props type it returns different values:\n * - `parentKeys` is defined and `pathMatcher` or `nodeKey` is provided - returns undefined **or** `filtering` and `autoExpand` prop from `HierarchyNode`;\n * - `parentKeys` is undefined - does not return `HierarchyNode.autoExpand` option;\n * - props have `asyncPathMatcher` - returns either Promise or the regular return value based on whether or not `asyncPathMatcher` returns a promise.\n */\n createChildNodeProps,\n };\n}\n\ntype NormalizedFilteringPath = ReturnType<(typeof HierarchyFilteringPath)[\"normalize\"]>;\n\n/**\n * Extracts information from filtering paths and later returns `filtering` and `autoExpand` values from `HierarchyNode`.\n *\n * Saved values can be applied to a single `HierarchyNode` - this means that a new reducer should be created every time these props are requested for a `HierarchyNode`.\n *\n * Extracts information using `accept` function:\n * - Determines if node is filter target, and if it is saves the options as `filterTargetOptions`\n * - Saves `HierarchyFilteringPathOptions` and `filteredChildrenIdentifierPaths`\n */\nclass MatchingFilteringPathsReducer {\n private _filteredChildrenIdentifierPaths = new Array<NormalizedFilteringPath>();\n private _isFilterTarget = false;\n private _filterTargetOptions: HierarchyFilteringPathOptions | undefined = undefined;\n private _revealOption: HierarchyFilteringPathOptions[\"reveal\"] = false;\n\n public constructor(private _hasFilterTargetAncestor: boolean) {}\n\n public accept(normalizedPath: NormalizedFilteringPath): void {\n const { path, options } = normalizedPath;\n if (path.length === 1) {\n this._isFilterTarget = true;\n this._filterTargetOptions = HierarchyFilteringPath.mergeOptions(this._filterTargetOptions, options);\n } else if (path.length > 1) {\n this._filteredChildrenIdentifierPaths.push({ path: path.slice(1), options });\n this._revealOption = HierarchyFilteringPathOptions.mergeRevealOptions(options?.reveal, this._revealOption);\n }\n }\n\n public getNodeProps<T extends HierarchyNodeKey[] | undefined = undefined>(\n parentKeys?: T,\n ): T extends undefined ? Pick<NonGroupingHierarchyNode, \"filtering\"> : Pick<NonGroupingHierarchyNode, \"filtering\" | \"autoExpand\"> {\n return {\n ...(this._hasFilterTargetAncestor || this._isFilterTarget || this._filteredChildrenIdentifierPaths.length > 0\n ? {\n filtering: {\n ...(this._hasFilterTargetAncestor ? { hasFilterTargetAncestor: true } : undefined),\n ...(this._isFilterTarget ? { isFilterTarget: true, filterTargetOptions: this._filterTargetOptions } : undefined),\n ...(this._filteredChildrenIdentifierPaths.length > 0 ? { filteredChildrenIdentifierPaths: this._filteredChildrenIdentifierPaths } : undefined),\n },\n }\n : undefined),\n ...(parentKeys &&\n (shouldAutoExpandBasedOnReveal({\n reveal: this._revealOption,\n nodePositionInHierarchy: parentKeys.length,\n nodePositionInPath: parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length,\n }) ||\n !!this._filterTargetOptions?.autoExpand)\n ? { autoExpand: true }\n : undefined),\n };\n }\n}\n\n/** @internal */\nexport function shouldAutoExpandBasedOnReveal({\n reveal,\n nodePositionInPath,\n nodePositionInHierarchy,\n}: {\n reveal: HierarchyFilteringPathOptions[\"reveal\"];\n nodePositionInPath: number;\n nodePositionInHierarchy: number;\n}): boolean {\n if (!reveal) {\n return false;\n }\n if (reveal === true) {\n return true;\n }\n if (\"depthInHierarchy\" in reveal) {\n return nodePositionInHierarchy < reveal.depthInHierarchy;\n }\n return nodePositionInPath < reveal.depthInPath;\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import "./internal/DisposePolyfill.js";
2
+ import { HierarchyProvider } from "./HierarchyProvider.js";
3
+ /**
4
+ * Props for `mergeProviders` function.
5
+ * @public
6
+ */
7
+ interface MergeHierarchyProvidersProps {
8
+ /** List of providers to merge. */
9
+ providers: HierarchyProvider[];
10
+ }
11
+ /**
12
+ * Creates a single, merged, hierarchy provider from multiple given providers.
13
+ * @public
14
+ */
15
+ export declare function mergeProviders({ providers }: MergeHierarchyProvidersProps): HierarchyProvider & {
16
+ [Symbol.dispose]: () => void;
17
+ };
18
+ export {};
19
+ //# sourceMappingURL=HierarchyMerge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HierarchyMerge.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyMerge.ts"],"names":[],"mappings":"AAKA,OAAO,+BAA+B,CAAC;AAIvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAK3D;;;GAGG;AACH,UAAU,4BAA4B;IACpC,kCAAkC;IAClC,SAAS,EAAE,iBAAiB,EAAE,CAAC;CAChC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,SAAS,EAAE,EAAE,4BAA4B,GAAG,iBAAiB,GAAG;IAC/F,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B,CAyCA"}
@@ -0,0 +1,40 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import "./internal/DisposePolyfill.js";
6
+ import { filter, first, from, map, mergeMap, of } from "rxjs";
7
+ import { BeEvent } from "@itwin/core-bentley";
8
+ import { safeDispose } from "./internal/Common.js";
9
+ import { eachValueFrom } from "./internal/EachValueFrom.js";
10
+ import { sortNodesByLabelOperator } from "./internal/operators/Sorting.js";
11
+ /**
12
+ * Creates a single, merged, hierarchy provider from multiple given providers.
13
+ * @public
14
+ */
15
+ export function mergeProviders({ providers }) {
16
+ const hierarchyChanged = new BeEvent();
17
+ providers.forEach((p) => {
18
+ p.hierarchyChanged.addListener(() => hierarchyChanged.raiseEvent());
19
+ });
20
+ const dispose = () => {
21
+ hierarchyChanged.clear();
22
+ providers.forEach((p) => safeDispose(p));
23
+ };
24
+ return {
25
+ hierarchyChanged,
26
+ getNodes: (props) => eachValueFrom(from(providers).pipe(mergeMap((provider) => from(provider.getNodes(props)).pipe(mergeMap((node) => {
27
+ if (node.children) {
28
+ return of(node);
29
+ }
30
+ // each provider only considers its own data when determining node's children - in case it says
31
+ // the node has no children, we have to check against the other providers too
32
+ return from(providers).pipe(filter((p) => p !== provider), mergeMap((p) => p.getNodes({ parentNode: node })), map(() => true), first(undefined, false), map((hasChildren) => ({ ...node, children: hasChildren })));
33
+ }))), sortNodesByLabelOperator)),
34
+ getNodeInstanceKeys: (props) => eachValueFrom(from(providers).pipe(mergeMap((p) => p.getNodeInstanceKeys(props)))),
35
+ setFormatter: (formatter) => providers.forEach((p) => p.setFormatter(formatter)),
36
+ setHierarchyFilter: (props) => providers.forEach((p) => p.setHierarchyFilter(props)),
37
+ [Symbol.dispose]: dispose,
38
+ };
39
+ }
40
+ //# sourceMappingURL=HierarchyMerge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HierarchyMerge.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyMerge.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,+BAA+B,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAW3E;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,SAAS,EAAgC;IAGxE,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAAc,CAAC;IACnD,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACtB,CAAC,CAAC,gBAAgB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,gBAAgB,CAAC,KAAK,EAAE,CAAC;QACzB,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC;IAEF,OAAO;QACL,gBAAgB;QAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAClB,aAAa,CACX,IAA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AAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QACpF,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"./internal/DisposePolyfill.js\";\n\nimport { filter, first, from, map, mergeMap, of } from \"rxjs\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { HierarchyProvider } from \"./HierarchyProvider.js\";\nimport { safeDispose } from \"./internal/Common.js\";\nimport { eachValueFrom } from \"./internal/EachValueFrom.js\";\nimport { sortNodesByLabelOperator } from \"./internal/operators/Sorting.js\";\n\n/**\n * Props for `mergeProviders` function.\n * @public\n */\ninterface MergeHierarchyProvidersProps {\n /** List of providers to merge. */\n providers: HierarchyProvider[];\n}\n\n/**\n * Creates a single, merged, hierarchy provider from multiple given providers.\n * @public\n */\nexport function mergeProviders({ providers }: MergeHierarchyProvidersProps): HierarchyProvider & {\n [Symbol.dispose]: () => void;\n} {\n const hierarchyChanged = new BeEvent<() => void>();\n providers.forEach((p) => {\n p.hierarchyChanged.addListener(() => hierarchyChanged.raiseEvent());\n });\n const dispose = () => {\n hierarchyChanged.clear();\n providers.forEach((p) => safeDispose(p));\n };\n\n return {\n hierarchyChanged,\n getNodes: (props) =>\n eachValueFrom(\n from(providers).pipe(\n mergeMap((provider) =>\n from(provider.getNodes(props)).pipe(\n mergeMap((node) => {\n if (node.children) {\n return of(node);\n }\n // each provider only considers its own data when determining node's children - in case it says\n // the node has no children, we have to check against the other providers too\n return from(providers).pipe(\n filter((p) => p !== provider),\n mergeMap((p) => p.getNodes({ parentNode: node })),\n map(() => true),\n first(undefined, false),\n map((hasChildren) => ({ ...node, children: hasChildren })),\n );\n }),\n ),\n ),\n sortNodesByLabelOperator,\n ),\n ),\n getNodeInstanceKeys: (props) => eachValueFrom(from(providers).pipe(mergeMap((p) => p.getNodeInstanceKeys(props)))),\n setFormatter: (formatter) => providers.forEach((p) => p.setFormatter(formatter)),\n setHierarchyFilter: (props) => providers.forEach((p) => p.setHierarchyFilter(props)),\n [Symbol.dispose]: dispose,\n };\n}\n"]}
@@ -43,8 +43,6 @@ interface BaseHierarchyNode {
43
43
  extendedData?: {
44
44
  [key: string]: any;
45
45
  };
46
- /** Data that may be assigned to the node if filtering is enabled */
47
- filtering?: HierarchyNodeFilteringProps;
48
46
  }
49
47
  /**
50
48
  * A data structure that represents a single non-grouping hierarchy node.
@@ -58,6 +56,8 @@ export interface NonGroupingHierarchyNode extends BaseHierarchyNode {
58
56
  * filter when requesting child hierarchy level will have no effect.
59
57
  */
60
58
  supportsFiltering?: boolean;
59
+ /** Data that may be assigned to the node if filtering is enabled */
60
+ filtering?: HierarchyNodeFilteringProps;
61
61
  }
62
62
  /**
63
63
  * A data structure that represents a grouping node that groups other nodes.
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyNode.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNode.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAChG,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,kCAAkC,EAClC,4BAA4B,EAC5B,iCAAiC,EAClC,MAAM,uBAAuB,CAAC;AAE/B,cAAc;AACd,MAAM,MAAM,2BAA2B,GAAG;IACxC,4FAA4F;IAC5F,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,wDAAwD;IACxD,+BAA+B,CAAC,EAAE,sBAAsB,EAAE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D,CAAC;IAJe,iCAAmB,sBAIlC,CAAA;IACD,6DAA6D;IAC7D,SAAgB,mBAAmB,CACjC,IAAW;QAEX,OAAO,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IAJe,iCAAmB,sBAIlC,CAAA;IACD,gFAAgF;IAChF,SAAgB,iCAAiC,CAC/C,IAAW;QAEX,OAAO,gBAAgB,CAAC,6BAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClE,CAAC;IAJe,+CAAiC,oCAIhD,CAAA;IACD,sEAAsE;IACtE,SAAgB,2BAA2B,CACzC,IAAW;QAEX,OAAO,gBAAgB,CAAC,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IAJe,yCAA2B,8BAI1C,CAAA;IACD,4EAA4E;IAC5E,SAAgB,gCAAgC,CAC9C,IAAW;QAEX,OAAO,gBAAgB,CAAC,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjE,CAAC;IAJe,8CAAgC,mCAI/C,CAAA;IACD,gEAAgE;IAChE,SAAgB,sBAAsB,CACpC,IAAW;QAEX,OAAO,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC;IAJe,oCAAsB,yBAIrC,CAAA;AACH,CAAC,EArDgB,aAAa,KAAb,aAAa,QAqD7B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { OmitOverUnion } from \"@itwin/presentation-shared\";\nimport { HierarchyFilteringPath, HierarchyFilteringPathOptions } from \"./HierarchyFiltering.js\";\nimport {\n ClassGroupingNodeKey,\n GenericNodeKey,\n GroupingNodeKey,\n HierarchyNodeKey,\n IModelHierarchyNodeKey,\n IModelInstanceKey,\n InstancesNodeKey,\n LabelGroupingNodeKey,\n PropertyGroupingNodeKey,\n PropertyOtherValuesGroupingNodeKey,\n PropertyValueGroupingNodeKey,\n PropertyValueRangeGroupingNodeKey,\n} from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport type HierarchyNodeFilteringProps = {\n /** If set to true, then one of the ancestor nodes in the hierarchy is the filter target. */\n hasFilterTargetAncestor?: boolean;\n /** Paths to node's children that are filter targets. */\n filteredChildrenIdentifierPaths?: HierarchyFilteringPath[];\n} & (\n | {\n /** Whether or not this node is a filter target. */\n isFilterTarget?: false;\n }\n | {\n /** Whether or not this node is a filter target. */\n isFilterTarget: true;\n /** Options that were used to filter the node. */\n filterTargetOptions?: HierarchyFilteringPathOptions;\n }\n);\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNodeFilteringProps {\n /** @deprecated in 1.3. Use `createHierarchyFilteringHelper` and its `createChildNodeProps` function to create filtering props for nodes. */\n /* c8 ignore start */\n export function create(props: {\n hasFilterTargetAncestor?: boolean;\n filteredChildrenIdentifierPaths?: HierarchyFilteringPath[];\n isFilterTarget?: boolean;\n filterTargetOptions?: HierarchyFilteringPathOptions;\n }): HierarchyNodeFilteringProps | undefined {\n const { hasFilterTargetAncestor, filteredChildrenIdentifierPaths, isFilterTarget, filterTargetOptions } = props;\n if (isFilterTarget || hasFilterTargetAncestor || filteredChildrenIdentifierPaths?.length) {\n return {\n ...(isFilterTarget ? { isFilterTarget, filterTargetOptions } : undefined),\n ...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),\n ...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),\n };\n }\n return undefined;\n }\n /* c8 ignore end */\n}\n\n/**\n * A data structure that defines attributes that are common to all types of hierarchy nodes.\n * @public\n */\ninterface BaseHierarchyNode {\n /** Identifiers of all node ancestors. Can be used to identify a node in the hierarchy. */\n parentKeys: HierarchyNodeKey[];\n /** Node's display label. */\n label: string;\n /** A flag indicating whether the node has children or not. */\n children: boolean;\n /** A flag indicating whether this node should be auto-expanded in the UI. */\n autoExpand?: boolean;\n /** Additional data that may be assigned to this node. */\n extendedData?: { [key: string]: any };\n /** Data that may be assigned to the node if filtering is enabled */\n filtering?: HierarchyNodeFilteringProps;\n}\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n * @public\n */\nexport interface NonGroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify the node in its hierarchy level. */\n key: GenericNodeKey | InstancesNodeKey;\n /**\n * Identifies whether the hierarchy level below this node supports filtering. If not, supplying an instance\n * filter when requesting child hierarchy level will have no effect.\n */\n supportsFiltering?: boolean;\n}\n\n/**\n * A data structure that represents a grouping node that groups other nodes.\n * @public\n */\nexport interface GroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify this grouping node in its hierarchy level. */\n key: GroupingNodeKey;\n\n /**\n * Keys of all instances grouped by this node, including deeply nested under\n * other grouping nodes.\n */\n groupedInstanceKeys: IModelInstanceKey[];\n\n /** The closest ancestor node that is not a grouping node. May be `undefined` if the grouping node grouped root level nodes. */\n nonGroupingAncestor?: ParentHierarchyNode<NonGroupingHierarchyNode>;\n}\n\n/**\n * A data structure that represents a single hierarchy node.\n * @public\n */\nexport type HierarchyNode = NonGroupingHierarchyNode | GroupingHierarchyNode;\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNode {\n /** Checks whether the given node is a generic node */\n export function isGeneric<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & NonGroupingHierarchyNode & { key: GenericNodeKey } {\n return HierarchyNodeKey.isGeneric(node.key);\n }\n /** Checks whether the given node is a standard (iModel content based) node */\n export function isIModelNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & { key: IModelHierarchyNodeKey } {\n return HierarchyNodeKey.isIModelNodeKey(node.key);\n }\n /** Checks whether the given node is an ECInstances-based node */\n export function isInstancesNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & NonGroupingHierarchyNode & { key: InstancesNodeKey } {\n return HierarchyNodeKey.isInstances(node.key);\n }\n /** Checks whether the given node is a grouping node */\n export function isGroupingNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & GroupingHierarchyNode {\n return HierarchyNodeKey.isGrouping(node.key);\n }\n /** Checks whether the given node is a class grouping node */\n export function isClassGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: ClassGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isClassGrouping(node.key);\n }\n /** Checks whether the given node is a label grouping node */\n export function isLabelGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: LabelGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isLabelGrouping(node.key);\n }\n /** Checks whether the given node is property grouping node for other values */\n export function isPropertyOtherValuesGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyOtherValuesGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyOtherValuesGrouping(node.key);\n }\n /** Checks whether the given node is a property value grouping node */\n export function isPropertyValueGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyValueGrouping(node.key);\n }\n /** Checks whether the given node is a property value range grouping node */\n export function isPropertyValueRangeGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueRangeGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyValueRangeGrouping(node.key);\n }\n /** Checks whether the given node is a property grouping node */\n export function isPropertyGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyGrouping(node.key);\n }\n}\n\n/**\n * A type of `HierarchyNode` that doesn't know about its children and is an input when requesting\n * them using `HierarchyProvider.getNodes`.\n * @public\n */\nexport type ParentHierarchyNode<TBase = HierarchyNode> = OmitOverUnion<TBase, \"children\">;\n"]}
1
+ {"version":3,"file":"HierarchyNode.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAIhG,OAAO,EAIL,gBAAgB,GASjB,MAAM,uBAAuB,CAAC;AAoB/B,cAAc;AACd,2DAA2D;AAC3D,MAAM,KAAW,2BAA2B,CAoB3C;AApBD,WAAiB,2BAA2B;IAC1C,4IAA4I;IAC5I,qBAAqB;IACrB,SAAgB,MAAM,CAAC,KAKtB;QACC,MAAM,EAAE,uBAAuB,EAAE,+BAA+B,EAAE,cAAc,EAAE,mBAAmB,EAAE,GAAG,KAAK,CAAC;QAChH,IAAI,cAAc,IAAI,uBAAuB,IAAI,+BAA+B,EAAE,MAAM,EAAE,CAAC;YACzF,OAAO;gBACL,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBACzE,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,uBAAuB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBACtE,GAAG,CAAC,CAAC,CAAC,+BAA+B,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,+BAA+B,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;aACjG,CAAC;QACJ,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAfe,kCAAM,SAerB,CAAA;IACD,mBAAmB;AACrB,CAAC,EApBgB,2BAA2B,KAA3B,2BAA2B,QAoB3C;AA2DD,cAAc;AACd,2DAA2D;AAC3D,MAAM,KAAW,aAAa,CAqD7B;AArD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C5D,CAAC;IAJe,yCAA2B,8BAI1C,CAAA;IACD,4EAA4E;IAC5E,SAAgB,gCAAgC,CAC9C,IAAW;QAEX,OAAO,gBAAgB,CAAC,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjE,CAAC;IAJe,8CAAgC,mCAI/C,CAAA;IACD,gEAAgE;IAChE,SAAgB,sBAAsB,CACpC,IAAW;QAEX,OAAO,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC;IAJe,oCAAsB,yBAIrC,CAAA;AACH,CAAC,EArDgB,aAAa,KAAb,aAAa,QAqD7B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { OmitOverUnion } from \"@itwin/presentation-shared\";\nimport { HierarchyFilteringPath, HierarchyFilteringPathOptions } from \"./HierarchyFiltering.js\";\nimport {\n ClassGroupingNodeKey,\n GenericNodeKey,\n GroupingNodeKey,\n HierarchyNodeKey,\n IModelHierarchyNodeKey,\n IModelInstanceKey,\n InstancesNodeKey,\n LabelGroupingNodeKey,\n PropertyGroupingNodeKey,\n PropertyOtherValuesGroupingNodeKey,\n PropertyValueGroupingNodeKey,\n PropertyValueRangeGroupingNodeKey,\n} from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport type HierarchyNodeFilteringProps = {\n /** If set to true, then one of the ancestor nodes in the hierarchy is the filter target. */\n hasFilterTargetAncestor?: boolean;\n /** Paths to node's children that are filter targets. */\n filteredChildrenIdentifierPaths?: HierarchyFilteringPath[];\n} & (\n | {\n /** Whether or not this node is a filter target. */\n isFilterTarget?: false;\n }\n | {\n /** Whether or not this node is a filter target. */\n isFilterTarget: true;\n /** Options that were used to filter the node. */\n filterTargetOptions?: HierarchyFilteringPathOptions;\n }\n);\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNodeFilteringProps {\n /** @deprecated in 1.3. Use `createHierarchyFilteringHelper` and its `createChildNodeProps` function to create filtering props for nodes. */\n /* c8 ignore start */\n export function create(props: {\n hasFilterTargetAncestor?: boolean;\n filteredChildrenIdentifierPaths?: HierarchyFilteringPath[];\n isFilterTarget?: boolean;\n filterTargetOptions?: HierarchyFilteringPathOptions;\n }): HierarchyNodeFilteringProps | undefined {\n const { hasFilterTargetAncestor, filteredChildrenIdentifierPaths, isFilterTarget, filterTargetOptions } = props;\n if (isFilterTarget || hasFilterTargetAncestor || filteredChildrenIdentifierPaths?.length) {\n return {\n ...(isFilterTarget ? { isFilterTarget, filterTargetOptions } : undefined),\n ...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),\n ...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),\n };\n }\n return undefined;\n }\n /* c8 ignore end */\n}\n\n/**\n * A data structure that defines attributes that are common to all types of hierarchy nodes.\n * @public\n */\ninterface BaseHierarchyNode {\n /** Identifiers of all node ancestors. Can be used to identify a node in the hierarchy. */\n parentKeys: HierarchyNodeKey[];\n /** Node's display label. */\n label: string;\n /** A flag indicating whether the node has children or not. */\n children: boolean;\n /** A flag indicating whether this node should be auto-expanded in the UI. */\n autoExpand?: boolean;\n /** Additional data that may be assigned to this node. */\n extendedData?: { [key: string]: any };\n}\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n * @public\n */\nexport interface NonGroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify the node in its hierarchy level. */\n key: GenericNodeKey | InstancesNodeKey;\n /**\n * Identifies whether the hierarchy level below this node supports filtering. If not, supplying an instance\n * filter when requesting child hierarchy level will have no effect.\n */\n supportsFiltering?: boolean;\n /** Data that may be assigned to the node if filtering is enabled */\n filtering?: HierarchyNodeFilteringProps;\n}\n\n/**\n * A data structure that represents a grouping node that groups other nodes.\n * @public\n */\nexport interface GroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify this grouping node in its hierarchy level. */\n key: GroupingNodeKey;\n\n /**\n * Keys of all instances grouped by this node, including deeply nested under\n * other grouping nodes.\n */\n groupedInstanceKeys: IModelInstanceKey[];\n\n /** The closest ancestor node that is not a grouping node. May be `undefined` if the grouping node grouped root level nodes. */\n nonGroupingAncestor?: ParentHierarchyNode<NonGroupingHierarchyNode>;\n}\n\n/**\n * A data structure that represents a single hierarchy node.\n * @public\n */\nexport type HierarchyNode = NonGroupingHierarchyNode | GroupingHierarchyNode;\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNode {\n /** Checks whether the given node is a generic node */\n export function isGeneric<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & NonGroupingHierarchyNode & { key: GenericNodeKey } {\n return HierarchyNodeKey.isGeneric(node.key);\n }\n /** Checks whether the given node is a standard (iModel content based) node */\n export function isIModelNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & { key: IModelHierarchyNodeKey } {\n return HierarchyNodeKey.isIModelNodeKey(node.key);\n }\n /** Checks whether the given node is an ECInstances-based node */\n export function isInstancesNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & NonGroupingHierarchyNode & { key: InstancesNodeKey } {\n return HierarchyNodeKey.isInstances(node.key);\n }\n /** Checks whether the given node is a grouping node */\n export function isGroupingNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & GroupingHierarchyNode {\n return HierarchyNodeKey.isGrouping(node.key);\n }\n /** Checks whether the given node is a class grouping node */\n export function isClassGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: ClassGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isClassGrouping(node.key);\n }\n /** Checks whether the given node is a label grouping node */\n export function isLabelGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: LabelGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isLabelGrouping(node.key);\n }\n /** Checks whether the given node is property grouping node for other values */\n export function isPropertyOtherValuesGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyOtherValuesGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyOtherValuesGrouping(node.key);\n }\n /** Checks whether the given node is a property value grouping node */\n export function isPropertyValueGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyValueGrouping(node.key);\n }\n /** Checks whether the given node is a property value range grouping node */\n export function isPropertyValueRangeGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueRangeGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyValueRangeGrouping(node.key);\n }\n /** Checks whether the given node is a property grouping node */\n export function isPropertyGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyGrouping(node.key);\n }\n}\n\n/**\n * A type of `HierarchyNode` that doesn't know about its children and is an input when requesting\n * them using `HierarchyProvider.getNodes`.\n * @public\n */\nexport type ParentHierarchyNode<TBase = HierarchyNode> = OmitOverUnion<TBase, \"children\">;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyNodeKey.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNodeKey.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;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