sonner 2.0.0-beta.3 → 2.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/dist/index.js CHANGED
@@ -706,13 +706,13 @@ const Toast = (props)=>{
706
706
  }
707
707
  deleteToast();
708
708
  setSwipeOut(true);
709
- setIsSwiped(false);
710
709
  return;
711
710
  } else {
712
711
  var _toastRef_current2, _toastRef_current3;
713
712
  (_toastRef_current2 = toastRef.current) == null ? void 0 : _toastRef_current2.style.setProperty('--swipe-amount-x', `0px`);
714
713
  (_toastRef_current3 = toastRef.current) == null ? void 0 : _toastRef_current3.style.setProperty('--swipe-amount-y', `0px`);
715
714
  }
715
+ setIsSwiped(false);
716
716
  setSwiping(false);
717
717
  setSwipeDirection(null);
718
718
  },
@@ -952,24 +952,26 @@ const Toaster = /*#__PURE__*/ React__default.default.forwardRef(function Toaster
952
952
  return;
953
953
  }
954
954
  // Prevent batching, temp solution.
955
- ReactDOM__default.default.flushSync(()=>{
956
- setToasts((toasts)=>{
957
- const indexOfExistingToast = toasts.findIndex((t)=>t.id === toast.id);
958
- // Update the toast if it already exists
959
- if (indexOfExistingToast !== -1) {
955
+ setTimeout(()=>{
956
+ ReactDOM__default.default.flushSync(()=>{
957
+ setToasts((toasts)=>{
958
+ const indexOfExistingToast = toasts.findIndex((t)=>t.id === toast.id);
959
+ // Update the toast if it already exists
960
+ if (indexOfExistingToast !== -1) {
961
+ return [
962
+ ...toasts.slice(0, indexOfExistingToast),
963
+ {
964
+ ...toasts[indexOfExistingToast],
965
+ ...toast
966
+ },
967
+ ...toasts.slice(indexOfExistingToast + 1)
968
+ ];
969
+ }
960
970
  return [
961
- ...toasts.slice(0, indexOfExistingToast),
962
- {
963
- ...toasts[indexOfExistingToast],
964
- ...toast
965
- },
966
- ...toasts.slice(indexOfExistingToast + 1)
971
+ toast,
972
+ ...toasts
967
973
  ];
968
- }
969
- return [
970
- toast,
971
- ...toasts
972
- ];
974
+ });
973
975
  });
974
976
  });
975
977
  });
package/dist/index.mjs CHANGED
@@ -699,13 +699,13 @@ const Toast = (props)=>{
699
699
  }
700
700
  deleteToast();
701
701
  setSwipeOut(true);
702
- setIsSwiped(false);
703
702
  return;
704
703
  } else {
705
704
  var _toastRef_current2, _toastRef_current3;
706
705
  (_toastRef_current2 = toastRef.current) == null ? void 0 : _toastRef_current2.style.setProperty('--swipe-amount-x', `0px`);
707
706
  (_toastRef_current3 = toastRef.current) == null ? void 0 : _toastRef_current3.style.setProperty('--swipe-amount-y', `0px`);
708
707
  }
708
+ setIsSwiped(false);
709
709
  setSwiping(false);
710
710
  setSwipeDirection(null);
711
711
  },
@@ -945,24 +945,26 @@ const Toaster = /*#__PURE__*/ React.forwardRef(function Toaster(props, ref) {
945
945
  return;
946
946
  }
947
947
  // Prevent batching, temp solution.
948
- ReactDOM.flushSync(()=>{
949
- setToasts((toasts)=>{
950
- const indexOfExistingToast = toasts.findIndex((t)=>t.id === toast.id);
951
- // Update the toast if it already exists
952
- if (indexOfExistingToast !== -1) {
948
+ setTimeout(()=>{
949
+ ReactDOM.flushSync(()=>{
950
+ setToasts((toasts)=>{
951
+ const indexOfExistingToast = toasts.findIndex((t)=>t.id === toast.id);
952
+ // Update the toast if it already exists
953
+ if (indexOfExistingToast !== -1) {
954
+ return [
955
+ ...toasts.slice(0, indexOfExistingToast),
956
+ {
957
+ ...toasts[indexOfExistingToast],
958
+ ...toast
959
+ },
960
+ ...toasts.slice(indexOfExistingToast + 1)
961
+ ];
962
+ }
953
963
  return [
954
- ...toasts.slice(0, indexOfExistingToast),
955
- {
956
- ...toasts[indexOfExistingToast],
957
- ...toast
958
- },
959
- ...toasts.slice(indexOfExistingToast + 1)
964
+ toast,
965
+ ...toasts
960
966
  ];
961
- }
962
- return [
963
- toast,
964
- ...toasts
965
- ];
967
+ });
966
968
  });
967
969
  });
968
970
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sonner",
3
- "version": "2.0.0-beta.3",
3
+ "version": "2.0.1",
4
4
  "description": "An opinionated toast component for React.",
5
5
  "exports": {
6
6
  ".": {