heroui-modal-provider
Version:
[](https://www.npmjs.com/package/heroui-modal-provider) [](https://w
45 lines (44 loc) • 1.42 kB
TypeScript
import { ComponentType } from 'react';
export declare type ModalComponent<P> = ComponentType<P>;
export declare type ModalComponentProps<P> = Omit<P, 'isOpen'>;
export interface Props {
isOpen?: Boolean;
[key: string]: any;
}
export interface Options {
hideOnClose?: boolean;
destroyOnClose?: boolean;
rootId?: string;
}
export interface State {
[id: string]: StateElement;
}
export interface StateElement {
component: ComponentType<any>;
props?: Props;
options?: Options;
}
export declare type ActionMap<M extends {
[index: string]: any;
}> = {
[Key in keyof M]: M[Key] extends undefined ? {
type: Key;
} : {
type: Key;
payload: M[Key];
};
};
export declare type UpdateFn = <P extends Props>(id: string, props: Partial<ModalComponentProps<P>>) => void;
export declare type HideFn = (id: string) => void;
export declare type DestroyFn = (id: string) => void;
export declare type DestroyByRootIdFn = (rootId: string) => void;
export declare type ShowFn = <P extends Props>(component: ComponentType<P>, props?: ModalComponentProps<P>, options?: Options) => ShowFnOutput<P>;
export interface ShowFnOutput<P> {
id: string;
hide: () => void;
destroy: () => void;
update: (newProps: Partial<ModalComponentProps<P>>) => void;
}
export interface ModalConfig {
enforceProvider: boolean;
}