UNPKG

5.29 kBTypeScriptView Raw
1/// <reference types="react" />
2import { AbstractPureComponent2, IRef } from "../../common";
3import { HTMLInputProps, IControlledProps, ControlledProps2, IntentProps, Props, MaybeElement } from "../../common/props";
4import { IconName } from "../icon/icon";
5export declare type InputGroupProps = IInputGroupProps;
6/**
7 * @deprecated use IInputGroupProps2.
8 *
9 * NOTE: This interface does not extend HTMLInputProps due to incompatiblity with `IControlledProps`.
10 * Instead, we union the props in the component definition, which does work and properly disallows `string[]` values.
11 */
12export interface IInputGroupProps extends IControlledProps, IntentProps, Props {
13 /**
14 * Set this to `true` if you will be controlling the `value` of this input with asynchronous updates.
15 * These may occur if you do not immediately call setState in a parent component with the value from
16 * the `onChange` handler, or if working with certain libraries like __redux-form__.
17 *
18 * @default false
19 */
20 asyncControl?: boolean;
21 /**
22 * Whether the input is non-interactive.
23 * Note that `rightElement` must be disabled separately; this prop will not affect it.
24 *
25 * @default false
26 */
27 disabled?: boolean;
28 /**
29 * Whether the component should take up the full width of its container.
30 */
31 fill?: boolean;
32 /** Ref handler or a ref object that receives HTML `<input>` element backing this component. */
33 inputRef?: IRef<HTMLInputElement>;
34 /**
35 * Element to render on the left side of input. This prop is mutually exclusive
36 * with `leftIcon`.
37 */
38 leftElement?: JSX.Element;
39 /**
40 * Name of a Blueprint UI icon to render on the left side of the input group,
41 * before the user's cursor. This prop is mutually exclusive with `leftElement`.
42 * Usage with content is deprecated. Use `leftElement` for elements.
43 */
44 leftIcon?: IconName | MaybeElement;
45 /** Whether this input should use large styles. */
46 large?: boolean;
47 /** Whether this input should use small styles. */
48 small?: boolean;
49 /** Placeholder text in the absence of any value. */
50 placeholder?: string;
51 /**
52 * Element to render on right side of input.
53 * For best results, use a minimal button, tag, or small spinner.
54 */
55 rightElement?: JSX.Element;
56 /** Whether the input (and any buttons) should appear with rounded caps. */
57 round?: boolean;
58 /**
59 * HTML `input` type attribute.
60 *
61 * @default "text"
62 */
63 type?: string;
64}
65export declare type InputGroupProps2 = IInputGroupProps2;
66/** @deprecated use InputGroupProps2 */
67export interface IInputGroupProps2 extends Omit<HTMLInputProps, keyof ControlledProps2>, ControlledProps2, IntentProps, Props {
68 /**
69 * Set this to `true` if you will be controlling the `value` of this input with asynchronous updates.
70 * These may occur if you do not immediately call setState in a parent component with the value from
71 * the `onChange` handler, or if working with certain libraries like __redux-form__.
72 *
73 * @default false
74 */
75 asyncControl?: boolean;
76 /**
77 * Whether the input is non-interactive.
78 * Note that `rightElement` must be disabled separately; this prop will not affect it.
79 *
80 * @default false
81 */
82 disabled?: boolean;
83 /**
84 * Whether the component should take up the full width of its container.
85 */
86 fill?: boolean;
87 /** Ref handler or a ref object that receives HTML `<input>` element backing this component. */
88 inputRef?: IRef<HTMLInputElement>;
89 /**
90 * Element to render on the left side of input. This prop is mutually exclusive
91 * with `leftIcon`.
92 */
93 leftElement?: JSX.Element;
94 /**
95 * Name of a Blueprint UI icon to render on the left side of the input group,
96 * before the user's cursor. This prop is mutually exclusive with `leftElement`.
97 * Usage with content is deprecated. Use `leftElement` for elements.
98 */
99 leftIcon?: IconName | MaybeElement;
100 /** Whether this input should use large styles. */
101 large?: boolean;
102 /** Whether this input should use small styles. */
103 small?: boolean;
104 /** Placeholder text in the absence of any value. */
105 placeholder?: string;
106 /**
107 * Element to render on right side of input.
108 * For best results, use a minimal button, tag, or small spinner.
109 */
110 rightElement?: JSX.Element;
111 /** Whether the input (and any buttons) should appear with rounded caps. */
112 round?: boolean;
113 /**
114 * HTML `input` type attribute.
115 *
116 * @default "text"
117 */
118 type?: string;
119}
120export interface IInputGroupState {
121 leftElementWidth?: number;
122 rightElementWidth?: number;
123}
124export declare class InputGroup extends AbstractPureComponent2<InputGroupProps2, IInputGroupState> {
125 static displayName: string;
126 state: IInputGroupState;
127 private leftElement;
128 private rightElement;
129 private refHandlers;
130 render(): JSX.Element;
131 componentDidMount(): void;
132 componentDidUpdate(prevProps: InputGroupProps2): void;
133 protected validateProps(props: InputGroupProps2): void;
134 private maybeRenderLeftElement;
135 private maybeRenderRightElement;
136 private updateInputWidth;
137}