@moneymq/react 0.3.0 → 0.3.2

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,34 @@ 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
+ setShouldRender(false);
575
+ setAnimationPhase("closed");
576
+ onClose();
577
+ }, 300);
578
+ }, [onClose, animationPhase]);
551
579
  const copyToClipboard = (text, type) => {
552
580
  navigator.clipboard.writeText(text);
553
581
  if (type === "sender") {
@@ -741,7 +769,7 @@ function CheckoutModal({
741
769
  }, 3e3);
742
770
  return () => clearInterval(interval);
743
771
  }, [canPay, visible]);
744
- if (!visible) return null;
772
+ if (!shouldRender) return null;
745
773
  const WalletIcon = () => /* @__PURE__ */ jsxs3("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [
746
774
  /* @__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
775
  /* @__PURE__ */ jsx4("path", { d: "M16 12h.01", strokeWidth: "2", strokeLinecap: "round" })
@@ -760,6 +788,9 @@ function CheckoutModal({
760
788
  ] }),
761
789
  /* @__PURE__ */ jsx4("defs", { children: /* @__PURE__ */ jsx4("clipPath", { id: "clip0_524_7", children: /* @__PURE__ */ jsx4("rect", { width: "471", height: "99", fill: "white" }) }) })
762
790
  ] });
791
+ const isBackdropVisible = animationPhase === "backdrop" || animationPhase === "open";
792
+ const isModalVisible = animationPhase === "open";
793
+ const isClosing = animationPhase === "closing";
763
794
  return /* @__PURE__ */ jsxs3(Fragment2, { children: [
764
795
  /* @__PURE__ */ jsx4("style", { children: `
765
796
  @keyframes spin {
@@ -774,10 +805,11 @@ function CheckoutModal({
774
805
  position: "fixed",
775
806
  inset: 0,
776
807
  zIndex: 9998,
777
- backgroundColor: "rgba(0, 0, 0, 0.6)",
778
- backdropFilter: "blur(8px)"
808
+ backgroundColor: isBackdropVisible && !isClosing ? "rgba(0, 0, 0, 0.6)" : "rgba(0, 0, 0, 0)",
809
+ backdropFilter: isBackdropVisible && !isClosing ? "blur(8px)" : "blur(0px)",
810
+ transition: "background-color 250ms cubic-bezier(0.4, 0, 0.2, 1), backdrop-filter 250ms cubic-bezier(0.4, 0, 0.2, 1)"
779
811
  },
780
- onClick: onClose
812
+ onClick: handleAnimatedClose
781
813
  }
782
814
  ),
783
815
  /* @__PURE__ */ jsx4(
@@ -790,9 +822,10 @@ function CheckoutModal({
790
822
  display: "flex",
791
823
  alignItems: "center",
792
824
  justifyContent: "center",
793
- padding: "1rem"
825
+ padding: "1rem",
826
+ pointerEvents: isClosing ? "none" : "auto"
794
827
  },
795
- onClick: onClose,
828
+ onClick: handleAnimatedClose,
796
829
  children: /* @__PURE__ */ jsxs3(
797
830
  "div",
798
831
  {
@@ -802,7 +835,10 @@ function CheckoutModal({
802
835
  backgroundColor: "#2c2c2e",
803
836
  borderRadius: "1rem",
804
837
  overflow: "hidden",
805
- boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.5)"
838
+ boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.5)",
839
+ opacity: isModalVisible && !isClosing ? 1 : 0,
840
+ transform: isModalVisible && !isClosing ? "translateY(0) scale(1)" : "translateY(-20px) scale(0.98)",
841
+ transition: "opacity 200ms cubic-bezier(0.4, 0, 0.2, 1), transform 250ms cubic-bezier(0.4, 0, 0.2, 1)"
806
842
  },
807
843
  onClick: (e) => e.stopPropagation(),
808
844
  children: [
@@ -854,7 +890,7 @@ function CheckoutModal({
854
890
  /* @__PURE__ */ jsx4(
855
891
  "button",
856
892
  {
857
- onClick: onClose,
893
+ onClick: handleAnimatedClose,
858
894
  style: {
859
895
  padding: "0.375rem 0.75rem",
860
896
  fontSize: "0.8125rem",