@itwin/tree-widget-react 4.0.0-alpha.2 → 4.0.0-alpha.4
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 +34 -1
- package/README.md +1 -3
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js +3 -2
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/ErrorState.js +2 -2
- package/lib/esm/tree-widget-react/components/tree-header/ErrorState.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/SearchBox.js +4 -4
- package/lib/esm/tree-widget-react/components/tree-header/SearchBox.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/SelectableTree.css +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +6 -6
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +10 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +246 -129
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +69 -20
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +54 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +280 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNode.d.ts +26 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNode.js +23 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNode.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/{CategoriesVisibilityHandler.d.ts → internal/CategoriesVisibilityHandler.d.ts} +18 -9
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +214 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/ClassNameDefinitions.d.ts +7 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/ClassNameDefinitions.js +11 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/ClassNameDefinitions.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.d.ts +0 -4
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContext.d.ts +28 -4
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContext.js +73 -2
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContext.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js +3 -4
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.css +2 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js +6 -6
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js +9 -9
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +15 -15
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/index.d.ts +1 -0
- package/lib/esm/tree-widget-react/components/trees/index.js +1 -0
- package/lib/esm/tree-widget-react/components/trees/index.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +12 -12
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.d.ts +6 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js +7 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +11 -11
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +5 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +45 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +2 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +128 -38
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/public/locales/en/TreeWidget.json +15 -4
- package/package.json +8 -11
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesVisibilityHandler.js +0 -87
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesVisibilityHandler.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContextProvider.d.ts +0 -7
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContextProvider.js +0 -66
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContextProvider.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/Tree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAwDvD;;;GAGG;AACH,MAAM,UAAU,IAAI,CAAC,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAAG,K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B,KAAC,eAAe,KAAG,GACX,IACN,GAC0B,CACnC,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAAC,EAC7B,MAAM,EACN,SAAS,EACT,OAAO,GAKR;IACC,OAAO,WAAW,CAChB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,CACtB,MAAM,CACJ,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;QACxB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAC7B,OAAO,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC,EACF,UAAU,CACX,EACH,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAC7B,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useMemo, useState } from \"react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { Spinner } from \"@itwin/itwinui-react/bricks\";\nimport { SchemaMetadataContextProvider } from \"@itwin/presentation-components\";\nimport { useIModelUnifiedSelectionTree } from \"@itwin/presentation-hierarchies-react\";\nimport { UnifiedSelectionContextProvider } from \"@itwin/unified-selection-react\";\nimport { useHierarchiesLocalization } from \"../UseHierarchiesLocalization.js\";\nimport { useHierarchyLevelFiltering } from \"../UseHierarchyFiltering.js\";\nimport { useIModelChangeListener } from \"../UseIModelChangeListener.js\";\nimport { useNodeHighlighting } from \"../UseNodeHighlighting.js\";\nimport { useReportingAction, useTelemetryContext } from \"../UseTelemetryContext.js\";\nimport { createIModelAccess } from \"../Utils.js\";\nimport { Delayed } from \"./Delayed.js\";\nimport { EmptyTreeContent } from \"./EmptyTreeContent.js\";\nimport { ProgressOverlay } from \"./ProgressOverlay.js\";\n\nimport type { BaseTreeRendererProps } from \"./BaseTreeRenderer.js\";\nimport type { MarkRequired } from \"@itwin/core-bentley\";\nimport type { FunctionProps } from \"../Utils.js\";\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport type { PresentationHierarchyNode, SelectionStorage, useIModelTree, useSelectionHandler } from \"@itwin/presentation-hierarchies-react\";\nimport type { HighlightInfo } from \"../UseNodeHighlighting.js\";\n\n/** @beta */\nexport type TreeProps = Pick<FunctionProps<typeof useIModelTree>, \"getFilteredPaths\" | \"getHierarchyDefinition\"> &\n Partial<Pick<FunctionProps<typeof useSelectionHandler>, \"selectionMode\">> & {\n /** iModel connection that should be used to pull data from. */\n imodel: IModelConnection;\n /** Callback for getting `SchemaContext` for specific iModel. */\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\n /** Unique tree component name that will be used as unified selection change event source when selecting node. */\n treeName: string;\n /** Unified selection storage that should be used by tree to handle tree selection changes. */\n selectionStorage: SelectionStorage;\n /**\n * An optional predicate to allow or prohibit selection of a node.\n * When not supplied, all nodes are selectable.\n */\n selectionPredicate?: (node: PresentationHierarchyNode) => boolean;\n /** Tree renderer that should be used to render tree data. */\n treeRenderer: (\n treeProps: Required<\n Pick<\n BaseTreeRendererProps,\n | \"rootNodes\"\n | \"expandNode\"\n | \"getLabel\"\n | \"onFilterClick\"\n | \"selectNodes\"\n | \"selectionMode\"\n | \"isNodeSelected\"\n | \"getHierarchyLevelDetails\"\n | \"getLabel\"\n >\n >,\n ) => ReactNode;\n /** Custom iModel access that is stored outside tree component. If not provided it new iModel access will be created using `imodel` prop. */\n imodelAccess?: FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n /** Size limit that should be applied on each hierarchy level. Default to `1000`. */\n hierarchyLevelSizeLimit?: number;\n /** Component that should be renderer if there are no tree nodes. */\n emptyTreeContent?: ReactNode;\n /** Callback that this invoked when tree reloads. */\n onReload?: () => void;\n /** Options for highlighting node labels. */\n highlight?: HighlightInfo;\n };\n\n/**\n * Default tree component that manages tree state and renders using supplied `treeRenderer`.\n * @Beta\n */\nexport function Tree({ getSchemaContext, hierarchyLevelSizeLimit, selectionStorage, imodelAccess: providedIModelAccess, ...props }: TreeProps) {\n const defaultHierarchyLevelSizeLimit = hierarchyLevelSizeLimit ?? 1000;\n\n const imodelAccess = useMemo(() => {\n return providedIModelAccess ?? createIModelAccess({ getSchemaContext, imodel: props.imodel });\n }, [providedIModelAccess, getSchemaContext, props.imodel]);\n\n return (\n <SchemaMetadataContextProvider imodel={props.imodel} schemaContextProvider={getSchemaContext}>\n <TreeImpl {...props} selectionStorage={selectionStorage} imodelAccess={imodelAccess} defaultHierarchyLevelSizeLimit={defaultHierarchyLevelSizeLimit} />\n </SchemaMetadataContextProvider>\n );\n}\n\nfunction TreeImpl({\n imodel,\n imodelAccess,\n treeName,\n emptyTreeContent,\n getFilteredPaths,\n defaultHierarchyLevelSizeLimit,\n getHierarchyDefinition,\n selectionPredicate,\n selectionMode,\n onReload,\n treeRenderer,\n selectionStorage,\n highlight,\n}: MarkRequired<Omit<TreeProps, \"getSchemaContext\">, \"imodelAccess\"> & { defaultHierarchyLevelSizeLimit: number }) {\n const localizedStrings = useHierarchiesLocalization();\n const { onFeatureUsed, onPerformanceMeasured } = useTelemetryContext();\n const [imodelChanged] = useState(new BeEvent<() => void>());\n const {\n rootNodes,\n getNode,\n isLoading,\n selectNodes: selectNodesAction,\n setFormatter: _setFormatter,\n expandNode,\n ...treeProps\n } = useIModelUnifiedSelectionTree({\n imodelAccess,\n imodelChanged,\n selectionStorage,\n getHierarchyDefinition,\n getFilteredPaths,\n sourceName: treeName,\n localizedStrings,\n onPerformanceMeasured: (action, duration) => {\n if (action === \"reload\") {\n onReload?.();\n }\n onPerformanceMeasured(action, duration);\n },\n onHierarchyLimitExceeded: () => onFeatureUsed({ featureId: \"hierarchy-level-size-limit-hit\", reportInteraction: false }),\n onHierarchyLoadError: ({ type, error }) => {\n // eslint-disable-next-line no-console\n console.error(error);\n onFeatureUsed({ featureId: `error-${type}`, reportInteraction: false });\n },\n });\n useIModelChangeListener({ imodel, action: useCallback(() => imodelChanged.raiseEvent(), [imodelChanged]) });\n\n const selectNodes = useSelectionPredicate({\n action: useReportingAction({ action: selectNodesAction }),\n predicate: selectionPredicate,\n getNode,\n });\n const { filteringDialog, onFilterClick } = useHierarchyLevelFiltering({\n imodel,\n defaultHierarchyLevelSizeLimit,\n });\n const reportingExpandNode = useReportingAction({ action: expandNode });\n const reportingOnFilterClicked = useReportingAction({ action: onFilterClick });\n const { getLabel } = useNodeHighlighting({ rootNodes, highlight });\n\n if (rootNodes === undefined) {\n return (\n <div style={{ display: \"flex\", alignItems: \"center\", justifyContent: \"center\", flexDirection: \"column\", width: \"100%\", height: \"100%\" }}>\n <Delayed show={true}>\n <Spinner />\n </Delayed>\n </div>\n );\n }\n\n if (rootNodes.length === 0 && !isLoading) {\n return (\n <div style={{ display: \"flex\", alignItems: \"center\", justifyContent: \"center\", flexDirection: \"column\", width: \"100%\", height: \"100%\" }}>\n {emptyTreeContent ? emptyTreeContent : <EmptyTreeContent />}\n </div>\n );\n }\n\n const treeRendererProps: FunctionProps<TreeProps[\"treeRenderer\"]> = {\n ...treeProps,\n rootNodes,\n selectionMode: selectionMode ?? \"single\",\n selectNodes,\n expandNode: reportingExpandNode,\n onFilterClick: reportingOnFilterClicked,\n getLabel,\n };\n\n return (\n <UnifiedSelectionContextProvider storage={selectionStorage}>\n <div style={{ position: \"relative\", height: \"100%\", overflow: \"hidden\" }}>\n <div id=\"tw-tree-renderer-container\" style={{ overflow: \"auto\", height: \"100%\" }}>\n {treeRenderer(treeRendererProps)}\n {filteringDialog}\n </div>\n <Delayed show={isLoading}>\n <ProgressOverlay />\n </Delayed>\n </div>\n </UnifiedSelectionContextProvider>\n );\n}\n\nfunction useSelectionPredicate({\n action,\n predicate,\n getNode,\n}: {\n action: (...args: any[]) => void;\n predicate?: (node: PresentationHierarchyNode) => boolean;\n getNode: (nodeId: string) => PresentationHierarchyNode | undefined;\n}): ReturnType<typeof useIModelUnifiedSelectionTree>[\"selectNodes\"] {\n return useCallback(\n (nodeIds, changeType) =>\n action(\n nodeIds.filter((nodeId) => {\n const node = getNode(nodeId);\n return node && (!predicate || predicate(node));\n }),\n changeType,\n ),\n [action, getNode, predicate],\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/Tree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAwDvD;;;GAGG;AACH,MAAM,UAAU,IAAI,CAAC,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAAG,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,CAAC;AAED,SAAS,qBAAqB,CAAC,EAC7B,MAAM,EACN,SAAS,EACT,OAAO,GAKR;IACC,OAAO,WAAW,CAChB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,CACtB,MAAM,CACJ,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;QACxB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAC7B,OAAO,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC,EACF,UAAU,CACX,EACH,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAC7B,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useMemo, useState } from \"react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { Spinner } from \"@itwin/itwinui-react/bricks\";\nimport { SchemaMetadataContextProvider } from \"@itwin/presentation-components\";\nimport { useIModelUnifiedSelectionTree } from \"@itwin/presentation-hierarchies-react\";\nimport { useHierarchiesLocalization } from \"../UseHierarchiesLocalization.js\";\nimport { useHierarchyLevelFiltering } from \"../UseHierarchyFiltering.js\";\nimport { useIModelChangeListener } from \"../UseIModelChangeListener.js\";\nimport { useNodeHighlighting } from \"../UseNodeHighlighting.js\";\nimport { useReportingAction, useTelemetryContext } from \"../UseTelemetryContext.js\";\nimport { createIModelAccess } from \"../Utils.js\";\nimport { Delayed } from \"./Delayed.js\";\nimport { EmptyTreeContent } from \"./EmptyTreeContent.js\";\nimport { ProgressOverlay } from \"./ProgressOverlay.js\";\n\nimport type { BaseTreeRendererProps } from \"./BaseTreeRenderer.js\";\nimport type { MarkRequired } from \"@itwin/core-bentley\";\nimport type { FunctionProps } from \"../Utils.js\";\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport type { PresentationHierarchyNode, SelectionStorage, useIModelTree, useSelectionHandler } from \"@itwin/presentation-hierarchies-react\";\nimport type { HighlightInfo } from \"../UseNodeHighlighting.js\";\n\n/** @beta */\nexport type TreeProps = Pick<FunctionProps<typeof useIModelTree>, \"getFilteredPaths\" | \"getHierarchyDefinition\"> &\n Partial<Pick<FunctionProps<typeof useSelectionHandler>, \"selectionMode\">> & {\n /** iModel connection that should be used to pull data from. */\n imodel: IModelConnection;\n /** Callback for getting `SchemaContext` for specific iModel. */\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\n /** Unique tree component name that will be used as unified selection change event source when selecting node. */\n treeName: string;\n /** Unified selection storage that should be used by tree to handle tree selection changes. */\n selectionStorage: SelectionStorage;\n /**\n * An optional predicate to allow or prohibit selection of a node.\n * When not supplied, all nodes are selectable.\n */\n selectionPredicate?: (node: PresentationHierarchyNode) => boolean;\n /** Tree renderer that should be used to render tree data. */\n treeRenderer: (\n treeProps: Required<\n Pick<\n BaseTreeRendererProps,\n | \"rootNodes\"\n | \"expandNode\"\n | \"getLabel\"\n | \"onFilterClick\"\n | \"selectNodes\"\n | \"selectionMode\"\n | \"isNodeSelected\"\n | \"getHierarchyLevelDetails\"\n | \"getLabel\"\n >\n >,\n ) => ReactNode;\n /** Custom iModel access that is stored outside tree component. If not provided it new iModel access will be created using `imodel` prop. */\n imodelAccess?: FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n /** Size limit that should be applied on each hierarchy level. Default to `1000`. */\n hierarchyLevelSizeLimit?: number;\n /** Component that should be renderer if there are no tree nodes. */\n emptyTreeContent?: ReactNode;\n /** Callback that this invoked when tree reloads. */\n onReload?: () => void;\n /** Options for highlighting node labels. */\n highlight?: HighlightInfo;\n };\n\n/**\n * Default tree component that manages tree state and renders using supplied `treeRenderer`.\n * @beta\n */\nexport function Tree({ getSchemaContext, hierarchyLevelSizeLimit, selectionStorage, imodelAccess: providedIModelAccess, ...props }: TreeProps) {\n const defaultHierarchyLevelSizeLimit = hierarchyLevelSizeLimit ?? 1000;\n\n const imodelAccess = useMemo(() => {\n return providedIModelAccess ?? createIModelAccess({ getSchemaContext, imodel: props.imodel });\n }, [providedIModelAccess, getSchemaContext, props.imodel]);\n\n return (\n <SchemaMetadataContextProvider imodel={props.imodel} schemaContextProvider={getSchemaContext}>\n <TreeImpl {...props} selectionStorage={selectionStorage} imodelAccess={imodelAccess} defaultHierarchyLevelSizeLimit={defaultHierarchyLevelSizeLimit} />\n </SchemaMetadataContextProvider>\n );\n}\n\nfunction TreeImpl({\n imodel,\n imodelAccess,\n treeName,\n emptyTreeContent,\n getFilteredPaths,\n defaultHierarchyLevelSizeLimit,\n getHierarchyDefinition,\n selectionPredicate,\n selectionMode,\n onReload,\n treeRenderer,\n selectionStorage,\n highlight,\n}: MarkRequired<Omit<TreeProps, \"getSchemaContext\">, \"imodelAccess\"> & { defaultHierarchyLevelSizeLimit: number }) {\n const localizedStrings = useHierarchiesLocalization();\n const { onFeatureUsed, onPerformanceMeasured } = useTelemetryContext();\n const [imodelChanged] = useState(new BeEvent<() => void>());\n const {\n rootNodes,\n getNode,\n isLoading,\n selectNodes: selectNodesAction,\n setFormatter: _setFormatter,\n expandNode,\n ...treeProps\n } = useIModelUnifiedSelectionTree({\n imodelAccess,\n imodelChanged,\n getHierarchyDefinition,\n getFilteredPaths,\n sourceName: treeName,\n localizedStrings,\n selectionStorage,\n onPerformanceMeasured: (action, duration) => {\n if (action === \"reload\") {\n onReload?.();\n }\n onPerformanceMeasured(action, duration);\n },\n onHierarchyLimitExceeded: () => onFeatureUsed({ featureId: \"hierarchy-level-size-limit-hit\", reportInteraction: false }),\n onHierarchyLoadError: ({ type, error }) => {\n // eslint-disable-next-line no-console\n console.error(error);\n onFeatureUsed({ featureId: `error-${type}`, reportInteraction: false });\n },\n });\n useIModelChangeListener({ imodel, action: useCallback(() => imodelChanged.raiseEvent(), [imodelChanged]) });\n\n const selectNodes = useSelectionPredicate({\n action: useReportingAction({ action: selectNodesAction }),\n predicate: selectionPredicate,\n getNode,\n });\n const { filteringDialog, onFilterClick } = useHierarchyLevelFiltering({\n imodel,\n defaultHierarchyLevelSizeLimit,\n });\n const reportingExpandNode = useReportingAction({ action: expandNode });\n const reportingOnFilterClicked = useReportingAction({ action: onFilterClick });\n const { getLabel } = useNodeHighlighting({ rootNodes, highlight });\n\n if (rootNodes === undefined) {\n return (\n <div style={{ display: \"flex\", alignItems: \"center\", justifyContent: \"center\", flexDirection: \"column\", width: \"100%\", height: \"100%\" }}>\n <Delayed show={true}>\n <Spinner />\n </Delayed>\n </div>\n );\n }\n\n if (rootNodes.length === 0 && !isLoading) {\n return (\n <div style={{ display: \"flex\", alignItems: \"center\", justifyContent: \"center\", flexDirection: \"column\", width: \"100%\", height: \"100%\" }}>\n {emptyTreeContent ? emptyTreeContent : <EmptyTreeContent />}\n </div>\n );\n }\n\n const treeRendererProps: FunctionProps<TreeProps[\"treeRenderer\"]> = {\n ...treeProps,\n rootNodes,\n selectionMode: selectionMode ?? \"single\",\n selectNodes,\n expandNode: reportingExpandNode,\n onFilterClick: reportingOnFilterClicked,\n getLabel,\n };\n\n return (\n <div style={{ position: \"relative\", height: \"100%\", overflow: \"hidden\" }}>\n <div id=\"tw-tree-renderer-container\" style={{ overflow: \"auto\", height: \"100%\" }}>\n {treeRenderer(treeRendererProps)}\n {filteringDialog}\n </div>\n <Delayed show={isLoading}>\n <ProgressOverlay />\n </Delayed>\n </div>\n );\n}\n\nfunction useSelectionPredicate({\n action,\n predicate,\n getNode,\n}: {\n action: (...args: any[]) => void;\n predicate?: (node: PresentationHierarchyNode) => boolean;\n getNode: (nodeId: string) => PresentationHierarchyNode | undefined;\n}): ReturnType<typeof useIModelUnifiedSelectionTree>[\"selectNodes\"] {\n return useCallback(\n (nodeIds, changeType) =>\n action(\n nodeIds.filter((nodeId) => {\n const node = getNode(nodeId);\n return node && (!predicate || predicate(node));\n }),\n changeType,\n ),\n [action, getNode, predicate],\n );\n}\n"]}
|
package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.css
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
|
|
6
|
-
.tw-tree-node-visibility-button-hidden,
|
|
6
|
+
.tw-tree-node-visibility-button-hidden,
|
|
7
|
+
.tw-tree-node-visibility-button-partial {
|
|
7
8
|
visibility: visible;
|
|
8
9
|
}
|
package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import "./TreeNodeVisibilityButton.css";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import visibilityHideSvg from "@itwin/itwinui-icons/visibility-hide.svg";
|
|
7
|
+
import visibilityPartialSvg from "@itwin/itwinui-icons/visibility-partial.svg";
|
|
8
|
+
import visibilityShowSvg from "@itwin/itwinui-icons/visibility-show.svg";
|
|
9
9
|
/** @internal */
|
|
10
10
|
export function createVisibilityAction({ getVisibilityButtonState, onVisibilityButtonClick, }) {
|
|
11
11
|
return (node) => {
|
|
@@ -13,11 +13,11 @@ export function createVisibilityAction({ getVisibilityButtonState, onVisibilityB
|
|
|
13
13
|
const getIcon = () => {
|
|
14
14
|
switch (state.state) {
|
|
15
15
|
case "visible":
|
|
16
|
-
return
|
|
16
|
+
return visibilityShowSvg;
|
|
17
17
|
case "hidden":
|
|
18
|
-
return
|
|
18
|
+
return visibilityHideSvg;
|
|
19
19
|
case "partial":
|
|
20
|
-
return
|
|
20
|
+
return visibilityPartialSvg;
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
return {
|
package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeVisibilityButton.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"TreeNodeVisibilityButton.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,gCAAgC,CAAC;AACxC,OAAO,iBAAiB,MAAM,0CAA0C,CAAC;AACzE,OAAO,oBAAoB,MAAM,6CAA6C,CAAC;AAC/E,OAAO,iBAAiB,MAAM,0CAA0C,CAAC;AAsBzE,gBAAgB;AAChB,MAAM,UAAU,sBAAsB,CAAC,EACrC,wBAAwB,EACxB,uBAAuB,GACO;IAC9B,OAAO,CAAC,IAAI,EAAE,EAAE;QACd,MAAM,KAAK,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;QAE7C,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,QAAQ,KAAK,CAAC,KAAK,EAAE;gBACnB,KAAK,SAAS;oBACZ,OAAO,iBAAiB,CAAC;gBAC3B,KAAK,QAAQ;oBACX,OAAO,iBAAiB,CAAC;gBAC3B,KAAK,SAAS;oBACZ,OAAO,oBAAoB,CAAC;aAC/B;QACH,CAAC,CAAC;QACF,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,OAAO,IAAI,2BAA2B;YACnD,MAAM,EAAE,GAAG,EAAE;gBACX,uBAAuB,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;YAC7C,CAAC;YACD,IAAI,EAAE,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;YAClD,IAAI,EAAE,OAAO,EAAE;SAChB,CAAC;IACJ,CAAC,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 \"./TreeNodeVisibilityButton.css\";\nimport visibilityHideSvg from \"@itwin/itwinui-icons/visibility-hide.svg\";\nimport visibilityPartialSvg from \"@itwin/itwinui-icons/visibility-partial.svg\";\nimport visibilityShowSvg from \"@itwin/itwinui-icons/visibility-show.svg\";\n\nimport type { PresentationHierarchyNode, TreeItemAction } from \"@itwin/presentation-hierarchies-react\";\n\n/**\n * Data structure that describes tree node checkbox state.\n * @beta\n */\ninterface TreeItemVisibilityButtonState {\n state: \"visible\" | \"partial\" | \"hidden\";\n isDisabled?: boolean;\n tooltip?: string;\n}\n\n/** @beta */\nexport interface TreeItemVisibilityButtonProps {\n /** Callback that should be invoked when checkbox is clicked. */\n onVisibilityButtonClick: (node: PresentationHierarchyNode, state: TreeItemVisibilityButtonState[\"state\"]) => void;\n /** Callback that should be used to determine current checkbox state. */\n getVisibilityButtonState: (node: PresentationHierarchyNode) => TreeItemVisibilityButtonState;\n}\n\n/** @internal */\nexport function createVisibilityAction({\n getVisibilityButtonState,\n onVisibilityButtonClick,\n}: TreeItemVisibilityButtonProps): (node: PresentationHierarchyNode) => TreeItemAction {\n return (node) => {\n const state = getVisibilityButtonState(node);\n\n const getIcon = () => {\n switch (state.state) {\n case \"visible\":\n return visibilityShowSvg;\n case \"hidden\":\n return visibilityHideSvg;\n case \"partial\":\n return visibilityPartialSvg;\n }\n };\n return {\n label: state.tooltip ?? \"Determining visibility...\",\n action: () => {\n onVisibilityButtonClick(node, state.state);\n },\n show: state.state !== \"visible\" ? true : undefined,\n icon: getIcon(),\n };\n };\n}\n"]}
|
package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js
CHANGED
|
@@ -3,6 +3,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
import classSvg from "@itwin/itwinui-icons/bis-class.svg";
|
|
7
|
+
import elementSvg from "@itwin/itwinui-icons/bis-element.svg";
|
|
8
|
+
import documentSvg from "@itwin/itwinui-icons/document.svg";
|
|
9
|
+
import ecSchemaSvg from "@itwin/itwinui-icons/selection-children.svg";
|
|
6
10
|
import { EmptyTreeContent } from "../common/components/EmptyTreeContent.js";
|
|
7
11
|
import { Tree } from "../common/components/Tree.js";
|
|
8
12
|
import { TreeRenderer } from "../common/components/TreeRenderer.js";
|
|
@@ -10,28 +14,24 @@ import { ExternalSourcesTreeComponent } from "./ExternalSourcesTreeComponent.js"
|
|
|
10
14
|
import { ExternalSourcesTreeDefinition } from "./ExternalSourcesTreeDefinition.js";
|
|
11
15
|
/** @beta */
|
|
12
16
|
export function ExternalSourcesTree(props) {
|
|
13
|
-
return (_jsx(Tree, { emptyTreeContent: _jsx(EmptyTreeContent, { icon:
|
|
17
|
+
return (_jsx(Tree, { emptyTreeContent: _jsx(EmptyTreeContent, { icon: documentSvg }), ...props, treeName: ExternalSourcesTreeComponent.id, getHierarchyDefinition: getDefinitionsProvider, selectionMode: props.selectionMode ?? "none", treeRenderer: (treeProps) => _jsx(TreeRenderer, { ...treeProps, getIcon: getIcon }) }));
|
|
14
18
|
}
|
|
15
19
|
const getDefinitionsProvider = (props) => {
|
|
16
20
|
return new ExternalSourcesTreeDefinition(props);
|
|
17
21
|
};
|
|
18
|
-
const ecSchemaIcon = new URL("@itwin/itwinui-icons/selection-children.svg", import.meta.url).href;
|
|
19
|
-
const elementIcon = new URL("@itwin/itwinui-icons/tree-element.svg", import.meta.url).href;
|
|
20
|
-
const documentIcon = new URL("@itwin/itwinui-icons/document-reference.svg", import.meta.url).href;
|
|
21
|
-
const classIcon = new URL("@itwin/itwinui-icons/tree-class.svg", import.meta.url).href;
|
|
22
22
|
function getIcon(node) {
|
|
23
23
|
if (node.extendedData?.imageId === undefined) {
|
|
24
24
|
return undefined;
|
|
25
25
|
}
|
|
26
26
|
switch (node.extendedData.imageId) {
|
|
27
27
|
case "icon-item":
|
|
28
|
-
return
|
|
28
|
+
return elementSvg;
|
|
29
29
|
case "icon-ec-class":
|
|
30
|
-
return
|
|
30
|
+
return classSvg;
|
|
31
31
|
case "icon-document":
|
|
32
|
-
return
|
|
32
|
+
return documentSvg;
|
|
33
33
|
case "icon-ec-schema":
|
|
34
|
-
return
|
|
34
|
+
return ecSchemaSvg;
|
|
35
35
|
}
|
|
36
36
|
return undefined;
|
|
37
37
|
}
|
package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExternalSourcesTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;
|
|
1
|
+
{"version":3,"file":"ExternalSourcesTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,QAAQ,MAAM,oCAAoC,CAAC;AAC1D,OAAO,UAAU,MAAM,sCAAsC,CAAC;AAC9D,OAAO,WAAW,MAAM,mCAAmC,CAAC;AAC5D,OAAO,WAAW,MAAM,6CAA6C,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAcnF,YAAY;AACZ,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,OAAO,CACL,KAAC,IAAI,IACH,gBAAgB,EAAE,KAAC,gBAAgB,IAAC,IAAI,EAAE,WAAW,GAAI,KACrD,KAAK,EACT,QAAQ,EAAE,4BAA4B,CAAC,EAAE,EACzC,sBAAsB,EAAE,sBAAsB,EAC9C,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,MAAM,EAC5C,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,KAAC,YAAY,OAAK,SAAS,EAAE,OAAO,EAAE,OAAO,GAAI,GAC9E,CACH,CAAC;AACJ,CAAC;AAED,MAAM,sBAAsB,GAAwC,CAAC,KAAK,EAAE,EAAE;IAC5E,OAAO,IAAI,6BAA6B,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,SAAS,OAAO,CAAC,IAA+B;IAC9C,IAAI,IAAI,CAAC,YAAY,EAAE,OAAO,KAAK,SAAS,EAAE;QAC5C,OAAO,SAAS,CAAC;KAClB;IAED,QAAQ,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;QACjC,KAAK,WAAW;YACd,OAAO,UAAU,CAAC;QACpB,KAAK,eAAe;YAClB,OAAO,QAAQ,CAAC;QAClB,KAAK,eAAe;YAClB,OAAO,WAAW,CAAC;QACrB,KAAK,gBAAgB;YACnB,OAAO,WAAW,CAAC;KACtB;IAED,OAAO,SAAS,CAAC;AACnB,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 classSvg from \"@itwin/itwinui-icons/bis-class.svg\";\nimport elementSvg from \"@itwin/itwinui-icons/bis-element.svg\";\nimport documentSvg from \"@itwin/itwinui-icons/document.svg\";\nimport ecSchemaSvg from \"@itwin/itwinui-icons/selection-children.svg\";\nimport { EmptyTreeContent } from \"../common/components/EmptyTreeContent.js\";\nimport { Tree } from \"../common/components/Tree.js\";\nimport { TreeRenderer } from \"../common/components/TreeRenderer.js\";\nimport { ExternalSourcesTreeComponent } from \"./ExternalSourcesTreeComponent.js\";\nimport { ExternalSourcesTreeDefinition } from \"./ExternalSourcesTreeDefinition.js\";\n\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { BaseTreeRendererProps } from \"../common/components/BaseTreeRenderer.js\";\nimport type { TreeProps } from \"../common/components/Tree.js\";\n\n/** @beta */\nexport type ExternalSourcesTreeProps = Pick<TreeProps, \"imodel\" | \"getSchemaContext\" | \"selectionStorage\" | \"selectionMode\" | \"emptyTreeContent\"> &\n Pick<BaseTreeRendererProps, \"actions\"> & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n };\n\n/** @beta */\nexport function ExternalSourcesTree(props: ExternalSourcesTreeProps) {\n return (\n <Tree\n emptyTreeContent={<EmptyTreeContent icon={documentSvg} />}\n {...props}\n treeName={ExternalSourcesTreeComponent.id}\n getHierarchyDefinition={getDefinitionsProvider}\n selectionMode={props.selectionMode ?? \"none\"}\n treeRenderer={(treeProps) => <TreeRenderer {...treeProps} getIcon={getIcon} />}\n />\n );\n}\n\nconst getDefinitionsProvider: TreeProps[\"getHierarchyDefinition\"] = (props) => {\n return new ExternalSourcesTreeDefinition(props);\n};\n\nfunction getIcon(node: PresentationHierarchyNode): string | undefined {\n if (node.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n switch (node.extendedData.imageId) {\n case \"icon-item\":\n return elementSvg;\n case \"icon-ec-class\":\n return classSvg;\n case \"icon-document\":\n return documentSvg;\n case \"icon-ec-schema\":\n return ecSchemaSvg;\n }\n\n return undefined;\n}\n"]}
|
|
@@ -3,6 +3,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
import categorySvg from "@itwin/itwinui-icons/bis-category-3d.svg";
|
|
7
|
+
import classSvg from "@itwin/itwinui-icons/bis-class.svg";
|
|
8
|
+
import elementSvg from "@itwin/itwinui-icons/bis-element.svg";
|
|
9
|
+
import subjectSvg from "@itwin/itwinui-icons/bis-subject.svg";
|
|
10
|
+
import groupSvg from "@itwin/itwinui-icons/group.svg";
|
|
11
|
+
import modelSvg from "@itwin/itwinui-icons/model-cube.svg";
|
|
12
|
+
import hierarchyTreeSvg from "@itwin/itwinui-icons/selection-children.svg";
|
|
6
13
|
import { EmptyTreeContent } from "../common/components/EmptyTreeContent.js";
|
|
7
14
|
import { Tree } from "../common/components/Tree.js";
|
|
8
15
|
import { TreeRenderer } from "../common/components/TreeRenderer.js";
|
|
@@ -11,7 +18,7 @@ import { IModelContentTreeDefinition } from "./IModelContentTreeDefinition.js";
|
|
|
11
18
|
import { IModelContentTreeIdsCache } from "./internal/IModelContentTreeIdsCache.js";
|
|
12
19
|
/** @beta */
|
|
13
20
|
export function IModelContentTree(props) {
|
|
14
|
-
return (_jsx(Tree, { emptyTreeContent: _jsx(EmptyTreeContent, { icon:
|
|
21
|
+
return (_jsx(Tree, { emptyTreeContent: _jsx(EmptyTreeContent, { icon: modelSvg }), ...props, treeName: IModelContentTreeComponent.id, getHierarchyDefinition: getDefinitionsProvider, selectionMode: props.selectionMode ?? "extended", treeRenderer: (treeProps) => _jsx(TreeRenderer, { ...treeProps, getIcon: getIcon }) }));
|
|
15
22
|
}
|
|
16
23
|
const getDefinitionsProvider = ({ imodelAccess }) => {
|
|
17
24
|
return new IModelContentTreeDefinition({
|
|
@@ -19,32 +26,25 @@ const getDefinitionsProvider = ({ imodelAccess }) => {
|
|
|
19
26
|
idsCache: new IModelContentTreeIdsCache(imodelAccess),
|
|
20
27
|
});
|
|
21
28
|
};
|
|
22
|
-
const subjectIcon = new URL("@itwin/itwinui-icons/tree-subject.svg", import.meta.url).href;
|
|
23
|
-
const classIcon = new URL("@itwin/itwinui-icons/tree-class.svg", import.meta.url).href;
|
|
24
|
-
const modelIcon = new URL("@itwin/itwinui-icons/model-cube.svg", import.meta.url).href;
|
|
25
|
-
const categoryIcon = new URL("@itwin/itwinui-icons/tree-category.svg", import.meta.url).href;
|
|
26
|
-
const elementIcon = new URL("@itwin/itwinui-icons/tree-element.svg", import.meta.url).href;
|
|
27
|
-
const hierarchyTreeIcon = new URL("@itwin/itwinui-icons/selection-children.svg", import.meta.url).href;
|
|
28
|
-
const groupIcon = new URL("@itwin/itwinui-icons/group.svg", import.meta.url).href;
|
|
29
29
|
function getIcon(node) {
|
|
30
30
|
if (node.extendedData?.imageId === undefined) {
|
|
31
31
|
return undefined;
|
|
32
32
|
}
|
|
33
33
|
switch (node.extendedData.imageId) {
|
|
34
34
|
case "icon-layers":
|
|
35
|
-
return
|
|
35
|
+
return categorySvg;
|
|
36
36
|
case "icon-item":
|
|
37
|
-
return
|
|
37
|
+
return elementSvg;
|
|
38
38
|
case "icon-ec-class":
|
|
39
|
-
return
|
|
39
|
+
return classSvg;
|
|
40
40
|
case "icon-folder":
|
|
41
|
-
return
|
|
41
|
+
return subjectSvg;
|
|
42
42
|
case "icon-model":
|
|
43
|
-
return
|
|
43
|
+
return modelSvg;
|
|
44
44
|
case "icon-hierarchy-tree":
|
|
45
|
-
return
|
|
45
|
+
return hierarchyTreeSvg;
|
|
46
46
|
case "icon-group":
|
|
47
|
-
return
|
|
47
|
+
return groupSvg;
|
|
48
48
|
}
|
|
49
49
|
return undefined;
|
|
50
50
|
}
|
package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;
|
|
1
|
+
{"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,WAAW,MAAM,0CAA0C,CAAC;AACnE,OAAO,QAAQ,MAAM,oCAAoC,CAAC;AAC1D,OAAO,UAAU,MAAM,sCAAsC,CAAC;AAC9D,OAAO,UAAU,MAAM,sCAAsC,CAAC;AAC9D,OAAO,QAAQ,MAAM,gCAAgC,CAAC;AACtD,OAAO,QAAQ,MAAM,qCAAqC,CAAC;AAC3D,OAAO,gBAAgB,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAcpF,YAAY;AACZ,MAAM,UAAU,iBAAiB,CAAC,KAA6B;IAC7D,OAAO,CACL,KAAC,IAAI,IACH,gBAAgB,EAAE,KAAC,gBAAgB,IAAC,IAAI,EAAE,QAAQ,GAAI,KAClD,KAAK,EACT,QAAQ,EAAE,0BAA0B,CAAC,EAAE,EACvC,sBAAsB,EAAE,sBAAsB,EAC9C,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,UAAU,EAChD,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,KAAC,YAAY,OAAK,SAAS,EAAE,OAAO,EAAE,OAAO,GAAI,GAC9E,CACH,CAAC;AACJ,CAAC;AAED,MAAM,sBAAsB,GAAwC,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE;IACvF,OAAO,IAAI,2BAA2B,CAAC;QACrC,YAAY;QACZ,QAAQ,EAAE,IAAI,yBAAyB,CAAC,YAAY,CAAC;KACtD,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,SAAS,OAAO,CAAC,IAA+B;IAC9C,IAAI,IAAI,CAAC,YAAY,EAAE,OAAO,KAAK,SAAS,EAAE;QAC5C,OAAO,SAAS,CAAC;KAClB;IAED,QAAQ,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;QACjC,KAAK,aAAa;YAChB,OAAO,WAAW,CAAC;QACrB,KAAK,WAAW;YACd,OAAO,UAAU,CAAC;QACpB,KAAK,eAAe;YAClB,OAAO,QAAQ,CAAC;QAClB,KAAK,aAAa;YAChB,OAAO,UAAU,CAAC;QACpB,KAAK,YAAY;YACf,OAAO,QAAQ,CAAC;QAClB,KAAK,qBAAqB;YACxB,OAAO,gBAAgB,CAAC;QAC1B,KAAK,YAAY;YACf,OAAO,QAAQ,CAAC;KACnB;IAED,OAAO,SAAS,CAAC;AACnB,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 categorySvg from \"@itwin/itwinui-icons/bis-category-3d.svg\";\nimport classSvg from \"@itwin/itwinui-icons/bis-class.svg\";\nimport elementSvg from \"@itwin/itwinui-icons/bis-element.svg\";\nimport subjectSvg from \"@itwin/itwinui-icons/bis-subject.svg\";\nimport groupSvg from \"@itwin/itwinui-icons/group.svg\";\nimport modelSvg from \"@itwin/itwinui-icons/model-cube.svg\";\nimport hierarchyTreeSvg from \"@itwin/itwinui-icons/selection-children.svg\";\nimport { EmptyTreeContent } from \"../common/components/EmptyTreeContent.js\";\nimport { Tree } from \"../common/components/Tree.js\";\nimport { TreeRenderer } from \"../common/components/TreeRenderer.js\";\nimport { IModelContentTreeComponent } from \"./IModelContentTreeComponent.js\";\nimport { IModelContentTreeDefinition } from \"./IModelContentTreeDefinition.js\";\nimport { IModelContentTreeIdsCache } from \"./internal/IModelContentTreeIdsCache.js\";\n\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { BaseTreeRendererProps } from \"../common/components/BaseTreeRenderer.js\";\nimport type { TreeProps } from \"../common/components/Tree.js\";\n\n/** @beta */\nexport type IModelContentTreeProps = Pick<TreeProps, \"imodel\" | \"getSchemaContext\" | \"selectionStorage\" | \"selectionMode\" | \"emptyTreeContent\"> &\n Pick<BaseTreeRendererProps, \"actions\"> & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n };\n\n/** @beta */\nexport function IModelContentTree(props: IModelContentTreeProps) {\n return (\n <Tree\n emptyTreeContent={<EmptyTreeContent icon={modelSvg} />}\n {...props}\n treeName={IModelContentTreeComponent.id}\n getHierarchyDefinition={getDefinitionsProvider}\n selectionMode={props.selectionMode ?? \"extended\"}\n treeRenderer={(treeProps) => <TreeRenderer {...treeProps} getIcon={getIcon} />}\n />\n );\n}\n\nconst getDefinitionsProvider: TreeProps[\"getHierarchyDefinition\"] = ({ imodelAccess }) => {\n return new IModelContentTreeDefinition({\n imodelAccess,\n idsCache: new IModelContentTreeIdsCache(imodelAccess),\n });\n};\n\nfunction getIcon(node: PresentationHierarchyNode): string | undefined {\n if (node.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n switch (node.extendedData.imageId) {\n case \"icon-layers\":\n return categorySvg;\n case \"icon-item\":\n return elementSvg;\n case \"icon-ec-class\":\n return classSvg;\n case \"icon-folder\":\n return subjectSvg;\n case \"icon-model\":\n return modelSvg;\n case \"icon-hierarchy-tree\":\n return hierarchyTreeSvg;\n case \"icon-group\":\n return groupSvg;\n }\n\n return undefined;\n}\n"]}
|
|
@@ -7,6 +7,7 @@ export { useCategoriesTree } from "./categories-tree/UseCategoriesTree.js";
|
|
|
7
7
|
export { useModelsTreeButtonProps } from "./models-tree/ModelsTreeButtons.js";
|
|
8
8
|
export { useCategoriesTreeButtonProps } from "./categories-tree/CategoriesTreeButtons.js";
|
|
9
9
|
export { BaseTreeRendererProps } from "./common/components/BaseTreeRenderer.js";
|
|
10
|
+
export { FocusedInstancesContextProvider, useFocusedInstancesContext } from "./common/FocusedInstancesContext.js";
|
|
10
11
|
export { Tree } from "./common/components/Tree.js";
|
|
11
12
|
export { VisibilityTree } from "./common/components/VisibilityTree.js";
|
|
12
13
|
export { TreeRenderer } from "./common/components/TreeRenderer.js";
|
|
@@ -10,6 +10,7 @@ export { useModelsTree } from "./models-tree/UseModelsTree.js";
|
|
|
10
10
|
export { useCategoriesTree } from "./categories-tree/UseCategoriesTree.js";
|
|
11
11
|
export { useModelsTreeButtonProps } from "./models-tree/ModelsTreeButtons.js";
|
|
12
12
|
export { useCategoriesTreeButtonProps } from "./categories-tree/CategoriesTreeButtons.js";
|
|
13
|
+
export { FocusedInstancesContextProvider, useFocusedInstancesContext } from "./common/FocusedInstancesContext.js";
|
|
13
14
|
export { Tree } from "./common/components/Tree.js";
|
|
14
15
|
export { VisibilityTree } from "./common/components/VisibilityTree.js";
|
|
15
16
|
export { TreeRenderer } from "./common/components/TreeRenderer.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/tree-widget-react/components/trees/index.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,qDAAqD,CAAC;AACjG,OAAO,EAAE,4BAA4B,EAAE,MAAM,yDAAyD,CAAC;AAEvG,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAG1F,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AAEvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,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\nexport { ModelsTreeComponent } from \"./models-tree/ModelsTreeComponent.js\";\nexport { CategoriesTreeComponent } from \"./categories-tree/CategoriesTreeComponent.js\";\nexport { IModelContentTreeComponent } from \"./imodel-content-tree/IModelContentTreeComponent.js\";\nexport { ExternalSourcesTreeComponent } from \"./external-sources-tree/ExternalSourcesTreeComponent.js\";\n\nexport { useModelsTree } from \"./models-tree/UseModelsTree.js\";\nexport { useCategoriesTree } from \"./categories-tree/UseCategoriesTree.js\";\n\nexport { useModelsTreeButtonProps } from \"./models-tree/ModelsTreeButtons.js\";\nexport { useCategoriesTreeButtonProps } from \"./categories-tree/CategoriesTreeButtons.js\";\n\nexport { BaseTreeRendererProps } from \"./common/components/BaseTreeRenderer.js\";\nexport { Tree } from \"./common/components/Tree.js\";\nexport { VisibilityTree } from \"./common/components/VisibilityTree.js\";\nexport { TreeRenderer } from \"./common/components/TreeRenderer.js\";\nexport { VisibilityTreeRenderer } from \"./common/components/VisibilityTreeRenderer.js\";\nexport { HierarchyVisibilityHandler, VisibilityStatus } from \"./common/UseHierarchyVisibility.js\";\nexport { TelemetryContextProvider } from \"./common/UseTelemetryContext.js\";\nexport { FilterLimitExceededError } from \"./common/TreeErrors.js\";\n\nexport { ModelsTreeVisibilityHandlerOverrides } from \"./models-tree/internal/ModelsTreeVisibilityHandler.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/tree-widget-react/components/trees/index.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,qDAAqD,CAAC;AACjG,OAAO,EAAE,4BAA4B,EAAE,MAAM,yDAAyD,CAAC;AAEvG,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAG1F,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAElH,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AAEvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,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\nexport { ModelsTreeComponent } from \"./models-tree/ModelsTreeComponent.js\";\nexport { CategoriesTreeComponent } from \"./categories-tree/CategoriesTreeComponent.js\";\nexport { IModelContentTreeComponent } from \"./imodel-content-tree/IModelContentTreeComponent.js\";\nexport { ExternalSourcesTreeComponent } from \"./external-sources-tree/ExternalSourcesTreeComponent.js\";\n\nexport { useModelsTree } from \"./models-tree/UseModelsTree.js\";\nexport { useCategoriesTree } from \"./categories-tree/UseCategoriesTree.js\";\n\nexport { useModelsTreeButtonProps } from \"./models-tree/ModelsTreeButtons.js\";\nexport { useCategoriesTreeButtonProps } from \"./categories-tree/CategoriesTreeButtons.js\";\n\nexport { BaseTreeRendererProps } from \"./common/components/BaseTreeRenderer.js\";\nexport { FocusedInstancesContextProvider, useFocusedInstancesContext } from \"./common/FocusedInstancesContext.js\";\n\nexport { Tree } from \"./common/components/Tree.js\";\nexport { VisibilityTree } from \"./common/components/VisibilityTree.js\";\nexport { TreeRenderer } from \"./common/components/TreeRenderer.js\";\nexport { VisibilityTreeRenderer } from \"./common/components/VisibilityTreeRenderer.js\";\nexport { HierarchyVisibilityHandler, VisibilityStatus } from \"./common/UseHierarchyVisibility.js\";\nexport { TelemetryContextProvider } from \"./common/UseTelemetryContext.js\";\nexport { FilterLimitExceededError } from \"./common/TreeErrors.js\";\n\nexport { ModelsTreeVisibilityHandlerOverrides } from \"./models-tree/internal/ModelsTreeVisibilityHandler.js\";\n"]}
|
|
@@ -4,16 +4,16 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
import { useEffect, useMemo, useState } from "react";
|
|
7
|
+
import toggle2DSvg from "@itwin/itwinui-icons/2d.svg";
|
|
8
|
+
import toggle3DSvg from "@itwin/itwinui-icons/3d.svg";
|
|
9
|
+
import focusModeSvg from "@itwin/itwinui-icons/cursor-click.svg";
|
|
10
|
+
import visibilityHideSvg from "@itwin/itwinui-icons/visibility-hide.svg";
|
|
11
|
+
import visibilityShowSvg from "@itwin/itwinui-icons/visibility-show.svg";
|
|
12
|
+
import visibilityInvertSvg from "@itwin/itwinui-icons/visibilty-invert.svg";
|
|
7
13
|
import { IconButton } from "@itwin/itwinui-react/bricks";
|
|
8
14
|
import { TreeWidget } from "../../../TreeWidget.js";
|
|
9
15
|
import { useFocusedInstancesContext } from "../common/FocusedInstancesContext.js";
|
|
10
16
|
import { areAllModelsVisible, hideAllModels, invertAllModels, showAllModels, toggleModels } from "./internal/ModelsTreeVisibilityHandler.js";
|
|
11
|
-
const visibilityShowIcon = new URL("@itwin/itwinui-icons/visibility-show.svg", import.meta.url).href;
|
|
12
|
-
const visibilityHideIcon = new URL("@itwin/itwinui-icons/visibility-hide.svg", import.meta.url).href;
|
|
13
|
-
const visibilityInvertIcon = new URL("@itwin/itwinui-icons/visibilty-invert.svg", import.meta.url).href;
|
|
14
|
-
const focusModeIcon = new URL("@itwin/itwinui-icons/cursor-click.svg", import.meta.url).href;
|
|
15
|
-
const toggle3DIcon = new URL("@itwin/itwinui-icons/3d.svg", import.meta.url).href;
|
|
16
|
-
const toggle2DIcon = new URL("@itwin/itwinui-icons/2d.svg", import.meta.url).href;
|
|
17
17
|
/**
|
|
18
18
|
* Custom hook that creates props required to render `ModelsTreeComponent` header button.
|
|
19
19
|
*
|
|
@@ -79,21 +79,21 @@ export function ShowAllButton(props) {
|
|
|
79
79
|
return (_jsx(IconButton, { variant: "ghost", label: TreeWidget.translate("modelsTree.buttons.showAll.tooltip"), onClick: () => {
|
|
80
80
|
props.onFeatureUsed?.("models-tree-showall");
|
|
81
81
|
void showAllModels(props.models.map((model) => model.id), props.viewport);
|
|
82
|
-
}, icon:
|
|
82
|
+
}, icon: visibilityShowSvg }));
|
|
83
83
|
}
|
|
84
84
|
/** @public */
|
|
85
85
|
export function HideAllButton(props) {
|
|
86
86
|
return (_jsx(IconButton, { variant: "ghost", label: TreeWidget.translate("modelsTree.buttons.hideAll.tooltip"), onClick: () => {
|
|
87
87
|
props.onFeatureUsed?.("models-tree-hideall");
|
|
88
88
|
void hideAllModels(props.models.map((model) => model.id), props.viewport);
|
|
89
|
-
}, icon:
|
|
89
|
+
}, icon: visibilityHideSvg }));
|
|
90
90
|
}
|
|
91
91
|
/** @public */
|
|
92
92
|
export function InvertButton(props) {
|
|
93
93
|
return (_jsx(IconButton, { variant: "ghost", label: TreeWidget.translate("modelsTree.buttons.invert.tooltip"), onClick: () => {
|
|
94
94
|
props.onFeatureUsed?.("models-tree-invert");
|
|
95
95
|
void invertAllModels(props.models.map((model) => model.id), props.viewport);
|
|
96
|
-
}, icon:
|
|
96
|
+
}, icon: visibilityInvertSvg }));
|
|
97
97
|
}
|
|
98
98
|
/** @public */
|
|
99
99
|
export function View2DButton(props) {
|
|
@@ -108,7 +108,7 @@ export function View2DButton(props) {
|
|
|
108
108
|
return (_jsx(IconButton, { variant: "ghost", label: TreeWidget.translate("modelsTree.buttons.toggle2d.tooltip"), onClick: () => {
|
|
109
109
|
props.onFeatureUsed?.("models-tree-view2d");
|
|
110
110
|
void toggleModels(models2d, is2dToggleActive, props.viewport);
|
|
111
|
-
}, "aria-disabled": models2d.length === 0, isActive: is2dToggleActive, icon:
|
|
111
|
+
}, "aria-disabled": models2d.length === 0, isActive: is2dToggleActive, icon: toggle2DSvg }));
|
|
112
112
|
}
|
|
113
113
|
/** @public */
|
|
114
114
|
export function View3DButton(props) {
|
|
@@ -123,7 +123,7 @@ export function View3DButton(props) {
|
|
|
123
123
|
return (_jsx(IconButton, { variant: "ghost", label: TreeWidget.translate("modelsTree.buttons.toggle3d.tooltip"), onClick: () => {
|
|
124
124
|
props.onFeatureUsed?.("models-tree-view3d");
|
|
125
125
|
void toggleModels(models3d, is3dToggleActive, props.viewport);
|
|
126
|
-
}, "aria-disabled": models3d.length === 0, isActive: is3dToggleActive, icon:
|
|
126
|
+
}, "aria-disabled": models3d.length === 0, isActive: is3dToggleActive, icon: toggle3DSvg }));
|
|
127
127
|
}
|
|
128
128
|
/** @public */
|
|
129
129
|
export function ToggleInstancesFocusButton({ onFeatureUsed, disabled }) {
|
|
@@ -136,6 +136,6 @@ export function ToggleInstancesFocusButton({ onFeatureUsed, disabled }) {
|
|
|
136
136
|
return (_jsx(IconButton, { variant: "ghost", label: label, onClick: () => {
|
|
137
137
|
onFeatureUsed?.("models-tree-instancesfocus");
|
|
138
138
|
toggle();
|
|
139
|
-
}, "aria-disabled": disabled, isActive: enabled, icon:
|
|
139
|
+
}, "aria-disabled": disabled, isActive: enabled, icon: focusModeSvg }));
|
|
140
140
|
}
|
|
141
141
|
//# sourceMappingURL=ModelsTreeButtons.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTreeButtons.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAO7I,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,0CAA0C,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;AACrG,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,0CAA0C,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;AACrG,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,2CAA2C,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;AACxG,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,uCAAuC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;AAC7F,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B,IAAI,EAAE,aAAa,GACnB,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { IconButton } from \"@itwin/itwinui-react/bricks\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport { areAllModelsVisible, hideAllModels, invertAllModels, showAllModels, toggleModels } from \"./internal/ModelsTreeVisibilityHandler.js\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { GeometricModel3dProps, ModelQueryParams } from \"@itwin/core-common\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport type { TreeToolbarButtonProps } from \"../../tree-header/SelectableTree.js\";\n\nconst visibilityShowIcon = new URL(\"@itwin/itwinui-icons/visibility-show.svg\", import.meta.url).href;\nconst visibilityHideIcon = new URL(\"@itwin/itwinui-icons/visibility-hide.svg\", import.meta.url).href;\nconst visibilityInvertIcon = new URL(\"@itwin/itwinui-icons/visibilty-invert.svg\", import.meta.url).href;\nconst focusModeIcon = new URL(\"@itwin/itwinui-icons/cursor-click.svg\", import.meta.url).href;\nconst toggle3DIcon = new URL(\"@itwin/itwinui-icons/3d.svg\", import.meta.url).href;\nconst toggle2DIcon = new URL(\"@itwin/itwinui-icons/2d.svg\", import.meta.url).href;\n\n/**\n * Information about a single Model.\n * @public\n */\nexport interface ModelInfo {\n id: string;\n isPlanProjection?: boolean;\n}\n\n/**\n * Props that get passed to `ModelsTreeComponent` header button renderer.\n * @see ModelTreeComponentProps.headerButtons\n * @public\n */\nexport interface ModelsTreeHeaderButtonProps extends TreeToolbarButtonProps {\n /** A list of models available in the iModel. */\n models: ModelInfo[];\n}\n\n/**\n * Custom hook that creates props required to render `ModelsTreeComponent` header button.\n *\n * Example:\n * ```tsx\n * const { buttonProps, onModelsFiltered } = useModelsTreeButtonProps({ imodel, viewport });\n * <TreeWithHeader\n * buttons={[\n * <ModelsTreeComponent.ShowAllButton {...buttonProps} />,\n * <ModelsTreeComponent.HideAllButton {...buttonProps} />,\n * ]}\n * >\n * <ModelsTree {...treeProps} onModelsFiltered={onModelsFiltered} />\n * </TreeWithHeader>\n * ```\n *\n *\n * @public\n */\nexport function useModelsTreeButtonProps({ imodel, viewport }: { imodel: IModelConnection; viewport: Viewport }): {\n buttonProps: Pick<ModelsTreeHeaderButtonProps, \"models\" | \"viewport\">;\n onModelsFiltered: (models: Id64String[] | undefined) => void;\n} {\n const [filteredModels, setFilteredModels] = useState<Id64String[] | undefined>();\n const models = useAvailableModels(imodel);\n const availableModels = useMemo(() => (!filteredModels ? models : models.filter((model) => filteredModels.includes(model.id))), [models, filteredModels]);\n return {\n buttonProps: {\n models: availableModels,\n viewport,\n },\n onModelsFiltered: setFilteredModels,\n };\n}\n\nfunction useAvailableModels(imodel: IModelConnection): ModelInfo[] {\n const [availableModels, setAvailableModels] = useState<ModelInfo[]>([]);\n\n useEffect(() => {\n queryModelsForHeaderActions(imodel)\n .then((modelInfos: ModelInfo[]) => {\n setAvailableModels(modelInfos);\n })\n .catch(() => {\n setAvailableModels([]);\n });\n }, [imodel]);\n\n return availableModels;\n}\n\nasync function queryModelsForHeaderActions(iModel: IModelConnection) {\n const queryParams: ModelQueryParams = {\n from: \"BisCore.GeometricModel3d\",\n where: `\n EXISTS (\n SELECT 1\n FROM BisCore.Element e\n WHERE e.ECClassId IS (BisCore.GeometricElement3d, BisCore.InformationPartitionElement)\n AND e.ECInstanceId = GeometricModel3d.ModeledElement.Id\n )\n `,\n wantPrivate: false,\n };\n\n const modelProps = await iModel.models.queryProps(queryParams);\n return modelProps.map(({ id, isPlanProjection }: GeometricModel3dProps) => ({ id, isPlanProjection })).filter(({ id }) => id) as ModelInfo[];\n}\n\n/** @public */\nexport type ModelsTreeHeaderButtonType = (props: ModelsTreeHeaderButtonProps) => React.ReactElement | null;\n\n/** @public */\nexport function ShowAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.showAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-showall\");\n void showAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n icon={visibilityShowIcon}\n />\n );\n}\n\n/** @public */\nexport function HideAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.hideAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-hideall\");\n void hideAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n icon={visibilityHideIcon}\n />\n );\n}\n\n/** @public */\nexport function InvertButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.invert.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-invert\");\n void invertAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n icon={visibilityInvertIcon}\n />\n );\n}\n\n/** @public */\nexport function View2DButton(props: ModelsTreeHeaderButtonProps) {\n const models2d = useMemo(() => {\n return props.models.filter((model) => model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is2dToggleActive, setIs2dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs2dToggleActive(areAllModelsVisible(models2d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs2dToggleActive(areAllModelsVisible(models2d, vp)));\n }, [models2d, props.viewport]);\n\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.toggle2d.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view2d\");\n void toggleModels(models2d, is2dToggleActive, props.viewport);\n }}\n aria-disabled={models2d.length === 0}\n isActive={is2dToggleActive}\n icon={toggle2DIcon}\n />\n );\n}\n\n/** @public */\nexport function View3DButton(props: ModelsTreeHeaderButtonProps) {\n const models3d = useMemo(() => {\n return props.models.filter((model) => !model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is3dToggleActive, setIs3dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs3dToggleActive(areAllModelsVisible(models3d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs3dToggleActive(areAllModelsVisible(models3d, vp)));\n }, [models3d, props.viewport]);\n\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.toggle3d.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view3d\");\n void toggleModels(models3d, is3dToggleActive, props.viewport);\n }}\n aria-disabled={models3d.length === 0}\n isActive={is3dToggleActive}\n icon={toggle3DIcon}\n />\n );\n}\n\n/** @public */\nexport function ToggleInstancesFocusButton({ onFeatureUsed, disabled }: { onFeatureUsed?: (feature: string) => void; disabled?: boolean }) {\n const { enabled, toggle } = useFocusedInstancesContext();\n const label = disabled\n ? TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.disabled.tooltip\")\n : enabled\n ? TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.disable.tooltip\")\n : TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.enable.tooltip\");\n return (\n <IconButton\n variant={\"ghost\"}\n label={label}\n onClick={() => {\n onFeatureUsed?.(\"models-tree-instancesfocus\");\n toggle();\n }}\n aria-disabled={disabled}\n isActive={enabled}\n icon={focusModeIcon}\n />\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ModelsTreeButtons.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAA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YAC5E,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,mDAAmD,CAAC,CAAC;IAChF,OAAO,CACL,KAAC,UAAU,IACT,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,GAAG,EAAE;YACZ,aAAa,EAAE,CAAC,4BAA4B,CAAC,CAAC;YAC9C,MAAM,EAAE,CAAC;QACX,CAAC,mBACc,QAAQ,EACvB,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,YAAY,GAClB,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport toggle2DSvg from \"@itwin/itwinui-icons/2d.svg\";\nimport toggle3DSvg from \"@itwin/itwinui-icons/3d.svg\";\nimport focusModeSvg from \"@itwin/itwinui-icons/cursor-click.svg\";\nimport visibilityHideSvg from \"@itwin/itwinui-icons/visibility-hide.svg\";\nimport visibilityShowSvg from \"@itwin/itwinui-icons/visibility-show.svg\";\nimport visibilityInvertSvg from \"@itwin/itwinui-icons/visibilty-invert.svg\";\nimport { IconButton } from \"@itwin/itwinui-react/bricks\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport { areAllModelsVisible, hideAllModels, invertAllModels, showAllModels, toggleModels } from \"./internal/ModelsTreeVisibilityHandler.js\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { GeometricModel3dProps, ModelQueryParams } from \"@itwin/core-common\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport type { TreeToolbarButtonProps } from \"../../tree-header/SelectableTree.js\";\n\n/**\n * Information about a single Model.\n * @public\n */\nexport interface ModelInfo {\n id: string;\n isPlanProjection?: boolean;\n}\n\n/**\n * Props that get passed to `ModelsTreeComponent` header button renderer.\n * @see ModelTreeComponentProps.headerButtons\n * @public\n */\nexport interface ModelsTreeHeaderButtonProps extends TreeToolbarButtonProps {\n /** A list of models available in the iModel. */\n models: ModelInfo[];\n}\n\n/**\n * Custom hook that creates props required to render `ModelsTreeComponent` header button.\n *\n * Example:\n * ```tsx\n * const { buttonProps, onModelsFiltered } = useModelsTreeButtonProps({ imodel, viewport });\n * <TreeWithHeader\n * buttons={[\n * <ModelsTreeComponent.ShowAllButton {...buttonProps} />,\n * <ModelsTreeComponent.HideAllButton {...buttonProps} />,\n * ]}\n * >\n * <ModelsTree {...treeProps} onModelsFiltered={onModelsFiltered} />\n * </TreeWithHeader>\n * ```\n *\n *\n * @public\n */\nexport function useModelsTreeButtonProps({ imodel, viewport }: { imodel: IModelConnection; viewport: Viewport }): {\n buttonProps: Pick<ModelsTreeHeaderButtonProps, \"models\" | \"viewport\">;\n onModelsFiltered: (models: Id64String[] | undefined) => void;\n} {\n const [filteredModels, setFilteredModels] = useState<Id64String[] | undefined>();\n const models = useAvailableModels(imodel);\n const availableModels = useMemo(() => (!filteredModels ? models : models.filter((model) => filteredModels.includes(model.id))), [models, filteredModels]);\n return {\n buttonProps: {\n models: availableModels,\n viewport,\n },\n onModelsFiltered: setFilteredModels,\n };\n}\n\nfunction useAvailableModels(imodel: IModelConnection): ModelInfo[] {\n const [availableModels, setAvailableModels] = useState<ModelInfo[]>([]);\n\n useEffect(() => {\n queryModelsForHeaderActions(imodel)\n .then((modelInfos: ModelInfo[]) => {\n setAvailableModels(modelInfos);\n })\n .catch(() => {\n setAvailableModels([]);\n });\n }, [imodel]);\n\n return availableModels;\n}\n\nasync function queryModelsForHeaderActions(iModel: IModelConnection) {\n const queryParams: ModelQueryParams = {\n from: \"BisCore.GeometricModel3d\",\n where: `\n EXISTS (\n SELECT 1\n FROM BisCore.Element e\n WHERE e.ECClassId IS (BisCore.GeometricElement3d, BisCore.InformationPartitionElement)\n AND e.ECInstanceId = GeometricModel3d.ModeledElement.Id\n )\n `,\n wantPrivate: false,\n };\n\n const modelProps = await iModel.models.queryProps(queryParams);\n return modelProps.map(({ id, isPlanProjection }: GeometricModel3dProps) => ({ id, isPlanProjection })).filter(({ id }) => id) as ModelInfo[];\n}\n\n/** @public */\nexport type ModelsTreeHeaderButtonType = (props: ModelsTreeHeaderButtonProps) => React.ReactElement | null;\n\n/** @public */\nexport function ShowAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.showAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-showall\");\n void showAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n icon={visibilityShowSvg}\n />\n );\n}\n\n/** @public */\nexport function HideAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.hideAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-hideall\");\n void hideAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n icon={visibilityHideSvg}\n />\n );\n}\n\n/** @public */\nexport function InvertButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.invert.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-invert\");\n void invertAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n icon={visibilityInvertSvg}\n />\n );\n}\n\n/** @public */\nexport function View2DButton(props: ModelsTreeHeaderButtonProps) {\n const models2d = useMemo(() => {\n return props.models.filter((model) => model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is2dToggleActive, setIs2dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs2dToggleActive(areAllModelsVisible(models2d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs2dToggleActive(areAllModelsVisible(models2d, vp)));\n }, [models2d, props.viewport]);\n\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.toggle2d.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view2d\");\n void toggleModels(models2d, is2dToggleActive, props.viewport);\n }}\n aria-disabled={models2d.length === 0}\n isActive={is2dToggleActive}\n icon={toggle2DSvg}\n />\n );\n}\n\n/** @public */\nexport function View3DButton(props: ModelsTreeHeaderButtonProps) {\n const models3d = useMemo(() => {\n return props.models.filter((model) => !model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is3dToggleActive, setIs3dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs3dToggleActive(areAllModelsVisible(models3d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs3dToggleActive(areAllModelsVisible(models3d, vp)));\n }, [models3d, props.viewport]);\n\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.toggle3d.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view3d\");\n void toggleModels(models3d, is3dToggleActive, props.viewport);\n }}\n aria-disabled={models3d.length === 0}\n isActive={is3dToggleActive}\n icon={toggle3DSvg}\n />\n );\n}\n\n/** @public */\nexport function ToggleInstancesFocusButton({ onFeatureUsed, disabled }: { onFeatureUsed?: (feature: string) => void; disabled?: boolean }) {\n const { enabled, toggle } = useFocusedInstancesContext();\n const label = disabled\n ? TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.disabled.tooltip\")\n : enabled\n ? TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.disable.tooltip\")\n : TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.enable.tooltip\");\n return (\n <IconButton\n variant={\"ghost\"}\n label={label}\n onClick={() => {\n onFeatureUsed?.(\"models-tree-instancesfocus\");\n toggle();\n }}\n aria-disabled={disabled}\n isActive={enabled}\n icon={focusModeSvg}\n />\n );\n}\n"]}
|
|
@@ -54,7 +54,12 @@ export declare const ModelsTreeComponent: {
|
|
|
54
54
|
*/
|
|
55
55
|
View3DButton: ModelsTreeHeaderButtonType;
|
|
56
56
|
/**
|
|
57
|
-
* Renders
|
|
57
|
+
* Renders an "Instance focus" toggle button that enables/disables instances focusing mode.
|
|
58
|
+
*
|
|
59
|
+
* Requires instances focus context to be provided using `FocusedInstancesContextProvider`. The context
|
|
60
|
+
* is provided automatically, when using `ModelsTreeComponent`, but needs to be provided by consumers
|
|
61
|
+
* when rendering `ToggleInstancesFocusButton` outside of `ModelsTreeComponent`.
|
|
62
|
+
*
|
|
58
63
|
* @public
|
|
59
64
|
*/
|
|
60
65
|
ToggleInstancesFocusButton: ModelsTreeHeaderButtonType;
|
|
@@ -8,8 +8,7 @@ import { Fragment, useEffect } from "react";
|
|
|
8
8
|
import { useActiveIModelConnection } from "@itwin/appui-react";
|
|
9
9
|
import { TreeWidget } from "../../../TreeWidget.js";
|
|
10
10
|
import { SelectableTree } from "../../tree-header/SelectableTree.js";
|
|
11
|
-
import { useFocusedInstancesContext } from "../common/FocusedInstancesContext.js";
|
|
12
|
-
import { FocusedInstancesContextProvider } from "../common/FocusedInstancesContextProvider.js";
|
|
11
|
+
import { FocusedInstancesContextProvider, useFocusedInstancesContext } from "../common/FocusedInstancesContext.js";
|
|
13
12
|
import { useActiveViewport } from "../common/UseActiveViewport.js";
|
|
14
13
|
import { TelemetryContextProvider } from "../common/UseTelemetryContext.js";
|
|
15
14
|
import { ModelsTree } from "./ModelsTree.js";
|
|
@@ -54,7 +53,12 @@ ModelsTreeComponent.View2DButton = View2DButton;
|
|
|
54
53
|
*/
|
|
55
54
|
ModelsTreeComponent.View3DButton = View3DButton;
|
|
56
55
|
/**
|
|
57
|
-
* Renders
|
|
56
|
+
* Renders an "Instance focus" toggle button that enables/disables instances focusing mode.
|
|
57
|
+
*
|
|
58
|
+
* Requires instances focus context to be provided using `FocusedInstancesContextProvider`. The context
|
|
59
|
+
* is provided automatically, when using `ModelsTreeComponent`, but needs to be provided by consumers
|
|
60
|
+
* when rendering `ToggleInstancesFocusButton` outside of `ModelsTreeComponent`.
|
|
61
|
+
*
|
|
58
62
|
* @public
|
|
59
63
|
*/
|
|
60
64
|
ModelsTreeComponent.ToggleInstancesFocusButton = ToggleInstancesFocusButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";;AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE
|
|
1
|
+
{"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";;AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AACnH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,aAAa,EACb,YAAY,EACZ,aAAa,EACb,0BAA0B,EA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,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YAC/I,KAAC,cAAc,IAAC,OAAO,EAAE,OAAO,YAC9B,KAAC,UAAU,OAAK,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,GAAI,GACxG,GACQ,CAC5B,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 { Fragment, useEffect } from \"react\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { SelectableTree } from \"../../tree-header/SelectableTree.js\";\nimport { FocusedInstancesContextProvider, useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport { useActiveViewport } from \"../common/UseActiveViewport.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { ModelsTree } from \"./ModelsTree.js\";\nimport {\n HideAllButton,\n InvertButton,\n ShowAllButton,\n ToggleInstancesFocusButton,\n useModelsTreeButtonProps,\n View2DButton,\n View3DButton,\n} from \"./ModelsTreeButtons.js\";\n\nimport type { ModelsTreeProps } from \"./ModelsTree.js\";\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { ModelsTreeHeaderButtonProps, ModelsTreeHeaderButtonType } from \"./ModelsTreeButtons.js\";\n\n/** @public */\ninterface ModelsTreeComponentProps\n extends Pick<\n ModelsTreeProps,\n | \"getSchemaContext\"\n | \"selectionStorage\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"selectionPredicate\"\n | \"hierarchyConfig\"\n | \"visibilityHandlerOverrides\"\n | \"getFilteredPaths\"\n | \"filter\"\n | \"emptyTreeContent\"\n | \"actions\"\n > {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * ModelsTreeComponent.ShowAllButton,\n * ModelsTreeComponent.HideAllButton,\n * ModelsTreeComponent.InvertButton,\n * ModelsTreeComponent.View2DButton,\n * ModelsTreeComponent.View3DButton,\n * ModelsTreeComponent.ToggleInstancesFocusButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: ModelsTreeHeaderButtonProps) => React.ReactNode>;\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `ModelsTree` and a header with filtering capabilities\n * and header buttons.\n *\n * @public\n */\nexport const ModelsTreeComponent = (props: ModelsTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return (\n <FocusedInstancesContextProvider selectionStorage={props.selectionStorage} imodelKey={iModel.key}>\n <ModelsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />\n </FocusedInstancesContextProvider>\n );\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all models.\n * @public\n */\nModelsTreeComponent.ShowAllButton = ShowAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"Hide all\" button that disables display of all models.\n * @public\n */\nModelsTreeComponent.HideAllButton = HideAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all models.\n * @public\n */\nModelsTreeComponent.InvertButton = InvertButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 2D\" button that enables display of all plan projection models and disables all others.\n * @public\n */\nModelsTreeComponent.View2DButton = View2DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 3D\" button that enables display of all non-plan projection models and disables all plan projection ones.\n * @public\n */\nModelsTreeComponent.View3DButton = View3DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Instance focus\" toggle button that enables/disables instances focusing mode.\n *\n * Requires instances focus context to be provided using `FocusedInstancesContextProvider`. The context\n * is provided automatically, when using `ModelsTreeComponent`, but needs to be provided by consumers\n * when rendering `ToggleInstancesFocusButton` outside of `ModelsTreeComponent`.\n *\n * @public\n */\nModelsTreeComponent.ToggleInstancesFocusButton = ToggleInstancesFocusButton as ModelsTreeHeaderButtonType;\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.id = \"models-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.getLabel = () => TreeWidget.translate(\"modelsTree.label\");\n\nfunction ModelsTreeComponentImpl({\n iModel,\n viewport,\n headerButtons,\n onFeatureUsed,\n onPerformanceMeasured,\n filter,\n ...treeProps\n}: ModelsTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const { buttonProps, onModelsFiltered } = useModelsTreeButtonProps({ imodel: iModel, viewport });\n const { enabled: instanceFocusEnabled, toggle: toggleInstanceFocus } = useFocusedInstancesContext();\n\n const buttons: ReactNode = headerButtons\n ? headerButtons.map((btn, index) => <Fragment key={index}>{btn({ ...buttonProps, onFeatureUsed })}</Fragment>)\n : [\n <ShowAllButton {...buttonProps} key=\"show-all-btn\" onFeatureUsed={onFeatureUsed} />,\n <HideAllButton {...buttonProps} key=\"hide-all-btn\" onFeatureUsed={onFeatureUsed} />,\n <InvertButton {...buttonProps} key=\"invert-all-btn\" onFeatureUsed={onFeatureUsed} />,\n <View2DButton {...buttonProps} key=\"view-2d-btn\" onFeatureUsed={onFeatureUsed} />,\n <View3DButton {...buttonProps} key=\"view-3d-btn\" onFeatureUsed={onFeatureUsed} />,\n <ToggleInstancesFocusButton disabled={filter !== undefined} key=\"toggle-instances-focus-btn\" onFeatureUsed={onFeatureUsed} />,\n ];\n\n useEffect(() => {\n if (instanceFocusEnabled && filter !== undefined) {\n toggleInstanceFocus();\n }\n }, [instanceFocusEnabled, filter, toggleInstanceFocus]);\n\n return (\n <TelemetryContextProvider componentIdentifier={ModelsTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <SelectableTree buttons={buttons}>\n <ModelsTree {...treeProps} imodel={iModel} activeView={viewport} filter={filter} onModelsFiltered={onModelsFiltered} />\n </SelectableTree>\n </TelemetryContextProvider>\n );\n}\n"]}
|