chore: change enum prop type name

This commit is contained in:
aalizzwell 2022-10-03 16:00:14 +08:00
parent e781133016
commit ac68cb94d2
3 changed files with 50 additions and 31 deletions

View File

@ -1,6 +1,9 @@
import { ExtractPropTypes } from "vue";
import { ViewType, EnumTypeProp } from './types';
import { ViewType, EnumType } from './types';
/**
*
*/
export const comboListProps = {
/**
*
@ -50,6 +53,21 @@ export const comboListProps = {
*
* text | tagViewType.Text
*/
viewType: EnumTypeProp(ViewType.Text, ViewType),
viewType: EnumType(ViewType.Text, ViewType),
/**
*
*/
mapFields: Object,
/**
*
*/
data: Array,
idField: {
type: String,
default: 'id'
},
valueField: {
}
};
export type ComboListProps = ExtractPropTypes<typeof comboListProps>;

View File

@ -1,3 +1,4 @@
import Constructor, { } from 'vue';
/**
*
*/
@ -11,7 +12,7 @@ export enum ViewType {
* @param enumType
* @returns
*/
export function EnumTypeProp<T extends string | number>(defaultValue: T, enumType: Record<symbol, T>) {
export function EnumType<T extends string | number>(defaultValue: T, enumType: Record<symbol, T>) {
return {
default: defaultValue,
validator: (value: T) => Object.values(enumType).includes(value)