@itwin/tree-widget-react 0.10.0 → 1.0.0-dev.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 +331 -0
- package/README.md +146 -29
- package/lib/cjs/TreeWidget.d.ts +0 -1
- package/lib/cjs/TreeWidget.js +1 -6
- package/lib/cjs/TreeWidget.js.map +1 -1
- package/lib/cjs/components/TreeFilteringState.d.ts +3 -1
- package/lib/cjs/components/TreeFilteringState.js +19 -40
- package/lib/cjs/components/TreeFilteringState.js.map +1 -1
- package/lib/cjs/components/TreeWidgetComponent.d.ts +29 -5
- package/lib/cjs/components/TreeWidgetComponent.js +85 -29
- package/lib/cjs/components/TreeWidgetComponent.js.map +1 -1
- package/lib/cjs/components/TreeWidgetComponent.scss +4 -24
- package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +25 -2
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js +31 -46
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/cjs/components/tree-header/TreeHeader.d.ts +26 -0
- package/lib/cjs/components/tree-header/TreeHeader.js +43 -0
- package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -0
- package/lib/cjs/components/tree-header/TreeHeader.scss +69 -0
- package/lib/cjs/components/trees/CategoriesVisibilityUtils.d.ts +12 -6
- package/lib/cjs/components/trees/CategoriesVisibilityUtils.js +10 -4
- package/lib/cjs/components/trees/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/cjs/components/trees/Common.d.ts +2 -2
- package/lib/cjs/components/trees/Common.js +1 -1
- package/lib/cjs/components/trees/Common.js.map +1 -1
- package/lib/cjs/components/trees/VisibilityTreeBase.scss +66 -10
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.d.ts +13 -12
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.js +6 -17
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.js.map +1 -1
- package/lib/cjs/components/trees/VisibilityTreeRenderer.d.ts +38 -14
- package/lib/cjs/components/trees/VisibilityTreeRenderer.js +35 -41
- package/lib/cjs/components/trees/VisibilityTreeRenderer.js.map +1 -1
- package/lib/cjs/components/trees/category-tree/CategoriesTree.d.ts +12 -11
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js +17 -41
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +1 -1
- package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.d.ts +67 -6
- package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js +61 -72
- package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.d.ts +30 -8
- package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js +61 -34
- package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSources.json +230 -0
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +27 -0
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +61 -0
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -0
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +20 -0
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +39 -0
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -0
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +30 -0
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +39 -0
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -0
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +26 -0
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js +35 -0
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -0
- package/lib/cjs/components/trees/index.d.ts +5 -1
- package/lib/cjs/components/trees/index.js +10 -2
- package/lib/cjs/components/trees/index.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +26 -18
- package/lib/cjs/components/trees/models-tree/ModelsTree.js +22 -50
- package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.d.ts +70 -2
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +68 -105
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.d.ts +40 -12
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js +65 -5
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/Utils.d.ts +12 -0
- package/lib/cjs/components/trees/models-tree/Utils.js +625 -1
- package/lib/cjs/components/trees/models-tree/Utils.js.map +1 -1
- package/lib/cjs/components/utils/AutoSizer.d.ts +6 -3
- package/lib/cjs/components/utils/AutoSizer.js +9 -29
- package/lib/cjs/components/utils/AutoSizer.js.map +1 -1
- package/lib/cjs/components/utils/IsPromiseLike.d.ts +4 -1
- package/lib/cjs/components/utils/IsPromiseLike.js +6 -3
- package/lib/cjs/components/utils/IsPromiseLike.js.map +1 -1
- package/lib/cjs/tree-widget-react.d.ts +0 -1
- package/lib/cjs/tree-widget-react.js +5 -2
- package/lib/cjs/tree-widget-react.js.map +1 -1
- package/lib/esm/TreeWidget.d.ts +0 -1
- package/lib/esm/TreeWidget.js +2 -7
- package/lib/esm/TreeWidget.js.map +1 -1
- package/lib/esm/components/TreeFilteringState.d.ts +3 -1
- package/lib/esm/components/TreeFilteringState.js +17 -19
- package/lib/esm/components/TreeFilteringState.js.map +1 -1
- package/lib/esm/components/TreeWidgetComponent.d.ts +29 -5
- package/lib/esm/components/TreeWidgetComponent.js +82 -7
- package/lib/esm/components/TreeWidgetComponent.js.map +1 -1
- package/lib/esm/components/TreeWidgetComponent.scss +4 -24
- package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +25 -2
- package/lib/esm/components/TreeWidgetUiItemsProvider.js +29 -41
- package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/components/tree-header/TreeHeader.d.ts +26 -0
- package/lib/esm/components/tree-header/TreeHeader.js +36 -0
- package/lib/esm/components/tree-header/TreeHeader.js.map +1 -0
- package/lib/esm/components/tree-header/TreeHeader.scss +69 -0
- package/lib/esm/components/trees/CategoriesVisibilityUtils.d.ts +12 -6
- package/lib/esm/components/trees/CategoriesVisibilityUtils.js +10 -4
- package/lib/esm/components/trees/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/esm/components/trees/Common.d.ts +2 -2
- package/lib/esm/components/trees/Common.js +1 -1
- package/lib/esm/components/trees/Common.js.map +1 -1
- package/lib/esm/components/trees/VisibilityTreeBase.scss +66 -10
- package/lib/esm/components/trees/VisibilityTreeEventHandler.d.ts +13 -12
- package/lib/esm/components/trees/VisibilityTreeEventHandler.js +6 -17
- package/lib/esm/components/trees/VisibilityTreeEventHandler.js.map +1 -1
- package/lib/esm/components/trees/VisibilityTreeRenderer.d.ts +38 -14
- package/lib/esm/components/trees/VisibilityTreeRenderer.js +29 -19
- package/lib/esm/components/trees/VisibilityTreeRenderer.js.map +1 -1
- package/lib/esm/components/trees/category-tree/CategoriesTree.d.ts +12 -11
- package/lib/esm/components/trees/category-tree/CategoriesTree.js +16 -21
- package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.d.ts +67 -6
- package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js +60 -52
- package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.d.ts +30 -8
- package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js +57 -14
- package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSources.json +230 -0
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +27 -0
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +34 -0
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -0
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +20 -0
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +35 -0
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -0
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +30 -0
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +32 -0
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -0
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +26 -0
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js +31 -0
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -0
- package/lib/esm/components/trees/index.d.ts +5 -1
- package/lib/esm/components/trees/index.js +5 -1
- package/lib/esm/components/trees/index.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +26 -18
- package/lib/esm/components/trees/models-tree/ModelsTree.js +23 -32
- package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.d.ts +70 -2
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +66 -84
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.d.ts +40 -12
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js +60 -5
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
- package/lib/esm/components/trees/models-tree/Utils.d.ts +12 -0
- package/lib/esm/components/trees/models-tree/Utils.js +622 -0
- package/lib/esm/components/trees/models-tree/Utils.js.map +1 -1
- package/lib/esm/components/utils/AutoSizer.d.ts +6 -3
- package/lib/esm/components/utils/AutoSizer.js +9 -10
- package/lib/esm/components/utils/AutoSizer.js.map +1 -1
- package/lib/esm/components/utils/IsPromiseLike.d.ts +4 -1
- package/lib/esm/components/utils/IsPromiseLike.js +4 -1
- package/lib/esm/components/utils/IsPromiseLike.js.map +1 -1
- package/lib/esm/tree-widget-react.d.ts +0 -1
- package/lib/esm/tree-widget-react.js +0 -1
- package/lib/esm/tree-widget-react.js.map +1 -1
- package/lib/public/locales/en/TreeWidget.json +13 -4
- package/package.json +44 -48
- package/lib/cjs/components/rulesets/ClassificationSystems.json +0 -122
- package/lib/cjs/components/search-bar/SearchBar.d.ts +0 -48
- package/lib/cjs/components/search-bar/SearchBar.js +0 -86
- package/lib/cjs/components/search-bar/SearchBar.js.map +0 -1
- package/lib/cjs/components/search-bar/SearchBar.scss +0 -118
- package/lib/cjs/components/search-bar/SearchBox.d.ts +0 -70
- package/lib/cjs/components/search-bar/SearchBox.js +0 -186
- package/lib/cjs/components/search-bar/SearchBox.js.map +0 -1
- package/lib/cjs/components/search-bar/SearchBox.scss +0 -70
- package/lib/cjs/components/trees/IModelContentTree.d.ts +0 -4
- package/lib/cjs/components/trees/IModelContentTree.js +0 -50
- package/lib/cjs/components/trees/IModelContentTree.js.map +0 -1
- package/lib/cjs/components/trees/models-tree/Hierarchy.GroupedByClass.json +0 -391
- package/lib/cjs/components/trees/models-tree/Hierarchy.json +0 -386
- package/lib/cjs/components/trees/models-tree/ModelsTreeSearch.json +0 -239
- package/lib/cjs/types.d.ts +0 -44
- package/lib/cjs/types.js +0 -11
- package/lib/cjs/types.js.map +0 -1
- package/lib/esm/components/rulesets/ClassificationSystems.json +0 -122
- package/lib/esm/components/search-bar/SearchBar.d.ts +0 -48
- package/lib/esm/components/search-bar/SearchBar.js +0 -60
- package/lib/esm/components/search-bar/SearchBar.js.map +0 -1
- package/lib/esm/components/search-bar/SearchBar.scss +0 -118
- package/lib/esm/components/search-bar/SearchBox.d.ts +0 -70
- package/lib/esm/components/search-bar/SearchBox.js +0 -160
- package/lib/esm/components/search-bar/SearchBox.js.map +0 -1
- package/lib/esm/components/search-bar/SearchBox.scss +0 -70
- package/lib/esm/components/trees/IModelContentTree.d.ts +0 -4
- package/lib/esm/components/trees/IModelContentTree.js +0 -24
- package/lib/esm/components/trees/IModelContentTree.js.map +0 -1
- package/lib/esm/components/trees/models-tree/Hierarchy.GroupedByClass.json +0 -391
- package/lib/esm/components/trees/models-tree/Hierarchy.json +0 -386
- package/lib/esm/components/trees/models-tree/ModelsTreeSearch.json +0 -239
- package/lib/esm/types.d.ts +0 -44
- package/lib/esm/types.js +0 -8
- package/lib/esm/types.js.map +0 -1
- /package/lib/cjs/components/{rulesets → trees/imodel-content-tree}/IModelContent.json +0 -0
- /package/lib/esm/components/{rulesets → trees/imodel-content-tree}/IModelContent.json +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisibilityTreeRenderer.js","sourceRoot":"","sources":["../../../../src/components/trees/VisibilityTreeRenderer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"VisibilityTreeRenderer.js","sourceRoot":"","sources":["../../../../src/components/trees/VisibilityTreeRenderer.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;+FAG+F;AAE/F,iCAAkC;AAClC,8DAA0F;AAC1F,wDAAgD;AAChD,4EAAwF;AACxF,4DAAoC;AAOpC;;;;;GAKG;AACH,MAAM,sBAAsB,GAAG,EAAE,CAAC;AA2BlC;;;GAGG;AACI,MAAM,4BAA4B,GAAG,CAAC,2BAAwD,EAAE,EAAE;IACvG,MAAM,YAAY,GAAG,IAAA,wCAAgC,EAAC,2BAA2B,CAAC,CAAC;IACnF,OAAO,SAAS,sBAAsB,CAAC,KAAwB;QAC7D,OAAO,CACL,uBAAC,+BAAY,OACP,KAA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,SAAgB,4BAA4B,CAAC,KAAwC;IACnF,OAAO,CACL,iCAAK,SAAS,EAAC,8BAA8B,aAC3C,iCAAM,SAAS,EAAC,qBAAqB,YAAE,KAAK,CAAC,KAAK,GAAQ,EAC1D,iCAAM,SAAS,EAAC,mBAAmB,YAAE,KAAK,CAAC,OAAO,GAAQ,IACtD,CACP,CAAC;AACJ,CAAC;AAPD,oEAOC","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 } from \"react\";\nimport { TreeImageLoader, TreeNodeRenderer, TreeRenderer } from \"@itwin/components-react\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport { useControlledPresentationTreeFiltering } from \"@itwin/presentation-components\";\nimport classNames from \"classnames\";\n\nimport type { AbstractTreeNodeLoaderWithProvider, TreeNodeRendererProps, TreeRendererProps } from \"@itwin/components-react\";\nimport type { NodeCheckboxRenderProps } from \"@itwin/core-react\";\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { VisibilityTreeFilterInfo } from \"./Common\";\n\n/**\n * This constant is taken from `@itwin/core-react`.\n * Defines the size in pixels of the expansion toggle.\n * It is used to keep same hierarchy nodes with children and nodes without children in the same line.\n * @note This value applies only to the leaf nodes.\n */\nconst EXPANSION_TOGGLE_WIDTH = 24;\n\n/**\n * Props for visibility tree node renderer.\n * @public\n */\nexport interface VisibilityTreeRendererProps {\n /**\n * Specifies whether the icon at the left of the node label should be rendered.\n */\n iconsEnabled: boolean;\n /**\n * Specifies whether node description should be enabled.\n */\n descriptionEnabled: boolean;\n /**\n * Defines the offset in pixels of how much each hierarchy level should be offset to the right from the checkbox.\n * Defaults to `20`.\n */\n levelOffset?: number;\n /**\n * Specifies whether the root node be expanded at all times.\n * Defaults to `false`.\n */\n disableRootNodeCollapse?: boolean;\n}\n\n/**\n * Creates Visibility tree renderer which renders nodes with eye checkbox.\n * @public\n */\nexport const createVisibilityTreeRenderer = (visibilityTreeRendererProps: VisibilityTreeRendererProps) => {\n const nodeRenderer = createVisibilityTreeNodeRenderer(visibilityTreeRendererProps);\n return function VisibilityTreeRenderer(props: TreeRendererProps) {\n return (\n <TreeRenderer\n {...props}\n nodeRenderer={nodeRenderer}\n />\n );\n };\n};\n\nconst imageLoader = new TreeImageLoader();\n\n/**\n * Creates node renderer which renders node with eye checkbox.\n * @public\n */\nexport const createVisibilityTreeNodeRenderer = ({ levelOffset = 20, disableRootNodeCollapse = false, descriptionEnabled, iconsEnabled }: VisibilityTreeRendererProps) => {\n return function VisibilityTreeNodeRenderer(treeNodeProps: TreeNodeRendererProps) {\n const nodeOffset = treeNodeProps.node.depth * levelOffset + (treeNodeProps.node.numChildren === 0 ? EXPANSION_TOGGLE_WIDTH : 0);\n return (\n <TreeNodeRenderer\n {...treeNodeProps}\n node={{ ...treeNodeProps.node, depth: 0, numChildren: 1 }} // if we want to disable TreeNodeRenderer style calculations for tree nodes, we need to override these values.\n checkboxRenderer={(checkboxProps: NodeCheckboxRenderProps) => (\n <div className=\"visibility-tree-checkbox-container\" style={{ marginRight: `${nodeOffset}px` }}>\n <VisibilityTreeNodeCheckbox { ...checkboxProps }/>\n </div>\n )}\n descriptionEnabled={descriptionEnabled}\n imageLoader={iconsEnabled ? imageLoader : undefined}\n className={classNames(\"with-checkbox\", (treeNodeProps.node.numChildren === 0 || (disableRootNodeCollapse && treeNodeProps.node.parentId === undefined)) && \"disable-expander\", treeNodeProps.className)}\n />\n );\n };\n};\n\n/**\n * Checkbox renderer that renders an eye.\n * @public\n */\nexport const VisibilityTreeNodeCheckbox = (props: NodeCheckboxRenderProps) => (\n <Checkbox\n className=\"visibility-tree-checkbox\"\n variant=\"eyeball\"\n checked={props.checked}\n onChange={(e) => props.onChange(e.currentTarget.checked)}\n disabled={props.disabled}\n title={props.title}\n />\n);\n\n/**\n * Filters data provider used in supplied node loader and invokes onFilterApplied when filtering is completed.\n * @public\n */\nexport const useVisibilityTreeFiltering = (\n nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>,\n filterInfo?: VisibilityTreeFilterInfo,\n onFilterApplied?: (filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void,\n) => {\n const { filter, activeMatchIndex } = filterInfo ?? { filter: undefined, activeMatchIndex: undefined };\n const {\n filteredNodeLoader,\n isFiltering,\n matchesCount,\n nodeHighlightingProps,\n } = useControlledPresentationTreeFiltering({ nodeLoader, filter, activeMatchIndex });\n\n useEffect(\n () => {\n if (filter && matchesCount !== undefined && filteredNodeLoader !== nodeLoader)\n onFilterApplied && onFilterApplied(filteredNodeLoader.dataProvider, matchesCount);\n },\n [filter, matchesCount, nodeLoader, filteredNodeLoader, onFilterApplied],\n );\n\n return { filteredNodeLoader, isFiltering, nodeHighlightingProps };\n};\n\n/**\n * Properties for [[VisibilityTreeNoFilteredData]] component.\n * @public\n */\nexport interface VisibilityTreeNoFilteredDataProps {\n title: string;\n message: string;\n}\n\n/**\n * Renders message that no nodes was found for filter.\n * @public\n */\nexport function VisibilityTreeNoFilteredData(props: VisibilityTreeNoFilteredDataProps) {\n return (\n <div className=\"components-tree-errormessage\">\n <span className=\"errormessage-header\">{props.title}</span>\n <span className=\"errormessage-body\">{props.message}</span>\n </div>\n );\n}\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "../VisibilityTreeBase.scss";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { CategoryVisibilityHandler } from "./CategoryVisibilityHandler";
|
|
4
|
+
import type { IModelConnection, ViewManager, Viewport } from "@itwin/core-frontend";
|
|
5
|
+
import type { Ruleset } from "@itwin/presentation-common";
|
|
6
|
+
import type { IPresentationTreeDataProvider } from "@itwin/presentation-components";
|
|
7
|
+
import type { VisibilityTreeFilterInfo } from "../Common";
|
|
8
|
+
import type { CategoryInfo } from "./CategoryVisibilityHandler";
|
|
8
9
|
/**
|
|
9
10
|
* Presentation rules used by ControlledCategoriesTree
|
|
10
11
|
* @internal
|
|
@@ -18,7 +19,7 @@ export interface CategoryTreeProps {
|
|
|
18
19
|
/** Flag for accommodating all viewports */
|
|
19
20
|
allViewports?: boolean;
|
|
20
21
|
/** Active viewport */
|
|
21
|
-
activeView
|
|
22
|
+
activeView: Viewport;
|
|
22
23
|
/**
|
|
23
24
|
* An IModel to pull data from
|
|
24
25
|
*/
|
|
@@ -36,6 +37,10 @@ export interface CategoryTreeProps {
|
|
|
36
37
|
* Callback invoked when tree is filtered.
|
|
37
38
|
*/
|
|
38
39
|
onFilterApplied?: (filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Available iModel categories
|
|
42
|
+
*/
|
|
43
|
+
categories: CategoryInfo[];
|
|
39
44
|
/**
|
|
40
45
|
* Custom category visibility handler to use for testing
|
|
41
46
|
* @internal
|
|
@@ -46,13 +51,9 @@ export interface CategoryTreeProps {
|
|
|
46
51
|
* @internal
|
|
47
52
|
*/
|
|
48
53
|
viewManager?: ViewManager;
|
|
49
|
-
/**
|
|
50
|
-
* Available iModel categories
|
|
51
|
-
*/
|
|
52
|
-
categories: CategoryInfo[];
|
|
53
54
|
}
|
|
54
55
|
/**
|
|
55
|
-
* Tree which displays and manages categories contained in an iModel.
|
|
56
|
+
* Tree which displays and manages display of categories contained in an iModel.
|
|
56
57
|
* @public
|
|
57
58
|
*/
|
|
58
59
|
export declare function CategoryTree(props: CategoryTreeProps): JSX.Element;
|
|
@@ -1,31 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CategoryTree = exports.RULESET_CATEGORIES = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
5
|
/*---------------------------------------------------------------------------------------------
|
|
3
6
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
7
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
8
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.CategoryTree = exports.RULESET_CATEGORIES = void 0;
|
|
27
9
|
require("../VisibilityTreeBase.scss");
|
|
28
|
-
const
|
|
10
|
+
const react_1 = require("react");
|
|
29
11
|
const components_react_1 = require("@itwin/components-react");
|
|
30
12
|
const core_frontend_1 = require("@itwin/core-frontend");
|
|
31
13
|
const core_react_1 = require("@itwin/core-react");
|
|
@@ -42,7 +24,7 @@ const PAGING_SIZE = 20;
|
|
|
42
24
|
*/
|
|
43
25
|
exports.RULESET_CATEGORIES = require("./Categories.json"); // eslint-disable-line @typescript-eslint/no-var-requires
|
|
44
26
|
/**
|
|
45
|
-
* Tree which displays and manages categories contained in an iModel.
|
|
27
|
+
* Tree which displays and manages display of categories contained in an iModel.
|
|
46
28
|
* @public
|
|
47
29
|
*/
|
|
48
30
|
function CategoryTree(props) {
|
|
@@ -55,36 +37,30 @@ function CategoryTree(props) {
|
|
|
55
37
|
// istanbul ignore next
|
|
56
38
|
const viewManager = props.viewManager ?? core_frontend_1.IModelApp.viewManager;
|
|
57
39
|
const { activeView, allViewports, categoryVisibilityHandler } = props;
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const eventHandler = (0, core_react_1.useDisposable)(React.useCallback(() => new VisibilityTreeEventHandler_1.VisibilityTreeEventHandler({
|
|
40
|
+
const visibilityHandler = useCategoryVisibilityHandler(viewManager, props.iModel, props.categories, activeView, allViewports, categoryVisibilityHandler);
|
|
41
|
+
(0, react_1.useEffect)(() => {
|
|
42
|
+
setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises
|
|
43
|
+
}, [activeView]);
|
|
44
|
+
const eventHandler = (0, core_react_1.useDisposable)((0, react_1.useCallback)(() => new VisibilityTreeEventHandler_1.VisibilityTreeEventHandler({
|
|
64
45
|
nodeLoader: filteredNodeLoader,
|
|
65
46
|
visibilityHandler,
|
|
66
|
-
collapsedChildrenDisposalEnabled: true,
|
|
67
47
|
}), [filteredNodeLoader, visibilityHandler]));
|
|
68
48
|
const treeModel = (0, components_react_1.useTreeModel)(filteredNodeLoader.modelSource);
|
|
69
|
-
const treeRenderer = (0, VisibilityTreeRenderer_1.
|
|
70
|
-
const overlay = isFiltering ?
|
|
49
|
+
const treeRenderer = (0, VisibilityTreeRenderer_1.createVisibilityTreeRenderer)({ iconsEnabled: false, descriptionEnabled: true, levelOffset: 10 });
|
|
50
|
+
const overlay = isFiltering ? (0, jsx_runtime_1.jsx)("div", { className: "filteredTreeOverlay" }) : undefined;
|
|
71
51
|
const filterApplied = filteredNodeLoader !== nodeLoader;
|
|
72
|
-
const noFilteredDataRenderer =
|
|
73
|
-
return
|
|
52
|
+
const noFilteredDataRenderer = (0, react_1.useCallback)(() => {
|
|
53
|
+
return (0, jsx_runtime_1.jsx)(VisibilityTreeRenderer_1.VisibilityTreeNoFilteredData, { title: TreeWidget_1.TreeWidget.translate("categoriesTree.noCategoryFound"), message: TreeWidget_1.TreeWidget.translate("categoriesTree.noMatchingCategoryNames") });
|
|
74
54
|
}, []);
|
|
75
|
-
return (
|
|
76
|
-
React.createElement(components_react_1.ControlledTree, { nodeLoader: filteredNodeLoader, model: treeModel, selectionMode: components_react_1.SelectionMode.None, eventsHandler: eventHandler, treeRenderer: treeRenderer, descriptionsEnabled: true, nodeHighlightingProps: nodeHighlightingProps, noDataRenderer: filterApplied ? noFilteredDataRenderer : undefined, width: props.width, height: props.height }),
|
|
77
|
-
overlay));
|
|
55
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "tree-widget-visibility-tree-base", children: [(0, jsx_runtime_1.jsx)(components_react_1.ControlledTree, { nodeLoader: filteredNodeLoader, model: treeModel, selectionMode: components_react_1.SelectionMode.None, eventsHandler: eventHandler, treeRenderer: treeRenderer, descriptionsEnabled: true, nodeHighlightingProps: nodeHighlightingProps, noDataRenderer: filterApplied ? noFilteredDataRenderer : undefined, width: props.width, height: props.height }), overlay] }));
|
|
78
56
|
}
|
|
79
57
|
exports.CategoryTree = CategoryTree;
|
|
80
58
|
function useCategoryVisibilityHandler(viewManager, imodel, categories, activeView, allViewports, visibilityHandler) {
|
|
81
|
-
|
|
59
|
+
const defaultVisibilityHandler = (0, core_react_1.useDisposable)((0, react_1.useCallback)(() => new CategoryVisibilityHandler_1.CategoryVisibilityHandler({ viewManager, imodel, categories, activeView, allViewports }), [viewManager, imodel, categories, activeView, allViewports]));
|
|
82
60
|
// istanbul ignore next
|
|
83
|
-
visibilityHandler ??
|
|
61
|
+
return visibilityHandler ?? defaultVisibilityHandler;
|
|
84
62
|
}
|
|
85
63
|
async function setViewType(activeView) {
|
|
86
|
-
if (!activeView)
|
|
87
|
-
return;
|
|
88
64
|
const view = activeView.view;
|
|
89
65
|
// TODO: remove this eslint rule when tree-widget uses itwinjs-core 4.0.0 version
|
|
90
66
|
const viewType = view.is3d() ? "3d" : "2d"; // eslint-disable-line @itwin/no-internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTree.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTree.tsx"],"names":[],"mappings":";;;;AAAA;;;+FAG+F;AAE/F,sCAAoC;AACpC,iCAA+C;AAC/C,8DAAsF;AACtF,wDAAiD;AACjD,kDAAkD;AAClD,4EAA+E;AAC/E,wEAA4D;AAC5D,oDAAiD;AACjD,8EAA2E;AAC3E,sEAAmI;AACnI,2EAAwE;AAQxE,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB;;;GAGG;AACU,QAAA,kBAAkB,GAAY,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,yDAAyD;AA4ClI;;;GAGG;AACH,SAAgB,YAAY,CAAC,KAAwB;IACnD,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,uDAA6B,EAAC;QACnD,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO,EAAE,0BAAkB;QAC3B,UAAU,EAAE,WAAW;KACxB,CAAC,CAAC;IAEH,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,qBAAqB,EAAE,GAAG,IAAA,mDAA0B,EAAC,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IACnJ,uBAAuB;IACvB,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,yBAAS,CAAC,WAAW,CAAC;IAC/D,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,yBAAyB,EAAE,GAAG,KAAK,C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AK,EAAE,SAAS,EAChB,aAAa,EAAE,gCAAa,CAAC,IAAI,EACjC,aAAa,EAAE,YAAY,EAC3B,YAAY,EAAE,YAAY,EAC1B,mBAAmB,EAAE,IAAI,EACzB,qBAAqB,EAAE,qBAAqB,EAC5C,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,SAAS,EAClE,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,MAAM,EAAE,KAAK,CAAC,MAAM,GACpB,EACD,OAAO,IACJ,CACP,CAAC;AACJ,CAAC;AAnDD,oCAmDC;AAED,SAAS,4BAA4B,CAAC,WAAwB,EAAE,MAAwB,EAAE,UAA0B,EAAE,UAAoB,EAAE,YAAsB,EAAE,iBAA6C;IAC/M,MAAM,wBAAwB,GAAG,IAAA,0BAAa,EAAC,IAAA,mBAAW,EACxD,GAAG,EAAE,CACH,IAAI,qDAAyB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,EAC9F,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAC7D,CAAC;IACF,uBAAuB;IACvB,OAAO,iBAAiB,IAAI,wBAAwB,CAAC;AACvD,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,UAAoB;IAC7C,MAAM,IAAI,GAAG,UAAU,CAAC,IAAwB,CAAC;IACjD,iFAAiF;IACjF,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,yCAAyC;IACrF,MAAM,oCAAY,CAAC,YAAY,CAAC,IAAI,CAAC,0BAAkB,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC9F,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 \"../VisibilityTreeBase.scss\";\nimport { useCallback, useEffect } from \"react\";\nimport { ControlledTree, SelectionMode, useTreeModel } from \"@itwin/components-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { useDisposable } from \"@itwin/core-react\";\nimport { usePresentationTreeNodeLoader } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { VisibilityTreeEventHandler } from \"../VisibilityTreeEventHandler\";\nimport { createVisibilityTreeRenderer, useVisibilityTreeFiltering, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { CategoryVisibilityHandler } from \"./CategoryVisibilityHandler\";\n\nimport type { IModelConnection, SpatialViewState, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { VisibilityTreeFilterInfo } from \"../Common\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\n\nconst PAGING_SIZE = 20;\n\n/**\n * Presentation rules used by ControlledCategoriesTree\n * @internal\n */\nexport const RULESET_CATEGORIES: Ruleset = require(\"./Categories.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\n\n/**\n * Properties for the [[CategoryTree]] component\n * @public\n */\nexport interface CategoryTreeProps {\n /** Flag for accommodating all viewports */\n allViewports?: boolean;\n /** Active viewport */\n activeView: Viewport;\n /**\n * An IModel to pull data from\n */\n iModel: IModelConnection;\n /** Width of the component */\n width: number;\n /** Height of the component */\n height: number;\n /**\n * Information for tree filtering.\n * @alpha\n */\n filterInfo?: VisibilityTreeFilterInfo;\n /**\n * Callback invoked when tree is filtered.\n */\n onFilterApplied?: (filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void;\n /**\n * Available iModel categories\n */\n categories: CategoryInfo[];\n /**\n * Custom category visibility handler to use for testing\n * @internal\n */\n categoryVisibilityHandler?: CategoryVisibilityHandler;\n /**\n * Custom view manager to use for testing\n * @internal\n */\n viewManager?: ViewManager;\n}\n\n/**\n * Tree which displays and manages display of categories contained in an iModel.\n * @public\n */\nexport function CategoryTree(props: CategoryTreeProps) {\n const { nodeLoader } = usePresentationTreeNodeLoader({\n imodel: props.iModel,\n ruleset: RULESET_CATEGORIES,\n pagingSize: PAGING_SIZE,\n });\n\n const { filteredNodeLoader, isFiltering, nodeHighlightingProps } = useVisibilityTreeFiltering(nodeLoader, props.filterInfo, props.onFilterApplied);\n // istanbul ignore next\n const viewManager = props.viewManager ?? IModelApp.viewManager;\n const { activeView, allViewports, categoryVisibilityHandler } = props;\n const visibilityHandler = useCategoryVisibilityHandler(viewManager, props.iModel, props.categories, activeView, allViewports, categoryVisibilityHandler);\n\n useEffect(() => {\n setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [activeView]);\n\n const eventHandler = useDisposable(useCallback(() => new VisibilityTreeEventHandler({\n nodeLoader: filteredNodeLoader,\n visibilityHandler,\n }), [filteredNodeLoader, visibilityHandler]));\n\n const treeModel = useTreeModel(filteredNodeLoader.modelSource);\n const treeRenderer = createVisibilityTreeRenderer({ iconsEnabled: false, descriptionEnabled: true, levelOffset: 10 });\n const overlay = isFiltering ? <div className=\"filteredTreeOverlay\" /> : undefined;\n const filterApplied = filteredNodeLoader !== nodeLoader;\n\n const noFilteredDataRenderer = useCallback(() => {\n return <VisibilityTreeNoFilteredData\n title={TreeWidget.translate(\"categoriesTree.noCategoryFound\")}\n message={TreeWidget.translate(\"categoriesTree.noMatchingCategoryNames\")}\n />;\n }, []);\n\n return (\n <div className=\"tree-widget-visibility-tree-base\">\n <ControlledTree\n nodeLoader={filteredNodeLoader}\n model={treeModel}\n selectionMode={SelectionMode.None}\n eventsHandler={eventHandler}\n treeRenderer={treeRenderer}\n descriptionsEnabled={true}\n nodeHighlightingProps={nodeHighlightingProps}\n noDataRenderer={filterApplied ? noFilteredDataRenderer : undefined}\n width={props.width}\n height={props.height}\n />\n {overlay}\n </div>\n );\n}\n\nfunction useCategoryVisibilityHandler(viewManager: ViewManager, imodel: IModelConnection, categories: CategoryInfo[], activeView: Viewport, allViewports?: boolean, visibilityHandler?: CategoryVisibilityHandler) {\n const defaultVisibilityHandler = useDisposable(useCallback(\n () =>\n new CategoryVisibilityHandler({ viewManager, imodel, categories, activeView, allViewports }),\n [viewManager, imodel, categories, activeView, allViewports]),\n );\n // istanbul ignore next\n return visibilityHandler ?? defaultVisibilityHandler;\n}\n\nasync function setViewType(activeView: Viewport) {\n const view = activeView.view as SpatialViewState;\n // TODO: remove this eslint rule when tree-widget uses itwinjs-core 4.0.0 version\n const viewType = view.is3d() ? \"3d\" : \"2d\"; // eslint-disable-line @itwin/no-internal\n await Presentation.presentation.vars(RULESET_CATEGORIES.id).setString(\"ViewType\", viewType);\n}\n"]}
|
|
@@ -1,10 +1,71 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "../VisibilityTreeBase.scss";
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import type { TreeHeaderButtonProps } from "../../tree-header/TreeHeader";
|
|
4
|
+
import type { CategoryTreeProps } from "./CategoriesTree";
|
|
5
|
+
import type { CategoryInfo } from "./CategoryVisibilityHandler";
|
|
6
|
+
/**
|
|
7
|
+
* Props that get passed to [[CategoriesTreeComponent]] header button renderer.
|
|
8
|
+
* @see CategoriesTreeComponentProps.headerButtons
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export interface CategoriesTreeHeaderButtonProps extends TreeHeaderButtonProps {
|
|
12
|
+
/** A list of categories available in the iModel */
|
|
13
|
+
categories: CategoryInfo[];
|
|
14
|
+
/** In case the tree is filtered, a list of filtered categories. */
|
|
15
|
+
filteredCategories?: CategoryInfo[];
|
|
9
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Props for [[CategoriesTreeComponent]].
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export interface CategoriesTreeComponentProps extends Omit<CategoryTreeProps, "iModel" | "activeView" | "width" | "height" | "filterInfo" | "onFilterApplied" | "categories" | "categoryVisibilityHandler" | "viewManager"> {
|
|
22
|
+
/**
|
|
23
|
+
* Renderers of header buttons. Defaults to:
|
|
24
|
+
* ```ts
|
|
25
|
+
* [
|
|
26
|
+
* CategoriesTreeComponent.ShowAllButton,
|
|
27
|
+
* CategoriesTreeComponent.HideAllButton,
|
|
28
|
+
* CategoriesTreeComponent.InvertAllButton,
|
|
29
|
+
* ]
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
headerButtons?: Array<(props: CategoriesTreeHeaderButtonProps) => React.ReactNode>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A component that renders [[CategoriesTree]] and a header with filtering capabilities
|
|
36
|
+
* and header buttons.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare const CategoriesTreeComponent: {
|
|
40
|
+
(props: CategoriesTreeComponentProps): JSX.Element | null;
|
|
41
|
+
/**
|
|
42
|
+
* Renders a "Show all" button that enables display of all categories and their subcategories.
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
ShowAllButton: typeof ShowAllButton;
|
|
46
|
+
/**
|
|
47
|
+
* Renders a "Hide all" button that disables display of all categories.
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
HideAllButton: typeof HideAllButton;
|
|
51
|
+
/**
|
|
52
|
+
* Renders an "Invert all" button that inverts display of all categories.
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
InvertAllButton: typeof InvertAllButton;
|
|
56
|
+
/**
|
|
57
|
+
* Id of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
id: string;
|
|
61
|
+
/**
|
|
62
|
+
* Label of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
getLabel(): string;
|
|
66
|
+
};
|
|
67
|
+
declare function ShowAllButton(props: CategoriesTreeHeaderButtonProps): JSX.Element;
|
|
68
|
+
declare function HideAllButton(props: CategoriesTreeHeaderButtonProps): JSX.Element;
|
|
69
|
+
declare function InvertAllButton(props: CategoriesTreeHeaderButtonProps): JSX.Element;
|
|
70
|
+
export {};
|
|
10
71
|
//# sourceMappingURL=CategoriesTreeComponent.d.ts.map
|
|
@@ -1,116 +1,105 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
3
|
exports.CategoriesTreeComponent = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
23
5
|
/*---------------------------------------------------------------------------------------------
|
|
24
6
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
25
7
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
26
8
|
*--------------------------------------------------------------------------------------------*/
|
|
27
9
|
require("../VisibilityTreeBase.scss");
|
|
28
|
-
const react_1 =
|
|
10
|
+
const react_1 = require("react");
|
|
29
11
|
const appui_react_1 = require("@itwin/appui-react");
|
|
30
12
|
const core_frontend_1 = require("@itwin/core-frontend");
|
|
31
13
|
const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
|
|
32
14
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
33
15
|
const presentation_components_1 = require("@itwin/presentation-components");
|
|
34
16
|
const TreeWidget_1 = require("../../../TreeWidget");
|
|
35
|
-
const
|
|
17
|
+
const TreeHeader_1 = require("../../tree-header/TreeHeader");
|
|
36
18
|
const TreeFilteringState_1 = require("../../TreeFilteringState");
|
|
37
19
|
const AutoSizer_1 = require("../../utils/AutoSizer");
|
|
38
|
-
const CategoriesVisibilityUtils_1 = require("../CategoriesVisibilityUtils");
|
|
39
20
|
const CategoriesTree_1 = require("./CategoriesTree");
|
|
40
21
|
const CategoryVisibilityHandler_1 = require("./CategoryVisibilityHandler");
|
|
41
|
-
|
|
22
|
+
/**
|
|
23
|
+
* A component that renders [[CategoriesTree]] and a header with filtering capabilities
|
|
24
|
+
* and header buttons.
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
const CategoriesTreeComponent = (props) => {
|
|
42
28
|
const iModel = (0, appui_react_1.useActiveIModelConnection)();
|
|
43
29
|
const viewport = (0, appui_react_1.useActiveViewport)();
|
|
44
30
|
if (!iModel || !viewport) {
|
|
45
31
|
return null;
|
|
46
32
|
}
|
|
47
|
-
return (
|
|
48
|
-
}
|
|
33
|
+
return ((0, jsx_runtime_1.jsx)(CategoriesTreeComponentImpl, { ...props, iModel: iModel, viewport: viewport }));
|
|
34
|
+
};
|
|
49
35
|
exports.CategoriesTreeComponent = CategoriesTreeComponent;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Renders a "Show all" button that enables display of all categories and their subcategories.
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
exports.CategoriesTreeComponent.ShowAllButton = ShowAllButton;
|
|
41
|
+
/**
|
|
42
|
+
* Renders a "Hide all" button that disables display of all categories.
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
exports.CategoriesTreeComponent.HideAllButton = HideAllButton;
|
|
46
|
+
/**
|
|
47
|
+
* Renders an "Invert all" button that inverts display of all categories.
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
exports.CategoriesTreeComponent.InvertAllButton = InvertAllButton;
|
|
51
|
+
/**
|
|
52
|
+
* Id of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
exports.CategoriesTreeComponent.id = "categories-tree";
|
|
56
|
+
/**
|
|
57
|
+
* Label of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
exports.CategoriesTreeComponent.getLabel = () => TreeWidget_1.TreeWidget.translate("categories");
|
|
53
61
|
function CategoriesTreeComponentImpl(props) {
|
|
54
62
|
const categories = (0, CategoryVisibilityHandler_1.useCategories)(core_frontend_1.IModelApp.viewManager, props.iModel, props.viewport);
|
|
55
63
|
const [filteredCategories, setFilteredCategories] = (0, react_1.useState)();
|
|
56
|
-
const { searchOptions, filterString,
|
|
64
|
+
const { searchOptions, filterString, onFilterApplied, filteredProvider, } = (0, TreeFilteringState_1.useTreeFilteringState)();
|
|
57
65
|
(0, react_1.useEffect)(() => {
|
|
58
66
|
(async () => {
|
|
59
67
|
if (filteredProvider)
|
|
60
|
-
setFilteredCategories((await getFilteredCategories(filteredProvider))
|
|
68
|
+
setFilteredCategories((await getFilteredCategories(filteredProvider)));
|
|
61
69
|
else
|
|
62
70
|
setFilteredCategories(undefined);
|
|
63
71
|
})();
|
|
64
72
|
}, [filteredProvider]);
|
|
65
|
-
return (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
]),
|
|
73
|
-
react_1.default.createElement(AutoSizer_1.AutoSizer, null, ({ width, height }) => (react_1.default.createElement(CategoriesTree_1.CategoryTree, { ...props, categories: categories, width: width, height: height, filterInfo: { filter: filterString, activeMatchIndex }, onFilterApplied: onFilterApplied })))));
|
|
73
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "tree-widget-tree-with-header", children: [(0, jsx_runtime_1.jsx)(TreeHeader_1.TreeHeader, { onFilterClear: searchOptions.onFilterCancel, onFilterStart: searchOptions.onFilterStart, onSelectedChanged: searchOptions.onResultSelectedChanged, resultCount: searchOptions.matchedResultCount, selectedIndex: searchOptions.activeMatchIndex, children: props.headerButtons
|
|
74
|
+
? props.headerButtons.map((btn, index) => (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: btn({ viewport: props.viewport, categories, filteredCategories }) }, index))
|
|
75
|
+
: [
|
|
76
|
+
(0, jsx_runtime_1.jsx)(ShowAllButton, { viewport: props.viewport, categories: categories, filteredCategories: filteredCategories }, "show-all-btn"),
|
|
77
|
+
(0, jsx_runtime_1.jsx)(HideAllButton, { viewport: props.viewport, categories: categories, filteredCategories: filteredCategories }, "hide-all-btn"),
|
|
78
|
+
(0, jsx_runtime_1.jsx)(InvertAllButton, { viewport: props.viewport, categories: categories, filteredCategories: filteredCategories }, "invert-all-btn"),
|
|
79
|
+
] }), (0, jsx_runtime_1.jsx)("div", { className: "tree-widget-tree-content", children: (0, jsx_runtime_1.jsx)(AutoSizer_1.AutoSizer, { children: ({ width, height }) => ((0, jsx_runtime_1.jsx)(CategoriesTree_1.CategoryTree, { ...props, categories: categories, width: width, height: height, filterInfo: { filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }, onFilterApplied: onFilterApplied, activeView: props.viewport })) }) })] }));
|
|
74
80
|
}
|
|
75
81
|
async function getFilteredCategories(filteredProvider) {
|
|
82
|
+
const filteredCategories = [];
|
|
76
83
|
const nodes = await filteredProvider.getNodes();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
for (const node of nodes) {
|
|
85
|
+
if (!(0, presentation_components_1.isPresentationTreeNodeItem)(node)) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const filteredCategoryId = CategoryVisibilityHandler_1.CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(node.key);
|
|
89
|
+
const filteredSubCategoriesIds = node.hasChildren
|
|
90
|
+
? (await filteredProvider.getNodes(node)).filter(presentation_components_1.isPresentationTreeNodeItem).map((child) => CategoryVisibilityHandler_1.CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(child.key))
|
|
91
|
+
: [];
|
|
92
|
+
filteredCategories.push({ categoryId: filteredCategoryId, subCategoryIds: filteredSubCategoriesIds });
|
|
93
|
+
}
|
|
94
|
+
return filteredCategories;
|
|
80
95
|
}
|
|
81
96
|
function ShowAllButton(props) {
|
|
82
|
-
|
|
83
|
-
await (0, CategoriesVisibilityUtils_1.enableCategory)(core_frontend_1.IModelApp.viewManager, props.viewport.iModel, (props.filteredCategories ?? props.categories).map((category) => category.categoryId), true, true);
|
|
84
|
-
};
|
|
85
|
-
return (react_1.default.createElement(itwinui_react_1.IconButton, { className: "tree-widget-header-tree-toolbar-icon", size: "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("showAll"), onClick: showAll },
|
|
86
|
-
react_1.default.createElement(itwinui_icons_react_1.SvgVisibilityShow, null)));
|
|
97
|
+
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("showAll"), onClick: () => void (0, CategoryVisibilityHandler_1.showAllCategories)((props.filteredCategories ?? props.categories).map((category) => category.categoryId), props.viewport), children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityShow, {}) }));
|
|
87
98
|
}
|
|
88
99
|
function HideAllButton(props) {
|
|
89
|
-
|
|
90
|
-
await (0, CategoriesVisibilityUtils_1.enableCategory)(core_frontend_1.IModelApp.viewManager, props.viewport.iModel, (props.filteredCategories ?? props.categories).map((category) => category.categoryId), false, true);
|
|
91
|
-
};
|
|
92
|
-
return (react_1.default.createElement(itwinui_react_1.IconButton, { className: "tree-widget-header-tree-toolbar-icon", size: "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("hideAll"), onClick: hideAll },
|
|
93
|
-
react_1.default.createElement(itwinui_icons_react_1.SvgVisibilityHide, null)));
|
|
100
|
+
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("hideAll"), onClick: () => void (0, CategoryVisibilityHandler_1.hideAllCategories)((props.filteredCategories ?? props.categories).map((category) => category.categoryId), props.viewport), children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityHide, {}) }));
|
|
94
101
|
}
|
|
95
|
-
function
|
|
96
|
-
|
|
97
|
-
const ids = (props.filteredCategories ?? props.categories).map((category) => category.categoryId);
|
|
98
|
-
const enabled = [];
|
|
99
|
-
const disabled = [];
|
|
100
|
-
for (const id of ids) {
|
|
101
|
-
if (props.viewport.view.viewsCategory(id)) {
|
|
102
|
-
enabled.push(id);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
disabled.push(id);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
// Disable enabled
|
|
109
|
-
await (0, CategoriesVisibilityUtils_1.enableCategory)(core_frontend_1.IModelApp.viewManager, props.viewport.iModel, enabled, false, true);
|
|
110
|
-
// Enable disabled
|
|
111
|
-
await (0, CategoriesVisibilityUtils_1.enableCategory)(core_frontend_1.IModelApp.viewManager, props.viewport.iModel, disabled, true, true);
|
|
112
|
-
};
|
|
113
|
-
return (react_1.default.createElement(itwinui_react_1.IconButton, { className: "tree-widget-header-tree-toolbar-icon", title: TreeWidget_1.TreeWidget.translate("invert"), size: "small", styleType: "borderless", onClick: invert },
|
|
114
|
-
react_1.default.createElement(itwinui_icons_react_1.SvgVisibilityHalf, null)));
|
|
102
|
+
function InvertAllButton(props) {
|
|
103
|
+
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { title: TreeWidget_1.TreeWidget.translate("invert"), size: "small", styleType: "borderless", onClick: () => void (0, CategoryVisibilityHandler_1.invertAllCategories)(props.filteredCategories ?? props.categories, props.viewport), children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityHalf, {}) }));
|
|
115
104
|
}
|
|
116
105
|
//# sourceMappingURL=CategoriesTreeComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTreeComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,sCAAoC;AACpC,+CAAmD;AACnD,oDAAkF;AAClF,wDAAmF;AACnF,oEAAqG;AACrG,wDAAkD;AAClD,4EAAqI;AACrI,oDAAiD;AACjD,0DAAuD;AACvD,iEAAiE;AACjE,qDAAkD;AAClD,4EAA8D;AAC9D,qDAAgD;AAChD,2EAAqG;AAIrG,SAAgB,uBAAuB,CAAC,KAA0B;IAChE,MAAM,MAAM,GAAG,IAAA,uCAAyB,GAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,IAAA,+BAAiB,GAAE,CAAC;IAErC,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE;QACxB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,8BAAC,2BAA2B,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAC/E,CAAC;AACJ,CAAC;AAXD,0DAWC;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V,CACd,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*--------------------------------------------------------------------------------------------*/\nimport \"../VisibilityTreeBase.scss\";\nimport React, { useEffect, useState } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { IModelApp, IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { IconButton } from \"@itwin/itwinui-react\";\nimport { IPresentationTreeDataProvider, isPresentationTreeNodeItem, PresentationTreeNodeItem } from \"@itwin/presentation-components\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { SearchBar } from \"../../search-bar/SearchBar\";\nimport { useTreeFilteringState } from \"../../TreeFilteringState\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { enableCategory } from \"../CategoriesVisibilityUtils\";\nimport { CategoryTree } from \"./CategoriesTree\";\nimport { CategoryInfo, CategoryVisibilityHandler, useCategories } from \"./CategoryVisibilityHandler\";\n\nimport type { CategoriesTreeHeaderButtonProps, CategoriesTreeProps } from \"../../../types\";\n\nexport function CategoriesTreeComponent(props: CategoriesTreeProps) {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return (\n <CategoriesTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />\n );\n}\n\nCategoriesTreeComponent.ShowAllButton = ShowAllButton;\nCategoriesTreeComponent.HideAllButton = HideAllButton;\nCategoriesTreeComponent.InvertButton = InvertButton;\n\nfunction CategoriesTreeComponentImpl(props: CategoriesTreeProps & { iModel: IModelConnection, viewport: ScreenViewport }) {\n const categories = useCategories(IModelApp.viewManager, props.iModel, props.viewport);\n const [filteredCategories, setFilteredCategories] = useState<CategoryInfo[]>();\n const {\n searchOptions,\n filterString,\n activeMatchIndex,\n onFilterApplied,\n filteredProvider,\n } = useTreeFilteringState();\n\n useEffect(() => {\n (async () => {\n if (filteredProvider)\n setFilteredCategories((await getFilteredCategories(filteredProvider)).map((category) => ({ categoryId: category })));\n else\n setFilteredCategories(undefined);\n })();\n }, [filteredProvider]);\n\n return (\n <>\n <SearchBar\n value=\"\"\n valueChangedDelay={500}\n placeholder={TreeWidget.translate(\"search\")}\n title={TreeWidget.translate(\"searchForSomething\")}\n filteringInProgress={searchOptions.isFiltering}\n onFilterClear={searchOptions.onFilterCancel}\n onFilterStart={searchOptions.onFilterStart}\n onSelectedChanged={searchOptions.onResultSelectedChanged}\n resultCount={searchOptions.matchedResultCount ?? 0}\n >\n {props.headerButtons\n ? props.headerButtons.map((btn, index) =>\n <React.Fragment key={index}>\n {btn({ viewport: props.viewport, categories, filteredCategories })}\n </React.Fragment>)\n : [\n <ShowAllButton viewport={props.viewport} categories={categories} filteredCategories={filteredCategories} key=\"show-all-btn\" />,\n <HideAllButton viewport={props.viewport} categories={categories} filteredCategories={filteredCategories} key=\"hide-all-btn\" />,\n <InvertButton viewport={props.viewport} categories={categories} filteredCategories={filteredCategories} key=\"invert-all-btn\" />,\n ]\n }\n </SearchBar>\n <AutoSizer>\n {({ width, height }) => (\n <CategoryTree\n {...props}\n categories={categories}\n width={width}\n height={height}\n filterInfo={{ filter: filterString, activeMatchIndex }}\n onFilterApplied={onFilterApplied}\n />\n )}\n </AutoSizer>\n </>\n );\n}\n\nasync function getFilteredCategories(filteredProvider: IPresentationTreeDataProvider) {\n const nodes = await filteredProvider.getNodes();\n return nodes\n .filter((node) => isPresentationTreeNodeItem(node))\n .map((node) => CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey((node as PresentationTreeNodeItem).key));\n}\n\nfunction ShowAllButton(props: CategoriesTreeHeaderButtonProps) {\n const showAll = async () => {\n await enableCategory(\n IModelApp.viewManager,\n props.viewport.iModel,\n (props.filteredCategories ?? props.categories).map((category) => category.categoryId),\n true,\n true,\n );\n };\n\n return (\n <IconButton\n className=\"tree-widget-header-tree-toolbar-icon\"\n size=\"small\"\n styleType=\"borderless\"\n title={TreeWidget.translate(\"showAll\")}\n onClick={showAll}\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\nfunction HideAllButton(props: CategoriesTreeHeaderButtonProps) {\n const hideAll = async () => {\n await enableCategory(\n IModelApp.viewManager,\n props.viewport.iModel,\n (props.filteredCategories ?? props.categories).map((category) => category.categoryId),\n false,\n true,\n );\n };\n\n return (\n <IconButton\n className=\"tree-widget-header-tree-toolbar-icon\"\n size=\"small\"\n styleType=\"borderless\"\n title={TreeWidget.translate(\"hideAll\")}\n onClick={hideAll}\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\nfunction InvertButton(props: CategoriesTreeHeaderButtonProps) {\n const invert = async () => {\n const ids = (props.filteredCategories ?? props.categories).map((category) => category.categoryId);\n\n const enabled: string[] = [];\n const disabled: string[] = [];\n for (const id of ids) {\n if (props.viewport.view.viewsCategory(id)) {\n enabled.push(id);\n } else {\n disabled.push(id);\n }\n }\n // Disable enabled\n await enableCategory(\n IModelApp.viewManager,\n props.viewport.iModel,\n enabled,\n false,\n true\n );\n\n // Enable disabled\n await enableCategory(\n IModelApp.viewManager,\n props.viewport.iModel,\n disabled,\n true,\n true\n );\n };\n\n return (\n <IconButton\n className=\"tree-widget-header-tree-toolbar-icon\"\n title={TreeWidget.translate(\"invert\")}\n size=\"small\"\n styleType=\"borderless\"\n onClick={invert}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CategoriesTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTreeComponent.tsx"],"names":[],"mappings":";;;;AAAA;;;+FAG+F;AAE/F,sCAAoC;AACpC,iCAAsD;AACtD,oDAAkF;AAClF,wDAAiD;AACjD,oEAAqG;AACrG,wDAAkD;AAClD,4EAA4E;AAC5E,oDAAiD;AAC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AC,YAAY,EACtB,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,SAAS,CAAC,EACtC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,IAAA,6CAAiB,EAAC,CAAC,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,YAE5I,uBAAC,uCAAiB,KAAG,GACV,CACd,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,KAAsC;IAC3D,OAAO,CACL,uBAAC,0BAAU,IACT,IAAI,EAAC,OAAO,EACZ,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,SAAS,CAAC,EACtC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,IAAA,6CAAiB,EAAC,CAAC,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,YAE5I,uBAAC,uCAAiB,KAAG,GACV,CACd,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,KAAsC;IAC7D,OAAO,CACL,uBAAC,0BAAU,IACT,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,EACrC,IAAI,EAAC,OAAO,EACZ,SAAS,EAAC,YAAY,EACtB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,IAAA,+CAAmB,EAAC,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,YAErG,uBAAC,uCAAiB,KAAG,GACV,CACd,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 \"../VisibilityTreeBase.scss\";\nimport { Fragment, useEffect, useState } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { IconButton } from \"@itwin/itwinui-react\";\nimport { isPresentationTreeNodeItem } from \"@itwin/presentation-components\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeHeader } from \"../../tree-header/TreeHeader\";\nimport { useTreeFilteringState } from \"../../TreeFilteringState\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { CategoryTree } from \"./CategoriesTree\";\nimport { CategoryVisibilityHandler, hideAllCategories, invertAllCategories, showAllCategories, useCategories } from \"./CategoryVisibilityHandler\";\n\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\nimport type { CategoryTreeProps } from \"./CategoriesTree\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\n\n/**\n * Props that get passed to [[CategoriesTreeComponent]] header button renderer.\n * @see CategoriesTreeComponentProps.headerButtons\n * @public\n */\nexport interface CategoriesTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of categories available in the iModel */\n categories: CategoryInfo[];\n /** In case the tree is filtered, a list of filtered categories. */\n filteredCategories?: CategoryInfo[];\n}\n\n/**\n * Props for [[CategoriesTreeComponent]].\n * @public\n */\nexport interface CategoriesTreeComponentProps extends Omit<CategoryTreeProps,\n| \"iModel\"\n| \"activeView\"\n| \"width\"\n| \"height\"\n| \"filterInfo\"\n| \"onFilterApplied\"\n| \"categories\"\n| \"categoryVisibilityHandler\"\n| \"viewManager\"\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}\n\n/**\n * A component that renders [[CategoriesTree]] and a header with filtering capabilities\n * 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 (\n <CategoriesTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />\n );\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 [[TreeWidgetComponent]].\n * @public\n */\nCategoriesTreeComponent.id = \"categories-tree\";\n\n/**\n * Label of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].\n * @public\n */\nCategoriesTreeComponent.getLabel = () => TreeWidget.translate(\"categories\");\n\nfunction CategoriesTreeComponentImpl(props: CategoriesTreeComponentProps & { iModel: IModelConnection, viewport: ScreenViewport }) {\n const categories = useCategories(IModelApp.viewManager, props.iModel, props.viewport);\n const [filteredCategories, setFilteredCategories] = useState<CategoryInfo[]>();\n const {\n searchOptions,\n filterString,\n onFilterApplied,\n filteredProvider,\n } = useTreeFilteringState();\n\n useEffect(() => {\n (async () => {\n if (filteredProvider)\n setFilteredCategories((await getFilteredCategories(filteredProvider)));\n else\n setFilteredCategories(undefined);\n })();\n }, [filteredProvider]);\n\n return (\n <div className=\"tree-widget-tree-with-header\">\n <TreeHeader\n onFilterClear={searchOptions.onFilterCancel}\n onFilterStart={searchOptions.onFilterStart}\n onSelectedChanged={searchOptions.onResultSelectedChanged}\n resultCount={searchOptions.matchedResultCount}\n selectedIndex={searchOptions.activeMatchIndex}\n >\n {props.headerButtons\n ? props.headerButtons.map(\n (btn, index) =>\n <Fragment key={index}>\n {btn({ viewport: props.viewport, categories, filteredCategories })}\n </Fragment>\n )\n : [\n <ShowAllButton viewport={props.viewport} categories={categories} filteredCategories={filteredCategories} key=\"show-all-btn\" />,\n <HideAllButton viewport={props.viewport} categories={categories} filteredCategories={filteredCategories} key=\"hide-all-btn\" />,\n <InvertAllButton viewport={props.viewport} categories={categories} filteredCategories={filteredCategories} key=\"invert-all-btn\" />,\n ]\n }\n </TreeHeader>\n <div className=\"tree-widget-tree-content\">\n <AutoSizer>\n {({ width, height }) => (\n <CategoryTree\n {...props}\n categories={categories}\n width={width}\n height={height}\n filterInfo={{ filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }}\n onFilterApplied={onFilterApplied}\n activeView={props.viewport}\n />\n )}\n </AutoSizer>\n </div>\n </div>\n );\n}\n\nasync function getFilteredCategories(filteredProvider: IPresentationTreeDataProvider) {\n const filteredCategories: CategoryInfo[] = [];\n const nodes = await filteredProvider.getNodes();\n for (const node of nodes) {\n if (!isPresentationTreeNodeItem(node)) {\n continue;\n }\n const filteredCategoryId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(node.key);\n const filteredSubCategoriesIds = node.hasChildren\n ? (await filteredProvider.getNodes(node)).filter(isPresentationTreeNodeItem).map((child) => CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(child.key))\n : [];\n filteredCategories.push({ categoryId: filteredCategoryId, subCategoryIds: filteredSubCategoriesIds });\n }\n return filteredCategories;\n}\n\nfunction ShowAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size=\"small\"\n styleType=\"borderless\"\n title={TreeWidget.translate(\"showAll\")}\n onClick={() => void showAllCategories((props.filteredCategories ?? props.categories).map((category) => category.categoryId), props.viewport)}\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\nfunction HideAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size=\"small\"\n styleType=\"borderless\"\n title={TreeWidget.translate(\"hideAll\")}\n onClick={() => void hideAllCategories((props.filteredCategories ?? props.categories).map((category) => category.categoryId), props.viewport)}\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\nfunction InvertAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n title={TreeWidget.translate(\"invert\")}\n size=\"small\"\n styleType=\"borderless\"\n onClick={() => void invertAllCategories(props.filteredCategories ?? props.categories, props.viewport)}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n"]}
|