@itwin/tree-widget-react 0.10.0 → 1.0.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/CHANGELOG.md +331 -0
  2. package/README.md +146 -29
  3. package/lib/cjs/TreeWidget.d.ts +0 -1
  4. package/lib/cjs/TreeWidget.js +1 -6
  5. package/lib/cjs/TreeWidget.js.map +1 -1
  6. package/lib/cjs/components/TreeFilteringState.d.ts +3 -1
  7. package/lib/cjs/components/TreeFilteringState.js +19 -40
  8. package/lib/cjs/components/TreeFilteringState.js.map +1 -1
  9. package/lib/cjs/components/TreeWidgetComponent.d.ts +29 -5
  10. package/lib/cjs/components/TreeWidgetComponent.js +85 -29
  11. package/lib/cjs/components/TreeWidgetComponent.js.map +1 -1
  12. package/lib/cjs/components/TreeWidgetComponent.scss +4 -24
  13. package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +25 -2
  14. package/lib/cjs/components/TreeWidgetUiItemsProvider.js +31 -46
  15. package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
  16. package/lib/cjs/components/tree-header/TreeHeader.d.ts +26 -0
  17. package/lib/cjs/components/tree-header/TreeHeader.js +43 -0
  18. package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -0
  19. package/lib/cjs/components/tree-header/TreeHeader.scss +69 -0
  20. package/lib/cjs/components/trees/CategoriesVisibilityUtils.d.ts +12 -6
  21. package/lib/cjs/components/trees/CategoriesVisibilityUtils.js +10 -4
  22. package/lib/cjs/components/trees/CategoriesVisibilityUtils.js.map +1 -1
  23. package/lib/cjs/components/trees/Common.d.ts +2 -2
  24. package/lib/cjs/components/trees/Common.js +1 -1
  25. package/lib/cjs/components/trees/Common.js.map +1 -1
  26. package/lib/cjs/components/trees/VisibilityTreeBase.scss +66 -10
  27. package/lib/cjs/components/trees/VisibilityTreeEventHandler.d.ts +13 -12
  28. package/lib/cjs/components/trees/VisibilityTreeEventHandler.js +6 -17
  29. package/lib/cjs/components/trees/VisibilityTreeEventHandler.js.map +1 -1
  30. package/lib/cjs/components/trees/VisibilityTreeRenderer.d.ts +38 -14
  31. package/lib/cjs/components/trees/VisibilityTreeRenderer.js +35 -41
  32. package/lib/cjs/components/trees/VisibilityTreeRenderer.js.map +1 -1
  33. package/lib/cjs/components/trees/category-tree/CategoriesTree.d.ts +12 -11
  34. package/lib/cjs/components/trees/category-tree/CategoriesTree.js +17 -41
  35. package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +1 -1
  36. package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.d.ts +67 -6
  37. package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js +61 -72
  38. package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
  39. package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.d.ts +30 -8
  40. package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js +61 -34
  41. package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js.map +1 -1
  42. package/lib/cjs/components/trees/external-sources-tree/ExternalSources.json +230 -0
  43. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +27 -0
  44. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +61 -0
  45. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -0
  46. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +20 -0
  47. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +39 -0
  48. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -0
  49. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +30 -0
  50. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +39 -0
  51. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -0
  52. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +26 -0
  53. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js +35 -0
  54. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -0
  55. package/lib/cjs/components/trees/index.d.ts +5 -1
  56. package/lib/cjs/components/trees/index.js +10 -2
  57. package/lib/cjs/components/trees/index.js.map +1 -1
  58. package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +26 -18
  59. package/lib/cjs/components/trees/models-tree/ModelsTree.js +22 -50
  60. package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
  61. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.d.ts +70 -2
  62. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +68 -105
  63. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  64. package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.d.ts +40 -12
  65. package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js +65 -5
  66. package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
  67. package/lib/cjs/components/trees/models-tree/Utils.d.ts +12 -0
  68. package/lib/cjs/components/trees/models-tree/Utils.js +625 -1
  69. package/lib/cjs/components/trees/models-tree/Utils.js.map +1 -1
  70. package/lib/cjs/components/utils/AutoSizer.d.ts +6 -3
  71. package/lib/cjs/components/utils/AutoSizer.js +9 -29
  72. package/lib/cjs/components/utils/AutoSizer.js.map +1 -1
  73. package/lib/cjs/components/utils/IsPromiseLike.d.ts +4 -1
  74. package/lib/cjs/components/utils/IsPromiseLike.js +6 -3
  75. package/lib/cjs/components/utils/IsPromiseLike.js.map +1 -1
  76. package/lib/cjs/tree-widget-react.d.ts +0 -1
  77. package/lib/cjs/tree-widget-react.js +5 -2
  78. package/lib/cjs/tree-widget-react.js.map +1 -1
  79. package/lib/esm/TreeWidget.d.ts +0 -1
  80. package/lib/esm/TreeWidget.js +2 -7
  81. package/lib/esm/TreeWidget.js.map +1 -1
  82. package/lib/esm/components/TreeFilteringState.d.ts +3 -1
  83. package/lib/esm/components/TreeFilteringState.js +17 -19
  84. package/lib/esm/components/TreeFilteringState.js.map +1 -1
  85. package/lib/esm/components/TreeWidgetComponent.d.ts +29 -5
  86. package/lib/esm/components/TreeWidgetComponent.js +82 -7
  87. package/lib/esm/components/TreeWidgetComponent.js.map +1 -1
  88. package/lib/esm/components/TreeWidgetComponent.scss +4 -24
  89. package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +25 -2
  90. package/lib/esm/components/TreeWidgetUiItemsProvider.js +29 -41
  91. package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
  92. package/lib/esm/components/tree-header/TreeHeader.d.ts +26 -0
  93. package/lib/esm/components/tree-header/TreeHeader.js +36 -0
  94. package/lib/esm/components/tree-header/TreeHeader.js.map +1 -0
  95. package/lib/esm/components/tree-header/TreeHeader.scss +69 -0
  96. package/lib/esm/components/trees/CategoriesVisibilityUtils.d.ts +12 -6
  97. package/lib/esm/components/trees/CategoriesVisibilityUtils.js +10 -4
  98. package/lib/esm/components/trees/CategoriesVisibilityUtils.js.map +1 -1
  99. package/lib/esm/components/trees/Common.d.ts +2 -2
  100. package/lib/esm/components/trees/Common.js +1 -1
  101. package/lib/esm/components/trees/Common.js.map +1 -1
  102. package/lib/esm/components/trees/VisibilityTreeBase.scss +66 -10
  103. package/lib/esm/components/trees/VisibilityTreeEventHandler.d.ts +13 -12
  104. package/lib/esm/components/trees/VisibilityTreeEventHandler.js +6 -17
  105. package/lib/esm/components/trees/VisibilityTreeEventHandler.js.map +1 -1
  106. package/lib/esm/components/trees/VisibilityTreeRenderer.d.ts +38 -14
  107. package/lib/esm/components/trees/VisibilityTreeRenderer.js +29 -19
  108. package/lib/esm/components/trees/VisibilityTreeRenderer.js.map +1 -1
  109. package/lib/esm/components/trees/category-tree/CategoriesTree.d.ts +12 -11
  110. package/lib/esm/components/trees/category-tree/CategoriesTree.js +16 -21
  111. package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +1 -1
  112. package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.d.ts +67 -6
  113. package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js +60 -52
  114. package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
  115. package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.d.ts +30 -8
  116. package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js +57 -14
  117. package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js.map +1 -1
  118. package/lib/esm/components/trees/external-sources-tree/ExternalSources.json +230 -0
  119. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +27 -0
  120. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +34 -0
  121. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -0
  122. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +20 -0
  123. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +35 -0
  124. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -0
  125. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +30 -0
  126. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +32 -0
  127. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -0
  128. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +26 -0
  129. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js +31 -0
  130. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -0
  131. package/lib/esm/components/trees/index.d.ts +5 -1
  132. package/lib/esm/components/trees/index.js +5 -1
  133. package/lib/esm/components/trees/index.js.map +1 -1
  134. package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +26 -18
  135. package/lib/esm/components/trees/models-tree/ModelsTree.js +23 -32
  136. package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
  137. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.d.ts +70 -2
  138. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +66 -84
  139. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  140. package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.d.ts +40 -12
  141. package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js +60 -5
  142. package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
  143. package/lib/esm/components/trees/models-tree/Utils.d.ts +12 -0
  144. package/lib/esm/components/trees/models-tree/Utils.js +622 -0
  145. package/lib/esm/components/trees/models-tree/Utils.js.map +1 -1
  146. package/lib/esm/components/utils/AutoSizer.d.ts +6 -3
  147. package/lib/esm/components/utils/AutoSizer.js +9 -10
  148. package/lib/esm/components/utils/AutoSizer.js.map +1 -1
  149. package/lib/esm/components/utils/IsPromiseLike.d.ts +4 -1
  150. package/lib/esm/components/utils/IsPromiseLike.js +4 -1
  151. package/lib/esm/components/utils/IsPromiseLike.js.map +1 -1
  152. package/lib/esm/tree-widget-react.d.ts +0 -1
  153. package/lib/esm/tree-widget-react.js +0 -1
  154. package/lib/esm/tree-widget-react.js.map +1 -1
  155. package/lib/public/locales/en/TreeWidget.json +13 -4
  156. package/package.json +44 -48
  157. package/lib/cjs/components/rulesets/ClassificationSystems.json +0 -122
  158. package/lib/cjs/components/search-bar/SearchBar.d.ts +0 -48
  159. package/lib/cjs/components/search-bar/SearchBar.js +0 -86
  160. package/lib/cjs/components/search-bar/SearchBar.js.map +0 -1
  161. package/lib/cjs/components/search-bar/SearchBar.scss +0 -118
  162. package/lib/cjs/components/search-bar/SearchBox.d.ts +0 -70
  163. package/lib/cjs/components/search-bar/SearchBox.js +0 -186
  164. package/lib/cjs/components/search-bar/SearchBox.js.map +0 -1
  165. package/lib/cjs/components/search-bar/SearchBox.scss +0 -70
  166. package/lib/cjs/components/trees/IModelContentTree.d.ts +0 -4
  167. package/lib/cjs/components/trees/IModelContentTree.js +0 -50
  168. package/lib/cjs/components/trees/IModelContentTree.js.map +0 -1
  169. package/lib/cjs/components/trees/models-tree/Hierarchy.GroupedByClass.json +0 -391
  170. package/lib/cjs/components/trees/models-tree/Hierarchy.json +0 -386
  171. package/lib/cjs/components/trees/models-tree/ModelsTreeSearch.json +0 -239
  172. package/lib/cjs/types.d.ts +0 -44
  173. package/lib/cjs/types.js +0 -11
  174. package/lib/cjs/types.js.map +0 -1
  175. package/lib/esm/components/rulesets/ClassificationSystems.json +0 -122
  176. package/lib/esm/components/search-bar/SearchBar.d.ts +0 -48
  177. package/lib/esm/components/search-bar/SearchBar.js +0 -60
  178. package/lib/esm/components/search-bar/SearchBar.js.map +0 -1
  179. package/lib/esm/components/search-bar/SearchBar.scss +0 -118
  180. package/lib/esm/components/search-bar/SearchBox.d.ts +0 -70
  181. package/lib/esm/components/search-bar/SearchBox.js +0 -160
  182. package/lib/esm/components/search-bar/SearchBox.js.map +0 -1
  183. package/lib/esm/components/search-bar/SearchBox.scss +0 -70
  184. package/lib/esm/components/trees/IModelContentTree.d.ts +0 -4
  185. package/lib/esm/components/trees/IModelContentTree.js +0 -24
  186. package/lib/esm/components/trees/IModelContentTree.js.map +0 -1
  187. package/lib/esm/components/trees/models-tree/Hierarchy.GroupedByClass.json +0 -391
  188. package/lib/esm/components/trees/models-tree/Hierarchy.json +0 -386
  189. package/lib/esm/components/trees/models-tree/ModelsTreeSearch.json +0 -239
  190. package/lib/esm/types.d.ts +0 -44
  191. package/lib/esm/types.js +0 -8
  192. package/lib/esm/types.js.map +0 -1
  193. /package/lib/cjs/components/{rulesets → trees/imodel-content-tree}/IModelContent.json +0 -0
  194. /package/lib/esm/components/{rulesets → trees/imodel-content-tree}/IModelContent.json +0 -0
