@su-labs/notifications 1.0.2 → 20.3.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/CHANGELOG.md ADDED
@@ -0,0 +1,48 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [22.3.0] - 2026-11-07
11
+
12
+ ### Added
13
+ - Links inside the message: pass `message` as a list of text and links (`{ label, onClick, dismiss }`), each link closing the notification unless `dismiss: false`
14
+
15
+ ### Changed
16
+ - Depends on exactly `@su-labs/core` 1.3.0
17
+
18
+ ## [22.2.0] - 2026-11-07
19
+
20
+ ### Added
21
+ - Notifications slide in from their side of the screen and slide out when closed; durations set with `--su-notification-enter-duration` (400ms) and `--su-notification-leave-duration` (300ms), and no motion for visitors who prefer reduced motion
22
+ - `slideFrom` option (`'auto'`, `'left'`, `'right'`, `'top'`, `'bottom'`) to slide in from a chosen direction whatever the position, as `configure({ slideFrom })` or the `slideFrom` property
23
+ - `actions` option: buttons under the message (`label`, `onClick`, `dismiss`), each closing the notification unless `dismiss: false`
24
+
25
+ ### Changed
26
+ - Depends on exactly `@su-labs/core` 1.2.0 (no version range), so every install runs the core it was tested with
27
+
28
+ ### Documentation
29
+ - README lists every CSS variable, including `--su-notification-max-width` for wider notifications
30
+
31
+ ## [22.1.1] - 2026-11-05
32
+
33
+ ### Changed
34
+ - Package homepage now points to the website with a live demo
35
+
36
+ ### Fixed
37
+ - Notifications without `cssClass` rendered empty under Angular 22 (`NgClass` no longer accepts `undefined`); classes are now bound directly and `CommonModule` is no longer imported
38
+
39
+ ## [22.1.0] - 2026-11-05
40
+
41
+ ### Changed
42
+ - Notification logic moved to the framework-agnostic `@su-labs/core/notifications`; `SuNotificationService` is now an Angular wrapper around `SuNotificationController` with the same public API
43
+ - Added `@su-labs/core` as a dependency
44
+ - README links to the `@su-labs/core` installation guides for non-Angular projects
45
+
46
+ ### Fixed
47
+ - Auto-close timers are cancelled when a notification is dismissed or the service is destroyed
48
+ - Repair table of contents links in README.md
package/README.md CHANGED
@@ -1,7 +1,50 @@
1
1
  # Notifications
2
2
 
