@acorex/components 21.0.1-next.2 → 21.0.1-next.3
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/action-sheet/index.d.ts +19 -41
- package/dialog/index.d.ts +14 -18
- package/dropdown/index.d.ts +4 -3
- package/fesm2022/acorex-components-action-sheet.mjs +93 -141
- package/fesm2022/acorex-components-action-sheet.mjs.map +1 -1
- package/fesm2022/acorex-components-conversation2.mjs +2 -2
- package/fesm2022/acorex-components-conversation2.mjs.map +1 -1
- package/fesm2022/acorex-components-dialog.mjs +45 -66
- package/fesm2022/acorex-components-dialog.mjs.map +1 -1
- package/fesm2022/acorex-components-dropdown.mjs +4 -0
- package/fesm2022/acorex-components-dropdown.mjs.map +1 -1
- package/fesm2022/acorex-components-grid-layout-builder.mjs +2 -2
- package/fesm2022/acorex-components-grid-layout-builder.mjs.map +1 -1
- package/fesm2022/acorex-components-loading-dialog.mjs +36 -73
- package/fesm2022/acorex-components-loading-dialog.mjs.map +1 -1
- package/fesm2022/acorex-components-menu.mjs +5 -26
- package/fesm2022/acorex-components-menu.mjs.map +1 -1
- package/fesm2022/{acorex-components-modal-acorex-components-modal-Bmoz9DL5.mjs → acorex-components-modal-acorex-components-modal-CXXcFToK.mjs} +3 -27
- package/fesm2022/acorex-components-modal-acorex-components-modal-CXXcFToK.mjs.map +1 -0
- package/fesm2022/{acorex-components-modal-modal-content.component-CSJU1vRi.mjs → acorex-components-modal-modal-content.component-B4rhHeEz.mjs} +2 -2
- package/fesm2022/{acorex-components-modal-modal-content.component-CSJU1vRi.mjs.map → acorex-components-modal-modal-content.component-B4rhHeEz.mjs.map} +1 -1
- package/fesm2022/acorex-components-modal.mjs +1 -1
- package/fesm2022/acorex-components-notification.mjs +257 -374
- package/fesm2022/acorex-components-notification.mjs.map +1 -1
- package/fesm2022/acorex-components-popover.mjs +175 -136
- package/fesm2022/acorex-components-popover.mjs.map +1 -1
- package/fesm2022/acorex-components-popup.mjs +105 -308
- package/fesm2022/acorex-components-popup.mjs.map +1 -1
- package/fesm2022/acorex-components-routing-progress.mjs +2 -2
- package/fesm2022/acorex-components-routing-progress.mjs.map +1 -1
- package/fesm2022/acorex-components-scheduler.mjs +1195 -136
- package/fesm2022/acorex-components-scheduler.mjs.map +1 -1
- package/fesm2022/acorex-components-toast.mjs +123 -231
- package/fesm2022/acorex-components-toast.mjs.map +1 -1
- package/fesm2022/acorex-components-tooltip.mjs +3 -2
- package/fesm2022/acorex-components-tooltip.mjs.map +1 -1
- package/loading-dialog/index.d.ts +15 -31
- package/menu/index.d.ts +0 -4
- package/modal/index.d.ts +0 -7
- package/notification/index.d.ts +32 -47
- package/package.json +7 -7
- package/popover/index.d.ts +27 -20
- package/popup/index.d.ts +27 -103
- package/scheduler/index.d.ts +281 -27
- package/toast/index.d.ts +18 -24
- package/tooltip/index.d.ts +2 -1
- package/fesm2022/acorex-components-modal-acorex-components-modal-Bmoz9DL5.mjs.map +0 -1
|
@@ -2,333 +2,13 @@ import { MXBaseComponent, AXClosableComponent, AXComponent } from '@acorex/cdk/c
|
|
|
2
2
|
import { AXButtonComponent } from '@acorex/components/button';
|
|
3
3
|
import { AXDecoratorCloseButtonComponent } from '@acorex/components/decorators';
|
|
4
4
|
import { AXLoadingComponent } from '@acorex/components/loading';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { AXTranslatorPipe, AXTranslationService } from '@acorex/core/translation';
|
|
6
|
+
import { DIALOG_DATA, DialogRef, Dialog } from '@angular/cdk/dialog';
|
|
7
|
+
import { TemplatePortal, ComponentPortal, CdkPortalOutlet } from '@angular/cdk/portal';
|
|
8
|
+
import { AsyncPipe } from '@angular/common';
|
|
7
9
|
import * as i0 from '@angular/core';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
const AX_NOTIFICATION_CONFIG = new InjectionToken('AX_NOTIFICATION_CONFIG', {
|
|
12
|
-
providedIn: 'root',
|
|
13
|
-
factory: () => AXNotificationDefaultConfig,
|
|
14
|
-
});
|
|
15
|
-
const AXNotificationDefaultConfig = {
|
|
16
|
-
gap: 5,
|
|
17
|
-
timeOut: 2500,
|
|
18
|
-
timeOutProgress: true,
|
|
19
|
-
closeButton: true,
|
|
20
|
-
location: 'top-end',
|
|
21
|
-
limit: 3,
|
|
22
|
-
pauseOnHover: true,
|
|
23
|
-
};
|
|
24
|
-
function notificationConfig(config = {}) {
|
|
25
|
-
const result = {
|
|
26
|
-
...AXNotificationDefaultConfig,
|
|
27
|
-
...config,
|
|
28
|
-
};
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
let notificationIdCounter = 0;
|
|
33
|
-
class AXNotificationService {
|
|
34
|
-
constructor() {
|
|
35
|
-
this.overlayService = inject(AXOverlayService);
|
|
36
|
-
this.translationService = inject(AXTranslationService);
|
|
37
|
-
this.defaultConfig = inject(AX_NOTIFICATION_CONFIG);
|
|
38
|
-
this.activeNotifications = signal([], ...(ngDevMode ? [{ debugName: "activeNotifications" }] : []));
|
|
39
|
-
this.reservedNotifications = signal([], ...(ngDevMode ? [{ debugName: "reservedNotifications" }] : []));
|
|
40
|
-
this.notificationCounterRef = signal(null, ...(ngDevMode ? [{ debugName: "notificationCounterRef" }] : []));
|
|
41
|
-
this.moreNotificationsColor = signal('primary', ...(ngDevMode ? [{ debugName: "moreNotificationsColor" }] : []));
|
|
42
|
-
this.moreNotificationsLocation = signal('bottom-center', ...(ngDevMode ? [{ debugName: "moreNotificationsLocation" }] : []));
|
|
43
|
-
this.reserveCounter = signal(0, ...(ngDevMode ? [{ debugName: "reserveCounter" }] : []));
|
|
44
|
-
}
|
|
45
|
-
show(config) {
|
|
46
|
-
config = { ...this.defaultConfig, ...config };
|
|
47
|
-
this.moreNotificationsColor.set(config.color);
|
|
48
|
-
this.moreNotificationsLocation.set(config.location);
|
|
49
|
-
if (this.defaultConfig.limit > 0 && this.activeNotifications().length >= this.defaultConfig.limit) {
|
|
50
|
-
const reservedRef = {
|
|
51
|
-
close: () => {
|
|
52
|
-
console.warn('Reserved notification cannot be closed until it is displayed.');
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
this.reservedNotifications.update((prev) => [...prev, { config, reservedRef }]);
|
|
56
|
-
this.handleReservedNotificationCounter();
|
|
57
|
-
return reservedRef;
|
|
58
|
-
}
|
|
59
|
-
return this.displayNotification(config);
|
|
60
|
-
}
|
|
61
|
-
displayNotification(config) {
|
|
62
|
-
const gap = this.defaultConfig.gap;
|
|
63
|
-
const notificationData = {
|
|
64
|
-
buttons: config.buttons,
|
|
65
|
-
icon: config.icon,
|
|
66
|
-
title: config.title,
|
|
67
|
-
content: config.content,
|
|
68
|
-
location: config.location,
|
|
69
|
-
closeButton: config.closeButton ?? true,
|
|
70
|
-
color: config.color,
|
|
71
|
-
timeOut: config.timeOut,
|
|
72
|
-
timeOutProgress: config.timeOutProgress ?? true,
|
|
73
|
-
pauseOnHover: config.pauseOnHover,
|
|
74
|
-
};
|
|
75
|
-
const notificationId = `notification-${++notificationIdCounter}`;
|
|
76
|
-
let internalRef;
|
|
77
|
-
const closeNotification = () => {
|
|
78
|
-
if (internalRef) {
|
|
79
|
-
internalRef.overlayRef.dispose();
|
|
80
|
-
this.activeNotifications.set(this.activeNotifications().filter((n) => n.id !== internalRef.id));
|
|
81
|
-
this.handleShowReservedNotification();
|
|
82
|
-
this.handleReservedNotificationCounter();
|
|
83
|
-
setTimeout(() => {
|
|
84
|
-
this.reposition(config.location, gap);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
this.overlayService
|
|
89
|
-
.create(AXNotificationComponent, {
|
|
90
|
-
inputs: {
|
|
91
|
-
config: notificationData,
|
|
92
|
-
onClose: closeNotification,
|
|
93
|
-
},
|
|
94
|
-
centered: false,
|
|
95
|
-
panelClass: ['ax-animate-animated', 'ax-animate-fadeIn', 'ax-animate-faster'],
|
|
96
|
-
onDispose: () => {
|
|
97
|
-
// Clean up when disposed externally
|
|
98
|
-
const currentNotifications = this.activeNotifications();
|
|
99
|
-
if (internalRef && currentNotifications.find((n) => n.id === internalRef.id)) {
|
|
100
|
-
this.activeNotifications.set(currentNotifications.filter((n) => n.id !== internalRef.id));
|
|
101
|
-
this.handleShowReservedNotification();
|
|
102
|
-
this.handleReservedNotificationCounter();
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
})
|
|
106
|
-
.then((overlayRef) => {
|
|
107
|
-
internalRef = {
|
|
108
|
-
id: notificationId,
|
|
109
|
-
overlayRef,
|
|
110
|
-
config: notificationData,
|
|
111
|
-
close: closeNotification,
|
|
112
|
-
};
|
|
113
|
-
// Position the notification BEFORE adding to activeNotifications
|
|
114
|
-
this.positionNotification(overlayRef.overlayElement, config.location, gap);
|
|
115
|
-
this.activeNotifications.update((prev) => [...prev, internalRef]);
|
|
116
|
-
this.handleReservedNotificationCounter();
|
|
117
|
-
});
|
|
118
|
-
return {
|
|
119
|
-
close: () => {
|
|
120
|
-
closeNotification();
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
hideAll() {
|
|
125
|
-
this.reserveCounter.set(0);
|
|
126
|
-
this.reservedNotifications.set([]);
|
|
127
|
-
// Close all active notifications
|
|
128
|
-
this.activeNotifications().forEach((notification) => {
|
|
129
|
-
notification.overlayRef.dispose();
|
|
130
|
-
});
|
|
131
|
-
this.activeNotifications.set([]);
|
|
132
|
-
// Close counter notification if exists
|
|
133
|
-
const counterRef = this.notificationCounterRef();
|
|
134
|
-
if (counterRef) {
|
|
135
|
-
counterRef.overlayRef.dispose();
|
|
136
|
-
this.notificationCounterRef.set(null);
|
|
137
|
-
}
|
|
138
|
-
this.handleReservedNotificationCounter();
|
|
139
|
-
}
|
|
140
|
-
handleShowReservedNotification() {
|
|
141
|
-
if (this.activeNotifications().length > this.defaultConfig.limit - 1)
|
|
142
|
-
return;
|
|
143
|
-
if (!this.reservedNotifications().length)
|
|
144
|
-
return;
|
|
145
|
-
const reserved = this.reservedNotifications()[0];
|
|
146
|
-
this.reservedNotifications.update((prev) => prev.slice(1));
|
|
147
|
-
const displayedRef = this.displayNotification(reserved.config);
|
|
148
|
-
this.handleReservedNotificationCounter();
|
|
149
|
-
reserved.reservedRef.close = displayedRef.close;
|
|
150
|
-
}
|
|
151
|
-
handleReservedNotificationCounter() {
|
|
152
|
-
const reservedCount = this.reservedNotifications().length;
|
|
153
|
-
if (reservedCount === this.reserveCounter())
|
|
154
|
-
return;
|
|
155
|
-
this.reserveCounter.set(reservedCount);
|
|
156
|
-
if (reservedCount === 0 && this.notificationCounterRef() !== null) {
|
|
157
|
-
this.notificationCounterRef().close();
|
|
158
|
-
this.notificationCounterRef.set(null);
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
if (reservedCount > 0) {
|
|
162
|
-
if (this.notificationCounterRef() !== null) {
|
|
163
|
-
this.notificationCounterRef().close();
|
|
164
|
-
this.notificationCounterRef.set(null);
|
|
165
|
-
}
|
|
166
|
-
this.createReservedCounterNotification();
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
async createReservedCounterNotification() {
|
|
170
|
-
const gap = this.defaultConfig.gap;
|
|
171
|
-
const opt = {
|
|
172
|
-
closeButton: false,
|
|
173
|
-
color: this.moreNotificationsColor(),
|
|
174
|
-
location: this.moreNotificationsLocation(),
|
|
175
|
-
title: await this.translationService.translateAsync('@acorex:common.notifications.more', {
|
|
176
|
-
params: { number: this.reserveCounter() },
|
|
177
|
-
}),
|
|
178
|
-
timeOutProgress: false,
|
|
179
|
-
};
|
|
180
|
-
const notificationId = `notification-counter-${++notificationIdCounter}`;
|
|
181
|
-
let counterInternalRef;
|
|
182
|
-
const closeCounter = () => {
|
|
183
|
-
if (counterInternalRef) {
|
|
184
|
-
counterInternalRef.overlayRef.dispose();
|
|
185
|
-
if (this.notificationCounterRef()?.id === counterInternalRef.id) {
|
|
186
|
-
this.notificationCounterRef.set(null);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
const overlayRef = await this.overlayService.create(AXNotificationComponent, {
|
|
191
|
-
inputs: {
|
|
192
|
-
config: opt,
|
|
193
|
-
onClose: closeCounter,
|
|
194
|
-
},
|
|
195
|
-
centered: false,
|
|
196
|
-
panelClass: ['ax-animate-animated', 'ax-animate-fadeIn', 'ax-animate-faster'],
|
|
197
|
-
});
|
|
198
|
-
counterInternalRef = {
|
|
199
|
-
id: notificationId,
|
|
200
|
-
overlayRef,
|
|
201
|
-
config: opt,
|
|
202
|
-
close: closeCounter,
|
|
203
|
-
};
|
|
204
|
-
this.notificationCounterRef.set(counterInternalRef);
|
|
205
|
-
// Position the counter notification
|
|
206
|
-
this.positionNotification(overlayRef.overlayElement, opt.location, gap);
|
|
207
|
-
}
|
|
208
|
-
positionNotification(element, location, gap) {
|
|
209
|
-
if (!element)
|
|
210
|
-
return;
|
|
211
|
-
const pos = this.getPosition(location) + gap;
|
|
212
|
-
// Override the centered overlay container styles for notification positioning
|
|
213
|
-
element.style.width = 'max-content';
|
|
214
|
-
element.style.height = 'auto';
|
|
215
|
-
element.style.display = 'block';
|
|
216
|
-
element.style.alignItems = '';
|
|
217
|
-
element.style.justifyContent = '';
|
|
218
|
-
// Reset all positioning styles
|
|
219
|
-
element.style.top = '';
|
|
220
|
-
element.style.bottom = '';
|
|
221
|
-
element.style.left = '';
|
|
222
|
-
element.style.right = '';
|
|
223
|
-
element.style.transform = '';
|
|
224
|
-
// Apply position based on location
|
|
225
|
-
switch (location) {
|
|
226
|
-
case 'bottom-center':
|
|
227
|
-
element.style.bottom = pos + 'px';
|
|
228
|
-
element.style.left = '50%';
|
|
229
|
-
element.style.transform = 'translateX(-50%)';
|
|
230
|
-
break;
|
|
231
|
-
case 'bottom-end':
|
|
232
|
-
element.style.bottom = pos + 'px';
|
|
233
|
-
element.style.right = gap + 'px';
|
|
234
|
-
break;
|
|
235
|
-
case 'bottom-start':
|
|
236
|
-
element.style.bottom = pos + 'px';
|
|
237
|
-
element.style.left = gap + 'px';
|
|
238
|
-
break;
|
|
239
|
-
case 'top-center':
|
|
240
|
-
element.style.top = pos + 'px';
|
|
241
|
-
element.style.left = '50%';
|
|
242
|
-
element.style.transform = 'translateX(-50%)';
|
|
243
|
-
break;
|
|
244
|
-
case 'top-end':
|
|
245
|
-
element.style.top = pos + 'px';
|
|
246
|
-
element.style.right = gap + 'px';
|
|
247
|
-
break;
|
|
248
|
-
case 'top-start':
|
|
249
|
-
element.style.top = pos + 'px';
|
|
250
|
-
element.style.left = gap + 'px';
|
|
251
|
-
break;
|
|
252
|
-
case 'center-start':
|
|
253
|
-
element.style.top = '50%';
|
|
254
|
-
element.style.left = gap + 'px';
|
|
255
|
-
element.style.transform = 'translateY(-50%)';
|
|
256
|
-
break;
|
|
257
|
-
case 'center-end':
|
|
258
|
-
element.style.top = '50%';
|
|
259
|
-
element.style.right = gap + 'px';
|
|
260
|
-
element.style.transform = 'translateY(-50%)';
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
reposition(notificationLocation, gap) {
|
|
265
|
-
const list = this.activeNotifications().filter((n) => n.config?.location === notificationLocation);
|
|
266
|
-
list.forEach((notification, index) => {
|
|
267
|
-
const element = notification.overlayRef.overlayElement;
|
|
268
|
-
if (!element)
|
|
269
|
-
return;
|
|
270
|
-
const pos = this.getRepositionPosition(index, gap, list, notificationLocation);
|
|
271
|
-
this.applyRepositionPosition(element, notificationLocation, pos, gap);
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
getRepositionPosition(index, gap, list, notificationLocation) {
|
|
275
|
-
if (index === 0)
|
|
276
|
-
return gap;
|
|
277
|
-
const previousNotification = list[index - 1];
|
|
278
|
-
const previousElement = previousNotification.overlayRef.overlayElement;
|
|
279
|
-
if (!previousElement)
|
|
280
|
-
return gap;
|
|
281
|
-
if (notificationLocation.split('-')[0] === 'bottom') {
|
|
282
|
-
return window.innerHeight - previousElement.offsetTop + gap;
|
|
283
|
-
}
|
|
284
|
-
return previousElement.offsetTop + previousElement.offsetHeight + gap;
|
|
285
|
-
}
|
|
286
|
-
applyRepositionPosition(element, location, pos, gap) {
|
|
287
|
-
// Reset transform if needed, then apply position
|
|
288
|
-
const isVerticalCenter = location === 'center-start' || location === 'center-end';
|
|
289
|
-
const isHorizontalCenter = location === 'bottom-center' || location === 'top-center';
|
|
290
|
-
if (location.startsWith('bottom')) {
|
|
291
|
-
element.style.bottom = pos + 'px';
|
|
292
|
-
element.style.top = '';
|
|
293
|
-
if (isHorizontalCenter) {
|
|
294
|
-
element.style.transform = 'translateX(-50%)';
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
else if (location.startsWith('top')) {
|
|
298
|
-
element.style.top = pos + 'px';
|
|
299
|
-
element.style.bottom = '';
|
|
300
|
-
if (isHorizontalCenter) {
|
|
301
|
-
element.style.transform = 'translateX(-50%)';
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
else if (isVerticalCenter) {
|
|
305
|
-
element.style.top = pos + 'px';
|
|
306
|
-
element.style.bottom = '';
|
|
307
|
-
element.style.transform = '';
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
getPosition(location) {
|
|
311
|
-
const list = this.activeNotifications().filter((n) => n.config?.location === location);
|
|
312
|
-
if (list.length === 0)
|
|
313
|
-
return 0;
|
|
314
|
-
const lastNotification = list[list.length - 1];
|
|
315
|
-
const element = lastNotification.overlayRef.overlayElement;
|
|
316
|
-
if (!element)
|
|
317
|
-
return 0;
|
|
318
|
-
if (location.split('-')[0] === 'bottom') {
|
|
319
|
-
return window.innerHeight - element.offsetTop;
|
|
320
|
-
}
|
|
321
|
-
return element.offsetTop + element.offsetHeight;
|
|
322
|
-
}
|
|
323
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXNotificationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
324
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXNotificationService, providedIn: 'root' }); }
|
|
325
|
-
}
|
|
326
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXNotificationService, decorators: [{
|
|
327
|
-
type: Injectable,
|
|
328
|
-
args: [{
|
|
329
|
-
providedIn: 'root',
|
|
330
|
-
}]
|
|
331
|
-
}] });
|
|
10
|
+
import { inject, signal, TemplateRef, HostBinding, ViewEncapsulation, ChangeDetectionStrategy, Component, InjectionToken, NgModule, Injectable } from '@angular/core';
|
|
11
|
+
import { GlobalPositionStrategy } from '@angular/cdk/overlay';
|
|
332
12
|
|
|
333
13
|
/**
|
|
334
14
|
* The Button is a component which detects user interaction and triggers a corresponding event
|
|
@@ -338,37 +18,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImpo
|
|
|
338
18
|
class AXNotificationComponent extends MXBaseComponent {
|
|
339
19
|
constructor() {
|
|
340
20
|
super(...arguments);
|
|
341
|
-
|
|
342
|
-
this.
|
|
343
|
-
/** @internal Callback function to close the notification */
|
|
344
|
-
this.onClose = input(...(ngDevMode ? [undefined, { debugName: "onClose" }] : []));
|
|
345
|
-
this.notificationService = inject(AXNotificationService);
|
|
21
|
+
this.config = inject(DIALOG_DATA);
|
|
22
|
+
this.dialogRef = inject(DialogRef);
|
|
346
23
|
this.isPaused = signal(false, ...(ngDevMode ? [{ debugName: "isPaused" }] : []));
|
|
347
24
|
this.remainingTime = signal(0, ...(ngDevMode ? [{ debugName: "remainingTime" }] : []));
|
|
348
25
|
this.transitionDuration = signal(150, ...(ngDevMode ? [{ debugName: "transitionDuration" }] : []));
|
|
349
|
-
/** Template content if config.content is a TemplateRef */
|
|
350
|
-
this.templateContent = computed(() => {
|
|
351
|
-
const content = this.config().content;
|
|
352
|
-
return content instanceof TemplateRef ? content : null;
|
|
353
|
-
}, ...(ngDevMode ? [{ debugName: "templateContent" }] : []));
|
|
354
|
-
/** Component content if config.content is a component Type */
|
|
355
|
-
this.componentContent = computed(() => {
|
|
356
|
-
const content = this.config().content;
|
|
357
|
-
return typeof content === 'function' ? content : null;
|
|
358
|
-
}, ...(ngDevMode ? [{ debugName: "componentContent" }] : []));
|
|
359
|
-
/** String content if config.content is a string */
|
|
360
|
-
this.stringContent = computed(() => {
|
|
361
|
-
const content = this.config().content;
|
|
362
|
-
return typeof content === 'string' ? content : '';
|
|
363
|
-
}, ...(ngDevMode ? [{ debugName: "stringContent" }] : []));
|
|
364
26
|
}
|
|
365
27
|
ngOnInit() {
|
|
366
28
|
super.ngOnInit();
|
|
29
|
+
this._initContent();
|
|
367
30
|
this._initIcon();
|
|
368
|
-
this.remainingTime.set(this.config
|
|
31
|
+
this.remainingTime.set(this.config.timeOut);
|
|
369
32
|
this._handleTimeOut();
|
|
370
33
|
this.getHostElement().addEventListener('pointerenter', () => {
|
|
371
|
-
if (!this.config
|
|
34
|
+
if (!this.config.pauseOnHover)
|
|
372
35
|
return;
|
|
373
36
|
if (this.isPaused())
|
|
374
37
|
return;
|
|
@@ -377,7 +40,7 @@ class AXNotificationComponent extends MXBaseComponent {
|
|
|
377
40
|
this.pauseAnimation();
|
|
378
41
|
});
|
|
379
42
|
this.getHostElement().addEventListener('pointerleave', () => {
|
|
380
|
-
if (!this.config
|
|
43
|
+
if (!this.config.pauseOnHover)
|
|
381
44
|
return;
|
|
382
45
|
if (!this.isPaused())
|
|
383
46
|
return;
|
|
@@ -390,7 +53,7 @@ class AXNotificationComponent extends MXBaseComponent {
|
|
|
390
53
|
clearInterval(this.intervalId);
|
|
391
54
|
}
|
|
392
55
|
_handleTimeOut() {
|
|
393
|
-
if (this.config
|
|
56
|
+
if (this.config.timeOut) {
|
|
394
57
|
this.intervalId = setInterval(() => {
|
|
395
58
|
this.remainingTime.update((prev) => prev - this.transitionDuration());
|
|
396
59
|
if (this.remainingTime() <= 0) {
|
|
@@ -401,9 +64,18 @@ class AXNotificationComponent extends MXBaseComponent {
|
|
|
401
64
|
}
|
|
402
65
|
}
|
|
403
66
|
/** @ignore */
|
|
67
|
+
_initContent() {
|
|
68
|
+
if (this.config.content instanceof TemplateRef) {
|
|
69
|
+
this._selectedPortal = new TemplatePortal(this.config.content, this.getViewContainer());
|
|
70
|
+
}
|
|
71
|
+
else if (typeof this.config.content === 'function') {
|
|
72
|
+
this._selectedPortal = new ComponentPortal(this.config.content);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** @ignore */
|
|
404
76
|
_initIcon() {
|
|
405
|
-
if (!this.config
|
|
406
|
-
switch (this.config
|
|
77
|
+
if (!this.config.icon) {
|
|
78
|
+
switch (this.config.color) {
|
|
407
79
|
case 'success':
|
|
408
80
|
this._icon = 'ax-icon ax-icon-check-circle';
|
|
409
81
|
break;
|
|
@@ -414,58 +86,81 @@ class AXNotificationComponent extends MXBaseComponent {
|
|
|
414
86
|
this._icon = 'ax-icon ax-icon-warning';
|
|
415
87
|
break;
|
|
416
88
|
default:
|
|
417
|
-
this._icon = this.config
|
|
89
|
+
this._icon = this.config.icon || 'ax-icon ax-icon-info';
|
|
418
90
|
break;
|
|
419
91
|
}
|
|
420
92
|
}
|
|
421
93
|
else {
|
|
422
|
-
this._icon = this.config
|
|
94
|
+
this._icon = this.config.icon;
|
|
423
95
|
}
|
|
424
96
|
}
|
|
425
97
|
/** @ignore */
|
|
98
|
+
get _stringContent() {
|
|
99
|
+
return typeof this.config.content === 'string' ? this.config.content : '';
|
|
100
|
+
}
|
|
101
|
+
/** @ignore */
|
|
426
102
|
_handleButtonClick(button) {
|
|
427
103
|
if (button.onClick) {
|
|
428
104
|
button.onClick({ source: button });
|
|
429
105
|
}
|
|
430
106
|
}
|
|
431
|
-
/**
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
close() {
|
|
435
|
-
const closeCallback = this.onClose();
|
|
436
|
-
if (closeCallback) {
|
|
437
|
-
closeCallback();
|
|
438
|
-
}
|
|
107
|
+
/** @ignore */
|
|
108
|
+
get __hostClass() {
|
|
109
|
+
return `ax-${this.config.color}`;
|
|
439
110
|
}
|
|
440
111
|
/**
|
|
441
|
-
* Closes
|
|
112
|
+
* Closes the dialog and provides the component and HTML element for reference.
|
|
442
113
|
*/
|
|
443
|
-
|
|
444
|
-
this.
|
|
114
|
+
close() {
|
|
115
|
+
this.dialogRef.close({
|
|
116
|
+
component: this,
|
|
117
|
+
htmlElement: this.getHostElement(),
|
|
118
|
+
});
|
|
445
119
|
}
|
|
446
120
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXNotificationComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
447
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.15", type: AXNotificationComponent, isStandalone: true, selector: "ax-notification",
|
|
121
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.15", type: AXNotificationComponent, isStandalone: true, selector: "ax-notification", host: { properties: { "class": "this.__hostClass" } }, providers: [
|
|
448
122
|
{ provide: AXClosableComponent, useExisting: AXNotificationComponent },
|
|
449
123
|
{ provide: AXComponent, useExisting: AXNotificationComponent },
|
|
450
|
-
], usesInheritance: true, ngImport: i0, template: "<span class=\"ax-notification-icon ax-icon-solid {{ _icon }}\"></span>\n<div class=\"ax-notification-content\">\n <div class=\"ax-notification-title\">{{ config
|
|
124
|
+
], usesInheritance: true, ngImport: i0, template: "<span class=\"ax-notification-icon ax-icon-solid {{ _icon }}\"></span>\n<div class=\"ax-notification-content\">\n <div class=\"ax-notification-title\">{{ config.title | translate | async }}</div>\n @if (_selectedPortal) {\n <ng-template [cdkPortalOutlet]=\"_selectedPortal\"></ng-template>\n } @else {\n <div>{{ _stringContent | translate | async }}</div>\n }\n\n @if (config.buttons?.length) {\n <div class=\"ax-notification-buttons\">\n @for (button of config.buttons; track $index) {\n <ax-button\n class=\"ax-xs\"\n [text]=\"button.text | translate | async\"\n [color]=\"button.color\"\n [look]=\"button.look\"\n [disabled]=\"button.disabled\"\n (onClick)=\"_handleButtonClick(button)\"\n >\n @if (button.loading) {\n <ax-loading></ax-loading>\n }\n </ax-button>\n }\n </div>\n }\n</div>\n@if (config.closeButton) {\n <ax-close-button></ax-close-button>\n}\n@if (config.timeOutProgress && config.timeOut && remainingTime()) {\n <div\n class=\"ax-notification-progress\"\n [style.transition-duration]=\"transitionDuration()\"\n [style.width]=\"(remainingTime() * 100) / config.timeOut + '%'\"\n ></div>\n}\n", styles: ["ax-notification.ax-default{--ax-comp-notification-icon-text-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-surface)}.ax-dark ax-notification.ax-default{--ax-comp-notification-icon-text-color: var(--ax-sys-color-on-darkest-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-lightest-surface)}ax-notification.ax-primary{--ax-comp-notification-icon-text-color: var(--ax-sys-color-primary-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-primary-surface)}ax-notification.ax-secondary{--ax-comp-notification-icon-text-color: var(--ax-sys-color-secondary-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-secondary-surface)}ax-notification.ax-success{--ax-comp-notification-icon-text-color: var(--ax-sys-color-success-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-success-surface)}ax-notification.ax-warning{--ax-comp-notification-icon-text-color: var(--ax-sys-color-warning-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-warning-surface)}ax-notification.ax-danger{--ax-comp-notification-icon-text-color: var(--ax-sys-color-danger-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-danger-surface)}ax-notification.ax-accent1{--ax-comp-notification-icon-text-color: var(--ax-sys-color-accent1-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-accent1-surface)}ax-notification.ax-accent2{--ax-comp-notification-icon-text-color: var(--ax-sys-color-accent2-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-accent2-surface)}ax-notification.ax-accent3{--ax-comp-notification-icon-text-color: var(--ax-sys-color-accent3-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-accent3-surface)}ax-notification.ax-accent4{--ax-comp-notification-icon-text-color: var(--ax-sys-color-accent4-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-accent4-surface)}ax-notification.ax-accent5{--ax-comp-notification-icon-text-color: var(--ax-sys-color-accent5-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-accent5-surface)}ax-notification.ax-accent6{--ax-comp-notification-icon-text-color: var(--ax-sys-color-accent6-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-accent6-surface)}ax-notification.ax-accent7{--ax-comp-notification-icon-text-color: var(--ax-sys-color-accent7-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-accent7-surface)}ax-notification{position:relative;display:flex;width:98vw;overflow:hidden;padding:1rem;--ax-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--ax-shadow-colored: 0 10px 15px -3px var(--ax-shadow-color), 0 4px 6px -4px var(--ax-shadow-color);box-shadow:var(--ax-ring-offset-shadow, 0 0 rgba(0, 0, 0, 0)),var(--ax-ring-shadow, 0 0 rgba(0, 0, 0, 0)),var(--ax-shadow);background-color:rgba(var(--ax-comp-notification-bg-color, var(--ax-sys-color-lightest-surface)));font-size:var(--ax-comp-notification-font-size, .875rem);line-height:var(--ax-comp-notification-line-height, 1.25rem);border-width:var(--ax-comp-notification-border-width, 1px);border-color:rgba(var(--ax-comp-notification-border-color, var(--ax-sys-color-border-lightest-surface)));border-radius:var(--ax-comp-notification-border-radius, var(--ax-sys-border-radius))}@media (min-width: 768px){ax-notification{width:24rem}}ax-notification .ax-notification-icon,ax-notification .ax-icon-close{font-size:1.25rem;line-height:1.75rem;max-width:fit-content;align-items:flex-start}ax-notification .ax-notification-icon{color:rgba(var(--ax-comp-notification-icon-text-color));padding-inline-end:.75rem}ax-notification .ax-notification-content{display:flex;flex:1 1 0%;flex-direction:column;font-weight:400;justify-content:center;color:rgba(var(--ax-comp-notification-text-color, var(--ax-sys-color-on-surface)))}ax-notification .ax-notification-content .ax-notification-title{font-weight:500;line-height:1.5}ax-notification .ax-notification-content .ax-notification-buttons{margin-top:.75rem;display:flex;gap:.75rem}ax-notification .ax-notification-progress{width:100%;bottom:0;height:.25rem;position:absolute;inset-inline-end:0px;inset-inline-start:0px;transition-property:width;transition-timing-function:linear;transition-duration:var(--ax-sys-transition-duration);background-color:rgba(var(--ax-comp-notification-progress-bg-color, 255, 255, 255, .46))}.ax-dark ax-notification{--ax-comp-notification-bg-color: var(--ax-sys-color-darkest-surface);--ax-comp-notification-border-color: var(--ax-sys-color-border-darkest-surface)}\n"], dependencies: [{ kind: "directive", type: CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }, { kind: "component", type: AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "iconOnly", "type", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "loadingTextChange"] }, { kind: "component", type: AXLoadingComponent, selector: "ax-loading", inputs: ["visible", "type", "context"], outputs: ["visibleChange"] }, { kind: "component", type: AXDecoratorCloseButtonComponent, selector: "ax-close-button", inputs: ["closeAll", "icon"] }, { kind: "pipe", type: AsyncPipe, name: "async" }, { kind: "pipe", type: AXTranslatorPipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
451
125
|
}
|
|
452
126
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXNotificationComponent, decorators: [{
|
|
453
127
|
type: Component,
|
|
454
|
-
args: [{ selector: 'ax-notification', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None,
|
|
455
|
-
'[class]': '"ax-" + config().color',
|
|
456
|
-
}, providers: [
|
|
128
|
+
args: [{ selector: 'ax-notification', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [
|
|
457
129
|
{ provide: AXClosableComponent, useExisting: AXNotificationComponent },
|
|
458
130
|
{ provide: AXComponent, useExisting: AXNotificationComponent },
|
|
459
131
|
], imports: [
|
|
460
|
-
|
|
461
|
-
NgComponentOutlet,
|
|
132
|
+
CdkPortalOutlet,
|
|
462
133
|
AXButtonComponent,
|
|
463
134
|
AXLoadingComponent,
|
|
464
135
|
AXDecoratorCloseButtonComponent,
|
|
465
136
|
AsyncPipe,
|
|
466
137
|
AXTranslatorPipe,
|
|
467
|
-
], template: "<span class=\"ax-notification-icon ax-icon-solid {{ _icon }}\"></span>\n<div class=\"ax-notification-content\">\n <div class=\"ax-notification-title\">{{ config
|
|
468
|
-
}], propDecorators: {
|
|
138
|
+
], template: "<span class=\"ax-notification-icon ax-icon-solid {{ _icon }}\"></span>\n<div class=\"ax-notification-content\">\n <div class=\"ax-notification-title\">{{ config.title | translate | async }}</div>\n @if (_selectedPortal) {\n <ng-template [cdkPortalOutlet]=\"_selectedPortal\"></ng-template>\n } @else {\n <div>{{ _stringContent | translate | async }}</div>\n }\n\n @if (config.buttons?.length) {\n <div class=\"ax-notification-buttons\">\n @for (button of config.buttons; track $index) {\n <ax-button\n class=\"ax-xs\"\n [text]=\"button.text | translate | async\"\n [color]=\"button.color\"\n [look]=\"button.look\"\n [disabled]=\"button.disabled\"\n (onClick)=\"_handleButtonClick(button)\"\n >\n @if (button.loading) {\n <ax-loading></ax-loading>\n }\n </ax-button>\n }\n </div>\n }\n</div>\n@if (config.closeButton) {\n <ax-close-button></ax-close-button>\n}\n@if (config.timeOutProgress && config.timeOut && remainingTime()) {\n <div\n class=\"ax-notification-progress\"\n [style.transition-duration]=\"transitionDuration()\"\n [style.width]=\"(remainingTime() * 100) / config.timeOut + '%'\"\n ></div>\n}\n", styles: ["ax-notification.ax-default{--ax-comp-notification-icon-text-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-surface)}.ax-dark ax-notification.ax-default{--ax-comp-notification-icon-text-color: var(--ax-sys-color-on-darkest-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-lightest-surface)}ax-notification.ax-primary{--ax-comp-notification-icon-text-color: var(--ax-sys-color-primary-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-primary-surface)}ax-notification.ax-secondary{--ax-comp-notification-icon-text-color: var(--ax-sys-color-secondary-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-secondary-surface)}ax-notification.ax-success{--ax-comp-notification-icon-text-color: var(--ax-sys-color-success-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-success-surface)}ax-notification.ax-warning{--ax-comp-notification-icon-text-color: var(--ax-sys-color-warning-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-warning-surface)}ax-notification.ax-danger{--ax-comp-notification-icon-text-color: var(--ax-sys-color-danger-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-danger-surface)}ax-notification.ax-accent1{--ax-comp-notification-icon-text-color: var(--ax-sys-color-accent1-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-accent1-surface)}ax-notification.ax-accent2{--ax-comp-notification-icon-text-color: var(--ax-sys-color-accent2-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-accent2-surface)}ax-notification.ax-accent3{--ax-comp-notification-icon-text-color: var(--ax-sys-color-accent3-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-accent3-surface)}ax-notification.ax-accent4{--ax-comp-notification-icon-text-color: var(--ax-sys-color-accent4-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-accent4-surface)}ax-notification.ax-accent5{--ax-comp-notification-icon-text-color: var(--ax-sys-color-accent5-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-accent5-surface)}ax-notification.ax-accent6{--ax-comp-notification-icon-text-color: var(--ax-sys-color-accent6-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-accent6-surface)}ax-notification.ax-accent7{--ax-comp-notification-icon-text-color: var(--ax-sys-color-accent7-surface);--ax-comp-notification-progress-bg-color: var(--ax-sys-color-accent7-surface)}ax-notification{position:relative;display:flex;width:98vw;overflow:hidden;padding:1rem;--ax-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--ax-shadow-colored: 0 10px 15px -3px var(--ax-shadow-color), 0 4px 6px -4px var(--ax-shadow-color);box-shadow:var(--ax-ring-offset-shadow, 0 0 rgba(0, 0, 0, 0)),var(--ax-ring-shadow, 0 0 rgba(0, 0, 0, 0)),var(--ax-shadow);background-color:rgba(var(--ax-comp-notification-bg-color, var(--ax-sys-color-lightest-surface)));font-size:var(--ax-comp-notification-font-size, .875rem);line-height:var(--ax-comp-notification-line-height, 1.25rem);border-width:var(--ax-comp-notification-border-width, 1px);border-color:rgba(var(--ax-comp-notification-border-color, var(--ax-sys-color-border-lightest-surface)));border-radius:var(--ax-comp-notification-border-radius, var(--ax-sys-border-radius))}@media (min-width: 768px){ax-notification{width:24rem}}ax-notification .ax-notification-icon,ax-notification .ax-icon-close{font-size:1.25rem;line-height:1.75rem;max-width:fit-content;align-items:flex-start}ax-notification .ax-notification-icon{color:rgba(var(--ax-comp-notification-icon-text-color));padding-inline-end:.75rem}ax-notification .ax-notification-content{display:flex;flex:1 1 0%;flex-direction:column;font-weight:400;justify-content:center;color:rgba(var(--ax-comp-notification-text-color, var(--ax-sys-color-on-surface)))}ax-notification .ax-notification-content .ax-notification-title{font-weight:500;line-height:1.5}ax-notification .ax-notification-content .ax-notification-buttons{margin-top:.75rem;display:flex;gap:.75rem}ax-notification .ax-notification-progress{width:100%;bottom:0;height:.25rem;position:absolute;inset-inline-end:0px;inset-inline-start:0px;transition-property:width;transition-timing-function:linear;transition-duration:var(--ax-sys-transition-duration);background-color:rgba(var(--ax-comp-notification-progress-bg-color, 255, 255, 255, .46))}.ax-dark ax-notification{--ax-comp-notification-bg-color: var(--ax-sys-color-darkest-surface);--ax-comp-notification-border-color: var(--ax-sys-color-border-darkest-surface)}\n"] }]
|
|
139
|
+
}], propDecorators: { __hostClass: [{
|
|
140
|
+
type: HostBinding,
|
|
141
|
+
args: ['class']
|
|
142
|
+
}] } });
|
|
143
|
+
|
|
144
|
+
const AX_NOTIFICATION_CONFIG = new InjectionToken('AX_NOTIFICATION_CONFIG', {
|
|
145
|
+
providedIn: 'root',
|
|
146
|
+
factory: () => AXNotificationDefaultConfig,
|
|
147
|
+
});
|
|
148
|
+
const AXNotificationDefaultConfig = {
|
|
149
|
+
gap: 5,
|
|
150
|
+
timeOut: 2500,
|
|
151
|
+
timeOutProgress: true,
|
|
152
|
+
closeButton: true,
|
|
153
|
+
location: 'top-end',
|
|
154
|
+
limit: 3,
|
|
155
|
+
pauseOnHover: true,
|
|
156
|
+
};
|
|
157
|
+
function notificationConfig(config = {}) {
|
|
158
|
+
const result = {
|
|
159
|
+
...AXNotificationDefaultConfig,
|
|
160
|
+
...config,
|
|
161
|
+
};
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
469
164
|
|
|
470
165
|
class AXNotificationModule {
|
|
471
166
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXNotificationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
@@ -480,6 +175,194 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImpo
|
|
|
480
175
|
}]
|
|
481
176
|
}] });
|
|
482
177
|
|
|
178
|
+
class AXNotificationService {
|
|
179
|
+
constructor() {
|
|
180
|
+
this.dialog = inject(Dialog);
|
|
181
|
+
this.translationService = inject(AXTranslationService);
|
|
182
|
+
this.defaultConfig = inject(AX_NOTIFICATION_CONFIG);
|
|
183
|
+
this.activeNotifications = [];
|
|
184
|
+
this.reservedNotifications = [];
|
|
185
|
+
this.notificationCounterElement = null;
|
|
186
|
+
this.moreNotificationsColor = 'primary';
|
|
187
|
+
this.moreNotificationsLocation = 'bottom-center';
|
|
188
|
+
this.reserveCounter = 0;
|
|
189
|
+
}
|
|
190
|
+
show(config) {
|
|
191
|
+
config = { ...this.defaultConfig, ...config };
|
|
192
|
+
this.moreNotificationsColor = config.color;
|
|
193
|
+
this.moreNotificationsLocation = config.location;
|
|
194
|
+
if (this.defaultConfig.limit > 0 && this.activeNotifications.length >= this.defaultConfig.limit) {
|
|
195
|
+
const reservedRef = {
|
|
196
|
+
close: () => {
|
|
197
|
+
console.warn('Reserved notification cannot be closed until it is displayed.');
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
this.reservedNotifications.push({ config, reservedRef });
|
|
201
|
+
this.handleReservedNotificationCounter();
|
|
202
|
+
return reservedRef;
|
|
203
|
+
}
|
|
204
|
+
return this.displayNotification(config);
|
|
205
|
+
}
|
|
206
|
+
displayNotification(config) {
|
|
207
|
+
const gap = this.defaultConfig.gap;
|
|
208
|
+
const pos = this.getPosition(config.location) + gap + 'px';
|
|
209
|
+
const positionStrategy = this.getPositionStrategy(new GlobalPositionStrategy(), config.location, pos, gap);
|
|
210
|
+
const dialogRef = this.dialog.open(AXNotificationComponent, {
|
|
211
|
+
data: config,
|
|
212
|
+
autoFocus: '__no_element__',
|
|
213
|
+
restoreFocus: false,
|
|
214
|
+
role: 'dialog',
|
|
215
|
+
ariaModal: true,
|
|
216
|
+
closeOnNavigation: true,
|
|
217
|
+
closeOnDestroy: true,
|
|
218
|
+
hasBackdrop: false,
|
|
219
|
+
panelClass: ['ax-animate-animated', 'ax-animate-fadeIn', 'ax-animate-faster'],
|
|
220
|
+
positionStrategy,
|
|
221
|
+
});
|
|
222
|
+
this.activeNotifications.push(dialogRef.id);
|
|
223
|
+
this.handleReservedNotificationCounter();
|
|
224
|
+
const notificationRef = dialogRef.componentInstance;
|
|
225
|
+
dialogRef.closed.subscribe(() => {
|
|
226
|
+
this.activeNotifications = this.activeNotifications.filter((id) => id !== dialogRef.id);
|
|
227
|
+
this.handleShowReservedNotification();
|
|
228
|
+
this.handleReservedNotificationCounter();
|
|
229
|
+
setTimeout(() => {
|
|
230
|
+
this.reposition(config.location, gap);
|
|
231
|
+
}, 0);
|
|
232
|
+
});
|
|
233
|
+
return {
|
|
234
|
+
close: () => {
|
|
235
|
+
notificationRef.close();
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
hideAll() {
|
|
240
|
+
this.dialog.closeAll();
|
|
241
|
+
this.reserveCounter = 0;
|
|
242
|
+
this.reservedNotifications = [];
|
|
243
|
+
this.activeNotifications = [];
|
|
244
|
+
this.handleReservedNotificationCounter();
|
|
245
|
+
}
|
|
246
|
+
handleShowReservedNotification() {
|
|
247
|
+
if (this.activeNotifications.length > this.defaultConfig.limit - 1)
|
|
248
|
+
return;
|
|
249
|
+
if (!this.reservedNotifications.length)
|
|
250
|
+
return;
|
|
251
|
+
const { config, reservedRef } = this.reservedNotifications.shift();
|
|
252
|
+
const displayedRef = this.displayNotification(config);
|
|
253
|
+
this.handleReservedNotificationCounter();
|
|
254
|
+
reservedRef.close = displayedRef.close;
|
|
255
|
+
}
|
|
256
|
+
handleReservedNotificationCounter() {
|
|
257
|
+
const reservedCount = this.reservedNotifications.length;
|
|
258
|
+
if (reservedCount === this.reserveCounter)
|
|
259
|
+
return;
|
|
260
|
+
this.reserveCounter = reservedCount;
|
|
261
|
+
if (reservedCount === 0 && this.notificationCounterElement !== null) {
|
|
262
|
+
this.notificationCounterElement.close();
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (reservedCount > 0) {
|
|
266
|
+
if (this.notificationCounterElement !== null) {
|
|
267
|
+
this.notificationCounterElement.close();
|
|
268
|
+
}
|
|
269
|
+
this.createReservedCounternotification();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
async createReservedCounternotification() {
|
|
273
|
+
const opt = {
|
|
274
|
+
closeButton: false,
|
|
275
|
+
color: this.moreNotificationsColor,
|
|
276
|
+
location: this.moreNotificationsLocation,
|
|
277
|
+
title: await this.translationService.translateAsync('@acorex:common.notifications.more', {
|
|
278
|
+
params: { number: this.reserveCounter },
|
|
279
|
+
}),
|
|
280
|
+
timeOutProgress: false,
|
|
281
|
+
};
|
|
282
|
+
const gap = this.defaultConfig.gap;
|
|
283
|
+
const pos = this.getPosition(opt.location) + gap + 'px';
|
|
284
|
+
const positionStrategy = this.getPositionStrategy(new GlobalPositionStrategy(), opt.location, pos, gap);
|
|
285
|
+
const dialogRef = this.dialog.open(AXNotificationComponent, {
|
|
286
|
+
data: opt,
|
|
287
|
+
autoFocus: '__no_element__',
|
|
288
|
+
restoreFocus: true,
|
|
289
|
+
role: 'dialog',
|
|
290
|
+
ariaModal: true,
|
|
291
|
+
closeOnNavigation: true,
|
|
292
|
+
closeOnDestroy: true,
|
|
293
|
+
hasBackdrop: false,
|
|
294
|
+
panelClass: ['ax-animate-animated', 'ax-animate-fadeIn', 'ax-animate-faster'],
|
|
295
|
+
positionStrategy,
|
|
296
|
+
});
|
|
297
|
+
this.notificationCounterElement = dialogRef.componentInstance;
|
|
298
|
+
}
|
|
299
|
+
reposition(notificationLocation, gap) {
|
|
300
|
+
const list = this.dialog.openDialogs
|
|
301
|
+
.map((c) => c.componentInstance)
|
|
302
|
+
.filter((c) => c.config?.location == notificationLocation);
|
|
303
|
+
list.forEach((element, index) => {
|
|
304
|
+
const pos = this.getRepositionPosition(index, gap, list, notificationLocation);
|
|
305
|
+
this.getPositionStrategy(element.dialogRef.config.positionStrategy, notificationLocation, pos, gap).apply();
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
getRepositionPosition(index, gap, list, notificationLocation) {
|
|
309
|
+
if (index === 0)
|
|
310
|
+
return gap + 'px';
|
|
311
|
+
const previouseElement = list[index - 1];
|
|
312
|
+
if (notificationLocation.split('-')[0] == 'bottom') {
|
|
313
|
+
return window.innerHeight - previouseElement.getHostElement().offsetTop + gap + 'px';
|
|
314
|
+
}
|
|
315
|
+
return previouseElement.getHostElement().offsetTop + previouseElement.getHostElement().offsetHeight + gap + 'px';
|
|
316
|
+
}
|
|
317
|
+
getPosition(location) {
|
|
318
|
+
const list = this.dialog.openDialogs
|
|
319
|
+
.map((c) => c.componentInstance)
|
|
320
|
+
.filter((c) => c.config.location == location);
|
|
321
|
+
if (list.length == 0)
|
|
322
|
+
return 0;
|
|
323
|
+
if (location.split('-')[0] == 'bottom') {
|
|
324
|
+
return window.innerHeight - list[list.length - 1].getHostElement().offsetTop;
|
|
325
|
+
}
|
|
326
|
+
return list[list.length - 1].getHostElement().offsetTop + list[list.length - 1].getHostElement().offsetHeight;
|
|
327
|
+
}
|
|
328
|
+
getPositionStrategy(positionStrategy, location, pos, gap) {
|
|
329
|
+
switch (location) {
|
|
330
|
+
case 'bottom-center':
|
|
331
|
+
return positionStrategy.bottom(pos).centerHorizontally();
|
|
332
|
+
break;
|
|
333
|
+
case 'bottom-end':
|
|
334
|
+
return positionStrategy.bottom(pos).right(gap + 'px');
|
|
335
|
+
break;
|
|
336
|
+
case 'bottom-start':
|
|
337
|
+
return positionStrategy.bottom(pos).left(gap + 'px');
|
|
338
|
+
break;
|
|
339
|
+
case 'top-center':
|
|
340
|
+
return positionStrategy.top(pos).centerHorizontally();
|
|
341
|
+
break;
|
|
342
|
+
case 'top-end':
|
|
343
|
+
return positionStrategy.top(pos).right(gap + 'px');
|
|
344
|
+
break;
|
|
345
|
+
case 'top-start':
|
|
346
|
+
return positionStrategy.top(pos).left(gap + 'px');
|
|
347
|
+
break;
|
|
348
|
+
case 'center-start':
|
|
349
|
+
return positionStrategy.centerVertically().left(gap + 'px');
|
|
350
|
+
break;
|
|
351
|
+
case 'center-end':
|
|
352
|
+
return positionStrategy.centerVertically().right(gap + 'px');
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXNotificationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
357
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXNotificationService, providedIn: 'root' }); }
|
|
358
|
+
}
|
|
359
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AXNotificationService, decorators: [{
|
|
360
|
+
type: Injectable,
|
|
361
|
+
args: [{
|
|
362
|
+
providedIn: 'root',
|
|
363
|
+
}]
|
|
364
|
+
}] });
|
|
365
|
+
|
|
483
366
|
/**
|
|
484
367
|
* Generated bundle index. Do not edit.
|
|
485
368
|
*/
|