@react-native-oh/react-native-harmony 0.72.86 → 0.77.18

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 (81) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSE-Meta +21 -0
  3. package/Libraries/Alert/delegates/AlertDelegate.harmony.ts +84 -0
  4. package/Libraries/Alert/{AlertManager.ts → delegates/AlertManager.harmony.ts} +10 -4
  5. package/Libraries/Animated/shouldUseTurboAnimatedModule.harmony.ts +10 -0
  6. package/Libraries/Components/AccessibilityInfo/delegates/AccessibilityInfoDelegate.harmony.ts +44 -0
  7. package/Libraries/Components/AccessibilityInfo/{NativeAccessibilityInfoHarmony.ts → delegates/NativeAccessibilityInfoHarmony.harmony.ts} +9 -2
  8. package/Libraries/Components/Keyboard/delegates/KeyboardAvoidingViewDelegate.harmony.ts +42 -0
  9. package/Libraries/Components/RefreshControl/delegates/RefreshControlDelegate.harmony.tsx +29 -0
  10. package/Libraries/Components/SafeAreaView/SafeAreaView.harmony.tsx +93 -31
  11. package/Libraries/Components/ScrollView/delegates/ScrollViewDelegate.harmony.tsx +41 -0
  12. package/Libraries/Components/ScrollView/delegates/ScrollViewNativeComponentDelegate.harmony.ts +89 -0
  13. package/Libraries/Components/ScrollView/processDecelerationRate.harmony.ts +19 -0
  14. package/Libraries/Components/StatusBar/delegates/NativeStatusBarManagerHarmony.harmony.ts +53 -0
  15. package/Libraries/Components/StatusBar/delegates/StatusBarDelegate.harmony.ts +83 -0
  16. package/Libraries/Components/TextInput/delegates/TextInputDelegate.harmony.tsx +98 -0
  17. package/Libraries/Components/TextInput/delegates/TextInputStateDelegate.harmony.tsx +20 -0
  18. package/Libraries/Components/Touchable/delegates/TouchableHighlightDelegate.harmony.ts +14 -0
  19. package/Libraries/Components/Touchable/delegates/TouchableNativeFeedbackDelegate.harmony.ts +14 -0
  20. package/Libraries/Components/Touchable/delegates/TouchableWithoutFeedbackDelegate.harmony.ts +14 -0
  21. package/Libraries/Components/delegates/ButtonDelegate.harmony.ts +41 -0
  22. package/Libraries/Core/setUpPlatform.harmony.js +30 -0
  23. package/Libraries/Image/AssetSourceResolver.harmony.ts +1 -5
  24. package/Libraries/Image/Image.harmony.ts +17 -0
  25. package/Libraries/NativeComponent/BaseViewConfig.harmony.js +12 -326
  26. package/Libraries/NativeComponent/delegates/ViewConfigIgnoreDelegate.harmony.ts +13 -0
  27. package/Libraries/ReactNative/delegates/BridgelessUIManagerDelegate.harmony.ts +14 -0
  28. package/Libraries/ReactNative/delegates/I18nManagerDelegate.harmony.ts +22 -0
  29. package/Libraries/Settings/Settings.harmony.ts +20 -0
  30. package/Libraries/Share/delegates/ShareDelegate.harmony.ts +42 -0
  31. package/Libraries/StyleSheet/NativePlatformColor.harmony.ts +15 -0
  32. package/Libraries/StyleSheet/PlatformColorValueTypes.harmony.ts +8 -1
  33. package/Libraries/Utilities/BackHandler.harmony.ts +10 -0
  34. package/Libraries/Utilities/NativePlatformConstantsHarmony.harmony.ts +17 -0
  35. package/Libraries/Utilities/Platform.harmony.ts +38 -13
  36. package/Libraries/Vibration/delegates/VibrationDelegate.harmony.ts +14 -0
  37. package/NOTICE.md +846 -0
  38. package/README.md +2 -2
  39. package/index.js +53 -63
  40. package/jest.config.js +0 -7
  41. package/metro.config.d.ts +17 -0
  42. package/metro.config.js +398 -115
  43. package/package.json +58 -37
  44. package/react-native.config.js +57 -9
  45. package/react_native_openharmony.har +0 -0
  46. package/tsconfig.json +10 -4
  47. package/types/index.harmony.d.ts +99 -0
  48. package/Libraries/Alert/Alert.harmony.js +0 -77
  49. package/Libraries/Animated/NativeAnimatedHelper.harmony.js +0 -601
  50. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.harmony.js +0 -441
  51. package/Libraries/Components/Button/Button.harmony.js +0 -451
  52. package/Libraries/Components/Image/Image.flow.harmony.js +0 -53
  53. package/Libraries/Components/Image/Image.harmony.js +0 -317
  54. package/Libraries/Components/Image/NativeImageLoaderHarmony.js +0 -38
  55. package/Libraries/Components/Keyboard/KeyboardAvoidingView.harmony.js +0 -256
  56. package/Libraries/Components/RefreshControl/RefreshControl.harmony.js +0 -210
  57. package/Libraries/Components/ScrollView/ScrollView.harmony.js +0 -1951
  58. package/Libraries/Components/ScrollView/processDecelerationRate.harmony.js +0 -24
  59. package/Libraries/Components/StatusBar/NativeStatusBarManagerHarmony.js +0 -71
  60. package/Libraries/Components/StatusBar/StatusBar.harmony.js +0 -447
  61. package/Libraries/Components/TextInput/TextInput.harmony.js +0 -1716
  62. package/Libraries/Components/TextInput/TextInputState.harmony.js +0 -220
  63. package/Libraries/Components/Touchable/TouchableHighlight.harmony.js +0 -396
  64. package/Libraries/Components/Touchable/TouchableNativeFeedback.harmony.js +0 -364
  65. package/Libraries/Components/Touchable/TouchableWithoutFeedback.harmony.js +0 -227
  66. package/Libraries/Components/View/View.harmony.js +0 -149
  67. package/Libraries/Core/setUpReactDevTools.harmony.js +0 -93
  68. package/Libraries/ReactNative/I18nManager.harmony.js +0 -78
  69. package/Libraries/ReactNative/UIManager.harmony.js +0 -210
  70. package/Libraries/Settings/Settings.harmony.js +0 -15
  71. package/Libraries/Share/Share.harmony.js +0 -174
  72. package/Libraries/StyleSheet/NativePlatformColor.ts +0 -8
  73. package/Libraries/Utilities/BackHandler.harmony.js +0 -109
  74. package/Libraries/Utilities/NativePlatformConstants.harmony.ts +0 -8
  75. package/Libraries/Utilities/Platform.d.ts +0 -117
  76. package/Libraries/Utilities/createPerformanceLogger.harmony.js +0 -328
  77. package/Libraries/Vibration/Vibration.harmony.js +0 -88
  78. package/harmony/.keep +0 -0
  79. package/harmony/rnoh-hvigor-plugin-0.2.0.tgz +0 -0
  80. package/react_native_openharmony_release.har +0 -0
  81. package/types/index.d.ts +0 -108