@@ -1,8 +1,8 @@
1
- import { TreeNodeItem } from "@itwin/components-react";
2
1
  import { BeEvent } from "@itwin/core-bentley";
3
- import { IModelConnection, ViewManager, Viewport } from "@itwin/core-frontend";
4
2
  import { NodeKey } from "@itwin/presentation-common";
5
- import { IVisibilityHandler, VisibilityChangeListener, VisibilityStatus } from "../VisibilityTreeEventHandler";
3
+ import type { TreeNodeItem } from "@itwin/components-react";
4
+ import type { IModelConnection, ViewManager, Viewport } from "@itwin/core-frontend";
5
+ import type { IVisibilityHandler, VisibilityChangeListener, VisibilityStatus } from "../VisibilityTreeEventHandler";
6
6
  /**
7
7
  * Loads categories from viewport or uses provided list of categories.
8
8
  * @internal
@@ -10,26 +10,33 @@ import { IVisibilityHandler, VisibilityChangeListener, VisibilityStatus } from "
10
10
  export declare function useCategories(viewManager: ViewManager, imodel: IModelConnection, view?: Viewport): CategoryInfo[];
11
11
  /**
12
12
  * Data structure that describes category.
13
- * @alpha
13
+ * @public
14
14
  */
15
15
  export interface CategoryInfo {
16
16
  categoryId: string;
17
17
  subCategoryIds?: string[];
18
18
  }
19
- /** @alpha */
19
+ /**
20
+ * Params for creating a [[CategoryVisibilityHandler]].
21
+ * @public
22
+ */
20
23
  export interface CategoryVisibilityHandlerParams {
21
24
  viewManager: ViewManager;
22
25
  imodel: IModelConnection;
23
26
  categories: CategoryInfo[];
24
- activeView?: Viewport;
27
+ activeView: Viewport;
25
28
  allViewports?: boolean;
26
29
  }
