Merge branch 'feat/combolist'

This commit is contained in:
aalizzwell 2022-10-03 17:26:25 +08:00
commit fa17e1efbb
3 changed files with 83 additions and 27 deletions

View File

@ -1,5 +1,6 @@
import { defineComponent, SetupContext } from 'vue';
import { comboListProps, ComboListProps } from './combo-list.props';
import { ButtonEdit } from '../../button-edit';
export default defineComponent({
name: 'FComboList',
props: comboListProps,
@ -7,7 +8,9 @@ export default defineComponent({
setup(props: ComboListProps, context: SetupContext) {
return () => {
return (
<div id={props.id}>combo-list</div>
<>
<ButtonEdit id={props.id} />
</>
);
};
}

View File

@ -1,55 +1,99 @@
import { ExtractPropTypes } from "vue";
import { ViewType, EnumTypeProp } from './types';
import { ViewType, EnumType, Type } from './types';
/**
*
*/
export const comboListProps = {
/**
*
*/
id: String,
id: Type(String),
/**
*
* false
* `false`
*/
disabled: {
type: Boolean,
default: false
},
disabled: Type({ default: false, type: Boolean }),
/**
*
* false
* `false`
*/
readonly: {
type: Boolean,
default: false
},
readonly: Type({ default: false, type: Boolean }),
/**
*
*/
maxLength: Number,
maxLength: Type(Number),
/**
*
*/
placeholder: String,
placeholder: Type(String),
/**
*
*
*/
enableClear: {
type: Boolean,
default: true
},
enableClear: Type({ default: true, type: Boolean }),
/**
*
*
*/
enableTitle: {
type: Boolean,
default: true
},
enableTitle: Type({ default: true, type: Boolean }),
/**
*
* text | tagViewType.Text
* text | tag`ViewType.Text``text`
*/
viewType: EnumTypeProp(ViewType.Text, ViewType),
viewType: EnumType(ViewType.Text, ViewType),
/**
*
*/
mapFields: Type(Object),
/**
*
*/
data: Type(Array),
/**
* id字段
* `id`
*/
idField: Type({ default: 'id', type: String }),
/**
*
* `id`
*/
valueField: Type({ default: 'id', type: String }),
/**
*
* `label`
*/
textField: Type({ default: 'label', type: String }),
/**
*
* `false`
*/
multiSelect: Type({default: false, type: Boolean}),
/**
*
*/
uri: Type(String),
/**
*
* `200`
*/
maxHeight: Type({default: 200, type: Number}),
/**
*
* `false`
*/
remoteSearch: Type({default: false, type: Boolean}),
/**
*
* `true`
*/
hidePanelOnClear: Type({default: true, type: Boolean}),
/**
*
* `,`
*/
separator: Type({default: ',', type: String}),
};
export type ComboListProps = ExtractPropTypes<typeof comboListProps>;

View File

@ -1,3 +1,4 @@
import { Prop } from 'vue';
/**
*
*/
@ -6,12 +7,20 @@ export enum ViewType {
Tag = 'tag'
};
/**
*
*
* @param options options
* @returns
*/
export function Type<T, D>(options: Prop<T, D>) {
return options;
}
/**
*
* @param defaultValue
* @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)