UNPKG

@datalayer/primer-rjsf

Version:

React JSON Schema Form (RJSF) for Primer

18 lines (17 loc) 1.51 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { FormControl } from "@primer/react"; import { getTemplate, getUiOptions, } from "@rjsf/utils"; /** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field * content, (label, description, children, errors and help) inside of a `WrapIfAdditional` component. * * @param props - The `FieldTemplateProps` for this component */ export default function FieldTemplate(props) { const { id, children, classNames, style, disabled, displayLabel, hidden, label, onDropPropertyClick, onKeyChange, readonly, required, rawErrors = [], errors, help, rawDescription, schema, uiSchema, registry, } = props; const uiOptions = getUiOptions(uiSchema); const WrapIfAdditionalTemplate = getTemplate("WrapIfAdditionalTemplate", registry, uiOptions); if (hidden) { return _jsx("div", { style: { display: "none" }, children: children }); } return (_jsx(WrapIfAdditionalTemplate, { classNames: classNames, style: style, disabled: disabled, id: id, label: label, onDropPropertyClick: onDropPropertyClick, onKeyChange: onKeyChange, readonly: readonly, required: required, schema: schema, uiSchema: uiSchema, registry: registry, children: _jsxs(FormControl, { required: required, children: [_jsx(FormControl.Label, { visuallyHidden: true }), children, displayLabel && rawDescription ? (_jsx(FormControl.Caption, { id: id, children: rawDescription })) : null, errors, help] }) })); }