@office-iss/react-native-win32 0.0.0-canary.255 → 0.0.0-canary.257

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.
Files changed (57) hide show
  1. package/.flowconfig +1 -1
  2. package/CHANGELOG.json +79 -1
  3. package/CHANGELOG.md +28 -4
  4. package/Libraries/Components/TextInput/InputAccessoryView.js +10 -1
  5. package/Libraries/Components/View/ViewAccessibility.js +4 -4
  6. package/Libraries/Components/View/ViewAccessibility.win32.js +6 -6
  7. package/Libraries/Core/ReactNativeVersion.js +1 -1
  8. package/Libraries/Core/setUpTimers.js +19 -0
  9. package/Libraries/Image/ImageProps.js +16 -5
  10. package/Libraries/Image/ImageViewNativeComponent.js +2 -1
  11. package/Libraries/LogBox/Data/LogBoxData.js +39 -4
  12. package/Libraries/LogBox/Data/LogBoxLog.js +5 -2
  13. package/Libraries/LogBox/Data/parseLogBoxLog.js +23 -2
  14. package/Libraries/LogBox/LogBox.js +29 -12
  15. package/Libraries/LogBox/LogBoxNotificationContainer.js +4 -0
  16. package/Libraries/LogBox/UI/LogBoxInspector.js +8 -70
  17. package/Libraries/LogBox/UI/LogBoxInspectorBody.js +87 -0
  18. package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +6 -42
  19. package/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js +58 -0
  20. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +5 -66
  21. package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +7 -72
  22. package/Libraries/LogBox/UI/LogBoxInspectorHeaderButton.js +76 -0
  23. package/Libraries/LogBox/UI/LogBoxNotification.js +13 -152
  24. package/Libraries/LogBox/UI/LogBoxNotificationCountBadge.js +63 -0
  25. package/Libraries/LogBox/UI/LogBoxNotificationDismissButton.js +67 -0
  26. package/Libraries/LogBox/UI/LogBoxNotificationMessage.js +57 -0
  27. package/Libraries/Renderer/implementations/ReactFabric-dev.js +15690 -26405
  28. package/Libraries/Renderer/implementations/ReactFabric-prod.js +2675 -1630
  29. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +2945 -1682
  30. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +16141 -27018
  31. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +2723 -1666
  32. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +2984 -1737
  33. package/Libraries/Renderer/shims/ReactFabric.js +2 -2
  34. package/Libraries/Renderer/shims/ReactFeatureFlags.js +2 -2
  35. package/Libraries/Renderer/shims/ReactNative.js +2 -3
  36. package/Libraries/Renderer/shims/ReactNativeTypes.js +2 -2
  37. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +2 -2
  38. package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -2
  39. package/Libraries/Share/Share.d.ts +16 -10
  40. package/Libraries/Share/Share.js +14 -15
  41. package/Libraries/Text/Text.js +142 -121
  42. package/Libraries/Text/Text.win32.js +153 -130
  43. package/Libraries/Text/TextNativeComponent.js +6 -5
  44. package/Libraries/Text/TextNativeComponent.win32.js +6 -5
  45. package/Libraries/Text/TextOptimized.js +538 -0
  46. package/Libraries/Text/TextProps.js +6 -6
  47. package/Libraries/Text/TextProps.win32.js +6 -6
  48. package/Libraries/Types/CodegenTypes.js +3 -0
  49. package/Libraries/Utilities/ReactNativeTestTools.js +7 -24
  50. package/Libraries/__tests__/ButtonWin32-test.js +7 -6
  51. package/Libraries/promiseRejectionTrackingOptions.js +1 -0
  52. package/jest/renderer.js +25 -14
  53. package/jest/setup.js +5 -0
  54. package/overrides.json +7 -7
  55. package/package.json +19 -19
  56. package/src/private/specs/modules/NativeDevSettings.js +1 -0
  57. package/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js +34 -0
@@ -56,8 +56,10 @@ const Text: React.AbstractComponent<
56
56
  'aria-selected': ariaSelected,
57
57
  'aria-setsize': ariaSetsize, // Win32
58
58
  ellipsizeMode,
59
+ disabled,
59
60
  id,
60
61
  nativeID,
62
+ numberOfLines,
61
63
  onLongPress,
62
64
  onPress,
63
65
  onPressIn,
