@swype-org/react-sdk 0.1.26 → 0.1.27

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
@@ -1,4 +1,4 @@
1
- import { createContext, useRef, useState, useCallback, useMemo, useContext, useEffect } from 'react';
1
+ import { createContext, useRef, useEffect, useState, useCallback, useMemo, useContext } from 'react';
2
2
  import { PrivyProvider, usePrivy } from '@privy-io/react-auth';
3
3
  import { createConfig, http, WagmiProvider, useConfig, useConnect, useSwitchChain } from 'wagmi';
4
4
  import { mainnet, arbitrum, base } from 'wagmi/chains';
@@ -74,6 +74,26 @@ var wagmiConfig = createConfig({
74
74
  [base.id]: http()
75
75
  }
76
76
  });
77
+ var PRIVY_MODAL_CENTER_CSS = `
78
+ @media (max-width: 440px) {
79
+ #privy-dialog [data-headlessui-state] {
80
+ position: static !important;
81
+ bottom: auto !important;
82
+ margin: auto !important;
83
+ width: 360px !important;
84
+ max-width: calc(100vw - 32px) !important;
85
+ box-shadow: 0px 8px 36px rgba(55, 65, 81, 0.15) !important;
86
+ border-radius: var(--privy-border-radius-lg) !important;
87
+ transform: none !important;
88
+ transition: opacity 100ms ease-in !important;
89
+ }
90
+ #privy-dialog [data-headlessui-state].entering,
91
+ #privy-dialog [data-headlessui-state].leaving {
92
+ opacity: 0 !important;
93
+ transform: none !important;
94
+ }
95
+ }
96
+ `;
77
97
  var SwypeContext = createContext(null);
