@itwin/presentation-hierarchies-react 2.0.0-alpha.48 → 2.0.0-alpha.49

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/README.md +2 -40
  3. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts +2 -0
  4. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -1
  5. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js +15 -0
  6. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +1 -1
  7. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts +10 -0
  8. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +1 -1
  9. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js +2 -0
  10. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +1 -1
  11. package/lib/esm/presentation-hierarchies-react/stratakit/{FilterAction.d.ts → TreeNodeFilterAction.d.ts} +8 -7
  12. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -0
  13. package/lib/esm/presentation-hierarchies-react/stratakit/{FilterAction.js → TreeNodeFilterAction.js} +8 -2
  14. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -0
  15. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +57 -0
  16. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -0
  17. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +71 -0
  18. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -0
  19. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.css +25 -0
  20. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +6 -6
  21. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -1
  22. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +56 -49
  23. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -1
  24. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +16 -10
  25. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -1
  26. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js +56 -16
  27. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -1
  28. package/lib/esm/presentation-hierarchies-react.d.ts +3 -4
  29. package/lib/esm/presentation-hierarchies-react.d.ts.map +1 -1
  30. package/lib/esm/presentation-hierarchies-react.js +2 -3
  31. package/lib/esm/presentation-hierarchies-react.js.map +1 -1
  32. package/package.json +7 -7
  33. package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.d.ts.map +0 -1
  34. package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.js.map +0 -1
  35. package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.d.ts +0 -21
  36. package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.d.ts.map +0 -1
  37. package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.js +0 -36
  38. package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"presentation-hierarchies-react.js","sourceRoot":"","sources":["../../src/presentation-hierarchies-react.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,yDAAyD,CAAC;AAC9F,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAC/F,OAAO,EAAE,mBAAmB,EAAE,MAAM,yDAAyD,CAAC;AAE9F,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,mDAAmD,CAAC;AACjH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gEAAgE,CAAC;AAC3G,OAAO,EAAE,cAAc,EAA4B,MAAM,0DAA0D,CAAC;AACpH,OAAO,EAAE,YAAY,EAAE,MAAM,4DAA4D,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,4DAA4D,CAAC;AACjH,OAAO,EAAE,qBAAqB,EAAE,MAAM,4DAA4D,CAAC;AACnG,OAAO,EAAE,0BAA0B,EAAE,MAAM,iEAAiE,CAAC;AAC7G,OAAO,EAAE,iBAAiB,EAAE,MAAM,iEAAiE,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iEAAiE,CAAC;AACpG,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAgB,MAAM,4DAA4D,CAAC;AAC1H,OAAO,EAAE,2BAA2B,EAAE,MAAM,mEAAmE,CAAC;AAEhH,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAqB,SAAS,EAAE,SAAS,EAAE,MAAM,iCAAiC,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\nexport { GenericErrorInfo, PresentationHierarchyNode, ErrorInfo, ResultSetTooLargeErrorInfo } from \"./presentation-hierarchies-react/TreeNode.js\";\nexport { useSelectionHandler } from \"./presentation-hierarchies-react/UseSelectionHandler.js\";\nexport { useTree, useUnifiedSelectionTree } from \"./presentation-hierarchies-react/UseTree.js\";\nexport { useNodeHighlighting } from \"./presentation-hierarchies-react/UseNodeHighlighting.js\";\nexport { HierarchyLevelDetails, TreeRendererProps } from \"./presentation-hierarchies-react/Renderers.js\";\nexport { useIModelTree, useIModelUnifiedSelectionTree } from \"./presentation-hierarchies-react/UseIModelTree.js\";\nexport { StrataKitTreeNodeRenderer } from \"./presentation-hierarchies-react/stratakit/TreeNodeRenderer.js\";\nexport { TreeActionBase, TreeActionBaseAttributes } from \"./presentation-hierarchies-react/stratakit/TreeAction.js\";\nexport { FilterAction } from \"./presentation-hierarchies-react/stratakit/FilterAction.js\";\nexport { RenameAction, RenameContextProvider } from \"./presentation-hierarchies-react/stratakit/RenameAction.js\";\nexport { StrataKitTreeRenderer } from \"./presentation-hierarchies-react/stratakit/TreeRenderer.js\";\nexport { StrataKitRootErrorRenderer } from \"./presentation-hierarchies-react/stratakit/RootErrorRenderer.js\";\nexport { TreeErrorRenderer } from \"./presentation-hierarchies-react/stratakit/TreeErrorRenderer.js\";\nexport { ErrorItemRenderer } from \"./presentation-hierarchies-react/stratakit/ErrorItemRenderer.js\";\nexport { useFlatTreeItems, useErrorList, FlatTreeItem } from \"./presentation-hierarchies-react/stratakit/FlatTreeNode.js\";\nexport { LocalizationContextProvider } from \"./presentation-hierarchies-react/stratakit/LocalizationContext.js\";\n\nexport { GenericInstanceFilter, HierarchyNode, HierarchyProvider, getLogger, setLogger } from \"@itwin/presentation-hierarchies\";\nexport { SelectionStorage } from \"@itwin/unified-selection\";\n"]}
