UNPKG

4.08 kBTypeScriptView Raw
1import * as React from 'react';
2import { Autofill } from './Autofill';
3import { IRefObject, KeyCodes } from '../../Utilities';
4/**
5 * {@docCategory Autofill}
6 */
7export interface IAutofill {
8 /**
9 * The current index of the cursor in the input area. Returns -1 if the input element
10 * is not ready.
11 */
12 cursorLocation: number | null;
13 /**
14 * A boolean for whether or not there is a value selected in the input area.
15 */
16 isValueSelected: boolean;
17 /**
18 * The current text value that the user has entered.
19 */
20 value: string;
21 /**
22 * The current index of where the selection starts. Returns -1 if the input element
23 * is not ready.
24 */
25 selectionStart: number | null;
26 /**
27 * the current index of where the selection ends. Returns -1 if the input element
28 * is not ready.
29 */
30 selectionEnd: number | null;
31 /**
32 * The current input element.
33 */
34 inputElement: HTMLInputElement | null;
35 /**
36 * Focus the input element.
37 */
38 focus(): void;
39 /**
40 * Clear all text in the input. Sets value to '';
41 */
42 clear(): void;
43}
44/**
45 * {@docCategory Autofill}
46 */
47export interface IAutofillProps extends React.InputHTMLAttributes<HTMLInputElement | Autofill> {
48 /**
49 * Gets the compoonent ref.
50 */
51 componentRef?: IRefObject<IAutofill>;
52 /**
53 * The suggested autofill value that will display.
54 */
55 suggestedDisplayValue?: string;
56 /**
57 * A callback for when the current input value changes.
58 *
59 * @param composing - true if the change event was triggered while the
60 * inner input was in the middle of a multi-character composition.
61 * (for example, jp-hiragana IME input)
62 */
63 onInputValueChange?: (newValue?: string, composing?: boolean) => void;
64 /**
65 * When the user uses left arrow, right arrow, clicks, or deletes text autofill is disabled
66 * Since the user has taken control. It is automatically reenabled when the user enters text and the
67 * cursor is at the end of the text in the input box. This specifies other key presses that will reenabled
68 * autofill.
69 * @defaultvalue [KeyCodes.down, KeyCodes.up]
70 */
71 enableAutofillOnKeyPress?: KeyCodes[];
72 /**
73 * The default value to be visible. This is different from placeholder
74 * because it actually sets the current value of the picker
75 * Note: This will only be set upon component creation
76 * and will not update with subsequent prop updates.
77 */
78 defaultVisibleValue?: string;
79 /**
80 * Handler for checking and updating the value if needed
81 * in componentWillReceiveProps
82 *
83 * @returns - the updated value to set, if needed
84 */
85 updateValueInWillReceiveProps?: () => string | null;
86 /**
87 * Handler for checking if the full value of the input should
88 * be seleced in componentDidUpdate
89 *
90 * @returns - should the full value of the input be selected?
91 */
92 shouldSelectFullInputValueInComponentDidUpdate?: () => boolean;
93 /**
94 * A callback used to modify the input string.
95 *
96 * @param composing - true if the change event was triggered while the
97 * inner input was in the middle of a multi-character composition.
98 * (for example, jp-hiragana IME input)
99 */
100 onInputChange?: (value: string, composing: boolean) => string;
101 /**
102 * Should the value of the input be selected? True if we're focused on our input, false otherwise.
103 * We need to explicitly not select the text in the autofill if we are no longer focused.
104 * In IE11, selecting a input will also focus the input, causing other element's focus to be stolen.
105 */
106 preventValueSelection?: boolean;
107}
108/**
109 * Deprecated, do not use.
110 * @deprecated do not use, will be removed in 6.0
111 * {@docCategory Autofill}
112 */
113export interface IBaseAutoFill extends IAutofill {
114}
115/**
116 * Deprecated, do not use.
117 * @deprecated do not use, will be removed in 6.0
118 * {@docCategory Autofill}
119 */
120export interface IBaseAutoFillProps extends IAutofillProps {
121}