mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-14 17:31:02 +08:00
2280dd5c5e
- Using `defineComponent` to wrap component up for Volar support, this should close #841 - Also made changes for some typing - Removed `merge.ts` since `Object.assign` are now supported natively
62 lines
1.3 KiB
Vue
62 lines
1.3 KiB
Vue
<template>
|
|
<div
|
|
class="el-select-dropdown"
|
|
:class="[{ 'is-multiple': isMultiple }, popperClass]"
|
|
:style="{ minWidth: minWidth }"
|
|
>
|
|
<slot></slot>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import {
|
|
defineComponent,
|
|
computed,
|
|
onMounted,
|
|
onBeforeUnmount,
|
|
inject,
|
|
ref,
|
|
} from 'vue'
|
|
import { addResizeListener, removeResizeListener, ResizableElement } from '@element-plus/utils/resize-event'
|
|
import {
|
|
selectKey,
|
|
} from './token'
|
|
|
|
|
|
export default defineComponent({
|
|
name: 'ElSelectDropdown',
|
|
|
|
componentName: 'ElSelectDropdown',
|
|
|
|
setup() {
|
|
const select = inject(selectKey)
|
|
|
|
// computed
|
|
const popperClass = computed(() => select.props.popperClass)
|
|
const isMultiple = computed(() => select.props.multiple)
|
|
const minWidth = ref('')
|
|
|
|
function updateMinWidth() {
|
|
minWidth.value = select.selectWrapper?.getBoundingClientRect().width + 'px'
|
|
}
|
|
|
|
onMounted(() => {
|
|
// TODO: updatePopper
|
|
// popper.value.update()
|
|
|
|
addResizeListener(select.selectWrapper as ResizableElement, updateMinWidth)
|
|
})
|
|
|
|
onBeforeUnmount(() => {
|
|
removeResizeListener(select.selectWrapper as ResizableElement, updateMinWidth)
|
|
})
|
|
|
|
return {
|
|
minWidth,
|
|
popperClass,
|
|
isMultiple,
|
|
}
|
|
},
|
|
})
|
|
</script>
|