import type { Form } from './Form'; import type { FormSetupCallback } from './IConfigurableFormCollection'; import type { IReadOnlyFormCollection } from './IReadOnlyFormCollection'; import { ReadOnlyObservableCollection } from '../collections'; import { type IObjectValidator, type IValidatable } from '../validation'; /** * Represents a configurable read-only observable collection of form sections. Callbacks can be configured for setting * up individual form sections for cases where validation and other aspects are based on the state of an entity or the * form itself. * * @template TForm The concrete type of the form section. * @template TValidationError The concrete type for representing validation errors (strings, enums, numbers etc.). */ export declare class ReadOnlyFormCollection, TValidationError = string> extends ReadOnlyObservableCollection implements IReadOnlyFormCollection, IValidatable { private _error; private readonly _setupCallbacks; /** * Initializes a new instance of the {@linkcode ReadOnlyFormCollection} class. * @param sections The sections to initialize the collection with. */ constructor(sections?: Iterable); /** * Gets the validation configuration for the form. Fields have their own individual validation config as well. * * @see {@linkcode Form.validation} */ readonly validation: IObjectValidator; /** * A flag indicating whether the section collection is valid. * * A section collection is valid only when itself is valid and all contained sections are valid. */ get isValid(): boolean; /** * A flag indicating whether the section collection is invalid. * * A section collection is invalid when itself is invalid or any contained sections is invalid. */ get isInvalid(): boolean; /** * Gets or sets the error message when the section collection is invalid. */ get error(): TValidationError | null; /** * Gets or sets the error message when the section collection is invalid. */ set error(value: TValidationError | false | null | undefined); /** * Configures the provided `setupCallback` and applies it on all existing form sections within the collection * and to any form section that is added. * @param setupCallback The callback performing the setup. */ withItemSetup(setupCallback: FormSetupCallback): this; /** * Removes the provided `setupCallback` and no longer applies it to form sections that are added, all existing * form sections are reset and re-configured using the remaining setup callbacks. * @param setupCallback The callback performing the setup. */ withoutItemSetup(setupCallback: FormSetupCallback): this; /** * Clears all setup callbacks and resets all existing form sections. */ clearItemSetups(): void; /** * Resets the form, contained fields and sections to their initial configuration. * * Validation and other flags are reset, fields retain their current values. */ reset(): void; /** * Invoked when a section's properies change, this is a plugin method through which notification propagation can be made with ease. */ protected onSectionChanged(section: Form, changedProperties: readonly (keyof Form)[]): void; /** * Invoked when the current instance's properties change, this is a plugin method to help reduce validations when changes do not * have an effect on validation. * * @returns Returns `true` if a validation should be triggered for the given changed properties; otherwise `false`. */ protected onShouldTriggerValidation(changedProperties: readonly (keyof this)[]): boolean; private _setupSections; }