@office-iss/react-native-win32 0.68.0 → 0.69.0-preview.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/.eslintrc.js +1 -0
  2. package/.flowconfig +1 -3
  3. package/CHANGELOG.json +386 -32
  4. package/CHANGELOG.md +166 -19
  5. package/IntegrationTests/BUCK +4 -1
  6. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +7 -0
  7. package/Libraries/ActionSheetIOS/NativeActionSheetManager.js +1 -0
  8. package/Libraries/Alert/Alert.win32.js +1 -1
  9. package/Libraries/Animated/AnimatedImplementation.js +1 -1
  10. package/Libraries/Animated/NativeAnimatedHelper.js +55 -9
  11. package/Libraries/Animated/NativeAnimatedModule.js +1 -0
  12. package/Libraries/Animated/NativeAnimatedTurboModule.js +1 -0
  13. package/Libraries/Animated/animations/TimingAnimation.js +6 -11
  14. package/Libraries/Animated/createAnimatedComponent.js +2 -2
  15. package/Libraries/Animated/nodes/AnimatedColor.js +95 -29
  16. package/Libraries/Animated/nodes/AnimatedInterpolation.js +19 -22
  17. package/Libraries/Animated/nodes/AnimatedNode.js +2 -2
  18. package/Libraries/Animated/nodes/AnimatedValue.js +1 -1
  19. package/Libraries/AppState/AppState.js +1 -1
  20. package/Libraries/Blob/URL.js +7 -1
  21. package/Libraries/Components/Button.js +3 -0
  22. package/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js +5 -0
  23. package/Libraries/Components/Pressable/Pressable.js +3 -3
  24. package/Libraries/Components/Pressable/Pressable.win32.js +3 -3
  25. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +47 -38
  26. package/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js +15 -7
  27. package/Libraries/Components/ScrollView/ScrollView.js +1 -1
  28. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +16 -3
  29. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +3 -1
  30. package/Libraries/Components/Slider/Slider.js +0 -2
  31. package/Libraries/Components/Slider/SliderNativeComponent.js +0 -1
  32. package/Libraries/Components/StatusBar/StatusBar.js +6 -1
  33. package/Libraries/Components/Switch/Switch.js +11 -1
  34. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +114 -109
  35. package/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +17 -9
  36. package/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +13 -5
  37. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +10 -0
  38. package/Libraries/Components/TextInput/TextInput.js +1 -8
  39. package/Libraries/Components/TextInput/TextInputState.js +10 -2
  40. package/Libraries/Components/TextInput/TextInputState.win32.js +10 -2
  41. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
  42. package/Libraries/Components/Touchable/TouchableBounce.js +1 -0
  43. package/Libraries/Components/Touchable/TouchableHighlight.js +1 -0
  44. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -0
  45. package/Libraries/Components/Touchable/TouchableOpacity.js +7 -1
  46. package/Libraries/Components/Touchable/TouchableWin32.Props.d.ts +3 -1
  47. package/Libraries/Components/Touchable/TouchableWin32.Props.js.map +1 -1
  48. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +2 -0
  49. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  50. package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +1 -0
  51. package/Libraries/Components/View/View.win32.js +33 -1
  52. package/Libraries/Components/View/ViewNativeComponent.js +68 -8
  53. package/Libraries/Components/View/ViewPropTypes.js +36 -4
  54. package/Libraries/Components/View/ViewPropTypes.win32.js +36 -4
  55. package/Libraries/Components/View/ViewWin32.Props.d.ts +1 -1
  56. package/Libraries/Components/View/ViewWin32.Props.js.map +1 -1
  57. package/Libraries/Core/Devtools/parseHermesStack.js +1 -1
  58. package/Libraries/Core/ExceptionsManager.js +1 -1
  59. package/Libraries/Core/RawEventEmitter.js +38 -0
  60. package/Libraries/Core/ReactNativeVersion.js +2 -2
  61. package/Libraries/Core/polyfillPromise.js +32 -0
  62. package/Libraries/Core/setUpReactDevTools.js +3 -2
  63. package/Libraries/EventEmitter/NativeEventEmitter.js +3 -3
  64. package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +2 -1
  65. package/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js +3 -3
  66. package/Libraries/Events/CustomEvent.js +32 -0
  67. package/Libraries/Events/EventPolyfill.js +239 -0
  68. package/Libraries/Image/Image.android.js +0 -6
  69. package/Libraries/Image/Image.ios.js +0 -6
  70. package/Libraries/Image/Image.win32.js +2 -8
  71. package/Libraries/Image/ImageViewNativeComponent.js +18 -3
  72. package/Libraries/Image/TextInlineImageNativeComponent.js +23 -15
  73. package/Libraries/Image/resolveAssetSource.win32.js +1 -1
  74. package/Libraries/Inspector/Inspector.js +2 -4
  75. package/Libraries/Inspector/Inspector.win32.js +7 -9
  76. package/Libraries/Interaction/BridgeSpyStallHandler.js +4 -3
  77. package/Libraries/Interaction/InteractionManager.js +1 -12
  78. package/Libraries/Interaction/TaskQueue.js +5 -4
  79. package/Libraries/LayoutAnimation/LayoutAnimation.js +13 -0
  80. package/Libraries/Linking/Linking.js +1 -1
  81. package/Libraries/Lists/FlatList.js +27 -6
  82. package/Libraries/Lists/VirtualizedList.js +71 -55
  83. package/Libraries/Lists/VirtualizedListContext.js +7 -3
  84. package/Libraries/Lists/VirtualizedSectionList.js +2 -2
  85. package/Libraries/Lists/__tests__/{FillRateHelper-test.windows.js → FillRateHelper-test.js} +2 -2
  86. package/Libraries/Lists/__tests__/{FlatList-test.windows.js → FlatList-test.js} +2 -2
  87. package/Libraries/Lists/__tests__/{SectionList-test.windows.js → SectionList-test.js} +14 -14
  88. package/Libraries/Lists/__tests__/{VirtualizeUtils-test.windows.js → VirtualizeUtils-test.js} +3 -3
  89. package/Libraries/Lists/__tests__/{VirtualizedList-test.windows.js → VirtualizedList-test.js} +92 -43
  90. package/Libraries/Lists/__tests__/{VirtualizedSectionList-test.windows.js → VirtualizedSectionList-test.js} +16 -14
  91. package/Libraries/LogBox/Data/LogBoxData.js +2 -2
  92. package/Libraries/LogBox/Data/LogBoxLog.js +1 -1
  93. package/Libraries/LogBox/Data/LogBoxSymbolication.js +1 -1
  94. package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
  95. package/Libraries/LogBox/LogBox.js +2 -21
  96. package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +1 -0
  97. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +2 -1
  98. package/Libraries/NativeComponent/BaseViewConfig.android.js +295 -0
  99. package/Libraries/NativeComponent/BaseViewConfig.ios.js +333 -0
  100. package/Libraries/NativeComponent/BaseViewConfig.win32.js +334 -0
  101. package/Libraries/NativeComponent/NativeComponentRegistry.js +0 -2
  102. package/Libraries/NativeComponent/PlatformBaseViewConfig.js +24 -0
  103. package/Libraries/NativeComponent/StaticViewConfigValidator.js +7 -42
  104. package/Libraries/NativeComponent/ViewConfig.js +4 -4
  105. package/Libraries/NativeComponent/ViewConfigIgnore.js +54 -0
  106. package/Libraries/Network/FormData.js +7 -1
  107. package/Libraries/Network/RCTNetworking.win32.js +1 -1
  108. package/Libraries/Pressability/Pressability.js +115 -46
  109. package/Libraries/Pressability/Pressability.win32.js +174 -69
  110. package/Libraries/Pressability/PressabilityDebug.js +5 -9
  111. package/Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js +1 -0
  112. package/Libraries/ReactNative/AppContainer.js +1 -1
  113. package/Libraries/ReactNative/{DummyUIManager.js → BridgelessUIManager.js} +62 -40
  114. package/Libraries/ReactNative/PaperUIManager.win32.js +5 -5
  115. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +39 -0
  116. package/Libraries/ReactNative/UIManager.js +2 -3
  117. package/Libraries/ReactNative/renderApplication.js +4 -0
  118. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +8 -0
  119. package/Libraries/Renderer/implementations/ReactFabric-dev.js +5908 -4906
  120. package/Libraries/Renderer/implementations/ReactFabric-prod.js +2100 -1918
  121. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +2567 -2352
  122. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +5610 -4844
  123. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +1710 -1556
  124. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +1830 -1639
  125. package/Libraries/Renderer/shims/ReactNativeTypes.js +2 -1
  126. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +2 -1
  127. package/Libraries/StyleSheet/EdgeInsetsPropType.js +4 -1
  128. package/Libraries/StyleSheet/StyleSheetTypes.js +59 -66
  129. package/Libraries/StyleSheet/normalizeColor.js +1 -1
  130. package/Libraries/StyleSheet/private/_StyleSheetTypesOverrides.js +15 -0
  131. package/Libraries/StyleSheet/private/_TransformStyle.js +53 -0
  132. package/Libraries/Text/Text.js +13 -7
  133. package/Libraries/Text/TextNativeComponent.js +2 -0
  134. package/Libraries/Text/TextNativeComponent.win32.js +2 -0
  135. package/Libraries/Text/TextProps.js +10 -0
  136. package/Libraries/Types/CoreEventTypes.js +13 -1
  137. package/Libraries/Types/CoreEventTypes.win32.js +26 -1
  138. package/Libraries/Utilities/Appearance.js +0 -8
  139. package/Libraries/Utilities/HMRClient.js +1 -1
  140. package/Libraries/Utilities/ReactNativeTestTools.js +1 -0
  141. package/Libraries/Utilities/codegenNativeComponent.js +16 -6
  142. package/Libraries/Utilities/stringifySafe.js +4 -1
  143. package/Libraries/Utilities/useColorScheme.js +9 -15
  144. package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +3 -3
  145. package/Libraries/WebSocket/WebSocket.js +1 -1
  146. package/Libraries/vendor/emitter/_EmitterSubscription.js +1 -1
  147. package/Libraries/vendor/emitter/_EventEmitter.js +1 -1
  148. package/Libraries/vendor/emitter/_EventSubscription.js +1 -1
  149. package/flow/{use-subscription.js → use-sync-external-store.js} +4 -4
  150. package/index.js +30 -25
  151. package/index.win32.js +30 -25
  152. package/jest/preprocessor.js +24 -107
  153. package/jest/preprocessor_DO_NOT_USE.js +122 -0
  154. package/metro.config.js +3 -47
  155. package/overrides.json +39 -46
  156. package/package.json +32 -29
  157. package/rntypes/index.d.ts +19 -7
  158. package/src/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +1 -1
  159. package/src/Libraries/Components/Touchable/TouchableWin32.Props.tsx +3 -1
  160. package/src/Libraries/Components/View/ViewWin32.Props.ts +1 -0
  161. package/src/Libraries/Lists/__tests__/__snapshots__/FlatList-test.js.snap +427 -0
  162. package/src/Libraries/Lists/__tests__/__snapshots__/SectionList-test.js.snap +391 -0
  163. package/src/Libraries/Lists/__tests__/__snapshots__/VirtualizeUtils-test.js.snap +3 -0
  164. package/src/Libraries/Lists/__tests__/__snapshots__/VirtualizedList-test.js.snap +4565 -0
  165. package/src/Libraries/Lists/__tests__/__snapshots__/VirtualizedSectionList-test.js.snap +1153 -0
  166. package/src/rntypes/index.d.ts +19 -7
  167. package/typings-index.js +5 -1
  168. package/typings-index.js.map +1 -1
  169. package/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js +0 -44
  170. package/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js +0 -45
  171. package/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js +0 -123
  172. package/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.js +0 -45
  173. package/Libraries/Components/View/ReactNativeViewViewConfig.js +0 -360
  174. package/Libraries/Components/View/ReactNativeViewViewConfig.win32.js +0 -401
  175. package/Libraries/Components/View/ReactNativeViewViewConfigAndroid.js +0 -83
  176. package/Libraries/ReactNative/UIManagerInjection.js +0 -15
  177. package/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +0 -24527
  178. package/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +0 -8309
  179. package/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +0 -8961
  180. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +0 -24948
  181. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +0 -8400
  182. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +0 -9049
  183. package/flow/Promise.js +0 -47
