'use client' export default function QInput({ type, readOnly = false, options, value, onChange }) { // options = options || [ // { // id: 'one', // name: 'Option 1', // value: '111', // }, // { // id: 'two', // name: 'Option 2', // value: '222', // }, // { // id: 'three', // name: 'Option 3', // value: '333', // }, // ] const handleChange = (e, optionValue) => { if (type === 'radio') { onChange(e.target.value) } else { const newValue = value.includes(optionValue) ? value.filter((v) => v !== optionValue) : [...value, optionValue] onChange(newValue) } } return (
{type === 'text' ? (
onChange(e.target.value)} />
) : type === 'radio' || type === 'checkbox' ? (
{options?.map((option) => (
handleChange(e, option.value)} />
))}
) : null}
) }