@itwin/presentation-hierarchies 2.0.0-alpha.12 → 2.0.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +301 -16
- package/README.md +2 -2
- package/lib/cjs/hierarchies/HierarchyNode.d.ts +13 -11
- package/lib/cjs/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNode.js +18 -0
- package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeIdentifier.d.ts +2 -0
- package/lib/cjs/hierarchies/HierarchyNodeIdentifier.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeIdentifier.js +23 -6
- package/lib/cjs/hierarchies/HierarchyNodeIdentifier.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts +5 -4
- package/lib/cjs/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyNodeKey.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts +3 -3
- package/lib/cjs/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/HierarchySearch.d.ts +206 -78
- package/lib/cjs/hierarchies/HierarchySearch.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchySearch.js +315 -113
- package/lib/cjs/hierarchies/HierarchySearch.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts +2 -2
- package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.d.ts +3 -3
- package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyNode.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts +9 -4
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +25 -16
- package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts +4 -4
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js +12 -9
- package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts +3 -3
- package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.d.ts +2 -2
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.js +31 -55
- package/lib/cjs/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts +2 -2
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.js +1 -1
- package/lib/cjs/hierarchies/imodel/TreeNodesReader.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js +4 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
- package/lib/cjs/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.d.ts +2 -2
- package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/ReduceToMergeMap.js.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/Sorting.d.ts.map +1 -1
- package/lib/cjs/hierarchies/internal/operators/Sorting.js.map +1 -1
- package/lib/cjs/presentation-hierarchies.d.ts +1 -1
- package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies.js +2 -1
- package/lib/cjs/presentation-hierarchies.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNode.d.ts +13 -11
- package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNode.js +18 -0
- package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeIdentifier.d.ts +2 -0
- package/lib/esm/hierarchies/HierarchyNodeIdentifier.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeIdentifier.js +23 -6
- package/lib/esm/hierarchies/HierarchyNodeIdentifier.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeKey.d.ts +5 -4
- package/lib/esm/hierarchies/HierarchyNodeKey.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyNodeKey.js.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.d.ts +3 -3
- package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/HierarchySearch.d.ts +206 -78
- package/lib/esm/hierarchies/HierarchySearch.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchySearch.js +314 -111
- package/lib/esm/hierarchies/HierarchySearch.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts +2 -2
- package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyNode.d.ts +3 -3
- package/lib/esm/hierarchies/imodel/IModelHierarchyNode.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyNode.js.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts +9 -4
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +26 -17
- package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts +4 -4
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js +13 -10
- package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
- package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts +3 -3
- package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.d.ts +2 -2
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.js +32 -56
- package/lib/esm/hierarchies/imodel/SearchHierarchyDefinition.js.map +1 -1
- package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts +2 -2
- package/lib/esm/hierarchies/imodel/TreeNodesReader.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/TreeNodesReader.js +2 -2
- package/lib/esm/hierarchies/imodel/TreeNodesReader.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/BaseClassGrouping.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js +4 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/ClassGrouping.js.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.d.ts.map +1 -1
- package/lib/esm/hierarchies/imodel/operators/grouping/PropertiesGrouping.js.map +1 -1
- package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.d.ts +2 -2
- package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/ReduceToMergeMap.js.map +1 -1
- package/lib/esm/hierarchies/internal/operators/Sorting.d.ts.map +1 -1
- package/lib/esm/hierarchies/internal/operators/Sorting.js.map +1 -1
- package/lib/esm/presentation-hierarchies.d.ts +1 -1
- package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies.js +1 -1
- package/lib/esm/presentation-hierarchies.js.map +1 -1
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,226 @@
|
|
|
1
1
|
# @itwin/presentation-hierarchies
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.14
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1264](https://github.com/iTwin/presentation/pull/1264): Enhance `HierarchySearchTree.createBuilder()` by allowing it to process resulting hierarchy.
|
|
8
|
+
|
|
9
|
+
Example:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
const builder = HierarchySearchTree.createBuilder<{ heat?: number }>();
|
|
13
|
+
builder.accept({
|
|
14
|
+
tree: subTree,
|
|
15
|
+
handler: {
|
|
16
|
+
onEntryHandled: ({ treeEntry, parentEntries }) => {
|
|
17
|
+
// Assign some extra information to the entry and its ancestors. This will allow us to test
|
|
18
|
+
// that we can use that information in `getTree` method to filter out entries.
|
|
19
|
+
[...parentEntries, treeEntry].forEach((entry) => {
|
|
20
|
+
entry.extras.heat ? entry.extras.heat++ : (entry.extras.heat = 1);
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
const tree = builder.getTree({
|
|
26
|
+
// Only include branches with heat > 5
|
|
27
|
+
processEntry: ({ treeEntry }) =>
|
|
28
|
+
(treeEntry.extras.heat ?? 0) > 5 ? treeEntry : undefined,
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- [#1256](https://github.com/iTwin/presentation/pull/1256): Fix `alpha` dependencies being specified with a range (`^`), allowing package manager to use higher versions, possibly with breaking changes.
|
|
35
|
+
|
|
36
|
+
## 2.0.0-alpha.13
|
|
37
|
+
|
|
38
|
+
### Major Changes
|
|
39
|
+
|
|
40
|
+
- [#1250](https://github.com/iTwin/presentation/pull/1250): Use type-safe full class names.
|
|
41
|
+
|
|
42
|
+
The full class names used in this package were defined as `string`, although we always expect them to be in specific format - either `Schema:Class` or `Schema.Class`. In many cases we rely on this format when parsing the name for compare or other purposes, so type safety for the format is highly beneficial. This change makes full class names type-safe(ier) through [TypeScript's template literal types](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html), so that we can be sure that they are always in correct format.
|
|
43
|
+
|
|
44
|
+
## Breaking changes
|
|
45
|
+
|
|
46
|
+
- `ClassGroupingNodeKey.className` is now of type `EC.FullClassName` instead of `string`.
|
|
47
|
+
- `NodesQueryClauseFactory.createSelectClause` prop `grouping.byBaseClasses.fullClassNames` is now of type `EC.FullClassName[]` instead of `string[]`.
|
|
48
|
+
- `NodesQueryClauseFactory.createSelectClause` prop `grouping.byProperties.propertiesClassName` is now of type `EC.FullClassName` instead of `string`.
|
|
49
|
+
- `HierarchyNodesDefinition.fullClassName` is now of type `EC.FullClassName` instead of `string`.
|
|
50
|
+
- `createPredicateBasedHierarchyDefinition` prop `hierarchies.childNodes[number].parentInstancesNodePredicate` now accepts `EC.FullClassName` instead of `string`.
|
|
51
|
+
- `NodesQueryClauseFactory.createFilterClauses` prop `contentClass.fullName` is now of type `EC.FullClassName` instead of `string`.
|
|
52
|
+
- `PropertyOtherValuesGroupingNodeKey.properties[number].className` is now of type `EC.FullClassName` instead of `string`.
|
|
53
|
+
- `PropertyValueGroupingNodeKey.propertyClassName` is now of type `EC.FullClassName` instead of `string`.
|
|
54
|
+
- `PropertyValueRangeGroupingNodeKey.propertyClassName` is now of type `EC.FullClassName` instead of `string`.
|
|
55
|
+
|
|
56
|
+
In many cases migration will be seamless, as long as the input string matches the expected format. In some cases (e.g. when assigning a string variable to one of the affected properties), you may need to use `normalizeFullClassName` from `@itwin/presentation-shared` to ensure the value is of the correct type:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
const myClassName: string = "MySchema.MyClass";
|
|
60
|
+
|
|
61
|
+
// before
|
|
62
|
+
const myClassGroupingNodeKey: ClassGroupingNodeKey = {
|
|
63
|
+
type: "class-grouping",
|
|
64
|
+
className: myClassName,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// after
|
|
68
|
+
const myClassGroupingNodeKey: ClassGroupingNodeKey = {
|
|
69
|
+
type: "class-grouping",
|
|
70
|
+
// assigning `MySchema.MyClass` directly wouldn't require using `normalizeFullClassName` as the type would be correctly inferred, but if the class name is stored in a variable of type `string`, you need to use `normalizeFullClassName` to ensure it's of the correct type
|
|
71
|
+
className: normalizeFullClassName(myClassName),
|
|
72
|
+
};
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
- [#1236](https://github.com/iTwin/presentation/pull/1236): Start using tree structure for defining hierarchy search paths.
|
|
76
|
+
|
|
77
|
+
**Additions:**
|
|
78
|
+
|
|
79
|
+
- `HierarchySearchTree` type that represents a tree structure of hierarchy search paths and is now used for hierarchy search implementation in `HierarchyProvider`.
|
|
80
|
+
|
|
81
|
+
In addition to the type, there's also a namespace with the same name, providing utility functions for working with the tree structure:
|
|
82
|
+
|
|
83
|
+
- `HierarchySearchTree.createBuilder` function to create a builder for hierarchy search trees, which can be used to create a tree from individual paths or to merge multiple trees together:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
const builder = HierarchySearchTree.createBuilder();
|
|
87
|
+
builder.accept({ path: searchPath1 });
|
|
88
|
+
builder.accept({ path: searchPath2 });
|
|
89
|
+
builder.accept({ tree: partialSearchTree });
|
|
90
|
+
const tree: HierarchySearchTree[] = builder.getTree();
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
This is the preferred way to create a `HierarchySearchTree`, as it allows to create a tree without having to create an array first, as opposed to `HierarchySearchTree.createFromPathsList` function described below.
|
|
94
|
+
|
|
95
|
+
- `HierarchySearchTree.createFromPathsList` function to create a hierarchy search tree from a list of hierarchy search paths. This is a quick & easy way to migrate from the old `HierarchySearchPath[]` structure to `HierarchySearchTree[]`, but it's' less efficient than using the builder if you need to create a tree from a large number of paths, as it needs to create an intermediate array.
|
|
96
|
+
|
|
97
|
+
The recommended way to handle multiple search paths is to use the builder and call `accept` for each path, as it allows to create a tree without having to create an array first:
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
// Instead of doing this:
|
|
101
|
+
const searchPaths: HierarchySearchPath[] = [];
|
|
102
|
+
for (const item of items) {
|
|
103
|
+
searchPaths.push(createSearchPathForItem(item));
|
|
104
|
+
}
|
|
105
|
+
const tree: HierarchySearchTree[] =
|
|
106
|
+
await HierarchySearchTree.createFromPathsList(searchPaths);
|
|
107
|
+
|
|
108
|
+
// Do this:
|
|
109
|
+
const builder = HierarchySearchTree.createBuilder();
|
|
110
|
+
for (const item of items) {
|
|
111
|
+
builder.accept({ path: createSearchPathForItem(item) });
|
|
112
|
+
}
|
|
113
|
+
const tree: HierarchySearchTree[] = builder.getTree();
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- `HierarchySearchTree.mergeOptions` function to merge options of two hierarchy search trees. Used internally to merge options of the same nodes when creating a tree from a list of paths.
|
|
117
|
+
|
|
118
|
+
- `HierarchyNode.getGroupingNodeLevel` utility function to get the level of a grouping node in the hierarchy. Convenient for specifying the `groupingLevel` prop in `HierarchySearchPath.options.reveal` and `HierarchySearchTree.options.autoExpand`.
|
|
119
|
+
|
|
120
|
+
- `HierarchyNodeIdentifier.compare` static function to compare two `HierarchyNodeIdentifier` objects. Useful when using `HierarchyNodeIdentifier` as a key in a dictionary sorted set.
|
|
121
|
+
|
|
122
|
+
**Breaking changes:**
|
|
123
|
+
|
|
124
|
+
- `HierarchySearchPathOptions.reveal` type `{ depthInHierarchy: number }` was replaced with `{ groupingLevel: number }`.
|
|
125
|
+
|
|
126
|
+
The `depthInHierarchy` option was only useful when revealing grouping nodes, the rename makes the intent more explicit. In addition, the `groupingLevel` option is only handled in the scope of one specific `InstancesNode` node that the options are supplied for, so handling this option is more efficient - we only need to handle it for grouping nodes, and look only as deep as the next grouped `InstancesNode` node.
|
|
127
|
+
|
|
128
|
+
Migration:
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
const groupingNode = getMyGroupingNode();
|
|
132
|
+
const searchPath: HierarchySearchPath = {
|
|
133
|
+
// ...
|
|
134
|
+
options: {
|
|
135
|
+
// before
|
|
136
|
+
reveal: { depthInHierarchy: groupingNode.parentKeys.length },
|
|
137
|
+
|
|
138
|
+
// after
|
|
139
|
+
reveal: {
|
|
140
|
+
groupingLevel: HierarchyNode.getGroupingNodeLevel(groupingNode),
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
- `HierarchyProvider.setHierarchySearch` now takes `{ paths: HierarchySearchTree[] }` instead of `{ paths: HierarchySearchPath[] }`.
|
|
147
|
+
|
|
148
|
+
Migration:
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
const provider: HierarchyProvider = getMyHierarchyProvider();
|
|
152
|
+
const searchPaths: HierarchySearchPath[] = getMySearchPaths();
|
|
153
|
+
provider.setHierarchySearch({
|
|
154
|
+
// before
|
|
155
|
+
paths: searchPaths,
|
|
156
|
+
|
|
157
|
+
// after
|
|
158
|
+
// - see `HierarchySearchTree.createFromPathsList` description above for more efficient way to do this
|
|
159
|
+
// - quick migration:
|
|
160
|
+
paths: await HierarchySearchTree.createFromPathsList(searchPaths),
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
- `createIModelHierarchyProvider` and `createMergedIModelHierarchyProvider` functions' `search` prop now takes `{ paths: HierarchySearchTree[] }` instead of `{ paths: HierarchySearchPath[] }`. Use `HierarchySearchTree.createFromPathsList` to do the conversion.
|
|
165
|
+
|
|
166
|
+
Migration:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
const searchPaths: HierarchySearchPath[] = getMySearchPaths();
|
|
170
|
+
const provider = createIModelHierarchyProvider({
|
|
171
|
+
// ...
|
|
172
|
+
search: {
|
|
173
|
+
// before
|
|
174
|
+
paths: searchPaths,
|
|
175
|
+
|
|
176
|
+
// after
|
|
177
|
+
// - see `HierarchySearchTree.createFromPathsList` description above for more efficient way to do this
|
|
178
|
+
// - quick migration:
|
|
179
|
+
paths: await HierarchySearchTree.createFromPathsList(searchPaths),
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
- `HierarchyNode.search` changes:
|
|
185
|
+
|
|
186
|
+
- Type of `childrenTargetPaths` has been changed from `HierarchySearchPath[]` to `HierarchySearchTree[]`.
|
|
187
|
+
- `searchTargetOptions` was replaced with `options`, which is available not only for nodes with `isSearchTarget: true`, but all of them.
|
|
188
|
+
|
|
189
|
+
The changes of this attribute are taken care of by the `createHierarchySearchHelper` changes described below.
|
|
190
|
+
|
|
191
|
+
- `createHierarchySearchHelper` changes:
|
|
192
|
+
|
|
193
|
+
- The first argument is now `HierarchySearchTree[]` instead of `HierarchySearchPath[]`.
|
|
194
|
+
- The `createChildNodeProps` function of returned result no longer requires the `parentKeys` prop, but instead always requires the `nodeKey` prop.
|
|
195
|
+
|
|
196
|
+
Migration:
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
// Somewhere in `HierarchyProvider.getNodes` implementation...
|
|
200
|
+
|
|
201
|
+
// Type of the first argument has changed, but it also changed on `HierarchyProvider`, so likely no changes are needed here. If the
|
|
202
|
+
// type of `rootSearch.paths` is still `HierarchySearchPath[]` - use `HierarchySearchTree.createFromPathsList` to do the conversion.
|
|
203
|
+
const helper = createHierarchySearchHelper(rootSearch?.paths, parentNode);
|
|
204
|
+
for (const book of books) {
|
|
205
|
+
const nodeKey: GenericNodeKey = { type: "generic", id: `book:${book.key}` };
|
|
206
|
+
yield {
|
|
207
|
+
key: nodeKey,
|
|
208
|
+
label: book.title,
|
|
209
|
+
children: false,
|
|
210
|
+
parentKeys: [...parentNode.parentKeys, parentNode.key],
|
|
211
|
+
// before
|
|
212
|
+
...searchHelper?.createChildNodeProps({ nodeKey, parentKeys }),
|
|
213
|
+
// after
|
|
214
|
+
...searchHelper?.createChildNodeProps({ nodeKey }),
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Patch Changes
|
|
220
|
+
|
|
221
|
+
- Updated dependencies:
|
|
222
|
+
- @itwin/presentation-shared@2.0.0-alpha.9
|
|
223
|
+
|
|
3
224
|
## 2.0.0-alpha.12
|
|
4
225
|
|
|
5
226
|
### Patch Changes
|
|
@@ -91,15 +312,21 @@
|
|
|
91
312
|
// or, provide implementation as a class instance:
|
|
92
313
|
const afterAsClassObject = createHierarchyProvider(
|
|
93
314
|
({ hierarchyChanged }) =>
|
|
94
|
-
new (class
|
|
95
|
-
|
|
315
|
+
new (class
|
|
316
|
+
implements Pick<HierarchyProvider, "getNodes" | "setFormatter">
|
|
317
|
+
{
|
|
318
|
+
public async *getNodes({
|
|
319
|
+
parentNode,
|
|
320
|
+
}): ReturnType<HierarchyProvider["getNodes"]> {
|
|
96
321
|
// yield nodes...
|
|
97
322
|
}
|
|
98
323
|
public setFormatter(formatter: IPrimitiveValueFormatter | undefined) {
|
|
99
324
|
// set formatter...
|
|
100
|
-
hierarchyChanged.raiseEvent({
|
|
325
|
+
hierarchyChanged.raiseEvent({
|
|
326
|
+
formatterChange: { newFormatter: formatter },
|
|
327
|
+
});
|
|
101
328
|
}
|
|
102
|
-
})()
|
|
329
|
+
})()
|
|
103
330
|
);
|
|
104
331
|
```
|
|
105
332
|
|
|
@@ -126,6 +353,7 @@
|
|
|
126
353
|
the `createNodesQueryClauseFactory` function should be called with `imodelAccess` that is passed to `HierarchyDefinition.defineHierarchyLevel`.
|
|
127
354
|
|
|
128
355
|
**Breaking changes:**
|
|
356
|
+
|
|
129
357
|
- `DefineHierarchyLevelProps.imodelKey` was replaced with `imodelAccess`. If needed, the key can be accessed using `imodelAccess.imodelKey`. This affects the following APIs:
|
|
130
358
|
- `HierarchyDefinition.defineHierarchyLevel` (function that uses these props),
|
|
131
359
|
- `DefineRootHierarchyLevelProps` (extends the props type),
|
|
@@ -138,6 +366,7 @@
|
|
|
138
366
|
- [#1137](https://github.com/iTwin/presentation/pull/1137): Fix hierarchy search only handling a single (latest) iModel results when searching multi-iModel hierarchies.
|
|
139
367
|
|
|
140
368
|
Notable API changes:
|
|
369
|
+
|
|
141
370
|
- **BREAKING:** `NodeParser` (type of `HierarchyDefinition.parseNode` function) now gets a single props argument instead of multiple arguments. In addition, the props object now also contains an imodel key argument.
|
|
142
371
|
|
|
143
372
|
```ts
|
|
@@ -172,6 +401,7 @@
|
|
|
172
401
|
Properties and APIs were renamed accordingly to clarify the distinction and avoid confusion between hierarchy‑wide search and per-hierarchy‑level filtering.
|
|
173
402
|
|
|
174
403
|
**Breaking changes:**
|
|
404
|
+
|
|
175
405
|
- Removed deprecated `extractFilteringProps`.
|
|
176
406
|
- Removed deprecated `HierarchyNodeFilteringProps.create`.
|
|
177
407
|
- Renamed `createHierarchyFilteringHelper` to `createHierarchySearchHelper`. It's return type was also adjusted for the rename:
|
|
@@ -196,6 +426,7 @@
|
|
|
196
426
|
- 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.
|
|
197
427
|
|
|
198
428
|
**Breaking changes:**
|
|
429
|
+
|
|
199
430
|
- `GroupingHierarchyNode` no longer contains `filtering` attribute. This was always the case, but now the types have been updated to match it.
|
|
200
431
|
- Changed return type of `createHierarchyFilteringHelper`:
|
|
201
432
|
- Removed `createChildNodePropsAsync` - it became an overload of `createChildNodeProps`, whose path matching is done through `asyncPathMatcher` callback.
|
|
@@ -258,6 +489,7 @@
|
|
|
258
489
|
### Major Changes
|
|
259
490
|
|
|
260
491
|
- [#954](https://github.com/iTwin/presentation/pull/954): Add additional requirements for types in `EC` metadata namespace, whose objects are returned by `ECSchemaProvider`.
|
|
492
|
+
|
|
261
493
|
- `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.
|
|
262
494
|
- `EC.Class` now additionally has these members:
|
|
263
495
|
- `baseClass: Promise<Class | undefined>`
|
|
@@ -276,6 +508,14 @@
|
|
|
276
508
|
- Updated dependencies:
|
|
277
509
|
- @itwin/presentation-shared@2.0.0-alpha.0
|
|
278
510
|
|
|
511
|
+
## 1.7.11
|
|
512
|
+
|
|
513
|
+
### Patch Changes
|
|
514
|
+
|
|
515
|
+
- [#1242](https://github.com/iTwin/presentation/pull/1242): Bump dependencies.
|
|
516
|
+
- Updated dependencies:
|
|
517
|
+
- @itwin/presentation-shared@1.2.10
|
|
518
|
+
|
|
279
519
|
## 1.7.10
|
|
280
520
|
|
|
281
521
|
### Patch Changes
|
|
@@ -356,6 +596,7 @@
|
|
|
356
596
|
### Minor Changes
|
|
357
597
|
|
|
358
598
|
- 8f7d200926b93e862276e1f978f6c891691e0dae: Refactored specifying the depth / level to which filtering path should be auto-expanded.
|
|
599
|
+
|
|
359
600
|
- Deprecated `FilteringPathAutoExpandOption` and `FilterTargetGroupingNodeInfo`.
|
|
360
601
|
- Added `FilteringPathAutoExpandDepthInPath` and `FilteringPathAutoExpandDepthInHierarchy` which should be used instead.
|
|
361
602
|
|
|
@@ -420,7 +661,10 @@
|
|
|
420
661
|
**Before:**
|
|
421
662
|
|
|
422
663
|
```ts
|
|
423
|
-
const childNodeProps = await createHierarchyFilteringHelper(
|
|
664
|
+
const childNodeProps = await createHierarchyFilteringHelper(
|
|
665
|
+
undefined,
|
|
666
|
+
undefined
|
|
667
|
+
).createChildNodePropsAsync({
|
|
424
668
|
pathMatcher: (identifier): boolean | Promise<boolean> => {
|
|
425
669
|
return false;
|
|
426
670
|
},
|
|
@@ -428,6 +672,7 @@
|
|
|
428
672
|
```
|
|
429
673
|
|
|
430
674
|
**After:**
|
|
675
|
+
|
|
431
676
|
- **Option A:** check if it's a Promise before awaiting:
|
|
432
677
|
|
|
433
678
|
Use this when you want to get slightly better performance by avoiding unnecessary `await`.
|
|
@@ -446,7 +691,10 @@
|
|
|
446
691
|
Use this if pathMatcher always returns a Promise or you prefer a simpler pattern.
|
|
447
692
|
|
|
448
693
|
```ts
|
|
449
|
-
const childNodeProps = await createHierarchyFilteringHelper(
|
|
694
|
+
const childNodeProps = await createHierarchyFilteringHelper(
|
|
695
|
+
undefined,
|
|
696
|
+
undefined
|
|
697
|
+
).createChildNodePropsAsync({
|
|
450
698
|
pathMatcher: async (identifier): Promise<boolean> => {
|
|
451
699
|
return false;
|
|
452
700
|
},
|
|
@@ -512,6 +760,7 @@
|
|
|
512
760
|
- [#783](https://github.com/iTwin/presentation/pull/783): Added hierarchy filtering helper to make hierarchy filtering easier to implement.
|
|
513
761
|
|
|
514
762
|
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:
|
|
763
|
+
|
|
515
764
|
- `hasFilter` tells if the hierarchy level has a filter applied.
|
|
516
765
|
- `hasFilterTargetAncestor` tells if there's a filter target ancestor node up in the hierarchy.
|
|
517
766
|
- `getChildNodeFilteringIdentifiers()` returns an array of hierarchy node identifiers that apply specifically for this hierarchy level.
|
|
@@ -520,6 +769,7 @@
|
|
|
520
769
|
See the [Implementing hierarchy filtering support](./learning/CustomHierarchyProviders.md#implementing-hierarchy-filtering-support) learning page for a usage example.
|
|
521
770
|
|
|
522
771
|
In addition, deprecated a few APIs that are replaced by filtering helper:
|
|
772
|
+
|
|
523
773
|
- `extractFilteringProps` function,
|
|
524
774
|
- `HierarchyNodeFilteringProps.create` function.
|
|
525
775
|
|
|
@@ -565,6 +815,7 @@
|
|
|
565
815
|
| 50k | not tested | 13.45 s |
|
|
566
816
|
|
|
567
817
|
In addition, changed `NodeParser` (return type of `HierarchyDefinition.parseNode`):
|
|
818
|
+
|
|
568
819
|
- It now can return a promise, so instead of just `SourceInstanceHierarchyNode` it can now also return `Promise<SourceInstanceHierarchyNode>`.
|
|
569
820
|
- Additionally, it now accepts an optional `parentNode` argument of `HierarchyDefinitionParentNode` type.
|
|
570
821
|
|
|
@@ -596,6 +847,7 @@
|
|
|
596
847
|
### Minor Changes
|
|
597
848
|
|
|
598
849
|
- [#708](https://github.com/iTwin/presentation/pull/708): **BREAKING:** Added support for creating hierarchies from multiple data sources.
|
|
850
|
+
|
|
599
851
|
- `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.
|
|
600
852
|
- `HierarchyNode` terminology and related changes:
|
|
601
853
|
- "Standard" nodes were renamed to "IModel" nodes to signify the fact that they're based on iModel data:
|
|
@@ -623,6 +875,7 @@
|
|
|
623
875
|
- The returned provider now has a `dispose` method to clean up resources - make sure to call it when the provider is no longer needed.
|
|
624
876
|
- 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.
|
|
625
877
|
- Renamed `createClassBasedHierarchyDefinition` to `createPredicateBasedHierarchyDefinition` to signify its props changes:
|
|
878
|
+
|
|
626
879
|
- 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.
|
|
627
880
|
- 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.
|
|
628
881
|
|
|
@@ -675,6 +928,7 @@
|
|
|
675
928
|
```
|
|
676
929
|
|
|
677
930
|
- [#708](https://github.com/iTwin/presentation/pull/708): Added utilities for custom hierarchy filtering handling:
|
|
931
|
+
|
|
678
932
|
- `extractFilteringProps` function, given root level hierarchy filtering paths and a parent node, returns props required to filter particular hierarchy level.
|
|
679
933
|
- `HierarchyFilteringPath` interface is now public and there's also a similarly-named namespace with the following utilities:
|
|
680
934
|
- `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.
|
|
@@ -703,7 +957,9 @@
|
|
|
703
957
|
```ts
|
|
704
958
|
const selectQueryFactory = createNodesQueryClauseFactory({
|
|
705
959
|
imodelAccess,
|
|
706
|
-
instanceLabelSelectClauseFactory: createBisInstanceLabelSelectClauseFactory(
|
|
960
|
+
instanceLabelSelectClauseFactory: createBisInstanceLabelSelectClauseFactory(
|
|
961
|
+
{ classHierarchyInspector: imodelAccess }
|
|
962
|
+
),
|
|
707
963
|
});
|
|
708
964
|
```
|
|
709
965
|
|
|
@@ -726,7 +982,12 @@
|
|
|
726
982
|
// Path to the element "C"
|
|
727
983
|
path: [elementKeys.a, elementKeys.b, elementKeys.c],
|
|
728
984
|
// Supply grouping node attributes with the path to the "C" element.
|
|
729
|
-
options: {
|
|
985
|
+
options: {
|
|
986
|
+
autoExpand: {
|
|
987
|
+
key: groupingNode.key,
|
|
988
|
+
depth: groupingNode.parentKeys.length,
|
|
989
|
+
},
|
|
990
|
+
},
|
|
730
991
|
},
|
|
731
992
|
],
|
|
732
993
|
},
|
|
@@ -765,7 +1026,12 @@
|
|
|
765
1026
|
const hierarchyProvider = createHierarchyProvider({
|
|
766
1027
|
imodelAccess,
|
|
767
1028
|
hierarchyDefinition: createHierarchyDefinition(imodelAccess),
|
|
768
|
-
filtering: {
|
|
1029
|
+
filtering: {
|
|
1030
|
+
paths: filterPaths.map((path) => ({
|
|
1031
|
+
path,
|
|
1032
|
+
options: { autoExpand: true },
|
|
1033
|
+
})),
|
|
1034
|
+
},
|
|
769
1035
|
});
|
|
770
1036
|
```
|
|
771
1037
|
|
|
@@ -807,12 +1073,18 @@
|
|
|
807
1073
|
childNodes: [
|
|
808
1074
|
{
|
|
809
1075
|
parentNodeClassName: "BisCore.PhysicalElement",
|
|
810
|
-
definitions: async ({ parentNode }) =>
|
|
1076
|
+
definitions: async ({ parentNode }) =>
|
|
1077
|
+
getPhysicalElementChildren(parentNode),
|
|
811
1078
|
},
|
|
812
1079
|
{
|
|
813
1080
|
parentNodeClassName: "BisCore.SpatialElement",
|
|
814
1081
|
definitions: async ({ parentNode, parentNodeClassName }) => {
|
|
815
|
-
if (
|
|
1082
|
+
if (
|
|
1083
|
+
await inspector.classDerivesFrom(
|
|
1084
|
+
parentNodeClassName,
|
|
1085
|
+
"BisCore.PhysicalElement"
|
|
1086
|
+
)
|
|
1087
|
+
) {
|
|
816
1088
|
return [];
|
|
817
1089
|
}
|
|
818
1090
|
|
|
@@ -822,11 +1094,21 @@
|
|
|
822
1094
|
{
|
|
823
1095
|
parentNodeClassName: "BisCore.GeometricElement3d",
|
|
824
1096
|
definitions: async ({ parentNode, parentNodeClassName }) => {
|
|
825
|
-
if (
|
|
1097
|
+
if (
|
|
1098
|
+
await inspector.classDerivesFrom(
|
|
1099
|
+
parentNodeClassName,
|
|
1100
|
+
"BisCore.PhysicalElement"
|
|
1101
|
+
)
|
|
1102
|
+
) {
|
|
826
1103
|
return [];
|
|
827
1104
|
}
|
|
828
1105
|
|
|
829
|
-
if (
|
|
1106
|
+
if (
|
|
1107
|
+
await inspector.classDerivesFrom(
|
|
1108
|
+
parentNodeClassName,
|
|
1109
|
+
"BisCore.SpatialElement"
|
|
1110
|
+
)
|
|
1111
|
+
) {
|
|
830
1112
|
return [];
|
|
831
1113
|
}
|
|
832
1114
|
|
|
@@ -847,17 +1129,20 @@
|
|
|
847
1129
|
childNodes: [
|
|
848
1130
|
{
|
|
849
1131
|
parentNodeClassName: "BisCore.PhysicalElement",
|
|
850
|
-
definitions: async ({ parentNode }) =>
|
|
1132
|
+
definitions: async ({ parentNode }) =>
|
|
1133
|
+
getPhysicalElementChildren(parentNode),
|
|
851
1134
|
},
|
|
852
1135
|
{
|
|
853
1136
|
parentNodeClassName: "BisCore.SpatialElement",
|
|
854
1137
|
onlyIfNotHandled: true,
|
|
855
|
-
definitions: async ({ parentNode }) =>
|
|
1138
|
+
definitions: async ({ parentNode }) =>
|
|
1139
|
+
getSpatialElementChildren(parentNode),
|
|
856
1140
|
},
|
|
857
1141
|
{
|
|
858
1142
|
parentNodeClassName: "BisCore.GeometricElement3d",
|
|
859
1143
|
onlyIfNotHandled: true,
|
|
860
|
-
definitions: async ({ parentNode }) =>
|
|
1144
|
+
definitions: async ({ parentNode }) =>
|
|
1145
|
+
getGeometricElement3dChildren(parentNode),
|
|
861
1146
|
},
|
|
862
1147
|
],
|
|
863
1148
|
},
|
package/README.md
CHANGED
|
@@ -76,7 +76,7 @@ Here's a simple example of how to create a hierarchy provider and build a hierar
|
|
|
76
76
|
```ts
|
|
77
77
|
import { IModelConnection } from "@itwin/core-frontend";
|
|
78
78
|
import { createECSchemaProvider, createECSqlQueryExecutor, createIModelKey } from "@itwin/presentation-core-interop";
|
|
79
|
-
import { createLimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
|
|
79
|
+
import { createLimitingECSqlQueryExecutor, HierarchyLevelDefinition } from "@itwin/presentation-hierarchies";
|
|
80
80
|
import { createCachingECClassHierarchyInspector, Props } from "@itwin/presentation-shared";
|
|
81
81
|
|
|
82
82
|
import {
|
|
@@ -138,7 +138,7 @@ function createProvider(imodelAccess: Props<typeof createIModelHierarchyProvider
|
|
|
138
138
|
{
|
|
139
139
|
// For BisCore.Model parent nodes, select all BisCore.Element instances contained in corresponding model
|
|
140
140
|
parentInstancesNodePredicate: "BisCore.Model",
|
|
141
|
-
definitions: async ({ parentNodeInstanceIds }: DefineInstanceNodeChildHierarchyLevelProps) => [
|
|
141
|
+
definitions: async ({ parentNodeInstanceIds }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> => [
|
|
142
142
|
{
|
|
143
143
|
fullClassName: "BisCore.Element",
|
|
144
144
|
query: {
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { HierarchyNodeKey } from "./HierarchyNodeKey.js";
|
|
2
2
|
import type { OmitOverUnion } from "@itwin/presentation-shared";
|
|
3
3
|
import type { ClassGroupingNodeKey, GenericNodeKey, GroupingNodeKey, IModelHierarchyNodeKey, IModelInstanceKey, InstancesNodeKey, LabelGroupingNodeKey, PropertyGroupingNodeKey, PropertyOtherValuesGroupingNodeKey, PropertyValueGroupingNodeKey, PropertyValueRangeGroupingNodeKey } from "./HierarchyNodeKey.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { HierarchySearchTree } from "./HierarchySearch.js";
|
|
5
5
|
/** @public */
|
|
6
|
-
export
|
|
6
|
+
export interface HierarchyNodeSearchProps {
|
|
7
7
|
/** If set to true, then one of the ancestor nodes in the hierarchy is the search target. */
|
|
8
8
|
hasSearchTargetAncestor?: boolean;
|
|
9
9
|
/** Paths to node's children that are search targets. */
|
|
10
|
-
childrenTargetPaths?:
|
|
11
|
-
} & ({
|
|
10
|
+
childrenTargetPaths?: HierarchySearchTree[];
|
|
12
11
|
/** Whether or not this node is a search target. */
|
|
13
|
-
isSearchTarget?:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/** Options that were used to search the node. */
|
|
18
|
-
searchTargetOptions?: HierarchySearchPathOptions;
|
|
19
|
-
});
|
|
12
|
+
isSearchTarget?: boolean;
|
|
13
|
+
/** Options assigned to this node through search. */
|
|
14
|
+
options?: HierarchySearchTree["options"];
|
|
15
|
+
}
|
|
20
16
|
/**
|
|
21
17
|
* A data structure that defines attributes that are common to all types of hierarchy nodes.
|
|
22
18
|
* @public
|
|
@@ -136,6 +132,12 @@ export declare namespace HierarchyNode {
|
|
|
136
132
|
key: PropertyGroupingNodeKey;
|
|
137
133
|
supportsFiltering?: undefined;
|
|
138
134
|
} & GroupingHierarchyNode;
|
|
135
|
+
/**
|
|
136
|
+
* Gets the grouping level of the given grouping node.
|
|
137
|
+
*
|
|
138
|
+
* May be useful when setting `groupingLevel` for `HierarchySearchTree.options.autoExpand` or `HierarchySearchPathOptions.reveal`.
|
|
139
|
+
*/
|
|
140
|
+
function getGroupingNodeLevel(groupingNode: Pick<GroupingHierarchyNode, "key" | "parentKeys">): number;
|
|
139
141
|
}
|
|
140
142
|
/**
|
|
141
143
|
* A type of `HierarchyNode` that doesn't know about its children and is an input when requesting
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchyNode.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNode.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,sBAAsB,EAC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AG;QAAE,GAAG,EAAE,iCAAiC,CAAC;QAAC,iBAAiB,CAAC,EAAE,SAAS,CAAA;KAAE,GAAG,qBAAqB,CAEnH;IACD,gEAAgE;IAChE,SAAgB,sBAAsB,CAAC,KAAK,SAAS;QAAE,GAAG,EAAE,gBAAgB,CAAA;KAAE,EAC5E,IAAI,EAAE,KAAK,GACV,IAAI,IAAI,KAAK,GAAG;QAAE,GAAG,EAAE,uBAAuB,CAAC;QAAC,iBAAiB,CAAC,EAAE,SAAS,CAAA;KAAE,GAAG,qBAAqB,CAEzG;IAED;;;;OAIG;IACH,SAAgB,oBAAoB,CAAC,YAAY,EAAE,IAAI,CAAC,qBAAqB,EAAE,KAAK,GAAG,YAAY,CAAC,GAAG,MAAM,CAU5G;CACF;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,CAAC,KAAK,GAAG,aAAa,IAAI,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC"}
|
|
@@ -60,5 +60,23 @@ var HierarchyNode;
|
|
|
60
60
|
return HierarchyNodeKey_js_1.HierarchyNodeKey.isPropertyGrouping(node.key);
|
|
61
61
|
}
|
|
62
62
|
HierarchyNode.isPropertyGroupingNode = isPropertyGroupingNode;
|
|
63
|
+
/**
|
|
64
|
+
* Gets the grouping level of the given grouping node.
|
|
65
|
+
*
|
|
66
|
+
* May be useful when setting `groupingLevel` for `HierarchySearchTree.options.autoExpand` or `HierarchySearchPathOptions.reveal`.
|
|
67
|
+
*/
|
|
68
|
+
function getGroupingNodeLevel(groupingNode) {
|
|
69
|
+
let level = 1;
|
|
70
|
+
for (let i = groupingNode.parentKeys.length - 1; i >= 0; i--) {
|
|
71
|
+
if (HierarchyNodeKey_js_1.HierarchyNodeKey.isGrouping(groupingNode.parentKeys[i])) {
|
|
72
|
+
level++;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return level;
|
|
79
|
+
}
|
|
80
|
+
HierarchyNode.getGroupingNodeLevel = getGroupingNodeLevel;
|
|
63
81
|
})(HierarchyNode || (exports.HierarchyNode = HierarchyNode = {}));
|
|
64
82
|
//# sourceMappingURL=HierarchyNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchyNode.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNode.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,+DAAyD;
|
|
1
|
+
{"version":3,"file":"HierarchyNode.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNode.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,+DAAyD;AAuFzD,cAAc;AACd,2DAA2D;AAC3D,IAAiB,aAAa,CAsE7B;AAtED,WAAiB,aAAa;IAC5B,sDAAsD;IACtD,SAAgB,SAAS,CAA0C,IAAW;QAC5E,OAAO,sCAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9C,CAAC;IAFe,uBAAS,YAExB,CAAA;IACD,8EAA8E;IAC9E,SAAgB,YAAY,CAA0C,IAAW;QAC/E,OAAO,sCAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IAFe,0BAAY,eAE3B,CAAA;IACD,iEAAiE;IACjE,SAAgB,eAAe,CAA0C,IAAW;QAClF,OAAO,sCAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC;IAFe,6BAAe,kBAE9B,CAAA;IACD,uDAAuD;IACvD,SAAgB,cAAc,CAA0C,IAAW;QACjF,OAAO,sCAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,CAAC;IAFe,4BAAc,iBAE7B,CAAA;IACD,6DAA6D;IAC7D,SAAgB,mBAAmB,CACjC,IAAW;QAEX,OAAO,sCAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,C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AK,CAAC;IACf,CAAC;IAVe,kCAAoB,uBAUnC,CAAA;AACH,CAAC,EAtEgB,aAAa,6BAAb,aAAa,QAsE7B","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 { HierarchyNodeKey } from \"./HierarchyNodeKey.js\";\n\nimport type { OmitOverUnion } from \"@itwin/presentation-shared\";\nimport type {\n ClassGroupingNodeKey,\n GenericNodeKey,\n GroupingNodeKey,\n IModelHierarchyNodeKey,\n IModelInstanceKey,\n InstancesNodeKey,\n LabelGroupingNodeKey,\n PropertyGroupingNodeKey,\n PropertyOtherValuesGroupingNodeKey,\n PropertyValueGroupingNodeKey,\n PropertyValueRangeGroupingNodeKey,\n} from \"./HierarchyNodeKey.js\";\nimport type { HierarchySearchTree } from \"./HierarchySearch.js\";\n\n/** @public */\nexport interface HierarchyNodeSearchProps {\n /** If set to true, then one of the ancestor nodes in the hierarchy is the search target. */\n hasSearchTargetAncestor?: boolean;\n /** Paths to node's children that are search targets. */\n childrenTargetPaths?: HierarchySearchTree[];\n /** Whether or not this node is a search target. */\n isSearchTarget?: boolean;\n /** Options assigned to this node through search. */\n options?: HierarchySearchTree[\"options\"];\n}\n\n/**\n * A data structure that defines attributes that are common to all types of hierarchy nodes.\n * @public\n */\ninterface BaseHierarchyNode {\n /** Identifiers of all node ancestors. Can be used to identify a node in the hierarchy. */\n parentKeys: HierarchyNodeKey[];\n /** Node's display label. */\n label: string;\n /** A flag indicating whether the node has children or not. */\n children: boolean;\n /** A flag indicating whether this node should be auto-expanded in the UI. */\n autoExpand?: boolean;\n /** Additional data that may be assigned to this node. */\n extendedData?: { [key: string]: any };\n}\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n * @public\n */\nexport interface NonGroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify the node in its hierarchy level. */\n key: GenericNodeKey | InstancesNodeKey;\n /**\n * Identifies whether the hierarchy level below this node supports filtering. If not, supplying an instance\n * filter when requesting child hierarchy level will have no effect.\n */\n supportsFiltering?: boolean;\n /** Data that is assigned to the node if hierarchy search is enabled */\n search?: HierarchyNodeSearchProps;\n}\n\n/**\n * A data structure that represents a grouping node that groups other nodes.\n * @public\n */\nexport interface GroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify this grouping node in its hierarchy level. */\n key: GroupingNodeKey;\n\n /**\n * Keys of all instances grouped by this node, including deeply nested under\n * other grouping nodes.\n */\n groupedInstanceKeys: IModelInstanceKey[];\n\n /** The closest ancestor node that is not a grouping node. May be `undefined` if the grouping node grouped root level nodes. */\n nonGroupingAncestor?: ParentHierarchyNode<NonGroupingHierarchyNode>;\n}\n\n/**\n * A data structure that represents a single hierarchy node.\n * @public\n */\nexport type HierarchyNode = NonGroupingHierarchyNode | GroupingHierarchyNode;\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNode {\n /** Checks whether the given node is a generic node */\n export function isGeneric<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & NonGroupingHierarchyNode & { key: GenericNodeKey } {\n return HierarchyNodeKey.isGeneric(node.key);\n }\n /** Checks whether the given node is a standard (iModel content based) node */\n export function isIModelNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & { key: IModelHierarchyNodeKey } {\n return HierarchyNodeKey.isIModelNodeKey(node.key);\n }\n /** Checks whether the given node is an ECInstances-based node */\n export function isInstancesNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & NonGroupingHierarchyNode & { key: InstancesNodeKey } {\n return HierarchyNodeKey.isInstances(node.key);\n }\n /** Checks whether the given node is a grouping node */\n export function isGroupingNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & GroupingHierarchyNode {\n return HierarchyNodeKey.isGrouping(node.key);\n }\n /** Checks whether the given node is a class grouping node */\n export function isClassGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: ClassGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isClassGrouping(node.key);\n }\n /** Checks whether the given node is a label grouping node */\n export function isLabelGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: LabelGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isLabelGrouping(node.key);\n }\n /** Checks whether the given node is property grouping node for other values */\n export function isPropertyOtherValuesGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyOtherValuesGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyOtherValuesGrouping(node.key);\n }\n /** Checks whether the given node is a property value grouping node */\n export function isPropertyValueGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyValueGrouping(node.key);\n }\n /** Checks whether the given node is a property value range grouping node */\n export function isPropertyValueRangeGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueRangeGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyValueRangeGrouping(node.key);\n }\n /** Checks whether the given node is a property grouping node */\n export function isPropertyGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyGrouping(node.key);\n }\n\n /**\n * Gets the grouping level of the given grouping node.\n *\n * May be useful when setting `groupingLevel` for `HierarchySearchTree.options.autoExpand` or `HierarchySearchPathOptions.reveal`.\n */\n export function getGroupingNodeLevel(groupingNode: Pick<GroupingHierarchyNode, \"key\" | \"parentKeys\">): number {\n let level = 1;\n for (let i = groupingNode.parentKeys.length - 1; i >= 0; i--) {\n if (HierarchyNodeKey.isGrouping(groupingNode.parentKeys[i])) {\n level++;\n } else {\n break;\n }\n }\n return level;\n }\n}\n\n/**\n * A type of `HierarchyNode` that doesn't know about its children and is an input when requesting\n * them using `HierarchyProvider.getNodes`.\n * @public\n */\nexport type ParentHierarchyNode<TBase = HierarchyNode> = OmitOverUnion<TBase, \"children\">;\n"]}
|
|
@@ -18,6 +18,8 @@ export declare namespace HierarchyNodeIdentifier {
|
|
|
18
18
|
function isGenericNodeIdentifier(id: HierarchyNodeIdentifier): id is GenericNodeKey;
|
|
19
19
|
/** Checks two identifiers for equality */
|
|
20
20
|
function equal(lhs: HierarchyNodeIdentifier, rhs: HierarchyNodeIdentifier): boolean;
|
|
21
|
+
/** Compares two identifiers */
|
|
22
|
+
function compare(lhs: HierarchyNodeIdentifier, rhs: HierarchyNodeIdentifier): number;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* A path of hierarchy node identifiers, typically used to describe a path from root down
|