@@ -31,7 +31,6 @@
31
31
  // Dominique Richard <https://github.com/doumart>
32
32
  // Mohamed Shaban <https://github.com/drmas>
33
33
  // Jérémy Barbet <https://github.com/jeremybarbet>
34
- // Christian Ost <https://github.com/ca057>
35
34
  // David Sheldrick <https://github.com/ds300>
36
35
  // Natsathorn Yuthakovit <https://github.com/natsathorn>
37
36
  // ConnectDotz <https://github.com/connectdotz>
@@ -41,6 +40,7 @@
41
40
  // Arafat Zahan <https://github.com/kuasha420>
42
41
  // Pedro Hernández <https://github.com/phvillegas>
43
42
  // Sebastian Silbermann <https://github.com/eps1lon>
43
+ // Zihan Chen <https://github.com/ZihanChen-MSFT>
44
44
  // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
45
45
  // TypeScript Version: 3.0
46
46
 
@@ -3220,12 +3220,6 @@ export interface RefreshControlPropsAndroid extends ViewProps {
3220
3220
  * Size of the refresh indicator, see RefreshControl.SIZE.
3221
3221
  */
3222
3222
  size?: number | undefined;
3223
-
3224
- /**
3225
- * Progress view top offset
3226
- * @platform android
3227
- */
3228
- progressViewOffset?: number | undefined;
3229
3223
  }
