UNPKG

4.62 kBTypeScriptView Raw
1import * as React from "react";
2import { AbstractPureComponent2, Alignment } from "../../common";
3import { HTMLInputProps, Props } from "../../common/props";
4export declare type ControlProps = IControlProps;
5/** @deprecated use ControlProps */
6export interface IControlProps extends Props, HTMLInputProps {
7 /**
8 * Alignment of the indicator within container.
9 *
10 * @default Alignment.LEFT
11 */
12 alignIndicator?: Alignment;
13 /** Whether the control is checked. */
14 checked?: boolean;
15 /** JSX label for the control. */
16 children?: React.ReactNode;
17 /** Whether the control is initially checked (uncontrolled mode). */
18 defaultChecked?: boolean;
19 /** Whether the control is non-interactive. */
20 disabled?: boolean;
21 /** Ref handler that receives HTML `<input>` element backing this component. */
22 inputRef?: React.Ref<HTMLInputElement>;
23 /** Whether the control should appear as an inline element. */
24 inline?: boolean;
25 /**
26 * Text label for the control.
27 *
28 * Use `children` or `labelElement` to supply JSX content. This prop actually supports JSX elements,
29 * but TypeScript will throw an error because `HTMLAttributes` only allows strings.
30 */
31 label?: string;
32 /**
33 * JSX Element label for the control.
34 *
35 * This prop is a workaround for TypeScript consumers as the type definition for `label` only
36 * accepts strings. JavaScript consumers can provide a JSX element directly to `label`.
37 */
38 labelElement?: React.ReactNode;
39 /** Whether this control should use large styles. */
40 large?: boolean;
41 /** Event handler invoked when input value is changed. */
42 onChange?: React.FormEventHandler<HTMLInputElement>;
43 /**
44 * Name of the HTML tag that wraps the checkbox.
45 *
46 * By default a `<label>` is used, which effectively enlarges the click
47 * target to include all of its children. Supply a different tag name if
48 * this behavior is undesirable or you're listening to click events from a
49 * parent element (as the label can register duplicate clicks).
50 *
51 * @default "label"
52 */
53 tagName?: keyof JSX.IntrinsicElements;
54}
55export declare type SwitchProps = ISwitchProps;
56/** @deprecated use SwitchProps */
57export interface ISwitchProps extends ControlProps {
58 /**
59 * Text to display inside the switch indicator when checked.
60 * If `innerLabel` is provided and this prop is omitted, then `innerLabel`
61 * will be used for both states.
62 *
63 * @default innerLabel
64 */
65 innerLabelChecked?: string;
66 /**
67 * Text to display inside the switch indicator when unchecked.
68 */
69 innerLabel?: string;
70}
71/**
72 * Switch component.
73 *
74 * @see https://blueprintjs.com/docs/#core/components/switch
75 */
76export declare class Switch extends AbstractPureComponent2<SwitchProps> {
77 static displayName: string;
78 render(): JSX.Element;
79}
80/** @deprecated use RadioProps */
81export declare type IRadioProps = ControlProps;
82export declare type RadioProps = IRadioProps;
83/**
84 * Radio component.
85 *
86 * @see https://blueprintjs.com/docs/#core/components/radio
87 */
88export declare class Radio extends AbstractPureComponent2<RadioProps> {
89 static displayName: string;
90 render(): JSX.Element;
91}
92export declare type CheckboxProps = ICheckboxProps;
93/** @deprecated use CheckboxProps */
94export interface ICheckboxProps extends ControlProps {
95 /** Whether this checkbox is initially indeterminate (uncontrolled mode). */
96 defaultIndeterminate?: boolean;
97 /**
98 * Whether this checkbox is indeterminate, or "partially checked."
99 * The checkbox will appear with a small dash instead of a tick to indicate that the value
100 * is not exactly true or false.
101 *
102 * Note that this prop takes precendence over `checked`: if a checkbox is marked both
103 * `checked` and `indeterminate` via props, it will appear as indeterminate in the DOM.
104 */
105 indeterminate?: boolean;
106}
107export interface ICheckboxState {
108 indeterminate: boolean;
109}
110/**
111 * Checkbox component.
112 *
113 * @see https://blueprintjs.com/docs/#core/components/checkbox
114 */
115export declare class Checkbox extends AbstractPureComponent2<CheckboxProps, ICheckboxState> {
116 static displayName: string;
117 static getDerivedStateFromProps({ indeterminate }: CheckboxProps): ICheckboxState | null;
118 state: ICheckboxState;
119 input: HTMLInputElement | null;
120 private handleInputRef;
121 render(): JSX.Element;
122 componentDidMount(): void;
123 componentDidUpdate(prevProps: CheckboxProps): void;
124 private updateIndeterminate;
125 private handleChange;
126}