@itwin/tree-widget-react 3.16.1 → 3.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -2
- package/lib/cjs/tree-widget-react/components/SelectableTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/TreeSelector.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/TreeWidgetUiItemsProvider.js +1 -1
- package/lib/cjs/tree-widget-react/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/tree-header/TreeWithHeader.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTree.d.ts +2 -2
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTree.js +2 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.d.ts +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +13 -0
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +92 -74
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.d.ts +3 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +21 -8
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +21 -9
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +300 -251
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.d.ts +2 -0
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +66 -107
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +22 -12
- package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/UseActiveViewport.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/UseHierarchyVisibility.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/components/ProgressOverlay.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/components/Tree.d.ts +2 -2
- package/lib/cjs/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.d.ts +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/components/TreeRenderer.d.ts +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/components/TreeRenderer.js +2 -2
- package/lib/cjs/tree-widget-react/components/trees/common/components/TreeRenderer.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTree.d.ts +3 -3
- package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.d.ts +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/internal/Utils.d.ts +25 -0
- package/lib/cjs/tree-widget-react/components/trees/common/internal/Utils.js +83 -0
- package/lib/cjs/tree-widget-react/components/trees/common/internal/Utils.js.map +1 -0
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +1 -0
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +86 -28
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js +2 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/Utils.d.ts +5 -6
- package/lib/cjs/tree-widget-react/components/trees/models-tree/Utils.js +5 -17
- package/lib/cjs/tree-widget-react/components/trees/models-tree/Utils.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js +5 -4
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/FilteredTree.d.ts +7 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js +52 -0
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +28 -12
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +382 -278
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNode.d.ts +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNode.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +272 -139
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/cjs/tree-widget-react-internal.d.ts +2 -1
- package/lib/cjs/tree-widget-react-internal.js +4 -1
- package/lib/cjs/tree-widget-react-internal.js.map +1 -1
- package/lib/esm/tree-widget-react/components/SelectableTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/TreeSelector.js.map +1 -1
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js +1 -1
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/TreeWithHeader.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js +2 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +13 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +92 -74
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.d.ts +3 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +22 -9
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +21 -9
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +301 -252
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.d.ts +2 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +67 -108
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +23 -13
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseActiveViewport.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/ProgressOverlay.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.d.ts +25 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js +74 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +1 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +83 -25
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +2 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.d.ts +5 -6
- package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.js +4 -16
- package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js +4 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.d.ts +7 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js +52 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +28 -12
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +382 -278
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNode.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNode.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +257 -124
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react-internal.d.ts +2 -1
- package/lib/esm/tree-widget-react-internal.js +2 -1
- package/lib/esm/tree-widget-react-internal.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesVisibilityUtils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAsBhG,sDAkBC;AAMD,4DAEC;AAGD,gEAqBC;AAMD,8CAEC;AAMD,8CAEC;AAUD,kDA4BC;AA5HD,sDAA2C;AAC3C,oDAAoD;AACpD,wDAAkE;AAclE;;;GAGG;AACI,KAAK,UAAU,qBAAqB,CAAC,QAAkB,EAAE,WAAsB,EAAE,OAAgB,EAAE,sBAAsB,GAAG,IAAI;IACrI,QAAQ,CAAC,qBAAqB,CAAC,WAAW,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC;IAE7E,sCAAsC;IACtC,MAAM,yBAAyB,GAAa,EAAE,CAAC;IAC/C,KAAK,MAAM,GAAG,IAAI,QAAQ,CAAC,0BAA0B,EAAE,CAAC;QACtD,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,E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,EAAE,CAAC;QAClC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YACtD,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YAC5C,SAAS;QACX,CAAC;QACD,wCAAwC;QACxC,IAAI,QAAQ,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;YAChG,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC9C,CAAC;aAAM,CAAC;YACN,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,uDAAuD;IACvD,KAAK,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,QAAQ,CAAC,0BAA0B,EAAE,CAAC;QAC1E,IAAI,CAAC,OAAO,IAAI,mBAAmB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACpD,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACnC,mBAAmB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED,MAAM,qBAAqB,CAAC,QAAQ,EAAE,CAAC,GAAG,mBAAmB,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAE7E,MAAM,qBAAqB,CAAC,QAAQ,EAAE,CAAC,GAAG,kBAAkB,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC7E,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 { Guid } from \"@itwin/core-bentley\";\nimport { QueryRowFormat } from \"@itwin/core-common\";\nimport { PerModelCategoryVisibility } from \"@itwin/core-frontend\";\n\nimport type { GuidString, Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { Viewport } from \"@itwin/core-frontend\";\n\n/**\n * Data structure that describes category.\n * @beta\n */\nexport interface CategoryInfo {\n categoryId: string;\n subCategoryIds?: string[];\n}\n\n/**\n * Changes category display in the viewport.\n * @internal\n */\nexport async function enableCategoryDisplay(viewport: Viewport, categoryIds: Id64Array, enabled: boolean, enableAllSubCategories = true) {\n viewport.changeCategoryDisplay(categoryIds, enabled, enableAllSubCategories);\n\n // remove category overrides per model\n const modelsContainingOverrides: string[] = [];\n for (const ovr of viewport.perModelCategoryVisibility) {\n if (categoryIds.findIndex((id) => id === ovr.categoryId) !== -1) {\n modelsContainingOverrides.push(ovr.modelId);\n }\n }\n viewport.perModelCategoryVisibility.setOverride(modelsContainingOverrides, categoryIds, 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 viewport.iModel.categories.getCategoryInfo(categoryIds)).forEach((categoryInfo) => {\n categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewport, value.id, false));\n });\n }\n}\n\n/**\n * Changes subcategory display in the viewport\n * @internal\n */\nexport function enableSubCategoryDisplay(viewport: Viewport, key: string, enabled: boolean) {\n viewport.changeSubCategoryDisplay(key, enabled);\n}\n\n/** @internal */\nexport async function loadCategoriesFromViewport(vp: Viewport, componentId?: GuidString) {\n // Query categories and add them to state\n const selectUsedSpatialCategoryIds =\n \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)\";\n const selectUsedDrawingCategoryIds =\n \"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 const rows = await vp.iModel\n .createQueryReader(ecsql2, undefined, {\n rowFormat: QueryRowFormat.UseJsPropertyNames,\n restartToken: `CategoriesVisibilityUtils/${componentId ?? Guid.createValue()}/categories`,\n })\n .toArray();\n (await vp.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 return categories;\n}\n\n/**\n * Enable display of all given categories.\n * @public\n */\nexport async function showAllCategories(categories: string[], viewport: Viewport) {\n await enableCategoryDisplay(viewport, categories, true, true);\n}\n\n/**\n * Disable display of all given categories.\n * @public\n */\nexport async function hideAllCategories(categories: string[], viewport: Viewport) {\n await enableCategoryDisplay(viewport, categories, false, true);\n}\n\n/**\n * Invert display of all given categories.\n * Categories are inverted like this:\n * - If category is visible, it will be hidden.\n * - If category is hidden, it will be visible.\n * - If category is partially visible, it will be fully visible.\n * @public\n */\nexport async function invertAllCategories(categories: CategoryInfo[], viewport: Viewport) {\n const categoriesToEnable = new Set<Id64String>();\n const categoriesToDisable = new Set<Id64String>();\n\n for (const category of categories) {\n if (!viewport.view.viewsCategory(category.categoryId)) {\n categoriesToEnable.add(category.categoryId);\n continue;\n }\n // Check if category is in partial state\n if (category.subCategoryIds?.some((subCategory) => !viewport.isSubCategoryVisible(subCategory))) {\n categoriesToEnable.add(category.categoryId);\n } else {\n categoriesToDisable.add(category.categoryId);\n }\n }\n\n // collect per model overrides that need to be inverted\n for (const { categoryId, visible } of viewport.perModelCategoryVisibility) {\n if (!visible && categoriesToDisable.has(categoryId)) {\n categoriesToEnable.add(categoryId);\n categoriesToDisable.delete(categoryId);\n }\n }\n\n await enableCategoryDisplay(viewport, [...categoriesToDisable], false, true);\n\n await enableCategoryDisplay(viewport, [...categoriesToEnable], true, true);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CategoriesVisibilityUtils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAyBhG,sDA6BC;AAMD,4DAEC;AAGD,gEAqBC;AAMD,8CAEC;AAMD,8CAEC;AAUD,kDA4BC;AA1ID,+BAAmD;AACnD,sDAAiD;AACjD,oDAAoD;AACpD,wDAAkE;AAClE,kDAAyF;AACzF,uCAA0C;AAc1C;;;GAGG;AACI,KAAK,UAAU,qBAAqB,CAAC,QAAkB,EAAE,WAAsB,EAAE,OAAgB,EAAE,sBAAsB,GAAG,IAAI;IACrI,MAAM,eAAe,GAAG,CAAC,kBAA6B,EAAE,EAAE;QACxD,MAAM,yBAAyB,GAAa,EAAE,CAAC;QAC/C,KAAK,MAAM,GAAG,IAAI,QAAQ,CAAC,0BAA0B,EAAE,CAAC;YACtD,IAAI,mBAAI,CAAC,GAAG,CAAC,kBAAkB,EAAE,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;gBACjD,yBAAyB,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;QACD,QAAQ,CAAC,0BAA0B,CAAC,WAAW,CAAC,yBAAyB,EAAE,kBAAkB,EAAE,0CAA0B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3I,CAAC,CAAC;IACF,MAAM,oBAAoB,GAAG,KAAK,EAAE,kBAA6B,EAAE,EAAE;QACnE,6GAA6G;QAC7G,CAAC,MAAM,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;YAC9F,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,wBAAwB,CAAC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AG,IAAI,GAAG,EAAc,CAAC;IAElD,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE,CAAC;QAClC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YACtD,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YAC5C,SAAS;QACX,CAAC;QACD,wCAAwC;QACxC,IAAI,QAAQ,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;YAChG,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC9C,CAAC;aAAM,CAAC;YACN,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,uDAAuD;IACvD,KAAK,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,QAAQ,CAAC,0BAA0B,EAAE,CAAC;QAC1E,IAAI,CAAC,OAAO,IAAI,mBAAmB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACpD,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACnC,mBAAmB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED,MAAM,qBAAqB,CAAC,QAAQ,EAAE,CAAC,GAAG,mBAAmB,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAE7E,MAAM,qBAAqB,CAAC,QAAQ,EAAE,CAAC,GAAG,kBAAkB,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC7E,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 { bufferCount, from, mergeMap } from \"rxjs\";\nimport { Guid, Id64 } from \"@itwin/core-bentley\";\nimport { QueryRowFormat } from \"@itwin/core-common\";\nimport { PerModelCategoryVisibility } from \"@itwin/core-frontend\";\nimport { getOptimalBatchSize, releaseMainThreadOnItemsCount } from \"./internal/Utils.js\";\nimport { toVoidPromise } from \"./Rxjs.js\";\n\nimport type { GuidString, Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { Viewport } from \"@itwin/core-frontend\";\n\n/**\n * Data structure that describes category.\n * @beta\n */\nexport interface CategoryInfo {\n categoryId: string;\n subCategoryIds?: string[];\n}\n\n/**\n * Changes category display in the viewport.\n * @internal\n */\nexport async function enableCategoryDisplay(viewport: Viewport, categoryIds: Id64Array, enabled: boolean, enableAllSubCategories = true) {\n const removeOverrides = (bufferedCategories: Id64Array) => {\n const modelsContainingOverrides: string[] = [];\n for (const ovr of viewport.perModelCategoryVisibility) {\n if (Id64.has(bufferedCategories, ovr.categoryId)) {\n modelsContainingOverrides.push(ovr.modelId);\n }\n }\n viewport.perModelCategoryVisibility.setOverride(modelsContainingOverrides, bufferedCategories, PerModelCategoryVisibility.Override.None);\n };\n const disableSubCategories = async (bufferedCategories: Id64Array) => {\n // changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.\n (await viewport.iModel.categories.getCategoryInfo(bufferedCategories)).forEach((categoryInfo) => {\n categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewport, value.id, false));\n });\n };\n return toVoidPromise(\n from(categoryIds).pipe(\n releaseMainThreadOnItemsCount(500),\n bufferCount(getOptimalBatchSize({ totalSize: categoryIds.length, maximumBatchSize: 500 })),\n mergeMap(async (bufferedCategories) => {\n viewport.changeCategoryDisplay(bufferedCategories, enabled, enableAllSubCategories);\n removeOverrides(bufferedCategories);\n if (!enabled) {\n await disableSubCategories(bufferedCategories);\n }\n }),\n ),\n );\n}\n\n/**\n * Changes subcategory display in the viewport\n * @internal\n */\nexport function enableSubCategoryDisplay(viewport: Viewport, key: string, enabled: boolean) {\n viewport.changeSubCategoryDisplay(key, enabled);\n}\n\n/** @internal */\nexport async function loadCategoriesFromViewport(vp: Viewport, componentId?: GuidString) {\n // Query categories and add them to state\n const selectUsedSpatialCategoryIds =\n \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)\";\n const selectUsedDrawingCategoryIds =\n \"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 const rows = await vp.iModel\n .createQueryReader(ecsql2, undefined, {\n rowFormat: QueryRowFormat.UseJsPropertyNames,\n restartToken: `CategoriesVisibilityUtils/${componentId ?? Guid.createValue()}/categories`,\n })\n .toArray();\n (await vp.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 return categories;\n}\n\n/**\n * Enable display of all given categories.\n * @public\n */\nexport async function showAllCategories(categories: string[], viewport: Viewport) {\n await enableCategoryDisplay(viewport, categories, true, true);\n}\n\n/**\n * Disable display of all given categories.\n * @public\n */\nexport async function hideAllCategories(categories: string[], viewport: Viewport) {\n await enableCategoryDisplay(viewport, categories, false, true);\n}\n\n/**\n * Invert display of all given categories.\n * Categories are inverted like this:\n * - If category is visible, it will be hidden.\n * - If category is hidden, it will be visible.\n * - If category is partially visible, it will be fully visible.\n * @public\n */\nexport async function invertAllCategories(categories: CategoryInfo[], viewport: Viewport) {\n const categoriesToEnable = new Set<Id64String>();\n const categoriesToDisable = new Set<Id64String>();\n\n for (const category of categories) {\n if (!viewport.view.viewsCategory(category.categoryId)) {\n categoriesToEnable.add(category.categoryId);\n continue;\n }\n // Check if category is in partial state\n if (category.subCategoryIds?.some((subCategory) => !viewport.isSubCategoryVisible(subCategory))) {\n categoriesToEnable.add(category.categoryId);\n } else {\n categoriesToDisable.add(category.categoryId);\n }\n }\n\n // collect per model overrides that need to be inverted\n for (const { categoryId, visible } of viewport.perModelCategoryVisibility) {\n if (!visible && categoriesToDisable.has(categoryId)) {\n categoriesToEnable.add(categoryId);\n categoriesToDisable.delete(categoryId);\n }\n }\n\n await enableCategoryDisplay(viewport, [...categoriesToDisable], false, true);\n\n await enableCategoryDisplay(viewport, [...categoriesToEnable], true, true);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseActiveViewport.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/UseActiveViewport.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;;
|
|
1
|
+
{"version":3,"file":"UseActiveViewport.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/UseActiveViewport.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAWhG,8CAUC;AAnBD,iCAA4C;AAC5C,wDAAiD;AAIjD;;;GAGG;AACH,SAAgB,iBAAiB;IAC/B,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAC,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IACzF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,iBAAiB,CAAC,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QACtD,OAAO,yBAAS,CAAC,WAAW,CAAC,yBAAyB,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;YAC1E,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useState } from \"react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\n\nimport type { ScreenViewport } from \"@itwin/core-frontend\";\n\n/**\n * A copy of `useActiveViewport` from `@itwin/appui-react` package until X is fixed.\n * @internal\n */\nexport function useActiveViewport(): ScreenViewport | undefined {\n const [activeViewport, setActiveViewport] = useState(IModelApp.viewManager.selectedView);\n useEffect(() => {\n setActiveViewport(IModelApp.viewManager.selectedView);\n return IModelApp.viewManager.onSelectedViewportChanged.addListener((args) => {\n setActiveViewport(args.current);\n });\n }, []);\n\n return activeViewport;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseHierarchyVisibility.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/UseHierarchyVisibility.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAyDhG,wDA8FC;AAiDD,sEAeC;AArND,iCAAoD;AACpD,+BAcc;AACd,qEAA+D;AAuC/D,SAAgB,sBAAsB,CAAC,EAAE,wBAAwB,EAA+B;IAC9F,MAAM,mBAAmB,GAAG,IAAA,cAAM,EAAC,IAAI,GAAG,EAAgG,CAAC,CAAC;IAC5I,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAqD;QACrF,gBAAgB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC7C,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC;QAC3B,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;KACzB,CAAC,CAAC;IACH,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,4CAAmB,G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G,KAAK;YACR,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,IAAA,oBAAa,EAAC,GAAG,EAAE,EAAE,YAAY,EAAE,SAAoB,EAAE,CAAC;YAC9F,OAAO;SACR,CAAC,CACH;QACH,CAAC,CAAC,GAAG,CAAC;AACV,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useRef, useState } from \"react\";\nimport {\n asyncScheduler,\n defer,\n distinct,\n EMPTY,\n from,\n lastValueFrom,\n mergeMap,\n observeOn,\n onErrorResumeNextWith,\n Subject,\n takeUntil,\n tap,\n throttleTime,\n} from \"rxjs\";\nimport { useTelemetryContext } from \"./UseTelemetryContext.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { MutableRefObject } from \"react\";\nimport type { BeEvent, IDisposable } from \"@itwin/core-bentley\";\nimport type { HierarchyNode, PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { TreeCheckboxProps } from \"./components/TreeNodeCheckbox.js\";\n\n/**\n * Data structure that describes instance visibility status.\n * @beta\n */\nexport interface VisibilityStatus {\n /** Instance visibility state. */\n state: \"visible\" | \"partial\" | \"hidden\";\n /** Specifies whether visibility changing is disabled or not. */\n isDisabled?: boolean;\n /** Tooltip that should be displayed when hovering over the visibility checkbox. */\n tooltip?: string;\n}\n\n/**\n * Handler that can be used to determine and change visibility of instances represented by tree nodes.\n * @beta\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface HierarchyVisibilityHandler extends IDisposable {\n /** Event used to notify tree about visibility changes from outside. */\n readonly onVisibilityChange: BeEvent<() => void>;\n /** Returns current visibility status for tree node. */\n getVisibilityStatus(node: HierarchyNode): Promise<VisibilityStatus> | VisibilityStatus;\n /** Changes visibility of the instance represented by tree node. */\n changeVisibility(node: HierarchyNode, on: boolean): Promise<void>;\n}\n\ninterface UseHierarchyVisibilityProps {\n visibilityHandlerFactory: () => HierarchyVisibilityHandler;\n}\n\nexport function useHierarchyVisibility({ visibilityHandlerFactory }: UseHierarchyVisibilityProps): TreeCheckboxProps & { triggerRefresh: () => void } {\n const visibilityStatusMap = useRef(new Map<string, { node: PresentationHierarchyNode; status: VisibilityStatus; needsRefresh: boolean }>());\n const [state, setState] = useState<TreeCheckboxProps & { triggerRefresh: () => void }>({\n getCheckboxState: () => ({ isLoading: true }),\n onCheckboxClicked: () => {},\n triggerRefresh: () => {},\n });\n const { onFeatureUsed } = useTelemetryContext();\n\n useEffect(() => {\n visibilityStatusMap.current.clear();\n const handler = visibilityHandlerFactory();\n\n const visibilityChanged = new Subject<void>();\n const calculate = new Subject<PresentationHierarchyNode>();\n const calculateNodeStatus = (node: PresentationHierarchyNode) => {\n calculate.next(node);\n };\n\n const resetCache = () => {\n visibilityStatusMap.current.forEach((value) => {\n value.needsRefresh = true;\n });\n visibilityChanged.next();\n };\n\n const triggerCheckboxUpdate = () => {\n setState((prev) => ({\n ...prev,\n getCheckboxState: createStateGetter(visibilityStatusMap, calculateNodeStatus),\n }));\n };\n\n const subscription = calculate\n .pipe(\n distinct(undefined, visibilityChanged),\n observeOn(asyncScheduler),\n mergeMap((node) =>\n defer(async () => handler.getVisibilityStatus(node.nodeData)).pipe(\n tap({\n next: (status) => {\n visibilityStatusMap.current.set(node.id, {\n node,\n status,\n needsRefresh: false,\n });\n },\n }),\n takeUntil(visibilityChanged),\n onErrorResumeNextWith(EMPTY),\n ),\n ),\n throttleTime(100, undefined, { leading: false, trailing: true }),\n )\n .subscribe({\n next: () => {\n triggerCheckboxUpdate();\n },\n });\n\n const changeVisibility = (node: PresentationHierarchyNode, checked: boolean) => {\n onFeatureUsed({ featureId: \"visibility-change\", reportInteraction: true });\n void handler.changeVisibility(node.nodeData, checked);\n const entry = visibilityStatusMap.current.get(node.id);\n if (!entry) {\n return;\n }\n entry.status.state = checked ? \"visible\" : \"hidden\";\n delete entry.status.tooltip;\n triggerCheckboxUpdate();\n };\n\n setState({\n onCheckboxClicked: changeVisibility,\n getCheckboxState: createStateGetter(visibilityStatusMap, calculateNodeStatus),\n triggerRefresh: () => {\n resetCache();\n triggerCheckboxUpdate();\n },\n });\n\n const removeListener = handler.onVisibilityChange.addListener(() => {\n resetCache();\n triggerCheckboxUpdate();\n });\n\n return () => {\n subscription.unsubscribe();\n removeListener();\n handler.dispose();\n };\n }, [visibilityHandlerFactory, onFeatureUsed]);\n\n return state;\n}\n\nfunction createStateGetter(\n map: MutableRefObject<Map<string, { node: PresentationHierarchyNode; status: VisibilityStatus; needsRefresh: boolean }>>,\n calculateVisibility: (node: PresentationHierarchyNode) => void,\n): TreeCheckboxProps[\"getCheckboxState\"] {\n return (node) => {\n const entry = map.current.get(node.id);\n if (entry === undefined) {\n calculateVisibility(node);\n return { isLoading: true };\n }\n\n if (entry.needsRefresh) {\n calculateVisibility(node);\n }\n\n const status = entry.status;\n return {\n ...status,\n state: status.state === \"visible\" ? \"on\" : status.state === \"hidden\" ? \"off\" : \"partial\",\n };\n };\n}\n\n/**\n * Properties for an overridden method of a `HierarchyVisibilityHandler` implementation.\n * @beta\n */\nexport type HierarchyVisibilityHandlerOverridableMethodProps<TFunc> = TFunc extends (props: infer TProps) => infer TResult\n ? TProps & {\n /** A callback that produces the value from the original implementation. */\n readonly originalImplementation: () => TResult;\n /**\n * Reference to the hierarchy based handler.\n * @note Calling `getVisibility` or `changeVisibility` of this object invokes the overridden implementation as well.\n */\n readonly handler: HierarchyVisibilityHandler;\n }\n : never;\n\n/**\n * Function type for an overridden method of `HierarchyVisibilityHandler`.\n * @beta\n */\nexport type HierarchyVisibilityHandlerOverridableMethod<TFunc> = TFunc extends (...args: any[]) => infer TResult\n ? (props: HierarchyVisibilityHandlerOverridableMethodProps<TFunc>) => TResult\n : never;\n\nexport function createVisibilityHandlerResult<TResult, TOverrideProps>(\n handler: HierarchyVisibilityHandler,\n props: TOverrideProps,\n obs: Observable<TResult>,\n override: HierarchyVisibilityHandlerOverridableMethod<(props: TOverrideProps) => Promise<TResult>> | undefined,\n): Observable<TResult> {\n return override\n ? from(\n override({\n ...props,\n originalImplementation: async () => lastValueFrom(obs, { defaultValue: undefined as TResult }),\n handler,\n }),\n )\n : obs;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UseHierarchyVisibility.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/UseHierarchyVisibility.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAyDhG,wDA8FC;AAiDD,sEAeC;AArND,iCAAoD;AACpD,+BAcc;AACd,qEAA+D;AAuC/D,SAAgB,sBAAsB,CAAC,EAAE,wBAAwB,EAA+B;IAC9F,MAAM,mBAAmB,GAAG,IAAA,cAAM,EAAC,IAAI,GAAG,EAAgG,CAAC,CAAC;IAC5I,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAqD;QACrF,gBAAgB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC7C,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC;QAC3B,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;KACzB,CAAC,CAAC;IACH,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,4CAAmB,GAAE,CAAC;IAEhD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,mBAAmB,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,wBAAwB,EAAE,CAAC;QAE3C,MAAM,iBAAiB,GAAG,IAAI,cAAO,EAAQ,CAAC;QAC9C,MAAM,SAAS,GAAG,IAAI,cAAO,EAA6B,CAAC;QAC3D,MAAM,mBAAmB,GAAG,CAAC,IAA+B,EAAE,EAAE;YAC9D,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC;QAEF,MAAM,UAAU,GAAG,GAAG,EAAE;YAC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B,GAAwH,EACxH,mBAA8D;IAE9D,OAAO,CAAC,IAAI,EAAE,EAAE;QACd,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,mBAAmB,CAAC,IAAI,CAAC,CAAC;YAC1B,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC7B,CAAC;QAED,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;YACvB,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAED,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,OAAO;YACL,GAAG,MAAM;YACT,KAAK,EAAE,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SACzF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AA0BD,SAAgB,6BAA6B,CAC3C,OAAmC,EACnC,KAAqB,EACrB,GAAwB,EACxB,QAA8G;IAE9G,OAAO,QAAQ;QACb,CAAC,CAAC,IAAA,WAAI,EACF,QAAQ,CAAC;YACP,GAAG,KAAK;YACR,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,IAAA,oBAAa,EAAC,GAAG,EAAE,EAAE,YAAY,EAAE,SAAoB,EAAE,CAAC;YAC9F,OAAO;SACR,CAAC,CACH;QACH,CAAC,CAAC,GAAG,CAAC;AACV,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useRef, useState } from \"react\";\nimport {\n asyncScheduler,\n defer,\n distinct,\n EMPTY,\n from,\n lastValueFrom,\n mergeMap,\n observeOn,\n onErrorResumeNextWith,\n Subject,\n takeUntil,\n tap,\n throttleTime,\n} from \"rxjs\";\nimport { useTelemetryContext } from \"./UseTelemetryContext.js\";\n\nimport type { MutableRefObject } from \"react\";\nimport type { Observable } from \"rxjs\";\nimport type { BeEvent, IDisposable } from \"@itwin/core-bentley\";\nimport type { HierarchyNode, PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { TreeCheckboxProps } from \"./components/TreeNodeCheckbox.js\";\n\n/**\n * Data structure that describes instance visibility status.\n * @beta\n */\nexport interface VisibilityStatus {\n /** Instance visibility state. */\n state: \"visible\" | \"partial\" | \"hidden\";\n /** Specifies whether visibility changing is disabled or not. */\n isDisabled?: boolean;\n /** Tooltip that should be displayed when hovering over the visibility checkbox. */\n tooltip?: string;\n}\n\n/**\n * Handler that can be used to determine and change visibility of instances represented by tree nodes.\n * @beta\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface HierarchyVisibilityHandler extends IDisposable {\n /** Event used to notify tree about visibility changes from outside. */\n readonly onVisibilityChange: BeEvent<() => void>;\n /** Returns current visibility status for tree node. */\n getVisibilityStatus(node: HierarchyNode): Promise<VisibilityStatus> | VisibilityStatus;\n /** Changes visibility of the instance represented by tree node. */\n changeVisibility(node: HierarchyNode, on: boolean): Promise<void>;\n}\n\ninterface UseHierarchyVisibilityProps {\n visibilityHandlerFactory: () => HierarchyVisibilityHandler;\n}\n\nexport function useHierarchyVisibility({ visibilityHandlerFactory }: UseHierarchyVisibilityProps): TreeCheckboxProps & { triggerRefresh: () => void } {\n const visibilityStatusMap = useRef(new Map<string, { node: PresentationHierarchyNode; status: VisibilityStatus; needsRefresh: boolean }>());\n const [state, setState] = useState<TreeCheckboxProps & { triggerRefresh: () => void }>({\n getCheckboxState: () => ({ isLoading: true }),\n onCheckboxClicked: () => {},\n triggerRefresh: () => {},\n });\n const { onFeatureUsed } = useTelemetryContext();\n\n useEffect(() => {\n visibilityStatusMap.current.clear();\n const handler = visibilityHandlerFactory();\n\n const visibilityChanged = new Subject<void>();\n const calculate = new Subject<PresentationHierarchyNode>();\n const calculateNodeStatus = (node: PresentationHierarchyNode) => {\n calculate.next(node);\n };\n\n const resetCache = () => {\n visibilityStatusMap.current.forEach((value) => {\n value.needsRefresh = true;\n });\n visibilityChanged.next();\n };\n\n const triggerCheckboxUpdate = () => {\n setState((prev) => ({\n ...prev,\n getCheckboxState: createStateGetter(visibilityStatusMap, calculateNodeStatus),\n }));\n };\n\n const subscription = calculate\n .pipe(\n distinct(undefined, visibilityChanged),\n observeOn(asyncScheduler),\n mergeMap((node) =>\n defer(async () => handler.getVisibilityStatus(node.nodeData)).pipe(\n tap({\n next: (status) => {\n visibilityStatusMap.current.set(node.id, {\n node,\n status,\n needsRefresh: false,\n });\n },\n }),\n takeUntil(visibilityChanged),\n onErrorResumeNextWith(EMPTY),\n ),\n ),\n throttleTime(100, undefined, { leading: false, trailing: true }),\n )\n .subscribe({\n next: () => {\n triggerCheckboxUpdate();\n },\n });\n\n const changeVisibility = (node: PresentationHierarchyNode, checked: boolean) => {\n onFeatureUsed({ featureId: \"visibility-change\", reportInteraction: true });\n void handler.changeVisibility(node.nodeData, checked);\n const entry = visibilityStatusMap.current.get(node.id);\n if (!entry) {\n return;\n }\n entry.status.state = checked ? \"visible\" : \"hidden\";\n delete entry.status.tooltip;\n triggerCheckboxUpdate();\n };\n\n setState({\n onCheckboxClicked: changeVisibility,\n getCheckboxState: createStateGetter(visibilityStatusMap, calculateNodeStatus),\n triggerRefresh: () => {\n resetCache();\n triggerCheckboxUpdate();\n },\n });\n\n const removeListener = handler.onVisibilityChange.addListener(() => {\n resetCache();\n triggerCheckboxUpdate();\n });\n\n return () => {\n subscription.unsubscribe();\n removeListener();\n handler.dispose();\n };\n }, [visibilityHandlerFactory, onFeatureUsed]);\n\n return state;\n}\n\nfunction createStateGetter(\n map: MutableRefObject<Map<string, { node: PresentationHierarchyNode; status: VisibilityStatus; needsRefresh: boolean }>>,\n calculateVisibility: (node: PresentationHierarchyNode) => void,\n): TreeCheckboxProps[\"getCheckboxState\"] {\n return (node) => {\n const entry = map.current.get(node.id);\n if (entry === undefined) {\n calculateVisibility(node);\n return { isLoading: true };\n }\n\n if (entry.needsRefresh) {\n calculateVisibility(node);\n }\n\n const status = entry.status;\n return {\n ...status,\n state: status.state === \"visible\" ? \"on\" : status.state === \"hidden\" ? \"off\" : \"partial\",\n };\n };\n}\n\n/**\n * Properties for an overridden method of a `HierarchyVisibilityHandler` implementation.\n * @beta\n */\nexport type HierarchyVisibilityHandlerOverridableMethodProps<TFunc> = TFunc extends (props: infer TProps) => infer TResult\n ? TProps & {\n /** A callback that produces the value from the original implementation. */\n readonly originalImplementation: () => TResult;\n /**\n * Reference to the hierarchy based handler.\n * @note Calling `getVisibility` or `changeVisibility` of this object invokes the overridden implementation as well.\n */\n readonly handler: HierarchyVisibilityHandler;\n }\n : never;\n\n/**\n * Function type for an overridden method of `HierarchyVisibilityHandler`.\n * @beta\n */\nexport type HierarchyVisibilityHandlerOverridableMethod<TFunc> = TFunc extends (...args: any[]) => infer TResult\n ? (props: HierarchyVisibilityHandlerOverridableMethodProps<TFunc>) => TResult\n : never;\n\nexport function createVisibilityHandlerResult<TResult, TOverrideProps>(\n handler: HierarchyVisibilityHandler,\n props: TOverrideProps,\n obs: Observable<TResult>,\n override: HierarchyVisibilityHandlerOverridableMethod<(props: TOverrideProps) => Promise<TResult>> | undefined,\n): Observable<TResult> {\n return override\n ? from(\n override({\n ...props,\n originalImplementation: async () => lastValueFrom(obs, { defaultValue: undefined as TResult }),\n handler,\n }),\n )\n : obs;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressOverlay.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/ProgressOverlay.tsx"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"ProgressOverlay.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/ProgressOverlay.tsx"],"names":[],"mappings":";;AASA,0CAOC;;AAhBD;;;gGAGgG;AAEhG,kCAAgC;AAEhC,wDAAsD;AAEtD,SAAgB,eAAe;IAC7B,OAAO,CACL,iCAAK,SAAS,EAAC,+BAA+B,aAC5C,uBAAC,8BAAc,IAAC,aAAa,SAAG,EAChC,gCAAK,SAAS,EAAC,8BAA8B,GAAG,IAC5C,CACP,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 \"./ProgressOverlay.scss\";\n\nimport { ProgressLinear } from \"@itwin/itwinui-react\";\n\nexport function ProgressOverlay() {\n return (\n <div className=\"tw-progress-overlay-container\">\n <ProgressLinear indeterminate />\n <div className=\"tw-progress-overlay-backdrop\" />\n </div>\n );\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useSelectionHandler } from "@itwin/presentation-hierarchies-react";
|
|
2
|
-
import type { MarkRequired } from "@itwin/core-bentley";
|
|
3
|
-
import type { FunctionProps } from "../Utils.js";
|
|
4
2
|
import type { ReactNode } from "react";
|
|
3
|
+
import type { MarkRequired } from "@itwin/core-bentley";
|
|
5
4
|
import type { IModelConnection } from "@itwin/core-frontend";
|
|
6
5
|
import type { SchemaContext } from "@itwin/ecschema-metadata";
|
|
7
6
|
import type { PresentationHierarchyNode, SelectionStorage, useIModelTree } from "@itwin/presentation-hierarchies-react";
|
|
8
7
|
import type { HighlightInfo } from "../UseNodeHighlighting.js";
|
|
8
|
+
import type { FunctionProps } from "../Utils.js";
|
|
9
9
|
import type { TreeRendererProps } from "./TreeRenderer.js";
|
|
10
10
|
/** @beta */
|
|
11
11
|
export type TreeProps = Pick<FunctionProps<typeof useIModelTree>, "getFilteredPaths" | "getHierarchyDefinition"> & Partial<Pick<FunctionProps<typeof useSelectionHandler>, "selectionMode">> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/Tree.tsx"],"names":[],"mappings":";;AAwEA,oBAgBC;AAGD,4BAMC;;AAjGD;;;gGAGgG;AAEhG,iCAA8C;AAC9C,sDAA8C;AAC9C,wDAAkE;AAClE,4EAA+E;AAC/E,0FAA2G;AAC3G,6DAAuD;AACvD,oFAA8E;AAC9E,0EAAyE;AACzE,8DAAwD;AACxD,8EAAwE;AACxE,sEAAgE;AAChE,sEAAoF;AACpF,6CAAuC;AACvC,6DAAuD;AAkDvD;;;GAGG;AACH,SAAgB,IAAI,CAAC,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAAG,KAAK,EAAa;IAC3I,MAAM,EAAE,YAAY,EAAE,8BAA8B,EAAE,GAAG,IAAA,oCAAe,EAAC;QACvE,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,YAAY,EAAE,oBAAoB;QAClC,gBAAgB;QAChB,uBAAuB;KACxB,CAAC,CAAC;IACH,OAAO,CACL,uBAAC,QAAQ,OACH,KAAK,EACT,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,YAAY,EAAE,YAAY,EAC1B,8BAA8B,EAAE,8BAA8B,GAC9D,CACH,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,SAAgB,QAAQ,CAAC,EAAE,gBAAgB,EAAE,GAAG,KAAK,EAAwF;IAC3I,OAAO,CACL,uBAAC,uDAA6B,IAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,qBAAqB,EAAE,gBAAgB,YAC1F,uBAAC,YAAY,OAAK,KAAK,GAAI,GACG,CACjC,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,EACpB,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,8BAA8B,EAC9B,sBAA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AAS,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC,EACF,UAAU,CACX,EACH,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAC7B,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useState } from \"react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { Flex, ProgressRadial, Text } from \"@itwin/itwinui-react\";\nimport { SchemaMetadataContextProvider } from \"@itwin/presentation-components\";\nimport { useIModelUnifiedSelectionTree, useSelectionHandler } from \"@itwin/presentation-hierarchies-react\";\nimport { TreeWidget } from \"../../../../TreeWidget.js\";\nimport { useHierarchiesLocalization } from \"../UseHierarchiesLocalization.js\";\nimport { useHierarchyLevelFiltering } from \"../UseHierarchyFiltering.js\";\nimport { useIModelAccess } from \"../UseIModelAccess.js\";\nimport { useIModelChangeListener } from \"../UseIModelChangeListener.js\";\nimport { useNodeHighlighting } from \"../UseNodeHighlighting.js\";\nimport { useReportingAction, useTelemetryContext } from \"../UseTelemetryContext.js\";\nimport { Delayed } from \"./Delayed.js\";\nimport { ProgressOverlay } from \"./ProgressOverlay.js\";\n\nimport type { MarkRequired } from \"@itwin/core-bentley\";\nimport type { FunctionProps } from \"../Utils.js\";\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport type { PresentationHierarchyNode, SelectionStorage, useIModelTree } from \"@itwin/presentation-hierarchies-react\";\nimport type { HighlightInfo } from \"../UseNodeHighlighting.js\";\nimport type { TreeRendererProps } from \"./TreeRenderer.js\";\n\n/** @beta */\nexport type TreeProps = Pick<FunctionProps<typeof useIModelTree>, \"getFilteredPaths\" | \"getHierarchyDefinition\"> &\n Partial<Pick<FunctionProps<typeof useSelectionHandler>, \"selectionMode\">> & {\n /** iModel connection that should be used to pull data from. */\n imodel: IModelConnection;\n /** Callback for getting `SchemaContext` for specific iModel. */\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\n /** Unique tree component name that will be used as unified selection change event source when selecting node. */\n treeName: string;\n /** Unified selection storage that should be used by tree to handle tree selection changes. */\n selectionStorage: SelectionStorage;\n /**\n * An optional predicate to allow or prohibit selection of a node.\n * When not supplied, all nodes are selectable.\n */\n selectionPredicate?: (node: PresentationHierarchyNode) => boolean;\n /** Tree renderer that should be used to render tree data. */\n treeRenderer: (\n treeProps: Required<\n Pick<\n TreeRendererProps,\n \"rootNodes\" | \"expandNode\" | \"onNodeClick\" | \"onNodeKeyDown\" | \"onFilterClick\" | \"isNodeSelected\" | \"getHierarchyLevelDetails\" | \"size\" | \"getLabel\"\n >\n >,\n ) => ReactNode;\n /** Custom iModel access that is stored outside tree component. If not provided it new iModel access will be created using `imodel` prop. */\n imodelAccess?: FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n /** Size limit that should be applied on each hierarchy level. Default to `1000`. */\n hierarchyLevelSizeLimit?: number;\n /** Modifies the density of tree nodes. `enlarged` tree nodes have bigger button hit boxes. */\n density?: \"default\" | \"enlarged\";\n /** Message that should be renderer if there are no tree nodes. */\n noDataMessage?: ReactNode;\n /** Callback that this invoked when tree reloads. */\n onReload?: () => void;\n /** Options for highlighting node labels. */\n highlight?: HighlightInfo;\n };\n\n/**\n * Default tree component that manages tree state and renders using supplied `treeRenderer`.\n * @beta\n */\nexport function Tree({ getSchemaContext, hierarchyLevelSizeLimit, selectionStorage, imodelAccess: providedIModelAccess, ...props }: TreeProps) {\n const { imodelAccess, currentHierarchyLevelSizeLimit } = useIModelAccess({\n imodel: props.imodel,\n imodelAccess: providedIModelAccess,\n getSchemaContext,\n hierarchyLevelSizeLimit,\n });\n return (\n <TreeBase\n {...props}\n getSchemaContext={getSchemaContext}\n selectionStorage={selectionStorage}\n imodelAccess={imodelAccess}\n currentHierarchyLevelSizeLimit={currentHierarchyLevelSizeLimit}\n />\n );\n}\n\n/** @internal */\nexport function TreeBase({ getSchemaContext, ...props }: MarkRequired<TreeProps, \"imodelAccess\"> & { currentHierarchyLevelSizeLimit: number }) {\n return (\n <SchemaMetadataContextProvider imodel={props.imodel} schemaContextProvider={getSchemaContext}>\n <TreeBaseImpl {...props} />\n </SchemaMetadataContextProvider>\n );\n}\n\nfunction TreeBaseImpl({\n imodel,\n imodelAccess,\n treeName,\n noDataMessage,\n getFilteredPaths,\n currentHierarchyLevelSizeLimit,\n getHierarchyDefinition,\n selectionPredicate,\n selectionMode,\n onReload,\n treeRenderer,\n density,\n highlight,\n selectionStorage,\n}: MarkRequired<Omit<TreeProps, \"getSchemaContext\">, \"imodelAccess\"> & { currentHierarchyLevelSizeLimit: number }) {\n const localizedStrings = useHierarchiesLocalization();\n const { onFeatureUsed, onPerformanceMeasured } = useTelemetryContext();\n const [imodelChanged] = useState(new BeEvent<() => void>());\n const {\n rootNodes,\n getNode,\n isLoading,\n selectNodes: selectNodesAction,\n setFormatter: _setFormatter,\n expandNode,\n ...treeProps\n } = useIModelUnifiedSelectionTree({\n imodelAccess,\n imodelChanged,\n getHierarchyDefinition,\n getFilteredPaths,\n sourceName: treeName,\n localizedStrings,\n selectionStorage,\n onPerformanceMeasured: (action, duration) => {\n if (action === \"reload\") {\n onReload?.();\n }\n onPerformanceMeasured(action, duration);\n },\n onHierarchyLimitExceeded: () => onFeatureUsed({ featureId: \"hierarchy-level-size-limit-hit\", reportInteraction: false }),\n onHierarchyLoadError: ({ type, error }) => {\n // eslint-disable-next-line no-console\n console.error(error);\n onFeatureUsed({ featureId: `error-${type}`, reportInteraction: false });\n },\n });\n useIModelChangeListener({ imodel, action: useCallback(() => imodelChanged.raiseEvent(), [imodelChanged]) });\n\n const selectNodes = useSelectionPredicate({\n action: useReportingAction({ action: selectNodesAction }),\n predicate: selectionPredicate,\n getNode,\n });\n const { onNodeClick, onNodeKeyDown } = useSelectionHandler({ rootNodes, selectNodes, selectionMode: selectionMode ?? \"single\" });\n const { filteringDialog, onFilterClick } = useHierarchyLevelFiltering({\n imodel,\n defaultHierarchyLevelSizeLimit: currentHierarchyLevelSizeLimit,\n });\n const reportingExpandNode = useReportingAction({ action: expandNode });\n const reportingOnFilterClicked = useReportingAction({ action: onFilterClick });\n const { getLabel } = useNodeHighlighting({ rootNodes, highlight });\n\n if (rootNodes === undefined) {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\" flexDirection=\"column\" style={{ width: \"100%\", height: \"100%\" }}>\n <Delayed show={true}>\n <ProgressRadial size=\"large\" />\n </Delayed>\n </Flex>\n );\n }\n\n if (rootNodes.length === 0 && !isLoading) {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\" flexDirection=\"column\" style={{ width: \"100%\", height: \"100%\" }}>\n {noDataMessage ? noDataMessage : <Text>{TreeWidget.translate(\"baseTree.dataIsNotAvailable\")}</Text>}\n </Flex>\n );\n }\n\n const treeRendererProps: FunctionProps<TreeProps[\"treeRenderer\"]> = {\n ...treeProps,\n rootNodes,\n onNodeClick,\n onNodeKeyDown,\n expandNode: reportingExpandNode,\n onFilterClick: reportingOnFilterClicked,\n getLabel,\n size: density === \"enlarged\" ? \"default\" : \"small\",\n };\n\n return (\n <div style={{ position: \"relative\", height: \"100%\", overflow: \"hidden\" }}>\n <div id=\"tw-tree-renderer-container\" style={{ height: \"100%\" }}>\n {treeRenderer(treeRendererProps)}\n {filteringDialog}\n </div>\n <Delayed show={isLoading}>\n <ProgressOverlay />\n </Delayed>\n </div>\n );\n}\n\nfunction useSelectionPredicate({\n action,\n predicate,\n getNode,\n}: {\n action: (...args: any[]) => void;\n predicate?: (node: PresentationHierarchyNode) => boolean;\n getNode: (nodeId: string) => PresentationHierarchyNode | undefined;\n}): ReturnType<typeof useIModelUnifiedSelectionTree>[\"selectNodes\"] {\n return useCallback(\n (nodeIds, changeType) =>\n action(\n nodeIds.filter((nodeId) => {\n const node = getNode(nodeId);\n return node && (!predicate || predicate(node));\n }),\n changeType,\n ),\n [action, getNode, predicate],\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/Tree.tsx"],"names":[],"mappings":";;AAwEA,oBAgBC;AAGD,4BAMC;;AAjGD;;;gGAGgG;AAEhG,iCAA8C;AAC9C,sDAA8C;AAC9C,wDAAkE;AAClE,4EAA+E;AAC/E,0FAA2G;AAC3G,6DAAuD;AACvD,oFAA8E;AAC9E,0EAAyE;AACzE,8DAAwD;AACxD,8EAAwE;AACxE,sEAAgE;AAChE,sEAAoF;AACpF,6CAAuC;AACvC,6DAAuD;AAkDvD;;;GAGG;AACH,SAAgB,IAAI,CAAC,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAAG,KAAK,EAAa;IAC3I,MAAM,EAAE,YAAY,EAAE,8BAA8B,EAAE,GAAG,IAAA,oCAAe,EAAC;QACvE,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,YAAY,EAAE,oBAAoB;QAClC,gBAAgB;QAChB,uBAAuB;KACxB,CAAC,CAAC;IACH,OAAO,CACL,uBAAC,QAAQ,OACH,KAAK,EACT,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,YAAY,EAAE,YAAY,EAC1B,8BAA8B,EAAE,8BAA8B,GAC9D,CACH,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,SAAgB,QAAQ,CAAC,EAAE,gBAAgB,EAAE,GAAG,KAAK,EAAwF;IAC3I,OAAO,CACL,uBAAC,uDAA6B,IAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,qBAAqB,EAAE,gBAAgB,YAC1F,uBAAC,YAAY,OAAK,KAAK,GAAI,GACG,CACjC,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,EACpB,MAAM,EACN,YAAY,EACZ,Q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MAAM,CAAC,CAAC;QAC7B,OAAO,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC,EACF,UAAU,CACX,EACH,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAC7B,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useState } from \"react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { Flex, ProgressRadial, Text } from \"@itwin/itwinui-react\";\nimport { SchemaMetadataContextProvider } from \"@itwin/presentation-components\";\nimport { useIModelUnifiedSelectionTree, useSelectionHandler } from \"@itwin/presentation-hierarchies-react\";\nimport { TreeWidget } from \"../../../../TreeWidget.js\";\nimport { useHierarchiesLocalization } from \"../UseHierarchiesLocalization.js\";\nimport { useHierarchyLevelFiltering } from \"../UseHierarchyFiltering.js\";\nimport { useIModelAccess } from \"../UseIModelAccess.js\";\nimport { useIModelChangeListener } from \"../UseIModelChangeListener.js\";\nimport { useNodeHighlighting } from \"../UseNodeHighlighting.js\";\nimport { useReportingAction, useTelemetryContext } from \"../UseTelemetryContext.js\";\nimport { Delayed } from \"./Delayed.js\";\nimport { ProgressOverlay } from \"./ProgressOverlay.js\";\n\nimport type { ReactNode } from \"react\";\nimport type { MarkRequired } from \"@itwin/core-bentley\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport type { PresentationHierarchyNode, SelectionStorage, useIModelTree } from \"@itwin/presentation-hierarchies-react\";\nimport type { HighlightInfo } from \"../UseNodeHighlighting.js\";\nimport type { FunctionProps } from \"../Utils.js\";\nimport type { TreeRendererProps } from \"./TreeRenderer.js\";\n\n/** @beta */\nexport type TreeProps = Pick<FunctionProps<typeof useIModelTree>, \"getFilteredPaths\" | \"getHierarchyDefinition\"> &\n Partial<Pick<FunctionProps<typeof useSelectionHandler>, \"selectionMode\">> & {\n /** iModel connection that should be used to pull data from. */\n imodel: IModelConnection;\n /** Callback for getting `SchemaContext` for specific iModel. */\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\n /** Unique tree component name that will be used as unified selection change event source when selecting node. */\n treeName: string;\n /** Unified selection storage that should be used by tree to handle tree selection changes. */\n selectionStorage: SelectionStorage;\n /**\n * An optional predicate to allow or prohibit selection of a node.\n * When not supplied, all nodes are selectable.\n */\n selectionPredicate?: (node: PresentationHierarchyNode) => boolean;\n /** Tree renderer that should be used to render tree data. */\n treeRenderer: (\n treeProps: Required<\n Pick<\n TreeRendererProps,\n \"rootNodes\" | \"expandNode\" | \"onNodeClick\" | \"onNodeKeyDown\" | \"onFilterClick\" | \"isNodeSelected\" | \"getHierarchyLevelDetails\" | \"size\" | \"getLabel\"\n >\n >,\n ) => ReactNode;\n /** Custom iModel access that is stored outside tree component. If not provided it new iModel access will be created using `imodel` prop. */\n imodelAccess?: FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n /** Size limit that should be applied on each hierarchy level. Default to `1000`. */\n hierarchyLevelSizeLimit?: number;\n /** Modifies the density of tree nodes. `enlarged` tree nodes have bigger button hit boxes. */\n density?: \"default\" | \"enlarged\";\n /** Message that should be renderer if there are no tree nodes. */\n noDataMessage?: ReactNode;\n /** Callback that this invoked when tree reloads. */\n onReload?: () => void;\n /** Options for highlighting node labels. */\n highlight?: HighlightInfo;\n };\n\n/**\n * Default tree component that manages tree state and renders using supplied `treeRenderer`.\n * @beta\n */\nexport function Tree({ getSchemaContext, hierarchyLevelSizeLimit, selectionStorage, imodelAccess: providedIModelAccess, ...props }: TreeProps) {\n const { imodelAccess, currentHierarchyLevelSizeLimit } = useIModelAccess({\n imodel: props.imodel,\n imodelAccess: providedIModelAccess,\n getSchemaContext,\n hierarchyLevelSizeLimit,\n });\n return (\n <TreeBase\n {...props}\n getSchemaContext={getSchemaContext}\n selectionStorage={selectionStorage}\n imodelAccess={imodelAccess}\n currentHierarchyLevelSizeLimit={currentHierarchyLevelSizeLimit}\n />\n );\n}\n\n/** @internal */\nexport function TreeBase({ getSchemaContext, ...props }: MarkRequired<TreeProps, \"imodelAccess\"> & { currentHierarchyLevelSizeLimit: number }) {\n return (\n <SchemaMetadataContextProvider imodel={props.imodel} schemaContextProvider={getSchemaContext}>\n <TreeBaseImpl {...props} />\n </SchemaMetadataContextProvider>\n );\n}\n\nfunction TreeBaseImpl({\n imodel,\n imodelAccess,\n treeName,\n noDataMessage,\n getFilteredPaths,\n currentHierarchyLevelSizeLimit,\n getHierarchyDefinition,\n selectionPredicate,\n selectionMode,\n onReload,\n treeRenderer,\n density,\n highlight,\n selectionStorage,\n}: MarkRequired<Omit<TreeProps, \"getSchemaContext\">, \"imodelAccess\"> & { currentHierarchyLevelSizeLimit: number }) {\n const localizedStrings = useHierarchiesLocalization();\n const { onFeatureUsed, onPerformanceMeasured } = useTelemetryContext();\n const [imodelChanged] = useState(new BeEvent<() => void>());\n const {\n rootNodes,\n getNode,\n isLoading,\n selectNodes: selectNodesAction,\n setFormatter: _setFormatter,\n expandNode,\n ...treeProps\n } = useIModelUnifiedSelectionTree({\n imodelAccess,\n imodelChanged,\n getHierarchyDefinition,\n getFilteredPaths,\n sourceName: treeName,\n localizedStrings,\n selectionStorage,\n onPerformanceMeasured: (action, duration) => {\n if (action === \"reload\") {\n onReload?.();\n }\n onPerformanceMeasured(action, duration);\n },\n onHierarchyLimitExceeded: () => onFeatureUsed({ featureId: \"hierarchy-level-size-limit-hit\", reportInteraction: false }),\n onHierarchyLoadError: ({ type, error }) => {\n // eslint-disable-next-line no-console\n console.error(error);\n onFeatureUsed({ featureId: `error-${type}`, reportInteraction: false });\n },\n });\n useIModelChangeListener({ imodel, action: useCallback(() => imodelChanged.raiseEvent(), [imodelChanged]) });\n\n const selectNodes = useSelectionPredicate({\n action: useReportingAction({ action: selectNodesAction }),\n predicate: selectionPredicate,\n getNode,\n });\n const { onNodeClick, onNodeKeyDown } = useSelectionHandler({ rootNodes, selectNodes, selectionMode: selectionMode ?? \"single\" });\n const { filteringDialog, onFilterClick } = useHierarchyLevelFiltering({\n imodel,\n defaultHierarchyLevelSizeLimit: currentHierarchyLevelSizeLimit,\n });\n const reportingExpandNode = useReportingAction({ action: expandNode });\n const reportingOnFilterClicked = useReportingAction({ action: onFilterClick });\n const { getLabel } = useNodeHighlighting({ rootNodes, highlight });\n\n if (rootNodes === undefined) {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\" flexDirection=\"column\" style={{ width: \"100%\", height: \"100%\" }}>\n <Delayed show={true}>\n <ProgressRadial size=\"large\" />\n </Delayed>\n </Flex>\n );\n }\n\n if (rootNodes.length === 0 && !isLoading) {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\" flexDirection=\"column\" style={{ width: \"100%\", height: \"100%\" }}>\n {noDataMessage ? noDataMessage : <Text>{TreeWidget.translate(\"baseTree.dataIsNotAvailable\")}</Text>}\n </Flex>\n );\n }\n\n const treeRendererProps: FunctionProps<TreeProps[\"treeRenderer\"]> = {\n ...treeProps,\n rootNodes,\n onNodeClick,\n onNodeKeyDown,\n expandNode: reportingExpandNode,\n onFilterClick: reportingOnFilterClicked,\n getLabel,\n size: density === \"enlarged\" ? \"default\" : \"small\",\n };\n\n return (\n <div style={{ position: \"relative\", height: \"100%\", overflow: \"hidden\" }}>\n <div id=\"tw-tree-renderer-container\" style={{ height: \"100%\" }}>\n {treeRenderer(treeRendererProps)}\n {filteringDialog}\n </div>\n <Delayed show={isLoading}>\n <ProgressOverlay />\n </Delayed>\n </div>\n );\n}\n\nfunction useSelectionPredicate({\n action,\n predicate,\n getNode,\n}: {\n action: (...args: any[]) => void;\n predicate?: (node: PresentationHierarchyNode) => boolean;\n getNode: (nodeId: string) => PresentationHierarchyNode | undefined;\n}): ReturnType<typeof useIModelUnifiedSelectionTree>[\"selectNodes\"] {\n return useCallback(\n (nodeIds, changeType) =>\n action(\n nodeIds.filter((nodeId) => {\n const node = getNode(nodeId);\n return node && (!predicate || predicate(node));\n }),\n changeType,\n ),\n [action, getNode, predicate],\n );\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Checkbox } from "@itwin/itwinui-react";
|
|
2
|
-
import type { PresentationHierarchyNode, RenderedTreeNode } from "@itwin/presentation-hierarchies-react";
|
|
3
2
|
import type { ComponentPropsWithoutRef } from "react";
|
|
3
|
+
import type { PresentationHierarchyNode, RenderedTreeNode } from "@itwin/presentation-hierarchies-react";
|
|
4
4
|
/**
|
|
5
5
|
* Data structure that describes tree node checkbox state.
|
|
6
6
|
* @beta
|
package/lib/cjs/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeCheckbox.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.tsx"],"names":[],"mappings":";;AAwCA,4CA+BC;;AAvED;;;gGAGgG;AAEhG,wDAAyD;AACzD,0FAAoF;AAiCpF,gBAAgB;AAChB,SAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,GAAG,KAAK,EAAsD;IAC1I,IAAI,MAAM,IAAI,IAAI,IAAI,CAAC,IAAA,4DAA2B,EAAC,IAAI,CAAC,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,aAAa,GAA8C;QAC/D,GAAG,KAAK;QACR,YAAY,EAAE,aAAa,CAAC,OAAO;QACnC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACb,CAAC,CAAC,eAAe,EAAE,CAAC;QACtB,CAAC;QACD,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;YACd,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACnD,CAAC;KACF,CAAC;IACF,IAAI,WAAW,IAAI,aAAa,EAAE,CAAC;QACjC,aAAa,CAAC,KAAK,GAAG;YACpB,GAAG,aAAa,CAAC,KAAK;YACtB,UAAU,EAAE,QAAQ;SACrB,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,aAAa,CAAC,OAAO,GAAG,aAAa,CAAC,KAAK,KAAK,IAAI,CAAC;QACrD,aAAa,CAAC,aAAa,GAAG,aAAa,CAAC,KAAK,KAAK,SAAS,CAAC;QAChE,aAAa,CAAC,QAAQ,GAAG,aAAa,CAAC,UAAU,CAAC;IACpD,CAAC;IACD,OAAO,CACL,uBAAC,cAAc,IAAC,OAAO,EAAE,aAAa,CAAC,OAAO,YAC5C,uBAAC,wBAAQ,OAAK,aAAa,GAAI,GAChB,CAClB,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAoD;IAC7F,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CACjB,uBAAC,uBAAO,IAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAC,MAAM,YACxC,QAAQ,GACD,CACX,CAAC,CAAC,CAAC,CACF,2DAAG,QAAQ,GAAI,CAChB,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 { Checkbox, Tooltip } from \"@itwin/itwinui-react\";\nimport { isPresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\n\nimport type {
|
|
1
|
+
{"version":3,"file":"TreeNodeCheckbox.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.tsx"],"names":[],"mappings":";;AAwCA,4CA+BC;;AAvED;;;gGAGgG;AAEhG,wDAAyD;AACzD,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,OAAO,EAAE,OAAO,EAAE,SAAS,EAAC,MAAM,YACxC,QAAQ,GACD,CACX,CAAC,CAAC,CAAC,CACF,2DAAG,QAAQ,GAAI,CAChB,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 { Checkbox, Tooltip } from \"@itwin/itwinui-react\";\nimport { isPresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\n\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { PresentationHierarchyNode, RenderedTreeNode } from \"@itwin/presentation-hierarchies-react\";\n\n/**\n * Data structure that describes tree node checkbox state.\n * @beta\n */\ntype TreeNodeCheckboxState = (\n | {\n state: \"on\" | \"off\" | \"partial\";\n isDisabled?: boolean;\n }\n | {\n isLoading: true;\n }\n) & {\n tooltip?: string;\n};\n\n/** @beta */\nexport interface TreeCheckboxProps {\n /** Callback that should be invoked when checkbox is clicked. */\n onCheckboxClicked: (node: PresentationHierarchyNode, checked: boolean) => void;\n /** Callback that should be used to determine current checkbox state. */\n getCheckboxState: (node: PresentationHierarchyNode) => TreeNodeCheckboxState;\n}\n\n/** @internal */\ntype TreeNodeCheckboxProps = TreeCheckboxProps &\n Omit<ComponentPropsWithoutRef<typeof Checkbox>, \"onClick\" | \"checked\" | \"onChange\" | \"indeterminate\" | \"disabled\" | \"title\">;\n\n/** @internal */\nexport function TreeNodeCheckbox({ node, onCheckboxClicked, getCheckboxState, ...props }: TreeNodeCheckboxProps & { node: RenderedTreeNode }) {\n if (\"type\" in node || !isPresentationHierarchyNode(node)) {\n return null;\n }\n\n const checkboxState = getCheckboxState(node);\n const checkboxProps: ComponentPropsWithoutRef<typeof Checkbox> = {\n ...props,\n \"aria-label\": checkboxState.tooltip,\n onClick: (e) => {\n e.stopPropagation();\n },\n onChange: (e) => {\n onCheckboxClicked(node, e.currentTarget.checked);\n },\n };\n if (\"isLoading\" in checkboxState) {\n checkboxProps.style = {\n ...checkboxProps.style,\n visibility: \"hidden\",\n };\n } else {\n checkboxProps.checked = checkboxState.state === \"on\";\n checkboxProps.indeterminate = checkboxState.state === \"partial\";\n checkboxProps.disabled = checkboxState.isDisabled;\n }\n return (\n <TooltipWrapper content={checkboxState.tooltip}>\n <Checkbox {...checkboxProps} />\n </TooltipWrapper>\n );\n}\n\nfunction TooltipWrapper({ content, children }: { content?: string; children?: React.ReactNode }) {\n return !!content ? (\n <Tooltip content={content} placement=\"left\">\n {children}\n </Tooltip>\n ) : (\n <>{children}</>\n );\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Tree } from "@itwin/itwinui-react";
|
|
2
|
-
import type { TreeNodeRendererProps } from "./TreeNodeRenderer.js";
|
|
3
2
|
import type { ComponentPropsWithoutRef } from "react";
|
|
4
3
|
import type { PresentationHierarchyNode, PresentationTreeNode, RenderedTreeNode } from "@itwin/presentation-hierarchies-react";
|
|
4
|
+
import type { TreeNodeRendererProps } from "./TreeNodeRenderer.js";
|
|
5
5
|
/** @beta */
|
|
6
6
|
export type TreeRendererProps = Pick<TreeNodeRendererProps, "expandNode" | "onNodeClick" | "onNodeKeyDown" | "onFilterClick" | "getIcon" | "getLabel" | "getSublabel" | "getActions" | "getHierarchyLevelDetails" | "checkboxProps" | "reloadTree" | "filterButtonsVisibility"> & Omit<ComponentPropsWithoutRef<typeof Tree<RenderedTreeNode>>, "data" | "nodeRenderer" | "getNode"> & {
|
|
7
7
|
/** Tree nodes to render. */
|
|
@@ -9,8 +9,8 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
9
9
|
const react_1 = require("react");
|
|
10
10
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
11
11
|
const presentation_hierarchies_react_1 = require("@itwin/presentation-hierarchies-react");
|
|
12
|
-
const TreeNodeRenderer_js_1 = require("./TreeNodeRenderer.js");
|
|
13
12
|
const UseHierarchiesLocalization_js_1 = require("../UseHierarchiesLocalization.js");
|
|
13
|
+
const TreeNodeRenderer_js_1 = require("./TreeNodeRenderer.js");
|
|
14
14
|
/**
|
|
15
15
|
* Default renderer for rendering tree data.
|
|
16
16
|
* @beta
|
|
@@ -43,6 +43,6 @@ function TreeRenderer({ rootNodes, expandNode, onNodeClick, onNodeKeyDown, onNod
|
|
|
43
43
|
size,
|
|
44
44
|
]);
|
|
45
45
|
const getNode = (0, react_1.useCallback)((node) => (0, presentation_hierarchies_react_1.createRenderedTreeNodeData)(node, isNodeSelected), [isNodeSelected]);
|
|
46
|
-
return ((0, jsx_runtime_1.jsx)(presentation_hierarchies_react_1.LocalizationContextProvider, { localizedStrings: localizedStrings, children: (0, jsx_runtime_1.jsx)(itwinui_react_1.Tree, { ...props, data: rootNodes, nodeRenderer: nodeRenderer, getNode: getNode, enableVirtualization: enableVirtualization ?? true, style: { height: "100%" }, size: size }) }));
|
|
46
|
+
return ((0, jsx_runtime_1.jsx)(presentation_hierarchies_react_1.LocalizationContextProvider, { localizedStrings: localizedStrings, children: (0, jsx_runtime_1.jsx)(itwinui_react_1.Tree, { ...props, data: rootNodes, id: "tw-tree-renderer", nodeRenderer: nodeRenderer, getNode: getNode, enableVirtualization: enableVirtualization ?? true, style: { height: "100%" }, size: size }) }));
|
|
47
47
|
}
|
|
48
48
|
//# sourceMappingURL=TreeRenderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/TreeRenderer.tsx"],"names":[],"mappings":";;AA4CA,
|
|
1
|
+
{"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/TreeRenderer.tsx"],"names":[],"mappings":";;AA4CA,oCAsFC;;AAlID;;;gGAGgG;AAEhG,iCAAoC;AACpC,wDAA4C;AAC5C,0FAAgH;AAChH,oFAA8E;AAC9E,+DAAyD;A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AAO;QACP,QAAQ;QACR,WAAW;QACX,UAAU;QACV,aAAa;QACb,aAAa;QACb,uBAAuB;QACvB,UAAU;QACV,IAAI;KACL,CACF,CAAC;IAEF,MAAM,OAAO,GAAG,IAAA,mBAAW,EACzB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,2DAA0B,EAAC,IAAI,EAAE,cAAc,CAAC,EAC1D,CAAC,cAAc,CAAC,CACjB,CAAC;IAEF,OAAO,CACL,uBAAC,4DAA2B,IAAC,gBAAgB,EAAE,gBAAgB,YAC7D,uBAAC,oBAAI,OACC,KAAK,EACT,IAAI,EAAE,SAAS,EACf,EAAE,EAAE,kBAAkB,EACtB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,OAAO,EAChB,oBAAoB,EAAE,oBAAoB,IAAI,IAAI,EAClD,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EACzB,IAAI,EAAE,IAAI,GACV,GAC0B,CAC/B,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback } from \"react\";\nimport { Tree } from \"@itwin/itwinui-react\";\nimport { createRenderedTreeNodeData, LocalizationContextProvider } from \"@itwin/presentation-hierarchies-react\";\nimport { useHierarchiesLocalization } from \"../UseHierarchiesLocalization.js\";\nimport { TreeNodeRenderer } from \"./TreeNodeRenderer.js\";\n\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { PresentationHierarchyNode, PresentationTreeNode, RenderedTreeNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { TreeNodeRendererProps } from \"./TreeNodeRenderer.js\";\n\n/** @beta */\nexport type TreeRendererProps = Pick<\n TreeNodeRendererProps,\n | \"expandNode\"\n | \"onNodeClick\"\n | \"onNodeKeyDown\"\n | \"onFilterClick\"\n | \"getIcon\"\n | \"getLabel\"\n | \"getSublabel\"\n | \"getActions\"\n | \"getHierarchyLevelDetails\"\n | \"checkboxProps\"\n | \"reloadTree\"\n | \"filterButtonsVisibility\"\n> &\n Omit<ComponentPropsWithoutRef<typeof Tree<RenderedTreeNode>>, \"data\" | \"nodeRenderer\" | \"getNode\"> & {\n /** Tree nodes to render. */\n rootNodes: PresentationTreeNode[];\n /** Callback to check if specific node is selected. */\n isNodeSelected: (nodeId: string) => boolean;\n /** Callback that is invoked when node is double clicked. */\n onNodeDoubleClick?: (node: PresentationHierarchyNode, isSelected: boolean) => void;\n };\n\n/**\n * Default renderer for rendering tree data.\n * @beta\n */\nexport function TreeRenderer({\n rootNodes,\n expandNode,\n onNodeClick,\n onNodeKeyDown,\n onNodeDoubleClick,\n isNodeSelected,\n onFilterClick,\n getIcon,\n getLabel,\n getSublabel,\n getActions,\n getHierarchyLevelDetails,\n checkboxProps,\n filterButtonsVisibility,\n reloadTree,\n size,\n enableVirtualization,\n ...props\n}: TreeRendererProps) {\n const localizedStrings = useHierarchiesLocalization();\n const nodeRenderer = useCallback<ComponentPropsWithoutRef<typeof Tree<RenderedTreeNode>>[\"nodeRenderer\"]>(\n (nodeProps) => {\n return (\n <TreeNodeRenderer\n {...nodeProps}\n onNodeClick={(node, isSelected, event) => {\n if (onNodeDoubleClick && event.detail === 2) {\n onNodeDoubleClick?.(node, !!nodeProps.isSelected);\n // Click node to not lose selection\n return onNodeClick?.(node, true, event);\n }\n onNodeClick?.(node, isSelected, event);\n }}\n expandNode={expandNode}\n onNodeKeyDown={onNodeKeyDown}\n getIcon={getIcon}\n getLabel={getLabel}\n getSublabel={getSublabel}\n getActions={getActions}\n onFilterClick={onFilterClick}\n getHierarchyLevelDetails={getHierarchyLevelDetails}\n checkboxProps={checkboxProps}\n reloadTree={reloadTree}\n size={size}\n filterButtonsVisibility={filterButtonsVisibility}\n />\n );\n },\n [\n expandNode,\n onNodeClick,\n onNodeKeyDown,\n onNodeDoubleClick,\n getHierarchyLevelDetails,\n getIcon,\n getLabel,\n getSublabel,\n getActions,\n onFilterClick,\n checkboxProps,\n filterButtonsVisibility,\n reloadTree,\n size,\n ],\n );\n\n const getNode = useCallback<ComponentPropsWithoutRef<typeof Tree<RenderedTreeNode>>[\"getNode\"]>(\n (node) => createRenderedTreeNodeData(node, isNodeSelected),\n [isNodeSelected],\n );\n\n return (\n <LocalizationContextProvider localizedStrings={localizedStrings}>\n <Tree<RenderedTreeNode>\n {...props}\n data={rootNodes}\n id={\"tw-tree-renderer\"}\n nodeRenderer={nodeRenderer}\n getNode={getNode}\n enableVirtualization={enableVirtualization ?? true}\n style={{ height: \"100%\" }}\n size={size}\n />\n </LocalizationContextProvider>\n );\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { TreeProps } from "./Tree.js";
|
|
2
|
-
import type { FunctionProps } from "../Utils.js";
|
|
3
1
|
import type { ReactNode } from "react";
|
|
4
|
-
import type { VisibilityTreeRendererProps } from "./VisibilityTreeRenderer.js";
|
|
5
2
|
import type { ECClassHierarchyInspector } from "@itwin/presentation-shared";
|
|
6
3
|
import type { HierarchyVisibilityHandler } from "../UseHierarchyVisibility.js";
|
|
4
|
+
import type { FunctionProps } from "../Utils.js";
|
|
5
|
+
import type { TreeProps } from "./Tree.js";
|
|
6
|
+
import type { VisibilityTreeRendererProps } from "./VisibilityTreeRenderer.js";
|
|
7
7
|
/** @beta */
|
|
8
8
|
export type VisibilityTreeProps = Omit<TreeProps, "treeRenderer" | "imodelAccess"> & {
|
|
9
9
|
/** Callback for creating visibility handler used to control visibility of instances represented by tree nodes. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisibilityTree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/VisibilityTree.tsx"],"names":[],"mappings":";;AA+BA,wCAqBC;;AApDD;;;gGAGgG;AAEhG,iCAAoC;AACpC,4EAAsE;AACtE,8DAAwD;AACxD,uCAAqC;AAmBrC;;;GAGG;AACH,SAAgB,cAAc,CAAC,EAAE,wBAAwB,EAAE,YAAY,EAAE,uBAAuB,EAAE,GAAG,KAAK,EAAuB;IAC/H,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;IAC3C,MAAM,EAAE,YAAY,EAAE,8BAA8B,EAAE,GAAG,IAAA,oCAAe,EAAC;QACvE,MAAM;QACN,gBAAgB;QAChB,uBAAuB;KACxB,CAAC,CAAC;IAEH,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,IAAA,kDAAsB,EAAC;QACrF,wBAAwB,EAAE,IAAA,mBAAW,EAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,wBAAwB,EAAE,YAAY,CAAC,CAAC;KAClI,CAAC,CAAC;IAEH,OAAO,CACL,uBAAC,kBAAQ,OACH,KAAK,EACT,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,YAAY,EAC1B,8BAA8B,EAAE,8BAA8B,EAC9D,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,EAAE,GAAG,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC,GAChG,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback } from \"react\";\nimport { useHierarchyVisibility } from \"../UseHierarchyVisibility.js\";\nimport { useIModelAccess } from \"../UseIModelAccess.js\";\nimport { TreeBase } from \"./Tree.js\";\n\nimport type {
|
|
1
|
+
{"version":3,"file":"VisibilityTree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/VisibilityTree.tsx"],"names":[],"mappings":";;AA+BA,wCAqBC;;AApDD;;;gGAGgG;AAEhG,iCAAoC;AACpC,4EAAsE;AACtE,8DAAwD;AACxD,uCAAqC;AAmBrC;;;GAGG;AACH,SAAgB,cAAc,CAAC,EAAE,wBAAwB,EAAE,YAAY,EAAE,uBAAuB,EAAE,GAAG,KAAK,EAAuB;IAC/H,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;IAC3C,MAAM,EAAE,YAAY,EAAE,8BAA8B,EAAE,GAAG,IAAA,oCAAe,EAAC;QACvE,MAAM;QACN,gBAAgB;QAChB,uBAAuB;KACxB,CAAC,CAAC;IAEH,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,IAAA,kDAAsB,EAAC;QACrF,wBAAwB,EAAE,IAAA,mBAAW,EAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,wBAAwB,EAAE,YAAY,CAAC,CAAC;KAClI,CAAC,CAAC;IAEH,OAAO,CACL,uBAAC,kBAAQ,OACH,KAAK,EACT,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,YAAY,EAC1B,8BAA8B,EAAE,8BAA8B,EAC9D,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,EAAE,GAAG,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC,GAChG,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback } from \"react\";\nimport { useHierarchyVisibility } from \"../UseHierarchyVisibility.js\";\nimport { useIModelAccess } from \"../UseIModelAccess.js\";\nimport { TreeBase } from \"./Tree.js\";\n\nimport type { ReactNode } from \"react\";\nimport type { ECClassHierarchyInspector } from \"@itwin/presentation-shared\";\nimport type { HierarchyVisibilityHandler } from \"../UseHierarchyVisibility.js\";\nimport type { FunctionProps } from \"../Utils.js\";\nimport type { TreeProps } from \"./Tree.js\";\nimport type { VisibilityTreeRendererProps } from \"./VisibilityTreeRenderer.js\";\n\n/** @beta */\nexport type VisibilityTreeProps = Omit<TreeProps, \"treeRenderer\" | \"imodelAccess\"> & {\n /** Callback for creating visibility handler used to control visibility of instances represented by tree nodes. */\n visibilityHandlerFactory: (props: { imodelAccess: ECClassHierarchyInspector }) => HierarchyVisibilityHandler;\n /** Tree renderer that should be used to render tree data. */\n treeRenderer: (\n treeProps: FunctionProps<TreeProps[\"treeRenderer\"]> & Pick<VisibilityTreeRendererProps, \"getCheckboxState\" | \"onCheckboxClicked\">,\n ) => ReactNode;\n};\n\n/**\n * Tree component that can control visibility of instances represented by tree nodes.\n * @beta\n */\nexport function VisibilityTree({ visibilityHandlerFactory, treeRenderer, hierarchyLevelSizeLimit, ...props }: VisibilityTreeProps) {\n const { imodel, getSchemaContext } = props;\n const { imodelAccess, currentHierarchyLevelSizeLimit } = useIModelAccess({\n imodel,\n getSchemaContext,\n hierarchyLevelSizeLimit,\n });\n\n const { getCheckboxState, onCheckboxClicked, triggerRefresh } = useHierarchyVisibility({\n visibilityHandlerFactory: useCallback(() => visibilityHandlerFactory({ imodelAccess }), [visibilityHandlerFactory, imodelAccess]),\n });\n\n return (\n <TreeBase\n {...props}\n onReload={triggerRefresh}\n imodelAccess={imodelAccess}\n currentHierarchyLevelSizeLimit={currentHierarchyLevelSizeLimit}\n treeRenderer={(treeProps) => treeRenderer({ ...treeProps, getCheckboxState, onCheckboxClicked })}\n />\n );\n}\n"]}
|
package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { TreeRendererProps } from "./TreeRenderer.js";
|
|
2
1
|
import type { TreeCheckboxProps } from "./TreeNodeCheckbox.js";
|
|
2
|
+
import type { TreeRendererProps } from "./TreeRenderer.js";
|
|
3
3
|
/** @beta */
|
|
4
4
|
export type VisibilityTreeRendererProps = TreeRendererProps & TreeCheckboxProps;
|
|
5
5
|
/**
|
package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisibilityTreeRenderer.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.tsx"],"names":[],"mappings":";;AAmBA,wDAaC;;AAhCD;;;gGAGgG;AAEhG,iCAAgC;AAChC,8EAAwE;AACxE,uDAAiD;AAQjD;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,KAAK,EAA+B;IAC5H,MAAM,EAAE,iBAAiB,EAAE,GAAG,IAAA,oDAAuB,EAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC,CAAC;IAErI,MAAM,aAAa,GAAuC,IAAA,eAAO,EAC/D,GAAG,EAAE,CAAC,CAAC;QACL,OAAO,EAAE,SAAS;QAClB,gBAAgB;QAChB,iBAAiB;KAClB,CAAC,EACF,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,CACtC,CAAC;IAEF,OAAO,uBAAC,8BAAY,OAAK,KAAK,EAAE,aAAa,EAAE,aAAa,GAAI,CAAC;AACnE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useMemo } from \"react\";\nimport { useMultiCheckboxHandler } from \"../UseMultiCheckboxHandler.js\";\nimport { TreeRenderer } from \"./TreeRenderer.js\";\n\nimport type {
|
|
1
|
+
{"version":3,"file":"VisibilityTreeRenderer.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.tsx"],"names":[],"mappings":";;AAmBA,wDAaC;;AAhCD;;;gGAGgG;AAEhG,iCAAgC;AAChC,8EAAwE;AACxE,uDAAiD;AAQjD;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,KAAK,EAA+B;IAC5H,MAAM,EAAE,iBAAiB,EAAE,GAAG,IAAA,oDAAuB,EAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC,CAAC;IAErI,MAAM,aAAa,GAAuC,IAAA,eAAO,EAC/D,GAAG,EAAE,CAAC,CAAC;QACL,OAAO,EAAE,SAAS;QAClB,gBAAgB;QAChB,iBAAiB;KAClB,CAAC,EACF,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,CACtC,CAAC;IAEF,OAAO,uBAAC,8BAAY,OAAK,KAAK,EAAE,aAAa,EAAE,aAAa,GAAI,CAAC;AACnE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useMemo } from \"react\";\nimport { useMultiCheckboxHandler } from \"../UseMultiCheckboxHandler.js\";\nimport { TreeRenderer } from \"./TreeRenderer.js\";\n\nimport type { TreeCheckboxProps } from \"./TreeNodeCheckbox.js\";\nimport type { TreeRendererProps } from \"./TreeRenderer.js\";\n\n/** @beta */\nexport type VisibilityTreeRendererProps = TreeRendererProps & TreeCheckboxProps;\n\n/**\n * Tree renderer that renders tree nodes with eye checkboxes for controlling visibility of instances represented by tree nodes.\n * @beta\n */\nexport function VisibilityTreeRenderer({ getCheckboxState, onCheckboxClicked: onClick, ...props }: VisibilityTreeRendererProps) {\n const { onCheckboxClicked } = useMultiCheckboxHandler({ rootNodes: props.rootNodes, isNodeSelected: props.isNodeSelected, onClick });\n\n const checkboxProps: TreeRendererProps[\"checkboxProps\"] = useMemo(\n () => ({\n variant: \"eyeball\",\n getCheckboxState,\n onCheckboxClicked,\n }),\n [getCheckboxState, onCheckboxClicked],\n );\n\n return <TreeRenderer {...props} checkboxProps={checkboxProps} />;\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Observable, OperatorFunction } from "rxjs";
|
|
2
|
+
import type { Visibility } from "../Tooltip.js";
|
|
3
|
+
import type { VisibilityStatus } from "../UseHierarchyVisibility.js";
|
|
4
|
+
/** @internal */
|
|
5
|
+
export declare function setDifference<T>(lhs: Readonly<Iterable<T>>, rhs: ReadonlySet<T>): Set<T>;
|
|
6
|
+
/** @internal */
|
|
7
|
+
export declare function setIntersection<T>(lhs: Readonly<Iterable<T>>, rhs: ReadonlySet<T>): Set<T>;
|
|
8
|
+
/** @internal */
|
|
9
|
+
export declare function mergeVisibilities(obs: Observable<Visibility>): Observable<Visibility | "empty">;
|
|
10
|
+
/** @internal */
|
|
11
|
+
export declare function mergeVisibilityStatuses(tooltipMap?: {
|
|
12
|
+
[key in Visibility]: string | undefined;
|
|
13
|
+
}, ignoreTooltip?: boolean): OperatorFunction<VisibilityStatus, VisibilityStatus>;
|
|
14
|
+
/** @internal */
|
|
15
|
+
export declare function getTooltipOptions(key: string | undefined, ignoreTooltip?: boolean): {
|
|
16
|
+
useTooltip: string | false | undefined;
|
|
17
|
+
};
|
|
18
|
+
/** @internal */
|
|
19
|
+
export declare function releaseMainThreadOnItemsCount<T>(elementCount: number): (obs: Observable<T>) => Observable<T>;
|
|
20
|
+
/** @internal */
|
|
21
|
+
export declare function getOptimalBatchSize({ totalSize, maximumBatchSize }: {
|
|
22
|
+
totalSize: number;
|
|
23
|
+
maximumBatchSize: number;
|
|
24
|
+
}): number;
|
|
25
|
+
//# sourceMappingURL=Utils.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.setDifference = setDifference;
|
|
8
|
+
exports.setIntersection = setIntersection;
|
|
9
|
+
exports.mergeVisibilities = mergeVisibilities;
|
|
10
|
+
exports.mergeVisibilityStatuses = mergeVisibilityStatuses;
|
|
11
|
+
exports.getTooltipOptions = getTooltipOptions;
|
|
12
|
+
exports.releaseMainThreadOnItemsCount = releaseMainThreadOnItemsCount;
|
|
13
|
+
exports.getOptimalBatchSize = getOptimalBatchSize;
|
|
14
|
+
const rxjs_1 = require("rxjs");
|
|
15
|
+
const Rxjs_js_1 = require("../Rxjs.js");
|
|
16
|
+
const Tooltip_js_1 = require("../Tooltip.js");
|
|
17
|
+
/** @internal */
|
|
18
|
+
function setDifference(lhs, rhs) {
|
|
19
|
+
const result = new Set();
|
|
20
|
+
for (const x of lhs) {
|
|
21
|
+
if (!rhs.has(x)) {
|
|
22
|
+
result.add(x);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
/** @internal */
|
|
28
|
+
function setIntersection(lhs, rhs) {
|
|
29
|
+
const result = new Set();
|
|
30
|
+
for (const x of lhs) {
|
|
31
|
+
if (rhs.has(x)) {
|
|
32
|
+
result.add(x);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
/** @internal */
|
|
38
|
+
function mergeVisibilities(obs) {
|
|
39
|
+
return obs.pipe((0, Rxjs_js_1.reduceWhile)((x) => x.allVisible || x.allHidden, (acc, val) => {
|
|
40
|
+
acc.allVisible &&= val === "visible";
|
|
41
|
+
acc.allHidden &&= val === "hidden";
|
|
42
|
+
return acc;
|
|
43
|
+
}, { allVisible: true, allHidden: true }), (0, rxjs_1.map)((x) => {
|
|
44
|
+
if (!x) {
|
|
45
|
+
return "empty";
|
|
46
|
+
}
|
|
47
|
+
return x.allVisible ? "visible" : x.allHidden ? "hidden" : "partial";
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
/** @internal */
|
|
51
|
+
function mergeVisibilityStatuses(tooltipMap, ignoreTooltip) {
|
|
52
|
+
return (obs) => {
|
|
53
|
+
return obs.pipe((0, rxjs_1.map)((visibilityStatus) => visibilityStatus.state), mergeVisibilities, (0, rxjs_1.map)((visibility) => {
|
|
54
|
+
if (visibility === "empty") {
|
|
55
|
+
visibility = "visible";
|
|
56
|
+
}
|
|
57
|
+
return (0, Tooltip_js_1.createVisibilityStatus)(visibility, getTooltipOptions(tooltipMap?.[visibility], ignoreTooltip));
|
|
58
|
+
}));
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** @internal */
|
|
62
|
+
function getTooltipOptions(key, ignoreTooltip) {
|
|
63
|
+
return {
|
|
64
|
+
useTooltip: ignoreTooltip ? false : key,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** @internal */
|
|
68
|
+
function releaseMainThreadOnItemsCount(elementCount) {
|
|
69
|
+
return (obs) => {
|
|
70
|
+
return obs.pipe((0, rxjs_1.bufferCount)(elementCount), (0, rxjs_1.concatMap)((buff, i) => {
|
|
71
|
+
const out = (0, rxjs_1.of)(buff);
|
|
72
|
+
if (i === 0 && buff.length < elementCount) {
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
75
|
+
return out.pipe((0, rxjs_1.delay)(0));
|
|
76
|
+
}), (0, rxjs_1.concatAll)());
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** @internal */
|
|
80
|
+
function getOptimalBatchSize({ totalSize, maximumBatchSize }) {
|
|
81
|
+
return Math.ceil(totalSize / Math.ceil(totalSize / maximumBatchSize));
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=Utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/internal/Utils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAWhG,sCAQC;AAGD,0CAQC;AAGD,8CAkBC;AAGD,0DAgBC;AAGD,8CAIC;AAGD,sEAcC;AAGD,kDAEC;AAjGD,+BAAyE;AACzE,wCAAyC;AACzC,8CAAuD;AAMvD,gBAAgB;AAChB,SAAgB,aAAa,CAAI,GAA0B,EAAE,GAAmB;IAC9E,MAAM,MAAM,GAAG,IAAI,GAAG,EAAK,CAAC;IAC5B,KAAK,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAChB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,gBAAgB;AAChB,SAAgB,eAAe,CAAI,GAA0B,EAAE,GAAmB;IAChF,MAAM,MAAM,GAAG,IAAI,GAAG,EAAK,CAAC;IAC5B,KAAK,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;QACpB,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACf,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,gBAAgB;AAChB,SAAgB,iBAAiB,CAAC,GAA2B;IAC3D,OAAO,GAAG,CAAC,IAAI,CACb,IAAA,qBAAW,EACT,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,SAAS,EAClC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACX,GAAG,CAAC,UAAU,KAAK,GAAG,KAAK,SAAS,CAAC;QACrC,GAAG,CAAC,SAAS,KAAK,GAAG,KAAK,QAAQ,CAAC;QACnC,OAAO,GAAG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AAY,CAAC,EACzB,IAAA,gBAAS,EAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;YACpB,MAAM,GAAG,GAAG,IAAA,SAAE,EAAC,IAAI,CAAC,CAAC;YACrB,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,YAAY,EAAE,CAAC;gBAC1C,OAAO,GAAG,CAAC;YACb,CAAC;YACD,OAAO,GAAG,CAAC,IAAI,CAAC,IAAA,YAAK,EAAC,CAAC,CAAC,CAAC,CAAC;QAC5B,CAAC,CAAC,EACF,IAAA,gBAAS,GAAE,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,SAAgB,mBAAmB,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAmD;IAClH,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,gBAAgB,CAAC,CAAC,CAAC;AACxE,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 { bufferCount, concatAll, concatMap, delay, map, of } from \"rxjs\";\nimport { reduceWhile } from \"../Rxjs.js\";\nimport { createVisibilityStatus } from \"../Tooltip.js\";\n\nimport type { Observable, OperatorFunction } from \"rxjs\";\nimport type { Visibility } from \"../Tooltip.js\";\nimport type { VisibilityStatus } from \"../UseHierarchyVisibility.js\";\n\n/** @internal */\nexport function setDifference<T>(lhs: Readonly<Iterable<T>>, rhs: ReadonlySet<T>): Set<T> {\n const result = new Set<T>();\n for (const x of lhs) {\n if (!rhs.has(x)) {\n result.add(x);\n }\n }\n return result;\n}\n\n/** @internal */\nexport function setIntersection<T>(lhs: Readonly<Iterable<T>>, rhs: ReadonlySet<T>): Set<T> {\n const result = new Set<T>();\n for (const x of lhs) {\n if (rhs.has(x)) {\n result.add(x);\n }\n }\n return result;\n}\n\n/** @internal */\nexport function mergeVisibilities(obs: Observable<Visibility>): Observable<Visibility | \"empty\"> {\n return obs.pipe(\n reduceWhile(\n (x) => x.allVisible || x.allHidden,\n (acc, val) => {\n acc.allVisible &&= val === \"visible\";\n acc.allHidden &&= val === \"hidden\";\n return acc;\n },\n { allVisible: true, allHidden: true },\n ),\n map((x) => {\n if (!x) {\n return \"empty\";\n }\n return x.allVisible ? \"visible\" : x.allHidden ? \"hidden\" : \"partial\";\n }),\n );\n}\n\n/** @internal */\nexport function mergeVisibilityStatuses(\n tooltipMap?: { [key in Visibility]: string | undefined },\n ignoreTooltip?: boolean,\n): OperatorFunction<VisibilityStatus, VisibilityStatus> {\n return (obs) => {\n return obs.pipe(\n map((visibilityStatus) => visibilityStatus.state),\n mergeVisibilities,\n map((visibility) => {\n if (visibility === \"empty\") {\n visibility = \"visible\";\n }\n return createVisibilityStatus(visibility, getTooltipOptions(tooltipMap?.[visibility], ignoreTooltip));\n }),\n );\n };\n}\n\n/** @internal */\nexport function getTooltipOptions(key: string | undefined, ignoreTooltip?: boolean) {\n return {\n useTooltip: ignoreTooltip ? (false as const) : key,\n };\n}\n\n/** @internal */\nexport function releaseMainThreadOnItemsCount<T>(elementCount: number) {\n return (obs: Observable<T>): Observable<T> => {\n return obs.pipe(\n bufferCount(elementCount),\n concatMap((buff, i) => {\n const out = of(buff);\n if (i === 0 && buff.length < elementCount) {\n return out;\n }\n return out.pipe(delay(0));\n }),\n concatAll(),\n );\n };\n}\n\n/** @internal */\nexport function getOptimalBatchSize({ totalSize, maximumBatchSize }: { totalSize: number; maximumBatchSize: number }): number {\n return Math.ceil(totalSize / Math.ceil(totalSize / maximumBatchSize));\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UseModelsTreeProps } from "./UseModelsTree.js";
|
|
2
1
|
import type { VisibilityTreeProps } from "../common/components/VisibilityTree.js";
|
|
2
|
+
import type { UseModelsTreeProps } from "./UseModelsTree.js";
|
|
3
3
|
/** @beta */
|
|
4
4
|
export type ModelsTreeProps = Pick<VisibilityTreeProps, "imodel" | "getSchemaContext" | "selectionStorage" | "density" | "selectionMode"> & UseModelsTreeProps & {
|
|
5
5
|
hierarchyLevelConfig?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";;AAqBA,gCAuCC;;AA5DD;;;gGAGgG;AAEhG,8EAAwE;AACxE,8FAAwF;AACxF,yDAAmD;AAanD,YAAY;AACZ,SAAgB,UAAU,CAAC,EACzB,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,OAAO,EACP,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GACC;IAChB,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,IAAA,gCAAa,EAAC;QACvD,UAAU;QACV,MAAM;QACN,eAAe;QACf,0BAA0B;QAC1B,gBAAgB;QAChB,gBAAgB;QAChB,kBAAkB;QAClB,eAAe;KAChB,CAAC,CAAC;IAEH,OAAO,CACL,uBAAC,kCAAc,OACT,eAAe,EACnB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,oBAAoB,EAAE,SAAS,EACxD,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,uBAAC,kDAAsB,OAAK,SAAS,KAAM,aAAa,GAAI,GACzF,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { VisibilityTree } from \"../common/components/VisibilityTree.js\";\nimport { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer.js\";\nimport { useModelsTree } from \"./UseModelsTree.js\";\n\nimport type {
|
|
1
|
+
{"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";;AAqBA,gCAuCC;;AA5DD;;;gGAGgG;AAEhG,8EAAwE;AACxE,8FAAwF;AACxF,yDAAmD;AAanD,YAAY;AACZ,SAAgB,UAAU,CAAC,EACzB,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,OAAO,EACP,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GACC;IAChB,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,IAAA,gCAAa,EAAC;QACvD,UAAU;QACV,MAAM;QACN,eAAe;QACf,0BAA0B;QAC1B,gBAAgB;QAChB,gBAAgB;QAChB,kBAAkB;QAClB,eAAe;KAChB,CAAC,CAAC;IAEH,OAAO,CACL,uBAAC,kCAAc,OACT,eAAe,EACnB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,oBAAoB,EAAE,SAAS,EACxD,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,uBAAC,kDAAsB,OAAK,SAAS,KAAM,aAAa,GAAI,GACzF,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { VisibilityTree } from \"../common/components/VisibilityTree.js\";\nimport { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer.js\";\nimport { useModelsTree } from \"./UseModelsTree.js\";\n\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\nimport type { UseModelsTreeProps } from \"./UseModelsTree.js\";\n\n/** @beta */\nexport type ModelsTreeProps = Pick<VisibilityTreeProps, \"imodel\" | \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"selectionMode\"> &\n UseModelsTreeProps & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n };\n\n/** @beta */\nexport function ModelsTree({\n imodel,\n getSchemaContext,\n selectionStorage,\n activeView,\n filter,\n density,\n hierarchyLevelConfig,\n hierarchyConfig,\n selectionMode,\n selectionPredicate,\n visibilityHandlerOverrides,\n getFilteredPaths,\n onModelsFiltered,\n getSubTreePaths,\n}: ModelsTreeProps) {\n const { modelsTreeProps, rendererProps } = useModelsTree({\n activeView,\n filter,\n hierarchyConfig,\n visibilityHandlerOverrides,\n getFilteredPaths,\n onModelsFiltered,\n selectionPredicate,\n getSubTreePaths,\n });\n\n return (\n <VisibilityTree\n {...modelsTreeProps}\n imodel={imodel}\n selectionStorage={selectionStorage}\n getSchemaContext={getSchemaContext}\n hierarchyLevelSizeLimit={hierarchyLevelConfig?.sizeLimit}\n density={density}\n selectionMode={selectionMode}\n treeRenderer={(treeProps) => <VisibilityTreeRenderer {...treeProps} {...rendererProps} />}\n />\n );\n}\n"]}
|