better-toast 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { Type, OnInit } from '@angular/core';
2
+ import { Type } from '@angular/core';
3
3
 
4
4
  declare const TOASTER_POSITIONS: readonly ["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"];
5
5
  type ToasterPosition = (typeof TOASTER_POSITIONS)[number];
@@ -49,7 +49,7 @@ type ToastVariant = (typeof TOAST_VARIANTS)[number];
49
49
  /**
50
50
  * Per-variant icon overrides for `<app-toaster [icons]>`.
51
51
  *
52
- * Each value is either an **Angular standalone component** class (rendered with `NgComponentOutlet`),
52
+ * Each value is either an **Angular standalone component** class (rendered dynamically in the icon slot),
53
53
  * or **`null`** to show no icon for that variant. Omitted keys keep the library defaults.
54
54
  *
55
55
  * The **`default`** variant has no built-in icon; set `default` here (or pass {@link ToastOptions.icon}
@@ -136,8 +136,8 @@ type ToastCancelMethodOptions = Omit<ToastOptions, 'icon' | 'classNames'> & {
136
136
  /**
137
137
  * Options for {@link ToasterService.custom}.
138
138
  * {@link CustomToastOptions.inputs} is merged into the body component (same pattern as {@link HeadlessToastOptions.inputs});
139
- * **`toastId`** is always injected after your inputs. The component must declare a matching `input()` / `@Input()` for **`toastId`**
140
- * so `NgComponentOutlet` can bind it (same requirement as {@link ToasterService.headless}).
139
+ * **`toastId`** is always injected after your inputs. The component should declare `toastId` with `input()`.
140
+ * so the outlet can bind it (same requirement as {@link ToasterService.headless}).
141
141
  */
