Skip to content

Commit f401766

Browse files
committedMar 20, 2025·
chore(deps): update vaul-vue
1 parent 70f469b commit f401766

File tree

13 files changed

+184
-250
lines changed

13 files changed

+184
-250
lines changed
 

‎docs/content/3.components/drawer.md

+30-4
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,31 @@ slots:
166166
:placeholder{class="h-48 m-4"}
167167
::
168168

169+
### Handle Only
170+
171+
Use the `handle-only` prop to only allow the Drawer to be dragged by the handle.
172+
173+
::component-code
174+
---
175+
prettier: true
176+
props:
177+
handleOnly: true
178+
slots:
179+
default: |
180+
181+
<UButton label="Open" color="neutral" variant="subtle" trailing-icon="i-lucide-chevron-up" />
182+
183+
content: |
184+
185+
<Placeholder class="h-48 m-4" />
186+
---
187+
188+
:u-button{label="Open" color="neutral" variant="subtle" trailing-icon="i-lucide-chevron-up"}
189+
190+
#content
191+
:placeholder{class="h-48 m-4"}
192+
::
193+
169194
### Overlay
170195

171196
Use the `overlay` prop to control whether the Drawer has an overlay or not. Defaults to `true`.
@@ -193,13 +218,14 @@ slots:
193218

194219
### Scale background
195220

196-
Use the `should-scale-background` prop to scale the background when the Drawer is open, creating a visual depth effect.
221+
Use the `should-scale-background` prop to scale the background when the Drawer is open, creating a visual depth effect. You can set the `set-background-color-on-scale` prop to `false` to prevent changing the background color.
197222

198223
::component-code
199224
---
200225
prettier: true
201226
props:
202227
shouldScaleBackground: true
228+
setBackgroundColorOnScale: true
203229
slots:
204230
default: |
205231

@@ -217,12 +243,12 @@ slots:
217243
::
218244

219245
::warning
220-
Make sure to add the `vaul-drawer-wrapper` directive to a parent element of your app to make this work.
246+
Make sure to add the `data-vaul-drawer-wrapper` directive to a parent element of your app to make this work.
221247

