@ngx-formly/core 10.0.1 → 11.1.0-rc.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 +103 -173
- package/fesm2022/ngx-formly-core-json-schema.mjs +670 -842
- package/fesm2022/ngx-formly-core-json-schema.mjs.map +1 -1
- package/fesm2022/ngx-formly-core-preset.mjs +76 -57
- package/fesm2022/ngx-formly-core-preset.mjs.map +1 -1
- package/fesm2022/ngx-formly-core-select.mjs +192 -134
- package/fesm2022/ngx-formly-core-select.mjs.map +1 -1
- package/fesm2022/ngx-formly-core-testing.mjs +112 -87
- package/fesm2022/ngx-formly-core-testing.mjs.map +1 -1
- package/fesm2022/ngx-formly-core.mjs +3560 -3031
- package/fesm2022/ngx-formly-core.mjs.map +1 -1
- package/package.json +2 -2
- package/types/ngx-formly-core-json-schema.d.ts +39 -41
- package/types/ngx-formly-core-preset.d.ts +8 -12
- package/types/ngx-formly-core-select.d.ts +35 -40
- package/types/ngx-formly-core-testing.d.ts +27 -29
- package/types/ngx-formly-core.d.ts +764 -659
|
@@ -1,135 +1,193 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { NgModule, Pipe } from "@angular/core";
|
|
3
|
+
import { BehaviorSubject, isObservable } from "rxjs";
|
|
4
|
+
import { filter, map, tap } from "rxjs/operators";
|
|
5
|
+
var FormlySelectOptionsPipe = class FormlySelectOptionsPipe {
|
|
6
|
+
transform(options, field) {
|
|
7
|
+
if (!isObservable(options)) options = this.observableOf(options, field);
|
|
8
|
+
else this.dispose();
|
|
9
|
+
return options.pipe(map((value) => this.transformOptions(value, field)));
|
|
10
|
+
}
|
|
11
|
+
ngOnDestroy() {
|
|
12
|
+
this.dispose();
|
|
13
|
+
}
|
|
14
|
+
transformOptions(options, field) {
|
|
15
|
+
const to = this.transformSelectProps(field);
|
|
16
|
+
const opts = [];
|
|
17
|
+
const groups = {};
|
|
18
|
+
options?.forEach((option) => {
|
|
19
|
+
if (to.mapProp) {
|
|
20
|
+
const mapped = to.mapProp(option);
|
|
21
|
+
opts.push(mapped);
|
|
22
|
+
} else {
|
|
23
|
+
const o = this.transformOption(option, to);
|
|
24
|
+
if (o.group) {
|
|
25
|
+
const id = groups[o.label];
|
|
26
|
+
if (id === void 0) groups[o.label] = opts.push(o) - 1;
|
|
27
|
+
else o.group.forEach((o) => opts[id].group.push(o));
|
|
28
|
+
} else opts.push(o);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return opts;
|
|
32
|
+
}
|
|
33
|
+
transformOption(option, props) {
|
|
34
|
+
const group = props.groupProp(option);
|
|
35
|
+
if (Array.isArray(group)) return {
|
|
36
|
+
label: props.labelProp(option),
|
|
37
|
+
group: group.map((opt) => this.transformOption(opt, props))
|
|
38
|
+
};
|
|
39
|
+
option = {
|
|
40
|
+
label: props.labelProp(option),
|
|
41
|
+
value: props.valueProp(option),
|
|
42
|
+
disabled: !!props.disabledProp(option)
|
|
43
|
+
};
|
|
44
|
+
if (group) return {
|
|
45
|
+
label: group,
|
|
46
|
+
group: [option]
|
|
47
|
+
};
|
|
48
|
+
return option;
|
|
49
|
+
}
|
|
50
|
+
transformSelectProps(field) {
|
|
51
|
+
const props = field?.props || field?.templateOptions || {};
|
|
52
|
+
const selectPropFn = (prop) => typeof prop === "function" ? prop : (o) => o[prop];
|
|
53
|
+
return {
|
|
54
|
+
groupProp: selectPropFn(props.groupProp || "group"),
|
|
55
|
+
labelProp: selectPropFn(props.labelProp || "label"),
|
|
56
|
+
valueProp: selectPropFn(props.valueProp || "value"),
|
|
57
|
+
disabledProp: selectPropFn(props.disabledProp || "disabled"),
|
|
58
|
+
mapProp: props.mapProp
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
dispose() {
|
|
62
|
+
if (this._options) {
|
|
63
|
+
this._options.complete();
|
|
64
|
+
this._options = null;
|
|
65
|
+
}
|
|
66
|
+
if (this._subscription) {
|
|
67
|
+
this._subscription.unsubscribe();
|
|
68
|
+
this._subscription = null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
observableOf(options, f) {
|
|
72
|
+
this.dispose();
|
|
73
|
+
if (f && f.options && f.options.fieldChanges) this._subscription = f.options.fieldChanges.pipe(filter(({ property, type, field }) => {
|
|
74
|
+
return type === "expressionChanges" && (property.indexOf("templateOptions.options") === 0 || property.indexOf("props.options") === 0) && field === f && Array.isArray(field.props.options) && !!this._options;
|
|
75
|
+
}), tap(() => this._options.next(f.props.options))).subscribe();
|
|
76
|
+
this._options = new BehaviorSubject(options);
|
|
77
|
+
return this._options.asObservable();
|
|
78
|
+
}
|
|
79
|
+
static {
|
|
80
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
81
|
+
minVersion: "12.0.0",
|
|
82
|
+
version: "22.2.2",
|
|
83
|
+
ngImport: i0,
|
|
84
|
+
type: FormlySelectOptionsPipe,
|
|
85
|
+
deps: [],
|
|
86
|
+
target: i0.ɵɵFactoryTarget.Pipe
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
static {
|
|
90
|
+
this.ɵpipe = i0.ɵɵngDeclarePipe({
|
|
91
|
+
minVersion: "14.0.0",
|
|
92
|
+
version: "22.2.2",
|
|
93
|
+
ngImport: i0,
|
|
94
|
+
type: FormlySelectOptionsPipe,
|
|
95
|
+
isStandalone: true,
|
|
96
|
+
name: "formlySelectOptions"
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
101
|
+
minVersion: "12.0.0",
|
|
102
|
+
version: "22.2.2",
|
|
103
|
+
ngImport: i0,
|
|
104
|
+
type: FormlySelectOptionsPipe,
|
|
105
|
+
decorators: [{
|
|
106
|
+
type: Pipe,
|
|
107
|
+
args: [{
|
|
108
|
+
name: "formlySelectOptions",
|
|
109
|
+
standalone: true
|
|
110
|
+
}]
|
|
111
|
+
}]
|
|
112
|
+
});
|
|
113
|
+
var LegacyFormlySelectOptionsPipe = class LegacyFormlySelectOptionsPipe extends FormlySelectOptionsPipe {
|
|
114
|
+
static {
|
|
115
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
116
|
+
minVersion: "12.0.0",
|
|
117
|
+
version: "22.2.2",
|
|
118
|
+
ngImport: i0,
|
|
119
|
+
type: LegacyFormlySelectOptionsPipe,
|
|
120
|
+
deps: null,
|
|
121
|
+
target: i0.ɵɵFactoryTarget.Pipe
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
static {
|
|
125
|
+
this.ɵpipe = i0.ɵɵngDeclarePipe({
|
|
126
|
+
minVersion: "14.0.0",
|
|
127
|
+
version: "22.2.2",
|
|
128
|
+
ngImport: i0,
|
|
129
|
+
type: LegacyFormlySelectOptionsPipe,
|
|
130
|
+
isStandalone: false,
|
|
131
|
+
name: "formlySelectOptions"
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
136
|
+
minVersion: "12.0.0",
|
|
137
|
+
version: "22.2.2",
|
|
138
|
+
ngImport: i0,
|
|
139
|
+
type: LegacyFormlySelectOptionsPipe,
|
|
140
|
+
decorators: [{
|
|
141
|
+
type: Pipe,
|
|
142
|
+
args: [{
|
|
143
|
+
name: "formlySelectOptions",
|
|
144
|
+
standalone: false
|
|
145
|
+
}]
|
|
146
|
+
}]
|
|
147
|
+
});
|
|
148
|
+
var FormlySelectModule = class FormlySelectModule {
|
|
149
|
+
static {
|
|
150
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
151
|
+
minVersion: "12.0.0",
|
|
152
|
+
version: "22.2.2",
|
|
153
|
+
ngImport: i0,
|
|
154
|
+
type: FormlySelectModule,
|
|
155
|
+
deps: [],
|
|
156
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
static {
|
|
160
|
+
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
161
|
+
minVersion: "14.0.0",
|
|
162
|
+
version: "22.2.2",
|
|
163
|
+
ngImport: i0,
|
|
164
|
+
type: FormlySelectModule,
|
|
165
|
+
declarations: [LegacyFormlySelectOptionsPipe],
|
|
166
|
+
exports: [LegacyFormlySelectOptionsPipe]
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
static {
|
|
170
|
+
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
171
|
+
minVersion: "12.0.0",
|
|
172
|
+
version: "22.2.2",
|
|
173
|
+
ngImport: i0,
|
|
174
|
+
type: FormlySelectModule
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
179
|
+
minVersion: "12.0.0",
|
|
180
|
+
version: "22.2.2",
|
|
181
|
+
ngImport: i0,
|
|
182
|
+
type: FormlySelectModule,
|
|
183
|
+
decorators: [{
|
|
184
|
+
type: NgModule,
|
|
185
|
+
args: [{
|
|
186
|
+
declarations: [LegacyFormlySelectOptionsPipe],
|
|
187
|
+
exports: [LegacyFormlySelectOptionsPipe]
|
|
188
|
+
}]
|
|
189
|
+
}]
|
|
190
|
+
});
|
|
134
191
|
export { FormlySelectModule, FormlySelectOptionsPipe, LegacyFormlySelectOptionsPipe };
|
|
135
|
-
|
|
192
|
+
|
|
193
|
+
//# sourceMappingURL=ngx-formly-core-select.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-formly-core-select.mjs","sources":["../../../../src/core/select/src/select-options.pipe.ts","../../../../src/core/select/src/select.module.ts"
|
|
1
|
+
{"version":3,"file":"ngx-formly-core-select.mjs","names":[],"sources":["../../../../src/core/select/src/select-options.pipe.ts","../../../../src/core/select/src/select.module.ts"],"sourcesContent":["import { OnDestroy, Pipe, PipeTransform } from '@angular/core';\nimport { BehaviorSubject, isObservable, Observable, Subscription } from 'rxjs';\nimport { filter, map, tap } from 'rxjs/operators';\nimport { FormlyFieldConfig, FormlyFieldProps } from '@ngx-formly/core';\n\nexport interface FormlySelectOption {\n label: string;\n disabled?: boolean;\n value?: any;\n group?: FormlySelectOption[];\n}\n\nexport interface FormlyFieldSelectProps extends FormlyFieldProps {\n groupProp?: string | ((option: any) => string);\n labelProp?: string | ((option: any) => string);\n valueProp?: string | ((option: any) => any);\n disabledProp?: string | ((option: any) => boolean);\n mapProp?: (option: any) => FormlySelectOption;\n}\n\ntype ITransformOption = {\n labelProp: (option: any) => string;\n valueProp: (option: any) => any;\n disabledProp: (option: any) => boolean;\n groupProp: (option: any) => string;\n mapProp?: (option: any) => FormlySelectOption;\n};\n\n@Pipe({ name: 'formlySelectOptions', standalone: true })\nexport class FormlySelectOptionsPipe implements PipeTransform, OnDestroy {\n private _subscription: Subscription;\n private _options: BehaviorSubject<any[]>;\n\n transform(options: any, field?: FormlyFieldConfig): Observable<FormlySelectOption[]> {\n if (!isObservable(options)) {\n options = this.observableOf(options, field);\n } else {\n this.dispose();\n }\n\n return (options as Observable<any>).pipe(map((value) => this.transformOptions(value, field)));\n }\n\n ngOnDestroy(): void {\n this.dispose();\n }\n\n private transformOptions(options: any[], field?: FormlyFieldConfig): FormlySelectOption[] {\n const to = this.transformSelectProps(field);\n\n const opts: FormlySelectOption[] = [];\n const groups: { [id: string]: number } = {};\n\n options?.forEach((option) => {\n if (to.mapProp) {\n const mapped = to.mapProp(option);\n opts.push(mapped);\n } else {\n const o = this.transformOption(option, to);\n if (o.group) {\n const id = groups[o.label];\n if (id === undefined) {\n groups[o.label] = opts.push(o) - 1;\n } else {\n o.group.forEach((o) => opts[id].group.push(o));\n }\n } else {\n opts.push(o);\n }\n }\n });\n\n return opts;\n }\n\n private transformOption(option: any, props: ITransformOption): FormlySelectOption {\n const group = props.groupProp(option);\n if (Array.isArray(group)) {\n return {\n label: props.labelProp(option),\n group: group.map((opt) => this.transformOption(opt, props)),\n };\n }\n\n option = {\n label: props.labelProp(option),\n value: props.valueProp(option),\n disabled: !!props.disabledProp(option),\n };\n\n if (group) {\n return { label: group, group: [option] };\n }\n\n return option;\n }\n\n private transformSelectProps(field?: FormlyFieldConfig): ITransformOption {\n const props = field?.props || field?.templateOptions || {};\n const selectPropFn = (prop: any) => (typeof prop === 'function' ? prop : (o: any) => o[prop]);\n\n return {\n groupProp: selectPropFn(props.groupProp || 'group'),\n labelProp: selectPropFn(props.labelProp || 'label'),\n valueProp: selectPropFn(props.valueProp || 'value'),\n disabledProp: selectPropFn(props.disabledProp || 'disabled'),\n mapProp: props.mapProp,\n };\n }\n\n private dispose() {\n if (this._options) {\n this._options.complete();\n this._options = null;\n }\n\n if (this._subscription) {\n this._subscription.unsubscribe();\n this._subscription = null;\n }\n }\n\n private observableOf(options: any, f?: FormlyFieldConfig) {\n this.dispose();\n if (f && f.options && f.options.fieldChanges) {\n this._subscription = f.options.fieldChanges\n .pipe(\n filter(({ property, type, field }) => {\n return (\n type === 'expressionChanges' &&\n (property.indexOf('templateOptions.options') === 0 || property.indexOf('props.options') === 0) &&\n field === f &&\n Array.isArray(field.props.options) &&\n !!this._options\n );\n }),\n tap(() => this._options.next(f.props.options as any)),\n )\n .subscribe();\n }\n\n this._options = new BehaviorSubject(options);\n return this._options.asObservable();\n }\n}\n\n@Pipe({ name: 'formlySelectOptions', standalone: false })\nexport class LegacyFormlySelectOptionsPipe extends FormlySelectOptionsPipe implements PipeTransform, OnDestroy {}\n","import { NgModule } from '@angular/core';\nimport { LegacyFormlySelectOptionsPipe } from './select-options.pipe';\n\n@NgModule({\n declarations: [LegacyFormlySelectOptionsPipe],\n exports: [LegacyFormlySelectOptionsPipe],\n})\nexport class FormlySelectModule {}\n"],"mappings":";;;;AA6BA,IAAa,0BAAb,MAAa,wBAAuB;CAIlC,UAAU,SAAc,OAAyB;EAC/C,IAAI,CAAC,aAAa,OAAO,GACvB,UAAU,KAAK,aAAa,SAAS,KAAK;OAE1C,KAAK,QAAO;EAGd,OAAQ,QAA4B,KAAK,KAAK,UAAU,KAAK,iBAAiB,OAAO,KAAK,CAAC,CAAC;CAC9F;CAEA,cAAW;EACT,KAAK,QAAO;CACd;CAEQ,iBAAiB,SAAgB,OAAyB;EAChE,MAAM,KAAK,KAAK,qBAAqB,KAAK;EAE1C,MAAM,OAA6B,CAAA;EACnC,MAAM,SAAmC,CAAA;EAEzC,SAAS,SAAS,WAAU;GAC1B,IAAI,GAAG,SAAS;IACd,MAAM,SAAS,GAAG,QAAQ,MAAM;IAChC,KAAK,KAAK,MAAM;GAClB,OAAO;IACL,MAAM,IAAI,KAAK,gBAAgB,QAAQ,EAAE;IACzC,IAAI,EAAE,OAAO;KACX,MAAM,KAAK,OAAO,EAAE;KACpB,IAAI,OAAO,QACT,OAAO,EAAE,SAAS,KAAK,KAAK,CAAC,IAAI;UAEjC,EAAE,MAAM,SAAS,MAAM,KAAK,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC;IAEjD,OACE,KAAK,KAAK,CAAC;GAEf;EACF,CAAC;EAED,OAAO;CACT;CAEQ,gBAAgB,QAAa,OAAuB;EAC1D,MAAM,QAAQ,MAAM,UAAU,MAAM;EACpC,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO;GACL,OAAO,MAAM,UAAU,MAAM;GAC7B,OAAO,MAAM,KAAK,QAAQ,KAAK,gBAAgB,KAAK,KAAK,CAAC;EAC3D;EAGH,SAAS;GACP,OAAO,MAAM,UAAU,MAAM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AAA,UAAA;GAAA,MAAA;EAAkB,CAAA;CAAA;;AAAlB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAkB,YAAA,CAAA;EAJ9B,MAAA;EAAS,MAAA,CAAA;GACR,cAAc,CAAC,6BAA6B;GAC5C,SAAS,CAAC,6BAA6B;EACxC,CAAA"}
|
|
@@ -1,93 +1,118 @@
|
|
|
1
|
-
import { TestBed } from
|
|
2
|
-
import * as i0 from
|
|
3
|
-
import { Component } from
|
|
4
|
-
import * as i1 from
|
|
5
|
-
import {
|
|
6
|
-
import { ReactiveFormsModule } from
|
|
7
|
-
import { By } from
|
|
8
|
-
|
|
1
|
+
import { TestBed } from "@angular/core/testing";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { ChangeDetectionStrategy, Component } from "@angular/core";
|
|
4
|
+
import * as i1 from "@ngx-formly/core";
|
|
5
|
+
import { FormlyFormBuilder, FormlyModule } from "@ngx-formly/core";
|
|
6
|
+
import { ReactiveFormsModule } from "@angular/forms";
|
|
7
|
+
import { By } from "@angular/platform-browser";
|
|
9
8
|
function setInputs(fixture, inputs, detectChanges = true) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
fixture.detectChanges();
|
|
15
|
-
}
|
|
9
|
+
Object.keys(inputs).forEach((input) => {
|
|
10
|
+
fixture.componentInstance[input] = inputs[input];
|
|
11
|
+
});
|
|
12
|
+
if (detectChanges !== false) fixture.detectChanges();
|
|
16
13
|
}
|
|
17
|
-
function createComponent({ template, inputs, config, detectChanges, imports, declarations, providers
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
14
|
+
function createComponent({ template, inputs, config, detectChanges, imports, declarations, providers }) {
|
|
15
|
+
TestBed.configureTestingModule({
|
|
16
|
+
declarations: [TestComponent, ...declarations || []],
|
|
17
|
+
imports: [
|
|
18
|
+
ReactiveFormsModule,
|
|
19
|
+
FormlyModule.forRoot(config),
|
|
20
|
+
...imports || []
|
|
21
|
+
],
|
|
22
|
+
providers: providers || [],
|
|
23
|
+
teardown: { destroyAfterEach: false }
|
|
24
|
+
}).overrideComponent(TestComponent, { set: {
|
|
25
|
+
template,
|
|
26
|
+
inputs: Object.keys(inputs)
|
|
27
|
+
} });
|
|
28
|
+
const fixture = TestBed.createComponent(TestComponent);
|
|
29
|
+
Object.keys(inputs).forEach((input) => {
|
|
30
|
+
fixture.componentInstance[input] = inputs[input];
|
|
31
|
+
});
|
|
32
|
+
setInputs(fixture, inputs, detectChanges);
|
|
33
|
+
const utils = {
|
|
34
|
+
fixture,
|
|
35
|
+
detectChanges: () => fixture.detectChanges(),
|
|
36
|
+
setInputs: (props) => setInputs(fixture, props),
|
|
37
|
+
query: (selector) => fixture.debugElement.query(By.css(selector)),
|
|
38
|
+
queryAll: (selector) => fixture.debugElement.queryAll(By.css(selector))
|
|
39
|
+
};
|
|
40
|
+
Object.keys(inputs).forEach((input) => {
|
|
41
|
+
Object.defineProperty(utils, input, { get: () => fixture.componentInstance[input] });
|
|
42
|
+
});
|
|
43
|
+
return utils;
|
|
47
44
|
}
|
|
48
45
|
function createFieldComponent(field, config = {}) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
constructor(builder) {
|
|
73
|
-
this.builder = builder;
|
|
74
|
-
}
|
|
75
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: TestComponent, deps: [{ token: i1.FormlyFormBuilder }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
76
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.25", type: TestComponent, isStandalone: false, selector: "formly-test-component", providers: [FormlyFormBuilder], ngImport: i0, template: '', isInline: true }); }
|
|
46
|
+
const model = field?.model || {};
|
|
47
|
+
const options = field?.options || {};
|
|
48
|
+
delete field?.model;
|
|
49
|
+
delete field?.options;
|
|
50
|
+
const utils = createComponent({
|
|
51
|
+
template: "<formly-field [field]=\"field\"></formly-field>",
|
|
52
|
+
inputs: { field },
|
|
53
|
+
...config,
|
|
54
|
+
detectChanges: false
|
|
55
|
+
});
|
|
56
|
+
const builder = utils.fixture.componentRef.instance.builder;
|
|
57
|
+
builder.build({
|
|
58
|
+
model,
|
|
59
|
+
options,
|
|
60
|
+
fieldGroup: [field]
|
|
61
|
+
});
|
|
62
|
+
utils.detectChanges();
|
|
63
|
+
const setInputs = utils.setInputs;
|
|
64
|
+
utils.setInputs = (props) => {
|
|
65
|
+
if (props.field) builder.build(props.field);
|
|
66
|
+
setInputs(props);
|
|
67
|
+
};
|
|
68
|
+
return utils;
|
|
77
69
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
70
|
+
var TestComponent = class TestComponent {
|
|
71
|
+
constructor(builder) {
|
|
72
|
+
this.builder = builder;
|
|
73
|
+
}
|
|
74
|
+
static {
|
|
75
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
76
|
+
minVersion: "12.0.0",
|
|
77
|
+
version: "22.2.2",
|
|
78
|
+
ngImport: i0,
|
|
79
|
+
type: TestComponent,
|
|
80
|
+
deps: [{ token: i1.FormlyFormBuilder }],
|
|
81
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
static {
|
|
85
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
86
|
+
minVersion: "14.0.0",
|
|
87
|
+
version: "22.2.2",
|
|
88
|
+
type: TestComponent,
|
|
89
|
+
isStandalone: false,
|
|
90
|
+
selector: "formly-test-component",
|
|
91
|
+
providers: [FormlyFormBuilder],
|
|
92
|
+
ngImport: i0,
|
|
93
|
+
template: "",
|
|
94
|
+
isInline: true,
|
|
95
|
+
changeDetection: i0.ChangeDetectionStrategy.Eager
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
100
|
+
minVersion: "12.0.0",
|
|
101
|
+
version: "22.2.2",
|
|
102
|
+
ngImport: i0,
|
|
103
|
+
type: TestComponent,
|
|
104
|
+
decorators: [{
|
|
105
|
+
type: Component,
|
|
106
|
+
args: [{
|
|
107
|
+
selector: "formly-test-component",
|
|
108
|
+
template: "",
|
|
109
|
+
providers: [FormlyFormBuilder],
|
|
110
|
+
changeDetection: ChangeDetectionStrategy.Eager,
|
|
111
|
+
standalone: false
|
|
112
|
+
}]
|
|
113
|
+
}],
|
|
114
|
+
ctorParameters: () => [{ type: i1.FormlyFormBuilder }]
|
|
115
|
+
});
|
|
92
116
|
export { createComponent, createFieldComponent };
|
|
93
|
-
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=ngx-formly-core-testing.mjs.map
|