mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
feat(Modal): open programmatically (#78)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
@@ -13,7 +13,7 @@ import { toRef } from 'vue'
|
||||
import { ConfigProvider, TooltipProvider, useForwardProps } from 'radix-vue'
|
||||
import { reactivePick } from '@vueuse/core'
|
||||
import { useId } from '#imports'
|
||||
import { UToaster } from '#components'
|
||||
import { UToaster, UModalProvider } from '#components'
|
||||
|
||||
const props = withDefaults(defineProps<ProviderProps>(), {
|
||||
useId: () => useId()
|
||||
@@ -31,5 +31,7 @@ const toasterProps = toRef(() => props.toaster)
|
||||
<slot />
|
||||
</UToaster>
|
||||
</TooltipProvider>
|
||||
|
||||
<UModalProvider />
|
||||
</ConfigProvider>
|
||||
</template>
|
||||
|
||||
12
src/runtime/components/ModalProvider.vue
Normal file
12
src/runtime/components/ModalProvider.vue
Normal file
@@ -0,0 +1,12 @@
|
||||
<script lang="ts" setup>
|
||||
import { inject } from 'vue'
|
||||
import { useModal, modalInjectionKey } from '../composables/useModal'
|
||||
|
||||
const modalState = inject(modalInjectionKey)
|
||||
|
||||
const { isOpen } = useModal()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<component :is="modalState.component" v-if="modalState" v-bind="modalState.props" v-model:open="isOpen" />
|
||||
</template>
|
||||
Reference in New Issue
Block a user