chore: merge code

This commit is contained in:
Sagi 2022-10-03 15:19:01 +08:00
commit a8ae06e5ea
6 changed files with 111 additions and 0 deletions

View File

@ -0,0 +1,13 @@
import type { App } from 'vue';
import FComboList from './src/combo-list.component';
export * from './src/types';
export * from './src/combo-list.props';
export { FComboList };
export default {
install(app: App): void {
app.component(FComboList.name, FComboList);
},
};

View File

@ -0,0 +1,14 @@
import { defineComponent, SetupContext } from 'vue';
import { comboListProps, ComboListProps } from './combo-list.props';
export default defineComponent({
name: 'FComboList',
props: comboListProps,
emits: [],
setup(props: ComboListProps, context: SetupContext) {
return () => {
return (
<div id={props.id}>combo-list</div>
);
};
}
});

View File

@ -0,0 +1,55 @@
import { ExtractPropTypes } from "vue";
import { ViewType, EnumTypeProp } from './types';
export const comboListProps = {
/**
*
*/
id: String,
/**
*
* false
*/
disabled: {
type: Boolean,
default: false
},
/**
*
* false
*/
readonly: {
type: Boolean,
default: false
},
/**
*
*/
maxLength: Number,
/**
*
*/
placeholder: String,
/**
*
*
*/
enableClear: {
type: Boolean,
default: true
},
/**
*
*
*/
enableTitle: {
type: Boolean,
default: true
},
/**
*
* text | tagViewType.Text
*/
viewType: EnumTypeProp(ViewType.Text, ViewType),
};
export type ComboListProps = ExtractPropTypes<typeof comboListProps>;

View File

@ -0,0 +1,19 @@
/**
*
*/
export enum ViewType {
Text = 'text',
Tag = 'tag'
};
/**
*
* @param defaultValue
* @param enumType
* @returns
*/
export function EnumTypeProp<T extends string | number>(defaultValue: T, enumType: Record<symbol, T>) {
return {
default: defaultValue,
validator: (value: T) => Object.values(enumType).includes(value)
}
}

View File

@ -12,6 +12,7 @@ import RadioGroup from "./components/radio-group.vue";
import Section from "./components/section.vue";
import Notify from "./components/notify.vue";
import Accordion from "./components/accordion.vue";
import ComboList from "./components/combo-list.vue";
const canEdit = ref(true);
const disable = ref(false);
@ -44,6 +45,7 @@ const canAutoComplete = ref(false);
<Notify></Notify>
<Accordion></Accordion>
<Tabs />
<ComboList />
</template>
<style scoped>

View File

@ -0,0 +1,8 @@
<script setup lang="ts">
import ComboList from '../../components/combo-list/src/combo-list.component';
</script>
<template>
<ComboList/>
</template>