3230
3224
 
3231
3225
  export interface RefreshControlProps extends RefreshControlPropsIOS, RefreshControlPropsAndroid {
@@ -3238,6 +3232,11 @@ export interface RefreshControlProps extends RefreshControlPropsIOS, RefreshCont
3238
3232
  * Whether the view should be indicating an active refresh.
3239
3233
  */
3240
3234
  refreshing: boolean;
3235
+
3236
+ /**
3237
+ * Progress view top offset
3238
+ */
3239
+ progressViewOffset?: number | undefined;
3241
3240
  }
3242
3241
 
3243
3242
  /**
@@ -9159,6 +9158,19 @@ export interface ImageStoreStatic {
9159
9158
  getBase64ForTag(uri: string, success: (base64ImageData: string) => void, failure: (error: any) => void): void;
9160
9159
  }
9161
9160
 
9161
+ //
9162
+ // Turbo Module
9163
+ //
9164
+
9165
+ export interface TurboModule {
9166
+ getConstants?(): {}
9167
+ }
9168
+
9169
+ export const TurboModuleRegistry: {
9170
+ get<T extends TurboModule>(name: string): T | null;
9171
+ getEnforcing<T extends TurboModule>(name: string): T;
9172
+ }
9173
+
9162
9174
  //
9163
9175
  // Interfacing with Native Modules
9164
9176
  // https://reactnative.dev/docs/native-modules-ios
package/typings-index.js CHANGED
@@ -9,7 +9,11 @@
9
9
  */
