Skip to content

Commit f30acc1

Browse files
brentvatneosdnk
authored andcommitted
Add TypeScript types (#4)
* Add some basic TypeScript types * Add snapTo to types * Add Reanimated as development dependency for types
1 parent 8d3d7e9 commit f30acc1

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed

package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
21
{
32
"name": "reanimated-bottom-sheet",
43
"version": "1.0.0-alpha.1",
54
"description": "Bottom sheet component",
65
"main": "index.js",
6+
"types": "reanimated-bottom-sheet.d.ts",
77
"scripts": {
88
"test": "echo \"Error: no test specified\" && exit 1"
99
},
@@ -14,7 +14,11 @@
1414
"gesture",
1515
"handler"
1616
],
17-
"files": ["index.js, README.md"],
17+
"files": [
18+
"index.js",
19+
"reanimated-bottom-sheet.d.ts",
20+
"README.md"
21+
],
1822
"author": "Michał Osadnik",
1923
"repository": {
2024
"type": "git",
@@ -25,12 +29,13 @@
2529
"peerDependencies": {
2630
"react": "*",
2731
"react-native": "*",
28-
"react-native-reanimated": "*",
29-
"react-native-gesture-handler": "*"
32+
"react-native-gesture-handler": "*",
33+
"react-native-reanimated": "*"
3034
},
3135
"devDependencies": {
3236
"babel-eslint": "^10.0.1",
3337
"eslint": "^5.15.1",
34-
"eslint-plugin-react": "^7.12.4"
38+
"eslint-plugin-react": "^7.12.4",
39+
"react-native-reanimated": "^1.0.0-alpha.12"
3540
}
3641
}

reanimated-bottom-sheet.d.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
declare module 'reanimated-bottom-sheet' {
2+
import * as React from 'react';
3+
import Animated from 'react-native-reanimated';
4+
5+
interface BottomSheetProps {
6+
/** Points for snapping of bottom sheet component. They define distance from bottom of the screen. Might be number or percent (as string e.g. '20%') for points or percents of screen height from bottom. */
7+
snapPoints: number[];
8+
9+
/** Determines initial snap point of bottom sheet. Defaults to 0. */
10+
initialSnap?: number;
11+
12+
/** Method for rendering scrollable content of bottom sheet. */
13+
renderContent?: () => React.ReactElement | null;
14+
15+
/** Method for rendering non-scrollable header of bottom sheet. */
16+
renderHeader?: () => React.ReactElement | null;
17+
18+
/** Defines if bottom sheet could be scrollable by gesture. Defaults to true. */
19+
enabledGestureInteraction?: boolean;
20+
21+
/** If false blocks snapping using snapTo method. Defaults to true */
22+
enabledManualSnapping?: boolean;
23+
24+
/** Defines whether it's possible to scroll inner content of bottom sheet. Defaults to true. */
25+
enabledInnerScrolling?: boolean;
26+
27+
/** Reanimated node which holds position of bottom sheet, where 1 it the highest snap point and 0 is the lowest. */
28+
callbackNode?: Animated.Node<any>;
29+
}
30+
31+
export default class BottomSheet extends React.Component<BottomSheetProps> {
32+
/** Snap to the snap point at index (e.g. index 0 is 450 in [450, 300, 0]) */
33+
snapTo: (index: number) => void;
34+
}
35+
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,11 @@ react-is@^16.8.1:
822822
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.4.tgz#90f336a68c3a29a096a3d648ab80e87ec61482a2"
823823
integrity sha512-PVadd+WaUDOAciICm/J1waJaSvgq+4rHE/K70j0PFqKhkTBsPv/82UGQJNXAngz1fOQLLxI6z1sEDmJDQhCTAA==
824824

825+
react-native-reanimated@^1.0.0-alpha.12:
826+
version "1.0.0-alpha.12"
827+
resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-1.0.0-alpha.12.tgz#535c84a9e87c919417aee0fa68f360b3bb9556b0"
828+
integrity sha512-jZDPxz8IjpoZ7VAW5X6WJhemmpuLkX6Y9lxKuHJAXls1EwRYkyXIPwvSG34umeqqYSE8Hl3A5TS4pfLORoqm/A==
829+
825830
regexpp@^2.0.1:
826831
version "2.0.1"
827832
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f"

0 commit comments

Comments
 (0)