import type { ReactElement } from "react";
import { createElement } from "react";
import type { TModalWrapperProps } from "../config/types";

/**
 * Внутренний компонент модального окна
 * @returns {ReactElement}
 */
const ModalWrapper = (props: TModalWrapperProps): ReactElement => {

  const { isInline, ...rest } = props;

  const type = isInline ? "div" : "template";

  const modal = createElement(type, {
    ...rest,
    "aria-hidden": isInline ? true : undefined,
    hidden: isInline ? true : undefined,
  });

  return (
    <div style={{ display: "contents" }}>
      {modal}
    </div>
  );
};

export {
  ModalWrapper,
};
