@@ -25,16 +25,16 @@ import {
2525import { ReactElement } from 'react' ;
2626import UsernamePassword from './UsernamePassword' ;
2727import IdentifierFirst from './IdentifierFirst' ;
28- import GoogleButton from './GoogleButton' ;
29- import GitHubButton from './GitHubButton' ;
30- import MicrosoftButton from './MicrosoftButton' ;
31- import FacebookButton from './FacebookButton' ;
32- import LinkedInButton from './LinkedInButton' ;
33- import SignInWithEthereumButton from './SignInWithEthereumButton' ;
28+ import GoogleButton from '../../options /GoogleButton' ;
29+ import GitHubButton from '../../options /GitHubButton' ;
30+ import MicrosoftButton from '../../options /MicrosoftButton' ;
31+ import FacebookButton from '../../options /FacebookButton' ;
32+ import LinkedInButton from '../../options /LinkedInButton' ;
33+ import SignInWithEthereumButton from '../../options /SignInWithEthereumButton' ;
3434import EmailOtp from './EmailOtp' ;
3535import Totp from './Totp' ;
3636import SmsOtp from './SmsOtp' ;
37- import SocialButton from './SocialButton' ;
37+ import SocialButton from '../../options /SocialButton' ;
3838import MultiOptionButton from './MultiOptionButton' ;
3939
4040/**
@@ -44,7 +44,7 @@ export interface BaseSignInOptionProps extends WithPreferences {
4444 /**
4545 * The authenticator configuration.
4646 */
47- authenticator : EmbeddedSignInFlowAuthenticator ;
47+ authenticator ? : EmbeddedSignInFlowAuthenticator ;
4848
4949 /**
5050 * Current form values.
@@ -74,7 +74,7 @@ export interface BaseSignInOptionProps extends WithPreferences {
7474 /**
7575 * Callback function called when the option is submitted.
7676 */
77- onSubmit : ( authenticator : EmbeddedSignInFlowAuthenticator , formData ?: Record < string , string > ) => void ;
77+ onSubmit ? : ( authenticator : EmbeddedSignInFlowAuthenticator , formData ?: Record < string , string > ) => void ;
7878
7979 /**
8080 * Custom CSS class name for form inputs.
@@ -95,64 +95,142 @@ export interface BaseSignInOptionProps extends WithPreferences {
9595/**
9696 * Creates the appropriate sign-in option component based on the authenticator's ID.
9797 */
98- export const createSignInOption = ( props : BaseSignInOptionProps ) : ReactElement => {
99- const { authenticator, ...optionProps } = props ;
100-
98+ export const createSignInOption = ( {
99+ authenticator,
100+ onSubmit,
101+ buttonClassName,
102+ preferences,
103+ ...rest
104+ } : BaseSignInOptionProps ) : ReactElement => {
101105 // Check if this authenticator has params (indicating it needs user input)
102106 const hasParams = authenticator . metadata ?. params && authenticator . metadata . params . length > 0 ;
103107
104108 // Use authenticatorId to determine the component type
105109 switch ( authenticator . authenticatorId ) {
106110 case ApplicationNativeAuthenticationConstants . SupportedAuthenticators . UsernamePassword :
107- return < UsernamePassword { ...props } /> ;
111+ return < UsernamePassword authenticator = { authenticator } preferences = { preferences } onSubmit = { onSubmit } { ...rest } /> ;
108112
109113 case ApplicationNativeAuthenticationConstants . SupportedAuthenticators . IdentifierFirst :
110- return < IdentifierFirst { ...props } /> ;
114+ return < IdentifierFirst authenticator = { authenticator } preferences = { preferences } onSubmit = { onSubmit } { ...rest } /> ;
111115
112116 case ApplicationNativeAuthenticationConstants . SupportedAuthenticators . Google :
113- return < GoogleButton { ...props } /> ;
117+ return (
118+ < GoogleButton
119+ className = { buttonClassName }
120+ onClick = { ( ) => onSubmit ( authenticator ) }
121+ authenticator = { authenticator }
122+ preferences = { preferences }
123+ { ...rest }
124+ />
125+ ) ;
114126
115127 case ApplicationNativeAuthenticationConstants . SupportedAuthenticators . GitHub :
116- return < GitHubButton { ...props } /> ;
128+ return (
129+ < GitHubButton
130+ authenticator = { authenticator }
131+ preferences = { preferences }
132+ className = { buttonClassName }
133+ onClick = { ( ) => onSubmit ( authenticator ) }
134+ { ...rest }
135+ />
136+ ) ;
117137
118138 case ApplicationNativeAuthenticationConstants . SupportedAuthenticators . Microsoft :
119- return < MicrosoftButton { ...props } /> ;
139+ return (
140+ < MicrosoftButton
141+ authenticator = { authenticator }
142+ preferences = { preferences }
143+ className = { buttonClassName }
144+ onClick = { ( ) => onSubmit ( authenticator ) }
145+ { ...rest }
146+ />
147+ ) ;
120148
121149 case ApplicationNativeAuthenticationConstants . SupportedAuthenticators . Facebook :
122- return < FacebookButton { ...props } /> ;
150+ return (
151+ < FacebookButton
152+ authenticator = { authenticator }
153+ preferences = { preferences }
154+ className = { buttonClassName }
155+ onClick = { ( ) => onSubmit ( authenticator ) }
156+ { ...rest }
157+ />
158+ ) ;
123159
124160 case ApplicationNativeAuthenticationConstants . SupportedAuthenticators . LinkedIn :
125- return < LinkedInButton { ...props } /> ;
161+ return (
162+ < LinkedInButton
163+ authenticator = { authenticator }
164+ preferences = { preferences }
165+ className = { buttonClassName }
166+ onClick = { ( ) => onSubmit ( authenticator ) }
167+ { ...rest }
168+ />
169+ ) ;
126170
127171 case ApplicationNativeAuthenticationConstants . SupportedAuthenticators . SignInWithEthereum :
128- return < SignInWithEthereumButton { ...props } /> ;
172+ return (
173+ < SignInWithEthereumButton
174+ authenticator = { authenticator }
175+ preferences = { preferences }
176+ className = { buttonClassName }
177+ onClick = { ( ) => onSubmit ( authenticator ) }
178+ { ...rest }
179+ />
180+ ) ;
129181
130182 case ApplicationNativeAuthenticationConstants . SupportedAuthenticators . EmailOtp :
131183 // If it has params, render as input form, otherwise as selection button
132- return hasParams ? < EmailOtp { ...props } /> : < MultiOptionButton { ...props } /> ;
184+ return hasParams ? (
185+ < EmailOtp authenticator = { authenticator } preferences = { preferences } onSubmit = { onSubmit } { ...rest } />
186+ ) : (
187+ < MultiOptionButton authenticator = { authenticator } preferences = { preferences } onSubmit = { onSubmit } { ...rest } />
188+ ) ;
133189
134190 case ApplicationNativeAuthenticationConstants . SupportedAuthenticators . Totp :
135191 // If it has params, render as input form, otherwise as selection button
136- return hasParams ? < Totp { ...props } /> : < MultiOptionButton { ...props } /> ;
192+ return hasParams ? (
193+ < Totp authenticator = { authenticator } preferences = { preferences } onSubmit = { onSubmit } { ...rest } />
194+ ) : (
195+ < MultiOptionButton authenticator = { authenticator } preferences = { preferences } onSubmit = { onSubmit } { ...rest } />
196+ ) ;
137197
138198 case ApplicationNativeAuthenticationConstants . SupportedAuthenticators . SmsOtp :
139199 // If it has params, render as input form, otherwise as selection button
140- return hasParams ? < SmsOtp { ...props } /> : < MultiOptionButton { ...props } /> ;
200+ return hasParams ? (
201+ < SmsOtp authenticator = { authenticator } preferences = { preferences } onSubmit = { onSubmit } { ...rest } />
202+ ) : (
203+ < MultiOptionButton authenticator = { authenticator } preferences = { preferences } onSubmit = { onSubmit } { ...rest } />
204+ ) ;
141205
142206 default :
143207 // Check if it's a federated authenticator (non-LOCAL idp)
144208 if ( authenticator . idp !== EmbeddedSignInFlowAuthenticatorKnownIdPType . Local ) {
145209 // For unknown federated authenticators, use generic social login
146- return < SocialButton { ...props } /> ;
210+ return (
211+ < SocialButton
212+ authenticator = { authenticator }
213+ preferences = { preferences }
214+ className = { buttonClassName }
215+ onClick = { ( ) => onSubmit ( authenticator ) }
216+ { ...rest }
217+ >
218+ { authenticator . idp }
219+ </ SocialButton >
220+ ) ;
147221 }
148222
149223 // For LOCAL authenticators, decide based on whether they have params
150224 if ( hasParams ) {
151225 // Fallback to username/password for unknown local authenticators with params
152- return < UsernamePassword { ...props } /> ;
226+ return (
227+ < UsernamePassword authenticator = { authenticator } preferences = { preferences } onSubmit = { onSubmit } { ...rest } />
228+ ) ;
153229 } else {
154230 // Use multi-option button for LOCAL authenticators without params
155- return < MultiOptionButton { ...props } /> ;
231+ return (
232+ < MultiOptionButton authenticator = { authenticator } preferences = { preferences } onSubmit = { onSubmit } { ...rest } />
233+ ) ;
156234 }
157235 }
158236} ;
0 commit comments