import type { FormInstance } from 'antd/es/form'; import type { NamePath } from 'antd/es/form/interface'; import type { FormProps as AntFormProps } from 'antd/es/form'; type FieldChangeMeta = { name?: NamePath; value?: unknown; touched?: boolean; errors?: string[]; warnings?: string[]; validating?: boolean; }; export type FormValidateMode = 'onSubmit' | 'onBlur' | 'onChange' | 'onTouched' | 'all'; export type FormReValidateMode = 'onChange' | 'onBlur' | 'onSubmit'; export declare const DEFAULT_VALIDATE_MODE: FormValidateMode; export declare const DEFAULT_REVALIDATE_MODE: FormReValidateMode; export type OBFormConfig = { validateMode?: FormValidateMode; reValidateMode?: FormReValidateMode; /** Preserve field values when fields unmount (antd default `true`, OB default `false`). */ preserve?: boolean; }; export declare function resolveValidateMode(prop?: FormValidateMode, context?: FormValidateMode): FormValidateMode; export declare function resolveReValidateMode(prop?: FormReValidateMode, context?: FormReValidateMode): FormReValidateMode; export declare function resolveValidateTrigger(validateMode: FormValidateMode, explicitTrigger?: AntFormProps['validateTrigger']): AntFormProps['validateTrigger'] | undefined; export declare function shouldInjectRevalidateOnChange(validateMode: FormValidateMode, reValidateMode: FormReValidateMode, explicitTrigger?: AntFormProps['validateTrigger']): boolean; export declare function shouldTrackSubmitAttempt(validateMode: FormValidateMode, reValidateMode: FormReValidateMode, explicitTrigger?: AntFormProps['validateTrigger']): boolean; /** * Port of react-hook-form `skipValidation` for change events (`isBlurEvent = false`). * Reference implementation for tests; runtime uses `getFieldsToRevalidateOnChange` instead. * @see https://github.com/react-hook-form/react-hook-form/blob/master/src/logic/skipValidation.ts */ export declare function shouldSkipValidationOnChange(validateMode: FormValidateMode, reValidateMode: FormReValidateMode, options: { isSubmitted: boolean; isFieldTouched: boolean; }): boolean; export declare function markFormSubmitted(submitted: { current: boolean; }): void; export declare function normalizeNamePath(name: NamePath): (string | number)[]; export declare function serializeNamePath(name: NamePath): string; export declare function deserializeNamePath(key: string): NamePath; /** * Collect the field name paths whose value actually changed, from `onFieldsChange` changedFields. * * rc-field-form emits `onFieldsChange` for value updates as well as validation-state updates * (validating / errors / warnings), and only the former should trigger revalidation. A validation * update reports the unchanged value, so comparing against the last value seen for the field * separates the two. Fields seen for the first time only seed `previousValues`; they are not * reported as changed, which matches "nothing to clear before a field has ever been validated". * * Comparing by identity mirrors rc-field-form's own change detection (`newValue !== value`): it only * dispatches a value update when the reference (or primitive) differs. */ export declare function collectValueChangedNames(changedFields: FieldChangeMeta[], previousValues: Map): NamePath[]; /** State tracked by the injected revalidation, keyed by `serializeNamePath` where applicable. */ export type TrackedFormState = { /** Fields the user has blurred. */ blurredFields: Set; /** Last value seen per field. */ previousValues: Map; /** Whether form submit was attempted (react-hook-form `isSubmitted`). */ submitted: { current: boolean; }; }; export declare function getTrackedFormState(form: FormInstance): TrackedFormState; /** * `resetFields()` mutates field internals without emitting `onFieldsChange` (unlike value updates and * validations), so the tracked state cannot be cleared from `handleFieldsChange`. Patch the instance * method instead, mirroring react-hook-form: a full `reset()` clears everything, while * `resetFields([name])` (like `resetField`) clears only that field and keeps the submit state. */ export declare function patchResetFieldsTracking(form: FormInstance): void; /** * Track fields the user has blurred (react-hook-form `touchedFields`). * * rc-field-form sets a field's `touched` flag on every change, so `touched` cannot tell a blur apart * from typing. A blur instead runs the configured `onBlur` validation, which is observable as an * in-flight `validating` update and, once it settles, as errors. Fields without rules run no * validation, but they have nothing to validate either. */ export declare function syncBlurredFieldsFromFieldsChange(blurredFields: Set, changedFields: FieldChangeMeta[], validateMode: FormValidateMode): void; export declare function getFieldsToRevalidateOnChange(form: FormInstance, validateMode: FormValidateMode, blurredFields: Set, options?: { changedNames?: NamePath[]; submitted?: boolean; }): NamePath[]; export declare function revalidateOnChange(form: FormInstance, options: { validateMode: FormValidateMode; reValidateMode: FormReValidateMode; blurredFields: Set; changedNames?: NamePath[]; submitted?: boolean; }): void; export {};