devlab-one-dynamic-toast 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
ADDED
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
# Dynamic Snackbar
|
|
2
|
+
|
|
3
|
+
A lightweight Angular Material-based Snackbar Library that provides beautiful, customizable, and consistent toast notifications throughout your application.
|
|
4
|
+
|
|
5
|
+
The library offers predefined notification types such as Success, Error, Warning, and Information while also allowing fully customizable snackbars through a configuration object.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
* 🚀 Simple API
|
|
12
|
+
* 🎨 Angular Material Snackbar
|
|
13
|
+
* ✅ Success Notifications
|
|
14
|
+
* ❌ Error Notifications
|
|
15
|
+
* ⚠️ Warning Notifications
|
|
16
|
+
* ℹ️ Information Notifications
|
|
17
|
+
* 🎯 Fully Customizable
|
|
18
|
+
* ⏱ Configurable Duration
|
|
19
|
+
* 📍 Configurable Position
|
|
20
|
+
* 🎨 Custom Styling Support
|
|
21
|
+
* ⚡ Lightweight and Fast
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash id="u5s9qx"
|
|
28
|
+
npm install devlab-one-dynamic-snackbar
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Inject Snackbar Service
|
|
34
|
+
|
|
35
|
+
```typescript id="7wqz6u"
|
|
36
|
+
import { SnackbarService } from 'devlab-one-dynamic-snackbar';
|
|
37
|
+
|
|
38
|
+
constructor(
|
|
39
|
+
private snackbar: SnackbarService
|
|
40
|
+
) {}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Available Methods
|
|
46
|
+
|
|
47
|
+
```typescript id="8zlg24"
|
|
48
|
+
show(config: SnackbarConfig): void;
|
|
49
|
+
|
|
50
|
+
success(
|
|
51
|
+
message: string,
|
|
52
|
+
title?: string
|
|
53
|
+
): void;
|
|
54
|
+
|
|
55
|
+
error(
|
|
56
|
+
message: string,
|
|
57
|
+
title?: string
|
|
58
|
+
): void;
|
|
59
|
+
|
|
60
|
+
warning(
|
|
61
|
+
message: string,
|
|
62
|
+
title?: string
|
|
63
|
+
): void;
|
|
64
|
+
|
|
65
|
+
info(
|
|
66
|
+
message: string,
|
|
67
|
+
title?: string
|
|
68
|
+
): void;
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Success Snackbar
|
|
74
|
+
|
|
75
|
+
Display success notifications after successful operations.
|
|
76
|
+
|
|
77
|
+
```typescript id="xy7l4o"
|
|
78
|
+
this.snackbar.success(
|
|
79
|
+
'Employee created successfully'
|
|
80
|
+
);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### With Title
|
|
84
|
+
|
|
85
|
+
```typescript id="k5u1sv"
|
|
86
|
+
this.snackbar.success(
|
|
87
|
+
'Employee created successfully',
|
|
88
|
+
'Success'
|
|
89
|
+
);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Error Snackbar
|
|
95
|
+
|
|
96
|
+
Display application or API error messages.
|
|
97
|
+
|
|
98
|
+
```typescript id="nd6kz4"
|
|
99
|
+
this.snackbar.error(
|
|
100
|
+
'Unable to create employee'
|
|
101
|
+
);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### With Title
|
|
105
|
+
|
|
106
|
+
```typescript id="g4i9ef"
|
|
107
|
+
this.snackbar.error(
|
|
108
|
+
'Unable to create employee',
|
|
109
|
+
'Error'
|
|
110
|
+
);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Warning Snackbar
|
|
116
|
+
|
|
117
|
+
Display warning messages.
|
|
118
|
+
|
|
119
|
+
```typescript id="j2m7ph"
|
|
120
|
+
this.snackbar.warning(
|
|
121
|
+
'You have unsaved changes'
|
|
122
|
+
);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### With Title
|
|
126
|
+
|
|
127
|
+
```typescript id="9o2wrl"
|
|
128
|
+
this.snackbar.warning(
|
|
129
|
+
'You have unsaved changes',
|
|
130
|
+
'Warning'
|
|
131
|
+
);
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Information Snackbar
|
|
137
|
+
|
|
138
|
+
Display informational messages.
|
|
139
|
+
|
|
140
|
+
```typescript id="w4a6ng"
|
|
141
|
+
this.snackbar.info(
|
|
142
|
+
'New update available'
|
|
143
|
+
);
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### With Title
|
|
147
|
+
|
|
148
|
+
```typescript id="q9x5lm"
|
|
149
|
+
this.snackbar.info(
|
|
150
|
+
'New update available',
|
|
151
|
+
'Information'
|
|
152
|
+
);
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Custom Snackbar
|
|
158
|
+
|
|
159
|
+
For complete control over the snackbar appearance and behavior, use the `show()` method.
|
|
160
|
+
|
|
161
|
+
```typescript id="u0a8yv"
|
|
162
|
+
this.snackbar.show({
|
|
163
|
+
title: 'Success',
|
|
164
|
+
message: 'Employee created successfully',
|
|
165
|
+
type: 'success'
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Snackbar Configuration
|
|
172
|
+
|
|
173
|
+
```typescript id="5zprxv"
|
|
174
|
+
export interface SnackbarConfig {
|
|
175
|
+
title?: string;
|
|
176
|
+
message: string;
|
|
177
|
+
type?: SnackbarType;
|
|
178
|
+
duration?: number;
|
|
179
|
+
horizontalPosition?: HorizontalPosition;
|
|
180
|
+
verticalPosition?: VerticalPosition;
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Snackbar Types
|
|
187
|
+
|
|
188
|
+
```typescript id="f58rqm"
|
|
189
|
+
export enum SnackbarType {
|
|
190
|
+
Success = 'success',
|
|
191
|
+
Error = 'error',
|
|
192
|
+
Warning = 'warning',
|
|
193
|
+
Info = 'info'
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Duration Configuration
|
|
200
|
+
|
|
201
|
+
Default snackbar duration can be overridden.
|
|
202
|
+
|
|
203
|
+
```typescript id="x7t0v9"
|
|
204
|
+
this.snackbar.show({
|
|
205
|
+
title: 'Success',
|
|
206
|
+
message: 'Employee created successfully',
|
|
207
|
+
duration: 5000
|
|
208
|
+
});
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Duration is specified in milliseconds.
|
|
212
|
+
|
|
213
|
+
| Value | Description |
|
|
214
|
+
| ----- | ----------- |
|
|
215
|
+
| 3000 | 3 seconds |
|
|
216
|
+
| 5000 | 5 seconds |
|
|
217
|
+
| 10000 | 10 seconds |
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## Position Configuration
|
|
222
|
+
|
|
223
|
+
### Horizontal Position
|
|
224
|
+
|
|
225
|
+
```typescript id="3kfd2x"
|
|
226
|
+
horizontalPosition: 'start'
|
|
227
|
+
horizontalPosition: 'center'
|
|
228
|
+
horizontalPosition: 'end'
|
|
229
|
+
horizontalPosition: 'left'
|
|
230
|
+
horizontalPosition: 'right'
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Vertical Position
|
|
234
|
+
|
|
235
|
+
```typescript id="n1c2ez"
|
|
236
|
+
verticalPosition: 'top'
|
|
237
|
+
verticalPosition: 'bottom'
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Example
|
|
241
|
+
|
|
242
|
+
```typescript id="k4r7hd"
|
|
243
|
+
this.snackbar.show({
|
|
244
|
+
title: 'Success',
|
|
245
|
+
message: 'Employee created successfully',
|
|
246
|
+
horizontalPosition: 'right',
|
|
247
|
+
verticalPosition: 'top'
|
|
248
|
+
});
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## Complete Example
|
|
254
|
+
|
|
255
|
+
```typescript id="6xq4rf"
|
|
256
|
+
this.snackbar.show({
|
|
257
|
+
title: 'Employee Created',
|
|
258
|
+
message: 'Employee record saved successfully',
|
|
259
|
+
type: SnackbarType.Success,
|
|
260
|
+
duration: 5000,
|
|
261
|
+
horizontalPosition: 'right',
|
|
262
|
+
verticalPosition: 'top'
|
|
263
|
+
});
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## API Success Example
|
|
269
|
+
|
|
270
|
+
```typescript id="h8k3ql"
|
|
271
|
+
this.employeeService.create(employee)
|
|
272
|
+
.subscribe({
|
|
273
|
+
next: () => {
|
|
274
|
+
this.snackbar.success(
|
|
275
|
+
'Employee created successfully'
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## API Error Example
|
|
284
|
+
|
|
285
|
+
```typescript id="s6y4mn"
|
|
286
|
+
this.employeeService.create(employee)
|
|
287
|
+
.subscribe({
|
|
288
|
+
error: () => {
|
|
289
|
+
this.snackbar.error(
|
|
290
|
+
'Unable to create employee'
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## UI Examples
|
|
299
|
+
|
|
300
|
+
### Success
|
|
301
|
+
|
|
302
|
+
```text id="v5a0re"
|
|
303
|
+
┌──────────────────────────────┐
|
|
304
|
+
│ ✓ Success │
|
|
305
|
+
│ Employee created successfully│
|
|
306
|
+
└──────────────────────────────┘
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Error
|
|
310
|
+
|
|
311
|
+
```text id="8e7kpt"
|
|
312
|
+
┌──────────────────────────────┐
|
|
313
|
+
│ ✕ Error │
|
|
314
|
+
│ Unable to create employee │
|
|
315
|
+
└──────────────────────────────┘
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Warning
|
|
319
|
+
|
|
320
|
+
```text id="n0m8dx"
|
|
321
|
+
┌──────────────────────────────┐
|
|
322
|
+
│ ⚠ Warning │
|
|
323
|
+
│ Unsaved changes detected │
|
|
324
|
+
└──────────────────────────────┘
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Information
|
|
328
|
+
|
|
329
|
+
```text id="c7v4up"
|
|
330
|
+
┌──────────────────────────────┐
|
|
331
|
+
│ ℹ Information │
|
|
332
|
+
│ New update available │
|
|
333
|
+
└──────────────────────────────┘
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## Typical Usage Scenarios
|
|
339
|
+
|
|
340
|
+
### Form Save
|
|
341
|
+
|
|
342
|
+
```typescript id="5y2mkr"
|
|
343
|
+
this.snackbar.success(
|
|
344
|
+
'Form submitted successfully'
|
|
345
|
+
);
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### API Error
|
|
349
|
+
|
|
350
|
+
```typescript id="p4x1wo"
|
|
351
|
+
this.snackbar.error(
|
|
352
|
+
'Unable to connect to server'
|
|
353
|
+
);
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Warning Notification
|
|
357
|
+
|
|
358
|
+
```typescript id="r6t8yl"
|
|
359
|
+
this.snackbar.warning(
|
|
360
|
+
'Session will expire in 2 minutes'
|
|
361
|
+
);
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Application Update
|
|
365
|
+
|
|
366
|
+
```typescript id="q3v5sa"
|
|
367
|
+
this.snackbar.info(
|
|
368
|
+
'Version 2.0 is now available'
|
|
369
|
+
);
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## Built With
|
|
375
|
+
|
|
376
|
+
* Angular 21+
|
|
377
|
+
* Angular Material Snackbar
|
|
378
|
+
* TypeScript
|
|
379
|
+
* RxJS
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## Why Dynamic Snackbar?
|
|
384
|
+
|
|
385
|
+
Instead of repeatedly configuring Angular Material snackbars throughout your application:
|
|
386
|
+
|
|
387
|
+
```typescript id="j8u1dx"
|
|
388
|
+
this.snackBar.open(
|
|
389
|
+
message,
|
|
390
|
+
'Close',
|
|
391
|
+
{
|
|
392
|
+
duration: 3000,
|
|
393
|
+
horizontalPosition: 'right',
|
|
394
|
+
verticalPosition: 'top'
|
|
395
|
+
}
|
|
396
|
+
);
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
Simply use:
|
|
400
|
+
|
|
401
|
+
```typescript id="v5m2zr"
|
|
402
|
+
this.snackbar.success(
|
|
403
|
+
'Employee created successfully'
|
|
404
|
+
);
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
and let the library handle styling, icons, duration, positioning, and consistency automatically.
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
## License
|
|
412
|
+
|
|
413
|
+
MIT License
|
|
Binary file
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Inject, Component, Injectable } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/material/snack-bar';
|
|
4
|
+
import { MAT_SNACK_BAR_DATA } from '@angular/material/snack-bar';
|
|
5
|
+
import { CommonModule } from '@angular/common';
|
|
6
|
+
import * as i2 from '@angular/material/icon';
|
|
7
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
8
|
+
|
|
9
|
+
class DynamicSnackbar {
|
|
10
|
+
data;
|
|
11
|
+
snackBarRef;
|
|
12
|
+
constructor(data, snackBarRef) {
|
|
13
|
+
this.data = data;
|
|
14
|
+
this.snackBarRef = snackBarRef;
|
|
15
|
+
}
|
|
16
|
+
close() {
|
|
17
|
+
this.snackBarRef.dismiss();
|
|
18
|
+
}
|
|
19
|
+
get icon() {
|
|
20
|
+
switch (this.data.type) {
|
|
21
|
+
case 'success':
|
|
22
|
+
return 'check_circle';
|
|
23
|
+
case 'error':
|
|
24
|
+
return 'error';
|
|
25
|
+
case 'warning':
|
|
26
|
+
return 'warning';
|
|
27
|
+
case 'info':
|
|
28
|
+
return 'info';
|
|
29
|
+
default:
|
|
30
|
+
return 'notifications';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: DynamicSnackbar, deps: [{ token: MAT_SNACK_BAR_DATA }, { token: i1.MatSnackBarRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
34
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.2", type: DynamicSnackbar, isStandalone: true, selector: "lib-snackbar", ngImport: i0, template: "<div class=\"snackbar-wrapper\">\n\n <mat-icon class=\"icon\">\n {{ icon }}\n </mat-icon>\n\n <div class=\"content\">\n\n @if(data.title){\n\n <div class=\"title\">\n {{ data.title }}\n </div>\n\n }\n\n @if(data.enableHtml){\n\n <div\n [innerHTML]=\"data.message\">\n </div>\n\n } @else {\n\n <div>\n {{ data.message }}\n </div>\n\n }\n\n </div>\n\n <button\n class=\"close-btn\"\n (click)=\"close()\">\n\n \u2715\n\n </button>\n\n</div>", styles: [".ngx-snackbar-panel .mat-mdc-snackbar-surface{min-width:400px!important;max-width:500px!important;padding:0!important;background:transparent!important;box-shadow:none!important}.snackbar-wrapper{display:flex;align-items:flex-start;gap:12px;min-width:350px}.icon{margin-top:2px}.content{flex:1}.title{font-weight:600;margin-bottom:4px}.close-btn{border:none;background:transparent;cursor:pointer;font-size:18px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] });
|
|
35
|
+
}
|
|
36
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: DynamicSnackbar, decorators: [{
|
|
37
|
+
type: Component,
|
|
38
|
+
args: [{ selector: 'lib-snackbar', standalone: true, imports: [
|
|
39
|
+
CommonModule,
|
|
40
|
+
MatIconModule
|
|
41
|
+
], template: "<div class=\"snackbar-wrapper\">\n\n <mat-icon class=\"icon\">\n {{ icon }}\n </mat-icon>\n\n <div class=\"content\">\n\n @if(data.title){\n\n <div class=\"title\">\n {{ data.title }}\n </div>\n\n }\n\n @if(data.enableHtml){\n\n <div\n [innerHTML]=\"data.message\">\n </div>\n\n } @else {\n\n <div>\n {{ data.message }}\n </div>\n\n }\n\n </div>\n\n <button\n class=\"close-btn\"\n (click)=\"close()\">\n\n \u2715\n\n </button>\n\n</div>", styles: [".ngx-snackbar-panel .mat-mdc-snackbar-surface{min-width:400px!important;max-width:500px!important;padding:0!important;background:transparent!important;box-shadow:none!important}.snackbar-wrapper{display:flex;align-items:flex-start;gap:12px;min-width:350px}.icon{margin-top:2px}.content{flex:1}.title{font-weight:600;margin-bottom:4px}.close-btn{border:none;background:transparent;cursor:pointer;font-size:18px}\n"] }]
|
|
42
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
43
|
+
type: Inject,
|
|
44
|
+
args: [MAT_SNACK_BAR_DATA]
|
|
45
|
+
}] }, { type: i1.MatSnackBarRef }] });
|
|
46
|
+
|
|
47
|
+
class SnackbarService {
|
|
48
|
+
snackBar;
|
|
49
|
+
constructor(snackBar) {
|
|
50
|
+
this.snackBar = snackBar;
|
|
51
|
+
}
|
|
52
|
+
show(config) {
|
|
53
|
+
this.snackBar.openFromComponent(DynamicSnackbar, {
|
|
54
|
+
duration: config.duration ?? 50000000,
|
|
55
|
+
horizontalPosition: config.horizontalPosition ??
|
|
56
|
+
'right',
|
|
57
|
+
verticalPosition: config.verticalPosition ??
|
|
58
|
+
'top',
|
|
59
|
+
panelClass: [
|
|
60
|
+
'ngx-snackbar',
|
|
61
|
+
config.type ?? 'info',
|
|
62
|
+
...(config.panelClass ?? [])
|
|
63
|
+
],
|
|
64
|
+
data: config
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
success(message, title) {
|
|
68
|
+
this.show({
|
|
69
|
+
type: 'success',
|
|
70
|
+
title,
|
|
71
|
+
message
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
error(message, title) {
|
|
75
|
+
this.show({
|
|
76
|
+
type: 'error',
|
|
77
|
+
title,
|
|
78
|
+
message
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
warning(message, title) {
|
|
82
|
+
this.show({
|
|
83
|
+
type: 'warning',
|
|
84
|
+
title,
|
|
85
|
+
message
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
info(message, title) {
|
|
89
|
+
this.show({
|
|
90
|
+
type: 'info',
|
|
91
|
+
title,
|
|
92
|
+
message
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: SnackbarService, deps: [{ token: i1.MatSnackBar }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
96
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: SnackbarService, providedIn: 'root' });
|
|
97
|
+
}
|
|
98
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: SnackbarService, decorators: [{
|
|
99
|
+
type: Injectable,
|
|
100
|
+
args: [{
|
|
101
|
+
providedIn: 'root'
|
|
102
|
+
}]
|
|
103
|
+
}], ctorParameters: () => [{ type: i1.MatSnackBar }] });
|
|
104
|
+
|
|
105
|
+
/*
|
|
106
|
+
* Public API Surface of dynamic-toast
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Generated bundle index. Do not edit.
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
export { DynamicSnackbar, SnackbarService };
|
|
114
|
+
//# sourceMappingURL=devlab-one-dynamic-toast.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devlab-one-dynamic-toast.mjs","sources":["../../../projects/dynamic-toast/src/lib/dynamic-snackbar.ts","../../../projects/dynamic-toast/src/lib/dynamic-snackbar.html","../../../projects/dynamic-toast/src/lib/dynamic-snackbar.service.ts","../../../projects/dynamic-toast/src/public-api.ts","../../../projects/dynamic-toast/src/devlab-one-dynamic-toast.ts"],"sourcesContent":["import {\n Component,\n Inject\n} from '@angular/core';\n\nimport {\n MAT_SNACK_BAR_DATA,\n MatSnackBarRef\n} from '@angular/material/snack-bar';\n\nimport { CommonModule } from '@angular/common';\nimport { MatIconModule } from '@angular/material/icon';\n\nimport {\n SnackbarConfig\n} from './dynamic-snackbar.modal';\n\n@Component({\n selector: 'lib-snackbar',\n standalone: true,\n imports: [\n CommonModule,\n MatIconModule\n ],\n templateUrl: './dynamic-snackbar.html',\n styleUrls: ['./dynamic-snackbar.scss']\n})\nexport class DynamicSnackbar {\n\n constructor(\n @Inject(MAT_SNACK_BAR_DATA)\n public data: SnackbarConfig,\n\n private snackBarRef:\n MatSnackBarRef<DynamicSnackbar>\n ) {}\n\n public close(): void {\n\n this.snackBarRef.dismiss();\n }\n\n public get icon(): string {\n\n switch (this.data.type) {\n\n case 'success':\n return 'check_circle';\n\n case 'error':\n return 'error';\n\n case 'warning':\n return 'warning';\n\n case 'info':\n return 'info';\n\n default:\n return 'notifications';\n }\n }\n}","<div class=\"snackbar-wrapper\">\n\n <mat-icon class=\"icon\">\n {{ icon }}\n </mat-icon>\n\n <div class=\"content\">\n\n @if(data.title){\n\n <div class=\"title\">\n {{ data.title }}\n </div>\n\n }\n\n @if(data.enableHtml){\n\n <div\n [innerHTML]=\"data.message\">\n </div>\n\n } @else {\n\n <div>\n {{ data.message }}\n </div>\n\n }\n\n </div>\n\n <button\n class=\"close-btn\"\n (click)=\"close()\">\n\n ✕\n\n </button>\n\n</div>","import {\n Injectable\n} from '@angular/core';\n\nimport {\n MatSnackBar\n} from '@angular/material/snack-bar';\n\nimport {\n DynamicSnackbar\n} from './dynamic-snackbar';\n\nimport {\n SnackbarConfig\n} from './dynamic-snackbar.modal';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class SnackbarService {\n\n constructor(\n private snackBar: MatSnackBar\n ) { }\n\n public show(\n config: SnackbarConfig\n ): void {\n\n this.snackBar.openFromComponent(\n DynamicSnackbar,\n {\n duration:\n config.duration ?? 50000000,\n\n horizontalPosition:\n config.horizontalPosition ??\n 'right',\n\n verticalPosition:\n config.verticalPosition ??\n 'top',\n\n panelClass: [\n 'ngx-snackbar',\n config.type ?? 'info',\n ...(config.panelClass ?? [])\n ],\n\n data: config\n }\n );\n }\n\n public success(\n message: string,\n title?: string\n ): void {\n\n this.show({\n type: 'success',\n title,\n message\n });\n }\n\n public error(\n message: string,\n title?: string\n ): void {\n\n this.show({\n type: 'error',\n title,\n message\n });\n }\n\n public warning(\n message: string,\n title?: string\n ): void {\n\n this.show({\n type: 'warning',\n title,\n message\n });\n }\n\n public info(\n message: string,\n title?: string\n ): void {\n\n this.show({\n type: 'info',\n title,\n message\n });\n }\n}","/*\n * Public API Surface of dynamic-toast\n */\n\nexport * from './lib/dynamic-snackbar';\nexport * from './lib/dynamic-snackbar.service';\nexport * from './lib/dynamic-snackbar.modal';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;MA2Ba,eAAe,CAAA;AAIjB,IAAA,IAAA;AAEC,IAAA,WAAA;IAJV,WAAA,CAES,IAAoB,EAEnB,WACuB,EAAA;QAHxB,IAAA,CAAA,IAAI,GAAJ,IAAI;QAE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AC;AACR,YAAA,IAAI,EAAE,SAAS;YACf,KAAK;YACL;AACD,SAAA,CAAC;IACJ;IAEO,IAAI,CACT,OAAe,EACf,KAAc,EAAA;QAGd,IAAI,CAAC,IAAI,CAAC;AACR,YAAA,IAAI,EAAE,MAAM;YACZ,KAAK;YACL;AACD,SAAA,CAAC;IACJ;uGAjFW,eAAe,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,WAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAf,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,eAAe,cAFd,MAAM,EAAA,CAAA;;2FAEP,eAAe,EAAA,UAAA,EAAA,CAAA;kBAH3B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE;AACb,iBAAA;;;AClBD;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "devlab-one-dynamic-toast",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^21.2.0",
|
|
6
|
+
"@angular/core": "^21.2.0"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"tslib": "^2.3.0"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"module": "fesm2022/devlab-one-dynamic-toast.mjs",
|
|
13
|
+
"typings": "types/devlab-one-dynamic-toast.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
"./package.json": {
|
|
16
|
+
"default": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./types/devlab-one-dynamic-toast.d.ts",
|
|
20
|
+
"default": "./fesm2022/devlab-one-dynamic-toast.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"type": "module"
|
|
24
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { MatSnackBarRef, MatSnackBar } from '@angular/material/snack-bar';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
|
|
4
|
+
type SnackbarType = 'success' | 'error' | 'warning' | 'info';
|
|
5
|
+
interface SnackbarConfig {
|
|
6
|
+
title?: string;
|
|
7
|
+
message: string;
|
|
8
|
+
type?: SnackbarType;
|
|
9
|
+
duration?: number;
|
|
10
|
+
enableHtml?: boolean;
|
|
11
|
+
horizontalPosition?: 'start' | 'center' | 'end' | 'left' | 'right';
|
|
12
|
+
verticalPosition?: 'top' | 'bottom';
|
|
13
|
+
panelClass?: string[];
|
|
14
|
+
action?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare class DynamicSnackbar {
|
|
18
|
+
data: SnackbarConfig;
|
|
19
|
+
private snackBarRef;
|
|
20
|
+
constructor(data: SnackbarConfig, snackBarRef: MatSnackBarRef<DynamicSnackbar>);
|
|
21
|
+
close(): void;
|
|
22
|
+
get icon(): string;
|
|
23
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DynamicSnackbar, never>;
|
|
24
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DynamicSnackbar, "lib-snackbar", never, {}, {}, never, never, true, never>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare class SnackbarService {
|
|
28
|
+
private snackBar;
|
|
29
|
+
constructor(snackBar: MatSnackBar);
|
|
30
|
+
show(config: SnackbarConfig): void;
|
|
31
|
+
success(message: string, title?: string): void;
|
|
32
|
+
error(message: string, title?: string): void;
|
|
33
|
+
warning(message: string, title?: string): void;
|
|
34
|
+
info(message: string, title?: string): void;
|
|
35
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SnackbarService, never>;
|
|
36
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<SnackbarService>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { DynamicSnackbar, SnackbarService };
|
|
40
|
+
export type { SnackbarConfig, SnackbarType };
|