UNPKG

@withjoy/joykit

Version:

UI Component Library for Joy web

51 lines (50 loc) 1.92 kB
import * as React from 'react'; import { IconSource } from '../components/Icon'; import { BaseComponentProps } from './props'; import { ResponsiveValue } from './styledSystem/types'; export declare type ButtonSize = 'small' | 'medium'; export declare type Intent = 'primary' | 'secondary'; export declare type ButtonVariant = 'success' | 'danger' | 'info'; export interface AbstractButtonProps extends BaseComponentProps { /** Content to displayed */ children?: React.ReactNode; className?: string; /** Whether or not this button can be interacted with */ disabled?: boolean; /** Whether or not it should expand to the width of its container */ fill?: ResponsiveValue<boolean>; /** * Name of JoyKit icon or custom icon to be displayed on the left. * * Can be used in lieu of children, at */ icon?: IconSource; /** Name of JoyKit icon or custom icon to be displayed on the right. */ iconRight?: IconSource; /** * To show different levels of emphasis */ intent?: Intent; /** Replaces button text with spinner while a background action is being performed */ loading?: boolean; size?: ButtonSize; /** * Visual intent color to apply */ variant?: ButtonVariant; } export declare const ABSTRACT_BUTTON_PROPS: string[]; export interface CommonButtonProps { onClick?: React.MouseEventHandler<HTMLElement>; disabled?: boolean; tabIndex?: number; } export declare abstract class AbstractButton<P extends React.HTMLAttributes<any>, S = {}> extends React.PureComponent<AbstractButtonProps & P, S> { /** * Override native button attributes depending upon state */ protected getCommonButtonProps: () => CommonButtonProps; abstract render(): React.ReactNode; protected renderChildren: () => React.ReactNode; private renderContent; }