@sumaris-net/ngx-components 1.23.36 → 1.23.38

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.
@@ -4174,7 +4174,7 @@
4174
4174
  control.disable(opts);
4175
4175
  });
4176
4176
  }
4177
- function addValueInArray(arrayControl, createControl, equals, isEmpty, value, options) {
4177
+ function pushValueInArray(arrayControl, createControl, equals, isEmpty, value, options) {
4178
4178
  options = options || { emitEvent: true };
4179
4179
  var hasChanged = false;
4180
4180
  var index = -1;
@@ -4524,6 +4524,10 @@
4524
4524
  this.equals = equals;
4525
4525
  this.isEmpty = isEmpty;
4526
4526
  this._validators = options && options.validators;
4527
+ // Register into the form array
4528
+ if (options === null || options === void 0 ? void 0 : options.helperProperty) {
4529
+ _formArray[FormArrayHelper.FORMA_HELPER_PROPERTY] = this;
4530
+ }
4527
4531
  // empty array not allow by default
4528
4532
  this.setAllowEmptyArray(toBoolean(options && options.allowEmptyArray, false));
4529
4533
  }
@@ -4535,6 +4539,9 @@
4535
4539
  }
4536
4540
  return arrayControl;
4537
4541
  };
4542
+ FormArrayHelper.hasHelper = function (formArray) {
4543
+ return formArray && !!formArray[this.FORMA_HELPER_PROPERTY];
4544
+ };
4538
4545
  Object.defineProperty(FormArrayHelper.prototype, "allowEmptyArray", {
4539
4546
  get: function () {
4540
4547
  return this._allowEmptyArray;
@@ -4552,9 +4559,17 @@
4552
4559
  enumerable: false,
4553
4560
  configurable: true
4554
4561
  });
4562
+ /**
4563
+ * @param value
4564
+ * @param options
4565
+ * @deprecated Use push() instead
4566
+ */
4555
4567
  FormArrayHelper.prototype.add = function (value, options) {
4568
+ return pushValueInArray(this._formArray, this.createControl, this.equals, this.isEmpty, value, options);
4569
+ };
4570
+ FormArrayHelper.prototype.push = function (value, options) {
4556
4571
  var _this = this;
4557
- return addValueInArray(this._formArray, function () { return _this.createControl(value); }, this.equals, this.isEmpty, value, options);
4572
+ return pushValueInArray(this._formArray, function () { return _this.createControl(value); }, this.equals, this.isEmpty, value, options);
4558
4573
  };
4559
4574
  FormArrayHelper.prototype.removeAt = function (index) {
4560
4575
  // Do not remove if last criterion
@@ -4589,27 +4604,19 @@
4589
4604
  return this._formArray.at(index);
4590
4605
  };
4591
4606
  /**
4592
- * Resize the FormArray, then set values
4593
- * @param values
4607
+ * Resize the FormArray, then patch values
4608
+ * @param data
4594
4609
  * @param opts
4595
4610
  */
4596
- FormArrayHelper.prototype.setValue = function (values, opts) {
4611
+ FormArrayHelper.prototype.patchValue = function (values, opts) {
4597
4612
  var _this = this;
4598
- this.resize(0);
4613
+ this.resize((values === null || values === void 0 ? void 0 : values.length) || 0);
4614
+ var emitEvent = (!opts || (opts === null || opts === void 0 ? void 0 : opts.emitEvent) !== false);
4599
4615
  (values || []).forEach(function (value, i) {
4600
- var isLast = i === values.length - 1;
4601
- _this.add(value, { emitEvent: isLast });
4616
+ var last = (i === values.length - 1);
4617
+ _this.push(value, { emitEvent: last && emitEvent });
4602
4618
  });
4603
4619
  };
4604
- /**
4605
- * Resize the FormArray, then patch values
4606
- * @param data
4607
- * @param opts
4608
- */
4609
- FormArrayHelper.prototype.patchValue = function (data, opts) {
4610
- this.resize((data === null || data === void 0 ? void 0 : data.length) || 0);
4611
- this._formArray.patchValue(data, opts);
4612
- };
4613
4620
  FormArrayHelper.prototype.disable = function (opts) {
4614
4621
  this._formArray.controls.forEach(function (c) { return c.disable(opts); });
4615
4622
  };
@@ -4639,6 +4646,7 @@
4639
4646
  };
4640
4647
  return FormArrayHelper;
4641
4648
  }());
4649
+ FormArrayHelper.FORMA_HELPER_PROPERTY = '_helper';
4642
4650
  // TODO continue to use this kind of declaration ?
4643
4651
  var AppFormUtils = /** @class */ (function () {
4644
4652
  function AppFormUtils() {
@@ -4672,7 +4680,7 @@
4672
4680
  AppFormUtils.updateValueAndValidity = updateValueAndValidity;
4673
4681
  AppFormUtils.getFormErrors = getFormErrors;
4674
4682
  // ArrayForm
4675
- AppFormUtils.addValueInArray = addValueInArray;
4683
+ AppFormUtils.addValueInArray = pushValueInArray;
4676
4684
  AppFormUtils.removeValueInArray = removeValueInArray;
4677
4685
  AppFormUtils.resizeArray = resizeArray;
4678
4686
  AppFormUtils.clearValueInArray = clearValueInArray;
@@ -35602,7 +35610,6 @@
35602
35610
  exports.UsersPage = UsersPage;
35603
35611
  exports.accountToString = accountToString;
35604
35612
  exports.adaptValueToControl = adaptValueToControl;
35605
- exports.addValueInArray = addValueInArray;
35606
35613
  exports.arrayDistinct = arrayDistinct;
35607
35614
  exports.arrayGroupBy = arrayGroupBy;
35608
35615
  exports.arraySize = arraySize;
@@ -35705,6 +35712,7 @@
35705
35712
  exports.propertiesPathComparator = propertiesPathComparator;
35706
35713
  exports.propertyComparator = propertyComparator;
35707
35714
  exports.propertyPathComparator = propertyPathComparator;
35715
+ exports.pushValueInArray = pushValueInArray;
35708
35716
  exports.referentialToString = referentialToString;
35709
35717
  exports.referentialsToString = referentialsToString;
35710
35718
  exports.remove = remove;