ngx-modialog
Version:
Modal / Dialog for Angular
53 lines (52 loc) • 1.75 kB
JavaScript
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
import { Injectable } from '@angular/core';
import { DROP_IN_TYPE } from 'ngx-modialog';
export class JSNativeModalRenderer {
/**
* @param {?} dialog
* @param {?} vcRef
* @return {?}
*/
render(dialog, vcRef) {
let /** @type {?} */ result;
switch (dialog.context.dialogType) {
case DROP_IN_TYPE.alert:
window.alert(dialog.context.message);
result = true;
break;
case DROP_IN_TYPE.prompt:
result = window.prompt(dialog.context.message, dialog.context.promptDefault);
break;
case DROP_IN_TYPE.confirm:
result = window.confirm(dialog.context.message);
break;
}
dialog.destroy = () => {
};
if (result === false) {
dialog.dismiss();
}
else {
dialog.close(result);
}
// we need to return ComponentRef<ModalOverlay> but a native dialog does'nt have that
// so we resolve an empty promise, the user of this renderer should expect that.
return /** @type {?} */ ({});
}
}
JSNativeModalRenderer.decorators = [
{ type: Injectable },
];
function JSNativeModalRenderer_tsickle_Closure_declarations() {
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
JSNativeModalRenderer.decorators;
/**
* @nocollapse
* @type {function(): !Array<(null|{type: ?, decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>)})>}
*/
JSNativeModalRenderer.ctorParameters;
}
//# sourceMappingURL=js-native-modal-renderer.js.map