@rolster/forms 2.7.2 → 2.9.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/dist/cjs/arguments.js +46 -46
- package/dist/cjs/arguments.js.map +1 -1
- package/dist/cjs/helpers.js +53 -53
- package/dist/cjs/helpers.js.map +1 -1
- package/dist/cjs/index.js +518 -510
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/arguments.js +46 -46
- package/dist/es/arguments.js.map +1 -1
- package/dist/es/helpers.js +53 -53
- package/dist/es/helpers.js.map +1 -1
- package/dist/es/index.js +518 -510
- package/dist/es/index.js.map +1 -1
- package/dist/esm/arguments.d.ts +18 -18
- package/dist/esm/arguments.js +47 -47
- package/dist/esm/arguments.js.map +1 -1
- package/dist/esm/form-array/arguments.d.ts +6 -6
- package/dist/esm/form-array/arguments.js +1 -1
- package/dist/esm/form-array/form-array-control.d.ts +20 -20
- package/dist/esm/form-array/form-array-control.js +13 -13
- package/dist/esm/form-array/form-array-group.d.ts +13 -13
- package/dist/esm/form-array/form-array-group.js +14 -14
- package/dist/esm/form-array/form-array-list.d.ts +20 -20
- package/dist/esm/form-array/form-array-list.js +51 -51
- package/dist/esm/form-array/form-array.d.ts +55 -54
- package/dist/esm/form-array/form-array.js +149 -145
- package/dist/esm/form-array/form-array.js.map +1 -1
- package/dist/esm/form-array/index.d.ts +5 -5
- package/dist/esm/form-array/index.js +5 -5
- package/dist/esm/form-array/types.d.ts +2 -2
- package/dist/esm/form-array/types.js +1 -1
- package/dist/esm/form-control.d.ts +53 -52
- package/dist/esm/form-control.js +123 -119
- package/dist/esm/form-control.js.map +1 -1
- package/dist/esm/form-group.d.ts +34 -34
- package/dist/esm/form-group.js +93 -93
- package/dist/esm/form-group.js.map +1 -1
- package/dist/esm/helpers.d.ts +25 -25
- package/dist/esm/helpers.js +55 -55
- package/dist/esm/helpers.js.map +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +4 -4
- package/dist/esm/types.d.ts +141 -139
- package/dist/esm/types.js +1 -1
- package/package.json +5 -5
- package/readme.md +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -5,530 +5,538 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var uuid = require('uuid');
|
|
6
6
|
var commons = require('@rolster/commons');
|
|
7
7
|
|
|
8
|
-
function itIsControlOptions(options) {
|
|
9
|
-
return (typeof options === 'object' &&
|
|
10
|
-
('value' in options || 'validators' in options));
|
|
11
|
-
}
|
|
12
|
-
function itIsGroupOptions(options) {
|
|
13
|
-
return typeof options === 'object' && 'controls' in options;
|
|
14
|
-
}
|
|
15
|
-
function itIsArrayOptions(options) {
|
|
16
|
-
return (typeof options === 'object' &&
|
|
17
|
-
('groups' in options || 'validators' in options));
|
|
18
|
-
}
|
|
19
|
-
function createFormControlOptions(...controlOptions) {
|
|
20
|
-
const [options, validators] = controlOptions;
|
|
21
|
-
if (!options) {
|
|
22
|
-
return { value: options, validators };
|
|
23
|
-
}
|
|
24
|
-
if (!validators && itIsControlOptions(options)) {
|
|
25
|
-
return options;
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
value: options,
|
|
29
|
-
validators
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function createFormGroupOptions(...groupOptions) {
|
|
33
|
-
const [options, validators] = groupOptions;
|
|
34
|
-
if (!validators && itIsGroupOptions(options)) {
|
|
35
|
-
return options;
|
|
36
|
-
}
|
|
37
|
-
return {
|
|
38
|
-
controls: options,
|
|
39
|
-
validators
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function createFormArrayOptions(...arrayOptions) {
|
|
43
|
-
const [options, validators] = arrayOptions;
|
|
44
|
-
if (!options) {
|
|
45
|
-
return { groups: options, validators };
|
|
46
|
-
}
|
|
47
|
-
if (!validators && itIsArrayOptions(options)) {
|
|
48
|
-
return options;
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
groups: options,
|
|
52
|
-
validators
|
|
53
|
-
};
|
|
8
|
+
function itIsControlOptions(options) {
|
|
9
|
+
return (typeof options === 'object' &&
|
|
10
|
+
('value' in options || 'validators' in options));
|
|
11
|
+
}
|
|
12
|
+
function itIsGroupOptions(options) {
|
|
13
|
+
return typeof options === 'object' && 'controls' in options;
|
|
14
|
+
}
|
|
15
|
+
function itIsArrayOptions(options) {
|
|
16
|
+
return (typeof options === 'object' &&
|
|
17
|
+
('groups' in options || 'validators' in options));
|
|
18
|
+
}
|
|
19
|
+
function createFormControlOptions(...controlOptions) {
|
|
20
|
+
const [options, validators] = controlOptions;
|
|
21
|
+
if (!options) {
|
|
22
|
+
return { value: options, validators };
|
|
23
|
+
}
|
|
24
|
+
if (!validators && itIsControlOptions(options)) {
|
|
25
|
+
return options;
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
value: options,
|
|
29
|
+
validators
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function createFormGroupOptions(...groupOptions) {
|
|
33
|
+
const [options, validators] = groupOptions;
|
|
34
|
+
if (!validators && itIsGroupOptions(options)) {
|
|
35
|
+
return options;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
controls: options,
|
|
39
|
+
validators
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function createFormArrayOptions(...arrayOptions) {
|
|
43
|
+
const [options, validators] = arrayOptions;
|
|
44
|
+
if (!options) {
|
|
45
|
+
return { groups: options, validators };
|
|
46
|
+
}
|
|
47
|
+
if (!validators && itIsArrayOptions(options)) {
|
|
48
|
+
return options;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
groups: options,
|
|
52
|
+
validators
|
|
53
|
+
};
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
function reduceErrors(errors) {
|
|
57
|
-
return errors.reduce((keys, { id }) => [...keys, id], []);
|
|
58
|
-
}
|
|
59
|
-
const controlIsValid = ({ value, validators }) => {
|
|
60
|
-
return validators.reduce((errors, validator) => {
|
|
61
|
-
const error = validator(value);
|
|
62
|
-
if (error) {
|
|
63
|
-
errors.push(error);
|
|
64
|
-
}
|
|
65
|
-
return errors;
|
|
66
|
-
}, []);
|
|
67
|
-
};
|
|
68
|
-
const controlsAllChecked = (controls, key) => {
|
|
69
|
-
return Object.values(controls).reduce((value, control) => control.disabled ? value : value && commons.parseBoolean(control[key]), true);
|
|
70
|
-
};
|
|
71
|
-
const controlsPartialChecked = (controls, key) => {
|
|
72
|
-
return Object.values(controls).reduce((value, control) => control.disabled ? value : value || commons.parseBoolean(control[key]), false);
|
|
73
|
-
};
|
|
74
|
-
const controlsToValue = (controls) => {
|
|
75
|
-
return Object.entries(controls).reduce((result, [key, { value }]) => {
|
|
76
|
-
result[key] = value;
|
|
77
|
-
return result;
|
|
78
|
-
}, {});
|
|
79
|
-
};
|
|
80
|
-
const groupIsValid = ({ controls, validators }) => {
|
|
81
|
-
return validators.reduce((errors, validator) => {
|
|
82
|
-
const error = validator(controls);
|
|
83
|
-
if (error) {
|
|
84
|
-
errors.push(error);
|
|
85
|
-
}
|
|
86
|
-
return errors;
|
|
87
|
-
}, []);
|
|
88
|
-
};
|
|
89
|
-
function groupAllChecked(groups, key) {
|
|
90
|
-
return groups.reduce((value, group) => value && commons.parseBoolean(group[key]), true);
|
|
91
|
-
}
|
|
92
|
-
function groupPartialChecked(groups, key) {
|
|
93
|
-
return groups.reduce((value, group) => value || commons.parseBoolean(group[key]), false);
|
|
94
|
-
}
|
|
95
|
-
const arrayIsValid = ({ groups, validators }) => {
|
|
96
|
-
return validators.reduce((errors, validator) => {
|
|
97
|
-
const error = validator(groups);
|
|
98
|
-
if (error) {
|
|
99
|
-
errors.push(error);
|
|
100
|
-
}
|
|
101
|
-
return errors;
|
|
102
|
-
}, []);
|
|
103
|
-
};
|
|
104
|
-
function hasError(errors, key) {
|
|
105
|
-
return reduceErrors(errors).includes(key);
|
|
106
|
-
}
|
|
107
|
-
function someErrors(errors, keys) {
|
|
108
|
-
return reduceErrors(errors).some((key) => keys.includes(key));
|
|
56
|
+
function reduceErrors(errors) {
|
|
57
|
+
return errors.reduce((keys, { id }) => [...keys, id], []);
|
|
58
|
+
}
|
|
59
|
+
const controlIsValid = ({ value, validators }) => {
|
|
60
|
+
return validators.reduce((errors, validator) => {
|
|
61
|
+
const error = validator(value);
|
|
62
|
+
if (error) {
|
|
63
|
+
errors.push(error);
|
|
64
|
+
}
|
|
65
|
+
return errors;
|
|
66
|
+
}, []);
|
|
67
|
+
};
|
|
68
|
+
const controlsAllChecked = (controls, key) => {
|
|
69
|
+
return Object.values(controls).reduce((value, control) => control.disabled ? value : value && commons.parseBoolean(control[key]), true);
|
|
70
|
+
};
|
|
71
|
+
const controlsPartialChecked = (controls, key) => {
|
|
72
|
+
return Object.values(controls).reduce((value, control) => control.disabled ? value : value || commons.parseBoolean(control[key]), false);
|
|
73
|
+
};
|
|
74
|
+
const controlsToValue = (controls) => {
|
|
75
|
+
return Object.entries(controls).reduce((result, [key, { value }]) => {
|
|
76
|
+
result[key] = value;
|
|
77
|
+
return result;
|
|
78
|
+
}, {});
|
|
79
|
+
};
|
|
80
|
+
const groupIsValid = ({ controls, validators }) => {
|
|
81
|
+
return validators.reduce((errors, validator) => {
|
|
82
|
+
const error = validator(controls);
|
|
83
|
+
if (error) {
|
|
84
|
+
errors.push(error);
|
|
85
|
+
}
|
|
86
|
+
return errors;
|
|
87
|
+
}, []);
|
|
88
|
+
};
|
|
89
|
+
function groupAllChecked(groups, key) {
|
|
90
|
+
return groups.reduce((value, group) => value && commons.parseBoolean(group[key]), true);
|
|
91
|
+
}
|
|
92
|
+
function groupPartialChecked(groups, key) {
|
|
93
|
+
return groups.reduce((value, group) => value || commons.parseBoolean(group[key]), false);
|
|
94
|
+
}
|
|
95
|
+
const arrayIsValid = ({ groups, validators }) => {
|
|
96
|
+
return validators.reduce((errors, validator) => {
|
|
97
|
+
const error = validator(groups);
|
|
98
|
+
if (error) {
|
|
99
|
+
errors.push(error);
|
|
100
|
+
}
|
|
101
|
+
return errors;
|
|
102
|
+
}, []);
|
|
103
|
+
};
|
|
104
|
+
function hasError(errors, key) {
|
|
105
|
+
return reduceErrors(errors).includes(key);
|
|
106
|
+
}
|
|
107
|
+
function someErrors(errors, keys) {
|
|
108
|
+
return reduceErrors(errors).some((key) => keys.includes(key));
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
class FormControl {
|
|
112
|
-
constructor(controlOptions, controlValidators) {
|
|
113
|
-
this.currentFocused = false;
|
|
114
|
-
this.currentTouched = false;
|
|
115
|
-
this.currentDirty = false;
|
|
116
|
-
this.currentDisabled = false;
|
|
117
|
-
this.currentValid = true;
|
|
118
|
-
this.currentErrors = [];
|
|
119
|
-
const { value, validators } = createFormControlOptions(controlOptions, controlValidators);
|
|
120
|
-
this.observable = commons.observable(value);
|
|
121
|
-
this.initialValue = value;
|
|
122
|
-
this.validators = validators;
|
|
123
|
-
this.currentValue = value;
|
|
124
|
-
this.updateValueAndValidity(value, validators);
|
|
125
|
-
}
|
|
126
|
-
get focused() {
|
|
127
|
-
return this.currentFocused;
|
|
128
|
-
}
|
|
129
|
-
get unfocused() {
|
|
130
|
-
return !this.currentFocused;
|
|
131
|
-
}
|
|
132
|
-
get touched() {
|
|
133
|
-
return this.currentTouched;
|
|
134
|
-
}
|
|
135
|
-
get untouched() {
|
|
136
|
-
return !this.currentTouched;
|
|
137
|
-
}
|
|
138
|
-
get dirty() {
|
|
139
|
-
return this.currentDirty;
|
|
140
|
-
}
|
|
141
|
-
get pristine() {
|
|
142
|
-
return !this.currentDirty;
|
|
143
|
-
}
|
|
144
|
-
get disabled() {
|
|
145
|
-
return this.currentDisabled;
|
|
146
|
-
}
|
|
147
|
-
get enabled() {
|
|
148
|
-
return !this.currentDisabled;
|
|
149
|
-
}
|
|
150
|
-
get valid() {
|
|
151
|
-
return this.currentValid;
|
|
152
|
-
}
|
|
153
|
-
get invalid() {
|
|
154
|
-
return !this.currentValid;
|
|
155
|
-
}
|
|
156
|
-
get value() {
|
|
157
|
-
return this.currentValue;
|
|
158
|
-
}
|
|
159
|
-
get errors() {
|
|
160
|
-
return this.currentErrors;
|
|
161
|
-
}
|
|
162
|
-
get error() {
|
|
163
|
-
return this.currentError;
|
|
164
|
-
}
|
|
165
|
-
get wrong() {
|
|
166
|
-
return this.touched && this.invalid;
|
|
167
|
-
}
|
|
168
|
-
hasError(key) {
|
|
169
|
-
return hasError(this.errors, key);
|
|
170
|
-
}
|
|
171
|
-
someErrors(keys) {
|
|
172
|
-
return someErrors(this.errors, keys);
|
|
173
|
-
}
|
|
174
|
-
reset() {
|
|
175
|
-
this.setValue(this.initialValue);
|
|
176
|
-
this.currentDirty = false;
|
|
177
|
-
this.currentTouched = false;
|
|
178
|
-
}
|
|
179
|
-
focus() {
|
|
180
|
-
this.currentFocused = true;
|
|
181
|
-
}
|
|
182
|
-
blur() {
|
|
183
|
-
this.currentFocused = false;
|
|
184
|
-
this.currentTouched = true;
|
|
185
|
-
}
|
|
186
|
-
disable() {
|
|
187
|
-
this.currentDisabled = true;
|
|
188
|
-
}
|
|
189
|
-
enable() {
|
|
190
|
-
this.currentDisabled = false;
|
|
191
|
-
}
|
|
192
|
-
touch() {
|
|
193
|
-
this.currentTouched = true;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
this.
|
|
219
|
-
this.
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
111
|
+
class FormControl {
|
|
112
|
+
constructor(controlOptions, controlValidators) {
|
|
113
|
+
this.currentFocused = false;
|
|
114
|
+
this.currentTouched = false;
|
|
115
|
+
this.currentDirty = false;
|
|
116
|
+
this.currentDisabled = false;
|
|
117
|
+
this.currentValid = true;
|
|
118
|
+
this.currentErrors = [];
|
|
119
|
+
const { value, validators } = createFormControlOptions(controlOptions, controlValidators);
|
|
120
|
+
this.observable = commons.observable(value);
|
|
121
|
+
this.initialValue = value;
|
|
122
|
+
this.validators = validators;
|
|
123
|
+
this.currentValue = value;
|
|
124
|
+
this.updateValueAndValidity(value, validators);
|
|
125
|
+
}
|
|
126
|
+
get focused() {
|
|
127
|
+
return this.currentFocused;
|
|
128
|
+
}
|
|
129
|
+
get unfocused() {
|
|
130
|
+
return !this.currentFocused;
|
|
131
|
+
}
|
|
132
|
+
get touched() {
|
|
133
|
+
return this.currentTouched;
|
|
134
|
+
}
|
|
135
|
+
get untouched() {
|
|
136
|
+
return !this.currentTouched;
|
|
137
|
+
}
|
|
138
|
+
get dirty() {
|
|
139
|
+
return this.currentDirty;
|
|
140
|
+
}
|
|
141
|
+
get pristine() {
|
|
142
|
+
return !this.currentDirty;
|
|
143
|
+
}
|
|
144
|
+
get disabled() {
|
|
145
|
+
return this.currentDisabled;
|
|
146
|
+
}
|
|
147
|
+
get enabled() {
|
|
148
|
+
return !this.currentDisabled;
|
|
149
|
+
}
|
|
150
|
+
get valid() {
|
|
151
|
+
return this.currentValid;
|
|
152
|
+
}
|
|
153
|
+
get invalid() {
|
|
154
|
+
return !this.currentValid;
|
|
155
|
+
}
|
|
156
|
+
get value() {
|
|
157
|
+
return this.currentValue;
|
|
158
|
+
}
|
|
159
|
+
get errors() {
|
|
160
|
+
return this.currentErrors;
|
|
161
|
+
}
|
|
162
|
+
get error() {
|
|
163
|
+
return this.currentError;
|
|
164
|
+
}
|
|
165
|
+
get wrong() {
|
|
166
|
+
return this.touched && this.invalid;
|
|
167
|
+
}
|
|
168
|
+
hasError(key) {
|
|
169
|
+
return hasError(this.errors, key);
|
|
170
|
+
}
|
|
171
|
+
someErrors(keys) {
|
|
172
|
+
return someErrors(this.errors, keys);
|
|
173
|
+
}
|
|
174
|
+
reset() {
|
|
175
|
+
this.setValue(this.initialValue);
|
|
176
|
+
this.currentDirty = false;
|
|
177
|
+
this.currentTouched = false;
|
|
178
|
+
}
|
|
179
|
+
focus() {
|
|
180
|
+
this.currentFocused = true;
|
|
181
|
+
}
|
|
182
|
+
blur() {
|
|
183
|
+
this.currentFocused = false;
|
|
184
|
+
this.currentTouched = true;
|
|
185
|
+
}
|
|
186
|
+
disable() {
|
|
187
|
+
this.currentDisabled = true;
|
|
188
|
+
}
|
|
189
|
+
enable() {
|
|
190
|
+
this.currentDisabled = false;
|
|
191
|
+
}
|
|
192
|
+
touch() {
|
|
193
|
+
this.currentTouched = true;
|
|
194
|
+
}
|
|
195
|
+
setInitialValue(value) {
|
|
196
|
+
this.initialValue = value;
|
|
197
|
+
this.setValue(value);
|
|
198
|
+
}
|
|
199
|
+
setValue(value) {
|
|
200
|
+
if (this.enabled) {
|
|
201
|
+
this.currentValue = value;
|
|
202
|
+
this.currentDirty = true;
|
|
203
|
+
this.updateValueAndValidity(value, this.validators);
|
|
204
|
+
this.observable.next(value);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
setValidators(validators = []) {
|
|
208
|
+
this.validators = validators;
|
|
209
|
+
this.updateValueAndValidity(this.value, validators);
|
|
210
|
+
}
|
|
211
|
+
subscribe(subscriber) {
|
|
212
|
+
return this.observable.subscribe(subscriber);
|
|
213
|
+
}
|
|
214
|
+
updateValueAndValidity(value, validators) {
|
|
215
|
+
if (validators) {
|
|
216
|
+
const errors = controlIsValid({ value, validators });
|
|
217
|
+
this.currentError = errors[0];
|
|
218
|
+
this.currentErrors = errors;
|
|
219
|
+
this.currentValid = errors.length === 0;
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
this.currentValid = true;
|
|
223
|
+
this.currentError = undefined;
|
|
224
|
+
this.currentErrors = [];
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function formControl(options, validators) {
|
|
229
|
+
return new FormControl(createFormControlOptions(options, validators));
|
|
226
230
|
}
|
|
227
231
|
|
|
228
|
-
class FormArrayControl extends FormControl {
|
|
229
|
-
constructor(controlOptions, controlValidators) {
|
|
230
|
-
const { value, validators } = createFormControlOptions(controlOptions, controlValidators);
|
|
231
|
-
super(value, validators);
|
|
232
|
-
this.uuid = uuid.v4();
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function formArrayControl(options, validators) {
|
|
236
|
-
return new FormArrayControl(createFormControlOptions(options, validators));
|
|
232
|
+
class FormArrayControl extends FormControl {
|
|
233
|
+
constructor(controlOptions, controlValidators) {
|
|
234
|
+
const { value, validators } = createFormControlOptions(controlOptions, controlValidators);
|
|
235
|
+
super(value, validators);
|
|
236
|
+
this.uuid = uuid.v4();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function formArrayControl(options, validators) {
|
|
240
|
+
return new FormArrayControl(createFormControlOptions(options, validators));
|
|
237
241
|
}
|
|
238
242
|
|
|
239
|
-
class FormGroup {
|
|
240
|
-
constructor(groupOptions, groupValidators) {
|
|
241
|
-
this.currentErrors = [];
|
|
242
|
-
this.currentValid = true;
|
|
243
|
-
const { controls, validators } = createFormGroupOptions(groupOptions, groupValidators);
|
|
244
|
-
this.currentControls = controls;
|
|
245
|
-
this.validators = validators;
|
|
246
|
-
this.updateValueAndValidity(controls, validators);
|
|
247
|
-
this.observable = commons.observable(this.value);
|
|
248
|
-
Object.values(controls).forEach((control) => {
|
|
249
|
-
control.subscribe(() => {
|
|
250
|
-
this.updateValueAndValidity(this.controls, this.validators);
|
|
251
|
-
this.observable.next(this.value);
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
get controls() {
|
|
256
|
-
return this.currentControls;
|
|
257
|
-
}
|
|
258
|
-
get touched() {
|
|
259
|
-
return controlsPartialChecked(this.controls, 'touched');
|
|
260
|
-
}
|
|
261
|
-
get touchedAll() {
|
|
262
|
-
return controlsAllChecked(this.controls, 'touched');
|
|
263
|
-
}
|
|
264
|
-
get untouched() {
|
|
265
|
-
return !this.touched;
|
|
266
|
-
}
|
|
267
|
-
get untouchedAll() {
|
|
268
|
-
return !this.touchedAll;
|
|
269
|
-
}
|
|
270
|
-
get dirty() {
|
|
271
|
-
return controlsPartialChecked(this.controls, 'dirty');
|
|
272
|
-
}
|
|
273
|
-
get dirtyAll() {
|
|
274
|
-
return controlsAllChecked(this.controls, 'dirty');
|
|
275
|
-
}
|
|
276
|
-
get pristine() {
|
|
277
|
-
return !this.dirty;
|
|
278
|
-
}
|
|
279
|
-
get pristineAll() {
|
|
280
|
-
return this.dirtyAll;
|
|
281
|
-
}
|
|
282
|
-
get valid() {
|
|
283
|
-
return this.currentValid && controlsAllChecked(this.controls, 'valid');
|
|
284
|
-
}
|
|
285
|
-
get invalid() {
|
|
286
|
-
return !this.valid;
|
|
287
|
-
}
|
|
288
|
-
get value() {
|
|
289
|
-
return controlsToValue(this.controls);
|
|
290
|
-
}
|
|
291
|
-
get errors() {
|
|
292
|
-
return this.currentErrors;
|
|
293
|
-
}
|
|
294
|
-
get error() {
|
|
295
|
-
return this.currentError;
|
|
296
|
-
}
|
|
297
|
-
get wrong() {
|
|
298
|
-
return this.touched && this.invalid;
|
|
299
|
-
}
|
|
300
|
-
reset() {
|
|
301
|
-
Object.values(this.controls).forEach((control) => {
|
|
302
|
-
control.reset();
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
setValidators(validators) {
|
|
306
|
-
this.validators = validators;
|
|
307
|
-
this.updateValueAndValidity(this.controls, validators);
|
|
308
|
-
}
|
|
309
|
-
subscribe(subscriber) {
|
|
310
|
-
return this.observable.subscribe(subscriber);
|
|
311
|
-
}
|
|
312
|
-
updateValueAndValidity(controls, validators) {
|
|
313
|
-
if (validators) {
|
|
314
|
-
const errors = groupIsValid({ controls, validators });
|
|
315
|
-
this.currentErrors = errors;
|
|
316
|
-
this.currentError = errors[0];
|
|
317
|
-
this.currentValid = errors.length === 0;
|
|
318
|
-
}
|
|
319
|
-
else {
|
|
320
|
-
this.currentErrors = [];
|
|
321
|
-
this.currentError = undefined;
|
|
322
|
-
this.currentValid = true;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
function formGroup(options, validators) {
|
|
327
|
-
return new FormGroup(createFormGroupOptions(options, validators));
|
|
243
|
+
class FormGroup {
|
|
244
|
+
constructor(groupOptions, groupValidators) {
|
|
245
|
+
this.currentErrors = [];
|
|
246
|
+
this.currentValid = true;
|
|
247
|
+
const { controls, validators } = createFormGroupOptions(groupOptions, groupValidators);
|
|
248
|
+
this.currentControls = controls;
|
|
249
|
+
this.validators = validators;
|
|
250
|
+
this.updateValueAndValidity(controls, validators);
|
|
251
|
+
this.observable = commons.observable(this.value);
|
|
252
|
+
Object.values(controls).forEach((control) => {
|
|
253
|
+
control.subscribe(() => {
|
|
254
|
+
this.updateValueAndValidity(this.controls, this.validators);
|
|
255
|
+
this.observable.next(this.value);
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
get controls() {
|
|
260
|
+
return this.currentControls;
|
|
261
|
+
}
|
|
262
|
+
get touched() {
|
|
263
|
+
return controlsPartialChecked(this.controls, 'touched');
|
|
264
|
+
}
|
|
265
|
+
get touchedAll() {
|
|
266
|
+
return controlsAllChecked(this.controls, 'touched');
|
|
267
|
+
}
|
|
268
|
+
get untouched() {
|
|
269
|
+
return !this.touched;
|
|
270
|
+
}
|
|
271
|
+
get untouchedAll() {
|
|
272
|
+
return !this.touchedAll;
|
|
273
|
+
}
|
|
274
|
+
get dirty() {
|
|
275
|
+
return controlsPartialChecked(this.controls, 'dirty');
|
|
276
|
+
}
|
|
277
|
+
get dirtyAll() {
|
|
278
|
+
return controlsAllChecked(this.controls, 'dirty');
|
|
279
|
+
}
|
|
280
|
+
get pristine() {
|
|
281
|
+
return !this.dirty;
|
|
282
|
+
}
|
|
283
|
+
get pristineAll() {
|
|
284
|
+
return this.dirtyAll;
|
|
285
|
+
}
|
|
286
|
+
get valid() {
|
|
287
|
+
return this.currentValid && controlsAllChecked(this.controls, 'valid');
|
|
288
|
+
}
|
|
289
|
+
get invalid() {
|
|
290
|
+
return !this.valid;
|
|
291
|
+
}
|
|
292
|
+
get value() {
|
|
293
|
+
return controlsToValue(this.controls);
|
|
294
|
+
}
|
|
295
|
+
get errors() {
|
|
296
|
+
return this.currentErrors;
|
|
297
|
+
}
|
|
298
|
+
get error() {
|
|
299
|
+
return this.currentError;
|
|
300
|
+
}
|
|
301
|
+
get wrong() {
|
|
302
|
+
return this.touched && this.invalid;
|
|
303
|
+
}
|
|
304
|
+
reset() {
|
|
305
|
+
Object.values(this.controls).forEach((control) => {
|
|
306
|
+
control.reset();
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
setValidators(validators) {
|
|
310
|
+
this.validators = validators;
|
|
311
|
+
this.updateValueAndValidity(this.controls, validators);
|
|
312
|
+
}
|
|
313
|
+
subscribe(subscriber) {
|
|
314
|
+
return this.observable.subscribe(subscriber);
|
|
315
|
+
}
|
|
316
|
+
updateValueAndValidity(controls, validators) {
|
|
317
|
+
if (validators) {
|
|
318
|
+
const errors = groupIsValid({ controls, validators });
|
|
319
|
+
this.currentErrors = errors;
|
|
320
|
+
this.currentError = errors[0];
|
|
321
|
+
this.currentValid = errors.length === 0;
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
this.currentErrors = [];
|
|
325
|
+
this.currentError = undefined;
|
|
326
|
+
this.currentValid = true;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
function formGroup(options, validators) {
|
|
331
|
+
return new FormGroup(createFormGroupOptions(options, validators));
|
|
328
332
|
}
|
|
329
333
|
|
|
330
|
-
class FormArrayGroup extends FormGroup {
|
|
331
|
-
constructor(groupOptions, groupValidators) {
|
|
332
|
-
const { controls, resource, validators } = createFormGroupOptions(groupOptions, groupValidators);
|
|
333
|
-
super(controls, validators);
|
|
334
|
-
this.uuid = uuid.v4();
|
|
335
|
-
this.resource = resource;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
function formArrayGroup(options, validators) {
|
|
339
|
-
return new FormArrayGroup(createFormGroupOptions(options, validators));
|
|
334
|
+
class FormArrayGroup extends FormGroup {
|
|
335
|
+
constructor(groupOptions, groupValidators) {
|
|
336
|
+
const { controls, resource, validators } = createFormGroupOptions(groupOptions, groupValidators);
|
|
337
|
+
super(controls, validators);
|
|
338
|
+
this.uuid = uuid.v4();
|
|
339
|
+
this.resource = resource;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function formArrayGroup(options, validators) {
|
|
343
|
+
return new FormArrayGroup(createFormGroupOptions(options, validators));
|
|
340
344
|
}
|
|
341
345
|
|
|
342
|
-
class FormArrayList extends FormControl {
|
|
343
|
-
constructor(valueToControls, value, validators) {
|
|
344
|
-
const initialValue = value || [];
|
|
345
|
-
super(initialValue, validators);
|
|
346
|
-
this.valueToControls = valueToControls;
|
|
347
|
-
this.currentControls = initialValue.map((value) => this.createControls(value));
|
|
348
|
-
this.uuid = uuid.v4();
|
|
349
|
-
}
|
|
350
|
-
get controls() {
|
|
351
|
-
return this.currentControls;
|
|
352
|
-
}
|
|
353
|
-
get touched() {
|
|
354
|
-
return this.controls.reduce((valid, controls) => valid && controlsPartialChecked(controls, 'touched'), true);
|
|
355
|
-
}
|
|
356
|
-
get dirty() {
|
|
357
|
-
return this.controls.reduce((valid, controls) => valid && controlsPartialChecked(controls, 'dirty'), true);
|
|
358
|
-
}
|
|
359
|
-
get valid() {
|
|
360
|
-
return (this.currentValid &&
|
|
361
|
-
this.controls.reduce((valid, controls) => valid && controlsAllChecked(controls, 'valid'), true));
|
|
362
|
-
}
|
|
363
|
-
get value() {
|
|
364
|
-
return this.controls.map((controls) => controlsToValue(controls));
|
|
365
|
-
}
|
|
366
|
-
setValue(values) {
|
|
367
|
-
this.currentControls = values.map((value) => this.createControls(value));
|
|
368
|
-
}
|
|
369
|
-
push(controls) {
|
|
370
|
-
this.currentControls = this.currentControls.concat([controls]);
|
|
371
|
-
}
|
|
372
|
-
remove(controls) {
|
|
373
|
-
this.currentControls = this.currentControls.filter((currentControls) => currentControls !== controls);
|
|
374
|
-
}
|
|
375
|
-
createControls(value) {
|
|
376
|
-
const controls = this.valueToControls(value);
|
|
377
|
-
Object.values(controls).forEach((control) => {
|
|
378
|
-
control.subscribe(() => {
|
|
379
|
-
const { value, validators } = this;
|
|
380
|
-
this.updateValueAndValidity(value, validators);
|
|
381
|
-
this.observable.next(value);
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
|
-
return controls;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
function formArrayList(valueToControl, value, validators) {
|
|
388
|
-
return new FormArrayList(valueToControl, value, validators);
|
|
346
|
+
class FormArrayList extends FormControl {
|
|
347
|
+
constructor(valueToControls, value, validators) {
|
|
348
|
+
const initialValue = value || [];
|
|
349
|
+
super(initialValue, validators);
|
|
350
|
+
this.valueToControls = valueToControls;
|
|
351
|
+
this.currentControls = initialValue.map((value) => this.createControls(value));
|
|
352
|
+
this.uuid = uuid.v4();
|
|
353
|
+
}
|
|
354
|
+
get controls() {
|
|
355
|
+
return this.currentControls;
|
|
356
|
+
}
|
|
357
|
+
get touched() {
|
|
358
|
+
return this.controls.reduce((valid, controls) => valid && controlsPartialChecked(controls, 'touched'), true);
|
|
359
|
+
}
|
|
360
|
+
get dirty() {
|
|
361
|
+
return this.controls.reduce((valid, controls) => valid && controlsPartialChecked(controls, 'dirty'), true);
|
|
362
|
+
}
|
|
363
|
+
get valid() {
|
|
364
|
+
return (this.currentValid &&
|
|
365
|
+
this.controls.reduce((valid, controls) => valid && controlsAllChecked(controls, 'valid'), true));
|
|
366
|
+
}
|
|
367
|
+
get value() {
|
|
368
|
+
return this.controls.map((controls) => controlsToValue(controls));
|
|
369
|
+
}
|
|
370
|
+
setValue(values) {
|
|
371
|
+
this.currentControls = values.map((value) => this.createControls(value));
|
|
372
|
+
}
|
|
373
|
+
push(controls) {
|
|
374
|
+
this.currentControls = this.currentControls.concat([controls]);
|
|
375
|
+
}
|
|
376
|
+
remove(controls) {
|
|
377
|
+
this.currentControls = this.currentControls.filter((currentControls) => currentControls !== controls);
|
|
378
|
+
}
|
|
379
|
+
createControls(value) {
|
|
380
|
+
const controls = this.valueToControls(value);
|
|
381
|
+
Object.values(controls).forEach((control) => {
|
|
382
|
+
control.subscribe(() => {
|
|
383
|
+
const { value, validators } = this;
|
|
384
|
+
this.updateValueAndValidity(value, validators);
|
|
385
|
+
this.observable.next(value);
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
return controls;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
function formArrayList(valueToControl, value, validators) {
|
|
392
|
+
return new FormArrayList(valueToControl, value, validators);
|
|
389
393
|
}
|
|
390
394
|
|
|
391
|
-
class FormArray {
|
|
392
|
-
constructor(arrayOptions, arrayValidators) {
|
|
393
|
-
this.currentGroups = [];
|
|
394
|
-
this.currentValid = true;
|
|
395
|
-
this.currentDisabled = false;
|
|
396
|
-
this.currentErrors = [];
|
|
397
|
-
const { groups, validators } = createFormArrayOptions(arrayOptions, arrayValidators);
|
|
398
|
-
this.unsusbcriptions = new Map();
|
|
399
|
-
this.
|
|
400
|
-
this.validators = validators;
|
|
401
|
-
this.refresh(this.
|
|
402
|
-
this.observable = commons.observable(this.value);
|
|
403
|
-
groups?.forEach((group) => {
|
|
404
|
-
this.subscription(group);
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
get groups() {
|
|
408
|
-
return this.currentGroups;
|
|
409
|
-
}
|
|
410
|
-
get controls() {
|
|
411
|
-
return this.groups.map(({ controls }) => controls);
|
|
412
|
-
}
|
|
413
|
-
get touched() {
|
|
414
|
-
return groupPartialChecked(this.groups, 'touched');
|
|
415
|
-
}
|
|
416
|
-
get touchedAll() {
|
|
417
|
-
return groupAllChecked(this.groups, 'touchedAll');
|
|
418
|
-
}
|
|
419
|
-
get untouched() {
|
|
420
|
-
return !this.touched;
|
|
421
|
-
}
|
|
422
|
-
get untouchedAll() {
|
|
423
|
-
return !this.touchedAll;
|
|
424
|
-
}
|
|
425
|
-
get dirty() {
|
|
426
|
-
return groupPartialChecked(this.groups, 'dirty');
|
|
427
|
-
}
|
|
428
|
-
get dirtyAll() {
|
|
429
|
-
return groupAllChecked(this.groups, 'dirtyAll');
|
|
430
|
-
}
|
|
431
|
-
get pristine() {
|
|
432
|
-
return !this.dirty;
|
|
433
|
-
}
|
|
434
|
-
get pristineAll() {
|
|
435
|
-
return !this.dirtyAll;
|
|
436
|
-
}
|
|
437
|
-
get disabled() {
|
|
438
|
-
return this.currentDisabled;
|
|
439
|
-
}
|
|
440
|
-
get enabled() {
|
|
441
|
-
return !this.currentDisabled;
|
|
442
|
-
}
|
|
443
|
-
get valid() {
|
|
444
|
-
return this.currentValid && groupAllChecked(this.groups, 'valid');
|
|
445
|
-
}
|
|
446
|
-
get invalid() {
|
|
447
|
-
return !this.currentValid;
|
|
448
|
-
}
|
|
449
|
-
get value() {
|
|
450
|
-
return this.groups.map(({ value: state }) => state);
|
|
451
|
-
}
|
|
452
|
-
get error() {
|
|
453
|
-
return this.currentError;
|
|
454
|
-
}
|
|
455
|
-
get errors() {
|
|
456
|
-
return this.currentErrors;
|
|
457
|
-
}
|
|
458
|
-
get wrong() {
|
|
459
|
-
return this.touched && this.invalid;
|
|
460
|
-
}
|
|
461
|
-
hasError(key) {
|
|
462
|
-
return hasError(this.errors, key);
|
|
463
|
-
}
|
|
464
|
-
someErrors(keys) {
|
|
465
|
-
return someErrors(this.errors, keys);
|
|
466
|
-
}
|
|
467
|
-
reset() {
|
|
468
|
-
this.refresh(this.
|
|
469
|
-
}
|
|
470
|
-
disable() {
|
|
471
|
-
this.currentDisabled = true;
|
|
472
|
-
}
|
|
473
|
-
enable() {
|
|
474
|
-
this.currentDisabled = false;
|
|
475
|
-
}
|
|
476
|
-
push(group) {
|
|
477
|
-
this.subscription(group);
|
|
478
|
-
this.refresh([...this.groups, group]);
|
|
479
|
-
}
|
|
480
|
-
merge(groups) {
|
|
481
|
-
groups.forEach((group) => {
|
|
482
|
-
this.subscription(group);
|
|
483
|
-
});
|
|
484
|
-
this.refresh([...this.groups, ...groups]);
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
this.
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
this.
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
this.
|
|
520
|
-
this.
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
395
|
+
class FormArray {
|
|
396
|
+
constructor(arrayOptions, arrayValidators) {
|
|
397
|
+
this.currentGroups = [];
|
|
398
|
+
this.currentValid = true;
|
|
399
|
+
this.currentDisabled = false;
|
|
400
|
+
this.currentErrors = [];
|
|
401
|
+
const { groups, validators } = createFormArrayOptions(arrayOptions, arrayValidators);
|
|
402
|
+
this.unsusbcriptions = new Map();
|
|
403
|
+
this.initialValue = groups;
|
|
404
|
+
this.validators = validators;
|
|
405
|
+
this.refresh(this.initialValue);
|
|
406
|
+
this.observable = commons.observable(this.value);
|
|
407
|
+
groups?.forEach((group) => {
|
|
408
|
+
this.subscription(group);
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
get groups() {
|
|
412
|
+
return this.currentGroups;
|
|
413
|
+
}
|
|
414
|
+
get controls() {
|
|
415
|
+
return this.groups.map(({ controls }) => controls);
|
|
416
|
+
}
|
|
417
|
+
get touched() {
|
|
418
|
+
return groupPartialChecked(this.groups, 'touched');
|
|
419
|
+
}
|
|
420
|
+
get touchedAll() {
|
|
421
|
+
return groupAllChecked(this.groups, 'touchedAll');
|
|
422
|
+
}
|
|
423
|
+
get untouched() {
|
|
424
|
+
return !this.touched;
|
|
425
|
+
}
|
|
426
|
+
get untouchedAll() {
|
|
427
|
+
return !this.touchedAll;
|
|
428
|
+
}
|
|
429
|
+
get dirty() {
|
|
430
|
+
return groupPartialChecked(this.groups, 'dirty');
|
|
431
|
+
}
|
|
432
|
+
get dirtyAll() {
|
|
433
|
+
return groupAllChecked(this.groups, 'dirtyAll');
|
|
434
|
+
}
|
|
435
|
+
get pristine() {
|
|
436
|
+
return !this.dirty;
|
|
437
|
+
}
|
|
438
|
+
get pristineAll() {
|
|
439
|
+
return !this.dirtyAll;
|
|
440
|
+
}
|
|
441
|
+
get disabled() {
|
|
442
|
+
return this.currentDisabled;
|
|
443
|
+
}
|
|
444
|
+
get enabled() {
|
|
445
|
+
return !this.currentDisabled;
|
|
446
|
+
}
|
|
447
|
+
get valid() {
|
|
448
|
+
return this.currentValid && groupAllChecked(this.groups, 'valid');
|
|
449
|
+
}
|
|
450
|
+
get invalid() {
|
|
451
|
+
return !this.currentValid;
|
|
452
|
+
}
|
|
453
|
+
get value() {
|
|
454
|
+
return this.groups.map(({ value: state }) => state);
|
|
455
|
+
}
|
|
456
|
+
get error() {
|
|
457
|
+
return this.currentError;
|
|
458
|
+
}
|
|
459
|
+
get errors() {
|
|
460
|
+
return this.currentErrors;
|
|
461
|
+
}
|
|
462
|
+
get wrong() {
|
|
463
|
+
return this.touched && this.invalid;
|
|
464
|
+
}
|
|
465
|
+
hasError(key) {
|
|
466
|
+
return hasError(this.errors, key);
|
|
467
|
+
}
|
|
468
|
+
someErrors(keys) {
|
|
469
|
+
return someErrors(this.errors, keys);
|
|
470
|
+
}
|
|
471
|
+
reset() {
|
|
472
|
+
this.refresh(this.initialValue);
|
|
473
|
+
}
|
|
474
|
+
disable() {
|
|
475
|
+
this.currentDisabled = true;
|
|
476
|
+
}
|
|
477
|
+
enable() {
|
|
478
|
+
this.currentDisabled = false;
|
|
479
|
+
}
|
|
480
|
+
push(group) {
|
|
481
|
+
this.subscription(group);
|
|
482
|
+
this.refresh([...this.groups, group]);
|
|
483
|
+
}
|
|
484
|
+
merge(groups) {
|
|
485
|
+
groups.forEach((group) => {
|
|
486
|
+
this.subscription(group);
|
|
487
|
+
});
|
|
488
|
+
this.refresh([...this.groups, ...groups]);
|
|
489
|
+
}
|
|
490
|
+
setInitialValue(groups) {
|
|
491
|
+
this.initialValue = groups;
|
|
492
|
+
this.setValue(groups);
|
|
493
|
+
}
|
|
494
|
+
setValue(groups) {
|
|
495
|
+
this.currentGroups.forEach(({ uuid }) => {
|
|
496
|
+
this.unsusbcriptions.delete(uuid);
|
|
497
|
+
});
|
|
498
|
+
groups.forEach((group) => {
|
|
499
|
+
this.subscription(group);
|
|
500
|
+
});
|
|
501
|
+
this.refresh(groups); // Update groups
|
|
502
|
+
}
|
|
503
|
+
remove({ uuid }) {
|
|
504
|
+
this.refresh(this.groups.filter((group) => group.uuid !== uuid));
|
|
505
|
+
}
|
|
506
|
+
setValidators(validators) {
|
|
507
|
+
this.validators = validators;
|
|
508
|
+
this.updateValidityStatus(this.groups, validators);
|
|
509
|
+
}
|
|
510
|
+
subscribe(subscriber) {
|
|
511
|
+
return this.observable.subscribe(subscriber);
|
|
512
|
+
}
|
|
513
|
+
subscription(group) {
|
|
514
|
+
const unsusbcription = group.subscribe(() => {
|
|
515
|
+
this.updateValidityStatus(this.groups, this.validators);
|
|
516
|
+
});
|
|
517
|
+
this.unsusbcriptions.set(group.uuid, unsusbcription);
|
|
518
|
+
}
|
|
519
|
+
updateValidityStatus(groups, validators) {
|
|
520
|
+
if (validators) {
|
|
521
|
+
const errors = arrayIsValid({ groups, validators });
|
|
522
|
+
this.currentErrors = errors;
|
|
523
|
+
this.currentError = errors[0];
|
|
524
|
+
this.currentValid = errors.length === 0;
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
this.currentValid = true;
|
|
528
|
+
this.currentErrors = [];
|
|
529
|
+
this.currentError = undefined;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
refresh(newGroups) {
|
|
533
|
+
const groups = newGroups || [];
|
|
534
|
+
this.currentGroups = groups;
|
|
535
|
+
this.updateValidityStatus(groups, this.validators);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
function formArray(options, validators) {
|
|
539
|
+
return new FormArray(createFormArrayOptions(options, validators));
|
|
532
540
|
}
|
|
533
541
|
|
|
534
542
|
exports.FormArray = FormArray;
|