@itwin/tree-widget-react 3.6.0 → 3.6.1
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 +11 -2
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +6 -0
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +48 -3
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.d.ts +4 -2
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +91 -96
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/UseIModelAccess.d.ts +18 -0
- package/lib/cjs/tree-widget-react/components/trees/common/UseIModelAccess.js +34 -0
- package/lib/cjs/tree-widget-react/components/trees/common/UseIModelAccess.js.map +1 -0
- package/lib/cjs/tree-widget-react/components/trees/common/Utils.d.ts +0 -14
- package/lib/cjs/tree-widget-react/components/trees/common/Utils.js +1 -16
- package/lib/cjs/tree-widget-react/components/trees/common/Utils.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/components/Tree.d.ts +5 -0
- package/lib/cjs/tree-widget-react/components/trees/common/components/Tree.js +16 -9
- package/lib/cjs/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTree.d.ts +2 -2
- package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTree.js +8 -4
- package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +6 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +48 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.d.ts +4 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +92 -97
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseIModelAccess.d.ts +18 -0
- package/lib/esm/tree-widget-react/components/trees/common/UseIModelAccess.js +30 -0
- package/lib/esm/tree-widget-react/components/trees/common/UseIModelAccess.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/Utils.d.ts +0 -14
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js +0 -14
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.d.ts +5 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js +15 -9
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.js +10 -6
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/package.json +2 -2
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { useEffect, useRef } from "react";
|
|
6
|
-
import { createECSchemaProvider, createECSqlQueryExecutor } from "@itwin/presentation-core-interop";
|
|
7
|
-
import { createLimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
|
|
8
|
-
import { createCachingECClassHierarchyInspector } from "@itwin/presentation-shared";
|
|
9
6
|
/** @internal */
|
|
10
7
|
export function createIdsSelector(ids) {
|
|
11
8
|
// Note: `json_array` function only accepts up to 127 arguments and we may have more `ids` than that. As a workaround,
|
|
@@ -37,17 +34,6 @@ export function pushToMap(targetMap, key, value) {
|
|
|
37
34
|
set.add(value);
|
|
38
35
|
}
|
|
39
36
|
/** @internal */
|
|
40
|
-
export function createIModelAccess({ imodel, getSchemaContext }) {
|
|
41
|
-
const schemas = getSchemaContext(imodel);
|
|
42
|
-
const schemaProvider = createECSchemaProvider(schemas);
|
|
43
|
-
return {
|
|
44
|
-
imodelKey: imodel.key,
|
|
45
|
-
...schemaProvider,
|
|
46
|
-
...createCachingECClassHierarchyInspector({ schemaProvider, cacheSize: 100 }),
|
|
47
|
-
...createLimitingECSqlQueryExecutor(createECSqlQueryExecutor(imodel), 1000),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
/** @internal */
|
|
51
37
|
export function useLatest(value) {
|
|
52
38
|
const ref = useRef(value);
|
|
53
39
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/Utils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/Utils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAO1C,gBAAgB;AAChB,MAAM,UAAU,iBAAiB,CAAC,GAAc;IAC9C,sHAAsH;IACtH,oCAAoC;IACpC,MAAM,MAAM,GAAG,IAAI,KAAK,EAAgB,CAAC;IACzC,KAAK,IAAI,eAAe,GAAG,CAAC,EAAE,eAAe,GAAG,GAAG,CAAC,MAAM,EAAE,eAAe,IAAI,GAAG,EAAE;QAClF,IAAI,aAAa,GAAuB,eAAe,GAAG,GAA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S,CAAI,KAAQ;IACnC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,SAAS,CAAC,GAAG,EAAE;QACb,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACtB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACZ,OAAO,GAAG,CAAC;AACb,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 { useEffect, useRef } from \"react\";\n\nimport type { Id64Array, Id64String } from \"@itwin/core-bentley\";\n\n/** @beta */\nexport type FunctionProps<THook extends (props: any) => any> = Parameters<THook>[0];\n\n/** @internal */\nexport function createIdsSelector(ids: Id64Array): string {\n // Note: `json_array` function only accepts up to 127 arguments and we may have more `ids` than that. As a workaround,\n // we're creating an array of arrays\n const slices = new Array<Id64String[]>();\n for (let sliceStartIndex = 0; sliceStartIndex < ids.length; sliceStartIndex += 127) {\n let sliceEndIndex: number | undefined = sliceStartIndex + 127;\n if (sliceEndIndex > ids.length) {\n sliceEndIndex = undefined;\n }\n slices.push(ids.slice(sliceStartIndex, sliceEndIndex));\n }\n return `json_array(${slices.map((sliceIds) => `json_array(${sliceIds.map((id) => `'${id}'`).join(\",\")})`).join(\",\")})`;\n}\n\n/** @internal */\nexport function parseIdsSelectorResult(selectorResult: any): Id64Array {\n if (!Array.isArray(selectorResult)) {\n return [];\n }\n return selectorResult.reduce((arr, ids: Id64String | Id64String[]) => [...arr, ...(Array.isArray(ids) ? ids : [ids])], new Array<Id64String>());\n}\n\n/** @internal */\nexport function pushToMap<TKey, TValue>(targetMap: Map<TKey, Set<TValue>>, key: TKey, value: TValue) {\n let set = targetMap.get(key);\n if (!set) {\n set = new Set();\n targetMap.set(key, set);\n }\n set.add(value);\n}\n\n/** @internal */\nexport function useLatest<T>(value: T) {\n const ref = useRef(value);\n useEffect(() => {\n ref.current = value;\n }, [value]);\n return ref;\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useSelectionHandler } from "@itwin/presentation-hierarchies-react";
|
|
2
|
+
import type { MarkRequired } from "@itwin/core-bentley";
|
|
2
3
|
import type { FunctionProps } from "../Utils.js";
|
|
3
4
|
import type { ReactNode } from "react";
|
|
4
5
|
import type { IModelConnection } from "@itwin/core-frontend";
|
|
@@ -41,4 +42,8 @@ export type TreeProps = Pick<FunctionProps<typeof useIModelTree>, "getFilteredPa
|
|
|
41
42
|
* @beta
|
|
42
43
|
*/
|
|
43
44
|
export declare function Tree({ getSchemaContext, hierarchyLevelSizeLimit, selectionStorage, imodelAccess: providedIModelAccess, ...props }: TreeProps): JSX.Element;
|
|
45
|
+
/** @internal */
|
|
46
|
+
export declare function TreeBase({ getSchemaContext, ...props }: MarkRequired<TreeProps, "imodelAccess"> & {
|
|
47
|
+
currentHierarchyLevelSizeLimit: number;
|
|
48
|
+
}): JSX.Element;
|
|
44
49
|
//# sourceMappingURL=Tree.d.ts.map
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
import { useCallback,
|
|
6
|
+
import { useCallback, useState } from "react";
|
|
7
7
|
import { BeEvent } from "@itwin/core-bentley";
|
|
8
8
|
import { Flex, ProgressRadial, Text } from "@itwin/itwinui-react";
|
|
9
9
|
import { SchemaMetadataContextProvider } from "@itwin/presentation-components";
|
|
@@ -11,10 +11,10 @@ import { useIModelUnifiedSelectionTree, useSelectionHandler } from "@itwin/prese
|
|
|
11
11
|
import { TreeWidget } from "../../../../TreeWidget.js";
|
|
12
12
|
import { useHierarchiesLocalization } from "../UseHierarchiesLocalization.js";
|
|
13
13
|
import { useHierarchyLevelFiltering } from "../UseHierarchyFiltering.js";
|
|
14
|
+
import { useIModelAccess } from "../UseIModelAccess.js";
|
|
14
15
|
import { useIModelChangeListener } from "../UseIModelChangeListener.js";
|
|
15
16
|
import { useNodeHighlighting } from "../UseNodeHighlighting.js";
|
|
16
17
|
import { useReportingAction, useTelemetryContext } from "../UseTelemetryContext.js";
|
|
17
|
-
import { createIModelAccess } from "../Utils.js";
|
|
18
18
|
import { Delayed } from "./Delayed.js";
|
|
19
19
|
import { ProgressOverlay } from "./ProgressOverlay.js";
|
|
20
20
|
/**
|
|
@@ -22,13 +22,19 @@ import { ProgressOverlay } from "./ProgressOverlay.js";
|
|
|
22
22
|
* @beta
|
|
23
23
|
*/
|
|
24
24
|
export function Tree({ getSchemaContext, hierarchyLevelSizeLimit, selectionStorage, imodelAccess: providedIModelAccess, ...props }) {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const { imodelAccess, currentHierarchyLevelSizeLimit } = useIModelAccess({
|
|
26
|
+
imodel: props.imodel,
|
|
27
|
+
imodelAccess: providedIModelAccess,
|
|
28
|
+
getSchemaContext,
|
|
29
|
+
hierarchyLevelSizeLimit,
|
|
30
|
+
});
|
|
31
|
+
return (_jsx(TreeBase, { ...props, getSchemaContext: getSchemaContext, selectionStorage: selectionStorage, imodelAccess: imodelAccess, currentHierarchyLevelSizeLimit: currentHierarchyLevelSizeLimit }));
|
|
32
|
+
}
|
|
33
|
+
/** @internal */
|
|
34
|
+
export function TreeBase({ getSchemaContext, ...props }) {
|
|
35
|
+
return (_jsx(SchemaMetadataContextProvider, { imodel: props.imodel, schemaContextProvider: getSchemaContext, children: _jsx(TreeBaseImpl, { ...props }) }));
|
|
30
36
|
}
|
|
31
|
-
function
|
|
37
|
+
function TreeBaseImpl({ imodel, imodelAccess, treeName, noDataMessage, getFilteredPaths, currentHierarchyLevelSizeLimit, getHierarchyDefinition, selectionPredicate, selectionMode, onReload, treeRenderer, density, highlight, selectionStorage, }) {
|
|
32
38
|
const localizedStrings = useHierarchiesLocalization();
|
|
33
39
|
const { onFeatureUsed, onPerformanceMeasured } = useTelemetryContext();
|
|
34
40
|
const [imodelChanged] = useState(new BeEvent());
|
|
@@ -62,7 +68,7 @@ function TreeImpl({ imodel, imodelAccess, treeName, noDataMessage, getFilteredPa
|
|
|
62
68
|
const { onNodeClick, onNodeKeyDown } = useSelectionHandler({ rootNodes, selectNodes, selectionMode: selectionMode ?? "single" });
|
|
63
69
|
const { filteringDialog, onFilterClick } = useHierarchyLevelFiltering({
|
|
64
70
|
imodel,
|
|
65
|
-
defaultHierarchyLevelSizeLimit,
|
|
71
|
+
defaultHierarchyLevelSizeLimit: currentHierarchyLevelSizeLimit,
|
|
66
72
|
});
|
|
67
73
|
const reportingExpandNode = useReportingAction({ action: expandNode });
|
|
68
74
|
const reportingOnFilterClicked = useReportingAction({ action: onFilterClick });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/Tree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC3G,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAA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C,SAAS,CAAC,6BAA6B,CAAC,GAAQ,GAC9F,CACR,CAAC;KACH;IAED,MAAM,iBAAiB,GAA6C;QAClE,GAAG,SAAS;QACZ,SAAS;QACT,WAAW;QACX,aAAa;QACb,UAAU,EAAE,mBAAmB;QAC/B,aAAa,EAAE,wBAAwB;QACvC,QAAQ;QACR,IAAI,EAAE,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;KACnD,CAAC;IAEF,OAAO,CACL,eAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,aACtE,eAAK,EAAE,EAAC,4BAA4B,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,aAC3D,YAAY,CAAC,iBAAiB,CAAC,EAC/B,eAAe,IACZ,EACN,KAAC,OAAO,IAAC,IAAI,EAAE,SAAS,YACtB,KAAC,eAAe,KAAG,GACX,IACN,CACP,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAAC,EAC7B,MAAM,EACN,SAAS,EACT,OAAO,GAKR;IACC,OAAO,WAAW,CAChB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,CACtB,MAAM,CACJ,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;QACxB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAC7B,OAAO,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC,EACF,UAAU,CACX,EACH,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAC7B,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 { useCallback, useMemo, useState } from \"react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { Flex, ProgressRadial, Text } from \"@itwin/itwinui-react\";\nimport { SchemaMetadataContextProvider } from \"@itwin/presentation-components\";\nimport { useIModelUnifiedSelectionTree, useSelectionHandler } from \"@itwin/presentation-hierarchies-react\";\nimport { TreeWidget } from \"../../../../TreeWidget.js\";\nimport { useHierarchiesLocalization } from \"../UseHierarchiesLocalization.js\";\nimport { useHierarchyLevelFiltering } from \"../UseHierarchyFiltering.js\";\nimport { useIModelChangeListener } from \"../UseIModelChangeListener.js\";\nimport { useNodeHighlighting } from \"../UseNodeHighlighting.js\";\nimport { useReportingAction, useTelemetryContext } from \"../UseTelemetryContext.js\";\nimport { createIModelAccess } from \"../Utils.js\";\nimport { Delayed } from \"./Delayed.js\";\nimport { ProgressOverlay } from \"./ProgressOverlay.js\";\n\nimport type { MarkRequired } from \"@itwin/core-bentley\";\nimport type { FunctionProps } from \"../Utils.js\";\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport type { PresentationHierarchyNode, SelectionStorage, useIModelTree } from \"@itwin/presentation-hierarchies-react\";\nimport type { HighlightInfo } from \"../UseNodeHighlighting.js\";\nimport type { TreeRendererProps } from \"./TreeRenderer.js\";\n\n/** @beta */\nexport type TreeProps = Pick<FunctionProps<typeof useIModelTree>, \"getFilteredPaths\" | \"getHierarchyDefinition\"> &\n Partial<Pick<FunctionProps<typeof useSelectionHandler>, \"selectionMode\">> & {\n /** iModel connection that should be used to pull data from. */\n imodel: IModelConnection;\n /** Callback for getting `SchemaContext` for specific iModel. */\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\n /** Unique tree component name that will be used as unified selection change event source when selecting node. */\n treeName: string;\n /** Unified selection storage that should be used by tree to handle tree selection changes. */\n selectionStorage: SelectionStorage;\n /**\n * An optional predicate to allow or prohibit selection of a node.\n * When not supplied, all nodes are selectable.\n */\n selectionPredicate?: (node: PresentationHierarchyNode) => boolean;\n /** Tree renderer that should be used to render tree data. */\n treeRenderer: (\n treeProps: Required<\n Pick<\n TreeRendererProps,\n \"rootNodes\" | \"expandNode\" | \"onNodeClick\" | \"onNodeKeyDown\" | \"onFilterClick\" | \"isNodeSelected\" | \"getHierarchyLevelDetails\" | \"size\" | \"getLabel\"\n >\n >,\n ) => ReactNode;\n /** Custom iModel access that is stored outside tree component. If not provided it new iModel access will be created using `imodel` prop. */\n imodelAccess?: FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n /** Size limit that should be applied on each hierarchy level. Default to `1000`. */\n hierarchyLevelSizeLimit?: number;\n /** Modifies the density of tree nodes. `enlarged` tree nodes have bigger button hit boxes. */\n density?: \"default\" | \"enlarged\";\n /** Message that should be renderer if there are no tree nodes. */\n noDataMessage?: ReactNode;\n /** Callback that this invoked when tree reloads. */\n onReload?: () => void;\n /** Options for highlighting node labels. */\n highlight?: HighlightInfo;\n };\n\n/**\n * Default tree component that manages tree state and renders using supplied `treeRenderer`.\n * @beta\n */\nexport function Tree({ getSchemaContext, hierarchyLevelSizeLimit, selectionStorage, imodelAccess: providedIModelAccess, ...props }: TreeProps) {\n const defaultHierarchyLevelSizeLimit = hierarchyLevelSizeLimit ?? 1000;\n\n const imodelAccess = useMemo(() => {\n return providedIModelAccess ?? createIModelAccess({ getSchemaContext, imodel: props.imodel });\n }, [providedIModelAccess, getSchemaContext, props.imodel]);\n\n return (\n <SchemaMetadataContextProvider imodel={props.imodel} schemaContextProvider={getSchemaContext}>\n <TreeImpl {...props} selectionStorage={selectionStorage} imodelAccess={imodelAccess} defaultHierarchyLevelSizeLimit={defaultHierarchyLevelSizeLimit} />\n </SchemaMetadataContextProvider>\n );\n}\n\nfunction TreeImpl({\n imodel,\n imodelAccess,\n treeName,\n noDataMessage,\n getFilteredPaths,\n defaultHierarchyLevelSizeLimit,\n getHierarchyDefinition,\n selectionPredicate,\n selectionMode,\n onReload,\n treeRenderer,\n density,\n highlight,\n selectionStorage,\n}: MarkRequired<Omit<TreeProps, \"getSchemaContext\">, \"imodelAccess\"> & { defaultHierarchyLevelSizeLimit: number }) {\n const localizedStrings = useHierarchiesLocalization();\n const { onFeatureUsed, onPerformanceMeasured } = useTelemetryContext();\n const [imodelChanged] = useState(new BeEvent<() => void>());\n const {\n rootNodes,\n getNode,\n isLoading,\n selectNodes: selectNodesAction,\n setFormatter: _setFormatter,\n expandNode,\n ...treeProps\n } = useIModelUnifiedSelectionTree({\n imodelAccess,\n imodelChanged,\n getHierarchyDefinition,\n getFilteredPaths,\n sourceName: treeName,\n localizedStrings,\n selectionStorage,\n onPerformanceMeasured: (action, duration) => {\n if (action === \"reload\") {\n onReload?.();\n }\n onPerformanceMeasured(action, duration);\n },\n onHierarchyLimitExceeded: () => onFeatureUsed({ featureId: \"hierarchy-level-size-limit-hit\", reportInteraction: false }),\n onHierarchyLoadError: ({ type, error }) => {\n // eslint-disable-next-line no-console\n console.error(error);\n onFeatureUsed({ featureId: `error-${type}`, reportInteraction: false });\n },\n });\n useIModelChangeListener({ imodel, action: useCallback(() => imodelChanged.raiseEvent(), [imodelChanged]) });\n\n const selectNodes = useSelectionPredicate({\n action: useReportingAction({ action: selectNodesAction }),\n predicate: selectionPredicate,\n getNode,\n });\n const { onNodeClick, onNodeKeyDown } = useSelectionHandler({ rootNodes, selectNodes, selectionMode: selectionMode ?? \"single\" });\n const { filteringDialog, onFilterClick } = useHierarchyLevelFiltering({\n imodel,\n defaultHierarchyLevelSizeLimit,\n });\n const reportingExpandNode = useReportingAction({ action: expandNode });\n const reportingOnFilterClicked = useReportingAction({ action: onFilterClick });\n const { getLabel } = useNodeHighlighting({ rootNodes, highlight });\n\n if (rootNodes === undefined) {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\" flexDirection=\"column\" style={{ width: \"100%\", height: \"100%\" }}>\n <Delayed show={true}>\n <ProgressRadial size=\"large\" />\n </Delayed>\n </Flex>\n );\n }\n\n if (rootNodes.length === 0 && !isLoading) {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\" flexDirection=\"column\" style={{ width: \"100%\", height: \"100%\" }}>\n {noDataMessage ? noDataMessage : <Text>{TreeWidget.translate(\"baseTree.dataIsNotAvailable\")}</Text>}\n </Flex>\n );\n }\n\n const treeRendererProps: FunctionProps<TreeProps[\"treeRenderer\"]> = {\n ...treeProps,\n rootNodes,\n onNodeClick,\n onNodeKeyDown,\n expandNode: reportingExpandNode,\n onFilterClick: reportingOnFilterClicked,\n getLabel,\n size: density === \"enlarged\" ? \"default\" : \"small\",\n };\n\n return (\n <div style={{ position: \"relative\", height: \"100%\", overflow: \"hidden\" }}>\n <div id=\"tw-tree-renderer-container\" style={{ height: \"100%\" }}>\n {treeRenderer(treeRendererProps)}\n {filteringDialog}\n </div>\n <Delayed show={isLoading}>\n <ProgressOverlay />\n </Delayed>\n </div>\n );\n}\n\nfunction useSelectionPredicate({\n action,\n predicate,\n getNode,\n}: {\n action: (...args: any[]) => void;\n predicate?: (node: PresentationHierarchyNode) => boolean;\n getNode: (nodeId: string) => PresentationHierarchyNode | undefined;\n}): ReturnType<typeof useIModelUnifiedSelectionTree>[\"selectNodes\"] {\n return useCallback(\n (nodeIds, changeType) =>\n action(\n nodeIds.filter((nodeId) => {\n const node = getNode(nodeId);\n return node && (!predicate || predicate(node));\n }),\n changeType,\n ),\n [action, getNode, predicate],\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/Tree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AA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AAI,IAAI,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC,EACF,UAAU,CACX,EACH,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAC7B,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 { useCallback, useState } from \"react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { Flex, ProgressRadial, Text } from \"@itwin/itwinui-react\";\nimport { SchemaMetadataContextProvider } from \"@itwin/presentation-components\";\nimport { useIModelUnifiedSelectionTree, useSelectionHandler } from \"@itwin/presentation-hierarchies-react\";\nimport { TreeWidget } from \"../../../../TreeWidget.js\";\nimport { useHierarchiesLocalization } from \"../UseHierarchiesLocalization.js\";\nimport { useHierarchyLevelFiltering } from \"../UseHierarchyFiltering.js\";\nimport { useIModelAccess } from \"../UseIModelAccess.js\";\nimport { useIModelChangeListener } from \"../UseIModelChangeListener.js\";\nimport { useNodeHighlighting } from \"../UseNodeHighlighting.js\";\nimport { useReportingAction, useTelemetryContext } from \"../UseTelemetryContext.js\";\nimport { Delayed } from \"./Delayed.js\";\nimport { ProgressOverlay } from \"./ProgressOverlay.js\";\n\nimport type { MarkRequired } from \"@itwin/core-bentley\";\nimport type { FunctionProps } from \"../Utils.js\";\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport type { PresentationHierarchyNode, SelectionStorage, useIModelTree } from \"@itwin/presentation-hierarchies-react\";\nimport type { HighlightInfo } from \"../UseNodeHighlighting.js\";\nimport type { TreeRendererProps } from \"./TreeRenderer.js\";\n\n/** @beta */\nexport type TreeProps = Pick<FunctionProps<typeof useIModelTree>, \"getFilteredPaths\" | \"getHierarchyDefinition\"> &\n Partial<Pick<FunctionProps<typeof useSelectionHandler>, \"selectionMode\">> & {\n /** iModel connection that should be used to pull data from. */\n imodel: IModelConnection;\n /** Callback for getting `SchemaContext` for specific iModel. */\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\n /** Unique tree component name that will be used as unified selection change event source when selecting node. */\n treeName: string;\n /** Unified selection storage that should be used by tree to handle tree selection changes. */\n selectionStorage: SelectionStorage;\n /**\n * An optional predicate to allow or prohibit selection of a node.\n * When not supplied, all nodes are selectable.\n */\n selectionPredicate?: (node: PresentationHierarchyNode) => boolean;\n /** Tree renderer that should be used to render tree data. */\n treeRenderer: (\n treeProps: Required<\n Pick<\n TreeRendererProps,\n \"rootNodes\" | \"expandNode\" | \"onNodeClick\" | \"onNodeKeyDown\" | \"onFilterClick\" | \"isNodeSelected\" | \"getHierarchyLevelDetails\" | \"size\" | \"getLabel\"\n >\n >,\n ) => ReactNode;\n /** Custom iModel access that is stored outside tree component. If not provided it new iModel access will be created using `imodel` prop. */\n imodelAccess?: FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n /** Size limit that should be applied on each hierarchy level. Default to `1000`. */\n hierarchyLevelSizeLimit?: number;\n /** Modifies the density of tree nodes. `enlarged` tree nodes have bigger button hit boxes. */\n density?: \"default\" | \"enlarged\";\n /** Message that should be renderer if there are no tree nodes. */\n noDataMessage?: ReactNode;\n /** Callback that this invoked when tree reloads. */\n onReload?: () => void;\n /** Options for highlighting node labels. */\n highlight?: HighlightInfo;\n };\n\n/**\n * Default tree component that manages tree state and renders using supplied `treeRenderer`.\n * @beta\n */\nexport function Tree({ getSchemaContext, hierarchyLevelSizeLimit, selectionStorage, imodelAccess: providedIModelAccess, ...props }: TreeProps) {\n const { imodelAccess, currentHierarchyLevelSizeLimit } = useIModelAccess({\n imodel: props.imodel,\n imodelAccess: providedIModelAccess,\n getSchemaContext,\n hierarchyLevelSizeLimit,\n });\n return (\n <TreeBase\n {...props}\n getSchemaContext={getSchemaContext}\n selectionStorage={selectionStorage}\n imodelAccess={imodelAccess}\n currentHierarchyLevelSizeLimit={currentHierarchyLevelSizeLimit}\n />\n );\n}\n\n/** @internal */\nexport function TreeBase({ getSchemaContext, ...props }: MarkRequired<TreeProps, \"imodelAccess\"> & { currentHierarchyLevelSizeLimit: number }) {\n return (\n <SchemaMetadataContextProvider imodel={props.imodel} schemaContextProvider={getSchemaContext}>\n <TreeBaseImpl {...props} />\n </SchemaMetadataContextProvider>\n );\n}\n\nfunction TreeBaseImpl({\n imodel,\n imodelAccess,\n treeName,\n noDataMessage,\n getFilteredPaths,\n currentHierarchyLevelSizeLimit,\n getHierarchyDefinition,\n selectionPredicate,\n selectionMode,\n onReload,\n treeRenderer,\n density,\n highlight,\n selectionStorage,\n}: MarkRequired<Omit<TreeProps, \"getSchemaContext\">, \"imodelAccess\"> & { currentHierarchyLevelSizeLimit: number }) {\n const localizedStrings = useHierarchiesLocalization();\n const { onFeatureUsed, onPerformanceMeasured } = useTelemetryContext();\n const [imodelChanged] = useState(new BeEvent<() => void>());\n const {\n rootNodes,\n getNode,\n isLoading,\n selectNodes: selectNodesAction,\n setFormatter: _setFormatter,\n expandNode,\n ...treeProps\n } = useIModelUnifiedSelectionTree({\n imodelAccess,\n imodelChanged,\n getHierarchyDefinition,\n getFilteredPaths,\n sourceName: treeName,\n localizedStrings,\n selectionStorage,\n onPerformanceMeasured: (action, duration) => {\n if (action === \"reload\") {\n onReload?.();\n }\n onPerformanceMeasured(action, duration);\n },\n onHierarchyLimitExceeded: () => onFeatureUsed({ featureId: \"hierarchy-level-size-limit-hit\", reportInteraction: false }),\n onHierarchyLoadError: ({ type, error }) => {\n // eslint-disable-next-line no-console\n console.error(error);\n onFeatureUsed({ featureId: `error-${type}`, reportInteraction: false });\n },\n });\n useIModelChangeListener({ imodel, action: useCallback(() => imodelChanged.raiseEvent(), [imodelChanged]) });\n\n const selectNodes = useSelectionPredicate({\n action: useReportingAction({ action: selectNodesAction }),\n predicate: selectionPredicate,\n getNode,\n });\n const { onNodeClick, onNodeKeyDown } = useSelectionHandler({ rootNodes, selectNodes, selectionMode: selectionMode ?? \"single\" });\n const { filteringDialog, onFilterClick } = useHierarchyLevelFiltering({\n imodel,\n defaultHierarchyLevelSizeLimit: currentHierarchyLevelSizeLimit,\n });\n const reportingExpandNode = useReportingAction({ action: expandNode });\n const reportingOnFilterClicked = useReportingAction({ action: onFilterClick });\n const { getLabel } = useNodeHighlighting({ rootNodes, highlight });\n\n if (rootNodes === undefined) {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\" flexDirection=\"column\" style={{ width: \"100%\", height: \"100%\" }}>\n <Delayed show={true}>\n <ProgressRadial size=\"large\" />\n </Delayed>\n </Flex>\n );\n }\n\n if (rootNodes.length === 0 && !isLoading) {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\" flexDirection=\"column\" style={{ width: \"100%\", height: \"100%\" }}>\n {noDataMessage ? noDataMessage : <Text>{TreeWidget.translate(\"baseTree.dataIsNotAvailable\")}</Text>}\n </Flex>\n );\n }\n\n const treeRendererProps: FunctionProps<TreeProps[\"treeRenderer\"]> = {\n ...treeProps,\n rootNodes,\n onNodeClick,\n onNodeKeyDown,\n expandNode: reportingExpandNode,\n onFilterClick: reportingOnFilterClicked,\n getLabel,\n size: density === \"enlarged\" ? \"default\" : \"small\",\n };\n\n return (\n <div style={{ position: \"relative\", height: \"100%\", overflow: \"hidden\" }}>\n <div id=\"tw-tree-renderer-container\" style={{ height: \"100%\" }}>\n {treeRenderer(treeRendererProps)}\n {filteringDialog}\n </div>\n <Delayed show={isLoading}>\n <ProgressOverlay />\n </Delayed>\n </div>\n );\n}\n\nfunction useSelectionPredicate({\n action,\n predicate,\n getNode,\n}: {\n action: (...args: any[]) => void;\n predicate?: (node: PresentationHierarchyNode) => boolean;\n getNode: (nodeId: string) => PresentationHierarchyNode | undefined;\n}): ReturnType<typeof useIModelUnifiedSelectionTree>[\"selectNodes\"] {\n return useCallback(\n (nodeIds, changeType) =>\n action(\n nodeIds.filter((nodeId) => {\n const node = getNode(nodeId);\n return node && (!predicate || predicate(node));\n }),\n changeType,\n ),\n [action, getNode, predicate],\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FunctionProps } from "../Utils.js";
|
|
2
1
|
import type { TreeProps } from "./Tree.js";
|
|
2
|
+
import type { FunctionProps } from "../Utils.js";
|
|
3
3
|
import type { ReactNode } from "react";
|
|
4
4
|
import type { VisibilityTreeRendererProps } from "./VisibilityTreeRenderer.js";
|
|
5
5
|
import type { ECClassHierarchyInspector } from "@itwin/presentation-shared";
|
|
@@ -17,5 +17,5 @@ export type VisibilityTreeProps = Omit<TreeProps, "treeRenderer" | "imodelAccess
|
|
|
17
17
|
* Tree component that can control visibility of instances represented by tree nodes.
|
|
18
18
|
* @beta
|
|
19
19
|
*/
|
|
20
|
-
export declare function VisibilityTree({ visibilityHandlerFactory, treeRenderer, ...props }: VisibilityTreeProps): JSX.Element;
|
|
20
|
+
export declare function VisibilityTree({ visibilityHandlerFactory, treeRenderer, hierarchyLevelSizeLimit, ...props }: VisibilityTreeProps): JSX.Element;
|
|
21
21
|
//# sourceMappingURL=VisibilityTree.d.ts.map
|
|
@@ -3,20 +3,24 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
import { useCallback
|
|
6
|
+
import { useCallback } from "react";
|
|
7
7
|
import { useHierarchyVisibility } from "../UseHierarchyVisibility.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { useIModelAccess } from "../UseIModelAccess.js";
|
|
9
|
+
import { TreeBase } from "./Tree.js";
|
|
10
10
|
/**
|
|
11
11
|
* Tree component that can control visibility of instances represented by tree nodes.
|
|
12
12
|
* @beta
|
|
13
13
|
*/
|
|
14
|
-
export function VisibilityTree({ visibilityHandlerFactory, treeRenderer, ...props }) {
|
|
14
|
+
export function VisibilityTree({ visibilityHandlerFactory, treeRenderer, hierarchyLevelSizeLimit, ...props }) {
|
|
15
15
|
const { imodel, getSchemaContext } = props;
|
|
16
|
-
const
|
|
16
|
+
const { imodelAccess, currentHierarchyLevelSizeLimit } = useIModelAccess({
|
|
17
|
+
imodel,
|
|
18
|
+
getSchemaContext,
|
|
19
|
+
hierarchyLevelSizeLimit,
|
|
20
|
+
});
|
|
17
21
|
const { getCheckboxState, onCheckboxClicked, triggerRefresh } = useHierarchyVisibility({
|
|
18
22
|
visibilityHandlerFactory: useCallback(() => visibilityHandlerFactory({ imodelAccess }), [visibilityHandlerFactory, imodelAccess]),
|
|
19
23
|
});
|
|
20
|
-
return (_jsx(
|
|
24
|
+
return (_jsx(TreeBase, { ...props, onReload: triggerRefresh, imodelAccess: imodelAccess, currentHierarchyLevelSizeLimit: currentHierarchyLevelSizeLimit, treeRenderer: (treeProps) => treeRenderer({ ...treeProps, getCheckboxState, onCheckboxClicked }) }));
|
|
21
25
|
}
|
|
22
26
|
//# sourceMappingURL=VisibilityTree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisibilityTree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/VisibilityTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"VisibilityTree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/VisibilityTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAmBrC;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,wBAAwB,EAAE,YAAY,EAAE,uBAAuB,EAAE,GAAG,KAAK,EAAuB;IAC/H,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;IAC3C,MAAM,EAAE,YAAY,EAAE,8BAA8B,EAAE,GAAG,eAAe,CAAC;QACvE,MAAM;QACN,gBAAgB;QAChB,uBAAuB;KACxB,CAAC,CAAC;IAEH,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,sBAAsB,CAAC;QACrF,wBAAwB,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,wBAAwB,EAAE,YAAY,CAAC,CAAC;KAClI,CAAC,CAAC;IAEH,OAAO,CACL,KAAC,QAAQ,OACH,KAAK,EACT,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,YAAY,EAC1B,8BAA8B,EAAE,8BAA8B,EAC9D,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,EAAE,GAAG,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC,GAChG,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 { useCallback } from \"react\";\nimport { useHierarchyVisibility } from \"../UseHierarchyVisibility.js\";\nimport { useIModelAccess } from \"../UseIModelAccess.js\";\nimport { TreeBase } from \"./Tree.js\";\n\nimport type { TreeProps } from \"./Tree.js\";\nimport type { FunctionProps } from \"../Utils.js\";\nimport type { ReactNode } from \"react\";\nimport type { VisibilityTreeRendererProps } from \"./VisibilityTreeRenderer.js\";\nimport type { ECClassHierarchyInspector } from \"@itwin/presentation-shared\";\nimport type { HierarchyVisibilityHandler } from \"../UseHierarchyVisibility.js\";\n\n/** @beta */\nexport type VisibilityTreeProps = Omit<TreeProps, \"treeRenderer\" | \"imodelAccess\"> & {\n /** Callback for creating visibility handler used to control visibility of instances represented by tree nodes. */\n visibilityHandlerFactory: (props: { imodelAccess: ECClassHierarchyInspector }) => HierarchyVisibilityHandler;\n /** Tree renderer that should be used to render tree data. */\n treeRenderer: (\n treeProps: FunctionProps<TreeProps[\"treeRenderer\"]> & Pick<VisibilityTreeRendererProps, \"getCheckboxState\" | \"onCheckboxClicked\">,\n ) => ReactNode;\n};\n\n/**\n * Tree component that can control visibility of instances represented by tree nodes.\n * @beta\n */\nexport function VisibilityTree({ visibilityHandlerFactory, treeRenderer, hierarchyLevelSizeLimit, ...props }: VisibilityTreeProps) {\n const { imodel, getSchemaContext } = props;\n const { imodelAccess, currentHierarchyLevelSizeLimit } = useIModelAccess({\n imodel,\n getSchemaContext,\n hierarchyLevelSizeLimit,\n });\n\n const { getCheckboxState, onCheckboxClicked, triggerRefresh } = useHierarchyVisibility({\n visibilityHandlerFactory: useCallback(() => visibilityHandlerFactory({ imodelAccess }), [visibilityHandlerFactory, imodelAccess]),\n });\n\n return (\n <TreeBase\n {...props}\n onReload={triggerRefresh}\n imodelAccess={imodelAccess}\n currentHierarchyLevelSizeLimit={currentHierarchyLevelSizeLimit}\n treeRenderer={(treeProps) => treeRenderer({ ...treeProps, getCheckboxState, onCheckboxClicked })}\n />\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/tree-widget-react",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.1",
|
|
4
4
|
"description": "Tree Widget React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Bentley",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"@itwin/itwinui-illustrations-react": "^2.1.0",
|
|
72
72
|
"@itwin/presentation-core-interop": "^1.3.0",
|
|
73
73
|
"@itwin/presentation-hierarchies": "^1.4.1",
|
|
74
|
-
"@itwin/presentation-hierarchies-react": "^1.6.
|
|
74
|
+
"@itwin/presentation-hierarchies-react": "^1.6.5",
|
|
75
75
|
"@itwin/presentation-shared": "^1.2.0",
|
|
76
76
|
"@itwin/unified-selection": "^1.3.0",
|
|
77
77
|
"classnames": "^2.5.1",
|