Skip to content

Commit ffbf841

Browse files
authored
Merge pull request #5 from iway1/improvement/type-declarations
Added type declarations (for vanilla JS projects)
2 parents 1b98084 + ff070c4 commit ffbf841

12 files changed

+114
-0
lines changed

commit-and-push

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tsc -p package/tsconfig.json
2+
git add .
3+
read -p "Enter a commit message (no quotes): " commitMessage
4+
git commit -m "$commitMessage"
5+
git push

package/tsconfig.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions": {
3+
"declaration": true,
4+
"emitDeclarationOnly": true,
5+
"outDir": "types",
6+
"jsx": "react-native",
7+
"esModuleInterop": true
8+
},
9+
}

package/types/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export { default as KeyboardAvoiderInsets } from './src/components/KeyboardAvoiderInsets';
2+
export { default as KeyboardAvoiderView } from './src/components/KeyboardAvoiderView';
3+
export { default as KeyboardAvoiderScrollView } from './src/components/KeyboardAvoiderScrollView';
4+
export { default as KeyboardAvoiderScrollSection } from './src/components/KeyboardAvoiderScrollSection';
5+
export { default as KeyboardAvoiderProvider } from './src/components/KeyboardAvoiderProvider';
6+
export { useAppHeight } from './src/components/KeyboardAvoiderProvider';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference types="react" />
2+
import { CommonProps } from "./common-props";
3+
export default function KeyboardAvoiderInsets({ animationEasing, animationTime, extraSpace }: CommonProps): JSX.Element;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { ReactNode } from "react";
2+
export default function KeyboardAvoiderProvider({ children, }: {
3+
children: ReactNode;
4+
}): JSX.Element;
5+
export declare function useAppHeight(): {
6+
appHeight: number;
7+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference types="react" />
2+
import { ViewProps } from "react-native";
3+
export default function KeyboardAvoiderScrollSection(props: Omit<ViewProps, 'collapsable'>): JSX.Element;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// <reference types="react" />
2+
import { ScrollViewProps, View } from "react-native";
3+
import { CommonProps } from "./common-props";
4+
declare type Props = ScrollViewProps & CommonProps & {
5+
/**
6+
* What to do when the keyboard hides on iOS.
7+
* @option 'stay' - *Default* scroll view will not move when the keyboard hides (it will stay where it is.)
8+
* @option 'revert' - Scroll view will return to its original position when the keyboard hides.
9+
*/
10+
iosHideBehavior?: 'stay' | 'revert';
11+
};
12+
export default function KeyboardAvoiderScrollView({ animationEasing, animationTime, extraSpace, iosHideBehavior, ...props }: Props): JSX.Element;
13+
export declare function useScrollViewContext(): {
14+
registerView: ({ view, id, }: {
15+
view: View;
16+
id: string;
17+
}) => void;
18+
unregisterView: (id: string) => void;
19+
};
20+
export {};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/// <reference types="react" />
2+
import { ViewProps } from 'react-native';
3+
import Animated from 'react-native-reanimated';
4+
import { CommonProps } from './common-props';
5+
export declare type KeyboardAvoidMode = 'whole-view' | 'focused-input';
6+
export default function KeyboardAvoiderView({ animationEasing, animationTime, extraSpace, enableAndroid, avoidMode, ...props }: Animated.AnimateProps<ViewProps> & CommonProps & {
7+
/**
8+
* Enable on android. Defaults to true to ensure consistent behavior.
9+
*/
10+
enableAndroid?: boolean;
11+
/**
12+
* Sets the avoid mode. Defaults to 'whole-view'.
13+
* @option 'whole-view' - view moves to show the entire view when the keyboard is shown.
14+
* @option 'focused-input' - view moves to show only the focused text input.
15+
*/
16+
avoidMode?: KeyboardAvoidMode;
17+
}): JSX.Element;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Animated from "react-native-reanimated";
2+
export declare type CommonProps = {
3+
/**
4+
* Duration of the keyboard avoiding animation.
5+
*/
6+
animationTime?: number;
7+
/**
8+
* Extra space between the keyboard avoiding element and the keyboard.
9+
*/
10+
extraSpace?: number;
11+
/**
12+
* Easing function to use. Can be any `react-native-reanimated` easing function. Defaults to Easing.quad.
13+
* Open animation will use Easing.out(animationEasing), close animation will use Easing.in(animationEasing).
14+
*/
15+
animationEasing?: Animated.EasingFunction;
16+
};
17+
export declare const defaultCommonProps: {
18+
animationTime: number;
19+
animationEasing: Animated.EasingFunction;
20+
extraSpace: number;
21+
};

package/types/src/defaults.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

0 commit comments

Comments
 (0)