Skip to content

Commit 0ab913d

Browse files
authored
All changes pre 0.77 merge (#2394)
Contains all the internal changes pre 0.77. Squash of diffs D66828387..D69614635
1 parent a3f5c10 commit 0ab913d

468 files changed

Lines changed: 11965 additions & 6010 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

RNPrefixHeader.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
2+
3+
#ifdef __OBJC__
4+
#import <Foundation/Foundation.h>
5+
#endif

packages/react-native/Libraries/ActionSheetIOS/ActionSheetIOS.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const ActionSheetIOS = {
4949
+anchor?: ?number,
5050
+tintColor?: ColorValue | ProcessedColorValue,
5151
+cancelButtonTintColor?: ColorValue | ProcessedColorValue,
52+
+disabledButtonTintColor?: ColorValue | ProcessedColorValue,
5253
+userInterfaceStyle?: string,
5354
+disabledButtonIndices?: Array<number>,
5455
|},
@@ -64,6 +65,7 @@ const ActionSheetIOS = {
6465
const {
6566
tintColor,
6667
cancelButtonTintColor,
68+
disabledButtonTintColor,
6769
destructiveButtonIndex,
6870
...remainingOptions
6971
} = options;
@@ -77,6 +79,10 @@ const ActionSheetIOS = {
7779

7880
const processedTintColor = processColor(tintColor);
7981
const processedCancelButtonTintColor = processColor(cancelButtonTintColor);
82+
const processedDisabledButtonTintColor = processColor(
83+
disabledButtonTintColor,
84+
);
85+
8086
invariant(
8187
processedTintColor == null || typeof processedTintColor === 'number',
8288
'Unexpected color given for ActionSheetIOS.showActionSheetWithOptions tintColor',
@@ -86,13 +92,20 @@ const ActionSheetIOS = {
8692
typeof processedCancelButtonTintColor === 'number',
8793
'Unexpected color given for ActionSheetIOS.showActionSheetWithOptions cancelButtonTintColor',
8894
);
95+
invariant(
96+
processedDisabledButtonTintColor == null ||
97+
typeof processedDisabledButtonTintColor === 'number',
98+
'Unexpected color given for ActionSheetIOS.showActionSheetWithOptions disabledButtonTintColor',
99+
);
89100
RCTActionSheetManager.showActionSheetWithOptions(
90101
{
91102
...remainingOptions,
92103
// $FlowFixMe[incompatible-call]
93104
tintColor: processedTintColor,
94105
// $FlowFixMe[incompatible-call]
95106
cancelButtonTintColor: processedCancelButtonTintColor,
107+
// $FlowFixMe[incompatible-call]
108+
disabledButtonTintColor: processedDisabledButtonTintColor,
96109
destructiveButtonIndices,
97110
},
98111
callback,

packages/react-native/Libraries/Alert/Alert.js

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,53 +9,17 @@
99
*/
1010

1111
import type {DialogOptions} from '../NativeModules/specs/NativeDialogManagerAndroid';
12+
import type {AlertButtons, AlertOptions, AlertType} from './AlertTypes.flow';
1213

1314
import Platform from '../Utilities/Platform';
1415
import RCTAlertManager from './RCTAlertManager';
1516

16-
export type AlertType =
17-
| 'default'
18-
| 'plain-text'
19-
| 'secure-text'
20-
| 'login-password';
21-
export type AlertButtonStyle = 'default' | 'cancel' | 'destructive';
22-
export type Buttons = Array<{
23-
text?: string,
24-
onPress?: ?Function,
25-
isPreferred?: boolean,
26-
style?: AlertButtonStyle,
27-
...
28-
}>;
29-
// [macOS
30-
export type DefaultInputsArray = Array<{
31-
default?: string,
32-
placeholder?: string,
33-
style?: AlertButtonStyle,
34-
}>;
35-
// macOS]
36-
37-
type Options = {
38-
cancelable?: ?boolean,
39-
userInterfaceStyle?: 'unspecified' | 'light' | 'dark',
40-
onDismiss?: ?() => void,
41-
// [macOS
42-
modal?: ?boolean,
43-
critical?: ?boolean,
44-
// macOS]
45-
...
46-
};
47-
48-
/**
49-
* Launches an alert dialog with the specified title and message.
50-
*
51-
* See https://reactnative.dev/docs/alert
52-
*/
5317
class Alert {
5418
static alert(
5519
title: ?string,
5620
message?: ?string,
57-
buttons?: Buttons,
58-
options?: Options,
21+
buttons?: AlertButtons,
22+
options?: AlertOptions,
5923
): void {
6024
if (Platform.OS === 'ios') {
6125
Alert.prompt(
@@ -99,7 +63,7 @@ class Alert {
9963
// At most three buttons (neutral, negative, positive). Ignore rest.
10064
// The text 'OK' should be probably localized. iOS Alert does that in native.
10165
const defaultPositiveText = 'OK';
102-
const validButtons: Buttons = buttons
66+
const validButtons: AlertButtons = buttons
10367
? buttons.slice(0, 3)
10468
: [{text: defaultPositiveText}];
10569
const buttonPositive = validButtons.pop();
@@ -142,11 +106,11 @@ class Alert {
142106
static prompt(
143107
title: ?string,
144108
message?: ?string,
145-
callbackOrButtons?: ?(((text: string) => void) | Buttons),
109+
callbackOrButtons?: ?(((text: string) => void) | AlertButtons),
146110
type?: ?AlertType = 'plain-text',
147111
defaultValue?: string,
148112
keyboardType?: string,
149-
options?: Options,
113+
options?: AlertOptions,
150114
): void {
151115
if (Platform.OS === 'ios') {
152116
let callbacks: Array<?any> = [];
@@ -252,7 +216,7 @@ class Alert {
252216
static promptMacOS(
253217
title: ?string,
254218
message?: ?string,
255-
callbackOrButtons?: ?((text: string) => void) | Buttons,
219+
callbackOrButtons?: ?((text: string) => void) | AlertButtons,
256220
type?: ?AlertType = 'plain-text',
257221
defaultInputs?: DefaultInputsArray,
258222
modal?: ?boolean,
@@ -292,4 +256,4 @@ class Alert {
292256
// macOS]
293257
}
294258

295-
module.exports = Alert;
259+
export default Alert;

packages/react-native/Libraries/Alert/RCTAlertManager.ios.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {Args} from './NativeAlertManager';
1212

1313
import NativeAlertManager from './NativeAlertManager';
1414

15-
module.exports = {
15+
export default {
1616
alertWithArgs(
1717
args: Args,
1818
callback: (id: number, value: string) => void,
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2015-present, Facebook, Inc.
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
33
*
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -8,9 +8,18 @@
88
* @flow strict-local
99
*/
1010

11-
// [macOS]
11+
import type {Args} from './NativeAlertManager';
1212

13-
/* $FlowFixMe allow macOS to share iOS file */
14-
const alertWithArgs = require('./RCTAlertManager.ios');
13+
import NativeAlertManager from './NativeAlertManager';
1514

16-
module.exports = alertWithArgs;
15+
module.exports = {
16+
alertWithArgs(
17+
args: Args,
18+
callback: (id: number, value: string) => void,
19+
): void {
20+
if (NativeAlertManager == null) {
21+
return;
22+
}
23+
NativeAlertManager.alertWithArgs(args, callback);
24+
},
25+
};

packages/react-native/Libraries/Animated/AnimatedEvent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
import type {PlatformConfig} from './AnimatedPlatformConfig';
1414

15-
import {findNodeHandle} from '../ReactNative/RendererProxy';
1615
import NativeAnimatedHelper from '../../src/private/animated/NativeAnimatedHelper';
16+
import {findNodeHandle} from '../ReactNative/RendererProxy';
1717
import AnimatedValue from './nodes/AnimatedValue';
1818
import AnimatedValueXY from './nodes/AnimatedValueXY';
1919
import invariant from 'invariant';

packages/react-native/Libraries/Animated/AnimatedImplementation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ const parallel = function (
373373
const stopTogether = !(config && config.stopTogether === false);
374374

375375
const result = {
376-
start: function (callback?: ?EndCallback) {
376+
start: function (callback?: ?EndCallback, isLooping?: boolean) {
377377
if (doneCount === animations.length) {
378378
callback && callback({finished: true});
379379
return;
@@ -397,7 +397,7 @@ const parallel = function (
397397
if (!animation) {
398398
cb({finished: true});
399399
} else {
400-
animation.start(cb);
400+
animation.start(cb, isLooping);
401401
}
402402
});
403403
},

packages/react-native/Libraries/Animated/NativeAnimatedAllowlist.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* @format
99
*/
1010

11+
import type {AnimatedPropsAllowlist} from './nodes/AnimatedProps';
12+
1113
import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
1214

1315
/**
@@ -16,7 +18,7 @@ import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNa
1618
* In general native animated implementation should support any numeric or color property that
1719
* doesn't need to be updated through the shadow view hierarchy (all non-layout properties).
1820
*/
19-
const SUPPORTED_COLOR_STYLES: {[string]: boolean} = {
21+
const SUPPORTED_COLOR_STYLES: {[string]: true} = {
2022
backgroundColor: true,
2123
borderBottomColor: true,
2224
borderColor: true,
@@ -29,7 +31,7 @@ const SUPPORTED_COLOR_STYLES: {[string]: boolean} = {
2931
tintColor: true,
3032
};
3133

32-
const SUPPORTED_STYLES: {[string]: boolean} = {
34+
const SUPPORTED_STYLES: {[string]: true} = {
3335
...SUPPORTED_COLOR_STYLES,
3436
borderBottomEndRadius: true,
3537
borderBottomLeftRadius: true,
@@ -58,7 +60,7 @@ const SUPPORTED_STYLES: {[string]: boolean} = {
5860
translateY: true,
5961
};
6062

61-
const SUPPORTED_TRANSFORMS: {[string]: boolean} = {
63+
const SUPPORTED_TRANSFORMS: {[string]: true} = {
6264
translateX: true,
6365
translateY: true,
6466
scale: true,
@@ -71,17 +73,26 @@ const SUPPORTED_TRANSFORMS: {[string]: boolean} = {
7173
perspective: true,
7274
skewX: true,
7375
skewY: true,
74-
matrix: ReactNativeFeatureFlags.shouldUseAnimatedObjectForTransform(),
76+
...(ReactNativeFeatureFlags.shouldUseAnimatedObjectForTransform()
77+
? {matrix: true}
78+
: {}),
7579
};
7680

77-
const SUPPORTED_INTERPOLATION_PARAMS: {[string]: boolean} = {
81+
const SUPPORTED_INTERPOLATION_PARAMS: {[string]: true} = {
7882
inputRange: true,
7983
outputRange: true,
8084
extrapolate: true,
8185
extrapolateRight: true,
8286
extrapolateLeft: true,
8387
};
8488

89+
/**
90+
* Default allowlist for component props that support native animated values.
91+
*/
92+
export default {
93+
style: SUPPORTED_STYLES,
94+
} as AnimatedPropsAllowlist;
95+
8596
export function allowInterpolationParam(param: string): void {
8697
SUPPORTED_INTERPOLATION_PARAMS[param] = true;
8798
}
@@ -95,17 +106,17 @@ export function allowTransformProp(prop: string): void {
95106
}
96107

97108
export function isSupportedColorStyleProp(prop: string): boolean {
98-
return SUPPORTED_COLOR_STYLES[prop] === true;
109+
return SUPPORTED_COLOR_STYLES.hasOwnProperty(prop);
99110
}
100111

101112
export function isSupportedInterpolationParam(param: string): boolean {
102-
return SUPPORTED_INTERPOLATION_PARAMS[param] === true;
113+
return SUPPORTED_INTERPOLATION_PARAMS.hasOwnProperty(param);
103114
}
104115

105116
export function isSupportedStyleProp(prop: string): boolean {
106-
return SUPPORTED_STYLES[prop] === true;
117+
return SUPPORTED_STYLES.hasOwnProperty(prop);
107118
}
108119

109120
export function isSupportedTransformProp(prop: string): boolean {
110-
return SUPPORTED_TRANSFORMS[prop] === true;
121+
return SUPPORTED_TRANSFORMS.hasOwnProperty(prop);
111122
}

0 commit comments

Comments
 (0)