UNPKG

@elastic/eui

Version:

Elastic UI Component Library

36 lines (32 loc) 1.39 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 inside a parent flyout's children. * This allows nested flyouts to automatically inherit the session * without requiring explicit `session="inherit"` prop. */ import { jsx as ___EmotionJSX } from "@emotion/react"; var EuiFlyoutParentContext = /*#__PURE__*/createContext(false); /** * Provider that wraps a flyout's children to indicate they're inside a parent flyout. * Nested flyouts can use this to automatically default to session inheritance. */ export var EuiFlyoutParentProvider = function EuiFlyoutParentProvider(_ref) { var children = _ref.children; return ___EmotionJSX(EuiFlyoutParentContext.Provider, { value: true }, children); }; /** * Hook that returns `true` when called within a parent flyout's children. * Used to automatically determine if a nested flyout should inherit the session. */ export var useIsInsideParentFlyout = function useIsInsideParentFlyout() { return useContext(EuiFlyoutParentContext); };