mesauth-angular 1.2.0 → 1.2.1
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/package.json +39 -40
- package/dist/README.md +0 -297
- package/mesauth-angular-1.0.0.tgz +0 -0
- package/mesauth-angular-1.0.1.tgz +0 -0
- package/mesauth-angular-1.1.0.tgz +0 -0
- package/ng-package.json +0 -8
- package/src/index.ts +0 -10
- package/src/ma-user.component.ts +0 -39
- package/src/mes-auth.interceptor.ts +0 -59
- package/src/mes-auth.module.ts +0 -9
- package/src/mes-auth.service.ts +0 -406
- package/src/notification-badge.component.ts +0 -125
- package/src/notification-panel.component.ts +0 -672
- package/src/theme.service.ts +0 -70
- package/src/toast-container.component.ts +0 -221
- package/src/toast.service.ts +0 -47
- package/src/user-profile.component.ts +0 -449
- package/tsconfig.json +0 -22
- /package/{dist/fesm2022 → fesm2022}/mesauth-angular.mjs +0 -0
- /package/{dist/fesm2022 → fesm2022}/mesauth-angular.mjs.map +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
package/src/theme.service.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Injectable, OnDestroy } from '@angular/core';
|
|
2
|
-
import { BehaviorSubject, Observable } from 'rxjs';
|
|
3
|
-
|
|
4
|
-
export type Theme = 'light' | 'dark';
|
|
5
|
-
|
|
6
|
-
@Injectable({
|
|
7
|
-
providedIn: 'root'
|
|
8
|
-
})
|
|
9
|
-
export class ThemeService implements OnDestroy {
|
|
10
|
-
private _currentTheme = new BehaviorSubject<Theme>('light');
|
|
11
|
-
public currentTheme$: Observable<Theme> = this._currentTheme.asObservable();
|
|
12
|
-
private observer: MutationObserver | null = null;
|
|
13
|
-
|
|
14
|
-
constructor() {
|
|
15
|
-
this.detectTheme();
|
|
16
|
-
this.startWatching();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
ngOnDestroy(): void {
|
|
20
|
-
this.stopWatching();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
private detectTheme(): void {
|
|
24
|
-
const html = document.documentElement;
|
|
25
|
-
const isDark = html.classList.contains('dark') ||
|
|
26
|
-
html.getAttribute('data-theme') === 'dark' ||
|
|
27
|
-
html.getAttribute('theme') === 'dark' ||
|
|
28
|
-
html.getAttribute('data-coreui-theme') === 'dark';
|
|
29
|
-
|
|
30
|
-
this._currentTheme.next(isDark ? 'dark' : 'light');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
private startWatching(): void {
|
|
34
|
-
if (typeof MutationObserver === 'undefined') {
|
|
35
|
-
// Fallback for older browsers - check periodically
|
|
36
|
-
setInterval(() => this.detectTheme(), 1000);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
this.observer = new MutationObserver(() => {
|
|
41
|
-
this.detectTheme();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
this.observer.observe(document.documentElement, {
|
|
45
|
-
attributes: true,
|
|
46
|
-
attributeFilter: ['class', 'data-theme', 'theme', 'data-coreui-theme']
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
private stopWatching(): void {
|
|
51
|
-
if (this.observer) {
|
|
52
|
-
this.observer.disconnect();
|
|
53
|
-
this.observer = null;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
get currentTheme(): Theme {
|
|
58
|
-
return this._currentTheme.value;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Method to manually set theme if needed
|
|
62
|
-
setTheme(theme: Theme): void {
|
|
63
|
-
this._currentTheme.next(theme);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Re-detect theme from DOM
|
|
67
|
-
refreshTheme(): void {
|
|
68
|
-
this.detectTheme();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { Component, OnInit, OnDestroy, HostBinding } from '@angular/core';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { ToastService, Toast } from './toast.service';
|
|
4
|
-
import { ThemeService, Theme } from './theme.service';
|
|
5
|
-
import { Subject } from 'rxjs';
|
|
6
|
-
import { takeUntil } from 'rxjs/operators';
|
|
7
|
-
|
|
8
|
-
@Component({
|
|
9
|
-
selector: 'ma-toast-container',
|
|
10
|
-
standalone: true,
|
|
11
|
-
imports: [CommonModule],
|
|
12
|
-
template: `
|
|
13
|
-
<div class="toast-container">
|
|
14
|
-
<div
|
|
15
|
-
*ngFor="let toast of toasts"
|
|
16
|
-
class="toast"
|
|
17
|
-
[class]="'toast-' + toast.type"
|
|
18
|
-
[@slideIn]
|
|
19
|
-
>
|
|
20
|
-
<div class="toast-content">
|
|
21
|
-
<div *ngIf="toast.title" class="toast-title">{{ toast.title }}</div>
|
|
22
|
-
<div class="toast-message" [innerHTML]="toast.message"></div>
|
|
23
|
-
</div>
|
|
24
|
-
<button class="toast-close" (click)="close(toast.id)" aria-label="Close">
|
|
25
|
-
✕
|
|
26
|
-
</button>
|
|
27
|
-
</div>
|
|
28
|
-
</div>
|
|
29
|
-
`,
|
|
30
|
-
styles: [`
|
|
31
|
-
:host {
|
|
32
|
-
--info-color: #2196f3;
|
|
33
|
-
--success-color: #4caf50;
|
|
34
|
-
--warning-color: #ff9800;
|
|
35
|
-
--error-color: #f44336;
|
|
36
|
-
--text-primary: #333;
|
|
37
|
-
--bg-primary: white;
|
|
38
|
-
--shadow: rgba(0, 0, 0, 0.15);
|
|
39
|
-
--text-secondary: #999;
|
|
40
|
-
--border-color: rgba(0, 0, 0, 0.1);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
:host(.theme-dark) {
|
|
44
|
-
--info-color: #64b5f6;
|
|
45
|
-
--success-color: #81c784;
|
|
46
|
-
--warning-color: #ffb74d;
|
|
47
|
-
--error-color: #ef5350;
|
|
48
|
-
--text-primary: #e0e0e0;
|
|
49
|
-
--bg-primary: #1e1e1e;
|
|
50
|
-
--shadow: rgba(0, 0, 0, 0.3);
|
|
51
|
-
--text-secondary: #888;
|
|
52
|
-
--border-color: rgba(255, 255, 255, 0.1);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.toast-container {
|
|
56
|
-
position: fixed;
|
|
57
|
-
top: 20px;
|
|
58
|
-
right: 20px;
|
|
59
|
-
z-index: 9999;
|
|
60
|
-
pointer-events: none;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.toast {
|
|
64
|
-
display: flex;
|
|
65
|
-
align-items: flex-start;
|
|
66
|
-
gap: 12px;
|
|
67
|
-
padding: 12px 16px;
|
|
68
|
-
margin-bottom: 12px;
|
|
69
|
-
border-radius: 4px;
|
|
70
|
-
background: var(--bg-primary);
|
|
71
|
-
border: 1px solid var(--border-color);
|
|
72
|
-
box-shadow: 0 4px 12px var(--shadow);
|
|
73
|
-
pointer-events: auto;
|
|
74
|
-
min-width: 280px;
|
|
75
|
-
max-width: 400px;
|
|
76
|
-
animation: slideIn 0.3s ease-out;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.toast-content {
|
|
80
|
-
flex: 1;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.toast-title {
|
|
84
|
-
font-weight: 600;
|
|
85
|
-
font-size: 14px;
|
|
86
|
-
margin-bottom: 4px;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.toast-message {
|
|
90
|
-
font-size: 13px;
|
|
91
|
-
line-height: 1.4;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.toast-close {
|
|
95
|
-
background: none;
|
|
96
|
-
border: none;
|
|
97
|
-
cursor: pointer;
|
|
98
|
-
font-size: 18px;
|
|
99
|
-
color: var(--text-secondary);
|
|
100
|
-
padding: 0;
|
|
101
|
-
width: 24px;
|
|
102
|
-
height: 24px;
|
|
103
|
-
display: flex;
|
|
104
|
-
align-items: center;
|
|
105
|
-
justify-content: center;
|
|
106
|
-
flex-shrink: 0;
|
|
107
|
-
transition: color 0.2s;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.toast-close:hover {
|
|
111
|
-
color: var(--text-primary);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/* Toast types */
|
|
115
|
-
.toast-info {
|
|
116
|
-
border-left: 4px solid var(--info-color);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.toast-info .toast-title {
|
|
120
|
-
color: var(--info-color);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.toast-info .toast-message {
|
|
124
|
-
color: var(--text-primary);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.toast-success {
|
|
128
|
-
border-left: 4px solid var(--success-color);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.toast-success .toast-title {
|
|
132
|
-
color: var(--success-color);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.toast-success .toast-message {
|
|
136
|
-
color: var(--text-primary);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.toast-warning {
|
|
140
|
-
border-left: 4px solid var(--warning-color);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.toast-warning .toast-title {
|
|
144
|
-
color: var(--warning-color);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.toast-warning .toast-message {
|
|
148
|
-
color: var(--text-primary);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.toast-error {
|
|
152
|
-
border-left: 4px solid var(--error-color);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.toast-error .toast-title {
|
|
156
|
-
color: var(--error-color);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.toast-error .toast-message {
|
|
160
|
-
color: var(--text-primary);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
@keyframes slideIn {
|
|
164
|
-
from {
|
|
165
|
-
transform: translateX(400px);
|
|
166
|
-
opacity: 0;
|
|
167
|
-
}
|
|
168
|
-
to {
|
|
169
|
-
transform: translateX(0);
|
|
170
|
-
opacity: 1;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
@media (max-width: 600px) {
|
|
175
|
-
.toast-container {
|
|
176
|
-
top: 10px;
|
|
177
|
-
right: 10px;
|
|
178
|
-
left: 10px;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
.toast {
|
|
182
|
-
min-width: auto;
|
|
183
|
-
max-width: 100%;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
`]
|
|
187
|
-
})
|
|
188
|
-
export class ToastContainerComponent implements OnInit, OnDestroy {
|
|
189
|
-
@HostBinding('class') get themeClass(): string {
|
|
190
|
-
return `theme-${this.currentTheme}`;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
toasts: Toast[] = [];
|
|
194
|
-
currentTheme: Theme = 'light';
|
|
195
|
-
private destroy$ = new Subject<void>();
|
|
196
|
-
|
|
197
|
-
constructor(private toastService: ToastService, private themeService: ThemeService) {}
|
|
198
|
-
|
|
199
|
-
ngOnInit() {
|
|
200
|
-
this.toastService.toasts
|
|
201
|
-
.pipe(takeUntil(this.destroy$))
|
|
202
|
-
.subscribe(toasts => {
|
|
203
|
-
this.toasts = toasts;
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
this.themeService.currentTheme$
|
|
207
|
-
.pipe(takeUntil(this.destroy$))
|
|
208
|
-
.subscribe(theme => {
|
|
209
|
-
this.currentTheme = theme;
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
ngOnDestroy() {
|
|
214
|
-
this.destroy$.next();
|
|
215
|
-
this.destroy$.complete();
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
close(id: string) {
|
|
219
|
-
this.toastService.remove(id);
|
|
220
|
-
}
|
|
221
|
-
}
|
package/src/toast.service.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { BehaviorSubject, Observable } from 'rxjs';
|
|
3
|
-
|
|
4
|
-
export interface Toast {
|
|
5
|
-
id: string;
|
|
6
|
-
message: string;
|
|
7
|
-
title?: string;
|
|
8
|
-
type: 'info' | 'success' | 'warning' | 'error';
|
|
9
|
-
duration?: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
@Injectable({ providedIn: 'root' })
|
|
13
|
-
export class ToastService {
|
|
14
|
-
private toasts$ = new BehaviorSubject<Toast[]>([]);
|
|
15
|
-
public toasts: Observable<Toast[]> = this.toasts$.asObservable();
|
|
16
|
-
|
|
17
|
-
show(message: string, title?: string, type: 'info' | 'success' | 'warning' | 'error' = 'info', duration: number = 5000) {
|
|
18
|
-
const id = Math.random().toString(36).substr(2, 9);
|
|
19
|
-
const toast: Toast = {
|
|
20
|
-
id,
|
|
21
|
-
message,
|
|
22
|
-
title,
|
|
23
|
-
type,
|
|
24
|
-
duration
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const currentToasts = this.toasts$.value;
|
|
28
|
-
this.toasts$.next([...currentToasts, toast]);
|
|
29
|
-
|
|
30
|
-
if (duration > 0) {
|
|
31
|
-
setTimeout(() => {
|
|
32
|
-
this.remove(id);
|
|
33
|
-
}, duration);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return id;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
remove(id: string) {
|
|
40
|
-
const currentToasts = this.toasts$.value;
|
|
41
|
-
this.toasts$.next(currentToasts.filter(t => t.id !== id));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
clear() {
|
|
45
|
-
this.toasts$.next([]);
|
|
46
|
-
}
|
|
47
|
-
}
|