@office-iss/react-native-win32 0.84.0-preview.2 → 0.85.0-preview.1
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/.eslintignore +1 -0
- package/.flowconfig +1 -5
- package/CHANGELOG.json +79 -13
- package/CHANGELOG.md +14 -8
- package/IntegrationTests/IntegrationTestHarnessTest.js +1 -1
- package/IntegrationTests/LayoutEventsTest.js +1 -1
- package/IntegrationTests/TimersTest.js +1 -1
- package/Libraries/ActionSheetIOS/ActionSheetIOS.js +3 -3
- package/Libraries/Animated/Animated.d.ts +8 -1
- package/Libraries/Animated/AnimatedEvent.js +4 -4
- package/Libraries/Animated/AnimatedImplementation.js +2 -2
- package/Libraries/Animated/animations/Animation.js +3 -3
- package/Libraries/Animated/animations/DecayAnimation.js +4 -4
- package/Libraries/Animated/animations/SpringAnimation.js +5 -5
- package/Libraries/Animated/animations/TimingAnimation.js +5 -5
- package/Libraries/Animated/createAnimatedComponent.js +7 -7
- package/Libraries/Animated/nodes/AnimatedColor.js +2 -2
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +12 -12
- package/Libraries/Animated/nodes/AnimatedNode.js +3 -3
- package/Libraries/Animated/nodes/AnimatedObject.js +3 -3
- package/Libraries/Animated/nodes/AnimatedProps.js +6 -6
- package/Libraries/Animated/nodes/AnimatedStyle.js +7 -7
- package/Libraries/Animated/nodes/AnimatedTransform.js +13 -13
- package/Libraries/Animated/nodes/AnimatedValue.js +1 -1
- package/Libraries/Animated/nodes/AnimatedValueXY.js +1 -1
- package/Libraries/Animated/nodes/AnimatedWithChildren.js +1 -1
- package/Libraries/Animated/useAnimatedColor.d.ts +15 -0
- package/Libraries/Animated/useAnimatedColor.js +25 -0
- package/Libraries/Animated/useAnimatedValueXY.d.ts +15 -0
- package/Libraries/Animated/useAnimatedValueXY.js +26 -0
- package/Libraries/AppState/AppState.js +1 -1
- package/Libraries/BatchedBridge/MessageQueue.js +3 -3
- package/Libraries/BatchedBridge/NativeModules.js +12 -10
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +30 -26
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +34 -30
- package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +2 -2
- package/Libraries/Components/Button.js +2 -2
- package/Libraries/Components/Button.win32.js +2 -2
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js +2 -2
- package/Libraries/Components/EnterString.win32.js +2 -2
- package/Libraries/Components/EnterString.win32.js.map +1 -1
- package/Libraries/Components/Keyboard/Keyboard.js +6 -6
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +1 -1
- package/Libraries/Components/LayoutConformance/LayoutConformance.js +1 -1
- package/Libraries/Components/LayoutConformance/LayoutConformanceNativeComponent.js +1 -1
- package/Libraries/Components/Pressable/Pressable.d.ts +5 -0
- package/Libraries/Components/Pressable/Pressable.js +3 -3
- package/Libraries/Components/Pressable/Pressable.win32.js +3 -3
- package/Libraries/Components/Pressable/useAndroidRippleForView.js +4 -4
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +1 -1
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidTypes.js +3 -3
- package/Libraries/Components/RefreshControl/RefreshControl.js +5 -5
- package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +8 -12
- package/Libraries/Components/ScrollView/ScrollView.d.ts +9 -0
- package/Libraries/Components/ScrollView/ScrollView.js +19 -9
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +8 -18
- package/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js +4 -3
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
- package/Libraries/Components/StaticRenderer.js +1 -1
- package/Libraries/Components/StatusBar/StatusBar.js +8 -8
- package/Libraries/Components/Switch/Switch.js +3 -3
- package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +33 -48
- package/Libraries/Components/TextInput/InputAccessoryView.js +1 -1
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +6 -11
- package/Libraries/Components/TextInput/TextInput.flow.js +21 -20
- package/Libraries/Components/TextInput/TextInput.flow.win32.js +23 -22
- package/Libraries/Components/TextInput/TextInput.js +8 -4
- package/Libraries/Components/TextInput/TextInput.win32.js +3 -4
- package/Libraries/Components/Touchable/PooledClass.js +1 -1
- package/Libraries/Components/Touchable/Touchable.js +2 -2
- package/Libraries/Components/Touchable/Touchable.win32.js +2 -2
- package/Libraries/Components/Touchable/TouchableBounce.js +4 -4
- package/Libraries/Components/Touchable/TouchableHighlight.js +8 -8
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +7 -7
- package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +7 -7
- package/Libraries/Components/Touchable/TouchableOpacity.js +4 -4
- package/Libraries/Components/Touchable/TouchableWin32.js +1 -1
- package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +1 -1
- package/Libraries/Components/UnimplementedViews/UnimplementedView.js +1 -1
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +68 -31
- package/Libraries/Components/View/ViewAccessibility.js +7 -7
- package/Libraries/Components/View/ViewAccessibility.win32.js +7 -7
- package/Libraries/Components/View/ViewPropTypes.js +14 -14
- package/Libraries/Components/View/ViewPropTypes.win32.js +16 -16
- package/Libraries/Core/Devtools/parseHermesStack.js +8 -8
- package/Libraries/Core/Devtools/symbolicateStackTrace.js +2 -2
- package/Libraries/Core/ExceptionsManager.js +2 -2
- package/Libraries/Core/ExtendedError.js +3 -3
- package/Libraries/Core/RawEventEmitter.js +1 -1
- package/Libraries/Core/ReactNativeVersion.js +2 -2
- package/Libraries/Core/Timers/JSTimers.js +3 -2
- package/Libraries/Core/setUpDeveloperTools.js +1 -1
- package/Libraries/Core/setUpErrorHandling.js +4 -2
- package/Libraries/Core/setUpReactDevTools.js +23 -6
- package/Libraries/Core/setUpSegmentFetcher.js +1 -1
- package/Libraries/Debugging/DebuggingOverlay.js +2 -2
- package/Libraries/EventEmitter/NativeEventEmitter.js +7 -9
- package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +1 -1
- package/Libraries/Image/AssetSourceResolver.js +1 -1
- package/Libraries/Image/Image.android.js +172 -306
- package/Libraries/Image/ImageProps.js +9 -11
- package/Libraries/Image/ImageSource.js +2 -2
- package/Libraries/Image/ImageSourceUtils.js +8 -4
- package/Libraries/Image/ImageTypes.flow.js +2 -2
- package/Libraries/Image/ImageViewNativeComponent.js +7 -16
- package/Libraries/Image/nativeImageSource.js +1 -1
- package/Libraries/Interaction/InteractionManager.js +5 -4
- package/Libraries/Interaction/PanResponder.js +1 -1
- package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -2
- package/Libraries/Linking/Linking.js +1 -1
- package/Libraries/Lists/FlatList.js +3 -3
- package/Libraries/Lists/SectionList.js +1 -1
- package/Libraries/Lists/SectionListModern.js +2 -2
- package/Libraries/LogBox/Data/LogBoxData.js +38 -24
- package/Libraries/LogBox/Data/LogBoxLog.js +43 -112
- package/Libraries/LogBox/Data/parseLogBoxLog.js +21 -117
- package/Libraries/LogBox/LogBox.js +42 -19
- package/Libraries/LogBox/LogBoxInspectorContainer.js +2 -2
- package/Libraries/LogBox/LogBoxNotificationContainer.js +2 -2
- package/Libraries/LogBox/UI/LogBoxButton.js +14 -16
- package/Libraries/LogBox/UI/LogBoxInspector.js +2 -2
- package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js +6 -9
- package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.win32.js +6 -9
- package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorHeaderButton.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorMessageHeader.js +10 -15
- package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js +25 -18
- package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.win32.js +15 -16
- package/Libraries/LogBox/UI/LogBoxInspectorSection.js +5 -7
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +8 -10
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.win32.js +11 -13
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.js +8 -6
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.win32.js +3 -5
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +17 -29
- package/Libraries/LogBox/UI/LogBoxMessage.js +28 -37
- package/Libraries/LogBox/UI/LogBoxNotification.js +1 -1
- package/Libraries/Modal/Modal.js +3 -3
- package/Libraries/NativeComponent/BaseViewConfig.android.js +28 -52
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +19 -21
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +16 -16
- package/Libraries/Network/RCTNetworking.android.js +1 -1
- package/Libraries/Network/RCTNetworking.ios.js +1 -1
- package/Libraries/Network/RCTNetworking.js.flow +1 -1
- package/Libraries/Network/RCTNetworking.win32.js +1 -1
- package/Libraries/Network/RCTNetworkingEventDefinitions.flow.js +1 -1
- package/Libraries/Network/XMLHttpRequest.js +1 -1
- package/Libraries/PermissionsAndroid/PermissionsAndroid.js +3 -3
- package/Libraries/Pressability/Pressability.js +5 -5
- package/Libraries/Pressability/Pressability.win32.js +5 -5
- package/Libraries/Pressability/PressabilityDebug.js +1 -1
- package/Libraries/Pressability/PressabilityPerformanceEventEmitter.js +1 -1
- package/Libraries/Pressability/usePressability.js +3 -14
- package/Libraries/PushNotificationIOS/PushNotificationIOS.js +2 -2
- package/Libraries/ReactNative/AppContainer-dev.js +18 -1
- package/Libraries/ReactNative/AppContainer.js +1 -1
- package/Libraries/ReactNative/AppRegistry.flow.js +2 -2
- package/Libraries/ReactNative/AppRegistryImpl.js +2 -2
- package/Libraries/ReactNative/FabricUIManager.js +1 -1
- package/Libraries/ReactNative/RendererImplementation.js +4 -4
- package/Libraries/ReactNative/UIManagerProperties.js +1 -1
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +3 -2
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3 -2
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +3 -2
- package/Libraries/Renderer/shims/ReactFabric.js +1 -3
- package/Libraries/Renderer/shims/ReactFeatureFlags.js +1 -3
- package/Libraries/Renderer/shims/ReactNative.js +3 -2
- package/Libraries/Renderer/shims/ReactNativeTypes.js +1 -3
- package/Libraries/Renderer/shims/ReactNativeTypes.win32.js +1 -3
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +1 -3
- package/Libraries/Renderer/shims/createReactNativeComponentClass.js +1 -3
- package/Libraries/StyleSheet/PointPropType.js +1 -1
- package/Libraries/StyleSheet/Rect.js +1 -1
- package/Libraries/StyleSheet/StyleSheet.d.ts +0 -5
- package/Libraries/StyleSheet/StyleSheet.js +1 -1
- package/Libraries/StyleSheet/StyleSheet.js.flow +1 -1
- package/Libraries/StyleSheet/StyleSheetExports.js +16 -25
- package/Libraries/StyleSheet/StyleSheetExports.js.flow +2 -7
- package/Libraries/StyleSheet/StyleSheetTypes.js +33 -35
- package/Libraries/StyleSheet/private/_StyleSheetTypesOverrides.js +5 -5
- package/Libraries/StyleSheet/private/_TransformStyle.js +7 -7
- package/Libraries/StyleSheet/processBackgroundImage.js +7 -7
- package/Libraries/StyleSheet/processBackgroundPosition.js +4 -4
- package/Libraries/StyleSheet/processBackgroundRepeat.js +4 -4
- package/Libraries/StyleSheet/processBackgroundSize.js +4 -4
- package/Libraries/StyleSheet/processBoxShadow.js +44 -4
- package/Libraries/StyleSheet/processColorArray.js +2 -2
- package/Libraries/StyleSheet/processFilter.js +2 -2
- package/Libraries/Text/Text.js +295 -627
- package/Libraries/Text/Text.win32.js +360 -744
- package/Libraries/Text/TextNativeComponent.js +14 -7
- package/Libraries/Text/TextNativeComponent.win32.js +14 -7
- package/Libraries/Text/TextProps.js +4 -4
- package/Libraries/Text/TextProps.win32.js +4 -4
- package/Libraries/Types/CodegenTypes.js +1 -1
- package/Libraries/Types/CoreEventTypes.js +21 -21
- package/Libraries/Types/CoreEventTypes.win32.js +22 -21
- package/Libraries/Types/ReactDevToolsTypes.js +2 -2
- package/Libraries/Utilities/Appearance.js +6 -1
- package/Libraries/Utilities/Dimensions.js +1 -1
- package/Libraries/Utilities/Dimensions.win32.js +1 -1
- package/Libraries/Utilities/HMRClient.js +32 -5
- package/Libraries/Utilities/IPerformanceLogger.js +4 -4
- package/Libraries/Utilities/codegenNativeCommands.js +4 -4
- package/Libraries/Utilities/codegenNativeComponent.d.ts +2 -0
- package/Libraries/Utilities/codegenNativeComponent.js +2 -2
- package/Libraries/Utilities/logError.js +1 -1
- package/Libraries/Utilities/stringifySafe.js +3 -3
- package/Libraries/Utilities/useMergeRefs.js +2 -2
- package/Libraries/vendor/core/ErrorUtils.js +4 -4
- package/Libraries/vendor/emitter/EventEmitter.js +16 -20
- package/flow/bom.js.flow +18 -17
- package/flow/dom.js.flow +12 -5
- package/flow/global.js +1 -1
- package/index.js +9 -0
- package/index.win32.js +9 -0
- package/index.win32.js.flow +8 -1
- package/jest/RefreshControlMock.js +2 -2
- package/jest/assetFileTransformer.js +8 -3
- package/jest/mockComponent.js +3 -4
- package/jest/mockNativeComponent.js +1 -1
- package/jest/mocks/ActivityIndicator.js +2 -2
- package/jest/mocks/Image.js +2 -2
- package/jest/mocks/Modal.js +2 -2
- package/jest/mocks/RefreshControl.js +3 -3
- package/jest/mocks/RendererProxy.js +2 -2
- package/jest/mocks/ScrollView.js +5 -5
- package/jest/mocks/Text.js +2 -2
- package/jest/mocks/TextInput.js +2 -2
- package/jest/mocks/View.js +2 -2
- package/jest/mocks/ViewNativeComponent.js +1 -1
- package/jest/mocks/requireNativeComponent.js +1 -1
- package/jest/mocks/useColorScheme.js +1 -1
- package/jest/setup.js +68 -31
- package/overrides.json +30 -36
- package/package.json +20 -17
- package/src/private/animated/NativeAnimatedHelper.js +2 -2
- package/src/private/animated/NativeAnimatedHelper.win32.js +2 -2
- package/src/private/animated/createAnimatedPropsMemoHook.js +19 -19
- package/src/private/components/virtualview/VirtualView.js +14 -21
- package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +11 -10
- package/src/private/components/virtualview/VirtualViewNativeComponent.js +4 -4
- package/src/private/devsupport/devmenu/elementinspector/BorderBox.js +2 -2
- package/src/private/devsupport/devmenu/elementinspector/BoxInspector.js +3 -3
- package/src/private/devsupport/devmenu/elementinspector/ElementBox.js +4 -4
- package/src/private/devsupport/devmenu/elementinspector/ElementProperties.js +1 -1
- package/src/private/devsupport/devmenu/elementinspector/Inspector.js +39 -17
- package/src/private/devsupport/devmenu/elementinspector/InspectorOverlay.js +15 -3
- package/src/private/devsupport/devmenu/elementinspector/InspectorPanel.js +2 -2
- package/src/private/devsupport/devmenu/elementinspector/ReactDevToolsOverlay.js +2 -8
- package/src/private/devsupport/devmenu/elementinspector/StyleInspector.js +1 -1
- package/src/private/devsupport/devmenu/elementinspector/resolveBoxStyle.js +1 -1
- package/src/private/devsupport/devmenu/elementinspector/useExternalInspection.js +102 -0
- package/src/private/devsupport/rndevtools/FuseboxSessionObserver.js +12 -25
- package/src/private/devsupport/rndevtools/GlobalStateObserver.js +56 -0
- package/src/private/devsupport/rndevtools/TracingStateObserver.js +28 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +71 -79
- package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +2 -2
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +14 -12
- package/src/private/setup/setUpDefaultReactNativeEnvironment.js +6 -0
- package/src/private/specs_DEPRECATED/components/ActivityIndicatorViewNativeComponent.js +1 -1
- package/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js +3 -3
- package/src/private/specs_DEPRECATED/components/AndroidHorizontalScrollContentViewNativeComponent.js +1 -1
- package/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js +2 -2
- package/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js +2 -2
- package/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js +3 -3
- package/src/private/specs_DEPRECATED/components/ProgressBarAndroidNativeComponent.js +1 -1
- package/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js +1 -1
- package/src/private/specs_DEPRECATED/components/RCTInputAccessoryViewNativeComponent.js +1 -1
- package/src/private/specs_DEPRECATED/components/RCTModalHostViewNativeComponent.js +3 -3
- package/src/private/specs_DEPRECATED/components/RCTSafeAreaViewNativeComponent.js +1 -1
- package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +2 -2
- package/src/private/specs_DEPRECATED/components/UnimplementedNativeViewNativeComponent.js +1 -1
- package/src/private/specs_DEPRECATED/modules/NativeImageLoaderIOS.js +1 -1
- package/src/private/styles/composeStyles.js +1 -1
- package/src/private/utilities/toError.js +27 -0
- package/src/private/utilities/toExtendedError.js +30 -0
- package/src/private/webapis/dom/events/Event.js +1 -1
- package/src/private/webapis/dom/events/EventHandlerAttributes.js +2 -2
- package/src/private/webapis/dom/events/EventTarget.js +3 -3
- package/src/private/webapis/dom/events/internals/EventInternals.js +2 -2
- package/src/private/webapis/dom/nodes/ReadOnlyElement.js +1 -1
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +2 -2
- package/src/private/webapis/dom/nodes/specs/NativeDOM.js +14 -14
- package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +2 -2
- package/src/private/webapis/dom/oldstylecollections/NodeList.js +2 -2
- package/src/private/webapis/geometry/DOMRectList.js +2 -2
- package/src/private/webapis/intersectionobserver/IntersectionObserver.js +8 -8
- package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +6 -6
- package/src/private/webapis/mutationobserver/MutationObserver.js +2 -2
- package/src/private/webapis/mutationobserver/MutationRecord.js +2 -2
- package/src/private/webapis/mutationobserver/internals/MutationObserverManager.js +1 -1
- package/src/private/webapis/mutationobserver/specs/NativeMutationObserver.js +3 -3
- package/src/private/webapis/performance/LongTasks.js +3 -3
- package/src/private/webapis/performance/Performance.js +4 -4
- package/src/private/webapis/performance/PerformanceEntry.js +1 -1
- package/src/private/webapis/performance/PerformanceObserver.js +2 -2
- package/src/private/webapis/performance/specs/NativePerformance.js +8 -8
- package/src/private/webapis/structuredClone/structuredClone.js +2 -2
- package/src/types/globals.d.ts +4 -4
- package/src-win/Libraries/Components/EnterString.win32.tsx +2 -2
- package/src-win/Libraries/Components/Touchable/TouchableWin32.tsx +14 -14
- package/src-win/index.win32.js.flow +8 -1
- package/types/index.d.ts +2 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.js +0 -60
- package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +0 -94
- package/Libraries/Image/TextInlineImageNativeComponent.js +0 -49
|
@@ -19,16 +19,21 @@ import * as PressabilityDebug from '../Pressability/PressabilityDebug';
|
|
|
19
19
|
import usePressability from '../Pressability/usePressability';
|
|
20
20
|
import flattenStyle from '../StyleSheet/flattenStyle';
|
|
21
21
|
import processColor from '../StyleSheet/processColor';
|
|
22
|
+
import StyleSheet from '../StyleSheet/StyleSheet';
|
|
22
23
|
import Platform from '../Utilities/Platform';
|
|
23
24
|
import TextAncestorContext from './TextAncestorContext';
|
|
24
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
NativeSelectableText,
|
|
27
|
+
NativeText,
|
|
28
|
+
NativeVirtualText,
|
|
29
|
+
} from './TextNativeComponent';
|
|
25
30
|
import * as React from 'react';
|
|
26
31
|
import {useContext, useMemo, useState} from 'react';
|
|
27
32
|
|
|
28
33
|
export type {TextProps} from './TextProps';
|
|
29
34
|
|
|
30
35
|
type TextForwardRef = React.ElementRef<
|
|
31
|
-
typeof NativeText | typeof NativeVirtualText,
|
|
36
|
+
typeof NativeText | typeof NativeVirtualText | typeof NativeSelectableText,
|
|
32
37
|
>;
|
|
33
38
|
|
|
34
39
|
/**
|
|
@@ -36,751 +41,366 @@ type TextForwardRef = React.ElementRef<
|
|
|
36
41
|
*
|
|
37
42
|
* @see https://reactnative.dev/docs/text
|
|
38
43
|
*/
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
selected: ariaSelected,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
44
|
+
const TextImpl: component(
|
|
45
|
+
ref?: React.RefSetter<TextForwardRef>,
|
|
46
|
+
...props: TextProps
|
|
47
|
+
) = ({
|
|
48
|
+
ref: forwardedRef,
|
|
49
|
+
accessible,
|
|
50
|
+
accessibilityLabel,
|
|
51
|
+
accessibilityRole,
|
|
52
|
+
accessibilityState,
|
|
53
|
+
allowFontScaling,
|
|
54
|
+
'aria-busy': ariaBusy,
|
|
55
|
+
'aria-checked': ariaChecked,
|
|
56
|
+
'aria-disabled': ariaDisabled,
|
|
57
|
+
'aria-expanded': ariaExpanded,
|
|
58
|
+
'aria-hidden': ariaHidden,
|
|
59
|
+
'aria-label': ariaLabel,
|
|
60
|
+
'aria-selected': ariaSelected,
|
|
61
|
+
// #[ Win32
|
|
62
|
+
'aria-level': ariaLevel,
|
|
63
|
+
'aria-multiselectable': ariaMultiselectable,
|
|
64
|
+
'aria-posinset': ariaPosinset,
|
|
65
|
+
'aria-required': ariaRequired,
|
|
66
|
+
'aria-setsize': ariaSetsize,
|
|
67
|
+
'aria-controls': ariaControls,
|
|
68
|
+
'aria-describedby': ariaDescribedBy,
|
|
69
|
+
'aria-description': ariaDescription,
|
|
70
|
+
accessibilityLevel,
|
|
71
|
+
accessibilityPositionInSet,
|
|
72
|
+
accessibilitySetSize,
|
|
73
|
+
accessibilityControls,
|
|
74
|
+
accessibilityDescribedBy,
|
|
75
|
+
accessibilityDescription,
|
|
76
|
+
// #] Win32
|
|
77
|
+
children,
|
|
78
|
+
ellipsizeMode,
|
|
79
|
+
disabled,
|
|
80
|
+
id,
|
|
81
|
+
nativeID,
|
|
82
|
+
numberOfLines,
|
|
83
|
+
onLongPress,
|
|
84
|
+
onPress,
|
|
85
|
+
onPressIn,
|
|
86
|
+
onPressOut,
|
|
87
|
+
onResponderGrant,
|
|
88
|
+
onResponderMove,
|
|
89
|
+
onResponderRelease,
|
|
90
|
+
onResponderTerminate,
|
|
91
|
+
onResponderTerminationRequest,
|
|
92
|
+
onStartShouldSetResponder,
|
|
93
|
+
pressRetentionOffset,
|
|
94
|
+
role,
|
|
95
|
+
selectable,
|
|
96
|
+
selectionColor,
|
|
97
|
+
suppressHighlighting,
|
|
98
|
+
style,
|
|
99
|
+
...restProps
|
|
100
|
+
}: {
|
|
101
|
+
ref?: React.RefSetter<TextForwardRef>,
|
|
102
|
+
...TextProps,
|
|
103
|
+
}) => {
|
|
104
|
+
const processedProps = restProps as {
|
|
105
|
+
...NativeTextProps,
|
|
106
|
+
};
|
|
107
|
+
const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
|
|
108
|
+
// #Win32 [
|
|
109
|
+
const _accessibilityControls = ariaControls ?? accessibilityControls;
|
|
110
|
+
const _accessibilityDescribedBy =
|
|
111
|
+
ariaDescribedBy ?? accessibilityDescribedBy;
|
|
112
|
+
const _accessibilityDescription =
|
|
113
|
+
ariaDescription ?? accessibilityDescription;
|
|
114
|
+
const _accessibilityLevel = ariaLevel ?? accessibilityLevel;
|
|
115
|
+
const _accessibilityPositionInSet =
|
|
116
|
+
ariaPosinset ?? accessibilityPositionInSet;
|
|
117
|
+
const _accessibilitySetSize = ariaSetsize ?? accessibilitySetSize;
|
|
118
|
+
// ] #Win32
|
|
119
|
+
|
|
120
|
+
let _accessibilityState: ?TextProps['accessibilityState'] =
|
|
121
|
+
accessibilityState;
|
|
122
|
+
if (
|
|
123
|
+
ariaBusy != null ||
|
|
124
|
+
ariaChecked != null ||
|
|
125
|
+
ariaDisabled != null ||
|
|
126
|
+
ariaExpanded != null ||
|
|
127
|
+
ariaSelected != null
|
|
128
|
+
) {
|
|
129
|
+
if (_accessibilityState != null) {
|
|
130
|
+
_accessibilityState = {
|
|
131
|
+
busy: ariaBusy ?? _accessibilityState.busy,
|
|
132
|
+
checked: ariaChecked ?? _accessibilityState.checked,
|
|
133
|
+
disabled: ariaDisabled ?? _accessibilityState.disabled,
|
|
134
|
+
expanded: ariaExpanded ?? _accessibilityState.expanded,
|
|
135
|
+
// #Win32 [
|
|
136
|
+
multiselectable:
|
|
137
|
+
ariaMultiselectable ?? accessibilityState?.multiselectable,
|
|
138
|
+
required: ariaRequired ?? accessibilityState?.required,
|
|
139
|
+
// ] #Win32
|
|
140
|
+
selected: ariaSelected ?? _accessibilityState.selected,
|
|
141
|
+
};
|
|
142
|
+
} else {
|
|
143
|
+
_accessibilityState = {
|
|
144
|
+
busy: ariaBusy,
|
|
145
|
+
checked: ariaChecked,
|
|
146
|
+
disabled: ariaDisabled,
|
|
147
|
+
expanded: ariaExpanded,
|
|
148
|
+
// #[ Win32
|
|
149
|
+
multiselectable: ariaMultiselectable,
|
|
150
|
+
required: ariaRequired,
|
|
151
|
+
// #] Win32
|
|
152
|
+
selected: ariaSelected,
|
|
153
|
+
};
|
|
152
154
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const _accessibilityStateDisabled = _accessibilityState?.disabled;
|
|
158
|
+
const _disabled = disabled ?? _accessibilityStateDisabled;
|
|
159
|
+
|
|
160
|
+
// If the disabled prop and accessibilityState.disabled are out of sync but not both in
|
|
161
|
+
// falsy states we need to update the accessibilityState object to use the disabled prop.
|
|
162
|
+
if (
|
|
163
|
+
_disabled !== _accessibilityStateDisabled &&
|
|
164
|
+
((_disabled != null && _disabled !== false) ||
|
|
165
|
+
(_accessibilityStateDisabled != null &&
|
|
166
|
+
_accessibilityStateDisabled !== false))
|
|
167
|
+
) {
|
|
168
|
+
if (_accessibilityState == null) {
|
|
169
|
+
_accessibilityState = {disabled};
|
|
170
|
+
} else {
|
|
166
171
|
_accessibilityState.disabled = _disabled;
|
|
167
172
|
}
|
|
173
|
+
}
|
|
168
174
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const _accessible = Platform.select({
|
|
177
|
-
ios: accessible !== false,
|
|
178
|
-
android:
|
|
179
|
-
accessible == null
|
|
180
|
-
? onPress != null || onLongPress != null
|
|
181
|
-
: accessible,
|
|
182
|
-
default: accessible !== false, // [Windows #13996 - default value is accessible !== false]
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
const isPressable =
|
|
186
|
-
(onPress != null ||
|
|
187
|
-
onLongPress != null ||
|
|
188
|
-
onStartShouldSetResponder != null) &&
|
|
189
|
-
_disabled !== true;
|
|
190
|
-
|
|
191
|
-
const shouldUseLinkRole =
|
|
192
|
-
ReactNativeFeatureFlags.shouldUseLinkRoleForPressableText() &&
|
|
193
|
-
isPressable &&
|
|
194
|
-
accessibilityRole == null &&
|
|
195
|
-
role == null;
|
|
196
|
-
|
|
197
|
-
const _accessibilityRole =
|
|
198
|
-
accessibilityRole ?? (shouldUseLinkRole ? 'link' : undefined);
|
|
199
|
-
|
|
200
|
-
const _role = shouldUseLinkRole ? undefined : role;
|
|
201
|
-
|
|
202
|
-
// TODO: Move this processing to the view configuration.
|
|
203
|
-
const _selectionColor =
|
|
204
|
-
selectionColor != null ? processColor(selectionColor) : undefined;
|
|
205
|
-
|
|
206
|
-
let _style = style;
|
|
207
|
-
if (__DEV__) {
|
|
208
|
-
if (PressabilityDebug.isEnabled() && onPress != null) {
|
|
209
|
-
_style = [style, {color: 'magenta'}];
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
let _numberOfLines = numberOfLines;
|
|
214
|
-
if (_numberOfLines != null && !(_numberOfLines >= 0)) {
|
|
215
|
-
if (__DEV__) {
|
|
216
|
-
console.error(
|
|
217
|
-
`'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
_numberOfLines = 0;
|
|
175
|
+
if (ariaHidden !== undefined) {
|
|
176
|
+
processedProps.accessibilityElementsHidden = ariaHidden;
|
|
177
|
+
if (ariaHidden === true) {
|
|
178
|
+
processedProps.importantForAccessibility = 'no-hide-descendants';
|
|
221
179
|
}
|
|
180
|
+
}
|
|
222
181
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
overrides = overrides || ({}: {...TextStyleInternal});
|
|
230
|
-
overrides.fontWeight =
|
|
231
|
-
// $FlowFixMe[incompatible-type]
|
|
232
|
-
(String(processedStyle.fontWeight): TextStyleInternal['fontWeight']);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if (processedStyle.userSelect != null) {
|
|
236
|
-
_selectable = userSelectToSelectableMap[processedStyle.userSelect];
|
|
237
|
-
overrides = overrides || ({}: {...TextStyleInternal});
|
|
238
|
-
overrides.userSelect = undefined;
|
|
239
|
-
}
|
|
182
|
+
const _accessible = Platform.select({
|
|
183
|
+
ios: accessible !== false,
|
|
184
|
+
android:
|
|
185
|
+
accessible == null ? onPress != null || onLongPress != null : accessible,
|
|
186
|
+
default: accessible !== false, // [Windows #13996 - default value is accessible !== false]
|
|
187
|
+
});
|
|
240
188
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
189
|
+
const isPressable =
|
|
190
|
+
(onPress != null ||
|
|
191
|
+
onLongPress != null ||
|
|
192
|
+
onStartShouldSetResponder != null) &&
|
|
193
|
+
_disabled !== true;
|
|
247
194
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
_style = [_style, overrides];
|
|
251
|
-
}
|
|
252
|
-
}
|
|
195
|
+
const shouldUseLinkRole =
|
|
196
|
+
isPressable && accessibilityRole == null && role == null;
|
|
253
197
|
|
|
254
|
-
|
|
198
|
+
const _accessibilityRole =
|
|
199
|
+
accessibilityRole ?? (shouldUseLinkRole ? 'link' : undefined);
|
|
255
200
|
|
|
256
|
-
|
|
257
|
-
processedProps.accessibilityLabel = _accessibilityLabel;
|
|
258
|
-
}
|
|
259
|
-
if (_accessibilityRole !== undefined) {
|
|
260
|
-
processedProps.accessibilityRole = _accessibilityRole;
|
|
261
|
-
}
|
|
262
|
-
if (_accessibilityState !== undefined) {
|
|
263
|
-
processedProps.accessibilityState = _accessibilityState;
|
|
264
|
-
}
|
|
265
|
-
if (_nativeID !== undefined) {
|
|
266
|
-
processedProps.nativeID = _nativeID;
|
|
267
|
-
}
|
|
268
|
-
if (_numberOfLines !== undefined) {
|
|
269
|
-
processedProps.numberOfLines = _numberOfLines;
|
|
270
|
-
}
|
|
271
|
-
if (_selectable !== undefined) {
|
|
272
|
-
processedProps.selectable = _selectable;
|
|
273
|
-
}
|
|
274
|
-
if (_style !== undefined) {
|
|
275
|
-
processedProps.style = _style;
|
|
276
|
-
}
|
|
277
|
-
if (_selectionColor !== undefined) {
|
|
278
|
-
processedProps.selectionColor = _selectionColor;
|
|
279
|
-
}
|
|
280
|
-
if (_role !== undefined) {
|
|
281
|
-
processedProps.role = _role;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// [Windows accessibility properties
|
|
285
|
-
if (_accessibilityControls !== undefined) {
|
|
286
|
-
processedProps.accessibilityControls = _accessibilityControls;
|
|
287
|
-
}
|
|
201
|
+
const _role = shouldUseLinkRole ? undefined : role;
|
|
288
202
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
203
|
+
// TODO: Move this processing to the view configuration.
|
|
204
|
+
const _selectionColor =
|
|
205
|
+
selectionColor != null ? processColor(selectionColor) : undefined;
|
|
292
206
|
|
|
293
|
-
|
|
294
|
-
|
|
207
|
+
let _style = style;
|
|
208
|
+
if (__DEV__) {
|
|
209
|
+
if (PressabilityDebug.isEnabled() && onPress != null) {
|
|
210
|
+
_style = [style, {color: 'magenta'}];
|
|
295
211
|
}
|
|
212
|
+
}
|
|
296
213
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
if (_accessibilitySetSize !== undefined) {
|
|
304
|
-
processedProps.accessibilitySetSize = _accessibilitySetSize;
|
|
305
|
-
}
|
|
306
|
-
// ]
|
|
307
|
-
|
|
308
|
-
let textPressabilityProps: ?TextPressabilityProps;
|
|
309
|
-
if (isPressable) {
|
|
310
|
-
textPressabilityProps = {
|
|
311
|
-
onLongPress,
|
|
312
|
-
onPress,
|
|
313
|
-
onPressIn,
|
|
314
|
-
onPressOut,
|
|
315
|
-
onResponderGrant,
|
|
316
|
-
onResponderMove,
|
|
317
|
-
onResponderRelease,
|
|
318
|
-
onResponderTerminate,
|
|
319
|
-
onResponderTerminationRequest,
|
|
320
|
-
onStartShouldSetResponder,
|
|
321
|
-
pressRetentionOffset,
|
|
322
|
-
suppressHighlighting,
|
|
323
|
-
};
|
|
214
|
+
let _numberOfLines = numberOfLines;
|
|
215
|
+
if (_numberOfLines != null && !(_numberOfLines >= 0)) {
|
|
216
|
+
if (__DEV__) {
|
|
217
|
+
console.error(
|
|
218
|
+
`'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
|
|
219
|
+
);
|
|
324
220
|
}
|
|
221
|
+
_numberOfLines = 0;
|
|
222
|
+
}
|
|
325
223
|
|
|
326
|
-
|
|
327
|
-
if (hasTextAncestor) {
|
|
328
|
-
processedProps.disabled = disabled;
|
|
329
|
-
processedProps.children = children;
|
|
330
|
-
if (isPressable) {
|
|
331
|
-
return (
|
|
332
|
-
<NativePressableVirtualText
|
|
333
|
-
ref={forwardedRef}
|
|
334
|
-
textProps={processedProps}
|
|
335
|
-
textPressabilityProps={textPressabilityProps ?? {}}
|
|
336
|
-
/>
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
return <NativeVirtualText {...processedProps} ref={forwardedRef} />;
|
|
340
|
-
}
|
|
224
|
+
let _selectable = selectable;
|
|
341
225
|
|
|
342
|
-
|
|
226
|
+
let processedStyle = flattenStyle<TextStyleProp>(_style);
|
|
227
|
+
if (processedStyle != null) {
|
|
228
|
+
let overrides: ?{...TextStyleInternal} = null;
|
|
229
|
+
if (typeof processedStyle.fontWeight === 'number') {
|
|
230
|
+
overrides = overrides || ({}: {...TextStyleInternal});
|
|
231
|
+
overrides.fontWeight =
|
|
232
|
+
// $FlowFixMe[incompatible-type]
|
|
233
|
+
(String(processedStyle.fontWeight): TextStyleInternal['fontWeight']);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (processedStyle.userSelect != null) {
|
|
237
|
+
_selectable = userSelectToSelectableMap[processedStyle.userSelect];
|
|
238
|
+
overrides = overrides || ({}: {...TextStyleInternal});
|
|
239
|
+
overrides.userSelect = undefined;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (processedStyle.verticalAlign != null) {
|
|
243
|
+
overrides = overrides || ({}: {...TextStyleInternal});
|
|
244
|
+
overrides.textAlignVertical =
|
|
245
|
+
verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
|
|
246
|
+
overrides.verticalAlign = undefined;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (overrides != null) {
|
|
250
|
+
// $FlowFixMe[incompatible-type]
|
|
251
|
+
_style = [_style, overrides];
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (ReactNativeFeatureFlags.defaultTextToOverflowHidden()) {
|
|
256
|
+
_style = [styles.default, _style];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const _nativeID = id ?? nativeID;
|
|
260
|
+
|
|
261
|
+
if (_accessibilityLabel !== undefined) {
|
|
262
|
+
processedProps.accessibilityLabel = _accessibilityLabel;
|
|
263
|
+
}
|
|
264
|
+
if (_accessibilityRole !== undefined) {
|
|
265
|
+
processedProps.accessibilityRole = _accessibilityRole;
|
|
266
|
+
}
|
|
267
|
+
if (_accessibilityState !== undefined) {
|
|
268
|
+
processedProps.accessibilityState = _accessibilityState;
|
|
269
|
+
}
|
|
270
|
+
if (_nativeID !== undefined) {
|
|
271
|
+
processedProps.nativeID = _nativeID;
|
|
272
|
+
}
|
|
273
|
+
if (_numberOfLines !== undefined) {
|
|
274
|
+
processedProps.numberOfLines = _numberOfLines;
|
|
275
|
+
}
|
|
276
|
+
if (_selectable !== undefined) {
|
|
277
|
+
processedProps.selectable = _selectable;
|
|
278
|
+
}
|
|
279
|
+
if (_style !== undefined) {
|
|
280
|
+
processedProps.style = _style;
|
|
281
|
+
}
|
|
282
|
+
if (_selectionColor !== undefined) {
|
|
283
|
+
processedProps.selectionColor = _selectionColor;
|
|
284
|
+
}
|
|
285
|
+
if (_role !== undefined) {
|
|
286
|
+
processedProps.role = _role;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// [Windows accessibility properties
|
|
290
|
+
if (_accessibilityControls !== undefined) {
|
|
291
|
+
processedProps.accessibilityControls = _accessibilityControls;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (_accessibilityDescribedBy !== undefined) {
|
|
295
|
+
processedProps.accessibilityDescribedBy = _accessibilityDescribedBy;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (_accessibilityDescription !== undefined) {
|
|
299
|
+
processedProps.accessibilityDescription = _accessibilityDescription;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (_accessibilityLevel !== undefined) {
|
|
303
|
+
processedProps.accessibilityLevel = _accessibilityLevel;
|
|
304
|
+
}
|
|
305
|
+
if (_accessibilityPositionInSet !== undefined) {
|
|
306
|
+
processedProps.accessibilityPositionInSet = _accessibilityPositionInSet;
|
|
307
|
+
}
|
|
308
|
+
if (_accessibilitySetSize !== undefined) {
|
|
309
|
+
processedProps.accessibilitySetSize = _accessibilitySetSize;
|
|
310
|
+
}
|
|
311
|
+
// ]
|
|
312
|
+
|
|
313
|
+
let textPressabilityProps: ?TextPressabilityProps;
|
|
314
|
+
if (isPressable) {
|
|
315
|
+
textPressabilityProps = {
|
|
316
|
+
onLongPress,
|
|
317
|
+
onPress,
|
|
318
|
+
onPressIn,
|
|
319
|
+
onPressOut,
|
|
320
|
+
onResponderGrant,
|
|
321
|
+
onResponderMove,
|
|
322
|
+
onResponderRelease,
|
|
323
|
+
onResponderTerminate,
|
|
324
|
+
onResponderTerminationRequest,
|
|
325
|
+
onStartShouldSetResponder,
|
|
326
|
+
pressRetentionOffset,
|
|
327
|
+
suppressHighlighting,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
343
330
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
processedProps.disabled =
|
|
347
|
-
processedProps.ellipsizeMode = ellipsizeMode ?? 'tail';
|
|
331
|
+
const hasTextAncestor = useContext(TextAncestorContext);
|
|
332
|
+
if (hasTextAncestor) {
|
|
333
|
+
processedProps.disabled = disabled;
|
|
348
334
|
processedProps.children = children;
|
|
349
|
-
|
|
350
335
|
if (isPressable) {
|
|
351
|
-
|
|
352
|
-
<
|
|
336
|
+
return (
|
|
337
|
+
<PressableVirtualText
|
|
353
338
|
ref={forwardedRef}
|
|
354
339
|
textProps={processedProps}
|
|
355
340
|
textPressabilityProps={textPressabilityProps ?? {}}
|
|
356
341
|
/>
|
|
357
342
|
);
|
|
358
|
-
} else {
|
|
359
|
-
nativeText = <NativeText {...processedProps} ref={forwardedRef} />;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
if (children == null) {
|
|
363
|
-
return nativeText;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
// If the children do not contain a JSX element it would not be possible to have a
|
|
367
|
-
// nested `Text` component so we can skip adding the `TextAncestorContext` context wrapper
|
|
368
|
-
// which has a performance overhead. Since we do this for performance reasons we need
|
|
369
|
-
// to keep the check simple to avoid regressing overall perf. For this reason the
|
|
370
|
-
// `children.length` constant is set to `3`, this should be a reasonable tradeoff
|
|
371
|
-
// to capture the majority of `Text` uses but also not make this check too expensive.
|
|
372
|
-
if (Array.isArray(children) && children.length <= 3) {
|
|
373
|
-
let hasNonTextChild = false;
|
|
374
|
-
for (let child of children) {
|
|
375
|
-
if (child != null && typeof child === 'object') {
|
|
376
|
-
hasNonTextChild = true;
|
|
377
|
-
break;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
if (!hasNonTextChild) {
|
|
381
|
-
return nativeText;
|
|
382
|
-
}
|
|
383
|
-
} else if (typeof children !== 'object') {
|
|
384
|
-
return nativeText;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
return <TextAncestorContext value={true}>{nativeText}</TextAncestorContext>;
|
|
388
|
-
};
|
|
389
|
-
_TextImpl = TextImplNoDefaultProps;
|
|
390
|
-
} else {
|
|
391
|
-
const TextImplLegacy: component(
|
|
392
|
-
ref?: React.RefSetter<TextForwardRef>,
|
|
393
|
-
...props: TextProps
|
|
394
|
-
) = ({
|
|
395
|
-
ref: forwardedRef,
|
|
396
|
-
accessible,
|
|
397
|
-
accessibilityElementsHidden,
|
|
398
|
-
importantForAccessibility,
|
|
399
|
-
accessibilityLabel,
|
|
400
|
-
accessibilityRole,
|
|
401
|
-
accessibilityState,
|
|
402
|
-
allowFontScaling,
|
|
403
|
-
'aria-busy': ariaBusy,
|
|
404
|
-
'aria-checked': ariaChecked,
|
|
405
|
-
'aria-disabled': ariaDisabled,
|
|
406
|
-
'aria-expanded': ariaExpanded,
|
|
407
|
-
'aria-hidden': ariaHidden,
|
|
408
|
-
'aria-label': ariaLabel,
|
|
409
|
-
'aria-selected': ariaSelected,
|
|
410
|
-
//#[ Win32
|
|
411
|
-
'aria-controls': ariaControls,
|
|
412
|
-
'aria-describedby': ariaDescribedBy,
|
|
413
|
-
'aria-description': ariaDescription,
|
|
414
|
-
'aria-level': ariaLevel,
|
|
415
|
-
'aria-multiselectable': ariaMultiselectable,
|
|
416
|
-
'aria-posinset': ariaPosinset,
|
|
417
|
-
'aria-required': ariaRequired,
|
|
418
|
-
'aria-setsize': ariaSetsize,
|
|
419
|
-
accessibilityLevel,
|
|
420
|
-
accessibilityPositionInSet,
|
|
421
|
-
accessibilitySetSize,
|
|
422
|
-
accessibilityControls,
|
|
423
|
-
accessibilityDescribedBy,
|
|
424
|
-
accessibilityDescription,
|
|
425
|
-
// #] Win32
|
|
426
|
-
children,
|
|
427
|
-
ellipsizeMode,
|
|
428
|
-
disabled,
|
|
429
|
-
id,
|
|
430
|
-
nativeID,
|
|
431
|
-
numberOfLines,
|
|
432
|
-
onLongPress,
|
|
433
|
-
onPress,
|
|
434
|
-
onPressIn,
|
|
435
|
-
onPressOut,
|
|
436
|
-
onResponderGrant,
|
|
437
|
-
onResponderMove,
|
|
438
|
-
onResponderRelease,
|
|
439
|
-
onResponderTerminate,
|
|
440
|
-
onResponderTerminationRequest,
|
|
441
|
-
onStartShouldSetResponder,
|
|
442
|
-
pressRetentionOffset,
|
|
443
|
-
role,
|
|
444
|
-
selectable,
|
|
445
|
-
selectionColor,
|
|
446
|
-
suppressHighlighting,
|
|
447
|
-
style,
|
|
448
|
-
...restProps
|
|
449
|
-
}: {
|
|
450
|
-
ref?: React.RefSetter<TextForwardRef>,
|
|
451
|
-
...TextProps,
|
|
452
|
-
}) => {
|
|
453
|
-
const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
|
|
454
|
-
//#[ Win32
|
|
455
|
-
const _accessibilityControls = ariaControls ?? accessibilityControls;
|
|
456
|
-
const _accessibilityDescribedBy =
|
|
457
|
-
ariaDescribedBy ?? accessibilityDescribedBy;
|
|
458
|
-
const _accessibilityDescription =
|
|
459
|
-
ariaDescription ?? accessibilityDescription;
|
|
460
|
-
const _accessibilityLevel = ariaLevel ?? accessibilityLevel;
|
|
461
|
-
const _accessibilityPositionInSet =
|
|
462
|
-
ariaPosinset ?? accessibilityPositionInSet;
|
|
463
|
-
const _accessibilitySetSize = ariaSetsize ?? accessibilitySetSize;
|
|
464
|
-
//#] Win32
|
|
465
|
-
|
|
466
|
-
let _accessibilityState: ?TextProps['accessibilityState'] =
|
|
467
|
-
accessibilityState;
|
|
468
|
-
if (
|
|
469
|
-
ariaBusy != null ||
|
|
470
|
-
ariaChecked != null ||
|
|
471
|
-
ariaDisabled != null ||
|
|
472
|
-
ariaExpanded != null ||
|
|
473
|
-
ariaSelected != null
|
|
474
|
-
) {
|
|
475
|
-
if (_accessibilityState != null) {
|
|
476
|
-
_accessibilityState = {
|
|
477
|
-
busy: ariaBusy ?? _accessibilityState.busy,
|
|
478
|
-
checked: ariaChecked ?? _accessibilityState.checked,
|
|
479
|
-
disabled: ariaDisabled ?? _accessibilityState.disabled,
|
|
480
|
-
expanded: ariaExpanded ?? _accessibilityState.expanded,
|
|
481
|
-
//#[Win32
|
|
482
|
-
multiselectable:
|
|
483
|
-
ariaMultiselectable ?? accessibilityState?.multiselectable,
|
|
484
|
-
required: ariaRequired ?? accessibilityState?.required,
|
|
485
|
-
// #] Win32
|
|
486
|
-
selected: ariaSelected ?? _accessibilityState.selected,
|
|
487
|
-
};
|
|
488
|
-
} else {
|
|
489
|
-
_accessibilityState = {
|
|
490
|
-
busy: ariaBusy,
|
|
491
|
-
checked: ariaChecked,
|
|
492
|
-
disabled: ariaDisabled,
|
|
493
|
-
expanded: ariaExpanded,
|
|
494
|
-
// #[ Win32
|
|
495
|
-
multiselectable: ariaMultiselectable,
|
|
496
|
-
required: ariaRequired,
|
|
497
|
-
// #]win32
|
|
498
|
-
selected: ariaSelected,
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
const _accessibilityStateDisabled = _accessibilityState?.disabled;
|
|
504
|
-
const _disabled = disabled ?? _accessibilityStateDisabled;
|
|
505
|
-
|
|
506
|
-
let _accessibilityElementsHidden =
|
|
507
|
-
ariaHidden ?? accessibilityElementsHidden;
|
|
508
|
-
let _importantForAccessibility = importantForAccessibility;
|
|
509
|
-
if (ariaHidden === true) {
|
|
510
|
-
_importantForAccessibility = 'no-hide-descendants';
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
const isPressable =
|
|
514
|
-
(onPress != null ||
|
|
515
|
-
onLongPress != null ||
|
|
516
|
-
onStartShouldSetResponder != null) &&
|
|
517
|
-
_disabled !== true;
|
|
518
|
-
|
|
519
|
-
const shouldUseLinkRole =
|
|
520
|
-
ReactNativeFeatureFlags.shouldUseLinkRoleForPressableText() &&
|
|
521
|
-
isPressable &&
|
|
522
|
-
accessibilityRole == null &&
|
|
523
|
-
role == null;
|
|
524
|
-
|
|
525
|
-
const _accessibilityRole =
|
|
526
|
-
accessibilityRole ?? (shouldUseLinkRole ? 'link' : undefined);
|
|
527
|
-
|
|
528
|
-
const _role = shouldUseLinkRole ? undefined : role;
|
|
529
|
-
|
|
530
|
-
// TODO: Move this processing to the view configuration.
|
|
531
|
-
const _selectionColor =
|
|
532
|
-
selectionColor != null ? processColor(selectionColor) : undefined;
|
|
533
|
-
|
|
534
|
-
let _style = style;
|
|
535
|
-
if (__DEV__) {
|
|
536
|
-
if (PressabilityDebug.isEnabled() && onPress != null) {
|
|
537
|
-
_style = [style, {color: 'magenta'}];
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
let _numberOfLines = numberOfLines;
|
|
542
|
-
if (_numberOfLines != null && !(_numberOfLines >= 0)) {
|
|
543
|
-
if (__DEV__) {
|
|
544
|
-
console.error(
|
|
545
|
-
`'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
|
|
546
|
-
);
|
|
547
|
-
}
|
|
548
|
-
_numberOfLines = 0;
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
let _selectable = selectable;
|
|
552
|
-
|
|
553
|
-
let processedStyle = flattenStyle<TextStyleProp>(_style);
|
|
554
|
-
if (processedStyle != null) {
|
|
555
|
-
let overrides: ?{...TextStyleInternal} = null;
|
|
556
|
-
if (typeof processedStyle.fontWeight === 'number') {
|
|
557
|
-
overrides = overrides || ({}: {...TextStyleInternal});
|
|
558
|
-
overrides.fontWeight =
|
|
559
|
-
// $FlowFixMe[incompatible-type]
|
|
560
|
-
(processedStyle.fontWeight.toString(): TextStyleInternal['fontWeight']);
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
if (processedStyle.userSelect != null) {
|
|
564
|
-
_selectable = userSelectToSelectableMap[processedStyle.userSelect];
|
|
565
|
-
overrides = overrides || ({}: {...TextStyleInternal});
|
|
566
|
-
overrides.userSelect = undefined;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
if (processedStyle.verticalAlign != null) {
|
|
570
|
-
overrides = overrides || ({}: {...TextStyleInternal});
|
|
571
|
-
overrides.textAlignVertical =
|
|
572
|
-
verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
|
|
573
|
-
overrides.verticalAlign = undefined;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
if (overrides != null) {
|
|
577
|
-
// $FlowFixMe[incompatible-type]
|
|
578
|
-
_style = [_style, overrides];
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
const _nativeID = id ?? nativeID;
|
|
583
|
-
|
|
584
|
-
const hasTextAncestor = useContext(TextAncestorContext);
|
|
585
|
-
if (hasTextAncestor) {
|
|
586
|
-
if (isPressable) {
|
|
587
|
-
return (
|
|
588
|
-
<NativePressableVirtualText
|
|
589
|
-
ref={forwardedRef}
|
|
590
|
-
textProps={{
|
|
591
|
-
...restProps,
|
|
592
|
-
accessibilityElementsHidden: _accessibilityElementsHidden,
|
|
593
|
-
accessibilityLabel: _accessibilityLabel,
|
|
594
|
-
accessibilityRole: _accessibilityRole,
|
|
595
|
-
accessibilityState: _accessibilityState,
|
|
596
|
-
importantForAccessibility: _importantForAccessibility,
|
|
597
|
-
// #[ Win32
|
|
598
|
-
accessibilityControls: _accessibilityControls,
|
|
599
|
-
accessibilityDescribedBy: _accessibilityDescribedBy,
|
|
600
|
-
accessibilityDescription: _accessibilityDescription,
|
|
601
|
-
accessibilityLevel: _accessibilityLevel,
|
|
602
|
-
accessibilityPositionInSet: _accessibilityPositionInSet,
|
|
603
|
-
accessibilitySetSize: _accessibilitySetSize,
|
|
604
|
-
// #] Win32
|
|
605
|
-
nativeID: _nativeID,
|
|
606
|
-
numberOfLines: _numberOfLines,
|
|
607
|
-
selectable: _selectable,
|
|
608
|
-
selectionColor: _selectionColor,
|
|
609
|
-
style: _style,
|
|
610
|
-
disabled: disabled,
|
|
611
|
-
role: _role,
|
|
612
|
-
children,
|
|
613
|
-
}}
|
|
614
|
-
textPressabilityProps={{
|
|
615
|
-
onLongPress,
|
|
616
|
-
onPress,
|
|
617
|
-
onPressIn,
|
|
618
|
-
onPressOut,
|
|
619
|
-
onResponderGrant,
|
|
620
|
-
onResponderMove,
|
|
621
|
-
onResponderRelease,
|
|
622
|
-
onResponderTerminate,
|
|
623
|
-
onResponderTerminationRequest,
|
|
624
|
-
onStartShouldSetResponder,
|
|
625
|
-
pressRetentionOffset,
|
|
626
|
-
suppressHighlighting,
|
|
627
|
-
}}
|
|
628
|
-
/>
|
|
629
|
-
);
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
return (
|
|
633
|
-
<NativeVirtualText
|
|
634
|
-
{...restProps}
|
|
635
|
-
accessibilityElementsHidden={_accessibilityElementsHidden}
|
|
636
|
-
accessibilityLabel={_accessibilityLabel}
|
|
637
|
-
accessibilityRole={_accessibilityRole}
|
|
638
|
-
accessibilityState={_accessibilityState}
|
|
639
|
-
importantForAccessibility={_importantForAccessibility}
|
|
640
|
-
// #[ Win32
|
|
641
|
-
accessibilityControls={_accessibilityControls}
|
|
642
|
-
accessibilityDescribedBy={_accessibilityDescribedBy}
|
|
643
|
-
accessibilityDescription={_accessibilityDescription}
|
|
644
|
-
accessibilityLevel={_accessibilityLevel}
|
|
645
|
-
accessibilityPositionInSet={_accessibilityPositionInSet}
|
|
646
|
-
accessibilitySetSize={_accessibilitySetSize}
|
|
647
|
-
// #] Win32
|
|
648
|
-
nativeID={_nativeID}
|
|
649
|
-
numberOfLines={_numberOfLines}
|
|
650
|
-
ref={forwardedRef}
|
|
651
|
-
selectable={_selectable}
|
|
652
|
-
selectionColor={_selectionColor}
|
|
653
|
-
style={_style}
|
|
654
|
-
disabled={disabled}
|
|
655
|
-
role={_role}>
|
|
656
|
-
{children}
|
|
657
|
-
</NativeVirtualText>
|
|
658
|
-
);
|
|
659
343
|
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
textProps={{
|
|
687
|
-
...restProps,
|
|
688
|
-
accessibilityElementsHidden: _accessibilityElementsHidden,
|
|
689
|
-
accessibilityLabel: _accessibilityLabel,
|
|
690
|
-
accessibilityRole: _accessibilityRole,
|
|
691
|
-
accessibilityState: _accessibilityState,
|
|
692
|
-
accessible: _accessible,
|
|
693
|
-
allowFontScaling: allowFontScaling !== false,
|
|
694
|
-
disabled: _disabled,
|
|
695
|
-
ellipsizeMode: ellipsizeMode ?? 'tail',
|
|
696
|
-
importantForAccessibility: _importantForAccessibility,
|
|
697
|
-
nativeID: _nativeID,
|
|
698
|
-
numberOfLines: _numberOfLines,
|
|
699
|
-
selectable: _selectable,
|
|
700
|
-
selectionColor: _selectionColor,
|
|
701
|
-
style: _style,
|
|
702
|
-
role: _role,
|
|
703
|
-
children,
|
|
704
|
-
}}
|
|
705
|
-
textPressabilityProps={{
|
|
706
|
-
onLongPress,
|
|
707
|
-
onPress,
|
|
708
|
-
onPressIn,
|
|
709
|
-
onPressOut,
|
|
710
|
-
onResponderGrant,
|
|
711
|
-
onResponderMove,
|
|
712
|
-
onResponderRelease,
|
|
713
|
-
onResponderTerminate,
|
|
714
|
-
onResponderTerminationRequest,
|
|
715
|
-
onStartShouldSetResponder,
|
|
716
|
-
pressRetentionOffset,
|
|
717
|
-
suppressHighlighting,
|
|
718
|
-
}}
|
|
719
|
-
/>
|
|
720
|
-
);
|
|
721
|
-
} else {
|
|
722
|
-
nativeText = (
|
|
723
|
-
<NativeText
|
|
724
|
-
{...restProps}
|
|
725
|
-
accessibilityElementsHidden={_accessibilityElementsHidden}
|
|
726
|
-
accessibilityLabel={_accessibilityLabel}
|
|
727
|
-
accessibilityRole={_accessibilityRole}
|
|
728
|
-
accessibilityState={_accessibilityState}
|
|
729
|
-
accessible={_accessible}
|
|
730
|
-
allowFontScaling={allowFontScaling !== false}
|
|
731
|
-
disabled={_disabled}
|
|
732
|
-
ellipsizeMode={ellipsizeMode ?? 'tail'}
|
|
733
|
-
importantForAccessibility={_importantForAccessibility}
|
|
734
|
-
nativeID={_nativeID}
|
|
735
|
-
numberOfLines={_numberOfLines}
|
|
736
|
-
ref={forwardedRef}
|
|
737
|
-
selectable={_selectable}
|
|
738
|
-
selectionColor={_selectionColor}
|
|
739
|
-
style={_style}
|
|
740
|
-
role={_role}>
|
|
741
|
-
{children}
|
|
742
|
-
</NativeText>
|
|
344
|
+
return <NativeVirtualText {...processedProps} ref={forwardedRef} />;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
let nativeText = null;
|
|
348
|
+
|
|
349
|
+
processedProps.accessible = _accessible;
|
|
350
|
+
processedProps.allowFontScaling = allowFontScaling !== false;
|
|
351
|
+
processedProps.disabled = _disabled;
|
|
352
|
+
processedProps.ellipsizeMode = ellipsizeMode ?? 'tail';
|
|
353
|
+
processedProps.children = children;
|
|
354
|
+
|
|
355
|
+
if (isPressable) {
|
|
356
|
+
nativeText = (
|
|
357
|
+
<PressableText
|
|
358
|
+
ref={forwardedRef}
|
|
359
|
+
selectable={_selectable}
|
|
360
|
+
textProps={processedProps}
|
|
361
|
+
textPressabilityProps={textPressabilityProps ?? {}}
|
|
362
|
+
/>
|
|
363
|
+
);
|
|
364
|
+
} else {
|
|
365
|
+
nativeText =
|
|
366
|
+
_selectable === true ? (
|
|
367
|
+
<NativeSelectableText {...processedProps} ref={forwardedRef} />
|
|
368
|
+
) : (
|
|
369
|
+
<NativeText {...processedProps} ref={forwardedRef} />
|
|
743
370
|
);
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (children == null) {
|
|
374
|
+
return nativeText;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// If the children do not contain a JSX element it would not be possible to have a
|
|
378
|
+
// nested `Text` component so we can skip adding the `TextAncestorContext` context wrapper
|
|
379
|
+
// which has a performance overhead. Since we do this for performance reasons we need
|
|
380
|
+
// to keep the check simple to avoid regressing overall perf. For this reason the
|
|
381
|
+
// `children.length` constant is set to `3`, this should be a reasonable tradeoff
|
|
382
|
+
// to capture the majority of `Text` uses but also not make this check too expensive.
|
|
383
|
+
if (Array.isArray(children) && children.length <= 3) {
|
|
384
|
+
let hasNonTextChild = false;
|
|
385
|
+
for (let child of children) {
|
|
386
|
+
if (child != null && typeof child === 'object') {
|
|
387
|
+
hasNonTextChild = true;
|
|
388
|
+
break;
|
|
763
389
|
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
}
|
|
767
|
-
} else if (typeof children !== 'object') {
|
|
390
|
+
}
|
|
391
|
+
if (!hasNonTextChild) {
|
|
768
392
|
return nativeText;
|
|
769
393
|
}
|
|
394
|
+
} else if (typeof children !== 'object') {
|
|
395
|
+
return nativeText;
|
|
396
|
+
}
|
|
770
397
|
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
_TextImpl = TextImplLegacy;
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
const TextImpl: component(
|
|
777
|
-
ref?: React.RefSetter<TextForwardRef>,
|
|
778
|
-
...props: TextProps
|
|
779
|
-
) = _TextImpl;
|
|
398
|
+
return <TextAncestorContext value={true}>{nativeText}</TextAncestorContext>;
|
|
399
|
+
};
|
|
780
400
|
|
|
781
401
|
TextImpl.displayName = 'Text';
|
|
782
402
|
|
|
783
|
-
type TextPressabilityProps =
|
|
403
|
+
type TextPressabilityProps = Readonly<{
|
|
784
404
|
onLongPress?: ?(event: GestureResponderEvent) => unknown,
|
|
785
405
|
onPress?: ?(event: GestureResponderEvent) => unknown,
|
|
786
406
|
onPressIn?: ?(event: GestureResponderEvent) => unknown,
|
|
@@ -914,28 +534,17 @@ function useTextPressability({
|
|
|
914
534
|
);
|
|
915
535
|
}
|
|
916
536
|
|
|
917
|
-
type NativePressableTextProps = $ReadOnly<{
|
|
918
|
-
textProps: NativeTextProps,
|
|
919
|
-
textPressabilityProps: TextPressabilityProps,
|
|
920
|
-
}>;
|
|
921
|
-
|
|
922
537
|
/**
|
|
923
538
|
* Wrap the NativeVirtualText component and initialize pressability.
|
|
924
539
|
*
|
|
925
540
|
* This logic is split out from the main Text component to enable the more
|
|
926
541
|
* expensive pressability logic to be only initialized when needed.
|
|
927
542
|
*/
|
|
928
|
-
|
|
929
|
-
ref: React.RefSetter<TextForwardRef>,
|
|
930
|
-
...props: NativePressableTextProps
|
|
931
|
-
) = ({
|
|
932
|
-
ref: forwardedRef,
|
|
933
|
-
textProps,
|
|
934
|
-
textPressabilityProps,
|
|
935
|
-
}: {
|
|
543
|
+
component PressableVirtualText(
|
|
936
544
|
ref?: React.RefSetter<TextForwardRef>,
|
|
937
|
-
|
|
938
|
-
|
|
545
|
+
textProps: NativeTextProps,
|
|
546
|
+
textPressabilityProps: TextPressabilityProps,
|
|
547
|
+
) {
|
|
939
548
|
const [isHighlighted, eventHandlersForText] = useTextPressability(
|
|
940
549
|
textPressabilityProps,
|
|
941
550
|
);
|
|
@@ -946,42 +555,40 @@ const NativePressableVirtualText: component(
|
|
|
946
555
|
{...eventHandlersForText}
|
|
947
556
|
isHighlighted={isHighlighted}
|
|
948
557
|
isPressable={true}
|
|
949
|
-
ref={
|
|
558
|
+
ref={ref}
|
|
950
559
|
/>
|
|
951
560
|
);
|
|
952
|
-
}
|
|
561
|
+
}
|
|
953
562
|
|
|
954
563
|
/**
|
|
955
|
-
* Wrap
|
|
564
|
+
* Wrap a NativeText component and initialize pressability.
|
|
956
565
|
*
|
|
957
566
|
* This logic is split out from the main Text component to enable the more
|
|
958
567
|
* expensive pressability logic to be only initialized when needed.
|
|
959
568
|
*/
|
|
960
|
-
|
|
961
|
-
ref: React.RefSetter<TextForwardRef>,
|
|
962
|
-
...props: NativePressableTextProps
|
|
963
|
-
) = ({
|
|
964
|
-
ref: forwardedRef,
|
|
965
|
-
textProps,
|
|
966
|
-
textPressabilityProps,
|
|
967
|
-
}: {
|
|
569
|
+
component PressableText(
|
|
968
570
|
ref?: React.RefSetter<TextForwardRef>,
|
|
969
|
-
|
|
970
|
-
|
|
571
|
+
selectable?: ?boolean,
|
|
572
|
+
textProps: NativeTextProps,
|
|
573
|
+
textPressabilityProps: TextPressabilityProps,
|
|
574
|
+
) {
|
|
971
575
|
const [isHighlighted, eventHandlersForText] = useTextPressability(
|
|
972
576
|
textPressabilityProps,
|
|
973
577
|
);
|
|
974
578
|
|
|
579
|
+
const NativeComponent =
|
|
580
|
+
selectable === true ? NativeSelectableText : NativeText;
|
|
581
|
+
|
|
975
582
|
return (
|
|
976
|
-
<
|
|
583
|
+
<NativeComponent
|
|
977
584
|
{...textProps}
|
|
978
585
|
{...eventHandlersForText}
|
|
979
586
|
isHighlighted={isHighlighted}
|
|
980
587
|
isPressable={true}
|
|
981
|
-
ref={
|
|
588
|
+
ref={ref}
|
|
982
589
|
/>
|
|
983
590
|
);
|
|
984
|
-
}
|
|
591
|
+
}
|
|
985
592
|
|
|
986
593
|
const userSelectToSelectableMap = {
|
|
987
594
|
auto: true,
|
|
@@ -998,4 +605,13 @@ const verticalAlignToTextAlignVerticalMap = {
|
|
|
998
605
|
middle: 'center',
|
|
999
606
|
} as const;
|
|
1000
607
|
|
|
608
|
+
const styles = StyleSheet.create({
|
|
609
|
+
// Native components have historically acted like overflow: 'hidden'. We set
|
|
610
|
+
// this, as part of the default style, to let client differentiate with
|
|
611
|
+
// overflow: 'visible'.
|
|
612
|
+
default: {
|
|
613
|
+
overflow: 'hidden',
|
|
614
|
+
},
|
|
615
|
+
});
|
|
616
|
+
|
|
1001
617
|
export default TextImpl;
|