@itwin/tree-widget-react 3.17.6 → 3.17.8
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 +18 -2
- package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.d.ts +1 -0
- package/lib/cjs/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.js +7 -2
- 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/TreeNodeCheckbox.scss +14 -0
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +2 -2
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.d.ts +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.js +4 -2
- 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/TreeNodeCheckbox.scss +14 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/package.json +19 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
# Change Log - @itwin/tree-widget-react
|
|
2
2
|
|
|
3
|
-
<!-- This log was last generated on
|
|
3
|
+
<!-- This log was last generated on Fri, 06 Mar 2026 19:28:08 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 3.17.8
|
|
8
|
+
|
|
9
|
+
Fri, 06 Mar 2026 19:28:08 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Hide visibility checkbox tooltip and hover effect on touch devices. ([#1615](https://github.com/iTwin/viewer-components-react/pull/1615))
|
|
14
|
+
|
|
15
|
+
## 3.17.7
|
|
16
|
+
|
|
17
|
+
Tue, 24 Feb 2026 07:54:06 GMT
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- Consume the latest iTwin.js Core patch that improves performance of category display changes. Requires iTwin.js Core packages @ `5.7.0`. ([#1605](https://github.com/iTwin/viewer-components-react/pull/1605))
|
|
22
|
+
|
|
7
23
|
## 3.17.6
|
|
8
24
|
|
|
9
|
-
Mon, 09 Feb 2026 12:
|
|
25
|
+
Mon, 09 Feb 2026 12:17:01 GMT
|
|
10
26
|
|
|
11
27
|
### Patches
|
|
12
28
|
|
|
@@ -37,7 +37,7 @@ async function enableCategoryDisplay(viewport, categoryIds, enabled, enableAllSu
|
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
39
|
return (0, Rxjs_js_1.toVoidPromise)((0, rxjs_1.from)(categoryIds).pipe((0, Utils_js_1.releaseMainThreadOnItemsCount)(500), (0, rxjs_1.bufferCount)((0, Utils_js_1.getOptimalBatchSize)({ totalSize: categoryIds.length, maximumBatchSize: 500 })), (0, rxjs_1.mergeMap)(async (bufferedCategories) => {
|
|
40
|
-
viewport.changeCategoryDisplay(bufferedCategories, enabled, enableAllSubCategories);
|
|
40
|
+
viewport.changeCategoryDisplay(bufferedCategories, enabled, enableAllSubCategories, true);
|
|
41
41
|
removeOverrides(bufferedCategories);
|
|
42
42
|
if (!enabled) {
|
|
43
43
|
await disableSubCategories(bufferedCategories);
|
|
@@ -1 +1 @@
|
|
|
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,QAAQ,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,C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,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
|
+
{"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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mB,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, true);\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,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.TreeNodeCheckbox = TreeNodeCheckbox;
|
|
4
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
@@ -6,6 +9,8 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
6
9
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
7
10
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
8
11
|
*--------------------------------------------------------------------------------------------*/
|
|
12
|
+
require("./TreeNodeCheckbox.scss");
|
|
13
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
9
14
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
10
15
|
const presentation_hierarchies_react_1 = require("@itwin/presentation-hierarchies-react");
|
|
11
16
|
/** @internal */
|
|
@@ -35,9 +40,9 @@ function TreeNodeCheckbox({ node, onCheckboxClicked, getCheckboxState, ...props
|
|
|
35
40
|
checkboxProps.indeterminate = checkboxState.state === "partial";
|
|
36
41
|
checkboxProps.disabled = checkboxState.isDisabled;
|
|
37
42
|
}
|
|
38
|
-
return ((0, jsx_runtime_1.jsx)(TooltipWrapper, { content: checkboxState.tooltip, children: (0, jsx_runtime_1.jsx)(itwinui_react_1.Checkbox, { ...checkboxProps }) }));
|
|
43
|
+
return ((0, jsx_runtime_1.jsx)(TooltipWrapper, { content: checkboxState.tooltip, children: (0, jsx_runtime_1.jsx)(itwinui_react_1.Checkbox, { ...checkboxProps, className: (0, classnames_1.default)("tw-tree-node-checkbox", checkboxProps.className) }) }));
|
|
39
44
|
}
|
|
40
45
|
function TooltipWrapper({ content, children }) {
|
|
41
|
-
return !!content ? ((0, jsx_runtime_1.jsx)(itwinui_react_1.Tooltip, { content: content, placement: "left", children: children })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }));
|
|
46
|
+
return !!content ? ((0, jsx_runtime_1.jsx)(itwinui_react_1.Tooltip, { content: content, placement: "left", className: "tw-tree-node-checkbox-tooltip", children: children })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }));
|
|
42
47
|
}
|
|
43
48
|
//# sourceMappingURL=TreeNodeCheckbox.js.map
|
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":"
|
|
1
|
+
{"version":3,"file":"TreeNodeCheckbox.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.tsx"],"names":[],"mappings":";;;;;AA2CA,4CA+BC;;AA1ED;;;gGAGgG;AAEhG,mCAAiC;AAEjC,4DAA4B;AAC5B,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,EAAE,SAAS,EAAE,IAAA,oBAAE,EAAC,uBAAuB,EAAE,aAAa,CAAC,SAAS,CAAC,GAAI,GACjF,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,EAAC,SAAS,EAAC,+BAA+B,YAClF,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 \"./TreeNodeCheckbox.scss\";\n\nimport cx from \"classnames\";\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} className={cx(\"tw-tree-node-checkbox\", checkboxProps.className)} />\n </TooltipWrapper>\n );\n}\n\nfunction TooltipWrapper({ content, children }: { content?: string; children?: React.ReactNode }) {\n return !!content ? (\n <Tooltip content={content} placement=\"left\" className=\"tw-tree-node-checkbox-tooltip\">\n {children}\n </Tooltip>\n ) : (\n <>{children}</>\n );\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
|
|
6
|
+
@media (hover: none) {
|
|
7
|
+
.tw-tree-node-checkbox:hover {
|
|
8
|
+
background-color: transparent;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.tw-tree-node-checkbox-tooltip {
|
|
12
|
+
display: none;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -478,7 +478,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
478
478
|
}
|
|
479
479
|
removeAlwaysDrawnExclusive() {
|
|
480
480
|
return this.#idsCache.getAllCategories().pipe((0, rxjs_1.map)((categoryIds) => {
|
|
481
|
-
this.#props.viewport.changeCategoryDisplay(categoryIds, false, false);
|
|
481
|
+
this.#props.viewport.changeCategoryDisplay(categoryIds, false, false, true);
|
|
482
482
|
this.#props.viewport.clearNeverDrawn();
|
|
483
483
|
this.#props.viewport.perModelCategoryVisibility.clearOverrides();
|
|
484
484
|
this.#props.viewport.setAlwaysDrawn(this.#props.viewport.alwaysDrawn ?? new Set());
|
|
@@ -542,7 +542,7 @@ class ModelsTreeVisibilityHandlerImpl {
|
|
|
542
542
|
if (override === core_frontend_1.PerModelCategoryVisibility.Override.None && on) {
|
|
543
543
|
// we took off the override which means the category is displayed in selector, but
|
|
544
544
|
// doesn't mean all its subcategories are displayed - this call ensures that
|
|
545
|
-
viewport.changeCategoryDisplay(categoryId, true, true);
|
|
545
|
+
viewport.changeCategoryDisplay(categoryId, true, true, true);
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
548
|
changeCategoryState(props) {
|