react-native-external-keyboard 0.5.2 → 0.5.3
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/README.md +13 -0
- package/android/src/main/java/com/externalkeyboard/ExternalKeyboardViewPackage.java +34 -6
- package/android/src/main/java/com/externalkeyboard/modules/ExternalKeyboardModule.java +52 -0
- package/android/src/main/java/com/externalkeyboard/views/TextInputFocusWrapper/TextInputFocusWrapper.java +55 -17
- package/android/src/main/java/com/externalkeyboard/views/TextInputFocusWrapper/TextInputFocusWrapperManager.java +5 -3
- package/android/src/newarch/ExternalKeyboardModuleSpec.java +9 -0
- package/android/src/oldarch/ExternalKeyboardModuleSpec.java +13 -0
- package/ios/Modules/RNCEKVExternalKeyboardModule.h +17 -0
- package/ios/Modules/RNCEKVExternalKeyboardModule.mm +40 -0
- package/lib/commonjs/components/KeyboardFocusView/KeyboardFocusView.js +8 -1
- package/lib/commonjs/components/KeyboardFocusView/KeyboardFocusView.js.map +1 -1
- package/lib/commonjs/index.js +5 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/modules/Keyboard.android.js +26 -0
- package/lib/commonjs/modules/Keyboard.android.js.map +1 -0
- package/lib/commonjs/modules/Keyboard.js +11 -0
- package/lib/commonjs/modules/Keyboard.js.map +1 -0
- package/lib/commonjs/nativeSpec/NativeExternalKeyboardModule.js +9 -0
- package/lib/commonjs/nativeSpec/NativeExternalKeyboardModule.js.map +1 -0
- package/lib/commonjs/utils/useFocusStyle.js.map +1 -1
- package/lib/commonjs/utils/withKeyboardFocus.js +2 -0
- package/lib/commonjs/utils/withKeyboardFocus.js.map +1 -1
- package/lib/module/components/KeyboardFocusView/KeyboardFocusView.js +9 -2
- package/lib/module/components/KeyboardFocusView/KeyboardFocusView.js.map +1 -1
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/Keyboard.android.js +19 -0
- package/lib/module/modules/Keyboard.android.js.map +1 -0
- package/lib/module/modules/Keyboard.js +5 -0
- package/lib/module/modules/Keyboard.js.map +1 -0
- package/lib/module/nativeSpec/NativeExternalKeyboardModule.js +3 -0
- package/lib/module/nativeSpec/NativeExternalKeyboardModule.js.map +1 -0
- package/lib/module/utils/useFocusStyle.js.map +1 -1
- package/lib/module/utils/withKeyboardFocus.js +2 -0
- package/lib/module/utils/withKeyboardFocus.js.map +1 -1
- package/lib/typescript/src/components/BaseKeyboardView/BaseKeyboardView.d.ts +1 -22
- package/lib/typescript/src/components/BaseKeyboardView/BaseKeyboardView.d.ts.map +1 -1
- package/lib/typescript/src/components/KeyboardFocusView/KeyboardFocusView.d.ts +2 -22
- package/lib/typescript/src/components/KeyboardFocusView/KeyboardFocusView.d.ts.map +1 -1
- package/lib/typescript/src/components/Touchable/Pressable.d.ts +1 -14
- package/lib/typescript/src/components/Touchable/Pressable.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/modules/Keyboard.android.d.ts +3 -0
- package/lib/typescript/src/modules/Keyboard.android.d.ts.map +1 -0
- package/lib/typescript/src/modules/Keyboard.d.ts +2 -0
- package/lib/typescript/src/modules/Keyboard.d.ts.map +1 -0
- package/lib/typescript/src/nativeSpec/NativeExternalKeyboardModule.d.ts +7 -0
- package/lib/typescript/src/nativeSpec/NativeExternalKeyboardModule.d.ts.map +1 -0
- package/lib/typescript/src/types/BaseKeyboardView.d.ts +2 -1
- package/lib/typescript/src/types/BaseKeyboardView.d.ts.map +1 -1
- package/lib/typescript/src/types/KeyboardFocusView.types.d.ts +4 -3
- package/lib/typescript/src/types/KeyboardFocusView.types.d.ts.map +1 -1
- package/lib/typescript/src/utils/useFocusStyle.d.ts +3 -3
- package/lib/typescript/src/utils/useFocusStyle.d.ts.map +1 -1
- package/lib/typescript/src/utils/withKeyboardFocus.d.ts +11 -14
- package/lib/typescript/src/utils/withKeyboardFocus.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/KeyboardFocusView/KeyboardFocusView.tsx +12 -1
- package/src/index.tsx +2 -0
- package/src/modules/Keyboard.android.ts +29 -0
- package/src/modules/Keyboard.ts +5 -0
- package/src/nativeSpec/NativeExternalKeyboardModule.ts +8 -0
- package/src/types/BaseKeyboardView.ts +4 -1
- package/src/types/KeyboardFocusView.types.ts +9 -3
- package/src/utils/useFocusStyle.tsx +4 -4
- package/src/utils/withKeyboardFocus.tsx +29 -27
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { NativeSyntheticEvent, GestureResponderEvent } from 'react-native';
|
|
2
2
|
import type { FocusStyle } from './FocusStyle';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
BaseFocusViewProps,
|
|
5
|
+
BaseKeyboardViewProps,
|
|
6
|
+
OnKeyPress,
|
|
7
|
+
} from './BaseKeyboardView';
|
|
4
8
|
|
|
5
9
|
export type KeyboardFocusEvent = NativeSyntheticEvent<{
|
|
6
10
|
isFocused: boolean;
|
|
@@ -12,10 +16,12 @@ export type FocusStateCallbackType = {
|
|
|
12
16
|
readonly focused: boolean;
|
|
13
17
|
};
|
|
14
18
|
|
|
15
|
-
export type
|
|
19
|
+
export type FocusViewProps = {
|
|
16
20
|
focusStyle?: FocusStyle;
|
|
17
21
|
onPress?: (e: GestureResponderEvent | OnKeyPress) => void;
|
|
18
22
|
onLongPress?: (e?: GestureResponderEvent | OnKeyPress) => void;
|
|
19
23
|
onFocus?: () => void;
|
|
20
24
|
onBlur?: () => void;
|
|
21
|
-
};
|
|
25
|
+
} & BaseFocusViewProps;
|
|
26
|
+
|
|
27
|
+
export type KeyboardFocusViewProps = BaseKeyboardViewProps & FocusViewProps;
|
|
@@ -20,18 +20,18 @@ const backgroundTintMap = Platform.select<Partial<Record<TintType, boolean>>>({
|
|
|
20
20
|
|
|
21
21
|
const DEFAULT_BACKGROUND_TINT = '#dce3f9';
|
|
22
22
|
|
|
23
|
-
type UseFocusStyleProps = {
|
|
23
|
+
type UseFocusStyleProps<C> = {
|
|
24
24
|
focusStyle?: FocusStyle;
|
|
25
25
|
containerFocusStyle?: FocusStyle;
|
|
26
26
|
onFocusChange?: (isFocused: boolean) => void;
|
|
27
27
|
tintColor?: ColorValue;
|
|
28
28
|
tintType?: TintType;
|
|
29
29
|
style?: PressableProps['style'];
|
|
30
|
-
Component?: React.ComponentType
|
|
30
|
+
Component?: React.ComponentType<C>;
|
|
31
31
|
withPressedStyle?: boolean;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
export const useFocusStyle = ({
|
|
34
|
+
export const useFocusStyle = <C extends {}>({
|
|
35
35
|
focusStyle,
|
|
36
36
|
onFocusChange,
|
|
37
37
|
containerFocusStyle,
|
|
@@ -40,7 +40,7 @@ export const useFocusStyle = ({
|
|
|
40
40
|
style,
|
|
41
41
|
Component,
|
|
42
42
|
withPressedStyle = false,
|
|
43
|
-
}: UseFocusStyleProps) => {
|
|
43
|
+
}: UseFocusStyleProps<C>) => {
|
|
44
44
|
const [focused, setFocusStatus] = useState(false);
|
|
45
45
|
|
|
46
46
|
const onFocusChangeHandler = useCallback(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useMemo } from 'react';
|
|
1
|
+
import React, { useCallback, useMemo, type RefObject } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
View,
|
|
4
4
|
StyleSheet,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
type PressableProps,
|
|
8
8
|
} from 'react-native';
|
|
9
9
|
import { BaseKeyboardView } from '../components';
|
|
10
|
-
import type { FocusStyle
|
|
10
|
+
import type { FocusStyle } from '../types';
|
|
11
11
|
import type { KeyboardFocus, OnKeyPress } from '../types/BaseKeyboardView';
|
|
12
12
|
import { useFocusStyle } from './useFocusStyle';
|
|
13
13
|
import type { TintType } from '../types/WithKeyboardFocus';
|
|
@@ -17,35 +17,35 @@ import {
|
|
|
17
17
|
} from '../components/RenderPropComponent/RenderPropComponent';
|
|
18
18
|
import { useKeyboardPress } from './useKeyboardPress/useKeyboardPress';
|
|
19
19
|
import { IsViewFocusedContext } from '../context/IsViewFocusedContext';
|
|
20
|
+
import type { FocusViewProps } from '../types/KeyboardFocusView.types';
|
|
20
21
|
|
|
21
|
-
type
|
|
22
|
-
onPress?: T;
|
|
23
|
-
onLongPress?: T;
|
|
24
|
-
onPressIn?: K;
|
|
25
|
-
onPressOut?: K;
|
|
22
|
+
export type KeyboardPressType<K, T> = {
|
|
23
|
+
onPress?: T | ((e?: OnKeyPress) => void);
|
|
24
|
+
onLongPress?: T | ((e?: OnKeyPress) => void);
|
|
25
|
+
onPressIn?: K | ((e?: OnKeyPress) => void);
|
|
26
|
+
onPressOut?: K | ((e?: OnKeyPress) => void);
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
export
|
|
29
|
-
|
|
29
|
+
export type WithKeyboardProps<R> = {
|
|
30
|
+
withPressedStyle?: boolean;
|
|
31
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
32
|
+
containerFocusStyle?: FocusStyle;
|
|
33
|
+
tintType?: TintType;
|
|
34
|
+
componentRef?: RefObject<R>;
|
|
35
|
+
FocusHoverComponent?: RenderProp;
|
|
36
|
+
style?: PressableProps['style'];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type WithKeyboardFocus<K, T, C, R> = C &
|
|
40
|
+
KeyboardPressType<K, T> &
|
|
41
|
+
FocusViewProps &
|
|
42
|
+
WithKeyboardProps<R>;
|
|
43
|
+
|
|
44
|
+
export const withKeyboardFocus = <K, T, C extends {}, R>(
|
|
45
|
+
Component: React.ComponentType<C>
|
|
30
46
|
) => {
|
|
31
47
|
const WithKeyboardFocus = React.memo(
|
|
32
|
-
React.forwardRef<
|
|
33
|
-
View | KeyboardFocus,
|
|
34
|
-
{
|
|
35
|
-
onPress?: T | ((e?: OnKeyPress) => void);
|
|
36
|
-
onLongPress?: T | ((e?: OnKeyPress) => void);
|
|
37
|
-
onPressIn?: K | ((e?: OnKeyPress) => void);
|
|
38
|
-
onPressOut?: K | ((e?: OnKeyPress) => void);
|
|
39
|
-
disabled?: boolean;
|
|
40
|
-
withPressedStyle?: boolean;
|
|
41
|
-
} & Omit<KeyboardFocusViewProps, 'onPress' | 'onLongPress' | 'style'> & {
|
|
42
|
-
containerStyle?: StyleProp<ViewStyle>;
|
|
43
|
-
containerFocusStyle?: FocusStyle;
|
|
44
|
-
tintType?: TintType;
|
|
45
|
-
FocusHoverComponent?: RenderProp;
|
|
46
|
-
style?: PressableProps['style'];
|
|
47
|
-
}
|
|
48
|
-
>(
|
|
48
|
+
React.forwardRef<View | KeyboardFocus, WithKeyboardFocus<K, T, C, R>>(
|
|
49
49
|
(
|
|
50
50
|
{
|
|
51
51
|
tintType = 'default',
|
|
@@ -70,6 +70,7 @@ export const withKeyboardFocus = <K, T>(
|
|
|
70
70
|
containerFocusStyle,
|
|
71
71
|
FocusHoverComponent,
|
|
72
72
|
viewRef,
|
|
73
|
+
componentRef,
|
|
73
74
|
haloCornerRadius,
|
|
74
75
|
haloExpendX,
|
|
75
76
|
haloExpendY,
|
|
@@ -147,12 +148,13 @@ export const withKeyboardFocus = <K, T>(
|
|
|
147
148
|
groupIdentifier={groupIdentifier}
|
|
148
149
|
>
|
|
149
150
|
<Component
|
|
151
|
+
ref={componentRef}
|
|
150
152
|
style={componentStyleViewStyle}
|
|
151
153
|
onPress={onPressHandler as T}
|
|
152
154
|
onLongPress={onLongPress as T}
|
|
153
155
|
onPressIn={onPressIn as K}
|
|
154
156
|
onPressOut={onPressOut as K}
|
|
155
|
-
{...(props as
|
|
157
|
+
{...(props as unknown as C)}
|
|
156
158
|
/>
|
|
157
159
|
{focused && HoverComonent && (
|
|
158
160
|
<RenderPropComponent render={HoverComonent} />
|