Skip to content

Commit

Permalink
Merge pull request facebook#840 from amgleitman/amgleitman/0.64-merge…
Browse files Browse the repository at this point in the history
…-2020-10-14

Merge from upstream through 2020-10-14
  • Loading branch information
amgleitman committed Oct 6, 2021
2 parents 3203279 + 7414a7d commit eb53c09
Show file tree
Hide file tree
Showing 202 changed files with 12,464 additions and 13,099 deletions.
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# node_modules ignored by default

**/main.js
**/staticBundle.js
bots/node_modules
docs/generatedComponentApiDocs.js
flow/
Libraries/Renderer/*
Libraries/vendor/**/*
node_modules/
packages/*/node_modules
packages/*/lib
packages/*/lib-commonjs
Expand Down
5 changes: 0 additions & 5 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ flow/
[options]
emoji=true

esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable

exact_by_default=true

module.file_ext=.js
Expand All @@ -55,8 +52,6 @@ suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState
suppress_type=$FlowFixMeEmpty

well_formed_exports=true
types_first=true
experimental.abstract_locations=true

[lints]
Expand Down
5 changes: 0 additions & 5 deletions .flowconfig.android
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ flow/
[options]
emoji=true

esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable

exact_by_default=true

module.file_ext=.js
Expand All @@ -58,8 +55,6 @@ suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState
suppress_type=$FlowFixMeEmpty

well_formed_exports=true
types_first=true
experimental.abstract_locations=true

[lints]
Expand Down
8 changes: 4 additions & 4 deletions Libraries/Components/Picker/Picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ type PickerItemProps = $ReadOnly<{|

/**
* The value to be passed to picker's `onValueChange` callback when
* this item is selected. Can be a string or an integer.
* this item is selected.
*/
value?: ?(number | string),
value?: ?string,

/**
* Color of this item's text.
Expand Down Expand Up @@ -62,9 +62,9 @@ type PickerProps = $ReadOnly<{|
style?: ?TextStyleProp,

/**
* Value matching value of one of the items. Can be a string or an integer.
* Value matching value of one of the items.
*/
selectedValue?: ?(number | string),
selectedValue?: ?string,

