import { AltEditorLiteError } from '../core/alt-editor-lite-error.js'; import { type EditorFormValidationResult, type LocalUniqueValidator } from './validate-editor-form.js'; import type { FormDependencies } from './form-dependency.js'; import type { FormValidationRequestContext, FormValidator } from './form-validation.js'; import type { AltEditorLiteLanguage } from '../core/alt-editor-lite-language.js'; import type { DialogTemplateSource } from '../core/editing-options.js'; import type { DeepPartial, EditorValues } from '../core/editor-values.js'; import type { FieldConfig } from '../fields/field-config.js'; import type { FieldController } from '../fields/field-controller.js'; import type { FieldPath, FieldPathValue } from '../object-path/field-path.js'; /** * Public controller for one rendered editor form. */ export interface FormController { /** Root form element. */ readonly element: HTMLFormElement; /** Populates configured fields from partial nested values. */ populate(values: Readonly>): void; /** Collects enabled, normalized field values. */ collect(): Promise>; /** Runs native constraints followed by custom field validators. */ validate(): Promise; /** Retrieves one configured controller by safe field path. */ getField>(name: TPath): FieldController> | null; /** Updates interaction state while an operation owns the dialog. */ setBusy(isBusy: boolean): void; /** Maps known field errors and displays remaining submission text. */ showSubmissionError(error: AltEditorLiteError): void; /** Clears field and submission errors. */ clearErrors(): void; /** Removes owned callbacks, controllers, and DOM. */ destroy(): void; } /** Stable values and field metadata returned for one dialog submission. */ export type FormSubmissionValidationResult = { readonly valid: false; readonly error: AltEditorLiteError; } | { readonly valid: true; readonly values: Readonly>; readonly fieldValues: ReadonlyMap; }; /** * Default DOM-backed FormController implementation. */ export declare class EditorFormController implements FormController { private readonly language; private readonly validateUnique?; readonly element: HTMLFormElement; private readonly controllerByName; private readonly configuredFieldNames; private readonly comparatorByName; private readonly fieldControllerByName; private readonly runtimeByName; private readonly dependencyFieldByName; private readonly lifecycleAbortController; private readonly submissionErrorElement; private readonly validationSequence; private readonly activeChangeAbortControllers; private readonly activeChangeTasks; private readonly fieldValidation; private readonly invalidMessage; private readonly layout; private dependencyController; private operationErrorMessage; private validationErrorMessage; private activeFormValidationAbortController; private controllers; private isDestroyed; private dirtyBaseline; private cleanRevision; revision: number; onMutation: (() => void) | undefined; private recordMutation; /** * Creates fields in stable configuration order. * * @param fields - Validated field configurations. * @param instanceId - Instance-scoped DOM prefix. * @param language - Complete resolved language. */ constructor(fields: readonly FieldConfig[], instanceId: string, language: Readonly, validateUnique?: LocalUniqueValidator | undefined, template?: DialogTemplateSource, dependencies?: Readonly>, onDependencyError?: (sourcePath: string, error: AltEditorLiteError) => void, operation?: 'create' | 'edit'); /** Populates configured fields from nested values. */ populate(values: Readonly>): void; /** * Populates matching configured paths from a row-shaped source object. * * This internal boundary keeps `TRow` and `TFormValues` separate: paths * absent from the row retain their configured defaults. * * @param sourceValues - Row snapshot read through safe configured paths. */ populateFromSource(sourceValues: Readonly): void; /** Resolves dependencies after defaults or source values are populated. */ initializeDependencies(): Promise; /** Collects enabled normalized values. */ collect(): Promise>; /** Captures the current settled field values as the clean dialog state. */ rebaseDirtyState(): Promise; /** Compares current values with the latest clean dialog state when needed. */ isDirty(): Promise; /** Runs native and custom validation. */ validate(): Promise; /** Runs one operation-owned validation and returns its exact collected values. */ validateForSubmission(operationSignal: AbortSignal, validateForm: FormValidator | undefined, context: FormValidationRequestContext): Promise>; /** Retrieves one public field facade. */ getField>(name: TPath): FieldController> | null; /** Updates the form busy state. */ setBusy(isBusy: boolean): void; /** Maps and displays an operation error. */ showSubmissionError(error: AltEditorLiteError): void; /** Clears obsolete operation-level feedback while preserving field validation. */ clearSubmissionError(): void; /** Clears all displayed errors. */ clearErrors(): void; /** Removes owned form resources. */ destroy(): void; private assertActive; private notifyFieldChange; private runFieldChange; private waitForCurrentFieldWork; private renderSubmissionError; private showValidationError; private validateManagedController; }