Skip to content

Commit

Permalink
fix: export component props (#424)
Browse files Browse the repository at this point in the history
## 📜 Description

Exported props for all components, including:
- `KeyboardAvoidingView`;
- `KeyboardStcikyView`;
- `KeyboardAwareScrollView`;
- `KeyboardToolbar`.

## 💡 Motivation and Context

Sometimes people need to wrap components into additional methods (for
example `createBottomSheetScrollableComponent`) and it requires to know
which props component is consuming.

Before devs had to copy/paste the props, but this is not a good from
code duplication and consistency perspective.

So in this PR I'm exporting props for remaining components
(`KeyboardToolbarProps` were already exported).

## 📢 Changelog

### JS

- export props for `KeyboardAvoidingView`;
- export props for `KeyboardStickyView`;
- export props for `KeyboardAwareScrollView`;

## 🤔 How Has This Been Tested?

Tested via CI 😁 

## 📸 Screenshots (if appropriate):

<img width="910" alt="image"
src="https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/cb823852-6d41-484d-8afe-3dc8900f2172">

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
  • Loading branch information
kirillzyusko authored Apr 25, 2024
1 parent a3538f9 commit 6ffa49d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/components/KeyboardAvoidingView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useKeyboardAnimation } from "./hooks";

import type { LayoutRectangle, ViewProps } from "react-native";

type Props = {
export type KeyboardAvoidingViewProps = {
/**
* Specify how to react to the presence of the keyboard.
*/
Expand Down Expand Up @@ -47,7 +47,10 @@ const defaultLayout: LayoutRectangle = {
* View that moves out of the way when the keyboard appears by automatically
* adjusting its height, position, or bottom padding.
*/
const KeyboardAvoidingView = forwardRef<View, React.PropsWithChildren<Props>>(
const KeyboardAvoidingView = forwardRef<
View,
React.PropsWithChildren<KeyboardAvoidingViewProps>
>(
(
{
behavior,
Expand Down
2 changes: 1 addition & 1 deletion src/components/KeyboardAwareScrollView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import type {
} from "react-native";
import type { FocusedInputLayoutChangedEvent } from "react-native-keyboard-controller";

type KeyboardAwareScrollViewProps = {
export type KeyboardAwareScrollViewProps = {
/** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */
bottomOffset?: number;
/** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */
Expand Down
2 changes: 1 addition & 1 deletion src/components/KeyboardStickyView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useReanimatedKeyboardAnimation } from "react-native-keyboard-controller

import type { View, ViewProps } from "react-native";

type KeyboardStickyViewProps = {
export type KeyboardStickyViewProps = {
/**
* Specify additional offset to the view for given keyboard state.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ export {
default as KeyboardToolbar,
DefaultKeyboardToolbarTheme,
} from "./KeyboardToolbar";
export type { KeyboardAvoidingViewProps } from "./KeyboardAvoidingView";
export type { KeyboardStickyViewProps } from "./KeyboardStickyView";
export type { KeyboardAwareScrollViewProps } from "./KeyboardAwareScrollView";
export type { KeyboardToolbarProps } from "./KeyboardToolbar";
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ export {
KeyboardToolbar,
DefaultKeyboardToolbarTheme,
} from "./components";
export type { KeyboardToolbarProps } from "./components";
export type {
KeyboardAvoidingViewProps,
KeyboardStickyViewProps,
KeyboardAwareScrollViewProps,
KeyboardToolbarProps,
} from "./components";

0 comments on commit 6ffa49d

Please sign in to comment.