@rolster/forms 2.8.0 → 2.10.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.
@@ -58,6 +58,12 @@ function hasError(errors, key) {
58
58
  function someErrors(errors, keys) {
59
59
  return reduceErrors(errors).some((key) => keys.includes(key));
60
60
  }
61
+ function reduceControlsToArray(controls, key) {
62
+ return Object.values(controls).map((control) => control[key]);
63
+ }
64
+ function reduceGroupToArray(group, key) {
65
+ return reduceControlsToArray(group.controls, key);
66
+ }
61
67
 
62
68
  exports.arrayIsValid = arrayIsValid;
63
69
  exports.controlIsValid = controlIsValid;
@@ -68,5 +74,7 @@ exports.groupAllChecked = groupAllChecked;
68
74
  exports.groupIsValid = groupIsValid;
69
75
  exports.groupPartialChecked = groupPartialChecked;
70
76
  exports.hasError = hasError;
77
+ exports.reduceControlsToArray = reduceControlsToArray;
78
+ exports.reduceGroupToArray = reduceGroupToArray;
71
79
  exports.someErrors = someErrors;
72
80
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sources":["../esm/helpers.js"],"sourcesContent":["import { parseBoolean } from '@rolster/commons';\nfunction reduceErrors(errors) {\n return errors.reduce((keys, { id }) => [...keys, id], []);\n}\nexport const controlIsValid = ({ value, validators }) => {\n return validators.reduce((errors, validator) => {\n const error = validator(value);\n if (error) {\n errors.push(error);\n }\n return errors;\n }, []);\n};\nexport const controlsAllChecked = (controls, key) => {\n return Object.values(controls).reduce((value, control) => control.disabled ? value : value && parseBoolean(control[key]), true);\n};\nexport const controlsPartialChecked = (controls, key) => {\n return Object.values(controls).reduce((value, control) => control.disabled ? value : value || parseBoolean(control[key]), false);\n};\nexport const controlsToValue = (controls) => {\n return Object.entries(controls).reduce((result, [key, { value }]) => {\n result[key] = value;\n return result;\n }, {});\n};\nexport const groupIsValid = ({ controls, validators }) => {\n return validators.reduce((errors, validator) => {\n const error = validator(controls);\n if (error) {\n errors.push(error);\n }\n return errors;\n }, []);\n};\nexport function groupAllChecked(groups, key) {\n return groups.reduce((value, group) => value && parseBoolean(group[key]), true);\n}\nexport function groupPartialChecked(groups, key) {\n return groups.reduce((value, group) => value || parseBoolean(group[key]), false);\n}\nexport const arrayIsValid = ({ groups, validators }) => {\n return validators.reduce((errors, validator) => {\n const error = validator(groups);\n if (error) {\n errors.push(error);\n }\n return errors;\n }, []);\n};\nexport function hasError(errors, key) {\n return reduceErrors(errors).includes(key);\n}\nexport function someErrors(errors, keys) {\n return reduceErrors(errors).some((key) => keys.includes(key));\n}\n//# sourceMappingURL=helpers.js.map"],"names":["parseBoolean"],"mappings":";;;;;;AACA,SAAS,YAAY,CAAC,MAAM,EAAE;AAC9B,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAC9D,CAAC;AACW,MAAC,cAAc,GAAG,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK;AACzD,IAAI,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,SAAS,KAAK;AACpD,QAAQ,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;AACvC,QAAQ,IAAI,KAAK,EAAE;AACnB,YAAY,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC/B,SAAS;AACT,QAAQ,OAAO,MAAM,CAAC;AACtB,KAAK,EAAE,EAAE,CAAC,CAAC;AACX,EAAE;AACU,MAAC,kBAAkB,GAAG,CAAC,QAAQ,EAAE,GAAG,KAAK;AACrD,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,GAAG,KAAK,GAAG,KAAK,IAAIA,oBAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAA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AAS,mBAAmB,CAAC,MAAM,EAAE,GAAG,EAAE;AACjD,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,IAAIA,oBAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AACrF,CAAC;AACW,MAAC,YAAY,GAAG,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK;AACxD,IAAI,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,SAAS,KAAK;AACpD,QAAQ,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AACxC,QAAQ,IAAI,KAAK,EAAE;AACnB,YAAY,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC/B,SAAS;AACT,QAAQ,OAAO,MAAM,CAAC;AACtB,KAAK,EAAE,EAAE,CAAC,CAAC;AACX,EAAE;AACK,SAAS,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;AACtC,IAAI,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC9C,CAAC;AACM,SAAS,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE;AACzC,IAAI,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AAClE;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"helpers.js","sources":["../esm/helpers.js"],"sourcesContent":["import { parseBoolean } from '@rolster/commons';\nfunction reduceErrors(errors) {\n return errors.reduce((keys, { id }) => [...keys, id], []);\n}\nexport const controlIsValid = ({ value, validators }) => {\n return validators.reduce((errors, validator) => {\n const error = validator(value);\n if (error) {\n errors.push(error);\n }\n return errors;\n }, []);\n};\nexport const controlsAllChecked = (controls, key) => {\n return Object.values(controls).reduce((value, control) => control.disabled ? value : value && parseBoolean(control[key]), true);\n};\nexport const controlsPartialChecked = (controls, key) => {\n return Object.values(controls).reduce((value, control) => control.disabled ? value : value || parseBoolean(control[key]), false);\n};\nexport const controlsToValue = (controls) => {\n return Object.entries(controls).reduce((result, [key, { value }]) => {\n result[key] = value;\n return result;\n }, {});\n};\nexport const groupIsValid = ({ controls, validators }) => {\n return validators.reduce((errors, validator) => {\n const error = validator(controls);\n if (error) {\n errors.push(error);\n }\n return errors;\n }, []);\n};\nexport function groupAllChecked(groups, key) {\n return groups.reduce((value, group) => value && parseBoolean(group[key]), true);\n}\nexport function groupPartialChecked(groups, key) {\n return groups.reduce((value, group) => value || parseBoolean(group[key]), false);\n}\nexport const arrayIsValid = ({ groups, validators }) => {\n return validators.reduce((errors, validator) => {\n const error = validator(groups);\n if (error) {\n errors.push(error);\n }\n return errors;\n }, []);\n};\nexport function hasError(errors, key) {\n return reduceErrors(errors).includes(key);\n}\nexport function someErrors(errors, keys) {\n return reduceErrors(errors).some((key) => keys.includes(key));\n}\nexport function reduceControlsToArray(controls, key) {\n return Object.values(controls).map((control) => control[key]);\n}\nexport function reduceGroupToArray(group, key) {\n return reduceControlsToArray(group.controls, key);\n}\n//# sourceMappingURL=helpers.js.map"],"names":["parseBoolean"],"mappings":";;;;;;AACA,SAAS,YAAY,CAAC,MAAM,EAAE;AAC9B,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAC9D,CAAC;AACW,MAAC,cAAc,GAAG,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK;AACzD,IAAI,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,SAAS,KAAK;AACpD,QAAQ,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;AACvC,QAAQ,IAAI,KAAK,EAAE;AACnB,YAAY,MAAM,CAAC,IAAI,CAAC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,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AAClE,CAAC;AACM,SAAS,qBAAqB,CAAC,QAAQ,EAAE,GAAG,EAAE;AACrD,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AAClE,CAAC;AACM,SAAS,kBAAkB,CAAC,KAAK,EAAE,GAAG,EAAE;AAC/C,IAAI,OAAO,qBAAqB,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AACtD;;;;;;;;;;;;;;;"}
package/dist/cjs/index.js CHANGED
@@ -109,58 +109,58 @@ function someErrors(errors, keys) {
109
109
  }
110
110
 
111
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);
112
+ constructor(options, validators) {
113
+ this._focused = false;
114
+ this._touched = false;
115
+ this._dirty = false;
116
+ this._disabled = false;
117
+ this._valid = true;
118
+ this._errors = [];
119
+ const _options = createFormControlOptions(options, validators);
120
+ this.observable = commons.observable(_options.value);
121
+ this.currentValue = _options.value;
122
+ this.validators = _options.validators;
123
+ this._value = _options.value;
124
+ this.updateValueAndValidity(_options.value, _options.validators);
125
125
  }
