@ahmiao666/ahmiao-react-dialog-element
Version:
61 lines (60 loc) • 2.07 kB
TypeScript
import React from "react";
export interface DialogCustomOptions {
component: React.ComponentType<any>;
width?: number | string;
maskClosable?: boolean;
title?: string;
showIcon?: boolean;
showClose?: boolean;
icon?: any;
maskBg?: string;
props?: Record<string, any>;
onNext?: (value?: any) => void;
familyName?: string;
style?: React.CSSProperties;
}
type DialogState = {
visible: boolean;
options: DialogCustomOptions | null;
resolve?: (value: any) => void;
reject?: (reason?: any) => void;
};
type DialogStateMap = Map<string, DialogState>;
export declare function openDialogCustom(options: DialogCustomOptions): Promise<any>;
export declare const DialogCustomStaticMethods: {
/**
* 打开弹窗
*/
open: (component: React.ComponentType<any>, options?: Omit<DialogCustomOptions, "component">) => Promise<any>;
/**
* 打开指定family的弹窗
*/
openWithFamily: (familyName: string, component: React.ComponentType<any>, options?: Omit<DialogCustomOptions, "component" | "familyName">) => Promise<any>;
/**
* 关闭指定family的弹窗
*/
close: (familyName?: string) => void;
/**
* 关闭所有弹窗
*/
closeAll: () => void;
/**
* 获取所有弹窗状态
*/
getStates: () => DialogStateMap;
/**
* 检查是否有弹窗打开
*/
hasOpenDialog: (familyName?: string) => boolean;
};
export declare function useDialogStates(): DialogStateMap;
export declare function useDialogSelector<T>(selector: (states: DialogStateMap) => T): T;
export declare function useHasOpenDialog(): boolean;
export declare function useFamilyVisible(familyName: string): boolean;
export declare function getDialogFrozenSnapshot(): ReadonlyMap<string, Readonly<{
visible: boolean;
options: DialogCustomOptions | null;
}>>;
export declare function subscribeHasOpen(listener: (hasOpen: boolean) => void): () => void;
export declare const useDialogCustom: typeof openDialogCustom;
export default openDialogCustom;