11import { LOGIN_PROVIDER , type SafeEventEmitter } from "@web3auth/auth" ;
22import { ADAPTER_NAMES , ChainNamespaceType , cloneDeep , log , WALLET_ADAPTERS , WalletRegistry } from "@web3auth/base/src" ;
33import deepmerge from "deepmerge" ;
4- import { createEffect , createMemo , createSignal , on } from "solid-js" ;
4+ import { createEffect , createMemo , createSignal , Match , on , Suspense , Switch } from "solid-js" ;
55
66import { PAGES } from "../../constants" ;
77import { ExternalWalletEventType , MODAL_STATUS , ModalState , SocialLoginEventType , StateEmitterEvents } from "../../interfaces" ;
88import { Body } from "../Body" ;
99import { Modal } from "../Modal" ;
10+ import { Widget } from "../Widget" ;
1011
1112export interface LoginModalProps {
1213 stateListener : SafeEventEmitter < StateEmitterEvents > ;
@@ -18,6 +19,7 @@ export interface LoginModalProps {
1819 handleExternalWalletClick : ( params : ExternalWalletEventType ) => void ;
1920 handleShowExternalWallets : ( externalWalletsInitialized : boolean ) => void ;
2021 closeModal : ( ) => void ;
22+ widget ?: "modal" | "embed" ;
2123}
2224
2325const LoginModal = ( props : LoginModalProps ) => {
@@ -176,27 +178,56 @@ const LoginModal = (props: LoginModalProps) => {
176178 ) ;
177179
178180 return (
179- < Modal open = { modalState ( ) . modalVisibility } placement = "center" padding = { false } showCloseIcon = { showCloseIcon ( ) } onClose = { closeModal } >
180- < Body
181- { ...props }
182- showPasswordLessInput = { showPasswordLessInput ( ) }
183- showExternalWalletButton = { showExternalWalletButton ( ) }
184- handleSocialLoginClick = { ( params : SocialLoginEventType ) => preHandleSocialWalletClick ( params ) }
185- socialLoginsConfig = { modalState ( ) . socialLoginsConfig }
186- areSocialLoginsVisible = { areSocialLoginsVisible ( ) }
187- isEmailPrimary = { isEmailPrimary ( ) }
188- isExternalPrimary = { isExternalPrimary ( ) }
189- showExternalWalletPage = { showExternalWalletPage ( ) }
190- handleExternalWalletBtnClick = { handleExternalWalletBtnClick }
191- modalState = { modalState ( ) }
192- preHandleExternalWalletClick = { preHandleExternalWalletClick }
193- setModalState = { setModalState }
194- onCloseLoader = { onCloseLoader }
195- isEmailPasswordLessLoginVisible = { isEmailPasswordLessLoginVisible ( ) }
196- isSmsPasswordLessLoginVisible = { isSmsPasswordLessLoginVisible ( ) }
197- handleBackClick = { handleBackClick }
198- />
199- </ Modal >
181+ < Suspense >
182+ < Switch >
183+ < Match when = { props . widget === "modal" } >
184+ < Modal open = { modalState ( ) . modalVisibility } placement = "center" padding = { false } showCloseIcon = { showCloseIcon ( ) } onClose = { closeModal } >
185+ < Body
186+ { ...props }
187+ showPasswordLessInput = { showPasswordLessInput ( ) }
188+ showExternalWalletButton = { showExternalWalletButton ( ) }
189+ handleSocialLoginClick = { ( params : SocialLoginEventType ) => preHandleSocialWalletClick ( params ) }
190+ socialLoginsConfig = { modalState ( ) . socialLoginsConfig }
191+ areSocialLoginsVisible = { areSocialLoginsVisible ( ) }
192+ isEmailPrimary = { isEmailPrimary ( ) }
193+ isExternalPrimary = { isExternalPrimary ( ) }
194+ showExternalWalletPage = { showExternalWalletPage ( ) }
195+ handleExternalWalletBtnClick = { handleExternalWalletBtnClick }
196+ modalState = { modalState ( ) }
197+ preHandleExternalWalletClick = { preHandleExternalWalletClick }
198+ setModalState = { setModalState }
199+ onCloseLoader = { onCloseLoader }
200+ isEmailPasswordLessLoginVisible = { isEmailPasswordLessLoginVisible ( ) }
201+ isSmsPasswordLessLoginVisible = { isSmsPasswordLessLoginVisible ( ) }
202+ handleBackClick = { handleBackClick }
203+ />
204+ </ Modal >
205+ </ Match >
206+ < Match when = { props . widget === "embed" } >
207+ < Widget padding = { false } >
208+ < Body
209+ { ...props }
210+ showPasswordLessInput = { showPasswordLessInput ( ) }
211+ showExternalWalletButton = { showExternalWalletButton ( ) }
212+ handleSocialLoginClick = { ( params : SocialLoginEventType ) => preHandleSocialWalletClick ( params ) }
213+ socialLoginsConfig = { modalState ( ) . socialLoginsConfig }
214+ areSocialLoginsVisible = { areSocialLoginsVisible ( ) }
215+ isEmailPrimary = { isEmailPrimary ( ) }
216+ isExternalPrimary = { isExternalPrimary ( ) }
217+ showExternalWalletPage = { showExternalWalletPage ( ) }
218+ handleExternalWalletBtnClick = { handleExternalWalletBtnClick }
219+ modalState = { modalState ( ) }
220+ preHandleExternalWalletClick = { preHandleExternalWalletClick }
221+ setModalState = { setModalState }
222+ onCloseLoader = { onCloseLoader }
223+ isEmailPasswordLessLoginVisible = { isEmailPasswordLessLoginVisible ( ) }
224+ isSmsPasswordLessLoginVisible = { isSmsPasswordLessLoginVisible ( ) }
225+ handleBackClick = { handleBackClick }
226+ />
227+ </ Widget >
228+ </ Match >
229+ </ Switch >
230+ </ Suspense >
200231 ) ;
201232} ;
202233
0 commit comments