| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <template>
- <el-input ref="input" v-bind="$attrs" :class="[variant]" />
- </template>
- <script setup lang="ts">
- import { ref } from 'vue'
- import type { InputInstance } from 'element-plus'
- const input = ref<InputInstance>()
- withDefaults(
- defineProps<{
- variant?: 'outlined' | 'borderless' | 'filled' | 'underline'
- }>(),
- { variant: 'outlined' }
- )
- defineExpose({
- ...(input.value || {}),
- focus() {
- input.value?.focus()
- },
- blur() {
- input.value?.blur()
- },
- select() {
- input.value?.select()
- }
- })
- </script>
- <style lang="less" scoped>
- .borderless {
- :deep(.el-input__wrapper) {
- box-shadow: none;
- &:hover,
- &.is-focus {
- box-shadow: 0 0 0 1px var(--el-input-focus-border-color) inset;
- }
- }
- }
- .underline {
- :deep(.el-input__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-input__wrapper) {
- box-shadow: none;
- background-color: #f5f5f5;
- &:hover {
- background-color: #f0f0f0;
- }
- &.is-focus {
- background-color: transparent;
- }
- }
- }
- </style>
|