elk/components/common/dropdown/Dropdown.vue

32 lines
652 B
Vue
Raw Normal View History

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