10
10
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
11
  if (k2 === undefined) k2 = k;
12
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12
+ var desc = Object.getOwnPropertyDescriptor(m, k);
13
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14
+ desc = { enumerable: true, get: function() { return m[k]; } };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
13
17
  }) : (function(o, m, k, k2) {
14
18
  if (k2 === undefined) k2 = k;
15
19
  o[k2] = m[k];
@@ -1 +1 @@
1
- {"version":3,"file":"typings-index.js","sourceRoot":"","sources":["src/typings-index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;AAEH;;;;EAIE;AAEF,2EAA2E;AAC3E,sFAAsF;AACtF,+CAA+C;AAC/C,kDAAgC;AAMhC,8EAA4D;AAC5D,wEAAsD;AACtD,8EAA4D;AAC5D,wEAAsD;AACtD,kFAAgE;AAChE,4EAA0D;AAC1D,sFAAoE;AACpE,wFAAsE;AACtE,wFAAsE;AACtE,kFAAgE;AAChE,sEAAoD;AACpD,2EAAyD;AACzD,2EAAyD","sourcesContent":["/**\n * @packagedocumentation\n *\n * This package provides Win32 specific components in addition to providing the core react-native primities.\n * Cross platform React-native primitives should be imported from 'react-native'\n * Win32 specific components need to be imported from '\\@office-iss/react-native-win32'\n *\n */\n\n/*\n This file is used to provide the typings for this package.\n NOTE: Concrete classes, objects etc that actually need to be exported from the package,\n need to also be added to index.win32.js\n*/\n\n// Importing from a copy of react-native types instead of from react-native\n// to allow custom typescript resolvers to redirect react-native to react-native-win32\n// when building bundles for the win32 platform\nexport * from './rntypes/index';\nexport type { \n AccessibilityActionInfo,\n AccessibilityActionName,\n AccessibilityState\n} from './Libraries/Components/View/ViewWin32.Props';\nexport * from './Libraries/Components/View/ViewWin32.Props';\nexport * from './Libraries/Components/View/ViewWin32';\nexport * from './Libraries/Components/Text/TextWin32.Props';\nexport * from './Libraries/Components/Text/TextWin32';\nexport * from './Libraries/Components/Button/ButtonWin32.Props';\nexport * from './Libraries/Components/Button/ButtonWin32';\nexport * from './Libraries/StyleSheet/PlatformColorValueTypesWin32';\nexport * from './Libraries/Components/Touchable/TouchableWin32.Props';\nexport * from './Libraries/Components/Touchable/TouchableWin32.Types';\nexport * from './Libraries/Components/Touchable/TouchableWin32';\nexport * from './Libraries/PersonaCoin/PersonaCoin';\nexport * from './Libraries/PersonaCoin/PersonaCoinTypes';\nexport * from './Libraries/Utilities/FocusManager.win32';"]}
1
+ {"version":3,"file":"typings-index.js","sourceRoot":"","sources":["src/typings-index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;;;;;AAEH;;;;EAIE;AAEF,2EAA2E;AAC3E,sFAAsF;AACtF,+CAA+C;AAC/C,kDAAgC;AAMhC,8EAA4D;AAC5D,wEAAsD;AACtD,8EAA4D;AAC5D,wEAAsD;AACtD,kFAAgE;AAChE,4EAA0D;AAC1D,sFAAoE;AACpE,wFAAsE;AACtE,wFAAsE;AACtE,kFAAgE;AAChE,sEAAoD;AACpD,2EAAyD;AACzD,2EAAyD","sourcesContent":["/**\n * @packagedocumentation\n *\n * This package provides Win32 specific components in addition to providing the core react-native primities.\n * Cross platform React-native primitives should be imported from 'react-native'\n * Win32 specific components need to be imported from '\\@office-iss/react-native-win32'\n *\n */\n\n/*\n This file is used to provide the typings for this package.\n NOTE: Concrete classes, objects etc that actually need to be exported from the package,\n need to also be added to index.win32.js\n*/\n\n// Importing from a copy of react-native types instead of from react-native\n// to allow custom typescript resolvers to redirect react-native to react-native-win32\n// when building bundles for the win32 platform\nexport * from './rntypes/index';\nexport type { \n AccessibilityActionInfo,\n AccessibilityActionName,\n AccessibilityState\n} from './Libraries/Components/View/ViewWin32.Props';\nexport * from './Libraries/Components/View/ViewWin32.Props';\nexport * from './Libraries/Components/View/ViewWin32';\nexport * from './Libraries/Components/Text/TextWin32.Props';\nexport * from './Libraries/Components/Text/TextWin32';\nexport * from './Libraries/Components/Button/ButtonWin32.Props';\nexport * from './Libraries/Components/Button/ButtonWin32';\nexport * from './Libraries/StyleSheet/PlatformColorValueTypesWin32';\nexport * from './Libraries/Components/Touchable/TouchableWin32.Props';\nexport * from './Libraries/Components/Touchable/TouchableWin32.Types';\nexport * from './Libraries/Components/Touchable/TouchableWin32';\nexport * from './Libraries/PersonaCoin/PersonaCoin';\nexport * from './Libraries/PersonaCoin/PersonaCoinTypes';\nexport * from './Libraries/Utilities/FocusManager.win32';"]}
@@ -1,44 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @flow strict-local
8
- * @format
9
- */
10
-
11
- import codegenNativeComponent from '../../Utilities/codegenNativeComponent';
12
- import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
13
- import type {ViewProps} from '../View/ViewPropTypes';
14
- import type {
15
- BubblingEventHandler,
16
- WithDefault,
17
- Int32,
18
- } from '../../Types/CodegenTypes';
19
- import type {ColorValue} from '../../StyleSheet/StyleSheet';
20
-
21
- export type OnChangeEvent = $ReadOnly<{|
22
- value: Int32,
23
- selectedSegmentIndex: Int32,
24
- |}>;
25
-
26
- type NativeProps = $ReadOnly<{|
27
- ...ViewProps,
28
-
29
- // Props
30
- values?: $ReadOnlyArray<string>,
31
- selectedIndex?: WithDefault<Int32, 0>,
32
- enabled?: WithDefault<boolean, true>,
33
- tintColor?: ?ColorValue,
34
- textColor?: ?ColorValue,
35
- backgroundColor?: ?ColorValue,
36
- momentary?: WithDefault<boolean, false>,
37
-
38
- // Events
39
- onChange?: ?BubblingEventHandler<OnChangeEvent>,
40
- |}>;
41
-
42
- export default (codegenNativeComponent<NativeProps>(
43
- 'RCTSegmentedControl',
44
- ): HostComponent<NativeProps>);
@@ -1,45 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- */
9
-
10
- 'use strict';
11
- import * as React from 'react';
12
- import StyleSheet from '../../StyleSheet/StyleSheet';
13
- import Text from '../../Text/Text';
14
- import View from '../View/View';
15
-
16
- class DummySegmentedControlIOS extends React.Component {
17
- render() {
18
- return (
19
- <View style={[styles.dummy, this.props.style]}>
20
- <Text style={styles.text}>
21
- SegmentedControlIOS is not supported on this platform!
22
- </Text>
23
- </View>
24
- );
25
- }
26
- }
27
-
28
- const styles = StyleSheet.create({
29
- dummy: {
30
- width: 120,
31
- height: 50,
32
- backgroundColor: '#ffbcbc',
33
- borderWidth: 1,
34
- borderColor: 'red',
35
- alignItems: 'center',
36
- justifyContent: 'center',
37
- },
38
- text: {
39
- color: '#333333',
40
- margin: 5,
41
- fontSize: 10,
42
- },
43
- });
44
-
45
- module.exports = DummySegmentedControlIOS;
@@ -1,123 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @flow strict-local
9
- */
10
-
11
- import * as React from 'react';
12
- import StyleSheet from '../../StyleSheet/StyleSheet';
13
- import type {OnChangeEvent} from './RCTSegmentedControlNativeComponent';
14
- import type {ViewProps} from '../View/ViewPropTypes';
15
- import RCTSegmentedControlNativeComponent from './RCTSegmentedControlNativeComponent';
16
- import type {SyntheticEvent} from 'react-native/Libraries/Types/CoreEventTypes';
17
-
18
- type SegmentedControlIOSProps = $ReadOnly<{|
19
- ...ViewProps,
20
- /**
21
- * The labels for the control's segment buttons, in order.
22
- *
23
- * The default value is an empty array.
24
- */
25
- values?: $ReadOnlyArray<string>,
26
- /**
27
- * The index in `props.values` of the segment to be (pre)selected.
28
- */
29
- selectedIndex?: ?number,
30
- /**
31
- * If false the user won't be able to interact with the control.
32
- *
33
- * The default value is true.
34
- */
35
- enabled?: boolean,
36
- /**
37
- * Accent color of the control.
38
- */
39
- tintColor?: ?string,
40
- /**
41
- * If true, then selecting a segment won't persist visually.
42
- * The `onValueChange` callback will still work as expected.
43
- */
44
- momentary?: ?boolean,
45
- /**
46
- * Callback that is called when the user taps a segment
47
- */
48
- onChange?: ?(event: SyntheticEvent<OnChangeEvent>) => void,
49
- /**
50
- * Callback that is called when the user taps a segment;
51
- * passes the segment's value as an argument
52
- */
53
- onValueChange?: ?(value: number) => mixed,
54
- |}>;
55
-
56
- type Props = $ReadOnly<{|
57
- ...SegmentedControlIOSProps,
58
- forwardedRef: ?React.Ref<typeof RCTSegmentedControlNativeComponent>,
59
- |}>;
60
-
61
- /**
62
- * Use `SegmentedControlIOS` to render a UISegmentedControl iOS.
63
- *
64
- * #### Programmatically changing selected index
65
- *
66
- * The selected index can be changed on the fly by assigning the
67
- * selectedIndex prop to a state variable, then changing that variable.
68
- * Note that the state variable would need to be updated as the user
69
- * selects a value and changes the index, as shown in the example below.
70
- *
71
- * ````
72
- * <SegmentedControlIOS
73
- * values={['One', 'Two']}
74
- * selectedIndex={this.state.selectedIndex}
75
- * onChange={(event) => {
76
- * this.setState({selectedIndex: event.nativeEvent.selectedSegmentIndex});
77
- * }}
78
- * />
79
- * ````
80
- */
81
-
82
- class SegmentedControlIOS extends React.Component<Props> {
83
- _onChange = (event: SyntheticEvent<OnChangeEvent>) => {
84
- this.props.onChange && this.props.onChange(event);
85
- this.props.onValueChange &&
86
- this.props.onValueChange(event.nativeEvent.value);
87
- };
88
-
89
- render() {
90
- const {enabled, forwardedRef, onValueChange, style, values, ...props} =
91
- this.props;
92
- return (
93
- <RCTSegmentedControlNativeComponent
94
- {...props}
95
- ref={forwardedRef}
96
- style={[styles.segmentedControl, style]}
97
- enabled={enabled !== false}
98
- values={values ?? []}
99
- onChange={this._onChange}
100
- />
101
- );
102
- }
103
- }
104
-
105
- const styles = StyleSheet.create({
106
- segmentedControl: {
107
- height: 28,
108
- },
109
- });
110
-
111
- const SegmentedControlIOSWithRef = React.forwardRef(
112
- (
113
- props: SegmentedControlIOSProps,
114
- forwardedRef: ?React.Ref<typeof RCTSegmentedControlNativeComponent>,
115
- ) => {
116
- return <SegmentedControlIOS {...props} forwardedRef={forwardedRef} />;
117
- },
118
- );
119
-
120
- /* $FlowFixMe[cannot-resolve-name] (>=0.89.0 site=react_native_ios_fb) This
121
- * comment suppresses an error found when Flow v0.89 was deployed. To see the
122
- * error, delete this comment and run Flow. */
123
- module.exports = (SegmentedControlIOSWithRef: NativeSegmentedControlIOS);
@@ -1,45 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- */
9
-
10
- 'use strict';
11
- import * as React from 'react';
12
- import StyleSheet from '../../StyleSheet/StyleSheet';
13
- import Text from '../../Text/Text';
14
- import View from '../View/View';
15
-
16
- class DummySegmentedControlIOS extends React.Component {
17
- render() {
18
- return (
19
- <View style={[styles.dummy, this.props.style]}>
20
- <Text style={styles.text}>
21
- SegmentedControlIOS is not supported on this platform!
22
- </Text>
23
- </View>
24
- );
25
- }
26
- }
27
-
28
- const styles = StyleSheet.create({
29
- dummy: {
30
- width: 120,
31
- height: 50,
32
- backgroundColor: '#ffbcbc',
33
- borderWidth: 1,
34
- borderColor: 'red',
35
- alignItems: 'center',
36
- justifyContent: 'center',
37
- },
38
- text: {
39
- color: '#333333',
40
- margin: 5,
41
- fontSize: 10,
42
- },
43
- });
44
-
45
- module.exports = DummySegmentedControlIOS;