@office-iss/react-native-win32 0.0.0-canary.288 → 0.0.0-canary.289
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.flowconfig +3 -2
- package/CHANGELOG.json +22 -1
- package/CHANGELOG.md +16 -7
- package/Libraries/Alert/Alert.d.ts +4 -1
- package/Libraries/Alert/Alert.js +3 -0
- package/Libraries/Animated/Easing.js +13 -15
- package/Libraries/Animated/createAnimatedComponent.js +24 -12
- package/Libraries/Animated/nodes/AnimatedNode.js +2 -1
- package/Libraries/Animated/nodes/AnimatedProps.js +18 -1
- package/Libraries/Animated/nodes/AnimatedValue.js +6 -2
- package/Libraries/Blob/URL.js +23 -10
- package/Libraries/Components/TextInput/Tests/TextInputTest.d.ts +2 -1
- package/Libraries/Components/TextInput/Tests/TextInputTest.js.map +1 -1
- package/Libraries/Components/TextInput/TextInput.d.ts +6 -0
- package/Libraries/Components/TextInput/TextInput.flow.js +36 -3
- package/Libraries/Components/TextInput/TextInput.js +101 -110
- package/Libraries/Components/TextInput/TextInput.win32.js +102 -111
- package/Libraries/Components/Touchable/Tests/TouchableWin32Test.d.ts +2 -1
- package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
- package/Libraries/Core/ReactNativeVersion.js +2 -2
- package/Libraries/Image/Tests/ImageWin32Test.d.ts +2 -1
- package/Libraries/Image/Tests/ImageWin32Test.js.map +1 -1
- package/Libraries/Interaction/TaskQueue.js +1 -0
- package/Libraries/Modal/Modal.js +30 -4
- package/Libraries/ReactNative/AppRegistry.flow.js +49 -0
- package/Libraries/ReactNative/AppRegistry.js +2 -322
- package/Libraries/ReactNative/AppRegistry.js.flow +23 -0
- package/Libraries/ReactNative/AppRegistryImpl.js +316 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +1 -4
- package/Libraries/StyleSheet/PlatformColorValueTypesIOS.js +6 -0
- package/Libraries/StyleSheet/StyleSheet.js +5 -197
- package/Libraries/StyleSheet/StyleSheet.js.flow +166 -0
- package/Libraries/StyleSheet/{StyleSheet.win32.js → StyleSheetExports.js} +2 -151
- package/Libraries/StyleSheet/StyleSheetExports.js.flow +110 -0
- package/Libraries/StyleSheet/StyleSheetTypes.js +42 -18
- package/Libraries/Types/CodegenTypesNamespace.d.ts +45 -0
- package/Libraries/{Modal/ModalInjection.js → Types/CodegenTypesNamespace.js} +4 -5
- package/Libraries/Utilities/codegenNativeCommands.d.ts +18 -0
- package/Libraries/Utilities/codegenNativeComponent.d.ts +26 -0
- package/Libraries/vendor/emitter/EventEmitter.js +6 -2
- package/flow/global.js +1 -0
- package/flow/jest.js +4 -2
- package/index.js +47 -43
- package/index.win32.js +60 -55
- package/overrides.json +8 -16
- package/package.json +14 -14
- package/src/private/animated/NativeAnimatedHelper.js +18 -7
- package/src/private/animated/NativeAnimatedHelper.win32.js +18 -7
- package/src/private/animated/createAnimatedPropsHook.js +34 -15
- package/src/private/featureflags/ReactNativeFeatureFlags.js +14 -31
- package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +9 -1
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +2 -3
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +5 -18
- package/src/private/webapis/dom/nodes/internals/NodeInternals.js +6 -0
- package/src/types/third_party/event-target-shim.d.ts +392 -0
- package/src-win/Libraries/Components/TextInput/Tests/TextInputTest.tsx +7 -7
- package/src-win/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +3 -3
- package/src-win/Libraries/Image/Tests/ImageWin32Test.tsx +1 -1
- package/types/index.d.ts +4 -0
|
@@ -18,7 +18,6 @@ import type {
|
|
|
18
18
|
import type {ViewProps} from '../View/ViewPropTypes';
|
|
19
19
|
import type {TextInputInstance, TextInputType} from './TextInput.flow';
|
|
20
20
|
|
|
21
|
-
import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
|
|
22
21
|
import usePressability from '../../Pressability/usePressability';
|
|
23
22
|
import flattenStyle from '../../StyleSheet/flattenStyle';
|
|
24
23
|
import StyleSheet, {
|
|
@@ -58,6 +57,9 @@ if (Platform.OS === 'android') {
|
|
|
58
57
|
require('./RCTMultilineTextInputNativeComponent').Commands;
|
|
59
58
|
}
|
|
60
59
|
|
|
60
|
+
/**
|
|
61
|
+
* @see TextInputProps.onChange
|
|
62
|
+
*/
|
|
61
63
|
export type TextInputChangeEventData = $ReadOnly<{
|
|
62
64
|
eventCount: number,
|
|
63
65
|
target: number,
|
|
@@ -80,6 +82,9 @@ export type TextInputEvent = NativeSyntheticEvent<
|
|
|
80
82
|
}>,
|
|
81
83
|
>;
|
|
82
84
|
|
|
85
|
+
/**
|
|
86
|
+
* @see TextInputProps.onContentSizeChange
|
|
87
|
+
*/
|
|
83
88
|
export type TextInputContentSizeChangeEventData = $ReadOnly<{
|
|
84
89
|
target: number,
|
|
85
90
|
contentSize: $ReadOnly<{
|
|
@@ -95,16 +100,29 @@ export type TargetEvent = $ReadOnly<{
|
|
|
95
100
|
target: number,
|
|
96
101
|
}>;
|
|
97
102
|
|
|
103
|
+
/**
|
|
104
|
+
* @see TextInputProps.onFocus
|
|
105
|
+
*/
|
|
98
106
|
export type TextInputFocusEventData = TargetEvent;
|
|
99
107
|
|
|
100
108
|
export type TextInputBlurEvent = NativeSyntheticEvent<TextInputFocusEventData>;
|
|
101
109
|
export type TextInputFocusEvent = NativeSyntheticEvent<TextInputFocusEventData>;
|
|
102
110
|
|
|
111
|
+
/**
|
|
112
|
+
* @see TextInputProps.onScroll
|
|
113
|
+
*/
|
|
114
|
+
export type TextInputScrollEventData = {
|
|
115
|
+
contentOffset: {x: number, y: number},
|
|
116
|
+
};
|
|
117
|
+
|
|
103
118
|
type Selection = $ReadOnly<{
|
|
104
119
|
start: number,
|
|
105
120
|
end: number,
|
|
106
121
|
}>;
|
|
107
122
|
|
|
123
|
+
/**
|
|
124
|
+
* @see TextInputProps.onSelectionChange
|
|
125
|
+
*/
|
|
108
126
|
export type TextInputSelectionChangeEventData = $ReadOnly<{
|
|
109
127
|
...TargetEvent,
|
|
110
128
|
selection: Selection,
|
|
@@ -113,7 +131,10 @@ export type TextInputSelectionChangeEventData = $ReadOnly<{
|
|
|
113
131
|
export type TextInputSelectionChangeEvent =
|
|
114
132
|
NativeSyntheticEvent<TextInputSelectionChangeEventData>;
|
|
115
133
|
|
|
116
|
-
|
|
134
|
+
/**
|
|
135
|
+
* @see TextInputProps.onKeyPress
|
|
136
|
+
*/
|
|
137
|
+
export type TextInputKeyPressEventData = $ReadOnly<{
|
|
117
138
|
...TargetEvent,
|
|
118
139
|
key: string,
|
|
119
140
|
target?: ?number,
|
|
@@ -123,12 +144,30 @@ type TextInputKeyPressEventData = $ReadOnly<{
|
|
|
123
144
|
export type TextInputKeyPressEvent =
|
|
124
145
|
NativeSyntheticEvent<TextInputKeyPressEventData>;
|
|
125
146
|
|
|
147
|
+
/**
|
|
148
|
+
* @see TextInputProps.onEndEditing
|
|
149
|
+
*/
|
|
126
150
|
export type TextInputEndEditingEventData = $ReadOnly<{
|
|
127
151
|
...TargetEvent,
|
|
128
152
|
eventCount: number,
|
|
129
153
|
text: string,
|
|
130
154
|
}>;
|
|
131
155
|
|
|
156
|
+
export type TextInputEndEditingEvent =
|
|
157
|
+
NativeSyntheticEvent<TextInputEndEditingEventData>;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @see TextInputProps.onSubmitEditing
|
|
161
|
+
*/
|
|
162
|
+
export type TextInputSubmitEditingEventData = $ReadOnly<{
|
|
163
|
+
...TargetEvent,
|
|
164
|
+
eventCount: number,
|
|
165
|
+
text: string,
|
|
166
|
+
}>;
|
|
167
|
+
|
|
168
|
+
export type TextInputSubmitEditingEvent =
|
|
169
|
+
NativeSyntheticEvent<TextInputSubmitEditingEventData>;
|
|
170
|
+
|
|
132
171
|
export type TextInputEditingEvent =
|
|
133
172
|
NativeSyntheticEvent<TextInputEndEditingEventData>;
|
|
134
173
|
|
|
@@ -419,6 +458,21 @@ export type TextInputAndroidProps = $ReadOnly<{
|
|
|
419
458
|
*/
|
|
420
459
|
disableFullscreenUI?: ?boolean,
|
|
421
460
|
|
|
461
|
+
/**
|
|
462
|
+
* Determines whether the individual fields in your app should be included in a
|
|
463
|
+
* view structure for autofill purposes on Android API Level 26+. Defaults to auto.
|
|
464
|
+
* To disable auto complete, use `off`.
|
|
465
|
+
*
|
|
466
|
+
* *Android Only*
|
|
467
|
+
*
|
|
468
|
+
* The following values work on Android only:
|
|
469
|
+
*
|
|
470
|
+
* - `auto` - let Android decide
|
|
471
|
+
* - `no` - not important for autofill
|
|
472
|
+
* - `noExcludeDescendants` - this view and its children aren't important for autofill
|
|
473
|
+
* - `yes` - is important for autofill
|
|
474
|
+
* - `yesExcludeDescendants` - this view is important for autofill but its children aren't
|
|
475
|
+
*/
|
|
422
476
|
importantForAutofill?: ?(
|
|
423
477
|
| 'auto'
|
|
424
478
|
| 'no'
|
|
@@ -486,11 +540,7 @@ export type TextInputAndroidProps = $ReadOnly<{
|
|
|
486
540
|
underlineColorAndroid?: ?ColorValue,
|
|
487
541
|
}>;
|
|
488
542
|
|
|
489
|
-
|
|
490
|
-
...$Diff<ViewProps, $ReadOnly<{style: ?ViewStyleProp}>>,
|
|
491
|
-
...TextInputIOSProps,
|
|
492
|
-
...TextInputAndroidProps,
|
|
493
|
-
|
|
543
|
+
type TextInputBaseProps = $ReadOnly<{
|
|
494
544
|
/**
|
|
495
545
|
* Can tell `TextInput` to automatically capitalize certain characters.
|
|
496
546
|
*
|
|
@@ -792,7 +842,7 @@ export type TextInputProps = $ReadOnly<{
|
|
|
792
842
|
/**
|
|
793
843
|
* Callback that is called when text input ends.
|
|
794
844
|
*/
|
|
795
|
-
onEndEditing?: ?(e:
|
|
845
|
+
onEndEditing?: ?(e: TextInputEndEditingEvent) => mixed,
|
|
796
846
|
|
|
797
847
|
/**
|
|
798
848
|
* Callback that is called when the text input is focused.
|
|
@@ -834,7 +884,7 @@ export type TextInputProps = $ReadOnly<{
|
|
|
834
884
|
* Callback that is called when the text input's submit button is pressed.
|
|
835
885
|
* Invalid if `multiline={true}` is specified.
|
|
836
886
|
*/
|
|
837
|
-
onSubmitEditing?: ?(e:
|
|
887
|
+
onSubmitEditing?: ?(e: TextInputSubmitEditingEvent) => mixed,
|
|
838
888
|
|
|
839
889
|
/**
|
|
840
890
|
* Invoked on content scroll with `{ nativeEvent: { contentOffset: { x, y } } }`.
|
|
@@ -915,7 +965,9 @@ export type TextInputProps = $ReadOnly<{
|
|
|
915
965
|
selectionColor?: ?ColorValue,
|
|
916
966
|
|
|
917
967
|
/**
|
|
918
|
-
*
|
|
968
|
+
* When provided it will set the color of the selection handles when highlighting text.
|
|
969
|
+
* Unlike the behavior of `selectionColor` the handle color will be set independently
|
|
970
|
+
* from the color of the text selection box.
|
|
919
971
|
* @platform android
|
|
920
972
|
*/
|
|
921
973
|
selectionHandleColor?: ?ColorValue,
|
|
@@ -990,6 +1042,42 @@ export type TextInputProps = $ReadOnly<{
|
|
|
990
1042
|
value?: ?Stringish,
|
|
991
1043
|
}>;
|
|
992
1044
|
|
|
1045
|
+
export type TextInputProps = $ReadOnly<{
|
|
1046
|
+
...$Diff<ViewProps, $ReadOnly<{style: ?ViewStyleProp}>>,
|
|
1047
|
+
...TextInputIOSProps,
|
|
1048
|
+
...TextInputAndroidProps,
|
|
1049
|
+
...TextInputBaseProps,
|
|
1050
|
+
}>;
|
|
1051
|
+
|
|
1052
|
+
type TextInputStateType = $ReadOnly<{
|
|
1053
|
+
/**
|
|
1054
|
+
* @deprecated Use currentlyFocusedInput
|
|
1055
|
+
* Returns the ID of the currently focused text field, if one exists
|
|
1056
|
+
* If no text field is focused it returns null
|
|
1057
|
+
*/
|
|
1058
|
+
currentlyFocusedField: () => ?number,
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* Returns the ref of the currently focused text field, if one exists
|
|
1062
|
+
* If no text field is focused it returns null
|
|
1063
|
+
*/
|
|
1064
|
+
currentlyFocusedInput: () => ?HostInstance,
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* @param textField ref of the text field to focus
|
|
1068
|
+
* Focuses the specified text field
|
|
1069
|
+
* noop if the text field was already focused
|
|
1070
|
+
*/
|
|
1071
|
+
focusTextInput: (textField: ?HostInstance) => void,
|
|
1072
|
+
|
|
1073
|
+
/**
|
|
1074
|
+
* @param textField ref of the text field to focus
|
|
1075
|
+
* Unfocuses the specified text field
|
|
1076
|
+
* noop if it wasn't focused
|
|
1077
|
+
*/
|
|
1078
|
+
blurTextInput: (textField: ?HostInstance) => void,
|
|
1079
|
+
}>;
|
|
1080
|
+
|
|
993
1081
|
type ViewCommands = $NonMaybeType<
|
|
994
1082
|
| typeof AndroidTextInputCommands
|
|
995
1083
|
| typeof RCTMultilineTextInputNativeCommands
|
|
@@ -1008,7 +1096,7 @@ const emptyFunctionThatReturnsTrue = () => true;
|
|
|
1008
1096
|
* in native and in JavaScript. This is necessary due to the asynchronous nature
|
|
1009
1097
|
* of text input events.
|
|
1010
1098
|
*/
|
|
1011
|
-
function
|
|
1099
|
+
function useTextInputStateSynchronization({
|
|
1012
1100
|
props,
|
|
1013
1101
|
mostRecentEventCount,
|
|
1014
1102
|
selection,
|
|
@@ -1084,94 +1172,6 @@ function useTextInputStateSynchronization_STATE({
|
|
|
1084
1172
|
return {setLastNativeText, setLastNativeSelection};
|
|
1085
1173
|
}
|
|
1086
1174
|
|
|
1087
|
-
/**
|
|
1088
|
-
* This hook handles the synchronization between the state of the text input
|
|
1089
|
-
* in native and in JavaScript. This is necessary due to the asynchronous nature
|
|
1090
|
-
* of text input events.
|
|
1091
|
-
*/
|
|
1092
|
-
function useTextInputStateSynchronization_REFS({
|
|
1093
|
-
props,
|
|
1094
|
-
mostRecentEventCount,
|
|
1095
|
-
selection,
|
|
1096
|
-
inputRef,
|
|
1097
|
-
text,
|
|
1098
|
-
viewCommands,
|
|
1099
|
-
}: {
|
|
1100
|
-
props: TextInputProps,
|
|
1101
|
-
mostRecentEventCount: number,
|
|
1102
|
-
selection: ?Selection,
|
|
1103
|
-
inputRef: React.RefObject<null | TextInputInstance>,
|
|
1104
|
-
text?: string,
|
|
1105
|
-
viewCommands: ViewCommands,
|
|
1106
|
-
}): {
|
|
1107
|
-
setLastNativeText: string => void,
|
|
1108
|
-
setLastNativeSelection: LastNativeSelection => void,
|
|
1109
|
-
} {
|
|
1110
|
-
const lastNativeTextRef = useRef<?Stringish>(props.value);
|
|
1111
|
-
const lastNativeSelectionRef = useRef<LastNativeSelection>({
|
|
1112
|
-
selection: {start: -1, end: -1},
|
|
1113
|
-
mostRecentEventCount: mostRecentEventCount,
|
|
1114
|
-
});
|
|
1115
|
-
|
|
1116
|
-
// This is necessary in case native updates the text and JS decides
|
|
1117
|
-
// that the update should be ignored and we should stick with the value
|
|
1118
|
-
// that we have in JS.
|
|
1119
|
-
useLayoutEffect(() => {
|
|
1120
|
-
const nativeUpdate: {text?: string, selection?: Selection} = {};
|
|
1121
|
-
|
|
1122
|
-
const lastNativeSelection = lastNativeSelectionRef.current.selection;
|
|
1123
|
-
|
|
1124
|
-
if (
|
|
1125
|
-
lastNativeTextRef.current !== props.value &&
|
|
1126
|
-
typeof props.value === 'string'
|
|
1127
|
-
) {
|
|
1128
|
-
nativeUpdate.text = props.value;
|
|
1129
|
-
lastNativeTextRef.current = props.value;
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
if (
|
|
1133
|
-
selection &&
|
|
1134
|
-
lastNativeSelection &&
|
|
1135
|
-
(lastNativeSelection.start !== selection.start ||
|
|
1136
|
-
lastNativeSelection.end !== selection.end)
|
|
1137
|
-
) {
|
|
1138
|
-
nativeUpdate.selection = selection;
|
|
1139
|
-
lastNativeSelectionRef.current = {selection, mostRecentEventCount};
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
if (Object.keys(nativeUpdate).length === 0) {
|
|
1143
|
-
return;
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
if (inputRef.current != null) {
|
|
1147
|
-
viewCommands.setTextAndSelection(
|
|
1148
|
-
inputRef.current,
|
|
1149
|
-
mostRecentEventCount,
|
|
1150
|
-
text,
|
|
1151
|
-
selection?.start ?? -1,
|
|
1152
|
-
selection?.end ?? -1,
|
|
1153
|
-
);
|
|
1154
|
-
}
|
|
1155
|
-
}, [
|
|
1156
|
-
mostRecentEventCount,
|
|
1157
|
-
inputRef,
|
|
1158
|
-
props.value,
|
|
1159
|
-
props.defaultValue,
|
|
1160
|
-
selection,
|
|
1161
|
-
text,
|
|
1162
|
-
viewCommands,
|
|
1163
|
-
]);
|
|
1164
|
-
|
|
1165
|
-
return {
|
|
1166
|
-
setLastNativeText: lastNativeText => {
|
|
1167
|
-
lastNativeTextRef.current = lastNativeText;
|
|
1168
|
-
},
|
|
1169
|
-
setLastNativeSelection: lastNativeSelection => {
|
|
1170
|
-
lastNativeSelectionRef.current = lastNativeSelection;
|
|
1171
|
-
},
|
|
1172
|
-
};
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
1175
|
/**
|
|
1176
1176
|
* A foundational component for inputting text into the app via a
|
|
1177
1177
|
* keyboard. Props provide configurability for several features, such as
|
|
@@ -1324,10 +1324,6 @@ function InternalTextInput(props: TextInputProps): React.Node {
|
|
|
1324
1324
|
: RCTSinglelineTextInputNativeCommands);
|
|
1325
1325
|
|
|
1326
1326
|
const [mostRecentEventCount, setMostRecentEventCount] = useState<number>(0);
|
|
1327
|
-
const useTextInputStateSynchronization =
|
|
1328
|
-
ReactNativeFeatureFlags.useRefsForTextInputState()
|
|
1329
|
-
? useTextInputStateSynchronization_REFS
|
|
1330
|
-
: useTextInputStateSynchronization_STATE;
|
|
1331
1327
|
const {setLastNativeText, setLastNativeSelection} =
|
|
1332
1328
|
useTextInputStateSynchronization({
|
|
1333
1329
|
props,
|
|
@@ -1806,7 +1802,7 @@ const autoCompleteWebToTextContentTypeMap = {
|
|
|
1806
1802
|
};
|
|
1807
1803
|
|
|
1808
1804
|
const ExportedForwardRef: component(
|
|
1809
|
-
ref
|
|
1805
|
+
ref?: React.RefSetter<TextInputInstance>,
|
|
1810
1806
|
...props: React.ElementConfig<typeof InternalTextInput>
|
|
1811
1807
|
) = React.forwardRef(function TextInput(
|
|
1812
1808
|
{
|
|
@@ -1878,12 +1874,7 @@ ExportedForwardRef.State = {
|
|
|
1878
1874
|
};
|
|
1879
1875
|
|
|
1880
1876
|
export type TextInputComponentStatics = $ReadOnly<{
|
|
1881
|
-
State:
|
|
1882
|
-
currentlyFocusedInput: typeof TextInputState.currentlyFocusedInput,
|
|
1883
|
-
currentlyFocusedField: typeof TextInputState.currentlyFocusedField,
|
|
1884
|
-
focusTextInput: typeof TextInputState.focusTextInput,
|
|
1885
|
-
blurTextInput: typeof TextInputState.blurTextInput,
|
|
1886
|
-
}>,
|
|
1877
|
+
State: TextInputStateType,
|
|
1887
1878
|
}>;
|
|
1888
1879
|
|
|
1889
1880
|
const styles = StyleSheet.create({
|
|
@@ -18,7 +18,6 @@ import type {
|
|
|
18
18
|
import type {ViewProps} from '../View/ViewPropTypes';
|
|
19
19
|
import type {TextInputInstance, TextInputType} from './TextInput.flow';
|
|
20
20
|
|
|
21
|
-
import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
|
|
22
21
|
import usePressability from '../../Pressability/usePressability';
|
|
23
22
|
import flattenStyle from '../../StyleSheet/flattenStyle';
|
|
24
23
|
import StyleSheet, {
|
|
@@ -69,6 +68,9 @@ else if (Platform.OS === 'win32') {
|
|
|
69
68
|
}
|
|
70
69
|
// Windows]
|
|
71
70
|
|
|
71
|
+
/**
|
|
72
|
+
* @see TextInputProps.onChange
|
|
73
|
+
*/
|
|
72
74
|
export type TextInputChangeEventData = $ReadOnly<{
|
|
73
75
|
eventCount: number,
|
|
74
76
|
target: number,
|
|
@@ -91,6 +93,9 @@ export type TextInputEvent = NativeSyntheticEvent<
|
|
|
91
93
|
}>,
|
|
92
94
|
>;
|
|
93
95
|
|
|
96
|
+
/**
|
|
97
|
+
* @see TextInputProps.onContentSizeChange
|
|
98
|
+
*/
|
|
94
99
|
export type TextInputContentSizeChangeEventData = $ReadOnly<{
|
|
95
100
|
target: number,
|
|
96
101
|
contentSize: $ReadOnly<{
|
|
@@ -106,16 +111,29 @@ export type TargetEvent = $ReadOnly<{
|
|
|
106
111
|
target: number,
|
|
107
112
|
}>;
|
|
108
113
|
|
|
114
|
+
/**
|
|
115
|
+
* @see TextInputProps.onFocus
|
|
116
|
+
*/
|
|
109
117
|
export type TextInputFocusEventData = TargetEvent;
|
|
110
118
|
|
|
111
119
|
export type TextInputBlurEvent = NativeSyntheticEvent<TextInputFocusEventData>;
|
|
112
120
|
export type TextInputFocusEvent = NativeSyntheticEvent<TextInputFocusEventData>;
|
|
113
121
|
|
|
122
|
+
/**
|
|
123
|
+
* @see TextInputProps.onScroll
|
|
124
|
+
*/
|
|
125
|
+
export type TextInputScrollEventData = {
|
|
126
|
+
contentOffset: {x: number, y: number},
|
|
127
|
+
};
|
|
128
|
+
|
|
114
129
|
type Selection = $ReadOnly<{
|
|
115
130
|
start: number,
|
|
116
131
|
end: number,
|
|
117
132
|
}>;
|
|
118
133
|
|
|
134
|
+
/**
|
|
135
|
+
* @see TextInputProps.onSelectionChange
|
|
136
|
+
*/
|
|
119
137
|
export type TextInputSelectionChangeEventData = $ReadOnly<{
|
|
120
138
|
...TargetEvent,
|
|
121
139
|
selection: Selection,
|
|
@@ -124,7 +142,10 @@ export type TextInputSelectionChangeEventData = $ReadOnly<{
|
|
|
124
142
|
export type TextInputSelectionChangeEvent =
|
|
125
143
|
NativeSyntheticEvent<TextInputSelectionChangeEventData>;
|
|
126
144
|
|
|
127
|
-
|
|
145
|
+
/**
|
|
146
|
+
* @see TextInputProps.onKeyPress
|
|
147
|
+
*/
|
|
148
|
+
export type TextInputKeyPressEventData = $ReadOnly<{
|
|
128
149
|
...TargetEvent,
|
|
129
150
|
key: string,
|
|
130
151
|
target?: ?number,
|
|
@@ -134,12 +155,30 @@ type TextInputKeyPressEventData = $ReadOnly<{
|
|
|
134
155
|
export type TextInputKeyPressEvent =
|
|
135
156
|
NativeSyntheticEvent<TextInputKeyPressEventData>;
|
|
136
157
|
|
|
158
|
+
/**
|
|
159
|
+
* @see TextInputProps.onEndEditing
|
|
160
|
+
*/
|
|
137
161
|
export type TextInputEndEditingEventData = $ReadOnly<{
|
|
138
162
|
...TargetEvent,
|
|
139
163
|
eventCount: number,
|
|
140
164
|
text: string,
|
|
141
165
|
}>;
|
|
142
166
|
|
|
167
|
+
export type TextInputEndEditingEvent =
|
|
168
|
+
NativeSyntheticEvent<TextInputEndEditingEventData>;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @see TextInputProps.onSubmitEditing
|
|
172
|
+
*/
|
|
173
|
+
export type TextInputSubmitEditingEventData = $ReadOnly<{
|
|
174
|
+
...TargetEvent,
|
|
175
|
+
eventCount: number,
|
|
176
|
+
text: string,
|
|
177
|
+
}>;
|
|
178
|
+
|
|
179
|
+
export type TextInputSubmitEditingEvent =
|
|
180
|
+
NativeSyntheticEvent<TextInputSubmitEditingEventData>;
|
|
181
|
+
|
|
143
182
|
export type TextInputEditingEvent =
|
|
144
183
|
NativeSyntheticEvent<TextInputEndEditingEventData>;
|
|
145
184
|
|
|
@@ -427,6 +466,21 @@ export type TextInputAndroidProps = $ReadOnly<{
|
|
|
427
466
|
*/
|
|
428
467
|
disableFullscreenUI?: ?boolean,
|
|
429
468
|
|
|
469
|
+
/**
|
|
470
|
+
* Determines whether the individual fields in your app should be included in a
|
|
471
|
+
* view structure for autofill purposes on Android API Level 26+. Defaults to auto.
|
|
472
|
+
* To disable auto complete, use `off`.
|
|
473
|
+
*
|
|
474
|
+
* *Android Only*
|
|
475
|
+
*
|
|
476
|
+
* The following values work on Android only:
|
|
477
|
+
*
|
|
478
|
+
* - `auto` - let Android decide
|
|
479
|
+
* - `no` - not important for autofill
|
|
480
|
+
* - `noExcludeDescendants` - this view and its children aren't important for autofill
|
|
481
|
+
* - `yes` - is important for autofill
|
|
482
|
+
* - `yesExcludeDescendants` - this view is important for autofill but its children aren't
|
|
483
|
+
*/
|
|
430
484
|
importantForAutofill?: ?(
|
|
431
485
|
| 'auto'
|
|
432
486
|
| 'no'
|
|
@@ -520,12 +574,7 @@ type TextInputWindowsProps = $ReadOnly<{|
|
|
|
520
574
|
|
|
521
575
|
// Windows]
|
|
522
576
|
|
|
523
|
-
|
|
524
|
-
...$Diff<ViewProps, $ReadOnly<{style: ?ViewStyleProp}>>,
|
|
525
|
-
...TextInputIOSProps,
|
|
526
|
-
...TextInputAndroidProps,
|
|
527
|
-
...TextInputWindowsProps, // [Windows]
|
|
528
|
-
|
|
577
|
+
type TextInputBaseProps = $ReadOnly<{
|
|
529
578
|
/**
|
|
530
579
|
* String to be read by screenreaders to indicate an error state. The acceptable parameters
|
|
531
580
|
* of accessibilityErrorMessage is a string. Setting accessibilityInvalid to true activates
|
|
@@ -835,7 +884,7 @@ export type TextInputProps = $ReadOnly<{
|
|
|
835
884
|
/**
|
|
836
885
|
* Callback that is called when text input ends.
|
|
837
886
|
*/
|
|
838
|
-
onEndEditing?: ?(e:
|
|
887
|
+
onEndEditing?: ?(e: TextInputEndEditingEvent) => mixed,
|
|
839
888
|
|
|
840
889
|
/**
|
|
841
890
|
* Callback that is called when the text input is focused.
|
|
@@ -877,7 +926,7 @@ export type TextInputProps = $ReadOnly<{
|
|
|
877
926
|
* Callback that is called when the text input's submit button is pressed.
|
|
878
927
|
* Invalid if `multiline={true}` is specified.
|
|
879
928
|
*/
|
|
880
|
-
onSubmitEditing?: ?(e:
|
|
929
|
+
onSubmitEditing?: ?(e: TextInputSubmitEditingEvent) => mixed,
|
|
881
930
|
|
|
882
931
|
/**
|
|
883
932
|
* Invoked on content scroll with `{ nativeEvent: { contentOffset: { x, y } } }`.
|
|
@@ -958,7 +1007,9 @@ export type TextInputProps = $ReadOnly<{
|
|
|
958
1007
|
selectionColor?: ?ColorValue,
|
|
959
1008
|
|
|
960
1009
|
/**
|
|
961
|
-
*
|
|
1010
|
+
* When provided it will set the color of the selection handles when highlighting text.
|
|
1011
|
+
* Unlike the behavior of `selectionColor` the handle color will be set independently
|
|
1012
|
+
* from the color of the text selection box.
|
|
962
1013
|
* @platform android
|
|
963
1014
|
*/
|
|
964
1015
|
selectionHandleColor?: ?ColorValue,
|
|
@@ -1033,6 +1084,43 @@ export type TextInputProps = $ReadOnly<{
|
|
|
1033
1084
|
value?: ?Stringish,
|
|
1034
1085
|
}>;
|
|
1035
1086
|
|
|
1087
|
+
export type TextInputProps = $ReadOnly<{
|
|
1088
|
+
...$Diff<ViewProps, $ReadOnly<{style: ?ViewStyleProp}>>,
|
|
1089
|
+
...TextInputIOSProps,
|
|
1090
|
+
...TextInputAndroidProps,
|
|
1091
|
+
...TextInputBaseProps,
|
|
1092
|
+
...TextInputWindowsProps, // [Windows]
|
|
1093
|
+
}>;
|
|
1094
|
+
|
|
1095
|
+
type TextInputStateType = $ReadOnly<{
|
|
1096
|
+
/**
|
|
1097
|
+
* @deprecated Use currentlyFocusedInput
|
|
1098
|
+
* Returns the ID of the currently focused text field, if one exists
|
|
1099
|
+
* If no text field is focused it returns null
|
|
1100
|
+
*/
|
|
1101
|
+
currentlyFocusedField: () => ?number,
|
|
1102
|
+
|
|
1103
|
+
/**
|
|
1104
|
+
* Returns the ref of the currently focused text field, if one exists
|
|
1105
|
+
* If no text field is focused it returns null
|
|
1106
|
+
*/
|
|
1107
|
+
currentlyFocusedInput: () => ?HostInstance,
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* @param textField ref of the text field to focus
|
|
1111
|
+
* Focuses the specified text field
|
|
1112
|
+
* noop if the text field was already focused
|
|
1113
|
+
*/
|
|
1114
|
+
focusTextInput: (textField: ?HostInstance) => void,
|
|
1115
|
+
|
|
1116
|
+
/**
|
|
1117
|
+
* @param textField ref of the text field to focus
|
|
1118
|
+
* Unfocuses the specified text field
|
|
1119
|
+
* noop if it wasn't focused
|
|
1120
|
+
*/
|
|
1121
|
+
blurTextInput: (textField: ?HostInstance) => void,
|
|
1122
|
+
}>;
|
|
1123
|
+
|
|
1036
1124
|
type ViewCommands = $NonMaybeType<
|
|
1037
1125
|
| typeof AndroidTextInputCommands
|
|
1038
1126
|
| typeof RCTMultilineTextInputNativeCommands
|
|
@@ -1051,7 +1139,7 @@ const emptyFunctionThatReturnsTrue = () => true;
|
|
|
1051
1139
|
* in native and in JavaScript. This is necessary due to the asynchronous nature
|
|
1052
1140
|
* of text input events.
|
|
1053
1141
|
*/
|
|
1054
|
-
function
|
|
1142
|
+
function useTextInputStateSynchronization({
|
|
1055
1143
|
props,
|
|
1056
1144
|
mostRecentEventCount,
|
|
1057
1145
|
selection,
|
|
@@ -1127,94 +1215,6 @@ function useTextInputStateSynchronization_STATE({
|
|
|
1127
1215
|
return {setLastNativeText, setLastNativeSelection};
|
|
1128
1216
|
}
|
|
1129
1217
|
|
|
1130
|
-
/**
|
|
1131
|
-
* This hook handles the synchronization between the state of the text input
|
|
1132
|
-
* in native and in JavaScript. This is necessary due to the asynchronous nature
|
|
1133
|
-
* of text input events.
|
|
1134
|
-
*/
|
|
1135
|
-
function useTextInputStateSynchronization_REFS({
|
|
1136
|
-
props,
|
|
1137
|
-
mostRecentEventCount,
|
|
1138
|
-
selection,
|
|
1139
|
-
inputRef,
|
|
1140
|
-
text,
|
|
1141
|
-
viewCommands,
|
|
1142
|
-
}: {
|
|
1143
|
-
props: TextInputProps,
|
|
1144
|
-
mostRecentEventCount: number,
|
|
1145
|
-
selection: ?Selection,
|
|
1146
|
-
inputRef: React.RefObject<null | TextInputInstance>,
|
|
1147
|
-
text?: string,
|
|
1148
|
-
viewCommands: ViewCommands,
|
|
1149
|
-
}): {
|
|
1150
|
-
setLastNativeText: string => void,
|
|
1151
|
-
setLastNativeSelection: LastNativeSelection => void,
|
|
1152
|
-
} {
|
|
1153
|
-
const lastNativeTextRef = useRef<?Stringish>(props.value);
|
|
1154
|
-
const lastNativeSelectionRef = useRef<LastNativeSelection>({
|
|
1155
|
-
selection: {start: -1, end: -1},
|
|
1156
|
-
mostRecentEventCount: mostRecentEventCount,
|
|
1157
|
-
});
|
|
1158
|
-
|
|
1159
|
-
// This is necessary in case native updates the text and JS decides
|
|
1160
|
-
// that the update should be ignored and we should stick with the value
|
|
1161
|
-
// that we have in JS.
|
|
1162
|
-
useLayoutEffect(() => {
|
|
1163
|
-
const nativeUpdate: {text?: string, selection?: Selection} = {};
|
|
1164
|
-
|
|
1165
|
-
const lastNativeSelection = lastNativeSelectionRef.current.selection;
|
|
1166
|
-
|
|
1167
|
-
if (
|
|
1168
|
-
lastNativeTextRef.current !== props.value &&
|
|
1169
|
-
typeof props.value === 'string'
|
|
1170
|
-
) {
|
|
1171
|
-
nativeUpdate.text = props.value;
|
|
1172
|
-
lastNativeTextRef.current = props.value;
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
if (
|
|
1176
|
-
selection &&
|
|
1177
|
-
lastNativeSelection &&
|
|
1178
|
-
(lastNativeSelection.start !== selection.start ||
|
|
1179
|
-
lastNativeSelection.end !== selection.end)
|
|
1180
|
-
) {
|
|
1181
|
-
nativeUpdate.selection = selection;
|
|
1182
|
-
lastNativeSelectionRef.current = {selection, mostRecentEventCount};
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
if (Object.keys(nativeUpdate).length === 0) {
|
|
1186
|
-
return;
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
if (inputRef.current != null) {
|
|
1190
|
-
viewCommands.setTextAndSelection(
|
|
1191
|
-
inputRef.current,
|
|
1192
|
-
mostRecentEventCount,
|
|
1193
|
-
text,
|
|
1194
|
-
selection?.start ?? -1,
|
|
1195
|
-
selection?.end ?? -1,
|
|
1196
|
-
);
|
|
1197
|
-
}
|
|
1198
|
-
}, [
|
|
1199
|
-
mostRecentEventCount,
|
|
1200
|
-
inputRef,
|
|
1201
|
-
props.value,
|
|
1202
|
-
props.defaultValue,
|
|
1203
|
-
selection,
|
|
1204
|
-
text,
|
|
1205
|
-
viewCommands,
|
|
1206
|
-
]);
|
|
1207
|
-
|
|
1208
|
-
return {
|
|
1209
|
-
setLastNativeText: lastNativeText => {
|
|
1210
|
-
lastNativeTextRef.current = lastNativeText;
|
|
1211
|
-
},
|
|
1212
|
-
setLastNativeSelection: lastNativeSelection => {
|
|
1213
|
-
lastNativeSelectionRef.current = lastNativeSelection;
|
|
1214
|
-
},
|
|
1215
|
-
};
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
1218
|
/**
|
|
1219
1219
|
* A foundational component for inputting text into the app via a
|
|
1220
1220
|
* keyboard. Props provide configurability for several features, such as
|
|
@@ -1370,10 +1370,6 @@ function InternalTextInput(props: TextInputProps): React.Node {
|
|
|
1370
1370
|
: RCTSinglelineTextInputNativeCommands);
|
|
1371
1371
|
|
|
1372
1372
|
const [mostRecentEventCount, setMostRecentEventCount] = useState<number>(0);
|
|
1373
|
-
const useTextInputStateSynchronization =
|
|
1374
|
-
ReactNativeFeatureFlags.useRefsForTextInputState()
|
|
1375
|
-
? useTextInputStateSynchronization_REFS
|
|
1376
|
-
: useTextInputStateSynchronization_STATE;
|
|
1377
1373
|
const {setLastNativeText, setLastNativeSelection} =
|
|
1378
1374
|
useTextInputStateSynchronization({
|
|
1379
1375
|
props,
|
|
@@ -1947,7 +1943,7 @@ const autoCompleteWebToTextContentTypeMap = {
|
|
|
1947
1943
|
};
|
|
1948
1944
|
|
|
1949
1945
|
const ExportedForwardRef: component(
|
|
1950
|
-
ref
|
|
1946
|
+
ref?: React.RefSetter<TextInputInstance>,
|
|
1951
1947
|
...props: React.ElementConfig<typeof InternalTextInput>
|
|
1952
1948
|
) = React.forwardRef(function TextInput(
|
|
1953
1949
|
{
|
|
@@ -2018,12 +2014,7 @@ ExportedForwardRef.State = {
|
|
|
2018
2014
|
};
|
|
2019
2015
|
|
|
2020
2016
|
export type TextInputComponentStatics = $ReadOnly<{
|
|
2021
|
-
State:
|
|
2022
|
-
currentlyFocusedInput: typeof TextInputState.currentlyFocusedInput,
|
|
2023
|
-
currentlyFocusedField: typeof TextInputState.currentlyFocusedField,
|
|
2024
|
-
focusTextInput: typeof TextInputState.focusTextInput,
|
|
2025
|
-
blurTextInput: typeof TextInputState.blurTextInput,
|
|
2026
|
-
}>,
|
|
2017
|
+
State: TextInputStateType,
|
|
2027
2018
|
}>;
|
|
2028
2019
|
|
|
2029
2020
|
const styles = StyleSheet.create({
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
export declare const displayName = "TouchableWin32 Examples";
|
|
2
3
|
export declare const title = "TouchableWin32";
|
|
3
4
|
export declare const description = "Demonstration of touchable + focus + hover behavior all in one component";
|
|
4
5
|
export declare const examples: {
|
|
5
6
|
title: string;
|
|
6
7
|
description: string;
|
|
7
|
-
render(): JSX.Element;
|
|
8
|
+
render(): React.JSX.Element;
|
|
8
9
|
}[];
|