react-native-ui-lib 7.46.3 → 8.0.0

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 (214) hide show
  1. package/babel.config.js +12 -0
  2. package/incubator.d.ts +2 -2
  3. package/incubator.js +0 -2
  4. package/index.js +1 -0
  5. package/lib/android/build.gradle +5 -5
  6. package/lib/android/src/main/java/com/wix/reactnativeuilib/UiLibPackageList.java +0 -2
  7. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager.java +31 -23
  8. package/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java +1 -1
  9. package/lib/components/{HighlighterOverlayView.d.ts → HighlighterOverlayView/index.d.ts} +1 -1
  10. package/lib/components/HighlighterOverlayView/index.js +49 -0
  11. package/lib/components/{HighlighterOverlayView.web.d.ts → HighlighterOverlayView/index.web.d.ts} +1 -1
  12. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.android.d.ts +5 -2
  13. package/lib/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.android.js +51 -0
  14. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.d.ts +1 -1
  15. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.js +3 -3
  16. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.d.ts +3 -0
  17. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.js +1 -1
  18. package/lib/components/Keyboard/{KeyboardInput/utils → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager}/__tests__/EventEmitterManager.spec.js +1 -1
  19. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/__tests__/KeyboardRegistry.spec.js +1 -1
  20. package/lib/components/Keyboard/{KeyboardInput/KeyboardRegistry.d.ts → KeyboardAccessoryView/KeyboardRegistry/index.d.ts} +1 -1
  21. package/lib/components/Keyboard/{KeyboardInput/KeyboardRegistry.js → KeyboardAccessoryView/KeyboardRegistry/index.js} +1 -1
  22. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/keyboardRegistry.api.json +9 -9
  23. package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.d.ts +26 -0
  24. package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.js +91 -0
  25. package/lib/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.d.ts → KeyboardAccessoryView/index.d.ts} +11 -1
  26. package/lib/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.js → KeyboardAccessoryView/index.js} +31 -5
  27. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/keyboardAccessoryView.api.json +5 -5
  28. package/lib/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.d.ts → KeyboardAwareInsetsView/index.d.ts} +1 -1
  29. package/lib/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.js → KeyboardAwareInsetsView/index.js} +1 -1
  30. package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.d.ts +1 -4
  31. package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.js +5 -8
  32. package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.d.ts +2 -2
  33. package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/keyboardTrackingView.api.json +11 -20
  34. package/lib/components/Keyboard/index.d.ts +6 -6
  35. package/lib/components/Keyboard/index.js +6 -6
  36. package/lib/components/SafeArea/SafeAreaInsetsManager.d.ts +21 -7
  37. package/lib/components/SafeArea/SafeAreaInsetsManager.js +95 -31
  38. package/lib/components/SafeArea/SafeAreaSpacerView.d.ts +2 -2
  39. package/lib/components/SafeArea/SafeAreaSpacerView.js +63 -9
  40. package/lib/components/SafeArea/__tests__/SafeAreaInsetsManager.spec.js +274 -0
  41. package/lib/components/SafeArea/index.d.ts +10 -0
  42. package/lib/components/SafeArea/index.js +11 -0
  43. package/lib/components/index.d.ts +1 -1
  44. package/lib/components/index.js +1 -1
  45. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomInputControllerTemp.m +56 -8
  46. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.h +1 -7
  47. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.m +1 -1
  48. package/lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m +134 -44
  49. package/lib/package.json +3 -3
  50. package/lib/react-native.config.js +1 -3
  51. package/metro.config.js +2 -2
  52. package/package.json +33 -32
  53. package/panView.d.ts +2 -0
  54. package/panView.js +1 -0
  55. package/scripts/release/prReleaseNotesCommon.js +15 -4
  56. package/src/commons/Constants.js +2 -5
  57. package/src/commons/modifiers.d.ts +1 -0
  58. package/src/commons/modifiers.js +5 -2
  59. package/src/components/KeyboardAwareScrollView/KeyboardAwareBase.js +5 -1
  60. package/src/components/actionSheet/index.d.ts +2 -12
  61. package/src/components/actionSheet/index.js +3 -42
  62. package/src/components/animatedImage/index.js +12 -2
  63. package/src/components/badge/index.d.ts +107 -47
  64. package/src/components/button/button.api.json +1 -1
  65. package/src/components/button/index.d.ts +53 -23
  66. package/src/components/button/types.d.ts +0 -1
  67. package/src/components/colorPicker/ColorPickerDialog.d.ts +1 -1
  68. package/src/components/colorPicker/ColorPickerDialog.js +1 -1
  69. package/src/components/dateTimePicker/index.d.ts +186 -5
  70. package/src/components/dateTimePicker/index.js +3 -4
  71. package/src/components/dialog/dialog.api.json +34 -35
  72. package/src/{incubator → components}/dialog/dialogHeader.api.json +2 -2
  73. package/src/components/dialog/index.d.ts +13 -105
  74. package/src/components/dialog/index.js +205 -212
  75. package/src/{incubator → components}/dialog/types.d.ts +7 -19
  76. package/src/{incubator → components}/dialog/types.js +1 -3
  77. package/src/{incubator → components}/dialog/useDialogContent.d.ts +1 -1
  78. package/src/components/drawer/Swipeable.js +1 -2
  79. package/src/components/drawer/index.js +31 -25
  80. package/src/components/fadedScrollView/index.js +7 -2
  81. package/src/components/featureHighlight/index.d.ts +1 -1
  82. package/src/components/hint/index.d.ts +0 -8
  83. package/src/components/hint/index.js +4 -6
  84. package/src/components/image/index.js +4 -0
  85. package/src/components/index.js +0 -19
  86. package/src/components/marquee/types.js +4 -1
  87. package/src/components/modal/index.d.ts +5 -0
  88. package/src/components/modal/index.js +14 -10
  89. package/src/components/modal/modal.api.json +5 -0
  90. package/src/{incubator → components}/panView/index.d.ts +3 -3
  91. package/src/{incubator → components}/panView/index.js +4 -4
  92. package/src/{incubator → components}/panView/usePanGesture.d.ts +1 -1
  93. package/src/components/picker/Picker.driver.new.d.ts +2 -2
  94. package/src/components/picker/Picker.driver.new.js +3 -3
  95. package/src/components/picker/PickerItem.js +6 -20
  96. package/src/components/picker/PickerPresenter.d.ts +0 -1
  97. package/src/components/picker/PickerPresenter.js +1 -23
  98. package/src/components/picker/api/picker.api.json +0 -1
  99. package/src/components/picker/api/pickerItem.api.json +0 -5
  100. package/src/components/picker/helpers/useFieldType.d.ts +53 -23
  101. package/src/components/picker/helpers/usePickerLabel.d.ts +1 -1
  102. package/src/components/picker/helpers/usePickerLabel.js +2 -3
  103. package/src/components/picker/helpers/usePickerMigrationWarnings.d.ts +1 -1
  104. package/src/components/picker/helpers/usePickerMigrationWarnings.js +0 -12
  105. package/src/components/picker/helpers/usePickerSearch.d.ts +1 -1
  106. package/src/components/picker/helpers/usePickerSearch.js +4 -8
  107. package/src/components/picker/helpers/usePickerSelection.d.ts +1 -1
  108. package/src/components/picker/helpers/usePickerSelection.js +2 -10
  109. package/src/components/picker/index.js +4 -22
  110. package/src/components/picker/types.d.ts +1 -24
  111. package/src/components/segmentedControl/index.js +3 -3
  112. package/src/components/slider/GradientSlider.d.ts +1 -1
  113. package/src/components/slider/index.js +1 -1
  114. package/src/components/sortableGridList/SortableItem.js +13 -4
  115. package/src/components/sortableList/SortableListItem.js +13 -4
  116. package/src/components/stackAggregator/index.js +16 -11
  117. package/src/components/tabController/TabPage.js +18 -14
  118. package/src/components/text/Text.driver.new.d.ts +2 -2
  119. package/src/components/text/Text.driver.new.js +2 -2
  120. package/src/components/text/index.js +2 -3
  121. package/src/components/textField/Input.js +0 -1
  122. package/src/components/textField/TextField.driver.new.d.ts +2 -2
  123. package/src/components/textField/TextField.driver.new.js +2 -2
  124. package/src/components/textField/presets/outline.d.ts +106 -46
  125. package/src/components/textField/presets/underline.d.ts +106 -46
  126. package/src/components/textField/types.js +1 -0
  127. package/src/components/textField/usePreset.d.ts +72 -44
  128. package/src/components/timeline/types.js +3 -0
  129. package/src/{incubator/hooks/useHiddenLocation.web.d.ts → hooks/useHiddenLocation/index.d.ts} +1 -1
  130. package/src/{incubator/hooks/useHiddenLocation.d.ts → hooks/useHiddenLocation/index.web.d.ts} +1 -1
  131. package/src/incubator/expandableOverlay/ExpandableOverlay.driver.js +1 -1
  132. package/src/incubator/expandableOverlay/index.d.ts +42 -3
  133. package/src/incubator/expandableOverlay/index.js +1 -4
  134. package/src/incubator/index.d.ts +0 -2
  135. package/src/incubator/index.js +0 -2
  136. package/src/incubator/slider/SliderPresenter.js +2 -1
  137. package/src/incubator/toast/index.js +1 -1
  138. package/src/index.d.ts +3 -10
  139. package/src/index.js +42 -162
  140. package/src/testkit/index.d.ts +1 -1
  141. package/src/testkit/index.js +1 -1
  142. package/src/testkit/new/Component.driver.d.ts +4 -1
  143. package/src/testkit/new/Component.driver.js +3 -3
  144. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReactHacks.java +0 -30
  145. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReflectionUtils.java +0 -34
  146. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/DefaultKeyListener.java +0 -33
  147. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/KeyListenerProxy.java +0 -53
  148. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerModule.java +0 -54
  149. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerPackage.java +0 -28
  150. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/ViewUtils.java +0 -36
  151. package/lib/components/HighlighterOverlayView.js +0 -40
  152. package/lib/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.js +0 -28
  153. package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.d.ts +0 -11
  154. package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.js +0 -17
  155. package/panningViews.d.ts +0 -2
  156. package/panningViews.js +0 -1
  157. package/react-native.config.js +0 -22
  158. package/sharedTransition.d.ts +0 -2
  159. package/sharedTransition.js +0 -1
  160. package/src/components/dialog/DialogDismissibleView.d.ts +0 -34
  161. package/src/components/dialog/DialogDismissibleView.js +0 -184
  162. package/src/components/dialog/OverlayFadingBackground.d.ts +0 -14
  163. package/src/components/dialog/OverlayFadingBackground.js +0 -45
  164. package/src/components/panningViews/asPanViewConsumer.d.ts +0 -3
  165. package/src/components/panningViews/asPanViewConsumer.js +0 -16
  166. package/src/components/panningViews/panDismissibleView.d.ts +0 -51
  167. package/src/components/panningViews/panDismissibleView.js +0 -350
  168. package/src/components/panningViews/panGestureView.d.ts +0 -23
  169. package/src/components/panningViews/panGestureView.js +0 -156
  170. package/src/components/panningViews/panListenerView.d.ts +0 -66
  171. package/src/components/panningViews/panListenerView.js +0 -155
  172. package/src/components/panningViews/panResponderView.d.ts +0 -19
  173. package/src/components/panningViews/panResponderView.js +0 -79
  174. package/src/components/panningViews/panningContext.d.ts +0 -3
  175. package/src/components/panningViews/panningContext.js +0 -4
  176. package/src/components/panningViews/panningProvider.d.ts +0 -73
  177. package/src/components/panningViews/panningProvider.js +0 -101
  178. package/src/components/sharedTransition/ShareTransitionContext.js +0 -3
  179. package/src/components/sharedTransition/SharedArea.js +0 -153
  180. package/src/components/sharedTransition/SourceElement.js +0 -44
  181. package/src/components/sharedTransition/TargetElement.js +0 -38
  182. package/src/components/sharedTransition/index.js +0 -9
  183. package/src/incubator/dialog/dialog.api.json +0 -54
  184. package/src/incubator/dialog/index.d.ts +0 -15
  185. package/src/incubator/dialog/index.js +0 -218
  186. /package/lib/components/{HighlighterOverlayView.web.js → HighlighterOverlayView/index.web.js} +0 -0
  187. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.d.ts +0 -0
  188. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.js +0 -0
  189. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.d.ts +0 -0
  190. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.js +0 -0
  191. /package/lib/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.d.ts → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.d.ts} +0 -0
  192. /package/lib/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.js → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.js} +0 -0
  193. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.d.ts +0 -0
  194. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.js +0 -0
  195. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.d.ts +0 -0
  196. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.js +0 -0
  197. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.d.ts +0 -0
  198. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.js +0 -0
  199. /package/lib/components/Keyboard/{KeyboardTracking → KeyboardAwareInsetsView}/keyboardAwareInsetsView.api.json +0 -0
  200. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.d.ts +0 -0
  201. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.js +0 -0
  202. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.js +0 -0
  203. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.d.ts +0 -0
  204. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.js +0 -0
  205. /package/src/{incubator → components}/dialog/Dialog.driver.new.d.ts +0 -0
  206. /package/src/{incubator → components}/dialog/Dialog.driver.new.js +0 -0
  207. /package/src/{incubator → components}/dialog/DialogHeader.d.ts +0 -0
  208. /package/src/{incubator → components}/dialog/DialogHeader.js +0 -0
  209. /package/src/{incubator → components}/dialog/useDialogContent.js +0 -0
  210. /package/src/{incubator → components}/panView/panningUtil.d.ts +0 -0
  211. /package/src/{incubator → components}/panView/panningUtil.js +0 -0
  212. /package/src/{incubator → components}/panView/usePanGesture.js +0 -0
  213. /package/src/{incubator/hooks/useHiddenLocation.js → hooks/useHiddenLocation/index.js} +0 -0
  214. /package/src/{incubator/hooks/useHiddenLocation.web.js → hooks/useHiddenLocation/index.web.js} +0 -0
