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

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