2020-08-09 18:58:19 +02:00
|
|
|
import * as React from "react";
|
|
|
|
import {ReactElement} from "react";
|
2020-09-12 15:49:20 +02:00
|
|
|
import {Registry} from "../../events";
|
|
|
|
import {Translatable} from "../../ui/react-elements/i18n";
|
2020-08-09 18:58:19 +02:00
|
|
|
|
|
|
|
export type ModalType = "error" | "warning" | "info" | "none";
|
|
|
|
|
|
|
|
export interface ModalOptions {
|
|
|
|
destroyOnClose?: boolean;
|
|
|
|
|
|
|
|
defaultSize?: { width: number, height: number };
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ModalEvents {
|
|
|
|
"open": {},
|
|
|
|
"close": {},
|
|
|
|
|
|
|
|
/* create is implicitly at object creation */
|
|
|
|
"destroy": {}
|
|
|
|
}
|
|
|
|
|
|
|
|
export enum ModalState {
|
|
|
|
SHOWN,
|
|
|
|
HIDDEN,
|
|
|
|
DESTROYED
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ModalController {
|
|
|
|
getOptions() : Readonly<ModalOptions>;
|
|
|
|
getEvents() : Registry<ModalEvents>;
|
|
|
|
getState() : ModalState;
|
|
|
|
|
|
|
|
show() : Promise<void>;
|
|
|
|
hide() : Promise<void>;
|
|
|
|
|
|
|
|
destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
export abstract class AbstractModal {
|
|
|
|
protected constructor() {}
|
|
|
|
|
|
|
|
abstract renderBody() : ReactElement;
|
2020-09-29 15:02:36 +02:00
|
|
|
abstract title() : string | React.ReactElement;
|
2020-08-09 18:58:19 +02:00
|
|
|
|
|
|
|
/* only valid for the "inline" modals */
|
|
|
|
type() : ModalType { return "none"; }
|
|
|
|
|
|
|
|
protected onInitialize() {}
|
|
|
|
protected onDestroy() {}
|
|
|
|
|
|
|
|
protected onClose() {}
|
|
|
|
protected onOpen() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface ModalRenderer {
|
|
|
|
renderModal(modal: AbstractModal | undefined);
|
|
|
|
}
|