myoperator-ui 0.0.171 → 0.0.172-beta.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/dist/index.js +12 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4653,13 +4653,18 @@ export {
|
|
|
4653
4653
|
// ============================================================================
|
|
4654
4654
|
|
|
4655
4655
|
const TOAST_LIMIT = 5;
|
|
4656
|
-
const TOAST_REMOVE_DELAY =
|
|
4656
|
+
const TOAST_REMOVE_DELAY = 2000;
|
|
4657
4657
|
|
|
4658
4658
|
type ToasterToast = ToastProps & {
|
|
4659
4659
|
id: string;
|
|
4660
4660
|
title?: React.ReactNode;
|
|
4661
4661
|
description?: React.ReactNode;
|
|
4662
4662
|
action?: ToastActionElement;
|
|
4663
|
+
/**
|
|
4664
|
+
* Duration in milliseconds before the toast is removed after dismissal.
|
|
4665
|
+
* Defaults to 2000ms (2 seconds).
|
|
4666
|
+
*/
|
|
4667
|
+
duration?: number;
|
|
4663
4668
|
};
|
|
4664
4669
|
|
|
4665
4670
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -4703,7 +4708,7 @@ interface State {
|
|
|
4703
4708
|
|
|
4704
4709
|
const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>();
|
|
4705
4710
|
|
|
4706
|
-
const addToRemoveQueue = (toastId: string) => {
|
|
4711
|
+
const addToRemoveQueue = (toastId: string, duration?: number) => {
|
|
4707
4712
|
if (toastTimeouts.has(toastId)) {
|
|
4708
4713
|
return;
|
|
4709
4714
|
}
|
|
@@ -4714,7 +4719,7 @@ const addToRemoveQueue = (toastId: string) => {
|
|
|
4714
4719
|
type: "REMOVE_TOAST",
|
|
4715
4720
|
toastId: toastId,
|
|
4716
4721
|
});
|
|
4717
|
-
}, TOAST_REMOVE_DELAY);
|
|
4722
|
+
}, duration ?? TOAST_REMOVE_DELAY);
|
|
4718
4723
|
|
|
4719
4724
|
toastTimeouts.set(toastId, timeout);
|
|
4720
4725
|
};
|
|
@@ -4739,10 +4744,11 @@ export const reducer = (state: State, action: Action): State => {
|
|
|
4739
4744
|
const { toastId } = action;
|
|
4740
4745
|
|
|
4741
4746
|
if (toastId) {
|
|
4742
|
-
|
|
4747
|
+
const toastItem = state.toasts.find((t) => t.id === toastId);
|
|
4748
|
+
addToRemoveQueue(toastId, toastItem?.duration);
|
|
4743
4749
|
} else {
|
|
4744
|
-
state.toasts.forEach((
|
|
4745
|
-
addToRemoveQueue(
|
|
4750
|
+
state.toasts.forEach((toastItem) => {
|
|
4751
|
+
addToRemoveQueue(toastItem.id, toastItem.duration);
|
|
4746
4752
|
});
|
|
4747
4753
|
}
|
|
4748
4754
|
|