chore: update enum type prop name

This commit is contained in:
aalizzwell 2022-10-03 14:29:00 +08:00
parent 3f5c354384
commit 87189e4eeb
2 changed files with 5 additions and 7 deletions

View File

@ -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 | tagViewType.Text
*/
viewType: enumTypeProp(ViewType.Text, ViewType),
viewType: EnumTypeProp(ViewType.Text, ViewType),
};
export type ButtonProps = ExtractPropTypes<typeof comboListProps>;
export type ComboListProps = ExtractPropTypes<typeof comboListProps>;

View File

@ -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)
}
}