@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.js CHANGED
@@ -591,6 +591,32 @@ function CheckoutModal({
591
591
  const { isSandboxMode, sandboxAccounts } = useSandbox();
592
592
  const client = useMoneyMQ();
593
593
  const lottieRef = (0, import_react4.useRef)(null);
594
+ const [shouldRender, setShouldRender] = (0, import_react4.useState)(false);
595
+ const [animationPhase, setAnimationPhase] = (0, import_react4.useState)("closed");
596
+ (0, import_react4.useEffect)(() => {
597
+ if (visible && !shouldRender) {
598
+ setShouldRender(true);
599
+ requestAnimationFrame(() => {
600
+ setAnimationPhase("backdrop");
601
+ setTimeout(() => {
602
+ setAnimationPhase("open");
603
+ }, 150);
604
+ });
605
+ } else if (!visible && shouldRender && animationPhase !== "closing") {
606
+ setAnimationPhase("closing");
607
+ setTimeout(() => {
608
+ setShouldRender(false);
609
+ setAnimationPhase("closed");
610
+ }, 300);
611
+ }
612
+ }, [visible, shouldRender, animationPhase]);
613
+ const handleAnimatedClose = (0, import_react4.useCallback)(() => {
614
+ if (animationPhase === "closing") return;
615
+ setAnimationPhase("closing");
616
+ setTimeout(() => {
617
+ onClose();
618
+ }, 300);
619
+ }, [onClose, animationPhase]);
594
620
  const copyToClipboard = (text, type) => {
595
621
  navigator.clipboard.writeText(text);
596
622
  if (type === "sender") {
@@ -784,7 +810,7 @@ function CheckoutModal({
784
810
  }, 3e3);
785
811
  return () => clearInterval(interval);
786
812
  }, [canPay, visible]);
787
- if (!visible) return null;
813
+ if (!shouldRender) return null;
788
814
  const WalletIcon = () => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [
789
815
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M21 12V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2h14a2 2 0 002-2v-5z" }),
790
816
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M16 12h.01", strokeWidth: "2", strokeLinecap: "round" })
@@ -803,6 +829,9 @@ function CheckoutModal({
803
829
  ] }),
804
830
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("clipPath", { id: "clip0_524_7", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { width: "471", height: "99", fill: "white" }) }) })
805
831
  ] });
832
+ const isBackdropVisible = animationPhase === "backdrop" || animationPhase === "open";
833
+ const isModalVisible = animationPhase === "open";
834
+ const isClosing = animationPhase === "closing";
806
835
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
807
836
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("style", { children: `
808
837
  @keyframes spin {
@@ -817,10 +846,11 @@ function CheckoutModal({
817
846
  position: "fixed",
818
847
  inset: 0,
819
848
  zIndex: 9998,
820
- backgroundColor: "rgba(0, 0, 0, 0.6)",
821
- backdropFilter: "blur(8px)"
849
+ backgroundColor: isBackdropVisible && !isClosing ? "rgba(0, 0, 0, 0.6)" : "rgba(0, 0, 0, 0)",
850
+ backdropFilter: isBackdropVisible && !isClosing ? "blur(8px)" : "blur(0px)",
851
+ transition: "background-color 250ms cubic-bezier(0.4, 0, 0.2, 1), backdrop-filter 250ms cubic-bezier(0.4, 0, 0.2, 1)"
822
852
  },
823
- onClick: onClose
853
+ onClick: handleAnimatedClose
824
854
  }
825
855
  ),
826
856
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
@@ -833,9 +863,10 @@ function CheckoutModal({
833
863
  display: "flex",
834
864
  alignItems: "center",
835
865
  justifyContent: "center",
836
- padding: "1rem"
866
+ padding: "1rem",
867
+ pointerEvents: isClosing ? "none" : "auto"
837
868
  },
838
- onClick: onClose,
869
+ onClick: handleAnimatedClose,
839
870
  children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
840
871
  "div",
841
872
  {
@@ -845,7 +876,10 @@ function CheckoutModal({
845
876
  backgroundColor: "#2c2c2e",
846
877
  borderRadius: "1rem",
847
878
  overflow: "hidden",
848
- boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.5)"
879
+ boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.5)",
880
+ opacity: isModalVisible && !isClosing ? 1 : 0,
881
+ transform: isModalVisible && !isClosing ? "translateY(0) scale(1)" : "translateY(-20px) scale(0.98)",
882
+ transition: "opacity 200ms cubic-bezier(0.4, 0, 0.2, 1), transform 250ms cubic-bezier(0.4, 0, 0.2, 1)"
849
883
  },
850
884
  onClick: (e) => e.stopPropagation(),
851
885
  children: [
@@ -897,7 +931,7 @@ function CheckoutModal({
897
931
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
898
932
  "button",
899
933
  {
900
- onClick: onClose,
934
+ onClick: handleAnimatedClose,
901
935
  style: {
902
936
  padding: "0.375rem 0.75rem",
903
937
  fontSize: "0.8125rem",