UNPKG

@conform-to/react

Version:

Conform view adapter for react

35 lines 1.76 kB
import type { FormValue, Submission } from '@conform-to/dom/future'; import type { ActionHandler, IntentDispatcher, UnknownIntent } from './types'; /** * Serializes intent to string format: "type" or "type(payload)". */ export declare function serializeIntent<Intent extends UnknownIntent = UnknownIntent>(intent: Intent): string; /** * Parses serialized intent string back to intent object. */ export declare function deserializeIntent(value: string): UnknownIntent; /** * Applies intent transformation to submission payload. * Returns modified payload or null for reset intent. */ export declare function applyIntent(submission: Submission, options?: { handlers?: Record<string, ActionHandler>; }): Record<string, FormValue> | null; export declare function insertItem<Item>(list: Array<Item>, item: Item, index: number): void; export declare function removeItem(list: Array<unknown>, index: number): void; export declare function reorderItems(list: Array<unknown>, fromIndex: number, toIndex: number): void; /** * Updates list keys by removing child keys and optionally transforming remaining keys. */ export declare function updateListKeys(keys: Record<string, string[]> | undefined, keyToBeRemoved: string, updateKey?: (key: string) => string | null): Record<string, string[]>; /** * Built-in action handlers for form intents: * - reset: clears form data * - validate: marks fields as touched for validation display * - update: updates specific field values * - insert/remove/reorder: manages array field operations */ export declare const actionHandlers: { [Type in keyof IntentDispatcher]: IntentDispatcher[Type] extends (payload: any) => void ? ActionHandler<IntentDispatcher[Type]> : never; }; //# sourceMappingURL=intent.d.ts.map