@itwin/presentation-hierarchies 2.0.0-alpha.4 → 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.
- package/CHANGELOG.md +56 -9
- package/lib/cjs/hierarchies/HierarchyFiltering.d.ts +77 -36
- package/lib/cjs/hierarchies/HierarchyFiltering.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyFiltering.js +126 -98
- package/lib/cjs/hierarchies/HierarchyFiltering.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyMerge.d.ts +19 -0
- package/lib/cjs/hierarchies/HierarchyMerge.d.ts.map +1 -0
- package/lib/cjs/hierarchies/HierarchyMerge.js +43 -0
- package/lib/cjs/hierarchies/HierarchyMerge.js.map +1 -0
- package/lib/cjs/hierarchies/HierarchyNode.d.ts +2 -2
- package/lib/cjs/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeKey.js +8 -8
- package/lib/cjs/hierarchies/HierarchyNodeKey.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts +0 -18
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.js +0 -37
- package/lib/cjs/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts +2 -0
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js +45 -30
- package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts +42 -7
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +144 -45
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.js +10 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.js +1 -0
- package/lib/cjs/hierarchies/imodel/operators/HideIfNoChildren.js.map +1 -1
- package/lib/cjs/hierarchies/internal/Common.d.ts +3 -0
- package/lib/cjs/hierarchies/internal/Common.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/Common.js +12 -1
- package/lib/cjs/hierarchies/internal/Common.js.map +1 -1
- package/lib/cjs/hierarchies/internal/EachValueFrom.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/EachValueFrom.js +1 -0
- package/lib/cjs/hierarchies/internal/EachValueFrom.js.map +1 -1
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js +2 -1
- package/lib/cjs/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -1
- package/lib/cjs/presentation-hierarchies.d.ts +3 -2
- package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies.js +4 -3
- package/lib/cjs/presentation-hierarchies.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyFiltering.d.ts +77 -36
- package/lib/esm/hierarchies/HierarchyFiltering.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyFiltering.js +125 -98
- package/lib/esm/hierarchies/HierarchyFiltering.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyMerge.d.ts +19 -0
- package/lib/esm/hierarchies/HierarchyMerge.d.ts.map +1 -0
- package/lib/esm/hierarchies/HierarchyMerge.js +40 -0
- package/lib/esm/hierarchies/HierarchyMerge.js.map +1 -0
- package/lib/esm/hierarchies/HierarchyNode.d.ts +2 -2
- package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeKey.js +9 -9
- package/lib/esm/hierarchies/HierarchyNodeKey.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.d.ts +0 -18
- package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.js +1 -36
- package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts +2 -0
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js +47 -32
- package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts +42 -7
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +146 -48
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/TreeNodesReader.js +10 -1
- package/lib/esm/hierarchies/imodel/TreeNodesReader.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.js +1 -0
- package/lib/esm/hierarchies/imodel/operators/HideIfNoChildren.js.map +1 -1
- package/lib/esm/hierarchies/internal/Common.d.ts +3 -0
- package/lib/esm/hierarchies/internal/Common.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/Common.js +11 -1
- package/lib/esm/hierarchies/internal/Common.js.map +1 -1
- package/lib/esm/hierarchies/internal/EachValueFrom.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/EachValueFrom.js +1 -0
- package/lib/esm/hierarchies/internal/EachValueFrom.js.map +1 -1
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js +3 -2
- package/lib/esm/hierarchies/internal/RxjsHierarchyDefinition.js.map +1 -1
- package/lib/esm/presentation-hierarchies.d.ts +3 -2
- package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies.js +2 -2
- package/lib/esm/presentation-hierarchies.js.map +1 -1
- package/package.json +17 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @itwin/presentation-hierarchies
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.6
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 6a00754233e6d1b8956a5fc7680829562156d659: Fixed a bug causing `HierarchyNode.autoExpand` flag to be set on non-grouping nodes, when `HierarchyFilteringPathOptions.autoExpand.depthInHierarchy` points to a grouping node whose child non-grouping node is not a filter target.
|
|
8
|
+
|
|
9
|
+
**Breaking changes:**
|
|
10
|
+
- `GroupingHierarchyNode` no longer contains `filtering` attribute. This was always the case, but now the types have been updated to match it.
|
|
11
|
+
- Changed return type of `createHierarchyFilteringHelper`:
|
|
12
|
+
- Removed `createChildNodePropsAsync` - it became an overload of `createChildNodeProps`, whose path matching is done through `asyncPathMatcher` callback.
|
|
13
|
+
- `createChildNodeProps` now has multiple overloads and returns different types based on provided props. `autoExpand` flag is only returned when `parentKeys` are provided.
|
|
14
|
+
- Renamed `HierarchyFilteringPathOptions.autoExpand` -> `HierarchyFilteringPathOptions.reveal` to match intent.
|
|
15
|
+
- Changed `HierarchyFilteringPathOptions.reveal.depthInHierarchy` and `depthInPath` to use 0-based indexing instead of 1-based indexing.
|
|
16
|
+
- Changed `HierarchyFilteringPathOptions.reveal.depthInHierarchy` to not set `autoExpand` flag on the node that is at the `depthInHierarchy` position.
|
|
17
|
+
|
|
18
|
+
- e9ef80880c776522ce3b2632c8c3c461e62d6444: The hierarchy provider returned by `mergeProviders` doesn't have the deprecated `dispose` method anymore. Use `[Symbol.dispose]` instead.
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- e9e42c3a513cb7d594351ee2244c7efe67cc4385: Added `HierarchyFilteringPathOptions.autoExpand` option to enable auto-expanding of filter target nodes.
|
|
23
|
+
- e9ef80880c776522ce3b2632c8c3c461e62d6444: Add an experimental (`@alpha`) function `createMergedIModelHierarchyProvider` for creating a hierarchy from multiple versions of the same iModel.
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- e9ef80880c776522ce3b2632c8c3c461e62d6444: Fix `HierarchyNodeKey` methods `equals` and `compare` not handling different schema-class separators and casing.
|
|
28
|
+
- Updated dependencies:
|
|
29
|
+
- @itwin/presentation-shared@2.0.0-alpha.4
|
|
30
|
+
|
|
31
|
+
## 2.0.0-alpha.5
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- [#1112](https://github.com/iTwin/presentation/pull/1112): Version bump
|
|
36
|
+
- Updated dependencies:
|
|
37
|
+
- @itwin/presentation-shared@2.0.0-alpha.3
|
|
38
|
+
|
|
3
39
|
## 2.0.0-alpha.4
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
|
@@ -33,7 +69,6 @@
|
|
|
33
69
|
### Major Changes
|
|
34
70
|
|
|
35
71
|
- [#954](https://github.com/iTwin/presentation/pull/954): Add additional requirements for types in `EC` metadata namespace, whose objects are returned by `ECSchemaProvider`.
|
|
36
|
-
|
|
37
72
|
- `EC.Schema`, `EC.Class` and `EC.Property` now all have an async `getCustomAttributes()` method that returns an `EC.CustomAttributeSet`, allowing consumers to access custom attributes of these schema items.
|
|
38
73
|
- `EC.Class` now additionally has these members:
|
|
39
74
|
- `baseClass: Promise<Class | undefined>`
|
|
@@ -52,6 +87,26 @@
|
|
|
52
87
|
- Updated dependencies:
|
|
53
88
|
- @itwin/presentation-shared@2.0.0-alpha.0
|
|
54
89
|
|
|
90
|
+
## 1.7.5
|
|
91
|
+
|
|
92
|
+
### Patch Changes
|
|
93
|
+
|
|
94
|
+
- [#1124](https://github.com/iTwin/presentation/pull/1124): Bump dependencies.
|
|
95
|
+
- Updated dependencies:
|
|
96
|
+
- @itwin/presentation-shared@1.2.4
|
|
97
|
+
|
|
98
|
+
## 1.7.4
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- [#1088](https://github.com/iTwin/presentation/pull/1088): Fix restart tokens not being unique when they need to, causing queries to be cancelled.
|
|
103
|
+
|
|
104
|
+
## 1.7.3
|
|
105
|
+
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- [#1083](https://github.com/iTwin/presentation/pull/1083): Add unique guid to existing restart tokens, and add restart tokens to executed queries.
|
|
109
|
+
|
|
55
110
|
## 1.7.2
|
|
56
111
|
|
|
57
112
|
### Patch Changes
|
|
@@ -71,7 +126,6 @@
|
|
|
71
126
|
### Minor Changes
|
|
72
127
|
|
|
73
128
|
- 8f7d200926b93e862276e1f978f6c891691e0dae: Refactored specifying the depth / level to which filtering path should be auto-expanded.
|
|
74
|
-
|
|
75
129
|
- Deprecated `FilteringPathAutoExpandOption` and `FilterTargetGroupingNodeInfo`.
|
|
76
130
|
- Added `FilteringPathAutoExpandDepthInPath` and `FilteringPathAutoExpandDepthInHierarchy` which should be used instead.
|
|
77
131
|
|
|
@@ -144,7 +198,6 @@
|
|
|
144
198
|
```
|
|
145
199
|
|
|
146
200
|
**After:**
|
|
147
|
-
|
|
148
201
|
- **Option A:** check if it's a Promise before awaiting:
|
|
149
202
|
|
|
150
203
|
Use this when you want to get slightly better performance by avoiding unnecessary `await`.
|
|
@@ -229,7 +282,6 @@
|
|
|
229
282
|
- [#783](https://github.com/iTwin/presentation/pull/783): Added hierarchy filtering helper to make hierarchy filtering easier to implement.
|
|
230
283
|
|
|
231
284
|
The helper can be created using the `createHierarchyFilteringHelper` function and supplying it the root level filtering paths and parent node. From there, filtering information for specific hierarchy level is determined and an object with the following attributes is returned:
|
|
232
|
-
|
|
233
285
|
- `hasFilter` tells if the hierarchy level has a filter applied.
|
|
234
286
|
- `hasFilterTargetAncestor` tells if there's a filter target ancestor node up in the hierarchy.
|
|
235
287
|
- `getChildNodeFilteringIdentifiers()` returns an array of hierarchy node identifiers that apply specifically for this hierarchy level.
|
|
@@ -238,7 +290,6 @@
|
|
|
238
290
|
See the [Implementing hierarchy filtering support](./learning/CustomHierarchyProviders.md#implementing-hierarchy-filtering-support) learning page for a usage example.
|
|
239
291
|
|
|
240
292
|
In addition, deprecated a few APIs that are replaced by filtering helper:
|
|
241
|
-
|
|
242
293
|
- `extractFilteringProps` function,
|
|
243
294
|
- `HierarchyNodeFilteringProps.create` function.
|
|
244
295
|
|
|
@@ -284,7 +335,6 @@
|
|
|
284
335
|
| 50k | not tested | 13.45 s |
|
|
285
336
|
|
|
286
337
|
In addition, changed `NodeParser` (return type of `HierarchyDefinition.parseNode`):
|
|
287
|
-
|
|
288
338
|
- It now can return a promise, so instead of just `SourceInstanceHierarchyNode` it can now also return `Promise<SourceInstanceHierarchyNode>`.
|
|
289
339
|
- Additionally, it now accepts an optional `parentNode` argument of `HierarchyDefinitionParentNode` type.
|
|
290
340
|
|
|
@@ -316,7 +366,6 @@
|
|
|
316
366
|
### Minor Changes
|
|
317
367
|
|
|
318
368
|
- [#708](https://github.com/iTwin/presentation/pull/708): **BREAKING:** Added support for creating hierarchies from multiple data sources.
|
|
319
|
-
|
|
320
369
|
- `InstancesNodeKey.instanceKeys` array items now have an optional `imodelKey` attribute to allow for the identification of the iModel that the instance belongs to. This is useful when working with sets of instance keys representing instances from different iModels. In addition, the same `imodelKey` attribute is also available on `HierarchyNodeIdentifier` to allow for filtering nodes based on the iModel they belong to.
|
|
321
370
|
- `HierarchyNode` terminology and related changes:
|
|
322
371
|
- "Standard" nodes were renamed to "IModel" nodes to signify the fact that they're based on iModel data:
|
|
@@ -344,7 +393,6 @@
|
|
|
344
393
|
- The returned provider now has a `dispose` method to clean up resources - make sure to call it when the provider is no longer needed.
|
|
345
394
|
- Added `mergeProviders` function, which, given a number of hierarchy providers, creates a new provider that merges the hierarchies of the input providers. The returned provider has a `dispose` method that needs to be called when the provider is no longer needed.
|
|
346
395
|
- Renamed `createClassBasedHierarchyDefinition` to `createPredicateBasedHierarchyDefinition` to signify its props changes:
|
|
347
|
-
|
|
348
396
|
- When specifying `childNodes` definition for instances parent node, the `parentNodeClassName` attribute was changed to `parentInstancesNodePredicate`. In addition to accepting a full class name, identifying the class of parent instances to return children for, it now also accepts an async function predicate.
|
|
349
397
|
- When specifying `childNodes` definition for generic parent node, the `customParentNodeKey` attribute was changed to `parentGenericNodePredicate`. The type changed from `string`, identifying the key of the parent node, to an async function predicate.
|
|
350
398
|
|
|
@@ -397,7 +445,6 @@
|
|
|
397
445
|
```
|
|
398
446
|
|
|
399
447
|
- [#708](https://github.com/iTwin/presentation/pull/708): Added utilities for custom hierarchy filtering handling:
|
|
400
|
-
|
|
401
448
|
- `extractFilteringProps` function, given root level hierarchy filtering paths and a parent node, returns props required to filter particular hierarchy level.
|
|
402
449
|
- `HierarchyFilteringPath` interface is now public and there's also a similarly-named namespace with the following utilities:
|
|
403
450
|
- `mergeOptions` merges filtering options of two paths. This is useful for cases when there are multiple paths targeting the same node, but with different options.
|
|
@@ -1,37 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NonGroupingHierarchyNode } from "./HierarchyNode.js";
|
|
2
2
|
import { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from "./HierarchyNodeIdentifier.js";
|
|
3
|
-
import { GenericNodeKey, InstancesNodeKey } from "./HierarchyNodeKey.js";
|
|
3
|
+
import { GenericNodeKey, HierarchyNodeKey, InstancesNodeKey } from "./HierarchyNodeKey.js";
|
|
4
4
|
/** @public */
|
|
5
|
-
export interface
|
|
5
|
+
export interface FilteringPathRevealDepthInPath {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Index of the node in filtering path should be revealed in hierarchy by auto-expanding its ancestors.
|
|
8
8
|
*
|
|
9
9
|
* Use when you want to expand up to specific instance node and don't care about grouping nodes.
|
|
10
10
|
*
|
|
11
|
-
* **
|
|
11
|
+
* **Use case example:**
|
|
12
|
+
*
|
|
13
|
+
* All nodes up to `Element1` should be expanded in the following hierarchy:
|
|
14
|
+
* - Node1
|
|
15
|
+
* - GroupingNode1
|
|
16
|
+
* - GroupingNode2
|
|
17
|
+
* - Element1
|
|
18
|
+
* - Element2
|
|
19
|
+
*
|
|
20
|
+
* Provide `{ path: [Node1, Element1], reveal: { depthInPath: 1 } }`
|
|
21
|
+
*
|
|
22
|
+
* **NOTE**: All nodes that are up to `depthInPath` will be expanded **except** filter targets.
|
|
12
23
|
*/
|
|
13
24
|
depthInPath: number;
|
|
14
25
|
}
|
|
15
26
|
/** @public */
|
|
16
|
-
export interface
|
|
27
|
+
export interface FilteringPathRevealDepthInHierarchy {
|
|
17
28
|
/**
|
|
18
|
-
*
|
|
29
|
+
* 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.
|
|
19
30
|
*
|
|
20
31
|
* This should take into account the number of grouping nodes in hierarchy.
|
|
21
32
|
*
|
|
22
|
-
*
|
|
33
|
+
* **Use case example:**
|
|
23
34
|
*
|
|
24
|
-
*
|
|
35
|
+
* Only `Node1` and `GroupingNode1` should have `autoExpand` flag in the following hierarchy:
|
|
25
36
|
* - Node1
|
|
26
37
|
* - GroupingNode1
|
|
27
38
|
* - GroupingNode2
|
|
28
39
|
* - Element1
|
|
29
40
|
* - Element2
|
|
30
|
-
*
|
|
41
|
+
*
|
|
42
|
+
* Provide `{ path: [Node1, Element1], reveal: { depthInHierarchy: 2 } }`
|
|
31
43
|
*
|
|
32
44
|
* To get the correct depth use `HierarchyNode.parentKeys.length`.
|
|
33
45
|
*
|
|
34
|
-
* **NOTE**: All nodes that are up to
|
|
46
|
+
* **NOTE**: All nodes that are up to `depthInHierarchy` will be expanded **except** filter targets.
|
|
35
47
|
*/
|
|
36
48
|
depthInHierarchy: number;
|
|
37
49
|
}
|
|
@@ -41,10 +53,18 @@ export interface HierarchyFilteringPathOptions {
|
|
|
41
53
|
* This option specifies the way `autoExpand` flag should be assigned to nodes in the filtered hierarchy.
|
|
42
54
|
* - If it's `false` or `undefined`, nodes have no 'autoExpand' flag.
|
|
43
55
|
* - If it's `true`, then all nodes up to the filter target will have `autoExpand` flag.
|
|
44
|
-
* - If it's an instance of `
|
|
45
|
-
* - If it's an instance of `
|
|
56
|
+
* - If it's an instance of `FilteringPathRevealDepthInPath`, then all nodes up to `depthInPath` will have `autoExpand` flag.
|
|
57
|
+
* - If it's an instance of `FilteringPathRevealDepthInHierarchy`, then all nodes up to `depthInHierarchy` will have `autoExpand` flag.
|
|
46
58
|
*/
|
|
47
|
-
|
|
59
|
+
reveal?: boolean | FilteringPathRevealDepthInHierarchy | FilteringPathRevealDepthInPath;
|
|
60
|
+
/**
|
|
61
|
+
* This option specifies whether or not filter target should be expanded.
|
|
62
|
+
* - If it's `false` or `undefined`, filter target won't have 'autoExpand' flag.
|
|
63
|
+
* - If it's `true`, filter target will have `autoExpand` flag.
|
|
64
|
+
*
|
|
65
|
+
* **NOTE**: this attribute does not set `autoExpand` flag on nodes up to the filter target. For that use `reveal`.
|
|
66
|
+
*/
|
|
67
|
+
autoExpand?: boolean;
|
|
48
68
|
}
|
|
49
69
|
/**
|
|
50
70
|
* A path of hierarchy node identifiers for filtering the hierarchy with additional options.
|
|
@@ -63,17 +83,14 @@ export declare namespace HierarchyFilteringPath {
|
|
|
63
83
|
function normalize(source: HierarchyFilteringPath): Exclude<HierarchyFilteringPath, HierarchyNodeIdentifiersPath>;
|
|
64
84
|
/**
|
|
65
85
|
* Merges two given `HierarchyFilteringPathOptions` objects.
|
|
66
|
-
* - if both inputs are `undefined`, `undefined` is returned,
|
|
67
|
-
* - else if one of the inputs is `undefined`, the other one is returned.
|
|
68
|
-
* - else, merge each option individually.
|
|
69
86
|
*
|
|
70
|
-
* For the `
|
|
87
|
+
* For the `reveal` attribute, the merge chooses to `reveal` as deep as the deepest input:
|
|
71
88
|
* - if any one of the inputs is `true`, return `true`,
|
|
72
89
|
* - else if only one of the inputs is an object, return it,
|
|
73
90
|
* - else if both inputs are falsy, return `false` or `undefined`,
|
|
74
91
|
* - else:
|
|
75
|
-
* - if only one of the inputs has `
|
|
76
|
-
* - else return the one with greater `
|
|
92
|
+
* - if only one of the inputs has `depthInHierarchy` set, return the other one,
|
|
93
|
+
* - else return the one with greater `depthInPath` or `depthInHierarchy`.
|
|
77
94
|
*
|
|
78
95
|
* @public
|
|
79
96
|
*/
|
|
@@ -95,10 +112,8 @@ export declare function extractFilteringProps(rootLevelFilteringProps: Hierarchy
|
|
|
95
112
|
*
|
|
96
113
|
* @public
|
|
97
114
|
*/
|
|
98
|
-
export declare function createHierarchyFilteringHelper(rootLevelFilteringProps: HierarchyFilteringPath[] | undefined, parentNode: Pick<NonGroupingHierarchyNode, "filtering"
|
|
99
|
-
/**
|
|
100
|
-
* Returns a flag indicating if the hierarchy level is filtered.
|
|
101
|
-
*/
|
|
115
|
+
export declare function createHierarchyFilteringHelper(rootLevelFilteringProps: HierarchyFilteringPath[] | undefined, parentNode: Pick<NonGroupingHierarchyNode, "filtering"> | undefined): {
|
|
116
|
+
/** Returns a flag indicating if the hierarchy level is filtered. */
|
|
102
117
|
hasFilter: boolean;
|
|
103
118
|
/**
|
|
104
119
|
* Returns a flag indicating whether this hierarchy level has an ancestor node
|
|
@@ -117,20 +132,46 @@ export declare function createHierarchyFilteringHelper(rootLevelFilteringProps:
|
|
|
117
132
|
* and `autoExpand`) to be set based on the filter paths and filtering options. This function calculates
|
|
118
133
|
* these props for a child node based on its key or path matcher.
|
|
119
134
|
*
|
|
120
|
-
* When using `pathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies
|
|
135
|
+
* When using `pathMatcher` or `asyncPathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies
|
|
121
136
|
* to their node. For example, only some parts of the identifier can be checked for improved performance. Otherwise, the
|
|
122
137
|
* `nodeKey` prop can be used to check the whole identifier.
|
|
138
|
+
*
|
|
139
|
+
* There are multiple overloads of `createChildNodeProps`: depending on props type it returns different values:
|
|
140
|
+
* - `parentKeys` is defined and `pathMatcher` or `nodeKey` is provided - returns undefined **or** `filtering` and `autoExpand` prop from `HierarchyNode`;
|
|
141
|
+
* - `parentKeys` is undefined - does not return `HierarchyNode.autoExpand` option;
|
|
142
|
+
* - props have `asyncPathMatcher` - returns either Promise or the regular return value based on whether or not `asyncPathMatcher` returns a promise.
|
|
123
143
|
*/
|
|
124
|
-
createChildNodeProps:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
144
|
+
createChildNodeProps: {
|
|
145
|
+
(props: {
|
|
146
|
+
parentKeys?: undefined;
|
|
147
|
+
nodeKey: InstancesNodeKey | GenericNodeKey;
|
|
148
|
+
}): Pick<NonGroupingHierarchyNode, "filtering"> | undefined;
|
|
149
|
+
(props: {
|
|
150
|
+
parentKeys?: undefined;
|
|
151
|
+
pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;
|
|
152
|
+
}): Pick<NonGroupingHierarchyNode, "filtering"> | undefined;
|
|
153
|
+
(props: {
|
|
154
|
+
parentKeys?: undefined;
|
|
155
|
+
asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;
|
|
156
|
+
}): Promise<Pick<NonGroupingHierarchyNode, "filtering"> | undefined> | Pick<NonGroupingHierarchyNode, "filtering"> | undefined;
|
|
157
|
+
(props: {
|
|
158
|
+
parentKeys: HierarchyNodeKey[];
|
|
159
|
+
nodeKey: InstancesNodeKey | GenericNodeKey;
|
|
160
|
+
}): Pick<NonGroupingHierarchyNode, "filtering" | "autoExpand"> | undefined;
|
|
161
|
+
(props: {
|
|
162
|
+
parentKeys: HierarchyNodeKey[];
|
|
163
|
+
pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;
|
|
164
|
+
}): Pick<NonGroupingHierarchyNode, "filtering" | "autoExpand"> | undefined;
|
|
165
|
+
(props: {
|
|
166
|
+
parentKeys: HierarchyNodeKey[];
|
|
167
|
+
asyncPathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;
|
|
168
|
+
}): Promise<Pick<NonGroupingHierarchyNode, "filtering" | "autoExpand"> | undefined> | Pick<NonGroupingHierarchyNode, "filtering" | "autoExpand"> | undefined;
|
|
169
|
+
};
|
|
135
170
|
};
|
|
171
|
+
/** @internal */
|
|
172
|
+
export declare function shouldAutoExpandBasedOnReveal({ reveal, nodePositionInPath, nodePositionInHierarchy, }: {
|
|
173
|
+
reveal: HierarchyFilteringPathOptions["reveal"];
|
|
174
|
+
nodePositionInPath: number;
|
|
175
|
+
nodePositionInHierarchy: number;
|
|
176
|
+
}): boolean;
|
|
136
177
|
//# 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,
|
|
1
|
+
{"version":3,"file":"HierarchyFiltering.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyFiltering.ts"],"names":[],"mappings":"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"}
|
|
@@ -7,11 +7,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.HierarchyFilteringPath = void 0;
|
|
8
8
|
exports.extractFilteringProps = extractFilteringProps;
|
|
9
9
|
exports.createHierarchyFilteringHelper = createHierarchyFilteringHelper;
|
|
10
|
+
exports.shouldAutoExpandBasedOnReveal = shouldAutoExpandBasedOnReveal;
|
|
10
11
|
const HierarchyNodeIdentifier_js_1 = require("./HierarchyNodeIdentifier.js");
|
|
11
12
|
const HierarchyNodeKey_js_1 = require("./HierarchyNodeKey.js");
|
|
12
13
|
var HierarchyFilteringPathOptions;
|
|
13
14
|
(function (HierarchyFilteringPathOptions) {
|
|
14
|
-
function
|
|
15
|
+
function mergeRevealOptions(lhs, rhs) {
|
|
15
16
|
if (rhs === true || lhs === true) {
|
|
16
17
|
return true;
|
|
17
18
|
}
|
|
@@ -33,7 +34,11 @@ var HierarchyFilteringPathOptions;
|
|
|
33
34
|
}
|
|
34
35
|
return lhsDepth > rhsDepth ? lhs : rhs;
|
|
35
36
|
}
|
|
36
|
-
HierarchyFilteringPathOptions.
|
|
37
|
+
HierarchyFilteringPathOptions.mergeRevealOptions = mergeRevealOptions;
|
|
38
|
+
function mergeAutoExpandOption(lhs, rhs) {
|
|
39
|
+
return lhs || rhs ? true : undefined;
|
|
40
|
+
}
|
|
41
|
+
HierarchyFilteringPathOptions.mergeAutoExpandOption = mergeAutoExpandOption;
|
|
37
42
|
})(HierarchyFilteringPathOptions || (HierarchyFilteringPathOptions = {}));
|
|
38
43
|
/** @public */
|
|
39
44
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
@@ -52,27 +57,26 @@ var HierarchyFilteringPath;
|
|
|
52
57
|
HierarchyFilteringPath.normalize = normalize;
|
|
53
58
|
/**
|
|
54
59
|
* Merges two given `HierarchyFilteringPathOptions` objects.
|
|
55
|
-
* - if both inputs are `undefined`, `undefined` is returned,
|
|
56
|
-
* - else if one of the inputs is `undefined`, the other one is returned.
|
|
57
|
-
* - else, merge each option individually.
|
|
58
60
|
*
|
|
59
|
-
* For the `
|
|
61
|
+
* For the `reveal` attribute, the merge chooses to `reveal` as deep as the deepest input:
|
|
60
62
|
* - if any one of the inputs is `true`, return `true`,
|
|
61
63
|
* - else if only one of the inputs is an object, return it,
|
|
62
64
|
* - else if both inputs are falsy, return `false` or `undefined`,
|
|
63
65
|
* - else:
|
|
64
|
-
* - if only one of the inputs has `
|
|
65
|
-
* - else return the one with greater `
|
|
66
|
+
* - if only one of the inputs has `depthInHierarchy` set, return the other one,
|
|
67
|
+
* - else return the one with greater `depthInPath` or `depthInHierarchy`.
|
|
66
68
|
*
|
|
67
69
|
* @public
|
|
68
70
|
*/
|
|
69
71
|
function mergeOptions(lhs, rhs) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
const reveal = HierarchyFilteringPathOptions.mergeRevealOptions(lhs?.reveal, rhs?.reveal);
|
|
73
|
+
const autoExpand = HierarchyFilteringPathOptions.mergeAutoExpandOption(lhs?.autoExpand, rhs?.autoExpand);
|
|
74
|
+
return reveal || autoExpand
|
|
75
|
+
? {
|
|
76
|
+
...(reveal !== undefined ? { reveal } : undefined),
|
|
77
|
+
...(autoExpand !== undefined ? { autoExpand } : undefined),
|
|
78
|
+
}
|
|
79
|
+
: undefined;
|
|
76
80
|
}
|
|
77
81
|
HierarchyFilteringPath.mergeOptions = mergeOptions;
|
|
78
82
|
})(HierarchyFilteringPath || (exports.HierarchyFilteringPath = HierarchyFilteringPath = {}));
|
|
@@ -84,19 +88,24 @@ var HierarchyFilteringPath;
|
|
|
84
88
|
*/
|
|
85
89
|
/* c8 ignore start */
|
|
86
90
|
function extractFilteringProps(rootLevelFilteringProps, parentNode) {
|
|
87
|
-
|
|
91
|
+
const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);
|
|
92
|
+
return filteringProps?.filteredNodePaths !== undefined
|
|
93
|
+
? {
|
|
94
|
+
filteredNodePaths: filteringProps.filteredNodePaths,
|
|
95
|
+
hasFilterTargetAncestor: filteringProps.hasFilterTargetAncestor,
|
|
96
|
+
}
|
|
97
|
+
: undefined;
|
|
88
98
|
}
|
|
89
99
|
/* c8 ignore end */
|
|
90
100
|
function extractFilteringPropsInternal(rootLevelFilteringProps, parentNode) {
|
|
91
101
|
if (!parentNode) {
|
|
92
102
|
return rootLevelFilteringProps ? { filteredNodePaths: rootLevelFilteringProps, hasFilterTargetAncestor: false } : undefined;
|
|
93
103
|
}
|
|
94
|
-
|
|
95
|
-
? {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
: undefined;
|
|
104
|
+
const filteringProps = {
|
|
105
|
+
...(parentNode.filtering?.filteredChildrenIdentifierPaths ? { filteredNodePaths: parentNode.filtering.filteredChildrenIdentifierPaths } : undefined),
|
|
106
|
+
hasFilterTargetAncestor: !!parentNode.filtering?.hasFilterTargetAncestor || !!parentNode.filtering?.isFilterTarget,
|
|
107
|
+
};
|
|
108
|
+
return filteringProps.filteredNodePaths || filteringProps.hasFilterTargetAncestor ? filteringProps : undefined;
|
|
100
109
|
}
|
|
101
110
|
/**
|
|
102
111
|
* Creates a set of utilities for making it easier to filter the given hierarchy
|
|
@@ -107,10 +116,61 @@ function extractFilteringPropsInternal(rootLevelFilteringProps, parentNode) {
|
|
|
107
116
|
function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNode) {
|
|
108
117
|
const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);
|
|
109
118
|
const hasFilter = !!filteringProps;
|
|
119
|
+
function saveFilteringPropsFromPathsIntoReducer(extractionProps) {
|
|
120
|
+
// Passes down matching normalized paths to the reducer.
|
|
121
|
+
// It uses `nodeKey`, `pathMatcher` or `asyncPathMatcher` to check if `HierarchyNodeIdentifier` at the first position in filtering path matches the node
|
|
122
|
+
// and if it does, the path is passed down to the reducer.
|
|
123
|
+
// This function returns a promise only if asyncPathMatcher returns a promise.
|
|
124
|
+
if (!filteringProps?.filteredNodePaths) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const matchedPathPromises = new Array();
|
|
128
|
+
for (const filteredChildrenNodeIdentifierPath of filteringProps.filteredNodePaths) {
|
|
129
|
+
const normalizedPath = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);
|
|
130
|
+
/* c8 ignore next 3 */
|
|
131
|
+
if (normalizedPath.path.length === 0) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if ("nodeKey" in extractionProps) {
|
|
135
|
+
if ((HierarchyNodeKey_js_1.HierarchyNodeKey.isGeneric(extractionProps.nodeKey) && HierarchyNodeIdentifier_js_1.HierarchyNodeIdentifier.equal(normalizedPath.path[0], extractionProps.nodeKey)) ||
|
|
136
|
+
(HierarchyNodeKey_js_1.HierarchyNodeKey.isInstances(extractionProps.nodeKey) &&
|
|
137
|
+
extractionProps.nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier_js_1.HierarchyNodeIdentifier.equal(normalizedPath.path[0], ik)))) {
|
|
138
|
+
extractionProps.pathsReducer.accept(normalizedPath);
|
|
139
|
+
}
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const matchesPossiblyPromise = "pathMatcher" in extractionProps ? extractionProps.pathMatcher(normalizedPath.path[0]) : extractionProps.asyncPathMatcher(normalizedPath.path[0]);
|
|
143
|
+
if (matchesPossiblyPromise instanceof Promise) {
|
|
144
|
+
matchedPathPromises.push(matchesPossiblyPromise.then((matches) => (matches ? normalizedPath : undefined)));
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (matchesPossiblyPromise) {
|
|
148
|
+
extractionProps.pathsReducer.accept(normalizedPath);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (matchedPathPromises.length === 0) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
return Promise.all(matchedPathPromises).then((matchedPath) => matchedPath.forEach((normalizedPath) => normalizedPath && extractionProps.pathsReducer.accept(normalizedPath)));
|
|
155
|
+
}
|
|
156
|
+
function createChildNodeProps(props) {
|
|
157
|
+
if (!hasFilter) {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
const reducer = new MatchingFilteringPathsReducer(filteringProps.hasFilterTargetAncestor);
|
|
161
|
+
if ("asyncPathMatcher" in props) {
|
|
162
|
+
const extractResult = saveFilteringPropsFromPathsIntoReducer({ pathsReducer: reducer, asyncPathMatcher: props.asyncPathMatcher });
|
|
163
|
+
if (extractResult instanceof Promise) {
|
|
164
|
+
return extractResult.then(() => reducer.getNodeProps(props.parentKeys));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
saveFilteringPropsFromPathsIntoReducer({ ...props, pathsReducer: reducer });
|
|
169
|
+
}
|
|
170
|
+
return reducer.getNodeProps(props.parentKeys);
|
|
171
|
+
}
|
|
110
172
|
return {
|
|
111
|
-
/**
|
|
112
|
-
* Returns a flag indicating if the hierarchy level is filtered.
|
|
113
|
-
*/
|
|
173
|
+
/** Returns a flag indicating if the hierarchy level is filtered. */
|
|
114
174
|
hasFilter,
|
|
115
175
|
/**
|
|
116
176
|
* Returns a flag indicating whether this hierarchy level has an ancestor node
|
|
@@ -124,7 +184,7 @@ function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNode) {
|
|
|
124
184
|
* hierarchy level. Returns `undefined` if filtering is not applied to this level.
|
|
125
185
|
*/
|
|
126
186
|
getChildNodeFilteringIdentifiers: () => {
|
|
127
|
-
if (!
|
|
187
|
+
if (!filteringProps?.filteredNodePaths) {
|
|
128
188
|
return undefined;
|
|
129
189
|
}
|
|
130
190
|
return filteringProps.filteredNodePaths
|
|
@@ -137,68 +197,33 @@ function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNode) {
|
|
|
137
197
|
* and `autoExpand`) to be set based on the filter paths and filtering options. This function calculates
|
|
138
198
|
* these props for a child node based on its key or path matcher.
|
|
139
199
|
*
|
|
140
|
-
* When using `pathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies
|
|
200
|
+
* When using `pathMatcher` or `asyncPathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies
|
|
141
201
|
* to their node. For example, only some parts of the identifier can be checked for improved performance. Otherwise, the
|
|
142
202
|
* `nodeKey` prop can be used to check the whole identifier.
|
|
203
|
+
*
|
|
204
|
+
* There are multiple overloads of `createChildNodeProps`: depending on props type it returns different values:
|
|
205
|
+
* - `parentKeys` is defined and `pathMatcher` or `nodeKey` is provided - returns undefined **or** `filtering` and `autoExpand` prop from `HierarchyNode`;
|
|
206
|
+
* - `parentKeys` is undefined - does not return `HierarchyNode.autoExpand` option;
|
|
207
|
+
* - props have `asyncPathMatcher` - returns either Promise or the regular return value based on whether or not `asyncPathMatcher` returns a promise.
|
|
143
208
|
*/
|
|
144
|
-
createChildNodeProps
|
|
145
|
-
if (!hasFilter) {
|
|
146
|
-
return undefined;
|
|
147
|
-
}
|
|
148
|
-
const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);
|
|
149
|
-
filteringProps.filteredNodePaths.forEach((filteredPath) => {
|
|
150
|
-
const normalizedPath = HierarchyFilteringPath.normalize(filteredPath);
|
|
151
|
-
if ("nodeKey" in props &&
|
|
152
|
-
((HierarchyNodeKey_js_1.HierarchyNodeKey.isGeneric(props.nodeKey) && HierarchyNodeIdentifier_js_1.HierarchyNodeIdentifier.equal(normalizedPath.path[0], props.nodeKey)) ||
|
|
153
|
-
(HierarchyNodeKey_js_1.HierarchyNodeKey.isInstances(props.nodeKey) && props.nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier_js_1.HierarchyNodeIdentifier.equal(normalizedPath.path[0], ik))))) {
|
|
154
|
-
reducer.accept(normalizedPath);
|
|
155
|
-
}
|
|
156
|
-
else if ("pathMatcher" in props && props.pathMatcher(normalizedPath.path[0])) {
|
|
157
|
-
reducer.accept(normalizedPath);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
return reducer.getNodeProps(parentNode);
|
|
161
|
-
},
|
|
162
|
-
/**
|
|
163
|
-
* Similar to `createChildNodeProps`, but takes an async `pathMatcher` prop.
|
|
164
|
-
*/
|
|
165
|
-
createChildNodePropsAsync: (props) => {
|
|
166
|
-
if (!hasFilter) {
|
|
167
|
-
return undefined;
|
|
168
|
-
}
|
|
169
|
-
const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);
|
|
170
|
-
const matchedPathPromises = new Array();
|
|
171
|
-
for (const filteredChildrenNodeIdentifierPath of filteringProps.filteredNodePaths) {
|
|
172
|
-
const normalizedPath = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);
|
|
173
|
-
/* c8 ignore next 3 */
|
|
174
|
-
if (normalizedPath.path.length === 0) {
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
const matchesPossiblyPromise = props.pathMatcher(normalizedPath.path[0]);
|
|
178
|
-
if (matchesPossiblyPromise instanceof Promise) {
|
|
179
|
-
matchedPathPromises.push(matchesPossiblyPromise.then((matches) => (matches ? normalizedPath : undefined)));
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
|
-
if (!matchesPossiblyPromise) {
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
reducer.accept(normalizedPath);
|
|
186
|
-
}
|
|
187
|
-
if (matchedPathPromises.length === 0) {
|
|
188
|
-
return reducer.getNodeProps(parentNode);
|
|
189
|
-
}
|
|
190
|
-
return Promise.all(matchedPathPromises)
|
|
191
|
-
.then((matchedPath) => matchedPath.forEach((normalizedPath) => normalizedPath && reducer.accept(normalizedPath)))
|
|
192
|
-
.then(() => reducer.getNodeProps(parentNode));
|
|
193
|
-
},
|
|
209
|
+
createChildNodeProps,
|
|
194
210
|
};
|
|
195
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* Extracts information from filtering paths and later returns `filtering` and `autoExpand` values from `HierarchyNode`.
|
|
214
|
+
*
|
|
215
|
+
* 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`.
|
|
216
|
+
*
|
|
217
|
+
* Extracts information using `accept` function:
|
|
218
|
+
* - Determines if node is filter target, and if it is saves the options as `filterTargetOptions`
|
|
219
|
+
* - Saves `HierarchyFilteringPathOptions` and `filteredChildrenIdentifierPaths`
|
|
220
|
+
*/
|
|
196
221
|
class MatchingFilteringPathsReducer {
|
|
197
222
|
_hasFilterTargetAncestor;
|
|
198
223
|
_filteredChildrenIdentifierPaths = new Array();
|
|
199
224
|
_isFilterTarget = false;
|
|
200
225
|
_filterTargetOptions = undefined;
|
|
201
|
-
|
|
226
|
+
_revealOption = false;
|
|
202
227
|
constructor(_hasFilterTargetAncestor) {
|
|
203
228
|
this._hasFilterTargetAncestor = _hasFilterTargetAncestor;
|
|
204
229
|
}
|
|
@@ -210,28 +235,10 @@ class MatchingFilteringPathsReducer {
|
|
|
210
235
|
}
|
|
211
236
|
else if (path.length > 1) {
|
|
212
237
|
this._filteredChildrenIdentifierPaths.push({ path: path.slice(1), options });
|
|
213
|
-
this.
|
|
238
|
+
this._revealOption = HierarchyFilteringPathOptions.mergeRevealOptions(options?.reveal, this._revealOption);
|
|
214
239
|
}
|
|
215
240
|
}
|
|
216
|
-
|
|
217
|
-
if (this._autoExpandOption === true) {
|
|
218
|
-
return true;
|
|
219
|
-
}
|
|
220
|
-
if (typeof this._autoExpandOption === "object") {
|
|
221
|
-
const parentLength = !parentNode
|
|
222
|
-
? 0
|
|
223
|
-
: "depthInHierarchy" in this._autoExpandOption
|
|
224
|
-
? 1 + parentNode.parentKeys.length
|
|
225
|
-
: 1 + parentNode.parentKeys.filter((key) => !HierarchyNodeKey_js_1.HierarchyNodeKey.isGrouping(key)).length;
|
|
226
|
-
const depth = "depthInHierarchy" in this._autoExpandOption
|
|
227
|
-
? this._autoExpandOption.depthInHierarchy
|
|
228
|
-
: // With `depthInPath` option we don't want to expand node that is at the `depthInPath` position
|
|
229
|
-
this._autoExpandOption.depthInPath - 1;
|
|
230
|
-
return parentLength < depth;
|
|
231
|
-
}
|
|
232
|
-
return false;
|
|
233
|
-
}
|
|
234
|
-
getNodeProps(parentNode) {
|
|
241
|
+
getNodeProps(parentKeys) {
|
|
235
242
|
return {
|
|
236
243
|
...(this._hasFilterTargetAncestor || this._isFilterTarget || this._filteredChildrenIdentifierPaths.length > 0
|
|
237
244
|
? {
|
|
@@ -242,8 +249,29 @@ class MatchingFilteringPathsReducer {
|
|
|
242
249
|
},
|
|
243
250
|
}
|
|
244
251
|
: undefined),
|
|
245
|
-
...(
|
|
252
|
+
...(parentKeys &&
|
|
253
|
+
(shouldAutoExpandBasedOnReveal({
|
|
254
|
+
reveal: this._revealOption,
|
|
255
|
+
nodePositionInHierarchy: parentKeys.length,
|
|
256
|
+
nodePositionInPath: parentKeys.filter((key) => !HierarchyNodeKey_js_1.HierarchyNodeKey.isGrouping(key)).length,
|
|
257
|
+
}) ||
|
|
258
|
+
!!this._filterTargetOptions?.autoExpand)
|
|
259
|
+
? { autoExpand: true }
|
|
260
|
+
: undefined),
|
|
246
261
|
};
|
|
247
262
|
}
|
|
248
263
|
}
|
|
264
|
+
/** @internal */
|
|
265
|
+
function shouldAutoExpandBasedOnReveal({ reveal, nodePositionInPath, nodePositionInHierarchy, }) {
|
|
266
|
+
if (!reveal) {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
if (reveal === true) {
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
if ("depthInHierarchy" in reveal) {
|
|
273
|
+
return nodePositionInHierarchy < reveal.depthInHierarchy;
|
|
274
|
+
}
|
|
275
|
+
return nodePositionInPath < reveal.depthInPath;
|
|
276
|
+
}
|
|
249
277
|
//# sourceMappingURL=HierarchyFiltering.js.map
|