@itwin/tree-widget-react 2.3.2 → 3.0.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/README.md +232 -147
- package/lib/cjs/TreeWidget.d.ts +2 -4
- package/lib/cjs/TreeWidget.js +0 -6
- package/lib/cjs/TreeWidget.js.map +1 -1
- package/lib/cjs/components/SelectableTree.d.ts +3 -9
- package/lib/cjs/components/SelectableTree.js +1 -1
- package/lib/cjs/components/SelectableTree.js.map +1 -1
- package/lib/cjs/components/TreeSelector.d.ts +2 -2
- package/lib/cjs/components/TreeSelector.js.map +1 -1
- package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +14 -25
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js +43 -45
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/cjs/components/tree-header/TreeHeader.js +17 -9
- package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/cjs/components/tree-header/TreeHeader.scss +7 -41
- package/lib/cjs/components/trees/Tree.scss +23 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesTree.d.ts +22 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesTree.js +78 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesTree.js.map +1 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.d.ts +21 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.js +37 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.d.ts +55 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js +75 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +23 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.js +185 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesVisibilityHandler.d.ts +36 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesVisibilityHandler.js +94 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesVisibilityHandler.js.map +1 -0
- package/lib/cjs/components/trees/categories-tree/UseCategories.d.ts +8 -0
- package/lib/cjs/components/trees/categories-tree/UseCategories.js +22 -0
- package/lib/cjs/components/trees/categories-tree/UseCategories.js.map +1 -0
- package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.d.ts +46 -0
- package/lib/cjs/components/trees/{CategoriesVisibilityUtils.js → common/CategoriesVisibilityUtils.js} +56 -8
- package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.js.map +1 -0
- package/lib/cjs/components/trees/common/FocusedInstancesContext.d.ts +14 -0
- package/lib/cjs/components/trees/common/FocusedInstancesContext.js +16 -0
- package/lib/cjs/components/trees/common/FocusedInstancesContext.js.map +1 -0
- package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.d.ts +8 -0
- package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js +71 -0
- package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js.map +1 -0
- package/lib/cjs/components/trees/common/Rxjs.d.ts +10 -0
- package/lib/cjs/components/trees/common/Rxjs.js +46 -0
- package/lib/cjs/components/trees/common/Rxjs.js.map +1 -0
- package/lib/cjs/components/trees/common/UseFeatureReporting.d.ts +11 -0
- package/lib/cjs/components/trees/common/UseFeatureReporting.js +10 -1
- package/lib/cjs/components/trees/common/UseFeatureReporting.js.map +1 -1
- package/lib/cjs/components/trees/common/UseFiltering.d.ts +12 -0
- package/lib/cjs/components/trees/common/UseFiltering.js +29 -0
- package/lib/cjs/components/trees/common/UseFiltering.js.map +1 -0
- package/lib/cjs/components/trees/common/UseHierarchiesLocalization.d.ts +8 -0
- package/lib/cjs/components/trees/common/UseHierarchiesLocalization.js +33 -0
- package/lib/cjs/components/trees/common/UseHierarchiesLocalization.js.map +1 -0
- package/lib/cjs/components/trees/common/UseHierarchyFiltering.d.ts +19 -0
- package/lib/cjs/components/trees/common/UseHierarchyFiltering.js +157 -0
- package/lib/cjs/components/trees/common/UseHierarchyFiltering.js.map +1 -0
- package/lib/cjs/components/trees/common/UseHierarchyVisibility.d.ts +30 -0
- package/lib/cjs/components/trees/common/UseHierarchyVisibility.js +98 -0
- package/lib/cjs/components/trees/common/UseHierarchyVisibility.js.map +1 -0
- package/lib/cjs/components/trees/common/UseIModelChangeListener.d.ts +9 -0
- package/lib/cjs/components/trees/common/UseIModelChangeListener.js +20 -0
- package/lib/cjs/components/trees/common/UseIModelChangeListener.js.map +1 -0
- package/lib/cjs/components/trees/common/UseMultiCheckboxHandler.d.ts +13 -0
- package/lib/cjs/components/trees/common/UseMultiCheckboxHandler.js +35 -0
- package/lib/cjs/components/trees/common/UseMultiCheckboxHandler.js.map +1 -0
- package/lib/cjs/components/trees/common/UseNodeHighlighting.d.ts +16 -0
- package/lib/cjs/components/trees/common/UseNodeHighlighting.js +140 -0
- package/lib/cjs/components/trees/common/UseNodeHighlighting.js.map +1 -0
- package/lib/cjs/components/trees/common/Utils.d.ts +16 -6
- package/lib/cjs/components/trees/common/Utils.js +38 -34
- package/lib/cjs/components/trees/common/Utils.js.map +1 -1
- package/lib/cjs/components/trees/common/components/BaseTree.d.ts +34 -0
- package/lib/cjs/components/trees/common/components/BaseTree.js +77 -0
- package/lib/cjs/components/trees/common/components/BaseTree.js.map +1 -0
- package/lib/cjs/components/trees/common/components/Delayed.d.ts +6 -0
- package/lib/cjs/components/trees/common/components/Delayed.js +31 -0
- package/lib/cjs/components/trees/common/components/Delayed.js.map +1 -0
- package/lib/cjs/components/trees/common/components/ProgressOverlay.d.ts +5 -0
- package/lib/cjs/components/trees/common/components/ProgressOverlay.js +16 -0
- package/lib/cjs/components/trees/common/components/ProgressOverlay.js.map +1 -0
- package/lib/cjs/components/trees/common/components/ProgressOverlay.scss +21 -0
- package/lib/cjs/components/trees/common/components/TreeNodeCheckbox.d.ts +20 -0
- package/lib/cjs/components/trees/common/components/TreeNodeCheckbox.js +28 -0
- package/lib/cjs/components/trees/common/components/TreeNodeCheckbox.js.map +1 -0
- package/lib/cjs/components/trees/common/components/TreeNodeRenderer.d.ts +13 -0
- package/lib/cjs/components/trees/common/components/TreeNodeRenderer.js +20 -0
- package/lib/cjs/components/trees/common/components/TreeNodeRenderer.js.map +1 -0
- package/lib/cjs/components/trees/common/components/TreeRenderer.d.ts +19 -0
- package/lib/cjs/components/trees/common/components/TreeRenderer.js +30 -0
- package/lib/cjs/components/trees/common/components/TreeRenderer.js.map +1 -0
- package/lib/cjs/components/trees/common/components/TreeRenderer.scss +62 -0
- package/lib/cjs/components/trees/common/components/VisibilityTree.d.ts +14 -0
- package/lib/cjs/components/trees/common/components/VisibilityTree.js +41 -0
- package/lib/cjs/components/trees/common/components/VisibilityTree.js.map +1 -0
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +11 -35
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +29 -83
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +14 -14
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +12 -12
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.d.ts +24 -0
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js +262 -0
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js.map +1 -0
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +11 -35
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +41 -79
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +14 -14
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js +12 -12
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeDefinition.d.ts +28 -0
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +619 -0
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -0
- package/lib/cjs/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.d.ts +26 -0
- package/lib/cjs/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js +203 -0
- package/lib/cjs/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js.map +1 -0
- package/lib/cjs/components/trees/index.d.ts +4 -16
- package/lib/cjs/components/trees/index.js +9 -30
- package/lib/cjs/components/trees/index.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +17 -72
- package/lib/cjs/components/trees/models-tree/ModelsTree.js +196 -135
- package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.d.ts +33 -0
- package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.js +101 -0
- package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.js.map +1 -0
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.d.ts +14 -35
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +40 -83
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.d.ts +67 -0
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.js +617 -0
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -0
- package/lib/cjs/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.d.ts +24 -0
- package/lib/cjs/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js +121 -0
- package/lib/cjs/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -0
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +44 -0
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeIdsCache.js +325 -0
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -0
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeNode.d.ts +31 -0
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeNode.js +40 -0
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeNode.js.map +1 -0
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +122 -0
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +757 -0
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -0
- package/lib/cjs/components/trees/models-tree/internal/Tooltip.d.ts +13 -0
- package/lib/cjs/components/trees/models-tree/internal/Tooltip.js +29 -0
- package/lib/cjs/components/trees/models-tree/internal/Tooltip.js.map +1 -0
- package/lib/cjs/components/trees/models-tree/internal/VisibilityChangeEventListener.d.ts +10 -0
- package/lib/cjs/components/trees/models-tree/internal/VisibilityChangeEventListener.js +43 -0
- package/lib/cjs/components/trees/models-tree/internal/VisibilityChangeEventListener.js.map +1 -0
- package/lib/cjs/tree-widget-react.d.ts +3 -4
- package/lib/cjs/tree-widget-react.js +8 -4
- package/lib/cjs/tree-widget-react.js.map +1 -1
- package/lib/esm/TreeWidget.d.ts +2 -4
- package/lib/esm/TreeWidget.js +0 -6
- package/lib/esm/TreeWidget.js.map +1 -1
- package/lib/esm/components/SelectableTree.d.ts +3 -9
- package/lib/esm/components/SelectableTree.js +1 -1
- package/lib/esm/components/SelectableTree.js.map +1 -1
- package/lib/esm/components/TreeSelector.d.ts +2 -2
- package/lib/esm/components/TreeSelector.js.map +1 -1
- package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +14 -25
- package/lib/esm/components/TreeWidgetUiItemsProvider.js +42 -44
- package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/components/tree-header/TreeHeader.js +17 -9
- package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/esm/components/tree-header/TreeHeader.scss +7 -41
- package/lib/esm/components/trees/Tree.scss +23 -0
- package/lib/esm/components/trees/categories-tree/CategoriesTree.d.ts +22 -0
- package/lib/esm/components/trees/categories-tree/CategoriesTree.js +74 -0
- package/lib/esm/components/trees/categories-tree/CategoriesTree.js.map +1 -0
- package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.d.ts +21 -0
- package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.js +31 -0
- package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -0
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.d.ts +55 -0
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js +68 -0
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -0
- package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +23 -0
- package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.js +181 -0
- package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -0
- package/lib/esm/components/trees/categories-tree/CategoriesVisibilityHandler.d.ts +36 -0
- package/lib/esm/components/trees/categories-tree/CategoriesVisibilityHandler.js +90 -0
- package/lib/esm/components/trees/categories-tree/CategoriesVisibilityHandler.js.map +1 -0
- package/lib/esm/components/trees/categories-tree/UseCategories.d.ts +8 -0
- package/lib/esm/components/trees/categories-tree/UseCategories.js +18 -0
- package/lib/esm/components/trees/categories-tree/UseCategories.js.map +1 -0
- package/lib/esm/components/trees/common/CategoriesVisibilityUtils.d.ts +46 -0
- package/lib/esm/components/trees/{CategoriesVisibilityUtils.js → common/CategoriesVisibilityUtils.js} +51 -6
- package/lib/esm/components/trees/common/CategoriesVisibilityUtils.js.map +1 -0
- package/lib/esm/components/trees/common/FocusedInstancesContext.d.ts +14 -0
- package/lib/esm/components/trees/common/FocusedInstancesContext.js +12 -0
- package/lib/esm/components/trees/common/FocusedInstancesContext.js.map +1 -0
- package/lib/esm/components/trees/common/FocusedInstancesContextProvider.d.ts +8 -0
- package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js +67 -0
- package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js.map +1 -0
- package/lib/esm/components/trees/common/Rxjs.d.ts +10 -0
- package/lib/esm/components/trees/common/Rxjs.js +40 -0
- package/lib/esm/components/trees/common/Rxjs.js.map +1 -0
- package/lib/esm/components/trees/common/UseFeatureReporting.d.ts +11 -0
- package/lib/esm/components/trees/common/UseFeatureReporting.js +8 -0
- package/lib/esm/components/trees/common/UseFeatureReporting.js.map +1 -1
- package/lib/esm/components/trees/common/UseFiltering.d.ts +12 -0
- package/lib/esm/components/trees/common/UseFiltering.js +25 -0
- package/lib/esm/components/trees/common/UseFiltering.js.map +1 -0
- package/lib/esm/components/trees/common/UseHierarchiesLocalization.d.ts +8 -0
- package/lib/esm/components/trees/common/UseHierarchiesLocalization.js +29 -0
- package/lib/esm/components/trees/common/UseHierarchiesLocalization.js.map +1 -0
- package/lib/esm/components/trees/common/UseHierarchyFiltering.d.ts +19 -0
- package/lib/esm/components/trees/common/UseHierarchyFiltering.js +153 -0
- package/lib/esm/components/trees/common/UseHierarchyFiltering.js.map +1 -0
- package/lib/esm/components/trees/common/UseHierarchyVisibility.d.ts +30 -0
- package/lib/esm/components/trees/common/UseHierarchyVisibility.js +94 -0
- package/lib/esm/components/trees/common/UseHierarchyVisibility.js.map +1 -0
- package/lib/esm/components/trees/common/UseIModelChangeListener.d.ts +9 -0
- package/lib/esm/components/trees/common/UseIModelChangeListener.js +16 -0
- package/lib/esm/components/trees/common/UseIModelChangeListener.js.map +1 -0
- package/lib/esm/components/trees/common/UseMultiCheckboxHandler.d.ts +13 -0
- package/lib/esm/components/trees/common/UseMultiCheckboxHandler.js +31 -0
- package/lib/esm/components/trees/common/UseMultiCheckboxHandler.js.map +1 -0
- package/lib/esm/components/trees/common/UseNodeHighlighting.d.ts +16 -0
- package/lib/esm/components/trees/common/UseNodeHighlighting.js +136 -0
- package/lib/esm/components/trees/common/UseNodeHighlighting.js.map +1 -0
- package/lib/esm/components/trees/common/Utils.d.ts +16 -6
- package/lib/esm/components/trees/common/Utils.js +33 -29
- package/lib/esm/components/trees/common/Utils.js.map +1 -1
- package/lib/esm/components/trees/common/components/BaseTree.d.ts +34 -0
- package/lib/esm/components/trees/common/components/BaseTree.js +73 -0
- package/lib/esm/components/trees/common/components/BaseTree.js.map +1 -0
- package/lib/esm/components/trees/common/components/Delayed.d.ts +6 -0
- package/lib/esm/components/trees/common/components/Delayed.js +27 -0
- package/lib/esm/components/trees/common/components/Delayed.js.map +1 -0
- package/lib/esm/components/trees/common/components/ProgressOverlay.d.ts +5 -0
- package/lib/esm/components/trees/common/components/ProgressOverlay.js +12 -0
- package/lib/esm/components/trees/common/components/ProgressOverlay.js.map +1 -0
- package/lib/esm/components/trees/common/components/ProgressOverlay.scss +21 -0
- package/lib/esm/components/trees/common/components/TreeNodeCheckbox.d.ts +20 -0
- package/lib/esm/components/trees/common/components/TreeNodeCheckbox.js +21 -0
- package/lib/esm/components/trees/common/components/TreeNodeCheckbox.js.map +1 -0
- package/lib/esm/components/trees/common/components/TreeNodeRenderer.d.ts +13 -0
- package/lib/esm/components/trees/common/components/TreeNodeRenderer.js +13 -0
- package/lib/esm/components/trees/common/components/TreeNodeRenderer.js.map +1 -0
- package/lib/esm/components/trees/common/components/TreeRenderer.d.ts +19 -0
- package/lib/esm/components/trees/common/components/TreeRenderer.js +26 -0
- package/lib/esm/components/trees/common/components/TreeRenderer.js.map +1 -0
- package/lib/esm/components/trees/common/components/TreeRenderer.scss +62 -0
- package/lib/esm/components/trees/common/components/VisibilityTree.d.ts +14 -0
- package/lib/esm/components/trees/common/components/VisibilityTree.js +37 -0
- package/lib/esm/components/trees/common/components/VisibilityTree.js.map +1 -0
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +11 -35
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +27 -58
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +14 -14
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +12 -12
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.d.ts +24 -0
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js +258 -0
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js.map +1 -0
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +11 -35
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +39 -54
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +14 -14
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js +12 -12
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeDefinition.d.ts +28 -0
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +615 -0
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -0
- package/lib/esm/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.d.ts +26 -0
- package/lib/esm/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js +199 -0
- package/lib/esm/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js.map +1 -0
- package/lib/esm/components/trees/index.d.ts +4 -16
- package/lib/esm/components/trees/index.js +4 -16
- package/lib/esm/components/trees/index.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +17 -72
- package/lib/esm/components/trees/models-tree/ModelsTree.js +196 -132
- package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeButtons.d.ts +33 -0
- package/lib/esm/components/trees/models-tree/ModelsTreeButtons.js +92 -0
- package/lib/esm/components/trees/models-tree/ModelsTreeButtons.js.map +1 -0
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.d.ts +14 -35
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +38 -81
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.d.ts +67 -0
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.js +613 -0
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -0
- package/lib/esm/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.d.ts +24 -0
- package/lib/esm/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js +117 -0
- package/lib/esm/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -0
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +44 -0
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeIdsCache.js +321 -0
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -0
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeNode.d.ts +31 -0
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeNode.js +37 -0
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeNode.js.map +1 -0
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +122 -0
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +748 -0
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -0
- package/lib/esm/components/trees/models-tree/internal/Tooltip.d.ts +13 -0
- package/lib/esm/components/trees/models-tree/internal/Tooltip.js +24 -0
- package/lib/esm/components/trees/models-tree/internal/Tooltip.js.map +1 -0
- package/lib/esm/components/trees/models-tree/internal/VisibilityChangeEventListener.d.ts +10 -0
- package/lib/esm/components/trees/models-tree/internal/VisibilityChangeEventListener.js +39 -0
- package/lib/esm/components/trees/models-tree/internal/VisibilityChangeEventListener.js.map +1 -0
- package/lib/esm/tree-widget-react.d.ts +3 -4
- package/lib/esm/tree-widget-react.js +3 -4
- package/lib/esm/tree-widget-react.js.map +1 -1
- package/lib/public/locales/en/TreeWidget.json +126 -42
- package/package.json +19 -6
- package/lib/cjs/components/TreeFilteringState.d.ts +0 -18
- package/lib/cjs/components/TreeFilteringState.js +0 -46
- package/lib/cjs/components/TreeFilteringState.js.map +0 -1
- package/lib/cjs/components/trees/CategoriesVisibilityUtils.d.ts +0 -25
- package/lib/cjs/components/trees/CategoriesVisibilityUtils.js.map +0 -1
- package/lib/cjs/components/trees/VisibilityTreeBase.scss +0 -82
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.d.ts +0 -67
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.js +0 -158
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.js.map +0 -1
- package/lib/cjs/components/trees/VisibilityTreeRenderer.d.ts +0 -100
- package/lib/cjs/components/trees/VisibilityTreeRenderer.js +0 -98
- package/lib/cjs/components/trees/VisibilityTreeRenderer.js.map +0 -1
- package/lib/cjs/components/trees/category-tree/Categories.json +0 -99
- package/lib/cjs/components/trees/category-tree/CategoriesTree.d.ts +0 -60
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js +0 -141
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +0 -1
- package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.d.ts +0 -71
- package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js +0 -123
- package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js.map +0 -1
- package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.d.ts +0 -72
- package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js +0 -172
- package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js.map +0 -1
- package/lib/cjs/components/trees/common/ContextMenu.d.ts +0 -39
- package/lib/cjs/components/trees/common/ContextMenu.js +0 -44
- package/lib/cjs/components/trees/common/ContextMenu.js.map +0 -1
- package/lib/cjs/components/trees/common/ReportingTreeEventHandler.d.ts +0 -27
- package/lib/cjs/components/trees/common/ReportingTreeEventHandler.js +0 -51
- package/lib/cjs/components/trees/common/ReportingTreeEventHandler.js.map +0 -1
- package/lib/cjs/components/trees/common/TreeNodeRenderer.d.ts +0 -61
- package/lib/cjs/components/trees/common/TreeNodeRenderer.js +0 -50
- package/lib/cjs/components/trees/common/TreeNodeRenderer.js.map +0 -1
- package/lib/cjs/components/trees/common/TreeRenderer.d.ts +0 -55
- package/lib/cjs/components/trees/common/TreeRenderer.js +0 -67
- package/lib/cjs/components/trees/common/TreeRenderer.js.map +0 -1
- package/lib/cjs/components/trees/common/TreeRenderer.scss +0 -149
- package/lib/cjs/components/trees/common/Types.d.ts +0 -57
- package/lib/cjs/components/trees/common/Types.js +0 -21
- package/lib/cjs/components/trees/common/Types.js.map +0 -1
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.d.ts +0 -43
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.js +0 -49
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.js.map +0 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSources.json +0 -228
- package/lib/cjs/components/trees/imodel-content-tree/IModelContent.json +0 -443
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.d.ts +0 -19
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.js +0 -36
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.js.map +0 -1
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.d.ts +0 -130
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js +0 -651
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js.map +0 -1
- package/lib/cjs/components/trees/models-tree/Utils.d.ts +0 -29
- package/lib/cjs/components/trees/models-tree/Utils.js +0 -556
- package/lib/cjs/components/trees/models-tree/Utils.js.map +0 -1
- package/lib/cjs/components/utils/UseTreeTransientState.d.ts +0 -19
- package/lib/cjs/components/utils/UseTreeTransientState.js +0 -33
- package/lib/cjs/components/utils/UseTreeTransientState.js.map +0 -1
- package/lib/esm/components/TreeFilteringState.d.ts +0 -18
- package/lib/esm/components/TreeFilteringState.js +0 -42
- package/lib/esm/components/TreeFilteringState.js.map +0 -1
- package/lib/esm/components/trees/CategoriesVisibilityUtils.d.ts +0 -25
- package/lib/esm/components/trees/CategoriesVisibilityUtils.js.map +0 -1
- package/lib/esm/components/trees/VisibilityTreeBase.scss +0 -82
- package/lib/esm/components/trees/VisibilityTreeEventHandler.d.ts +0 -67
- package/lib/esm/components/trees/VisibilityTreeEventHandler.js +0 -154
- package/lib/esm/components/trees/VisibilityTreeEventHandler.js.map +0 -1
- package/lib/esm/components/trees/VisibilityTreeRenderer.d.ts +0 -100
- package/lib/esm/components/trees/VisibilityTreeRenderer.js +0 -86
- package/lib/esm/components/trees/VisibilityTreeRenderer.js.map +0 -1
- package/lib/esm/components/trees/category-tree/Categories.json +0 -99
- package/lib/esm/components/trees/category-tree/CategoriesTree.d.ts +0 -60
- package/lib/esm/components/trees/category-tree/CategoriesTree.js +0 -111
- package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +0 -1
- package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.d.ts +0 -71
- package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js +0 -116
- package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js.map +0 -1
- package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.d.ts +0 -72
- package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js +0 -164
- package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js.map +0 -1
- package/lib/esm/components/trees/common/ContextMenu.d.ts +0 -39
- package/lib/esm/components/trees/common/ContextMenu.js +0 -39
- package/lib/esm/components/trees/common/ContextMenu.js.map +0 -1
- package/lib/esm/components/trees/common/ReportingTreeEventHandler.d.ts +0 -27
- package/lib/esm/components/trees/common/ReportingTreeEventHandler.js +0 -47
- package/lib/esm/components/trees/common/ReportingTreeEventHandler.js.map +0 -1
- package/lib/esm/components/trees/common/TreeNodeRenderer.d.ts +0 -61
- package/lib/esm/components/trees/common/TreeNodeRenderer.js +0 -44
- package/lib/esm/components/trees/common/TreeNodeRenderer.js.map +0 -1
- package/lib/esm/components/trees/common/TreeRenderer.d.ts +0 -55
- package/lib/esm/components/trees/common/TreeRenderer.js +0 -59
- package/lib/esm/components/trees/common/TreeRenderer.js.map +0 -1
- package/lib/esm/components/trees/common/TreeRenderer.scss +0 -149
- package/lib/esm/components/trees/common/Types.d.ts +0 -57
- package/lib/esm/components/trees/common/Types.js +0 -18
- package/lib/esm/components/trees/common/Types.js.map +0 -1
- package/lib/esm/components/trees/common/UseVisibilityTreeState.d.ts +0 -43
- package/lib/esm/components/trees/common/UseVisibilityTreeState.js +0 -45
- package/lib/esm/components/trees/common/UseVisibilityTreeState.js.map +0 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSources.json +0 -228
- package/lib/esm/components/trees/imodel-content-tree/IModelContent.json +0 -443
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.d.ts +0 -19
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.js +0 -32
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.js.map +0 -1
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.d.ts +0 -130
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js +0 -641
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js.map +0 -1
- package/lib/esm/components/trees/models-tree/Utils.d.ts +0 -29
- package/lib/esm/components/trees/models-tree/Utils.js +0 -548
- package/lib/esm/components/trees/models-tree/Utils.js.map +0 -1
- package/lib/esm/components/utils/UseTreeTransientState.d.ts +0 -19
- package/lib/esm/components/utils/UseTreeTransientState.js +0 -29
- package/lib/esm/components/utils/UseTreeTransientState.js.map +0 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.CategoriesVisibilityHandler = void 0;
|
|
8
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
9
|
+
const presentation_hierarchies_1 = require("@itwin/presentation-hierarchies");
|
|
10
|
+
const CategoriesVisibilityUtils_1 = require("../common/CategoriesVisibilityUtils");
|
|
11
|
+
/** @internal */
|
|
12
|
+
class CategoriesVisibilityHandler {
|
|
13
|
+
constructor(props) {
|
|
14
|
+
this.onVisibilityChange = new core_bentley_1.BeEvent();
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
16
|
+
this.onDisplayStyleChanged = () => {
|
|
17
|
+
this.onVisibilityChangeInternal();
|
|
18
|
+
};
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
20
|
+
this.onViewedCategoriesChanged = () => {
|
|
21
|
+
this.onVisibilityChangeInternal();
|
|
22
|
+
};
|
|
23
|
+
this._viewManager = props.viewManager;
|
|
24
|
+
this._imodel = props.imodel;
|
|
25
|
+
this._viewport = props.viewport;
|
|
26
|
+
// istanbul ignore next
|
|
27
|
+
this._useAllViewports = props.allViewports ?? false;
|
|
28
|
+
this._viewport.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);
|
|
29
|
+
this._viewport.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);
|
|
30
|
+
}
|
|
31
|
+
dispose() {
|
|
32
|
+
this._viewport.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);
|
|
33
|
+
this._viewport.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);
|
|
34
|
+
clearTimeout(this._pendingVisibilityChange);
|
|
35
|
+
}
|
|
36
|
+
/** Returns visibility status of the tree node. */
|
|
37
|
+
getVisibilityStatus(node) {
|
|
38
|
+
if (!presentation_hierarchies_1.HierarchyNode.isInstancesNode(node)) {
|
|
39
|
+
return { state: "hidden", isDisabled: true };
|
|
40
|
+
}
|
|
41
|
+
return { state: node.parentKeys.length ? this.getSubCategoryVisibility(node) : this.getCategoryVisibility(node) };
|
|
42
|
+
}
|
|
43
|
+
async changeVisibility(node, on) {
|
|
44
|
+
if (!presentation_hierarchies_1.HierarchyNode.isInstancesNode(node)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// handle subcategory visibility change
|
|
48
|
+
if (node.parentKeys.length) {
|
|
49
|
+
const childId = CategoriesVisibilityHandler.getInstanceIdFromHierarchyNode(node);
|
|
50
|
+
const parentCategoryId = node.extendedData?.categoryId;
|
|
51
|
+
// make sure parent category is enabled
|
|
52
|
+
if (on && parentCategoryId) {
|
|
53
|
+
await this.enableCategory([parentCategoryId], true, false);
|
|
54
|
+
}
|
|
55
|
+
this.enableSubCategory(childId, on);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const instanceId = CategoriesVisibilityHandler.getInstanceIdFromHierarchyNode(node);
|
|
59
|
+
await this.enableCategory([instanceId], on, true);
|
|
60
|
+
}
|
|
61
|
+
getSubCategoryVisibility(node) {
|
|
62
|
+
const parentCategoryId = node.extendedData?.categoryId;
|
|
63
|
+
if (!parentCategoryId) {
|
|
64
|
+
return "hidden";
|
|
65
|
+
}
|
|
66
|
+
const subcategoryId = CategoriesVisibilityHandler.getInstanceIdFromHierarchyNode(node);
|
|
67
|
+
const isVisible = this._viewport.view.viewsCategory(parentCategoryId) && this._viewport.isSubCategoryVisible(subcategoryId);
|
|
68
|
+
return isVisible ? "visible" : "hidden";
|
|
69
|
+
}
|
|
70
|
+
getCategoryVisibility(node) {
|
|
71
|
+
const instanceId = CategoriesVisibilityHandler.getInstanceIdFromHierarchyNode(node);
|
|
72
|
+
return this._viewport.view.viewsCategory(instanceId) ? "visible" : "hidden";
|
|
73
|
+
}
|
|
74
|
+
onVisibilityChangeInternal() {
|
|
75
|
+
if (this._pendingVisibilityChange) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this._pendingVisibilityChange = setTimeout(() => {
|
|
79
|
+
this.onVisibilityChange.raiseEvent();
|
|
80
|
+
this._pendingVisibilityChange = undefined;
|
|
81
|
+
}, 0);
|
|
82
|
+
}
|
|
83
|
+
static getInstanceIdFromHierarchyNode(node) {
|
|
84
|
+
return presentation_hierarchies_1.HierarchyNode.isInstancesNode(node) && node.key.instanceKeys.length > 0 ? node.key.instanceKeys[0].id : /* istanbul ignore next */ "";
|
|
85
|
+
}
|
|
86
|
+
async enableCategory(ids, enabled, enableAllSubCategories = true) {
|
|
87
|
+
await (0, CategoriesVisibilityUtils_1.enableCategoryDisplay)(this._viewManager, this._imodel, ids, enabled, this._useAllViewports, enableAllSubCategories);
|
|
88
|
+
}
|
|
89
|
+
enableSubCategory(key, enabled) {
|
|
90
|
+
(0, CategoriesVisibilityUtils_1.enableSubCategoryDisplay)(this._viewManager, key, enabled, this._useAllViewports);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.CategoriesVisibilityHandler = CategoriesVisibilityHandler;
|
|
94
|
+
//# sourceMappingURL=CategoriesVisibilityHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CategoriesVisibilityHandler.js","sourceRoot":"","sources":["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AgB,EAAE,sBAAsB,CAAC,CAAC;IAC5H,CAAC;IAEM,iBAAiB,CAAC,GAAW,EAAE,OAAgB;QACpD,IAAA,oDAAwB,EAAC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACnF,CAAC;CACF;AAxGD,kEAwGC","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 { BeEvent } from \"@itwin/core-bentley\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { enableCategoryDisplay, enableSubCategoryDisplay } from \"../common/CategoriesVisibilityUtils\";\n\nimport type { CategoryInfo } from \"../common/CategoriesVisibilityUtils\";\nimport type { IModelConnection, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { HierarchyVisibilityHandler, VisibilityStatus } from \"../common/UseHierarchyVisibility\";\n\ninterface CategoriesVisibilityHandlerProps {\n viewManager: ViewManager;\n imodel: IModelConnection;\n categories: CategoryInfo[];\n viewport: Viewport;\n allViewports?: boolean;\n}\n\n/** @internal */\nexport class CategoriesVisibilityHandler implements HierarchyVisibilityHandler {\n private _viewManager: ViewManager;\n private _imodel: IModelConnection;\n private _pendingVisibilityChange: any | undefined;\n private _viewport: Viewport;\n private _useAllViewports: boolean;\n\n constructor(props: CategoriesVisibilityHandlerProps) {\n this._viewManager = props.viewManager;\n this._imodel = props.imodel;\n this._viewport = props.viewport;\n // istanbul ignore next\n this._useAllViewports = props.allViewports ?? false;\n this._viewport.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);\n this._viewport.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);\n }\n\n public dispose() {\n this._viewport.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);\n this._viewport.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);\n clearTimeout(this._pendingVisibilityChange);\n }\n\n public onVisibilityChange = new BeEvent();\n\n /** Returns visibility status of the tree node. */\n public getVisibilityStatus(node: HierarchyNode): Promise<VisibilityStatus> | VisibilityStatus {\n if (!HierarchyNode.isInstancesNode(node)) {\n return { state: \"hidden\", isDisabled: true };\n }\n return { state: node.parentKeys.length ? this.getSubCategoryVisibility(node) : this.getCategoryVisibility(node) };\n }\n\n public async changeVisibility(node: HierarchyNode, on: boolean) {\n if (!HierarchyNode.isInstancesNode(node)) {\n return;\n }\n\n // handle subcategory visibility change\n if (node.parentKeys.length) {\n const childId = CategoriesVisibilityHandler.getInstanceIdFromHierarchyNode(node);\n const parentCategoryId = node.extendedData?.categoryId;\n\n // make sure parent category is enabled\n if (on && parentCategoryId) {\n await this.enableCategory([parentCategoryId], true, false);\n }\n\n this.enableSubCategory(childId, on);\n return;\n }\n\n const instanceId = CategoriesVisibilityHandler.getInstanceIdFromHierarchyNode(node);\n await this.enableCategory([instanceId], on, true);\n }\n\n public getSubCategoryVisibility(node: HierarchyNode) {\n const parentCategoryId = node.extendedData?.categoryId;\n if (!parentCategoryId) {\n return \"hidden\";\n }\n\n const subcategoryId = CategoriesVisibilityHandler.getInstanceIdFromHierarchyNode(node);\n const isVisible = this._viewport.view.viewsCategory(parentCategoryId) && this._viewport.isSubCategoryVisible(subcategoryId);\n return isVisible ? \"visible\" : \"hidden\";\n }\n\n public getCategoryVisibility(node: HierarchyNode) {\n const instanceId = CategoriesVisibilityHandler.getInstanceIdFromHierarchyNode(node);\n return this._viewport.view.viewsCategory(instanceId) ? \"visible\" : \"hidden\";\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onDisplayStyleChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onViewedCategoriesChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onVisibilityChangeInternal() {\n if (this._pendingVisibilityChange) {\n return;\n }\n\n this._pendingVisibilityChange = setTimeout(() => {\n this.onVisibilityChange.raiseEvent();\n this._pendingVisibilityChange = undefined;\n }, 0);\n }\n\n public static getInstanceIdFromHierarchyNode(node: HierarchyNode) {\n return HierarchyNode.isInstancesNode(node) && node.key.instanceKeys.length > 0 ? node.key.instanceKeys[0].id : /* istanbul ignore next */ \"\";\n }\n\n public async enableCategory(ids: string[], enabled: boolean, enableAllSubCategories = true) {\n await enableCategoryDisplay(this._viewManager, this._imodel, ids, enabled, this._useAllViewports, enableAllSubCategories);\n }\n\n public enableSubCategory(key: string, enabled: boolean) {\n enableSubCategoryDisplay(this._viewManager, key, enabled, this._useAllViewports);\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IModelConnection, ViewManager, Viewport } from "@itwin/core-frontend";
|
|
2
|
+
import type { CategoryInfo } from "../common/CategoriesVisibilityUtils";
|
|
3
|
+
/**
|
|
4
|
+
* Loads categories from viewport or uses provided list of categories.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare function useCategories(viewManager: ViewManager, imodel: IModelConnection, view?: Viewport): CategoryInfo[];
|
|
8
|
+
//# sourceMappingURL=UseCategories.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.useCategories = void 0;
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const components_react_1 = require("@itwin/components-react");
|
|
10
|
+
const CategoriesVisibilityUtils_1 = require("../common/CategoriesVisibilityUtils");
|
|
11
|
+
const EMPTY_CATEGORIES_ARRAY = [];
|
|
12
|
+
/**
|
|
13
|
+
* Loads categories from viewport or uses provided list of categories.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
function useCategories(viewManager, imodel, view) {
|
|
17
|
+
const currentView = view || viewManager.getFirstOpenView();
|
|
18
|
+
const categoriesPromise = (0, react_1.useMemo)(async () => (0, CategoriesVisibilityUtils_1.loadCategoriesFromViewport)(imodel, currentView), [imodel, currentView]);
|
|
19
|
+
return (0, components_react_1.useAsyncValue)(categoriesPromise) ?? EMPTY_CATEGORIES_ARRAY;
|
|
20
|
+
}
|
|
21
|
+
exports.useCategories = useCategories;
|
|
22
|
+
//# sourceMappingURL=UseCategories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseCategories.js","sourceRoot":"","sources":["../../../../../src/components/trees/categories-tree/UseCategories.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAAgC;AAChC,8DAAwD;AACxD,mFAAiF;AAKjF,MAAM,sBAAsB,GAAmB,EAAE,CAAC;AAElD;;;GAGG;AACH,SAAgB,aAAa,CAAC,WAAwB,EAAE,MAAwB,EAAE,IAAe;IAC/F,MAAM,WAAW,GAAG,IAAI,IAAI,WAAW,CAAC,gBAAgB,EAAE,CAAC;IAC3D,MAAM,iBAAiB,GAAG,IAAA,eAAO,EAAC,KAAK,IAAI,EAAE,CAAC,IAAA,sDAA0B,EAAC,MAAM,EAAE,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IACtH,OAAO,IAAA,gCAAa,EAAC,iBAAiB,CAAC,IAAI,sBAAsB,CAAC;AACpE,CAAC;AAJD,sCAIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useMemo } from \"react\";\nimport { useAsyncValue } from \"@itwin/components-react\";\nimport { loadCategoriesFromViewport } from \"../common/CategoriesVisibilityUtils\";\n\nimport type { IModelConnection, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { CategoryInfo } from \"../common/CategoriesVisibilityUtils\";\n\nconst EMPTY_CATEGORIES_ARRAY: CategoryInfo[] = [];\n\n/**\n * Loads categories from viewport or uses provided list of categories.\n * @internal\n */\nexport function useCategories(viewManager: ViewManager, imodel: IModelConnection, view?: Viewport) {\n const currentView = view || viewManager.getFirstOpenView();\n const categoriesPromise = useMemo(async () => loadCategoriesFromViewport(imodel, currentView), [imodel, currentView]);\n return useAsyncValue(categoriesPromise) ?? EMPTY_CATEGORIES_ARRAY;\n}\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { IModelConnection, ViewManager, Viewport } from "@itwin/core-frontend";
|
|
2
|
+
/**
|
|
3
|
+
* Data structure that describes category.
|
|
4
|
+
*/
|
|
5
|
+
export interface CategoryInfo {
|
|
6
|
+
categoryId: string;
|
|
7
|
+
subCategoryIds?: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Toggles visibility of categories to show or hide.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare function toggleAllCategories(viewManager: ViewManager, imodel: IModelConnection, display: boolean, viewport?: Viewport, forAllViewports?: boolean): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Gets ids of all categories from specified imodel and viewport.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare function getCategories(imodel: IModelConnection, viewport?: Viewport): Promise<string[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Changes category display in the viewport.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare function enableCategoryDisplay(viewManager: ViewManager, imodel: IModelConnection, ids: string[], enabled: boolean, forAllViewports: boolean, enableAllSubCategories?: boolean): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Changes subcategory display in the viewport
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export declare function enableSubCategoryDisplay(viewManager: ViewManager, key: string, enabled: boolean, forAllViewports?: boolean): void;
|
|
29
|
+
/** @internal */
|
|
30
|
+
export declare function loadCategoriesFromViewport(iModel?: IModelConnection, vp?: Viewport): Promise<CategoryInfo[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Enable display of all given categories.
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export declare function showAllCategories(categories: string[], viewport: Viewport): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Disable display of all given categories.
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare function hideAllCategories(categories: string[], viewport: Viewport): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Invert display of all given categories.
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export declare function invertAllCategories(categories: CategoryInfo[], viewport: Viewport): Promise<void>;
|
|
46
|
+
//# sourceMappingURL=CategoriesVisibilityUtils.d.ts.map
|
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.loadCategoriesFromViewport = exports.
|
|
7
|
+
exports.invertAllCategories = exports.hideAllCategories = exports.showAllCategories = exports.loadCategoriesFromViewport = exports.enableSubCategoryDisplay = exports.enableCategoryDisplay = exports.getCategories = exports.toggleAllCategories = void 0;
|
|
8
8
|
const core_common_1 = require("@itwin/core-common");
|
|
9
9
|
const core_frontend_1 = require("@itwin/core-frontend");
|
|
10
|
-
const EMPTY_CATEGORIES_ARRAY = [];
|
|
11
10
|
/**
|
|
12
11
|
* Toggles visibility of categories to show or hide.
|
|
13
12
|
* @internal
|
|
@@ -20,7 +19,7 @@ async function toggleAllCategories(viewManager, imodel, display, viewport, forAl
|
|
|
20
19
|
if (ids.length === 0) {
|
|
21
20
|
return;
|
|
22
21
|
}
|
|
23
|
-
await
|
|
22
|
+
await enableCategoryDisplay(viewManager, imodel, ids, display, forAllViewports ?? false);
|
|
24
23
|
}
|
|
25
24
|
exports.toggleAllCategories = toggleAllCategories;
|
|
26
25
|
/**
|
|
@@ -36,7 +35,7 @@ exports.getCategories = getCategories;
|
|
|
36
35
|
* Changes category display in the viewport.
|
|
37
36
|
* @internal
|
|
38
37
|
*/
|
|
39
|
-
async function
|
|
38
|
+
async function enableCategoryDisplay(viewManager, imodel, ids, enabled, forAllViewports, enableAllSubCategories = true) {
|
|
40
39
|
if (!viewManager.selectedView) {
|
|
41
40
|
return;
|
|
42
41
|
}
|
|
@@ -57,7 +56,7 @@ async function enableCategory(viewManager, imodel, ids, enabled, forAllViewports
|
|
|
57
56
|
// changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.
|
|
58
57
|
if (false === enabled) {
|
|
59
58
|
(await imodel.categories.getCategoryInfo(ids)).forEach((categoryInfo) => {
|
|
60
|
-
categoryInfo.subCategories.forEach((value) =>
|
|
59
|
+
categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewManager, value.id, false, forAllViewports));
|
|
61
60
|
});
|
|
62
61
|
}
|
|
63
62
|
}
|
|
@@ -72,12 +71,12 @@ async function enableCategory(viewManager, imodel, ids, enabled, forAllViewports
|
|
|
72
71
|
await updateViewport(viewManager.selectedView);
|
|
73
72
|
}
|
|
74
73
|
}
|
|
75
|
-
exports.
|
|
74
|
+
exports.enableCategoryDisplay = enableCategoryDisplay;
|
|
76
75
|
/**
|
|
77
76
|
* Changes subcategory display in the viewport
|
|
78
77
|
* @internal
|
|
79
78
|
*/
|
|
80
|
-
function
|
|
79
|
+
function enableSubCategoryDisplay(viewManager, key, enabled, forAllViewports) {
|
|
81
80
|
if (!viewManager.selectedView) {
|
|
82
81
|
return;
|
|
83
82
|
}
|
|
@@ -98,7 +97,7 @@ function enableSubCategory(viewManager, key, enabled, forAllViewports) {
|
|
|
98
97
|
updateViewport(viewManager.selectedView);
|
|
99
98
|
}
|
|
100
99
|
}
|
|
101
|
-
exports.
|
|
100
|
+
exports.enableSubCategoryDisplay = enableSubCategoryDisplay;
|
|
102
101
|
/** @internal */
|
|
103
102
|
async function loadCategoriesFromViewport(iModel, vp) {
|
|
104
103
|
if (!vp) {
|
|
@@ -120,4 +119,53 @@ async function loadCategoriesFromViewport(iModel, vp) {
|
|
|
120
119
|
return categories;
|
|
121
120
|
}
|
|
122
121
|
exports.loadCategoriesFromViewport = loadCategoriesFromViewport;
|
|
122
|
+
const EMPTY_CATEGORIES_ARRAY = [];
|
|
123
|
+
/**
|
|
124
|
+
* Enable display of all given categories.
|
|
125
|
+
* @public
|
|
126
|
+
*/
|
|
127
|
+
async function showAllCategories(categories, viewport) {
|
|
128
|
+
await enableCategoryDisplay(core_frontend_1.IModelApp.viewManager, viewport.iModel, categories, true, true);
|
|
129
|
+
}
|
|
130
|
+
exports.showAllCategories = showAllCategories;
|
|
131
|
+
/**
|
|
132
|
+
* Disable display of all given categories.
|
|
133
|
+
* @public
|
|
134
|
+
*/
|
|
135
|
+
async function hideAllCategories(categories, viewport) {
|
|
136
|
+
await enableCategoryDisplay(core_frontend_1.IModelApp.viewManager, viewport.iModel, categories, false, true);
|
|
137
|
+
}
|
|
138
|
+
exports.hideAllCategories = hideAllCategories;
|
|
139
|
+
/**
|
|
140
|
+
* Invert display of all given categories.
|
|
141
|
+
* @public
|
|
142
|
+
*/
|
|
143
|
+
async function invertAllCategories(categories, viewport) {
|
|
144
|
+
const enabled = [];
|
|
145
|
+
const disabled = [];
|
|
146
|
+
const enabledSubCategories = [];
|
|
147
|
+
const disabledSubCategories = [];
|
|
148
|
+
for (const category of categories) {
|
|
149
|
+
if (!viewport.view.viewsCategory(category.categoryId)) {
|
|
150
|
+
disabled.push(category.categoryId);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
// First, we need to check if at least one subcategory is disabled. If it is true, then only subcategories should change display, not categories.
|
|
154
|
+
if (category.subCategoryIds?.some((subCategory) => !viewport.isSubCategoryVisible(subCategory))) {
|
|
155
|
+
for (const subCategory of category.subCategoryIds) {
|
|
156
|
+
viewport.isSubCategoryVisible(subCategory) ? enabledSubCategories.push(subCategory) : disabledSubCategories.push(subCategory);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
enabled.push(category.categoryId);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// Disable enabled
|
|
164
|
+
enabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(core_frontend_1.IModelApp.viewManager, subCategory, false, true));
|
|
165
|
+
await enableCategoryDisplay(core_frontend_1.IModelApp.viewManager, viewport.iModel, enabled, false, true);
|
|
166
|
+
// Enable disabled
|
|
167
|
+
disabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(core_frontend_1.IModelApp.viewManager, subCategory, true, true));
|
|
168
|
+
await enableCategoryDisplay(core_frontend_1.IModelApp.viewManager, viewport.iModel, disabled, true, true);
|
|
169
|
+
}
|
|
170
|
+
exports.invertAllCategories = invertAllCategories;
|
|
123
171
|
//# sourceMappingURL=CategoriesVisibilityUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CategoriesVisibilityUtils.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/CategoriesVisibilityUtils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,oDAAoD;AACpD,wDAA6E;AAY7E;;;GAGG;AACI,KAAK,UAAU,mBAAmB,CACvC,WAAwB,EACxB,MAAwB,EACxB,OAAgB,EAChB,QAAmB,EACnB,eAAyB;IAEzB,uBAAuB;IACvB,MAAM,UAAU,GAAG,QAAQ,IAAI,WAAW,CAAC,gBAAgB,EAAE,CAAC;IAC9D,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAEpD,qBAAqB;IACrB,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;QACpB,OAAO;KACR;IAED,MAAM,qBAAqB,CAAC,WAAW,EAAE,MAAM,E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C,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;aAC/H;SACF;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;SACnC;KACF;IAED,kBAAkB;IAClB,oBAAoB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,wBAAwB,CAAC,yBAAS,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IAEzH,MAAM,qBAAqB,CAAC,yBAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAE1F,kBAAkB;IAClB,qBAAqB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,wBAAwB,CAAC,yBAAS,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAEzH,MAAM,qBAAqB,CAAC,yBAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC5F,CAAC;AA9BD,kDA8BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { QueryRowFormat } from \"@itwin/core-common\";\nimport { IModelApp, PerModelCategoryVisibility } from \"@itwin/core-frontend\";\n\nimport type { IModelConnection, ViewManager, Viewport } from \"@itwin/core-frontend\";\n\n/**\n * Data structure that describes category.\n */\nexport interface CategoryInfo {\n categoryId: string;\n subCategoryIds?: string[];\n}\n\n/**\n * Toggles visibility of categories to show or hide.\n * @internal\n */\nexport async function toggleAllCategories(\n viewManager: ViewManager,\n imodel: IModelConnection,\n display: boolean,\n viewport?: Viewport,\n forAllViewports?: boolean,\n) {\n // istanbul ignore next\n const activeView = viewport ?? viewManager.getFirstOpenView();\n const ids = await getCategories(imodel, activeView);\n\n // istanbul ignore if\n if (ids.length === 0) {\n return;\n }\n\n await enableCategoryDisplay(viewManager, imodel, ids, display, forAllViewports ?? false);\n}\n\n/**\n * Gets ids of all categories from specified imodel and viewport.\n * @internal\n */\nexport async function getCategories(imodel: IModelConnection, viewport?: Viewport) {\n const categories = await loadCategoriesFromViewport(imodel, viewport);\n return categories.map((category) => category.categoryId);\n}\n\n/**\n * Changes category display in the viewport.\n * @internal\n */\nexport async function enableCategoryDisplay(\n viewManager: ViewManager,\n imodel: IModelConnection,\n ids: string[],\n enabled: boolean,\n forAllViewports: boolean,\n enableAllSubCategories = true,\n) {\n if (!viewManager.selectedView) {\n return;\n }\n\n const updateViewport = async (vp: Viewport) => {\n // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we\n // are using 'allViewports' property\n if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {\n vp.changeCategoryDisplay(ids, enabled, enableAllSubCategories);\n\n // remove category overrides per model\n const modelsContainingOverrides: string[] = [];\n for (const ovr of vp.perModelCategoryVisibility) {\n // istanbul ignore else\n if (ids.findIndex((id) => id === ovr.categoryId) !== -1) {\n modelsContainingOverrides.push(ovr.modelId);\n }\n }\n vp.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, PerModelCategoryVisibility.Override.None);\n\n // changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.\n if (false === enabled) {\n (await imodel.categories.getCategoryInfo(ids)).forEach((categoryInfo) => {\n categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewManager, value.id, false, forAllViewports));\n });\n }\n }\n };\n\n // This property let us act on all viewports or just on the selected one, configurable by the app\n if (forAllViewports) {\n for (const viewport of viewManager) {\n await updateViewport(viewport);\n }\n } else {\n await updateViewport(viewManager.selectedView);\n }\n}\n\n/**\n * Changes subcategory display in the viewport\n * @internal\n */\nexport function enableSubCategoryDisplay(viewManager: ViewManager, key: string, enabled: boolean, forAllViewports?: boolean) {\n if (!viewManager.selectedView) {\n return;\n }\n\n const updateViewport = (vp: Viewport) => {\n // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we\n // are using 'allViewports' property\n if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {\n vp.changeSubCategoryDisplay(key, enabled);\n }\n };\n\n // This property let us act on all viewports or just on the selected one, configurable by the app\n if (forAllViewports) {\n for (const viewport of viewManager) {\n updateViewport(viewport);\n }\n } else {\n updateViewport(viewManager.selectedView);\n }\n}\n\n/** @internal */\nexport async function loadCategoriesFromViewport(iModel?: IModelConnection, vp?: Viewport) {\n if (!vp) {\n return EMPTY_CATEGORIES_ARRAY;\n }\n\n // Query categories and add them to state\n const selectUsedSpatialCategoryIds =\n \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)\";\n const selectUsedDrawingCategoryIds =\n \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement2d WHERE Model.Id=? AND Category.Id IN (SELECT ECInstanceId from BisCore.DrawingCategory)\";\n const ecsql = vp.view.is3d() ? selectUsedSpatialCategoryIds : selectUsedDrawingCategoryIds;\n const ecsql2 = `SELECT ECInstanceId as id FROM ${vp.view.is3d() ? \"BisCore.SpatialCategory\" : \"BisCore.DrawingCategory\"} WHERE ECInstanceId IN (${ecsql})`;\n\n const categories: CategoryInfo[] = [];\n\n // istanbul ignore else\n if (iModel) {\n const rows = await iModel.createQueryReader(ecsql2, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }).toArray();\n (await iModel.categories.getCategoryInfo(rows.map((row) => row.id))).forEach((val) => {\n categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });\n });\n }\n return categories;\n}\nconst EMPTY_CATEGORIES_ARRAY: CategoryInfo[] = [];\n\n/**\n * Enable display of all given categories.\n * @public\n */\nexport async function showAllCategories(categories: string[], viewport: Viewport) {\n await enableCategoryDisplay(IModelApp.viewManager, viewport.iModel, categories, true, true);\n}\n\n/**\n * Disable display of all given categories.\n * @public\n */\nexport async function hideAllCategories(categories: string[], viewport: Viewport) {\n await enableCategoryDisplay(IModelApp.viewManager, viewport.iModel, categories, false, true);\n}\n\n/**\n * Invert display of all given categories.\n * @public\n */\nexport async function invertAllCategories(categories: CategoryInfo[], viewport: Viewport) {\n const enabled: string[] = [];\n const disabled: string[] = [];\n const enabledSubCategories: string[] = [];\n const disabledSubCategories: string[] = [];\n\n for (const category of categories) {\n if (!viewport.view.viewsCategory(category.categoryId)) {\n disabled.push(category.categoryId);\n continue;\n }\n // First, we need to check if at least one subcategory is disabled. If it is true, then only subcategories should change display, not categories.\n if (category.subCategoryIds?.some((subCategory) => !viewport.isSubCategoryVisible(subCategory))) {\n for (const subCategory of category.subCategoryIds) {\n viewport.isSubCategoryVisible(subCategory) ? enabledSubCategories.push(subCategory) : disabledSubCategories.push(subCategory);\n }\n } else {\n enabled.push(category.categoryId);\n }\n }\n\n // Disable enabled\n enabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(IModelApp.viewManager, subCategory, false, true));\n\n await enableCategoryDisplay(IModelApp.viewManager, viewport.iModel, enabled, false, true);\n\n // Enable disabled\n disabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(IModelApp.viewManager, subCategory, true, true));\n\n await enableCategoryDisplay(IModelApp.viewManager, viewport.iModel, disabled, true, true);\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { InstanceKey } from "@itwin/presentation-shared";
|
|
3
|
+
import type { GroupingHierarchyNode } from "@itwin/presentation-hierarchies";
|
|
4
|
+
/** @internal */
|
|
5
|
+
export interface FocusedInstancesContext {
|
|
6
|
+
loadInstanceKeys?: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>;
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
toggle: () => void;
|
|
9
|
+
}
|
|
10
|
+
/** @internal */
|
|
11
|
+
export declare const focusedInstancesContext: import("react").Context<FocusedInstancesContext>;
|
|
12
|
+
/** @internal */
|
|
13
|
+
export declare function useFocusedInstancesContext(): FocusedInstancesContext;
|
|
14
|
+
//# sourceMappingURL=FocusedInstancesContext.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.useFocusedInstancesContext = exports.focusedInstancesContext = void 0;
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
/** @internal */
|
|
10
|
+
exports.focusedInstancesContext = (0, react_1.createContext)({ enabled: false, toggle: () => { } });
|
|
11
|
+
/** @internal */
|
|
12
|
+
function useFocusedInstancesContext() {
|
|
13
|
+
return (0, react_1.useContext)(exports.focusedInstancesContext);
|
|
14
|
+
}
|
|
15
|
+
exports.useFocusedInstancesContext = useFocusedInstancesContext;
|
|
16
|
+
//# sourceMappingURL=FocusedInstancesContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FocusedInstancesContext.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/FocusedInstancesContext.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAAkD;AAYlD,gBAAgB;AACH,QAAA,uBAAuB,GAAG,IAAA,qBAAa,EAA0B,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAC;AAEpH,gBAAgB;AAChB,SAAgB,0BAA0B;IACxC,OAAO,IAAA,kBAAU,EAAC,+BAAuB,CAAC,CAAC;AAC7C,CAAC;AAFD,gEAEC","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 { createContext, useContext } from \"react\";\n\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { GroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\n/** @internal */\nexport interface FocusedInstancesContext {\n loadInstanceKeys?: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>;\n enabled: boolean;\n toggle: () => void;\n}\n\n/** @internal */\nexport const focusedInstancesContext = createContext<FocusedInstancesContext>({ enabled: false, toggle: () => {} });\n\n/** @internal */\nexport function useFocusedInstancesContext() {\n return useContext(focusedInstancesContext);\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SelectionStorage } from "@itwin/presentation-hierarchies-react";
|
|
2
|
+
import type { PropsWithChildren } from "react";
|
|
3
|
+
/** @internal */
|
|
4
|
+
export declare function FocusedInstancesContextProvider({ selectionStorage, imodelKey, children, }: PropsWithChildren<{
|
|
5
|
+
selectionStorage: SelectionStorage;
|
|
6
|
+
imodelKey: string;
|
|
7
|
+
}>): JSX.Element;
|
|
8
|
+
//# sourceMappingURL=FocusedInstancesContextProvider.d.ts.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FocusedInstancesContextProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
/*---------------------------------------------------------------------------------------------
|
|
6
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
7
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
8
|
+
*--------------------------------------------------------------------------------------------*/
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const presentation_hierarchies_react_1 = require("@itwin/presentation-hierarchies-react");
|
|
11
|
+
const unified_selection_1 = require("@itwin/unified-selection");
|
|
12
|
+
const FocusedInstancesContext_1 = require("./FocusedInstancesContext");
|
|
13
|
+
/** @internal */
|
|
14
|
+
function FocusedInstancesContextProvider({ selectionStorage, imodelKey, children, }) {
|
|
15
|
+
const [state, setState] = (0, react_1.useState)({
|
|
16
|
+
enabled: false,
|
|
17
|
+
toggle: () => {
|
|
18
|
+
setState((prev) => ({ ...prev, enabled: !prev.enabled }));
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
const enabled = state.enabled;
|
|
22
|
+
(0, react_1.useEffect)(() => {
|
|
23
|
+
if (!enabled) {
|
|
24
|
+
setState((prev) => ({ ...prev, loadInstanceKeys: undefined }));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const onSelectionChanged = () => {
|
|
28
|
+
const selection = selectionStorage.getSelection({ imodelKey, level: 0 });
|
|
29
|
+
if (unified_selection_1.Selectables.isEmpty(selection)) {
|
|
30
|
+
setState((prev) => ({ ...prev, loadInstanceKeys: undefined }));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const selected = [];
|
|
34
|
+
unified_selection_1.Selectables.forEach(selection, (selectable) => {
|
|
35
|
+
if (unified_selection_1.Selectable.isInstanceKey(selectable)) {
|
|
36
|
+
selected.push(selectable);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (isHierarchyNode(selectable.data) && presentation_hierarchies_react_1.HierarchyNode.isGroupingNode(selectable.data)) {
|
|
40
|
+
selected.push(selectable.data);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
selected.push(selectable.loadInstanceKeys);
|
|
44
|
+
});
|
|
45
|
+
const loadInstanceKeys = async function* () {
|
|
46
|
+
for (const item of selected) {
|
|
47
|
+
if (typeof item === "function") {
|
|
48
|
+
yield* item();
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
yield item;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
setState((prev) => ({ ...prev, loadInstanceKeys }));
|
|
56
|
+
};
|
|
57
|
+
onSelectionChanged();
|
|
58
|
+
return selectionStorage.selectionChangeEvent.addListener(({ imodelKey: changeImodelKey, level }) => {
|
|
59
|
+
if (changeImodelKey !== imodelKey || level !== 0) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
onSelectionChanged();
|
|
63
|
+
});
|
|
64
|
+
}, [enabled, imodelKey, selectionStorage]);
|
|
65
|
+
return (0, jsx_runtime_1.jsx)(FocusedInstancesContext_1.focusedInstancesContext.Provider, { value: state, children: children });
|
|
66
|
+
}
|
|
67
|
+
exports.FocusedInstancesContextProvider = FocusedInstancesContextProvider;
|
|
68
|
+
function isHierarchyNode(data) {
|
|
69
|
+
return !!data && typeof data === "object" && "key" in data;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=FocusedInstancesContextProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FocusedInstancesContextProvider.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/FocusedInstancesContextProvider.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAA4C;AAC5C,0FAAsE;AACtE,gEAAmE;AACnE,uEAAoE;AAQpE,gBAAgB;AAChB,SAAgB,+BAA+B,CAAC,EAC9C,gBAAgB,EAChB,SAAS,EACT,QAAQ,GACqE;IAC7E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAA0B;QAC1D,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,GAAG,EAAE;YACX,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC5D,CAAC;KACF,CAAC,CAAC;IACH,MAAM,OAAO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E;wBAC9B,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;qBACf;yBAAM;wBACL,MAAM,IAAI,CAAC;qBACZ;iBACF;YACH,CAAC,CAAC;YAEF,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC;QACtD,CAAC,CAAC;QAEF,kBAAkB,EAAE,CAAC;QACrB,OAAO,gBAAgB,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,EAAE;YACjG,IAAI,eAAe,KAAK,SAAS,IAAI,KAAK,KAAK,CAAC,EAAE;gBAChD,OAAO;aACR;YACD,kBAAkB,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAE3C,OAAO,uBAAC,iDAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAoC,CAAC;AACvG,CAAC;AAhED,0EAgEC;AAED,SAAS,eAAe,CAAC,IAAa;IACpC,OAAO,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,CAAC;AAC7D,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useState } from \"react\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport { Selectable, Selectables } from \"@itwin/unified-selection\";\nimport { focusedInstancesContext } from \"./FocusedInstancesContext\";\n\nimport type { SelectionStorage } from \"@itwin/presentation-hierarchies-react\";\nimport type { PropsWithChildren } from \"react\";\nimport type { InstanceKey } from \"@itwin/presentation-common\";\nimport type { FocusedInstancesContext } from \"./FocusedInstancesContext\";\nimport type { GroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\n/** @internal */\nexport function FocusedInstancesContextProvider({\n selectionStorage,\n imodelKey,\n children,\n}: PropsWithChildren<{ selectionStorage: SelectionStorage; imodelKey: string }>) {\n const [state, setState] = useState<FocusedInstancesContext>({\n enabled: false,\n toggle: () => {\n setState((prev) => ({ ...prev, enabled: !prev.enabled }));\n },\n });\n const enabled = state.enabled;\n\n useEffect(() => {\n if (!enabled) {\n setState((prev) => ({ ...prev, loadInstanceKeys: undefined }));\n return;\n }\n\n const onSelectionChanged = () => {\n const selection = selectionStorage.getSelection({ imodelKey, level: 0 });\n if (Selectables.isEmpty(selection)) {\n setState((prev) => ({ ...prev, loadInstanceKeys: undefined }));\n return;\n }\n\n const selected: Array<InstanceKey | GroupingHierarchyNode | (() => AsyncIterableIterator<InstanceKey>)> = [];\n Selectables.forEach(selection, (selectable) => {\n if (Selectable.isInstanceKey(selectable)) {\n selected.push(selectable);\n return;\n }\n\n if (isHierarchyNode(selectable.data) && HierarchyNode.isGroupingNode(selectable.data)) {\n selected.push(selectable.data);\n return;\n }\n\n selected.push(selectable.loadInstanceKeys);\n });\n\n const loadInstanceKeys: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode> = async function* () {\n for (const item of selected) {\n if (typeof item === \"function\") {\n yield* item();\n } else {\n yield item;\n }\n }\n };\n\n setState((prev) => ({ ...prev, loadInstanceKeys }));\n };\n\n onSelectionChanged();\n return selectionStorage.selectionChangeEvent.addListener(({ imodelKey: changeImodelKey, level }) => {\n if (changeImodelKey !== imodelKey || level !== 0) {\n return;\n }\n onSelectionChanged();\n });\n }, [enabled, imodelKey, selectionStorage]);\n\n return <focusedInstancesContext.Provider value={state}>{children}</focusedInstancesContext.Provider>;\n}\n\nfunction isHierarchyNode(data: unknown): data is HierarchyNode {\n return !!data && typeof data === \"object\" && \"key\" in data;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Observable, ObservableInput, OperatorFunction } from "rxjs";
|
|
2
|
+
/**
|
|
3
|
+
* Applies reduce function and "returns" early if the predicate returns `false` for the accumulator.
|
|
4
|
+
*/
|
|
5
|
+
export declare function reduceWhile<TValue, TAccumulator>(predicate: (x: TAccumulator) => boolean, reduceFunc: (acc: TAccumulator, val: TValue) => TAccumulator, initial: TAccumulator): OperatorFunction<TValue, TAccumulator | undefined>;
|
|
6
|
+
/** Same as `firstValueFrom` except it won't throw if the observable emits no values. */
|
|
7
|
+
export declare function toVoidPromise(obs: Observable<any>): Promise<void>;
|
|
8
|
+
/** Returns observable results in an array */
|
|
9
|
+
export declare function collect<T>(obs: ObservableInput<T>): Promise<T[]>;
|
|
10
|
+
//# sourceMappingURL=Rxjs.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.collect = exports.toVoidPromise = exports.reduceWhile = void 0;
|
|
8
|
+
const rxjs_1 = require("rxjs");
|
|
9
|
+
/**
|
|
10
|
+
* Applies reduce function and "returns" early if the predicate returns `false` for the accumulator.
|
|
11
|
+
*/
|
|
12
|
+
function reduceWhile(predicate, reduceFunc, initial) {
|
|
13
|
+
return (obs) => {
|
|
14
|
+
return obs.pipe((0, rxjs_1.scan)(reduceFunc, initial), (0, rxjs_1.takeWhile)(predicate, true), (0, rxjs_1.defaultIfEmpty)(undefined), (0, rxjs_1.last)());
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
exports.reduceWhile = reduceWhile;
|
|
18
|
+
/** Same as `firstValueFrom` except it won't throw if the observable emits no values. */
|
|
19
|
+
async function toVoidPromise(obs) {
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
obs.subscribe({
|
|
22
|
+
complete: () => resolve(),
|
|
23
|
+
error: reject,
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.toVoidPromise = toVoidPromise;
|
|
28
|
+
/** Returns observable results in an array */
|
|
29
|
+
async function collect(obs) {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
const arr = new Array();
|
|
32
|
+
(0, rxjs_1.from)(obs).subscribe({
|
|
33
|
+
next(item) {
|
|
34
|
+
arr.push(item);
|
|
35
|
+
},
|
|
36
|
+
complete() {
|
|
37
|
+
resolve(arr);
|
|
38
|
+
},
|
|
39
|
+
error(reason) {
|
|
40
|
+
reject(reason);
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
exports.collect = collect;
|
|
46
|
+
//# sourceMappingURL=Rxjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rxjs.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/Rxjs.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,+BAAmE;AAInE;;GAEG;AACH,SAAgB,WAAW,CACzB,SAAuC,EACvC,UAA4D,EAC5D,OAAqB;IAErB,OAAO,CAAC,GAAG,EAAE,EAAE;QACb,OAAO,GAAG,CAAC,IAAI,CAAC,IAAA,WAAI,EAAC,UAAU,EAAE,OAAO,CAAC,EAAE,IAAA,gBAAS,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,IAAA,qBAAc,EAAC,SAAS,CAAC,EAAE,IAAA,WAAI,GAAE,CAAC,CAAC;IAC5G,CAAC,CAAC;AACJ,CAAC;AARD,kCAQC;AAED,wFAAwF;AACjF,KAAK,UAAU,aAAa,CAAC,GAAoB;IACtD,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,GAAG,CAAC,SAAS,CAAC;YACZ,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE;YACzB,KAAK,EAAE,MAAM;SACd,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAPD,sCAOC;AAED,6CAA6C;AACtC,KAAK,UAAU,OAAO,CAAI,GAAuB;IACtD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,GAAG,GAAG,IAAI,KAAK,EAAK,CAAC;QAC3B,IAAA,WAAI,EAAC,GAAG,CAAC,CAAC,SAAS,CAAC;YAClB,IAAI,CAAC,IAAO;gBACV,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,CAAC;YACD,QAAQ;gBACN,OAAO,CAAC,GAAG,CAAC,CAAC;YACf,CAAC;YACD,KAAK,CAAC,MAAM;gBACV,MAAM,CAAC,MAAM,CAAC,CAAC;YACjB,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAfD,0BAeC","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 { defaultIfEmpty, from, last, scan, takeWhile } from \"rxjs\";\n\nimport type { Observable, ObservableInput, OperatorFunction } from \"rxjs\";\n\n/**\n * Applies reduce function and \"returns\" early if the predicate returns `false` for the accumulator.\n */\nexport function reduceWhile<TValue, TAccumulator>(\n predicate: (x: TAccumulator) => boolean,\n reduceFunc: (acc: TAccumulator, val: TValue) => TAccumulator,\n initial: TAccumulator,\n): OperatorFunction<TValue, TAccumulator | undefined> {\n return (obs) => {\n return obs.pipe(scan(reduceFunc, initial), takeWhile(predicate, true), defaultIfEmpty(undefined), last());\n };\n}\n\n/** Same as `firstValueFrom` except it won't throw if the observable emits no values. */\nexport async function toVoidPromise(obs: Observable<any>): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n obs.subscribe({\n complete: () => resolve(),\n error: reject,\n });\n });\n}\n\n/** Returns observable results in an array */\nexport async function collect<T>(obs: ObservableInput<T>): Promise<T[]> {\n return new Promise((resolve, reject) => {\n const arr = new Array<T>();\n from(obs).subscribe({\n next(item: T) {\n arr.push(item);\n },\n complete() {\n resolve(arr);\n },\n error(reason) {\n reject(reason);\n },\n });\n });\n}\n"]}
|
|
@@ -20,4 +20,15 @@ export type UsageTrackedFeatures = "visibility-change" | "hierarchy-level-filter
|
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
22
|
export declare function useFeatureReporting(props: UseFeatureReportingProps): UseFeatureReportingResult;
|
|
23
|
+
interface UseReportingActionProps<T> {
|
|
24
|
+
action: T;
|
|
25
|
+
featureId?: UsageTrackedFeatures;
|
|
26
|
+
reportUsage?: (props: {
|
|
27
|
+
featureId?: UsageTrackedFeatures;
|
|
28
|
+
reportInteraction: true;
|
|
29
|
+
}) => void;
|
|
30
|
+
}
|
|
31
|
+
/** @internal */
|
|
32
|
+
export declare function useReportingAction<T extends (...args: any[]) => void>({ action, featureId, reportUsage }: UseReportingActionProps<T>): (...args: Parameters<T>) => void;
|
|
33
|
+
export {};
|
|
23
34
|
//# sourceMappingURL=UseFeatureReporting.d.ts.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.useFeatureReporting = void 0;
|
|
7
|
+
exports.useReportingAction = exports.useFeatureReporting = void 0;
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
/**
|
|
10
10
|
* Enables feature reporting for a tree component.
|
|
@@ -27,4 +27,13 @@ function useFeatureReporting(props) {
|
|
|
27
27
|
return { reportUsage };
|
|
28
28
|
}
|
|
29
29
|
exports.useFeatureReporting = useFeatureReporting;
|
|
30
|
+
/** @internal */
|
|
31
|
+
// istanbul ignore next
|
|
32
|
+
function useReportingAction({ action, featureId, reportUsage }) {
|
|
33
|
+
return (0, react_1.useCallback)((...args) => {
|
|
34
|
+
reportUsage?.({ featureId, reportInteraction: true });
|
|
35
|
+
action(...args);
|
|
36
|
+
}, [action, reportUsage, featureId]);
|
|
37
|
+
}
|
|
38
|
+
exports.useReportingAction = useReportingAction;
|
|
30
39
|
//# sourceMappingURL=UseFeatureReporting.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseFeatureReporting.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/UseFeatureReporting.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAAuD;AAmBvD;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;IAChD,MAAM,gBAAgB,GAAG,IAAA,cAAM,EAAC,aAAa,CAAC,CAAC;IAE/C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,gBAAgB,CAAC,OAAO,GAAG,aAAa,CAAC;IAC3C,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,MAAM,WAAW,GAAG,IAAA,mBAAW,EAC7B,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAoE,EAAE,EAAE;QACrG,IAAI,iBAAiB,KAAK,KAAK,EAAE;YAC/B,gBAAgB,CAAC,OAAO,EAAE,CAAC,OAAO,cAAc,EAAE,CAAC,CAAC;SACrD;QACD,IAAI,SAAS,EAAE;YACb,gBAAgB,CAAC,OAAO,EAAE,CAAC,GAAG,cAAc,IAAI,SAAS,EAAE,CAAC,CAAC;SAC9D;IACH,CAAC,EACD,CAAC,cAAc,CAAC,CACjB,CAAC;IAEF,OAAO,EAAE,WAAW,EAAE,CAAC;AACzB,CAAC;AArBD,kDAqBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useEffect, useRef } from \"react\";\n\n/** @internal */\nexport interface UseFeatureReportingProps {\n treeIdentifier: string;\n onFeatureUsed?: (featureId: string) => void;\n}\n\n/** @internal */\nexport interface UseFeatureReportingResult {\n reportUsage: (props: { featureId?: UsageTrackedFeatures; reportInteraction: boolean }) => void;\n}\n\n/**\n * Features that are tracked for usage.\n * @internal\n */\nexport type UsageTrackedFeatures = \"visibility-change\" | \"hierarchy-level-filtering\" | \"filtering\" | \"hierarchy-level-size-limit-hit\" | \"zoom-to-node\";\n\n/**\n * Enables feature reporting for a tree component.\n * @internal\n */\nexport function useFeatureReporting(props: UseFeatureReportingProps): UseFeatureReportingResult {\n const { treeIdentifier, onFeatureUsed } = props;\n const onFeatureUsedRef = useRef(onFeatureUsed);\n\n useEffect(() => {\n onFeatureUsedRef.current = onFeatureUsed;\n }, [onFeatureUsed]);\n\n const reportUsage = useCallback(\n ({ featureId, reportInteraction }: { featureId?: UsageTrackedFeatures; reportInteraction: boolean }) => {\n if (reportInteraction !== false) {\n onFeatureUsedRef.current?.(`use-${treeIdentifier}`);\n }\n if (featureId) {\n onFeatureUsedRef.current?.(`${treeIdentifier}-${featureId}`);\n }\n },\n [treeIdentifier],\n );\n\n return { reportUsage };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UseFeatureReporting.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/UseFeatureReporting.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAAuD;AAmBvD;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;IAChD,MAAM,gBAAgB,GAAG,IAAA,cAAM,EAAC,aAAa,CAAC,CAAC;IAE/C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,gBAAgB,CAAC,OAAO,GAAG,aAAa,CAAC;IAC3C,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,MAAM,WAAW,GAAG,IAAA,mBAAW,EAC7B,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAoE,EAAE,EAAE;QACrG,IAAI,iBAAiB,KAAK,KAAK,EAAE;YAC/B,gBAAgB,CAAC,OAAO,EAAE,CAAC,OAAO,cAAc,EAAE,CAAC,CAAC;SACrD;QACD,IAAI,SAAS,EAAE;YACb,gBAAgB,CAAC,OAAO,EAAE,CAAC,GAAG,cAAc,IAAI,SAAS,EAAE,CAAC,CAAC;SAC9D;IACH,CAAC,EACD,CAAC,cAAc,CAAC,CACjB,CAAC;IAEF,OAAO,EAAE,WAAW,EAAE,CAAC;AACzB,CAAC;AArBD,kDAqBC;AAQD,gBAAgB;AAChB,uBAAuB;AACvB,SAAgB,kBAAkB,CAAqC,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAA8B;IACnI,OAAO,IAAA,mBAAW,EAChB,CAAC,GAAG,IAAI,EAAE,EAAE;QACV,WAAW,EAAE,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IAClB,CAAC,EACD,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,CACjC,CAAC;AACJ,CAAC;AARD,gDAQC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useEffect, useRef } from \"react\";\n\n/** @internal */\nexport interface UseFeatureReportingProps {\n treeIdentifier: string;\n onFeatureUsed?: (featureId: string) => void;\n}\n\n/** @internal */\nexport interface UseFeatureReportingResult {\n reportUsage: (props: { featureId?: UsageTrackedFeatures; reportInteraction: boolean }) => void;\n}\n\n/**\n * Features that are tracked for usage.\n * @internal\n */\nexport type UsageTrackedFeatures = \"visibility-change\" | \"hierarchy-level-filtering\" | \"filtering\" | \"hierarchy-level-size-limit-hit\" | \"zoom-to-node\";\n\n/**\n * Enables feature reporting for a tree component.\n * @internal\n */\nexport function useFeatureReporting(props: UseFeatureReportingProps): UseFeatureReportingResult {\n const { treeIdentifier, onFeatureUsed } = props;\n const onFeatureUsedRef = useRef(onFeatureUsed);\n\n useEffect(() => {\n onFeatureUsedRef.current = onFeatureUsed;\n }, [onFeatureUsed]);\n\n const reportUsage = useCallback(\n ({ featureId, reportInteraction }: { featureId?: UsageTrackedFeatures; reportInteraction: boolean }) => {\n if (reportInteraction !== false) {\n onFeatureUsedRef.current?.(`use-${treeIdentifier}`);\n }\n if (featureId) {\n onFeatureUsedRef.current?.(`${treeIdentifier}-${featureId}`);\n }\n },\n [treeIdentifier],\n );\n\n return { reportUsage };\n}\n\ninterface UseReportingActionProps<T> {\n action: T;\n featureId?: UsageTrackedFeatures;\n reportUsage?: (props: { featureId?: UsageTrackedFeatures; reportInteraction: true }) => void;\n}\n\n/** @internal */\n// istanbul ignore next\nexport function useReportingAction<T extends (...args: any[]) => void>({ action, featureId, reportUsage }: UseReportingActionProps<T>) {\n return useCallback<(...args: Parameters<T>) => void>(\n (...args) => {\n reportUsage?.({ featureId, reportInteraction: true });\n action(...args);\n },\n [action, reportUsage, featureId],\n );\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface UseFilteringResult {
|
|
2
|
+
filter: string;
|
|
3
|
+
activeMatchIndex: number;
|
|
4
|
+
totalMatches: number;
|
|
5
|
+
applyFilter: (filter: string) => void;
|
|
6
|
+
clearFilter: () => void;
|
|
7
|
+
onHighlightChanged: (index: number, matches?: number) => void;
|
|
8
|
+
}
|
|
9
|
+
/** @internal */
|
|
10
|
+
export declare function useFiltering(): UseFilteringResult;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=UseFiltering.d.ts.map
|