@itwin/presentation-hierarchies 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # @itwin/presentation-hierarchies
2
2
 
3
+ ## 1.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8f7d200926b93e862276e1f978f6c891691e0dae: Refactored specifying the depth / level to which filtering path should be auto-expanded.
8
+
9
+ - Deprecated `FilteringPathAutoExpandOption` and `FilterTargetGroupingNodeInfo`.
10
+ - Added `FilteringPathAutoExpandDepthInPath` and `FilteringPathAutoExpandDepthInHierarchy` which should be used instead.
11
+
12
+ Migration:
13
+
14
+ ```ts
15
+ const pathExpandedToInstanceInPath: HierarchyFilteringPath = {
16
+ path: [instanceKey1, instanceKey2, instanceKey3],
17
+ options: {
18
+ // deprecated:
19
+ autoExpand: { depth: 1 },
20
+ // do this instead:
21
+ autoExpand: { depthInPath: 1 },
22
+ },
23
+ };
24
+
25
+ const pathExpandedToGroupingNode: HierarchyFilteringPath = {
26
+ path: [instanceKey1, instanceKey2, instanceKey3],
27
+ options: {
28
+ // deprecated:
29
+ autoExpand: { depth: 1, key: groupingNodeKey },
30
+ // also deprecated:
31
+ autoExpand: { depth: 1, includeGroupingNodes: true },
32
+ // do this instead:
33
+ autoExpand: { depthInHierarchy: 1 },
34
+ },
35
+ };
36
+ ```
37
+
38
+ ## 1.6.1
39
+
40
+ ### Patch Changes
41
+
42
+ - [#1010](https://github.com/iTwin/presentation/pull/1010): Fixed `HierarchyFilteringPathOptions.autoExpand` depth option not working properly with grouping nodes. Added `includeGroupingNodes` attribute to `FilteringPathAutoExpandOption`, which allows auto-expanding only desired gouping nodes, when set together with `depth` value.
43
+
3
44
  ## 1.6.0
4
45
 
5
46
  ### Minor Changes
@@ -1,24 +1,83 @@
1
1
  import { HierarchyNode, NonGroupingHierarchyNode } from "./HierarchyNode.js";
2
2
  import { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from "./HierarchyNodeIdentifier.js";
3
3
  import { GenericNodeKey, GroupingNodeKey, InstancesNodeKey } from "./HierarchyNodeKey.js";
4
- /** @public */
4
+ /**
5
+ * @public
6
+ * @deprecated in 1.7. Use `FilteringPathAutoExpandDepthInHierarchy` instead.
7
+ */
5
8
  export interface FilterTargetGroupingNodeInfo {
6
9
  /**
7
10
  * Key of the grouping node.
8
- * @deprecated in 1.6. This option is no longer needed.
11
+ * @deprecated in 1.6. Use `FilteringPathAutoExpandDepthInHierarchy` instead.
9
12
  */
10
13
  key: GroupingNodeKey;
11
14
  /**
12
15
  * Depth up to which nodes in the hierarchy should be expanded.
16
+ * @deprecated in 1.6. Use `FilteringPathAutoExpandDepthInHierarchy` instead.
13
17
  */
14
18
  depth: number;
15
19
  }
16
- /** @public */
20
+ /**
21
+ * @public
22
+ * @deprecated in 1.7. Use `FilteringPathAutoExpandDepthInPath` or `FilteringPathAutoExpandDepthInHierarchy` instead.
23
+ */
17
24
  export interface FilteringPathAutoExpandOption {
18
25
  /**
19
26
  * Depth up to which nodes in the hierarchy should be expanded.
27
+ *
28
+ * If `includeGroupingNodes` is set to true, then depth should take into account the number of grouping nodes in hierarchy.
29
+ * @deprecated in 1.7. Use `FilteringPathAutoExpandDepthInPath` or `FilteringPathAutoExpandDepthInHierarchy` instead.
20
30
  */
21
31
  depth: number;
32
+ /**
33
+ * Whether or not `depth` includes grouping nodes.
34
+ *
35
+ * Use when you want to autoExpand only some of the grouping nodes.
36
+ *
37
+ * **Use case example:**
38
+ *
39
+ * You want to `autoExpand` only `Node1` and `GroupingNode1` in the following hierarchy:
40
+ * - Node1
41
+ * - GroupingNode1
42
+ * - GroupingNode2
43
+ * - Element1
44
+ * - Element2
45
+ * Then you provide `autoExpand: { depth: 2, includeGroupingNodes: true }`
46
+ *
47
+ * To get the correct depth use `HierarchyNode.parentKeys.length`.
48
+ * @deprecated in 1.7. Use `FilteringPathAutoExpandDepthInHierarchy` instead.
49
+ */
50
+ includeGroupingNodes?: boolean;
51
+ }
52
+ /** @public */
53
+ export interface FilteringPathAutoExpandDepthInPath {
54
+ /**
55
+ * Depth up to which nodes in the filtering path should be expanded.
56
+ *
57
+ * Use when you want to expand up to specific instance node and don't care about grouping nodes.
58
+ */
59
+ depthInPath: number;
60
+ }
61
+ /** @public */
62
+ export interface FilteringPathAutoExpandDepthInHierarchy {
63
+ /**
64
+ * Depth up to which nodes in the hierarchy should be expanded.
65
+ *
66
+ * This should take into account the number of grouping nodes in hierarchy.
67
+ *
68
+ * * **Use case example:**
69
+ *
70
+ * You want to `autoExpand` only `Node1` and `GroupingNode1` in the following hierarchy:
71
+ * - Node1
72
+ * - GroupingNode1
73
+ * - GroupingNode2
74
+ * - Element1
75
+ * - Element2
76
+ * Then you provide `autoExpand: { depthInHierarchy: 2 }`
77
+ *
78
+ * To get the correct depth use `HierarchyNode.parentKeys.length`.
79
+ */
80
+ depthInHierarchy: number;
22
81
  }
23
82
  /** @public */
24
83
  export interface HierarchyFilteringPathOptions {
@@ -29,8 +88,10 @@ export interface HierarchyFilteringPathOptions {
29
88
  * - If it's an instance of `FilterTargetGroupingNodeInfo`, then all nodes up to the grouping node that matches this property,
30
89
  * will have `autoExpand` flag.
31
90
  * - If it's an instance of `FilteringPathAutoExpandOption`, then all nodes up to and including `depth` will have `autoExpand` flag.
91
+ * - If it's an instance of `FilteringPathAutoExpandDepthInPath`, then all nodes up to and including `depthInPath` will have `autoExpand` flag.
92
+ * - If it's an instance of `FilteringPathAutoExpandDepthInHierarchy`, then all nodes up to and including `depthInHierarchy` will have `autoExpand` flag.
32
93
  */
33
- autoExpand?: boolean | FilterTargetGroupingNodeInfo | FilteringPathAutoExpandOption;
94
+ autoExpand?: boolean | FilterTargetGroupingNodeInfo | FilteringPathAutoExpandOption | FilteringPathAutoExpandDepthInHierarchy | FilteringPathAutoExpandDepthInPath;
34
95
  }
35
96
  /**
36
97
  * A path of hierarchy node identifiers for filtering the hierarchy with additional options.
@@ -55,9 +116,11 @@ export declare namespace HierarchyFilteringPath {
55
116
  *
56
117
  * For the `autoExpand` attribute, the merge chooses to auto-expand as deep as the deepest input:
57
118
  * - if any one of the inputs is `true`, return `true`,
58
- * - else if both inputs are objects, return the one with the greater `depth` attribute.
59
- * - else if one input is an object, return it.
60
- * - else, return `false` or `undefined`.
119
+ * - else if only one of the inputs is an object, return it,
120
+ * - else if both inputs are falsy, return `false` or `undefined`,
121
+ * - else:
122
+ * - if only one of the inputs has `includeGroupingNodes` set to `true` or `key` defined or `depthInHierarchy` set, return the other one,
123
+ * - else return the one with greater `depth`, `depthInPath` or `depthInHierarchy`.
61
124
  *
62
125
  * @public
63
126
  */
@@ -79,7 +142,7 @@ export declare function extractFilteringProps(rootLevelFilteringProps: Hierarchy
79
142
  *
80
143
  * @public
81
144
  */
82
- export declare function createHierarchyFilteringHelper(rootLevelFilteringProps: HierarchyFilteringPath[] | undefined, parentNode: Pick<NonGroupingHierarchyNode, "filtering"> | undefined): {
145
+ export declare function createHierarchyFilteringHelper(rootLevelFilteringProps: HierarchyFilteringPath[] | undefined, parentNode: Pick<NonGroupingHierarchyNode, "filtering" | "parentKeys"> | undefined): {
83
146
  /**
84
147
  * Returns a flag indicating if the hierarchy level is filtered.
85
148
  */
@@ -109,18 +172,12 @@ export declare function createHierarchyFilteringHelper(rootLevelFilteringProps:
109
172
  nodeKey: InstancesNodeKey | GenericNodeKey;
110
173
  } | {
111
174
  pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;
112
- }) => NodeProps | undefined;
175
+ }) => Pick<HierarchyNode, "autoExpand" | "filtering"> | undefined;
113
176
  /**
114
177
  * Similar to `createChildNodeProps`, but takes an async `pathMatcher` prop.
115
178
  */
116
179
  createChildNodePropsAsync: (props: {
117
180
  pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;
118
- }) => Promise<NodeProps | undefined> | NodeProps | undefined;
119
- };
120
- /** @public */
121
- export type NodeProps = Pick<HierarchyNode, "autoExpand" | "filtering"> & {
122
- filtering?: {
123
- autoExpandDepth?: number;
124
- };
181
+ }) => Promise<Pick<HierarchyNode, "autoExpand" | "filtering"> | undefined> | Pick<HierarchyNode, "autoExpand" | "filtering"> | undefined;
125
182
  };
