@neocomplexx/ngx-neo-modal-mat
Version:
689 lines (682 loc) • 36.4 kB
JavaScript
import { __awaiter } from 'tslib';
import { ɵɵelementStart, ɵɵelement, ɵɵelementEnd, ɵɵtext, ɵɵnextContext, ɵɵadvance, ɵɵtextInterpolate, ɵɵgetCurrentView, ɵɵlistener, ɵɵrestoreView, ɵɵpropertyInterpolate, ɵɵproperty, ɵɵpipe, ɵɵpipeBind1, ɵɵdirectiveInject, ɵɵdefineComponent, ɵɵstaticViewQuery, ɵɵviewQuery, ɵɵqueryRefresh, ɵɵloadQuery, ɵɵtemplate, ɵsetClassMetadata, Component, Inject, ViewChild, ɵɵinject, ɵɵdefineInjectable, Injectable, ɵɵdefineNgModule, ɵɵdefineInjector, ɵɵsetNgModuleScope, NgModule } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef, MatDialogContent, MatDialogActions, MatDialog, MAT_DIALOG_DEFAULT_OPTIONS, MatDialogModule } from '@angular/material/dialog';
import { NgIf, CommonModule } from '@angular/common';
import { ɵangular_packages_forms_forms_y, NgControlStatusGroup, NgForm, DefaultValueAccessor, NgControlStatus, NgModel, FormsModule } from '@angular/forms';
import { MatFormField } from '@angular/material/form-field';
import { MatInput, MatInputModule } from '@angular/material/input';
import { MatButton, MatButtonModule } from '@angular/material/button';
import { TranslatePipe, TranslateService, TranslateModule } from '@ngx-translate/core';
const _c0 = ["buttons"];
const _c1 = ["myInput"];
function NgxNeoModalMatComponent_div_2_Template(rf, ctx) { if (rf & 1) {
ɵɵelementStart(0, "div", 16);
ɵɵelement(1, "div", 17);
ɵɵelement(2, "span", 18);
ɵɵelement(3, "span", 19);
ɵɵelement(4, "div", 20);
ɵɵelement(5, "div", 21);
ɵɵelement(6, "div", 22);
ɵɵelementEnd();
} }
function NgxNeoModalMatComponent_div_3_Template(rf, ctx) { if (rf & 1) {
ɵɵelementStart(0, "div", 23);
ɵɵelementStart(1, "span", 24);
ɵɵelement(2, "span", 25);
ɵɵelement(3, "span", 26);
ɵɵelementEnd();
ɵɵelementEnd();
} }
function NgxNeoModalMatComponent_div_4_Template(rf, ctx) { if (rf & 1) {
ɵɵelementStart(0, "div", 27);
ɵɵtext(1, "!");
ɵɵelementEnd();
} }
function NgxNeoModalMatComponent_div_5_Template(rf, ctx) { if (rf & 1) {
ɵɵelementStart(0, "div", 28);
ɵɵtext(1, "i");
ɵɵelementEnd();
} }
function NgxNeoModalMatComponent_div_6_Template(rf, ctx) { if (rf & 1) {
ɵɵelementStart(0, "div", 29);
ɵɵtext(1, "?");
ɵɵelementEnd();
} }
function NgxNeoModalMatComponent_h4_7_Template(rf, ctx) { if (rf & 1) {
ɵɵelementStart(0, "h4");
ɵɵtext(1);
ɵɵelementEnd();
} if (rf & 2) {
const ctx_r5 = ɵɵnextContext();
ɵɵadvance(1);
ɵɵtextInterpolate(ctx_r5.config.title.text);
} }
function NgxNeoModalMatComponent_form_10_Template(rf, ctx) { if (rf & 1) {
const _r15 = ɵɵgetCurrentView();
ɵɵelementStart(0, "form", 30);
ɵɵelementStart(1, "mat-form-field", 30);
ɵɵelementStart(2, "input", 31, 32);
ɵɵlistener("ngModelChange", function NgxNeoModalMatComponent_form_10_Template_input_ngModelChange_2_listener($event) { ɵɵrestoreView(_r15); const ctx_r14 = ɵɵnextContext(); return ctx_r14.config.input.value = $event; })("keyup.enter", function NgxNeoModalMatComponent_form_10_Template_input_keyup_enter_2_listener() { ɵɵrestoreView(_r15); const ctx_r16 = ɵɵnextContext(); return ctx_r16.setFocus(); });
ɵɵelementEnd();
ɵɵelementEnd();
ɵɵelementEnd();
} if (rf & 2) {
const ctx_r6 = ɵɵnextContext();
ɵɵadvance(2);
ɵɵpropertyInterpolate("placeholder", ctx_r6.config.input.placeholder);
ɵɵproperty("ngModel", ctx_r6.config.input.value);
} }
function NgxNeoModalMatComponent_button_13_Template(rf, ctx) { if (rf & 1) {
const _r18 = ɵɵgetCurrentView();
ɵɵelementStart(0, "button", 33);
ɵɵlistener("click", function NgxNeoModalMatComponent_button_13_Template_button_click_0_listener() { ɵɵrestoreView(_r18); const ctx_r17 = ɵɵnextContext(); return ctx_r17.informResult("Accept"); });
ɵɵtext(1);
ɵɵpipe(2, "translate");
ɵɵelementEnd();
} if (rf & 2) {
ɵɵadvance(1);
ɵɵtextInterpolate(ɵɵpipeBind1(2, 1, "BTNACCEPT"));
} }
function NgxNeoModalMatComponent_button_14_Template(rf, ctx) { if (rf & 1) {
const _r20 = ɵɵgetCurrentView();
ɵɵelementStart(0, "button", 34);
ɵɵlistener("click", function NgxNeoModalMatComponent_button_14_Template_button_click_0_listener() { ɵɵrestoreView(_r20); const ctx_r19 = ɵɵnextContext(); return ctx_r19.informResult("Cancel"); });
ɵɵtext(1);
ɵɵpipe(2, "translate");
ɵɵelementEnd();
} if (rf & 2) {
ɵɵadvance(1);
ɵɵtextInterpolate(ɵɵpipeBind1(2, 1, "BTNCANCEL"));
} }
function NgxNeoModalMatComponent_button_15_Template(rf, ctx) { if (rf & 1) {
const _r22 = ɵɵgetCurrentView();
ɵɵelementStart(0, "button", 35);
ɵɵlistener("click", function NgxNeoModalMatComponent_button_15_Template_button_click_0_listener() { ɵɵrestoreView(_r22); const ctx_r21 = ɵɵnextContext(); return ctx_r21.informResult("Yes"); });
ɵɵtext(1);
ɵɵpipe(2, "translate");
ɵɵelementEnd();
} if (rf & 2) {
ɵɵadvance(1);
ɵɵtextInterpolate(ɵɵpipeBind1(2, 1, "BTNYES"));
} }
function NgxNeoModalMatComponent_button_16_Template(rf, ctx) { if (rf & 1) {
const _r24 = ɵɵgetCurrentView();
ɵɵelementStart(0, "button", 36);
ɵɵlistener("click", function NgxNeoModalMatComponent_button_16_Template_button_click_0_listener() { ɵɵrestoreView(_r24); const ctx_r23 = ɵɵnextContext(); return ctx_r23.informResult("Retry"); });
ɵɵtext(1);
ɵɵpipe(2, "translate");
ɵɵelementEnd();
} if (rf & 2) {
ɵɵadvance(1);
ɵɵtextInterpolate(ɵɵpipeBind1(2, 1, "BTNRETR"));
} }
function NgxNeoModalMatComponent_button_17_Template(rf, ctx) { if (rf & 1) {
const _r26 = ɵɵgetCurrentView();
ɵɵelementStart(0, "button", 37);
ɵɵlistener("click", function NgxNeoModalMatComponent_button_17_Template_button_click_0_listener() { ɵɵrestoreView(_r26); const ctx_r25 = ɵɵnextContext(); return ctx_r25.informResult("No"); });
ɵɵtext(1);
ɵɵpipe(2, "translate");
ɵɵelementEnd();
} if (rf & 2) {
ɵɵadvance(1);
ɵɵtextInterpolate(ɵɵpipeBind1(2, 1, "BTNO"));
} }
class NgxNeoModalMatComponent {
constructor(data, activeModal) {
this.data = data;
this.activeModal = activeModal;
this.config = {
title: {
visibility: true,
text: 'This is a title'
},
message: 'This is a message',
type: null,
input: {
visibility: false,
placeholder: 'Ingrese su texto aquí',
value: null,
autofocus: false,
id: 'neoInput'
},
button: {
yes: {
visibility: false,
autofocus: false,
text: 'Si',
id: 'neoBtnYes'
},
no: {
visibility: false,
autofocus: false,
text: 'No',
id: 'neoBtnNo'
},
retry: {
visibility: false,
autofocus: false,
text: 'Reintentar',
id: 'neoBtnRetry'
},
cancel: {
visibility: true,
autofocus: false,
text: 'Cancelar',
id: 'neoBtnCancel'
},
accept: {
visibility: true,
autofocus: true,
text: 'Aceptar',
id: 'neoBtnAccept'
},
}
};
this.mergeDeep(this.config, data.config);
}
ngOnInit() {
}
isObject(item) {
return (item && typeof item === 'object' && !Array.isArray(item));
}
mergeDeep(target, ...sources) {
if (!sources.length) {
return target;
}
const source = sources.shift();
if (this.isObject(target) && this.isObject(source)) {
for (const key in source) {
if (this.isObject(source[key])) {
if (!target[key]) {
Object.assign(target, { [key]: {} });
}
this.mergeDeep(target[key], source[key]);
}
else {
Object.assign(target, { [key]: source[key] });
}
}
}
return this.mergeDeep(target, ...sources);
}
activeFocus(inputModal = true) {
const foc = this.getButtonFocus();
const inputFocus = this.getInputFocus();
// Find element in DOM and focus.
if (inputFocus && inputModal && (!foc || foc === 'neoBtnAccept')) {
this.input.nativeElement.focus();
}
else if (foc) {
const button = this.btn.nativeElement.children.namedItem(foc);
if (button) {
button.focus();
}
}
}
getButtonFocus() {
const button = Object.keys(this.config.button)
.find(key => this.config.button[key].visibility && this.config.button[key].autofocus);
if (button) {
return this.config.button[button].id;
}
else {
return null;
}
}
getInputFocus() {
if (this.config.input.visibility && this.config.input.autofocus) {
return this.config.input.id;
}
else {
return null;
}
}
ngAfterViewInit() {
setTimeout(() => this.activeFocus(), 0);
}
informResult(res) {
const button = AlertButton[res];
const respuesta = new AlertResult(button, this.config.input.value);
this.activeModal.close(respuesta);
}
setFocus() {
this.activeFocus(false);
}
}
/** @nocollapse */ NgxNeoModalMatComponent.ɵfac = function NgxNeoModalMatComponent_Factory(t) { return new (t || NgxNeoModalMatComponent)(ɵɵdirectiveInject(MAT_DIALOG_DATA), ɵɵdirectiveInject(MatDialogRef)); };
/** @nocollapse */ NgxNeoModalMatComponent.ɵcmp = ɵɵdefineComponent({ type: NgxNeoModalMatComponent, selectors: [["lib-ngx-neo-modal-mat"]], viewQuery: function NgxNeoModalMatComponent_Query(rf, ctx) { if (rf & 1) {
ɵɵstaticViewQuery(_c0, true);
ɵɵviewQuery(_c1, true);
} if (rf & 2) {
var _t;
ɵɵqueryRefresh(_t = ɵɵloadQuery()) && (ctx.btn = _t.first);
ɵɵqueryRefresh(_t = ɵɵloadQuery()) && (ctx.input = _t.first);
} }, decls: 18, vars: 13, consts: [["mat-dialog-content", "", 1, "text-center", "mat-modal"], [1, "icons"], ["class", "swal2-icon swal2-success swal2-animate-success-icon", 4, "ngIf"], ["class", "swal2-icon swal2-error swal2-animate-error-icon", 4, "ngIf"], ["class", "swal2-icon swal2-warning", 4, "ngIf"], ["class", "swal2-icon swal2-info", 4, "ngIf"], ["class", "swal2-icon swal2-question", 4, "ngIf"], [4, "ngIf"], ["class", "full-width", 4, "ngIf"], ["align", "end"], ["buttons", ""], ["mat-raised-button", "", "color", "primary", "id", "neoBtnAccept", "type", "button", 3, "click", 4, "ngIf"], ["mat-raised-button", "", "color", "primary", "id", "neoBtnCancel", "type", "button", 3, "click", 4, "ngIf"], ["mat-raised-button", "", "color", "primary", "id", "neoBtnYes", "type", "button", 3, "click", 4, "ngIf"], ["mat-raised-button", "", "color", "primary", "id", "neoBtnRetry", "type", "button", 3, "click", 4, "ngIf"], ["mat-raised-button", "", "color", "primary", "id", "neoBtnNo", "type", "button", 3, "click", 4, "ngIf"], [1, "swal2-icon", "swal2-success", "swal2-animate-success-icon"], [1, "swal2-success-circular-line-left"], [1, "swal2-success-line-tip", "swal2-animate-success-line-tip"], [1, "swal2-success-line-long", "swal2-animate-success-line-long"], [1, "swal2-success-ring"], [1, "swal2-success-fix"], [1, "swal2-success-circular-line-right"], [1, "swal2-icon", "swal2-error", "swal2-animate-error-icon"], [1, "swal2-x-mark", "swal2-animate-x-mark"], [1, "swal2-x-mark-line-left"], [1, "swal2-x-mark-line-right"], [1, "swal2-icon", "swal2-warning"], [1, "swal2-icon", "swal2-info"], [1, "swal2-icon", "swal2-question"], [1, "full-width"], ["name", "inputModal", "matInput", "", "id", "neoInput", "type", "text", 3, "ngModel", "placeholder", "ngModelChange", "keyup.enter"], ["myInput", ""], ["mat-raised-button", "", "color", "primary", "id", "neoBtnAccept", "type", "button", 3, "click"], ["mat-raised-button", "", "color", "primary", "id", "neoBtnCancel", "type", "button", 3, "click"], ["mat-raised-button", "", "color", "primary", "id", "neoBtnYes", "type", "button", 3, "click"], ["mat-raised-button", "", "color", "primary", "id", "neoBtnRetry", "type", "button", 3, "click"], ["mat-raised-button", "", "color", "primary", "id", "neoBtnNo", "type", "button", 3, "click"]], template: function NgxNeoModalMatComponent_Template(rf, ctx) { if (rf & 1) {
ɵɵelementStart(0, "div", 0);
ɵɵelementStart(1, "div", 1);
ɵɵtemplate(2, NgxNeoModalMatComponent_div_2_Template, 7, 0, "div", 2);
ɵɵtemplate(3, NgxNeoModalMatComponent_div_3_Template, 4, 0, "div", 3);
ɵɵtemplate(4, NgxNeoModalMatComponent_div_4_Template, 2, 0, "div", 4);
ɵɵtemplate(5, NgxNeoModalMatComponent_div_5_Template, 2, 0, "div", 5);
ɵɵtemplate(6, NgxNeoModalMatComponent_div_6_Template, 2, 0, "div", 6);
ɵɵelementEnd();
ɵɵtemplate(7, NgxNeoModalMatComponent_h4_7_Template, 2, 1, "h4", 7);
ɵɵelementStart(8, "p");
ɵɵtext(9);
ɵɵelementEnd();
ɵɵtemplate(10, NgxNeoModalMatComponent_form_10_Template, 4, 2, "form", 8);
ɵɵelementEnd();
ɵɵelementStart(11, "mat-dialog-actions", 9, 10);
ɵɵtemplate(13, NgxNeoModalMatComponent_button_13_Template, 3, 3, "button", 11);
ɵɵtemplate(14, NgxNeoModalMatComponent_button_14_Template, 3, 3, "button", 12);
ɵɵtemplate(15, NgxNeoModalMatComponent_button_15_Template, 3, 3, "button", 13);
ɵɵtemplate(16, NgxNeoModalMatComponent_button_16_Template, 3, 3, "button", 14);
ɵɵtemplate(17, NgxNeoModalMatComponent_button_17_Template, 3, 3, "button", 15);
ɵɵelementEnd();
} if (rf & 2) {
ɵɵadvance(2);
ɵɵproperty("ngIf", ctx.config.type === "success");
ɵɵadvance(1);
ɵɵproperty("ngIf", ctx.config.type === "error");
ɵɵadvance(1);
ɵɵproperty("ngIf", ctx.config.type === "warning");
ɵɵadvance(1);
ɵɵproperty("ngIf", ctx.config.type === "info");
ɵɵadvance(1);
ɵɵproperty("ngIf", ctx.config.type === "question");
ɵɵadvance(1);
ɵɵproperty("ngIf", ctx.config.title.visibility);
ɵɵadvance(2);
ɵɵtextInterpolate(ctx.config.message);
ɵɵadvance(1);
ɵɵproperty("ngIf", ctx.config.input.visibility);
ɵɵadvance(3);
ɵɵproperty("ngIf", ctx.config.button.accept.visibility);
ɵɵadvance(1);
ɵɵproperty("ngIf", ctx.config.button.cancel.visibility);
ɵɵadvance(1);
ɵɵproperty("ngIf", ctx.config.button.yes.visibility);
ɵɵadvance(1);
ɵɵproperty("ngIf", ctx.config.button.retry.visibility);
ɵɵadvance(1);
ɵɵproperty("ngIf", ctx.config.button.no.visibility);
} }, directives: [MatDialogContent, NgIf, MatDialogActions, ɵangular_packages_forms_forms_y, NgControlStatusGroup, NgForm, MatFormField, MatInput, DefaultValueAccessor, NgControlStatus, NgModel, MatButton], pipes: [TranslatePipe], styles: [".modal-footer[_ngcontent-%COMP%], .modal-header[_ngcontent-%COMP%]{border:0}@-webkit-keyframes showSweetAlert{0%{transform:scale(.7)}45%{transform:scale(1.05)}80%{transform:scale(.95)}100%{transform:scale(1)}}@keyframes showSweetAlert{0%{transform:scale(.7)}45%{transform:scale(1.05)}80%{transform:scale(.95)}100%{transform:scale(1)}}@-webkit-keyframes hideSweetAlert{0%{transform:scale(1);opacity:1}100%{transform:scale(.5);opacity:0}}@keyframes hideSweetAlert{0%{transform:scale(1);opacity:1}100%{transform:scale(.5);opacity:0}}.swal2-show[_ngcontent-%COMP%]{-webkit-animation:.3s showSweetAlert;animation:.3s showSweetAlert}.swal2-show.swal2-noanimation[_ngcontent-%COMP%]{-webkit-animation:none;animation:none}.swal2-hide[_ngcontent-%COMP%]{-webkit-animation:.15s forwards hideSweetAlert;animation:.15s forwards hideSweetAlert}.swal2-hide.swal2-noanimation[_ngcontent-%COMP%]{-webkit-animation:none;animation:none}@-webkit-keyframes animate-success-tip{0%,54%{width:0;left:1px;top:19px}70%{width:50px;left:-8px;top:37px}84%{width:17px;left:21px;top:48px}100%{width:25px;left:14px;top:45px}}@keyframes animate-success-tip{0%,54%{width:0;left:1px;top:19px}70%{width:50px;left:-8px;top:37px}84%{width:17px;left:21px;top:48px}100%{width:25px;left:14px;top:45px}}@-webkit-keyframes animate-success-long{0%,65%{width:0;right:46px;top:54px}84%{width:55px;right:0;top:35px}100%{width:47px;right:8px;top:38px}}@keyframes animate-success-long{0%,65%{width:0;right:46px;top:54px}84%{width:55px;right:0;top:35px}100%{width:47px;right:8px;top:38px}}@-webkit-keyframes rotatePlaceholder{0%,5%{transform:rotate(-45deg)}100%,12%{transform:rotate(-405deg)}}@keyframes rotatePlaceholder{0%,5%{transform:rotate(-45deg)}100%,12%{transform:rotate(-405deg)}}.swal2-animate-success-line-tip[_ngcontent-%COMP%]{-webkit-animation:.75s animate-success-tip;animation:.75s animate-success-tip}.swal2-animate-success-line-long[_ngcontent-%COMP%]{-webkit-animation:.75s animate-success-long;animation:.75s animate-success-long}@-webkit-keyframes animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0);opacity:1}}@keyframes animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0);opacity:1}}.swal2-animate-error-icon[_ngcontent-%COMP%]{-webkit-animation:.5s animate-error-icon;animation:.5s animate-error-icon}@-webkit-keyframes animate-x-mark{0%,50%{transform:scale(.4);margin-top:26px;opacity:0}80%{transform:scale(1.15);margin-top:-6px}100%{transform:scale(1);margin-top:0;opacity:1}}@keyframes animate-x-mark{0%,50%{transform:scale(.4);margin-top:26px;opacity:0}80%{transform:scale(1.15);margin-top:-6px}100%{transform:scale(1);margin-top:0;opacity:1}}.swal2-animate-x-mark[_ngcontent-%COMP%]{-webkit-animation:.5s animate-x-mark;animation:.5s animate-x-mark}@-webkit-keyframes rotate-loading{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@keyframes rotate-loading{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}.swal2-success.swal2-animate-success-icon[_ngcontent-%COMP%] .swal2-success-circular-line-right[_ngcontent-%COMP%]{-webkit-animation:4.25s ease-in rotatePlaceholder;animation:4.25s ease-in rotatePlaceholder}.swal2-icon[_ngcontent-%COMP%]{width:80px;height:80px;border:4px solid transparent;border-radius:50%;margin:20px auto 30px;padding:0;position:relative;box-sizing:content-box;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.swal2-icon.swal2-error[_ngcontent-%COMP%]{border-color:#f27474}.swal2-icon.swal2-error[_ngcontent-%COMP%] .swal2-x-mark[_ngcontent-%COMP%]{position:relative;display:block}.swal2-icon.swal2-error[_ngcontent-%COMP%] [class^=swal2-x-mark-line][_ngcontent-%COMP%]{position:absolute;height:5px;width:47px;background-color:#f27474;display:block;top:37px;border-radius:2px}.swal2-icon.swal2-error[_ngcontent-%COMP%] [class^=swal2-x-mark-line][class$=left][_ngcontent-%COMP%]{transform:rotate(45deg);left:17px}.swal2-icon.swal2-error[_ngcontent-%COMP%] [class^=swal2-x-mark-line][class$=right][_ngcontent-%COMP%]{transform:rotate(-45deg);right:16px}.swal2-icon.swal2-warning[_ngcontent-%COMP%]{font-family:\"Helvetica Neue\",Helvetica,Arial,sans-serif;color:#f8bb86;border-color:#facea8;font-size:60px;line-height:80px;text-align:center}.swal2-icon.swal2-info[_ngcontent-%COMP%]{font-family:\"Open Sans\",sans-serif;color:#3fc3ee;border-color:#9de0f6;font-size:60px;line-height:80px;text-align:center}.swal2-icon.swal2-question[_ngcontent-%COMP%]{font-family:\"Helvetica Neue\",Helvetica,Arial,sans-serif;color:#87adbd;border-color:#c9dae1;font-size:60px;line-height:80px;text-align:center}.swal2-icon.swal2-success[_ngcontent-%COMP%]{border-color:#a5dc86}.swal2-icon.swal2-success[_ngcontent-%COMP%] [class^=swal2-success-circular-line][_ngcontent-%COMP%]{border-radius:50%;position:absolute;width:60px;height:120px;transform:rotate(45deg)}.swal2-icon.swal2-success[_ngcontent-%COMP%] [class^=swal2-success-circular-line][class$=left][_ngcontent-%COMP%]{border-radius:120px 0 0 120px;top:-7px;left:-33px;transform:rotate(-45deg);transform-origin:60px 60px}.swal2-icon.swal2-success[_ngcontent-%COMP%] [class^=swal2-success-circular-line][class$=right][_ngcontent-%COMP%]{border-radius:0 120px 120px 0;top:-11px;left:30px;transform:rotate(-45deg);transform-origin:0 60px}.swal2-icon.swal2-success[_ngcontent-%COMP%] .swal2-success-ring[_ngcontent-%COMP%]{width:80px;height:80px;border:4px solid rgba(165,220,134,.2);border-radius:50%;box-sizing:content-box;position:absolute;left:-4px;top:-4px;z-index:2}.swal2-icon.swal2-success[_ngcontent-%COMP%] .swal2-success-fix[_ngcontent-%COMP%]{width:7px;height:90px;position:absolute;left:28px;top:8px;z-index:1;transform:rotate(-45deg)}.swal2-icon.swal2-success[_ngcontent-%COMP%] [class^=swal2-success-line][_ngcontent-%COMP%]{height:5px;background-color:#a5dc86;display:block;border-radius:2px;position:absolute;z-index:2}.swal2-icon.swal2-success[_ngcontent-%COMP%] [class^=swal2-success-line][class$=tip][_ngcontent-%COMP%]{width:25px;left:14px;top:46px;transform:rotate(45deg)}.swal2-icon.swal2-success[_ngcontent-%COMP%] [class^=swal2-success-line][class$=long][_ngcontent-%COMP%]{width:47px;right:8px;top:38px;transform:rotate(-45deg)}.full-width[_ngcontent-%COMP%]{width:100%}.text-center[_ngcontent-%COMP%]{text-align:center}"] });
/*@__PURE__*/ (function () { ɵsetClassMetadata(NgxNeoModalMatComponent, [{
type: Component,
args: [{
selector: 'lib-ngx-neo-modal-mat',
templateUrl: './ngx-neo-modal-mat.component.html',
styleUrls: ['./ngx-neo-modal-mat.component.scss']
}]
}], function () { return [{ type: undefined, decorators: [{
type: Inject,
args: [MAT_DIALOG_DATA]
}] }, { type: MatDialogRef }]; }, { btn: [{
type: ViewChild,
args: ['buttons', { static: true }]
}], input: [{
type: ViewChild,
args: ['myInput', { static: false }]
}] }); })();
class AlertResult {
constructor(ButtonResponse, messageInput) {
this.ButtonResponse = ButtonResponse;
this.messageInput = messageInput;
}
}
// tslint:disable:no-bitwise
var AlertButton;
(function (AlertButton) {
AlertButton[AlertButton["None"] = 0] = "None";
AlertButton[AlertButton["Accept"] = 1] = "Accept";
AlertButton[AlertButton["Cancel"] = 2] = "Cancel";
AlertButton[AlertButton["Yes"] = 4] = "Yes";
AlertButton[AlertButton["No"] = 8] = "No";
AlertButton[AlertButton["Retry"] = 16] = "Retry";
})(AlertButton || (AlertButton = {}));
class NgxNeoModalMatService {
constructor(dialog, translate) {
this.dialog = dialog;
this.translate = translate;
this.originalAlert = window.alert;
window.alert = (msg) => __awaiter(this, void 0, void 0, function* () {
yield this.alert(msg);
});
}
openModal(config) {
return __awaiter(this, void 0, void 0, function* () {
const dialogRef = this.dialog.open(NgxNeoModalMatComponent, {
data: { config: config }
});
return dialogRef.afterClosed().toPromise();
});
}
/**
* Show message. Can be use as window.alert
*/
alert(msg, autofocus = false) {
return __awaiter(this, void 0, void 0, function* () {
const config = {
title: {
visibility: false
},
message: msg,
button: {
cancel: {
visibility: false
},
accept: {
autofocus: autofocus,
}
}
};
yield this.openModal(config);
});
}
/**
*
* Show succsessfull message
*/
success(msg, autofocus = true) {
return __awaiter(this, void 0, void 0, function* () {
const title = yield this.translate.get('SUCCESSTITLE').toPromise();
const config = {
title: {
text: title
},
message: msg,
type: 'success',
button: {
cancel: {
visibility: false
},
accept: {
autofocus: autofocus,
}
}
};
return this.openModal(config);
});
}
/**
*
* Warning message
*/
warning(msg, autofocus = false) {
return __awaiter(this, void 0, void 0, function* () {
const title = yield this.translate.get('WARNTITLE').toPromise();
const config = {
title: {
text: title
},
message: msg,
type: 'warning',
button: {
cancel: {
visibility: false
},
accept: {
autofocus: autofocus,
}
}
};
return this.openModal(config);
});
}
/**
*
* Error message
*/
error(msg, autofocus = true) {
return __awaiter(this, void 0, void 0, function* () {
const title = yield this.translate.get('ERRORTITLE').toPromise();
const config = {
title: {
text: title
},
message: msg,
type: 'error',
button: {
cancel: {
visibility: false
},
accept: {
autofocus: autofocus,
}
}
};
return this.openModal(config);
});
}
/**
*
* Information message
*/
info(msg, autofocus = true) {
return __awaiter(this, void 0, void 0, function* () {
const title = yield this.translate.get('INFOTITLE').toPromise();
const config = {
title: {
text: title
},
message: msg,
type: 'info',
button: {
cancel: {
visibility: false
},
accept: {
autofocus: autofocus,
}
}
};
return this.openModal(config);
});
}
/**
*
* Show decission modal with question and two options for accept or reject.
*/
// tslint:disable-next-line:max-line-length
decision(questionMsg, successMsg, cancelMsg, autofocus = AlertButton.Cancel) {
return __awaiter(this, void 0, void 0, function* () {
const buttonAcceptFocus = autofocus === AlertButton.Accept;
const buttonCancelFocus = autofocus === AlertButton.Cancel;
const title = yield this.translate.get('DECISIONTITLE').toPromise();
const config = {
title: {
text: title
},
message: questionMsg,
type: 'question',
button: {
cancel: {
autofocus: buttonCancelFocus
},
accept: {
autofocus: buttonAcceptFocus
}
}
};
return this.openModal(config)
.then((value) => {
if (value.ButtonResponse === AlertButton.Accept) {
if (successMsg && successMsg !== '') {
this.success(successMsg);
}
}
else {
if (cancelMsg) {
this.info(cancelMsg);
}
}
return Promise.resolve(value);
});
});
}
/**
*
* Input text message
*/
// tslint:disable-next-line:max-line-length
input(title, placeholder, successMsg, autofocus = true, buttonAutofocus = AlertButton.Accept) {
return __awaiter(this, void 0, void 0, function* () {
const buttonAcceptFocus = buttonAutofocus === AlertButton.Accept;
const buttonCancelFocus = buttonAutofocus === AlertButton.Cancel;
const config = {
title: {
text: title
},
message: '',
input: {
placeholder,
visibility: true,
autofocus: autofocus
},
button: {
accepct: {
autofocus: buttonAcceptFocus
},
cancel: {
autofocus: buttonCancelFocus
}
}
};
return this.openModal(config)
.then((value) => {
if (value.ButtonResponse === AlertButton.Accept) {
if (successMsg) {
this.success(successMsg);
}
}
return Promise.resolve(value);
});
});
}
// tslint:disable:no-bitwise
yesNoCancel(title, message, buttonFocus) {
return __awaiter(this, void 0, void 0, function* () {
return this.custom(title, message, (AlertButton.Yes | AlertButton.No | AlertButton.Cancel), buttonFocus);
});
}
custom(title, message, buttons, buttonFocus) {
return __awaiter(this, void 0, void 0, function* () {
const buttonAccept = (buttons & AlertButton.Accept) > 0;
const buttonYes = (buttons & AlertButton.Yes) > 0;
const buttonCancel = (buttons & AlertButton.Cancel) > 0;
const buttonNo = (buttons & AlertButton.No) > 0;
const buttonRetry = (buttons & AlertButton.Retry) > 0;
const buttonAcceptFocus = buttonFocus === AlertButton.Accept;
const buttonYesFocus = buttonFocus === AlertButton.Yes;
const buttonCancelFocus = buttonFocus === AlertButton.Cancel;
const buttonNoFocus = buttonFocus === AlertButton.No;
const buttonRetryFocus = buttonFocus === AlertButton.Retry;
const config = {
title: {
text: title
},
message,
button: {
yes: {
visibility: buttonYes,
autofocus: buttonYesFocus
},
no: {
visibility: buttonNo,
autofocus: buttonNoFocus
},
retry: {
visibility: buttonRetry,
autofocus: buttonRetryFocus
},
cancel: {
visibility: buttonCancel,
autofocus: buttonCancelFocus
},
accept: {
visibility: buttonAccept,
autofocus: buttonAcceptFocus
}
}
};
return this.openModal(config);
});
}
isObject(item) {
return (item && typeof item === 'object' && !Array.isArray(item));
}
// this will lead to infinite recursion on circular references
mergeDeep(target, ...sources) {
if (!sources.length) {
return target;
}
const source = sources.shift();
if (this.isObject(target) && this.isObject(source)) {
for (const key in source) {
if (this.isObject(source[key])) {
if (!target[key]) {
Object.assign(target, { [key]: {} });
}
this.mergeDeep(target[key], source[key]);
}
else {
Object.assign(target, { [key]: source[key] });
}
}
}
return this.mergeDeep(target, ...sources);
}
}
/** @nocollapse */ NgxNeoModalMatService.ɵfac = function NgxNeoModalMatService_Factory(t) { return new (t || NgxNeoModalMatService)(ɵɵinject(MatDialog), ɵɵinject(TranslateService)); };
/** @nocollapse */ NgxNeoModalMatService.ɵprov = ɵɵdefineInjectable({ token: NgxNeoModalMatService, factory: NgxNeoModalMatService.ɵfac, providedIn: 'root' });
/*@__PURE__*/ (function () { ɵsetClassMetadata(NgxNeoModalMatService, [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}], function () { return [{ type: MatDialog }, { type: TranslateService }]; }, null); })();
class NgxNeoModalMatModule {
}
/** @nocollapse */ NgxNeoModalMatModule.ɵmod = ɵɵdefineNgModule({ type: NgxNeoModalMatModule });
/** @nocollapse */ NgxNeoModalMatModule.ɵinj = ɵɵdefineInjector({ factory: function NgxNeoModalMatModule_Factory(t) { return new (t || NgxNeoModalMatModule)(); }, providers: [
{ provide: MAT_DIALOG_DEFAULT_OPTIONS, useValue: { disableClose: true, hasBackdrop: true } }
], imports: [[
CommonModule,
MatDialogModule,
MatButtonModule,
MatInputModule,
FormsModule,
TranslateModule.forChild({ extend: true })
]] });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && ɵɵsetNgModuleScope(NgxNeoModalMatModule, { declarations: [NgxNeoModalMatComponent], imports: [CommonModule,
MatDialogModule,
MatButtonModule,
MatInputModule,
FormsModule, TranslateModule], exports: [NgxNeoModalMatComponent] }); })();
/*@__PURE__*/ (function () { ɵsetClassMetadata(NgxNeoModalMatModule, [{
type: NgModule,
args: [{
declarations: [NgxNeoModalMatComponent],
imports: [
CommonModule,
MatDialogModule,
MatButtonModule,
MatInputModule,
FormsModule,
TranslateModule.forChild({ extend: true })
],
exports: [NgxNeoModalMatComponent],
entryComponents: [NgxNeoModalMatComponent],
providers: [
{ provide: MAT_DIALOG_DEFAULT_OPTIONS, useValue: { disableClose: true, hasBackdrop: true } }
]
}]
}], null, null); })();
/*
* Public API Surface of ngx-neo-modal-mat
*/
/**
* Generated bundle index. Do not edit.
*/
export { AlertButton, AlertResult, NgxNeoModalMatComponent, NgxNeoModalMatModule, NgxNeoModalMatService };
//# sourceMappingURL=neocomplexx-ngx-neo-modal-mat.js.map