import type { JSX } from "solid-js";
import { Portal } from "../../utilities/portal/portal";

/** Props for AlertDialog.Portal. */
export interface AlertDialogPortalProps {
  target?: Element | null;
  children: JSX.Element;
}

/** Renders children into a portal (defaults to document.body). */
export function AlertDialogPortal(props: AlertDialogPortalProps): JSX.Element {
  return props.target !== undefined ? (
    <Portal target={props.target}>{props.children}</Portal>
  ) : (
    <Portal>{props.children}</Portal>
  );
}
