import { HydratedItem } from '../../contexts/types'; import { Locale } from '../../types/Locale'; import { CuringData, CuringFormState, CuringFormStateKey } from '../../widgets/TaxbitCuringDocumentation/types'; export type CuringErrors = Partial>; export type UseCuringStateProps = { /** Server-derived data passed in from `CuringPersist` after the status fetch. */ serverData: CuringData; /** Initial locale; updated only if the host re-mounts with a new value. */ language?: Locale; /** Threaded through to the chrome via `state.config.poweredByTaxbit`. */ poweredByTaxbit?: boolean; /** * When true, threads `config.collectSignatureName = true` into descriptor * state so `signatureNameDescriptor` becomes visible + required on the * review screen. Callers who set this should also skip the previous-W-Form * fetch upstream (see `TaxbitCuringDocumentationPersist`) so the two * signature-name sources stay mutually exclusive. */ collectSignatureName?: boolean; /** * Payload-agnostic submit callback — receives the raw form state and leaves * transport/serialisation to the caller (Stage 8's widget-internal * `useTaxbitCuring`). The uploaded file lives on `state.file`; uploads read * it from state rather than taking it as a separate arg, so the contract * scales to multi-file widgets without a signature change. */ onSubmit?: (state: CuringFormState) => void | Promise; }; /** * Form-state engine for the curing widget. Holds `CuringFormState`, exposes * `setField` / `setFile` / `hideErrors` / `showErrors` write paths, computes * `derived.sptWeightedTotal`, walks the flat descriptor list into `items` * (hydrated `HydratedElement[]` for `ElementRenderer`), aggregates * `errors`, and wraps the host's `onSubmit` with `isSubmitting`. Mirrors * `useQuestionnaireState`'s public shape so the cognitive bridge is short. * * Payload-agnostic: `onSubmit(state)` hands the raw state out (file included, * on `state.file`) and lets the caller own the multipart build + POST * (Stage 8's widget-internal `useTaxbitCuring`). */ export declare const useCuringState: ({ serverData, language: initialLanguage, poweredByTaxbit, collectSignatureName, onSubmit, }: UseCuringStateProps) => { fields: CuringFormState; derived: { sptWeightedTotal: number; }; serverData: CuringData; ui: { language: Locale; isShowingErrors: boolean; setValue: (key: CuringFormStateKey, value: string | undefined) => void; setFile: (key: CuringFormStateKey, file: File | null) => void; hideErrors: () => void; setLanguage: import('react').Dispatch>; }; config: { poweredByTaxbit: boolean | undefined; collectSignatureName: boolean | undefined; }; errors: Partial>; items: HydratedItem[]; isValid: boolean; isShowingErrors: boolean; isSubmitting: boolean; onSubmit: () => Promise; };