mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
* fix(components): select Give some space to the input field * fix(components): [select] fix(components): [select] Add the judgement of filterable * fix(components): [select-v2] Give some space to the input field Give some space to the input field * fix(components): [select-v2 & select & input] Create constants/form.ts Create a form.ts file to store the MINIMUM_INPUT_WIDTH constant
26 lines
668 B
TypeScript
26 lines
668 B
TypeScript
import { computed, ref, shallowRef } from 'vue'
|
|
import { useResizeObserver } from '@vueuse/core'
|
|
import { MINIMUM_INPUT_WIDTH } from '@element-plus/constants'
|
|
|
|
export function useCalcInputWidth() {
|
|
const calculatorRef = shallowRef<HTMLElement>()
|
|
const calculatorWidth = ref(0)
|
|
|
|
const inputStyle = computed(() => ({
|
|
minWidth: `${Math.max(calculatorWidth.value, MINIMUM_INPUT_WIDTH)}px`,
|
|
}))
|
|
|
|
const resetCalculatorWidth = () => {
|
|
calculatorWidth.value =
|
|
calculatorRef.value?.getBoundingClientRect().width ?? 0
|
|
}
|
|
|
|
useResizeObserver(calculatorRef, resetCalculatorWidth)
|
|
|
|
return {
|
|
calculatorRef,
|
|
calculatorWidth,
|
|
inputStyle,
|
|
}
|
|
}
|