@itwin/tree-widget-react 1.0.0-dev.3 → 1.0.0-dev.5

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 (96) hide show
  1. package/README.md +2 -1
  2. package/lib/cjs/components/{TreeWidgetComponent.d.ts → SelectableTree.d.ts} +6 -6
  3. package/lib/cjs/components/{TreeWidgetComponent.js → SelectableTree.js} +8 -8
  4. package/lib/cjs/components/SelectableTree.js.map +1 -0
  5. package/lib/{esm/components/TreeWidgetComponent.scss → cjs/components/SelectableTree.scss} +1 -15
  6. package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +3 -2
  7. package/lib/cjs/components/TreeWidgetUiItemsProvider.js +9 -3
  8. package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
  9. package/lib/cjs/components/TreeWidgetUiItemsProvider.scss +9 -0
  10. package/lib/cjs/components/tree-header/TreeHeader.js +23 -1
  11. package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
  12. package/lib/cjs/components/trees/Common.d.ts +27 -0
  13. package/lib/cjs/components/trees/Common.js.map +1 -1
  14. package/lib/cjs/components/trees/VisibilityTreeRenderer.d.ts +13 -5
  15. package/lib/cjs/components/trees/VisibilityTreeRenderer.js +11 -10
  16. package/lib/cjs/components/trees/VisibilityTreeRenderer.js.map +1 -1
  17. package/lib/cjs/components/trees/category-tree/Categories.json +4 -8
  18. package/lib/cjs/components/trees/category-tree/CategoriesTree.d.ts +3 -21
  19. package/lib/cjs/components/trees/category-tree/CategoriesTree.js +8 -2
  20. package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +1 -1
  21. package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.d.ts +2 -2
  22. package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js +2 -2
  23. package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
  24. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +2 -9
  25. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +1 -1
  26. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  27. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +3 -13
  28. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +2 -6
  29. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  30. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +2 -2
  31. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js +2 -2
  32. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
  33. package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +3 -29
  34. package/lib/cjs/components/trees/models-tree/ModelsTree.js +11 -2
  35. package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
  36. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.d.ts +2 -2
  37. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +2 -2
  38. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  39. package/lib/cjs/components/trees/models-tree/Utils.d.ts +4 -1
  40. package/lib/cjs/components/trees/models-tree/Utils.js +28 -36
  41. package/lib/cjs/components/trees/models-tree/Utils.js.map +1 -1
  42. package/lib/cjs/components/utils/UseTreeTransientState.d.ts +19 -0
  43. package/lib/cjs/components/utils/UseTreeTransientState.js +33 -0
  44. package/lib/cjs/components/utils/UseTreeTransientState.js.map +1 -0
  45. package/lib/cjs/tree-widget-react.d.ts +2 -1
  46. package/lib/cjs/tree-widget-react.js +2 -1
  47. package/lib/cjs/tree-widget-react.js.map +1 -1
  48. package/lib/esm/components/{TreeWidgetComponent.d.ts → SelectableTree.d.ts} +6 -6
  49. package/lib/esm/components/{TreeWidgetComponent.js → SelectableTree.js} +6 -6
  50. package/lib/esm/components/SelectableTree.js.map +1 -0
  51. package/lib/{cjs/components/TreeWidgetComponent.scss → esm/components/SelectableTree.scss} +1 -15
  52. package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +3 -2
  53. package/lib/esm/components/TreeWidgetUiItemsProvider.js +9 -3
  54. package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
  55. package/lib/esm/components/TreeWidgetUiItemsProvider.scss +9 -0
  56. package/lib/esm/components/tree-header/TreeHeader.js +24 -2
  57. package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
  58. package/lib/esm/components/trees/Common.d.ts +27 -0
  59. package/lib/esm/components/trees/Common.js.map +1 -1
  60. package/lib/esm/components/trees/VisibilityTreeRenderer.d.ts +13 -5
  61. package/lib/esm/components/trees/VisibilityTreeRenderer.js +10 -9
  62. package/lib/esm/components/trees/VisibilityTreeRenderer.js.map +1 -1
  63. package/lib/esm/components/trees/category-tree/Categories.json +4 -8
  64. package/lib/esm/components/trees/category-tree/CategoriesTree.d.ts +3 -21
  65. package/lib/esm/components/trees/category-tree/CategoriesTree.js +8 -2
  66. package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +1 -1
  67. package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.d.ts +2 -2
  68. package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js +2 -2
  69. package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
  70. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +2 -9
  71. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +1 -1
  72. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  73. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +3 -13
  74. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +2 -3
  75. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  76. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +2 -2
  77. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js +2 -2
  78. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
  79. package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +3 -29
  80. package/lib/esm/components/trees/models-tree/ModelsTree.js +12 -3
  81. package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
  82. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.d.ts +2 -2
  83. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +2 -2
  84. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  85. package/lib/esm/components/trees/models-tree/Utils.d.ts +4 -1
  86. package/lib/esm/components/trees/models-tree/Utils.js +26 -35
  87. package/lib/esm/components/trees/models-tree/Utils.js.map +1 -1
  88. package/lib/esm/components/utils/UseTreeTransientState.d.ts +19 -0
  89. package/lib/esm/components/utils/UseTreeTransientState.js +29 -0
  90. package/lib/esm/components/utils/UseTreeTransientState.js.map +1 -0
  91. package/lib/esm/tree-widget-react.d.ts +2 -1
  92. package/lib/esm/tree-widget-react.js +2 -1
  93. package/lib/esm/tree-widget-react.js.map +1 -1
  94. package/package.json +10 -10
  95. package/lib/cjs/components/TreeWidgetComponent.js.map +0 -1
  96. package/lib/esm/components/TreeWidgetComponent.js.map +0 -1
@@ -46,13 +46,19 @@ function CategoryTree(props) {
46
46
  visibilityHandler,
47
47
  }), [filteredNodeLoader, visibilityHandler]));
48
48
  const treeModel = (0, components_react_1.useTreeModel)(filteredNodeLoader.modelSource);
49
- const treeRenderer = (0, VisibilityTreeRenderer_1.createVisibilityTreeRenderer)({ iconsEnabled: false, descriptionEnabled: true, levelOffset: 10 });
49
+ const treeRenderer = (0, VisibilityTreeRenderer_1.createVisibilityTreeRenderer)({
50
+ nodeRendererProps: {
51
+ iconsEnabled: false,
52
+ descriptionEnabled: true,
53
+ levelOffset: 10,
54
+ },
55
+ });
50
56
  const overlay = isFiltering ? (0, jsx_runtime_1.jsx)("div", { className: "filteredTreeOverlay" }) : undefined;
51
57
  const filterApplied = filteredNodeLoader !== nodeLoader;
52
58
  const noFilteredDataRenderer = (0, react_1.useCallback)(() => {
53
59
  return (0, jsx_runtime_1.jsx)(VisibilityTreeRenderer_1.VisibilityTreeNoFilteredData, { title: TreeWidget_1.TreeWidget.translate("categoriesTree.noCategoryFound"), message: TreeWidget_1.TreeWidget.translate("categoriesTree.noMatchingCategoryNames") });
54
60
  }, []);
55
- return ((0, jsx_runtime_1.jsxs)("div", { className: "tree-widget-visibility-tree-base", children: [(0, jsx_runtime_1.jsx)(components_react_1.ControlledTree, { nodeLoader: filteredNodeLoader, model: treeModel, selectionMode: components_react_1.SelectionMode.None, eventsHandler: eventHandler, treeRenderer: treeRenderer, descriptionsEnabled: true, nodeHighlightingProps: nodeHighlightingProps, noDataRenderer: filterApplied ? noFilteredDataRenderer : undefined, width: props.width, height: props.height }), overlay] }));
61
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "tree-widget-visibility-tree-base", children: [(0, jsx_runtime_1.jsx)(components_react_1.ControlledTree, { nodeLoader: filteredNodeLoader, model: treeModel, selectionMode: props.selectionMode ?? components_react_1.SelectionMode.None, eventsHandler: eventHandler, treeRenderer: treeRenderer, descriptionsEnabled: true, nodeHighlightingProps: nodeHighlightingProps, noDataRenderer: filterApplied ? noFilteredDataRenderer : undefined, width: props.width, height: props.height }), overlay] }));
56
62
  }
57
63
  exports.CategoryTree = CategoryTree;
