@itwin/presentation-hierarchies-react 2.0.0-alpha.10 → 2.0.0-alpha.12
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 +30 -0
- package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.d.ts +12 -5
- package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.js +37 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts +17 -7
- package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.js +7 -5
- package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js +4 -5
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts +8 -8
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js +32 -57
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts +8 -4
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +18 -24
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts +3 -2
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js +45 -14
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js.map +1 -1
- package/package.json +27 -29
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @itwin/presentation-hierarchies-react
|
|
2
2
|
|
|
3
|
+
## 2.0.0-alpha.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#922](https://github.com/iTwin/presentation/pull/922): Fix tree displaying aditional scrollbars, when scrolling to the last element with low tree width.
|
|
8
|
+
|
|
9
|
+
## 2.0.0-alpha.11
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#916](https://github.com/iTwin/presentation/pull/916): Fix tree nodes overlapping when nodes with and without sublabel are rendered alongside.
|
|
14
|
+
- [#920](https://github.com/iTwin/presentation/pull/920): Changed error display for node errors to match new design system.
|
|
15
|
+
|
|
3
16
|
## 2.0.0-alpha.10
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -114,6 +127,23 @@
|
|
|
114
127
|
|
|
115
128
|
- [#847](https://github.com/iTwin/presentation/pull/847): Moving tree rendering components to a new design systems.
|
|
116
129
|
|
|
130
|
+
## 1.6.4
|
|
131
|
+
|
|
132
|
+
### Patch Changes
|
|
133
|
+
|
|
134
|
+
- [#909](https://github.com/iTwin/presentation/pull/909): Do not use `dev` versions of `@itwin/*` packages.
|
|
135
|
+
- Updated dependencies:
|
|
136
|
+
- @itwin/unified-selection@1.4.1
|
|
137
|
+
- @itwin/presentation-hierarchies@1.4.2
|
|
138
|
+
- @itwin/presentation-shared@1.2.1
|
|
139
|
+
|
|
140
|
+
## 1.6.3
|
|
141
|
+
|
|
142
|
+
### Patch Changes
|
|
143
|
+
|
|
144
|
+
- Updated dependencies:
|
|
145
|
+
- @itwin/unified-selection@1.4.0
|
|
146
|
+
|
|
117
147
|
## 1.6.2
|
|
118
148
|
|
|
119
149
|
### Patch Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PresentationTreeNode } from "../TreeNode.js";
|
|
1
|
+
import { PresentationHierarchyNode, PresentationInfoNode, PresentationTreeNode } from "../TreeNode.js";
|
|
2
2
|
/** @alpha */
|
|
3
3
|
interface PlaceholderNode {
|
|
4
4
|
id: string;
|
|
@@ -6,16 +6,23 @@ interface PlaceholderNode {
|
|
|
6
6
|
placeholder: true;
|
|
7
7
|
}
|
|
8
8
|
/** @alpha */
|
|
9
|
-
export type FlatNode
|
|
9
|
+
export type FlatNode = {
|
|
10
10
|
level: number;
|
|
11
11
|
levelSize: number;
|
|
12
12
|
posInLevel: number;
|
|
13
|
-
} &
|
|
13
|
+
} & PresentationHierarchyNode;
|
|
14
14
|
/** @alpha */
|
|
15
|
-
export
|
|
15
|
+
export interface ErrorNode {
|
|
16
|
+
error: PresentationInfoNode;
|
|
17
|
+
parent?: PresentationHierarchyNode;
|
|
18
|
+
expandTo: (expandNode: (nodeId: string) => void) => void;
|
|
19
|
+
}
|
|
20
|
+
/** @alpha */
|
|
21
|
+
export type FlatTreeNode = FlatNode | PlaceholderNode;
|
|
16
22
|
/** @alpha */
|
|
17
23
|
export declare function isPlaceholderNode(node: FlatTreeNode): node is PlaceholderNode;
|
|
18
24
|
/** @alpha */
|
|
19
|
-
export declare function flattenNodes(rootNodes: PresentationTreeNode[]): FlatTreeNode
|
|
25
|
+
export declare function flattenNodes(rootNodes: PresentationTreeNode[]): FlatTreeNode[];
|
|
26
|
+
export declare function getErrors(rootNodes: PresentationTreeNode[]): ErrorNode[];
|
|
20
27
|
export {};
|
|
21
28
|
//# sourceMappingURL=FlatTreeNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
{"version":3,"file":"FlatTreeNode.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/FlatTreeNode.ts"],"names":[],"mappings":"AAKA,OAAO,EAA+B,yBAAyB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEpI,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,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,yBAAyB,CAAC;AAE9B,aAAa;AACb,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,oBAAoB,CAAC;IAC5B,MAAM,CAAC,EAAE,yBAAyB,CAAC;IACnC,QAAQ,EAAE,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,KAAK,IAAI,CAAC;CAC1D;AAED,aAAa;AACb,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,eAAe,CAAC;AAEtD,aAAa;AACb,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,IAAI,eAAe,CAE7E;AAED,aAAa;AACb,wBAAgB,YAAY,CAAC,SAAS,EAAE,oBAAoB,EAAE,kBAE7D;AAuBD,wBAAgB,SAAS,CAAC,SAAS,EAAE,oBAAoB,EAAE,GAAG,SAAS,EAAE,CAUxE"}
|
|
@@ -14,8 +14,11 @@ export function flattenNodes(rootNodes) {
|
|
|
14
14
|
function getFlatNodes(nodes, level) {
|
|
15
15
|
const flatNodes = [];
|
|
16
16
|
nodes.forEach((node, index) => {
|
|
17
|
+
if (!isPresentationHierarchyNode(node)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
17
20
|
flatNodes.push({ ...node, level, levelSize: nodes.length, posInLevel: index + 1 });
|
|
18
|
-
if (!
|
|
21
|
+
if (!node.isExpanded) {
|
|
19
22
|
return;
|
|
20
23
|
}
|
|
21
24
|
if (node.children !== true) {
|
|
@@ -27,4 +30,37 @@ function getFlatNodes(nodes, level) {
|
|
|
27
30
|
});
|
|
28
31
|
return flatNodes;
|
|
29
32
|
}
|
|
33
|
+
export function getErrors(rootNodes) {
|
|
34
|
+
return rootNodes.flatMap((rootNode) => {
|
|
35
|
+
if (!isPresentationHierarchyNode(rootNode)) {
|
|
36
|
+
return [{ parent: undefined, error: rootNode, expandTo: (expandNode) => expandTo(expandNode, []) }];
|
|
37
|
+
}
|
|
38
|
+
if (rootNode.children === true) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
return getErrorNodes(rootNode, !rootNode.isExpanded ? [rootNode.id] : []);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function getErrorNodes(parent, path) {
|
|
45
|
+
const errorList = [];
|
|
46
|
+
if (parent.children === true) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
const pathToChild = [...path, ...(!parent.isExpanded ? [parent.id] : [])];
|
|
50
|
+
parent.children.forEach((node) => {
|
|
51
|
+
if (!isPresentationHierarchyNode(node)) {
|
|
52
|
+
errorList.push({ parent, error: node, expandTo: (expandNode) => expandTo(expandNode, path) });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (node.children !== true) {
|
|
56
|
+
const childErrorList = getErrorNodes(node, pathToChild);
|
|
57
|
+
errorList.push(...childErrorList);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return errorList;
|
|
62
|
+
}
|
|
63
|
+
function expandTo(expandNode, path) {
|
|
64
|
+
path.forEach((nodeId) => expandNode(nodeId));
|
|
65
|
+
}
|
|
30
66
|
//# sourceMappingURL=FlatTreeNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlatTreeNode.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/FlatTreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,2BAA2B,
|
|
1
|
+
{"version":3,"file":"FlatTreeNode.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/FlatTreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,2BAA2B,EAAyE,MAAM,gBAAgB,CAAC;AA0BpI,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,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,EAAE,CAAC;YACvC,OAAO;QACT,CAAC;QACD,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,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,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,CAA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,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC/B,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,EAAE,CAAC;YACvC,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;YAC9F,OAAO;QACT,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC3B,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YACxD,SAAS,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;YAClC,OAAO;QACT,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,UAAoC,EAAE,IAAc;IACpE,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;AAC/C,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, PresentationHierarchyNode, PresentationInfoNode, 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 = {\n level: number;\n levelSize: number;\n posInLevel: number;\n} & PresentationHierarchyNode;\n\n/** @alpha */\nexport interface ErrorNode {\n error: PresentationInfoNode;\n parent?: PresentationHierarchyNode;\n expandTo: (expandNode: (nodeId: string) => void) => void;\n}\n\n/** @alpha */\nexport type FlatTreeNode = FlatNode | 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, 1);\n}\n\nfunction getFlatNodes(nodes: PresentationTreeNode[], level: number) {\n const flatNodes: FlatTreeNode[] = [];\n nodes.forEach((node, index) => {\n if (!isPresentationHierarchyNode(node)) {\n return;\n }\n flatNodes.push({ ...node, level, levelSize: nodes.length, posInLevel: index + 1 });\n if (!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\nexport function getErrors(rootNodes: PresentationTreeNode[]): ErrorNode[] {\n return rootNodes.flatMap((rootNode) => {\n if (!isPresentationHierarchyNode(rootNode)) {\n return [{ parent: undefined, error: rootNode, expandTo: (expandNode) => expandTo(expandNode, []) }];\n }\n if (rootNode.children === true) {\n return [];\n }\n return getErrorNodes(rootNode, !rootNode.isExpanded ? [rootNode.id] : []);\n });\n}\n\nfunction getErrorNodes(parent: PresentationHierarchyNode, path: string[]) {\n const errorList: ErrorNode[] = [];\n\n if (parent.children === true) {\n return [];\n }\n\n const pathToChild = [...path, ...(!parent.isExpanded ? [parent.id] : [])];\n parent.children.forEach((node) => {\n if (!isPresentationHierarchyNode(node)) {\n errorList.push({ parent, error: node, expandTo: (expandNode) => expandTo(expandNode, path) });\n return;\n }\n\n if (node.children !== true) {\n const childErrorList = getErrorNodes(node, pathToChild);\n errorList.push(...childErrorList);\n return;\n }\n });\n return errorList;\n}\n\nfunction expandTo(expandNode: (nodeId: string) => void, path: string[]) {\n path.forEach((nodeId) => expandNode(nodeId));\n}\n"]}
|
|
@@ -26,27 +26,37 @@ export interface LocalizedStrings {
|
|
|
26
26
|
clearHierarchyLevelFilter: string;
|
|
27
27
|
/**
|
|
28
28
|
* Message displayed when no nodes matching filter are found.
|
|
29
|
-
* Default value: `No
|
|
29
|
+
* Default value: `No matches for current filter for {{node}}`.
|
|
30
30
|
*/
|
|
31
31
|
noFilteredChildren: string;
|
|
32
|
+
/**
|
|
33
|
+
* Label for change filter action.
|
|
34
|
+
* Default value: `Change filter`.
|
|
35
|
+
*/
|
|
36
|
+
noFilteredChildrenChangeFilter: string;
|
|
37
|
+
/**
|
|
38
|
+
* Message displayed when hierarchy creation for a node failed.
|
|
39
|
+
* Default value: `Failed to create hierarchy for {{node}}`.
|
|
40
|
+
*/
|
|
41
|
+
failedToCreateHierarchy: string;
|
|
32
42
|
/**
|
|
33
43
|
* Message displayed when result limit exceeds hierarchy size limit.
|
|
34
|
-
* Default value: `
|
|
44
|
+
* Default value: `The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit`.
|
|
35
45
|
*/
|
|
36
46
|
resultLimitExceeded: string;
|
|
37
47
|
/**
|
|
38
|
-
*
|
|
39
|
-
* Default value: `
|
|
48
|
+
* Label displayed on error dropdown.
|
|
49
|
+
* Default value: `issues found`.
|
|
40
50
|
*/
|
|
41
|
-
|
|
51
|
+
issuesFound: string;
|
|
42
52
|
/**
|
|
43
53
|
* Message displayed when hierarchy size limit can be overridden.
|
|
44
|
-
* Default value:
|
|
54
|
+
* Default value: `Increase limit to {{limit}}`.
|
|
45
55
|
*/
|
|
46
56
|
increaseHierarchyLimit: string;
|
|
47
57
|
/**
|
|
48
58
|
* Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.
|
|
49
|
-
* Default value: `
|
|
59
|
+
* Default value: `Add Filter`.
|
|
50
60
|
*/
|
|
51
61
|
increaseHierarchyLimitWithFiltering: string;
|
|
52
62
|
/**
|
|
@@ -1 +1 @@
|
|
|
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,qCAAqC,EAAE,MAAM,CAAC;IAC9C;;;OAGG;IACH,yBAAyB,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,
|
|
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,qCAAqC,EAAE,MAAM,CAAC;IAC9C;;;OAGG;IACH,yBAAyB,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,8BAA8B,EAAE,MAAM,CAAC;IACvC;;;OAGG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;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;AAmBD;;;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"}
|
|
@@ -9,11 +9,13 @@ const defaultLocalizedStrings = {
|
|
|
9
9
|
filterHierarchyLevel: "Apply filter",
|
|
10
10
|
filterHierarchyLevelActiveDescription: "Filter is applied",
|
|
11
11
|
clearHierarchyLevelFilter: "Clear active filter",
|
|
12
|
-
noFilteredChildren: "No
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
noFilteredChildren: "No matches for current filter for {{node}}",
|
|
13
|
+
noFilteredChildrenChangeFilter: "Change filter",
|
|
14
|
+
failedToCreateHierarchy: "Failed to create hierarchy for {{node}}",
|
|
15
|
+
resultLimitExceeded: "The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit",
|
|
16
|
+
issuesFound: "issues found",
|
|
17
|
+
increaseHierarchyLimit: "Increase limit to {{limit}}",
|
|
18
|
+
increaseHierarchyLimitWithFiltering: "Add Filter",
|
|
17
19
|
retry: "Retry",
|
|
18
20
|
};
|
|
19
21
|
const localizationContext = createContext({ localizedStrings: defaultLocalizedStrings });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalizationContext.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/LocalizationContext.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAqB,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LocalizationContext.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/LocalizationContext.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAqB,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AA0E1F,MAAM,uBAAuB,GAAqB;IAChD,OAAO,EAAE,YAAY;IACrB,oBAAoB,EAAE,cAAc;IACpC,qCAAqC,EAAE,mBAAmB;IAC1D,yBAAyB,EAAE,qBAAqB;IAChD,kBAAkB,EAAE,4CAA4C;IAChE,8BAA8B,EAAE,eAAe;IAC/C,uBAAuB,EAAE,yCAAyC;IAClE,mBAAmB,EAAE,+FAA+F;IACpH,WAAW,EAAE,cAAc;IAC3B,sBAAsB,EAAE,6BAA6B;IACrD,mCAAmC,EAAE,YAAY;IACjD,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,MAAM,mBAAmB,GAAG,aAAa,CAAsB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,CAAC,CAAC;AAW9G;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAuD;IAC7H,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAAE,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAE9G,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAAE,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACtF,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEvB,OAAO,KAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAgC,CAAC;AAC/F,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,sBAAsB;IACpC,OAAO,UAAU,CAAC,mBAAmB,CAAC,CAAC;AACzC,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 { createContext, PropsWithChildren, useContext, useEffect, useState } from \"react\";\n\n/**\n * Localized strings used in the components.\n * @public\n */\nexport interface LocalizedStrings {\n /**\n * Message displayed when nodes are loading.\n * Default value: `Loading...`.\n */\n loading: string;\n /**\n * Title for apply hierarchy filter button.\n * Default value: `Apply filter`.\n */\n filterHierarchyLevel: string;\n /**\n * Accesible description for applied hierarchy filter button.\n * Default value: `Filter is applied`.\n */\n filterHierarchyLevelActiveDescription: string;\n /**\n * Title for clear hierarchy filter button.\n * Default value: `Clear active filter`.\n */\n clearHierarchyLevelFilter: string;\n /**\n * Message displayed when no nodes matching filter are found.\n * Default value: `No matches for current filter for {{node}}`.\n */\n noFilteredChildren: string;\n /**\n * Label for change filter action.\n * Default value: `Change filter`.\n */\n noFilteredChildrenChangeFilter: string;\n /**\n * Message displayed when hierarchy creation for a node failed.\n * Default value: `Failed to create hierarchy for {{node}}`.\n */\n failedToCreateHierarchy: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit`.\n */\n resultLimitExceeded: string;\n /**\n * Label displayed on error dropdown.\n * Default value: `issues found`.\n */\n issuesFound: string;\n /**\n * Message displayed when hierarchy size limit can be overridden.\n * Default value: `Increase limit to {{limit}}`.\n */\n increaseHierarchyLimit: string;\n /**\n * Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.\n * Default value: `Add Filter`.\n */\n increaseHierarchyLimitWithFiltering: string;\n /**\n * Label for retry action.\n * Default value: `Retry`.\n */\n retry: string;\n}\n\n/** @internal */\nexport interface LocalizationContext {\n localizedStrings: LocalizedStrings;\n}\n\nconst defaultLocalizedStrings: LocalizedStrings = {\n loading: \"Loading...\",\n filterHierarchyLevel: \"Apply filter\",\n filterHierarchyLevelActiveDescription: \"Filter is applied\",\n clearHierarchyLevelFilter: \"Clear active filter\",\n noFilteredChildren: \"No matches for current filter for {{node}}\",\n noFilteredChildrenChangeFilter: \"Change filter\",\n failedToCreateHierarchy: \"Failed to create hierarchy for {{node}}\",\n resultLimitExceeded: \"The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit\",\n issuesFound: \"issues found\",\n increaseHierarchyLimit: \"Increase limit to {{limit}}\",\n increaseHierarchyLimitWithFiltering: \"Add Filter\",\n retry: \"Retry\",\n};\n\nconst localizationContext = createContext<LocalizationContext>({ localizedStrings: defaultLocalizedStrings });\n\n/**\n * Properties for `LocalizationContextProvider`.\n * @public\n */\ninterface LocalizationContextProviderProps {\n /** Localized strings used in the components. */\n localizedStrings?: Partial<LocalizedStrings>;\n}\n\n/**\n * Context provider for localized strings used in the components.\n * @public\n */\nexport function LocalizationContextProvider({ localizedStrings, children }: PropsWithChildren<LocalizationContextProviderProps>) {\n const [state, setState] = useState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n\n useEffect(() => {\n setState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n }, [localizedStrings]);\n\n return <localizationContext.Provider value={state}>{children}</localizationContext.Provider>;\n}\n\n/** @internal */\nexport function useLocalizationContext() {\n return useContext(localizationContext);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeActionButton.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeActionButton.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAK/D,aAAa;AACb,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,aAAa;AACb,MAAM,MAAM,iBAAiB,GAAG;IAC9B,yEAAyE;IACzE,QAAQ,CAAC,EAAE,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI,CAAC;CACnE,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,0BAA0B,CAAC,CAAC,CAAC;AAE1E,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"TreeActionButton.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeActionButton.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAK/D,aAAa;AACb,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,aAAa;AACb,MAAM,MAAM,iBAAiB,GAAG;IAC9B,yEAAyE;IACzE,QAAQ,CAAC,EAAE,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI,CAAC;CACnE,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,0BAA0B,CAAC,CAAC,CAAC;AAE1E,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,EAAE,cAAc,2CAEhG;AAED,aAAa;AACb,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,wBAAwB,EAAE,EAAE,iBAAiB,GAAG,CAAC,IAAI,EAAE,yBAAyB,KAAK,cAAc,CAwB9I"}
|
|
@@ -3,12 +3,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
import {
|
|
6
|
+
import { Tree } from "@itwin/itwinui-react/bricks";
|
|
7
7
|
import { useLocalizationContext } from "./LocalizationContext.js";
|
|
8
|
-
const
|
|
8
|
+
const filterSvg = new URL("@itwin/itwinui-icons/filter.svg", import.meta.url).href;
|
|
9
9
|
/** @internal */
|
|
10
10
|
export function TreeActionButton({ show, label, action, icon, activeDescription }) {
|
|
11
|
-
return
|
|
11
|
+
return _jsx(Tree.ItemAction, { label: label, dot: activeDescription, icon: icon, visible: show, onClick: action });
|
|
12
12
|
}
|
|
13
13
|
/** @alpha */
|
|
14
14
|
export function useFilterAction({ onFilter, getHierarchyLevelDetails }) {
|
|
@@ -30,9 +30,8 @@ export function useFilterAction({ onFilter, getHierarchyLevelDetails }) {
|
|
|
30
30
|
hierarchyLevelDetails && onFilter?.(hierarchyLevelDetails);
|
|
31
31
|
},
|
|
32
32
|
show: handleVisibility(),
|
|
33
|
-
isDropdownAction: false,
|
|
34
33
|
activeDescription: node.isFiltered ? localizedStrings.filterHierarchyLevelActiveDescription : undefined,
|
|
35
|
-
icon:
|
|
34
|
+
icon: filterSvg,
|
|
36
35
|
};
|
|
37
36
|
};
|
|
38
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeActionButton.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeActionButton.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"TreeActionButton.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeActionButton.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAGnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,iCAAiC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;AA4BnF,gBAAgB;AAChB,MAAM,UAAU,gBAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAkB;IAC/F,OAAO,KAAC,IAAI,CAAC,UAAU,IAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAI,CAAC;AAC/G,CAAC;AAED,aAAa;AACb,MAAM,UAAU,eAAe,CAAC,EAAE,QAAQ,EAAE,wBAAwB,EAAqB;IACvF,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACtD,OAAO,CAAC,IAAI,EAAE,EAAE;QACd,MAAM,gBAAgB,GAAG,GAAG,EAAE;YAC5B,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;gBACpC,OAAO,KAAK,CAAC;YACf,CAAC;YACD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC;QAEF,OAAO;YACL,KAAK,EAAE,gBAAgB,CAAC,oBAAoB;YAC5C,MAAM,EAAE,GAAG,EAAE;gBACX,MAAM,qBAAqB,GAAG,wBAAwB,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAClE,qBAAqB,IAAI,QAAQ,EAAE,CAAC,qBAAqB,CAAC,CAAC;YAC7D,CAAC;YACD,IAAI,EAAE,gBAAgB,EAAE;YACxB,iBAAiB,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,qCAAqC,CAAC,CAAC,CAAC,SAAS;YACvG,IAAI,EAAE,SAAS;SAChB,CAAC;IACJ,CAAC,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 { Tree } from \"@itwin/itwinui-react/bricks\";\nimport { PresentationHierarchyNode } from \"../TreeNode.js\";\nimport { HierarchyLevelDetails, useTree } from \"../UseTree.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\n\nconst filterSvg = new URL(\"@itwin/itwinui-icons/filter.svg\", import.meta.url).href;\n\n/** @alpha */\nexport interface TreeItemAction {\n label: string;\n action: () => void;\n icon: string;\n /**\n * Determines action items visibility:\n * - `False` - action item is hidden.\n * - `True` - action item is visible at all times.\n * - `Undefined` - action item is visible on hover/focus.\n */\n show?: boolean;\n /**\n * Provide a value when action button is in active state to display a dot above the button.\n * Provided text value is used to set accessible description it should descibe why the action is in active state.\n * If left undefined the action item will be rendered normally.\n */\n activeDescription?: string;\n}\n\n/** @alpha */\nexport type FilterActionProps = {\n /** Action to perform when the filter button is clicked for this node. */\n onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n} & Partial<Pick<ReturnType<typeof useTree>, \"getHierarchyLevelDetails\">>;\n\n/** @internal */\nexport function TreeActionButton({ show, label, action, icon, activeDescription }: TreeItemAction) {\n return <Tree.ItemAction label={label} dot={activeDescription} icon={icon} visible={show} onClick={action} />;\n}\n\n/** @alpha */\nexport function useFilterAction({ onFilter, getHierarchyLevelDetails }: FilterActionProps): (node: PresentationHierarchyNode) => TreeItemAction {\n const { localizedStrings } = useLocalizationContext();\n return (node) => {\n const handleVisibility = () => {\n if (!onFilter || !node.isFilterable) {\n return false;\n }\n if (node.isFiltered) {\n return true;\n }\n return undefined;\n };\n\n return {\n label: localizedStrings.filterHierarchyLevel,\n action: () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);\n hierarchyLevelDetails && onFilter?.(hierarchyLevelDetails);\n },\n show: handleVisibility(),\n activeDescription: node.isFiltered ? localizedStrings.filterHierarchyLevelActiveDescription : undefined,\n icon: filterSvg,\n };\n };\n}\n"]}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { CSSProperties, ForwardRefExoticComponent, RefAttributes } from "react";
|
|
2
|
-
import { PresentationInfoNode } from "../TreeNode.js";
|
|
3
1
|
import { HierarchyLevelDetails, useTree } from "../UseTree.js";
|
|
4
|
-
import {
|
|
2
|
+
import { ErrorNode } from "./FlatTreeNode.js";
|
|
5
3
|
/** @alpha */
|
|
6
4
|
export interface TreeErrorItemProps {
|
|
7
5
|
/** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */
|
|
@@ -13,11 +11,13 @@ export interface TreeErrorItemProps {
|
|
|
13
11
|
onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;
|
|
14
12
|
}
|
|
15
13
|
interface TreeErrorRendererOwnProps {
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
errorList: ErrorNode[];
|
|
15
|
+
}
|
|
16
|
+
type TreeErrorRendererProps = TreeErrorRendererOwnProps & TreeErrorItemProps & Partial<Pick<ReturnType<typeof useTree>, "getHierarchyLevelDetails">> & Pick<LinkedNodeProps, "scrollToElement">;
|
|
17
|
+
export declare function TreeErrorRenderer({ errorList, scrollToElement, getHierarchyLevelDetails, onFilterClick }: TreeErrorRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
interface LinkedNodeProps {
|
|
19
|
+
errorNode: ErrorNode;
|
|
20
|
+
scrollToElement: (node: ErrorNode) => void;
|
|
18
21
|
}
|
|
19
|
-
type TreeErrorRendererProps = TreeErrorRendererOwnProps & TreeErrorItemProps & Partial<Pick<ReturnType<typeof useTree>, "getHierarchyLevelDetails">>;
|
|
20
|
-
/** @internal */
|
|
21
|
-
export declare const TreeErrorRenderer: ForwardRefExoticComponent<TreeErrorRendererProps & RefAttributes<HTMLElement>>;
|
|
22
22
|
export {};
|
|
23
23
|
//# sourceMappingURL=TreeErrorRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeErrorRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeErrorRenderer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TreeErrorRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeErrorRenderer.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,aAAa;AACb,MAAM,WAAW,kBAAkB;IACjC,iGAAiG;IACjG,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IACrF,yEAAyE;IACzE,aAAa,CAAC,EAAE,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI,CAAC;CACxE;AAED,UAAU,yBAAyB;IACjC,SAAS,EAAE,SAAS,EAAE,CAAC;CACxB;AAED,KAAK,sBAAsB,GAAG,yBAAyB,GACrD,kBAAkB,GAClB,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,0BAA0B,CAAC,CAAC,GACrE,IAAI,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;AAE3C,wBAAgB,iBAAiB,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,wBAAwB,EAAE,aAAa,EAAE,EAAE,sBAAsB,2CA+BhI;AAqDD,UAAU,eAAe;IACvB,SAAS,EAAE,SAAS,CAAC;IACrB,eAAe,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CAC5C"}
|
|
@@ -3,70 +3,45 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
import {
|
|
7
|
-
import { Anchor, Text, Tree } from "@itwin/itwinui-react/bricks";
|
|
6
|
+
import { Anchor, unstable_ErrorRegion as ErrorRegion, Text } from "@itwin/itwinui-react/bricks";
|
|
8
7
|
import { MAX_LIMIT_OVERRIDE } from "../internal/Utils.js";
|
|
9
8
|
import { useLocalizationContext } from "./LocalizationContext.js";
|
|
10
|
-
|
|
11
|
-
export const TreeErrorRenderer = forwardRef(({ node, getHierarchyLevelDetails, onFilterClick, reloadTree, ...rest }, forwardedRef) => {
|
|
9
|
+
export function TreeErrorRenderer({ errorList, scrollToElement, getHierarchyLevelDetails, onFilterClick }) {
|
|
12
10
|
const { localizedStrings } = useLocalizationContext();
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const hierarchyLevelDetails = getHierarchyLevelDetails?.(
|
|
17
|
-
hierarchyLevelDetails && onFilterClick(hierarchyLevelDetails);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return (_jsx(
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
return (_jsx(
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
11
|
+
const errorItems = errorList.map((errorNode) => {
|
|
12
|
+
if (errorNode.error.type === "ResultSetTooLarge") {
|
|
13
|
+
return (_jsx(ResultSetTooLarge, { onFilterClick: () => {
|
|
14
|
+
const hierarchyLevelDetails = getHierarchyLevelDetails?.(errorNode.parent?.id);
|
|
15
|
+
hierarchyLevelDetails && onFilterClick?.(hierarchyLevelDetails);
|
|
16
|
+
}, onOverrideLimit: getHierarchyLevelDetails ? (limit) => getHierarchyLevelDetails(errorNode.parent?.id)?.setSizeLimit(limit) : undefined, scrollToElement: scrollToElement, limit: errorNode.error.resultSetSizeLimit, errorNode: errorNode }, errorNode.error.id));
|
|
17
|
+
}
|
|
18
|
+
if (errorNode.error.type === "NoFilterMatches") {
|
|
19
|
+
return _jsx(NoFilterMatches, { scrollToElement: scrollToElement, errorNode: errorNode }, errorNode.error.id);
|
|
20
|
+
}
|
|
21
|
+
return _jsx(DefaultErrorContainer, { scrollToElement: scrollToElement, errorNode: errorNode }, errorNode.error.id);
|
|
22
|
+
});
|
|
23
|
+
return (_jsx(ErrorRegion.Root, { style: { width: "100%" }, label: errorList.length !== 0 ? `${errorList.length} ${localizedStrings?.issuesFound}` : undefined, items: errorItems }));
|
|
24
|
+
}
|
|
25
|
+
function NoFilterMatches({ onFilterClick, errorNode, scrollToElement }) {
|
|
26
|
+
const { localizedStrings } = useLocalizationContext();
|
|
27
|
+
return (_jsx(ErrorRegion.Item, { message: _jsx(MessageWithNode, { errorNode: errorNode, scrollToElement: scrollToElement, message: localizedStrings.noFilteredChildren }), actions: _jsx(Anchor, { onClick: () => onFilterClick, children: localizedStrings.noFilteredChildrenChangeFilter }) }));
|
|
28
|
+
}
|
|
29
|
+
function DefaultErrorContainer({ reloadTree, errorNode, scrollToElement }) {
|
|
30
|
+
const { localizedStrings } = useLocalizationContext();
|
|
31
|
+
return (_jsx(ErrorRegion.Item, { message: _jsx(MessageWithNode, { errorNode: errorNode, scrollToElement: scrollToElement, message: localizedStrings.failedToCreateHierarchy }), actions: _jsx(Anchor, { onClick: () => reloadTree, children: localizedStrings.retry }) }));
|
|
32
|
+
}
|
|
33
|
+
function ResultSetTooLarge({ errorNode, onFilterClick, limit, onOverrideLimit, scrollToElement }) {
|
|
33
34
|
const { localizedStrings } = useLocalizationContext();
|
|
34
35
|
const supportsFiltering = !!onFilterClick;
|
|
35
36
|
const supportsLimitOverride = !!onOverrideLimit && limit < MAX_LIMIT_OVERRIDE;
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
? createLocalizedMessage(supportsFiltering ? localizedStrings.increaseHierarchyLimitWithFiltering : localizedStrings.increaseHierarchyLimit, MAX_LIMIT_OVERRIDE, () => onOverrideLimit(MAX_LIMIT_OVERRIDE))
|
|
39
|
-
: { title: "", element: null };
|
|
40
|
-
const title = `${limitExceededMessage.title} ${increaseLimitMessage.title}`;
|
|
41
|
-
return (_jsxs("div", { style: { display: "flex", alignItems: "start" }, title: title, children: [limitExceededMessage.element, increaseLimitMessage.element] }));
|
|
37
|
+
const messageWithLimit = localizedStrings.resultLimitExceeded.replace("{{limit}}", limit.toString());
|
|
38
|
+
return (_jsx(ErrorRegion.Item, { message: _jsx(MessageWithNode, { errorNode: errorNode, scrollToElement: scrollToElement, message: messageWithLimit }), actions: _jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [supportsLimitOverride && (_jsx(Anchor, { onClick: () => onOverrideLimit(MAX_LIMIT_OVERRIDE), children: localizedStrings.increaseHierarchyLimit.replace("{{limit}}", MAX_LIMIT_OVERRIDE.toString()) })), supportsFiltering && _jsx(Anchor, { onClick: onFilterClick, children: localizedStrings.increaseHierarchyLimitWithFiltering })] }) }));
|
|
42
39
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
return (_jsxs("div", { style: { display: "flex" }, children: [_jsx(Text, { variant: "body-sm", children: message }), onRetry ? _jsx(Anchor, { onClick: onRetry, children: localizedStrings?.retry }) : null] }));
|
|
40
|
+
function LinkedNode({ errorNode, scrollToElement }) {
|
|
41
|
+
return _jsx(Anchor, { onClick: () => scrollToElement(errorNode), children: errorNode.parent?.label });
|
|
46
42
|
}
|
|
47
|
-
function
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const exp = new RegExp("<link>(.*)</link>");
|
|
51
|
-
const match = messageWithLimit.match(exp);
|
|
52
|
-
if (!match) {
|
|
53
|
-
return {
|
|
54
|
-
title: messageWithLimit,
|
|
55
|
-
element: (_jsx("div", { style: { display: "flex" }, children: _jsx(Text, { variant: "body-sm", children: messageWithLimit }) })),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
const [fullText, innerText] = match;
|
|
59
|
-
const [textBefore, textAfter] = messageWithLimit.split(fullText);
|
|
60
|
-
return {
|
|
61
|
-
title: messageWithLimit.replace(fullText, innerText),
|
|
62
|
-
element: (_jsxs("div", { style: { display: "flex" }, children: [textBefore ? _jsx(Text, { variant: "body-sm", children: textBefore }) : null, _jsx(Anchor
|
|
63
|
-
// underline props does not exist in v5
|
|
64
|
-
, {
|
|
65
|
-
// underline props does not exist in v5
|
|
66
|
-
onClick: (e) => {
|
|
67
|
-
e.stopPropagation();
|
|
68
|
-
onClick?.();
|
|
69
|
-
}, children: innerText }), textAfter ? _jsx(Text, { variant: "body-sm", children: textAfter }) : null] })),
|
|
70
|
-
};
|
|
43
|
+
function MessageWithNode({ errorNode, scrollToElement, message }) {
|
|
44
|
+
const splitMessage = message.split("{{node}}", 2);
|
|
45
|
+
return (_jsxs("div", { style: { display: "flex", whiteSpace: "pre", flexWrap: "wrap" }, children: [_jsx(Text, { variant: "body-sm", children: splitMessage[0] }), _jsx(LinkedNode, { errorNode: errorNode, scrollToElement: scrollToElement }), splitMessage[1] ? _jsx(Text, { variant: "body-sm", children: splitMessage[1] }) : null] }));
|
|
71
46
|
}
|
|
72
47
|
//# sourceMappingURL=TreeErrorRenderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeErrorRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeErrorRenderer.tsx"],"names":[],"mappings":";AAA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AE,CAAC;wBACpB,OAAO,EAAE,EAAE,CAAC;oBACd,CAAC,YAEA,SAAS,GACH,EACR,SAAS,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,YAAG,SAAS,GAAQ,CAAC,CAAC,CAAC,IAAI,IAC5D,CACP;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 { ComponentPropsWithoutRef, CSSProperties, forwardRef, ForwardRefExoticComponent, RefAttributes } from \"react\";\nimport { Anchor, Text, Tree } from \"@itwin/itwinui-react/bricks\";\nimport { MAX_LIMIT_OVERRIDE } from \"../internal/Utils.js\";\nimport { PresentationInfoNode } from \"../TreeNode.js\";\nimport { HierarchyLevelDetails, useTree } from \"../UseTree.js\";\nimport { FlatNode } from \"./FlatTreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\n\n/** @alpha */\nexport interface TreeErrorItemProps {\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 /** Action to perform when the filter button is clicked for this node. */\n onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n}\n\ninterface TreeErrorRendererOwnProps {\n node: FlatNode<PresentationInfoNode>;\n style?: CSSProperties;\n}\n\ntype TreeErrorRendererProps = TreeErrorRendererOwnProps & TreeErrorItemProps & Partial<Pick<ReturnType<typeof useTree>, \"getHierarchyLevelDetails\">>;\n\n/** @internal */\nexport const TreeErrorRenderer: ForwardRefExoticComponent<TreeErrorRendererProps & RefAttributes<HTMLElement>> = forwardRef(\n ({ node, getHierarchyLevelDetails, onFilterClick, reloadTree, ...rest }, forwardedRef) => {\n const { localizedStrings } = useLocalizationContext();\n if (node.type === \"ResultSetTooLarge\") {\n return (\n <ResultSetTooLargeNode\n {...rest}\n ref={forwardedRef}\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 aria-level={node.level}\n aria-posinset={node.posInLevel}\n aria-setsize={node.levelSize}\n />\n );\n }\n\n if (node.type === \"NoFilterMatches\") {\n return (\n <Tree.Item\n {...rest}\n ref={forwardedRef}\n aria-level={node.level}\n aria-posinset={node.posInLevel}\n aria-setsize={node.levelSize}\n label={localizedStrings.noFilteredChildren}\n aria-disabled={true}\n />\n );\n }\n\n const onRetry = reloadTree ? () => reloadTree({ parentNodeId: node.parentNodeId, state: \"reset\" }) : undefined;\n return (\n <Tree.Item\n {...rest}\n ref={forwardedRef}\n aria-level={node.level}\n aria-posinset={node.posInLevel}\n aria-setsize={node.levelSize}\n label={<ErrorNodeLabel message={node.message} onRetry={onRetry} />}\n aria-disabled={true}\n />\n );\n },\n);\nTreeErrorRenderer.displayName = \"TreeErrorRenderer\";\n\nconst ResultSetTooLargeNode = forwardRef<\n HTMLElement,\n Omit<ComponentPropsWithoutRef<typeof Tree.Item>, \"onExpanded\" | \"label\"> & ResultSetTooLargeNodeLabelProps\n>(({ onFilterClick, onOverrideLimit, limit, ...props }, forwardedRef) => {\n return (\n <Tree.Item\n {...props}\n ref={forwardedRef}\n label={<ResultSetTooLargeNodeLabel limit={limit} onFilterClick={onFilterClick} onOverrideLimit={onOverrideLimit} />}\n />\n );\n});\nResultSetTooLargeNode.displayName = \"ResultSetTooLargeNode\";\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 <div style={{ display: \"flex\", alignItems: \"start\" }} title={title}>\n {limitExceededMessage.element}\n {increaseLimitMessage.element}\n </div>\n );\n}\n\nfunction ErrorNodeLabel({ message, onRetry }: { message: string; onRetry?: () => void }) {\n const { localizedStrings } = useLocalizationContext();\n return (\n <div style={{ display: \"flex\" }}>\n <Text variant={\"body-sm\"}>{message}</Text>\n {onRetry ? <Anchor onClick={onRetry}>{localizedStrings?.retry}</Anchor> : null}\n </div>\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 <div style={{ display: \"flex\" }}>\n <Text variant={\"body-sm\"}>{messageWithLimit}</Text>\n </div>\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 <div style={{ display: \"flex\" }}>\n {textBefore ? <Text variant={\"body-sm\"}>{textBefore}</Text> : null}\n <Anchor\n // underline props does not exist in v5\n onClick={(e) => {\n e.stopPropagation();\n onClick?.();\n }}\n >\n {innerText}\n </Anchor>\n {textAfter ? <Text variant={\"body-sm\"}>{textAfter}</Text> : null}\n </div>\n ),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TreeErrorRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeErrorRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,oBAAoB,IAAI,WAAW,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAmBlE,MAAM,UAAU,iBAAiB,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,wBAAwB,EAAE,aAAa,EAA0B;IAC/H,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACtD,MAAM,UAAU,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;QAC7C,IAAI,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;YACjD,OAAO,CACL,KAAC,iBAAiB,IAEhB,aAAa,EAAE,GAAG,EAAE;oBAClB,MAAM,qBAAqB,GAAG,wBAAwB,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;oBAC/E,qBAAqB,IAAI,aAAa,EAAE,CAAC,qBAAqB,CAAC,CAAC;gBAClE,CAAC,EACD,eAAe,EAAE,wBAAwB,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,wBAAwB,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EACtI,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE,SAAS,CAAC,KAAK,CA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AAC,MAAM,IAAC,OAAO,EAAE,aAAa,YAAG,gBAAgB,CAAC,mCAAmC,GAAU,IACjH,GAER,CACH,CAAC;AACJ,CAAC;AAOD,SAAS,UAAU,CAAC,EAAE,SAAS,EAAE,eAAe,EAAmB;IACjE,OAAO,KAAC,MAAM,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,YAAG,SAAS,CAAC,MAAM,EAAE,KAAK,GAAU,CAAC;AAC/F,CAAC;AAED,SAAS,eAAe,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAyC;IACrG,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAClD,OAAO,CACL,eAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,aAClE,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,YAAG,YAAY,CAAC,CAAC,CAAC,GAAQ,EAClD,KAAC,UAAU,IAAC,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,GAAI,EACrE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,YAAG,YAAY,CAAC,CAAC,CAAC,GAAQ,CAAC,CAAC,CAAC,IAAI,IACxE,CACP,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 { Anchor, unstable_ErrorRegion as ErrorRegion, Text } from \"@itwin/itwinui-react/bricks\";\nimport { MAX_LIMIT_OVERRIDE } from \"../internal/Utils.js\";\nimport { HierarchyLevelDetails, useTree } from \"../UseTree.js\";\nimport { ErrorNode } from \"./FlatTreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\n\n/** @alpha */\nexport interface TreeErrorItemProps {\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 /** Action to perform when the filter button is clicked for this node. */\n onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n}\n\ninterface TreeErrorRendererOwnProps {\n errorList: ErrorNode[];\n}\n\ntype TreeErrorRendererProps = TreeErrorRendererOwnProps &\n TreeErrorItemProps &\n Partial<Pick<ReturnType<typeof useTree>, \"getHierarchyLevelDetails\">> &\n Pick<LinkedNodeProps, \"scrollToElement\">;\n\nexport function TreeErrorRenderer({ errorList, scrollToElement, getHierarchyLevelDetails, onFilterClick }: TreeErrorRendererProps) {\n const { localizedStrings } = useLocalizationContext();\n const errorItems = errorList.map((errorNode) => {\n if (errorNode.error.type === \"ResultSetTooLarge\") {\n return (\n <ResultSetTooLarge\n key={errorNode.error.id}\n onFilterClick={() => {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(errorNode.parent?.id);\n hierarchyLevelDetails && onFilterClick?.(hierarchyLevelDetails);\n }}\n onOverrideLimit={getHierarchyLevelDetails ? (limit) => getHierarchyLevelDetails(errorNode.parent?.id)?.setSizeLimit(limit) : undefined}\n scrollToElement={scrollToElement}\n limit={errorNode.error.resultSetSizeLimit}\n errorNode={errorNode}\n />\n );\n }\n if (errorNode.error.type === \"NoFilterMatches\") {\n return <NoFilterMatches key={errorNode.error.id} scrollToElement={scrollToElement} errorNode={errorNode} />;\n }\n return <DefaultErrorContainer key={errorNode.error.id} scrollToElement={scrollToElement} errorNode={errorNode} />;\n });\n\n return (\n <ErrorRegion.Root\n style={{ width: \"100%\" }}\n label={errorList.length !== 0 ? `${errorList.length} ${localizedStrings?.issuesFound}` : undefined}\n items={errorItems}\n />\n );\n}\n\nfunction NoFilterMatches({ onFilterClick, errorNode, scrollToElement }: LinkedNodeProps & Pick<TreeErrorItemProps, \"onFilterClick\">) {\n const { localizedStrings } = useLocalizationContext();\n\n return (\n <ErrorRegion.Item\n message={<MessageWithNode errorNode={errorNode} scrollToElement={scrollToElement} message={localizedStrings.noFilteredChildren} />}\n actions={<Anchor onClick={() => onFilterClick}>{localizedStrings.noFilteredChildrenChangeFilter}</Anchor>}\n />\n );\n}\n\nfunction DefaultErrorContainer({ reloadTree, errorNode, scrollToElement }: LinkedNodeProps & Pick<TreeErrorItemProps, \"reloadTree\">) {\n const { localizedStrings } = useLocalizationContext();\n\n return (\n <ErrorRegion.Item\n message={<MessageWithNode errorNode={errorNode} scrollToElement={scrollToElement} message={localizedStrings.failedToCreateHierarchy} />}\n actions={<Anchor onClick={() => reloadTree}>{localizedStrings.retry}</Anchor>}\n />\n );\n}\n\ntype ResultSetTooLargeProps = {\n limit: number;\n onFilterClick?: () => void;\n onOverrideLimit?: (limit: number) => void;\n} & LinkedNodeProps;\n\nfunction ResultSetTooLarge({ errorNode, onFilterClick, limit, onOverrideLimit, scrollToElement }: ResultSetTooLargeProps) {\n const { localizedStrings } = useLocalizationContext();\n const supportsFiltering = !!onFilterClick;\n const supportsLimitOverride = !!onOverrideLimit && limit < MAX_LIMIT_OVERRIDE;\n const messageWithLimit = localizedStrings.resultLimitExceeded.replace(\"{{limit}}\", limit.toString());\n\n return (\n <ErrorRegion.Item\n message={<MessageWithNode errorNode={errorNode} scrollToElement={scrollToElement} message={messageWithLimit} />}\n actions={\n <div style={{ display: \"flex\", flexDirection: \"column\" }}>\n {supportsLimitOverride && (\n <Anchor onClick={() => onOverrideLimit(MAX_LIMIT_OVERRIDE)}>\n {localizedStrings.increaseHierarchyLimit.replace(\"{{limit}}\", MAX_LIMIT_OVERRIDE.toString())}\n </Anchor>\n )}\n {supportsFiltering && <Anchor onClick={onFilterClick}>{localizedStrings.increaseHierarchyLimitWithFiltering}</Anchor>}\n </div>\n }\n />\n );\n}\n\ninterface LinkedNodeProps {\n errorNode: ErrorNode;\n scrollToElement: (node: ErrorNode) => void;\n}\n\nfunction LinkedNode({ errorNode, scrollToElement }: LinkedNodeProps) {\n return <Anchor onClick={() => scrollToElement(errorNode)}>{errorNode.parent?.label}</Anchor>;\n}\n\nfunction MessageWithNode({ errorNode, scrollToElement, message }: LinkedNodeProps & { message: string }) {\n const splitMessage = message.split(\"{{node}}\", 2);\n return (\n <div style={{ display: \"flex\", whiteSpace: \"pre\", flexWrap: \"wrap\" }}>\n <Text variant={\"body-sm\"}>{splitMessage[0]}</Text>\n <LinkedNode errorNode={errorNode} scrollToElement={scrollToElement} />\n {splitMessage[1] ? <Text variant={\"body-sm\"}>{splitMessage[1]}</Text> : null}\n </div>\n );\n}\n"]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef, ForwardRefExoticComponent, ReactElement, ReactNode, RefAttributes } from "react";
|
|
2
2
|
import { Tree } from "@itwin/itwinui-react/bricks";
|
|
3
3
|
import { PresentationHierarchyNode } from "../TreeNode.js";
|
|
4
|
-
import { useTree } from "../UseTree.js";
|
|
5
|
-
import { FlatTreeNode } from "./FlatTreeNode.js";
|
|
4
|
+
import { useTree, UseTreeResult } from "../UseTree.js";
|
|
5
|
+
import { ErrorNode, FlatTreeNode } from "./FlatTreeNode.js";
|
|
6
6
|
import { TreeItemAction } from "./TreeActionButton.js";
|
|
7
|
-
import { TreeErrorItemProps } from "./TreeErrorRenderer.js";
|
|
8
7
|
/** @alpha */
|
|
9
8
|
type TreeNodeProps = ComponentPropsWithoutRef<typeof Tree.Item>;
|
|
10
9
|
/** @alpha */
|
|
@@ -28,9 +27,14 @@ export interface TreeNodeRendererOwnProps {
|
|
|
28
27
|
* E.g. icons, color picker, etc.
|
|
29
28
|
*/
|
|
30
29
|
getDecorations?: (node: PresentationHierarchyNode) => ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Used to determine if node contains errors.
|
|
32
|
+
* Returns an error if node contains one, otherwise returns undefined.
|
|
33
|
+
*/
|
|
34
|
+
hasError?: (node: PresentationHierarchyNode) => ErrorNode | undefined;
|
|
31
35
|
}
|
|
32
36
|
/** @alpha */
|
|
33
|
-
type TreeNodeRendererProps = Pick<ReturnType<typeof useTree>, "expandNode" | "isNodeSelected"> & Partial<Pick<ReturnType<typeof useTree>, "getHierarchyLevelDetails">> & Omit<TreeNodeProps, "actions" | "aria-level" | "aria-posinset" | "aria-setsize" | "label" | "icon" | "expanded" | "selected" | "unstable_decorations"> &
|
|
37
|
+
type TreeNodeRendererProps = Pick<ReturnType<typeof useTree>, "expandNode" | "isNodeSelected"> & Partial<Pick<ReturnType<typeof useTree>, "getHierarchyLevelDetails">> & Omit<TreeNodeProps, "actions" | "aria-level" | "aria-posinset" | "aria-setsize" | "label" | "icon" | "expanded" | "selected" | "unstable_decorations"> & Partial<Pick<UseTreeResult, "reloadTree">> & TreeNodeRendererOwnProps;
|
|
34
38
|
/**
|
|
35
39
|
* A component that renders `RenderedTreeNode` using the `TreeNode` component from `@itwin/itwinui-react`.
|
|
36
40
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EACL,wBAAwB,EAExB,yBAAyB,EAGzB,YAAY,EACZ,SAAS,EAET,aAAa,
|
|
1
|
+
{"version":3,"file":"TreeNodeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EACL,wBAAwB,EAExB,yBAAyB,EAGzB,YAAY,EACZ,SAAS,EAET,aAAa,EAId,MAAM,OAAO,CAAC;AACf,OAAO,EAAW,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,YAAY,EAA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AAE,0BAA0B,CAAC,CAAC,GACrE,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,YAAY,GAAG,eAAe,GAAG,cAAc,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,sBAAsB,CAAC,GACtJ,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,GAC1C,wBAAwB,CAAC;AAE3B;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,yBAAyB,CAAC,qBAAqB,GAAG,aAAa,CAAC,WAAW,CAAC,CAsE1G,CAAC"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
/*---------------------------------------------------------------------------------------------
|
|
3
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
import { forwardRef, useCallback, useRef, } from "react";
|
|
7
|
-
import {
|
|
8
|
-
import { isPresentationHierarchyNode } from "../TreeNode.js";
|
|
6
|
+
import { forwardRef, useCallback, useMemo, useRef, } from "react";
|
|
7
|
+
import { Spinner, Tree } from "@itwin/itwinui-react/bricks";
|
|
9
8
|
import { isPlaceholderNode } from "./FlatTreeNode.js";
|
|
10
9
|
import { useLocalizationContext } from "./LocalizationContext.js";
|
|
11
10
|
import { TreeActionButton } from "./TreeActionButton.js";
|
|
12
|
-
|
|
13
|
-
const dropdownIcon = new URL("@itwin/itwinui-icons/more-horizontal.svg", import.meta.url).href;
|
|
11
|
+
const refreshSvg = new URL("@itwin/itwinui-icons/refresh.svg", import.meta.url).href;
|
|
14
12
|
/**
|
|
15
13
|
* A component that renders `RenderedTreeNode` using the `TreeNode` component from `@itwin/itwinui-react`.
|
|
16
14
|
*
|
|
@@ -18,33 +16,29 @@ const dropdownIcon = new URL("@itwin/itwinui-icons/more-horizontal.svg", import.
|
|
|
18
16
|
* @see https://itwinui.bentley.com/docs/tree
|
|
19
17
|
* @public
|
|
20
18
|
*/
|
|
21
|
-
export const TreeNodeRenderer = forwardRef(({ node, expandNode, getLabel, getSublabel,
|
|
19
|
+
export const TreeNodeRenderer = forwardRef(({ node, expandNode, getLabel, getSublabel, onNodeClick, onNodeKeyDown, isNodeSelected, actions, getDecorations, hasError, reloadTree, ...treeItemProps }, forwardedRef) => {
|
|
22
20
|
const nodeRef = useRef(null);
|
|
23
21
|
const ref = useMergedRefs(forwardedRef, nodeRef);
|
|
22
|
+
const { localizedStrings } = useLocalizationContext();
|
|
23
|
+
const childErrorNode = useMemo(() => {
|
|
24
|
+
return !isPlaceholderNode(node) ? hasError?.(node) : false;
|
|
25
|
+
}, [hasError, node]);
|
|
24
26
|
if (isPlaceholderNode(node)) {
|
|
25
27
|
return _jsx(PlaceholderNode, { ...treeItemProps, level: node.level, ref: ref });
|
|
26
28
|
}
|
|
27
|
-
if (!isPresentationHierarchyNode(node)) {
|
|
28
|
-
return (_jsx(TreeErrorRenderer, { style: treeItemProps.style, ref: ref, node: node, getHierarchyLevelDetails: getHierarchyLevelDetails, reloadTree: reloadTree, onFilterClick: onFilterClick }));
|
|
29
|
-
}
|
|
30
29
|
const getActions = () => {
|
|
31
30
|
if (!actions || actions.length === 0) {
|
|
32
31
|
return undefined;
|
|
33
32
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return _jsx(TreeActionButton, { ...actionInfo }, index);
|
|
38
|
-
});
|
|
33
|
+
const actionButtons = [];
|
|
34
|
+
if (childErrorNode && childErrorNode.error.type === "Unknown") {
|
|
35
|
+
actionButtons.push(_jsx(TreeActionButton, { label: localizedStrings.retry, action: () => reloadTree?.({ parentNodeId: node.id }), show: true, icon: refreshSvg }));
|
|
39
36
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
_jsx(TreeActionButton, { ...
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return _jsx(DropdownMenu.Item, { label: info.label, onClick: () => info.action() }, info.label);
|
|
46
|
-
}) })] }, 2),
|
|
47
|
-
];
|
|
37
|
+
actionButtons.push(...actions.map((action, index) => {
|
|
38
|
+
const actionInfo = action(node);
|
|
39
|
+
return _jsx(TreeActionButton, { ...actionInfo }, index);
|
|
40
|
+
}));
|
|
41
|
+
return actionButtons;
|
|
48
42
|
};
|
|
49
43
|
const selected = isNodeSelected(node.id);
|
|
50
44
|
return (_jsx(Tree.Item, { ...treeItemProps, ref: ref, "aria-level": node.level, "aria-posinset": node.posInLevel, "aria-setsize": node.levelSize, label: getLabel ? getLabel(node) : node.label, description: getSublabel ? getSublabel(node) : undefined, selected: selected, expanded: node.isExpanded || node.children === true || node.children.length > 0 ? node.isExpanded : undefined, onExpandedChange: (isExpanded) => {
|
|
@@ -56,7 +50,7 @@ export const TreeNodeRenderer = forwardRef(({ node, expandNode, getLabel, getSub
|
|
|
56
50
|
if (!treeItemProps["aria-disabled"] && event.target === nodeRef.current) {
|
|
57
51
|
onNodeKeyDown?.(node, !selected, event);
|
|
58
52
|
}
|
|
59
|
-
}, actions: getActions(), unstable_decorations: getDecorations && getDecorations(node) }));
|
|
53
|
+
}, actions: getActions(), unstable_decorations: getDecorations && getDecorations(node), error: !!childErrorNode }));
|
|
60
54
|
});
|
|
61
55
|
TreeNodeRenderer.displayName = "TreeNodeRenderer";
|
|
62
56
|
const PlaceholderNode = forwardRef(({ level, ...props }, forwardedRef) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAEL,UAAU,EAQV,WAAW,EACX,MAAM,GACP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAC1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;AACJ,CAAC,CACF,CAAC;AACF,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAElD,MAAM,eAAe,GAAG,UAAU,CAGhC,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,YAAY,EAAE,EAAE;IACtC,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACtD,OAAO,CACL,KAAC,IAAI,CAAC,IAAI,OACJ,KAAK,gBACG,KAAK,mBACF,CAAC,kBACF,CAAC,EACf,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,gBAAgB,CAAC,OAAO,EAC/B,IAAI,EAAE,KAAC,OAAO,IAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,CAAC,OAAO,GAAI,GACjE,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AACH,eAAe,CAAC,WAAW,GAAG,iBAAiB,CAAC;AAEhD,SAAS,aAAa,CAAI,GAAG,IAA6D;IACxF,OAAO,WAAW,CAChB,CAAC,QAAkB,EAAE,EAAE;QACrB,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,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 {\n ComponentPropsWithoutRef,\n forwardRef,\n ForwardRefExoticComponent,\n LegacyRef,\n MutableRefObject,\n ReactElement,\n ReactNode,\n Ref,\n RefAttributes,\n useCallback,\n useRef,\n} from \"react\";\nimport { DropdownMenu, Spinner, Tree } from \"@itwin/itwinui-react/bricks\";\nimport { isPresentationHierarchyNode, PresentationHierarchyNode } from \"../TreeNode.js\";\nimport { useTree } from \"../UseTree.js\";\nimport { FlatTreeNode, isPlaceholderNode } from \"./FlatTreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\nimport { TreeActionButton, TreeItemAction } from \"./TreeActionButton.js\";\nimport { TreeErrorItemProps, TreeErrorRenderer } from \"./TreeErrorRenderer.js\";\n\nconst dropdownIcon = new URL(\"@itwin/itwinui-icons/more-horizontal.svg\", import.meta.url).href;\n\n/** @alpha */\ntype TreeNodeProps = ComponentPropsWithoutRef<typeof Tree.Item>;\n\n/** @alpha */\nexport interface TreeNodeRendererOwnProps {\n /** Node that is rendered. */\n node: FlatTreeNode;\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 /**\n * Actions for tree item.\n */\n actions?: Array<(node: PresentationHierarchyNode) => TreeItemAction>;\n /**\n * Used to render elements between expander and label.\n * E.g. icons, color picker, etc.\n */\n getDecorations?: (node: PresentationHierarchyNode) => ReactNode;\n}\n\n/** @alpha */\ntype TreeNodeRendererProps = Pick<ReturnType<typeof useTree>, \"expandNode\" | \"isNodeSelected\"> &\n Partial<Pick<ReturnType<typeof useTree>, \"getHierarchyLevelDetails\">> &\n Omit<TreeNodeProps, \"actions\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\" | \"label\" | \"icon\" | \"expanded\" | \"selected\" | \"unstable_decorations\"> &\n TreeNodeRendererOwnProps &\n TreeErrorItemProps;\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 * @public\n */\nexport const TreeNodeRenderer: ForwardRefExoticComponent<TreeNodeRendererProps & RefAttributes<HTMLElement>> = forwardRef(\n (\n {\n node,\n expandNode,\n getLabel,\n getSublabel,\n onFilterClick,\n onNodeClick,\n onNodeKeyDown,\n isNodeSelected,\n getHierarchyLevelDetails,\n reloadTree,\n actions,\n getDecorations,\n ...treeItemProps\n },\n forwardedRef,\n ) => {\n const nodeRef = useRef<HTMLElement>(null);\n const ref = useMergedRefs(forwardedRef, nodeRef);\n\n if (isPlaceholderNode(node)) {\n return <PlaceholderNode {...treeItemProps} level={node.level} ref={ref} />;\n }\n\n if (!isPresentationHierarchyNode(node)) {\n return (\n <TreeErrorRenderer\n style={treeItemProps.style}\n ref={ref}\n node={node}\n getHierarchyLevelDetails={getHierarchyLevelDetails}\n reloadTree={reloadTree}\n onFilterClick={onFilterClick}\n />\n );\n }\n\n const getActions = () => {\n if (!actions || actions.length === 0) {\n return undefined;\n }\n\n if (actions.length < 4) {\n return actions.map((action, index) => {\n const actionInfo = action(node);\n return <TreeActionButton key={index} {...actionInfo} />;\n });\n }\n\n return [\n <TreeActionButton key={0} {...actions[0](node)} />,\n <TreeActionButton key={1} {...actions[1](node)} />,\n <DropdownMenu.Root key={2}>\n <DropdownMenu.Button render={<Tree.ItemAction icon={dropdownIcon} label=\"Tree actions dropdown\" />} />\n <DropdownMenu.Content>\n {actions.slice(2, actions.length).map((action) => {\n const info = action(node);\n return <DropdownMenu.Item label={info.label} key={info.label} onClick={() => info.action()} />;\n })}\n </DropdownMenu.Content>\n </DropdownMenu.Root>,\n ];\n };\n\n const selected = isNodeSelected(node.id);\n return (\n <Tree.Item\n {...treeItemProps}\n ref={ref}\n aria-level={node.level}\n aria-posinset={node.posInLevel}\n aria-setsize={node.levelSize}\n label={getLabel ? getLabel(node) : node.label}\n description={getSublabel ? getSublabel(node) : undefined}\n selected={selected}\n expanded={node.isExpanded || node.children === true || node.children.length > 0 ? node.isExpanded : undefined}\n onExpandedChange={(isExpanded) => {\n expandNode(node.id, isExpanded);\n }}\n onClick={(event) => {\n !treeItemProps[\"aria-disabled\"] && onNodeClick?.(node, !selected, event);\n }}\n onKeyDown={(event) => {\n // Ignore if it is called on the element inside, e.g. checkbox or expander\n if (!treeItemProps[\"aria-disabled\"] && event.target === nodeRef.current) {\n onNodeKeyDown?.(node, !selected, event);\n }\n }}\n actions={getActions()}\n unstable_decorations={getDecorations && getDecorations(node)}\n />\n );\n },\n);\nTreeNodeRenderer.displayName = \"TreeNodeRenderer\";\n\nconst PlaceholderNode = forwardRef<\n HTMLDivElement,\n Omit<TreeNodeProps, \"onExpanded\" | \"label\" | \"actions\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\" | \"icon\"> & { level: number }\n>(({ level, ...props }, forwardedRef) => {\n const { localizedStrings } = useLocalizationContext();\n return (\n <Tree.Item\n {...props}\n aria-level={level}\n aria-posinset={1}\n aria-setsize={1}\n ref={forwardedRef}\n label={localizedStrings.loading}\n icon={<Spinner size={\"small\"} title={localizedStrings.loading} />}\n />\n );\n});\nPlaceholderNode.displayName = \"PlaceholderNode\";\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"]}
|
|
1
|
+
{"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeNodeRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OA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f,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,gBAAgB,CAAC,OAAO,EAC/B,IAAI,EAAE,KAAC,OAAO,IAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,CAAC,OAAO,GAAI,GACjE,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AACH,eAAe,CAAC,WAAW,GAAG,iBAAiB,CAAC;AAEhD,SAAS,aAAa,CAAI,GAAG,IAA6D;IACxF,OAAO,WAAW,CAChB,CAAC,QAAkB,EAAE,EAAE;QACrB,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,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 {\n ComponentPropsWithoutRef,\n forwardRef,\n ForwardRefExoticComponent,\n LegacyRef,\n MutableRefObject,\n ReactElement,\n ReactNode,\n Ref,\n RefAttributes,\n useCallback,\n useMemo,\n useRef,\n} from \"react\";\nimport { Spinner, Tree } from \"@itwin/itwinui-react/bricks\";\nimport { PresentationHierarchyNode } from \"../TreeNode.js\";\nimport { useTree, UseTreeResult } from \"../UseTree.js\";\nimport { ErrorNode, FlatTreeNode, isPlaceholderNode } from \"./FlatTreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\nimport { TreeActionButton, TreeItemAction } from \"./TreeActionButton.js\";\n\nconst refreshSvg = new URL(\"@itwin/itwinui-icons/refresh.svg\", import.meta.url).href;\n\n/** @alpha */\ntype TreeNodeProps = ComponentPropsWithoutRef<typeof Tree.Item>;\n\n/** @alpha */\nexport interface TreeNodeRendererOwnProps {\n /** Node that is rendered. */\n node: FlatTreeNode;\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 /**\n * Actions for tree item.\n */\n actions?: Array<(node: PresentationHierarchyNode) => TreeItemAction>;\n /**\n * Used to render elements between expander and label.\n * E.g. icons, color picker, etc.\n */\n getDecorations?: (node: PresentationHierarchyNode) => ReactNode;\n /**\n * Used to determine if node contains errors.\n * Returns an error if node contains one, otherwise returns undefined.\n */\n hasError?: (node: PresentationHierarchyNode) => ErrorNode | undefined;\n}\n\n/** @alpha */\ntype TreeNodeRendererProps = Pick<ReturnType<typeof useTree>, \"expandNode\" | \"isNodeSelected\"> &\n Partial<Pick<ReturnType<typeof useTree>, \"getHierarchyLevelDetails\">> &\n Omit<TreeNodeProps, \"actions\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\" | \"label\" | \"icon\" | \"expanded\" | \"selected\" | \"unstable_decorations\"> &\n Partial<Pick<UseTreeResult, \"reloadTree\">> &\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 * @public\n */\nexport const TreeNodeRenderer: ForwardRefExoticComponent<TreeNodeRendererProps & RefAttributes<HTMLElement>> = forwardRef(\n (\n { node, expandNode, getLabel, getSublabel, onNodeClick, onNodeKeyDown, isNodeSelected, actions, getDecorations, hasError, reloadTree, ...treeItemProps },\n forwardedRef,\n ) => {\n const nodeRef = useRef<HTMLElement>(null);\n const ref = useMergedRefs(forwardedRef, nodeRef);\n const { localizedStrings } = useLocalizationContext();\n\n const childErrorNode = useMemo(() => {\n return !isPlaceholderNode(node) ? hasError?.(node) : false;\n }, [hasError, node]);\n\n if (isPlaceholderNode(node)) {\n return <PlaceholderNode {...treeItemProps} level={node.level} ref={ref} />;\n }\n\n const getActions = () => {\n if (!actions || actions.length === 0) {\n return undefined;\n }\n\n const actionButtons: ReactElement[] = [];\n\n if (childErrorNode && childErrorNode.error.type === \"Unknown\") {\n actionButtons.push(\n <TreeActionButton label={localizedStrings.retry} action={() => reloadTree?.({ parentNodeId: node.id })} show={true} icon={refreshSvg} />,\n );\n }\n\n actionButtons.push(\n ...actions.map((action, index) => {\n const actionInfo = action(node);\n return <TreeActionButton key={index} {...actionInfo} />;\n }),\n );\n\n return actionButtons;\n };\n\n const selected = isNodeSelected(node.id);\n return (\n <Tree.Item\n {...treeItemProps}\n ref={ref}\n aria-level={node.level}\n aria-posinset={node.posInLevel}\n aria-setsize={node.levelSize}\n label={getLabel ? getLabel(node) : node.label}\n description={getSublabel ? getSublabel(node) : undefined}\n selected={selected}\n expanded={node.isExpanded || node.children === true || node.children.length > 0 ? node.isExpanded : undefined}\n onExpandedChange={(isExpanded) => {\n expandNode(node.id, isExpanded);\n }}\n onClick={(event) => {\n !treeItemProps[\"aria-disabled\"] && onNodeClick?.(node, !selected, event);\n }}\n onKeyDown={(event) => {\n // Ignore if it is called on the element inside, e.g. checkbox or expander\n if (!treeItemProps[\"aria-disabled\"] && event.target === nodeRef.current) {\n onNodeKeyDown?.(node, !selected, event);\n }\n }}\n actions={getActions()}\n unstable_decorations={getDecorations && getDecorations(node)}\n error={!!childErrorNode}\n />\n );\n },\n);\nTreeNodeRenderer.displayName = \"TreeNodeRenderer\";\n\nconst PlaceholderNode = forwardRef<\n HTMLDivElement,\n Omit<TreeNodeProps, \"onExpanded\" | \"label\" | \"actions\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\" | \"icon\"> & { level: number }\n>(({ level, ...props }, forwardedRef) => {\n const { localizedStrings } = useLocalizationContext();\n return (\n <Tree.Item\n {...props}\n aria-level={level}\n aria-posinset={1}\n aria-setsize={1}\n ref={forwardedRef}\n label={localizedStrings.loading}\n icon={<Spinner size={\"small\"} title={localizedStrings.loading} />}\n />\n );\n});\nPlaceholderNode.displayName = \"PlaceholderNode\";\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"]}
|
|
@@ -4,6 +4,7 @@ import { PresentationTreeNode } from "../TreeNode.js";
|
|
|
4
4
|
import { SelectionMode } from "../UseSelectionHandler.js";
|
|
5
5
|
import { useTree } from "../UseTree.js";
|
|
6
6
|
import { LocalizationContextProvider } from "./LocalizationContext.js";
|
|
7
|
+
import { TreeErrorItemProps } from "./TreeErrorRenderer.js";
|
|
7
8
|
import { TreeNodeRenderer } from "./TreeNodeRenderer.js";
|
|
8
9
|
/** @alpha */
|
|
9
10
|
export type TreeProps = ComponentPropsWithoutRef<typeof Tree.Root>;
|
|
@@ -17,7 +18,7 @@ interface TreeRendererOwnProps {
|
|
|
17
18
|
selectionMode?: SelectionMode;
|
|
18
19
|
}
|
|
19
20
|
/** @alpha */
|
|
20
|
-
type TreeRendererProps = Pick<ReturnType<typeof useTree>, "expandNode"> & Partial<Pick<ReturnType<typeof useTree>, "selectNodes" | "isNodeSelected" | "getHierarchyLevelDetails" | "reloadTree">> & Omit<TreeNodeRendererProps, "node" | "reloadTree"> & TreeRendererOwnProps & ComponentPropsWithoutRef<typeof LocalizationContextProvider>;
|
|
21
|
+
type TreeRendererProps = Pick<ReturnType<typeof useTree>, "expandNode"> & Partial<Pick<ReturnType<typeof useTree>, "selectNodes" | "isNodeSelected" | "getHierarchyLevelDetails" | "reloadTree">> & Pick<TreeErrorItemProps, "onFilterClick"> & Omit<TreeNodeRendererProps, "node" | "reloadTree"> & TreeRendererOwnProps & ComponentPropsWithoutRef<typeof LocalizationContextProvider>;
|
|
21
22
|
/**
|
|
22
23
|
* A component that renders a tree using the `Tree` component from `@itwin/itwinui-react`. The tree nodes
|
|
23
24
|
* are rendered using `TreeNodeRenderer` component from this package.
|
|
@@ -25,6 +26,6 @@ type TreeRendererProps = Pick<ReturnType<typeof useTree>, "expandNode"> & Partia
|
|
|
25
26
|
* @see https://itwinui.bentley.com/docs/tree
|
|
26
27
|
* @alpha
|
|
27
28
|
*/
|
|
28
|
-
export declare function TreeRenderer({ rootNodes, expandNode, localizedStrings, selectNodes, selectionMode, ...treeProps }: TreeRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export declare function TreeRenderer({ rootNodes, expandNode, localizedStrings, selectNodes, selectionMode, getHierarchyLevelDetails, onFilterClick, reloadTree, ...treeProps }: TreeRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
29
30
|
export {};
|
|
30
31
|
//# sourceMappingURL=TreeRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"TreeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAA2C,MAAM,OAAO,CAAC;AAC1F,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;A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@@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
import { createElement as _createElement } from "react";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
/*---------------------------------------------------------------------------------------------
|
|
4
4
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
5
5
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
6
6
|
*--------------------------------------------------------------------------------------------*/
|
|
7
|
-
import { useMemo, useRef } from "react";
|
|
7
|
+
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
8
8
|
import { Tree } from "@itwin/itwinui-react/bricks";
|
|
9
9
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
10
10
|
import { useSelectionHandler } from "../UseSelectionHandler.js";
|
|
11
|
-
import { flattenNodes } from "./FlatTreeNode.js";
|
|
11
|
+
import { flattenNodes, getErrors } from "./FlatTreeNode.js";
|
|
12
12
|
import { LocalizationContextProvider } from "./LocalizationContext.js";
|
|
13
|
+
import { TreeErrorRenderer } from "./TreeErrorRenderer.js";
|
|
13
14
|
import { TreeNodeRenderer } from "./TreeNodeRenderer.js";
|
|
14
15
|
/**
|
|
15
16
|
* A component that renders a tree using the `Tree` component from `@itwin/itwinui-react`. The tree nodes
|
|
@@ -18,31 +19,61 @@ import { TreeNodeRenderer } from "./TreeNodeRenderer.js";
|
|
|
18
19
|
* @see https://itwinui.bentley.com/docs/tree
|
|
19
20
|
* @alpha
|
|
20
21
|
*/
|
|
21
|
-
export function TreeRenderer({ rootNodes, expandNode, localizedStrings, selectNodes, selectionMode, ...treeProps }) {
|
|
22
|
+
export function TreeRenderer({ rootNodes, expandNode, localizedStrings, selectNodes, selectionMode, getHierarchyLevelDetails, onFilterClick, reloadTree, ...treeProps }) {
|
|
22
23
|
const { onNodeClick, onNodeKeyDown } = useSelectionHandler({
|
|
23
24
|
rootNodes,
|
|
24
25
|
selectNodes: selectNodes ?? noopSelectNodes,
|
|
25
26
|
selectionMode: selectionMode ?? "single",
|
|
26
27
|
});
|
|
28
|
+
const scrollToNode = useRef(undefined);
|
|
27
29
|
const parentRef = useRef(null);
|
|
28
30
|
const flatNodes = useMemo(() => flattenNodes(rootNodes), [rootNodes]);
|
|
31
|
+
const errorList = useMemo(() => getErrors(rootNodes), [rootNodes]);
|
|
32
|
+
const hasError = useCallback((node) => {
|
|
33
|
+
if (node.children === true) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
const error = errorList.find((errorNode) => errorNode.parent?.id === node.id);
|
|
37
|
+
return error;
|
|
38
|
+
}, [errorList]);
|
|
29
39
|
const virtualizer = useVirtualizer({
|
|
30
40
|
count: flatNodes.length,
|
|
31
41
|
getScrollElement: () => parentRef.current,
|
|
42
|
+
getItemKey: (index) => flatNodes[index].id,
|
|
32
43
|
estimateSize: () => 28,
|
|
33
44
|
overscan: 5,
|
|
34
45
|
});
|
|
35
46
|
const items = virtualizer.getVirtualItems();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
const scrollToElement = (errorNode) => {
|
|
48
|
+
const index = flatNodes.findIndex((flatNode) => flatNode.id === errorNode.parent?.id);
|
|
49
|
+
if (index === -1) {
|
|
50
|
+
errorNode.expandTo((nodeId) => expandNode(nodeId, true));
|
|
51
|
+
scrollToNode.current = errorNode.parent?.id;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
virtualizer.scrollToIndex(index, { align: "end" });
|
|
55
|
+
};
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (scrollToNode.current === undefined) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const index = flatNodes.findIndex((flatNode) => flatNode.id === scrollToNode.current);
|
|
61
|
+
if (index === -1) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
virtualizer.scrollToIndex(index, { align: "end" });
|
|
65
|
+
scrollToNode.current = undefined;
|
|
66
|
+
}, [flatNodes, virtualizer]);
|
|
67
|
+
return (_jsxs(LocalizationContextProvider, { localizedStrings: localizedStrings, children: [_jsx(TreeErrorRenderer, { errorList: errorList, scrollToElement: scrollToElement, getHierarchyLevelDetails: getHierarchyLevelDetails, onFilterClick: onFilterClick, reloadTree: reloadTree }), _jsx("div", { style: { height: "100%", width: "100%", overflowY: "auto" }, ref: parentRef, children: _jsx(Tree.Root, { style: { height: virtualizer.getTotalSize(), minHeight: "100%", width: "100%", position: "relative", overflow: "hidden" }, children: items.map((virtualizedItem) => {
|
|
68
|
+
return (_createElement(TreeNodeRenderer, { ...treeProps, ref: virtualizer.measureElement, style: {
|
|
69
|
+
position: "absolute",
|
|
70
|
+
top: 0,
|
|
71
|
+
left: 0,
|
|
72
|
+
width: "100%",
|
|
73
|
+
transform: `translateY(${virtualizedItem.start}px)`,
|
|
74
|
+
willChange: "transform",
|
|
75
|
+
}, expandNode: expandNode, onNodeClick: onNodeClick, onNodeKeyDown: onNodeKeyDown, hasError: hasError, node: flatNodes[virtualizedItem.index], key: virtualizedItem.key, "data-index": virtualizedItem.index, reloadTree: reloadTree }));
|
|
76
|
+
}) }) })] }));
|
|
46
77
|
}
|
|
47
78
|
function noopSelectNodes() { }
|
|
48
79
|
//# sourceMappingURL=TreeRenderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeRenderer.tsx"],"names":[],"mappings":";;AAAA;;;gGAGgG;AAEhG,OAAO,EAA4B,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/itwinui/TreeRenderer.tsx"],"names":[],"mappings":";;AAAA;;;gGAGgG;AAEhG,OAAO,EAA4B,WAAW,EAAE,SAAS,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C,KAAK,KAAK;gCACnD,UAAU,EAAE,WAAW;6BACxB,EACD,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC,EACtC,GAAG,EAAE,eAAe,CAAC,GAAG,gBACZ,eAAe,CAAC,KAAK,EACjC,UAAU,EAAE,UAAU,GACtB,CACH,CAAC;oBACJ,CAAC,CAAC,GACQ,GACR,IACsB,CAC/B,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,KAAI,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 { ComponentPropsWithoutRef, useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { Tree } from \"@itwin/itwinui-react/bricks\";\nimport { useVirtualizer } from \"@tanstack/react-virtual\";\nimport { PresentationHierarchyNode, PresentationTreeNode } from \"../TreeNode.js\";\nimport { SelectionMode, useSelectionHandler } from \"../UseSelectionHandler.js\";\nimport { useTree } from \"../UseTree.js\";\nimport { ErrorNode, flattenNodes, getErrors } from \"./FlatTreeNode.js\";\nimport { LocalizationContextProvider } from \"./LocalizationContext.js\";\nimport { TreeErrorItemProps, TreeErrorRenderer } from \"./TreeErrorRenderer.js\";\nimport { TreeNodeRenderer } from \"./TreeNodeRenderer.js\";\n\n/** @alpha */\nexport type TreeProps = ComponentPropsWithoutRef<typeof Tree.Root>;\n\n/** @alpha */\nexport type TreeNodeRendererProps = ComponentPropsWithoutRef<typeof TreeNodeRenderer>;\n/** @alpha */\ninterface TreeRendererOwnProps {\n /** Root nodes of the tree. */\n rootNodes: PresentationTreeNode[];\n /** Active selection mode used by the tree. Defaults to `\"single\"`. */\n selectionMode?: SelectionMode;\n}\n\n/** @alpha */\ntype TreeRendererProps = Pick<ReturnType<typeof useTree>, \"expandNode\"> &\n Partial<Pick<ReturnType<typeof useTree>, \"selectNodes\" | \"isNodeSelected\" | \"getHierarchyLevelDetails\" | \"reloadTree\">> &\n Pick<TreeErrorItemProps, \"onFilterClick\"> &\n Omit<TreeNodeRendererProps, \"node\" | \"reloadTree\"> &\n TreeRendererOwnProps &\n ComponentPropsWithoutRef<typeof LocalizationContextProvider>;\n\n/**\n * A component that renders a tree using the `Tree` component from `@itwin/itwinui-react`. The tree nodes\n * are rendered using `TreeNodeRenderer` component from this package.\n *\n * @see https://itwinui.bentley.com/docs/tree\n * @alpha\n */\nexport function TreeRenderer({\n rootNodes,\n expandNode,\n localizedStrings,\n selectNodes,\n selectionMode,\n getHierarchyLevelDetails,\n onFilterClick,\n reloadTree,\n ...treeProps\n}: TreeRendererProps) {\n const { onNodeClick, onNodeKeyDown } = useSelectionHandler({\n rootNodes,\n selectNodes: selectNodes ?? noopSelectNodes,\n selectionMode: selectionMode ?? \"single\",\n });\n const scrollToNode = useRef<string | undefined>(undefined);\n const parentRef = useRef<HTMLDivElement>(null);\n const flatNodes = useMemo(() => flattenNodes(rootNodes), [rootNodes]);\n const errorList = useMemo(() => getErrors(rootNodes), [rootNodes]);\n\n const hasError = useCallback(\n (node: PresentationHierarchyNode) => {\n if (node.children === true) {\n return undefined;\n }\n\n const error = errorList.find((errorNode) => errorNode.parent?.id === node.id);\n return error;\n },\n [errorList],\n );\n\n const virtualizer = useVirtualizer({\n count: flatNodes.length,\n getScrollElement: () => parentRef.current,\n getItemKey: (index) => flatNodes[index].id,\n estimateSize: () => 28,\n overscan: 5,\n });\n\n const items = virtualizer.getVirtualItems();\n\n const scrollToElement = (errorNode: ErrorNode) => {\n const index = flatNodes.findIndex((flatNode) => flatNode.id === errorNode.parent?.id);\n if (index === -1) {\n errorNode.expandTo((nodeId) => expandNode(nodeId, true));\n scrollToNode.current = errorNode.parent?.id;\n return;\n }\n virtualizer.scrollToIndex(index, { align: \"end\" });\n };\n\n useEffect(() => {\n if (scrollToNode.current === undefined) {\n return;\n }\n const index = flatNodes.findIndex((flatNode) => flatNode.id === scrollToNode.current);\n if (index === -1) {\n return;\n }\n virtualizer.scrollToIndex(index, { align: \"end\" });\n scrollToNode.current = undefined;\n }, [flatNodes, virtualizer]);\n\n return (\n <LocalizationContextProvider localizedStrings={localizedStrings}>\n <TreeErrorRenderer\n errorList={errorList}\n scrollToElement={scrollToElement}\n getHierarchyLevelDetails={getHierarchyLevelDetails}\n onFilterClick={onFilterClick}\n reloadTree={reloadTree}\n />\n <div style={{ height: \"100%\", width: \"100%\", overflowY: \"auto\" }} ref={parentRef}>\n <Tree.Root style={{ height: virtualizer.getTotalSize(), minHeight: \"100%\", width: \"100%\", position: \"relative\", overflow: \"hidden\" }}>\n {items.map((virtualizedItem) => {\n return (\n <TreeNodeRenderer\n {...treeProps}\n ref={virtualizer.measureElement}\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"100%\",\n transform: `translateY(${virtualizedItem.start}px)`,\n willChange: \"transform\",\n }}\n expandNode={expandNode}\n onNodeClick={onNodeClick}\n onNodeKeyDown={onNodeKeyDown}\n hasError={hasError}\n node={flatNodes[virtualizedItem.index]}\n key={virtualizedItem.key}\n data-index={virtualizedItem.index}\n reloadTree={reloadTree}\n />\n );\n })}\n </Tree.Root>\n </div>\n </LocalizationContextProvider>\n );\n}\n\nfunction noopSelectNodes() {}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-hierarchies-react",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.12",
|
|
4
4
|
"description": "React components based on `@itwin/presentation-hierarchies`",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -37,20 +37,20 @@
|
|
|
37
37
|
"./package.json": "./package.json"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@itwin/core-bentley": "^
|
|
40
|
+
"@itwin/core-bentley": "^4.10.10",
|
|
41
41
|
"@itwin/itwinui-illustrations-react": "^2.1.0",
|
|
42
42
|
"@tanstack/react-virtual": "^3.13.0",
|
|
43
43
|
"classnames": "^2.5.1",
|
|
44
44
|
"immer": "^10.1.1",
|
|
45
45
|
"react-error-boundary": "^4.0.13",
|
|
46
46
|
"rxjs": "^7.8.1",
|
|
47
|
-
"@itwin/
|
|
48
|
-
"@itwin/presentation-
|
|
49
|
-
"@itwin/
|
|
47
|
+
"@itwin/presentation-hierarchies": "^1.4.2",
|
|
48
|
+
"@itwin/presentation-shared": "^1.2.1",
|
|
49
|
+
"@itwin/unified-selection": "^1.4.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@itwin/itwinui-icons": "5.0.0-alpha.4",
|
|
53
|
-
"@itwin/itwinui-react": "5.0.0-alpha.
|
|
53
|
+
"@itwin/itwinui-react": "5.0.0-alpha.13",
|
|
54
54
|
"react": "^17.0.0 || ^18.0.0",
|
|
55
55
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
56
56
|
},
|
|
@@ -64,38 +64,36 @@
|
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@itwin/build-tools": "5.0.0-dev.67",
|
|
67
|
+
"@itwin/eslint-plugin": "5.0.0-dev.1",
|
|
67
68
|
"@itwin/itwinui-icons": "5.0.0-alpha.4",
|
|
68
|
-
"@itwin/itwinui-react": "5.0.0-alpha.
|
|
69
|
-
"@testing-library/dom": "^10.
|
|
70
|
-
"@testing-library/react": "^16.
|
|
71
|
-
"@testing-library/user-event": "^14.
|
|
72
|
-
"@types/chai": "^
|
|
73
|
-
"@types/chai-as-promised": "^
|
|
74
|
-
"@types/chai-subset": "^1.3.5",
|
|
69
|
+
"@itwin/itwinui-react": "5.0.0-alpha.13",
|
|
70
|
+
"@testing-library/dom": "^10.4.0",
|
|
71
|
+
"@testing-library/react": "^16.2.0",
|
|
72
|
+
"@testing-library/user-event": "^14.6.1",
|
|
73
|
+
"@types/chai": "^5.2.0",
|
|
74
|
+
"@types/chai-as-promised": "^8.0.2",
|
|
75
75
|
"@types/jsdom": "^21.1.7",
|
|
76
|
-
"@types/mocha": "^10.0.
|
|
76
|
+
"@types/mocha": "^10.0.10",
|
|
77
77
|
"@types/react": "^18.3.3",
|
|
78
78
|
"@types/react-dom": "^18.3.0",
|
|
79
|
-
"@types/sinon": "^17.0.
|
|
80
|
-
"@types/sinon-chai": "^
|
|
81
|
-
"c8": "^10.1.
|
|
82
|
-
"chai": "^
|
|
83
|
-
"chai-as-promised": "^
|
|
84
|
-
"chai-subset": "^1.6.0",
|
|
79
|
+
"@types/sinon": "^17.0.4",
|
|
80
|
+
"@types/sinon-chai": "^4.0.0",
|
|
81
|
+
"c8": "^10.1.3",
|
|
82
|
+
"chai": "^5.2.0",
|
|
83
|
+
"chai-as-promised": "^8.0.1",
|
|
85
84
|
"cpx2": "^7.0.1",
|
|
86
85
|
"cross-env": "^7.0.3",
|
|
87
86
|
"eslint": "^9.13.0",
|
|
88
|
-
"eslint-plugin-react": "^7.37.
|
|
89
|
-
"global-jsdom": "^
|
|
87
|
+
"eslint-plugin-react": "^7.37.4",
|
|
88
|
+
"global-jsdom": "^26.0.0",
|
|
90
89
|
"ignore-styles": "^5.0.1",
|
|
91
|
-
"jsdom": "^
|
|
92
|
-
"mocha": "^
|
|
90
|
+
"jsdom": "^26.0.0",
|
|
91
|
+
"mocha": "^11.1.0",
|
|
93
92
|
"react": "^18.3.1",
|
|
94
93
|
"react-dom": "^18.3.1",
|
|
95
94
|
"rimraf": "^6.0.1",
|
|
96
|
-
"sinon": "^
|
|
97
|
-
"sinon-chai": "^
|
|
98
|
-
"testdouble": "^3.20.2",
|
|
95
|
+
"sinon": "^19.0.4",
|
|
96
|
+
"sinon-chai": "^4.0.0",
|
|
99
97
|
"typescript": "~5.7.3",
|
|
100
98
|
"presentation-test-utilities": "^0.0.0"
|
|
101
99
|
},
|
|
@@ -106,9 +104,9 @@
|
|
|
106
104
|
"clean": "rimraf lib build",
|
|
107
105
|
"cover": "c8 npm -s test",
|
|
108
106
|
"lint": "eslint ./src/**/*.{ts,tsx}",
|
|
109
|
-
"test:dev": "
|
|
107
|
+
"test:dev": "node --experimental-test-module-mocks --enable-source-maps --import presentation-test-utilities/node-hooks/ignore-styles ./node_modules/mocha/bin/mocha.js --config ./.mocharc.json",
|
|
110
108
|
"test": "npm run test:dev -- --parallel --jobs=4",
|
|
111
|
-
"extract-api": "betools extract-api --entry
|
|
109
|
+
"extract-api": "betools extract-api --entry=lib/esm/presentation-hierarchies-react --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api --includeUnexportedApis",
|
|
112
110
|
"check-internal": "node ../../scripts/checkInternal.js --apiSummary ./api/presentation-hierarchies-react.api.md",
|
|
113
111
|
"update-extractions": "node ../../scripts/updateExtractions.js --targets=./README.md",
|
|
114
112
|
"check-extractions": "node ../../scripts/updateExtractions.js --targets=./README.md --check",
|