@memberjunction/ng-notifications 6.1.0-edge.1 → 6.1.0-edge.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/LICENSE
CHANGED
|
@@ -1,7 +1,183 @@
|
|
|
1
|
-
|
|
1
|
+
Business Source License 1.1
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
License text copyright (c) 2024 MariaDB plc, All Rights Reserved.
|
|
4
|
+
"Business Source License" is a trademark of MariaDB plc.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
-----------------------------------------------------------------------------
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
Parameters
|
|
9
|
+
|
|
10
|
+
Licensor: Blue Cypress, Inc.
|
|
11
|
+
|
|
12
|
+
Licensed Work: MemberJunction.
|
|
13
|
+
The Licensed Work is (c) 2023-2026 Blue Cypress, Inc.
|
|
14
|
+
|
|
15
|
+
Additional Use Grant: Subject to the terms of this License, Licensor grants
|
|
16
|
+
you the following additional rights to make Production
|
|
17
|
+
Use of the Licensed Work.
|
|
18
|
+
|
|
19
|
+
1. Internal Use
|
|
20
|
+
|
|
21
|
+
You may make production use of the Licensed Work for
|
|
22
|
+
your own internal business or organizational operations.
|
|
23
|
+
|
|
24
|
+
2. Nonprofit Use
|
|
25
|
+
|
|
26
|
+
If you are a Nonprofit, you may make production use of
|
|
27
|
+
the Licensed Work for the operations and activities of
|
|
28
|
+
your Organizational Family.
|
|
29
|
+
|
|
30
|
+
3. MemberJunction Certified Program Use
|
|
31
|
+
|
|
32
|
+
If you are authorized by Licensor under the
|
|
33
|
+
MemberJunction Certified Program to provide professional
|
|
34
|
+
services using the Licensed Work, you may make
|
|
35
|
+
production use of the Licensed Work in providing such
|
|
36
|
+
professional services to a client, provided that:
|
|
37
|
+
|
|
38
|
+
(a) the Licensed Work is deployed in, and the applicable
|
|
39
|
+
production use occurs within, an environment owned,
|
|
40
|
+
leased, licensed, subscribed to, or otherwise controlled
|
|
41
|
+
by that client; and
|
|
42
|
+
|
|
43
|
+
(b) the production use is for that client's own internal
|
|
44
|
+
business or organizational operations or is otherwise
|
|
45
|
+
independently permitted to that client under this
|
|
46
|
+
Additional Use Grant.
|
|
47
|
+
|
|
48
|
+
4. Definitions Applicable to the Additional Use Grant
|
|
49
|
+
|
|
50
|
+
"Affiliate" means, with respect to a specified Person,
|
|
51
|
+
any other Person that directly or indirectly Controls,
|
|
52
|
+
is Controlled by, or is under common Control with such
|
|
53
|
+
specified Person.
|
|
54
|
+
|
|
55
|
+
"Control" (including the terms "Controls," "Controlled
|
|
56
|
+
by," and "under common Control with") means the direct
|
|
57
|
+
or indirect possession of the power to direct or cause
|
|
58
|
+
the direction of the management and policies of a
|
|
59
|
+
Person, whether through ownership of voting interests,
|
|
60
|
+
by contract, or otherwise.
|
|
61
|
+
|
|
62
|
+
"Organizational Family" means, with respect to a Person,
|
|
63
|
+
(a) such Person and its Affiliates, and (b) any
|
|
64
|
+
nonprofit organization, governmental entity, chapter,
|
|
65
|
+
division, local affiliate, regional affiliate, state
|
|
66
|
+
affiliate, national affiliate, or other entity that is
|
|
67
|
+
formally affiliated with such Person through governing
|
|
68
|
+
documents, a charter, bylaws, a membership agreement, or
|
|
69
|
+
another written organizational instrument, and is
|
|
70
|
+
recognized under such documents as part of the same
|
|
71
|
+
organizational structure.
|
|
72
|
+
|
|
73
|
+
"Nonprofit" means a Person recognized by the Internal
|
|
74
|
+
Revenue Service as exempt from federal income taxation
|
|
75
|
+
under Section 501(c)(3), 501(c)(4), 501(c)(5), or
|
|
76
|
+
501(c)(6) of the Internal Revenue Code, or a foreign
|
|
77
|
+
organization recognized under substantially equivalent
|
|
78
|
+
laws.
|
|
79
|
+
|
|
80
|
+
A Person claiming eligibility as a Nonprofit shall, upon
|
|
81
|
+
Licensor's reasonable request, provide documentation
|
|
82
|
+
reasonably sufficient to demonstrate that it qualifies
|
|
83
|
+
as a Nonprofit. If such Person materially misrepresents,
|
|
84
|
+
or is unable to demonstrate, its qualification as a
|
|
85
|
+
Nonprofit, the rights granted to such Person under
|
|
86
|
+
Section 2 of this Additional Use Grant shall terminate.
|
|
87
|
+
|
|
88
|
+
"MemberJunction Certified Program" means Licensor's
|
|
89
|
+
then-current program for certifying and authorizing a
|
|
90
|
+
Person to provide professional services using the
|
|
91
|
+
Licensed Work.
|
|
92
|
+
|
|
93
|
+
"Person" means any individual, corporation, limited
|
|
94
|
+
liability company, partnership, association, nonprofit
|
|
95
|
+
organization, governmental entity, or other legal or
|
|
96
|
+
organizational entity.
|
|
97
|
+
|
|
98
|
+
Change Date: Four (4) years from the date the Licensed Work is first
|
|
99
|
+
made available.
|
|
100
|
+
|
|
101
|
+
Change License: MIT License.
|
|
102
|
+
|
|
103
|
+
For information about alternative licensing arrangements for the Licensed
|
|
104
|
+
Work, please contact Blue Cypress, Inc.
|
|
105
|
+
|
|
106
|
+
-----------------------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
Terms
|
|
109
|
+
|
|
110
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
111
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
112
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
113
|
+
production use.
|
|
114
|
+
|
|
115
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
116
|
+
available distribution of a specific version of the Licensed Work under this
|
|
117
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
118
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
119
|
+
above terminate.
|
|
120
|
+
|
|
121
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
122
|
+
currently in effect as described in this License, you must purchase a
|
|
123
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
124
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
125
|
+
|
|
126
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
127
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
128
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
129
|
+
for each version of the Licensed Work released by Licensor.
|
|
130
|
+
|
|
131
|
+
You must conspicuously display this License on each original or modified copy
|
|
132
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
133
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
134
|
+
License apply to your use of that work.
|
|
135
|
+
|
|
136
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
137
|
+
terminate your rights under this License for the current and all other
|
|
138
|
+
versions of the Licensed Work.
|
|
139
|
+
|
|
140
|
+
This License does not grant you any right in any trademark or logo of
|
|
141
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
142
|
+
Licensor as expressly required by this License).
|
|
143
|
+
|
|
144
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
145
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
146
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
147
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
148
|
+
TITLE.
|
|
149
|
+
|
|
150
|
+
MariaDB hereby grants you permission to use this License's text to license
|
|
151
|
+
your works, and to refer to it using the trademark "Business Source License",
|
|
152
|
+
as long as you comply with the Covenants of Licensor below.
|
|
153
|
+
|
|
154
|
+
-----------------------------------------------------------------------------
|
|
155
|
+
|
|
156
|
+
Covenants of Licensor
|
|
157
|
+
|
|
158
|
+
In consideration of the right to use this License's text and the "Business
|
|
159
|
+
Source License" name and trademark, Licensor covenants to MariaDB, and to all
|
|
160
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
161
|
+
|
|
162
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
163
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
164
|
+
where "compatible" means that software provided under the Change License
|
|
165
|
+
can be included in a program with software provided under GPL Version 2.0
|
|
166
|
+
or a later version. Licensor may specify additional Change Licenses without
|
|
167
|
+
limitation.
|
|
168
|
+
|
|
169
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
170
|
+
impose any additional restriction on the right granted in this License, as
|
|
171
|
+
the Additional Use Grant; or (b) insert the text "None".
|
|
172
|
+
|
|
173
|
+
3. To specify a Change Date.
|
|
174
|
+
|
|
175
|
+
4. Not to modify this License in any other way.
|
|
176
|
+
|
|
177
|
+
-----------------------------------------------------------------------------
|
|
178
|
+
|
|
179
|
+
Notice
|
|
180
|
+
|
|
181
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
182
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
183
|
+
under an Open Source License, as stated in this License.
|
|
@@ -94,10 +94,10 @@ export declare class MJNotificationService {
|
|
|
94
94
|
static UpdateNotificationObservables(): void;
|
|
95
95
|
/**
|
|
96
96
|
* Creates a message that is not saved to the User Notifications table, but is displayed to the user.
|
|
97
|
-
* Uses a lightweight DOM-based toast notification.
|
|
97
|
+
* Uses a lightweight DOM-based toast notification styled with MemberJunction design tokens.
|
|
98
98
|
* @param message - text to display
|
|
99
|
-
* @param style - display styling
|
|
100
|
-
* @param hideAfter - option to auto hide after the specified delay in milliseconds
|
|
99
|
+
* @param style - display styling ('none' | 'success' | 'error' | 'warning' | 'info')
|
|
100
|
+
* @param hideAfter - option to auto hide after the specified delay in milliseconds (defaults to 3500-5000ms based on style; pass 0 to disable auto-hide)
|
|
101
101
|
*/
|
|
102
102
|
CreateSimpleNotification(message: string, style?: "none" | "success" | "error" | "warning" | "info", hideAfter?: number): void;
|
|
103
103
|
/**
|
|
@@ -105,7 +105,7 @@ export declare class MJNotificationService {
|
|
|
105
105
|
*/
|
|
106
106
|
private ensureToastContainer;
|
|
107
107
|
/**
|
|
108
|
-
* Shows a
|
|
108
|
+
* Shows a modern card toast notification using DOM elements and MJ design tokens.
|
|
109
109
|
*/
|
|
110
110
|
private showToast;
|
|
111
111
|
/**
|
|
@@ -1 +1 @@
|
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is not saved to the User Notifications table, but is displayed to the user.
|
|
224
|
-
* Uses a lightweight DOM-based toast notification.
|
|
224
|
+
* Uses a lightweight DOM-based toast notification styled with MemberJunction design tokens.
|
|
225
225
|
* @param message - text to display
|
|
226
|
-
* @param style - display styling
|
|
227
|
-
* @param hideAfter - option to auto hide after the specified delay in milliseconds
|
|
226
|
+
* @param style - display styling ('none' | 'success' | 'error' | 'warning' | 'info')
|
|
227
|
+
* @param hideAfter - option to auto hide after the specified delay in milliseconds (defaults to 3500-5000ms based on style; pass 0 to disable auto-hide)
|
|
228
228
|
*/
|
|
229
229
|
CreateSimpleNotification(message, style = "success", hideAfter) {
|
|
230
|
-
|
|
230
|
+
const defaultHide = style === 'error' ? 5000 : style === 'warning' ? 4500 : 3500;
|
|
231
|
+
const effectiveHideAfter = hideAfter !== undefined ? hideAfter : defaultHide;
|
|
232
|
+
this.showToast(message, style, effectiveHideAfter);
|
|
231
233
|
}
|
|
232
234
|
/**
|
|
233
235
|
* Ensures the toast container element exists in the DOM.
|
|
@@ -238,68 +240,118 @@ export class MJNotificationService {
|
|
|
238
240
|
container = document.createElement('div');
|
|
239
241
|
container.id = 'mj-toast-container';
|
|
240
242
|
container.style.cssText = `
|
|
241
|
-
position: fixed;
|
|
242
|
-
|
|
243
|
+
position: fixed;
|
|
244
|
+
top: 24px;
|
|
245
|
+
right: 24px;
|
|
246
|
+
z-index: 100000;
|
|
247
|
+
display: flex;
|
|
248
|
+
flex-direction: column;
|
|
249
|
+
align-items: flex-end;
|
|
250
|
+
gap: 10px;
|
|
243
251
|
pointer-events: none;
|
|
252
|
+
max-width: calc(100vw - 48px);
|
|
244
253
|
`;
|
|
245
254
|
document.body.appendChild(container);
|
|
246
255
|
}
|
|
247
256
|
return container;
|
|
248
257
|
}
|
|
249
258
|
/**
|
|
250
|
-
* Shows a
|
|
259
|
+
* Shows a modern card toast notification using DOM elements and MJ design tokens.
|
|
251
260
|
*/
|
|
252
261
|
showToast(message, style, hideAfter) {
|
|
253
262
|
const container = this.ensureToastContainer();
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
`;
|
|
261
|
-
const bgColors = {
|
|
262
|
-
success: 'var(--mj-status-success)',
|
|
263
|
-
error: 'var(--mj-status-error)',
|
|
264
|
-
warning: 'var(--mj-status-warning)',
|
|
265
|
-
info: 'var(--mj-status-info)',
|
|
266
|
-
none: 'var(--mj-text-secondary)'
|
|
263
|
+
const statusColors = {
|
|
264
|
+
success: 'var(--mj-status-success, #10b981)',
|
|
265
|
+
error: 'var(--mj-status-error, #ef4444)',
|
|
266
|
+
warning: 'var(--mj-status-warning, #f59e0b)',
|
|
267
|
+
info: 'var(--mj-status-info, #3b82f6)',
|
|
268
|
+
none: 'var(--mj-brand-primary, #6366f1)',
|
|
267
269
|
};
|
|
268
|
-
|
|
270
|
+
const accentColor = statusColors[style] || statusColors['none'];
|
|
269
271
|
const iconMap = {
|
|
270
|
-
success:
|
|
271
|
-
error:
|
|
272
|
-
warning:
|
|
273
|
-
info:
|
|
274
|
-
none:
|
|
275
|
-
};
|
|
276
|
-
const icon = iconMap[style] || '';
|
|
277
|
-
const removeToast = () => {
|
|
278
|
-
toast.style.animation = 'mj-toast-slide-out 0.3s ease-in forwards';
|
|
279
|
-
toast.addEventListener('animationend', () => toast.remove());
|
|
272
|
+
success: `<div style="width: 28px; height: 28px; border-radius: 50%; background: color-mix(in srgb, var(--mj-status-success, #10b981) 14%, transparent); display: flex; align-items: center; justify-content: center; color: var(--mj-status-success, #10b981); flex-shrink: 0;"><i class="fa-solid fa-circle-check" style="font-size: 15px;"></i></div>`,
|
|
273
|
+
error: `<div style="width: 28px; height: 28px; border-radius: 50%; background: color-mix(in srgb, var(--mj-status-error, #ef4444) 14%, transparent); display: flex; align-items: center; justify-content: center; color: var(--mj-status-error, #ef4444); flex-shrink: 0;"><i class="fa-solid fa-circle-xmark" style="font-size: 15px;"></i></div>`,
|
|
274
|
+
warning: `<div style="width: 28px; height: 28px; border-radius: 50%; background: color-mix(in srgb, var(--mj-status-warning, #f59e0b) 14%, transparent); display: flex; align-items: center; justify-content: center; color: var(--mj-status-warning, #f59e0b); flex-shrink: 0;"><i class="fa-solid fa-triangle-exclamation" style="font-size: 14px;"></i></div>`,
|
|
275
|
+
info: `<div style="width: 28px; height: 28px; border-radius: 50%; background: color-mix(in srgb, var(--mj-status-info, #3b82f6) 14%, transparent); display: flex; align-items: center; justify-content: center; color: var(--mj-status-info, #3b82f6); flex-shrink: 0;"><i class="fa-solid fa-circle-info" style="font-size: 15px;"></i></div>`,
|
|
276
|
+
none: `<div style="width: 28px; height: 28px; border-radius: 50%; background: color-mix(in srgb, var(--mj-brand-primary, #6366f1) 14%, transparent); display: flex; align-items: center; justify-content: center; color: var(--mj-brand-primary, #6366f1); flex-shrink: 0;"><i class="fa-solid fa-bell" style="font-size: 14px;"></i></div>`,
|
|
280
277
|
};
|
|
278
|
+
const iconHtml = iconMap[style] || iconMap['none'];
|
|
279
|
+
const toast = document.createElement('div');
|
|
280
|
+
toast.className = `mj-toast-item mj-toast--${style}`;
|
|
281
|
+
toast.style.cssText = `
|
|
282
|
+
pointer-events: auto;
|
|
283
|
+
min-width: 300px;
|
|
284
|
+
max-width: 460px;
|
|
285
|
+
padding: 12px 16px;
|
|
286
|
+
border-radius: var(--mj-radius-md, 8px);
|
|
287
|
+
background: var(--mj-bg-surface, #ffffff);
|
|
288
|
+
color: var(--mj-text-primary, #1e293b);
|
|
289
|
+
border: 1px solid var(--mj-border-subtle, rgba(0, 0, 0, 0.08));
|
|
290
|
+
border-left: 4px solid ${accentColor};
|
|
291
|
+
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
|
|
292
|
+
display: flex;
|
|
293
|
+
align-items: center;
|
|
294
|
+
gap: 12px;
|
|
295
|
+
font-family: inherit;
|
|
296
|
+
font-size: 0.88rem;
|
|
297
|
+
line-height: 1.4;
|
|
298
|
+
backdrop-filter: blur(12px);
|
|
299
|
+
-webkit-backdrop-filter: blur(12px);
|
|
300
|
+
animation: mj-toast-slide-in 0.28s cubic-bezier(0.16, 1, 0.3, 1);
|
|
301
|
+
transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
|
|
302
|
+
`;
|
|
281
303
|
toast.innerHTML = `
|
|
282
|
-
${
|
|
283
|
-
<
|
|
284
|
-
|
|
304
|
+
${iconHtml}
|
|
305
|
+
<div style="flex: 1; font-weight: 500; font-size: 0.84rem; color: var(--mj-text-primary, #1e293b); word-break: break-word;">${this.escapeHtml(message)}</div>
|
|
306
|
+
<button type="button" class="mj-toast-close" style="background: transparent; border: none; padding: 4px 6px; border-radius: 4px; color: var(--mj-text-muted, #94a3b8); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 13px; line-height: 1; transition: color 0.15s ease;" aria-label="Close">
|
|
307
|
+
<i class="fa-solid fa-xmark"></i>
|
|
308
|
+
</button>
|
|
285
309
|
`;
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
310
|
+
const closeBtn = toast.querySelector('.mj-toast-close');
|
|
311
|
+
const removeToast = () => {
|
|
312
|
+
toast.style.animation = 'mj-toast-slide-out 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards';
|
|
313
|
+
toast.addEventListener('animationend', () => toast.remove(), { once: true });
|
|
314
|
+
};
|
|
315
|
+
closeBtn?.addEventListener('click', removeToast);
|
|
316
|
+
closeBtn?.addEventListener('mouseenter', () => {
|
|
317
|
+
closeBtn.style.color = 'var(--mj-text-primary, #1e293b)';
|
|
318
|
+
closeBtn.style.backgroundColor = 'var(--mj-bg-surface-sunken, #f1f5f9)';
|
|
319
|
+
});
|
|
320
|
+
closeBtn?.addEventListener('mouseleave', () => {
|
|
321
|
+
closeBtn.style.color = 'var(--mj-text-muted, #94a3b8)';
|
|
322
|
+
closeBtn.style.backgroundColor = 'transparent';
|
|
323
|
+
});
|
|
290
324
|
container.appendChild(toast);
|
|
291
325
|
// Inject keyframes if not already present
|
|
292
326
|
if (!document.getElementById('mj-toast-keyframes')) {
|
|
293
327
|
const styleEl = document.createElement('style');
|
|
294
328
|
styleEl.id = 'mj-toast-keyframes';
|
|
295
329
|
styleEl.textContent = `
|
|
296
|
-
@keyframes mj-toast-slide-in {
|
|
297
|
-
|
|
330
|
+
@keyframes mj-toast-slide-in {
|
|
331
|
+
from { opacity: 0; transform: translateY(-12px) scale(0.96); }
|
|
332
|
+
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
333
|
+
}
|
|
334
|
+
@keyframes mj-toast-slide-out {
|
|
335
|
+
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
336
|
+
to { opacity: 0; transform: translateY(-12px) scale(0.96); }
|
|
337
|
+
}
|
|
298
338
|
`;
|
|
299
339
|
document.head.appendChild(styleEl);
|
|
300
340
|
}
|
|
301
|
-
|
|
302
|
-
|
|
341
|
+
// Auto-hide with hover-pause support
|
|
342
|
+
if (hideAfter > 0) {
|
|
343
|
+
let timer = setTimeout(removeToast, hideAfter);
|
|
344
|
+
toast.addEventListener('mouseenter', () => {
|
|
345
|
+
if (timer) {
|
|
346
|
+
clearTimeout(timer);
|
|
347
|
+
timer = null;
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
toast.addEventListener('mouseleave', () => {
|
|
351
|
+
if (!timer) {
|
|
352
|
+
timer = setTimeout(removeToast, 2000);
|
|
353
|
+
}
|
|
354
|
+
});
|
|
303
355
|
}
|
|
304
356
|
}
|
|
305
357
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.service.js","sourceRoot":"","sources":["../../src/lib/notifications.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAqB,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAAE,cAAc,EAA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C,WAAW,GAAG,IAAI,CAAC;QACvB,OAAO,GAAG,CAAC,SAAS,CAAC;IACvB,CAAC;+GAvVU,qBAAqB;gEAArB,qBAAqB,WAArB,qBAAqB,mBAFpB,MAAM;;iFAEP,qBAAqB;cAHjC,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB","sourcesContent":["import { Injectable } from '@angular/core';\nimport { IMetadataProvider, LogError, Metadata, StartupManager } from '@memberjunction/core';\nimport { UserInfoEngine, MJUserNotificationEntity } from '@memberjunction/core-entities';\nimport { DisplaySimpleNotificationRequestData, MJEventType, MJGlobal, GetGlobalObjectStore } from '@memberjunction/global';\nimport { GraphQLDataProvider } from '@memberjunction/graphql-dataprovider';\nimport { BehaviorSubject, Observable, Subject } from 'rxjs';\nimport { map, shareReplay } from 'rxjs/operators';\n\n/**\n * This injectable service is also available as a singleton MJNotificationService.Instance globally within an Angular application/library process space. It is responsible for displaying notifications to the user and also is able to manage the User Notifications entity\n * in the database.\n */\n/**\n * Multi-provider note: callers under a non-default provider should set\n * `service.Provider = component.ProviderToUse` before invoking any methods.\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class MJNotificationService {\n private static readonly _globalStoreKey = '___SINGLETON__MJNotificationService';\n private static _loaded: boolean = false;\n\n private _provider: IMetadataProvider | null = null;\n public get Provider(): IMetadataProvider {\n return this._provider ?? Metadata.Provider;\n }\n public set Provider(value: IMetadataProvider | null) {\n this._provider = value;\n }\n\n private static isLoading$ = new BehaviorSubject<boolean>(false);\n private tabChange = new Subject();\n tabChange$ = this.tabChange.asObservable();\n\n /**\n * Observable stream of the current user's notifications, derived from\n * UserInfoEngine.UserNotifications$. Emits immediately on subscribe (shareReplay\n * buffers the latest value) and re-emits whenever the engine's notifications\n * cache is mutated — by save, delete, remote-invalidate, or refresh. Each\n * emission re-runs the engine's per-user filter+sort.\n */\n public static readonly Notifications$: Observable<MJUserNotificationEntity[]> =\n UserInfoEngine.Instance.UserNotifications$.pipe(\n map(() => UserInfoEngine.Instance.UserNotifications),\n shareReplay({ bufferSize: 1, refCount: false })\n );\n\n /**\n * Observable stream of the current user's unread notification count, derived\n * from Notifications$. Same emission lifecycle as Notifications$.\n */\n public static readonly UnreadCount$: Observable<number> =\n MJNotificationService.Notifications$.pipe(\n map((arr) => arr.filter((n) => n.Unread).length),\n shareReplay({ bufferSize: 1, refCount: false })\n );\n\n /**\n * Optional callback that consuming apps can set to suppress toast notifications\n * for specific events (e.g., when the user is actively viewing the conversation\n * that triggered the notification). Return true to suppress the toast.\n * The notification DB record is still created and the badge count still updates.\n */\n public ShouldSuppressToast?: (statusObj: Record<string, unknown>) => boolean;\n\n constructor() {\n const g = GetGlobalObjectStore()!;\n if (g[MJNotificationService._globalStoreKey]) {\n return g[MJNotificationService._globalStoreKey] as MJNotificationService;\n }\n g[MJNotificationService._globalStoreKey] = this;\n\n MJGlobal.Instance.GetEventListener(true).subscribe( (event) => {\n switch (event.event) {\n case MJEventType.DisplaySimpleNotificationRequest: \n // received the message to display a notification to the user, so do that...\n const messageData: DisplaySimpleNotificationRequestData = <DisplaySimpleNotificationRequestData>event.args;\n this.CreateSimpleNotification(messageData.message,messageData.style, messageData.DisplayDuration);\n break;\n case MJEventType.ComponentEvent:\n if (event.eventCode === \"UserNotificationsUpdated\") {\n // refresh the user notifications\n MJNotificationService.RefreshUserNotifications();\n }\n break;\n case MJEventType.LoggedIn:\n if (MJNotificationService._loaded === false) {\n // Wait for StartupManager to complete before refreshing notifications.\n // UserInfoEngine (which backs RefreshUserNotifications) is @RegisterForStartup\n // and its _metadataConfigs are only populated during Config() which runs\n // as part of StartupManager.Startup(). Calling RefreshItem() before that\n // completes would silently find no config and return nothing.\n StartupManager.Instance.Startup().then(() => {\n MJNotificationService.RefreshUserNotifications();\n });\n }\n\n // Notifications$ / UnreadCount$ are derived from UserInfoEngine.UserNotifications$\n // at static-init time, so they auto-update whenever the engine's cache mutates.\n // No per-login subscription wiring is needed.\n\n // got the login, now subscribe to push status updates here so we can then raise them as events in MJ Global locally\n this.PushStatusUpdates().subscribe( (message: string) => {\n // Handle undefined/null messages gracefully\n if (!message) {\n return;\n }\n\n const statusObj = JSON.parse(message);\n\n // pass along as an event so anyone else who wants to know about the push status update can do stuff\n MJGlobal.Instance.RaiseEvent({\n event: MJEventType.ComponentEvent,\n eventCode: \"PushStatusUpdates\",\n args: statusObj,\n component: this\n })\n\n const type = statusObj.type?.trim().toLowerCase();\n if (type === 'notification' || type === 'usernotifications') {\n // Server sends type:'notification', legacy used 'usernotifications' — support both\n const action = statusObj.action?.trim().toLowerCase()\n || statusObj.details?.action?.trim().toLowerCase();\n if (action === 'create') {\n // Check if the consuming app wants to suppress this toast\n // (e.g., user is actively viewing the conversation that triggered it)\n const suppress = this.ShouldSuppressToast?.(statusObj) ?? false;\n if (!suppress) {\n this.CreateSimpleNotification(statusObj.title || 'New Notification Available', \"success\", 3000);\n }\n // Always refresh the notification list (badge count, unread state)\n MJNotificationService.RefreshUserNotifications();\n }\n }\n else {\n // otherwise just post it as a simple notification, except Skip messages, we will let Skip handle those.\n // 'realtimedelegationprogress' carries a per-step message that the voice session consumes + narrates\n // itself — it must NOT raise a toast (otherwise a live voice call spams a toast per progress step).\n if (type !== 'askskip' && type !== 'entityobjectstatusmessage' && type !== 'realtimedelegationprogress' && typeof statusObj.message === 'string') {\n this.CreateSimpleNotification(statusObj.message, \"success\", 2500);\n }\n }\n });\n break;\n } \n });\n }\n\n public PushStatusUpdates(): Observable<string> {\n const gp: GraphQLDataProvider = <GraphQLDataProvider><unknown>this.Provider;\n return gp.PushStatusUpdates();\n }\n\n public static get Instance(): MJNotificationService {\n return GetGlobalObjectStore()![MJNotificationService._globalStoreKey] as MJNotificationService;\n }\n \n /**\n * The current user's notifications, delegated to UserInfoEngine which owns the\n * cache. Applies the per-user filter and newest-first sort on each access.\n */\n public static get UserNotifications(): MJUserNotificationEntity[] {\n return UserInfoEngine.Instance.UserNotifications;\n }\n\n /**\n * The current user's unread notifications, delegated to UserInfoEngine.\n */\n public static get UnreadUserNotifications(): MJUserNotificationEntity[] {\n return UserInfoEngine.Instance.UnreadNotifications;\n }\n\n /**\n * The current user's unread notification count, delegated to UserInfoEngine.\n */\n public static get UnreadUserNotificationCount(): number {\n return UserInfoEngine.Instance.UnreadNotificationCount;\n }\n\n /**\n * Instance method to access Notifications$ observable\n */\n public get notifications$(): Observable<MJUserNotificationEntity[]> {\n return MJNotificationService.Notifications$;\n }\n\n /**\n * Instance method to access UnreadCount$ observable\n */\n public get unreadCount$(): Observable<number> {\n return MJNotificationService.UnreadCount$;\n }\n\n\n /**\n * Creates a user notification in the database and refreshes the UI. Returns the notification object.\n * @param title \n * @param message \n * @param resourceTypeId \n * @param resourceRecordId \n * @param resourceConfiguration Any object, it is converted to a string by JSON.stringify and stored in the database\n * @returns \n */\n public async CreateNotification(title: string, message: string, resourceTypeId: string | null, resourceRecordId: string | null, resourceConfiguration: any | null, displayToUser: boolean = true): Promise<MJUserNotificationEntity> {\n const md = this.Provider;\n const notification = <MJUserNotificationEntity>await md.GetEntityObject('MJ: User Notifications');\n notification.Title = title;\n notification.Message = message;\n if (resourceTypeId)\n notification.ResourceTypeID = resourceTypeId;\n if (resourceRecordId)\n notification.ResourceRecordID = resourceRecordId;\n if (resourceConfiguration)\n notification.ResourceConfiguration = JSON.stringify(resourceConfiguration);\n \n notification.UserID = md.CurrentUser.ID;\n notification.Unread = true;\n const result = await notification.Save();\n if (result) {\n MJNotificationService.RefreshUserNotifications();\n }\n\n if (displayToUser)\n this.CreateSimpleNotification(notification.Message, \"success\", 2500);\n\n return notification;\n }\n\n /**\n * Refresh user notifications from the server. Delegates to UserInfoEngine.RefreshItem,\n * whose successful reload mutates the engine's notifications cache and triggers an\n * emission on Notifications$/UnreadCount$ via the BaseEngine observable plumbing —\n * subscribers are updated automatically with no manual re-emit required here.\n *\n * Uses RefreshItem() rather than relying solely on the global CACHE_INVALIDATION\n * listener: when this method is called in response to a PushStatusUpdates message,\n * the cache-invalidation event may not have arrived yet (separate WebSocket message,\n * potential race). RefreshItem() eliminates that race by doing a targeted RunView\n * for just notifications.\n */\n public static async RefreshUserNotifications() {\n try {\n await UserInfoEngine.Instance.RefreshItem('_UserNotifications');\n MJNotificationService._loaded = true;\n }\n catch (e) {\n LogError(e);\n }\n }\n\n /**\n * @deprecated Kept as a no-op for backward compatibility. Observable emissions are now\n * driven by UserInfoEngine.UserNotifications$, which auto-emits on save/delete/\n * remote-invalidate/refresh. External callers no longer need to manually push updates.\n */\n public static UpdateNotificationObservables() {\n // No-op — see JSDoc above.\n }\n\n /**\n * Creates a message that is not saved to the User Notifications table, but is displayed to the user.\n * Uses a lightweight DOM-based toast notification.\n * @param message - text to display\n * @param style - display styling\n * @param hideAfter - option to auto hide after the specified delay in milliseconds\n */\n public CreateSimpleNotification(message: string, style: \"none\" | \"success\" | \"error\" | \"warning\" | \"info\" = \"success\", hideAfter?: number) {\n this.showToast(message, style, hideAfter);\n }\n\n /**\n * Ensures the toast container element exists in the DOM.\n */\n private ensureToastContainer(): HTMLElement {\n let container = document.getElementById('mj-toast-container');\n if (!container) {\n container = document.createElement('div');\n container.id = 'mj-toast-container';\n container.style.cssText = `\n position: fixed; top: 16px; left: 50%; transform: translateX(-50%);\n z-index: 100000; display: flex; flex-direction: column; align-items: center; gap: 8px;\n pointer-events: none;\n `;\n document.body.appendChild(container);\n }\n return container;\n }\n\n /**\n * Shows a lightweight toast notification using DOM elements.\n */\n private showToast(message: string, style: string, hideAfter?: number): void {\n const container = this.ensureToastContainer();\n\n const toast = document.createElement('div');\n toast.style.cssText = `\n pointer-events: auto; padding: 12px 20px; border-radius: 6px; font-size: 14px;\n font-family: inherit; max-width: 500px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);\n display: flex; align-items: center; gap: 8px; animation: mj-toast-slide-in 0.3s ease-out;\n color: var(--mj-text-inverse);\n `;\n\n const bgColors: Record<string, string> = {\n success: 'var(--mj-status-success)',\n error: 'var(--mj-status-error)',\n warning: 'var(--mj-status-warning)',\n info: 'var(--mj-status-info)',\n none: 'var(--mj-text-secondary)'\n };\n toast.style.backgroundColor = bgColors[style] || bgColors['none'];\n\n const iconMap: Record<string, string> = {\n success: '\\u2713',\n error: '\\u2717',\n warning: '\\u26A0',\n info: '\\u2139',\n none: ''\n };\n const icon = iconMap[style] || '';\n\n const removeToast = () => {\n toast.style.animation = 'mj-toast-slide-out 0.3s ease-in forwards';\n toast.addEventListener('animationend', () => toast.remove());\n };\n\n toast.innerHTML = `\n ${icon ? `<span style=\"font-size:16px;font-weight:bold;\">${icon}</span>` : ''}\n <span style=\"flex:1;\">${this.escapeHtml(message)}</span>\n ${!hideAfter ? `<button style=\"background:none;border:none;color:var(--mj-text-inverse);cursor:pointer;font-size:18px;padding:0 0 0 8px;line-height:1;\" aria-label=\"Close\">×</button>` : ''}\n `;\n\n if (!hideAfter) {\n const closeBtn = toast.querySelector('button');\n closeBtn?.addEventListener('click', removeToast);\n }\n\n container.appendChild(toast);\n\n // Inject keyframes if not already present\n if (!document.getElementById('mj-toast-keyframes')) {\n const styleEl = document.createElement('style');\n styleEl.id = 'mj-toast-keyframes';\n styleEl.textContent = `\n @keyframes mj-toast-slide-in { from { opacity:0; transform:translateY(-20px); } to { opacity:1; transform:translateY(0); } }\n @keyframes mj-toast-slide-out { from { opacity:1; transform:translateY(0); } to { opacity:0; transform:translateY(-20px); } }\n `;\n document.head.appendChild(styleEl);\n }\n\n if (hideAfter) {\n setTimeout(removeToast, hideAfter);\n }\n }\n\n /**\n * Escapes HTML entities to prevent XSS in toast messages.\n */\n private escapeHtml(text: string): string {\n const div = document.createElement('div');\n div.textContent = text;\n return div.innerHTML;\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"notifications.service.js","sourceRoot":"","sources":["../../src/lib/notifications.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAqB,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC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BAAqB;cAHjC,UAAU;eAAC;gBACV,UAAU,EAAE,MAAM;aACnB","sourcesContent":["import { Injectable } from '@angular/core';\nimport { IMetadataProvider, LogError, Metadata, StartupManager } from '@memberjunction/core';\nimport { UserInfoEngine, MJUserNotificationEntity } from '@memberjunction/core-entities';\nimport { DisplaySimpleNotificationRequestData, MJEventType, MJGlobal, GetGlobalObjectStore } from '@memberjunction/global';\nimport { GraphQLDataProvider } from '@memberjunction/graphql-dataprovider';\nimport { BehaviorSubject, Observable, Subject } from 'rxjs';\nimport { map, shareReplay } from 'rxjs/operators';\n\n/**\n * This injectable service is also available as a singleton MJNotificationService.Instance globally within an Angular application/library process space. It is responsible for displaying notifications to the user and also is able to manage the User Notifications entity\n * in the database.\n */\n/**\n * Multi-provider note: callers under a non-default provider should set\n * `service.Provider = component.ProviderToUse` before invoking any methods.\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class MJNotificationService {\n private static readonly _globalStoreKey = '___SINGLETON__MJNotificationService';\n private static _loaded: boolean = false;\n\n private _provider: IMetadataProvider | null = null;\n public get Provider(): IMetadataProvider {\n return this._provider ?? Metadata.Provider;\n }\n public set Provider(value: IMetadataProvider | null) {\n this._provider = value;\n }\n\n private static isLoading$ = new BehaviorSubject<boolean>(false);\n private tabChange = new Subject();\n tabChange$ = this.tabChange.asObservable();\n\n /**\n * Observable stream of the current user's notifications, derived from\n * UserInfoEngine.UserNotifications$. Emits immediately on subscribe (shareReplay\n * buffers the latest value) and re-emits whenever the engine's notifications\n * cache is mutated — by save, delete, remote-invalidate, or refresh. Each\n * emission re-runs the engine's per-user filter+sort.\n */\n public static readonly Notifications$: Observable<MJUserNotificationEntity[]> =\n UserInfoEngine.Instance.UserNotifications$.pipe(\n map(() => UserInfoEngine.Instance.UserNotifications),\n shareReplay({ bufferSize: 1, refCount: false })\n );\n\n /**\n * Observable stream of the current user's unread notification count, derived\n * from Notifications$. Same emission lifecycle as Notifications$.\n */\n public static readonly UnreadCount$: Observable<number> =\n MJNotificationService.Notifications$.pipe(\n map((arr) => arr.filter((n) => n.Unread).length),\n shareReplay({ bufferSize: 1, refCount: false })\n );\n\n /**\n * Optional callback that consuming apps can set to suppress toast notifications\n * for specific events (e.g., when the user is actively viewing the conversation\n * that triggered the notification). Return true to suppress the toast.\n * The notification DB record is still created and the badge count still updates.\n */\n public ShouldSuppressToast?: (statusObj: Record<string, unknown>) => boolean;\n\n constructor() {\n const g = GetGlobalObjectStore()!;\n if (g[MJNotificationService._globalStoreKey]) {\n return g[MJNotificationService._globalStoreKey] as MJNotificationService;\n }\n g[MJNotificationService._globalStoreKey] = this;\n\n MJGlobal.Instance.GetEventListener(true).subscribe( (event) => {\n switch (event.event) {\n case MJEventType.DisplaySimpleNotificationRequest: \n // received the message to display a notification to the user, so do that...\n const messageData: DisplaySimpleNotificationRequestData = <DisplaySimpleNotificationRequestData>event.args;\n this.CreateSimpleNotification(messageData.message,messageData.style, messageData.DisplayDuration);\n break;\n case MJEventType.ComponentEvent:\n if (event.eventCode === \"UserNotificationsUpdated\") {\n // refresh the user notifications\n MJNotificationService.RefreshUserNotifications();\n }\n break;\n case MJEventType.LoggedIn:\n if (MJNotificationService._loaded === false) {\n // Wait for StartupManager to complete before refreshing notifications.\n // UserInfoEngine (which backs RefreshUserNotifications) is @RegisterForStartup\n // and its _metadataConfigs are only populated during Config() which runs\n // as part of StartupManager.Startup(). Calling RefreshItem() before that\n // completes would silently find no config and return nothing.\n StartupManager.Instance.Startup().then(() => {\n MJNotificationService.RefreshUserNotifications();\n });\n }\n\n // Notifications$ / UnreadCount$ are derived from UserInfoEngine.UserNotifications$\n // at static-init time, so they auto-update whenever the engine's cache mutates.\n // No per-login subscription wiring is needed.\n\n // got the login, now subscribe to push status updates here so we can then raise them as events in MJ Global locally\n this.PushStatusUpdates().subscribe( (message: string) => {\n // Handle undefined/null messages gracefully\n if (!message) {\n return;\n }\n\n const statusObj = JSON.parse(message);\n\n // pass along as an event so anyone else who wants to know about the push status update can do stuff\n MJGlobal.Instance.RaiseEvent({\n event: MJEventType.ComponentEvent,\n eventCode: \"PushStatusUpdates\",\n args: statusObj,\n component: this\n })\n\n const type = statusObj.type?.trim().toLowerCase();\n if (type === 'notification' || type === 'usernotifications') {\n // Server sends type:'notification', legacy used 'usernotifications' — support both\n const action = statusObj.action?.trim().toLowerCase()\n || statusObj.details?.action?.trim().toLowerCase();\n if (action === 'create') {\n // Check if the consuming app wants to suppress this toast\n // (e.g., user is actively viewing the conversation that triggered it)\n const suppress = this.ShouldSuppressToast?.(statusObj) ?? false;\n if (!suppress) {\n this.CreateSimpleNotification(statusObj.title || 'New Notification Available', \"success\", 3000);\n }\n // Always refresh the notification list (badge count, unread state)\n MJNotificationService.RefreshUserNotifications();\n }\n }\n else {\n // otherwise just post it as a simple notification, except Skip messages, we will let Skip handle those.\n // 'realtimedelegationprogress' carries a per-step message that the voice session consumes + narrates\n // itself — it must NOT raise a toast (otherwise a live voice call spams a toast per progress step).\n if (type !== 'askskip' && type !== 'entityobjectstatusmessage' && type !== 'realtimedelegationprogress' && typeof statusObj.message === 'string') {\n this.CreateSimpleNotification(statusObj.message, \"success\", 2500);\n }\n }\n });\n break;\n } \n });\n }\n\n public PushStatusUpdates(): Observable<string> {\n const gp: GraphQLDataProvider = <GraphQLDataProvider><unknown>this.Provider;\n return gp.PushStatusUpdates();\n }\n\n public static get Instance(): MJNotificationService {\n return GetGlobalObjectStore()![MJNotificationService._globalStoreKey] as MJNotificationService;\n }\n \n /**\n * The current user's notifications, delegated to UserInfoEngine which owns the\n * cache. Applies the per-user filter and newest-first sort on each access.\n */\n public static get UserNotifications(): MJUserNotificationEntity[] {\n return UserInfoEngine.Instance.UserNotifications;\n }\n\n /**\n * The current user's unread notifications, delegated to UserInfoEngine.\n */\n public static get UnreadUserNotifications(): MJUserNotificationEntity[] {\n return UserInfoEngine.Instance.UnreadNotifications;\n }\n\n /**\n * The current user's unread notification count, delegated to UserInfoEngine.\n */\n public static get UnreadUserNotificationCount(): number {\n return UserInfoEngine.Instance.UnreadNotificationCount;\n }\n\n /**\n * Instance method to access Notifications$ observable\n */\n public get notifications$(): Observable<MJUserNotificationEntity[]> {\n return MJNotificationService.Notifications$;\n }\n\n /**\n * Instance method to access UnreadCount$ observable\n */\n public get unreadCount$(): Observable<number> {\n return MJNotificationService.UnreadCount$;\n }\n\n\n /**\n * Creates a user notification in the database and refreshes the UI. Returns the notification object.\n * @param title \n * @param message \n * @param resourceTypeId \n * @param resourceRecordId \n * @param resourceConfiguration Any object, it is converted to a string by JSON.stringify and stored in the database\n * @returns \n */\n public async CreateNotification(title: string, message: string, resourceTypeId: string | null, resourceRecordId: string | null, resourceConfiguration: any | null, displayToUser: boolean = true): Promise<MJUserNotificationEntity> {\n const md = this.Provider;\n const notification = <MJUserNotificationEntity>await md.GetEntityObject('MJ: User Notifications');\n notification.Title = title;\n notification.Message = message;\n if (resourceTypeId)\n notification.ResourceTypeID = resourceTypeId;\n if (resourceRecordId)\n notification.ResourceRecordID = resourceRecordId;\n if (resourceConfiguration)\n notification.ResourceConfiguration = JSON.stringify(resourceConfiguration);\n \n notification.UserID = md.CurrentUser.ID;\n notification.Unread = true;\n const result = await notification.Save();\n if (result) {\n MJNotificationService.RefreshUserNotifications();\n }\n\n if (displayToUser)\n this.CreateSimpleNotification(notification.Message, \"success\", 2500);\n\n return notification;\n }\n\n /**\n * Refresh user notifications from the server. Delegates to UserInfoEngine.RefreshItem,\n * whose successful reload mutates the engine's notifications cache and triggers an\n * emission on Notifications$/UnreadCount$ via the BaseEngine observable plumbing —\n * subscribers are updated automatically with no manual re-emit required here.\n *\n * Uses RefreshItem() rather than relying solely on the global CACHE_INVALIDATION\n * listener: when this method is called in response to a PushStatusUpdates message,\n * the cache-invalidation event may not have arrived yet (separate WebSocket message,\n * potential race). RefreshItem() eliminates that race by doing a targeted RunView\n * for just notifications.\n */\n public static async RefreshUserNotifications() {\n try {\n await UserInfoEngine.Instance.RefreshItem('_UserNotifications');\n MJNotificationService._loaded = true;\n }\n catch (e) {\n LogError(e);\n }\n }\n\n /**\n * @deprecated Kept as a no-op for backward compatibility. Observable emissions are now\n * driven by UserInfoEngine.UserNotifications$, which auto-emits on save/delete/\n * remote-invalidate/refresh. External callers no longer need to manually push updates.\n */\n public static UpdateNotificationObservables() {\n // No-op — see JSDoc above.\n }\n\n /**\n * Creates a message that is not saved to the User Notifications table, but is displayed to the user.\n * Uses a lightweight DOM-based toast notification styled with MemberJunction design tokens.\n * @param message - text to display\n * @param style - display styling ('none' | 'success' | 'error' | 'warning' | 'info')\n * @param hideAfter - option to auto hide after the specified delay in milliseconds (defaults to 3500-5000ms based on style; pass 0 to disable auto-hide)\n */\n public CreateSimpleNotification(\n message: string,\n style: \"none\" | \"success\" | \"error\" | \"warning\" | \"info\" = \"success\",\n hideAfter?: number\n ): void {\n const defaultHide = style === 'error' ? 5000 : style === 'warning' ? 4500 : 3500;\n const effectiveHideAfter = hideAfter !== undefined ? hideAfter : defaultHide;\n this.showToast(message, style, effectiveHideAfter);\n }\n\n /**\n * Ensures the toast container element exists in the DOM.\n */\n private ensureToastContainer(): HTMLElement {\n let container = document.getElementById('mj-toast-container');\n if (!container) {\n container = document.createElement('div');\n container.id = 'mj-toast-container';\n container.style.cssText = `\n position: fixed;\n top: 24px;\n right: 24px;\n z-index: 100000;\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n gap: 10px;\n pointer-events: none;\n max-width: calc(100vw - 48px);\n `;\n document.body.appendChild(container);\n }\n return container;\n }\n\n /**\n * Shows a modern card toast notification using DOM elements and MJ design tokens.\n */\n private showToast(message: string, style: string, hideAfter: number): void {\n const container = this.ensureToastContainer();\n\n const statusColors: Record<string, string> = {\n success: 'var(--mj-status-success, #10b981)',\n error: 'var(--mj-status-error, #ef4444)',\n warning: 'var(--mj-status-warning, #f59e0b)',\n info: 'var(--mj-status-info, #3b82f6)',\n none: 'var(--mj-brand-primary, #6366f1)',\n };\n const accentColor = statusColors[style] || statusColors['none'];\n\n const iconMap: Record<string, string> = {\n success: `<div style=\"width: 28px; height: 28px; border-radius: 50%; background: color-mix(in srgb, var(--mj-status-success, #10b981) 14%, transparent); display: flex; align-items: center; justify-content: center; color: var(--mj-status-success, #10b981); flex-shrink: 0;\"><i class=\"fa-solid fa-circle-check\" style=\"font-size: 15px;\"></i></div>`,\n error: `<div style=\"width: 28px; height: 28px; border-radius: 50%; background: color-mix(in srgb, var(--mj-status-error, #ef4444) 14%, transparent); display: flex; align-items: center; justify-content: center; color: var(--mj-status-error, #ef4444); flex-shrink: 0;\"><i class=\"fa-solid fa-circle-xmark\" style=\"font-size: 15px;\"></i></div>`,\n warning: `<div style=\"width: 28px; height: 28px; border-radius: 50%; background: color-mix(in srgb, var(--mj-status-warning, #f59e0b) 14%, transparent); display: flex; align-items: center; justify-content: center; color: var(--mj-status-warning, #f59e0b); flex-shrink: 0;\"><i class=\"fa-solid fa-triangle-exclamation\" style=\"font-size: 14px;\"></i></div>`,\n info: `<div style=\"width: 28px; height: 28px; border-radius: 50%; background: color-mix(in srgb, var(--mj-status-info, #3b82f6) 14%, transparent); display: flex; align-items: center; justify-content: center; color: var(--mj-status-info, #3b82f6); flex-shrink: 0;\"><i class=\"fa-solid fa-circle-info\" style=\"font-size: 15px;\"></i></div>`,\n none: `<div style=\"width: 28px; height: 28px; border-radius: 50%; background: color-mix(in srgb, var(--mj-brand-primary, #6366f1) 14%, transparent); display: flex; align-items: center; justify-content: center; color: var(--mj-brand-primary, #6366f1); flex-shrink: 0;\"><i class=\"fa-solid fa-bell\" style=\"font-size: 14px;\"></i></div>`,\n };\n const iconHtml = iconMap[style] || iconMap['none'];\n\n const toast = document.createElement('div');\n toast.className = `mj-toast-item mj-toast--${style}`;\n toast.style.cssText = `\n pointer-events: auto;\n min-width: 300px;\n max-width: 460px;\n padding: 12px 16px;\n border-radius: var(--mj-radius-md, 8px);\n background: var(--mj-bg-surface, #ffffff);\n color: var(--mj-text-primary, #1e293b);\n border: 1px solid var(--mj-border-subtle, rgba(0, 0, 0, 0.08));\n border-left: 4px solid ${accentColor};\n box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);\n display: flex;\n align-items: center;\n gap: 12px;\n font-family: inherit;\n font-size: 0.88rem;\n line-height: 1.4;\n backdrop-filter: blur(12px);\n -webkit-backdrop-filter: blur(12px);\n animation: mj-toast-slide-in 0.28s cubic-bezier(0.16, 1, 0.3, 1);\n transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);\n `;\n\n toast.innerHTML = `\n ${iconHtml}\n <div style=\"flex: 1; font-weight: 500; font-size: 0.84rem; color: var(--mj-text-primary, #1e293b); word-break: break-word;\">${this.escapeHtml(message)}</div>\n <button type=\"button\" class=\"mj-toast-close\" style=\"background: transparent; border: none; padding: 4px 6px; border-radius: 4px; color: var(--mj-text-muted, #94a3b8); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 13px; line-height: 1; transition: color 0.15s ease;\" aria-label=\"Close\">\n <i class=\"fa-solid fa-xmark\"></i>\n </button>\n `;\n\n const closeBtn = toast.querySelector<HTMLButtonElement>('.mj-toast-close');\n const removeToast = () => {\n toast.style.animation = 'mj-toast-slide-out 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards';\n toast.addEventListener('animationend', () => toast.remove(), { once: true });\n };\n\n closeBtn?.addEventListener('click', removeToast);\n closeBtn?.addEventListener('mouseenter', () => {\n closeBtn.style.color = 'var(--mj-text-primary, #1e293b)';\n closeBtn.style.backgroundColor = 'var(--mj-bg-surface-sunken, #f1f5f9)';\n });\n closeBtn?.addEventListener('mouseleave', () => {\n closeBtn.style.color = 'var(--mj-text-muted, #94a3b8)';\n closeBtn.style.backgroundColor = 'transparent';\n });\n\n container.appendChild(toast);\n\n // Inject keyframes if not already present\n if (!document.getElementById('mj-toast-keyframes')) {\n const styleEl = document.createElement('style');\n styleEl.id = 'mj-toast-keyframes';\n styleEl.textContent = `\n @keyframes mj-toast-slide-in {\n from { opacity: 0; transform: translateY(-12px) scale(0.96); }\n to { opacity: 1; transform: translateY(0) scale(1); }\n }\n @keyframes mj-toast-slide-out {\n from { opacity: 1; transform: translateY(0) scale(1); }\n to { opacity: 0; transform: translateY(-12px) scale(0.96); }\n }\n `;\n document.head.appendChild(styleEl);\n }\n\n // Auto-hide with hover-pause support\n if (hideAfter > 0) {\n let timer: ReturnType<typeof setTimeout> | null = setTimeout(removeToast, hideAfter);\n\n toast.addEventListener('mouseenter', () => {\n if (timer) {\n clearTimeout(timer);\n timer = null;\n }\n });\n\n toast.addEventListener('mouseleave', () => {\n if (!timer) {\n timer = setTimeout(removeToast, 2000);\n }\n });\n }\n }\n\n /**\n * Escapes HTML entities to prevent XSS in toast messages.\n */\n private escapeHtml(text: string): string {\n const div = document.createElement('div');\n div.textContent = text;\n return div.innerHTML;\n }\n}"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-notifications",
|
|
3
|
-
"version": "6.1.0-edge.
|
|
3
|
+
"version": "6.1.0-edge.3",
|
|
4
4
|
"description": "MemberJunction: Simple Angular library for displaying user notifications",
|
|
5
5
|
"main": "./dist/public-api.js",
|
|
6
6
|
"typings": "./dist/public-api.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"keywords": [],
|
|
11
11
|
"author": "",
|
|
12
|
-
"license": "
|
|
12
|
+
"license": "BUSL-1.1",
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@angular/compiler": "21.1.3",
|
|
15
15
|
"@angular/compiler-cli": "21.1.3",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"@angular/core": "^21.1.3"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@memberjunction/core": "6.1.0-edge.
|
|
24
|
-
"@memberjunction/ng-base-types": "6.1.0-edge.
|
|
25
|
-
"@memberjunction/core-entities": "6.1.0-edge.
|
|
26
|
-
"@memberjunction/global": "6.1.0-edge.
|
|
27
|
-
"@memberjunction/graphql-dataprovider": "6.1.0-edge.
|
|
23
|
+
"@memberjunction/core": "6.1.0-edge.3",
|
|
24
|
+
"@memberjunction/ng-base-types": "6.1.0-edge.3",
|
|
25
|
+
"@memberjunction/core-entities": "6.1.0-edge.3",
|
|
26
|
+
"@memberjunction/global": "6.1.0-edge.3",
|
|
27
|
+
"@memberjunction/graphql-dataprovider": "6.1.0-edge.3",
|
|
28
28
|
"tslib": "^2.8.1",
|
|
29
29
|
"rxjs": "^7.8.2"
|
|
30
30
|
},
|