Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: export prop/emit types #31

Merged
merged 2 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions packages/vaul-vue/src/DrawerContent.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, useAttrs, watch } from 'vue'
import { computed, watch } from 'vue'
import { DialogContent } from 'radix-vue'
import { injectDrawerRootContext } from './context'

Expand All @@ -18,8 +18,6 @@ const {
closeDrawer,
} = injectDrawerRootContext()

const attrs = useAttrs()

const snapPointHeight = computed(() => {
if (snapPointsOffset.value && snapPointsOffset.value.length > 0)
return `${snapPointsOffset.value[0]}px`
Expand Down Expand Up @@ -60,7 +58,7 @@ watch(
ref="drawerRef"
vaul-drawer=""
:vaul-drawer-visible="isVisible ? 'true' : 'false'"
:style="[attrs.style, { '--snap-point-height': snapPointHeight }]"
:style="{ '--snap-point-height': snapPointHeight }"
@pointerdown="onPress"
@pointermove="onDrag"
@pointerup="onRelease"
Expand Down
8 changes: 4 additions & 4 deletions packages/vaul-vue/src/DrawerRoot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { type WritableComputedRef, computed, toRefs } from 'vue'
import { provideDrawerRootContext } from './context'
import {
CLOSE_THRESHOLD,
type DialogEmits,
type DialogProps,
type DrawerRootEmits,
type DrawerRootProps,
SCROLL_LOCK_TIMEOUT,
useDrawer,
} from './controls'

const props = withDefaults(defineProps<DialogProps>(), {
const props = withDefaults(defineProps<DrawerRootProps>(), {
open: undefined,
fixed: undefined,
dismissible: true,
Expand All @@ -25,7 +25,7 @@ const props = withDefaults(defineProps<DialogProps>(), {
scrollLockTimeout: SCROLL_LOCK_TIMEOUT,
})

const emit = defineEmits<DialogEmits>()
const emit = defineEmits<DrawerRootEmits>()

const fadeFromIndex = computed(() => props.fadeFromIndex ?? (props.snapPoints && props.snapPoints.length - 1))

Expand Down
6 changes: 3 additions & 3 deletions packages/vaul-vue/src/DrawerRootNested.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script setup lang="ts">
import { useForwardPropsEmits } from 'radix-vue'
import DrawerRoot from './DrawerRoot.vue'
import type { DialogEmits, DialogProps } from './controls'
import type { DrawerRootEmits, DrawerRootProps } from './controls'
import { injectDrawerRootContext } from './context'

const props = defineProps<DialogProps>()
const emits = defineEmits<DialogEmits>()
const props = defineProps<DrawerRootProps>()
const emits = defineEmits<DrawerRootEmits>()

const { onNestedDrag, onNestedOpenChange, onNestedRelease } = injectDrawerRootContext()
function onClose() {
Expand Down
4 changes: 2 additions & 2 deletions packages/vaul-vue/src/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface WithoutFadeFromProps {
fadeFromIndex?: never
}

export type DialogProps = {
export type DrawerRootProps = {
activeSnapPoint?: number | string | null
closeThreshold?: number
shouldScaleBackground?: boolean
Expand All @@ -55,7 +55,7 @@ export interface UseDrawerProps {
scrollLockTimeout: Ref<number>
}

export interface DialogEmits {
export interface DrawerRootEmits {
(e: 'drag', percentageDragged: number): void
(e: 'release', open: boolean): void
(e: 'close'): void
Expand Down
34 changes: 22 additions & 12 deletions packages/vaul-vue/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
import {
DialogClose as DrawerClose,
DialogDescription as DrawerDescription,
DialogPortal as DrawerPortal,
DialogTitle as DrawerTitle,
DialogTrigger as DrawerTrigger,
} from 'radix-vue'
import DrawerRoot from './DrawerRoot.vue'
import DrawerRootNested from './DrawerRootNested.vue'
import DrawerOverlay from './DrawerOverlay.vue'
import DrawerContent from './DrawerContent.vue'

export type {
DrawerRootEmits,
DrawerRootProps,
} from './controls'

export {
DrawerTitle,
DrawerDescription,
DrawerTrigger,
DrawerPortal,
DrawerClose,
DrawerRoot,
DrawerRootNested,
DrawerOverlay,
DrawerContent,
}

export {
DialogClose as DrawerClose,
type DialogCloseProps as DrawerCloseProps,

DialogDescription as DrawerDescription,
type DialogDescriptionProps as DrawerDescriptionProps,

DialogPortal as DrawerPortal,
type DialogPortalProps as DrawerPortalProps,

DialogTitle as DrawerTitle,
type DialogTitleProps as DrawerTitleProps,

DialogTrigger as DrawerTrigger,
type DialogTriggerProps as DrawerTriggerProps,
} from 'radix-vue'
Loading