chore: update enum type prop name
This commit is contained in:
parent
3f5c354384
commit
87189e4eeb
|
@ -1,5 +1,5 @@
|
|||
import { ExtractPropTypes } from "vue";
|
||||
import { ViewType, enumTypeProp } from './types';
|
||||
import { ViewType, EnumTypeProp } from './types';
|
||||
|
||||
export const comboListProps = {
|
||||
/**
|
||||
|
@ -50,6 +50,6 @@ export const comboListProps = {
|
|||
* 可选,下拉列表值展示方式
|
||||
* 支持text | tag,即文本或标签,默认为ViewType.Text,即文本方式
|
||||
*/
|
||||
viewType: enumTypeProp(ViewType.Text, ViewType),
|
||||
viewType: EnumTypeProp(ViewType.Text, ViewType),
|
||||
};
|
||||
export type ButtonProps = ExtractPropTypes<typeof comboListProps>;
|
||||
export type ComboListProps = ExtractPropTypes<typeof comboListProps>;
|
|
@ -11,11 +11,9 @@ export enum ViewType {
|
|||
* @param enumType 枚举类型
|
||||
* @returns
|
||||
*/
|
||||
export function enumTypeProp<T extends string | number>(defaultValue: T, enumType: Record<string | number, any>) {
|
||||
export function EnumTypeProp<T extends string | number>(defaultValue: T, enumType: Record<symbol, T>) {
|
||||
return {
|
||||
default: defaultValue,
|
||||
validator(value: T) {
|
||||
return enumType[value] !== undefined
|
||||
}
|
||||
validator: (value: T) => Object.values(enumType).includes(value)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue