chore: add option component

This commit is contained in:
aalizzwell 2022-10-14 20:06:46 +08:00 committed by Sagi
parent c2fd8b4971
commit 4f6c1e7034
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,20 @@
import { defineComponent, SetupContext } from 'vue';
import { comboListProps, ComboListProps } from '../combo-list.props';
import { useOption } from '../composition/use-option';
export default defineComponent({
name: 'FOption',
props: comboListProps,
emits: [],
inheritAttrs: false,
setup(props: ComboListProps, context: SetupContext) {
const { name } = useOption(props, context);
return () => {
return (
<li style="cursor: default;" class="list-group-item list-group-item-action">
{context.slots?.default ? context.slots.default() : name.value}
</li>
);
};
}
});

View File

@ -0,0 +1,12 @@
import { computed, Ref, SetupContext } from "vue";
import { OptionProps } from "../combo-list.props";
import { IUseOption } from "./types";
export function useOption(props: OptionProps, context: SetupContext): IUseOption {
const name = computed(() => {
return props.name || props.value;
});
return {
name
};
}