@itwin/tree-widget-react 3.0.0-dev.4 → 3.0.0-dev.6
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/README.md +27 -0
- package/lib/cjs/components/SelectableTree.js +1 -2
- package/lib/cjs/components/SelectableTree.js.map +1 -1
- package/lib/cjs/components/SelectableTree.scss +5 -0
- package/lib/cjs/components/tree-header/TreeHeader.d.ts +3 -2
- package/lib/cjs/components/tree-header/TreeHeader.js +1 -1
- package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js +2 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +2 -2
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.js +5 -4
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.js +2 -1
- package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/cjs/components/trees/common/FocusedInstancesContext.d.ts +1 -1
- package/lib/cjs/components/trees/common/FocusedInstancesContext.js.map +1 -1
- package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js +4 -4
- package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js.map +1 -1
- package/lib/cjs/components/trees/common/TreeErrors.d.ts +9 -0
- package/lib/cjs/components/trees/common/TreeErrors.js +19 -0
- package/lib/cjs/components/trees/common/TreeErrors.js.map +1 -0
- package/lib/cjs/components/trees/common/UseActiveViewport.d.ts +7 -0
- package/lib/cjs/components/trees/common/UseActiveViewport.js +25 -0
- package/lib/cjs/components/trees/common/UseActiveViewport.js.map +1 -0
- package/lib/cjs/components/trees/index.d.ts +1 -0
- package/lib/cjs/components/trees/index.js +3 -1
- package/lib/cjs/components/trees/index.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +6 -11
- package/lib/cjs/components/trees/models-tree/ModelsTree.js +2 -2
- package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +3 -2
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.d.ts +11 -6
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.js +63 -43
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/UseModelsTree.d.ts +11 -2
- package/lib/cjs/components/trees/models-tree/UseModelsTree.js +52 -31
- package/lib/cjs/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +4 -3
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/components/SelectableTree.js +2 -3
- package/lib/esm/components/SelectableTree.js.map +1 -1
- package/lib/esm/components/SelectableTree.scss +5 -0
- package/lib/esm/components/tree-header/TreeHeader.d.ts +3 -2
- package/lib/esm/components/tree-header/TreeHeader.js +1 -1
- package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js +2 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +2 -2
- package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.js +5 -4
- package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/UseCategoriesTree.js +2 -1
- package/lib/esm/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/esm/components/trees/common/FocusedInstancesContext.d.ts +1 -1
- package/lib/esm/components/trees/common/FocusedInstancesContext.js.map +1 -1
- package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js +4 -4
- package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js.map +1 -1
- package/lib/esm/components/trees/common/TreeErrors.d.ts +9 -0
- package/lib/esm/components/trees/common/TreeErrors.js +15 -0
- package/lib/esm/components/trees/common/TreeErrors.js.map +1 -0
- package/lib/esm/components/trees/common/UseActiveViewport.d.ts +7 -0
- package/lib/esm/components/trees/common/UseActiveViewport.js +21 -0
- package/lib/esm/components/trees/common/UseActiveViewport.js.map +1 -0
- package/lib/esm/components/trees/index.d.ts +1 -0
- package/lib/esm/components/trees/index.js +1 -0
- package/lib/esm/components/trees/index.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +6 -11
- package/lib/esm/components/trees/models-tree/ModelsTree.js +2 -2
- package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +3 -2
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.d.ts +11 -6
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.js +63 -43
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/esm/components/trees/models-tree/UseModelsTree.d.ts +11 -2
- package/lib/esm/components/trees/models-tree/UseModelsTree.js +52 -31
- package/lib/esm/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +4 -3
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/package.json +28 -28
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/categories-tree/CategoriesTreeComponent.tsx"],"names":[],"mappings":";;AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,yBAAyB,EAAE,
|
|
1
|
+
{"version":3,"file":"CategoriesTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/categories-tree/CategoriesTreeComponent.tsx"],"names":[],"mappings":";;AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AA2BtH;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAmC,EAAE,EAAE;IAC7E,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAC;IAErC,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE;QACxB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAC,2BAA2B,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAAC;AACxF,CAAC,CAAC;AAEF;;;GAGG;AACH,uBAAuB,CAAC,aAAa,GAAG,aAAa,CAAC;AAEtD;;;GAGG;AACH,uBAAuB,CAAC,aA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AAE,qBAAqB,EAAE,qBAAqB,YACnJ,KAAC,cAAc,IACb,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE;gBACd,aAAa,EAAE,WAAW;gBAC1B,aAAa,EAAE,WAAW;aAC3B,YAED,KAAC,cAAc,OAAK,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAI,GACxE,GACQ,CAC5B,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 { Fragment } from \"react\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeWithHeader } from \"../../tree-header/TreeWithHeader\";\nimport { useActiveViewport } from \"../common/UseActiveViewport\";\nimport { useFiltering } from \"../common/UseFiltering\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext\";\nimport { CategoriesTree } from \"./CategoriesTree\";\nimport { HideAllButton, InvertAllButton, ShowAllButton, useCategoriesTreeButtonProps } from \"./CategoriesTreeButtons\";\n\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { CategoriesTreeHeaderButtonProps } from \"./CategoriesTreeButtons\";\n\n/** @public */\ninterface CategoriesTreeComponentProps\n extends Pick<\n ComponentPropsWithoutRef<typeof CategoriesTree>,\n \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"hierarchyLevelConfig\" | \"selectionMode\"\n > {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * CategoriesTreeComponent.ShowAllButton,\n * CategoriesTreeComponent.HideAllButton,\n * CategoriesTreeComponent.InvertAllButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: CategoriesTreeHeaderButtonProps) => React.ReactNode>;\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `CategoriesTree` and a header with filtering capabilities and header buttons.\n * @public\n */\nexport const CategoriesTreeComponent = (props: CategoriesTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return <CategoriesTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />;\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all categories and their subcategories.\n * @public\n */\nCategoriesTreeComponent.ShowAllButton = ShowAllButton;\n\n/**\n * Renders a \"Hide all\" button that disables display of all categories.\n * @public\n */\nCategoriesTreeComponent.HideAllButton = HideAllButton;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all categories.\n * @public\n */\nCategoriesTreeComponent.InvertAllButton = InvertAllButton;\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nCategoriesTreeComponent.id = \"categories-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nCategoriesTreeComponent.getLabel = () => TreeWidget.translate(\"categoriesTree.label\");\n\nfunction CategoriesTreeComponentImpl({\n iModel,\n viewport,\n headerButtons,\n onPerformanceMeasured,\n onFeatureUsed,\n ...treeProps\n}: CategoriesTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const buttonProps = useCategoriesTreeButtonProps({ viewport });\n const { filter, applyFilter, clearFilter } = useFiltering();\n const density = treeProps.density;\n\n const buttons: ReactNode = headerButtons\n ? headerButtons.map((btn, index) => <Fragment key={index}>{btn({ ...buttonProps, onFeatureUsed })}</Fragment>)\n : [\n <ShowAllButton {...buttonProps} key=\"show-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <HideAllButton {...buttonProps} key=\"hide-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <InvertAllButton {...buttonProps} key=\"invert-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n ];\n\n return (\n <TelemetryContextProvider componentIdentifier={CategoriesTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <TreeWithHeader\n buttons={buttons}\n density={density}\n filteringProps={{\n onFilterStart: applyFilter,\n onFilterClear: clearFilter,\n }}\n >\n <CategoriesTree {...treeProps} imodel={iModel} activeView={viewport} filter={filter} />\n </TreeWithHeader>\n </TelemetryContextProvider>\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ECClassHierarchyInspector, ECSchemaProvider } from "@itwin/presentation-shared";
|
|
2
|
-
import type { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyLevelDefinition,
|
|
2
|
+
import type { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyLevelDefinition, LimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
|
|
3
3
|
interface CategoriesTreeDefinitionProps {
|
|
4
4
|
imodelAccess: ECSchemaProvider & ECClassHierarchyInspector;
|
|
5
5
|
viewType: "2d" | "3d";
|
|
@@ -17,7 +17,7 @@ export declare class CategoriesTreeDefinition implements HierarchyDefinition {
|
|
|
17
17
|
defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;
|
|
18
18
|
private createRootHierarchyLevelDefinition;
|
|
19
19
|
private createSubcategoryQuery;
|
|
20
|
-
static createInstanceKeyPaths(props: CategoriesTreeInstanceKeyPathsFromInstanceLabelProps): Promise<
|
|
20
|
+
static createInstanceKeyPaths(props: CategoriesTreeInstanceKeyPathsFromInstanceLabelProps): Promise<import("@itwin/presentation-hierarchies/lib/cjs/hierarchies/HierarchyProvider").HierarchyFilteringPath[]>;
|
|
21
21
|
}
|
|
22
22
|
export {};
|
|
23
23
|
//# sourceMappingURL=CategoriesTreeDefinition.d.ts.map
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { createClassBasedHierarchyDefinition, createNodesQueryClauseFactory } from "@itwin/presentation-hierarchies";
|
|
6
6
|
import { createBisInstanceLabelSelectClauseFactory, ECSql } from "@itwin/presentation-shared";
|
|
7
|
+
import { FilterLimitExceededError } from "../common/TreeErrors";
|
|
7
8
|
const MAX_FILTERING_INSTANCE_KEY_COUNT = 100;
|
|
8
9
|
export class CategoriesTreeDefinition {
|
|
9
10
|
constructor(props) {
|
|
@@ -167,14 +168,14 @@ async function createInstanceKeyPathsFromInstanceLabel(props) {
|
|
|
167
168
|
`,
|
|
168
169
|
bindings: [{ type: "string", value: props.label.replace(/[%_\\]/g, "\\$&") }],
|
|
169
170
|
}, { restartToken: "tree-widget/categories-tree/filter-by-label-query" });
|
|
170
|
-
const paths =
|
|
171
|
+
const paths = [];
|
|
171
172
|
for await (const row of reader) {
|
|
172
|
-
const path = [{ className: row.CategoryClass, id: row.CategoryId }];
|
|
173
|
-
row.SubcategoryId && path.push({ className: row.SubcategoryClass, id: row.SubcategoryId });
|
|
173
|
+
const path = { path: [{ className: row.CategoryClass, id: row.CategoryId }], options: { autoExpand: true } };
|
|
174
|
+
row.SubcategoryId && path.path.push({ className: row.SubcategoryClass, id: row.SubcategoryId });
|
|
174
175
|
paths.push(path);
|
|
175
176
|
}
|
|
176
177
|
if (paths.length > MAX_FILTERING_INSTANCE_KEY_COUNT) {
|
|
177
|
-
throw new
|
|
178
|
+
throw new FilterLimitExceededError(MAX_FILTERING_INSTANCE_KEY_COUNT);
|
|
178
179
|
}
|
|
179
180
|
return paths;
|
|
180
181
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesTreeDefinition.js","sourceRoot":"","sources":["../../../../../src/components/trees/categories-tree/CategoriesTreeDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,mCAAmC,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AACrH,OAAO,EAAE,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gC,EAAE;QACnD,MAAM,IAAI,KAAK,CAAC,4BAA4B,gCAAgC,QAAQ,CAAC,CAAC;KACvF;IACD,OAAO,KAAK,CAAC;AACf,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 { createClassBasedHierarchyDefinition, createNodesQueryClauseFactory } from \"@itwin/presentation-hierarchies\";\nimport { createBisInstanceLabelSelectClauseFactory, ECSql } from \"@itwin/presentation-shared\";\n\nimport type { ECClassHierarchyInspector, ECSchemaProvider, IInstanceLabelSelectClauseFactory } from \"@itwin/presentation-shared\";\nimport type {\n DefineHierarchyLevelProps,\n DefineInstanceNodeChildHierarchyLevelProps,\n DefineRootHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n HierarchyNodeIdentifiersPath,\n LimitingECSqlQueryExecutor,\n NodesQueryClauseFactory,\n} from \"@itwin/presentation-hierarchies\";\n\nconst MAX_FILTERING_INSTANCE_KEY_COUNT = 100;\n\ninterface CategoriesTreeDefinitionProps {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector;\n viewType: \"2d\" | \"3d\";\n}\n\ninterface CategoriesTreeInstanceKeyPathsFromInstanceLabelProps {\n imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n label: string;\n viewType: \"2d\" | \"3d\";\n}\n\nexport class CategoriesTreeDefinition implements HierarchyDefinition {\n private _impl: HierarchyDefinition;\n private _selectQueryFactory: NodesQueryClauseFactory;\n private _nodeLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n\n public constructor(props: CategoriesTreeDefinitionProps) {\n this._impl = createClassBasedHierarchyDefinition({\n classHierarchyInspector: props.imodelAccess,\n hierarchy: {\n rootNodes: async (requestProps) => this.createRootHierarchyLevelDefinition({ ...requestProps, viewType: props.viewType }),\n childNodes: [\n {\n parentNodeClassName: \"BisCore.Category\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createSubcategoryQuery(requestProps),\n },\n ],\n },\n });\n this._selectQueryFactory = createNodesQueryClauseFactory({ imodelAccess: props.imodelAccess });\n this._nodeLabelSelectClauseFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps) {\n return this._impl.defineHierarchyLevel(props);\n }\n\n private async createRootHierarchyLevelDefinition(props: DefineRootHierarchyLevelProps & { viewType: \"2d\" | \"3d\" }): Promise<HierarchyLevelDefinition> {\n const { categoryClass, categoryElementClass } = getClassesByView(props.viewType);\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: props.instanceFilter,\n contentClass: { fullName: categoryClass, alias: \"this\" },\n });\n return [\n {\n fullClassName: categoryClass,\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: ECSql.createRawPropertyValueSelector(\"this\", \"ECClassId\") },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: categoryClass,\n }),\n },\n hasChildren: {\n selector: `\n IFNULL((\n SELECT 1\n FROM (\n SELECT COUNT(1) AS ChildCount\n FROM BisCore.SubCategory sc\n WHERE sc.Parent.Id = this.ECInstanceId\n )\n WHERE ChildCount > 1\n ), 0)\n `,\n },\n extendedData: {\n description: { selector: \"this.Description\" },\n },\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n JOIN BisCore.Model m ON m.ECInstanceId = this.Model.Id\n WHERE\n NOT this.IsPrivate\n AND (NOT m.IsPrivate OR m.ECClassId IS (BisCore.DictionaryModel))\n AND EXISTS (SELECT 1 FROM ${categoryElementClass} e WHERE e.Category.Id = this.ECInstanceId)\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n },\n ];\n }\n\n private async createSubcategoryQuery({\n parentNodeInstanceIds: elementIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.SubCategory\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.SubCategory\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.SubCategory\",\n }),\n },\n extendedData: {\n categoryId: { selector: \"printf('0x%x', this.Parent.Id)\" },\n },\n supportsFiltering: false,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n NOT this.IsPrivate AND this.Parent.Id IN (${elementIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: elementIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n }\n\n public static async createInstanceKeyPaths(props: CategoriesTreeInstanceKeyPathsFromInstanceLabelProps) {\n const labelsFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });\n return createInstanceKeyPathsFromInstanceLabel({ ...props, labelsFactory });\n }\n}\n\nfunction getClassesByView(viewType: \"2d\" | \"3d\") {\n return viewType === \"2d\"\n ? { categoryClass: \"BisCore.DrawingCategory\", categoryElementClass: \"BisCore:GeometricElement2d\" }\n : { categoryClass: \"BisCore.SpatialCategory\", categoryElementClass: \"BisCore:GeometricElement3d\" };\n}\n\nasync function createInstanceKeyPathsFromInstanceLabel(\n props: CategoriesTreeInstanceKeyPathsFromInstanceLabelProps & { labelsFactory: IInstanceLabelSelectClauseFactory },\n) {\n const { categoryClass, categoryElementClass } = getClassesByView(props.viewType);\n const reader = props.imodelAccess.createQueryReader(\n {\n ctes: [\n `RootCategories(ClassName, ECInstanceId, ChildCount) as (\n SELECT\n ec_classname(this.ECClassId, 's.c'),\n this.ECInstanceId,\n COUNT(sc.ECInstanceId)\n FROM ${categoryClass} this\n JOIN BisCore.Model m ON m.ECInstanceId = this.Model.Id\n JOIN BisCore.SubCategory sc ON sc.Parent.Id = this.ECInstanceId\n WHERE\n NOT this.IsPrivate\n AND (NOT m.IsPrivate OR m.ECClassId IS (BisCore.DictionaryModel))\n AND EXISTS (SELECT 1 FROM ${categoryElementClass} e WHERE e.Category.Id = this.ECInstanceId)\n GROUP BY this.ECInstanceId\n )`,\n `SubCategoriesWithLabels(ClassName, ECInstanceId, ParentId, DisplayLabel) as (\n SELECT\n ec_classname(this.ECClassId, 's.c'),\n this.ECInstanceId,\n this.Parent.Id,\n ${await props.labelsFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.SubCategory\",\n })}\n FROM BisCore.SubCategory this\n WHERE NOT this.IsPrivate\n )`,\n ],\n ecsql: `\n SELECT\n c.ClassName AS CategoryClass,\n c.ECInstanceId AS CategoryId,\n IIF(c.ChildCount > 1, sc.ClassName, NULL) AS SubcategoryClass,\n IIF(c.ChildCount > 1, sc.ECInstanceId, NULL) AS SubcategoryId\n FROM RootCategories c\n JOIN SubCategoriesWithLabels sc ON sc.ParentId = c.ECInstanceId\n WHERE sc.DisplayLabel LIKE '%' || ? || '%' ESCAPE '\\\\'\n LIMIT ${MAX_FILTERING_INSTANCE_KEY_COUNT + 1}\n `,\n bindings: [{ type: \"string\", value: props.label.replace(/[%_\\\\]/g, \"\\\\$&\") }],\n },\n { restartToken: \"tree-widget/categories-tree/filter-by-label-query\" },\n );\n const paths = new Array<HierarchyNodeIdentifiersPath>();\n for await (const row of reader) {\n const path = [{ className: row.CategoryClass, id: row.CategoryId }];\n row.SubcategoryId && path.push({ className: row.SubcategoryClass, id: row.SubcategoryId });\n paths.push(path);\n }\n if (paths.length > MAX_FILTERING_INSTANCE_KEY_COUNT) {\n throw new Error(`Filter matches more than ${MAX_FILTERING_INSTANCE_KEY_COUNT} items`);\n }\n return paths;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CategoriesTreeDefinition.js","sourceRoot":"","sources":["../../../../../src/components/trees/categories-tree/CategoriesTreeDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,mCAAmC,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AACrH,OAAO,EAAE,yCAAyC,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAchE,MAAM,gCAAgC,GAAG,GAAG,CAAC;AAgB7C,MAAM,OAAO,wBAAwB;IAKnC,YAAmB,KAAoC;QACrD,IAAI,CAAC,KAAK,GAAG,mCAAmC,CAAC;YAC/C,uBAAuB,EAAE,KAAK,CAAC,YAAY;YAC3C,SAAS,EAAE;gBACT,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,CAAC,IAAI,CAAC,kCAAkC,CAAC,EAAE,GAAG,YAAY,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;gBACzH,UAAU,EAAE;oBACV;wBACE,mBAAmB,EAAE,kBAAkB;wBACvC,WAAW,EAAE,KAAK,EAAE,YAAwD,EAAE,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,YAAY,CAAC;qBAC3H;iBACF;aACF;SACF,CAAC,CAAC;QACH,IAAI,CAAC,mBAAmB,GAAG,6BAA6B,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC;QAC/F,IAAI,CAAC,6BAA6B,GAAG,yCAAyC,CAAC,EAAE,uBAAuB,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC;IAClI,CAAC;IAEM,KAAK,CAAC,oBAAoB,C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AK,EAAE,MAAM,GAAG,IAAI,MAAM,EAAE;QAC9B,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,aAAa,EAAE,EAAE,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC;QAC7G,GAAG,CAAC,aAAa,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,gBAAgB,EAAE,EAAE,EAAE,GAAG,CAAC,aAAa,EAAE,CAAC,CAAC;QAChG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KAClB;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,gCAAgC,EAAE;QACnD,MAAM,IAAI,wBAAwB,CAAC,gCAAgC,CAAC,CAAC;KACtE;IACD,OAAO,KAAK,CAAC;AACf,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 { createClassBasedHierarchyDefinition, createNodesQueryClauseFactory } from \"@itwin/presentation-hierarchies\";\nimport { createBisInstanceLabelSelectClauseFactory, ECSql } from \"@itwin/presentation-shared\";\nimport { FilterLimitExceededError } from \"../common/TreeErrors\";\n\nimport type { ECClassHierarchyInspector, ECSchemaProvider, IInstanceLabelSelectClauseFactory } from \"@itwin/presentation-shared\";\nimport type {\n createHierarchyProvider,\n DefineHierarchyLevelProps,\n DefineInstanceNodeChildHierarchyLevelProps,\n DefineRootHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n LimitingECSqlQueryExecutor,\n NodesQueryClauseFactory,\n} from \"@itwin/presentation-hierarchies\";\n\nconst MAX_FILTERING_INSTANCE_KEY_COUNT = 100;\n\ntype HierarchyProviderProps = Parameters<typeof createHierarchyProvider>[0];\ntype HierarchyFilteringPaths = NonNullable<NonNullable<HierarchyProviderProps[\"filtering\"]>[\"paths\"]>;\n\ninterface CategoriesTreeDefinitionProps {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector;\n viewType: \"2d\" | \"3d\";\n}\n\ninterface CategoriesTreeInstanceKeyPathsFromInstanceLabelProps {\n imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n label: string;\n viewType: \"2d\" | \"3d\";\n}\n\nexport class CategoriesTreeDefinition implements HierarchyDefinition {\n private _impl: HierarchyDefinition;\n private _selectQueryFactory: NodesQueryClauseFactory;\n private _nodeLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n\n public constructor(props: CategoriesTreeDefinitionProps) {\n this._impl = createClassBasedHierarchyDefinition({\n classHierarchyInspector: props.imodelAccess,\n hierarchy: {\n rootNodes: async (requestProps) => this.createRootHierarchyLevelDefinition({ ...requestProps, viewType: props.viewType }),\n childNodes: [\n {\n parentNodeClassName: \"BisCore.Category\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createSubcategoryQuery(requestProps),\n },\n ],\n },\n });\n this._selectQueryFactory = createNodesQueryClauseFactory({ imodelAccess: props.imodelAccess });\n this._nodeLabelSelectClauseFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps) {\n return this._impl.defineHierarchyLevel(props);\n }\n\n private async createRootHierarchyLevelDefinition(props: DefineRootHierarchyLevelProps & { viewType: \"2d\" | \"3d\" }): Promise<HierarchyLevelDefinition> {\n const { categoryClass, categoryElementClass } = getClassesByView(props.viewType);\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: props.instanceFilter,\n contentClass: { fullName: categoryClass, alias: \"this\" },\n });\n return [\n {\n fullClassName: categoryClass,\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: ECSql.createRawPropertyValueSelector(\"this\", \"ECClassId\") },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: categoryClass,\n }),\n },\n hasChildren: {\n selector: `\n IFNULL((\n SELECT 1\n FROM (\n SELECT COUNT(1) AS ChildCount\n FROM BisCore.SubCategory sc\n WHERE sc.Parent.Id = this.ECInstanceId\n )\n WHERE ChildCount > 1\n ), 0)\n `,\n },\n extendedData: {\n description: { selector: \"this.Description\" },\n },\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n JOIN BisCore.Model m ON m.ECInstanceId = this.Model.Id\n WHERE\n NOT this.IsPrivate\n AND (NOT m.IsPrivate OR m.ECClassId IS (BisCore.DictionaryModel))\n AND EXISTS (SELECT 1 FROM ${categoryElementClass} e WHERE e.Category.Id = this.ECInstanceId)\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n },\n ];\n }\n\n private async createSubcategoryQuery({\n parentNodeInstanceIds: elementIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.SubCategory\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.SubCategory\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.SubCategory\",\n }),\n },\n extendedData: {\n categoryId: { selector: \"printf('0x%x', this.Parent.Id)\" },\n },\n supportsFiltering: false,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n NOT this.IsPrivate AND this.Parent.Id IN (${elementIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: elementIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n }\n\n public static async createInstanceKeyPaths(props: CategoriesTreeInstanceKeyPathsFromInstanceLabelProps) {\n const labelsFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });\n return createInstanceKeyPathsFromInstanceLabel({ ...props, labelsFactory });\n }\n}\n\nfunction getClassesByView(viewType: \"2d\" | \"3d\") {\n return viewType === \"2d\"\n ? { categoryClass: \"BisCore.DrawingCategory\", categoryElementClass: \"BisCore:GeometricElement2d\" }\n : { categoryClass: \"BisCore.SpatialCategory\", categoryElementClass: \"BisCore:GeometricElement3d\" };\n}\n\nasync function createInstanceKeyPathsFromInstanceLabel(\n props: CategoriesTreeInstanceKeyPathsFromInstanceLabelProps & { labelsFactory: IInstanceLabelSelectClauseFactory },\n) {\n const { categoryClass, categoryElementClass } = getClassesByView(props.viewType);\n const reader = props.imodelAccess.createQueryReader(\n {\n ctes: [\n `RootCategories(ClassName, ECInstanceId, ChildCount) as (\n SELECT\n ec_classname(this.ECClassId, 's.c'),\n this.ECInstanceId,\n COUNT(sc.ECInstanceId)\n FROM ${categoryClass} this\n JOIN BisCore.Model m ON m.ECInstanceId = this.Model.Id\n JOIN BisCore.SubCategory sc ON sc.Parent.Id = this.ECInstanceId\n WHERE\n NOT this.IsPrivate\n AND (NOT m.IsPrivate OR m.ECClassId IS (BisCore.DictionaryModel))\n AND EXISTS (SELECT 1 FROM ${categoryElementClass} e WHERE e.Category.Id = this.ECInstanceId)\n GROUP BY this.ECInstanceId\n )`,\n `SubCategoriesWithLabels(ClassName, ECInstanceId, ParentId, DisplayLabel) as (\n SELECT\n ec_classname(this.ECClassId, 's.c'),\n this.ECInstanceId,\n this.Parent.Id,\n ${await props.labelsFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.SubCategory\",\n })}\n FROM BisCore.SubCategory this\n WHERE NOT this.IsPrivate\n )`,\n ],\n ecsql: `\n SELECT\n c.ClassName AS CategoryClass,\n c.ECInstanceId AS CategoryId,\n IIF(c.ChildCount > 1, sc.ClassName, NULL) AS SubcategoryClass,\n IIF(c.ChildCount > 1, sc.ECInstanceId, NULL) AS SubcategoryId\n FROM RootCategories c\n JOIN SubCategoriesWithLabels sc ON sc.ParentId = c.ECInstanceId\n WHERE sc.DisplayLabel LIKE '%' || ? || '%' ESCAPE '\\\\'\n LIMIT ${MAX_FILTERING_INSTANCE_KEY_COUNT + 1}\n `,\n bindings: [{ type: \"string\", value: props.label.replace(/[%_\\\\]/g, \"\\\\$&\") }],\n },\n { restartToken: \"tree-widget/categories-tree/filter-by-label-query\" },\n );\n const paths: HierarchyFilteringPaths = [];\n for await (const row of reader) {\n const path = { path: [{ className: row.CategoryClass, id: row.CategoryId }], options: { autoExpand: true } };\n row.SubcategoryId && path.path.push({ className: row.SubcategoryClass, id: row.SubcategoryId });\n paths.push(path);\n }\n if (paths.length > MAX_FILTERING_INSTANCE_KEY_COUNT) {\n throw new FilterLimitExceededError(MAX_FILTERING_INSTANCE_KEY_COUNT);\n }\n return paths;\n}\n"]}
|
|
@@ -7,6 +7,7 @@ import { useCallback, useMemo, useState } from "react";
|
|
|
7
7
|
import { SvgLayers } from "@itwin/itwinui-icons-react";
|
|
8
8
|
import { Text } from "@itwin/itwinui-react";
|
|
9
9
|
import { TreeWidget } from "../../../TreeWidget";
|
|
10
|
+
import { FilterLimitExceededError } from "../common/TreeErrors";
|
|
10
11
|
import { useTelemetryContext } from "../common/UseTelemetryContext";
|
|
11
12
|
import { CategoriesTreeDefinition } from "./CategoriesTreeDefinition";
|
|
12
13
|
import { CategoriesVisibilityHandler } from "./CategoriesVisibilityHandler";
|
|
@@ -42,7 +43,7 @@ export function useCategoriesTree({ filter, activeView }) {
|
|
|
42
43
|
return await CategoriesTreeDefinition.createInstanceKeyPaths({ imodelAccess, label: filter, viewType: activeView.view.is2d() ? "2d" : "3d" });
|
|
43
44
|
}
|
|
44
45
|
catch (e) {
|
|
45
|
-
const newError = e instanceof
|
|
46
|
+
const newError = e instanceof FilterLimitExceededError ? "tooManyFilterMatches" : "unknownFilterError";
|
|
46
47
|
if (newError !== "tooManyFilterMatches") {
|
|
47
48
|
const feature = e instanceof Error && e.message.includes("query too long to execute or server is too busy") ? "error-timeout" : "error-unknown";
|
|
48
49
|
onFeatureUsed({ featureId: feature, reportInteraction: false });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseCategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/categories-tree/UseCategoriesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAgC5E;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAA0B;IAC9E,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,EAA4C,CAAC;IACjG,MAAM,wBAAwB,GAAG,WAAW,CAAC,GAAG,EAAE;QAChD,MAAM,iBAAiB,GAAG,IAAI,2BAA2B,CAAC;YACxD,QAAQ,EAAE,UAAU;SACrB,CAAC,CAAC;QACH,OAAO;YACL,mBAAmB,EAAE,KAAK,EAAE,IAAmB,EAAE,EAAE,CAAC,iBAAiB,CAAC,mBAAmB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|
+
{"version":3,"file":"UseCategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/categories-tree/UseCategoriesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAgC5E;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAA0B;IAC9E,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,EAA4C,CAAC;IACjG,MAAM,wBAAwB,GAAG,WAAW,CAAC,GAAG,EAAE;QAChD,MAAM,iBAAiB,GAAG,IAAI,2BAA2B,CAAC;YACxD,QAAQ,EAAE,UAAU;SACrB,CAAC,CAAC;QACH,OAAO;YACL,mBAAmB,EAAE,KAAK,EAAE,IAAmB,EAAE,EAAE,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAC/F,gBAAgB,EAAE,KAAK,EAAE,IAAmB,EAAE,EAAW,EAAE,EAAE,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC;YAC1G,kBAAkB,EAAE,iBAAiB,CAAC,kBAAkB;YACxD,OAAO,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,OAAO,EAAE;SAC3C,CAAC;IACJ,CAAC,EAAE,CAAC,UAAU,C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AAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,CAAC;iBACjE;gBACD,iBAAiB,CAAC,QAAQ,CAAC,CAAC;gBAC5B,OAAO,EAAE,CAAC;aACX;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;IAExC,OAAO;QACL,mBAAmB,EAAE;YACnB,QAAQ,EAAE,oBAAoB;YAC9B,sBAAsB;YACtB,gBAAgB;YAChB,wBAAwB;YACxB,aAAa,EAAE,gBAAgB,CAAC,MAAM,EAAE,cAAc,CAAC;YACvD,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS;SACjD;QACD,aAAa,EAAE;YACb,OAAO;YACP,WAAW;SACZ;KACF,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAc,EAAE,KAAoC;IAC5E,IAAI,KAAK,EAAE;QACT,OAAO,KAAC,IAAI,cAAE,UAAU,CAAC,SAAS,CAAC,4BAA4B,KAAK,EAAE,CAAC,GAAQ,CAAC;KACjF;IACD,IAAI,MAAM,EAAE;QACV,OAAO,KAAC,IAAI,cAAE,UAAU,CAAC,SAAS,CAAC,oCAAoC,EAAE,EAAE,MAAM,EAAE,CAAC,GAAQ,CAAC;KAC9F;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,OAAO;IACd,OAAO,KAAC,SAAS,KAAG,CAAC;AACvB,CAAC;AAED,SAAS,WAAW,CAAC,IAA+B;IAClD,OAAO,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC;AACxC,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 { SvgLayers } from \"@itwin/itwinui-icons-react\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { FilterLimitExceededError } from \"../common/TreeErrors\";\nimport { useTelemetryContext } from \"../common/UseTelemetryContext\";\nimport { CategoriesTreeDefinition } from \"./CategoriesTreeDefinition\";\nimport { CategoriesVisibilityHandler } from \"./CategoriesVisibilityHandler\";\n\nimport type { VisibilityTree } from \"../common/components/VisibilityTree\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer\";\n\ntype CategoriesTreeFilteringError = \"tooManyFilterMatches\" | \"unknownFilterError\";\n\n/** @beta */\ntype VisibilityTreeRendererProps = ComponentPropsWithoutRef<typeof VisibilityTreeRenderer>;\n\n/** @beta */\ntype VisibilityTreeProps = ComponentPropsWithoutRef<typeof VisibilityTree>;\n\n/** @beta */\ninterface UseCategoriesTreeProps {\n filter: string;\n activeView: Viewport;\n}\n\n/** @beta */\ninterface UseCategoriesTreeResult {\n categoriesTreeProps: Pick<\n VisibilityTreeProps,\n \"treeName\" | \"getHierarchyDefinition\" | \"getFilteredPaths\" | \"visibilityHandlerFactory\" | \"highlight\" | \"noDataMessage\"\n >;\n rendererProps: Pick<Required<VisibilityTreeRendererProps>, \"getIcon\" | \"getSublabel\">;\n}\n\n/**\n * Custom hook to create and manage state for the categories tree.\n * @beta\n */\nexport function useCategoriesTree({ filter, activeView }: UseCategoriesTreeProps): UseCategoriesTreeResult {\n const [filteringError, setFilteringError] = useState<CategoriesTreeFilteringError | undefined>();\n const visibilityHandlerFactory = useCallback(() => {\n const visibilityHandler = new CategoriesVisibilityHandler({\n viewport: activeView,\n });\n return {\n getVisibilityStatus: async (node: HierarchyNode) => visibilityHandler.getVisibilityStatus(node),\n changeVisibility: async (node: HierarchyNode, on: boolean) => visibilityHandler.changeVisibility(node, on),\n onVisibilityChange: visibilityHandler.onVisibilityChange,\n dispose: () => visibilityHandler.dispose(),\n };\n }, [activeView]);\n const { onFeatureUsed } = useTelemetryContext();\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n (props) => {\n return new CategoriesTreeDefinition({ ...props, viewType: activeView.view.is2d() ? \"2d\" : \"3d\" });\n },\n [activeView],\n );\n\n const getFilteredPaths = useMemo<VisibilityTreeProps[\"getFilteredPaths\"] | undefined>(() => {\n setFilteringError(undefined);\n if (!filter) {\n return undefined;\n }\n return async ({ imodelAccess }) => {\n onFeatureUsed({ featureId: \"filtering\", reportInteraction: true });\n try {\n return await CategoriesTreeDefinition.createInstanceKeyPaths({ imodelAccess, label: filter, viewType: activeView.view.is2d() ? \"2d\" : \"3d\" });\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }, [filter, activeView, onFeatureUsed]);\n\n return {\n categoriesTreeProps: {\n treeName: \"categories-tree-v2\",\n getHierarchyDefinition,\n getFilteredPaths,\n visibilityHandlerFactory,\n noDataMessage: getNoDataMessage(filter, filteringError),\n highlight: filter ? { text: filter } : undefined,\n },\n rendererProps: {\n getIcon,\n getSublabel,\n },\n };\n}\n\nfunction getNoDataMessage(filter: string, error?: CategoriesTreeFilteringError) {\n if (error) {\n return <Text>{TreeWidget.translate(`categoriesTree.filtering.${error}`)}</Text>;\n }\n if (filter) {\n return <Text>{TreeWidget.translate(\"categoriesTree.filtering.noMatches\", { filter })}</Text>;\n }\n return undefined;\n}\n\nfunction getIcon() {\n return <SvgLayers />;\n}\n\nfunction getSublabel(node: PresentationHierarchyNode) {\n return node.extendedData?.description;\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { InstanceKey } from "@itwin/presentation-shared";
|
|
3
3
|
import type { GroupingHierarchyNode } from "@itwin/presentation-hierarchies";
|
|
4
4
|
export interface FocusedInstancesContext {
|
|
5
|
-
|
|
5
|
+
loadFocusedItems?: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>;
|
|
6
6
|
enabled: boolean;
|
|
7
7
|
toggle: () => void;
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FocusedInstancesContext.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/FocusedInstancesContext.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAWlD,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAA0B,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAC;AAEpH,MAAM,UAAU,0BAA0B;IACxC,OAAO,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { createContext, useContext } from \"react\";\n\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { GroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\nexport interface FocusedInstancesContext {\n
|
|
1
|
+
{"version":3,"file":"FocusedInstancesContext.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/FocusedInstancesContext.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAWlD,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAA0B,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAC;AAEpH,MAAM,UAAU,0BAA0B;IACxC,OAAO,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { createContext, useContext } from \"react\";\n\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { GroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\nexport interface FocusedInstancesContext {\n loadFocusedItems?: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>;\n enabled: boolean;\n toggle: () => void;\n}\n\nexport const focusedInstancesContext = createContext<FocusedInstancesContext>({ enabled: false, toggle: () => {} });\n\nexport function useFocusedInstancesContext() {\n return useContext(focusedInstancesContext);\n}\n"]}
|
|
@@ -17,13 +17,13 @@ export function FocusedInstancesContextProvider({ selectionStorage, imodelKey, c
|
|
|
17
17
|
const enabled = state.enabled;
|
|
18
18
|
useEffect(() => {
|
|
19
19
|
if (!enabled) {
|
|
20
|
-
setState((prev) => ({ ...prev,
|
|
20
|
+
setState((prev) => ({ ...prev, loadFocusedItems: undefined }));
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
const onSelectionChanged = () => {
|
|
24
24
|
const selection = selectionStorage.getSelection({ imodelKey, level: 0 });
|
|
25
25
|
if (Selectables.isEmpty(selection)) {
|
|
26
|
-
setState((prev) => ({ ...prev,
|
|
26
|
+
setState((prev) => ({ ...prev, loadFocusedItems: undefined }));
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
const selected = [];
|
|
@@ -38,7 +38,7 @@ export function FocusedInstancesContextProvider({ selectionStorage, imodelKey, c
|
|
|
38
38
|
}
|
|
39
39
|
selected.push(selectable.loadInstanceKeys);
|
|
40
40
|
});
|
|
41
|
-
const
|
|
41
|
+
const loadFocusedItems = async function* () {
|
|
42
42
|
for (const item of selected) {
|
|
43
43
|
if (typeof item === "function") {
|
|
44
44
|
yield* item();
|
|
@@ -48,7 +48,7 @@ export function FocusedInstancesContextProvider({ selectionStorage, imodelKey, c
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
setState((prev) => ({ ...prev,
|
|
51
|
+
setState((prev) => ({ ...prev, loadFocusedItems }));
|
|
52
52
|
};
|
|
53
53
|
onSelectionChanged();
|
|
54
54
|
return selectionStorage.selectionChangeEvent.addListener(({ imodelKey: changeImodelKey, level }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FocusedInstancesContextProvider.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/FocusedInstancesContextProvider.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAQpE,MAAM,UAAU,+BAA+B,CAAC,EAC9C,gBAAgB,EAChB,SAAS,EACT,QAAQ,GACqE;IAC7E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAA0B;QAC1D,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,GAAG,EAAE;YACX,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC5D,CAAC;KACF,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAE9B,SAAS,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AM;wBACL,MAAM,IAAI,CAAC;qBACZ;iBACF;YACH,CAAC,CAAC;YAEF,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC;QACtD,CAAC,CAAC;QAEF,kBAAkB,EAAE,CAAC;QACrB,OAAO,gBAAgB,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,EAAE;YACjG,IAAI,eAAe,KAAK,SAAS,IAAI,KAAK,KAAK,CAAC,EAAE;gBAChD,OAAO;aACR;YACD,kBAAkB,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAE3C,OAAO,KAAC,uBAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAoC,CAAC;AACvG,CAAC;AAED,SAAS,eAAe,CAAC,IAAa;IACpC,OAAO,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,CAAC;AAC7D,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, useState } from \"react\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport { Selectable, Selectables } from \"@itwin/unified-selection\";\nimport { focusedInstancesContext } from \"./FocusedInstancesContext\";\n\nimport type { SelectionStorage } from \"@itwin/presentation-hierarchies-react\";\nimport type { PropsWithChildren } from \"react\";\nimport type { InstanceKey } from \"@itwin/presentation-common\";\nimport type { FocusedInstancesContext } from \"./FocusedInstancesContext\";\nimport type { GroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\nexport function FocusedInstancesContextProvider({\n selectionStorage,\n imodelKey,\n children,\n}: PropsWithChildren<{ selectionStorage: SelectionStorage; imodelKey: string }>) {\n const [state, setState] = useState<FocusedInstancesContext>({\n enabled: false,\n toggle: () => {\n setState((prev) => ({ ...prev, enabled: !prev.enabled }));\n },\n });\n const enabled = state.enabled;\n\n useEffect(() => {\n if (!enabled) {\n setState((prev) => ({ ...prev,
|
|
1
|
+
{"version":3,"file":"FocusedInstancesContextProvider.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/FocusedInstancesContextProvider.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAQpE,MAAM,UAAU,+BAA+B,CAAC,EAC9C,gBAAgB,EAChB,SAAS,EACT,QAAQ,GACqE;IAC7E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAA0B;QAC1D,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,GAAG,EAAE;YACX,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC5D,CAAC;KACF,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAE9B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO,EAAE;YACZ,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;YAC/D,OAAO;SACR;QAED,MAAM,kB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EAAE,CAAC;QACrB,OAAO,gBAAgB,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,EAAE;YACjG,IAAI,eAAe,KAAK,SAAS,IAAI,KAAK,KAAK,CAAC,EAAE;gBAChD,OAAO;aACR;YACD,kBAAkB,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAE3C,OAAO,KAAC,uBAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAoC,CAAC;AACvG,CAAC;AAED,SAAS,eAAe,CAAC,IAAa;IACpC,OAAO,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,CAAC;AAC7D,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, useState } from \"react\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport { Selectable, Selectables } from \"@itwin/unified-selection\";\nimport { focusedInstancesContext } from \"./FocusedInstancesContext\";\n\nimport type { SelectionStorage } from \"@itwin/presentation-hierarchies-react\";\nimport type { PropsWithChildren } from \"react\";\nimport type { InstanceKey } from \"@itwin/presentation-common\";\nimport type { FocusedInstancesContext } from \"./FocusedInstancesContext\";\nimport type { GroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\nexport function FocusedInstancesContextProvider({\n selectionStorage,\n imodelKey,\n children,\n}: PropsWithChildren<{ selectionStorage: SelectionStorage; imodelKey: string }>) {\n const [state, setState] = useState<FocusedInstancesContext>({\n enabled: false,\n toggle: () => {\n setState((prev) => ({ ...prev, enabled: !prev.enabled }));\n },\n });\n const enabled = state.enabled;\n\n useEffect(() => {\n if (!enabled) {\n setState((prev) => ({ ...prev, loadFocusedItems: undefined }));\n return;\n }\n\n const onSelectionChanged = () => {\n const selection = selectionStorage.getSelection({ imodelKey, level: 0 });\n if (Selectables.isEmpty(selection)) {\n setState((prev) => ({ ...prev, loadFocusedItems: undefined }));\n return;\n }\n\n const selected: Array<InstanceKey | GroupingHierarchyNode | (() => AsyncIterableIterator<InstanceKey>)> = [];\n Selectables.forEach(selection, (selectable) => {\n if (Selectable.isInstanceKey(selectable)) {\n selected.push(selectable);\n return;\n }\n\n if (isHierarchyNode(selectable.data) && HierarchyNode.isGroupingNode(selectable.data)) {\n selected.push(selectable.data);\n return;\n }\n\n selected.push(selectable.loadInstanceKeys);\n });\n\n const loadFocusedItems: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode> = async function* () {\n for (const item of selected) {\n if (typeof item === \"function\") {\n yield* item();\n } else {\n yield item;\n }\n }\n };\n\n setState((prev) => ({ ...prev, loadFocusedItems }));\n };\n\n onSelectionChanged();\n return selectionStorage.selectionChangeEvent.addListener(({ imodelKey: changeImodelKey, level }) => {\n if (changeImodelKey !== imodelKey || level !== 0) {\n return;\n }\n onSelectionChanged();\n });\n }, [enabled, imodelKey, selectionStorage]);\n\n return <focusedInstancesContext.Provider value={state}>{children}</focusedInstancesContext.Provider>;\n}\n\nfunction isHierarchyNode(data: unknown): data is HierarchyNode {\n return !!data && typeof data === \"object\" && \"key\" in data;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error that is thrown when too many matches are found while filtering the tree.
|
|
3
|
+
* @beta
|
|
4
|
+
*/
|
|
5
|
+
export declare class FilterLimitExceededError extends Error {
|
|
6
|
+
readonly limit: number;
|
|
7
|
+
constructor(limit: number);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=TreeErrors.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* Error that is thrown when too many matches are found while filtering the tree.
|
|
7
|
+
* @beta
|
|
8
|
+
*/
|
|
9
|
+
export class FilterLimitExceededError extends Error {
|
|
10
|
+
constructor(limit) {
|
|
11
|
+
super("Too many filter matches");
|
|
12
|
+
this.limit = limit;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=TreeErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeErrors.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/TreeErrors.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG;;;GAGG;AACH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD,YAAmC,KAAa;QAC9C,KAAK,CAAC,yBAAyB,CAAC,CAAC;QADA,UAAK,GAAL,KAAK,CAAQ;IAEhD,CAAC;CACF","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\n/**\n * Error that is thrown when too many matches are found while filtering the tree.\n * @beta\n */\nexport class FilterLimitExceededError extends Error {\n public constructor(public readonly limit: number) {\n super(\"Too many filter matches\");\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ScreenViewport } from "@itwin/core-frontend";
|
|
2
|
+
/**
|
|
3
|
+
* A copy of `useActiveViewport` from `@itwin/appui-react` package until X is fixed.
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare function useActiveViewport(): ScreenViewport | undefined;
|
|
7
|
+
//# sourceMappingURL=UseActiveViewport.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
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 { useEffect, useState } from "react";
|
|
6
|
+
import { IModelApp } from "@itwin/core-frontend";
|
|
7
|
+
/**
|
|
8
|
+
* A copy of `useActiveViewport` from `@itwin/appui-react` package until X is fixed.
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export function useActiveViewport() {
|
|
12
|
+
const [activeViewport, setActiveViewport] = useState(IModelApp.viewManager.selectedView);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
setActiveViewport(IModelApp.viewManager.selectedView);
|
|
15
|
+
return IModelApp.viewManager.onSelectedViewportChanged.addListener((args) => {
|
|
16
|
+
setActiveViewport(args.current);
|
|
17
|
+
});
|
|
18
|
+
}, []);
|
|
19
|
+
return activeViewport;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=UseActiveViewport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseActiveViewport.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/UseActiveViewport.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAClD,SAAS,CAAC,WAAW,CAAC,YAAY,CACnC,CAAC;IACF,SAAS,CAAC,GAAG,EAAE;QACb,iBAAiB,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QACtD,OAAO,SAAS,CAAC,WAAW,CAAC,yBAAyB,CAAC,WAAW,CAChE,CAAC,IAAI,EAAE,EAAE;YACP,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC,CACF,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,cAAc,CAAC;AACxB,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, useState } from \"react\";\nimport type { ScreenViewport } from \"@itwin/core-frontend\";\nimport { IModelApp } from \"@itwin/core-frontend\";\n\n/** \n * A copy of `useActiveViewport` from `@itwin/appui-react` package until X is fixed.\n * @internal\n */\nexport function useActiveViewport(): ScreenViewport | undefined {\n const [activeViewport, setActiveViewport] = useState(\n IModelApp.viewManager.selectedView\n );\n useEffect(() => {\n setActiveViewport(IModelApp.viewManager.selectedView);\n return IModelApp.viewManager.onSelectedViewportChanged.addListener(\n (args) => {\n setActiveViewport(args.current);\n }\n );\n }, []);\n\n return activeViewport;\n}\n"]}
|
|
@@ -12,5 +12,6 @@ export { TreeRenderer } from "./common/components/TreeRenderer";
|
|
|
12
12
|
export { VisibilityTreeRenderer } from "./common/components/VisibilityTreeRenderer";
|
|
13
13
|
export { HierarchyVisibilityHandler, VisibilityStatus } from "./common/UseHierarchyVisibility";
|
|
14
14
|
export { TelemetryContextProvider } from "./common/UseTelemetryContext";
|
|
15
|
+
export { FilterLimitExceededError } from "./common/TreeErrors";
|
|
15
16
|
export { ModelsTreeVisibilityHandlerOverrides } from "./models-tree/internal/ModelsTreeVisibilityHandler";
|
|
16
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -15,4 +15,5 @@ export { VisibilityTree } from "./common/components/VisibilityTree";
|
|
|
15
15
|
export { TreeRenderer } from "./common/components/TreeRenderer";
|
|
16
16
|
export { VisibilityTreeRenderer } from "./common/components/VisibilityTreeRenderer";
|
|
17
17
|
export { TelemetryContextProvider } from "./common/UseTelemetryContext";
|
|
18
|
+
export { FilterLimitExceededError } from "./common/TreeErrors";
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/trees/index.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,kDAAkD,CAAC;AAC9F,OAAO,EAAE,4BAA4B,EAAE,MAAM,sDAAsD,CAAC;AAEpG,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AAEvF,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAEpF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nexport { ModelsTreeComponent } from \"./models-tree/ModelsTreeComponent\";\nexport { CategoriesTreeComponent } from \"./categories-tree/CategoriesTreeComponent\";\nexport { IModelContentTreeComponent } from \"./imodel-content-tree/IModelContentTreeComponent\";\nexport { ExternalSourcesTreeComponent } from \"./external-sources-tree/ExternalSourcesTreeComponent\";\n\nexport { useModelsTree } from \"./models-tree/UseModelsTree\";\nexport { useCategoriesTree } from \"./categories-tree/UseCategoriesTree\";\n\nexport { useModelsTreeButtonProps } from \"./models-tree/ModelsTreeButtons\";\nexport { useCategoriesTreeButtonProps } from \"./categories-tree/CategoriesTreeButtons\";\n\nexport { Tree } from \"./common/components/Tree\";\nexport { VisibilityTree } from \"./common/components/VisibilityTree\";\nexport { TreeRenderer } from \"./common/components/TreeRenderer\";\nexport { VisibilityTreeRenderer } from \"./common/components/VisibilityTreeRenderer\";\nexport { HierarchyVisibilityHandler, VisibilityStatus } from \"./common/UseHierarchyVisibility\";\nexport { TelemetryContextProvider } from \"./common/UseTelemetryContext\";\n\nexport { ModelsTreeVisibilityHandlerOverrides } from \"./models-tree/internal/ModelsTreeVisibilityHandler\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/trees/index.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,kDAAkD,CAAC;AAC9F,OAAO,EAAE,4BAA4B,EAAE,MAAM,sDAAsD,CAAC;AAEpG,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AAEvF,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAEpF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nexport { ModelsTreeComponent } from \"./models-tree/ModelsTreeComponent\";\nexport { CategoriesTreeComponent } from \"./categories-tree/CategoriesTreeComponent\";\nexport { IModelContentTreeComponent } from \"./imodel-content-tree/IModelContentTreeComponent\";\nexport { ExternalSourcesTreeComponent } from \"./external-sources-tree/ExternalSourcesTreeComponent\";\n\nexport { useModelsTree } from \"./models-tree/UseModelsTree\";\nexport { useCategoriesTree } from \"./categories-tree/UseCategoriesTree\";\n\nexport { useModelsTreeButtonProps } from \"./models-tree/ModelsTreeButtons\";\nexport { useCategoriesTreeButtonProps } from \"./categories-tree/CategoriesTreeButtons\";\n\nexport { Tree } from \"./common/components/Tree\";\nexport { VisibilityTree } from \"./common/components/VisibilityTree\";\nexport { TreeRenderer } from \"./common/components/TreeRenderer\";\nexport { VisibilityTreeRenderer } from \"./common/components/VisibilityTreeRenderer\";\nexport { HierarchyVisibilityHandler, VisibilityStatus } from \"./common/UseHierarchyVisibility\";\nexport { TelemetryContextProvider } from \"./common/UseTelemetryContext\";\nexport { FilterLimitExceededError } from \"./common/TreeErrors\";\n\nexport { ModelsTreeVisibilityHandlerOverrides } from \"./models-tree/internal/ModelsTreeVisibilityHandler\";\n"]}
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
import { VisibilityTree } from "../common/components/VisibilityTree";
|
|
2
|
+
import { useModelsTree } from "./UseModelsTree";
|
|
2
3
|
import type { ComponentPropsWithoutRef } from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import type { ModelsTreeHierarchyConfiguration } from "./ModelsTreeDefinition";
|
|
4
|
+
/** @beta */
|
|
5
|
+
type VisibilityTreeProps = ComponentPropsWithoutRef<typeof VisibilityTree>;
|
|
6
6
|
/** @beta */
|
|
7
7
|
interface ModelsTreeOwnProps {
|
|
8
|
-
activeView: Viewport;
|
|
9
8
|
hierarchyLevelConfig?: {
|
|
10
9
|
sizeLimit?: number;
|
|
11
10
|
};
|
|
12
|
-
hierarchyConfig?: Partial<ModelsTreeHierarchyConfiguration>;
|
|
13
|
-
visibilityHandlerOverrides?: ModelsTreeVisibilityHandlerOverrides;
|
|
14
|
-
filter?: string;
|
|
15
11
|
}
|
|
12
|
+
type UseModelsTreeProps = Parameters<typeof useModelsTree>[0];
|
|
16
13
|
/** @beta */
|
|
17
|
-
type
|
|
18
|
-
/** @beta */
|
|
19
|
-
type ModelsTreeProps = ModelsTreeOwnProps & Pick<VisibilityTreeProps, "imodel" | "getSchemaContext" | "selectionStorage" | "density" | "selectionMode">;
|
|
14
|
+
type ModelsTreeProps = ModelsTreeOwnProps & UseModelsTreeProps & Pick<VisibilityTreeProps, "imodel" | "getSchemaContext" | "selectionStorage" | "density" | "selectionMode">;
|
|
20
15
|
/** @beta */
|
|
21
|
-
export declare function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, visibilityHandlerOverrides, }: ModelsTreeProps): JSX.Element;
|
|
16
|
+
export declare function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, visibilityHandlerOverrides, getFilteredPaths, }: ModelsTreeProps): JSX.Element;
|
|
22
17
|
export {};
|
|
23
18
|
//# sourceMappingURL=ModelsTree.d.ts.map
|
|
@@ -7,8 +7,8 @@ import { VisibilityTree } from "../common/components/VisibilityTree";
|
|
|
7
7
|
import { VisibilityTreeRenderer } from "../common/components/VisibilityTreeRenderer";
|
|
8
8
|
import { useModelsTree } from "./UseModelsTree";
|
|
9
9
|
/** @beta */
|
|
10
|
-
export function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, visibilityHandlerOverrides, }) {
|
|
11
|
-
const { modelsTreeProps, rendererProps } = useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides });
|
|
10
|
+
export function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, visibilityHandlerOverrides, getFilteredPaths, }) {
|
|
11
|
+
const { modelsTreeProps, rendererProps } = useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides, getFilteredPaths });
|
|
12
12
|
return (_jsx(VisibilityTree, { ...modelsTreeProps, imodel: imodel, selectionStorage: selectionStorage, getSchemaContext: getSchemaContext, hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit, density: density, selectionMode: selectionMode, treeRenderer: (treeProps) => _jsx(VisibilityTreeRenderer, { ...treeProps, ...rendererProps }) }));
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=ModelsTree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAqBhD,YAAY;AACZ,MAAM,UAAU,UAAU,CAAC,EACzB,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,OAAO,EACP,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,0BAA0B,EAC1B,gBAAgB,GACA;IAChB,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAEhJ,OAAO,CACL,KAAC,cAAc,OACT,eAAe,EACnB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,oBAAoB,EAAE,SAAS,EACxD,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,KAAC,sBAAsB,OAAK,SAAS,KAAM,aAAa,GAAI,GACzF,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 { VisibilityTree } from \"../common/components/VisibilityTree\";\nimport { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer\";\nimport { useModelsTree } from \"./UseModelsTree\";\n\nimport type { ComponentPropsWithoutRef } from \"react\";\n\n/** @beta */\ntype VisibilityTreeProps = ComponentPropsWithoutRef<typeof VisibilityTree>;\n\n/** @beta */\ninterface ModelsTreeOwnProps {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n}\n\ntype UseModelsTreeProps = Parameters<typeof useModelsTree>[0];\n\n/** @beta */\ntype ModelsTreeProps = ModelsTreeOwnProps &\n UseModelsTreeProps &\n Pick<VisibilityTreeProps, \"imodel\" | \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"selectionMode\">;\n\n/** @beta */\nexport function ModelsTree({\n imodel,\n getSchemaContext,\n selectionStorage,\n activeView,\n filter,\n density,\n hierarchyLevelConfig,\n hierarchyConfig,\n selectionMode,\n visibilityHandlerOverrides,\n getFilteredPaths,\n}: ModelsTreeProps) {\n const { modelsTreeProps, rendererProps } = useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides, getFilteredPaths });\n\n return (\n <VisibilityTree\n {...modelsTreeProps}\n imodel={imodel}\n selectionStorage={selectionStorage}\n getSchemaContext={getSchemaContext}\n hierarchyLevelSizeLimit={hierarchyLevelConfig?.sizeLimit}\n density={density}\n selectionMode={selectionMode}\n treeRenderer={(treeProps) => <VisibilityTreeRenderer {...treeProps} {...rendererProps} />}\n />\n );\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import { HideAllButton, InvertButton, ShowAllButton, ToggleInstancesFocusButton,
|
|
|
3
3
|
import type { ComponentPropsWithoutRef } from "react";
|
|
4
4
|
import type { ModelsTreeHeaderButtonProps } from "./ModelsTreeButtons";
|
|
5
5
|
/** @public */
|
|
6
|
-
interface ModelsTreeComponentProps extends Pick<ComponentPropsWithoutRef<typeof ModelsTree>, "getSchemaContext" | "selectionStorage" | "density" | "hierarchyLevelConfig" | "selectionMode" | "hierarchyConfig" | "visibilityHandlerOverrides"> {
|
|
6
|
+
interface ModelsTreeComponentProps extends Pick<ComponentPropsWithoutRef<typeof ModelsTree>, "getSchemaContext" | "selectionStorage" | "density" | "hierarchyLevelConfig" | "selectionMode" | "hierarchyConfig" | "visibilityHandlerOverrides" | "getFilteredPaths"> {
|
|
7
7
|
/**
|
|
8
8
|
* Renderers of header buttons. Defaults to:
|
|
9
9
|
* ```ts
|
|
@@ -5,11 +5,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
6
6
|
*--------------------------------------------------------------------------------------------*/
|
|
7
7
|
import { Fragment, useEffect } from "react";
|
|
8
|
-
import { useActiveIModelConnection
|
|
8
|
+
import { useActiveIModelConnection } from "@itwin/appui-react";
|
|
9
9
|
import { TreeWidget } from "../../../TreeWidget";
|
|
10
10
|
import { TreeWithHeader } from "../../tree-header/TreeWithHeader";
|
|
11
11
|
import { useFocusedInstancesContext } from "../common/FocusedInstancesContext";
|
|
12
12
|
import { FocusedInstancesContextProvider } from "../common/FocusedInstancesContextProvider";
|
|
13
|
+
import { useActiveViewport } from "../common/UseActiveViewport";
|
|
13
14
|
import { useFiltering } from "../common/UseFiltering";
|
|
14
15
|
import { TelemetryContextProvider } from "../common/UseTelemetryContext";
|
|
15
16
|
import { ModelsTree } from "./ModelsTree";
|
|
@@ -91,7 +92,7 @@ function ModelsTreeComponentImpl({ iModel, viewport, headerButtons, onFeatureUse
|
|
|
91
92
|
return (_jsx(TelemetryContextProvider, { componentIdentifier: ModelsTreeComponent.id, onFeatureUsed: onFeatureUsed, onPerformanceMeasured: onPerformanceMeasured, children: _jsx(TreeWithHeader, { filteringProps: {
|
|
92
93
|
onFilterStart: applyFilter,
|
|
93
94
|
onFilterClear: clearFilter,
|
|
94
|
-
isDisabled: instanceFocusEnabled,
|
|
95
|
+
isDisabled: instanceFocusEnabled || !!treeProps.getFilteredPaths,
|
|
95
96
|
}, buttons: buttons, density: density, children: _jsx(ModelsTree, { ...treeProps, imodel: iModel, activeView: viewport, filter: filter }) }) }));
|
|
96
97
|
}
|
|
97
98
|
//# sourceMappingURL=ModelsTreeComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";;AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,
|
|
1
|
+
{"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";;AAAA;;;gG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AG,EAAC,cAAc,EAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAI;YACrG,eAAC,YAAY,OAAK,WAAW,EAAE,GAAG,EAAC,gBAAgB,EAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAI;YACtG,eAAC,YAAY,OAAK,WAAW,EAAE,GAAG,EAAC,aAAa,EAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAI;YACnG,eAAC,YAAY,OAAK,WAAW,EAAE,GAAG,EAAC,aAAa,EAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAI;YACnG,KAAC,0BAA0B,IAAkC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,IAA3E,4BAA4B,CAAmD;SAChH,CAAC;IAEN,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,oBAAoB,EAAE;YACxB,WAAW,EAAE,CAAC;SACf;IACH,CAAC,EAAE,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC,CAAC;IAExC,OAAO,CACL,KAAC,wBAAwB,IAAC,mBAAmB,EAAE,mBAAmB,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YAC/I,KAAC,cAAc,IACb,cAAc,EAAE;gBACd,aAAa,EAAE,WAAW;gBAC1B,aAAa,EAAE,WAAW;gBAC1B,UAAU,EAAE,oBAAoB,IAAI,CAAC,CAAC,SAAS,CAAC,gBAAgB;aACjE,EACD,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,YAEhB,KAAC,UAAU,OAAK,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAI,GACpE,GACQ,CAC5B,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 { Fragment, useEffect } from \"react\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeWithHeader } from \"../../tree-header/TreeWithHeader\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext\";\nimport { FocusedInstancesContextProvider } from \"../common/FocusedInstancesContextProvider\";\nimport { useActiveViewport } from \"../common/UseActiveViewport\";\nimport { useFiltering } from \"../common/UseFiltering\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext\";\nimport { ModelsTree } from \"./ModelsTree\";\nimport {\n HideAllButton, InvertButton, ShowAllButton, ToggleInstancesFocusButton, useModelsTreeButtonProps, View2DButton, View3DButton,\n} from \"./ModelsTreeButtons\";\n\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { ModelsTreeHeaderButtonProps } from \"./ModelsTreeButtons\";\n\n/** @public */\ninterface ModelsTreeComponentProps\n extends Pick<\n ComponentPropsWithoutRef<typeof ModelsTree>,\n | \"getSchemaContext\"\n | \"selectionStorage\"\n | \"density\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"hierarchyConfig\"\n | \"visibilityHandlerOverrides\"\n | \"getFilteredPaths\"\n > {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * ModelsTreeComponent.ShowAllButton,\n * ModelsTreeComponent.HideAllButton,\n * ModelsTreeComponent.InvertButton,\n * ModelsTreeComponent.View2DButton,\n * ModelsTreeComponent.View3DButton,\n * ModelsTreeComponent.ToggleInstancesFocusButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: ModelsTreeHeaderButtonProps) => React.ReactNode>;\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `ModelsTree` and a header with filtering capabilities\n * and header buttons.\n *\n * @public\n */\nexport const ModelsTreeComponent = (props: ModelsTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return (\n <FocusedInstancesContextProvider selectionStorage={props.selectionStorage} imodelKey={iModel.key}>\n <ModelsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />\n </FocusedInstancesContextProvider>\n );\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all models.\n * @public\n */\nModelsTreeComponent.ShowAllButton = ShowAllButton;\n\n/**\n * Renders a \"Hide all\" button that disables display of all models.\n * @public\n */\nModelsTreeComponent.HideAllButton = HideAllButton;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all models.\n * @public\n */\nModelsTreeComponent.InvertButton = InvertButton;\n\n/**\n * Renders a \"View 2D\" button that enables display of all plan projection models and disables all others.\n * @public\n */\nModelsTreeComponent.View2DButton = View2DButton;\n\n/**\n * Renders a \"View 3D\" button that enables display of all non-plan projection models and disables all plan projection ones.\n * @public\n */\nModelsTreeComponent.View3DButton = View3DButton;\n\n/**\n * Renders a \"Enable/Disable instances focus\" button that enables/disables instances focusing mode.\n * @public\n */\nModelsTreeComponent.ToggleInstancesFocusButton = ToggleInstancesFocusButton;\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.id = \"models-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.getLabel = () => TreeWidget.translate(\"modelsTree.label\");\n\nfunction ModelsTreeComponentImpl({\n iModel,\n viewport,\n headerButtons,\n onFeatureUsed,\n onPerformanceMeasured,\n ...treeProps\n}: ModelsTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const buttonProps = useModelsTreeButtonProps({ imodel: iModel, viewport });\n const { filter, applyFilter, clearFilter } = useFiltering();\n const { enabled: instanceFocusEnabled } = useFocusedInstancesContext();\n const density = treeProps.density;\n\n const buttons: ReactNode = headerButtons\n ? headerButtons.map((btn, index) => <Fragment key={index}>{btn({ ...buttonProps, onFeatureUsed })}</Fragment>)\n : [\n <ShowAllButton {...buttonProps} key=\"show-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <HideAllButton {...buttonProps} key=\"hide-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <InvertButton {...buttonProps} key=\"invert-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <View2DButton {...buttonProps} key=\"view-2d-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <View3DButton {...buttonProps} key=\"view-3d-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <ToggleInstancesFocusButton key=\"toggle-instances-focus-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n ];\n\n useEffect(() => {\n if (instanceFocusEnabled) {\n clearFilter();\n }\n }, [instanceFocusEnabled, clearFilter]);\n\n return (\n <TelemetryContextProvider componentIdentifier={ModelsTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <TreeWithHeader\n filteringProps={{\n onFilterStart: applyFilter,\n onFilterClear: clearFilter,\n isDisabled: instanceFocusEnabled || !!treeProps.getFilteredPaths,\n }}\n buttons={buttons}\n density={density}\n >\n <ModelsTree {...treeProps} imodel={iModel} activeView={viewport} filter={filter} />\n </TreeWithHeader>\n </TelemetryContextProvider>\n );\n}\n"]}
|