UNPKG

@itwin/presentation-hierarchies-react

Version:

React components based on `@itwin/presentation-hierarchies`

66 lines 3.21 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ Object.defineProperty(exports, "__esModule", { value: true }); exports.useIModelTree = useIModelTree; exports.useIModelUnifiedSelectionTree = useIModelUnifiedSelectionTree; const react_1 = require("react"); const presentation_hierarchies_1 = require("@itwin/presentation-hierarchies"); const UseTree_js_1 = require("./UseTree.js"); /** * A React hook that creates state for a tree component whose displayed hierarchy is based on * iModel data. * * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a * component-agnostic result which may be used to render the hierarchy using any UI framework. * * See `README.md` for an example * * @see `useTree` * @see `useIModelUnifiedSelectionTree` * @public */ function useIModelTree(props) { const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings, ...rest } = props; return (0, UseTree_js_1.useTree)({ ...rest, ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings }), }); } /** * A React hook that creates state for a tree component whose displayed hierarchy is based on * iModel data and that is integrated with unified selection through the given selection * storage (previously the storage was provided through the, now deprecated, `UnifiedSelectionProvider`). * * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a * component-agnostic result which may be used to render the hierarchy using any UI framework. * * See `README.md` for an example * * @see `useIModelTree` * @see `useUnifiedSelectionTree` * @see `UnifiedSelectionProvider` * @public */ function useIModelUnifiedSelectionTree(props) { const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings, ...rest } = props; return (0, UseTree_js_1.useUnifiedSelectionTree)({ ...rest, ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings }), }); } function useIModelTreeProps(props) { const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings } = props; return { getHierarchyProvider: (0, react_1.useCallback)(() => (0, presentation_hierarchies_1.createIModelHierarchyProvider)({ imodelAccess, imodelChanged, hierarchyDefinition: getHierarchyDefinition({ imodelAccess }), localizedStrings, }), [imodelAccess, imodelChanged, getHierarchyDefinition, localizedStrings]), getFilteredPaths: (0, react_1.useCallback)(async ({ abortSignal }) => getFilteredPaths?.({ imodelAccess, abortSignal }), [imodelAccess, getFilteredPaths]), }; } //# sourceMappingURL=UseIModelTree.js.map