feat(useOverlay)!: handle programmatic modals and slideovers (#3279)

Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
Eugen Istoc
2025-02-27 11:32:48 -05:00
committed by GitHub
parent 607d9a7b4e
commit 108d36fd8a
27 changed files with 422 additions and 497 deletions

View 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>