1 | import { Component, ChangeDetectionStrategy, ViewEncapsulation, Input, NgModule } from '@angular/core';
|
2 | import { CommonModule } from '@angular/common';
|
3 |
|
4 | class UIMessage {
|
5 | constructor() {
|
6 | this.escape = true;
|
7 | }
|
8 | get icon() {
|
9 | let icon = null;
|
10 | if (this.severity) {
|
11 | switch (this.severity) {
|
12 | case 'success':
|
13 | icon = 'pi pi-check';
|
14 | break;
|
15 | case 'info':
|
16 | icon = 'pi pi-info-circle';
|
17 | break;
|
18 | case 'error':
|
19 | icon = 'pi pi-times-circle';
|
20 | break;
|
21 | case 'warn':
|
22 | icon = 'pi pi-exclamation-triangle';
|
23 | break;
|
24 | default:
|
25 | icon = 'pi pi-info-circle';
|
26 | break;
|
27 | }
|
28 | }
|
29 | return icon;
|
30 | }
|
31 | }
|
32 | UIMessage.decorators = [
|
33 | { type: Component, args: [{
|
34 | selector: 'p-message',
|
35 | template: `
|
36 | <div aria-live="polite" class="p-inline-message p-component p-inline-message" *ngIf="severity" [ngStyle]="style" [class]="styleClass"
|
37 | [ngClass]="{'p-inline-message-info': (severity === 'info'),
|
38 | 'p-inline-message-warn': (severity === 'warn'),
|
39 | 'p-inline-message-error': (severity === 'error'),
|
40 | 'p-inline-message-success': (severity === 'success'),
|
41 | 'p-inline-message-icon-only': this.text == null}">
|
42 | <span class="p-inline-message-icon" [ngClass]="icon"></span>
|
43 | <div *ngIf="!escape; else escapeOut">
|
44 | <span *ngIf="!escape" class="p-inline-message-text" [innerHTML]="text"></span>
|
45 | </div>
|
46 | <ng-template #escapeOut>
|
47 | <span *ngIf="escape" class="p-inline-message-text">{{text}}</span>
|
48 | </ng-template>
|
49 | </div>
|
50 | `,
|
51 | changeDetection: ChangeDetectionStrategy.OnPush,
|
52 | encapsulation: ViewEncapsulation.None,
|
53 | styles: [".p-inline-message{-ms-flex-align:center;-ms-flex-pack:center;align-items:center;display:-ms-inline-flexbox;display:inline-flex;justify-content:center;vertical-align:top}.p-inline-message-icon-only .p-inline-message-text{visibility:hidden;width:0}.p-fluid .p-inline-message{display:-ms-flexbox;display:flex}"]
|
54 | },] }
|
55 | ];
|
56 | UIMessage.propDecorators = {
|
57 | severity: [{ type: Input }],
|
58 | text: [{ type: Input }],
|
59 | escape: [{ type: Input }],
|
60 | style: [{ type: Input }],
|
61 | styleClass: [{ type: Input }]
|
62 | };
|
63 | class MessageModule {
|
64 | }
|
65 | MessageModule.decorators = [
|
66 | { type: NgModule, args: [{
|
67 | imports: [CommonModule],
|
68 | exports: [UIMessage],
|
69 | declarations: [UIMessage]
|
70 | },] }
|
71 | ];
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 | export { MessageModule, UIMessage };
|
78 |
|