@itwin/presentation-hierarchies-react 2.0.0-alpha.6 → 2.0.0-alpha.61
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 +1151 -11
- package/README.md +93 -160
- package/lib/presentation-hierarchies-react/FlatTreeNode.d.ts +49 -0
- package/lib/presentation-hierarchies-react/FlatTreeNode.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/FlatTreeNode.js +96 -0
- package/lib/presentation-hierarchies-react/FlatTreeNode.js.map +1 -0
- package/lib/presentation-hierarchies-react/LocalizationContext.d.ts +24 -0
- package/lib/presentation-hierarchies-react/LocalizationContext.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/LocalizationContext.js +40 -0
- package/lib/presentation-hierarchies-react/LocalizationContext.js.map +1 -0
- package/lib/presentation-hierarchies-react/Renderers.d.ts +92 -0
- package/lib/presentation-hierarchies-react/Renderers.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/TreeNode.d.ts +80 -0
- package/lib/presentation-hierarchies-react/TreeNode.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseIModelTree.d.ts +28 -15
- package/lib/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseIModelTree.js +183 -0
- package/lib/presentation-hierarchies-react/UseIModelTree.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts +30 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.js +57 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts +23 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.js +124 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseTree.d.ts +112 -0
- package/lib/presentation-hierarchies-react/UseTree.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseTree.js +298 -0
- package/lib/presentation-hierarchies-react/UseTree.js.map +1 -0
- package/lib/presentation-hierarchies-react/Utils.js +56 -0
- package/lib/presentation-hierarchies-react/Utils.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js +10 -0
- package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts +9 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js +12 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeActions.js +294 -0
- package/lib/presentation-hierarchies-react/internal/TreeActions.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeLoader.js +98 -0
- package/lib/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.d.ts +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.js +115 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +35 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js +141 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/Utils.js +42 -0
- package/lib/presentation-hierarchies-react/internal/Utils.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +40 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +387 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +21 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +185 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts +49 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js +88 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +38 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +77 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +29 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +91 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +31 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +155 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.css +25 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +14 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +540 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +75 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js +417 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react-extract.d.ts +17 -0
- package/lib/presentation-hierarchies-react-extract.js +16 -0
- package/lib/presentation-hierarchies-react-stratakit.d.ts +8 -0
- package/lib/presentation-hierarchies-react-stratakit.js +8 -0
- package/lib/presentation-hierarchies-react.d.ts +11 -0
- package/lib/presentation-hierarchies-react.js +8 -0
- package/lib/public/locales/en/PresentationHierarchies_1.0.json +26 -0
- package/package.json +78 -56
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts +0 -75
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.js +0 -12
- package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts +0 -15
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js +0 -22
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +0 -62
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +0 -46
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +0 -98
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +0 -132
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.js +0 -242
- package/lib/esm/presentation-hierarchies-react/UseTree.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts +0 -2
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js +0 -11
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +0 -53
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +0 -307
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +0 -44
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +0 -94
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +0 -70
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +0 -153
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +0 -28
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +0 -128
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts +0 -23
- package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js +0 -58
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.d.ts +0 -21
- package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.js +0 -30
- package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts +0 -73
- package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.js +0 -34
- package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.d.ts +0 -25
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js +0 -40
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts +0 -23
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js +0 -72
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts +0 -40
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +0 -80
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts +0 -30
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js +0 -48
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react.d.ts +0 -13
- package/lib/esm/presentation-hierarchies-react.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react.js +0 -16
- package/lib/esm/presentation-hierarchies-react.js.map +0 -1
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
/** @internal */
|
|
6
|
-
export function isTreeModelHierarchyNode(node) {
|
|
7
|
-
return "nodeData" in node && node.nodeData !== undefined;
|
|
8
|
-
}
|
|
9
|
-
/** @internal */
|
|
10
|
-
export function isTreeModelInfoNode(node) {
|
|
11
|
-
return "type" in node && node.type !== undefined;
|
|
12
|
-
}
|
|
13
|
-
/** @internal */
|
|
14
|
-
export var TreeModel;
|
|
15
|
-
(function (TreeModel) {
|
|
16
|
-
function expandNode(model, nodeId, isExpanded) {
|
|
17
|
-
const node = model.idToNode.get(nodeId);
|
|
18
|
-
if (!node || !isTreeModelHierarchyNode(node)) {
|
|
19
|
-
return "none";
|
|
20
|
-
}
|
|
21
|
-
node.isExpanded = isExpanded;
|
|
22
|
-
if (!isExpanded || !node.children) {
|
|
23
|
-
return "none";
|
|
24
|
-
}
|
|
25
|
-
const children = model.parentChildMap.get(node.id);
|
|
26
|
-
if (!children) {
|
|
27
|
-
node.isLoading = true;
|
|
28
|
-
return "loadChildren";
|
|
29
|
-
}
|
|
30
|
-
if (children.length !== 1) {
|
|
31
|
-
return "none";
|
|
32
|
-
}
|
|
33
|
-
const firstChild = TreeModel.getNode(model, children[0]);
|
|
34
|
-
if (!firstChild || !isTreeModelInfoNode(firstChild) || firstChild.type !== "Unknown") {
|
|
35
|
-
return "none";
|
|
36
|
-
}
|
|
37
|
-
// remove subtree if there is only one `Unknown` info node in order to attempt reloading children
|
|
38
|
-
TreeModel.removeSubTree(model, nodeId);
|
|
39
|
-
node.isLoading = true;
|
|
40
|
-
return "reloadChildren";
|
|
41
|
-
}
|
|
42
|
-
TreeModel.expandNode = expandNode;
|
|
43
|
-
/** @internal */
|
|
44
|
-
function addHierarchyPart(model, rootId, hierarchyPart) {
|
|
45
|
-
removeSubTree(model, rootId);
|
|
46
|
-
for (const [parentId, children] of hierarchyPart.parentChildMap) {
|
|
47
|
-
model.parentChildMap.set(parentId, children);
|
|
48
|
-
}
|
|
49
|
-
for (const [nodeId, node] of hierarchyPart.idToNode) {
|
|
50
|
-
model.idToNode.set(nodeId, node);
|
|
51
|
-
}
|
|
52
|
-
const parentNode = rootId !== undefined ? model.idToNode.get(rootId) : model.rootNode;
|
|
53
|
-
/* c8 ignore next 3*/
|
|
54
|
-
if (!parentNode || isTreeModelInfoNode(parentNode)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
parentNode.isLoading = false;
|
|
58
|
-
}
|
|
59
|
-
TreeModel.addHierarchyPart = addHierarchyPart;
|
|
60
|
-
function removeSubTree(model, parentId) {
|
|
61
|
-
const currentChildren = model.parentChildMap.get(parentId);
|
|
62
|
-
if (!currentChildren) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
model.parentChildMap.delete(parentId);
|
|
66
|
-
for (const childId of currentChildren) {
|
|
67
|
-
const childNode = model.idToNode.get(childId);
|
|
68
|
-
if (childNode && isTreeModelHierarchyNode(childNode)) {
|
|
69
|
-
removeSubTree(model, childNode.id);
|
|
70
|
-
}
|
|
71
|
-
model.idToNode.delete(childId);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
TreeModel.removeSubTree = removeSubTree;
|
|
75
|
-
function setHierarchyLimit(model, nodeId, limit) {
|
|
76
|
-
return updateForReload(model, nodeId, (node) => {
|
|
77
|
-
node.hierarchyLimit = limit;
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
TreeModel.setHierarchyLimit = setHierarchyLimit;
|
|
81
|
-
function setInstanceFilter(model, nodeId, filter) {
|
|
82
|
-
return updateForReload(model, nodeId, (node) => {
|
|
83
|
-
if (filter && isTreeModelHierarchyNode(node)) {
|
|
84
|
-
node.isExpanded = true;
|
|
85
|
-
}
|
|
86
|
-
node.instanceFilter = filter;
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
TreeModel.setInstanceFilter = setInstanceFilter;
|
|
90
|
-
function selectNodes(model, nodeIds, changeType) {
|
|
91
|
-
if (changeType === "replace") {
|
|
92
|
-
for (const [nodeId, node] of model.idToNode) {
|
|
93
|
-
if (!isTreeModelHierarchyNode(node)) {
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
node.isSelected = !!nodeIds.find((id) => id === nodeId);
|
|
97
|
-
}
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
for (const nodeId of nodeIds) {
|
|
101
|
-
const modelNode = model.idToNode.get(nodeId);
|
|
102
|
-
if (!modelNode || !isTreeModelHierarchyNode(modelNode)) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
modelNode.isSelected = changeType === "add";
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
TreeModel.selectNodes = selectNodes;
|
|
109
|
-
function isNodeSelected(model, nodeId) {
|
|
110
|
-
const currentNode = model.idToNode.get(nodeId);
|
|
111
|
-
return !!currentNode && isTreeModelHierarchyNode(currentNode) && !!currentNode.isSelected;
|
|
112
|
-
}
|
|
113
|
-
TreeModel.isNodeSelected = isNodeSelected;
|
|
114
|
-
function getNode(model, nodeId) {
|
|
115
|
-
if (!nodeId) {
|
|
116
|
-
return model.rootNode;
|
|
117
|
-
}
|
|
118
|
-
return model.idToNode.get(nodeId);
|
|
119
|
-
}
|
|
120
|
-
TreeModel.getNode = getNode;
|
|
121
|
-
function setIsLoading(model, nodeId, isLoading) {
|
|
122
|
-
if (nodeId === undefined) {
|
|
123
|
-
model.rootNode.isLoading = isLoading;
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const modelNode = model.idToNode.get(nodeId);
|
|
127
|
-
/* c8 ignore next 3*/
|
|
128
|
-
if (!modelNode || !isTreeModelHierarchyNode(modelNode)) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
modelNode.isLoading = isLoading;
|
|
132
|
-
}
|
|
133
|
-
TreeModel.setIsLoading = setIsLoading;
|
|
134
|
-
})(TreeModel || (TreeModel = {}));
|
|
135
|
-
function updateForReload(model, nodeId, update) {
|
|
136
|
-
TreeModel.removeSubTree(model, nodeId);
|
|
137
|
-
if (nodeId === undefined) {
|
|
138
|
-
update(model.rootNode);
|
|
139
|
-
model.rootNode.isLoading = true;
|
|
140
|
-
return true;
|
|
141
|
-
}
|
|
142
|
-
const modelNode = model.idToNode.get(nodeId);
|
|
143
|
-
if (!modelNode || !isTreeModelHierarchyNode(modelNode)) {
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
update(modelNode);
|
|
147
|
-
if (modelNode.isExpanded) {
|
|
148
|
-
modelNode.isLoading = true;
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
//# sourceMappingURL=TreeModel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TreeModel.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/TreeModel.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAwDhG,gBAAgB;AAChB,MAAM,UAAU,wBAAwB,CAAC,IAAoE;IAC3G,OAAO,UAAU,IAAI,IAAI,IAAI,IAAI,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AC7C,qBAAqB;QACrB,IAAI,CAAC,SAAS,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE,CAAC;YACvD,OAAO;QACT,CAAC;QACD,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC;IAClC,CAAC;IAXe,sBAAY,eAW3B,CAAA;AACH,CAAC,EA/HgB,SAAS,KAAT,SAAS,QA+HzB;AAED,SAAS,eAAe,CAAC,KAAgB,EAAE,MAA0B,EAAE,MAAkE;IACvI,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACvB,KAAK,CAAC,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7C,IAAI,CAAC,SAAS,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE,CAAC;QACvD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,CAAC;IAClB,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;QACzB,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,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 { GenericInstanceFilter, HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { SelectionChangeType } from \"../UseSelectionHandler.js\";\n\n/** @internal */\nexport interface TreeModelRootNode {\n id: undefined;\n nodeData: undefined;\n hierarchyLimit?: number | \"unbounded\";\n instanceFilter?: GenericInstanceFilter;\n isLoading?: boolean;\n}\n\n/** @internal */\nexport interface TreeModelHierarchyNode {\n id: string;\n nodeData: HierarchyNode;\n label: string;\n children: boolean;\n isLoading?: boolean;\n isExpanded?: boolean;\n isSelected?: boolean;\n hierarchyLimit?: number | \"unbounded\";\n instanceFilter?: GenericInstanceFilter;\n}\n\n/** @internal */\nexport interface TreeModelGenericInfoNode {\n id: string;\n parentId: string | undefined;\n type: \"Unknown\";\n message: string;\n}\n\n/** @internal */\nexport interface TreeModelNoFilterMatchesInfoNode {\n id: string;\n parentId: string | undefined;\n type: \"NoFilterMatches\";\n}\n\n/** @internal */\nexport interface TreeModelResultSetTooLargeInfoNode {\n id: string;\n parentId: string | undefined;\n type: \"ResultSetTooLarge\";\n resultSetSizeLimit: number;\n}\n\n/** @internal */\nexport type TreeModelInfoNode = TreeModelGenericInfoNode | TreeModelResultSetTooLargeInfoNode | TreeModelNoFilterMatchesInfoNode;\n\n/** @internal */\nexport type TreeModelNode = TreeModelHierarchyNode | TreeModelInfoNode;\n\n/** @internal */\nexport function isTreeModelHierarchyNode(node: TreeModelHierarchyNode | TreeModelInfoNode | TreeModelRootNode): node is TreeModelHierarchyNode {\n return \"nodeData\" in node && node.nodeData !== undefined;\n}\n\n/** @internal */\nexport function isTreeModelInfoNode(node: TreeModelHierarchyNode | TreeModelInfoNode | TreeModelRootNode): node is TreeModelInfoNode {\n return \"type\" in node && node.type !== undefined;\n}\n\n/** @internal */\nexport interface TreeModel {\n parentChildMap: Map<string | undefined, string[]>;\n idToNode: Map<string, TreeModelNode>;\n rootNode: TreeModelRootNode;\n}\n\n/** @internal */\nexport namespace TreeModel {\n export function expandNode(model: TreeModel, nodeId: string, isExpanded: boolean): \"none\" | \"loadChildren\" | \"reloadChildren\" {\n const node = model.idToNode.get(nodeId);\n if (!node || !isTreeModelHierarchyNode(node)) {\n return \"none\";\n }\n\n node.isExpanded = isExpanded;\n if (!isExpanded || !node.children) {\n return \"none\";\n }\n\n const children = model.parentChildMap.get(node.id);\n if (!children) {\n node.isLoading = true;\n return \"loadChildren\";\n }\n\n if (children.length !== 1) {\n return \"none\";\n }\n\n const firstChild = TreeModel.getNode(model, children[0]);\n if (!firstChild || !isTreeModelInfoNode(firstChild) || firstChild.type !== \"Unknown\") {\n return \"none\";\n }\n\n // remove subtree if there is only one `Unknown` info node in order to attempt reloading children\n TreeModel.removeSubTree(model, nodeId);\n node.isLoading = true;\n return \"reloadChildren\";\n }\n\n /** @internal */\n export function addHierarchyPart(model: TreeModel, rootId: string | undefined, hierarchyPart: TreeModel): void {\n removeSubTree(model, rootId);\n\n for (const [parentId, children] of hierarchyPart.parentChildMap) {\n model.parentChildMap.set(parentId, children);\n }\n\n for (const [nodeId, node] of hierarchyPart.idToNode) {\n model.idToNode.set(nodeId, node);\n }\n\n const parentNode = rootId !== undefined ? model.idToNode.get(rootId) : model.rootNode;\n /* c8 ignore next 3*/\n if (!parentNode || isTreeModelInfoNode(parentNode)) {\n return;\n }\n parentNode.isLoading = false;\n }\n\n export function removeSubTree(model: TreeModel, parentId: string | undefined): void {\n const currentChildren = model.parentChildMap.get(parentId);\n if (!currentChildren) {\n return;\n }\n model.parentChildMap.delete(parentId);\n\n for (const childId of currentChildren) {\n const childNode = model.idToNode.get(childId);\n if (childNode && isTreeModelHierarchyNode(childNode)) {\n removeSubTree(model, childNode.id);\n }\n model.idToNode.delete(childId);\n }\n }\n\n export function setHierarchyLimit(model: TreeModel, nodeId: string | undefined, limit?: number | \"unbounded\"): boolean {\n return updateForReload(model, nodeId, (node) => {\n node.hierarchyLimit = limit;\n });\n }\n\n export function setInstanceFilter(model: TreeModel, nodeId: string | undefined, filter?: GenericInstanceFilter): boolean {\n return updateForReload(model, nodeId, (node) => {\n if (filter && isTreeModelHierarchyNode(node)) {\n node.isExpanded = true;\n }\n node.instanceFilter = filter;\n });\n }\n\n export function selectNodes(model: TreeModel, nodeIds: Array<string>, changeType: SelectionChangeType) {\n if (changeType === \"replace\") {\n for (const [nodeId, node] of model.idToNode) {\n if (!isTreeModelHierarchyNode(node)) {\n continue;\n }\n node.isSelected = !!nodeIds.find((id) => id === nodeId);\n }\n return;\n }\n for (const nodeId of nodeIds) {\n const modelNode = model.idToNode.get(nodeId);\n if (!modelNode || !isTreeModelHierarchyNode(modelNode)) {\n return;\n }\n modelNode.isSelected = changeType === \"add\";\n }\n }\n\n export function isNodeSelected(model: TreeModel, nodeId: string): boolean {\n const currentNode = model.idToNode.get(nodeId);\n return !!currentNode && isTreeModelHierarchyNode(currentNode) && !!currentNode.isSelected;\n }\n\n export function getNode(model: TreeModel, nodeId: string | undefined): TreeModelNode | TreeModelRootNode | undefined {\n if (!nodeId) {\n return model.rootNode;\n }\n return model.idToNode.get(nodeId);\n }\n\n export function setIsLoading(model: TreeModel, nodeId: string | undefined, isLoading: boolean) {\n if (nodeId === undefined) {\n model.rootNode.isLoading = isLoading;\n return;\n }\n const modelNode = model.idToNode.get(nodeId);\n /* c8 ignore next 3*/\n if (!modelNode || !isTreeModelHierarchyNode(modelNode)) {\n return;\n }\n modelNode.isLoading = isLoading;\n }\n}\n\nfunction updateForReload(model: TreeModel, nodeId: string | undefined, update: (node: TreeModelHierarchyNode | TreeModelRootNode) => void) {\n TreeModel.removeSubTree(model, nodeId);\n if (nodeId === undefined) {\n update(model.rootNode);\n model.rootNode.isLoading = true;\n return true;\n }\n\n const modelNode = model.idToNode.get(nodeId);\n if (!modelNode || !isTreeModelHierarchyNode(modelNode)) {\n return false;\n }\n\n update(modelNode);\n if (modelNode.isExpanded) {\n modelNode.isLoading = true;\n return true;\n }\n return false;\n}\n"]}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { SelectionStorage } from "@itwin/unified-selection";
|
|
2
|
-
import { SelectionChangeType } from "../UseSelectionHandler.js";
|
|
3
|
-
import { TreeModelNode, TreeModelRootNode } from "./TreeModel.js";
|
|
4
|
-
/** @internal */
|
|
5
|
-
export interface TreeSelectionOptions {
|
|
6
|
-
isNodeSelected: (nodeId: string) => boolean;
|
|
7
|
-
selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => void;
|
|
8
|
-
}
|
|
9
|
-
/** @public */
|
|
10
|
-
export interface UseUnifiedTreeSelectionProps {
|
|
11
|
-
/**
|
|
12
|
-
* Identifier to distinguish this source of changes to the unified selection from another ones in the application.
|
|
13
|
-
*/
|
|
14
|
-
sourceName: string;
|
|
15
|
-
/**
|
|
16
|
-
* Unified selection storage to use for listening, getting and changing active selection.
|
|
17
|
-
*
|
|
18
|
-
* When not specified, the deprecated unified selection React context is used to access the
|
|
19
|
-
* selection storage (see `UnifiedSelectionProvider`). This prop will be made required in the
|
|
20
|
-
* next major release, where the deprecated context will also be removed.
|
|
21
|
-
*/
|
|
22
|
-
selectionStorage?: SelectionStorage;
|
|
23
|
-
}
|
|
24
|
-
/** @internal */
|
|
25
|
-
export declare function useUnifiedTreeSelection({ sourceName, selectionStorage, getTreeModelNode, }: UseUnifiedTreeSelectionProps & {
|
|
26
|
-
getTreeModelNode: (nodeId: string) => TreeModelNode | TreeModelRootNode | undefined;
|
|
27
|
-
}): TreeSelectionOptions;
|
|
28
|
-
//# sourceMappingURL=UseUnifiedSelection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UseUnifiedSelection.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/UseUnifiedSelection.ts"],"names":[],"mappings":"AASA,OAAO,EAA2B,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAErF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAoD,aAAa,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEpH,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,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED,gBAAgB;AAChB,wBAAgB,uBAAuB,CAAC,EACtC,UAAU,EACV,gBAAgB,EAChB,gBAAgB,GACjB,EAAE,4BAA4B,GAAG;IAAE,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,aAAa,GAAG,iBAAiB,GAAG,SAAS,CAAA;CAAE,GAAG,oBAAoB,CA6B/I"}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { useEffect, useState } from "react";
|
|
6
|
-
import { assert } from "@itwin/core-bentley";
|
|
7
|
-
import { HierarchyNode } from "@itwin/presentation-hierarchies";
|
|
8
|
-
import { Selectables } from "@itwin/unified-selection";
|
|
9
|
-
import { useUnifiedSelectionStorage } from "../UnifiedSelectionContext.js";
|
|
10
|
-
import { isTreeModelHierarchyNode } from "./TreeModel.js";
|
|
11
|
-
/** @internal */
|
|
12
|
-
export function useUnifiedTreeSelection({ sourceName, selectionStorage, getTreeModelNode, }) {
|
|
13
|
-
const [options, setOptions] = useState(() => ({
|
|
14
|
-
isNodeSelected: /* c8 ignore next */ () => false,
|
|
15
|
-
selectNodes: /* c8 ignore next */ () => { },
|
|
16
|
-
}));
|
|
17
|
-
const deprecatedSelectionStorage = useUnifiedSelectionStorage();
|
|
18
|
-
selectionStorage ??= deprecatedSelectionStorage;
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
if (!selectionStorage) {
|
|
21
|
-
// TODO: make selectionStorage prop required
|
|
22
|
-
setOptions({
|
|
23
|
-
isNodeSelected: () => false,
|
|
24
|
-
selectNodes: () => { },
|
|
25
|
-
});
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
setOptions(createOptions(sourceName, selectionStorage, getTreeModelNode));
|
|
29
|
-
return selectionStorage.selectionChangeEvent.addListener((args) => {
|
|
30
|
-
if (args.level > 0) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
setOptions(createOptions(sourceName, selectionStorage, getTreeModelNode));
|
|
34
|
-
});
|
|
35
|
-
}, [selectionStorage, getTreeModelNode, sourceName]);
|
|
36
|
-
return options;
|
|
37
|
-
}
|
|
38
|
-
function createOptions(source, storage, getNode) {
|
|
39
|
-
return {
|
|
40
|
-
isNodeSelected: (nodeId) => {
|
|
41
|
-
const node = getNode(nodeId);
|
|
42
|
-
if (!node || !isTreeModelHierarchyNode(node)) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
return Object.entries(groupNodeSelectablesByIModelKey(node)).some(([imodelKey, nodeSelectables]) => {
|
|
46
|
-
const storageSelectables = storage.getSelection({ imodelKey, level: 0 });
|
|
47
|
-
return Selectables.hasAny(storageSelectables, nodeSelectables);
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
|
-
selectNodes: (nodeIds, changeType) => {
|
|
51
|
-
const imodelSelectables = {};
|
|
52
|
-
for (const nodeId of nodeIds) {
|
|
53
|
-
const node = getNode(nodeId);
|
|
54
|
-
if (!node || !isTreeModelHierarchyNode(node)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
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
|
-
});
|
|
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
|
-
});
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
function groupNodeSelectablesByIModelKey(modelNode) {
|
|
84
|
-
const hierarchyNode = modelNode.nodeData;
|
|
85
|
-
if (HierarchyNode.isInstancesNode(hierarchyNode)) {
|
|
86
|
-
return groupIModelInstanceKeys(hierarchyNode.key.instanceKeys);
|
|
87
|
-
}
|
|
88
|
-
if (HierarchyNode.isGroupingNode(hierarchyNode)) {
|
|
89
|
-
return Object.entries(groupIModelInstanceKeys(hierarchyNode.groupedInstanceKeys)).reduce((imodelSelectables, [imodelKey, instanceKeys]) => ({
|
|
90
|
-
...imodelSelectables,
|
|
91
|
-
[imodelKey]: [
|
|
92
|
-
{
|
|
93
|
-
identifier: modelNode.id,
|
|
94
|
-
data: hierarchyNode,
|
|
95
|
-
async *loadInstanceKeys() {
|
|
96
|
-
for (const key of instanceKeys) {
|
|
97
|
-
yield key;
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
}), {});
|
|
103
|
-
}
|
|
104
|
-
assert(HierarchyNode.isGeneric(hierarchyNode));
|
|
105
|
-
return {
|
|
106
|
-
// note: generic nodes aren't associated with an imodel
|
|
107
|
-
[""]: [
|
|
108
|
-
{
|
|
109
|
-
identifier: modelNode.id,
|
|
110
|
-
data: hierarchyNode,
|
|
111
|
-
async *loadInstanceKeys() { },
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
function groupIModelInstanceKeys(instanceKeys) {
|
|
117
|
-
return instanceKeys.reduce((imodelSelectables, key) => {
|
|
118
|
-
const imodelKey = key.imodelKey ?? "";
|
|
119
|
-
let selectablesList = imodelSelectables[imodelKey];
|
|
120
|
-
if (!selectablesList) {
|
|
121
|
-
selectablesList = [];
|
|
122
|
-
imodelSelectables[imodelKey] = selectablesList;
|
|
123
|
-
}
|
|
124
|
-
selectablesList.push(key);
|
|
125
|
-
return imodelSelectables;
|
|
126
|
-
}, {});
|
|
127
|
-
}
|
|
128
|
-
//# sourceMappingURL=UseUnifiedSelection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UseUnifiedSelection.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/UseUnifiedSelection.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAoB,MAAM,iCAAiC,CAAC;AAElF,OAAO,EAAc,WAAW,EAAoB,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,EAAE,wBAAwB,EAA4D,MAAM,gBAAgB,CAAC;AAyBpH,gBAAgB;AAChB,MAAM,UAAU,uBAAuB,CAAC,EACtC,UAAU,EACV,gBAAgB,EAChB,gBAAgB,GACuG;IACvH,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAuB,GAAG,EAAE,CAAC,CAAC;QAClE,cAAc,EAAE,oBAAoB,CAAC,GAAG,EAAE,CAAC,KAAK;QAChD,WAAW,EAAE,oBAAoB,CAAC,GAAG,EAAE,GAAE,CAAC;KAC3C,CAAC,CAAC,CAAC;IAEJ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B,KAAI,CAAC;aAC7B;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,YAA8C;IAC7E,OAAO,YAAY,CAAC,MAAM,CACxB,CAAC,iBAAiB,EAAE,GAAG,EAAE,EAAE;QACzB,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC;QACtC,IAAI,eAAe,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACnD,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,eAAe,GAAG,EAAE,CAAC;YACrB,iBAAiB,CAAC,SAAS,CAAC,GAAG,eAAe,CAAC;QACjD,CAAC;QACD,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,OAAO,iBAAiB,CAAC;IAC3B,CAAC,EACD,EAA4C,CAC7C,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 { assert } from \"@itwin/core-bentley\";\nimport { HierarchyNode, InstancesNodeKey } from \"@itwin/presentation-hierarchies\";\nimport { InstanceKey } from \"@itwin/presentation-shared\";\nimport { Selectable, Selectables, SelectionStorage } from \"@itwin/unified-selection\";\nimport { useUnifiedSelectionStorage } from \"../UnifiedSelectionContext.js\";\nimport { SelectionChangeType } from \"../UseSelectionHandler.js\";\nimport { isTreeModelHierarchyNode, TreeModelHierarchyNode, TreeModelNode, TreeModelRootNode } from \"./TreeModel.js\";\n\n/** @internal */\nexport interface TreeSelectionOptions {\n isNodeSelected: (nodeId: string) => boolean;\n selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => void;\n}\n\n/** @public */\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 * Unified selection storage to use for listening, getting and changing active selection.\n *\n * When not specified, the deprecated unified selection React context is used to access the\n * selection storage (see `UnifiedSelectionProvider`). This prop will be made required in the\n * next major release, where the deprecated context will also be removed.\n */\n selectionStorage?: SelectionStorage;\n}\n\n/** @internal */\nexport function useUnifiedTreeSelection({\n sourceName,\n selectionStorage,\n getTreeModelNode,\n}: UseUnifiedTreeSelectionProps & { getTreeModelNode: (nodeId: string) => TreeModelNode | TreeModelRootNode | undefined }): TreeSelectionOptions {\n const [options, setOptions] = useState<TreeSelectionOptions>(() => ({\n isNodeSelected: /* c8 ignore next */ () => false,\n selectNodes: /* c8 ignore next */ () => {},\n }));\n\n const deprecatedSelectionStorage = useUnifiedSelectionStorage();\n selectionStorage ??= deprecatedSelectionStorage;\n\n useEffect(() => {\n if (!selectionStorage) {\n // TODO: make selectionStorage prop required\n setOptions({\n isNodeSelected: () => false,\n selectNodes: () => {},\n });\n return;\n }\n\n setOptions(createOptions(sourceName, selectionStorage, getTreeModelNode));\n return selectionStorage.selectionChangeEvent.addListener((args) => {\n if (args.level > 0) {\n return;\n }\n setOptions(createOptions(sourceName, selectionStorage, getTreeModelNode));\n });\n }, [selectionStorage, getTreeModelNode, 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.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 assert(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\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"]}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import "./DisposePolyfill.js";
|
|
2
|
-
import { HierarchyNode } from "@itwin/presentation-hierarchies";
|
|
3
|
-
/** @internal */
|
|
4
|
-
export declare function createNodeId(node: Pick<HierarchyNode, "key" | "parentKeys">): string;
|
|
5
|
-
/** @internal */
|
|
6
|
-
export declare function sameNodes(lhs: HierarchyNode, rhs: HierarchyNode): boolean;
|
|
7
|
-
/** @internal */
|
|
8
|
-
export declare const MAX_LIMIT_OVERRIDE = 10000;
|
|
9
|
-
/**
|
|
10
|
-
* A helper that disposes the given object, if it's disposable.
|
|
11
|
-
*
|
|
12
|
-
* The first option is to dispose using the deprecated `dispose` method if it exists on the object.
|
|
13
|
-
* If not, we use the new `Symbol.dispose` method. If that doesn't exist either, the object is
|
|
14
|
-
* considered as non-disposable and nothing is done with it.
|
|
15
|
-
*
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
export declare function safeDispose(disposable: {} | {
|
|
19
|
-
[Symbol.dispose]: () => void;
|
|
20
|
-
} | {
|
|
21
|
-
dispose: () => void;
|
|
22
|
-
}): void;
|
|
23
|
-
//# sourceMappingURL=Utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/Utils.ts"],"names":[],"mappings":"AAKA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAoB,MAAM,iCAAiC,CAAC;AAElF,gBAAgB;AAChB,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,YAAY,CAAC,UAE3E;AAiBD,gBAAgB;AAChB,wBAAgB,SAAS,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,GAAG,OAAO,CAezE;AAED,gBAAgB;AAChB,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,EAAE,GAAG;IAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,QAMtG"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import "./DisposePolyfill.js";
|
|
6
|
-
import { HierarchyNodeKey } from "@itwin/presentation-hierarchies";
|
|
7
|
-
/** @internal */
|
|
8
|
-
export function createNodeId(node) {
|
|
9
|
-
return [...node.parentKeys.map(serializeNodeKey), serializeNodeKey(node.key)].join(";");
|
|
10
|
-
}
|
|
11
|
-
function serializeNodeKey(key) {
|
|
12
|
-
return convertObjectValuesToString(key);
|
|
13
|
-
}
|
|
14
|
-
function convertObjectValuesToString(obj) {
|
|
15
|
-
return Object.entries(obj)
|
|
16
|
-
.map(([, value]) => {
|
|
17
|
-
if (typeof value === "object") {
|
|
18
|
-
return convertObjectValuesToString(value);
|
|
19
|
-
}
|
|
20
|
-
return String(value);
|
|
21
|
-
})
|
|
22
|
-
.join(",");
|
|
23
|
-
}
|
|
24
|
-
/** @internal */
|
|
25
|
-
export function sameNodes(lhs, rhs) {
|
|
26
|
-
if (HierarchyNodeKey.compare(lhs.key, rhs.key) !== 0) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
if (lhs.parentKeys.length !== rhs.parentKeys.length) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
for (let i = lhs.parentKeys.length - 1; i >= 0; --i) {
|
|
33
|
-
if (HierarchyNodeKey.compare(lhs.parentKeys[i], rhs.parentKeys[i]) !== 0) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
/** @internal */
|
|
40
|
-
export const MAX_LIMIT_OVERRIDE = 10000;
|
|
41
|
-
/**
|
|
42
|
-
* A helper that disposes the given object, if it's disposable.
|
|
43
|
-
*
|
|
44
|
-
* The first option is to dispose using the deprecated `dispose` method if it exists on the object.
|
|
45
|
-
* If not, we use the new `Symbol.dispose` method. If that doesn't exist either, the object is
|
|
46
|
-
* considered as non-disposable and nothing is done with it.
|
|
47
|
-
*
|
|
48
|
-
* @internal
|
|
49
|
-
*/
|
|
50
|
-
export function safeDispose(disposable) {
|
|
51
|
-
if ("dispose" in disposable) {
|
|
52
|
-
disposable.dispose();
|
|
53
|
-
}
|
|
54
|
-
else if (Symbol.dispose in disposable) {
|
|
55
|
-
disposable[Symbol.dispose]();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=Utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/Utils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,sBAAsB,CAAC;AAC9B,OAAO,EAAiB,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAElF,gBAAgB;AAChB,MAAM,UAAU,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,2BAA2B,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,2BAA2B,CAAC,GAAW;IAC9C,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG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QACxC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAC/B,CAAC;AACH,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 \"./DisposePolyfill.js\";\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\n/**\n * A helper that disposes the given object, if it's disposable.\n *\n * The first option is to dispose using the deprecated `dispose` method if it exists on the object.\n * If not, we use the new `Symbol.dispose` method. If that doesn't exist either, the object is\n * considered as non-disposable and nothing is done with it.\n *\n * @internal\n */\nexport function safeDispose(disposable: {} | { [Symbol.dispose]: () => void } | { dispose: () => void }) {\n if (\"dispose\" in disposable) {\n disposable.dispose();\n } else if (Symbol.dispose in disposable) {\n disposable[Symbol.dispose]();\n }\n}\n"]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { PresentationTreeNode } from "../TreeNode.js";
|
|
2
|
-
/** @alpha */
|
|
3
|
-
interface PlaceholderNode {
|
|
4
|
-
id: string;
|
|
5
|
-
level: number;
|
|
6
|
-
placeholder: true;
|
|
7
|
-
}
|
|
8
|
-
/** @alpha */
|
|
9
|
-
export type FlatNode<TNode extends PresentationTreeNode = PresentationTreeNode> = {
|
|
10
|
-
level: number;
|
|
11
|
-
levelSize: number;
|
|
12
|
-
posInLevel: number;
|
|
13
|
-
} & TNode;
|
|
14
|
-
/** @alpha */
|
|
15
|
-
export type FlatTreeNode<TNode extends PresentationTreeNode = PresentationTreeNode> = FlatNode<TNode> | PlaceholderNode;
|
|
16
|
-
/** @alpha */
|
|
17
|
-
export declare function isPlaceholderNode(node: FlatTreeNode): node is PlaceholderNode;
|
|
18
|
-
/** @alpha */
|
|
19
|
-
export declare function flattenNodes(rootNodes: PresentationTreeNode[]): FlatTreeNode<PresentationTreeNode>[];
|
|
20
|
-
export {};
|
|
21
|
-
//# sourceMappingURL=FlatTreeNode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FlatTreeNode.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/FlatTreeNode.ts"],"names":[],"mappings":"AAKA,OAAO,EAA+B,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEnF,aAAa;AACb,UAAU,eAAe;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,IAAI,CAAC;CACnB;AAED,aAAa;AACb,MAAM,MAAM,QAAQ,CAAC,KAAK,SAAS,oBAAoB,GAAG,oBAAoB,IAAI;IAChF,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,KAAK,CAAC;AAEV,aAAa;AACb,MAAM,MAAM,YAAY,CAAC,KAAK,SAAS,oBAAoB,GAAG,oBAAoB,IAAI,QAAQ,CAAC,KAAK,CAAC,GAAG,eAAe,CAAC;AAExH,aAAa;AACb,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,IAAI,eAAe,CAE7E;AAED,aAAa;AACb,wBAAgB,YAAY,CAAC,SAAS,EAAE,oBAAoB,EAAE,wCAE7D"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { isPresentationHierarchyNode } from "../TreeNode.js";
|
|
6
|
-
/** @alpha */
|
|
7
|
-
export function isPlaceholderNode(node) {
|
|
8
|
-
return "placeholder" in node;
|
|
9
|
-
}
|
|
10
|
-
/** @alpha */
|
|
11
|
-
export function flattenNodes(rootNodes) {
|
|
12
|
-
return getFlatNodes(rootNodes, 0);
|
|
13
|
-
}
|
|
14
|
-
function getFlatNodes(nodes, level) {
|
|
15
|
-
const flatNodes = [];
|
|
16
|
-
nodes.forEach((node, index) => {
|
|
17
|
-
flatNodes.push({ ...node, level, levelSize: nodes.length, posInLevel: index + 1 });
|
|
18
|
-
if (!isPresentationHierarchyNode(node) || !node.isExpanded) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (node.children !== true) {
|
|
22
|
-
const childNodes = getFlatNodes(node.children, level + 1);
|
|
23
|
-
flatNodes.push(...childNodes);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
flatNodes.push({ id: `${node.id}-children-placeholder`, level: level + 1, placeholder: true });
|
|
27
|
-
});
|
|
28
|
-
return flatNodes;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=FlatTreeNode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FlatTreeNode.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/FlatTreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,2BAA2B,EAAwB,MAAM,gBAAgB,CAAC;AAmBnF,aAAa;AACb,MAAM,UAAU,iBAAiB,CAAC,IAAkB;IAClD,OAAO,aAAa,IAAI,IAAI,CAAC;AAC/B,CAAC;AAED,aAAa;AACb,MAAM,UAAU,YAAY,CAAC,SAAiC;IAC5D,OAAO,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,YAAY,CAAC,KAA6B,EAAE,KAAa;IAChE,MAAM,SAAS,GAAmB,EAAE,CAAC;IACrC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC5B,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC;QACnF,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YAC3D,OAAO;QACT,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC3B,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;YAC1D,SAAS,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,uBAAuB,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,WAAW,EAAE,IAAI,EAA4B,CAAC,CAAC;IAC3H,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,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 { isPresentationHierarchyNode, PresentationTreeNode } from \"../TreeNode.js\";\n\n/** @alpha */\ninterface PlaceholderNode {\n id: string;\n level: number;\n placeholder: true;\n}\n\n/** @alpha */\nexport type FlatNode<TNode extends PresentationTreeNode = PresentationTreeNode> = {\n level: number;\n levelSize: number;\n posInLevel: number;\n} & TNode;\n\n/** @alpha */\nexport type FlatTreeNode<TNode extends PresentationTreeNode = PresentationTreeNode> = FlatNode<TNode> | PlaceholderNode;\n\n/** @alpha */\nexport function isPlaceholderNode(node: FlatTreeNode): node is PlaceholderNode {\n return \"placeholder\" in node;\n}\n\n/** @alpha */\nexport function flattenNodes(rootNodes: PresentationTreeNode[]) {\n return getFlatNodes(rootNodes, 0);\n}\n\nfunction getFlatNodes(nodes: PresentationTreeNode[], level: number) {\n const flatNodes: FlatTreeNode[] = [];\n nodes.forEach((node, index) => {\n flatNodes.push({ ...node, level, levelSize: nodes.length, posInLevel: index + 1 });\n if (!isPresentationHierarchyNode(node) || !node.isExpanded) {\n return;\n }\n if (node.children !== true) {\n const childNodes = getFlatNodes(node.children, level + 1);\n flatNodes.push(...childNodes);\n return;\n }\n\n flatNodes.push({ id: `${node.id}-children-placeholder`, level: level + 1, placeholder: true } satisfies PlaceholderNode);\n });\n return flatNodes;\n}\n"]}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { PropsWithChildren } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* Localized strings used in the components.
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export interface LocalizedStrings {
|
|
7
|
-
/**
|
|
8
|
-
* Message displayed when nodes are loading.
|
|
9
|
-
* Default value: `Loading...`.
|
|
10
|
-
*/
|
|
11
|
-
loading: string;
|
|
12
|
-
/**
|
|
13
|
-
* Title for apply hierarchy filter button.
|
|
14
|
-
* Default value: `Apply filter`.
|
|
15
|
-
*/
|
|
16
|
-
filterHierarchyLevel: string;
|
|
17
|
-
/**
|
|
18
|
-
* Title for clear hierarchy filter button.
|
|
19
|
-
* Default value: `Clear active filter`.
|
|
20
|
-
*/
|
|
21
|
-
clearHierarchyLevelFilter: string;
|
|
22
|
-
/**
|
|
23
|
-
* Message displayed when no nodes matching filter are found.
|
|
24
|
-
* Default value: `No child nodes match current filter`.
|
|
25
|
-
*/
|
|
26
|
-
noFilteredChildren: string;
|
|
27
|
-
/**
|
|
28
|
-
* Message displayed when result limit exceeds hierarchy size limit.
|
|
29
|
-
* Default value: `There are more items than allowed limit of {{limit}}.`.
|
|
30
|
-
*/
|
|
31
|
-
resultLimitExceeded: string;
|
|
32
|
-
/**
|
|
33
|
-
* Message displayed when result limit exceeds hierarchy size limit and hierarchy filtering is enabled.
|
|
34
|
-
* Default value: `Please provide <link>additional filtering</link> - there are more items than allowed limit of {{limit}}.`.
|
|
35
|
-
*/
|
|
36
|
-
resultLimitExceededWithFiltering: string;
|
|
37
|
-
/**
|
|
38
|
-
* Message displayed when hierarchy size limit can be overridden.
|
|
39
|
-
* Default value: `<link>Increase the hierarchy level size limit to {{limit}}.</link>`.
|
|
40
|
-
*/
|
|
41
|
-
increaseHierarchyLimit: string;
|
|
42
|
-
/**
|
|
43
|
-
* Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.
|
|
44
|
-
* Default value: `Or, <link>increase the hierarchy level size limit to {{limit}}.</link>`.
|
|
45
|
-
*/
|
|
46
|
-
increaseHierarchyLimitWithFiltering: string;
|
|
47
|
-
/**
|
|
48
|
-
* Label for retry action.
|
|
49
|
-
* Default value: `Retry`.
|
|
50
|
-
*/
|
|
51
|
-
retry: string;
|
|
52
|
-
}
|
|
53
|
-
/** @internal */
|
|
54
|
-
export interface LocalizationContext {
|
|
55
|
-
localizedStrings: LocalizedStrings;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Properties for `LocalizationContextProvider`.
|
|
59
|
-
* @public
|
|
60
|
-
*/
|
|
61
|
-
interface LocalizationContextProviderProps {
|
|
62
|
-
/** Localized strings used in the components. */
|
|
63
|
-
localizedStrings?: Partial<LocalizedStrings>;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Context provider for localized strings used in the components.
|
|
67
|
-
* @public
|
|
68
|
-
*/
|
|
69
|
-
export declare function LocalizationContextProvider({ localizedStrings, children }: PropsWithChildren<LocalizationContextProviderProps>): import("react/jsx-runtime").JSX.Element;
|
|
70
|
-
/** @internal */
|
|
71
|
-
export declare function useLocalizationContext(): LocalizationContext;
|
|
72
|
-
export {};
|
|
73
|
-
//# sourceMappingURL=LocalizationContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalizationContext.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/LocalizationContext.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAiB,iBAAiB,EAAmC,MAAM,OAAO,CAAC;AAE1F;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,yBAAyB,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,gCAAgC,EAAE,MAAM,CAAC;IACzC;;;OAGG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,mCAAmC,EAAE,MAAM,CAAC;IAC5C;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED,gBAAgB;AAChB,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AAgBD;;;GAGG;AACH,UAAU,gCAAgC;IACxC,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC,gCAAgC,CAAC,2CAQ9H;AAED,gBAAgB;AAChB,wBAAgB,sBAAsB,wBAErC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
import { createContext, useContext, useEffect, useState } from "react";
|
|
7
|
-
const defaultLocalizedStrings = {
|
|
8
|
-
loading: "Loading...",
|
|
9
|
-
filterHierarchyLevel: "Apply filter",
|
|
10
|
-
clearHierarchyLevelFilter: "Clear active filter",
|
|
11
|
-
noFilteredChildren: "No child nodes match current filter",
|
|
12
|
-
resultLimitExceeded: "There are more items than allowed limit of {{limit}}.",
|
|
13
|
-
resultLimitExceededWithFiltering: "Please provide <link>additional filtering</link> - there are more items than allowed limit of {{limit}}.",
|
|
14
|
-
increaseHierarchyLimit: "<link>Increase the hierarchy level size limit to {{limit}}.</link>",
|
|
15
|
-
increaseHierarchyLimitWithFiltering: "Or, <link>increase the hierarchy level size limit to {{limit}}.</link>",
|
|
16
|
-
retry: "Retry",
|
|
17
|
-
};
|
|
18
|
-
const localizationContext = createContext({ localizedStrings: defaultLocalizedStrings });
|
|
19
|
-
/**
|
|
20
|
-
* Context provider for localized strings used in the components.
|
|
21
|
-
* @public
|
|
22
|
-
*/
|
|
23
|
-
export function LocalizationContextProvider({ localizedStrings, children }) {
|
|
24
|
-
const [state, setState] = useState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
setState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });
|
|
27
|
-
}, [localizedStrings]);
|
|
28
|
-
return _jsx(localizationContext.Provider, { value: state, children: children });
|
|
29
|
-
}
|
|
30
|
-
/** @internal */
|
|
31
|
-
export function useLocalizationContext() {
|
|
32
|
-
return useContext(localizationContext);
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=LocalizationContext.js.map
|