react-native-keyboard-controller 1.17.4 → 1.18.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 +4 -1
- package/android/src/base/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +6 -5
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardBackgroundViewManager.kt +19 -0
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +4 -0
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +3 -5
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +3 -5
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/OverKeyboardViewManager.kt +3 -5
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +3 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/Context.kt +20 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +2 -12
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardBackgroundViewManagerImpl.kt +13 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +2 -6
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardGestureAreaViewManagerImpl.kt +1 -5
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/OverKeyboardViewManagerImpl.kt +1 -5
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +4 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/{StatusBarManagerCompatModuleImpl.kt → statusbar/StatusBarManagerCompatModuleImpl.kt} +31 -5
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/statusbar/StatusBarModuleProxy.kt +86 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +9 -11
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/background/KeyboardBackgroundViewGroup.kt +35 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/background/Skins.kt +91 -0
- package/android/src/main/jni/reactnativekeyboardcontroller.h +1 -0
- package/android/src/main/res/values/attrs.xml +7 -0
- package/android/src/main/res/values/colors.xml +35 -0
- package/android/src/main/res/values-v29/colors.xml +5 -0
- package/android/src/main/res/values-v30/colors.xml +17 -0
- package/android/src/main/res/values-v33/colors.xml +16 -0
- package/android/src/main/res/values-v34/colors.xml +18 -0
- package/android/src/main/res/values-v35/colors.xml +10 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardBackgroundViewManager.kt +15 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +5 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +2 -5
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +2 -5
- package/android/src/paper/java/com/reactnativekeyboardcontroller/OverKeyboardViewManager.kt +2 -5
- package/android/src/paper/java/com/reactnativekeyboardcontroller/StatusBarManagerCompatModule.kt +3 -1
- package/android/src/turbo/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +5 -5
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardBackgroundViewComponentDescriptor.h +27 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardBackgroundViewShadowNode.cpp +14 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardBackgroundViewShadowNode.h +30 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardBackgroundViewState.h +28 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardExtenderComponentDescriptor.h +27 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardExtenderShadowNode.cpp +14 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardExtenderShadowNode.h +30 -0
- package/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardExtenderState.h +28 -0
- package/ios/KeyboardControllerModule.mm +9 -0
- package/ios/delegates/KCTextInputCompositeDelegate.swift +5 -5
- package/ios/events/KeyboardEventEmitterPayload.swift +1 -1
- package/ios/extensions/String.swift +12 -0
- package/ios/extensions/UIResponder.swift +27 -0
- package/ios/interactive/KeyboardAreaExtender.swift +5 -5
- package/ios/observers/FocusedInputObserver.swift +14 -5
- package/ios/observers/KeyboardMovementObserver.swift +24 -9
- package/ios/protocols/TextInput.swift +22 -0
- package/ios/swizzling/UIResponderSwizzle.swift +3 -0
- package/ios/traversal/KeyboardView.swift +6 -3
- package/ios/views/KeyboardBackgroundViewManager.h +29 -0
- package/ios/views/KeyboardBackgroundViewManager.mm +168 -0
- package/ios/views/KeyboardExtenderContainerView.swift +59 -0
- package/ios/views/KeyboardExtenderManager.h +29 -0
- package/ios/views/KeyboardExtenderManager.mm +287 -0
- package/jest/index.js +6 -1
- package/lib/commonjs/animated.js +7 -10
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/bindings.js +15 -1
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js +5 -1
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +49 -29
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js +2 -3
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/Button.js +2 -3
- package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/constants.js +17 -0
- package/lib/commonjs/components/KeyboardToolbar/constants.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/index.js +25 -22
- package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/commonjs/hooks/useKeyboardState/index.js +18 -8
- package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -1
- package/lib/commonjs/index.js +8 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/module.js +2 -1
- package/lib/commonjs/module.js.map +1 -1
- package/lib/commonjs/specs/KeyboardBackgroundViewNativeComponent.js +12 -0
- package/lib/commonjs/specs/KeyboardBackgroundViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/KeyboardExtenderNativeComponent.js +13 -0
- package/lib/commonjs/specs/KeyboardExtenderNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
- package/lib/commonjs/types/module.js.map +1 -1
- package/lib/commonjs/types/views.js.map +1 -1
- package/lib/commonjs/views/KeyboardExtender/index.ios.js +43 -0
- package/lib/commonjs/views/KeyboardExtender/index.ios.js.map +1 -0
- package/lib/commonjs/views/KeyboardExtender/index.js +46 -0
- package/lib/commonjs/views/KeyboardExtender/index.js.map +1 -0
- package/lib/commonjs/views/index.js +7 -0
- package/lib/commonjs/views/index.js.map +1 -1
- package/lib/module/animated.js +8 -11
- package/lib/module/animated.js.map +1 -1
- package/lib/module/bindings.js +14 -0
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js +4 -0
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +50 -30
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/Arrow.js +2 -2
- package/lib/module/components/KeyboardToolbar/Arrow.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/Button.js +2 -2
- package/lib/module/components/KeyboardToolbar/Button.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/constants.js +11 -0
- package/lib/module/components/KeyboardToolbar/constants.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/index.js +17 -14
- package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/module/hooks/useKeyboardState/index.js +18 -6
- package/lib/module/hooks/useKeyboardState/index.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/module.js +2 -1
- package/lib/module/module.js.map +1 -1
- package/lib/module/specs/KeyboardBackgroundViewNativeComponent.js +5 -0
- package/lib/module/specs/KeyboardBackgroundViewNativeComponent.js.map +1 -0
- package/lib/module/specs/KeyboardExtenderNativeComponent.js +6 -0
- package/lib/module/specs/KeyboardExtenderNativeComponent.js.map +1 -0
- package/lib/module/specs/NativeKeyboardController.js.map +1 -1
- package/lib/module/types/module.js.map +1 -1
- package/lib/module/types/views.js.map +1 -1
- package/lib/module/views/KeyboardExtender/index.ios.js +36 -0
- package/lib/module/views/KeyboardExtender/index.ios.js.map +1 -0
- package/lib/module/views/KeyboardExtender/index.js +39 -0
- package/lib/module/views/KeyboardExtender/index.js.map +1 -0
- package/lib/module/views/index.js +1 -0
- package/lib/module/views/index.js.map +1 -1
- package/lib/typescript/animated.d.ts +7 -0
- package/lib/typescript/bindings.d.ts +14 -1
- package/lib/typescript/bindings.native.d.ts +3 -1
- package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +2 -2
- package/lib/typescript/components/KeyboardToolbar/constants.d.ts +10 -0
- package/lib/typescript/hooks/useKeyboardState/index.d.ts +8 -2
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/specs/KeyboardBackgroundViewNativeComponent.d.ts +6 -0
- package/lib/typescript/specs/KeyboardExtenderNativeComponent.d.ts +7 -0
- package/lib/typescript/specs/NativeKeyboardController.d.ts +1 -0
- package/lib/typescript/types/module.d.ts +15 -3
- package/lib/typescript/types/views.d.ts +5 -0
- package/lib/typescript/views/KeyboardExtender/index.d.ts +19 -0
- package/lib/typescript/views/KeyboardExtender/index.ios.d.ts +19 -0
- package/lib/typescript/views/index.d.ts +1 -0
- package/package.json +7 -3
- package/react-native.config.js +1 -0
- package/src/animated.tsx +14 -9
- package/src/bindings.native.ts +8 -0
- package/src/bindings.ts +18 -0
- package/src/components/KeyboardAwareScrollView/index.tsx +72 -47
- package/src/components/KeyboardToolbar/Arrow.tsx +2 -2
- package/src/components/KeyboardToolbar/Button.tsx +2 -2
- package/src/components/KeyboardToolbar/constants.ts +15 -0
- package/src/components/KeyboardToolbar/index.tsx +45 -17
- package/src/hooks/useKeyboardState/index.ts +25 -6
- package/src/index.ts +1 -1
- package/src/module.ts +2 -1
- package/src/specs/KeyboardBackgroundViewNativeComponent.ts +10 -0
- package/src/specs/KeyboardExtenderNativeComponent.ts +13 -0
- package/src/specs/NativeKeyboardController.ts +1 -0
- package/src/types/module.ts +17 -3
- package/src/types/views.ts +5 -0
- package/src/views/KeyboardExtender/index.ios.tsx +35 -0
- package/src/views/KeyboardExtender/index.tsx +42 -0
- package/src/views/index.ts +1 -0
- package/ios/extensions/UIKeyboardAppearance.swift +0 -21
- package/lib/commonjs/components/hooks/useColorScheme.js +0 -10
- package/lib/commonjs/components/hooks/useColorScheme.js.map +0 -1
- package/lib/commonjs/monkey-patch.android.js +0 -53
- package/lib/commonjs/monkey-patch.android.js.map +0 -1
- package/lib/commonjs/monkey-patch.js +0 -11
- package/lib/commonjs/monkey-patch.js.map +0 -1
- package/lib/module/components/hooks/useColorScheme.js +0 -4
- package/lib/module/components/hooks/useColorScheme.js.map +0 -1
- package/lib/module/monkey-patch.android.js +0 -42
- package/lib/module/monkey-patch.android.js.map +0 -1
- package/lib/module/monkey-patch.js +0 -5
- package/lib/module/monkey-patch.js.map +0 -1
- package/lib/typescript/components/hooks/useColorScheme.d.ts +0 -2
- package/lib/typescript/monkey-patch.android.d.ts +0 -2
- package/lib/typescript/monkey-patch.d.ts +0 -2
- package/src/components/hooks/useColorScheme.ts +0 -5
- package/src/monkey-patch.android.ts +0 -41
- package/src/monkey-patch.ts +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useEffect","useMemo","useState","StyleSheet","Text","View","FocusedInputEvents","KeyboardController","useColorScheme","KeyboardStickyView","Arrow","Button","colors","TEST_ID_KEYBOARD_TOOLBAR","TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS","TEST_ID_KEYBOARD_TOOLBAR_NEXT","TEST_ID_KEYBOARD_TOOLBAR_CONTENT","TEST_ID_KEYBOARD_TOOLBAR_DONE","KEYBOARD_TOOLBAR_HEIGHT","DEFAULT_OPACITY","KeyboardToolbar","props","content","theme","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","offset","closed","opened","enabled","insets","rest","colorScheme","inputs","setInputs","current","count","isPrevDisabled","isNextDisabled","subscription","addListener","e","remove","doneStyle","styles","doneButton","color","primary","toolbarStyle","toolbar","backgroundColor","background","paddingLeft","left","paddingRight","right","ButtonContainer","IconContainer","onPressNext","event","isDefaultPrevented","setFocusTo","onPressPrev","onPressDone","dismiss","createElement","_extends","style","testID","arrows","accessibilityHint","accessibilityLabel","disabled","onPress","type","flex","rippleRadius","doneButtonContainer","maxFontSizeMultiplier","create","position","bottom","alignItems","width","flexDirection","height","fontWeight","fontSize","marginRight","marginLeft","DefaultKeyboardToolbarTheme"],"sources":["index.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\n\nimport { FocusedInputEvents } from \"../../bindings\";\nimport { KeyboardController } from \"../../module\";\nimport useColorScheme from \"../hooks/useColorScheme\";\nimport KeyboardStickyView from \"../KeyboardStickyView\";\n\nimport Arrow from \"./Arrow\";\nimport Button from \"./Button\";\nimport { colors } from \"./colors\";\n\nimport type { HEX, KeyboardToolbarTheme } from \"./types\";\nimport type { KeyboardStickyViewProps } from \"../KeyboardStickyView\";\nimport type { ReactNode } from \"react\";\nimport type { GestureResponderEvent, ViewProps } from \"react-native\";\n\ntype SafeAreaInsets = {\n left: number;\n right: number;\n};\n\nexport type KeyboardToolbarProps = Omit<\n ViewProps,\n \"style\" | \"testID\" | \"children\"\n> & {\n /** An element that is shown in the middle of the toolbar. */\n content?: React.JSX.Element | null;\n /** A set of dark/light colors consumed by toolbar component. */\n theme?: KeyboardToolbarTheme;\n /** Custom text for done button. */\n doneText?: ReactNode;\n /** Custom touchable component for toolbar (used for prev/next/done buttons). */\n button?: typeof Button;\n /** Custom icon component used to display next/prev buttons. */\n icon?: typeof Arrow;\n /**\n * Whether to show next and previous buttons. Can be useful to set it to `false` if you have only one input\n * and want to show only `Done` button. Default to `true`.\n */\n showArrows?: boolean;\n /**\n * A callback that is called when the user presses the next button along with the default action.\n */\n onNextCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the previous button along with the default action.\n */\n onPrevCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the done button along with the default action.\n */\n onDoneCallback?: (event: GestureResponderEvent) => void;\n /**\n * A component that applies blur effect to the toolbar.\n */\n blur?: React.JSX.Element | null;\n /**\n * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.\n */\n opacity?: HEX;\n /**\n * A object containing `left`/`right` properties. Used to specify proper container padding in landscape mode.\n */\n insets?: SafeAreaInsets;\n} & Pick<KeyboardStickyViewProps, \"offset\" | \"enabled\">;\n\nconst TEST_ID_KEYBOARD_TOOLBAR = \"keyboard.toolbar\";\nconst TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;\nconst TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;\nconst TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;\nconst TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;\n\nconst KEYBOARD_TOOLBAR_HEIGHT = 42;\nconst DEFAULT_OPACITY: HEX = \"FF\";\n\n/**\n * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` buttons from left and\n * `Done` button from the right (to dismiss the keyboard). Allows to add customizable content (yours UI elements) in the middle.\n *\n * @param props - Component props.\n * @returns A component that is shown above the keyboard with `Prev`/`Next` and `Done` buttons.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-toolbar|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardToolbar doneText=\"Close\" />\n * ```\n */\nconst KeyboardToolbar: React.FC<KeyboardToolbarProps> = (props) => {\n const {\n content,\n theme = colors,\n doneText = \"Done\",\n button,\n icon,\n showArrows = true,\n onNextCallback,\n onPrevCallback,\n onDoneCallback,\n blur = null,\n opacity = DEFAULT_OPACITY,\n offset: { closed = 0, opened = 0 } = {},\n enabled = true,\n insets,\n ...rest\n } = props;\n const colorScheme = useColorScheme();\n const [inputs, setInputs] = useState({\n current: 0,\n count: 0,\n });\n const isPrevDisabled = inputs.current === 0;\n const isNextDisabled = inputs.current === inputs.count - 1;\n\n useEffect(() => {\n const subscription = FocusedInputEvents.addListener(\"focusDidSet\", (e) => {\n setInputs(e);\n });\n\n return subscription.remove;\n }, []);\n const doneStyle = useMemo(\n () => [styles.doneButton, { color: theme[colorScheme].primary }],\n [colorScheme, theme],\n );\n const toolbarStyle = useMemo(\n () => [\n styles.toolbar,\n {\n backgroundColor: `${theme[colorScheme].background}${opacity}`,\n },\n {\n paddingLeft: insets?.left,\n paddingRight: insets?.right,\n },\n ],\n [colorScheme, opacity, theme, insets],\n );\n const offset = useMemo(\n () => ({ closed: closed + KEYBOARD_TOOLBAR_HEIGHT, opened }),\n [closed, opened],\n );\n const ButtonContainer = button || Button;\n const IconContainer = icon || Arrow;\n\n const onPressNext = useCallback(\n (event: GestureResponderEvent) => {\n onNextCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"next\");\n }\n },\n [onNextCallback],\n );\n const onPressPrev = useCallback(\n (event: GestureResponderEvent) => {\n onPrevCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"prev\");\n }\n },\n [onPrevCallback],\n );\n const onPressDone = useCallback(\n (event: GestureResponderEvent) => {\n onDoneCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.dismiss();\n }\n },\n [onDoneCallback],\n );\n\n return (\n <KeyboardStickyView enabled={enabled} offset={offset}>\n <View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\n {blur}\n {showArrows && (\n <View style={styles.arrows}>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the previous field\"\n accessibilityLabel=\"Previous\"\n disabled={isPrevDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\n theme={theme}\n onPress={onPressPrev}\n >\n <IconContainer\n disabled={isPrevDisabled}\n theme={theme}\n type=\"prev\"\n />\n </ButtonContainer>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the next field\"\n accessibilityLabel=\"Next\"\n disabled={isNextDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\n theme={theme}\n onPress={onPressNext}\n >\n <IconContainer\n disabled={isNextDisabled}\n theme={theme}\n type=\"next\"\n />\n </ButtonContainer>\n </View>\n )}\n\n <View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>\n {content}\n </View>\n {doneText && (\n <ButtonContainer\n accessibilityHint=\"Closes the keyboard\"\n accessibilityLabel=\"Done\"\n rippleRadius={28}\n style={styles.doneButtonContainer}\n testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}\n theme={theme}\n onPress={onPressDone}\n >\n <Text maxFontSizeMultiplier={1.3} style={doneStyle}>\n {doneText}\n </Text>\n </ButtonContainer>\n )}\n </View>\n </KeyboardStickyView>\n );\n};\n\nconst styles = StyleSheet.create({\n flex: {\n flex: 1,\n },\n toolbar: {\n position: \"absolute\",\n bottom: 0,\n alignItems: \"center\",\n width: \"100%\",\n flexDirection: \"row\",\n height: KEYBOARD_TOOLBAR_HEIGHT,\n },\n arrows: {\n flexDirection: \"row\",\n paddingLeft: 8,\n },\n doneButton: {\n fontWeight: \"600\",\n fontSize: 15,\n },\n doneButtonContainer: {\n marginRight: 16,\n marginLeft: 8,\n },\n});\n\nexport { colors as DefaultKeyboardToolbarTheme };\nexport default KeyboardToolbar;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACxE,SAASC,UAAU,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAErD,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,kBAAkB,QAAQ,cAAc;AACjD,OAAOC,cAAc,MAAM,yBAAyB;AACpD,OAAOC,kBAAkB,MAAM,uBAAuB;AAEtD,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,MAAM,MAAM,UAAU;AAC7B,SAASC,MAAM,QAAQ,UAAU;AAyDjC,MAAMC,wBAAwB,GAAG,kBAAkB;AACnD,MAAMC,iCAAiC,GAAG,GAAGD,wBAAwB,WAAW;AAChF,MAAME,6BAA6B,GAAG,GAAGF,wBAAwB,OAAO;AACxE,MAAMG,gCAAgC,GAAG,GAAGH,wBAAwB,UAAU;AAC9E,MAAMI,6BAA6B,GAAG,GAAGJ,wBAAwB,OAAO;AAExE,MAAMK,uBAAuB,GAAG,EAAE;AAClC,MAAMC,eAAoB,GAAG,IAAI;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAA+C,GAAIC,KAAK,IAAK;EACjE,MAAM;IACJC,OAAO;IACPC,KAAK,GAAGX,MAAM;IACdY,QAAQ,GAAG,MAAM;IACjBC,MAAM;IACNC,IAAI;IACJC,UAAU,GAAG,IAAI;IACjBC,cAAc;IACdC,cAAc;IACdC,cAAc;IACdC,IAAI,GAAG,IAAI;IACXC,OAAO,GAAGb,eAAe;IACzBc,MAAM,EAAE;MAAEC,MAAM,GAAG,CAAC;MAAEC,MAAM,GAAG;IAA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KAAM;IACbyD,OAAO,EAAEV;EAAY,gBAErBxE,KAAA,CAAA0E,aAAA,CAACpE,IAAI;IAACiF,qBAAqB,EAAE,GAAI;IAACX,KAAK,EAAExB;EAAU,GAChD1B,QACG,CACS,CAEf,CACY,CAAC;AAEzB,CAAC;AAED,MAAM2B,MAAM,GAAGhD,UAAU,CAACmF,MAAM,CAAC;EAC/BJ,IAAI,EAAE;IACJA,IAAI,EAAE;EACR,CAAC;EACD1B,OAAO,EAAE;IACP+B,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE,CAAC;IACTC,UAAU,EAAE,QAAQ;IACpBC,KAAK,EAAE,MAAM;IACbC,aAAa,EAAE,KAAK;IACpBC,MAAM,EAAE1E;EACV,CAAC;EACD0D,MAAM,EAAE;IACNe,aAAa,EAAE,KAAK;IACpBhC,WAAW,EAAE;EACf,CAAC;EACDP,UAAU,EAAE;IACVyC,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDV,mBAAmB,EAAE;IACnBW,WAAW,EAAE,EAAE;IACfC,UAAU,EAAE;EACd;AACF,CAAC,CAAC;AAEF,SAASpF,MAAM,IAAIqF,2BAA2B;AAC9C,eAAe7E,eAAe","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","useCallback","useEffect","useMemo","useState","StyleSheet","Text","View","FocusedInputEvents","useKeyboardState","KeyboardController","KeyboardStickyView","Arrow","Button","colors","DEFAULT_OPACITY","KEYBOARD_HAS_ROUNDED_CORNERS","KEYBOARD_TOOLBAR_HEIGHT","OPENED_OFFSET","TEST_ID_KEYBOARD_TOOLBAR","TEST_ID_KEYBOARD_TOOLBAR_CONTENT","TEST_ID_KEYBOARD_TOOLBAR_DONE","TEST_ID_KEYBOARD_TOOLBAR_NEXT","TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS","KeyboardToolbar","props","content","theme","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","offset","closed","opened","enabled","insets","rest","colorScheme","state","appearance","inputs","setInputs","current","count","isPrevDisabled","isNextDisabled","subscription","addListener","e","remove","doneStyle","styles","doneButton","color","primary","toolbarStyle","toolbar","backgroundColor","background","paddingLeft","left","paddingRight","right","floating","containerStyle","marginLeft","marginRight","ButtonContainer","IconContainer","onPressNext","event","isDefaultPrevented","setFocusTo","onPressPrev","onPressDone","dismiss","createElement","style","_extends","testID","arrows","accessibilityHint","accessibilityLabel","disabled","onPress","type","flex","rippleRadius","doneButtonContainer","maxFontSizeMultiplier","create","position","bottom","alignItems","width","flexDirection","height","fontWeight","fontSize","alignSelf","borderRadius","overflow","DefaultKeyboardToolbarTheme"],"sources":["index.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\n\nimport { FocusedInputEvents } from \"../../bindings\";\nimport { useKeyboardState } from \"../../hooks\";\nimport { KeyboardController } from \"../../module\";\nimport KeyboardStickyView from \"../KeyboardStickyView\";\n\nimport Arrow from \"./Arrow\";\nimport Button from \"./Button\";\nimport { colors } from \"./colors\";\nimport {\n DEFAULT_OPACITY,\n KEYBOARD_HAS_ROUNDED_CORNERS,\n KEYBOARD_TOOLBAR_HEIGHT,\n OPENED_OFFSET,\n TEST_ID_KEYBOARD_TOOLBAR,\n TEST_ID_KEYBOARD_TOOLBAR_CONTENT,\n TEST_ID_KEYBOARD_TOOLBAR_DONE,\n TEST_ID_KEYBOARD_TOOLBAR_NEXT,\n TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS,\n} from \"./constants\";\n\nimport type { HEX, KeyboardToolbarTheme } from \"./types\";\nimport type { KeyboardStickyViewProps } from \"../KeyboardStickyView\";\nimport type { ReactNode } from \"react\";\nimport type { GestureResponderEvent, ViewProps } from \"react-native\";\n\ntype SafeAreaInsets = {\n left: number;\n right: number;\n};\n\nexport type KeyboardToolbarProps = Omit<\n ViewProps,\n \"style\" | \"testID\" | \"children\"\n> & {\n /** An element that is shown in the middle of the toolbar. */\n content?: React.JSX.Element | null;\n /** A set of dark/light colors consumed by toolbar component. */\n theme?: KeyboardToolbarTheme;\n /** Custom text for done button. */\n doneText?: ReactNode;\n /** Custom touchable component for toolbar (used for prev/next/done buttons). */\n button?: typeof Button;\n /** Custom icon component used to display next/prev buttons. */\n icon?: typeof Arrow;\n /**\n * Whether to show next and previous buttons. Can be useful to set it to `false` if you have only one input\n * and want to show only `Done` button. Default to `true`.\n */\n showArrows?: boolean;\n /**\n * A callback that is called when the user presses the next button along with the default action.\n */\n onNextCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the previous button along with the default action.\n */\n onPrevCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the done button along with the default action.\n */\n onDoneCallback?: (event: GestureResponderEvent) => void;\n /**\n * A component that applies blur effect to the toolbar.\n */\n blur?: React.JSX.Element | null;\n /**\n * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.\n */\n opacity?: HEX;\n /**\n * A object containing `left`/`right` properties. Used to specify proper container padding in landscape mode.\n */\n insets?: SafeAreaInsets;\n} & Pick<KeyboardStickyViewProps, \"offset\" | \"enabled\">;\n\n/**\n * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` buttons from left and\n * `Done` button from the right (to dismiss the keyboard). Allows to add customizable content (yours UI elements) in the middle.\n *\n * @param props - Component props.\n * @returns A component that is shown above the keyboard with `Prev`/`Next` and `Done` buttons.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-toolbar|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardToolbar doneText=\"Close\" />\n * ```\n */\nconst KeyboardToolbar: React.FC<KeyboardToolbarProps> = (props) => {\n const {\n content,\n theme = colors,\n doneText = \"Done\",\n button,\n icon,\n showArrows = true,\n onNextCallback,\n onPrevCallback,\n onDoneCallback,\n blur = null,\n opacity = DEFAULT_OPACITY,\n offset: { closed = 0, opened = 0 } = {},\n enabled = true,\n insets,\n ...rest\n } = props;\n const colorScheme = useKeyboardState((state) => state.appearance);\n const [inputs, setInputs] = useState({\n current: 0,\n count: 0,\n });\n const isPrevDisabled = inputs.current === 0;\n const isNextDisabled = inputs.current === inputs.count - 1;\n\n useEffect(() => {\n const subscription = FocusedInputEvents.addListener(\"focusDidSet\", (e) => {\n setInputs(e);\n });\n\n return subscription.remove;\n }, []);\n const doneStyle = useMemo(\n () => [styles.doneButton, { color: theme[colorScheme].primary }],\n [colorScheme, theme],\n );\n const toolbarStyle = useMemo(\n () => [\n styles.toolbar,\n {\n backgroundColor: `${theme[colorScheme].background}${opacity}`,\n },\n !KEYBOARD_HAS_ROUNDED_CORNERS\n ? {\n paddingLeft: insets?.left,\n paddingRight: insets?.right,\n }\n : null,\n KEYBOARD_HAS_ROUNDED_CORNERS ? styles.floating : null,\n ],\n [colorScheme, opacity, theme, insets],\n );\n const containerStyle = useMemo(\n () => [\n KEYBOARD_HAS_ROUNDED_CORNERS\n ? {\n marginLeft: (insets?.left ?? 0) + 16,\n marginRight: (insets?.right ?? 0) + 16,\n }\n : null,\n ],\n [insets],\n );\n const offset = useMemo(\n () => ({\n closed: closed + KEYBOARD_TOOLBAR_HEIGHT,\n opened: opened + OPENED_OFFSET,\n }),\n [closed, opened],\n );\n const ButtonContainer = button || Button;\n const IconContainer = icon || Arrow;\n\n const onPressNext = useCallback(\n (event: GestureResponderEvent) => {\n onNextCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"next\");\n }\n },\n [onNextCallback],\n );\n const onPressPrev = useCallback(\n (event: GestureResponderEvent) => {\n onPrevCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"prev\");\n }\n },\n [onPrevCallback],\n );\n const onPressDone = useCallback(\n (event: GestureResponderEvent) => {\n onDoneCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.dismiss();\n }\n },\n [onDoneCallback],\n );\n\n return (\n <KeyboardStickyView\n enabled={enabled}\n offset={offset}\n style={containerStyle}\n >\n <View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\n {blur}\n {showArrows && (\n <View style={styles.arrows}>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the previous field\"\n accessibilityLabel=\"Previous\"\n disabled={isPrevDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\n theme={theme}\n onPress={onPressPrev}\n >\n <IconContainer\n disabled={isPrevDisabled}\n theme={theme}\n type=\"prev\"\n />\n </ButtonContainer>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the next field\"\n accessibilityLabel=\"Next\"\n disabled={isNextDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\n theme={theme}\n onPress={onPressNext}\n >\n <IconContainer\n disabled={isNextDisabled}\n theme={theme}\n type=\"next\"\n />\n </ButtonContainer>\n </View>\n )}\n\n <View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>\n {content}\n </View>\n {doneText && (\n <ButtonContainer\n accessibilityHint=\"Closes the keyboard\"\n accessibilityLabel=\"Done\"\n rippleRadius={28}\n style={styles.doneButtonContainer}\n testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}\n theme={theme}\n onPress={onPressDone}\n >\n <Text maxFontSizeMultiplier={1.3} style={doneStyle}>\n {doneText}\n </Text>\n </ButtonContainer>\n )}\n </View>\n </KeyboardStickyView>\n );\n};\n\nconst styles = StyleSheet.create({\n flex: {\n flex: 1,\n },\n toolbar: {\n position: \"absolute\",\n bottom: 0,\n alignItems: \"center\",\n width: \"100%\",\n flexDirection: \"row\",\n height: KEYBOARD_TOOLBAR_HEIGHT,\n },\n arrows: {\n flexDirection: \"row\",\n paddingLeft: 8,\n },\n doneButton: {\n fontWeight: \"600\",\n fontSize: 15,\n },\n doneButtonContainer: {\n marginRight: 16,\n marginLeft: 8,\n },\n floating: {\n alignSelf: \"center\",\n borderRadius: 20,\n overflow: \"hidden\",\n },\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M,EAAEjE;EAAiC,GAChEM,OACG,CAAC,EACNE,QAAQ,iBACP5B,KAAA,CAAAkF,aAAA,CAACT,eAAe;IACdc,iBAAiB,EAAC,qBAAqB;IACvCC,kBAAkB,EAAC,MAAM;IACzBK,YAAY,EAAE,EAAG;IACjBV,KAAK,EAAE1B,MAAM,CAACqC,mBAAoB;IAClCT,MAAM,EAAEhE,6BAA8B;IACtCM,KAAK,EAAEA,KAAM;IACb+D,OAAO,EAAEV;EAAY,gBAErBhF,KAAA,CAAAkF,aAAA,CAAC5E,IAAI;IAACyF,qBAAqB,EAAE,GAAI;IAACZ,KAAK,EAAE3B;EAAU,GAChD5B,QACG,CACS,CAEf,CACY,CAAC;AAEzB,CAAC;AAED,MAAM6B,MAAM,GAAGpD,UAAU,CAAC2F,MAAM,CAAC;EAC/BJ,IAAI,EAAE;IACJA,IAAI,EAAE;EACR,CAAC;EACD9B,OAAO,EAAE;IACPmC,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE,CAAC;IACTC,UAAU,EAAE,QAAQ;IACpBC,KAAK,EAAE,MAAM;IACbC,aAAa,EAAE,KAAK;IACpBC,MAAM,EAAErF;EACV,CAAC;EACDqE,MAAM,EAAE;IACNe,aAAa,EAAE,KAAK;IACpBpC,WAAW,EAAE;EACf,CAAC;EACDP,UAAU,EAAE;IACV6C,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDV,mBAAmB,EAAE;IACnBtB,WAAW,EAAE,EAAE;IACfD,UAAU,EAAE;EACd,CAAC;EACDF,QAAQ,EAAE;IACRoC,SAAS,EAAE,QAAQ;IACnBC,YAAY,EAAE,EAAE;IAChBC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AAEF,SAAS7F,MAAM,IAAI8F,2BAA2B;AAC9C,eAAepF,eAAe","ignoreList":[]}
|
|
@@ -6,18 +6,23 @@ const getLatestState = () => ({
|
|
|
6
6
|
...KeyboardController.state(),
|
|
7
7
|
isVisible: KeyboardController.isVisible()
|
|
8
8
|
});
|
|
9
|
+
const defaultSelector = state => state;
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* React Hook that represents the current keyboard state on iOS and Android.
|
|
12
13
|
* It tracks keyboard visibility, height, appearance, type and other properties.
|
|
13
14
|
* This hook subscribes to keyboard events and updates the state reactively.
|
|
14
15
|
*
|
|
16
|
+
* @template T - A type of the returned object from the `selector`.
|
|
17
|
+
* @param selector - A function that receives the current keyboard state and picks only necessary properties to avoid frequent re-renders.
|
|
15
18
|
* @returns Object {@link KeyboardState|containing} keyboard state information.
|
|
16
19
|
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-state|Documentation} page for more details.
|
|
17
20
|
* @example
|
|
18
21
|
* ```tsx
|
|
19
22
|
* function MyComponent() {
|
|
20
|
-
* const
|
|
23
|
+
* const isVisible = useKeyboardState((state) => state.isVisible);
|
|
24
|
+
* const height = useKeyboardState((state) => state.height);
|
|
25
|
+
*
|
|
21
26
|
* return (
|
|
22
27
|
* <View>
|
|
23
28
|
* <Text>Keyboard is {isVisible ? 'visible' : 'hidden'}</Text>
|
|
@@ -27,22 +32,29 @@ const getLatestState = () => ({
|
|
|
27
32
|
* }
|
|
28
33
|
* ```
|
|
29
34
|
*/
|
|
30
|
-
|
|
31
|
-
const [state, setState] = useState(getLatestState);
|
|
35
|
+
function useKeyboardState(selector = defaultSelector) {
|
|
36
|
+
const [state, setState] = useState(() => selector(getLatestState()));
|
|
32
37
|
useEffect(() => {
|
|
33
38
|
const subscriptions = EVENTS.map(event => KeyboardEvents.addListener(event, () =>
|
|
34
39
|
// state will be updated by global listener first,
|
|
35
40
|
// so we simply read it and don't derive data from the event
|
|
36
|
-
setState(getLatestState)));
|
|
41
|
+
setState(selector(getLatestState()))));
|
|
42
|
+
// update `appearance` prematurely
|
|
43
|
+
const willShowSubscription = KeyboardEvents.addListener("keyboardWillShow", e => setState(selector({
|
|
44
|
+
...getLatestState(),
|
|
45
|
+
appearance: e.appearance
|
|
46
|
+
})));
|
|
37
47
|
|
|
38
48
|
// we might have missed an update between reading a value in render and
|
|
39
49
|
// `addListener` in this handler, so we set it here. If there was
|
|
40
50
|
// no change, React will filter out this update as a no-op.
|
|
41
|
-
setState(getLatestState);
|
|
51
|
+
setState(selector(getLatestState()));
|
|
42
52
|
return () => {
|
|
43
53
|
subscriptions.forEach(subscription => subscription.remove());
|
|
54
|
+
willShowSubscription.remove();
|
|
44
55
|
};
|
|
45
56
|
}, []);
|
|
46
57
|
return state;
|
|
47
|
-
}
|
|
58
|
+
}
|
|
59
|
+
export { useKeyboardState };
|
|
48
60
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useState","KeyboardEvents","KeyboardController","EVENTS","getLatestState","state","isVisible","useKeyboardState","setState","subscriptions","map","event","addListener","forEach","subscription","remove"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport { KeyboardEvents } from \"../../bindings\";\nimport { KeyboardController } from \"../../module\";\n\nimport type { KeyboardState } from \"../../types\";\n\nconst EVENTS = [\"keyboardDidShow\", \"keyboardDidHide\"] as const;\n\nconst getLatestState = () => ({\n ...KeyboardController.state(),\n isVisible: KeyboardController.isVisible(),\n});\n\n/**\n * React Hook that represents the current keyboard state on iOS and Android.\n * It tracks keyboard visibility, height, appearance, type and other properties.\n * This hook subscribes to keyboard events and updates the state reactively.\n *\n * @returns Object {@link KeyboardState|containing} keyboard state information.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-state|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const
|
|
1
|
+
{"version":3,"names":["useEffect","useState","KeyboardEvents","KeyboardController","EVENTS","getLatestState","state","isVisible","defaultSelector","useKeyboardState","selector","setState","subscriptions","map","event","addListener","willShowSubscription","e","appearance","forEach","subscription","remove"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport { KeyboardEvents } from \"../../bindings\";\nimport { KeyboardController } from \"../../module\";\n\nimport type { KeyboardState } from \"../../types\";\n\nconst EVENTS = [\"keyboardDidShow\", \"keyboardDidHide\"] as const;\n\nconst getLatestState = () => ({\n ...KeyboardController.state(),\n isVisible: KeyboardController.isVisible(),\n});\n\ntype KeyboardStateSelector<T> = (state: KeyboardState) => T;\n\nconst defaultSelector: KeyboardStateSelector<KeyboardState> = (state) => state;\n\n/**\n * React Hook that represents the current keyboard state on iOS and Android.\n * It tracks keyboard visibility, height, appearance, type and other properties.\n * This hook subscribes to keyboard events and updates the state reactively.\n *\n * @template T - A type of the returned object from the `selector`.\n * @param selector - A function that receives the current keyboard state and picks only necessary properties to avoid frequent re-renders.\n * @returns Object {@link KeyboardState|containing} keyboard state information.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-state|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const isVisible = useKeyboardState((state) => state.isVisible);\n * const height = useKeyboardState((state) => state.height);\n *\n * return (\n * <View>\n * <Text>Keyboard is {isVisible ? 'visible' : 'hidden'}</Text>\n * <Text>Keyboard height: {height}</Text>\n * </View>\n * );\n * }\n * ```\n */\nfunction useKeyboardState<T = KeyboardState>(\n selector: KeyboardStateSelector<T> = defaultSelector as KeyboardStateSelector<T>,\n): T {\n const [state, setState] = useState<T>(() => selector(getLatestState()));\n\n useEffect(() => {\n const subscriptions = EVENTS.map((event) =>\n KeyboardEvents.addListener(event, () =>\n // state will be updated by global listener first,\n // so we simply read it and don't derive data from the event\n setState(selector(getLatestState())),\n ),\n );\n // update `appearance` prematurely\n const willShowSubscription = KeyboardEvents.addListener(\n \"keyboardWillShow\",\n (e) =>\n setState(selector({ ...getLatestState(), appearance: e.appearance })),\n );\n\n // we might have missed an update between reading a value in render and\n // `addListener` in this handler, so we set it here. If there was\n // no change, React will filter out this update as a no-op.\n setState(selector(getLatestState()));\n\n return () => {\n subscriptions.forEach((subscription) => subscription.remove());\n willShowSubscription.remove();\n };\n }, []);\n\n return state;\n}\n\nexport { useKeyboardState };\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,SAASC,cAAc,QAAQ,gBAAgB;AAC/C,SAASC,kBAAkB,QAAQ,cAAc;AAIjD,MAAMC,MAAM,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,CAAU;AAE9D,MAAMC,cAAc,GAAGA,CAAA,MAAO;EAC5B,GAAGF,kBAAkB,CAACG,KAAK,CAAC,CAAC;EAC7BC,SAAS,EAAEJ,kBAAkB,CAACI,SAAS,CAAC;AAC1C,CAAC,CAAC;AAIF,MAAMC,eAAqD,GAAIF,KAAK,IAAKA,KAAK;;AAE9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,gBAAgBA,CACvBC,QAAkC,GAAGF,eAA2C,EAC7E;EACH,MAAM,CAACF,KAAK,EAAEK,QAAQ,CAAC,GAAGV,QAAQ,CAAI,MAAMS,QAAQ,CAACL,cAAc,CAAC,CAAC,CAAC,CAAC;EAEvEL,SAAS,CAAC,MAAM;IACd,MAAMY,aAAa,GAAGR,MAAM,CAACS,GAAG,CAAEC,KAAK,IACrCZ,cAAc,CAACa,WAAW,CAACD,KAAK,EAAE;IAChC;IACA;IACAH,QAAQ,CAACD,QAAQ,CAACL,cAAc,CAAC,CAAC,CAAC,CACrC,CACF,CAAC;IACD;IACA,MAAMW,oBAAoB,GAAGd,cAAc,CAACa,WAAW,CACrD,kBAAkB,EACjBE,CAAC,IACAN,QAAQ,CAACD,QAAQ,CAAC;MAAE,GAAGL,cAAc,CAAC,CAAC;MAAEa,UAAU,EAAED,CAAC,CAACC;IAAW,CAAC,CAAC,CACxE,CAAC;;IAED;IACA;IACA;IACAP,QAAQ,CAACD,QAAQ,CAACL,cAAc,CAAC,CAAC,CAAC,CAAC;IAEpC,OAAO,MAAM;MACXO,aAAa,CAACO,OAAO,CAAEC,YAAY,IAAKA,YAAY,CAACC,MAAM,CAAC,CAAC,CAAC;MAC9DL,oBAAoB,CAACK,MAAM,CAAC,CAAC;IAC/B,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOf,KAAK;AACd;AAEA,SAASG,gBAAgB","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -8,5 +8,5 @@ export * from "./types";
|
|
|
8
8
|
export { KeyboardAvoidingView, KeyboardStickyView, KeyboardAwareScrollView,
|
|
9
9
|
// keyboard toolbar
|
|
10
10
|
KeyboardToolbar, DefaultKeyboardToolbarTheme } from "./components";
|
|
11
|
-
export { OverKeyboardView } from "./views";
|
|
11
|
+
export { OverKeyboardView, KeyboardExtender } from "./views";
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KeyboardAvoidingView","KeyboardStickyView","KeyboardAwareScrollView","KeyboardToolbar","DefaultKeyboardToolbarTheme","OverKeyboardView"],"sources":["index.ts"],"sourcesContent":["export * from \"./bindings\";\nexport * from \"./animated\";\nexport * from \"./context\";\nexport * from \"./hooks\";\nexport * from \"./constants\";\nexport * from \"./module\";\nexport * from \"./types\";\n\nexport {\n KeyboardAvoidingView,\n KeyboardStickyView,\n KeyboardAwareScrollView,\n // keyboard toolbar\n KeyboardToolbar,\n DefaultKeyboardToolbarTheme,\n} from \"./components\";\nexport type {\n KeyboardAvoidingViewProps,\n KeyboardStickyViewProps,\n KeyboardAwareScrollViewProps,\n KeyboardToolbarProps,\n} from \"./components\";\nexport { OverKeyboardView } from \"./views\";\n"],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,SAAS;AAEvB,SACEA,oBAAoB,EACpBC,kBAAkB,EAClBC,uBAAuB;AACvB;AACAC,eAAe,EACfC,2BAA2B,QACtB,cAAc;AAOrB,SAASC,gBAAgB,QAAQ,SAAS","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["KeyboardAvoidingView","KeyboardStickyView","KeyboardAwareScrollView","KeyboardToolbar","DefaultKeyboardToolbarTheme","OverKeyboardView","KeyboardExtender"],"sources":["index.ts"],"sourcesContent":["export * from \"./bindings\";\nexport * from \"./animated\";\nexport * from \"./context\";\nexport * from \"./hooks\";\nexport * from \"./constants\";\nexport * from \"./module\";\nexport * from \"./types\";\n\nexport {\n KeyboardAvoidingView,\n KeyboardStickyView,\n KeyboardAwareScrollView,\n // keyboard toolbar\n KeyboardToolbar,\n DefaultKeyboardToolbarTheme,\n} from \"./components\";\nexport type {\n KeyboardAvoidingViewProps,\n KeyboardStickyViewProps,\n KeyboardAwareScrollViewProps,\n KeyboardToolbarProps,\n} from \"./components\";\nexport { OverKeyboardView, KeyboardExtender } from \"./views\";\n"],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,SAAS;AAEvB,SACEA,oBAAoB,EACpBC,kBAAkB,EAClBC,uBAAuB;AACvB;AACAC,eAAe,EACfC,2BAA2B,QACtB,cAAc;AAOrB,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,SAAS","ignoreList":[]}
|
package/lib/module/module.js
CHANGED
|
@@ -6,7 +6,7 @@ let lastState = {
|
|
|
6
6
|
timestamp: new Date().getTime(),
|
|
7
7
|
target: -1,
|
|
8
8
|
type: "default",
|
|
9
|
-
appearance: "
|
|
9
|
+
appearance: "light"
|
|
10
10
|
};
|
|
11
11
|
KeyboardEvents.addListener("keyboardDidHide", e => {
|
|
12
12
|
isClosed = true;
|
|
@@ -40,6 +40,7 @@ export const KeyboardController = {
|
|
|
40
40
|
setDefaultMode: KeyboardControllerNative.setDefaultMode,
|
|
41
41
|
setInputMode: KeyboardControllerNative.setInputMode,
|
|
42
42
|
setFocusTo: KeyboardControllerNative.setFocusTo,
|
|
43
|
+
preload: KeyboardControllerNative.preload,
|
|
43
44
|
dismiss,
|
|
44
45
|
isVisible,
|
|
45
46
|
state
|
package/lib/module/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KeyboardControllerNative","KeyboardEvents","isClosed","lastState","height","duration","timestamp","Date","getTime","target","type","appearance","addListener","e","dismiss","options","keepFocus","Promise","resolve","subscription","undefined","remove","isVisible","state","KeyboardController","setDefaultMode","setInputMode","setFocusTo"],"sources":["module.ts"],"sourcesContent":["import { KeyboardControllerNative, KeyboardEvents } from \"./bindings\";\n\nimport type {\n DismissOptions,\n KeyboardControllerModule,\n KeyboardEventData,\n} from \"./types\";\n\nlet isClosed = true;\nlet lastState: KeyboardEventData = {\n height: 0,\n duration: 0,\n timestamp: new Date().getTime(),\n target: -1,\n type: \"default\",\n appearance: \"
|
|
1
|
+
{"version":3,"names":["KeyboardControllerNative","KeyboardEvents","isClosed","lastState","height","duration","timestamp","Date","getTime","target","type","appearance","addListener","e","dismiss","options","keepFocus","Promise","resolve","subscription","undefined","remove","isVisible","state","KeyboardController","setDefaultMode","setInputMode","setFocusTo","preload"],"sources":["module.ts"],"sourcesContent":["import { KeyboardControllerNative, KeyboardEvents } from \"./bindings\";\n\nimport type {\n DismissOptions,\n KeyboardControllerModule,\n KeyboardEventData,\n} from \"./types\";\n\nlet isClosed = true;\nlet lastState: KeyboardEventData = {\n height: 0,\n duration: 0,\n timestamp: new Date().getTime(),\n target: -1,\n type: \"default\",\n appearance: \"light\",\n};\n\nKeyboardEvents.addListener(\"keyboardDidHide\", (e) => {\n isClosed = true;\n lastState = e;\n});\n\nKeyboardEvents.addListener(\"keyboardDidShow\", (e) => {\n isClosed = false;\n lastState = e;\n});\n\nconst dismiss = async (options?: DismissOptions): Promise<void> => {\n const keepFocus = options?.keepFocus ?? false;\n\n return new Promise((resolve) => {\n if (isClosed) {\n resolve();\n\n return;\n }\n\n const subscription = KeyboardEvents.addListener(\"keyboardDidHide\", () => {\n resolve(undefined);\n subscription.remove();\n });\n\n KeyboardControllerNative.dismiss(keepFocus);\n });\n};\nconst isVisible = () => !isClosed;\nconst state = () => lastState;\n\n/**\n * KeyboardController module. Helps to perform imperative actions/checks with keyboard.\n */\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: KeyboardControllerNative.setDefaultMode,\n setInputMode: KeyboardControllerNative.setInputMode,\n setFocusTo: KeyboardControllerNative.setFocusTo,\n preload: KeyboardControllerNative.preload,\n dismiss,\n isVisible,\n state,\n};\n"],"mappings":"AAAA,SAASA,wBAAwB,EAAEC,cAAc,QAAQ,YAAY;AAQrE,IAAIC,QAAQ,GAAG,IAAI;AACnB,IAAIC,SAA4B,GAAG;EACjCC,MAAM,EAAE,CAAC;EACTC,QAAQ,EAAE,CAAC;EACXC,SAAS,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC;EAC/BC,MAAM,EAAE,CAAC,CAAC;EACVC,IAAI,EAAE,SAAS;EACfC,UAAU,EAAE;AACd,CAAC;AAEDV,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDX,QAAQ,GAAG,IAAI;EACfC,SAAS,GAAGU,CAAC;AACf,CAAC,CAAC;AAEFZ,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDX,QAAQ,GAAG,KAAK;EAChBC,SAAS,GAAGU,CAAC;AACf,CAAC,CAAC;AAEF,MAAMC,OAAO,GAAG,MAAOC,OAAwB,IAAoB;EACjE,MAAMC,SAAS,GAAG,CAAAD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,SAAS,KAAI,KAAK;EAE7C,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;IAC9B,IAAIhB,QAAQ,EAAE;MACZgB,OAAO,CAAC,CAAC;MAET;IACF;IAEA,MAAMC,YAAY,GAAGlB,cAAc,CAACW,WAAW,CAAC,iBAAiB,EAAE,MAAM;MACvEM,OAAO,CAACE,SAAS,CAAC;MAClBD,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC;IAEFrB,wBAAwB,CAACc,OAAO,CAACE,SAAS,CAAC;EAC7C,CAAC,CAAC;AACJ,CAAC;AACD,MAAMM,SAAS,GAAGA,CAAA,KAAM,CAACpB,QAAQ;AACjC,MAAMqB,KAAK,GAAGA,CAAA,KAAMpB,SAAS;;AAE7B;AACA;AACA;AACA,OAAO,MAAMqB,kBAA4C,GAAG;EAC1DC,cAAc,EAAEzB,wBAAwB,CAACyB,cAAc;EACvDC,YAAY,EAAE1B,wBAAwB,CAAC0B,YAAY;EACnDC,UAAU,EAAE3B,wBAAwB,CAAC2B,UAAU;EAC/CC,OAAO,EAAE5B,wBAAwB,CAAC4B,OAAO;EACzCd,OAAO;EACPQ,SAAS;EACTC;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent","interfaceOnly"],"sources":["KeyboardBackgroundViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\n\nimport type { HostComponent } from \"react-native\";\nimport type { ViewProps } from \"react-native/Libraries/Components/View/ViewPropTypes\";\n\nexport interface NativeProps extends ViewProps {}\n\nexport default codegenNativeComponent<NativeProps>(\"KeyboardBackgroundView\", {\n interfaceOnly: true,\n}) as HostComponent<NativeProps>;\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;AAO5F,eAAeA,sBAAsB,CAAc,wBAAwB,EAAE;EAC3EC,aAAa,EAAE;AACjB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
2
|
+
export default codegenNativeComponent("KeyboardExtender", {
|
|
3
|
+
interfaceOnly: true,
|
|
4
|
+
excludedPlatforms: ["android"]
|
|
5
|
+
});
|
|
6
|
+
//# sourceMappingURL=KeyboardExtenderNativeComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent","interfaceOnly","excludedPlatforms"],"sources":["KeyboardExtenderNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\n\nimport type { HostComponent } from \"react-native\";\nimport type { ViewProps } from \"react-native/Libraries/Components/View/ViewPropTypes\";\n\nexport interface NativeProps extends ViewProps {\n enabled?: boolean;\n}\n\nexport default codegenNativeComponent<NativeProps>(\"KeyboardExtender\", {\n interfaceOnly: true,\n excludedPlatforms: [\"android\"],\n}) as HostComponent<NativeProps>;\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;AAS5F,eAAeA,sBAAsB,CAAc,kBAAkB,EAAE;EACrEC,aAAa,EAAE,IAAI;EACnBC,iBAAiB,EAAE,CAAC,SAAS;AAC/B,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","get"],"sources":["NativeKeyboardController.ts"],"sourcesContent":["import { TurboModuleRegistry } from \"react-native\";\n\nimport type { TurboModule } from \"react-native\";\n\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n // methods\n setInputMode(mode: number): void;\n setDefaultMode(): void;\n dismiss(keepFocus: boolean): void;\n setFocusTo(direction: string): void;\n\n // event emitter\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n}\n\nexport default TurboModuleRegistry.get<Spec>(\"KeyboardController\");\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","get"],"sources":["NativeKeyboardController.ts"],"sourcesContent":["import { TurboModuleRegistry } from \"react-native\";\n\nimport type { TurboModule } from \"react-native\";\n\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n // methods\n setInputMode(mode: number): void;\n setDefaultMode(): void;\n preload(): void;\n dismiss(keepFocus: boolean): void;\n setFocusTo(direction: string): void;\n\n // event emitter\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n}\n\nexport default TurboModuleRegistry.get<Spec>(\"KeyboardController\");\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,cAAc;AAmBlD,eAAeA,mBAAmB,CAACC,GAAG,CAAO,oBAAoB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["module.ts"],"sourcesContent":["import type { EmitterSubscription, TextInputProps } from \"react-native\";\n\n// Event module declarations\nexport type KeyboardControllerEvents =\n | \"keyboardWillShow\"\n | \"keyboardDidShow\"\n | \"keyboardWillHide\"\n | \"keyboardDidHide\";\nexport type KeyboardEventData = {\n /** Height of the keyboard. */\n height: number;\n /** Duration of the keyboard animation. */\n duration: number;\n /** Timestamp of the last keyboard event. */\n timestamp: number;\n /** Tag of the focused `TextInput`. */\n target: number;\n /** `keyboardType` property from focused `TextInput`. */\n type: NonNullable<TextInputProps[\"keyboardType\"]>;\n /** Keyboard appearance. Can be one of `
|
|
1
|
+
{"version":3,"names":[],"sources":["module.ts"],"sourcesContent":["import type { EmitterSubscription, TextInputProps } from \"react-native\";\n\n// Event module declarations\nexport type KeyboardControllerEvents =\n | \"keyboardWillShow\"\n | \"keyboardDidShow\"\n | \"keyboardWillHide\"\n | \"keyboardDidHide\";\nexport type KeyboardEventData = {\n /** Height of the keyboard. */\n height: number;\n /** Duration of the keyboard animation. */\n duration: number;\n /** Timestamp of the last keyboard event. */\n timestamp: number;\n /** Tag of the focused `TextInput`. */\n target: number;\n /** `keyboardType` property from focused `TextInput`. */\n type: NonNullable<TextInputProps[\"keyboardType\"]>;\n /** Keyboard appearance. Can be one of `dark` or `light`. */\n appearance: \"dark\" | \"light\";\n};\n/**\n * An object that represent current keyboard state.\n */\nexport type KeyboardState = {\n /** Whether the keyboard is currently visible. */\n isVisible: boolean;\n} & KeyboardEventData;\nexport type KeyboardEventsModule = {\n /**\n * The `addListener` function connects a JavaScript function to an identified native\n * keyboard notification event.\n *\n * This function then returns the reference to the listener.\n *\n * `name` is the string that identifies the event you're listening for. This\n * can be any of the following:\n *\n * - `keyboardWillShow`;\n * - `keyboardDidShow`;\n * - `keyboardWillHide`;\n * - `keyboardDidHide`.\n */\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEventData) => void,\n ) => EmitterSubscription;\n};\nexport type Direction = \"next\" | \"prev\" | \"current\";\nexport type DismissOptions = {\n /**\n * A boolean property indicating whether focus should be kept on the input after dismissing the keyboard. Default is `false`.\n */\n keepFocus: boolean;\n};\nexport type KeyboardControllerModule = {\n // android only\n /**\n * Sets default `windowSoftInputMode` (the one that declared in `AndroidManifest.xml`).\n *\n * @platform android\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setdefaultmode-|docs} page for more details.\n */\n setDefaultMode: () => void;\n /**\n * Changes `windowSoftInputMode` on Android.\n *\n * @platform android\n * @see AndroidSoftInputModes for all possible values and {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setinputmode-|docs} page for more details.\n */\n setInputMode: (mode: number) => void;\n // ios only\n /**\n * A method that preloads the keyboard. It's useful when you want to avoid a delay when the user focuses the first input.\n *\n * @platform ios\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#preload-|docs} page for more details.\n */\n preload: () => void;\n // all platforms\n /**\n * Dismisses the active keyboard. Removes a focus by default, but allows to pass `{keepFocus: true}` to keep focus.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#dismiss|docs} page for more details.\n */\n dismiss: (options?: DismissOptions) => Promise<void>;\n /**\n * Moves focus to the specified direction (`next`, `prev` or `current` to restore a focus).\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setfocusto|docs} page for more details.\n */\n setFocusTo: (direction: Direction) => void;\n /**\n * Whether the keyboard is fully visible.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#isvisible|docs} page for more details.\n */\n isVisible: () => boolean;\n /**\n * Method that returns current keyboard state.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#state|docs} page for more details.\n */\n state: () => KeyboardEventData;\n};\nexport type KeyboardControllerNativeModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // ios only\n preload: () => void;\n // all platforms\n dismiss: (keepFocus: boolean) => void;\n setFocusTo: (direction: Direction) => void;\n // native event module stuff\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["views.ts"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport type { ViewProps } from \"react-native\";\n\nexport type KeyboardGestureAreaProps = {\n /**\n * Determines how the keyboard position will be controlled:\n * - `ios` - keyboard will be following finger only when finger touches keyboard\n * - `linear` - keyboard will be following finger position linearly.\n *\n * @platform android\n */\n interpolator?: \"ios\" | \"linear\";\n /**\n * Whether to allow to show a keyboard from dismissed state by swipe up.\n * Default to `false`.\n *\n * @platform android\n */\n showOnSwipeUp?: boolean;\n /**\n * Whether to allow to control a keyboard by gestures. The strategy how\n * it should be controlled is determined by `interpolator` property.\n * Defaults to `true`.\n *\n * @platform android\n */\n enableSwipeToDismiss?: boolean;\n /**\n * Extra distance to the keyboard.\n */\n offset?: number;\n /**\n * A corresponding `nativeID` value from the associated `TextInput` (a string that links the `KeyboardGestureArea` to one or more `TextInput` components).\n * This is **required on iOS** in order to apply the `offset` when the keyboard is shown. Only the currently focused `TextInput` with a matching `nativeID`\n * will receive offset behavior.\n *\n * @platform ios\n */\n textInputNativeID?: string;\n} & ViewProps;\nexport type OverKeyboardViewProps = PropsWithChildren<{\n /**\n * A boolean prop indicating whether the view is visible or not. If it's true then view is shown on the screen. If it's false then view is hidden.\n */\n visible: boolean;\n}>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["views.ts"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport type { ViewProps } from \"react-native\";\n\nexport type KeyboardGestureAreaProps = {\n /**\n * Determines how the keyboard position will be controlled:\n * - `ios` - keyboard will be following finger only when finger touches keyboard\n * - `linear` - keyboard will be following finger position linearly.\n *\n * @platform android\n */\n interpolator?: \"ios\" | \"linear\";\n /**\n * Whether to allow to show a keyboard from dismissed state by swipe up.\n * Default to `false`.\n *\n * @platform android\n */\n showOnSwipeUp?: boolean;\n /**\n * Whether to allow to control a keyboard by gestures. The strategy how\n * it should be controlled is determined by `interpolator` property.\n * Defaults to `true`.\n *\n * @platform android\n */\n enableSwipeToDismiss?: boolean;\n /**\n * Extra distance to the keyboard.\n */\n offset?: number;\n /**\n * A corresponding `nativeID` value from the associated `TextInput` (a string that links the `KeyboardGestureArea` to one or more `TextInput` components).\n * This is **required on iOS** in order to apply the `offset` when the keyboard is shown. Only the currently focused `TextInput` with a matching `nativeID`\n * will receive offset behavior.\n *\n * @platform ios\n */\n textInputNativeID?: string;\n} & ViewProps;\nexport type OverKeyboardViewProps = PropsWithChildren<{\n /**\n * A boolean prop indicating whether the view is visible or not. If it's true then view is shown on the screen. If it's false then view is hidden.\n */\n visible: boolean;\n}>;\nexport type KeyboardBackgroundViewProps = PropsWithChildren<ViewProps>;\nexport type KeyboardExtenderProps = PropsWithChildren<{\n /** Controls whether this `KeyboardExtender` instance should take an effect. Default is `true`. */\n enabled: boolean;\n}>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { RCTKeyboardExtender } from "../../bindings";
|
|
4
|
+
import { useWindowDimensions } from "../../hooks";
|
|
5
|
+
/**
|
|
6
|
+
* A component that embeds its children into the keyboard thus enhancing keyboard functionality.
|
|
7
|
+
*
|
|
8
|
+
* @param props - Component props.
|
|
9
|
+
* @returns A view component that renders inside the keyboard above all system buttons.
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <KeyboardExtender>
|
|
13
|
+
* <Button>10$</Button>
|
|
14
|
+
* <Button>20$</Button>
|
|
15
|
+
* <Button>50$</Button>
|
|
16
|
+
* </KeyboardExtender>
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
const KeyboardExtender = props => {
|
|
20
|
+
const {
|
|
21
|
+
children,
|
|
22
|
+
enabled = true
|
|
23
|
+
} = props;
|
|
24
|
+
const {
|
|
25
|
+
width
|
|
26
|
+
} = useWindowDimensions();
|
|
27
|
+
return /*#__PURE__*/React.createElement(RCTKeyboardExtender, {
|
|
28
|
+
enabled: enabled
|
|
29
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
30
|
+
style: {
|
|
31
|
+
width
|
|
32
|
+
}
|
|
33
|
+
}, children));
|
|
34
|
+
};
|
|
35
|
+
export default KeyboardExtender;
|
|
36
|
+
//# sourceMappingURL=index.ios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","View","RCTKeyboardExtender","useWindowDimensions","KeyboardExtender","props","children","enabled","width","createElement","style"],"sources":["index.ios.tsx"],"sourcesContent":["import React from \"react\";\nimport { View } from \"react-native\";\n\nimport { RCTKeyboardExtender } from \"../../bindings\";\nimport { useWindowDimensions } from \"../../hooks\";\n\nimport type { KeyboardExtenderProps } from \"../../types\";\nimport type { PropsWithChildren } from \"react\";\n\n/**\n * A component that embeds its children into the keyboard thus enhancing keyboard functionality.\n *\n * @param props - Component props.\n * @returns A view component that renders inside the keyboard above all system buttons.\n * @example\n * ```tsx\n * <KeyboardExtender>\n * <Button>10$</Button>\n * <Button>20$</Button>\n * <Button>50$</Button>\n * </KeyboardExtender>\n * ```\n */\nconst KeyboardExtender = (props: PropsWithChildren<KeyboardExtenderProps>) => {\n const { children, enabled = true } = props;\n const { width } = useWindowDimensions();\n\n return (\n <RCTKeyboardExtender enabled={enabled}>\n <View style={{ width }}>{children}</View>\n </RCTKeyboardExtender>\n );\n};\n\nexport default KeyboardExtender;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,cAAc;AAEnC,SAASC,mBAAmB,QAAQ,gBAAgB;AACpD,SAASC,mBAAmB,QAAQ,aAAa;AAKjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,gBAAgB,GAAIC,KAA+C,IAAK;EAC5E,MAAM;IAAEC,QAAQ;IAAEC,OAAO,GAAG;EAAK,CAAC,GAAGF,KAAK;EAC1C,MAAM;IAAEG;EAAM,CAAC,GAAGL,mBAAmB,CAAC,CAAC;EAEvC,oBACEH,KAAA,CAAAS,aAAA,CAACP,mBAAmB;IAACK,OAAO,EAAEA;EAAQ,gBACpCP,KAAA,CAAAS,aAAA,CAACR,IAAI;IAACS,KAAK,EAAE;MAAEF;IAAM;EAAE,GAAEF,QAAe,CACrB,CAAC;AAE1B,CAAC;AAED,eAAeF,gBAAgB","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Animated } from "react-native";
|
|
3
|
+
import { KeyboardBackgroundView } from "../../bindings";
|
|
4
|
+
import { KeyboardStickyView } from "../../components";
|
|
5
|
+
import { useKeyboardAnimation } from "../../hooks";
|
|
6
|
+
const AnimatedKeyboardBackgroundView = Animated.createAnimatedComponent(KeyboardBackgroundView);
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A component that embeds its children into the keyboard thus enhancing keyboard functionality.
|
|
10
|
+
*
|
|
11
|
+
* @param props - Component props.
|
|
12
|
+
* @returns A view component that renders inside the keyboard above all system buttons.
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <KeyboardExtender>
|
|
16
|
+
* <Button>10$</Button>
|
|
17
|
+
* <Button>20$</Button>
|
|
18
|
+
* <Button>50$</Button>
|
|
19
|
+
* </KeyboardExtender>
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
const KeyboardExtender = props => {
|
|
23
|
+
const {
|
|
24
|
+
children,
|
|
25
|
+
enabled = true
|
|
26
|
+
} = props;
|
|
27
|
+
const {
|
|
28
|
+
progress
|
|
29
|
+
} = useKeyboardAnimation();
|
|
30
|
+
return /*#__PURE__*/React.createElement(KeyboardStickyView, {
|
|
31
|
+
enabled: enabled
|
|
32
|
+
}, /*#__PURE__*/React.createElement(AnimatedKeyboardBackgroundView, {
|
|
33
|
+
style: {
|
|
34
|
+
opacity: progress
|
|
35
|
+
}
|
|
36
|
+
}, children));
|
|
37
|
+
};
|
|
38
|
+
export default KeyboardExtender;
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","Animated","KeyboardBackgroundView","KeyboardStickyView","useKeyboardAnimation","AnimatedKeyboardBackgroundView","createAnimatedComponent","KeyboardExtender","props","children","enabled","progress","createElement","style","opacity"],"sources":["index.tsx"],"sourcesContent":["import React from \"react\";\nimport { Animated } from \"react-native\";\n\nimport { KeyboardBackgroundView } from \"../../bindings\";\nimport { KeyboardStickyView } from \"../../components\";\nimport { useKeyboardAnimation } from \"../../hooks\";\n\nimport type { KeyboardExtenderProps } from \"../../types\";\nimport type { PropsWithChildren } from \"react\";\n\nconst AnimatedKeyboardBackgroundView = Animated.createAnimatedComponent(\n KeyboardBackgroundView,\n);\n\n/**\n * A component that embeds its children into the keyboard thus enhancing keyboard functionality.\n *\n * @param props - Component props.\n * @returns A view component that renders inside the keyboard above all system buttons.\n * @example\n * ```tsx\n * <KeyboardExtender>\n * <Button>10$</Button>\n * <Button>20$</Button>\n * <Button>50$</Button>\n * </KeyboardExtender>\n * ```\n */\nconst KeyboardExtender = (props: PropsWithChildren<KeyboardExtenderProps>) => {\n const { children, enabled = true } = props;\n const { progress } = useKeyboardAnimation();\n\n return (\n <KeyboardStickyView enabled={enabled}>\n <AnimatedKeyboardBackgroundView style={{ opacity: progress }}>\n {children}\n </AnimatedKeyboardBackgroundView>\n </KeyboardStickyView>\n );\n};\n\nexport default KeyboardExtender;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,QAAQ,cAAc;AAEvC,SAASC,sBAAsB,QAAQ,gBAAgB;AACvD,SAASC,kBAAkB,QAAQ,kBAAkB;AACrD,SAASC,oBAAoB,QAAQ,aAAa;AAKlD,MAAMC,8BAA8B,GAAGJ,QAAQ,CAACK,uBAAuB,CACrEJ,sBACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,gBAAgB,GAAIC,KAA+C,IAAK;EAC5E,MAAM;IAAEC,QAAQ;IAAEC,OAAO,GAAG;EAAK,CAAC,GAAGF,KAAK;EAC1C,MAAM;IAAEG;EAAS,CAAC,GAAGP,oBAAoB,CAAC,CAAC;EAE3C,oBACEJ,KAAA,CAAAY,aAAA,CAACT,kBAAkB;IAACO,OAAO,EAAEA;EAAQ,gBACnCV,KAAA,CAAAY,aAAA,CAACP,8BAA8B;IAACQ,KAAK,EAAE;MAAEC,OAAO,EAAEH;IAAS;EAAE,GAC1DF,QAC6B,CACd,CAAC;AAEzB,CAAC;AAED,eAAeF,gBAAgB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","OverKeyboardView"],"sources":["index.ts"],"sourcesContent":["export { default as OverKeyboardView } from \"./OverKeyboardView\";\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,gBAAgB,QAAQ,oBAAoB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["default","OverKeyboardView","KeyboardExtender"],"sources":["index.ts"],"sourcesContent":["export { default as OverKeyboardView } from \"./OverKeyboardView\";\nexport { default as KeyboardExtender } from \"./KeyboardExtender\";\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,gBAAgB,QAAQ,oBAAoB;AAChE,SAASD,OAAO,IAAIE,gBAAgB,QAAQ,oBAAoB","ignoreList":[]}
|
|
@@ -34,6 +34,13 @@ type KeyboardProviderProps = {
|
|
|
34
34
|
* Defaults to `true`.
|
|
35
35
|
*/
|
|
36
36
|
enabled?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* A boolean prop indicating whether to preload the keyboard to reduce time-to-interaction (TTI) on first input focus.
|
|
39
|
+
* Defaults to `true`.
|
|
40
|
+
*
|
|
41
|
+
* @platform ios
|
|
42
|
+
*/
|
|
43
|
+
preload?: boolean;
|
|
37
44
|
};
|
|
38
45
|
/**
|
|
39
46
|
* A component that wrap your app. Under the hood it works with {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|KeyboardControllerView} to receive events during keyboard movements,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FocusedInputEventsModule, KeyboardControllerNativeModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps, OverKeyboardViewProps, WindowDimensionsEventsModule } from "./types";
|
|
1
|
+
import type { FocusedInputEventsModule, KeyboardBackgroundViewProps, KeyboardControllerNativeModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardExtenderProps, KeyboardGestureAreaProps, OverKeyboardViewProps, WindowDimensionsEventsModule } from "./types";
|
|
2
2
|
export declare const KeyboardControllerNative: KeyboardControllerNativeModule;
|
|
3
3
|
/**
|
|
4
4
|
* An event emitter that provides a way to subscribe to next keyboard events:
|
|
@@ -29,3 +29,16 @@ export declare const KeyboardControllerView: React.FC<KeyboardControllerProps>;
|
|
|
29
29
|
*/
|
|
30
30
|
export declare const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps>;
|
|
31
31
|
export declare const RCTOverKeyboardView: React.FC<OverKeyboardViewProps>;
|
|
32
|
+
/**
|
|
33
|
+
* A view that matches keyboard background.
|
|
34
|
+
*
|
|
35
|
+
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-background-view|Documentation} page for more details.
|
|
36
|
+
*/
|
|
37
|
+
export declare const KeyboardBackgroundView: React.FC<KeyboardBackgroundViewProps>;
|
|
38
|
+
/**
|
|
39
|
+
* A container that will embed its children into the keyboard
|
|
40
|
+
* and will always show them above the keyboard.
|
|
41
|
+
*
|
|
42
|
+
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-extender|Documentation} page for more details.
|
|
43
|
+
*/
|
|
44
|
+
export declare const RCTKeyboardExtender: React.FC<KeyboardExtenderProps>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FocusedInputEventsModule, KeyboardControllerNativeModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps, OverKeyboardViewProps, WindowDimensionsEventsModule } from "./types";
|
|
1
|
+
import type { FocusedInputEventsModule, KeyboardBackgroundViewProps, KeyboardControllerNativeModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardExtenderProps, KeyboardGestureAreaProps, OverKeyboardViewProps, WindowDimensionsEventsModule } from "./types";
|
|
2
2
|
export declare const KeyboardControllerNative: KeyboardControllerNativeModule;
|
|
3
3
|
export declare const KeyboardEvents: KeyboardEventsModule;
|
|
4
4
|
/**
|
|
@@ -10,3 +10,5 @@ export declare const WindowDimensionsEvents: WindowDimensionsEventsModule;
|
|
|
10
10
|
export declare const KeyboardControllerView: React.FC<KeyboardControllerProps>;
|
|
11
11
|
export declare const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps>;
|
|
12
12
|
export declare const RCTOverKeyboardView: React.FC<OverKeyboardViewProps>;
|
|
13
|
+
export declare const KeyboardBackgroundView: React.FC<KeyboardBackgroundViewProps>;
|
|
14
|
+
export declare const RCTKeyboardExtender: React.FC<KeyboardExtenderProps>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { ScrollView, ScrollViewProps } from "react-native";
|
|
3
3
|
export type KeyboardAwareScrollViewProps = {
|
|
4
|
-
/** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */
|
|
4
|
+
/** The distance between the keyboard and the caret inside a focused `TextInput` when the keyboard is shown. Default is `0`. */
|
|
5
5
|
bottomOffset?: number;
|
|
6
6
|
/** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */
|
|
7
7
|
disableScrollOnKeyboardHide?: boolean;
|
|
@@ -30,7 +30,7 @@ export type KeyboardAwareScrollViewProps = {
|
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
declare const KeyboardAwareScrollView: React.ForwardRefExoticComponent<{
|
|
33
|
-
/** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */
|
|
33
|
+
/** The distance between the keyboard and the caret inside a focused `TextInput` when the keyboard is shown. Default is `0`. */
|
|
34
34
|
bottomOffset?: number;
|
|
35
35
|
/** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */
|
|
36
36
|
disableScrollOnKeyboardHide?: boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HEX } from "./types";
|
|
2
|
+
export declare const TEST_ID_KEYBOARD_TOOLBAR = "keyboard.toolbar";
|
|
3
|
+
export declare const TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = "keyboard.toolbar.previous";
|
|
4
|
+
export declare const TEST_ID_KEYBOARD_TOOLBAR_NEXT = "keyboard.toolbar.next";
|
|
5
|
+
export declare const TEST_ID_KEYBOARD_TOOLBAR_CONTENT = "keyboard.toolbar.content";
|
|
6
|
+
export declare const TEST_ID_KEYBOARD_TOOLBAR_DONE = "keyboard.toolbar.done";
|
|
7
|
+
export declare const KEYBOARD_TOOLBAR_HEIGHT = 42;
|
|
8
|
+
export declare const DEFAULT_OPACITY: HEX;
|
|
9
|
+
export declare const KEYBOARD_HAS_ROUNDED_CORNERS: boolean;
|
|
10
|
+
export declare const OPENED_OFFSET: number;
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import type { KeyboardState } from "../../types";
|
|
2
|
+
type KeyboardStateSelector<T> = (state: KeyboardState) => T;
|
|
2
3
|
/**
|
|
3
4
|
* React Hook that represents the current keyboard state on iOS and Android.
|
|
4
5
|
* It tracks keyboard visibility, height, appearance, type and other properties.
|
|
5
6
|
* This hook subscribes to keyboard events and updates the state reactively.
|
|
6
7
|
*
|
|
8
|
+
* @template T - A type of the returned object from the `selector`.
|
|
9
|
+
* @param selector - A function that receives the current keyboard state and picks only necessary properties to avoid frequent re-renders.
|
|
7
10
|
* @returns Object {@link KeyboardState|containing} keyboard state information.
|
|
8
11
|
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-state|Documentation} page for more details.
|
|
9
12
|
* @example
|
|
10
13
|
* ```tsx
|
|
11
14
|
* function MyComponent() {
|
|
12
|
-
* const
|
|
15
|
+
* const isVisible = useKeyboardState((state) => state.isVisible);
|
|
16
|
+
* const height = useKeyboardState((state) => state.height);
|
|
17
|
+
*
|
|
13
18
|
* return (
|
|
14
19
|
* <View>
|
|
15
20
|
* <Text>Keyboard is {isVisible ? 'visible' : 'hidden'}</Text>
|
|
@@ -19,4 +24,5 @@ import type { KeyboardState } from "../../types";
|
|
|
19
24
|
* }
|
|
20
25
|
* ```
|
|
21
26
|
*/
|
|
22
|
-
|
|
27
|
+
declare function useKeyboardState<T = KeyboardState>(selector?: KeyboardStateSelector<T>): T;
|
|
28
|
+
export { useKeyboardState };
|
|
@@ -7,4 +7,4 @@ export * from "./module";
|
|
|
7
7
|
export * from "./types";
|
|
8
8
|
export { KeyboardAvoidingView, KeyboardStickyView, KeyboardAwareScrollView, KeyboardToolbar, DefaultKeyboardToolbarTheme, } from "./components";
|
|
9
9
|
export type { KeyboardAvoidingViewProps, KeyboardStickyViewProps, KeyboardAwareScrollViewProps, KeyboardToolbarProps, } from "./components";
|
|
10
|
-
export { OverKeyboardView } from "./views";
|
|
10
|
+
export { OverKeyboardView, KeyboardExtender } from "./views";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HostComponent } from "react-native";
|
|
2
|
+
import type { ViewProps } from "react-native/Libraries/Components/View/ViewPropTypes";
|
|
3
|
+
export interface NativeProps extends ViewProps {
|
|
4
|
+
}
|
|
5
|
+
declare const _default: HostComponent<NativeProps>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HostComponent } from "react-native";
|
|
2
|
+
import type { ViewProps } from "react-native/Libraries/Components/View/ViewPropTypes";
|
|
3
|
+
export interface NativeProps extends ViewProps {
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare const _default: HostComponent<NativeProps>;
|
|
7
|
+
export default _default;
|
|
@@ -3,6 +3,7 @@ export interface Spec extends TurboModule {
|
|
|
3
3
|
readonly getConstants: () => {};
|
|
4
4
|
setInputMode(mode: number): void;
|
|
5
5
|
setDefaultMode(): void;
|
|
6
|
+
preload(): void;
|
|
6
7
|
dismiss(keepFocus: boolean): void;
|
|
7
8
|
setFocusTo(direction: string): void;
|
|
8
9
|
addListener: (eventName: string) => void;
|
|
@@ -11,8 +11,8 @@ export type KeyboardEventData = {
|
|
|
11
11
|
target: number;
|
|
12
12
|
/** `keyboardType` property from focused `TextInput`. */
|
|
13
13
|
type: NonNullable<TextInputProps["keyboardType"]>;
|
|
14
|
-
/** Keyboard appearance. Can be one of `
|
|
15
|
-
appearance:
|
|
14
|
+
/** Keyboard appearance. Can be one of `dark` or `light`. */
|
|
15
|
+
appearance: "dark" | "light";
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
18
|
* An object that represent current keyboard state.
|
|
@@ -49,13 +49,24 @@ export type KeyboardControllerModule = {
|
|
|
49
49
|
/**
|
|
50
50
|
* Sets default `windowSoftInputMode` (the one that declared in `AndroidManifest.xml`).
|
|
51
51
|
*
|
|
52
|
+
* @platform android
|
|
52
53
|
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setdefaultmode-|docs} page for more details.
|
|
53
54
|
*/
|
|
54
55
|
setDefaultMode: () => void;
|
|
55
56
|
/**
|
|
56
|
-
* Changes `windowSoftInputMode` on Android.
|
|
57
|
+
* Changes `windowSoftInputMode` on Android.
|
|
58
|
+
*
|
|
59
|
+
* @platform android
|
|
60
|
+
* @see AndroidSoftInputModes for all possible values and {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setinputmode-|docs} page for more details.
|
|
57
61
|
*/
|
|
58
62
|
setInputMode: (mode: number) => void;
|
|
63
|
+
/**
|
|
64
|
+
* A method that preloads the keyboard. It's useful when you want to avoid a delay when the user focuses the first input.
|
|
65
|
+
*
|
|
66
|
+
* @platform ios
|
|
67
|
+
* @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#preload-|docs} page for more details.
|
|
68
|
+
*/
|
|
69
|
+
preload: () => void;
|
|
59
70
|
/**
|
|
60
71
|
* Dismisses the active keyboard. Removes a focus by default, but allows to pass `{keepFocus: true}` to keep focus.
|
|
61
72
|
*
|
|
@@ -84,6 +95,7 @@ export type KeyboardControllerModule = {
|
|
|
84
95
|
export type KeyboardControllerNativeModule = {
|
|
85
96
|
setDefaultMode: () => void;
|
|
86
97
|
setInputMode: (mode: number) => void;
|
|
98
|
+
preload: () => void;
|
|
87
99
|
dismiss: (keepFocus: boolean) => void;
|
|
88
100
|
setFocusTo: (direction: Direction) => void;
|
|
89
101
|
addListener: (eventName: string) => void;
|
|
@@ -43,3 +43,8 @@ export type OverKeyboardViewProps = PropsWithChildren<{
|
|
|
43
43
|
*/
|
|
44
44
|
visible: boolean;
|
|
45
45
|
}>;
|
|
46
|
+
export type KeyboardBackgroundViewProps = PropsWithChildren<ViewProps>;
|
|
47
|
+
export type KeyboardExtenderProps = PropsWithChildren<{
|
|
48
|
+
/** Controls whether this `KeyboardExtender` instance should take an effect. Default is `true`. */
|
|
49
|
+
enabled: boolean;
|
|
50
|
+
}>;
|