@@ -69,15 +71,20 @@ const Text: React.AbstractComponent<
69
71
  onResponderTerminationRequest,
70
72
  onStartShouldSetResponder,
71
73
  pressRetentionOffset,
74
+ selectable,
75
+ selectionColor,
72
76
  suppressHighlighting,
77
+ style,
73
78
  ...restProps
74
79
  } = props;
75
80
 
76
81
  const [isHighlighted, setHighlighted] = useState(false);
77
82
 
78
- let _accessibilityState;
83
+ const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
84
+
85
+ let _accessibilityState: ?TextProps['accessibilityState'] =
86
+ accessibilityState;
79
87
  if (
80
- accessibilityState != null ||
81
88
  ariaBusy != null ||
82
89
  ariaChecked != null ||
83
90
  ariaDisabled != null ||
@@ -86,27 +93,32 @@ const Text: React.AbstractComponent<
86
93
  ariaRequired != null ||
87
94
  ariaSelected != null
88
95
  ) {
89
- _accessibilityState = {
90
- busy: ariaBusy ?? accessibilityState?.busy,
91
- checked: ariaChecked ?? accessibilityState?.checked,
92
- disabled: ariaDisabled ?? accessibilityState?.disabled,
93
- expanded: ariaExpanded ?? accessibilityState?.expanded,
94
- multiselectable:
95
- ariaMultiselectable ?? accessibilityState?.multiselectable, // Win32
96
- required: ariaRequired ?? accessibilityState?.required, // Win32
97
- selected: ariaSelected ?? accessibilityState?.selected,
98
- };
96
+ if (_accessibilityState != null) {
97
+ _accessibilityState = {
98
+ busy: ariaBusy ?? _accessibilityState.busy,
99
+ checked: ariaChecked ?? _accessibilityState.checked,
100
+ disabled: ariaDisabled ?? _accessibilityState.disabled,
101
+ expanded: ariaExpanded ?? _accessibilityState.expanded,
102
+ multiselectable:
103
+ ariaMultiselectable ?? accessibilityState?.multiselectable, // Win32
104
+ required: ariaRequired ?? accessibilityState?.required, // Win32
105
+ selected: ariaSelected ?? _accessibilityState.selected,
106
+ };
107
+ } else {
108
+ _accessibilityState = {
109
+ busy: ariaBusy,
110
+ checked: ariaChecked,
111
+ disabled: ariaDisabled,
112
+ expanded: ariaExpanded,
113
+ multiselectable: ariaMultiselectable, // Win32,
114
+ required: ariaRequired, // Win32
115
+ selected: ariaSelected,
116
+ };
117
+ }
99
118
  }
100
119
 
101
- const _disabled =
102
- restProps.disabled != null
103
- ? restProps.disabled
104
- : _accessibilityState?.disabled;
105
-
106
- const nativeTextAccessibilityState =
107
- _disabled !== _accessibilityState?.disabled
108
- ? {..._accessibilityState, disabled: _disabled}
109
- : _accessibilityState;
120
+ const _accessibilityStateDisabled = _accessibilityState?.disabled;
121
+ const _disabled = disabled ?? _accessibilityStateDisabled;
110
122
 
111
123
  const isPressable =
