@daffodil/design 0.67.0 → 0.68.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. package/esm2022/article/article/article.component.mjs +2 -2
  2. package/esm2022/article/examples/article-headings/article-headings.component.mjs +3 -4
  3. package/esm2022/loading-icon/examples/loading-icon-color/loading-icon-color.component.mjs +3 -3
  4. package/esm2022/loading-icon/loading-icon/loading-icon.component.mjs +3 -3
  5. package/esm2022/modal/service/modal.service.mjs +2 -3
  6. package/esm2022/toast/daffodil-design-toast.mjs +5 -0
  7. package/esm2022/toast/examples/daffodil-design-toast-examples.mjs +5 -0
  8. package/esm2022/toast/examples/default-toast/default-toast.component.mjs +38 -0
  9. package/esm2022/toast/examples/default-toast/default-toast.module.mjs +36 -0
  10. package/esm2022/toast/examples/index.mjs +2 -0
  11. package/esm2022/toast/examples/public_api.mjs +15 -0
  12. package/esm2022/toast/examples/toast-positions/toast-positions.component.mjs +42 -0
  13. package/esm2022/toast/examples/toast-positions/toast-positions.module.mjs +57 -0
  14. package/esm2022/toast/examples/toast-status/toast-status.component.mjs +45 -0
  15. package/esm2022/toast/examples/toast-status/toast-status.module.mjs +40 -0
  16. package/esm2022/toast/examples/toast-with-custom-duration/toast-with-custom-duration.component.mjs +26 -0
  17. package/esm2022/toast/examples/toast-with-custom-duration/toast-with-custom-duration.module.mjs +32 -0
  18. package/esm2022/toast/index.mjs +2 -0
  19. package/esm2022/toast/interfaces/toast-action.mjs +2 -0
  20. package/esm2022/toast/interfaces/toast.mjs +2 -0
  21. package/esm2022/toast/options/daff-toast-options.mjs +16 -0
  22. package/esm2022/toast/public_api.mjs +9 -0
  23. package/esm2022/toast/service/changes-focus.mjs +2 -0
  24. package/esm2022/toast/service/position-strategy.mjs +29 -0
  25. package/esm2022/toast/service/position.service.mjs +33 -0
  26. package/esm2022/toast/service/toast.service.mjs +116 -0
  27. package/esm2022/toast/toast/toast-config.mjs +2 -0
  28. package/esm2022/toast/toast/toast-template.component.mjs +262 -0
  29. package/esm2022/toast/toast/toast.component.mjs +82 -0
  30. package/esm2022/toast/toast-actions/toast-actions.directive.mjs +19 -0
  31. package/esm2022/toast/toast-message/toast-message.directive.mjs +19 -0
  32. package/esm2022/toast/toast-title/toast-title.directive.mjs +19 -0
  33. package/esm2022/toast/toast.module.mjs +70 -0
  34. package/fesm2022/daffodil-design-article-examples.mjs +2 -2
  35. package/fesm2022/daffodil-design-article-examples.mjs.map +1 -1
  36. package/fesm2022/daffodil-design-article.mjs +2 -2
  37. package/fesm2022/daffodil-design-article.mjs.map +1 -1
  38. package/fesm2022/daffodil-design-loading-icon-examples.mjs +2 -2
  39. package/fesm2022/daffodil-design-loading-icon-examples.mjs.map +1 -1
  40. package/fesm2022/daffodil-design-loading-icon.mjs +2 -2
  41. package/fesm2022/daffodil-design-loading-icon.mjs.map +1 -1
  42. package/fesm2022/daffodil-design-modal.mjs +1 -2
  43. package/fesm2022/daffodil-design-modal.mjs.map +1 -1
  44. package/fesm2022/daffodil-design-toast-examples.mjs +287 -0
  45. package/fesm2022/daffodil-design-toast-examples.mjs.map +1 -0
  46. package/fesm2022/daffodil-design-toast.mjs +625 -0
  47. package/fesm2022/daffodil-design-toast.mjs.map +1 -0
  48. package/loading-icon/src/loading-icon-theme.scss +24 -8
  49. package/navbar/README.md +1 -1
  50. package/package.json +1 -1
  51. package/scss/theme.scss +2 -0
  52. package/toast/README.md +115 -0
  53. package/toast/examples/default-toast/default-toast.component.d.ts +15 -0
  54. package/toast/examples/default-toast/default-toast.module.d.ts +11 -0
  55. package/toast/examples/index.d.ts +1 -0
  56. package/toast/examples/public_api.d.ts +2 -0
  57. package/toast/examples/toast-positions/toast-positions.component.d.ts +17 -0
  58. package/toast/examples/toast-positions/toast-positions.module.d.ts +12 -0
  59. package/toast/examples/toast-status/toast-status.component.d.ts +14 -0
  60. package/toast/examples/toast-status/toast-status.module.d.ts +12 -0
  61. package/toast/examples/toast-with-custom-duration/toast-with-custom-duration.component.d.ts +10 -0
  62. package/toast/examples/toast-with-custom-duration/toast-with-custom-duration.module.d.ts +10 -0
  63. package/toast/index.d.ts +1 -0
  64. package/toast/interfaces/toast-action.d.ts +38 -0
  65. package/toast/interfaces/toast.d.ts +20 -0
  66. package/toast/options/daff-toast-options.d.ts +15 -0
  67. package/toast/public_api.d.ts +11 -0
  68. package/toast/service/changes-focus.d.ts +2 -0
  69. package/toast/service/position-strategy.d.ts +3 -0
  70. package/toast/service/position.service.d.ts +15 -0
  71. package/toast/service/toast.service.d.ts +29 -0
  72. package/toast/src/toast-theme.scss +63 -0
  73. package/toast/toast/toast-config.d.ts +7 -0
  74. package/toast/toast/toast-template.component.d.ts +20 -0
  75. package/toast/toast/toast.component.d.ts +52 -0
  76. package/toast/toast-actions/toast-actions.directive.d.ts +6 -0
  77. package/toast/toast-message/toast-message.directive.d.ts +6 -0
  78. package/toast/toast-title/toast-title.directive.d.ts +6 -0
  79. package/toast/toast.module.d.ts +17 -0
