UNPKG

@asgardeo/react

Version:
67 lines (66 loc) 2.31 kB
/** * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import { WithPreferences } from '@asgardeo/browser'; import { ButtonHTMLAttributes, ForwardRefExoticComponent, ReactNode, RefAttributes } from 'react'; /** * Common props shared by all {@link BaseSignInButton} components. */ export interface CommonBaseSignInButtonProps { /** * Loading state during sign-in process */ isLoading?: boolean; /** * Function to initiate the sign-in process */ signIn: () => Promise<void>; } /** * Props passed to the render function of {@link BaseSignInButton} */ export type BaseSignInButtonRenderProps = CommonBaseSignInButtonProps; /** * Props interface of {@link BaseSignInButton} */ export interface BaseSignInButtonProps extends Partial<CommonBaseSignInButtonProps>, Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'>, WithPreferences { /** * Render prop function that receives sign-in props, or traditional ReactNode children */ children?: ((props: BaseSignInButtonRenderProps) => ReactNode) | ReactNode; } /** * Base SignInButton component that supports both render props and traditional props patterns. * * @example Using render props * ```tsx * <BaseSignInButton> * {({signIn, isLoading}) => ( * <button onClick={signIn} disabled={isLoading}> * {isLoading ? 'Signing in...' : 'Sign In'} * </button> * )} * </BaseSignInButton> * ``` * * @example Using traditional props * ```tsx * <BaseSignInButton className="custom-button">Sign In</BaseSignInButton> * ``` */ declare const BaseSignInButton: ForwardRefExoticComponent<BaseSignInButtonProps & RefAttributes<HTMLButtonElement>>; export default BaseSignInButton;