diff --git a/packages/components/select/src/select.vue b/packages/components/select/src/select.vue index 8ea49e1836..519d16ca1c 100644 --- a/packages/components/select/src/select.vue +++ b/packages/components/select/src/select.vue @@ -281,13 +281,10 @@ import ElScrollbar from '@element-plus/components/scrollbar' import ElTag, { tagProps } from '@element-plus/components/tag' import ElIcon from '@element-plus/components/icon' import { useDeprecateAppendToBody } from '@element-plus/components/popper' -import { - CHANGE_EVENT, - UPDATE_MODEL_EVENT, - getComponentSize, -} from '@element-plus/constants' +import { CHANGE_EVENT, UPDATE_MODEL_EVENT } from '@element-plus/constants' import { addResizeListener, + getComponentSize, isValidComponentSize, removeResizeListener, } from '@element-plus/utils' diff --git a/packages/components/select/src/useSelect.ts b/packages/components/select/src/useSelect.ts index 4b02e78345..ab5711a083 100644 --- a/packages/components/select/src/useSelect.ts +++ b/packages/components/select/src/useSelect.ts @@ -15,9 +15,13 @@ import { CHANGE_EVENT, EVENT_CODE, UPDATE_MODEL_EVENT, - getComponentSize, } from '@element-plus/constants' -import { debugWarn, isKorean, scrollIntoView } from '@element-plus/utils' +import { + debugWarn, + getComponentSize, + isKorean, + scrollIntoView, +} from '@element-plus/utils' import { useLocale, useNamespace, useSize } from '@element-plus/hooks' import { formContextKey, formItemContextKey } from '@element-plus/tokens' diff --git a/packages/constants/size.ts b/packages/constants/size.ts index a157c26ec9..6cca6b3b5b 100644 --- a/packages/constants/size.ts +++ b/packages/constants/size.ts @@ -7,7 +7,3 @@ export const componentSizeMap = { default: 32, small: 24, } as const - -export const getComponentSize = (size: ComponentSize = 'default') => { - return componentSizeMap[size || 'default'] -} diff --git a/packages/utils/dom/style.ts b/packages/utils/dom/style.ts index 3892303571..210fa26073 100644 --- a/packages/utils/dom/style.ts +++ b/packages/utils/dom/style.ts @@ -1,9 +1,12 @@ import { isClient } from '@vueuse/core' -import { isObject } from '../types' +import { isNumber, isObject, isString } from '../types' import { camelize } from '../strings' import { entriesOf, keysOf } from '../objects' +import { debugWarn } from '../error' import type { CSSProperties } from 'vue' +const SCOPE = 'utils/dom/style' + export const classNameToArray = (cls = '') => cls.split(' ').filter((item) => !!item.trim()) @@ -70,3 +73,13 @@ export const removeStyle = ( setStyle(element, style, '') } } + +export function addUnit(value?: string | number, defaultUnit = 'px') { + if (!value) return '' + if (isString(value)) { + return value + } else if (isNumber(value)) { + return `${value}${defaultUnit}` + } + debugWarn(SCOPE, 'binding value must be a string or number') +} diff --git a/packages/utils/vue/index.ts b/packages/utils/vue/index.ts index 494b4e65f8..10a950634e 100644 --- a/packages/utils/vue/index.ts +++ b/packages/utils/vue/index.ts @@ -3,7 +3,7 @@ export * from './icon' export * from './install' export * from './props' export * from './refs' -export * from './style' +export * from './size' export * from './typescript' export * from './validator' export * from './vnode' diff --git a/packages/utils/vue/size.ts b/packages/utils/vue/size.ts new file mode 100644 index 0000000000..2525be0b79 --- /dev/null +++ b/packages/utils/vue/size.ts @@ -0,0 +1,7 @@ +import { componentSizeMap } from '@element-plus/constants' + +import type { ComponentSize } from '@element-plus/constants' + +export const getComponentSize = (size?: ComponentSize) => { + return componentSizeMap[size || 'default'] +} diff --git a/packages/utils/vue/style.ts b/packages/utils/vue/style.ts deleted file mode 100644 index a8b7ca7661..0000000000 --- a/packages/utils/vue/style.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { isNumber, isString } from '../types' -import { debugWarn } from '../error' - -const SCOPE = 'utils/vue/style' - -export function addUnit( - value: string | number | undefined, - defaultUnit = 'px' -) { - if (!value) return '' - if (isString(value)) { - return value - } else if (isNumber(value)) { - return `${value}${defaultUnit}` - } - debugWarn(SCOPE, 'binding value must be a string or number') -}