@koalarx/ui
Version:
Koala UI is a Design System developed in Angular whose objective is to facilitate and make your development faster and simpler, making this framework your greatest ally.
140 lines (132 loc) • 10.3 kB
JavaScript
import * as i0 from '@angular/core';
import { Component, ChangeDetectionStrategy, Inject, Injectable, NgModule } from '@angular/core';
import * as i2 from '@angular/material/dialog';
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i3 from '@angular/material/button';
import { MatButtonModule } from '@angular/material/button';
import * as i4 from '@angular/material/icon';
import { MatIconModule } from '@angular/material/icon';
import * as i5 from '@koalarx/ui/dynamic-component';
import { KoalaDynamicComponentModule } from '@koalarx/ui/dynamic-component';
import * as i1$1 from '@koalarx/ui/dialog';
var KoalaAlertEnum;
(function (KoalaAlertEnum) {
KoalaAlertEnum[KoalaAlertEnum["success"] = 200] = "success";
KoalaAlertEnum[KoalaAlertEnum["badRequest"] = 400] = "badRequest";
KoalaAlertEnum[KoalaAlertEnum["unhautorized"] = 401] = "unhautorized";
KoalaAlertEnum[KoalaAlertEnum["notFound"] = 404] = "notFound";
KoalaAlertEnum[KoalaAlertEnum["internalServerError"] = 500] = "internalServerError";
})(KoalaAlertEnum || (KoalaAlertEnum = {}));
class DialogAlertComponent {
constructor(alert) {
this.alert = alert;
if (alert.alertEnum) {
switch (alert.alertEnum) {
case KoalaAlertEnum.success:
this.icon = 'check_circle';
this.iconColor = 'success';
break;
case KoalaAlertEnum.notFound:
this.icon = 'visibility_off';
this.iconColor = 'notFound';
break;
case KoalaAlertEnum.internalServerError:
this.icon = 'error';
this.iconColor = 'error';
break;
case KoalaAlertEnum.badRequest:
this.icon = 'warning';
this.iconColor = 'badRequest';
break;
case KoalaAlertEnum.unhautorized:
this.icon = 'no_encryption';
this.iconColor = 'unhautorized';
break;
}
}
}
}
DialogAlertComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogAlertComponent, deps: [{ token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
DialogAlertComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: DialogAlertComponent, selector: "ng-component", ngImport: i0, template: "<div class=\"content\" mat-dialog-content>\n <mat-icon *ngIf=\"alert.alertEnum else avatar\" [ngClass]=\"iconColor ?? ''\">{{icon}}</mat-icon>\n <ng-template #avatar>\n <koala-dynamic-component [dynamicComponent]=\"alert.avatar\"></koala-dynamic-component>\n </ng-template>\n <p [innerHTML]=\"alert.message\" class=\"w-100 alert-message text-center\"></p>\n</div>\n<div align=\"center\" mat-dialog-actions>\n\t<div *ngFor=\"let action of alert?.actions\">\n\t <button\n\t\t (click)=\"action.action()\"\n\t\t *ngIf=\"action.show\"\n\t\t [color]=\"action.color\"\n\t\t mat-dialog-close\n\t\t mat-raised-button>\n\t {{action.text}}\n\t </button>\n\t</div>\n <button color=\"primary\" mat-dialog-close mat-raised-button>Ok</button>\n</div>\n", styles: [".content{color:#616161}.content .alert-message{display:inline-block;margin:15px auto;font-family:OpenSans,sans-serif;font-weight:700}.content mat-icon{position:relative;display:block;margin:15px auto;width:60px;height:60px;font-size:60px}.content mat-icon.success{color:#4caf50}.content mat-icon.notFound{color:#2196f3}.content mat-icon.error{color:#e53935}.content mat-icon.badRequest{color:#ffc107}.content mat-icon.unhautorized{color:#ff9800}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["aria-label", "type", "mat-dialog-close", "matDialogClose"], exportAs: ["matDialogClose"] }, { kind: "directive", type: i2.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "directive", type: i2.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "component", type: i3.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i4.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i5.KoalaDynamicComponentFactory, selector: "koala-dynamic-component", inputs: ["dynamicComponent"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DialogAlertComponent, decorators: [{
type: Component,
args: [{ changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"content\" mat-dialog-content>\n <mat-icon *ngIf=\"alert.alertEnum else avatar\" [ngClass]=\"iconColor ?? ''\">{{icon}}</mat-icon>\n <ng-template #avatar>\n <koala-dynamic-component [dynamicComponent]=\"alert.avatar\"></koala-dynamic-component>\n </ng-template>\n <p [innerHTML]=\"alert.message\" class=\"w-100 alert-message text-center\"></p>\n</div>\n<div align=\"center\" mat-dialog-actions>\n\t<div *ngFor=\"let action of alert?.actions\">\n\t <button\n\t\t (click)=\"action.action()\"\n\t\t *ngIf=\"action.show\"\n\t\t [color]=\"action.color\"\n\t\t mat-dialog-close\n\t\t mat-raised-button>\n\t {{action.text}}\n\t </button>\n\t</div>\n <button color=\"primary\" mat-dialog-close mat-raised-button>Ok</button>\n</div>\n", styles: [".content{color:#616161}.content .alert-message{display:inline-block;margin:15px auto;font-family:OpenSans,sans-serif;font-weight:700}.content mat-icon{position:relative;display:block;margin:15px auto;width:60px;height:60px;font-size:60px}.content mat-icon.success{color:#4caf50}.content mat-icon.notFound{color:#2196f3}.content mat-icon.error{color:#e53935}.content mat-icon.badRequest{color:#ffc107}.content mat-icon.unhautorized{color:#ff9800}\n"] }]
}], ctorParameters: function () {
return [{ type: undefined, decorators: [{
type: Inject,
args: [MAT_DIALOG_DATA]
}] }];
} });
class KoalaRequestCodeToAlertEnumTranslate {
static translate(statusCode) {
switch (statusCode) {
case 400:
case 422:
case 405:
return KoalaAlertEnum.badRequest;
case 404:
return KoalaAlertEnum.notFound;
case 401:
return KoalaAlertEnum.unhautorized;
default:
return KoalaAlertEnum.internalServerError;
}
}
}
class KoalaAlertService {
constructor(dialogService) {
this.dialogService = dialogService;
}
create(alertConfig) {
this.dialogService.open(DialogAlertComponent, 'auto', alertConfig);
}
}
KoalaAlertService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: KoalaAlertService, deps: [{ token: i1$1.KoalaDialogService }], target: i0.ɵɵFactoryTarget.Injectable });
KoalaAlertService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: KoalaAlertService, providedIn: "any" });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: KoalaAlertService, decorators: [{
type: Injectable,
args: [{ providedIn: "any" }]
}], ctorParameters: function () { return [{ type: i1$1.KoalaDialogService }]; } });
class KoalaAlertModule {
}
KoalaAlertModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: KoalaAlertModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
KoalaAlertModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: KoalaAlertModule, declarations: [DialogAlertComponent], imports: [CommonModule,
MatDialogModule,
MatButtonModule,
MatIconModule,
KoalaDynamicComponentModule], exports: [DialogAlertComponent] });
KoalaAlertModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: KoalaAlertModule, providers: [
KoalaAlertService
], imports: [CommonModule,
MatDialogModule,
MatButtonModule,
MatIconModule,
KoalaDynamicComponentModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: KoalaAlertModule, decorators: [{
type: NgModule,
args: [{
declarations: [
DialogAlertComponent
],
imports: [
CommonModule,
MatDialogModule,
MatButtonModule,
MatIconModule,
KoalaDynamicComponentModule
],
providers: [
KoalaAlertService
],
exports: [
DialogAlertComponent
]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { DialogAlertComponent, KoalaAlertEnum, KoalaAlertModule, KoalaAlertService, KoalaRequestCodeToAlertEnumTranslate };
//# sourceMappingURL=koalarx-ui-alert.mjs.map