<script setup lang="ts">
import { inject } from 'vue'
import { Primitive } from '@/lib/primitive'
import { DialogContextKey } from './context'

const props = defineProps<{ asChild?: boolean }>()

const context = inject(DialogContextKey)!
</script>

<template>
  <Primitive
    as="button"
    :as-child="props.asChild"
    type="button"
    data-slot="dialog-close"
    @click="context.open.value = false"
  >
    <slot />
  </Primitive>
</template>
