@progress/kendo-angular-notification 4.0.1 → 11.0.0-develop.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/LICENSE.md +1 -1
  2. package/NOTICE.txt +4 -4
  3. package/README.md +1 -1
  4. package/{esm2015/main.js → esm2020/index.mjs} +1 -1
  5. package/{esm2015/localization/localized-messages.directive.js → esm2020/localization/localized-messages.directive.mjs} +5 -5
  6. package/{esm2015/models/animation.js → esm2020/models/animation.mjs} +1 -1
  7. package/{esm2015/models/type.js → esm2020/models/notification-ref.mjs} +1 -1
  8. package/{esm2015/models/notification-settings.js → esm2020/models/notification-settings.mjs} +1 -1
  9. package/{esm2015/models/notification-ref.js → esm2020/models/position.mjs} +1 -1
  10. package/{esm2015/models/position.js → esm2020/models/type.mjs} +1 -1
  11. package/{esm2015/notification.component.js → esm2020/notification.component.mjs} +76 -46
  12. package/{esm2015/notification.container.component.js → esm2020/notification.container.component.mjs} +6 -6
  13. package/{esm2015/notification.module.js → esm2020/notification.module.mjs} +7 -6
  14. package/{esm2015/package-metadata.js → esm2020/package-metadata.mjs} +3 -3
  15. package/{esm2015/kendo-angular-notification.js → esm2020/progress-kendo-angular-notification.mjs} +2 -2
  16. package/{esm2015/services/notification.service.js → esm2020/services/notification.service.mjs} +8 -7
  17. package/{esm2015/utils/animations.js → esm2020/utils/animations.mjs} +1 -1
  18. package/fesm2015/progress-kendo-angular-notification.mjs +741 -0
  19. package/{fesm2015/kendo-angular-notification.js → fesm2020/progress-kendo-angular-notification.mjs} +96 -65
  20. package/{main.d.ts → index.d.ts} +1 -1
  21. package/localization/localized-messages.directive.d.ts +1 -1
  22. package/models/animation.d.ts +1 -1
  23. package/models/notification-ref.d.ts +2 -2
  24. package/models/notification-settings.d.ts +1 -1
  25. package/models/position.d.ts +1 -1
  26. package/models/type.d.ts +1 -1
  27. package/notification.component.d.ts +7 -1
  28. package/notification.container.component.d.ts +1 -1
  29. package/notification.module.d.ts +3 -2
  30. package/package-metadata.d.ts +1 -1
  31. package/package.json +28 -54
  32. package/{kendo-angular-notification.d.ts → progress-kendo-angular-notification.d.ts} +2 -2
  33. package/schematics/ngAdd/index.js +5 -7
  34. package/services/notification.service.d.ts +1 -1
  35. package/utils/animations.d.ts +1 -1
  36. package/bundles/kendo-angular-notification.umd.js +0 -5
  37. package/schematics/ngAdd/index.js.map +0 -1
