react-native-ui-lib 7.46.2 → 7.46.3-snapshot.7341
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/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 +52 -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 +109 -41
- package/lib/package.json +1 -1
- package/lib/react-native.config.js +1 -3
- package/metro.config.js +2 -2
- package/package.json +25 -25
- package/panView.d.ts +2 -0
- package/panView.js +1 -0
- package/react-native.config.js +1 -3
- 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/badge/index.d.ts +107 -47
- package/src/components/button/button.api.json +6 -1
- package/src/components/button/index.d.ts +61 -23
- package/src/components/button/index.js +18 -1
- package/src/components/button/types.d.ts +4 -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 +31 -37
- 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 +204 -212
- package/src/{incubator → components}/dialog/types.d.ts +0 -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/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/sortableGridList/SortableItem.js +13 -4
- package/src/components/sortableList/SortableListItem.js +13 -4
- package/src/components/stackAggregator/index.js +16 -11
- package/src/components/text/Text.driver.new.d.ts +2 -2
- package/src/components/text/Text.driver.new.js +2 -2
- 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/gradient/BorderGradient.d.ts +4 -0
- package/src/incubator/gradient/BorderGradient.js +45 -0
- package/src/incubator/gradient/CircleGradient.d.ts +4 -0
- package/src/incubator/gradient/CircleGradient.js +35 -0
- package/src/incubator/gradient/RectangleGradient.d.ts +4 -0
- package/src/incubator/gradient/RectangleGradient.js +32 -0
- package/src/incubator/gradient/index.d.ts +5 -0
- package/src/incubator/gradient/index.js +31 -0
- package/src/incubator/gradient/types.d.ts +26 -0
- package/src/incubator/gradient/types.js +1 -0
- package/src/incubator/gradient/useAngleTransform.d.ts +27 -0
- package/src/incubator/gradient/useAngleTransform.js +72 -0
- package/src/incubator/index.d.ts +1 -2
- package/src/incubator/index.js +2 -3
- package/src/incubator/toast/index.js +1 -1
- package/src/index.d.ts +3 -10
- package/src/index.js +42 -162
- package/src/optionalDependencies/LinearGradientPackage.d.ts +1 -1
- 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/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,8 @@
|
|
|
13
13
|
|
|
14
14
|
#import "LNAnimatorTemp.h"
|
|
15
15
|
|
|
16
|
+
#import "RNNAppDelegate.h"
|
|
17
|
+
|
|
16
18
|
#define kHlperViewTag 0x1f1f1f
|
|
17
19
|
|
|
18
20
|
NSString *const RCTCustomInputControllerKeyboardResigendEventTemp = @"kbdResigned";
|
|
@@ -49,7 +51,6 @@ NSString *const RCTCustomInputControllerKeyboardResigendEventTemp = @"kbdResigne
|
|
|
49
51
|
{
|
|
50
52
|
[self.delegate _WXInputHelperViewResignFirstResponder:self];
|
|
51
53
|
}
|
|
52
|
-
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
return rv;
|
|
@@ -118,17 +119,36 @@ RCT_EXPORT_MODULE(CustomInputControllerTemp)
|
|
|
118
119
|
return [params[@"useSafeArea"] isEqual:@(1)];
|
|
119
120
|
}
|
|
120
121
|
|
|
122
|
+
- (UITextField*)getTextFieldFromTextInputComponentView:(id)inputField {
|
|
123
|
+
UITextField *textField = nil;
|
|
124
|
+
|
|
125
|
+
if ([inputField isKindOfClass:NSClassFromString(@"RCTTextInputComponentView")])
|
|
126
|
+
{
|
|
127
|
+
Ivar textFieldIvar = class_getInstanceVariable([inputField class], "_backedTextInputView");
|
|
128
|
+
if (textFieldIvar != NULL)
|
|
129
|
+
{
|
|
130
|
+
textField = [inputField valueForKey:@"_backedTextInputView"];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return textField;
|
|
135
|
+
}
|
|
136
|
+
|
|
121
137
|
RCT_EXPORT_METHOD(presentCustomInputComponent:(nonnull NSNumber*)inputFieldTag params:(nonnull NSDictionary*)params)
|
|
122
138
|
{
|
|
123
139
|
RCTBridge* bridge = [self.bridge valueForKey:@"parentBridge"];
|
|
124
140
|
if(bridge == nil)
|
|
125
141
|
{
|
|
126
|
-
|
|
142
|
+
bridge = self.bridge;
|
|
127
143
|
}
|
|
128
144
|
|
|
129
145
|
UIView* inputField = [self.bridge.uiManager viewForReactTag:inputFieldTag];
|
|
130
146
|
NSDictionary *initialProps = params[@"initialProps"];
|
|
131
|
-
|
|
147
|
+
|
|
148
|
+
RNNAppDelegate* appDelegate = (RNNAppDelegate*)[UIApplication sharedApplication].delegate;
|
|
149
|
+
UIView *rv = [appDelegate.rootViewFactory viewWithModuleName:params[@"component"]
|
|
150
|
+
initialProperties:initialProps];
|
|
151
|
+
|
|
132
152
|
if(initialProps != nil && initialProps[@"backgroundColor"] != nil)
|
|
133
153
|
{
|
|
134
154
|
UIColor *backgroundColor = [RCTConvert UIColor:initialProps[@"backgroundColor"]];
|
|
@@ -148,7 +168,17 @@ RCT_EXPORT_METHOD(presentCustomInputComponent:(nonnull NSNumber*)inputFieldTag p
|
|
|
148
168
|
helperView.tag = kHlperViewTag;
|
|
149
169
|
helperView.delegate = self;
|
|
150
170
|
|
|
151
|
-
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
if ([inputField isKindOfClass:NSClassFromString(@"RCTTextInputComponentView")])
|
|
174
|
+
{
|
|
175
|
+
UITextField *textField = [self getTextFieldFromTextInputComponentView:inputField];
|
|
176
|
+
if (textField != nil)
|
|
177
|
+
{
|
|
178
|
+
helperView.inputAccessoryView = textField.inputAccessoryView;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else if ([inputField isKindOfClass:NSClassFromString(@"RCTTextView")])
|
|
152
182
|
{
|
|
153
183
|
UITextView *textView = nil;
|
|
154
184
|
Ivar backedTextInputIvar = class_getInstanceVariable([inputField class], "_backedTextInput");
|
|
@@ -213,7 +243,17 @@ RCT_EXPORT_METHOD(resetInput:(nonnull NSNumber*)inputFieldTag)
|
|
|
213
243
|
_WXInputHelperViewTemp* helperView = [inputField.superview viewWithTag:kHlperViewTag];
|
|
214
244
|
if(helperView != nil && [helperView isFirstResponder])
|
|
215
245
|
{//restore the first responder only if it was already the first responder to prevent the keyboard from opening again if not necessary
|
|
216
|
-
[inputField
|
|
246
|
+
if ([inputField isKindOfClass:NSClassFromString(@"RCTTextInputComponentView")])
|
|
247
|
+
{
|
|
248
|
+
UITextField *textField = [self getTextFieldFromTextInputComponentView:inputField];
|
|
249
|
+
if (textField != nil)
|
|
250
|
+
{
|
|
251
|
+
[textField reactFocus];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
} else {
|
|
255
|
+
[inputField reactFocus];
|
|
256
|
+
}
|
|
217
257
|
}
|
|
218
258
|
}
|
|
219
259
|
}
|
|
@@ -251,7 +291,7 @@ RCT_EXPORT_METHOD(dismissKeyboard)
|
|
|
251
291
|
}
|
|
252
292
|
}
|
|
253
293
|
|
|
254
|
-
-(UIColor*)reactViewAvgColor:(
|
|
294
|
+
-(UIColor*)reactViewAvgColor:(UIView*)rootView
|
|
255
295
|
{
|
|
256
296
|
if (rootView.frame.size.width == 0 || rootView.frame.size.height == 0)
|
|
257
297
|
{
|
|
@@ -296,7 +336,7 @@ RCT_EXPORT_METHOD(expandFullScreenForInput:(nonnull NSNumber*)inputFieldTag)
|
|
|
296
336
|
helperView.keepInSuperviewOnResign = YES;
|
|
297
337
|
|
|
298
338
|
RCTCustomKeyboardViewControllerTemp *customKeyboardViewController = (RCTCustomKeyboardViewControllerTemp*)helperView.inputViewController;
|
|
299
|
-
|
|
339
|
+
UIView *rv = customKeyboardViewController.rootView;
|
|
300
340
|
UIInputView *inputView = helperView.inputViewController.inputView;
|
|
301
341
|
|
|
302
342
|
_fullScreenWindow = [[UIWindow alloc] initWithFrame:[inputView.window convertRect:inputView.bounds fromView:inputView]];
|
|
@@ -370,7 +410,7 @@ RCT_EXPORT_METHOD(resetSizeForInput:(nonnull NSNumber*)inputFieldTag)
|
|
|
370
410
|
completionHandler:^(BOOL completed)
|
|
371
411
|
{
|
|
372
412
|
RCTCustomKeyboardViewControllerTemp *customKeyboardViewController = (RCTCustomKeyboardViewControllerTemp*)helperView.inputViewController;
|
|
373
|
-
|
|
413
|
+
UIView *rv = _fullScreenWindow.rootViewController.view;
|
|
374
414
|
|
|
375
415
|
[UIView performWithoutAnimation:^{
|
|
376
416
|
|
|
@@ -388,6 +428,8 @@ RCT_EXPORT_METHOD(resetSizeForInput:(nonnull NSNumber*)inputFieldTag)
|
|
|
388
428
|
}
|
|
389
429
|
}
|
|
390
430
|
|
|
431
|
+
|
|
432
|
+
|
|
391
433
|
#pragma mark - _WXInputHelperViewDelegateTemp methods
|
|
392
434
|
|
|
393
435
|
-(void)_WXInputHelperViewResignFirstResponder:(UIView*)wxInputHelperView
|
|
@@ -397,6 +439,8 @@ RCT_EXPORT_METHOD(resetSizeForInput:(nonnull NSNumber*)inputFieldTag)
|
|
|
397
439
|
[self sendEventWithName:RCTCustomInputControllerKeyboardResigendEventTemp body:nil];
|
|
398
440
|
}
|
|
399
441
|
self.customInputComponentPresented = NO;
|
|
442
|
+
|
|
443
|
+
|
|
400
444
|
}
|
|
401
445
|
|
|
402
446
|
@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
|