@itwin/presentation-hierarchies-react 2.0.0-alpha.53 → 2.0.0-alpha.55
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 +58 -0
- package/README.md +23 -61
- package/lib/presentation-hierarchies-react/Renderers.d.ts +92 -0
- package/lib/presentation-hierarchies-react/Renderers.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/TreeNode.d.ts +33 -29
- package/lib/presentation-hierarchies-react/TreeNode.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseIModelTree.d.ts +28 -17
- package/lib/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseIModelTree.js +184 -0
- package/lib/presentation-hierarchies-react/UseIModelTree.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts +30 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.js +58 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts +25 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.js +125 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseTree.d.ts +112 -0
- package/lib/presentation-hierarchies-react/UseTree.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseTree.js +294 -0
- package/lib/presentation-hierarchies-react/UseTree.js.map +1 -0
- package/lib/presentation-hierarchies-react/Utils.js +56 -0
- package/lib/presentation-hierarchies-react/Utils.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js +10 -0
- package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts +9 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js +12 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeActions.js +295 -0
- package/lib/presentation-hierarchies-react/internal/TreeActions.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeLoader.js +99 -0
- package/lib/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.d.ts +3 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.js +120 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +37 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js +142 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/Utils.js +43 -0
- package/lib/presentation-hierarchies-react/internal/Utils.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +38 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +381 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/FlatTreeNode.d.ts +16 -15
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.js +91 -0
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts +24 -0
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.js +41 -0
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +27 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +186 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts +49 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js +89 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +38 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +64 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +29 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +92 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +33 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +156 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +18 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +535 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +75 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js +418 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react.d.ts +18 -0
- package/lib/presentation-hierarchies-react.js +16 -0
- package/lib/public/locales/en/PresentationHierarchies_1.0.json +26 -0
- package/package.json +27 -21
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts +0 -85
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts.map +0 -1
- 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.d.ts.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/UseIModelTree.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +0 -62
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts +0 -24
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js +0 -53
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +0 -48
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +0 -83
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +0 -94
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.js +0 -241
- package/lib/esm/presentation-hierarchies-react/UseTree.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/Utils.js +0 -39
- package/lib/esm/presentation-hierarchies-react/Utils.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts +0 -2
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js +0 -11
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +0 -53
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +0 -322
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.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/TreeLoader.js +0 -90
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +0 -47
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +0 -157
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +0 -42
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +0 -115
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts +0 -23
- package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js +0 -58
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +0 -27
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +0 -74
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js +0 -73
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts +0 -138
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js +0 -47
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +0 -16
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +0 -42
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts +0 -45
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js +0 -36
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +0 -30
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +0 -30
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +0 -20
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +0 -29
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +0 -57
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +0 -71
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +0 -46
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +0 -133
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +0 -75
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js +0 -193
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react.d.ts +0 -17
- package/lib/esm/presentation-hierarchies-react.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react.js +0 -18
- package/lib/esm/presentation-hierarchies-react.js.map +0 -1
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeRenderer.css +0 -0
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { 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
|
|
@@ -1 +0,0 @@
|
|
|
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/B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAqB;IACpD,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,YAAY,CAAC,KAAiB,EAAE,KAAa;IACpD,MAAM,SAAS,GAAmB,EAAE,CAAC;IACrC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC5B,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC;QAC7F,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACnC,OAAO;QACT,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC3B,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;YAC1D,SAAS,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,uBAAuB,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,WAAW,EAAE,IAAI,EAAgC,CAAC,CAAC;IAC/H,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,SAAqB;IACjD,OAAO,OAAO,CACZ,GAAG,EAAE,CACH,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC7B,IAAI,WAAW,CAAC,QAAQ,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"]}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { PropsWithChildren } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* Localized strings used in the components.
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export interface LocalizedStrings {
|
|
7
|
-
/**
|
|
8
|
-
* Message displayed when nodes are loading.
|
|
9
|
-
* Default value: `Loading...`.
|
|
10
|
-
*/
|
|
11
|
-
loading: string;
|
|
12
|
-
/**
|
|
13
|
-
* Title for apply hierarchy filter button.
|
|
14
|
-
* Default value: `Apply filter`.
|
|
15
|
-
*/
|
|
16
|
-
filterHierarchyLevel: string;
|
|
17
|
-
/**
|
|
18
|
-
* 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
|
-
* Label for tree node rename input.
|
|
114
|
-
* Default value: `New label`.
|
|
115
|
-
*/
|
|
116
|
-
newLabel: string;
|
|
117
|
-
}
|
|
118
|
-
/** @internal */
|
|
119
|
-
export interface LocalizationContext {
|
|
120
|
-
localizedStrings: LocalizedStrings;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Properties for `LocalizationContextProvider`.
|
|
124
|
-
* @public
|
|
125
|
-
*/
|
|
126
|
-
interface LocalizationContextProviderProps {
|
|
127
|
-
/** Localized strings used in the components. */
|
|
128
|
-
localizedStrings?: Partial<LocalizedStrings>;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Context provider for localized strings used in the components.
|
|
132
|
-
* @public
|
|
133
|
-
*/
|
|
134
|
-
export declare function LocalizationContextProvider({ localizedStrings, children }: PropsWithChildren<LocalizationContextProviderProps>): import("react/jsx-runtime").JSX.Element;
|
|
135
|
-
/** @internal */
|
|
136
|
-
export declare function useLocalizationContext(): LocalizationContext;
|
|
137
|
-
export {};
|
|
138
|
-
//# sourceMappingURL=LocalizationContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;IACf;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,gBAAgB;AAChB,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AA6BD;;;GAGG;AACH,UAAU,gCAAgC;IACxC,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC,gCAAgC,CAAC,2CAQ9H;AAED,gBAAgB;AAChB,wBAAgB,sBAAsB,wBAErC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
import { createContext, useContext, useEffect, useState } from "react";
|
|
7
|
-
const defaultLocalizedStrings = {
|
|
8
|
-
loading: "Loading...",
|
|
9
|
-
filterHierarchyLevel: "Apply filter",
|
|
10
|
-
filterHierarchyLevelActiveDescription: "Filter is applied",
|
|
11
|
-
clearHierarchyLevelFilter: "Clear active filter",
|
|
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",
|
|
24
|
-
retry: "Retry",
|
|
25
|
-
rename: "Rename",
|
|
26
|
-
more: "More",
|
|
27
|
-
confirm: "Confirm",
|
|
28
|
-
cancel: "Cancel",
|
|
29
|
-
newLabel: "New label",
|
|
30
|
-
};
|
|
31
|
-
const localizationContext = createContext({ localizedStrings: defaultLocalizedStrings });
|
|
32
|
-
/**
|
|
33
|
-
* Context provider for localized strings used in the components.
|
|
34
|
-
* @public
|
|
35
|
-
*/
|
|
36
|
-
export function LocalizationContextProvider({ localizedStrings, children }) {
|
|
37
|
-
const [state, setState] = useState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
setState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });
|
|
40
|
-
}, [localizedStrings]);
|
|
41
|
-
return _jsx(localizationContext.Provider, { value: state, children: children });
|
|
42
|
-
}
|
|
43
|
-
/** @internal */
|
|
44
|
-
export function useLocalizationContext() {
|
|
45
|
-
return useContext(localizationContext);
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=LocalizationContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AA4H1F,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;IAChB,QAAQ,EAAE,WAAW;CACtB,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 * Label for tree node rename input.\n * Default value: `New label`.\n */\n newLabel: 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 newLabel: \"New label\",\n};\n\nconst localizationContext = createContext<LocalizationContext>({ localizedStrings: defaultLocalizedStrings });\n\n/**\n * Properties for `LocalizationContextProvider`.\n * @public\n */\ninterface LocalizationContextProviderProps {\n /** Localized strings used in the components. */\n localizedStrings?: Partial<LocalizedStrings>;\n}\n\n/**\n * Context provider for localized strings used in the components.\n * @public\n */\nexport function LocalizationContextProvider({ localizedStrings, children }: PropsWithChildren<LocalizationContextProviderProps>) {\n const [state, setState] = useState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n\n useEffect(() => {\n setState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n }, [localizedStrings]);\n\n return <localizationContext.Provider value={state}>{children}</localizationContext.Provider>;\n}\n\n/** @internal */\nexport function useLocalizationContext() {\n return useContext(localizationContext);\n}\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,42 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,CAAC;AAGzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAUlE;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,EAAE,KAAK,EAAE,wBAAwB,EAAE,UAAU,EAAmC;IACzH,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,EAAE,CAAC;IAEtD,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;QACvC,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;QAC7F,OAAO,CACL,KAAC,kBAAkB,IACjB,OAAO,EAAE,gBAAgB,CAAC,uBAAuB,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,kBAAkB,CAAC,QAAQ,EAAE,CAAC,EAC3G,OAAO,EAAE;gBACP;oBACE,MAAM,EAAE,eAAe;oBACvB,KAAK,EAAE,gBAAgB,CAAC,iCAAiC;oBACzD,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI;iBACtB;aACF,GACD,CACH,CAAC;IACJ,CAAC;IAED,OAAO,CACL,KAAC,kBAAkB,IACjB,OAAO,EAAE,gBAAgB,CAAC,2BAA2B,EACrD,OAAO,EAAE;YACP;gBACE,MAAM,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;gBACrE,KAAK,EAAE,gBAAgB,CAAC,KAAK;gBAC7B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI;aACtB;SACF,GACD,CACH,CAAC;AACJ,CAAC;AAOD,SAAS,kBAAkB,CAAC,EAAE,OAAO,EAAE,OAAO,EAA2B;IACvE,OAAO,CACL,eAAK,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,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"]}
|
|
@@ -1,45 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
import { 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
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TreeErrorRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAgB,YAAY,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAqB,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD;;;;GAIG;AACH,UAAU,yBAAyB;IACjC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,UAAU,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;IAC7C,uIAAuI;IACvI,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,YAAY,CAAC;CAC/D;AAED,aAAa;AACb,MAAM,MAAM,sBAAsB,GAAG,yBAAyB,GAAG,IAAI,CAAC,sBAAsB,EAAE,WAAW,CAAC,CAAC;AAE3G;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,sBAAsB,EAAE,EAAE,sBAAsB,2CAyB1H"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
import { cloneElement } from "react";
|
|
7
|
-
import { unstable_ErrorRegion as ErrorRegion } from "@stratakit/structures";
|
|
8
|
-
import { ErrorItemRenderer } from "./ErrorItemRenderer.js";
|
|
9
|
-
import { useLocalizationContext } from "./LocalizationContext.js";
|
|
10
|
-
/**
|
|
11
|
-
* A component that renders error display dropdown using the `unstable_ErrorRegion` component from `@itwin/itwinui-react`.
|
|
12
|
-
* As input, the component uses a list of `ErrorNode` objects, which are generally created using the `useErrorList` hook.
|
|
13
|
-
*
|
|
14
|
-
* @alpha
|
|
15
|
-
*/
|
|
16
|
-
export function TreeErrorRenderer({ treeLabel, errorNodes, renderError, ...errorItemRendererProps }) {
|
|
17
|
-
const { localizedStrings } = useLocalizationContext();
|
|
18
|
-
const errorItems = errorNodes.map((errorNode) => {
|
|
19
|
-
const errorRendererProps = {
|
|
20
|
-
errorNode,
|
|
21
|
-
...errorItemRendererProps,
|
|
22
|
-
};
|
|
23
|
-
if (renderError) {
|
|
24
|
-
return cloneElement(renderError(errorRendererProps), { key: errorNode.id });
|
|
25
|
-
}
|
|
26
|
-
return _jsx(ErrorItemRenderer, { ...errorRendererProps }, errorNode.id);
|
|
27
|
-
});
|
|
28
|
-
return (_jsx(ErrorRegion.Root, { style: { width: "100%" }, "aria-label": localizedStrings.issuesForTree.replace("{{tree_label}}", treeLabel), label: errorNodes.length === 0 ? localizedStrings.noIssuesFound : localizedStrings.issuesFound.replace("{{number_of_issues}}", errorNodes.length.toString()), items: errorItems }));
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=TreeErrorRenderer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TreeErrorRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,YAAY,EAAgB,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,oBAAoB,IAAI,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAA0B,MAAM,wBAAwB,CAAC;AAEnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAsBlE;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,sBAAsB,EAA0B;IACzH,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACtD,MAAM,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;QAC9C,MAAM,kBAAkB,GAA2B;YACjD,SAAS;YACT,GAAG,sBAAsB;SAC1B,CAAC;QAEF,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,YAAY,CAAC,WAAW,CAAC,kBAAkB,CAAC,EAAE,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9E,CAAC;QAED,OAAO,KAAC,iBAAiB,OAAwB,kBAAkB,IAApC,SAAS,CAAC,EAAE,CAA4B,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,OAAO,CACL,KAAC,WAAW,CAAC,IAAI,IACf,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,gBACZ,gBAAgB,CAAC,aAAa,CAAC,OAAO,CAAC,gBAAgB,EAAE,SAAS,CAAC,EAC/E,KAAK,EACH,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC,gBAAgB,CAAC,WAAW,CAAC,OAAO,CAAC,sBAAsB,EAAE,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAEvJ,KAAK,EAAE,UAAU,GACjB,CACH,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 { cloneElement, ReactElement } from \"react\";\nimport { unstable_ErrorRegion as ErrorRegion } from \"@stratakit/structures\";\nimport { ErrorItemRenderer, ErrorItemRendererProps } from \"./ErrorItemRenderer.js\";\nimport { useErrorNodes } from \"./FlatTreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.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) {\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"]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { HierarchyLevelDetails, TreeRendererProps } from "../Renderers.js";
|
|
2
|
-
import { TreeNode } from "../TreeNode.js";
|
|
3
|
-
import { TreeActionBaseAttributes } from "./TreeAction.js";
|
|
4
|
-
/**
|
|
5
|
-
* React component that renders a filter action for a tree item.
|
|
6
|
-
*
|
|
7
|
-
* The action calls the `onFilter` callback prop when clicked.
|
|
8
|
-
*
|
|
9
|
-
* @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action
|
|
10
|
-
* to tree items.
|
|
11
|
-
*
|
|
12
|
-
* @alpha
|
|
13
|
-
*/
|
|
14
|
-
export declare const TreeNodeFilterAction: import("react").NamedExoticComponent<{
|
|
15
|
-
/** Action to perform when the filter button is clicked for this node. */
|
|
16
|
-
onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;
|
|
17
|
-
} & TreeActionBaseAttributes & Pick<TreeRendererProps, "getHierarchyLevelDetails"> & {
|
|
18
|
-
node: TreeNode;
|
|
19
|
-
}>;
|
|
20
|
-
//# sourceMappingURL=TreeNodeFilterAction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeFilterAction.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAkB,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAS3E;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB;IAf/B,yEAAyE;eAC9D,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI;;UAmB5B,QAAQ;EAoB7C,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
import { memo, useCallback } from "react";
|
|
7
|
-
import filterSvg from "@stratakit/icons/filter.svg";
|
|
8
|
-
import { useLocalizationContext } from "./LocalizationContext.js";
|
|
9
|
-
import { TreeActionBase } from "./TreeAction.js";
|
|
10
|
-
/**
|
|
11
|
-
* React component that renders a filter action for a tree item.
|
|
12
|
-
*
|
|
13
|
-
* The action calls the `onFilter` callback prop when clicked.
|
|
14
|
-
*
|
|
15
|
-
* @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action
|
|
16
|
-
* to tree items.
|
|
17
|
-
*
|
|
18
|
-
* @alpha
|
|
19
|
-
*/
|
|
20
|
-
export const TreeNodeFilterAction = memo(function TreeNodeFilterAction({ node, onFilter, getHierarchyLevelDetails, ...actionAttributes }) {
|
|
21
|
-
const { localizedStrings } = useLocalizationContext();
|
|
22
|
-
const { filterHierarchyLevel, filterHierarchyLevelActiveDescription } = localizedStrings;
|
|
23
|
-
const handleClick = useCallback(() => {
|
|
24
|
-
const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);
|
|
25
|
-
hierarchyLevelDetails && onFilter?.(hierarchyLevelDetails);
|
|
26
|
-
}, [node, getHierarchyLevelDetails, onFilter]);
|
|
27
|
-
return (_jsx(TreeActionBase, { ...actionAttributes, label: filterHierarchyLevel, onClick: handleClick, icon: filterSvg, visible: node.isFiltered ? true : undefined, dot: node.isFiltered ? filterHierarchyLevelActiveDescription : undefined, hide: !onFilter || !node.isFilterable }));
|
|
28
|
-
});
|
|
29
|
-
//# sourceMappingURL=TreeNodeFilterAction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeFilterAction.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,SAAS,MAAM,6BAA6B,CAAC;AAGpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,cAAc,EAA4B,MAAM,iBAAiB,CAAC;AAS3E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,SAAS,oBAAoB,CAAC,EACrE,IAAI,EACJ,QAAQ,EACR,wBAAwB,EACxB,GAAG,gBAAgB,EAC4B;IAC/C,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACtD,MAAM,EAAE,oBAAoB,EAAE,qCAAqC,EAAE,GAAG,gBAAgB,CAAC;IAEzF,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE;QACnC,MAAM,qBAAqB,GAAG,wBAAwB,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClE,qBAAqB,IAAI,QAAQ,EAAE,CAAC,qBAAqB,CAAC,CAAC;IAC7D,CAAC,EAAE,CAAC,IAAI,EAAE,wBAAwB,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE/C,OAAO,CACL,KAAC,cAAc,OACT,gBAAgB,EACpB,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,WAAW,EACpB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EAC3C,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC,SAAS,EACxE,IAAI,EAAE,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,GACrC,CACH,CAAC;AACJ,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 { memo, useCallback } from \"react\";\nimport filterSvg from \"@stratakit/icons/filter.svg\";\nimport { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport { TreeNode } from \"../TreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\nimport { TreeActionBase, TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/** @alpha */\ntype TreeNodeFilterActionProps = {\n /** Action to perform when the filter button is clicked for this node. */\n onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n} & TreeActionBaseAttributes &\n Pick<TreeRendererProps, \"getHierarchyLevelDetails\">;\n\n/**\n * React component that renders a filter action for a tree item.\n *\n * The action calls the `onFilter` callback prop when clicked.\n *\n * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action\n * to tree items.\n *\n * @alpha\n */\nexport const TreeNodeFilterAction = memo(function TreeNodeFilterAction({\n node,\n onFilter,\n getHierarchyLevelDetails,\n ...actionAttributes\n}: TreeNodeFilterActionProps & { node: TreeNode }) {\n const { localizedStrings } = useLocalizationContext();\n const { filterHierarchyLevel, filterHierarchyLevelActiveDescription } = localizedStrings;\n\n const handleClick = useCallback(() => {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);\n hierarchyLevelDetails && onFilter?.(hierarchyLevelDetails);\n }, [node, getHierarchyLevelDetails, onFilter]);\n\n return (\n <TreeActionBase\n {...actionAttributes}\n label={filterHierarchyLevel}\n onClick={handleClick}\n icon={filterSvg}\n visible={node.isFiltered ? true : undefined}\n dot={node.isFiltered ? filterHierarchyLevelActiveDescription : undefined}\n hide={!onFilter || !node.isFilterable}\n />\n );\n});\n"]}
|