UNPKG

@acrool/react-modal

Version:
24 lines (23 loc) 1.15 kB
import { default as React } from 'react'; import { IModalOptions } from '../types'; interface ICreateModal<T> extends React.FC<T> { show: TModalShowMulti<T>; showWithKey: TModalShowWithKeyMulti<T>; } type TModalShow = () => void; type TModalShowWithKey = (queueKey: string) => void; type TModalShowArgs<T> = (args: T) => void; type TModalShowNotRequiredArgs<T> = (partialArgs?: T) => void; type TModalShowWithKeyArgs<T> = (queueKey: string, args: T) => void; type TModalShowWithKeyNotRequiredArgs<T> = (queueKey: string, partialArgs?: T) => void; type TModalShowMulti<T> = T extends undefined ? TModalShow : T extends Required<{}> ? TModalShowArgs<T> : TModalShowNotRequiredArgs<T>; type TModalShowWithKeyMulti<T> = T extends undefined ? TModalShowWithKey : T extends Required<{}> ? TModalShowWithKeyArgs<T> : TModalShowWithKeyNotRequiredArgs<T>; /** * 產生帶 framer-motion 功能的Modal * * 需要呼叫 show 才會傳送到 portal * @param ModalComponent * @param modalOptions */ declare function createModal<T = undefined>(ModalComponent: React.FC<T>, modalOptions?: IModalOptions): ICreateModal<T>; export default createModal;