UNPKG

4 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
31 * and the button will be disabled (_even if_ `disabled={false}`). The width of the button is
32 * not affected by the value of this prop.
33 *
34 * @default false
35 */
36 loading?: boolean;
37 /** Whether this button should use minimal styles. */
38 minimal?: boolean;
39 /** Whether this button should use outlined styles. */
40 outlined?: boolean;
41 /** Name of a Blueprint UI icon (or an icon element) to render after the text. */
42 rightIcon?: IconName | MaybeElement;
43 /** Whether this button should use small styles. */
44 small?: boolean;
45 /**
46 * HTML `type` attribute of button. Accepted values are `"button"`, `"submit"`, and `"reset"`.
47 * Note that this prop has no effect on `AnchorButton`; it only affects `Button`.
48 *
49 * @default "button"
50 */
51 type?: "submit" | "reset" | "button";
52}
53/** @deprecated use AnchorButtonProps */
54export declare type IAnchorButtonProps = ButtonProps<HTMLAnchorElement>;
55export declare type AnchorButtonProps = IAnchorButtonProps;
56export interface IButtonState {
57 isActive: boolean;
58}
59export declare abstract class AbstractButton<E extends HTMLButtonElement | HTMLAnchorElement> extends AbstractPureComponent2<ButtonProps<E> & (E extends HTMLButtonElement ? React.ButtonHTMLAttributes<HTMLButtonElement> : React.AnchorHTMLAttributes<HTMLAnchorElement>), IButtonState> {
60 state: {
61 isActive: boolean;
62 };
63 protected abstract buttonRef: HTMLElement | null;
64 private currentKeyDown?;
65 abstract render(): JSX.Element;
66 protected getCommonButtonProps(): {
67 className: string;
68 disabled: boolean | (ButtonProps<E> & (E extends HTMLButtonElement ? React.ButtonHTMLAttributes<HTMLButtonElement> : React.AnchorHTMLAttributes<HTMLAnchorElement>))["disabled"];
69 onBlur: (e: React.FocusEvent<any, Element>) => void;
70 onClick: (ButtonProps<E> & (E extends HTMLButtonElement ? React.ButtonHTMLAttributes<HTMLButtonElement> : React.AnchorHTMLAttributes<HTMLAnchorElement>))["onClick"] | undefined;
71 onKeyDown: (e: React.KeyboardEvent<any>) => void;
72 onKeyUp: (e: React.KeyboardEvent<any>) => void;
73 tabIndex: number | (ButtonProps<E> & (E extends HTMLButtonElement ? React.ButtonHTMLAttributes<HTMLButtonElement> : React.AnchorHTMLAttributes<HTMLAnchorElement>))["tabIndex"] | undefined;
74 };
75 protected handleKeyDown: (e: React.KeyboardEvent<any>) => void;
76 protected handleKeyUp: (e: React.KeyboardEvent<any>) => void;
77 protected handleBlur: (e: React.FocusEvent<any>) => void;
78 protected renderChildren(): React.ReactNode;
79}