58
64
  function useCategoryVisibilityHandler(viewManager, imodel, categories, activeView, allViewports, visibilityHandler) {
@@ -1 +1 @@
1
- {"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTree.tsx"],"names":[],"mappings":";;;;AAAA;;;+FAG+F;AAE/F,sCAAoC;AACpC,iCAA+C;AAC/C,8DAAsF;AACtF,wDAAiD;AACjD,kDAAkD;AAClD,4EAA+E;AAC/E,wEAA4D;AAC5D,oDAAiD;AACjD,8EAA2E;AAC3E,sEAAmI;AACnI,2EAAw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,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,EAC9F,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAC7D,CAAC;IACF,uBAAuB;IACvB,OAAO,iBAAiB,IAAI,wBAAwB,CAAC;AACvD,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,UAAoB;IAC7C,MAAM,IAAI,GAAG,UAAU,CAAC,IAAwB,CAAC;IACjD,iFAAiF;IACjF,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,yCAAyC;IACrF,MAAM,oCAAY,CAAC,YAAY,CAAC,IAAI,CAAC,0BAAkB,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC9F,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport { useCallback, useEffect } from \"react\";\nimport { ControlledTree, SelectionMode, useTreeModel } from \"@itwin/components-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { useDisposable } from \"@itwin/core-react\";\nimport { usePresentationTreeNodeLoader } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { VisibilityTreeEventHandler } from \"../VisibilityTreeEventHandler\";\nimport { createVisibilityTreeRenderer, useVisibilityTreeFiltering, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { CategoryVisibilityHandler } from \"./CategoryVisibilityHandler\";\n\nimport type { IModelConnection, SpatialViewState, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { VisibilityTreeFilterInfo } from \"../Common\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\n\nconst PAGING_SIZE = 20;\n\n/**\n * Presentation rules used by ControlledCategoriesTree\n * @internal\n */\nexport const RULESET_CATEGORIES: Ruleset = require(\"./Categories.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\n\n/**\n * Properties for the [[CategoryTree]] component\n * @public\n */\nexport interface CategoryTreeProps {\n /** Flag for accommodating all viewports */\n allViewports?: boolean;\n /** Active viewport */\n activeView: Viewport;\n /**\n * An IModel to pull data from\n */\n iModel: IModelConnection;\n /** Width of the component */\n width: number;\n /** Height of the component */\n height: number;\n /**\n * Information for tree filtering.\n * @alpha\n */\n filterInfo?: VisibilityTreeFilterInfo;\n /**\n * Callback invoked when tree is filtered.\n */\n onFilterApplied?: (filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void;\n /**\n * Available iModel categories\n */\n categories: CategoryInfo[];\n /**\n * Custom category visibility handler to use for testing\n * @internal\n */\n categoryVisibilityHandler?: CategoryVisibilityHandler;\n /**\n * Custom view manager to use for testing\n * @internal\n */\n viewManager?: ViewManager;\n}\n\n/**\n * Tree which displays and manages display of categories contained in an iModel.\n * @public\n */\nexport function CategoryTree(props: CategoryTreeProps) {\n const { nodeLoader } = usePresentationTreeNodeLoader({\n imodel: props.iModel,\n ruleset: RULESET_CATEGORIES,\n pagingSize: PAGING_SIZE,\n });\n\n const { filteredNodeLoader, isFiltering, nodeHighlightingProps } = useVisibilityTreeFiltering(nodeLoader, props.filterInfo, props.onFilterApplied);\n // istanbul ignore next\n const viewManager = props.viewManager ?? IModelApp.viewManager;\n const { activeView, allViewports, categoryVisibilityHandler } = props;\n const visibilityHandler = useCategoryVisibilityHandler(viewManager, props.iModel, props.categories, activeView, allViewports, categoryVisibilityHandler);\n\n useEffect(() => {\n setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [activeView]);\n\n const eventHandler = useDisposable(useCallback(() => new VisibilityTreeEventHandler({\n nodeLoader: filteredNodeLoader,\n visibilityHandler,\n }), [filteredNodeLoader, visibilityHandler]));\n\n const treeModel = useTreeModel(filteredNodeLoader.modelSource);\n const treeRenderer = createVisibilityTreeRenderer({ iconsEnabled: false, descriptionEnabled: true, levelOffset: 10 });\n const overlay = isFiltering ? <div className=\"filteredTreeOverlay\" /> : undefined;\n const filterApplied = filteredNodeLoader !== nodeLoader;\n\n const noFilteredDataRenderer = useCallback(() => {\n return <VisibilityTreeNoFilteredData\n title={TreeWidget.translate(\"categoriesTree.noCategoryFound\")}\n message={TreeWidget.translate(\"categoriesTree.noMatchingCategoryNames\")}\n />;\n }, []);\n\n return (\n <div className=\"tree-widget-visibility-tree-base\">\n <ControlledTree\n nodeLoader={filteredNodeLoader}\n model={treeModel}\n selectionMode={SelectionMode.None}\n eventsHandler={eventHandler}\n treeRenderer={treeRenderer}\n descriptionsEnabled={true}\n nodeHighlightingProps={nodeHighlightingProps}\n noDataRenderer={filterApplied ? noFilteredDataRenderer : undefined}\n width={props.width}\n height={props.height}\n />\n {overlay}\n </div>\n );\n}\n\nfunction useCategoryVisibilityHandler(viewManager: ViewManager, imodel: IModelConnection, categories: CategoryInfo[], activeView: Viewport, allViewports?: boolean, visibilityHandler?: CategoryVisibilityHandler) {\n const defaultVisibilityHandler = useDisposable(useCallback(\n () =>\n new CategoryVisibilityHandler({ viewManager, imodel, categories, activeView, allViewports }),\n [viewManager, imodel, categories, activeView, allViewports]),\n );\n // istanbul ignore next\n return visibilityHandler ?? defaultVisibilityHandler;\n}\n\nasync function setViewType(activeView: Viewport) {\n const view = activeView.view as SpatialViewState;\n // TODO: remove this eslint rule when tree-widget uses itwinjs-core 4.0.0 version\n const viewType = view.is3d() ? \"3d\" : \"2d\"; // eslint-disable-line @itwin/no-internal\n await Presentation.presentation.vars(RULESET_CATEGORIES.id).setString(\"ViewType\", viewType);\n}\n"]}
1
+ {"version":3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K,EAClB,MAAM,EAAE,KAAK,CAAC,MAAM,GACpB,EACD,OAAO,IACJ,CACP,CAAC;AACJ,CAAC;AAzDD,oCAyDC;AAED,SAAS,4BAA4B,CAAC,WAAwB,EAAE,MAAwB,EAAE,UAA0B,EAAE,UAAoB,EAAE,YAAsB,EAAE,iBAA6C;IAC/M,MAAM,wBAAwB,GAAG,IAAA,0BAAa,EAAC,IAAA,mBAAW,EACxD,GAAG,EAAE,CACH,IAAI,qDAAyB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,EAC9F,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAC7D,CAAC;IACF,uBAAuB;IACvB,OAAO,iBAAiB,IAAI,wBAAwB,CAAC;AACvD,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,UAAoB;IAC7C,MAAM,IAAI,GAAG,UAAU,CAAC,IAAwB,CAAC;IACjD,iFAAiF;IACjF,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,yCAAyC;IACrF,MAAM,oCAAY,CAAC,YAAY,CAAC,IAAI,CAAC,0BAAkB,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC9F,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport { useCallback, useEffect } from \"react\";\nimport { ControlledTree, SelectionMode, useTreeModel } from \"@itwin/components-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { useDisposable } from \"@itwin/core-react\";\nimport { usePresentationTreeNodeLoader } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { VisibilityTreeEventHandler } from \"../VisibilityTreeEventHandler\";\nimport { createVisibilityTreeRenderer, useVisibilityTreeFiltering, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { CategoryVisibilityHandler } from \"./CategoryVisibilityHandler\";\n\nimport type { IModelConnection, SpatialViewState, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { BaseFilterableTreeProps } from \"../Common\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\n\nconst PAGING_SIZE = 20;\n\n/**\n * Presentation rules used by ControlledCategoriesTree\n * @internal\n */\nexport const RULESET_CATEGORIES: Ruleset = require(\"./Categories.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\n\n/**\n * Properties for the [[CategoryTree]] component\n * @public\n */\nexport interface CategoryTreeProps extends BaseFilterableTreeProps {\n /** Flag for accommodating all viewports */\n allViewports?: boolean;\n /** Active viewport */\n activeView: Viewport;\n /**\n * Available iModel categories\n */\n categories: CategoryInfo[];\n /**\n * Custom category visibility handler to use for testing\n * @internal\n */\n categoryVisibilityHandler?: CategoryVisibilityHandler;\n /**\n * Custom view manager to use for testing\n * @internal\n */\n viewManager?: ViewManager;\n}\n\n/**\n * Tree which displays and manages display of categories contained in an iModel.\n * @public\n */\nexport function CategoryTree(props: CategoryTreeProps) {\n const { nodeLoader } = usePresentationTreeNodeLoader({\n imodel: props.iModel,\n ruleset: RULESET_CATEGORIES,\n pagingSize: PAGING_SIZE,\n });\n\n const { filteredNodeLoader, isFiltering, nodeHighlightingProps } = useVisibilityTreeFiltering(nodeLoader, props.filterInfo, props.onFilterApplied);\n // istanbul ignore next\n const viewManager = props.viewManager ?? IModelApp.viewManager;\n const { activeView, allViewports, categoryVisibilityHandler } = props;\n const visibilityHandler = useCategoryVisibilityHandler(viewManager, props.iModel, props.categories, activeView, allViewports, categoryVisibilityHandler);\n\n useEffect(() => {\n setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [activeView]);\n\n const eventHandler = useDisposable(useCallback(() => new VisibilityTreeEventHandler({\n nodeLoader: filteredNodeLoader,\n visibilityHandler,\n }), [filteredNodeLoader, visibilityHandler]));\n\n const treeModel = useTreeModel(filteredNodeLoader.modelSource);\n const treeRenderer = createVisibilityTreeRenderer({\n nodeRendererProps: {\n iconsEnabled: false,\n descriptionEnabled: true,\n levelOffset: 10,\n },\n });\n const overlay = isFiltering ? <div className=\"filteredTreeOverlay\" /> : undefined;\n const filterApplied = filteredNodeLoader !== nodeLoader;\n\n const noFilteredDataRenderer = useCallback(() => {\n return <VisibilityTreeNoFilteredData\n title={TreeWidget.translate(\"categoriesTree.noCategoryFound\")}\n message={TreeWidget.translate(\"categoriesTree.noMatchingCategoryNames\")}\n />;\n }, []);\n\n return (\n <div className=\"tree-widget-visibility-tree-base\">\n <ControlledTree\n nodeLoader={filteredNodeLoader}\n model={treeModel}\n selectionMode={props.selectionMode ?? SelectionMode.None}\n eventsHandler={eventHandler}\n treeRenderer={treeRenderer}\n descriptionsEnabled={true}\n nodeHighlightingProps={nodeHighlightingProps}\n noDataRenderer={filterApplied ? noFilteredDataRenderer : undefined}\n width={props.width}\n height={props.height}\n />\n {overlay}\n </div>\n );\n}\n\nfunction useCategoryVisibilityHandler(viewManager: ViewManager, imodel: IModelConnection, categories: CategoryInfo[], activeView: Viewport, allViewports?: boolean, visibilityHandler?: CategoryVisibilityHandler) {\n const defaultVisibilityHandler = useDisposable(useCallback(\n () =>\n new CategoryVisibilityHandler({ viewManager, imodel, categories, activeView, allViewports }),\n [viewManager, imodel, categories, activeView, allViewports]),\n );\n // istanbul ignore next\n return visibilityHandler ?? defaultVisibilityHandler;\n}\n\nasync function setViewType(activeView: Viewport) {\n const view = activeView.view as SpatialViewState;\n // TODO: remove this eslint rule when tree-widget uses itwinjs-core 4.0.0 version\n const viewType = view.is3d() ? \"3d\" : \"2d\"; // eslint-disable-line @itwin/no-internal\n await Presentation.presentation.vars(RULESET_CATEGORIES.id).setString(\"ViewType\", viewType);\n}\n"]}
@@ -54,12 +54,12 @@ export declare const CategoriesTreeComponent: {
54
54
  */
55
55
  InvertAllButton: typeof InvertAllButton;
56
56
  /**
57
- * Id of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].
57
+ * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].
58
58
  * @public
59
59
  */
60
60
  id: string;
61
61
  /**
62
- * Label of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].
62
+ * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].
63
63
  * @public
64
64
  */
65
65
  getLabel(): string;
@@ -49,12 +49,12 @@ exports.CategoriesTreeComponent.HideAllButton = HideAllButton;
49
49
  */
50
50
  exports.CategoriesTreeComponent.InvertAllButton = InvertAllButton;
51
51
  /**
52
- * Id of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].
52
+ * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].
53
53
  * @public
54
54
  */
55
55
  exports.CategoriesTreeComponent.id = "categories-tree";
56
56
  /**
57
- * Label of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].
57
+ * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].
58
58
  * @public
59
59
  */
60
60
  exports.CategoriesTreeComponent.getLabel = () => TreeWidget_1.TreeWidget.translate("categories");
@@ -1 +1 @@
1
- {"version":3,"file":"CategoriesTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTreeComponent.tsx"],"names":[],"mappings":";;;;AAAA;;;+FAG+F;AAE/F,sCAAoC;AACpC,iCAAsD;AACtD,oDAAkF;AAClF,wDAAiD;AACjD,oEAAqG;AACrG,wDAAkD;AAClD,4EAA4E;AAC5E,oDAAiD;AACjD,6DAA0D;AAC1D,iEAAiE;AACjE,q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CAAC,SAAS,CAAC,SAAS,CAAC,EACtC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,IAAA,6CAAiB,EAAC,CAAC,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,YAE5I,uBAAC,uCAAiB,KAAG,GACV,CACd,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,KAAsC;IAC3D,OAAO,CACL,uBAAC,0BAAU,IACT,IAAI,EAAC,OAAO,EACZ,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,SAAS,CAAC,EACtC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,IAAA,6CAAiB,EAAC,CAAC,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,YAE5I,uBAAC,uCAAiB,KAAG,GACV,CACd,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,KAAsC;IAC7D,OAAO,CACL,uBAAC,0BAAU,IACT,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,EACrC,IAAI,EAAC,OAAO,EACZ,SAAS,EAAC,YAAY,EACtB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,IAAA,+CAAmB,EAAC,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,YAErG,uBAAC,uCAAiB,KAAG,GACV,CACd,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport { Fragment, useEffect, useState } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { IconButton } from \"@itwin/itwinui-react\";\nimport { isPresentationTreeNodeItem } from \"@itwin/presentation-components\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeHeader } from \"../../tree-header/TreeHeader\";\nimport { useTreeFilteringState } from \"../../TreeFilteringState\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { CategoryTree } from \"./CategoriesTree\";\nimport { CategoryVisibilityHandler, hideAllCategories, invertAllCategories, showAllCategories, useCategories } from \"./CategoryVisibilityHandler\";\n\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\nimport type { CategoryTreeProps } from \"./CategoriesTree\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\n\n/**\n * Props that get passed to [[CategoriesTreeComponent]] header button renderer.\n * @see CategoriesTreeComponentProps.headerButtons\n * @public\n */\nexport interface CategoriesTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of categories available in the iModel */\n categories: CategoryInfo[];\n /** In case the tree is filtered, a list of filtered categories. */\n filteredCategories?: CategoryInfo[];\n}\n\n/**\n * Props for [[CategoriesTreeComponent]].\n * @public\n */\nexport interface CategoriesTreeComponentProps extends Omit<CategoryTreeProps,\n| \"iModel\"\n| \"activeView\"\n| \"width\"\n| \"height\"\n| \"filterInfo\"\n| \"onFilterApplied\"\n| \"categories\"\n| \"categoryVisibilityHandler\"\n| \"viewManager\"\n> {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * CategoriesTreeComponent.ShowAllButton,\n * CategoriesTreeComponent.HideAllButton,\n * CategoriesTreeComponent.InvertAllButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: CategoriesTreeHeaderButtonProps) => React.ReactNode>;\n}\n\n/**\n * A component that renders [[CategoriesTree]] and a header with filtering capabilities\n * and header buttons.\n * @public\n */\nexport const CategoriesTreeComponent = (props: CategoriesTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return (\n <CategoriesTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />\n );\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all categories and their subcategories.\n * @public\n */\nCategoriesTreeComponent.ShowAllButton = ShowAllButton;\n\n/**\n * Renders a \"Hide all\" button that disables display of all categories.\n * @public\n */\nCategoriesTreeComponent.HideAllButton = HideAllButton;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all categories.\n * @public\n */\nCategoriesTreeComponent.InvertAllButton = InvertAllButton;\n\n/**\n * Id of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].\n * @public\n */\nCategoriesTreeComponent.id = \"categories-tree\";\n\n/**\n * Label of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].\n * @public\n */\nCategoriesTreeComponent.getLabel = () => TreeWidget.translate(\"categories\");\n\nfunction CategoriesTreeComponentImpl(props: CategoriesTreeComponentProps & { iModel: IModelConnection, viewport: ScreenViewport }) {\n const categories = useCategories(IModelApp.viewManager, props.iModel, props.viewport);\n const [filteredCategories, setFilteredCategories] = useState<CategoryInfo[]>();\n const {\n searchOptions,\n filterString,\n onFilterApplied,\n filteredProvider,\n } = useTreeFilteringState();\n\n useEffect(() => {\n (async () => {\n if (filteredProvider)\n setFilteredCategories((await getFilteredCategories(filteredProvider)));\n else\n setFilteredCategories(undefined);\n })();\n }, [filteredProvider]);\n\n return (\n <div className=\"tree-widget-tree-with-header\">\n <TreeHeader\n onFilterClear={searchOptions.onFilterCancel}\n onFilterStart={searchOptions.onFilterStart}\n onSelectedChanged={searchOptions.onResultSelectedChanged}\n resultCount={searchOptions.matchedResultCount}\n selectedIndex={searchOptions.activeMatchIndex}\n >\n {props.headerButtons\n ? props.headerButtons.map(\n (btn, index) =>\n <Fragment key={index}>\n {btn({ viewport: props.viewport, categories, filteredCategories })}\n </Fragment>\n )\n : [\n <ShowAllButton viewport={props.viewport} categories={categories} filteredCategories={filteredCategories} key=\"show-all-btn\" />,\n <HideAllButton viewport={props.viewport} categories={categories} filteredCategories={filteredCategories} key=\"hide-all-btn\" />,\n <InvertAllButton viewport={props.viewport} categories={categories} filteredCategories={filteredCategories} key=\"invert-all-btn\" />,\n ]\n }\n </TreeHeader>\n <div className=\"tree-widget-tree-content\">\n <AutoSizer>\n {({ width, height }) => (\n <CategoryTree\n {...props}\n categories={categories}\n width={width}\n height={height}\n filterInfo={{ filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }}\n onFilterApplied={onFilterApplied}\n activeView={props.viewport}\n />\n )}\n </AutoSizer>\n </div>\n </div>\n );\n}\n\nasync function getFilteredCategories(filteredProvider: IPresentationTreeDataProvider) {\n const filteredCategories: CategoryInfo[] = [];\n const nodes = await filteredProvider.getNodes();\n for (const node of nodes) {\n if (!isPresentationTreeNodeItem(node)) {\n continue;\n }\n const filteredCategoryId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(node.key);\n const filteredSubCategoriesIds = node.hasChildren\n ? (await filteredProvider.getNodes(node)).filter(isPresentationTreeNodeItem).map((child) => CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(child.key))\n : [];\n filteredCategories.push({ categoryId: filteredCategoryId, subCategoryIds: filteredSubCategoriesIds });\n }\n return filteredCategories;\n}\n\nfunction ShowAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size=\"small\"\n styleType=\"borderless\"\n title={TreeWidget.translate(\"showAll\")}\n onClick={() => void showAllCategories((props.filteredCategories ?? props.categories).map((category) => category.categoryId), props.viewport)}\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\nfunction HideAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size=\"small\"\n styleType=\"borderless\"\n title={TreeWidget.translate(\"hideAll\")}\n onClick={() => void hideAllCategories((props.filteredCategories ?? props.categories).map((category) => category.categoryId), props.viewport)}\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\nfunction InvertAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n title={TreeWidget.translate(\"invert\")}\n size=\"small\"\n styleType=\"borderless\"\n onClick={() => void invertAllCategories(props.filteredCategories ?? props.categories, props.viewport)}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n"]}
1
+ {"version":3,"file":"CategoriesTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTreeComponent.tsx"],"names":[],"mappings":";;;;AAAA;;;+FAG+F;AAE/F,sCAAoC;AACpC,iCAAsD;AACtD,oDAAkF;AAClF,wDAAiD;AACjD,oEAAqG;AACrG,wDAAkD;AAClD,4EAA4E;AAC5E,oDAAiD;AACjD,6DAA0D;AAC1D,iEAAiE;AACjE,qDAAkD;AAClD,qDAAgD;AAChD,2EAAkJ;AAgDlJ;;;;GAIG;AACI,MAAM,uBAAuB,GAAG,CAAC,KAAmC,EAAE,EAAE;IAC7E,MAAM,MAAM,GAAG,IAAA,uCAAyB,GAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,IAAA,+BAAiB,GAAE,CAAC;IAErC,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE;QACxB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,uBAAC,2BAA2B,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAC/E,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,uBAAuB,2BAWlC;AAEF;;;GAGG;AACH,+BAAuB,CAAC,aAAa,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AAE,GAAG,EAAE,CAAC,KAAK,IAAA,6CAAiB,EAAC,CAAC,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,YAE5I,uBAAC,uCAAiB,KAAG,GACV,CACd,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,KAAsC;IAC7D,OAAO,CACL,uBAAC,0BAAU,IACT,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,EACrC,IAAI,EAAC,OAAO,EACZ,SAAS,EAAC,YAAY,EACtB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,IAAA,+CAAmB,EAAC,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,YAErG,uBAAC,uCAAiB,KAAG,GACV,CACd,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport { Fragment, useEffect, useState } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { IconButton } from \"@itwin/itwinui-react\";\nimport { isPresentationTreeNodeItem } from \"@itwin/presentation-components\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeHeader } from \"../../tree-header/TreeHeader\";\nimport { useTreeFilteringState } from \"../../TreeFilteringState\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { CategoryTree } from \"./CategoriesTree\";\nimport { CategoryVisibilityHandler, hideAllCategories, invertAllCategories, showAllCategories, useCategories } from \"./CategoryVisibilityHandler\";\n\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\nimport type { CategoryTreeProps } from \"./CategoriesTree\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\n\n/**\n * Props that get passed to [[CategoriesTreeComponent]] header button renderer.\n * @see CategoriesTreeComponentProps.headerButtons\n * @public\n */\nexport interface CategoriesTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of categories available in the iModel */\n categories: CategoryInfo[];\n /** In case the tree is filtered, a list of filtered categories. */\n filteredCategories?: CategoryInfo[];\n}\n\n/**\n * Props for [[CategoriesTreeComponent]].\n * @public\n */\nexport interface CategoriesTreeComponentProps extends Omit<CategoryTreeProps,\n| \"iModel\"\n| \"activeView\"\n| \"width\"\n| \"height\"\n| \"filterInfo\"\n| \"onFilterApplied\"\n| \"categories\"\n| \"categoryVisibilityHandler\"\n| \"viewManager\"\n> {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * CategoriesTreeComponent.ShowAllButton,\n * CategoriesTreeComponent.HideAllButton,\n * CategoriesTreeComponent.InvertAllButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: CategoriesTreeHeaderButtonProps) => React.ReactNode>;\n}\n\n/**\n * A component that renders [[CategoriesTree]] and a header with filtering capabilities\n * and header buttons.\n * @public\n */\nexport const CategoriesTreeComponent = (props: CategoriesTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return (\n <CategoriesTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />\n );\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all categories and their subcategories.\n * @public\n */\nCategoriesTreeComponent.ShowAllButton = ShowAllButton;\n\n/**\n * Renders a \"Hide all\" button that disables display of all categories.\n * @public\n */\nCategoriesTreeComponent.HideAllButton = HideAllButton;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all categories.\n * @public\n */\nCategoriesTreeComponent.InvertAllButton = InvertAllButton;\n\n/**\n * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nCategoriesTreeComponent.id = \"categories-tree\";\n\n/**\n * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nCategoriesTreeComponent.getLabel = () => TreeWidget.translate(\"categories\");\n\nfunction CategoriesTreeComponentImpl(props: CategoriesTreeComponentProps & { iModel: IModelConnection, viewport: ScreenViewport }) {\n const categories = useCategories(IModelApp.viewManager, props.iModel, props.viewport);\n const [filteredCategories, setFilteredCategories] = useState<CategoryInfo[]>();\n const {\n searchOptions,\n filterString,\n onFilterApplied,\n filteredProvider,\n } = useTreeFilteringState();\n\n useEffect(() => {\n (async () => {\n if (filteredProvider)\n setFilteredCategories((await getFilteredCategories(filteredProvider)));\n else\n setFilteredCategories(undefined);\n })();\n }, [filteredProvider]);\n\n return (\n <div className=\"tree-widget-tree-with-header\">\n <TreeHeader\n onFilterClear={searchOptions.onFilterCancel}\n onFilterStart={searchOptions.onFilterStart}\n onSelectedChanged={searchOptions.onResultSelectedChanged}\n resultCount={searchOptions.matchedResultCount}\n selectedIndex={searchOptions.activeMatchIndex}\n >\n {props.headerButtons\n ? props.headerButtons.map(\n (btn, index) =>\n <Fragment key={index}>\n {btn({ viewport: props.viewport, categories, filteredCategories })}\n </Fragment>\n )\n : [\n <ShowAllButton viewport={props.viewport} categories={categories} filteredCategories={filteredCategories} key=\"show-all-btn\" />,\n <HideAllButton viewport={props.viewport} categories={categories} filteredCategories={filteredCategories} key=\"hide-all-btn\" />,\n <InvertAllButton viewport={props.viewport} categories={categories} filteredCategories={filteredCategories} key=\"invert-all-btn\" />,\n ]\n }\n </TreeHeader>\n <div className=\"tree-widget-tree-content\">\n <AutoSizer>\n {({ width, height }) => (\n <CategoryTree\n {...props}\n categories={categories}\n width={width}\n height={height}\n filterInfo={{ filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }}\n onFilterApplied={onFilterApplied}\n activeView={props.viewport}\n />\n )}\n </AutoSizer>\n </div>\n </div>\n );\n}\n\nasync function getFilteredCategories(filteredProvider: IPresentationTreeDataProvider) {\n const filteredCategories: CategoryInfo[] = [];\n const nodes = await filteredProvider.getNodes();\n for (const node of nodes) {\n if (!isPresentationTreeNodeItem(node)) {\n continue;\n }\n const filteredCategoryId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(node.key);\n const filteredSubCategoriesIds = node.hasChildren\n ? (await filteredProvider.getNodes(node)).filter(isPresentationTreeNodeItem).map((child) => CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(child.key))\n : [];\n filteredCategories.push({ categoryId: filteredCategoryId, subCategoryIds: filteredSubCategoriesIds });\n }\n return filteredCategories;\n}\n\nfunction ShowAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size=\"small\"\n styleType=\"borderless\"\n title={TreeWidget.translate(\"showAll\")}\n onClick={() => void showAllCategories((props.filteredCategories ?? props.categories).map((category) => category.categoryId), props.viewport)}\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\nfunction HideAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size=\"small\"\n styleType=\"borderless\"\n title={TreeWidget.translate(\"hideAll\")}\n onClick={() => void hideAllCategories((props.filteredCategories ?? props.categories).map((category) => category.categoryId), props.viewport)}\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\nfunction InvertAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n title={TreeWidget.translate(\"invert\")}\n size=\"small\"\n styleType=\"borderless\"\n onClick={() => void invertAllCategories(props.filteredCategories ?? props.categories, props.viewport)}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import "../VisibilityTreeBase.scss";
3
- import type { IModelConnection } from "@itwin/core-frontend";
4
3
  import type { Ruleset } from "@itwin/presentation-common";
