import classNames from 'classnames'; import { FC, WebCellProps } from 'web-cell'; import { Size } from '../type'; export interface ModalProps extends WebCellProps { backdrop?: 'static' | boolean; size?: 'sm' | 'lg' | 'xl'; fullscreen?: true | `${Size}-down`; centered?: boolean; scrollable?: boolean; animation?: boolean; show?: boolean; } const emitHideByKeyUp = () => document .querySelectorAll('.modal.show') .forEach(modal => modal.dispatchEvent(new CustomEvent('hide'))); const emitHideByClick = ({ currentTarget }: MouseEvent) => (currentTarget as HTMLElement) .closest('.modal') .dispatchEvent(new CustomEvent('hide')); export const Modal: FC = ({ className, backdrop, size, fullscreen, centered, scrollable, animation, show, ref, children, ...props }) => (
node ? globalThis.addEventListener?.('keyup', emitHideByKeyUp) : globalThis.removeEventListener?.('keyup', emitHideByKeyUp) } {...props} >
{children}
); export interface ModalHeaderProps extends WebCellProps { closeButton?: boolean; } export const ModalHeader: FC = ({ className = '', children, closeButton, ...props }) => (
{children} {closeButton && (
); export type ModalTitleProps = WebCellProps; export const ModalTitle: FC = ({ className = 'fs-5', children, ...props }) => (

{children}

); export type ModalBodyProps = WebCellProps; export const ModalBody: FC = ({ className = '', children, ...props }) => (
{children}
); export type ModalFooterProps = WebCellProps; export const ModalFooter: FC = ({ className = '', children, ...props }) => (
{children}
);