27
- /** @alpha */
30
+ /**
31
+ * An [[IVisibilityHandler]] implementation that knows how to determine and change visibility of categories
32
+ * and subcategories.
33
+ * @public
34
+ */
28
35
  export declare class CategoryVisibilityHandler implements IVisibilityHandler {
29
36
  private _viewManager;
30
37
  private _imodel;
31
38
  private _pendingVisibilityChange;
32
- private _activeView?;
39
+ private _activeView;
33
40
  private _useAllViewports;
34
41
  private _categories;
35
42
  constructor(params: CategoryVisibilityHandlerParams);
@@ -47,4 +54,19 @@ export declare class CategoryVisibilityHandler implements IVisibilityHandler {
47
54
  enableCategory(ids: string[], enabled: boolean, enableAllSubCategories?: boolean): Promise<void>;
48
55
  enableSubCategory(key: string, enabled: boolean): void;
49
56
  }
57
+ /**
58
+ * Enable display of all given categories.
59
+ * @public
60
+ */
61
+ export declare function showAllCategories(categories: string[], viewport: Viewport): Promise<void>;
62
+ /**
63
+ * Disable display of all given categories.
64
+ * @public
65
+ */
66
+ export declare function hideAllCategories(categories: string[], viewport: Viewport): Promise<void>;
67
+ /**
68
+ * Invert display of all given categories.
69
+ * @public
70
+ */
71
+ export declare function invertAllCategories(categories: CategoryInfo[], viewport: Viewport): Promise<void>;
50
72
  //# sourceMappingURL=CategoryVisibilityHandler.d.ts.map
@@ -3,30 +3,12 @@
3
3
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
4
  * See LICENSE.md in the project root for license terms and full copyright notice.
5
5
  *--------------------------------------------------------------------------------------------*/
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
6
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.CategoryVisibilityHandler = exports.useCategories = void 0;
27
- const React = __importStar(require("react"));
7
+ exports.invertAllCategories = exports.hideAllCategories = exports.showAllCategories = exports.CategoryVisibilityHandler = exports.useCategories = void 0;
8
+ const react_1 = require("react");
28
9
  const components_react_1 = require("@itwin/components-react");
29
10
  const core_bentley_1 = require("@itwin/core-bentley");
11
+ const core_frontend_1 = require("@itwin/core-frontend");
30
12
  const presentation_common_1 = require("@itwin/presentation-common");
31
13
  const presentation_components_1 = require("@itwin/presentation-components");
32
14
  const CategoriesVisibilityUtils_1 = require("../CategoriesVisibilityUtils");
@@ -37,11 +19,15 @@ const EMPTY_CATEGORIES_ARRAY = [];
37
19
  */
38
20
  function useCategories(viewManager, imodel, view) {
39
21
  const currentView = view || viewManager.getFirstOpenView();
40
- const categoriesPromise = React.useMemo(async () => (0, CategoriesVisibilityUtils_1.loadCategoriesFromViewport)(imodel, currentView), [imodel, currentView]);
22
+ const categoriesPromise = (0, react_1.useMemo)(async () => (0, CategoriesVisibilityUtils_1.loadCategoriesFromViewport)(imodel, currentView), [imodel, currentView]);
41
23
  return (0, components_react_1.useAsyncValue)(categoriesPromise) ?? EMPTY_CATEGORIES_ARRAY;
42
24
  }
43
25
  exports.useCategories = useCategories;
44
- /** @alpha */
26
+ /**
27
+ * An [[IVisibilityHandler]] implementation that knows how to determine and change visibility of categories
28
+ * and subcategories.
29
+ * @public
30
+ */
45
31
  class CategoryVisibilityHandler {
46
32
  constructor(params) {
47
33
  this.onVisibilityChange = new core_bentley_1.BeEvent();
@@ -59,16 +45,12 @@ class CategoryVisibilityHandler {
59
45
  // istanbul ignore next
60
46
  this._useAllViewports = params.allViewports ?? false;
61
47
  this._categories = params.categories;
62
- if (this._activeView) {
63
- this._activeView.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);
64
- this._activeView.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);
65
- }
48
+ this._activeView.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);
49
+ this._activeView.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);
66
50
  }
67
51
  dispose() {
68
- if (this._activeView) {
69
- this._activeView.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);
70
- this._activeView.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);
71
- }
52
+ this._activeView.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);
53
+ this._activeView.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);
72
54
  clearTimeout(this._pendingVisibilityChange);
73
55
  }
