react-native-external-keyboard 0.8.5 → 0.9.1

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.
Files changed (159) hide show
  1. package/README.md +149 -67
  2. package/android/src/main/java/com/externalkeyboard/delegates/FocusOrderDelegate.java +81 -75
  3. package/android/src/main/java/com/externalkeyboard/delegates/FocusOrderDelegateHost.java +14 -0
  4. package/android/src/main/java/com/externalkeyboard/helper/Linking/A11yOrderLinking.java +5 -0
  5. package/android/src/main/java/com/externalkeyboard/modules/ExternalKeyboardModule.java +10 -10
  6. package/android/src/main/java/com/externalkeyboard/services/FocusLinkObserver/FocusLinkObserver.java +26 -35
  7. package/android/src/main/java/com/externalkeyboard/views/ExternalKeyboardLockView/ExternalKeyboardLockView.java +5 -0
  8. package/android/src/main/java/com/externalkeyboard/views/ExternalKeyboardLockView/ExternalKeyboardLockViewManager.java +6 -0
  9. package/android/src/main/java/com/externalkeyboard/views/ExternalKeyboardView/ExternalKeyboardView.java +8 -307
  10. package/android/src/main/java/com/externalkeyboard/views/ExternalKeyboardView/ExternalKeyboardViewManager.java +11 -18
  11. package/android/src/main/java/com/externalkeyboard/views/TextInputFocusWrapper/TextInputFocusWrapper.java +208 -101
  12. package/android/src/main/java/com/externalkeyboard/views/TextInputFocusWrapper/TextInputFocusWrapperManager.java +123 -34
  13. package/android/src/main/java/com/externalkeyboard/views/base/FocusHighlightBase.java +38 -0
  14. package/android/src/main/java/com/externalkeyboard/views/base/ViewGroupBase.java +19 -0
  15. package/android/src/main/java/com/externalkeyboard/views/base/ViewOrderGroupBase.java +190 -0
  16. package/android/src/main/java/com/externalkeyboard/views/base/keyboard/ViewFocusChangeBase.java +39 -0
  17. package/android/src/main/java/com/externalkeyboard/views/base/keyboard/ViewFocusRequestBase.java +125 -0
  18. package/android/src/main/java/com/externalkeyboard/views/base/keyboard/ViewKeyHandlerBase.java +40 -0
  19. package/android/src/newarch/TextInputFocusWrapperManagerSpec.java +2 -8
  20. package/android/src/oldarch/ExternalKeyboardLockViewManagerSpec.java +1 -0
  21. package/android/src/oldarch/TextInputFocusWrapperManagerSpec.java +32 -2
  22. package/ios/Delegates/RNCEKVFocusLinkDelegate/RNCEKVFocusLinkDelegate.h +35 -0
  23. package/ios/Delegates/RNCEKVFocusLinkDelegate/RNCEKVFocusLinkDelegate.mm +195 -0
  24. package/ios/Delegates/RNCEKVFocusOrderDelegate/RNCEKVFocusOrderProtocol.h +6 -8
  25. package/ios/Delegates/RNCEKVFocusSequenceDelegate/RNCEKVFocusSequenceDelegate.h +25 -0
  26. package/ios/Delegates/RNCEKVFocusSequenceDelegate/RNCEKVFocusSequenceDelegate.mm +163 -0
  27. package/ios/Delegates/RNCEKVGroupIdentifierDelegate/RNCEKVGroupIdentifierDelegate.h +2 -6
  28. package/ios/Delegates/RNCEKVGroupIdentifierDelegate/RNCEKVGroupIdentifierDelegate.mm +6 -78
  29. package/ios/Delegates/RNCEKVHaloDelegate/RNCEKVHaloDelegate.h +3 -4
  30. package/ios/Delegates/RNCEKVHaloDelegate/RNCEKVHaloDelegate.mm +32 -101
  31. package/ios/Delegates/RNCEKVHaloDelegate/RNCEKVHaloProtocol.h +1 -1
  32. package/ios/Extensions/RCTEnhancedScrollView+RNCEKVExternalKeyboard.mm +1 -1
  33. package/ios/Extensions/RCTTextInputComponentView+RNCEKVExternalKeyboard.mm +15 -0
  34. package/ios/Extensions/RCTViewComponentView+RNCEKVExternalKeyboard.h +9 -6
  35. package/ios/Extensions/RCTViewComponentView+RNCEKVExternalKeyboard.mm +16 -29
  36. package/ios/Extensions/UIViewController+RNCEKVExternalKeyboard.h +1 -0
  37. package/ios/Extensions/UIViewController+RNCEKVExternalKeyboard.mm +8 -0
  38. package/ios/Helpers/RNCEKVNativeProps/RNCEKVNativeProps.h +123 -0
  39. package/ios/Protocols/RNCEKVCustomFocusEffectProtocol.h +15 -0
  40. package/ios/Protocols/RNCEKVCustomGroudIdProtocol.h +15 -0
  41. package/ios/Protocols/RNCEKVKeyboardFocusableProtocol.h +15 -0
  42. package/ios/Services/RNCEKVFocusLinkObserver.mm +2 -3
  43. package/ios/Services/RNCEKVKeyboardOrderManager/RNCEKVOrderRelationship/RNCEKVOrderRelationship.mm +15 -28
  44. package/ios/Services/RNCEKVOrderLinking.mm +43 -51
  45. package/ios/Views/Base/ContextMenu/RNCEKVViewContextMenuBase.h +33 -0
  46. package/ios/Views/Base/ContextMenu/RNCEKVViewContextMenuBase.mm +84 -0
  47. package/ios/Views/Base/FocusChange/RNCEKVViewFocusChangeBase.h +37 -0
  48. package/ios/Views/Base/FocusChange/RNCEKVViewFocusChangeBase.mm +89 -0
  49. package/ios/Views/Base/FocusOrderGroup/RNCEKVViewOrderGroupBase.h +49 -0
  50. package/ios/Views/Base/FocusOrderGroup/RNCEKVViewOrderGroupBase.mm +245 -0
  51. package/ios/Views/Base/FocusRequest/RNCEKVViewFocusRequestBase.h +34 -0
  52. package/ios/Views/Base/FocusRequest/RNCEKVViewFocusRequestBase.mm +112 -0
  53. package/ios/Views/Base/GroupIdentifier/RNCEKVViewGroupIdentifierBase.h +27 -0
  54. package/ios/Views/Base/GroupIdentifier/RNCEKVViewGroupIdentifierBase.mm +69 -0
  55. package/ios/Views/Base/KeyPress/RNCEKVViewKeyPress.h +30 -0
  56. package/ios/Views/Base/KeyPress/RNCEKVViewKeyPress.mm +75 -0
  57. package/ios/Views/Base/KeyboardHallo/RNCEKVExternalKeyboardHalloBase.h +33 -0
  58. package/ios/Views/Base/KeyboardHallo/RNCEKVExternalKeyboardHalloBase.mm +92 -0
  59. package/ios/Views/Base/ViewGroup/RNCEKVViewGroupBase.h +36 -0
  60. package/ios/Views/Base/ViewGroup/RNCEKVViewGroupBase.mm +63 -0
  61. package/ios/Views/RNCEKVExternalKeyboardLockView/RNCEKVExternalKeyboardLockView.h +8 -0
  62. package/ios/Views/RNCEKVExternalKeyboardLockView/RNCEKVExternalKeyboardLockView.mm +105 -2
  63. package/ios/Views/RNCEKVExternalKeyboardLockView/RNCEKVExternalKeyboardLockViewManager.mm +11 -0
  64. package/ios/Views/RNCEKVExternalKeyboardView/RNCEKVExternalKeyboardView.h +7 -82
  65. package/ios/Views/RNCEKVExternalKeyboardView/RNCEKVExternalKeyboardView.mm +23 -493
  66. package/ios/Views/RNCEKVExternalKeyboardView/RNCEKVExternalKeyboardViewManager.mm +5 -7
  67. package/ios/Views/RNCEKVKeyboardFocusGroupView/RNCEKVKeyboardFocusGroup.mm +20 -17
  68. package/ios/Views/RNCEKVTextInputFocusWrapper/RNCEKVTextInputFocusWrapper.h +10 -39
  69. package/ios/Views/RNCEKVTextInputFocusWrapper/RNCEKVTextInputFocusWrapper.mm +40 -73
  70. package/ios/Views/RNCEKVTextInputFocusWrapper/RNCEKVTextInputFocusWrapperManager.mm +76 -8
  71. package/lib/commonjs/components/BaseKeyboardView/BaseKeyboardView.js +35 -7
  72. package/lib/commonjs/components/BaseKeyboardView/BaseKeyboardView.js.map +1 -1
  73. package/lib/commonjs/components/KeyboardExtendedInput/KeyboardExtendedInput.js +79 -1
  74. package/lib/commonjs/components/KeyboardExtendedInput/KeyboardExtendedInput.js.map +1 -1
  75. package/lib/commonjs/components/KeyboardFocusLock/FocusTrap/FocusTrap.js +18 -4
  76. package/lib/commonjs/components/KeyboardFocusLock/FocusTrap/FocusTrap.js.map +1 -1
  77. package/lib/commonjs/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.js +17 -2
  78. package/lib/commonjs/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.js.map +1 -1
  79. package/lib/commonjs/components/KeyboardFocusView/KeyboardFocusView.js +2 -0
  80. package/lib/commonjs/components/KeyboardFocusView/KeyboardFocusView.js.map +1 -1
  81. package/lib/commonjs/nativeSpec/ExternalKeyboardLockViewNativeComponent.ts +1 -0
  82. package/lib/commonjs/nativeSpec/TextInputFocusWrapperNativeComponent.ts +16 -0
  83. package/lib/commonjs/utils/useFocusStyle.js +3 -9
  84. package/lib/commonjs/utils/useFocusStyle.js.map +1 -1
  85. package/lib/commonjs/utils/withKeyboardFocus.js +32 -15
  86. package/lib/commonjs/utils/withKeyboardFocus.js.map +1 -1
  87. package/lib/commonjs/utils/wrapOrderPrefix.js +17 -0
  88. package/lib/commonjs/utils/wrapOrderPrefix.js.map +1 -0
  89. package/lib/module/components/BaseKeyboardView/BaseKeyboardView.js +35 -7
  90. package/lib/module/components/BaseKeyboardView/BaseKeyboardView.js.map +1 -1
  91. package/lib/module/components/KeyboardExtendedInput/KeyboardExtendedInput.js +80 -2
  92. package/lib/module/components/KeyboardExtendedInput/KeyboardExtendedInput.js.map +1 -1
  93. package/lib/module/components/KeyboardFocusLock/FocusTrap/FocusTrap.js +18 -4
  94. package/lib/module/components/KeyboardFocusLock/FocusTrap/FocusTrap.js.map +1 -1
  95. package/lib/module/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.js +16 -2
  96. package/lib/module/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.js.map +1 -1
  97. package/lib/module/components/KeyboardFocusView/KeyboardFocusView.js +2 -0
  98. package/lib/module/components/KeyboardFocusView/KeyboardFocusView.js.map +1 -1
  99. package/lib/module/nativeSpec/ExternalKeyboardLockViewNativeComponent.ts +1 -0
  100. package/lib/module/nativeSpec/TextInputFocusWrapperNativeComponent.ts +16 -0
  101. package/lib/module/utils/useFocusStyle.js +4 -10
  102. package/lib/module/utils/useFocusStyle.js.map +1 -1
  103. package/lib/module/utils/withKeyboardFocus.js +32 -15
  104. package/lib/module/utils/withKeyboardFocus.js.map +1 -1
  105. package/lib/module/utils/wrapOrderPrefix.js +12 -0
  106. package/lib/module/utils/wrapOrderPrefix.js.map +1 -0
  107. package/lib/typescript/src/components/BaseKeyboardView/BaseKeyboardView.d.ts.map +1 -1
  108. package/lib/typescript/src/components/KeyboardExtendedInput/KeyboardExtendedInput.d.ts.map +1 -1
  109. package/lib/typescript/src/components/KeyboardExtendedInput/KeyboardExtendedInput.types.d.ts +15 -0
  110. package/lib/typescript/src/components/KeyboardExtendedInput/KeyboardExtendedInput.types.d.ts.map +1 -1
  111. package/lib/typescript/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.d.ts +1 -1
  112. package/lib/typescript/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.d.ts.map +1 -1
  113. package/lib/typescript/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.d.ts +2 -1
  114. package/lib/typescript/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.d.ts.map +1 -1
  115. package/lib/typescript/src/components/KeyboardFocusView/KeyboardFocusView.d.ts.map +1 -1
  116. package/lib/typescript/src/index.d.ts +1 -1
  117. package/lib/typescript/src/nativeSpec/ExternalKeyboardLockViewNativeComponent.d.ts +1 -0
  118. package/lib/typescript/src/nativeSpec/ExternalKeyboardLockViewNativeComponent.d.ts.map +1 -1
  119. package/lib/typescript/src/nativeSpec/TextInputFocusWrapperNativeComponent.d.ts +16 -1
  120. package/lib/typescript/src/nativeSpec/TextInputFocusWrapperNativeComponent.d.ts.map +1 -1
  121. package/lib/typescript/src/types/BaseKeyboardView.d.ts +2 -0
  122. package/lib/typescript/src/types/BaseKeyboardView.d.ts.map +1 -1
  123. package/lib/typescript/src/types/KeyboardFocusLock.types.d.ts +1 -0
  124. package/lib/typescript/src/types/KeyboardFocusLock.types.d.ts.map +1 -1
  125. package/lib/typescript/src/types/WithKeyboardFocus.d.ts +11 -2
  126. package/lib/typescript/src/types/WithKeyboardFocus.d.ts.map +1 -1
  127. package/lib/typescript/src/utils/useFocusStyle.d.ts +1 -0
  128. package/lib/typescript/src/utils/useFocusStyle.d.ts.map +1 -1
  129. package/lib/typescript/src/utils/withKeyboardFocus.d.ts.map +1 -1
  130. package/lib/typescript/src/utils/wrapOrderPrefix.d.ts +9 -0
  131. package/lib/typescript/src/utils/wrapOrderPrefix.d.ts.map +1 -0
  132. package/package.json +6 -2
  133. package/src/components/BaseKeyboardView/BaseKeyboardView.tsx +88 -10
  134. package/src/components/KeyboardExtendedInput/KeyboardExtendedInput.tsx +138 -2
  135. package/src/components/KeyboardExtendedInput/KeyboardExtendedInput.types.ts +15 -0
  136. package/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.tsx +21 -4
  137. package/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.tsx +20 -3
  138. package/src/components/KeyboardFocusView/KeyboardFocusView.tsx +2 -0
  139. package/src/nativeSpec/ExternalKeyboardLockViewNativeComponent.ts +1 -0
  140. package/src/nativeSpec/TextInputFocusWrapperNativeComponent.ts +16 -0
  141. package/src/types/BaseKeyboardView.ts +2 -0
  142. package/src/types/KeyboardFocusLock.types.ts +1 -0
  143. package/src/types/WithKeyboardFocus.ts +19 -2
  144. package/src/utils/useFocusStyle.tsx +5 -15
  145. package/src/utils/withKeyboardFocus.tsx +44 -15
  146. package/src/utils/wrapOrderPrefix.ts +16 -0
  147. package/ios/Delegates/RNCEKVFocusOrderDelegate/RNCEKVFocusGuideDelegate/RNCEKVFocusGuideDelegate.h +0 -36
  148. package/ios/Delegates/RNCEKVFocusOrderDelegate/RNCEKVFocusGuideDelegate/RNCEKVFocusGuideDelegate.mm +0 -150
  149. package/ios/Delegates/RNCEKVFocusOrderDelegate/RNCEKVFocusOrderDelegate.h +0 -47
  150. package/ios/Delegates/RNCEKVFocusOrderDelegate/RNCEKVFocusOrderDelegate.mm +0 -326
  151. package/ios/Services/RNCEKVKeyboardOrderManager/RNCEKVKeyboardOrderManager.h +0 -17
  152. package/ios/Services/RNCEKVKeyboardOrderManager/RNCEKVKeyboardOrderManager.mm +0 -15
  153. package/lib/commonjs/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.android.js +0 -22
  154. package/lib/commonjs/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.android.js.map +0 -1
  155. package/lib/module/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.android.js +0 -17
  156. package/lib/module/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.android.js.map +0 -1
  157. package/lib/typescript/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.android.d.ts +0 -4
  158. package/lib/typescript/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.android.d.ts.map +0 -1
  159. package/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.android.tsx +0 -16