/**
* Callback for when an item is selected. This is called with the following parameters:
Expand Down
6 changes: 3 additions & 3 deletions Libraries/Components/Picker/PickerIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type PickerIOSChangeEvent = SyntheticEvent<

type RCTPickerIOSItemType = $ReadOnly<{|
label: ?Label,
value: ?(number | string),
value: ?string,
textColor: ?ProcessedColorValue,
|}>;

Expand All @@ -50,7 +50,7 @@ type Props = $ReadOnly<{|
itemStyle?: ?TextStyleProp,
onChange?: ?(event: PickerIOSChangeEvent) => mixed,
onValueChange?: ?(itemValue: string | number, itemIndex: number) => mixed,
selectedValue: ?(number | string),
selectedValue: ?string,
accessibilityLabel?: ?string,
|}>;

Expand All @@ -61,7 +61,7 @@ type State = {|

type ItemProps = $ReadOnly<{|
label: ?Label,
value?: ?(number | string),
value?: ?string,
color?: ?ColorValue,
|}>;

Expand Down
19 changes: 14 additions & 5 deletions Libraries/Components/Picker/RCTPickerNativeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
'use strict';

const requireNativeComponent = require('../../ReactNative/requireNativeComponent');
const ReactNativeViewConfigRegistry = require('../../Renderer/shims/ReactNativeViewConfigRegistry');

import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import type {SyntheticEvent} from '../../Types/CoreEventTypes';
import type {TextStyleProp} from '../../StyleSheet/StyleSheet';
import type {ProcessedColorValue} from '../../StyleSheet/processColor';
import codegenNativeCommands from '../../Utilities/codegenNativeCommands';
import RCTPickerViewConfig from './RCTPickerViewConfig';
import * as React from 'react';

type PickerIOSChangeEvent = SyntheticEvent<
Expand All @@ -28,7 +30,7 @@ type PickerIOSChangeEvent = SyntheticEvent<

type RCTPickerIOSItemType = $ReadOnly<{|
label: ?Label,
value: ?(number | string),
value: ?string,
textColor: ?ProcessedColorValue,
|}>;

Expand Down Expand Up @@ -56,8 +58,15 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
supportedCommands: ['setNativeSelectedIndex'],
});

const RCTPickerNativeComponent: ComponentType = requireNativeComponent<NativeProps>(
'RCTPicker',
);
let RCTPickerNativeComponent;
if (global.RN$Bridgeless) {
ReactNativeViewConfigRegistry.register('RCTPicker', () => {
return RCTPickerViewConfig;
});
RCTPickerNativeComponent = 'RCTPicker';
} else {
RCTPickerNativeComponent = requireNativeComponent<NativeProps>('RCTPicker');
}

export default RCTPickerNativeComponent;
// flowlint-next-line unclear-type:off
export default ((RCTPickerNativeComponent: any): HostComponent<NativeProps>);
41 changes: 41 additions & 0 deletions Libraries/Components/Picker/RCTPickerViewConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/

'use strict';

import ReactNativeViewViewConfig from '../../Components/View/ReactNativeViewViewConfig';
import type {ReactNativeBaseComponentViewConfig} from '../../Renderer/shims/ReactNativeTypes';

const RCTPickerViewConfig = {
uiViewClassName: 'RCTPicker',
bubblingEventTypes: {
topChange: {
phasedRegistrationNames: {
bubbled: 'onChange',
captured: 'onChangeCapture',
},
},
},
directEventTypes: {},
validAttributes: {
...ReactNativeViewViewConfig.validAttributes,
color: {process: require('../../StyleSheet/processColor')},
fontFamily: true,
fontSize: true,
fontStyle: true,
fontWeight: true,
items: true,
onChange: true,
selectedIndex: true,
textAlign: true,
},
};

module.exports = (RCTPickerViewConfig: ReactNativeBaseComponentViewConfig<>);
62 changes: 31 additions & 31 deletions Libraries/Components/Switch/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,39 +173,39 @@ class Switch extends React.Component<Props> {
ref={this._handleSwitchNativeComponentRef}
/>
);
}

const platformProps = {
disabled,
onTintColor: trackColorForTrue,
style: StyleSheet.compose(
{height: 31, width: 51},
StyleSheet.compose(
style,
ios_backgroundColor == null
? null
: {
backgroundColor: ios_backgroundColor,
borderRadius: 16,
},
} else {
const platformProps = {
disabled,
onTintColor: trackColorForTrue,
style: StyleSheet.compose(
{height: 31, width: 51},
StyleSheet.compose(
style,
ios_backgroundColor == null
? null
: {
backgroundColor: ios_backgroundColor,
borderRadius: 16,
},
),
),
),
thumbTintColor: thumbColor,
tintColor: trackColorForFalse,
value: value === true,
};
thumbTintColor: thumbColor,
tintColor: trackColorForFalse,
value: value === true,
};

return (
<SwitchNativeComponent
{...props}
{...platformProps}
accessibilityRole={props.accessibilityRole ?? 'switch'}
onChange={this._handleChange}
onResponderTerminationRequest={returnsFalse}
onStartShouldSetResponder={returnsTrue}
ref={this._handleSwitchNativeComponentRef}
/>
);
return (
<SwitchNativeComponent
{...props}
{...platformProps}
accessibilityRole={props.accessibilityRole ?? 'switch'}
onChange={this._handleChange}
onResponderTerminationRequest={returnsFalse}
onStartShouldSetResponder={returnsTrue}
ref={this._handleSwitchNativeComponentRef}
/>
);
}
}

componentDidUpdate() {
Expand Down
22 changes: 18 additions & 4 deletions Libraries/EventEmitter/NativeEventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,29 @@ type NativeModule = {
...
};

type NativeEventEmitterOptions = $ReadOnly<{|
__SECRET_DISABLE_CALLS_INTO_MODULE_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: boolean,
|}>;

const DEFAULT_NATIVE_EVENT_EMITTER_OPTIONS = {
__SECRET_DISABLE_CALLS_INTO_MODULE_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: false,
};

/**
* Abstract base class for implementing event-emitting modules. This implements
* a subset of the standard EventEmitter node module API.
*/
export default class NativeEventEmitter extends EventEmitter {
_nativeModule: ?NativeModule;
_disableCallsIntoModule: boolean;

constructor(nativeModule: ?NativeModule) {
constructor(
nativeModule: ?NativeModule,
options: NativeEventEmitterOptions = DEFAULT_NATIVE_EVENT_EMITTER_OPTIONS,
) {
super(RCTDeviceEventEmitter.sharedSubscriber);
this._disableCallsIntoModule =
options.__SECRET_DISABLE_CALLS_INTO_MODULE_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
if (
Platform.OS === 'ios' ||
Platform.OS === 'macos' /* TODO(macOS GH#774) */
Expand All @@ -45,7 +59,7 @@ export default class NativeEventEmitter extends EventEmitter {
listener: Function,
context: ?Object,
): EventSubscription {
if (this._nativeModule != null) {
if (this._nativeModule != null && !this._disableCallsIntoModule) {
this._nativeModule.addListener(eventType);
}
return super.addListener(eventType, listener, context);
Expand All @@ -54,14 +68,14 @@ export default class NativeEventEmitter extends EventEmitter {
removeAllListeners(eventType: string) {
invariant(eventType, 'eventType argument is required.');
const count = this.listenerCount(eventType);
if (this._nativeModule != null) {
if (this._nativeModule != null && !this._disableCallsIntoModule) {
this._nativeModule.removeListeners(count);
}
super.removeAllListeners(eventType);
}

removeSubscription(subscription: EventSubscription) {
if (this._nativeModule != null) {
if (this._nativeModule != null && !this._disableCallsIntoModule) {
this._nativeModule.removeListeners(1);
}
super.removeSubscription(subscription);
Expand Down
Loading

0 comments on commit eb53c09

Please sign in to comment.