@itwin/presentation-hierarchies-react 2.0.0-alpha.52 → 2.0.0-alpha.54
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 +33 -0
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts +62 -55
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts +33 -29
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts +27 -16
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +181 -54
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts +12 -6
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js +54 -49
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +7 -30
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +116 -74
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +67 -54
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.js +283 -226
- package/lib/esm/presentation-hierarchies-react/UseTree.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/Utils.js +44 -27
- package/lib/esm/presentation-hierarchies-react/Utils.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js +6 -7
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +271 -298
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +91 -82
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +3 -47
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +114 -151
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +32 -37
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +128 -101
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js +29 -44
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +24 -13
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +344 -67
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts +16 -15
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js +78 -60
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts +122 -117
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js +59 -38
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +16 -5
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +161 -35
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts +21 -17
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js +84 -31
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +22 -14
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +61 -26
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +15 -6
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +75 -25
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +16 -40
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +140 -61
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +14 -42
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +489 -121
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +58 -55
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js +412 -181
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react.d.ts +17 -17
- package/lib/esm/presentation-hierarchies-react.js +15 -18
- package/package.json +17 -14
- package/lib/esm/presentation-hierarchies-react/Renderers.js +0 -6
- package/lib/esm/presentation-hierarchies-react/Renderers.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.js +0 -6
- package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/Utils.d.ts +0 -8
- package/lib/esm/presentation-hierarchies-react/Utils.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts +0 -2
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +0 -53
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +0 -62
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts +0 -23
- package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react.js.map +0 -1
|
@@ -1,42 +1,168 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
1
|
+
import { useLocalizationContext } from "./LocalizationContext.js";
|
|
2
|
+
import { c } from "react-compiler-runtime";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
4
|
import { Button, Text } from "@stratakit/bricks";
|
|
7
5
|
import { Icon } from "@stratakit/foundations";
|
|
8
6
|
import errorSvg from "@stratakit/icons/status-error.svg";
|
|
9
|
-
|
|
7
|
+
|
|
8
|
+
//#region src/presentation-hierarchies-react/stratakit/RootErrorRenderer.tsx
|
|
10
9
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
10
|
+
* A component that renders root node error state.
|
|
11
|
+
*
|
|
12
|
+
* @alpha
|
|
13
|
+
*/
|
|
14
|
+
function StrataKitRootErrorRenderer(t0) {
|
|
15
|
+
const $ = c(19);
|
|
16
|
+
const { error, getHierarchyLevelDetails, reloadTree } = t0;
|
|
17
|
+
const { localizedStrings } = useLocalizationContext();
|
|
18
|
+
if (error.type === "ResultSetTooLarge") {
|
|
19
|
+
let t1;
|
|
20
|
+
if ($[0] !== getHierarchyLevelDetails) {
|
|
21
|
+
t1 = () => getHierarchyLevelDetails(void 0)?.setSizeLimit("unbounded");
|
|
22
|
+
$[0] = getHierarchyLevelDetails;
|
|
23
|
+
$[1] = t1;
|
|
24
|
+
} else t1 = $[1];
|
|
25
|
+
const onOverrideLimit = t1;
|
|
26
|
+
let t2;
|
|
27
|
+
if ($[2] !== error.resultSetSizeLimit || $[3] !== localizedStrings.rootResultLimitExceeded) {
|
|
28
|
+
t2 = localizedStrings.rootResultLimitExceeded.replace("{{limit}}", error.resultSetSizeLimit.toString());
|
|
29
|
+
$[2] = error.resultSetSizeLimit;
|
|
30
|
+
$[3] = localizedStrings.rootResultLimitExceeded;
|
|
31
|
+
$[4] = t2;
|
|
32
|
+
} else t2 = $[4];
|
|
33
|
+
let t3;
|
|
34
|
+
if ($[5] !== localizedStrings.increaseHierarchyLimitToUnlimited || $[6] !== onOverrideLimit) {
|
|
35
|
+
t3 = [{
|
|
36
|
+
action: onOverrideLimit,
|
|
37
|
+
label: localizedStrings.increaseHierarchyLimitToUnlimited,
|
|
38
|
+
condition: _temp
|
|
39
|
+
}];
|
|
40
|
+
$[5] = localizedStrings.increaseHierarchyLimitToUnlimited;
|
|
41
|
+
$[6] = onOverrideLimit;
|
|
42
|
+
$[7] = t3;
|
|
43
|
+
} else t3 = $[7];
|
|
44
|
+
let t4;
|
|
45
|
+
if ($[8] !== t2 || $[9] !== t3) {
|
|
46
|
+
t4 = /* @__PURE__ */ jsx(RootErrorContainer, {
|
|
47
|
+
message: t2,
|
|
48
|
+
actions: t3
|
|
49
|
+
});
|
|
50
|
+
$[8] = t2;
|
|
51
|
+
$[9] = t3;
|
|
52
|
+
$[10] = t4;
|
|
53
|
+
} else t4 = $[10];
|
|
54
|
+
return t4;
|
|
55
|
+
}
|
|
56
|
+
let t1;
|
|
57
|
+
if ($[11] !== reloadTree) {
|
|
58
|
+
t1 = () => reloadTree({
|
|
59
|
+
parentNodeId: void 0,
|
|
60
|
+
state: "reset"
|
|
61
|
+
});
|
|
62
|
+
$[11] = reloadTree;
|
|
63
|
+
$[12] = t1;
|
|
64
|
+
} else t1 = $[12];
|
|
65
|
+
let t2;
|
|
66
|
+
if ($[13] !== localizedStrings.retry || $[14] !== t1) {
|
|
67
|
+
t2 = [{
|
|
68
|
+
action: t1,
|
|
69
|
+
label: localizedStrings.retry,
|
|
70
|
+
condition: _temp2
|
|
71
|
+
}];
|
|
72
|
+
$[13] = localizedStrings.retry;
|
|
73
|
+
$[14] = t1;
|
|
74
|
+
$[15] = t2;
|
|
75
|
+
} else t2 = $[15];
|
|
76
|
+
let t3;
|
|
77
|
+
if ($[16] !== localizedStrings.failedToCreateRootHierarchy || $[17] !== t2) {
|
|
78
|
+
t3 = /* @__PURE__ */ jsx(RootErrorContainer, {
|
|
79
|
+
message: localizedStrings.failedToCreateRootHierarchy,
|
|
80
|
+
actions: t2
|
|
81
|
+
});
|
|
82
|
+
$[16] = localizedStrings.failedToCreateRootHierarchy;
|
|
83
|
+
$[17] = t2;
|
|
84
|
+
$[18] = t3;
|
|
85
|
+
} else t3 = $[18];
|
|
86
|
+
return t3;
|
|
87
|
+
}
|
|
88
|
+
function _temp2() {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
function _temp() {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
function RootErrorContainer(t0) {
|
|
95
|
+
const $ = c(10);
|
|
96
|
+
const { actions, message } = t0;
|
|
97
|
+
let t1;
|
|
98
|
+
let t2;
|
|
99
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
100
|
+
t1 = {
|
|
101
|
+
height: "100%",
|
|
102
|
+
display: "flex",
|
|
103
|
+
flexDirection: "column",
|
|
104
|
+
justifyContent: "center",
|
|
105
|
+
alignItems: "center",
|
|
106
|
+
gap: "0.5rem"
|
|
107
|
+
};
|
|
108
|
+
t2 = /* @__PURE__ */ jsx(Icon, {
|
|
109
|
+
href: errorSvg,
|
|
110
|
+
size: "large"
|
|
111
|
+
});
|
|
112
|
+
$[0] = t1;
|
|
113
|
+
$[1] = t2;
|
|
114
|
+
} else {
|
|
115
|
+
t1 = $[0];
|
|
116
|
+
t2 = $[1];
|
|
117
|
+
}
|
|
118
|
+
let t3;
|
|
119
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
120
|
+
t3 = { textAlign: "center" };
|
|
121
|
+
$[2] = t3;
|
|
122
|
+
} else t3 = $[2];
|
|
123
|
+
let t4;
|
|
124
|
+
if ($[3] !== message) {
|
|
125
|
+
t4 = /* @__PURE__ */ jsx(Text, {
|
|
126
|
+
variant: "body-sm",
|
|
127
|
+
style: t3,
|
|
128
|
+
children: message
|
|
129
|
+
});
|
|
130
|
+
$[3] = message;
|
|
131
|
+
$[4] = t4;
|
|
132
|
+
} else t4 = $[4];
|
|
133
|
+
let t5;
|
|
134
|
+
if ($[5] !== actions) {
|
|
135
|
+
t5 = actions?.filter(_temp3).map(_temp4);
|
|
136
|
+
$[5] = actions;
|
|
137
|
+
$[6] = t5;
|
|
138
|
+
} else t5 = $[6];
|
|
139
|
+
let t6;
|
|
140
|
+
if ($[7] !== t4 || $[8] !== t5) {
|
|
141
|
+
t6 = /* @__PURE__ */ jsxs("div", {
|
|
142
|
+
style: t1,
|
|
143
|
+
children: [
|
|
144
|
+
t2,
|
|
145
|
+
t4,
|
|
146
|
+
t5
|
|
147
|
+
]
|
|
148
|
+
});
|
|
149
|
+
$[7] = t4;
|
|
150
|
+
$[8] = t5;
|
|
151
|
+
$[9] = t6;
|
|
152
|
+
} else t6 = $[9];
|
|
153
|
+
return t6;
|
|
154
|
+
}
|
|
155
|
+
function _temp4(action) {
|
|
156
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
157
|
+
onClick: () => action.action(),
|
|
158
|
+
children: action.label
|
|
159
|
+
}, action.label);
|
|
34
160
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.map((action) => {
|
|
39
|
-
return (_jsx(Button, { onClick: () => action.action(), children: action.label }, action.label));
|
|
40
|
-
})] }));
|
|
161
|
+
function _temp3(t0) {
|
|
162
|
+
const { condition } = t0;
|
|
163
|
+
return condition();
|
|
41
164
|
}
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
export { StrataKitRootErrorRenderer };
|
|
42
168
|
//# sourceMappingURL=RootErrorRenderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RootErrorRenderer.js","
|
|
1
|
+
{"version":3,"file":"RootErrorRenderer.js","names":["Button","Text","Icon","errorSvg","useLocalizationContext","JSX","RootErrorRendererProps","ErrorInfo","StrataKitRootErrorRendererProps","error","StrataKitRootErrorRenderer","t0","$","_c","getHierarchyLevelDetails","reloadTree","localizedStrings","type","t1","undefined","setSizeLimit","onOverrideLimit","t2","resultSetSizeLimit","rootResultLimitExceeded","replace","toString","t3","increaseHierarchyLimitToUnlimited","action","label","condition","_temp","t4","parentNodeId","state","retry","_temp2","failedToCreateRootHierarchy","RootErrorContainerProps","message","actions","RootErrorContainer","Symbol","for","height","display","flexDirection","justifyContent","alignItems","gap","textAlign","t5","filter","_temp3","map","_temp4","t6"],"sources":["../../../../src/presentation-hierarchies-react/stratakit/RootErrorRenderer.tsx"],"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 { Button, Text } from \"@stratakit/bricks\";\nimport { Icon } from \"@stratakit/foundations\";\nimport errorSvg from \"@stratakit/icons/status-error.svg\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\n\nimport type { JSX } from \"react\";\nimport type { RootErrorRendererProps } from \"../Renderers.js\";\nimport type { ErrorInfo } from \"../TreeNode.js\";\n\n/**\n * @alpha\n */\nexport type StrataKitRootErrorRendererProps = {\n /**\n * Root error to be displayed\n */\n error: ErrorInfo;\n} & RootErrorRendererProps;\n\n/**\n * A component that renders root node error state.\n *\n * @alpha\n */\nexport function StrataKitRootErrorRenderer({ error, getHierarchyLevelDetails, reloadTree }: StrataKitRootErrorRendererProps): JSX.Element {\n const { localizedStrings } = useLocalizationContext();\n\n if (error.type === \"ResultSetTooLarge\") {\n const onOverrideLimit = () => getHierarchyLevelDetails(undefined)?.setSizeLimit(\"unbounded\");\n return (\n <RootErrorContainer\n message={localizedStrings.rootResultLimitExceeded.replace(\"{{limit}}\", error.resultSetSizeLimit.toString())}\n actions={[\n {\n action: onOverrideLimit,\n label: localizedStrings.increaseHierarchyLimitToUnlimited,\n condition: () => true,\n },\n ]}\n />\n );\n }\n\n return (\n <RootErrorContainer\n message={localizedStrings.failedToCreateRootHierarchy}\n actions={[\n {\n action: () => reloadTree({ parentNodeId: undefined, state: \"reset\" }),\n label: localizedStrings.retry,\n condition: () => true,\n },\n ]}\n />\n );\n}\n\ninterface RootErrorContainerProps {\n message: string;\n actions?: { action: () => void; label: string; condition: () => boolean }[];\n}\n\nfunction RootErrorContainer({ actions, message }: RootErrorContainerProps) {\n return (\n <div style={{ height: \"100%\", display: \"flex\", flexDirection: \"column\", justifyContent: \"center\", alignItems: \"center\", gap: \"0.5rem\" }}>\n <Icon href={errorSvg} size=\"large\" />\n <Text variant={\"body-sm\"} style={{ textAlign: \"center\" }}>\n {message}\n </Text>\n {actions\n ?.filter(({ condition }) => condition())\n .map((action) => {\n return (\n <Button key={action.label} onClick={() => action.action()}>\n {action.label}\n </Button>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA6BA,SAAOU,2BAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAoC,MAAA,EAAAJ,OAAAK,0BAAAC,eAAAJ;CACzC,MAAA,EAAAK,qBAA6BZ,wBAAwB;AAErD,KAAIK,MAAKQ,SAAU,qBAAmB;EAAA,IAAAC;AAAA,MAAAN,EAAA,OAAAE,0BAAA;AACZI,cAAMJ,yBAAyBK,OAAwB,EAAAC,aAAC,YAAY;AAAAR,KAAA,KAAAE;AAAAF,KAAA,KAAAM;QAAAA,MAAAN,EAAA;EAA5F,MAAAS,kBAAwBH;EAAqE,IAAAI;AAAA,MAAAV,EAAA,OAAAH,MAAAc,sBAAAX,EAAA,OAAAI,iBAAAQ,yBAAA;AA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;AAAArB,IAAA,KAAAwC;AAAAxC,IAAA,KAAA6C;OAAAA,MAAA7C,EAAA;AAAA,QAdN6C;;AAFJ,SAAAD,OAAA3B,QAAA;AAAA,QAWY,oBAAC;EAAmC,eAAMA,OAAMA,QAAQ;YACrDA,OAAMC;IADID,OAAMC,MAEV;;AAbrB,SAAAwB,OAAA3C,IAAA;CAQkB,MAAA,EAAAoB,cAAApB;AAAa,QAAKoB,WAAW"}
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import { ComponentProps } from "react";
|
|
1
|
+
import { ComponentProps, NamedExoticComponent } from "react";
|
|
2
2
|
import { Tree } from "@stratakit/structures";
|
|
3
|
+
|
|
4
|
+
//#region src/presentation-hierarchies-react/stratakit/TreeAction.d.ts
|
|
3
5
|
/**
|
|
4
6
|
* Attributes used to decide how to render tree actions. They allow to differentiate action style based on the context
|
|
5
7
|
* where that action is used.
|
|
6
8
|
* @alpha
|
|
7
9
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
interface TreeActionBaseAttributes {
|
|
11
|
+
/**
|
|
12
|
+
* Specifies action variant supported by tree nodes:
|
|
13
|
+
*
|
|
14
|
+
* - "default" - standard action displayed in the dropdown menu accessible through the ellipsis button on the node.
|
|
15
|
+
* - "inline" - actions displayed directly on the tree node.
|
|
16
|
+
* - "context-menu" - actions displayed in the context menu opened by right-clicking the tree node.
|
|
17
|
+
*/
|
|
18
|
+
variant?: "default" | "inline" | "context-menu";
|
|
19
|
+
/**
|
|
20
|
+
* Indicates that the actions is not applicable for current tree node and should be hidden.
|
|
21
|
+
* When set to true, the action will not be rendered at all.
|
|
22
|
+
*/
|
|
23
|
+
hide?: boolean;
|
|
22
24
|
}
|
|
23
25
|
/** @alpha */
|
|
24
|
-
|
|
26
|
+
type TreeActionBaseProps = ComponentProps<typeof Tree.ItemAction> & TreeActionBaseAttributes;
|
|
25
27
|
/**
|
|
26
28
|
* Base component used to render tree actions. It is designed to allow rendering same action in different contexts: inline, dropdown, context menu.
|
|
27
29
|
* Should be used together with `StrataKitTreeNodeRenderer` and returned from `getInlineActions`, `getMenuActions` and `getContextMenuActions` callbacks.
|
|
@@ -41,5 +43,7 @@ export type TreeActionBaseProps = ComponentProps<typeof Tree.ItemAction> & TreeA
|
|
|
41
43
|
*
|
|
42
44
|
* @alpha
|
|
43
45
|
*/
|
|
44
|
-
|
|
46
|
+
declare const TreeActionBase: NamedExoticComponent<TreeActionBaseProps>;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { TreeActionBase, TreeActionBaseAttributes };
|
|
45
49
|
//# sourceMappingURL=TreeAction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeAction.d.ts","
|
|
1
|
+
{"version":3,"file":"TreeAction.d.ts","names":[],"sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeAction.tsx"],"mappings":";;;;;;AAeA;;;UAAiB,wBAAA;EAaX;AAIN;;;;;;EATE,OAAA;EASiG;;;;EAJjG,IAAA;AAAA;;KAIU,mBAAA,GAAsB,cAAA,QAAsB,IAAA,CAAK,UAAA,IAAc,wBAAA;;;;;;;;;;;;;;;;;;;;cAqB9D,cAAA,EAAgB,oBAAA,CAAqB,mBAAA"}
|
|
@@ -1,36 +1,89 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
1
|
+
import { c } from "react-compiler-runtime";
|
|
6
2
|
import { memo } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
4
|
import { DropdownMenu, Tree } from "@stratakit/structures";
|
|
5
|
+
|
|
6
|
+
//#region src/presentation-hierarchies-react/stratakit/TreeAction.tsx
|
|
8
7
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
8
|
+
* Base component used to render tree actions. It is designed to allow rendering same action in different contexts: inline, dropdown, context menu.
|
|
9
|
+
* Should be used together with `StrataKitTreeNodeRenderer` and returned from `getInlineActions`, `getMenuActions` and `getContextMenuActions` callbacks.
|
|
10
|
+
*
|
|
11
|
+
* When implementing custom action that returns this component, make sure to forward `TreeActionBaseAttributes` props to it. Example:
|
|
12
|
+
*
|
|
13
|
+
* ```tsx
|
|
14
|
+
* interface MyCustomTreeActionProps extends TreeActionBaseAttributes {
|
|
15
|
+
* myProp: string
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* function MyCustomTreeAction({ myProp, ...attributes }: MyCustomTreeActionProps) {
|
|
19
|
+
* // custom button logic goes here
|
|
20
|
+
* return <TreeActionBase {...attributes} icon={...} onClick={...} />
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @alpha
|
|
25
|
+
*/
|
|
26
|
+
const TreeActionBase = memo(function TreeActionBase(t0) {
|
|
27
|
+
const $ = c(15);
|
|
28
|
+
let actionProps;
|
|
29
|
+
let dot;
|
|
30
|
+
let hide;
|
|
31
|
+
let t1;
|
|
32
|
+
let visible;
|
|
33
|
+
if ($[0] !== t0) {
|
|
34
|
+
({hide, variant: t1, dot, visible, ...actionProps} = t0);
|
|
35
|
+
$[0] = t0;
|
|
36
|
+
$[1] = actionProps;
|
|
37
|
+
$[2] = dot;
|
|
38
|
+
$[3] = hide;
|
|
39
|
+
$[4] = t1;
|
|
40
|
+
$[5] = visible;
|
|
41
|
+
} else {
|
|
42
|
+
actionProps = $[1];
|
|
43
|
+
dot = $[2];
|
|
44
|
+
hide = $[3];
|
|
45
|
+
t1 = $[4];
|
|
46
|
+
visible = $[5];
|
|
47
|
+
}
|
|
48
|
+
const variant = t1 === void 0 ? "default" : t1;
|
|
49
|
+
if (hide) {
|
|
50
|
+
let t2;
|
|
51
|
+
if ($[6] !== actionProps || $[7] !== variant) {
|
|
52
|
+
t2 = variant === "inline" ? /* @__PURE__ */ jsx(Tree.ItemAction, {
|
|
53
|
+
...actionProps,
|
|
54
|
+
visible: false
|
|
55
|
+
}) : void 0;
|
|
56
|
+
$[6] = actionProps;
|
|
57
|
+
$[7] = variant;
|
|
58
|
+
$[8] = t2;
|
|
59
|
+
} else t2 = $[8];
|
|
60
|
+
return t2;
|
|
61
|
+
}
|
|
62
|
+
if (variant === "context-menu") {
|
|
63
|
+
let t2;
|
|
64
|
+
if ($[9] !== actionProps) {
|
|
65
|
+
t2 = /* @__PURE__ */ jsx(DropdownMenu.Item, { ...actionProps });
|
|
66
|
+
$[9] = actionProps;
|
|
67
|
+
$[10] = t2;
|
|
68
|
+
} else t2 = $[10];
|
|
69
|
+
return t2;
|
|
70
|
+
}
|
|
71
|
+
const t2 = variant === "inline" ? visible : void 0;
|
|
72
|
+
let t3;
|
|
73
|
+
if ($[11] !== actionProps || $[12] !== dot || $[13] !== t2) {
|
|
74
|
+
t3 = /* @__PURE__ */ jsx(Tree.ItemAction, {
|
|
75
|
+
...actionProps,
|
|
76
|
+
dot,
|
|
77
|
+
visible: t2
|
|
78
|
+
});
|
|
79
|
+
$[11] = actionProps;
|
|
80
|
+
$[12] = dot;
|
|
81
|
+
$[13] = t2;
|
|
82
|
+
$[14] = t3;
|
|
83
|
+
} else t3 = $[14];
|
|
84
|
+
return t3;
|
|
35
85
|
});
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
export { TreeActionBase };
|
|
36
89
|
//# sourceMappingURL=TreeAction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeAction.js","
|
|
1
|
+
{"version":3,"file":"TreeAction.js","names":["memo","DropdownMenu","Tree","ComponentProps","NamedExoticComponent","TreeActionBaseAttributes","variant","hide","TreeActionBaseProps","ItemAction","TreeActionBase","t0","$","_c","actionProps","dot","t1","visible","undefined","t2","t3"],"sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeAction.tsx"],"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 { memo } from \"react\";\nimport { DropdownMenu, Tree } from \"@stratakit/structures\";\n\nimport type { ComponentProps, NamedExoticComponent } from \"react\";\n\n/**\n * Attributes used to decide how to render tree actions. They allow to differentiate action style based on the context\n * where that action is used.\n * @alpha\n */\nexport interface TreeActionBaseAttributes {\n /**\n * Specifies action variant supported by tree nodes:\n *\n * - \"default\" - standard action displayed in the dropdown menu accessible through the ellipsis button on the node.\n * - \"inline\" - actions displayed directly on the tree node.\n * - \"context-menu\" - actions displayed in the context menu opened by right-clicking the tree node.\n */\n variant?: \"default\" | \"inline\" | \"context-menu\";\n /**\n * Indicates that the actions is not applicable for current tree node and should be hidden.\n * When set to true, the action will not be rendered at all.\n */\n hide?: boolean;\n}\n\n/** @alpha */\nexport type TreeActionBaseProps = ComponentProps<typeof Tree.ItemAction> & TreeActionBaseAttributes;\n\n/**\n * Base component used to render tree actions. It is designed to allow rendering same action in different contexts: inline, dropdown, context menu.\n * Should be used together with `StrataKitTreeNodeRenderer` and returned from `getInlineActions`, `getMenuActions` and `getContextMenuActions` callbacks.\n *\n * When implementing custom action that returns this component, make sure to forward `TreeActionBaseAttributes` props to it. Example:\n *\n * ```tsx\n * interface MyCustomTreeActionProps extends TreeActionBaseAttributes {\n * myProp: string\n * }\n *\n * function MyCustomTreeAction({ myProp, ...attributes }: MyCustomTreeActionProps) {\n * // custom button logic goes here\n * return <TreeActionBase {...attributes} icon={...} onClick={...} />\n * }\n * ```\n *\n * @alpha\n */\nexport const TreeActionBase: NamedExoticComponent<TreeActionBaseProps> = memo(function TreeActionBase({\n hide,\n variant = \"default\",\n dot,\n visible,\n ...actionProps\n}: TreeActionBaseProps) {\n if (hide) {\n return variant === \"inline\" ? <Tree.ItemAction {...actionProps} visible={false} /> : undefined;\n }\n\n if (variant === \"context-menu\") {\n return <DropdownMenu.Item {...actionProps} />;\n }\n\n return <Tree.ItemAction {...actionProps} dot={dot} visible={variant === \"inline\" ? visible : undefined} />;\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,MAAaU,iBAA4DV,KAAK,SAAAU,eAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAR;CAAA,IAAAS;CAAA,IAAAC;AAAA,KAAAL,EAAA,OAAAD,IAAA;AAAwB,GAAA,CAAAJ,MAAAD,SAAAU,IAAAD,KAAAE,YAAAH,eAAAH;AAMhFC,IAAA,KAAAD;AAAAC,IAAA,KAAAE;AAAAF,IAAA,KAAAG;AAAAH,IAAA,KAAAL;AAAAK,IAAA,KAAAI;AAAAJ,IAAA,KAAAK;QAAA;AAAAH,gBAAAF,EAAA;AAAAG,QAAAH,EAAA;AAAAL,SAAAK,EAAA;AAAAI,OAAAJ,EAAA;AAAAK,YAAAL,EAAA;;CAJpB,MAAAN,UAAAU,OAAAE,SAAA,YAAAF;AAKA,KAAIT,MAAI;EAAA,IAAAY;AAAA,MAAAP,EAAA,OAAAE,eAAAF,EAAA,OAAAN,SAAA;AACCa,QAAAb,YAAY,WAAW,oBAAA,KAAA;IAAA,GAAqBQ;IAAsB,SAAA;KAAqB,GAAvFI;AAAuFN,KAAA,KAAAE;AAAAF,KAAA,KAAAN;AAAAM,KAAA,KAAAO;QAAAA,MAAAP,EAAA;AAAA,SAAvFO;;AAGT,KAAIb,YAAY,gBAAc;EAAA,IAAAa;AAAA,MAAAP,EAAA,OAAAE,aAAA;AACrBK,QAAA,oBAAA,aAAA,QAAA,GAAuBL,cAAe;AAAAF,KAAA,KAAAE;AAAAF,KAAA,MAAAO;QAAAA,MAAAP,EAAA;AAAA,SAAtCO;;CAGmD,MAAAA,KAAAb,YAAY,WAAZW,UAAAC;CAA0C,IAAAE;AAAA,KAAAR,EAAA,QAAAE,eAAAF,EAAA,QAAAG,OAAAH,EAAA,QAAAO,IAAA;AAA/FC,OAAA,oBAAA,KAAA;GAAA,GAAqBN;GAAkBC;GAAc,SAAAI;IAA8C;AAAAP,IAAA,MAAAE;AAAAF,IAAA,MAAAG;AAAAH,IAAA,MAAAO;AAAAP,IAAA,MAAAQ;OAAAA,MAAAR,EAAA;AAAA,QAAnGQ;EACP"}
|
|
@@ -1,30 +1,38 @@
|
|
|
1
|
-
import { ReactElement } from "react";
|
|
2
|
-
import { ErrorItemRendererProps } from "./ErrorItemRenderer.js";
|
|
3
1
|
import { useErrorNodes } from "./FlatTreeNode.js";
|
|
2
|
+
import { ErrorItemRendererProps } from "./ErrorItemRenderer.js";
|
|
3
|
+
import { JSX, ReactElement } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts
|
|
4
6
|
/**
|
|
5
7
|
* Interface containing building blocks for `TreeErrorRenderer`.
|
|
6
8
|
*
|
|
7
9
|
* @alpha
|
|
8
10
|
*/
|
|
9
11
|
interface TreeErrorRendererOwnProps {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
/**
|
|
13
|
+
* A user friendly display label of the tree. Should be unique within the consuming application,
|
|
14
|
+
* as it's used for creating a unique accessible label for the error region.
|
|
15
|
+
*/
|
|
16
|
+
treeLabel: string;
|
|
17
|
+
/** List of error nodes to render errors for. */
|
|
18
|
+
errorNodes: ReturnType<typeof useErrorNodes>;
|
|
19
|
+
/** Callback to render custom error messages. Component should be wrapped in `ErrorRegion.Item` from `@itwin/itwinui-react` package. */
|
|
20
|
+
renderError?: (props: ErrorItemRendererProps) => ReactElement;
|
|
19
21
|
}
|
|
20
22
|
/** @alpha */
|
|
21
|
-
|
|
23
|
+
type TreeErrorRendererProps = TreeErrorRendererOwnProps & Omit<ErrorItemRendererProps, "errorNode">;
|
|
22
24
|
/**
|
|
23
25
|
* A component that renders error display dropdown using the `unstable_ErrorRegion` component from `@itwin/itwinui-react`.
|
|
24
26
|
* As input, the component uses a list of `ErrorNode` objects, which are generally created using the `useErrorList` hook.
|
|
25
27
|
*
|
|
26
28
|
* @alpha
|
|
27
29
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
declare function TreeErrorRenderer({
|
|
31
|
+
treeLabel,
|
|
32
|
+
errorNodes,
|
|
33
|
+
renderError,
|
|
34
|
+
...errorItemRendererProps
|
|
35
|
+
}: TreeErrorRendererProps): JSX.Element;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { TreeErrorRenderer, TreeErrorRendererProps };
|
|
30
38
|
//# sourceMappingURL=TreeErrorRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeErrorRenderer.d.ts","
|
|
1
|
+
{"version":3,"file":"TreeErrorRenderer.d.ts","names":[],"sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx"],"mappings":";;;;;;;AAYuD;;;UAO7C,yBAAA;EAOI;;;;EAFZ,SAAA;EAAA;EAEA,UAAA,EAAY,UAAA,QAAkB,aAAA;EAAlB;EAEZ,WAAA,IAAe,KAAA,EAAO,sBAAA,KAA2B,YAAA;AAAA;;KAIvC,sBAAA,GAAyB,yBAAA,GAA4B,IAAA,CAAK,sBAAA;;;;AAAtE;;;iBAQgB,iBAAA,CAAA;EAAoB,SAAA;EAAW,UAAA;EAAY,WAAA;EAAA,GAAgB;AAAA,GAA0B,sBAAA,GAAyB,GAAA,CAAI,OAAA"}
|
|
@@ -1,30 +1,65 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
import { cloneElement } from "react";
|
|
7
|
-
import { unstable_ErrorRegion as ErrorRegion } from "@stratakit/structures";
|
|
8
|
-
import { ErrorItemRenderer } from "./ErrorItemRenderer.js";
|
|
9
1
|
import { useLocalizationContext } from "./LocalizationContext.js";
|
|
2
|
+
import { ErrorItemRenderer } from "./ErrorItemRenderer.js";
|
|
3
|
+
import { c } from "react-compiler-runtime";
|
|
4
|
+
import { cloneElement } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { unstable_ErrorRegion } from "@stratakit/structures";
|
|
7
|
+
|
|
8
|
+
//#region src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx
|
|
10
9
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
10
|
+
* A component that renders error display dropdown using the `unstable_ErrorRegion` component from `@itwin/itwinui-react`.
|
|
11
|
+
* As input, the component uses a list of `ErrorNode` objects, which are generally created using the `useErrorList` hook.
|
|
12
|
+
*
|
|
13
|
+
* @alpha
|
|
14
|
+
*/
|
|
15
|
+
function TreeErrorRenderer(t0) {
|
|
16
|
+
const $ = c(12);
|
|
17
|
+
const { treeLabel, errorNodes, renderError, ...errorItemRendererProps } = t0;
|
|
18
|
+
const { localizedStrings } = useLocalizationContext();
|
|
19
|
+
const errorItems = errorNodes.map((errorNode) => {
|
|
20
|
+
const errorRendererProps = {
|
|
21
|
+
errorNode,
|
|
22
|
+
...errorItemRendererProps
|
|
23
|
+
};
|
|
24
|
+
if (renderError) return cloneElement(renderError(errorRendererProps), { key: errorNode.id });
|
|
25
|
+
return /* @__PURE__ */ jsx(ErrorItemRenderer, { ...errorRendererProps }, errorNode.id);
|
|
26
|
+
});
|
|
27
|
+
let t1;
|
|
28
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
29
|
+
t1 = { width: "100%" };
|
|
30
|
+
$[0] = t1;
|
|
31
|
+
} else t1 = $[0];
|
|
32
|
+
let t2;
|
|
33
|
+
if ($[1] !== localizedStrings.issuesForTree || $[2] !== treeLabel) {
|
|
34
|
+
t2 = localizedStrings.issuesForTree.replace("{{tree_label}}", treeLabel);
|
|
35
|
+
$[1] = localizedStrings.issuesForTree;
|
|
36
|
+
$[2] = treeLabel;
|
|
37
|
+
$[3] = t2;
|
|
38
|
+
} else t2 = $[3];
|
|
39
|
+
let t3;
|
|
40
|
+
if ($[4] !== errorNodes.length || $[5] !== localizedStrings.issuesFound || $[6] !== localizedStrings.noIssuesFound) {
|
|
41
|
+
t3 = errorNodes.length === 0 ? localizedStrings.noIssuesFound : localizedStrings.issuesFound.replace("{{number_of_issues}}", errorNodes.length.toString());
|
|
42
|
+
$[4] = errorNodes.length;
|
|
43
|
+
$[5] = localizedStrings.issuesFound;
|
|
44
|
+
$[6] = localizedStrings.noIssuesFound;
|
|
45
|
+
$[7] = t3;
|
|
46
|
+
} else t3 = $[7];
|
|
47
|
+
let t4;
|
|
48
|
+
if ($[8] !== errorItems || $[9] !== t2 || $[10] !== t3) {
|
|
49
|
+
t4 = /* @__PURE__ */ jsx(unstable_ErrorRegion.Root, {
|
|
50
|
+
style: t1,
|
|
51
|
+
"aria-label": t2,
|
|
52
|
+
label: t3,
|
|
53
|
+
items: errorItems
|
|
54
|
+
});
|
|
55
|
+
$[8] = errorItems;
|
|
56
|
+
$[9] = t2;
|
|
57
|
+
$[10] = t3;
|
|
58
|
+
$[11] = t4;
|
|
59
|
+
} else t4 = $[11];
|
|
60
|
+
return t4;
|
|
29
61
|
}
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
export { TreeErrorRenderer };
|
|
30
65
|
//# sourceMappingURL=TreeErrorRenderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeErrorRenderer.js","
|
|
1
|
+
{"version":3,"file":"TreeErrorRenderer.js","names":["cloneElement","unstable_ErrorRegion","ErrorRegion","ErrorItemRenderer","useLocalizationContext","JSX","ReactElement","ErrorItemRendererProps","useErrorNodes","TreeErrorRendererOwnProps","treeLabel","errorNodes","ReturnType","renderError","props","TreeErrorRendererProps","Omit","TreeErrorRenderer","t0","$","_c","errorItemRendererProps","localizedStrings","errorItems","map","errorNode","errorRendererProps","key","id","t1","Symbol","for","width","t2","issuesForTree","replace","t3","length","issuesFound","noIssuesFound","toString","t4"],"sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx"],"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 { cloneElement } from \"react\";\nimport { unstable_ErrorRegion as ErrorRegion } from \"@stratakit/structures\";\nimport { ErrorItemRenderer } from \"./ErrorItemRenderer.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\n\nimport type { JSX, ReactElement } from \"react\";\nimport type { ErrorItemRendererProps } from \"./ErrorItemRenderer.js\";\nimport type { useErrorNodes } from \"./FlatTreeNode.js\";\n\n/**\n * Interface containing building blocks for `TreeErrorRenderer`.\n *\n * @alpha\n */\ninterface TreeErrorRendererOwnProps {\n /**\n * A user friendly display label of the tree. Should be unique within the consuming application,\n * as it's used for creating a unique accessible label for the error region.\n */\n treeLabel: string;\n /** List of error nodes to render errors for. */\n errorNodes: ReturnType<typeof useErrorNodes>;\n /** Callback to render custom error messages. Component should be wrapped in `ErrorRegion.Item` from `@itwin/itwinui-react` package. */\n renderError?: (props: ErrorItemRendererProps) => ReactElement;\n}\n\n/** @alpha */\nexport type TreeErrorRendererProps = TreeErrorRendererOwnProps & Omit<ErrorItemRendererProps, \"errorNode\">;\n\n/**\n * A component that renders error display dropdown using the `unstable_ErrorRegion` component from `@itwin/itwinui-react`.\n * As input, the component uses a list of `ErrorNode` objects, which are generally created using the `useErrorList` hook.\n *\n * @alpha\n */\nexport function TreeErrorRenderer({ treeLabel, errorNodes, renderError, ...errorItemRendererProps }: TreeErrorRendererProps): JSX.Element {\n const { localizedStrings } = useLocalizationContext();\n const errorItems = errorNodes.map((errorNode) => {\n const errorRendererProps: ErrorItemRendererProps = {\n errorNode,\n ...errorItemRendererProps,\n };\n\n if (renderError) {\n return cloneElement(renderError(errorRendererProps), { key: errorNode.id });\n }\n\n return <ErrorItemRenderer key={errorNode.id} {...errorRendererProps} />;\n });\n\n return (\n <ErrorRegion.Root\n style={{ width: \"100%\" }}\n aria-label={localizedStrings.issuesForTree.replace(\"{{tree_label}}\", treeLabel)}\n label={\n errorNodes.length === 0 ? localizedStrings.noIssuesFound : localizedStrings.issuesFound.replace(\"{{number_of_issues}}\", errorNodes.length.toString())\n }\n items={errorItems}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAwCA,SAAOiB,kBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAA2B,MAAA,EAAAV,WAAAC,YAAAE,aAAA,GAAAQ,2BAAAH;CAChC,MAAA,EAAAI,qBAA6BlB,wBAAwB;CACrD,MAAAmB,aAAmBZ,WAAUa,KAAKC,cAAA;EAChC,MAAAC,qBAAmD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