customizable-toast-notification 3.18.2 → 3.20.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 +31 -0
- package/README.md +110 -5
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +173 -3
- 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 +63 -5
package/dist/index.d.ts
CHANGED
|
@@ -58,9 +58,12 @@ type ToastGlobalConfig$1 = {
|
|
|
58
58
|
swipeToDismiss: boolean;
|
|
59
59
|
sound: boolean;
|
|
60
60
|
soundPreset?: "modern" | "retro" | "futuristic" | "subtle" | "bell" | string;
|
|
61
|
+
icon?: boolean;
|
|
61
62
|
pauseOnHover?: boolean;
|
|
62
63
|
syncTabs: boolean;
|
|
63
64
|
aiPrioritization: boolean;
|
|
65
|
+
shadowDom?: boolean;
|
|
66
|
+
trapFocus?: boolean;
|
|
64
67
|
debug?: boolean;
|
|
65
68
|
priorityScorer?: ((context: {
|
|
66
69
|
type: string;
|
|
@@ -73,6 +76,60 @@ type ToastGlobalConfig$1 = {
|
|
|
73
76
|
onMetrics?: ((metrics: ToastMetrics$1) => void) | null;
|
|
74
77
|
};
|
|
75
78
|
|
|
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
|
+
|
|
76
133
|
/**
|
|
77
134
|
* Returns a real-time snapshot of toast manager telemetry metrics.
|
|
78
135
|
* @returns {import('../utils/config.js').ToastMetrics}
|
|
@@ -559,6 +616,63 @@ type SpringConfig$1 = {
|
|
|
559
616
|
};
|
|
560
617
|
type SpringPreset$1 = "default" | "gentle" | "wobbly" | "stiff" | "bouncy" | string;
|
|
561
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
|
+
|
|
562
676
|
type SoundPreset = "modern" | "retro" | "futuristic" | "subtle" | "bell" | string;
|
|
563
677
|
type ToastType = "info" | "success" | "error" | "warning";
|
|
564
678
|
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";
|
|
@@ -659,11 +773,63 @@ type ToastOptions = {
|
|
|
659
773
|
soundPreset?: SoundPreset;
|
|
660
774
|
icon?: boolean | string | HTMLElement | ((options: ToastOptions) => boolean | string | HTMLElement | null | undefined);
|
|
661
775
|
swipeToDismiss?: boolean;
|
|
662
|
-
progress?: number | "indeterminate";
|
|
776
|
+
progress?: number | string | "indeterminate";
|
|
777
|
+
progressNormalized?: boolean;
|
|
663
778
|
syncTabs?: boolean;
|
|
779
|
+
syncDismiss?: boolean;
|
|
664
780
|
aiPrioritization?: boolean;
|
|
665
781
|
priority?: number;
|
|
666
782
|
usePool?: boolean;
|
|
783
|
+
/**
|
|
784
|
+
* - Optional thread/tag identifier for replacement/updating
|
|
785
|
+
*/
|
|
786
|
+
tag?: string;
|
|
787
|
+
/**
|
|
788
|
+
* - Optional group identifier for grouping related toasts
|
|
789
|
+
*/
|
|
790
|
+
groupId?: string;
|
|
791
|
+
/**
|
|
792
|
+
* - Whether to trap keyboard Tab focus within the toast
|
|
793
|
+
*/
|
|
794
|
+
trapFocus?: boolean;
|
|
795
|
+
/**
|
|
796
|
+
* - Whether to isolate the container in an attached Shadow DOM root
|
|
797
|
+
*/
|
|
798
|
+
shadowDom?: boolean;
|
|
799
|
+
};
|
|
800
|
+
type ToastHistoryEntry = {
|
|
801
|
+
/**
|
|
802
|
+
* - Unique toast key or identifier
|
|
803
|
+
*/
|
|
804
|
+
id: string;
|
|
805
|
+
/**
|
|
806
|
+
* - Notification text message
|
|
807
|
+
*/
|
|
808
|
+
message: string;
|
|
809
|
+
/**
|
|
810
|
+
* - Notification status type
|
|
811
|
+
*/
|
|
812
|
+
type: ToastType;
|
|
813
|
+
/**
|
|
814
|
+
* - Toast placement coordinates
|
|
815
|
+
*/
|
|
816
|
+
position: string;
|
|
817
|
+
/**
|
|
818
|
+
* - Unix timestamp (ms) when created
|
|
819
|
+
*/
|
|
820
|
+
timestamp: number;
|
|
821
|
+
/**
|
|
822
|
+
* - Unix timestamp (ms) when dismissed
|
|
823
|
+
*/
|
|
824
|
+
dismissedAt?: number;
|
|
825
|
+
/**
|
|
826
|
+
* - Current lifecycle status
|
|
827
|
+
*/
|
|
828
|
+
status: "active" | "dismissed" | "dropped";
|
|
829
|
+
/**
|
|
830
|
+
* - Snapshot of configured options
|
|
831
|
+
*/
|
|
832
|
+
options?: Record<string, unknown>;
|
|
667
833
|
};
|
|
668
834
|
type ReducedMotionMode = "auto" | "always" | "never";
|
|
669
835
|
type ToastTheme = "light" | "dark" | "high-contrast" | "compact" | "spacious" | "glass";
|
|
@@ -705,6 +871,8 @@ type ToastGlobalConfig = {
|
|
|
705
871
|
soundPreset?: SoundPreset;
|
|
706
872
|
syncTabs?: boolean;
|
|
707
873
|
aiPrioritization?: boolean;
|
|
874
|
+
shadowDom?: boolean;
|
|
875
|
+
trapFocus?: boolean;
|
|
708
876
|
debug?: boolean;
|
|
709
877
|
priorityScorer?: ((context: {
|
|
710
878
|
type: string;
|
|
@@ -785,6 +953,8 @@ declare namespace createToastWithPriority {
|
|
|
785
953
|
export { dismissToast as dismiss };
|
|
786
954
|
export { noopAll as dismissAll };
|
|
787
955
|
export { noopAll as clear };
|
|
956
|
+
export { getToastHistory as getHistory };
|
|
957
|
+
export { clearToastHistory as clearHistory };
|
|
788
958
|
}
|
|
789
959
|
/**
|
|
790
960
|
* Displays a success toast notification.
|
|
@@ -859,5 +1029,5 @@ declare const version: string;
|
|
|
859
1029
|
*/
|
|
860
1030
|
declare function toastPromise<T>(promiseOrFn: Promise<T> | (() => Promise<T> | T), messages?: ToastPromiseMessages, options?: ToastOptions): Promise<T>;
|
|
861
1031
|
|
|
862
|
-
export { calculateSpringSettlingDuration, calculateToastPriority, calculateVelocity, categorizeToast, clear, createGestureDetector, createToastWithPriority as createToast, custom, createToastWithPriority as default, detectPinch, dismissToast as dismiss, dismissAll, error, generateSpringLinearEasing, generateToastId, getAudioAnalyser, getAudioContext, getConfig, getSoundPresets, getSpringPresets, getSpringTransition, getToastBroadcaster, getToastMetrics, getToastPool, info, isAudioEnabled, isFlick, loading, noopAll as noop, playTone, registerSoundPreset, registerSpringPreset, resetAudioContext, resetConfig, resetContainerRegistry, resetSoundPresets, resetSpringPresets, resetToastBroadcaster, resetToastIdCounter, resetToastManager, resetToastPool, resolveSpringConfig, setAudioEnabled, setConfig, setDefaultColors, setDefaultMessages, shouldReduceMotion, solveSpring, success, toastPromise, updateToastByKey, version, warning };
|
|
863
|
-
export type { CTAOptions, ReducedMotionMode, SoundPreset, SpringConfig, SpringPreset, ToastGlobalConfig, ToastHandle, ToastLoaderOptions, ToastMetrics, ToastMountTarget, ToastOptions, ToastPosition, ToastPromiseMessages, ToastTheme, ToastType, UndoOptions };
|
|
1032
|
+
export { calculateSpringSettlingDuration, calculateToastPriority, calculateVelocity, categorizeToast, clear, clearToastHistory, createGestureDetector, createToastWithPriority as createToast, custom, createToastWithPriority as default, detectPinch, dismissToast as dismiss, dismissAll, error, generateSpringLinearEasing, generateToastId, getAudioAnalyser, getAudioContext, getAvailableLocales, getConfig, getLocale, getSoundPresets, getSpringPresets, getSpringTransition, getToastBroadcaster, getToastHistory, getToastMetrics, getToastPool, info, isAudioEnabled, isFlick, loading, noopAll as noop, playTone, registerLocale, registerSoundPreset, registerSpringPreset, resetAudioContext, resetConfig, resetContainerRegistry, resetLocale, resetSoundPresets, resetSpringPresets, resetToastBroadcaster, resetToastHistory, resetToastIdCounter, resetToastManager, resetToastPool, resolveSpringConfig, setAudioEnabled, setConfig, setDefaultColors, setDefaultMessages, setHistoryCapacity, setLocale, shouldReduceMotion, solveSpring, success, toastPromise, updateToastByKey, version, warning };
|
|
1033
|
+
export type { CTAOptions, ReducedMotionMode, SoundPreset, SpringConfig, SpringPreset, ToastGlobalConfig, ToastHandle, ToastHistoryEntry, ToastLoaderOptions, ToastMetrics, ToastMountTarget, ToastOptions, ToastPosition, ToastPromiseMessages, ToastTheme, ToastType, UndoOptions };
|