UNPKG

@addapptables/alert

Version:
2 lines 8.56 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/material/dialog"),require("@angular/cdk/portal"),require("@addapptables/core"),require("@angular/material/button"),require("@ngx-translate/core"),require("@angular/common")):"function"==typeof define&&define.amd?define("@addapptables/alert",["exports","@angular/core","@angular/material/dialog","@angular/cdk/portal","@addapptables/core","@angular/material/button","@ngx-translate/core","@angular/common"],e):e(((t=t||self).addapptables=t.addapptables||{},t.addapptables.alert={}),t.ng.core,t.ng.material.dialog,t.ng.cdk.portal,t["addapptables-core"],t.ng.material.button,t["ngx-translate-core"],t.ng.common)}(this,function(t,e,n,o,a,r,i,l){"use strict";var c=function(){function t(){}return t.decorators=[{type:e.Component,args:[{selector:"addapptable-alert-sucess",template:'<span class="alert-icon-success-line alert-icon-success-line-long"></span>\n<span class="alert-icon-success-line alert-icon-success-line-tip"></span>\n<div class="alert-icon-success-ring"></div>\n<div class="alert-icon-success-hide-corners"></div>',changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None,host:{"class":"alert-icon alert-icon-success"},styles:[""]}]}],t}(),s={success:"success",error:"error",info:"info",warning:"warning"},p=function(){function t(){}return t.decorators=[{type:e.Component,args:[{selector:"addapptable-app-alert-info",template:"",changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None,host:{"class":"alert-icon alert-icon-info"},styles:[""]}]}],t}(),d=function(){function t(){}return t.decorators=[{type:e.Component,args:[{selector:"addapptable-alert-warning",template:'<span class="alert-icon-warning-body">\n <span class="alert-icon-warning-dot"></span>\n</span>',host:{"class":"alert-icon alert-icon-warning "},changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None,styles:[""]}]}],t}(),u=function(){function t(){}return t.decorators=[{type:e.Component,args:[{selector:"addapptable-alert-error",template:'<div class="alert-icon-error-x-mark">\n <span class="alert-icon-error-line alert-icon-error-line-left"></span>\n <span class="alert-icon-error-line alert-icon-error-line-right"></span>\n</div>',host:{"class":"alert-icon alert-icon-error"},encapsulation:e.ViewEncapsulation.None,changeDetection:e.ChangeDetectionStrategy.OnPush,styles:[""]}]}],t}(),g=[{type:s.success,component:c},{type:s.info,component:p},{type:s.warning,component:d},{type:s.error,component:u}],m=new e.InjectionToken("AddapptableAlertData"),f=function(){function t(t,e,n){this.dialogRef=t,this.data=e,this.componentFactoryResolver=n}return t.prototype.ngOnInit=function(){},t.prototype.ngAfterViewInit=function(){this.loadComponents()},t.prototype.loadComponents=function(){var t=this,e=g.find(function(e){return e.type===t.data.type}),n=e&&e.component;this.resolveComponent(n,this.appDynamic.find(function(t){return"alert-icon"===t.name}).viewContainerRef),this.resolveComponent(this.data.customBody,this.appDynamic.find(function(t){return"alert-body"===t.name}).viewContainerRef),this.resolveComponent(this.data.customButtonComponent,this.appDynamic.find(function(t){return"alert-buttons"===t.name}).viewContainerRef)},t.prototype.resolveComponent=function(t,n){if(t)if(n.clear(),t instanceof e.TemplateRef)n.createEmbeddedView(t,{$implicit:this.data,dialogRef:this.dialogRef});else{var o=t&&this.componentFactoryResolver.resolveComponentFactory(t),a=this.createInjector(n.injector);n.createComponent(o,null,a)}},t.prototype.createInjector=function(t){var e=new WeakMap([[m,this.data],[n.MatDialogRef,this.dialogRef]]);return new o.PortalInjector(t,e)},t.prototype.buttonClick=function(t){this.dialogRef.close({data:this.data,result:t})},t.decorators=[{type:e.Component,args:[{selector:"addapptable-dialog-alert",template:'<ng-template addapptablesDynamic name="alert-icon"></ng-template>\r\n<div *ngIf="data?.title" class="alert-title">\r\n <span>\r\n {{data.title | translate}}\r\n </span>\r\n</div>\r\n<div *ngIf="data?.text" class="alert-text">\r\n <span>\r\n {{data.text | translate}}\r\n </span>\r\n</div>\r\n<ng-template addapptablesDynamic name="alert-body"></ng-template>\r\n<div class="alert-footer" *ngIf="!data?.hiddenButtons">\r\n <addapptable-alert-ok-button *ngIf="!data?.customButtonComponent" (click)="buttonClick(\'ok\')"></addapptable-alert-ok-button>\r\n <addapptable-alert-cancel-button *ngIf="!data?.customButtonComponent && data?.showCancelButton" (click)="buttonClick(\'cancel\')"></addapptable-alert-cancel-button>\r\n</div>\r\n<ng-template addapptablesDynamic name="alert-buttons"></ng-template>',changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None,styles:[".alert-icon{width:80px;height:80px;border-width:4px;border-style:solid;border-radius:50%;padding:0;position:relative;box-sizing:content-box;margin:20px auto}.alert-icon-custom{width:auto;height:auto;max-width:100%;border:none;border-radius:0}.alert-icon img{max-width:100%;max-height:100%}.alert-title{color:rgba(0,0,0,.65);font-weight:600;text-transform:none;position:relative;display:block;font-size:27px;line-height:normal;text-align:center;margin-bottom:0}.alert-title:first-child{margin-top:26px}.alert-title:not(:first-child){padding-bottom:0}.alert-title:not(:last-child){margin-bottom:13px}.alert-text{font-size:16px;position:relative;float:none;line-height:normal;vertical-align:top;text-align:center;display:inline-block;margin:0;padding:0 10px;font-weight:400;color:rgba(0,0,0,.64);overflow-wrap:break-word;box-sizing:border-box;width:100%}.alert-text:first-child{margin-top:45px}.alert-text:last-child{margin-bottom:45px}.alert-footer{text-align:right;margin-top:13px;padding:13px 16px;border-radius:inherit;border-top-left-radius:0;border-top-right-radius:0}.alert-footer-button-container{margin:5px;display:inline-block;position:relative}.alert-footer>*{display:inline-block;margin-right:.5em}.alert-footer>:last-child{margin-right:inherit}"]}]}],t.ctorParameters=function(){return[{type:n.MatDialogRef},{type:undefined,decorators:[{type:e.Inject,args:[n.MAT_DIALOG_DATA]}]},{type:e.ComponentFactoryResolver}]},t.propDecorators={appDynamic:[{type:e.ViewChildren,args:[a.DynamicDirective]}]},t}(),h=function(){function t(){this.click=new e.EventEmitter}return t.decorators=[{type:e.Component,args:[{selector:"addapptable-alert-ok-button",template:'<button mat-raised-button color="primary" (click)="click.emit($event)">{{\'general.ok\' | translate}}</button>',changeDetection:e.ChangeDetectionStrategy.OnPush,styles:[""]}]}],t.propDecorators={click:[{type:e.Output}]},t}(),y=function(){function t(){this.click=new e.EventEmitter}return t.decorators=[{type:e.Component,args:[{selector:"addapptable-alert-cancel-button",template:"<button mat-raised-button (click)=\"click.emit($event)\">{{'general.cancel' | translate}}</button>",changeDetection:e.ChangeDetectionStrategy.OnPush,styles:[""]}]}],t.propDecorators={click:[{type:e.Output}]},t}(),b=function(){function t(t){this._dialog=t}return t.prototype.showSimple=function(t,e){return this._open({title:t,text:e})},t.prototype.showSuccess=function(t,e){return this._open({title:t,text:e,type:s.success})},t.prototype.showError=function(t,e){return this._open({title:t,text:e,type:s.error})},t.prototype.showInfo=function(t,e){return this._open({title:t,text:e,type:s.info})},t.prototype.showWarning=function(t,e){return this._open({title:t,text:e,type:s.warning})},t.prototype.showConfirmation=function(t,e){return this._open({title:t,text:e,type:s.warning,showCancelButton:!0})},t.prototype._open=function(t){return this._dialog.open(f,{width:"500px",data:t})},t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[{type:n.MatDialog}]},t}(),C=function(){function t(){}return t.forRoot=function(){return{ngModule:t,providers:[b]}},t.decorators=[{type:e.NgModule,args:[{imports:[l.CommonModule,i.TranslateModule,r.MatButtonModule,a.CoreModule,n.MatDialogModule],declarations:[f,c,p,d,u,h,y],exports:[f],entryComponents:[f,c,p,d,u]}]}],t}();t.ADDAPPTABLE_ALERT_DATA=m,t.AddapptableDialogAlertComponent=f,t.AlertCancelButtonComponent=y,t.AlertEnum=s,t.AlertInfoComponent=p,t.AlertModule=C,t.AlertOkButtonComponent=h,t.AlertService=b,t.AlertSucessComponent=c,t.ErrorComponent=u,t.WarningComponent=d,t.alertComponents=g,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=addapptables-alert.umd.min.js.map