UNPKG

@itwin/unified-selection-react

Version:

React components for making use of `@itwin/unified-selection` package in React applications more straightforward

35 lines 1.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UnifiedSelectionContextProvider = UnifiedSelectionContextProvider; exports.useUnifiedSelectionContext = useUnifiedSelectionContext; const jsx_runtime_1 = require("react/jsx-runtime"); /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ const react_1 = require("react"); const unifiedSelectionContext = (0, react_1.createContext)(undefined); /** * A React context provider that makes given unified selection context available to all child components. This * is a requirement for `useUnifiedSelectionContext` to return valid context. * * See `README.md` for a usage example. * * @public */ function UnifiedSelectionContextProvider(props) { const { children, ...context } = props; return (0, jsx_runtime_1.jsx)(unifiedSelectionContext.Provider, { value: context, children: children }); } /** * A React hook for accessing unified selection context. The context must be provided by `UnifiedSelectionContextProvider`, * otherwise the hook will return `undefined`. * * See `README.md` for a usage example. * * @public */ function useUnifiedSelectionContext() { return (0, react_1.useContext)(unifiedSelectionContext); } //# sourceMappingURL=UnifiedSelectionContext.js.map