fernotify 1.2.10 → 1.2.11
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 +4 -1
- package/types/anime.d.ts +17 -0
- package/types/index.d.ts +173 -0
package/package.json
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fernotify",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11",
|
|
4
4
|
"description": "Sistema moderno de notificaciones con animaciones fluidas y soporte completo de Dark Mode",
|
|
5
5
|
"main": "dist/notification-system.js",
|
|
6
6
|
"module": "dist/notification-system.esm.js",
|
|
7
|
+
"types": "types/index.d.ts",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": {
|
|
10
|
+
"types": "./types/index.d.ts",
|
|
9
11
|
"import": "./dist/notification-system.esm.js",
|
|
10
12
|
"require": "./dist/notification-system.js"
|
|
11
13
|
}
|
|
12
14
|
},
|
|
13
15
|
"files": [
|
|
14
16
|
"dist/",
|
|
17
|
+
"types/",
|
|
15
18
|
"LICENSE",
|
|
16
19
|
"README.md",
|
|
17
20
|
"NOTIFICATION_SYSTEM_GUIDE.md"
|
package/types/anime.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Tipos mínimos para anime.js 3.x cargado por CDN
|
|
2
|
+
// Solo cubre las propiedades usadas en notification-system.ts
|
|
3
|
+
|
|
4
|
+
type AnimeValue = number | number[];
|
|
5
|
+
|
|
6
|
+
interface AnimeParams {
|
|
7
|
+
targets: unknown;
|
|
8
|
+
duration?: number;
|
|
9
|
+
delay?: number;
|
|
10
|
+
easing?: string;
|
|
11
|
+
opacity?: AnimeValue;
|
|
12
|
+
scale?: AnimeValue;
|
|
13
|
+
rotate?: AnimeValue;
|
|
14
|
+
complete?: () => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare function anime(params: AnimeParams): void;
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// Type definitions for fernotify
|
|
2
|
+
// Generated from notification-system.ts
|
|
3
|
+
|
|
4
|
+
export interface ButtonOptions {
|
|
5
|
+
text?: string;
|
|
6
|
+
color?: string;
|
|
7
|
+
shadowColor?: string;
|
|
8
|
+
onClick?: (() => void) | (() => Promise<unknown>);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface AnimationOptions {
|
|
12
|
+
overlayDuration?: number;
|
|
13
|
+
overlayEasing?: string;
|
|
14
|
+
boxDuration?: number;
|
|
15
|
+
boxDelay?: number;
|
|
16
|
+
boxEasing?: string;
|
|
17
|
+
boxStartScale?: number;
|
|
18
|
+
iconDuration?: number;
|
|
19
|
+
iconDelay?: number;
|
|
20
|
+
iconRotate?: number;
|
|
21
|
+
overlayOpacity?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface NotificationOptions {
|
|
25
|
+
type?: 'success' | 'error' | 'warning' | 'info' | 'question' | string;
|
|
26
|
+
title?: string;
|
|
27
|
+
message?: string;
|
|
28
|
+
html?: string;
|
|
29
|
+
content?: HTMLElement;
|
|
30
|
+
buttonText?: string;
|
|
31
|
+
buttonColor?: string | null;
|
|
32
|
+
onClose?: (() => void) | null;
|
|
33
|
+
timer?: number | null;
|
|
34
|
+
allowOutsideClick?: boolean;
|
|
35
|
+
allowEscapeKey?: boolean;
|
|
36
|
+
hideButton?: boolean;
|
|
37
|
+
buttons?: ButtonOptions[] | null;
|
|
38
|
+
onConfirm?: (() => void) | (() => Promise<unknown>) | null;
|
|
39
|
+
onCancel?: (() => void) | (() => Promise<unknown>) | null;
|
|
40
|
+
confirmText?: string;
|
|
41
|
+
cancelText?: string;
|
|
42
|
+
confirmColor?: string;
|
|
43
|
+
confirmShadow?: string;
|
|
44
|
+
cancelColor?: string;
|
|
45
|
+
cancelShadow?: string;
|
|
46
|
+
anim?: AnimationOptions;
|
|
47
|
+
showCloseButton?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type ToastPosition =
|
|
51
|
+
| 'top-right'
|
|
52
|
+
| 'top-left'
|
|
53
|
+
| 'top-center'
|
|
54
|
+
| 'bottom-right'
|
|
55
|
+
| 'bottom-left';
|
|
56
|
+
|
|
57
|
+
export interface ToastOptions {
|
|
58
|
+
type?: 'success' | 'error' | 'warning' | 'info' | 'question' | string;
|
|
59
|
+
title?: string;
|
|
60
|
+
message?: string;
|
|
61
|
+
duration?: number;
|
|
62
|
+
position?: ToastPosition;
|
|
63
|
+
showProgress?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Unique ID for deduplication: if a toast with this ID is already visible,
|
|
66
|
+
* its countdown is reset instead of creating a duplicate.
|
|
67
|
+
*/
|
|
68
|
+
id?: string;
|
|
69
|
+
/**
|
|
70
|
+
* When `false`, the close (×) button is hidden.
|
|
71
|
+
* `toastLoading()` sets this to `false` automatically.
|
|
72
|
+
* @default true
|
|
73
|
+
*/
|
|
74
|
+
closeable?: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export declare class NotificationSystem {
|
|
78
|
+
constructor();
|
|
79
|
+
|
|
80
|
+
// ── Modal notifications ──────────────────────────────────────────────────
|
|
81
|
+
|
|
82
|
+
/** Shows a modal notification. Returns a Promise that resolves when the modal is closed. */
|
|
83
|
+
show(options?: NotificationOptions): Promise<void>;
|
|
84
|
+
|
|
85
|
+
/** Closes the current modal. */
|
|
86
|
+
close(callback?: (() => void) | null): Promise<void>;
|
|
87
|
+
|
|
88
|
+
/** Alias for close(). */
|
|
89
|
+
hide(callback?: (() => void) | null): Promise<void>;
|
|
90
|
+
|
|
91
|
+
success(message: string, title?: string | null, options?: NotificationOptions): void;
|
|
92
|
+
error(message: string, title?: string | null, options?: NotificationOptions): void;
|
|
93
|
+
warning(message: string, title?: string | null, options?: NotificationOptions): void;
|
|
94
|
+
info(message: string, title?: string | null, options?: NotificationOptions): void;
|
|
95
|
+
question(message: string, title?: string | null, options?: NotificationOptions): void;
|
|
96
|
+
|
|
97
|
+
/** Shows a loading modal (no close button, blocks outside click / Escape). */
|
|
98
|
+
loading(message?: string, title?: string, options?: NotificationOptions): Promise<void>;
|
|
99
|
+
|
|
100
|
+
/** Closes the loading modal. */
|
|
101
|
+
closeLoading(callback?: (() => void) | null): Promise<void>;
|
|
102
|
+
|
|
103
|
+
// ── Toast notifications ──────────────────────────────────────────────────
|
|
104
|
+
|
|
105
|
+
/** Generic toast. Accepts a message string + options, or a single options object. */
|
|
106
|
+
toast(messageOrOptions: string | ToastOptions, options?: ToastOptions): void;
|
|
107
|
+
|
|
108
|
+
toastSuccess(message: string, title?: string, options?: ToastOptions): void;
|
|
109
|
+
toastError(message: string, title?: string, options?: ToastOptions): void;
|
|
110
|
+
toastWarning(message: string, title?: string, options?: ToastOptions): void;
|
|
111
|
+
toastInfo(message: string, title?: string, options?: ToastOptions): void;
|
|
112
|
+
toastQuestion(message: string, title?: string, options?: ToastOptions): void;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Shows a loading toast with a spinner.
|
|
116
|
+
* Only one loading toast can exist at a time (uses internal id `'__loading__'`).
|
|
117
|
+
* Close it with `closeToastLoading()`.
|
|
118
|
+
*/
|
|
119
|
+
toastLoading(message?: string, title?: string, options?: ToastOptions): void;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Closes the active loading toast and returns a Promise that resolves
|
|
123
|
+
* after the exit animation finishes (~300 ms).
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* notify.toastLoading('Saving…');
|
|
127
|
+
* await doWork();
|
|
128
|
+
* await notify.closeToastLoading(); // wait for exit animation
|
|
129
|
+
* notify.toastSuccess('Done!');
|
|
130
|
+
*/
|
|
131
|
+
closeToastLoading(): Promise<void>;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Instantly replaces the loading toast with a new toast (no animation gap).
|
|
135
|
+
* If no loading toast is active, behaves like a normal `toast()` call.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* notify.toastLoading('Saving…');
|
|
139
|
+
* await doWork();
|
|
140
|
+
* notify.replaceToastLoading('Done!', { type: 'success' });
|
|
141
|
+
*/
|
|
142
|
+
replaceToastLoading(message: string, options?: ToastOptions): void;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Default export: the `NotificationSystem` class.
|
|
147
|
+
*
|
|
148
|
+
* @example – ESM / Vite / React
|
|
149
|
+
* ```ts
|
|
150
|
+
* import NotificationSystem from 'fernotify';
|
|
151
|
+
* const notify = new NotificationSystem();
|
|
152
|
+
* notify.toastSuccess('Hello!');
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* @example – Singleton (recommended for apps)
|
|
156
|
+
* ```ts
|
|
157
|
+
* // src/lib/notify.ts
|
|
158
|
+
* import NotificationSystem from 'fernotify';
|
|
159
|
+
* const notify = new NotificationSystem();
|
|
160
|
+
* export default notify;
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export default NotificationSystem;
|
|
164
|
+
|
|
165
|
+
// Augment the global Window interface so window.notify is typed
|
|
166
|
+
// when the UMD/IIFE bundle is loaded via <script>.
|
|
167
|
+
declare global {
|
|
168
|
+
interface Window {
|
|
169
|
+
notify: NotificationSystem;
|
|
170
|
+
/** @deprecated Use window.notify instead. */
|
|
171
|
+
Notification: NotificationSystem;
|
|
172
|
+
}
|
|
173
|
+
}
|