import * as React from 'react'; import { Component, ComponentClass, MouseEvent, ReactNode } from 'react'; import getPassThrough, { PassTroughFunction } from '../../utils/getPassThrough'; import { PortalType } from '../Portal'; export interface ContainerNodeProps { active: boolean; className?: string; } export interface BackdropNodeProps { active: boolean; onClick(event: MouseEvent); } export interface OverlayFactoryArgs { Portal: PortalType; ContainerNode: ComponentClass; BackdropNode: ComponentClass; passthrough: PassTroughFunction< OverlayProps, 'Portal' | 'ContainerNode' | 'BackdropNode' >; } export interface OverlayProps { active: boolean; children: ReactNode; className?: string; container?: HTMLElement | (() => HTMLElement); onClick(event: MouseEvent); onPortalMount?(): void; onPortalUnmount?(): void; parentId?: string; } export default function overlayFactory({ BackdropNode, ContainerNode, Portal, passthrough, }: OverlayFactoryArgs): ComponentClass { const passProps = getPassThrough(passthrough); return class Overlay extends Component { render() { const { active, children, className, container, onClick, onPortalMount, onPortalUnmount, parentId, } = this.props; return ( {children} ); } }; }