@@ -0,0 +1,741 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2023 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import * as i0 from '@angular/core';
6
+ import { forwardRef, Directive, Input, EventEmitter, ViewContainerRef, Component, ViewChild, HostBinding, TemplateRef, InjectionToken, ApplicationRef, Injectable, Inject, Optional, NgModule } from '@angular/core';
7
+ import { take } from 'rxjs/operators';
8
+ import { validatePackage } from '@progress/kendo-licensing';
9
+ import * as i1$1 from '@angular/animations';
10
+ import { style, animate } from '@angular/animations';
11
+ import * as i1 from '@progress/kendo-angular-l10n';
12
+ import { ComponentMessages, LocalizationService, L10N_PREFIX } from '@progress/kendo-angular-l10n';
13
+ import { xIcon, checkOutlineIcon, exclamationCircleIcon, xOutlineIcon, infoCircleIcon } from '@progress/kendo-svg-icons';
14
+ import * as i3 from '@progress/kendo-angular-icons';
15
+ import { IconsModule } from '@progress/kendo-angular-icons';
16
+ import * as i5 from '@angular/common';
17
+ import { CommonModule } from '@angular/common';
18
+
19
+ class NotificationSettings {
20
+ constructor() {
21
+ /**
22
+ * Specifies the time in milliseconds after which the
23
+ * Notification will hide
24
+ * ([see example]({% slug hiding_notifications %}#toc-definig-a-delay-before-hiding)).
25
+ * Defaults to `5000`.
26
+ */
27
+ this.hideAfter = 5000;
28
+ /**
29
+ * Defines the position of the Notification
30
+ * ([see example]({% slug positioning_notification %})).
31
+ *
32
+ * The possible values are:
33
+ * * `horizontal: 'left'|'center'|'right'`
34
+ * * `vertical: 'top'|'bottom'`
35
+ */
36
+ this.position = { horizontal: 'right', vertical: 'top' };
37
+ /**
38
+ * Specifies the animation settings of the Notification
39
+ * ([see example]({% slug animations_notification %})).
40
+ *
41
+ * The possible values are:
42
+ * * `duration`—Accepts a number in milliseconds. Defaults to `500ms`.
43
+ * * `type?: 'slide'| (Default) 'fade'`
44
+ */
45
+ this.animation = { type: 'fade', duration: 500 };
46
+ /**
47
+ * Specifies if the Notification will require a user action to hide.
48
+ * If the property is set to `true`, the Notification renders a **Close** button
49
+ * ([see example]({% slug hiding_notifications %}#toc-defining-a-closable-notification)).
50
+ *
51
+ * The possible values are:
52
+ * * (Default) `false`
53
+ * * `true`
54
+ */
55
+ this.closable = false;
56
+ /**
57
+ * Specifies the type of the Notification
58
+ * ([see example]({% slug types_notification %})).
59
+ *
60
+ * The possible values are:
61
+ * * `style: (Default) 'none'|'success'|'error'|'warning'|'info'`
62
+ * * `icon: 'true'|'false'`
63
+ */
64
+ this.type = { style: 'none', icon: true };
65
+ }
66
+ }
67
+
68
+ /**
69
+ * @hidden
70
+ */
71
+ const packageMetadata = {
72
+ name: '@progress/kendo-angular-notification',
73
+ productName: 'Kendo UI for Angular',
74
+ productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
75
+ publishDate: 1673510433,
76
+ version: '',
77
+ licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/'
78
+ };
79
+
80
+ /**
81
+ * @hidden
82
+ */
83
+ function slideAnimation(height, duration) {
84
+ return [
85
+ style({ overflow: 'hidden', height: 0 }),
86
+ animate(`${duration}ms ease-in`, style({ height: `${height}px` }))
87
+ ];
88
+ }
89
+ /**
90
+ * @hidden
91
+ */
92
+ function slideCloseAnimation(height, duration) {
93
+ return [
94
+ style({ height: `${height}px` }),
95
+ animate(`${duration}ms ease-in`, style({ overflow: 'hidden', height: 0 }))
96
+ ];
97
+ }
98
+ /**
99
+ * @hidden
100
+ */
101
+ function fadeAnimation(duration) {
102
+ return [
103
+ style({ opacity: 0 }),
104
+ animate(`${duration}ms ease-in`, style({ opacity: 1 }))
105
+ ];
106
+ }
107
+ /**
108
+ * @hidden
109
+ */
110
+ function fadeCloseAnimation(duration) {
111
+ return [
112
+ style({ opacity: 1 }),
113
+ animate(`${duration}ms ease-in`, style({ opacity: 0 }))
114
+ ];
115
+ }
116
+
117
+ /**
118
+ * @hidden
119
+ */
120
+ class LocalizedMessagesDirective extends ComponentMessages {
121
+ constructor(service) {
122
+ super();
123
+ this.service = service;
124
+ }
125
+ }
126
+ LocalizedMessagesDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: LocalizedMessagesDirective, deps: [{ token: i1.LocalizationService }], target: i0.ɵɵFactoryTarget.Directive });
127
+ LocalizedMessagesDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.11", type: LocalizedMessagesDirective, selector: "[kendoNotificationLocalizedMessages]", inputs: { closeTitle: "closeTitle" }, providers: [
128
+ {
129
+ provide: ComponentMessages,
130
+ useExisting: forwardRef(() => LocalizedMessagesDirective)
131
+ }
132
+ ], usesInheritance: true, ngImport: i0 });
133
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: LocalizedMessagesDirective, decorators: [{
134
+ type: Directive,
135
+ args: [{
136
+ providers: [
137
+ {
138
+ provide: ComponentMessages,
139
+ useExisting: forwardRef(() => LocalizedMessagesDirective)
140
+ }
141
+ ],
142
+ selector: `[kendoNotificationLocalizedMessages]`
143
+ }]
144
+ }], ctorParameters: function () { return [{ type: i1.LocalizationService }]; }, propDecorators: { closeTitle: [{
145
+ type: Input
146
+ }] } });
147
+
148
+ /**
149
+ * @hidden
150
+ *
151
+ */
152
+ class NotificationComponent {
153
+ constructor(cdr, element, renderer, builder, localizationService) {
154
+ this.cdr = cdr;
155
+ this.element = element;
156
+ this.renderer = renderer;
157
+ this.builder = builder;
158
+ this.localizationService = localizationService;
159
+ /**
160
+ * @hidden
161
+ */
162
+ this.xIcon = xIcon;
163
+ this.close = new EventEmitter();
164
+ this.width = null;
165
+ this.height = null;
166
+ this.defaultHideAfter = 5000;
167
+ this.animationEnd = new EventEmitter();
168
+ this.rtl = false;
169
+ validatePackage(packageMetadata);
170
+ this.dynamicRTLSubscription = localizationService.changes.subscribe(({ rtl }) => {
171
+ this.rtl = rtl;
172
+ this.direction = this.rtl ? 'rtl' : 'ltr';
173
+ });
174
+ }
175
+ get containerClass() {
176
+ return true;
177
+ }
178
+ get closeButtonTitle() {
179
+ return this.closeTitle || this.localizationService.get('closeTitle');
180
+ }
181
+ notificationClasses() {
182
+ return `${this.type ? this.typeClass() : ''}
183
+ ${this.closable ? 'k-notification-closable' : ''}`;
184
+ }
185
+ ngOnInit() {
186
+ clearTimeout(this.hideTimeout);
187
+ }
188
+ ngOnDestroy() {
189
+ clearTimeout(this.hideTimeout);
190
+ if (this.dynamicRTLSubscription) {
191
+ this.dynamicRTLSubscription.unsubscribe();
192
+ }
193
+ }
194
+ ngAfterViewInit() {
195
+ if (!this.closable && !this.animation) {
196
+ this.setHideTimeout();
197
+ }
198
+ if (!this.closable && this.animation) {
199
+ this.animationEnd.pipe(take(1))
200
+ .subscribe(() => this.setHideTimeout());
201
+ }
202
+ if (this.animation) {
203
+ this.animate(this.animation);
204
+ }
205
+ }
206
+ typeClass() {
207
+ return {
208
+ 'none': '',
209
+ 'success': 'k-notification-success',
210
+ 'warning': 'k-notification-warning',
211
+ 'error': 'k-notification-error',
212
+ 'info': 'k-notification-info'
213
+ }[this.type.style];
214
+ }
215
+ typeIconClass() {
216
+ return {
217
+ 'none': '',
218
+ 'success': 'check-outline',
219
+ 'warning': 'exclamation-circle',
220
+ 'error': 'x-outline',
221
+ 'info': 'info-circle'
222
+ }[this.type.style];
223
+ }
224
+ typeSVGIcon() {
225
+ return {
226
+ 'none': null,
227
+ 'success': checkOutlineIcon,
228
+ 'warning': exclamationCircleIcon,
229
+ 'error': xOutlineIcon,
230
+ 'info': infoCircleIcon
231
+ }[this.type.style];
232
+ }
233
+ onCloseClick() {
234
+ clearTimeout(this.hideTimeout);
235
+ this.hide();
236
+ }
237
+ hide(customComponent) {
238
+ const elementHeight = getComputedStyle(this.element.nativeElement).height;
239
+ if (this.animation && elementHeight) {
240
+ this.animate(this.animation, true);
241
+ this.animationEnd.subscribe(() => {
242
+ this.emitClose(customComponent);
243
+ });
244
+ return;
245
+ }
246
+ this.emitClose(customComponent);
247
+ }
248
+ setHideTimeout() {
249
+ const hideAfter = this.hideAfter || this.defaultHideAfter;
250
+ this.hideTimeout = window.setTimeout(() => this.onCloseClick(), hideAfter);
251
+ }
252
+ emitClose(customComponent) {
253
+ if (customComponent) {
254
+ customComponent.destroy();
255
+ }
256
+ this.close.emit();
257
+ }
258
+ play(animation, animatedElement) {
259
+ const factory = this.builder.build(animation);
260
+ const element = this.element.nativeElement;
261
+ this.renderer.addClass(element, 'k-notification-container-animating');
262
+ let player = factory.create(animatedElement);
263
+ player.onDone(() => {
264
+ this.renderer.removeClass(element, 'k-notification-container-animating');
265
+ this.animationEnd.emit();
266
+ if (player) {
267
+ player.destroy();
268
+ player = null;
269
+ }
270
+ });
271
+ player.play();
272
+ }
273
+ animate(animation, onclose) {
274
+ const element = this.element.nativeElement;
275
+ const duration = animation.duration;
276
+ const height = element.offsetHeight;
277
+ const generatedAnimation = animation.type === 'slide' ?
278
+ this.slideAnimation(height, duration, onclose) :
279
+ this.fadeAnimation(duration, onclose);
280
+ this.play(generatedAnimation, element);
281
+ }
282
+ slideAnimation(height, duration, onclose) {
283
+ return onclose ? slideCloseAnimation(height, duration) : slideAnimation(height, duration);
284
+ }
285
+ fadeAnimation(duration, onclose) {
286
+ return onclose ? fadeCloseAnimation(duration) : fadeAnimation(duration);
287
+ }
288
+ }
289
+ NotificationComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NotificationComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i1$1.AnimationBuilder }, { token: i1.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
290
+ NotificationComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NotificationComponent, selector: "kendo-notification", inputs: { templateRef: "templateRef", templateString: "templateString", width: "width", height: "height", cssClass: "cssClass", hideAfter: "hideAfter", closable: "closable", type: "type", animation: "animation" }, host: { properties: { "attr.dir": "this.direction", "class.k-notification-container": "this.containerClass" } }, providers: [
291
+ LocalizationService,
292
+ {
293
+ provide: L10N_PREFIX,
294
+ useValue: 'kendo.notification'
295
+ }
296
+ ], viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: `
297
+ <ng-container kendoNotificationLocalizedMessages
298
+ i18n-closeTitle="kendo.notification.closeTitle|The title of the close button"
299
+ closeTitle="Close"
300
+ >
301
+ </ng-container>
302
+ <div class="k-notification {{ notificationClasses() }}"
303
+ [ngClass]="cssClass"
304
+ [style.height.px]="height"
305
+ [style.width.px]="width">
306
+ <kendo-icon-wrapper
307
+ *ngIf="type && type.icon && type.style !== 'none'"
308
+ innerCssClass="k-notification-status"
309
+ [name]="typeIconClass()"
310
+ [svgIcon]="typeSVGIcon()"
311
+ >
312
+ </kendo-icon-wrapper>
313
+ <div class="k-notification-content">
314
+ <ng-template
315
+ [ngIf]="templateRef"
316
+ [ngTemplateOutlet]="templateRef">
317
+ </ng-template>
318
+ <ng-template
319
+ [ngIf]="templateString">
320
+ {{ templateString }}
321
+ </ng-template>
322
+ <ng-container #container></ng-container>
323
+ </div>
324
+
325
+ <span *ngIf="closable" class="k-notification-actions">
326
+ <span class="k-notification-action k-notification-close-action" [attr.title]="closeButtonTitle" (click)="onCloseClick()">
327
+ <kendo-icon-wrapper name="x" [svgIcon]="xIcon"></kendo-icon-wrapper>
328
+ </span>
329
+ </span>
330
+ </div>
331
+ `, isInline: true, components: [{ type: i3.IconWrapperComponent, selector: "kendo-icon-wrapper", inputs: ["name", "svgIcon", "innerCssClass", "customFontClass"], exportAs: ["kendoIconWrapper"] }], directives: [{ type: LocalizedMessagesDirective, selector: "[kendoNotificationLocalizedMessages]", inputs: ["closeTitle"] }, { type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
332
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NotificationComponent, decorators: [{
333
+ type: Component,
334
+ args: [{
335
+ selector: 'kendo-notification',
336
+ template: `
337
+ <ng-container kendoNotificationLocalizedMessages
338
+ i18n-closeTitle="kendo.notification.closeTitle|The title of the close button"
339
+ closeTitle="Close"
340
+ >
341
+ </ng-container>
342
+ <div class="k-notification {{ notificationClasses() }}"
343
+ [ngClass]="cssClass"
344
+ [style.height.px]="height"
345
+ [style.width.px]="width">
346
+ <kendo-icon-wrapper
347
+ *ngIf="type && type.icon && type.style !== 'none'"
348
+ innerCssClass="k-notification-status"
349
+ [name]="typeIconClass()"
350
+ [svgIcon]="typeSVGIcon()"
351
+ >
352
+ </kendo-icon-wrapper>
353
+ <div class="k-notification-content">
354
+ <ng-template
355
+ [ngIf]="templateRef"
356
+ [ngTemplateOutlet]="templateRef">
357
+ </ng-template>
358
+ <ng-template
359
+ [ngIf]="templateString">
360
+ {{ templateString }}
361
+ </ng-template>
362
+ <ng-container #container></ng-container>
363
+ </div>
364
+
365
+ <span *ngIf="closable" class="k-notification-actions">
366
+ <span class="k-notification-action k-notification-close-action" [attr.title]="closeButtonTitle" (click)="onCloseClick()">
367
+ <kendo-icon-wrapper name="x" [svgIcon]="xIcon"></kendo-icon-wrapper>
368
+ </span>
369
+ </span>
370
+ </div>
371
+ `,
372
+ providers: [
373
+ LocalizationService,
374
+ {
375
+ provide: L10N_PREFIX,
376
+ useValue: 'kendo.notification'
377
+ }
378
+ ]
379
+ }]
380
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i1$1.AnimationBuilder }, { type: i1.LocalizationService }]; }, propDecorators: { container: [{
381
+ type: ViewChild,
382
+ args: ['container', { read: ViewContainerRef, static: true }]
383
+ }], templateRef: [{
384
+ type: Input
385
+ }], templateString: [{
386
+ type: Input
387
+ }], width: [{
388
+ type: Input
389
+ }], height: [{
390
+ type: Input
391
+ }], cssClass: [{
392
+ type: Input
393
+ }], hideAfter: [{
394
+ type: Input
395
+ }], closable: [{
396
+ type: Input
397
+ }], type: [{
398
+ type: Input
399
+ }], animation: [{
400
+ type: Input
401
+ }], direction: [{
402
+ type: HostBinding,
403
+ args: ['attr.dir']
404
+ }], containerClass: [{
405
+ type: HostBinding,
406
+ args: ['class.k-notification-container']
407
+ }] } });
408
+
409
+ /**
410
+ * @hidden
411
+ */
412
+ class NotificationContainerComponent {
413
+ constructor(element, renderer, resolver) {
414
+ this.element = element;
415
+ this.renderer = renderer;
416
+ this.resolver = resolver;
417
+ this.id = '';
418
+ this.notifications = [];
419
+ }
420
+ ngOnDestroy() {
421
+ this.notifications.forEach((notification) => {
422
+ if (notification.closeClickSubscription) {
423
+ notification.closeClickSubscription.unsubscribe();
424
+ }
425
+ });
426
+ this.notifications = [];
427
+ }
428
+ addNotification(settings) {
429
+ this.position = settings.position;
430
+ this.id = `${this.position.horizontal} ${this.position.vertical}`;
431
+ const factory = this.resolver.resolveComponentFactory(NotificationComponent);
432
+ const notificationRef = this.container.createComponent(factory);
433
+ this.applySettings(notificationRef, settings);
434
+ let customComponent = null;
435
+ if (typeof settings.content === 'function') {
436
+ const customFactory = this.resolver.resolveComponentFactory(settings.content);
437
+ customComponent = notificationRef.instance.container.createComponent(customFactory);
438
+ }
439
+ notificationRef.changeDetectorRef.detectChanges();
440
+ this.notifications.push(notificationRef.instance);
441
+ if (settings.appendTo) {
442
+ this.applyAbsolutePosition(settings.appendTo);
443
+ }
444
+ this.applyPosition();
445
+ this.applyContainerWrap();
446
+ return {
447
+ afterHide: notificationRef.instance.close,
448
+ hide: () => notificationRef.instance.hide(customComponent),
449
+ notification: notificationRef,
450
+ content: customComponent || null
451
+ };
452
+ }
453
+ hide(notificationRef) {
454
+ const instance = notificationRef.instance;
455
+ const index = this.notifications.indexOf(instance);
456
+ this.notifications.splice(index, 1);
457
+ if (instance.closeClickSubscription) {
458
+ instance.closeClickSubscription.unsubscribe();
459
+ }
460
+ instance.templateRef = null;
461
+ instance.templateString = null;
462
+ notificationRef.destroy();
463
+ }
464
+ applyContainerWrap() {
465
+ const value = this.position.horizontal === 'right' ? 'wrap-reverse' : 'wrap';
466
+ this.renderer.setStyle(this.group.nativeElement, 'flex-wrap', value);
467
+ }
468
+ applySettings(notificationRef, settings) {
469
+ const notification = notificationRef.instance;
470
+ const content = settings.content;
471
+ const animation = settings.animation || null;
472
+ notification.closeClickSubscription = notification.close
473
+ .subscribe(() => this.hide(notificationRef));
474
+ if (typeof content === 'string') {
475
+ notification.templateString = content;
476
+ }
477
+ if (content instanceof TemplateRef) {
478
+ notification.templateRef = content;
479
+ }
480
+ notification.animation = animation;
481
+ const type = settings.type;
482
+ if (type && type.style === undefined) {
483
+ type.style = 'none';
484
+ }
485
+ if (type && type.icon === undefined) {
486
+ type.icon = true;
487
+ }
488
+ notification.type = type;
489
+ notification.closeTitle = settings.closeTitle;
490
+ if (settings.cssClass) {
491
+ notification.cssClass = settings.cssClass;
492
+ }
493
+ notification.closable = settings.closable;
494
+ notification.hideAfter = settings.hideAfter;
495
+ notification.width = settings.width;
496
+ notification.height = settings.height;
497
+ }
498
+ applyAbsolutePosition(appendToContainer) {
499
+ const appendTo = appendToContainer.element.nativeElement;
500
+ const el = this.element.nativeElement.children[0];
501
+ if (window.getComputedStyle(appendTo).position === 'static') {
502
+ this.renderer.setStyle(appendTo, 'position', 'relative');
503
+ }
504
+ this.renderer.setStyle(el, 'position', 'absolute');
505
+ }
506
+ applyPosition() {
507
+ const element = this.element.nativeElement.children[0];
508
+ const elementHalfWidth = element.getBoundingClientRect().width / 2;
509
+ const positionStyles = this.setContainerPosition(this.position, elementHalfWidth);
510
+ Object.keys(positionStyles).forEach((cssStyle) => {
511
+ element.style[cssStyle] = positionStyles[cssStyle];
512
+ });
513
+ }
514
+ setContainerPosition(position, offsetMargin) {
515
+ const positionLayout = {
516
+ horizontal: {
517
+ left: { left: 0, alignItems: 'flex-start' },
518
+ right: { right: 0, alignItems: 'flex-start' },
519
+ center: { left: '50%', marginLeft: `${-offsetMargin}px`, alignItems: 'center' }
520
+ },
521
+ vertical: {
522
+ top: { top: 0 },
523
+ bottom: { bottom: 0 }
524
+ }
525
+ };
526
+ const horizontal = positionLayout.horizontal[position.horizontal];
527
+ const vertical = positionLayout.vertical[position.vertical];
528
+ return Object.assign({}, horizontal, vertical);
529
+ }
530
+ }
531
+ NotificationContainerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NotificationContainerComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ComponentFactoryResolver }], target: i0.ɵɵFactoryTarget.Component });
532
+ NotificationContainerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: NotificationContainerComponent, selector: "kendo-notification-container", inputs: { id: "id" }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, read: ViewContainerRef, static: true }, { propertyName: "group", first: true, predicate: ["group"], descendants: true, static: true }], ngImport: i0, template: `
533
+ <div #group class="k-notification-group">
534
+ <ng-container #container></ng-container>
535
+ </div>
536
+ `, isInline: true });
537
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NotificationContainerComponent, decorators: [{
538
+ type: Component,
539
+ args: [{
540
+ selector: 'kendo-notification-container',
541
+ template: `
542
+ <div #group class="k-notification-group">
543
+ <ng-container #container></ng-container>
544
+ </div>
545
+ `
546
+ }]
547
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ComponentFactoryResolver }]; }, propDecorators: { container: [{
548
+ type: ViewChild,
549
+ args: ['container', { read: ViewContainerRef, static: true }]
550
+ }], group: [{
551
+ type: ViewChild,
552
+ args: ['group', { static: true }]
553
+ }], id: [{
554
+ type: Input
555
+ }] } });
556
+
557
+ /**
558
+ * Used to inject the Notification container. If not provided, the first root component of
559
+ * the application is used.
560
+ *
561
+ * > The `NOTIFICATION_CONTAINER` can be used only with the [`NotificationService`]({% slug api_notification_notificationservice %}) class.
562
+ *
563
+ * @example
564
+ *
565
+ * ```ts-no-run
566
+ * // Import the Notification module
567
+ * import { NotificationModule, NOTIFICATION_CONTAINER } from '@progress/kendo-angular-notification';
568
+ *
569
+ * // The browser platform with a compiler
570
+ * import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
571
+ *
572
+ * import { ElementRef, NgModule } from '@angular/core';
573
+ *
574
+ * // Import the app component
575
+ * import { AppComponent } from './app.component';
576
+ *
577
+ * // Define the app module
578
+ * _@NgModule({
579
+ * declarations: [AppComponent], // declare app component
580
+ * imports: [BrowserModule, NotificationModule], // import Notification module
581
+ * bootstrap: [AppComponent],
582
+ * providers: [{
583
+ * provide: NOTIFICATION_CONTAINER,
584
+ * useFactory: () => {
585
+ * //return the container ElementRef, where the notification will be injected
586
+ * return { nativeElement: document.body } as ElementRef;
587
+ * }
588
+ * }]
589
+ * })
590
+ * export class AppModule {}
591
+ *
592
+ * // Compile and launch the module
593
+ * platformBrowserDynamic().bootstrapModule(AppModule);
594
+ * ```
595
+ */
596
+ const NOTIFICATION_CONTAINER = new InjectionToken('Notification Container');
597
+ /**
598
+ * A service for opening Notification components dynamically
599
+ * ([see example]({% slug overview_notification %})).
600
+ *
601
+ * @export
602
+ * @class NotificationService
603
+ */
604
+ class NotificationService {
605
+ /**
606
+ * @hidden
607
+ */
608
+ constructor(resolver, injector, container) {
609
+ this.resolver = resolver;
610
+ this.injector = injector;
611
+ this.container = container;
612
+ this.notificationContainers = [];
613
+ this.position = { horizontal: 'right', vertical: 'top' };
614
+ }
615
+ /**
616
+ * Opens a Notification component. Created Notification are mounted
617
+ * in the DOM directly in the root application component.
618
+ *
619
+ * @param {NotificationSettings} settings - The settings which define the Notification.
620
+ *
621
+ * @returns {NotificationRef} - A reference to the Notification object and the convenience properties.
622
+ */
623
+ show(settings) {
624
+ if (!settings) {
625
+ throw new Error('NotificationSettings settings are required');
626
+ }
627
+ const target = this.findGroupContainer(settings);
628
+ const position = settings.position || this.position;
629
+ const currentId = `${position.horizontal} ${position.vertical}`;
630
+ let container;
631
+ let notificationRef;
632
+ let notificationContainer = this.notificationContainers.find(c => target.nativeElement.contains(c.element.nativeElement) && c.id === currentId);
633
+ if (!notificationContainer) {
634
+ container = this.resolver
635
+ .resolveComponentFactory(NotificationContainerComponent)
636
+ .create(this.injector);
637
+ notificationContainer = container.instance;
638
+ this.appRef.attachView(container.hostView);
639
+ const hostViewElement = container.location.nativeElement;
640
+ const groupContainer = this.findGroupContainer(settings);
641
+ if (!groupContainer) {
642
+ throw new Error(`
643
+ View Container not found! Inject the NOTIFICATION_CONTAINER or define a specific ViewContainerRef via
644
+ the appendTo option. See http://www.telerik.com/kendo-angular-ui/components/notification/api/NOTIFICATION_CONTAINER/
645
+ for more details.
646
+ `);
647
+ }
648
+ groupContainer.nativeElement.appendChild(hostViewElement);
649
+ this.notificationContainers.push(notificationContainer);
650
+ }
651
+ settings.position = position;
652
+ // eslint-disable-next-line prefer-const
653
+ notificationRef = notificationContainer.addNotification(settings);
654
+ return notificationRef;
655
+ }
656
+ get appRef() {
657
+ if (!this.applicationRef) {
658
+ this.applicationRef = this.injector.get(ApplicationRef);
659
+ }
660
+ return this.applicationRef;
661
+ }
662
+ findGroupContainer(settings) {
663
+ let container;
664
+ if (settings.appendTo) {
665
+ container = settings.appendTo.element;
666
+ }
667
+ else if (this.container) {
668
+ container = this.container;
669
+ }
670
+ else {
671
+ const appRoot = this.appRef.components && this.appRef.components[0];
672
+ container = appRoot ? appRoot.location : null;
673
+ }
674
+ return container;
675
+ }
676
+ }
677
+ NotificationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NotificationService, deps: [{ token: i0.ComponentFactoryResolver }, { token: i0.Injector }, { token: NOTIFICATION_CONTAINER, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
678
+ NotificationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NotificationService });
679
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NotificationService, decorators: [{
680
+ type: Injectable
681
+ }], ctorParameters: function () {
682
+ return [{ type: i0.ComponentFactoryResolver }, { type: i0.Injector }, { type: i0.ElementRef, decorators: [{
683
+ type: Inject,
684
+ args: [NOTIFICATION_CONTAINER]
685
+ }, {
686
+ type: Optional
687
+ }] }];
688
+ } });
689
+
690
+ /**
691
+ * Represents the [NgModule](link:site.data.urls.angular['ngmoduleapi'])
692
+ * definition for the Notification component.
693
+ *
694
+ * The package exports:
695
+ * - `NotificationService`&mdash;The Notification service class.
696
+ *
697
+ * @example
698
+ *
699
+ * ```ts-no-run
700
+ * // Import the Notification module
701
+ * import { NotificationModule } from '@progress/kendo-angular-notification';
702
+ *
703
+ * // The browser platform with a compiler
704
+ * import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
705
+ *
706
+ * import { NgModule } from '@angular/core';
707
+ *
708
+ * // Import the app component
709
+ * _@NgModule{{
710
+ * declarations: [AppComponent], // declare app component
711
+ * imports: [BrowserModule, NotificationModule], // import NotificationModule module
712
+ * bootstrap: [AppComponent]
713
+ * }}
714
+ * export class AppModule {}
715
+ *
716
+ * // Compile and launch the module
717
+ * platformBrowserDynamic().bootstrapModule(AppModule);
718
+ * ```
719
+ */
720
+ class NotificationModule {
721
+ }
722
+ NotificationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NotificationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
723
+ NotificationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NotificationModule, declarations: [NotificationComponent, NotificationContainerComponent, LocalizedMessagesDirective], imports: [CommonModule, IconsModule], exports: [NotificationComponent, NotificationContainerComponent] });
724
+ NotificationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NotificationModule, providers: [NotificationService], imports: [[CommonModule, IconsModule]] });
725
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: NotificationModule, decorators: [{
726
+ type: NgModule,
727
+ args: [{
728
+ declarations: [NotificationComponent, NotificationContainerComponent, LocalizedMessagesDirective],
729
+ entryComponents: [NotificationComponent, NotificationContainerComponent],
730
+ imports: [CommonModule, IconsModule],
731
+ exports: [NotificationComponent, NotificationContainerComponent],
732
+ providers: [NotificationService]
733
+ }]
734
+ }] });
735
+
736
+ /**
737
+ * Generated bundle index. Do not edit.
738
+ */
739
+
740
+ export { NOTIFICATION_CONTAINER, NotificationComponent, NotificationContainerComponent, NotificationModule, NotificationService, NotificationSettings };
741
+