import { defineComponent, type PropType } from 'vue'; import type { BCMSRadioInputOption } from '../../types'; import { DefaultComponentProps } from '../_default'; import InputWrapper from './_input'; const component = defineComponent({ props: { ...DefaultComponentProps, options: Array as PropType>, modelValue: String, label: String, name: String, disabled: Boolean, helperText: String, }, emits: { 'update:modelValue': (val: string) => { return val; }, }, setup(props, { emit }) { function handlerInput(event: Event) { const element = event.target as HTMLInputElement; if (!element) { return; } emit('update:modelValue', element.value); } function keydownHandler(event: KeyboardEvent) { const element = event.target as HTMLInputElement; if (!element) { return; } if (event.key === 'Enter') { emit('update:modelValue', element.value); } } return () => (
{props.label && ( {props.label} )}
{props.options?.map((option, index) => { return (
{props.modelValue === option.value && (
)}
{option.label}
); })}
); }, }); export default component;