uilib-native 4.5.2 → 5.0.0-snapshot.7175
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/android/build.gradle +5 -5
- package/android/src/main/java/com/wix/reactnativeuilib/UiLibPackageList.java +0 -2
- package/android/src/main/java/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager.java +31 -23
- package/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java +1 -1
- package/components/HighlighterOverlayView/HighlighterViewNativeComponent.d.ts +61 -0
- package/components/HighlighterOverlayView/HighlighterViewNativeComponent.js +2 -0
- package/components/HighlighterOverlayView/index.js +49 -0
- package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.android.d.ts +5 -2
- package/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.android.js +51 -0
- package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.d.ts +1 -1
- package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.js +3 -3
- package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.d.ts +3 -0
- package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.js +1 -1
- package/components/Keyboard/{KeyboardInput/utils → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager}/__tests__/EventEmitterManager.spec.js +1 -1
- package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/__tests__/KeyboardRegistry.spec.js +1 -1
- package/components/Keyboard/{KeyboardInput/KeyboardRegistry.d.ts → KeyboardAccessoryView/KeyboardRegistry/index.d.ts} +1 -1
- package/components/Keyboard/{KeyboardInput/KeyboardRegistry.js → KeyboardAccessoryView/KeyboardRegistry/index.js} +1 -1
- package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/keyboardRegistry.api.json +9 -9
- package/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.d.ts +26 -0
- package/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.js +91 -0
- package/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.d.ts → KeyboardAccessoryView/index.d.ts} +11 -1
- package/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.js → KeyboardAccessoryView/index.js} +31 -5
- package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/keyboardAccessoryView.api.json +5 -5
- package/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.d.ts → KeyboardAwareInsetsView/index.d.ts} +1 -1
- package/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.js → KeyboardAwareInsetsView/index.js} +1 -1
- package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.d.ts +1 -4
- package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.js +5 -8
- package/components/Keyboard/KeyboardTrackingView/KeyboardTrackingViewNativeComponent.d.ts +58 -0
- package/components/Keyboard/KeyboardTrackingView/KeyboardTrackingViewNativeComponent.js +2 -0
- package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.d.ts +2 -2
- package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/keyboardTrackingView.api.json +11 -20
- package/components/Keyboard/index.d.ts +6 -6
- package/components/Keyboard/index.js +6 -6
- package/components/SafeArea/SafeAreaInsetsManager.d.ts +8 -3
- package/components/SafeArea/SafeAreaInsetsManager.js +89 -23
- package/components/SafeArea/SafeAreaSpacerView.js +60 -9
- package/package.json +1 -1
- package/react-native.config.js +1 -3
- package/scripts/releaseNative.js +20 -6
- package/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReactHacks.java +0 -30
- package/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReflectionUtils.java +0 -34
- package/android/src/main/java/com/wix/reactnativeuilib/textinput/DefaultKeyListener.java +0 -33
- package/android/src/main/java/com/wix/reactnativeuilib/textinput/KeyListenerProxy.java +0 -53
- package/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerModule.java +0 -54
- package/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerPackage.java +0 -28
- package/android/src/main/java/com/wix/reactnativeuilib/textinput/ViewUtils.java +0 -36
- package/components/HighlighterOverlayView.js +0 -40
- package/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.js +0 -28
- package/components/Keyboard/KeyboardInput/utils/KeyboardUtils.d.ts +0 -11
- package/components/Keyboard/KeyboardInput/utils/KeyboardUtils.js +0 -17
- /package/components/{HighlighterOverlayView.d.ts → HighlighterOverlayView/index.d.ts} +0 -0
- /package/components/{HighlighterOverlayView.web.d.ts → HighlighterOverlayView/index.web.d.ts} +0 -0
- /package/components/{HighlighterOverlayView.web.js → HighlighterOverlayView/index.web.js} +0 -0
- /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.d.ts +0 -0
- /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.js +0 -0
- /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.d.ts +0 -0
- /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.js +0 -0
- /package/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.d.ts → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.d.ts} +0 -0
- /package/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.js → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.js} +0 -0
- /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.d.ts +0 -0
- /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.js +0 -0
- /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.d.ts +0 -0
- /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.js +0 -0
- /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.d.ts +0 -0
- /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.js +0 -0
- /package/components/Keyboard/{KeyboardTracking → KeyboardAwareInsetsView}/keyboardAwareInsetsView.api.json +0 -0
- /package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.d.ts +0 -0
- /package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.js +0 -0
- /package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.js +0 -0
- /package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.d.ts +0 -0
- /package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.js +0 -0
package/android/build.gradle
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
|
|
3
3
|
project.ext {
|
|
4
|
-
buildToolsVersion = rootProject.ext.has("buildToolsVersion") ? rootProject.ext.buildToolsVersion : '
|
|
5
|
-
minSdkVersion = rootProject.ext.has("minSdkVersion") ? rootProject.ext.minSdkVersion :
|
|
6
|
-
compileSdkVersion = rootProject.ext.has("compileSdkVersion") ? rootProject.ext.compileSdkVersion :
|
|
7
|
-
targetSdkVersion = rootProject.ext.has("targetSdkVersion") ? rootProject.ext.targetSdkVersion :
|
|
8
|
-
supportLibVersion = rootProject.ext.has("supportLibVersion") ? rootProject.ext.supportLibVersion : '
|
|
4
|
+
buildToolsVersion = rootProject.ext.has("buildToolsVersion") ? rootProject.ext.buildToolsVersion : '35.0.0'
|
|
5
|
+
minSdkVersion = rootProject.ext.has("minSdkVersion") ? rootProject.ext.minSdkVersion : 24
|
|
6
|
+
compileSdkVersion = rootProject.ext.has("compileSdkVersion") ? rootProject.ext.compileSdkVersion : 35
|
|
7
|
+
targetSdkVersion = rootProject.ext.has("targetSdkVersion") ? rootProject.ext.targetSdkVersion : 34
|
|
8
|
+
supportLibVersion = rootProject.ext.has("supportLibVersion") ? rootProject.ext.supportLibVersion : '28.0.0'
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
android {
|
|
@@ -6,7 +6,6 @@ import com.facebook.react.ReactPackage;
|
|
|
6
6
|
import com.wix.reactnativeuilib.dynamicfont.DynamicFontPackage;
|
|
7
7
|
import com.wix.reactnativeuilib.highlighterview.HighlighterViewPackage;
|
|
8
8
|
import com.wix.reactnativeuilib.keyboardinput.KeyboardInputPackage;
|
|
9
|
-
import com.wix.reactnativeuilib.textinput.TextInputDelKeyHandlerPackage;
|
|
10
9
|
|
|
11
10
|
import java.util.Arrays;
|
|
12
11
|
import java.util.List;
|
|
@@ -23,7 +22,6 @@ public class UiLibPackageList {
|
|
|
23
22
|
return Arrays.asList(
|
|
24
23
|
new DynamicFontPackage(),
|
|
25
24
|
new HighlighterViewPackage(),
|
|
26
|
-
new TextInputDelKeyHandlerPackage(),
|
|
27
25
|
new KeyboardInputPackage(application)
|
|
28
26
|
);
|
|
29
27
|
}
|
package/android/src/main/java/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager.java
CHANGED
|
@@ -8,12 +8,15 @@ import android.util.SizeF;
|
|
|
8
8
|
import android.view.View;
|
|
9
9
|
|
|
10
10
|
import com.facebook.react.bridge.ReadableMap;
|
|
11
|
+
import com.facebook.react.bridge.UIManager;
|
|
11
12
|
import com.facebook.react.uimanager.IllegalViewOperationException;
|
|
12
13
|
import com.facebook.react.uimanager.NativeViewHierarchyManager;
|
|
13
14
|
import com.facebook.react.uimanager.SimpleViewManager;
|
|
14
15
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
16
|
+
import com.facebook.react.uimanager.UIManagerHelper;
|
|
15
17
|
import com.facebook.react.uimanager.UIManagerModule;
|
|
16
18
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
19
|
+
import com.facebook.react.uimanager.common.UIManagerType;
|
|
17
20
|
|
|
18
21
|
import javax.annotation.Nullable;
|
|
19
22
|
|
|
@@ -75,33 +78,38 @@ class HighlighterViewManager extends SimpleViewManager<HighlighterView> {
|
|
|
75
78
|
|
|
76
79
|
@ReactProp(name = "highlightViewTag")
|
|
77
80
|
public void setHighlightViewTag(final HighlighterView view, Integer highlightViewTag) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
81
|
+
if (highlightViewTag != null) {
|
|
82
|
+
try {
|
|
83
|
+
UIManager uiManager = UIManagerHelper.getUIManagerForReactTag(context, highlightViewTag);
|
|
84
|
+
if (uiManager != null) {
|
|
85
|
+
final View resolvedView = uiManager.resolveView(highlightViewTag);
|
|
86
|
+
if (resolvedView != null) {
|
|
87
|
+
if (resolvedView.getWidth() == 0 || resolvedView.getHeight() == 0) {
|
|
88
|
+
resolvedView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
|
89
|
+
@Override
|
|
90
|
+
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
|
91
|
+
float width = right - left;
|
|
92
|
+
float height = bottom - top;
|
|
93
|
+
if (width > 0 && height > 0) {
|
|
94
|
+
setViewBasedHighlightFrame(view, resolvedView);
|
|
95
|
+
resolvedView.removeOnLayoutChangeListener(this);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
} else {
|
|
100
|
+
setViewBasedHighlightFrame(view, resolvedView);
|
|
96
101
|
}
|
|
97
|
-
}
|
|
102
|
+
} else {
|
|
103
|
+
Log.e("HighlighterView", "was not able to resolve highlightViewTag: " + highlightViewTag.toString());
|
|
104
|
+
}
|
|
98
105
|
} else {
|
|
99
|
-
|
|
106
|
+
Log.e("HighlighterView", "was not able to resolve get uiManager for highlightViewTag: " + highlightViewTag.toString());
|
|
100
107
|
}
|
|
108
|
+
} catch (IllegalViewOperationException e) {
|
|
109
|
+
Log.e("HighlighterView", "invalid highlightViewTag: " + highlightViewTag.toString() + " " + e.toString());
|
|
101
110
|
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
Log.e("HighlighterView", "invalid highlightViewTag: " + highlightViewTag.toString() + " " + e.toString());
|
|
111
|
+
} else {
|
|
112
|
+
Log.e("HighlighterView", "highlightViewTag is null");
|
|
105
113
|
}
|
|
106
114
|
}
|
|
107
115
|
|
package/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java
CHANGED
|
@@ -9,7 +9,7 @@ public class RuntimeUtils {
|
|
|
9
9
|
private static final Runnable sUIUpdateClosure = new Runnable() {
|
|
10
10
|
@Override
|
|
11
11
|
public void run() {
|
|
12
|
-
ReactContextHolder.getContext().getNativeModule(UIManagerModule.class).onBatchComplete();
|
|
12
|
+
// ReactContextHolder.getContext().getNativeModule(UIManagerModule.class).onBatchComplete();
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/// <reference types="react-native/types/modules/codegen" />
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
import type { Float, Int32, WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
|
+
export interface HighlightFrame {
|
|
5
|
+
x: Float;
|
|
6
|
+
y: Float;
|
|
7
|
+
width: Float;
|
|
8
|
+
height: Float;
|
|
9
|
+
}
|
|
10
|
+
export interface MinimumRectSize {
|
|
11
|
+
width: Float;
|
|
12
|
+
height: Float;
|
|
13
|
+
}
|
|
14
|
+
export interface HighlightViewTagParams {
|
|
15
|
+
paddingLeft?: WithDefault<Float, 0>;
|
|
16
|
+
paddingTop?: WithDefault<Float, 0>;
|
|
17
|
+
paddingRight?: WithDefault<Float, 0>;
|
|
18
|
+
paddingBottom?: WithDefault<Float, 0>;
|
|
19
|
+
offsetX?: WithDefault<Float, 0>;
|
|
20
|
+
offsetY?: WithDefault<Float, 0>;
|
|
21
|
+
}
|
|
22
|
+
export interface NativeProps extends ViewProps {
|
|
23
|
+
/**
|
|
24
|
+
* The frame to highlight with x, y, width, height coordinates
|
|
25
|
+
*/
|
|
26
|
+
highlightFrame?: HighlightFrame;
|
|
27
|
+
/**
|
|
28
|
+
* The overlay color (processed color int for Android)
|
|
29
|
+
*/
|
|
30
|
+
overlayColor?: WithDefault<Int32, 0>;
|
|
31
|
+
/**
|
|
32
|
+
* The border radius for the highlighted area
|
|
33
|
+
*/
|
|
34
|
+
borderRadius?: WithDefault<Float, 0>;
|
|
35
|
+
/**
|
|
36
|
+
* The stroke color (processed color int for Android)
|
|
37
|
+
*/
|
|
38
|
+
strokeColor?: WithDefault<Int32, 0>;
|
|
39
|
+
/**
|
|
40
|
+
* The stroke width
|
|
41
|
+
*/
|
|
42
|
+
strokeWidth?: WithDefault<Float, 0>;
|
|
43
|
+
/**
|
|
44
|
+
* The React tag of the view to highlight
|
|
45
|
+
*/
|
|
46
|
+
highlightViewTag?: Int32;
|
|
47
|
+
/**
|
|
48
|
+
* Parameters for view-based highlighting including padding and offset
|
|
49
|
+
*/
|
|
50
|
+
highlightViewTagParams?: HighlightViewTagParams;
|
|
51
|
+
/**
|
|
52
|
+
* Minimum rectangle size for the highlight area
|
|
53
|
+
*/
|
|
54
|
+
minimumRectSize?: MinimumRectSize;
|
|
55
|
+
/**
|
|
56
|
+
* Inner padding for the highlight area
|
|
57
|
+
*/
|
|
58
|
+
innerPadding?: WithDefault<Float, 0>;
|
|
59
|
+
}
|
|
60
|
+
declare const _default: import("react-native/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
|
|
61
|
+
export default _default;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { processColor, StyleSheet, Modal } from 'react-native';
|
|
3
|
+
// Import the Codegen specification for New Architecture
|
|
4
|
+
import HighlighterViewNativeComponent from "./HighlighterViewNativeComponent";
|
|
5
|
+
const DefaultOverlayColor = 'rgba(0, 0, 0, 0.5)';
|
|
6
|
+
const HighlighterOverlayView = props => {
|
|
7
|
+
const {
|
|
8
|
+
overlayColor,
|
|
9
|
+
borderRadius,
|
|
10
|
+
strokeColor,
|
|
11
|
+
strokeWidth,
|
|
12
|
+
visible,
|
|
13
|
+
onRequestClose,
|
|
14
|
+
highlightFrame,
|
|
15
|
+
style,
|
|
16
|
+
children,
|
|
17
|
+
highlightViewTag,
|
|
18
|
+
highlightViewTagParams,
|
|
19
|
+
minimumRectSize,
|
|
20
|
+
innerPadding
|
|
21
|
+
} = props;
|
|
22
|
+
|
|
23
|
+
// Process colors for New Architecture Codegen component
|
|
24
|
+
const overlayColorToUse = processColor(overlayColor || DefaultOverlayColor);
|
|
25
|
+
const strokeColorToUse = strokeColor ? processColor(strokeColor) : undefined;
|
|
26
|
+
|
|
27
|
+
// Convert highlightViewTagParams to match native Codegen spec
|
|
28
|
+
let nativeHighlightViewTagParams;
|
|
29
|
+
if (highlightViewTagParams) {
|
|
30
|
+
const padding = typeof highlightViewTagParams.padding === 'number' ? highlightViewTagParams.padding : 0;
|
|
31
|
+
nativeHighlightViewTagParams = {
|
|
32
|
+
paddingLeft: padding,
|
|
33
|
+
paddingTop: padding,
|
|
34
|
+
paddingRight: padding,
|
|
35
|
+
paddingBottom: padding,
|
|
36
|
+
offsetX: highlightViewTagParams.offset?.x || 0,
|
|
37
|
+
offsetY: highlightViewTagParams.offset?.y || 0
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return <Modal visible={!!visible} animationType={'fade'} transparent onRequestClose={() => onRequestClose?.()}>
|
|
41
|
+
<HighlighterViewNativeComponent highlightFrame={highlightFrame} style={[style, {
|
|
42
|
+
...StyleSheet.absoluteFillObject,
|
|
43
|
+
backgroundColor: 'transparent'
|
|
44
|
+
}]} overlayColor={overlayColorToUse} borderRadius={borderRadius} strokeColor={strokeColorToUse} strokeWidth={strokeWidth} highlightViewTag={highlightViewTag || undefined} highlightViewTagParams={nativeHighlightViewTagParams} minimumRectSize={minimumRectSize} innerPadding={innerPadding} testID={props.testID} accessible={props.accessible} />
|
|
45
|
+
{children}
|
|
46
|
+
</Modal>;
|
|
47
|
+
};
|
|
48
|
+
HighlighterOverlayView.displayName = 'IGNORE';
|
|
49
|
+
export default HighlighterOverlayView;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import CustomKeyboardViewBase, { CustomKeyboardViewBaseProps } from '
|
|
2
|
+
import CustomKeyboardViewBase, { CustomKeyboardViewBaseProps } from './CustomKeyboardViewBase';
|
|
3
3
|
export default class CustomKeyboardView extends CustomKeyboardViewBase<CustomKeyboardViewBaseProps> {
|
|
4
4
|
static displayName: string;
|
|
5
5
|
componentDidUpdate(prevProps: CustomKeyboardViewBaseProps): Promise<void>;
|
|
6
|
-
|
|
6
|
+
getStyle: () => {
|
|
7
|
+
height: number | undefined;
|
|
8
|
+
};
|
|
9
|
+
render(): React.JSX.Element | null;
|
|
7
10
|
}
|
package/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.android.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Keyboard, View } from 'react-native';
|
|
3
|
+
import KeyboardRegistry from "../KeyboardRegistry";
|
|
4
|
+
import CustomKeyboardViewBase from "./CustomKeyboardViewBase";
|
|
5
|
+
export default class CustomKeyboardView extends CustomKeyboardViewBase {
|
|
6
|
+
static displayName = 'IGNORE';
|
|
7
|
+
async componentDidUpdate(prevProps) {
|
|
8
|
+
const {
|
|
9
|
+
component,
|
|
10
|
+
inputRef,
|
|
11
|
+
shouldFocus,
|
|
12
|
+
onKeyboardDismiss
|
|
13
|
+
} = this.props;
|
|
14
|
+
if (prevProps.component !== component) {
|
|
15
|
+
if (!component) {
|
|
16
|
+
if (shouldFocus) {
|
|
17
|
+
if (inputRef?.current) {
|
|
18
|
+
inputRef.current.focus?.();
|
|
19
|
+
} else {
|
|
20
|
+
inputRef?.focus?.();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
Keyboard.dismiss();
|
|
25
|
+
}
|
|
26
|
+
onKeyboardDismiss?.();
|
|
27
|
+
}
|
|
28
|
+
super.componentDidUpdate(prevProps);
|
|
29
|
+
}
|
|
30
|
+
getStyle = () => {
|
|
31
|
+
const {
|
|
32
|
+
keyboardHeight
|
|
33
|
+
} = this.props;
|
|
34
|
+
return {
|
|
35
|
+
height: keyboardHeight
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
render() {
|
|
39
|
+
const {
|
|
40
|
+
component,
|
|
41
|
+
initialProps
|
|
42
|
+
} = this.props;
|
|
43
|
+
const KeyboardComponent = component && KeyboardRegistry.getKeyboard(component);
|
|
44
|
+
if (!KeyboardComponent) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return <View style={this.getStyle()}>
|
|
48
|
+
<KeyboardComponent {...initialProps} />
|
|
49
|
+
</View>;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import CustomKeyboardViewBase, { CustomKeyboardViewBaseProps } from '
|
|
1
|
+
import CustomKeyboardViewBase, { CustomKeyboardViewBaseProps } from './CustomKeyboardViewBase';
|
|
2
2
|
export type CustomKeyboardViewProps = CustomKeyboardViewBaseProps & {
|
|
3
3
|
/**
|
|
4
4
|
* The reference to the actual text input (or the keyboard may not reset when instructed to, etc.)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import TextInputKeyboardManager from "
|
|
2
|
-
import KeyboardRegistry from "
|
|
3
|
-
import CustomKeyboardViewBase from "
|
|
1
|
+
import TextInputKeyboardManager from "../TextInputKeyboardManager/TextInputKeyboardManager.ios";
|
|
2
|
+
import KeyboardRegistry from "../KeyboardRegistry";
|
|
3
|
+
import CustomKeyboardViewBase from "./CustomKeyboardViewBase";
|
|
4
4
|
export default class CustomKeyboardView extends CustomKeyboardViewBase {
|
|
5
5
|
static displayName = 'IGNORE';
|
|
6
6
|
static defaultProps = {
|
|
@@ -3,6 +3,9 @@ import { EventSubscription } from 'react-native';
|
|
|
3
3
|
export type CustomKeyboardViewBaseProps = {
|
|
4
4
|
inputRef?: any;
|
|
5
5
|
initialProps?: any;
|
|
6
|
+
keyboardHeight?: number;
|
|
7
|
+
onKeyboardDismiss?: () => void;
|
|
8
|
+
shouldFocus?: boolean;
|
|
6
9
|
component?: string;
|
|
7
10
|
onItemSelected?: (component?: string, args?: any) => void;
|
|
8
11
|
onRequestShowKeyboard?: (keyboardId: string) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {AppRegistry, View} from 'react-native';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import KeyboardRegistry from '../
|
|
3
|
+
import KeyboardRegistry from '../index';
|
|
4
4
|
|
|
5
5
|
describe('KeyboardRegistry - components', () => {
|
|
6
6
|
const mockComponent = 'test_component';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import EventEmitterManager from './
|
|
1
|
+
import EventEmitterManager from './EventEmitterManager';
|
|
2
2
|
/**
|
|
3
3
|
* @description: used for registering keyboards and performing certain actions on the keyboards.
|
|
4
4
|
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/nativeComponentScreens/keyboardAccessory/demoKeyboards.js
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _intersection from "lodash/intersection";
|
|
2
2
|
import _isFunction from "lodash/isFunction";
|
|
3
3
|
import { AppRegistry } from 'react-native';
|
|
4
|
-
import EventEmitterManager from "./
|
|
4
|
+
import EventEmitterManager from "./EventEmitterManager";
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* Tech debt: how to deal with multiple registries in the app?
|
|
@@ -1,49 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "KeyboardRegistry",
|
|
3
3
|
"category": "infra",
|
|
4
|
-
"description": "used for registering keyboards and performing certain actions on the keyboards
|
|
4
|
+
"description": "used for registering keyboards and performing certain actions on the keyboards",
|
|
5
5
|
"example": "https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/nativeComponentScreens/keyboardAccessory/demoKeyboards.js",
|
|
6
6
|
"props": [
|
|
7
7
|
{
|
|
8
8
|
"name": "registerKeyboard",
|
|
9
9
|
"type": "static function",
|
|
10
|
-
"description": "Register a new keyboard.\ncomponentID (string) - the ID of the keyboard.\ngenerator (function) - a function for the creation of the keyboard.\nparams (object) - to be returned when using other methods (i.e. getKeyboards and getAllKeyboards)
|
|
10
|
+
"description": "Register a new keyboard.\ncomponentID (string) - the ID of the keyboard.\ngenerator (function) - a function for the creation of the keyboard.\nparams (object) - to be returned when using other methods (i.e. getKeyboards and getAllKeyboards)"
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
"name": "getKeyboard",
|
|
14
14
|
"type": "static function",
|
|
15
|
-
"description": "Get a specific keyboard\ncomponentID (string) - the ID of the keyboard
|
|
15
|
+
"description": "Get a specific keyboard\ncomponentID (string) - the ID of the keyboard"
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"name": "getKeyboards",
|
|
19
19
|
"type": "static function",
|
|
20
|
-
"description": "Get keyboards by IDs\ncomponentIDs (string[]) - the ID of the keyboard
|
|
20
|
+
"description": "Get keyboards by IDs\ncomponentIDs (string[]) - the ID of the keyboard"
|
|
21
21
|
},
|
|
22
22
|
{"name": "getAllKeyboards", "type": "static function", "description": "Get all keyboards"},
|
|
23
23
|
{
|
|
24
24
|
"name": "addListener",
|
|
25
25
|
"type": "static function",
|
|
26
|
-
"description": "Add a listener for a callback.\nglobalID (string) - ID that includes the componentID and the event name\n
|
|
26
|
+
"description": "Add a listener for a callback.\nglobalID (string) - ID that includes the componentID and the event name\n(i.e. if componentID='kb1' globalID='kb1.onItemSelected')\ncallback (function) - the callback to be called when the said event happens"
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
"name": "notifyListeners",
|
|
30
30
|
"type": "static function",
|
|
31
|
-
"description": "Notify that an event has occurred.\nglobalID (string) - ID that includes the componentID and the event name\n
|
|
31
|
+
"description": "Notify that an event has occurred.\nglobalID (string) - ID that includes the componentID and the event name\n(i.e. if componentID='kb1' globalID='kb1.onItemSelected')\nargs (object) - data to be sent to the listener"
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
"name": "removeListeners",
|
|
35
35
|
"type": "static function",
|
|
36
|
-
"description": "Remove a listener for a callback.\nglobalID (string) - ID that includes the componentID and the event name\n
|
|
36
|
+
"description": "Remove a listener for a callback.\nglobalID (string) - ID that includes the componentID and the event name\n(i.e. if componentID='kb1' globalID='kb1.onItemSelected')"
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
"name": "onItemSelected",
|
|
40
40
|
"type": "static function",
|
|
41
|
-
"description": "Default event to be used for when an item on the keyboard has been pressed.\ncomponentID (string) - the ID of the keyboard.\nargs (object) - data to be sent to the listener
|
|
41
|
+
"description": "Default event to be used for when an item on the keyboard has been pressed.\ncomponentID (string) - the ID of the keyboard.\nargs (object) - data to be sent to the listener"
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
"name": "requestShowKeyboard",
|
|
45
45
|
"type": "static function",
|
|
46
|
-
"description": "Request to show the keyboard\ncomponentID (string) - the ID of the keyboard
|
|
46
|
+
"description": "Request to show the keyboard\ncomponentID (string) - the ID of the keyboard"
|
|
47
47
|
}
|
|
48
48
|
],
|
|
49
49
|
"snippet": ["KeyboardRegistry.registerKeyboard('keyboardName$1', () => KeyboardComponent$2)"]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default class KeyboardUtils {
|
|
2
|
+
static displayName: string;
|
|
3
|
+
private static listeners;
|
|
4
|
+
private static addListener;
|
|
5
|
+
private static removeListener;
|
|
6
|
+
/**
|
|
7
|
+
* Used to dismiss (close) the keyboard.
|
|
8
|
+
*/
|
|
9
|
+
static dismiss: () => void;
|
|
10
|
+
}
|
|
11
|
+
interface KeyboardHeightProps {
|
|
12
|
+
id: string;
|
|
13
|
+
onDismiss: () => void;
|
|
14
|
+
}
|
|
15
|
+
declare const useKeyboardHeight: ({ id, onDismiss }: KeyboardHeightProps) => {
|
|
16
|
+
keyboardHeight: number;
|
|
17
|
+
isKeyboardVisible: boolean;
|
|
18
|
+
};
|
|
19
|
+
export interface KeyboardHeightListenerProps {
|
|
20
|
+
id: string;
|
|
21
|
+
onDismiss: () => void;
|
|
22
|
+
onKeyboardHeightChange?: (height: number) => void;
|
|
23
|
+
onKeyboardVisibilityChange?: (isKeyboardVisible: boolean) => void;
|
|
24
|
+
}
|
|
25
|
+
declare const KeyboardHeightListener: ({ id, onDismiss, onKeyboardHeightChange, onKeyboardVisibilityChange }: KeyboardHeightListenerProps) => null;
|
|
26
|
+
export { useKeyboardHeight, KeyboardHeightListener };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { Keyboard, Platform } from 'react-native';
|
|
3
|
+
import TextInputKeyboardManager from "../TextInputKeyboardManager";
|
|
4
|
+
const IS_IOS = Platform.OS === 'ios';
|
|
5
|
+
const DEFAULT_KEYBOARD_HEIGHT = IS_IOS ? 216 : 312; // TODO: verify this value for iOS
|
|
6
|
+
|
|
7
|
+
export default class KeyboardUtils {
|
|
8
|
+
static displayName = 'KeyboardUtils';
|
|
9
|
+
static listeners = {};
|
|
10
|
+
static addListener = (id, onDismiss) => {
|
|
11
|
+
if (id && onDismiss && !KeyboardUtils.listeners[id]) {
|
|
12
|
+
KeyboardUtils.listeners[id] = onDismiss;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
static removeListener = id => {
|
|
16
|
+
if (id && KeyboardUtils.listeners[id]) {
|
|
17
|
+
delete KeyboardUtils.listeners[id];
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Used to dismiss (close) the keyboard.
|
|
23
|
+
*/
|
|
24
|
+
static dismiss = () => {
|
|
25
|
+
Keyboard.dismiss();
|
|
26
|
+
TextInputKeyboardManager.dismissKeyboard();
|
|
27
|
+
Object.keys(KeyboardUtils.listeners).forEach(key => {
|
|
28
|
+
KeyboardUtils.listeners[key]();
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const useKeyboardHeight = ({
|
|
33
|
+
id,
|
|
34
|
+
onDismiss
|
|
35
|
+
}) => {
|
|
36
|
+
const [isInitialized, setIsInitialized] = useState(false);
|
|
37
|
+
const [keyboardHeight, setKeyboardHeight] = useState(DEFAULT_KEYBOARD_HEIGHT);
|
|
38
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
39
|
+
const keyboardDidShow = useCallback(e => {
|
|
40
|
+
if (!isInitialized) {
|
|
41
|
+
setIsInitialized(true);
|
|
42
|
+
setKeyboardHeight(e.endCoordinates.height);
|
|
43
|
+
}
|
|
44
|
+
setIsVisible(true);
|
|
45
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
+
}, []);
|
|
47
|
+
const keyboardDidHide = useCallback(() => {
|
|
48
|
+
setIsVisible(false);
|
|
49
|
+
}, []);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', keyboardDidShow);
|
|
52
|
+
const keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', keyboardDidHide);
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
KeyboardUtils.addListener(id, onDismiss);
|
|
55
|
+
return () => {
|
|
56
|
+
keyboardDidShowListener.remove();
|
|
57
|
+
keyboardDidHideListener.remove();
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
KeyboardUtils.removeListener(id);
|
|
60
|
+
};
|
|
61
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
62
|
+
}, []);
|
|
63
|
+
return {
|
|
64
|
+
keyboardHeight,
|
|
65
|
+
isKeyboardVisible: isVisible
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
const KeyboardHeightListener = ({
|
|
69
|
+
id,
|
|
70
|
+
onDismiss,
|
|
71
|
+
onKeyboardHeightChange,
|
|
72
|
+
onKeyboardVisibilityChange
|
|
73
|
+
}) => {
|
|
74
|
+
const {
|
|
75
|
+
keyboardHeight,
|
|
76
|
+
isKeyboardVisible
|
|
77
|
+
} = useKeyboardHeight({
|
|
78
|
+
id,
|
|
79
|
+
onDismiss
|
|
80
|
+
});
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
onKeyboardHeightChange?.(keyboardHeight);
|
|
83
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
84
|
+
}, [keyboardHeight]);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
onKeyboardVisibilityChange?.(isKeyboardVisible);
|
|
87
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
88
|
+
}, [isKeyboardVisible]);
|
|
89
|
+
return null;
|
|
90
|
+
};
|
|
91
|
+
export { useKeyboardHeight, KeyboardHeightListener };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import { LayoutChangeEvent } from 'react-native';
|
|
3
|
-
import { KeyboardTrackingViewProps } from '../
|
|
3
|
+
import { KeyboardTrackingViewProps } from '../KeyboardTrackingView';
|
|
4
4
|
type kbTrackingViewProps = Pick<KeyboardTrackingViewProps, 'scrollBehavior' | 'revealKeyboardInteractive' | 'manageScrollView' | 'requiresSameParentToManageScrollView' | 'allowHitsOutsideBounds' | 'addBottomView' | 'bottomViewColor' | 'useSafeArea' | 'usesBottomTabs'>;
|
|
5
5
|
export type KeyboardAccessoryViewProps = kbTrackingViewProps & {
|
|
6
6
|
/**
|
|
@@ -58,9 +58,16 @@ declare class KeyboardAccessoryView extends Component<KeyboardAccessoryViewProps
|
|
|
58
58
|
allowHitsOutsideBounds: boolean;
|
|
59
59
|
scrollBehavior: any;
|
|
60
60
|
};
|
|
61
|
+
static currentId: number;
|
|
61
62
|
customInputControllerEventsSubscriber: any;
|
|
62
63
|
trackingViewRef: any;
|
|
64
|
+
subscription: any;
|
|
65
|
+
id: number;
|
|
63
66
|
constructor(props: KeyboardAccessoryViewProps);
|
|
67
|
+
state: {
|
|
68
|
+
keyboardHeight: number;
|
|
69
|
+
shouldFocus: boolean;
|
|
70
|
+
};
|
|
64
71
|
componentWillUnmount(): void;
|
|
65
72
|
onContainerComponentHeightChanged(event: LayoutChangeEvent): void;
|
|
66
73
|
onAndroidBackPressed(): boolean;
|
|
@@ -69,6 +76,9 @@ declare class KeyboardAccessoryView extends Component<KeyboardAccessoryViewProps
|
|
|
69
76
|
registerAndroidBackHandler(): void;
|
|
70
77
|
processInitialProps(): any;
|
|
71
78
|
scrollToStart(): void;
|
|
79
|
+
onKeyboardHeightChange: (keyboardHeight: number) => void;
|
|
80
|
+
onDismiss: () => void;
|
|
81
|
+
onKeyboardDismiss: () => void;
|
|
72
82
|
render(): React.JSX.Element;
|
|
73
83
|
}
|
|
74
84
|
export default KeyboardAccessoryView;
|