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

import { useDialogContext } from './dialog.context';

export interface DialogProps
  extends Omit<
    BaseDialog.DialogProps,
    'open' | 'defaultOpen' | 'onOpenChange' | 'modal'
  > {}

export function DialogRoot(props: DialogProps) {
  const { open, modal, setOpen } = useDialogContext();

  return (
    <BaseDialog.Root
      {...props}
      open={open}
      onOpenChange={setOpen}
      modal={modal}
    />
  );
}