@@ -1,6 +1,7 @@
1
1
  import type { ViewProps, ColorValue } from 'react-native';
2
2
  import type {
3
3
  DirectEventHandler,
4
+ Float,
4
5
  Int32,
5
6
  } from 'react-native/Libraries/Types/CodegenTypes';
6
7
  // eslint-disable-next-line @react-native/no-deep-imports
@@ -21,10 +22,25 @@ export interface TextInputFocusWrapperNativeComponent extends ViewProps {
21
22
  blurType?: Int32;
22
23
  canBeFocused?: boolean;
23
24
  haloEffect?: boolean;
25
+ haloCornerRadius?: Float;
26
+ haloExpendX?: Float;
27
+ haloExpendY?: Float;
24
28
  tintColor?: ColorValue;
25
29
  blurOnSubmit?: boolean;
26
30
  multiline?: boolean;
27
31
  groupIdentifier?: string;
32
+ lockFocus?: Int32;
33
+ orderGroup?: string;
34
+ orderIndex?: Int32;
35
+ orderId?: string;
36
+ orderLeft?: string;
37
+ orderRight?: string;
38
+ orderUp?: string;
39
+ orderDown?: string;
40
+ orderForward?: string;
41
+ orderBackward?: string;
42
+ orderFirst?: string;
43
+ orderLast?: string;
28
44
  }