4
+ import type { BaseTreeProps } from "../Common";
5
5
  /**
6
6
  * Presentation rules used by ControlledCategoriesTree
7
7
  * @internal
@@ -11,14 +11,7 @@ export declare const RULESET_EXTERNAL_SOURCES: Ruleset;
11
11
  * Props for the [[ExternalSourcesTree]] component
12
12
  * @alpha
13
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
- }
14
+ export type ExternalSourcesTreeProps = BaseTreeProps;
22
15
  /**
23
16
  * Tree which displays a hierarchy of ExternalSources and their elements.
24
17
  * @alpha
@@ -52,7 +52,7 @@ function ExternalSourcesTree(props) {
52
52
  });
53
53
  const eventsHandler = (0, presentation_components_1.useUnifiedSelectionTreeEventHandler)({ nodeLoader });
54
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 }) }));
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: props.selectionMode ?? components_react_1.SelectionMode.Extended, eventsHandler: eventsHandler, width: props.width, height: props.height, iconsEnabled: true }) }));
56
56
  }
57
57
  exports.ExternalSourcesTree = ExternalSourcesTree;
58
58
  function customizeTreeNodeItem(item, node) {
@@ -1 +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"]}
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;AAQvB;;;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,KAAK,CAAC,aAAa,IAAI,gCAAa,CAAC,QAAQ,EAC5D,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 { Node, Ruleset } from \"@itwin/presentation-common\";\nimport type { BaseTreeProps } from \"../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 type ExternalSourcesTreeProps = BaseTreeProps;\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={props.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"]}
@@ -1,26 +1,16 @@
1
1
  /// <reference types="react" />
2
- import { SelectionMode } from "@itwin/components-react";
3
- import type { IModelConnection } from "@itwin/core-frontend";
4
2
  import type { Ruleset } from "@itwin/presentation-common";
3
+ import type { BaseTreeProps } from "../Common";
5
4
  /**
6
5
  * Presentation rules used by IModelContentTree
7
6
  * @internal
8
7
  */
