Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
} from '../../Types/CoreEventTypes';
import type {ViewProps} from '../View/ViewPropTypes';

import ReactNativeElement from '../../../src/private/webapis/dom/nodes/ReactNativeElement';
import {type ColorValue, type TextStyleProp} from '../../StyleSheet/StyleSheet';
import * as React from 'react';

Expand Down Expand Up @@ -1037,13 +1038,19 @@ export type TextInputProps = $ReadOnly<{
...TextInputBaseProps,
}>;

export interface TextInputInstance extends HostInstance {
+clear: () => void;
+isFocused: () => boolean;
+getNativeRef: () => ?HostInstance;
+setSelection: (start: number, end: number) => void;
/**
* TextInput monkey-patches the native element instance with these methods.
* It isn't technically a class but this is the most elegant way to type it.
*/
declare class _TextInputInstance extends ReactNativeElement {
clear(): void;
isFocused(): boolean;
getNativeRef(): ?ReactNativeElement;
setSelection(start: number, end: number): void;
}

export type TextInputInstance = _TextInputInstance;

/**
* A foundational component for inputting text into the app via a
* keyboard. Props provide configurability for several features, such as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ export default class ReactFabricHostComponent implements NativeMethods {
}

blur() {
// $FlowFixMe[incompatible-call] - Error supressed during the migration of HostInstance to ReactNativeElement
// $FlowFixMe - Error supressed during the migration of HostInstance to ReactNativeElement
TextInputState.blurTextInput(this);
}

focus() {
// $FlowFixMe[incompatible-call] - Error supressed during the migration of HostInstance to ReactNativeElement
// $FlowFixMe - Error supressed during the migration of HostInstance to ReactNativeElement
TextInputState.focusTextInput(this);
}

Expand Down
163 changes: 82 additions & 81 deletions packages/react-native/ReactNativeApi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<50520041f6fb4d55a59f063dab8469a4>>
* @generated SignedSource<<b43428758b3aefd30b2bd8a32ec0878a>>
*
* This file was generated by scripts/js-api/build-types/index.js.
*/
Expand Down Expand Up @@ -1003,6 +1003,12 @@ declare type ____ViewStyle_InternalOverrides = {}
declare type ____ViewStyleProp_Internal = StyleProp<
Readonly<Partial<____ViewStyle_Internal>>
>
declare class _TextInputInstance extends ReactNativeElement_default {
clear(): void
getNativeRef(): ReactNativeElement_default | undefined
isFocused(): boolean
setSelection(start: number, end: number): void
}
declare type $$AndroidSwitchNativeComponent =
typeof $$AndroidSwitchNativeComponent
declare type $$AnimatedFlatList = typeof $$AnimatedFlatList
Expand Down Expand Up @@ -2484,7 +2490,7 @@ declare type HostComponent<Config extends {}> = (
ref?: React.Ref<HostInstance>
},
) => React.ReactNode
declare type HostInstance = LegacyHostInstanceMethods
declare type HostInstance = ReactNativeElement_default
declare class HTMLCollection_default<T> implements Iterable<T>, ArrayLike_2<T> {
[index: number]: T
readonly length: number
Expand Down Expand Up @@ -5307,12 +5313,7 @@ declare type TextInputEndEditingEventData = Readonly<
}
>
declare type TextInputFocusEvent = FocusEvent
declare interface TextInputInstance extends HostInstance {
readonly clear: () => void
readonly getNativeRef: () => HostInstance | undefined
readonly isFocused: () => boolean
readonly setSelection: (start: number, end: number) => void
}
declare type TextInputInstance = _TextInputInstance
declare type TextInputIOSProps = {
readonly clearButtonMode?:
| "always"
Expand Down Expand Up @@ -5949,7 +5950,7 @@ declare type WrapperComponentProvider = (
appParameters: Object,
) => React.ComponentType<any>
export {
AccessibilityActionEvent, // 9247c3f0
AccessibilityActionEvent, // f6181a2c
AccessibilityInfo, // 70604904
AccessibilityProps, // 5a2836fc
AccessibilityRole, // f2f2e066
Expand All @@ -5958,14 +5959,14 @@ export {
ActionSheetIOS, // 88e6bfb0
ActionSheetIOSOptions, // 1756eb5a
ActivityIndicator, // 8d041a45
ActivityIndicatorProps, // 0edeb628
ActivityIndicatorProps, // 0fa4e79d
Alert, // 5bf12165
AlertButton, // bf1a3b60
AlertButtonStyle, // ec9fb242
AlertOptions, // a0cdac0f
AlertType, // 5ab91217
AndroidKeyboardEvent, // e03becc8
Animated, // b3949f33
Animated, // 6b0cea93
AppConfig, // ebddad4b
AppRegistry, // 6cdee1d6
AppState, // f7097b1b
Expand All @@ -5975,12 +5976,12 @@ export {
AutoCapitalize, // c0e857a0
BackHandler, // a9f9bad9
BackPressEventName, // 4620fb76
BlurEvent, // ab745200
BlurEvent, // 870b9bb5
BoxShadowValue, // b679703f
Button, // dd130b61
ButtonProps, // 99495f51
ButtonProps, // 3c081e75
Clipboard, // 9b8c878e
CodegenTypes, // 1b38ac82
CodegenTypes, // 030a94b8
ColorSchemeName, // 31a4350e
ColorValue, // 98989a8f
ComponentProvider, // b5c60ddd
Expand All @@ -5997,8 +5998,8 @@ export {
DisplayMetrics, // 1dc35cef
DisplayMetricsAndroid, // 872e62eb
DrawerLayoutAndroid, // 14121b61
DrawerLayoutAndroidProps, // 11c0dfe2
DrawerSlideEvent, // ad024574
DrawerLayoutAndroidProps, // 123d3a9d
DrawerSlideEvent, // cc43db83
DropShadowValue, // e9df2606
DynamicColorIOS, // 1f9b3410
DynamicColorIOSTuple, // 023ce58e
Expand All @@ -6011,28 +6012,28 @@ export {
EventSubscription, // b8d084aa
ExtendedExceptionData, // 5a6ccf5a
FilterFunction, // bf24c0e3
FlatList, // 0b12ef25
FlatListProps, // d185db31
FocusEvent, // 1dc2b592
FlatList, // 714df8ad
FlatListProps, // e3e724ea
FocusEvent, // 529b43eb
FontVariant, // 7c7558bb
GestureResponderEvent, // 9c9a1b0d
GestureResponderHandlers, // 2c0e77cb
GestureResponderEvent, // b466f6d6
GestureResponderHandlers, // 8356843d
Handle, // 2d65285d
HostComponent, // b6281cf9
HostInstance, // b159a964
HostComponent, // 5e13ff5a
HostInstance, // 489cbe7f
I18nManager, // f2fa58ce
IOSKeyboardEvent, // e67bfe3a
IgnorePattern, // ec6f6ece
Image, // 04474205
ImageBackground, // b588909c
ImageBackgroundProps, // f9de269c
ImageErrorEvent, // 66044485
ImageLoadEvent, // 62e6be9b
ImageProgressEventIOS, // 3d6ffb7a
ImageProps, // d77401e6
ImageBackground, // e74abb26
ImageBackgroundProps, // cadc2fba
ImageErrorEvent, // b7b2ae63
ImageLoadEvent, // 5baae813
ImageProgressEventIOS, // adb35052
ImageProps, // 40c727e1
ImagePropsAndroid, // 9fd9bcbb
ImagePropsBase, // efd768f1
ImagePropsIOS, // c788030b
ImagePropsBase, // 715b84bf
ImagePropsIOS, // 318adce2
ImageRequireSource, // 681d683b
ImageResolvedAssetSource, // f3060931
ImageSize, // 1c47cf88
Expand All @@ -6046,8 +6047,8 @@ export {
Insets, // e7fe432a
InteractionManager, // 301bfa63
Keyboard, // 87311c77
KeyboardAvoidingView, // ab2d7999
KeyboardAvoidingViewProps, // 8e348419
KeyboardAvoidingView, // d88d0d4c
KeyboardAvoidingViewProps, // bc844418
KeyboardEvent, // c3f895d4
KeyboardEventEasing, // af4091c8
KeyboardEventName, // 59299ad6
Expand All @@ -6060,7 +6061,7 @@ export {
LayoutAnimationProperty, // 52995f01
LayoutAnimationType, // 2da0a29b
LayoutAnimationTypes, // 081b3bde
LayoutChangeEvent, // 697f2b5c
LayoutChangeEvent, // c674f902
LayoutConformanceProps, // 055f03b8
LayoutRectangle, // 6601b294
Linking, // 292de0a0
Expand All @@ -6072,31 +6073,31 @@ export {
MeasureLayoutOnSuccessCallback, // 3592502a
MeasureOnSuccessCallback, // 82824e59
Modal, // 78e8a79d
ModalBaseProps, // 574f2b2d
ModalProps, // 3fb62261
ModalBaseProps, // 0c81c9b1
ModalProps, // 270223fa
ModalPropsAndroid, // 515fb173
ModalPropsIOS, // 6053cb61
ModeChangeEvent, // 0d79bb94
MouseEvent, // d432147f
ModalPropsIOS, // 4fbcedf6
ModeChangeEvent, // b889a7ce
MouseEvent, // 53ede3db
NativeAppEventEmitter, // b4d20c1d
NativeColorValue, // d2094c29
NativeComponentRegistry, // b4954306
NativeComponentRegistry, // 7fd99ba6
NativeDialogManagerAndroid, // 6254873e
NativeEventEmitter, // d72906cc
NativeEventSubscription, // de3942e7
NativeMethods, // 5adf5f75
NativeMethodsMixin, // 518cbd6c
NativeMethods, // 03dc51c5
NativeMethodsMixin, // 4b061b7e
NativeModules, // 1cf72876
NativeMouseEvent, // 2d5b5c9f
NativePointerEvent, // 5f27ae9c
NativeMouseEvent, // ff25cf35
NativePointerEvent, // 89c1f3ad
NativeScrollEvent, // caad7f53
NativeSyntheticEvent, // 29455160
NativeSyntheticEvent, // d2a1fe6a
NativeTouchEvent, // 59b676df
NativeUIEvent, // 44ac26ac
Networking, // b674447b
OpaqueColorValue, // 25f3fa5b
PanResponder, // 98a9b6fc
PanResponderCallbacks, // 0567f479
PanResponderCallbacks, // d325aa56
PanResponderGestureState, // 54baf558
PanResponderInstance, // c8b0d00c
Permission, // 06473f4f
Expand All @@ -6108,14 +6109,14 @@ export {
PlatformOSType, // 0a17561e
PlatformSelectSpec, // 09ed7758
PointValue, // 69db075f
PointerEvent, // 3c454015
PointerEvent, // ff3129ff
Pressable, // 3c6e4eb9
PressableAndroidRippleConfig, // 42bc9727
PressableProps, // 00d5ea16
PressableProps, // 96c8132d
PressableStateCallbackType, // 9af36561
ProcessedColorValue, // 33f74304
ProgressBarAndroid, // 03e66cf5
ProgressBarAndroidProps, // 9302458b
ProgressBarAndroidProps, // 29338dc2
PromiseTask, // 5102c862
PublicRootInstance, // 8040afd7
PublicTextInstance, // 7d73f802
Expand All @@ -6124,12 +6125,12 @@ export {
PushNotificationPermissions, // c2e7ae4f
Rationale, // 5df1b1c1
ReactNativeVersion, // abd76827
RefreshControl, // effd2a00
RefreshControlProps, // fca5a05f
RefreshControl, // 036f45cf
RefreshControlProps, // b7de1e77
RefreshControlPropsAndroid, // 99f64c97
RefreshControlPropsIOS, // 72a36381
Registry, // e1ed403e
ResponderSyntheticEvent, // dccf8514
ResponderSyntheticEvent, // e0d1564d
ReturnKeyTypeOptions, // afd47ba3
Role, // af7b889d
RootTag, // 3cd10504
Expand All @@ -6139,19 +6140,19 @@ export {
Runnables, // d3749ae1
SafeAreaView, // 4364c7bb
ScaledSize, // 07e417c7
ScrollEvent, // 865efb2e
ScrollResponderType, // 525b353d
ScrollEvent, // 84e5b805
ScrollResponderType, // d39056e7
ScrollToLocationParamsType, // d7ecdad1
ScrollView, // 7fb7c469
ScrollViewImperativeMethods, // 97a0b5ac
ScrollViewProps, // b276b839
ScrollViewImperativeMethods, // eb20aa46
ScrollViewProps, // 27986ff5
ScrollViewPropsAndroid, // 84e2134b
ScrollViewPropsIOS, // a2902f33
ScrollViewPropsIOS, // d83c9733
ScrollViewScrollToOptions, // 3313411e
SectionBase, // 0ccaedac
SectionList, // ba8c31d9
SectionList, // cc6dec0b
SectionListData, // 1c80bb2e
SectionListProps, // 177096d2
SectionListProps, // 97fcf95a
SectionListRenderItem, // cffebb53
SectionListRenderItemInfo, // 946c2128
Separators, // 6a45f7e3
Expand All @@ -6171,8 +6172,8 @@ export {
StyleSheet, // 02b98c20
SubmitBehavior, // c4ddf490
Switch, // aebc9941
SwitchChangeEvent, // 056868be
SwitchProps, // 57b2101f
SwitchChangeEvent, // 2e5bd2de
SwitchProps, // cb21930d
Systrace, // b5aa21fc
TVViewPropsIOS, // 330ce7b5
TargetedEvent, // 16e98910
Expand All @@ -6181,44 +6182,44 @@ export {
TextContentType, // 239b3ecc
TextInput, // 282b394e
TextInputAndroidProps, // 3f09ce49
TextInputChangeEvent, // 9cb24681
TextInputContentSizeChangeEvent, // f6f7ecae
TextInputEndEditingEvent, // 254671ea
TextInputFocusEvent, // 29cebb63
TextInputChangeEvent, // 380cbe93
TextInputContentSizeChangeEvent, // 5fba3f54
TextInputEndEditingEvent, // 8c22fac3
TextInputFocusEvent, // c36e977c
TextInputIOSProps, // 0d05a855
TextInputKeyPressEvent, // 8047f716
TextInputProps, // 5cda62e0
TextInputSelectionChangeEvent, // 3a657f0b
TextInputSubmitEditingEvent, // b350617f
TextLayoutEvent, // e289bd3c
TextProps, // 0f0be34d
TextInputKeyPressEvent, // 967178c2
TextInputProps, // 8f3237f1
TextInputSelectionChangeEvent, // a1a7622f
TextInputSubmitEditingEvent, // 48d903af
TextLayoutEvent, // 45b0a8d7
TextProps, // 95d8874d
TextStyle, // f3404e2b
ToastAndroid, // b4875e35
Touchable, // 93eb6c63
TouchableHighlight, // b4304a98
TouchableHighlightProps, // 7212b9cf
TouchableNativeFeedback, // 1562b2eb
TouchableNativeFeedbackProps, // 8a4eed44
TouchableHighlightProps, // c871f353
TouchableNativeFeedback, // aaa5b42c
TouchableNativeFeedbackProps, // 372d3213
TouchableOpacity, // 7e33acfd
TouchableOpacityProps, // 189c11df
TouchableWithoutFeedback, // d5fb023d
TouchableWithoutFeedbackProps, // 26d3cf4e
TouchableOpacityProps, // ba6c0ba4
TouchableWithoutFeedback, // 7363a906
TouchableWithoutFeedbackProps, // 68e3d87f
TransformsStyle, // 65e70f18
TurboModule, // dfe29706
TurboModuleRegistry, // 4ace6db2
UIManager, // 8d2c8281
UTFSequence, // baacd11b
Vibration, // 315e131d
View, // 39dd4de4
ViewProps, // 0ab8ceda
ViewPropsAndroid, // f3d007c3
ViewProps, // f8aca212
ViewPropsAndroid, // 21385d96
ViewPropsIOS, // 58ee19bf
ViewStyle, // c2db0e6e
VirtualViewMode, // 85a69ef6
VirtualizedList, // 4d513939
VirtualizedListProps, // 8526b87a
VirtualizedListProps, // 8efa6d8e
VirtualizedSectionList, // 446ba0df
VirtualizedSectionListProps, // de510cb4
VirtualizedSectionListProps, // c5e64f83
WrapperComponentProvider, // 9cf3844c
codegenNativeCommands, // e16d62f7
codegenNativeComponent, // ed4c8103
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/jest/mockNativeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ export default function mockNativeComponent<TProps: {...}>(
Component.displayName = viewName;
}

// $FlowFixMe[incompatible-return] - Error supressed during the migration of HostInstance to ReactNativeElement
// $FlowFixMe - Error supressed during the migration of HostInstance to ReactNativeElement
return Component;
}
Loading
Loading