shelving
Version:
Toolkit for using data in JavaScript.
13 lines (12 loc) • 624 B
JavaScript
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
import { requireForm, useField } from "./FormContext.js";
import { SchemaInput } from "./SchemaInput.js";
/** Show a `SchemaInput` for each property in the current form. */
export function FormInput({ name, ...props }) {
const field = useField(name);
return _jsx(SchemaInput, { ...field, ...props });
}
/** Show a `SchemaInput` for a named property in the current form. */
export function FormInputs() {
return (_jsx(_Fragment, { children: Object.keys(requireForm().schema.props).map(name => (_jsx(FormInput, { name: name }, name))) }));
}