@olafvv/ngx-dynamic-form 0.3.0 → 0.5.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 +2 -2
- package/esm2022/lib/components/dynamic-form-field/dynamic-form-field.component.mjs +16 -10
- package/esm2022/lib/controls/button/dynamic-button.component.mjs +3 -4
- package/esm2022/lib/controls/button/dynamic-button.model.mjs +1 -1
- package/esm2022/lib/controls/button-toggles/dynamic-button-toggles.component.mjs +3 -3
- package/esm2022/lib/controls/button-toggles/dynamic-button-toggles.model.mjs +1 -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 -4
- package/esm2022/lib/controls/input/dynamic-input.model.mjs +3 -1
- package/esm2022/lib/controls/radio-group/dynamic-radio-group.model.mjs +1 -1
- package/esm2022/lib/controls/readonly/dynamic-readonly.model.mjs +1 -1
- package/esm2022/lib/controls/select/dynamic-select.model.mjs +1 -1
- package/esm2022/lib/controls/textarea/dynamic-textarea.model.mjs +1 -1
- package/esm2022/lib/models/classes/dynamic-form-field-base.mjs +4 -1
- package/esm2022/lib/models/classes/dynamic-form-field-model.mjs +4 -1
- package/esm2022/lib/models/classes/dynamic-form-field-value-model.mjs +11 -11
- 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.service.mjs +2 -2
- package/fesm2022/olafvv-ngx-dynamic-form.mjs +83 -39
- package/fesm2022/olafvv-ngx-dynamic-form.mjs.map +1 -1
- package/lib/components/dynamic-form-field/dynamic-form-field.component.d.ts +1 -0
- package/lib/controls/button/dynamic-button.model.d.ts +11 -1
- package/lib/controls/button-toggles/dynamic-button-toggles.model.d.ts +2 -8
- 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 +21 -0
- package/lib/controls/input/dynamic-input.model.d.ts +6 -2
- package/lib/controls/radio-group/dynamic-radio-group.model.d.ts +2 -2
- package/lib/controls/readonly/dynamic-readonly.model.d.ts +1 -1
- package/lib/controls/select/dynamic-select.model.d.ts +7 -0
- package/lib/controls/textarea/dynamic-textarea.model.d.ts +23 -0
- package/lib/models/classes/dynamic-form-field-base.d.ts +3 -0
- package/lib/models/classes/dynamic-form-field-model.d.ts +3 -0
- package/lib/models/classes/dynamic-form-field-value-model.d.ts +22 -7
- package/lib/models/interfaces/dynamic-form-field-config.interface.d.ts +14 -10
- package/lib/models/interfaces/dynamic-form-field-relation.interface.d.ts +2 -2
- package/package.json +1 -1
|
@@ -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,21 @@
|
|
|
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 | null;
|
|
4
|
+
export interface DynamicDatepickerConfig extends DynamicFormFieldValueConfig<DynamicDatepickerControlValue> {
|
|
5
|
+
/** Maximum date selectable in the datepicker */
|
|
6
|
+
max?: DynamicDatepickerControlValue;
|
|
7
|
+
/** Minimum date selectable in the datepicker */
|
|
8
|
+
min?: DynamicDatepickerControlValue;
|
|
9
|
+
/** The initial date visible inside the datepicker when opening the picker */
|
|
10
|
+
startAt?: DynamicDatepickerControlValue;
|
|
11
|
+
/** The view the picker is initializing when opening */
|
|
12
|
+
startView?: 'month' | 'year' | 'multi-year';
|
|
13
|
+
}
|
|
14
|
+
export declare class DynamicDatepicker extends DynamicFormFieldValueModel<DynamicDatepickerControlValue> {
|
|
15
|
+
max: DynamicDatepickerControlValue | null;
|
|
16
|
+
min: DynamicDatepickerControlValue | null;
|
|
17
|
+
startAt: DynamicDatepickerControlValue | null;
|
|
18
|
+
startView: 'month' | 'year' | 'multi-year';
|
|
19
|
+
readonly type = "datepicker";
|
|
20
|
+
constructor(config: DynamicDatepickerConfig);
|
|
21
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { WritableSignal } from '@angular/core';
|
|
1
2
|
import { DynamicFormFieldValueConfig, DynamicFormFieldValueModel } from '../../models/classes/dynamic-form-field-value-model';
|
|
2
3
|
export declare const DYNAMIC_FORM_FIELD_INPUT = "input";
|
|
3
4
|
export type HtmlInputType = 'text' | 'number' | 'tel' | 'email' | 'password' | 'date' | 'time' | 'color';
|
|
4
|
-
export
|
|
5
|
+
export type DynamicInputValue = string | number | Date | null;
|
|
6
|
+
export interface DynamicInputConfig extends DynamicFormFieldValueConfig<DynamicInputValue> {
|
|
5
7
|
inputType?: HtmlInputType;
|
|
6
8
|
placeholder?: string;
|
|
7
9
|
max?: number;
|
|
@@ -13,8 +15,9 @@ export interface DynamicInputConfig extends DynamicFormFieldValueConfig<string |
|
|
|
13
15
|
autocomplete?: 'on' | 'off';
|
|
14
16
|
prefix?: string;
|
|
15
17
|
hideClearIcon?: boolean;
|
|
18
|
+
showLoader?: WritableSignal<boolean>;
|
|
16
19
|
}
|
|
17
|
-
export declare class DynamicInput extends DynamicFormFieldValueModel<
|
|
20
|
+
export declare class DynamicInput extends DynamicFormFieldValueModel<DynamicInputValue> {
|
|
18
21
|
inputType: HtmlInputType;
|
|
19
22
|
placeholder: string;
|
|
20
23
|
max: number | null;
|
|
@@ -26,6 +29,7 @@ export declare class DynamicInput extends DynamicFormFieldValueModel<string | nu
|
|
|
26
29
|
autocomplete: 'on' | 'off';
|
|
27
30
|
prefix: string | null;
|
|
28
31
|
hideClearIcon: boolean;
|
|
32
|
+
showLoader: WritableSignal<boolean>;
|
|
29
33
|
readonly type = "input";
|
|
30
34
|
constructor(config: DynamicInputConfig);
|
|
31
35
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { DynamicFormFieldOptionConfig, DynamicFormFieldOptionModel } from '../../models/classes/dynamic-form-field-option-model';
|
|
2
2
|
export declare const DYNAMIC_FORM_FIELD_RADIO_GROUP = "radio-group";
|
|
3
|
-
export interface DynamicRadioGroupConfig extends DynamicFormFieldOptionConfig<string | number> {
|
|
3
|
+
export interface DynamicRadioGroupConfig extends DynamicFormFieldOptionConfig<string | number | null> {
|
|
4
4
|
/** Placement of the option label. Default is 'before' */
|
|
5
5
|
labelPosition?: 'before' | 'after';
|
|
6
6
|
/** Whether the options are shown inline (horizontally). Default is false */
|
|
7
7
|
inline?: boolean;
|
|
8
8
|
}
|
|
9
|
-
export declare class DynamicRadioGroup extends DynamicFormFieldOptionModel<string | number> {
|
|
9
|
+
export declare class DynamicRadioGroup extends DynamicFormFieldOptionModel<string | number | null> {
|
|
10
10
|
labelPosition: 'before' | 'after';
|
|
11
11
|
inline: boolean;
|
|
12
12
|
readonly type: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DynamicFormFieldValueConfig, DynamicFormFieldValueModel } from '../../models/classes/dynamic-form-field-value-model';
|
|
2
2
|
export declare const DYNAMIC_FORM_FIELD_READONLY = "readonly";
|
|
3
3
|
export type DynamicReadonlyValue = string | number | null;
|
|
4
|
-
export interface DynamicReadonlyConfig extends DynamicFormFieldValueConfig<DynamicReadonlyValue> {
|
|
4
|
+
export interface DynamicReadonlyConfig extends Omit<DynamicFormFieldValueConfig<DynamicReadonlyValue>, 'validators' | 'relations' | 'updateOn'> {
|
|
5
5
|
}
|
|
6
6
|
export declare class DynamicReadonly extends DynamicFormFieldValueModel<DynamicReadonlyValue> {
|
|
7
7
|
readonly type = "readonly";
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { DynamicFormFieldOptionConfig, DynamicFormFieldOptionModel } from '../../models/classes/dynamic-form-field-option-model';
|
|
2
2
|
export declare const DYNAMIC_FORM_FIELD_SELECT = "select";
|
|
3
3
|
export interface DynamicSelectConfig<T> extends DynamicFormFieldOptionConfig<T> {
|
|
4
|
+
/**
|
|
5
|
+
* Show the native dropdown instead of the Angular Material styled dropdown
|
|
6
|
+
*/
|
|
4
7
|
native?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Whether it is possible to select multiple options.
|
|
10
|
+
* Default value is false
|
|
11
|
+
*/
|
|
5
12
|
multiple?: boolean;
|
|
6
13
|
}
|
|
7
14
|
export declare class DynamicSelect<T> extends DynamicFormFieldOptionModel<T> {
|
|
@@ -2,12 +2,35 @@ 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
|
+
/**
|
|
6
|
+
* Placeholder text inside the textarea.
|
|
7
|
+
* Only visible when the field is empty and in focus.
|
|
8
|
+
*/
|
|
5
9
|
placeholder?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Minimum amount of characters needed in the textarea
|
|
12
|
+
*/
|
|
6
13
|
minLength?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Maximum amount of characters it is possible to fill in the textarea
|
|
16
|
+
*/
|
|
7
17
|
maxLength?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Enables or disabled the browser natie autocomplete bubble when the control is in focus.
|
|
20
|
+
* Default value is 'off'
|
|
21
|
+
*/
|
|
8
22
|
autocomplete?: 'on' | 'off';
|
|
23
|
+
/**
|
|
24
|
+
* Amount of rows the textarea initializes on
|
|
25
|
+
*/
|
|
9
26
|
rows?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the textare automatically resizes to fit its content
|
|
29
|
+
*/
|
|
10
30
|
resize?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Maximum amount of rows the textarea show resize to
|
|
33
|
+
*/
|
|
11
34
|
resizeMaxRows?: number;
|
|
12
35
|
}
|
|
13
36
|
export declare class DynamicTextarea extends DynamicFormFieldValueModel<DynamicTextareaValue> {
|
|
@@ -6,6 +6,9 @@ export interface DynamicFormField {
|
|
|
6
6
|
model: DynamicFormFieldModel;
|
|
7
7
|
change: EventEmitter<any>;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Base class for the DynamicFormField component classes
|
|
11
|
+
*/
|
|
9
12
|
export declare abstract class DynamicFormFieldBase implements DynamicFormField {
|
|
10
13
|
group: UntypedFormGroup;
|
|
11
14
|
model: DynamicFormFieldModel;
|
|
@@ -2,6 +2,9 @@ import { Observable } from 'rxjs';
|
|
|
2
2
|
import { DynamicFormFieldConfig } from '../interfaces/dynamic-form-field-config.interface';
|
|
3
3
|
import { DynamicFormFieldRelation } from '../interfaces/dynamic-form-field-relation.interface';
|
|
4
4
|
import { DynamicFormValidator } from '../interfaces/dynamic-form-validator.interface';
|
|
5
|
+
/**
|
|
6
|
+
* Base class for all DynamicFormFields
|
|
7
|
+
*/
|
|
5
8
|
export declare abstract class DynamicFormFieldModel {
|
|
6
9
|
id: string;
|
|
7
10
|
width: number;
|
|
@@ -1,18 +1,33 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
1
|
import { DynamicFormFieldConfig } from '../interfaces/dynamic-form-field-config.interface';
|
|
3
2
|
import { DynamicFormFieldModel } from './dynamic-form-field-model';
|
|
4
3
|
export interface DynamicFormFieldValueConfig<T> extends DynamicFormFieldConfig {
|
|
4
|
+
/**
|
|
5
|
+
* The value of the control.
|
|
6
|
+
* This value will change when the control is used.
|
|
7
|
+
* @optional
|
|
8
|
+
*/
|
|
5
9
|
value?: T;
|
|
10
|
+
/**
|
|
11
|
+
* The default value of the control when initializing or resetting the control.
|
|
12
|
+
* @optional
|
|
13
|
+
*/
|
|
6
14
|
defaultValue?: T;
|
|
15
|
+
/**
|
|
16
|
+
* A function that gets called everytime the value of the control changes.
|
|
17
|
+
* Passes the value of the control as parameter.
|
|
18
|
+
* If you don't want to get an event on every keystroke without delay, use the ReactiveFormsModule `valueChanges` Observable
|
|
19
|
+
* @optional
|
|
20
|
+
*/
|
|
21
|
+
valueChanged?: (val: T | null) => any;
|
|
7
22
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Base class for a DynamicFormField with a value
|
|
25
|
+
*/
|
|
26
|
+
export declare abstract class DynamicFormFieldValueModel<T = unknown> extends DynamicFormFieldModel {
|
|
27
|
+
defaultValue: T | null;
|
|
12
28
|
private _value$;
|
|
29
|
+
private _valueChanged;
|
|
13
30
|
constructor(config: DynamicFormFieldValueConfig<T>);
|
|
14
|
-
get defaultValue(): T | null;
|
|
15
|
-
set defaultValue(val: T | null);
|
|
16
31
|
get value(): T | null;
|
|
17
32
|
set value(val: T | null);
|
|
18
33
|
}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { DynamicFormFieldRelation } from './dynamic-form-field-relation.interface';
|
|
2
2
|
import { DynamicFormValidator } from './dynamic-form-validator.interface';
|
|
3
|
+
/**
|
|
4
|
+
* Base configuration object for each Dynamic Form Field.
|
|
5
|
+
* Expects a generic type describing the type of the value the control holds.
|
|
6
|
+
*/
|
|
3
7
|
export interface DynamicFormFieldConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Name used as FormControlName
|
|
10
|
+
* @required
|
|
11
|
+
*/
|
|
12
|
+
name: string;
|
|
4
13
|
/**
|
|
5
14
|
* Whether the control has to be disabled.
|
|
6
15
|
* Default value is false.
|
|
@@ -19,21 +28,11 @@ export interface DynamicFormFieldConfig {
|
|
|
19
28
|
* @optional
|
|
20
29
|
*/
|
|
21
30
|
id?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Sets the width of the field, based on percentages. Default value is 100.
|
|
24
|
-
* @optional
|
|
25
|
-
*/
|
|
26
|
-
width?: number;
|
|
27
31
|
/**
|
|
28
32
|
* Used as mat-label when provided
|
|
29
33
|
* @optional
|
|
30
34
|
*/
|
|
31
35
|
label?: string | null;
|
|
32
|
-
/**
|
|
33
|
-
* Name used as FormControlName
|
|
34
|
-
* @required
|
|
35
|
-
*/
|
|
36
|
-
name: string;
|
|
37
36
|
/**
|
|
38
37
|
* Hint text underneath the FormControl
|
|
39
38
|
* @optional
|
|
@@ -61,4 +60,9 @@ export interface DynamicFormFieldConfig {
|
|
|
61
60
|
* @optional
|
|
62
61
|
*/
|
|
63
62
|
updateOn?: 'submit' | 'blur' | 'change';
|
|
63
|
+
/**
|
|
64
|
+
* Sets the width of the field, based on percentages. Default value is 100.
|
|
65
|
+
* @optional
|
|
66
|
+
*/
|
|
67
|
+
width?: number;
|
|
64
68
|
}
|
|
@@ -15,8 +15,8 @@ export interface RelationCondition {
|
|
|
15
15
|
fieldName?: string;
|
|
16
16
|
/**
|
|
17
17
|
* Path to the related field.
|
|
18
|
-
* This
|
|
19
|
-
|
|
18
|
+
* This must be used when working with nested FormGroups and you want to relate a field in a different group.
|
|
19
|
+
*/
|
|
20
20
|
path?: string;
|
|
21
21
|
/** Method that returns true when the condition is met. The passed parameter is the value of the depended field */
|
|
22
22
|
value: (val: any) => boolean;
|