TeaWeb/shared/js/ui/react-elements/external-modal/index.ts
2021-01-22 16:50:55 +01:00

17 lines
No EOL
758 B
TypeScript

import "./Controller";
import {ModalController, ModalOptions} from "../ModalDefinitions";
export type ControllerFactory = (modalType: string, constructorArguments?: any[], options?: ModalOptions) => ModalController;
let modalControllerFactory: ControllerFactory;
export function setExternalModalControllerFactory(factory: ControllerFactory) {
modalControllerFactory = factory;
}
export function spawnExternalModal<EventClass extends { [key: string]: any }>(modalType: string, constructorArguments?: any[], options?: ModalOptions) : ModalController {
if(typeof modalControllerFactory === "undefined") {
throw tr("No external modal factory has been set");
}
return modalControllerFactory(modalType, constructorArguments, options);
}