snackng 0.1.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/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "snackng",
3
+ "version": "0.1.0",
4
+ "description": "The easiest way to show toasts and snackbars in Angular with a glass design, zero UI dependencies and CSS-variable theming. No Material, no CDK, no Tailwind required.",
5
+ "author": "xgreymx",
6
+ "keywords": [
7
+ "angular",
8
+ "toast",
9
+ "toastr",
10
+ "snackbar",
11
+ "notification",
12
+ "glassmorphism",
13
+ "a11y",
14
+ "angular-toast",
15
+ "angular-snackbar",
16
+ "angular-notification",
17
+ "css-variables",
18
+ "ssr",
19
+ "standalone"
20
+ ],
21
+ "license": "Apache-2.0",
22
+ "homepage": "https://github.com/xgreymx/snackng#readme",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/xgreymx/snackng.git",
26
+ "directory": "projects/snackng"
27
+ },
28
+ "bugs": {
29
+ "url": "https://github.com/xgreymx/snackng/issues"
30
+ },
31
+ "funding": {
32
+ "type": "github",
33
+ "url": "https://github.com/sponsors/xgreymx"
34
+ },
35
+ "sideEffects": false,
36
+ "peerDependencies": {
37
+ "@angular/common": ">=21",
38
+ "@angular/core": ">=21",
39
+ "@angular/platform-browser": ">=21"
40
+ },
41
+ "dependencies": {
42
+ "tslib": "^2.3.0"
43
+ },
44
+ "exports": {
45
+ "./themes/daisy.css": {
46
+ "style": "./themes/daisy.css",
47
+ "default": "./themes/daisy.css"
48
+ },
49
+ "./package.json": {
50
+ "default": "./package.json"
51
+ },
52
+ ".": {
53
+ "types": "./types/snackng.d.ts",
54
+ "default": "./fesm2022/snackng.mjs"
55
+ }
56
+ },
57
+ "module": "fesm2022/snackng.mjs",
58
+ "typings": "types/snackng.d.ts",
59
+ "type": "module"
60
+ }
@@ -0,0 +1,35 @@
1
+ /* snackng — daisyUI bridge (optional)
2
+ ===================================
3
+ Import this ONLY if your app uses daisyUI:
4
+
5
+ @import "snackng/themes/daisy.css";
6
+
7
+ snackng does not depend on daisyUI or Tailwind. Without this file it renders
8
+ with its own glass defaults. With it, the toast colours are re-pointed at
9
+ daisyUI's semantic theme variables, so they follow theme switching and dark
10
+ mode automatically — daisyUI redefines `--color-*` per theme.
11
+
12
+ Note this replaces the glass gradients with daisyUI's flat theme colours.
13
+ To keep the glass look and only borrow daisy's hues, override the individual
14
+ variables yourself instead of importing this file. */
15
+
16
+ :root {
17
+ --snackng-success-bg: var(--color-success);
18
+ --snackng-success-ink: var(--color-success-content);
19
+ --snackng-success-solid: var(--color-success);
20
+
21
+ --snackng-warning-bg: var(--color-warning);
22
+ --snackng-warning-ink: var(--color-warning-content);
23
+ --snackng-warning-solid: var(--color-warning);
24
+
25
+ --snackng-danger-bg: var(--color-error);
26
+ --snackng-danger-ink: var(--color-error-content);
27
+ --snackng-danger-solid: var(--color-error);
28
+
29
+ --snackng-info-bg: var(--color-info);
30
+ --snackng-info-ink: var(--color-info-content);
31
+ --snackng-info-solid: var(--color-info);
32
+
33
+ --snackng-radius: var(--radius-box);
34
+ --snackng-font: inherit;
35
+ }
@@ -0,0 +1,108 @@
1
+ import * as i0 from '@angular/core';
2
+ import { OnDestroy, InjectionToken, EnvironmentProviders } from '@angular/core';
3
+
4
+ /** Built-in severities. Any other string is a custom type registered via `provideSnackng`. */
5
+ type SnackngBuiltInType = 'success' | 'warning' | 'danger' | 'info';
6
+ type SnackngType = SnackngBuiltInType | (string & {});
7
+ type SnackngPosition = 'top-start' | 'top-center' | 'top-end' | 'bottom-start' | 'bottom-center' | 'bottom-end';
8
+ type SnackngPoliteness = 'polite' | 'assertive' | 'off';
9
+ type SnackngOverflow = 'queue' | 'dismiss-oldest';
10
+ /** `'replaced'` means the toast was evicted under `overflow: 'dismiss-oldest'`. */
11
+ type SnackngDismissReason = 'timeout' | 'action' | 'manual' | 'replaced';
12
+ interface SnackngAction {
13
+ label: string;
14
+ handler?: () => void;
15
+ /** Dismiss the toast when the action is clicked. Defaults to true. */
16
+ dismissOnClick?: boolean;
17
+ }
18
+ /**
19
+ * Definition for a custom type. Built-in types already have icon and colors;
20
+ * a custom type inherits the neutral surface and is styled through
21
+ * `--snackng-<type>-bg` / `--snackng-<type>-ink`.
22
+ */
23
+ interface SnackngTypeDef {
24
+ /**
25
+ * Raw SVG markup for the icon. Trusted as-is (bypasses Angular's sanitizer),
26
+ * so it must come from your code, never from user input. Falls back to the
27
+ * `info` glyph when omitted.
28
+ */
29
+ icon?: string;
30
+ politeness?: SnackngPoliteness;
31
+ }
32
+ interface SnackngOptions {
33
+ title?: string;
34
+ /** Milliseconds before auto-dismiss. `0` keeps the toast until dismissed. */
35
+ duration?: number;
36
+ action?: SnackngAction;
37
+ position?: SnackngPosition;
38
+ /** Show the close button. */
39
+ dismissible?: boolean;
40
+ /** Overrides the politeness derived from the type. */
41
+ politeness?: SnackngPoliteness;
42
+ panelClass?: string | string[];
43
+ }
44
+ interface SnackngRef {
45
+ readonly id: string;
46
+ dismiss(): void;
47
+ readonly afterDismissed: Promise<SnackngDismissReason>;
48
+ }
49
+
50
+ declare class SnackngService implements OnDestroy {
51
+ private readonly store;
52
+ private readonly config;
53
+ private readonly liveRegion;
54
+ private readonly appRef;
55
+ private readonly injector;
56
+ private readonly document;
57
+ private readonly isBrowser;
58
+ private host?;
59
+ /**
60
+ * Toasts accepted but still waiting for a free slot under `overflow: 'queue'`.
61
+ * Useful for a "3 more" affordance.
62
+ */
63
+ readonly pending: i0.Signal<number>;
64
+ success(message: string, options?: SnackngOptions): SnackngRef;
65
+ warning(message: string, options?: SnackngOptions): SnackngRef;
66
+ danger(message: string, options?: SnackngOptions): SnackngRef;
67
+ info(message: string, options?: SnackngOptions): SnackngRef;
68
+ show(type: SnackngType, message: string, options?: SnackngOptions): SnackngRef;
69
+ dismissAll(): void;
70
+ private resolvePoliteness;
71
+ private ensureHost;
72
+ ngOnDestroy(): void;
73
+ static ɵfac: i0.ɵɵFactoryDeclaration<SnackngService, never>;
74
+ static ɵprov: i0.ɵɵInjectableDeclaration<SnackngService>;
75
+ }
76
+
77
+ interface SnackngConfig {
78
+ duration: number;
79
+ position: SnackngPosition;
80
+ /** Maximum toasts on screen at once. Extras are handled per `overflow`. */
81
+ max: number;
82
+ /**
83
+ * What happens when a toast arrives while `max` are already visible.
84
+ * `'queue'` waits for a free slot — nothing is ever lost, but a flood becomes
85
+ * a long parade. `'dismiss-oldest'` evicts the oldest to make room, so the
86
+ * newest always wins; useful when an interceptor can emit toasts in bursts.
87
+ */
88
+ overflow: SnackngOverflow;
89
+ /**
90
+ * Milliseconds between releasing consecutive queued toasts. Staggering keeps
91
+ * a burst from firing every enter animation at the same instant. `0` releases
92
+ * as many as fit at once.
93
+ */
94
+ stagger: number;
95
+ pauseOnHover: boolean;
96
+ dismissible: boolean;
97
+ types: Record<string, SnackngTypeDef>;
98
+ }
99
+ declare const SNACKNG_DEFAULTS: SnackngConfig;
100
+ declare const SNACKNG_CONFIG: InjectionToken<SnackngConfig>;
101
+ /**
102
+ * Optional. Without it the defaults above apply, so `npm i snackng` and calling
103
+ * the service is enough to get working toasts.
104
+ */
105
+ declare function provideSnackng(config?: Partial<SnackngConfig>): EnvironmentProviders;
106
+
107
+ export { SNACKNG_CONFIG, SNACKNG_DEFAULTS, SnackngService, provideSnackng };
108
+ export type { SnackngAction, SnackngBuiltInType, SnackngConfig, SnackngDismissReason, SnackngOptions, SnackngPoliteness, SnackngPosition, SnackngRef, SnackngType, SnackngTypeDef };