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.
- package/babel.config.js +12 -0
- package/incubator.d.ts +2 -2
- package/incubator.js +0 -2
- package/index.js +1 -0
- package/lib/android/build.gradle +5 -5
- package/lib/android/src/main/java/com/wix/reactnativeuilib/UiLibPackageList.java +0 -2
- package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager.java +31 -23
- package/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java +1 -1
- package/lib/components/{HighlighterOverlayView.d.ts → HighlighterOverlayView/index.d.ts} +1 -1
- package/lib/components/HighlighterOverlayView/index.js +49 -0
- package/lib/components/{HighlighterOverlayView.web.d.ts → HighlighterOverlayView/index.web.d.ts} +1 -1
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.android.d.ts +5 -2
- package/lib/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.android.js +51 -0
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.d.ts +1 -1
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.js +3 -3
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.d.ts +3 -0
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.js +1 -1
- package/lib/components/Keyboard/{KeyboardInput/utils → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager}/__tests__/EventEmitterManager.spec.js +1 -1
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/__tests__/KeyboardRegistry.spec.js +1 -1
- package/lib/components/Keyboard/{KeyboardInput/KeyboardRegistry.d.ts → KeyboardAccessoryView/KeyboardRegistry/index.d.ts} +1 -1
- package/lib/components/Keyboard/{KeyboardInput/KeyboardRegistry.js → KeyboardAccessoryView/KeyboardRegistry/index.js} +1 -1
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/keyboardRegistry.api.json +9 -9
- package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.d.ts +26 -0
- package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.js +91 -0
- package/lib/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.d.ts → KeyboardAccessoryView/index.d.ts} +11 -1
- package/lib/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.js → KeyboardAccessoryView/index.js} +31 -5
- package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/keyboardAccessoryView.api.json +5 -5
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.d.ts → KeyboardAwareInsetsView/index.d.ts} +1 -1
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.js → KeyboardAwareInsetsView/index.js} +1 -1
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.d.ts +1 -4
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.js +5 -8
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.d.ts +2 -2
- package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/keyboardTrackingView.api.json +11 -20
- package/lib/components/Keyboard/index.d.ts +6 -6
- package/lib/components/Keyboard/index.js +6 -6
- package/lib/components/SafeArea/SafeAreaInsetsManager.d.ts +21 -7
- package/lib/components/SafeArea/SafeAreaInsetsManager.js +95 -31
- package/lib/components/SafeArea/SafeAreaSpacerView.d.ts +2 -2
- package/lib/components/SafeArea/SafeAreaSpacerView.js +63 -9
- package/lib/components/SafeArea/__tests__/SafeAreaInsetsManager.spec.js +274 -0
- package/lib/components/SafeArea/index.d.ts +10 -0
- package/lib/components/SafeArea/index.js +11 -0
- package/lib/components/index.d.ts +1 -1
- package/lib/components/index.js +1 -1
- package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomInputControllerTemp.m +56 -8
- package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.h +1 -7
- package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.m +1 -1
- package/lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m +134 -44
- package/lib/package.json +3 -3
- package/lib/react-native.config.js +1 -3
- package/metro.config.js +2 -2
- package/package.json +33 -32
- package/panView.d.ts +2 -0
- package/panView.js +1 -0
- package/scripts/release/prReleaseNotesCommon.js +15 -4
- package/src/commons/Constants.js +2 -5
- package/src/commons/modifiers.d.ts +1 -0
- package/src/commons/modifiers.js +5 -2
- package/src/components/KeyboardAwareScrollView/KeyboardAwareBase.js +5 -1
- package/src/components/actionSheet/index.d.ts +2 -12
- package/src/components/actionSheet/index.js +3 -42
- package/src/components/animatedImage/index.js +12 -2
- package/src/components/badge/index.d.ts +107 -47
- package/src/components/button/button.api.json +1 -1
- package/src/components/button/index.d.ts +53 -23
- package/src/components/button/types.d.ts +0 -1
- package/src/components/colorPicker/ColorPickerDialog.d.ts +1 -1
- package/src/components/colorPicker/ColorPickerDialog.js +1 -1
- package/src/components/dateTimePicker/index.d.ts +186 -5
- package/src/components/dateTimePicker/index.js +3 -4
- package/src/components/dialog/dialog.api.json +34 -35
- package/src/{incubator → components}/dialog/dialogHeader.api.json +2 -2
- package/src/components/dialog/index.d.ts +13 -105
- package/src/components/dialog/index.js +205 -212
- package/src/{incubator → components}/dialog/types.d.ts +7 -19
- package/src/{incubator → components}/dialog/types.js +1 -3
- package/src/{incubator → components}/dialog/useDialogContent.d.ts +1 -1
- package/src/components/drawer/Swipeable.js +1 -2
- package/src/components/drawer/index.js +31 -25
- package/src/components/fadedScrollView/index.js +7 -2
- package/src/components/featureHighlight/index.d.ts +1 -1
- package/src/components/hint/index.d.ts +0 -8
- package/src/components/hint/index.js +4 -6
- package/src/components/image/index.js +4 -0
- package/src/components/index.js +0 -19
- package/src/components/marquee/types.js +4 -1
- package/src/components/modal/index.d.ts +5 -0
- package/src/components/modal/index.js +14 -10
- package/src/components/modal/modal.api.json +5 -0
- package/src/{incubator → components}/panView/index.d.ts +3 -3
- package/src/{incubator → components}/panView/index.js +4 -4
- package/src/{incubator → components}/panView/usePanGesture.d.ts +1 -1
- package/src/components/picker/Picker.driver.new.d.ts +2 -2
- package/src/components/picker/Picker.driver.new.js +3 -3
- package/src/components/picker/PickerItem.js +6 -20
- package/src/components/picker/PickerPresenter.d.ts +0 -1
- package/src/components/picker/PickerPresenter.js +1 -23
- package/src/components/picker/api/picker.api.json +0 -1
- package/src/components/picker/api/pickerItem.api.json +0 -5
- package/src/components/picker/helpers/useFieldType.d.ts +53 -23
- package/src/components/picker/helpers/usePickerLabel.d.ts +1 -1
- package/src/components/picker/helpers/usePickerLabel.js +2 -3
- package/src/components/picker/helpers/usePickerMigrationWarnings.d.ts +1 -1
- package/src/components/picker/helpers/usePickerMigrationWarnings.js +0 -12
- package/src/components/picker/helpers/usePickerSearch.d.ts +1 -1
- package/src/components/picker/helpers/usePickerSearch.js +4 -8
- package/src/components/picker/helpers/usePickerSelection.d.ts +1 -1
- package/src/components/picker/helpers/usePickerSelection.js +2 -10
- package/src/components/picker/index.js +4 -22
- package/src/components/picker/types.d.ts +1 -24
- package/src/components/segmentedControl/index.js +3 -3
- package/src/components/slider/GradientSlider.d.ts +1 -1
- package/src/components/slider/index.js +1 -1
- package/src/components/sortableGridList/SortableItem.js +13 -4
- package/src/components/sortableList/SortableListItem.js +13 -4
- package/src/components/stackAggregator/index.js +16 -11
- package/src/components/tabController/TabPage.js +18 -14
- package/src/components/text/Text.driver.new.d.ts +2 -2
- package/src/components/text/Text.driver.new.js +2 -2
- package/src/components/text/index.js +2 -3
- package/src/components/textField/Input.js +0 -1
- package/src/components/textField/TextField.driver.new.d.ts +2 -2
- package/src/components/textField/TextField.driver.new.js +2 -2
- package/src/components/textField/presets/outline.d.ts +106 -46
- package/src/components/textField/presets/underline.d.ts +106 -46
- package/src/components/textField/types.js +1 -0
- package/src/components/textField/usePreset.d.ts +72 -44
- package/src/components/timeline/types.js +3 -0
- package/src/{incubator/hooks/useHiddenLocation.web.d.ts → hooks/useHiddenLocation/index.d.ts} +1 -1
- package/src/{incubator/hooks/useHiddenLocation.d.ts → hooks/useHiddenLocation/index.web.d.ts} +1 -1
- package/src/incubator/expandableOverlay/ExpandableOverlay.driver.js +1 -1
- package/src/incubator/expandableOverlay/index.d.ts +42 -3
- package/src/incubator/expandableOverlay/index.js +1 -4
- package/src/incubator/index.d.ts +0 -2
- package/src/incubator/index.js +0 -2
- package/src/incubator/slider/SliderPresenter.js +2 -1
- package/src/incubator/toast/index.js +1 -1
- package/src/index.d.ts +3 -10
- package/src/index.js +42 -162
- package/src/testkit/index.d.ts +1 -1
- package/src/testkit/index.js +1 -1
- package/src/testkit/new/Component.driver.d.ts +4 -1
- package/src/testkit/new/Component.driver.js +3 -3
- package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReactHacks.java +0 -30
- package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReflectionUtils.java +0 -34
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/DefaultKeyListener.java +0 -33
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/KeyListenerProxy.java +0 -53
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerModule.java +0 -54
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerPackage.java +0 -28
- package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/ViewUtils.java +0 -36
- package/lib/components/HighlighterOverlayView.js +0 -40
- package/lib/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.js +0 -28
- package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.d.ts +0 -11
- package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.js +0 -17
- package/panningViews.d.ts +0 -2
- package/panningViews.js +0 -1
- package/react-native.config.js +0 -22
- package/sharedTransition.d.ts +0 -2
- package/sharedTransition.js +0 -1
- package/src/components/dialog/DialogDismissibleView.d.ts +0 -34
- package/src/components/dialog/DialogDismissibleView.js +0 -184
- package/src/components/dialog/OverlayFadingBackground.d.ts +0 -14
- package/src/components/dialog/OverlayFadingBackground.js +0 -45
- package/src/components/panningViews/asPanViewConsumer.d.ts +0 -3
- package/src/components/panningViews/asPanViewConsumer.js +0 -16
- package/src/components/panningViews/panDismissibleView.d.ts +0 -51
- package/src/components/panningViews/panDismissibleView.js +0 -350
- package/src/components/panningViews/panGestureView.d.ts +0 -23
- package/src/components/panningViews/panGestureView.js +0 -156
- package/src/components/panningViews/panListenerView.d.ts +0 -66
- package/src/components/panningViews/panListenerView.js +0 -155
- package/src/components/panningViews/panResponderView.d.ts +0 -19
- package/src/components/panningViews/panResponderView.js +0 -79
- package/src/components/panningViews/panningContext.d.ts +0 -3
- package/src/components/panningViews/panningContext.js +0 -4
- package/src/components/panningViews/panningProvider.d.ts +0 -73
- package/src/components/panningViews/panningProvider.js +0 -101
- package/src/components/sharedTransition/ShareTransitionContext.js +0 -3
- package/src/components/sharedTransition/SharedArea.js +0 -153
- package/src/components/sharedTransition/SourceElement.js +0 -44
- package/src/components/sharedTransition/TargetElement.js +0 -38
- package/src/components/sharedTransition/index.js +0 -9
- package/src/incubator/dialog/dialog.api.json +0 -54
- package/src/incubator/dialog/index.d.ts +0 -15
- package/src/incubator/dialog/index.js +0 -218
- /package/lib/components/{HighlighterOverlayView.web.js → HighlighterOverlayView/index.web.js} +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.js +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.js +0 -0
- /package/lib/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.d.ts → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.d.ts} +0 -0
- /package/lib/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.js → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.js} +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.js +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.js +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.js +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking → KeyboardAwareInsetsView}/keyboardAwareInsetsView.api.json +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.js +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.js +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.d.ts +0 -0
- /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.js +0 -0
- /package/src/{incubator → components}/dialog/Dialog.driver.new.d.ts +0 -0
- /package/src/{incubator → components}/dialog/Dialog.driver.new.js +0 -0
- /package/src/{incubator → components}/dialog/DialogHeader.d.ts +0 -0
- /package/src/{incubator → components}/dialog/DialogHeader.js +0 -0
- /package/src/{incubator → components}/dialog/useDialogContent.js +0 -0
- /package/src/{incubator → components}/panView/panningUtil.d.ts +0 -0
- /package/src/{incubator → components}/panView/panningUtil.js +0 -0
- /package/src/{incubator → components}/panView/usePanGesture.js +0 -0
- /package/src/{incubator/hooks/useHiddenLocation.js → hooks/useHiddenLocation/index.js} +0 -0
- /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
|
|
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 };
|
package/lib/components/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import DynamicFonts, { FontExtension } from "./DynamicFonts";
|
|
2
2
|
import HighlighterOverlayView from "./HighlighterOverlayView";
|
|
3
|
-
import SafeAreaSpacerView from "./SafeArea
|
|
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
|
-
|
|
146
|
+
bridge = self.bridge;
|
|
127
147
|
}
|
|
128
148
|
|
|
129
149
|
UIView* inputField = [self.bridge.uiManager viewForReactTag:inputFieldTag];
|
|
130
150
|
NSDictionary *initialProps = params[@"initialProps"];
|
|
131
|
-
|
|
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
|
-
|
|
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
|
|
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:(
|
|
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
|
-
|
|
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
|
-
|
|
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)
|
|
16
|
+
@property (nonatomic, strong) UIView *rootView;
|
|
23
17
|
|
|
24
18
|
@end
|