@@ -0,0 +1,274 @@
1
+ import {NativeModules, DeviceEventEmitter} from 'react-native';
2
+ import {DEFAULT_INSETS} from '../SafeAreaInsetsManager';
3
+
4
+ const MOCKED_INSETS = {top: 44, left: 0, bottom: 34, right: 0};
5
+
6
+ describe('SafeAreaInsetsManager', () => {
7
+ beforeEach(() => {
8
+ // Reset mocks
9
+ jest.clearAllMocks();
10
+
11
+ // Reset the SafeAreaInsetsCache by creating a fresh instance
12
+ jest.resetModules();
13
+
14
+ // Spy on console methods to verify logging
15
+ jest.spyOn(console, 'log').mockImplementation(() => {});
16
+ jest.spyOn(console, 'warn').mockImplementation(() => {});
17
+ });
18
+
19
+ afterEach(() => {
20
+ // Restore console methods
21
+ jest.restoreAllMocks();
22
+ });
23
+
24
+ describe('getSafeAreaInsets', () => {
25
+ it('should return default insets when native module is not available', async () => {
26
+ // Arrange
27
+ NativeModules.SafeAreaManager = null;
28
+ const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
29
+
30
+ // Act
31
+ const result = await SafeAreaInsetsManager.getSafeAreaInsets();
32
+
33
+ // Assert
34
+ expect(result).toEqual(DEFAULT_INSETS);
35
+ expect(console.log).toHaveBeenCalledWith('SafeAreaInsetsManager: Native SafeAreaManager not available, using defaults');
36
+ });
37
+
38
+ it('should return insets from native module when available', async () => {
39
+ // Arrange
40
+ const mockInsets = {top: 50, left: 10, bottom: 30, right: 10};
41
+ NativeModules.SafeAreaManager = {
42
+ getSafeAreaInsets: jest.fn().mockResolvedValue(mockInsets)
43
+ };
44
+
45
+ const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
46
+
47
+ // Act
48
+ const result = await SafeAreaInsetsManager.getSafeAreaInsets();
49
+
50
+ // Assert
51
+ expect(result).toEqual(mockInsets);
52
+ expect(NativeModules.SafeAreaManager.getSafeAreaInsets).toHaveBeenCalled();
53
+ });
54
+
55
+ it.skip('should return cached insets on subsequent calls', async () => {
56
+ // Arrange
57
+ const mockInsets = MOCKED_INSETS;
58
+ NativeModules.SafeAreaManager = {
59
+ getSafeAreaInsets: jest.fn().mockResolvedValue(mockInsets)
60
+ };
61
+
62
+ const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
63
+
64
+ // Act
65
+ const result1 = await SafeAreaInsetsManager.getSafeAreaInsets();
66
+ const result2 = await SafeAreaInsetsManager.getSafeAreaInsets();
67
+
68
+ // Assert
69
+ expect(result1).toEqual(mockInsets);
70
+ expect(result2).toEqual(mockInsets);
71
+ expect(NativeModules.SafeAreaManager.getSafeAreaInsets).toHaveBeenCalledTimes(1); // Should only call native once due to caching
72
+ });
73
+
74
+ it('should handle native module errors gracefully', async () => {
75
+ // Arrange
76
+ const mockError = new Error('Native module error');
77
+ NativeModules.SafeAreaManager = {
78
+ getSafeAreaInsets: jest.fn().mockRejectedValue(mockError)
79
+ };
80
+
81
+ const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
82
+
83
+ // Act
84
+ const result = await SafeAreaInsetsManager.getSafeAreaInsets();
85
+
86
+ // Assert
87
+ expect(result).toEqual(DEFAULT_INSETS); // Should fallback to defaults
88
+ expect(console.warn).toHaveBeenCalledWith('SafeAreaInsetsManager: Failed to get initial insets:', mockError);
89
+ expect(console.warn).toHaveBeenCalledWith('SafeAreaInsetsManager: Failed to get native insets:', mockError);
90
+ });
91
+
92
+ it('should handle native module setup errors gracefully', async () => {
93
+ // Arrange
94
+ Object.defineProperty(NativeModules, 'SafeAreaManager', {
95
+ get: () => {
96
+ throw new Error('Setup error');
97
+ }
98
+ });
99
+
100
+ const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
101
+
102
+ // Act
103
+ const result = await SafeAreaInsetsManager.getSafeAreaInsets();
104
+
105
+ // Assert
106
+ expect(result).toEqual(DEFAULT_INSETS); // Should fallback to defaults
107
+ expect(console.warn).toHaveBeenCalledWith('SafeAreaInsetsManager: Failed to connect to native module:', expect.any(Error));
108
+ });
109
+
110
+ it('should update insets when they change during the test', async () => {
111
+ // Arrange
112
+ const initialInsets = MOCKED_INSETS;
113
+ const updatedInsets = {top: 50, left: 0, bottom: 40, right: 0};
114
+
115
+ NativeModules.SafeAreaManager = {
116
+ // TODO: this will need to be changed when the we get caching to work in tests ("should return cached insets on subsequent calls")
117
+ // getSafeAreaInsets: jest.fn().mockResolvedValueOnce(initialInsets).mockResolvedValueOnce(updatedInsets)
118
+ getSafeAreaInsets: jest
119
+ .fn()
120
+ .mockResolvedValueOnce(initialInsets)
121
+ .mockResolvedValueOnce(initialInsets)
122
+ .mockResolvedValueOnce(updatedInsets)
123
+ };
124
+
125
+ const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
126
+
127
+ // Act & Assert - Initial insets
128
+ const result1 = await SafeAreaInsetsManager.getSafeAreaInsets();
129
+ expect(result1).toEqual(initialInsets);
130
+
131
+ // Force refresh of insets
132
+ await SafeAreaInsetsManager.refreshSafeAreaInsets();
133
+
134
+ // Simulate insets change event from native side
135
+ DeviceEventEmitter.emit('SafeAreaInsetsDidChangeEvent', updatedInsets);
136
+
137
+ // Get insets again - should reflect the change
138
+ const result2 = await SafeAreaInsetsManager.getSafeAreaInsets();
139
+ expect(result2).toEqual(updatedInsets);
140
+ });
141
+
142
+ it('should notify delegates when insets change during the test', async () => {
143
+ // Arrange
144
+ const initialInsets = MOCKED_INSETS;
145
+ const updatedInsets = {top: 50, left: 0, bottom: 40, right: 0};
146
+
147
+ NativeModules.SafeAreaManager = {
148
+ getSafeAreaInsets: jest.fn().mockResolvedValue(initialInsets)
149
+ };
150
+
151
+ const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
152
+
153
+ // Add a mock delegate
154
+ const mockDelegate = {
155
+ onSafeAreaInsetsDidChangeEvent: jest.fn()
156
+ };
157
+ SafeAreaInsetsManager.addSafeAreaChangedDelegate(mockDelegate);
158
+
159
+ // Act - Get initial insets
160
+ await SafeAreaInsetsManager.getSafeAreaInsets();
161
+
162
+ // Simulate insets change event from native side
163
+ DeviceEventEmitter.emit('SafeAreaInsetsDidChangeEvent', updatedInsets);
164
+
165
+ // Assert - Delegate should be notified
166
+ expect(mockDelegate.onSafeAreaInsetsDidChangeEvent).toHaveBeenCalledWith(updatedInsets);
167
+ });
168
+
169
+ it('should handle refreshSafeAreaInsets correctly', async () => {
170
+ // Arrange
171
+ const initialInsets = MOCKED_INSETS;
172
+ const refreshedInsets = {top: 48, left: 0, bottom: 36, right: 0};
173
+
174
+ NativeModules.SafeAreaManager = {
175
+ // TODO: this will need to be changed when the we get caching to work in tests ("should return cached insets on subsequent calls")
176
+ // getSafeAreaInsets: jest.fn().mockResolvedValueOnce(initialInsets).mockResolvedValueOnce(updatedInsets)
177
+ getSafeAreaInsets: jest
178
+ .fn()
179
+ .mockResolvedValueOnce(initialInsets)
180
+ .mockResolvedValueOnce(initialInsets)
181
+ .mockResolvedValueOnce(refreshedInsets)
182
+ };
183
+
184
+ const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
185
+
186
+ // Act
187
+ const result1 = await SafeAreaInsetsManager.getSafeAreaInsets();
188
+ expect(result1).toEqual(initialInsets);
189
+
190
+ // Refresh insets
191
+ await SafeAreaInsetsManager.refreshSafeAreaInsets();
192
+
193
+ const result2 = await SafeAreaInsetsManager.getSafeAreaInsets();
194
+
195
+ // Assert
196
+ expect(result2).toEqual(refreshedInsets);
197
+ // TODO: this will need to be changed when the we get caching to work in tests ("should return cached insets on subsequent calls")
198
+ expect(NativeModules.SafeAreaManager.getSafeAreaInsets).toHaveBeenCalledTimes(3);
199
+ });
200
+
201
+ it('should not notify delegates when insets remain the same after refresh', async () => {
202
+ // Arrange
203
+ const sameInsets = MOCKED_INSETS;
204
+
205
+ NativeModules.SafeAreaManager = {
206
+ getSafeAreaInsets: jest.fn().mockResolvedValue(sameInsets)
207
+ };
208
+
209
+ const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
210
+
211
+ // Add a mock delegate
212
+ const mockDelegate = {
213
+ onSafeAreaInsetsDidChangeEvent: jest.fn()
214
+ };
215
+ SafeAreaInsetsManager.addSafeAreaChangedDelegate(mockDelegate);
216
+
217
+ // Act
218
+ await SafeAreaInsetsManager.getSafeAreaInsets();
219
+ await SafeAreaInsetsManager.refreshSafeAreaInsets();
220
+
221
+ // TODO: this will need to be changed when the we get caching to work in tests ("should return cached insets on subsequent calls")
222
+ expect(NativeModules.SafeAreaManager.getSafeAreaInsets).toHaveBeenCalledTimes(3);
223
+
224
+ // Assert - Delegate should not be notified since insets didn't change
225
+ expect(mockDelegate.onSafeAreaInsetsDidChangeEvent).not.toHaveBeenCalled();
226
+ });
227
+
228
+ it('should return default insets when native getSafeAreaInsets returns null', async () => {
229
+ // Arrange
230
+ NativeModules.SafeAreaManager = {
231
+ getSafeAreaInsets: jest.fn().mockResolvedValue(null)
232
+ };
233
+
234
+ const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
235
+
236
+ // Act
237
+ const result = await SafeAreaInsetsManager.getSafeAreaInsets();
238
+
239
+ // Assert
240
+ expect(result).toEqual(DEFAULT_INSETS);
241
+ });
242
+
243
+ it('should properly manage delegate lifecycle', async () => {
244
+ // Arrange
245
+ NativeModules.SafeAreaManager = {
246
+ getSafeAreaInsets: jest.fn().mockResolvedValue(MOCKED_INSETS)
247
+ };
248
+
249
+ const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
250
+
251
+ const mockDelegate1 = {
252
+ onSafeAreaInsetsDidChangeEvent: jest.fn()
253
+ };
254
+ const mockDelegate2 = {
255
+ onSafeAreaInsetsDidChangeEvent: jest.fn()
256
+ };
257
+
258
+ // Act
259
+ SafeAreaInsetsManager.addSafeAreaChangedDelegate(mockDelegate1);
260
+ SafeAreaInsetsManager.addSafeAreaChangedDelegate(mockDelegate2);
261
+
262
+ // Remove one delegate
263
+ SafeAreaInsetsManager.removeSafeAreaChangedDelegate(mockDelegate1);
264
+
265
+ // Trigger notification
266
+ const newInsets = MOCKED_INSETS;
267
+ SafeAreaInsetsManager.notifyDelegates(newInsets);
268
+
269
+ // Assert
270
+ expect(mockDelegate1.onSafeAreaInsetsDidChangeEvent).not.toHaveBeenCalled();
271
+ expect(mockDelegate2.onSafeAreaInsetsDidChangeEvent).toHaveBeenCalledWith(newInsets);
272
+ });
273
+ });
274
+ });
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { ViewStyle, StyleProp } from 'react-native';
3
+ export type SafeAreaSpacerViewProps = {
4
+ style?: StyleProp<ViewStyle>;
5
+ };
6
+ declare const SafeAreaSpacerView: {
7
+ ({ style }: SafeAreaSpacerViewProps): React.JSX.Element;
8
+ displayName: string;
9
+ };
10
+ export default SafeAreaSpacerView;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { View, Platform } from 'react-native';
3
+ import SafeAreaSpacerViewIos from "./SafeAreaSpacerView";
4
+ const isIOS = Platform.OS === 'ios';
5
+ const SafeAreaSpacerView = ({
6
+ style
7
+ }) => {
8
+ return isIOS ? <SafeAreaSpacerViewIos style={style} /> : <View style={style} />;
9
+ };
10
+ SafeAreaSpacerView.displayName = 'SafeAreaSpacerView';
11
+ export default SafeAreaSpacerView;
@@ -1,6 +1,6 @@
1
1
  import DynamicFonts, { FontExtension } from './DynamicFonts';
