Skip to content

Commit 32005d8

Browse files
authoredMar 2, 2024··
feat: export prop/emit types (#31)
* chore: rename prop/emit * chore: export prop/emit types
1 parent 6b6b359 commit 32005d8

File tree

5 files changed

+33
-25
lines changed

5 files changed

+33
-25
lines changed
 

‎packages/vaul-vue/src/DrawerContent.vue

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { computed, useAttrs, watch } from 'vue'
2+
import { computed, watch } from 'vue'
33
import { DialogContent } from 'radix-vue'
44
import { injectDrawerRootContext } from './context'
55
@@ -18,8 +18,6 @@ const {
1818
closeDrawer,
1919
} = injectDrawerRootContext()
2020
21-
const attrs = useAttrs()
22-
2321
const snapPointHeight = computed(() => {
2422
if (snapPointsOffset.value && snapPointsOffset.value.length > 0)
2523
return `${snapPointsOffset.value[0]}px`
@@ -60,7 +58,7 @@ watch(
6058
ref="drawerRef"
6159
vaul-drawer=""
6260
:vaul-drawer-visible="isVisible ? 'true' : 'false'"
63-
:style="[attrs.style, { '--snap-point-height': snapPointHeight }]"
61+
:style="{ '--snap-point-height': snapPointHeight }"
6462
@pointerdown="onPress"
6563
@pointermove="onDrag"
6664
@pointerup="onRelease"

‎packages/vaul-vue/src/DrawerRoot.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { type WritableComputedRef, computed, toRefs } from 'vue'
55
import { provideDrawerRootContext } from './context'
66
import {
77
CLOSE_THRESHOLD,
8-
type DialogEmits,
9-
type DialogProps,
8+
type DrawerRootEmits,
9+
type DrawerRootProps,
1010
SCROLL_LOCK_TIMEOUT,
1111
useDrawer,
1212
} from './controls'
1313
14-
const props = withDefaults(defineProps<DialogProps>(), {
14+
const props = withDefaults(defineProps<DrawerRootProps>(), {
1515
open: undefined,
1616
fixed: undefined,
1717
dismissible: true,
@@ -25,7 +25,7 @@ const props = withDefaults(defineProps<DialogProps>(), {
2525
scrollLockTimeout: SCROLL_LOCK_TIMEOUT,
2626
})
2727
28-
const emit = defineEmits<DialogEmits>()
28+
const emit = defineEmits<DrawerRootEmits>()
2929
3030
const fadeFromIndex = computed(() => props.fadeFromIndex ?? (props.snapPoints && props.snapPoints.length - 1))
3131

‎packages/vaul-vue/src/DrawerRootNested.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<script setup lang="ts">
22
import { useForwardPropsEmits } from 'radix-vue'
33
import DrawerRoot from './DrawerRoot.vue'
4-
import type { DialogEmits, DialogProps } from './controls'
4+
import type { DrawerRootEmits, DrawerRootProps } from './controls'
55
import { injectDrawerRootContext } from './context'
66
7-
const props = defineProps<DialogProps>()
8-
const emits = defineEmits<DialogEmits>()
7+
const props = defineProps<DrawerRootProps>()
8+
const emits = defineEmits<DrawerRootEmits>()
99
1010
const { onNestedDrag, onNestedOpenChange, onNestedRelease } = injectDrawerRootContext()
1111
function onClose() {

‎packages/vaul-vue/src/controls.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export interface WithoutFadeFromProps {
2828
fadeFromIndex?: never
2929
}
3030

31-
export type DialogProps = {
31+
export type DrawerRootProps = {
3232
activeSnapPoint?: number | string | null
3333
closeThreshold?: number
3434
shouldScaleBackground?: boolean
@@ -55,7 +55,7 @@ export interface UseDrawerProps {
5555
scrollLockTimeout: Ref<number>
5656
}
5757

58-
export interface DialogEmits {
58+
export interface DrawerRootEmits {
5959
(e: 'drag', percentageDragged: number): void
6060
(e: 'release', open: boolean): void
6161
(e: 'close'): void

‎packages/vaul-vue/src/index.ts

+22-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
1-
import {
2-
DialogClose as DrawerClose,
3-
DialogDescription as DrawerDescription,
4-
DialogPortal as DrawerPortal,
5-
DialogTitle as DrawerTitle,
6-
DialogTrigger as DrawerTrigger,
7-
} from 'radix-vue'
81
import DrawerRoot from './DrawerRoot.vue'
92
import DrawerRootNested from './DrawerRootNested.vue'
103
import DrawerOverlay from './DrawerOverlay.vue'
114
import DrawerContent from './DrawerContent.vue'
125

6+
export type {
7+
DrawerRootEmits,
8+
DrawerRootProps,
9+
} from './controls'
10+
1311
export {
14-
DrawerTitle,
15-
DrawerDescription,
16-
DrawerTrigger,
17-
DrawerPortal,
18-
DrawerClose,
1912
DrawerRoot,
2013
DrawerRootNested,
2114
DrawerOverlay,
2215
DrawerContent,
2316
}
17+
18+
export {
19+
DialogClose as DrawerClose,
20+
type DialogCloseProps as DrawerCloseProps,
21+
22+
DialogDescription as DrawerDescription,
23+
type DialogDescriptionProps as DrawerDescriptionProps,
24+
25+
DialogPortal as DrawerPortal,
26+
type DialogPortalProps as DrawerPortalProps,
27+
28+
DialogTitle as DrawerTitle,
29+
type DialogTitleProps as DrawerTitleProps,
30+
31+
DialogTrigger as DrawerTrigger,
32+
type DialogTriggerProps as DrawerTriggerProps,
33+
} from 'radix-vue'

0 commit comments

Comments
 (0)
Please sign in to comment.