112
124
  (onPress != null ||
@@ -115,41 +127,47 @@ const Text: React.AbstractComponent<
115
127
  _disabled !== true;
116
128
 
117
129
  const initialized = useLazyInitialization(isPressable);
118
- const config = useMemo(
119
- () =>
120
- initialized
121
- ? {
122
- disabled: !isPressable,
123
- pressRectOffset: pressRetentionOffset,
124
- onLongPress,
125
- onPress,
126
- onPressIn(event: PressEvent) {
127
- // Updating isHighlighted causes unnecessary re-renders for platforms that don't use it
128
- // in the best case, and cause issues with text selection in the worst case. Forcing
129
- // the isHighlighted prop to false on all platforms except iOS.
130
- setHighlighted(
131
- (suppressHighlighting == null || !suppressHighlighting) &&
132
- Platform.OS === 'ios',
133
- );
134
- onPressIn?.(event);
135
- },
136
- onPressOut(event: PressEvent) {
137
- setHighlighted(false);
138
- onPressOut?.(event);
139
- },
140
- }
141
- : null,
142
- [
143
- initialized,
144
- isPressable,
145
- pressRetentionOffset,
130
+ const config = useMemo(() => {
131
+ if (!initialized) {
132
+ return null;
133
+ }
134
+
135
+ let _onPressIn = onPressIn;
136
+ let _onPressOut = onPressOut;
137
+
138
+ // Updating isHighlighted causes unnecessary re-renders for platforms that don't use it
139
+ // in the best case, and cause issues with text selection in the worst case. Forcing
140
+ // the isHighlighted prop to false on all platforms except iOS.
141
+ if (Platform.OS === 'ios') {
142
+ _onPressIn = (event: PressEvent) => {
143
+ setHighlighted(suppressHighlighting == null || !suppressHighlighting);
144
+ onPressIn?.(event);
145
+ };
146
+
147
+ _onPressOut = (event: PressEvent) => {
148
+ setHighlighted(false);
149
+ onPressOut?.(event);
150
+ };
151
+ }
152
+
153
+ return {
154
+ disabled: !isPressable,
155
+ pressRectOffset: pressRetentionOffset,
146
156
  onLongPress,
147
157
  onPress,
148
- onPressIn,
149
- onPressOut,
150
- suppressHighlighting,
151
- ],
152
- );
158
+ onPressIn: _onPressIn,
159
+ onPressOut: _onPressOut,
160
+ };
161
+ }, [
162
+ initialized,
163
+ isPressable,
164
+ pressRetentionOffset,
165
+ onLongPress,
166
+ onPress,
167
+ onPressIn,
168
+ onPressOut,
169
+ suppressHighlighting,
170
+ ]);
153
171
 
154
172
  const eventHandlers = usePressability(config);
155
173
  const eventHandlersForText = useMemo(
@@ -203,115 +221,120 @@ const Text: React.AbstractComponent<
203
221
  );
204
222
 
205
223
  // TODO: Move this processing to the view configuration.
206
- const selectionColor =
207
- restProps.selectionColor == null
208
- ? null
209
- : processColor(restProps.selectionColor);
210
-
211
- let style = restProps.style;
224
+ const _selectionColor =
225
+ selectionColor == null ? null : processColor(selectionColor);
212
226
 
227
+ let _style = style;
213
228
  if (__DEV__) {
214
229
  if (PressabilityDebug.isEnabled() && onPress != null) {
215
- style = [restProps.style, {color: 'magenta'}];
230
+ _style = [style, {color: 'magenta'}];
216
231
  }
217
232
  }
218
233
 
219
- let numberOfLines = restProps.numberOfLines;
220
- if (numberOfLines != null && !(numberOfLines >= 0)) {
221
- console.error(
222
- `'numberOfLines' in <Text> must be a non-negative number, received: ${numberOfLines}. The value will be set to 0.`,
223
- );
224
- numberOfLines = 0;
234
+ let _numberOfLines = numberOfLines;
235
+ if (_numberOfLines != null && !(_numberOfLines >= 0)) {
236
+ if (__DEV__) {
237
+ console.error(
238
+ `'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
239
+ );
240
+ }
241
+ _numberOfLines = 0;
225
242
  }
226
243
 
227
- const hasTextAncestor = useContext(TextAncestor);
228
-
229
- const _accessible = Platform.select({
230
- ios: accessible !== false,
231
- default: accessible,
232
- });
244
+ let _selectable = selectable;
245
+ const processedStyle = flattenStyle(_style);
246
+ if (processedStyle != null) {
247
+ if (typeof processedStyle.fontWeight === 'number') {
248
+ // $FlowFixMe[cannot-write]
249
+ processedStyle.fontWeight = processedStyle.fontWeight.toString();
250
+ }
233
251
 
234
- // $FlowFixMe[underconstrained-implicit-instantiation]
235
- style = flattenStyle(style);
252
+ if (processedStyle.userSelect != null) {
253
+ _selectable = userSelectToSelectableMap[processedStyle.userSelect];
254
+ // $FlowFixMe[cannot-write]
255
+ delete processedStyle.userSelect;
256
+ }
236
257
 
237
- if (typeof style?.fontWeight === 'number') {
238
- // $FlowFixMe[prop-missing]
239
- // $FlowFixMe[cannot-write]
240
- style.fontWeight = style?.fontWeight.toString();
258
+ if (processedStyle.verticalAlign != null) {
259
+ // $FlowFixMe[cannot-write]
260
+ processedStyle.textAlignVertical =
261
+ verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
262
+ // $FlowFixMe[cannot-write]
263
+ delete processedStyle.verticalAlign;
264
+ }
241
265
  }
242
266
 
243
- let _selectable = restProps.selectable;
244
- if (style?.userSelect != null) {
245
- // $FlowFixMe[invalid-computed-prop]
246
- _selectable = userSelectToSelectableMap[style.userSelect];
247
- // $FlowFixMe[prop-missing]
248
- // $FlowFixMe[cannot-write]
249
- delete style.userSelect;
267
+ const _nativeID = id ?? nativeID;
268
+
269
+ const hasTextAncestor = useContext(TextAncestor);
270
+ if (hasTextAncestor) {
271
+ return (
272
+ <NativeVirtualText
273
+ {...restProps}
274
+ {...eventHandlersForText}
275
+ accessibilityLabel={_accessibilityLabel}
276
+ accessibilityState={_accessibilityState}
277
+ accessibilityControls={ariaControls ?? accessibilityControls} // Win32
278
+ accessibilityDescribedBy={ariaDescribedBy ?? accessibilityDescribedBy} // Win32
279
+ accessibilityDescription={ariaDescription ?? accessibilityDescription} // Win32
280
+ accessibilityLevel={ariaLevel ?? accessibilityLevel} // Win32
281
+ accessibilityPositionInSet={ariaPosinset ?? accessibilityPositionInSet} // Win32
282
+ accessibilitySetSize={ariaSetsize ?? accessibilitySetSize} // Win32
283
+ isHighlighted={isHighlighted}
284
+ isPressable={isPressable}
285
+ nativeID={_nativeID}
286
+ numberOfLines={_numberOfLines}
287
+ ref={forwardedRef}
288
+ selectable={_selectable}
289
+ selectionColor={_selectionColor}
290
+ style={processedStyle}
291
+ disabled={disabled}
292
+ />
293
+ );
250
294
  }
251
295
 
252
- if (style?.verticalAlign != null) {
253
- // $FlowFixMe[prop-missing]
254
- // $FlowFixMe[cannot-write]
255
- style.textAlignVertical =
256
- // $FlowFixMe[invalid-computed-prop]
257
- verticalAlignToTextAlignVerticalMap[style.verticalAlign];
258
- // $FlowFixMe[prop-missing]
259
- // $FlowFixMe[cannot-write]
260
- delete style.verticalAlign;
296
+ // If the disabled prop and accessibilityState.disabled are out of sync but not both in
297
+ // falsy states we need to update the accessibilityState object to use the disabled prop.
298
+ if (
299
+ _disabled !== _accessibilityStateDisabled &&
300
+ ((_disabled != null && _disabled !== false) ||
301
+ (_accessibilityStateDisabled != null &&
302
+ _accessibilityStateDisabled !== false))
303
+ ) {
304
+ _accessibilityState = {..._accessibilityState, disabled: _disabled};
261
305
  }
262
306
 
263
- const _hasOnPressOrOnLongPress =
264
- props.onPress != null || props.onLongPress != null;
307
+ const _accessible = Platform.select({
308
+ ios: accessible !== false,
309
+ android:
310
+ accessible == null ? onPress != null || onLongPress != null : accessible,
311
+ default: accessible !== false,
312
+ });
265
313
 
266
- return hasTextAncestor ? (
267
- <NativeVirtualText
268
- {...restProps}
269
- {...eventHandlersForText}
270
- accessibilityControls={ariaControls ?? accessibilityControls} // Win32
271
- accessibilityDescribedBy={ariaDescribedBy ?? accessibilityDescribedBy} // Win32
272
- accessibilityDescription={ariaDescription ?? accessibilityDescription} // Win32
273
- accessibilityLabel={ariaLabel ?? accessibilityLabel}
274
- accessibilityLevel={ariaLevel ?? accessibilityLevel} // Win32
275
- accessibilityPositionInSet={ariaPosinset ?? accessibilityPositionInSet} // Win32
276
- accessibilitySetSize={ariaSetsize ?? accessibilitySetSize} // Win32
277
- accessibilityState={_accessibilityState}
278
- isHighlighted={isHighlighted}
279
- isPressable={isPressable}
280
- nativeID={id ?? nativeID}
281
- numberOfLines={numberOfLines}
282
- ref={forwardedRef}
283
- selectable={_selectable}
284
- selectionColor={selectionColor}
285
- style={style}
286
- />
287
- ) : (
314
+ return (
288
315
  <TextAncestor.Provider value={true}>
289
316
  <NativeText
290
317
  {...restProps}
291
318
  {...eventHandlersForText}
319
+ accessibilityLabel={_accessibilityLabel}
320
+ accessibilityState={_accessibilityState}
321
+ accessible={_accessible}
292
322
  accessibilityControls={ariaControls ?? accessibilityControls} // Win32
293
323
  accessibilityDescribedBy={ariaDescribedBy ?? accessibilityDescribedBy} // Win32
294
324
  accessibilityDescription={ariaDescription ?? accessibilityDescription} // Win32
295
- accessibilityLabel={ariaLabel ?? accessibilityLabel}
296
325
  accessibilityLevel={ariaLevel ?? accessibilityLevel} // Win32
297
326
  accessibilityPositionInSet={ariaPosinset ?? accessibilityPositionInSet} // Win32
298
327
  accessibilitySetSize={ariaSetsize ?? accessibilitySetSize} // Win32
299
- accessibilityState={nativeTextAccessibilityState}
300
- accessible={
301
- accessible == null && Platform.OS === 'android'
302
- ? _hasOnPressOrOnLongPress
303
- : _accessible
304
- }
305
328
  allowFontScaling={allowFontScaling !== false}
306
329
  disabled={_disabled}
307
330
  ellipsizeMode={ellipsizeMode ?? 'tail'}
308
331
  isHighlighted={isHighlighted}
309
- nativeID={id ?? nativeID}
310
- numberOfLines={numberOfLines}
332
+ nativeID={_nativeID}
333
+ numberOfLines={_numberOfLines}
311
334
  ref={forwardedRef}
312
335
  selectable={_selectable}
313
- selectionColor={selectionColor}
314
- style={style}
336
+ selectionColor={_selectionColor}
337
+ style={processedStyle}
315
338
  />
316
339
  </TextAncestor.Provider>
317
340
  );
@@ -8,15 +8,16 @@
8
8
  * @format
9
9
  */
10
10
 
11
+ import type {HostComponent} from '../Renderer/shims/ReactNativeTypes';
12
+ import type {ProcessedColorValue} from '../StyleSheet/processColor';
13
+ import type {PressEvent} from '../Types/CoreEventTypes';
14
+ import type {TextProps} from './TextProps';
15
+
11
16
  import {createViewConfig} from '../NativeComponent/ViewConfig';
12
17
  import UIManager from '../ReactNative/UIManager';
13
18
  import createReactNativeComponentClass from '../Renderer/shims/createReactNativeComponentClass';
14
- import {type HostComponent} from '../Renderer/shims/ReactNativeTypes';
15
- import {type ProcessedColorValue} from '../StyleSheet/processColor';
16
- import {type PressEvent} from '../Types/CoreEventTypes';
17
- import {type TextProps} from './TextProps';
18
19
 
19
- type NativeTextProps = $ReadOnly<{
20
+ export type NativeTextProps = $ReadOnly<{
20
21
  ...TextProps,
21
22
  isHighlighted?: ?boolean,
22
23
  selectionColor?: ?ProcessedColorValue,
@@ -8,15 +8,16 @@
8
8
  * @format
9
9
  */
10
10
 
11
+ import type {HostComponent} from '../Renderer/shims/ReactNativeTypes';
12
+ import type {ProcessedColorValue} from '../StyleSheet/processColor';
13
+ import type {PressEvent} from '../Types/CoreEventTypes';
14
+ import type {TextProps} from './TextProps';
15
+
11
16
  import {createViewConfig} from '../NativeComponent/ViewConfig';
12
17
  import UIManager from '../ReactNative/UIManager';
13
18
  import createReactNativeComponentClass from '../Renderer/shims/createReactNativeComponentClass';
14
- import {type HostComponent} from '../Renderer/shims/ReactNativeTypes';
15
- import {type ProcessedColorValue} from '../StyleSheet/processColor';
16
- import {type PressEvent} from '../Types/CoreEventTypes';
17
- import {type TextProps} from './TextProps';
18
19
 
19
- type NativeTextProps = $ReadOnly<{
20
+ export type NativeTextProps = $ReadOnly<{
20
21
  ...TextProps,
21
22
  isHighlighted?: ?boolean,
22
23
  selectionColor?: ?ProcessedColorValue,