@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
|
@@ -10,7 +10,7 @@ const core_frontend_1 = require("@itwin/core-frontend");
|
|
|
10
10
|
const EMPTY_CATEGORIES_ARRAY = [];
|
|
11
11
|
/**
|
|
12
12
|
* Toggles visibility of categories to show or hide.
|
|
13
|
-
* @
|
|
13
|
+
* @internal
|
|
14
14
|
*/
|
|
15
15
|
async function toggleAllCategories(viewManager, imodel, display, viewport, forAllViewports) {
|
|
16
16
|
// istanbul ignore next
|
|
@@ -24,14 +24,17 @@ async function toggleAllCategories(viewManager, imodel, display, viewport, forAl
|
|
|
24
24
|
exports.toggleAllCategories = toggleAllCategories;
|
|
25
25
|
/**
|
|
26
26
|
* Gets ids of all categories from specified imodel and viewport.
|
|
27
|
-
* @
|
|
27
|
+
* @internal
|
|
28
28
|
*/
|
|
29
29
|
async function getCategories(imodel, viewport) {
|
|
30
30
|
const categories = await loadCategoriesFromViewport(imodel, viewport);
|
|
31
31
|
return categories.map((category) => category.categoryId);
|
|
32
32
|
}
|
|
33
33
|
exports.getCategories = getCategories;
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Changes category display in the viewport.
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
35
38
|
async function enableCategory(viewManager, imodel, ids, enabled, forAllViewports, enableAllSubCategories = true) {
|
|
36
39
|
if (!viewManager.selectedView)
|
|
37
40
|
return;
|
|
@@ -67,7 +70,10 @@ async function enableCategory(viewManager, imodel, ids, enabled, forAllViewports
|
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
72
|
exports.enableCategory = enableCategory;
|
|
70
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Changes subcategory display in the viewport
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
71
77
|
function enableSubCategory(viewManager, key, enabled, forAllViewports) {
|
|
72
78
|
if (!viewManager.selectedView)
|
|
73
79
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesVisibilityUtils.js","sourceRoot":"","sources":["../../../../src/components/trees/CategoriesVisibilityUtils.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,oDAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"CategoriesVisibilityUtils.js","sourceRoot":"","sources":["../../../../src/components/trees/CategoriesVisibilityUtils.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,oDAAoD;AACpD,wDAAkE;AAKlE,MAAM,sBAAsB,GAAmB,EAAE,CAAC;AAElD;;;GAGG;AACI,KAAK,UAAU,mBAAmB,CAAC,WAAwB,EAAE,MAAwB,EAAE,OAAgB,EAAE,QAAmB,EAAE,eAAyB;IAC5J,uBAAuB;IACvB,MAAM,UAAU,GAAG,QAAQ,IAAI,WAAW,CAAC,gBAAgB,EAAE,CAAC;IAC9D,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAEpD,qBAAqB;IACrB,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;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AC9H,CAAC,CAAC,CAAC;KACJ;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AApBD,gEAoBC","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 { QueryRowFormat } from \"@itwin/core-common\";\nimport { PerModelCategoryVisibility } from \"@itwin/core-frontend\";\n\nimport type { IModelConnection, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { CategoryInfo } from \"./category-tree/CategoryVisibilityHandler\";\n\nconst EMPTY_CATEGORIES_ARRAY: CategoryInfo[] = [];\n\n/**\n * Toggles visibility of categories to show or hide.\n * @internal\n */\nexport async function toggleAllCategories(viewManager: ViewManager, imodel: IModelConnection, display: boolean, viewport?: Viewport, forAllViewports?: boolean) {\n // istanbul ignore next\n const activeView = viewport ?? viewManager.getFirstOpenView();\n const ids = await getCategories(imodel, activeView);\n\n // istanbul ignore if\n if (ids.length === 0)\n return;\n\n await enableCategory(viewManager, imodel, ids, display, forAllViewports ?? false);\n}\n\n/**\n * Gets ids of all categories from specified imodel and viewport.\n * @internal\n */\nexport async function getCategories(imodel: IModelConnection, viewport?: Viewport) {\n const categories = await loadCategoriesFromViewport(imodel, viewport);\n return categories.map((category) => category.categoryId);\n}\n\n/**\n * Changes category display in the viewport.\n * @internal\n */\nexport async function enableCategory(viewManager: ViewManager, imodel: IModelConnection, ids: string[], enabled: boolean, forAllViewports: boolean, enableAllSubCategories = true) {\n if (!viewManager.selectedView)\n return;\n\n const updateViewport = async (vp: Viewport) => {\n // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we\n // are using 'allViewports' property\n if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {\n vp.changeCategoryDisplay(ids, enabled, enableAllSubCategories);\n\n // remove category overrides per model\n const modelsContainingOverrides: string[] = [];\n for (const ovr of vp.perModelCategoryVisibility) {\n // istanbul ignore else\n if (ids.findIndex((id) => id === ovr.categoryId) !== -1)\n modelsContainingOverrides.push(ovr.modelId);\n }\n vp.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, PerModelCategoryVisibility.Override.None);\n\n // changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.\n if (false === enabled) {\n (await imodel.categories.getCategoryInfo(ids)).forEach((categoryInfo) => {\n categoryInfo.subCategories.forEach((value) => enableSubCategory(viewManager, value.id, false, forAllViewports));\n });\n }\n }\n };\n\n // This property let us act on all viewports or just on the selected one, configurable by the app\n if (forAllViewports) {\n for (const viewport of viewManager) {\n await updateViewport(viewport);\n }\n } else {\n await updateViewport(viewManager.selectedView);\n }\n}\n\n/**\n * Changes subcategory display in the viewport\n * @internal\n */\nexport function enableSubCategory(viewManager: ViewManager, key: string, enabled: boolean, forAllViewports?: boolean) {\n if (!viewManager.selectedView)\n return;\n\n const updateViewport = (vp: Viewport) => {\n // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we\n // are using 'allViewports' property\n if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {\n vp.changeSubCategoryDisplay(key, enabled);\n }\n };\n\n // This property let us act on all viewports or just on the selected one, configurable by the app\n if (forAllViewports) {\n for (const viewport of viewManager) {\n updateViewport(viewport);\n }\n } else {\n updateViewport(viewManager.selectedView);\n }\n}\n\n/** @internal */\nexport async function loadCategoriesFromViewport(iModel?: IModelConnection, vp?: Viewport) {\n if (!vp)\n return EMPTY_CATEGORIES_ARRAY;\n\n // Query categories and add them to state\n const selectUsedSpatialCategoryIds = \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)\";\n const selectUsedDrawingCategoryIds = \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement2d WHERE Model.Id=? AND Category.Id IN (SELECT ECInstanceId from BisCore.DrawingCategory)\";\n const ecsql = vp.view.is3d() ? selectUsedSpatialCategoryIds : selectUsedDrawingCategoryIds;\n const ecsql2 = `SELECT ECInstanceId as id FROM ${vp.view.is3d() ? \"BisCore.SpatialCategory\" : \"BisCore.DrawingCategory\"} WHERE ECInstanceId IN (${ecsql})`;\n\n const categories: CategoryInfo[] = [];\n\n // istanbul ignore else\n if (iModel) {\n const rows = await iModel.createQueryReader(ecsql2, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }).toArray();\n (await iModel.categories.getCategoryInfo(rows.map((row) => row.id))).forEach((val) => {\n categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });\n });\n }\n return categories;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* An option of how class grouping should work in a component.
|
|
3
|
-
* @
|
|
3
|
+
* @public
|
|
4
4
|
*/
|
|
5
5
|
export declare enum ClassGroupingOption {
|
|
6
6
|
/** Class grouping is disabled */
|
|
@@ -12,7 +12,7 @@ export declare enum ClassGroupingOption {
|
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Data structure that describes info used to filter visibility tree.
|
|
15
|
-
* @
|
|
15
|
+
* @public
|
|
16
16
|
*/
|
|
17
17
|
export interface VisibilityTreeFilterInfo {
|
|
18
18
|
filter: string;
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.ClassGroupingOption = void 0;
|
|
8
8
|
/**
|
|
9
9
|
* An option of how class grouping should work in a component.
|
|
10
|
-
* @
|
|
10
|
+
* @public
|
|
11
11
|
*/
|
|
12
12
|
var ClassGroupingOption;
|
|
13
13
|
(function (ClassGroupingOption) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Common.js","sourceRoot":"","sources":["../../../../src/components/trees/Common.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;;GAGG;AACH,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAC7B,iCAAiC;IACjC,yDAAE,CAAA;IACF,gCAAgC;IAChC,2DAAG,CAAA;IACH,4EAA4E;IAC5E,+EAAa,CAAA;AACf,CAAC,EAPW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAO9B","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 * An option of how class grouping should work in a component.\n * @
|
|
1
|
+
{"version":3,"file":"Common.js","sourceRoot":"","sources":["../../../../src/components/trees/Common.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;;GAGG;AACH,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAC7B,iCAAiC;IACjC,yDAAE,CAAA;IACF,gCAAgC;IAChC,2DAAG,CAAA;IACH,4EAA4E;IAC5E,+EAAa,CAAA;AACf,CAAC,EAPW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAO9B","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 * An option of how class grouping should work in a component.\n * @public\n */\nexport enum ClassGroupingOption {\n /** Class grouping is disabled */\n No,\n /** Class grouping is enabled */\n Yes,\n /** Class grouping is enabled and grouping node shows grouped items count */\n YesWithCounts,\n}\n\n/**\n * Data structure that describes info used to filter visibility tree.\n * @public\n */\nexport interface VisibilityTreeFilterInfo {\n filter: string;\n activeMatchIndex?: number;\n}\n"]}
|
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
|
|
6
|
+
.tree-widget-tree-with-header {
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: 100%;
|
|
9
|
+
|
|
10
|
+
.tree-widget-tree-header {
|
|
11
|
+
height: var(--iui-size-xl);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.tree-widget-tree-content {
|
|
15
|
+
height: calc(100% - var(--iui-size-xl));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
6
19
|
.tree-widget-visibility-tree-base {
|
|
7
20
|
height: 100%;
|
|
8
21
|
width: 100%;
|
|
@@ -10,19 +23,63 @@
|
|
|
10
23
|
flex-direction: column;
|
|
11
24
|
position: relative;
|
|
12
25
|
|
|
13
|
-
.
|
|
14
|
-
|
|
15
|
-
|
|
26
|
+
.ReactWindow__VariableSizeList {
|
|
27
|
+
>div {
|
|
28
|
+
min-width: max-content !important; // to override inline class
|
|
16
29
|
}
|
|
17
30
|
}
|
|
31
|
+
.core-tree-node {
|
|
32
|
+
&.with-checkbox {
|
|
33
|
+
>.contents {
|
|
34
|
+
padding-left: calc(var(--iui-size-3xs) / 2);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
18
37
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
38
|
+
&.disable-expander {
|
|
39
|
+
>.contents {
|
|
40
|
+
>.core-tree-expansionToggle {
|
|
41
|
+
display: none;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
23
45
|
|
|
24
|
-
|
|
25
|
-
|
|
46
|
+
&.is-selected {
|
|
47
|
+
>.contents {
|
|
48
|
+
>.visibility-tree-checkbox-container {
|
|
49
|
+
background-color: var(--iui-color-background-accent-muted)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.contents {
|
|
56
|
+
&:hover {
|
|
57
|
+
> .visibility-tree-checkbox-container {
|
|
58
|
+
background-color: var(--iui-color-background-hover);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
> .visibility-tree-checkbox-container {
|
|
63
|
+
height: var(--iui-size-l);
|
|
64
|
+
width: var(--iui-size-l);
|
|
65
|
+
position: sticky;
|
|
66
|
+
order: -1;
|
|
67
|
+
left: 0;
|
|
68
|
+
background-color: var(--iui-color-background);
|
|
69
|
+
z-index: 1;
|
|
70
|
+
display: flex;
|
|
71
|
+
align-items: center;
|
|
72
|
+
justify-content: center;
|
|
73
|
+
|
|
74
|
+
.visibility-tree-checkbox {
|
|
75
|
+
&:disabled {
|
|
76
|
+
background-color: transparent;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&:hover {
|
|
80
|
+
background-color: transparent;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
26
83
|
}
|
|
27
84
|
}
|
|
28
85
|
|
|
@@ -51,5 +108,4 @@
|
|
|
51
108
|
font-weight: bold;
|
|
52
109
|
}
|
|
53
110
|
}
|
|
54
|
-
|
|
55
111
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module IModelComponents
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { UnifiedSelectionTreeEventHandler } from "@itwin/presentation-components";
|
|
5
|
+
import type { TreeCheckboxStateChangeEventArgs, TreeNodeItem, TreeSelectionModificationEventArgs, TreeSelectionReplacementEventArgs } from "@itwin/components-react";
|
|
6
|
+
import type { BeEvent, IDisposable } from "@itwin/core-bentley";
|
|
7
|
+
import type { UnifiedSelectionTreeEventHandlerParams } from "@itwin/presentation-components";
|
|
7
8
|
/**
|
|
8
9
|
* Data structure that describes instance visibility status.
|
|
9
|
-
* @
|
|
10
|
+
* @public
|
|
10
11
|
*/
|
|
11
12
|
export interface VisibilityStatus {
|
|
12
13
|
state: "visible" | "partial" | "hidden";
|
|
@@ -15,12 +16,12 @@ export interface VisibilityStatus {
|
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* Type definition of visibility change event listener.
|
|
18
|
-
* @
|
|
19
|
+
* @public
|
|
19
20
|
*/
|
|
20
|
-
export
|
|
21
|
+
export type VisibilityChangeListener = (nodeIds?: string[], visibilityStatus?: Map<string, VisibilityStatus>) => void;
|
|
21
22
|
/**
|
|
22
23
|
* Visibility handler used to change or get visibility of instances represented by the tree node.
|
|
23
|
-
* @
|
|
24
|
+
* @public
|
|
24
25
|
*/
|
|
25
26
|
export interface IVisibilityHandler extends IDisposable {
|
|
26
27
|
getVisibilityStatus(node: TreeNodeItem): VisibilityStatus | Promise<VisibilityStatus>;
|
|
@@ -29,20 +30,20 @@ export interface IVisibilityHandler extends IDisposable {
|
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
32
|
* Type definition of predicate used to decide if node can be selected.
|
|
32
|
-
* @
|
|
33
|
+
* @public
|
|
33
34
|
*/
|
|
34
|
-
export
|
|
35
|
+
export type VisibilityTreeSelectionPredicate = (node: TreeNodeItem) => boolean;
|
|
35
36
|
/**
|
|
36
37
|
* Parameters for [[VisibilityTreeEventHandler]]
|
|
37
|
-
* @
|
|
38
|
+
* @public
|
|
38
39
|
*/
|
|
39
40
|
export interface VisibilityTreeEventHandlerParams extends UnifiedSelectionTreeEventHandlerParams {
|
|
40
|
-
visibilityHandler: IVisibilityHandler
|
|
41
|
+
visibilityHandler: IVisibilityHandler;
|
|
41
42
|
selectionPredicate?: VisibilityTreeSelectionPredicate;
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
45
|
* Base event handler for visibility tree.
|
|
45
|
-
* @
|
|
46
|
+
* @public
|
|
46
47
|
*/
|
|
47
48
|
export declare class VisibilityTreeEventHandler extends UnifiedSelectionTreeEventHandler {
|
|
48
49
|
private _visibilityHandler;
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.VisibilityTreeEventHandler = void 0;
|
|
11
11
|
const rxjs_1 = require("rxjs");
|
|
12
|
-
const empty_1 = require("rxjs/internal/observable/empty");
|
|
13
12
|
const from_1 = require("rxjs/internal/observable/from");
|
|
14
13
|
const map_1 = require("rxjs/internal/operators/map");
|
|
15
14
|
const mergeMap_1 = require("rxjs/internal/operators/mergeMap");
|
|
@@ -18,7 +17,7 @@ const presentation_components_1 = require("@itwin/presentation-components");
|
|
|
18
17
|
const IsPromiseLike_1 = require("../utils/IsPromiseLike");
|
|
19
18
|
/**
|
|
20
19
|
* Base event handler for visibility tree.
|
|
21
|
-
* @
|
|
20
|
+
* @public
|
|
22
21
|
*/
|
|
23
22
|
class VisibilityTreeEventHandler extends presentation_components_1.UnifiedSelectionTreeEventHandler {
|
|
24
23
|
constructor(params) {
|
|
@@ -27,13 +26,11 @@ class VisibilityTreeEventHandler extends presentation_components_1.UnifiedSelect
|
|
|
27
26
|
this._visibilityHandler = params.visibilityHandler;
|
|
28
27
|
this._selectionPredicate = params.selectionPredicate;
|
|
29
28
|
this._isChangingVisibility = false;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
29
|
+
this._listeners.push(this._visibilityHandler.onVisibilityChange.addListener(async (nodeIds, visibilityStatus) => {
|
|
30
|
+
if (this._isChangingVisibility)
|
|
31
|
+
return;
|
|
32
|
+
void this.updateCheckboxes(nodeIds, visibilityStatus);
|
|
33
|
+
}));
|
|
37
34
|
this._listeners.push(this.modelSource.onModelChanged.addListener(async ([_, changes]) => {
|
|
38
35
|
void this.updateCheckboxes([...changes.addedNodeIds, ...changes.modifiedNodeIds]);
|
|
39
36
|
}));
|
|
@@ -71,9 +68,6 @@ class VisibilityTreeEventHandler extends presentation_components_1.UnifiedSelect
|
|
|
71
68
|
this._isChangingVisibility = false;
|
|
72
69
|
void this.updateCheckboxes();
|
|
73
70
|
};
|
|
74
|
-
// istanbul ignore if
|
|
75
|
-
if (!this._visibilityHandler)
|
|
76
|
-
return undefined;
|
|
77
71
|
// eslint-disable-next-line deprecation/deprecation
|
|
78
72
|
(0, from_1.from)(event.stateChanges)
|
|
79
73
|
.pipe(
|
|
@@ -92,9 +86,6 @@ class VisibilityTreeEventHandler extends presentation_components_1.UnifiedSelect
|
|
|
92
86
|
.pipe(
|
|
93
87
|
// eslint-disable-next-line deprecation/deprecation
|
|
94
88
|
(0, mergeMap_1.mergeMap)(({ nodeItem, newState }) => {
|
|
95
|
-
// istanbul ignore if
|
|
96
|
-
if (!this._visibilityHandler)
|
|
97
|
-
return empty_1.EMPTY;
|
|
98
89
|
this._isChangingVisibility = true;
|
|
99
90
|
// eslint-disable-next-line deprecation/deprecation
|
|
100
91
|
return (0, from_1.from)(this._visibilityHandler.changeVisibility(nodeItem, newState === core_react_1.CheckBoxState.On));
|
|
@@ -138,8 +129,6 @@ class VisibilityTreeEventHandler extends presentation_components_1.UnifiedSelect
|
|
|
138
129
|
return nodeStates;
|
|
139
130
|
}
|
|
140
131
|
async getNodeCheckBoxInfo(node, visibilityStatus) {
|
|
141
|
-
if (!this._visibilityHandler)
|
|
142
|
-
return { ...node.checkbox, isVisible: false };
|
|
143
132
|
const result = visibilityStatus?.get(node.id) ?? this._visibilityHandler.getVisibilityStatus(node.item);
|
|
144
133
|
if ((0, IsPromiseLike_1.isPromiseLike)(result))
|
|
145
134
|
return this.createCheckboxInfo(await result);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisibilityTreeEventHandler.js","sourceRoot":"","sources":["../../../../src/components/trees/VisibilityTreeEventHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+BAAkC;AAClC,0DAAuD;AACvD,wDAAqD;AACrD,qDAAkD;AAClD,+DAA4D;AAM5D,kDAAkD;AAClD,4EAA0H;AAC1H,0DAAuD;AA2CvD;;;GAGG;AACH,MAAa,0BAA2B,SAAQ,0DAAgC;IAM9E,YAAY,MAAwC;QAClD,KAAK,CAAC,MAAM,CAAC,CAAC;QAJR,eAAU,GAAG,IAAI,KAAK,EAAc,CAAC;QAK3C,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC,iBAAiB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AG,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC;SACjF;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAEO,KAAK,CAAC,mBAAmB,CAAC,IAAmB,EAAE,gBAAgD;QACrG,IAAI,CAAC,IAAI,CAAC,kBAAkB;YAC1B,OAAO,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QAEhD,MAAM,MAAM,GAAG,gBAAgB,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAExG,IAAI,IAAA,6BAAa,EAAC,MAAM,CAAC;YACvB,OAAO,IAAI,CAAC,kBAAkB,CAAC,MAAM,MAAM,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAEO,kBAAkB,CAAC,MAAwB;QACjD,OAAO;YACL,KAAK,EAAE,8BAA8B,CAAC,MAAM,CAAC;YAC7C,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,KAAK;YACtC,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC;IACJ,CAAC;CACF;AAnKD,gEAmKC;AAED,MAAM,8BAA8B,GAAG,CAAC,MAAwB,EAAE,EAAE;IAClE,QAAQ,MAAM,CAAC,KAAK,EAAE;QACpB,KAAK,SAAS;YACZ,OAAO,0BAAa,CAAC,EAAE,CAAC;QAC1B,uBAAuB;QACvB,KAAK,SAAS;YACZ,OAAO,0BAAa,CAAC,OAAO,CAAC;QAC/B,KAAK,QAAQ,CAAC;QACd;YACE,OAAO,0BAAa,CAAC,GAAG,CAAC;KAC5B;AACH,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module IModelComponents\n */\n\nimport { Observable } from \"rxjs\";\nimport { EMPTY } from \"rxjs/internal/observable/empty\";\nimport { from } from \"rxjs/internal/observable/from\";\nimport { map } from \"rxjs/internal/operators/map\";\nimport { mergeMap } from \"rxjs/internal/operators/mergeMap\";\nimport {\n CheckBoxInfo, CheckboxStateChange, TreeCheckboxStateChangeEventArgs, TreeModelNode, TreeNodeItem, TreeSelectionChange,\n TreeSelectionModificationEventArgs, TreeSelectionReplacementEventArgs,\n} from \"@itwin/components-react\";\nimport { BeEvent, IDisposable } from \"@itwin/core-bentley\";\nimport { CheckBoxState } from \"@itwin/core-react\";\nimport { UnifiedSelectionTreeEventHandler, UnifiedSelectionTreeEventHandlerParams } from \"@itwin/presentation-components\";\nimport { isPromiseLike } from \"../utils/IsPromiseLike\";\n\n/**\n * Data structure that describes instance visibility status.\n * @alpha\n */\nexport interface VisibilityStatus {\n state: \"visible\" | \"partial\" | \"hidden\";\n isDisabled?: boolean;\n tooltip?: string;\n}\n\n/**\n * Type definition of visibility change event listener.\n * @alpha\n */\nexport type VisibilityChangeListener = (nodeIds?: string[], visibilityStatus?: Map<string, VisibilityStatus>) => void;\n\n/**\n * Visibility handler used to change or get visibility of instances represented by the tree node.\n * @alpha\n */\nexport interface IVisibilityHandler extends IDisposable {\n getVisibilityStatus(node: TreeNodeItem): VisibilityStatus | Promise<VisibilityStatus>;\n changeVisibility(node: TreeNodeItem, shouldDisplay: boolean): Promise<void>;\n onVisibilityChange: BeEvent<VisibilityChangeListener>;\n}\n\n/**\n * Type definition of predicate used to decide if node can be selected.\n * @alpha\n */\nexport type VisibilityTreeSelectionPredicate = (node: TreeNodeItem) => boolean;\n\n/**\n * Parameters for [[VisibilityTreeEventHandler]]\n * @alpha\n */\nexport interface VisibilityTreeEventHandlerParams extends UnifiedSelectionTreeEventHandlerParams {\n visibilityHandler: IVisibilityHandler | undefined;\n selectionPredicate?: VisibilityTreeSelectionPredicate;\n}\n\n/**\n * Base event handler for visibility tree.\n * @alpha\n */\nexport class VisibilityTreeEventHandler extends UnifiedSelectionTreeEventHandler {\n private _visibilityHandler: IVisibilityHandler | undefined;\n private _selectionPredicate?: VisibilityTreeSelectionPredicate;\n private _listeners = new Array<() => void>();\n private _isChangingVisibility: boolean;\n\n constructor(params: VisibilityTreeEventHandlerParams) {\n super(params);\n this._visibilityHandler = params.visibilityHandler;\n this._selectionPredicate = params.selectionPredicate;\n this._isChangingVisibility = false;\n\n if (this._visibilityHandler) {\n this._listeners.push(this._visibilityHandler.onVisibilityChange.addListener(async (nodeIds, visibilityStatus) => {\n if (this._isChangingVisibility)\n return;\n void this.updateCheckboxes(nodeIds, visibilityStatus);\n }));\n }\n\n this._listeners.push(this.modelSource.onModelChanged.addListener(async ([_, changes]) => {\n void this.updateCheckboxes([...changes.addedNodeIds, ...changes.modifiedNodeIds]);\n }));\n this.updateCheckboxes(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n\n public override dispose() {\n super.dispose();\n this._listeners.forEach((disposeFunc) => disposeFunc());\n }\n\n private filterSelectionItems(items: TreeNodeItem[]) {\n // istanbul ignore if\n if (!this._selectionPredicate)\n return items;\n\n return items.filter((item) => this._selectionPredicate!(item));\n }\n\n public override onSelectionModified({ modifications }: TreeSelectionModificationEventArgs) {\n const filteredModification = new Observable<TreeSelectionChange>((subscriber) => modifications.subscribe(subscriber)).pipe(\n map(({ selectedNodeItems, deselectedNodeItems }) => {\n return {\n selectedNodeItems: this.filterSelectionItems(selectedNodeItems),\n deselectedNodeItems: this.filterSelectionItems(deselectedNodeItems),\n };\n }),\n );\n return super.onSelectionModified({ modifications: filteredModification });\n }\n\n public override onSelectionReplaced({ replacements }: TreeSelectionReplacementEventArgs) {\n const filteredReplacements = new Observable<{ selectedNodeItems: TreeNodeItem[] }>((subscriber) => replacements.subscribe(subscriber)).pipe(\n map(({ selectedNodeItems }) => {\n return {\n selectedNodeItems: this.filterSelectionItems(selectedNodeItems),\n };\n }),\n );\n return super.onSelectionReplaced({ replacements: filteredReplacements });\n }\n\n public override onCheckboxStateChanged(event: TreeCheckboxStateChangeEventArgs) {\n const handleStateChanged = () => {\n this._isChangingVisibility = false;\n void this.updateCheckboxes();\n };\n // istanbul ignore if\n if (!this._visibilityHandler)\n return undefined;\n\n // eslint-disable-next-line deprecation/deprecation\n from(event.stateChanges)\n .pipe(\n // eslint-disable-next-line deprecation/deprecation\n mergeMap((changes) => this.changeVisibility(changes)),\n )\n // eslint-disable-next-line deprecation/deprecation\n .subscribe({\n complete: handleStateChanged,\n error: handleStateChanged,\n });\n return undefined;\n }\n\n private changeVisibility(changes: CheckboxStateChange[]) {\n // eslint-disable-next-line deprecation/deprecation\n return from(changes)\n .pipe(\n // eslint-disable-next-line deprecation/deprecation\n mergeMap(({ nodeItem, newState }) => {\n // istanbul ignore if\n if (!this._visibilityHandler)\n return EMPTY;\n this._isChangingVisibility = true;\n // eslint-disable-next-line deprecation/deprecation\n return from(this._visibilityHandler.changeVisibility(nodeItem, newState === CheckBoxState.On));\n }, 1),\n );\n }\n\n private async updateCheckboxes(affectedNodes?: string[], visibilityStatus?: Map<string, VisibilityStatus>) {\n const changes = await (affectedNodes ? this.collectAffectedNodesCheckboxInfos(affectedNodes, visibilityStatus) : this.collectAllNodesCheckboxInfos(visibilityStatus));\n this.updateModel(changes);\n }\n\n private updateModel(changes: Map<string, CheckBoxInfo>) {\n this.modelSource.modifyModel((model) => {\n for (const [nodeId, checkboxInfo] of changes) {\n const node = model.getNode(nodeId);\n // istanbul ignore if\n if (!node)\n continue;\n\n node.checkbox.isDisabled = checkboxInfo.isDisabled;\n node.checkbox.isVisible = checkboxInfo.isVisible;\n node.checkbox.state = checkboxInfo.state;\n node.checkbox.tooltip = checkboxInfo.tooltip;\n }\n });\n }\n\n private async collectAffectedNodesCheckboxInfos(affectedNodes: string[], visibilityStatus?: Map<string, VisibilityStatus>) {\n const nodeStates = new Map<string, CheckBoxInfo>();\n if (affectedNodes.length === 0)\n return nodeStates;\n\n await Promise.all(affectedNodes.map(async (nodeId) => {\n const node = this.modelSource.getModel().getNode(nodeId);\n // istanbul ignore else\n if (node)\n nodeStates.set(nodeId, await this.getNodeCheckBoxInfo(node, visibilityStatus));\n }));\n return nodeStates;\n }\n\n private async collectAllNodesCheckboxInfos(visibilityStatus?: Map<string, VisibilityStatus>) {\n const nodeStates = new Map<string, CheckBoxInfo>();\n for (const node of this.modelSource.getModel().iterateTreeModelNodes()) {\n nodeStates.set(node.id, await this.getNodeCheckBoxInfo(node, visibilityStatus));\n }\n return nodeStates;\n }\n\n private async getNodeCheckBoxInfo(node: TreeModelNode, visibilityStatus?: Map<string, VisibilityStatus>): Promise<CheckBoxInfo> {\n if (!this._visibilityHandler)\n return { ...node.checkbox, isVisible: false };\n\n const result = visibilityStatus?.get(node.id) ?? this._visibilityHandler.getVisibilityStatus(node.item);\n\n if (isPromiseLike(result))\n return this.createCheckboxInfo(await result);\n return this.createCheckboxInfo(result);\n }\n\n private createCheckboxInfo(status: VisibilityStatus): CheckBoxInfo {\n return {\n state: visibilityStateToCheckboxState(status),\n isDisabled: status.isDisabled || false,\n isVisible: true,\n tooltip: status.tooltip,\n };\n }\n}\n\nconst visibilityStateToCheckboxState = (status: VisibilityStatus) => {\n switch (status.state) {\n case \"visible\":\n return CheckBoxState.On;\n // istanbul ignore next\n case \"partial\":\n return CheckBoxState.Partial;\n case \"hidden\":\n default:\n return CheckBoxState.Off;\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"VisibilityTreeEventHandler.js","sourceRoot":"","sources":["../../../../src/components/trees/VisibilityTreeEventHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+BAAkC;AAClC,wDAAqD;AACrD,qDAAkD;AAClD,+DAA4D;AAC5D,kDAAkD;AAClD,4EAAkF;AAClF,0DAAuD;AAkDvD;;;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AAI,CAAC,EAAE,EAAE,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC;SACjF;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAEO,KAAK,CAAC,mBAAmB,CAAC,IAAmB,EAAE,gBAAgD;QACrG,MAAM,MAAM,GAAG,gBAAgB,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAExG,IAAI,IAAA,6BAAa,EAAC,MAAM,CAAC;YACvB,OAAO,IAAI,CAAC,kBAAkB,CAAC,MAAM,MAAM,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAEO,kBAAkB,CAAC,MAAwB;QACjD,OAAO;YACL,KAAK,EAAE,8BAA8B,CAAC,MAAM,CAAC;YAC7C,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,KAAK;YACtC,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC;IACJ,CAAC;CACF;AAtJD,gEAsJC;AAED,MAAM,8BAA8B,GAAG,CAAC,MAAwB,EAAE,EAAE;IAClE,QAAQ,MAAM,CAAC,KAAK,EAAE;QACpB,KAAK,SAAS;YACZ,OAAO,0BAAa,CAAC,EAAE,CAAC;QAC1B,uBAAuB;QACvB,KAAK,SAAS;YACZ,OAAO,0BAAa,CAAC,OAAO,CAAC;QAC/B,KAAK,QAAQ,CAAC;QACd;YACE,OAAO,0BAAa,CAAC,GAAG,CAAC;KAC5B;AACH,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module IModelComponents\n */\n\nimport { Observable } from \"rxjs\";\nimport { from } from \"rxjs/internal/observable/from\";\nimport { map } from \"rxjs/internal/operators/map\";\nimport { mergeMap } from \"rxjs/internal/operators/mergeMap\";\nimport { CheckBoxState } from \"@itwin/core-react\";\nimport { UnifiedSelectionTreeEventHandler } from \"@itwin/presentation-components\";\nimport { isPromiseLike } from \"../utils/IsPromiseLike\";\n\nimport type {\n CheckBoxInfo, CheckboxStateChange, TreeCheckboxStateChangeEventArgs, TreeModelNode, TreeNodeItem, TreeSelectionChange,\n TreeSelectionModificationEventArgs, TreeSelectionReplacementEventArgs,\n} from \"@itwin/components-react\";\nimport type { BeEvent, IDisposable } from \"@itwin/core-bentley\";\nimport type { UnifiedSelectionTreeEventHandlerParams } from \"@itwin/presentation-components\";\n\n/**\n * Data structure that describes instance visibility status.\n * @public\n */\nexport interface VisibilityStatus {\n state: \"visible\" | \"partial\" | \"hidden\";\n isDisabled?: boolean;\n tooltip?: string;\n}\n\n/**\n * Type definition of visibility change event listener.\n * @public\n */\nexport type VisibilityChangeListener = (nodeIds?: string[], visibilityStatus?: Map<string, VisibilityStatus>) => void;\n\n/**\n * Visibility handler used to change or get visibility of instances represented by the tree node.\n * @public\n */\nexport interface IVisibilityHandler extends IDisposable {\n getVisibilityStatus(node: TreeNodeItem): VisibilityStatus | Promise<VisibilityStatus>;\n changeVisibility(node: TreeNodeItem, shouldDisplay: boolean): Promise<void>;\n onVisibilityChange: BeEvent<VisibilityChangeListener>;\n}\n\n/**\n * Type definition of predicate used to decide if node can be selected.\n * @public\n */\nexport type VisibilityTreeSelectionPredicate = (node: TreeNodeItem) => boolean;\n\n/**\n * Parameters for [[VisibilityTreeEventHandler]]\n * @public\n */\nexport interface VisibilityTreeEventHandlerParams extends UnifiedSelectionTreeEventHandlerParams {\n visibilityHandler: IVisibilityHandler;\n selectionPredicate?: VisibilityTreeSelectionPredicate;\n}\n\n/**\n * Base event handler for visibility tree.\n * @public\n */\nexport class VisibilityTreeEventHandler extends UnifiedSelectionTreeEventHandler {\n private _visibilityHandler: IVisibilityHandler;\n private _selectionPredicate?: VisibilityTreeSelectionPredicate;\n private _listeners = new Array<() => void>();\n private _isChangingVisibility: boolean;\n\n constructor(params: VisibilityTreeEventHandlerParams) {\n super(params);\n this._visibilityHandler = params.visibilityHandler;\n this._selectionPredicate = params.selectionPredicate;\n this._isChangingVisibility = false;\n this._listeners.push(this._visibilityHandler.onVisibilityChange.addListener(async (nodeIds, visibilityStatus) => {\n if (this._isChangingVisibility)\n return;\n void this.updateCheckboxes(nodeIds, visibilityStatus);\n }));\n this._listeners.push(this.modelSource.onModelChanged.addListener(async ([_, changes]) => {\n void this.updateCheckboxes([...changes.addedNodeIds, ...changes.modifiedNodeIds]);\n }));\n this.updateCheckboxes(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n\n public override dispose() {\n super.dispose();\n this._listeners.forEach((disposeFunc) => disposeFunc());\n }\n\n private filterSelectionItems(items: TreeNodeItem[]) {\n // istanbul ignore if\n if (!this._selectionPredicate)\n return items;\n\n return items.filter((item) => this._selectionPredicate!(item));\n }\n\n public override onSelectionModified({ modifications }: TreeSelectionModificationEventArgs) {\n const filteredModification = new Observable<TreeSelectionChange>((subscriber) => modifications.subscribe(subscriber)).pipe(\n map(({ selectedNodeItems, deselectedNodeItems }) => {\n return {\n selectedNodeItems: this.filterSelectionItems(selectedNodeItems),\n deselectedNodeItems: this.filterSelectionItems(deselectedNodeItems),\n };\n }),\n );\n return super.onSelectionModified({ modifications: filteredModification });\n }\n\n public override onSelectionReplaced({ replacements }: TreeSelectionReplacementEventArgs) {\n const filteredReplacements = new Observable<{ selectedNodeItems: TreeNodeItem[] }>((subscriber) => replacements.subscribe(subscriber)).pipe(\n map(({ selectedNodeItems }) => {\n return {\n selectedNodeItems: this.filterSelectionItems(selectedNodeItems),\n };\n }),\n );\n return super.onSelectionReplaced({ replacements: filteredReplacements });\n }\n\n public override onCheckboxStateChanged(event: TreeCheckboxStateChangeEventArgs) {\n const handleStateChanged = () => {\n this._isChangingVisibility = false;\n void this.updateCheckboxes();\n };\n\n // eslint-disable-next-line deprecation/deprecation\n from(event.stateChanges)\n .pipe(\n // eslint-disable-next-line deprecation/deprecation\n mergeMap((changes) => this.changeVisibility(changes)),\n )\n // eslint-disable-next-line deprecation/deprecation\n .subscribe({\n complete: handleStateChanged,\n error: handleStateChanged,\n });\n return undefined;\n }\n\n private changeVisibility(changes: CheckboxStateChange[]) {\n // eslint-disable-next-line deprecation/deprecation\n return from(changes)\n .pipe(\n // eslint-disable-next-line deprecation/deprecation\n mergeMap(({ nodeItem, newState }) => {\n this._isChangingVisibility = true;\n // eslint-disable-next-line deprecation/deprecation\n return from(this._visibilityHandler.changeVisibility(nodeItem, newState === CheckBoxState.On));\n }, 1),\n );\n }\n\n private async updateCheckboxes(affectedNodes?: string[], visibilityStatus?: Map<string, VisibilityStatus>) {\n const changes = await (affectedNodes ? this.collectAffectedNodesCheckboxInfos(affectedNodes, visibilityStatus) : this.collectAllNodesCheckboxInfos(visibilityStatus));\n this.updateModel(changes);\n }\n\n private updateModel(changes: Map<string, CheckBoxInfo>) {\n this.modelSource.modifyModel((model) => {\n for (const [nodeId, checkboxInfo] of changes) {\n const node = model.getNode(nodeId);\n // istanbul ignore if\n if (!node)\n continue;\n\n node.checkbox.isDisabled = checkboxInfo.isDisabled;\n node.checkbox.isVisible = checkboxInfo.isVisible;\n node.checkbox.state = checkboxInfo.state;\n node.checkbox.tooltip = checkboxInfo.tooltip;\n }\n });\n }\n\n private async collectAffectedNodesCheckboxInfos(affectedNodes: string[], visibilityStatus?: Map<string, VisibilityStatus>) {\n const nodeStates = new Map<string, CheckBoxInfo>();\n if (affectedNodes.length === 0)\n return nodeStates;\n\n await Promise.all(affectedNodes.map(async (nodeId) => {\n const node = this.modelSource.getModel().getNode(nodeId);\n // istanbul ignore else\n if (node)\n nodeStates.set(nodeId, await this.getNodeCheckBoxInfo(node, visibilityStatus));\n }));\n return nodeStates;\n }\n\n private async collectAllNodesCheckboxInfos(visibilityStatus?: Map<string, VisibilityStatus>) {\n const nodeStates = new Map<string, CheckBoxInfo>();\n for (const node of this.modelSource.getModel().iterateTreeModelNodes()) {\n nodeStates.set(node.id, await this.getNodeCheckBoxInfo(node, visibilityStatus));\n }\n return nodeStates;\n }\n\n private async getNodeCheckBoxInfo(node: TreeModelNode, visibilityStatus?: Map<string, VisibilityStatus>): Promise<CheckBoxInfo> {\n const result = visibilityStatus?.get(node.id) ?? this._visibilityHandler.getVisibilityStatus(node.item);\n\n if (isPromiseLike(result))\n return this.createCheckboxInfo(await result);\n return this.createCheckboxInfo(result);\n }\n\n private createCheckboxInfo(status: VisibilityStatus): CheckBoxInfo {\n return {\n state: visibilityStateToCheckboxState(status),\n isDisabled: status.isDisabled || false,\n isVisible: true,\n tooltip: status.tooltip,\n };\n }\n}\n\nconst visibilityStateToCheckboxState = (status: VisibilityStatus) => {\n switch (status.state) {\n case \"visible\":\n return CheckBoxState.On;\n // istanbul ignore next\n case \"partial\":\n return CheckBoxState.Partial;\n case \"hidden\":\n default:\n return CheckBoxState.Off;\n }\n};\n"]}
|
|
@@ -1,35 +1,59 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { AbstractTreeNodeLoaderWithProvider, TreeNodeRendererProps, TreeRendererProps } from "@itwin/components-react";
|
|
3
|
-
import { NodeCheckboxRenderProps } from "@itwin/core-react";
|
|
4
|
-
import { IPresentationTreeDataProvider } from "@itwin/presentation-components";
|
|
5
|
-
import { VisibilityTreeFilterInfo } from "./Common";
|
|
2
|
+
import type { AbstractTreeNodeLoaderWithProvider, TreeNodeRendererProps, TreeRendererProps } from "@itwin/components-react";
|
|
3
|
+
import type { NodeCheckboxRenderProps } from "@itwin/core-react";
|
|
4
|
+
import type { IPresentationTreeDataProvider } from "@itwin/presentation-components";
|
|
5
|
+
import type { VisibilityTreeFilterInfo } from "./Common";
|
|
6
|
+
/**
|
|
7
|
+
* Props for visibility tree node renderer.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export interface VisibilityTreeRendererProps {
|
|
11
|
+
/**
|
|
12
|
+
* Specifies whether the icon at the left of the node label should be rendered.
|
|
13
|
+
*/
|
|
14
|
+
iconsEnabled: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Specifies whether node description should be enabled.
|
|
17
|
+
*/
|
|
18
|
+
descriptionEnabled: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Defines the offset in pixels of how much each hierarchy level should be offset to the right from the checkbox.
|
|
21
|
+
* Defaults to `20`.
|
|
22
|
+
*/
|
|
23
|
+
levelOffset?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Specifies whether the root node be expanded at all times.
|
|
26
|
+
* Defaults to `false`.
|
|
27
|
+
*/
|
|
28
|
+
disableRootNodeCollapse?: boolean;
|
|
29
|
+
}
|
|
6
30
|
/**
|
|
7
31
|
* Creates Visibility tree renderer which renders nodes with eye checkbox.
|
|
8
|
-
* @
|
|
32
|
+
* @public
|
|
9
33
|
*/
|
|
10
|
-
export declare const
|
|
34
|
+
export declare const createVisibilityTreeRenderer: (visibilityTreeRendererProps: VisibilityTreeRendererProps) => (props: TreeRendererProps) => JSX.Element;
|
|
11
35
|
/**
|
|
12
36
|
* Creates node renderer which renders node with eye checkbox.
|
|
13
|
-
* @
|
|
37
|
+
* @public
|
|
14
38
|
*/
|
|
15
|
-
export declare const createVisibilityTreeNodeRenderer: (
|
|
39
|
+
export declare const createVisibilityTreeNodeRenderer: ({ levelOffset, disableRootNodeCollapse, descriptionEnabled, iconsEnabled }: VisibilityTreeRendererProps) => (treeNodeProps: TreeNodeRendererProps) => JSX.Element;
|
|
16
40
|
/**
|
|
17
41
|
* Checkbox renderer that renders an eye.
|
|
18
|
-
* @
|
|
42
|
+
* @public
|
|
19
43
|
*/
|
|
20
|
-
export declare const
|
|
44
|
+
export declare const VisibilityTreeNodeCheckbox: (props: NodeCheckboxRenderProps) => JSX.Element;
|
|
21
45
|
/**
|
|
22
46
|
* Filters data provider used in supplied node loader and invokes onFilterApplied when filtering is completed.
|
|
23
|
-
* @
|
|
47
|
+
* @public
|
|
24
48
|
*/
|
|
25
|
-
export declare const useVisibilityTreeFiltering: (nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>, filterInfo?: VisibilityTreeFilterInfo
|
|
49
|
+
export declare const useVisibilityTreeFiltering: (nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>, filterInfo?: VisibilityTreeFilterInfo, onFilterApplied?: ((filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void) | undefined) => {
|
|
26
50
|
filteredNodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>;
|
|
27
51
|
isFiltering: boolean;
|
|
28
52
|
nodeHighlightingProps: import("@itwin/components-react").HighlightableTreeProps | undefined;
|
|
29
53
|
};
|
|
30
54
|
/**
|
|
31
55
|
* Properties for [[VisibilityTreeNoFilteredData]] component.
|
|
32
|
-
* @
|
|
56
|
+
* @public
|
|
33
57
|
*/
|
|
34
58
|
export interface VisibilityTreeNoFilteredDataProps {
|
|
35
59
|
title: string;
|
|
@@ -37,7 +61,7 @@ export interface VisibilityTreeNoFilteredDataProps {
|
|
|
37
61
|
}
|
|
38
62
|
/**
|
|
39
63
|
* Renders message that no nodes was found for filter.
|
|
40
|
-
* @
|
|
64
|
+
* @public
|
|
41
65
|
*/
|
|
42
66
|
export declare function VisibilityTreeNoFilteredData(props: VisibilityTreeNoFilteredDataProps): JSX.Element;
|
|
43
67
|
//# sourceMappingURL=VisibilityTreeRenderer.d.ts.map
|
|
@@ -1,67 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.VisibilityTreeNoFilteredData = exports.useVisibilityTreeFiltering = exports.VisibilityTreeNodeCheckbox = exports.createVisibilityTreeNodeRenderer = exports.createVisibilityTreeRenderer = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
8
|
/*---------------------------------------------------------------------------------------------
|
|
3
9
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
10
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
11
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
|
|
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.VisibilityTreeNoFilteredData = exports.useVisibilityTreeFiltering = exports.visibilityTreeNodeCheckboxRenderer = exports.createVisibilityTreeNodeRenderer = exports.useVisibilityTreeRenderer = void 0;
|
|
27
|
-
const React = __importStar(require("react"));
|
|
12
|
+
const react_1 = require("react");
|
|
28
13
|
const components_react_1 = require("@itwin/components-react");
|
|
29
14
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
30
15
|
const presentation_components_1 = require("@itwin/presentation-components");
|
|
16
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
17
|
+
/**
|
|
18
|
+
* This constant is taken from `@itwin/core-react`.
|
|
19
|
+
* Defines the size in pixels of the expansion toggle.
|
|
20
|
+
* It is used to keep same hierarchy nodes with children and nodes without children in the same line.
|
|
21
|
+
* @note This value applies only to the leaf nodes.
|
|
22
|
+
*/
|
|
23
|
+
const EXPANSION_TOGGLE_WIDTH = 24;
|
|
31
24
|
/**
|
|
32
25
|
* Creates Visibility tree renderer which renders nodes with eye checkbox.
|
|
33
|
-
* @
|
|
26
|
+
* @public
|
|
34
27
|
*/
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
const createVisibilityTreeRenderer = (visibilityTreeRendererProps) => {
|
|
29
|
+
const nodeRenderer = (0, exports.createVisibilityTreeNodeRenderer)(visibilityTreeRendererProps);
|
|
30
|
+
return function VisibilityTreeRenderer(props) {
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(components_react_1.TreeRenderer, { ...props, nodeRenderer: nodeRenderer }));
|
|
32
|
+
};
|
|
39
33
|
};
|
|
40
|
-
exports.
|
|
34
|
+
exports.createVisibilityTreeRenderer = createVisibilityTreeRenderer;
|
|
41
35
|
const imageLoader = new components_react_1.TreeImageLoader();
|
|
42
36
|
/**
|
|
43
37
|
* Creates node renderer which renders node with eye checkbox.
|
|
44
|
-
* @
|
|
38
|
+
* @public
|
|
45
39
|
*/
|
|
46
|
-
const createVisibilityTreeNodeRenderer = (
|
|
47
|
-
return (
|
|
48
|
-
|
|
40
|
+
const createVisibilityTreeNodeRenderer = ({ levelOffset = 20, disableRootNodeCollapse = false, descriptionEnabled, iconsEnabled }) => {
|
|
41
|
+
return function VisibilityTreeNodeRenderer(treeNodeProps) {
|
|
42
|
+
const nodeOffset = treeNodeProps.node.depth * levelOffset + (treeNodeProps.node.numChildren === 0 ? EXPANSION_TOGGLE_WIDTH : 0);
|
|
43
|
+
return ((0, jsx_runtime_1.jsx)(components_react_1.TreeNodeRenderer, { ...treeNodeProps, node: { ...treeNodeProps.node, depth: 0, numChildren: 1 }, checkboxRenderer: (checkboxProps) => ((0, jsx_runtime_1.jsx)("div", { className: "visibility-tree-checkbox-container", style: { marginRight: `${nodeOffset}px` }, children: (0, jsx_runtime_1.jsx)(exports.VisibilityTreeNodeCheckbox, { ...checkboxProps }) })), descriptionEnabled: descriptionEnabled, imageLoader: iconsEnabled ? imageLoader : undefined, className: (0, classnames_1.default)("with-checkbox", (treeNodeProps.node.numChildren === 0 || (disableRootNodeCollapse && treeNodeProps.node.parentId === undefined)) && "disable-expander", treeNodeProps.className) }));
|
|
44
|
+
};
|
|
49
45
|
};
|
|
50
46
|
exports.createVisibilityTreeNodeRenderer = createVisibilityTreeNodeRenderer;
|
|
51
47
|
/**
|
|
52
48
|
* Checkbox renderer that renders an eye.
|
|
53
|
-
* @
|
|
49
|
+
* @public
|
|
54
50
|
*/
|
|
55
|
-
const
|
|
56
|
-
exports.
|
|
51
|
+
const VisibilityTreeNodeCheckbox = (props) => ((0, jsx_runtime_1.jsx)(itwinui_react_1.Checkbox, { className: "visibility-tree-checkbox", variant: "eyeball", checked: props.checked, onChange: (e) => props.onChange(e.currentTarget.checked), disabled: props.disabled, title: props.title }));
|
|
52
|
+
exports.VisibilityTreeNodeCheckbox = VisibilityTreeNodeCheckbox;
|
|
57
53
|
/**
|
|
58
54
|
* Filters data provider used in supplied node loader and invokes onFilterApplied when filtering is completed.
|
|
59
|
-
* @
|
|
55
|
+
* @public
|
|
60
56
|
*/
|
|
61
57
|
const useVisibilityTreeFiltering = (nodeLoader, filterInfo, onFilterApplied) => {
|
|
62
58
|
const { filter, activeMatchIndex } = filterInfo ?? { filter: undefined, activeMatchIndex: undefined };
|
|
63
59
|
const { filteredNodeLoader, isFiltering, matchesCount, nodeHighlightingProps, } = (0, presentation_components_1.useControlledPresentationTreeFiltering)({ nodeLoader, filter, activeMatchIndex });
|
|
64
|
-
|
|
60
|
+
(0, react_1.useEffect)(() => {
|
|
65
61
|
if (filter && matchesCount !== undefined && filteredNodeLoader !== nodeLoader)
|
|
66
62
|
onFilterApplied && onFilterApplied(filteredNodeLoader.dataProvider, matchesCount);
|
|
67
63
|
}, [filter, matchesCount, nodeLoader, filteredNodeLoader, onFilterApplied]);
|
|
@@ -70,12 +66,10 @@ const useVisibilityTreeFiltering = (nodeLoader, filterInfo, onFilterApplied) =>
|
|
|
70
66
|
exports.useVisibilityTreeFiltering = useVisibilityTreeFiltering;
|
|
71
67
|
/**
|
|
72
68
|
* Renders message that no nodes was found for filter.
|
|
73
|
-
* @
|
|
69
|
+
* @public
|
|
74
70
|
*/
|
|
75
71
|
function VisibilityTreeNoFilteredData(props) {
|
|
76
|
-
return (
|
|
77
|
-
React.createElement("span", { className: "errormessage-header" }, props.title),
|
|
78
|
-
React.createElement("span", { className: "errormessage-body" }, props.message)));
|
|
72
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "components-tree-errormessage", children: [(0, jsx_runtime_1.jsx)("span", { className: "errormessage-header", children: props.title }), (0, jsx_runtime_1.jsx)("span", { className: "errormessage-body", children: props.message })] }));
|
|
79
73
|
}
|
|
80
74
|
exports.VisibilityTreeNoFilteredData = VisibilityTreeNoFilteredData;
|
|
81
75
|
//# sourceMappingURL=VisibilityTreeRenderer.js.map
|