Skip to content

Commit 00ba46b

Browse files
committed
chore: add jsdoc
1 parent 67a8fbb commit 00ba46b

File tree

1 file changed

+46
-6
lines changed

1 file changed

+46
-6
lines changed

packages/vaul-vue/src/controls.ts

+46-6
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,76 @@ import { usePositionFixed } from './usePositionFixed'
88
import type { DrawerRootContext } from './context'
99
import type { DrawerDirection } from './types'
1010

11-
export interface WithFadeFromProps {
12-
snapPoints: (number | string)[]
13-
fadeFromIndex: number
14-
}
15-
1611
export interface WithoutFadeFromProps {
12+
/**
13+
* Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up.
14+
* Should go from least visible. Example `[0.2, 0.5, 0.8]`.
15+
* You can also use px values, which doesn't take screen height into account.
16+
*/
1717
snapPoints?: (number | string)[]
18+
/**
19+
* Index of a `snapPoint` from which the overlay fade should be applied. Defaults to the last snap point.
20+
*/
1821
fadeFromIndex?: never
1922
}
2023

2124
export type DrawerRootProps = {
2225
activeSnapPoint?: number | string | null
26+
/**
27+
* Number between 0 and 1 that determines when the drawer should be closed.
28+
* Example: threshold of 0.5 would close the drawer if the user swiped for 50% of the height of the drawer or more.
29+
* @default 0.25
30+
*/
2331
closeThreshold?: number
2432
shouldScaleBackground?: boolean
2533
/**
2634
* When `false` we don't change body's background color when the drawer is open.
2735
* @default true
2836
*/
2937
setBackgroundColorOnScale?: boolean
38+
/**
39+
* Duration for which the drawer is not draggable after scrolling content inside of the drawer.
40+
* @default 500ms
41+
*/
3042
scrollLockTimeout?: number
43+
/**
44+
* When `true`, don't move the drawer upwards if there's space, but rather only change it's height so it's fully scrollable when the keyboard is open
45+
*/
3146
fixed?: boolean
47+
/**
48+
* When `false` dragging, clicking outside, pressing esc, etc. will not close the drawer.
49+
* Use this in combination with the `open` prop, otherwise you won't be able to open/close the drawer.
50+
* @default true
51+
*/
3252
dismissible?: boolean
53+
/**
54+
* When `false` it allows to interact with elements outside of the drawer without closing it.
55+
* @default true
56+
*/
3357
modal?: boolean
3458
open?: boolean
59+
/**
60+
* Opened by default, skips initial enter animation. Still reacts to `open` state changes
61+
* @default false
62+
*/
3563
defaultOpen?: boolean
3664
nested?: boolean
65+
/**
66+
* Direction of the drawer. Can be `top` or `bottom`, `left`, `right`.
67+
* @default 'bottom'
68+
*/
3769
direction?: DrawerDirection
3870
/**
3971
* When `true` the `body` doesn't get any styles assigned from Vaul
4072
*/
4173
noBodyStyles?: boolean
74+
/**
75+
* When `true` only allows the drawer to be dragged by the `<Drawer.Handle />` component.
76+
* @default false
77+
*/
4278
handleOnly?: boolean
4379
preventScrollRestoration?: boolean
44-
} & WithFadeFromProps
80+
} & WithoutFadeFromProps
4581

4682
export interface UseDrawerProps {
4783
open: Ref<boolean>
@@ -68,6 +104,10 @@ export interface DrawerRootEmits {
68104
(e: 'close'): void
69105
(e: 'update:open', open: boolean): void
70106
(e: 'update:activeSnapPoint', val: string | number): void
107+
/**
108+
* Gets triggered after the open or close animation ends, it receives an `open` argument with the `open` state of the drawer by the time the function was triggered.
109+
* Useful to revert any state changes for example.
110+
*/
71111
(e: 'animationEnd', open: boolean): void
72112
}
73113

0 commit comments

Comments
 (0)