Bring missing changes to 0.58-stable branch

This reverts commit b864e7e63e.
This commit is contained in:
Mike Grabowski
2019-01-28 14:56:57 +01:00
parent a289b7efb0
commit 9d19ab0c0c
130 changed files with 2583 additions and 1107 deletions
+92 -24
View File
@@ -34,6 +34,8 @@ const warning = require('fbjs/lib/warning');
import type {TextStyleProp, ViewStyleProp} from 'StyleSheet';
import type {ColorValue} from 'StyleSheetTypes';
import type {ViewProps} from 'ViewPropTypes';
import type {SyntheticEvent, ScrollEvent} from 'CoreEventTypes';
import type {PressEvent} from 'CoreEventTypes';
let AndroidTextInput;
let RCTMultilineTextInputView;
@@ -55,11 +57,73 @@ const onlyMultiline = {
children: true,
};
type Event = Object;
type Selection = {
export type ChangeEvent = SyntheticEvent<
$ReadOnly<{|
eventCount: number,
target: number,
text: string,
|}>,
>;
export type TextInputEvent = SyntheticEvent<
$ReadOnly<{|
eventCount: number,
previousText: string,
range: $ReadOnly<{|
start: number,
end: number,
|}>,
target: number,
text: string,
|}>,
>;
export type ContentSizeChangeEvent = SyntheticEvent<
$ReadOnly<{|
target: number,
contentSize: $ReadOnly<{|
width: number,
height: number,
|}>,
|}>,
>;
type TargetEvent = SyntheticEvent<
$ReadOnly<{|
target: number,
|}>,
>;
export type BlurEvent = TargetEvent;
export type FocusEvent = TargetEvent;
type Selection = $ReadOnly<{|
start: number,
end?: number,
};
end: number,
|}>;
export type SelectionChangeEvent = SyntheticEvent<
$ReadOnly<{|
selection: Selection,
target: number,
|}>,
>;
export type KeyPressEvent = SyntheticEvent<
$ReadOnly<{|
key: string,
target?: ?number,
eventCount?: ?number,
|}>,
>;
export type EditingEvent = SyntheticEvent<
$ReadOnly<{|
eventCount: number,
text: string,
target: number,
|}>,
>;
const DataDetectorTypes = [
'phoneNumber',
@@ -184,17 +248,17 @@ type Props = $ReadOnly<{|
returnKeyType?: ?ReturnKeyType,
maxLength?: ?number,
multiline?: ?boolean,
onBlur?: ?Function,
onFocus?: ?Function,
onChange?: ?Function,
onChangeText?: ?Function,
onContentSizeChange?: ?Function,
onTextInput?: ?Function,
onEndEditing?: ?Function,
onSelectionChange?: ?Function,
onSubmitEditing?: ?Function,
onKeyPress?: ?Function,
onScroll?: ?Function,
onBlur?: ?(e: BlurEvent) => void,
onFocus?: ?(e: FocusEvent) => void,
onChange?: ?(e: ChangeEvent) => void,
onChangeText?: ?(text: string) => void,
onContentSizeChange?: ?(e: ContentSizeChangeEvent) => void,
onTextInput?: ?(e: TextInputEvent) => void,
onEndEditing?: ?(e: EditingEvent) => void,
onSelectionChange?: ?(e: SelectionChangeEvent) => void,
onSubmitEditing?: ?(e: EditingEvent) => void,
onKeyPress?: ?(e: KeyPressEvent) => void,
onScroll?: ?(e: ScrollEvent) => void,
placeholder?: ?Stringish,
placeholderTextColor?: ?ColorValue,
secureTextEntry?: ?boolean,
@@ -792,7 +856,7 @@ const TextInput = createReactClass({
'oneTimeCode',
]),
},
getDefaultProps(): Object {
getDefaultProps() {
return {
allowFontScaling: true,
underlineColorAndroid: 'transparent',
@@ -1108,7 +1172,7 @@ const TextInput = createReactClass({
);
},
_onFocus: function(event: Event) {
_onFocus: function(event: FocusEvent) {
if (this.props.onFocus) {
this.props.onFocus(event);
}
@@ -1118,16 +1182,16 @@ const TextInput = createReactClass({
}
},
_onPress: function(event: Event) {
_onPress: function(event: PressEvent) {
if (this.props.editable || this.props.editable === undefined) {
this.focus();
}
},
_onChange: function(event: Event) {
_onChange: function(event: ChangeEvent) {
// Make sure to fire the mostRecentEventCount first so it is already set on
// native when the text value is set.
if (this._inputRef) {
if (this._inputRef && this._inputRef.setNativeProps) {
this._inputRef.setNativeProps({
mostRecentEventCount: event.nativeEvent.eventCount,
});
@@ -1147,7 +1211,7 @@ const TextInput = createReactClass({
this.forceUpdate();
},
_onSelectionChange: function(event: Event) {
_onSelectionChange: function(event: SelectionChangeEvent) {
this.props.onSelectionChange && this.props.onSelectionChange(event);
if (!this._inputRef) {
@@ -1188,7 +1252,11 @@ const TextInput = createReactClass({
nativeProps.selection = this.props.selection;
}
if (Object.keys(nativeProps).length > 0 && this._inputRef) {
if (
Object.keys(nativeProps).length > 0 &&
this._inputRef &&
this._inputRef.setNativeProps
) {
this._inputRef.setNativeProps(nativeProps);
}
@@ -1211,11 +1279,11 @@ const TextInput = createReactClass({
}
},
_onTextInput: function(event: Event) {
_onTextInput: function(event: TextInputEvent) {
this.props.onTextInput && this.props.onTextInput(event);
},
_onScroll: function(event: Event) {
_onScroll: function(event: ScrollEvent) {
this.props.onScroll && this.props.onScroll(event);
},
});