mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-14 17:31:02 +08:00
8b801cfd8a
fix #3032
28 lines
630 B
TypeScript
28 lines
630 B
TypeScript
import { isNumber } from './util'
|
|
|
|
export const isValidWidthUnit = (val: string | number): boolean =>{
|
|
if(isNumber(val)){
|
|
return true
|
|
} else {
|
|
return ['px', 'rem', 'em', 'vw', '%', 'vmin', 'vmax'].some(unit =>
|
|
(val as string).endsWith(unit),
|
|
) || (val as string).startsWith('calc')
|
|
}
|
|
}
|
|
|
|
export const isValidComponentSize = (val: string) =>
|
|
['', 'large', 'medium', 'small', 'mini'].includes(val)
|
|
|
|
export const isValidDatePickType = (val: string) =>
|
|
[
|
|
'year',
|
|
'month',
|
|
'date',
|
|
'dates',
|
|
'week',
|
|
'datetime',
|
|
'datetimerange',
|
|
'daterange',
|
|
'monthrange',
|
|
].includes(val)
|