29
45
 
30
46
  export default codegenNativeComponent<TextInputFocusWrapperNativeComponent>(
@@ -67,6 +67,8 @@ export type BaseFocusViewProps = {
67
67
  orderBackward?: string;
68
68
  orderFirst?: string | null;
69
69
  orderLast?: string | null;
70
+ orderPrefix?: string;
71
+ defaultFocusHighlightEnabled?: boolean;
70
72
  };
71
73
 
72
74
  export type BaseKeyboardViewProps = ViewProps & BaseFocusViewProps;
@@ -3,4 +3,5 @@ import type { ViewProps } from 'react-native';
3
3
  export type KeyboardFocusLockProps = ViewProps & {
4
4
  componentType?: number;
5
5
  lockDisabled?: boolean;
6
+ forceLock?: boolean;
6
7
  };
@@ -36,7 +36,18 @@ export type KeyboardPressType<ComponentProps extends object> = {
36
36
  onComponentBlur?: PickProp<ComponentProps, 'onBlur'>;
37
37
  };
38
38
 
39
- export type WithKeyboardProps<ViewType = View, ViewStyleType = unknown> = {
39
+ /** Extracts the state argument from a component's children render prop, or `never`. */
40
+ type ExtractRenderPropState<T> = T extends (state: infer S) => any ? S : never;
41
+
42
+ export type ChildrenRenderState<CP extends object> = 'children' extends keyof CP
43
+ ? ExtractRenderPropState<NonNullable<CP['children']>>
44
+ : never;
45
+
46
+ export type WithKeyboardProps<
47
+ ViewType = View,
48
+ ViewStyleType = unknown,
49
+ ComponentProps extends object = {}
50
+ > = {
40
51
  withPressedStyle?: boolean;
41
52
  containerStyle?: ViewStyleType | ViewProps['style'];
42
53
  containerFocusStyle?: FocusStyle;
@@ -46,6 +57,12 @@ export type WithKeyboardProps<ViewType = View, ViewStyleType = unknown> = {
46
57
  style?: PressableProps['style'];
47
58
  onBlur?: (() => void) | ((e: any) => void) | null;
48
59
  onFocus?: (() => void) | ((e: any) => void) | null;
60
+ renderContent?: ChildrenRenderState<ComponentProps> extends never
61
+ ? never
62
+ : (
63
+ state: ChildrenRenderState<ComponentProps> & { focused: boolean }
64
+ ) => React.ReactNode;
65
+ renderFocusable?: (state: { focused: boolean }) => React.ReactNode;
49
66
  };
50
67
 
51
68
  type KeyboardFocusBaseProps = Omit<
@@ -65,7 +82,7 @@ type KeyboardFocusOverrideProps<
65
82
  ViewType = View
66
83
  > = KeyboardPressType<ComponentProps> &
67
84
  KeyboardFocusBaseProps &
68
- WithKeyboardProps<ViewType, ViewStyleType>;
85
+ WithKeyboardProps<ViewType, ViewStyleType, ComponentProps>;
69
86
 
70
87
  export type WithKeyboardFocus<
71
88
  ComponentProps extends object,
@@ -1,22 +1,11 @@
1
1
  import { useState, useMemo, useCallback } from 'react';
2
- import {
3
- Platform,
4
- type ColorValue,
5
- type PressableProps,
6
- Pressable,
7
- } from 'react-native';
2
+ import { type ColorValue, type PressableProps, Pressable } from 'react-native';
8
3
  import type { FocusStyle } from '../types';
9
4
  import type { TintType } from '../types/WithKeyboardFocus';
10
5
 
11
- const backgroundTintMap = Platform.select<Partial<Record<TintType, boolean>>>({
12
- ios: {
13
- background: true,
14
- },
15
- default: {
16
- background: true,
17
- default: true,
18
- },
19
- });
6
+ const backgroundTintMap: Partial<Record<TintType, boolean>> = {
7
+ background: true,
8
+ };
20
9
 
21
10
  const DEFAULT_BACKGROUND_TINT = '#dce3f9';
22
11
 
@@ -29,6 +18,7 @@ type UseFocusStyleProps<C> = {
29
18
  style?: PressableProps['style'];
30
19
  Component?: React.ComponentType<C>;
31
20
  withPressedStyle?: boolean;
21
+ defaultFocusHighlightEnabled?: boolean;
32
22
  };
33
23
 
34
24
  export const useFocusStyle = <C extends {}>({
@@ -73,6 +73,9 @@ export const withKeyboardFocus = <
73
73
  lockFocus,
74
74
  onComponentFocus,
75
75
  onComponentBlur,
76
+ renderContent,
77
+ renderFocusable,
78
+ defaultFocusHighlightEnabled,
76
79
  ...props
77
80
  } = allProps as WithKeyboardFocus<ComponentProps, ViewStyleType>;
78
81
 
@@ -107,15 +110,46 @@ export const withKeyboardFocus = <
107
110
  disabled: (props as { disabled?: boolean })?.disabled,
108
111
  });
109
112
 
110
- const HoverComponent = useMemo(() => {
113
+ const contentChildrenProp = useMemo(
114
+ () =>
115
+ renderContent
116
+ ? (state: Record<string, unknown>) =>
117
+ (
118
+ renderContent as unknown as (
119
+ s: Record<string, unknown>
120
+ ) => React.ReactNode
121
+ )({ ...state, focused })
122
+ : undefined,
123
+ [renderContent, focused]
124
+ );
125
+
126
+ const focusableChildrenProp = useMemo(
127
+ () => (renderFocusable ? renderFocusable({ focused }) : undefined),
128
+ [renderFocusable, focused]
129
+ );
130
+
131
+ const hoverContent = useMemo(() => {
111
132
  if (FocusHoverComponent) return FocusHoverComponent;
112
133
  if (tintType === 'hover') {
113
134
  return <View style={[hoverColor, styles.absolute, styles.opacity]} />;
114
135
  }
115
-
116
136
  return undefined;
117
137
  }, [FocusHoverComponent, hoverColor, tintType]);
118
138
 
139
+ const focusOrderProps = {
140
+ orderIndex,
141
+ orderGroup,
142
+ orderId,
143
+ orderLeft,
144
+ orderRight,
145
+ orderUp,
146
+ orderDown,
147
+ orderForward,
148
+ orderBackward,
149
+ orderFirst,
150
+ orderLast,
151
+ };
152
+
119
153
  const onContextMenuHandler = useCallback(() => {
120
154
  (onLongPress as (e?: OnKeyPress) => void)?.();
121
155
  }, [onLongPress]);
@@ -127,6 +161,7 @@ export const withKeyboardFocus = <
127
161
  containerStyle as ViewProps['style'],
128
162
  containerFocusedStyle,
129
163
  ]}
164
+ defaultFocusHighlightEnabled={defaultFocusHighlightEnabled}
130
165
  ref={ref as RefObject<KeyboardFocus>}
131
166
  viewRef={viewRef}
132
167
  onKeyUpPress={onKeyUpPressHandler}
@@ -150,18 +185,8 @@ export const withKeyboardFocus = <
150
185
  enableA11yFocus={enableA11yFocus}
151
186
  screenAutoA11yFocus={screenAutoA11yFocus}
152
187
  screenAutoA11yFocusDelay={screenAutoA11yFocusDelay}
153
- orderIndex={orderIndex}
154
- orderGroup={orderGroup}
155
188
  lockFocus={lockFocus}
156
- orderId={orderId}
157
- orderLeft={orderLeft}
158
- orderRight={orderRight}
159
- orderUp={orderUp}
160
- orderDown={orderDown}
161
- orderForward={orderForward}
162
- orderBackward={orderBackward}
163
- orderFirst={orderFirst}
164
- orderLast={orderLast}
189
+ {...focusOrderProps}
165
190
  >
166
191
  <Component
167
192
  ref={componentRef}
@@ -181,9 +206,13 @@ export const withKeyboardFocus = <
181
206
  onFocus={onComponentFocus}
182
207
  onBlur={onComponentBlur}
183
208
  {...(props as unknown as ComponentProps)}
209
+ {...((contentChildrenProp || focusableChildrenProp) &&
210
+ ({
211
+ children: contentChildrenProp ?? focusableChildrenProp,
212
+ } as unknown as Partial<ComponentProps>))}
184
213
  />
185
- {focused && HoverComponent && (
186
- <RenderPropComponent render={HoverComponent} />
214
+ {focused && hoverContent && (
215
+ <RenderPropComponent render={hoverContent} />
187
216
  )}
188
217
  </BaseKeyboardView>
189
218
  </IsViewFocusedContext.Provider>
@@ -0,0 +1,16 @@
1
+ type Wrap = (id: string | undefined) => string | undefined;
2
+
3
+ const withPrefix =
4
+ (prefix: string): Wrap =>
5
+ (id) =>
6
+ id ? `${prefix}_${id}` : undefined;
7
+
8
+ const identity: Wrap = (id) => id;
9
+
10
+ /**
11
+ * Returns a function that prepends `prefix` to an order ID.
12
+ * When `prefix` is empty the identity function is returned — no
13
+ * per-call branch needed.
14
+ */
15
+ export const wrapOrderPrefix = (prefix: string): Wrap =>
16
+ prefix ? withPrefix(prefix) : identity;
@@ -1,36 +0,0 @@
1
- //
2
- // RNCEKVFocusGuideDelegate.h
3
- // Pods
4
- //
5
- // Created by Artur Kalach on 16/07/2025.
6
- //
7
-
8
- #ifndef RNCEKVFocusGuideDelegate_h
9
- #define RNCEKVFocusGuideDelegate_h
10
-
11
- #import <Foundation/Foundation.h>
12
- #import "RNCEKVFocusOrderProtocol.h"
13
- #import "RNCEKVFocusGuideHelper.h"
14
-
15
- @interface RNCEKVFocusGuideDelegate : NSObject
16
-
17
- - (instancetype _Nonnull)initWithView:(UIView<RNCEKVFocusOrderProtocol> *_Nonnull)view;
18
-
19
- //- (void)setLeftGuide:(UIView *_Nullable)view;
20
- //- (void)setRightGuide:(UIView *_Nullable)view;
21
- //- (void)setUpGuide:(UIView *_Nullable)view;
22
- //- (void)setDownGuide:(UIView *_Nullable)view;
23
- //
24
- //- (void)removeLeftGuide;
25
- //- (void)removeRightGuide;
26
- //- (void)removeUpGuide;
27
- //- (void)removeDownGuide;
28
-
29
- - (void)setIsFocused:(BOOL)value;
30
-
31
- - (void)setGuideFor:(RNCEKVFocusGuideDirection)direction withView: (UIView *_Nonnull)view;
32
- - (void)removeGuideFor:(RNCEKVFocusGuideDirection)direction;
33
-
34
- @end
35
-
36
- #endif /* RNCEKVFocusGuideDelegate_h */
@@ -1,150 +0,0 @@
1
- //
2
- // RNCEKVFocusGuideDelegate.m
3
- // react-native-external-keyboard
4
- //
5
- // Created by Artur Kalach on 16/07/2025.
6
- //
7
-
8
- #import <Foundation/Foundation.h>
9
- #import "RNCEKVFocusGuideDelegate.h"
10
-
11
- @implementation RNCEKVFocusGuideDelegate{
12
- BOOL _isFocused;
13
- UIView<RNCEKVFocusOrderProtocol>* _delegate;
14
- // UIFocusGuide *_leftFocusGuide;
15
- // UIFocusGuide *_rightFocusGuide;
16
- // UIFocusGuide *_upFocusGuide;
17
- // UIFocusGuide *_downFocusGuide;
18
- NSMutableDictionary<NSNumber *, UIFocusGuide*> *_sides;
19
- }
20
-
21
- - (instancetype _Nonnull )initWithView:(UIView<RNCEKVFocusOrderProtocol> *_Nonnull)delegate{
22
- self = [super init];
23
- if (self) {
24
- _delegate = delegate;
25
- _isFocused = false;
26
- _sides = [NSMutableDictionary dictionary];
27
- }
28
- return self;
29
- }
30
-
31
-
32
- - (void)setGuideFor:(RNCEKVFocusGuideDirection)direction withView: (UIView *)view {
33
- if (!view) return;
34
-
35
- [self removeGuideFor: direction];
36
- _sides[@(direction)] = [RNCEKVFocusGuideHelper setGuideForDirection: direction
37
- inView:_delegate
38
- focusView: view
39
- enabled: _isFocused];
40
- }
41
-
42
- -(void)removeGuideFor:(RNCEKVFocusGuideDirection)direction {
43
- if (_sides[@(direction)]) {
44
- [_delegate removeLayoutGuide: _sides[@(direction)]];
45
- _sides[@(direction)] = nil;
46
- }
47
- }
48
-
49
- //
50
- //
51
- //- (void)setLeftGuide:(UIView *)view {
52
- // if (!view) {
53
- // return;
54
- // }
55
- //
56
- // [self removeLeftGuide];
57
- // _leftFocusGuide = [RNCEKVFocusGuideHelper setGuideForDirection: RNCEKVFocusGuideDirectionLeft
58
- // inView:_delegate
59
- // focusView:view
60
- // enabled: _isFocused];
61
- //}
62
- //
63
- //
64
- //
65
- //- (void)setRightGuide:(UIView *)view {
66
- // if (!view) return;
67
- //
68
- // [self removeRightGuide];
69
- // _rightFocusGuide = [RNCEKVFocusGuideHelper setGuideForDirection: RNCEKVFocusGuideDirectionRight
70
- // inView:_delegate
71
- // focusView:view
72
- // enabled: _isFocused];
73
- //}
74
- //
75
- //- (void)setUpGuide:(UIView *)view {
76
- // if (!view) return;
77
- //
78
- // [self removeUpGuide];
79
- // _upFocusGuide = [RNCEKVFocusGuideHelper setGuideForDirection: RNCEKVFocusGuideDirectionUp
80
- // inView:_delegate
81
- // focusView:view
82
- // enabled: _isFocused];
83
- //}
84
- //
85
- //- (void)setDownGuide:(UIView *)view {
86
- // if (!view) return;
87
- //
88
- // [self removeDownGuide];
89
- // _downFocusGuide = [RNCEKVFocusGuideHelper setGuideForDirection: RNCEKVFocusGuideDirectionDown
90
- // inView:_delegate
91
- // focusView:view
92
- // enabled: _isFocused];
93
- //}
94
-
95
- - (void)setIsFocused:(BOOL)value {
96
- _isFocused = value;
97
-
98
- for (NSNumber *key in _sides) {
99
- UIFocusGuide* side = _sides[key];
100
- if(side) {
101
- side.enabled = value;
102
- }
103
- }
104
- //
105
- // if(_leftFocusGuide != nil) {
106
- // _leftFocusGuide.enabled = value;
107
- // }
108
- //
109
- // if(_rightFocusGuide != nil) {
110
- // _rightFocusGuide.enabled = value;
111
- // }
112
- //
113
- // if(_upFocusGuide != nil) {
114
- // _upFocusGuide.enabled = value;
115
- // }
116
- //
117
- // if(_downFocusGuide != nil) {
118
- // _downFocusGuide.enabled = value;
119
- // }
120
- }
121
- //
122
- //- (void)removeLeftGuide {
123
- // if (_leftFocusGuide) {
124
- // [_delegate removeLayoutGuide: _leftFocusGuide];
125
- // _leftFocusGuide = nil;
126
- // }
127
- //}
128
- //
129
- //- (void)removeRightGuide {
130
- // if (_rightFocusGuide) {
131
- // [_delegate removeLayoutGuide: _rightFocusGuide];
132
- // _rightFocusGuide = nil;
133
- // }
134
- //}
135
- //
136
- //- (void)removeUpGuide {
137
- // if (_upFocusGuide) {
138
- // [_delegate removeLayoutGuide:_upFocusGuide];
139
- // _upFocusGuide = nil;
140
- // }
141
- //}
142
- //
143
- //- (void)removeDownGuide {
144
- // if (_downFocusGuide) {
145
- // [_delegate removeLayoutGuide:_downFocusGuide];
146
- // _downFocusGuide = nil;
147
- // }
148
- //}
149
-
150
- @end
@@ -1,47 +0,0 @@
1
- //
2
- // RNCEKVFocusOrderDelegate.h
3
- // Pods
4
- //
5
- // Created by Artur Kalach on 25/06/2025.
6
- //
7
-
8
- #ifndef RNCEKVFocusOrderDelegate_h
9
- #define RNCEKVFocusOrderDelegate_h
10
-
11
- #import <Foundation/Foundation.h>
12
- #import "RNCEKVFocusOrderProtocol.h"
13
- #import "RNCEKVFocusGuideDelegate.h"
14
- #import "RNCEKVOrderSubscriber.h"
15
-
16
- typedef NS_ENUM(NSUInteger, RNCEKVLinkDirection) {
17
- RNCEKVLinkDirectionLeft,
18
- RNCEKVLinkDirectionRight,
19
- RNCEKVLinkDirectionUp,
20
- RNCEKVLinkDirectionDown
21
- };
22
-
23
-
24
-
25
-
26
- @interface RNCEKVFocusOrderDelegate : NSObject
27
-
28
- - (instancetype _Nonnull)initWithView:(UIView<RNCEKVFocusOrderProtocol> *_Nonnull)view;
29
-
30
- - (NSNumber*_Nullable)shouldUpdateFocusInContext:(UIFocusUpdateContext *_Nonnull)context;
31
-
32
- @property (nonatomic, strong) NSMutableDictionary<NSNumber *, RNCEKVOrderSubscriber*> * _Nonnull subscribers;
33
-
34
- - (void)linkId;
35
- - (void)refreshId:(NSString*_Nullable)prev next:(NSString*_Nullable)next;
36
- - (void)setIsFocused:(BOOL)value;
37
-
38
- - (void)refreshLeft:(NSString*_Nullable)prev next:(NSString*_Nullable)next;
39
- - (void)refreshRight:(NSString*_Nullable)prev next:(NSString*_Nullable)next;
40
- - (void)refreshUp:(NSString*_Nullable)prev next:(NSString*_Nullable)next;
41
- - (void)refreshDown:(NSString*_Nullable)prev next:(NSString*_Nullable)next;
42
- - (void)clear;
43
-
44
- @end
45
-
46
-
47
- #endif /* RNCEKVFocusOrderDelegate_h */