react-native-external-keyboard 0.9.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -600
- package/android/build.gradle +0 -18
- package/android/src/main/java/com/externalkeyboard/ExternalKeyboardViewPackage.java +24 -22
- package/android/src/main/java/com/externalkeyboard/events/EventHelper.java +10 -13
- package/android/src/main/java/com/externalkeyboard/helper/FocusHelper.java +1 -2
- package/android/src/main/java/com/externalkeyboard/services/FocusMemoryService.java +64 -0
- package/android/src/main/java/com/externalkeyboard/services/KeyboardFocusService.java +41 -0
- package/android/src/main/java/com/externalkeyboard/services/KeyboardService.java +4 -13
- package/android/src/main/java/com/externalkeyboard/views/ExternalKeyboardView/ExternalKeyboardView.java +2 -8
- package/android/src/main/java/com/externalkeyboard/views/ExternalKeyboardView/ExternalKeyboardViewManager.java +20 -13
- package/android/src/main/java/com/externalkeyboard/views/TextInputFocusWrapper/TextInputFocusWrapper.java +99 -21
- package/android/src/main/java/com/externalkeyboard/views/TextInputFocusWrapper/TextInputFocusWrapperManager.java +11 -0
- package/android/src/main/java/com/externalkeyboard/views/base/FocusHighlightBase.java +11 -5
- package/android/src/main/java/com/externalkeyboard/views/base/FocusableBase.java +36 -0
- package/android/src/main/java/com/externalkeyboard/views/base/keyboard/ViewFocusChangeBase.java +2 -3
- package/android/src/main/java/com/externalkeyboard/views/base/keyboard/ViewFocusRequestBase.java +10 -61
- package/android/src/newarch/ExternalKeyboardLockViewManagerInterface.java +11 -0
- package/android/src/newarch/ExternalKeyboardLockViewManagerSpec.java +0 -1
- package/android/src/newarch/ExternalKeyboardViewManagerInterface.java +42 -0
- package/android/src/newarch/ExternalKeyboardViewManagerSpec.java +0 -1
- package/android/src/newarch/KeyboardFocusGroupManagerInterface.java +12 -0
- package/android/src/newarch/KeyboardFocusGroupManagerSpec.java +0 -1
- package/android/src/newarch/TextInputFocusWrapperManagerInterface.java +34 -0
- package/android/src/newarch/TextInputFocusWrapperManagerSpec.java +0 -10
- package/android/src/newarch/helper/ReactNativeEventDispatcher.java +28 -0
- package/android/src/oldarch/ExternalKeyboardViewManagerSpec.java +6 -4
- package/android/src/oldarch/TextInputFocusWrapperManagerSpec.java +4 -0
- package/android/src/oldarch/helper/ReactNativeEventDispatcher.java +15 -0
- package/ios/Delegates/RNCEKVFocusDelegate/RNCEKVFocusDelegate.mm +1 -1
- package/ios/Delegates/RNCEKVFocusDelegate/RNCEKVFocusProtocol.h +1 -1
- package/ios/Delegates/RNCEKVHaloDelegate/RNCEKVHaloDelegate.h +2 -1
- package/ios/Delegates/RNCEKVHaloDelegate/RNCEKVHaloDelegate.mm +41 -5
- package/ios/Delegates/RNCEKVHaloDelegate/RNCEKVHaloProtocol.h +1 -0
- package/ios/Extensions/RCTCustomScrollView+RNCEKVExternalKeyboard.mm +5 -6
- package/ios/Extensions/RCTEnhancedScrollView+RNCEKVExternalKeyboard.mm +8 -9
- package/ios/Extensions/RCTTextInputComponentView+RNCEKVExternalKeyboard.mm +1 -1
- package/ios/Extensions/RCTViewComponentView+RNCEKVExternalKeyboard.h +0 -1
- package/ios/Extensions/RCTViewComponentView+RNCEKVExternalKeyboard.mm +16 -4
- package/ios/Extensions/UIViewController+RNCEKVExternalKeyboard.mm +7 -10
- package/ios/Helpers/RNCEKVNativeProps/RNCEKVNativeProps.h +4 -4
- package/ios/Helpers/RNCEKVSwizzleInstanceMethod/RNCEKVSwizzleInstanceMethod.h +19 -0
- package/ios/Protocols/RNCEKVCustomFocusEffectProtocol.h +1 -1
- package/ios/Services/RNCEKVFocusMemoryService.h +39 -0
- package/ios/Services/RNCEKVFocusMemoryService.mm +42 -0
- package/ios/Services/RNCEKVKeyboardFocusService.h +28 -0
- package/ios/Services/RNCEKVKeyboardFocusService.mm +54 -0
- package/ios/Views/Base/FocusChange/RNCEKVViewFocusChangeBase.h +2 -0
- package/ios/Views/Base/FocusChange/RNCEKVViewFocusChangeBase.mm +12 -10
- package/ios/Views/Base/FocusRequest/RNCEKVViewFocusRequestBase.h +1 -1
- package/ios/Views/Base/FocusRequest/RNCEKVViewFocusRequestBase.mm +6 -17
- package/ios/Views/Base/KeyboardHallo/RNCEKVExternalKeyboardHalloBase.h +1 -0
- package/ios/Views/Base/KeyboardHallo/RNCEKVExternalKeyboardHalloBase.mm +146 -6
- package/ios/Views/Base/ViewGroup/RNCEKVViewGroupBase.h +2 -0
- package/ios/Views/Base/ViewGroup/RNCEKVViewGroupBase.mm +4 -0
- package/ios/Views/RNCEKVExternalKeyboardView/RNCEKVExternalKeyboardView.h +1 -1
- package/ios/Views/RNCEKVExternalKeyboardView/RNCEKVExternalKeyboardView.mm +8 -4
- package/ios/Views/RNCEKVExternalKeyboardView/RNCEKVExternalKeyboardViewManager.mm +22 -11
- package/ios/Views/RNCEKVTextInputFocusWrapper/RNCEKVTextInputFocusWrapper.mm +17 -0
- package/ios/Views/RNCEKVTextInputFocusWrapper/RNCEKVTextInputFocusWrapperManager.mm +12 -0
- package/lib/commonjs/components/BaseKeyboardView/BaseKeyboardView.js +67 -65
- package/lib/commonjs/components/BaseKeyboardView/BaseKeyboardView.js.map +1 -1
- package/lib/commonjs/components/KeyboardExtendedInput/KeyboardExtendedInput.js +49 -97
- package/lib/commonjs/components/KeyboardExtendedInput/KeyboardExtendedInput.js.map +1 -1
- package/lib/commonjs/components/KeyboardFocusGroup/KeyboardFocusGroup.android.js.map +1 -1
- package/lib/commonjs/components/KeyboardFocusGroup/KeyboardFocusGroup.ios.js.map +1 -1
- package/lib/commonjs/components/KeyboardFocusGroup/KeyboardFocusGroup.js.map +1 -1
- package/lib/commonjs/components/{KeyboardExtendedInput/KeyboardExtendedInput.types.js → KeyboardFocusGroup/KeyboardFocusGroup.types.js} +1 -1
- package/lib/commonjs/components/KeyboardFocusGroup/KeyboardFocusGroup.types.js.map +1 -0
- package/lib/commonjs/components/KeyboardFocusLock/FocusFrame/FocusFrame.android.js +2 -1
- package/lib/commonjs/components/KeyboardFocusLock/FocusFrame/FocusFrame.android.js.map +1 -1
- package/lib/commonjs/components/KeyboardFocusLock/FocusTrap/FocusTrap.android.js +2 -1
- package/lib/commonjs/components/KeyboardFocusLock/FocusTrap/FocusTrap.android.js.map +1 -1
- package/lib/commonjs/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.js +2 -1
- package/lib/commonjs/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.js.map +1 -1
- package/lib/commonjs/components/KeyboardFocusView/KeyboardFocusView.js +14 -51
- package/lib/commonjs/components/KeyboardFocusView/KeyboardFocusView.js.map +1 -1
- package/lib/commonjs/components/index.js +47 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/index.js +37 -19
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nativeSpec/ExternalKeyboardLockViewNativeComponent.ts +1 -3
- package/lib/commonjs/nativeSpec/ExternalKeyboardViewNativeComponent.ts +12 -9
- package/lib/commonjs/nativeSpec/KeyboardFocusGroupNativeComponent.ts +5 -3
- package/lib/commonjs/nativeSpec/TextInputFocusWrapperNativeComponent.ts +7 -3
- package/lib/commonjs/types/KeyboardFocusLock.types.js +13 -0
- package/lib/commonjs/types/KeyboardFocusLock.types.js.map +1 -1
- package/lib/commonjs/types/baseKeyboardView.types.js +6 -0
- package/lib/commonjs/types/baseKeyboardView.types.js.map +1 -0
- package/lib/commonjs/types/{FocusStyle.js → focus.types.js} +1 -1
- package/lib/commonjs/types/{FocusStyle.js.map → focus.types.js.map} +1 -1
- package/lib/commonjs/types/focusOrder.types.js +33 -0
- package/lib/commonjs/types/focusOrder.types.js.map +1 -0
- package/lib/commonjs/types/{WithKeyboardFocus.js → focusStyle.types.js} +1 -1
- package/lib/commonjs/types/{WithKeyboardFocus.js.map → focusStyle.types.js.map} +1 -1
- package/lib/commonjs/types/index.js +18 -0
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/keyPress.types.js +6 -0
- package/lib/{module/types/WithKeyboardFocus.js.map → commonjs/types/keyPress.types.js.map} +1 -1
- package/lib/commonjs/types/keyboardInput.types.js +6 -0
- package/lib/commonjs/types/keyboardInput.types.js.map +1 -0
- package/lib/commonjs/types/withKeyboardFocus.types.js +6 -0
- package/lib/commonjs/types/withKeyboardFocus.types.js.map +1 -0
- package/lib/commonjs/utils/mapLockFocus.js +37 -0
- package/lib/commonjs/utils/mapLockFocus.js.map +1 -0
- package/lib/commonjs/utils/useFocusStyle.js +4 -21
- package/lib/commonjs/utils/useFocusStyle.js.map +1 -1
- package/lib/commonjs/utils/useKeyboardFocusContainer.js +79 -0
- package/lib/commonjs/utils/useKeyboardFocusContainer.js.map +1 -0
- package/lib/commonjs/utils/useKeyboardPress/useKeyboardPress.android.js +4 -7
- package/lib/commonjs/utils/useKeyboardPress/useKeyboardPress.android.js.map +1 -1
- package/lib/commonjs/utils/useKeyboardPress/useKeyboardPress.ios.js +3 -6
- package/lib/commonjs/utils/useKeyboardPress/useKeyboardPress.ios.js.map +1 -1
- package/lib/commonjs/utils/useKeyboardPress/useKeyboardPress.js +9 -7
- package/lib/commonjs/utils/useKeyboardPress/useKeyboardPress.js.map +1 -1
- package/lib/commonjs/utils/useKeyboardPressState.js +65 -0
- package/lib/commonjs/utils/useKeyboardPressState.js.map +1 -0
- package/lib/commonjs/utils/useOnFocusChange.js +1 -1
- package/lib/commonjs/utils/useOnFocusChange.js.map +1 -1
- package/lib/commonjs/utils/useOrderValidation.js +35 -0
- package/lib/commonjs/utils/useOrderValidation.js.map +1 -0
- package/lib/commonjs/utils/useRenderedChildren.js +34 -0
- package/lib/commonjs/utils/useRenderedChildren.js.map +1 -0
- package/lib/commonjs/utils/useWrappedOrderProps.js +35 -0
- package/lib/commonjs/utils/useWrappedOrderProps.js.map +1 -0
- package/lib/commonjs/utils/withKeyboardFocus.js +81 -96
- package/lib/commonjs/utils/withKeyboardFocus.js.map +1 -1
- package/lib/module/components/BaseKeyboardView/BaseKeyboardView.js +57 -55
- package/lib/module/components/BaseKeyboardView/BaseKeyboardView.js.map +1 -1
- package/lib/module/components/KeyboardExtendedInput/KeyboardExtendedInput.js +51 -99
- package/lib/module/components/KeyboardExtendedInput/KeyboardExtendedInput.js.map +1 -1
- package/lib/module/components/KeyboardFocusGroup/KeyboardFocusGroup.android.js.map +1 -1
- package/lib/module/components/KeyboardFocusGroup/KeyboardFocusGroup.ios.js.map +1 -1
- package/lib/module/components/KeyboardFocusGroup/KeyboardFocusGroup.js.map +1 -1
- package/lib/module/components/KeyboardFocusGroup/KeyboardFocusGroup.types.js +4 -0
- package/lib/module/components/KeyboardFocusGroup/KeyboardFocusGroup.types.js.map +1 -0
- package/lib/module/components/KeyboardFocusLock/FocusFrame/FocusFrame.android.js +2 -1
- package/lib/module/components/KeyboardFocusLock/FocusFrame/FocusFrame.android.js.map +1 -1
- package/lib/module/components/KeyboardFocusLock/FocusTrap/FocusTrap.android.js +2 -1
- package/lib/module/components/KeyboardFocusLock/FocusTrap/FocusTrap.android.js.map +1 -1
- package/lib/module/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.js +2 -1
- package/lib/module/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.js.map +1 -1
- package/lib/module/components/KeyboardFocusView/KeyboardFocusView.js +16 -53
- package/lib/module/components/KeyboardFocusView/KeyboardFocusView.js.map +1 -1
- package/lib/module/components/index.js +5 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/index.js +20 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeSpec/ExternalKeyboardLockViewNativeComponent.ts +1 -3
- package/lib/module/nativeSpec/ExternalKeyboardViewNativeComponent.ts +12 -9
- package/lib/module/nativeSpec/KeyboardFocusGroupNativeComponent.ts +5 -3
- package/lib/module/nativeSpec/TextInputFocusWrapperNativeComponent.ts +7 -3
- package/lib/module/types/KeyboardFocusLock.types.js +12 -1
- package/lib/module/types/KeyboardFocusLock.types.js.map +1 -1
- package/lib/module/types/baseKeyboardView.types.js +4 -0
- package/lib/module/types/baseKeyboardView.types.js.map +1 -0
- package/lib/module/types/focus.types.js +4 -0
- package/lib/module/types/{FocusStyle.js.map → focus.types.js.map} +1 -1
- package/lib/module/types/focusOrder.types.js +31 -0
- package/lib/module/types/focusOrder.types.js.map +1 -0
- package/lib/module/types/focusStyle.types.js +4 -0
- package/lib/module/types/focusStyle.types.js.map +1 -0
- package/lib/module/types/index.js +3 -0
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/keyPress.types.js +4 -0
- package/lib/module/types/keyPress.types.js.map +1 -0
- package/lib/module/types/keyboardInput.types.js +4 -0
- package/lib/module/types/keyboardInput.types.js.map +1 -0
- package/lib/module/types/withKeyboardFocus.types.js +4 -0
- package/lib/module/types/withKeyboardFocus.types.js.map +1 -0
- package/lib/module/utils/mapLockFocus.js +32 -0
- package/lib/module/utils/mapLockFocus.js.map +1 -0
- package/lib/module/utils/useFocusStyle.js +4 -21
- package/lib/module/utils/useFocusStyle.js.map +1 -1
- package/lib/module/utils/useKeyboardFocusContainer.js +74 -0
- package/lib/module/utils/useKeyboardFocusContainer.js.map +1 -0
- package/lib/module/utils/useKeyboardPress/useKeyboardPress.android.js +4 -7
- package/lib/module/utils/useKeyboardPress/useKeyboardPress.android.js.map +1 -1
- package/lib/module/utils/useKeyboardPress/useKeyboardPress.ios.js +3 -6
- package/lib/module/utils/useKeyboardPress/useKeyboardPress.ios.js.map +1 -1
- package/lib/module/utils/useKeyboardPress/useKeyboardPress.js +9 -7
- package/lib/module/utils/useKeyboardPress/useKeyboardPress.js.map +1 -1
- package/lib/module/utils/useKeyboardPressState.js +60 -0
- package/lib/module/utils/useKeyboardPressState.js.map +1 -0
- package/lib/module/utils/useOnFocusChange.js +1 -1
- package/lib/module/utils/useOnFocusChange.js.map +1 -1
- package/lib/module/utils/useOrderValidation.js +30 -0
- package/lib/module/utils/useOrderValidation.js.map +1 -0
- package/lib/module/utils/useRenderedChildren.js +29 -0
- package/lib/module/utils/useRenderedChildren.js.map +1 -0
- package/lib/module/utils/useWrappedOrderProps.js +30 -0
- package/lib/module/utils/useWrappedOrderProps.js.map +1 -0
- package/lib/module/utils/withKeyboardFocus.js +84 -99
- package/lib/module/utils/withKeyboardFocus.js.map +1 -1
- package/lib/typescript/src/components/BaseKeyboardView/BaseKeyboardView.d.ts +30 -10
- package/lib/typescript/src/components/BaseKeyboardView/BaseKeyboardView.d.ts.map +1 -1
- package/lib/typescript/src/components/KeyboardExtendedInput/KeyboardExtendedInput.d.ts +187 -12
- package/lib/typescript/src/components/KeyboardExtendedInput/KeyboardExtendedInput.d.ts.map +1 -1
- package/lib/typescript/src/components/KeyboardFocusGroup/KeyboardFocusGroup.android.d.ts +4 -146
- package/lib/typescript/src/components/KeyboardFocusGroup/KeyboardFocusGroup.android.d.ts.map +1 -1
- package/lib/typescript/src/components/KeyboardFocusGroup/KeyboardFocusGroup.d.ts +2 -12
- package/lib/typescript/src/components/KeyboardFocusGroup/KeyboardFocusGroup.d.ts.map +1 -1
- package/lib/typescript/src/components/KeyboardFocusGroup/KeyboardFocusGroup.ios.d.ts +4 -146
- package/lib/typescript/src/components/KeyboardFocusGroup/KeyboardFocusGroup.ios.d.ts.map +1 -1
- package/lib/typescript/src/components/KeyboardFocusGroup/KeyboardFocusGroup.types.d.ts +13 -0
- package/lib/typescript/src/components/KeyboardFocusGroup/KeyboardFocusGroup.types.d.ts.map +1 -0
- package/lib/typescript/src/components/KeyboardFocusLock/FocusFrame/FocusFrame.android.d.ts +1 -1
- package/lib/typescript/src/components/KeyboardFocusLock/FocusFrame/FocusFrame.android.d.ts.map +1 -1
- package/lib/typescript/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.android.d.ts +1 -1
- package/lib/typescript/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.android.d.ts.map +1 -1
- package/lib/typescript/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.d.ts +1 -1
- package/lib/typescript/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.d.ts.map +1 -1
- package/lib/typescript/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.d.ts +1 -1
- package/lib/typescript/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.d.ts.map +1 -1
- package/lib/typescript/src/components/KeyboardFocusView/KeyboardFocusView.d.ts +28 -18
- package/lib/typescript/src/components/KeyboardFocusView/KeyboardFocusView.d.ts.map +1 -1
- package/lib/typescript/src/components/Touchable/Pressable.d.ts +14 -14
- package/lib/typescript/src/components/Touchable/Pressable.d.ts.map +1 -1
- package/lib/typescript/src/components/index.d.ts +5 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +694 -9
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/nativeSpec/ExternalKeyboardLockViewNativeComponent.d.ts +2 -4
- package/lib/typescript/src/nativeSpec/ExternalKeyboardLockViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/nativeSpec/ExternalKeyboardViewNativeComponent.d.ts +6 -7
- package/lib/typescript/src/nativeSpec/ExternalKeyboardViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/nativeSpec/KeyboardFocusGroupNativeComponent.d.ts +2 -4
- package/lib/typescript/src/nativeSpec/KeyboardFocusGroupNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/nativeSpec/TextInputFocusWrapperNativeComponent.d.ts +4 -4
- package/lib/typescript/src/nativeSpec/TextInputFocusWrapperNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/types/KeyboardFocusLock.types.d.ts +15 -1
- package/lib/typescript/src/types/KeyboardFocusLock.types.d.ts.map +1 -1
- package/lib/typescript/src/types/KeyboardFocusView.types.d.ts +16 -14
- package/lib/typescript/src/types/KeyboardFocusView.types.d.ts.map +1 -1
- package/lib/typescript/src/types/baseKeyboardView.types.d.ts +119 -0
- package/lib/typescript/src/types/baseKeyboardView.types.d.ts.map +1 -0
- package/lib/typescript/src/types/focus.types.d.ts +35 -0
- package/lib/typescript/src/types/focus.types.d.ts.map +1 -0
- package/lib/typescript/src/types/focusOrder.types.d.ts +57 -0
- package/lib/typescript/src/types/focusOrder.types.d.ts.map +1 -0
- package/lib/typescript/src/types/focusStyle.types.d.ts +11 -0
- package/lib/typescript/src/types/focusStyle.types.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +11 -2
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/keyPress.types.d.ts +7 -0
- package/lib/typescript/src/types/keyPress.types.d.ts.map +1 -0
- package/lib/typescript/src/types/keyboardInput.types.d.ts +53 -0
- package/lib/typescript/src/types/keyboardInput.types.d.ts.map +1 -0
- package/lib/typescript/src/types/withKeyboardFocus.types.d.ts +109 -0
- package/lib/typescript/src/types/withKeyboardFocus.types.d.ts.map +1 -0
- package/lib/typescript/src/utils/mapLockFocus.d.ts +3 -0
- package/lib/typescript/src/utils/mapLockFocus.d.ts.map +1 -0
- package/lib/typescript/src/utils/useFocusStyle.d.ts +26 -34
- package/lib/typescript/src/utils/useFocusStyle.d.ts.map +1 -1
- package/lib/typescript/src/utils/useKeyboardFocusContainer.d.ts +898 -0
- package/lib/typescript/src/utils/useKeyboardFocusContainer.d.ts.map +1 -0
- package/lib/typescript/src/utils/useKeyboardPress/useKeyboardPress.android.d.ts +2 -2
- package/lib/typescript/src/utils/useKeyboardPress/useKeyboardPress.android.d.ts.map +1 -1
- package/lib/typescript/src/utils/useKeyboardPress/useKeyboardPress.d.ts +4 -3
- package/lib/typescript/src/utils/useKeyboardPress/useKeyboardPress.d.ts.map +1 -1
- package/lib/typescript/src/utils/useKeyboardPress/useKeyboardPress.ios.d.ts +3 -3
- package/lib/typescript/src/utils/useKeyboardPress/useKeyboardPress.ios.d.ts.map +1 -1
- package/lib/typescript/src/utils/useKeyboardPress/useKeyboardPress.types.d.ts +1 -2
- package/lib/typescript/src/utils/useKeyboardPress/useKeyboardPress.types.d.ts.map +1 -1
- package/lib/typescript/src/utils/useKeyboardPressState.d.ts +29 -0
- package/lib/typescript/src/utils/useKeyboardPressState.d.ts.map +1 -0
- package/lib/typescript/src/utils/useOnFocusChange.d.ts +3 -3
- package/lib/typescript/src/utils/useOnFocusChange.d.ts.map +1 -1
- package/lib/typescript/src/utils/useOrderValidation.d.ts +8 -0
- package/lib/typescript/src/utils/useOrderValidation.d.ts.map +1 -0
- package/lib/typescript/src/utils/useRenderedChildren.d.ts +18 -0
- package/lib/typescript/src/utils/useRenderedChildren.d.ts.map +1 -0
- package/lib/typescript/src/utils/useWrappedOrderProps.d.ts +13 -0
- package/lib/typescript/src/utils/useWrappedOrderProps.d.ts.map +1 -0
- package/lib/typescript/src/utils/withKeyboardFocus.d.ts +3 -4
- package/lib/typescript/src/utils/withKeyboardFocus.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/components/BaseKeyboardView/BaseKeyboardView.tsx +74 -94
- package/src/components/KeyboardExtendedInput/KeyboardExtendedInput.tsx +49 -149
- package/src/components/KeyboardFocusGroup/KeyboardFocusGroup.android.tsx +23 -32
- package/src/components/KeyboardFocusGroup/KeyboardFocusGroup.ios.tsx +32 -41
- package/src/components/KeyboardFocusGroup/KeyboardFocusGroup.tsx +3 -14
- package/src/components/KeyboardFocusGroup/KeyboardFocusGroup.types.ts +15 -0
- package/src/components/KeyboardFocusLock/FocusFrame/FocusFrame.android.tsx +2 -2
- package/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.android.tsx +2 -2
- package/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.tsx +1 -1
- package/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.tsx +2 -2
- package/src/components/KeyboardFocusView/KeyboardFocusView.tsx +29 -68
- package/src/components/Touchable/Pressable.tsx +2 -2
- package/src/components/index.ts +12 -0
- package/src/index.tsx +44 -32
- package/src/nativeSpec/ExternalKeyboardLockViewNativeComponent.ts +1 -3
- package/src/nativeSpec/ExternalKeyboardViewNativeComponent.ts +12 -9
- package/src/nativeSpec/KeyboardFocusGroupNativeComponent.ts +5 -3
- package/src/nativeSpec/TextInputFocusWrapperNativeComponent.ts +7 -3
- package/src/types/KeyboardFocusLock.types.ts +16 -1
- package/src/types/KeyboardFocusView.types.ts +17 -18
- package/src/types/baseKeyboardView.types.ts +122 -0
- package/src/types/focus.types.ts +40 -0
- package/src/types/focusOrder.types.ts +59 -0
- package/src/types/{FocusStyle.ts → focusStyle.types.ts} +5 -0
- package/src/types/index.ts +32 -2
- package/src/types/keyPress.types.ts +8 -0
- package/src/types/keyboardInput.types.ts +81 -0
- package/src/types/withKeyboardFocus.types.ts +178 -0
- package/src/utils/mapLockFocus.ts +31 -0
- package/src/utils/useFocusStyle.tsx +13 -41
- package/src/utils/useKeyboardFocusContainer.ts +102 -0
- package/src/utils/useKeyboardPress/useKeyboardPress.android.ts +4 -7
- package/src/utils/useKeyboardPress/useKeyboardPress.ios.ts +3 -6
- package/src/utils/useKeyboardPress/useKeyboardPress.ts +9 -7
- package/src/utils/useKeyboardPress/useKeyboardPress.types.ts +1 -2
- package/src/utils/useKeyboardPressState.ts +81 -0
- package/src/utils/useOnFocusChange.ts +4 -7
- package/src/utils/useOrderValidation.ts +74 -0
- package/src/utils/useRenderedChildren.ts +42 -0
- package/src/utils/useWrappedOrderProps.ts +48 -0
- package/src/utils/withKeyboardFocus.tsx +105 -125
- package/lib/commonjs/components/KeyboardExtendedInput/KeyboardExtendedInput.types.js.map +0 -1
- package/lib/commonjs/components/KeyboardFocusView/hooks/index.js +0 -13
- package/lib/commonjs/components/KeyboardFocusView/hooks/index.js.map +0 -1
- package/lib/commonjs/components/KeyboardFocusView/hooks/useFocusStyle/index.js +0 -13
- package/lib/commonjs/components/KeyboardFocusView/hooks/useFocusStyle/index.js.map +0 -1
- package/lib/commonjs/components/KeyboardFocusView/hooks/useFocusStyle/useFocusStyle.js +0 -33
- package/lib/commonjs/components/KeyboardFocusView/hooks/useFocusStyle/useFocusStyle.js.map +0 -1
- package/lib/commonjs/components/KeyboardFocusView/hooks/useFocusStyle/useTintStyle.js +0 -39
- package/lib/commonjs/components/KeyboardFocusView/hooks/useFocusStyle/useTintStyle.js.map +0 -1
- package/lib/commonjs/components/RenderPropComponent/RenderPropComponent.js +0 -23
- package/lib/commonjs/components/RenderPropComponent/RenderPropComponent.js.map +0 -1
- package/lib/commonjs/types/BaseKeyboardView.js +0 -18
- package/lib/commonjs/types/BaseKeyboardView.js.map +0 -1
- package/lib/module/components/KeyboardExtendedInput/KeyboardExtendedInput.types.js +0 -4
- package/lib/module/components/KeyboardExtendedInput/KeyboardExtendedInput.types.js.map +0 -1
- package/lib/module/components/KeyboardFocusView/hooks/index.js +0 -4
- package/lib/module/components/KeyboardFocusView/hooks/index.js.map +0 -1
- package/lib/module/components/KeyboardFocusView/hooks/useFocusStyle/index.js +0 -4
- package/lib/module/components/KeyboardFocusView/hooks/useFocusStyle/index.js.map +0 -1
- package/lib/module/components/KeyboardFocusView/hooks/useFocusStyle/useFocusStyle.js +0 -28
- package/lib/module/components/KeyboardFocusView/hooks/useFocusStyle/useFocusStyle.js.map +0 -1
- package/lib/module/components/KeyboardFocusView/hooks/useFocusStyle/useTintStyle.js +0 -34
- package/lib/module/components/KeyboardFocusView/hooks/useFocusStyle/useTintStyle.js.map +0 -1
- package/lib/module/components/RenderPropComponent/RenderPropComponent.js +0 -17
- package/lib/module/components/RenderPropComponent/RenderPropComponent.js.map +0 -1
- package/lib/module/types/BaseKeyboardView.js +0 -14
- package/lib/module/types/BaseKeyboardView.js.map +0 -1
- package/lib/module/types/FocusStyle.js +0 -4
- package/lib/module/types/WithKeyboardFocus.js +0 -4
- package/lib/typescript/src/components/KeyboardExtendedInput/KeyboardExtendedInput.types.d.ts +0 -45
- package/lib/typescript/src/components/KeyboardExtendedInput/KeyboardExtendedInput.types.d.ts.map +0 -1
- package/lib/typescript/src/components/KeyboardFocusView/hooks/index.d.ts +0 -2
- package/lib/typescript/src/components/KeyboardFocusView/hooks/index.d.ts.map +0 -1
- package/lib/typescript/src/components/KeyboardFocusView/hooks/useFocusStyle/index.d.ts +0 -2
- package/lib/typescript/src/components/KeyboardFocusView/hooks/useFocusStyle/index.d.ts.map +0 -1
- package/lib/typescript/src/components/KeyboardFocusView/hooks/useFocusStyle/useFocusStyle.d.ts +0 -175
- package/lib/typescript/src/components/KeyboardFocusView/hooks/useFocusStyle/useFocusStyle.d.ts.map +0 -1
- package/lib/typescript/src/components/KeyboardFocusView/hooks/useFocusStyle/useTintStyle.d.ts +0 -181
- package/lib/typescript/src/components/KeyboardFocusView/hooks/useFocusStyle/useTintStyle.d.ts.map +0 -1
- package/lib/typescript/src/components/RenderPropComponent/RenderPropComponent.d.ts +0 -6
- package/lib/typescript/src/components/RenderPropComponent/RenderPropComponent.d.ts.map +0 -1
- package/lib/typescript/src/types/BaseKeyboardView.d.ts +0 -70
- package/lib/typescript/src/types/BaseKeyboardView.d.ts.map +0 -1
- package/lib/typescript/src/types/FocusStyle.d.ts +0 -6
- package/lib/typescript/src/types/FocusStyle.d.ts.map +0 -1
- package/lib/typescript/src/types/WithKeyboardFocus.d.ts +0 -47
- package/lib/typescript/src/types/WithKeyboardFocus.d.ts.map +0 -1
- package/src/components/KeyboardExtendedInput/KeyboardExtendedInput.types.ts +0 -73
- package/src/components/KeyboardFocusView/hooks/index.ts +0 -1
- package/src/components/KeyboardFocusView/hooks/useFocusStyle/index.ts +0 -1
- package/src/components/KeyboardFocusView/hooks/useFocusStyle/useFocusStyle.ts +0 -34
- package/src/components/KeyboardFocusView/hooks/useFocusStyle/useTintStyle.ts +0 -41
- package/src/components/RenderPropComponent/RenderPropComponent.tsx +0 -18
- package/src/types/BaseKeyboardView.ts +0 -74
- package/src/types/WithKeyboardFocus.ts +0 -115
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import type { UseKeyboardPressProps } from './useKeyboardPress.types';
|
|
3
|
-
import type { OnKeyPress } from '../../types
|
|
3
|
+
import type { OnKeyPress } from '../../types';
|
|
4
4
|
import type { GestureResponderEvent } from 'react-native';
|
|
5
5
|
|
|
6
6
|
const IOS_SPACE_KEY = 44;
|
|
@@ -19,12 +19,10 @@ export const useKeyboardPress = <
|
|
|
19
19
|
onPressOut,
|
|
20
20
|
onLongPress,
|
|
21
21
|
triggerCodes = IOS_TRIGGER_CODES,
|
|
22
|
-
disabled = false,
|
|
23
22
|
}: UseKeyboardPressProps<T, K>) => {
|
|
24
23
|
const onKeyUpPressHandler = useMemo(() => {
|
|
25
24
|
return (e: OnKeyPress) => {
|
|
26
25
|
onKeyUpPress?.(e);
|
|
27
|
-
if (disabled) return;
|
|
28
26
|
|
|
29
27
|
if (triggerCodes.includes(e.nativeEvent.keyCode)) {
|
|
30
28
|
onPressOut?.(e);
|
|
@@ -35,18 +33,17 @@ export const useKeyboardPress = <
|
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
};
|
|
38
|
-
}, [onKeyUpPress, onLongPress, onPress, onPressOut, triggerCodes
|
|
36
|
+
}, [onKeyUpPress, onLongPress, onPress, onPressOut, triggerCodes]);
|
|
39
37
|
|
|
40
38
|
const onKeyDownPressHandler = useMemo(() => {
|
|
41
39
|
if (!onPressIn) return onKeyDownPress;
|
|
42
40
|
return (e: OnKeyPress) => {
|
|
43
41
|
onKeyDownPress?.(e);
|
|
44
|
-
if (disabled) return;
|
|
45
42
|
if (triggerCodes.includes(e.nativeEvent.keyCode)) {
|
|
46
43
|
onPressIn?.(e);
|
|
47
44
|
}
|
|
48
45
|
};
|
|
49
|
-
}, [onKeyDownPress, onPressIn, triggerCodes
|
|
46
|
+
}, [onKeyDownPress, onPressIn, triggerCodes]);
|
|
50
47
|
|
|
51
48
|
return {
|
|
52
49
|
onKeyUpPressHandler,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import type { UseKeyboardPressProps } from './useKeyboardPress.types';
|
|
3
|
-
import type { OnKeyPress } from '../../types
|
|
3
|
+
import type { OnKeyPress } from '../../types';
|
|
4
4
|
|
|
5
5
|
const IOS_SPACE_KEY = 44;
|
|
6
6
|
const IOS_RETURN_OR_ENTER = 40;
|
|
@@ -14,32 +14,34 @@ export const useKeyboardPress = <
|
|
|
14
14
|
onKeyUpPress,
|
|
15
15
|
onKeyDownPress,
|
|
16
16
|
onPress,
|
|
17
|
+
onLongPress,
|
|
17
18
|
onPressIn,
|
|
18
19
|
onPressOut,
|
|
19
20
|
triggerCodes = IOS_TRIGGER_CODES,
|
|
20
|
-
disabled = false,
|
|
21
21
|
}: UseKeyboardPressProps<T, K>) => {
|
|
22
22
|
const onKeyUpPressHandler = useMemo(() => {
|
|
23
|
-
if (!onPressOut) return onKeyUpPress;
|
|
24
23
|
return (e: OnKeyPress) => {
|
|
25
24
|
onKeyUpPress?.(e);
|
|
26
|
-
if (disabled) return;
|
|
27
25
|
if (triggerCodes.includes(e.nativeEvent.keyCode)) {
|
|
28
26
|
onPressOut?.(e);
|
|
27
|
+
if (e.nativeEvent.isLongPress) {
|
|
28
|
+
onLongPress?.({} as any);
|
|
29
|
+
} else {
|
|
30
|
+
onPress?.({} as any);
|
|
31
|
+
}
|
|
29
32
|
}
|
|
30
33
|
};
|
|
31
|
-
}, [onKeyUpPress, onPressOut, triggerCodes
|
|
34
|
+
}, [onKeyUpPress, onLongPress, onPress, onPressOut, triggerCodes]);
|
|
32
35
|
|
|
33
36
|
const onKeyDownPressHandler = useMemo(() => {
|
|
34
37
|
if (!onPressIn) return onKeyDownPress;
|
|
35
38
|
return (e: OnKeyPress) => {
|
|
36
39
|
onKeyDownPress?.(e);
|
|
37
|
-
if (disabled) return;
|
|
38
40
|
if (triggerCodes.includes(e.nativeEvent.keyCode)) {
|
|
39
41
|
onPressIn?.(e);
|
|
40
42
|
}
|
|
41
43
|
};
|
|
42
|
-
}, [onKeyDownPress, onPressIn, triggerCodes
|
|
44
|
+
}, [onKeyDownPress, onPressIn, triggerCodes]);
|
|
43
45
|
|
|
44
46
|
return {
|
|
45
47
|
onKeyUpPressHandler,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OnKeyPressFn } from '../../types
|
|
1
|
+
import type { OnKeyPressFn } from '../../types';
|
|
2
2
|
|
|
3
3
|
export type UseKeyboardPressProps<T, K> = {
|
|
4
4
|
triggerCodes?: number[];
|
|
@@ -8,5 +8,4 @@ export type UseKeyboardPressProps<T, K> = {
|
|
|
8
8
|
onPress?: T;
|
|
9
9
|
onPressIn?: K;
|
|
10
10
|
onPressOut?: K;
|
|
11
|
-
disabled?: boolean;
|
|
12
11
|
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
|
|
4
|
+
type AnyPressHandler = (event?: any) => void;
|
|
5
|
+
type PressableStyleFn = (state: { pressed: boolean }) => unknown;
|
|
6
|
+
|
|
7
|
+
type UseKeyboardPressStateParams = {
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
onPressIn?: AnyPressHandler;
|
|
10
|
+
onPressOut?: AnyPressHandler;
|
|
11
|
+
onFocusChange?: (isFocused: boolean) => void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Android only. Physical-keyboard activation (Enter / Space / DPad-center) never
|
|
16
|
+
* reaches the touch responder, so a wrapped component's `pressed` stays false.
|
|
17
|
+
* This derives a press state from the key down/up events and returns composable
|
|
18
|
+
* pieces to thread it through focus, press handlers, and function styles.
|
|
19
|
+
*
|
|
20
|
+
* Everything is a no-op unless `enabled` and running on Android, so callers can
|
|
21
|
+
* always wire the returned values unconditionally.
|
|
22
|
+
*/
|
|
23
|
+
export const useKeyboardPressState = ({
|
|
24
|
+
enabled = false,
|
|
25
|
+
onPressIn,
|
|
26
|
+
onPressOut,
|
|
27
|
+
onFocusChange,
|
|
28
|
+
}: UseKeyboardPressStateParams) => {
|
|
29
|
+
const active = enabled && Platform.OS === 'android';
|
|
30
|
+
const [pressed, setPressed] = useState(false);
|
|
31
|
+
|
|
32
|
+
const handlePressIn = useCallback(
|
|
33
|
+
(e?: any) => {
|
|
34
|
+
setPressed(true);
|
|
35
|
+
onPressIn?.(e);
|
|
36
|
+
},
|
|
37
|
+
[onPressIn]
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const handlePressOut = useCallback(
|
|
41
|
+
(e?: any) => {
|
|
42
|
+
setPressed(false);
|
|
43
|
+
onPressOut?.(e);
|
|
44
|
+
},
|
|
45
|
+
[onPressOut]
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const handleFocusChange = useCallback(
|
|
49
|
+
(isFocused: boolean) => {
|
|
50
|
+
// Drop a stuck press if focus leaves before the key-up arrives.
|
|
51
|
+
if (!isFocused && active) setPressed(false);
|
|
52
|
+
onFocusChange?.(isFocused);
|
|
53
|
+
},
|
|
54
|
+
[onFocusChange, active]
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
// Fold the keyboard press into a `style({ pressed })` function so visual
|
|
58
|
+
// press feedback (`withPressedStyle`, function styles) reacts to the keyboard.
|
|
59
|
+
// Non-function styles and the inactive case are returned untouched.
|
|
60
|
+
const applyPressedStyle = useCallback(
|
|
61
|
+
<S>(style: S): S => {
|
|
62
|
+
if (!active || typeof style !== 'function') return style;
|
|
63
|
+
const styleFn = style as PressableStyleFn;
|
|
64
|
+
return (({ pressed: touchPressed }: { pressed: boolean }) =>
|
|
65
|
+
styleFn({ pressed: touchPressed || pressed })) as S;
|
|
66
|
+
},
|
|
67
|
+
[active, pressed]
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
/** A keyboard-driven press is currently held. */
|
|
72
|
+
pressed: active && pressed,
|
|
73
|
+
/** Pass to the keyboard press hook; the original handlers when inactive. */
|
|
74
|
+
onPressIn: active ? handlePressIn : onPressIn,
|
|
75
|
+
onPressOut: active ? handlePressOut : onPressOut,
|
|
76
|
+
/** Wrap `onFocusChange` to clear a stuck press on blur. */
|
|
77
|
+
onFocusChange: handleFocusChange,
|
|
78
|
+
/** Fold the keyboard press into a function style. */
|
|
79
|
+
applyPressedStyle,
|
|
80
|
+
};
|
|
81
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
-
import type { OnFocusChangeFn } from '../types';
|
|
2
|
+
import type { OnFocusChangeFn, NativeFocusChangeHandler } from '../types';
|
|
3
3
|
|
|
4
4
|
type UseFocusChange = {
|
|
5
|
-
onFocusChange?:
|
|
5
|
+
onFocusChange?: OnFocusChangeFn;
|
|
6
6
|
onFocus?: () => void;
|
|
7
7
|
onBlur?: () => void;
|
|
8
8
|
};
|
|
@@ -12,12 +12,9 @@ export const useOnFocusChange = ({
|
|
|
12
12
|
onFocus,
|
|
13
13
|
onBlur,
|
|
14
14
|
}: UseFocusChange) =>
|
|
15
|
-
useCallback<
|
|
15
|
+
useCallback<NativeFocusChangeHandler>(
|
|
16
16
|
(e) => {
|
|
17
|
-
onFocusChange?.(
|
|
18
|
-
e.nativeEvent.isFocused,
|
|
19
|
-
(e?.nativeEvent as unknown as { target?: number })?.target
|
|
20
|
-
);
|
|
17
|
+
onFocusChange?.(e.nativeEvent.isFocused, e.nativeEvent.target);
|
|
21
18
|
if (e.nativeEvent.isFocused) {
|
|
22
19
|
onFocus?.();
|
|
23
20
|
} else {
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import type { FocusOrderProps } from '../types';
|
|
3
|
+
|
|
4
|
+
type UseOrderValidationProps = Pick<
|
|
5
|
+
FocusOrderProps,
|
|
6
|
+
| 'orderIndex'
|
|
7
|
+
| 'orderId'
|
|
8
|
+
| 'orderForward'
|
|
9
|
+
| 'orderBackward'
|
|
10
|
+
| 'orderFirst'
|
|
11
|
+
| 'orderLast'
|
|
12
|
+
| 'orderLeft'
|
|
13
|
+
| 'orderRight'
|
|
14
|
+
| 'orderUp'
|
|
15
|
+
| 'orderDown'
|
|
16
|
+
> & {
|
|
17
|
+
groupId?: string;
|
|
18
|
+
orderPrefix: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const useOrderValidation = ({
|
|
22
|
+
groupId,
|
|
23
|
+
orderIndex,
|
|
24
|
+
orderPrefix,
|
|
25
|
+
orderId,
|
|
26
|
+
orderForward,
|
|
27
|
+
orderBackward,
|
|
28
|
+
orderFirst,
|
|
29
|
+
orderLast,
|
|
30
|
+
orderLeft,
|
|
31
|
+
orderRight,
|
|
32
|
+
orderUp,
|
|
33
|
+
orderDown,
|
|
34
|
+
}: UseOrderValidationProps) => {
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!__DEV__) return;
|
|
37
|
+
if (orderIndex !== undefined && !groupId)
|
|
38
|
+
console.warn(
|
|
39
|
+
'`orderIndex` must be declared alongside `orderGroup` for proper functionality. Ensure components are wrapped with `KeyboardOrderFocusGroup` or provide `orderGroup` directly.'
|
|
40
|
+
);
|
|
41
|
+
}, [groupId, orderIndex]);
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (!__DEV__) return;
|
|
45
|
+
const hasOrderLinkProp =
|
|
46
|
+
orderId !== undefined ||
|
|
47
|
+
orderForward !== undefined ||
|
|
48
|
+
orderBackward !== undefined ||
|
|
49
|
+
orderFirst !== undefined ||
|
|
50
|
+
orderLast !== undefined ||
|
|
51
|
+
orderLeft !== undefined ||
|
|
52
|
+
orderRight !== undefined ||
|
|
53
|
+
orderUp !== undefined ||
|
|
54
|
+
orderDown !== undefined;
|
|
55
|
+
if (hasOrderLinkProp && orderPrefix === '') {
|
|
56
|
+
console.warn(
|
|
57
|
+
'[react-native-external-keyboard] orderId, orderForward, orderBackward, orderFirst, orderLast, ' +
|
|
58
|
+
'orderLeft, orderRight, orderUp, and orderDown are global IDs. ' +
|
|
59
|
+
'Wrap the component in <KeyboardOrderFocusGroup> or pass orderPrefix to avoid ID collisions across screens.'
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}, [
|
|
63
|
+
orderId,
|
|
64
|
+
orderForward,
|
|
65
|
+
orderBackward,
|
|
66
|
+
orderFirst,
|
|
67
|
+
orderLast,
|
|
68
|
+
orderLeft,
|
|
69
|
+
orderRight,
|
|
70
|
+
orderUp,
|
|
71
|
+
orderDown,
|
|
72
|
+
orderPrefix,
|
|
73
|
+
]);
|
|
74
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
type UseRenderedChildrenProps = {
|
|
4
|
+
focused: boolean;
|
|
5
|
+
keyboardPressed?: boolean;
|
|
6
|
+
renderContent?: (state: Record<string, unknown>) => React.ReactNode;
|
|
7
|
+
renderFocusable?: (state: { focused: boolean }) => React.ReactNode;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Resolves the `children` override for the wrapped component.
|
|
12
|
+
* - `renderContent` stays a function so the component can call it with its own state + `focused`
|
|
13
|
+
* (keyboard activation forces `pressed` when `keyboardPressed` is set)
|
|
14
|
+
* - `renderFocusable` is evaluated immediately and returned as a static node
|
|
15
|
+
* Returns `undefined` when neither prop is provided.
|
|
16
|
+
*/
|
|
17
|
+
export const useRenderedChildren = ({
|
|
18
|
+
focused,
|
|
19
|
+
keyboardPressed = false,
|
|
20
|
+
renderContent,
|
|
21
|
+
renderFocusable,
|
|
22
|
+
}: UseRenderedChildrenProps) => {
|
|
23
|
+
const contentChildren = useMemo(
|
|
24
|
+
() =>
|
|
25
|
+
renderContent
|
|
26
|
+
? (state: Record<string, unknown>) =>
|
|
27
|
+
renderContent({
|
|
28
|
+
...state,
|
|
29
|
+
...(keyboardPressed ? { pressed: true } : null),
|
|
30
|
+
focused,
|
|
31
|
+
})
|
|
32
|
+
: undefined,
|
|
33
|
+
[renderContent, focused, keyboardPressed]
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const focusableChildren = useMemo(
|
|
37
|
+
() => renderFocusable?.({ focused }),
|
|
38
|
+
[renderFocusable, focused]
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return contentChildren ?? focusableChildren;
|
|
42
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import type { FocusOrderProps } from '../types';
|
|
3
|
+
import { wrapOrderPrefix } from './wrapOrderPrefix';
|
|
4
|
+
|
|
5
|
+
export const useWrappedOrderProps = ({
|
|
6
|
+
orderPrefix = '',
|
|
7
|
+
orderId,
|
|
8
|
+
orderForward,
|
|
9
|
+
orderBackward,
|
|
10
|
+
orderFirst,
|
|
11
|
+
orderLast,
|
|
12
|
+
orderLeft,
|
|
13
|
+
orderRight,
|
|
14
|
+
orderUp,
|
|
15
|
+
orderDown,
|
|
16
|
+
}: FocusOrderProps) => {
|
|
17
|
+
const wrapPrefix = useMemo(() => wrapOrderPrefix(orderPrefix), [orderPrefix]);
|
|
18
|
+
|
|
19
|
+
return useMemo(
|
|
20
|
+
() => ({
|
|
21
|
+
orderId: wrapPrefix(orderId),
|
|
22
|
+
orderForward: wrapPrefix(orderForward),
|
|
23
|
+
orderBackward: wrapPrefix(orderBackward),
|
|
24
|
+
orderLeft: wrapPrefix(orderLeft),
|
|
25
|
+
orderRight: wrapPrefix(orderRight),
|
|
26
|
+
orderUp: wrapPrefix(orderUp),
|
|
27
|
+
orderDown: wrapPrefix(orderDown),
|
|
28
|
+
orderFirst: wrapPrefix(
|
|
29
|
+
orderFirst === null ? undefined : orderFirst ?? orderForward
|
|
30
|
+
),
|
|
31
|
+
orderLast: wrapPrefix(
|
|
32
|
+
orderLast === null ? undefined : orderLast ?? orderBackward
|
|
33
|
+
),
|
|
34
|
+
}),
|
|
35
|
+
[
|
|
36
|
+
wrapPrefix,
|
|
37
|
+
orderId,
|
|
38
|
+
orderForward,
|
|
39
|
+
orderBackward,
|
|
40
|
+
orderFirst,
|
|
41
|
+
orderLast,
|
|
42
|
+
orderLeft,
|
|
43
|
+
orderRight,
|
|
44
|
+
orderUp,
|
|
45
|
+
orderDown,
|
|
46
|
+
]
|
|
47
|
+
);
|
|
48
|
+
};
|