Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Add form and oauthButton slot props #4674

Merged
merged 3 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function BrandingSignInPage() {
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ emailField: { autoFocus: false } }}
slotProps={{ emailField: { autoFocus: false }, form: { noValidate: true } }}
/>
</AppProvider>
// preview-end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function BrandingSignInPage() {
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ emailField: { autoFocus: false } }}
slotProps={{ emailField: { autoFocus: false }, form: { noValidate: true } }}
/>
</AppProvider>
// preview-end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ const BRANDING = {
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ emailField: { autoFocus: false } }}
slotProps={{ emailField: { autoFocus: false }, form: { noValidate: true } }}
/>
</AppProvider>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function CredentialsSignInPage() {
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ emailField: { autoFocus: false } }}
slotProps={{ emailField: { autoFocus: false }, form: { noValidate: true } }}
/>
</AppProvider>
// preview-end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function CredentialsSignInPage() {
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ emailField: { autoFocus: false } }}
slotProps={{ emailField: { autoFocus: false }, form: { noValidate: true } }}
/>
</AppProvider>
// preview-end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ const providers = [{ id: 'credentials', name: 'Email and Password' }];
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ emailField: { autoFocus: false } }}
slotProps={{ emailField: { autoFocus: false }, form: { noValidate: true } }}
/>
</AppProvider>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function MagicLinkAlertSignInPage() {
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ emailField: { autoFocus: false } }}
slotProps={{ emailField: { autoFocus: false }, form: { noValidate: true } }}
/>
</AppProvider>
// preview-end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function MagicLinkAlertSignInPage() {
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ emailField: { autoFocus: false } }}
slotProps={{ emailField: { autoFocus: false }, form: { noValidate: true } }}
/>
</AppProvider>
// preview-end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ resolve({
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ emailField: { autoFocus: false } }}
slotProps={{ emailField: { autoFocus: false }, form: { noValidate: true } }}
/>
</AppProvider>
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function NotificationsSignInPageError() {
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ emailField: { autoFocus: false } }}
slotProps={{ emailField: { autoFocus: false }, form: { noValidate: true } }}
/>
</AppProvider>
// preview-end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function NotificationsSignInPageError() {
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ emailField: { autoFocus: false } }}
slotProps={{ emailField: { autoFocus: false }, form: { noValidate: true } }}
/>
</AppProvider>
// preview-end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ resolve({
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ emailField: { autoFocus: false } }}
slotProps={{ emailField: { autoFocus: false }, form: { noValidate: true } }}
/>
</AppProvider>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function PasskeySignInPage() {
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ emailField: { autoFocus: false } }}
slotProps={{ emailField: { autoFocus: false }, form: { noValidate: true } }}
/>
</AppProvider>
// preview-end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function PasskeySignInPage() {
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ emailField: { autoFocus: false } }}
slotProps={{ emailField: { autoFocus: false }, form: { noValidate: true } }}
/>
</AppProvider>
// preview-end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ const providers = [{ id: 'passkey', name: 'Passkey' }];
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ emailField: { autoFocus: false } }}
slotProps={{ emailField: { autoFocus: false }, form: { noValidate: true } }}
/>
</AppProvider>
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default function ThemeSignInPage() {
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ form: { noValidate: true } }}
sx={{
'& form > .MuiStack-root': {
marginTop: '2rem',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default function ThemeSignInPage() {
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ form: { noValidate: true } }}
sx={{
'& form > .MuiStack-root': {
marginTop: '2rem',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const THEME = createTheme({
<SignInPage
signIn={signIn}
providers={providers}
slotProps={{ form: { noValidate: true } }}
sx={{
'& form > .MuiStack-root': {
marginTop: '2rem',
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/toolpad/core/api/sign-in-page.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"slotProps": {
"type": {
"name": "shape",
"description": "{ emailField?: object, forgotPasswordLink?: object, passwordField?: object, rememberMe?: object, signUpLink?: object, submitButton?: object }"
"description": "{ emailField?: object, forgotPasswordLink?: object, form?: object, oAuthButton?: object, passwordField?: object, rememberMe?: object, signUpLink?: object, submitButton?: object }"
},
"default": "{}"
},
Expand Down
9 changes: 9 additions & 0 deletions packages/toolpad-core/src/SignInPage/SignInPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ export interface SignInPageProps {
forgotPasswordLink?: LinkProps;
signUpLink?: LinkProps;
rememberMe?: Partial<FormControlLabelProps>;
form?: Partial<React.FormHTMLAttributes<HTMLFormElement>>;
oAuthButton?: LoadingButtonProps;
};
/**
* The prop used to customize the styles on the `SignInPage` container
Expand Down Expand Up @@ -375,6 +377,7 @@ function SignInPage(props: SignInPageProps) {
error: oauthResponse?.error,
}));
}}
{...slotProps?.form}
>
<LoadingButton
key={provider.id}
Expand All @@ -391,6 +394,7 @@ function SignInPage(props: SignInPageProps) {
sx={{
textTransform: 'capitalize',
}}
{...slotProps?.oAuthButton}
>
<span>Sign in with {provider.name}</span>
</LoadingButton>
Expand Down Expand Up @@ -424,6 +428,7 @@ function SignInPage(props: SignInPageProps) {
error: passkeyResponse?.error,
}));
}}
{...slotProps?.form}
>
{slots?.emailField ? (
<slots.emailField {...slotProps?.emailField} />
Expand Down Expand Up @@ -498,6 +503,7 @@ function SignInPage(props: SignInPageProps) {
success: emailResponse?.success,
}));
}}
{...slotProps?.form}
>
{slots?.emailField ? (
<slots.emailField {...slotProps?.emailField} />
Expand Down Expand Up @@ -570,6 +576,7 @@ function SignInPage(props: SignInPageProps) {
error: credentialsResponse?.error,
}));
}}
{...slotProps?.form}
>
<Stack direction="column" spacing={2} sx={{ mb: 2 }}>
{slots?.emailField ? (
Expand Down Expand Up @@ -711,6 +718,8 @@ SignInPage.propTypes /* remove-proptypes */ = {
slotProps: PropTypes.shape({
emailField: PropTypes.object,
forgotPasswordLink: PropTypes.object,
form: PropTypes.object,
oAuthButton: PropTypes.object,
passwordField: PropTypes.object,
rememberMe: PropTypes.object,
signUpLink: PropTypes.object,
Expand Down