Debian Codegraph @

packages/mui/src/ErrorList/ErrorList.tsx

raw
1 import ErrorIcon from '@mui/icons-material/Error';
2 import Box from '@mui/material/Box';
3 import List from '@mui/material/List';
4 import ListItem from '@mui/material/ListItem';
5 import ListItemIcon from '@mui/material/ListItemIcon';
6 import ListItemText from '@mui/material/ListItemText';
7 import Paper from '@mui/material/Paper';
8 import Typography from '@mui/material/Typography';
9 import { ErrorListProps, FormContextType, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
10
11 /** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
12 *
13 * @param props - The `ErrorListProps` for this component
14 */
15 export default function ErrorList<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
16 errors,
17 registry,
18 }: ErrorListProps<T, S, F>) {
19 const { translateString } = registry;
20 return (
21 <Paper elevation={2}>
22 <Box mb={2} p={2}>
23 <Typography variant='h6'>{translateString(TranslatableString.ErrorsLabel)}</Typography>
24 <List dense={true}>
25 {errors.map((error, i: number) => {
26 return (
27 <ListItem key={i}>
28 <ListItemIcon>
29 <ErrorIcon color='error' />
30 </ListItemIcon>
31 <ListItemText primary={error.stack} />
32 </ListItem>
33 );
34 })}
35 </List>
36 </Box>
37 </Paper>
38 );
39 }