126
183
  //# sourceMappingURL=HierarchyFiltering.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyFiltering.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyFiltering.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,eAAe,EAAoB,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE5G,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C;;;OAGG;IACH,GAAG,EAAE,eAAe,CAAC;IAErB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED,cAAc;AACd,MAAM,WAAW,6BAA6B;IAC5C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED,cAAc;AACd,MAAM,WAAW,6BAA6B;IAC5C;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,4BAA4B,GAAG,6BAA6B,CAAC;CACrF;AAED;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,4BAA4B,GAAG;IAAE,IAAI,EAAE,4BAA4B,CAAC;IAAC,OAAO,CAAC,EAAE,6BAA6B,CAAA;CAAE,CAAC;AACpJ,cAAc;AAEd,yBAAiB,sBAAsB,CAAC;IACtC;;;OAGG;IACH,SAAgB,SAAS,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,EAAE,4BAA4B,CAAC,CAKvH;IAED;;;;;;;;;;;;;OAaG;IACH,SAAgB,YAAY,CAC1B,GAAG,EAAE,6BAA6B,G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,SAAS,GAC7C,6BAA6B,GAAG,SAAS,CAQ3C;CACF;AAED;;;;;GAKG;AAEH,wBAAgB,qBAAqB,CACnC,uBAAuB,EAAE,sBAAsB,EAAE,EACjD,UAAU,EAAE,IAAI,CAAC,wBAAwB,EAAE,WAAW,CAAC,GAAG,SAAS,GAEjE;IACE,iBAAiB,EAAE,sBAAsB,EAAE,CAAC;IAC5C,uBAAuB,EAAE,OAAO,CAAC;CAClC,GACD,SAAS,CAEZ;AAuBD;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,uBAAuB,EAAE,sBAAsB,EAAE,GAAG,SAAS,EAC7D,UAAU,EAAE,IAAI,CAAC,wBAAwB,EAAE,WAAW,GAAG,YAAY,CAAC,GAAG,SAAS;IAKhF;;OAEG;;IAGH;;;;;OAKG;;IAGH;;;OAGG;;IAWH;;;;;;;;OAQG;kCAGG;QACE,OAAO,EAAE,gBAAgB,GAAG,cAAc,CAAC;KAC5C,GACD;QACE,WAAW,EAAE,CAAC,UAAU,EAAE,uBAAuB,KAAK,OAAO,CAAC;KAC/D,KACJ,IAAI,CAAC,aAAa,EAAE,YAAY,GAAG,WAAW,CAAC,GAAG,SAAS;IAoB9D;;OAEG;uCACgC;QACjC,WAAW,EAAE,CAAC,UAAU,EAAE,uBAAuB,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;KAClF,KAAG,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY,GAAG,WAAW,CAAC,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,YAAY,GAAG,WAAW,CAAC,GAAG,SAAS;EAgCzI"}
