import React, { Children, cloneElement, FC, ReactElement } from 'react'
import Drawer from '../Drawer'
import type { IDrawerProps } from '../Drawer/Drawer'

export const TemporaryDrawer: FC<IDrawerProps> = ({
  children,
  open,
  onClose,
  ...other
}) => (
  <Drawer variant="temporary" open={open} onClose={onClose} {...other}>
    {Children.map(children, c =>
      cloneElement(c as ReactElement<any>, { onClick: onClose })
    )}
  </Drawer>
)
export default TemporaryDrawer
