@olafvv/ngx-dynamic-form 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +326 -3
- package/esm2022/lib/components/dynamic-form/dynamic-form.component.mjs +6 -15
- package/esm2022/lib/components/dynamic-form-field/dynamic-form-field.component.mjs +17 -13
- package/esm2022/lib/controls/button/dynamic-button.component.mjs +5 -6
- package/esm2022/lib/controls/button/dynamic-button.model.mjs +2 -3
- package/esm2022/lib/controls/button-toggles/dynamic-button-toggles.component.mjs +6 -6
- package/esm2022/lib/controls/button-toggles/dynamic-button-toggles.model.mjs +1 -3
- package/esm2022/lib/controls/checkbox/dynamic-checkbox.component.mjs +3 -3
- package/esm2022/lib/controls/controls.mjs +2 -1
- package/esm2022/lib/controls/datepicker/dynamic-datepicker.component.mjs +31 -0
- package/esm2022/lib/controls/datepicker/dynamic-datepicker.model.mjs +13 -0
- package/esm2022/lib/controls/input/dynamic-input.component.mjs +6 -6
- package/esm2022/lib/controls/input/dynamic-input.model.mjs +2 -1
- package/esm2022/lib/controls/radio-group/dynamic-radio-group.component.mjs +6 -6
- package/esm2022/lib/controls/readonly/dynamic-readonly.component.mjs +3 -3
- package/esm2022/lib/controls/select/dynamic-select.component.mjs +6 -9
- package/esm2022/lib/controls/textarea/dynamic-textarea.component.mjs +6 -6
- package/esm2022/lib/controls/textarea/dynamic-textarea.model.mjs +2 -1
- package/esm2022/lib/models/classes/dynamic-form-field-base.mjs +1 -1
- package/esm2022/lib/models/classes/dynamic-form-field-model.mjs +9 -2
- package/esm2022/lib/models/classes/dynamic-form-field-option-model.mjs +1 -1
- package/esm2022/lib/models/classes/dynamic-form-validators.mjs +21 -21
- package/esm2022/lib/models/constants/dynamic-relations.const.mjs +1 -1
- package/esm2022/lib/models/interfaces/dynamic-form-field-config.interface.mjs +1 -1
- package/esm2022/lib/models/interfaces/dynamic-form-field-relation.interface.mjs +1 -1
- package/esm2022/lib/services/dynamic-form-relations.service.mjs +13 -9
- package/esm2022/lib/services/dynamic-form.service.mjs +5 -5
- package/esm2022/lib/services/dynamic-validations.service.mjs +4 -4
- package/fesm2022/olafvv-ngx-dynamic-form.mjs +139 -107
- package/fesm2022/olafvv-ngx-dynamic-form.mjs.map +1 -1
- package/lib/components/dynamic-form/dynamic-form.component.d.ts +0 -7
- package/lib/components/dynamic-form-field/dynamic-form-field.component.d.ts +2 -2
- package/lib/controls/button/dynamic-button.model.d.ts +2 -4
- package/lib/controls/button-toggles/dynamic-button-toggles.model.d.ts +1 -7
- package/lib/controls/controls.d.ts +1 -0
- package/lib/controls/datepicker/dynamic-datepicker.component.d.ts +13 -0
- package/lib/controls/datepicker/dynamic-datepicker.model.d.ts +24 -0
- package/lib/controls/input/dynamic-input.model.d.ts +2 -0
- package/lib/controls/select/dynamic-select.component.d.ts +0 -2
- package/lib/controls/textarea/dynamic-textarea.model.d.ts +2 -0
- package/lib/models/classes/dynamic-form-field-model.d.ts +3 -1
- package/lib/models/classes/dynamic-form-validators.d.ts +12 -12
- package/lib/models/constants/dynamic-relations.const.d.ts +9 -1
- package/lib/models/interfaces/dynamic-form-field-config.interface.d.ts +7 -2
- package/lib/models/interfaces/dynamic-form-field-relation.interface.d.ts +9 -10
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './button-toggles/dynamic-button-toggles.model';
|
|
2
2
|
export * from './button/dynamic-button.model';
|
|
3
3
|
export * from './checkbox/dynamic-checkbox.model';
|
|
4
|
+
export * from './datepicker/dynamic-datepicker.model';
|
|
4
5
|
export * from './input/dynamic-input.model';
|
|
5
6
|
export * from './radio-group/dynamic-radio-group.model';
|
|
6
7
|
export * from './readonly/dynamic-readonly.model';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EventEmitter } from '@angular/core';
|
|
2
|
+
import { UntypedFormGroup } from '@angular/forms';
|
|
3
|
+
import { DynamicFormFieldBase } from '../../models/classes/dynamic-form-field-base';
|
|
4
|
+
import { DynamicFormFieldEvent } from '../../models/interfaces/dynamic-form-field-event.interface';
|
|
5
|
+
import { DynamicDatepicker } from './dynamic-datepicker.model';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
export declare class DynamicDatepickerComponent extends DynamicFormFieldBase {
|
|
8
|
+
model: DynamicDatepicker;
|
|
9
|
+
group: UntypedFormGroup;
|
|
10
|
+
change: EventEmitter<DynamicFormFieldEvent>;
|
|
11
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DynamicDatepickerComponent, never>;
|
|
12
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DynamicDatepickerComponent, "dynamic-datepicker", never, { "model": { "alias": "model"; "required": false; }; "group": { "alias": "group"; "required": false; }; }, { "change": "change"; }, never, never, true, never>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DynamicFormFieldValueConfig, DynamicFormFieldValueModel } from '../../models/classes/dynamic-form-field-value-model';
|
|
2
|
+
export declare const DYNAMIC_FORM_FIELD_DATEPICKER = "datepicker";
|
|
3
|
+
export type DynamicDatepickerControlValue = Date | object | string;
|
|
4
|
+
export interface DynamicDatepickerConfig extends DynamicFormFieldValueConfig<DynamicDatepickerControlValue> {
|
|
5
|
+
/**
|
|
6
|
+
* Maximum date selectable in the datepicker
|
|
7
|
+
* {DynamicDatepickerControlValue}
|
|
8
|
+
* */
|
|
9
|
+
max?: DynamicDatepickerControlValue;
|
|
10
|
+
/** Minimum date selectable in the datepicker */
|
|
11
|
+
min?: DynamicDatepickerControlValue;
|
|
12
|
+
/** The initial date visible inside the datepicker when opening the picker */
|
|
13
|
+
startAt?: DynamicDatepickerControlValue;
|
|
14
|
+
/** The view the picker is initializing when opening */
|
|
15
|
+
startView?: 'month' | 'year' | 'multi-year';
|
|
16
|
+
}
|
|
17
|
+
export declare class DynamicDatepicker extends DynamicFormFieldValueModel<DynamicDatepickerControlValue> {
|
|
18
|
+
max: DynamicDatepickerControlValue | null;
|
|
19
|
+
min: DynamicDatepickerControlValue | null;
|
|
20
|
+
startAt: DynamicDatepickerControlValue | null;
|
|
21
|
+
startView: 'month' | 'year' | 'multi-year';
|
|
22
|
+
readonly type = "datepicker";
|
|
23
|
+
constructor(config: DynamicDatepickerConfig);
|
|
24
|
+
}
|
|
@@ -3,6 +3,7 @@ export declare const DYNAMIC_FORM_FIELD_INPUT = "input";
|
|
|
3
3
|
export type HtmlInputType = 'text' | 'number' | 'tel' | 'email' | 'password' | 'date' | 'time' | 'color';
|
|
4
4
|
export interface DynamicInputConfig extends DynamicFormFieldValueConfig<string | number | Date | null> {
|
|
5
5
|
inputType?: HtmlInputType;
|
|
6
|
+
placeholder?: string;
|
|
6
7
|
max?: number;
|
|
7
8
|
min?: number;
|
|
8
9
|
maxLength?: number;
|
|
@@ -15,6 +16,7 @@ export interface DynamicInputConfig extends DynamicFormFieldValueConfig<string |
|
|
|
15
16
|
}
|
|
16
17
|
export declare class DynamicInput extends DynamicFormFieldValueModel<string | number | Date | null> {
|
|
17
18
|
inputType: HtmlInputType;
|
|
19
|
+
placeholder: string;
|
|
18
20
|
max: number | null;
|
|
19
21
|
min: number | null;
|
|
20
22
|
maxLength: number | null;
|
|
@@ -2,14 +2,12 @@ import { EventEmitter } from '@angular/core';
|
|
|
2
2
|
import { UntypedFormGroup } from '@angular/forms';
|
|
3
3
|
import { MatSelectChange } from '@angular/material/select';
|
|
4
4
|
import { DynamicFormFieldBase } from '../../models/classes/dynamic-form-field-base';
|
|
5
|
-
import { DynamicFormFieldOption } from '../../models/classes/dynamic-form-field-option-model';
|
|
6
5
|
import { DynamicSelect } from './dynamic-select.model';
|
|
7
6
|
import * as i0 from "@angular/core";
|
|
8
7
|
export declare class DynamicSelectComponent extends DynamicFormFieldBase {
|
|
9
8
|
model: DynamicSelect<string>;
|
|
10
9
|
group: UntypedFormGroup;
|
|
11
10
|
change: EventEmitter<MatSelectChange>;
|
|
12
|
-
trackByFn(index: number, option: DynamicFormFieldOption<unknown>): unknown;
|
|
13
11
|
static ɵfac: i0.ɵɵFactoryDeclaration<DynamicSelectComponent, never>;
|
|
14
12
|
static ɵcmp: i0.ɵɵComponentDeclaration<DynamicSelectComponent, "dynamic-select", never, { "model": { "alias": "model"; "required": false; }; "group": { "alias": "group"; "required": false; }; }, { "change": "change"; }, never, never, true, never>;
|
|
15
13
|
}
|
|
@@ -2,6 +2,7 @@ import { DynamicFormFieldValueConfig, DynamicFormFieldValueModel } from '../../m
|
|
|
2
2
|
export declare const DYNAMIC_FORM_FIELD_TEXTAREA = "textarea";
|
|
3
3
|
export type DynamicTextareaValue = string | null;
|
|
4
4
|
export interface DynamicTextareaConfig extends DynamicFormFieldValueConfig<DynamicTextareaValue> {
|
|
5
|
+
placeholder?: string;
|
|
5
6
|
minLength?: number;
|
|
6
7
|
maxLength?: number;
|
|
7
8
|
autocomplete?: 'on' | 'off';
|
|
@@ -10,6 +11,7 @@ export interface DynamicTextareaConfig extends DynamicFormFieldValueConfig<Dynam
|
|
|
10
11
|
resizeMaxRows?: number;
|
|
11
12
|
}
|
|
12
13
|
export declare class DynamicTextarea extends DynamicFormFieldValueModel<DynamicTextareaValue> {
|
|
14
|
+
placeholder: string;
|
|
13
15
|
minLength: number | null;
|
|
14
16
|
maxLength: number | null;
|
|
15
17
|
autocomplete: 'on' | 'off';
|
|
@@ -3,7 +3,6 @@ import { DynamicFormFieldConfig } from '../interfaces/dynamic-form-field-config.
|
|
|
3
3
|
import { DynamicFormFieldRelation } from '../interfaces/dynamic-form-field-relation.interface';
|
|
4
4
|
import { DynamicFormValidator } from '../interfaces/dynamic-form-validator.interface';
|
|
5
5
|
export declare abstract class DynamicFormFieldModel {
|
|
6
|
-
hidden: boolean;
|
|
7
6
|
id: string;
|
|
8
7
|
width: number;
|
|
9
8
|
label: string | null;
|
|
@@ -15,7 +14,10 @@ export declare abstract class DynamicFormFieldModel {
|
|
|
15
14
|
disabledChange: Observable<boolean>;
|
|
16
15
|
abstract readonly type: string;
|
|
17
16
|
private readonly disabled$;
|
|
17
|
+
private readonly $hidden;
|
|
18
18
|
constructor(config: DynamicFormFieldConfig);
|
|
19
19
|
get disabled(): boolean;
|
|
20
20
|
set disabled(disable: boolean);
|
|
21
|
+
get hidden(): boolean;
|
|
22
|
+
set hidden(hidden: boolean);
|
|
21
23
|
}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { DynamicFormValidator } from '../interfaces/dynamic-form-validator.interface';
|
|
2
2
|
export declare class DynamicFormValidators {
|
|
3
3
|
/**
|
|
4
|
-
* Default
|
|
5
|
-
* @param msg
|
|
6
|
-
*/
|
|
7
|
-
static required(msg?: string): DynamicFormValidator;
|
|
8
|
-
/**
|
|
9
|
-
* Ddefault requiredTrue validator, the value of the control has to be true
|
|
4
|
+
* Default email validator, the value of the control has to be a valid email address
|
|
10
5
|
* @param msg
|
|
11
6
|
*/
|
|
12
|
-
static
|
|
7
|
+
static email(msg?: string): DynamicFormValidator;
|
|
13
8
|
/**
|
|
14
9
|
* Default min validator, the value has to be greater or equal than the the provided number
|
|
15
10
|
* @param min number
|
|
@@ -34,15 +29,20 @@ export declare class DynamicFormValidators {
|
|
|
34
29
|
* @param msg
|
|
35
30
|
*/
|
|
36
31
|
static maxLength(max: number, msg?: string): DynamicFormValidator;
|
|
37
|
-
/**
|
|
38
|
-
* Ddefault email validator, the value of the control has to be a valid email address
|
|
39
|
-
* @param msg
|
|
40
|
-
*/
|
|
41
|
-
static email(msg?: string): DynamicFormValidator;
|
|
42
32
|
/**
|
|
43
33
|
* Default pattern validator, the value of the control has to match the provided pattern
|
|
44
34
|
* @param pattern: string | RegExp
|
|
45
35
|
* @param msg
|
|
46
36
|
*/
|
|
47
37
|
static pattern(pattern: string | RegExp, msg?: string): DynamicFormValidator;
|
|
38
|
+
/**
|
|
39
|
+
* Default required validator, the control must contain a value
|
|
40
|
+
* @param msg
|
|
41
|
+
*/
|
|
42
|
+
static required(msg?: string): DynamicFormValidator;
|
|
43
|
+
/**
|
|
44
|
+
* Default requiredTrue validator, the value of the control has to be true
|
|
45
|
+
* @param msg
|
|
46
|
+
*/
|
|
47
|
+
static requiredTrue(msg?: string): DynamicFormValidator;
|
|
48
48
|
}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Injector } from '@angular/core';
|
|
2
|
+
import { UntypedFormControl } from '@angular/forms';
|
|
3
|
+
import { DynamicFormFieldModel } from '../classes/dynamic-form-field-model';
|
|
4
|
+
import { RelationActionType } from '../interfaces/dynamic-form-field-relation.interface';
|
|
5
|
+
export interface DynamicRelationAction {
|
|
6
|
+
type: RelationActionType;
|
|
7
|
+
reversedType?: string;
|
|
8
|
+
change(hasMatch: boolean, model: DynamicFormFieldModel, control: UntypedFormControl, injector: Injector): void;
|
|
9
|
+
}
|
|
2
10
|
export declare const RELATION_ACTIONS: DynamicRelationAction[];
|
|
@@ -51,8 +51,13 @@ export interface DynamicFormFieldConfig {
|
|
|
51
51
|
relations?: DynamicFormFieldRelation[];
|
|
52
52
|
/**
|
|
53
53
|
* Event name for the control to update on.
|
|
54
|
-
*
|
|
55
|
-
*
|
|
54
|
+
* This will determine when Angular is checking the validators
|
|
55
|
+
* Possible values:
|
|
56
|
+
* - `change`: on every change event on the FormControl
|
|
57
|
+
* - `blur`: on the blur event of the FormControl
|
|
58
|
+
* - `submit`: when the parent form of the FormControl is submitted
|
|
59
|
+
*
|
|
60
|
+
* Default value is 'blur'.
|
|
56
61
|
* @optional
|
|
57
62
|
*/
|
|
58
63
|
updateOn?: 'submit' | 'blur' | 'change';
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { Injector } from '@angular/core';
|
|
2
|
-
import { UntypedFormControl } from '@angular/forms';
|
|
3
|
-
import { DynamicFormFieldModel } from '../classes/dynamic-form-field-model';
|
|
4
1
|
export declare enum RelationActionType {
|
|
5
2
|
DISABLED = "DISABLED",
|
|
6
3
|
ENABLED = "ENABLED",
|
|
@@ -14,16 +11,18 @@ export declare enum RelationOperator {
|
|
|
14
11
|
OR = "OR"
|
|
15
12
|
}
|
|
16
13
|
export interface RelationCondition {
|
|
17
|
-
|
|
14
|
+
/** Name of a field in the same form this field is depended on */
|
|
15
|
+
fieldName?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Path to the related field.
|
|
18
|
+
* This can be used when working with nested FormGroups and you want to relate a field in a different group.
|
|
19
|
+
* */
|
|
20
|
+
path?: string;
|
|
21
|
+
/** Method that returns true when the condition is met. The passed parameter is the value of the depended field */
|
|
18
22
|
value: (val: any) => boolean;
|
|
19
23
|
}
|
|
20
24
|
export interface DynamicFormFieldRelation {
|
|
21
25
|
actionType: RelationActionType;
|
|
22
|
-
operator?: RelationOperator;
|
|
23
26
|
conditions: RelationCondition[];
|
|
24
|
-
|
|
25
|
-
export interface DynamicRelationAction {
|
|
26
|
-
type: RelationActionType;
|
|
27
|
-
reversedType?: string;
|
|
28
|
-
change(hasMatch: boolean, model: DynamicFormFieldModel, control: UntypedFormControl, injector: Injector): void;
|
|
27
|
+
operator?: RelationOperator;
|
|
29
28
|
}
|