2
2
  import HighlighterOverlayView from './HighlighterOverlayView';
3
- import SafeAreaSpacerView from './SafeArea/SafeAreaSpacerView';
3
+ import SafeAreaSpacerView from './SafeArea';
4
4
  import SafeAreaInsetsManager from './SafeArea/SafeAreaInsetsManager';
5
5
  import Keyboard, { KeyboardTrackingViewProps, KeyboardAccessoryViewProps } from './Keyboard';
6
6
  export { DynamicFonts, FontExtension, HighlighterOverlayView, SafeAreaSpacerView, SafeAreaInsetsManager, Keyboard, KeyboardTrackingViewProps, KeyboardAccessoryViewProps };
@@ -1,6 +1,6 @@
1
1
  import DynamicFonts, { FontExtension } from "./DynamicFonts";
2
2
  import HighlighterOverlayView from "./HighlighterOverlayView";
3
- import SafeAreaSpacerView from "./SafeArea/SafeAreaSpacerView";
3
+ import SafeAreaSpacerView from "./SafeArea";
4
4
  import SafeAreaInsetsManager from "./SafeArea/SafeAreaInsetsManager";
5
5
  import Keyboard, { KeyboardTrackingViewProps, KeyboardAccessoryViewProps } from "./Keyboard";
6
6
  export { DynamicFonts, FontExtension, HighlighterOverlayView, SafeAreaSpacerView, SafeAreaInsetsManager, Keyboard, KeyboardTrackingViewProps, KeyboardAccessoryViewProps };
