UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

1 lines 11 kB
{"version":3,"file":"ng-zorro-antd-alert.mjs","sources":["../../components/alert/alert.component.ts","../../components/alert/alert.module.ts","../../components/alert/public-api.ts","../../components/alert/ng-zorro-antd-alert.ts"],"sourcesContent":["/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { Direction, Directionality } from '@angular/cdk/bidi';\nimport {\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n EventEmitter,\n Input,\n OnChanges,\n OnDestroy,\n OnInit,\n Optional,\n Output,\n SimpleChanges,\n TemplateRef,\n ViewEncapsulation\n} from '@angular/core';\nimport { Subject } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\nimport { slideAlertMotion } from 'ng-zorro-antd/core/animation';\nimport { NzConfigKey, NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';\nimport { BooleanInput } from 'ng-zorro-antd/core/types';\nimport { InputBoolean } from 'ng-zorro-antd/core/util';\n\nconst NZ_CONFIG_MODULE_NAME: NzConfigKey = 'alert';\n\n@Component({\n selector: 'nz-alert',\n exportAs: 'nzAlert',\n animations: [slideAlertMotion],\n template: `\n <div\n *ngIf=\"!closed\"\n class=\"ant-alert\"\n [class.ant-alert-rtl]=\"dir === 'rtl'\"\n [class.ant-alert-success]=\"nzType === 'success'\"\n [class.ant-alert-info]=\"nzType === 'info'\"\n [class.ant-alert-warning]=\"nzType === 'warning'\"\n [class.ant-alert-error]=\"nzType === 'error'\"\n [class.ant-alert-no-icon]=\"!nzShowIcon\"\n [class.ant-alert-banner]=\"nzBanner\"\n [class.ant-alert-closable]=\"nzCloseable\"\n [class.ant-alert-with-description]=\"!!nzDescription\"\n [@.disabled]=\"nzNoAnimation\"\n [@slideAlertMotion]\n (@slideAlertMotion.done)=\"onFadeAnimationDone()\"\n >\n <ng-container *ngIf=\"nzShowIcon\">\n <i nz-icon class=\"ant-alert-icon\" [nzType]=\"nzIconType || inferredIconType\" [nzTheme]=\"iconTheme\"></i>\n </ng-container>\n <div class=\"ant-alert-content\" *ngIf=\"nzMessage || nzDescription\">\n <span class=\"ant-alert-message\" *ngIf=\"nzMessage\">\n <ng-container *nzStringTemplateOutlet=\"nzMessage\">{{ nzMessage }}</ng-container>\n </span>\n <span class=\"ant-alert-description\" *ngIf=\"nzDescription\">\n <ng-container *nzStringTemplateOutlet=\"nzDescription\">{{ nzDescription }}</ng-container>\n </span>\n </div>\n <div class=\"ant-alert-action\" *ngIf=\"nzAction\">\n <ng-container *nzStringTemplateOutlet=\"nzAction\">{{ nzAction }}</ng-container>\n </div>\n <button\n type=\"button\"\n tabindex=\"0\"\n *ngIf=\"nzCloseable || nzCloseText\"\n class=\"ant-alert-close-icon\"\n (click)=\"closeAlert()\"\n >\n <ng-template #closeDefaultTemplate>\n <i nz-icon nzType=\"close\"></i>\n </ng-template>\n <ng-container *ngIf=\"nzCloseText; else closeDefaultTemplate\">\n <ng-container *nzStringTemplateOutlet=\"nzCloseText\">\n <span class=\"ant-alert-close-text\">{{ nzCloseText }}</span>\n </ng-container>\n </ng-container>\n </button>\n </div>\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n preserveWhitespaces: false\n})\nexport class NzAlertComponent implements OnChanges, OnDestroy, OnInit {\n readonly _nzModuleName: NzConfigKey = NZ_CONFIG_MODULE_NAME;\n static ngAcceptInputType_nzCloseable: BooleanInput;\n static ngAcceptInputType_nzShowIcon: BooleanInput;\n static ngAcceptInputType_nzBanner: BooleanInput;\n static ngAcceptInputType_nzNoAnimation: BooleanInput;\n\n @Input() nzAction: string | TemplateRef<void> | null = null;\n @Input() nzCloseText: string | TemplateRef<void> | null = null;\n @Input() nzIconType: string | null = null;\n @Input() nzMessage: string | TemplateRef<void> | null = null;\n @Input() nzDescription: string | TemplateRef<void> | null = null;\n @Input() nzType: 'success' | 'info' | 'warning' | 'error' = 'info';\n @Input() @WithConfig() @InputBoolean() nzCloseable: boolean = false;\n @Input() @WithConfig() @InputBoolean() nzShowIcon: boolean = false;\n @Input() @InputBoolean() nzBanner = false;\n @Input() @InputBoolean() nzNoAnimation = false;\n @Output() readonly nzOnClose = new EventEmitter<boolean>();\n closed = false;\n iconTheme: 'outline' | 'fill' = 'fill';\n inferredIconType: string = 'info-circle';\n dir: Direction = 'ltr';\n private isTypeSet = false;\n private isShowIconSet = false;\n private destroy$ = new Subject();\n\n constructor(\n public nzConfigService: NzConfigService,\n private cdr: ChangeDetectorRef,\n @Optional() private directionality: Directionality\n ) {\n this.nzConfigService\n .getConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME)\n .pipe(takeUntil(this.destroy$))\n .subscribe(() => {\n this.cdr.markForCheck();\n });\n }\n\n ngOnInit(): void {\n this.directionality.change?.pipe(takeUntil(this.destroy$)).subscribe((direction: Direction) => {\n this.dir = direction;\n this.cdr.detectChanges();\n });\n\n this.dir = this.directionality.value;\n }\n\n closeAlert(): void {\n this.closed = true;\n }\n\n onFadeAnimationDone(): void {\n if (this.closed) {\n this.nzOnClose.emit(true);\n }\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n const { nzShowIcon, nzDescription, nzType, nzBanner } = changes;\n if (nzShowIcon) {\n this.isShowIconSet = true;\n }\n if (nzType) {\n this.isTypeSet = true;\n switch (this.nzType) {\n case 'error':\n this.inferredIconType = 'close-circle';\n break;\n case 'success':\n this.inferredIconType = 'check-circle';\n break;\n case 'info':\n this.inferredIconType = 'info-circle';\n break;\n case 'warning':\n this.inferredIconType = 'exclamation-circle';\n break;\n }\n }\n if (nzDescription) {\n this.iconTheme = this.nzDescription ? 'outline' : 'fill';\n }\n if (nzBanner) {\n if (!this.isTypeSet) {\n this.nzType = 'warning';\n }\n if (!this.isShowIconSet) {\n this.nzShowIcon = true;\n }\n }\n }\n ngOnDestroy(): void {\n this.destroy$.next();\n this.destroy$.complete();\n }\n}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { BidiModule } from '@angular/cdk/bidi';\nimport { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\n\nimport { NzOutletModule } from 'ng-zorro-antd/core/outlet';\nimport { NzIconModule } from 'ng-zorro-antd/icon';\n\nimport { NzAlertComponent } from './alert.component';\n\n@NgModule({\n declarations: [NzAlertComponent],\n exports: [NzAlertComponent],\n imports: [BidiModule, CommonModule, NzIconModule, NzOutletModule]\n})\nexport class NzAlertModule {}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nexport * from './alert.component';\nexport * from './alert.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,MAAM,qBAAqB,GAAgB,OAAO,CAAC;MA2DtC,gBAAgB;IA0B3B,YACS,eAAgC,EAC/B,GAAsB,EACV,cAA8B;QAF3C,oBAAe,GAAf,eAAe,CAAiB;QAC/B,QAAG,GAAH,GAAG,CAAmB;QACV,mBAAc,GAAd,cAAc,CAAgB;QA5B3C,kBAAa,GAAgB,qBAAqB,CAAC;QAMnD,aAAQ,GAAsC,IAAI,CAAC;QACnD,gBAAW,GAAsC,IAAI,CAAC;QACtD,eAAU,GAAkB,IAAI,CAAC;QACjC,cAAS,GAAsC,IAAI,CAAC;QACpD,kBAAa,GAAsC,IAAI,CAAC;QACxD,WAAM,GAA6C,MAAM,CAAC;QAC5B,gBAAW,GAAY,KAAK,CAAC;QAC7B,eAAU,GAAY,KAAK,CAAC;QAC1C,aAAQ,GAAG,KAAK,CAAC;QACjB,kBAAa,GAAG,KAAK,CAAC;QAC5B,cAAS,GAAG,IAAI,YAAY,EAAW,CAAC;QAC3D,WAAM,GAAG,KAAK,CAAC;QACf,cA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