UNPKG

@rjsf/mui

Version:

Material UI 7 theme, fields and widgets for react-jsonschema-form

24 lines 1.42 kB
import { jsx as _jsx } from "react/jsx-runtime"; import ListItem from '@mui/material/ListItem'; import FormHelperText from '@mui/material/FormHelperText'; import List from '@mui/material/List'; import { errorId, getUiOptions, } from '@rjsf/utils'; import { getMuiProps } from '../util.js'; /** The `FieldErrorTemplate` component renders the errors local to the particular field * * @param props - The `FieldErrorProps` for the errors being rendered */ export default function FieldErrorTemplate(props) { const { errors = [], fieldPathId, uiSchema } = props; if (errors.length === 0) { return null; } const id = errorId(fieldPathId); const uiOptions = getUiOptions(uiSchema); const muiProps = getMuiProps(uiOptions); const { rjsfSlotProps: muiSlotProps } = muiProps; return (_jsx(List, { id: id, dense: true, disablePadding: true, ...muiSlotProps === null || muiSlotProps === void 0 ? void 0 : muiSlotProps.fieldErrorList, children: errors.map((error, i) => { return (_jsx(ListItem, { disableGutters: true, ...muiSlotProps === null || muiSlotProps === void 0 ? void 0 : muiSlotProps.fieldErrorListItem, children: _jsx(FormHelperText, { component: 'div', id: `${id}-${i}`, ...muiSlotProps === null || muiSlotProps === void 0 ? void 0 : muiSlotProps.fieldErrorFormHelperText, children: error }) }, i)); }) })); } //# sourceMappingURL=FieldErrorTemplate.js.map