9
8
  export declare const RULESET_IMODEL_CONTENT: Ruleset;
10
9
  /**
11
- * Props for [[IModelContentTree]]
10
+ * Props for [[IModelContentTree]].
12
11
  * @public
13
12
  */
14
- export interface IModelContentTreeProps extends Omit<React.HTMLProps<HTMLDivElement>, "children"> {
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
- /** Selection mode in the tree */
22
- selectionMode?: SelectionMode;
23
- }
13
+ export type IModelContentTreeProps = BaseTreeProps;
24
14
  /**
25
15
  * A tree that shows all iModel content starting from the root Subject, then the hierarchy of child
26
16
  * Subjects, their Models and Elements contained in those Models.
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.IModelContentTree = exports.RULESET_IMODEL_CONTENT = void 0;
7
4
  const jsx_runtime_1 = require("react/jsx-runtime");
@@ -9,7 +6,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
9
6
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
10
7
  * See LICENSE.md in the project root for license terms and full copyright notice.
11
8
  *--------------------------------------------------------------------------------------------*/
12
- const classnames_1 = __importDefault(require("classnames"));
13
9
  const react_1 = require("react");
14
10
  const components_react_1 = require("@itwin/components-react");
15
11
  const presentation_components_1 = require("@itwin/presentation-components");
@@ -24,7 +20,7 @@ exports.RULESET_IMODEL_CONTENT = require("./IModelContent.json"); // eslint-disa
24
20
  * @public
25
21
  */
