@itwin/presentation-hierarchies-react 2.0.0-alpha.5 → 2.0.0-alpha.51
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 +902 -7
- package/README.md +28 -70
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts +85 -0
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/Renderers.js +6 -0
- package/lib/esm/presentation-hierarchies-react/Renderers.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts +28 -29
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.js +1 -7
- package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts +7 -5
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +6 -6
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts +24 -0
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js +53 -0
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +12 -10
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +7 -22
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +33 -71
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.js +63 -64
- package/lib/esm/presentation-hierarchies-react/UseTree.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/Utils.d.ts +8 -0
- package/lib/esm/presentation-hierarchies-react/Utils.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/Utils.js +39 -0
- package/lib/esm/presentation-hierarchies-react/Utils.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +2 -2
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +31 -16
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +24 -6
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +29 -33
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +6 -29
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +31 -27
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +23 -9
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +16 -29
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +1 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +27 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +74 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts +48 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js +73 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts +133 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/{itwinui → stratakit}/LocalizationContext.js +17 -5
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +16 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +42 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts +45 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js +36 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +30 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +30 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +20 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +29 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +57 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +71 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.css +25 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +46 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +132 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +75 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js +193 -0
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -0
- package/lib/esm/presentation-hierarchies-react.d.ts +14 -10
- package/lib/esm/presentation-hierarchies-react.d.ts.map +1 -1
- package/lib/esm/presentation-hierarchies-react.js +11 -9
- package/lib/esm/presentation-hierarchies-react.js.map +1 -1
- package/package.json +55 -47
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts +0 -15
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js +0 -22
- package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.d.ts +0 -21
- package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.js +0 -30
- package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts +0 -73
- package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.d.ts +0 -25
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js +0 -40
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts +0 -23
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js +0 -72
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts +0 -40
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +0 -80
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts +0 -30
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js +0 -48
- package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js.map +0 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } 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 { Anchor, Text } from "@stratakit/bricks";
|
|
7
|
+
import { unstable_ErrorRegion as ErrorRegion } from "@stratakit/structures";
|
|
8
|
+
import { MAX_LIMIT_OVERRIDE } from "../internal/Utils.js";
|
|
9
|
+
import { useLocalizationContext } from "./LocalizationContext.js";
|
|
10
|
+
/**
|
|
11
|
+
* Renders StrataKit `<ErrorRegion.Item />` for all supported error types:
|
|
12
|
+
* - `ResultSetTooLarge` - renders `LocalizedStrings.resultLimitExceeded` message with actions to increase limit or apply filtering
|
|
13
|
+
* - `NoFilterMatches` - renders `LocalizedStrings.noFilteredChildren` message with action to change filter
|
|
14
|
+
* - `ChildrenLoad` - renders `LocalizedStrings.failedToCreateHierarchy` message with action to retry loading
|
|
15
|
+
* - `Unknown` - renders message set on error object.
|
|
16
|
+
*
|
|
17
|
+
* @alpha
|
|
18
|
+
*/
|
|
19
|
+
export function ErrorItemRenderer({ errorNode, getHierarchyLevelDetails, filterHierarchyLevel, reloadTree, scrollToNode }) {
|
|
20
|
+
const { localizedStrings } = useLocalizationContext();
|
|
21
|
+
if (errorNode.error.type === "ResultSetTooLarge") {
|
|
22
|
+
const limit = errorNode.error.resultSetSizeLimit;
|
|
23
|
+
const onOverrideLimit = getHierarchyLevelDetails ? () => getHierarchyLevelDetails(errorNode.id)?.setSizeLimit(MAX_LIMIT_OVERRIDE) : undefined;
|
|
24
|
+
return (_jsx(ErrorItemContainer, { errorNode: errorNode, actions: [
|
|
25
|
+
{
|
|
26
|
+
action: () => {
|
|
27
|
+
onOverrideLimit?.();
|
|
28
|
+
},
|
|
29
|
+
label: localizedStrings.increaseHierarchyLimit.replace("{{limit}}", MAX_LIMIT_OVERRIDE.toString()),
|
|
30
|
+
condition: () => !!onOverrideLimit && limit < MAX_LIMIT_OVERRIDE,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
action: () => {
|
|
34
|
+
const hierarchyLevelDetails = getHierarchyLevelDetails?.(errorNode.id);
|
|
35
|
+
hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);
|
|
36
|
+
},
|
|
37
|
+
label: localizedStrings.increaseHierarchyLimitWithFiltering,
|
|
38
|
+
condition: () => !!filterHierarchyLevel && !!errorNode?.isFilterable,
|
|
39
|
+
},
|
|
40
|
+
], message: localizedStrings.resultLimitExceeded.replace("{{limit}}", limit.toString()), scrollToElement: () => scrollToNode(errorNode) }));
|
|
41
|
+
}
|
|
42
|
+
if (errorNode.error.type === "NoFilterMatches") {
|
|
43
|
+
return (_jsx(ErrorItemContainer, { errorNode: errorNode, actions: [
|
|
44
|
+
{
|
|
45
|
+
action: () => {
|
|
46
|
+
const hierarchyLevelDetails = getHierarchyLevelDetails?.(errorNode.id);
|
|
47
|
+
hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);
|
|
48
|
+
},
|
|
49
|
+
label: localizedStrings.noFilteredChildrenChangeFilter,
|
|
50
|
+
condition: () => true,
|
|
51
|
+
},
|
|
52
|
+
], message: localizedStrings.noFilteredChildren, scrollToElement: () => scrollToNode(errorNode) }));
|
|
53
|
+
}
|
|
54
|
+
if (errorNode.error.type === "ChildrenLoad") {
|
|
55
|
+
return (_jsx(ErrorItemContainer, { errorNode: errorNode, actions: [
|
|
56
|
+
{
|
|
57
|
+
action: () => reloadTree({ parentNodeId: errorNode.id }),
|
|
58
|
+
label: localizedStrings.retry,
|
|
59
|
+
condition: () => true,
|
|
60
|
+
},
|
|
61
|
+
], message: localizedStrings.failedToCreateHierarchy, scrollToElement: () => scrollToNode(errorNode) }));
|
|
62
|
+
}
|
|
63
|
+
return _jsx(ErrorItemContainer, { errorNode: errorNode, message: errorNode.error.message, scrollToElement: () => scrollToNode(errorNode) });
|
|
64
|
+
}
|
|
65
|
+
function ErrorItemContainer({ errorNode, message, actions, scrollToElement }) {
|
|
66
|
+
return (_jsx(ErrorRegion.Item, { message: _jsx(MessageWithLink, { linkLabel: errorNode.label, scrollToElement: scrollToElement, message: message }), messageId: errorNode.id, actions: actions
|
|
67
|
+
?.filter(({ condition }) => condition())
|
|
68
|
+
.map(({ label, action }) => (_jsx(Text, { variant: "body-sm", children: _jsx(Anchor, { onClick: action, render: _jsx("button", {}), children: label }) }, label))) }));
|
|
69
|
+
}
|
|
70
|
+
function MessageWithLink({ linkLabel, scrollToElement, message }) {
|
|
71
|
+
const splitMessage = message.split("{{node}}", 2);
|
|
72
|
+
return (_jsxs("div", { style: { display: "flex", whiteSpace: "pre", flexWrap: "wrap" }, children: [splitMessage[0], _jsx(Anchor, { onClick: scrollToElement, render: _jsx("button", {}), children: linkLabel }), splitMessage[1] ? splitMessage[1] : null] }));
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=ErrorItemRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorItemRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/ErrorItemRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,oBAAoB,IAAI,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAI1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAclE;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAE,SAAS,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,UAAU,EAAE,YAAY,EAA0B;IAC/I,MAAM,EAAE,g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EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAA2B;IACnG,OAAO,CACL,KAAC,WAAW,CAAC,IAAI,IACf,OAAO,EAAE,KAAC,eAAe,IAAC,SAAS,EAAE,SAAS,CAAC,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,GAAI,EAC5G,SAAS,EAAE,SAAS,CAAC,EAAE,EACvB,OAAO,EAAE,OAAO;YACd,EAAE,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS,EAAE,CAAC;aACvC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAC1B,KAAC,IAAI,IAAa,OAAO,EAAC,SAAS,YACjC,KAAC,MAAM,IAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAU,YACxC,KAAK,GACC,IAHA,KAAK,CAIT,CACR,CAAC,GACJ,CACH,CAAC;AACJ,CAAC;AAQD,SAAS,eAAe,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAwB;IACpF,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,aACjE,YAAY,CAAC,CAAC,CAAC,EAChB,KAAC,MAAM,IAAC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,kBAAU,YACjD,SAAS,GACH,EACR,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IACrC,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, Text } from \"@stratakit/bricks\";\nimport { unstable_ErrorRegion as ErrorRegion } from \"@stratakit/structures\";\nimport { MAX_LIMIT_OVERRIDE } from \"../internal/Utils.js\";\nimport { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport { TreeNode } from \"../TreeNode.js\";\nimport { useErrorNodes } from \"./FlatTreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\n\n/** @alpha */\nexport interface ErrorItemRendererProps extends Pick<TreeRendererProps, \"getHierarchyLevelDetails\"> {\n /** A node containing an error. */\n errorNode: ReturnType<typeof useErrorNodes>[number];\n /** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */\n reloadTree: (options: { parentNodeId: string | undefined }) => void;\n /** A callback to scroll to the node associated with the error. */\n scrollToNode: (errorNode: TreeNode) => void;\n /** A callback to initiate filtering of the given hierarchy level. */\n filterHierarchyLevel?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n}\n\n/**\n * Renders StrataKit `<ErrorRegion.Item />` for all supported error types:\n * - `ResultSetTooLarge` - renders `LocalizedStrings.resultLimitExceeded` message with actions to increase limit or apply filtering\n * - `NoFilterMatches` - renders `LocalizedStrings.noFilteredChildren` message with action to change filter\n * - `ChildrenLoad` - renders `LocalizedStrings.failedToCreateHierarchy` message with action to retry loading\n * - `Unknown` - renders message set on error object.\n *\n * @alpha\n */\nexport function ErrorItemRenderer({ errorNode, getHierarchyLevelDetails, filterHierarchyLevel, reloadTree, scrollToNode }: ErrorItemRendererProps) {\n const { localizedStrings } = useLocalizationContext();\n\n if (errorNode.error.type === \"ResultSetTooLarge\") {\n const limit = errorNode.error.resultSetSizeLimit;\n const onOverrideLimit = getHierarchyLevelDetails ? () => getHierarchyLevelDetails(errorNode.id)?.setSizeLimit(MAX_LIMIT_OVERRIDE) : undefined;\n return (\n <ErrorItemContainer\n errorNode={errorNode}\n actions={[\n {\n action: () => {\n onOverrideLimit?.();\n },\n label: localizedStrings.increaseHierarchyLimit.replace(\"{{limit}}\", MAX_LIMIT_OVERRIDE.toString()),\n condition: () => !!onOverrideLimit && limit < MAX_LIMIT_OVERRIDE,\n },\n {\n action: () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(errorNode.id);\n hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);\n },\n label: localizedStrings.increaseHierarchyLimitWithFiltering,\n condition: () => !!filterHierarchyLevel && !!errorNode?.isFilterable,\n },\n ]}\n message={localizedStrings.resultLimitExceeded.replace(\"{{limit}}\", limit.toString())}\n scrollToElement={() => scrollToNode(errorNode)}\n />\n );\n }\n if (errorNode.error.type === \"NoFilterMatches\") {\n return (\n <ErrorItemContainer\n errorNode={errorNode}\n actions={[\n {\n action: () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(errorNode.id);\n hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);\n },\n label: localizedStrings.noFilteredChildrenChangeFilter,\n condition: () => true,\n },\n ]}\n message={localizedStrings.noFilteredChildren}\n scrollToElement={() => scrollToNode(errorNode)}\n />\n );\n }\n if (errorNode.error.type === \"ChildrenLoad\") {\n return (\n <ErrorItemContainer\n errorNode={errorNode}\n actions={[\n {\n action: () => reloadTree({ parentNodeId: errorNode.id }),\n label: localizedStrings.retry,\n condition: () => true,\n },\n ]}\n message={localizedStrings.failedToCreateHierarchy}\n scrollToElement={() => scrollToNode(errorNode)}\n />\n );\n }\n\n return <ErrorItemContainer errorNode={errorNode} message={errorNode.error.message} scrollToElement={() => scrollToNode(errorNode)} />;\n}\n\ntype ErrorItemContainerProps = {\n errorNode: TreeNode;\n message: string;\n actions?: { action: () => void; label: string; condition: () => boolean }[];\n} & Pick<MessageWithLinkProps, \"scrollToElement\">;\n\nfunction ErrorItemContainer({ errorNode, message, actions, scrollToElement }: ErrorItemContainerProps) {\n return (\n <ErrorRegion.Item\n message={<MessageWithLink linkLabel={errorNode.label} scrollToElement={scrollToElement} message={message} />}\n messageId={errorNode.id}\n actions={actions\n ?.filter(({ condition }) => condition())\n .map(({ label, action }) => (\n <Text key={label} variant=\"body-sm\">\n <Anchor onClick={action} render={<button />}>\n {label}\n </Anchor>\n </Text>\n ))}\n />\n );\n}\n\ninterface MessageWithLinkProps {\n scrollToElement: () => void;\n message: string;\n linkLabel?: string;\n}\n\nfunction MessageWithLink({ linkLabel, scrollToElement, message }: MessageWithLinkProps) {\n const splitMessage = message.split(\"{{node}}\", 2);\n return (\n <div style={{ display: \"flex\", whiteSpace: \"pre\", flexWrap: \"wrap\" }}>\n {splitMessage[0]}\n <Anchor onClick={scrollToElement} render={<button />}>\n {linkLabel}\n </Anchor>\n {splitMessage[1] ? splitMessage[1] : null}\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { TreeNode } from "../TreeNode.js";
|
|
2
|
+
/**
|
|
3
|
+
* Placeholder item that is added to hierarchy as a child for a parent item while its child items are loading.
|
|
4
|
+
*
|
|
5
|
+
* @alpha
|
|
6
|
+
*/
|
|
7
|
+
interface FlatPlaceholderItem {
|
|
8
|
+
id: string;
|
|
9
|
+
level: number;
|
|
10
|
+
placeholder: true;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* An item containing `TreeNode` node with properties needed for a flat tree structure.
|
|
14
|
+
*
|
|
15
|
+
* @alpha
|
|
16
|
+
*/
|
|
17
|
+
export interface FlatTreeNodeItem {
|
|
18
|
+
id: string;
|
|
19
|
+
level: number;
|
|
20
|
+
levelSize: number;
|
|
21
|
+
posInLevel: number;
|
|
22
|
+
node: TreeNode;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* An Item describing single tree item position and its content inside tree.
|
|
26
|
+
* Returned by `useFlatTreeNodeList` hook.
|
|
27
|
+
*
|
|
28
|
+
* @alpha
|
|
29
|
+
*/
|
|
30
|
+
export type FlatTreeItem = FlatTreeNodeItem | FlatPlaceholderItem;
|
|
31
|
+
/** @alpha */
|
|
32
|
+
export declare function isPlaceholderItem(item: FlatTreeItem): item is FlatPlaceholderItem;
|
|
33
|
+
/**
|
|
34
|
+
* Used to get a list of `FlatTreeItem` objects for the given list of `TreeNode` objects that represent
|
|
35
|
+
* a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a
|
|
36
|
+
* virtualized list.
|
|
37
|
+
*
|
|
38
|
+
* @alpha
|
|
39
|
+
*/
|
|
40
|
+
export declare function useFlatTreeItems(rootNodes: TreeNode[]): FlatTreeItem[];
|
|
41
|
+
/**
|
|
42
|
+
* Finds and returns all nodes containing errors in a given hierarchy.
|
|
43
|
+
*
|
|
44
|
+
* @alpha
|
|
45
|
+
*/
|
|
46
|
+
export declare function useErrorNodes(rootNodes: TreeNode[]): Array<TreeNode & Pick<Required<TreeNode>, "error">>;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=FlatTreeNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlatTreeNode.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;;GAIG;AACH,UAAU,mBAAmB;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,IAAI,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;AAElE,aAAa;AACb,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,IAAI,mBAAmB,CAEjF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,kBAErD;AAoBD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,CAcxG"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
/** @alpha */
|
|
7
|
+
export function isPlaceholderItem(item) {
|
|
8
|
+
return "placeholder" in item;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Used to get a list of `FlatTreeItem` objects for the given list of `TreeNode` objects that represent
|
|
12
|
+
* a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a
|
|
13
|
+
* virtualized list.
|
|
14
|
+
*
|
|
15
|
+
* @alpha
|
|
16
|
+
*/
|
|
17
|
+
export function useFlatTreeItems(rootNodes) {
|
|
18
|
+
return useMemo(() => getFlatItems(rootNodes, 1), [rootNodes]);
|
|
19
|
+
}
|
|
20
|
+
function getFlatItems(nodes, level) {
|
|
21
|
+
const flatItems = [];
|
|
22
|
+
nodes.forEach((node, index) => {
|
|
23
|
+
flatItems.push({ node, id: node.id, level, levelSize: nodes.length, posInLevel: index + 1 });
|
|
24
|
+
if (!node.isExpanded || node.error) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (node.children !== true) {
|
|
28
|
+
const childNodes = getFlatItems(node.children, level + 1);
|
|
29
|
+
flatItems.push(...childNodes);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
flatItems.push({ id: `${node.id}-children-placeholder`, level: level + 1, placeholder: true });
|
|
33
|
+
});
|
|
34
|
+
return flatItems;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Finds and returns all nodes containing errors in a given hierarchy.
|
|
38
|
+
*
|
|
39
|
+
* @alpha
|
|
40
|
+
*/
|
|
41
|
+
export function useErrorNodes(rootNodes) {
|
|
42
|
+
return useMemo(() => rootNodes.flatMap((rootNode) => {
|
|
43
|
+
if (isErrorNode(rootNode)) {
|
|
44
|
+
return [rootNode];
|
|
45
|
+
}
|
|
46
|
+
if (rootNode.children === true) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
return getErrorNodes(rootNode);
|
|
50
|
+
}), [rootNodes]);
|
|
51
|
+
}
|
|
52
|
+
function getErrorNodes(parent) {
|
|
53
|
+
const errorList = [];
|
|
54
|
+
if (parent.children === true) {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
parent.children.forEach((node) => {
|
|
58
|
+
if (isErrorNode(node)) {
|
|
59
|
+
errorList.push(node);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (node.children !== true) {
|
|
63
|
+
const childErrorList = getErrorNodes(node);
|
|
64
|
+
errorList.push(...childErrorList);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return errorList;
|
|
69
|
+
}
|
|
70
|
+
function isErrorNode(node) {
|
|
71
|
+
return node.error !== undefined;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=FlatTreeNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlatTreeNode.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAmChC,aAAa;AACb,MAAM,UAAU,iBAAiB,CAAC,IAAkB;IAClD,OAAO,aAAa,IAAI,IAAI,CAAC;AAC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,CAAC,EAAE,CAAC;YAC1B,OAAO,CAAC,QAAQ,CAAC,CAAC;QACpB,CAAC;QACD,IAAI,QAAQ,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC/B,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,CAAC,EACJ,CAAC,SAAS,CAAC,CACZ,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,MAAgB;IACrC,MAAM,SAAS,GAAqC,EAAE,CAAC;IAEvD,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC/B,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;YACtB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrB,OAAO;QACT,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC3B,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;YAC3C,SAAS,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;YAClC,OAAO;QACT,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,WAAW,CAAC,IAAc;IACjC,OAAO,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC;AAClC,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 { useMemo } from \"react\";\nimport { TreeNode } from \"../TreeNode.js\";\n\n/**\n * Placeholder item that is added to hierarchy as a child for a parent item while its child items are loading.\n *\n * @alpha\n */\ninterface FlatPlaceholderItem {\n id: string;\n level: number;\n placeholder: true;\n}\n\n/**\n * An item containing `TreeNode` node with properties needed for a flat tree structure.\n *\n * @alpha\n */\nexport interface FlatTreeNodeItem {\n id: string;\n level: number;\n levelSize: number;\n posInLevel: number;\n node: TreeNode;\n}\n\n/**\n * An Item describing single tree item position and its content inside tree.\n * Returned by `useFlatTreeNodeList` hook.\n *\n * @alpha\n */\nexport type FlatTreeItem = FlatTreeNodeItem | FlatPlaceholderItem;\n\n/** @alpha */\nexport function isPlaceholderItem(item: FlatTreeItem): item is FlatPlaceholderItem {\n return \"placeholder\" in item;\n}\n\n/**\n * Used to get a list of `FlatTreeItem` objects for the given list of `TreeNode` objects that represent\n * a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a\n * virtualized list.\n *\n * @alpha\n */\nexport function useFlatTreeItems(rootNodes: TreeNode[]) {\n return useMemo(() => getFlatItems(rootNodes, 1), [rootNodes]);\n}\n\nfunction getFlatItems(nodes: TreeNode[], level: number) {\n const flatItems: FlatTreeItem[] = [];\n nodes.forEach((node, index) => {\n flatItems.push({ node, id: node.id, level, levelSize: nodes.length, posInLevel: index + 1 });\n if (!node.isExpanded || node.error) {\n return;\n }\n if (node.children !== true) {\n const childNodes = getFlatItems(node.children, level + 1);\n flatItems.push(...childNodes);\n return;\n }\n\n flatItems.push({ id: `${node.id}-children-placeholder`, level: level + 1, placeholder: true } satisfies FlatPlaceholderItem);\n });\n return flatItems;\n}\n\n/**\n * Finds and returns all nodes containing errors in a given hierarchy.\n *\n * @alpha\n */\nexport function useErrorNodes(rootNodes: TreeNode[]): Array<TreeNode & Pick<Required<TreeNode>, \"error\">> {\n return useMemo(\n () =>\n rootNodes.flatMap((rootNode) => {\n if (isErrorNode(rootNode)) {\n return [rootNode];\n }\n if (rootNode.children === true) {\n return [];\n }\n return getErrorNodes(rootNode);\n }),\n [rootNodes],\n );\n}\n\nfunction getErrorNodes(parent: TreeNode) {\n const errorList: ReturnType<typeof useErrorNodes> = [];\n\n if (parent.children === true) {\n return [];\n }\n\n parent.children.forEach((node) => {\n if (isErrorNode(node)) {\n errorList.push(node);\n return;\n }\n\n if (node.children !== true) {\n const childErrorList = getErrorNodes(node);\n errorList.push(...childErrorList);\n return;\n }\n });\n return errorList;\n}\n\nfunction isErrorNode(node: TreeNode): node is TreeNode & Pick<Required<TreeNode>, \"error\"> {\n return node.error !== undefined;\n}\n"]}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Localized strings used in the components.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface LocalizedStrings {
|
|
7
|
+
/**
|
|
8
|
+
* Message displayed when nodes are loading.
|
|
9
|
+
* Default value: `Loading...`.
|
|
10
|
+
*/
|
|
11
|
+
loading: string;
|
|
12
|
+
/**
|
|
13
|
+
* Title for apply hierarchy filter button.
|
|
14
|
+
* Default value: `Apply filter`.
|
|
15
|
+
*/
|
|
16
|
+
filterHierarchyLevel: string;
|
|
17
|
+
/**
|
|
18
|
+
* Accessible description for applied hierarchy filter button.
|
|
19
|
+
* Default value: `Filter is applied`.
|
|
20
|
+
*/
|
|
21
|
+
filterHierarchyLevelActiveDescription: string;
|
|
22
|
+
/**
|
|
23
|
+
* Title for clear hierarchy filter button.
|
|
24
|
+
* Default value: `Clear active filter`.
|
|
25
|
+
*/
|
|
26
|
+
clearHierarchyLevelFilter: string;
|
|
27
|
+
/**
|
|
28
|
+
* Message displayed when no nodes matching filter are found.
|
|
29
|
+
* Default value: `No matches for current filter for {{node}}.`.
|
|
30
|
+
*/
|
|
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;
|
|
42
|
+
/**
|
|
43
|
+
* Message displayed when hierarchy creation for a node failed.
|
|
44
|
+
* Default value: `Failed to load tree.`.
|
|
45
|
+
*/
|
|
46
|
+
failedToCreateRootHierarchy: string;
|
|
47
|
+
/**
|
|
48
|
+
* Message displayed when result limit exceeds hierarchy size limit.
|
|
49
|
+
* Default value: `The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.`.
|
|
50
|
+
*/
|
|
51
|
+
resultLimitExceeded: string;
|
|
52
|
+
/**
|
|
53
|
+
* Message displayed when result limit exceeds hierarchy size limit.
|
|
54
|
+
* Default value: `The root item hierarchy contains {{limit}}+ items. Try increasing the limit.`.
|
|
55
|
+
*/
|
|
56
|
+
rootResultLimitExceeded: string;
|
|
57
|
+
/**
|
|
58
|
+
* Name for the error region landmark.
|
|
59
|
+
* Default value: `Issues for {{tree_label}}.`.
|
|
60
|
+
*/
|
|
61
|
+
issuesForTree: string;
|
|
62
|
+
/**
|
|
63
|
+
* Label displayed on the error region, when errors are detected.
|
|
64
|
+
* Default value: `{{number_of_issues}} issue(s) found.`.
|
|
65
|
+
*/
|
|
66
|
+
issuesFound: string;
|
|
67
|
+
/**
|
|
68
|
+
* Label displayed on the error region, when no issues are found.
|
|
69
|
+
* Default value: `No issues found.`.
|
|
70
|
+
*/
|
|
71
|
+
noIssuesFound: string;
|
|
72
|
+
/**
|
|
73
|
+
* Message displayed when hierarchy size limit can be overridden.
|
|
74
|
+
* Default value: `Increase limit to {{limit}}`.
|
|
75
|
+
*/
|
|
76
|
+
increaseHierarchyLimit: string;
|
|
77
|
+
/**
|
|
78
|
+
* Message displayed when hierarchy size limit can be overridden.
|
|
79
|
+
* Default value: `Remove limit`.
|
|
80
|
+
*/
|
|
81
|
+
increaseHierarchyLimitToUnlimited: string;
|
|
82
|
+
/**
|
|
83
|
+
* Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.
|
|
84
|
+
* Default value: `Add Filter`.
|
|
85
|
+
*/
|
|
86
|
+
increaseHierarchyLimitWithFiltering: string;
|
|
87
|
+
/**
|
|
88
|
+
* Label for retry action.
|
|
89
|
+
* Default value: `Retry`.
|
|
90
|
+
*/
|
|
91
|
+
retry: string;
|
|
92
|
+
/**
|
|
93
|
+
* Label for rename action.
|
|
94
|
+
* Default value: `Rename`.
|
|
95
|
+
*/
|
|
96
|
+
rename: string;
|
|
97
|
+
/**
|
|
98
|
+
* Label for more actions button.
|
|
99
|
+
* Default value: `More`.
|
|
100
|
+
*/
|
|
101
|
+
more: string;
|
|
102
|
+
/**
|
|
103
|
+
* Label for confirm button.
|
|
104
|
+
* Default value: `Confirm`.
|
|
105
|
+
*/
|
|
106
|
+
confirm: string;
|
|
107
|
+
/**
|
|
108
|
+
* Label for cancel button.
|
|
109
|
+
* Default value: `Cancel`.
|
|
110
|
+
*/
|
|
111
|
+
cancel: string;
|
|
112
|
+
}
|
|
113
|
+
/** @internal */
|
|
114
|
+
export interface LocalizationContext {
|
|
115
|
+
localizedStrings: LocalizedStrings;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Properties for `LocalizationContextProvider`.
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
interface LocalizationContextProviderProps {
|
|
122
|
+
/** Localized strings used in the components. */
|
|
123
|
+
localizedStrings?: Partial<LocalizedStrings>;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Context provider for localized strings used in the components.
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
export declare function LocalizationContextProvider({ localizedStrings, children }: PropsWithChildren<LocalizationContextProviderProps>): import("react/jsx-runtime").JSX.Element;
|
|
130
|
+
/** @internal */
|
|
131
|
+
export declare function useLocalizationContext(): LocalizationContext;
|
|
132
|
+
export {};
|
|
133
|
+
//# sourceMappingURL=LocalizationContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalizationContext.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/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,2BAA2B,EAAE,MAAM,CAAC;IACpC;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,iCAAiC,EAAE,MAAM,CAAC;IAC1C;;;OAGG;IACH,mCAAmC,EAAE,MAAM,CAAC;IAC5C;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,gBAAgB;AAChB,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AA4BD;;;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"}
|
|
@@ -7,13 +7,25 @@ import { createContext, useContext, useEffect, useState } from "react";
|
|
|
7
7
|
const defaultLocalizedStrings = {
|
|
8
8
|
loading: "Loading...",
|
|
9
9
|
filterHierarchyLevel: "Apply filter",
|
|
10
|
+
filterHierarchyLevelActiveDescription: "Filter is applied",
|
|
10
11
|
clearHierarchyLevelFilter: "Clear active filter",
|
|
11
|
-
noFilteredChildren: "No
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
noFilteredChildren: "No matches for current filter for {{node}}.",
|
|
13
|
+
noFilteredChildrenChangeFilter: "Change filter",
|
|
14
|
+
failedToCreateHierarchy: "Failed to create hierarchy for {{node}}.",
|
|
15
|
+
failedToCreateRootHierarchy: "Failed to load tree.",
|
|
16
|
+
resultLimitExceeded: "The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.",
|
|
17
|
+
rootResultLimitExceeded: "The root item hierarchy contains {{limit}}+ items. Try increasing the limit.",
|
|
18
|
+
issuesForTree: "Issues for {{tree_label}}.",
|
|
19
|
+
issuesFound: "{{number_of_issues}} issue(s) found.",
|
|
20
|
+
noIssuesFound: "No issues found.",
|
|
21
|
+
increaseHierarchyLimit: "Increase limit to {{limit}}",
|
|
22
|
+
increaseHierarchyLimitToUnlimited: "Remove limit",
|
|
23
|
+
increaseHierarchyLimitWithFiltering: "Add Filter",
|
|
16
24
|
retry: "Retry",
|
|
25
|
+
rename: "Rename",
|
|
26
|
+
more: "More",
|
|
27
|
+
confirm: "Confirm",
|
|
28
|
+
cancel: "Cancel",
|
|
17
29
|
};
|
|
18
30
|
const localizationContext = createContext({ localizedStrings: defaultLocalizedStrings });
|
|
19
31
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalizationContext.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAqB,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAuH1F,MAAM,uBAAuB,GAAqB;IAChD,OAAO,EAAE,YAAY;IACrB,oBAAoB,EAAE,cAAc;IACpC,qCAAqC,EAAE,mBAAmB;IAC1D,yBAAyB,EAAE,qBAAqB;IAChD,kBAAkB,EAAE,6CAA6C;IACjE,8BAA8B,EAAE,eAAe;IAC/C,uBAAuB,EAAE,0CAA0C;IACnE,2BAA2B,EAAE,sBAAsB;IACnD,mBAAmB,EAAE,gGAAgG;IACrH,uBAAuB,EAAE,8EAA8E;IACvG,aAAa,EAAE,4BAA4B;IAC3C,WAAW,EAAE,sCAAsC;IACnD,aAAa,EAAE,kBAAkB;IACjC,sBAAsB,EAAE,6BAA6B;IACrD,iCAAiC,EAAE,cAAc;IACjD,mCAAmC,EAAE,YAAY;IACjD,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;CACjB,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 * Accessible 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 hierarchy creation for a node failed.\n * Default value: `Failed to load tree.`.\n */\n failedToCreateRootHierarchy: 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 * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `The root item hierarchy contains {{limit}}+ items. Try increasing the limit.`.\n */\n rootResultLimitExceeded: string;\n /**\n * Name for the error region landmark.\n * Default value: `Issues for {{tree_label}}.`.\n */\n issuesForTree: string;\n /**\n * Label displayed on the error region, when errors are detected.\n * Default value: `{{number_of_issues}} issue(s) found.`.\n */\n issuesFound: string;\n /**\n * Label displayed on the error region, when no issues are found.\n * Default value: `No issues found.`.\n */\n noIssuesFound: 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.\n * Default value: `Remove limit`.\n */\n increaseHierarchyLimitToUnlimited: 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 * Label for rename action.\n * Default value: `Rename`.\n */\n rename: string;\n /**\n * Label for more actions button.\n * Default value: `More`.\n */\n more: string;\n /**\n * Label for confirm button.\n * Default value: `Confirm`.\n */\n confirm: string;\n /**\n * Label for cancel button.\n * Default value: `Cancel`.\n */\n cancel: 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 failedToCreateRootHierarchy: \"Failed to load tree.\",\n resultLimitExceeded: \"The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.\",\n rootResultLimitExceeded: \"The root item hierarchy contains {{limit}}+ items. Try increasing the limit.\",\n issuesForTree: \"Issues for {{tree_label}}.\",\n issuesFound: \"{{number_of_issues}} issue(s) found.\",\n noIssuesFound: \"No issues found.\",\n increaseHierarchyLimit: \"Increase limit to {{limit}}\",\n increaseHierarchyLimitToUnlimited: \"Remove limit\",\n increaseHierarchyLimitWithFiltering: \"Add Filter\",\n retry: \"Retry\",\n rename: \"Rename\",\n more: \"More\",\n confirm: \"Confirm\",\n cancel: \"Cancel\",\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"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RootErrorRendererProps } from "../Renderers.js";
|
|
2
|
+
import { ErrorInfo } from "../TreeNode.js";
|
|
3
|
+
/**
|
|
4
|
+
* @alpha
|
|
5
|
+
*/
|
|
6
|
+
export type StrataKitRootErrorRendererProps = {
|
|
7
|
+
/** Root error to be displayed */
|
|
8
|
+
error: ErrorInfo;
|
|
9
|
+
} & RootErrorRendererProps;
|
|
10
|
+
/**
|
|
11
|
+
* A component that renders root node error state.
|
|
12
|
+
*
|
|
13
|
+
* @alpha
|
|
14
|
+
*/
|
|
15
|
+
export declare function StrataKitRootErrorRenderer({ error, getHierarchyLevelDetails, reloadTree }: StrataKitRootErrorRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
//# sourceMappingURL=RootErrorRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RootErrorRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/RootErrorRenderer.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,iCAAiC;IACjC,KAAK,EAAE,SAAS,CAAC;CAClB,GAAG,sBAAsB,CAAC;AAE3B;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,EAAE,KAAK,EAAE,wBAAwB,EAAE,UAAU,EAAE,EAAE,+BAA+B,2CA+B1H"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } 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 { Button, Text } from "@stratakit/bricks";
|
|
7
|
+
import { Icon } from "@stratakit/foundations";
|
|
8
|
+
import errorSvg from "@stratakit/icons/status-error.svg";
|
|
9
|
+
import { useLocalizationContext } from "./LocalizationContext.js";
|
|
10
|
+
/**
|
|
11
|
+
* A component that renders root node error state.
|
|
12
|
+
*
|
|
13
|
+
* @alpha
|
|
14
|
+
*/
|
|
15
|
+
export function StrataKitRootErrorRenderer({ error, getHierarchyLevelDetails, reloadTree }) {
|
|
16
|
+
const { localizedStrings } = useLocalizationContext();
|
|
17
|
+
if (error.type === "ResultSetTooLarge") {
|
|
18
|
+
const onOverrideLimit = () => getHierarchyLevelDetails(undefined)?.setSizeLimit("unbounded");
|
|
19
|
+
return (_jsx(RootErrorContainer, { message: localizedStrings.rootResultLimitExceeded.replace("{{limit}}", error.resultSetSizeLimit.toString()), actions: [
|
|
20
|
+
{
|
|
21
|
+
action: onOverrideLimit,
|
|
22
|
+
label: localizedStrings.increaseHierarchyLimitToUnlimited,
|
|
23
|
+
condition: () => true,
|
|
24
|
+
},
|
|
25
|
+
] }));
|
|
26
|
+
}
|
|
27
|
+
return (_jsx(RootErrorContainer, { message: localizedStrings.failedToCreateRootHierarchy, actions: [
|
|
28
|
+
{
|
|
29
|
+
action: () => reloadTree({ parentNodeId: undefined, state: "reset" }),
|
|
30
|
+
label: localizedStrings.retry,
|
|
31
|
+
condition: () => true,
|
|
32
|
+
},
|
|
33
|
+
] }));
|
|
34
|
+
}
|
|
35
|
+
function RootErrorContainer({ actions, message }) {
|
|
36
|
+
return (_jsxs("div", { style: { height: "100%", display: "flex", flexDirection: "column", justifyContent: "center", alignItems: "center", gap: "0.5rem" }, children: [_jsx(Icon, { href: errorSvg, size: "large" }), _jsx(Text, { variant: "body-sm", style: { textAlign: "center" }, children: message }), actions
|
|
37
|
+
?.filter(({ condition }) => condition())
|
|
38
|
+
.map((action) => {
|
|
39
|
+
return (_jsx(Button, { onClick: () => action.action(), children: action.label }, action.label));
|
|
40
|
+
})] }));
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=RootErrorRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RootErrorRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/RootErrorRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,QAAQ,MAAM,mCAAmC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E,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,aACrI,KAAC,IAAI,IAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,OAAO,GAAG,EACrC,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,YACrD,OAAO,GACH,EACN,OAAO;gBACN,EAAE,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS,EAAE,CAAC;iBACvC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;gBACd,OAAO,CACL,KAAC,MAAM,IAAoB,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,YACtD,MAAM,CAAC,KAAK,IADF,MAAM,CAAC,KAAK,CAEhB,CACV,CAAC;YACJ,CAAC,CAAC,IACA,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 { Button, Text } from \"@stratakit/bricks\";\nimport { Icon } from \"@stratakit/foundations\";\nimport errorSvg from \"@stratakit/icons/status-error.svg\";\nimport { RootErrorRendererProps } from \"../Renderers.js\";\nimport { ErrorInfo } from \"../TreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\n\n/**\n * @alpha\n */\nexport type StrataKitRootErrorRendererProps = {\n /** Root error to be displayed */\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) {\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"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { Tree } from "@stratakit/structures";
|
|
3
|
+
/**
|
|
4
|
+
* Attributes used to decide how to render tree actions. They allow to differentiate action style based on the context
|
|
5
|
+
* where that action is used.
|
|
6
|
+
* @alpha
|
|
7
|
+
*/
|
|
8
|
+
export interface TreeActionBaseAttributes {
|
|
9
|
+
/**
|
|
10
|
+
* Specifies action variant supported by tree nodes:
|
|
11
|
+
*
|
|
12
|
+
* - "default" - standard action displayed in the dropdown menu accessible through the ellipsis button on the node.
|
|
13
|
+
* - "inline" - actions displayed directly on the tree node.
|
|
14
|
+
* - "context-menu" - actions displayed in the context menu opened by right-clicking the tree node.
|
|
15
|
+
*/
|
|
16
|
+
variant?: "default" | "inline" | "context-menu";
|
|
17
|
+
/**
|
|
18
|
+
* Indicates that the actions is not applicable for current tree node and should be hidden.
|
|
19
|
+
* When set to true, the action will not be rendered at all.
|
|
20
|
+
*/
|
|
21
|
+
hide?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** @alpha */
|
|
24
|
+
export type TreeActionBaseProps = ComponentProps<typeof Tree.ItemAction> & TreeActionBaseAttributes;
|
|
25
|
+
/**
|
|
26
|
+
* Base component used to render tree actions. It is designed to allow rendering same action in different contexts: inline, dropdown, context menu.
|
|
27
|
+
* Should be used together with `StrataKitTreeNodeRenderer` and returned from `getInlineActions`, `getMenuActions` and `getContextMenuActions` callbacks.
|
|
28
|
+
*
|
|
29
|
+
* When implementing custom action that returns this component, make sure to forward `TreeActionBaseAttributes` props to it. Example:
|
|
30
|
+
*
|
|
31
|
+
* ```tsx
|
|
32
|
+
* interface MyCustomTreeActionProps extends TreeActionBaseAttributes {
|
|
33
|
+
* myProp: string
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* function MyCustomTreeAction({ myProp, ...attributes }: MyCustomTreeActionProps) {
|
|
37
|
+
* // custom button logic goes here
|
|
38
|
+
* return <TreeActionBase {...attributes} icon={...} onClick={...} />
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @alpha
|
|
43
|
+
*/
|
|
44
|
+
export declare const TreeActionBase: import("react").NamedExoticComponent<TreeActionBaseProps>;
|
|
45
|
+
//# sourceMappingURL=TreeAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeAction.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeAction.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAQ,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAgB,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,cAAc,CAAC;IAChD;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,aAAa;AACb,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,wBAAwB,CAAC;AAEpG;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,cAAc,2DAUzB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { memo } from "react";
|
|
7
|
+
import { DropdownMenu, Tree } from "@stratakit/structures";
|
|
8
|
+
/**
|
|
9
|
+
* Base component used to render tree actions. It is designed to allow rendering same action in different contexts: inline, dropdown, context menu.
|
|
10
|
+
* Should be used together with `StrataKitTreeNodeRenderer` and returned from `getInlineActions`, `getMenuActions` and `getContextMenuActions` callbacks.
|
|
11
|
+
*
|
|
12
|
+
* When implementing custom action that returns this component, make sure to forward `TreeActionBaseAttributes` props to it. Example:
|
|
13
|
+
*
|
|
14
|
+
* ```tsx
|
|
15
|
+
* interface MyCustomTreeActionProps extends TreeActionBaseAttributes {
|
|
16
|
+
* myProp: string
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* function MyCustomTreeAction({ myProp, ...attributes }: MyCustomTreeActionProps) {
|
|
20
|
+
* // custom button logic goes here
|
|
21
|
+
* return <TreeActionBase {...attributes} icon={...} onClick={...} />
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @alpha
|
|
26
|
+
*/
|
|
27
|
+
export const TreeActionBase = memo(function TreeActionBase({ hide, variant = "default", dot, visible, ...actionProps }) {
|
|
28
|
+
if (hide) {
|
|
29
|
+
return variant === "inline" ? _jsx(Tree.ItemAction, { ...actionProps, visible: false }) : undefined;
|
|
30
|
+
}
|
|
31
|
+
if (variant === "context-menu") {
|
|
32
|
+
return _jsx(DropdownMenu.Item, { ...actionProps });
|
|
33
|
+
}
|
|
34
|
+
return _jsx(Tree.ItemAction, { ...actionProps, dot: dot, visible: variant === "inline" ? visible : undefined });
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=TreeAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeAction.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeAction.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAkB,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AA0B3D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,cAAc,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,WAAW,EAAuB;IACzI,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAC,IAAI,CAAC,UAAU,OAAK,WAAW,EAAE,OAAO,EAAE,KAAK,GAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IACjG,CAAC;IAED,IAAI,OAAO,KAAK,cAAc,EAAE,CAAC;QAC/B,OAAO,KAAC,YAAY,CAAC,IAAI,OAAK,WAAW,GAAI,CAAC;IAChD,CAAC;IAED,OAAO,KAAC,IAAI,CAAC,UAAU,OAAK,WAAW,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,GAAI,CAAC;AAC7G,CAAC,CAAC,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 { ComponentProps, memo } from \"react\";\nimport { DropdownMenu, Tree } from \"@stratakit/structures\";\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 = memo(function TreeActionBase({ hide, variant = \"default\", dot, visible, ...actionProps }: 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"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
import { ErrorItemRendererProps } from "./ErrorItemRenderer.js";
|
|
3
|
+
import { useErrorNodes } from "./FlatTreeNode.js";
|
|
4
|
+
/**
|
|
5
|
+
* Interface containing building blocks for `TreeErrorRenderer`.
|
|
6
|
+
*
|
|
7
|
+
* @alpha
|
|
8
|
+
*/
|
|
9
|
+
interface TreeErrorRendererOwnProps {
|
|
10
|
+
/**
|
|
11
|
+
* A user friendly display label of the tree. Should be unique within the consuming application,
|
|
12
|
+
* as it's used for creating a unique accessible label for the error region.
|
|
13
|
+
*/
|
|
14
|
+
treeLabel: string;
|
|
15
|
+
/** List of error nodes to render errors for. */
|
|
16
|
+
errorNodes: ReturnType<typeof useErrorNodes>;
|
|
17
|
+
/** Callback to render custom error messages. Component should be wrapped in `ErrorRegion.Item` from `@itwin/itwinui-react` package. */
|
|
18
|
+
renderError?: (props: ErrorItemRendererProps) => ReactElement;
|
|
19
|
+
}
|
|
20
|
+
/** @alpha */
|
|
21
|
+
export type TreeErrorRendererProps = TreeErrorRendererOwnProps & Omit<ErrorItemRendererProps, "errorNode">;
|
|
22
|
+
/**
|
|
23
|
+
* A component that renders error display dropdown using the `unstable_ErrorRegion` component from `@itwin/itwinui-react`.
|
|
24
|
+
* As input, the component uses a list of `ErrorNode` objects, which are generally created using the `useErrorList` hook.
|
|
25
|
+
*
|
|
26
|
+
* @alpha
|
|
27
|
+
*/
|
|
28
|
+
export declare function TreeErrorRenderer({ treeLabel, errorNodes, renderError, ...errorItemRendererProps }: TreeErrorRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=TreeErrorRenderer.d.ts.map
|