projects/ng-dynamic-forms/core/src/lib/model/input/dynamic-input.model.ts
constructor(config: DynamicInputModelConfig, layout?: DynamicFormControlLayout)
|
|||||||||
Parameters :
|
Private _list |
Type : any[] | null
|
Default value : null
|
Decorators :
@serializable('list')
|
Private Readonly _listId |
Type : string | null
|
Default value : null
|
accept |
Type : string | null
|
Decorators :
@serializable()
|
files |
Type : FileList | null
|
Default value : null
|
inputType |
Type : string
|
Decorators :
@serializable()
|
list$ |
Type : Observable<any[]> | null
|
Default value : null
|
mask |
Type : string | RegExp | Function | (string | RegExp)[] | null
|
Decorators :
@serializable()
|
max |
Type : number | string | Date | null
|
Decorators :
@serializable()
|
min |
Type : number | string | Date | null
|
Decorators :
@serializable()
|
multiple |
Type : boolean | null
|
Decorators :
@serializable()
|
pattern |
Type : string | null
|
Decorators :
@serializable()
|
step |
Type : number | null
|
Decorators :
@serializable()
|
Readonly type |
Type : string
|
Default value : DYNAMIC_FORM_CONTROL_TYPE_INPUT
|
Decorators :
@serializable()
|
autoComplete |
Type : string
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:21
|
autoFocus |
Type : boolean
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:22
|
maxLength |
Type : number | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:23
|
minLength |
Type : number | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:24
|
placeholder |
Type : string
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:25
|
prefix |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:26
|
readOnly |
Type : boolean
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:27
|
spellCheck |
Type : boolean
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:28
|
suffix |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:29
|
Private _value |
Type : T | null
|
Decorators :
@serializable('value')
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:22
|
additional |
Type : literal type | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:18
|
hint |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:19
|
required |
Type : boolean
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:20
|
tabIndex |
Type : number | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:21
|
Private Readonly value$ |
Type : BehaviorSubject<T>
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:24
|
Readonly valueChanges |
Type : Observable<T>
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:26
|
_disabled |
Type : boolean
|
Decorators :
@serializable('disabled')
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:28
|
asyncValidators |
Type : DynamicValidatorsConfig | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:27
|
controlTooltip |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:34
|
Private Readonly disabled$ |
Type : BehaviorSubject<boolean>
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:42
|
Readonly disabledChanges |
Type : Observable<boolean>
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:44
|
errorMessages |
Type : DynamicValidatorsConfig | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:29
|
hidden |
Type : boolean
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:30
|
id |
Type : string
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:31
|
label |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:32
|
labelTooltip |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:33
|
layout |
Type : DynamicFormControlLayout | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:35
|
name |
Type : string
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:36
|
parent |
Type : DynamicPathable | null
|
Default value : null
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:37
|
relations |
Type : DynamicFormControlRelation[]
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:38
|
Abstract Readonly type |
Type : string
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:46
|
updateOn |
Type : DynamicFormHook | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:39
|
validators |
Type : DynamicValidatorsConfig | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:40
|
_disabled |
Type : boolean
|
Decorators :
@serializable('disabled')
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:28
|
asyncValidators |
Type : DynamicValidatorsConfig | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:27
|
controlTooltip |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:34
|
Private Readonly disabled$ |
Type : BehaviorSubject<boolean>
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:42
|
Readonly disabledChanges |
Type : Observable<boolean>
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:44
|
errorMessages |
Type : DynamicValidatorsConfig | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:29
|
hidden |
Type : boolean
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:30
|
id |
Type : string
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:31
|
label |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:32
|
labelTooltip |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:33
|
layout |
Type : DynamicFormControlLayout | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:35
|
name |
Type : string
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:36
|
parent |
Type : DynamicPathable | null
|
Default value : null
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:37
|
relations |
Type : DynamicFormControlRelation[]
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:38
|
Abstract Readonly type |
Type : string
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:46
|
updateOn |
Type : DynamicFormHook | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:39
|
validators |
Type : DynamicValidatorsConfig | null
|
Decorators :
@serializable()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:40
|
Private _value |
Type : T | null
|
Decorators :
@serializable('value')
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:22
|
additional |
Type : literal type | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:18
|
hint |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:19
|
required |
Type : boolean
|
Decorators :
@serializable()
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:20
|
tabIndex |
Type : number | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:21
|
Private Readonly value$ |
Type : BehaviorSubject<T>
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:24
|
Readonly valueChanges |
Type : Observable<T>
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:26
|
_disabled |
Type : boolean
|
Decorators :
@serializable('disabled')
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:28
|
asyncValidators |
Type : DynamicValidatorsConfig | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:27
|
controlTooltip |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:34
|
Private Readonly disabled$ |
Type : BehaviorSubject<boolean>
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:42
|
Readonly disabledChanges |
Type : Observable<boolean>
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:44
|
errorMessages |
Type : DynamicValidatorsConfig | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:29
|
hidden |
Type : boolean
|
Decorators :
@serializable()
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:30
|
id |
Type : string
|
Decorators :
@serializable()
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:31
|
label |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:32
|
labelTooltip |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:33
|
layout |
Type : DynamicFormControlLayout | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:35
|
name |
Type : string
|
Decorators :
@serializable()
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:36
|
parent |
Type : DynamicPathable | null
|
Default value : null
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:37
|
relations |
Type : DynamicFormControlRelation[]
|
Decorators :
@serializable()
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:38
|
Abstract Readonly type |
Type : string
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:46
|
updateOn |
Type : DynamicFormHook | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:39
|
validators |
Type : DynamicValidatorsConfig | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:40
|
_disabled |
Type : boolean
|
Decorators :
@serializable('disabled')
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:28
|
asyncValidators |
Type : DynamicValidatorsConfig | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:27
|
controlTooltip |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:34
|
Private Readonly disabled$ |
Type : BehaviorSubject<boolean>
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:42
|
Readonly disabledChanges |
Type : Observable<boolean>
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:44
|
errorMessages |
Type : DynamicValidatorsConfig | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:29
|
hidden |
Type : boolean
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:30
|
id |
Type : string
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:31
|
label |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:32
|
labelTooltip |
Type : string | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:33
|
layout |
Type : DynamicFormControlLayout | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:35
|
name |
Type : string
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:36
|
parent |
Type : DynamicPathable | null
|
Default value : null
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:37
|
relations |
Type : DynamicFormControlRelation[]
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:38
|
Abstract Readonly type |
Type : string
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:46
|
updateOn |
Type : DynamicFormHook | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:39
|
validators |
Type : DynamicValidatorsConfig | null
|
Decorators :
@serializable()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:40
|
toJSON |
toJSON()
|
Returns :
any
|
getAdditional | |||||||||
getAdditional(key: string, defaultValue?: any | null)
|
|||||||||
Inherited from
DynamicInputControlModel
|
|||||||||
Defined in
DynamicInputControlModel:50
|
|||||||||
Parameters :
Returns :
any
|
toJSON |
toJSON()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:80
|
Returns :
any
|
toJSON |
toJSON()
|
Inherited from
DynamicInputControlModel
|
Defined in
DynamicInputControlModel:80
|
Returns :
any
|
getAdditional | |||||||||
getAdditional(key: string, defaultValue?: any | null)
|
|||||||||
Inherited from
DynamicFormValueControlModel
|
|||||||||
Defined in
DynamicFormValueControlModel:50
|
|||||||||
Parameters :
Returns :
any
|
toJSON |
toJSON()
|
Inherited from
DynamicFormValueControlModel
|
Defined in
DynamicFormValueControlModel:80
|
Returns :
any
|
toJSON |
toJSON()
|
Inherited from
DynamicFormControlModel
|
Defined in
DynamicFormControlModel:80
|
Returns :
any
|
listId |
getlistId()
|
hasList |
gethasList()
|
list | ||||
setlist(list)
|
||||
Parameters :
Returns :
void
|
import { DynamicInputControlModel, DynamicInputControlModelConfig } from "../dynamic-input-control.model";
import { DynamicFormControlLayout } from "../misc/dynamic-form-control-layout.model";
import { serializable } from "../../decorator/serializable.decorator";
import { maskToString } from "../../utils/json.utils";
import { isBoolean, isFunction, isNumber } from "../../utils/core.utils";
import { Observable, isObservable, of } from "rxjs";
import { tap } from "rxjs/operators";
export const DYNAMIC_FORM_CONTROL_TYPE_INPUT = "INPUT";
export const DYNAMIC_FORM_CONTROL_INPUT_TYPE_COLOR = "color";
export const DYNAMIC_FORM_CONTROL_INPUT_TYPE_DATE = "date";
//export const DYNAMIC_FORM_CONTROL_INPUT_TYPE_DATETIME = "datetime";
export const DYNAMIC_FORM_CONTROL_INPUT_TYPE_DATETIME_LOCAL = "datetime-local";
export const DYNAMIC_FORM_CONTROL_INPUT_TYPE_EMAIL = "email";
export const DYNAMIC_FORM_CONTROL_INPUT_TYPE_FILE = "file";
export const DYNAMIC_FORM_CONTROL_INPUT_TYPE_MONTH = "month";
export const DYNAMIC_FORM_CONTROL_INPUT_TYPE_NUMBER = "number";
export const DYNAMIC_FORM_CONTROL_INPUT_TYPE_PASSWORD = "password";
export const DYNAMIC_FORM_CONTROL_INPUT_TYPE_RANGE = "range";
export const DYNAMIC_FORM_CONTROL_INPUT_TYPE_SEARCH = "search";
export const DYNAMIC_FORM_CONTROL_INPUT_TYPE_TEL = "tel";
export const DYNAMIC_FORM_CONTROL_INPUT_TYPE_TEXT = "text";
export const DYNAMIC_FORM_CONTROL_INPUT_TYPE_TIME = "time";
export const DYNAMIC_FORM_CONTROL_INPUT_TYPE_URL = "url";
export const DYNAMIC_FORM_CONTROL_INPUT_TYPE_WEEK = "week";
export interface DynamicInputModelConfig extends DynamicInputControlModelConfig<string | number | Date | string[]> {
accept?: string;
inputType?: string;
list?: any[] | Observable<any[]>;
mask?: string | RegExp | Function | (string | RegExp)[];
max?: number | string | Date;
min?: number | string | Date;
multiple?: boolean;
pattern?: string;
step?: number;
}
export class DynamicInputModel extends DynamicInputControlModel<string | number | Date | string[]> {
@serializable() accept: string | null;
@serializable() inputType: string;
files: FileList | null = null;
list$: Observable<any[]> | null = null;
@serializable() mask: string | RegExp | Function | (string | RegExp)[] | null;
@serializable() max: number | string | Date | null;
@serializable() min: number | string | Date | null;
@serializable() multiple: boolean | null;
@serializable() pattern: string | null;
@serializable() step: number | null;
@serializable("list") private _list: any[] | null = null;
private readonly _listId: string | null = null;
@serializable() readonly type: string = DYNAMIC_FORM_CONTROL_TYPE_INPUT;
constructor(config: DynamicInputModelConfig, layout?: DynamicFormControlLayout) {
super(config, layout);
this.accept = config.accept || null;
this.inputType = config.inputType || DYNAMIC_FORM_CONTROL_INPUT_TYPE_TEXT;
this.mask = config.mask || null;
this.max = config.max !== undefined ? config.max : null;
this.min = config.min !== undefined ? config.min : null;
this.multiple = isBoolean(config.multiple) ? config.multiple : null;
this.pattern = config.pattern || null;
this.step = isNumber(config.step) ? config.step : null;
if (config.list !== undefined) {
this.list = config.list;
this._listId = `${this.id}List`;
}
}
get listId(): string | null {
return this._listId;
}
get hasList(): boolean {
return isObservable(this.list$);
}
set list(list: any[] | Observable<any[]> | null) {
if (Array.isArray(list)) {
this._list = list;
this.list$ = of(this._list);
} else if (isObservable(list)) {
this.list$ = list.pipe(tap(list => this._list = list));
} else {
this._list = null;
this.list$ = null;
}
}
toJSON() {
const json: any = super.toJSON();
if (this.mask !== null) {
json.mask = isFunction(this.mask) ? this.mask : maskToString(this.mask);
}
return json;
}
}