UNPKG

4.11 kBTypeScriptView Raw
1import * as React from "react";
2import { AbstractPureComponent2, ActionProps, Alignment, IElementRefProps, MaybeElement } from "../../common";
3import { IconName } from "../icon/icon";
4export declare type ButtonProps<E extends HTMLButtonElement | HTMLAnchorElement = HTMLButtonElement> = IButtonProps<E>;
5/** @deprecated use ButtonProps */
6export interface IButtonProps<E extends HTMLButtonElement | HTMLAnchorElement = HTMLButtonElement> extends ActionProps, IElementRefProps<E> {
7 /**
8 * If set to `true`, the button will display in an active state.
9 * This is equivalent to setting `className={Classes.ACTIVE}`.
10 *
11 * @default false
12 */
13 active?: boolean;
14 /**
15 * Text alignment within button. By default, icons and text will be centered
16 * within the button. Passing `"left"` or `"right"` will align the button
17 * text to that side and push `icon` and `rightIcon` to either edge. Passing
18 * `"center"` will center the text and icons together.
19 *
20 * @default Alignment.CENTER
21 */
22 alignText?: Alignment;
23 /** Button contents. */
24 children?: React.ReactNode;
25 /** Whether this button should expand to fill its container. */
26 fill?: boolean;
27 /** Whether this button should use large styles. */
28 large?: boolean;
29 /**
30 * If set to `true`, the button will display a centered loading spinner instead of its contents, and the button will be disabled.
31 * The width of the button is not affected by the value of this prop.
32 *
33 * @default false
34 */
35 loading?: boolean;
36 /** Whether this button should use minimal styles. */
37 minimal?: boolean;
38 /** Whether this button should use outlined styles. */
39 outlined?: boolean;
40 /** Name of a Blueprint UI icon (or an icon element) to render after the text. */
41 rightIcon?: IconName | MaybeElement;
42 /** Whether this button should use small styles. */
43 small?: boolean;
44 /**
45 * HTML `type` attribute of button. Accepted values are `"button"`, `"submit"`, and `"reset"`.
46 * Note that this prop has no effect on `AnchorButton`; it only affects `Button`.
47 *
48 * @default "button"
49 */
50 type?: "submit" | "reset" | "button";
51}
52/** @deprecated use AnchorButtonProps */
53export declare type IAnchorButtonProps = ButtonProps<HTMLAnchorElement>;
54export declare type AnchorButtonProps = IAnchorButtonProps;
55export interface IButtonState {
56 isActive: boolean;
57}
58export declare abstract class AbstractButton<E extends HTMLButtonElement | HTMLAnchorElement> extends AbstractPureComponent2<ButtonProps<E> & (E extends HTMLButtonElement ? React.ButtonHTMLAttributes<HTMLButtonElement> : React.AnchorHTMLAttributes<HTMLAnchorElement>), IButtonState> {
59 state: {
60 isActive: boolean;
61 };
62 protected abstract buttonRef: HTMLElement | null;
63 private currentKeyDown?;
64 abstract render(): JSX.Element;
65 protected getCommonButtonProps(): {
66 className: string;
67 disabled: (ButtonProps<E> & (E extends HTMLButtonElement ? React.ButtonHTMLAttributes<HTMLButtonElement> : React.AnchorHTMLAttributes<HTMLAnchorElement>))["loading"] | (ButtonProps<E> & (E extends HTMLButtonElement ? React.ButtonHTMLAttributes<HTMLButtonElement> : React.AnchorHTMLAttributes<HTMLAnchorElement>))["disabled"] | undefined;
68 onBlur: (e: React.FocusEvent<any>) => void;
69 onClick: (ButtonProps<E> & (E extends HTMLButtonElement ? React.ButtonHTMLAttributes<HTMLButtonElement> : React.AnchorHTMLAttributes<HTMLAnchorElement>))["onClick"] | undefined;
70 onKeyDown: (e: React.KeyboardEvent<any>) => void;
71 onKeyUp: (e: React.KeyboardEvent<any>) => void;
72 tabIndex: number | (ButtonProps<E> & (E extends HTMLButtonElement ? React.ButtonHTMLAttributes<HTMLButtonElement> : React.AnchorHTMLAttributes<HTMLAnchorElement>))["tabIndex"] | undefined;
73 };
74 protected handleKeyDown: (e: React.KeyboardEvent<any>) => void;
75 protected handleKeyUp: (e: React.KeyboardEvent<any>) => void;
76 protected handleBlur: (e: React.FocusEvent<any>) => void;
77 protected renderChildren(): React.ReactNode;
78}