126
126
  get focused() {
127
- return this.currentFocused;
127
+ return this._focused;
128
128
  }
129
129
  get unfocused() {
130
- return !this.currentFocused;
130
+ return !this._focused;
131
131
  }
132
132
  get touched() {
133
- return this.currentTouched;
133
+ return this._touched;
134
134
  }
135
135
  get untouched() {
136
- return !this.currentTouched;
136
+ return !this._touched;
137
137
  }
138
138
  get dirty() {
139
- return this.currentDirty;
139
+ return this._dirty;
140
140
  }
141
141
  get pristine() {
142
- return !this.currentDirty;
142
+ return !this._dirty;
143
143
  }
144
144
  get disabled() {
145
- return this.currentDisabled;
145
+ return this._disabled;
146
146
  }
147
147
  get enabled() {
148
- return !this.currentDisabled;
148
+ return !this._disabled;
149
149
  }
150
150
  get valid() {
151
- return this.currentValid;
151
+ return this._valid;
152
152
  }
153
153
  get invalid() {
154
- return !this.currentValid;
154
+ return !this._valid;
155
155
  }
156
156
  get value() {
157
- return this.currentValue;
157
+ return this._value;
158
158
  }
159
159
  get errors() {
160
- return this.currentErrors;
160
+ return this._errors;
161
161
  }