74
56
  getVisibilityStatus(node) {
@@ -98,14 +80,12 @@ class CategoryVisibilityHandler {
98
80
  }
99
81
  getSubCategoryVisibility(id) {
100
82
  const parentItem = this.getParent(id);
101
- if (!parentItem || !this._activeView)
83
+ if (!parentItem)
102
84
  return "hidden";
103
85
  const isVisible = this._activeView.view.viewsCategory(parentItem.categoryId) && this._activeView.isSubCategoryVisible(id);
104
86
  return isVisible ? "visible" : "hidden";
105
87
  }
106
88
  getCategoryVisibility(id) {
107
- if (!this._activeView)
108
- return "hidden";
109
89
  return this._activeView.view.viewsCategory(id) ? "visible" : "hidden";
110
90
  }
111
91
  getParent(key) {
@@ -137,4 +117,51 @@ class CategoryVisibilityHandler {
137
117
  }
138
118
  }
139
119
  exports.CategoryVisibilityHandler = CategoryVisibilityHandler;
120
+ /**
121
+ * Enable display of all given categories.
122
+ * @public
123
+ */
124
+ async function showAllCategories(categories, viewport) {
125
+ await (0, CategoriesVisibilityUtils_1.enableCategory)(core_frontend_1.IModelApp.viewManager, viewport.iModel, categories, true, true);
126
+ }
127
+ exports.showAllCategories = showAllCategories;
128
+ /**
129
+ * Disable display of all given categories.
130
+ * @public
131
+ */
132
+ async function hideAllCategories(categories, viewport) {
133
+ await (0, CategoriesVisibilityUtils_1.enableCategory)(core_frontend_1.IModelApp.viewManager, viewport.iModel, categories, false, true);
134
+ }
135
+ exports.hideAllCategories = hideAllCategories;
136
+ /**
137
+ * Invert display of all given categories.
138
+ * @public
139
+ */
140
+ async function invertAllCategories(categories, viewport) {
141
+ const enabled = [];
142
+ const disabled = [];
143
+ const enabledSubCategories = [];
144
+ const disabledSubCategories = [];
145
+ for (const category of categories) {
146
+ if (!viewport.view.viewsCategory(category.categoryId)) {
147
+ disabled.push(category.categoryId);
148
+ continue;
149
+ }
150
+ // First, we need to check if at least one subcategory is disabled. If it is true, then only subcategories should change display, not categories.
151
+ if (category.subCategoryIds?.some((subCategory) => !viewport.isSubCategoryVisible(subCategory))) {
152
+ for (const subCategory of category.subCategoryIds)
153
+ viewport.isSubCategoryVisible(subCategory) ? enabledSubCategories.push(subCategory) : disabledSubCategories.push(subCategory);
154
+ }
155
+ else {
156
+ enabled.push(category.categoryId);
157
+ }
158
+ }
159
+ // Disable enabled
160
+ enabledSubCategories.forEach((subCategory) => (0, CategoriesVisibilityUtils_1.enableSubCategory)(core_frontend_1.IModelApp.viewManager, subCategory, false, true));
161
+ await (0, CategoriesVisibilityUtils_1.enableCategory)(core_frontend_1.IModelApp.viewManager, viewport.iModel, enabled, false, true);
162
+ // Enable disabled
163
+ disabledSubCategories.forEach((subCategory) => (0, CategoriesVisibilityUtils_1.enableSubCategory)(core_frontend_1.IModelApp.viewManager, subCategory, true, true));
164
+ await (0, CategoriesVisibilityUtils_1.enableCategory)(core_frontend_1.IModelApp.viewManager, viewport.iModel, disabled, true, true);
165
+ }
166
+ exports.invertAllCategories = invertAllCategories;
140
167
  //# sourceMappingURL=CategoryVisibilityHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CategoryVisibilityHandler.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoryVisibilityHandler.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;;;;;;;AAE/F,6CAA+B;AAC/B,8DAAsE;AACtE,sDAA8C;AAE9C,oEAAqD;AACrD,4EAA4E;AAC5E,4EAA6G;AAG7G,MAAM,sBAAsB,GAAmB,EAAE,CAAC;AAElD;;;GAGG;AACH,SAAgB,aAAa,CAAC,WAAwB,EAAE,MAAwB,EAAE,IAAe;IAC/F,MAAM,WAAW,GAAG,IAAI,IAAI,WAAW,CAAC,gBAAgB,EAAE,CAAC;IAC3D,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,IAAA,sDAA0B,EAAC,MAAM,EAAE,WAAW,CAAC,EAAE,CAAC,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;YACrC,IAAI,CAAC,wBAAwB,GAAG,SAAS,CAAC;QAC5C,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAEM,MAAM,CAAC,4BAA4B,CAAC,OAAgB;QACzD,OAAO,CAAC,6BAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,0BAA0B,CAAC,EAAE,CAAC;IAC/I,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,GAAa,EAAE,OAAgB,EAAE,sBAAsB,GAAG,IAAI;QACxF,MAAM,IAAA,0CAAc,EAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,sBAAsB,CAAC,CAAC;IACrH,CAAC;IAEM,iBAAiB,CAAC,GAAW,EAAE,OAAgB;QACpD,IAAA,6CAAiB,EAAC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC5E,CAAC;CACF;AAzHD,8DAyHC","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 * as React from \"react\";\nimport { TreeNodeItem, useAsyncValue } from \"@itwin/components-react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { IModelConnection, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport { NodeKey } from \"@itwin/presentation-common\";\nimport { isPresentationTreeNodeItem } from \"@itwin/presentation-components\";\nimport { enableCategory, enableSubCategory, loadCategoriesFromViewport } from \"../CategoriesVisibilityUtils\";\nimport { IVisibilityHandler, VisibilityChangeListener, VisibilityStatus } from \"../VisibilityTreeEventHandler\";\n\nconst EMPTY_CATEGORIES_ARRAY: CategoryInfo[] = [];\n\n/**\n * Loads categories from viewport or uses provided list of categories.\n * @internal\n */\nexport function useCategories(viewManager: ViewManager, imodel: IModelConnection, view?: Viewport) {\n const currentView = view || viewManager.getFirstOpenView();\n const categoriesPromise = React.useMemo(async () => loadCategoriesFromViewport(imodel, currentView), [imodel, currentView]);\n return useAsyncValue(categoriesPromise) ?? EMPTY_CATEGORIES_ARRAY;\n}\n\n/**\n * Data structure that describes category.\n * @alpha\n */\nexport interface CategoryInfo {\n categoryId: string;\n subCategoryIds?: string[];\n}\n\n/** @alpha */\nexport interface CategoryVisibilityHandlerParams {\n viewManager: ViewManager;\n imodel: IModelConnection;\n categories: CategoryInfo[];\n activeView?: Viewport;\n allViewports?: boolean;\n}\n\n/** @alpha */\nexport class CategoryVisibilityHandler implements IVisibilityHandler {\n private _viewManager: ViewManager;\n private _imodel: IModelConnection;\n private _pendingVisibilityChange: any | undefined;\n private _activeView?: Viewport;\n private _useAllViewports: boolean;\n private _categories: CategoryInfo[];\n\n constructor(params: CategoryVisibilityHandlerParams) {\n this._viewManager = params.viewManager;\n this._imodel = params.imodel;\n this._activeView = params.activeView;\n // istanbul ignore next\n this._useAllViewports = params.allViewports ?? false;\n this._categories = params.categories;\n if (this._activeView) {\n this._activeView.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);\n this._activeView.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);\n }\n }\n\n public dispose() {\n if (this._activeView) {\n this._activeView.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);\n this._activeView.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);\n }\n clearTimeout(this._pendingVisibilityChange);\n }\n\n public onVisibilityChange = new BeEvent<VisibilityChangeListener>();\n\n public getVisibilityStatus(node: TreeNodeItem,): VisibilityStatus {\n const nodeKey = isPresentationTreeNodeItem(node) ? node.key : undefined;\n if (!nodeKey)\n return { state: \"hidden\", isDisabled: true};\n\n const instanceId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n return { state: node.parentId ? this.getSubCategoryVisibility(instanceId) : this.getCategoryVisibility(instanceId) };\n }\n\n public async changeVisibility(node: TreeNodeItem, shouldDisplay: boolean): Promise<void> {\n const nodeKey = isPresentationTreeNodeItem(node) ? node.key : undefined;\n if (!nodeKey)\n return;\n\n // handle subcategory visibility change\n if (node.parentId) {\n const childId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n // istanbul ignore next\n const parentId = this.getParent(childId)?.categoryId;\n\n // make sure parent category is enabled\n if (shouldDisplay && parentId)\n await this.enableCategory([parentId], true, false);\n\n this.enableSubCategory(childId, shouldDisplay);\n return;\n }\n\n const instanceId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n await this.enableCategory([instanceId], shouldDisplay, true);\n }\n\n public getSubCategoryVisibility(id: string) {\n const parentItem = this.getParent(id);\n if (!parentItem || !this._activeView)\n return \"hidden\";\n\n const isVisible = this._activeView.view.viewsCategory(parentItem.categoryId) && this._activeView.isSubCategoryVisible(id);\n return isVisible ? \"visible\" : \"hidden\";\n }\n\n public getCategoryVisibility(id: string) {\n if (!this._activeView)\n return \"hidden\";\n return this._activeView.view.viewsCategory(id) ? \"visible\" : \"hidden\";\n }\n\n public getParent(key: string): CategoryInfo | undefined {\n for (const category of this._categories) {\n // istanbul ignore else\n if (category.subCategoryIds) {\n if (category.subCategoryIds.indexOf(key) !== -1)\n return category;\n }\n }\n\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onDisplayStyleChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onViewedCategoriesChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onVisibilityChangeInternal() {\n if (this._pendingVisibilityChange)\n return;\n\n this._pendingVisibilityChange = setTimeout(() => {\n this.onVisibilityChange.raiseEvent();\n this._pendingVisibilityChange = undefined;\n }, 0);\n }\n\n public static getInstanceIdFromTreeNodeKey(nodeKey: NodeKey) {\n return (NodeKey.isInstancesNodeKey(nodeKey) && nodeKey.instanceKeys.length > 0) ? nodeKey.instanceKeys[0].id : /* istanbul ignore next */ \"\";\n }\n\n public async enableCategory(ids: string[], enabled: boolean, enableAllSubCategories = true) {\n await enableCategory(this._viewManager, this._imodel, ids, enabled, this._useAllViewports, enableAllSubCategories);\n }\n\n public enableSubCategory(key: string, enabled: boolean) {\n enableSubCategory(this._viewManager, key, enabled, this._useAllViewports);\n }\n}\n"]}
1
+ {"version":3,"file":"CategoryVisibilityHandler.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoryVisibilityHandler.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,iCAAgC;AAChC,8DAAwD;AACxD,sDAA8C;AAC9C,wDAAiD;AACjD,oEAAqD;AACrD,4EAA4E;AAC5E,4EAA6G;AAM7G,MAAM,sBAAsB,GAAmB,EAAE,CAAC;AAElD;;;GAGG;AACH,SAAgB,aAAa,CAAC,WAAwB,EAAE,MAAwB,EAAE,IAAe;IAC/F,MAAM,WAAW,GAAG,IAAI,IAAI,WAAW,CAAC,gBAAgB,EAAE,CAAC;IAC3D,MAAM,iBAAiB,GAAG,IAAA,eAAO,EAAC,KAAK,IAAI,EAAE,CAAC,IAAA,sDAA0B,EAAC,MAAM,EAAE,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IACtH,OAAO,IAAA,gCAAa,EAAC,iBAAiB,CAAC,IAAI,sBAAsB,CAAC;AACpE,CAAC;AAJD,sCAIC;AAuBD;;;;GAIG;AACH,MAAa,yBAAyB;IAQpC,YAAY,MAAuC;QAiB5C,uBAAkB,GAAG,IAAI,sBAAO,EAA4B,CAAC;QA2DpE,gEAAgE;QACxD,0BAAqB,GAAG,GAAG,EAAE;YACnC,IAAI,CAAC,0BAA0B,EAAE,CAAC;QAC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AAC,CAAC,QAAQ,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,EAAE;YAC/F,KAAK,MAAM,WAAW,IAAI,QAAQ,CAAC,cAAc;gBAC/C,QAAQ,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SACjI;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;SACnC;KACF;IAED,kBAAkB;IAClB,oBAAoB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAA,6CAAiB,EAC7D,yBAAS,CAAC,WAAW,EACrB,WAAW,EACX,KAAK,EACL,IAAI,CACL,CAAC,CAAC;IAEH,MAAM,IAAA,0CAAc,EAClB,yBAAS,CAAC,WAAW,EACrB,QAAQ,CAAC,MAAM,EACf,OAAO,EACP,KAAK,EACL,IAAI,CACL,CAAC;IAEF,kBAAkB;IAClB,qBAAqB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAA,6CAAiB,EAC9D,yBAAS,CAAC,WAAW,EACrB,WAAW,EACX,IAAI,EACJ,IAAI,CACL,CAAC,CAAC;IAEH,MAAM,IAAA,0CAAc,EAClB,yBAAS,CAAC,WAAW,EACrB,QAAQ,CAAC,MAAM,EACf,QAAQ,EACR,IAAI,EACJ,IAAI,CACL,CAAC;AACJ,CAAC;AAnDD,kDAmDC","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 { useAsyncValue } from \"@itwin/components-react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { NodeKey } from \"@itwin/presentation-common\";\nimport { isPresentationTreeNodeItem } from \"@itwin/presentation-components\";\nimport { enableCategory, enableSubCategory, loadCategoriesFromViewport } from \"../CategoriesVisibilityUtils\";\n\nimport type { TreeNodeItem } from \"@itwin/components-react\";\nimport type { IModelConnection, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { IVisibilityHandler, VisibilityChangeListener, VisibilityStatus } from \"../VisibilityTreeEventHandler\";\n\nconst EMPTY_CATEGORIES_ARRAY: CategoryInfo[] = [];\n\n/**\n * Loads categories from viewport or uses provided list of categories.\n * @internal\n */\nexport function useCategories(viewManager: ViewManager, imodel: IModelConnection, view?: Viewport) {\n const currentView = view || viewManager.getFirstOpenView();\n const categoriesPromise = useMemo(async () => loadCategoriesFromViewport(imodel, currentView), [imodel, currentView]);\n return useAsyncValue(categoriesPromise) ?? EMPTY_CATEGORIES_ARRAY;\n}\n\n/**\n * Data structure that describes category.\n * @public\n */\nexport interface CategoryInfo {\n categoryId: string;\n subCategoryIds?: string[];\n}\n\n/**\n * Params for creating a [[CategoryVisibilityHandler]].\n * @public\n */\nexport interface CategoryVisibilityHandlerParams {\n viewManager: ViewManager;\n imodel: IModelConnection;\n categories: CategoryInfo[];\n activeView: Viewport;\n allViewports?: boolean;\n}\n\n/**\n * An [[IVisibilityHandler]] implementation that knows how to determine and change visibility of categories\n * and subcategories.\n * @public\n */\nexport class CategoryVisibilityHandler implements IVisibilityHandler {\n private _viewManager: ViewManager;\n private _imodel: IModelConnection;\n private _pendingVisibilityChange: any | undefined;\n private _activeView: Viewport;\n private _useAllViewports: boolean;\n private _categories: CategoryInfo[];\n\n constructor(params: CategoryVisibilityHandlerParams) {\n this._viewManager = params.viewManager;\n this._imodel = params.imodel;\n this._activeView = params.activeView;\n // istanbul ignore next\n this._useAllViewports = params.allViewports ?? false;\n this._categories = params.categories;\n this._activeView.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);\n this._activeView.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);\n }\n\n public dispose() {\n this._activeView.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);\n this._activeView.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);\n clearTimeout(this._pendingVisibilityChange);\n }\n\n public onVisibilityChange = new BeEvent<VisibilityChangeListener>();\n\n public getVisibilityStatus(node: TreeNodeItem,): VisibilityStatus {\n const nodeKey = isPresentationTreeNodeItem(node) ? node.key : undefined;\n if (!nodeKey)\n return { state: \"hidden\", isDisabled: true };\n\n const instanceId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n return { state: node.parentId ? this.getSubCategoryVisibility(instanceId) : this.getCategoryVisibility(instanceId) };\n }\n\n public async changeVisibility(node: TreeNodeItem, shouldDisplay: boolean): Promise<void> {\n const nodeKey = isPresentationTreeNodeItem(node) ? node.key : undefined;\n if (!nodeKey)\n return;\n\n // handle subcategory visibility change\n if (node.parentId) {\n const childId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n // istanbul ignore next\n const parentId = this.getParent(childId)?.categoryId;\n\n // make sure parent category is enabled\n if (shouldDisplay && parentId)\n await this.enableCategory([parentId], true, false);\n\n this.enableSubCategory(childId, shouldDisplay);\n return;\n }\n\n const instanceId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n await this.enableCategory([instanceId], shouldDisplay, true);\n }\n\n public getSubCategoryVisibility(id: string) {\n const parentItem = this.getParent(id);\n if (!parentItem)\n return \"hidden\";\n\n const isVisible = this._activeView.view.viewsCategory(parentItem.categoryId) && this._activeView.isSubCategoryVisible(id);\n return isVisible ? \"visible\" : \"hidden\";\n }\n\n public getCategoryVisibility(id: string) {\n return this._activeView.view.viewsCategory(id) ? \"visible\" : \"hidden\";\n }\n\n public getParent(key: string): CategoryInfo | undefined {\n for (const category of this._categories) {\n // istanbul ignore else\n if (category.subCategoryIds) {\n if (category.subCategoryIds.indexOf(key) !== -1)\n return category;\n }\n }\n\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onDisplayStyleChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onViewedCategoriesChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onVisibilityChangeInternal() {\n if (this._pendingVisibilityChange)\n return;\n\n this._pendingVisibilityChange = setTimeout(() => {\n this.onVisibilityChange.raiseEvent();\n this._pendingVisibilityChange = undefined;\n }, 0);\n }\n\n public static getInstanceIdFromTreeNodeKey(nodeKey: NodeKey) {\n return (NodeKey.isInstancesNodeKey(nodeKey) && nodeKey.instanceKeys.length > 0) ? nodeKey.instanceKeys[0].id : /* istanbul ignore next */ \"\";\n }\n\n public async enableCategory(ids: string[], enabled: boolean, enableAllSubCategories = true) {\n await enableCategory(this._viewManager, this._imodel, ids, enabled, this._useAllViewports, enableAllSubCategories);\n }\n\n public enableSubCategory(key: string, enabled: boolean) {\n enableSubCategory(this._viewManager, key, enabled, this._useAllViewports);\n }\n}\n\n/**\n * Enable display of all given categories.\n * @public\n */\nexport async function showAllCategories(categories: string[], viewport: Viewport) {\n await enableCategory(\n IModelApp.viewManager,\n viewport.iModel,\n categories,\n true,\n true\n );\n}\n\n/**\n * Disable display of all given categories.\n * @public\n */\nexport async function hideAllCategories(categories: string[], viewport: Viewport) {\n await enableCategory(\n IModelApp.viewManager,\n viewport.iModel,\n categories,\n false,\n true\n );\n}\n\n/**\n * Invert display of all given categories.\n * @public\n */\nexport async function invertAllCategories(categories: CategoryInfo[], viewport: Viewport) {\n const enabled: string[] = [];\n const disabled: string[] = [];\n const enabledSubCategories: string[] = [];\n const disabledSubCategories: string[] = [];\n\n for (const category of categories) {\n if (!viewport.view.viewsCategory(category.categoryId)) {\n disabled.push(category.categoryId);\n continue;\n }\n // First, we need to check if at least one subcategory is disabled. If it is true, then only subcategories should change display, not categories.\n if (category.subCategoryIds?.some((subCategory) => !viewport.isSubCategoryVisible(subCategory))) {\n for (const subCategory of category.subCategoryIds)\n viewport.isSubCategoryVisible(subCategory) ? enabledSubCategories.push(subCategory) : disabledSubCategories.push(subCategory);\n } else {\n enabled.push(category.categoryId);\n }\n }\n\n // Disable enabled\n enabledSubCategories.forEach((subCategory) => enableSubCategory(\n IModelApp.viewManager,\n subCategory,\n false,\n true\n ));\n\n await enableCategory(\n IModelApp.viewManager,\n viewport.iModel,\n enabled,\n false,\n true\n );\n\n // Enable disabled\n disabledSubCategories.forEach((subCategory) => enableSubCategory(\n IModelApp.viewManager,\n subCategory,\n true,\n true\n ));\n\n await enableCategory(\n IModelApp.viewManager,\n viewport.iModel,\n disabled,\n true,\n true\n );\n}\n"]}
@@ -0,0 +1,230 @@
1
+ {
2
+ "$schema": "../../../../node_modules/@itwin/presentation-common/Ruleset.schema.json",
3
+ "id": "tree-widget-react/ExternalSources",
4
+ "requiredSchemas": [
5
+ {
6
+ "name": "BisCore",
7
+ "minVersion": "1.0.13"
8
+ }
9
+ ],
10
+ "rules": [
11
+ {
12
+ "ruleType": "RootNodes",
13
+ "specifications": [
14
+ {
15
+ "specType": "InstanceNodesOfSpecificClasses",
16
+ "classes": [
17
+ {
18
+ "schemaName": "BisCore",
19
+ "classNames": [
20
+ "ExternalSource"
21
+ ],
22
+ "arePolymorphic": false
23
+ }
24
+ ],
25
+ "relatedInstances": [
26
+ {
27
+ "relationshipPath": [
28
+ {
29
+ "relationship": {
30
+ "schemaName": "BisCore",
31
+ "className": "SynchronizationConfigSpecifiesRootSources"
32
+ },
33
+ "direction": "Backward"
34
+ }
35
+ ],
36
+ "isRequired": true,
37
+ "alias": "configRoot"
38
+ },
39
+ {
40
+ "relationshipPath": [
41
+ {
42
+ "relationship": {
43
+ "schemaName": "BisCore",
44
+ "className": "ExternalSourceIsInRepository"
45
+ },
46
+ "direction": "Forward"
47
+ }
48
+ ],
49
+ "isRequired": true,
50
+ "alias": "repo"
51
+ }
52
+ ],
53
+ "instanceFilter": "configRoot.ECInstanceId <> NULL",
54
+ "groupByClass": false,
55
+ "groupByLabel": false
56
+ }
57
+ ],
58
+ "autoExpand": true
59
+ },
60
+ {
61
+ "ruleType": "ChildNodes",
62
+ "condition": "ParentNode.IsOfClass(\"ExternalSourceGroup\", \"BisCore\")",
63
+ "specifications": [
64
+ {
65
+ "specType": "RelatedInstanceNodes",
66
+ "relationshipPaths": [
67
+ [
68
+ {
69
+ "relationship": {
70
+ "schemaName": "BisCore",
71
+ "className": "ExternalSourceGroupGroupsSources"
72
+ },
73
+ "direction": "Forward"
74
+ }
75
+ ]
76
+ ],
77
+ "groupByClass": false,
78
+ "groupByLabel": false
79
+ }
80
+ ]
81
+ },
82
+ {
83
+ "ruleType": "ChildNodes",
84
+ "condition": "ParentNode.IsOfClass(\"ExternalSource\", \"BisCore\")",
85
+ "specifications": [
86
+ {
87
+ "specType": "RelatedInstanceNodes",
88
+ "relationshipPaths": [
89
+ [
90
+ {
91
+ "relationship": {
92
+ "schemaName": "BisCore",
93
+ "className": "ExternalSourceOwnsAttachments"
94
+ },
95
+ "direction": "Forward"
96
+ },
97
+ {
98
+ "relationship": {
99
+ "schemaName": "BisCore",
100
+ "className": "ExternalSourceAttachmentAttachesSource"
101
+ },
102
+ "direction": "Forward"
103
+ }
104
+ ]
105
+ ],
106
+ "groupByClass": false,
107
+ "groupByLabel": false
108
+ },
109
+ {
110
+ "specType": "CustomNode",
111
+ "type": "T_ExternalSource_Elements",
112
+ "label": "Elements",
113
+ "hideIfNoChildren": true,
114
+ "nestedRules": [
115
+ {
116
+ "ruleType": "ChildNodes",
117
+ "specifications": [
118
+ {
119
+ "specType": "RelatedInstanceNodes",
120
+ "relationshipPaths": [
121
+ [
122
+ {
123
+ "relationship": {
124
+ "schemaName": "BisCore",
125
+ "className": "ElementIsFromSource"
126
+ },
127
+ "direction": "Backward",
128
+ "targetClass": {
129
+ "schemaName": "BisCore",
130
+ "className": "ExternalSourceAspect"
131
+ }
132
+ },
133
+ {
134
+ "relationship": {
135
+ "schemaName": "BisCore",
136
+ "className": "ElementOwnsMultiAspects"
137
+ },
138
+ "direction": "Backward",
139
+ "targetClass": {
140
+ "schemaName": "BisCore",
141
+ "className": "GeometricElement"
142
+ }
143
+ }
144
+ ]
145
+ ],
146
+ "groupByClass": true,
147
+ "groupByLabel": false
148
+ }
149
+ ]
150
+ }
151
+ ]
152
+ }
153
+ ]
154
+ },
155
+ {
156
+ "ruleType": "InstanceLabelOverride",
157
+ "class": {
158
+ "schemaName": "BisCore",
159
+ "className": "RepositoryLink"
160
+ },
161
+ "values": [
162
+ {
163
+ "specType": "Property",
164
+ "propertyName": "UserLabel"
165
+ }
166
+ ]
167
+ },
168
+ {
169
+ "ruleType": "InstanceLabelOverride",
170
+ "class": {
171
+ "schemaName": "BisCore",
172
+ "className": "ExternalSource"
173
+ },
174
+ "values": [
175
+ {
176
+ "specType": "Composite",
177
+ "separator": " - ",
178
+ "parts": [
179
+ {
180
+ "spec": {
181
+ "specType": "RelatedInstanceLabel",
182
+ "pathToRelatedInstance": {
183
+ "relationship": {
184
+ "schemaName": "BisCore",
185
+ "className": "ExternalSourceIsInRepository"
186
+ },
187
+ "direction": "Forward"
188
+ }
189
+ }
190
+ },
191
+ {
192
+ "spec": {
193
+ "specType": "Property",
194
+ "propertyName": "UserLabel"
195
+ }
196
+ }
197
+ ]
198
+ }
199
+ ]
200
+ },
201
+ {
202
+ "ruleType": "ExtendedData",
203
+ "condition": "ThisNode.IsInstanceNode ANDALSO this.IsOfClass(\"ExternalSource\", \"BisCore\")",
204
+ "items": {
205
+ "imageId": "\"icon-document\""
206
+ }
207
+ },
208
+ {
209
+ "ruleType": "ExtendedData",
210
+ "condition": "ThisNode.Type = \"T_ExternalSource_Elements\"",
211
+ "items": {
212
+ "imageId": "\"icon-ec-schema\""
213
+ }
214
+ },
215
+ {
216
+ "ruleType": "ExtendedData",
217
+ "condition": "ThisNode.IsClassGroupingNode",
218
+ "items": {
219
+ "imageId": "\"icon-ec-class\""
220
+ }
221
+ },
222
+ {
223
+ "ruleType": "ExtendedData",
224
+ "condition": "ThisNode.IsInstanceNode ANDALSO ThisNode.IsOfClass(\"GeometricElement\", \"BisCore\")",
225
+ "items": {
226
+ "imageId": "\"icon-item\""
227
+ }
228
+ }
229
+ ]
230
+ }
@@ -0,0 +1,27 @@
1
+ /// <reference types="react" />
2
+ import "../VisibilityTreeBase.scss";
3
+ import type { IModelConnection } from "@itwin/core-frontend";
4
+ import type { Ruleset } from "@itwin/presentation-common";
5
+ /**
6
+ * Presentation rules used by ControlledCategoriesTree
7
+ * @internal
8
+ */
9
+ export declare const RULESET_EXTERNAL_SOURCES: Ruleset;
10
+ /**
11
+ * Props for the [[ExternalSourcesTree]] component
12
+ * @alpha
13
+ */
14
+ export interface ExternalSourcesTreeProps {
15
+ /** An IModel to pull data from */
16
+ iModel: IModelConnection;
17
+ /** Width of the component */
18
+ width: number;
19
+ /** Height of the component */
20
+ height: number;
21
+ }
22
+ /**
23
+ * Tree which displays a hierarchy of ExternalSources and their elements.
24
+ * @alpha
25
+ */
26
+ export declare function ExternalSourcesTree(props: ExternalSourcesTreeProps): JSX.Element;
27
+ //# sourceMappingURL=ExternalSourcesTree.d.ts.map
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ExternalSourcesTree = exports.RULESET_EXTERNAL_SOURCES = void 0;
27
+ const jsx_runtime_1 = require("react/jsx-runtime");
28
+ /*---------------------------------------------------------------------------------------------
29
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
30
+ * See LICENSE.md in the project root for license terms and full copyright notice.
31
+ *--------------------------------------------------------------------------------------------*/
32
+ require("../VisibilityTreeBase.scss");
33
+ const components_react_1 = require("@itwin/components-react");
34
+ const presentation_components_1 = require("@itwin/presentation-components");
35
+ const RULESET_EXTERNAL_SOURCES_IMPORT = __importStar(require("./ExternalSources.json"));
36
+ /**
37
+ * Presentation rules used by ControlledCategoriesTree
38
+ * @internal
39
+ */
40
+ exports.RULESET_EXTERNAL_SOURCES = RULESET_EXTERNAL_SOURCES_IMPORT;
41
+ const PAGING_SIZE = 20;
42
+ /**
43
+ * Tree which displays a hierarchy of ExternalSources and their elements.
44
+ * @alpha
45
+ */
46
+ function ExternalSourcesTree(props) {
47
+ const { nodeLoader } = (0, presentation_components_1.usePresentationTreeNodeLoader)({
48
+ imodel: props.iModel,
49
+ ruleset: exports.RULESET_EXTERNAL_SOURCES,
50
+ pagingSize: PAGING_SIZE,
51
+ customizeTreeNodeItem,
52
+ });
53
+ const eventsHandler = (0, presentation_components_1.useUnifiedSelectionTreeEventHandler)({ nodeLoader });
54
+ const treeModel = (0, components_react_1.useTreeModel)(nodeLoader.modelSource);
55
+ return ((0, jsx_runtime_1.jsx)("div", { className: "tree-widget-visibility-tree-base", children: (0, jsx_runtime_1.jsx)(components_react_1.ControlledTree, { nodeLoader: nodeLoader, model: treeModel, selectionMode: components_react_1.SelectionMode.Extended, eventsHandler: eventsHandler, width: props.width, height: props.height, iconsEnabled: true }) }));
56
+ }
57
+ exports.ExternalSourcesTree = ExternalSourcesTree;
58
+ function customizeTreeNodeItem(item, node) {
59
+ item.icon = node.extendedData?.imageId;
60
+ }
61
+ //# sourceMappingURL=ExternalSourcesTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExternalSourcesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/external-sources-tree/ExternalSourcesTree.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAE/F,sCAAoC;AACpC,8DAAsF;AACtF,4EAAoH;AACpH,wFAA0E;AAM1E;;;GAGG;AACU,QAAA,wBAAwB,GAAG,+BAA0C,CAAC;AAEnF,MAAM,WAAW,GAAG,EAAE,CAAC;AAevB;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,uDAA6B,EAAC;QACnD,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO,EAAE,gCAAwB;QACjC,UAAU,EAAE,WAAW;QACvB,qBAAqB;KACtB,CAAC,CAAC;IACH,MAAM,aAAa,GAAG,IAAA,6DAAmC,EAAC,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1E,MAAM,SAAS,GAAG,IAAA,+BAAY,EAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACvD,OAAO,CACL,gCAAK,SAAS,EAAC,kCAAkC,YAC/C,uBAAC,iCAAc,IACb,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,SAAS,EAChB,aAAa,EAAE,gCAAa,CAAC,QAAQ,EACrC,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,YAAY,EAAE,IAAI,GAClB,GACE,CACP,CAAC;AACJ,CAAC;AAtBD,kDAsBC;AAED,SAAS,qBAAqB,CAAC,IAAsC,EAAE,IAAmB;IACxF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC;AACzC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport { ControlledTree, SelectionMode, useTreeModel } from \"@itwin/components-react\";\nimport { usePresentationTreeNodeLoader, useUnifiedSelectionTreeEventHandler } from \"@itwin/presentation-components\";\nimport * as RULESET_EXTERNAL_SOURCES_IMPORT from \"./ExternalSources.json\";\n\nimport type { DelayLoadedTreeNodeItem } from \"@itwin/components-react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { Node, Ruleset } from \"@itwin/presentation-common\";\n\n/**\n * Presentation rules used by ControlledCategoriesTree\n * @internal\n */\nexport const RULESET_EXTERNAL_SOURCES = RULESET_EXTERNAL_SOURCES_IMPORT as Ruleset;\n\nconst PAGING_SIZE = 20;\n\n/**\n * Props for the [[ExternalSourcesTree]] component\n * @alpha\n */\nexport interface ExternalSourcesTreeProps {\n /** An IModel to pull data from */\n iModel: IModelConnection;\n /** Width of the component */\n width: number;\n /** Height of the component */\n height: number;\n}\n\n/**\n * Tree which displays a hierarchy of ExternalSources and their elements.\n * @alpha\n */\nexport function ExternalSourcesTree(props: ExternalSourcesTreeProps) {\n const { nodeLoader } = usePresentationTreeNodeLoader({\n imodel: props.iModel,\n ruleset: RULESET_EXTERNAL_SOURCES,\n pagingSize: PAGING_SIZE,\n customizeTreeNodeItem,\n });\n const eventsHandler = useUnifiedSelectionTreeEventHandler({ nodeLoader });\n const treeModel = useTreeModel(nodeLoader.modelSource);\n return (\n <div className=\"tree-widget-visibility-tree-base\">\n <ControlledTree\n nodeLoader={nodeLoader}\n model={treeModel}\n selectionMode={SelectionMode.Extended}\n eventsHandler={eventsHandler}\n width={props.width}\n height={props.height}\n iconsEnabled={true}\n />\n </div>\n );\n}\n\nfunction customizeTreeNodeItem(item: Partial<DelayLoadedTreeNodeItem>, node: Partial<Node>) {\n item.icon = node.extendedData?.imageId;\n}\n"]}
@@ -0,0 +1,20 @@
1
+ /// <reference types="react" />
2
+ import "../VisibilityTreeBase.scss";
3
+ /**
4
+ * A component that displays an External Sources tree and any necessary "chrome".
5
+ * @alpha
6
+ */
7
+ export declare const ExternalSourcesTreeComponent: {
8
+ (props: {}): JSX.Element | null;
9
+ /**
10
+ * Id of the component. May be used when a creating a [[TreeDefinition]] for [[ExternalSourcesTreeComponent]].
11
+ * @alpha
12
+ */
13
+ id: string;
14
+ /**
15
+ * Label of the component. May be used when a creating a [[TreeDefinition]] for [[ExternalSourcesTreeComponent]].
16
+ * @alpha
17
+ */
18
+ getLabel(): string;
19
+ };
20
+ //# sourceMappingURL=ExternalSourcesTreeComponent.d.ts.map
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExternalSourcesTreeComponent = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ /*---------------------------------------------------------------------------------------------
6
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
7
+ * See LICENSE.md in the project root for license terms and full copyright notice.
8
+ *--------------------------------------------------------------------------------------------*/
9
+ require("../VisibilityTreeBase.scss");
10
+ const appui_react_1 = require("@itwin/appui-react");
11
+ const TreeWidget_1 = require("../../../TreeWidget");
12
+ const AutoSizer_1 = require("../../utils/AutoSizer");
13
+ const ExternalSourcesTree_1 = require("./ExternalSourcesTree");
14
+ /**
15
+ * A component that displays an External Sources tree and any necessary "chrome".
16
+ * @alpha
17
+ */
18
+ const ExternalSourcesTreeComponent = (props) => {
19
+ const iModel = (0, appui_react_1.useActiveIModelConnection)();
20
+ if (!iModel) {
21
+ return null;
22
+ }
23
+ return ((0, jsx_runtime_1.jsx)(ExternalSourcesTreeComponentImpl, { ...props, iModel: iModel }));
24
+ };
25
+ exports.ExternalSourcesTreeComponent = ExternalSourcesTreeComponent;
26
+ function ExternalSourcesTreeComponentImpl(props) {
27
+ return ((0, jsx_runtime_1.jsx)(AutoSizer_1.AutoSizer, { children: ({ width, height }) => ((0, jsx_runtime_1.jsx)(ExternalSourcesTree_1.ExternalSourcesTree, { ...props, width: width, height: height })) }));
28
+ }
29
+ /**
30
+ * Id of the component. May be used when a creating a [[TreeDefinition]] for [[ExternalSourcesTreeComponent]].
31
+ * @alpha
32
+ */
33
+ exports.ExternalSourcesTreeComponent.id = "external-sources-tree";
34
+ /**
35
+ * Label of the component. May be used when a creating a [[TreeDefinition]] for [[ExternalSourcesTreeComponent]].
36
+ * @alpha
37
+ */
38
+ exports.ExternalSourcesTreeComponent.getLabel = () => TreeWidget_1.TreeWidget.translate("externalSources");
39
+ //# sourceMappingURL=ExternalSourcesTreeComponent.js.map