@alauda-fe/common
Version:
Alauda frontend team common codes.
59 lines (58 loc) • 2.88 kB
TypeScript
import { AfterViewInit, ChangeDetectorRef, OnDestroy, QueryList } from '@angular/core';
import { AbstractControl, ControlValueAccessor, FormGroupDirective, NgControl, NgForm, ValidationErrors } from '@angular/forms';
import { ReplaySubject, Subject, Observable } from 'rxjs';
import * as i0 from "@angular/core";
export declare function createNestedFormControl<V, M = V>({ autoEmitChange, asyncValidator, }?: {
autoEmitChange?: boolean;
asyncValidator?: boolean;
}): new () => BaseNestedFormControl<V, M>;
export declare class BaseNestedFormControl<V, M = V> implements AfterViewInit, OnDestroy, ControlValueAccessor {
protected controls: QueryList<NgControl>;
get disabled(): boolean | '';
set disabled(val: boolean | '');
private _disabled;
onValidatorChange: () => void;
onChange: (_: V) => void;
onTouched: () => void;
onSubmitted: () => void;
model: M;
submitted: boolean;
protected autoEmitChange: boolean;
protected asyncValidator: boolean;
protected cdr: ChangeDetectorRef;
protected destroy$$: Subject<void>;
protected hostForm: FormGroupDirective | NgForm;
constructor();
ngAfterViewInit(): void;
ngOnDestroy(): void;
registerOnValidatorChange(fn: () => void): void;
registerOnChange(fn: (_: V) => void): void;
registerOnTouched(fn: () => void): void;
setDisabledState(isDisabled: boolean): void;
writeValue(value: V): void;
validate(_control?: AbstractControl): ValidationErrors | null | Observable<ValidationErrors | null>;
emitModel(model?: M): void;
emitValue(value: V): void;
protected valueIn(value: V): M;
protected modelOut(model: M): V;
static ɵfac: i0.ɵɵFactoryDeclaration<BaseNestedFormControl<any, any>, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<BaseNestedFormControl<any, any>, never, never, { "disabled": { "alias": "disabled"; "required": false; }; }, {}, never, never, false, never>;
}
/**
* @deprecated use {@link BaseNestedFormControl} instead.
*/
export declare class BaseNestedFormControlPure<V, M = V> extends BaseNestedFormControl<V, M> {
model$: ReplaySubject<M>;
constructor();
writeValue(value: V): void;
emitValue(value: V): void;
static ɵfac: i0.ɵɵFactoryDeclaration<BaseNestedFormControlPure<any, any>, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<BaseNestedFormControlPure<any, any>, never, never, {}, {}, never, never, false, never>;
}
type Path = string | Array<string | number>;
interface Mapper {
[x: string]: Mapper | Path;
}
export declare function dataTransfer<S extends object, T extends object, M extends Record<keyof T, Path | Mapper> = Record<keyof T, Path | Mapper>>(mapper: M): [(source: S) => T, (target: T) => S];
export declare function copyValue<T extends object>(from: Path, to: Path, mapper?: (v: any) => any): (object: T) => T;
export {};