zod-form-kit
Version:
UI-agnostic form generation library based on Zod schemas with extensible adapter pattern
5 lines (4 loc) • 752 B
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export function NumberField({ name, label, value = 0, onChange, error, required, options = {}, className = '' }) {
return (_jsxs("div", { className: `field number-field ${className}`, children: [_jsx("label", { htmlFor: name, id: name + '-label', className: `field-label ${required ? 'required' : ''}`, children: label }), _jsx("input", { id: name, name: name, type: "number", value: value, onChange: (e) => onChange(Number(e.target.value)), min: options.min, max: options.max, step: options.step, className: `field-input ${error ? 'error' : ''}`, required: required, "aria-labelledby": name + '-label' }), error && _jsx("span", { className: "field-error", children: error })] }));
}