1
0
mirror of https://github.com/elk-zone/elk synced 2024-12-28 13:37:59 +09:00
elk/components/common/dropdown/Dropdown.vue

30 lines
642 B
Vue
Raw Normal View History

2022-11-24 17:34:05 +09:00
<script setup lang="ts">
2023-01-03 20:58:08 +09:00
import { InjectionKeyDropdownContext } from '~/constants/symbols'
defineProps<{
placement?: string
autoBoundaryMaxSize?: boolean
}>()
2022-11-24 17:34:05 +09:00
const dropdown = $ref<any>()
const colorMode = useColorMode()
2022-11-24 17:34:05 +09:00
const hide = () => dropdown.hide()
2023-01-03 20:58:08 +09:00
provide(InjectionKeyDropdownContext, {
hide,
})
defineExpose({
hide,
2022-11-24 17:34:05 +09:00
})
</script>
<template>
<VDropdown v-bind="$attrs" ref="dropdown" :class="colorMode.value" :placement="placement || 'auto'" :auto-boundary-max-size="autoBoundaryMaxSize">
2022-11-24 17:34:05 +09:00
<slot />
<template #popper="scope">
<slot name="popper" v-bind="scope" />
</template>
</VDropdown>
</template>