import { type FieldName, FormError, type SubmissionResult } from '@conform-to/dom/future'; import type { FieldMetadata, Fieldset, FormContext, FormMetadata, FormState, FormAction, UnknownIntent, IntentHandler, BaseFieldMetadata, BaseFormMetadata, DefineConditionalField, ApplyStatus, CustomStateHandler, FormCustomState } from './types'; export declare function initializeState> = {}>(options?: { defaultValue?: Record | null | undefined; resetKey?: string | undefined; customStateHandlers?: CustomStateHandlers | undefined; lastCustomState?: FormCustomState | undefined; result?: SubmissionResult | undefined; }): FormState>; /** * Updates form state based on action type: * - Client actions: update target value and client errors * - Server actions: update server errors and clear client errors, with optional target value * - Initialize: set initial server value */ export declare function updateState> = {}>(state: FormState>, action: FormAction>; customStateHandlers: CustomStateHandlers | undefined; status: ApplyStatus; reset: () => FormState>; }>): FormState>; export declare function getFields(result: SubmissionResult): string[]; export declare function getApplyStatus(baseTargetValue: Record | undefined, finalTargetValue: Record | undefined): ApplyStatus; /** * Fallback state transition for intents that change the payload shape without * providing a `move()` mapping. It drops list keys and touched fields under * changed paths so stale client state does not point at the wrong fields. */ export declare function invalidateState = Record>(state: FormState, previousValue: Record, nextValue: Record): FormState; /** * Preserves list keys and touched fields for intents that can map old field * paths to new ones, such as insert, remove, and reorder. */ export declare function moveState = Record>(state: FormState, previousValue: Record, nextValue: Record, move: (name: string) => string | null): FormState; /** * Removes list keys where array length has changed to force regeneration. * Minimizes UI state loss by only invalidating keys when necessary. */ export declare function pruneListKeys(listKeys: Record, targetValue: Record): Record; export declare function getDefaultPayload(context: FormContext, name: string): unknown; export declare function getDefaultValue(context: FormContext, name: string): string; export declare function getDefaultOptions(context: FormContext, name: string): string[]; export declare function isDefaultChecked(context: FormContext, name: string): boolean; /** * Determine if the field is touched * * This checks if the field is in the list of touched fields, * or if there is any child field that is touched, i.e. form / fieldset */ export declare function isTouched(state: FormState, name?: string): boolean; export declare function getDefaultListKey(prefix: string, initialValue: Record | null, name: string): string[]; export declare function getListKey(context: FormContext, name: string): string[]; export declare function getErrors(state: FormState, name?: string): ErrorShape | undefined; export declare function getFieldErrors(state: FormState, name?: string): Record; /** * Checks if fieldErrors contains any errors at the given name or any child path. */ export declare function hasFieldError(error: FormError, name: string): boolean; export declare function isValid(state: FormState, name?: string): boolean; export declare function getFormMetadata = {}, CustomFieldMetadata extends Record = {}, CustomState extends Record = {}>(context: FormContext, options?: { extendFormMetadata?: ((metadata: BaseFormMetadata) => CustomFormMetadata) | undefined; extendFieldMetadata?: ((metadata: BaseFieldMetadata, ctx: { form: BaseFormMetadata; when: DefineConditionalField; }) => CustomFieldMetadata) | undefined; }): FormMetadata; export declare function getField = {}>(context: FormContext, options: { name: FieldName; extendFieldMetadata?: ((metadata: BaseFieldMetadata, ctx: { form: BaseFormMetadata; when: DefineConditionalField; }) => CustomFieldMetadata) | undefined; form?: BaseFormMetadata | undefined; key?: string | undefined; }): FieldMetadata; /** * Creates a proxy that dynamically generates field objects when properties are accessed. */ export declare function getFieldset, ErrorShape = string, CustomFieldMetadata extends Record = {}>(context: FormContext, options: { name?: FieldName | undefined; extendFieldMetadata?: ((metadata: BaseFieldMetadata, ctx: { form: BaseFormMetadata; when: DefineConditionalField; }) => CustomFieldMetadata) | undefined; form?: BaseFormMetadata | undefined; }): Fieldset; /** * Creates an array of field objects for list/array inputs */ export declare function getFieldList, ErrorShape = string, CustomFieldMetadata extends Record = {}>(context: FormContext, options: { name: FieldName; extendFieldMetadata?: ((metadata: BaseFieldMetadata, ctx: { form: BaseFormMetadata; when: DefineConditionalField; }) => CustomFieldMetadata) | undefined; }): FieldMetadata<[ FieldShape ] extends [Array | null | undefined] ? ItemShape : unknown, ErrorShape, CustomFieldMetadata>[]; export declare function defineCustomState> = {}, ErrorShape = any>(definition: CustomStateHandler): CustomStateHandler; export declare function mergeCustomStateHandlers> | undefined, InlineCustomState extends Record> | undefined>(globalCustomState: GlobalCustomState, inlineCustomState: InlineCustomState): GlobalCustomState & InlineCustomState; export declare function initializeCustomState>>(options: { handlers: CustomStateHandlers | undefined; currentState?: FormCustomState | undefined; result?: SubmissionResult | undefined; }): FormCustomState; export declare function updateCustomState>>(state: FormCustomState, action: FormAction, options: { handlers: CustomStateHandlers | undefined; }): FormCustomState; //# sourceMappingURL=state.d.ts.map