1*af2ec015STomasz Sapeta/**
2*af2ec015STomasz Sapeta * Copyright (c) Meta Platforms, Inc. and affiliates.
3*af2ec015STomasz Sapeta *
4*af2ec015STomasz Sapeta * This source code is licensed under the MIT license found in the
5*af2ec015STomasz Sapeta * LICENSE file in the root directory of this source tree.
6*af2ec015STomasz Sapeta *
7*af2ec015STomasz Sapeta * @format
8*af2ec015STomasz Sapeta */
9*af2ec015STomasz Sapeta
10*af2ec015STomasz Sapetaimport type * as React from 'react';
11*af2ec015STomasz Sapetaimport {Constructor} from '../../../types/private/Utilities';
12*af2ec015STomasz Sapetaimport {TimerMixin} from '../../../types/private/TimerMixin';
13*af2ec015STomasz Sapetaimport {
14*af2ec015STomasz Sapeta  HostComponent,
15*af2ec015STomasz Sapeta  NativeMethods,
16*af2ec015STomasz Sapeta} from '../../../types/public/ReactNativeTypes';
17*af2ec015STomasz Sapetaimport {ColorValue, StyleProp} from '../../StyleSheet/StyleSheet';
18*af2ec015STomasz Sapetaimport {TextStyle} from '../../StyleSheet/StyleSheetTypes';
19*af2ec015STomasz Sapetaimport {
20*af2ec015STomasz Sapeta  NativeSyntheticEvent,
21*af2ec015STomasz Sapeta  NativeTouchEvent,
22*af2ec015STomasz Sapeta  TargetedEvent,
23*af2ec015STomasz Sapeta} from '../../Types/CoreEventTypes';
24*af2ec015STomasz Sapetaimport EventEmitter from '../../vendor/emitter/EventEmitter';
25*af2ec015STomasz Sapetaimport {AccessibilityProps} from '../View/ViewAccessibility';
26*af2ec015STomasz Sapetaimport {ViewProps} from '../View/ViewPropTypes';
27*af2ec015STomasz Sapeta
28*af2ec015STomasz Sapetaexport type KeyboardType =
29*af2ec015STomasz Sapeta  | 'default'
30*af2ec015STomasz Sapeta  | 'number-pad'
31*af2ec015STomasz Sapeta  | 'decimal-pad'
32*af2ec015STomasz Sapeta  | 'numeric'
33*af2ec015STomasz Sapeta  | 'email-address'
34*af2ec015STomasz Sapeta  | 'phone-pad'
35*af2ec015STomasz Sapeta  | 'url';
36*af2ec015STomasz Sapetaexport type KeyboardTypeIOS =
37*af2ec015STomasz Sapeta  | 'ascii-capable'
38*af2ec015STomasz Sapeta  | 'numbers-and-punctuation'
39*af2ec015STomasz Sapeta  | 'name-phone-pad'
40*af2ec015STomasz Sapeta  | 'twitter'
41*af2ec015STomasz Sapeta  | 'web-search';
42*af2ec015STomasz Sapetaexport type KeyboardTypeAndroid = 'visible-password';
43*af2ec015STomasz Sapetaexport type KeyboardTypeOptions =
44*af2ec015STomasz Sapeta  | KeyboardType
45*af2ec015STomasz Sapeta  | KeyboardTypeAndroid
46*af2ec015STomasz Sapeta  | KeyboardTypeIOS;
47*af2ec015STomasz Sapeta
48*af2ec015STomasz Sapetaexport type InputModeOptions =
49*af2ec015STomasz Sapeta  | 'none'
50*af2ec015STomasz Sapeta  | 'text'
51*af2ec015STomasz Sapeta  | 'decimal'
52*af2ec015STomasz Sapeta  | 'numeric'
53*af2ec015STomasz Sapeta  | 'tel'
54*af2ec015STomasz Sapeta  | 'search'
55*af2ec015STomasz Sapeta  | 'email'
56*af2ec015STomasz Sapeta  | 'url';
57*af2ec015STomasz Sapeta
58*af2ec015STomasz Sapetaexport type ReturnKeyType = 'done' | 'go' | 'next' | 'search' | 'send';
59*af2ec015STomasz Sapetaexport type ReturnKeyTypeAndroid = 'none' | 'previous';
60*af2ec015STomasz Sapetaexport type ReturnKeyTypeIOS =
61*af2ec015STomasz Sapeta  | 'default'
62*af2ec015STomasz Sapeta  | 'google'
63*af2ec015STomasz Sapeta  | 'join'
64*af2ec015STomasz Sapeta  | 'route'
65*af2ec015STomasz Sapeta  | 'yahoo'
66*af2ec015STomasz Sapeta  | 'emergency-call';
67*af2ec015STomasz Sapeta
68*af2ec015STomasz Sapetaexport type ReturnKeyTypeOptions =
69*af2ec015STomasz Sapeta  | ReturnKeyType
70*af2ec015STomasz Sapeta  | ReturnKeyTypeAndroid
71*af2ec015STomasz Sapeta  | ReturnKeyTypeIOS;
72*af2ec015STomasz Sapeta
73*af2ec015STomasz Sapetatype DataDetectorTypes =
74*af2ec015STomasz Sapeta  | 'phoneNumber'
75*af2ec015STomasz Sapeta  | 'link'
76*af2ec015STomasz Sapeta  | 'address'
77*af2ec015STomasz Sapeta  | 'calendarEvent'
78*af2ec015STomasz Sapeta  | 'none'
79*af2ec015STomasz Sapeta  | 'all';
80*af2ec015STomasz Sapeta
81*af2ec015STomasz Sapeta/**
82*af2ec015STomasz Sapeta * DocumentSelectionState is responsible for maintaining selection information
83*af2ec015STomasz Sapeta * for a document.
84*af2ec015STomasz Sapeta *
85*af2ec015STomasz Sapeta * It is intended for use by AbstractTextEditor-based components for
86*af2ec015STomasz Sapeta * identifying the appropriate start/end positions to modify the
87*af2ec015STomasz Sapeta * DocumentContent, and for programmatically setting browser selection when
88*af2ec015STomasz Sapeta * components re-render.
89*af2ec015STomasz Sapeta */
90*af2ec015STomasz Sapetaexport interface DocumentSelectionState extends EventEmitter {
91*af2ec015STomasz Sapeta  new (anchor: number, focus: number): DocumentSelectionState;
92*af2ec015STomasz Sapeta
93*af2ec015STomasz Sapeta  /**
94*af2ec015STomasz Sapeta   * Apply an update to the state. If either offset value has changed,
95*af2ec015STomasz Sapeta   * set the values and emit the `change` event. Otherwise no-op.
96*af2ec015STomasz Sapeta   *
97*af2ec015STomasz Sapeta   */
98*af2ec015STomasz Sapeta  update(anchor: number, focus: number): void;
99*af2ec015STomasz Sapeta
100*af2ec015STomasz Sapeta  /**
101*af2ec015STomasz Sapeta   * Given a max text length, constrain our selection offsets to ensure
102*af2ec015STomasz Sapeta   * that the selection remains strictly within the text range.
103*af2ec015STomasz Sapeta   *
104*af2ec015STomasz Sapeta   */
105*af2ec015STomasz Sapeta  constrainLength(maxLength: number): void;
106*af2ec015STomasz Sapeta
107*af2ec015STomasz Sapeta  focus(): void;
108*af2ec015STomasz Sapeta  blur(): void;
109*af2ec015STomasz Sapeta  hasFocus(): boolean;
110*af2ec015STomasz Sapeta  isCollapsed(): boolean;
111*af2ec015STomasz Sapeta  isBackward(): boolean;
112*af2ec015STomasz Sapeta
113*af2ec015STomasz Sapeta  getAnchorOffset(): number;
114*af2ec015STomasz Sapeta  getFocusOffset(): number;
115*af2ec015STomasz Sapeta  getStartOffset(): number;
116*af2ec015STomasz Sapeta  getEndOffset(): number;
117*af2ec015STomasz Sapeta  overlaps(start: number, end: number): boolean;
118*af2ec015STomasz Sapeta}
119*af2ec015STomasz Sapeta
120*af2ec015STomasz Sapeta/**
121*af2ec015STomasz Sapeta * IOS Specific properties for TextInput
122*af2ec015STomasz Sapeta * @see https://reactnative.dev/docs/textinput#props
123*af2ec015STomasz Sapeta */
124*af2ec015STomasz Sapetaexport interface TextInputIOSProps {
125*af2ec015STomasz Sapeta  /**
126*af2ec015STomasz Sapeta   * enum('never', 'while-editing', 'unless-editing', 'always')
127*af2ec015STomasz Sapeta   * When the clear button should appear on the right side of the text view
128*af2ec015STomasz Sapeta   */
129*af2ec015STomasz Sapeta  clearButtonMode?:
130*af2ec015STomasz Sapeta    | 'never'
131*af2ec015STomasz Sapeta    | 'while-editing'
132*af2ec015STomasz Sapeta    | 'unless-editing'
133*af2ec015STomasz Sapeta    | 'always'
134*af2ec015STomasz Sapeta    | undefined;
135*af2ec015STomasz Sapeta
136*af2ec015STomasz Sapeta  /**
137*af2ec015STomasz Sapeta   * If true, clears the text field automatically when editing begins
138*af2ec015STomasz Sapeta   */
139*af2ec015STomasz Sapeta  clearTextOnFocus?: boolean | undefined;
140*af2ec015STomasz Sapeta
141*af2ec015STomasz Sapeta  /**
142*af2ec015STomasz Sapeta   * Determines the types of data converted to clickable URLs in the text input.
143*af2ec015STomasz Sapeta   * Only valid if `multiline={true}` and `editable={false}`.
144*af2ec015STomasz Sapeta   * By default no data types are detected.
145*af2ec015STomasz Sapeta   *
146*af2ec015STomasz Sapeta   * You can provide one type or an array of many types.
147*af2ec015STomasz Sapeta   *
148*af2ec015STomasz Sapeta   * Possible values for `dataDetectorTypes` are:
149*af2ec015STomasz Sapeta   *
150*af2ec015STomasz Sapeta   * - `'phoneNumber'`
151*af2ec015STomasz Sapeta   * - `'link'`
152*af2ec015STomasz Sapeta   * - `'address'`
153*af2ec015STomasz Sapeta   * - `'calendarEvent'`
154*af2ec015STomasz Sapeta   * - `'none'`
155*af2ec015STomasz Sapeta   * - `'all'`
156*af2ec015STomasz Sapeta   */
157*af2ec015STomasz Sapeta  dataDetectorTypes?: DataDetectorTypes | DataDetectorTypes[] | undefined;
158*af2ec015STomasz Sapeta
159*af2ec015STomasz Sapeta  /**
160*af2ec015STomasz Sapeta   * If true, the keyboard disables the return key when there is no text and automatically enables it when there is text.
161*af2ec015STomasz Sapeta   * The default value is false.
162*af2ec015STomasz Sapeta   */
163*af2ec015STomasz Sapeta  enablesReturnKeyAutomatically?: boolean | undefined;
164*af2ec015STomasz Sapeta
165*af2ec015STomasz Sapeta  /**
166*af2ec015STomasz Sapeta   * Determines the color of the keyboard.
167*af2ec015STomasz Sapeta   */
168*af2ec015STomasz Sapeta  keyboardAppearance?: 'default' | 'light' | 'dark' | undefined;
169*af2ec015STomasz Sapeta
170*af2ec015STomasz Sapeta  /**
171*af2ec015STomasz Sapeta   * Provide rules for your password.
172*af2ec015STomasz Sapeta   * For example, say you want to require a password with at least eight characters consisting of a mix of uppercase and lowercase letters, at least one number, and at most two consecutive characters.
173*af2ec015STomasz Sapeta   * "required: upper; required: lower; required: digit; max-consecutive: 2; minlength: 8;"
174*af2ec015STomasz Sapeta   */
175*af2ec015STomasz Sapeta  passwordRules?: string | null | undefined;
176*af2ec015STomasz Sapeta
177*af2ec015STomasz Sapeta  /**
178*af2ec015STomasz Sapeta   * If `true`, allows TextInput to pass touch events to the parent component.
179*af2ec015STomasz Sapeta   * This allows components to be swipeable from the TextInput on iOS,
180*af2ec015STomasz Sapeta   * as is the case on Android by default.
181*af2ec015STomasz Sapeta   * If `false`, TextInput always asks to handle the input (except when disabled).
182*af2ec015STomasz Sapeta   */
183*af2ec015STomasz Sapeta  rejectResponderTermination?: boolean | null | undefined;
184*af2ec015STomasz Sapeta
185*af2ec015STomasz Sapeta  /**
186*af2ec015STomasz Sapeta   * See DocumentSelectionState.js, some state that is responsible for maintaining selection information for a document
187*af2ec015STomasz Sapeta   */
188*af2ec015STomasz Sapeta  selectionState?: DocumentSelectionState | undefined;
189*af2ec015STomasz Sapeta
190*af2ec015STomasz Sapeta  /**
191*af2ec015STomasz Sapeta   * If false, disables spell-check style (i.e. red underlines). The default value is inherited from autoCorrect
192*af2ec015STomasz Sapeta   */
193*af2ec015STomasz Sapeta  spellCheck?: boolean | undefined;
194*af2ec015STomasz Sapeta
195*af2ec015STomasz Sapeta  /**
196*af2ec015STomasz Sapeta   * Give the keyboard and the system information about the expected
197*af2ec015STomasz Sapeta   * semantic meaning for the content that users enter.
198*af2ec015STomasz Sapeta   *
199*af2ec015STomasz Sapeta   * For iOS 11+ you can set `textContentType` to `username` or `password` to
200*af2ec015STomasz Sapeta   * enable autofill of login details from the device keychain.
201*af2ec015STomasz Sapeta   *
202*af2ec015STomasz Sapeta   * For iOS 12+ `newPassword` can be used to indicate a new password input the
203*af2ec015STomasz Sapeta   * user may want to save in the keychain, and `oneTimeCode` can be used to indicate
204*af2ec015STomasz Sapeta   * that a field can be autofilled by a code arriving in an SMS.
205*af2ec015STomasz Sapeta   *
206*af2ec015STomasz Sapeta   * To disable autofill, set textContentType to `none`.
207*af2ec015STomasz Sapeta   *
208*af2ec015STomasz Sapeta   * Possible values for `textContentType` are:
209*af2ec015STomasz Sapeta   *
210*af2ec015STomasz Sapeta   *  - `'none'`
211*af2ec015STomasz Sapeta   *  - `'URL'`
212*af2ec015STomasz Sapeta   *  - `'addressCity'`
213*af2ec015STomasz Sapeta   *  - `'addressCityAndState'`
214*af2ec015STomasz Sapeta   *  - `'addressState'`
215*af2ec015STomasz Sapeta   *  - `'countryName'`
216*af2ec015STomasz Sapeta   *  - `'creditCardNumber'`
217*af2ec015STomasz Sapeta   *  - `'emailAddress'`
218*af2ec015STomasz Sapeta   *  - `'familyName'`
219*af2ec015STomasz Sapeta   *  - `'fullStreetAddress'`
220*af2ec015STomasz Sapeta   *  - `'givenName'`
221*af2ec015STomasz Sapeta   *  - `'jobTitle'`
222*af2ec015STomasz Sapeta   *  - `'location'`
223*af2ec015STomasz Sapeta   *  - `'middleName'`
224*af2ec015STomasz Sapeta   *  - `'name'`
225*af2ec015STomasz Sapeta   *  - `'namePrefix'`
226*af2ec015STomasz Sapeta   *  - `'nameSuffix'`
227*af2ec015STomasz Sapeta   *  - `'nickname'`
228*af2ec015STomasz Sapeta   *  - `'organizationName'`
229*af2ec015STomasz Sapeta   *  - `'postalCode'`
230*af2ec015STomasz Sapeta   *  - `'streetAddressLine1'`
231*af2ec015STomasz Sapeta   *  - `'streetAddressLine2'`
232*af2ec015STomasz Sapeta   *  - `'sublocality'`
233*af2ec015STomasz Sapeta   *  - `'telephoneNumber'`
234*af2ec015STomasz Sapeta   *  - `'username'`
235*af2ec015STomasz Sapeta   *  - `'password'`
236*af2ec015STomasz Sapeta   *  - `'newPassword'`
237*af2ec015STomasz Sapeta   *  - `'oneTimeCode'`
238*af2ec015STomasz Sapeta   *
239*af2ec015STomasz Sapeta   */
240*af2ec015STomasz Sapeta  textContentType?:
241*af2ec015STomasz Sapeta    | 'none'
242*af2ec015STomasz Sapeta    | 'URL'
243*af2ec015STomasz Sapeta    | 'addressCity'
244*af2ec015STomasz Sapeta    | 'addressCityAndState'
245*af2ec015STomasz Sapeta    | 'addressState'
246*af2ec015STomasz Sapeta    | 'countryName'
247*af2ec015STomasz Sapeta    | 'creditCardNumber'
248*af2ec015STomasz Sapeta    | 'emailAddress'
249*af2ec015STomasz Sapeta    | 'familyName'
250*af2ec015STomasz Sapeta    | 'fullStreetAddress'
251*af2ec015STomasz Sapeta    | 'givenName'
252*af2ec015STomasz Sapeta    | 'jobTitle'
253*af2ec015STomasz Sapeta    | 'location'
254*af2ec015STomasz Sapeta    | 'middleName'
255*af2ec015STomasz Sapeta    | 'name'
256*af2ec015STomasz Sapeta    | 'namePrefix'
257*af2ec015STomasz Sapeta    | 'nameSuffix'
258*af2ec015STomasz Sapeta    | 'nickname'
259*af2ec015STomasz Sapeta    | 'organizationName'
260*af2ec015STomasz Sapeta    | 'postalCode'
261*af2ec015STomasz Sapeta    | 'streetAddressLine1'
262*af2ec015STomasz Sapeta    | 'streetAddressLine2'
263*af2ec015STomasz Sapeta    | 'sublocality'
264*af2ec015STomasz Sapeta    | 'telephoneNumber'
265*af2ec015STomasz Sapeta    | 'username'
266*af2ec015STomasz Sapeta    | 'password'
267*af2ec015STomasz Sapeta    | 'newPassword'
268*af2ec015STomasz Sapeta    | 'oneTimeCode'
269*af2ec015STomasz Sapeta    | undefined;
270*af2ec015STomasz Sapeta
271*af2ec015STomasz Sapeta  /**
272*af2ec015STomasz Sapeta   * If false, scrolling of the text view will be disabled. The default value is true. Only works with multiline={true}
273*af2ec015STomasz Sapeta   */
274*af2ec015STomasz Sapeta  scrollEnabled?: boolean | undefined;
275*af2ec015STomasz Sapeta
276*af2ec015STomasz Sapeta  /**
277*af2ec015STomasz Sapeta   * Set line break strategy on iOS.
278*af2ec015STomasz Sapeta   */
279*af2ec015STomasz Sapeta  lineBreakStrategyIOS?:
280*af2ec015STomasz Sapeta    | 'none'
281*af2ec015STomasz Sapeta    | 'standard'
282*af2ec015STomasz Sapeta    | 'hangul-word'
283*af2ec015STomasz Sapeta    | 'push-out'
284*af2ec015STomasz Sapeta    | undefined;
285*af2ec015STomasz Sapeta}
286*af2ec015STomasz Sapeta
287*af2ec015STomasz Sapeta/**
288*af2ec015STomasz Sapeta * Android Specific properties for TextInput
289*af2ec015STomasz Sapeta * @see https://reactnative.dev/docs/textinput#props
290*af2ec015STomasz Sapeta */
291*af2ec015STomasz Sapetaexport interface TextInputAndroidProps {
292*af2ec015STomasz Sapeta  /**
293*af2ec015STomasz Sapeta   * When provided it will set the color of the cursor (or "caret") in the component.
294*af2ec015STomasz Sapeta   * Unlike the behavior of `selectionColor` the cursor color will be set independently
295*af2ec015STomasz Sapeta   * from the color of the text selection box.
296*af2ec015STomasz Sapeta   * @platform android
297*af2ec015STomasz Sapeta   */
298*af2ec015STomasz Sapeta  cursorColor?: ColorValue | null | undefined;
299*af2ec015STomasz Sapeta
300*af2ec015STomasz Sapeta  /**
301*af2ec015STomasz Sapeta   * Determines whether the individual fields in your app should be included in a
302*af2ec015STomasz Sapeta   * view structure for autofill purposes on Android API Level 26+. Defaults to auto.
303*af2ec015STomasz Sapeta   * To disable auto complete, use `off`.
304*af2ec015STomasz Sapeta   *
305*af2ec015STomasz Sapeta   * *Android Only*
306*af2ec015STomasz Sapeta   *
307*af2ec015STomasz Sapeta   * The following values work on Android only:
308*af2ec015STomasz Sapeta   *
309*af2ec015STomasz Sapeta   * - `auto` - let Android decide
310*af2ec015STomasz Sapeta   * - `no` - not important for autofill
311*af2ec015STomasz Sapeta   * - `noExcludeDescendants` - this view and its children aren't important for autofill
312*af2ec015STomasz Sapeta   * - `yes` - is important for autofill
313*af2ec015STomasz Sapeta   * - `yesExcludeDescendants` - this view is important for autofill but its children aren't
314*af2ec015STomasz Sapeta   */
315*af2ec015STomasz Sapeta  importantForAutofill?:
316*af2ec015STomasz Sapeta    | 'auto'
317*af2ec015STomasz Sapeta    | 'no'
318*af2ec015STomasz Sapeta    | 'noExcludeDescendants'
319*af2ec015STomasz Sapeta    | 'yes'
320*af2ec015STomasz Sapeta    | 'yesExcludeDescendants'
321*af2ec015STomasz Sapeta    | undefined;
322*af2ec015STomasz Sapeta
323*af2ec015STomasz Sapeta  /**
324*af2ec015STomasz Sapeta   * When false, if there is a small amount of space available around a text input (e.g. landscape orientation on a phone),
325*af2ec015STomasz Sapeta   *   the OS may choose to have the user edit the text inside of a full screen text input mode.
326*af2ec015STomasz Sapeta   * When true, this feature is disabled and users will always edit the text directly inside of the text input.
327*af2ec015STomasz Sapeta   * Defaults to false.
328*af2ec015STomasz Sapeta   */
329*af2ec015STomasz Sapeta  disableFullscreenUI?: boolean | undefined;
330*af2ec015STomasz Sapeta
331*af2ec015STomasz Sapeta  /**
332*af2ec015STomasz Sapeta   * If defined, the provided image resource will be rendered on the left.
333*af2ec015STomasz Sapeta   */
334*af2ec015STomasz Sapeta  inlineImageLeft?: string | undefined;
335*af2ec015STomasz Sapeta
336*af2ec015STomasz Sapeta  /**
337*af2ec015STomasz Sapeta   * Padding between the inline image, if any, and the text input itself.
338*af2ec015STomasz Sapeta   */
339*af2ec015STomasz Sapeta  inlineImagePadding?: number | undefined;
340*af2ec015STomasz Sapeta
341*af2ec015STomasz Sapeta  /**
342*af2ec015STomasz Sapeta   * Sets the number of lines for a TextInput.
343*af2ec015STomasz Sapeta   * Use it with multiline set to true to be able to fill the lines.
344*af2ec015STomasz Sapeta   */
345*af2ec015STomasz Sapeta  numberOfLines?: number | undefined;
346*af2ec015STomasz Sapeta
347*af2ec015STomasz Sapeta  /**
348*af2ec015STomasz Sapeta   * Sets the return key to the label. Use it instead of `returnKeyType`.
349*af2ec015STomasz Sapeta   * @platform android
350*af2ec015STomasz Sapeta   */
351*af2ec015STomasz Sapeta  returnKeyLabel?: string | undefined;
352*af2ec015STomasz Sapeta
353*af2ec015STomasz Sapeta  /**
354*af2ec015STomasz Sapeta   * Set text break strategy on Android API Level 23+, possible values are simple, highQuality, balanced
355*af2ec015STomasz Sapeta   * The default value is simple.
356*af2ec015STomasz Sapeta   */
357*af2ec015STomasz Sapeta  textBreakStrategy?: 'simple' | 'highQuality' | 'balanced' | undefined;
358*af2ec015STomasz Sapeta
359*af2ec015STomasz Sapeta  /**
360*af2ec015STomasz Sapeta   * The color of the textInput underline.
361*af2ec015STomasz Sapeta   */
362*af2ec015STomasz Sapeta  underlineColorAndroid?: ColorValue | undefined;
363*af2ec015STomasz Sapeta
364*af2ec015STomasz Sapeta  /**
365*af2ec015STomasz Sapeta   * Vertically align text when `multiline` is set to true
366*af2ec015STomasz Sapeta   */
367*af2ec015STomasz Sapeta  textAlignVertical?: 'auto' | 'top' | 'bottom' | 'center' | undefined;
368*af2ec015STomasz Sapeta
369*af2ec015STomasz Sapeta  /**
370*af2ec015STomasz Sapeta   * When false, it will prevent the soft keyboard from showing when the field is focused. The default value is true
371*af2ec015STomasz Sapeta   */
372*af2ec015STomasz Sapeta  showSoftInputOnFocus?: boolean | undefined;
373*af2ec015STomasz Sapeta
374*af2ec015STomasz Sapeta  /**
375*af2ec015STomasz Sapeta   * Vertically align text when `multiline` is set to true
376*af2ec015STomasz Sapeta   */
377*af2ec015STomasz Sapeta  verticalAlign?: 'auto' | 'top' | 'bottom' | 'middle' | undefined;
378*af2ec015STomasz Sapeta}
379*af2ec015STomasz Sapeta
380*af2ec015STomasz Sapeta/**
381*af2ec015STomasz Sapeta * @see TextInputProps.onFocus
382*af2ec015STomasz Sapeta */
383*af2ec015STomasz Sapetaexport interface TextInputFocusEventData extends TargetedEvent {
384*af2ec015STomasz Sapeta  text: string;
385*af2ec015STomasz Sapeta  eventCount: number;
386*af2ec015STomasz Sapeta}
387*af2ec015STomasz Sapeta
388*af2ec015STomasz Sapeta/**
389*af2ec015STomasz Sapeta * @see TextInputProps.onScroll
390*af2ec015STomasz Sapeta */
391*af2ec015STomasz Sapetaexport interface TextInputScrollEventData {
392*af2ec015STomasz Sapeta  contentOffset: {x: number; y: number};
393*af2ec015STomasz Sapeta}
394*af2ec015STomasz Sapeta
395*af2ec015STomasz Sapeta/**
396*af2ec015STomasz Sapeta * @see TextInputProps.onSelectionChange
397*af2ec015STomasz Sapeta */
398*af2ec015STomasz Sapetaexport interface TextInputSelectionChangeEventData extends TargetedEvent {
399*af2ec015STomasz Sapeta  selection: {
400*af2ec015STomasz Sapeta    start: number;
401*af2ec015STomasz Sapeta    end: number;
402*af2ec015STomasz Sapeta  };
403*af2ec015STomasz Sapeta}
404*af2ec015STomasz Sapeta
405*af2ec015STomasz Sapeta/**
406*af2ec015STomasz Sapeta * @see TextInputProps.onKeyPress
407*af2ec015STomasz Sapeta */
408*af2ec015STomasz Sapetaexport interface TextInputKeyPressEventData {
409*af2ec015STomasz Sapeta  key: string;
410*af2ec015STomasz Sapeta}
411*af2ec015STomasz Sapeta
412*af2ec015STomasz Sapeta/**
413*af2ec015STomasz Sapeta * @see TextInputProps.onChange
414*af2ec015STomasz Sapeta */
415*af2ec015STomasz Sapetaexport interface TextInputChangeEventData extends TargetedEvent {
416*af2ec015STomasz Sapeta  eventCount: number;
417*af2ec015STomasz Sapeta  text: string;
418*af2ec015STomasz Sapeta}
419*af2ec015STomasz Sapeta
420*af2ec015STomasz Sapeta/**
421*af2ec015STomasz Sapeta * @see TextInputProps.onContentSizeChange
422*af2ec015STomasz Sapeta */
423*af2ec015STomasz Sapetaexport interface TextInputContentSizeChangeEventData {
424*af2ec015STomasz Sapeta  contentSize: {width: number; height: number};
425*af2ec015STomasz Sapeta}
426*af2ec015STomasz Sapeta
427*af2ec015STomasz Sapeta/**
428*af2ec015STomasz Sapeta * @see TextInputProps.onEndEditing
429*af2ec015STomasz Sapeta */
430*af2ec015STomasz Sapetaexport interface TextInputEndEditingEventData {
431*af2ec015STomasz Sapeta  text: string;
432*af2ec015STomasz Sapeta}
433*af2ec015STomasz Sapeta
434*af2ec015STomasz Sapeta/**
435*af2ec015STomasz Sapeta * @see TextInputProps.onSubmitEditing
436*af2ec015STomasz Sapeta */
437*af2ec015STomasz Sapetaexport interface TextInputSubmitEditingEventData {
438*af2ec015STomasz Sapeta  text: string;
439*af2ec015STomasz Sapeta}
440*af2ec015STomasz Sapeta
441*af2ec015STomasz Sapeta/**
442*af2ec015STomasz Sapeta * @see TextInputProps.onTextInput
443*af2ec015STomasz Sapeta */
444*af2ec015STomasz Sapetaexport interface TextInputTextInputEventData {
445*af2ec015STomasz Sapeta  text: string;
446*af2ec015STomasz Sapeta  previousText: string;
447*af2ec015STomasz Sapeta  range: {start: number; end: number};
448*af2ec015STomasz Sapeta}
449*af2ec015STomasz Sapeta
450*af2ec015STomasz Sapeta/**
451*af2ec015STomasz Sapeta * @see https://reactnative.dev/docs/textinput#props
452*af2ec015STomasz Sapeta */
453*af2ec015STomasz Sapetaexport interface TextInputProps
454*af2ec015STomasz Sapeta  extends ViewProps,
455*af2ec015STomasz Sapeta    TextInputIOSProps,
456*af2ec015STomasz Sapeta    TextInputAndroidProps,
457*af2ec015STomasz Sapeta    AccessibilityProps {
458*af2ec015STomasz Sapeta  /**
459*af2ec015STomasz Sapeta   * Specifies whether fonts should scale to respect Text Size accessibility settings.
460*af2ec015STomasz Sapeta   * The default is `true`.
461*af2ec015STomasz Sapeta   */
462*af2ec015STomasz Sapeta  allowFontScaling?: boolean | undefined;
463*af2ec015STomasz Sapeta
464*af2ec015STomasz Sapeta  /**
465*af2ec015STomasz Sapeta   * Can tell TextInput to automatically capitalize certain characters.
466*af2ec015STomasz Sapeta   *      characters: all characters,
467*af2ec015STomasz Sapeta   *      words: first letter of each word
468*af2ec015STomasz Sapeta   *      sentences: first letter of each sentence (default)
469*af2ec015STomasz Sapeta   *      none: don't auto capitalize anything
470*af2ec015STomasz Sapeta   *
471*af2ec015STomasz Sapeta   * https://reactnative.dev/docs/textinput#autocapitalize
472*af2ec015STomasz Sapeta   */
473*af2ec015STomasz Sapeta  autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters' | undefined;
474*af2ec015STomasz Sapeta
475*af2ec015STomasz Sapeta  /**
476*af2ec015STomasz Sapeta   * Specifies autocomplete hints for the system, so it can provide autofill.
477*af2ec015STomasz Sapeta   * On Android, the system will always attempt to offer autofill by using heuristics to identify the type of content.
478*af2ec015STomasz Sapeta   * To disable autocomplete, set autoComplete to off.
479*af2ec015STomasz Sapeta   *
480*af2ec015STomasz Sapeta   * The following values work across platforms:
481*af2ec015STomasz Sapeta   *
482*af2ec015STomasz Sapeta   * - `additional-name`
483*af2ec015STomasz Sapeta   * - `address-line1`
484*af2ec015STomasz Sapeta   * - `address-line2`
485*af2ec015STomasz Sapeta   * - `cc-number`
486*af2ec015STomasz Sapeta   * - `country`
487*af2ec015STomasz Sapeta   * - `current-password`
488*af2ec015STomasz Sapeta   * - `email`
489*af2ec015STomasz Sapeta   * - `family-name`
490*af2ec015STomasz Sapeta   * - `given-name`
491*af2ec015STomasz Sapeta   * - `honorific-prefix`
492*af2ec015STomasz Sapeta   * - `honorific-suffix`
493*af2ec015STomasz Sapeta   * - `name`
494*af2ec015STomasz Sapeta   * - `new-password`
495*af2ec015STomasz Sapeta   * - `off`
496*af2ec015STomasz Sapeta   * - `one-time-code`
497*af2ec015STomasz Sapeta   * - `postal-code`
498*af2ec015STomasz Sapeta   * - `street-address`
499*af2ec015STomasz Sapeta   * - `tel`
500*af2ec015STomasz Sapeta   * - `username`
501*af2ec015STomasz Sapeta   *
502*af2ec015STomasz Sapeta   * The following values work on iOS only:
503*af2ec015STomasz Sapeta   *
504*af2ec015STomasz Sapeta   * - `nickname`
505*af2ec015STomasz Sapeta   * - `organization`
506*af2ec015STomasz Sapeta   * - `organization-title`
507*af2ec015STomasz Sapeta   * - `url`
508*af2ec015STomasz Sapeta   *
509*af2ec015STomasz Sapeta   * The following values work on Android only:
510*af2ec015STomasz Sapeta   *
511*af2ec015STomasz Sapeta   * - `birthdate-day`
512*af2ec015STomasz Sapeta   * - `birthdate-full`
513*af2ec015STomasz Sapeta   * - `birthdate-month`
514*af2ec015STomasz Sapeta   * - `birthdate-year`
515*af2ec015STomasz Sapeta   * - `cc-csc`
516*af2ec015STomasz Sapeta   * - `cc-exp`
517*af2ec015STomasz Sapeta   * - `cc-exp-day`
518*af2ec015STomasz Sapeta   * - `cc-exp-month`
519*af2ec015STomasz Sapeta   * - `cc-exp-year`
520*af2ec015STomasz Sapeta   * - `gender`
521*af2ec015STomasz Sapeta   * - `name-family`
522*af2ec015STomasz Sapeta   * - `name-given`
523*af2ec015STomasz Sapeta   * - `name-middle`
524*af2ec015STomasz Sapeta   * - `name-middle-initial`
525*af2ec015STomasz Sapeta   * - `name-prefix`
526*af2ec015STomasz Sapeta   * - `name-suffix`
527*af2ec015STomasz Sapeta   * - `password`
528*af2ec015STomasz Sapeta   * - `password-new`
529*af2ec015STomasz Sapeta   * - `postal-address`
530*af2ec015STomasz Sapeta   * - `postal-address-country`
531*af2ec015STomasz Sapeta   * - `postal-address-extended`
532*af2ec015STomasz Sapeta   * - `postal-address-extended-postal-code`
533*af2ec015STomasz Sapeta   * - `postal-address-locality`
534*af2ec015STomasz Sapeta   * - `postal-address-region`
535*af2ec015STomasz Sapeta   * - `sms-otp`
536*af2ec015STomasz Sapeta   * - `tel-country-code`
537*af2ec015STomasz Sapeta   * - `tel-national`
538*af2ec015STomasz Sapeta   * - `tel-device`
539*af2ec015STomasz Sapeta   * - `username-new`
540*af2ec015STomasz Sapeta   */
541*af2ec015STomasz Sapeta  autoComplete?:
542*af2ec015STomasz Sapeta    | 'additional-name'
543*af2ec015STomasz Sapeta    | 'address-line1'
544*af2ec015STomasz Sapeta    | 'address-line2'
545*af2ec015STomasz Sapeta    | 'birthdate-day'
546*af2ec015STomasz Sapeta    | 'birthdate-full'
547*af2ec015STomasz Sapeta    | 'birthdate-month'
548*af2ec015STomasz Sapeta    | 'birthdate-year'
549*af2ec015STomasz Sapeta    | 'cc-csc'
550*af2ec015STomasz Sapeta    | 'cc-exp'
551*af2ec015STomasz Sapeta    | 'cc-exp-day'
552*af2ec015STomasz Sapeta    | 'cc-exp-month'
553*af2ec015STomasz Sapeta    | 'cc-exp-year'
554*af2ec015STomasz Sapeta    | 'cc-number'
555*af2ec015STomasz Sapeta    | 'country'
556*af2ec015STomasz Sapeta    | 'current-password'
557*af2ec015STomasz Sapeta    | 'email'
558*af2ec015STomasz Sapeta    | 'family-name'
559*af2ec015STomasz Sapeta    | 'gender'
560*af2ec015STomasz Sapeta    | 'given-name'
561*af2ec015STomasz Sapeta    | 'honorific-prefix'
562*af2ec015STomasz Sapeta    | 'honorific-suffix'
563*af2ec015STomasz Sapeta    | 'name'
564*af2ec015STomasz Sapeta    | 'name-family'
565*af2ec015STomasz Sapeta    | 'name-given'
566*af2ec015STomasz Sapeta    | 'name-middle'
567*af2ec015STomasz Sapeta    | 'name-middle-initial'
568*af2ec015STomasz Sapeta    | 'name-prefix'
569*af2ec015STomasz Sapeta    | 'name-suffix'
570*af2ec015STomasz Sapeta    | 'new-password'
571*af2ec015STomasz Sapeta    | 'nickname'
572*af2ec015STomasz Sapeta    | 'one-time-code'
573*af2ec015STomasz Sapeta    | 'organization'
574*af2ec015STomasz Sapeta    | 'organization-title'
575*af2ec015STomasz Sapeta    | 'password'
576*af2ec015STomasz Sapeta    | 'password-new'
577*af2ec015STomasz Sapeta    | 'postal-address'
578*af2ec015STomasz Sapeta    | 'postal-address-country'
579*af2ec015STomasz Sapeta    | 'postal-address-extended'
580*af2ec015STomasz Sapeta    | 'postal-address-extended-postal-code'
581*af2ec015STomasz Sapeta    | 'postal-address-locality'
582*af2ec015STomasz Sapeta    | 'postal-address-region'
583*af2ec015STomasz Sapeta    | 'postal-code'
584*af2ec015STomasz Sapeta    | 'street-address'
585*af2ec015STomasz Sapeta    | 'sms-otp'
586*af2ec015STomasz Sapeta    | 'tel'
587*af2ec015STomasz Sapeta    | 'tel-country-code'
588*af2ec015STomasz Sapeta    | 'tel-national'
589*af2ec015STomasz Sapeta    | 'tel-device'
590*af2ec015STomasz Sapeta    | 'url'
591*af2ec015STomasz Sapeta    | 'username'
592*af2ec015STomasz Sapeta    | 'username-new'
593*af2ec015STomasz Sapeta    | 'off'
594*af2ec015STomasz Sapeta    | undefined;
595*af2ec015STomasz Sapeta
596*af2ec015STomasz Sapeta  /**
597*af2ec015STomasz Sapeta   * If false, disables auto-correct.
598*af2ec015STomasz Sapeta   * The default value is true.
599*af2ec015STomasz Sapeta   */
600*af2ec015STomasz Sapeta  autoCorrect?: boolean | undefined;
601*af2ec015STomasz Sapeta
602*af2ec015STomasz Sapeta  /**
603*af2ec015STomasz Sapeta   * If true, focuses the input on componentDidMount.
604*af2ec015STomasz Sapeta   * The default value is false.
605*af2ec015STomasz Sapeta   */
606*af2ec015STomasz Sapeta  autoFocus?: boolean | undefined;
607*af2ec015STomasz Sapeta
608*af2ec015STomasz Sapeta  /**
609*af2ec015STomasz Sapeta   * If true, the text field will blur when submitted.
610*af2ec015STomasz Sapeta   * The default value is true.
611*af2ec015STomasz Sapeta   */
612*af2ec015STomasz Sapeta  blurOnSubmit?: boolean | undefined;
613*af2ec015STomasz Sapeta
614*af2ec015STomasz Sapeta  /**
615*af2ec015STomasz Sapeta   * If true, caret is hidden. The default value is false.
616*af2ec015STomasz Sapeta   */
617*af2ec015STomasz Sapeta  caretHidden?: boolean | undefined;
618*af2ec015STomasz Sapeta
619*af2ec015STomasz Sapeta  /**
620*af2ec015STomasz Sapeta   * If true, context menu is hidden. The default value is false.
621*af2ec015STomasz Sapeta   */
622*af2ec015STomasz Sapeta  contextMenuHidden?: boolean | undefined;
623*af2ec015STomasz Sapeta
624*af2ec015STomasz Sapeta  /**
625*af2ec015STomasz Sapeta   * Provides an initial value that will change when the user starts typing.
626*af2ec015STomasz Sapeta   * Useful for simple use-cases where you don't want to deal with listening to events
627*af2ec015STomasz Sapeta   * and updating the value prop to keep the controlled state in sync.
628*af2ec015STomasz Sapeta   */
629*af2ec015STomasz Sapeta  defaultValue?: string | undefined;
630*af2ec015STomasz Sapeta
631*af2ec015STomasz Sapeta  /**
632*af2ec015STomasz Sapeta   * If false, text is not editable. The default value is true.
633*af2ec015STomasz Sapeta   */
634*af2ec015STomasz Sapeta  editable?: boolean | undefined;
635*af2ec015STomasz Sapeta
636*af2ec015STomasz Sapeta  /**
637*af2ec015STomasz Sapeta   * enum("default", 'numeric', 'email-address', "ascii-capable", 'numbers-and-punctuation', 'url', 'number-pad', 'phone-pad', 'name-phone-pad',
638*af2ec015STomasz Sapeta   * 'decimal-pad', 'twitter', 'web-search', 'visible-password')
639*af2ec015STomasz Sapeta   * Determines which keyboard to open, e.g.numeric.
640*af2ec015STomasz Sapeta   * The following values work across platforms: - default - numeric - email-address - phone-pad
641*af2ec015STomasz Sapeta   * The following values work on iOS: - ascii-capable - numbers-and-punctuation - url - number-pad - name-phone-pad - decimal-pad - twitter - web-search
642*af2ec015STomasz Sapeta   * The following values work on Android: - visible-password
643*af2ec015STomasz Sapeta   */
644*af2ec015STomasz Sapeta  keyboardType?: KeyboardTypeOptions | undefined;
645*af2ec015STomasz Sapeta
646*af2ec015STomasz Sapeta  /**
647*af2ec015STomasz Sapeta   * Works like the inputmode attribute in HTML, it determines which keyboard to open, e.g. numeric and has precedence over keyboardType.
648*af2ec015STomasz Sapeta   */
649*af2ec015STomasz Sapeta  inputMode?: InputModeOptions | undefined;
650*af2ec015STomasz Sapeta
651*af2ec015STomasz Sapeta  /**
652*af2ec015STomasz Sapeta   * Limits the maximum number of characters that can be entered.
653*af2ec015STomasz Sapeta   * Use this instead of implementing the logic in JS to avoid flicker.
654*af2ec015STomasz Sapeta   */
655*af2ec015STomasz Sapeta  maxLength?: number | undefined;
656*af2ec015STomasz Sapeta
657*af2ec015STomasz Sapeta  /**
658*af2ec015STomasz Sapeta   * If true, the text input can be multiple lines. The default value is false.
659*af2ec015STomasz Sapeta   */
660*af2ec015STomasz Sapeta  multiline?: boolean | undefined;
661*af2ec015STomasz Sapeta
662*af2ec015STomasz Sapeta  /**
663*af2ec015STomasz Sapeta   * Callback that is called when the text input is blurred
664*af2ec015STomasz Sapeta   */
665*af2ec015STomasz Sapeta  onBlur?:
666*af2ec015STomasz Sapeta    | ((e: NativeSyntheticEvent<TextInputFocusEventData>) => void)
667*af2ec015STomasz Sapeta    | undefined;
668*af2ec015STomasz Sapeta
669*af2ec015STomasz Sapeta  /**
670*af2ec015STomasz Sapeta   * Callback that is called when the text input's text changes.
671*af2ec015STomasz Sapeta   */
672*af2ec015STomasz Sapeta  onChange?:
673*af2ec015STomasz Sapeta    | ((e: NativeSyntheticEvent<TextInputChangeEventData>) => void)
674*af2ec015STomasz Sapeta    | undefined;
675*af2ec015STomasz Sapeta
676*af2ec015STomasz Sapeta  /**
677*af2ec015STomasz Sapeta   * Callback that is called when the text input's text changes.
678*af2ec015STomasz Sapeta   * Changed text is passed as an argument to the callback handler.
679*af2ec015STomasz Sapeta   */
680*af2ec015STomasz Sapeta  onChangeText?: ((text: string) => void) | undefined;
681*af2ec015STomasz Sapeta
682*af2ec015STomasz Sapeta  /**
683*af2ec015STomasz Sapeta   * Callback that is called when the text input's content size changes.
684*af2ec015STomasz Sapeta   * This will be called with
685*af2ec015STomasz Sapeta   * `{ nativeEvent: { contentSize: { width, height } } }`.
686*af2ec015STomasz Sapeta   *
687*af2ec015STomasz Sapeta   * Only called for multiline text inputs.
688*af2ec015STomasz Sapeta   */
689*af2ec015STomasz Sapeta  onContentSizeChange?:
690*af2ec015STomasz Sapeta    | ((e: NativeSyntheticEvent<TextInputContentSizeChangeEventData>) => void)
691*af2ec015STomasz Sapeta    | undefined;
692*af2ec015STomasz Sapeta
693*af2ec015STomasz Sapeta  /**
694*af2ec015STomasz Sapeta   * Callback that is called when text input ends.
695*af2ec015STomasz Sapeta   */
696*af2ec015STomasz Sapeta  onEndEditing?:
697*af2ec015STomasz Sapeta    | ((e: NativeSyntheticEvent<TextInputEndEditingEventData>) => void)
698*af2ec015STomasz Sapeta    | undefined;
699*af2ec015STomasz Sapeta
700*af2ec015STomasz Sapeta  /**
701*af2ec015STomasz Sapeta   * Callback that is called when a touch is engaged.
702*af2ec015STomasz Sapeta   */
703*af2ec015STomasz Sapeta  onPressIn?: ((e: NativeSyntheticEvent<NativeTouchEvent>) => void) | undefined;
704*af2ec015STomasz Sapeta
705*af2ec015STomasz Sapeta  /**
706*af2ec015STomasz Sapeta   * Callback that is called when a touch is released.
707*af2ec015STomasz Sapeta   */
708*af2ec015STomasz Sapeta  onPressOut?:
709*af2ec015STomasz Sapeta    | ((e: NativeSyntheticEvent<NativeTouchEvent>) => void)
710*af2ec015STomasz Sapeta    | undefined;
711*af2ec015STomasz Sapeta
712*af2ec015STomasz Sapeta  /**
713*af2ec015STomasz Sapeta   * Callback that is called when the text input is focused
714*af2ec015STomasz Sapeta   */
715*af2ec015STomasz Sapeta  onFocus?:
716*af2ec015STomasz Sapeta    | ((e: NativeSyntheticEvent<TextInputFocusEventData>) => void)
717*af2ec015STomasz Sapeta    | undefined;
718*af2ec015STomasz Sapeta
719*af2ec015STomasz Sapeta  /**
720*af2ec015STomasz Sapeta   * Callback that is called when the text input selection is changed.
721*af2ec015STomasz Sapeta   */
722*af2ec015STomasz Sapeta  onSelectionChange?:
723*af2ec015STomasz Sapeta    | ((e: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => void)
724*af2ec015STomasz Sapeta    | undefined;
725*af2ec015STomasz Sapeta
726*af2ec015STomasz Sapeta  /**
727*af2ec015STomasz Sapeta   * Callback that is called when the text input's submit button is pressed.
728*af2ec015STomasz Sapeta   */
729*af2ec015STomasz Sapeta  onSubmitEditing?:
730*af2ec015STomasz Sapeta    | ((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void)
731*af2ec015STomasz Sapeta    | undefined;
732*af2ec015STomasz Sapeta
733*af2ec015STomasz Sapeta  /**
734*af2ec015STomasz Sapeta   * Callback that is called on new text input with the argument
735*af2ec015STomasz Sapeta   *  `{ nativeEvent: { text, previousText, range: { start, end } } }`.
736*af2ec015STomasz Sapeta   *
737*af2ec015STomasz Sapeta   * This prop requires multiline={true} to be set.
738*af2ec015STomasz Sapeta   */
739*af2ec015STomasz Sapeta  onTextInput?:
740*af2ec015STomasz Sapeta    | ((e: NativeSyntheticEvent<TextInputTextInputEventData>) => void)
741*af2ec015STomasz Sapeta    | undefined;
742*af2ec015STomasz Sapeta
743*af2ec015STomasz Sapeta  /**
744*af2ec015STomasz Sapeta   * Invoked on content scroll with
745*af2ec015STomasz Sapeta   *  `{ nativeEvent: { contentOffset: { x, y } } }`.
746*af2ec015STomasz Sapeta   *
747*af2ec015STomasz Sapeta   * May also contain other properties from ScrollEvent but on Android contentSize is not provided for performance reasons.
748*af2ec015STomasz Sapeta   */
749*af2ec015STomasz Sapeta  onScroll?:
750*af2ec015STomasz Sapeta    | ((e: NativeSyntheticEvent<TextInputScrollEventData>) => void)
751*af2ec015STomasz Sapeta    | undefined;
752*af2ec015STomasz Sapeta
753*af2ec015STomasz Sapeta  /**
754*af2ec015STomasz Sapeta   * Callback that is called when a key is pressed.
755*af2ec015STomasz Sapeta   * This will be called with
756*af2ec015STomasz Sapeta   *  `{ nativeEvent: { key: keyValue } }`
757*af2ec015STomasz Sapeta   * where keyValue is 'Enter' or 'Backspace' for respective keys and the typed-in character otherwise including ' ' for space.
758*af2ec015STomasz Sapeta   *
759*af2ec015STomasz Sapeta   * Fires before onChange callbacks.
760*af2ec015STomasz Sapeta   * Note: on Android only the inputs from soft keyboard are handled, not the hardware keyboard inputs.
761*af2ec015STomasz Sapeta   */
762*af2ec015STomasz Sapeta  onKeyPress?:
763*af2ec015STomasz Sapeta    | ((e: NativeSyntheticEvent<TextInputKeyPressEventData>) => void)
764*af2ec015STomasz Sapeta    | undefined;
765*af2ec015STomasz Sapeta
766*af2ec015STomasz Sapeta  /**
767*af2ec015STomasz Sapeta   * The string that will be rendered before text input has been entered
768*af2ec015STomasz Sapeta   */
769*af2ec015STomasz Sapeta  placeholder?: string | undefined;
770*af2ec015STomasz Sapeta
771*af2ec015STomasz Sapeta  /**
772*af2ec015STomasz Sapeta   * The text color of the placeholder string
773*af2ec015STomasz Sapeta   */
774*af2ec015STomasz Sapeta  placeholderTextColor?: ColorValue | undefined;
775*af2ec015STomasz Sapeta
776*af2ec015STomasz Sapeta  /**
777*af2ec015STomasz Sapeta   * enum('default', 'go', 'google', 'join', 'next', 'route', 'search', 'send', 'yahoo', 'done', 'emergency-call')
778*af2ec015STomasz Sapeta   * Determines how the return key should look.
779*af2ec015STomasz Sapeta   */
780*af2ec015STomasz Sapeta  returnKeyType?: ReturnKeyTypeOptions | undefined;
781*af2ec015STomasz Sapeta
782*af2ec015STomasz Sapeta  /**
783*af2ec015STomasz Sapeta   * If true, the text input obscures the text entered so that sensitive text like passwords stay secure.
784*af2ec015STomasz Sapeta   * The default value is false.
785*af2ec015STomasz Sapeta   */
786*af2ec015STomasz Sapeta  secureTextEntry?: boolean | undefined;
787*af2ec015STomasz Sapeta
788*af2ec015STomasz Sapeta  /**
789*af2ec015STomasz Sapeta   * If true, all text will automatically be selected on focus
790*af2ec015STomasz Sapeta   */
791*af2ec015STomasz Sapeta  selectTextOnFocus?: boolean | undefined;
792*af2ec015STomasz Sapeta
793*af2ec015STomasz Sapeta  /**
794*af2ec015STomasz Sapeta   * The start and end of the text input's selection. Set start and end to
795*af2ec015STomasz Sapeta   * the same value to position the cursor.
796*af2ec015STomasz Sapeta   */
797*af2ec015STomasz Sapeta  selection?: {start: number; end?: number | undefined} | undefined;
798*af2ec015STomasz Sapeta
799*af2ec015STomasz Sapeta  /**
800*af2ec015STomasz Sapeta   * The highlight (and cursor on ios) color of the text input
801*af2ec015STomasz Sapeta   */
802*af2ec015STomasz Sapeta  selectionColor?: ColorValue | undefined;
803*af2ec015STomasz Sapeta
804*af2ec015STomasz Sapeta  /**
805*af2ec015STomasz Sapeta   * Styles
806*af2ec015STomasz Sapeta   */
807*af2ec015STomasz Sapeta  style?: StyleProp<TextStyle> | undefined;
808*af2ec015STomasz Sapeta
809*af2ec015STomasz Sapeta  /**
810*af2ec015STomasz Sapeta   * Align the input text to the left, center, or right sides of the input field.
811*af2ec015STomasz Sapeta   */
812*af2ec015STomasz Sapeta  textAlign?: 'left' | 'center' | 'right' | undefined;
813*af2ec015STomasz Sapeta
814*af2ec015STomasz Sapeta  /**
815*af2ec015STomasz Sapeta   * Used to locate this view in end-to-end tests
816*af2ec015STomasz Sapeta   */
817*af2ec015STomasz Sapeta  testID?: string | undefined;
818*af2ec015STomasz Sapeta
819*af2ec015STomasz Sapeta  /**
820*af2ec015STomasz Sapeta   * Used to connect to an InputAccessoryView. Not part of react-natives documentation, but present in examples and
821*af2ec015STomasz Sapeta   * code.
822*af2ec015STomasz Sapeta   * See https://reactnative.dev/docs/inputaccessoryview for more information.
823*af2ec015STomasz Sapeta   */
824*af2ec015STomasz Sapeta  inputAccessoryViewID?: string | undefined;
825*af2ec015STomasz Sapeta
826*af2ec015STomasz Sapeta  /**
827*af2ec015STomasz Sapeta   * The value to show for the text input. TextInput is a controlled component,
828*af2ec015STomasz Sapeta   * which means the native value will be forced to match this value prop if provided.
829*af2ec015STomasz Sapeta   * For most uses this works great, but in some cases this may cause flickering - one common cause is preventing edits by keeping value the same.
830*af2ec015STomasz Sapeta   * In addition to simply setting the same value, either set editable={false},
831*af2ec015STomasz Sapeta   * or set/update maxLength to prevent unwanted edits without flicker.
832*af2ec015STomasz Sapeta   */
833*af2ec015STomasz Sapeta  value?: string | undefined;
834*af2ec015STomasz Sapeta
835*af2ec015STomasz Sapeta  /**
836*af2ec015STomasz Sapeta   * Specifies largest possible scale a font can reach when allowFontScaling is enabled. Possible values:
837*af2ec015STomasz Sapeta   * - null/undefined (default): inherit from the parent node or the global default (0)
838*af2ec015STomasz Sapeta   * - 0: no max, ignore parent/global default
839*af2ec015STomasz Sapeta   * - >= 1: sets the maxFontSizeMultiplier of this node to this value
840*af2ec015STomasz Sapeta   */
841*af2ec015STomasz Sapeta  maxFontSizeMultiplier?: number | null | undefined;
842*af2ec015STomasz Sapeta}
843*af2ec015STomasz Sapeta
844*af2ec015STomasz Sapeta/**
845*af2ec015STomasz Sapeta * This class is responsible for coordinating the "focused"
846*af2ec015STomasz Sapeta * state for TextInputs. All calls relating to the keyboard
847*af2ec015STomasz Sapeta * should be funneled through here
848*af2ec015STomasz Sapeta */
849*af2ec015STomasz Sapetainterface TextInputState {
850*af2ec015STomasz Sapeta  /**
851*af2ec015STomasz Sapeta   * @deprecated Use currentlyFocusedInput
852*af2ec015STomasz Sapeta   * Returns the ID of the currently focused text field, if one exists
853*af2ec015STomasz Sapeta   * If no text field is focused it returns null
854*af2ec015STomasz Sapeta   */
855*af2ec015STomasz Sapeta  currentlyFocusedField(): number;
856*af2ec015STomasz Sapeta
857*af2ec015STomasz Sapeta  /**
858*af2ec015STomasz Sapeta   * Returns the ref of the currently focused text field, if one exists
859*af2ec015STomasz Sapeta   * If no text field is focused it returns null
860*af2ec015STomasz Sapeta   */
861*af2ec015STomasz Sapeta  currentlyFocusedInput(): React.ElementRef<HostComponent<unknown>>;
862*af2ec015STomasz Sapeta
863*af2ec015STomasz Sapeta  /**
864*af2ec015STomasz Sapeta   * @param textField ref of the text field to focus
865*af2ec015STomasz Sapeta   * Focuses the specified text field
866*af2ec015STomasz Sapeta   * noop if the text field was already focused
867*af2ec015STomasz Sapeta   */
868*af2ec015STomasz Sapeta  focusTextInput(textField?: React.ElementRef<HostComponent<unknown>>): void;
869*af2ec015STomasz Sapeta
870*af2ec015STomasz Sapeta  /**
871*af2ec015STomasz Sapeta   * @param textField ref of the text field to focus
872*af2ec015STomasz Sapeta   * Unfocuses the specified text field
873*af2ec015STomasz Sapeta   * noop if it wasn't focused
874*af2ec015STomasz Sapeta   */
875*af2ec015STomasz Sapeta  blurTextInput(textField?: React.ElementRef<HostComponent<unknown>>): void;
876*af2ec015STomasz Sapeta}
877*af2ec015STomasz Sapeta
878*af2ec015STomasz Sapeta/**
879*af2ec015STomasz Sapeta * @see https://reactnative.dev/docs/textinput#methods
880*af2ec015STomasz Sapeta */
881*af2ec015STomasz Sapetadeclare class TextInputComponent extends React.Component<TextInputProps> {}
882*af2ec015STomasz Sapetadeclare const TextInputBase: Constructor<NativeMethods> &
883*af2ec015STomasz Sapeta  Constructor<TimerMixin> &
884*af2ec015STomasz Sapeta  typeof TextInputComponent;
885*af2ec015STomasz Sapetaexport class TextInput extends TextInputBase {
886*af2ec015STomasz Sapeta  /**
887*af2ec015STomasz Sapeta   * Access the current focus state.
888*af2ec015STomasz Sapeta   */
889*af2ec015STomasz Sapeta  static State: TextInputState;
890*af2ec015STomasz Sapeta
891*af2ec015STomasz Sapeta  /**
892*af2ec015STomasz Sapeta   * Returns if the input is currently focused.
893*af2ec015STomasz Sapeta   */
894*af2ec015STomasz Sapeta  isFocused: () => boolean;
895*af2ec015STomasz Sapeta
896*af2ec015STomasz Sapeta  /**
897*af2ec015STomasz Sapeta   * Removes all text from the input.
898*af2ec015STomasz Sapeta   */
899*af2ec015STomasz Sapeta  clear: () => void;
900*af2ec015STomasz Sapeta}
901