@aokiapp/rjsf-mantine-theme
Version:
Mantine theme, fields and widgets for react-jsonschema-form
1 lines • 2.2 kB
Source Map (JSON)
{"version":3,"file":"FieldErrorTemplate.cjs","sources":["../../src/templates/FieldErrorTemplate.tsx"],"sourcesContent":["import { FieldErrorProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';\nimport { createErrors } from '../utils/createErrors';\n\n/** The `FieldErrorTemplate` component renders the errors local to the particular field\n *\n * @param props - The `FieldErrorProps` for the errors being rendered\n */\nexport default function FieldErrorTemplate<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(props: FieldErrorProps<T, S, F>) {\n // show-hide decision phase start ----------------\n let show = false;\n\n // array, object, null will produce non-error yielding widgets\n // so we need to show the errors\n if (['array', 'object', 'null'].includes(props.schema.type as string)) {\n show = true;\n }\n\n // but if the schema is multiple-selecting data-url, it will yield a normal input widget, which will show errors\n // so we need to hide the errors\n if (\n props.schema.type === 'array' &&\n typeof props.schema.items === 'object' &&\n !(props.schema.items instanceof Array) &&\n props.schema.items?.type === 'string' &&\n props.schema.items?.format === 'data-url'\n ) {\n show = false;\n }\n // show-hide decision phase end ----------------\n\n if (show === false) {\n return null;\n }\n\n return createErrors<T>(props.errors, false, props.idSchema);\n}\n"],"names":["createErrors"],"mappings":";;;;;;AAEe,SAAS,kBAAkB,CAAC,KAAK,EAAE;AAClD,EAAE,IAAI,IAAI,GAAG,KAAK,CAAC;AACnB,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;AAC/D,IAAI,IAAI,GAAG,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,KAAK,QAAQ,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,YAAY,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,KAAK,UAAU,EAAE;AAC/M,IAAI,IAAI,GAAG,KAAK,CAAC;AACjB,GAAG;AACH,EAAE,IAAI,IAAI,KAAK,KAAK,EAAE;AACtB,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,OAAOA,yBAAY,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC3D;;;;"}