26
22
  const IModelContentTree = (props) => {
27
- const { iModel, className, width, height, ...divProps } = props;
23
+ const { iModel, width, height, selectionMode } = props;
28
24
  const { nodeLoader } = (0, presentation_components_1.usePresentationTreeNodeLoader)({
29
25
  imodel: iModel,
30
26
  ruleset: exports.RULESET_IMODEL_CONTENT,
@@ -33,7 +29,7 @@ const IModelContentTree = (props) => {
33
29
  });
34
30
  const eventHandler = (0, components_react_1.useTreeEventsHandler)((0, react_1.useMemo)(() => ({ nodeLoader, modelSource: nodeLoader.modelSource }), [nodeLoader]));
35
31
  const treeModel = (0, components_react_1.useTreeModel)(nodeLoader.modelSource);
36
- return ((0, jsx_runtime_1.jsx)("div", { ...divProps, className: (0, classnames_1.default)("imodel-content-tree", className), children: (0, jsx_runtime_1.jsx)(components_react_1.ControlledTree, { width: width, height: height, nodeLoader: nodeLoader, selectionMode: props.selectionMode ? /* istanbul ignore next */ props.selectionMode : components_react_1.SelectionMode.None, eventsHandler: eventHandler, model: treeModel, iconsEnabled: true }) }));
32
+ return ((0, jsx_runtime_1.jsx)("div", { className: "imodel-content-tree", children: (0, jsx_runtime_1.jsx)(components_react_1.ControlledTree, { width: width, height: height, nodeLoader: nodeLoader, selectionMode: selectionMode ?? components_react_1.SelectionMode.None, eventsHandler: eventHandler, model: treeModel, iconsEnabled: true }) }));
37
33
  };
38
34
  exports.IModelContentTree = IModelContentTree;
39
35
  //# sourceMappingURL=IModelContentTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/imodel-content-tree/IModelContentTree.tsx"],"names":[],"mappings":";;;;;;;AAAA;;;+FAG+F;AAE/F,4DAAoC;AACpC,iCAAgC;AAChC,8DAA4G;AAC5G,4EAA+E;AAK/E;;;GAGG;AACU,QAAA,sBAAsB,GAAY,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,yDAAyD;AAiBzI;;;;GAIG;AACI,MAAM,iBAAiB,GAAG,CAAC,KAA6B,EAAE,EAAE;IACjE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,KAAK,CAAC;IAEhE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,uDAA6B,EAAC;QACnD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,8BAAsB;QAC/B,UAAU,EAAE,EAAE;QACd,mCAAmC,EAAE,IAAI;KAC1C,CAAC,CAAC;IACH,MAAM,YAAY,GAAG,IAAA,uCAAoB,EAAC,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAE9H,MAAM,SAAS,GAAG,IAAA,+BAAY,EAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAEvD,OAAO,CACL,mCAAS,QAAQ,EAAE,SAAS,EAAE,IAAA,oBAAU,EAAC,qBAAqB,EAAE,SAAS,CAAC,YACxE,uBAAC,iCAAc,IACb,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,0BAA0B,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,gCAAa,CAAC,IAAI,EACxG,aAAa,EAAE,YAAY,EAC3B,KAAK,EAAE,SAAS,EAChB,YAAY,EAAE,IAAI,GAClB,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AA1BW,QAAA,iBAAiB,qBA0B5B","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 classNames from \"classnames\";\nimport { useMemo } from \"react\";\nimport { ControlledTree, SelectionMode, useTreeEventsHandler, useTreeModel } from \"@itwin/components-react\";\nimport { usePresentationTreeNodeLoader } from \"@itwin/presentation-components\";\n\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\n\n/**\n * Presentation rules used by IModelContentTree\n * @internal\n */\nexport const RULESET_IMODEL_CONTENT: Ruleset = require(\"./IModelContent.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\n\n/**\n * Props for [[IModelContentTree]]\n * @public\n */\nexport interface IModelContentTreeProps extends Omit<React.HTMLProps<HTMLDivElement>, \"children\"> {\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 /** Selection mode in the tree */\n selectionMode?: SelectionMode;\n}\n\n/**\n * A tree that shows all iModel content starting from the root Subject, then the hierarchy of child\n * Subjects, their Models and Elements contained in those Models.\n * @public\n */\nexport const IModelContentTree = (props: IModelContentTreeProps) => {\n const { iModel, className, width, height, ...divProps } = props;\n\n const { nodeLoader } = usePresentationTreeNodeLoader({\n imodel: iModel,\n ruleset: RULESET_IMODEL_CONTENT,\n pagingSize: 20,\n appendChildrenCountForGroupingNodes: true,\n });\n const eventHandler = useTreeEventsHandler(useMemo(() => ({ nodeLoader, modelSource: nodeLoader.modelSource }), [nodeLoader]));\n\n const treeModel = useTreeModel(nodeLoader.modelSource);\n\n return (\n <div {...divProps} className={classNames(\"imodel-content-tree\", className)}>\n <ControlledTree\n width={width}\n height={height}\n nodeLoader={nodeLoader}\n selectionMode={props.selectionMode ? /* istanbul ignore next */ props.selectionMode : SelectionMode.None}\n eventsHandler={eventHandler}\n model={treeModel}\n iconsEnabled={true}\n />\n </div>\n );\n};\n"]}
1
+ {"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/imodel-content-tree/IModelContentTree.tsx"],"names":[],"mappings":";;;;AAAA;;;+FAG+F;AAE/F,iCAAgC;AAChC,8DAA4G;AAC5G,4EAA+E;AAK/E;;;GAGG;AACU,QAAA,sBAAsB,GAAY,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,yDAAyD;AAQzI;;;;GAIG;AACI,MAAM,iBAAiB,GAAG,CAAC,KAA6B,EAAE,EAAE;IACjE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;IAEvD,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,uDAA6B,EAAC;QACnD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,8BAAsB;QAC/B,UAAU,EAAE,EAAE;QACd,mCAAmC,EAAE,IAAI;KAC1C,CAAC,CAAC;IACH,MAAM,YAAY,GAAG,IAAA,uCAAoB,EAAC,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAE9H,MAAM,SAAS,GAAG,IAAA,+BAAY,EAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAEvD,OAAO,CACL,gCAAK,SAAS,EAAC,qBAAqB,YAClC,uBAAC,iCAAc,IACb,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,IAAI,gCAAa,CAAC,IAAI,EAClD,aAAa,EAAE,YAAY,EAC3B,KAAK,EAAE,SAAS,EAChB,YAAY,EAAE,IAAI,GAClB,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AA1BW,QAAA,iBAAiB,qBA0B5B","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 { ControlledTree, SelectionMode, useTreeEventsHandler, useTreeModel } from \"@itwin/components-react\";\nimport { usePresentationTreeNodeLoader } from \"@itwin/presentation-components\";\n\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { BaseTreeProps } from \"../Common\";\n\n/**\n * Presentation rules used by IModelContentTree\n * @internal\n */\nexport const RULESET_IMODEL_CONTENT: Ruleset = require(\"./IModelContent.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\n\n/**\n * Props for [[IModelContentTree]].\n * @public\n */\nexport type IModelContentTreeProps = BaseTreeProps;\n\n/**\n * A tree that shows all iModel content starting from the root Subject, then the hierarchy of child\n * Subjects, their Models and Elements contained in those Models.\n * @public\n */\nexport const IModelContentTree = (props: IModelContentTreeProps) => {\n const { iModel, width, height, selectionMode } = props;\n\n const { nodeLoader } = usePresentationTreeNodeLoader({\n imodel: iModel,\n ruleset: RULESET_IMODEL_CONTENT,\n pagingSize: 20,\n appendChildrenCountForGroupingNodes: true,\n });\n const eventHandler = useTreeEventsHandler(useMemo(() => ({ nodeLoader, modelSource: nodeLoader.modelSource }), [nodeLoader]));\n\n const treeModel = useTreeModel(nodeLoader.modelSource);\n\n return (\n <div className=\"imodel-content-tree\">\n <ControlledTree\n width={width}\n height={height}\n nodeLoader={nodeLoader}\n selectionMode={selectionMode ?? SelectionMode.None}\n eventsHandler={eventHandler}\n model={treeModel}\n iconsEnabled={true}\n />\n </div>\n );\n};\n"]}
@@ -13,12 +13,12 @@ export type IModelContentTreeComponentProps = Omit<IModelContentTreeProps, "iMod
13
13
  export declare const IModelContentTreeComponent: {
14
14
  (props: IModelContentTreeComponentProps): JSX.Element | null;
15
15
  /**
16
- * Id of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].
16
+ * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].
17
17
  * @public
18
18
  */
19
19
  id: string;
20
20
  /**
21
- * Label of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].
21
+ * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].
22
22
  * @public
23
23
  */
24
24
  getLabel(): string;
@@ -23,12 +23,12 @@ const IModelContentTreeComponent = (props) => {
23
23
  };
24
24
  exports.IModelContentTreeComponent = IModelContentTreeComponent;
25
25
  /**
26
- * Id of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].
26
+ * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].
27
27
  * @public
28
28
  */
29
29
  exports.IModelContentTreeComponent.id = "imodel-content-tree";
30
30
  /**
31
- * Label of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].
31
+ * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].
32
32
  * @public
33
33
  */
34
34
  exports.IModelContentTreeComponent.getLabel = () => TreeWidget_1.TreeWidget.translate("imodelContent");
@@ -1 +1 @@
1
- {"version":3,"file":"IModelContentTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/imodel-content-tree/IModelContentTreeComponent.tsx"],"names":[],"mappings":";;;;AAAA;;;+FAG+F;AAE/F,sCAAoC;AACpC,oDAA+D;AAC/D,oDAAiD;AACjD,qDAAkD;AAClD,2DAAwD;AAUxD;;;GAGG;AACI,MAAM,0BAA0B,GAAG,CAAC,KAAsC,EAAE,EAAE;IACnF,MAAM,MAAM,GAAG,IAAA,uCAAyB,GAAE,CAAC;IAE3C,IAAI,CAAC,MAAM;QACT,OAAO,IAAI,CAAC;IAEd,OAAO,CACL,uBAAC,qBAAS,cACP,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CACtB,uBAAC,qCAAiB,OACZ,KAAK,EACT,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,GACd,CACH,GACS,CACb,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,0BAA0B,8BAkBrC;AAEF;;;GAGG;AACH,kCAA0B,CAAC,EAAE,GAAG,qBAAqB,CAAC;AAEtD;;;GAGG;AACH,kCAA0B,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,uBAAU,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { IModelContentTree } from \"./IModelContentTree\";\n\nimport type { IModelContentTreeProps } from \"./IModelContentTree\";\n\n/**\n * Props for [[IModelContentTreeComponent]].\n * @public\n */\nexport type IModelContentTreeComponentProps = Omit<IModelContentTreeProps, \"iModel\" | \"width\" | \"height\">;\n\n/**\n * A component that renders [[IModelContentTree]]\n * @public\n */\nexport const IModelContentTreeComponent = (props: IModelContentTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n\n if (!iModel)\n return null;\n\n return (\n <AutoSizer>\n {({ width, height }) => (\n <IModelContentTree\n {...props}\n iModel={iModel}\n width={width}\n height={height}\n />\n )}\n </AutoSizer>\n );\n};\n\n/**\n * Id of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].\n * @public\n */\nIModelContentTreeComponent.id = \"imodel-content-tree\";\n\n/**\n * Label of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].\n * @public\n */\nIModelContentTreeComponent.getLabel = () => TreeWidget.translate(\"imodelContent\");\n"]}
1
+ {"version":3,"file":"IModelContentTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/imodel-content-tree/IModelContentTreeComponent.tsx"],"names":[],"mappings":";;;;AAAA;;;+FAG+F;AAE/F,sCAAoC;AACpC,oDAA+D;AAC/D,oDAAiD;AACjD,qDAAkD;AAClD,2DAAwD;AAUxD;;;GAGG;AACI,MAAM,0BAA0B,GAAG,CAAC,KAAsC,EAAE,EAAE;IACnF,MAAM,MAAM,GAAG,IAAA,uCAAyB,GAAE,CAAC;IAE3C,IAAI,CAAC,MAAM;QACT,OAAO,IAAI,CAAC;IAEd,OAAO,CACL,uBAAC,qBAAS,cACP,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CACtB,uBAAC,qCAAiB,OACZ,KAAK,EACT,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,GACd,CACH,GACS,CACb,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,0BAA0B,8BAkBrC;AAEF;;;GAGG;AACH,kCAA0B,CAAC,EAAE,GAAG,qBAAqB,CAAC;AAEtD;;;GAGG;AACH,kCAA0B,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,uBAAU,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { IModelContentTree } from \"./IModelContentTree\";\n\nimport type { IModelContentTreeProps } from \"./IModelContentTree\";\n\n/**\n * Props for [[IModelContentTreeComponent]].\n * @public\n */\nexport type IModelContentTreeComponentProps = Omit<IModelContentTreeProps, \"iModel\" | \"width\" | \"height\">;\n\n/**\n * A component that renders [[IModelContentTree]]\n * @public\n */\nexport const IModelContentTreeComponent = (props: IModelContentTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n\n if (!iModel)\n return null;\n\n return (\n <AutoSizer>\n {({ width, height }) => (\n <IModelContentTree\n {...props}\n iModel={iModel}\n width={width}\n height={height}\n />\n )}\n </AutoSizer>\n );\n};\n\n/**\n * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nIModelContentTreeComponent.id = \"imodel-content-tree\";\n\n/**\n * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nIModelContentTreeComponent.getLabel = () => TreeWidget.translate(\"imodelContent\");\n"]}
@@ -1,12 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import "../VisibilityTreeBase.scss";
3
- import { SelectionMode } from "@itwin/components-react";
4
3
  import { ClassGroupingOption } from "../Common";
