Skip to content

Commit a8102bf

Browse files
committed
fix: improve TS definitions
1 parent aef7d95 commit a8102bf

File tree

1 file changed

+36
-13
lines changed

1 file changed

+36
-13
lines changed

src/types.ts

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
export type SnapPointProps = {
2-
/** The height of the sticky footer, if there's one */
2+
/**
3+
* The height of the sticky header, if there's one
4+
*/
35
headerHeight: number
4-
/** The height of the sticky footer, if there's one */
6+
/**
7+
* The height of the sticky footer, if there's one
8+
*/
59
footerHeight: number
6-
/** If the bottom sheet is animating to a snap point the height will match the destination height, not the height the bottom sheet might have in the middle of the animation. It includes the header and footer heights. */
10+
/**
11+
* If the bottom sheet is animating to a snap point the height will match the destination height, not the height the bottom sheet might have in the middle of the animation. It includes the header and footer heights.
12+
*/
713
height: number
8-
/** Minimum height needed to avoid scroll overflow in the content area, if possible. */
14+
/**
15+
* Minimum height needed to avoid scroll overflow in the content area, if possible.
16+
*/
917
minHeight: number
10-
/** Max height the sheet can be, your snap points are capped to this value. It's window.innerHeight by default but can be overriden using the maxHeight prop. */
18+
/**
19+
* Max height the sheet can be, your snap points are capped to this value. It's window.innerHeight by default but can be overriden using the maxHeight prop.
20+
*/
1121
maxHeight: number
1222
}
1323

@@ -20,14 +30,15 @@ export type defaultSnapProps = {
2030
lastSnap: number | null
2131
} & SnapPointProps
2232

23-
type defaultSnap = (props: defaultSnapProps) => number
24-
2533
/* Might make sense to expose a preventDefault method here */
2634
export type SpringEvent = {
2735
type: 'OPEN' | 'CLOSE' | 'RESIZE' | 'SNAP'
2836
}
2937

3038
export type Props = {
39+
/**
40+
* Ensure that whatever you put in here have at least 1px height, or else the bottom sheet won't open
41+
*/
3142
children: React.ReactNode
3243

3344
/**
@@ -69,6 +80,7 @@ export type Props = {
6980

7081
/**
7182
* Renders below the drag handle, set to `false` to disable the drag handle
83+
* @default true
7284
*/
7385
header?: React.ReactNode | false
7486

@@ -99,24 +111,35 @@ export type Props = {
99111
*/
100112
scrollLocking?: boolean
101113

102-
/** Handler that is called to get the height values that the bottom sheet can *snap* to when the user stops dragging. */
114+
/**
115+
* Handler that is called to get the height values that the bottom sheet can *snap* to when the user stops dragging.
116+
* @default ({ minHeight }) => minHeight
117+
*/
103118
snapPoints?: snapPoints
104119

105-
/** Handler that is called to get the initial height of the bottom sheet when it's opened (or when the viewport is resized). */
106-
defaultSnap?: defaultSnap | number
120+
/**
121+
* Handler that is called to get the initial height of the bottom sheet when it's opened (or when the viewport is resized).
122+
* @default ({ snapPoints, lastSnap }) => lastSnap ?? Math.min(...snapPoints)
123+
*/
124+
defaultSnap?: (props: defaultSnapProps) => number | number
107125

108-
/* Configures body-scroll-lock to reserve scrollbar gap by setting padding on <body>, clears when closing the bottom sheet. on by default iff blocking=true */
126+
/**
127+
* Configures body-scroll-lock to reserve scrollbar gap by setting padding on <body>, clears when closing the bottom sheet.
128+
* If blocking is true, then reserveScrollBarGap is true by default
129+
* @default blocking === true
130+
*/
109131
reserveScrollBarGap?: boolean
110132

111-
/* Open immediatly instead of initially animating from a closed => open state, useful if the bottom sheet is visible by default and the animation would be distracting */
133+
/**
134+
* Open immediatly instead of initially animating from a closed => open state, useful if the bottom sheet is visible by default and the animation would be distracting
135+
*/
112136
skipInitialTransition?: boolean
113137
} & Omit<React.PropsWithoutRef<JSX.IntrinsicElements['div']>, 'children'>
114138

115139
export interface RefHandles {
116140
/**
117141
* When given a number it'll find the closest snap point, so you don't need to know the exact value,
118142
* Use the callback method to access what snap points you can choose from.
119-
*
120143
*/
121144
snapTo: (
122145
numberOrCallback: number | ((state: defaultSnapProps) => number)

0 commit comments

Comments
 (0)