import { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode } from 'react';
import type { AvatarLayoutProps } from '../avatarLayout';
export type ButtonSentiment = 'default' | 'negative';
export type ButtonPriority = 'primary' | 'secondary' | 'secondary-neutral' | 'tertiary';
export type ButtonSize = 'sm' | 'md' | 'lg';
export type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
export type ButtonAddonIcon = {
type: 'icon';
value: ReactNode;
};
type ButtonAddonAvatar = {
type: 'avatar';
value: AvatarLayoutProps['avatars'];
};
type ButtonAddonStart = ButtonAddonIcon | ButtonAddonAvatar;
type ButtonAddonEnd = ButtonAddonIcon;
/**
* Common properties for the Button component.
*/
export interface CommonProps {
/**
* If set, toggles the new Button API
* @default false
* */
v2: true;
/** @default false **/
disabled?: boolean;
/** If set, the component will render as an HTML anchor. */
href?: string;
/**
* The `target` attribute for HTML anchor.
* If set to `_blank`, `rel="noopener noreferrer"` is automatically added to the rendered node.
*/
target?: string;
/** @default false */
loading?: boolean;
/**
* Makes the button take up the full width of its container
* @default false
*/
block?: boolean;
/**
* Sets the size of the button
* @default lg
* */
size?: ButtonSize;
/**
* Sets a visual hierarchy amongst the buttons displayed on the screen
* @default 'primary'
*/
priority?: ButtonPriority;
/**
* Emphasises the nature of the button's action
* @default default
*/
sentiment?: ButtonSentiment;
/** Accessory to be displayed before the label. Not supported by the `lg` size. */
addonStart?: ButtonAddonStart;
/** Accessory to be displayed after the label. Not supported by the `lg` size. */
addonEnd?: ButtonAddonEnd;
className?: string;
children?: ReactNode;
}
export type ButtonElementProps = Omit<
ButtonHTMLAttributes,
'disabled' | 'className'
> &
CommonProps & {
as?: 'button';
};
export type AnchorElementProps = Omit<
AnchorHTMLAttributes,
'type' | 'disabled' | 'href' | 'className'
> &
CommonProps & {
as?: 'a';
};
export type ButtonProps = ButtonElementProps | AnchorElementProps;