@rjsf/semantic-ui
Version:
Semantic UI theme, fields and widgets for react-jsonschema-form
30 lines • 1.18 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { errorId } from '@rjsf/utils';
import { nanoid } from 'nanoid';
import { Label, List } from 'semantic-ui-react';
import { getSemanticErrorProps } from '../util.js';
const DEFAULT_OPTIONS = {
options: {
pointing: 'above',
size: 'small',
},
};
/** The `FieldErrorTemplate` component renders the errors local to the particular field
*
* @param props - The `FieldErrorProps` for the errors being rendered
*/
export default function FieldErrorTemplate({ errors, idSchema, uiSchema, registry }) {
const { formContext } = registry;
const options = getSemanticErrorProps({
formContext,
uiSchema,
defaultProps: DEFAULT_OPTIONS,
});
const { pointing, size } = options;
if (errors && errors.length > 0) {
const id = errorId(idSchema);
return (_jsx(Label, { id: id, color: 'red', pointing: pointing || 'above', size: size || 'small', basic: true, children: _jsx(List, { bulleted: true, children: errors.map((error) => (_jsx(List.Item, { children: error }, nanoid()))) }) }));
}
return null;
}
//# sourceMappingURL=FieldErrorTemplate.js.map