142
142
  interface CustomToastOptions extends ToastOptions {
143
143
  inputs?: Record<string, unknown>;
@@ -192,7 +192,7 @@ interface ToastOptions {
192
192
  }
193
193
  /**
194
194
  * Options for {@link ToasterService.headless}.
195
- * The component must be **standalone** (or otherwise valid for `NgComponentOutlet`).
195
+ * The component must be **standalone** (or otherwise valid for `ViewContainerRef.createComponent`).
196
196
  * Headless toasts ignore `<app-toaster [closeButton]>`: no dismiss control is rendered.
197
197
  *
198
198
  * Per-toast **`icon`** and **`style`** are omitted: the inner component owns visuals; use
@@ -205,8 +205,7 @@ interface ToastOptions {
205
205
  */
206
206
  interface HeadlessToastOptions extends Omit<ToastOptions, 'icon' | 'style'> {
207
207
  /**
208
- * Values passed to the component’s `input()` / `@Input()` bindings
209
- * (same shape as `NgComponentOutlet` `inputs`).
208
+ * Values passed to the component’s `input()` bindings.
210
209
  */
211
210
  inputs?: Record<string, unknown>;
212
211
  }
@@ -221,13 +220,13 @@ interface ToasterItem {
221
220
  * via {@link ToasterService.custom}.
222
221
  */
223
222
  readonly contentComponent?: Type<unknown>;
224
- /** Bound to {@link ToasterItem.contentComponent} via `NgComponentOutlet` (includes auto **`toastId`**). */
223
+ /** Bound to {@link ToasterItem.contentComponent} by the toast outlet (includes auto **`toastId`**). */
225
224
  readonly contentComponentInputs?: Record<string, unknown>;
226
225
  /**
227
226
  * When set (without {@link ToasterItem.contentComponent}), the toast body is this standalone component only — same stack and motion as other toasts, without host chrome or a close button.
228
227
  */
229
228
  readonly component?: Type<unknown>;
230
- /** Bound to the headless component via `NgComponentOutlet`. */
229
+ /** Bound to the headless component by the toast outlet. */
231
230
  readonly componentInputs?: Record<string, unknown>;
232
231
  /** Per-toast override; see {@link ToastOptions.icon}. */
233
232
  readonly icon?: Type<unknown> | null;
@@ -359,10 +358,10 @@ declare class ToasterService {
359
358
  * Show a toast whose **message area** is a standalone Angular component while keeping normal toast chrome
360
359
  * (surface, icon column when applicable, close button, stack motion).
361
360
  *
362
- * Pass {@link CustomToastOptions.inputs} for `input()` / `@Input()` on that component.
361
+ * Pass {@link CustomToastOptions.inputs} for `input()` on that component.
363
362
  * The component also receives **`toastId`** (matches the returned id) for programmatic dismiss.
364
363
  *
365
- * @param component The component class (must be usable with `NgComponentOutlet`).
364
+ * @param component The component class (must work with `ViewContainerRef.createComponent`).
366
365
  * @param options Optional configuration object {@link CustomToastOptions}.
367
366
  * @returns The toast ID, useful for programmatic dismissal.
368
367
  */
@@ -374,7 +373,7 @@ declare class ToasterService {
374
373
  * Pass {@link HeadlessToastOptions.inputs} to feed `input()` on that component.
375
374
  * The component also automatically receives **`toastId`** (matches the returned id) for programmatic dismiss inside the component.
376
375
  *
377
- * @param component The component class (must be usable with `NgComponentOutlet`).
376
+ * @param component The component class (must work with `ViewContainerRef.createComponent`).
378
377
  * @param options Optional configuration object {@link HeadlessToastOptions}.
379
378
  * @returns The toast ID, useful for programmatic dismissal.
380
379
  */
@@ -428,6 +427,7 @@ declare class ToasterService {
428
427
  * Clear all toast notifications.
429
428
  */
430
429
  clear(): void;
430
+ private pushToast;
431
431
  private add;
432
432
  private addContentComponent;
433
433
  private addComponent;
@@ -437,6 +437,7 @@ declare class ToasterService {
437
437
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<ToasterService>;
438
438
  }
439
439
 
440
+ declare function resolveToasterOffsetSide(offset: ToasterOffset | undefined, side: 'top' | 'right' | 'bottom' | 'left'): string | undefined;
440
441
  /**
441
442
  * Renders the toaster stack. Add once near the root of your app (e.g. in `App`).
442
443
  * With `[stacked]="true"` (default), extra toasts collapse into a 3-layer card stack (latest in front); hover, focus, or a press on touch expands the full list.
@@ -453,7 +454,7 @@ declare class ToasterService {
453
454
  * Set `[theme]` to `light`, `dark`, or `system` (default): semantic colors follow the chosen mode; `system` uses `prefers-color-scheme`.
454
455
  * {@link ToasterService.action} / {@link ToasterService.cancel} render a message plus one text button (no icon column).
455
456
  */
456
- declare class BetterToaster implements OnInit {
457
+ declare class BetterToaster {
457
458
  protected readonly toaster: ToasterService;
458
459
  /**
459
460
  * Default auto-dismiss time in ms for `show` / `success` / `error` / `info` / `warning` when the second argument omits `durationMs`.
@@ -528,22 +529,7 @@ declare class BetterToaster implements OnInit {
528
529
  protected readonly notificationsRegionAriaLabel: _angular_core.Signal<string>;
529
530
  /** Resolved `aria-label` for each toast’s dismiss control. */
530
531
  protected readonly dismissButtonAriaLabel: _angular_core.Signal<string>;
531
- /** Vertical offset in px for the toast stack. */
532
- protected readonly offsetTop: _angular_core.Signal<string | undefined>;
533
- /** Horizontal offset in px for the toast stack. */
534
- protected readonly offsetRight: _angular_core.Signal<string | undefined>;
535
- /** Vertical offset in px for the toast stack. */
536
- protected readonly offsetBottom: _angular_core.Signal<string | undefined>;
537
- /** Horizontal offset in px for the toast stack. */
538
- protected readonly offsetLeft: _angular_core.Signal<string | undefined>;
539
- /** Vertical offset in px for the toast stack on narrow layouts. */
540
- protected readonly mobileOffsetTop: _angular_core.Signal<string | undefined>;
541
- /** Horizontal offset in px for the toast stack on narrow layouts. */
542
- protected readonly mobileOffsetRight: _angular_core.Signal<string | undefined>;
543
- /** Vertical offset in px for the toast stack on narrow layouts. */
544
- protected readonly mobileOffsetBottom: _angular_core.Signal<string | undefined>;
545
- /** Horizontal offset in px for the toast stack on narrow layouts. */
546
- protected readonly mobileOffsetLeft: _angular_core.Signal<string | undefined>;
532
+ protected readonly offsetSide: typeof resolveToasterOffsetSide;
547
533
  /**
548
534
  * `--index` is the stack depth: last item is 0 (front), older items count up.
549
535
  * Collapsed peek, scale, front, and hidden layers are CSS from that index / `:last-child`.
@@ -569,10 +555,6 @@ declare class BetterToaster implements OnInit {
569
555
  onStackFocusOut(event: FocusEvent): void;
570
556
  private pauseAllAutoDismiss;
571
557
  private resumeAllAutoDismiss;
572
- /**
573
- * Initializes the toaster service with the default duration.
574
- */
575
- ngOnInit(): void;
576
558
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<BetterToaster, never>;
577
559
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<BetterToaster, "better-toaster", never, { "durationMs": { "alias": "duration"; "required": false; "isSignal": true; }; "position": { "alias": "position"; "required": false; "isSignal": true; }; "stacked": { "alias": "stacked"; "required": false; "isSignal": true; }; "offset": { "alias": "offset"; "required": false; "isSignal": true; }; "mobileOffset": { "alias": "mobileOffset"; "required": false; "isSignal": true; }; "richColors": { "alias": "richColors"; "required": false; "isSignal": true; }; "theme": { "alias": "theme"; "required": false; "isSignal": true; }; "icons": { "alias": "icons"; "required": false; "isSignal": true; }; "toastOptions": { "alias": "toastOptions"; "required": false; "isSignal": true; }; "closeButton": { "alias": "closeButton"; "required": false; "isSignal": true; }; "accessibilityLabels": { "alias": "accessibilityLabels"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
578
560
  }