import * as rxjs from 'rxjs'; import { BehaviorSubject, Observable } from 'rxjs'; import * as i0 from '@angular/core'; import { Signal, PipeTransform } from '@angular/core'; import * as i11 from '@angular/forms'; import { FormControlStatus, ValidationErrors as ValidationErrors$1, AbstractControl, FormArray, FormGroup, FormControl } from '@angular/forms'; import { Primitive, ReadonlyBehaviorSubject, DeepPartial } from 'tableau-ui-angular/types'; import * as tableau_ui_angular_form from 'tableau-ui-angular/form'; import * as i12 from '@angular/common'; interface Meta { readonly untouched: boolean; readonly touched: boolean; readonly validity: FormControlStatus; readonly pristine: boolean; readonly dirty: boolean; readonly enabled: boolean; readonly disabled: boolean; readonly valueIsDefault: boolean; readonly updateOn: 'blur' | 'change' | 'submit'; readonly errors: ValidationErrors$1 | null; readonly childControls: readonly Meta[] | undefined; hasError: (errorCode?: string, requireTouched?: boolean) => boolean; getErrorValue: (errorCode: string, requireTouched?: boolean) => Primitive; } interface MetaFns { /** * Sets errors on a form control when running validations manually, rather than automatically. * * Calling `setErrors` also updates the validity of the parent control. * * @param opts Configuration options that determine how the control propagates * changes and emits events after the control errors are set. * * `emitEvent`: When true or not supplied (the default), the `statusChanges` * observable emits an event after the errors are set. * * @usageNotes * * ### Manually set the errors for a control * * ```ts * const login = new FormControl('someLogin'); * login.setErrors({ * notUnique: true * }); * * expect(login.valid).toEqual(false); * expect(login.errors).toEqual({ notUnique: true }); * * login.setValue('someOtherLogin'); * * expect(login.valid).toEqual(true); * ``` */ setErrors: (errors: ValidationErrors$1 | null, emitEvent?: boolean) => TChild; /** * Marks the control as `touched`. A control is touched by focus and * blur events that do not change the value. * * * @see {@link markAsUntouched()} * @see {@link markAsDirty()} * @see {@link markAsPristine()} * * @param emitEvent When true or not supplied, the meta$ observable emits an event. Default is true. * @param markAncestors When true, marks all ancestors of the control as well */ markAsTouched: (markAncestors?: boolean, emitEvent?: boolean) => TChild; /** * Marks the control and all its descendant controls as `touched`. * @see {@link markAsTouched()} * * @param emitEvent When true or not supplied, the meta$ observable emits an event. Default is true. */ markAllAsTouched: (emitEvent?: boolean) => TChild; /** * Marks the control as `untouched`. * * If the control has any children, also marks all children as `untouched` * and recalculates the `touched` status of all parent controls. * * @see {@link markAsTouched()} * @see {@link markAsDirty()} * @see {@link markAsPristine()} * * @param emitEvent When true or not supplied, the meta$ observable emits an event. Default is true. * @param markAncestors When true, mark only this control. When false or not supplied, * marks all direct ancestors. Default is false. */ markAsUntouched: (emitEvent?: boolean, markAncestors?: boolean) => TChild; /** * Marks the control as `dirty`. A control becomes dirty when * the control's value is changed through the UI; compare `markAsTouched`. * * If the control is already dirty this does nothing * * @see {@link markAsTouched()} * @see {@link markAsUntouched()} * @see {@link markAsPristine()} * * @param emitEvent When true or not supplied, the meta$ observable emits an event. Default is true. * @param markAncestors When true, mark only this control. When false or not supplied, * marks all direct ancestors. Default is false. */ markAsDirty: (emitEvent?: boolean, markAncestors?: boolean) => TChild; /** * Marks the control as `pristine`. * * If the control has any children, marks all children as `pristine`, * and recalculates the `pristine` status of all parent * controls. * * If the control is already pristine, this does nothing * * @see {@link markAsTouched()} * @see {@link markAsUntouched()} * @see {@link markAsDirty()} * * @param emitEvent When true or not supplied, the meta$ observable emits an event. Default is true. * @param markAncestors When true, mark only this control. When false or not supplied, * marks all direct ancestors. Default is false. */ markAsPristine: (emitEvent?: boolean, markAncestors?: boolean) => TChild; /** * Disables the control. This means the control is exempt from validation checks and * excluded from the aggregate value of any parent. Its validity is `DISABLED`. * * If the control has children, all children are also disabled. * * If the control is already disabled, this does nothing. * * @see {@link AbstractControlMeta.validity} * * @param emitEvent When true or not supplied, the meta$ observable emits an event. Default is true. * @param markAncestors When true, mark only this control. When false or not supplied, * marks all direct ancestors. Default is false. */ disable: (emitEvent?: boolean, markAncestors?: boolean) => TChild; /** * Enables the control. This means the control is included in validation checks and * the aggregate value of its parent. Its status recalculates based on its value and * its validators. * * By default, if the control has children, all children are enabled. * * If the control is already enabled, this does nothing. * * @see {@link AbstractControl.status} * * @param emitEvent When true or not supplied, the meta$ observable emits an event. Default is true. * @param markAncestors When true, mark only this control. When false or not supplied, * marks all direct ancestors. Default is false. */ enable: (emitEvent?: boolean, markAncestors?: boolean) => TChild; } interface Hierarchy { /** * The parent of this control */ readonly parent: AC | undefined; /** * The root of this control. This is the top level control in the tree. */ readonly root: AC | undefined; readonly childList$: BehaviorSubject; readonly $childList: Signal; getChild: (path?: string[] | string) => AC | undefined; get hierarchyData(): HierarchyData; } interface HierarchyData { status: FormControlStatus; value: unknown; meta: Meta; children?: Record; } type ValidationErrors = Record; type ValidatorFn = (control: AbstractControl) => ValidationErrors | null; type AsyncValidatorFn = (control: AbstractControl) => Promise | Observable; interface ValidatorFns { /** * Returns the function that is used to determine the validity of this control synchronously. * If multiple validators have been added, this will be a single composed function. * See `Validators.compose()` for additional information. */ get validator(): ValidatorFn | null; /** * Sets the function that is used to determine the validity of this control synchronously. * It's recommended to use 'setValidators' or 'addValidators' instead, which will compose this function */ set validator(validator: ValidatorFn | null); /** * Returns the function that is used to determine the validity of this control asynchronously. * If multiple validators have been added, this will be a single composed function. * See `Validators.compose()` for additional information. */ get asyncValidator(): AsyncValidatorFn | null; /** * Sets the function that is used to determine the validity of this control asynchronously. * It's recommended to use 'setAsyncValidators' or 'addAsyncValidators' instead, which will compose this function */ set asyncValidator(asyncValidatorFn: AsyncValidatorFn | null); /** * Sets the synchronous validators that are active on this control. Calling * this overwrites any existing synchronous validators. * * When you add or remove a validator at run time, you must call * `updateValueAndValidity()` for the new validation to take effect. * * If you want to add a new validator without affecting existing ones, consider * using `addValidators()` method instead. */ setValidators: (validators: ValidatorFn | ValidatorFn[] | null) => TChild; /** * Sets the asynchronous validators that are active on this control. Calling this * overwrites any existing asynchronous validators. * * When you add or remove a validator at run time, you must call * `updateValueAndValidity()` for the new validation to take effect. * * If you want to add a new validator without affecting existing ones, consider * using `addAsyncValidators()` method instead. */ setAsyncValidators: (validators: AsyncValidatorFn | AsyncValidatorFn[] | null) => TChild; /** * Add a synchronous validator or validators to this control, without affecting other validators. * * When you add or remove a validator at run time, you must call * `updateValueAndValidity()` for the new validation to take effect. * * Adding a validator that already exists will have no effect. If duplicate validator functions * are present in the `validators` array, only the first instance would be added to a form * control. * * @param validators The new validator function or functions to add to this control. */ addValidators: (validators: ValidatorFn | ValidatorFn[]) => TChild; /** * Add an asynchronous validator or validators to this control, without affecting other * validators. * * When you add or remove a validator at run time, you must call * `updateValueAndValidity()` for the new validation to take effect. * * Adding a validator that already exists will have no effect. * * @param validators The new asynchronous validator function or functions to add to this control. */ addAsyncValidators: (validators: AsyncValidatorFn | AsyncValidatorFn[]) => TChild; /** * Remove a synchronous validator from this control, without affecting other validators. * Validators are compared by function reference; you must pass a reference to the exact same * validator function as the one that was originally set. If a provided validator is not found, * it is ignored. * * @usageNotes * * ### Reference to a ValidatorFn * * ``` * // Reference to the RequiredValidator * const ctrl = new FormControl('', Validators.required); * ctrl.removeValidators(Validators.required); * * // Reference to anonymous function inside MinValidator * const minValidator = Validators.min(3); * const ctrl = new FormControl('', minValidator); * expect(ctrl.hasValidator(minValidator)).toEqual(true) * expect(ctrl.hasValidator(Validators.min(3))).toEqual(false) * * ctrl.removeValidators(minValidator); * ``` * * When you add or remove a validator at run time, you must call * `updateValueAndValidity()` for the new validation to take effect. * * @param validators The validator or validators to remove. */ removeValidators: (validators: ValidatorFn | ValidatorFn[]) => TChild; /** * Remove an asynchronous validator from this control, without affecting other validators. * Validators are compared by function reference; you must pass a reference to the exact same * validator function as the one that was originally set. If a provided validator is not found, it * is ignored. * * When you add or remove a validator at run time, you must call * `updateValueAndValidity()` for the new validation to take effect. * * @param validators The asynchronous validator or validators to remove. */ removeAsyncValidators: (validators: AsyncValidatorFn | AsyncValidatorFn[]) => TChild; /** * Check whether a synchronous validator function is present on this control. The provided * validator must be a reference to the exact same function that was provided. * * @usageNotes * * ### Reference to a ValidatorFn * * ``` * // Reference to the RequiredValidator * const ctrl = new FormControl(0, Validators.required); * expect(ctrl.hasValidator(Validators.required)).toEqual(true) * * // Reference to anonymous function inside MinValidator * const minValidator = Validators.min(3); * const ctrl = new FormControl(0, minValidator); * expect(ctrl.hasValidator(minValidator)).toEqual(true) * expect(ctrl.hasValidator(Validators.min(3))).toEqual(false) * ``` * * @param validator The validator to check for presence. Compared by function reference. * @returns Whether the provided validator was found on this control. */ hasValidator: (validator: ValidatorFn) => boolean; /** * Check whether an asynchronous validator function is present on this control. The provided * validator must be a reference to the exact same function that was provided. * * @param validator The asynchronous validator to check for presence. Compared by function * reference. * @returns Whether the provided asynchronous validator was found on this control. */ hasAsyncValidator: (validator: AsyncValidatorFn) => boolean; /** * Empties out the synchronous validator list. * * When you add or remove a validator at run time, you must call * `updateValueAndValidity()` for the new validation to take effect. * */ clearValidators: () => TChild; /** * Empties out the async validator list. * * When you add or remove a validator at run time, you must call * `updateValueAndValidity()` for the new validation to take effect. * */ clearAsyncValidators: () => TChild; } interface RegisterFns { enableChange: (callback: (enabled: boolean) => void) => TChild; metaChange: (callback: (meta: Meta) => void) => TChild; alwaysDisabled: () => TChild; } interface AC { readonly type: 'array' | 'control' | 'group'; readonly meta$: ReadonlyBehaviorSubject; readonly $meta: Signal; /** * Checks if the control is invalid. * This is a promise as async validators may be involved. * @returns */ isInvalid: () => Promise; readonly value$: Observable; readonly $value: Signal; readonly defaultValue: unknown; readonly submitted$: Observable; readonly reset$: Observable; readonly hierarchy: Hierarchy; readonly validatorFn: ValidatorFns; readonly metaFn: MetaFns; readonly registerFn: RegisterFns; /** * Recalculates the value and validation status of the control. * @param includeAncestors Also update the value and validity of ancestor controls. * @param includeDescendants Also update the value and validity of descendant controls. * @param markAsTouched If not provided or true, mark the control as touched. * @param markAsDirty If not provided or true, mark the control as dirty. * @param emitEvent If not provided or true, emits the valueChanges event after updating the value and validity. * @returns */ updateValueAndValidity: (includeAncestors: boolean, includeDescendants: boolean, markAsTouched: boolean, markAsDirty: boolean, emitEvent?: boolean) => void; destroy: () => void; } type PrimitiveWithUndefined = Primitive | undefined; interface FcRegisterFns extends RegisterFns> { /** * Registers a callback to be called when the value of the control changes. * The callback is always called initially. * @param callback * @param alsoRunOnEnabled Whether to also run the callback when the control is enabled. * @param alsoRunOnDisabled Whether to also run the callback when the control is disabled. */ valueChange: (callback: (value: T, oldValue: T | undefined, control: FC) => void, alsoRunOnEnabled?: boolean, alsoRunOnDisabled?: boolean) => FC; } interface FC extends AC { value$: Observable; $value: Signal; submitted$: Observable; reset$: Observable; validatorFn: ValidatorFns>; metaFn: MetaFns>; registerFn: FcRegisterFns; /** * Sets a new value for the form control. * * @param value The new value for the control. * @param options Configuration options that determine how the control propagates changes * and emits events when the value changes. * The configuration options are passed to the {@link AbstractControl#updateValueAndValidity * updateValueAndValidity} method. * * * `onlySelf`: When true, each change only affects this control, and not its parent. Default is * false. * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and * `valueChanges` * observables emit events with the latest status and value when the control value is updated. * When false, no events are emitted. * * `emitModelToViewChange`: Only for FormControls. When true or not supplied (the default), each change triggers an * `onChange` event to * update the view. * * `emitViewToModelChange`: Only for FormControls. When true or not supplied (the default), each change triggers an * `ngModelChange` * event to update the model. * */ setValue: (value: T, options?: { onlySelf?: boolean; emitEvent?: boolean; emitModelToViewChange?: boolean; emitViewToModelChange?: boolean; }) => void; /** * Resets the control, marking it `pristine` and `untouched`, and resetting * the value to its initial value * * @param updateParentsValue If true, updates the value of parent controls. * @param emitEvent If true, emits the `valueChanges` event after resetting. */ resetWithDefaultValue: (updateParentsValue?: boolean, emitEvent?: boolean) => void; /** * Resets the form control, marking it `pristine` and `untouched`, and resetting * the value to the provided value * @param value * @param updateParentsValue If true, updates the value of parent controls. * @param emitEvent If true, emits the `valueChanges` event after resetting. * @returns */ reset: (value: T, updateParentsValue?: boolean, emitEvent?: boolean) => void; } interface FgRegisterFns> extends RegisterFns> { /** * Registers a callback to be called when the value of the group changes. * The callback is always called initially. * @param callback * @param alsoRunOnEnabled Whether to also run the callback when the control is enabled. * @param alsoRunOnDisabled Whether to also run the callback when the control is disabled. */ valueChange: (callback: (value: DeepPartial, oldValue: DeepPartial | undefined, control: FG) => void, alsoRunOnEnabled?: boolean, alsoRunOnDisabled?: boolean) => FG; /** * Registers a callback to be called when the value of a child control changes * The callback is always called initially. * @param callback * @param alsoRunOnEnabled Whether to also run the callback when the control is enabled. * @param alsoRunOnDisabled Whether to also run the callback when the control is disabled. */ childChange: (formControlSelector: (children: FormReferencesOf) => FC, callback: (group: FG, control: FC, value: T) => void, alsoRunOnEnabled?: boolean, alsoRunOnDisabled?: boolean) => FG; /** * Registers a callback to be called when the value of a child group changes * The callback is always called initially. * @param callback * @param alsoRunOnEnabled Whether to also run the callback when the control is enabled. * @param alsoRunOnDisabled Whether to also run the callback when the control is disabled. */ childGroupChange: >(formControlSelector: (children: FormReferencesOf) => FG, callback: (group: FG, control: FG, value: DeepPartial) => void, alsoRunOnEnabled?: boolean, alsoRunOnDisabled?: boolean) => FG; } interface FG> extends AC { readonly controls: FormReferencesOf; value$: Observable>; $value: Signal>; rawValue$: Observable; $rawValue: Signal; submitted$: Observable>; reset$: Observable>; validatorFn: ValidatorFns>; metaFn: MetaFns>; registerFn: FgRegisterFns; /** * Sets a new value for the form control. * * @param value The new value for the control. * @param options Configuration options that determine how the control propagates changes * and emits events when the value changes. * The configuration options are passed to the {@link AbstractControl#updateValueAndValidity * updateValueAndValidity} method. * * * `onlySelf`: When true, each change only affects this control, and not its parent. Default is * false. * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and * `valueChanges` * observables emit events with the latest status and value when the control value is updated. * When false, no events are emitted. * * `emitModelToViewChange`: Only for FormControls. When true or not supplied (the default), each change triggers an * `onChange` event to * update the view. * * `emitViewToModelChange`: Only for FormControls. When true or not supplied (the default), each change triggers an * `ngModelChange` * event to update the model. * */ setValue: (value: T, options?: { onlySelf?: boolean; emitEvent?: boolean; emitModelToViewChange?: boolean; emitViewToModelChange?: boolean; }) => void; /** * Resets the control, marking it `pristine` and `untouched`, and resetting * the value to its initial value * * @param updateParentsValue If true, updates the value of parent controls. * @param emitEvent If true, emits the `valueChanges` event after resetting. */ resetWithDefaultValue: (updateParentsValue?: boolean, emitEvent?: boolean) => void; /** * Resets the form control, marking it `pristine` and `untouched`, and resetting * the value to the provided value * @param value * @param updateParentsValue If true, updates the value of parent controls. * @param emitEvent If true, emits the `valueChanges` event after resetting. * @returns */ reset: (value: T, updateParentsValue?: boolean, emitEvent?: boolean) => void; } interface FaRegisterFns> extends RegisterFns> { /** * Registers a callback to be called when the value of the array changes. * The callback is always called initially. * @param callback * @param alsoRunOnEnabled Whether to also run the callback when the control is enabled. * @param alsoRunOnDisabled Whether to also run the callback when the control is disabled. */ valueChange: (callback: (value: DeepPartial[], oldValue: DeepPartial[] | undefined, controls: FG[], control: FA) => void, alsoRunOnEnabled?: boolean, alsoRunOnDisabled?: boolean) => FA; } interface FA> extends AC { controls$: Observable[]>; $controls: Signal[]>; value$: Observable[]>; $value: Signal[]>; rawValue$: Observable; $rawValue: Signal; submitted$: Observable[]>; reset$: Observable[]>; validatorFn: ValidatorFns>; metaFn: MetaFns>; registerFn: FaRegisterFns; push: (control: FG, options?: { emitEvent?: boolean; }) => void; removeAt: (index: number, destroyControl: boolean, options?: { emitEvent?: boolean; }) => void; insert: (index: number, control: FG, options?: { emitEvent?: boolean; }) => void; clear: (destroyControls: boolean, options?: { emitEvent?: boolean; }) => void; at: (index: number) => FG | undefined; /** * Resets the control, marking it `pristine` and `untouched`, and resetting * the value to its initial value * * @param updateParentsValue If true, updates the value of parent controls. * @param emitEvent If true, emits the `valueChanges` event after resetting. */ resetWithDefaultValue: (updateParentsValue?: boolean, emitEvent?: boolean) => void; /** * Resets the form control, marking it `pristine` and `untouched`, and resetting * the value to the provided value * @param value * @param updateParentsValue If true, updates the value of parent controls. * @param emitEvent If true, emits the `valueChanges` event after resetting. * @returns */ reset: (value: T[], updateParentsValue?: boolean, emitEvent?: boolean) => void; } type FormReferencesOf> = { [K in keyof T]-?: NonNullable extends (infer U)[] ? U extends Record ? FA | NonNullable> : NonNullable extends Primitive ? FC : undefined : NonNullable extends Primitive ? FC : NonNullable extends Record ? FG> : undefined; }; declare class FB { control(value: T, validators?: ValidatorFn | ValidatorFn[], asyncValidators?: AsyncValidatorFn | AsyncValidatorFn[], initialDisabled?: boolean, updateOn?: 'blur' | 'change' | 'submit'): FC; group>(controls: FormReferencesOf, validators?: ValidatorFn | ValidatorFn[], asyncValidators?: AsyncValidatorFn | AsyncValidatorFn[], updateOn?: 'blur' | 'change' | 'submit'): FG; array>(controls: FG[], validators?: ValidatorFn | ValidatorFn[], asyncValidators?: AsyncValidatorFn | AsyncValidatorFn[], updateOn?: 'blur' | 'change' | 'submit'): FA; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } type ControlsOf> = { [K in keyof T]-?: NonNullable extends Array ? U extends Record ? Extract | FormArray | FormGroup>>> : FormControl : NonNullable extends Date ? FormControl : NonNullable extends Record ? FormGroup>> | Extract : FormControl; }; declare class FormErrorPipe implements PipeTransform { transform(meta: Meta | null | undefined, specificError: string, requireTouched?: boolean, log?: boolean): Primitive; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class FormHasErrorPipe implements PipeTransform { transform(meta: Meta | null | undefined, specificError?: string, requireTouched?: boolean, log?: boolean): boolean; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class FormMetaPipe implements PipeTransform { transform(form: AC | null | undefined, path?: string): Observable; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class FormArrayPipe implements PipeTransform { transform(form: AC, path?: string): FormArray; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class FormControlPipe implements PipeTransform { transform(form: AC, path?: string): FormControl; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class FormGroupPipe implements PipeTransform { transform(form: AC, path?: string): FormGroup; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class FormArrayValuePipe implements PipeTransform { transform = any>(formRef: FA | null | undefined, kind?: TKind): Observable : TItem[]>; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class FormControlValuePipe implements PipeTransform { transform(group: FC | null | undefined): rxjs.Observable; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class FormGroupValuePipe implements PipeTransform { transform = any>(group: FG | null | undefined, kind?: TKind): Observable : T>; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class FormArrayControlsPipe implements PipeTransform { transform(form: FA): rxjs.Observable[]>; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class TableauUiFormModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } export { FB, FormArrayControlsPipe, FormArrayPipe, FormArrayValuePipe, FormControlPipe, FormControlValuePipe, FormErrorPipe, FormGroupPipe, FormGroupValuePipe, FormHasErrorPipe, FormMetaPipe, TableauUiFormModule }; export type { AC, AsyncValidatorFn, ControlsOf, FA, FC, FG, FaRegisterFns, FcRegisterFns, FgRegisterFns, FormReferencesOf, Hierarchy, HierarchyData, Meta, MetaFns, RegisterFns, ValidationErrors, ValidatorFn, ValidatorFns };