@aokiapp/rjsf-mantine-theme
Version:
Mantine theme, fields and widgets for react-jsonschema-form
30 lines • 1.3 kB
JavaScript
import { createErrors } from '../utils/createErrors';
/** 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) {
var _a, _b;
// show-hide decision phase start ----------------
let show = false;
// array, object, null will produce non-error yielding widgets
// so we need to show the errors
if (['array', 'object', 'null'].includes(props.schema.type)) {
show = true;
}
// but if the schema is multiple-selecting data-url, it will yield a normal input widget, which will show errors
// so we need to hide the errors
if (props.schema.type === 'array' &&
typeof props.schema.items === 'object' &&
!(props.schema.items instanceof Array) &&
((_a = props.schema.items) === null || _a === void 0 ? void 0 : _a.type) === 'string' &&
((_b = props.schema.items) === null || _b === void 0 ? void 0 : _b.format) === 'data-url') {
show = false;
}
// show-hide decision phase end ----------------
if (show === false) {
return null;
}
return createErrors(props.errors, false, props.idSchema);
}
//# sourceMappingURL=FieldErrorTemplate.js.map