1 | import * as i0 from '@angular/core';
|
2 | import { Directive, TemplateRef, Component, ViewChild, HostBinding, Input, HostListener, NgModule } from '@angular/core';
|
3 | import * as i1 from '@angular/common';
|
4 | import { CommonModule } from '@angular/common';
|
5 | import * as i2 from '@angular/material/icon';
|
6 | import { MatIconModule } from '@angular/material/icon';
|
7 | import { trigger, state, style, AUTO_STYLE, transition, group, query, animateChild, animate } from '@angular/animations';
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | const tdCollapseAnimation = trigger('tdCollapse', [
|
23 | state('1', style({
|
24 | height: '0',
|
25 | overflow: 'hidden',
|
26 | })),
|
27 | state('0', style({
|
28 | height: AUTO_STYLE,
|
29 | overflow: AUTO_STYLE,
|
30 | })),
|
31 | transition('0 => 1', [
|
32 | style({
|
33 | overflow: 'hidden',
|
34 | height: AUTO_STYLE,
|
35 | }),
|
36 | group([
|
37 | query('@*', animateChild(), { optional: true }),
|
38 | animate('{{ duration }}ms {{ delay }}ms {{ ease }}', style({
|
39 | height: '0',
|
40 | overflow: 'hidden',
|
41 | })),
|
42 | ]),
|
43 | ], { params: { duration: 150, delay: '0', ease: 'ease-in' } }),
|
44 | transition('1 => 0', [
|
45 | style({
|
46 | height: '0',
|
47 | overflow: 'hidden',
|
48 | }),
|
49 | group([
|
50 | query('@*', animateChild(), { optional: true }),
|
51 | animate('{{ duration }}ms {{ delay }}ms {{ ease }}', style({
|
52 | overflow: 'hidden',
|
53 | height: AUTO_STYLE,
|
54 | })),
|
55 | ]),
|
56 | ], { params: { duration: 150, delay: '0', ease: 'ease-out' } }),
|
57 | ]);
|
58 |
|
59 | class TdMessageContainerDirective {
|
60 | viewContainer;
|
61 | constructor(viewContainer) {
|
62 | this.viewContainer = viewContainer;
|
63 | }
|
64 | static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: TdMessageContainerDirective, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
|
65 | static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.2", type: TdMessageContainerDirective, selector: "[tdMessageContainer]", ngImport: i0 });
|
66 | }
|
67 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: TdMessageContainerDirective, decorators: [{
|
68 | type: Directive,
|
69 | args: [{
|
70 | selector: '[tdMessageContainer]',
|
71 | }]
|
72 | }], ctorParameters: () => [{ type: i0.ViewContainerRef }] });
|
73 | class TdMessageComponent {
|
74 | _renderer;
|
75 | _changeDetectorRef;
|
76 | _elementRef;
|
77 | _color;
|
78 | _opened = true;
|
79 | _hidden = false;
|
80 | _animating = false;
|
81 | _initialized = false;
|
82 | _childElement;
|
83 | _template;
|
84 | |
85 |
|
86 |
|
87 | get collapsedAnimation() {
|
88 | return { value: !this._opened, duration: 100 };
|
89 | }
|
90 | |
91 |
|
92 |
|
93 | get hidden() {
|
94 | return this._hidden ? 'none' : '';
|
95 | }
|
96 | |
97 |
|
98 |
|
99 |
|
100 |
|
101 | label;
|
102 | |
103 |
|
104 |
|
105 |
|
106 |
|
107 | sublabel;
|
108 | |
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 | icon = 'info_outline';
|
115 | |
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 | set color(color) {
|
122 | this._renderer.removeClass(this._elementRef.nativeElement, 'mat-' + this._color);
|
123 | this._renderer.removeClass(this._elementRef.nativeElement, 'bgc-' + this._color + '-100');
|
124 | this._renderer.removeClass(this._elementRef.nativeElement, 'tc-' + this._color + '-700');
|
125 | if (color === 'primary' || color === 'accent' || color === 'warn') {
|
126 | this._renderer.addClass(this._elementRef.nativeElement, 'mat-' + color);
|
127 | }
|
128 | else {
|
129 | this._renderer.addClass(this._elementRef.nativeElement, 'bgc-' + color + '-100');
|
130 | this._renderer.addClass(this._elementRef.nativeElement, 'tc-' + color + '-700');
|
131 | }
|
132 | this._color = color;
|
133 | this._changeDetectorRef.markForCheck();
|
134 | }
|
135 | get color() {
|
136 | return this._color;
|
137 | }
|
138 | |
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 | set opened(opened) {
|
145 | if (this._initialized) {
|
146 | if (opened) {
|
147 | this.open();
|
148 | }
|
149 | else {
|
150 | this.close();
|
151 | }
|
152 | }
|
153 | else {
|
154 | this._opened = opened;
|
155 | }
|
156 | }
|
157 | get opened() {
|
158 | return this._opened;
|
159 | }
|
160 | constructor(_renderer, _changeDetectorRef, _elementRef) {
|
161 | this._renderer = _renderer;
|
162 | this._changeDetectorRef = _changeDetectorRef;
|
163 | this._elementRef = _elementRef;
|
164 | this._renderer.addClass(this._elementRef.nativeElement, 'td-message');
|
165 | }
|
166 | |
167 |
|
168 |
|
169 |
|
170 | animationDoneListener() {
|
171 | if (!this._opened) {
|
172 | this._hidden = true;
|
173 | this._detach();
|
174 | }
|
175 | this._animating = false;
|
176 | this._changeDetectorRef.markForCheck();
|
177 | }
|
178 | |
179 |
|
180 |
|
181 | ngAfterViewInit() {
|
182 | Promise.resolve(undefined).then(() => {
|
183 | if (this._opened) {
|
184 | this._attach();
|
185 | }
|
186 | this._initialized = true;
|
187 | });
|
188 | }
|
189 | |
190 |
|
191 |
|
192 |
|
193 | open() {
|
194 | if (!this._opened && !this._animating) {
|
195 | this._opened = true;
|
196 | this._attach();
|
197 | this._startAnimationState();
|
198 | }
|
199 | }
|
200 | |
201 |
|
202 |
|
203 |
|
204 | close() {
|
205 | if (this._opened && !this._animating) {
|
206 | this._opened = false;
|
207 | this._startAnimationState();
|
208 | }
|
209 | }
|
210 | |
211 |
|
212 |
|
213 | toggle() {
|
214 | if (this._opened) {
|
215 | this.close();
|
216 | }
|
217 | else {
|
218 | this.open();
|
219 | }
|
220 | }
|
221 | |
222 |
|
223 |
|
224 | _startAnimationState() {
|
225 | this._animating = true;
|
226 | this._hidden = false;
|
227 | this._changeDetectorRef.markForCheck();
|
228 | }
|
229 | |
230 |
|
231 |
|
232 | _attach() {
|
233 | this._childElement?.viewContainer.createEmbeddedView(this._template);
|
234 | this._changeDetectorRef.markForCheck();
|
235 | }
|
236 | |
237 |
|
238 |
|
239 | _detach() {
|
240 | this._childElement?.viewContainer.clear();
|
241 | this._changeDetectorRef.markForCheck();
|
242 | }
|
243 | static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: TdMessageComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
244 | static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.1.2", type: TdMessageComponent, selector: "td-message", inputs: { label: "label", sublabel: "sublabel", icon: "icon", color: "color", opened: "opened" }, host: { listeners: { "@tdCollapse.done": "animationDoneListener()" }, properties: { "@tdCollapse": "this.collapsedAnimation", "style.display": "this.hidden" } }, viewQueries: [{ propertyName: "_childElement", first: true, predicate: TdMessageContainerDirective, descendants: true, static: true }, { propertyName: "_template", first: true, predicate: TemplateRef, descendants: true }], ngImport: i0, template: "<div tdMessageContainer></div>\n<ng-template>\n <div class=\"td-message-wrapper\">\n <mat-icon class=\"td-message-icon\">{{ icon }}</mat-icon>\n <div class=\"td-message-labels\">\n <div *ngIf=\"label\" class=\"td-message-label\">{{ label }}</div>\n <div *ngIf=\"sublabel\" class=\"td-message-sublabel\">{{ sublabel }}</div>\n </div>\n <ng-content select=\"[td-message-actions]\"></ng-content>\n </div>\n</ng-template>\n", styles: [":host{display:block}:host .td-message-wrapper{padding:8px 16px;min-height:52px;box-sizing:border-box;display:flex;flex-direction:row;align-items:center;align-content:center;max-width:100%;justify-content:flex-start}:host .td-message-wrapper .td-message-labels{flex:1}.td-message-icon{margin-right:16px}::ng-deep [dir=rtl] .td-message-icon{margin-left:16px;margin-right:0}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: TdMessageContainerDirective, selector: "[tdMessageContainer]" }], animations: [tdCollapseAnimation] });
|
245 | }
|
246 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: TdMessageComponent, decorators: [{
|
247 | type: Component,
|
248 | args: [{ selector: 'td-message', animations: [tdCollapseAnimation], template: "<div tdMessageContainer></div>\n<ng-template>\n <div class=\"td-message-wrapper\">\n <mat-icon class=\"td-message-icon\">{{ icon }}</mat-icon>\n <div class=\"td-message-labels\">\n <div *ngIf=\"label\" class=\"td-message-label\">{{ label }}</div>\n <div *ngIf=\"sublabel\" class=\"td-message-sublabel\">{{ sublabel }}</div>\n </div>\n <ng-content select=\"[td-message-actions]\"></ng-content>\n </div>\n</ng-template>\n", styles: [":host{display:block}:host .td-message-wrapper{padding:8px 16px;min-height:52px;box-sizing:border-box;display:flex;flex-direction:row;align-items:center;align-content:center;max-width:100%;justify-content:flex-start}:host .td-message-wrapper .td-message-labels{flex:1}.td-message-icon{margin-right:16px}::ng-deep [dir=rtl] .td-message-icon{margin-left:16px;margin-right:0}\n"] }]
|
249 | }], ctorParameters: () => [{ type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }], propDecorators: { _childElement: [{
|
250 | type: ViewChild,
|
251 | args: [TdMessageContainerDirective, { static: true }]
|
252 | }], _template: [{
|
253 | type: ViewChild,
|
254 | args: [TemplateRef]
|
255 | }], collapsedAnimation: [{
|
256 | type: HostBinding,
|
257 | args: ['@tdCollapse']
|
258 | }], hidden: [{
|
259 | type: HostBinding,
|
260 | args: ['style.display']
|
261 | }], label: [{
|
262 | type: Input
|
263 | }], sublabel: [{
|
264 | type: Input
|
265 | }], icon: [{
|
266 | type: Input
|
267 | }], color: [{
|
268 | type: Input
|
269 | }], opened: [{
|
270 | type: Input
|
271 | }], animationDoneListener: [{
|
272 | type: HostListener,
|
273 | args: ['@tdCollapse.done']
|
274 | }] } });
|
275 |
|
276 | const TD_MESSAGE = [
|
277 | TdMessageComponent,
|
278 | TdMessageContainerDirective,
|
279 | ];
|
280 | class CovalentMessageModule {
|
281 | static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: CovalentMessageModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
282 | static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.1.2", ngImport: i0, type: CovalentMessageModule, declarations: [TdMessageComponent,
|
283 | TdMessageContainerDirective], imports: [CommonModule, MatIconModule], exports: [TdMessageComponent,
|
284 | TdMessageContainerDirective] });
|
285 | static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: CovalentMessageModule, imports: [CommonModule, MatIconModule] });
|
286 | }
|
287 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: CovalentMessageModule, decorators: [{
|
288 | type: NgModule,
|
289 | args: [{
|
290 | imports: [CommonModule, MatIconModule],
|
291 | declarations: [TD_MESSAGE],
|
292 | exports: [TD_MESSAGE],
|
293 | }]
|
294 | }] });
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 | export { CovalentMessageModule, TdMessageComponent, TdMessageContainerDirective };
|
301 |
|