///
import { StateStore } from 'stream-chat';
export type GetDialogParams = {
id: DialogId;
};
export type GetOrCreateDialogParams = GetDialogParams & {
/**
* Optional per-dialog override.
* If undefined, manager-level `closeOnClickOutside` is used.
*/
closeOnClickOutside?: boolean;
};
type DialogId = string;
export type Dialog = {
close: () => void;
closeOnClickOutside?: boolean;
id: DialogId;
isOpen: boolean | undefined;
open: (zIndex?: number) => void;
removalTimeout: NodeJS.Timeout | undefined;
remove: () => void;
toggle: (closeAll?: boolean) => void;
};
export type DialogManagerOptions = {
/** Enables closing all dialogs in this manager when clicking overlay/outside area. */
closeOnClickOutside?: boolean;
id?: string;
};
type Dialogs = Record;
export type DialogManagerState = {
dialogsById: Dialogs;
};
/**
* Keeps a map of Dialog objects.
* Dialog can be controlled via `Dialog` object retrieved using `useDialog()` hook.
* The hook returns an object with the following API:
*
* - `dialog.open()` - opens the dialog
* - `dialog.close()` - closes the dialog
* - `dialog.toggle()` - toggles the dialog open state. Accepts boolean argument closeAll. If enabled closes any other dialog that would be open.
* - `dialog.remove()` - removes the dialog object reference from the state (primarily for cleanup purposes)
*/
export declare class DialogManager {
/** Manager-level outside click policy used by DialogPortal dismiss handlers. */
closeOnClickOutside: boolean;
id: string;
state: StateStore;
constructor({ closeOnClickOutside, id }?: DialogManagerOptions);
get openDialogCount(): number;
get(id: DialogId): Dialog | undefined;
getOrCreate({ closeOnClickOutside, id }: GetOrCreateDialogParams): Dialog;
open(params: GetOrCreateDialogParams, closeRest?: boolean): void;
close(id: DialogId): void;
closeAll(): void;
toggle(params: GetOrCreateDialogParams, closeAll?: boolean): void;
remove: (id: DialogId) => void;
/**
* Marks the dialog state as unused. If the dialog id is referenced again quickly,
* the state will not be removed. Otherwise, the state will be removed after
* a short timeout.
*/
markForRemoval(id: DialogId): void;
cancelPendingRemoval(id: DialogId): void;
}
export {};
//# sourceMappingURL=DialogManager.d.ts.map