@@ -13,6 +13,12 @@
13
13
 
14
14
  #import "LNAnimatorTemp.h"
15
15
 
16
+ #if __has_include(<React-RCTAppDelegate/RCTAppDelegate.h>)
17
+ #import <React-RCTAppDelegate/RCTAppDelegate.h>
18
+ #elif __has_include(<React_RCTAppDelegate/RCTAppDelegate.h>)
19
+ #import <React_RCTAppDelegate/RCTAppDelegate.h>
20
+ #endif
21
+
16
22
  #define kHlperViewTag 0x1f1f1f
17
23
 
18
24
  NSString *const RCTCustomInputControllerKeyboardResigendEventTemp = @"kbdResigned";
@@ -49,7 +55,6 @@ NSString *const RCTCustomInputControllerKeyboardResigendEventTemp = @"kbdResigne
49
55
  {
50
56
  [self.delegate _WXInputHelperViewResignFirstResponder:self];
51
57
  }
52
-
53
58
  }
54
59
 
55
60
  return rv;
@@ -118,17 +123,36 @@ RCT_EXPORT_MODULE(CustomInputControllerTemp)
118
123
  return [params[@"useSafeArea"] isEqual:@(1)];
119
124
  }
120
125
 
126
+ - (UITextField*)getTextFieldFromTextInputComponentView:(id)inputField {
127
+ UITextField *textField = nil;
128
+
129
+ if ([inputField isKindOfClass:NSClassFromString(@"RCTTextInputComponentView")])
130
+ {
131
+ Ivar textFieldIvar = class_getInstanceVariable([inputField class], "_backedTextInputView");
132
+ if (textFieldIvar != NULL)
133
+ {
134
+ textField = [inputField valueForKey:@"_backedTextInputView"];
135
+ }
136
+ }
137
+
138
+ return textField;
139
+ }
140
+
121
141
  RCT_EXPORT_METHOD(presentCustomInputComponent:(nonnull NSNumber*)inputFieldTag params:(nonnull NSDictionary*)params)
