diff --git a/packages/checkout/src/components/SequenceCheckoutProvider/SequenceCheckoutProvider.tsx b/packages/checkout/src/components/SequenceCheckoutProvider/SequenceCheckoutProvider.tsx index fad8f80f8..32b5e1b5b 100644 --- a/packages/checkout/src/components/SequenceCheckoutProvider/SequenceCheckoutProvider.tsx +++ b/packages/checkout/src/components/SequenceCheckoutProvider/SequenceCheckoutProvider.tsx @@ -1,7 +1,7 @@ 'use client' import { getModalPositionCss, ShadowRoot, useConnectConfigContext, useTheme } from '@0xsequence/connect' -import { Modal } from '@0xsequence/design-system' +import { Modal, ThemeProvider } from '@0xsequence/design-system' import { AnimatePresence } from 'motion/react' import { useEffect, useState, type ReactNode } from 'react' @@ -303,111 +303,115 @@ export const SequenceCheckoutProvider = ({ children, config }: SequenceCheckoutP defaultLocation: getDefaultLocationCheckout() }} > - - - {openCheckoutModal && ( - setOpenCheckoutModal(false)} - > -
- {getCheckoutHeader()} - {getCheckoutContent()} -
-
- )} - {openAddFundsModal && ( - -
- {getAddFundsHeader()} - {getAddFundsContent()} -
-
- )} - {openPaymentSelectionModal && ( - setOpenPaymentSelectionModal(false)} - > -
- {getCheckoutFlowHeader()} - {getCheckoutFlowContent()} -
-
- )} - {openTransferFundsModal && ( - -
- - -
-
- )} - {openTransactionStatusModal && ( - -
- -
-
- )} - {isOpenSwapModal && ( - -
- - -
-
- )} -
+ + {(container: HTMLDivElement) => ( + + + {openCheckoutModal && ( + setOpenCheckoutModal(false)} + > +
+ {getCheckoutHeader()} + {getCheckoutContent()} +
+
+ )} + {openAddFundsModal && ( + +
+ {getAddFundsHeader()} + {getAddFundsContent()} +
+
+ )} + {openPaymentSelectionModal && ( + setOpenPaymentSelectionModal(false)} + > +
+ {getCheckoutFlowHeader()} + {getCheckoutFlowContent()} +
+
+ )} + {openTransferFundsModal && ( + +
+ + +
+
+ )} + {openTransactionStatusModal && ( + +
+ +
+
+ )} + {isOpenSwapModal && ( + +
+ + +
+
+ )} +
+
+ )}
{children} diff --git a/packages/connect/src/components/SequenceConnectInlineProvider/SequenceConnectInlineProvider.tsx b/packages/connect/src/components/SequenceConnectInlineProvider/SequenceConnectInlineProvider.tsx index 258591209..e3bea1c9e 100644 --- a/packages/connect/src/components/SequenceConnectInlineProvider/SequenceConnectInlineProvider.tsx +++ b/packages/connect/src/components/SequenceConnectInlineProvider/SequenceConnectInlineProvider.tsx @@ -282,152 +282,159 @@ export const SequenceConnectInlineProvider = (props: SequenceConnectInlineProvid - - - {pendingRequestConfirmation && ( - { - rejectPendingRequest('') - }} - > -
-
+ {(container: HTMLDivElement) => ( + + + {pendingRequestConfirmation && ( + { + rejectPendingRequest('') }} > - - -

- Confirm{' '} - {pendingRequestConfirmation.type === 'signMessage' ? 'signing message' : 'transaction'} -

-
-
- - {pendingRequestConfirmation.type === 'signMessage' && pendingRequestConfirmation.message && ( -
- - Message - - - - {isJSON(pendingRequestConfirmation.message) ? ( - - ) : ( - hexToString(pendingRequestConfirmation.message as unknown as Hex) - )} - - -
- )} - - {pendingRequestConfirmation.type === 'signTransaction' && ( - - )} - - {pendingRequestConfirmation.chainId && ( -
-
- - Network +
+
+ + +

+ Confirm{' '} + {pendingRequestConfirmation.type === 'signMessage' + ? 'signing message' + : 'transaction'} +

-
-
- + + + {pendingRequestConfirmation.type === 'signMessage' && + pendingRequestConfirmation.message && ( +
+ + Message + + + + {isJSON(pendingRequestConfirmation.message) ? ( + + ) : ( + hexToString(pendingRequestConfirmation.message as unknown as Hex) + )} + + +
+ )} + + {pendingRequestConfirmation.type === 'signTransaction' && ( + + )} + + {pendingRequestConfirmation.chainId && ( +
+
+ + Network + +
+
+ +
+
+ )} + +
+
- )} - -
-
-
- -
- -
-
- - )} - {isEmailConflictOpen && emailConflictInfo && ( - { - toggleEmailConflictModal(false) - }} - > -
- - Email already in use - -
- - Another account with this email address{' '} - ({emailConflictInfo.email}) already exists with account type{' '} - ({emailConflictInfo.type}). Please sign in again with the correct - account. - -
-
-
-
-
- )} - - {isSocialLinkOpen && - (waasConnector ? ( - setIsSocialLinkOpen(false)}> - - - ) : ( - setIsSocialLinkOpen(false)}> - - Social link is not supported for universal wallets (works only for embedded wallets) - - - ))} - + + )} + + {isEmailConflictOpen && emailConflictInfo && ( + { + toggleEmailConflictModal(false) + }} + > +
+ + Email already in use + +
+ + Another account with this email address{' '} + ({emailConflictInfo.email}) already exists with account type{' '} + ({emailConflictInfo.type}). Please sign in again with the + correct account. + +
+
+
+
+
+ )} + + {isSocialLinkOpen && + (waasConnector ? ( + setIsSocialLinkOpen(false)}> + + + ) : ( + setIsSocialLinkOpen(false)}> + + Social link is not supported for universal wallets (works only for embedded wallets) + + + ))} + + + )} {children} diff --git a/packages/connect/src/components/SequenceConnectProvider/SequenceConnectProvider.tsx b/packages/connect/src/components/SequenceConnectProvider/SequenceConnectProvider.tsx index 2828f9266..22af78af5 100644 --- a/packages/connect/src/components/SequenceConnectProvider/SequenceConnectProvider.tsx +++ b/packages/connect/src/components/SequenceConnectProvider/SequenceConnectProvider.tsx @@ -1,6 +1,16 @@ 'use client' -import { Button, Card, Modal, ModalPrimitive, Spinner, Text, ToastProvider, type Theme } from '@0xsequence/design-system' +import { + Button, + Card, + Modal, + ModalPrimitive, + Spinner, + Text, + ThemeProvider, + ToastProvider, + type Theme +} from '@0xsequence/design-system' import { SequenceHooksProvider } from '@0xsequence/hooks' import { SequenceClient, setupAnalytics, type Analytics } from '@0xsequence/provider' import { GoogleOAuthProvider } from '@react-oauth/google' @@ -240,187 +250,194 @@ export const SequenceConnectProvider = (props: SequenceConnectProviderProps) => - - - {openConnectModal && ( - setOpenConnectModal(false)} - > - {isWalletConfigLoading || isAuthStatusLoading ? ( -
- -
- ) : ( - - setOpenConnectModal(false)} - emailConflictInfo={emailConflictInfo} - {...props} - config={incomingConfig} - resolvedConfig={config} - isV3WalletSignedIn={isV3WalletSignedIn} - isAuthStatusLoading={isAuthStatusLoading} - enabledProviders={enabledProviders} - walletConfigurationSignIn={walletConfigurationSignIn} - sdkConfig={sdkConfig} - /> - - )} -
- )} - {pendingRequestConfirmation && ( - { - rejectPendingRequest('') - }} - > -
-
+ {(container: HTMLDivElement) => ( + + + {openConnectModal && ( + setOpenConnectModal(false)} > - - -

- Confirm{' '} - {pendingRequestConfirmation.type === 'signMessage' ? 'signing message' : 'transaction'} -

-
-
- - {pendingRequestConfirmation.type === 'signMessage' && pendingRequestConfirmation.message && ( -
- - Message - - - - {isJSON(pendingRequestConfirmation.message) ? ( - - ) : ( - hexToString(pendingRequestConfirmation.message as unknown as Hex) - )} - - + {isWalletConfigLoading || isAuthStatusLoading ? ( +
+
+ ) : ( + + setOpenConnectModal(false)} + emailConflictInfo={emailConflictInfo} + {...props} + config={incomingConfig} + resolvedConfig={config} + isV3WalletSignedIn={isV3WalletSignedIn} + isAuthStatusLoading={isAuthStatusLoading} + enabledProviders={enabledProviders} + walletConfigurationSignIn={walletConfigurationSignIn} + sdkConfig={sdkConfig} + /> + )} - - {pendingRequestConfirmation.type === 'signTransaction' && ( - - )} - - {pendingRequestConfirmation.chainId && ( -
-
- - Network + + )} + {pendingRequestConfirmation && ( + { + rejectPendingRequest('') + }} + > +
+
+ + +

+ Confirm{' '} + {pendingRequestConfirmation.type === 'signMessage' + ? 'signing message' + : 'transaction'} +

-
-
- + + + {pendingRequestConfirmation.type === 'signMessage' && + pendingRequestConfirmation.message && ( +
+ + Message + + + + {isJSON(pendingRequestConfirmation.message) ? ( + + ) : ( + hexToString(pendingRequestConfirmation.message as unknown as Hex) + )} + + +
+ )} + + {pendingRequestConfirmation.type === 'signTransaction' && ( + + )} + + {pendingRequestConfirmation.chainId && ( +
+
+ + Network + +
+
+ +
+
+ )} + +
+
- )} -
-
-
- -
- -
-
- - )} - {isEmailConflictOpen && emailConflictInfo && ( - { - setOpenConnectModal(false) - toggleEmailConflictModal(false) - }} - > -
- - Email already in use - -
- - Another account with this email address{' '} - ({emailConflictInfo.email}) already exists with account type{' '} - ({emailConflictInfo.type}). Please sign in again with the correct - account. - -
-
+
-
-
-
- )} - {isSocialLinkOpen && - (waasConnector ? ( - setIsSocialLinkOpen(false)}> - - - ) : ( - setIsSocialLinkOpen(false)}> - - Social link is not supported for universal wallets (works only for embedded wallets) - - - ))} -
+ + )} + {isSocialLinkOpen && + (waasConnector ? ( + setIsSocialLinkOpen(false)}> + + + ) : ( + setIsSocialLinkOpen(false)}> + + Social link is not supported for universal wallets (works only for embedded wallets) + + + ))} + +
+ )} {children} diff --git a/packages/connect/src/components/ShadowRoot/ShadowRoot.tsx b/packages/connect/src/components/ShadowRoot/ShadowRoot.tsx index f5a2ee54d..dfa082b47 100644 --- a/packages/connect/src/components/ShadowRoot/ShadowRoot.tsx +++ b/packages/connect/src/components/ShadowRoot/ShadowRoot.tsx @@ -20,7 +20,7 @@ const getCSSStyleSheet = (customCSS?: string) => { interface ShadowRootProps { theme?: Theme - children: ReactNode + children: ReactNode | ((container: HTMLDivElement) => ReactNode) customCSS?: string } @@ -51,14 +51,20 @@ export const ShadowRoot = (props: ShadowRootProps) => { } }, [windowDocument]) + const renderedChildren = container ? ( + typeof children === 'function' ? ( + children(container) + ) : ( + + {children} + + ) + ) : null + return windowDocument ? createPortal(
- {container && ( - - {children} - - )} + {renderedChildren}
, document.body ) diff --git a/packages/wallet-widget/src/components/SequenceWalletProvider/SequenceWalletProvider.tsx b/packages/wallet-widget/src/components/SequenceWalletProvider/SequenceWalletProvider.tsx index 75236d719..8b00228d2 100644 --- a/packages/wallet-widget/src/components/SequenceWalletProvider/SequenceWalletProvider.tsx +++ b/packages/wallet-widget/src/components/SequenceWalletProvider/SequenceWalletProvider.tsx @@ -8,7 +8,7 @@ import { useSocialLink, useTheme } from '@0xsequence/connect' -import { Modal, Scroll } from '@0xsequence/design-system' +import { Modal, Scroll, ThemeProvider } from '@0xsequence/design-system' import { AnimatePresence } from 'motion/react' import { useContext, useEffect, useRef, useState, type ReactNode } from 'react' import { useConnection } from 'wagmi' @@ -112,40 +112,48 @@ export const WalletContent = ({ children }: SequenceWalletProviderProps) => { - - - {openWalletModal && !isConnectModalOpen && !isSocialLinkOpen && ( - setOpenWalletModal(false)} - > -
-
{getHeader(navigation)}
- -
- {displayScrollbar ? {getContent(navigation)} : getContent(navigation)} -
-
-
- )} -
+ + {(container: HTMLDivElement) => ( + + + {openWalletModal && !isConnectModalOpen && !isSocialLinkOpen && ( + setOpenWalletModal(false)} + > +
+
{getHeader(navigation)}
+ +
+ {displayScrollbar ? ( + {getContent(navigation)} + ) : ( + getContent(navigation) + )} +
+
+
+ )} +
+
+ )}
{children}