UNPKG

@elastic/eui

Version:

Elastic UI Component Library

33 lines (29 loc) 1.25 kB
/* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ import React, { createContext, useContext } from 'react'; // Context to track if we're within a managed flyout import { jsx as ___EmotionJSX } from "@emotion/react"; var EuiFlyoutIsManagedContext = /*#__PURE__*/createContext(false); /** * React provider that marks descendants as being rendered inside * an EUI managed flyout. Used by hooks/components to alter behavior * (e.g., focus handling) when inside a managed flyout tree. */ export var EuiFlyoutIsManagedProvider = function EuiFlyoutIsManagedProvider(_ref) { var isManaged = _ref.isManaged, children = _ref.children; return ___EmotionJSX(EuiFlyoutIsManagedContext.Provider, { value: isManaged }, children); }; /** * Hook that returns `true` when called within an EUI managed flyout subtree. */ export var useIsInManagedFlyout = function useIsInManagedFlyout() { return useContext(EuiFlyoutIsManagedContext); };