5
4
  import { ModelsVisibilityHandler } from "./ModelsVisibilityHandler";
6
- import type { IModelConnection, Viewport } from "@itwin/core-frontend";
5
+ import type { Viewport } from "@itwin/core-frontend";
7
6
  import type { SingleSchemaClassSpecification } from "@itwin/presentation-common";
8
- import type { IPresentationTreeDataProvider } from "@itwin/presentation-components";
9
- import type { VisibilityTreeFilterInfo } from "../Common";
7
+ import type { BaseFilterableTreeProps } from "../Common";
10
8
  import type { ModelsTreeSelectionPredicate } from "./ModelsVisibilityHandler";
11
9
  /**
12
10
  * Props for configuring the hierarchy in [[ModelsTree]].
@@ -25,19 +23,7 @@ export interface ModelsTreeHierarchyConfiguration {
25
23
  * Props for [[ModelsTree]] component
26
24
  * @public
27
25
  */
28
- export interface ModelsTreeProps {
29
- /**
30
- * An IModel to pull data from
31
- */
32
- iModel: IModelConnection;
33
- /** Width of the component */
34
- width: number;
35
- /** Height of the component */
36
- height: number;
37
- /**
38
- * Selection mode in the tree
39
- */
40
- selectionMode?: SelectionMode;
26
+ export interface ModelsTreeProps extends BaseFilterableTreeProps {
41
27
  /**
42
28
  * Predicate which indicates whether node can be selected or no
43
29
  */
@@ -46,18 +32,6 @@ export interface ModelsTreeProps {
46
32
  * Active view used to determine and control visibility
47
33
  */
48
34
  activeView: Viewport;
49
- /**
50
- * Ref to the root HTML element used by this component
51
- */
52
- rootElementRef?: React.Ref<HTMLDivElement>;
53
- /**
54
- * Information for tree filtering.
55
- */
56
- filterInfo?: VisibilityTreeFilterInfo;
57
- /**
58
- * Callback invoked when tree is filtered.
59
- */
60
- onFilterApplied?: (filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void;
61
35
  /**
62
36
  * Configuration options for the hierarchy loaded in the component.
63
37
  */
@@ -36,13 +36,20 @@ function ModelsTree(props) {
36
36
  selectionPredicate: (node) => !selectionPredicate || !(0, presentation_components_1.isPresentationTreeNodeItem)(node) ? true : selectionPredicate(node.key, ModelsVisibilityHandler_1.ModelsVisibilityHandler.getNodeType(node)),
37
37
  }), [filteredNodeLoader, visibilityHandler, selectionPredicate]));
38
38
  const treeModel = (0, components_react_1.useTreeModel)(filteredNodeLoader.modelSource);
39
- const treeRenderer = (0, VisibilityTreeRenderer_1.createVisibilityTreeRenderer)({ iconsEnabled: true, descriptionEnabled: false, levelOffset: 10, disableRootNodeCollapse: true });
39
+ const treeRenderer = (0, VisibilityTreeRenderer_1.createVisibilityTreeRenderer)({
40
+ nodeRendererProps: {
41
+ iconsEnabled: true,
42
+ descriptionEnabled: false,
43
+ levelOffset: 10,
44
+ disableRootNodeCollapse: true,
45
+ },
46
+ });
40
47
  const overlay = isFiltering ? (0, jsx_runtime_1.jsx)("div", { className: "filteredTreeOverlay" }) : undefined;
41
48
  // istanbul ignore next
42
49
  const noFilteredDataRenderer = (0, react_1.useCallback)(() => {
43
50
  return (0, jsx_runtime_1.jsx)(VisibilityTreeRenderer_1.VisibilityTreeNoFilteredData, { title: TreeWidget_1.TreeWidget.translate("modelTree.noModelFound"), message: TreeWidget_1.TreeWidget.translate("modelTree.noMatchingModelNames") });
44
51
  }, []);
45
- return ((0, jsx_runtime_1.jsxs)("div", { className: "tree-widget-visibility-tree-base", ref: props.rootElementRef, children: [(0, jsx_runtime_1.jsx)(components_react_1.ControlledTree, { nodeLoader: filteredNodeLoader, model: treeModel, selectionMode: props.selectionMode || components_react_1.SelectionMode.None, eventsHandler: eventHandler, treeRenderer: treeRenderer, nodeHighlightingProps: nodeHighlightingProps, noDataRenderer: filterApplied ? noFilteredDataRenderer : undefined, onItemsRendered: onItemsRendered, width: props.width, height: props.height }), overlay] }));
52
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "tree-widget-visibility-tree-base", children: [(0, jsx_runtime_1.jsx)(components_react_1.ControlledTree, { nodeLoader: filteredNodeLoader, model: treeModel, selectionMode: props.selectionMode || components_react_1.SelectionMode.None, eventsHandler: eventHandler, treeRenderer: treeRenderer, nodeHighlightingProps: nodeHighlightingProps, noDataRenderer: filterApplied ? noFilteredDataRenderer : undefined, onItemsRendered: onItemsRendered, width: props.width, height: props.height }), overlay] }));
46
53
  }
47
54
  exports.ModelsTree = ModelsTree;
48
55
  function useModelsTreeNodeLoader(props) {
@@ -61,12 +68,14 @@ function useModelsTreeNodeLoader(props) {
61
68
  appendChildrenCountForGroupingNodes: (props.hierarchyConfig?.enableElementsClassGrouping === Common_1.ClassGroupingOption.YesWithCounts),
62
69
  pagingSize: PAGING_SIZE,
63
70
  enableHierarchyAutoUpdate: props.enableHierarchyAutoUpdate,
71
+ customizeTreeNodeItem: Utils_1.customizeModelsTreeNodeItem,
64
72
  });
65
73
  const { nodeLoader: searchNodeLoader, onItemsRendered: onSearchItemsRendered } = (0, presentation_components_1.usePresentationTreeNodeLoader)({
66
74
  imodel: props.iModel,
67
75
  ruleset: rulesets.search,
68
76
  pagingSize: PAGING_SIZE,
69
77
  enableHierarchyAutoUpdate: props.enableHierarchyAutoUpdate,
78
+ customizeTreeNodeItem: Utils_1.customizeModelsTreeNodeItem,
70
79
  });
71
80
  const activeNodeLoader = props.filterInfo?.filter ? searchNodeLoader : nodeLoader;
72
81
  const activeItemsRenderedCallback = props.filterInfo?.filter ? onSearchItemsRendered : onItemsRendered;
