mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
* feat(components): [input-tag] add input-tag component * feat: styles * test: add test * docs: add docs * docs: updata * docs: uopdata * docs: updata * fix: optimize the style when input too long text * feat: add draggable attribute * fix: regain focus after dragged * fix: regain focus on dragend * refactor: useDragTag * fix: style of disabled * refactor: rename event name * refactor: move useCalcInputWidth to hooks * feat: add aria-label
26 lines
639 B
TypeScript
26 lines
639 B
TypeScript
import { computed, ref, shallowRef } from 'vue'
|
|
import { useResizeObserver } from '@vueuse/core'
|
|
|
|
export function useCalcInputWidth() {
|
|
const calculatorRef = shallowRef<HTMLElement>()
|
|
const calculatorWidth = ref(0)
|
|
const MINIMUM_INPUT_WIDTH = 11
|
|
|
|
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,
|
|
}
|
|
}
|