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

/** Props for Drawer.Portal. */
export interface DrawerPortalProps {
  /** Optional target element; defaults to document.body. */
  target?: Element | null;
  children: JSX.Element;
}

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