Skip to content

Commit 0299271

Browse files
expose getEditingProps
1 parent 63618c5 commit 0299271

File tree

4 files changed

+12
-24
lines changed

4 files changed

+12
-24
lines changed

apps/test-viewer/src/UiProvidersConfig.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,12 @@ const configuredUiItems = new Map<string, UiItem>([
163163
<ClassificationsTreeComponent
164164
selectionStorage={unifiedSelectionStorage}
165165
hierarchyConfig={{ rootClassificationSystemCode: "50k classifications" }}
166-
onLabelChanged={(node, newLabel) => {
167-
console.log("node label changed", node, newLabel);
166+
getEditingProps={(node) => {
167+
return {
168+
onLabelChanged: (newLabel: string) => {
169+
console.log("node label changed", node, newLabel);
170+
},
171+
};
168172
}}
169173
/>
170174
),

packages/itwin/tree-widget/api/tree-widget-react.api.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export const ClassificationsTreeComponent: {
128128
};
129129

130130
// @alpha (undocumented)
131-
interface ClassificationsTreeComponentProps extends Pick<ClassificationsTreeProps, "selectionStorage" | "hierarchyLevelConfig" | "selectionMode" | "emptyTreeContent" | "getActions" | "getDecorations" | "hierarchyConfig" | "onLabelChanged"> {
131+
interface ClassificationsTreeComponentProps extends Pick<ClassificationsTreeProps, "selectionStorage" | "hierarchyLevelConfig" | "selectionMode" | "emptyTreeContent" | "getActions" | "getDecorations" | "hierarchyConfig" | "getEditingProps"> {
132132
// (undocumented)
133133
onFeatureUsed?: (feature: string) => void;
134134
// (undocumented)
@@ -147,11 +147,10 @@ export function ClassificationsTreeIcon({ node }: {
147147
}): JSX_2.Element | undefined;
148148

149149
// @alpha (undocumented)
150-
type ClassificationsTreeProps = Pick<VisibilityTreeProps, "imodel" | "selectionStorage" | "selectionMode" | "emptyTreeContent"> & Pick<VisibilityTreeRendererProps, "getActions" | "getDecorations"> & UseClassificationsTreeProps & {
150+
type ClassificationsTreeProps = Pick<VisibilityTreeProps, "imodel" | "selectionStorage" | "selectionMode" | "emptyTreeContent"> & Pick<VisibilityTreeRendererProps, "getActions" | "getDecorations" | "getEditingProps"> & UseClassificationsTreeProps & {
151151
hierarchyLevelConfig?: {
152152
sizeLimit?: number;
153153
};
154-
onLabelChanged?: (node: PresentationHierarchyNode, newLabel: string) => void;
155154
};
156155

157156
// @public

packages/itwin/tree-widget/src/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.tsx

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,23 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import type { VisibilityTreeProps } from "../common/components/VisibilityTree.js";
7-
import type { ComponentProps } from "react";
87
import { useCallback } from "react";
98
import { RenameAction } from "@itwin/presentation-hierarchies-react";
109
import { VisibilityTree } from "../common/components/VisibilityTree.js";
1110
import { VisibilityTreeRenderer } from "../common/components/VisibilityTreeRenderer.js";
1211
import { useClassificationsTree } from "./UseClassificationsTree.js";
1312

14-
import type { PresentationHierarchyNode, StrataKitTreeRenderer } from "@itwin/presentation-hierarchies-react";
13+
import type { PresentationHierarchyNode } from "@itwin/presentation-hierarchies-react";
1514
import type { VisibilityTreeRendererProps } from "../common/components/VisibilityTreeRenderer.js";
1615
import type { UseClassificationsTreeProps } from "./UseClassificationsTree.js";
1716

1817
/** @alpha */
1918
export type ClassificationsTreeProps = Pick<VisibilityTreeProps, "imodel" | "selectionStorage" | "selectionMode" | "emptyTreeContent"> &
20-
Pick<VisibilityTreeRendererProps, "getActions" | "getDecorations"> &
19+
Pick<VisibilityTreeRendererProps, "getActions" | "getDecorations" | "getEditingProps"> &
2120
UseClassificationsTreeProps & {
2221
hierarchyLevelConfig?: {
2322
sizeLimit?: number;
2423
};
25-
onLabelChanged?: (node: PresentationHierarchyNode, newLabel: string) => void;
2624
};
2725

2826
/** @alpha */
@@ -36,7 +34,7 @@ export function ClassificationsTree({
3634
emptyTreeContent,
3735
getDecorations,
3836
getActions,
39-
onLabelChanged,
37+
getEditingProps,
4038
}: ClassificationsTreeProps) {
4139
const { categoriesTreeProps, rendererProps } = useClassificationsTree({
4240
activeView,
@@ -51,19 +49,6 @@ export function ClassificationsTree({
5149
[getActions],
5250
);
5351

54-
const getEditingProps = useCallback<Required<ComponentProps<typeof StrataKitTreeRenderer>>["getEditingProps"]>(
55-
(node) => {
56-
return {
57-
onLabelChanged: onLabelChanged
58-
? (newLabel) => {
59-
onLabelChanged(node, newLabel);
60-
}
61-
: undefined,
62-
};
63-
},
64-
[onLabelChanged],
65-
);
66-
6752
return (
6853
<VisibilityTree
6954
{...categoriesTreeProps}

packages/itwin/tree-widget/src/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type { IModelConnection, ScreenViewport } from "@itwin/core-frontend";
1818
interface ClassificationsTreeComponentProps
1919
extends Pick<
2020
ClassificationsTreeProps,
21-
"selectionStorage" | "hierarchyLevelConfig" | "selectionMode" | "emptyTreeContent" | "getActions" | "getDecorations" | "hierarchyConfig" | "onLabelChanged"
21+
"selectionStorage" | "hierarchyLevelConfig" | "selectionMode" | "emptyTreeContent" | "getActions" | "getDecorations" | "hierarchyConfig" | "getEditingProps"
2222
> {
2323
onPerformanceMeasured?: (featureId: string, duration: number) => void;
2424
onFeatureUsed?: (feature: string) => void;

0 commit comments

Comments
 (0)