mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-21 01:02:59 +08:00
refactor(utils): move function (#7336)
This commit is contained in:
parent
6c399d32d9
commit
9de79794a3
@ -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'
|
||||
|
@ -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'
|
||||
|
||||
|
@ -7,7 +7,3 @@ export const componentSizeMap = {
|
||||
default: 32,
|
||||
small: 24,
|
||||
} as const
|
||||
|
||||
export const getComponentSize = (size: ComponentSize = 'default') => {
|
||||
return componentSizeMap[size || 'default']
|
||||
}
|
||||
|
@ -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')
|
||||
}
|
||||
|
@ -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'
|
||||
|
7
packages/utils/vue/size.ts
Normal file
7
packages/utils/vue/size.ts
Normal file
@ -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']
|
||||
}
|
@ -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')
|
||||
}
|
Loading…
Reference in New Issue
Block a user