@asgardeo/react
Version:
React implementation of Asgardeo JavaScript SDK.
67 lines (66 loc) • 2.33 kB
TypeScript
/**
* 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 { ForwardRefExoticComponent, ButtonHTMLAttributes, ReactNode, RefAttributes } from 'react';
/**
* Common props shared by all {@link BaseSignOutButton} components.
*/
export interface CommonBaseSignOutButtonProps {
/**
* Loading state during sign-out process
*/
isLoading?: boolean;
/**
* Function to initiate the sign-out process
*/
signOut: () => Promise<void>;
}
/**
* Props passed to the render function of {@link BaseSignOutButton}
*/
export type BaseSignOutButtonRenderProps = CommonBaseSignOutButtonProps;
/**
* Props interface of {@link BaseSignOutButton}
*/
export interface BaseSignOutButtonProps extends Partial<CommonBaseSignOutButtonProps>, Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'>, WithPreferences {
/**
* Render prop function that receives sign-out props, or traditional ReactNode children
*/
children?: ((props: BaseSignOutButtonRenderProps) => ReactNode) | ReactNode;
}
/**
* Base SignOutButton component that supports both render props and traditional props patterns.
*
* @example Using render props
* ```tsx
* <BaseSignOutButton>
* {({signOut, isLoading}) => (
* <button onClick={signOut} disabled={isLoading}>
* {isLoading ? 'Signing out...' : 'Sign Out'}
* </button>
* )}
* </BaseSignOutButton>
* ```
*
* @example Using traditional props
* ```tsx
* <BaseSignOutButton className="custom-button">Sign Out</BaseSignOutButton>
* ```
*/
declare const BaseSignOutButton: ForwardRefExoticComponent<BaseSignOutButtonProps & RefAttributes<HTMLButtonElement>>;
export default BaseSignOutButton;