162
162
  get error() {
163
- return this.currentError;
163
+ return this._error;
164
164
  }
165
165
  get wrong() {
166
166
  return this.touched && this.invalid;
@@ -172,30 +172,34 @@ class FormControl {
172
172
  return someErrors(this.errors, keys);
173
173
  }
174
174
  reset() {
175
- this.setValue(this.initialValue);
176
- this.currentDirty = false;
177
- this.currentTouched = false;
175
+ this.setValue(this.currentValue);
176
+ this._dirty = false;
177
+ this._touched = false;
178
178
  }
179
179
  focus() {
180
- this.currentFocused = true;
180
+ this._focused = true;
181
181
  }
182
182
  blur() {
183
- this.currentFocused = false;
184
- this.currentTouched = true;
183
+ this._focused = false;
184
+ this._touched = true;
185
185
  }
186
186
  disable() {
187
- this.currentDisabled = true;
187
+ this._disabled = true;
188
188
  }
189
189
  enable() {
190
- this.currentDisabled = false;
190
+ this._disabled = false;
191
191
  }
192
192
  touch() {
193
- this.currentTouched = true;
193
+ this._touched = true;
194
+ }
195
+ setInitialValue(value) {
196
+ this.currentValue = value;
197
+ this.setValue(value);
194
198
  }
195
199
  setValue(value) {
196
200
  if (this.enabled) {
197
- this.currentValue = value;
198
- this.currentDirty = true;
201
+ this._value = value;
202
+ this._dirty = true;
199
203
  this.updateValueAndValidity(value, this.validators);
200
204
  this.observable.next(value);
201
205
  }
@@ -210,14 +214,14 @@ class FormControl {
210
214
  updateValueAndValidity(value, validators) {
211
215
  if (validators) {
212
216
  const errors = controlIsValid({ value, validators });
213
- this.currentError = errors[0];
214
- this.currentErrors = errors;
215
- this.currentValid = errors.length === 0;
217
+ this._error = errors[0];
218
+ this._errors = errors;
219
+ this._valid = errors.length === 0;
216
220
  }
217
221
  else {
218
- this.currentValid = true;
219
- this.currentError = undefined;
220
- this.currentErrors = [];
222
+ this._valid = true;
223
+ this._error = undefined;
224
+ this._errors = [];
221
225
  }
222
226
  }
223
227
  }
@@ -226,9 +230,9 @@ function formControl(options, validators) {
226
230
  }
227
231
 
228
232
  class FormArrayControl extends FormControl {
229
- constructor(controlOptions, controlValidators) {
230
- const { value, validators } = createFormControlOptions(controlOptions, controlValidators);
231
- super(value, validators);
233
+ constructor(options, validators) {
234
+ const _options = createFormControlOptions(options, validators);
235
+ super(_options.value, _options.validators);
232
236
  this.uuid = uuid.v4();
233
237
  }
234
238
  }
@@ -237,15 +241,15 @@ function formArrayControl(options, validators) {
237
241
  }
238
242
 
239
243
  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);
244
+ constructor(options, validators) {
245
+ this._errors = [];
246
+ this._valid = true;
247
+ const _options = createFormGroupOptions(options, validators);
248
+ this._controls = _options.controls;
249
+ this.validators = _options.validators;
250
+ this.updateValueAndValidity(_options.controls, _options.validators);
247
251
  this.observable = commons.observable(this.value);
248
- Object.values(controls).forEach((control) => {
252
+ Object.values(_options.controls).forEach((control) => {
249
253
  control.subscribe(() => {
250
254
  this.updateValueAndValidity(this.controls, this.validators);
251
255
  this.observable.next(this.value);
@@ -253,34 +257,34 @@ class FormGroup {
253
257
  });
254
258
  }
255
259
  get controls() {
256
- return this.currentControls;
260
+ return this._controls;
257
261
  }
258
262
  get touched() {
259
263
  return controlsPartialChecked(this.controls, 'touched');
260
264
  }
261
- get touchedAll() {
265
+ get toucheds() {
262
266
  return controlsAllChecked(this.controls, 'touched');
263
267
  }
264
268
  get untouched() {
265
269
  return !this.touched;
266
270
  }
267
- get untouchedAll() {
268
- return !this.touchedAll;
271
+ get untoucheds() {
272
+ return !this.toucheds;
269
273
  }
270
274
  get dirty() {
271
275
  return controlsPartialChecked(this.controls, 'dirty');
272
276
  }
273
- get dirtyAll() {
277
+ get dirties() {
274
278
  return controlsAllChecked(this.controls, 'dirty');
275
279
  }
276
280
  get pristine() {
277
281
  return !this.dirty;
278
282
  }
279
- get pristineAll() {
280
- return this.dirtyAll;
283
+ get pristines() {
284
+ return this.dirties;
281
285
  }
282
286
  get valid() {
283
- return this.currentValid && controlsAllChecked(this.controls, 'valid');
287
+ return this._valid && controlsAllChecked(this.controls, 'valid');
284
288
  }
285
289
  get invalid() {
286
290
  return !this.valid;
@@ -289,10 +293,10 @@ class FormGroup {
289
293
  return controlsToValue(this.controls);
290
294
  }
291
295
  get errors() {
292
- return this.currentErrors;
296
+ return this._errors;
293
297
  }
294
298
  get error() {
295
- return this.currentError;
299
+ return this._error;
296
300
  }
297
301
  get wrong() {
298
302
  return this.touched && this.invalid;
@@ -312,14 +316,14 @@ class FormGroup {
312
316
  updateValueAndValidity(controls, validators) {
313
317
  if (validators) {
314
318
  const errors = groupIsValid({ controls, validators });
315
- this.currentErrors = errors;
316
- this.currentError = errors[0];
317
- this.currentValid = errors.length === 0;
319
+ this._errors = errors;
320
+ this._error = errors[0];
321
+ this._valid = errors.length === 0;
318
322
  }
319
323
  else {
320
- this.currentErrors = [];
321
- this.currentError = undefined;
322
- this.currentValid = true;
324
+ this._errors = [];
325
+ this._error = undefined;
326
+ this._valid = true;
323
327
  }
324
328
  }
325
329
  }
@@ -328,11 +332,11 @@ function formGroup(options, validators) {
328
332
  }
329
333
 
330
334
  class FormArrayGroup extends FormGroup {
331
- constructor(groupOptions, groupValidators) {
332
- const { controls, resource, validators } = createFormGroupOptions(groupOptions, groupValidators);
333
- super(controls, validators);
335
+ constructor(options, validators) {
336
+ const _options = createFormGroupOptions(options, validators);
337
+ super(_options.controls, _options.validators);
334
338
  this.uuid = uuid.v4();
335
- this.resource = resource;
339
+ this.resource = _options.resource;
336
340
  }
337
341
  }
338
342
  function formArrayGroup(options, validators) {
@@ -341,14 +345,14 @@ function formArrayGroup(options, validators) {
341
345
 
342
346
  class FormArrayList extends FormControl {
343
347
  constructor(valueToControls, value, validators) {
344
- const initialValue = value || [];
345
- super(initialValue, validators);
348
+ const _value = value || [];
349
+ super(_value, validators);
346
350
  this.valueToControls = valueToControls;
347
- this.currentControls = initialValue.map((value) => this.createControls(value));
351
+ this._controls = _value.map((value) => this.createControls(value));
348
352
  this.uuid = uuid.v4();
349
353
  }
350
354
  get controls() {
351
- return this.currentControls;
355
+ return this._controls;
352
356
  }
353
357
  get touched() {
354
358
  return this.controls.reduce((valid, controls) => valid && controlsPartialChecked(controls, 'touched'), true);
@@ -357,20 +361,20 @@ class FormArrayList extends FormControl {
357
361
  return this.controls.reduce((valid, controls) => valid && controlsPartialChecked(controls, 'dirty'), true);
358
362
  }
359
363
  get valid() {
360
- return (this.currentValid &&
364
+ return (this._valid &&
361
365
  this.controls.reduce((valid, controls) => valid && controlsAllChecked(controls, 'valid'), true));
362
366
  }
363
367
  get value() {
364
368
  return this.controls.map((controls) => controlsToValue(controls));
365
369
  }
366
370
  setValue(values) {
367
- this.currentControls = values.map((value) => this.createControls(value));
371
+ this._controls = values.map((value) => this.createControls(value));
368
372
  }
369
373
  push(controls) {
370
- this.currentControls = this.currentControls.concat([controls]);
374
+ this._controls = this._controls.concat([controls]);
371
375
  }
372
376
  remove(controls) {
373
- this.currentControls = this.currentControls.filter((currentControls) => currentControls !== controls);
377
+ this._controls = this._controls.filter((_controls) => _controls !== controls);
374
378
  }
375
379
  createControls(value) {
376
380
  const controls = this.valueToControls(value);
@@ -389,23 +393,23 @@ function formArrayList(valueToControl, value, validators) {
389
393
  }
390
394
 
391
395
  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);
396
+ constructor(options, validators) {
397
+ this._groups = [];
398
+ this._valid = true;
399
+ this._disabled = false;
400
+ this._errors = [];
401
+ const _options = createFormArrayOptions(options, validators);
398
402
  this.unsusbcriptions = new Map();
399
- this.initialState = groups;
400
- this.validators = validators;
401
- this.refresh(this.initialState);
403
+ this.currentValue = _options.groups;
404
+ this.validators = _options.validators;
405
+ this.refresh(this.currentValue);
402
406
  this.observable = commons.observable(this.value);
403
- groups?.forEach((group) => {
407
+ _options.groups?.forEach((group) => {
404
408
  this.subscription(group);
405
409
  });
406
410
  }
407
411
  get groups() {
408
- return this.currentGroups;
412
+ return this._groups;
409
413
  }
410
414
  get controls() {
411
415
  return this.groups.map(({ controls }) => controls);
@@ -413,47 +417,47 @@ class FormArray {
413
417
  get touched() {
414
418
  return groupPartialChecked(this.groups, 'touched');
415
419
  }
416
- get touchedAll() {
417
- return groupAllChecked(this.groups, 'touchedAll');
420
+ get toucheds() {
421
+ return groupAllChecked(this.groups, 'toucheds');
418
422
  }
419
423
  get untouched() {
420
424
  return !this.touched;
421
425
  }
422
- get untouchedAll() {
423
- return !this.touchedAll;
426
+ get untoucheds() {
427
+ return !this.toucheds;
424
428
  }
425
429
  get dirty() {
426
430
  return groupPartialChecked(this.groups, 'dirty');
427
431
  }
428
- get dirtyAll() {
429
- return groupAllChecked(this.groups, 'dirtyAll');
432
+ get dirties() {
433
+ return groupAllChecked(this.groups, 'dirties');
430
434
  }
431
435
  get pristine() {
432
436
  return !this.dirty;
433
437
  }
434
- get pristineAll() {
435
- return !this.dirtyAll;
438
+ get pristines() {
439
+ return !this.dirties;
436
440
  }
437
441
  get disabled() {
438
- return this.currentDisabled;
442
+ return this._disabled;
439
443
  }
440
444
  get enabled() {
441
- return !this.currentDisabled;
445
+ return !this._disabled;
442
446
  }
443
447
  get valid() {
444
- return this.currentValid && groupAllChecked(this.groups, 'valid');
448
+ return this._valid && groupAllChecked(this.groups, 'valid');
445
449
  }
446
450
  get invalid() {
447
- return !this.currentValid;
451
+ return !this._valid;
448
452
  }
449
453
  get value() {
450
454
  return this.groups.map(({ value: state }) => state);
451
455
  }
452
456
  get error() {
453
- return this.currentError;
457
+ return this._error;
454
458
  }
455
459
  get errors() {
456
- return this.currentErrors;
460
+ return this._errors;
457
461
  }
458
462
  get wrong() {
459
463
  return this.touched && this.invalid;
@@ -465,13 +469,13 @@ class FormArray {
465
469
  return someErrors(this.errors, keys);
466
470
  }
467
471
  reset() {
468
- this.refresh(this.initialState);
472
+ this.refresh(this.currentValue);
469
473
  }
470
474
  disable() {
471
- this.currentDisabled = true;
475
+ this._disabled = true;
472
476
  }
473
477
  enable() {
474
- this.currentDisabled = false;
478
+ this._disabled = false;
475
479
  }
476
480
  push(group) {
477
481
  this.subscription(group);
@@ -483,8 +487,12 @@ class FormArray {
483
487
  });
484
488
  this.refresh([...this.groups, ...groups]);
485
489
  }
486
- set(groups) {
487
- this.currentGroups.forEach(({ uuid }) => {
490
+ setInitialValue(groups) {
491
+ this.currentValue = groups;
492
+ this.setValue(groups);
493
+ }
494
+ setValue(groups) {
495
+ this._groups.forEach(({ uuid }) => {
488
496
  this.unsusbcriptions.delete(uuid);
489
497
  });
490
498
  groups.forEach((group) => {
@@ -511,19 +519,19 @@ class FormArray {
511
519
  updateValidityStatus(groups, validators) {
512
520
  if (validators) {
513
521
  const errors = arrayIsValid({ groups, validators });
514
- this.currentErrors = errors;
515
- this.currentError = errors[0];
516
- this.currentValid = errors.length === 0;
522
+ this._errors = errors;
523
+ this._error = errors[0];
524
+ this._valid = errors.length === 0;
517
525
  }
518
526
  else {
519
- this.currentValid = true;
520
- this.currentErrors = [];
521
- this.currentError = undefined;
527
+ this._valid = true;
528
+ this._errors = [];
529
+ this._error = undefined;
522
530
  }
523
531
  }
524
532
  refresh(newGroups) {
525
533
  const groups = newGroups || [];
526
- this.currentGroups = groups;
534
+ this._groups = groups;
527
535
  this.updateValidityStatus(groups, this.validators);
528
536
  }
529
537
  }