@@ -9,6 +9,36 @@ exports.extractFilteringProps = extractFilteringProps;
9
9
  exports.createHierarchyFilteringHelper = createHierarchyFilteringHelper;
10
10
  const HierarchyNodeIdentifier_js_1 = require("./HierarchyNodeIdentifier.js");
11
11
  const HierarchyNodeKey_js_1 = require("./HierarchyNodeKey.js");
12
+ var HierarchyFilteringPathOptions;
13
+ (function (HierarchyFilteringPathOptions) {
14
+ function mergeAutoExpandOptions(lhs, rhs) {
15
+ if (rhs === true || lhs === true) {
16
+ return true;
17
+ }
18
+ if (!rhs || !lhs) {
19
+ return !!rhs ? rhs : lhs;
20
+ }
21
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
22
+ const lhsDepth = "depth" in lhs ? lhs.depth : "depthInPath" in lhs ? lhs.depthInPath : lhs.depthInHierarchy;
23
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
24
+ const rhsDepth = "depth" in rhs ? rhs.depth : "depthInPath" in rhs ? rhs.depthInPath : rhs.depthInHierarchy;
25
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
26
+ const isLhsDepthBasedOnPath = "depthInPath" in lhs ? true : !("key" in lhs) && !("depthInHierarchy" in lhs) && !lhs.includeGroupingNodes;
27
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
28
+ const isRhsDepthBasedOnPath = "depthInPath" in rhs ? true : !("key" in rhs) && !("depthInHierarchy" in rhs) && !rhs.includeGroupingNodes;
29
+ if (isLhsDepthBasedOnPath) {
30
+ if (isRhsDepthBasedOnPath) {
31
+ return lhsDepth > rhsDepth ? lhs : rhs;
32
+ }
33
+ return lhs;
34
+ }
35
+ if (isRhsDepthBasedOnPath) {
36
+ return rhs;
37
+ }
38
+ return lhsDepth > rhsDepth ? lhs : rhs;
39
+ }
40
+ HierarchyFilteringPathOptions.mergeAutoExpandOptions = mergeAutoExpandOptions;
41
+ })(HierarchyFilteringPathOptions || (HierarchyFilteringPathOptions = {}));
12
42
  /** @public */