1
+ {"version":3,"file":"presentation-hierarchies-react.js","sourceRoot":"","sources":["../../src/presentation-hierarchies-react.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,yDAAyD,CAAC;AAC9F,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAC/F,OAAO,EAAE,mBAAmB,EAAE,MAAM,yDAAyD,CAAC;AAE9F,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,mDAAmD,CAAC;AACjH,OAAO,EAAE,cAAc,EAA4B,MAAM,0DAA0D,CAAC;AACpH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oEAAoE,CAAC;AAC1G,OAAO,EAAE,oBAAoB,EAAE,MAAM,oEAAoE,CAAC;AAC1G,OAAO,EAAE,qBAAqB,EAAmC,MAAM,4DAA4D,CAAC;AACpI,OAAO,EAAE,0BAA0B,EAAE,MAAM,iEAAiE,CAAC;AAC7G,OAAO,EAAE,iBAAiB,EAAE,MAAM,iEAAiE,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iEAAiE,CAAC;AACpG,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAgB,MAAM,4DAA4D,CAAC;AAC1H,OAAO,EAAE,2BAA2B,EAAE,MAAM,mEAAmE,CAAC;AAEhH,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAqB,SAAS,EAAE,SAAS,EAAE,MAAM,iCAAiC,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\nexport { GenericErrorInfo, PresentationHierarchyNode, ErrorInfo, ResultSetTooLargeErrorInfo } from \"./presentation-hierarchies-react/TreeNode.js\";\nexport { useSelectionHandler } from \"./presentation-hierarchies-react/UseSelectionHandler.js\";\nexport { useTree, useUnifiedSelectionTree } from \"./presentation-hierarchies-react/UseTree.js\";\nexport { useNodeHighlighting } from \"./presentation-hierarchies-react/UseNodeHighlighting.js\";\nexport { HierarchyLevelDetails, TreeRendererProps } from \"./presentation-hierarchies-react/Renderers.js\";\nexport { useIModelTree, useIModelUnifiedSelectionTree } from \"./presentation-hierarchies-react/UseIModelTree.js\";\nexport { TreeActionBase, TreeActionBaseAttributes } from \"./presentation-hierarchies-react/stratakit/TreeAction.js\";\nexport { TreeNodeFilterAction } from \"./presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js\";\nexport { TreeNodeRenameAction } from \"./presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js\";\nexport { StrataKitTreeRenderer, StrataKitTreeRendererAttributes } from \"./presentation-hierarchies-react/stratakit/TreeRenderer.js\";\nexport { StrataKitRootErrorRenderer } from \"./presentation-hierarchies-react/stratakit/RootErrorRenderer.js\";\nexport { TreeErrorRenderer } from \"./presentation-hierarchies-react/stratakit/TreeErrorRenderer.js\";\nexport { ErrorItemRenderer } from \"./presentation-hierarchies-react/stratakit/ErrorItemRenderer.js\";\nexport { useFlatTreeItems, useErrorList, FlatTreeItem } from \"./presentation-hierarchies-react/stratakit/FlatTreeNode.js\";\nexport { LocalizationContextProvider } from \"./presentation-hierarchies-react/stratakit/LocalizationContext.js\";\n\nexport { GenericInstanceFilter, HierarchyNode, HierarchyProvider, getLogger, setLogger } from \"@itwin/presentation-hierarchies\";\nexport { SelectionStorage } from \"@itwin/unified-selection\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/presentation-hierarchies-react",
3
- "version": "2.0.0-alpha.48",
3
+ "version": "2.0.0-alpha.49",
4
4
  "description": "React components based on `@itwin/presentation-hierarchies`",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -37,15 +37,15 @@
37
37
  "./package.json": "./package.json"
38
38
  },
39
39
  "dependencies": {
40
- "@itwin/core-bentley": "^5.4.2",
40
+ "@itwin/core-bentley": "^5.5.1",
41
41
  "@tanstack/react-virtual": "^3.13.13",
42
42
  "classnames": "^2.5.1",
43
43
  "immer": "^10.2.0",
44
44
  "react-error-boundary": "^4.1.2",
45
45
  "rxjs": "^7.8.2",
46
- "@itwin/presentation-hierarchies": "^2.0.0-alpha.9",
47
- "@itwin/presentation-shared": "^2.0.0-alpha.5",
48
- "@itwin/unified-selection": "^1.6.4"
46
+ "@itwin/presentation-hierarchies": "^2.0.0-alpha.10",
47
+ "@itwin/presentation-shared": "^2.0.0-alpha.6",
48
+ "@itwin/unified-selection": "^1.6.6-alpha.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@stratakit/bricks": "^0.5",
@@ -70,7 +70,7 @@
70
70
  }
71
71
  },
