@office-iss/react-native-win32 0.0.0-canary.302 → 0.0.0-canary.303
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 +2 -2
- package/CHANGELOG.json +28 -1
- package/CHANGELOG.md +15 -5
- package/IntegrationTests/IntegrationTestsApp.js +1 -1
- package/IntegrationTests/LayoutEventsTest.js +3 -3
- package/Libraries/ActionSheetIOS/ActionSheetIOS.js +3 -3
- package/Libraries/Alert/RCTAlertManager.android.js +2 -2
- package/Libraries/Animated/AnimatedEvent.js +1 -1
- package/Libraries/Animated/AnimatedImplementation.js +2 -2
- package/Libraries/Animated/AnimatedMock.js +1 -1
- package/Libraries/Animated/NativeAnimatedAllowlist.js +1 -0
- package/Libraries/Animated/animations/Animation.js +5 -6
- package/Libraries/Animated/components/AnimatedScrollView.js +1 -1
- package/Libraries/Animated/nodes/AnimatedColor.js +9 -9
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +4 -4
- package/Libraries/Animated/nodes/AnimatedProps.js +2 -2
- package/Libraries/Animated/nodes/AnimatedStyle.js +6 -4
- package/Libraries/Animated/nodes/AnimatedTransform.js +1 -1
- package/Libraries/AppState/AppState.js +5 -1
- package/Libraries/BatchedBridge/NativeModules.js +1 -1
- package/Libraries/Blob/BlobManager.js +1 -1
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +1 -1
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +1 -1
- package/Libraries/Components/Button.js +1 -1
- package/Libraries/Components/Button.win32.js +1 -1
- package/Libraries/Components/Pressable/useAndroidRippleForView.js +2 -2
- package/Libraries/Components/ScrollView/ScrollView.js +3 -2
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
- package/Libraries/Components/TextInput/TextInput.flow.js +12 -5
- package/Libraries/Components/TextInput/TextInput.flow.win32.js +12 -5
- package/Libraries/Components/TextInput/TextInput.js +9 -4
- package/Libraries/Components/TextInput/TextInput.win32.js +9 -6
- package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +2 -3
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +1 -1
- package/Libraries/Components/View/View.win32.js +3 -1
- package/Libraries/Core/Devtools/loadBundleFromServer.js +1 -1
- package/Libraries/Core/Devtools/loadBundleFromServer.win32.js +1 -1
- package/Libraries/Core/ExceptionsManager.js +2 -2
- package/Libraries/Core/ReactFiberErrorDialog.js +3 -3
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Core/Timers/JSTimers.js +1 -1
- package/Libraries/Core/Timers/immediateShim.js +1 -1
- package/Libraries/Debugging/DebuggingOverlayRegistry.js +5 -3
- package/Libraries/Image/Image.android.js +318 -111
- package/Libraries/Image/ImageSourceUtils.js +8 -2
- package/Libraries/Image/resolveAssetSource.js +1 -1
- package/Libraries/Interaction/InteractionManager.js +1 -1
- package/Libraries/Interaction/PanResponder.js +1 -1
- package/Libraries/Lists/FlatList.js +5 -6
- package/Libraries/LogBox/Data/LogBoxData.js +1 -1
- package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.win32.js +1 -1
- package/Libraries/Modal/Modal.js +2 -2
- package/Libraries/NativeComponent/NativeComponentRegistry.js +1 -1
- package/Libraries/NativeComponent/ViewConfig.js +1 -1
- package/Libraries/Network/RCTNetworking.android.js +1 -1
- package/Libraries/Network/RCTNetworking.ios.js +1 -1
- package/Libraries/Network/RCTNetworking.win32.js +1 -1
- package/Libraries/Network/convertRequestBody.js +1 -1
- package/Libraries/PermissionsAndroid/PermissionsAndroid.js +10 -9
- package/Libraries/Pressability/HoverState.js +2 -0
- package/Libraries/Pressability/HoverState.win32.js +2 -0
- package/Libraries/PushNotificationIOS/PushNotificationIOS.js +2 -2
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +2 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +3 -3
- package/Libraries/ReactNative/RendererImplementation.js +116 -116
- package/Libraries/ReactNative/UIManager.js +3 -3
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -1
- package/Libraries/Renderer/shims/ReactFabric.js +1 -3
- package/Libraries/Renderer/shims/ReactFeatureFlags.js +1 -3
- package/Libraries/Renderer/shims/ReactNative.js +1 -3
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +1 -3
- package/Libraries/Renderer/shims/createReactNativeComponentClass.js +1 -3
- package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +2 -2
- package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +2 -2
- package/Libraries/StyleSheet/PlatformColorValueTypes.win32.js +4 -0
- package/Libraries/StyleSheet/flattenStyle.js +2 -2
- package/Libraries/StyleSheet/splitLayoutProps.js +2 -2
- package/Libraries/Text/Text.js +509 -235
- package/Libraries/Text/Text.win32.js +622 -275
- package/Libraries/Text/TextNativeComponent.js +2 -2
- package/Libraries/Text/TextNativeComponent.win32.js +2 -2
- package/Libraries/Utilities/HMRClient.js +0 -1
- package/Libraries/Utilities/Platform.android.js +3 -3
- package/Libraries/Utilities/Platform.d.ts +1 -0
- package/Libraries/Utilities/Platform.ios.js +1 -1
- package/Libraries/Utilities/Platform.win32.js +3 -3
- package/Libraries/Utilities/PlatformTypes.js +1 -1
- package/Libraries/Utilities/ReactNativeTestTools.js +12 -0
- package/Libraries/Utilities/codegenNativeCommands.js +1 -1
- package/Libraries/Utilities/codegenNativeComponent.js +1 -1
- package/Libraries/Utilities/differ/pointsDiffer.js +1 -1
- package/Libraries/vendor/emitter/EventEmitter.js +1 -1
- package/index.js +3 -0
- package/index.win32.js +4 -0
- package/jest/local-setup.js +2 -2
- package/jest/mock.js +1 -1
- package/jest/mockComponent.js +8 -8
- package/jest/mockNativeComponent.js +3 -2
- package/jest/mocks/Modal.js +1 -1
- package/jest/mocks/ScrollView.js +1 -1
- package/jest/mocks/ViewNativeComponent.js +1 -1
- package/jest/setup.js +12 -12
- package/overrides.json +16 -16
- package/package.json +12 -12
- package/src/private/animated/NativeAnimatedHelper.js +3 -3
- package/src/private/animated/NativeAnimatedHelper.win32.js +3 -3
- package/src/private/animated/createAnimatedPropsHook.js +9 -11
- package/src/private/animated/createAnimatedPropsMemoHook.js +6 -6
- package/src/private/components/virtualview/VirtualView.js +7 -4
- package/src/private/components/virtualview/VirtualViewNativeComponent.js +6 -0
- package/src/private/devsupport/devmenu/elementinspector/Inspector.js +2 -2
- package/src/private/featureflags/ReactNativeFeatureFlags.js +9 -8
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +1 -2
- package/src/private/renderer/errorhandling/ErrorHandlers.js +3 -3
- package/src/private/types/HostInstance.js +4 -1
- package/src/private/webapis/dom/nodes/ReactNativeDocument.js +22 -2
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +1 -1
- package/src/private/webapis/dom/nodes/ReadOnlyElement.js +5 -3
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +16 -13
- package/src/private/webapis/dom/nodes/internals/NodeInternals.js +45 -22
- package/src/private/webapis/dom/nodes/internals/ReactNativeDocumentInstanceHandle.js +1 -1
- package/src/private/webapis/dom/nodes/specs/NativeDOM.js +26 -192
- package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +14 -11
- package/src/private/webapis/dom/oldstylecollections/NodeList.js +13 -10
- package/src/private/webapis/geometry/DOMRectList.js +1 -1
- package/src/private/webapis/mutationobserver/internals/MutationObserverManager.js +1 -1
- package/src/private/webapis/performance/EventTiming.js +1 -1
- package/src/private/webapis/performance/Performance.js +12 -30
- package/src/private/webapis/performance/specs/NativePerformance.js +4 -4
- package/src/private/webapis/structuredClone/structuredClone.js +9 -9
|
@@ -14,12 +14,13 @@ import type {GestureResponderEvent} from '../Types/CoreEventTypes';
|
|
|
14
14
|
import type {NativeTextProps} from './TextNativeComponent';
|
|
15
15
|
import type {PressRetentionOffset, TextProps} from './TextProps';
|
|
16
16
|
|
|
17
|
+
import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
|
|
17
18
|
import * as PressabilityDebug from '../Pressability/PressabilityDebug';
|
|
18
19
|
import usePressability from '../Pressability/usePressability';
|
|
19
20
|
import flattenStyle from '../StyleSheet/flattenStyle';
|
|
20
21
|
import processColor from '../StyleSheet/processColor';
|
|
21
22
|
import Platform from '../Utilities/Platform';
|
|
22
|
-
import
|
|
23
|
+
import TextAncestorContext from './TextAncestorContext';
|
|
23
24
|
import {NativeText, NativeVirtualText} from './TextNativeComponent';
|
|
24
25
|
import * as React from 'react';
|
|
25
26
|
import {useContext, useMemo, useState} from 'react';
|
|
@@ -35,188 +36,608 @@ type TextForwardRef = React.ElementRef<
|
|
|
35
36
|
*
|
|
36
37
|
* @see https://reactnative.dev/docs/text
|
|
37
38
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
39
|
+
let _TextImpl;
|
|
40
|
+
if (ReactNativeFeatureFlags.reduceDefaultPropsInText()) {
|
|
41
|
+
const TextImplNoDefaultProps: component(
|
|
42
|
+
ref?: React.RefSetter<TextForwardRef>,
|
|
43
|
+
...props: TextProps
|
|
44
|
+
) = ({
|
|
45
|
+
ref: forwardedRef,
|
|
46
|
+
accessible,
|
|
47
|
+
accessibilityLabel,
|
|
48
|
+
accessibilityState,
|
|
49
|
+
allowFontScaling,
|
|
50
|
+
'aria-busy': ariaBusy,
|
|
51
|
+
'aria-checked': ariaChecked,
|
|
52
|
+
'aria-disabled': ariaDisabled,
|
|
53
|
+
'aria-expanded': ariaExpanded,
|
|
54
|
+
'aria-label': ariaLabel,
|
|
55
|
+
'aria-selected': ariaSelected,
|
|
56
|
+
// #[ Win32
|
|
57
|
+
'aria-level': ariaLevel,
|
|
58
|
+
'aria-multiselectable': ariaMultiselectable,
|
|
59
|
+
'aria-posinset': ariaPosinset,
|
|
60
|
+
'aria-required': ariaRequired,
|
|
61
|
+
'aria-setsize': ariaSetsize,
|
|
62
|
+
'aria-controls': ariaControls,
|
|
63
|
+
'aria-describedby': ariaDescribedBy,
|
|
64
|
+
'aria-description': ariaDescription,
|
|
65
|
+
accessibilityLevel,
|
|
66
|
+
accessibilityPositionInSet,
|
|
67
|
+
accessibilitySetSize,
|
|
68
|
+
accessibilityControls,
|
|
69
|
+
accessibilityDescribedBy,
|
|
70
|
+
accessibilityDescription,
|
|
71
|
+
// #] Win32
|
|
72
|
+
children,
|
|
73
|
+
ellipsizeMode,
|
|
74
|
+
disabled,
|
|
75
|
+
id,
|
|
76
|
+
nativeID,
|
|
77
|
+
numberOfLines,
|
|
78
|
+
onLongPress,
|
|
79
|
+
onPress,
|
|
80
|
+
onPressIn,
|
|
81
|
+
onPressOut,
|
|
82
|
+
onResponderGrant,
|
|
83
|
+
onResponderMove,
|
|
84
|
+
onResponderRelease,
|
|
85
|
+
onResponderTerminate,
|
|
86
|
+
onResponderTerminationRequest,
|
|
87
|
+
onStartShouldSetResponder,
|
|
88
|
+
pressRetentionOffset,
|
|
89
|
+
selectable,
|
|
90
|
+
selectionColor,
|
|
91
|
+
suppressHighlighting,
|
|
92
|
+
style,
|
|
93
|
+
...restProps
|
|
94
|
+
}: {
|
|
95
|
+
ref?: React.RefSetter<TextForwardRef>,
|
|
96
|
+
...TextProps,
|
|
97
|
+
}) => {
|
|
98
|
+
const processedProps = restProps as {
|
|
99
|
+
...NativeTextProps,
|
|
100
|
+
};
|
|
101
|
+
const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
|
|
102
|
+
// #Win32 [
|
|
103
|
+
const _accessibilityControls = ariaControls ?? accessibilityControls;
|
|
104
|
+
const _accessibilityDescribedBy =
|
|
105
|
+
ariaDescribedBy ?? accessibilityDescribedBy;
|
|
106
|
+
const _accessibilityDescription =
|
|
107
|
+
ariaDescription ?? accessibilityDescription;
|
|
108
|
+
const _accessibilityLevel = ariaLevel ?? accessibilityLevel;
|
|
109
|
+
const _accessibilityPositionInSet =
|
|
110
|
+
ariaPosinset ?? accessibilityPositionInSet;
|
|
111
|
+
const _accessibilitySetSize = ariaSetsize ?? accessibilitySetSize;
|
|
112
|
+
// ] #Win32
|
|
113
|
+
|
|
114
|
+
let _accessibilityState: ?TextProps['accessibilityState'] =
|
|
115
|
+
accessibilityState;
|
|
116
|
+
if (
|
|
117
|
+
ariaBusy != null ||
|
|
118
|
+
ariaChecked != null ||
|
|
119
|
+
ariaDisabled != null ||
|
|
120
|
+
ariaExpanded != null ||
|
|
121
|
+
ariaSelected != null
|
|
122
|
+
) {
|
|
123
|
+
if (_accessibilityState != null) {
|
|
124
|
+
_accessibilityState = {
|
|
125
|
+
busy: ariaBusy ?? _accessibilityState.busy,
|
|
126
|
+
checked: ariaChecked ?? _accessibilityState.checked,
|
|
127
|
+
disabled: ariaDisabled ?? _accessibilityState.disabled,
|
|
128
|
+
expanded: ariaExpanded ?? _accessibilityState.expanded,
|
|
129
|
+
// #Win32 [
|
|
130
|
+
multiselectable:
|
|
131
|
+
ariaMultiselectable ?? accessibilityState?.multiselectable,
|
|
132
|
+
required: ariaRequired ?? accessibilityState?.required,
|
|
133
|
+
// ] #Win32
|
|
134
|
+
selected: ariaSelected ?? _accessibilityState.selected,
|
|
135
|
+
};
|
|
136
|
+
} else {
|
|
137
|
+
_accessibilityState = {
|
|
138
|
+
busy: ariaBusy,
|
|
139
|
+
checked: ariaChecked,
|
|
140
|
+
disabled: ariaDisabled,
|
|
141
|
+
expanded: ariaExpanded,
|
|
142
|
+
// #Win32 [
|
|
143
|
+
multiselectable: ariaMultiselectable,
|
|
144
|
+
required: ariaRequired,
|
|
145
|
+
// ] #Win32
|
|
146
|
+
selected: ariaSelected,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const _accessibilityStateDisabled = _accessibilityState?.disabled;
|
|
152
|
+
const _disabled = disabled ?? _accessibilityStateDisabled;
|
|
153
|
+
|
|
154
|
+
// If the disabled prop and accessibilityState.disabled are out of sync but not both in
|
|
155
|
+
// falsy states we need to update the accessibilityState object to use the disabled prop.
|
|
156
|
+
if (
|
|
157
|
+
_accessibilityState != null &&
|
|
158
|
+
_disabled !== _accessibilityStateDisabled &&
|
|
159
|
+
((_disabled != null && _disabled !== false) ||
|
|
160
|
+
(_accessibilityStateDisabled != null &&
|
|
161
|
+
_accessibilityStateDisabled !== false))
|
|
162
|
+
) {
|
|
163
|
+
_accessibilityState.disabled = _disabled;
|
|
132
164
|
}
|
|
133
|
-
}
|
|
134
165
|
|
|
135
|
-
|
|
136
|
-
|
|
166
|
+
const _accessible = Platform.select({
|
|
167
|
+
ios: accessible !== false,
|
|
168
|
+
android:
|
|
169
|
+
accessible == null
|
|
170
|
+
? onPress != null || onLongPress != null
|
|
171
|
+
: accessible,
|
|
172
|
+
default: accessible !== false, // [Windows #13996 - default value is accessible !== false]
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const isPressable =
|
|
176
|
+
(onPress != null ||
|
|
177
|
+
onLongPress != null ||
|
|
178
|
+
onStartShouldSetResponder != null) &&
|
|
179
|
+
_disabled !== true;
|
|
180
|
+
|
|
181
|
+
// TODO: Move this processing to the view configuration.
|
|
182
|
+
const _selectionColor =
|
|
183
|
+
selectionColor != null ? processColor(selectionColor) : undefined;
|
|
184
|
+
|
|
185
|
+
let _style = style;
|
|
186
|
+
if (__DEV__) {
|
|
187
|
+
if (PressabilityDebug.isEnabled() && onPress != null) {
|
|
188
|
+
_style = [style, {color: 'magenta'}];
|
|
189
|
+
}
|
|
190
|
+
}
|
|
137
191
|
|
|
138
|
-
|
|
139
|
-
(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
192
|
+
let _numberOfLines = numberOfLines;
|
|
193
|
+
if (_numberOfLines != null && !(_numberOfLines >= 0)) {
|
|
194
|
+
if (__DEV__) {
|
|
195
|
+
console.error(
|
|
196
|
+
`'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
_numberOfLines = 0;
|
|
200
|
+
}
|
|
143
201
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
202
|
+
let _selectable = selectable;
|
|
203
|
+
|
|
204
|
+
let processedStyle = flattenStyle<TextStyleProp>(_style);
|
|
205
|
+
if (processedStyle != null) {
|
|
206
|
+
let overrides: ?{...TextStyleInternal} = null;
|
|
207
|
+
if (typeof processedStyle.fontWeight === 'number') {
|
|
208
|
+
overrides = overrides || ({}: {...TextStyleInternal});
|
|
209
|
+
overrides.fontWeight =
|
|
210
|
+
// $FlowFixMe[incompatible-type]
|
|
211
|
+
(String(processedStyle.fontWeight): TextStyleInternal['fontWeight']);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (processedStyle.userSelect != null) {
|
|
215
|
+
_selectable = userSelectToSelectableMap[processedStyle.userSelect];
|
|
216
|
+
overrides = overrides || ({}: {...TextStyleInternal});
|
|
217
|
+
overrides.userSelect = undefined;
|
|
218
|
+
}
|
|
147
219
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
220
|
+
if (processedStyle.verticalAlign != null) {
|
|
221
|
+
overrides = overrides || ({}: {...TextStyleInternal});
|
|
222
|
+
overrides.textAlignVertical =
|
|
223
|
+
verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
|
|
224
|
+
overrides.verticalAlign = undefined;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (overrides != null) {
|
|
228
|
+
// $FlowFixMe[incompatible-type]
|
|
229
|
+
_style = [_style, overrides];
|
|
230
|
+
}
|
|
152
231
|
}
|
|
153
|
-
}
|
|
154
232
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
233
|
+
const _nativeID = id ?? nativeID;
|
|
234
|
+
|
|
235
|
+
if (_accessibilityLabel !== undefined) {
|
|
236
|
+
processedProps.accessibilityLabel = _accessibilityLabel;
|
|
237
|
+
}
|
|
238
|
+
if (_accessibilityState !== undefined) {
|
|
239
|
+
processedProps.accessibilityState = _accessibilityState;
|
|
240
|
+
}
|
|
241
|
+
if (_nativeID !== undefined) {
|
|
242
|
+
processedProps.nativeID = _nativeID;
|
|
243
|
+
}
|
|
244
|
+
if (_numberOfLines !== undefined) {
|
|
245
|
+
processedProps.numberOfLines = _numberOfLines;
|
|
246
|
+
}
|
|
247
|
+
if (_selectable !== undefined) {
|
|
248
|
+
processedProps.selectable = _selectable;
|
|
249
|
+
}
|
|
250
|
+
if (_style !== undefined) {
|
|
251
|
+
processedProps.style = _style;
|
|
252
|
+
}
|
|
253
|
+
if (_selectionColor !== undefined) {
|
|
254
|
+
processedProps.selectionColor = _selectionColor;
|
|
161
255
|
}
|
|
162
|
-
_numberOfLines = 0;
|
|
163
|
-
}
|
|
164
256
|
|
|
165
|
-
|
|
257
|
+
// [Windows accessibility properties
|
|
258
|
+
if (_accessibilityControls !== undefined) {
|
|
259
|
+
processedProps.accessibilityControls = _accessibilityControls;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (_accessibilityDescribedBy !== undefined) {
|
|
263
|
+
processedProps.accessibilityDescribedBy = _accessibilityDescribedBy;
|
|
264
|
+
}
|
|
166
265
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
let overrides: ?{...TextStyleInternal} = null;
|
|
170
|
-
if (typeof processedStyle.fontWeight === 'number') {
|
|
171
|
-
overrides = overrides || ({}: {...TextStyleInternal});
|
|
172
|
-
overrides.fontWeight =
|
|
173
|
-
// $FlowFixMe[incompatible-cast]
|
|
174
|
-
(processedStyle.fontWeight.toString(): TextStyleInternal['fontWeight']);
|
|
266
|
+
if (_accessibilityDescription !== undefined) {
|
|
267
|
+
processedProps.accessibilityDescription = _accessibilityDescription;
|
|
175
268
|
}
|
|
176
269
|
|
|
177
|
-
if (
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
270
|
+
if (_accessibilityLevel !== undefined) {
|
|
271
|
+
processedProps.accessibilityLevel = _accessibilityLevel;
|
|
272
|
+
}
|
|
273
|
+
if (_accessibilityPositionInSet !== undefined) {
|
|
274
|
+
processedProps.accessibilityPositionInSet = _accessibilityPositionInSet;
|
|
181
275
|
}
|
|
276
|
+
if (_accessibilitySetSize !== undefined) {
|
|
277
|
+
processedProps.accessibilitySetSize = _accessibilitySetSize;
|
|
278
|
+
}
|
|
279
|
+
// ]
|
|
182
280
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
281
|
+
let textPressabilityProps: ?TextPressabilityProps;
|
|
282
|
+
if (isPressable) {
|
|
283
|
+
textPressabilityProps = {
|
|
284
|
+
onLongPress,
|
|
285
|
+
onPress,
|
|
286
|
+
onPressIn,
|
|
287
|
+
onPressOut,
|
|
288
|
+
onResponderGrant,
|
|
289
|
+
onResponderMove,
|
|
290
|
+
onResponderRelease,
|
|
291
|
+
onResponderTerminate,
|
|
292
|
+
onResponderTerminationRequest,
|
|
293
|
+
onStartShouldSetResponder,
|
|
294
|
+
pressRetentionOffset,
|
|
295
|
+
suppressHighlighting,
|
|
296
|
+
};
|
|
188
297
|
}
|
|
189
298
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
299
|
+
const hasTextAncestor = useContext(TextAncestorContext);
|
|
300
|
+
if (hasTextAncestor) {
|
|
301
|
+
processedProps.disabled = disabled;
|
|
302
|
+
processedProps.children = children;
|
|
303
|
+
if (isPressable) {
|
|
304
|
+
return (
|
|
305
|
+
<NativePressableVirtualText
|
|
306
|
+
ref={forwardedRef}
|
|
307
|
+
textProps={processedProps}
|
|
308
|
+
textPressabilityProps={textPressabilityProps ?? {}}
|
|
309
|
+
/>
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
return <NativeVirtualText {...processedProps} ref={forwardedRef} />;
|
|
193
313
|
}
|
|
194
|
-
}
|
|
195
314
|
|
|
196
|
-
|
|
315
|
+
let nativeText = null;
|
|
316
|
+
|
|
317
|
+
processedProps.accessible = _accessible;
|
|
318
|
+
processedProps.allowFontScaling = allowFontScaling !== false;
|
|
319
|
+
processedProps.disabled = _disabled;
|
|
320
|
+
processedProps.ellipsizeMode = ellipsizeMode ?? 'tail';
|
|
321
|
+
processedProps.children = children;
|
|
197
322
|
|
|
198
|
-
const hasTextAncestor = useContext(TextAncestor);
|
|
199
|
-
if (hasTextAncestor) {
|
|
200
323
|
if (isPressable) {
|
|
324
|
+
nativeText = (
|
|
325
|
+
<NativePressableText
|
|
326
|
+
ref={forwardedRef}
|
|
327
|
+
textProps={processedProps}
|
|
328
|
+
textPressabilityProps={textPressabilityProps ?? {}}
|
|
329
|
+
/>
|
|
330
|
+
);
|
|
331
|
+
} else {
|
|
332
|
+
nativeText = <NativeText {...processedProps} ref={forwardedRef} />;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
if (children == null) {
|
|
336
|
+
return nativeText;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// If the children do not contain a JSX element it would not be possible to have a
|
|
340
|
+
// nested `Text` component so we can skip adding the `TextAncestorContext` context wrapper
|
|
341
|
+
// which has a performance overhead. Since we do this for performance reasons we need
|
|
342
|
+
// to keep the check simple to avoid regressing overall perf. For this reason the
|
|
343
|
+
// `children.length` constant is set to `3`, this should be a reasonable tradeoff
|
|
344
|
+
// to capture the majority of `Text` uses but also not make this check too expensive.
|
|
345
|
+
if (Array.isArray(children) && children.length <= 3) {
|
|
346
|
+
let hasNonTextChild = false;
|
|
347
|
+
for (let child of children) {
|
|
348
|
+
if (child != null && typeof child === 'object') {
|
|
349
|
+
hasNonTextChild = true;
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (!hasNonTextChild) {
|
|
354
|
+
return nativeText;
|
|
355
|
+
}
|
|
356
|
+
} else if (typeof children !== 'object') {
|
|
357
|
+
return nativeText;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return <TextAncestorContext value={true}>{nativeText}</TextAncestorContext>;
|
|
361
|
+
};
|
|
362
|
+
_TextImpl = TextImplNoDefaultProps;
|
|
363
|
+
} else {
|
|
364
|
+
const TextImplLegacy: component(
|
|
365
|
+
ref?: React.RefSetter<TextForwardRef>,
|
|
366
|
+
...props: TextProps
|
|
367
|
+
) = ({
|
|
368
|
+
ref: forwardedRef,
|
|
369
|
+
accessible,
|
|
370
|
+
accessibilityLabel,
|
|
371
|
+
accessibilityState,
|
|
372
|
+
allowFontScaling,
|
|
373
|
+
'aria-busy': ariaBusy,
|
|
374
|
+
'aria-checked': ariaChecked,
|
|
375
|
+
'aria-disabled': ariaDisabled,
|
|
376
|
+
'aria-expanded': ariaExpanded,
|
|
377
|
+
'aria-label': ariaLabel,
|
|
378
|
+
'aria-selected': ariaSelected,
|
|
379
|
+
//#[ Win32
|
|
380
|
+
'aria-controls': ariaControls,
|
|
381
|
+
'aria-describedby': ariaDescribedBy,
|
|
382
|
+
'aria-description': ariaDescription,
|
|
383
|
+
'aria-level': ariaLevel,
|
|
384
|
+
'aria-multiselectable': ariaMultiselectable,
|
|
385
|
+
'aria-posinset': ariaPosinset,
|
|
386
|
+
'aria-required': ariaRequired,
|
|
387
|
+
'aria-setsize': ariaSetsize,
|
|
388
|
+
accessibilityLevel,
|
|
389
|
+
accessibilityPositionInSet,
|
|
390
|
+
accessibilitySetSize,
|
|
391
|
+
accessibilityControls,
|
|
392
|
+
accessibilityDescribedBy,
|
|
393
|
+
accessibilityDescription,
|
|
394
|
+
// #] Win32
|
|
395
|
+
children,
|
|
396
|
+
ellipsizeMode,
|
|
397
|
+
disabled,
|
|
398
|
+
id,
|
|
399
|
+
nativeID,
|
|
400
|
+
numberOfLines,
|
|
401
|
+
onLongPress,
|
|
402
|
+
onPress,
|
|
403
|
+
onPressIn,
|
|
404
|
+
onPressOut,
|
|
405
|
+
onResponderGrant,
|
|
406
|
+
onResponderMove,
|
|
407
|
+
onResponderRelease,
|
|
408
|
+
onResponderTerminate,
|
|
409
|
+
onResponderTerminationRequest,
|
|
410
|
+
onStartShouldSetResponder,
|
|
411
|
+
pressRetentionOffset,
|
|
412
|
+
selectable,
|
|
413
|
+
selectionColor,
|
|
414
|
+
suppressHighlighting,
|
|
415
|
+
style,
|
|
416
|
+
...restProps
|
|
417
|
+
}: {
|
|
418
|
+
ref?: React.RefSetter<TextForwardRef>,
|
|
419
|
+
...TextProps,
|
|
420
|
+
}) => {
|
|
421
|
+
const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
|
|
422
|
+
//#[ Win32
|
|
423
|
+
const _accessibilityControls = ariaControls ?? accessibilityControls;
|
|
424
|
+
const _accessibilityDescribedBy =
|
|
425
|
+
ariaDescribedBy ?? accessibilityDescribedBy;
|
|
426
|
+
const _accessibilityDescription =
|
|
427
|
+
ariaDescription ?? accessibilityDescription;
|
|
428
|
+
const _accessibilityLevel = ariaLevel ?? accessibilityLevel;
|
|
429
|
+
const _accessibilityPositionInSet =
|
|
430
|
+
ariaPosinset ?? accessibilityPositionInSet;
|
|
431
|
+
const _accessibilitySetSize = ariaSetsize ?? accessibilitySetSize;
|
|
432
|
+
//#] Win32
|
|
433
|
+
|
|
434
|
+
let _accessibilityState: ?TextProps['accessibilityState'] =
|
|
435
|
+
accessibilityState;
|
|
436
|
+
if (
|
|
437
|
+
ariaBusy != null ||
|
|
438
|
+
ariaChecked != null ||
|
|
439
|
+
ariaDisabled != null ||
|
|
440
|
+
ariaExpanded != null ||
|
|
441
|
+
ariaSelected != null
|
|
442
|
+
) {
|
|
443
|
+
if (_accessibilityState != null) {
|
|
444
|
+
_accessibilityState = {
|
|
445
|
+
busy: ariaBusy ?? _accessibilityState.busy,
|
|
446
|
+
checked: ariaChecked ?? _accessibilityState.checked,
|
|
447
|
+
disabled: ariaDisabled ?? _accessibilityState.disabled,
|
|
448
|
+
expanded: ariaExpanded ?? _accessibilityState.expanded,
|
|
449
|
+
//#[Win32
|
|
450
|
+
multiselectable:
|
|
451
|
+
ariaMultiselectable ?? accessibilityState?.multiselectable,
|
|
452
|
+
required: ariaRequired ?? accessibilityState?.required,
|
|
453
|
+
// #] Win32
|
|
454
|
+
selected: ariaSelected ?? _accessibilityState.selected,
|
|
455
|
+
};
|
|
456
|
+
} else {
|
|
457
|
+
_accessibilityState = {
|
|
458
|
+
busy: ariaBusy,
|
|
459
|
+
checked: ariaChecked,
|
|
460
|
+
disabled: ariaDisabled,
|
|
461
|
+
expanded: ariaExpanded,
|
|
462
|
+
// #[ Win32
|
|
463
|
+
multiselectable: ariaMultiselectable,
|
|
464
|
+
required: ariaRequired,
|
|
465
|
+
// #]win32
|
|
466
|
+
selected: ariaSelected,
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
const _accessibilityStateDisabled = _accessibilityState?.disabled;
|
|
472
|
+
const _disabled = disabled ?? _accessibilityStateDisabled;
|
|
473
|
+
|
|
474
|
+
const isPressable =
|
|
475
|
+
(onPress != null ||
|
|
476
|
+
onLongPress != null ||
|
|
477
|
+
onStartShouldSetResponder != null) &&
|
|
478
|
+
_disabled !== true;
|
|
479
|
+
|
|
480
|
+
// TODO: Move this processing to the view configuration.
|
|
481
|
+
const _selectionColor =
|
|
482
|
+
selectionColor != null ? processColor(selectionColor) : undefined;
|
|
483
|
+
|
|
484
|
+
let _style = style;
|
|
485
|
+
if (__DEV__) {
|
|
486
|
+
if (PressabilityDebug.isEnabled() && onPress != null) {
|
|
487
|
+
_style = [style, {color: 'magenta'}];
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
let _numberOfLines = numberOfLines;
|
|
492
|
+
if (_numberOfLines != null && !(_numberOfLines >= 0)) {
|
|
493
|
+
if (__DEV__) {
|
|
494
|
+
console.error(
|
|
495
|
+
`'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
_numberOfLines = 0;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
let _selectable = selectable;
|
|
502
|
+
|
|
503
|
+
let processedStyle = flattenStyle<TextStyleProp>(_style);
|
|
504
|
+
if (processedStyle != null) {
|
|
505
|
+
let overrides: ?{...TextStyleInternal} = null;
|
|
506
|
+
if (typeof processedStyle.fontWeight === 'number') {
|
|
507
|
+
overrides = overrides || ({}: {...TextStyleInternal});
|
|
508
|
+
overrides.fontWeight =
|
|
509
|
+
// $FlowFixMe[incompatible-type]
|
|
510
|
+
(processedStyle.fontWeight.toString(): TextStyleInternal['fontWeight']);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
if (processedStyle.userSelect != null) {
|
|
514
|
+
_selectable = userSelectToSelectableMap[processedStyle.userSelect];
|
|
515
|
+
overrides = overrides || ({}: {...TextStyleInternal});
|
|
516
|
+
overrides.userSelect = undefined;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
if (processedStyle.verticalAlign != null) {
|
|
520
|
+
overrides = overrides || ({}: {...TextStyleInternal});
|
|
521
|
+
overrides.textAlignVertical =
|
|
522
|
+
verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
|
|
523
|
+
overrides.verticalAlign = undefined;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
if (overrides != null) {
|
|
527
|
+
// $FlowFixMe[incompatible-type]
|
|
528
|
+
_style = [_style, overrides];
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
const _nativeID = id ?? nativeID;
|
|
533
|
+
|
|
534
|
+
const hasTextAncestor = useContext(TextAncestorContext);
|
|
535
|
+
if (hasTextAncestor) {
|
|
536
|
+
if (isPressable) {
|
|
537
|
+
return (
|
|
538
|
+
<NativePressableVirtualText
|
|
539
|
+
ref={forwardedRef}
|
|
540
|
+
textProps={{
|
|
541
|
+
...restProps,
|
|
542
|
+
accessibilityLabel: _accessibilityLabel,
|
|
543
|
+
accessibilityState: _accessibilityState,
|
|
544
|
+
// #[ Win32
|
|
545
|
+
accessibilityControls: _accessibilityControls,
|
|
546
|
+
accessibilityDescribedBy: _accessibilityDescribedBy,
|
|
547
|
+
accessibilityDescription: _accessibilityDescription,
|
|
548
|
+
accessibilityLevel: _accessibilityLevel,
|
|
549
|
+
accessibilityPositionInSet: _accessibilityPositionInSet,
|
|
550
|
+
accessibilitySetSize: _accessibilitySetSize,
|
|
551
|
+
// #] Win32
|
|
552
|
+
nativeID: _nativeID,
|
|
553
|
+
numberOfLines: _numberOfLines,
|
|
554
|
+
selectable: _selectable,
|
|
555
|
+
selectionColor: _selectionColor,
|
|
556
|
+
style: _style,
|
|
557
|
+
disabled: disabled,
|
|
558
|
+
children,
|
|
559
|
+
}}
|
|
560
|
+
textPressabilityProps={{
|
|
561
|
+
onLongPress,
|
|
562
|
+
onPress,
|
|
563
|
+
onPressIn,
|
|
564
|
+
onPressOut,
|
|
565
|
+
onResponderGrant,
|
|
566
|
+
onResponderMove,
|
|
567
|
+
onResponderRelease,
|
|
568
|
+
onResponderTerminate,
|
|
569
|
+
onResponderTerminationRequest,
|
|
570
|
+
onStartShouldSetResponder,
|
|
571
|
+
pressRetentionOffset,
|
|
572
|
+
suppressHighlighting,
|
|
573
|
+
}}
|
|
574
|
+
/>
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
|
|
201
578
|
return (
|
|
202
|
-
<
|
|
579
|
+
<NativeVirtualText
|
|
580
|
+
{...restProps}
|
|
581
|
+
accessibilityLabel={_accessibilityLabel}
|
|
582
|
+
accessibilityState={_accessibilityState}
|
|
583
|
+
// #[ Win32
|
|
584
|
+
accessibilityControls={_accessibilityControls}
|
|
585
|
+
accessibilityDescribedBy={_accessibilityDescribedBy}
|
|
586
|
+
accessibilityDescription={_accessibilityDescription}
|
|
587
|
+
accessibilityLevel={_accessibilityLevel}
|
|
588
|
+
accessibilityPositionInSet={_accessibilityPositionInSet}
|
|
589
|
+
accessibilitySetSize={_accessibilitySetSize}
|
|
590
|
+
// #] Win32
|
|
591
|
+
nativeID={_nativeID}
|
|
592
|
+
numberOfLines={_numberOfLines}
|
|
593
|
+
ref={forwardedRef}
|
|
594
|
+
selectable={_selectable}
|
|
595
|
+
selectionColor={_selectionColor}
|
|
596
|
+
style={_style}
|
|
597
|
+
disabled={disabled}>
|
|
598
|
+
{children}
|
|
599
|
+
</NativeVirtualText>
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// If the disabled prop and accessibilityState.disabled are out of sync but not both in
|
|
604
|
+
// falsy states we need to update the accessibilityState object to use the disabled prop.
|
|
605
|
+
if (
|
|
606
|
+
_disabled !== _accessibilityStateDisabled &&
|
|
607
|
+
((_disabled != null && _disabled !== false) ||
|
|
608
|
+
(_accessibilityStateDisabled != null &&
|
|
609
|
+
_accessibilityStateDisabled !== false))
|
|
610
|
+
) {
|
|
611
|
+
_accessibilityState = {..._accessibilityState, disabled: _disabled};
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
const _accessible = Platform.select({
|
|
615
|
+
ios: accessible !== false,
|
|
616
|
+
android:
|
|
617
|
+
accessible == null
|
|
618
|
+
? onPress != null || onLongPress != null
|
|
619
|
+
: accessible,
|
|
620
|
+
default: accessible !== false, // [Windows #13996 - default value is accessible !== false]
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
let nativeText = null;
|
|
624
|
+
if (isPressable) {
|
|
625
|
+
nativeText = (
|
|
626
|
+
<NativePressableText
|
|
203
627
|
ref={forwardedRef}
|
|
204
628
|
textProps={{
|
|
205
629
|
...restProps,
|
|
206
630
|
accessibilityLabel: _accessibilityLabel,
|
|
207
631
|
accessibilityState: _accessibilityState,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
accessibilityPositionInSet: _accessibilityPositionInSet, // Win32
|
|
213
|
-
accessibilitySetSize: _accessibilitySetSize, // Win32
|
|
632
|
+
accessible: _accessible,
|
|
633
|
+
allowFontScaling: allowFontScaling !== false,
|
|
634
|
+
disabled: _disabled,
|
|
635
|
+
ellipsizeMode: ellipsizeMode ?? 'tail',
|
|
214
636
|
nativeID: _nativeID,
|
|
215
637
|
numberOfLines: _numberOfLines,
|
|
216
638
|
selectable: _selectable,
|
|
217
639
|
selectionColor: _selectionColor,
|
|
218
640
|
style: _style,
|
|
219
|
-
disabled: disabled,
|
|
220
641
|
children,
|
|
221
642
|
}}
|
|
222
643
|
textPressabilityProps={{
|
|
@@ -235,135 +656,61 @@ const TextImpl: component(
|
|
|
235
656
|
}}
|
|
236
657
|
/>
|
|
237
658
|
);
|
|
659
|
+
} else {
|
|
660
|
+
nativeText = (
|
|
661
|
+
<NativeText
|
|
662
|
+
{...restProps}
|
|
663
|
+
accessibilityLabel={_accessibilityLabel}
|
|
664
|
+
accessibilityState={_accessibilityState}
|
|
665
|
+
accessible={_accessible}
|
|
666
|
+
allowFontScaling={allowFontScaling !== false}
|
|
667
|
+
disabled={_disabled}
|
|
668
|
+
ellipsizeMode={ellipsizeMode ?? 'tail'}
|
|
669
|
+
nativeID={_nativeID}
|
|
670
|
+
numberOfLines={_numberOfLines}
|
|
671
|
+
ref={forwardedRef}
|
|
672
|
+
selectable={_selectable}
|
|
673
|
+
selectionColor={_selectionColor}
|
|
674
|
+
style={_style}>
|
|
675
|
+
{children}
|
|
676
|
+
</NativeText>
|
|
677
|
+
);
|
|
238
678
|
}
|
|
239
679
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
{...restProps}
|
|
243
|
-
accessibilityLabel={_accessibilityLabel}
|
|
244
|
-
accessibilityState={_accessibilityState}
|
|
245
|
-
accessibilityControls={_accessibilityControls} // Win32
|
|
246
|
-
accessibilityDescribedBy={_accessibilityDescribedBy} // Win32
|
|
247
|
-
accessibilityDescription={_accessibilityDescription} // Win32
|
|
248
|
-
accessibilityLevel={_accessibilityLevel} // Win32
|
|
249
|
-
accessibilityPositionInSet={_accessibilityPositionInSet} // Win32
|
|
250
|
-
accessibilitySetSize={_accessibilitySetSize} // Win32
|
|
251
|
-
nativeID={_nativeID}
|
|
252
|
-
numberOfLines={_numberOfLines}
|
|
253
|
-
ref={forwardedRef}
|
|
254
|
-
selectable={_selectable}
|
|
255
|
-
selectionColor={_selectionColor}
|
|
256
|
-
style={_style}
|
|
257
|
-
disabled={disabled}>
|
|
258
|
-
{children}
|
|
259
|
-
</NativeVirtualText>
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// If the disabled prop and accessibilityState.disabled are out of sync but not both in
|
|
264
|
-
// falsy states we need to update the accessibilityState object to use the disabled prop.
|
|
265
|
-
if (
|
|
266
|
-
_disabled !== _accessibilityStateDisabled &&
|
|
267
|
-
((_disabled != null && _disabled !== false) ||
|
|
268
|
-
(_accessibilityStateDisabled != null &&
|
|
269
|
-
_accessibilityStateDisabled !== false))
|
|
270
|
-
) {
|
|
271
|
-
_accessibilityState = {..._accessibilityState, disabled: _disabled};
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
const _accessible = Platform.select({
|
|
275
|
-
ios: accessible !== false,
|
|
276
|
-
android:
|
|
277
|
-
accessible == null ? onPress != null || onLongPress != null : accessible,
|
|
278
|
-
default: accessible !== false, // [Windows #13996 - default value is accessible !== false]
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
let nativeText = null;
|
|
282
|
-
if (isPressable) {
|
|
283
|
-
nativeText = (
|
|
284
|
-
<NativePressableText
|
|
285
|
-
ref={forwardedRef}
|
|
286
|
-
textProps={{
|
|
287
|
-
...restProps,
|
|
288
|
-
accessibilityLabel: _accessibilityLabel,
|
|
289
|
-
accessibilityState: _accessibilityState,
|
|
290
|
-
accessible: _accessible,
|
|
291
|
-
allowFontScaling: allowFontScaling !== false,
|
|
292
|
-
disabled: _disabled,
|
|
293
|
-
ellipsizeMode: ellipsizeMode ?? 'tail',
|
|
294
|
-
nativeID: _nativeID,
|
|
295
|
-
numberOfLines: _numberOfLines,
|
|
296
|
-
selectable: _selectable,
|
|
297
|
-
selectionColor: _selectionColor,
|
|
298
|
-
style: _style,
|
|
299
|
-
children,
|
|
300
|
-
}}
|
|
301
|
-
textPressabilityProps={{
|
|
302
|
-
onLongPress,
|
|
303
|
-
onPress,
|
|
304
|
-
onPressIn,
|
|
305
|
-
onPressOut,
|
|
306
|
-
onResponderGrant,
|
|
307
|
-
onResponderMove,
|
|
308
|
-
onResponderRelease,
|
|
309
|
-
onResponderTerminate,
|
|
310
|
-
onResponderTerminationRequest,
|
|
311
|
-
onStartShouldSetResponder,
|
|
312
|
-
pressRetentionOffset,
|
|
313
|
-
suppressHighlighting,
|
|
314
|
-
}}
|
|
315
|
-
/>
|
|
316
|
-
);
|
|
317
|
-
} else {
|
|
318
|
-
nativeText = (
|
|
319
|
-
<NativeText
|
|
320
|
-
{...restProps}
|
|
321
|
-
accessibilityLabel={_accessibilityLabel}
|
|
322
|
-
accessibilityState={_accessibilityState}
|
|
323
|
-
accessible={_accessible}
|
|
324
|
-
allowFontScaling={allowFontScaling !== false}
|
|
325
|
-
disabled={_disabled}
|
|
326
|
-
ellipsizeMode={ellipsizeMode ?? 'tail'}
|
|
327
|
-
nativeID={_nativeID}
|
|
328
|
-
numberOfLines={_numberOfLines}
|
|
329
|
-
ref={forwardedRef}
|
|
330
|
-
selectable={_selectable}
|
|
331
|
-
selectionColor={_selectionColor}
|
|
332
|
-
style={_style}>
|
|
333
|
-
{children}
|
|
334
|
-
</NativeText>
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
if (children == null) {
|
|
339
|
-
return nativeText;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// If the children do not contain a JSX element it would not be possible to have a
|
|
343
|
-
// nested `Text` component so we can skip adding the `TextAncestor` context wrapper
|
|
344
|
-
// which has a performance overhead. Since we do this for performance reasons we need
|
|
345
|
-
// to keep the check simple to avoid regressing overall perf. For this reason the
|
|
346
|
-
// `children.length` constant is set to `3`, this should be a reasonable tradeoff
|
|
347
|
-
// to capture the majority of `Text` uses but also not make this check too expensive.
|
|
348
|
-
if (Array.isArray(children) && children.length <= 3) {
|
|
349
|
-
let hasNonTextChild = false;
|
|
350
|
-
for (let child of children) {
|
|
351
|
-
if (child != null && typeof child === 'object') {
|
|
352
|
-
hasNonTextChild = true;
|
|
353
|
-
break;
|
|
354
|
-
}
|
|
680
|
+
if (children == null) {
|
|
681
|
+
return nativeText;
|
|
355
682
|
}
|
|
356
|
-
|
|
683
|
+
|
|
684
|
+
// If the children do not contain a JSX element it would not be possible to have a
|
|
685
|
+
// nested `Text` component so we can skip adding the `TextAncestorContext` context wrapper
|
|
686
|
+
// which has a performance overhead. Since we do this for performance reasons we need
|
|
687
|
+
// to keep the check simple to avoid regressing overall perf. For this reason the
|
|
688
|
+
// `children.length` constant is set to `3`, this should be a reasonable tradeoff
|
|
689
|
+
// to capture the majority of `Text` uses but also not make this check too expensive.
|
|
690
|
+
if (Array.isArray(children) && children.length <= 3) {
|
|
691
|
+
let hasNonTextChild = false;
|
|
692
|
+
for (let child of children) {
|
|
693
|
+
if (child != null && typeof child === 'object') {
|
|
694
|
+
hasNonTextChild = true;
|
|
695
|
+
break;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
if (!hasNonTextChild) {
|
|
699
|
+
return nativeText;
|
|
700
|
+
}
|
|
701
|
+
} else if (typeof children !== 'object') {
|
|
357
702
|
return nativeText;
|
|
358
703
|
}
|
|
359
|
-
} else if (typeof children !== 'object') {
|
|
360
|
-
return nativeText;
|
|
361
|
-
}
|
|
362
704
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}
|
|
705
|
+
return <TextAncestorContext value={true}>{nativeText}</TextAncestorContext>;
|
|
706
|
+
};
|
|
707
|
+
_TextImpl = TextImplLegacy;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
const TextImpl: component(
|
|
711
|
+
ref?: React.RefSetter<TextForwardRef>,
|
|
712
|
+
...props: TextProps
|
|
713
|
+
) = _TextImpl;
|
|
367
714
|
|
|
368
715
|
TextImpl.displayName = 'Text';
|
|
369
716
|
|