@itwin/tree-widget-react 3.5.1 → 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 +24 -2
- package/README.md +2 -1
- 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 +49 -4
- 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/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +3 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +12 -8
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.d.ts +12 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +14 -44
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +5 -3
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +26 -60
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +22 -9
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.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 +49 -4
- 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/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +3 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +13 -9
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.d.ts +12 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +14 -44
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +5 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +27 -61
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +22 -9
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/package.json +4 -5
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
import { createECSchemaProvider, createECSqlQueryExecutor } from "@itwin/presentation-core-interop";
|
|
7
|
+
import { createLimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
|
|
8
|
+
import { createCachingECClassHierarchyInspector } from "@itwin/presentation-shared";
|
|
9
|
+
/** @internal */
|
|
10
|
+
export function useIModelAccess({ imodel, getSchemaContext, imodelAccess: providedIModelAccess, hierarchyLevelSizeLimit }) {
|
|
11
|
+
const defaultHierarchyLevelSizeLimit = hierarchyLevelSizeLimit ?? 1000;
|
|
12
|
+
const imodelAccess = useMemo(() => {
|
|
13
|
+
return providedIModelAccess ?? createIModelAccess({ getSchemaContext, imodel, hierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit });
|
|
14
|
+
}, [providedIModelAccess, getSchemaContext, imodel, defaultHierarchyLevelSizeLimit]);
|
|
15
|
+
return {
|
|
16
|
+
imodelAccess,
|
|
17
|
+
currentHierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function createIModelAccess({ imodel, getSchemaContext, hierarchyLevelSizeLimit, }) {
|
|
21
|
+
const schemas = getSchemaContext(imodel);
|
|
22
|
+
const schemaProvider = createECSchemaProvider(schemas);
|
|
23
|
+
return {
|
|
24
|
+
imodelKey: imodel.key,
|
|
25
|
+
...schemaProvider,
|
|
26
|
+
...createCachingECClassHierarchyInspector({ schemaProvider, cacheSize: 100 }),
|
|
27
|
+
...createLimitingECSqlQueryExecutor(createECSqlQueryExecutor(imodel), hierarchyLevelSizeLimit),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=UseIModelAccess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseIModelAccess.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/UseIModelAccess.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACpG,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAE,sCAAsC,EAAE,MAAM,4BAA4B,CAAC;AAgBpF,gBAAgB;AAChB,MAAM,UAAU,eAAe,CAAC,EAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,uBAAuB,EAAuB;IAIzI,MAAM,8BAA8B,GAAG,uBAAuB,IAAI,IAAI,CAAC;IACvE,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE;QAChC,OAAO,oBAAoB,IAAI,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,MAAM,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,CAAC,CAAC;IAC3I,CAAC,EAAE,CAAC,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,EAAE,8BAA8B,CAAC,CAAC,CAAC;IAErF,OAAO;QACL,YAAY;QACZ,8BAA8B,EAAE,8BAA8B;KAC/D,CAAA;AACL,CAAC;AAED,SAAS,kBAAkB,CAAC,EAC1B,MAAM,EACN,gBAAgB,EAChB,uBAAuB,GAKxB;IACC,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,cAAc,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACvD,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,GAAG;QACrB,GAAG,cAAc;QACjB,GAAG,sCAAsC,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;QAC7E,GAAG,gCAAgC,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,uBAAuB,CAAC;KAC/F,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 { useMemo } from \"react\";\nimport { createECSchemaProvider, createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { createLimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport { createCachingECClassHierarchyInspector } from \"@itwin/presentation-shared\";\n\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport type { useIModelTree } from \"@itwin/presentation-hierarchies-react\";\nimport type { FunctionProps } from \"./Utils.js\";\n\ntype IModelAccess = FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n\nexport interface UseIModelAccessProps {\n imodel: IModelConnection;\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\n imodelAccess?: IModelAccess;\n hierarchyLevelSizeLimit?: number;\n}\n\n/** @internal */\nexport function useIModelAccess({imodel, getSchemaContext, imodelAccess: providedIModelAccess, hierarchyLevelSizeLimit}: UseIModelAccessProps): {\n imodelAccess: IModelAccess;\n currentHierarchyLevelSizeLimit: number;\n} {\n const defaultHierarchyLevelSizeLimit = hierarchyLevelSizeLimit ?? 1000;\n const imodelAccess = useMemo(() => {\n return providedIModelAccess ?? createIModelAccess({ getSchemaContext, imodel, hierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit });\n }, [providedIModelAccess, getSchemaContext, imodel, defaultHierarchyLevelSizeLimit]);\n\n return {\n imodelAccess,\n currentHierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit,\n }\n}\n\nfunction createIModelAccess({\n imodel,\n getSchemaContext,\n hierarchyLevelSizeLimit,\n}: {\n imodel: IModelConnection;\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\n hierarchyLevelSizeLimit: number;\n}) {\n const schemas = getSchemaContext(imodel);\n const schemaProvider = createECSchemaProvider(schemas);\n return {\n imodelKey: imodel.key,\n ...schemaProvider,\n ...createCachingECClassHierarchyInspector({ schemaProvider, cacheSize: 100 }),\n ...createLimitingECSqlQueryExecutor(createECSqlQueryExecutor(imodel), hierarchyLevelSizeLimit),\n };\n}\n"]}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { Id64Array } from "@itwin/core-bentley";
|
|
3
|
-
import type { IModelConnection } from "@itwin/core-frontend";
|
|
4
|
-
import type { SchemaContext } from "@itwin/ecschema-metadata";
|
|
5
3
|
/** @beta */
|
|
6
4
|
export type FunctionProps<THook extends (props: any) => any> = Parameters<THook>[0];
|
|
7
5
|
/** @internal */
|
|
@@ -11,17 +9,5 @@ export declare function parseIdsSelectorResult(selectorResult: any): Id64Array;
|
|
|
11
9
|
/** @internal */
|
|
12
10
|
export declare function pushToMap<TKey, TValue>(targetMap: Map<TKey, Set<TValue>>, key: TKey, value: TValue): void;
|
|
13
11
|
/** @internal */
|
|
14
|
-
export declare function createIModelAccess({ imodel, getSchemaContext }: {
|
|
15
|
-
imodel: IModelConnection;
|
|
16
|
-
getSchemaContext: (imodel: IModelConnection) => SchemaContext;
|
|
17
|
-
}): {
|
|
18
|
-
createQueryReader(query: import("@itwin/presentation-shared").ECSqlQueryDef, config?: (import("@itwin/presentation-shared").ECSqlQueryReaderOptions & {
|
|
19
|
-
limit?: number | "unbounded" | undefined;
|
|
20
|
-
}) | undefined): AsyncIterableIterator<import("@itwin/presentation-shared").ECSqlQueryRow>;
|
|
21
|
-
classDerivesFrom(derivedClassFullName: string, candidateBaseClassFullName: string): boolean | Promise<boolean>;
|
|
22
|
-
getSchema(schemaName: string): Promise<import("@itwin/presentation-shared").EC.Schema | undefined>;
|
|
23
|
-
imodelKey: string;
|
|
24
|
-
};
|
|
25
|
-
/** @internal */
|
|
26
12
|
export declare function useLatest<T>(value: T): import("react").MutableRefObject<T>;
|
|
27
13
|
//# sourceMappingURL=Utils.d.ts.map
|
|
@@ -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,C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CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,EAAc,CAAC,CAAC;AAClJ,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,SAAS,CAAe,SAAiC,EAAE,GAAS,EAAE,KAAa;IACjG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,CAAC,GAAG,EAAE;QACR,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;QAChB,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;KACzB;IACD,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACjB,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,SAAS,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,MA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tB,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;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,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAkDvD;;;GAGG;AACH,MAAM,UAAU,IAAI,CAAC,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAAG,KAAK,EAAa;IAC3I,MAAM,EAAE,YAAY,EAAE,8BAA8B,EAAE,GAAG,eAAe,CAAC;QACvE,MAAM,EAAE,KAAK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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, 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/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import type { IModelContentTreeHierarchyConfiguration } from "./IModelContentTreeDefinition.js";
|
|
2
3
|
import type { TreeProps } from "../common/components/Tree.js";
|
|
3
4
|
/** @beta */
|
|
4
5
|
export type IModelContentTreeProps = Pick<TreeProps, "imodel" | "getSchemaContext" | "selectionStorage" | "density" | "selectionMode"> & {
|
|
5
6
|
hierarchyLevelConfig?: {
|
|
6
7
|
sizeLimit?: number;
|
|
7
8
|
};
|
|
9
|
+
hierarchyConfig?: Partial<IModelContentTreeHierarchyConfiguration>;
|
|
8
10
|
};
|
|
9
11
|
/** @beta */
|
|
10
|
-
export declare function IModelContentTree(props: IModelContentTreeProps): JSX.Element;
|
|
12
|
+
export declare function IModelContentTree({ hierarchyConfig: hierarchyConfigProp, ...props }: IModelContentTreeProps): JSX.Element;
|
|
11
13
|
//# sourceMappingURL=IModelContentTree.d.ts.map
|
|
@@ -3,22 +3,26 @@ 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 } from "react";
|
|
6
7
|
import { SvgFolder, SvgGroup, SvgHierarchyTree, SvgImodelHollow, SvgItem, SvgLayers, SvgModel } from "@itwin/itwinui-icons-react";
|
|
7
8
|
import { Tree } from "../common/components/Tree.js";
|
|
8
9
|
import { TreeRenderer } from "../common/components/TreeRenderer.js";
|
|
9
10
|
import { IModelContentTreeComponent } from "./IModelContentTreeComponent.js";
|
|
10
|
-
import { IModelContentTreeDefinition } from "./IModelContentTreeDefinition.js";
|
|
11
|
+
import { defaultHierarchyConfiguration, IModelContentTreeDefinition } from "./IModelContentTreeDefinition.js";
|
|
11
12
|
import { IModelContentTreeIdsCache } from "./internal/IModelContentTreeIdsCache.js";
|
|
12
13
|
/** @beta */
|
|
13
|
-
export function IModelContentTree(props) {
|
|
14
|
-
|
|
14
|
+
export function IModelContentTree({ hierarchyConfig: hierarchyConfigProp, ...props }) {
|
|
15
|
+
const getHierarchyDefinition = useCallback(({ imodelAccess }) => {
|
|
16
|
+
const hierarchyConfig = {
|
|
17
|
+
...defaultHierarchyConfiguration,
|
|
18
|
+
...hierarchyConfigProp,
|
|
19
|
+
};
|
|
20
|
+
return new IModelContentTreeDefinition({ imodelAccess, idsCache: new IModelContentTreeIdsCache(imodelAccess), hierarchyConfig });
|
|
21
|
+
},
|
|
22
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
|
+
Object.values(hierarchyConfigProp ?? {}));
|
|
24
|
+
return (_jsx(Tree, { ...props, treeName: IModelContentTreeComponent.id, getHierarchyDefinition: getHierarchyDefinition, selectionMode: props.selectionMode ?? "extended", treeRenderer: (treeProps) => _jsx(TreeRenderer, { ...treeProps, getIcon: getIcon }) }));
|
|
15
25
|
}
|
|
16
|
-
const getDefinitionsProvider = ({ imodelAccess }) => {
|
|
17
|
-
return new IModelContentTreeDefinition({
|
|
18
|
-
imodelAccess,
|
|
19
|
-
idsCache: new IModelContentTreeIdsCache(imodelAccess),
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
26
|
function getIcon(node) {
|
|
23
27
|
if (node.extendedData?.imageId === undefined) {
|
|
24
28
|
return undefined;
|
package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAClI,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAClI,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC9G,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAepF,YAAY;AACZ,MAAM,UAAU,iBAAiB,CAAC,EAAE,eAAe,EAAE,mBAAmB,EAAE,GAAG,KAAK,EAA0B;IAC1G,MAAM,sBAAsB,GAAG,WAAW,CACxC,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE;QACnB,MAAM,eAAe,GAAG;YACtB,GAAG,6BAA6B;YAChC,GAAG,mBAAmB;SACvB,CAAC;QACF,OAAO,IAAI,2BAA2B,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,yBAAyB,CAAC,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC;IACnI,CAAC;IACD,uDAAuD;IACvD,MAAM,CAAC,MAAM,CAAC,mBAAmB,IAAI,EAAE,CAAC,CACzC,CAAC;IAEF,OAAO,CACL,KAAC,IAAI,OACC,KAAK,EACT,QAAQ,EAAE,0BAA0B,CAAC,EAAE,EACvC,sBAAsB,EAAE,sBAAsB,EAC9C,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,UAAU,EAChD,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,KAAC,YAAY,OAAK,SAAS,EAAE,OAAO,EAAE,OAAO,GAAI,GAC9E,CACH,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,IAA+B;IAC9C,IAAI,IAAI,CAAC,YAAY,EAAE,OAAO,KAAK,SAAS,EAAE;QAC5C,OAAO,SAAS,CAAC;KAClB;IAED,QAAQ,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;QACjC,KAAK,aAAa;YAChB,OAAO,KAAC,SAAS,KAAG,CAAC;QACvB,KAAK,WAAW;YACd,OAAO,KAAC,OAAO,KAAG,CAAC;QACrB,KAAK,eAAe;YAClB,OAAO,KAAC,OAAO,KAAG,CAAC;QACrB,KAAK,sBAAsB;YACzB,OAAO,KAAC,eAAe,KAAG,CAAC;QAC7B,KAAK,aAAa;YAChB,OAAO,KAAC,SAAS,KAAG,CAAC;QACvB,KAAK,YAAY;YACf,OAAO,KAAC,QAAQ,KAAG,CAAC;QACtB,KAAK,qBAAqB;YACxB,OAAO,KAAC,gBAAgB,KAAG,CAAC;QAC9B,KAAK,YAAY;YACf,OAAO,KAAC,QAAQ,KAAG,CAAC;KACvB;IAED,OAAO,SAAS,CAAC;AACnB,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 { SvgFolder, SvgGroup, SvgHierarchyTree, SvgImodelHollow, SvgItem, SvgLayers, SvgModel } from \"@itwin/itwinui-icons-react\";\nimport { Tree } from \"../common/components/Tree.js\";\nimport { TreeRenderer } from \"../common/components/TreeRenderer.js\";\nimport { IModelContentTreeComponent } from \"./IModelContentTreeComponent.js\";\nimport { defaultHierarchyConfiguration, IModelContentTreeDefinition } from \"./IModelContentTreeDefinition.js\";\nimport { IModelContentTreeIdsCache } from \"./internal/IModelContentTreeIdsCache.js\";\n\nimport type { ReactElement } from \"react\";\nimport type { IModelContentTreeHierarchyConfiguration } from \"./IModelContentTreeDefinition.js\";\nimport type { TreeProps } from \"../common/components/Tree.js\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\n\n/** @beta */\nexport type IModelContentTreeProps = Pick<TreeProps, \"imodel\" | \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"selectionMode\"> & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n hierarchyConfig?: Partial<IModelContentTreeHierarchyConfiguration>;\n};\n\n/** @beta */\nexport function IModelContentTree({ hierarchyConfig: hierarchyConfigProp, ...props }: IModelContentTreeProps) {\n const getHierarchyDefinition = useCallback<TreeProps[\"getHierarchyDefinition\"]>(\n ({ imodelAccess }) => {\n const hierarchyConfig = {\n ...defaultHierarchyConfiguration,\n ...hierarchyConfigProp,\n };\n return new IModelContentTreeDefinition({ imodelAccess, idsCache: new IModelContentTreeIdsCache(imodelAccess), hierarchyConfig });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n Object.values(hierarchyConfigProp ?? {}),\n );\n\n return (\n <Tree\n {...props}\n treeName={IModelContentTreeComponent.id}\n getHierarchyDefinition={getHierarchyDefinition}\n selectionMode={props.selectionMode ?? \"extended\"}\n treeRenderer={(treeProps) => <TreeRenderer {...treeProps} getIcon={getIcon} />}\n />\n );\n}\n\nfunction getIcon(node: PresentationHierarchyNode): ReactElement | undefined {\n if (node.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n switch (node.extendedData.imageId) {\n case \"icon-layers\":\n return <SvgLayers />;\n case \"icon-item\":\n return <SvgItem />;\n case \"icon-ec-class\":\n return <SvgItem />;\n case \"icon-imodel-hollow-2\":\n return <SvgImodelHollow />;\n case \"icon-folder\":\n return <SvgFolder />;\n case \"icon-model\":\n return <SvgModel />;\n case \"icon-hierarchy-tree\":\n return <SvgHierarchyTree />;\n case \"icon-group\":\n return <SvgGroup />;\n }\n\n return undefined;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { IModelContentTreeProps } from "./IModelContentTree.js";
|
|
3
3
|
/** @beta */
|
|
4
|
-
interface IModelContentTreeComponentProps extends Pick<IModelContentTreeProps, "getSchemaContext" | "selectionStorage" | "density" | "hierarchyLevelConfig" | "selectionMode"> {
|
|
4
|
+
interface IModelContentTreeComponentProps extends Pick<IModelContentTreeProps, "getSchemaContext" | "selectionStorage" | "density" | "hierarchyConfig" | "hierarchyLevelConfig" | "selectionMode"> {
|
|
5
5
|
onPerformanceMeasured?: (featureId: string, duration: number) => void;
|
|
6
6
|
onFeatureUsed?: (feature: string) => void;
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelContentTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAW3D;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,EAAE,aAAa,EAAE,qBAAqB,EAAE,GAAG,KAAK,EAAmC,EAAE,EAAE;IAChI,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAE3C,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,KAAC,wBAAwB,IAAC,mBAAmB,EAAE,0BAA0B,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YACtJ,KAAC,iBAAiB,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,GAAI,GACvB,CAC5B,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,0BAA0B,CAAC,EAAE,GAAG,wBAAwB,CAAC;AAEzD;;;GAGG;AACH,0BAA0B,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,yBAAyB,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 { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { IModelContentTree } from \"./IModelContentTree.js\";\n\nimport type { IModelContentTreeProps } from \"./IModelContentTree.js\";\n\n/** @beta */\ninterface IModelContentTreeComponentProps\n extends Pick<IModelContentTreeProps, \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"hierarchyLevelConfig\" | \"selectionMode\"> {\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `IModelContentTree`.\n * @beta\n */\nexport const IModelContentTreeComponent = ({ onFeatureUsed, onPerformanceMeasured, ...props }: IModelContentTreeComponentProps) => {\n const imodel = useActiveIModelConnection();\n\n if (!imodel) {\n return null;\n }\n\n return (\n <TelemetryContextProvider componentIdentifier={IModelContentTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <IModelContentTree {...props} imodel={imodel} />\n </TelemetryContextProvider>\n );\n};\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @beta\n */\nIModelContentTreeComponent.id = \"imodel-content-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @beta\n */\nIModelContentTreeComponent.getLabel = () => TreeWidget.translate(\"imodelContentTree.label\");\n"]}
|
|
1
|
+
{"version":3,"file":"IModelContentTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAW3D;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,EAAE,aAAa,EAAE,qBAAqB,EAAE,GAAG,KAAK,EAAmC,EAAE,EAAE;IAChI,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAE3C,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,KAAC,wBAAwB,IAAC,mBAAmB,EAAE,0BAA0B,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YACtJ,KAAC,iBAAiB,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,GAAI,GACvB,CAC5B,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,0BAA0B,CAAC,EAAE,GAAG,wBAAwB,CAAC;AAEzD;;;GAGG;AACH,0BAA0B,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,yBAAyB,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 { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { IModelContentTree } from \"./IModelContentTree.js\";\n\nimport type { IModelContentTreeProps } from \"./IModelContentTree.js\";\n\n/** @beta */\ninterface IModelContentTreeComponentProps\n extends Pick<IModelContentTreeProps, \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"hierarchyConfig\" | \"hierarchyLevelConfig\" | \"selectionMode\"> {\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `IModelContentTree`.\n * @beta\n */\nexport const IModelContentTreeComponent = ({ onFeatureUsed, onPerformanceMeasured, ...props }: IModelContentTreeComponentProps) => {\n const imodel = useActiveIModelConnection();\n\n if (!imodel) {\n return null;\n }\n\n return (\n <TelemetryContextProvider componentIdentifier={IModelContentTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <IModelContentTree {...props} imodel={imodel} />\n </TelemetryContextProvider>\n );\n};\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @beta\n */\nIModelContentTreeComponent.id = \"imodel-content-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @beta\n */\nIModelContentTreeComponent.getLabel = () => TreeWidget.translate(\"imodelContentTree.label\");\n"]}
|
|
@@ -2,19 +2,30 @@ import { ProcessedHierarchyNode } from "@itwin/presentation-hierarchies";
|
|
|
2
2
|
import type { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyLevelDefinition } from "@itwin/presentation-hierarchies";
|
|
3
3
|
import type { ECClassHierarchyInspector, ECSchemaProvider } from "@itwin/presentation-shared";
|
|
4
4
|
import type { IModelContentTreeIdsCache } from "./internal/IModelContentTreeIdsCache.js";
|
|
5
|
+
/**
|
|
6
|
+
* Defines hierarchy configuration supported by `IModelContentTree`.
|
|
7
|
+
* @beta
|
|
8
|
+
*/
|
|
9
|
+
export interface IModelContentTreeHierarchyConfiguration {
|
|
10
|
+
/** Should the root Subject node be hidden. Defaults to `false`. */
|
|
11
|
+
hideRootSubject: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** @internal */
|
|
14
|
+
export declare const defaultHierarchyConfiguration: IModelContentTreeHierarchyConfiguration;
|
|
5
15
|
interface IModelContentTreeDefinitionProps {
|
|
6
16
|
imodelAccess: ECSchemaProvider & ECClassHierarchyInspector;
|
|
7
17
|
idsCache: IModelContentTreeIdsCache;
|
|
18
|
+
hierarchyConfig: IModelContentTreeHierarchyConfiguration;
|
|
8
19
|
}
|
|
9
20
|
export declare class IModelContentTreeDefinition implements HierarchyDefinition {
|
|
10
21
|
private _impl;
|
|
11
22
|
private _idsCache;
|
|
23
|
+
private _hierarchyConfig;
|
|
12
24
|
private _selectQueryFactory;
|
|
13
25
|
private _nodeLabelSelectClauseFactory;
|
|
14
26
|
constructor(props: IModelContentTreeDefinitionProps);
|
|
15
27
|
postProcessNode(node: ProcessedHierarchyNode): Promise<ProcessedHierarchyNode>;
|
|
16
28
|
defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;
|
|
17
|
-
private createRootHierarchyLevelDefinition;
|
|
18
29
|
private createSubjectChildrenQuery;
|
|
19
30
|
private createISubModeledElementChildrenQuery;
|
|
20
31
|
private createGeometricModelChildrenQuery;
|
|
@@ -2,16 +2,22 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { IModel } from "@itwin/core-common";
|
|
5
6
|
import { createNodesQueryClauseFactory, createPredicateBasedHierarchyDefinition, NodeSelectClauseColumnNames, ProcessedHierarchyNode, } from "@itwin/presentation-hierarchies";
|
|
6
|
-
import { createBisInstanceLabelSelectClauseFactory
|
|
7
|
+
import { createBisInstanceLabelSelectClauseFactory } from "@itwin/presentation-shared";
|
|
7
8
|
import { createIdsSelector, parseIdsSelectorResult } from "../common/Utils.js";
|
|
9
|
+
/** @internal */
|
|
10
|
+
export const defaultHierarchyConfiguration = {
|
|
11
|
+
hideRootSubject: false,
|
|
12
|
+
};
|
|
8
13
|
export class IModelContentTreeDefinition {
|
|
9
14
|
constructor(props) {
|
|
10
15
|
this._idsCache = props.idsCache;
|
|
16
|
+
this._hierarchyConfig = props.hierarchyConfig;
|
|
11
17
|
this._impl = createPredicateBasedHierarchyDefinition({
|
|
12
18
|
classHierarchyInspector: props.imodelAccess,
|
|
13
19
|
hierarchy: {
|
|
14
|
-
rootNodes: async (requestProps) => this.
|
|
20
|
+
rootNodes: async (requestProps) => this.createSubjectChildrenQuery({ ...requestProps, parentNodeInstanceIds: this._hierarchyConfig.hideRootSubject ? [IModel.rootSubjectId] : [] }),
|
|
15
21
|
childNodes: [
|
|
16
22
|
{
|
|
17
23
|
parentInstancesNodePredicate: "BisCore.Subject",
|
|
@@ -78,43 +84,7 @@ export class IModelContentTreeDefinition {
|
|
|
78
84
|
async defineHierarchyLevel(props) {
|
|
79
85
|
return this._impl.defineHierarchyLevel(props);
|
|
80
86
|
}
|
|
81
|
-
async
|
|
82
|
-
const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({
|
|
83
|
-
filter: props.instanceFilter,
|
|
84
|
-
contentClass: { fullName: "BisCore.Subject", alias: "this" },
|
|
85
|
-
});
|
|
86
|
-
return [
|
|
87
|
-
{
|
|
88
|
-
fullClassName: "BisCore.Subject",
|
|
89
|
-
query: {
|
|
90
|
-
ecsql: `
|
|
91
|
-
SELECT
|
|
92
|
-
${await this._selectQueryFactory.createSelectClause({
|
|
93
|
-
ecClassId: { selector: ECSql.createRawPropertyValueSelector("this", "ECClassId") },
|
|
94
|
-
ecInstanceId: { selector: "this.ECInstanceId" },
|
|
95
|
-
nodeLabel: {
|
|
96
|
-
selector: await this._nodeLabelSelectClauseFactory.createSelectClause({
|
|
97
|
-
classAlias: "this",
|
|
98
|
-
className: "BisCore.Subject",
|
|
99
|
-
}),
|
|
100
|
-
},
|
|
101
|
-
extendedData: {
|
|
102
|
-
imageId: "icon-imodel-hollow-2",
|
|
103
|
-
},
|
|
104
|
-
autoExpand: true,
|
|
105
|
-
supportsFiltering: true,
|
|
106
|
-
})}
|
|
107
|
-
FROM ${instanceFilterClauses.from} this
|
|
108
|
-
${instanceFilterClauses.joins}
|
|
109
|
-
WHERE
|
|
110
|
-
this.Parent.Id IS NULL
|
|
111
|
-
${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : ""}
|
|
112
|
-
`,
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
];
|
|
116
|
-
}
|
|
117
|
-
async createSubjectChildrenQuery({ parentNodeInstanceIds: subjectIds, instanceFilter, }) {
|
|
87
|
+
async createSubjectChildrenQuery({ parentNodeInstanceIds: parentSubjectIds, instanceFilter, }) {
|
|
118
88
|
const [subjectFilterClauses, modelFilterClauses] = await Promise.all([
|
|
119
89
|
this._selectQueryFactory.createFilterClauses({
|
|
120
90
|
filter: instanceFilter,
|
|
@@ -125,10 +95,9 @@ export class IModelContentTreeDefinition {
|
|
|
125
95
|
contentClass: { fullName: "BisCore.Model", alias: "this" },
|
|
126
96
|
}),
|
|
127
97
|
]);
|
|
128
|
-
const [childSubjectIds, childModelIds] =
|
|
129
|
-
this._idsCache.getChildSubjectIds(
|
|
130
|
-
|
|
131
|
-
]);
|
|
98
|
+
const [childSubjectIds, childModelIds] = parentSubjectIds.length
|
|
99
|
+
? await Promise.all([this._idsCache.getChildSubjectIds(parentSubjectIds), this._idsCache.getChildSubjectModelIds(parentSubjectIds)])
|
|
100
|
+
: [[IModel.rootSubjectId], []];
|
|
132
101
|
const defs = new Array();
|
|
133
102
|
childSubjectIds.length &&
|
|
134
103
|
defs.push({
|
|
@@ -148,8 +117,9 @@ export class IModelContentTreeDefinition {
|
|
|
148
117
|
hasChildren: { selector: `InVirtualSet(?, this.ECInstanceId)` },
|
|
149
118
|
grouping: { byLabel: { action: "merge", groupId: "subject" } },
|
|
150
119
|
extendedData: {
|
|
151
|
-
imageId:
|
|
120
|
+
imageId: { selector: `IIF(this.ECInstanceId = ${IModel.rootSubjectId}, 'icon-imodel-hollow-2', 'icon-folder')` },
|
|
152
121
|
},
|
|
122
|
+
autoExpand: { selector: `IIF(this.ECInstanceId = ${IModel.rootSubjectId}, true, false)` },
|
|
153
123
|
supportsFiltering: true,
|
|
154
124
|
})}
|
|
155
125
|
FROM ${subjectFilterClauses.from} this
|