13
43
  // eslint-disable-next-line @typescript-eslint/no-redeclare
14
44
  var HierarchyFilteringPath;
@@ -32,9 +62,11 @@ var HierarchyFilteringPath;
32
62
  *
33
63
  * For the `autoExpand` attribute, the merge chooses to auto-expand as deep as the deepest input:
34
64
  * - if any one of the inputs is `true`, return `true`,
35
- * - else if both inputs are objects, return the one with the greater `depth` attribute.
36
- * - else if one input is an object, return it.
37
- * - else, return `false` or `undefined`.
65
+ * - else if only one of the inputs is an object, return it,
66
+ * - else if both inputs are falsy, return `false` or `undefined`,
67
+ * - else:
68
+ * - if only one of the inputs has `includeGroupingNodes` set to `true` or `key` defined or `depthInHierarchy` set, return the other one,
69
+ * - else return the one with greater `depth`, `depthInPath` or `depthInHierarchy`.
38
70
  *
39
71
  * @public
40
72
  */
@@ -43,18 +75,7 @@ var HierarchyFilteringPath;
43
75
  return lhs ?? rhs;
44
76
  }
45
77
  return {
46
- autoExpand: (() => {
47
- if (rhs.autoExpand === true || lhs.autoExpand === true) {
48
- return true;
49
- }
50
- if (typeof lhs.autoExpand === "object") {
51
- if (typeof rhs.autoExpand === "object" && rhs.autoExpand.depth > lhs.autoExpand.depth) {
52
- return rhs.autoExpand;
53
- }
54
- return lhs.autoExpand;
55
- }
56
- return rhs.autoExpand;
57
- })(),
78
+ autoExpand: HierarchyFilteringPathOptions.mergeAutoExpandOptions(lhs.autoExpand, rhs.autoExpand),
58
79
  };
59
80
  }
60
81
  HierarchyFilteringPath.mergeOptions = mergeOptions;
@@ -140,7 +161,7 @@ function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNode) {
140
161
  reducer.accept(normalizedPath);
141
162
  }
142
163
  });
143
- return reducer.getNodeProps();
164
+ return reducer.getNodeProps(parentNode);
144
165
  },
