zod-form-kit
Version:
UI-agnostic form generation library based on Zod schemas with extensible adapter pattern
5 lines (4 loc) • 803 B
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export function EnumField({ value = '', onChange, error, required, label, name, values = [] }) {
return (_jsxs("div", { className: "field enum-field", children: [_jsx("label", { className: `field-label ${required ? 'required' : ''}`, htmlFor: name, id: `${name}-label`, children: label }), _jsxs("select", { id: name, name: name, value: value, onChange: (e) => onChange(e.target.value), className: `field-input ${error ? 'error' : ''}`, "aria-labelledby": `${name}-label`, required: required, children: [_jsx("option", { value: "", children: "Select an option..." }), values.map((option) => (_jsx("option", { value: option, children: option }, option)))] }), error && _jsx("div", { className: "field-error", children: error })] }));
}