UNPKG

2.36 kBTypeScriptView Raw
1import * as React from "react";
2import { AbstractPureComponent2 } from "../../common";
3export interface IAsyncControllableInputProps extends React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> {
4 inputRef?: React.LegacyRef<HTMLInputElement>;
5}
6declare type InputValue = IAsyncControllableInputProps["value"];
7export interface IAsyncControllableInputState {
8 /**
9 * Whether we are in the middle of a composition event.
10 *
11 * @default false
12 */
13 isComposing: boolean;
14 /**
15 * The source of truth for the input value. This is not updated during IME composition.
16 * It may be updated by a parent component.
17 *
18 * @default ""
19 */
20 value: InputValue;
21 /**
22 * The latest input value, which updates during IME composition. Defaults to props.value.
23 */
24 nextValue: InputValue;
25 /**
26 * Whether there is a pending update we are expecting from a parent component.
27 *
28 * @default false
29 */
30 hasPendingUpdate: boolean;
31}
32/**
33 * A stateful wrapper around the low-level <input> component which works around a
34 * [React bug](https://github.com/facebook/react/issues/3926). This bug is reproduced when an input
35 * receives CompositionEvents (for example, through IME composition) and has its value prop updated
36 * asychronously. This might happen if a component chooses to do async validation of a value
37 * returned by the input's `onChange` callback.
38 *
39 * Note: this component does not apply any Blueprint-specific styling.
40 */
41export declare class AsyncControllableInput extends AbstractPureComponent2<IAsyncControllableInputProps, IAsyncControllableInputState> {
42 static displayName: string;
43 /**
44 * The amount of time (in milliseconds) which the input will wait after a compositionEnd event before
45 * unlocking its state value for external updates via props. See `handleCompositionEnd` for more details.
46 */
47 static COMPOSITION_END_DELAY: number;
48 state: IAsyncControllableInputState;
49 private cancelPendingCompositionEnd;
50 static getDerivedStateFromProps(nextProps: IAsyncControllableInputProps, nextState: IAsyncControllableInputState): Partial<IAsyncControllableInputState> | null;
51 render(): JSX.Element;
52 private handleCompositionStart;
53 private handleCompositionEnd;
54 private handleChange;
55}
56export {};