@avoraui/av-notifications 0.0.2
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.
- package/README.md +502 -0
- package/av-notifications-0.0.1.tgz +0 -0
- package/avoraui-av-notifications-0.0.2.tgz +0 -0
- package/fesm2022/av-notifications.mjs +690 -0
- package/fesm2022/av-notifications.mjs.map +1 -0
- package/fesm2022/avoraui-av-notifications.mjs +690 -0
- package/fesm2022/avoraui-av-notifications.mjs.map +1 -0
- package/index.d.ts +44 -0
- package/package.json +43 -0
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Inject, Component, Injectable, NgModule } from '@angular/core';
|
|
3
|
+
import { CommonModule } from '@angular/common';
|
|
4
|
+
import * as i1 from '@angular/material/dialog';
|
|
5
|
+
import { MAT_DIALOG_DATA, MatDialogContent } from '@angular/material/dialog';
|
|
6
|
+
import { trigger, transition, style, animate } from '@angular/animations';
|
|
7
|
+
import { MatIcon } from '@angular/material/icon';
|
|
8
|
+
import { MatIconButton } from '@angular/material/button';
|
|
9
|
+
|
|
10
|
+
class AvFailedNotification {
|
|
11
|
+
config;
|
|
12
|
+
dialogRef;
|
|
13
|
+
autoCloseTimer;
|
|
14
|
+
currentTheme = 'light';
|
|
15
|
+
constructor(config, dialogRef) {
|
|
16
|
+
this.config = config;
|
|
17
|
+
this.dialogRef = dialogRef;
|
|
18
|
+
// Set default values
|
|
19
|
+
this.config = {
|
|
20
|
+
position: 'top',
|
|
21
|
+
duration: 5000,
|
|
22
|
+
animationDuration: 300,
|
|
23
|
+
showCloseButton: true,
|
|
24
|
+
autoClose: true,
|
|
25
|
+
theme: 'auto',
|
|
26
|
+
...config
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
ngOnInit() {
|
|
30
|
+
// Determine and set theme
|
|
31
|
+
this.setTheme();
|
|
32
|
+
// Setup auto close
|
|
33
|
+
if (this.config.autoClose && this.config.duration) {
|
|
34
|
+
this.autoCloseTimer = window.setTimeout(() => {
|
|
35
|
+
this.close();
|
|
36
|
+
}, this.config.duration);
|
|
37
|
+
}
|
|
38
|
+
// Setup animation parameters based on position
|
|
39
|
+
this.setupAnimationParams();
|
|
40
|
+
}
|
|
41
|
+
ngOnDestroy() {
|
|
42
|
+
if (this.autoCloseTimer) {
|
|
43
|
+
clearTimeout(this.autoCloseTimer);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
close() {
|
|
47
|
+
this.dialogRef.close();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get all CSS classes for the notification
|
|
51
|
+
*/
|
|
52
|
+
getNotificationClasses() {
|
|
53
|
+
const classes = [
|
|
54
|
+
`position-${this.config.position}`,
|
|
55
|
+
`theme-${this.currentTheme}`
|
|
56
|
+
];
|
|
57
|
+
return classes.join(' ');
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Determine and set the current theme
|
|
61
|
+
*/
|
|
62
|
+
setTheme() {
|
|
63
|
+
switch (this.config.theme) {
|
|
64
|
+
case 'light':
|
|
65
|
+
this.currentTheme = 'light';
|
|
66
|
+
break;
|
|
67
|
+
case 'dark':
|
|
68
|
+
this.currentTheme = 'dark';
|
|
69
|
+
break;
|
|
70
|
+
case 'auto':
|
|
71
|
+
default:
|
|
72
|
+
// Detect system preference
|
|
73
|
+
this.currentTheme = this.detectSystemTheme();
|
|
74
|
+
// Listen for system theme changes
|
|
75
|
+
this.listenForSystemThemeChanges();
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Detect system theme preference
|
|
81
|
+
*/
|
|
82
|
+
detectSystemTheme() {
|
|
83
|
+
if (typeof window !== 'undefined' && window.matchMedia) {
|
|
84
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
85
|
+
}
|
|
86
|
+
return 'light'; // fallback
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Listen for system theme changes when theme is set to 'auto'
|
|
90
|
+
*/
|
|
91
|
+
listenForSystemThemeChanges() {
|
|
92
|
+
if (typeof window !== 'undefined' && window.matchMedia) {
|
|
93
|
+
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
94
|
+
const handleThemeChange = (e) => {
|
|
95
|
+
if (this.config.theme === 'auto') {
|
|
96
|
+
this.currentTheme = e.matches ? 'dark' : 'light';
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
// Modern browsers
|
|
100
|
+
if (mediaQuery.addEventListener) {
|
|
101
|
+
mediaQuery.addEventListener('change', handleThemeChange);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// Fallback for older browsers
|
|
105
|
+
mediaQuery.addListener(handleThemeChange);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
setupAnimationParams() {
|
|
110
|
+
const position = this.config.position || 'top';
|
|
111
|
+
const duration = this.config.animationDuration || 300;
|
|
112
|
+
let enterTransform = '';
|
|
113
|
+
let exitTransform = '';
|
|
114
|
+
switch (position) {
|
|
115
|
+
case 'top':
|
|
116
|
+
enterTransform = 'translateY(-100%)';
|
|
117
|
+
exitTransform = 'translateY(-100%)';
|
|
118
|
+
break;
|
|
119
|
+
case 'bottom':
|
|
120
|
+
enterTransform = 'translateY(100%)';
|
|
121
|
+
exitTransform = 'translateY(100%)';
|
|
122
|
+
break;
|
|
123
|
+
case 'left':
|
|
124
|
+
enterTransform = 'translateX(-100%)';
|
|
125
|
+
exitTransform = 'translateX(-100%)';
|
|
126
|
+
break;
|
|
127
|
+
case 'right':
|
|
128
|
+
enterTransform = 'translateX(100%)';
|
|
129
|
+
exitTransform = 'translateX(100%)';
|
|
130
|
+
break;
|
|
131
|
+
case 'top-left':
|
|
132
|
+
enterTransform = 'translate(-100%, -100%)';
|
|
133
|
+
exitTransform = 'translate(-100%, -100%)';
|
|
134
|
+
break;
|
|
135
|
+
case 'top-right':
|
|
136
|
+
enterTransform = 'translate(100%, -100%)';
|
|
137
|
+
exitTransform = 'translate(100%, -100%)';
|
|
138
|
+
break;
|
|
139
|
+
case 'bottom-left':
|
|
140
|
+
enterTransform = 'translate(-100%, 100%)';
|
|
141
|
+
exitTransform = 'translate(-100%, 100%)';
|
|
142
|
+
break;
|
|
143
|
+
case 'bottom-right':
|
|
144
|
+
enterTransform = 'translate(100%, 100%)';
|
|
145
|
+
exitTransform = 'translate(100%, 100%)';
|
|
146
|
+
break;
|
|
147
|
+
default:
|
|
148
|
+
enterTransform = 'scale(0.8)';
|
|
149
|
+
exitTransform = 'scale(0.8)';
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: AvFailedNotification, deps: [{ token: MAT_DIALOG_DATA }, { token: i1.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
153
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.2", type: AvFailedNotification, isStandalone: true, selector: "av-failed-notification", ngImport: i0, template: "<div mat-dialog-content\r\n class=\"notification-box failed-box\"\r\n [class]=\"getNotificationClasses()\"\r\n [@notificationAnimation]>\r\n\r\n <div class=\"notification-content\">\r\n <mat-icon class=\"notification-icon\">error</mat-icon>\r\n <span class=\"message\">{{ config.message }}</span>\r\n </div>\r\n\r\n @if (config.showCloseButton) {\r\n <button mat-icon-button class=\"close-button\" (click)=\"close()\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n }\r\n</div>\r\n", styles: [":host{display:block!important}.notification-box{display:flex;flex-direction:row;justify-content:space-between;align-items:center;min-height:3rem;min-width:300px;max-width:500px;border-radius:15px;padding:16px 20px;box-shadow:0 8px 32px #0000001f;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);position:relative;overflow:hidden;transition:all .3s ease}.notification-content{display:flex;align-items:center;gap:12px;flex:1}.notification-icon{font-size:20px!important;width:20px!important;height:20px!important;flex-shrink:0}.message{font-size:14px;font-weight:500;line-height:1.4;word-break:break-word}.close-button{flex-shrink:0;width:32px!important;height:32px!important;margin-left:8px;opacity:.7;transition:all .2s ease;border-radius:50%}.close-button:hover{opacity:1}.close-button mat-icon{display:flex;align-items:center;justify-content:center;font-size:18px!important;width:18px!important;height:18px!important}.position-top,.position-top-left,.position-top-right{box-shadow:0 10px 25px #00000026}.position-bottom,.position-bottom-left,.position-bottom-right{box-shadow:0 -10px 25px #00000026}.position-left{box-shadow:10px 0 25px #00000026}.position-right{box-shadow:-10px 0 25px #00000026}.failed-box.theme-light{background:linear-gradient(135deg,#fef2f2,#fee2e2);color:#dc2626;border:1px solid rgba(220,38,38,.3)}.failed-box.theme-light .close-button{background-color:#dc262626;color:#dc2626}.failed-box.theme-light .close-button:hover{background-color:#dc262640;color:#b91c1c}.failed-box.theme-light .notification-icon{color:#dc2626}.failed-box.theme-dark{background:linear-gradient(135deg,#450a0a,#7f1d1d);color:#fca5a5;border:1px solid rgba(252,165,165,.3);box-shadow:0 8px 32px #0006}.failed-box.theme-dark .close-button{background-color:#fca5a526;color:#fca5a5}.failed-box.theme-dark .close-button:hover{background-color:#fca5a540;color:#fbbf24}.failed-box.theme-dark .notification-icon,.failed-box.theme-dark .message{color:#fca5a5}@media (max-width: 768px){.notification-box{min-width:280px;max-width:calc(100vw - 40px);margin:0 20px}.message{font-size:13px}}>>> .notification-dialog .mat-mdc-dialog-container{background:transparent!important;box-shadow:none!important;padding:0!important}>>> .notification-dialog .mat-mdc-dialog-surface{background:transparent!important;box-shadow:none!important;padding:0!important}>>> .mdc-dialog--open .mat-mdc-dialog-surface{border-radius:15px!important}>>> .mdc-dialog--closing .mat-mdc-dialog-surface{border-radius:15px!important}.notification-box{transition:background .3s ease,color .3s ease,border-color .3s ease,box-shadow .3s ease}.close-button{transition:background-color .2s ease,color .2s ease,opacity .2s ease}.notification-icon,.message{transition:color .3s ease}\n"], dependencies: [{ kind: "directive", type: MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }], animations: [
|
|
154
|
+
trigger('notificationAnimation', [
|
|
155
|
+
transition(':enter', [
|
|
156
|
+
style({ transform: '{{ enterTransform }}', opacity: 0 }),
|
|
157
|
+
animate('{{ duration }}ms {{ easing }}', style({ transform: 'translate(0, 0)', opacity: 1 }))
|
|
158
|
+
], { params: { enterTransform: 'translateY(-100%)', duration: 300, easing: 'ease-out' } }),
|
|
159
|
+
transition(':leave', [
|
|
160
|
+
animate('{{ duration }}ms {{ easing }}', style({ transform: '{{ exitTransform }}', opacity: 0 }))
|
|
161
|
+
], { params: { exitTransform: 'translateY(-100%)', duration: 250, easing: 'ease-in' } })
|
|
162
|
+
])
|
|
163
|
+
] });
|
|
164
|
+
}
|
|
165
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: AvFailedNotification, decorators: [{
|
|
166
|
+
type: Component,
|
|
167
|
+
args: [{ selector: 'av-failed-notification', imports: [
|
|
168
|
+
MatDialogContent,
|
|
169
|
+
MatIcon,
|
|
170
|
+
MatIconButton
|
|
171
|
+
], standalone: true, animations: [
|
|
172
|
+
trigger('notificationAnimation', [
|
|
173
|
+
transition(':enter', [
|
|
174
|
+
style({ transform: '{{ enterTransform }}', opacity: 0 }),
|
|
175
|
+
animate('{{ duration }}ms {{ easing }}', style({ transform: 'translate(0, 0)', opacity: 1 }))
|
|
176
|
+
], { params: { enterTransform: 'translateY(-100%)', duration: 300, easing: 'ease-out' } }),
|
|
177
|
+
transition(':leave', [
|
|
178
|
+
animate('{{ duration }}ms {{ easing }}', style({ transform: '{{ exitTransform }}', opacity: 0 }))
|
|
179
|
+
], { params: { exitTransform: 'translateY(-100%)', duration: 250, easing: 'ease-in' } })
|
|
180
|
+
])
|
|
181
|
+
], template: "<div mat-dialog-content\r\n class=\"notification-box failed-box\"\r\n [class]=\"getNotificationClasses()\"\r\n [@notificationAnimation]>\r\n\r\n <div class=\"notification-content\">\r\n <mat-icon class=\"notification-icon\">error</mat-icon>\r\n <span class=\"message\">{{ config.message }}</span>\r\n </div>\r\n\r\n @if (config.showCloseButton) {\r\n <button mat-icon-button class=\"close-button\" (click)=\"close()\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n }\r\n</div>\r\n", styles: [":host{display:block!important}.notification-box{display:flex;flex-direction:row;justify-content:space-between;align-items:center;min-height:3rem;min-width:300px;max-width:500px;border-radius:15px;padding:16px 20px;box-shadow:0 8px 32px #0000001f;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);position:relative;overflow:hidden;transition:all .3s ease}.notification-content{display:flex;align-items:center;gap:12px;flex:1}.notification-icon{font-size:20px!important;width:20px!important;height:20px!important;flex-shrink:0}.message{font-size:14px;font-weight:500;line-height:1.4;word-break:break-word}.close-button{flex-shrink:0;width:32px!important;height:32px!important;margin-left:8px;opacity:.7;transition:all .2s ease;border-radius:50%}.close-button:hover{opacity:1}.close-button mat-icon{display:flex;align-items:center;justify-content:center;font-size:18px!important;width:18px!important;height:18px!important}.position-top,.position-top-left,.position-top-right{box-shadow:0 10px 25px #00000026}.position-bottom,.position-bottom-left,.position-bottom-right{box-shadow:0 -10px 25px #00000026}.position-left{box-shadow:10px 0 25px #00000026}.position-right{box-shadow:-10px 0 25px #00000026}.failed-box.theme-light{background:linear-gradient(135deg,#fef2f2,#fee2e2);color:#dc2626;border:1px solid rgba(220,38,38,.3)}.failed-box.theme-light .close-button{background-color:#dc262626;color:#dc2626}.failed-box.theme-light .close-button:hover{background-color:#dc262640;color:#b91c1c}.failed-box.theme-light .notification-icon{color:#dc2626}.failed-box.theme-dark{background:linear-gradient(135deg,#450a0a,#7f1d1d);color:#fca5a5;border:1px solid rgba(252,165,165,.3);box-shadow:0 8px 32px #0006}.failed-box.theme-dark .close-button{background-color:#fca5a526;color:#fca5a5}.failed-box.theme-dark .close-button:hover{background-color:#fca5a540;color:#fbbf24}.failed-box.theme-dark .notification-icon,.failed-box.theme-dark .message{color:#fca5a5}@media (max-width: 768px){.notification-box{min-width:280px;max-width:calc(100vw - 40px);margin:0 20px}.message{font-size:13px}}>>> .notification-dialog .mat-mdc-dialog-container{background:transparent!important;box-shadow:none!important;padding:0!important}>>> .notification-dialog .mat-mdc-dialog-surface{background:transparent!important;box-shadow:none!important;padding:0!important}>>> .mdc-dialog--open .mat-mdc-dialog-surface{border-radius:15px!important}>>> .mdc-dialog--closing .mat-mdc-dialog-surface{border-radius:15px!important}.notification-box{transition:background .3s ease,color .3s ease,border-color .3s ease,box-shadow .3s ease}.close-button{transition:background-color .2s ease,color .2s ease,opacity .2s ease}.notification-icon,.message{transition:color .3s ease}\n"] }]
|
|
182
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
183
|
+
type: Inject,
|
|
184
|
+
args: [MAT_DIALOG_DATA]
|
|
185
|
+
}] }, { type: i1.MatDialogRef }] });
|
|
186
|
+
|
|
187
|
+
const DEFAULT_NOTIFICATION_CONFIG = {
|
|
188
|
+
position: 'top',
|
|
189
|
+
duration: 5000,
|
|
190
|
+
animationDuration: 300,
|
|
191
|
+
showCloseButton: true,
|
|
192
|
+
autoClose: true,
|
|
193
|
+
theme: 'auto'
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
class AvSuccessNotification {
|
|
197
|
+
config;
|
|
198
|
+
dialogRef;
|
|
199
|
+
autoCloseTimer;
|
|
200
|
+
currentTheme = 'light';
|
|
201
|
+
constructor(config, dialogRef) {
|
|
202
|
+
this.config = config;
|
|
203
|
+
this.dialogRef = dialogRef;
|
|
204
|
+
// Set default values
|
|
205
|
+
this.config = {
|
|
206
|
+
position: 'top',
|
|
207
|
+
duration: 5000,
|
|
208
|
+
animationDuration: 300,
|
|
209
|
+
showCloseButton: true,
|
|
210
|
+
autoClose: true,
|
|
211
|
+
theme: 'auto',
|
|
212
|
+
...config
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
ngOnInit() {
|
|
216
|
+
// Determine and set theme
|
|
217
|
+
this.setTheme();
|
|
218
|
+
// Setup auto close
|
|
219
|
+
if (this.config.autoClose && this.config.duration) {
|
|
220
|
+
this.autoCloseTimer = window.setTimeout(() => {
|
|
221
|
+
this.close();
|
|
222
|
+
}, this.config.duration);
|
|
223
|
+
}
|
|
224
|
+
// Setup animation parameters based on position
|
|
225
|
+
this.setupAnimationParams();
|
|
226
|
+
}
|
|
227
|
+
ngOnDestroy() {
|
|
228
|
+
if (this.autoCloseTimer) {
|
|
229
|
+
clearTimeout(this.autoCloseTimer);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
close() {
|
|
233
|
+
this.dialogRef.close();
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Get all CSS classes for the notification
|
|
237
|
+
*/
|
|
238
|
+
getNotificationClasses() {
|
|
239
|
+
const classes = [
|
|
240
|
+
`position-${this.config.position}`,
|
|
241
|
+
`theme-${this.currentTheme}`
|
|
242
|
+
];
|
|
243
|
+
return classes.join(' ');
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Determine and set the current theme
|
|
247
|
+
*/
|
|
248
|
+
setTheme() {
|
|
249
|
+
switch (this.config.theme) {
|
|
250
|
+
case 'light':
|
|
251
|
+
this.currentTheme = 'light';
|
|
252
|
+
break;
|
|
253
|
+
case 'dark':
|
|
254
|
+
this.currentTheme = 'dark';
|
|
255
|
+
break;
|
|
256
|
+
case 'auto':
|
|
257
|
+
default:
|
|
258
|
+
// Detect system preference
|
|
259
|
+
this.currentTheme = this.detectSystemTheme();
|
|
260
|
+
// Listen for system theme changes
|
|
261
|
+
this.listenForSystemThemeChanges();
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Detect system theme preference
|
|
267
|
+
*/
|
|
268
|
+
detectSystemTheme() {
|
|
269
|
+
if (typeof window !== 'undefined' && window.matchMedia) {
|
|
270
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
271
|
+
}
|
|
272
|
+
return 'light'; // fallback
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Listen for system theme changes when theme is set to 'auto'
|
|
276
|
+
*/
|
|
277
|
+
listenForSystemThemeChanges() {
|
|
278
|
+
if (typeof window !== 'undefined' && window.matchMedia) {
|
|
279
|
+
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
280
|
+
const handleThemeChange = (e) => {
|
|
281
|
+
if (this.config.theme === 'auto') {
|
|
282
|
+
this.currentTheme = e.matches ? 'dark' : 'light';
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
// Modern browsers
|
|
286
|
+
if (mediaQuery.addEventListener) {
|
|
287
|
+
mediaQuery.addEventListener('change', handleThemeChange);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
// Fallback for older browsers
|
|
291
|
+
mediaQuery.addListener(handleThemeChange);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
setupAnimationParams() {
|
|
296
|
+
const position = this.config.position || 'top';
|
|
297
|
+
const duration = this.config.animationDuration || 300;
|
|
298
|
+
let enterTransform = '';
|
|
299
|
+
let exitTransform = '';
|
|
300
|
+
switch (position) {
|
|
301
|
+
case 'top':
|
|
302
|
+
enterTransform = 'translateY(-100%)';
|
|
303
|
+
exitTransform = 'translateY(-100%)';
|
|
304
|
+
break;
|
|
305
|
+
case 'bottom':
|
|
306
|
+
enterTransform = 'translateY(100%)';
|
|
307
|
+
exitTransform = 'translateY(100%)';
|
|
308
|
+
break;
|
|
309
|
+
case 'left':
|
|
310
|
+
enterTransform = 'translateX(-100%)';
|
|
311
|
+
exitTransform = 'translateX(-100%)';
|
|
312
|
+
break;
|
|
313
|
+
case 'right':
|
|
314
|
+
enterTransform = 'translateX(100%)';
|
|
315
|
+
exitTransform = 'translateX(100%)';
|
|
316
|
+
break;
|
|
317
|
+
case 'top-left':
|
|
318
|
+
enterTransform = 'translate(-100%, -100%)';
|
|
319
|
+
exitTransform = 'translate(-100%, -100%)';
|
|
320
|
+
break;
|
|
321
|
+
case 'top-right':
|
|
322
|
+
enterTransform = 'translate(100%, -100%)';
|
|
323
|
+
exitTransform = 'translate(100%, -100%)';
|
|
324
|
+
break;
|
|
325
|
+
case 'bottom-left':
|
|
326
|
+
enterTransform = 'translate(-100%, 100%)';
|
|
327
|
+
exitTransform = 'translate(-100%, 100%)';
|
|
328
|
+
break;
|
|
329
|
+
case 'bottom-right':
|
|
330
|
+
enterTransform = 'translate(100%, 100%)';
|
|
331
|
+
exitTransform = 'translate(100%, 100%)';
|
|
332
|
+
break;
|
|
333
|
+
default:
|
|
334
|
+
enterTransform = 'scale(0.8)';
|
|
335
|
+
exitTransform = 'scale(0.8)';
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: AvSuccessNotification, deps: [{ token: MAT_DIALOG_DATA }, { token: i1.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
339
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.2", type: AvSuccessNotification, isStandalone: true, selector: "av-success-notification", ngImport: i0, template: "<div mat-dialog-content\r\n class=\"notification-box success-box\"\r\n [class]=\"getNotificationClasses()\"\r\n [@notificationAnimation]>\r\n\r\n <div class=\"notification-content\">\r\n <mat-icon class=\"notification-icon\">check_circle</mat-icon>\r\n <span class=\"message\">{{ config.message }}</span>\r\n </div>\r\n\r\n @if (config.showCloseButton) {\r\n <button mat-icon-button class=\"close-button\" (click)=\"close()\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n }\r\n</div>\r\n", styles: [":host{display:block!important}.notification-box{display:flex;flex-direction:row;justify-content:space-between;align-items:center;min-height:3rem;min-width:300px;max-width:500px;border-radius:15px;padding:16px 20px;box-shadow:0 8px 32px #0000001f;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);position:relative;overflow:hidden;transition:all .3s ease}.notification-content{display:flex;align-items:center;gap:12px;flex:1}.notification-icon{font-size:20px!important;width:20px!important;height:20px!important;flex-shrink:0}.message{font-size:14px;font-weight:500;line-height:1.4;word-break:break-word}.close-button{flex-shrink:0;width:32px!important;height:32px!important;margin-left:8px;opacity:.7;transition:all .2s ease;border-radius:50%}.close-button:hover{opacity:1}.close-button mat-icon{display:flex;align-items:center;justify-content:center;font-size:18px!important;width:18px!important;height:18px!important}.position-top,.position-top-left,.position-top-right{box-shadow:0 10px 25px #00000026}.position-bottom,.position-bottom-left,.position-bottom-right{box-shadow:0 -10px 25px #00000026}.position-left{box-shadow:10px 0 25px #00000026}.position-right{box-shadow:-10px 0 25px #00000026}.success-box.theme-light{background:linear-gradient(135deg,#f0fdf4,#dcfce7);color:#16a34a;border:1px solid rgba(22,163,74,.3)}.success-box.theme-light .close-button{background-color:#16a34a26;color:#16a34a}.success-box.theme-light .close-button:hover{background-color:#16a34a40;color:#15803d}.success-box.theme-dark{background:linear-gradient(135deg,#052e16,#166534);color:#86efac;border:1px solid rgba(134,239,172,.3)}.success-box.theme-dark .close-button{background-color:#86efac26;color:#86efac}.success-box.theme-dark .close-button:hover{background-color:#86efac40;color:#bbf7d0}@media (max-width: 768px){.notification-box{min-width:280px;max-width:calc(100vw - 40px);margin:0 20px}.message{font-size:13px}}>>> .notification-dialog .mat-mdc-dialog-container{background:transparent!important;box-shadow:none!important;padding:0!important}>>> .notification-dialog .mat-mdc-dialog-surface{background:transparent!important;box-shadow:none!important;padding:0!important}>>> .mdc-dialog--open .mat-mdc-dialog-surface{border-radius:15px!important}>>> .mdc-dialog--closing .mat-mdc-dialog-surface{border-radius:15px!important}.notification-box{transition:background .3s ease,color .3s ease,border-color .3s ease,box-shadow .3s ease}.close-button{transition:background-color .2s ease,color .2s ease,opacity .2s ease}.notification-icon,.message{transition:color .3s ease}\n"], dependencies: [{ kind: "directive", type: MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }], animations: [
|
|
340
|
+
trigger('notificationAnimation', [
|
|
341
|
+
transition(':enter', [
|
|
342
|
+
style({ transform: '{{ enterTransform }}', opacity: 0 }),
|
|
343
|
+
animate('{{ duration }}ms {{ easing }}', style({ transform: 'translate(0, 0)', opacity: 1 }))
|
|
344
|
+
], { params: { enterTransform: 'translateY(-100%)', duration: 300, easing: 'ease-out' } }),
|
|
345
|
+
transition(':leave', [
|
|
346
|
+
animate('{{ duration }}ms {{ easing }}', style({ transform: '{{ exitTransform }}', opacity: 0 }))
|
|
347
|
+
], { params: { exitTransform: 'translateY(-100%)', duration: 250, easing: 'ease-in' } })
|
|
348
|
+
])
|
|
349
|
+
] });
|
|
350
|
+
}
|
|
351
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: AvSuccessNotification, decorators: [{
|
|
352
|
+
type: Component,
|
|
353
|
+
args: [{ selector: 'av-success-notification', imports: [
|
|
354
|
+
MatDialogContent,
|
|
355
|
+
MatIcon,
|
|
356
|
+
MatIconButton
|
|
357
|
+
], standalone: true, animations: [
|
|
358
|
+
trigger('notificationAnimation', [
|
|
359
|
+
transition(':enter', [
|
|
360
|
+
style({ transform: '{{ enterTransform }}', opacity: 0 }),
|
|
361
|
+
animate('{{ duration }}ms {{ easing }}', style({ transform: 'translate(0, 0)', opacity: 1 }))
|
|
362
|
+
], { params: { enterTransform: 'translateY(-100%)', duration: 300, easing: 'ease-out' } }),
|
|
363
|
+
transition(':leave', [
|
|
364
|
+
animate('{{ duration }}ms {{ easing }}', style({ transform: '{{ exitTransform }}', opacity: 0 }))
|
|
365
|
+
], { params: { exitTransform: 'translateY(-100%)', duration: 250, easing: 'ease-in' } })
|
|
366
|
+
])
|
|
367
|
+
], template: "<div mat-dialog-content\r\n class=\"notification-box success-box\"\r\n [class]=\"getNotificationClasses()\"\r\n [@notificationAnimation]>\r\n\r\n <div class=\"notification-content\">\r\n <mat-icon class=\"notification-icon\">check_circle</mat-icon>\r\n <span class=\"message\">{{ config.message }}</span>\r\n </div>\r\n\r\n @if (config.showCloseButton) {\r\n <button mat-icon-button class=\"close-button\" (click)=\"close()\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n }\r\n</div>\r\n", styles: [":host{display:block!important}.notification-box{display:flex;flex-direction:row;justify-content:space-between;align-items:center;min-height:3rem;min-width:300px;max-width:500px;border-radius:15px;padding:16px 20px;box-shadow:0 8px 32px #0000001f;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);position:relative;overflow:hidden;transition:all .3s ease}.notification-content{display:flex;align-items:center;gap:12px;flex:1}.notification-icon{font-size:20px!important;width:20px!important;height:20px!important;flex-shrink:0}.message{font-size:14px;font-weight:500;line-height:1.4;word-break:break-word}.close-button{flex-shrink:0;width:32px!important;height:32px!important;margin-left:8px;opacity:.7;transition:all .2s ease;border-radius:50%}.close-button:hover{opacity:1}.close-button mat-icon{display:flex;align-items:center;justify-content:center;font-size:18px!important;width:18px!important;height:18px!important}.position-top,.position-top-left,.position-top-right{box-shadow:0 10px 25px #00000026}.position-bottom,.position-bottom-left,.position-bottom-right{box-shadow:0 -10px 25px #00000026}.position-left{box-shadow:10px 0 25px #00000026}.position-right{box-shadow:-10px 0 25px #00000026}.success-box.theme-light{background:linear-gradient(135deg,#f0fdf4,#dcfce7);color:#16a34a;border:1px solid rgba(22,163,74,.3)}.success-box.theme-light .close-button{background-color:#16a34a26;color:#16a34a}.success-box.theme-light .close-button:hover{background-color:#16a34a40;color:#15803d}.success-box.theme-dark{background:linear-gradient(135deg,#052e16,#166534);color:#86efac;border:1px solid rgba(134,239,172,.3)}.success-box.theme-dark .close-button{background-color:#86efac26;color:#86efac}.success-box.theme-dark .close-button:hover{background-color:#86efac40;color:#bbf7d0}@media (max-width: 768px){.notification-box{min-width:280px;max-width:calc(100vw - 40px);margin:0 20px}.message{font-size:13px}}>>> .notification-dialog .mat-mdc-dialog-container{background:transparent!important;box-shadow:none!important;padding:0!important}>>> .notification-dialog .mat-mdc-dialog-surface{background:transparent!important;box-shadow:none!important;padding:0!important}>>> .mdc-dialog--open .mat-mdc-dialog-surface{border-radius:15px!important}>>> .mdc-dialog--closing .mat-mdc-dialog-surface{border-radius:15px!important}.notification-box{transition:background .3s ease,color .3s ease,border-color .3s ease,box-shadow .3s ease}.close-button{transition:background-color .2s ease,color .2s ease,opacity .2s ease}.notification-icon,.message{transition:color .3s ease}\n"] }]
|
|
368
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
369
|
+
type: Inject,
|
|
370
|
+
args: [MAT_DIALOG_DATA]
|
|
371
|
+
}] }, { type: i1.MatDialogRef }] });
|
|
372
|
+
|
|
373
|
+
class AvWarningNotification {
|
|
374
|
+
config;
|
|
375
|
+
dialogRef;
|
|
376
|
+
autoCloseTimer;
|
|
377
|
+
currentTheme = 'light';
|
|
378
|
+
constructor(config, dialogRef) {
|
|
379
|
+
this.config = config;
|
|
380
|
+
this.dialogRef = dialogRef;
|
|
381
|
+
// Set default values
|
|
382
|
+
this.config = {
|
|
383
|
+
position: 'top',
|
|
384
|
+
duration: 5000,
|
|
385
|
+
animationDuration: 300,
|
|
386
|
+
showCloseButton: true,
|
|
387
|
+
autoClose: true,
|
|
388
|
+
theme: 'auto',
|
|
389
|
+
...config
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
ngOnInit() {
|
|
393
|
+
// Determine and set theme
|
|
394
|
+
this.setTheme();
|
|
395
|
+
// Setup auto close
|
|
396
|
+
if (this.config.autoClose && this.config.duration) {
|
|
397
|
+
this.autoCloseTimer = window.setTimeout(() => {
|
|
398
|
+
this.close();
|
|
399
|
+
}, this.config.duration);
|
|
400
|
+
}
|
|
401
|
+
// Setup animation parameters based on position
|
|
402
|
+
this.setupAnimationParams();
|
|
403
|
+
}
|
|
404
|
+
ngOnDestroy() {
|
|
405
|
+
if (this.autoCloseTimer) {
|
|
406
|
+
clearTimeout(this.autoCloseTimer);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
close() {
|
|
410
|
+
this.dialogRef.close();
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Get all CSS classes for the notification
|
|
414
|
+
*/
|
|
415
|
+
getNotificationClasses() {
|
|
416
|
+
const classes = [
|
|
417
|
+
`position-${this.config.position}`,
|
|
418
|
+
`theme-${this.currentTheme}`
|
|
419
|
+
];
|
|
420
|
+
return classes.join(' ');
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Determine and set the current theme
|
|
424
|
+
*/
|
|
425
|
+
setTheme() {
|
|
426
|
+
switch (this.config.theme) {
|
|
427
|
+
case 'light':
|
|
428
|
+
this.currentTheme = 'light';
|
|
429
|
+
break;
|
|
430
|
+
case 'dark':
|
|
431
|
+
this.currentTheme = 'dark';
|
|
432
|
+
break;
|
|
433
|
+
case 'auto':
|
|
434
|
+
default:
|
|
435
|
+
// Detect system preference
|
|
436
|
+
this.currentTheme = this.detectSystemTheme();
|
|
437
|
+
// Listen for system theme changes
|
|
438
|
+
this.listenForSystemThemeChanges();
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Detect system theme preference
|
|
444
|
+
*/
|
|
445
|
+
detectSystemTheme() {
|
|
446
|
+
if (typeof window !== 'undefined' && window.matchMedia) {
|
|
447
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
448
|
+
}
|
|
449
|
+
return 'light'; // fallback
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Listen for system theme changes when theme is set to 'auto'
|
|
453
|
+
*/
|
|
454
|
+
listenForSystemThemeChanges() {
|
|
455
|
+
if (typeof window !== 'undefined' && window.matchMedia) {
|
|
456
|
+
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
457
|
+
const handleThemeChange = (e) => {
|
|
458
|
+
if (this.config.theme === 'auto') {
|
|
459
|
+
this.currentTheme = e.matches ? 'dark' : 'light';
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
// Modern browsers
|
|
463
|
+
if (mediaQuery.addEventListener) {
|
|
464
|
+
mediaQuery.addEventListener('change', handleThemeChange);
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
// Fallback for older browsers
|
|
468
|
+
mediaQuery.addListener(handleThemeChange);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
setupAnimationParams() {
|
|
473
|
+
const position = this.config.position || 'top';
|
|
474
|
+
const duration = this.config.animationDuration || 300;
|
|
475
|
+
let enterTransform = '';
|
|
476
|
+
let exitTransform = '';
|
|
477
|
+
switch (position) {
|
|
478
|
+
case 'top':
|
|
479
|
+
enterTransform = 'translateY(-100%)';
|
|
480
|
+
exitTransform = 'translateY(-100%)';
|
|
481
|
+
break;
|
|
482
|
+
case 'bottom':
|
|
483
|
+
enterTransform = 'translateY(100%)';
|
|
484
|
+
exitTransform = 'translateY(100%)';
|
|
485
|
+
break;
|
|
486
|
+
case 'left':
|
|
487
|
+
enterTransform = 'translateX(-100%)';
|
|
488
|
+
exitTransform = 'translateX(-100%)';
|
|
489
|
+
break;
|
|
490
|
+
case 'right':
|
|
491
|
+
enterTransform = 'translateX(100%)';
|
|
492
|
+
exitTransform = 'translateX(100%)';
|
|
493
|
+
break;
|
|
494
|
+
case 'top-left':
|
|
495
|
+
enterTransform = 'translate(-100%, -100%)';
|
|
496
|
+
exitTransform = 'translate(-100%, -100%)';
|
|
497
|
+
break;
|
|
498
|
+
case 'top-right':
|
|
499
|
+
enterTransform = 'translate(100%, -100%)';
|
|
500
|
+
exitTransform = 'translate(100%, -100%)';
|
|
501
|
+
break;
|
|
502
|
+
case 'bottom-left':
|
|
503
|
+
enterTransform = 'translate(-100%, 100%)';
|
|
504
|
+
exitTransform = 'translate(-100%, 100%)';
|
|
505
|
+
break;
|
|
506
|
+
case 'bottom-right':
|
|
507
|
+
enterTransform = 'translate(100%, 100%)';
|
|
508
|
+
exitTransform = 'translate(100%, 100%)';
|
|
509
|
+
break;
|
|
510
|
+
default:
|
|
511
|
+
enterTransform = 'scale(0.8)';
|
|
512
|
+
exitTransform = 'scale(0.8)';
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: AvWarningNotification, deps: [{ token: MAT_DIALOG_DATA }, { token: i1.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
516
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.2", type: AvWarningNotification, isStandalone: true, selector: "av-warning-notification", ngImport: i0, template: "<div mat-dialog-content\r\n class=\"notification-box warning-box\"\r\n [class]=\"getNotificationClasses()\"\r\n [@notificationAnimation]>\r\n\r\n <div class=\"notification-content\">\r\n <mat-icon class=\"notification-icon\">warning</mat-icon>\r\n <span class=\"message\">{{ config.message }}</span>\r\n </div>\r\n\r\n @if (config.showCloseButton) {\r\n <button mat-icon-button class=\"close-button\" (click)=\"close()\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n }\r\n</div>\r\n", styles: [":host{display:block!important}.notification-box{display:flex;flex-direction:row;justify-content:space-between;align-items:center;min-height:3rem;min-width:300px;max-width:500px;border-radius:15px;padding:16px 20px;box-shadow:0 8px 32px #0000001f;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);position:relative;overflow:hidden;transition:all .3s ease}.notification-content{display:flex;align-items:center;gap:12px;flex:1}.notification-icon{font-size:20px!important;width:20px!important;height:20px!important;flex-shrink:0}.message{font-size:14px;font-weight:500;line-height:1.4;word-break:break-word}.close-button{flex-shrink:0;width:32px!important;height:32px!important;margin-left:8px;opacity:.7;transition:all .2s ease;border-radius:50%}.close-button:hover{opacity:1}.close-button mat-icon{display:flex;align-items:center;justify-content:center;font-size:18px!important;width:18px!important;height:18px!important}.position-top,.position-top-left,.position-top-right{box-shadow:0 10px 25px #00000026}.position-bottom,.position-bottom-left,.position-bottom-right{box-shadow:0 -10px 25px #00000026}.position-left{box-shadow:10px 0 25px #00000026}.position-right{box-shadow:-10px 0 25px #00000026}.warning-box.theme-light{background:linear-gradient(135deg,#fffbeb,#fef3c7);color:#d97706;border:1px solid rgba(217,119,6,.3)}.warning-box.theme-light .close-button{background-color:#d9770626;color:#d97706}.warning-box.theme-light .close-button:hover{background-color:#d9770640;color:#c2410c}.warning-box.theme-dark{background:linear-gradient(135deg,#451a03,#92400e);color:#fcd34d;border:1px solid rgba(252,211,77,.3)}.warning-box.theme-dark .close-button{background-color:#fcd34d26;color:#fcd34d}.warning-box.theme-dark .close-button:hover{background-color:#fcd34d40;color:#fde047}@media (max-width: 768px){.notification-box{min-width:280px;max-width:calc(100vw - 40px);margin:0 20px}.message{font-size:13px}}>>> .notification-dialog .mat-mdc-dialog-container{background:transparent!important;box-shadow:none!important;padding:0!important}>>> .notification-dialog .mat-mdc-dialog-surface{background:transparent!important;box-shadow:none!important;padding:0!important}>>> .mdc-dialog--open .mat-mdc-dialog-surface{border-radius:15px!important}>>> .mdc-dialog--closing .mat-mdc-dialog-surface{border-radius:15px!important}.notification-box{transition:background .3s ease,color .3s ease,border-color .3s ease,box-shadow .3s ease}.close-button{transition:background-color .2s ease,color .2s ease,opacity .2s ease}.notification-icon,.message{transition:color .3s ease}\n"], dependencies: [{ kind: "directive", type: MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }], animations: [
|
|
517
|
+
trigger('notificationAnimation', [
|
|
518
|
+
transition(':enter', [
|
|
519
|
+
style({ transform: '{{ enterTransform }}', opacity: 0 }),
|
|
520
|
+
animate('{{ duration }}ms {{ easing }}', style({ transform: 'translate(0, 0)', opacity: 1 }))
|
|
521
|
+
], { params: { enterTransform: 'translateY(-100%)', duration: 300, easing: 'ease-out' } }),
|
|
522
|
+
transition(':leave', [
|
|
523
|
+
animate('{{ duration }}ms {{ easing }}', style({ transform: '{{ exitTransform }}', opacity: 0 }))
|
|
524
|
+
], { params: { exitTransform: 'translateY(-100%)', duration: 250, easing: 'ease-in' } })
|
|
525
|
+
])
|
|
526
|
+
] });
|
|
527
|
+
}
|
|
528
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: AvWarningNotification, decorators: [{
|
|
529
|
+
type: Component,
|
|
530
|
+
args: [{ selector: 'av-warning-notification', imports: [
|
|
531
|
+
MatDialogContent,
|
|
532
|
+
MatIcon,
|
|
533
|
+
MatIconButton
|
|
534
|
+
], standalone: true, animations: [
|
|
535
|
+
trigger('notificationAnimation', [
|
|
536
|
+
transition(':enter', [
|
|
537
|
+
style({ transform: '{{ enterTransform }}', opacity: 0 }),
|
|
538
|
+
animate('{{ duration }}ms {{ easing }}', style({ transform: 'translate(0, 0)', opacity: 1 }))
|
|
539
|
+
], { params: { enterTransform: 'translateY(-100%)', duration: 300, easing: 'ease-out' } }),
|
|
540
|
+
transition(':leave', [
|
|
541
|
+
animate('{{ duration }}ms {{ easing }}', style({ transform: '{{ exitTransform }}', opacity: 0 }))
|
|
542
|
+
], { params: { exitTransform: 'translateY(-100%)', duration: 250, easing: 'ease-in' } })
|
|
543
|
+
])
|
|
544
|
+
], template: "<div mat-dialog-content\r\n class=\"notification-box warning-box\"\r\n [class]=\"getNotificationClasses()\"\r\n [@notificationAnimation]>\r\n\r\n <div class=\"notification-content\">\r\n <mat-icon class=\"notification-icon\">warning</mat-icon>\r\n <span class=\"message\">{{ config.message }}</span>\r\n </div>\r\n\r\n @if (config.showCloseButton) {\r\n <button mat-icon-button class=\"close-button\" (click)=\"close()\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n }\r\n</div>\r\n", styles: [":host{display:block!important}.notification-box{display:flex;flex-direction:row;justify-content:space-between;align-items:center;min-height:3rem;min-width:300px;max-width:500px;border-radius:15px;padding:16px 20px;box-shadow:0 8px 32px #0000001f;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);position:relative;overflow:hidden;transition:all .3s ease}.notification-content{display:flex;align-items:center;gap:12px;flex:1}.notification-icon{font-size:20px!important;width:20px!important;height:20px!important;flex-shrink:0}.message{font-size:14px;font-weight:500;line-height:1.4;word-break:break-word}.close-button{flex-shrink:0;width:32px!important;height:32px!important;margin-left:8px;opacity:.7;transition:all .2s ease;border-radius:50%}.close-button:hover{opacity:1}.close-button mat-icon{display:flex;align-items:center;justify-content:center;font-size:18px!important;width:18px!important;height:18px!important}.position-top,.position-top-left,.position-top-right{box-shadow:0 10px 25px #00000026}.position-bottom,.position-bottom-left,.position-bottom-right{box-shadow:0 -10px 25px #00000026}.position-left{box-shadow:10px 0 25px #00000026}.position-right{box-shadow:-10px 0 25px #00000026}.warning-box.theme-light{background:linear-gradient(135deg,#fffbeb,#fef3c7);color:#d97706;border:1px solid rgba(217,119,6,.3)}.warning-box.theme-light .close-button{background-color:#d9770626;color:#d97706}.warning-box.theme-light .close-button:hover{background-color:#d9770640;color:#c2410c}.warning-box.theme-dark{background:linear-gradient(135deg,#451a03,#92400e);color:#fcd34d;border:1px solid rgba(252,211,77,.3)}.warning-box.theme-dark .close-button{background-color:#fcd34d26;color:#fcd34d}.warning-box.theme-dark .close-button:hover{background-color:#fcd34d40;color:#fde047}@media (max-width: 768px){.notification-box{min-width:280px;max-width:calc(100vw - 40px);margin:0 20px}.message{font-size:13px}}>>> .notification-dialog .mat-mdc-dialog-container{background:transparent!important;box-shadow:none!important;padding:0!important}>>> .notification-dialog .mat-mdc-dialog-surface{background:transparent!important;box-shadow:none!important;padding:0!important}>>> .mdc-dialog--open .mat-mdc-dialog-surface{border-radius:15px!important}>>> .mdc-dialog--closing .mat-mdc-dialog-surface{border-radius:15px!important}.notification-box{transition:background .3s ease,color .3s ease,border-color .3s ease,box-shadow .3s ease}.close-button{transition:background-color .2s ease,color .2s ease,opacity .2s ease}.notification-icon,.message{transition:color .3s ease}\n"] }]
|
|
545
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
546
|
+
type: Inject,
|
|
547
|
+
args: [MAT_DIALOG_DATA]
|
|
548
|
+
}] }, { type: i1.MatDialogRef }] });
|
|
549
|
+
|
|
550
|
+
class AvNotificationService {
|
|
551
|
+
dialog;
|
|
552
|
+
activeNotifications = [];
|
|
553
|
+
globalConfig = DEFAULT_NOTIFICATION_CONFIG;
|
|
554
|
+
constructor(dialog) {
|
|
555
|
+
this.dialog = dialog;
|
|
556
|
+
}
|
|
557
|
+
show(config) {
|
|
558
|
+
const finalConfig = {
|
|
559
|
+
...this.globalConfig,
|
|
560
|
+
...config
|
|
561
|
+
};
|
|
562
|
+
const dialogConfig = {
|
|
563
|
+
data: finalConfig,
|
|
564
|
+
position: this.getDialogPosition(finalConfig.position),
|
|
565
|
+
hasBackdrop: false,
|
|
566
|
+
panelClass: [
|
|
567
|
+
'notification-dialog',
|
|
568
|
+
`notification-${finalConfig.position}`,
|
|
569
|
+
`notification-${finalConfig.type}`,
|
|
570
|
+
`notification-theme-${finalConfig.theme}`
|
|
571
|
+
],
|
|
572
|
+
autoFocus: false,
|
|
573
|
+
restoreFocus: false
|
|
574
|
+
};
|
|
575
|
+
// Select the appropriate component based on type
|
|
576
|
+
const component = this.getComponentByType(finalConfig.type);
|
|
577
|
+
const dialogRef = this.dialog.open(component, dialogConfig);
|
|
578
|
+
// Track active notifications
|
|
579
|
+
this.activeNotifications.push(dialogRef);
|
|
580
|
+
// Remove from tracking when closed
|
|
581
|
+
dialogRef.afterClosed().subscribe(() => {
|
|
582
|
+
const index = this.activeNotifications.indexOf(dialogRef);
|
|
583
|
+
if (index > -1) {
|
|
584
|
+
this.activeNotifications.splice(index, 1);
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
return dialogRef;
|
|
588
|
+
}
|
|
589
|
+
showFailure(message, options) {
|
|
590
|
+
return this.show({
|
|
591
|
+
message,
|
|
592
|
+
type: 'error',
|
|
593
|
+
...options
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
showSuccess(message, options) {
|
|
597
|
+
return this.show({
|
|
598
|
+
message,
|
|
599
|
+
type: 'success',
|
|
600
|
+
...options
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
showWarning(message, options) {
|
|
604
|
+
return this.show({
|
|
605
|
+
message,
|
|
606
|
+
type: 'warning',
|
|
607
|
+
...options
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
getComponentByType(type) {
|
|
611
|
+
const components = {
|
|
612
|
+
'error': AvFailedNotification,
|
|
613
|
+
'success': AvSuccessNotification,
|
|
614
|
+
'warning': AvWarningNotification,
|
|
615
|
+
};
|
|
616
|
+
return components[type] || AvFailedNotification;
|
|
617
|
+
}
|
|
618
|
+
getDialogPosition(position) {
|
|
619
|
+
const positions = {
|
|
620
|
+
'top': { top: '20px' },
|
|
621
|
+
'bottom': { bottom: '20px' },
|
|
622
|
+
'left': { left: '20px', top: '50%', transform: 'translateY(-50%)' },
|
|
623
|
+
'right': { right: '20px', top: '50%', transform: 'translateY(-50%)' },
|
|
624
|
+
'top-left': { top: '20px', left: '20px' },
|
|
625
|
+
'top-right': { top: '20px', right: '20px' },
|
|
626
|
+
'bottom-left': { bottom: '20px', left: '20px' },
|
|
627
|
+
'bottom-right': { bottom: '20px', right: '20px' },
|
|
628
|
+
'center': { top: '50%', left: '50%', transform: 'translate(-50%, -50%)' }
|
|
629
|
+
};
|
|
630
|
+
return positions[position] || positions['top'];
|
|
631
|
+
}
|
|
632
|
+
closeAll() {
|
|
633
|
+
this.activeNotifications.forEach(ref => ref.close());
|
|
634
|
+
this.activeNotifications = [];
|
|
635
|
+
}
|
|
636
|
+
closeByType(type) {
|
|
637
|
+
this.activeNotifications.forEach(ref => {
|
|
638
|
+
if (ref.componentInstance?.config?.type === type) {
|
|
639
|
+
ref.close();
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
getActiveCount() {
|
|
644
|
+
return this.activeNotifications.length;
|
|
645
|
+
}
|
|
646
|
+
hasActiveNotifications(type) {
|
|
647
|
+
if (!type) {
|
|
648
|
+
return this.activeNotifications.length > 0;
|
|
649
|
+
}
|
|
650
|
+
return this.activeNotifications.some(ref => ref.componentInstance?.config?.type === type);
|
|
651
|
+
}
|
|
652
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: AvNotificationService, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
653
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: AvNotificationService, providedIn: 'root' });
|
|
654
|
+
}
|
|
655
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: AvNotificationService, decorators: [{
|
|
656
|
+
type: Injectable,
|
|
657
|
+
args: [{
|
|
658
|
+
providedIn: 'root'
|
|
659
|
+
}]
|
|
660
|
+
}], ctorParameters: () => [{ type: i1.MatDialog }] });
|
|
661
|
+
|
|
662
|
+
class AvNotificationsModule {
|
|
663
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: AvNotificationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
664
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.2", ngImport: i0, type: AvNotificationsModule, imports: [CommonModule] });
|
|
665
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: AvNotificationsModule, providers: [
|
|
666
|
+
AvNotificationService
|
|
667
|
+
], imports: [CommonModule] });
|
|
668
|
+
}
|
|
669
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.2", ngImport: i0, type: AvNotificationsModule, decorators: [{
|
|
670
|
+
type: NgModule,
|
|
671
|
+
args: [{
|
|
672
|
+
imports: [
|
|
673
|
+
CommonModule,
|
|
674
|
+
],
|
|
675
|
+
providers: [
|
|
676
|
+
AvNotificationService
|
|
677
|
+
],
|
|
678
|
+
}]
|
|
679
|
+
}] });
|
|
680
|
+
|
|
681
|
+
/*
|
|
682
|
+
* Public API Surface of av-notifications
|
|
683
|
+
*/
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Generated bundle index. Do not edit.
|
|
687
|
+
*/
|
|
688
|
+
|
|
689
|
+
export { AvNotificationService, AvNotificationsModule };
|
|
690
|
+
//# sourceMappingURL=av-notifications.mjs.map
|