react-native-windows 0.75.4 → 0.76.0-preview.2
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 +6 -4
- package/Directory.Build.props +4 -0
- package/Directory.Build.targets +5 -0
- package/Libraries/Alert/Alert.js +3 -0
- package/Libraries/Alert/Alert.windows.js +3 -0
- package/Libraries/Animated/AnimatedEvent.js +1 -1
- package/Libraries/Animated/AnimatedImplementation.js +7 -7
- package/Libraries/Animated/NativeAnimatedAllowlist.js +111 -0
- package/Libraries/Animated/animations/Animation.js +11 -1
- package/Libraries/Animated/animations/DecayAnimation.js +1 -1
- package/Libraries/Animated/animations/SpringAnimation.js +1 -1
- package/Libraries/Animated/animations/TimingAnimation.js +2 -1
- package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
- package/Libraries/Animated/createAnimatedComponent.js +10 -9
- package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +3 -2
- package/Libraries/Animated/nodes/AnimatedNode.js +42 -33
- package/Libraries/Animated/nodes/AnimatedObject.js +56 -50
- package/Libraries/Animated/nodes/AnimatedProps.js +77 -40
- package/Libraries/Animated/nodes/AnimatedStyle.js +103 -59
- package/Libraries/Animated/nodes/AnimatedTracking.js +1 -1
- package/Libraries/Animated/nodes/AnimatedTransform.js +102 -67
- package/Libraries/Animated/nodes/AnimatedValue.js +2 -1
- package/Libraries/Animated/nodes/AnimatedWithChildren.js +21 -22
- package/Libraries/Animated/useAnimatedProps.js +142 -7
- package/Libraries/BatchedBridge/NativeModules.js +2 -0
- package/Libraries/Blob/FileReader.js +1 -1
- package/Libraries/Blob/URL.js +2 -62
- package/Libraries/Blob/URLSearchParams.js +71 -0
- package/Libraries/Components/Button.windows.js +0 -1
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -1
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +17 -0
- package/Libraries/Components/Keyboard/KeyboardExt.js.map +1 -1
- package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +1 -1
- package/Libraries/Components/ScrollView/ScrollView.js +131 -169
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +3 -0
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.windows.js +3 -0
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
- package/Libraries/Components/StatusBar/StatusBar.js +3 -1
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +10 -0
- package/Libraries/Components/TextInput/TextInput.d.ts +32 -2
- package/Libraries/Components/TextInput/TextInput.js +230 -94
- package/Libraries/Components/TextInput/TextInput.windows.js +230 -105
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +23 -1
- package/Libraries/Components/View/ReactNativeViewAttributes.js +2 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.windows.js +2 -0
- package/Libraries/Components/View/View.windows.js +32 -30
- package/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
- package/Libraries/Components/View/ViewNativeComponent.js +0 -1
- package/Libraries/Components/View/ViewPropTypes.js +14 -0
- package/Libraries/Components/View/ViewPropTypes.windows.js +14 -0
- package/Libraries/Core/ExceptionsManager.js +2 -0
- package/Libraries/Core/InitializeCore.js +3 -1
- package/Libraries/Core/ReactFiberErrorDialog.js +3 -0
- package/Libraries/Core/ReactNativeVersion.js +4 -4
- package/Libraries/Core/setUpDeveloperTools.js +5 -1
- package/Libraries/Core/setUpErrorHandling.js +7 -1
- package/Libraries/Core/setUpGlobals.js +1 -0
- package/Libraries/Core/setUpReactRefresh.js +0 -4
- package/Libraries/Image/AssetSourceResolver.js +28 -1
- package/Libraries/Image/AssetSourceResolver.windows.js +28 -1
- package/Libraries/Image/Image.android.js +9 -14
- package/Libraries/Image/Image.ios.js +11 -22
- package/Libraries/Image/Image.windows.js +11 -22
- package/Libraries/Image/ImageBackground.js +1 -8
- package/Libraries/Image/ImageUtils.js +9 -9
- package/Libraries/Image/ImageViewNativeComponent.js +1 -0
- package/Libraries/Inspector/Inspector.js +3 -2
- package/Libraries/Inspector/InspectorPanel.js +16 -10
- package/Libraries/Inspector/NetworkOverlay.js +1 -1
- package/Libraries/Interaction/TaskQueue.js +1 -0
- package/Libraries/Lists/FlatList.js +1 -1
- package/Libraries/Lists/SectionList.js +2 -2
- package/Libraries/Lists/SectionListModern.js +3 -3
- package/Libraries/LogBox/Data/LogBoxData.js +24 -3
- package/Libraries/LogBox/LogBoxNotificationContainer.js +3 -2
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +9 -8
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.windows.js +9 -8
- package/Libraries/Modal/Modal.js +0 -1
- package/Libraries/NativeComponent/BaseViewConfig.android.js +9 -1
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +17 -1
- package/Libraries/NativeComponent/BaseViewConfig.windows.js +17 -1
- package/Libraries/NativeComponent/NativeComponentRegistry.js +22 -22
- package/Libraries/NativeComponent/StaticViewConfigValidator.js +0 -21
- package/Libraries/Network/XMLHttpRequest.js +4 -2
- package/Libraries/ReactNative/AppContainer-dev.js +1 -5
- package/Libraries/ReactNative/AppContainer-prod.js +1 -5
- package/Libraries/ReactNative/AppContainer.js +1 -2
- package/Libraries/ReactNative/AppRegistry.d.ts +0 -4
- package/Libraries/ReactNative/AppRegistry.js +1 -7
- package/Libraries/ReactNative/BridgelessUIManager.js +1 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +1 -1
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +5 -5
- package/Libraries/ReactNative/RendererImplementation.js +26 -4
- package/Libraries/ReactNative/getNativeComponentAttributes.js +12 -0
- package/Libraries/ReactNative/renderApplication.js +1 -3
- package/Libraries/Renderer/shims/ReactNativeTypes.js +11 -4
- package/Libraries/StyleSheet/StyleSheet.js +1 -1
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +152 -2
- package/Libraries/StyleSheet/StyleSheetTypes.js +60 -5
- package/Libraries/StyleSheet/processBackgroundImage.js +384 -0
- package/Libraries/StyleSheet/processBoxShadow.js +209 -0
- package/Libraries/StyleSheet/processFilter.js +231 -42
- package/Libraries/Text/Text.js +394 -196
- package/Libraries/Text/Text.windows.js +476 -300
- package/Libraries/Text/TextNativeComponent.js +2 -1
- package/Libraries/TurboModule/TurboModuleRegistry.js +13 -50
- package/Libraries/Types/CodegenTypes.js +3 -1
- package/Libraries/Utilities/Appearance.js +108 -84
- package/Libraries/Utilities/DevLoadingView.js +2 -4
- package/Libraries/Utilities/HMRClient.js +8 -6
- package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
- package/Libraries/Utilities/createPerformanceLogger.js +0 -9
- package/Libraries/Utilities/stringifyViewConfig.js +22 -0
- package/Libraries/Utilities/useColorScheme.js +3 -3
- package/Libraries/WebSocket/WebSocket.js +1 -1
- package/Libraries/promiseRejectionTrackingOptions.js +1 -1
- package/Libraries/vendor/emitter/EventEmitter.js +6 -5
- package/Microsoft.ReactNative/ComponentView.idl +11 -0
- package/Microsoft.ReactNative/Composition.Input.idl +1 -0
- package/Microsoft.ReactNative/CompositionSwitcher.idl +3 -0
- package/Microsoft.ReactNative/Fabric/AbiComponentDescriptor.cpp +9 -9
- package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +9 -9
- package/Microsoft.ReactNative/Fabric/ComponentView.cpp +7 -9
- package/Microsoft.ReactNative/Fabric/ComponentView.h +5 -6
- package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +4 -0
- package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +44 -13
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +42 -5
- package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +81 -63
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +2 -3
- package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +8 -6
- package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.h +1 -2
- package/Microsoft.ReactNative/Fabric/Composition/FocusManager.cpp +20 -6
- package/Microsoft.ReactNative/Fabric/Composition/FocusManager.h +13 -6
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +2 -3
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +1 -2
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +72 -54
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +14 -4
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +26 -8
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +5 -2
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +18 -7
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +1 -2
- package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +6 -6
- package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.h +1 -2
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +97 -140
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +8 -4
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +18 -11
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h +5 -4
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.cpp +0 -13
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.h +0 -3
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +29 -4
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +2 -0
- package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +1 -2
- package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.h +1 -2
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +28 -12
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h +33 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +26 -9
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h +10 -4
- package/Microsoft.ReactNative/IReactModuleBuilder.cpp +5 -0
- package/Microsoft.ReactNative/IReactModuleBuilder.h +1 -0
- package/Microsoft.ReactNative/IReactModuleBuilder.idl +9 -0
- package/Microsoft.ReactNative/IReactViewComponentBuilder.idl +8 -1
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +2 -0
- package/Microsoft.ReactNative/Modules/AlertModule.cpp +3 -1
- package/Microsoft.ReactNative/Modules/AppearanceModule.cpp +1 -1
- package/Microsoft.ReactNative/Modules/AppearanceModule.h +7 -1
- package/Microsoft.ReactNative/Modules/DevSettingsModule.cpp +3 -3
- package/Microsoft.ReactNative/Modules/DevSettingsModule.h +1 -1
- package/Microsoft.ReactNative/Modules/LinkingManagerModule.cpp +2 -2
- package/Microsoft.ReactNative/Modules/LinkingManagerModule.h +1 -1
- package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +9 -0
- package/Microsoft.ReactNative/Modules/LogBoxModule.h +2 -0
- package/Microsoft.ReactNative/Modules/SampleTurboModule.cpp +121 -0
- package/Microsoft.ReactNative/Modules/SampleTurboModule.h +90 -0
- package/Microsoft.ReactNative/ReactHost/MsoReactContext.cpp +0 -7
- package/Microsoft.ReactNative/ReactHost/MsoReactContext.h +0 -5
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +5 -1
- package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.cpp +59 -0
- package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.h +23 -0
- package/Microsoft.ReactNative/ReactNativeAppBuilder.cpp +179 -0
- package/Microsoft.ReactNative/ReactNativeAppBuilder.h +35 -0
- package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +69 -0
- package/Microsoft.ReactNative/ReactNativeIsland.idl +2 -0
- package/Microsoft.ReactNative/ReactNativeWin32App.cpp +82 -0
- package/Microsoft.ReactNative/ReactNativeWin32App.h +38 -0
- package/Microsoft.ReactNative/TurboModulesProvider.cpp +45 -0
- package/Microsoft.ReactNative/Views/DynamicAutomationPeer.cpp +2 -1
- package/Microsoft.ReactNative/Views/FlyoutViewManager.cpp +25 -16
- package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +3 -4
- package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +3 -0
- package/Microsoft.ReactNative.Cxx/ModuleRegistration.cpp +2 -2
- package/Microsoft.ReactNative.Cxx/ModuleRegistration.h +62 -4
- package/Microsoft.ReactNative.Cxx/NativeModules.h +131 -14
- package/Microsoft.ReactNative.Managed.CodeGen/ReactNativeNames.cs +10 -2
- package/PropertySheets/Autolink.props +1 -1
- package/PropertySheets/Bundle.props +1 -1
- package/PropertySheets/Codegen.props +1 -1
- package/PropertySheets/Generated/PackageVersion.g.props +4 -4
- package/PropertySheets/NuGet.LockFile.props +18 -0
- package/README.md +29 -29
- package/ReactCommon/ReactCommon.vcxproj +5 -1
- package/ReactCommon/ReactCommon.vcxproj.filters +11 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +2 -7
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +441 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +266 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/Utf8.h +56 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Base.h +3 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Bridging.h +2 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/CallbackWrapper.h +1 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Convert.h +172 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/EventEmitter.h +4 -5
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Function.h +2 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +1 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModuleUtils.h +3 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/scrollview/ScrollViewProps.cpp +9 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/LayoutableShadowNode.cpp +363 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/JSRuntimeFactory.h +22 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +118 -51
- package/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 +8 -1
- package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +2 -2
- package/Shared/Modules/WebSocketModule.cpp +1 -2
- package/Shared/Networking/WinRTWebSocketResource.cpp +4 -1
- package/Shared/Shared.vcxitems +38 -2
- package/Shared/Shared.vcxitems.filters +6 -1
- package/Shared/TurboModuleManager.cpp +0 -3
- package/codegen/NativeLinkingManagerSpec.g.h +3 -3
- package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +198 -54
- package/codegen/NativeSampleTurboModuleSpec.g.h +35 -0
- package/codegen/rnwcoreJSI-generated.cpp +245 -101
- package/codegen/rnwcoreJSI.h +847 -548
- package/index.js +3 -1
- package/index.windows.js +3 -1
- package/jest/mockComponent.js +4 -1
- package/jest/mockModal.js +1 -3
- package/jest/mockScrollView.js +1 -1
- package/jest/renderer.js +2 -2
- package/jest/setup.js +16 -13
- package/package.json +34 -30
- package/src/private/animated/NativeAnimatedHelper.js +438 -0
- package/src/private/animated/NativeAnimatedValidation.js +64 -0
- package/src/private/components/HScrollViewNativeComponents.js +56 -0
- package/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js +29 -0
- package/src/private/components/VScrollViewNativeComponents.js +48 -0
- package/src/private/components/useSyncOnScroll.js +48 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +166 -16
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +29 -5
- package/src/private/fusebox/FuseboxSessionObserver.js +42 -0
- package/{Libraries/Core → src/private/renderer/errorhandling}/ErrorHandlers.js +14 -4
- package/src/private/setup/setUpDOM.js +28 -0
- package/src/private/setup/setUpIntersectionObserver.js +27 -0
- package/src/private/setup/setUpMutationObserver.js +26 -0
- package/src/private/setup/setUpPerformanceObserver.js +64 -0
- package/src/private/specs/modules/NativeAppearance.js +3 -3
- package/src/private/specs/modules/NativeLinkingManager.js +1 -1
- package/src/private/specs/modules/NativePlatformConstantsWindows.js +7 -0
- package/src/private/specs/modules/NativeSampleTurboModule.js +14 -1
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +6 -4
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserver.js +5 -3
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverEntry.js +3 -3
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverManager.js +14 -17
- package/src/private/{specs/modules → webapis/intersectionobserver/specs}/NativeIntersectionObserver.js +2 -2
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver/specs}/__mocks__/NativeIntersectionObserver.js +4 -4
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserver.js +5 -3
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserverManager.js +24 -15
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationRecord.js +4 -6
- package/src/private/{specs/modules → webapis/mutationobserver/specs}/NativeMutationObserver.js +2 -2
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver/specs}/__mocks__/NativeMutationObserver.js +5 -5
- package/src/private/webapis/performance/{EventCounts.js → EventTiming.js} +65 -3
- package/src/private/webapis/performance/LongTasks.js +39 -0
- package/src/private/webapis/performance/Performance.js +22 -9
- package/src/private/webapis/performance/PerformanceEntry.js +36 -18
- package/src/private/webapis/performance/PerformanceObserver.js +29 -43
- package/src/private/webapis/performance/RawPerformanceEntry.js +24 -1
- package/src/private/webapis/performance/UserTiming.js +17 -12
- package/src/private/webapis/performance/specs/NativePerformanceObserver.js +1 -1
- package/template/cpp-app/src/AutolinkedNativeModules.g.cpp +1 -1
- package/template/cpp-app/src/AutolinkedNativeModules.g.h +1 -1
- package/template/cs-app/src/AutolinkedNativeModules.g.cs +1 -1
- package/template/index.windows.bundle +1 -1
- package/template/metro.config.js +2 -2
- package/template/shared-app/src/AutolinkedNativeModules.g.props +1 -1
- package/template/shared-app/src/AutolinkedNativeModules.g.targets +1 -1
- package/templates/cpp-app/metro.config.js +2 -2
- package/templates/cpp-app/template.config.js +5 -5
- package/templates/cpp-app/windows/MyApp/AutolinkedNativeModules.g.cpp +1 -1
- package/templates/cpp-app/windows/MyApp/AutolinkedNativeModules.g.h +1 -1
- package/templates/cpp-app/windows/MyApp/MyApp.cpp +2 -0
- package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +1 -1
- package/templates/cpp-lib/example/metro.config.js +2 -2
- package/templates/cpp-lib/template.config.js +3 -3
- package/templates/cpp-lib/windows/MyLib/MyLib.h +3 -3
- package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +1 -1
- package/types/experimental.d.ts +12 -98
- package/Common/packages.lock.json +0 -26
- package/Folly/packages.lock.json +0 -23
- package/Libraries/Animated/NativeAnimatedHelper.js +0 -615
- package/Libraries/Core/setUpIntersectionObserver.js +0 -16
- package/Libraries/Core/setUpMutationObserver.js +0 -16
- package/Libraries/Core/setUpPerformanceObserver.js +0 -18
- package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +0 -13
- package/Libraries/MutationObserver/NativeMutationObserver.js +0 -13
- package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +0 -135
- package/Microsoft.ReactNative/packages.lock.json +0 -132
- package/Microsoft.ReactNative.Managed/packages.lock.json +0 -373
- package/Microsoft.ReactNative.Managed.CodeGen/packages.lock.json +0 -3197
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/algorithm/CalculateLayout.cpp +0 -2396
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/config/Config.cpp +0 -136
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/config/Config.h +0 -92
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/LayoutResults.cpp +0 -48
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/LayoutResults.h +0 -122
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/Node.cpp +0 -388
- package/ReactCommon/packages.lock.json +0 -30
- package/fmt/packages.lock.json +0 -13
- package/src/private/core/setUpDOM.js +0 -18
- package/src/private/webapis/performance/PerformanceEventTiming.js +0 -55
- /package/src/private/{core → styles}/composeStyles.js +0 -0
package/Libraries/Text/Text.js
CHANGED
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import type {TextStyleProp} from '../StyleSheet/StyleSheet';
|
|
12
|
+
import type {____TextStyle_Internal as TextStyleInternal} from '../StyleSheet/StyleSheetTypes';
|
|
11
13
|
import type {PressEvent} from '../Types/CoreEventTypes';
|
|
12
|
-
import type {
|
|
14
|
+
import type {NativeTextProps} from './TextNativeComponent';
|
|
15
|
+
import type {PressRetentionOffset, TextProps} from './TextProps';
|
|
13
16
|
|
|
14
17
|
import * as PressabilityDebug from '../Pressability/PressabilityDebug';
|
|
15
18
|
import usePressability from '../Pressability/usePressability';
|
|
@@ -21,96 +24,351 @@ import {NativeText, NativeVirtualText} from './TextNativeComponent';
|
|
|
21
24
|
import * as React from 'react';
|
|
22
25
|
import {useContext, useMemo, useState} from 'react';
|
|
23
26
|
|
|
27
|
+
type TextForwardRef = React.ElementRef<
|
|
28
|
+
typeof NativeText | typeof NativeVirtualText,
|
|
29
|
+
>;
|
|
30
|
+
|
|
24
31
|
/**
|
|
25
32
|
* Text is the fundamental component for displaying text.
|
|
26
33
|
*
|
|
27
34
|
* @see https://reactnative.dev/docs/text
|
|
28
35
|
*/
|
|
29
|
-
const Text: React.AbstractComponent<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
36
|
+
const Text: React.AbstractComponent<TextProps, TextForwardRef> =
|
|
37
|
+
React.forwardRef(
|
|
38
|
+
(
|
|
39
|
+
{
|
|
40
|
+
accessible,
|
|
41
|
+
accessibilityLabel,
|
|
42
|
+
accessibilityState,
|
|
43
|
+
allowFontScaling,
|
|
44
|
+
'aria-busy': ariaBusy,
|
|
45
|
+
'aria-checked': ariaChecked,
|
|
46
|
+
'aria-disabled': ariaDisabled,
|
|
47
|
+
'aria-expanded': ariaExpanded,
|
|
48
|
+
'aria-label': ariaLabel,
|
|
49
|
+
'aria-selected': ariaSelected,
|
|
50
|
+
children,
|
|
51
|
+
ellipsizeMode,
|
|
52
|
+
disabled,
|
|
53
|
+
id,
|
|
54
|
+
nativeID,
|
|
55
|
+
numberOfLines,
|
|
56
|
+
onLongPress,
|
|
57
|
+
onPress,
|
|
58
|
+
onPressIn,
|
|
59
|
+
onPressOut,
|
|
60
|
+
onResponderGrant,
|
|
61
|
+
onResponderMove,
|
|
62
|
+
onResponderRelease,
|
|
63
|
+
onResponderTerminate,
|
|
64
|
+
onResponderTerminationRequest,
|
|
65
|
+
onStartShouldSetResponder,
|
|
66
|
+
pressRetentionOffset,
|
|
67
|
+
selectable,
|
|
68
|
+
selectionColor,
|
|
69
|
+
suppressHighlighting,
|
|
70
|
+
style,
|
|
71
|
+
...restProps
|
|
72
|
+
}: TextProps,
|
|
73
|
+
forwardedRef,
|
|
74
|
+
) => {
|
|
75
|
+
const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
|
|
66
76
|
|
|
67
|
-
|
|
77
|
+
let _accessibilityState: ?TextProps['accessibilityState'] =
|
|
78
|
+
accessibilityState;
|
|
79
|
+
if (
|
|
80
|
+
ariaBusy != null ||
|
|
81
|
+
ariaChecked != null ||
|
|
82
|
+
ariaDisabled != null ||
|
|
83
|
+
ariaExpanded != null ||
|
|
84
|
+
ariaSelected != null
|
|
85
|
+
) {
|
|
86
|
+
if (_accessibilityState != null) {
|
|
87
|
+
_accessibilityState = {
|
|
88
|
+
busy: ariaBusy ?? _accessibilityState.busy,
|
|
89
|
+
checked: ariaChecked ?? _accessibilityState.checked,
|
|
90
|
+
disabled: ariaDisabled ?? _accessibilityState.disabled,
|
|
91
|
+
expanded: ariaExpanded ?? _accessibilityState.expanded,
|
|
92
|
+
selected: ariaSelected ?? _accessibilityState.selected,
|
|
93
|
+
};
|
|
94
|
+
} else {
|
|
95
|
+
_accessibilityState = {
|
|
96
|
+
busy: ariaBusy,
|
|
97
|
+
checked: ariaChecked,
|
|
98
|
+
disabled: ariaDisabled,
|
|
99
|
+
expanded: ariaExpanded,
|
|
100
|
+
selected: ariaSelected,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
68
104
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
let _accessibilityState: ?TextProps['accessibilityState'] =
|
|
72
|
-
accessibilityState;
|
|
73
|
-
if (
|
|
74
|
-
ariaBusy != null ||
|
|
75
|
-
ariaChecked != null ||
|
|
76
|
-
ariaDisabled != null ||
|
|
77
|
-
ariaExpanded != null ||
|
|
78
|
-
ariaSelected != null
|
|
79
|
-
) {
|
|
80
|
-
if (_accessibilityState != null) {
|
|
81
|
-
_accessibilityState = {
|
|
82
|
-
busy: ariaBusy ?? _accessibilityState.busy,
|
|
83
|
-
checked: ariaChecked ?? _accessibilityState.checked,
|
|
84
|
-
disabled: ariaDisabled ?? _accessibilityState.disabled,
|
|
85
|
-
expanded: ariaExpanded ?? _accessibilityState.expanded,
|
|
86
|
-
selected: ariaSelected ?? _accessibilityState.selected,
|
|
87
|
-
};
|
|
88
|
-
} else {
|
|
89
|
-
_accessibilityState = {
|
|
90
|
-
busy: ariaBusy,
|
|
91
|
-
checked: ariaChecked,
|
|
92
|
-
disabled: ariaDisabled,
|
|
93
|
-
expanded: ariaExpanded,
|
|
94
|
-
selected: ariaSelected,
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
}
|
|
105
|
+
const _accessibilityStateDisabled = _accessibilityState?.disabled;
|
|
106
|
+
const _disabled = disabled ?? _accessibilityStateDisabled;
|
|
98
107
|
|
|
99
|
-
|
|
100
|
-
|
|
108
|
+
const isPressable =
|
|
109
|
+
(onPress != null ||
|
|
110
|
+
onLongPress != null ||
|
|
111
|
+
onStartShouldSetResponder != null) &&
|
|
112
|
+
_disabled !== true;
|
|
101
113
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
onStartShouldSetResponder != null) &&
|
|
106
|
-
_disabled !== true;
|
|
114
|
+
// TODO: Move this processing to the view configuration.
|
|
115
|
+
const _selectionColor =
|
|
116
|
+
selectionColor == null ? null : processColor(selectionColor);
|
|
107
117
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
118
|
+
let _style = style;
|
|
119
|
+
if (__DEV__) {
|
|
120
|
+
if (PressabilityDebug.isEnabled() && onPress != null) {
|
|
121
|
+
_style = [style, {color: 'magenta'}];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
let _numberOfLines = numberOfLines;
|
|
126
|
+
if (_numberOfLines != null && !(_numberOfLines >= 0)) {
|
|
127
|
+
if (__DEV__) {
|
|
128
|
+
console.error(
|
|
129
|
+
`'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
_numberOfLines = 0;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let _selectable = selectable;
|
|
136
|
+
|
|
137
|
+
let processedStyle = flattenStyle<TextStyleProp>(_style);
|
|
138
|
+
if (processedStyle != null) {
|
|
139
|
+
let overrides: ?{...TextStyleInternal} = null;
|
|
140
|
+
if (typeof processedStyle.fontWeight === 'number') {
|
|
141
|
+
overrides = overrides || ({}: {...TextStyleInternal});
|
|
142
|
+
overrides.fontWeight =
|
|
143
|
+
// $FlowFixMe[incompatible-cast]
|
|
144
|
+
(processedStyle.fontWeight.toString(): TextStyleInternal['fontWeight']);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (processedStyle.userSelect != null) {
|
|
148
|
+
_selectable = userSelectToSelectableMap[processedStyle.userSelect];
|
|
149
|
+
overrides = overrides || ({}: {...TextStyleInternal});
|
|
150
|
+
overrides.userSelect = undefined;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (processedStyle.verticalAlign != null) {
|
|
154
|
+
overrides = overrides || ({}: {...TextStyleInternal});
|
|
155
|
+
overrides.textAlignVertical =
|
|
156
|
+
verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
|
|
157
|
+
overrides.verticalAlign = undefined;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (overrides != null) {
|
|
161
|
+
// $FlowFixMe[incompatible-type]
|
|
162
|
+
_style = [_style, overrides];
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const _nativeID = id ?? nativeID;
|
|
167
|
+
|
|
168
|
+
const hasTextAncestor = useContext(TextAncestor);
|
|
169
|
+
if (hasTextAncestor) {
|
|
170
|
+
if (isPressable) {
|
|
171
|
+
return (
|
|
172
|
+
<NativePressableVirtualText
|
|
173
|
+
ref={forwardedRef}
|
|
174
|
+
textProps={{
|
|
175
|
+
...restProps,
|
|
176
|
+
accessibilityLabel: _accessibilityLabel,
|
|
177
|
+
accessibilityState: _accessibilityState,
|
|
178
|
+
nativeID: _nativeID,
|
|
179
|
+
numberOfLines: _numberOfLines,
|
|
180
|
+
selectable: _selectable,
|
|
181
|
+
selectionColor: _selectionColor,
|
|
182
|
+
style: _style,
|
|
183
|
+
disabled: disabled,
|
|
184
|
+
children,
|
|
185
|
+
}}
|
|
186
|
+
textPressabilityProps={{
|
|
187
|
+
onLongPress,
|
|
188
|
+
onPress,
|
|
189
|
+
onPressIn,
|
|
190
|
+
onPressOut,
|
|
191
|
+
onResponderGrant,
|
|
192
|
+
onResponderMove,
|
|
193
|
+
onResponderRelease,
|
|
194
|
+
onResponderTerminate,
|
|
195
|
+
onResponderTerminationRequest,
|
|
196
|
+
onStartShouldSetResponder,
|
|
197
|
+
pressRetentionOffset,
|
|
198
|
+
suppressHighlighting,
|
|
199
|
+
}}
|
|
200
|
+
/>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return (
|
|
205
|
+
<NativeVirtualText
|
|
206
|
+
{...restProps}
|
|
207
|
+
accessibilityLabel={_accessibilityLabel}
|
|
208
|
+
accessibilityState={_accessibilityState}
|
|
209
|
+
isHighlighted={false}
|
|
210
|
+
isPressable={false}
|
|
211
|
+
nativeID={_nativeID}
|
|
212
|
+
numberOfLines={_numberOfLines}
|
|
213
|
+
ref={forwardedRef}
|
|
214
|
+
selectable={_selectable}
|
|
215
|
+
selectionColor={_selectionColor}
|
|
216
|
+
style={_style}
|
|
217
|
+
disabled={disabled}>
|
|
218
|
+
{children}
|
|
219
|
+
</NativeVirtualText>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// If the disabled prop and accessibilityState.disabled are out of sync but not both in
|
|
224
|
+
// falsy states we need to update the accessibilityState object to use the disabled prop.
|
|
225
|
+
if (
|
|
226
|
+
_disabled !== _accessibilityStateDisabled &&
|
|
227
|
+
((_disabled != null && _disabled !== false) ||
|
|
228
|
+
(_accessibilityStateDisabled != null &&
|
|
229
|
+
_accessibilityStateDisabled !== false))
|
|
230
|
+
) {
|
|
231
|
+
_accessibilityState = {..._accessibilityState, disabled: _disabled};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const _accessible = Platform.select({
|
|
235
|
+
ios: accessible !== false,
|
|
236
|
+
android:
|
|
237
|
+
accessible == null
|
|
238
|
+
? onPress != null || onLongPress != null
|
|
239
|
+
: accessible,
|
|
240
|
+
default: accessible,
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
let nativeText = null;
|
|
244
|
+
if (isPressable) {
|
|
245
|
+
nativeText = (
|
|
246
|
+
<NativePressableText
|
|
247
|
+
ref={forwardedRef}
|
|
248
|
+
textProps={{
|
|
249
|
+
...restProps,
|
|
250
|
+
accessibilityLabel: _accessibilityLabel,
|
|
251
|
+
accessibilityState: _accessibilityState,
|
|
252
|
+
accessible: _accessible,
|
|
253
|
+
allowFontScaling: allowFontScaling !== false,
|
|
254
|
+
disabled: _disabled,
|
|
255
|
+
ellipsizeMode: ellipsizeMode ?? 'tail',
|
|
256
|
+
nativeID: _nativeID,
|
|
257
|
+
numberOfLines: _numberOfLines,
|
|
258
|
+
selectable: _selectable,
|
|
259
|
+
selectionColor: _selectionColor,
|
|
260
|
+
style: _style,
|
|
261
|
+
children,
|
|
262
|
+
}}
|
|
263
|
+
textPressabilityProps={{
|
|
264
|
+
onLongPress,
|
|
265
|
+
onPress,
|
|
266
|
+
onPressIn,
|
|
267
|
+
onPressOut,
|
|
268
|
+
onResponderGrant,
|
|
269
|
+
onResponderMove,
|
|
270
|
+
onResponderRelease,
|
|
271
|
+
onResponderTerminate,
|
|
272
|
+
onResponderTerminationRequest,
|
|
273
|
+
onStartShouldSetResponder,
|
|
274
|
+
pressRetentionOffset,
|
|
275
|
+
suppressHighlighting,
|
|
276
|
+
}}
|
|
277
|
+
/>
|
|
278
|
+
);
|
|
279
|
+
} else {
|
|
280
|
+
nativeText = (
|
|
281
|
+
<NativeText
|
|
282
|
+
{...restProps}
|
|
283
|
+
accessibilityLabel={_accessibilityLabel}
|
|
284
|
+
accessibilityState={_accessibilityState}
|
|
285
|
+
accessible={_accessible}
|
|
286
|
+
allowFontScaling={allowFontScaling !== false}
|
|
287
|
+
disabled={_disabled}
|
|
288
|
+
ellipsizeMode={ellipsizeMode ?? 'tail'}
|
|
289
|
+
isHighlighted={false}
|
|
290
|
+
nativeID={_nativeID}
|
|
291
|
+
numberOfLines={_numberOfLines}
|
|
292
|
+
ref={forwardedRef}
|
|
293
|
+
selectable={_selectable}
|
|
294
|
+
selectionColor={_selectionColor}
|
|
295
|
+
style={_style}>
|
|
296
|
+
{children}
|
|
297
|
+
</NativeText>
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (children == null) {
|
|
302
|
+
return nativeText;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// If the children do not contain a JSX element it would not be possible to have a
|
|
306
|
+
// nested `Text` component so we can skip adding the `TextAncestor` context wrapper
|
|
307
|
+
// which has a performance overhead. Since we do this for performance reasons we need
|
|
308
|
+
// to keep the check simple to avoid regressing overall perf. For this reason the
|
|
309
|
+
// `children.length` constant is set to `3`, this should be a reasonable tradeoff
|
|
310
|
+
// to capture the majority of `Text` uses but also not make this check too expensive.
|
|
311
|
+
if (Array.isArray(children) && children.length <= 3) {
|
|
312
|
+
let hasNonTextChild = false;
|
|
313
|
+
for (let child of children) {
|
|
314
|
+
if (child != null && typeof child === 'object') {
|
|
315
|
+
hasNonTextChild = true;
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (!hasNonTextChild) {
|
|
320
|
+
return nativeText;
|
|
321
|
+
}
|
|
322
|
+
} else if (typeof children !== 'object') {
|
|
323
|
+
return nativeText;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return (
|
|
327
|
+
<TextAncestor.Provider value={true}>{nativeText}</TextAncestor.Provider>
|
|
328
|
+
);
|
|
329
|
+
},
|
|
330
|
+
);
|
|
331
|
+
|
|
332
|
+
Text.displayName = 'Text';
|
|
113
333
|
|
|
334
|
+
type TextPressabilityProps = $ReadOnly<{
|
|
335
|
+
onLongPress?: ?(event: PressEvent) => mixed,
|
|
336
|
+
onPress?: ?(event: PressEvent) => mixed,
|
|
337
|
+
onPressIn?: ?(event: PressEvent) => mixed,
|
|
338
|
+
onPressOut?: ?(event: PressEvent) => mixed,
|
|
339
|
+
onResponderGrant?: ?(event: PressEvent) => void,
|
|
340
|
+
onResponderMove?: ?(event: PressEvent) => void,
|
|
341
|
+
onResponderRelease?: ?(event: PressEvent) => void,
|
|
342
|
+
onResponderTerminate?: ?(event: PressEvent) => void,
|
|
343
|
+
onResponderTerminationRequest?: ?() => boolean,
|
|
344
|
+
onStartShouldSetResponder?: ?() => boolean,
|
|
345
|
+
pressRetentionOffset?: ?PressRetentionOffset,
|
|
346
|
+
suppressHighlighting?: ?boolean,
|
|
347
|
+
}>;
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Hook that handles setting up Pressability of Text components.
|
|
351
|
+
*
|
|
352
|
+
* NOTE: This hook is relatively expensive so it should only be used absolutely necessary.
|
|
353
|
+
*/
|
|
354
|
+
function useTextPressability({
|
|
355
|
+
onLongPress,
|
|
356
|
+
onPress,
|
|
357
|
+
onPressIn,
|
|
358
|
+
onPressOut,
|
|
359
|
+
onResponderGrant,
|
|
360
|
+
onResponderMove,
|
|
361
|
+
onResponderRelease,
|
|
362
|
+
onResponderTerminate,
|
|
363
|
+
onResponderTerminationRequest,
|
|
364
|
+
onStartShouldSetResponder,
|
|
365
|
+
pressRetentionOffset,
|
|
366
|
+
suppressHighlighting,
|
|
367
|
+
}: TextPressabilityProps) {
|
|
368
|
+
const [isHighlighted, setHighlighted] = useState(false);
|
|
369
|
+
|
|
370
|
+
// Setup pressability config and wrap callbacks needs to track the highlight state.
|
|
371
|
+
const config = useMemo(() => {
|
|
114
372
|
let _onPressIn = onPressIn;
|
|
115
373
|
let _onPressOut = onPressOut;
|
|
116
374
|
|
|
@@ -130,7 +388,7 @@ const Text: React.AbstractComponent<
|
|
|
130
388
|
}
|
|
131
389
|
|
|
132
390
|
return {
|
|
133
|
-
disabled:
|
|
391
|
+
disabled: false,
|
|
134
392
|
pressRectOffset: pressRetentionOffset,
|
|
135
393
|
onLongPress,
|
|
136
394
|
onPress,
|
|
@@ -138,8 +396,6 @@ const Text: React.AbstractComponent<
|
|
|
138
396
|
onPressOut: _onPressOut,
|
|
139
397
|
};
|
|
140
398
|
}, [
|
|
141
|
-
initialized,
|
|
142
|
-
isPressable,
|
|
143
399
|
pressRetentionOffset,
|
|
144
400
|
onLongPress,
|
|
145
401
|
onPress,
|
|
@@ -148,7 +404,10 @@ const Text: React.AbstractComponent<
|
|
|
148
404
|
suppressHighlighting,
|
|
149
405
|
]);
|
|
150
406
|
|
|
407
|
+
// Init the pressability class
|
|
151
408
|
const eventHandlers = usePressability(config);
|
|
409
|
+
|
|
410
|
+
// Create NativeText event handlers which proxy events to pressability
|
|
152
411
|
const eventHandlersForText = useMemo(
|
|
153
412
|
() =>
|
|
154
413
|
eventHandlers == null
|
|
@@ -199,128 +458,67 @@ const Text: React.AbstractComponent<
|
|
|
199
458
|
],
|
|
200
459
|
);
|
|
201
460
|
|
|
202
|
-
//
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (PressabilityDebug.isEnabled() && onPress != null) {
|
|
209
|
-
_style = [style, {color: 'magenta'}];
|
|
210
|
-
}
|
|
211
|
-
}
|
|
461
|
+
// Return the highlight state and NativeText event handlers
|
|
462
|
+
return useMemo(
|
|
463
|
+
() => [isHighlighted, eventHandlersForText],
|
|
464
|
+
[isHighlighted, eventHandlersForText],
|
|
465
|
+
);
|
|
466
|
+
}
|
|
212
467
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
`'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
_numberOfLines = 0;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
let _selectable = selectable;
|
|
224
|
-
const processedStyle = flattenStyle(_style);
|
|
225
|
-
if (processedStyle != null) {
|
|
226
|
-
if (typeof processedStyle.fontWeight === 'number') {
|
|
227
|
-
// $FlowFixMe[cannot-write]
|
|
228
|
-
processedStyle.fontWeight = processedStyle.fontWeight.toString();
|
|
229
|
-
}
|
|
468
|
+
type NativePressableTextProps = $ReadOnly<{
|
|
469
|
+
textProps: NativeTextProps,
|
|
470
|
+
textPressabilityProps: TextPressabilityProps,
|
|
471
|
+
}>;
|
|
230
472
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
const _nativeID = id ?? nativeID;
|
|
247
|
-
|
|
248
|
-
const hasTextAncestor = useContext(TextAncestor);
|
|
249
|
-
if (hasTextAncestor) {
|
|
250
|
-
return (
|
|
251
|
-
<NativeVirtualText
|
|
252
|
-
{...restProps}
|
|
253
|
-
{...eventHandlersForText}
|
|
254
|
-
accessibilityLabel={_accessibilityLabel}
|
|
255
|
-
accessibilityState={_accessibilityState}
|
|
256
|
-
isHighlighted={isHighlighted}
|
|
257
|
-
isPressable={isPressable}
|
|
258
|
-
nativeID={_nativeID}
|
|
259
|
-
numberOfLines={_numberOfLines}
|
|
260
|
-
ref={forwardedRef}
|
|
261
|
-
selectable={_selectable}
|
|
262
|
-
selectionColor={_selectionColor}
|
|
263
|
-
style={processedStyle}
|
|
264
|
-
disabled={disabled}
|
|
265
|
-
/>
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// If the disabled prop and accessibilityState.disabled are out of sync but not both in
|
|
270
|
-
// falsy states we need to update the accessibilityState object to use the disabled prop.
|
|
271
|
-
if (
|
|
272
|
-
_disabled !== _accessibilityStateDisabled &&
|
|
273
|
-
((_disabled != null && _disabled !== false) ||
|
|
274
|
-
(_accessibilityStateDisabled != null &&
|
|
275
|
-
_accessibilityStateDisabled !== false))
|
|
276
|
-
) {
|
|
277
|
-
_accessibilityState = {..._accessibilityState, disabled: _disabled};
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
const _accessible = Platform.select({
|
|
281
|
-
ios: accessible !== false,
|
|
282
|
-
android:
|
|
283
|
-
accessible == null ? onPress != null || onLongPress != null : accessible,
|
|
284
|
-
default: accessible,
|
|
285
|
-
});
|
|
473
|
+
/**
|
|
474
|
+
* Wrap the NativeVirtualText component and initialize pressability.
|
|
475
|
+
*
|
|
476
|
+
* This logic is split out from the main Text component to enable the more
|
|
477
|
+
* expensive pressability logic to be only initialized when needed.
|
|
478
|
+
*/
|
|
479
|
+
const NativePressableVirtualText: React.AbstractComponent<
|
|
480
|
+
NativePressableTextProps,
|
|
481
|
+
TextForwardRef,
|
|
482
|
+
> = React.forwardRef(({textProps, textPressabilityProps}, forwardedRef) => {
|
|
483
|
+
const [isHighlighted, eventHandlersForText] = useTextPressability(
|
|
484
|
+
textPressabilityProps,
|
|
485
|
+
);
|
|
286
486
|
|
|
287
487
|
return (
|
|
288
|
-
<
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
allowFontScaling={allowFontScaling !== false}
|
|
296
|
-
disabled={_disabled}
|
|
297
|
-
ellipsizeMode={ellipsizeMode ?? 'tail'}
|
|
298
|
-
isHighlighted={isHighlighted}
|
|
299
|
-
nativeID={_nativeID}
|
|
300
|
-
numberOfLines={_numberOfLines}
|
|
301
|
-
ref={forwardedRef}
|
|
302
|
-
selectable={_selectable}
|
|
303
|
-
selectionColor={_selectionColor}
|
|
304
|
-
style={processedStyle}
|
|
305
|
-
/>
|
|
306
|
-
</TextAncestor.Provider>
|
|
488
|
+
<NativeVirtualText
|
|
489
|
+
{...textProps}
|
|
490
|
+
{...eventHandlersForText}
|
|
491
|
+
isHighlighted={isHighlighted}
|
|
492
|
+
isPressable={true}
|
|
493
|
+
ref={forwardedRef}
|
|
494
|
+
/>
|
|
307
495
|
);
|
|
308
496
|
});
|
|
309
497
|
|
|
310
|
-
Text.displayName = 'Text';
|
|
311
|
-
|
|
312
498
|
/**
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
499
|
+
* Wrap the NativeText component and initialize pressability.
|
|
500
|
+
*
|
|
501
|
+
* This logic is split out from the main Text component to enable the more
|
|
502
|
+
* expensive pressability logic to be only initialized when needed.
|
|
316
503
|
*/
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
504
|
+
const NativePressableText: React.AbstractComponent<
|
|
505
|
+
NativePressableTextProps,
|
|
506
|
+
TextForwardRef,
|
|
507
|
+
> = React.forwardRef(({textProps, textPressabilityProps}, forwardedRef) => {
|
|
508
|
+
const [isHighlighted, eventHandlersForText] = useTextPressability(
|
|
509
|
+
textPressabilityProps,
|
|
510
|
+
);
|
|
511
|
+
|
|
512
|
+
return (
|
|
513
|
+
<NativeText
|
|
514
|
+
{...textProps}
|
|
515
|
+
{...eventHandlersForText}
|
|
516
|
+
isHighlighted={isHighlighted}
|
|
517
|
+
isPressable={true}
|
|
518
|
+
ref={forwardedRef}
|
|
519
|
+
/>
|
|
520
|
+
);
|
|
521
|
+
});
|
|
324
522
|
|
|
325
523
|
const userSelectToSelectableMap = {
|
|
326
524
|
auto: true,
|