import { FieldElement, ParseFunction } from './useForm'; import { PathsAndValues } from './useFormState'; /** * Returns the copy of an object built from the path with the assigned value. */ export declare function build(path: string, value: any, context: any, syntaxChecked?: boolean): T; /** * Builds an object using paths and values. * @param paths */ export declare function reconstruct(paths: PathsAndValues): T | null; /** * Returns a deeply cloned object. */ export declare function clone(object: T): T; /** * Returns a flat object. * @example { a: { test: 1 }, b: 2 } => { "a.test": 1, b: 2 } * @param object * @param path * @param preserveKeys */ export declare function flatten(object: Record, path?: string | null, preserveKeys?: boolean): Record; /** * Returns checked values from an input element. */ export declare function getCheckedValues(element: HTMLInputElement): string[]; /** * Returns a field ID using a name and form ID. */ export declare function getFieldId(name: string, formId: string): string; /** * Returns parsed field value. * @param field * @param options */ export declare function getFieldValue(field: FieldElement, options?: { parse?: ParseFunction; }): any; /** * Extracts indexed parts of a given path and returns them as an array. * @param path */ export declare function getIndexedPathParts(path: string): [string, number, string]; /** * Returns the index of an object path. * @param path */ export declare function getIndexFromPath(path: string): number | null; /** * Returns selected values from a select element. */ export declare function getSelectedValues(element: HTMLSelectElement): string[]; /** * Checks if an object contains attributes with values different of null and undefined. * @param obj */ export declare function hasDefinedValues(obj: Record): boolean; /** * Checks if an object contains true values. * @param obj */ export declare function hasTrueValues(obj: Record): boolean; /** * Returns an empty string when value is null. */ export declare function inputValue(value?: T): string | T; export declare function isMultipleFieldElement(element: unknown): boolean; /** * Returns the parsed value of a field based on its type. */ export declare function parseInputValue(input: HTMLElement): string | number | undefined; /** * Generates a random key. */ export declare function randomKey(length?: number): string; /** * Returns a value from a context using a path. */ export declare function resolve(path: string, context?: any, syntaxChecked?: boolean): T | undefined; /** * Normalizes index to be within a valid range. * @param index * @param maxIndex */ export declare function normalizeIndex(index: number, maxIndex: number): number; /** * Moves path value in a record. * todo add unit tests * @param record * @param path * @param fromIndex * @param toIndex * @param maxIndex */ export declare function movePathIndices>(record: T, path: string, fromIndex: number, toIndex: number, maxIndex: number): T; /** * Swaps two list values in a record. * todo add unit tests * @param record * @param path * @param fromIndex * @param toIndex */ export declare function swapPathIndices>(record: T, path: string, fromIndex: number, toIndex: number): T; /** * Updates indices in paths of a record. * todo add unit tests * @param record * @param path * @param index * @param change */ export declare function updatePathIndices>(record: T, path: string, index: number, change: number): T; //# sourceMappingURL=utils.d.ts.map