customizable-toast-notification 3.14.0 → 3.16.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 +67 -0
- package/README.md +643 -4
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +2 -0
- package/dist/index.css.d.ts +50 -0
- package/dist/index.css.map +7 -0
- package/dist/index.d.ts +586 -6
- package/dist/index.esm.mjs +3 -3
- package/dist/index.esm.mjs.map +1 -1
- package/dist/index.umd.js +3 -3
- package/dist/index.umd.js.map +1 -1
- package/package.json +16 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Updates global toast configuration.
|
|
3
|
+
* @param {Partial<ToastGlobalConfig>} [options]
|
|
4
|
+
* @returns {ToastGlobalConfig}
|
|
5
|
+
*/
|
|
6
|
+
declare function setConfig(options?: Partial<ToastGlobalConfig$1>): ToastGlobalConfig$1;
|
|
7
|
+
/**
|
|
8
|
+
* Resets global toast configuration back to pristine defaults.
|
|
9
|
+
* Cleans up DOM attributes attached to document.documentElement.
|
|
10
|
+
* @returns {ToastGlobalConfig}
|
|
11
|
+
*/
|
|
12
|
+
declare function resetConfig(): ToastGlobalConfig$1;
|
|
13
|
+
/**
|
|
14
|
+
* Returns a snapshot of the current global toast configuration.
|
|
15
|
+
* @returns {ToastGlobalConfig}
|
|
16
|
+
*/
|
|
17
|
+
declare function getConfig(): ToastGlobalConfig$1;
|
|
18
|
+
/**
|
|
19
|
+
* Whether toast animations should be reduced for accessibility.
|
|
20
|
+
* @returns {boolean}
|
|
21
|
+
*/
|
|
22
|
+
declare function shouldReduceMotion(): boolean;
|
|
23
|
+
type ReducedMotionMode$1 = "auto" | "always" | "never";
|
|
24
|
+
type ToastTheme$1 = "light" | "dark" | "high-contrast" | "compact" | "spacious" | "glass";
|
|
25
|
+
type ToastMountTarget$1 = Element | DocumentFragment | ShadowRoot;
|
|
26
|
+
type ToastMetrics$1 = {
|
|
27
|
+
/**
|
|
28
|
+
* - Currently rendered active toasts
|
|
29
|
+
*/
|
|
30
|
+
activeCount: number;
|
|
31
|
+
/**
|
|
32
|
+
* - Number of queued toasts waiting to be displayed
|
|
33
|
+
*/
|
|
34
|
+
queueDepth: number;
|
|
35
|
+
/**
|
|
36
|
+
* - Count of currently visible toasts
|
|
37
|
+
*/
|
|
38
|
+
visibleCount: number;
|
|
39
|
+
/**
|
|
40
|
+
* - Number of toasts dropped due to queue overflow
|
|
41
|
+
*/
|
|
42
|
+
droppedCount: number;
|
|
43
|
+
/**
|
|
44
|
+
* - Epoch timestamp (ms) when metrics were recorded
|
|
45
|
+
*/
|
|
46
|
+
timestamp: number;
|
|
47
|
+
};
|
|
48
|
+
type ToastGlobalConfig$1 = {
|
|
49
|
+
maxVisible: number;
|
|
50
|
+
maxQueueSize: number;
|
|
51
|
+
zIndex: number;
|
|
52
|
+
targetNode: ToastMountTarget$1 | null;
|
|
53
|
+
disableInlineStyles: boolean;
|
|
54
|
+
reducedMotion: ReducedMotionMode$1;
|
|
55
|
+
defaultPosition: string;
|
|
56
|
+
theme: ToastTheme$1;
|
|
57
|
+
stacked: boolean;
|
|
58
|
+
swipeToDismiss: boolean;
|
|
59
|
+
sound: boolean;
|
|
60
|
+
soundPreset?: "modern" | "retro" | "futuristic" | "subtle" | "bell" | string;
|
|
61
|
+
syncTabs: boolean;
|
|
62
|
+
aiPrioritization: boolean;
|
|
63
|
+
priorityScorer?: ((context: any) => number | {
|
|
64
|
+
score: number;
|
|
65
|
+
}) | null;
|
|
66
|
+
onMetrics?: ((metrics: ToastMetrics$1) => void) | null;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Returns a real-time snapshot of toast manager telemetry metrics.
|
|
71
|
+
* @returns {import('../utils/config.js').ToastMetrics}
|
|
72
|
+
*/
|
|
73
|
+
declare function getToastMetrics(): ToastMetrics$1;
|
|
1
74
|
declare function resetToastManager(): void;
|
|
2
75
|
/**
|
|
3
76
|
* Updates an active, pending, or queued toast in-place with new options.
|
|
@@ -8,15 +81,40 @@ declare function updateToastByKey(key: string, newOptions?: Partial<ToastOptions
|
|
|
8
81
|
|
|
9
82
|
declare function resetContainerRegistry(): void;
|
|
10
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Returns a shared AnalyserNode for real-time waveform visualization.
|
|
86
|
+
* @returns {AnalyserNode | null}
|
|
87
|
+
*/
|
|
88
|
+
declare function getAudioAnalyser(): AnalyserNode | null;
|
|
11
89
|
/**
|
|
12
90
|
* Synthesizes a pleasant audio chime or tone using pure Web Audio API oscillators.
|
|
13
91
|
* Zero external audio assets or network requests.
|
|
14
|
-
* @param {'success' | 'error' | 'warning' | 'info' | 'pop' | string} toneType
|
|
92
|
+
* @param {'success' | 'error' | 'warning' | 'info' | 'pop' | string} [toneType="info"]
|
|
93
|
+
* @param {'modern' | 'retro' | 'futuristic' | 'subtle' | 'bell' | string} [preset="modern"]
|
|
94
|
+
* @returns {void}
|
|
95
|
+
*/
|
|
96
|
+
declare function playTone(toneType?: "success" | "error" | "warning" | "info" | "pop" | string, preset?: "modern" | "retro" | "futuristic" | "subtle" | "bell" | string): void;
|
|
97
|
+
/**
|
|
98
|
+
* Registers a custom sound synthesis preset.
|
|
99
|
+
* @param {string} name - Name of the preset (e.g. 'arcade')
|
|
100
|
+
* @param {(ctx: AudioContext, toneType: string, now: number) => void} synthesizerFn
|
|
101
|
+
* @returns {boolean} True if successfully registered
|
|
102
|
+
*/
|
|
103
|
+
declare function registerSoundPreset(name: string, synthesizerFn: (ctx: AudioContext, toneType: string, now: number) => void): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Returns a list of all currently available sound presets (built-in + custom).
|
|
106
|
+
* @returns {string[]}
|
|
107
|
+
*/
|
|
108
|
+
declare function getSoundPresets(): string[];
|
|
109
|
+
/**
|
|
110
|
+
* Clears custom sound presets (primarily for testing and environment resets).
|
|
111
|
+
* @returns {void}
|
|
15
112
|
*/
|
|
16
|
-
declare function
|
|
113
|
+
declare function resetSoundPresets(): void;
|
|
17
114
|
/**
|
|
18
115
|
* Globally enable or disable synthesized notification sounds.
|
|
19
116
|
* @param {boolean} enabled
|
|
117
|
+
* @returns {void}
|
|
20
118
|
*/
|
|
21
119
|
declare function setAudioEnabled(enabled: boolean): void;
|
|
22
120
|
/**
|
|
@@ -24,7 +122,408 @@ declare function setAudioEnabled(enabled: boolean): void;
|
|
|
24
122
|
* @returns {boolean}
|
|
25
123
|
*/
|
|
26
124
|
declare function isAudioEnabled(): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Resets the cached AudioContext instance (useful for test isolation).
|
|
127
|
+
* @returns {void}
|
|
128
|
+
*/
|
|
129
|
+
declare function resetAudioContext(): void;
|
|
27
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Get or create the global toast pool instance
|
|
133
|
+
* @param {number} [initialSize=5] - Initial pool size
|
|
134
|
+
* @param {number} [maxSize=50] - Maximum pool size
|
|
135
|
+
* @returns {ToastElementPool}
|
|
136
|
+
*/
|
|
137
|
+
declare function getToastPool(initialSize?: number, maxSize?: number): ToastElementPool;
|
|
138
|
+
/**
|
|
139
|
+
* Reset pool instance (for testing)
|
|
140
|
+
*/
|
|
141
|
+
declare function resetToastPool(): void;
|
|
142
|
+
/**
|
|
143
|
+
* @typedef {Object} PooledToastElement
|
|
144
|
+
* @property {HTMLElement} element - The reusable toast element
|
|
145
|
+
* @property {boolean} inUse - Whether element is currently allocated
|
|
146
|
+
* @property {string | null} id - Unique toast ID
|
|
147
|
+
*/
|
|
148
|
+
declare class ToastElementPool {
|
|
149
|
+
constructor(initialSize?: number, maxSize?: number);
|
|
150
|
+
initialSize: number;
|
|
151
|
+
maxSize: number;
|
|
152
|
+
/** @type {Array<{element: HTMLElement, inUse: boolean, id: string | null}>} */
|
|
153
|
+
pool: Array<{
|
|
154
|
+
element: HTMLElement;
|
|
155
|
+
inUse: boolean;
|
|
156
|
+
id: string | null;
|
|
157
|
+
}>;
|
|
158
|
+
inUseCount: number;
|
|
159
|
+
/**
|
|
160
|
+
* Create a new toast element template
|
|
161
|
+
* @private
|
|
162
|
+
* @returns {HTMLElement}
|
|
163
|
+
*/
|
|
164
|
+
private _createToastElement;
|
|
165
|
+
/**
|
|
166
|
+
* Acquire a toast element from pool or create new one
|
|
167
|
+
* @param {string} toastId - Unique identifier for this toast
|
|
168
|
+
* @returns {HTMLElement} - Ready-to-use toast element
|
|
169
|
+
*/
|
|
170
|
+
acquire(toastId: string): HTMLElement;
|
|
171
|
+
/**
|
|
172
|
+
* Release a toast element back to pool
|
|
173
|
+
* @param {HTMLElement} element - The element to release
|
|
174
|
+
* @param {string} toastId - The toast ID being released
|
|
175
|
+
* @returns {void}
|
|
176
|
+
*/
|
|
177
|
+
release(element: HTMLElement, toastId: string): void;
|
|
178
|
+
/**
|
|
179
|
+
* Get pool statistics for monitoring
|
|
180
|
+
* @returns {{total: number, inUse: number, available: number, utilization: number, maxSize: number}} - Pool stats
|
|
181
|
+
*/
|
|
182
|
+
getStats(): {
|
|
183
|
+
total: number;
|
|
184
|
+
inUse: number;
|
|
185
|
+
available: number;
|
|
186
|
+
utilization: number;
|
|
187
|
+
maxSize: number;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Clear all pooled elements (for cleanup/testing)
|
|
191
|
+
* @returns {void}
|
|
192
|
+
*/
|
|
193
|
+
clear(): void;
|
|
194
|
+
/**
|
|
195
|
+
* Compact pool (remove unused elements above initial size)
|
|
196
|
+
* Useful for long-running apps with temporary toast spikes
|
|
197
|
+
* @returns {void}
|
|
198
|
+
*/
|
|
199
|
+
compact(): void;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Get or create the global broadcaster instance
|
|
204
|
+
* @returns {ToastBroadcaster}
|
|
205
|
+
*/
|
|
206
|
+
declare function getToastBroadcaster(): ToastBroadcaster;
|
|
207
|
+
/**
|
|
208
|
+
* Reset broadcaster instance (for testing)
|
|
209
|
+
*/
|
|
210
|
+
declare function resetToastBroadcaster(): void;
|
|
211
|
+
/**
|
|
212
|
+
* @typedef {Object} ToastSyncMessage
|
|
213
|
+
* @property {string} type - Message type: 'create', 'update', 'dismiss', 'sync-request', 'sync-response'
|
|
214
|
+
* @property {string} toastId - Unique toast identifier
|
|
215
|
+
* @property {Object} payload - Message-specific data
|
|
216
|
+
* @property {number} timestamp - Message timestamp
|
|
217
|
+
* @property {string} tabId - Originating tab ID
|
|
218
|
+
*/
|
|
219
|
+
declare class ToastBroadcaster {
|
|
220
|
+
channel: BroadcastChannel;
|
|
221
|
+
tabId: string;
|
|
222
|
+
isLeadTab: boolean;
|
|
223
|
+
listeners: Map<any, any>;
|
|
224
|
+
supportsBroadcastChannel: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Generate unique tab identifier with high cross-tab entropy.
|
|
227
|
+
* Unlike DOM element IDs (which rely on monotonic counters within a single thread),
|
|
228
|
+
* tab IDs must guarantee uniqueness across independent browser processes/tabs
|
|
229
|
+
* that do not share memory even if opened in the exact same millisecond.
|
|
230
|
+
*
|
|
231
|
+
* @private
|
|
232
|
+
* @returns {string} Unique tab ID matching /^tab-[a-z0-9]+-[a-z0-9]+$/
|
|
233
|
+
*/
|
|
234
|
+
private _generateTabId;
|
|
235
|
+
/**
|
|
236
|
+
* Initialize BroadcastChannel if available
|
|
237
|
+
* @private
|
|
238
|
+
*/
|
|
239
|
+
private _initBroadcastChannel;
|
|
240
|
+
/**
|
|
241
|
+
* Attempt to become the lead tab
|
|
242
|
+
* @private
|
|
243
|
+
*/
|
|
244
|
+
private _becomeLeadIfNeeded;
|
|
245
|
+
leaderTimer: any;
|
|
246
|
+
/**
|
|
247
|
+
* Broadcast a toast event to other tabs
|
|
248
|
+
* @param {string} type - Event type
|
|
249
|
+
* @param {string} [toastId=''] - Toast ID
|
|
250
|
+
* @param {Object} [payload={}] - Event payload
|
|
251
|
+
*/
|
|
252
|
+
broadcast(type: string, toastId?: string, payload?: any): void;
|
|
253
|
+
/**
|
|
254
|
+
* Handle incoming message from other tab
|
|
255
|
+
* @private
|
|
256
|
+
* @param {ToastSyncMessage} message
|
|
257
|
+
*/
|
|
258
|
+
private _handleMessage;
|
|
259
|
+
/**
|
|
260
|
+
* Register listener for toast events
|
|
261
|
+
* @param {string} type - Event type to listen for
|
|
262
|
+
* @param {Function} callback - Callback function
|
|
263
|
+
* @returns {Function} - Unsubscribe function
|
|
264
|
+
*/
|
|
265
|
+
on(type: string, callback: Function): Function;
|
|
266
|
+
/**
|
|
267
|
+
* Register active toasts getter (set by ToastManager)
|
|
268
|
+
* @param {Function} getter
|
|
269
|
+
*/
|
|
270
|
+
registerActiveToastsGetter(getter: Function): void;
|
|
271
|
+
_getActiveToasts: Function;
|
|
272
|
+
/**
|
|
273
|
+
* Register queued toasts getter (set by ToastManager)
|
|
274
|
+
* @param {Function} getter
|
|
275
|
+
*/
|
|
276
|
+
registerQueuedToastsGetter(getter: Function): void;
|
|
277
|
+
_getQueuedToasts: Function;
|
|
278
|
+
/**
|
|
279
|
+
* Check if cross-tab sync is supported
|
|
280
|
+
* @returns {boolean}
|
|
281
|
+
*/
|
|
282
|
+
isSupported(): boolean;
|
|
283
|
+
/**
|
|
284
|
+
* Get current tab ID
|
|
285
|
+
* @returns {string}
|
|
286
|
+
*/
|
|
287
|
+
getTabId(): string;
|
|
288
|
+
/**
|
|
289
|
+
* Is this the lead tab
|
|
290
|
+
* @returns {boolean}
|
|
291
|
+
*/
|
|
292
|
+
isLeadingTab(): boolean;
|
|
293
|
+
/**
|
|
294
|
+
* Cleanup on unload
|
|
295
|
+
*/
|
|
296
|
+
destroy(): void;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Calculate priority score for toast based on type, message, and context
|
|
301
|
+
* @param {ToastScoringContext} context
|
|
302
|
+
* @returns {ScorerResult}
|
|
303
|
+
*/
|
|
304
|
+
declare function calculateToastPriority(context: ToastScoringContext): ScorerResult;
|
|
305
|
+
/**
|
|
306
|
+
* Extract semantic category from toast message
|
|
307
|
+
* @param {string} message
|
|
308
|
+
* @returns {string[]} - Categories (security, performance, user, system, etc.)
|
|
309
|
+
*/
|
|
310
|
+
declare function categorizeToast(message: string): string[];
|
|
311
|
+
type ToastScoringContext = {
|
|
312
|
+
/**
|
|
313
|
+
* - Toast type (success, error, warning, info)
|
|
314
|
+
*/
|
|
315
|
+
type: string;
|
|
316
|
+
/**
|
|
317
|
+
* - Toast message content
|
|
318
|
+
*/
|
|
319
|
+
message: string;
|
|
320
|
+
/**
|
|
321
|
+
* - Duration in milliseconds
|
|
322
|
+
*/
|
|
323
|
+
duration: number;
|
|
324
|
+
/**
|
|
325
|
+
* - Full toast options
|
|
326
|
+
*/
|
|
327
|
+
options: any;
|
|
328
|
+
};
|
|
329
|
+
type ScorerResult = {
|
|
330
|
+
/**
|
|
331
|
+
* - Priority score (0-100)
|
|
332
|
+
*/
|
|
333
|
+
score: number;
|
|
334
|
+
/**
|
|
335
|
+
* - Score breakdown by factor
|
|
336
|
+
*/
|
|
337
|
+
breakdown: any;
|
|
338
|
+
/**
|
|
339
|
+
* - Detected keywords affecting score
|
|
340
|
+
*/
|
|
341
|
+
keywords: string[];
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Calculate velocity of a swipe gesture
|
|
346
|
+
* @param {number} distance - Distance traveled in pixels
|
|
347
|
+
* @param {number} duration - Duration in milliseconds
|
|
348
|
+
* @returns {number} - Velocity in pixels/millisecond
|
|
349
|
+
*/
|
|
350
|
+
declare function calculateVelocity(distance: number, duration: number): number;
|
|
351
|
+
/**
|
|
352
|
+
* Detect if gesture is a flick (fast swipe with high velocity)
|
|
353
|
+
* @param {number} velocity - Gesture velocity (px/ms)
|
|
354
|
+
* @param {number} distance - Distance traveled (px)
|
|
355
|
+
* @param {number} [velocityThreshold=0.5] - Minimum velocity for flick (default 0.5 px/ms)
|
|
356
|
+
* @param {number} [distanceThreshold=50] - Minimum distance for flick (default 50px)
|
|
357
|
+
* @returns {boolean}
|
|
358
|
+
*/
|
|
359
|
+
declare function isFlick(velocity: number, distance: number, velocityThreshold?: number, distanceThreshold?: number): boolean;
|
|
360
|
+
/**
|
|
361
|
+
* Detect pinch gesture (two-finger distance change)
|
|
362
|
+
* @param {GestureState} state
|
|
363
|
+
* @param {number} sensitivityThreshold - Minimum distance change for pinch (default 20px)
|
|
364
|
+
* @returns {Object} - Pinch info { isPinch, scale, direction }
|
|
365
|
+
*/
|
|
366
|
+
declare function detectPinch(state: GestureState, sensitivityThreshold?: number): any;
|
|
367
|
+
/**
|
|
368
|
+
* Create gesture detector function for element
|
|
369
|
+
* @param {HTMLElement} element
|
|
370
|
+
* @param {Object} options
|
|
371
|
+
* @returns {Object} - Detector with attach/detach methods
|
|
372
|
+
*/
|
|
373
|
+
declare function createGestureDetector(element: HTMLElement, options?: any): any;
|
|
374
|
+
type TouchPoint = {
|
|
375
|
+
/**
|
|
376
|
+
* - X coordinate
|
|
377
|
+
*/
|
|
378
|
+
x: number;
|
|
379
|
+
/**
|
|
380
|
+
* - Y coordinate
|
|
381
|
+
*/
|
|
382
|
+
y: number;
|
|
383
|
+
/**
|
|
384
|
+
* - Touch identifier
|
|
385
|
+
*/
|
|
386
|
+
id: number;
|
|
387
|
+
/**
|
|
388
|
+
* - Timestamp
|
|
389
|
+
*/
|
|
390
|
+
time: number;
|
|
391
|
+
};
|
|
392
|
+
type GestureState = {
|
|
393
|
+
/**
|
|
394
|
+
* - Current touch points
|
|
395
|
+
*/
|
|
396
|
+
touches: TouchPoint[];
|
|
397
|
+
/**
|
|
398
|
+
* - Initial touch points
|
|
399
|
+
*/
|
|
400
|
+
startTouches: TouchPoint[];
|
|
401
|
+
/**
|
|
402
|
+
* - Gesture start time
|
|
403
|
+
*/
|
|
404
|
+
startTime: number;
|
|
405
|
+
/**
|
|
406
|
+
* - Initial distance between touches (for pinch)
|
|
407
|
+
*/
|
|
408
|
+
startDistance: number;
|
|
409
|
+
/**
|
|
410
|
+
* - Current distance between touches
|
|
411
|
+
*/
|
|
412
|
+
currentDistance: number;
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Reset the internal monotonic counter (primarily for test isolation)
|
|
417
|
+
* @returns {void}
|
|
418
|
+
*/
|
|
419
|
+
declare function resetToastIdCounter(): void;
|
|
420
|
+
/**
|
|
421
|
+
* Generate unique, CSS-safe ID for DOM elements.
|
|
422
|
+
* Combines sanitized prefix, millisecond timestamp, and monotonic counter with session salt.
|
|
423
|
+
* Guarantees 0% collision rate without HTTP/HTTPS secure context restrictions.
|
|
424
|
+
*
|
|
425
|
+
* @param {string} [prefix="toast"] - Optional prefix for ID
|
|
426
|
+
* @returns {string} Unique ID matching /^toast-[a-z0-9]+-[a-z0-9]+$/
|
|
427
|
+
*/
|
|
428
|
+
declare function generateToastId(prefix?: string): string;
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Register a custom named spring preset.
|
|
432
|
+
* @param {string} name - Unique preset identifier
|
|
433
|
+
* @param {SpringConfig & { bezierFallback?: string }} config - Spring parameters
|
|
434
|
+
*/
|
|
435
|
+
declare function registerSpringPreset(name: string, config: SpringConfig$1 & {
|
|
436
|
+
bezierFallback?: string;
|
|
437
|
+
}): void;
|
|
438
|
+
/**
|
|
439
|
+
* Retrieve list of registered spring preset names.
|
|
440
|
+
* @returns {string[]}
|
|
441
|
+
*/
|
|
442
|
+
declare function getSpringPresets(): string[];
|
|
443
|
+
/**
|
|
444
|
+
* Reset all registered custom spring presets back to defaults.
|
|
445
|
+
*/
|
|
446
|
+
declare function resetSpringPresets(): void;
|
|
447
|
+
/**
|
|
448
|
+
* Resolves a spring input into concrete numerical physics constants.
|
|
449
|
+
* @param {boolean | SpringPreset | SpringConfig} spring - Preset name or custom parameters
|
|
450
|
+
* @returns {{ stiffness: number, damping: number, mass: number, bezierFallback: string } | null}
|
|
451
|
+
*/
|
|
452
|
+
declare function resolveSpringConfig(spring: boolean | SpringPreset$1 | SpringConfig$1): {
|
|
453
|
+
stiffness: number;
|
|
454
|
+
damping: number;
|
|
455
|
+
mass: number;
|
|
456
|
+
bezierFallback: string;
|
|
457
|
+
} | null;
|
|
458
|
+
/**
|
|
459
|
+
* Solves the damped harmonic oscillator step response at time t (in seconds).
|
|
460
|
+
* Returns displacement value y(t) transitioning from 0 to 1.
|
|
461
|
+
*
|
|
462
|
+
* @param {number} t - Time in seconds (t >= 0)
|
|
463
|
+
* @param {{ stiffness: number, damping: number, mass: number }} config
|
|
464
|
+
* @returns {number} Value of step response at time t
|
|
465
|
+
*/
|
|
466
|
+
declare function solveSpring(t: number, config: {
|
|
467
|
+
stiffness: number;
|
|
468
|
+
damping: number;
|
|
469
|
+
mass: number;
|
|
470
|
+
}): number;
|
|
471
|
+
/**
|
|
472
|
+
* Calculates the duration (in milliseconds) required for the spring to settle
|
|
473
|
+
* within an acceptable error threshold (default: 0.005 / 0.5%).
|
|
474
|
+
*
|
|
475
|
+
* @param {{ stiffness: number, damping: number, mass: number }} config
|
|
476
|
+
* @param {number} [threshold=0.005]
|
|
477
|
+
* @returns {number} Settling duration in milliseconds
|
|
478
|
+
*/
|
|
479
|
+
declare function calculateSpringSettlingDuration(config: {
|
|
480
|
+
stiffness: number;
|
|
481
|
+
damping: number;
|
|
482
|
+
mass: number;
|
|
483
|
+
}, threshold?: number): number;
|
|
484
|
+
/**
|
|
485
|
+
* Generates a modern CSS linear(...) timing function representation of the spring motion.
|
|
486
|
+
* @param {{ stiffness: number, damping: number, mass: number }} config
|
|
487
|
+
* @param {number} [points=32]
|
|
488
|
+
* @returns {string} CSS linear(...) curve string
|
|
489
|
+
*/
|
|
490
|
+
declare function generateSpringLinearEasing(config: {
|
|
491
|
+
stiffness: number;
|
|
492
|
+
damping: number;
|
|
493
|
+
mass: number;
|
|
494
|
+
}, points?: number): string;
|
|
495
|
+
/**
|
|
496
|
+
* Returns comprehensive transition timing, easing, and duration parameters for a toast with spring physics.
|
|
497
|
+
* @param {boolean | SpringPreset | SpringConfig} spring
|
|
498
|
+
* @returns {{ config: { stiffness: number, damping: number, mass: number }, duration: number, easing: string, isSpring: boolean } | null}
|
|
499
|
+
*/
|
|
500
|
+
declare function getSpringTransition(spring: boolean | SpringPreset$1 | SpringConfig$1): {
|
|
501
|
+
config: {
|
|
502
|
+
stiffness: number;
|
|
503
|
+
damping: number;
|
|
504
|
+
mass: number;
|
|
505
|
+
};
|
|
506
|
+
duration: number;
|
|
507
|
+
easing: string;
|
|
508
|
+
isSpring: boolean;
|
|
509
|
+
} | null;
|
|
510
|
+
type SpringConfig$1 = {
|
|
511
|
+
/**
|
|
512
|
+
* - Spring tension / stiffness constant (k > 0)
|
|
513
|
+
*/
|
|
514
|
+
stiffness?: number;
|
|
515
|
+
/**
|
|
516
|
+
* - Damping friction coefficient (c > 0)
|
|
517
|
+
*/
|
|
518
|
+
damping?: number;
|
|
519
|
+
/**
|
|
520
|
+
* - Inertial mass (m > 0)
|
|
521
|
+
*/
|
|
522
|
+
mass?: number;
|
|
523
|
+
};
|
|
524
|
+
type SpringPreset$1 = "default" | "gentle" | "wobbly" | "stiff" | "bouncy" | string;
|
|
525
|
+
|
|
526
|
+
type SoundPreset = "modern" | "retro" | "futuristic" | "subtle" | "bell" | string;
|
|
28
527
|
type ToastType = "info" | "success" | "error" | "warning";
|
|
29
528
|
type ToastPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right" | "top-center" | "bottom-center" | "left-center" | "right-center" | "top-full-width" | "bottom-full-width" | "center";
|
|
30
529
|
type CTAOptions = {
|
|
@@ -37,6 +536,35 @@ type CTAOptions = {
|
|
|
37
536
|
autoClose?: boolean;
|
|
38
537
|
onClick?: (e: MouseEvent) => void | Promise<void>;
|
|
39
538
|
};
|
|
539
|
+
type UndoOptions = {
|
|
540
|
+
/**
|
|
541
|
+
* - Button text label (default: 'Undo')
|
|
542
|
+
*/
|
|
543
|
+
label?: string;
|
|
544
|
+
/**
|
|
545
|
+
* - Whether to display decaying seconds counter (default: true)
|
|
546
|
+
*/
|
|
547
|
+
showCountdown?: boolean;
|
|
548
|
+
/**
|
|
549
|
+
* - Callback fired when clicked
|
|
550
|
+
*/
|
|
551
|
+
onUndo?: (e: MouseEvent, toast: HTMLElement) => void | Promise<void>;
|
|
552
|
+
};
|
|
553
|
+
type SpringConfig = {
|
|
554
|
+
/**
|
|
555
|
+
* - Spring stiffness constant (k > 0)
|
|
556
|
+
*/
|
|
557
|
+
stiffness?: number;
|
|
558
|
+
/**
|
|
559
|
+
* - Damping friction coefficient (c > 0)
|
|
560
|
+
*/
|
|
561
|
+
damping?: number;
|
|
562
|
+
/**
|
|
563
|
+
* - Inertial mass (m > 0)
|
|
564
|
+
*/
|
|
565
|
+
mass?: number;
|
|
566
|
+
};
|
|
567
|
+
type SpringPreset = "default" | "gentle" | "wobbly" | "stiff" | "bouncy" | string;
|
|
40
568
|
type ToastLoaderOptions = {
|
|
41
569
|
/**
|
|
42
570
|
* - Spinner size in pixels (default 14)
|
|
@@ -80,11 +608,63 @@ type ToastOptions = {
|
|
|
80
608
|
fontDirection?: "auto" | "ltr" | "rtl";
|
|
81
609
|
fontPadding?: string;
|
|
82
610
|
className?: string;
|
|
83
|
-
cta?: CTAOptions;
|
|
611
|
+
cta?: CTAOptions | CTAOptions[];
|
|
612
|
+
undo?: ((e: MouseEvent, toast: HTMLElement) => void | Promise<void>) | UndoOptions;
|
|
613
|
+
spring?: boolean | SpringPreset | SpringConfig;
|
|
84
614
|
stacked?: boolean;
|
|
85
615
|
sound?: boolean | "success" | "error" | "warning" | "info" | "pop" | string;
|
|
616
|
+
soundPreset?: SoundPreset;
|
|
86
617
|
swipeToDismiss?: boolean;
|
|
87
618
|
progress?: number;
|
|
619
|
+
syncTabs?: boolean;
|
|
620
|
+
aiPrioritization?: boolean;
|
|
621
|
+
priority?: number;
|
|
622
|
+
usePool?: boolean;
|
|
623
|
+
};
|
|
624
|
+
type ReducedMotionMode = "auto" | "always" | "never";
|
|
625
|
+
type ToastTheme = "light" | "dark" | "high-contrast" | "compact" | "spacious" | "glass";
|
|
626
|
+
type ToastMountTarget = Element | DocumentFragment | ShadowRoot;
|
|
627
|
+
type ToastMetrics = {
|
|
628
|
+
/**
|
|
629
|
+
* - Currently rendered active toasts
|
|
630
|
+
*/
|
|
631
|
+
activeCount: number;
|
|
632
|
+
/**
|
|
633
|
+
* - Number of queued toasts waiting to be displayed
|
|
634
|
+
*/
|
|
635
|
+
queueDepth: number;
|
|
636
|
+
/**
|
|
637
|
+
* - Count of currently visible toasts
|
|
638
|
+
*/
|
|
639
|
+
visibleCount: number;
|
|
640
|
+
/**
|
|
641
|
+
* - Number of toasts dropped due to queue overflow
|
|
642
|
+
*/
|
|
643
|
+
droppedCount: number;
|
|
644
|
+
/**
|
|
645
|
+
* - Epoch timestamp (ms) when metrics were recorded
|
|
646
|
+
*/
|
|
647
|
+
timestamp: number;
|
|
648
|
+
};
|
|
649
|
+
type ToastGlobalConfig = {
|
|
650
|
+
maxVisible?: number;
|
|
651
|
+
maxQueueSize?: number;
|
|
652
|
+
zIndex?: number;
|
|
653
|
+
targetNode?: ToastMountTarget | null;
|
|
654
|
+
disableInlineStyles?: boolean;
|
|
655
|
+
reducedMotion?: ReducedMotionMode;
|
|
656
|
+
defaultPosition?: ToastPosition | string;
|
|
657
|
+
theme?: ToastTheme;
|
|
658
|
+
stacked?: boolean;
|
|
659
|
+
swipeToDismiss?: boolean;
|
|
660
|
+
sound?: boolean;
|
|
661
|
+
soundPreset?: SoundPreset;
|
|
662
|
+
syncTabs?: boolean;
|
|
663
|
+
aiPrioritization?: boolean;
|
|
664
|
+
priorityScorer?: ((context: any) => number | {
|
|
665
|
+
score: number;
|
|
666
|
+
}) | null;
|
|
667
|
+
onMetrics?: ((metrics: ToastMetrics) => void) | null;
|
|
88
668
|
};
|
|
89
669
|
type ToastHandle = {
|
|
90
670
|
dismiss: () => Promise<void>;
|
|
@@ -113,7 +693,7 @@ declare function setDefaultColors(colors: Partial<Record<ToastType, string>>): v
|
|
|
113
693
|
declare function setDefaultMessages(messages: Partial<Record<ToastType, string>>): void;
|
|
114
694
|
declare function dismissToast(): Promise<void>;
|
|
115
695
|
declare function noopAll(): Promise<void>;
|
|
116
|
-
declare const version:
|
|
696
|
+
declare const version: any;
|
|
117
697
|
/**
|
|
118
698
|
* Wraps a promise or function with automatic loading, success, and error toasts.
|
|
119
699
|
* @template T
|
|
@@ -124,5 +704,5 @@ declare const version: "3.13.0";
|
|
|
124
704
|
*/
|
|
125
705
|
declare function toastPromise<T>(promiseOrFn: Promise<T> | (() => Promise<T> | T), messages?: ToastPromiseMessages, options?: ToastOptions): Promise<T>;
|
|
126
706
|
|
|
127
|
-
export { createToastWithPriority as createToast, dismissToast as dismiss, isAudioEnabled, noopAll as noop, playTone, resetContainerRegistry, resetToastManager, setAudioEnabled, setDefaultColors, setDefaultMessages, toastPromise, updateToastByKey, version };
|
|
128
|
-
export type { CTAOptions, ToastHandle, ToastLoaderOptions, ToastOptions, ToastPosition, ToastPromiseMessages, ToastType };
|
|
707
|
+
export { calculateSpringSettlingDuration, calculateToastPriority, calculateVelocity, categorizeToast, createGestureDetector, createToastWithPriority as createToast, detectPinch, dismissToast as dismiss, generateSpringLinearEasing, generateToastId, getAudioAnalyser, getConfig, getSoundPresets, getSpringPresets, getSpringTransition, getToastBroadcaster, getToastMetrics, getToastPool, isAudioEnabled, isFlick, noopAll as noop, playTone, registerSoundPreset, registerSpringPreset, resetAudioContext, resetConfig, resetContainerRegistry, resetSoundPresets, resetSpringPresets, resetToastBroadcaster, resetToastIdCounter, resetToastManager, resetToastPool, resolveSpringConfig, setAudioEnabled, setConfig, setDefaultColors, setDefaultMessages, shouldReduceMotion, solveSpring, toastPromise, updateToastByKey, version };
|
|
708
|
+
export type { CTAOptions, ReducedMotionMode, SoundPreset, SpringConfig, SpringPreset, ToastGlobalConfig, ToastHandle, ToastLoaderOptions, ToastMetrics, ToastMountTarget, ToastOptions, ToastPosition, ToastPromiseMessages, ToastTheme, ToastType, UndoOptions };
|