@stemy/ngx-dynamic-form 10.2.22 → 12.0.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/bundles/stemy-ngx-dynamic-form.umd.js +1781 -902
- package/bundles/stemy-ngx-dynamic-form.umd.js.map +1 -1
- package/esm2015/ngx-dynamic-form/common-types.js +463 -7
- package/esm2015/ngx-dynamic-form/components/base/dynamic-form-base.component.js +87 -0
- package/esm2015/ngx-dynamic-form/components/dynamic-form/dynamic-form.component.js +91 -0
- package/esm2015/ngx-dynamic-form/components/dynamic-form-file/dynamic-form-file.component.js +112 -0
- package/esm2015/ngx-dynamic-form/components/dynamic-form-group/dynamic-form-group.component.js +19 -0
- package/esm2015/ngx-dynamic-form/components/dynamic-form-input/dynamic-form-input.component.js +69 -0
- package/esm2015/ngx-dynamic-form/components/dynamic-form-model/dynamic-form-model.component.js +23 -0
- package/esm2015/ngx-dynamic-form/components/dynamic-form-select/dynamic-form-select.component.js +73 -0
- package/esm2015/ngx-dynamic-form/components/dynamic-form-static/dynamic-form-static.component.js +20 -0
- package/esm2015/ngx-dynamic-form/components/dynamic-forms/dynamic-forms.component.js +134 -0
- package/esm2015/ngx-dynamic-form/directives/async-submit.directive.js +6 -17
- package/esm2015/ngx-dynamic-form/directives/dynamic-form-control.directive.js +32 -0
- package/esm2015/ngx-dynamic-form/directives/dynamic-form-group.directive.js +40 -0
- package/esm2015/ngx-dynamic-form/directives/dynamic-form-template.directive.js +38 -0
- package/esm2015/ngx-dynamic-form/ngx-dynamic-form.module.js +36 -35
- package/esm2015/ngx-dynamic-form/services/dynamic-form.service.js +41 -386
- package/esm2015/ngx-dynamic-form/services/form-utilities.js +108 -0
- package/esm2015/ngx-dynamic-form/services/open-api.service.js +130 -0
- package/esm2015/public_api.js +15 -6
- package/esm2015/stemy-ngx-dynamic-form.js +4 -3
- package/fesm2015/stemy-ngx-dynamic-form.js +1357 -594
- package/fesm2015/stemy-ngx-dynamic-form.js.map +1 -1
- package/ngx-dynamic-form/common-types.d.ts +181 -27
- package/ngx-dynamic-form/components/base/dynamic-form-base.component.d.ts +44 -0
- package/ngx-dynamic-form/components/dynamic-form/dynamic-form.component.d.ts +21 -0
- package/ngx-dynamic-form/components/dynamic-form-file/dynamic-form-file.component.d.ts +16 -0
- package/ngx-dynamic-form/components/dynamic-form-group/dynamic-form-group.component.d.ts +6 -0
- package/ngx-dynamic-form/components/dynamic-form-input/dynamic-form-input.component.d.ts +12 -0
- package/ngx-dynamic-form/components/dynamic-form-model/dynamic-form-model.component.d.ts +6 -0
- package/ngx-dynamic-form/components/dynamic-form-select/dynamic-form-select.component.d.ts +9 -0
- package/ngx-dynamic-form/components/dynamic-form-static/dynamic-form-static.component.d.ts +5 -0
- package/ngx-dynamic-form/components/dynamic-forms/dynamic-forms.component.d.ts +26 -0
- package/ngx-dynamic-form/directives/async-submit.directive.d.ts +1 -5
- package/ngx-dynamic-form/directives/dynamic-form-control.directive.d.ts +12 -0
- package/ngx-dynamic-form/directives/dynamic-form-group.directive.d.ts +14 -0
- package/ngx-dynamic-form/directives/dynamic-form-template.directive.d.ts +16 -0
- package/ngx-dynamic-form/ngx-dynamic-form.module.d.ts +15 -5
- package/ngx-dynamic-form/services/dynamic-form.service.d.ts +11 -39
- package/ngx-dynamic-form/services/form-utilities.d.ts +19 -0
- package/ngx-dynamic-form/services/open-api.service.d.ts +37 -0
- package/package.json +16 -17
- package/public_api.d.ts +14 -5
- package/stemy-ngx-dynamic-form.d.ts +3 -2
- package/stemy-ngx-dynamic-form.metadata.json +1 -1
- package/bundles/stemy-ngx-dynamic-form.umd.min.js +0 -16
- package/bundles/stemy-ngx-dynamic-form.umd.min.js.map +0 -1
- package/esm2015/ngx-dynamic-form/components/base/dynamic-base-form-control-container.component.js +0 -91
- package/esm2015/ngx-dynamic-form/components/base/dynamic-base-form.component.js +0 -129
- package/esm2015/ngx-dynamic-form/services/dynamic-form-validation.service.js +0 -11
- package/esm2015/ngx-dynamic-form/utils/dynamic-form-array.model.js +0 -8
- package/esm2015/ngx-dynamic-form/utils/form-subject.js +0 -18
- package/esm2015/ngx-dynamic-form/utils/validators.js +0 -28
- package/ngx-dynamic-form/components/base/dynamic-base-form-control-container.component.d.ts +0 -37
- package/ngx-dynamic-form/components/base/dynamic-base-form.component.d.ts +0 -37
- package/ngx-dynamic-form/services/dynamic-form-validation.service.d.ts +0 -5
- package/ngx-dynamic-form/utils/dynamic-form-array.model.d.ts +0 -12
- package/ngx-dynamic-form/utils/form-subject.d.ts +0 -8
- package/ngx-dynamic-form/utils/validators.d.ts +0 -4
|
@@ -1,25 +1,33 @@
|
|
|
1
|
-
import { EventEmitter, TemplateRef } from "@angular/core";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export interface
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
serialize(validate?: boolean): Promise<any>;
|
|
1
|
+
import { ChangeDetectorRef, EventEmitter, InjectionToken, Injector, TemplateRef, Type, ValueProvider } from "@angular/core";
|
|
2
|
+
import { FormControl, FormGroup, ValidationErrors } from "@angular/forms";
|
|
3
|
+
import { IResolveFactory, IAsyncMessage, IRequestOptions } from "@stemy/ngx-utils";
|
|
4
|
+
export declare const FORM_GROUP_TYPE: InjectionToken<Type<IFormControlComponent>>;
|
|
5
|
+
export declare const FORM_CONTROL_PROVIDER: InjectionToken<IFormControlProvider>;
|
|
6
|
+
export interface IFormControlComponent {
|
|
7
|
+
control: IDynamicFormControl;
|
|
8
|
+
}
|
|
9
|
+
export interface IFormGroupComponent {
|
|
10
|
+
form: IDynamicForm;
|
|
11
|
+
control: IDynamicFormControl;
|
|
13
12
|
}
|
|
14
|
-
export
|
|
13
|
+
export declare abstract class FormControlComponent<T extends IFormControlData> implements IFormControlComponent {
|
|
14
|
+
control: IDynamicFormControl;
|
|
15
|
+
get form(): IDynamicFormBase;
|
|
16
|
+
get data(): T;
|
|
17
|
+
get value(): any;
|
|
18
|
+
get meta(): any;
|
|
19
|
+
get inputClass(): boolean;
|
|
15
20
|
}
|
|
16
|
-
export
|
|
17
|
-
|
|
21
|
+
export declare type IFormControlProviderAcceptor = (control: IDynamicFormControl) => boolean;
|
|
22
|
+
export declare type IFormControlProviderLoader = (control: IDynamicFormControl) => Promise<any>;
|
|
23
|
+
export declare type IFormControlOptions = (control: IDynamicFormControl) => Promise<IFormControlOption[]>;
|
|
24
|
+
export declare type IFormControlSerializer = (id: string, parent: IDynamicFormControl) => Promise<any>;
|
|
25
|
+
export interface IFormControlProvider {
|
|
26
|
+
component: Type<IFormControlComponent>;
|
|
27
|
+
priority: number;
|
|
28
|
+
acceptor: IFormControlProviderAcceptor;
|
|
29
|
+
loader: IFormControlProviderLoader;
|
|
18
30
|
}
|
|
19
|
-
export declare type IFormControlSerializer = (model: DynamicFormValueControlModel<any>, control: AbstractControl) => Promise<any>;
|
|
20
|
-
export declare type IFormInputMask = string | RegExp;
|
|
21
|
-
export declare type IFormInputMaskFunction = (raw: string) => IFormInputMask[];
|
|
22
|
-
export declare type IFormInputUnMaskFunction = (value: string) => any;
|
|
23
31
|
export interface IFormSerializer {
|
|
24
32
|
id: string;
|
|
25
33
|
func: IFormControlSerializer;
|
|
@@ -29,6 +37,106 @@ export interface IFormSerializers {
|
|
|
29
37
|
}
|
|
30
38
|
export declare type DynamicFormState = "VALID" | "INVALID" | "PENDING" | "DISABLED" | "LOADING";
|
|
31
39
|
export declare type DynamicFormUpdateOn = "change" | "blur" | "submit";
|
|
40
|
+
export interface IDynamicFormControl {
|
|
41
|
+
id: string;
|
|
42
|
+
type: string;
|
|
43
|
+
data: IFormControlData;
|
|
44
|
+
visible: boolean;
|
|
45
|
+
meta: any;
|
|
46
|
+
form: IDynamicFormBase;
|
|
47
|
+
injector: Injector;
|
|
48
|
+
label: string;
|
|
49
|
+
provider: IFormControlProvider;
|
|
50
|
+
model: any;
|
|
51
|
+
formId: string;
|
|
52
|
+
errors: ValidationErrors;
|
|
53
|
+
value: any;
|
|
54
|
+
touched: boolean;
|
|
55
|
+
disabled: boolean;
|
|
56
|
+
updateOn: DynamicFormUpdateOn;
|
|
57
|
+
setValue(value: any): void;
|
|
58
|
+
getData<T extends IFormControlData>(): T;
|
|
59
|
+
getControl(id: string): IDynamicFormControl;
|
|
60
|
+
load(): Promise<any>;
|
|
61
|
+
check(): Promise<any>;
|
|
62
|
+
shouldSerialize(): Promise<boolean>;
|
|
63
|
+
shouldValidate(): Promise<boolean>;
|
|
64
|
+
serialize(): Promise<any>;
|
|
65
|
+
onFocus(): void;
|
|
66
|
+
onBlur(): void;
|
|
67
|
+
showErrors(): void;
|
|
68
|
+
}
|
|
69
|
+
export declare class DynamicFormGroup extends FormGroup implements IDynamicFormControl {
|
|
70
|
+
readonly form: IDynamicFormBase;
|
|
71
|
+
get id(): string;
|
|
72
|
+
get type(): string;
|
|
73
|
+
get data(): IFormControlData;
|
|
74
|
+
get visible(): boolean;
|
|
75
|
+
get meta(): any;
|
|
76
|
+
get injector(): Injector;
|
|
77
|
+
get label(): string;
|
|
78
|
+
get provider(): IFormControlProvider;
|
|
79
|
+
get model(): any;
|
|
80
|
+
get formId(): string;
|
|
81
|
+
get formControls(): IDynamicFormControl[];
|
|
82
|
+
get formFields(): IDynamicFormFieldSets;
|
|
83
|
+
get prefix(): string;
|
|
84
|
+
get name(): string;
|
|
85
|
+
get state(): DynamicFormState;
|
|
86
|
+
private helper;
|
|
87
|
+
private mName;
|
|
88
|
+
private mModel;
|
|
89
|
+
private mControls;
|
|
90
|
+
private mSerializers;
|
|
91
|
+
private mFieldSets;
|
|
92
|
+
private initialized;
|
|
93
|
+
private loading;
|
|
94
|
+
private changeTimer;
|
|
95
|
+
private static createFormControls;
|
|
96
|
+
private static createFormSerializers;
|
|
97
|
+
constructor(form: IDynamicFormBase, control?: IFormControl);
|
|
98
|
+
getData<T extends IFormControlData>(): T;
|
|
99
|
+
getControl(id: string): IDynamicFormControl;
|
|
100
|
+
load(): Promise<any>;
|
|
101
|
+
check(): Promise<any>;
|
|
102
|
+
shouldSerialize(): Promise<boolean>;
|
|
103
|
+
shouldValidate(): Promise<boolean>;
|
|
104
|
+
serialize(): Promise<any>;
|
|
105
|
+
onFocus(): void;
|
|
106
|
+
onBlur(): void;
|
|
107
|
+
showErrors(): void;
|
|
108
|
+
reloadControls(): Promise<any>;
|
|
109
|
+
setup(model: any, info: IDynamicFormInfo): void;
|
|
110
|
+
updateModel(control: IDynamicFormControl): void;
|
|
111
|
+
private reloadControlsFrom;
|
|
112
|
+
}
|
|
113
|
+
export declare class DynamicFormControl extends FormControl implements IDynamicFormControl {
|
|
114
|
+
private control;
|
|
115
|
+
readonly group: DynamicFormGroup;
|
|
116
|
+
get id(): string;
|
|
117
|
+
get type(): string;
|
|
118
|
+
get data(): IFormControlData;
|
|
119
|
+
get visible(): boolean;
|
|
120
|
+
get meta(): any;
|
|
121
|
+
get form(): IDynamicFormBase;
|
|
122
|
+
get injector(): Injector;
|
|
123
|
+
get label(): string;
|
|
124
|
+
get provider(): IFormControlProvider;
|
|
125
|
+
get model(): any;
|
|
126
|
+
get formId(): string;
|
|
127
|
+
private helper;
|
|
128
|
+
constructor(control: IFormControl, group: DynamicFormGroup);
|
|
129
|
+
getData<T extends IFormControlData>(): T;
|
|
130
|
+
getControl(id: string): IDynamicFormControl;
|
|
131
|
+
load(): Promise<any>;
|
|
132
|
+
check(): Promise<any>;
|
|
133
|
+
shouldSerialize(): Promise<boolean>;
|
|
134
|
+
shouldValidate(): Promise<boolean>;
|
|
135
|
+
serialize(): Promise<any>;
|
|
136
|
+
onFocus(): void;
|
|
137
|
+
onBlur(): void;
|
|
138
|
+
showErrors(): void;
|
|
139
|
+
}
|
|
32
140
|
export interface IFormControl {
|
|
33
141
|
id: string;
|
|
34
142
|
type: string;
|
|
@@ -44,8 +152,8 @@ export interface IFormControlData {
|
|
|
44
152
|
hidden?: FormControlTesterFactory;
|
|
45
153
|
shouldSerialize?: FormControlTesterFactory;
|
|
46
154
|
shouldValidate?: FormControlTesterFactory;
|
|
47
|
-
validator?:
|
|
48
|
-
validators?:
|
|
155
|
+
validator?: FormControlValidatorFactory;
|
|
156
|
+
validators?: FormControlValidatorFactory[];
|
|
49
157
|
updateOn?: DynamicFormUpdateOn;
|
|
50
158
|
reload?: string | string[];
|
|
51
159
|
}
|
|
@@ -54,14 +162,12 @@ export interface IFormInputData extends IFormControlData {
|
|
|
54
162
|
autocomplete?: string;
|
|
55
163
|
placeholder?: string;
|
|
56
164
|
useLanguage?: boolean;
|
|
57
|
-
mask?: IFormInputMaskFunction | IFormInputMask[];
|
|
58
|
-
unmask?: IFormInputUnMaskFunction;
|
|
59
165
|
step?: number;
|
|
60
166
|
min?: number;
|
|
61
167
|
max?: number;
|
|
62
168
|
}
|
|
63
169
|
export interface IFormSelectData extends IFormControlData {
|
|
64
|
-
options?:
|
|
170
|
+
options?: IFormControlOptions | IResolveFactory;
|
|
65
171
|
emptyOption?: boolean;
|
|
66
172
|
type?: string;
|
|
67
173
|
multi?: boolean;
|
|
@@ -116,19 +222,55 @@ export interface IDynamicMultiFormConfig extends IDynamicFormConfig {
|
|
|
116
222
|
multi: true;
|
|
117
223
|
}
|
|
118
224
|
export declare type IDynamicFormsConfigs = Array<IDynamicSingleFormConfig | IDynamicMultiFormConfig>;
|
|
119
|
-
export
|
|
225
|
+
export interface IDynamicFormBase {
|
|
226
|
+
name?: string;
|
|
227
|
+
readonly?: boolean;
|
|
228
|
+
updateOn?: "change" | "blur" | "submit";
|
|
229
|
+
classes: string;
|
|
230
|
+
parent: IDynamicFormBase;
|
|
231
|
+
wrapperTemplate: TemplateRef<any>;
|
|
232
|
+
fieldSetTemplate: TemplateRef<any>;
|
|
233
|
+
controlTemplate: TemplateRef<any>;
|
|
234
|
+
controlTemplates: IDynamicFormTemplates;
|
|
235
|
+
labelTemplates: IDynamicFormTemplates;
|
|
236
|
+
inputTemplates: IDynamicFormTemplates;
|
|
237
|
+
prefixTemplates: IDynamicFormTemplates;
|
|
238
|
+
suffixTemplates: IDynamicFormTemplates;
|
|
239
|
+
setPrefixTemplates: IDynamicFormTemplates;
|
|
240
|
+
setSuffixTemplates: IDynamicFormTemplates;
|
|
241
|
+
onChange: EventEmitter<IDynamicFormControl>;
|
|
242
|
+
onStatusChange: EventEmitter<IDynamicFormBase>;
|
|
243
|
+
onInit: EventEmitter<IDynamicFormBase>;
|
|
244
|
+
onSubmit: EventEmitter<IDynamicFormBase>;
|
|
245
|
+
root?: IDynamicFormBase;
|
|
246
|
+
status: DynamicFormState;
|
|
247
|
+
injector?: Injector;
|
|
248
|
+
cdr?: ChangeDetectorRef;
|
|
249
|
+
validate(showErrors?: boolean): Promise<any>;
|
|
250
|
+
serialize(validate?: boolean): Promise<any>;
|
|
251
|
+
check(): Promise<any>;
|
|
252
|
+
getControl(id: string): IDynamicFormControl;
|
|
253
|
+
findProvider(control: IDynamicFormControl): IFormControlProvider;
|
|
254
|
+
}
|
|
255
|
+
export declare type AsyncSubmitMethod = (form: IDynamicFormBase) => Promise<IAsyncMessage>;
|
|
120
256
|
export interface IDynamicFormInfo {
|
|
257
|
+
group?: DynamicFormGroup;
|
|
121
258
|
name?: string;
|
|
122
259
|
controls?: IFormControl[];
|
|
123
260
|
serializers?: IFormSerializers;
|
|
124
261
|
fieldSets?: IFormFieldSet[];
|
|
125
262
|
}
|
|
263
|
+
export interface IDynamicForm extends IDynamicFormBase, IDynamicFormInfo {
|
|
264
|
+
data: any;
|
|
265
|
+
}
|
|
126
266
|
export interface IDynamicFormFieldSets {
|
|
127
267
|
[id: string]: IFormFieldSet;
|
|
128
268
|
}
|
|
129
|
-
export declare type FormControlTester = (control:
|
|
269
|
+
export declare type FormControlTester = (control: IDynamicFormControl) => Promise<boolean>;
|
|
130
270
|
export declare type FormControlTesterFactory = FormControlTester | IResolveFactory;
|
|
131
|
-
export declare
|
|
271
|
+
export declare type FormControlValidator = (control: IDynamicFormControl) => Promise<string | ValidationErrors>;
|
|
272
|
+
export declare type FormControlValidatorFactory = FormControlValidator | IResolveFactory;
|
|
273
|
+
export declare function defaultSerializer(id: string, parent: IDynamicFormControl): Promise<any>;
|
|
132
274
|
export declare function FormSerializable(serializer?: IFormControlSerializer | IResolveFactory): PropertyDecorator;
|
|
133
275
|
export declare function FormInput(data?: IFormInputData): PropertyDecorator;
|
|
134
276
|
export declare function FormSelect(data?: IFormSelectData): PropertyDecorator;
|
|
@@ -136,6 +278,18 @@ export declare function FormStatic(data?: IFormStaticData): PropertyDecorator;
|
|
|
136
278
|
export declare function FormModel(data?: IFormModelData): PropertyDecorator;
|
|
137
279
|
export declare function FormFile(data?: IFormFileData): PropertyDecorator;
|
|
138
280
|
export declare function FormFieldSet(data: IFormFieldSet): ClassDecorator;
|
|
281
|
+
export interface FormGroupProvider extends ValueProvider {
|
|
282
|
+
provide: InjectionToken<Type<IFormGroupComponent>>;
|
|
283
|
+
multi?: boolean;
|
|
284
|
+
useValue: Type<IFormGroupComponent>;
|
|
285
|
+
}
|
|
286
|
+
export declare function provideFormGroup(component: Type<IFormGroupComponent>): FormGroupProvider;
|
|
287
|
+
export interface FormControlProvider {
|
|
288
|
+
provide: InjectionToken<IFormControlProvider>;
|
|
289
|
+
multi?: boolean;
|
|
290
|
+
useValue: IFormControlProvider;
|
|
291
|
+
}
|
|
292
|
+
export declare function provideFormControl(component: Type<IFormControlComponent>, acceptor: IFormControlProviderAcceptor, loader: IFormControlProviderLoader, priority?: number): FormControlProvider;
|
|
139
293
|
export declare function defineFormControl(target: any, propertyKey: string, control: IFormControl): void;
|
|
140
294
|
export declare function getFormFieldSets(target: any): IDynamicFormFieldSets;
|
|
141
295
|
export declare function getFormControl(target: any, propertyKey: string): IFormControl;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AfterContentInit, ChangeDetectorRef, EventEmitter, Injector, QueryList, TemplateRef } from "@angular/core";
|
|
2
|
+
import { DynamicFormState, IDynamicFormBase, IDynamicFormControl, IDynamicFormTemplates, IFormControlProvider } from "../../common-types";
|
|
3
|
+
import { DynamicFormTemplateDirective } from "../../directives/dynamic-form-template.directive";
|
|
4
|
+
import { DynamicFormService } from "../../services/dynamic-form.service";
|
|
5
|
+
export declare abstract class DynamicFormBaseComponent implements IDynamicFormBase, AfterContentInit {
|
|
6
|
+
private formService;
|
|
7
|
+
name: string;
|
|
8
|
+
readonly: boolean;
|
|
9
|
+
updateOn: "change" | "blur" | "submit";
|
|
10
|
+
classes: any;
|
|
11
|
+
parent: IDynamicFormBase;
|
|
12
|
+
wrapperTemplate: TemplateRef<any>;
|
|
13
|
+
fieldSetTemplate: TemplateRef<any>;
|
|
14
|
+
controlTemplate: TemplateRef<any>;
|
|
15
|
+
controlTemplates: IDynamicFormTemplates;
|
|
16
|
+
labelTemplates: IDynamicFormTemplates;
|
|
17
|
+
inputTemplates: IDynamicFormTemplates;
|
|
18
|
+
prefixTemplates: IDynamicFormTemplates;
|
|
19
|
+
suffixTemplates: IDynamicFormTemplates;
|
|
20
|
+
setPrefixTemplates: IDynamicFormTemplates;
|
|
21
|
+
setSuffixTemplates: IDynamicFormTemplates;
|
|
22
|
+
onChange: EventEmitter<IDynamicFormControl>;
|
|
23
|
+
onStatusChange: EventEmitter<IDynamicFormBase>;
|
|
24
|
+
onInit: EventEmitter<IDynamicFormBase>;
|
|
25
|
+
onSubmit: EventEmitter<IDynamicFormBase>;
|
|
26
|
+
prefixTemplate: TemplateRef<any>;
|
|
27
|
+
suffixTemplate: TemplateRef<any>;
|
|
28
|
+
get root(): IDynamicFormBase;
|
|
29
|
+
abstract status: DynamicFormState;
|
|
30
|
+
readonly injector: Injector;
|
|
31
|
+
readonly cdr: ChangeDetectorRef;
|
|
32
|
+
protected templates: QueryList<DynamicFormTemplateDirective>;
|
|
33
|
+
protected cWrapperTemplate: TemplateRef<any>;
|
|
34
|
+
protected cFieldSetTemplate: TemplateRef<any>;
|
|
35
|
+
protected cControlTemplate: TemplateRef<any>;
|
|
36
|
+
protected constructor(cdr: ChangeDetectorRef, formService: DynamicFormService);
|
|
37
|
+
abstract validate(showErrors?: boolean): Promise<any>;
|
|
38
|
+
abstract serialize(validate?: boolean): Promise<any>;
|
|
39
|
+
abstract check(): Promise<any>;
|
|
40
|
+
abstract getControl(id: string): IDynamicFormControl;
|
|
41
|
+
findProvider(control: IDynamicFormControl): IFormControlProvider;
|
|
42
|
+
ngAfterContentInit(): void;
|
|
43
|
+
protected filterTemplates(templates: IDynamicFormTemplates, type: string): IDynamicFormTemplates;
|
|
44
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AfterContentInit, ChangeDetectorRef, OnChanges, SimpleChanges } from "@angular/core";
|
|
2
|
+
import { DynamicFormGroup, DynamicFormState, IDynamicForm, IDynamicFormControl, IFormControl, IFormFieldSet, IFormSerializers } from "../../common-types";
|
|
3
|
+
import { DynamicFormService } from "../../services/dynamic-form.service";
|
|
4
|
+
import { DynamicFormBaseComponent } from "../base/dynamic-form-base.component";
|
|
5
|
+
export declare class DynamicFormComponent extends DynamicFormBaseComponent implements IDynamicForm, AfterContentInit, OnChanges {
|
|
6
|
+
group: DynamicFormGroup;
|
|
7
|
+
controls: IFormControl[];
|
|
8
|
+
serializers: IFormSerializers;
|
|
9
|
+
fieldSets: IFormFieldSet[];
|
|
10
|
+
data: any;
|
|
11
|
+
defaultFieldSet: IFormFieldSet;
|
|
12
|
+
get status(): DynamicFormState;
|
|
13
|
+
get formControls(): IDynamicFormControl[];
|
|
14
|
+
constructor(cdr: ChangeDetectorRef, forms: DynamicFormService);
|
|
15
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
16
|
+
onFormSubmit(): void;
|
|
17
|
+
validate(showErrors?: boolean): Promise<any>;
|
|
18
|
+
serialize(validate?: boolean): Promise<any>;
|
|
19
|
+
check(): Promise<any>;
|
|
20
|
+
getControl(id: string): IDynamicFormControl;
|
|
21
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FormControlComponent, IDynamicFormControl, IFormFileData } from "../../common-types";
|
|
2
|
+
import { ApiService, IToasterService } from "@stemy/ngx-utils";
|
|
3
|
+
export declare class DynamicFormFileComponent extends FormControlComponent<IFormFileData> {
|
|
4
|
+
readonly api: ApiService;
|
|
5
|
+
readonly toaster: IToasterService;
|
|
6
|
+
private fileImageCache;
|
|
7
|
+
static acceptor(control: IDynamicFormControl): boolean;
|
|
8
|
+
static loader(): Promise<any>;
|
|
9
|
+
constructor(api: ApiService, toaster: IToasterService);
|
|
10
|
+
onSelect(input: HTMLInputElement): void;
|
|
11
|
+
protected processFiles(fileList: FileList): void;
|
|
12
|
+
protected upload(files: File[]): void;
|
|
13
|
+
delete(index?: number): void;
|
|
14
|
+
getUrl(image: any): string;
|
|
15
|
+
private getImgUrl;
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ILanguageService } from "@stemy/ngx-utils";
|
|
2
|
+
import { DynamicFormControl, FormControlComponent, IFormInputData } from "../../common-types";
|
|
3
|
+
export declare class DynamicFormInputComponent extends FormControlComponent<IFormInputData> {
|
|
4
|
+
private language;
|
|
5
|
+
static acceptor(control: DynamicFormControl): boolean;
|
|
6
|
+
static loader(): Promise<any>;
|
|
7
|
+
get isChecked(): boolean;
|
|
8
|
+
constructor(language: ILanguageService);
|
|
9
|
+
onDateChange(value: string): void;
|
|
10
|
+
onTextChange(value: string): void;
|
|
11
|
+
onNumberBlur(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DynamicFormControl, FormControlComponent, IFormModelData } from "../../common-types";
|
|
2
|
+
export declare class DynamicFormModelComponent extends FormControlComponent<IFormModelData> {
|
|
3
|
+
private subForm;
|
|
4
|
+
static acceptor(control: DynamicFormControl): boolean;
|
|
5
|
+
static loader(): Promise<any>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DynamicFormControl, FormControlComponent, IDynamicFormControl, IFormControlOption, IFormSelectData } from "../../common-types";
|
|
2
|
+
export declare class DynamicFormSelectComponent extends FormControlComponent<IFormSelectData> {
|
|
3
|
+
static acceptor(control: DynamicFormControl): boolean;
|
|
4
|
+
static loader(control: IDynamicFormControl): Promise<any>;
|
|
5
|
+
static fillOptions(control: IDynamicFormControl, options: IFormControlOption[]): void;
|
|
6
|
+
onSelectChange(value: any): void;
|
|
7
|
+
checkValue(option: IFormControlOption): boolean;
|
|
8
|
+
findOption(option: IFormControlOption, index: number, id: string): boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DynamicFormControl, FormControlComponent, IFormStaticData } from "../../common-types";
|
|
2
|
+
export declare class DynamicFormStaticComponent extends FormControlComponent<IFormStaticData> {
|
|
3
|
+
static acceptor(control: DynamicFormControl): boolean;
|
|
4
|
+
static loader(): Promise<any>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AfterContentInit, ChangeDetectorRef, OnChanges, SimpleChanges, TemplateRef } from "@angular/core";
|
|
2
|
+
import { DynamicFormState, IDynamicFormBase, IDynamicFormControl, IDynamicFormsConfigs, IDynamicFormTemplates } from "../../common-types";
|
|
3
|
+
import { DynamicFormBaseComponent } from "../base/dynamic-form-base.component";
|
|
4
|
+
import { DynamicFormService } from "../../services/dynamic-form.service";
|
|
5
|
+
export declare class DynamicFormsComponent extends DynamicFormBaseComponent implements IDynamicFormBase, AfterContentInit, OnChanges {
|
|
6
|
+
data: IDynamicFormsConfigs;
|
|
7
|
+
containerTemplate: TemplateRef<any>;
|
|
8
|
+
formPrefixTemplates: IDynamicFormTemplates;
|
|
9
|
+
formSuffixTemplates: IDynamicFormTemplates;
|
|
10
|
+
innerFormPrefixTemplates: IDynamicFormTemplates;
|
|
11
|
+
innerFormSuffixTemplates: IDynamicFormTemplates;
|
|
12
|
+
get status(): DynamicFormState;
|
|
13
|
+
configs: IDynamicFormsConfigs;
|
|
14
|
+
protected cContainerTemplate: TemplateRef<any>;
|
|
15
|
+
private forms;
|
|
16
|
+
constructor(cdr: ChangeDetectorRef, formService: DynamicFormService);
|
|
17
|
+
ngAfterContentInit(): void;
|
|
18
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
19
|
+
validate(showErrors?: boolean): Promise<any>;
|
|
20
|
+
serialize(validate?: boolean): Promise<any>;
|
|
21
|
+
check(): Promise<any>;
|
|
22
|
+
getControl(id: string): IDynamicFormControl;
|
|
23
|
+
private checkForms;
|
|
24
|
+
private getFromValue;
|
|
25
|
+
private createFormGroups;
|
|
26
|
+
}
|
|
@@ -3,12 +3,9 @@ import { IAsyncMessage, IToasterService } from "@stemy/ngx-utils";
|
|
|
3
3
|
import { AsyncSubmitMethod, IDynamicFormBase } from "../common-types";
|
|
4
4
|
export declare class AsyncSubmitDirective implements OnInit, OnDestroy {
|
|
5
5
|
private toaster;
|
|
6
|
-
|
|
7
|
-
readonly elem: ElementRef;
|
|
8
|
-
readonly renderer: Renderer2;
|
|
6
|
+
private cdr;
|
|
9
7
|
method: AsyncSubmitMethod;
|
|
10
8
|
form: IDynamicFormBase;
|
|
11
|
-
context: any;
|
|
12
9
|
onSuccess: EventEmitter<IAsyncMessage>;
|
|
13
10
|
onError: EventEmitter<IAsyncMessage>;
|
|
14
11
|
private loading;
|
|
@@ -17,7 +14,6 @@ export declare class AsyncSubmitDirective implements OnInit, OnDestroy {
|
|
|
17
14
|
private onStatusChange;
|
|
18
15
|
private onSubmit;
|
|
19
16
|
get isDisabled(): boolean;
|
|
20
|
-
set isDisabled(value: boolean);
|
|
21
17
|
get isLoading(): boolean;
|
|
22
18
|
constructor(toaster: IToasterService, cdr: ChangeDetectorRef, elem: ElementRef, renderer: Renderer2);
|
|
23
19
|
ngOnInit(): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OnChanges, SimpleChanges, ViewContainerRef } from "@angular/core";
|
|
2
|
+
import { IDynamicFormControl, IFormControlComponent } from "../common-types";
|
|
3
|
+
import { DynamicFormService } from "../services/dynamic-form.service";
|
|
4
|
+
export declare class DynamicFormControlDirective implements OnChanges {
|
|
5
|
+
private vcr;
|
|
6
|
+
private forms;
|
|
7
|
+
control: IDynamicFormControl;
|
|
8
|
+
get component(): IFormControlComponent;
|
|
9
|
+
private comp;
|
|
10
|
+
constructor(vcr: ViewContainerRef, forms: DynamicFormService);
|
|
11
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OnChanges, SimpleChanges, ViewContainerRef } from "@angular/core";
|
|
2
|
+
import { IDynamicForm, IDynamicFormControl, IFormControlComponent } from "../common-types";
|
|
3
|
+
import { DynamicFormService } from "../services/dynamic-form.service";
|
|
4
|
+
export declare class DynamicFormGroupDirective implements OnChanges {
|
|
5
|
+
private vcr;
|
|
6
|
+
private forms;
|
|
7
|
+
control: IDynamicFormControl;
|
|
8
|
+
form: IDynamicForm;
|
|
9
|
+
visible: boolean;
|
|
10
|
+
get component(): IFormControlComponent;
|
|
11
|
+
private comp;
|
|
12
|
+
constructor(vcr: ViewContainerRef, forms: DynamicFormService);
|
|
13
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TemplateRef } from "@angular/core";
|
|
2
|
+
export declare class DynamicFormTemplateDirective {
|
|
3
|
+
template: TemplateRef<any>;
|
|
4
|
+
control: string;
|
|
5
|
+
label: string;
|
|
6
|
+
input: string;
|
|
7
|
+
prefix: string;
|
|
8
|
+
suffix: string;
|
|
9
|
+
setPrefix: string;
|
|
10
|
+
setSuffix: string;
|
|
11
|
+
formPrefix: string;
|
|
12
|
+
formSuffix: string;
|
|
13
|
+
innerFormPrefix: string;
|
|
14
|
+
innerFormSuffix: string;
|
|
15
|
+
constructor(template: TemplateRef<any>);
|
|
16
|
+
}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { ModuleWithProviders } from "@angular/core";
|
|
2
|
+
import { FormControlProvider, FormGroupProvider } from "./common-types";
|
|
2
3
|
import { AsyncSubmitDirective } from "./directives/async-submit.directive";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { DynamicFormControlDirective } from "./directives/dynamic-form-control.directive";
|
|
5
|
+
import { DynamicFormGroupDirective } from "./directives/dynamic-form-group.directive";
|
|
6
|
+
import { DynamicFormTemplateDirective } from "./directives/dynamic-form-template.directive";
|
|
7
|
+
import { DynamicFormsComponent } from "./components/dynamic-forms/dynamic-forms.component";
|
|
8
|
+
import { DynamicFormComponent } from "./components/dynamic-form/dynamic-form.component";
|
|
9
|
+
import { DynamicFormGroupComponent } from "./components/dynamic-form-group/dynamic-form-group.component";
|
|
10
|
+
import { DynamicFormFileComponent } from "./components/dynamic-form-file/dynamic-form-file.component";
|
|
11
|
+
import { DynamicFormInputComponent } from "./components/dynamic-form-input/dynamic-form-input.component";
|
|
12
|
+
import { DynamicFormSelectComponent } from "./components/dynamic-form-select/dynamic-form-select.component";
|
|
13
|
+
import { DynamicFormStaticComponent } from "./components/dynamic-form-static/dynamic-form-static.component";
|
|
14
|
+
import { DynamicFormModelComponent } from "./components/dynamic-form-model/dynamic-form-model.component";
|
|
15
|
+
export declare const components: (typeof DynamicFormComponent | typeof DynamicFormsComponent | typeof DynamicFormGroupComponent | typeof DynamicFormFileComponent | typeof DynamicFormInputComponent | typeof DynamicFormSelectComponent | typeof DynamicFormStaticComponent | typeof DynamicFormModelComponent)[];
|
|
16
|
+
export declare const directives: (typeof AsyncSubmitDirective | typeof DynamicFormControlDirective | typeof DynamicFormTemplateDirective | typeof DynamicFormGroupDirective)[];
|
|
7
17
|
export declare const pipes: any[];
|
|
8
18
|
export declare class NgxDynamicFormModule {
|
|
9
|
-
static forRoot(): ModuleWithProviders<NgxDynamicFormModule>;
|
|
19
|
+
static forRoot(controlProviders?: Array<FormControlProvider>, groupProvider?: FormGroupProvider): ModuleWithProviders<NgxDynamicFormModule>;
|
|
10
20
|
}
|
|
@@ -1,40 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
protected schemas: IOpenApiSchemas;
|
|
13
|
-
constructor(cs: DynamicFormComponentService, vs: DynamicFormValidationService, openApi: OpenApiService);
|
|
14
|
-
patchGroup(value: any, formModel: DynamicFormModel, formGroup: FormGroup): void;
|
|
15
|
-
patchForm(value: any, component: DynamicFormComponent): void;
|
|
16
|
-
serialize(formModel: DynamicFormModel, formGroup: FormGroup): Promise<any>;
|
|
17
|
-
notifyChanges(formModel: DynamicFormModel, formGroup: FormGroup): void;
|
|
18
|
-
updateSelectOptions(formControlModel: DynamicFormControlModel, formControl: AbstractControl): void;
|
|
19
|
-
showErrors(form: DynamicFormComponent): void;
|
|
20
|
-
detectChanges(formComponent?: DynamicFormComponent): void;
|
|
21
|
-
protected patchValueRecursive(value: any, formModel: DynamicFormModel, formGroup: FormGroup): void;
|
|
22
|
-
protected serializeRecursive(formModel: DynamicFormModel, formGroup: FormGroup): Promise<any>;
|
|
23
|
-
protected notifyChangesRecursive(formModel: DynamicFormModel, formGroup: FormGroup): void;
|
|
24
|
-
protected showErrorsForGroup(formGroup: FormGroup): void;
|
|
25
|
-
protected showErrorsForControls(controls: AbstractControl[]): void;
|
|
26
|
-
getFormModelForSchema(name: string): Promise<DynamicFormModel>;
|
|
27
|
-
protected getFormModelForSchemaDef(schema: IOpenApiSchema): DynamicFormModel;
|
|
28
|
-
protected getFormControlModel(property: IOpenApiSchemaProperty, schema: IOpenApiSchema): DynamicFormControlModel;
|
|
29
|
-
protected getFormControlConfig(property: IOpenApiSchemaProperty, schema: IOpenApiSchema): DynamicFormValueControlModelConfig<any>;
|
|
30
|
-
protected getFormArrayConfig(property: IOpenApiSchemaProperty, schema: IOpenApiSchema): DynamicFormArrayModelConfig;
|
|
31
|
-
protected getFormGroupConfig(property: IOpenApiSchemaProperty, schema: IOpenApiSchema): DynamicFormGroupModelConfig;
|
|
32
|
-
protected getFormInputConfig(property: IOpenApiSchemaProperty, schema: IOpenApiSchema): DynamicInputModelConfig;
|
|
33
|
-
protected getFormTextareaConfig(property: IOpenApiSchemaProperty, schema: IOpenApiSchema): DynamicTextAreaModelConfig;
|
|
34
|
-
protected getFormSelectConfig(property: IOpenApiSchemaProperty, schema: IOpenApiSchema): DynamicSelectModelConfig<any>;
|
|
35
|
-
protected getFormCheckboxConfig(property: IOpenApiSchemaProperty, schema: IOpenApiSchema): DynamicCheckboxModelConfig;
|
|
36
|
-
protected translateOptions(options: DynamicFormOptionConfig<any>[]): Promise<DynamicFormOptionConfig<any>[]>;
|
|
37
|
-
protected getFormSelectOptions(property: IOpenApiSchemaProperty, schema: IOpenApiSchema): FormSubject<DynamicFormOptionConfig<any>[]>;
|
|
38
|
-
protected getFormUploadConfig(property: IOpenApiSchemaProperty, schema: IOpenApiSchema): DynamicFileUploadModelConfig;
|
|
39
|
-
protected getValidators(property: IOpenApiSchemaProperty, schema: IOpenApiSchema): DynamicValidatorsConfig;
|
|
1
|
+
import { ComponentFactoryResolver, Injector, Type, ViewContainerRef } from "@angular/core";
|
|
2
|
+
import { IDynamicFormControl, IFormControlComponent, IFormControlProvider, IFormGroupComponent } from "../common-types";
|
|
3
|
+
export declare class DynamicFormService {
|
|
4
|
+
private components;
|
|
5
|
+
private groupType;
|
|
6
|
+
private resolver;
|
|
7
|
+
readonly injector: Injector;
|
|
8
|
+
constructor(components: IFormControlProvider[], groupType: Type<IFormGroupComponent>, resolver: ComponentFactoryResolver, injector: Injector);
|
|
9
|
+
findProvider(control: IDynamicFormControl): IFormControlProvider;
|
|
10
|
+
createComponent(vcr: ViewContainerRef, provider: IFormControlProvider): IFormControlComponent;
|
|
11
|
+
createGroup(vcr: ViewContainerRef): IFormGroupComponent;
|
|
40
12
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DatePipe } from "@angular/common";
|
|
2
|
+
import { FormControlTester, FormControlValidator, IDynamicFormControl, IFormControlSerializer } from "../common-types";
|
|
3
|
+
export declare class FormUtilities {
|
|
4
|
+
static checkField(expression?: string): FormControlTester;
|
|
5
|
+
static checkReadonly(control: IDynamicFormControl): Promise<boolean>;
|
|
6
|
+
static readonly(): Promise<boolean>;
|
|
7
|
+
static validateJSON(control: IDynamicFormControl): Promise<string>;
|
|
8
|
+
static validateRequired(control: IDynamicFormControl): Promise<string>;
|
|
9
|
+
static validateMinLength(length: number): FormControlValidator;
|
|
10
|
+
static validateMaxLength(length: number): FormControlValidator;
|
|
11
|
+
static validateRequiredTranslation(control: IDynamicFormControl): Promise<string>;
|
|
12
|
+
static validateEmail(control: IDynamicFormControl): Promise<string>;
|
|
13
|
+
static validatePhone(control: IDynamicFormControl): Promise<string>;
|
|
14
|
+
static serializeLogo(id: string, parent: IDynamicFormControl): Promise<any>;
|
|
15
|
+
static serializeFile(id: string, parent: IDynamicFormControl): Promise<any>;
|
|
16
|
+
static serializeNumber(id: string, parent: IDynamicFormControl): Promise<any>;
|
|
17
|
+
static serializeJSON(id: string, parent: IDynamicFormControl): Promise<any>;
|
|
18
|
+
static serializeDate(date: DatePipe, format?: string, defaultValue?: string): IFormControlSerializer;
|
|
19
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ApiService } from "@stemy/ngx-utils";
|
|
2
|
+
import { IFormControl, IFormSerializers } from "../common-types";
|
|
3
|
+
export interface IOpenApiSchemaProperty {
|
|
4
|
+
id: string;
|
|
5
|
+
type: string;
|
|
6
|
+
format: string;
|
|
7
|
+
column: boolean;
|
|
8
|
+
additionalProperties: any;
|
|
9
|
+
$ref: string;
|
|
10
|
+
enum: string[];
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
export interface IOpenApiSchema {
|
|
14
|
+
properties: {
|
|
15
|
+
[name: string]: IOpenApiSchemaProperty;
|
|
16
|
+
};
|
|
17
|
+
required: string[];
|
|
18
|
+
}
|
|
19
|
+
export interface IDynamicFormInputs {
|
|
20
|
+
controls?: IFormControl[];
|
|
21
|
+
serializers?: IFormSerializers;
|
|
22
|
+
schema?: IOpenApiSchema;
|
|
23
|
+
}
|
|
24
|
+
export declare class OpenApiService {
|
|
25
|
+
private api;
|
|
26
|
+
private schemasPromise;
|
|
27
|
+
private schemas;
|
|
28
|
+
constructor(api: ApiService);
|
|
29
|
+
getFormInputsForSchema(name: string): Promise<IDynamicFormInputs>;
|
|
30
|
+
private getFormInputsForSchemaDef;
|
|
31
|
+
private getFormControlForProperty;
|
|
32
|
+
private getBaseFormData;
|
|
33
|
+
private getFormInputData;
|
|
34
|
+
private getFormSelectData;
|
|
35
|
+
private getFormFileData;
|
|
36
|
+
private getValidators;
|
|
37
|
+
}
|