<template>
	<el-select ref="input" v-bind="$attrs" :class="[variant]">
		<slot />
	</el-select>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import type { SelectInstance } from 'element-plus'

const input = ref<SelectInstance>()

withDefaults(
	defineProps<{
		variant?: 'outlined' | 'borderless' | 'filled' | 'underline'
	}>(),
	{ variant: 'outlined' }
)

defineExpose({
	...(input.value || {}),
	focus() {
		input.value?.focus()
	},
	blur() {
		input.value?.blur()
	}
})
</script>

<style lang="less" scoped>
.borderless {
	:deep(.el-select__wrapper) {
		box-shadow: none;
		&:hover,
		&.is-focus {
			box-shadow: 0 0 0 1px var(--el-input-focus-border-color) inset;
		}
	}
}
.underline {
	:deep(.el-select__wrapper) {
		box-shadow: none;
		border-radius: 0;
		border-bottom: solid 1px var(--el-input-border-color);
		&:hover,
		&.is-focus {
			border-bottom: solid 1px var(--el-input-focus-border-color);
		}
	}
}
.filled {
	:deep(.el-select__wrapper) {
		box-shadow: none;
		background-color: #f5f5f5;
		&:hover {
			background-color: #f0f0f0;
		}
		&.is-focus {
			background-color: transparent;
		}
	}
}
</style>