@@ -1,451 +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
9
- * @generate-docs
10
- */
11
-
12
- 'use strict';
13
-
14
- import type {TextStyleProp, ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
15
- import type {PressEvent} from 'react-native/Libraries/Types/CoreEventTypes';
16
- import type {Button as ButtonType} from 'react-native/Libraries/Button/Button.flow';
17
- import type {
18
- AccessibilityActionEvent,
19
- AccessibilityActionInfo,
20
- AccessibilityState,
21
- } from 'react-native/Libraries/Components/View/ViewAccessibility';
22
-
23
- import StyleSheet, {type ColorValue} from 'react-native/Libraries/StyleSheet/StyleSheet';
24
- import Text from 'react-native/Libraries/Text/Text';
25
- import Platform from '../../Utilities/Platform';
26
- import TouchableNativeFeedback from 'react-native/Libraries/Components/Touchable/TouchableNativeFeedback';
27
- import TouchableOpacity from 'react-native/Libraries/Components/Touchable/TouchableOpacity';
28
- import View from 'react-native/Libraries/Components/View/View';
29
- import invariant from 'invariant';
30
- import * as React from 'react';
31
-
32
- type ButtonProps = $ReadOnly<{|
33
- /**
34
- Text to display inside the button. On Android the given title will be
35
- converted to the uppercased form.
36
- */
37
- title: string,
38
-
39
- /**
40
- Handler to be called when the user taps the button. The first function
41
- argument is an event in form of [PressEvent](pressevent).
42
- */
43
- onPress: (event?: PressEvent) => mixed,
44
-
45
- /**
46
- If `true`, doesn't play system sound on touch.
47
-
48
- @platform android
49
-
50
- @default false
51
- */
52
- touchSoundDisabled?: ?boolean,
53
-
54
- /**
55
- Color of the text (iOS), or background color of the button (Android).
56
-
57
- @default {@platform android} '#2196F3'
58
- @default {@platform ios} '#007AFF'
59
- */
60
- color?: ?ColorValue,
61
-
62
- /**
63
- TV preferred focus.
64
-
65
- @platform tv
66
-
67
- @default false
68
- */
69
- hasTVPreferredFocus?: ?boolean,
70
-
71
- /**
72
- Designates the next view to receive focus when the user navigates down. See
73
- the [Android documentation][android:nextFocusDown].
74
-
75
- [android:nextFocusDown]:
76
- https://developer.android.com/reference/android/view/View.html#attr_android:nextFocusDown
77
-
78
- @platform android, tv
79
- */
80
- nextFocusDown?: ?number,
81
-
82
- /**
83
- Designates the next view to receive focus when the user navigates forward.
84
- See the [Android documentation][android:nextFocusForward].
85
-
86
- [android:nextFocusForward]:
87
- https://developer.android.com/reference/android/view/View.html#attr_android:nextFocusForward
88
-
89
- @platform android, tv
90
- */
91
- nextFocusForward?: ?number,
92
-
93
- /**
94
- Designates the next view to receive focus when the user navigates left. See
95
- the [Android documentation][android:nextFocusLeft].
96
-
97
- [android:nextFocusLeft]:
98
- https://developer.android.com/reference/android/view/View.html#attr_android:nextFocusLeft
99
-
100
- @platform android, tv
101
- */
102
- nextFocusLeft?: ?number,
103
-
104
- /**
105
- Designates the next view to receive focus when the user navigates right. See
106
- the [Android documentation][android:nextFocusRight].
107
-
108
- [android:nextFocusRight]:
109
- https://developer.android.com/reference/android/view/View.html#attr_android:nextFocusRight
110
-
111
- @platform android, tv
112
- */
113
- nextFocusRight?: ?number,
114
-
115
- /**
116
- Designates the next view to receive focus when the user navigates up. See
117
- the [Android documentation][android:nextFocusUp].
118
-
119
- [android:nextFocusUp]:
120
- https://developer.android.com/reference/android/view/View.html#attr_android:nextFocusUp
121
-
122
- @platform android, tv
123
- */
124
- nextFocusUp?: ?number,
125
-
126
- /**
127
- Text to display for blindness accessibility features.
128
- */
129
- accessibilityLabel?: ?string,
130
- /**
131
- * Alias for accessibilityLabel https://reactnative.dev/docs/view#accessibilitylabel
132
- * https://github.com/facebook/react-native/issues/34424
133
- */
134
- 'aria-label'?: ?string,
135
- /**
136
- If `true`, disable all interactions for this component.
137
-
138
- @default false
139
- */
140
- disabled?: ?boolean,
141
-
142
- /**
143
- Used to locate this view in end-to-end tests.
144
- */
145
- testID?: ?string,
146
-
147
- /**
148
- * Accessibility props.
149
- */
150
- accessible?: ?boolean,
151
- accessibilityActions?: ?$ReadOnlyArray<AccessibilityActionInfo>,
152
- onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed,
153
- accessibilityState?: ?AccessibilityState,
154
-
155
- /**
156
- * alias for accessibilityState
157
- *
158
- * see https://reactnative.dev/docs/accessibility#accessibilitystate
159
- */
160
- 'aria-busy'?: ?boolean,
161
- 'aria-checked'?: ?boolean | 'mixed',
162
- 'aria-disabled'?: ?boolean,
163
- 'aria-expanded'?: ?boolean,
164
- 'aria-selected'?: ?boolean,
165
-
166
- /**
167
- * [Android] Controlling if a view fires accessibility events and if it is reported to accessibility services.
168
- */
169
- importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'),
170
- accessibilityHint?: ?string,
171
- accessibilityLanguage?: ?Stringish,
172
- |}>;
173
-
174
- /**
175
- A basic button component that should render nicely on any platform. Supports a
176
- minimal level of customization.
177
-
178
- If this button doesn't look right for your app, you can build your own button
179
- using [TouchableOpacity](touchableopacity) or
180
- [TouchableWithoutFeedback](touchablewithoutfeedback). For inspiration, look at
181
- the [source code for this button component][button:source]. Or, take a look at
182
- the [wide variety of button components built by the community]
183
- [button:examples].
184
-
185
- [button:source]:
186
- https://github.com/facebook/react-native/blob/HEAD/Libraries/Components/Button.js
187
-
188
- [button:examples]:
189
- https://js.coach/?menu%5Bcollections%5D=React%20Native&page=1&query=button
190
-
191
- ```jsx
192
- <Button
193
- onPress={onPressLearnMore}
194
- title="Learn More"
195
- color="#841584"
196
- accessibilityLabel="Learn more about this purple button"
197
- />
198
- ```
199
-
200
- ```SnackPlayer name=Button%20Example
201
- import React from 'react';
202
- import { StyleSheet, Button, View, SafeAreaView, Text, Alert } from 'react-native';
203
-
204
- const Separator = () => (
205
- <View style={styles.separator} />
206
- );
207
-
208
- const App = () => (
209
- <SafeAreaView style={styles.container}>
210
- <View>
211
- <Text style={styles.title}>
212
- The title and onPress handler are required. It is recommended to set accessibilityLabel to help make your app usable by everyone.
213
- </Text>
214
- <Button
215
- title="Press me"
216
- onPress={() => Alert.alert('Simple Button pressed')}
217
- />
218
- </View>
219
- <Separator />
220
- <View>
221
- <Text style={styles.title}>
222
- Adjust the color in a way that looks standard on each platform. On iOS, the color prop controls the color of the text. On Android, the color adjusts the background color of the button.
223
- </Text>
224
- <Button
225
- title="Press me"
226
- color="#f194ff"
227
- onPress={() => Alert.alert('Button with adjusted color pressed')}
228
- />
229
- </View>
230
- <Separator />
231
- <View>
232
- <Text style={styles.title}>
233
- All interaction for the component are disabled.
234
- </Text>
235
- <Button
236
- title="Press me"
237
- disabled
238
- onPress={() => Alert.alert('Cannot press this one')}
239
- />
240
- </View>
241
- <Separator />
242
- <View>
243
- <Text style={styles.title}>
244
- This layout strategy lets the title define the width of the button.
245
- </Text>
246
- <View style={styles.fixToText}>
247
- <Button
248
- title="Left button"
249
- onPress={() => Alert.alert('Left button pressed')}
250
- />
251
- <Button
252
- title="Right button"
253
- onPress={() => Alert.alert('Right button pressed')}
254
- />
255
- </View>
256
- </View>
257
- </SafeAreaView>
258
- );
259
-
260
- const styles = StyleSheet.create({
261
- container: {
262
- flex: 1,
263
- justifyContent: 'center',
264
- marginHorizontal: 16,
265
- },
266
- title: {
267
- textAlign: 'center',
268
- marginVertical: 8,
269
- },
270
- fixToText: {
271
- flexDirection: 'row',
272
- justifyContent: 'space-between',
273
- },
274
- separator: {
275
- marginVertical: 8,
276
- borderBottomColor: '#737373',
277
- borderBottomWidth: StyleSheet.hairlineWidth,
278
- },
279
- });
280
-
281
- export default App;
282
- ```
283
- */
284
-
285
- class Button extends React.Component<ButtonProps> {
286
- render(): React.Node {
287
- const {
288
- accessibilityLabel,
289
- accessibilityState,
290
- 'aria-busy': ariaBusy,
291
- 'aria-checked': ariaChecked,
292
- 'aria-disabled': ariaDisabled,
293
- 'aria-expanded': ariaExpanded,
294
- 'aria-label': ariaLabel,
295
- 'aria-selected': ariaSelected,
296
- importantForAccessibility,
297
- color,
298
- onPress,
299
- touchSoundDisabled,
300
- title,
301
- hasTVPreferredFocus,
302
- nextFocusDown,
303
- nextFocusForward,
304
- nextFocusLeft,
305
- nextFocusRight,
306
- nextFocusUp,
307
- testID,
308
- accessible,
309
- accessibilityActions,
310
- accessibilityHint,
311
- accessibilityLanguage,
312
- onAccessibilityAction,
313
- } = this.props;
314
- const buttonStyles: Array<ViewStyleProp> = [styles.button];
315
- const textStyles: Array<TextStyleProp> = [styles.text];
316
- if (color) {
317
- if (Platform.OS === 'ios') {
318
- textStyles.push({color: color});
319
- } else {
320
- buttonStyles.push({backgroundColor: color});
321
- }
322
- }
323
-
324
- let _accessibilityState = {
325
- busy: ariaBusy ?? accessibilityState?.busy,
326
- checked: ariaChecked ?? accessibilityState?.checked,
327
- disabled: ariaDisabled ?? accessibilityState?.disabled,
328
- expanded: ariaExpanded ?? accessibilityState?.expanded,
329
- selected: ariaSelected ?? accessibilityState?.selected,
330
- };
331
-
332
- const disabled =
333
- this.props.disabled != null
334
- ? this.props.disabled
335
- : _accessibilityState?.disabled;
336
-
337
- _accessibilityState =
338
- disabled !== _accessibilityState?.disabled
339
- ? {..._accessibilityState, disabled}
340
- : _accessibilityState;
341
-
342
- if (disabled) {
343
- buttonStyles.push(styles.buttonDisabled);
344
- textStyles.push(styles.textDisabled);
345
- }
346
-
347
- invariant(
348
- typeof title === 'string',
349
- 'The title prop of a Button must be a string',
350
- );
351
- const formattedTitle =
352
- Platform.OS === 'android' ? title.toUpperCase() : title;
353
- const Touchable =
354
- Platform.OS === 'android' ? TouchableNativeFeedback : TouchableOpacity;
355
-
356
- // If `no` is specified for `importantForAccessibility`, it will be changed to `no-hide-descendants` because the text inside should not be focused.
357
- const _importantForAccessibility =
358
- importantForAccessibility === 'no'
359
- ? 'no-hide-descendants'
360
- : importantForAccessibility;
361
-
362
- return (
363
- <Touchable
364
- accessible={accessible}
365
- accessibilityActions={accessibilityActions}
366
- onAccessibilityAction={onAccessibilityAction}
367
- accessibilityLabel={ariaLabel || accessibilityLabel}
368
- accessibilityHint={accessibilityHint}
369
- accessibilityLanguage={accessibilityLanguage}
370
- accessibilityRole="button"
371
- accessibilityState={_accessibilityState}
372
- importantForAccessibility={_importantForAccessibility}
373
- hasTVPreferredFocus={hasTVPreferredFocus}
374
- nextFocusDown={nextFocusDown}
375
- nextFocusForward={nextFocusForward}
376
- nextFocusLeft={nextFocusLeft}
377
- nextFocusRight={nextFocusRight}
378
- nextFocusUp={nextFocusUp}
379
- testID={testID}
380
- disabled={disabled}
381
- onPress={onPress}
382
- touchSoundDisabled={touchSoundDisabled}>
383
- <View style={buttonStyles} focusable={false}>
384
- <Text style={textStyles} disabled={disabled}>
385
- {formattedTitle}
386
- </Text>
387
- </View>
388
- </Touchable>
389
- );
390
- }
391
- }
392
-
393
- const styles = StyleSheet.create({
394
- button: Platform.select({
395
- ios: {},
396
- android: {
397
- elevation: 4,
398
- // Material design blue from https://material.google.com/style/color.html#color-color-palette
399
- backgroundColor: '#2196F3',
400
- borderRadius: 2,
401
- },
402
- // RNOH:patch -add harmony default button style
403
- harmony: {
404
- backgroundColor: '#317aff',
405
- borderRadius: 8
406
- }
407
- }),
408
- text: {
409
- textAlign: 'center',
410
- margin: 8,
411
- ...Platform.select({
412
- ios: {
413
- // iOS blue from https://developer.apple.com/ios/human-interface-guidelines/visual-design/color/
414
- color: '#007AFF',
415
- fontSize: 18,
416
- },
417
- android: {
418
- color: 'white',
419
- fontWeight: '500',
420
- },
421
- // RNOH: patch - add harmony default button text style
422
- harmony: {
423
- color: '#FFFFFF',
424
- fontSize: 16
425
- }
426
- }),
427
- },
428
- buttonDisabled: Platform.select({
429
- ios: {},
430
- android: {
431
- elevation: 0,
432
- backgroundColor: '#dfdfdf',
433
- },
434
- // RNOH: patch - add harmony default button disabled style
435
- harmony: {
436
- opacity: 0.4
437
- }
438
- }),
439
- textDisabled: Platform.select({
440
- ios: {
441
- color: '#cdcdcd',
442
- },
443
- android: {
444
- color: '#a1a1a1',
445
- },
446
- // RNOH: patch - add harmony default button disabled text style
447
- harmony: {}
448
- }),
449
- });
450
-
451
- module.exports = (Button: ButtonType);
@@ -1,53 +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
8
- * @format
9
- */
10
-
11
- import type {RootTag} from 'react-native/Libraries/Types/RootTagTypes';
12
- import type {ResolvedAssetSource} from 'react-native/Libraries/Image/AssetSourceResolver';
13
- import type {ImageProps as ImagePropsType} from 'react-native/Libraries/Image/ImageProps';
14
-
15
- import ImageViewNativeComponent from 'react-native/Libraries/Image/ImageViewNativeComponent';
16
- import * as React from 'react';
17
-
18
- type ImageComponentStaticsHarmony = $ReadOnly<{|
19
- getSize: (
20
- uri: string,
21
- success: (width: number, height: number) => void,
22
- failure?: (error: any) => void,
23
- ) => void,
24
-
25
- getSizeWithHeaders(
26
- uri: string,
27
- headers: {[string]: string, ...},
28
- success: (width: number, height: number) => void,
29
- failure?: (error: any) => void,
30
- ): any,
31
-
32
- prefetch(url: string, callback: ?(requestId: number) => void): any,
33
-
34
- prefetchWithMetadata(
35
- url: string,
36
- queryRootName: string,
37
- rootTag?: ?RootTag,
38
- ): any,
39
-
40
- queryCache(
41
- urls: Array<string>,
42
- ): Promise<{[string]: 'memory' | 'disk' | 'disk/memory', ...}>,
43
-
44
- resolveAssetSource(source: any): ?ResolvedAssetSource,
45
-
46
- abortPrefetch(requestId: number): void,
47
- |}>;
48
-
49
- export type ImageHarmony = React.AbstractComponent<
50
- ImagePropsType,
51
- React.ElementRef<typeof ImageViewNativeComponent>,
52
- > &
53
- ImageComponentStaticsHarmony;