@itwin/presentation-hierarchies 2.0.0-alpha.12 → 2.0.0-alpha.13
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 +268 -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 +184 -78
- package/lib/cjs/hierarchies/HierarchySearch.d.ts.map +1 -1
- package/lib/cjs/hierarchies/HierarchySearch.js +305 -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 +184 -78
- package/lib/esm/hierarchies/HierarchySearch.d.ts.map +1 -1
- package/lib/esm/hierarchies/HierarchySearch.js +304 -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 +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,193 @@
|
|
|
1
1
|
# @itwin/presentation-hierarchies
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.13
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#1250](https://github.com/iTwin/presentation/pull/1250): Use type-safe full class names.
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
## Breaking changes
|
|
12
|
+
|
|
13
|
+
- `ClassGroupingNodeKey.className` is now of type `EC.FullClassName` instead of `string`.
|
|
14
|
+
- `NodesQueryClauseFactory.createSelectClause` prop `grouping.byBaseClasses.fullClassNames` is now of type `EC.FullClassName[]` instead of `string[]`.
|
|
15
|
+
- `NodesQueryClauseFactory.createSelectClause` prop `grouping.byProperties.propertiesClassName` is now of type `EC.FullClassName` instead of `string`.
|
|
16
|
+
- `HierarchyNodesDefinition.fullClassName` is now of type `EC.FullClassName` instead of `string`.
|
|
17
|
+
- `createPredicateBasedHierarchyDefinition` prop `hierarchies.childNodes[number].parentInstancesNodePredicate` now accepts `EC.FullClassName` instead of `string`.
|
|
18
|
+
- `NodesQueryClauseFactory.createFilterClauses` prop `contentClass.fullName` is now of type `EC.FullClassName` instead of `string`.
|
|
19
|
+
- `PropertyOtherValuesGroupingNodeKey.properties[number].className` is now of type `EC.FullClassName` instead of `string`.
|
|
20
|
+
- `PropertyValueGroupingNodeKey.propertyClassName` is now of type `EC.FullClassName` instead of `string`.
|
|
21
|
+
- `PropertyValueRangeGroupingNodeKey.propertyClassName` is now of type `EC.FullClassName` instead of `string`.
|
|
22
|
+
|
|
23
|
+
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:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
const myClassName: string = "MySchema.MyClass";
|
|
27
|
+
|
|
28
|
+
// before
|
|
29
|
+
const myClassGroupingNodeKey: ClassGroupingNodeKey = {
|
|
30
|
+
type: "class-grouping",
|
|
31
|
+
className: myClassName,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// after
|
|
35
|
+
const myClassGroupingNodeKey: ClassGroupingNodeKey = {
|
|
36
|
+
type: "class-grouping",
|
|
37
|
+
// 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
|
|
38
|
+
className: normalizeFullClassName(myClassName),
|
|
39
|
+
};
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
- [#1236](https://github.com/iTwin/presentation/pull/1236): Start using tree structure for defining hierarchy search paths.
|
|
43
|
+
|
|
44
|
+
**Additions:**
|
|
45
|
+
|
|
46
|
+
- `HierarchySearchTree` type that represents a tree structure of hierarchy search paths and is now used for hierarchy search implementation in `HierarchyProvider`.
|
|
47
|
+
|
|
48
|
+
In addition to the type, there's also a namespace with the same name, providing utility functions for working with the tree structure:
|
|
49
|
+
|
|
50
|
+
- `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:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
const builder = HierarchySearchTree.createBuilder();
|
|
54
|
+
builder.accept({ path: searchPath1 });
|
|
55
|
+
builder.accept({ path: searchPath2 });
|
|
56
|
+
builder.accept({ tree: partialSearchTree });
|
|
57
|
+
const tree: HierarchySearchTree = builder.getTree();
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
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.
|
|
61
|
+
|
|
62
|
+
- `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.
|
|
63
|
+
|
|
64
|
+
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:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
// Instead of doing this:
|
|
68
|
+
const searchPaths: HierarchySearchPath[] = [];
|
|
69
|
+
for (const item of items) {
|
|
70
|
+
searchPaths.push(createSearchPathForItem(item));
|
|
71
|
+
}
|
|
72
|
+
const tree: HierarchySearchTree =
|
|
73
|
+
HierarchySearchTree.createFromPathsList(searchPaths);
|
|
74
|
+
|
|
75
|
+
// Do this:
|
|
76
|
+
const builder = HierarchySearchTree.createBuilder();
|
|
77
|
+
for (const item of items) {
|
|
78
|
+
builder.accept({ path: createSearchPathForItem(item) });
|
|
79
|
+
}
|
|
80
|
+
const tree: HierarchySearchTree = builder.getTree();
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
- `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.
|
|
84
|
+
|
|
85
|
+
- `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`.
|
|
86
|
+
|
|
87
|
+
- `HierarchyNodeIdentifier.compare` static function to compare two `HierarchyNodeIdentifier` objects. Useful when using `HierarchyNodeIdentifier` as a key in a dictionary sorted set.
|
|
88
|
+
|
|
89
|
+
**Breaking changes:**
|
|
90
|
+
|
|
91
|
+
- `HierarchySearchPathOptions.reveal` type `{ depthInHierarchy: number }` was replaced with `{ groupingLevel: number }`.
|
|
92
|
+
|
|
93
|
+
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.
|
|
94
|
+
|
|
95
|
+
Migration:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const groupingNode = getMyGroupingNode();
|
|
99
|
+
const searchPath: HierarchySearchPath = {
|
|
100
|
+
// ...
|
|
101
|
+
options: {
|
|
102
|
+
// before
|
|
103
|
+
reveal: { depthInHierarchy: groupingNode.parentKeys.length },
|
|
104
|
+
|
|
105
|
+
// after
|
|
106
|
+
reveal: {
|
|
107
|
+
groupingLevel: HierarchyNode.getGroupingNodeLevel(groupingNode),
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
- `HierarchyProvider.setHierarchySearch` now takes `{ paths: HierarchySearchTree[] }` instead of `{ paths: HierarchySearchPath[] }`.
|
|
114
|
+
|
|
115
|
+
Migration:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
const provider: HierarchyProvider = getMyHierarchyProvider();
|
|
119
|
+
const searchPaths: HierarchySearchPath[] = getMySearchPaths();
|
|
120
|
+
provider.setHierarchySearch({
|
|
121
|
+
// before
|
|
122
|
+
paths: searchPaths,
|
|
123
|
+
|
|
124
|
+
// after
|
|
125
|
+
// - see `HierarchySearchTree.createFromPathsList` description above for more efficient way to do this
|
|
126
|
+
// - quick migration:
|
|
127
|
+
paths: await HierarchySearchTree.createFromPathsList(searchPaths),
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
- `createIModelHierarchyProvider` and `createMergedIModelHierarchyProvider` functions' `search` prop now takes `{ paths: HierarchySearchTree[] }` instead of `{ paths: HierarchySearchPath[] }`. Use `HierarchySearchTree.createFromPathsList` to do the conversion.
|
|
132
|
+
|
|
133
|
+
Migration:
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
const searchPaths: HierarchySearchPath[] = getMySearchPaths();
|
|
137
|
+
const provider = createIModelHierarchyProvider({
|
|
138
|
+
// ...
|
|
139
|
+
search: {
|
|
140
|
+
// before
|
|
141
|
+
paths: searchPaths,
|
|
142
|
+
|
|
143
|
+
// after
|
|
144
|
+
// - see `HierarchySearchTree.createFromPathsList` description above for more efficient way to do this
|
|
145
|
+
// - quick migration:
|
|
146
|
+
paths: await HierarchySearchTree.createFromPathsList(searchPaths),
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
- `HierarchyNode.search` changes:
|
|
152
|
+
|
|
153
|
+
- Type of `childrenTargetPaths` has been changed from `HierarchySearchPath[]` to `HierarchySearchTree[]`.
|
|
154
|
+
- `searchTargetOptions` was replaced with `options`, which is available not only for nodes with `isSearchTarget: true`, but all of them.
|
|
155
|
+
|
|
156
|
+
The changes of this attribute are taken care of by the `createHierarchySearchHelper` changes described below.
|
|
157
|
+
|
|
158
|
+
- `createHierarchySearchHelper` changes:
|
|
159
|
+
|
|
160
|
+
- The first argument is now `HierarchySearchTree[]` instead of `HierarchySearchPath[]`.
|
|
161
|
+
- The `createChildNodeProps` function of returned result no longer requires the `parentKeys` prop, but instead always requires the `nodeKey` prop.
|
|
162
|
+
|
|
163
|
+
Migration:
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
// Somewhere in `HierarchyProvider.getNodes` implementation...
|
|
167
|
+
|
|
168
|
+
// Type of the first argument has changed, but it also changed on `HierarchyProvider`, so likely no changes are needed here. If the
|
|
169
|
+
// type of `rootSearch.paths` is still `HierarchySearchPath[]` - use `HierarchySearchTree.createFromPathsList` to do the conversion.
|
|
170
|
+
const helper = createHierarchySearchHelper(rootSearch?.paths, parentNode);
|
|
171
|
+
for (const book of books) {
|
|
172
|
+
const nodeKey: GenericNodeKey = { type: "generic", id: `book:${book.key}` };
|
|
173
|
+
yield {
|
|
174
|
+
key: nodeKey,
|
|
175
|
+
label: book.title,
|
|
176
|
+
children: false,
|
|
177
|
+
parentKeys: [...parentNode.parentKeys, parentNode.key],
|
|
178
|
+
// before
|
|
179
|
+
...searchHelper?.createChildNodeProps({ nodeKey, parentKeys }),
|
|
180
|
+
// after
|
|
181
|
+
...searchHelper?.createChildNodeProps({ nodeKey }),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Patch Changes
|
|
187
|
+
|
|
188
|
+
- Updated dependencies:
|
|
189
|
+
- @itwin/presentation-shared@2.0.0-alpha.9
|
|
190
|
+
|
|
3
191
|
## 2.0.0-alpha.12
|
|
4
192
|
|
|
5
193
|
### Patch Changes
|
|
@@ -91,15 +279,21 @@
|
|
|
91
279
|
// or, provide implementation as a class instance:
|
|
92
280
|
const afterAsClassObject = createHierarchyProvider(
|
|
93
281
|
({ hierarchyChanged }) =>
|
|
94
|
-
new (class
|
|
95
|
-
|
|
282
|
+
new (class
|
|
283
|
+
implements Pick<HierarchyProvider, "getNodes" | "setFormatter">
|
|
284
|
+
{
|
|
285
|
+
public async *getNodes({
|
|
286
|
+
parentNode,
|
|
287
|
+
}): ReturnType<HierarchyProvider["getNodes"]> {
|
|
96
288
|
// yield nodes...
|
|
97
289
|
}
|
|
98
290
|
public setFormatter(formatter: IPrimitiveValueFormatter | undefined) {
|
|
99
291
|
// set formatter...
|
|
100
|
-
hierarchyChanged.raiseEvent({
|
|
292
|
+
hierarchyChanged.raiseEvent({
|
|
293
|
+
formatterChange: { newFormatter: formatter },
|
|
294
|
+
});
|
|
101
295
|
}
|
|
102
|
-
})()
|
|
296
|
+
})()
|
|
103
297
|
);
|
|
104
298
|
```
|
|
105
299
|
|
|
@@ -126,6 +320,7 @@
|
|
|
126
320
|
the `createNodesQueryClauseFactory` function should be called with `imodelAccess` that is passed to `HierarchyDefinition.defineHierarchyLevel`.
|
|
127
321
|
|
|
128
322
|
**Breaking changes:**
|
|
323
|
+
|
|
129
324
|
- `DefineHierarchyLevelProps.imodelKey` was replaced with `imodelAccess`. If needed, the key can be accessed using `imodelAccess.imodelKey`. This affects the following APIs:
|
|
130
325
|
- `HierarchyDefinition.defineHierarchyLevel` (function that uses these props),
|
|
131
326
|
- `DefineRootHierarchyLevelProps` (extends the props type),
|
|
@@ -138,6 +333,7 @@
|
|
|
138
333
|
- [#1137](https://github.com/iTwin/presentation/pull/1137): Fix hierarchy search only handling a single (latest) iModel results when searching multi-iModel hierarchies.
|
|
139
334
|
|
|
140
335
|
Notable API changes:
|
|
336
|
+
|
|
141
337
|
- **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
338
|
|
|
143
339
|
```ts
|
|
@@ -172,6 +368,7 @@
|
|
|
172
368
|
Properties and APIs were renamed accordingly to clarify the distinction and avoid confusion between hierarchy‑wide search and per-hierarchy‑level filtering.
|
|
173
369
|
|
|
174
370
|
**Breaking changes:**
|
|
371
|
+
|
|
175
372
|
- Removed deprecated `extractFilteringProps`.
|
|
176
373
|
- Removed deprecated `HierarchyNodeFilteringProps.create`.
|
|
177
374
|
- Renamed `createHierarchyFilteringHelper` to `createHierarchySearchHelper`. It's return type was also adjusted for the rename:
|
|
@@ -196,6 +393,7 @@
|
|
|
196
393
|
- 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
394
|
|
|
198
395
|
**Breaking changes:**
|
|
396
|
+
|
|
199
397
|
- `GroupingHierarchyNode` no longer contains `filtering` attribute. This was always the case, but now the types have been updated to match it.
|
|
200
398
|
- Changed return type of `createHierarchyFilteringHelper`:
|
|
201
399
|
- Removed `createChildNodePropsAsync` - it became an overload of `createChildNodeProps`, whose path matching is done through `asyncPathMatcher` callback.
|
|
@@ -258,6 +456,7 @@
|
|
|
258
456
|
### Major Changes
|
|
259
457
|
|
|
260
458
|
- [#954](https://github.com/iTwin/presentation/pull/954): Add additional requirements for types in `EC` metadata namespace, whose objects are returned by `ECSchemaProvider`.
|
|
459
|
+
|
|
261
460
|
- `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
461
|
- `EC.Class` now additionally has these members:
|
|
263
462
|
- `baseClass: Promise<Class | undefined>`
|
|
@@ -276,6 +475,14 @@
|
|
|
276
475
|
- Updated dependencies:
|
|
277
476
|
- @itwin/presentation-shared@2.0.0-alpha.0
|
|
278
477
|
|
|
478
|
+
## 1.7.11
|
|
479
|
+
|
|
480
|
+
### Patch Changes
|
|
481
|
+
|
|
482
|
+
- [#1242](https://github.com/iTwin/presentation/pull/1242): Bump dependencies.
|
|
483
|
+
- Updated dependencies:
|
|
484
|
+
- @itwin/presentation-shared@1.2.10
|
|
485
|
+
|
|
279
486
|
## 1.7.10
|
|
280
487
|
|
|
281
488
|
### Patch Changes
|
|
@@ -356,6 +563,7 @@
|
|
|
356
563
|
### Minor Changes
|
|
357
564
|
|
|
358
565
|
- 8f7d200926b93e862276e1f978f6c891691e0dae: Refactored specifying the depth / level to which filtering path should be auto-expanded.
|
|
566
|
+
|
|
359
567
|
- Deprecated `FilteringPathAutoExpandOption` and `FilterTargetGroupingNodeInfo`.
|
|
360
568
|
- Added `FilteringPathAutoExpandDepthInPath` and `FilteringPathAutoExpandDepthInHierarchy` which should be used instead.
|
|
361
569
|
|
|
@@ -420,7 +628,10 @@
|
|
|
420
628
|
**Before:**
|
|
421
629
|
|
|
422
630
|
```ts
|
|
423
|
-
const childNodeProps = await createHierarchyFilteringHelper(
|
|
631
|
+
const childNodeProps = await createHierarchyFilteringHelper(
|
|
632
|
+
undefined,
|
|
633
|
+
undefined
|
|
634
|
+
).createChildNodePropsAsync({
|
|
424
635
|
pathMatcher: (identifier): boolean | Promise<boolean> => {
|
|
425
636
|
return false;
|
|
426
637
|
},
|
|
@@ -428,6 +639,7 @@
|
|
|
428
639
|
```
|
|
429
640
|
|
|
430
641
|
**After:**
|
|
642
|
+
|
|
431
643
|
- **Option A:** check if it's a Promise before awaiting:
|
|
432
644
|
|
|
433
645
|
Use this when you want to get slightly better performance by avoiding unnecessary `await`.
|
|
@@ -446,7 +658,10 @@
|
|
|
446
658
|
Use this if pathMatcher always returns a Promise or you prefer a simpler pattern.
|
|
447
659
|
|
|
448
660
|
```ts
|
|
449
|
-
const childNodeProps = await createHierarchyFilteringHelper(
|
|
661
|
+
const childNodeProps = await createHierarchyFilteringHelper(
|
|
662
|
+
undefined,
|
|
663
|
+
undefined
|
|
664
|
+
).createChildNodePropsAsync({
|
|
450
665
|
pathMatcher: async (identifier): Promise<boolean> => {
|
|
451
666
|
return false;
|
|
452
667
|
},
|
|
@@ -512,6 +727,7 @@
|
|
|
512
727
|
- [#783](https://github.com/iTwin/presentation/pull/783): Added hierarchy filtering helper to make hierarchy filtering easier to implement.
|
|
513
728
|
|
|
514
729
|
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:
|
|
730
|
+
|
|
515
731
|
- `hasFilter` tells if the hierarchy level has a filter applied.
|
|
516
732
|
- `hasFilterTargetAncestor` tells if there's a filter target ancestor node up in the hierarchy.
|
|
517
733
|
- `getChildNodeFilteringIdentifiers()` returns an array of hierarchy node identifiers that apply specifically for this hierarchy level.
|
|
@@ -520,6 +736,7 @@
|
|
|
520
736
|
See the [Implementing hierarchy filtering support](./learning/CustomHierarchyProviders.md#implementing-hierarchy-filtering-support) learning page for a usage example.
|
|
521
737
|
|
|
522
738
|
In addition, deprecated a few APIs that are replaced by filtering helper:
|
|
739
|
+
|
|
523
740
|
- `extractFilteringProps` function,
|
|
524
741
|
- `HierarchyNodeFilteringProps.create` function.
|
|
525
742
|
|
|
@@ -565,6 +782,7 @@
|
|
|
565
782
|
| 50k | not tested | 13.45 s |
|
|
566
783
|
|
|
567
784
|
In addition, changed `NodeParser` (return type of `HierarchyDefinition.parseNode`):
|
|
785
|
+
|
|
568
786
|
- It now can return a promise, so instead of just `SourceInstanceHierarchyNode` it can now also return `Promise<SourceInstanceHierarchyNode>`.
|
|
569
787
|
- Additionally, it now accepts an optional `parentNode` argument of `HierarchyDefinitionParentNode` type.
|
|
570
788
|
|
|
@@ -596,6 +814,7 @@
|
|
|
596
814
|
### Minor Changes
|
|
597
815
|
|
|
598
816
|
- [#708](https://github.com/iTwin/presentation/pull/708): **BREAKING:** Added support for creating hierarchies from multiple data sources.
|
|
817
|
+
|
|
599
818
|
- `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
819
|
- `HierarchyNode` terminology and related changes:
|
|
601
820
|
- "Standard" nodes were renamed to "IModel" nodes to signify the fact that they're based on iModel data:
|
|
@@ -623,6 +842,7 @@
|
|
|
623
842
|
- 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
843
|
- 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
844
|
- Renamed `createClassBasedHierarchyDefinition` to `createPredicateBasedHierarchyDefinition` to signify its props changes:
|
|
845
|
+
|
|
626
846
|
- 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
847
|
- 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
848
|
|
|
@@ -675,6 +895,7 @@
|
|
|
675
895
|
```
|
|
676
896
|
|
|
677
897
|
- [#708](https://github.com/iTwin/presentation/pull/708): Added utilities for custom hierarchy filtering handling:
|
|
898
|
+
|
|
678
899
|
- `extractFilteringProps` function, given root level hierarchy filtering paths and a parent node, returns props required to filter particular hierarchy level.
|
|
679
900
|
- `HierarchyFilteringPath` interface is now public and there's also a similarly-named namespace with the following utilities:
|
|
680
901
|
- `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 +924,9 @@
|
|
|
703
924
|
```ts
|
|
704
925
|
const selectQueryFactory = createNodesQueryClauseFactory({
|
|
705
926
|
imodelAccess,
|
|
706
|
-
instanceLabelSelectClauseFactory: createBisInstanceLabelSelectClauseFactory(
|
|
927
|
+
instanceLabelSelectClauseFactory: createBisInstanceLabelSelectClauseFactory(
|
|
928
|
+
{ classHierarchyInspector: imodelAccess }
|
|
929
|
+
),
|
|
707
930
|
});
|
|
708
931
|
```
|
|
709
932
|
|
|
@@ -726,7 +949,12 @@
|
|
|
726
949
|
// Path to the element "C"
|
|
727
950
|
path: [elementKeys.a, elementKeys.b, elementKeys.c],
|
|
728
951
|
// Supply grouping node attributes with the path to the "C" element.
|
|
729
|
-
options: {
|
|
952
|
+
options: {
|
|
953
|
+
autoExpand: {
|
|
954
|
+
key: groupingNode.key,
|
|
955
|
+
depth: groupingNode.parentKeys.length,
|
|
956
|
+
},
|
|
957
|
+
},
|
|
730
958
|
},
|
|
731
959
|
],
|
|
732
960
|
},
|
|
@@ -765,7 +993,12 @@
|
|
|
765
993
|
const hierarchyProvider = createHierarchyProvider({
|
|
766
994
|
imodelAccess,
|
|
767
995
|
hierarchyDefinition: createHierarchyDefinition(imodelAccess),
|
|
768
|
-
filtering: {
|
|
996
|
+
filtering: {
|
|
997
|
+
paths: filterPaths.map((path) => ({
|
|
998
|
+
path,
|
|
999
|
+
options: { autoExpand: true },
|
|
1000
|
+
})),
|
|
1001
|
+
},
|
|
769
1002
|
});
|
|
770
1003
|
```
|
|
771
1004
|
|
|
@@ -807,12 +1040,18 @@
|
|
|
807
1040
|
childNodes: [
|
|
808
1041
|
{
|
|
809
1042
|
parentNodeClassName: "BisCore.PhysicalElement",
|
|
810
|
-
definitions: async ({ parentNode }) =>
|
|
1043
|
+
definitions: async ({ parentNode }) =>
|
|
1044
|
+
getPhysicalElementChildren(parentNode),
|
|
811
1045
|
},
|
|
812
1046
|
{
|
|
813
1047
|
parentNodeClassName: "BisCore.SpatialElement",
|
|
814
1048
|
definitions: async ({ parentNode, parentNodeClassName }) => {
|
|
815
|
-
if (
|
|
1049
|
+
if (
|
|
1050
|
+
await inspector.classDerivesFrom(
|
|
1051
|
+
parentNodeClassName,
|
|
1052
|
+
"BisCore.PhysicalElement"
|
|
1053
|
+
)
|
|
1054
|
+
) {
|
|
816
1055
|
return [];
|
|
817
1056
|
}
|
|
818
1057
|
|
|
@@ -822,11 +1061,21 @@
|
|
|
822
1061
|
{
|
|
823
1062
|
parentNodeClassName: "BisCore.GeometricElement3d",
|
|
824
1063
|
definitions: async ({ parentNode, parentNodeClassName }) => {
|
|
825
|
-
if (
|
|
1064
|
+
if (
|
|
1065
|
+
await inspector.classDerivesFrom(
|
|
1066
|
+
parentNodeClassName,
|
|
1067
|
+
"BisCore.PhysicalElement"
|
|
1068
|
+
)
|
|
1069
|
+
) {
|
|
826
1070
|
return [];
|
|
827
1071
|
}
|
|
828
1072
|
|
|
829
|
-
if (
|
|
1073
|
+
if (
|
|
1074
|
+
await inspector.classDerivesFrom(
|
|
1075
|
+
parentNodeClassName,
|
|
1076
|
+
"BisCore.SpatialElement"
|
|
1077
|
+
)
|
|
1078
|
+
) {
|
|
830
1079
|
return [];
|
|
831
1080
|
}
|
|
832
1081
|
|
|
@@ -847,17 +1096,20 @@
|
|
|
847
1096
|
childNodes: [
|
|
848
1097
|
{
|
|
849
1098
|
parentNodeClassName: "BisCore.PhysicalElement",
|
|
850
|
-
definitions: async ({ parentNode }) =>
|
|
1099
|
+
definitions: async ({ parentNode }) =>
|
|
1100
|
+
getPhysicalElementChildren(parentNode),
|
|
851
1101
|
},
|
|
852
1102
|
{
|
|
853
1103
|
parentNodeClassName: "BisCore.SpatialElement",
|
|
854
1104
|
onlyIfNotHandled: true,
|
|
855
|
-
definitions: async ({ parentNode }) =>
|
|
1105
|
+
definitions: async ({ parentNode }) =>
|
|
1106
|
+
getSpatialElementChildren(parentNode),
|
|
856
1107
|
},
|
|
857
1108
|
{
|
|
858
1109
|
parentNodeClassName: "BisCore.GeometricElement3d",
|
|
859
1110
|
onlyIfNotHandled: true,
|
|
860
|
-
definitions: async ({ parentNode }) =>
|
|
1111
|
+
definitions: async ({ parentNode }) =>
|
|
1112
|
+
getGeometricElement3dChildren(parentNode),
|
|
861
1113
|
},
|
|
862
1114
|
],
|
|
863
1115
|
},
|
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,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,kCAAkC,EAClC,4BAA4B,EAC5B,iCAAiC,EAClC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,
|
|
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,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,kCAAkC,EAClC,4BAA4B,EAC5B,iCAAiC,EAClC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,cAAc;AACd,MAAM,WAAW,wBAAwB;IACvC,4FAA4F;IAC5F,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,wDAAwD;IACxD,mBAAmB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC5C,mDAAmD;IACnD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oDAAoD;IACpD,OAAO,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CAC1C;AAED;;;GAGG;AACH,UAAU,iBAAiB;IACzB,0FAA0F;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,GACV,IAAI,IAAI,KAAK,GAAG;QAAE,GAAG,EAAE,4BAA4B,CAAC;QAAC,iBAAiB,CAAC,EAAE,SAAS,CAAA;KAAE,GAAG,qBAAqB,CAE9G;IACD,4EAA4E;IAC5E,SAAgB,gCAAgC,CAAC,KAAK,SAAS;QAAE,GAAG,EAAE,gBAAgB,CAAA;KAAE,EACtF,IAAI,EAAE,KAAK,GACV,IAAI,IAAI,KAAK,GAAG;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,uDA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,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7D,IAAI,sCAAgB,CAAC,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC5D,KAAK,EAAE,CAAC;YACV,CAAC;iBAAM,CAAC;gBACN,MAAM;YACR,CAAC;QACH,CAAC;QACD,OAAO,KAAK,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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchyNodeIdentifier.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNodeIdentifier.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HierarchyNodeIdentifier.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNodeIdentifier.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/E;;;;;;;;;GASG;AACH,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GAAG,cAAc,CAAC;AAEzE,cAAc;AAEd,yBAAiB,uBAAuB,CAAC;IACvC,yEAAyE;IACzE,SAAgB,wBAAwB,CAAC,EAAE,EAAE,uBAAuB,GAAG,EAAE,IAAI,iBAAiB,CAE7F;IAED,uEAAuE;IACvE,SAAgB,uBAAuB,CAAC,EAAE,EAAE,uBAAuB,GAAG,EAAE,IAAI,cAAc,CAEzF;IAED,0CAA0C;IAC1C,SAAgB,KAAK,CAAC,GAAG,EAAE,uBAAuB,EAAE,GAAG,EAAE,uBAAuB,WAE/E;IAED,+BAA+B;IAC/B,SAAgB,OAAO,CAAC,GAAG,EAAE,uBAAuB,EAAE,GAAG,EAAE,uBAAuB,GAAG,MAAM,CAmB1F;CACF;AAED;;;;;GAKG;AACH,MAAM,MAAM,4BAA4B,GAAG,uBAAuB,EAAE,CAAC"}
|