3
+ `@su-labs/notifications`
4
+
5
+ ![Angular](https://img.shields.io/badge/Angular-DD0031?style=for-the-badge&logo=angular&logoColor=white)
6
+ ![Angular Version](https://img.shields.io/badge/Angular-v22-DD0031?style=for-the-badge&logo=angular&logoColor=white)
7
+ ![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
8
+ ![License](https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge)
9
+ ![NPM](https://img.shields.io/badge/NPM-CB3837?style=for-the-badge&logo=npm&logoColor=white)
10
+ ![Size](https://img.shields.io/badge/Size-Small-green.svg?style=for-the-badge)
11
+ ![Downloads](https://img.shields.io/npm/dt/@su-labs/notifications?style=for-the-badge)
12
+ ![Version](https://img.shields.io/npm/v/@su-labs/notifications?style=for-the-badge)
13
+
3
14
  A highly customizable Angular notification library built with modern practices, including reactive Signals. Easily display different types of notifications with various positions, custom icons, and optional auto-closing behavior.
4
15
 
16
+ > **Not using Angular?** The same notification logic is available for React, Vue, Svelte, vanilla JavaScript and Node in [`@su-labs/core`](https://www.npmjs.com/package/@su-labs/core). See the [installation guides](https://github.com/Greezaaa/settings-utils-lib/blob/main/docs/README.md).
17
+
18
+ ## Table of Contents
19
+
20
+ - [Why Use This Library?](#why-use-this-library)
21
+ - [Features](#features)
22
+ - [Installation](#installation)
23
+ - [Quick Start](#quick-start)
24
+ - [Usage](#usage)
25
+ - [API Reference](#api-reference)
26
+ - [Configuration Options](#configuration-options)
27
+ - [Styling](#styling)
28
+ - [How It Works](#how-it-works)
29
+ - [Browser Compatibility](#browser-compatibility)
30
+ - [Related Libraries](#related-libraries)
31
+ - [Troubleshooting](#troubleshooting)
32
+ - [Support](#support)
33
+ - [Contributing](#contributing)
34
+ - [License](#license)
35
+
36
+ ## Why Use This Library?
37
+
38
+ - **Lightweight** - Minimal bundle size
39
+ - **Reactive** - Built with Angular Signals
40
+ - **Customizable** - Multiple themes and positions
41
+ - **Icon Support** - Default SVG or custom icons
42
+ - **Auto-dismiss** - Configurable duration
43
+ - **Type-Safe** - Full TypeScript support
44
+ - **Zero Dependencies** - No bloat
45
+ - **Well Tested** - Comprehensive test coverage
46
+ - **Well Documented** - Clear examples and API docs
47
+
5
48
  ## Features
6
49
 
7
50
  - **Reactive Core:** Built on Angular Signals for optimal performance and reactive updates.
@@ -26,7 +69,37 @@ npm install @su-labs/notifications
26
69
  This library requires the following peer dependencies:
27
70
 
28
71
  ```sh
29
- npm install @angular/common@">=20.1.0" @angular/core@">=20.1.0" @angular/platform-browser@">=20.1.0"
72
+ npm install @angular/common@^22 @angular/core@^22
73
+ ```
74
+
75
+ ## Quick Start
76
+
77
+ ```typescript
78
+ // 1. Install
79
+ npm install @su-labs/notifications
80
+
81
+ // 2. Add component to your app template
82
+ // app.component.html
83
+ <su-notifications></su-notifications>
84
+ <router-outlet></router-outlet>
85
+
86
+ // 3. Show notifications from any component
87
+ import { Component, inject } from '@angular/core';
88
+ import { SuNotificationService } from '@su-labs/notifications';
89
+
90
+ @Component({
91
+ template: `<button (click)="showSuccess()">Show Success</button>`
92
+ })
93
+ export class AppComponent {
94
+ notificationService = inject(SuNotificationService);
95
+
96
+ showSuccess() {
97
+ this.notificationService.show({
98
+ type: 'success',
99
+ message: 'Operation completed!'
100
+ });
101
+ }
102
+ }
30
103
  ```
31
104
 
32
105
  ## Usage
@@ -84,7 +157,7 @@ export class MyExampleComponent {
84
157
  this.notificationService.show({
85
158
  type: 'info',
86
159
  message: 'This is a custom icon notification.',
87
- icon: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-zap"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon></svg>`
160
+ icon: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon></svg>`
88
161
  });
89
162
  }
90
163
  }
@@ -94,7 +167,6 @@ export class MyExampleComponent {
94
167
 
95
168
  You can configure the global position of all notifications by directly setting the position property on the service instance. This is best done during application initialization.
96
169
 
97
-
98
170
  ```ts
99
171
  // src/app/app.config.ts
100
172
  import { ApplicationConfig, inject, provideAppInitializer } from '@angular/core';
@@ -111,6 +183,141 @@ export const appConfig: ApplicationConfig = {
111
183
  };
112
184
  ```
113
185
 
186
+ Notifications slide in from the side they sit on (from the left here). To slide them in from another direction, whatever the position, set `slideFrom` to `'left'`, `'right'`, `'top'` or `'bottom'` (`'auto'` is the default):
187
+
188
+ ```ts
189
+ notificationService.configure({ position: 'top-right', slideFrom: 'top' });
190
+ ```
191
+
192
+ ## API Reference
193
+
194
+ ### Service (SuNotificationService)
195
+
196
+ #### Properties
197
+
198
+ | Property | Type | Description |
199
+ |----------|------|-------------|
200
+ | `position` | `NotificationPosition` |
201
+
202
+ #### Methods
203
+
204
+ | Method | Parameters | Description |
205
+ |--------|------------|-------------|
206
+ | `show(config)` | `NotificationConfig` | Display a new notification |
207
+ | `dismiss(id)` | `string` | Manually dismiss a notification |
208
+
209
+ ### Types
210
+
211
+ ```typescript
212
+ type NotificationType = 'info' | 'success' | 'warning' | 'error' | 'custom';
213
+
214
+ type NotificationPosition =
215
+ | 'top-right'
216
+ | 'top-left'
217
+ | 'bottom-right'
218
+ | 'bottom-left'
219
+ | 'top-center'
220
+ | 'bottom-center';
221
+
222
+ interface NotificationConfig {
223
+ type: NotificationType;
224
+ message: string | (string | NotificationAction)[]; // Text, or text and links
225
+ duration?: number; // Default: 3000ms
226
+ autoClose?: boolean; // Default: true
227
+ cssClass?: string; // Custom CSS class
228
+ icon?: string; // Custom SVG string or image URL
229
+ actions?: NotificationAction[]; // Buttons under the message
230
+ }
231
+
232
+ interface NotificationAction {
233
+ label: string; // Button text
234
+ onClick: () => void; // Called when the button is pressed
235
+ dismiss?: boolean; // Close the notification afterwards (default: true)
236
+ }
237
+ ```
238
+
239
+ ### Action buttons
240
+
241
+ Give a notification `actions` to show buttons under its message, for example to undo or to open a page. Each button closes the notification after its `onClick` runs, unless it sets `dismiss: false`. Combine with `autoClose: false` to keep the notification until the user answers:
242
+
243
+ ```typescript
244
+ this.notifications.show({
245
+ type: 'info',
246
+ message: 'Photo deleted',
247
+ autoClose: false,
248
+ actions: [
249
+ { label: 'Undo', onClick: () => this.restorePhoto() },
250
+ { label: 'OK', onClick: () => {} },
251
+ ],
252
+ });
253
+ ```
254
+
255
+ ### Links in the message
256
+
257
+ Pass `message` as a list to make part of it a link. Text pieces show as they are; each `{ label, onClick }` piece is a link that runs `onClick`, then closes the notification unless it sets `dismiss: false`:
258
+
259
+ ```typescript
260
+ this.notifications.show({
261
+ type: 'info',
262
+ message: ['New: ', { label: 'Sliding puzzle', onClick: () => this.router.navigateByUrl('/sliding-puzzle') }],
263
+ });
264
+ ```
265
+
266
+ Restyle the links with the `.link` class inside `su-lib-notifications`.
267
+
268
+ ## Configuration Options
269
+
270
+ ### Notification Types
271
+
272
+ | Type | Description |
273
+ |------|-------------|
274
+ | `info` | Informational message |
275
+ | `success` | Success message |
276
+ | `warning` | Warning message |
277
+ | `error` | Error message |
278
+ | `custom` | Custom styled message |
279
+
280
+ ### Positions
281
+
282
+ | Position | Description |
283
+ |----------|-------------|
284
+ | `top-right` | Top right corner (default) |
285
+ | `top-left` | Top left corner |
286
+ | `top-center` | Top center |
287
+ | `bottom-right` | Bottom right corner |
288
+ | `bottom-left` | Bottom left corner |
289
+ | `bottom-center` | Bottom center |
290
+
291
+ ## Styling
292
+
293
+ Notifications slide in from the side of the screen they appear on and slide back out when they close (they simply appear and disappear for visitors who prefer reduced motion). Every part of a notification can be restyled with CSS variables, set on `:root` or any parent element. For example, to let long messages use more width:
294
+
295
+ ```css
296
+ :root {
297
+ --su-notification-max-width: min(100% - 2rem, 26rem);
298
+ }
299
+ ```
300
+
301
+ | Variable | Default | Controls |
302
+ |----------|---------|----------|
303
+ | `--su-notification-width` | `max-content` | Width of a notification; by default it fits its text |
304
+ | `--su-notification-max-width` | `min(100% - 2rem, 300px)` | Widest a notification gets before its text wraps |
305
+ | `--su-notification-padding-block` | `1rem` | Space above and below the text |
306
+ | `--su-notification-padding-inline` | `1.25rem` | Space left and right of the text |
307
+ | `--su-notification-container-gap` | `1.2rem` | Space between stacked notifications |
308
+ | `--su-notification-container-position` | `1rem` | Distance from the edges of the screen |
309
+ | `--su-notification-enter-duration` | `400ms` | How long a notification takes to slide in from its side of the screen |
310
+ | `--su-notification-leave-duration` | `300ms` | How long it takes to slide back out when closed |
311
+ | `--su-notification-background-color` | `#fff` | Background |
312
+ | `--su-notification-text-color` | `#333` | Text |
313
+ | `--su-notification-box-shadow` | `rgba(0, 0, 0, 0.15)` | Shadow colour |
314
+ | `--su-notification-info-border-color` | `#2196f3` | Left border of `info` (likewise `success`, `warning`, `error`, `custom`) |
315
+ | `--su-notification-icon-color` | `currentColor` | Icon colour |
316
+ | `--su-notification-icon-width` / `-height` | `24px` | Icon size |
317
+ | `--su-notification-action-border-color` | `currentColor` | Border of action buttons (they take the notification's text colour) |
318
+ | `--su-notification-close-btn-size` | `20px` | Close button size |
319
+ | `--su-notification-close-btn-background-color` | the background | Close button background (also `-text-color`, `-border-color`, `-border-radius`, `-font-size`, `-hover-background`, `-hover-color`) |
320
+
114
321
  ## How It Works
115
322
 
116
323
  The library consists of a stateless service (`SuNotificationService`) and a presentational component (`SuNotificationComponent`).
@@ -119,6 +326,54 @@ The service manages a list of notifications using a private Signal. When you cal
119
326
 
120
327
  The component's icons are rendered using `[innerHTML]` to safely inject SVG markup into the template. Angular's `DomSanitizer` is used to prevent security risks like Cross-Site Scripting (XSS) attacks.
121
328
 
329
+ ## Browser Compatibility
330
+
331
+ Works in all modern browsers that support:
332
+ - CSS Flexbox
333
+ - CSS Animations
334
+ - Angular 22+
335
+ - ES2022+
336
+
337
+ | Browser | Version |
338
+ |---------|---------|
339
+ | Chrome | ≥ 90 |
340
+ | Firefox | ≥ 88 |
341
+ | Safari | ≥ 14 |
342
+ | Edge | ≥ 90 |
343
+
344
+ ## Related Libraries
345
+
346
+ Part of the **@su-labs** suite:
347
+
348
+ - [@su-labs/visit-tracker](https://www.npmjs.com/package/@su-labs/visit-tracker) - User visit tracking
349
+ - [@su-labs/theme](https://www.npmjs.com/package/@su-labs/theme) - Theme management with dark mode support
350
+ - [@su-labs/scroll-spy](https://www.npmjs.com/package/@su-labs/scroll-spy) - Scroll position tracking
351
+ - [@su-labs/font-size](https://www.npmjs.com/package/@su-labs/font-size) - Accessible font size controls
352
+
353
+ ## Troubleshooting
354
+
355
+ ### Notifications not showing?
356
+
357
+ Make sure you've added `<su-notifications></su-notifications>` to your root component template.
358
+
359
+ ### Icons not displaying?
360
+
361
+ If using custom icons, ensure the SVG string is valid. For security, Angular sanitizes HTML by default.
362
+
363
+ ### Position not changing?
364
+
365
+ Set the position property during app initialization using `provideAppInitializer`.
366
+
367
+ ### TypeScript errors?
368
+
369
+ Ensure you have Angular 22+ and TypeScript 6.0+ installed.
370
+
371
+ ## Support
372
+
373
+ - Found a bug? [Open an issue](https://github.com/Greezaaa/settings-utils-lib/issues)
374
+ - Have a feature request? [Start a discussion](https://github.com/Greezaaa/settings-utils-lib/discussions)
375
+ - Like this library? [Give it a star!](https://github.com/Greezaaa/settings-utils-lib)
376
+
122
377
  ## Contributing
123
378
 
124
379
  If you find any bugs or have feature requests, please open an issue or submit a pull request on our [GitHub repository](https://github.com/Greezaaa/settings-utils-lib.git).
@@ -1,39 +1,56 @@
1
1
  import * as i0 from '@angular/core';
2
- import { signal, Injectable, inject, Component } from '@angular/core';
3
- import * as i1 from '@angular/common';
4
- import { CommonModule } from '@angular/common';
2
+ import { signal, Injectable, inject, ChangeDetectionStrategy, Component } from '@angular/core';
3
+ import { SuNotificationController, isSuNotificationImageIcon } from '@su-labs/core/notifications';
5
4
  import { DomSanitizer } from '@angular/platform-browser';
6
5
 
7
6
  /**
8
- * Service for managing notifications.
7
+ * Angular service for managing notifications.
9
8
  *
10
- * Provides methods to show, dismiss, and clear notifications.
11
- * Notifications are reactive signals, making them easy to bind in templates.
9
+ * Thin wrapper around the framework-agnostic `SuNotificationController` from
10
+ * `@su-labs/core/notifications` that exposes the notifications as an Angular signal.
12
11
  */
13
12
  class SuNotificationService {
14
- /**
15
- * Internal signal holding the list of notifications.
16
- */
17
- _notifications = signal([], ...(ngDevMode ? [{ debugName: "_notifications" }] : []));
13
+ /** Framework-agnostic notification logic */
14
+ controller = new SuNotificationController();
15
+ /** Internal signal holding the list of notifications, kept in sync with the controller */
16
+ _notifications = signal(this.controller.notifications.get(), ...(ngDevMode ? [{ debugName: "_notifications" }] : []));
18
17
  /**
19
18
  * Read-only access to the notifications list.
20
19
  * Can be used in templates for reactive updates.
21
20
  */
22
21
  notifications = this._notifications.asReadonly();
22
+ /** Stops syncing the controller's notifications into the signal */
23
+ unsubscribe = this.controller.notifications.subscribe((list) => this._notifications.set(list));
23
24
  /**
24
- * Default position where notifications will appear on the screen.
25
- * Can be configured via `configure` method.
25
+ * Position where notifications appear on the screen.
26
+ * Can also be set via the `configure` method.
26
27
  * @default 'top-right'
27
28
  */
28
- position = 'top-right';
29
+ get position() {
30
+ return this.controller.position.get();
31
+ }
32
+ set position(position) {
33
+ this.controller.configure({ position });
34
+ }
35
+ /**
36
+ * The direction notifications slide in from, whatever their position.
37
+ * Can also be set via the `configure` method.
38
+ * @default 'auto'
39
+ */
40
+ get slideFrom() {
41
+ return this.controller.slideFrom.get();
42
+ }
43
+ set slideFrom(slideFrom) {
44
+ this.controller.configure({ slideFrom });
45
+ }
29
46
  /**
30
47
  * Configure the notification service.
31
48
  * @param cfg Configuration object
32
49
  * @param cfg.position Optional position to display notifications.
50
+ * @param cfg.slideFrom Optional direction notifications slide in from.
33
51
  */
34
52
  configure(cfg) {
35
- if (cfg.position)
36
- this.position = cfg.position;
53
+ this.controller.configure(cfg);
37
54
  }
38
55
  /**
39
56
  * Show a new notification.
@@ -41,39 +58,30 @@ class SuNotificationService {
41
58
  * @returns The unique ID of the notification.
42
59
  */
43
60
  show(options) {
44
- const id = crypto.randomUUID();
45
- const notification = {
46
- id,
47
- type: options.type,
48
- message: options.message,
49
- duration: options.duration ?? 3000,
50
- autoClose: options.autoClose ?? true,
51
- cssClass: options.cssClass,
52
- icon: options.icon ?? true,
53
- };
54
- this._notifications.update((list) => [...list, notification]);
55
- if (notification.autoClose) {
56
- setTimeout(() => this.dismiss(id), notification.duration);
57
- }
58
- return id;
61
+ return this.controller.show(options);
59
62
  }
60
63
  /**
61
64
  * Dismiss a specific notification by its ID.
62
65
  * @param id ID of the notification to remove.
63
66
  */
64
67
  dismiss(id) {
65
- this._notifications.update((list) => list.filter((n) => n.id !== id));
68
+ this.controller.dismiss(id);
66
69
  }
67
70
  /**
68
71
  * Clear all notifications immediately.
69
72
  */
70
73
  clearAll() {
71
- this._notifications.set([]);
74
+ this.controller.clearAll();
72
75
  }
73
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: SuNotificationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
74
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: SuNotificationService, providedIn: 'root' });
76
+ /** Angular lifecycle hook for service destruction */
77
+ ngOnDestroy() {
78
+ this.unsubscribe();
79
+ this.controller.destroy();
80
+ }
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' });
75
83
  }
76
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: SuNotificationService, decorators: [{
84
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuNotificationService, decorators: [{
77
85
  type: Injectable,
78
86
  args: [{ providedIn: 'root' }]
79
87
  }] });
@@ -98,27 +106,27 @@ class SuNotificationComponent {
98
106
  dismiss(id) {
99
107
  this.service.dismiss(id);
100
108
  }
109
+ /**
110
+ * Runs an action button of a notification, then closes the notification unless the action says not to.
111
+ * @param id ID of the notification the button belongs to
112
+ * @param action The action that was pressed
113
+ */
114
+ runAction(id, action) {
115
+ action.onClick();
116
+ if (action.dismiss !== false) {
117
+ this.service.dismiss(id);
118
+ }
119
+ }
101
120
  /**
102
121
  * Checks if the provided `icon` value should be rendered as an image (`<img>`).
103
- *
104
- * Determines whether the `icon` is a string pointing to an image file:
105
- * - Local or relative paths (starting with `/`)
106
- * - URLs (starting with `http`)
107
- * - File paths ending with `.png`, `.jpg`, or `.svg`
108
- *
109
- * Inline SVG strings (e.g., `<svg>...</svg>`) are **not** treated as images and
110
- * should be rendered with `[innerHTML]`.
122
+ * Inline SVG strings are rendered with `[innerHTML]` instead.
123
+ * See `isSuNotificationImageIcon` in `@su-labs/core/notifications` for the rules.
111
124
  *
112
125
  * @param icon The icon value from the notification (boolean or string)
113
- * @returns `true` if the icon is an image path or URL, `false` for inline SVGs or `false`
126
+ * @returns `true` if the icon is an image path or URL
114
127
  */
115
128
  isImage(icon) {
116
- return (typeof icon === 'string' &&
117
- (icon.endsWith('.png') ||
118
- icon.endsWith('.jpg') ||
119
- icon.endsWith('.svg') ||
120
- icon.startsWith('http') ||
121
- icon.startsWith('/')));
129
+ return isSuNotificationImageIcon(icon);
122
130
  }
123
131
  /**
124
132
  * Sanitizes an inline SVG string so it can be safely rendered with [innerHTML].
@@ -129,18 +137,14 @@ class SuNotificationComponent {
129
137
  getSanitizedIcon(icon) {
130
138
  return this.sanitizer.bypassSecurityTrustHtml(icon);
131
139
  }
132
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: SuNotificationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
133
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.7", type: SuNotificationComponent, isStandalone: true, selector: "su-lib-notifications", ngImport: i0, template: "<div class=\"notification-container\" [ngClass]=\"[service.position]\">\n\t@for (notification of notifications(); track notification.id) {\n\t<div class=\"notification\" [ngClass]=\"[notification.type, notification.cssClass]\">\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<!-- if icon === true, render default SVG via switch -->\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<span class=\"message\">{{ notification.message }}</span>\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{position:fixed;pointer-events:none;display:flex;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.top-right{align-items:flex-end;flex-direction:column;top:var(--su-notification-container-position, 1rem);right:var(--su-notification-container-position, 1rem)}.notification-container.top-left{align-items:flex-start;flex-direction:column;top:var(--su-notification-container-position, 1rem);left:var(--su-notification-container-position, 1rem)}.notification-container.bottom-right{align-items:flex-end;flex-direction:column-reverse;bottom:var(--su-notification-container-position, 1rem);right:var(--su-notification-container-position, 1rem)}.notification-container.bottom-left{align-items:flex-start;flex-direction:column-reverse;bottom:var(--su-notification-container-position, 1rem);left:var(--su-notification-container-position, 1rem)}.notification-container.top-center{align-items:center;flex-direction:column;top:var(--su-notification-container-position, 1rem);left:50%;translate:-50% 0}.notification-container.bottom-center{align-items:center;flex-direction:column-reverse;bottom:var(--su-notification-container-position, 1rem);left:50%;translate:-50% 0}.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);box-shadow:0 4px 8px var(--su-notification-box-shadow, rgba(0, 0, 0, .15));display:flex;align-items:center;gap:1rem;transition:transform .2s ease,opacity .2s ease}.notification.success{border-left:4px solid var(--su-notification-success-border-color, #4caf50)}.notification.info{border-left:4px solid var(--su-notification-info-border-color, #2196f3)}.notification.warning{border-left:4px solid var(--su-notification-warning-border-color, #ff9800)}.notification.error{border-left:4px solid var(--su-notification-error-border-color, #f44336)}.notification.custom{border-left:4px solid var(--su-notification-custom-border-color, #9c27b0)}.notification .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)}.notification .icon-container .icon{width:100%;height:100%}.notification .message{flex:1}.notification .close{position:absolute;width:var(--su-notification-close-btn-size, 20px);height:var(--su-notification-close-btn-size, 20px);top:calc(var(--su-notification-close-btn-size, 20px) * -.5);right:calc(var(--su-notification-close-btn-size, 20px) * -.5);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:0 4px 8px var(--su-notification-box-shadow, rgba(0, 0, 0, .15));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)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
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 });
134
142
  }
135
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: SuNotificationComponent, decorators: [{
143
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuNotificationComponent, decorators: [{
136
144
  type: Component,
137
- args: [{ selector: 'su-lib-notifications', standalone: true, imports: [CommonModule], template: "<div class=\"notification-container\" [ngClass]=\"[service.position]\">\n\t@for (notification of notifications(); track notification.id) {\n\t<div class=\"notification\" [ngClass]=\"[notification.type, notification.cssClass]\">\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<!-- if icon === true, render default SVG via switch -->\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<span class=\"message\">{{ notification.message }}</span>\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{position:fixed;pointer-events:none;display:flex;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.top-right{align-items:flex-end;flex-direction:column;top:var(--su-notification-container-position, 1rem);right:var(--su-notification-container-position, 1rem)}.notification-container.top-left{align-items:flex-start;flex-direction:column;top:var(--su-notification-container-position, 1rem);left:var(--su-notification-container-position, 1rem)}.notification-container.bottom-right{align-items:flex-end;flex-direction:column-reverse;bottom:var(--su-notification-container-position, 1rem);right:var(--su-notification-container-position, 1rem)}.notification-container.bottom-left{align-items:flex-start;flex-direction:column-reverse;bottom:var(--su-notification-container-position, 1rem);left:var(--su-notification-container-position, 1rem)}.notification-container.top-center{align-items:center;flex-direction:column;top:var(--su-notification-container-position, 1rem);left:50%;translate:-50% 0}.notification-container.bottom-center{align-items:center;flex-direction:column-reverse;bottom:var(--su-notification-container-position, 1rem);left:50%;translate:-50% 0}.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);box-shadow:0 4px 8px var(--su-notification-box-shadow, rgba(0, 0, 0, .15));display:flex;align-items:center;gap:1rem;transition:transform .2s ease,opacity .2s ease}.notification.success{border-left:4px solid var(--su-notification-success-border-color, #4caf50)}.notification.info{border-left:4px solid var(--su-notification-info-border-color, #2196f3)}.notification.warning{border-left:4px solid var(--su-notification-warning-border-color, #ff9800)}.notification.error{border-left:4px solid var(--su-notification-error-border-color, #f44336)}.notification.custom{border-left:4px solid var(--su-notification-custom-border-color, #9c27b0)}.notification .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)}.notification .icon-container .icon{width:100%;height:100%}.notification .message{flex:1}.notification .close{position:absolute;width:var(--su-notification-close-btn-size, 20px);height:var(--su-notification-close-btn-size, 20px);top:calc(var(--su-notification-close-btn-size, 20px) * -.5);right:calc(var(--su-notification-close-btn-size, 20px) * -.5);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:0 4px 8px var(--su-notification-box-shadow, rgba(0, 0, 0, .15));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)}\n"] }]
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"] }]
138
146
  }] });
139
147
 
140
- /*
141
- * Public API Surface of notifications
142
- */
143
-
144
148
  /**
145
149
  * Generated bundle index. Do not edit.
146
150
  */
@@ -1 +1 @@
1
- {"version":3,"file":"su-labs-notifications.mjs","sources":["../../../../projects/su-labs/notifications/src/lib/notification.service.ts","../../../../projects/su-labs/notifications/src/lib/notification.component.ts","../../../../projects/su-labs/notifications/src/lib/notification.component.html","../../../../projects/su-labs/notifications/src/public-api.ts","../../../../projects/su-labs/notifications/src/su-labs-notifications.ts"],"sourcesContent":["import { Injectable, signal } from '@angular/core';\nimport {\n SuNotification,\n SuNotificationOptions,\n SuNotificationPosition,\n} from './notification.model';\n\n/**\n * Service for managing notifications.\n *\n * Provides methods to show, dismiss, and clear notifications.\n * Notifications are reactive signals, making them easy to bind in templates.\n */\n@Injectable({ providedIn: 'root' })\nexport class SuNotificationService {\n /**\n * Internal signal holding the list of notifications.\n */\n private _notifications = signal<SuNotification[]>([]);\n\n /**\n * Read-only access to the notifications list.\n * Can be used in templates for reactive updates.\n */\n notifications = this._notifications.asReadonly();\n\n /**\n * Default position where notifications will appear on the screen.\n * Can be configured via `configure` method.\n * @default 'top-right'\n */\n position: SuNotificationPosition = 'top-right';\n\n /**\n * Configure the notification service.\n * @param cfg Configuration object\n * @param cfg.position Optional position to display notifications.\n */\n configure(cfg: { position?: SuNotificationPosition }): void {\n if (cfg.position) this.position = cfg.position;\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 const id = crypto.randomUUID();\n const notification: SuNotification = {\n id,\n type: options.type,\n message: options.message,\n duration: options.duration ?? 3000,\n autoClose: options.autoClose ?? true,\n cssClass: options.cssClass,\n icon: options.icon ?? true,\n };\n\n this._notifications.update((list) => [...list, notification]);\n\n if (notification.autoClose) {\n setTimeout(() => this.dismiss(id), notification.duration);\n }\n\n return id;\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._notifications.update((list) => list.filter((n) => n.id !== id));\n }\n\n /**\n * Clear all notifications immediately.\n */\n clearAll(): void {\n this._notifications.set([]);\n }\n}\n","import { Component, inject } from '@angular/core';\nimport { SuNotificationService } from './notification.service';\nimport { CommonModule } from '@angular/common';\nimport { DomSanitizer, SafeHtml } from '@angular/platform-browser';\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 imports: [CommonModule],\n templateUrl: './notification.component.html',\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 * Checks if the provided `icon` value should be rendered as an image (`<img>`).\n *\n * Determines whether the `icon` is a string pointing to an image file:\n * - Local or relative paths (starting with `/`)\n * - URLs (starting with `http`)\n * - File paths ending with `.png`, `.jpg`, or `.svg`\n *\n * Inline SVG strings (e.g., `<svg>...</svg>`) are **not** treated as images and\n * should be rendered with `[innerHTML]`.\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, `false` for inline SVGs or `false`\n */\n isImage(icon: string | boolean): boolean {\n return (\n typeof icon === 'string' &&\n (icon.endsWith('.png') ||\n icon.endsWith('.jpg') ||\n icon.endsWith('.svg') ||\n icon.startsWith('http') ||\n icon.startsWith('/'))\n );\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\" [ngClass]=\"[service.position]\">\n\t@for (notification of notifications(); track notification.id) {\n\t<div class=\"notification\" [ngClass]=\"[notification.type, notification.cssClass]\">\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<!-- if icon === true, render default SVG via switch -->\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<span class=\"message\">{{ notification.message }}</span>\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 * Public API Surface of notifications\n */\n\nexport * from './lib/notification.component';\nexport * from './lib/notification.service';\nexport * from './lib/notification.model';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"su-labs-notifications.mjs","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":"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"}
package/index.d.ts CHANGED
@@ -1,89 +1,49 @@
1
1
  import * as i0 from '@angular/core';
2
+ import { OnDestroy } from '@angular/core';
2
3
  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';
3
6
  import { SafeHtml } from '@angular/platform-browser';
4
7
 
5
8
  /**
6
- * Represents the type of a notification.
7
- */
8
- type SuNotificationType = 'info' | 'success' | 'warning' | 'error' | 'custom';
9
- /**
10
- * Options for configuring a notification.
11
- */
12
- interface SuNotificationOptions {
13
- /**
14
- * The type of notification. Determines styling and default icon.
15
- */
16
- type: SuNotificationType;
17
- /**
18
- * The main message text to display in the notification.
19
- */
20
- message: string;
21
- /**
22
- * Duration in milliseconds before the notification automatically closes.
23
- * @default 3000
24
- */
25
- duration?: number;
26
- /**
27
- * Whether the notification should automatically close after the duration.
28
- * @default true
29
- */
30
- autoClose?: boolean;
31
- /**
32
- * Additional CSS class(es) to apply to the notification for custom styling.
33
- */
34
- cssClass?: string;
35
- /**
36
- * Icon configuration for the notification:
37
- * - `false`: no icon
38
- * - `true`: default icon for the given type
39
- * - `string`: custom SVG markup or URL for the icon
40
- */
41
- icon?: boolean | string;
42
- }
43
- /**
44
- * A notification instance with a unique identifier.
45
- */
46
- interface SuNotification extends SuNotificationOptions {
47
- /**
48
- * Unique identifier for the notification instance.
49
- */
50
- id: string;
51
- }
52
- /**
53
- * Possible positions for displaying notifications on the screen.
54
- */
55
- type SuNotificationPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';
56
-
57
- /**
58
- * Service for managing notifications.
9
+ * Angular service for managing notifications.
59
10
  *
60
- * Provides methods to show, dismiss, and clear notifications.
61
- * Notifications are reactive signals, making them easy to bind in templates.
11
+ * Thin wrapper around the framework-agnostic `SuNotificationController` from
12
+ * `@su-labs/core/notifications` that exposes the notifications as an Angular signal.
62
13
  */
63
- declare class SuNotificationService {
64
- /**
65
- * Internal signal holding the list of notifications.
66
- */
67
- private _notifications;
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;
68
19
  /**
69
20
  * Read-only access to the notifications list.
70
21
  * Can be used in templates for reactive updates.
71
22
  */
72
- notifications: i0.Signal<SuNotification[]>;
23
+ readonly notifications: i0.Signal<SuNotification[]>;
24
+ /** Stops syncing the controller's notifications into the signal */
25
+ private readonly unsubscribe;
73
26
  /**
74
- * Default position where notifications will appear on the screen.
75
- * Can be configured via `configure` method.
27
+ * Position where notifications appear on the screen.
28
+ * Can also be set via the `configure` method.
76
29
  * @default 'top-right'
77
30
  */
78
- position: SuNotificationPosition;
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);
79
40
  /**
80
41
  * Configure the notification service.
81
42
  * @param cfg Configuration object
82
43
  * @param cfg.position Optional position to display notifications.
44
+ * @param cfg.slideFrom Optional direction notifications slide in from.
83
45
  */
84
- configure(cfg: {
85
- position?: SuNotificationPosition;
86
- }): void;
46
+ configure(cfg: SuNotificationConfig): void;
87
47
  /**
88
48
  * Show a new notification.
89
49
  * @param options Options to configure the notification.
@@ -99,6 +59,8 @@ declare class SuNotificationService {
99
59
  * Clear all notifications immediately.
100
60
  */
101
61
  clearAll(): void;
62
+ /** Angular lifecycle hook for service destruction */
63
+ ngOnDestroy(): void;
102
64
  static ɵfac: i0.ɵɵFactoryDeclaration<SuNotificationService, never>;
103
65
  static ɵprov: i0.ɵɵInjectableDeclaration<SuNotificationService>;
104
66
  }
@@ -121,19 +83,19 @@ declare class SuNotificationComponent {
121
83
  * @param id ID of the notification to dismiss
122
84
  */
123
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;
124
92
  /**
125
93
  * Checks if the provided `icon` value should be rendered as an image (`<img>`).
126
- *
127
- * Determines whether the `icon` is a string pointing to an image file:
128
- * - Local or relative paths (starting with `/`)
129
- * - URLs (starting with `http`)
130
- * - File paths ending with `.png`, `.jpg`, or `.svg`
131
- *
132
- * Inline SVG strings (e.g., `<svg>...</svg>`) are **not** treated as images and
133
- * should be rendered with `[innerHTML]`.
94
+ * Inline SVG strings are rendered with `[innerHTML]` instead.
95
+ * See `isSuNotificationImageIcon` in `@su-labs/core/notifications` for the rules.
134
96
  *
135
97
  * @param icon The icon value from the notification (boolean or string)
136
- * @returns `true` if the icon is an image path or URL, `false` for inline SVGs or `false`
98
+ * @returns `true` if the icon is an image path or URL
137
99
  */
138
100
  isImage(icon: string | boolean): boolean;
139
101
  /**
@@ -148,4 +110,3 @@ declare class SuNotificationComponent {
148
110
  }
149
111
 
150
112
  export { SuNotificationComponent, SuNotificationService };
151
- export type { SuNotification, SuNotificationOptions, SuNotificationPosition, SuNotificationType };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@su-labs/notifications",
3
- "version": "1.0.2",
3
+ "version": "20.3.0",
4
4
  "keywords": [
5
5
  "angular",
6
6
  "notifications",
@@ -17,7 +17,7 @@
17
17
  "snack-bar",
18
18
  "library"
19
19
  ],
20
- "homepage": "https://github.com/Greezaaa/settings-utils-lib/tree/main/projects/su-labs/font-size#readme",
20
+ "homepage": "https://su-labs.dev/notifications/",
21
21
  "author": {
22
22
  "name": "Yevheniy Alekseyev",
23
23
  "email": "yev.alekseyev@gmail.com",
@@ -26,16 +26,17 @@
26
26
  "repository": {
27
27
  "type": "git",
28
28
  "url": "https://github.com/Greezaaa/settings-utils-lib.git",
29
- "directory": "projects/su-labs/font-size"
29
+ "directory": "projects/su-labs/notifications"
30
30
  },
31
31
  "bugs": {
32
32
  "url": "https://github.com/Greezaaa/settings-utils-lib/issues"
33
33
  },
34
34
  "peerDependencies": {
35
- "@angular/common": "^20.1.0",
36
- "@angular/core": "^20.1.0"
35
+ "@angular/common": "^20.0.0",
36
+ "@angular/core": "^20.0.0"
37
37
  },
38
38
  "dependencies": {
39
+ "@su-labs/core": "1.3.0",
39
40
  "tslib": "^2.3.0"
40
41
  },
41
42
  "sideEffects": false,