122
142
  {
123
143
  RCTBridge* bridge = [self.bridge valueForKey:@"parentBridge"];
124
144
  if(bridge == nil)
125
145
  {
126
- return;
146
+ bridge = self.bridge;
127
147
  }
128
148
 
129
149
  UIView* inputField = [self.bridge.uiManager viewForReactTag:inputFieldTag];
130
150
  NSDictionary *initialProps = params[@"initialProps"];
131
- RCTRootView* rv = [[RCTRootView alloc] initWithBridge:bridge moduleName:params[@"component"] initialProperties:initialProps];
151
+
152
+ RCTAppDelegate* appDelegate = (RCTAppDelegate*)[UIApplication sharedApplication].delegate;
153
+ UIView *rv = [appDelegate.rootViewFactory viewWithModuleName:params[@"component"]
154
+ initialProperties:initialProps];
155
+
132
156
  if(initialProps != nil && initialProps[@"backgroundColor"] != nil)
133
157
  {
134
158
  UIColor *backgroundColor = [RCTConvert UIColor:initialProps[@"backgroundColor"]];
@@ -148,7 +172,17 @@ RCT_EXPORT_METHOD(presentCustomInputComponent:(nonnull NSNumber*)inputFieldTag p
148
172
  helperView.tag = kHlperViewTag;
149
173
  helperView.delegate = self;
150
174
 
151
- if ([inputField isKindOfClass:NSClassFromString(@"RCTTextView")])
175
+
176
+
177
+ if ([inputField isKindOfClass:NSClassFromString(@"RCTTextInputComponentView")])
178
+ {
179
+ UITextField *textField = [self getTextFieldFromTextInputComponentView:inputField];
180
+ if (textField != nil)
181
+ {
182
+ helperView.inputAccessoryView = textField.inputAccessoryView;
183
+ }
184
+ }
185
+ else if ([inputField isKindOfClass:NSClassFromString(@"RCTTextView")])
152
186
  {
153
187
  UITextView *textView = nil;
154
188
  Ivar backedTextInputIvar = class_getInstanceVariable([inputField class], "_backedTextInput");
@@ -213,7 +247,17 @@ RCT_EXPORT_METHOD(resetInput:(nonnull NSNumber*)inputFieldTag)
213
247
  _WXInputHelperViewTemp* helperView = [inputField.superview viewWithTag:kHlperViewTag];
214
248
  if(helperView != nil && [helperView isFirstResponder])
215
249
  {//restore the first responder only if it was already the first responder to prevent the keyboard from opening again if not necessary
216
- [inputField reactFocus];
250
+ if ([inputField isKindOfClass:NSClassFromString(@"RCTTextInputComponentView")])
251
+ {
252
+ UITextField *textField = [self getTextFieldFromTextInputComponentView:inputField];
253
+ if (textField != nil)
254
+ {
255
+ [textField reactFocus];
256
+ }
257
+
258
+ } else {
259
+ [inputField reactFocus];
260
+ }
217
261
  }
218
262
  }
219
263
  }
@@ -251,7 +295,7 @@ RCT_EXPORT_METHOD(dismissKeyboard)
251
295
  }
252
296
  }
