{"version":3,"sources":["middlewares/FormGroupTemplateMw.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAGxD,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,aAAa,CAAC,4BAA4B,CAkBrF,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,aAAa,CAAC,4BAA4B,CAWjF,CAAC;AAEF,eAAe,mBAAmB,CAAC","file":"FormGroupTemplateMw.d.ts","sourcesContent":["import * as React from 'react';\nimport { toJSONSchemaPath, isRequired } from '../core';\nimport { BlueprintFormMiddlewareProps } from '../share';\nimport { FormGroup, Intent } from '@blueprintjs/core';\n\nexport const FormGroupTemplateBaseMw: React.ComponentType<BlueprintFormMiddlewareProps> = (props) => {\n  const { schema, dataPath, next, errors } = props;\n\n  if (typeof schema === 'boolean') return next(props);\n\n  const id = toJSONSchemaPath(dataPath);\n  const error = errors && errors.find(({ dataPath }) => dataPath === id);\n\n  return (\n    <FormGroup\n      label={schema.title || dataPath[dataPath.length - 1]}\n      helperText={error ? error.message : schema.description}\n      labelInfo={isRequired(props) ? '(required)' : ''}\n      intent={error ? Intent.DANGER : Intent.NONE}\n    >\n      {next(props)}\n    </FormGroup>\n  );\n};\n\nexport const FormGroupTemplateMw: React.ComponentType<BlueprintFormMiddlewareProps> = (props) => {\n  const { schema, parent, next } = props;\n  if (\n    typeof schema === 'boolean' ||\n    schema.type === 'object' ||\n    schema.type === 'array' ||\n    (parent && typeof parent.schema !== 'boolean' && parent.schema.type === 'array')\n  )\n    return next(props);\n\n  return <FormGroupTemplateBaseMw {...props} />;\n};\n\nexport default FormGroupTemplateMw;\n"]}