@itwin/presentation-hierarchies-react 2.0.0-alpha.54 → 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 +32 -0
- package/README.md +23 -61
- package/lib/presentation-hierarchies-react/Renderers.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/TreeNode.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseIModelTree.d.ts +1 -1
- package/lib/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseIModelTree.js +43 -48
- package/lib/presentation-hierarchies-react/UseIModelTree.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseTree.d.ts +8 -3
- package/lib/presentation-hierarchies-react/UseTree.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseTree.js +16 -20
- package/lib/presentation-hierarchies-react/UseTree.js.map +1 -0
- package/lib/presentation-hierarchies-react/Utils.js.map +1 -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.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/Utils.js.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/ErrorItemRenderer.d.ts +3 -3
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/ErrorItemRenderer.js +158 -128
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -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.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/RootErrorRenderer.js +64 -46
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeErrorRenderer.d.ts +3 -3
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeErrorRenderer.js +19 -20
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeFilterAction.js +43 -30
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeRenameAction.js +37 -31
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeRenderer.js +226 -191
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeRenderer.d.ts +3 -6
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeRenderer.js +39 -45
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -0
- package/lib/{esm/presentation-hierarchies-react.d.ts → presentation-hierarchies-react.d.ts} +3 -2
- package/lib/{esm/presentation-hierarchies-react.js → presentation-hierarchies-react.js} +3 -2
- package/lib/public/locales/en/PresentationHierarchies_1.0.json +26 -0
- package/package.json +18 -15
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/Utils.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +0 -1
- 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.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 -67
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +0 -1
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/Renderers.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/TreeNode.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseNodeHighlighting.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseNodeHighlighting.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseSelectionHandler.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseSelectionHandler.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/Utils.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/internal/DisposePolyfill.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/internal/TreeActions.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/internal/TreeLoader.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/internal/TreeModel.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/internal/TreeModel.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/internal/UseUnifiedSelection.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/internal/UseUnifiedSelection.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/internal/Utils.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/FlatTreeNode.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/FlatTreeNode.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/RootErrorRenderer.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeAction.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeAction.js +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeFilterAction.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeRenameAction.d.ts +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeRenderer.css +0 -0
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeRenderer.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlatTreeNode.js","names":["useMemo","TreeNode","FlatPlaceholderItem","id","level","placeholder","FlatTreeNodeItem","levelSize","posInLevel","node","FlatTreeItem","isPlaceholderItem","item","useFlatTreeItems","rootNodes","$","_c","t0","getFlatItems","nodes","flatItems","forEach","index","push","length","isExpanded","error","children","childNodes","useErrorNodes","flatMap","_temp","rootNode","isErrorNode","getErrorNodes","parent","errorList","ReturnType","childErrorList","Pick","Required","undefined"],"sources":["../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts"],"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\";\n\nimport type { 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"],"mappings":";;;;AA0CA,SAAgBW,kBAAkBC,MAAiD;AACjF,QAAO,iBAAiBA;;;;;;;;;AAU1B,SAAOC,iBAAAC,WAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;AAAA,KAAAF,EAAA,OAAAD,WAAA;AACgBG,OAAAC,aAAaJ,WAAW,EAAE;AAAAC,IAAA,KAAAD;AAAAC,IAAA,KAAAE;OAAAA,MAAAF,EAAA;AAAA,QAA1BE;;AAGvB,SAASC,aAAaC,OAAmBf,OAAe;CACtD,MAAMgB,YAA4B,EAAE;AACpCD,OAAME,SAASZ,MAAMa,UAAU;AAC7BF,YAAUG,KAAK;GAAEd;GAAMN,IAAIM,KAAKN;GAAIC;GAAOG,WAAWY,MAAMK;GAAQhB,YAAYc,QAAQ;GAAG,CAAC;AAC5F,MAAI,CAACb,KAAKgB,cAAchB,KAAKiB,MAC3B;AAEF,MAAIjB,KAAKkB,aAAa,MAAM;GAC1B,MAAMC,aAAaV,aAAaT,KAAKkB,UAAUvB,QAAQ,EAAE;AACzDgB,aAAUG,KAAK,GAAGK,WAAW;AAC7B;;AAGFR,YAAUG,KAAK;GAAEpB,IAAI,GAAGM,KAAKN,GAAE;GAAyBC,OAAOA,QAAQ;GAAGC,aAAa;GAAM,CAA+B;GAC5H;AACF,QAAOe;;;;;;;AAQT,SAAOS,cAAAf,WAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;AAAA,KAAAF,EAAA,OAAAD,WAAA;AAGDG,OAAAH,UAASgB,QAASC,MAQhB;AAAAhB,IAAA,KAAAD;AAAAC,IAAA,KAAAE;OAAAA,MAAAF,EAAA;AAAA,QARFE;;AAHC,SAAAc,MAAAC,UAAA;AAIC,KAAIC,YAAYD,SAAS,CAAA,QAChB,CAACA,SAAS;AAEnB,KAAIA,SAAQL,aAAc,KAAI,QACrB,EAAE;AACV,QACMO,cAAcF,SAAS;;AAMtC,SAASE,cAAcC,QAAkB;CACvC,MAAMC,YAA8C,EAAE;AAEtD,KAAID,OAAOR,aAAa,KACtB,QAAO,EAAE;AAGXQ,QAAOR,SAASN,SAASZ,SAAS;AAChC,MAAIwB,YAAYxB,KAAK,EAAE;AACrB2B,aAAUb,KAAKd,KAAK;AACpB;;AAGF,MAAIA,KAAKkB,aAAa,MAAM;GAC1B,MAAMW,iBAAiBJ,cAAczB,KAAK;AAC1C2B,aAAUb,KAAK,GAAGe,eAAe;AACjC;;GAEF;AACF,QAAOF;;AAGT,SAASH,YAAYxB,MAAsE;AACzF,QAAOA,KAAKiB,UAAUe"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { JSX, PropsWithChildren } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Properties for `LocalizationContextProvider`.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
interface LocalizationContextProviderProps {
|
|
9
|
+
/** Localization object compatible with `@itwin/core-common` */
|
|
10
|
+
localization: {
|
|
11
|
+
getLocalizedString: (key: string) => string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Context provider for localizing components.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
declare function LocalizationContextProvider({
|
|
19
|
+
localization,
|
|
20
|
+
children
|
|
21
|
+
}: PropsWithChildren<LocalizationContextProviderProps>): JSX.Element;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { LocalizationContextProvider };
|
|
24
|
+
//# sourceMappingURL=LocalizationContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalizationContext.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"mappings":";;;AAW0C;;;;AAAA,UAQhC,gCAAA;EAGN;EADF,YAAA;IACE,kBAAA,GAAqB,GAAA;EAAA;AAAA;;;;;iBAQT,2BAAA,CAAA;EAA8B,YAAA;EAAc;AAAA,GAAY,iBAAA,CAAkB,gCAAA,IAAoC,GAAA,CAAI,OAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { LOCALIZATION_NAMESPACE } from "../internal/LocalizedStrings.js";
|
|
2
|
+
import { c } from "react-compiler-runtime";
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx
|
|
7
|
+
const localizationContext = createContext((key) => key);
|
|
8
|
+
/**
|
|
9
|
+
* Context provider for localizing components.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
function LocalizationContextProvider(t0) {
|
|
13
|
+
const $ = c(5);
|
|
14
|
+
const { localization, children } = t0;
|
|
15
|
+
let t1;
|
|
16
|
+
if ($[0] !== localization) {
|
|
17
|
+
t1 = (key) => localization.getLocalizedString(`${LOCALIZATION_NAMESPACE}:${key}`);
|
|
18
|
+
$[0] = localization;
|
|
19
|
+
$[1] = t1;
|
|
20
|
+
} else t1 = $[1];
|
|
21
|
+
const translate = t1;
|
|
22
|
+
let t2;
|
|
23
|
+
if ($[2] !== children || $[3] !== translate) {
|
|
24
|
+
t2 = /* @__PURE__ */ jsx(localizationContext.Provider, {
|
|
25
|
+
value: translate,
|
|
26
|
+
children
|
|
27
|
+
});
|
|
28
|
+
$[2] = children;
|
|
29
|
+
$[3] = translate;
|
|
30
|
+
$[4] = t2;
|
|
31
|
+
} else t2 = $[4];
|
|
32
|
+
return t2;
|
|
33
|
+
}
|
|
34
|
+
/** @internal */
|
|
35
|
+
function useTranslation() {
|
|
36
|
+
return useContext(localizationContext);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { LocalizationContextProvider, useTranslation };
|
|
41
|
+
//# sourceMappingURL=LocalizationContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalizationContext.js","names":["createContext","useContext","useMemo","LOCALIZATION_NAMESPACE","JSX","PropsWithChildren","LocalizationKey","TranslateFunc","key","localizationContext","LocalizationContextProviderProps","localization","getLocalizedString","LocalizationContextProvider","t0","$","_c","children","t1","translate","t2","useTranslation"],"sources":["../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { createContext, useContext, useMemo } from \"react\";\nimport { LOCALIZATION_NAMESPACE } from \"../internal/LocalizedStrings.js\";\n\nimport type { JSX, PropsWithChildren } from \"react\";\nimport type { LocalizationKey } from \"../internal/LocalizedStrings.js\";\n\ntype TranslateFunc = (key: LocalizationKey) => string;\n\nconst localizationContext = createContext<TranslateFunc>((key) => key);\n\n/**\n * Properties for `LocalizationContextProvider`.\n * @public\n */\ninterface LocalizationContextProviderProps {\n /** Localization object compatible with `@itwin/core-common` */\n localization: {\n getLocalizedString: (key: string) => string;\n };\n}\n\n/**\n * Context provider for localizing components.\n * @public\n */\nexport function LocalizationContextProvider({ localization, children }: PropsWithChildren<LocalizationContextProviderProps>): JSX.Element {\n const translate = useMemo<TranslateFunc>(() => {\n return (key: LocalizationKey) => localization.getLocalizedString(`${LOCALIZATION_NAMESPACE}:${key}`);\n }, [localization]);\n return <localizationContext.Provider value={translate}>{children}</localizationContext.Provider>;\n}\n\n/** @internal */\nexport function useTranslation() {\n return useContext(localizationContext);\n}\n"],"mappings":";;;;;;AAaA,MAAMS,sBAAsBT,eAA8BQ,QAAQA,IAAI;;;;;AAiBtE,SAAOK,4BAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAqC,MAAA,EAAAL,cAAAM,aAAAH;CAA+E,IAAAI;AAAA,KAAAH,EAAA,OAAAJ,cAAA;AAEhHO,QAAAV,QAA0BG,aAAYC,mBAAoB,GAAGT,uBAAsB,GAAIK,MAAM;AAAAO,IAAA,KAAAJ;AAAAI,IAAA,KAAAG;OAAAA,MAAAH,EAAA;CADtG,MAAAI,YACED;CACiB,IAAAE;AAAA,KAAAL,EAAA,OAAAE,YAAAF,EAAA,OAAAI,WAAA;AACZC,OAAA,oBAAA,oBAAA;GAAqCD,OAAAA;GAAYF;IAAwC;AAAAF,IAAA,KAAAE;AAAAF,IAAA,KAAAI;AAAAJ,IAAA,KAAAK;OAAAA,MAAAL,EAAA;AAAA,QAAzFK;;;AAIT,SAAOC,iBAAA;AAAA,QACEpB,WAAWQ,oBAAoB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RootErrorRenderer.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/RootErrorRenderer.tsx"],"mappings":";;;;;;;AAiBA;KAAY,+BAAA;;;;EAIV,KAAA,EAAO,SAAA;AAAA,IACL,sBAAA;;;AAOJ;;;iBAAgB,0BAAA,CAAA;EAA6B,KAAA;EAAO,wBAAA;EAA0B;AAAA,GAAc,+BAAA,GAAkC,GAAA,CAAI,OAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useTranslation } from "./LocalizationContext.js";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { Button, Text } from "@stratakit/bricks";
|
|
@@ -12,9 +12,9 @@ import errorSvg from "@stratakit/icons/status-error.svg";
|
|
|
12
12
|
* @alpha
|
|
13
13
|
*/
|
|
14
14
|
function StrataKitRootErrorRenderer(t0) {
|
|
15
|
-
const $ = c(
|
|
15
|
+
const $ = c(25);
|
|
16
16
|
const { error, getHierarchyLevelDetails, reloadTree } = t0;
|
|
17
|
-
const
|
|
17
|
+
const translate = useTranslation();
|
|
18
18
|
if (error.type === "ResultSetTooLarge") {
|
|
19
19
|
let t1;
|
|
20
20
|
if ($[0] !== getHierarchyLevelDetails) {
|
|
@@ -24,66 +24,84 @@ function StrataKitRootErrorRenderer(t0) {
|
|
|
24
24
|
} else t1 = $[1];
|
|
25
25
|
const onOverrideLimit = t1;
|
|
26
26
|
let t2;
|
|
27
|
-
if ($[2] !== error.resultSetSizeLimit || $[3] !==
|
|
28
|
-
t2 =
|
|
27
|
+
if ($[2] !== error.resultSetSizeLimit || $[3] !== translate) {
|
|
28
|
+
t2 = translate("rootResultLimitExceeded").replace("{{limit}}", error.resultSetSizeLimit.toString());
|
|
29
29
|
$[2] = error.resultSetSizeLimit;
|
|
30
|
-
$[3] =
|
|
30
|
+
$[3] = translate;
|
|
31
31
|
$[4] = t2;
|
|
32
32
|
} else t2 = $[4];
|
|
33
33
|
let t3;
|
|
34
|
-
if ($[5] !==
|
|
35
|
-
t3 =
|
|
34
|
+
if ($[5] !== translate) {
|
|
35
|
+
t3 = translate("increaseHierarchyLimitToUnlimited");
|
|
36
|
+
$[5] = translate;
|
|
37
|
+
$[6] = t3;
|
|
38
|
+
} else t3 = $[6];
|
|
39
|
+
let t4;
|
|
40
|
+
if ($[7] !== onOverrideLimit || $[8] !== t3) {
|
|
41
|
+
t4 = [{
|
|
36
42
|
action: onOverrideLimit,
|
|
37
|
-
label:
|
|
43
|
+
label: t3,
|
|
38
44
|
condition: _temp
|
|
39
45
|
}];
|
|
40
|
-
$[
|
|
41
|
-
$[
|
|
42
|
-
$[
|
|
43
|
-
} else
|
|
44
|
-
let
|
|
45
|
-
if ($[
|
|
46
|
-
|
|
46
|
+
$[7] = onOverrideLimit;
|
|
47
|
+
$[8] = t3;
|
|
48
|
+
$[9] = t4;
|
|
49
|
+
} else t4 = $[9];
|
|
50
|
+
let t5;
|
|
51
|
+
if ($[10] !== t2 || $[11] !== t4) {
|
|
52
|
+
t5 = /* @__PURE__ */ jsx(RootErrorContainer, {
|
|
47
53
|
message: t2,
|
|
48
|
-
actions:
|
|
54
|
+
actions: t4
|
|
49
55
|
});
|
|
50
|
-
$[
|
|
51
|
-
$[
|
|
52
|
-
$[
|
|
53
|
-
} else
|
|
54
|
-
return
|
|
56
|
+
$[10] = t2;
|
|
57
|
+
$[11] = t4;
|
|
58
|
+
$[12] = t5;
|
|
59
|
+
} else t5 = $[12];
|
|
60
|
+
return t5;
|
|
55
61
|
}
|
|
56
62
|
let t1;
|
|
57
|
-
if ($[
|
|
58
|
-
t1 = ()
|
|
63
|
+
if ($[13] !== translate) {
|
|
64
|
+
t1 = translate("failedToCreateRootHierarchy");
|
|
65
|
+
$[13] = translate;
|
|
66
|
+
$[14] = t1;
|
|
67
|
+
} else t1 = $[14];
|
|
68
|
+
let t2;
|
|
69
|
+
if ($[15] !== reloadTree) {
|
|
70
|
+
t2 = () => reloadTree({
|
|
59
71
|
parentNodeId: void 0,
|
|
60
72
|
state: "reset"
|
|
61
73
|
});
|
|
62
|
-
$[
|
|
63
|
-
$[
|
|
64
|
-
} else
|
|
65
|
-
let t2;
|
|
66
|
-
if ($[13] !== localizedStrings.retry || $[14] !== t1) {
|
|
67
|
-
t2 = [{
|
|
68
|
-
action: t1,
|
|
69
|
-
label: localizedStrings.retry,
|
|
70
|
-
condition: _temp2
|
|
71
|
-
}];
|
|
72
|
-
$[13] = localizedStrings.retry;
|
|
73
|
-
$[14] = t1;
|
|
74
|
-
$[15] = t2;
|
|
75
|
-
} else t2 = $[15];
|
|
74
|
+
$[15] = reloadTree;
|
|
75
|
+
$[16] = t2;
|
|
76
|
+
} else t2 = $[16];
|
|
76
77
|
let t3;
|
|
77
|
-
if ($[
|
|
78
|
-
t3 =
|
|
79
|
-
|
|
80
|
-
actions: t2
|
|
81
|
-
});
|
|
82
|
-
$[16] = localizedStrings.failedToCreateRootHierarchy;
|
|
83
|
-
$[17] = t2;
|
|
78
|
+
if ($[17] !== translate) {
|
|
79
|
+
t3 = translate("retry");
|
|
80
|
+
$[17] = translate;
|
|
84
81
|
$[18] = t3;
|
|
85
82
|
} else t3 = $[18];
|
|
86
|
-
|
|
83
|
+
let t4;
|
|
84
|
+
if ($[19] !== t2 || $[20] !== t3) {
|
|
85
|
+
t4 = [{
|
|
86
|
+
action: t2,
|
|
87
|
+
label: t3,
|
|
88
|
+
condition: _temp2
|
|
89
|
+
}];
|
|
90
|
+
$[19] = t2;
|
|
91
|
+
$[20] = t3;
|
|
92
|
+
$[21] = t4;
|
|
93
|
+
} else t4 = $[21];
|
|
94
|
+
let t5;
|
|
95
|
+
if ($[22] !== t1 || $[23] !== t4) {
|
|
96
|
+
t5 = /* @__PURE__ */ jsx(RootErrorContainer, {
|
|
97
|
+
message: t1,
|
|
98
|
+
actions: t4
|
|
99
|
+
});
|
|
100
|
+
$[22] = t1;
|
|
101
|
+
$[23] = t4;
|
|
102
|
+
$[24] = t5;
|
|
103
|
+
} else t5 = $[24];
|
|
104
|
+
return t5;
|
|
87
105
|
}
|
|
88
106
|
function _temp2() {
|
|
89
107
|
return true;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RootErrorRenderer.js","names":["Button","Text","Icon","errorSvg","useTranslation","JSX","RootErrorRendererProps","ErrorInfo","StrataKitRootErrorRendererProps","error","StrataKitRootErrorRenderer","t0","$","_c","getHierarchyLevelDetails","reloadTree","translate","type","t1","undefined","setSizeLimit","onOverrideLimit","t2","resultSetSizeLimit","replace","toString","t3","t4","action","label","condition","_temp","t5","parentNodeId","state","_temp2","RootErrorContainerProps","message","actions","RootErrorContainer","Symbol","for","height","display","flexDirection","justifyContent","alignItems","gap","textAlign","filter","_temp3","map","_temp4","t6"],"sources":["../../../src/presentation-hierarchies-react/stratakit/RootErrorRenderer.tsx"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Button, Text } from \"@stratakit/bricks\";\nimport { Icon } from \"@stratakit/foundations\";\nimport errorSvg from \"@stratakit/icons/status-error.svg\";\nimport { useTranslation } from \"./LocalizationContext.js\";\n\nimport type { JSX } from \"react\";\nimport type { RootErrorRendererProps } from \"../Renderers.js\";\nimport type { ErrorInfo } from \"../TreeNode.js\";\n\n/**\n * @alpha\n */\nexport type StrataKitRootErrorRendererProps = {\n /**\n * Root error to be displayed\n */\n error: ErrorInfo;\n} & RootErrorRendererProps;\n\n/**\n * A component that renders root node error state.\n *\n * @alpha\n */\nexport function StrataKitRootErrorRenderer({ error, getHierarchyLevelDetails, reloadTree }: StrataKitRootErrorRendererProps): JSX.Element {\n const translate = useTranslation();\n\n if (error.type === \"ResultSetTooLarge\") {\n const onOverrideLimit = () => getHierarchyLevelDetails(undefined)?.setSizeLimit(\"unbounded\");\n return (\n <RootErrorContainer\n message={translate(\"rootResultLimitExceeded\").replace(\"{{limit}}\", error.resultSetSizeLimit.toString())}\n actions={[\n {\n action: onOverrideLimit,\n label: translate(\"increaseHierarchyLimitToUnlimited\"),\n condition: () => true,\n },\n ]}\n />\n );\n }\n\n return (\n <RootErrorContainer\n message={translate(\"failedToCreateRootHierarchy\")}\n actions={[\n {\n action: () => reloadTree({ parentNodeId: undefined, state: \"reset\" }),\n label: translate(\"retry\"),\n condition: () => true,\n },\n ]}\n />\n );\n}\n\ninterface RootErrorContainerProps {\n message: string;\n actions?: { action: () => void; label: string; condition: () => boolean }[];\n}\n\nfunction RootErrorContainer({ actions, message }: RootErrorContainerProps) {\n return (\n <div style={{ height: \"100%\", display: \"flex\", flexDirection: \"column\", justifyContent: \"center\", alignItems: \"center\", gap: \"0.5rem\" }}>\n <Icon href={errorSvg} size=\"large\" />\n <Text variant={\"body-sm\"} style={{ textAlign: \"center\" }}>\n {message}\n </Text>\n {actions\n ?.filter(({ condition }) => condition())\n .map((action) => {\n return (\n <Button key={action.label} onClick={() => action.action()}>\n {action.label}\n </Button>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA6BA,SAAOU,2BAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAoC,MAAA,EAAAJ,OAAAK,0BAAAC,eAAAJ;CACzC,MAAAK,YAAkBZ,gBAAgB;AAElC,KAAIK,MAAKQ,SAAU,qBAAmB;EAAA,IAAAC;AAAA,MAAAN,EAAA,OAAAE,0BAAA;AACZI,cAAMJ,yBAAyBK,OAAwB,EAAAC,aAAC,YAAY;AAAAR,KAAA,KAAAE;AAAAF,KAAA,KAAAM;QAAAA,MAAAN,EAAA;EAA5F,MAAAS,kBAAwBH;EAAqE,IAAAI;AAAA,MAAAV,EAAA,OAAAH,MAAAc,sBAAAX,EAAA,OAAAI,WAAA;AAGhFM,QAAAN,UAAU,0BAA0B,CAAAQ,QAAS,aAAaf,MAAKc,mBAAmBE,UAAW,CAAC;AAAAb,KAAA,KAAAH,MAAAc;AAAAX,KAAA,KAAAI;AAAAJ,KAAA,KAAAU;QAAAA,MAAAV,EAAA;EAAA,IAAAc;AAAA,MAAAd,EAAA,OAAAI,WAAA;AAI5FU,QAAAV,UAAU,oCAAoC;AAAAJ,KAAA,KAAAI;AAAAJ,KAAA,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K;;IASG;AAAApB,IAAA,KAAAe;AAAAf,IAAA,KAAAoB;AAAApB,IAAA,KAAAyC;OAAAA,MAAAzC,EAAA;AAAA,QAdNyC;;AAFJ,SAAAD,OAAAxB,QAAA;AAAA,QAWY,oBAAC;EAAmC,eAAMA,OAAMA,QAAQ;YACrDA,OAAMC;IADID,OAAMC,MAEV;;AAbrB,SAAAqB,OAAAvC,IAAA;CAQkB,MAAA,EAAAmB,cAAAnB;AAAa,QAAKmB,WAAW"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeAction.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeAction.tsx"],"mappings":";;;;;;AAeA;;;UAAiB,wBAAA;EAaX;AAIN;;;;;;EATE,OAAA;EASiG;;;;EAJjG,IAAA;AAAA;;KAIU,mBAAA,GAAsB,cAAA,QAAsB,IAAA,CAAK,UAAA,IAAc,wBAAA;;;;;;;;;;;;;;;;;;;;cAqB9D,cAAA,EAAgB,oBAAA,CAAqB,mBAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeAction.js","names":["memo","DropdownMenu","Tree","ComponentProps","NamedExoticComponent","TreeActionBaseAttributes","variant","hide","TreeActionBaseProps","ItemAction","TreeActionBase","t0","$","_c","actionProps","dot","t1","visible","undefined","t2","t3"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeAction.tsx"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { memo } from \"react\";\nimport { DropdownMenu, Tree } from \"@stratakit/structures\";\n\nimport type { ComponentProps, NamedExoticComponent } from \"react\";\n\n/**\n * Attributes used to decide how to render tree actions. They allow to differentiate action style based on the context\n * where that action is used.\n * @alpha\n */\nexport interface TreeActionBaseAttributes {\n /**\n * Specifies action variant supported by tree nodes:\n *\n * - \"default\" - standard action displayed in the dropdown menu accessible through the ellipsis button on the node.\n * - \"inline\" - actions displayed directly on the tree node.\n * - \"context-menu\" - actions displayed in the context menu opened by right-clicking the tree node.\n */\n variant?: \"default\" | \"inline\" | \"context-menu\";\n /**\n * Indicates that the actions is not applicable for current tree node and should be hidden.\n * When set to true, the action will not be rendered at all.\n */\n hide?: boolean;\n}\n\n/** @alpha */\nexport type TreeActionBaseProps = ComponentProps<typeof Tree.ItemAction> & TreeActionBaseAttributes;\n\n/**\n * Base component used to render tree actions. It is designed to allow rendering same action in different contexts: inline, dropdown, context menu.\n * Should be used together with `StrataKitTreeNodeRenderer` and returned from `getInlineActions`, `getMenuActions` and `getContextMenuActions` callbacks.\n *\n * When implementing custom action that returns this component, make sure to forward `TreeActionBaseAttributes` props to it. Example:\n *\n * ```tsx\n * interface MyCustomTreeActionProps extends TreeActionBaseAttributes {\n * myProp: string\n * }\n *\n * function MyCustomTreeAction({ myProp, ...attributes }: MyCustomTreeActionProps) {\n * // custom button logic goes here\n * return <TreeActionBase {...attributes} icon={...} onClick={...} />\n * }\n * ```\n *\n * @alpha\n */\nexport const TreeActionBase: NamedExoticComponent<TreeActionBaseProps> = memo(function TreeActionBase({\n hide,\n variant = \"default\",\n dot,\n visible,\n ...actionProps\n}: TreeActionBaseProps) {\n if (hide) {\n return variant === \"inline\" ? <Tree.ItemAction {...actionProps} visible={false} /> : undefined;\n }\n\n if (variant === \"context-menu\") {\n return <DropdownMenu.Item {...actionProps} />;\n }\n\n return <Tree.ItemAction {...actionProps} dot={dot} visible={variant === \"inline\" ? visible : undefined} />;\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,MAAaU,iBAA4DV,KAAK,SAAAU,eAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAR;CAAA,IAAAS;CAAA,IAAAC;AAAA,KAAAL,EAAA,OAAAD,IAAA;AAAwB,GAAA,CAAAJ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odes: ReturnType<typeof useErrorNodes>;
|
|
19
|
-
/** Callback to render custom error messages. Component should be wrapped in `
|
|
19
|
+
/** Callback to render custom error messages. Component should be wrapped in `unstable_ErrorRegion.Item` from `@stratakit/structures` package. */
|
|
20
20
|
renderError?: (props: ErrorItemRendererProps) => ReactElement;
|
|
21
21
|
}
|
|
22
22
|
/** @alpha */
|
|
23
23
|
type TreeErrorRendererProps = TreeErrorRendererOwnProps & Omit<ErrorItemRendererProps, "errorNode">;
|
|
24
24
|
/**
|
|
25
|
-
* A component that renders error display dropdown using the `unstable_ErrorRegion` component from `@
|
|
26
|
-
* As input, the component uses a list of `ErrorNode` objects, which are generally created using the `
|
|
25
|
+
* A component that renders error display dropdown using the `unstable_ErrorRegion` component from `@stratakit/structures`.
|
|
26
|
+
* As input, the component uses a list of `ErrorNode` objects, which are generally created using the `useErrorNodes` hook.
|
|
27
27
|
*
|
|
28
28
|
* @alpha
|
|
29
29
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeErrorRenderer.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx"],"mappings":";;;;;;;AAYuD;;;UAO7C,yBAAA;EAOI;;;;EAFZ,SAAA;EAAA;EAEA,UAAA,EAAY,UAAA,QAAkB,aAAA;EAAlB;EAEZ,WAAA,IAAe,KAAA,EAAO,sBAAA,KAA2B,YAAA;AAAA;;KAIvC,sBAAA,GAAyB,yBAAA,GAA4B,IAAA,CAAK,sBAAA;;;;AAAtE;;;iBAQgB,iBAAA,CAAA;EAAoB,SAAA;EAAW,UAAA;EAAY,WAAA;EAAA,GAAgB;AAAA,GAA0B,sBAAA,GAAyB,GAAA,CAAI,OAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useTranslation } from "./LocalizationContext.js";
|
|
2
2
|
import { ErrorItemRenderer } from "./ErrorItemRenderer.js";
|
|
3
3
|
import { c } from "react-compiler-runtime";
|
|
4
4
|
import { cloneElement } from "react";
|
|
@@ -7,15 +7,15 @@ import { unstable_ErrorRegion } from "@stratakit/structures";
|
|
|
7
7
|
|
|
8
8
|
//#region src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx
|
|
9
9
|
/**
|
|
10
|
-
* A component that renders error display dropdown using the `unstable_ErrorRegion` component from `@
|
|
11
|
-
* As input, the component uses a list of `ErrorNode` objects, which are generally created using the `
|
|
10
|
+
* A component that renders error display dropdown using the `unstable_ErrorRegion` component from `@stratakit/structures`.
|
|
11
|
+
* As input, the component uses a list of `ErrorNode` objects, which are generally created using the `useErrorNodes` hook.
|
|
12
12
|
*
|
|
13
13
|
* @alpha
|
|
14
14
|
*/
|
|
15
15
|
function TreeErrorRenderer(t0) {
|
|
16
|
-
const $ = c(
|
|
16
|
+
const $ = c(11);
|
|
17
17
|
const { treeLabel, errorNodes, renderError, ...errorItemRendererProps } = t0;
|
|
18
|
-
const
|
|
18
|
+
const translate = useTranslation();
|
|
19
19
|
const errorItems = errorNodes.map((errorNode) => {
|
|
20
20
|
const errorRendererProps = {
|
|
21
21
|
errorNode,
|
|
@@ -30,33 +30,32 @@ function TreeErrorRenderer(t0) {
|
|
|
30
30
|
$[0] = t1;
|
|
31
31
|
} else t1 = $[0];
|
|
32
32
|
let t2;
|
|
33
|
-
if ($[1] !==
|
|
34
|
-
t2 =
|
|
35
|
-
$[1] =
|
|
33
|
+
if ($[1] !== translate || $[2] !== treeLabel) {
|
|
34
|
+
t2 = translate("issuesForTree").replace("{{tree_label}}", treeLabel);
|
|
35
|
+
$[1] = translate;
|
|
36
36
|
$[2] = treeLabel;
|
|
37
37
|
$[3] = t2;
|
|
38
38
|
} else t2 = $[3];
|
|
39
39
|
let t3;
|
|
40
|
-
if ($[4] !== errorNodes.length || $[5] !==
|
|
41
|
-
t3 = errorNodes.length === 0 ?
|
|
40
|
+
if ($[4] !== errorNodes.length || $[5] !== translate) {
|
|
41
|
+
t3 = errorNodes.length === 0 ? translate("noIssuesFound") : translate("issuesFound").replace("{{number_of_issues}}", errorNodes.length.toString());
|
|
42
42
|
$[4] = errorNodes.length;
|
|
43
|
-
$[5] =
|
|
44
|
-
$[6] =
|
|
45
|
-
|
|
46
|
-
} else t3 = $[7];
|
|
43
|
+
$[5] = translate;
|
|
44
|
+
$[6] = t3;
|
|
45
|
+
} else t3 = $[6];
|
|
47
46
|
let t4;
|
|
48
|
-
if ($[
|
|
47
|
+
if ($[7] !== errorItems || $[8] !== t2 || $[9] !== t3) {
|
|
49
48
|
t4 = /* @__PURE__ */ jsx(unstable_ErrorRegion.Root, {
|
|
50
49
|
style: t1,
|
|
51
50
|
"aria-label": t2,
|
|
52
51
|
label: t3,
|
|
53
52
|
items: errorItems
|
|
54
53
|
});
|
|
55
|
-
$[
|
|
56
|
-
$[
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
59
|
-
} else t4 = $[
|
|
54
|
+
$[7] = errorItems;
|
|
55
|
+
$[8] = t2;
|
|
56
|
+
$[9] = t3;
|
|
57
|
+
$[10] = t4;
|
|
58
|
+
} else t4 = $[10];
|
|
60
59
|
return t4;
|
|
61
60
|
}
|
|
62
61
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeErrorRenderer.js","names":["cloneElement","unstable_ErrorRegion","ErrorRegion","ErrorItemRenderer","useTranslation","JSX","ReactElement","ErrorItemRendererProps","useErrorNodes","TreeErrorRendererOwnProps","treeLabel","errorNodes","ReturnType","renderError","props","TreeErrorRendererProps","Omit","TreeErrorRenderer","t0","$","_c","errorItemRendererProps","translate","errorItems","map","errorNode","errorRendererProps","key","id","t1","Symbol","for","width","t2","replace","t3","length","toString","t4"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeErrorRenderer.tsx"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { cloneElement } from \"react\";\nimport { unstable_ErrorRegion as ErrorRegion } from \"@stratakit/structures\";\nimport { ErrorItemRenderer } from \"./ErrorItemRenderer.js\";\nimport { useTranslation } from \"./LocalizationContext.js\";\n\nimport type { JSX, ReactElement } from \"react\";\nimport type { ErrorItemRendererProps } from \"./ErrorItemRenderer.js\";\nimport type { useErrorNodes } from \"./FlatTreeNode.js\";\n\n/**\n * Interface containing building blocks for `TreeErrorRenderer`.\n *\n * @alpha\n */\ninterface TreeErrorRendererOwnProps {\n /**\n * A user friendly display label of the tree. Should be unique within the consuming application,\n * as it's used for creating a unique accessible label for the error region.\n */\n treeLabel: string;\n /** List of error nodes to render errors for. */\n errorNodes: ReturnType<typeof useErrorNodes>;\n /** Callback to render custom error messages. Component should be wrapped in `unstable_ErrorRegion.Item` from `@stratakit/structures` 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 `@stratakit/structures`.\n * As input, the component uses a list of `ErrorNode` objects, which are generally created using the `useErrorNodes` hook.\n *\n * @alpha\n */\nexport function TreeErrorRenderer({ treeLabel, errorNodes, renderError, ...errorItemRendererProps }: TreeErrorRendererProps): JSX.Element {\n const translate = useTranslation();\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={translate(\"issuesForTree\").replace(\"{{tree_label}}\", treeLabel)}\n label={errorNodes.length === 0 ? translate(\"noIssuesFound\") : translate(\"issuesFound\").replace(\"{{number_of_issues}}\", errorNodes.length.toString())}\n items={errorItems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AAE;GACAZ,OAAAA;IACP;AAAAJ,IAAA,KAAAI;AAAAJ,IAAA,KAAAc;AAAAd,IAAA,KAAAgB;AAAAhB,IAAA,MAAAmB;OAAAA,MAAAnB,EAAA;AAAA,QALFmB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeNodeFilterAction.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.tsx"],"mappings":";;;;;;;KAgBK,yBAAA;EAAA;;;EAIH,QAAA,IAAY,qBAAA,EAAuB,qBAAA;AAAA,IACjC,wBAAA,GACF,IAAA,CAAK,iBAAA;;;;;;;;;;;cAYM,oBAAA,EAAsB,oBAAA,CAAqB,yBAAA;EAA8B,IAAA,EAAM,QAAA;AAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { useTranslation } from "./LocalizationContext.js";
|
|
1
2
|
import { TreeActionBase } from "./TreeAction.js";
|
|
2
|
-
import { useLocalizationContext } from "./LocalizationContext.js";
|
|
3
3
|
import { c } from "react-compiler-runtime";
|
|
4
4
|
import { memo } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -17,7 +17,7 @@ import filterSvg from "@stratakit/icons/filter.svg";
|
|
|
17
17
|
* @alpha
|
|
18
18
|
*/
|
|
19
19
|
const TreeNodeFilterAction = memo(function TreeNodeFilterAction(t0) {
|
|
20
|
-
const $ = c(
|
|
20
|
+
const $ = c(20);
|
|
21
21
|
let actionAttributes;
|
|
22
22
|
let getHierarchyLevelDetails;
|
|
23
23
|
let node;
|
|
@@ -35,43 +35,56 @@ const TreeNodeFilterAction = memo(function TreeNodeFilterAction(t0) {
|
|
|
35
35
|
node = $[3];
|
|
36
36
|
onFilter = $[4];
|
|
37
37
|
}
|
|
38
|
-
const
|
|
39
|
-
const { filterHierarchyLevel, filterHierarchyLevelActiveDescription } = localizedStrings;
|
|
38
|
+
const translate = useTranslation();
|
|
40
39
|
let t1;
|
|
41
|
-
if ($[5] !==
|
|
42
|
-
t1 = ()
|
|
40
|
+
if ($[5] !== translate) {
|
|
41
|
+
t1 = translate("filterHierarchyLevel");
|
|
42
|
+
$[5] = translate;
|
|
43
|
+
$[6] = t1;
|
|
44
|
+
} else t1 = $[6];
|
|
45
|
+
const filterHierarchyLevel = t1;
|
|
46
|
+
let t2;
|
|
47
|
+
if ($[7] !== translate) {
|
|
48
|
+
t2 = translate("filterHierarchyLevelActiveDescription");
|
|
49
|
+
$[7] = translate;
|
|
50
|
+
$[8] = t2;
|
|
51
|
+
} else t2 = $[8];
|
|
52
|
+
const filterHierarchyLevelActiveDescription = t2;
|
|
53
|
+
let t3;
|
|
54
|
+
if ($[9] !== getHierarchyLevelDetails || $[10] !== node.id || $[11] !== onFilter) {
|
|
55
|
+
t3 = () => {
|
|
43
56
|
const hierarchyLevelDetails = getHierarchyLevelDetails(node.id);
|
|
44
57
|
hierarchyLevelDetails && onFilter?.(hierarchyLevelDetails);
|
|
45
58
|
};
|
|
46
|
-
$[
|
|
47
|
-
$[
|
|
48
|
-
$[
|
|
49
|
-
$[
|
|
50
|
-
} else
|
|
51
|
-
const handleClick =
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
let
|
|
56
|
-
if ($[
|
|
57
|
-
|
|
59
|
+
$[9] = getHierarchyLevelDetails;
|
|
60
|
+
$[10] = node.id;
|
|
61
|
+
$[11] = onFilter;
|
|
62
|
+
$[12] = t3;
|
|
63
|
+
} else t3 = $[12];
|
|
64
|
+
const handleClick = t3;
|
|
65
|
+
const t4 = node.isFiltered ? true : void 0;
|
|
66
|
+
const t5 = node.isFiltered ? filterHierarchyLevelActiveDescription : void 0;
|
|
67
|
+
const t6 = !onFilter || !node.isFilterable;
|
|
68
|
+
let t7;
|
|
69
|
+
if ($[13] !== actionAttributes || $[14] !== filterHierarchyLevel || $[15] !== handleClick || $[16] !== t4 || $[17] !== t5 || $[18] !== t6) {
|
|
70
|
+
t7 = /* @__PURE__ */ jsx(TreeActionBase, {
|
|
58
71
|
...actionAttributes,
|
|
59
72
|
label: filterHierarchyLevel,
|
|
60
73
|
onClick: handleClick,
|
|
61
74
|
icon: filterSvg,
|
|
62
|
-
visible:
|
|
63
|
-
dot:
|
|
64
|
-
hide:
|
|
75
|
+
visible: t4,
|
|
76
|
+
dot: t5,
|
|
77
|
+
hide: t6
|
|
65
78
|
});
|
|
66
|
-
$[
|
|
67
|
-
$[
|
|
68
|
-
$[
|
|
69
|
-
$[
|
|
70
|
-
$[
|
|
71
|
-
$[
|
|
72
|
-
$[
|
|
73
|
-
} else
|
|
74
|
-
return
|
|
79
|
+
$[13] = actionAttributes;
|
|
80
|
+
$[14] = filterHierarchyLevel;
|
|
81
|
+
$[15] = handleClick;
|
|
82
|
+
$[16] = t4;
|
|
83
|
+
$[17] = t5;
|
|
84
|
+
$[18] = t6;
|
|
85
|
+
$[19] = t7;
|
|
86
|
+
} else t7 = $[19];
|
|
87
|
+
return t7;
|
|
75
88
|
});
|
|
76
89
|
|
|
77
90
|
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeNodeFilterAction.js","names":["memo","useCallback","filterSvg","useTranslation","TreeActionBase","NamedExoticComponent","HierarchyLevelDetails","TreeRendererProps","TreeNode","TreeActionBaseAttributes","TreeNodeFilterActionProps","onFilter","hierarchyLevelDetails","Pick","TreeNodeFilterAction","node","t0","$","_c","actionAttributes","getHierarchyLevelDetails","translate","t1","filterHierarchyLevel","t2","filterHierarchyLevelActiveDescription","t3","id","handleClick","t4","isFiltered","undefined","t5","t6","isFilterable","t7"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.tsx"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { memo, useCallback } from \"react\";\nimport filterSvg from \"@stratakit/icons/filter.svg\";\nimport { useTranslation } from \"./LocalizationContext.js\";\nimport { TreeActionBase } from \"./TreeAction.js\";\n\nimport type { NamedExoticComponent } from \"react\";\nimport type { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport type { TreeNode } from \"../TreeNode.js\";\nimport type { TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/** @alpha */\ntype TreeNodeFilterActionProps = {\n /**\n * Action to perform when the filter button is clicked for this node.\n */\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: NamedExoticComponent<TreeNodeFilterActionProps & { node: TreeNode }> = memo(function TreeNodeFilterAction({\n node,\n onFilter,\n getHierarchyLevelDetails,\n ...actionAttributes\n}: TreeNodeFilterActionProps & { node: TreeNode }) {\n const translate = useTranslation();\n const filterHierarchyLevel = translate(\"filterHierarchyLevel\");\n const filterHierarchyLevelActiveDescription = translate(\"filterHierarchyLevelActiveDescription\");\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"],"mappings":";;;;;;;;;;;;;;;;;;AAkCA,MAAac,uBAA6Fd,KAAK,SAAAc,qBAAAE,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAA,IAAAC;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EAAA,QAAAY,MAAAZ,EAAA,QAAAe,MAAAf,EAAA,QAAAgB,IAAA;AAPvCE,OAAA,oBAAC;GAAc,GACThB;GACGI,OAAAA;GACEK,SAAAA;GACH1B,MAAAA;GACG,SAAA2B;GACJ,KAAAG;GACC,MAAAC;IACN;AAAAhB,IAAA,MAAAE;AAAAF,IAAA,MAAAM;AAAAN,IAAA,MAAAW;AAAAX,IAAA,MAAAY;AAAAZ,IAAA,MAAAe;AAAAf,IAAA,MAAAgB;AAAAhB,IAAA,MAAAkB;OAAAA,MAAAlB,EAAA;AAAA,QARFkB;EAUF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeNodeRenameAction.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.tsx"],"mappings":";;;;;;;;;AAyBA;;;;;;;;cAAa,oBAAA,EAAsB,oBAAA,CAAqB,wBAAA;EAA6B,IAAA,EAAM,QAAA;AAAA;;UAkB1E,oBAAA;EAlBkF;AAkBnG;;;EAKE,cAAA,GAAiB,QAAA;EACjB,mBAAA;EACA,QAAA,IAAY,QAAA;AAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { useTranslation } from "./LocalizationContext.js";
|
|
1
2
|
import { TreeActionBase } from "./TreeAction.js";
|
|
2
|
-
import { useLocalizationContext } from "./LocalizationContext.js";
|
|
3
3
|
import { c } from "react-compiler-runtime";
|
|
4
4
|
import { createContext, memo, useContext, useState } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -18,7 +18,7 @@ import renameSvg from "@stratakit/icons/rename.svg";
|
|
|
18
18
|
* @alpha
|
|
19
19
|
*/
|
|
20
20
|
const TreeNodeRenameAction = memo(function TreeNodeRenameAction(t0) {
|
|
21
|
-
const $ = c(
|
|
21
|
+
const $ = c(16);
|
|
22
22
|
let actionAttributes;
|
|
23
23
|
let node;
|
|
24
24
|
if ($[0] !== t0) {
|
|
@@ -30,45 +30,51 @@ const TreeNodeRenameAction = memo(function TreeNodeRenameAction(t0) {
|
|
|
30
30
|
actionAttributes = $[1];
|
|
31
31
|
node = $[2];
|
|
32
32
|
}
|
|
33
|
-
const
|
|
33
|
+
const translate = useTranslation();
|
|
34
34
|
const context = useTreeNodeRenameContext();
|
|
35
|
-
const { rename } = localizedStrings;
|
|
36
35
|
let t1;
|
|
37
|
-
if ($[3] !==
|
|
38
|
-
t1 =
|
|
39
|
-
$[3] =
|
|
40
|
-
$[4] =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const canRename = t1;
|
|
44
|
-
const startRename = context?.startRename;
|
|
36
|
+
if ($[3] !== translate) {
|
|
37
|
+
t1 = translate("rename");
|
|
38
|
+
$[3] = translate;
|
|
39
|
+
$[4] = t1;
|
|
40
|
+
} else t1 = $[4];
|
|
41
|
+
const rename = t1;
|
|
45
42
|
let t2;
|
|
46
|
-
if ($[
|
|
47
|
-
t2 = ()
|
|
43
|
+
if ($[5] !== context || $[6] !== node) {
|
|
44
|
+
t2 = context?.canRename(node) ?? false;
|
|
45
|
+
$[5] = context;
|
|
46
|
+
$[6] = node;
|
|
47
|
+
$[7] = t2;
|
|
48
|
+
} else t2 = $[7];
|
|
49
|
+
const canRename = t2;
|
|
50
|
+
const startRename = context?.startRename;
|
|
51
|
+
let t3;
|
|
52
|
+
if ($[8] !== node || $[9] !== startRename) {
|
|
53
|
+
t3 = () => {
|
|
48
54
|
startRename?.(node);
|
|
49
55
|
};
|
|
50
|
-
$[
|
|
51
|
-
$[
|
|
52
|
-
$[
|
|
53
|
-
} else
|
|
54
|
-
const handleClick =
|
|
55
|
-
const
|
|
56
|
-
let
|
|
57
|
-
if ($[
|
|
58
|
-
|
|
56
|
+
$[8] = node;
|
|
57
|
+
$[9] = startRename;
|
|
58
|
+
$[10] = t3;
|
|
59
|
+
} else t3 = $[10];
|
|
60
|
+
const handleClick = t3;
|
|
61
|
+
const t4 = !canRename;
|
|
62
|
+
let t5;
|
|
63
|
+
if ($[11] !== actionAttributes || $[12] !== handleClick || $[13] !== rename || $[14] !== t4) {
|
|
64
|
+
t5 = /* @__PURE__ */ jsx(TreeActionBase, {
|
|
59
65
|
...actionAttributes,
|
|
60
66
|
label: rename,
|
|
61
67
|
onClick: handleClick,
|
|
62
68
|
icon: renameSvg,
|
|
63
|
-
hide:
|
|
69
|
+
hide: t4
|
|
64
70
|
});
|
|
65
|
-
$[
|
|
66
|
-
$[
|
|
67
|
-
$[
|
|
68
|
-
$[
|
|
69
|
-
$[
|
|
70
|
-
} else
|
|
71
|
-
return
|
|
71
|
+
$[11] = actionAttributes;
|
|
72
|
+
$[12] = handleClick;
|
|
73
|
+
$[13] = rename;
|
|
74
|
+
$[14] = t4;
|
|
75
|
+
$[15] = t5;
|
|
76
|
+
} else t5 = $[15];
|
|
77
|
+
return t5;
|
|
72
78
|
});
|
|
73
79
|
const treeNodeRenameContext = createContext(void 0);
|
|
74
80
|
/** @internal */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeNodeRenameAction.js","names":["createContext","memo","useCallback","useContext","useMemo","useState","renameSvg","useTranslation","TreeActionBase","NamedExoticComponent","PropsWithChildren","TreeNode","TreeActionBaseAttributes","TreeNodeRenameAction","node","t0","$","_c","actionAttributes","translate","context","useTreeNodeRenameContext","t1","rename","t2","canRename","startRename","t3","handleClick","t4","t5","TreeNodeEditingProps","onLabelChanged","newLabel","labelValidationHint","validate","RenameParameters","nodeId","commit","TreeNodeRenameContext","renameParameters","cancelRename","treeNodeRenameContext","undefined","TreeNodeRenameContextProvider","value","children","useTreeNodeRenameContextValue","getEditingProps","setRenameParameters","id","Symbol","for","node_0"],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.tsx"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { createContext, memo, useCallback, useContext, useMemo, useState } from \"react\";\nimport renameSvg from \"@stratakit/icons/rename.svg\";\nimport { useTranslation } from \"./LocalizationContext.js\";\nimport { TreeActionBase } from \"./TreeAction.js\";\n\nimport type { NamedExoticComponent, PropsWithChildren } from \"react\";\nimport type { TreeNode } from \"../TreeNode.js\";\nimport type { TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/**\n * React component that renders a rename action for a tree item.\n *\n * The tree component must have `getEditingProps.onLabelChanged` prop set to enable renaming functionality. When\n * rename is completed, the `onLabelChanged` function is called to make the actual data update.\n *\n * @see `getMenuActions`, `getInlineActions`, `getContextMenuActions` props of `TreeRenderer` to add this action\n * to tree items.\n *\n * @alpha\n */\nexport const TreeNodeRenameAction: NamedExoticComponent<TreeActionBaseAttributes & { node: TreeNode }> = memo(function TreeNodeRenameAction({\n node,\n ...actionAttributes\n}: TreeActionBaseAttributes & { node: TreeNode }) {\n const translate = useTranslation();\n const context = useTreeNodeRenameContext();\n const rename = translate(\"rename\");\n\n const canRename = context?.canRename(node) ?? false;\n const startRename = context?.startRename;\n const handleClick = useCallback(() => {\n startRename?.(node);\n }, [startRename, node]);\n\n return <TreeActionBase {...actionAttributes} label={rename} onClick={handleClick} icon={renameSvg} hide={!canRename} />;\n});\n\n/** @alpha */\nexport interface TreeNodeEditingProps {\n /**\n * A callback that is invoked when node label is changed. Should be used together\n * with `<TreeNodeRenameAction />` to enter label editing mode.\n */\n onLabelChanged: (newLabel: string) => void;\n labelValidationHint?: string;\n validate?: (newLabel: string) => boolean;\n}\n\n/** @internal */\nexport interface RenameParameters {\n nodeId: string;\n commit: (newLabel: string) => void;\n labelValidationHint?: string;\n validate?: (newLabel: string) => boolean;\n}\n\ninterface TreeNodeRenameContext {\n renameParameters?: RenameParameters;\n startRename: (node: TreeNode) => void;\n canRename: (node: TreeNode) => boolean;\n cancelRename: () => void;\n}\n\nconst treeNodeRenameContext = createContext<TreeNodeRenameContext | undefined>(undefined);\n\n/** @internal */\nexport const useTreeNodeRenameContext = () => {\n return useContext(treeNodeRenameContext);\n};\n\n/** @internal */\nexport function TreeNodeRenameContextProvider({ value, children }: PropsWithChildren<{ value: TreeNodeRenameContext }>) {\n return <treeNodeRenameContext.Provider value={value}>{children}</treeNodeRenameContext.Provider>;\n}\n\n/** @internal */\nexport function useTreeNodeRenameContextValue({ getEditingProps }: { getEditingProps?: (node: TreeNode) => TreeNodeEditingProps | undefined }) {\n const [renameParameters, setRenameParameters] = useState<RenameParameters | undefined>(undefined);\n\n const startRename = useCallback(\n (node: TreeNode) => {\n const { onLabelChanged, labelValidationHint, validate } = getEditingProps?.(node) ?? {};\n if (onLabelChanged) {\n setRenameParameters({\n nodeId: node.id,\n commit: (newLabel) => {\n onLabelChanged(newLabel);\n setRenameParameters(undefined);\n },\n labelValidationHint,\n validate,\n });\n }\n },\n [getEditingProps],\n );\n\n const cancelRename = useCallback(() => {\n setRenameParameters(undefined);\n }, []);\n\n const canRename = useCallback(\n (node: TreeNode) => {\n return getEditingProps?.(node)?.onLabelChanged !== undefined;\n },\n [getEditingProps],\n );\n\n return useMemo(\n () => ({\n renameParameters,\n cancelRename,\n startRename,\n canRename,\n }),\n [renameParameters, canRename, startRename, cancelRename],\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyBA,MAAaa,uBAA4FZ,KAAK,SAAAY,qBAAAE,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAA,IAAAC;CAAA,IAAAJ;AAAA,KAAAE,EAAA,OAAAD,IAAA;AAA8B,GAAA,CAAAD,SAAAI,oBAAAH;AAG5FC,IAAA,KAAAD;AAAAC,IAAA,KAAAE;AAAAF,IAAA,KAAAF;QAAA;AAAAI,qBAAAF,EAAA;AAAAF,SAAAE,EAAA;;CAC9C,MAAAG,YAAkBZ,gBAAgB;CAClC,MAAAa,UAAgBC,0BAA0B;CAAC,IAAAC;AAAA,KAAAN,EAAA,OAAAG,WAAA;AAC5BG,OAAAH,UAAU,SAAS;AAAAH,IAAA,KAA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