react-native-ui-lib 7.46.2-snapshot.7314 → 7.46.2-snapshot.7316

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 (199) hide show
  1. package/babel.config.js +0 -12
  2. package/index.js +0 -1
  3. package/lib/android/build.gradle +5 -5
  4. package/lib/android/src/main/java/com/wix/reactnativeuilib/UiLibPackageList.java +2 -0
  5. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager.java +23 -31
  6. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReactHacks.java +30 -0
  7. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReflectionUtils.java +34 -0
  8. package/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java +1 -1
  9. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/DefaultKeyListener.java +33 -0
  10. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/KeyListenerProxy.java +53 -0
  11. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerModule.java +54 -0
  12. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerPackage.java +28 -0
  13. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/ViewUtils.java +36 -0
  14. package/lib/components/{HighlighterOverlayView/index.d.ts → HighlighterOverlayView.d.ts} +1 -1
  15. package/lib/components/HighlighterOverlayView.js +40 -0
  16. package/lib/components/{HighlighterOverlayView/index.web.d.ts → HighlighterOverlayView.web.d.ts} +1 -1
  17. package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/CustomKeyboardView.android.d.ts +2 -5
  18. package/lib/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.js +28 -0
  19. package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/CustomKeyboardView.ios.d.ts +1 -1
  20. package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/CustomKeyboardView.ios.js +3 -3
  21. package/lib/components/Keyboard/{KeyboardAccessoryView/CustomKeyboardView → KeyboardInput}/CustomKeyboardViewBase.d.ts +0 -3
  22. package/lib/components/Keyboard/{KeyboardAccessoryView/CustomKeyboardView → KeyboardInput}/CustomKeyboardViewBase.js +1 -1
  23. package/lib/components/Keyboard/{KeyboardAccessoryView/index.d.ts → KeyboardInput/KeyboardAccessoryView.d.ts} +1 -11
  24. package/lib/components/Keyboard/{KeyboardAccessoryView/index.js → KeyboardInput/KeyboardAccessoryView.js} +5 -31
  25. package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/index.d.ts → KeyboardInput/KeyboardRegistry.d.ts} +1 -1
  26. package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/index.js → KeyboardInput/KeyboardRegistry.js} +1 -1
  27. package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry → KeyboardInput}/__tests__/KeyboardRegistry.spec.js +1 -1
  28. package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/keyboardAccessoryView.api.json +5 -5
  29. package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry → KeyboardInput}/keyboardRegistry.api.json +9 -9
  30. package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.d.ts +11 -0
  31. package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.js +17 -0
  32. package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager → KeyboardInput/utils}/__tests__/EventEmitterManager.spec.js +1 -1
  33. package/lib/components/Keyboard/{KeyboardAwareInsetsView/index.d.ts → KeyboardTracking/KeyboardAwareInsetsView.d.ts} +1 -1
  34. package/lib/components/Keyboard/{KeyboardAwareInsetsView/index.js → KeyboardTracking/KeyboardAwareInsetsView.js} +1 -1
  35. package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/KeyboardTrackingView.ios.d.ts +4 -1
  36. package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/KeyboardTrackingView.ios.js +8 -5
  37. package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/index.d.ts +2 -2
  38. package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/keyboardTrackingView.api.json +20 -11
  39. package/lib/components/Keyboard/index.d.ts +6 -6
  40. package/lib/components/Keyboard/index.js +6 -6
  41. package/lib/components/SafeArea/SafeAreaInsetsManager.d.ts +7 -21
  42. package/lib/components/SafeArea/SafeAreaInsetsManager.js +31 -95
  43. package/lib/components/SafeArea/SafeAreaSpacerView.d.ts +2 -2
  44. package/lib/components/SafeArea/SafeAreaSpacerView.js +9 -63
  45. package/lib/components/index.d.ts +1 -1
  46. package/lib/components/index.js +1 -1
  47. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomInputControllerTemp.m +8 -52
  48. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.h +7 -1
  49. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.m +1 -1
  50. package/lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m +41 -109
  51. package/lib/package.json +1 -1
  52. package/lib/react-native.config.js +3 -1
  53. package/metro.config.js +2 -2
  54. package/package.json +24 -24
  55. package/panningViews.d.ts +2 -0
  56. package/panningViews.js +1 -0
  57. package/react-native.config.js +3 -1
  58. package/sharedTransition.d.ts +2 -0
  59. package/sharedTransition.js +1 -0
  60. package/src/commons/Constants.js +5 -2
  61. package/src/components/KeyboardAwareScrollView/KeyboardAwareBase.js +1 -5
  62. package/src/components/actionSheet/index.d.ts +12 -2
  63. package/src/components/actionSheet/index.js +42 -3
  64. package/src/components/badge/index.d.ts +47 -107
  65. package/src/components/button/button.api.json +6 -1
  66. package/src/components/button/index.d.ts +31 -53
  67. package/src/components/button/index.js +18 -1
  68. package/src/components/button/types.d.ts +5 -0
  69. package/src/components/colorPicker/ColorPickerDialog.d.ts +1 -1
  70. package/src/components/colorPicker/ColorPickerDialog.js +1 -1
  71. package/src/components/dateTimePicker/index.d.ts +5 -186
  72. package/src/components/dateTimePicker/index.js +4 -3
  73. package/src/components/dialog/DialogDismissibleView.d.ts +34 -0
  74. package/src/components/dialog/DialogDismissibleView.js +184 -0
  75. package/src/components/dialog/OverlayFadingBackground.d.ts +14 -0
  76. package/src/components/dialog/OverlayFadingBackground.js +45 -0
  77. package/src/components/dialog/dialog.api.json +37 -31
  78. package/src/components/dialog/index.d.ts +105 -13
  79. package/src/components/dialog/index.js +212 -204
  80. package/src/components/drawer/Swipeable.js +2 -1
  81. package/src/components/drawer/index.js +25 -31
  82. package/src/components/fadedScrollView/index.js +2 -7
  83. package/src/components/featureHighlight/index.d.ts +1 -1
  84. package/src/components/index.js +19 -0
  85. package/src/components/modal/index.d.ts +0 -5
  86. package/src/components/modal/index.js +10 -14
  87. package/src/components/modal/modal.api.json +0 -5
  88. package/src/components/panningViews/asPanViewConsumer.d.ts +3 -0
  89. package/src/components/panningViews/asPanViewConsumer.js +16 -0
  90. package/src/components/panningViews/panDismissibleView.d.ts +51 -0
  91. package/src/components/panningViews/panDismissibleView.js +350 -0
  92. package/src/components/panningViews/panGestureView.d.ts +23 -0
  93. package/src/components/panningViews/panGestureView.js +156 -0
  94. package/src/components/panningViews/panListenerView.d.ts +66 -0
  95. package/src/components/panningViews/panListenerView.js +155 -0
  96. package/src/components/panningViews/panResponderView.d.ts +19 -0
  97. package/src/components/panningViews/panResponderView.js +79 -0
  98. package/src/components/panningViews/panningContext.d.ts +3 -0
  99. package/src/components/panningViews/panningContext.js +4 -0
  100. package/src/components/panningViews/panningProvider.d.ts +73 -0
  101. package/src/components/panningViews/panningProvider.js +101 -0
  102. package/src/components/picker/Picker.driver.new.d.ts +2 -2
  103. package/src/components/picker/Picker.driver.new.js +3 -3
  104. package/src/components/picker/PickerItem.js +20 -6
  105. package/src/components/picker/PickerPresenter.d.ts +1 -0
  106. package/src/components/picker/PickerPresenter.js +23 -1
  107. package/src/components/picker/api/picker.api.json +1 -0
  108. package/src/components/picker/api/pickerItem.api.json +5 -0
  109. package/src/components/picker/helpers/useFieldType.d.ts +23 -53
  110. package/src/components/picker/helpers/usePickerLabel.d.ts +1 -1
  111. package/src/components/picker/helpers/usePickerLabel.js +3 -2
  112. package/src/components/picker/helpers/usePickerMigrationWarnings.d.ts +1 -1
  113. package/src/components/picker/helpers/usePickerMigrationWarnings.js +12 -0
  114. package/src/components/picker/helpers/usePickerSearch.d.ts +1 -1
  115. package/src/components/picker/helpers/usePickerSearch.js +8 -4
  116. package/src/components/picker/helpers/usePickerSelection.d.ts +1 -1
  117. package/src/components/picker/helpers/usePickerSelection.js +10 -2
  118. package/src/components/picker/index.js +22 -4
  119. package/src/components/picker/types.d.ts +24 -1
  120. package/src/components/segmentedControl/index.js +3 -3
  121. package/src/components/sharedTransition/ShareTransitionContext.js +3 -0
  122. package/src/components/sharedTransition/SharedArea.js +153 -0
  123. package/src/components/sharedTransition/SourceElement.js +44 -0
  124. package/src/components/sharedTransition/TargetElement.js +38 -0
  125. package/src/components/sharedTransition/index.js +9 -0
  126. package/src/components/slider/GradientSlider.d.ts +1 -1
  127. package/src/components/sortableGridList/SortableItem.js +4 -13
  128. package/src/components/sortableList/SortableListItem.js +4 -13
  129. package/src/components/stackAggregator/index.js +11 -16
  130. package/src/components/text/Text.driver.new.d.ts +2 -2
  131. package/src/components/text/Text.driver.new.js +2 -2
  132. package/src/components/textField/Input.js +1 -0
  133. package/src/components/textField/TextField.driver.new.d.ts +2 -2
  134. package/src/components/textField/TextField.driver.new.js +2 -2
  135. package/src/components/textField/presets/outline.d.ts +46 -106
  136. package/src/components/textField/presets/underline.d.ts +46 -106
  137. package/src/components/textField/usePreset.d.ts +44 -72
  138. package/src/incubator/dialog/dialog.api.json +54 -0
  139. package/src/{components → incubator}/dialog/dialogHeader.api.json +2 -2
  140. package/src/incubator/dialog/index.d.ts +15 -0
  141. package/src/incubator/dialog/index.js +218 -0
  142. package/src/{components → incubator}/dialog/types.d.ts +19 -0
  143. package/src/{components → incubator}/dialog/types.js +3 -1
  144. package/src/{components → incubator}/dialog/useDialogContent.d.ts +1 -1
  145. package/src/incubator/expandableOverlay/ExpandableOverlay.driver.js +1 -1
  146. package/src/incubator/expandableOverlay/index.d.ts +3 -42
  147. package/src/incubator/expandableOverlay/index.js +4 -1
  148. package/src/{hooks/useHiddenLocation/index.d.ts → incubator/hooks/useHiddenLocation.d.ts} +1 -1
  149. package/src/{hooks/useHiddenLocation/index.web.d.ts → incubator/hooks/useHiddenLocation.web.d.ts} +1 -1
  150. package/src/incubator/index.d.ts +2 -0
  151. package/src/incubator/index.js +2 -0
  152. package/src/{components → incubator}/panView/index.d.ts +3 -3
  153. package/src/{components → incubator}/panView/index.js +4 -4
  154. package/src/{components → incubator}/panView/usePanGesture.d.ts +1 -1
  155. package/src/incubator/toast/index.js +1 -1
  156. package/src/index.d.ts +10 -3
  157. package/src/index.js +160 -41
  158. package/src/testkit/index.d.ts +1 -1
  159. package/src/testkit/index.js +1 -1
  160. package/src/testkit/new/Component.driver.d.ts +1 -4
  161. package/src/testkit/new/Component.driver.js +3 -3
  162. package/lib/components/HighlighterOverlayView/index.js +0 -49
  163. package/lib/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.android.js +0 -51
  164. package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.d.ts +0 -26
  165. package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.js +0 -91
  166. package/lib/components/SafeArea/__tests__/SafeAreaInsetsManager.spec.js +0 -274
  167. package/lib/components/SafeArea/index.d.ts +0 -10
  168. package/lib/components/SafeArea/index.js +0 -11
  169. package/panView.d.ts +0 -2
  170. package/panView.js +0 -1
  171. /package/lib/components/{HighlighterOverlayView/index.web.js → HighlighterOverlayView.web.js} +0 -0
  172. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/index.d.ts +0 -0
  173. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/index.js +0 -0
  174. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/index.web.d.ts +0 -0
  175. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/CustomKeyboardView/index.web.js +0 -0
  176. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/TextInputKeyboardManager.android.d.ts +0 -0
  177. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/TextInputKeyboardManager.android.js +0 -0
  178. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/TextInputKeyboardManager.ios.d.ts +0 -0
  179. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/TextInputKeyboardManager.ios.js +0 -0
  180. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/index.d.ts +0 -0
  181. /package/lib/components/Keyboard/{KeyboardAccessoryView → KeyboardInput}/TextInputKeyboardManager/index.js +0 -0
  182. /package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.d.ts → KeyboardInput/utils/EventEmitterManager.d.ts} +0 -0
  183. /package/lib/components/Keyboard/{KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.js → KeyboardInput/utils/EventEmitterManager.js} +0 -0
  184. /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/KeyboardTrackingView.android.d.ts +0 -0
  185. /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/KeyboardTrackingView.android.js +0 -0
  186. /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/index.js +0 -0
  187. /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/index.web.d.ts +0 -0
  188. /package/lib/components/Keyboard/{KeyboardTrackingView → KeyboardTracking/KeyboardTrackingView}/index.web.js +0 -0
  189. /package/lib/components/Keyboard/{KeyboardAwareInsetsView → KeyboardTracking}/keyboardAwareInsetsView.api.json +0 -0
  190. /package/src/{components → incubator}/dialog/Dialog.driver.new.d.ts +0 -0
  191. /package/src/{components → incubator}/dialog/Dialog.driver.new.js +0 -0
  192. /package/src/{components → incubator}/dialog/DialogHeader.d.ts +0 -0
  193. /package/src/{components → incubator}/dialog/DialogHeader.js +0 -0
  194. /package/src/{components → incubator}/dialog/useDialogContent.js +0 -0
  195. /package/src/{hooks/useHiddenLocation/index.js → incubator/hooks/useHiddenLocation.js} +0 -0
  196. /package/src/{hooks/useHiddenLocation/index.web.js → incubator/hooks/useHiddenLocation.web.js} +0 -0
  197. /package/src/{components → incubator}/panView/panningUtil.d.ts +0 -0
  198. /package/src/{components → incubator}/panView/panningUtil.js +0 -0
  199. /package/src/{components → incubator}/panView/usePanGesture.js +0 -0
@@ -1,274 +0,0 @@
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
- });
@@ -1,10 +0,0 @@
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;
@@ -1,11 +0,0 @@
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;
package/panView.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import {PanView} from './src';
2
- export default PanView;
package/panView.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('./src/components/panView').default;