@@ -1 +1 @@
1
- {"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";;;;AAAA;;;+FAG+F;AAE/F,sCAAoC;AACpC,iCAAwD;AACxD,8DAAsF;AACtF,kDAAkD;AAClD,4EAA2G;AAC3G,oDAAiD;AACjD,sCAAgD;AAChD,8EAA2E;AAC3E,sEAAmI;AACnI,uEAA0F;AAC1F,mCAA6D;AAQ7D,MAAM,WAAW,GAAG,EAAE,CAAC;AAoEvB;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,KAAsB;IAC/C,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;IACvE,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,qBAAqB,EAAE,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,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEvF,MAAM,wBAAwB,GAAG,IAAA,0BAAa,EAAC,IAAA,mBAAW,EACxD,GAAG,EAAE,CACH,IAAI,iDAAuB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,CAAC,EACpH,CAAC,SAAS,EAAE,UAAU,EAAE,oBAAoB,EAAE,0BAA0B,CAAC,CAAC,CAC3E,CAAC;IAEF,MAAM,OAAO,GAAG,iBAAiB,IAAI,wBAAwB,CAAC;IAE9D,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,OAAO,IAAI,OAAO,CAAC,uBAAuB,CAAC,oBAAoB,CAAC,CAAC;IACnE,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC;IAEpC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,sBAAsB,GAAG,CAAC,YAAmF,EAAyD,EAAE;IAC5K,MAAM,gBAAgB,GAAG,YAAqD,CAAC;IAC/E,OAAO,gBAAgB,CAAC,iBAAiB,KAAK,SAAS,IAAI,gBAAgB,CAAC,cAAc,KAAK,SAAS,IAAI,gBAAgB,CAAC,qBAAqB,KAAK,SAAS,CAAC;AACnK,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAAC,YAAmF,EAAqD,EAAE;IACzK,OAAO,sBAAsB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;AACzE,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport { useCallback, useEffect, useMemo } from \"react\";\nimport { ControlledTree, SelectionMode, useTreeModel } from \"@itwin/components-react\";\nimport { useDisposable } from \"@itwin/core-react\";\nimport { isPresentationTreeNodeItem, usePresentationTreeNodeLoader } from \"@itwin/presentation-components\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { ClassGroupingOption } from \"../Common\";\nimport { VisibilityTreeEventHandler } from \"../VisibilityTreeEventHandler\";\nimport { createVisibilityTreeRenderer, useVisibilityTreeFiltering, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { ModelsVisibilityHandler, SubjectModelIdsCache } from \"./ModelsVisibilityHandler\";\nimport { createRuleset, createSearchRuleset } from \"./Utils\";\n\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport type { SingleSchemaClassSpecification } from \"@itwin/presentation-common\";\nimport type { IFilteredPresentationTreeDataProvider, IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { VisibilityTreeFilterInfo } from \"../Common\";\nimport type { ModelsTreeSelectionPredicate } from \"./ModelsVisibilityHandler\";\n\nconst PAGING_SIZE = 20;\n\n/**\n * Props for configuring the hierarchy in [[ModelsTree]].\n * @public\n */\nexport interface ModelsTreeHierarchyConfiguration {\n /** Should the tree group displayed element nodes by class. Defaults to `ClassGroupingOption.No`. */\n enableElementsClassGrouping?: ClassGroupingOption;\n /**\n * Defines the `bis.GeometricElement3d` sub-class that should be used to load element nodes.\n * Defaults to `bis.GeometricElement3d`. It's expected for the given class to derive from it.\n */\n elementClassSpecification?: SingleSchemaClassSpecification;\n}\n\n/**\n * Props for [[ModelsTree]] component\n * @public\n */\nexport interface ModelsTreeProps {\n /**\n * An IModel to pull data from\n */\n iModel: IModelConnection;\n /** Width of the component */\n width: number;\n /** Height of the component */\n height: number;\n /**\n * Selection mode in the tree\n */\n selectionMode?: SelectionMode;\n /**\n * Predicate which indicates whether node can be selected or no\n */\n selectionPredicate?: ModelsTreeSelectionPredicate;\n /**\n * Active view used to determine and control visibility\n */\n activeView: Viewport;\n /**\n * Ref to the root HTML element used by this component\n */\n rootElementRef?: React.Ref<HTMLDivElement>;\n /**\n * Information for tree filtering.\n */\n filterInfo?: VisibilityTreeFilterInfo;\n /**\n * Callback invoked when tree is filtered.\n */\n onFilterApplied?: (filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void;\n /**\n * Configuration options for the hierarchy loaded in the component.\n */\n hierarchyConfig?: ModelsTreeHierarchyConfiguration;\n /**\n * Auto-update the hierarchy when data in the iModel changes.\n * @alpha\n */\n enableHierarchyAutoUpdate?: boolean;\n /**\n * Custom visibility handler.\n */\n modelsVisibilityHandler?: ModelsVisibilityHandler;\n}\n\n/**\n * A tree component that shows a subject - model - category - element\n * hierarchy along with checkboxes that represent and allow changing\n * the display of those instances.\n * @public\n */\nexport function ModelsTree(props: ModelsTreeProps) {\n const { nodeLoader, onItemsRendered } = useModelsTreeNodeLoader(props);\n const { filteredNodeLoader, isFiltering, nodeHighlightingProps } = useVisibilityTreeFiltering(nodeLoader, props.filterInfo, props.onFilterApplied);\n const filterApplied = filteredNodeLoader !== nodeLoader;\n\n const { activeView, modelsVisibilityHandler, selectionPredicate } = props;\n\n const visibilityHandler = useVisibilityHandler(\n nodeLoader.dataProvider.rulesetId,\n props.iModel,\n activeView,\n modelsVisibilityHandler,\n getFilteredDataProvider(filteredNodeLoader.dataProvider),\n props.enableHierarchyAutoUpdate);\n const eventHandler = useDisposable(useCallback(() => new VisibilityTreeEventHandler({\n nodeLoader: filteredNodeLoader,\n visibilityHandler,\n selectionPredicate: (node) => !selectionPredicate || !isPresentationTreeNodeItem(node) ? true : selectionPredicate(node.key, ModelsVisibilityHandler.getNodeType(node)),\n }), [filteredNodeLoader, visibilityHandler, selectionPredicate]));\n\n const treeModel = useTreeModel(filteredNodeLoader.modelSource);\n const treeRenderer = createVisibilityTreeRenderer({ iconsEnabled: true, descriptionEnabled: false, levelOffset: 10, disableRootNodeCollapse: true });\n\n const overlay = isFiltering ? <div className=\"filteredTreeOverlay\" /> : undefined;\n\n // istanbul ignore next\n const noFilteredDataRenderer = useCallback(() => {\n return <VisibilityTreeNoFilteredData\n title={TreeWidget.translate(\"modelTree.noModelFound\")}\n message={TreeWidget.translate(\"modelTree.noMatchingModelNames\")}\n />;\n }, []);\n\n return (\n <div className=\"tree-widget-visibility-tree-base\" ref={props.rootElementRef}>\n <ControlledTree\n nodeLoader={filteredNodeLoader}\n model={treeModel}\n selectionMode={props.selectionMode || SelectionMode.None}\n eventsHandler={eventHandler}\n treeRenderer={treeRenderer}\n nodeHighlightingProps={nodeHighlightingProps}\n noDataRenderer={filterApplied ? noFilteredDataRenderer : undefined}\n onItemsRendered={onItemsRendered}\n width={props.width}\n height={props.height}\n />\n {overlay}\n </div>\n );\n}\n\nfunction useModelsTreeNodeLoader(props: ModelsTreeProps) {\n const rulesets = {\n general: useMemo(() => createRuleset({\n enableElementsClassGrouping: !!props.hierarchyConfig?.enableElementsClassGrouping,\n elementClassSpecification: props.hierarchyConfig?.elementClassSpecification,\n }), [props.hierarchyConfig?.enableElementsClassGrouping, props.hierarchyConfig?.elementClassSpecification]),\n search: useMemo(() => createSearchRuleset({\n elementClassSpecification: props.hierarchyConfig?.elementClassSpecification,\n }), [props.hierarchyConfig?.elementClassSpecification]),\n };\n\n const { nodeLoader, onItemsRendered } = usePresentationTreeNodeLoader({\n imodel: props.iModel,\n ruleset: rulesets.general,\n appendChildrenCountForGroupingNodes: (props.hierarchyConfig?.enableElementsClassGrouping === ClassGroupingOption.YesWithCounts),\n pagingSize: PAGING_SIZE,\n enableHierarchyAutoUpdate: props.enableHierarchyAutoUpdate,\n });\n const { nodeLoader: searchNodeLoader, onItemsRendered: onSearchItemsRendered } = usePresentationTreeNodeLoader({\n imodel: props.iModel,\n ruleset: rulesets.search,\n pagingSize: PAGING_SIZE,\n enableHierarchyAutoUpdate: props.enableHierarchyAutoUpdate,\n });\n\n const activeNodeLoader = props.filterInfo?.filter ? searchNodeLoader : nodeLoader;\n const activeItemsRenderedCallback = props.filterInfo?.filter ? onSearchItemsRendered : onItemsRendered;\n\n return {\n nodeLoader: activeNodeLoader,\n onItemsRendered: activeItemsRenderedCallback,\n };\n}\n\nfunction useVisibilityHandler(\n rulesetId: string,\n iModel: IModelConnection,\n activeView: Viewport,\n visibilityHandler?: ModelsVisibilityHandler,\n filteredDataProvider?: IFilteredPresentationTreeDataProvider,\n hierarchyAutoUpdateEnabled?: boolean,\n) {\n const subjectModelIdsCache = useMemo(() => new SubjectModelIdsCache(iModel), [iModel]);\n\n const defaultVisibilityHandler = useDisposable(useCallback(\n () =>\n new ModelsVisibilityHandler({ rulesetId, viewport: activeView, hierarchyAutoUpdateEnabled, subjectModelIdsCache }),\n [rulesetId, activeView, subjectModelIdsCache, hierarchyAutoUpdateEnabled])\n );\n\n const handler = visibilityHandler ?? defaultVisibilityHandler;\n\n useEffect(() => {\n handler && handler.setFilteredDataProvider(filteredDataProvider);\n }, [handler, filteredDataProvider]);\n\n return handler;\n}\n\nconst isFilteredDataProvider = (dataProvider: IPresentationTreeDataProvider | IFilteredPresentationTreeDataProvider): dataProvider is IFilteredPresentationTreeDataProvider => {\n const filteredProvider = dataProvider as IFilteredPresentationTreeDataProvider;\n return filteredProvider.nodeMatchesFilter !== undefined && filteredProvider.getActiveMatch !== undefined && filteredProvider.countFilteringResults !== undefined;\n};\n\nconst getFilteredDataProvider = (dataProvider: IPresentationTreeDataProvider | IFilteredPresentationTreeDataProvider): IFilteredPresentationTreeDataProvider | undefined => {\n return isFilteredDataProvider(dataProvider) ? dataProvider : undefined;\n};\n"]}
1
+ {"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";;;;AAAA;;;+FAG+F;AAE/F,sCAAoC;AACpC,iCAAwD;AACxD,8DAAsF;AACtF,kDAAkD;AAClD,4EAA2G;AAC3G,oDAAiD;AACjD,sCAAgD;AAChD,8EAA2E;AAC3E,sEAAmI;AACnI,uEAA0F;AAC1F,mCAA0F;AAQ1F,MAAM,WAAW,GAAG,EAAE,CAAC;AA4CvB;;;;;GAKG;AACH,SAAgB,UAAU,CA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ED,SAAS,oBAAoB,CAC3B,SAAiB,EACjB,MAAwB,EACxB,UAAoB,EACpB,iBAA2C,EAC3C,oBAA4D,EAC5D,0BAAoC;IAEpC,MAAM,oBAAoB,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,IAAI,8CAAoB,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEvF,MAAM,wBAAwB,GAAG,IAAA,0BAAa,EAAC,IAAA,mBAAW,EACxD,GAAG,EAAE,CACH,IAAI,iDAAuB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,CAAC,EACpH,CAAC,SAAS,EAAE,UAAU,EAAE,oBAAoB,EAAE,0BAA0B,CAAC,CAAC,CAC3E,CAAC;IAEF,MAAM,OAAO,GAAG,iBAAiB,IAAI,wBAAwB,CAAC;IAE9D,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,OAAO,IAAI,OAAO,CAAC,uBAAuB,CAAC,oBAAoB,CAAC,CAAC;IACnE,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC;IAEpC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,sBAAsB,GAAG,CAAC,YAAmF,EAAyD,EAAE;IAC5K,MAAM,gBAAgB,GAAG,YAAqD,CAAC;IAC/E,OAAO,gBAAgB,CAAC,iBAAiB,KAAK,SAAS,IAAI,gBAAgB,CAAC,cAAc,KAAK,SAAS,IAAI,gBAAgB,CAAC,qBAAqB,KAAK,SAAS,CAAC;AACnK,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAAC,YAAmF,EAAqD,EAAE;IACzK,OAAO,sBAAsB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;AACzE,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport { useCallback, useEffect, useMemo } from \"react\";\nimport { ControlledTree, SelectionMode, useTreeModel } from \"@itwin/components-react\";\nimport { useDisposable } from \"@itwin/core-react\";\nimport { isPresentationTreeNodeItem, usePresentationTreeNodeLoader } from \"@itwin/presentation-components\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { ClassGroupingOption } from \"../Common\";\nimport { VisibilityTreeEventHandler } from \"../VisibilityTreeEventHandler\";\nimport { createVisibilityTreeRenderer, useVisibilityTreeFiltering, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { ModelsVisibilityHandler, SubjectModelIdsCache } from \"./ModelsVisibilityHandler\";\nimport { createRuleset, createSearchRuleset, customizeModelsTreeNodeItem } from \"./Utils\";\n\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport type { SingleSchemaClassSpecification } from \"@itwin/presentation-common\";\nimport type { IFilteredPresentationTreeDataProvider, IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { BaseFilterableTreeProps } from \"../Common\";\nimport type { ModelsTreeSelectionPredicate } from \"./ModelsVisibilityHandler\";\n\nconst PAGING_SIZE = 20;\n\n/**\n * Props for configuring the hierarchy in [[ModelsTree]].\n * @public\n */\nexport interface ModelsTreeHierarchyConfiguration {\n /** Should the tree group displayed element nodes by class. Defaults to `ClassGroupingOption.No`. */\n enableElementsClassGrouping?: ClassGroupingOption;\n /**\n * Defines the `bis.GeometricElement3d` sub-class that should be used to load element nodes.\n * Defaults to `bis.GeometricElement3d`. It's expected for the given class to derive from it.\n */\n elementClassSpecification?: SingleSchemaClassSpecification;\n}\n\n/**\n * Props for [[ModelsTree]] component\n * @public\n */\nexport interface ModelsTreeProps extends BaseFilterableTreeProps {\n /**\n * Predicate which indicates whether node can be selected or no\n */\n selectionPredicate?: ModelsTreeSelectionPredicate;\n /**\n * Active view used to determine and control visibility\n */\n activeView: Viewport;\n /**\n * Configuration options for the hierarchy loaded in the component.\n */\n hierarchyConfig?: ModelsTreeHierarchyConfiguration;\n /**\n * Auto-update the hierarchy when data in the iModel changes.\n * @alpha\n */\n enableHierarchyAutoUpdate?: boolean;\n /**\n * Custom visibility handler.\n */\n modelsVisibilityHandler?: ModelsVisibilityHandler;\n}\n\n/**\n * A tree component that shows a subject - model - category - element\n * hierarchy along with checkboxes that represent and allow changing\n * the display of those instances.\n * @public\n */\nexport function ModelsTree(props: ModelsTreeProps) {\n const { nodeLoader, onItemsRendered } = useModelsTreeNodeLoader(props);\n const { filteredNodeLoader, isFiltering, nodeHighlightingProps } = useVisibilityTreeFiltering(nodeLoader, props.filterInfo, props.onFilterApplied);\n const filterApplied = filteredNodeLoader !== nodeLoader;\n\n const { activeView, modelsVisibilityHandler, selectionPredicate } = props;\n\n const visibilityHandler = useVisibilityHandler(\n nodeLoader.dataProvider.rulesetId,\n props.iModel,\n activeView,\n modelsVisibilityHandler,\n getFilteredDataProvider(filteredNodeLoader.dataProvider),\n props.enableHierarchyAutoUpdate);\n const eventHandler = useDisposable(useCallback(() => new VisibilityTreeEventHandler({\n nodeLoader: filteredNodeLoader,\n visibilityHandler,\n selectionPredicate: (node) => !selectionPredicate || !isPresentationTreeNodeItem(node) ? true : selectionPredicate(node.key, ModelsVisibilityHandler.getNodeType(node)),\n }), [filteredNodeLoader, visibilityHandler, selectionPredicate]));\n\n const treeModel = useTreeModel(filteredNodeLoader.modelSource);\n const treeRenderer = createVisibilityTreeRenderer({\n nodeRendererProps: {\n iconsEnabled: true,\n descriptionEnabled: false,\n levelOffset: 10,\n disableRootNodeCollapse: true,\n },\n });\n\n const overlay = isFiltering ? <div className=\"filteredTreeOverlay\" /> : undefined;\n\n // istanbul ignore next\n const noFilteredDataRenderer = useCallback(() => {\n return <VisibilityTreeNoFilteredData\n title={TreeWidget.translate(\"modelTree.noModelFound\")}\n message={TreeWidget.translate(\"modelTree.noMatchingModelNames\")}\n />;\n }, []);\n\n return (\n <div className=\"tree-widget-visibility-tree-base\">\n <ControlledTree\n nodeLoader={filteredNodeLoader}\n model={treeModel}\n selectionMode={props.selectionMode || SelectionMode.None}\n eventsHandler={eventHandler}\n treeRenderer={treeRenderer}\n nodeHighlightingProps={nodeHighlightingProps}\n noDataRenderer={filterApplied ? noFilteredDataRenderer : undefined}\n onItemsRendered={onItemsRendered}\n width={props.width}\n height={props.height}\n />\n {overlay}\n </div>\n );\n}\n\nfunction useModelsTreeNodeLoader(props: ModelsTreeProps) {\n const rulesets = {\n general: useMemo(() => createRuleset({\n enableElementsClassGrouping: !!props.hierarchyConfig?.enableElementsClassGrouping,\n elementClassSpecification: props.hierarchyConfig?.elementClassSpecification,\n }), [props.hierarchyConfig?.enableElementsClassGrouping, props.hierarchyConfig?.elementClassSpecification]),\n search: useMemo(() => createSearchRuleset({\n elementClassSpecification: props.hierarchyConfig?.elementClassSpecification,\n }), [props.hierarchyConfig?.elementClassSpecification]),\n };\n\n const { nodeLoader, onItemsRendered } = usePresentationTreeNodeLoader({\n imodel: props.iModel,\n ruleset: rulesets.general,\n appendChildrenCountForGroupingNodes: (props.hierarchyConfig?.enableElementsClassGrouping === ClassGroupingOption.YesWithCounts),\n pagingSize: PAGING_SIZE,\n enableHierarchyAutoUpdate: props.enableHierarchyAutoUpdate,\n customizeTreeNodeItem: customizeModelsTreeNodeItem,\n });\n const { nodeLoader: searchNodeLoader, onItemsRendered: onSearchItemsRendered } = usePresentationTreeNodeLoader({\n imodel: props.iModel,\n ruleset: rulesets.search,\n pagingSize: PAGING_SIZE,\n enableHierarchyAutoUpdate: props.enableHierarchyAutoUpdate,\n customizeTreeNodeItem: customizeModelsTreeNodeItem,\n });\n\n const activeNodeLoader = props.filterInfo?.filter ? searchNodeLoader : nodeLoader;\n const activeItemsRenderedCallback = props.filterInfo?.filter ? onSearchItemsRendered : onItemsRendered;\n\n return {\n nodeLoader: activeNodeLoader,\n onItemsRendered: activeItemsRenderedCallback,\n };\n}\n\nfunction useVisibilityHandler(\n rulesetId: string,\n iModel: IModelConnection,\n activeView: Viewport,\n visibilityHandler?: ModelsVisibilityHandler,\n filteredDataProvider?: IFilteredPresentationTreeDataProvider,\n hierarchyAutoUpdateEnabled?: boolean,\n) {\n const subjectModelIdsCache = useMemo(() => new SubjectModelIdsCache(iModel), [iModel]);\n\n const defaultVisibilityHandler = useDisposable(useCallback(\n () =>\n new ModelsVisibilityHandler({ rulesetId, viewport: activeView, hierarchyAutoUpdateEnabled, subjectModelIdsCache }),\n [rulesetId, activeView, subjectModelIdsCache, hierarchyAutoUpdateEnabled])\n );\n\n const handler = visibilityHandler ?? defaultVisibilityHandler;\n\n useEffect(() => {\n handler && handler.setFilteredDataProvider(filteredDataProvider);\n }, [handler, filteredDataProvider]);\n\n return handler;\n}\n\nconst isFilteredDataProvider = (dataProvider: IPresentationTreeDataProvider | IFilteredPresentationTreeDataProvider): dataProvider is IFilteredPresentationTreeDataProvider => {\n const filteredProvider = dataProvider as IFilteredPresentationTreeDataProvider;\n return filteredProvider.nodeMatchesFilter !== undefined && filteredProvider.getActiveMatch !== undefined && filteredProvider.countFilteringResults !== undefined;\n};\n\nconst getFilteredDataProvider = (dataProvider: IPresentationTreeDataProvider | IFilteredPresentationTreeDataProvider): IFilteredPresentationTreeDataProvider | undefined => {\n return isFilteredDataProvider(dataProvider) ? dataProvider : undefined;\n};\n"]}
@@ -71,12 +71,12 @@ export declare const ModelsTreeComponent: {
71
71
  */
72
72
  View3DButton: typeof View3DButton;
73
73
  /**
74
- * Id of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].
74
+ * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].
75
75
  * @public
76
76
  */
77
77
  id: string;
78
78
  /**
79
- * Label of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].
79
+ * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].
80
80
  * @public
81
81
  */
82
82
  getLabel(): string;
@@ -56,12 +56,12 @@ exports.ModelsTreeComponent.View2DButton = View2DButton;
56
56
  */
57
57
  exports.ModelsTreeComponent.View3DButton = View3DButton;
58
58
  /**
59
- * Id of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].
59
+ * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].
60
60
  * @public
61
61
  */
62
62
  exports.ModelsTreeComponent.id = "models-tree";
63
63
  /**
64
- * Label of the component. May be used when a creating a [[TreeDefinition]] for [[TreeWidgetComponent]].
64
+ * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].
65
65
  * @public
66
66
  */
67
67
  exports.ModelsTreeComponent.getLabel = () => TreeWidget_1.TreeWidget.translate("models");