@@ -0,0 +1,625 @@
1
+ import * as i1 from '@angular/cdk/layout';
2
+ import * as i0 from '@angular/core';
3
+ import { InjectionToken, Injectable, Inject, Directive, HostBinding, Component, ViewEncapsulation, ChangeDetectionStrategy, ContentChild, Input, HostListener, EventEmitter, Output, NgModule, Optional, SkipSelf } from '@angular/core';
4
+ import * as i2 from '@daffodil/design';
5
+ import { DaffBreakpoints, daffArticleEncapsulatedMixin, daffStatusMixin, DaffPrefixDirective, DaffPrefixSuffixModule } from '@daffodil/design';
6
+ import * as i1$2 from '@angular/cdk/overlay';
7
+ import { OverlayModule, GlobalPositionStrategy } from '@angular/cdk/overlay';
8
+ import { PortalModule, ComponentPortal } from '@angular/cdk/portal';
9
+ import * as i2$1 from '@angular/common';
10
+ import { CommonModule } from '@angular/common';
11
+ import * as i4 from '@fortawesome/angular-fontawesome';
12
+ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
13
+ import * as i3 from '@daffodil/design/button';
14
+ import { DaffButtonModule } from '@daffodil/design/button';
15
+ import { trigger, transition, style, animate } from '@angular/animations';
16
+ import { faTimes } from '@fortawesome/free-solid-svg-icons';
17
+ import * as i1$1 from '@angular/cdk/a11y';
18
+ import { merge, of, EMPTY } from 'rxjs';
19
+ import { filter, map, tap, delay, take } from 'rxjs/operators';
20
+
21
+ ;
22
+ ;
23
+ const daffToastDefaultOptions = {
24
+ position: {
25
+ vertical: 'top',
26
+ horizontal: 'right',
27
+ },
28
+ useParent: true,
29
+ };
30
+ const DAFF_TOAST_OPTIONS = new InjectionToken('DAFF_TOAST_OPTIONS', { providedIn: 'root', factory: () => daffToastDefaultOptions });
31
+ const provideDaffToastOptions = (options) => ({ provide: DAFF_TOAST_OPTIONS, useValue: {
32
+ ...daffToastDefaultOptions,
33
+ ...options,
34
+ } });
35
+
36
+ class DaffToastPositionService {
37
+ constructor(options, mediaQuery) {
38
+ this.options = options;
39
+ this.mediaQuery = mediaQuery;
40
+ this._config = options.position;
41
+ }
42
+ get config() {
43
+ return this.mediaQuery.isMatched(DaffBreakpoints.MOBILE)
44
+ ? this._position ?? this._config
45
+ : { vertical: 'bottom', horizontal: 'center' };
46
+ }
47
+ set config(val) {
48
+ this._config = val;
49
+ }
50
+ setPosition(position) {
51
+ this._position = position;
52
+ }
53
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastPositionService, deps: [{ token: DAFF_TOAST_OPTIONS }, { token: i1.BreakpointObserver }], target: i0.ɵɵFactoryTarget.Injectable }); }
54
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastPositionService }); }
55
+ }
56
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastPositionService, decorators: [{
57
+ type: Injectable
58
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
59
+ type: Inject,
60
+ args: [DAFF_TOAST_OPTIONS]
61
+ }] }, { type: i1.BreakpointObserver }] });
62
+
63
+ const daffToastChangesFocus = (toast) => toast.actions?.length > 0;
64
+
65
+ class DaffToastActionsDirective {
66
+ constructor() {
67
+ this.class = true;
68
+ }
69
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastActionsDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
70
+ /** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.1", type: DaffToastActionsDirective, selector: "[daffToastActions]", host: { properties: { "class.daff-toast__actions": "this.class" } }, ngImport: i0 }); }
71
+ }
72
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastActionsDirective, decorators: [{
73
+ type: Directive,
74
+ args: [{
75
+ selector: '[daffToastActions]',
76
+ }]
77
+ }], propDecorators: { class: [{
78
+ type: HostBinding,
79
+ args: ['class.daff-toast__actions']
80
+ }] } });
81
+
82
+ /**
83
+ * An _elementRef is needed for the core mixins
84
+ */
85
+ class DaffToastBase {
86
+ constructor(_elementRef, _renderer) {
87
+ this._elementRef = _elementRef;
88
+ this._renderer = _renderer;
89
+ }
90
+ }
91
+ const _daffToastBase = daffArticleEncapsulatedMixin(daffStatusMixin(DaffToastBase));
92
+ /**
93
+ * DaffToastComponent provides a way to display and
94
+ * communicate information for user actions or system updates.
95
+ */
96
+ class DaffToastComponent extends _daffToastBase {
97
+ /**
98
+ * @docs-private
99
+ */
100
+ onEscape() {
101
+ this.toast.dismiss();
102
+ }
103
+ constructor(elementRef, renderer, _focusTrapFactory, _focusStack) {
104
+ super(elementRef, renderer);
105
+ this.elementRef = elementRef;
106
+ this.renderer = renderer;
107
+ this._focusTrapFactory = _focusTrapFactory;
108
+ this._focusStack = _focusStack;
109
+ /** @docs-private */
110
+ this.class = true;
111
+ /** @docs-private */
112
+ this.role = 'status';
113
+ }
114
+ ngAfterContentInit() {
115
+ if (daffToastChangesFocus(this.toast)) {
116
+ this._focusTrap = this._focusTrapFactory.create(this._elementRef.nativeElement);
117
+ }
118
+ }
119
+ ngAfterViewInit() {
120
+ if (daffToastChangesFocus(this.toast)) {
121
+ this._focusStack.push();
122
+ this._focusTrap.focusFirstTabbableElementWhenReady();
123
+ }
124
+ }
125
+ ngOnDestroy() {
126
+ if (daffToastChangesFocus(this.toast)) {
127
+ this._focusTrap.destroy();
128
+ }
129
+ }
130
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i1$1.ConfigurableFocusTrapFactory }, { token: i2.DaffFocusStackService }], target: i0.ɵɵFactoryTarget.Component }); }
131
+ /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.1.1", type: DaffToastComponent, selector: "daff-toast", inputs: { status: "status", toast: "toast" }, host: { listeners: { "keydown.escape": "onEscape()" }, properties: { "class.daff-toast": "this.class", "attr.role": "this.role" } }, queries: [{ propertyName: "_actions", first: true, predicate: DaffToastActionsDirective, descendants: true }, { propertyName: "_prefix", first: true, predicate: DaffPrefixDirective, descendants: true }], usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"_prefix\">\n <ng-content select=\"[daffPrefix]\"></ng-content>\n</ng-container>\n<div class=\"daff-toast__details\">\n <div class=\"daff-toast__content\">\n <ng-content select=\"[daffToastTitle]\"></ng-content>\n <ng-content select=\"[daffToastMessage]\"></ng-content>\n </div>\n <ng-content select=\"[daffToastActions]\"></ng-content>\n</div>\n<ng-content></ng-content>\n", styles: [".daff-toast{display:flex;border-radius:.25rem;font-size:1rem;line-height:1.5rem;position:relative;min-width:15rem;max-width:90vw}@media (min-width: 480px){.daff-toast{max-width:22rem}}.daff-toast+div+.daff-toast,.daff-toast+div+div+.daff-toast,.daff-toast+.daff-toast{margin-top:.75rem}.daff-toast:before{content:\"\";border-radius:.25rem 0 0 .25rem;position:absolute;height:100%;left:0;top:0;width:.25rem}.daff-toast .daff-prefix{padding:1rem 0 1rem 1rem}.daff-toast__close-button{cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;appearance:none;background:none;border:none;color:currentColor;margin:0;min-height:3rem;height:3rem;min-width:3rem;width:3rem}.daff-toast__details{display:block;font-size:1rem;line-height:1.5rem;width:100%}.daff-toast__content{display:flex;flex-direction:column;gap:.25rem;padding:1rem}.daff-toast__title{font-weight:600}.daff-toast__message{font-weight:400;line-height:1.25rem}.daff-toast__actions{display:flex;align-items:center;gap:.5rem;min-height:3rem;padding:0 1rem 1rem}\n"], dependencies: [{ kind: "directive", type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
132
+ }
133
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastComponent, decorators: [{
134
+ type: Component,
135
+ args: [{ selector: 'daff-toast', inputs: ['status'], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"_prefix\">\n <ng-content select=\"[daffPrefix]\"></ng-content>\n</ng-container>\n<div class=\"daff-toast__details\">\n <div class=\"daff-toast__content\">\n <ng-content select=\"[daffToastTitle]\"></ng-content>\n <ng-content select=\"[daffToastMessage]\"></ng-content>\n </div>\n <ng-content select=\"[daffToastActions]\"></ng-content>\n</div>\n<ng-content></ng-content>\n", styles: [".daff-toast{display:flex;border-radius:.25rem;font-size:1rem;line-height:1.5rem;position:relative;min-width:15rem;max-width:90vw}@media (min-width: 480px){.daff-toast{max-width:22rem}}.daff-toast+div+.daff-toast,.daff-toast+div+div+.daff-toast,.daff-toast+.daff-toast{margin-top:.75rem}.daff-toast:before{content:\"\";border-radius:.25rem 0 0 .25rem;position:absolute;height:100%;left:0;top:0;width:.25rem}.daff-toast .daff-prefix{padding:1rem 0 1rem 1rem}.daff-toast__close-button{cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;appearance:none;background:none;border:none;color:currentColor;margin:0;min-height:3rem;height:3rem;min-width:3rem;width:3rem}.daff-toast__details{display:block;font-size:1rem;line-height:1.5rem;width:100%}.daff-toast__content{display:flex;flex-direction:column;gap:.25rem;padding:1rem}.daff-toast__title{font-weight:600}.daff-toast__message{font-weight:400;line-height:1.25rem}.daff-toast__actions{display:flex;align-items:center;gap:.5rem;min-height:3rem;padding:0 1rem 1rem}\n"] }]
136
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i1$1.ConfigurableFocusTrapFactory }, { type: i2.DaffFocusStackService }], propDecorators: { class: [{
137
+ type: HostBinding,
138
+ args: ['class.daff-toast']
139
+ }], role: [{
140
+ type: HostBinding,
141
+ args: ['attr.role']
142
+ }], _actions: [{
143
+ type: ContentChild,
144
+ args: [DaffToastActionsDirective]
145
+ }], _prefix: [{
146
+ type: ContentChild,
147
+ args: [DaffPrefixDirective]
148
+ }], toast: [{
149
+ type: Input
150
+ }], onEscape: [{
151
+ type: HostListener,
152
+ args: ['keydown.escape']
153
+ }] } });
154
+
155
+ class DaffToastTitleDirective {
156
+ constructor() {
157
+ this.class = true;
158
+ }
159
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastTitleDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
160
+ /** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.1", type: DaffToastTitleDirective, selector: "[daffToastTitle]", host: { properties: { "class.daff-toast__title": "this.class" } }, ngImport: i0 }); }
161
+ }
162
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastTitleDirective, decorators: [{
163
+ type: Directive,
164
+ args: [{
165
+ selector: '[daffToastTitle]',
166
+ }]
167
+ }], propDecorators: { class: [{
168
+ type: HostBinding,
169
+ args: ['class.daff-toast__title']
170
+ }] } });
171
+
172
+ class DaffToastMessageDirective {
173
+ constructor() {
174
+ this.class = true;
175
+ }
176
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastMessageDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
177
+ /** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.1", type: DaffToastMessageDirective, selector: "[daffToastMessage]", host: { properties: { "class.daff-toast__message": "this.class" } }, ngImport: i0 }); }
178
+ }
179
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastMessageDirective, decorators: [{
180
+ type: Directive,
181
+ args: [{
182
+ selector: '[daffToastMessage]',
183
+ }]
184
+ }], propDecorators: { class: [{
185
+ type: HostBinding,
186
+ args: ['class.daff-toast__message']
187
+ }] } });
188
+
189
+ class DaffToastTemplateComponent {
190
+ constructor(cd, options, toastPosition) {
191
+ this.cd = cd;
192
+ this.options = options;
193
+ this.toastPosition = toastPosition;
194
+ this.faTimes = faTimes;
195
+ this._items = [];
196
+ this.closeToast = new EventEmitter();
197
+ }
198
+ onCloseToast(event) {
199
+ this.closeToast.emit();
200
+ }
201
+ get slideAnimation() {
202
+ switch (this.toastPosition.config.horizontal + '-' + this.toastPosition.config.vertical) {
203
+ case 'left-top':
204
+ case 'left-bottom':
205
+ return {
206
+ value: 0,
207
+ params: {
208
+ startX: '-100%',
209
+ endX: '0',
210
+ startY: '0',
211
+ endY: '0',
212
+ },
213
+ };
214
+ case 'right-top':
215
+ case 'right-bottom':
216
+ return {
217
+ value: 0,
218
+ params: {
219
+ startX: '100%',
220
+ endX: '0',
221
+ startY: '0',
222
+ endY: '0',
223
+ },
224
+ };
225
+ case 'center-top':
226
+ return {
227
+ value: 0,
228
+ params: {
229
+ startX: '0',
230
+ endX: '0',
231
+ startY: '-100%',
232
+ endY: '0',
233
+ },
234
+ };
235
+ case 'center-bottom':
236
+ return {
237
+ value: 0,
238
+ params: {
239
+ startX: '0',
240
+ endX: '0',
241
+ startY: '100%',
242
+ endY: '0',
243
+ },
244
+ };
245
+ }
246
+ }
247
+ get items() {
248
+ return this._items;
249
+ }
250
+ set items(value) {
251
+ this._items = value;
252
+ this.cd.markForCheck();
253
+ }
254
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastTemplateComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: DAFF_TOAST_OPTIONS }, { token: DaffToastPositionService }], target: i0.ɵɵFactoryTarget.Component }); }
255
+ /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.1.1", type: DaffToastTemplateComponent, selector: "ng-component", inputs: { items: "items" }, outputs: { closeToast: "closeToast" }, ngImport: i0, template: `
256
+ <daff-toast
257
+ *ngFor="let item of items | slice:0:3"
258
+ [toast]="item"
259
+ [status]="item.status ?? null"
260
+ (closeToast)="item.dismiss()"
261
+ [@slideIn]="slideAnimation"
262
+ [attr.role]="item.actions ? 'alertdialog' : undefined"
263
+ [attr.aria-labelledby]="item.actions ? item.title : undefined"
264
+ [attr.aria-describedby]="item.actions ? item.message : undefined">
265
+ <div daffToastTitle>{{ item.title }}</div>
266
+ <div daffToastMessage>{{ item.message }}</div>
267
+ <div daffToastActions *ngIf="item.actions">
268
+ <ng-container *ngFor="let action of item.actions">
269
+ <ng-container *ngTemplateOutlet="button;context:{ action, item }"></ng-container>
270
+ </ng-container>
271
+ </div>
272
+ <button daff-icon-button color="theme-contrast"
273
+ *ngIf="item.dismissible"
274
+ aria-label="close button"
275
+ [attr.aria-hidden]="item.actions ? undefined : true"
276
+ (click)="onCloseToast(item.dismiss())">
277
+ <fa-icon [icon]="faTimes" size="sm" [fixedWidth]="true"></fa-icon>
278
+ </button>
279
+ </daff-toast>
280
+
281
+ <ng-template #button let-action="action" let-item="item">
282
+ <ng-container [ngSwitch]="action.type">
283
+ <button type="button" *ngSwitchDefault daff-button
284
+ [status]="action.status"
285
+ [color]="action.color"
286
+ [size]="action.size"
287
+ [attr.aria-label]="action.content"
288
+ (click)="action.eventEmitter?.emit({ event: $event, action})">
289
+ {{ action.content }}
290
+ </button>
291
+ <button type="button" *ngSwitchCase="'stroked'" daff-stroked-button
292
+ [status]="action.status"
293
+ [color]="action.color"
294
+ [size]="action.size"
295
+ [attr.aria-label]="action.content"
296
+ (click)="action.eventEmitter?.emit({ event: $event, action})">
297
+ {{ action.content }}
298
+ </button>
299
+ <button type="button" *ngSwitchCase="'raised'" daff-raised-button
300
+ [status]="action.status"
301
+ [color]="action.color"
302
+ [size]="action.size"
303
+ [attr.aria-label]="action.content"
304
+ (click)="action.eventEmitter?.emit({ event: $event, action})">
305
+ {{ action.content }}
306
+ </button>
307
+ <button type="button" *ngSwitchCase="'flat'" daff-flat-button
308
+ [status]="action.status"
309
+ [color]="action.color"
310
+ [size]="action.size"
311
+ [attr.aria-label]="action.content"
312
+ (click)="action.eventEmitter?.emit({ event: $event, action})">
313
+ {{ action.content }}
314
+ </button>
315
+ <button type="button" *ngSwitchCase="'underline'" daff-underline-button
316
+ [status]="action.status"
317
+ [color]="action.color"
318
+ [size]="action.size"
319
+ [attr.aria-label]="action.content"
320
+ (click)="action.eventEmitter?.emit({ event: $event, action})">
321
+ {{ action.content }}
322
+ </button>
323
+ </ng-container>
324
+ </ng-template>
325
+ `, isInline: true, dependencies: [{ kind: "directive", type: i2$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2$1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i2$1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i2$1.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "component", type: i3.DaffButtonComponent, selector: "button[daff-button],button[daff-stroked-button],button[daff-raised-button],button[daff-flat-button],button[daff-icon-button],button[daff-underline-button],a[daff-button],a[daff-stroked-button],a[daff-raised-button],a[daff-flat-button],a[daff-icon-button],a[daff-underline-button]", inputs: ["color", "size", "status", "loading", "tabindex", "disabled"] }, { kind: "component", type: i4.FaIconComponent, selector: "fa-icon", inputs: ["icon", "title", "animation", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "classes", "transform", "a11yRole"] }, { kind: "component", type: DaffToastComponent, selector: "daff-toast", inputs: ["status", "toast"] }, { kind: "directive", type: DaffToastActionsDirective, selector: "[daffToastActions]" }, { kind: "directive", type: DaffToastTitleDirective, selector: "[daffToastTitle]" }, { kind: "directive", type: DaffToastMessageDirective, selector: "[daffToastMessage]" }, { kind: "pipe", type: i2$1.SlicePipe, name: "slice" }], animations: [
326
+ trigger('slideIn', [
327
+ transition(':enter', [
328
+ style({ opacity: '0', transform: 'translate({{startX}}, {{startY}})' }),
329
+ animate('300ms ease-out', style({ opacity: '1', transform: 'translate({{endX}}, {{endY}})' })),
330
+ ], { params: {
331
+ startX: '0',
332
+ startY: '0',
333
+ endX: '0',
334
+ endY: '0',
335
+ } }),
336
+ ]),
337
+ ], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
338
+ }
339
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastTemplateComponent, decorators: [{
340
+ type: Component,
341
+ args: [{
342
+ changeDetection: ChangeDetectionStrategy.OnPush,
343
+ template: `
344
+ <daff-toast
345
+ *ngFor="let item of items | slice:0:3"
346
+ [toast]="item"
347
+ [status]="item.status ?? null"
348
+ (closeToast)="item.dismiss()"
349
+ [@slideIn]="slideAnimation"
350
+ [attr.role]="item.actions ? 'alertdialog' : undefined"
351
+ [attr.aria-labelledby]="item.actions ? item.title : undefined"
352
+ [attr.aria-describedby]="item.actions ? item.message : undefined">
353
+ <div daffToastTitle>{{ item.title }}</div>
354
+ <div daffToastMessage>{{ item.message }}</div>
355
+ <div daffToastActions *ngIf="item.actions">
356
+ <ng-container *ngFor="let action of item.actions">
357
+ <ng-container *ngTemplateOutlet="button;context:{ action, item }"></ng-container>
358
+ </ng-container>
359
+ </div>
360
+ <button daff-icon-button color="theme-contrast"
361
+ *ngIf="item.dismissible"
362
+ aria-label="close button"
363
+ [attr.aria-hidden]="item.actions ? undefined : true"
364
+ (click)="onCloseToast(item.dismiss())">
365
+ <fa-icon [icon]="faTimes" size="sm" [fixedWidth]="true"></fa-icon>
366
+ </button>
367
+ </daff-toast>
368
+
369
+ <ng-template #button let-action="action" let-item="item">
370
+ <ng-container [ngSwitch]="action.type">
371
+ <button type="button" *ngSwitchDefault daff-button
372
+ [status]="action.status"
373
+ [color]="action.color"
374
+ [size]="action.size"
375
+ [attr.aria-label]="action.content"
376
+ (click)="action.eventEmitter?.emit({ event: $event, action})">
377
+ {{ action.content }}
378
+ </button>
379
+ <button type="button" *ngSwitchCase="'stroked'" daff-stroked-button
380
+ [status]="action.status"
381
+ [color]="action.color"
382
+ [size]="action.size"
383
+ [attr.aria-label]="action.content"
384
+ (click)="action.eventEmitter?.emit({ event: $event, action})">
385
+ {{ action.content }}
386
+ </button>
387
+ <button type="button" *ngSwitchCase="'raised'" daff-raised-button
388
+ [status]="action.status"
389
+ [color]="action.color"
390
+ [size]="action.size"
391
+ [attr.aria-label]="action.content"
392
+ (click)="action.eventEmitter?.emit({ event: $event, action})">
393
+ {{ action.content }}
394
+ </button>
395
+ <button type="button" *ngSwitchCase="'flat'" daff-flat-button
396
+ [status]="action.status"
397
+ [color]="action.color"
398
+ [size]="action.size"
399
+ [attr.aria-label]="action.content"
400
+ (click)="action.eventEmitter?.emit({ event: $event, action})">
401
+ {{ action.content }}
402
+ </button>
403
+ <button type="button" *ngSwitchCase="'underline'" daff-underline-button
404
+ [status]="action.status"
405
+ [color]="action.color"
406
+ [size]="action.size"
407
+ [attr.aria-label]="action.content"
408
+ (click)="action.eventEmitter?.emit({ event: $event, action})">
409
+ {{ action.content }}
410
+ </button>
411
+ </ng-container>
412
+ </ng-template>
413
+ `,
414
+ animations: [
415
+ trigger('slideIn', [
416
+ transition(':enter', [
417
+ style({ opacity: '0', transform: 'translate({{startX}}, {{startY}})' }),
418
+ animate('300ms ease-out', style({ opacity: '1', transform: 'translate({{endX}}, {{endY}})' })),
419
+ ], { params: {
420
+ startX: '0',
421
+ startY: '0',
422
+ endX: '0',
423
+ endY: '0',
424
+ } }),
425
+ ]),
426
+ ],
427
+ }]
428
+ }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: undefined, decorators: [{
429
+ type: Inject,
430
+ args: [DAFF_TOAST_OPTIONS]
431
+ }] }, { type: DaffToastPositionService }], propDecorators: { closeToast: [{
432
+ type: Output
433
+ }], items: [{
434
+ type: Input
435
+ }] } });
436
+
437
+ class DaffToastModule {
438
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
439
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.1.1", ngImport: i0, type: DaffToastModule, declarations: [DaffToastComponent,
440
+ DaffToastActionsDirective,
441
+ DaffToastTitleDirective,
442
+ DaffToastMessageDirective,
443
+ DaffToastTemplateComponent], imports: [CommonModule,
444
+ DaffPrefixSuffixModule,
445
+ DaffButtonModule,
446
+ FontAwesomeModule,
447
+ PortalModule,
448
+ OverlayModule], exports: [DaffToastComponent,
449
+ DaffToastActionsDirective,
450
+ DaffToastTitleDirective,
451
+ DaffToastMessageDirective,
452
+ DaffPrefixSuffixModule] }); }
453
+ /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastModule, providers: [
454
+ DaffToastPositionService,
455
+ ], imports: [CommonModule,
456
+ DaffPrefixSuffixModule,
457
+ DaffButtonModule,
458
+ FontAwesomeModule,
459
+ PortalModule,
460
+ OverlayModule, DaffPrefixSuffixModule] }); }
461
+ }
462
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastModule, decorators: [{
463
+ type: NgModule,
464
+ args: [{
465
+ imports: [
466
+ CommonModule,
467
+ DaffPrefixSuffixModule,
468
+ DaffButtonModule,
469
+ FontAwesomeModule,
470
+ PortalModule,
471
+ OverlayModule,
472
+ ],
473
+ declarations: [
474
+ DaffToastComponent,
475
+ DaffToastActionsDirective,
476
+ DaffToastTitleDirective,
477
+ DaffToastMessageDirective,
478
+ DaffToastTemplateComponent,
479
+ ],
480
+ exports: [
481
+ DaffToastComponent,
482
+ DaffToastActionsDirective,
483
+ DaffToastTitleDirective,
484
+ DaffToastMessageDirective,
485
+ DaffPrefixSuffixModule,
486
+ ],
487
+ providers: [
488
+ DaffToastPositionService,
489
+ ],
490
+ }]
491
+ }] });
492
+
493
+ const createPositionStrategy = (position) => {
494
+ const strat = new GlobalPositionStrategy();
495
+ switch (position.horizontal) {
496
+ case 'left':
497
+ strat.left('48px');
498
+ break;
499
+ case 'right':
500
+ strat.right('48px');
501
+ break;
502
+ case 'center':
503
+ strat.centerHorizontally();
504
+ break;
505
+ default:
506
+ strat.right('48px');
507
+ }
508
+ switch (position.vertical) {
509
+ case 'top':
510
+ strat.top('80px');
511
+ break;
512
+ case 'bottom':
513
+ strat.bottom('48px');
514
+ break;
515
+ default:
516
+ strat.top('80px');
517
+ }
518
+ return strat;
519
+ };
520
+
521
+ const daffDefaultToastConfiguration = {};
522
+
523
+ class DaffToastService {
524
+ constructor(overlay, options, _parentToast, mediaQuery, toastPosition, focusStack) {
525
+ this.overlay = overlay;
526
+ this.options = options;
527
+ this._parentToast = _parentToast;
528
+ this.mediaQuery = mediaQuery;
529
+ this.toastPosition = toastPosition;
530
+ this.focusStack = focusStack;
531
+ this._toasts = [];
532
+ this._sub = this.mediaQuery.observe(DaffBreakpoints.MOBILE).pipe(filter(() => this._overlayRef !== undefined), map((position) => createPositionStrategy(this.toastPosition.config)), tap((strategy) => this._overlayRef.updatePositionStrategy(strategy))).subscribe();
533
+ }
534
+ ngOnDestroy() {
535
+ this._sub.unsubscribe();
536
+ }
537
+ _attachToastTemplate(overlayRef) {
538
+ const template = overlayRef.attach(new ComponentPortal(DaffToastTemplateComponent));
539
+ return template;
540
+ }
541
+ _createOverlayRef() {
542
+ return this.overlay.create({
543
+ hasBackdrop: false,
544
+ scrollStrategy: this.overlay.scrollStrategies.noop(),
545
+ positionStrategy: createPositionStrategy(this.toastPosition.config),
546
+ });
547
+ }
548
+ open(toast, configuration) {
549
+ if (this._parentToast && this.options.useParent) {
550
+ return this._parentToast.open(toast, configuration);
551
+ }
552
+ const config = {
553
+ ...daffDefaultToastConfiguration,
554
+ // sets the default duration to 5000ms if a toast does not have actions
555
+ duration: toast.actions?.length > 0 ? undefined : 5000,
556
+ ...configuration,
557
+ };
558
+ if (this._toasts.length === 0) {
559
+ this._overlayRef = this._createOverlayRef();
560
+ this._template = this._attachToastTemplate(this._overlayRef);
561
+ }
562
+ const dismissEvent = new EventEmitter();
563
+ const _toastPlus = {
564
+ dismissible: true,
565
+ ...toast,
566
+ dismiss: () => {
567
+ dismissEvent.emit();
568
+ },
569
+ dismissalStream: merge(config.duration ? of(undefined).pipe(delay(config.duration)) : EMPTY, dismissEvent).pipe(take(1)),
570
+ };
571
+ _toastPlus.dismissalStream.subscribe(() => {
572
+ this.close(_toastPlus);
573
+ });
574
+ this._toasts = [
575
+ _toastPlus,
576
+ ...this._toasts,
577
+ ];
578
+ this._template.instance.items = this._toasts;
579
+ return _toastPlus;
580
+ }
581
+ close(toast) {
582
+ if (this._parentToast && this.options.useParent) {
583
+ this._parentToast.close(toast);
584
+ return;
585
+ }
586
+ if (daffToastChangesFocus(toast)) {
587
+ this.focusStack.pop();
588
+ }
589
+ const index = this._toasts.indexOf(toast);
590
+ if (index === -1) {
591
+ throw new Error('The Toast that you are trying to remove does not exist.');
592
+ }
593
+ this._toasts = this._toasts.filter(m => m !== toast);
594
+ this._template.instance.items = [...this._toasts];
595
+ // This currently overrides the ":leave" animation as we currently
596
+ // remove the animating element immediately after there are no more toasts,
597
+ // without waiting for the animation to complete.
598
+ if (this._toasts.length === 0) {
599
+ this._overlayRef.dispose();
600
+ this._template.destroy();
601
+ this._overlayRef = undefined;
602
+ this._template = undefined;
603
+ }
604
+ }
605
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastService, deps: [{ token: i1$2.Overlay }, { token: DAFF_TOAST_OPTIONS }, { token: DaffToastService, optional: true, skipSelf: true }, { token: i1.BreakpointObserver }, { token: DaffToastPositionService }, { token: i2.DaffFocusStackService }], target: i0.ɵɵFactoryTarget.Injectable }); }
606
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastService, providedIn: DaffToastModule }); }
607
+ }
608
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffToastService, decorators: [{
609
+ type: Injectable,
610
+ args: [{ providedIn: DaffToastModule }]
611
+ }], ctorParameters: () => [{ type: i1$2.Overlay }, { type: undefined, decorators: [{
612
+ type: Inject,
613
+ args: [DAFF_TOAST_OPTIONS]
614
+ }] }, { type: DaffToastService, decorators: [{
615
+ type: Optional
616
+ }, {
617
+ type: SkipSelf
618
+ }] }, { type: i1.BreakpointObserver }, { type: DaffToastPositionService }, { type: i2.DaffFocusStackService }] });
619
+
620
+ /**
621
+ * Generated bundle index. Do not edit.
622
+ */
623
+
624
+ export { DAFF_TOAST_OPTIONS, DaffToastActionsDirective, DaffToastComponent, DaffToastMessageDirective, DaffToastModule, DaffToastPositionService, DaffToastService, DaffToastTitleDirective, provideDaffToastOptions };
625
+ //# sourceMappingURL=daffodil-design-toast.mjs.map