@rjsf/mui
Version:
Material UI 7 theme, fields and widgets for react-jsonschema-form
22 lines • 2.2 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import FormControl from '@mui/material/FormControl';
import Typography from '@mui/material/Typography';
import { getTemplate, getUiOptions, } from '@rjsf/utils';
import { getMuiProps } from '../util.js';
/** 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, onKeyRename, onKeyRenameBlur, onRemoveProperty, readonly, required, rawErrors = [], errors, help, description, 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 });
}
const isCheckbox = uiOptions.widget === 'checkbox';
const { rjsfSlotProps: muiSlotProps, ...otherMuiProps } = getMuiProps(uiOptions);
return (_jsx(WrapIfAdditionalTemplate, { classNames: classNames, style: style, disabled: disabled, id: id, label: label, displayLabel: displayLabel, rawDescription: rawDescription, onKeyRename: onKeyRename, onKeyRenameBlur: onKeyRenameBlur, onRemoveProperty: onRemoveProperty, readonly: readonly, required: required, schema: schema, uiSchema: uiSchema, registry: registry, children: _jsxs(FormControl, { fullWidth: true, error: rawErrors.length ? true : false, required: required, ...muiSlotProps === null || muiSlotProps === void 0 ? void 0 : muiSlotProps.fieldFormControl, sx: otherMuiProps.sx, className: otherMuiProps.className, children: [children, displayLabel && !isCheckbox && rawDescription ? (_jsx(Typography, { variant: 'caption', color: 'textSecondary', ...muiSlotProps === null || muiSlotProps === void 0 ? void 0 : muiSlotProps.fieldTypography, children: description })) : null, errors, help] }) }));
}
//# sourceMappingURL=FieldTemplate.js.map