{"version":3,"file":"FormValidatorGroupWithForm.mjs","names":[],"sources":["../../../../package/services/formValidation/FormValidatorGroupWithForm.tsx"],"sourcesContent":["import { showToast } from 'components/common/toast';\nimport { FormValidatorGroup, createFormComponent } from '@ahrowe/form-validation';\nimport type { FormGroup, FormValidatorGroupOptions, InferGroupValues, ValidationError } from '@ahrowe/form-validation';\nimport type React from 'react';\nimport { ThemeColor } from '../../common/themeProvider/color.types';\n\n/** Default onSubmitError: surface the first error as an error toast. Callers can override via options.onSubmitError. */\nconst defaultOnSubmitError = (errors: ValidationError[]): void => {\n  showToast(errors[0].message, { color: ThemeColor.Error });\n};\n\n/**\n * FormValidatorGroup with `this.Form` automatically attached.\n * Kept in a .tsx file so formValidatorGroup.ts stays framework-agnostic.\n *\n * This is the class you should use everywhere — it is a drop-in replacement\n * for FormValidatorGroup with one extra property: `this.Form`.\n *\n * Also injects the default toast-based onSubmitError so both hook and class-component\n * consumers surface errors out of the box; pass options.onSubmitError to override.\n */\nexport default class FormValidatorGroupWithForm<\n  TGroup extends FormGroup = FormGroup,\n  TInitial = InferGroupValues<TGroup>,\n> extends FormValidatorGroup<TGroup, TInitial> {\n  Form: React.FC<React.FormHTMLAttributes<HTMLFormElement>>;\n\n  constructor(\n    groupDef: TGroup,\n    component: { forceUpdate: () => void } | null = null,\n    options?: FormValidatorGroupOptions<TGroup, TInitial>,\n  ) {\n    super(groupDef, component, { ...options, onSubmitError: options?.onSubmitError ?? defaultOnSubmitError });\n    this.Form = createFormComponent(this);\n  }\n}\n"],"mappings":"2OAOA,IAAM,EAAwB,GAAoC,CAChE,EAAU,EAAO,EAAE,CAAC,QAAS,CAAE,MAAO,EAAW,KAAM,CAAC,CAC1D,EAYqB,EAArB,cAGU,CAAqC,CAG7C,YACE,EACA,EAAgD,KAChD,EACA,CACA,MAAM,EAAU,EAAW,CAAE,GAAG,EAAS,cAAe,GAAS,eAAiB,CAAqB,CAAC,EACxG,KAAK,KAAO,EAAoB,IAAI,CACtC,CACF"}