import React, { useEffect } from 'react'; import trapFocus from '../utils/trapFocus'; import Typography from '../Typography/Typography'; export interface DrawerProps { ariaLabel?: string; callback: Function; children: React.ReactNode; id?: string; onBottom?: boolean; onRight?: boolean; openCallback?: Function; title?: string; showBack?: boolean; showClose?: boolean; showMask?: boolean; } const Drawer = ({ ariaLabel, callback, children, id = 'myDrawer', onBottom = false, onRight = false, openCallback = () => {}, title, showBack = false, showClose = true, showMask = true, }: DrawerProps) => { useEffect(() => { if (openCallback !== null) openCallback(); document.addEventListener('keydown', (e) => { trapFocus(e, `#${id}--drawer`, true); }); }, [id, openCallback]); return ( <>