@moneymq/react 0.3.0 → 0.3.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.mjs CHANGED
@@ -548,6 +548,32 @@ function CheckoutModal({
548
548
  const { isSandboxMode, sandboxAccounts } = useSandbox();
549
549
  const client = useMoneyMQ();
550
550
  const lottieRef = useRef(null);
551
+ const [shouldRender, setShouldRender] = useState4(false);
552
+ const [animationPhase, setAnimationPhase] = useState4("closed");
553
+ useEffect3(() => {
554
+ if (visible && !shouldRender) {
555
+ setShouldRender(true);
556
+ requestAnimationFrame(() => {
557
+ setAnimationPhase("backdrop");
558
+ setTimeout(() => {
559
+ setAnimationPhase("open");
560
+ }, 150);
561
+ });
562
+ } else if (!visible && shouldRender && animationPhase !== "closing") {
563
+ setAnimationPhase("closing");
564
+ setTimeout(() => {
565
+ setShouldRender(false);
566
+ setAnimationPhase("closed");
567
+ }, 300);
568
+ }
569
+ }, [visible, shouldRender, animationPhase]);
570
+ const handleAnimatedClose = useCallback3(() => {
571
+ if (animationPhase === "closing") return;
572
+ setAnimationPhase("closing");
573
+ setTimeout(() => {
574
+ onClose();
575
+ }, 300);
576
+ }, [onClose, animationPhase]);
551
577
  const copyToClipboard = (text, type) => {
552
578
  navigator.clipboard.writeText(text);
553
579
  if (type === "sender") {
@@ -741,7 +767,7 @@ function CheckoutModal({
741
767
  }, 3e3);
742
768
  return () => clearInterval(interval);
743
769
  }, [canPay, visible]);
744
- if (!visible) return null;
770
+ if (!shouldRender) return null;
745
771
  const WalletIcon = () => /* @__PURE__ */ jsxs3("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [
746
772
  /* @__PURE__ */ jsx4("path", { d: "M21 12V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2h14a2 2 0 002-2v-5z" }),
747
773
  /* @__PURE__ */ jsx4("path", { d: "M16 12h.01", strokeWidth: "2", strokeLinecap: "round" })
@@ -760,6 +786,9 @@ function CheckoutModal({
760
786
  ] }),
761
787
  /* @__PURE__ */ jsx4("defs", { children: /* @__PURE__ */ jsx4("clipPath", { id: "clip0_524_7", children: /* @__PURE__ */ jsx4("rect", { width: "471", height: "99", fill: "white" }) }) })
762
788
  ] });
789
+ const isBackdropVisible = animationPhase === "backdrop" || animationPhase === "open";
790
+ const isModalVisible = animationPhase === "open";
791
+ const isClosing = animationPhase === "closing";
763
792
  return /* @__PURE__ */ jsxs3(Fragment2, { children: [
764
793
  /* @__PURE__ */ jsx4("style", { children: `
765
794
  @keyframes spin {
@@ -774,10 +803,11 @@ function CheckoutModal({
774
803
  position: "fixed",
775
804
  inset: 0,
776
805
  zIndex: 9998,
777
- backgroundColor: "rgba(0, 0, 0, 0.6)",
778
- backdropFilter: "blur(8px)"
806
+ backgroundColor: isBackdropVisible && !isClosing ? "rgba(0, 0, 0, 0.6)" : "rgba(0, 0, 0, 0)",
807
+ backdropFilter: isBackdropVisible && !isClosing ? "blur(8px)" : "blur(0px)",
808
+ transition: "background-color 250ms cubic-bezier(0.4, 0, 0.2, 1), backdrop-filter 250ms cubic-bezier(0.4, 0, 0.2, 1)"
779
809
  },
780
- onClick: onClose
810
+ onClick: handleAnimatedClose
781
811
  }
782
812
  ),
783
813
  /* @__PURE__ */ jsx4(
@@ -790,9 +820,10 @@ function CheckoutModal({
790
820
  display: "flex",
791
821
  alignItems: "center",
792
822
  justifyContent: "center",
793
- padding: "1rem"
823
+ padding: "1rem",
824
+ pointerEvents: isClosing ? "none" : "auto"
794
825
  },
795
- onClick: onClose,
826
+ onClick: handleAnimatedClose,
796
827
  children: /* @__PURE__ */ jsxs3(
797
828
  "div",
798
829
  {
@@ -802,7 +833,10 @@ function CheckoutModal({
802
833
  backgroundColor: "#2c2c2e",
803
834
  borderRadius: "1rem",
804
835
  overflow: "hidden",
805
- boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.5)"
836
+ boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.5)",
837
+ opacity: isModalVisible && !isClosing ? 1 : 0,
838
+ transform: isModalVisible && !isClosing ? "translateY(0) scale(1)" : "translateY(-20px) scale(0.98)",
839
+ transition: "opacity 200ms cubic-bezier(0.4, 0, 0.2, 1), transform 250ms cubic-bezier(0.4, 0, 0.2, 1)"
806
840
  },
807
841
  onClick: (e) => e.stopPropagation(),
808
842
  children: [
@@ -854,7 +888,7 @@ function CheckoutModal({
854
888
  /* @__PURE__ */ jsx4(
855
889
  "button",
856
890
  {
857
- onClick: onClose,
891
+ onClick: handleAnimatedClose,
858
892
  style: {
859
893
  padding: "0.375rem 0.75rem",
860
894
  fontSize: "0.8125rem",