uilib-native 5.0.0-snapshot.7240 → 5.0.0-snapshot.7257

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.
@@ -7,6 +7,12 @@ export type SafeAreaInsetsType = {
7
7
  export type SafeAreaChangedDelegateType = {
8
8
  onSafeAreaInsetsDidChangeEvent?: (insets: SafeAreaInsetsType) => void;
9
9
  };
10
+ export declare const DEFAULT_INSETS: {
11
+ top: number;
12
+ left: number;
13
+ bottom: number;
14
+ right: number;
15
+ };
10
16
  declare class SafeAreaInsetsManager {
11
17
  _defaultInsets: SafeAreaInsetsType;
12
18
  _safeAreaInsets: SafeAreaInsetsType;
@@ -3,14 +3,15 @@ import _remove from "lodash/remove";
3
3
  import _forEach from "lodash/forEach";
4
4
  /* eslint no-underscore-dangle: 0 */
5
5
  import { NativeModules, DeviceEventEmitter } from 'react-native';
6
+ export const DEFAULT_INSETS = {
7
+ top: 47,
8
+ left: 0,
9
+ bottom: 34,
10
+ right: 0
11
+ };
6
12
  let SafeAreaInsetsCache = null;
7
13
  class SafeAreaInsetsManager {
8
- _defaultInsets = {
9
- top: 47,
10
- left: 0,
11
- bottom: 34,
12
- right: 0
13
- }; // Common iPhone safe area values
14
+ _defaultInsets = DEFAULT_INSETS; // Common iPhone safe area values
14
15
 
15
16
  _safeAreaChangedDelegates = [];
16
17
  _nativeModule = null;
@@ -1,4 +1,7 @@
1
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};
2
5
 
3
6
  describe('SafeAreaInsetsManager', () => {
4
7
  beforeEach(() => {
@@ -28,7 +31,7 @@ describe('SafeAreaInsetsManager', () => {
28
31
  const result = await SafeAreaInsetsManager.getSafeAreaInsets();
29
32
 
30
33
  // Assert
31
- expect(result).toEqual({top: 47, left: 0, bottom: 34, right: 0});
34
+ expect(result).toEqual(DEFAULT_INSETS);
32
35
  expect(console.log).toHaveBeenCalledWith('SafeAreaInsetsManager: Native SafeAreaManager not available, using defaults');
33
36
  });
34
37
 
@@ -51,7 +54,7 @@ describe('SafeAreaInsetsManager', () => {
51
54
 
52
55
  it.skip('should return cached insets on subsequent calls', async () => {
53
56
  // Arrange
54
- const mockInsets = {top: 44, left: 0, bottom: 34, right: 0};
57
+ const mockInsets = MOCKED_INSETS;
55
58
  NativeModules.SafeAreaManager = {
56
59
  getSafeAreaInsets: jest.fn().mockResolvedValue(mockInsets)
57
60
  };
@@ -81,7 +84,7 @@ describe('SafeAreaInsetsManager', () => {
81
84
  const result = await SafeAreaInsetsManager.getSafeAreaInsets();
82
85
 
83
86
  // Assert
84
- expect(result).toEqual({top: 47, left: 0, bottom: 34, right: 0}); // Should fallback to defaults
87
+ expect(result).toEqual(DEFAULT_INSETS); // Should fallback to defaults
85
88
  expect(console.warn).toHaveBeenCalledWith('SafeAreaInsetsManager: Failed to get initial insets:', mockError);
86
89
  expect(console.warn).toHaveBeenCalledWith('SafeAreaInsetsManager: Failed to get native insets:', mockError);
87
90
  });
@@ -100,13 +103,13 @@ describe('SafeAreaInsetsManager', () => {
100
103
  const result = await SafeAreaInsetsManager.getSafeAreaInsets();
101
104
 
102
105
  // Assert
103
- expect(result).toEqual({top: 47, left: 0, bottom: 34, right: 0}); // Should fallback to defaults
106
+ expect(result).toEqual(DEFAULT_INSETS); // Should fallback to defaults
104
107
  expect(console.warn).toHaveBeenCalledWith('SafeAreaInsetsManager: Failed to connect to native module:', expect.any(Error));
105
108
  });
106
109
 
107
110
  it('should update insets when they change during the test', async () => {
108
111
  // Arrange
109
- const initialInsets = {top: 44, left: 0, bottom: 34, right: 0};
112
+ const initialInsets = MOCKED_INSETS;
110
113
  const updatedInsets = {top: 50, left: 0, bottom: 40, right: 0};
111
114
 
112
115
  NativeModules.SafeAreaManager = {
@@ -138,7 +141,7 @@ describe('SafeAreaInsetsManager', () => {
138
141
 
139
142
  it('should notify delegates when insets change during the test', async () => {
140
143
  // Arrange
141
- const initialInsets = {top: 44, left: 0, bottom: 34, right: 0};
144
+ const initialInsets = MOCKED_INSETS;
142
145
  const updatedInsets = {top: 50, left: 0, bottom: 40, right: 0};
143
146
 
144
147
  NativeModules.SafeAreaManager = {
@@ -165,7 +168,7 @@ describe('SafeAreaInsetsManager', () => {
165
168
 
166
169
  it('should handle refreshSafeAreaInsets correctly', async () => {
167
170
  // Arrange
168
- const initialInsets = {top: 44, left: 0, bottom: 34, right: 0};
171
+ const initialInsets = MOCKED_INSETS;
169
172
  const refreshedInsets = {top: 48, left: 0, bottom: 36, right: 0};
170
173
 
171
174
  NativeModules.SafeAreaManager = {
@@ -197,7 +200,7 @@ describe('SafeAreaInsetsManager', () => {
197
200
 
198
201
  it('should not notify delegates when insets remain the same after refresh', async () => {
199
202
  // Arrange
200
- const sameInsets = {top: 44, left: 0, bottom: 34, right: 0};
203
+ const sameInsets = MOCKED_INSETS;
201
204
 
202
205
  NativeModules.SafeAreaManager = {
203
206
  getSafeAreaInsets: jest.fn().mockResolvedValue(sameInsets)
@@ -234,13 +237,13 @@ describe('SafeAreaInsetsManager', () => {
234
237
  const result = await SafeAreaInsetsManager.getSafeAreaInsets();
235
238
 
236
239
  // Assert
237
- expect(result).toEqual({top: 47, left: 0, bottom: 34, right: 0});
240
+ expect(result).toEqual(DEFAULT_INSETS);
238
241
  });
239
242
 
240
243
  it('should properly manage delegate lifecycle', async () => {
241
244
  // Arrange
242
245
  NativeModules.SafeAreaManager = {
243
- getSafeAreaInsets: jest.fn().mockResolvedValue({top: 44, left: 0, bottom: 34, right: 0})
246
+ getSafeAreaInsets: jest.fn().mockResolvedValue(MOCKED_INSETS)
244
247
  };
245
248
 
246
249
  const SafeAreaInsetsManager = require('../SafeAreaInsetsManager').default;
@@ -260,7 +263,7 @@ describe('SafeAreaInsetsManager', () => {
260
263
  SafeAreaInsetsManager.removeSafeAreaChangedDelegate(mockDelegate1);
261
264
 
262
265
  // Trigger notification
263
- const newInsets = {top: 50, left: 0, bottom: 40, right: 0};
266
+ const newInsets = MOCKED_INSETS;
264
267
  SafeAreaInsetsManager.notifyDelegates(newInsets);
265
268
 
266
269
  // Assert
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uilib-native",
3
- "version": "5.0.0-snapshot.7240",
3
+ "version": "5.0.0-snapshot.7257",
4
4
  "homepage": "https://github.com/wix/react-native-ui-lib",
5
5
  "description": "uilib native components (separated from js components)",
6
6
  "main": "components/index",