mn-angular-lib 0.0.1 → 0.0.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.
|
@@ -1,23 +1,208 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component } from '@angular/core';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import { InjectionToken, Injectable, Optional, Inject, inject, Input, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { BehaviorSubject } from 'rxjs';
|
|
4
|
+
import * as i1 from '@angular/common';
|
|
5
|
+
import { CommonModule } from '@angular/common';
|
|
6
|
+
|
|
7
|
+
const MN_THEME = new InjectionToken('MN_THEME', {
|
|
8
|
+
providedIn: 'root',
|
|
9
|
+
factory: () => ({
|
|
10
|
+
primary: '#0d6efd',
|
|
11
|
+
radius: '0.375rem',
|
|
12
|
+
padding: '0.5rem 0.75rem',
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
function provideMnTheme(partial) {
|
|
16
|
+
return {
|
|
17
|
+
provide: MN_THEME,
|
|
18
|
+
useFactory: (defaults) => ({ ...defaults, ...partial }),
|
|
19
|
+
deps: [MN_THEME],
|
|
20
|
+
};
|
|
11
21
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
|
|
23
|
+
// projects/mn-angular-lib/src/lib/mn-mn-alert/mn-mn-alert.tokens.ts
|
|
24
|
+
const MN_ALERT_CONFIG = new InjectionToken('MN_ALERT_CONFIG');
|
|
25
|
+
const DEFAULT_MN_ALERT_CONFIG = {
|
|
26
|
+
durations: { success: 3000, info: 4000, warning: 5000, error: 7000, default: 4000 },
|
|
27
|
+
cssClasses: {
|
|
28
|
+
success: 'mn-alert-success',
|
|
29
|
+
info: 'mn-alert-info',
|
|
30
|
+
warning: 'mn-alert-warning',
|
|
31
|
+
error: 'mn-alert-error',
|
|
32
|
+
default: 'alert'
|
|
33
|
+
},
|
|
34
|
+
icons: {},
|
|
35
|
+
defaultDuration: 4000,
|
|
36
|
+
finalize: (a) => a
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
function provideMnAlerts(config = {}) {
|
|
40
|
+
const merged = {
|
|
41
|
+
...DEFAULT_MN_ALERT_CONFIG,
|
|
42
|
+
...config,
|
|
43
|
+
durations: { ...DEFAULT_MN_ALERT_CONFIG.durations, ...(config.durations ?? {}) },
|
|
44
|
+
cssClasses: { ...DEFAULT_MN_ALERT_CONFIG.cssClasses, ...(config.cssClasses ?? {}) },
|
|
45
|
+
icons: { ...DEFAULT_MN_ALERT_CONFIG.icons, ...(config.icons ?? {}) }
|
|
46
|
+
};
|
|
47
|
+
return { provide: MN_ALERT_CONFIG, useValue: merged };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let COUNTER = 0;
|
|
51
|
+
const uid = () => `mn_${++COUNTER}`;
|
|
52
|
+
class MnAlertStore {
|
|
53
|
+
_alerts$ = new BehaviorSubject([]);
|
|
54
|
+
alerts$ = this._alerts$.asObservable();
|
|
55
|
+
show(partial) {
|
|
56
|
+
// Ensure every alert has a numeric duration: use provided or fall back to per-kind default
|
|
57
|
+
const computedDuration = partial.duration ?? DEFAULT_MN_ALERT_CONFIG.durations[partial.kind] ?? DEFAULT_MN_ALERT_CONFIG.defaultDuration;
|
|
58
|
+
const a = { id: uid(), ...partial, duration: computedDuration };
|
|
59
|
+
this._alerts$.next([...this._alerts$.value, a]);
|
|
60
|
+
if (typeof a.duration === 'number' && a.duration > 0) {
|
|
61
|
+
setTimeout(() => this.dismiss(a.id), a.duration);
|
|
62
|
+
}
|
|
63
|
+
return a.id;
|
|
64
|
+
}
|
|
65
|
+
dismiss(id) {
|
|
66
|
+
const list = this._alerts$.value;
|
|
67
|
+
if (list.some(x => x.id === id)) {
|
|
68
|
+
this._alerts$.next(list.filter(x => x.id !== id));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
clear() {
|
|
72
|
+
this._alerts$.next([]);
|
|
73
|
+
}
|
|
74
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: MnAlertStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
75
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: MnAlertStore, providedIn: 'root' });
|
|
76
|
+
}
|
|
77
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: MnAlertStore, decorators: [{
|
|
78
|
+
type: Injectable,
|
|
79
|
+
args: [{ providedIn: 'root' }]
|
|
19
80
|
}] });
|
|
20
81
|
|
|
82
|
+
// projects/mn-angular-lib/src/lib/mn-mn-alert/mn-mn-alert.service.ts
|
|
83
|
+
class MnAlertService {
|
|
84
|
+
store;
|
|
85
|
+
cfg;
|
|
86
|
+
userDurations;
|
|
87
|
+
hasUserDurations;
|
|
88
|
+
constructor(store, cfg) {
|
|
89
|
+
this.store = store;
|
|
90
|
+
this.userDurations = cfg?.durations;
|
|
91
|
+
this.hasUserDurations = !!cfg?.durations;
|
|
92
|
+
this.cfg = {
|
|
93
|
+
...DEFAULT_MN_ALERT_CONFIG,
|
|
94
|
+
...(cfg ?? {}),
|
|
95
|
+
// Do not pre-merge durations; keep defaults separate and use logic in kind()
|
|
96
|
+
durations: DEFAULT_MN_ALERT_CONFIG.durations,
|
|
97
|
+
cssClasses: { ...DEFAULT_MN_ALERT_CONFIG.cssClasses, ...(cfg?.cssClasses ?? {}) },
|
|
98
|
+
icons: { ...DEFAULT_MN_ALERT_CONFIG.icons, ...(cfg?.icons ?? {}) }
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
show(input) {
|
|
102
|
+
// Always ensure a numeric duration is set
|
|
103
|
+
let duration = input.duration;
|
|
104
|
+
if (duration == null) {
|
|
105
|
+
// Prefer user defaultDuration if provided and not null, otherwise use library per-kind default
|
|
106
|
+
const userDefault = this.cfg.defaultDuration;
|
|
107
|
+
if (typeof userDefault === 'number') {
|
|
108
|
+
duration = userDefault;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
duration = DEFAULT_MN_ALERT_CONFIG.durations[input.kind];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const a = {
|
|
115
|
+
title: input.title,
|
|
116
|
+
subTitle: input.subTitle,
|
|
117
|
+
duration,
|
|
118
|
+
icon: input.icon,
|
|
119
|
+
cssClass: input.cssClass,
|
|
120
|
+
meta: input.meta,
|
|
121
|
+
kind: input.kind
|
|
122
|
+
};
|
|
123
|
+
return this.store.show(this.cfg.finalize(a));
|
|
124
|
+
}
|
|
125
|
+
success(title, subTitle, extra) {
|
|
126
|
+
return this.kind('success', title, subTitle, extra);
|
|
127
|
+
}
|
|
128
|
+
info(title, subTitle, extra) {
|
|
129
|
+
return this.kind('info', title, subTitle, extra);
|
|
130
|
+
}
|
|
131
|
+
warning(title, subTitle, extra) {
|
|
132
|
+
return this.kind('warning', title, subTitle, extra);
|
|
133
|
+
}
|
|
134
|
+
error(title, subTitle, extra) {
|
|
135
|
+
return this.kind('error', title, subTitle, extra);
|
|
136
|
+
}
|
|
137
|
+
dismiss(id) { this.store.dismiss(id); }
|
|
138
|
+
clear() { this.store.clear(); }
|
|
139
|
+
kind(kind, title, subTitle, extra) {
|
|
140
|
+
let duration = extra?.duration;
|
|
141
|
+
if (duration == null) {
|
|
142
|
+
if (this.hasUserDurations) {
|
|
143
|
+
const userDur = this.userDurations?.[kind];
|
|
144
|
+
if (typeof userDur === 'number') {
|
|
145
|
+
duration = userDur;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
// userDur is undefined or null -> fallback to user defaultDuration if numeric
|
|
149
|
+
if (typeof this.cfg.defaultDuration === 'number') {
|
|
150
|
+
duration = this.cfg.defaultDuration;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
duration = this.cfg.durations[kind];
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
// No user durations provided at all; use library defaults per kind
|
|
159
|
+
duration = this.cfg.durations[kind];
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const cssClass = extra?.cssClass ?? this.cfg.cssClasses[kind];
|
|
163
|
+
const icon = (extra?.icon ?? this.cfg.icons[kind]);
|
|
164
|
+
return this.show({ title, subTitle, duration: duration, cssClass, icon, meta: extra?.meta, kind: kind });
|
|
165
|
+
}
|
|
166
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: MnAlertService, deps: [{ token: MnAlertStore }, { token: MN_ALERT_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
167
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: MnAlertService, providedIn: 'root' });
|
|
168
|
+
}
|
|
169
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: MnAlertService, decorators: [{
|
|
170
|
+
type: Injectable,
|
|
171
|
+
args: [{ providedIn: 'root' }]
|
|
172
|
+
}], ctorParameters: () => [{ type: MnAlertStore }, { type: undefined, decorators: [{
|
|
173
|
+
type: Optional
|
|
174
|
+
}, {
|
|
175
|
+
type: Inject,
|
|
176
|
+
args: [MN_ALERT_CONFIG]
|
|
177
|
+
}] }] });
|
|
178
|
+
|
|
179
|
+
class MnAlertOutletComponent {
|
|
180
|
+
template;
|
|
181
|
+
store = inject(MnAlertStore);
|
|
182
|
+
alerts$ = this.store.alerts$;
|
|
183
|
+
constructor() { }
|
|
184
|
+
dismissAlert(id) {
|
|
185
|
+
this.store.dismiss(id);
|
|
186
|
+
}
|
|
187
|
+
trackById = (_, a) => a.id;
|
|
188
|
+
contextFor(a) {
|
|
189
|
+
return {
|
|
190
|
+
$implicit: a,
|
|
191
|
+
alert: a,
|
|
192
|
+
dismiss: () => this.dismissAlert(a.id)
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: MnAlertOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
196
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.9", type: MnAlertOutletComponent, isStandalone: true, selector: "mn-alert-outlet", inputs: { template: "template" }, ngImport: i0, template: "@if (alerts$ | async; as alerts) {\r\n @for (a of alerts; track trackById) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"template\"\r\n [ngTemplateOutletContext]=\"contextFor(a)\">\r\n </ng-container>\r\n }\r\n}\r\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
197
|
+
}
|
|
198
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: MnAlertOutletComponent, decorators: [{
|
|
199
|
+
type: Component,
|
|
200
|
+
args: [{ selector: 'mn-alert-outlet', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (alerts$ | async; as alerts) {\r\n @for (a of alerts; track trackById) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"template\"\r\n [ngTemplateOutletContext]=\"contextFor(a)\">\r\n </ng-container>\r\n }\r\n}\r\n" }]
|
|
201
|
+
}], ctorParameters: () => [], propDecorators: { template: [{
|
|
202
|
+
type: Input,
|
|
203
|
+
args: [{ required: true }]
|
|
204
|
+
}] } });
|
|
205
|
+
|
|
21
206
|
/*
|
|
22
207
|
* Public API Surface of mn-lib
|
|
23
208
|
*/
|
|
@@ -26,5 +211,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImpor
|
|
|
26
211
|
* Generated bundle index. Do not edit.
|
|
27
212
|
*/
|
|
28
213
|
|
|
29
|
-
export {
|
|
214
|
+
export { DEFAULT_MN_ALERT_CONFIG, MN_ALERT_CONFIG, MN_THEME, MnAlertOutletComponent, MnAlertService, MnAlertStore, provideMnAlerts, provideMnTheme };
|
|
30
215
|
//# sourceMappingURL=mn-angular-lib.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mn-angular-lib.mjs","sources":["../../../projects/mn-angular-lib/src/lib/mn-angular-lib.ts","../../../projects/mn-angular-lib/src/public-api.ts","../../../projects/mn-angular-lib/src/mn-angular-lib.ts"],"sourcesContent":["import { Component } from '@angular/core';\r\n\r\n@Component({\r\n selector: 'lib-mn-lib',\r\n imports: [],\r\n template: `\r\n <p>\r\n mn-angular-lib works!\r\n </p>\r\n `,\r\n styles: ``,\r\n})\r\nexport class MnAngularLib {\r\n\r\n}\r\n","/*\r\n * Public API Surface of mn-lib\r\n */\r\n\r\nexport * from './lib/mn-angular-lib';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;MAYa,YAAY,CAAA;uGAAZ,YAAY,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAZ,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,YAAY,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,YAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,EAPb,CAAA;;;;AAIT,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA;;2FAGU,YAAY,EAAA,UAAA,EAAA,CAAA;kBAVxB,SAAS;+BACE,YAAY,EAAA,OAAA,EACb,EAAE,EAAA,QAAA,EACD,CAAA;;;;AAIT,EAAA,CAAA,EAAA;;;ACTH;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"mn-angular-lib.mjs","sources":["../../../projects/mn-angular-lib/src/lib/styles/themes.ts","../../../projects/mn-angular-lib/src/lib/features/mn-alert/mn-alert.tokens.ts","../../../projects/mn-angular-lib/src/lib/features/mn-alert/mn-alert.providers.ts","../../../projects/mn-angular-lib/src/lib/features/mn-alert/mn-alert.store.ts","../../../projects/mn-angular-lib/src/lib/features/mn-alert/mn-alert.service.ts","../../../projects/mn-angular-lib/src/lib/features/mn-alert/mn-alert-outlet/mn-alert-outlet.ts","../../../projects/mn-angular-lib/src/lib/features/mn-alert/mn-alert-outlet/mn-alert-outlet.html","../../../projects/mn-angular-lib/src/public-api.ts","../../../projects/mn-angular-lib/src/mn-angular-lib.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\r\n\r\nexport interface MnTheme {\r\n primary: string;\r\n radius: string;\r\n padding: string;\r\n}\r\n\r\nexport const MN_THEME = new InjectionToken<MnTheme>('MN_THEME', {\r\n providedIn: 'root',\r\n factory: () => ({\r\n primary: '#0d6efd',\r\n radius: '0.375rem',\r\n padding: '0.5rem 0.75rem',\r\n }),\r\n});\r\n\r\nexport function provideMnTheme(partial: Partial<MnTheme>) {\r\n return {\r\n provide: MN_THEME,\r\n useFactory: (defaults: MnTheme) => ({ ...defaults, ...partial }),\r\n deps: [MN_THEME],\r\n } as const;\r\n}\r\n","// projects/mn-angular-lib/src/lib/mn-mn-alert/mn-mn-alert.tokens.ts\r\nimport { InjectionToken } from '@angular/core';\r\nimport { MnAlert } from './mn-alert.types';\r\n\r\nexport type MnAlertKind = 'success' | 'info' | 'warning' | 'error' | 'default';\r\n\r\nexport interface MnAlertConfig {\r\n durations?: Partial<Record<MnAlertKind, number | null>>;\r\n cssClasses?: Partial<Record<MnAlertKind, string>>;\r\n icons?: Partial<Record<MnAlertKind, unknown>>;\r\n defaultDuration?: number | null;\r\n finalize?: (a: MnAlert) => MnAlert;\r\n}\r\n\r\nexport const MN_ALERT_CONFIG = new InjectionToken<MnAlertConfig>('MN_ALERT_CONFIG');\r\n\r\nexport const DEFAULT_MN_ALERT_CONFIG: Required<MnAlertConfig> = {\r\n durations: { success: 3000, info: 4000, warning: 5000, error: 7000, default: 4000 },\r\n cssClasses: {\r\n success: 'mn-alert-success',\r\n info: 'mn-alert-info',\r\n warning: 'mn-alert-warning',\r\n error: 'mn-alert-error',\r\n default: 'alert'\r\n },\r\n icons: {},\r\n defaultDuration: 4000,\r\n finalize: (a) => a\r\n};\r\n","// projects/mn-angular-lib/src/lib/mn-mn-alert/mn-mn-alert.providers.ts\r\nimport { Provider } from '@angular/core';\r\nimport { MN_ALERT_CONFIG, MnAlertConfig, DEFAULT_MN_ALERT_CONFIG } from './mn-alert.tokens';\r\n\r\nexport function provideMnAlerts(config: MnAlertConfig = {}): Provider {\r\n const merged: MnAlertConfig = {\r\n ...DEFAULT_MN_ALERT_CONFIG,\r\n ...config,\r\n durations: { ...DEFAULT_MN_ALERT_CONFIG.durations, ...(config.durations ?? {}) },\r\n cssClasses: { ...DEFAULT_MN_ALERT_CONFIG.cssClasses, ...(config.cssClasses ?? {}) },\r\n icons: { ...DEFAULT_MN_ALERT_CONFIG.icons, ...(config.icons ?? {}) }\r\n };\r\n return { provide: MN_ALERT_CONFIG, useValue: merged };\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { BehaviorSubject } from 'rxjs';\r\nimport { MnAlert, MnAlertId } from './mn-alert.types';\r\nimport { DEFAULT_MN_ALERT_CONFIG } from './mn-alert.tokens';\r\n\r\nlet COUNTER = 0;\r\nconst uid = () => `mn_${++COUNTER}`;\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class MnAlertStore {\r\n private readonly _alerts$ = new BehaviorSubject<MnAlert[]>([]);\r\n readonly alerts$ = this._alerts$.asObservable();\r\n\r\n show(partial: Omit<MnAlert, 'id'>): MnAlertId {\r\n // Ensure every alert has a numeric duration: use provided or fall back to per-kind default\r\n const computedDuration = (partial as any).duration ?? (DEFAULT_MN_ALERT_CONFIG.durations as any)[(partial as any).kind] ?? DEFAULT_MN_ALERT_CONFIG.defaultDuration;\r\n const a: MnAlert = { id: uid(), ...partial, duration: computedDuration } as MnAlert;\r\n this._alerts$.next([...this._alerts$.value, a]);\r\n\r\n if (typeof a.duration === 'number' && a.duration > 0) {\r\n setTimeout(() => this.dismiss(a.id), a.duration);\r\n }\r\n return a.id;\r\n }\r\n\r\n dismiss(id: MnAlertId) {\r\n const list = this._alerts$.value;\r\n if (list.some(x => x.id === id)) {\r\n this._alerts$.next(list.filter(x => x.id !== id));\r\n }\r\n }\r\n\r\n clear() {\r\n this._alerts$.next([]);\r\n }\r\n}\r\n","// projects/mn-angular-lib/src/lib/mn-mn-alert/mn-mn-alert.service.ts\r\nimport { Injectable, Inject, Optional } from '@angular/core';\r\nimport { MnAlertStore } from './mn-alert.store';\r\nimport { MnAlert, MnAlertId } from './mn-alert.types';\r\nimport { MN_ALERT_CONFIG, DEFAULT_MN_ALERT_CONFIG, MnAlertConfig, MnAlertKind } from './mn-alert.tokens';\r\n\r\nexport interface MnShowInput {\r\n title: string;\r\n subTitle?: string;\r\n duration?: number;\r\n icon?: unknown;\r\n cssClass?: string;\r\n meta?: Record<string, unknown>;\r\n kind: MnAlertKind;\r\n}\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class MnAlertService {\r\n private readonly cfg: Required<MnAlertConfig>;\r\n private readonly userDurations?: Partial<Record<MnAlertKind, number | null>>;\r\n private readonly hasUserDurations: boolean;\r\n\r\n constructor(\r\n private readonly store: MnAlertStore,\r\n @Optional() @Inject(MN_ALERT_CONFIG) cfg: MnAlertConfig | null\r\n ) {\r\n this.userDurations = cfg?.durations;\r\n this.hasUserDurations = !!cfg?.durations;\r\n this.cfg = {\r\n ...DEFAULT_MN_ALERT_CONFIG,\r\n ...(cfg ?? {}),\r\n // Do not pre-merge durations; keep defaults separate and use logic in kind()\r\n durations: DEFAULT_MN_ALERT_CONFIG.durations,\r\n cssClasses: { ...DEFAULT_MN_ALERT_CONFIG.cssClasses, ...(cfg?.cssClasses ?? {}) },\r\n icons: { ...DEFAULT_MN_ALERT_CONFIG.icons, ...(cfg?.icons ?? {}) }\r\n };\r\n }\r\n\r\n show(input: MnShowInput): MnAlertId {\r\n // Always ensure a numeric duration is set\r\n let duration = input.duration;\r\n if (duration == null) {\r\n // Prefer user defaultDuration if provided and not null, otherwise use library per-kind default\r\n const userDefault = this.cfg.defaultDuration;\r\n if (typeof userDefault === 'number') {\r\n duration = userDefault;\r\n } else {\r\n duration = DEFAULT_MN_ALERT_CONFIG.durations[input.kind as keyof typeof DEFAULT_MN_ALERT_CONFIG.durations] as number;\r\n }\r\n }\r\n\r\n const a: Omit<MnAlert, 'id'> = {\r\n title: input.title,\r\n subTitle: input.subTitle,\r\n duration,\r\n icon: input.icon,\r\n cssClass: input.cssClass,\r\n meta: input.meta,\r\n kind: input.kind\r\n };\r\n return this.store.show(this.cfg.finalize(a as MnAlert));\r\n }\r\n\r\n success(title: string, subTitle?: string, extra?: Partial<MnShowInput>) {\r\n return this.kind('success', title, subTitle, extra);\r\n }\r\n info(title: string, subTitle?: string, extra?: Partial<MnShowInput>) {\r\n return this.kind('info', title, subTitle, extra);\r\n }\r\n warning(title: string, subTitle?: string, extra?: Partial<MnShowInput>) {\r\n return this.kind('warning', title, subTitle, extra);\r\n }\r\n error(title: string, subTitle?: string, extra?: Partial<MnShowInput>) {\r\n return this.kind('error', title, subTitle, extra);\r\n }\r\n\r\n dismiss(id: MnAlertId) { this.store.dismiss(id); }\r\n clear() { this.store.clear(); }\r\n\r\n private kind(kind: MnAlertKind, title: string, subTitle?: string, extra?: Partial<MnShowInput>) {\r\n let duration: number | null | undefined = extra?.duration;\r\n\r\n if (duration == null) {\r\n if (this.hasUserDurations) {\r\n const userDur = this.userDurations?.[kind];\r\n if (typeof userDur === 'number') {\r\n duration = userDur;\r\n } else {\r\n // userDur is undefined or null -> fallback to user defaultDuration if numeric\r\n if (typeof this.cfg.defaultDuration === 'number') {\r\n duration = this.cfg.defaultDuration;\r\n } else {\r\n duration = this.cfg.durations[kind as keyof typeof this.cfg.durations];\r\n }\r\n }\r\n } else {\r\n // No user durations provided at all; use library defaults per kind\r\n duration = this.cfg.durations[kind as keyof typeof this.cfg.durations];\r\n }\r\n }\r\n\r\n const cssClass = extra?.cssClass ?? this.cfg.cssClasses[kind];\r\n const icon = (extra?.icon ?? this.cfg.icons[kind]) as unknown;\r\n\r\n return this.show({ title, subTitle, duration: duration as number, cssClass, icon, meta: extra?.meta , kind: kind});\r\n }\r\n}\r\n","\r\nimport {Component, Input, TemplateRef, ChangeDetectionStrategy, inject} from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { Observable } from 'rxjs';\r\nimport {MnAlertStore} from '../mn-alert.store';\r\nimport {MnAlert} from '../mn-alert.types';\r\n\r\nexport interface MnAlertTemplateContext {\r\n $implicit: MnAlert;\r\n alert: MnAlert;\r\n dismiss: () => void;\r\n}\r\n\r\n@Component({\r\n selector: 'mn-alert-outlet',\r\n standalone: true,\r\n imports: [CommonModule],\r\n templateUrl: './mn-alert-outlet.html',\r\n styleUrl: './mn-alert-outlet.css',\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n})\r\nexport class MnAlertOutletComponent {\r\n @Input({ required: true }) template!: TemplateRef<MnAlertTemplateContext>;\r\n\r\n private store = inject(MnAlertStore);\r\n alerts$: Observable<MnAlert[]> = this.store.alerts$;\r\n\r\n constructor() {}\r\n\r\n dismissAlert(id: string) {\r\n this.store.dismiss(id);\r\n }\r\n\r\n trackById = (_: number, a: MnAlert) => a.id;\r\n\r\n contextFor(a: MnAlert) {\r\n return {\r\n $implicit: a,\r\n alert: a,\r\n dismiss: () => this.dismissAlert(a.id)\r\n } as const;\r\n }\r\n\r\n}\r\n","@if (alerts$ | async; as alerts) {\r\n @for (a of alerts; track trackById) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"template\"\r\n [ngTemplateOutletContext]=\"contextFor(a)\">\r\n </ng-container>\r\n }\r\n}\r\n","/*\r\n * Public API Surface of mn-lib\r\n */\r\nexport * from './lib';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;MAQa,QAAQ,GAAG,IAAI,cAAc,CAAU,UAAU,EAAE;AAC9D,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,OAAO;AACd,QAAA,OAAO,EAAE,SAAS;AAClB,QAAA,MAAM,EAAE,UAAU;AAClB,QAAA,OAAO,EAAE,gBAAgB;KAC1B,CAAC;AACH,CAAA;AAEK,SAAU,cAAc,CAAC,OAAyB,EAAA;IACtD,OAAO;AACL,QAAA,OAAO,EAAE,QAAQ;AACjB,QAAA,UAAU,EAAE,CAAC,QAAiB,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,EAAE,CAAC;QAChE,IAAI,EAAE,CAAC,QAAQ,CAAC;KACR;AACZ;;ACvBA;MAca,eAAe,GAAG,IAAI,cAAc,CAAgB,iBAAiB;AAE3E,MAAM,uBAAuB,GAA4B;IAC9D,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;AACnF,IAAA,UAAU,EAAE;AACV,QAAA,OAAO,EAAE,kBAAkB;AAC3B,QAAA,IAAI,EAAE,eAAe;AACrB,QAAA,OAAO,EAAE,kBAAkB;AAC3B,QAAA,KAAK,EAAE,gBAAgB;AACv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,OAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAKX,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBARlC,SAAS;+BACE,iBAAiB,EAAA,UAAA,EACf,IAAI,EAAA,OAAA,EACP,CAAC,YAAY,CAAC,EAAA,eAAA,EAGN,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,0OAAA,EAAA;;sBAG9C,KAAK;uBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;;;AEtB3B;;AAEG;;ACFH;;AAEG;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,106 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, Provider, TemplateRef } from '@angular/core';
|
|
3
|
+
import * as rxjs from 'rxjs';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
interface MnTheme {
|
|
7
|
+
primary: string;
|
|
8
|
+
radius: string;
|
|
9
|
+
padding: string;
|
|
6
10
|
}
|
|
11
|
+
declare const MN_THEME: InjectionToken<MnTheme>;
|
|
12
|
+
declare function provideMnTheme(partial: Partial<MnTheme>): {
|
|
13
|
+
readonly provide: InjectionToken<MnTheme>;
|
|
14
|
+
readonly useFactory: (defaults: MnTheme) => {
|
|
15
|
+
primary: string;
|
|
16
|
+
radius: string;
|
|
17
|
+
padding: string;
|
|
18
|
+
};
|
|
19
|
+
readonly deps: readonly [InjectionToken<MnTheme>];
|
|
20
|
+
};
|
|
7
21
|
|
|
8
|
-
|
|
22
|
+
type MnAlertId = string;
|
|
23
|
+
interface MnAlert {
|
|
24
|
+
id: MnAlertId;
|
|
25
|
+
title: string;
|
|
26
|
+
subTitle?: string;
|
|
27
|
+
icon?: unknown;
|
|
28
|
+
cssClass?: string;
|
|
29
|
+
duration?: number;
|
|
30
|
+
meta?: Record<string, unknown>;
|
|
31
|
+
kind: MnAlertKind;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type MnAlertKind = 'success' | 'info' | 'warning' | 'error' | 'default';
|
|
35
|
+
interface MnAlertConfig {
|
|
36
|
+
durations?: Partial<Record<MnAlertKind, number | null>>;
|
|
37
|
+
cssClasses?: Partial<Record<MnAlertKind, string>>;
|
|
38
|
+
icons?: Partial<Record<MnAlertKind, unknown>>;
|
|
39
|
+
defaultDuration?: number | null;
|
|
40
|
+
finalize?: (a: MnAlert) => MnAlert;
|
|
41
|
+
}
|
|
42
|
+
declare const MN_ALERT_CONFIG: InjectionToken<MnAlertConfig>;
|
|
43
|
+
declare const DEFAULT_MN_ALERT_CONFIG: Required<MnAlertConfig>;
|
|
44
|
+
|
|
45
|
+
declare function provideMnAlerts(config?: MnAlertConfig): Provider;
|
|
46
|
+
|
|
47
|
+
declare class MnAlertStore {
|
|
48
|
+
private readonly _alerts$;
|
|
49
|
+
readonly alerts$: rxjs.Observable<MnAlert[]>;
|
|
50
|
+
show(partial: Omit<MnAlert, 'id'>): MnAlertId;
|
|
51
|
+
dismiss(id: MnAlertId): void;
|
|
52
|
+
clear(): void;
|
|
53
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MnAlertStore, never>;
|
|
54
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<MnAlertStore>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface MnShowInput {
|
|
58
|
+
title: string;
|
|
59
|
+
subTitle?: string;
|
|
60
|
+
duration?: number;
|
|
61
|
+
icon?: unknown;
|
|
62
|
+
cssClass?: string;
|
|
63
|
+
meta?: Record<string, unknown>;
|
|
64
|
+
kind: MnAlertKind;
|
|
65
|
+
}
|
|
66
|
+
declare class MnAlertService {
|
|
67
|
+
private readonly store;
|
|
68
|
+
private readonly cfg;
|
|
69
|
+
private readonly userDurations?;
|
|
70
|
+
private readonly hasUserDurations;
|
|
71
|
+
constructor(store: MnAlertStore, cfg: MnAlertConfig | null);
|
|
72
|
+
show(input: MnShowInput): MnAlertId;
|
|
73
|
+
success(title: string, subTitle?: string, extra?: Partial<MnShowInput>): string;
|
|
74
|
+
info(title: string, subTitle?: string, extra?: Partial<MnShowInput>): string;
|
|
75
|
+
warning(title: string, subTitle?: string, extra?: Partial<MnShowInput>): string;
|
|
76
|
+
error(title: string, subTitle?: string, extra?: Partial<MnShowInput>): string;
|
|
77
|
+
dismiss(id: MnAlertId): void;
|
|
78
|
+
clear(): void;
|
|
79
|
+
private kind;
|
|
80
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MnAlertService, [null, { optional: true; }]>;
|
|
81
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<MnAlertService>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface MnAlertTemplateContext {
|
|
85
|
+
$implicit: MnAlert;
|
|
86
|
+
alert: MnAlert;
|
|
87
|
+
dismiss: () => void;
|
|
88
|
+
}
|
|
89
|
+
declare class MnAlertOutletComponent {
|
|
90
|
+
template: TemplateRef<MnAlertTemplateContext>;
|
|
91
|
+
private store;
|
|
92
|
+
alerts$: Observable<MnAlert[]>;
|
|
93
|
+
constructor();
|
|
94
|
+
dismissAlert(id: string): void;
|
|
95
|
+
trackById: (_: number, a: MnAlert) => string;
|
|
96
|
+
contextFor(a: MnAlert): {
|
|
97
|
+
readonly $implicit: MnAlert;
|
|
98
|
+
readonly alert: MnAlert;
|
|
99
|
+
readonly dismiss: () => void;
|
|
100
|
+
};
|
|
101
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MnAlertOutletComponent, never>;
|
|
102
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MnAlertOutletComponent, "mn-alert-outlet", never, { "template": { "alias": "template"; "required": true; }; }, {}, never, never, true, never>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export { DEFAULT_MN_ALERT_CONFIG, MN_ALERT_CONFIG, MN_THEME, MnAlertOutletComponent, MnAlertService, MnAlertStore, provideMnAlerts, provideMnTheme };
|
|
106
|
+
export type { MnAlert, MnAlertConfig, MnAlertId, MnAlertKind, MnAlertTemplateContext, MnShowInput, MnTheme };
|
package/package.json
CHANGED
|
File without changes
|