@stemy/ngx-dynamic-form 19.9.35 → 19.9.37
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.
|
@@ -68,19 +68,37 @@ function FormInput(data) {
|
|
|
68
68
|
break;
|
|
69
69
|
}
|
|
70
70
|
data.type = data.type || inputType;
|
|
71
|
-
defineFormControl(target, key, (fb, path, options) =>
|
|
71
|
+
defineFormControl(target, key, (fb, path, options) => {
|
|
72
|
+
const instance = getInstance(target);
|
|
73
|
+
return fb.createFormInput(key, {
|
|
74
|
+
...data,
|
|
75
|
+
defaultValue: instance[key] ?? null
|
|
76
|
+
}, path, options);
|
|
77
|
+
});
|
|
72
78
|
};
|
|
73
79
|
}
|
|
74
80
|
function FormSelect(data) {
|
|
75
81
|
data = data || {};
|
|
76
82
|
return (target, key) => {
|
|
77
|
-
defineFormControl(target, key, (fb, path, options) =>
|
|
83
|
+
defineFormControl(target, key, (fb, path, options) => {
|
|
84
|
+
const instance = getInstance(target);
|
|
85
|
+
return fb.createFormSelect(key, {
|
|
86
|
+
...data,
|
|
87
|
+
defaultValue: instance[key] ?? null
|
|
88
|
+
}, path, options);
|
|
89
|
+
});
|
|
78
90
|
};
|
|
79
91
|
}
|
|
80
92
|
function FormDate(data) {
|
|
81
93
|
data = data || {};
|
|
82
94
|
return (target, key) => {
|
|
83
|
-
defineFormControl(target, key, (fb, path, options) =>
|
|
95
|
+
defineFormControl(target, key, (fb, path, options) => {
|
|
96
|
+
const instance = getInstance(target);
|
|
97
|
+
return fb.createFormDate(key, {
|
|
98
|
+
...data,
|
|
99
|
+
defaultValue: instance[key] ?? null
|
|
100
|
+
}, path, options);
|
|
101
|
+
});
|
|
84
102
|
};
|
|
85
103
|
}
|
|
86
104
|
function FormUpload(data) {
|
|
@@ -92,7 +110,13 @@ function FormUpload(data) {
|
|
|
92
110
|
function FormStatic(data) {
|
|
93
111
|
data = data || {};
|
|
94
112
|
return (target, key) => {
|
|
95
|
-
defineFormControl(target, key, (fb, path, options) =>
|
|
113
|
+
defineFormControl(target, key, (fb, path, options) => {
|
|
114
|
+
const instance = getInstance(target);
|
|
115
|
+
return fb.createFormStatic(key, {
|
|
116
|
+
...data,
|
|
117
|
+
defaultValue: instance[key] ?? null
|
|
118
|
+
}, path, options);
|
|
119
|
+
});
|
|
96
120
|
};
|
|
97
121
|
}
|
|
98
122
|
function FormGroup(data) {
|
|
@@ -100,7 +124,11 @@ function FormGroup(data) {
|
|
|
100
124
|
return (target, key) => {
|
|
101
125
|
defineFormControl(target, key, (fb, parent, options) => {
|
|
102
126
|
const targetType = ReflectUtils.getOwnMetadata("design:type", target, key);
|
|
103
|
-
|
|
127
|
+
const instance = getInstance(target);
|
|
128
|
+
return fb.resolveFormGroup(key, targetType, {
|
|
129
|
+
...data,
|
|
130
|
+
defaultValue: instance[key] ?? {}
|
|
131
|
+
}, parent, options);
|
|
104
132
|
});
|
|
105
133
|
};
|
|
106
134
|
}
|
|
@@ -108,7 +136,11 @@ function FormArray(itemType, data) {
|
|
|
108
136
|
data = data || {};
|
|
109
137
|
return (target, key) => {
|
|
110
138
|
defineFormControl(target, key, (fb, parent, options) => {
|
|
111
|
-
|
|
139
|
+
const instance = getInstance(target);
|
|
140
|
+
return fb.resolveFormArray(key, itemType, {
|
|
141
|
+
...data,
|
|
142
|
+
defaultValue: instance[key] ?? []
|
|
143
|
+
}, parent, options);
|
|
112
144
|
});
|
|
113
145
|
};
|
|
114
146
|
}
|
|
@@ -122,6 +154,19 @@ function FormFieldSet(data) {
|
|
|
122
154
|
defineFormFieldSet(target, data);
|
|
123
155
|
};
|
|
124
156
|
}
|
|
157
|
+
function getInstance(target) {
|
|
158
|
+
let instance = ReflectUtils.getMetadata("dynamicFormInstance", target);
|
|
159
|
+
if (!instance) {
|
|
160
|
+
try {
|
|
161
|
+
instance = new target.constructor();
|
|
162
|
+
}
|
|
163
|
+
catch (e) {
|
|
164
|
+
instance = {};
|
|
165
|
+
}
|
|
166
|
+
ReflectUtils.defineMetadata("dynamicFormInstance", target, instance);
|
|
167
|
+
}
|
|
168
|
+
return instance;
|
|
169
|
+
}
|
|
125
170
|
|
|
126
171
|
function replaceSpecialChars(str, to = "-") {
|
|
127
172
|
return `${str}`.replace(/[&\/\\#, +()$~%.@'":*?<>{}]/g, to);
|
|
@@ -2215,11 +2260,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.22", ngImpo
|
|
|
2215
2260
|
|
|
2216
2261
|
class DynamicFormDateComponent extends DynamicFieldType {
|
|
2217
2262
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.22", ngImport: i0, type: DynamicFormDateComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2218
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.22", type: DynamicFormDateComponent, isStandalone: false, selector: "dynamic-form-date", usesInheritance: true, ngImport: i0, template: "<date-picker [formControl]=\"formControl\"\n [min]=\"$any(props.min)\"\n [max]=\"$any(props.max)\"\n [disabledDays]=\"props.
|
|
2263
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.22", type: DynamicFormDateComponent, isStandalone: false, selector: "dynamic-form-date", usesInheritance: true, ngImport: i0, template: "<date-picker [formControl]=\"formControl\"\n [testId]=\"field.testId\"\n [min]=\"$any(props.min)\"\n [max]=\"$any(props.max)\"\n [disabledDays]=\"props.disabledDays\"\n [disabledDates]=\"props.disabledDates\"\n [formlyAttributes]=\"field\"></date-picker>\n", dependencies: [{ kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i2.DatePickerComponent, selector: "date-picker" }, { kind: "directive", type: i3.LegacyFormlyAttributes, selector: "[formlyAttributes]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
2219
2264
|
}
|
|
2220
2265
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.22", ngImport: i0, type: DynamicFormDateComponent, decorators: [{
|
|
2221
2266
|
type: Component,
|
|
2222
|
-
args: [{ standalone: false, selector: "dynamic-form-date", encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<date-picker [formControl]=\"formControl\"\n [min]=\"$any(props.min)\"\n [max]=\"$any(props.max)\"\n [disabledDays]=\"props.
|
|
2267
|
+
args: [{ standalone: false, selector: "dynamic-form-date", encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<date-picker [formControl]=\"formControl\"\n [testId]=\"field.testId\"\n [min]=\"$any(props.min)\"\n [max]=\"$any(props.max)\"\n [disabledDays]=\"props.disabledDays\"\n [disabledDates]=\"props.disabledDates\"\n [formlyAttributes]=\"field\"></date-picker>\n" }]
|
|
2223
2268
|
}] });
|
|
2224
2269
|
|
|
2225
2270
|
class DynamicFormEditorComponent extends DynamicFieldType {
|