72
72
  "devDependencies": {
73
- "@itwin/build-tools": "^5.4.2",
73
+ "@itwin/build-tools": "^5.5.1",
74
74
  "@itwin/eslint-plugin": "5.1.0",
75
75
  "@stratakit/bricks": "^0.5.3",
76
76
  "@stratakit/foundations": "^0.4.3",
@@ -83,7 +83,7 @@
83
83
  "@types/chai-as-promised": "^8.0.2",
84
84
  "@types/jsdom": "^21.1.7",
85
85
  "@types/mocha": "^10.0.10",
86
- "@types/node": "^22.19.3",
86
+ "@types/node": "^22.19.7",
87
87
  "@types/react": "^18.3.27",
88
88
  "@types/react-dom": "^18.3.7",
89
89
  "@types/sinon": "^17.0.4",
@@ -1 +0,0 @@
1
- {"version":3,"file":"FilterAction.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/FilterAction.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAkB,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3E,aAAa;AACb,MAAM,MAAM,iBAAiB,GAAG;IAC9B,yEAAyE;IACzE,QAAQ,CAAC,EAAE,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI,CAAC;CACnE,GAAG,wBAAwB,GAC1B,IAAI,CAAC,iBAAiB,EAAE,0BAA0B,CAAC,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,YAAY;IATvB,yEAAyE;eAC9D,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI;;UAapC,yBAAyB;EAoBtD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"FilterAction.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/FilterAction.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;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,YAAY,CAAC,EACrD,IAAI,EACJ,QAAQ,EACR,wBAAwB,EACxB,GAAG,gBAAgB,EACqC;IACxD,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 { PresentationHierarchyNode } from \"../TreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\nimport { TreeActionBase, TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/** @alpha */\nexport type FilterActionProps = {\n /** Action to perform when the filter button is clicked for this node. */\n onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n} & TreeActionBaseAttributes &\n Pick<TreeRendererProps, \"getHierarchyLevelDetails\">;\n\n/**\n * React component that renders a filter action for a tree item.\n * @alpha\n */\nexport const FilterAction = memo(function FilterAction({\n node,\n onFilter,\n getHierarchyLevelDetails,\n ...actionAttributes\n}: FilterActionProps & { node: PresentationHierarchyNode }) {\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"]}
@@ -1,21 +0,0 @@
1
- import { PropsWithChildren } from "react";
2
- import { TreeActionBaseAttributes } from "./TreeAction.js";
3
- /**
4
- * React component that renders a rename action for a tree item.
5
- * The tree component must have `getEditingProps.onLabelChanged` prop set to enable renaming functionality. When the rename is completed, the `onLabelChanged` function is called to make the actual data update.
6
- * @alpha
7
- */
8
- export declare const RenameAction: import("react").NamedExoticComponent<TreeActionBaseAttributes>;
9
- interface RenameContext {
10
- isRenaming: boolean;
11
- setIsRenaming: (isRenaming: boolean) => void;
12
- onLabelChanged?: (newLabel: string) => void;
13
- }
14
- /** @internal */
15
- export declare const useRenameContext: () => RenameContext | undefined;
16
- /** @alpha */
17
- export declare function RenameContextProvider({ onLabelChanged, children }: PropsWithChildren<{
18
- onLabelChanged?: (newLabel: string) => void;
19
- }>): import("react/jsx-runtime").JSX.Element;
20
- export {};
21
- //# sourceMappingURL=RenameAction.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RenameAction.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/RenameAction.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAuB,iBAAiB,EAA8C,MAAM,OAAO,CAAC;AAG3G,OAAO,EAAkB,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3E;;;;GAIG;AACH,eAAO,MAAM,YAAY,gEAWvB,CAAC;AAEH,UAAU,aAAa;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C;AAID,gBAAgB;AAChB,eAAO,MAAM,gBAAgB,iCAE5B,CAAC;AAEF,aAAa;AACb,wBAAgB,qBAAqB,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC;IAAE,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,CAAC,2CAKrI"}
@@ -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 { createContext, memo, useCallback, useContext, useMemo, useState } from "react";
7
- import renameSvg from "@stratakit/icons/rename.svg";
8
- import { useLocalizationContext } from "./LocalizationContext.js";
9
- import { TreeActionBase } from "./TreeAction.js";
10
- /**
11
- * React component that renders a rename action for a tree item.
12
- * The tree component must have `getEditingProps.onLabelChanged` prop set to enable renaming functionality. When the rename is completed, the `onLabelChanged` function is called to make the actual data update.
13
- * @alpha
14
- */
15
- export const RenameAction = memo(function RenameAction(actionAttributes) {
16
- const { localizedStrings } = useLocalizationContext();
17
- const context = useRenameContext();
18
- const { rename } = localizedStrings;
19
- const setIsRenaming = context?.setIsRenaming;
20
- const handleClick = useCallback(() => {
21
- setIsRenaming?.(true);
22
- }, [setIsRenaming]);
23
- return _jsx(TreeActionBase, { ...actionAttributes, label: rename, onClick: handleClick, icon: renameSvg, hide: !context?.onLabelChanged });
24
- });
25
- const renameContext = createContext(undefined);
26
- /** @internal */
27
- export const useRenameContext = () => {
28
- return useContext(renameContext);
29
- };
30
- /** @alpha */
31
- export function RenameContextProvider({ onLabelChanged, children }) {
32
- const [isRenaming, setIsRenaming] = useState(false);
33
- const value = useMemo(() => ({ isRenaming, setIsRenaming, onLabelChanged }), [isRenaming, onLabelChanged]);
34
- return _jsx(renameContext.Provider, { value: value, children: children });
35
- }
36
- //# sourceMappingURL=RenameAction.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RenameAction.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/RenameAction.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAE,IAAI,EAAqB,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3G,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,cAAc,EAA4B,MAAM,iBAAiB,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,YAAY,CAAC,gBAA0C;IAC/F,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACtD,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IACnC,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC;IAEpC,MAAM,aAAa,GAAG,OAAO,EAAE,aAAa,CAAC;IAC7C,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE;QACnC,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,OAAO,KAAC,cAAc,OAAK,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,cAAc,GAAI,CAAC;AACxI,CAAC,CAAC,CAAC;AAQH,MAAM,aAAa,GAAG,aAAa,CAA4B,SAAS,CAAC,CAAC;AAE1E,gBAAgB;AAChB,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,OAAO,UAAU,CAAC,aAAa,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF,aAAa;AACb,MAAM,UAAU,qBAAqB,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAsE;IACpI,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC;IAE3G,OAAO,KAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAA0B,CAAC;AACnF,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, memo, PropsWithChildren, useCallback, useContext, useMemo, useState } from \"react\";\nimport renameSvg from \"@stratakit/icons/rename.svg\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\nimport { TreeActionBase, TreeActionBaseAttributes } from \"./TreeAction.js\";\n\n/**\n * React component that renders a rename action for a tree item.\n * The tree component must have `getEditingProps.onLabelChanged` prop set to enable renaming functionality. When the rename is completed, the `onLabelChanged` function is called to make the actual data update.\n * @alpha\n */\nexport const RenameAction = memo(function RenameAction(actionAttributes: TreeActionBaseAttributes) {\n const { localizedStrings } = useLocalizationContext();\n const context = useRenameContext();\n const { rename } = localizedStrings;\n\n const setIsRenaming = context?.setIsRenaming;\n const handleClick = useCallback(() => {\n setIsRenaming?.(true);\n }, [setIsRenaming]);\n\n return <TreeActionBase {...actionAttributes} label={rename} onClick={handleClick} icon={renameSvg} hide={!context?.onLabelChanged} />;\n});\n\ninterface RenameContext {\n isRenaming: boolean;\n setIsRenaming: (isRenaming: boolean) => void;\n onLabelChanged?: (newLabel: string) => void;\n}\n\nconst renameContext = createContext<RenameContext | undefined>(undefined);\n\n/** @internal */\nexport const useRenameContext = () => {\n return useContext(renameContext);\n};\n\n/** @alpha */\nexport function RenameContextProvider({ onLabelChanged, children }: PropsWithChildren<{ onLabelChanged?: (newLabel: string) => void }>) {\n const [isRenaming, setIsRenaming] = useState(false);\n const value = useMemo(() => ({ isRenaming, setIsRenaming, onLabelChanged }), [isRenaming, onLabelChanged]);\n\n return <renameContext.Provider value={value}>{children}</renameContext.Provider>;\n}\n"]}