253
297
 
254
- -(UIColor*)reactViewAvgColor:(RCTRootView*)rootView
298
+ -(UIColor*)reactViewAvgColor:(UIView*)rootView
255
299
  {
256
300
  if (rootView.frame.size.width == 0 || rootView.frame.size.height == 0)
257
301
  {
@@ -296,7 +340,7 @@ RCT_EXPORT_METHOD(expandFullScreenForInput:(nonnull NSNumber*)inputFieldTag)
296
340
  helperView.keepInSuperviewOnResign = YES;
297
341
 
298
342
  RCTCustomKeyboardViewControllerTemp *customKeyboardViewController = (RCTCustomKeyboardViewControllerTemp*)helperView.inputViewController;
299
- RCTRootView *rv = customKeyboardViewController.rootView;
343
+ UIView *rv = customKeyboardViewController.rootView;
300
344
  UIInputView *inputView = helperView.inputViewController.inputView;
301
345
 
302
346
  _fullScreenWindow = [[UIWindow alloc] initWithFrame:[inputView.window convertRect:inputView.bounds fromView:inputView]];
@@ -370,7 +414,7 @@ RCT_EXPORT_METHOD(resetSizeForInput:(nonnull NSNumber*)inputFieldTag)
370
414
  completionHandler:^(BOOL completed)
371
415
  {
372
416
  RCTCustomKeyboardViewControllerTemp *customKeyboardViewController = (RCTCustomKeyboardViewControllerTemp*)helperView.inputViewController;
373
- RCTRootView *rv = (RCTRootView*)_fullScreenWindow.rootViewController.view;
417
+ UIView *rv = _fullScreenWindow.rootViewController.view;
374
418
 
375
419
  [UIView performWithoutAnimation:^{
376
420
 
@@ -388,6 +432,8 @@ RCT_EXPORT_METHOD(resetSizeForInput:(nonnull NSNumber*)inputFieldTag)
388
432
  }
389
433
  }
390
434
 
435
+
436
+
391
437
  #pragma mark - _WXInputHelperViewDelegateTemp methods
392
438
 
393
439
  -(void)_WXInputHelperViewResignFirstResponder:(UIView*)wxInputHelperView
@@ -397,6 +443,8 @@ RCT_EXPORT_METHOD(resetSizeForInput:(nonnull NSNumber*)inputFieldTag)
397
443
  [self sendEventWithName:RCTCustomInputControllerKeyboardResigendEventTemp body:nil];
398
444
  }
399
445
  self.customInputComponentPresented = NO;
446
+
447
+
400
448
  }
401
449
 
402
450
  @end
@@ -7,18 +7,12 @@
7
7
 
8
8
  #import <UIKit/UIKit.h>
9
9
 
10
- #if __has_include(<React/RCTRootView.h>)
11
- #import <React/RCTRootView.h>
12
- #else
13
- #import "RCTRootView.h"
14
- #endif
15
-
16
10
  @interface RCTCustomKeyboardViewControllerTemp : UIInputViewController
17
11
 
18
12
  - (void) setAllowsSelfSizing:(BOOL)allowsSelfSizing;
19
13
  - (instancetype)initWithUsingSafeArea:(BOOL)useSafeArea;
20
14
 
21
15
  @property (nonatomic, strong) NSLayoutConstraint *heightConstraint;
22
- @property (nonatomic, strong) RCTRootView *rootView;
16
+ @property (nonatomic, strong) UIView *rootView;
23
17
 
24
18
  @end
@@ -57,7 +57,7 @@
57
57
  }
58
58
  }
59
59
 
60
- -(void)setRootView:(RCTRootView*)rootView
60
+ -(void)setRootView:(UIView*)rootView
61
61
  {
62
62
  if(_rootView != nil)
63
63
  {