@getpara/react-sdk-lite 2.0.0-dev.7 → 2.1.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.
Files changed (172) hide show
  1. package/dist/cli/cli.mjs +26 -1
  2. package/dist/modal/ParaModal.js +16 -10
  3. package/dist/modal/components/Account/Account.js +42 -4
  4. package/dist/modal/components/Account/AccountHeader.js +13 -16
  5. package/dist/modal/components/Account/AccountProfile.d.ts +1 -1
  6. package/dist/modal/components/Account/AccountProfile.js +82 -210
  7. package/dist/modal/components/Account/AccountProfileEntry.d.ts +12 -0
  8. package/dist/modal/components/Account/AccountProfileEntry.js +228 -0
  9. package/dist/modal/components/Account/AccountProfileLinkOptions.js +15 -4
  10. package/dist/modal/components/Account/AccountSend/AccountSendAsset.d.ts +1 -0
  11. package/dist/modal/components/Account/AccountSend/AccountSendAsset.js +94 -0
  12. package/dist/modal/components/Account/AccountSend/AccountSendForm.d.ts +1 -0
  13. package/dist/modal/components/Account/AccountSend/AccountSendForm.js +343 -0
  14. package/dist/modal/components/Account/AccountSend/AccountSendNetwork.d.ts +1 -0
  15. package/dist/modal/components/Account/AccountSend/AccountSendNetwork.js +53 -0
  16. package/dist/modal/components/Account/AccountSend/AccountSendNoAssets.d.ts +1 -0
  17. package/dist/modal/components/Account/AccountSend/AccountSendNoAssets.js +56 -0
  18. package/dist/modal/components/Account/AccountSend/AssetNetwork.d.ts +5 -0
  19. package/dist/modal/components/Account/AccountSend/AssetNetwork.js +36 -0
  20. package/dist/modal/components/Account/AccountSend/context.d.ts +38 -0
  21. package/dist/modal/components/Account/AccountSend/context.js +418 -0
  22. package/dist/modal/components/Account/AccountSend/index.d.ts +4 -0
  23. package/dist/modal/components/Account/AccountSend/index.js +67 -0
  24. package/dist/modal/components/Account/AccountWallet.d.ts +1 -0
  25. package/dist/modal/components/Account/AccountWallet.js +134 -0
  26. package/dist/modal/components/{WalletSelect/WalletSelect.d.ts → Account/AccountWalletSelect.d.ts} +1 -1
  27. package/dist/modal/components/{WalletSelect/WalletSelect.js → Account/AccountWalletSelect.js} +20 -6
  28. package/dist/modal/components/AddFunds/AddFunds.js +3 -2
  29. package/dist/modal/components/AddFunds/AddFundsAsset.js +7 -6
  30. package/dist/modal/components/AddFunds/AddFundsContext.d.ts +5 -5
  31. package/dist/modal/components/AddFunds/AddFundsProvider.js +1 -2
  32. package/dist/modal/components/AddFunds/AddFundsSettings.js +13 -54
  33. package/dist/modal/components/AddFunds/common.d.ts +0 -14
  34. package/dist/modal/components/AddFunds/common.js +1 -8
  35. package/dist/modal/components/AuthInput/AuthInput.js +2 -2
  36. package/dist/modal/components/AwaitingAccountStep/AwaitingAccountStep.js +3 -2
  37. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +8 -33
  38. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +5 -2
  39. package/dist/modal/components/Body/Body.js +81 -48
  40. package/dist/modal/components/ChainSwitch/ChainSwitch.js +8 -5
  41. package/dist/modal/components/Controls/ChainSelect.js +1 -2
  42. package/dist/modal/components/Controls/Controls.js +3 -1
  43. package/dist/modal/components/ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.d.ts +5 -1
  44. package/dist/modal/components/ExternalWalletNetworkSelectStep/ExternalWalletNetworkSelectStep.js +48 -19
  45. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +5 -2
  46. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +63 -33
  47. package/dist/modal/components/ExternalWallets/ExternalWallets.d.ts +3 -1
  48. package/dist/modal/components/ExternalWallets/ExternalWallets.js +22 -12
  49. package/dist/modal/components/Footer/Footer.js +4 -5
  50. package/dist/modal/components/Header/Header.js +1 -2
  51. package/dist/modal/components/Header/hooks/useStepTitle.js +53 -38
  52. package/dist/modal/components/Hero/Hero.js +5 -3
  53. package/dist/modal/components/IFrameStep/IFrameStep.js +13 -12
  54. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +4 -1
  55. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +6 -5
  56. package/dist/modal/components/OAuth/TelegramOAuthStep.js +6 -5
  57. package/dist/modal/components/OnRampComponents/AddingFunds.js +1 -1
  58. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +1 -2
  59. package/dist/modal/components/QuantityInput.d.ts +9 -0
  60. package/dist/modal/components/QuantityInput.js +91 -0
  61. package/dist/modal/components/SearchableButtonList.d.ts +34 -0
  62. package/dist/modal/components/SearchableButtonList.js +223 -0
  63. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +4 -1
  64. package/dist/modal/components/SwitchWalletsStep/SwitchWalletsStep.d.ts +1 -0
  65. package/dist/modal/components/SwitchWalletsStep/SwitchWalletsStep.js +10 -0
  66. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +13 -2
  67. package/dist/modal/components/Waiting/Waiting.d.ts +1 -1
  68. package/dist/modal/components/Waiting/Waiting.js +7 -2
  69. package/dist/modal/components/WalletCard/WalletCard.js +2 -3
  70. package/dist/modal/components/WalletSelectOld/WalletSelectOld.d.ts +7 -1
  71. package/dist/modal/components/WalletSelectOld/WalletSelectOld.js +33 -12
  72. package/dist/modal/components/common.d.ts +8 -10
  73. package/dist/modal/components/common.js +16 -36
  74. package/dist/modal/hooks/index.d.ts +4 -0
  75. package/dist/modal/hooks/index.js +5 -0
  76. package/dist/modal/hooks/useDebounce.d.ts +4 -0
  77. package/dist/modal/hooks/useDebounce.js +16 -0
  78. package/dist/modal/hooks/useFarcasterLogin.js +8 -1
  79. package/dist/modal/hooks/useTelegramLogin.js +4 -0
  80. package/dist/modal/index.d.ts +1 -1
  81. package/dist/modal/index.js +1 -1
  82. package/dist/modal/stores/modal/actions.js +9 -2
  83. package/dist/modal/stores/modal/useModalStore.d.ts +9 -1
  84. package/dist/modal/stores/modal/useModalStore.js +6 -2
  85. package/dist/modal/types/modalProps.d.ts +5 -1
  86. package/dist/modal/utils/authInputHelpers.js +1 -1
  87. package/dist/modal/utils/countryCodes.js +50 -1
  88. package/dist/modal/utils/getWalletDisplayName.js +1 -1
  89. package/dist/modal/utils/openPopup.d.ts +1 -1
  90. package/dist/modal/utils/openPopup.js +6 -2
  91. package/dist/modal/utils/renderTextWithLinks.d.ts +2 -0
  92. package/dist/modal/utils/renderTextWithLinks.js +34 -0
  93. package/dist/modal/utils/steps.d.ts +24 -3
  94. package/dist/modal/utils/steps.js +51 -5
  95. package/dist/modal/utils/stringFormatters.d.ts +2 -3
  96. package/dist/modal/utils/stringFormatters.js +11 -7
  97. package/dist/modal/utils/validatePortalOrigin.d.ts +2 -0
  98. package/dist/modal/utils/validatePortalOrigin.js +15 -0
  99. package/dist/provider/ParaProviderMin.js +13 -5
  100. package/dist/provider/actions/getEmbeddedAccount.d.ts +3 -2
  101. package/dist/provider/actions/getEmbeddedAccount.js +13 -4
  102. package/dist/provider/actions/index.d.ts +11 -9
  103. package/dist/provider/actions/index.js +4 -0
  104. package/dist/provider/components/CosmosWalletWrapper.js +3 -3
  105. package/dist/provider/components/EvmWalletWrapper.js +3 -3
  106. package/dist/provider/components/ExternalWalletWrapper.js +7 -1
  107. package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +3 -1
  108. package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +3 -1
  109. package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +3 -1
  110. package/dist/provider/hooks/mutations/index.d.ts +2 -0
  111. package/dist/provider/hooks/mutations/index.js +4 -0
  112. package/dist/provider/hooks/mutations/useAddAuthMethod.d.ts +42 -0
  113. package/dist/provider/hooks/mutations/useAddAuthMethod.js +57 -0
  114. package/dist/provider/hooks/mutations/useClaimPregenWallets.d.ts +2 -2
  115. package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +2 -2
  116. package/dist/provider/hooks/mutations/useCreatePregenWallet.d.ts +5 -5
  117. package/dist/provider/hooks/mutations/useCreatePregenWalletPerType.d.ts +2 -2
  118. package/dist/provider/hooks/mutations/useCreateWallet.d.ts +2 -2
  119. package/dist/provider/hooks/mutations/useCreateWalletPerType.d.ts +2 -2
  120. package/dist/provider/hooks/mutations/useEnable2fa.d.ts +2 -2
  121. package/dist/provider/hooks/mutations/useExportPrivateKey.d.ts +15 -0
  122. package/dist/provider/hooks/mutations/useExportPrivateKey.js +32 -0
  123. package/dist/provider/hooks/mutations/useHasPregenWallet.d.ts +2 -2
  124. package/dist/provider/hooks/mutations/useIssueJwt.d.ts +2 -2
  125. package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +2 -2
  126. package/dist/provider/hooks/mutations/useLoginExternalWallet.d.ts +8 -2
  127. package/dist/provider/hooks/mutations/useLogout.d.ts +2 -2
  128. package/dist/provider/hooks/mutations/useResendVerificationCode.d.ts +2 -2
  129. package/dist/provider/hooks/mutations/useSetup2fa.d.ts +2 -2
  130. package/dist/provider/hooks/mutations/useSignMessage.d.ts +2 -2
  131. package/dist/provider/hooks/mutations/useSignTransaction.d.ts +2 -2
  132. package/dist/provider/hooks/mutations/useSignUpOrLogIn.d.ts +2 -2
  133. package/dist/provider/hooks/mutations/useSwitchWallets.d.ts +57 -0
  134. package/dist/provider/hooks/mutations/useSwitchWallets.js +30 -0
  135. package/dist/provider/hooks/mutations/useUpdatePregenWalletIdentifier.d.ts +2 -2
  136. package/dist/provider/hooks/mutations/useVerify2fa.d.ts +2 -2
  137. package/dist/provider/hooks/mutations/useVerifyExternalWallet.d.ts +18 -27
  138. package/dist/provider/hooks/mutations/useVerifyFarcaster.d.ts +5 -5
  139. package/dist/provider/hooks/mutations/useVerifyNewAccount.d.ts +14 -11
  140. package/dist/provider/hooks/mutations/useVerifyOAuth.d.ts +2 -2
  141. package/dist/provider/hooks/mutations/useVerifyTelegram.d.ts +5 -5
  142. package/dist/provider/hooks/mutations/useWaitForLogin.d.ts +2 -2
  143. package/dist/provider/hooks/mutations/useWaitForSignup.d.ts +2 -2
  144. package/dist/provider/hooks/mutations/useWaitForWalletCreation.d.ts +2 -2
  145. package/dist/provider/hooks/queries/index.d.ts +1 -0
  146. package/dist/provider/hooks/queries/index.js +2 -0
  147. package/dist/provider/hooks/queries/useAccount.js +58 -24
  148. package/dist/provider/hooks/queries/useLinkedAccounts.js +4 -2
  149. package/dist/provider/hooks/queries/useProfileBalance.d.ts +29 -0
  150. package/dist/provider/hooks/queries/useProfileBalance.js +65 -0
  151. package/dist/provider/hooks/utils/useAssetInfo.d.ts +3 -0
  152. package/dist/provider/hooks/utils/useAssetInfo.js +21 -0
  153. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +1 -1
  154. package/dist/provider/hooks/utils/useEventListeners.js +22 -5
  155. package/dist/provider/hooks/utils/useModal.js +3 -3
  156. package/dist/provider/hooks/utils/useWalletState.d.ts +2 -1
  157. package/dist/provider/hooks/utils/useWalletState.js +2 -1
  158. package/dist/provider/providers/AccountLinkProvider.js +18 -11
  159. package/dist/provider/providers/AssetsProvider.d.ts +14 -0
  160. package/dist/provider/providers/AssetsProvider.js +68 -0
  161. package/dist/provider/providers/AuthProvider.d.ts +4 -0
  162. package/dist/provider/providers/AuthProvider.js +187 -43
  163. package/dist/provider/providers/ExternalWalletProvider.d.ts +19 -5
  164. package/dist/provider/providers/ExternalWalletProvider.js +363 -44
  165. package/dist/provider/stores/getters.d.ts +2 -2
  166. package/dist/provider/stores/slices/modal.js +4 -1
  167. package/dist/provider/stores/types.d.ts +6 -3
  168. package/package.json +8 -8
  169. package/dist/modal/constants/constants.d.ts +0 -35
  170. package/dist/modal/constants/constants.js +0 -148
  171. package/dist/modal/utils/routeMobileExternalWallet.d.ts +0 -1
  172. package/dist/modal/utils/routeMobileExternalWallet.js +0 -31
