UNPKG

@rxap/forms

Version:

This package provides a set of tools and directives to simplify working with Angular forms, including reactive forms, custom validators, and form directives for handling loading, submitting, and error states. It offers decorators for defining forms and co

97 lines (96 loc) 4.07 kB
import { Injector, StaticProvider } from '@angular/core'; import { Constructor } from '@rxap/utilities'; import { AbstractControl } from '@angular/forms'; import { FormDefinition, FormDefinitionMetadata, FormType } from './model'; export declare class FormArrayControlManager<T extends FormDefinition> { private readonly form; private readonly controlId; constructor(form: T, controlId: keyof T); inserted(index: number, controlOrDefinition: AbstractControl | FormDefinition): void; removed(index: number): void; } export declare class RxapFormBuilder<Data extends Record<string, any> = any, Form extends FormType<Data> = FormType<Data>> { private readonly definition; private readonly injector; private readonly formArrayGroups; private readonly formArrayControls; private readonly formControls; private readonly formGroups; private readonly formOptions; private readonly validators; private readonly asyncValidators; private readonly controlChanges; private readonly controlSetValue; private readonly providers; constructor(definition: Constructor<Form>, injector?: Injector, providers?: StaticProvider[]); build<T extends (FormDefinition<Data> | FormType<Data>)>(state?: Readonly<any>, options?: Partial<FormDefinitionMetadata & { controlId?: string; }>): T; private buildArrayControls; private buildArrayGroups; private buildGroups; private buildControls; /** * Coerce to a function array. * * @param form the current form definition instance * @param methodKeys A set of propertyKeys that points to form * definition instance methods */ private coerceToFnArray; /** * Coerce to a validator function array. * * @param form the current form definition instance * @param optionsValidators The options validator functions * @param validatorMethodKeys A set of propertyKeys that points to form * definition instance methods * @param injectValidators Injected validator functions */ private coerceToValidatorArray; /** * Coerce to the form state for the specified controlId. If none form state is * found the default form state will be returned. * * @param controlId A control id * @param defaultFormState The default form state * @param builderFormState The form state provides as build state parameter * @param optionsFormState The form state set by the decorator in the form definition */ private coerceToControlFormState; /** * Coerce to the form state for the specified controlId. If none form state is * found the default form state will be returned. * * The difference to the method coerceToControlFormState is that null will be * handled as undefined and the defaultFormState is used * * @param controlId A control id * @param defaultFormState The default form state * @param builderFormState The form state provides as build state parameter * @param optionsFormState The form state set by the decorator in the form definition */ private coerceToGroupFormState; /** * Coerce to the form state for the specified controlId. If none form state is * found the default form state will be returned. * * The difference to the method coerceToControlFormState is that null will be * handled as undefined and the defaultFormState is used * * @param controlId A control id * @param defaultFormState The default form state * @param builderFormState The form state provides as build state parameter * @param optionsFormState The form state set by the decorator in the form definition */ private coerceToArrayFormState; private extractControlChanges; private extractControlSetValue; private extractValidators; private extractAsyncValidators; private extractArrayGroups; private extractArrayControls; private extractGroups; private extractControls; private extractFormOptions; }