import { EuiAccordion } from '@elastic/eui' ; import React from 'react' ; import { euiStyled } from '../../../../../../../src/plugins/kibana_react/common' ; import { Stackframe as StackframeType , StackframeWithLineContext , } from '../../../../typings/es_schemas/raw/fields/stackframe' ; import { Context } from './Context' ; import { FrameHeading } from './frame_heading' ; import { Variables } from './Variables' ; const ContextContainer = euiStyled . div < { isLibraryFrame : boolean ; } > `
  position: relative;
  font-family: ${ ( { theme } ) => theme . eui . euiCodeFontFamily };
  font-size: ${ ( { theme } ) => theme . eui . euiFontSizeS };
  border: 1px solid ${ ( { theme } ) => theme . eui . euiColorLightShade };
  border-radius: ${ ( { theme } ) => theme . eui . euiBorderRadiusSmall };
  background: ${ ( { isLibraryFrame , theme } ) => isLibraryFrame ? theme . eui . euiColorEmptyShade : theme . eui . euiColorLightestShade };
` ; const NoContextFrameHeadingWrapper = euiStyled . div `
  margin-left: 28px;
` ; interface Props { stackframe : StackframeType ; codeLanguage ? : string ; id : string ; initialIsOpen ? : boolean ; isLibraryFrame ? : boolean ; } export function Stackframe ( { stackframe , codeLanguage , id , initialIsOpen = false , isLibraryFrame = false , } ) { if ( ! hasLineContext ( stackframe ) ) { return ( < NoContextFrameHeadingWrapper > < FrameHeading codeLanguage = { codeLanguage } stackframe = { stackframe } isLibraryFrame = { isLibraryFrame } / > < /NoContextFrameHeadingWrapper>); } return ( < EuiAccordion buttonContent = { < FrameHeading codeLanguage = { codeLanguage } stackframe = { stackframe } isLibraryFrame = { isLibraryFrame } / > } id = { id } initialIsOpen = { initialIsOpen } > < ContextContainer isLibraryFrame = { isLibraryFrame } > < Context stackframe = { stackframe } codeLanguage = { codeLanguage } isLibraryFrame = { isLibraryFrame } / > < /ContextContainer> < Variables vars = { stackframe . vars } / > < /EuiAccordion>); } function hasLineContext ( stackframe ) { return stackframe . line ?. hasOwnProperty ( 'context' ) || false ; }