@@ -5,17 +5,17 @@ import { useEffect, useState } from "react";
5
5
  import { useModalStore } from "../../stores/index.js";
6
6
  import { IFrameSteps } from "../../utils/steps.js";
7
7
  import { safeStyled } from "@getpara/react-common";
8
- import { SpinnerContainer } from "@getpara/react-common";
8
+ import { SpinnerContainer, MOBILE_SIZE } from "@getpara/react-common";
9
9
  import { CpslSpinner } from "@getpara/react-components";
10
- import { getPortalBaseURL } from "@getpara/web-sdk";
11
- import { MOBILE_SIZE } from "../../constants/constants.js";
12
10
  import { useStore } from "../../../provider/stores/useStore.js";
13
11
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
12
+ import { validatePortalOrigin } from "../../utils/validatePortalOrigin.js";
14
13
  const IFrameStep = () => {
15
14
  const iFrameUrl = useModalStore((state) => state.iFrameUrl);
16
15
  const setIsReady = useModalStore((state) => state.setIsIFrameReady);
17
16
  const isReady = useModalStore((state) => state.isIFrameReady);
18
17
  const currentStep = useModalStore((state) => state.step);
18
+ const refs = useModalStore((state) => state.refs);
19
19
  const embeddedModal = useStore((state) => {
20
20
  var _a;
21
21
  return (_a = state.modalConfig) == null ? void 0 : _a.embeddedModal;
@@ -32,22 +32,23 @@ const IFrameStep = () => {
32
32
  if (!iFrameUrl) {
33
33
  return;
34
34
  }
35
- const portalBase = getPortalBaseURL(para.ctx);
36
- if (!event.origin.startsWith(portalBase)) {
35
+ if (!validatePortalOrigin(event, para.ctx)) {
37
36
  return;
38
37
  }
39
38
  if (event.data) {
40
- if (event.data.type === "HEIGHT") {
41
- setHeight(event.data.height);
42
- setIsReady(true);
39
+ if (event.data.type === "HEIGHT" && typeof event.data.height === "number") {
40
+ setHeight(Math.max(event.data.height, 200));
41
+ setIsReady(event.data.height > 0 ? true : false);
43
42
  }
44
43
  }
45
44
  };
46
- window.addEventListener("message", handleMessage);
47
- return () => window.removeEventListener("message", handleMessage);
45
+ typeof window !== "undefined" && window.addEventListener("message", handleMessage);
46
+ return () => {
47
+ typeof window !== "undefined" && window.removeEventListener("message", handleMessage);
48
+ };
48
49
  }, [setIsReady, iFrameUrl]);
49
50
  return /* @__PURE__ */ jsxs(OuterContainer, { $isVisible: IFrameSteps.includes(currentStep), $embeddedModal: !!embeddedModal, $isReady: !!isReady, children: [
50
- /* @__PURE__ */ jsx(Container, { $isReady: !!isReady, $height: height, children: /* @__PURE__ */ jsx("iframe", { src: iFrameUrl }) }),
51
+ /* @__PURE__ */ jsx(Container, { $isReady: !!isReady, $height: height, children: /* @__PURE__ */ jsx("iframe", { src: iFrameUrl, ref: refs.iFrame }) }),
51
52
  !isReady && /* @__PURE__ */ jsx(SpinnerContainer, { style: { width: "100%", height: "100%", flex: 1, position: "absolute" }, children: /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) })
52
53
  ] });
53
54
  };
@@ -62,7 +63,7 @@ const OuterContainer = safeStyled.div`
62
63
  justify-content: center;
63
64
 
64
65
  @media (max-width: ${MOBILE_SIZE}px) {
65
- padding: ${({ $embeddedModal, $isVisible }) => !$isVisible ? "0px" : $embeddedModal ? "12px 0px 0px" : "72px 16px 0px"};
66
+ padding: ${({ $embeddedModal, $isVisible }) => !$isVisible ? "0px" : $embeddedModal ? "12px 0px 0px" : "0px"};
66
67
  }
67
68
  `;
68
69
  const Container = safeStyled.div`
@@ -30,7 +30,7 @@ const LoginDoneStep = ({ onClose }) => {
30
30
  return /* @__PURE__ */ jsx(WalletCard, { id, type, showAddFunds: false }, `${id}-${type}`);
31
31
  }, [para.externalWalletConnectionType, para.externalWallets, para.wallets]);
32
32
  useEffect(() => {
33
- setTimeout(() => {
33
+ const timerId = setTimeout(() => {
34
34
  if (bareModal) {
35
35
  setFlow("account");
36
36
  setStep(ModalStep.ACCOUNT_MAIN);
@@ -38,6 +38,9 @@ const LoginDoneStep = ({ onClose }) => {
38
38
  onClose();
39
39
  }
40
40
  }, 1600);
41
+ return () => {
42
+ clearTimeout(timerId);
43
+ };
41
44
  }, []);
42
45
  return /* @__PURE__ */ jsxs(StepContainer, { children: [
43
46
  /* @__PURE__ */ jsx(HeroIcon, { icon: "checkCircleFilled" }),
@@ -5,8 +5,8 @@ import { CpslSpinner } from "@getpara/react-components";
5
5
  import { useFarcasterLogin } from "../../hooks/useFarcasterLogin.js";
6
6
  import { safeStyled } from "@getpara/react-common";
7
7
  import { useEffect, useState } from "react";
8
- import { getPortalBaseURL } from "@getpara/web-sdk";
9
8
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
9
+ import { validatePortalOrigin } from "../../utils/validatePortalOrigin.js";
10
10
  function FarcasterOAuthStep() {
11
11
  const { url, isLoaded, setIsLoaded } = useFarcasterLogin({
12
12
  isActive: true
@@ -18,8 +18,7 @@ function FarcasterOAuthStep() {
18
18
  if (!url) {
19
19
  return;
20
20
  }
21
- const portalBase = getPortalBaseURL(para.ctx);
22
- if (!event.origin.startsWith(portalBase)) {
21
+ if (!validatePortalOrigin(event, para.ctx)) {
23
22
  return;
24
23
  }
25
24
  if (event.data) {
@@ -28,8 +27,10 @@ function FarcasterOAuthStep() {
28
27
  }
29
28
  }
30
29
  };
31
- window.addEventListener("message", handleMessage);
32
- return () => window.removeEventListener("message", handleMessage);
30
+ typeof window !== "undefined" && window.addEventListener("message", handleMessage);
31
+ return () => {
32
+ typeof window !== "undefined" && window.removeEventListener("message", handleMessage);
33
+ };
33
34
  }, [url]);
34
35
  return /* @__PURE__ */ jsxs(Container, { children: [
35
36
  url && /* @__PURE__ */ jsx(IFrame, { style: { display: isLoaded ? "block" : "none", height }, src: url, onLoad: () => setIsLoaded(true) }),
@@ -7,8 +7,8 @@ import { useTelegramLogin } from "../../hooks/useTelegramLogin.js";
7
7
  import { useEffect, useState } from "react";
8
8
  import { useAuthActions } from "../../../provider/providers/AuthProvider.js";
9
9
  import { useModalStore } from "../../stores/index.js";
10
- import { getPortalBaseURL } from "@getpara/web-sdk";
11
10
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
11
+ import { validatePortalOrigin } from "../../utils/validatePortalOrigin.js";
12
12
  function TelegramOAuthStep() {
13
13
  const { verifyTelegramStatus, verifyTelegram } = useAuthActions();
14
14
  const { url, isLoaded, setIsLoaded } = useTelegramLogin({
@@ -25,8 +25,7 @@ function TelegramOAuthStep() {
25
25
  if (!url) {
26
26
  return;
27
27
  }
28
- const portalBase = getPortalBaseURL(para.ctx, true);
29
- if (!event.origin.startsWith(portalBase)) {
28
+ if (!validatePortalOrigin(event, para.ctx)) {
30
29
  return;
31
30
  }
32
31
  if (event.data) {
@@ -35,8 +34,10 @@ function TelegramOAuthStep() {
35
34
  }
36
35
  }
37
36
  };
38
- window.addEventListener("message", handleMessage);
39
- return () => window.removeEventListener("message", handleMessage);
37
+ typeof window !== "undefined" && window.addEventListener("message", handleMessage);
38
+ return () => {
39
+ typeof window !== "undefined" && window.removeEventListener("message", handleMessage);
40
+ };
40
41
  }, [url]);
41
42
  return /* @__PURE__ */ jsxs(Container, { children: [
42
43
  url && /* @__PURE__ */ jsx(
@@ -3,7 +3,7 @@ import "../../../chunk-MMUBH76A.js";
3
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
4
  import { OnRampPurchaseStatus } from "@getpara/web-sdk";
5
5
  import { SpinnerContainer } from "../common.js";
6
- import { ON_RAMP_PROVIDERS } from "../../constants/constants.js";
6
+ import { ON_RAMP_PROVIDERS } from "@getpara/react-common";
7
7
  import { useModalStore } from "../../stores/index.js";
8
8
  import { CpslSpinner, CpslText } from "@getpara/react-components";
9
9
  const AddingFunds = () => {
@@ -4,8 +4,7 @@ import {
4
4
  } from "../../../chunk-MMUBH76A.js";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  import { useState } from "react";
7
- import { ON_RAMP_PROVIDERS } from "../../constants/constants.js";
8
- import { safeStyled } from "@getpara/react-common";
7
+ import { safeStyled, ON_RAMP_PROVIDERS } from "@getpara/react-common";
9
8
  import { CpslButton, CpslIcon, CpslSpinner, CpslText } from "@getpara/react-components";
10
9
  import { motion } from "framer-motion";
11
10
  const OnRampProviderButton = ({ config, index, onClick: _onClick }) => {
@@ -0,0 +1,9 @@
1
+ export declare function QuantityInput({ value, onChange, onFocus, onBlur, placeholder, size, symbol, }: {
2
+ value: string | null;
3
+ onFocus?: () => void;
4
+ onBlur?: () => void;
5
+ onChange: (_: string | null) => void;
6
+ placeholder?: string;
7
+ size?: string;
8
+ symbol?: string;
9
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,91 @@
1
+ "use client";
2
+ import "../../chunk-MMUBH76A.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { safeStyled } from "@getpara/react-common";
5
+ function QuantityInput({
6
+ value,
7
+ onChange,
8
+ onFocus,
9
+ onBlur,
10
+ placeholder,
11
+ size = "72px",
12
+ symbol
13
+ }) {
14
+ return /* @__PURE__ */ jsxs(Container, { style: { fontSize: size, position: "relative" }, children: [
15
+ symbol && /* @__PURE__ */ jsx(CurrencySign, { slot: "start", children: symbol }),
16
+ /* @__PURE__ */ jsx(
17
+ Input,
18
+ {
19
+ value: value != null ? value : "",
20
+ onFocus: (e) => {
21
+ e.currentTarget.select();
22
+ onFocus == null ? void 0 : onFocus();
23
+ },
24
+ onKeyDown: (e) => {
25
+ if (!/^(\d|\.)$/.test(e.key) && !["Delete", "Backspace", "Tab", "Shift", "ArrowLeft", "ArrowRight", "Home", "End"].includes(e.key)) {
26
+ e.preventDefault();
27
+ }
28
+ },
29
+ onChange: (e) => {
30
+ const rawValue = e.currentTarget.value;
31
+ if (rawValue === "") {
32
+ onChange(null);
33
+ return;
34
+ }
35
+ const numericValue = rawValue.replace(/[^0-9.]/g, "");
36
+ if (numericValue === "") {
37
+ onChange(null);
38
+ return;
39
+ }
40
+ const isValidNumberFormat = /^\d*\.?\d*$/.test(numericValue);
41
+ if (isValidNumberFormat) {
42
+ onChange(numericValue);
43
+ } else {
44
+ onChange(null);
45
+ }
46
+ },
47
+ onBlur: (e) => {
48
+ const numericValue = (e.currentTarget.value || "").replace(/[^0-9.]/g, "");
49
+ if (numericValue === "") {
50
+ onChange(null);
51
+ } else {
52
+ const parsed = parseFloat(numericValue);
53
+ if (!isNaN(parsed)) {
54
+ onChange(parsed.toString());
55
+ } else {
56
+ onChange(null);
57
+ }
58
+ }
59
+ onBlur == null ? void 0 : onBlur();
60
+ },
61
+ placeholder: placeholder || "0"
62
+ }
63
+ )
64
+ ] });
65
+ }
66
+ const Container = safeStyled.div`
67
+ display: flex;
68
+ align-items: center;
69
+ justify-content: center;
70
+ font-family: var(--cpsl-font-family);
71
+ color: var(--cpsl-color-text-primary);
72
+ `;
73
+ const CurrencySign = safeStyled.div`
74
+ position: relative;
75
+ left: 0px;
76
+ `;
77
+ const Input = safeStyled.input`
78
+ font-family: var(--cpsl-font-family);
79
+ font-size: inherit;
80
+ color: inherit;
81
+ background-color: transparent;
82
+ height: auto;
83
+ border-width: 0;
84
+ text-align: center;
85
+ width: 100%;
86
+ outline: none;
87
+ field-sizing: content;
88
+ `;
89
+ export {
90
+ QuantityInput
91
+ };
@@ -0,0 +1,34 @@
1
+ import { ReactNode } from 'react';
2
+ type AssetItem = {
3
+ key: string;
4
+ icon: ReactNode;
5
+ text: ReactNode;
6
+ textSecondary?: ReactNode;
7
+ endText?: ReactNode;
8
+ endTextSecondary?: ReactNode;
9
+ };
10
+ export declare const contentMotionProps: {
11
+ transition: {
12
+ duration: number;
13
+ };
14
+ initial: {
15
+ opacity: number;
16
+ };
17
+ animate: {
18
+ opacity: number;
19
+ };
20
+ exit: {
21
+ opacity: number;
22
+ };
23
+ };
24
+ export declare function SearchableButtonList<T>({ items, transformItem, searchFilter, searchPlaceholder, onSelect, }: {
25
+ items: T[];
26
+ transformItem: (_: T) => AssetItem;
27
+ searchFilter?: (_: {
28
+ item: T;
29
+ searchStr: string;
30
+ }) => boolean;
31
+ searchPlaceholder?: string;
32
+ onSelect: (_: T) => void;
33
+ }): import("react/jsx-runtime").JSX.Element;
34
+ export {};
@@ -0,0 +1,223 @@
1
+ "use client";
2
+ import {
3
+ __spreadProps,
4
+ __spreadValues
5
+ } from "../../chunk-MMUBH76A.js";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import * as comp from "@getpara/react-components";
8
+ import { safeStyled } from "@getpara/react-common";
9
+ import { useState, useMemo, useRef, useEffect } from "react";
10
+ import { GradientScroll } from "./common.js";
11
+ import { AnimatePresence, motion } from "framer-motion";
12
+ const contentMotionProps = {
13
+ transition: { duration: 0.2 },
14
+ initial: { opacity: 0 },
15
+ animate: { opacity: 1 },
16
+ exit: { opacity: 0 }
17
+ };
18
+ const ESTIMATED_ITEM_HEIGHT = 72;
19
+ const VISIBILITY_BUFFER = 3;
20
+ function SearchableButtonList({
21
+ items,
22
+ transformItem,
23
+ searchFilter,
24
+ searchPlaceholder = "Search for an asset",
25
+ onSelect
26
+ }) {
27
+ const [searchStr, setSearchStr] = useState("");
28
+ const outerContainerRef = useRef(null);
29
+ const scrollContainerRef = useRef(null);
30
+ const [scrollTop, setScrollTop] = useState(0);
31
+ const [containerHeight, setContainerHeight] = useState(0);
32
+ const [contentHeight, setContentHeight] = useState(0);
33
+ const [renderedRange, setRenderedRange] = useState({ start: 0, end: 0 });
34
+ const transformedAndFiltered = useMemo(() => {
35
+ return items.filter((item) => !searchFilter || searchFilter({ item, searchStr })).map((item) => ({
36
+ assetItem: transformItem(item),
37
+ originalItem: item
38
+ }));
39
+ }, [items, searchFilter, searchStr, transformItem]);
40
+ useEffect(() => {
41
+ setRenderedRange({ start: 0, end: 0 });
42
+ }, [items, searchStr]);
43
+ const desiredRange = useMemo(() => {
44
+ if (containerHeight === 0) {
45
+ return { start: 0, end: transformedAndFiltered.length };
46
+ }
47
+ const startIndex = Math.max(0, Math.floor(scrollTop / ESTIMATED_ITEM_HEIGHT) - VISIBILITY_BUFFER);
48
+ const endIndex = Math.min(
49
+ transformedAndFiltered.length,
50
+ Math.ceil((scrollTop + containerHeight) / ESTIMATED_ITEM_HEIGHT) + VISIBILITY_BUFFER
51
+ );
52
+ return { start: startIndex, end: endIndex };
53
+ }, [scrollTop, containerHeight, transformedAndFiltered.length]);
54
+ useEffect(() => {
55
+ setRenderedRange((prev) => ({
56
+ start: Math.min(desiredRange.start, prev.start),
57
+ end: Math.max(desiredRange.end, prev.end)
58
+ }));
59
+ }, [desiredRange]);
60
+ const visibleRange = renderedRange;
61
+ const visibleItems = useMemo(() => {
62
+ return transformedAndFiltered.slice(visibleRange.start, visibleRange.end);
63
+ }, [transformedAndFiltered, visibleRange.start, visibleRange.end]);
64
+ useEffect(() => {
65
+ var _a, _b;
66
+ const container = (_b = (_a = scrollContainerRef.current) == null ? void 0 : _a.parentElement) == null ? void 0 : _b.parentElement;
67
+ if (!container) return;
68
+ const updateDimensions = () => {
69
+ setContainerHeight(container.clientHeight);
70
+ setContentHeight(container.scrollHeight);
71
+ };
72
+ let scrollTimeout;
73
+ const handleScroll = () => {
74
+ if (scrollTimeout) {
75
+ cancelAnimationFrame(scrollTimeout);
76
+ }
77
+ scrollTimeout = requestAnimationFrame(() => {
78
+ setScrollTop(container.scrollTop);
79
+ });
80
+ };
81
+ updateDimensions();
82
+ container.addEventListener("scroll", handleScroll, { passive: true });
83
+ const resizeObserver = new ResizeObserver(updateDimensions);
84
+ resizeObserver.observe(container);
85
+ const contentDiv = scrollContainerRef.current;
86
+ if (contentDiv) {
87
+ const contentResizeObserver = new ResizeObserver(updateDimensions);
88
+ contentResizeObserver.observe(contentDiv);
89
+ return () => {
90
+ if (scrollTimeout) {
91
+ cancelAnimationFrame(scrollTimeout);
92
+ }
93
+ container.removeEventListener("scroll", handleScroll);
94
+ resizeObserver.disconnect();
95
+ contentResizeObserver.disconnect();
96
+ };
97
+ }
98
+ return () => {
99
+ if (scrollTimeout) {
100
+ cancelAnimationFrame(scrollTimeout);
101
+ }
102
+ container.removeEventListener("scroll", handleScroll);
103
+ resizeObserver.disconnect();
104
+ };
105
+ }, []);
106
+ const paddingTop = visibleRange.start * ESTIMATED_ITEM_HEIGHT;
107
+ const paddingBottom = Math.max(0, (transformedAndFiltered.length - visibleRange.end) * ESTIMATED_ITEM_HEIGHT);
108
+ const MAX_CONTAINER_HEIGHT = 480;
109
+ useEffect(() => {
110
+ var _a, _b;
111
+ const container = (_b = (_a = scrollContainerRef.current) == null ? void 0 : _a.parentElement) == null ? void 0 : _b.parentElement;
112
+ if (container) {
113
+ requestAnimationFrame(() => {
114
+ setContentHeight(container.scrollHeight);
115
+ });
116
+ }
117
+ }, [visibleRange.start, visibleRange.end, transformedAndFiltered.length]);
118
+ const outerContainerHeight = useMemo(() => {
119
+ if (contentHeight === 0) {
120
+ return MAX_CONTAINER_HEIGHT;
121
+ }
122
+ const searchInputHeight = items.length >= 4 && !!searchFilter ? 56 : 0;
123
+ const totalNeededHeight = contentHeight + searchInputHeight;
124
+ if (totalNeededHeight < MAX_CONTAINER_HEIGHT) {
125
+ return totalNeededHeight + 4;
126
+ }
127
+ return MAX_CONTAINER_HEIGHT;
128
+ }, [contentHeight, items.length, searchFilter]);
129
+ return /* @__PURE__ */ jsxs(
130
+ "div",
131
+ {
132
+ ref: outerContainerRef,
133
+ style: {
134
+ display: "flex",
135
+ flexDirection: "column",
136
+ height: `${outerContainerHeight}px`,
137
+ maxHeight: `${MAX_CONTAINER_HEIGHT}px`,
138
+ overflow: "hidden"
139
+ },
140
+ children: [
141
+ items.length >= 4 && !!searchFilter && /* @__PURE__ */ jsx(
142
+ SearchInput,
143
+ {
144
+ placeholder: searchPlaceholder,
145
+ value: searchStr,
146
+ onCpslInput: (e) => {
147
+ setSearchStr(e.detail.value);
148
+ },
149
+ style: { marginBottom: "8px" },
150
+ children: /* @__PURE__ */ jsx(comp.CpslIcon, { icon: "search", slot: "start" })
151
+ }
152
+ ),
153
+ /* @__PURE__ */ jsx(GradientScroll, { height: "100%", gap: "8px", children: /* @__PURE__ */ jsx("div", { ref: scrollContainerRef, children: /* @__PURE__ */ jsx(List, { style: { paddingTop, paddingBottom }, children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "sync", children: visibleItems.map(({ assetItem, originalItem }) => {
154
+ const { key, icon, text, textSecondary, endText, endTextSecondary } = assetItem;
155
+ return /* @__PURE__ */ jsx(motion.li, __spreadProps(__spreadValues({ style: { width: "100%" } }, contentMotionProps), { children: /* @__PURE__ */ jsxs(AssetButton, { fullWidth: true, variant: "secondary", onClick: () => onSelect(originalItem), children: [
156
+ icon,
157
+ /* @__PURE__ */ jsxs(Info, { children: [
158
+ /* @__PURE__ */ jsx(Code, { color: "contrast", variant: "bodyL", children: text }),
159
+ textSecondary && /* @__PURE__ */ jsx(Name, { color: "contrast", variant: "bodyS", children: textSecondary })
160
+ ] }),
161
+ endText && /* @__PURE__ */ jsxs(End, { children: [
162
+ /* @__PURE__ */ jsx(EndText, { color: "primary", variant: "bodyM", children: endText }),
163
+ endTextSecondary && /* @__PURE__ */ jsx(EndTextSecondary, { color: "contrast", variant: "bodyS", children: endTextSecondary })
164
+ ] })
165
+ ] }) }), key);
166
+ }) }) }) }) })
167
+ ]
168
+ }
169
+ );
170
+ }
171
+ const List = safeStyled.ul`
172
+ display: flex;
173
+ flex-direction: column;
174
+ width: 100%;
175
+ gap: 8px;
176
+ list-style: none;
177
+ padding-inline-start: 0;
178
+ padding-inline-end: 0;
179
+ margin: 0;
180
+ `;
181
+ const AssetButton = safeStyled(comp.CpslButton)`
182
+ display: flex;
183
+ justify-content: center;
184
+ align-items: center;
185
+ gap: 8px;
186
+ --button-secondary-background-color: var(--cpsl-color-background-8);
187
+ --button-secondary-border-color: var(--cpsl-color-background-8);
188
+ --button-secondary-hover-background-color: var(--cpsl-color-background-16);
189
+ --button-secondary-hover-border-color: var(--cpsl-color-background-16);
190
+ `;
191
+ const Info = safeStyled(comp.CpslCol)`
192
+ text-align: left;
193
+ min-width: 0;
194
+ `, Code = comp.CpslText, Name = safeStyled(comp.CpslText)`
195
+ display: flex;
196
+ align-items: flex-start;
197
+ overflow: hidden;
198
+ text-overflow: ellipsis;
199
+ white-space: nowrap;
200
+ min-width: 0;
201
+ height: 20px;
202
+ `, EndText = safeStyled(comp.CpslText)`
203
+ overflow: hidden;
204
+ text-overflow: ellipsis;
205
+ white-space: nowrap;
206
+ min-width: 0;
207
+ `, EndTextSecondary = safeStyled(comp.CpslText)`
208
+ overflow: hidden;
209
+ `;
210
+ const End = safeStyled(comp.CpslCol)`
211
+ text-align: right;
212
+ align-items: flex-end;
213
+ gap: 4px;
214
+ min-width: 0;
215
+ `;
216
+ const SearchInput = safeStyled(comp.CpslInput)`
217
+ --container-background-color: var(--cpsl-color-background-8);
218
+ --input-background-color: transparent;
219
+ `;
220
+ export {
221
+ SearchableButtonList,
222
+ contentMotionProps
223
+ };
@@ -32,10 +32,13 @@ const Setup2FAStep = ({ onClose }) => {
32
32
  const params = (twoFactorStatus == null ? void 0 : twoFactorStatus.uri) ? new URL(twoFactorStatus.uri).searchParams : void 0;
33
33
  const secret = params == null ? void 0 : params.get("secret");
34
34
  useEffect(() => {
35
- setTimeout(() => {
35
+ const timerId = setTimeout(() => {
36
36
  var _a, _b, _c, _d;
37
37
  (_d = (_c = (_b = (_a = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a.shadowRoot) == null ? void 0 : _b.querySelectorAll("input")) == null ? void 0 : _c[0]) == null ? void 0 : _d.focus();
38
38
  }, 10);
39
+ return () => {
40
+ clearTimeout(timerId);
41
+ };
39
42
  }, [isVerifying]);
40
43
  useEffect(() => {
41
44
  if (code.length === 6) {
@@ -0,0 +1 @@
1
+ export declare const SwitchWalletsStep: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import "../../../chunk-MMUBH76A.js";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { Waiting } from "../Waiting/Waiting.js";
5
+ const SwitchWalletsStep = () => {
6
+ return /* @__PURE__ */ jsx(Waiting, { heading: "Switching Wallets", subheading: "Please complete the wallet selection in the popup window." });
7
+ };
8
+ export {
9
+ SwitchWalletsStep
10
+ };
@@ -13,16 +13,20 @@ import { useResendVerificationCode } from "../../../provider/index.js";
13
13
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
14
14
  const VerificationCode = ({ authInfo, onResend, onSubmit, status, error }) => {
15
15
  const inputRef = useRef(null);
16
+ const resendTimerRef = useRef();
16
17
  const [code, setCode] = useState("");
17
18
  const [isPending, setIsPending] = useState(status === "pending");
18
19
  const [codeError, setCodeError] = useState(null);
19
20
  const [resendDisabled, setResendDisabled] = useState(false);
20
21
  const isEmail = (authInfo == null ? void 0 : authInfo.authType) === "email";
21
22
  useEffect(() => {
22
- setTimeout(() => {
23
+ const timerId = setTimeout(() => {
23
24
  var _a, _b, _c, _d;
24
25
  (_d = (_c = (_b = (_a = inputRef.current) == null ? void 0 : _a.shadowRoot) == null ? void 0 : _b.querySelectorAll("input")) == null ? void 0 : _c[0]) == null ? void 0 : _d.focus();
25
26
  }, 10);
27
+ return () => {
28
+ clearTimeout(timerId);
29
+ };
26
30
  }, []);
27
31
  useEffect(() => {
28
32
  setCodeError(null);
@@ -41,12 +45,19 @@ const VerificationCode = ({ authInfo, onResend, onSubmit, status, error }) => {
41
45
  try {
42
46
  onResend();
43
47
  } finally {
44
- setTimeout(() => {
48
+ resendTimerRef.current = setTimeout(() => {
45
49
  setResendDisabled(false);
46
50
  }, 3e3);
47
51
  }
48
52
  }
49
53
  });
54
+ useEffect(() => {
55
+ return () => {
56
+ if (resendTimerRef.current) {
57
+ clearTimeout(resendTimerRef.current);
58
+ }
59
+ };
60
+ }, []);
50
61
  const handleCodeInput = (e) => {
51
62
  setCode(e.detail.value.trim());
52
63
  };
@@ -1,5 +1,5 @@
1
1
  interface WaitingProps {
2
- heading: string;
2
+ heading?: string;
3
3
  subheading?: string;
4
4
  }
5
5
  export declare const Waiting: ({ heading, subheading }: WaitingProps) => import("react/jsx-runtime").JSX.Element;
@@ -3,15 +3,20 @@ import "../../../chunk-MMUBH76A.js";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { CpslSpinner, CpslText } from "@getpara/react-components";
5
5
  import { Heading, SpinnerContainer, StepContainer, InnerStepContainer } from "../common.js";
6
+ import { safeStyled } from "@getpara/react-common";
6
7
  const Waiting = ({ heading, subheading }) => {
7
- return /* @__PURE__ */ jsxs(StepContainer, { $wide: true, children: [
8
+ return /* @__PURE__ */ jsxs(Container, { $wide: true, children: [
8
9
  /* @__PURE__ */ jsx(SpinnerContainer, { children: /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) }),
9
- /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
10
+ heading && /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
10
11
  /* @__PURE__ */ jsx(Heading, { children: heading }),
11
12
  subheading && /* @__PURE__ */ jsx(CpslText, { variant: "bodyS", color: "secondary", weight: "medium", children: subheading })
12
13
  ] })
13
14
  ] });
14
15
  };
16
+ const Container = safeStyled(StepContainer)`
17
+ flex: 1;
18
+ justify-content: space-between;
19
+ `;
15
20
  export {
16
21
  Waiting
17
22
  };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import "../../../chunk-MMUBH76A.js";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
- import { safeStyled } from "@getpara/react-common";
4
+ import { safeStyled, WalletTypeIcon } from "@getpara/react-common";
5
5
  import { useModalStore } from "../../stores/index.js";
6
6
  import { CpslButton, CpslIcon, CpslText } from "@getpara/react-components";
7
7
  import { truncateAddress } from "@getpara/web-sdk";
@@ -9,7 +9,6 @@ import { ModalStep } from "../../utils/steps.js";
9
9
  import { useWalletState } from "../../../provider/index.js";
10
10
  import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
11
11
  import { useStore } from "../../../provider/stores/useStore.js";
12
- import { WalletTypeIcon } from "../common.js";
13
12
  const ExternalWalletCard = ({
14
13
  address,
15
14
  showAddFunds
@@ -129,7 +128,7 @@ const WalletNameContainer = safeStyled.div`
129
128
  const Name = safeStyled(CpslText)`
130
129
  width: 100%;
131
130
  &::part(text-element) {
132
- line-height: 100%;
131
+ line-height: 150%;
133
132
  text-overflow: ellipsis;
134
133
  overflow: hidden;
135
134
  white-space: nowrap;