UNPKG

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