import * as React from 'react' ; import { OpenSearchDashboardsServices } from '../context/types' ; import { OpenSearchDashboardsReactOverlays } from './types' ; import { toMountPoint } from '../util' ; export const createReactOverlays = ( services ) : OpenSearchDashboardsReactOverlays => { const checkCoreService = ( ) => { if ( ! services . overlays ) { throw new TypeError ( 'Could not show overlay as overlays service is not available.' ) ; } } ; const openFlyout = ( node , options ? ) => { checkCoreService ( ) ; return services . overlays ! . openFlyout ( toMountPoint ( < > { node } < />), options); } ; const openModal = ( node , options ? ) => { checkCoreService ( ) ; return services . overlays ! . openModal ( toMountPoint ( < > { node } < />), options); } ; const overlays = { openFlyout , openModal , } ; return overlays ; } ;