UNPKG

reblend-ui

Version:

Utilities for creating robust overlay components

53 lines (52 loc) 2.08 kB
import { AriaRole, ButtonHTMLAttributes, FC, ReblendNode, RefAttributes } from 'reblendjs'; export type ButtonType = 'button' | 'reset' | 'submit'; export interface AnchorOptions { href?: string; rel?: string; target?: string; } export interface UseButtonPropsOptions extends AnchorOptions { type?: ButtonType; disabled?: boolean; onClick?: Reblend.EventHandler<Reblend.MouseEvent | Reblend.KeyboardEvent>; tabIndex?: number | string; tagName?: keyof JSX.IntrinsicElements; role?: AriaRole | undefined; } export declare function isTrivialHref(href?: string): boolean; export interface AriaButtonProps { type?: ButtonType | undefined; disabled: boolean | undefined; role?: Reblend.AriaRole; tabIndex?: number | string | undefined; href?: string | undefined; target?: string | undefined; rel?: string | undefined; 'aria-disabled'?: true | undefined; onClick?: (event: Reblend.MouseEvent | Reblend.KeyboardEvent) => void; onKeyDown?: (event: Reblend.KeyboardEvent) => void; } export interface UseButtonPropsMetadata { tagName: Reblend.ElementType; } export declare function useButtonProps({ tagName, disabled, href, target, rel, role, onClick, tabIndex, type, }: UseButtonPropsOptions): [AriaButtonProps, UseButtonPropsMetadata]; export interface BaseButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> { /** * Control the underlying rendered element directly by passing in a valid * component type */ as?: keyof Reblend.JSX.IntrinsicElements | undefined; /** The disabled state of the button */ disabled?: boolean | undefined; /** Optionally specify an href to render a `<a>` tag styled as a button */ href?: string | undefined; /** Anchor target, when rendering an anchor as a button */ target?: string | undefined; rel?: string | undefined; ref?: RefAttributes<HTMLButtonElement>['ref']; children: ReblendNode; } export interface ButtonProps extends BaseButtonProps { } declare const Button: FC<ButtonProps>; export default Button;