customizable-toast-notification 3.20.2 → 4.0.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.
- package/CHANGELOG.md +29 -0
- package/README.md +56 -132
- package/dist/angular.cjs +126 -0
- package/dist/angular.cjs.map +1 -0
- package/dist/angular.d.ts +44 -0
- package/dist/angular.esm.mjs +126 -0
- package/dist/angular.esm.mjs.map +1 -0
- package/dist/index.cjs +115 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.d.ts +14 -12
- package/dist/index.css.map +2 -2
- package/dist/index.d.ts +28 -630
- package/dist/index.esm.mjs +114 -4
- package/dist/index.esm.mjs.map +1 -1
- package/dist/index.umd.js +114 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/react.cjs +126 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.ts +46 -0
- package/dist/react.esm.mjs +126 -0
- package/dist/react.esm.mjs.map +1 -0
- package/dist/solid.cjs +126 -0
- package/dist/solid.cjs.map +1 -0
- package/dist/solid.d.ts +45 -0
- package/dist/solid.esm.mjs +126 -0
- package/dist/solid.esm.mjs.map +1 -0
- package/dist/svelte.cjs +126 -0
- package/dist/svelte.cjs.map +1 -0
- package/dist/svelte.d.ts +50 -0
- package/dist/svelte.esm.mjs +126 -0
- package/dist/svelte.esm.mjs.map +1 -0
- package/dist/vue.cjs +126 -0
- package/dist/vue.cjs.map +1 -0
- package/dist/vue.d.ts +45 -0
- package/dist/vue.esm.mjs +126 -0
- package/dist/vue.esm.mjs.map +1 -0
- package/package.json +20 -28
package/dist/index.d.ts
CHANGED
|
@@ -57,11 +57,9 @@ type ToastGlobalConfig$1 = {
|
|
|
57
57
|
stacked: boolean;
|
|
58
58
|
swipeToDismiss: boolean;
|
|
59
59
|
sound: boolean;
|
|
60
|
-
soundPreset?: "modern" | "retro" | "futuristic" | "subtle" | "bell" | string;
|
|
61
60
|
icon?: boolean;
|
|
62
61
|
pauseOnHover?: boolean;
|
|
63
|
-
|
|
64
|
-
aiPrioritization: boolean;
|
|
62
|
+
priorityQueue: boolean;
|
|
65
63
|
shadowDom?: boolean;
|
|
66
64
|
trapFocus?: boolean;
|
|
67
65
|
debug?: boolean;
|
|
@@ -76,60 +74,6 @@ type ToastGlobalConfig$1 = {
|
|
|
76
74
|
onMetrics?: ((metrics: ToastMetrics$1) => void) | null;
|
|
77
75
|
};
|
|
78
76
|
|
|
79
|
-
/**
|
|
80
|
-
* Returns a read-only snapshot copy of the notification history ring buffer.
|
|
81
|
-
* @returns {ToastHistoryEntry[]}
|
|
82
|
-
*/
|
|
83
|
-
declare function getToastHistory(): ToastHistoryEntry$1[];
|
|
84
|
-
/**
|
|
85
|
-
* Clears all entries from the notification history ring buffer.
|
|
86
|
-
*/
|
|
87
|
-
declare function clearToastHistory(): void;
|
|
88
|
-
/**
|
|
89
|
-
* Sets the maximum capacity of the history ring buffer.
|
|
90
|
-
* @param {number} capacity - Maximum number of items to retain (minimum 1)
|
|
91
|
-
*/
|
|
92
|
-
declare function setHistoryCapacity(capacity: number): void;
|
|
93
|
-
/**
|
|
94
|
-
* Resets the history buffer back to empty and restores default capacity.
|
|
95
|
-
*/
|
|
96
|
-
declare function resetToastHistory(): void;
|
|
97
|
-
type ToastType$1 = "info" | "success" | "error" | "warning";
|
|
98
|
-
type ToastHistoryEntry$1 = {
|
|
99
|
-
/**
|
|
100
|
-
* - Unique toast key or identifier
|
|
101
|
-
*/
|
|
102
|
-
id: string;
|
|
103
|
-
/**
|
|
104
|
-
* - Notification text message
|
|
105
|
-
*/
|
|
106
|
-
message: string;
|
|
107
|
-
/**
|
|
108
|
-
* - Notification status type
|
|
109
|
-
*/
|
|
110
|
-
type: ToastType$1;
|
|
111
|
-
/**
|
|
112
|
-
* - Toast placement coordinates
|
|
113
|
-
*/
|
|
114
|
-
position: string;
|
|
115
|
-
/**
|
|
116
|
-
* - Unix timestamp (ms) when created
|
|
117
|
-
*/
|
|
118
|
-
timestamp: number;
|
|
119
|
-
/**
|
|
120
|
-
* - Unix timestamp (ms) when dismissed
|
|
121
|
-
*/
|
|
122
|
-
dismissedAt?: number;
|
|
123
|
-
/**
|
|
124
|
-
* - Current lifecycle status
|
|
125
|
-
*/
|
|
126
|
-
status: "active" | "dismissed" | "dropped";
|
|
127
|
-
/**
|
|
128
|
-
* - Snapshot of configured options
|
|
129
|
-
*/
|
|
130
|
-
options?: Record<string, unknown>;
|
|
131
|
-
};
|
|
132
|
-
|
|
133
77
|
/**
|
|
134
78
|
* Returns a real-time snapshot of toast manager telemetry metrics.
|
|
135
79
|
* @returns {import('../utils/config.js').ToastMetrics}
|
|
@@ -145,366 +89,6 @@ declare function updateToastByKey(key: string, newOptions?: Partial<ToastOptions
|
|
|
145
89
|
|
|
146
90
|
declare function resetContainerRegistry(): void;
|
|
147
91
|
|
|
148
|
-
/**
|
|
149
|
-
* Lazily initialize and return a shared AudioContext.
|
|
150
|
-
* Returns null in non-browser or unsupported environments.
|
|
151
|
-
* @param {boolean} [forceResume=true] - Whether to attempt resuming suspended AudioContext
|
|
152
|
-
* @returns {AudioContext | null}
|
|
153
|
-
*/
|
|
154
|
-
declare function getAudioContext(forceResume?: boolean): AudioContext | null;
|
|
155
|
-
/**
|
|
156
|
-
* Returns a shared AnalyserNode for real-time waveform visualization.
|
|
157
|
-
* @returns {AnalyserNode | null}
|
|
158
|
-
*/
|
|
159
|
-
declare function getAudioAnalyser(): AnalyserNode | null;
|
|
160
|
-
declare function playTone(toneType: string, preset: any): void;
|
|
161
|
-
/**
|
|
162
|
-
* Registers a custom sound synthesis preset.
|
|
163
|
-
* @param {string} name - Name of the preset (e.g. 'arcade')
|
|
164
|
-
* @param {(ctx: AudioContext, toneType: string, now: number) => void} synthesizerFn
|
|
165
|
-
* @returns {boolean} True if successfully registered
|
|
166
|
-
*/
|
|
167
|
-
declare function registerSoundPreset(name: string, synthesizerFn: (ctx: AudioContext, toneType: string, now: number) => void): boolean;
|
|
168
|
-
/**
|
|
169
|
-
* Returns a list of all currently available sound presets (built-in + custom).
|
|
170
|
-
* @returns {string[]}
|
|
171
|
-
*/
|
|
172
|
-
declare function getSoundPresets(): string[];
|
|
173
|
-
/**
|
|
174
|
-
* Clears custom sound presets (primarily for testing and environment resets).
|
|
175
|
-
* @returns {void}
|
|
176
|
-
*/
|
|
177
|
-
declare function resetSoundPresets(): void;
|
|
178
|
-
/**
|
|
179
|
-
* Globally enable or disable synthesized notification sounds.
|
|
180
|
-
* @param {boolean} enabled
|
|
181
|
-
* @returns {void}
|
|
182
|
-
*/
|
|
183
|
-
declare function setAudioEnabled(enabled: boolean): void;
|
|
184
|
-
/**
|
|
185
|
-
* Returns current global audio feedback status.
|
|
186
|
-
* @returns {boolean}
|
|
187
|
-
*/
|
|
188
|
-
declare function isAudioEnabled(): boolean;
|
|
189
|
-
/**
|
|
190
|
-
* Resets the cached AudioContext instance (useful for test isolation).
|
|
191
|
-
* @returns {void}
|
|
192
|
-
*/
|
|
193
|
-
declare function resetAudioContext(): void;
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Get or create the global toast pool instance
|
|
197
|
-
* @param {number} [initialSize=5] - Initial pool size
|
|
198
|
-
* @param {number} [maxSize=50] - Maximum pool size
|
|
199
|
-
* @returns {ToastElementPool}
|
|
200
|
-
*/
|
|
201
|
-
declare function getToastPool(initialSize?: number, maxSize?: number): ToastElementPool;
|
|
202
|
-
/**
|
|
203
|
-
* Reset pool instance (for testing)
|
|
204
|
-
*/
|
|
205
|
-
declare function resetToastPool(): void;
|
|
206
|
-
/**
|
|
207
|
-
* @typedef {Object} PooledToastElement
|
|
208
|
-
* @property {HTMLElement} element - The reusable toast element
|
|
209
|
-
* @property {boolean} inUse - Whether element is currently allocated
|
|
210
|
-
* @property {string | null} id - Unique toast ID
|
|
211
|
-
*/
|
|
212
|
-
declare class ToastElementPool {
|
|
213
|
-
constructor(initialSize?: number, maxSize?: number);
|
|
214
|
-
initialSize: number;
|
|
215
|
-
maxSize: number;
|
|
216
|
-
/** @type {Array<{element: HTMLElement, inUse: boolean, id: string | null}>} */
|
|
217
|
-
pool: Array<{
|
|
218
|
-
element: HTMLElement;
|
|
219
|
-
inUse: boolean;
|
|
220
|
-
id: string | null;
|
|
221
|
-
}>;
|
|
222
|
-
inUseCount: number;
|
|
223
|
-
/**
|
|
224
|
-
* Create a new toast element template
|
|
225
|
-
* @private
|
|
226
|
-
* @returns {HTMLElement}
|
|
227
|
-
*/
|
|
228
|
-
private _createToastElement;
|
|
229
|
-
/**
|
|
230
|
-
* Acquire a toast element from pool or create new one
|
|
231
|
-
* @param {string} toastId - Unique identifier for this toast
|
|
232
|
-
* @returns {HTMLElement} - Ready-to-use toast element
|
|
233
|
-
*/
|
|
234
|
-
acquire(toastId: string): HTMLElement;
|
|
235
|
-
/**
|
|
236
|
-
* Release a toast element back to pool
|
|
237
|
-
* @param {HTMLElement} element - The element to release
|
|
238
|
-
* @param {string} toastId - The toast ID being released
|
|
239
|
-
* @returns {void}
|
|
240
|
-
*/
|
|
241
|
-
release(element: HTMLElement, toastId: string): void;
|
|
242
|
-
/**
|
|
243
|
-
* Get pool statistics for monitoring
|
|
244
|
-
* @returns {{total: number, inUse: number, available: number, utilization: number, maxSize: number}} - Pool stats
|
|
245
|
-
*/
|
|
246
|
-
getStats(): {
|
|
247
|
-
total: number;
|
|
248
|
-
inUse: number;
|
|
249
|
-
available: number;
|
|
250
|
-
utilization: number;
|
|
251
|
-
maxSize: number;
|
|
252
|
-
};
|
|
253
|
-
/**
|
|
254
|
-
* Clear all pooled elements (for cleanup/testing)
|
|
255
|
-
* @returns {void}
|
|
256
|
-
*/
|
|
257
|
-
clear(): void;
|
|
258
|
-
/**
|
|
259
|
-
* Compact pool (remove unused elements above initial size)
|
|
260
|
-
* Useful for long-running apps with temporary toast spikes
|
|
261
|
-
* @returns {void}
|
|
262
|
-
*/
|
|
263
|
-
compact(): void;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Get or create the global broadcaster instance
|
|
268
|
-
* @returns {ToastBroadcaster}
|
|
269
|
-
*/
|
|
270
|
-
declare function getToastBroadcaster(): ToastBroadcaster;
|
|
271
|
-
/**
|
|
272
|
-
* Reset broadcaster instance (for testing)
|
|
273
|
-
*/
|
|
274
|
-
declare function resetToastBroadcaster(): void;
|
|
275
|
-
/**
|
|
276
|
-
* @typedef {Object} ToastSyncMessage
|
|
277
|
-
* @property {string} type - Message type: 'create', 'update', 'dismiss', 'sync-request', 'sync-response'
|
|
278
|
-
* @property {string} toastId - Unique toast identifier
|
|
279
|
-
* @property {Record<string, unknown>} payload - Message-specific data
|
|
280
|
-
* @property {number} timestamp - Message timestamp
|
|
281
|
-
* @property {string} tabId - Originating tab ID
|
|
282
|
-
*/
|
|
283
|
-
declare class ToastBroadcaster {
|
|
284
|
-
/** @type {BroadcastChannel | null} */
|
|
285
|
-
channel: BroadcastChannel | null;
|
|
286
|
-
tabId: string;
|
|
287
|
-
isLeadTab: boolean;
|
|
288
|
-
/** @type {ReturnType<typeof setTimeout> | null} */
|
|
289
|
-
leaderTimer: ReturnType<typeof setTimeout> | null;
|
|
290
|
-
/** @type {Map<string, Array<(data: Record<string, unknown>) => void>>} */
|
|
291
|
-
listeners: Map<string, Array<(data: Record<string, unknown>) => void>>;
|
|
292
|
-
supportsBroadcastChannel: boolean;
|
|
293
|
-
/**
|
|
294
|
-
* Generate unique tab identifier with high cross-tab entropy.
|
|
295
|
-
* Unlike DOM element IDs (which rely on monotonic counters within a single thread),
|
|
296
|
-
* tab IDs must guarantee uniqueness across independent browser processes/tabs
|
|
297
|
-
* that do not share memory even if opened in the exact same millisecond.
|
|
298
|
-
*
|
|
299
|
-
* @private
|
|
300
|
-
* @returns {string} Unique tab ID matching /^tab-[a-z0-9]+-[a-z0-9]+$/
|
|
301
|
-
*/
|
|
302
|
-
private _generateTabId;
|
|
303
|
-
/**
|
|
304
|
-
* Initialize BroadcastChannel if available
|
|
305
|
-
* @private
|
|
306
|
-
*/
|
|
307
|
-
private _initBroadcastChannel;
|
|
308
|
-
/**
|
|
309
|
-
* Attempt to become the lead tab
|
|
310
|
-
* @private
|
|
311
|
-
*/
|
|
312
|
-
private _becomeLeadIfNeeded;
|
|
313
|
-
/**
|
|
314
|
-
* Broadcast a toast event to other tabs
|
|
315
|
-
* @param {string} type - Event type
|
|
316
|
-
* @param {string} [toastId=''] - Toast ID
|
|
317
|
-
* @param {Record<string, unknown>} [payload={}] - Event payload
|
|
318
|
-
*/
|
|
319
|
-
broadcast(type: string, toastId?: string, payload?: Record<string, unknown>): void;
|
|
320
|
-
/**
|
|
321
|
-
* Handle incoming message from other tab
|
|
322
|
-
* @private
|
|
323
|
-
* @param {ToastSyncMessage} message
|
|
324
|
-
*/
|
|
325
|
-
private _handleMessage;
|
|
326
|
-
/**
|
|
327
|
-
* Register listener for toast events
|
|
328
|
-
* @param {string} type - Event type to listen for
|
|
329
|
-
* @param {Function} callback - Callback function
|
|
330
|
-
* @returns {Function} - Unsubscribe function
|
|
331
|
-
*/
|
|
332
|
-
on(type: string, callback: Function): Function;
|
|
333
|
-
/**
|
|
334
|
-
* Register active toasts getter (set by ToastManager)
|
|
335
|
-
* @param {Function} getter
|
|
336
|
-
*/
|
|
337
|
-
registerActiveToastsGetter(getter: Function): void;
|
|
338
|
-
_getActiveToasts: Function;
|
|
339
|
-
/**
|
|
340
|
-
* Register queued toasts getter (set by ToastManager)
|
|
341
|
-
* @param {Function} getter
|
|
342
|
-
*/
|
|
343
|
-
registerQueuedToastsGetter(getter: Function): void;
|
|
344
|
-
_getQueuedToasts: Function;
|
|
345
|
-
/**
|
|
346
|
-
* Check if cross-tab sync is supported
|
|
347
|
-
* @returns {boolean}
|
|
348
|
-
*/
|
|
349
|
-
isSupported(): boolean;
|
|
350
|
-
/**
|
|
351
|
-
* Get current tab ID
|
|
352
|
-
* @returns {string}
|
|
353
|
-
*/
|
|
354
|
-
getTabId(): string;
|
|
355
|
-
/**
|
|
356
|
-
* Is this the lead tab
|
|
357
|
-
* @returns {boolean}
|
|
358
|
-
*/
|
|
359
|
-
isLeadingTab(): boolean;
|
|
360
|
-
/**
|
|
361
|
-
* Cleanup on unload
|
|
362
|
-
*/
|
|
363
|
-
destroy(): void;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Calculate priority score for toast based on type, message, and context
|
|
368
|
-
* @param {ToastScoringContext} context
|
|
369
|
-
* @returns {ScorerResult}
|
|
370
|
-
*/
|
|
371
|
-
declare function calculateToastPriority(context: ToastScoringContext): ScorerResult;
|
|
372
|
-
/**
|
|
373
|
-
* Extract semantic category from toast message
|
|
374
|
-
* @param {string} message
|
|
375
|
-
* @returns {string[]} - Categories (security, performance, user, system, etc.)
|
|
376
|
-
*/
|
|
377
|
-
declare function categorizeToast(message: string): string[];
|
|
378
|
-
type ToastScoringContext = {
|
|
379
|
-
/**
|
|
380
|
-
* - Toast type (success, error, warning, info)
|
|
381
|
-
*/
|
|
382
|
-
type: string;
|
|
383
|
-
/**
|
|
384
|
-
* - Toast message content
|
|
385
|
-
*/
|
|
386
|
-
message: string;
|
|
387
|
-
/**
|
|
388
|
-
* - Duration in milliseconds
|
|
389
|
-
*/
|
|
390
|
-
duration: number;
|
|
391
|
-
/**
|
|
392
|
-
* - Full toast options
|
|
393
|
-
*/
|
|
394
|
-
options: Record<string, unknown>;
|
|
395
|
-
};
|
|
396
|
-
type ScorerResult = {
|
|
397
|
-
/**
|
|
398
|
-
* - Priority score (0-100)
|
|
399
|
-
*/
|
|
400
|
-
score: number;
|
|
401
|
-
/**
|
|
402
|
-
* - Score breakdown by factor
|
|
403
|
-
*/
|
|
404
|
-
breakdown: Record<string, number>;
|
|
405
|
-
/**
|
|
406
|
-
* - Detected keywords affecting score
|
|
407
|
-
*/
|
|
408
|
-
keywords: string[];
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Calculate velocity of a swipe gesture
|
|
413
|
-
* @param {number} distance - Distance traveled in pixels
|
|
414
|
-
* @param {number} duration - Duration in milliseconds
|
|
415
|
-
* @returns {number} - Velocity in pixels/millisecond
|
|
416
|
-
*/
|
|
417
|
-
declare function calculateVelocity(distance: number, duration: number): number;
|
|
418
|
-
/**
|
|
419
|
-
* Detect if gesture is a flick (fast swipe with high velocity)
|
|
420
|
-
* @param {number} velocity - Gesture velocity (px/ms)
|
|
421
|
-
* @param {number} distance - Distance traveled (px)
|
|
422
|
-
* @param {number} [velocityThreshold=0.5] - Minimum velocity for flick (default 0.5 px/ms)
|
|
423
|
-
* @param {number} [distanceThreshold=50] - Minimum distance for flick (default 50px)
|
|
424
|
-
* @returns {boolean}
|
|
425
|
-
*/
|
|
426
|
-
declare function isFlick(velocity: number, distance: number, velocityThreshold?: number, distanceThreshold?: number): boolean;
|
|
427
|
-
/**
|
|
428
|
-
* Detect pinch gesture (two-finger distance change)
|
|
429
|
-
* @param {GestureState} state
|
|
430
|
-
* @param {number} [sensitivityThreshold=20] - Minimum distance change for pinch (default 20px)
|
|
431
|
-
* @returns {PinchResult} - Pinch info { isPinch, scale, direction, distanceChange }
|
|
432
|
-
*/
|
|
433
|
-
declare function detectPinch(state: GestureState, sensitivityThreshold?: number): PinchResult;
|
|
434
|
-
/**
|
|
435
|
-
* Create gesture detector function for element
|
|
436
|
-
* @param {HTMLElement} element
|
|
437
|
-
* @param {GestureDetectorOptions} [options]
|
|
438
|
-
* @returns {GestureDetector} - Detector with attach/detach methods
|
|
439
|
-
*/
|
|
440
|
-
declare function createGestureDetector(element: HTMLElement, options?: GestureDetectorOptions): GestureDetector;
|
|
441
|
-
type TouchPoint = {
|
|
442
|
-
/**
|
|
443
|
-
* - X coordinate
|
|
444
|
-
*/
|
|
445
|
-
x: number;
|
|
446
|
-
/**
|
|
447
|
-
* - Y coordinate
|
|
448
|
-
*/
|
|
449
|
-
y: number;
|
|
450
|
-
/**
|
|
451
|
-
* - Touch identifier
|
|
452
|
-
*/
|
|
453
|
-
id: number;
|
|
454
|
-
/**
|
|
455
|
-
* - Timestamp
|
|
456
|
-
*/
|
|
457
|
-
time: number;
|
|
458
|
-
};
|
|
459
|
-
type GestureState = {
|
|
460
|
-
/**
|
|
461
|
-
* - Current touch points
|
|
462
|
-
*/
|
|
463
|
-
touches: TouchPoint[];
|
|
464
|
-
/**
|
|
465
|
-
* - Initial touch points
|
|
466
|
-
*/
|
|
467
|
-
startTouches: TouchPoint[];
|
|
468
|
-
/**
|
|
469
|
-
* - Gesture start time
|
|
470
|
-
*/
|
|
471
|
-
startTime: number;
|
|
472
|
-
/**
|
|
473
|
-
* - Initial distance between touches (for pinch)
|
|
474
|
-
*/
|
|
475
|
-
startDistance: number;
|
|
476
|
-
/**
|
|
477
|
-
* - Current distance between touches
|
|
478
|
-
*/
|
|
479
|
-
currentDistance: number;
|
|
480
|
-
};
|
|
481
|
-
type PinchResult = {
|
|
482
|
-
isPinch: boolean;
|
|
483
|
-
scale: number;
|
|
484
|
-
direction: "none" | "in" | "out";
|
|
485
|
-
distanceChange?: number;
|
|
486
|
-
};
|
|
487
|
-
type SwipeResult = {
|
|
488
|
-
distance: number;
|
|
489
|
-
velocity: number;
|
|
490
|
-
direction: "none" | "left" | "right";
|
|
491
|
-
duration: number;
|
|
492
|
-
};
|
|
493
|
-
type GestureDetectorOptions = {
|
|
494
|
-
onFlick?: ((swipe: SwipeResult) => void);
|
|
495
|
-
onPinch?: ((pinch: PinchResult) => void);
|
|
496
|
-
onSwipe?: ((swipe: SwipeResult) => void);
|
|
497
|
-
flickVelocityThreshold?: number;
|
|
498
|
-
swipeVelocityThreshold?: number;
|
|
499
|
-
swipeDistanceThreshold?: number;
|
|
500
|
-
pinchSensitivity?: number;
|
|
501
|
-
};
|
|
502
|
-
type GestureDetector = {
|
|
503
|
-
attach: () => void;
|
|
504
|
-
detach: () => void;
|
|
505
|
-
getState: () => GestureState | null;
|
|
506
|
-
};
|
|
507
|
-
|
|
508
92
|
/**
|
|
509
93
|
* Reset the internal monotonic counter (primarily for test isolation)
|
|
510
94
|
* @returns {void}
|
|
@@ -520,159 +104,6 @@ declare function resetToastIdCounter(): void;
|
|
|
520
104
|
*/
|
|
521
105
|
declare function generateToastId(prefix?: string): string;
|
|
522
106
|
|
|
523
|
-
/**
|
|
524
|
-
* Register a custom named spring preset.
|
|
525
|
-
* @param {string} name - Unique preset identifier
|
|
526
|
-
* @param {SpringConfig & { bezierFallback?: string }} config - Spring parameters
|
|
527
|
-
*/
|
|
528
|
-
declare function registerSpringPreset(name: string, config: SpringConfig$1 & {
|
|
529
|
-
bezierFallback?: string;
|
|
530
|
-
}): void;
|
|
531
|
-
/**
|
|
532
|
-
* Retrieve list of registered spring preset names.
|
|
533
|
-
* @returns {string[]}
|
|
534
|
-
*/
|
|
535
|
-
declare function getSpringPresets(): string[];
|
|
536
|
-
/**
|
|
537
|
-
* Reset all registered custom spring presets back to defaults.
|
|
538
|
-
*/
|
|
539
|
-
declare function resetSpringPresets(): void;
|
|
540
|
-
/**
|
|
541
|
-
* Resolves a spring input into concrete numerical physics constants.
|
|
542
|
-
* @param {boolean | SpringPreset | SpringConfig} spring - Preset name or custom parameters
|
|
543
|
-
* @returns {{ stiffness: number, damping: number, mass: number, bezierFallback: string } | null}
|
|
544
|
-
*/
|
|
545
|
-
declare function resolveSpringConfig(spring: boolean | SpringPreset$1 | SpringConfig$1): {
|
|
546
|
-
stiffness: number;
|
|
547
|
-
damping: number;
|
|
548
|
-
mass: number;
|
|
549
|
-
bezierFallback: string;
|
|
550
|
-
} | null;
|
|
551
|
-
/**
|
|
552
|
-
* Solves the damped harmonic oscillator step response at time t (in seconds).
|
|
553
|
-
* Returns displacement value y(t) transitioning from 0 to 1.
|
|
554
|
-
*
|
|
555
|
-
* @param {number} t - Time in seconds (t >= 0)
|
|
556
|
-
* @param {{ stiffness: number, damping: number, mass: number }} config
|
|
557
|
-
* @returns {number} Value of step response at time t
|
|
558
|
-
*/
|
|
559
|
-
declare function solveSpring(t: number, config: {
|
|
560
|
-
stiffness: number;
|
|
561
|
-
damping: number;
|
|
562
|
-
mass: number;
|
|
563
|
-
}): number;
|
|
564
|
-
/**
|
|
565
|
-
* Calculates the duration (in milliseconds) required for the spring to settle
|
|
566
|
-
* within an acceptable error threshold (default: 0.005 / 0.5%).
|
|
567
|
-
*
|
|
568
|
-
* @param {{ stiffness: number, damping: number, mass: number }} config
|
|
569
|
-
* @param {number} [threshold=0.005]
|
|
570
|
-
* @returns {number} Settling duration in milliseconds
|
|
571
|
-
*/
|
|
572
|
-
declare function calculateSpringSettlingDuration(config: {
|
|
573
|
-
stiffness: number;
|
|
574
|
-
damping: number;
|
|
575
|
-
mass: number;
|
|
576
|
-
}, threshold?: number): number;
|
|
577
|
-
/**
|
|
578
|
-
* Generates a modern CSS linear(...) timing function representation of the spring motion.
|
|
579
|
-
* @param {{ stiffness: number, damping: number, mass: number }} config
|
|
580
|
-
* @param {number} [points=32]
|
|
581
|
-
* @returns {string} CSS linear(...) curve string
|
|
582
|
-
*/
|
|
583
|
-
declare function generateSpringLinearEasing(config: {
|
|
584
|
-
stiffness: number;
|
|
585
|
-
damping: number;
|
|
586
|
-
mass: number;
|
|
587
|
-
}, points?: number): string;
|
|
588
|
-
/**
|
|
589
|
-
* Returns comprehensive transition timing, easing, and duration parameters for a toast with spring physics.
|
|
590
|
-
* @param {boolean | SpringPreset | SpringConfig} spring
|
|
591
|
-
* @returns {{ config: { stiffness: number, damping: number, mass: number }, duration: number, easing: string, isSpring: boolean } | null}
|
|
592
|
-
*/
|
|
593
|
-
declare function getSpringTransition(spring: boolean | SpringPreset$1 | SpringConfig$1): {
|
|
594
|
-
config: {
|
|
595
|
-
stiffness: number;
|
|
596
|
-
damping: number;
|
|
597
|
-
mass: number;
|
|
598
|
-
};
|
|
599
|
-
duration: number;
|
|
600
|
-
easing: string;
|
|
601
|
-
isSpring: boolean;
|
|
602
|
-
} | null;
|
|
603
|
-
type SpringConfig$1 = {
|
|
604
|
-
/**
|
|
605
|
-
* - Spring tension / stiffness constant (k > 0)
|
|
606
|
-
*/
|
|
607
|
-
stiffness?: number;
|
|
608
|
-
/**
|
|
609
|
-
* - Damping friction coefficient (c > 0)
|
|
610
|
-
*/
|
|
611
|
-
damping?: number;
|
|
612
|
-
/**
|
|
613
|
-
* - Inertial mass (m > 0)
|
|
614
|
-
*/
|
|
615
|
-
mass?: number;
|
|
616
|
-
};
|
|
617
|
-
type SpringPreset$1 = "default" | "gentle" | "wobbly" | "stiff" | "bouncy" | string;
|
|
618
|
-
|
|
619
|
-
/**
|
|
620
|
-
* Sets the active global locale for toast notifications.
|
|
621
|
-
* @param {string} locale - Locale code (e.g. 'en', 'hi', 'es', 'fr', 'de', 'ar', 'ja')
|
|
622
|
-
* @returns {string} The active locale code
|
|
623
|
-
*/
|
|
624
|
-
declare function setLocale(locale: string): string;
|
|
625
|
-
/**
|
|
626
|
-
* Returns the currently active global locale code.
|
|
627
|
-
* @returns {string} Current locale code
|
|
628
|
-
*/
|
|
629
|
-
declare function getLocale(): string;
|
|
630
|
-
/**
|
|
631
|
-
* Returns a list of all currently supported locale codes.
|
|
632
|
-
* @returns {string[]} Array of locale codes
|
|
633
|
-
*/
|
|
634
|
-
declare function getAvailableLocales(): string[];
|
|
635
|
-
/**
|
|
636
|
-
* Registers or overrides localized messages for a given locale code.
|
|
637
|
-
* @param {string} locale - Locale code (e.g. 'it', 'pt', 'zh')
|
|
638
|
-
* @param {LocaleMessages} messages - Dictionary of localized messages
|
|
639
|
-
*/
|
|
640
|
-
declare function registerLocale(locale: string, messages: LocaleMessages): void;
|
|
641
|
-
/**
|
|
642
|
-
* Resets the active locale back to 'en' and clears any registered custom locales.
|
|
643
|
-
*/
|
|
644
|
-
declare function resetLocale(): void;
|
|
645
|
-
type LocaleMessages = {
|
|
646
|
-
/**
|
|
647
|
-
* - Default success message
|
|
648
|
-
*/
|
|
649
|
-
success?: string;
|
|
650
|
-
/**
|
|
651
|
-
* - Default error message
|
|
652
|
-
*/
|
|
653
|
-
error?: string;
|
|
654
|
-
/**
|
|
655
|
-
* - Default warning message
|
|
656
|
-
*/
|
|
657
|
-
warning?: string;
|
|
658
|
-
/**
|
|
659
|
-
* - Default information message
|
|
660
|
-
*/
|
|
661
|
-
info?: string;
|
|
662
|
-
/**
|
|
663
|
-
* - Default loading message
|
|
664
|
-
*/
|
|
665
|
-
loading?: string;
|
|
666
|
-
/**
|
|
667
|
-
* - Default Undo action label
|
|
668
|
-
*/
|
|
669
|
-
undo?: string;
|
|
670
|
-
/**
|
|
671
|
-
* - Default Close button aria-label
|
|
672
|
-
*/
|
|
673
|
-
close?: string;
|
|
674
|
-
};
|
|
675
|
-
|
|
676
107
|
/**
|
|
677
108
|
* Attach global keyboard event listeners (Escape to dismiss, F6/Alt+T for landmark navigation)
|
|
678
109
|
* @param {Window} [win]
|
|
@@ -711,21 +142,6 @@ type UndoOptions = {
|
|
|
711
142
|
*/
|
|
712
143
|
onUndo?: (e: MouseEvent, toast: HTMLElement) => void | Promise<void>;
|
|
713
144
|
};
|
|
714
|
-
type SpringConfig = {
|
|
715
|
-
/**
|
|
716
|
-
* - Spring stiffness constant (k > 0)
|
|
717
|
-
*/
|
|
718
|
-
stiffness?: number;
|
|
719
|
-
/**
|
|
720
|
-
* - Damping friction coefficient (c > 0)
|
|
721
|
-
*/
|
|
722
|
-
damping?: number;
|
|
723
|
-
/**
|
|
724
|
-
* - Inertial mass (m > 0)
|
|
725
|
-
*/
|
|
726
|
-
mass?: number;
|
|
727
|
-
};
|
|
728
|
-
type SpringPreset = "default" | "gentle" | "wobbly" | "stiff" | "bouncy" | string;
|
|
729
145
|
type ToastLoaderOptions = {
|
|
730
146
|
/**
|
|
731
147
|
* - Spinner size in pixels (default 14)
|
|
@@ -741,6 +157,10 @@ type ToastLoaderOptions = {
|
|
|
741
157
|
text?: string;
|
|
742
158
|
};
|
|
743
159
|
type ToastOptions = {
|
|
160
|
+
/**
|
|
161
|
+
* - Optional custom unique identifier for the toast notification
|
|
162
|
+
*/
|
|
163
|
+
id?: string;
|
|
744
164
|
message?: string;
|
|
745
165
|
type?: ToastType;
|
|
746
166
|
duration?: number;
|
|
@@ -752,7 +172,7 @@ type ToastOptions = {
|
|
|
752
172
|
showProgressBar?: boolean;
|
|
753
173
|
animationDuration?: string;
|
|
754
174
|
animationEasing?: string;
|
|
755
|
-
animationType?: "default" | "fade" | "slide" | "zoom" | "bounce" | "flip" | string;
|
|
175
|
+
animationType?: "default" | "fade" | "slide" | "zoom" | "bounce" | "flip" | "spring" | string;
|
|
756
176
|
progressColor?: string;
|
|
757
177
|
progressBarColor?: string;
|
|
758
178
|
progressHeight?: string;
|
|
@@ -774,19 +194,25 @@ type ToastOptions = {
|
|
|
774
194
|
className?: string;
|
|
775
195
|
cta?: CTAOptions | CTAOptions[];
|
|
776
196
|
undo?: ((e: MouseEvent, toast: HTMLElement) => void | Promise<void>) | UndoOptions;
|
|
777
|
-
spring?: boolean
|
|
197
|
+
spring?: boolean;
|
|
778
198
|
stacked?: boolean;
|
|
779
|
-
sound?: boolean |
|
|
780
|
-
|
|
199
|
+
sound?: boolean | string;
|
|
200
|
+
/**
|
|
201
|
+
* - Sound playback handler callback
|
|
202
|
+
*/
|
|
203
|
+
onSound?: ((options: ToastOptions) => void);
|
|
781
204
|
icon?: boolean | string | HTMLElement | ((options: ToastOptions) => boolean | string | HTMLElement | null | undefined);
|
|
782
205
|
swipeToDismiss?: boolean;
|
|
783
206
|
progress?: number | string | "indeterminate";
|
|
784
207
|
progressNormalized?: boolean;
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
208
|
+
/**
|
|
209
|
+
* - Whether to sort toasts by priority
|
|
210
|
+
*/
|
|
211
|
+
priorityQueue?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* - Numeric priority score (higher = shown sooner)
|
|
214
|
+
*/
|
|
788
215
|
priority?: number;
|
|
789
|
-
usePool?: boolean;
|
|
790
216
|
/**
|
|
791
217
|
* - Optional thread/tag identifier for replacement/updating
|
|
792
218
|
*/
|
|
@@ -803,40 +229,14 @@ type ToastOptions = {
|
|
|
803
229
|
* - Whether to isolate the container in an attached Shadow DOM root
|
|
804
230
|
*/
|
|
805
231
|
shadowDom?: boolean;
|
|
806
|
-
};
|
|
807
|
-
type ToastHistoryEntry = {
|
|
808
232
|
/**
|
|
809
|
-
* -
|
|
233
|
+
* - ARIA role attribute (default: 'alert')
|
|
810
234
|
*/
|
|
811
|
-
|
|
235
|
+
role?: "alert" | "status" | string;
|
|
812
236
|
/**
|
|
813
|
-
* -
|
|
237
|
+
* - ARIA live region politeness
|
|
814
238
|
*/
|
|
815
|
-
|
|
816
|
-
/**
|
|
817
|
-
* - Notification status type
|
|
818
|
-
*/
|
|
819
|
-
type: ToastType;
|
|
820
|
-
/**
|
|
821
|
-
* - Toast placement coordinates
|
|
822
|
-
*/
|
|
823
|
-
position: string;
|
|
824
|
-
/**
|
|
825
|
-
* - Unix timestamp (ms) when created
|
|
826
|
-
*/
|
|
827
|
-
timestamp: number;
|
|
828
|
-
/**
|
|
829
|
-
* - Unix timestamp (ms) when dismissed
|
|
830
|
-
*/
|
|
831
|
-
dismissedAt?: number;
|
|
832
|
-
/**
|
|
833
|
-
* - Current lifecycle status
|
|
834
|
-
*/
|
|
835
|
-
status: "active" | "dismissed" | "dropped";
|
|
836
|
-
/**
|
|
837
|
-
* - Snapshot of configured options
|
|
838
|
-
*/
|
|
839
|
-
options?: Record<string, unknown>;
|
|
239
|
+
ariaLive?: "polite" | "assertive" | "off";
|
|
840
240
|
};
|
|
841
241
|
type ReducedMotionMode = "auto" | "always" | "never";
|
|
842
242
|
type ToastTheme = "light" | "dark" | "high-contrast" | "compact" | "spacious" | "glass";
|
|
@@ -875,9 +275,9 @@ type ToastGlobalConfig = {
|
|
|
875
275
|
stacked?: boolean;
|
|
876
276
|
swipeToDismiss?: boolean;
|
|
877
277
|
sound?: boolean;
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
278
|
+
icon?: boolean;
|
|
279
|
+
pauseOnHover?: boolean;
|
|
280
|
+
priorityQueue?: boolean;
|
|
881
281
|
shadowDom?: boolean;
|
|
882
282
|
trapFocus?: boolean;
|
|
883
283
|
debug?: boolean;
|
|
@@ -960,8 +360,6 @@ declare namespace createToastWithPriority {
|
|
|
960
360
|
export { dismissToast as dismiss };
|
|
961
361
|
export { noopAll as dismissAll };
|
|
962
362
|
export { noopAll as clear };
|
|
963
|
-
export { getToastHistory as getHistory };
|
|
964
|
-
export { clearToastHistory as clearHistory };
|
|
965
363
|
}
|
|
966
364
|
/**
|
|
967
365
|
* Displays a success toast notification.
|
|
@@ -1036,5 +434,5 @@ declare const version: string;
|
|
|
1036
434
|
*/
|
|
1037
435
|
declare function toastPromise<T>(promiseOrFn: Promise<T> | (() => Promise<T> | T), messages?: ToastPromiseMessages, options?: ToastOptions): Promise<T>;
|
|
1038
436
|
|
|
1039
|
-
export {
|
|
1040
|
-
export type { CTAOptions, ReducedMotionMode, SoundPreset,
|
|
437
|
+
export { clear, createToastWithPriority as createToast, custom, createToastWithPriority as default, dismissToast as dismiss, dismissAll, error, generateToastId, getConfig, getToastMetrics, info, initKeyboardShortcuts, loading, noopAll as noop, resetConfig, resetContainerRegistry, resetToastIdCounter, resetToastManager, setConfig, setDefaultColors, setDefaultMessages, shouldReduceMotion, success, toastPromise, updateToastByKey, version, warning };
|
|
438
|
+
export type { CTAOptions, ReducedMotionMode, SoundPreset, ToastGlobalConfig, ToastHandle, ToastLoaderOptions, ToastMetrics, ToastMountTarget, ToastOptions, ToastPosition, ToastPromiseMessages, ToastTheme, ToastType, UndoOptions };
|