145
166
  /**
146
167
  * Similar to `createChildNodeProps`, but takes an async `pathMatcher` prop.
@@ -168,11 +189,11 @@ function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNode) {
168
189
  reducer.accept(normalizedPath);
169
190
  }
170
191
  if (matchedPathPromises.length === 0) {
171
- return reducer.getNodeProps();
192
+ return reducer.getNodeProps(parentNode);
172
193
  }
173
194
  return Promise.all(matchedPathPromises)
174
195
  .then((matchedPath) => matchedPath.forEach((normalizedPath) => normalizedPath && reducer.accept(normalizedPath)))
175
- .then(() => reducer.getNodeProps());
196
+ .then(() => reducer.getNodeProps(parentNode));
176
197
  },
177
198
  };
178
199
  }
@@ -181,26 +202,45 @@ class MatchingFilteringPathsReducer {
181
202
  _filteredChildrenIdentifierPaths = new Array();
182
203
  _isFilterTarget = false;
183
204
  _filterTargetOptions = undefined;
184
- _needsAutoExpand = false;
205
+ _autoExpandOption = false;
185
206
  constructor(_hasFilterTargetAncestor) {
186
207
  this._hasFilterTargetAncestor = _hasFilterTargetAncestor;
187
208
  }
188
- accept({ path, options }) {
209
+ accept(normalizedPath) {
210
+ const { path, options } = normalizedPath;
189
211
  if (path.length === 1) {
190
212
  this._isFilterTarget = true;
191
213
  this._filterTargetOptions = HierarchyFilteringPath.mergeOptions(this._filterTargetOptions, options);
192
214
  }
193
215
  else if (path.length > 1) {
194
216
  this._filteredChildrenIdentifierPaths.push({ path: path.slice(1), options });
195
- if (options?.autoExpand) {
196
- if (!this._needsAutoExpand ||
197
- (this._needsAutoExpand !== true && (options.autoExpand === true || this._needsAutoExpand.depth < options.autoExpand.depth))) {
198
- this._needsAutoExpand = options.autoExpand;
199
- }
200
- }
217
+ this._autoExpandOption = HierarchyFilteringPathOptions.mergeAutoExpandOptions(options?.autoExpand, this._autoExpandOption);
218
+ }
219
+ }
220
+ getNeedsAutoExpand(parentNode) {
221
+ if (this._autoExpandOption === true) {
222
+ return true;
223
+ }
224
+ if (typeof this._autoExpandOption === "object") {
225
+ const parentLength = !parentNode
226
+ ? 0
227
+ : "key" in this._autoExpandOption ||
228
+ "depthInHierarchy" in this._autoExpandOption ||
229
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
230
+ ("includeGroupingNodes" in this._autoExpandOption && this._autoExpandOption.includeGroupingNodes)
231
+ ? 1 + parentNode.parentKeys.length
232
+ : 1 + parentNode.parentKeys.filter((key) => !HierarchyNodeKey_js_1.HierarchyNodeKey.isGrouping(key)).length;
233
+ const depth = "depthInHierarchy" in this._autoExpandOption
234
+ ? this._autoExpandOption.depthInHierarchy
235
+ : "depth" in this._autoExpandOption
236
+ ? // eslint-disable-next-line @typescript-eslint/no-deprecated
237
+ this._autoExpandOption.depth
238
+ : this._autoExpandOption.depthInPath;
239
+ return parentLength < depth;
201
240
  }
241
+ return false;
202
242
  }
203
- getNodeProps() {
243
+ getNodeProps(parentNode) {
204
244
  return {
205
245
  ...(this._hasFilterTargetAncestor || this._isFilterTarget || this._filteredChildrenIdentifierPaths.length > 0
206
246
  ? {
@@ -208,11 +248,10 @@ class MatchingFilteringPathsReducer {
208
248
  ...(this._hasFilterTargetAncestor ? { hasFilterTargetAncestor: true } : undefined),
209
249
  ...(this._isFilterTarget ? { isFilterTarget: true, filterTargetOptions: this._filterTargetOptions } : undefined),
210
250
  ...(this._filteredChildrenIdentifierPaths.length > 0 ? { filteredChildrenIdentifierPaths: this._filteredChildrenIdentifierPaths } : undefined),
211
- ...(this._needsAutoExpand && this._needsAutoExpand !== true ? { autoExpandDepth: this._needsAutoExpand.depth } : undefined),
212
251
  },
213
252
  }
214
253
  : undefined),
215
- ...(this._needsAutoExpand ? { autoExpand: !!this._needsAutoExpand } : undefined),
254
+ ...(this.getNeedsAutoExpand(parentNode) ? { autoExpand: true } : undefined),
216
255
  };
217
256
  }
218
257
  }
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyFiltering.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyFiltering.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA0GhG,sDAUC;AA6BD,wEA4GC;AA1PD,6EAAqG;AACrG,+DAA4G;AA0C5G,cAAc;AACd,2DAA2D;AAC3D,IAAiB,sBAAsB,CAiDtC;AAjDD,WAAiB,sBAAsB;IACrC;;;OAGG;IACH,SAAgB,SAAS,CAAC,MAA8B;QACtD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC1B,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IALe,gCAAS,YAKxB,CAAA;IAED;;;;;;;;;;;;;OAaG;IACH,SAAgB,YAAY,CAC1B,GAA8C,EA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AS,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;wBAC9I,GAAG,CAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,gBAAgB,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;qBAC5H;iBACF;gBACH,CAAC,CAAC,SAAS,CAAC;YACd,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;SACjF,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, GroupingNodeKey, HierarchyNodeKey, InstancesNodeKey } from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport interface FilterTargetGroupingNodeInfo {\n /**\n * Key of the grouping node.\n * @deprecated in 1.6. This option is no longer needed.\n */\n key: GroupingNodeKey;\n\n /**\n * Depth up to which nodes in the hierarchy should be expanded.\n */\n depth: number;\n}\n\n/** @public */\nexport interface FilteringPathAutoExpandOption {\n /**\n * Depth up to which nodes in the hierarchy should be expanded.\n */\n depth: 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 `FilterTargetGroupingNodeInfo`, then all nodes up to the grouping node that matches this property,\n * will have `autoExpand` flag.\n * - If it's an instance of `FilteringPathAutoExpandOption`, then all nodes up to and including `depth` will have `autoExpand` flag.\n */\n autoExpand?: boolean | FilterTargetGroupingNodeInfo | FilteringPathAutoExpandOption;\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 both inputs are objects, return the one with the greater `depth` attribute.\n * - else if one input is an object, return it.\n * - else, return `false` or `undefined`.\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[\"autoExpand\"] => {\n if (rhs.autoExpand === true || lhs.autoExpand === true) {\n return true;\n }\n if (typeof lhs.autoExpand === \"object\") {\n if (typeof rhs.autoExpand === \"object\" && rhs.autoExpand.depth > lhs.autoExpand.depth) {\n return rhs.autoExpand;\n }\n return lhs.autoExpand;\n }\n return rhs.autoExpand;\n })(),\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\"> | 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 ): NodeProps | 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();\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<NodeProps | undefined> | NodeProps | 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();\n }\n return Promise.all(matchedPathPromises)\n .then((matchedPath) => matchedPath.forEach((normalizedPath) => normalizedPath && reducer.accept(normalizedPath)))\n .then(() => reducer.getNodeProps());\n },\n };\n}\n\n/** @public */\nexport type NodeProps = Pick<HierarchyNode, \"autoExpand\" | \"filtering\"> & { filtering?: { autoExpandDepth?: number } };\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 _needsAutoExpand: boolean | { depth: number } = false;\n\n public constructor(private _hasFilterTargetAncestor: boolean) {}\n\n public accept({ path, options }: NormalizedFilteringPath) {\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 if (options?.autoExpand) {\n if (\n !this._needsAutoExpand ||\n (this._needsAutoExpand !== true && (options.autoExpand === true || this._needsAutoExpand.depth < options.autoExpand.depth))\n ) {\n this._needsAutoExpand = options.autoExpand;\n }\n }\n }\n }\n public getNodeProps(): NodeProps {\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 ...(this._needsAutoExpand && this._needsAutoExpand !== true ? { autoExpandDepth: this._needsAutoExpand.depth } : undefined),\n },\n }\n : undefined),\n ...(this._needsAutoExpand ? { autoExpand: !!this._needsAutoExpand } : undefined),\n };\n }\n}\n"]}
1
+ {"version":3,"file":"HierarchyFiltering.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyFiltering.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAwMhG,sDAUC;AA6BD,wEA4GC;AAxVD,6EAAqG;AACrG,+DAA4G;AA2G5G,IAAU,6BAA6B,CA+BtC;AA/BD,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;QACD,4DAA4D;QAC5D,MAAM,QAAQ,GAAG,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,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ACF","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, GroupingNodeKey, HierarchyNodeKey, InstancesNodeKey } from \"./HierarchyNodeKey.js\";\n\n/**\n * @public\n * @deprecated in 1.7. Use `FilteringPathAutoExpandDepthInHierarchy` instead.\n */\nexport interface FilterTargetGroupingNodeInfo {\n /**\n * Key of the grouping node.\n * @deprecated in 1.6. Use `FilteringPathAutoExpandDepthInHierarchy` instead.\n */\n key: GroupingNodeKey;\n\n /**\n * Depth up to which nodes in the hierarchy should be expanded.\n * @deprecated in 1.6. Use `FilteringPathAutoExpandDepthInHierarchy` instead.\n */\n depth: number;\n}\n\n/**\n * @public\n * @deprecated in 1.7. Use `FilteringPathAutoExpandDepthInPath` or `FilteringPathAutoExpandDepthInHierarchy` instead.\n */\nexport interface FilteringPathAutoExpandOption {\n /**\n * Depth up to which nodes in the hierarchy should be expanded.\n *\n * If `includeGroupingNodes` is set to true, then depth should take into account the number of grouping nodes in hierarchy.\n * @deprecated in 1.7. Use `FilteringPathAutoExpandDepthInPath` or `FilteringPathAutoExpandDepthInHierarchy` instead.\n */\n depth: number;\n /**\n * Whether or not `depth` includes grouping nodes.\n *\n * Use when you want to autoExpand only some of the grouping nodes.\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: { depth: 2, includeGroupingNodes: true }`\n *\n * To get the correct depth use `HierarchyNode.parentKeys.length`.\n * @deprecated in 1.7. Use `FilteringPathAutoExpandDepthInHierarchy` instead.\n */\n includeGroupingNodes?: boolean;\n}\n\n/** @public */\nexport interface FilteringPathAutoExpandDepthInPath {\n /**\n * Depth up to 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 depthInPath: number;\n}\n\n/** @public */\nexport interface FilteringPathAutoExpandDepthInHierarchy {\n /**\n * Depth up to 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 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 `FilterTargetGroupingNodeInfo`, then all nodes up to the grouping node that matches this property,\n * will have `autoExpand` flag.\n * - If it's an instance of `FilteringPathAutoExpandOption`, then all nodes up to and including `depth` will have `autoExpand` flag.\n * - If it's an instance of `FilteringPathAutoExpandDepthInPath`, then all nodes up to and including `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?:\n | boolean\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n | FilterTargetGroupingNodeInfo\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n | FilteringPathAutoExpandOption\n | FilteringPathAutoExpandDepthInHierarchy\n | 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 // eslint-disable-next-line @typescript-eslint/no-deprecated\n const lhsDepth = \"depth\" in lhs ? lhs.depth : \"depthInPath\" in lhs ? lhs.depthInPath : lhs.depthInHierarchy;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const rhsDepth = \"depth\" in rhs ? rhs.depth : \"depthInPath\" in rhs ? rhs.depthInPath : rhs.depthInHierarchy;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const isLhsDepthBasedOnPath = \"depthInPath\" in lhs ? true : !(\"key\" in lhs) && !(\"depthInHierarchy\" in lhs) && !lhs.includeGroupingNodes;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const isRhsDepthBasedOnPath = \"depthInPath\" in rhs ? true : !(\"key\" in rhs) && !(\"depthInHierarchy\" in rhs) && !rhs.includeGroupingNodes;\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 : \"key\" in this._autoExpandOption ||\n \"depthInHierarchy\" in this._autoExpandOption ||\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n (\"includeGroupingNodes\" in this._autoExpandOption && this._autoExpandOption.includeGroupingNodes)\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 : \"depth\" in this._autoExpandOption\n ? // eslint-disable-next-line @typescript-eslint/no-deprecated\n this._autoExpandOption.depth\n : this._autoExpandOption.depthInPath;\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 +1 @@
1
- {"version":3,"file":"FilteringHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/FilteringHierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OAAO,EAAuD,UAAU,EAAe,MAAM,MAAM,CAAC;AAEpG,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAkC,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGlG,OAAO,EACL,yBAAyB,EAEzB,wBAAwB,EAExB,4BAA4B,EAC7B,MAAM,wCAAwC,CAAC;AAKhD,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAE9I,UAAU,iCAAiC;IACzC,YAAY,EAAE,yBAAyB,GAAG;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAChE,MAAM,EAAE,uBAAuB,CAAC;IAChC,mBAAmB,EAAE,sBAAsB,EAAE,CAAC;IAC9C,WAAW,CAAC,EAAE,cAAc,CAAC;CAC9B;AAED,gBAAgB;AAChB,qBAAa,4BAA6B,YAAW,uBAAuB;IAC1E,OAAO,CAAC,aAAa,CAAoD;IACzE,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,oBAAoB,CAA2B;IACvD,OAAO,CAAC,YAAY,CAAiB;gBAElB,KAAK,EAAE,iCAAiC;IAO3D,IAAW,cAAc,IAAI,oBAAoB,CAYhD;IAED,OAAO,CAAC,wBAAwB;IA2ChC,IAAW,eAAe,IAAI,qBAAqB,CAYlD;IAED,IAAW,SAAS,IAAI,cAAc,CA6CrC;IAEM,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,UAAU,CAAC,wBAAwB,CAAC;CAoGpG;AAED,gBAAgB;AAEhB,eAAO,MAAM,oCAAoC,uBAAuB,CAAC;AAEzE,gBAAgB;AAEhB,eAAO,MAAM,iCAAiC,oBAAoB,CAAC;AAenE,gBAAgB;AAChB,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,WAAW,EAAE,GAAG,4BAA4B,CAgC7I;AAED,gBAAgB;AAChB,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,4BAA4B,GAAG,4BAA4B,CAc1G"}
1
+ {"version":3,"file":"FilteringHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/FilteringHierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OAAO,EAAuD,UAAU,EAAe,MAAM,MAAM,CAAC;AAEpG,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAkC,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGlG,OAAO,EACL,yBAAyB,EAEzB,wBAAwB,EAExB,4BAA4B,EAC7B,MAAM,wCAAwC,CAAC;AAKhD,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAE9I,UAAU,iCAAiC;IACzC,YAAY,EAAE,yBAAyB,GAAG;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAChE,MAAM,EAAE,uBAAuB,CAAC;IAChC,mBAAmB,EAAE,sBAAsB,EAAE,CAAC;IAC9C,WAAW,CAAC,EAAE,cAAc,CAAC;CAC9B;AAED,gBAAgB;AAChB,qBAAa,4BAA6B,YAAW,uBAAuB;IAC1E,OAAO,CAAC,aAAa,CAAoD;IACzE,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,oBAAoB,CAA2B;IACvD,OAAO,CAAC,YAAY,CAAiB;gBAElB,KAAK,EAAE,iCAAiC;IAO3D,IAAW,cAAc,IAAI,oBAAoB,CAYhD;IAED,OAAO,CAAC,wBAAwB;IAqDhC,IAAW,eAAe,IAAI,qBAAqB,CAYlD;IAED,IAAW,SAAS,IAAI,cAAc,CA2CrC;IAEM,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,UAAU,CAAC,wBAAwB,CAAC;CAoGpG;AAED,gBAAgB;AAEhB,eAAO,MAAM,oCAAoC,uBAAuB,CAAC;AAEzE,gBAAgB;AAEhB,eAAO,MAAM,iCAAiC,oBAAoB,CAAC;AAenE,gBAAgB;AAChB,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,WAAW,EAAE,GAAG,4BAA4B,CAgC7I;AAED,gBAAgB;AAChB,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,4BAA4B,GAAG,4BAA4B,CAc1G"}
@@ -10,6 +10,7 @@ exports.applyECInstanceIdsSelector = applyECInstanceIdsSelector;
10
10
  const rxjs_1 = require("rxjs");
11
11
  const HierarchyFiltering_js_1 = require("../HierarchyFiltering.js");
12
12
  const HierarchyNodeIdentifier_js_1 = require("../HierarchyNodeIdentifier.js");
13
+ const HierarchyNodeKey_js_1 = require("../HierarchyNodeKey.js");
13
14
  const IModelHierarchyDefinition_js_1 = require("../imodel/IModelHierarchyDefinition.js");
14
15
  const IModelHierarchyNode_js_1 = require("../imodel/IModelHierarchyNode.js");
15
16
  const NodeSelectQueryFactory_js_1 = require("../imodel/NodeSelectQueryFactory.js");
@@ -56,8 +57,17 @@ class FilteringHierarchyDefinition {
56
57
  }
57
58
  // If grouping node's child has `autoExpandUntil` flag,
58
59
  // auto-expand the grouping node only if it's depth is lower than that of the grouping node in associated with the target.
59
- const nodeDepth = node.parentKeys.length;
60
- const filterTargetDepth = childAutoExpand.depth;
60
+ const nodeDepth =
61
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
62
+ "key" in childAutoExpand || "depthInHierarchy" in childAutoExpand || (!("depthInPath" in childAutoExpand) && childAutoExpand.includeGroupingNodes)
63
+ ? node.parentKeys.length
64
+ : node.parentKeys.filter((key) => !HierarchyNodeKey_js_1.HierarchyNodeKey.isGrouping(key)).length;
65
+ const filterTargetDepth = "depth" in childAutoExpand
66
+ ? // eslint-disable-next-line @typescript-eslint/no-deprecated
67
+ childAutoExpand.depth
68
+ : "depthInPath" in childAutoExpand
69
+ ? childAutoExpand.depthInPath
70
+ : childAutoExpand.depthInHierarchy;
61
71
  if (nodeDepth < filterTargetDepth) {
62
72
  return true;
63
73
  }
@@ -115,9 +125,7 @@ class FilteringHierarchyDefinition {
115
125
  });
116
126
  return (nodeExtraPropsPossiblyPromise instanceof Promise ? (0, rxjs_1.from)(nodeExtraPropsPossiblyPromise) : (0, rxjs_1.of)(nodeExtraPropsPossiblyPromise)).pipe((0, rxjs_1.map)((nodeExtraProps) => {
117
127
  if (nodeExtraProps?.autoExpand) {
118
- const parentLength = parentNode ? 1 + parentNode.parentKeys.length : 0;
119
- parsedNode.autoExpand =
120
- nodeExtraProps.filtering?.autoExpandDepth !== undefined && parentLength >= nodeExtraProps.filtering.autoExpandDepth ? undefined : true;
128
+ parsedNode.autoExpand = true;
121
129
  }
122
130
  if (nodeExtraProps?.filtering) {
123
131
  parsedNode.filtering = nodeExtraProps.filtering;