@su-labs/notifications 19.3.1 → 20.3.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/README.md +6 -6
- package/fesm2022/su-labs-notifications.mjs +7 -7
- package/fesm2022/su-labs-notifications.mjs.map +1 -1
- package/index.d.ts +110 -3
- package/package.json +3 -3
- package/lib/notification.component.d.ts +0 -47
- package/lib/notification.service.d.ts +0 -62
- package/public-api.d.ts +0 -3
package/README.md
CHANGED
|
@@ -61,24 +61,24 @@ A highly customizable Angular notification library built with modern practices,
|
|
|
61
61
|
You can install this library via npm:
|
|
62
62
|
|
|
63
63
|
```sh
|
|
64
|
-
npm install @su-labs/notifications@
|
|
64
|
+
npm install @su-labs/notifications@ng20
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
This is the Angular
|
|
67
|
+
This is the Angular 20 version. For the newest Angular, install `@su-labs/notifications` without a tag. Before Angular 20.2, notifications show and hide without the slide animation.
|
|
68
68
|
|
|
69
69
|
## Peer Dependencies
|
|
70
70
|
|
|
71
71
|
This library requires the following peer dependencies:
|
|
72
72
|
|
|
73
73
|
```sh
|
|
74
|
-
npm install @angular/common@^
|
|
74
|
+
npm install @angular/common@^20 @angular/core@^20
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
## Quick Start
|
|
78
78
|
|
|
79
79
|
```typescript
|
|
80
80
|
// 1. Install
|
|
81
|
-
npm install @su-labs/notifications@
|
|
81
|
+
npm install @su-labs/notifications@ng20
|
|
82
82
|
|
|
83
83
|
// 2. Add component to your app template
|
|
84
84
|
// app.component.html
|
|
@@ -333,7 +333,7 @@ The component's icons are rendered using `[innerHTML]` to safely inject SVG mark
|
|
|
333
333
|
Works in all modern browsers that support:
|
|
334
334
|
- CSS Flexbox
|
|
335
335
|
- CSS Animations
|
|
336
|
-
- Angular
|
|
336
|
+
- Angular 20
|
|
337
337
|
- ES2022+
|
|
338
338
|
|
|
339
339
|
| Browser | Version |
|
|
@@ -368,7 +368,7 @@ Set the position property during app initialization using `provideAppInitializer
|
|
|
368
368
|
|
|
369
369
|
### TypeScript errors?
|
|
370
370
|
|
|
371
|
-
Ensure you have Angular
|
|
371
|
+
Ensure you have Angular 20 and TypeScript 5.8+ installed.
|
|
372
372
|
|
|
373
373
|
## Support
|
|
374
374
|
|
|
@@ -13,7 +13,7 @@ class SuNotificationService {
|
|
|
13
13
|
/** Framework-agnostic notification logic */
|
|
14
14
|
controller = new SuNotificationController();
|
|
15
15
|
/** Internal signal holding the list of notifications, kept in sync with the controller */
|
|
16
|
-
_notifications = signal(this.controller.notifications.get());
|
|
16
|
+
_notifications = signal(this.controller.notifications.get(), ...(ngDevMode ? [{ debugName: "_notifications" }] : []));
|
|
17
17
|
/**
|
|
18
18
|
* Read-only access to the notifications list.
|
|
19
19
|
* Can be used in templates for reactive updates.
|
|
@@ -78,10 +78,10 @@ class SuNotificationService {
|
|
|
78
78
|
this.unsubscribe();
|
|
79
79
|
this.controller.destroy();
|
|
80
80
|
}
|
|
81
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
82
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
81
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuNotificationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
82
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuNotificationService, providedIn: 'root' });
|
|
83
83
|
}
|
|
84
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
84
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuNotificationService, decorators: [{
|
|
85
85
|
type: Injectable,
|
|
86
86
|
args: [{ providedIn: 'root' }]
|
|
87
87
|
}] });
|
|
@@ -137,10 +137,10 @@ class SuNotificationComponent {
|
|
|
137
137
|
getSanitizedIcon(icon) {
|
|
138
138
|
return this.sanitizer.bypassSecurityTrustHtml(icon);
|
|
139
139
|
}
|
|
140
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
141
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
140
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuNotificationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
141
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.35", type: SuNotificationComponent, isStandalone: true, selector: "su-lib-notifications", ngImport: i0, template: "<div class=\"notification-container {{ service.position }}\" [attr.data-slide]=\"service.slideFrom\">\n\t@for (notification of notifications(); track notification.id) {\n\t<div\n\t\tclass=\"notification {{ notification.type }} {{ notification.cssClass ?? '' }}\"\n\t\tanimate.enter=\"su-notification-enter\"\n\t\tanimate.leave=\"su-notification-leave\"\n\t>\n\n\t\t<div class=\"icon-container\">\n\t\t\t@if (notification.icon) {\n\t\t\t\t@if (isImage(notification.icon!)) {\n\t\t\t\t\t<img [src]=\"notification.icon\" alt=\"icon\" />\n\t\t\t\t} @else if (typeof notification.icon === 'string') {\n\t\t\t\t\t<span [innerHTML]=\"getSanitizedIcon(notification.icon)\"></span>\n\t\t\t\t}\n\t\t\t\t@else {\n\t\t\t\t\t@switch (notification.type) {\n\t\t\t\t\t@case('success') {\n\t\t\t\t\t\t<svg class=\"icon\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t\t\t\t\t<path d=\"M20 6L9 17l-5-5\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t}\n\t\t\t\t\t@case('info') {\n\t\t\t\t\t\t<svg class=\"icon\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t\t\t\t\t<circle cx=\"12\" cy=\"12\" r=\"10\" />\n\t\t\t\t\t\t\t<line x1=\"12\" y1=\"16\" x2=\"12\" y2=\"12\" />\n\t\t\t\t\t\t\t<line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"8\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t}\n\t\t\t\t\t@case('warning') {\n\t\t\t\t\t\t<svg class=\"icon\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t\t\t\t\t<path d=\"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z\" />\n\t\t\t\t\t\t\t<line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\" />\n\t\t\t\t\t\t\t<line x1=\"12\" y1=\"17\" x2=\"12\" y2=\"17\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t}\n\t\t\t\t\t@case('error') {\n\t\t\t\t\t\t<svg class=\"icon\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t\t\t\t\t<circle cx=\"12\" cy=\"12\" r=\"10\" />\n\t\t\t\t\t\t\t<line x1=\"15\" y1=\"9\" x2=\"9\" y2=\"15\" />\n\t\t\t\t\t\t\t<line x1=\"9\" y1=\"9\" x2=\"15\" y2=\"15\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t</div>\n\n\t\t<div class=\"content\">\n\t\t\t<span class=\"message\">\n\t\t\t\t@if (typeof notification.message === 'string') {\n\t\t\t\t\t{{ notification.message }}\n\t\t\t\t} @else {\n\t\t\t\t\t@for (part of notification.message; track $index) {\n\t\t\t\t\t\t@if (typeof part === 'string') {{{ part }}} @else {<button class=\"link\" type=\"button\" (click)=\"runAction(notification.id, part)\">{{ part.label }}</button>}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t</span>\n\n\t\t\t@if (notification.actions?.length) {\n\t\t\t<div class=\"actions\">\n\t\t\t\t@for (action of notification.actions; track $index) {\n\t\t\t\t<button class=\"action\" type=\"button\" (click)=\"runAction(notification.id, action)\">{{ action.label }}</button>\n\t\t\t\t}\n\t\t\t</div>\n\t\t\t}\n\t\t</div>\n\n\t\t<button class=\"close\" (click)=\"dismiss(notification.id)\" type=\"button\">\u00D7</button>\n\t</div>\n\t}\n</div>\n\n\n", styles: [".notification-container{--_edge: var(--su-notification-container-position, 1rem);--_left: calc(-100% - 2rem) 0;--_right: calc(100% + 2rem) 0;--_top: 0 calc(-100% - 2rem) ;--_bottom: 0 calc(100% + 2rem) ;position:fixed;pointer-events:none;display:flex;flex-direction:column;gap:var(--su-notification-container-gap, 1.2rem);width:var(--su-notification-width, max-content);max-width:var(--su-notification-max-width, min(100% - 2rem, 300px));z-index:999999}.notification-container[class*=top-]{top:var(--_edge);--_slide: var(--_top)}.notification-container[class*=bottom-]{bottom:var(--_edge);flex-direction:column-reverse;--_slide: var(--_bottom)}.notification-container[class*=-right]{align-items:flex-end;right:var(--_edge);--_slide: var(--_right)}.notification-container[class*=-left]{align-items:flex-start;left:var(--_edge);--_slide: var(--_left)}.notification-container[class*=-center]{align-items:center;left:50%;translate:-50% 0}.notification-container[data-slide=left]{--_slide: var(--_left)}.notification-container[data-slide=right]{--_slide: var(--_right)}.notification-container[data-slide=top]{--_slide: var(--_top)}.notification-container[data-slide=bottom]{--_slide: var(--_bottom)}.notification{position:relative;pointer-events:auto;background-color:var(--su-notification-background-color, #fff);color:var(--su-notification-text-color, #333);padding-block:var(--su-notification-padding-block, 1rem);padding-inline:var(--su-notification-padding-inline, 1.25rem);--_shadow: 0 4px 8px var(--su-notification-box-shadow, rgba(0, 0, 0, .15));box-shadow:var(--_shadow);border-left:4px solid var(--_border);display:flex;align-items:center;gap:1rem}.notification.success{--_border: var(--su-notification-success-border-color, #4caf50)}.notification.info{--_border: var(--su-notification-info-border-color, #2196f3)}.notification.warning{--_border: var(--su-notification-warning-border-color, #ff9800)}.notification.error{--_border: var(--su-notification-error-border-color, #f44336)}.notification.custom{--_border: var(--su-notification-custom-border-color, #9c27b0)}.notification .close{--_size: var(--su-notification-close-btn-size, 20px);position:absolute;width:var(--_size);height:var(--_size);top:calc(var(--_size) / -2);right:calc(var(--_size) / -2);background:var(--su-notification-close-btn-background-color, var(--su-notification-background-color, #fff));color:var(--su-notification-close-btn-text-color, var(--su-notification-text-color, #333));border:1px solid var(--su-notification-close-btn-border-color, rgba(0, 0, 0, 0));border-radius:var(--su-notification-close-btn-border-radius, 50%);box-shadow:var(--_shadow);font-size:var(--su-notification-close-btn-font-size, 1rem);display:flex;justify-content:center;align-items:center;line-height:1;cursor:pointer}.notification .close:hover{background:var(--su-notification-close-btn-hover-background, rgba(51, 51, 51, .5));color:var(--su-notification-close-btn-hover-color, #fff)}.icon-container{display:flex;align-items:center;justify-content:center;width:var(--su-notification-icon-width, 24px);height:var(--su-notification-icon-height, var(--su-notification-icon-width, 24px));color:var(--su-notification-icon-color, currentColor)}.icon{width:100%;height:100%}.content{display:grid;flex:1;gap:.75rem}.actions{display:flex;flex-wrap:wrap;gap:.5rem}.action,.link{background:none;color:inherit;cursor:pointer;font:inherit}.action{border:1px solid var(--su-notification-action-border-color, currentColor);border-radius:6px;padding:.25rem .75rem}.link{border:0;padding:0;text-decoration:underline}.su-notification-enter{animation:su-notification-slide var(--su-notification-enter-duration, .4s) ease-out}.su-notification-leave{animation:su-notification-slide var(--su-notification-leave-duration, .3s) ease-in reverse forwards}@keyframes su-notification-slide{0%{opacity:0;translate:var(--_slide)}}@media(prefers-reduced-motion:reduce){.su-notification-enter,.su-notification-leave{animation:none}}\n"], changeDetection: i0.ChangeDetectionStrategy.Default });
|
|
142
142
|
}
|
|
143
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
143
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuNotificationComponent, decorators: [{
|
|
144
144
|
type: Component,
|
|
145
145
|
args: [{ selector: 'su-lib-notifications', standalone: true, changeDetection: ChangeDetectionStrategy.Default, template: "<div class=\"notification-container {{ service.position }}\" [attr.data-slide]=\"service.slideFrom\">\n\t@for (notification of notifications(); track notification.id) {\n\t<div\n\t\tclass=\"notification {{ notification.type }} {{ notification.cssClass ?? '' }}\"\n\t\tanimate.enter=\"su-notification-enter\"\n\t\tanimate.leave=\"su-notification-leave\"\n\t>\n\n\t\t<div class=\"icon-container\">\n\t\t\t@if (notification.icon) {\n\t\t\t\t@if (isImage(notification.icon!)) {\n\t\t\t\t\t<img [src]=\"notification.icon\" alt=\"icon\" />\n\t\t\t\t} @else if (typeof notification.icon === 'string') {\n\t\t\t\t\t<span [innerHTML]=\"getSanitizedIcon(notification.icon)\"></span>\n\t\t\t\t}\n\t\t\t\t@else {\n\t\t\t\t\t@switch (notification.type) {\n\t\t\t\t\t@case('success') {\n\t\t\t\t\t\t<svg class=\"icon\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t\t\t\t\t<path d=\"M20 6L9 17l-5-5\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t}\n\t\t\t\t\t@case('info') {\n\t\t\t\t\t\t<svg class=\"icon\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t\t\t\t\t<circle cx=\"12\" cy=\"12\" r=\"10\" />\n\t\t\t\t\t\t\t<line x1=\"12\" y1=\"16\" x2=\"12\" y2=\"12\" />\n\t\t\t\t\t\t\t<line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"8\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t}\n\t\t\t\t\t@case('warning') {\n\t\t\t\t\t\t<svg class=\"icon\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t\t\t\t\t<path d=\"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z\" />\n\t\t\t\t\t\t\t<line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\" />\n\t\t\t\t\t\t\t<line x1=\"12\" y1=\"17\" x2=\"12\" y2=\"17\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t}\n\t\t\t\t\t@case('error') {\n\t\t\t\t\t\t<svg class=\"icon\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t\t\t\t\t<circle cx=\"12\" cy=\"12\" r=\"10\" />\n\t\t\t\t\t\t\t<line x1=\"15\" y1=\"9\" x2=\"9\" y2=\"15\" />\n\t\t\t\t\t\t\t<line x1=\"9\" y1=\"9\" x2=\"15\" y2=\"15\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t</div>\n\n\t\t<div class=\"content\">\n\t\t\t<span class=\"message\">\n\t\t\t\t@if (typeof notification.message === 'string') {\n\t\t\t\t\t{{ notification.message }}\n\t\t\t\t} @else {\n\t\t\t\t\t@for (part of notification.message; track $index) {\n\t\t\t\t\t\t@if (typeof part === 'string') {{{ part }}} @else {<button class=\"link\" type=\"button\" (click)=\"runAction(notification.id, part)\">{{ part.label }}</button>}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t</span>\n\n\t\t\t@if (notification.actions?.length) {\n\t\t\t<div class=\"actions\">\n\t\t\t\t@for (action of notification.actions; track $index) {\n\t\t\t\t<button class=\"action\" type=\"button\" (click)=\"runAction(notification.id, action)\">{{ action.label }}</button>\n\t\t\t\t}\n\t\t\t</div>\n\t\t\t}\n\t\t</div>\n\n\t\t<button class=\"close\" (click)=\"dismiss(notification.id)\" type=\"button\">\u00D7</button>\n\t</div>\n\t}\n</div>\n\n\n", styles: [".notification-container{--_edge: var(--su-notification-container-position, 1rem);--_left: calc(-100% - 2rem) 0;--_right: calc(100% + 2rem) 0;--_top: 0 calc(-100% - 2rem) ;--_bottom: 0 calc(100% + 2rem) ;position:fixed;pointer-events:none;display:flex;flex-direction:column;gap:var(--su-notification-container-gap, 1.2rem);width:var(--su-notification-width, max-content);max-width:var(--su-notification-max-width, min(100% - 2rem, 300px));z-index:999999}.notification-container[class*=top-]{top:var(--_edge);--_slide: var(--_top)}.notification-container[class*=bottom-]{bottom:var(--_edge);flex-direction:column-reverse;--_slide: var(--_bottom)}.notification-container[class*=-right]{align-items:flex-end;right:var(--_edge);--_slide: var(--_right)}.notification-container[class*=-left]{align-items:flex-start;left:var(--_edge);--_slide: var(--_left)}.notification-container[class*=-center]{align-items:center;left:50%;translate:-50% 0}.notification-container[data-slide=left]{--_slide: var(--_left)}.notification-container[data-slide=right]{--_slide: var(--_right)}.notification-container[data-slide=top]{--_slide: var(--_top)}.notification-container[data-slide=bottom]{--_slide: var(--_bottom)}.notification{position:relative;pointer-events:auto;background-color:var(--su-notification-background-color, #fff);color:var(--su-notification-text-color, #333);padding-block:var(--su-notification-padding-block, 1rem);padding-inline:var(--su-notification-padding-inline, 1.25rem);--_shadow: 0 4px 8px var(--su-notification-box-shadow, rgba(0, 0, 0, .15));box-shadow:var(--_shadow);border-left:4px solid var(--_border);display:flex;align-items:center;gap:1rem}.notification.success{--_border: var(--su-notification-success-border-color, #4caf50)}.notification.info{--_border: var(--su-notification-info-border-color, #2196f3)}.notification.warning{--_border: var(--su-notification-warning-border-color, #ff9800)}.notification.error{--_border: var(--su-notification-error-border-color, #f44336)}.notification.custom{--_border: var(--su-notification-custom-border-color, #9c27b0)}.notification .close{--_size: var(--su-notification-close-btn-size, 20px);position:absolute;width:var(--_size);height:var(--_size);top:calc(var(--_size) / -2);right:calc(var(--_size) / -2);background:var(--su-notification-close-btn-background-color, var(--su-notification-background-color, #fff));color:var(--su-notification-close-btn-text-color, var(--su-notification-text-color, #333));border:1px solid var(--su-notification-close-btn-border-color, rgba(0, 0, 0, 0));border-radius:var(--su-notification-close-btn-border-radius, 50%);box-shadow:var(--_shadow);font-size:var(--su-notification-close-btn-font-size, 1rem);display:flex;justify-content:center;align-items:center;line-height:1;cursor:pointer}.notification .close:hover{background:var(--su-notification-close-btn-hover-background, rgba(51, 51, 51, .5));color:var(--su-notification-close-btn-hover-color, #fff)}.icon-container{display:flex;align-items:center;justify-content:center;width:var(--su-notification-icon-width, 24px);height:var(--su-notification-icon-height, var(--su-notification-icon-width, 24px));color:var(--su-notification-icon-color, currentColor)}.icon{width:100%;height:100%}.content{display:grid;flex:1;gap:.75rem}.actions{display:flex;flex-wrap:wrap;gap:.5rem}.action,.link{background:none;color:inherit;cursor:pointer;font:inherit}.action{border:1px solid var(--su-notification-action-border-color, currentColor);border-radius:6px;padding:.25rem .75rem}.link{border:0;padding:0;text-decoration:underline}.su-notification-enter{animation:su-notification-slide var(--su-notification-enter-duration, .4s) ease-out}.su-notification-leave{animation:su-notification-slide var(--su-notification-leave-duration, .3s) ease-in reverse forwards}@keyframes su-notification-slide{0%{opacity:0;translate:var(--_slide)}}@media(prefers-reduced-motion:reduce){.su-notification-enter,.su-notification-leave{animation:none}}\n"] }]
|
|
146
146
|
}] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"su-labs-notifications.mjs","sources":["../../../../compat/angular-19/build/notifications/src/lib/notification.service.ts","../../../../compat/angular-19/build/notifications/src/lib/notification.component.ts","../../../../compat/angular-19/build/notifications/src/lib/notification.component.html","../../../../compat/angular-19/build/notifications/src/su-labs-notifications.ts"],"sourcesContent":["import { Injectable, OnDestroy, signal } from '@angular/core';\nimport {\n SuNotification,\n SuNotificationConfig,\n SuNotificationController,\n SuNotificationOptions,\n SuNotificationPosition,\n SuNotificationSlide,\n} from '@su-labs/core/notifications';\n\n/**\n * Angular service for managing notifications.\n *\n * Thin wrapper around the framework-agnostic `SuNotificationController` from\n * `@su-labs/core/notifications` that exposes the notifications as an Angular signal.\n */\n@Injectable({ providedIn: 'root' })\nexport class SuNotificationService implements OnDestroy {\n /** Framework-agnostic notification logic */\n private readonly controller = new SuNotificationController();\n\n /** Internal signal holding the list of notifications, kept in sync with the controller */\n private readonly _notifications = signal<SuNotification[]>(this.controller.notifications.get());\n\n /**\n * Read-only access to the notifications list.\n * Can be used in templates for reactive updates.\n */\n readonly notifications = this._notifications.asReadonly();\n\n /** Stops syncing the controller's notifications into the signal */\n private readonly unsubscribe = this.controller.notifications.subscribe((list) => this._notifications.set(list));\n\n /**\n * Position where notifications appear on the screen.\n * Can also be set via the `configure` method.\n * @default 'top-right'\n */\n get position(): SuNotificationPosition {\n return this.controller.position.get();\n }\n\n set position(position: SuNotificationPosition) {\n this.controller.configure({ position });\n }\n\n /**\n * The direction notifications slide in from, whatever their position.\n * Can also be set via the `configure` method.\n * @default 'auto'\n */\n get slideFrom(): SuNotificationSlide {\n return this.controller.slideFrom.get();\n }\n\n set slideFrom(slideFrom: SuNotificationSlide) {\n this.controller.configure({ slideFrom });\n }\n\n /**\n * Configure the notification service.\n * @param cfg Configuration object\n * @param cfg.position Optional position to display notifications.\n * @param cfg.slideFrom Optional direction notifications slide in from.\n */\n configure(cfg: SuNotificationConfig): void {\n this.controller.configure(cfg);\n }\n\n /**\n * Show a new notification.\n * @param options Options to configure the notification.\n * @returns The unique ID of the notification.\n */\n show(options: SuNotificationOptions): string {\n return this.controller.show(options);\n }\n\n /**\n * Dismiss a specific notification by its ID.\n * @param id ID of the notification to remove.\n */\n dismiss(id: string): void {\n this.controller.dismiss(id);\n }\n\n /**\n * Clear all notifications immediately.\n */\n clearAll(): void {\n this.controller.clearAll();\n }\n\n /** Angular lifecycle hook for service destruction */\n ngOnDestroy(): void {\n this.unsubscribe();\n this.controller.destroy();\n }\n}\n","import { Component, inject, ChangeDetectionStrategy } from '@angular/core';\nimport { SuNotificationService } from './notification.service';\nimport { DomSanitizer, SafeHtml } from '@angular/platform-browser';\nimport { isSuNotificationImageIcon, SuNotificationAction } from '@su-labs/core/notifications';\n\n/**\n * Component to display notifications on the screen.\n *\n * Uses `SuNotificationService` to manage and render notifications.\n */\n@Component({\n selector: 'su-lib-notifications',\n standalone: true,\n templateUrl: './notification.component.html',\n changeDetection: ChangeDetectionStrategy.Default,\n styleUrls: ['./notification.component.scss'],\n})\nexport class SuNotificationComponent {\n /** Injected notification service */\n service = inject(SuNotificationService);\n\n /** Read-only signal of the current notifications */\n notifications = this.service.notifications;\n\n /** Angular sanitizer to safely render inline SVG strings */\n private sanitizer = inject(DomSanitizer);\n\n /**\n * Dismiss a notification by its ID.\n * Delegates to the service.\n * @param id ID of the notification to dismiss\n */\n dismiss(id: string): void {\n this.service.dismiss(id);\n }\n\n /**\n * Runs an action button of a notification, then closes the notification unless the action says not to.\n * @param id ID of the notification the button belongs to\n * @param action The action that was pressed\n */\n runAction(id: string, action: SuNotificationAction): void {\n action.onClick();\n if (action.dismiss !== false) {\n this.service.dismiss(id);\n }\n }\n\n /**\n * Checks if the provided `icon` value should be rendered as an image (`<img>`).\n * Inline SVG strings are rendered with `[innerHTML]` instead.\n * See `isSuNotificationImageIcon` in `@su-labs/core/notifications` for the rules.\n *\n * @param icon The icon value from the notification (boolean or string)\n * @returns `true` if the icon is an image path or URL\n */\n isImage(icon: string | boolean): boolean {\n return isSuNotificationImageIcon(icon);\n }\n\n /**\n * Sanitizes an inline SVG string so it can be safely rendered with [innerHTML].\n *\n * @param icon Inline SVG string\n * @returns SafeHtml object that can be bound to [innerHTML]\n */\n getSanitizedIcon(icon: string): SafeHtml {\n return this.sanitizer.bypassSecurityTrustHtml(icon);\n }\n}\n","<div class=\"notification-container {{ service.position }}\" [attr.data-slide]=\"service.slideFrom\">\n\t@for (notification of notifications(); track notification.id) {\n\t<div\n\t\tclass=\"notification {{ notification.type }} {{ notification.cssClass ?? '' }}\"\n\t\tanimate.enter=\"su-notification-enter\"\n\t\tanimate.leave=\"su-notification-leave\"\n\t>\n\n\t\t<div class=\"icon-container\">\n\t\t\t@if (notification.icon) {\n\t\t\t\t@if (isImage(notification.icon!)) {\n\t\t\t\t\t<img [src]=\"notification.icon\" alt=\"icon\" />\n\t\t\t\t} @else if (typeof notification.icon === 'string') {\n\t\t\t\t\t<span [innerHTML]=\"getSanitizedIcon(notification.icon)\"></span>\n\t\t\t\t}\n\t\t\t\t@else {\n\t\t\t\t\t@switch (notification.type) {\n\t\t\t\t\t@case('success') {\n\t\t\t\t\t\t<svg class=\"icon\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t\t\t\t\t<path d=\"M20 6L9 17l-5-5\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t}\n\t\t\t\t\t@case('info') {\n\t\t\t\t\t\t<svg class=\"icon\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t\t\t\t\t<circle cx=\"12\" cy=\"12\" r=\"10\" />\n\t\t\t\t\t\t\t<line x1=\"12\" y1=\"16\" x2=\"12\" y2=\"12\" />\n\t\t\t\t\t\t\t<line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"8\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t}\n\t\t\t\t\t@case('warning') {\n\t\t\t\t\t\t<svg class=\"icon\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t\t\t\t\t<path d=\"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z\" />\n\t\t\t\t\t\t\t<line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\" />\n\t\t\t\t\t\t\t<line x1=\"12\" y1=\"17\" x2=\"12\" y2=\"17\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t}\n\t\t\t\t\t@case('error') {\n\t\t\t\t\t\t<svg class=\"icon\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t\t\t\t\t<circle cx=\"12\" cy=\"12\" r=\"10\" />\n\t\t\t\t\t\t\t<line x1=\"15\" y1=\"9\" x2=\"9\" y2=\"15\" />\n\t\t\t\t\t\t\t<line x1=\"9\" y1=\"9\" x2=\"15\" y2=\"15\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t</div>\n\n\t\t<div class=\"content\">\n\t\t\t<span class=\"message\">\n\t\t\t\t@if (typeof notification.message === 'string') {\n\t\t\t\t\t{{ notification.message }}\n\t\t\t\t} @else {\n\t\t\t\t\t@for (part of notification.message; track $index) {\n\t\t\t\t\t\t@if (typeof part === 'string') {{{ part }}} @else {<button class=\"link\" type=\"button\" (click)=\"runAction(notification.id, part)\">{{ part.label }}</button>}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t</span>\n\n\t\t\t@if (notification.actions?.length) {\n\t\t\t<div class=\"actions\">\n\t\t\t\t@for (action of notification.actions; track $index) {\n\t\t\t\t<button class=\"action\" type=\"button\" (click)=\"runAction(notification.id, action)\">{{ action.label }}</button>\n\t\t\t\t}\n\t\t\t</div>\n\t\t\t}\n\t\t</div>\n\n\t\t<button class=\"close\" (click)=\"dismiss(notification.id)\" type=\"button\">×</button>\n\t</div>\n\t}\n</div>\n\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAUA;;;;;AAKG;MAEU,qBAAqB,CAAA;;AAEf,IAAA,UAAU,GAAG,IAAI,wBAAwB,EAAE;;AAG3C,IAAA,cAAc,GAAG,MAAM,CAAmB,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC;AAE/F;;;AAGG;AACM,IAAA,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE;;IAGxC,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAE/G;;;;AAIG;AACH,IAAA,IAAI,QAAQ,GAAA;QACV,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE;IACvC;IAEA,IAAI,QAAQ,CAAC,QAAgC,EAAA;QAC3C,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACzC;AAEA;;;;AAIG;AACH,IAAA,IAAI,SAAS,GAAA;QACX,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CA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js","sources":["../../../../compat/angular-20/build/notifications/src/lib/notification.service.ts","../../../../compat/angular-20/build/notifications/src/lib/notification.component.ts","../../../../compat/angular-20/build/notifications/src/lib/notification.component.html","../../../../compat/angular-20/build/notifications/src/su-labs-notifications.ts"],"sourcesContent":["import { Injectable, OnDestroy, signal } from '@angular/core';\nimport {\n SuNotification,\n SuNotificationConfig,\n SuNotificationController,\n SuNotificationOptions,\n SuNotificationPosition,\n SuNotificationSlide,\n} from '@su-labs/core/notifications';\n\n/**\n * Angular service for managing notifications.\n *\n * Thin wrapper around the framework-agnostic `SuNotificationController` from\n * `@su-labs/core/notifications` that exposes the notifications as an Angular signal.\n */\n@Injectable({ providedIn: 'root' })\nexport class SuNotificationService implements OnDestroy {\n /** Framework-agnostic notification logic */\n private readonly controller = new SuNotificationController();\n\n /** Internal signal holding the list of notifications, kept in sync with the controller */\n private readonly _notifications = signal<SuNotification[]>(this.controller.notifications.get());\n\n /**\n * Read-only access to the notifications list.\n * Can be used in templates for reactive updates.\n */\n readonly notifications = this._notifications.asReadonly();\n\n /** Stops syncing the controller's notifications into the signal */\n private readonly unsubscribe = this.controller.notifications.subscribe((list) => this._notifications.set(list));\n\n /**\n * Position where notifications appear on the screen.\n * Can also be set via the `configure` method.\n * @default 'top-right'\n */\n get position(): SuNotificationPosition {\n return this.controller.position.get();\n }\n\n set position(position: SuNotificationPosition) {\n this.controller.configure({ position });\n }\n\n /**\n * The direction notifications slide in from, whatever their position.\n * Can also be set via the `configure` method.\n * @default 'auto'\n */\n get slideFrom(): SuNotificationSlide {\n return this.controller.slideFrom.get();\n }\n\n set slideFrom(slideFrom: SuNotificationSlide) {\n this.controller.configure({ slideFrom });\n }\n\n /**\n * Configure the notification service.\n * @param cfg Configuration object\n * @param cfg.position Optional position to display notifications.\n * @param cfg.slideFrom Optional direction notifications slide in from.\n */\n configure(cfg: SuNotificationConfig): void {\n this.controller.configure(cfg);\n }\n\n /**\n * Show a new notification.\n * @param options Options to configure the notification.\n * @returns The unique ID of the notification.\n */\n show(options: SuNotificationOptions): string {\n return this.controller.show(options);\n }\n\n /**\n * Dismiss a specific notification by its ID.\n * @param id ID of the notification to remove.\n */\n dismiss(id: string): void {\n this.controller.dismiss(id);\n }\n\n /**\n * Clear all notifications immediately.\n */\n clearAll(): void {\n this.controller.clearAll();\n }\n\n /** Angular lifecycle hook for service destruction */\n ngOnDestroy(): void {\n this.unsubscribe();\n this.controller.destroy();\n }\n}\n","import { Component, inject, ChangeDetectionStrategy } from '@angular/core';\nimport { SuNotificationService } from './notification.service';\nimport { DomSanitizer, SafeHtml } from '@angular/platform-browser';\nimport { isSuNotificationImageIcon, SuNotificationAction } from '@su-labs/core/notifications';\n\n/**\n * Component to display notifications on the screen.\n *\n * Uses `SuNotificationService` to manage and render notifications.\n */\n@Component({\n selector: 'su-lib-notifications',\n standalone: true,\n templateUrl: './notification.component.html',\n changeDetection: ChangeDetectionStrategy.Default,\n styleUrls: ['./notification.component.scss'],\n})\nexport class SuNotificationComponent {\n /** Injected notification service */\n service = inject(SuNotificationService);\n\n /** Read-only signal of the current notifications */\n notifications = this.service.notifications;\n\n /** Angular sanitizer to safely render inline SVG strings */\n private sanitizer = inject(DomSanitizer);\n\n /**\n * Dismiss a notification by its ID.\n * Delegates to the service.\n * @param id ID of the notification to dismiss\n */\n dismiss(id: string): void {\n this.service.dismiss(id);\n }\n\n /**\n * Runs an action button of a notification, then closes the notification unless the action says not to.\n * @param id ID of the notification the button belongs to\n * @param action The action that was pressed\n */\n runAction(id: string, action: SuNotificationAction): void {\n action.onClick();\n if (action.dismiss !== false) {\n this.service.dismiss(id);\n }\n }\n\n /**\n * Checks if the provided `icon` value should be rendered as an image (`<img>`).\n * Inline SVG strings are rendered with `[innerHTML]` instead.\n * See `isSuNotificationImageIcon` in `@su-labs/core/notifications` for the rules.\n *\n * @param icon The icon value from the notification (boolean or string)\n * @returns `true` if the icon is an image path or URL\n */\n isImage(icon: string | boolean): boolean {\n return isSuNotificationImageIcon(icon);\n }\n\n /**\n * Sanitizes an inline SVG string so it can be safely rendered with [innerHTML].\n *\n * @param icon Inline SVG string\n * @returns SafeHtml object that can be bound to [innerHTML]\n */\n getSanitizedIcon(icon: string): SafeHtml {\n return this.sanitizer.bypassSecurityTrustHtml(icon);\n }\n}\n","<div class=\"notification-container {{ service.position }}\" [attr.data-slide]=\"service.slideFrom\">\n\t@for (notification of notifications(); track notification.id) {\n\t<div\n\t\tclass=\"notification {{ notification.type }} {{ notification.cssClass ?? '' }}\"\n\t\tanimate.enter=\"su-notification-enter\"\n\t\tanimate.leave=\"su-notification-leave\"\n\t>\n\n\t\t<div class=\"icon-container\">\n\t\t\t@if (notification.icon) {\n\t\t\t\t@if (isImage(notification.icon!)) {\n\t\t\t\t\t<img [src]=\"notification.icon\" alt=\"icon\" />\n\t\t\t\t} @else if (typeof notification.icon === 'string') {\n\t\t\t\t\t<span [innerHTML]=\"getSanitizedIcon(notification.icon)\"></span>\n\t\t\t\t}\n\t\t\t\t@else {\n\t\t\t\t\t@switch (notification.type) {\n\t\t\t\t\t@case('success') {\n\t\t\t\t\t\t<svg class=\"icon\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t\t\t\t\t<path d=\"M20 6L9 17l-5-5\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t}\n\t\t\t\t\t@case('info') {\n\t\t\t\t\t\t<svg class=\"icon\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t\t\t\t\t<circle cx=\"12\" cy=\"12\" r=\"10\" />\n\t\t\t\t\t\t\t<line x1=\"12\" y1=\"16\" x2=\"12\" y2=\"12\" />\n\t\t\t\t\t\t\t<line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"8\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t}\n\t\t\t\t\t@case('warning') {\n\t\t\t\t\t\t<svg class=\"icon\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t\t\t\t\t<path d=\"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z\" />\n\t\t\t\t\t\t\t<line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\" />\n\t\t\t\t\t\t\t<line x1=\"12\" y1=\"17\" x2=\"12\" y2=\"17\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t}\n\t\t\t\t\t@case('error') {\n\t\t\t\t\t\t<svg class=\"icon\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"\n\t\t\t\t\t\t\tstroke-linecap=\"round\" stroke-linejoin=\"round\">\n\t\t\t\t\t\t\t<circle cx=\"12\" cy=\"12\" r=\"10\" />\n\t\t\t\t\t\t\t<line x1=\"15\" y1=\"9\" x2=\"9\" y2=\"15\" />\n\t\t\t\t\t\t\t<line x1=\"9\" y1=\"9\" x2=\"15\" y2=\"15\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t</div>\n\n\t\t<div class=\"content\">\n\t\t\t<span class=\"message\">\n\t\t\t\t@if (typeof notification.message === 'string') {\n\t\t\t\t\t{{ notification.message }}\n\t\t\t\t} @else {\n\t\t\t\t\t@for (part of notification.message; track $index) {\n\t\t\t\t\t\t@if (typeof part === 'string') {{{ part }}} @else {<button class=\"link\" type=\"button\" (click)=\"runAction(notification.id, part)\">{{ part.label }}</button>}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t</span>\n\n\t\t\t@if (notification.actions?.length) {\n\t\t\t<div class=\"actions\">\n\t\t\t\t@for (action of notification.actions; track $index) {\n\t\t\t\t<button class=\"action\" type=\"button\" (click)=\"runAction(notification.id, action)\">{{ action.label }}</button>\n\t\t\t\t}\n\t\t\t</div>\n\t\t\t}\n\t\t</div>\n\n\t\t<button class=\"close\" (click)=\"dismiss(notification.id)\" type=\"button\">×</button>\n\t</div>\n\t}\n</div>\n\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAUA;;;;;AAKG;MAEU,qBAAqB,CAAA;;AAEf,IAAA,UAAU,GAAG,IAAI,wBAAwB,EAAE;;AAG3C,IAAA,cAAc,GAAG,MAAM,CAAmB,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,GAAG,EAAE,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,gBAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAC;AAE/F;;;AAGG;AACM,IAAA,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE;;IAGxC,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAE/G;;;;AAIG;AACH,IAAA,IAAI,QAAQ,GAAA;QACV,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE;IACvC;IAEA,IAAI,QAAQ,CAAC,QAAgC,EAAA;QAC3C,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACzC;AAEA;;;;AAIG;AACH,IAAA,IAAI,SAAS,GAAA;QACX,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,EAAE;IACxC;IAEA,IAAI,SAAS,CAAC,SAA8B,EAAA;QAC1C,IAAI,CAAC,UAAU,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import * as _su_labs_notifications from '@su-labs/notifications';
|
|
4
|
+
import { SuNotification, SuNotificationPosition, SuNotificationSlide, SuNotificationConfig, SuNotificationOptions, SuNotificationAction } from '@su-labs/core/notifications';
|
|
5
|
+
export { SuNotification, SuNotificationAction, SuNotificationConfig, SuNotificationMessagePart, SuNotificationOptions, SuNotificationPosition, SuNotificationSlide, SuNotificationType } from '@su-labs/core/notifications';
|
|
6
|
+
import { SafeHtml } from '@angular/platform-browser';
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
|
-
*
|
|
9
|
+
* Angular service for managing notifications.
|
|
10
|
+
*
|
|
11
|
+
* Thin wrapper around the framework-agnostic `SuNotificationController` from
|
|
12
|
+
* `@su-labs/core/notifications` that exposes the notifications as an Angular signal.
|
|
3
13
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
14
|
+
declare class SuNotificationService implements OnDestroy {
|
|
15
|
+
/** Framework-agnostic notification logic */
|
|
16
|
+
private readonly controller;
|
|
17
|
+
/** Internal signal holding the list of notifications, kept in sync with the controller */
|
|
18
|
+
private readonly _notifications;
|
|
19
|
+
/**
|
|
20
|
+
* Read-only access to the notifications list.
|
|
21
|
+
* Can be used in templates for reactive updates.
|
|
22
|
+
*/
|
|
23
|
+
readonly notifications: i0.Signal<SuNotification[]>;
|
|
24
|
+
/** Stops syncing the controller's notifications into the signal */
|
|
25
|
+
private readonly unsubscribe;
|
|
26
|
+
/**
|
|
27
|
+
* Position where notifications appear on the screen.
|
|
28
|
+
* Can also be set via the `configure` method.
|
|
29
|
+
* @default 'top-right'
|
|
30
|
+
*/
|
|
31
|
+
get position(): SuNotificationPosition;
|
|
32
|
+
set position(position: SuNotificationPosition);
|
|
33
|
+
/**
|
|
34
|
+
* The direction notifications slide in from, whatever their position.
|
|
35
|
+
* Can also be set via the `configure` method.
|
|
36
|
+
* @default 'auto'
|
|
37
|
+
*/
|
|
38
|
+
get slideFrom(): SuNotificationSlide;
|
|
39
|
+
set slideFrom(slideFrom: SuNotificationSlide);
|
|
40
|
+
/**
|
|
41
|
+
* Configure the notification service.
|
|
42
|
+
* @param cfg Configuration object
|
|
43
|
+
* @param cfg.position Optional position to display notifications.
|
|
44
|
+
* @param cfg.slideFrom Optional direction notifications slide in from.
|
|
45
|
+
*/
|
|
46
|
+
configure(cfg: SuNotificationConfig): void;
|
|
47
|
+
/**
|
|
48
|
+
* Show a new notification.
|
|
49
|
+
* @param options Options to configure the notification.
|
|
50
|
+
* @returns The unique ID of the notification.
|
|
51
|
+
*/
|
|
52
|
+
show(options: SuNotificationOptions): string;
|
|
53
|
+
/**
|
|
54
|
+
* Dismiss a specific notification by its ID.
|
|
55
|
+
* @param id ID of the notification to remove.
|
|
56
|
+
*/
|
|
57
|
+
dismiss(id: string): void;
|
|
58
|
+
/**
|
|
59
|
+
* Clear all notifications immediately.
|
|
60
|
+
*/
|
|
61
|
+
clearAll(): void;
|
|
62
|
+
/** Angular lifecycle hook for service destruction */
|
|
63
|
+
ngOnDestroy(): void;
|
|
64
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SuNotificationService, never>;
|
|
65
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<SuNotificationService>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Component to display notifications on the screen.
|
|
70
|
+
*
|
|
71
|
+
* Uses `SuNotificationService` to manage and render notifications.
|
|
72
|
+
*/
|
|
73
|
+
declare class SuNotificationComponent {
|
|
74
|
+
/** Injected notification service */
|
|
75
|
+
service: SuNotificationService;
|
|
76
|
+
/** Read-only signal of the current notifications */
|
|
77
|
+
notifications: i0.Signal<_su_labs_notifications.SuNotification[]>;
|
|
78
|
+
/** Angular sanitizer to safely render inline SVG strings */
|
|
79
|
+
private sanitizer;
|
|
80
|
+
/**
|
|
81
|
+
* Dismiss a notification by its ID.
|
|
82
|
+
* Delegates to the service.
|
|
83
|
+
* @param id ID of the notification to dismiss
|
|
84
|
+
*/
|
|
85
|
+
dismiss(id: string): void;
|
|
86
|
+
/**
|
|
87
|
+
* Runs an action button of a notification, then closes the notification unless the action says not to.
|
|
88
|
+
* @param id ID of the notification the button belongs to
|
|
89
|
+
* @param action The action that was pressed
|
|
90
|
+
*/
|
|
91
|
+
runAction(id: string, action: SuNotificationAction): void;
|
|
92
|
+
/**
|
|
93
|
+
* Checks if the provided `icon` value should be rendered as an image (`<img>`).
|
|
94
|
+
* Inline SVG strings are rendered with `[innerHTML]` instead.
|
|
95
|
+
* See `isSuNotificationImageIcon` in `@su-labs/core/notifications` for the rules.
|
|
96
|
+
*
|
|
97
|
+
* @param icon The icon value from the notification (boolean or string)
|
|
98
|
+
* @returns `true` if the icon is an image path or URL
|
|
99
|
+
*/
|
|
100
|
+
isImage(icon: string | boolean): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Sanitizes an inline SVG string so it can be safely rendered with [innerHTML].
|
|
103
|
+
*
|
|
104
|
+
* @param icon Inline SVG string
|
|
105
|
+
* @returns SafeHtml object that can be bound to [innerHTML]
|
|
106
|
+
*/
|
|
107
|
+
getSanitizedIcon(icon: string): SafeHtml;
|
|
108
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SuNotificationComponent, never>;
|
|
109
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SuNotificationComponent, "su-lib-notifications", never, {}, {}, never, never, true, never>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export { SuNotificationComponent, SuNotificationService };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@su-labs/notifications",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "20.3.1",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"angular",
|
|
6
6
|
"notifications",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"url": "https://github.com/Greezaaa/settings-utils-lib/issues"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@angular/common": "^
|
|
36
|
-
"@angular/core": "^
|
|
35
|
+
"@angular/common": "^20.0.0",
|
|
36
|
+
"@angular/core": "^20.0.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@su-labs/core": "1.9.0",
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { SuNotificationService } from './notification.service';
|
|
2
|
-
import { SafeHtml } from '@angular/platform-browser';
|
|
3
|
-
import { SuNotificationAction } from '@su-labs/core/notifications';
|
|
4
|
-
import * as i0 from "@angular/core";
|
|
5
|
-
/**
|
|
6
|
-
* Component to display notifications on the screen.
|
|
7
|
-
*
|
|
8
|
-
* Uses `SuNotificationService` to manage and render notifications.
|
|
9
|
-
*/
|
|
10
|
-
export declare class SuNotificationComponent {
|
|
11
|
-
/** Injected notification service */
|
|
12
|
-
service: SuNotificationService;
|
|
13
|
-
/** Read-only signal of the current notifications */
|
|
14
|
-
notifications: import("@angular/core").Signal<import("@su-labs/notifications").SuNotification[]>;
|
|
15
|
-
/** Angular sanitizer to safely render inline SVG strings */
|
|
16
|
-
private sanitizer;
|
|
17
|
-
/**
|
|
18
|
-
* Dismiss a notification by its ID.
|
|
19
|
-
* Delegates to the service.
|
|
20
|
-
* @param id ID of the notification to dismiss
|
|
21
|
-
*/
|
|
22
|
-
dismiss(id: string): void;
|
|
23
|
-
/**
|
|
24
|
-
* Runs an action button of a notification, then closes the notification unless the action says not to.
|
|
25
|
-
* @param id ID of the notification the button belongs to
|
|
26
|
-
* @param action The action that was pressed
|
|
27
|
-
*/
|
|
28
|
-
runAction(id: string, action: SuNotificationAction): void;
|
|
29
|
-
/**
|
|
30
|
-
* Checks if the provided `icon` value should be rendered as an image (`<img>`).
|
|
31
|
-
* Inline SVG strings are rendered with `[innerHTML]` instead.
|
|
32
|
-
* See `isSuNotificationImageIcon` in `@su-labs/core/notifications` for the rules.
|
|
33
|
-
*
|
|
34
|
-
* @param icon The icon value from the notification (boolean or string)
|
|
35
|
-
* @returns `true` if the icon is an image path or URL
|
|
36
|
-
*/
|
|
37
|
-
isImage(icon: string | boolean): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Sanitizes an inline SVG string so it can be safely rendered with [innerHTML].
|
|
40
|
-
*
|
|
41
|
-
* @param icon Inline SVG string
|
|
42
|
-
* @returns SafeHtml object that can be bound to [innerHTML]
|
|
43
|
-
*/
|
|
44
|
-
getSanitizedIcon(icon: string): SafeHtml;
|
|
45
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<SuNotificationComponent, never>;
|
|
46
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<SuNotificationComponent, "su-lib-notifications", never, {}, {}, never, never, true, never>;
|
|
47
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { OnDestroy } from '@angular/core';
|
|
2
|
-
import { SuNotification, SuNotificationConfig, SuNotificationOptions, SuNotificationPosition, SuNotificationSlide } from '@su-labs/core/notifications';
|
|
3
|
-
import * as i0 from "@angular/core";
|
|
4
|
-
/**
|
|
5
|
-
* Angular service for managing notifications.
|
|
6
|
-
*
|
|
7
|
-
* Thin wrapper around the framework-agnostic `SuNotificationController` from
|
|
8
|
-
* `@su-labs/core/notifications` that exposes the notifications as an Angular signal.
|
|
9
|
-
*/
|
|
10
|
-
export declare class SuNotificationService implements OnDestroy {
|
|
11
|
-
/** Framework-agnostic notification logic */
|
|
12
|
-
private readonly controller;
|
|
13
|
-
/** Internal signal holding the list of notifications, kept in sync with the controller */
|
|
14
|
-
private readonly _notifications;
|
|
15
|
-
/**
|
|
16
|
-
* Read-only access to the notifications list.
|
|
17
|
-
* Can be used in templates for reactive updates.
|
|
18
|
-
*/
|
|
19
|
-
readonly notifications: import("@angular/core").Signal<SuNotification[]>;
|
|
20
|
-
/** Stops syncing the controller's notifications into the signal */
|
|
21
|
-
private readonly unsubscribe;
|
|
22
|
-
/**
|
|
23
|
-
* Position where notifications appear on the screen.
|
|
24
|
-
* Can also be set via the `configure` method.
|
|
25
|
-
* @default 'top-right'
|
|
26
|
-
*/
|
|
27
|
-
get position(): SuNotificationPosition;
|
|
28
|
-
set position(position: SuNotificationPosition);
|
|
29
|
-
/**
|
|
30
|
-
* The direction notifications slide in from, whatever their position.
|
|
31
|
-
* Can also be set via the `configure` method.
|
|
32
|
-
* @default 'auto'
|
|
33
|
-
*/
|
|
34
|
-
get slideFrom(): SuNotificationSlide;
|
|
35
|
-
set slideFrom(slideFrom: SuNotificationSlide);
|
|
36
|
-
/**
|
|
37
|
-
* Configure the notification service.
|
|
38
|
-
* @param cfg Configuration object
|
|
39
|
-
* @param cfg.position Optional position to display notifications.
|
|
40
|
-
* @param cfg.slideFrom Optional direction notifications slide in from.
|
|
41
|
-
*/
|
|
42
|
-
configure(cfg: SuNotificationConfig): void;
|
|
43
|
-
/**
|
|
44
|
-
* Show a new notification.
|
|
45
|
-
* @param options Options to configure the notification.
|
|
46
|
-
* @returns The unique ID of the notification.
|
|
47
|
-
*/
|
|
48
|
-
show(options: SuNotificationOptions): string;
|
|
49
|
-
/**
|
|
50
|
-
* Dismiss a specific notification by its ID.
|
|
51
|
-
* @param id ID of the notification to remove.
|
|
52
|
-
*/
|
|
53
|
-
dismiss(id: string): void;
|
|
54
|
-
/**
|
|
55
|
-
* Clear all notifications immediately.
|
|
56
|
-
*/
|
|
57
|
-
clearAll(): void;
|
|
58
|
-
/** Angular lifecycle hook for service destruction */
|
|
59
|
-
ngOnDestroy(): void;
|
|
60
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<SuNotificationService, never>;
|
|
61
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<SuNotificationService>;
|
|
62
|
-
}
|
package/public-api.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export * from './lib/notification.component';
|
|
2
|
-
export * from './lib/notification.service';
|
|
3
|
-
export type { SuNotification, SuNotificationAction, SuNotificationConfig, SuNotificationMessagePart, SuNotificationOptions, SuNotificationPosition, SuNotificationSlide, SuNotificationType, } from '@su-labs/core/notifications';
|