222248
```vue [app.vue]
223249
<template>
224250
<UApp>
225-
<div class="bg-(--ui-bg)" vaul-drawer-wrapper>
251+
<div class="bg-(--ui-bg)" data-vaul-drawer-wrapper>
226252
<NuxtLayout>
227253
<NuxtPage />
228254
</NuxtLayout>
@@ -235,7 +261,7 @@ Make sure to add the `vaul-drawer-wrapper` directive to a parent element of your
235261
export default defineNuxtConfig({
236262
app: {
237263
rootAttrs: {
238-
'vaul-drawer-wrapper': '',
264+
'data-vaul-drawer-wrapper': '',
239265
'class': 'bg-(--ui-bg)'
240266
}
241267
}

‎docs/nuxt.config.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ export default defineNuxtConfig({
5555
}]
5656
},
5757
rootAttrs: {
58-
// @ts-expect-error - vaul-drawer-wrapper is not typed
59-
'vaul-drawer-wrapper': '',
58+
'data-vaul-drawer-wrapper': '',
6059
'class': 'bg-(--ui-bg)'
6160
}
6261
},

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
"unplugin": "^2.2.1",
117117
"unplugin-auto-import": "^19.1.1",
118118
"unplugin-vue-components": "^28.4.1",
119-
"vaul-vue": "^0.3.0",
119+
"vaul-vue": "^0.4.1",
120120
"vue": "^3.5.13",
121121
"vue-router": "^4.5.0"
122122
},

‎playground-vue/src/app.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ defineShortcuts({
8484

8585
<template>
8686
<UApp :toaster="(appConfig.toaster as any)">
87-
<div class="h-screen w-screen overflow-hidden flex min-h-0 bg-(--ui-bg)" vaul-drawer-wrapper>
87+
<div class="h-screen w-screen overflow-hidden flex min-h-0 bg-(--ui-bg)" data-vaul-drawer-wrapper>
8888
<UNavigationMenu :items="items" orientation="vertical" class="hidden lg:flex border-e border-(--ui-border) overflow-y-auto w-48 p-4" />
8989
<UNavigationMenu :items="items" orientation="horizontal" class="lg:hidden border-b border-(--ui-border) [&>div]:min-w-min overflow-x-auto" />
9090

‎playground/app/app.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ defineShortcuts({
8585
<template>
8686
<template v-if="!$route.path.startsWith('/__nuxt_ui__')">
8787
<UApp :toaster="appConfig.toaster">
88-
<div class="h-screen w-screen overflow-hidden flex flex-col lg:flex-row min-h-0 bg-(--ui-bg)" vaul-drawer-wrapper>
88+
<div class="h-screen w-screen overflow-hidden flex flex-col lg:flex-row min-h-0 bg-(--ui-bg)" data-vaul-drawer-wrapper>
8989
<UNavigationMenu :items="items" orientation="vertical" class="hidden lg:flex border-e border-(--ui-border) overflow-y-auto w-48 p-4" />
9090
<UNavigationMenu :items="items" orientation="horizontal" class="lg:hidden border-b border-(--ui-border) [&>div]:min-w-min overflow-x-auto" />
9191

‎playground/app/pages/components/drawer.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,39 @@ const inset = ref(false)
2020
</template>
2121
</UDrawer>
2222

23-
<UDrawer should-scale-background title="Drawer with `should-scale-background`" description="You need to add the `vaul-drawer-wrapper` directive to your content to make it work." :inset="inset">
23+
<UDrawer should-scale-background title="Drawer with `should-scale-background`" description="You need to add the `data-vaul-drawer-wrapper` directive to your content to make it work." :inset="inset">
2424
<UButton color="neutral" variant="outline" label="Open with scale" />
2525

2626
<template #body>
2727
<Placeholder class="h-screen w-full" />
2828
</template>
2929
</UDrawer>
3030

31-
<UDrawer title="Drawer with bottom direction" direction="bottom" :handle="false" :inset="inset">
31+
<UDrawer title="Drawer with bottom direction" direction="bottom" :inset="inset">
3232
<UButton color="neutral" variant="outline" label="Open on bottom" />
3333

3434
<template #body>
3535
<Placeholder class="h-96 w-full" />
3636
</template>
3737
</UDrawer>
3838

39-
<UDrawer title="Drawer with left direction" direction="left" :handle="false" :inset="inset">
39+
<UDrawer title="Drawer with left direction" direction="left" :inset="inset">
4040
<UButton color="neutral" variant="outline" label="Open on left" />
4141

4242
<template #body>
4343
<Placeholder class="w-96 h-full" />
4444
</template>
4545
</UDrawer>
4646

47-
<UDrawer title="Drawer with top direction" direction="top" :handle="false" :inset="inset">
47+
<UDrawer title="Drawer with top direction" direction="top" :inset="inset">
4848
<UButton color="neutral" variant="outline" label="Open on top" />
4949

5050
<template #body>
5151
<Placeholder class="h-96 w-full" />
5252
</template>
5353
</UDrawer>
5454

55-
<UDrawer title="Drawer with right direction" direction="right" :handle="false" :inset="inset">
55+
<UDrawer title="Drawer with right direction" direction="right" :inset="inset">
5656
<UButton color="neutral" variant="outline" label="Open on right" />
5757

5858
<template #body>

‎pnpm-lock.yaml

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎renovate.json

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
},
88
"ignoreDeps": [
99
"typescript",
10-
"vaul-vue",
1110
"vue-tsc"
1211
],
1312
"baseBranches": ["v2", "v3"],

‎src/runtime/components/Drawer.vue

+9-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const appConfigDrawer = _appConfig as AppConfig & { ui: { drawer: Partial<typeof
1111
1212
const drawer = tv({ extend: tv(theme), ...(appConfigDrawer.ui?.drawer || {}) })
1313
14-
export interface DrawerProps extends Pick<DrawerRootProps, 'activeSnapPoint' | 'closeThreshold' | 'defaultOpen' | 'direction' | 'fadeFromIndex' | 'fixed' | 'modal' | 'nested' | 'direction' | 'open' | 'scrollLockTimeout' | 'shouldScaleBackground' | 'snapPoints'> {
14+
export interface DrawerProps extends Pick<DrawerRootProps, 'activeSnapPoint' | 'closeThreshold' | 'shouldScaleBackground' | 'setBackgroundColorOnScale' | 'scrollLockTimeout' | 'fixed' | 'dismissible' | 'modal' | 'open' | 'defaultOpen' | 'nested' | 'direction' | 'noBodyStyles' | 'handleOnly' | 'preventScrollRestoration' | 'snapPoints'> {
1515
/**
1616
* The element or component this component should render as.
1717
* @defaultValue 'div'
@@ -42,10 +42,9 @@ export interface DrawerProps extends Pick<DrawerRootProps, 'activeSnapPoint' | '
4242
*/
4343
portal?: boolean
4444
/**
45-
* When `false`, the drawer will not close when clicking outside or pressing escape.
46-
* @defaultValue true
45+
* Index of a `snapPoint` from which the overlay fade should be applied. Defaults to the last snap point.
4746
*/
48-
dismissible?: boolean
47+
fadeFromIndex?: any
4948
class?: any
5049
ui?: Partial<typeof drawer.slots>
5150
}
@@ -54,7 +53,6 @@ export interface DrawerEmits extends DrawerRootEmits {}
5453
5554
export interface DrawerSlots {
5655
default(props?: {}): any
57-
handle(props?: {}): any
5856
content(props?: {}): any
5957
header(props?: {}): any
6058
title(props?: {}): any
@@ -67,19 +65,21 @@ export interface DrawerSlots {
6765
<script setup lang="ts">
6866
import { computed, toRef } from 'vue'
6967
import { useForwardPropsEmits } from 'reka-ui'
70-
import { DrawerRoot, DrawerTrigger, DrawerPortal, DrawerOverlay, DrawerContent, DrawerTitle, DrawerDescription } from 'vaul-vue'
68+
import { DrawerRoot, DrawerTrigger, DrawerPortal, DrawerOverlay, DrawerContent, DrawerTitle, DrawerDescription, DrawerHandle } from 'vaul-vue'
7169
import { reactivePick } from '@vueuse/core'
7270
7371
const props = withDefaults(defineProps<DrawerProps>(), {
7472
direction: 'bottom',
7573
portal: true,
7674
overlay: true,
77-
handle: true
75+
handle: true,
76+
modal: true,
77+
dismissible: true
7878
})
7979
const emits = defineEmits<DrawerEmits>()
8080
const slots = defineSlots<DrawerSlots>()
8181
82-
const rootProps = useForwardPropsEmits(reactivePick(props, 'activeSnapPoint', 'closeThreshold', 'defaultOpen', 'dismissible', 'fadeFromIndex', 'fixed', 'modal', 'nested', 'direction', 'open', 'scrollLockTimeout', 'shouldScaleBackground', 'snapPoints'), emits)
82+
const rootProps = useForwardPropsEmits(reactivePick(props, 'activeSnapPoint', 'closeThreshold', 'shouldScaleBackground', 'setBackgroundColorOnScale', 'scrollLockTimeout', 'fixed', 'dismissible', 'modal', 'open', 'defaultOpen', 'nested', 'direction', 'noBodyStyles', 'handleOnly', 'preventScrollRestoration', 'snapPoints', 'fadeFromIndex'), emits)
8383
const contentProps = toRef(() => props.content)
8484
const contentEvents = {
8585
closeAutoFocus: (e: Event) => e.preventDefault()
@@ -101,9 +101,7 @@ const ui = computed(() => drawer({
101101
<DrawerOverlay v-if="overlay" :class="ui.overlay({ class: props.ui?.overlay })" />
102102

103103
<DrawerContent :class="ui.content({ class: [!slots.default && props.class, props.ui?.content] })" v-bind="contentProps" v-on="contentEvents">
104-
<slot name="handle">
105-
<div v-if="handle" :class="ui.handle({ class: props.ui?.handle })" />
106-
</slot>
104+
<DrawerHandle v-if="handle" :class="ui.handle({ class: props.ui?.handle })" />
107105

108106
<slot name="content">
109107
<div :class="ui.container({ class: props.ui?.container })">

‎src/theme/drawer.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
export default {
1+
import type { ModuleOptions } from '../module'
2+
3+
export default (options: Required<ModuleOptions>) => ({
24
slots: {
35
overlay: 'fixed inset-0 bg-(--ui-bg-elevated)/75',
46
content: 'fixed bg-(--ui-bg) ring ring-(--ui-border) flex focus:outline-none',
5-
handle: 'shrink-0 rounded-full bg-(--ui-bg-accented)',
7+
handle: ['!bg-(--ui-bg-accented)', options.theme.transitions && 'transition-opacity'],
68
container: 'w-full flex flex-col gap-4 p-4 overflow-y-auto',
79
header: '',
810
title: 'text-(--ui-text-highlighted) font-semibold',
@@ -18,15 +20,15 @@ export default {
1820
},
1921
right: {
2022
content: 'flex-row',
21-
handle: 'ml-4'
23+
handle: '!ml-4'
2224
},
2325
bottom: {
2426
content: 'mt-24 flex-col',
2527
handle: 'mt-4'
2628
},
2729
left: {
2830
content: 'flex-row-reverse',
29-
handle: 'mr-4'
31+
handle: '!mr-4'
3032
}
3133
},
3234
inset: {
@@ -39,13 +41,13 @@ export default {
3941
direction: ['top', 'bottom'],
4042
class: {
4143
content: 'h-auto max-h-[96%]',
42-
handle: 'w-12 h-1.5 mx-auto'
44+
handle: '!w-12 !h-1.5 mx-auto'
4345
}
4446
}, {
4547
direction: ['right', 'left'],
4648
class: {
4749
content: 'w-auto max-w-[calc(100%-2rem)]',
48-
handle: 'h-12 w-1.5 mt-auto mb-auto'
50+
handle: '!h-12 !w-1.5 mt-auto mb-auto'
4951
}
5052
}, {
5153
direction: 'top',
@@ -96,4 +98,4 @@ export default {
9698
content: 'inset-y-0 right-0 rounded-l-[calc(var(--ui-radius)*2)]'
9799
}
98100
}]
99-
}
101+
})

‎test/components/Drawer.spec.ts

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ describe('Drawer', () => {
1414
['with description', { props: { ...props, title: 'Title', description: 'Description' } }],
1515
...directions.map((direction: string) => [`with direction ${direction}`, { props: { ...props, direction, title: 'Title', description: 'Description' } }]),
1616
...directions.map((direction: string) => [`with direction ${direction} inset`, { props: { ...props, direction, inset: true, title: 'Title', description: 'Description' } }]),
17-
['with top direction', { props: { ...props, direction: 'top' as const, title: 'Title', description: 'Description' } }],
18-
['with right direction', { props: { ...props, direction: 'right' as const, title: 'Title', description: 'Description' } }],
1917
['without handle', { props: { ...props, handle: false, title: 'Title', description: 'Description' } }],
2018
['without overlay', { props: { ...props, overlay: false, title: 'Title', description: 'Description' } }],
2119
['with class', { props: { ...props, class: 'bg-(--ui-bg-elevated)' } }],

‎test/components/__snapshots__/Drawer-vue.spec.ts.snap

+61-105
Large diffs are not rendered by default.

‎test/components/__snapshots__/Drawer.spec.ts.snap

+61-105
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.