78
98
  function SwypeProvider({
79
99
  apiBaseUrl,
@@ -84,6 +104,15 @@ function SwypeProvider({
84
104
  if (!queryClientRef.current) {
85
105
  queryClientRef.current = new QueryClient();
86
106
  }
107
+ useEffect(() => {
108
+ const style = document.createElement("style");
109
+ style.setAttribute("data-swype", "privy-modal-center");
110
+ style.textContent = PRIVY_MODAL_CENTER_CSS;
111
+ document.head.appendChild(style);
112
+ return () => {
113
+ style.remove();
114
+ };
115
+ }, []);
87
116
  const [depositAmount, setDepositAmountRaw] = useState(null);
88
117
  const setDepositAmount = useCallback((amount) => {
89
118
  setDepositAmountRaw(amount);
@@ -3022,7 +3051,7 @@ function SwypePayment({
3022
3051
  ]
3023
3052
  }
3024
3053
  ),
3025
- /* @__PURE__ */ jsxs(
3054
+ /* @__PURE__ */ jsx(
3026
3055
  "div",
3027
3056
  {
3028
3057
  style: {
@@ -3035,74 +3064,39 @@ function SwypePayment({
3035
3064
  border: `1px solid ${tokens.border}`,
3036
3065
  lineHeight: 1.7
3037
3066
  },
3038
- children: [
3039
- /* @__PURE__ */ jsxs(
3040
- "div",
3041
- {
3042
- style: { display: "flex", justifyContent: "space-between" },
3043
- children: [
3044
- /* @__PURE__ */ jsx("span", { children: "To" }),
3045
- /* @__PURE__ */ jsxs(
3046
- "span",
3047
- {
3048
- style: {
3049
- fontFamily: '"SF Mono", "Fira Code", monospace',
3050
- fontSize: "0.8rem"
3051
- },
3052
- children: [
3053
- destination.address.slice(0, 6),
3054
- "...",
3055
- destination.address.slice(-4)
3056
- ]
3057
- }
3058
- )
3059
- ]
3060
- }
3061
- ),
3062
- /* @__PURE__ */ jsxs(
3063
- "div",
3064
- {
3065
- style: { display: "flex", justifyContent: "space-between" },
3066
- children: [
3067
- /* @__PURE__ */ jsx("span", { children: "Token" }),
3068
- /* @__PURE__ */ jsx("span", { style: { fontWeight: 600 }, children: destination.token.symbol })
3069
- ]
3070
- }
3071
- ),
3072
- /* @__PURE__ */ jsxs(
3073
- "div",
3074
- {
3075
- style: {
3076
- display: "flex",
3077
- justifyContent: "space-between",
3078
- alignItems: "center"
3079
- },
3080
- children: [
3081
- /* @__PURE__ */ jsx("span", { children: "From" }),
3082
- noAccounts ? /* @__PURE__ */ jsx("span", { style: { fontWeight: 500, color: tokens.textMuted }, children: "New account" }) : /* @__PURE__ */ jsx(
3083
- AccountDropdown,
3084
- {
3085
- accounts,
3086
- selectedAccountId,
3087
- selectedWalletId,
3088
- onSelect: (id) => {
3089
- setSelectedAccountId(id);
3090
- setSelectedWalletId(null);
3091
- setConnectingNewAccount(false);
3092
- setSelectedProviderId(null);
3093
- },
3094
- onWalletSelect: (accountId, walletId) => {
3095
- setSelectedAccountId(accountId);
3096
- setSelectedWalletId(walletId);
3097
- setConnectingNewAccount(false);
3098
- setSelectedProviderId(null);
3099
- }
3067
+ children: /* @__PURE__ */ jsx(
3068
+ "div",
3069
+ {
3070
+ style: {
3071
+ display: "flex",
3072
+ justifyContent: "space-between",
3073
+ alignItems: "center"
3074
+ },
3075
+ children: noAccounts ? /* @__PURE__ */ jsx(Fragment, {}) : /* @__PURE__ */ jsxs("div", { children: [
3076
+ /* @__PURE__ */ jsx("span", { children: "From" }),
3077
+ /* @__PURE__ */ jsx(
3078
+ AccountDropdown,
3079
+ {
3080
+ accounts,
3081
+ selectedAccountId,
3082
+ selectedWalletId,
3083
+ onSelect: (id) => {
3084
+ setSelectedAccountId(id);
3085
+ setSelectedWalletId(null);
3086
+ setConnectingNewAccount(false);
3087
+ setSelectedProviderId(null);
3088
+ },
3089
+ onWalletSelect: (accountId, walletId) => {
3090
+ setSelectedAccountId(accountId);
3091
+ setSelectedWalletId(walletId);
3092
+ setConnectingNewAccount(false);
3093
+ setSelectedProviderId(null);
3100
3094
  }
3101
- )
3102
- ]
3103
- }
3104
- )
3105
- ]
3095
+ }
3096
+ )
3097
+ ] })
3098
+ }
3099
+ )
3106
3100
  }
3107
3101
  ),
3108
3102
  noAccounts && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "16px" }, children: [
@@ -3368,10 +3362,9 @@ function SwypePayment({
3368
3362
  }
3369
3363
  };
3370
3364
  const regMsg = getRegistrationMessage();
3371
- const transferStatus = getDisplayTransferStatus(polling.transfer, transfer);
3372
- const transferIdSuffix = getTransferIdSuffix(polling.transfer, transfer);
3373
- const statusLabel = creatingTransfer ? "Creating transfer..." : mobileFlow ? "Waiting for authorization..." : authExecutor.executing && regMsg.label ? regMsg.label : authExecutor.executing ? "Authorizing..." : transferSigning.signing ? "Preparing transfer..." : polling.isPolling ? "Processing payment..." : "Please wait...";
3374
- const statusDescription = creatingTransfer ? "Setting up your transfer..." : mobileFlow ? "Complete the authorization in your wallet app, then return here." : authExecutor.executing && regMsg.description ? regMsg.description : authExecutor.executing ? "Complete the wallet prompts to authorize this payment." : transferSigning.signing ? "Waiting for backend to prepare your transfer payload..." : polling.isPolling ? "Your payment is being processed. This usually takes a few moments." : "Hang tight...";
3365
+ getDisplayTransferStatus(polling.transfer, transfer);
3366
+ getTransferIdSuffix(polling.transfer, transfer);
3367
+ const statusLabel = creatingTransfer ? "Creating Transfer" : mobileFlow ? "Waiting for Authorization" : authExecutor.executing && regMsg.label ? regMsg.label : authExecutor.executing ? "Authorizing" : transferSigning.signing ? "Sending transfer" : polling.isPolling ? "Transfer Sent" : "Please wait...";
3375
3368
  return /* @__PURE__ */ jsx("div", { style: cardStyle, children: /* @__PURE__ */ jsxs("div", { style: { textAlign: "center", padding: "16px 0" }, children: [
3376
3369
  /* @__PURE__ */ jsx(Spinner, { size: 48 }),
3377
3370
  /* @__PURE__ */ jsx(
@@ -3385,36 +3378,6 @@ function SwypePayment({
3385
3378
  children: statusLabel
3386
3379
  }
3387
3380
  ),
3388
- /* @__PURE__ */ jsx(
3389
- "p",
3390
- {
3391
- style: {
3392
- fontSize: "0.85rem",
3393
- color: tokens.textSecondary,
3394
- margin: 0,
3395
- lineHeight: 1.5
3396
- },
3397
- children: statusDescription
3398
- }
3399
- ),
3400
- /* @__PURE__ */ jsxs(
3401
- "p",
3402
- {
3403
- style: {
3404
- marginTop: "12px",
3405
- marginBottom: 0,
3406
- fontSize: "0.8rem",
3407
- color: tokens.textSecondary
3408
- },
3409
- children: [
3410
- "Current status: ",
3411
- /* @__PURE__ */ jsx("strong", { style: { color: tokens.text }, children: transferStatus }),
3412
- " \xB7 ",
3413
- "Transfer: ",
3414
- /* @__PURE__ */ jsx("span", { style: { color: tokens.textMuted }, children: transferIdSuffix })
3415
- ]
3416
- }
3417
- ),
3418
3381
  polling.error && /* @__PURE__ */ jsxs(
3419
3382
  "p",
3420
3383
  {