mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-22 07:50:36 +01:00
feat(useOverlay)!: handle programmatic modals and slideovers (#3279)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
26
src/runtime/components/OverlayProvider.vue
Normal file
26
src/runtime/components/OverlayProvider.vue
Normal file
@@ -0,0 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
const { overlays, unMount, close } = useOverlay()
|
||||
|
||||
const mountedOverlays = computed(() => overlays.filter(overlay => overlay.isMounted))
|
||||
|
||||
const onAfterLeave = (id: symbol) => {
|
||||
close(id)
|
||||
unMount(id)
|
||||
}
|
||||
|
||||
const onClose = (id: symbol, value: any) => {
|
||||
close(id, value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<component
|
||||
:is="overlay.component"
|
||||
v-for="overlay in mountedOverlays"
|
||||
:key="overlay.id"
|
||||
v-bind="overlay.props"
|
||||
v-model:open="overlay.modelValue"
|
||||
@close="(value:any) => onClose(overlay.id, value)"
|
||||
@after:leave="onAfterLeave(overlay.id)"
|
||||
/>
|
||||
</template>
|
||||
Reference in New Issue
Block a user