@itwin/presentation-hierarchies-react 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +83 -0
- package/README.md +95 -77
- package/lib/cjs/presentation-hierarchies-react/UseIModelTree.d.ts +53 -0
- package/lib/cjs/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -0
- package/lib/cjs/presentation-hierarchies-react/UseIModelTree.js +65 -0
- package/lib/cjs/presentation-hierarchies-react/UseIModelTree.js.map +1 -0
- package/lib/cjs/presentation-hierarchies-react/UseTree.d.ts +17 -46
- package/lib/cjs/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/UseTree.js +46 -47
- package/lib/cjs/presentation-hierarchies-react/UseTree.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.d.ts +3 -2
- package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.js +8 -6
- package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.d.ts +3 -2
- package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.js +6 -4
- package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +1 -3
- package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.js +79 -43
- package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/internal/Utils.js +1 -1
- package/lib/cjs/presentation-hierarchies-react/internal/Utils.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts +3 -3
- package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +32 -15
- package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +1 -1
- package/lib/cjs/presentation-hierarchies-react.d.ts +1 -0
- package/lib/cjs/presentation-hierarchies-react.d.ts.map +1 -1
- package/lib/cjs/presentation-hierarchies-react.js +4 -1
- package/lib/cjs/presentation-hierarchies-react.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts +53 -0
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +61 -0
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +17 -46
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.js +47 -48
- package/lib/esm/presentation-hierarchies-react/UseTree.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +3 -2
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +8 -6
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +3 -2
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +6 -4
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +1 -3
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +79 -43
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts +3 -3
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +32 -15
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react.d.ts +1 -0
- package/lib/esm/presentation-hierarchies-react.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react.js +1 -0
- package/lib/esm/presentation-hierarchies-react.js.map +1 -1
- package/package.json +9 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeLoader.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/TreeLoader.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,+BAAwF;AAExF,2CAAoI;AACpI,mCAAuC;AA4BvC,gBAAgB;AAChB,MAAa,UAAU;
|
|
1
|
+
{"version":3,"file":"TreeLoader.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/TreeLoader.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,+BAAwF;AAExF,2CAAoI;AACpI,mCAAuC;AA4BvC,gBAAgB;AAChB,MAAa,UAAU;IAIX;IACA;IACA;IALF,kBAAkB,CAA8D;IAExF,YACU,kBAAqC,EACrC,yBAA+H,EAC/H,qBAA0F,EAClG,iBAA+E;QAHvE,uBAAkB,GAAlB,kBAAkB,CAAmB;QACrC,8BAAyB,GAAzB,yBAAyB,CAAsG;QAC/H,0BAAqB,GAArB,qBAAqB,CAAqE;QAGlG,IAAI,CAAC,kBAAkB,G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CAAC,IAAuC,EAAE,EAAE;QACjD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,SAAS,GAA2B;YACxC,EAAE,EAAE,iBAAiB,CAAC,IAAI,CAAC;YAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACtD,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,IAAuC;IAC9D,OAAO,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC;AACjD,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAY;IACpC,MAAM,WAAW,GAAG,KAA+B,CAAC;IACpD,OAAO,WAAW,CAAC,KAAK,KAAK,SAAS,IAAI,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AAChG,CAAC;AAED,SAAS,cAAc,CAAC,KAAY;IAClC,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,iDAAiD,CAAC,CAAC;AACnF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { catchError, expand, from, map, mergeMap, Observable, of, toArray } from \"rxjs\";\nimport { GenericInstanceFilter, HierarchyNode, HierarchyProvider, RowsLimitExceededError } from \"@itwin/presentation-hierarchies\";\nimport { isTreeModelHierarchyNode, TreeModelHierarchyNode, TreeModelInfoNode, TreeModelNode, TreeModelRootNode } from \"./TreeModel\";\nimport { createNodeId } from \"./Utils\";\n\n/** @internal */\nexport interface LoadedTreePart {\n parentId: string | undefined;\n loadedNodes: TreeModelNode[];\n}\n\n/** @internal */\nexport interface HierarchyLevelOptions {\n instanceFilter?: GenericInstanceFilter;\n hierarchyLevelSizeLimit?: number | \"unbounded\";\n}\n\n/** @internal */\nexport interface LoadNodesOptions {\n parent: TreeModelHierarchyNode | TreeModelRootNode;\n getHierarchyLevelOptions: (node: TreeModelRootNode | TreeModelHierarchyNode) => HierarchyLevelOptions;\n shouldLoadChildren: (node: TreeModelHierarchyNode) => boolean;\n buildNode?: (node: TreeModelHierarchyNode) => TreeModelHierarchyNode;\n ignoreCache?: boolean;\n}\n\n/** @internal */\nexport interface ITreeLoader {\n loadNodes(options: LoadNodesOptions): Observable<LoadedTreePart>;\n}\n\n/** @internal */\nexport class TreeLoader implements ITreeLoader {\n private _treeNodeIdFactory: (node: Pick<HierarchyNode, \"key\" | \"parentKeys\">) => string;\n\n constructor(\n private _hierarchyProvider: HierarchyProvider,\n private _onHierarchyLimitExceeded: (props: { parentId?: string; filter?: GenericInstanceFilter; limit?: number | \"unbounded\" }) => void,\n private _onHierarchyLoadError: (props: { parentId?: string; type: \"timeout\" | \"unknown\" }) => void,\n treeNodeIdFactory?: (node: Pick<HierarchyNode, \"key\" | \"parentKeys\">) => string,\n ) {\n this._treeNodeIdFactory = treeNodeIdFactory ?? /* istanbul ignore next */ createNodeId;\n }\n\n private loadChildren({ parent, getHierarchyLevelOptions, buildNode, ignoreCache }: Omit<LoadNodesOptions, \"shouldLoadChildren\">) {\n const { instanceFilter, hierarchyLevelSizeLimit } = getHierarchyLevelOptions(parent);\n const infoNodeIdBase = `${parent.id ?? \"<root>\"}`;\n const treeModelNodesFactory = createTreeModelNodesFactory({ buildNode, treeNodeIdFactory: this._treeNodeIdFactory });\n return from(\n this._hierarchyProvider.getNodes({\n parentNode: parent.nodeData,\n hierarchyLevelSizeLimit,\n instanceFilter,\n ignoreCache,\n }),\n ).pipe(\n toArray(),\n catchError((err) => {\n const nodeProps = {\n id: `${infoNodeIdBase}-${err.message}`,\n parentId: parent.id,\n };\n if (isRowsLimitError(err)) {\n this._onHierarchyLimitExceeded({ parentId: parent.id, filter: instanceFilter, limit: hierarchyLevelSizeLimit });\n return of([{ ...nodeProps, type: \"ResultSetTooLarge\" as const, resultSetSizeLimit: err.limit }]);\n }\n this._onHierarchyLoadError({ parentId: parent.id, type: isTimeoutError(err) ? \"timeout\" : \"unknown\" });\n return of([{ ...nodeProps, type: \"Unknown\" as const, message: \"Failed to create hierarchy level\" }]);\n }),\n map(\n (childNodes): LoadedTreePart => ({\n parentId: parent.id,\n loadedNodes:\n instanceFilter && childNodes.length === 0\n ? [\n {\n id: `${infoNodeIdBase}-no-filter-matches`,\n parentId: parent.id,\n type: \"NoFilterMatches\" as const,\n },\n ]\n : childNodes.map(treeModelNodesFactory),\n }),\n ),\n );\n }\n\n public loadNodes({ shouldLoadChildren, ...options }: LoadNodesOptions) {\n return this.loadChildren(options).pipe(\n expand((loadedPart) =>\n from(loadedPart.loadedNodes.filter((node): node is TreeModelHierarchyNode => isTreeModelHierarchyNode(node) && shouldLoadChildren(node))).pipe(\n mergeMap((node) => this.loadChildren({ ...options, parent: node })),\n ),\n ),\n );\n }\n}\n\nfunction createTreeModelNodesFactory({\n buildNode,\n treeNodeIdFactory,\n}: {\n buildNode?: (node: TreeModelHierarchyNode) => TreeModelHierarchyNode;\n treeNodeIdFactory: (node: Pick<HierarchyNode, \"key\" | \"parentKeys\">) => string;\n}): (node: TreeModelInfoNode | HierarchyNode) => TreeModelNode {\n return (node: TreeModelInfoNode | HierarchyNode) => {\n if (!isHierarchyNode(node)) {\n return node;\n }\n\n const modelNode: TreeModelHierarchyNode = {\n id: treeNodeIdFactory(node),\n children: node.children,\n label: node.label,\n nodeData: node,\n };\n return buildNode ? buildNode(modelNode) : modelNode;\n };\n}\n\nfunction isHierarchyNode(node: TreeModelInfoNode | HierarchyNode): node is HierarchyNode {\n return \"key\" in node && node.key !== undefined;\n}\n\nfunction isRowsLimitError(error: Error): error is RowsLimitExceededError {\n const asRowsError = error as RowsLimitExceededError;\n return asRowsError.limit !== undefined && asRowsError.message.includes(\"Query rows limit of\");\n}\n\nfunction isTimeoutError(error: Error) {\n return error.message.includes(\"query too long to execute or server is too busy\");\n}\n"]}
|
|
@@ -7,15 +7,13 @@ export interface TreeSelectionOptions {
|
|
|
7
7
|
}
|
|
8
8
|
/** @beta */
|
|
9
9
|
export interface UseUnifiedTreeSelectionProps {
|
|
10
|
-
/** Key of the iModel. */
|
|
11
|
-
imodelKey: string;
|
|
12
10
|
/**
|
|
13
11
|
* Identifier to distinguish this source of changes to the unified selection from another ones in the application.
|
|
14
12
|
*/
|
|
15
13
|
sourceName: string;
|
|
16
14
|
}
|
|
17
15
|
/** @internal */
|
|
18
|
-
export declare function useUnifiedTreeSelection({
|
|
16
|
+
export declare function useUnifiedTreeSelection({ sourceName, getNode, }: UseUnifiedTreeSelectionProps & {
|
|
19
17
|
getNode: (nodeId: string) => TreeModelNode | TreeModelRootNode | undefined;
|
|
20
18
|
}): TreeSelectionOptions;
|
|
21
19
|
//# sourceMappingURL=UseUnifiedSelection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseUnifiedSelection.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/UseUnifiedSelection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UseUnifiedSelection.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/UseUnifiedSelection.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAoD,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEjH,gBAAgB;AAChB,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAC5C,WAAW,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,mBAAmB,KAAK,IAAI,CAAC;CAChF;AAED,YAAY;AACZ,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,gBAAgB;AAChB,wBAAgB,uBAAuB,CAAC,EACtC,UAAU,EACV,OAAO,GACR,EAAE,4BAA4B,GAAG;IAAE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,aAAa,GAAG,iBAAiB,GAAG,SAAS,CAAA;CAAE,GAAG,oBAAoB,CA0BtI"}
|
|
@@ -11,7 +11,7 @@ const unified_selection_1 = require("@itwin/unified-selection");
|
|
|
11
11
|
const UnifiedSelectionContext_1 = require("../UnifiedSelectionContext");
|
|
12
12
|
const TreeModel_1 = require("./TreeModel");
|
|
13
13
|
/** @internal */
|
|
14
|
-
function useUnifiedTreeSelection({
|
|
14
|
+
function useUnifiedTreeSelection({ sourceName, getNode, }) {
|
|
15
15
|
const [options, setOptions] = (0, react_1.useState)(() => ({
|
|
16
16
|
isNodeSelected: /* istanbul ignore next */ () => false,
|
|
17
17
|
selectNodes: /* istanbul ignore next */ () => { },
|
|
@@ -25,71 +25,107 @@ function useUnifiedTreeSelection({ imodelKey, sourceName, getNode, }) {
|
|
|
25
25
|
});
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
setOptions(createOptions(
|
|
28
|
+
setOptions(createOptions(sourceName, selectionStorage, getNode));
|
|
29
29
|
return selectionStorage.selectionChangeEvent.addListener((args) => {
|
|
30
|
-
if (
|
|
30
|
+
if (args.level > 0) {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
setOptions(createOptions(
|
|
33
|
+
setOptions(createOptions(sourceName, selectionStorage, getNode));
|
|
34
34
|
});
|
|
35
|
-
}, [selectionStorage, getNode,
|
|
35
|
+
}, [selectionStorage, getNode, sourceName]);
|
|
36
36
|
return options;
|
|
37
37
|
}
|
|
38
|
-
function createOptions(
|
|
38
|
+
function createOptions(source, storage, getNode) {
|
|
39
39
|
return {
|
|
40
40
|
isNodeSelected: (nodeId) => {
|
|
41
41
|
const node = getNode(nodeId);
|
|
42
42
|
if (!node || !(0, TreeModel_1.isTreeModelHierarchyNode)(node)) {
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
return unified_selection_1.Selectables.has(selectables, { identifier: node.id });
|
|
45
|
+
return Object.entries(groupNodeSelectablesByIModelKey(node)).some(([imodelKey, nodeSelectables]) => {
|
|
46
|
+
const storageSelectables = storage.getSelection({ imodelKey, level: 0 });
|
|
47
|
+
return unified_selection_1.Selectables.hasAny(storageSelectables, nodeSelectables);
|
|
48
|
+
});
|
|
51
49
|
},
|
|
52
50
|
selectNodes: (nodeIds, changeType) => {
|
|
53
|
-
|
|
51
|
+
const imodelSelectables = {};
|
|
54
52
|
for (const nodeId of nodeIds) {
|
|
55
53
|
const node = getNode(nodeId);
|
|
56
54
|
if (!node || !(0, TreeModel_1.isTreeModelHierarchyNode)(node)) {
|
|
57
55
|
return;
|
|
58
56
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
storage.removeFromSelection(actionProps);
|
|
68
|
-
return;
|
|
69
|
-
case "replace":
|
|
70
|
-
storage.replaceSelection(actionProps);
|
|
71
|
-
return;
|
|
57
|
+
Object.entries(groupNodeSelectablesByIModelKey(node)).forEach(([imodelKey, nodeSelectables]) => {
|
|
58
|
+
let selectablesList = imodelSelectables[imodelKey];
|
|
59
|
+
if (!selectablesList) {
|
|
60
|
+
selectablesList = [];
|
|
61
|
+
imodelSelectables[imodelKey] = selectablesList;
|
|
62
|
+
}
|
|
63
|
+
nodeSelectables.forEach((selectable) => selectablesList.push(selectable));
|
|
64
|
+
});
|
|
72
65
|
}
|
|
66
|
+
Object.entries(imodelSelectables).forEach(([imodelKey, selectables]) => {
|
|
67
|
+
const actionProps = { imodelKey, source, selectables, level: 0 };
|
|
68
|
+
switch (changeType) {
|
|
69
|
+
case "add":
|
|
70
|
+
storage.addToSelection(actionProps);
|
|
71
|
+
return;
|
|
72
|
+
case "remove":
|
|
73
|
+
storage.removeFromSelection(actionProps);
|
|
74
|
+
return;
|
|
75
|
+
case "replace":
|
|
76
|
+
storage.replaceSelection(actionProps);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
73
80
|
},
|
|
74
81
|
};
|
|
75
82
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
function groupNodeSelectablesByIModelKey(modelNode) {
|
|
84
|
+
const hierarchyNode = modelNode.nodeData;
|
|
85
|
+
if (presentation_hierarchies_1.HierarchyNode.isGeneric(hierarchyNode)) {
|
|
86
|
+
return {
|
|
87
|
+
// note: generic nodes aren't associated with an imodel
|
|
88
|
+
[""]: [
|
|
89
|
+
{
|
|
90
|
+
identifier: modelNode.id,
|
|
91
|
+
data: hierarchyNode,
|
|
92
|
+
async *loadInstanceKeys() { },
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
};
|
|
79
96
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
if (presentation_hierarchies_1.HierarchyNode.isInstancesNode(hierarchyNode)) {
|
|
98
|
+
return groupIModelInstanceKeys(hierarchyNode.key.instanceKeys);
|
|
99
|
+
}
|
|
100
|
+
if (presentation_hierarchies_1.HierarchyNode.isGroupingNode(hierarchyNode)) {
|
|
101
|
+
return Object.entries(groupIModelInstanceKeys(hierarchyNode.groupedInstanceKeys)).reduce((imodelSelectables, [imodelKey, instanceKeys]) => ({
|
|
102
|
+
...imodelSelectables,
|
|
103
|
+
[imodelKey]: [
|
|
104
|
+
{
|
|
105
|
+
identifier: modelNode.id,
|
|
106
|
+
data: hierarchyNode,
|
|
107
|
+
async *loadInstanceKeys() {
|
|
108
|
+
for (const key of instanceKeys) {
|
|
109
|
+
yield key;
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
}), {});
|
|
115
|
+
}
|
|
116
|
+
// istanbul ignore next
|
|
117
|
+
return {};
|
|
118
|
+
}
|
|
119
|
+
function groupIModelInstanceKeys(instanceKeys) {
|
|
120
|
+
return instanceKeys.reduce((imodelSelectables, key) => {
|
|
121
|
+
const imodelKey = key.imodelKey ?? "";
|
|
122
|
+
let selectablesList = imodelSelectables[imodelKey];
|
|
123
|
+
if (!selectablesList) {
|
|
124
|
+
selectablesList = [];
|
|
125
|
+
imodelSelectables[imodelKey] = selectablesList;
|
|
126
|
+
}
|
|
127
|
+
selectablesList.push(key);
|
|
128
|
+
return imodelSelectables;
|
|
129
|
+
}, {});
|
|
94
130
|
}
|
|
95
131
|
//# sourceMappingURL=UseUnifiedSelection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseUnifiedSelection.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/UseUnifiedSelection.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AA0BhG,0DA+BC;AAvDD,iCAA4C;AAC5C,8EAAgE;AAChE,gEAAqF;AACrF,wEAAwE;AAExE,2CAAyF;AAkBzF,gBAAgB;AAChB,SAAgB,uBAAuB,CAAC,EACtC,SAAS,EACT,UAAU,EACV,OAAO,GACuG;IAC9G,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAuB,GAAG,EAAE,CAAC,CAAC;QAClE,cAAc,EAAE,0BAA0B,CAAC,GAAG,EAAE,CAAC,KAAK;QACtD,WAAW,EAAE,0BAA0B,CAAC,GAAG,EAAE,GAAE,CAAC;KACjD,CAAC,CAA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AC5D,IAAI,wCAAa,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC;IAC/B,CAAC;IAED,OAAO;QACL;YACE,UAAU,EAAE,MAAM;YAClB,KAAK,CAAC,CAAC,gBAAgB;gBACrB,IAAI,CAAC,wCAAa,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;oBACxC,OAAO;gBACT,CAAC;gBAED,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;oBAC3C,MAAM,GAAG,CAAC;gBACZ,CAAC;YACH,CAAC;YACD,IAAI,EAAE,IAAI;SACX;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useState } from \"react\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { Selectable, Selectables, SelectionStorage } from \"@itwin/unified-selection\";\nimport { useUnifiedSelectionContext } from \"../UnifiedSelectionContext\";\nimport { SelectionChangeType } from \"../UseSelectionHandler\";\nimport { isTreeModelHierarchyNode, TreeModelNode, TreeModelRootNode } from \"./TreeModel\";\n\n/** @internal */\nexport interface TreeSelectionOptions {\n isNodeSelected: (nodeId: string) => boolean;\n selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => void;\n}\n\n/** @beta */\nexport interface UseUnifiedTreeSelectionProps {\n /** Key of the iModel. */\n imodelKey: string;\n /**\n * Identifier to distinguish this source of changes to the unified selection from another ones in the application.\n */\n sourceName: string;\n}\n\n/** @internal */\nexport function useUnifiedTreeSelection({\n imodelKey,\n sourceName,\n getNode,\n}: UseUnifiedTreeSelectionProps & { getNode: (nodeId: string) => TreeModelNode | TreeModelRootNode | undefined }): TreeSelectionOptions {\n const [options, setOptions] = useState<TreeSelectionOptions>(() => ({\n isNodeSelected: /* istanbul ignore next */ () => false,\n selectNodes: /* istanbul ignore next */ () => {},\n }));\n\n const selectionStorage = useUnifiedSelectionContext();\n useEffect(() => {\n if (!selectionStorage) {\n setOptions({\n isNodeSelected: () => false,\n selectNodes: () => {},\n });\n return;\n }\n\n setOptions(createOptions(imodelKey, sourceName, selectionStorage, getNode));\n return selectionStorage.selectionChangeEvent.addListener((args) => {\n if (imodelKey !== args.imodelKey || args.level > 0) {\n return;\n }\n\n setOptions(createOptions(imodelKey, sourceName, selectionStorage, getNode));\n });\n }, [selectionStorage, getNode, imodelKey, sourceName]);\n\n return options;\n}\n\nfunction createOptions(\n key: string,\n source: string,\n storage: SelectionStorage,\n getNode: (nodeId: string) => TreeModelNode | TreeModelRootNode | undefined,\n): TreeSelectionOptions {\n return {\n isNodeSelected: (nodeId: string) => {\n const node = getNode(nodeId);\n if (!node || !isTreeModelHierarchyNode(node)) {\n return false;\n }\n\n const selectables = storage.getSelection({ imodelKey: key, level: 0 });\n\n const hierarchyNode = node.nodeData;\n if (HierarchyNode.isInstancesNode(hierarchyNode)) {\n return Selectables.hasAny(selectables, hierarchyNode.key.instanceKeys);\n }\n\n return Selectables.has(selectables, { identifier: node.id });\n },\n\n selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => {\n let selectables: Selectable[] = [];\n\n for (const nodeId of nodeIds) {\n const node = getNode(nodeId);\n if (!node || !isTreeModelHierarchyNode(node)) {\n return;\n }\n selectables = [...selectables, ...createSelectables(node.id, node.nodeData)];\n }\n\n const actionProps = { imodelKey: key, source, selectables, level: 0 };\n\n switch (changeType) {\n case \"add\":\n storage.addToSelection(actionProps);\n return;\n case \"remove\":\n storage.removeFromSelection(actionProps);\n return;\n case \"replace\":\n storage.replaceSelection(actionProps);\n return;\n }\n },\n };\n}\n\nfunction createSelectables(nodeId: string, node: HierarchyNode): Selectable[] {\n if (HierarchyNode.isInstancesNode(node)) {\n return node.key.instanceKeys;\n }\n\n return [\n {\n identifier: nodeId,\n async *loadInstanceKeys() {\n if (!HierarchyNode.isGroupingNode(node)) {\n return;\n }\n\n for (const key of node.groupedInstanceKeys) {\n yield key;\n }\n },\n data: node,\n },\n ];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UseUnifiedSelection.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/UseUnifiedSelection.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAyBhG,0DA6BC;AApDD,iCAA4C;AAC5C,8EAAkF;AAElF,gEAAqF;AACrF,wEAAwE;AAExE,2CAAiH;AAgBjH,gBAAgB;AAChB,SAAgB,uBAAuB,CAAC,EACtC,UAAU,EACV,OAAO,GACuG;IAC9G,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAuB,GAAG,EAAE,CAAC,CAAC;QAClE,cAAc,EAAE,0BAA0B,CAAC,GAAG,EAAE,CAAC,KAAK;QACtD,WAAW,EAAE,0BAA0B,CAAC,GAAG,EAAE,GAAE,CAAC;KACjD,CAAC,CAAC,CAAC;IAEJ,MAAM,gBAAgB,GAAG,IAAA,oDAA0B,GAAE,CAAC;IACtD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,UAAU,CAAC;gBACT,cAAc,EAAE,GAAG,EAAE,CAAC,KAAK;gBAC3B,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;aACtB,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QAED,UAAU,CAAC,aAAa,CAAC,UAAU,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC,CAAC;QACjE,OAAO,gBAAgB,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;YAChE,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;gBACnB,OAAO;YACT,CAAC;YACD,UAAU,CAAC,aAAa,CAAC,UAAU,EAAE,gBAAgB,EAAE,OAAO,CAAC,C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------------------------\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 { useEffect, useState } from \"react\";\nimport { HierarchyNode, InstancesNodeKey } from \"@itwin/presentation-hierarchies\";\nimport { InstanceKey } from \"@itwin/presentation-shared\";\nimport { Selectable, Selectables, SelectionStorage } from \"@itwin/unified-selection\";\nimport { useUnifiedSelectionContext } from \"../UnifiedSelectionContext\";\nimport { SelectionChangeType } from \"../UseSelectionHandler\";\nimport { isTreeModelHierarchyNode, TreeModelHierarchyNode, TreeModelNode, TreeModelRootNode } from \"./TreeModel\";\n\n/** @internal */\nexport interface TreeSelectionOptions {\n isNodeSelected: (nodeId: string) => boolean;\n selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => void;\n}\n\n/** @beta */\nexport interface UseUnifiedTreeSelectionProps {\n /**\n * Identifier to distinguish this source of changes to the unified selection from another ones in the application.\n */\n sourceName: string;\n}\n\n/** @internal */\nexport function useUnifiedTreeSelection({\n sourceName,\n getNode,\n}: UseUnifiedTreeSelectionProps & { getNode: (nodeId: string) => TreeModelNode | TreeModelRootNode | undefined }): TreeSelectionOptions {\n const [options, setOptions] = useState<TreeSelectionOptions>(() => ({\n isNodeSelected: /* istanbul ignore next */ () => false,\n selectNodes: /* istanbul ignore next */ () => {},\n }));\n\n const selectionStorage = useUnifiedSelectionContext();\n useEffect(() => {\n if (!selectionStorage) {\n setOptions({\n isNodeSelected: () => false,\n selectNodes: () => {},\n });\n return;\n }\n\n setOptions(createOptions(sourceName, selectionStorage, getNode));\n return selectionStorage.selectionChangeEvent.addListener((args) => {\n if (args.level > 0) {\n return;\n }\n setOptions(createOptions(sourceName, selectionStorage, getNode));\n });\n }, [selectionStorage, getNode, sourceName]);\n\n return options;\n}\n\nfunction createOptions(\n source: string,\n storage: SelectionStorage,\n getNode: (nodeId: string) => TreeModelNode | TreeModelRootNode | undefined,\n): TreeSelectionOptions {\n return {\n isNodeSelected: (nodeId: string) => {\n const node = getNode(nodeId);\n if (!node || !isTreeModelHierarchyNode(node)) {\n return false;\n }\n return Object.entries(groupNodeSelectablesByIModelKey(node)).some(([imodelKey, nodeSelectables]) => {\n const storageSelectables = storage.getSelection({ imodelKey, level: 0 });\n return Selectables.hasAny(storageSelectables, nodeSelectables);\n });\n },\n\n selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => {\n const imodelSelectables: { [imodelKey: string]: Selectable[] } = {};\n for (const nodeId of nodeIds) {\n const node = getNode(nodeId);\n if (!node || !isTreeModelHierarchyNode(node)) {\n return;\n }\n Object.entries(groupNodeSelectablesByIModelKey(node)).forEach(([imodelKey, nodeSelectables]) => {\n let selectablesList = imodelSelectables[imodelKey];\n if (!selectablesList) {\n selectablesList = [];\n imodelSelectables[imodelKey] = selectablesList;\n }\n nodeSelectables.forEach((selectable) => selectablesList.push(selectable));\n });\n }\n Object.entries(imodelSelectables).forEach(([imodelKey, selectables]) => {\n const actionProps = { imodelKey, source, selectables, level: 0 };\n switch (changeType) {\n case \"add\":\n storage.addToSelection(actionProps);\n return;\n case \"remove\":\n storage.removeFromSelection(actionProps);\n return;\n case \"replace\":\n storage.replaceSelection(actionProps);\n return;\n }\n });\n },\n };\n}\n\nfunction groupNodeSelectablesByIModelKey(modelNode: TreeModelHierarchyNode): { [imodelKey: string]: Selectable[] } {\n const hierarchyNode = modelNode.nodeData;\n if (HierarchyNode.isGeneric(hierarchyNode)) {\n return {\n // note: generic nodes aren't associated with an imodel\n [\"\"]: [\n {\n identifier: modelNode.id,\n data: hierarchyNode,\n async *loadInstanceKeys() {},\n },\n ],\n };\n }\n if (HierarchyNode.isInstancesNode(hierarchyNode)) {\n return groupIModelInstanceKeys(hierarchyNode.key.instanceKeys);\n }\n if (HierarchyNode.isGroupingNode(hierarchyNode)) {\n return Object.entries(groupIModelInstanceKeys(hierarchyNode.groupedInstanceKeys)).reduce(\n (imodelSelectables, [imodelKey, instanceKeys]) => ({\n ...imodelSelectables,\n [imodelKey]: [\n {\n identifier: modelNode.id,\n data: hierarchyNode,\n async *loadInstanceKeys() {\n for (const key of instanceKeys) {\n yield key;\n }\n },\n },\n ],\n }),\n {} as { [imodelKey: string]: Selectable[] },\n );\n }\n // istanbul ignore next\n return {};\n}\n\nfunction groupIModelInstanceKeys(instanceKeys: InstancesNodeKey[\"instanceKeys\"]) {\n return instanceKeys.reduce(\n (imodelSelectables, key) => {\n const imodelKey = key.imodelKey ?? \"\";\n let selectablesList = imodelSelectables[imodelKey];\n if (!selectablesList) {\n selectablesList = [];\n imodelSelectables[imodelKey] = selectablesList;\n }\n selectablesList.push(key);\n return imodelSelectables;\n },\n {} as { [imodelKey: string]: InstanceKey[] },\n );\n}\n"]}
|
|
@@ -13,7 +13,7 @@ function createNodeId(node) {
|
|
|
13
13
|
return [...node.parentKeys.map(serializeNodeKey), serializeNodeKey(node.key)].join(";");
|
|
14
14
|
}
|
|
15
15
|
function serializeNodeKey(key) {
|
|
16
|
-
return
|
|
16
|
+
return convertObjectValuesToString(key);
|
|
17
17
|
}
|
|
18
18
|
function convertObjectValuesToString(obj) {
|
|
19
19
|
return Object.entries(obj)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/Utils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAKhG,oCAEC;AAkBD,8BAeC;AAtCD,8EAAkF;AAElF,gBAAgB;AAChB,SAAgB,YAAY,CAAC,IAA+C;IAC1E,OAAO,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1F,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAqB;IAC7C,OAAO,
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../src/presentation-h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,2CAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YACzE,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,gBAAgB;AACH,QAAA,kBAAkB,GAAG,KAAK,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { HierarchyNode, HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\n\n/** @internal */\nexport function createNodeId(node: Pick<HierarchyNode, \"key\" | \"parentKeys\">) {\n return [...node.parentKeys.map(serializeNodeKey), serializeNodeKey(node.key)].join(\";\");\n}\n\nfunction serializeNodeKey(key: HierarchyNodeKey): string {\n return convertObjectValuesToString(key);\n}\n\nfunction convertObjectValuesToString(obj: object): string {\n return Object.entries(obj)\n .map(([, value]) => {\n if (typeof value === \"object\") {\n return convertObjectValuesToString(value);\n }\n return String(value);\n })\n .join(\",\");\n}\n\n/** @internal */\nexport function sameNodes(lhs: HierarchyNode, rhs: HierarchyNode): boolean {\n if (HierarchyNodeKey.compare(lhs.key, rhs.key) !== 0) {\n return false;\n }\n\n if (lhs.parentKeys.length !== rhs.parentKeys.length) {\n return false;\n }\n\n for (let i = lhs.parentKeys.length - 1; i >= 0; --i) {\n if (HierarchyNodeKey.compare(lhs.parentKeys[i], rhs.parentKeys[i]) !== 0) {\n return false;\n }\n }\n return true;\n}\n\n/** @internal */\nexport const MAX_LIMIT_OVERRIDE = 10000;\n"]}
|
|
@@ -2,7 +2,7 @@ import "./TreeNodeRenderer.css";
|
|
|
2
2
|
import { ComponentPropsWithoutRef, ReactElement } from "react";
|
|
3
3
|
import { TreeNode } from "@itwin/itwinui-react";
|
|
4
4
|
import { PresentationHierarchyNode } from "../TreeNode";
|
|
5
|
-
import { HierarchyLevelDetails,
|
|
5
|
+
import { HierarchyLevelDetails, UseTreeResult } from "../UseTree";
|
|
6
6
|
import { RenderedTreeNode } from "./TreeRenderer";
|
|
7
7
|
/** @beta */
|
|
8
8
|
type TreeNodeProps = ComponentPropsWithoutRef<typeof TreeNode>;
|
|
@@ -31,7 +31,7 @@ interface TreeNodeRendererOwnProps {
|
|
|
31
31
|
actionButtonsClassName?: string;
|
|
32
32
|
}
|
|
33
33
|
/** @beta */
|
|
34
|
-
type TreeNodeRendererProps = Pick<
|
|
34
|
+
type TreeNodeRendererProps = Pick<UseTreeResult, "expandNode"> & Partial<Pick<UseTreeResult, "getHierarchyLevelDetails">> & Omit<TreeNodeProps, "label" | "onExpanded" | "onSelected" | "icon"> & TreeNodeRendererOwnProps;
|
|
35
35
|
/**
|
|
36
36
|
* A component that renders `RenderedTreeNode` using the `TreeNode` component from `@itwin/itwinui-react`.
|
|
37
37
|
*
|
|
@@ -39,6 +39,6 @@ type TreeNodeRendererProps = Pick<ReturnType<typeof useTree>, "expandNode"> & Pa
|
|
|
39
39
|
* @see https://itwinui.bentley.com/docs/tree
|
|
40
40
|
* @beta
|
|
41
41
|
*/
|
|
42
|
-
export declare
|
|
42
|
+
export declare const TreeNodeRenderer: React.ForwardRefExoticComponent<TreeNodeRendererProps>;
|
|
43
43
|
export {};
|
|
44
44
|
//# sourceMappingURL=TreeNodeRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"TreeNodeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAKA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;QAAE,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IACrF,6CAA6C;IAC7C,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,YAAY;AACZ,KAAK,qBAAqB,GAAG,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,GAC5D,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,0BAA0B,CAAC,CAAC,GACxD,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,YAAY,GAAG,YAAY,GAAG,MAAM,CAAC,GACnE,wBAAwB,CAAC;AAE3B;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,yBAAyB,CAAC,qBAAqB,CA0HnF,CAAC"}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TreeNodeRenderer =
|
|
6
|
+
exports.TreeNodeRenderer = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
/*---------------------------------------------------------------------------------------------
|
|
9
9
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
@@ -24,26 +24,27 @@ const LocalizationContext_1 = require("./LocalizationContext");
|
|
|
24
24
|
* @see https://itwinui.bentley.com/docs/tree
|
|
25
25
|
* @beta
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
exports.TreeNodeRenderer = (0, react_1.forwardRef)(({ node, expandNode, getIcon, getLabel, getSublabel, onFilterClick, onNodeClick, onNodeKeyDown, isSelected, isDisabled, actionButtonsClassName, getHierarchyLevelDetails, reloadTree, ...treeNodeProps }, forwardedRef) => {
|
|
28
28
|
const { localizedStrings } = (0, LocalizationContext_1.useLocalizationContext)();
|
|
29
29
|
const applyFilterButtonRef = (0, react_1.useRef)(null);
|
|
30
30
|
const nodeRef = (0, react_1.useRef)(null);
|
|
31
|
+
const ref = useMergedRefs(forwardedRef, nodeRef);
|
|
31
32
|
if ("type" in node && node.type === "ChildrenPlaceholder") {
|
|
32
33
|
return (0, jsx_runtime_1.jsx)(PlaceholderNode, { ...treeNodeProps });
|
|
33
34
|
}
|
|
34
35
|
if ((0, TreeNode_1.isPresentationHierarchyNode)(node)) {
|
|
35
|
-
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.TreeNode, { ...treeNodeProps, ref:
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.TreeNode, { ...treeNodeProps, ref: ref, isSelected: isSelected, isDisabled: isDisabled, className: (0, classnames_1.default)(treeNodeProps.className, "stateless-tree-node", { filtered: node.isFiltered }), onClick: (event) => !isDisabled && onNodeClick?.(node, !isSelected, event), onKeyDown: (event) => {
|
|
36
37
|
// Ignore if it is called on the element inside, e.g. checkbox or expander
|
|
37
38
|
if (!isDisabled && event.target === nodeRef.current) {
|
|
38
39
|
onNodeKeyDown?.(node, !isSelected, event);
|
|
39
40
|
}
|
|
40
41
|
}, onExpanded: (_, isExpanded) => {
|
|
41
42
|
expandNode(node.id, isExpanded);
|
|
42
|
-
}, icon: getIcon ? getIcon(node) : undefined, label: getLabel ? getLabel(node) : node.label, sublabel: getSublabel ? getSublabel(node) : undefined, children: (0, jsx_runtime_1.jsxs)(itwinui_react_1.ButtonGroup, { className: (0, classnames_1.default)("action-buttons", actionButtonsClassName), children: [getHierarchyLevelDetails && node.isFiltered ? ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { className: "filtering-action-button", styleType: "borderless", size: "small",
|
|
43
|
+
}, icon: getIcon ? getIcon(node) : undefined, label: getLabel ? getLabel(node) : node.label, sublabel: getSublabel ? getSublabel(node) : undefined, children: (0, jsx_runtime_1.jsxs)(itwinui_react_1.ButtonGroup, { className: (0, classnames_1.default)("action-buttons", actionButtonsClassName), children: [getHierarchyLevelDetails && node.isFiltered ? ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { className: "filtering-action-button", styleType: "borderless", size: "small", label: localizedStrings.clearHierarchyLevelFilter, onClick: (e) => {
|
|
43
44
|
e.stopPropagation();
|
|
44
45
|
getHierarchyLevelDetails(node.id)?.setInstanceFilter(undefined);
|
|
45
46
|
applyFilterButtonRef.current?.focus();
|
|
46
|
-
}, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgRemove, {}) })) : null, onFilterClick && node.isFilterable ? ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { ref: applyFilterButtonRef, className: "filtering-action-button", styleType: "borderless", size: "small",
|
|
47
|
+
}, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgRemove, {}) })) : null, onFilterClick && node.isFilterable ? ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { ref: applyFilterButtonRef, className: "filtering-action-button", styleType: "borderless", size: "small", label: localizedStrings.filterHierarchyLevel, onClick: (e) => {
|
|
47
48
|
e.stopPropagation();
|
|
48
49
|
const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);
|
|
49
50
|
hierarchyLevelDetails && onFilterClick(hierarchyLevelDetails);
|
|
@@ -58,22 +59,25 @@ function TreeNodeRenderer({ node, expandNode, getIcon, getLabel, getSublabel, on
|
|
|
58
59
|
: undefined }));
|
|
59
60
|
}
|
|
60
61
|
if (node.type === "NoFilterMatches") {
|
|
61
|
-
return (0, jsx_runtime_1.jsx)(itwinui_react_1.TreeNode, { ...treeNodeProps, label: localizedStrings.noFilteredChildren, isDisabled: true, onExpanded: /* istanbul ignore next */ () => { } });
|
|
62
|
+
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.TreeNode, { ...treeNodeProps, ref: ref, label: localizedStrings.noFilteredChildren, isDisabled: true, onExpanded: /* istanbul ignore next */ () => { } }));
|
|
62
63
|
}
|
|
63
64
|
const onRetry = reloadTree ? () => reloadTree({ parentNodeId: node.parentNodeId, state: "reset" }) : undefined;
|
|
64
|
-
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.TreeNode, { ...treeNodeProps, label: (0, jsx_runtime_1.jsx)(ErrorNodeLabel, { message: node.message, onRetry: onRetry }), isDisabled: true, onExpanded: /* istanbul ignore next */ () => { } }));
|
|
65
|
-
}
|
|
65
|
+
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.TreeNode, { ...treeNodeProps, ref: ref, label: (0, jsx_runtime_1.jsx)(ErrorNodeLabel, { message: node.message, onRetry: onRetry }), isDisabled: true, onExpanded: /* istanbul ignore next */ () => { } }));
|
|
66
|
+
});
|
|
67
|
+
exports.TreeNodeRenderer.displayName = "TreeNodeRenderer";
|
|
68
|
+
const PlaceholderNode = (0, react_1.forwardRef)((props, forwardedRef) => {
|
|
69
|
+
const { localizedStrings } = (0, LocalizationContext_1.useLocalizationContext)();
|
|
70
|
+
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.TreeNode, { ...props, ref: forwardedRef, label: localizedStrings.loading, icon: (0, jsx_runtime_1.jsx)(itwinui_react_1.ProgressRadial, { size: "x-small", indeterminate: true, title: localizedStrings.loading }), onExpanded: /* istanbul ignore next */ () => { } }));
|
|
71
|
+
});
|
|
72
|
+
PlaceholderNode.displayName = "PlaceholderNode";
|
|
73
|
+
const ResultSetTooLargeNode = (0, react_1.forwardRef)(({ onFilterClick, onOverrideLimit, limit, ...props }, forwardedRef) => {
|
|
74
|
+
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.TreeNode, { ...props, ref: forwardedRef, className: "stateless-tree-node", label: (0, jsx_runtime_1.jsx)(ResultSetTooLargeNodeLabel, { limit: limit, onFilterClick: onFilterClick, onOverrideLimit: onOverrideLimit }), onExpanded: /* istanbul ignore next */ () => { } }));
|
|
75
|
+
});
|
|
76
|
+
ResultSetTooLargeNode.displayName = "ResultSetTooLargeNode";
|
|
66
77
|
function ErrorNodeLabel({ message, onRetry }) {
|
|
67
78
|
const { localizedStrings } = (0, LocalizationContext_1.useLocalizationContext)();
|
|
68
79
|
return ((0, jsx_runtime_1.jsxs)(itwinui_react_1.Flex, { flexDirection: "row", gap: "xs", title: message, alignItems: "start", children: [(0, jsx_runtime_1.jsx)(itwinui_react_1.Text, { children: message }), onRetry ? (0, jsx_runtime_1.jsx)(itwinui_react_1.Anchor, { onClick: onRetry, children: localizedStrings?.retry }) : null] }));
|
|
69
80
|
}
|
|
70
|
-
function PlaceholderNode(props) {
|
|
71
|
-
const { localizedStrings } = (0, LocalizationContext_1.useLocalizationContext)();
|
|
72
|
-
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.TreeNode, { ...props, label: localizedStrings.loading, icon: (0, jsx_runtime_1.jsx)(itwinui_react_1.ProgressRadial, { size: "x-small", indeterminate: true, title: localizedStrings.loading }), onExpanded: /* istanbul ignore next */ () => { } }));
|
|
73
|
-
}
|
|
74
|
-
function ResultSetTooLargeNode({ onFilterClick, onOverrideLimit, limit, ...props }) {
|
|
75
|
-
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.TreeNode, { ...props, className: "stateless-tree-node", label: (0, jsx_runtime_1.jsx)(ResultSetTooLargeNodeLabel, { limit: limit, onFilterClick: onFilterClick, onOverrideLimit: onOverrideLimit }), onExpanded: /* istanbul ignore next */ () => { } }));
|
|
76
|
-
}
|
|
77
81
|
function ResultSetTooLargeNodeLabel({ onFilterClick, onOverrideLimit, limit }) {
|
|
78
82
|
const { localizedStrings } = (0, LocalizationContext_1.useLocalizationContext)();
|
|
79
83
|
const supportsFiltering = !!onFilterClick;
|
|
@@ -106,4 +110,17 @@ function createLocalizedMessage(message, limit, onClick) {
|
|
|
106
110
|
}, children: innerText }), textAfter ? (0, jsx_runtime_1.jsx)(itwinui_react_1.Text, { children: textAfter }) : null] })),
|
|
107
111
|
};
|
|
108
112
|
}
|
|
113
|
+
function useMergedRefs(...refs) {
|
|
114
|
+
return (0, react_1.useCallback)((instance) => {
|
|
115
|
+
refs.forEach((ref) => {
|
|
116
|
+
if (typeof ref === "function") {
|
|
117
|
+
ref(instance);
|
|
118
|
+
}
|
|
119
|
+
else if (ref) {
|
|
120
|
+
ref.current = instance;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
124
|
+
[...refs]);
|
|
125
|
+
}
|
|
109
126
|
//# sourceMappingURL=TreeNodeRenderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":";;;;;AAsDA,4CAkHC;;AAxKD;;;gGAGgG;AAEhG,kCAAgC;AAChC,4DAA4B;AAC5B,iCAAuE;AACvE,oEAAmF;AACnF,wDAA6G;AAC7G,6CAAuD;AACvD,0CAAqF;AAErF,+DAA+D;AAkC/D;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EACX,aAAa,EACb,WAAW,EACX,aAAa,EACb,UAAU,EACV,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,UAAU,EACV,GAAG,aAAa,EACM;IACtB,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAA,4CAAsB,GAAE,CAAC;IACtD,MAAM,oBAAoB,GAAG,IAAA,cAAM,EAAoB,IAAI,CAAC,CAAC;IAC7D,MAAM,OAAO,GAAG,IAAA,cAAM,EAAgB,IAAI,CAAC,CAAC;IAE5C,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,qBAAqB,EAAE,CAAC;QAC1D,OAAO,uBAAC,eAAe,OAAK,aAAa,GAAI,CAAC;IAChD,CAAC;IAED,IAAI,IAAA,sCAA2B,EAAC,IAAI,CAAC,EAAE,CAAC;QACtC,OAAO,CACL,uBAAC,wBAAQ,OACH,aAAa,EACjB,GAAG,EAAE,OAAO,EACZ,U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CAAC;IACJ,CAAC;IAED,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;IACpC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEjE,OAAO;QACL,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC;QACpD,OAAO,EAAE,CACP,wBAAC,oBAAI,IAAC,aAAa,EAAC,KAAK,EAAC,GAAG,EAAC,KAAK,aAChC,UAAU,CAAC,CAAC,CAAC,uBAAC,oBAAI,cAAE,UAAU,GAAQ,CAAC,CAAC,CAAC,IAAI,EAC9C,uBAAC,sBAAM,IACL,SAAS,QACT,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;wBACb,CAAC,CAAC,eAAe,EAAE,CAAC;wBACpB,OAAO,EAAE,EAAE,CAAC;oBACd,CAAC,YAEA,SAAS,GACH,EACR,SAAS,CAAC,CAAC,CAAC,uBAAC,oBAAI,cAAE,SAAS,GAAQ,CAAC,CAAC,CAAC,IAAI,IACvC,CACR;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"./TreeNodeRenderer.css\";\nimport cx from \"classnames\";\nimport { ComponentPropsWithoutRef, ReactElement, useRef } from \"react\";\nimport { SvgFilter, SvgFilterHollow, SvgRemove } from \"@itwin/itwinui-icons-react\";\nimport { Anchor, ButtonGroup, Flex, IconButton, ProgressRadial, Text, TreeNode } from \"@itwin/itwinui-react\";\nimport { MAX_LIMIT_OVERRIDE } from \"../internal/Utils\";\nimport { isPresentationHierarchyNode, PresentationHierarchyNode } from \"../TreeNode\";\nimport { HierarchyLevelDetails, useTree } from \"../UseTree\";\nimport { useLocalizationContext } from \"./LocalizationContext\";\nimport { RenderedTreeNode } from \"./TreeRenderer\";\n\n/** @beta */\ntype TreeNodeProps = ComponentPropsWithoutRef<typeof TreeNode>;\n\n/** @beta */\ninterface TreeNodeRendererOwnProps {\n /** Node that is rendered. */\n node: RenderedTreeNode;\n /** Action to perform when the filter button is clicked for this node. */\n onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n /** Returns an icon for a given node. */\n getIcon?: (node: PresentationHierarchyNode) => ReactElement | undefined;\n /** Returns a label for a given node. */\n getLabel?: (node: PresentationHierarchyNode) => ReactElement | undefined;\n /** Returns sublabel for a given node. */\n getSublabel?: (node: PresentationHierarchyNode) => ReactElement | undefined;\n /** Action to perform when the node is clicked. */\n onNodeClick?: (node: PresentationHierarchyNode, isSelected: boolean, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Action to perform when a key is pressed when the node is hovered on. */\n onNodeKeyDown?: (node: PresentationHierarchyNode, isSelected: boolean, event: React.KeyboardEvent<HTMLElement>) => void;\n /** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */\n reloadTree?: (options: { parentNodeId: string | undefined; state: \"reset\" }) => void;\n /** CSS class name for the action buttons. */\n actionButtonsClassName?: string;\n}\n\n/** @beta */\ntype TreeNodeRendererProps = Pick<ReturnType<typeof useTree>, \"expandNode\"> &\n Partial<Pick<ReturnType<typeof useTree>, \"getHierarchyLevelDetails\">> &\n Omit<TreeNodeProps, \"label\" | \"onExpanded\" | \"onSelected\" | \"icon\"> &\n TreeNodeRendererOwnProps;\n\n/**\n * A component that renders `RenderedTreeNode` using the `TreeNode` component from `@itwin/itwinui-react`.\n *\n * @see `TreeRenderer`\n * @see https://itwinui.bentley.com/docs/tree\n * @beta\n */\nexport function TreeNodeRenderer({\n node,\n expandNode,\n getIcon,\n getLabel,\n getSublabel,\n onFilterClick,\n onNodeClick,\n onNodeKeyDown,\n isSelected,\n isDisabled,\n actionButtonsClassName,\n getHierarchyLevelDetails,\n reloadTree,\n ...treeNodeProps\n}: TreeNodeRendererProps) {\n const { localizedStrings } = useLocalizationContext();\n const applyFilterButtonRef = useRef<HTMLButtonElement>(null);\n const nodeRef = useRef<HTMLLIElement>(null);\n\n if (\"type\" in node && node.type === \"ChildrenPlaceholder\") {\n return <PlaceholderNode {...treeNodeProps} />;\n }\n\n if (isPresentationHierarchyNode(node)) {\n return (\n <TreeNode\n {...treeNodeProps}\n ref={nodeRef}\n isSelected={isSelected}\n isDisabled={isDisabled}\n className={cx(treeNodeProps.className, \"stateless-tree-node\", { filtered: node.isFiltered })}\n onClick={(event) => !isDisabled && onNodeClick?.(node, !isSelected, event)}\n onKeyDown={(event) => {\n // Ignore if it is called on the element inside, e.g. checkbox or expander\n if (!isDisabled && event.target === nodeRef.current) {\n onNodeKeyDown?.(node, !isSelected, event);\n }\n }}\n onExpanded={(_, isExpanded) => {\n expandNode(node.id, isExpanded);\n }}\n icon={getIcon ? getIcon(node) : undefined}\n label={getLabel ? getLabel(node) : node.label}\n sublabel={getSublabel ? getSublabel(node) : undefined}\n >\n <ButtonGroup className={cx(\"action-buttons\", actionButtonsClassName)}>\n {getHierarchyLevelDetails && node.isFiltered ? (\n <IconButton\n className=\"filtering-action-button\"\n styleType=\"borderless\"\n size=\"small\"\n title={localizedStrings.clearHierarchyLevelFilter}\n onClick={(e) => {\n e.stopPropagation();\n getHierarchyLevelDetails(node.id)?.setInstanceFilter(undefined);\n applyFilterButtonRef.current?.focus();\n }}\n >\n <SvgRemove />\n </IconButton>\n ) : null}\n {onFilterClick && node.isFilterable ? (\n <IconButton\n ref={applyFilterButtonRef}\n className=\"filtering-action-button\"\n styleType=\"borderless\"\n size=\"small\"\n title={localizedStrings.filterHierarchyLevel}\n onClick={(e) => {\n e.stopPropagation();\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);\n hierarchyLevelDetails && onFilterClick(hierarchyLevelDetails);\n }}\n >\n {node.isFiltered ? <SvgFilter /> : <SvgFilterHollow />}\n </IconButton>\n ) : null}\n </ButtonGroup>\n </TreeNode>\n );\n }\n\n if (node.type === \"ResultSetTooLarge\") {\n return (\n <ResultSetTooLargeNode\n {...treeNodeProps}\n limit={node.resultSetSizeLimit}\n onOverrideLimit={getHierarchyLevelDetails ? (limit) => getHierarchyLevelDetails(node.parentNodeId)?.setSizeLimit(limit) : undefined}\n onFilterClick={\n onFilterClick\n ? () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.parentNodeId);\n hierarchyLevelDetails && onFilterClick(hierarchyLevelDetails);\n }\n : undefined\n }\n />\n );\n }\n\n if (node.type === \"NoFilterMatches\") {\n return <TreeNode {...treeNodeProps} label={localizedStrings.noFilteredChildren} isDisabled={true} onExpanded={/* istanbul ignore next */ () => {}} />;\n }\n\n const onRetry = reloadTree ? () => reloadTree({ parentNodeId: node.parentNodeId, state: \"reset\" }) : undefined;\n return (\n <TreeNode\n {...treeNodeProps}\n label={<ErrorNodeLabel message={node.message} onRetry={onRetry} />}\n isDisabled={true}\n onExpanded={/* istanbul ignore next */ () => {}}\n />\n );\n}\n\nfunction ErrorNodeLabel({ message, onRetry }: { message: string; onRetry?: () => void }) {\n const { localizedStrings } = useLocalizationContext();\n return (\n <Flex flexDirection=\"row\" gap=\"xs\" title={message} alignItems=\"start\">\n <Text>{message}</Text>\n {onRetry ? <Anchor onClick={onRetry}>{localizedStrings?.retry}</Anchor> : null}\n </Flex>\n );\n}\n\nfunction PlaceholderNode(props: Omit<TreeNodeProps, \"onExpanded\" | \"label\">) {\n const { localizedStrings } = useLocalizationContext();\n return (\n <TreeNode\n {...props}\n label={localizedStrings.loading}\n icon={<ProgressRadial size=\"x-small\" indeterminate title={localizedStrings.loading} />}\n onExpanded={/* istanbul ignore next */ () => {}}\n ></TreeNode>\n );\n}\n\nfunction ResultSetTooLargeNode({\n onFilterClick,\n onOverrideLimit,\n limit,\n ...props\n}: Omit<TreeNodeProps, \"onExpanded\" | \"label\"> & ResultSetTooLargeNodeLabelProps) {\n return (\n <TreeNode\n {...props}\n className=\"stateless-tree-node\"\n label={<ResultSetTooLargeNodeLabel limit={limit} onFilterClick={onFilterClick} onOverrideLimit={onOverrideLimit} />}\n onExpanded={/* istanbul ignore next */ () => {}}\n />\n );\n}\n\ninterface ResultSetTooLargeNodeLabelProps {\n limit: number;\n onFilterClick?: () => void;\n onOverrideLimit?: (limit: number) => void;\n}\n\nfunction ResultSetTooLargeNodeLabel({ onFilterClick, onOverrideLimit, limit }: ResultSetTooLargeNodeLabelProps) {\n const { localizedStrings } = useLocalizationContext();\n const supportsFiltering = !!onFilterClick;\n const supportsLimitOverride = !!onOverrideLimit && limit < MAX_LIMIT_OVERRIDE;\n\n const limitExceededMessage = createLocalizedMessage(\n supportsFiltering ? localizedStrings.resultLimitExceededWithFiltering : localizedStrings.resultLimitExceeded,\n limit,\n onFilterClick,\n );\n const increaseLimitMessage = supportsLimitOverride\n ? createLocalizedMessage(\n supportsFiltering ? localizedStrings.increaseHierarchyLimitWithFiltering : localizedStrings.increaseHierarchyLimit,\n MAX_LIMIT_OVERRIDE,\n () => onOverrideLimit(MAX_LIMIT_OVERRIDE),\n )\n : { title: \"\", element: null };\n\n const title = `${limitExceededMessage.title} ${increaseLimitMessage.title}`;\n\n return (\n <Flex flexDirection=\"column\" gap=\"3xs\" title={title} alignItems=\"start\">\n {limitExceededMessage.element}\n {increaseLimitMessage.element}\n </Flex>\n );\n}\n\nfunction createLocalizedMessage(message: string, limit: number, onClick?: () => void) {\n const limitStr = limit.toLocaleString(undefined, { useGrouping: true });\n const messageWithLimit = message.replace(\"{{limit}}\", limitStr);\n const exp = new RegExp(\"<link>(.*)</link>\");\n const match = messageWithLimit.match(exp);\n\n if (!match) {\n return {\n title: messageWithLimit,\n element: (\n <Flex flexDirection=\"row\" gap=\"3xs\">\n <Text>{messageWithLimit}</Text>\n </Flex>\n ),\n };\n }\n\n const [fullText, innerText] = match;\n const [textBefore, textAfter] = messageWithLimit.split(fullText);\n\n return {\n title: messageWithLimit.replace(fullText, innerText),\n element: (\n <Flex flexDirection=\"row\" gap=\"3xs\">\n {textBefore ? <Text>{textBefore}</Text> : null}\n <Anchor\n underline\n onClick={(e) => {\n e.stopPropagation();\n onClick?.();\n }}\n >\n {innerText}\n </Anchor>\n {textAfter ? <Text>{textAfter}</Text> : null}\n </Flex>\n ),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;gGAGgG;AAEhG,kCAAgC;AAChC,4DAA4B;AAC5B,iCAAkI;AAClI,oEAAmF;AACnF,wDAA6G;AAC7G,6CAAuD;AACvD,0CAAqF;AAErF,+DAA+D;AAkC/D;;;;;;GAMG;AACU,QAAA,gBAAgB,GAA2D,IAAA,kBAAU,EAChG,CACE,EACE,IAAI,EACJ,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EACX,aAAa,EACb,WAAW,EACX,aAAa,EACb,UAAU,EACV,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,UAAU,EACV,GAAG,aAAa,EACjB,EACD,YAAY,EACZ,EAAE;IACF,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAA,4CAAsB,GAAE,CAAC;IACtD,MAAM,oBAAoB,GAAG,IAAA,cAAM,EAAoB,IAAI,CAAC,CAAC;IAC7D,MAAM,OAAO,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IAC7C,MAAM,GAAG,GAAG,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACjD,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,qBAAqB,EAAE,CAAC;QAC1D,OAAO,uBAAC,eAAe,OAAK,aAAa,GAAI,CAAC;IAChD,CAAC;IAED,IAAI,IAAA,sCAA2B,EAAC,IAAI,CAAC,EAAE,CAAC;QACtC,OAAO,CACL,uBAAC,wBAAQ,OACH,aAAa,EACjB,GAAG,EAAE,GAAG,EACR,U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,EAAE,EAAE;YACnB,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;gBAC9B,GAAG,CAAC,QAAQ,CAAC,CAAC;YAChB,CAAC;iBAAM,IAAI,GAAG,EAAE,CAAC;gBACd,GAAkC,CAAC,OAAO,GAAG,QAAQ,CAAC;YACzD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,uDAAuD;IAC1D,CAAC,GAAG,IAAI,CAAC,CACV,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"./TreeNodeRenderer.css\";\nimport cx from \"classnames\";\nimport { ComponentPropsWithoutRef, forwardRef, LegacyRef, MutableRefObject, ReactElement, Ref, useCallback, useRef } from \"react\";\nimport { SvgFilter, SvgFilterHollow, SvgRemove } from \"@itwin/itwinui-icons-react\";\nimport { Anchor, ButtonGroup, Flex, IconButton, ProgressRadial, Text, TreeNode } from \"@itwin/itwinui-react\";\nimport { MAX_LIMIT_OVERRIDE } from \"../internal/Utils\";\nimport { isPresentationHierarchyNode, PresentationHierarchyNode } from \"../TreeNode\";\nimport { HierarchyLevelDetails, UseTreeResult } from \"../UseTree\";\nimport { useLocalizationContext } from \"./LocalizationContext\";\nimport { RenderedTreeNode } from \"./TreeRenderer\";\n\n/** @beta */\ntype TreeNodeProps = ComponentPropsWithoutRef<typeof TreeNode>;\n\n/** @beta */\ninterface TreeNodeRendererOwnProps {\n /** Node that is rendered. */\n node: RenderedTreeNode;\n /** Action to perform when the filter button is clicked for this node. */\n onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n /** Returns an icon for a given node. */\n getIcon?: (node: PresentationHierarchyNode) => ReactElement | undefined;\n /** Returns a label for a given node. */\n getLabel?: (node: PresentationHierarchyNode) => ReactElement | undefined;\n /** Returns sublabel for a given node. */\n getSublabel?: (node: PresentationHierarchyNode) => ReactElement | undefined;\n /** Action to perform when the node is clicked. */\n onNodeClick?: (node: PresentationHierarchyNode, isSelected: boolean, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Action to perform when a key is pressed when the node is hovered on. */\n onNodeKeyDown?: (node: PresentationHierarchyNode, isSelected: boolean, event: React.KeyboardEvent<HTMLElement>) => void;\n /** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */\n reloadTree?: (options: { parentNodeId: string | undefined; state: \"reset\" }) => void;\n /** CSS class name for the action buttons. */\n actionButtonsClassName?: string;\n}\n\n/** @beta */\ntype TreeNodeRendererProps = Pick<UseTreeResult, \"expandNode\"> &\n Partial<Pick<UseTreeResult, \"getHierarchyLevelDetails\">> &\n Omit<TreeNodeProps, \"label\" | \"onExpanded\" | \"onSelected\" | \"icon\"> &\n TreeNodeRendererOwnProps;\n\n/**\n * A component that renders `RenderedTreeNode` using the `TreeNode` component from `@itwin/itwinui-react`.\n *\n * @see `TreeRenderer`\n * @see https://itwinui.bentley.com/docs/tree\n * @beta\n */\nexport const TreeNodeRenderer: React.ForwardRefExoticComponent<TreeNodeRendererProps> = forwardRef(\n (\n {\n node,\n expandNode,\n getIcon,\n getLabel,\n getSublabel,\n onFilterClick,\n onNodeClick,\n onNodeKeyDown,\n isSelected,\n isDisabled,\n actionButtonsClassName,\n getHierarchyLevelDetails,\n reloadTree,\n ...treeNodeProps\n },\n forwardedRef,\n ) => {\n const { localizedStrings } = useLocalizationContext();\n const applyFilterButtonRef = useRef<HTMLButtonElement>(null);\n const nodeRef = useRef<HTMLDivElement>(null);\n const ref = useMergedRefs(forwardedRef, nodeRef);\n if (\"type\" in node && node.type === \"ChildrenPlaceholder\") {\n return <PlaceholderNode {...treeNodeProps} />;\n }\n\n if (isPresentationHierarchyNode(node)) {\n return (\n <TreeNode\n {...treeNodeProps}\n ref={ref}\n isSelected={isSelected}\n isDisabled={isDisabled}\n className={cx(treeNodeProps.className, \"stateless-tree-node\", { filtered: node.isFiltered })}\n onClick={(event) => !isDisabled && onNodeClick?.(node, !isSelected, event)}\n onKeyDown={(event) => {\n // Ignore if it is called on the element inside, e.g. checkbox or expander\n if (!isDisabled && event.target === nodeRef.current) {\n onNodeKeyDown?.(node, !isSelected, event);\n }\n }}\n onExpanded={(_, isExpanded) => {\n expandNode(node.id, isExpanded);\n }}\n icon={getIcon ? getIcon(node) : undefined}\n label={getLabel ? getLabel(node) : node.label}\n sublabel={getSublabel ? getSublabel(node) : undefined}\n >\n <ButtonGroup className={cx(\"action-buttons\", actionButtonsClassName)}>\n {getHierarchyLevelDetails && node.isFiltered ? (\n <IconButton\n className=\"filtering-action-button\"\n styleType=\"borderless\"\n size=\"small\"\n label={localizedStrings.clearHierarchyLevelFilter}\n onClick={(e) => {\n e.stopPropagation();\n getHierarchyLevelDetails(node.id)?.setInstanceFilter(undefined);\n applyFilterButtonRef.current?.focus();\n }}\n >\n <SvgRemove />\n </IconButton>\n ) : null}\n {onFilterClick && node.isFilterable ? (\n <IconButton\n ref={applyFilterButtonRef}\n className=\"filtering-action-button\"\n styleType=\"borderless\"\n size=\"small\"\n label={localizedStrings.filterHierarchyLevel}\n onClick={(e) => {\n e.stopPropagation();\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);\n hierarchyLevelDetails && onFilterClick(hierarchyLevelDetails);\n }}\n >\n {node.isFiltered ? <SvgFilter /> : <SvgFilterHollow />}\n </IconButton>\n ) : null}\n </ButtonGroup>\n </TreeNode>\n );\n }\n\n if (node.type === \"ResultSetTooLarge\") {\n return (\n <ResultSetTooLargeNode\n {...treeNodeProps}\n limit={node.resultSetSizeLimit}\n onOverrideLimit={getHierarchyLevelDetails ? (limit) => getHierarchyLevelDetails(node.parentNodeId)?.setSizeLimit(limit) : undefined}\n onFilterClick={\n onFilterClick\n ? () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.parentNodeId);\n hierarchyLevelDetails && onFilterClick(hierarchyLevelDetails);\n }\n : undefined\n }\n />\n );\n }\n\n if (node.type === \"NoFilterMatches\") {\n return (\n <TreeNode {...treeNodeProps} ref={ref} label={localizedStrings.noFilteredChildren} isDisabled={true} onExpanded={/* istanbul ignore next */ () => {}} />\n );\n }\n\n const onRetry = reloadTree ? () => reloadTree({ parentNodeId: node.parentNodeId, state: \"reset\" }) : undefined;\n return (\n <TreeNode\n {...treeNodeProps}\n ref={ref}\n label={<ErrorNodeLabel message={node.message} onRetry={onRetry} />}\n isDisabled={true}\n onExpanded={/* istanbul ignore next */ () => {}}\n />\n );\n },\n);\nTreeNodeRenderer.displayName = \"TreeNodeRenderer\";\n\nconst PlaceholderNode = forwardRef<HTMLDivElement, Omit<TreeNodeProps, \"onExpanded\" | \"label\">>((props, forwardedRef) => {\n const { localizedStrings } = useLocalizationContext();\n return (\n <TreeNode\n {...props}\n ref={forwardedRef}\n label={localizedStrings.loading}\n icon={<ProgressRadial size=\"x-small\" indeterminate title={localizedStrings.loading} />}\n onExpanded={/* istanbul ignore next */ () => {}}\n />\n );\n});\nPlaceholderNode.displayName = \"PlaceholderNode\";\n\nconst ResultSetTooLargeNode = forwardRef<HTMLDivElement, Omit<TreeNodeProps, \"onExpanded\" | \"label\"> & ResultSetTooLargeNodeLabelProps>(\n ({ onFilterClick, onOverrideLimit, limit, ...props }, forwardedRef) => {\n return (\n <TreeNode\n {...props}\n ref={forwardedRef}\n className=\"stateless-tree-node\"\n label={<ResultSetTooLargeNodeLabel limit={limit} onFilterClick={onFilterClick} onOverrideLimit={onOverrideLimit} />}\n onExpanded={/* istanbul ignore next */ () => {}}\n />\n );\n },\n);\nResultSetTooLargeNode.displayName = \"ResultSetTooLargeNode\";\n\nfunction ErrorNodeLabel({ message, onRetry }: { message: string; onRetry?: () => void }) {\n const { localizedStrings } = useLocalizationContext();\n return (\n <Flex flexDirection=\"row\" gap=\"xs\" title={message} alignItems=\"start\">\n <Text>{message}</Text>\n {onRetry ? <Anchor onClick={onRetry}>{localizedStrings?.retry}</Anchor> : null}\n </Flex>\n );\n}\n\ninterface ResultSetTooLargeNodeLabelProps {\n limit: number;\n onFilterClick?: () => void;\n onOverrideLimit?: (limit: number) => void;\n}\n\nfunction ResultSetTooLargeNodeLabel({ onFilterClick, onOverrideLimit, limit }: ResultSetTooLargeNodeLabelProps) {\n const { localizedStrings } = useLocalizationContext();\n const supportsFiltering = !!onFilterClick;\n const supportsLimitOverride = !!onOverrideLimit && limit < MAX_LIMIT_OVERRIDE;\n\n const limitExceededMessage = createLocalizedMessage(\n supportsFiltering ? localizedStrings.resultLimitExceededWithFiltering : localizedStrings.resultLimitExceeded,\n limit,\n onFilterClick,\n );\n const increaseLimitMessage = supportsLimitOverride\n ? createLocalizedMessage(\n supportsFiltering ? localizedStrings.increaseHierarchyLimitWithFiltering : localizedStrings.increaseHierarchyLimit,\n MAX_LIMIT_OVERRIDE,\n () => onOverrideLimit(MAX_LIMIT_OVERRIDE),\n )\n : { title: \"\", element: null };\n\n const title = `${limitExceededMessage.title} ${increaseLimitMessage.title}`;\n\n return (\n <Flex flexDirection=\"column\" gap=\"3xs\" title={title} alignItems=\"start\">\n {limitExceededMessage.element}\n {increaseLimitMessage.element}\n </Flex>\n );\n}\n\nfunction createLocalizedMessage(message: string, limit: number, onClick?: () => void) {\n const limitStr = limit.toLocaleString(undefined, { useGrouping: true });\n const messageWithLimit = message.replace(\"{{limit}}\", limitStr);\n const exp = new RegExp(\"<link>(.*)</link>\");\n const match = messageWithLimit.match(exp);\n\n if (!match) {\n return {\n title: messageWithLimit,\n element: (\n <Flex flexDirection=\"row\" gap=\"3xs\">\n <Text>{messageWithLimit}</Text>\n </Flex>\n ),\n };\n }\n\n const [fullText, innerText] = match;\n const [textBefore, textAfter] = messageWithLimit.split(fullText);\n\n return {\n title: messageWithLimit.replace(fullText, innerText),\n element: (\n <Flex flexDirection=\"row\" gap=\"3xs\">\n {textBefore ? <Text>{textBefore}</Text> : null}\n <Anchor\n underline\n onClick={(e) => {\n e.stopPropagation();\n onClick?.();\n }}\n >\n {innerText}\n </Anchor>\n {textAfter ? <Text>{textAfter}</Text> : null}\n </Flex>\n ),\n };\n}\n\nfunction useMergedRefs<T>(...refs: ReadonlyArray<Ref<T> | LegacyRef<T> | undefined | null>) {\n return useCallback(\n (instance: T | null) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(instance);\n } else if (ref) {\n (ref as MutableRefObject<T | null>).current = instance;\n }\n });\n }, // eslint-disable-next-line react-hooks/exhaustive-deps\n [...refs],\n );\n}\n"]}
|
|
@@ -2,6 +2,7 @@ export { PresentationGenericInfoNode, PresentationHierarchyNode, PresentationInf
|
|
|
2
2
|
export { UnifiedSelectionProvider } from "./presentation-hierarchies-react/UnifiedSelectionContext";
|
|
3
3
|
export { useSelectionHandler } from "./presentation-hierarchies-react/UseSelectionHandler";
|
|
4
4
|
export { HierarchyLevelDetails, useTree, useUnifiedSelectionTree } from "./presentation-hierarchies-react/UseTree";
|
|
5
|
+
export { useIModelTree, useIModelUnifiedSelectionTree } from "./presentation-hierarchies-react/UseIModelTree";
|
|
5
6
|
export { TreeNodeRenderer } from "./presentation-hierarchies-react/itwinui/TreeNodeRenderer";
|
|
6
7
|
export { RenderedTreeNode, TreeRenderer, createRenderedTreeNodeData } from "./presentation-hierarchies-react/itwinui/TreeRenderer";
|
|
7
8
|
export { LocalizationContextProvider } from "./presentation-hierarchies-react/itwinui/LocalizationContext";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-hierarchies-react.d.ts","sourceRoot":"","sources":["../../src/presentation-hierarchies-react.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,oBAAoB,EACpB,qCAAqC,EACrC,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAAC;AACpG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sDAAsD,CAAC;AAC3F,OAAO,EAAE,q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md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.HierarchyNode = exports.GenericInstanceFilter = exports.LocalizationContextProvider = exports.createRenderedTreeNodeData = exports.TreeRenderer = exports.TreeNodeRenderer = exports.useUnifiedSelectionTree = exports.useTree = exports.useSelectionHandler = exports.UnifiedSelectionProvider = exports.isPresentationHierarchyNode = void 0;
|
|
7
|
+
exports.HierarchyNode = exports.GenericInstanceFilter = exports.LocalizationContextProvider = exports.createRenderedTreeNodeData = exports.TreeRenderer = exports.TreeNodeRenderer = exports.useIModelUnifiedSelectionTree = exports.useIModelTree = exports.useUnifiedSelectionTree = exports.useTree = exports.useSelectionHandler = exports.UnifiedSelectionProvider = exports.isPresentationHierarchyNode = void 0;
|
|
8
8
|
var TreeNode_1 = require("./presentation-hierarchies-react/TreeNode");
|
|
9
9
|
Object.defineProperty(exports, "isPresentationHierarchyNode", { enumerable: true, get: function () { return TreeNode_1.isPresentationHierarchyNode; } });
|
|
10
10
|
var UnifiedSelectionContext_1 = require("./presentation-hierarchies-react/UnifiedSelectionContext");
|
|
@@ -14,6 +14,9 @@ Object.defineProperty(exports, "useSelectionHandler", { enumerable: true, get: f
|
|
|
14
14
|
var UseTree_1 = require("./presentation-hierarchies-react/UseTree");
|
|
15
15
|
Object.defineProperty(exports, "useTree", { enumerable: true, get: function () { return UseTree_1.useTree; } });
|
|
16
16
|
Object.defineProperty(exports, "useUnifiedSelectionTree", { enumerable: true, get: function () { return UseTree_1.useUnifiedSelectionTree; } });
|
|
17
|
+
var UseIModelTree_1 = require("./presentation-hierarchies-react/UseIModelTree");
|
|
18
|
+
Object.defineProperty(exports, "useIModelTree", { enumerable: true, get: function () { return UseIModelTree_1.useIModelTree; } });
|
|
19
|
+
Object.defineProperty(exports, "useIModelUnifiedSelectionTree", { enumerable: true, get: function () { return UseIModelTree_1.useIModelUnifiedSelectionTree; } });
|
|
17
20
|
var TreeNodeRenderer_1 = require("./presentation-hierarchies-react/itwinui/TreeNodeRenderer");
|
|
18
21
|
Object.defineProperty(exports, "TreeNodeRenderer", { enumerable: true, get: function () { return TreeNodeRenderer_1.TreeNodeRenderer; } });
|
|
19
22
|
var TreeRenderer_1 = require("./presentation-hierarchies-react/itwinui/TreeRenderer");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-hierarchies-react.js","sourceRoot":"","sources":["../../src/presentation-hierarchies-react.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,sEAOmD;AADjD,uHAAA,2BAA2B,OAAA;AAE7B,oGAAoG;AAA3F,mIAAA,wBAAwB,OAAA;AACjC,4FAA2F;AAAlF,0HAAA,mBAAmB,OAAA;AAC5B,oEAAmH;AAAnF,kGAAA,OAAO,OAAA;AAAE,kHAAA,uBAAuB,OAAA;AAChE,8FAA6F;AAApF,oHAAA,gBAAgB,OAAA;AACzB,sFAAmI;AAAxG,4GAAA,YAAY,OAAA;AAAE,0HAAA,0BAA0B,OAAA;AACnE,oGAA2G;AAAlG,kIAAA,2BAA2B,OAAA;AAEpC,4EAA0G;AAAjG,iIAAA,qBAAqB,OAAA;AAAE,yHAAA,aAAa,OAAA","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\nexport {\n PresentationGenericInfoNode,\n PresentationHierarchyNode,\n PresentationInfoNode,\n PresentationResultSetTooLargeInfoNode,\n PresentationTreeNode,\n isPresentationHierarchyNode,\n} from \"./presentation-hierarchies-react/TreeNode\";\nexport { UnifiedSelectionProvider } from \"./presentation-hierarchies-react/UnifiedSelectionContext\";\nexport { useSelectionHandler } from \"./presentation-hierarchies-react/UseSelectionHandler\";\nexport { HierarchyLevelDetails, useTree, useUnifiedSelectionTree } from \"./presentation-hierarchies-react/UseTree\";\nexport { TreeNodeRenderer } from \"./presentation-hierarchies-react/itwinui/TreeNodeRenderer\";\nexport { RenderedTreeNode, TreeRenderer, createRenderedTreeNodeData } from \"./presentation-hierarchies-react/itwinui/TreeRenderer\";\nexport { LocalizationContextProvider } from \"./presentation-hierarchies-react/itwinui/LocalizationContext\";\n\nexport { GenericInstanceFilter, HierarchyNode, HierarchyProvider } from \"@itwin/presentation-hierarchies\";\nexport { SelectionStorage } from \"@itwin/unified-selection\";\n"]}
|
|
1
|
+
{"version":3,"file":"presentation-hierarchies-react.js","sourceRoot":"","sources":["../../src/presentation-hierarchies-react.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,sEAOmD;AADjD,uHAAA,2BAA2B,OAAA;AAE7B,oGAAoG;AAA3F,mIAAA,wBAAwB,OAAA;AACjC,4FAA2F;AAAlF,0HAAA,mBAAmB,OAAA;AAC5B,oEAAmH;AAAnF,kGAAA,OAAO,OAAA;AAAE,kHAAA,uBAAuB,OAAA;AAChE,gFAA8G;AAArG,8GAAA,aAAa,OAAA;AAAE,8HAAA,6BAA6B,OAAA;AACrD,8FAA6F;AAApF,oHAAA,gBAAgB,OAAA;AACzB,sFAAmI;AAAxG,4GAAA,YAAY,OAAA;AAAE,0HAAA,0BAA0B,OAAA;AACnE,oGAA2G;AAAlG,kIAAA,2BAA2B,OAAA;AAEpC,4EAA0G;AAAjG,iIAAA,qBAAqB,OAAA;AAAE,yHAAA,aAAa,OAAA","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\nexport {\n PresentationGenericInfoNode,\n PresentationHierarchyNode,\n PresentationInfoNode,\n PresentationResultSetTooLargeInfoNode,\n PresentationTreeNode,\n isPresentationHierarchyNode,\n} from \"./presentation-hierarchies-react/TreeNode\";\nexport { UnifiedSelectionProvider } from \"./presentation-hierarchies-react/UnifiedSelectionContext\";\nexport { useSelectionHandler } from \"./presentation-hierarchies-react/UseSelectionHandler\";\nexport { HierarchyLevelDetails, useTree, useUnifiedSelectionTree } from \"./presentation-hierarchies-react/UseTree\";\nexport { useIModelTree, useIModelUnifiedSelectionTree } from \"./presentation-hierarchies-react/UseIModelTree\";\nexport { TreeNodeRenderer } from \"./presentation-hierarchies-react/itwinui/TreeNodeRenderer\";\nexport { RenderedTreeNode, TreeRenderer, createRenderedTreeNodeData } from \"./presentation-hierarchies-react/itwinui/TreeRenderer\";\nexport { LocalizationContextProvider } from \"./presentation-hierarchies-react/itwinui/LocalizationContext\";\n\nexport { GenericInstanceFilter, HierarchyNode, HierarchyProvider } from \"@itwin/presentation-hierarchies\";\nexport { SelectionStorage } from \"@itwin/unified-selection\";\n"]}
|