import React from 'react';
import { clsx } from 'clsx';
import * as BaseDialog from '@radix-ui/react-dialog';

import { forwardRef } from '../utils/react';
import { Box } from '../box';
import * as css from './dialog.css';

export interface DialogOverlayProps extends BaseDialog.DialogOverlayProps {}

export const DialogOverlay = forwardRef<'div', DialogOverlayProps>(
  function DialogOverlay({ children, className, ...rest }, ref) {
    const cn = clsx(className, css.overlay);

    return (
      <BaseDialog.Overlay asChild {...rest}>
        <Box ref={ref} className={cn}>
          {children}
        </Box>
      </BaseDialog.Overlay>
    );
  },
);
