import type { CustomSerialize, FormError, FormValue, Serialize } from '@conform-to/dom/future'; import type { StandardSchemaV1 } from './standard-schema'; import { ValidateHandler, ValidateResult, BaseFieldMetadata, ConditionalFieldMetadata } from './types'; export declare function isUndefined(value: unknown): value is undefined; export declare function isString(value: unknown): value is string; export declare function isNumber(value: unknown): value is number; export declare function isNullable(value: unknown, typeGuard: (value: unknown) => value is T): value is T | null; export declare function isOptional(value: unknown, typeGuard: (value: unknown) => value is T): value is T | undefined; export declare function getPathArray(formValue: Record | null, name: string): Array; export declare function resolveDefaultValue(defaultValue: Record | URLSearchParams | null | undefined, intentName: string): Record; /** * Immutably updates a value at the specified path. * Empty path replaces the entire object. */ export declare function updatePathValue(data: Record, name: string, value: Data | Record): Record; /** * Updates array indices in a field path. * Returns null to remove fields, or the updated path with a new index. */ export declare function updatePathIndex(name: string, listName: string, update: (index: number) => number | null): string | null; export declare function resolveSerialize(customSerialize: CustomSerialize | undefined, defaultSerialize: Serialize): Serialize; export declare function normalizeValidateResult(result: ValidateResult): { error: FormError | null; value?: Value; }; /** * Handles different validation result formats: * - Promise: async validation only * - Staged result: immediate result with a pending result * - Object: sync validation only */ export declare function resolveValidateResult(result: ReturnType>): { syncResult: { error: FormError | null; value?: Value | undefined; } | undefined; asyncResult: Promise<{ error: FormError | null; value?: Value | undefined; }> | undefined; }; /** * Resolves a StandardSchema validation result to conform's format. */ export declare function resolveStandardSchemaResult(result: StandardSchemaV1.Result): { error: FormError | null; value?: Value; }; /** * Create a copy of the object with the updated properties if there is any change */ export declare function merge>(obj: Obj, update: Partial): Obj; /** * Transforms object keys using a mapping function. * Keys mapped to null are filtered out. */ export declare function transformKeys(obj: Record, fn: (key: string) => string | null): Record; /** * Appends item to array only if not already present. * Returns original array if item exists, new array if added. */ export declare function appendUniqueItem(list: Array, item: Item): Item[]; export declare function generateUniqueKey(): string; /** * Creates a type-only marker for TypeScript inference. * * This function always returns `true` at runtime. It exists * purely to capture the generic type parameter for compile-time type checking. * No runtime validation is performed. * * Common uses: * - `isError`: Specify the error shape for type inference * - `when`: Narrow field metadata to specific shapes for conditional props * * **Example: Specify error shape** * ```ts * configureForms({ * isError: shape(), // errors are string arrays * }); * ``` * * **Example: Conditional field metadata** * ```ts * extendFieldMetadata(metadata, { when }) { * return { * get dateRangePickerProps() { * return when(metadata, shape<{ start: string; end: string }>(), (m) => ({ * startName: m.getFieldset().start.name, * endName: m.getFieldset().end.name, * })); * }, * }; * } * ``` */ export declare function shape(): (value: unknown) => value is T; /** * Creates a conditional field metadata property that is only available * when the field shape matches the specified type. */ export declare function when(metadata: BaseFieldMetadata, _shape: (value: unknown) => value is FieldShape, fn: (m: BaseFieldMetadata) => Metadata): ConditionalFieldMetadata; export declare function isStandardSchemaV1(schema: unknown): schema is StandardSchemaV1; export declare function validateStandardSchemaV1(schema: Schema, payload: Record): any; //# sourceMappingURL=util.d.ts.map