chore: add option component
This commit is contained in:
parent
c2fd8b4971
commit
4f6c1e7034
|
@ -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>
|
||||
);
|
||||
};
|
||||
}
|
||||
});
|
|
@ -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
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue