@sumaris-net/ngx-components 1.3.9 → 1.4.1

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.
@@ -511,9 +511,12 @@
511
511
  return value.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
512
512
  }
513
513
  function removeDiacritics(text) {
514
- return text.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
514
+ return text.normalize('NFD')
515
+ //
516
+ .replace(/[\u0300-\u036f]/g, '');
515
517
  }
516
518
  function suggestFromArray(items, value, opts) {
519
+ var _this = this;
517
520
  if (isNotNil(value) && typeof value === 'object')
518
521
  return { data: [value] };
519
522
  value = (typeof value === 'string' && value !== '*') && value.toUpperCase() || undefined;
@@ -543,19 +546,28 @@
543
546
  target = target.slice();
544
547
  target.sort(propertiesPathComparator(keys));
545
548
  var total = items.length || 0;
549
+ var fetchMore;
546
550
  // Truncate if need
547
551
  if (opts) {
548
- if (opts.offset > 0) {
552
+ if (isNil(opts.offset) && opts.offset > 0) {
549
553
  items = items.slice(opts.offset);
550
554
  }
551
- if (isNotNil(opts.size)) {
555
+ if (isNotNil(opts.size) && items.length > opts.size) {
552
556
  items = items.slice(0, opts.size);
553
557
  }
554
558
  }
555
- return {
559
+ var res = {
556
560
  data: items,
557
561
  total: total
558
562
  };
563
+ // Add fetch more capability, if total was fetched
564
+ var nextOffset = (opts && opts.offset || 0) + items.length;
565
+ if (nextOffset < total) {
566
+ res.fetchMore = function (_) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
567
+ return [2 /*return*/, suggestFromArray(items, value, Object.assign({ offset: nextOffset }, opts))];
568
+ }); }); };
569
+ }
570
+ return res;
559
571
  }
560
572
  function suggestFromStringArray(values, value, options) {
561
573
  value = (typeof value === 'string' && value !== '*') && value.toUpperCase() || undefined;
@@ -1254,7 +1266,6 @@
1254
1266
  this.required = false;
1255
1267
  this.clearable = false;
1256
1268
  this.debounceTime = null;
1257
- this.highlightAccent = false;
1258
1269
  this.i18nPrefix = 'REFERENTIAL.';
1259
1270
  this.noResultMessage = 'COMMON.NO_RESULT';
1260
1271
  this.matAutocompletePosition = 'auto';
@@ -1389,9 +1400,10 @@
1389
1400
  this.mobile = toBoolean(this.mobile, this.config.mobile);
1390
1401
  this.suggestLengthThreshold = toNumber(this.suggestLengthThreshold, this.config.suggestLengthThreshold || 0);
1391
1402
  this.showAllOnFocus = toBoolean(this.showAllOnFocus, toBoolean(this.config.showAllOnFocus, this.suggestLengthThreshold === 0));
1392
- this.showPanelOnFocus = toBoolean(this.showPanelOnFocus, toBoolean(this.config.showPanelOnFocus, true));
1403
+ this.showPanelOnFocus = toBoolean(this.showPanelOnFocus, toBoolean(this.config.showPanelOnFocus));
1393
1404
  this.classList = this.classList || this.config.class;
1394
1405
  this.debounceTime = toNumber(this.debounceTime, this.config.debounceTime);
1406
+ this.highlightAccent = toBoolean(this.highlightAccent, toBoolean(this.config.highlightAccent));
1395
1407
  }
1396
1408
  // Default values
1397
1409
  this.displayAttributes = this.displayAttributes || ((_a = this.filter) === null || _a === void 0 ? void 0 : _a.attributes) || ['label', 'name'];
@@ -1419,7 +1431,9 @@
1419
1431
  || (classList.includes('min-width-large') && '400px')
1420
1432
  || (classList.includes('min-width-xlarge') && '450px')
1421
1433
  || (classList.includes('mat-autocomplete-panel-full-size') && '100vw')));
1434
+ this.showPanelOnFocus = toBoolean(this.showPanelOnFocus, true);
1422
1435
  this.debounceTime = toNumber(this.debounceTime, 250);
1436
+ this.highlightAccent = toBoolean(this.highlightAccent, false);
1423
1437
  this.suggestLengthThreshold = this.suggestLengthThreshold || 0;
1424
1438
  // No suggestFn: filter on the given items
1425
1439
  if (!this.suggestFn) {
@@ -1499,7 +1513,7 @@
1499
1513
  .pipe(operators.map(function (_) { return _this.searchable && _this.formControl.value; })))
1500
1514
  .pipe(
1501
1515
  // If value is a string (and is not = '*'), filter if not enough character
1502
- operators.filter(function (value) { return !(typeof value === 'string' && value === '*') || value.length >= _this.suggestLengthThreshold; }),
1516
+ operators.filter(function (value) { return value === '*' || !(typeof value === 'string') || value.length >= _this.suggestLengthThreshold; }),
1503
1517
  // Distinguish changes
1504
1518
  operators.distinctUntilChanged()))
1505
1519
  .pipe(
@@ -3780,7 +3794,7 @@
3780
3794
  Object.keys(control.errors).forEach(function (error) { return console.warn(logPrefix + " -> " + (path || '') + " (" + error + ")"); });
3781
3795
  }
3782
3796
  if (control.controls) {
3783
- Object.keys(control.controls).forEach(function (child) { return logFormErrors(control.controls[child], logPrefix, (path ? path + "/" + child : child)); } // Recursive call
3797
+ Object.keys(control.controls).forEach(function (child) { return logFormErrors(control.controls[child], logPrefix, (path ? path + "." + child : child)); } // Recursive call
3784
3798
  );
3785
3799
  }
3786
3800
  }
@@ -3790,7 +3804,7 @@
3790
3804
  Object.keys(control.errors).forEach(function (error) { return console.warn(logPrefix + " -> " + (path || '') + " (" + error + ")"); });
3791
3805
  }
3792
3806
  control.controls.forEach(function (child, index) {
3793
- logFormErrors(child, logPrefix, (path ? path + "#" + index : "#" + index)); // Recursive call
3807
+ logFormErrors(child, logPrefix, (path ? path + "." + index : "" + index)); // Recursive call
3794
3808
  });
3795
3809
  }
3796
3810
  // Other control's errors
@@ -3828,7 +3842,7 @@
3828
3842
  // Form array
3829
3843
  else if (control instanceof i1.FormArray) {
3830
3844
  control.controls.forEach(function (child, index) {
3831
- getFormErrors(child, Object.assign(Object.assign({}, opts), { controlName: (opts.controlName || '') + '#' + index, result: opts.result // Make sure to keep the same result object
3845
+ getFormErrors(child, Object.assign(Object.assign({}, opts), { controlName: (opts.controlName || '') + '.' + index, result: opts.result // Make sure to keep the same result object
3832
3846
  }));
3833
3847
  });
3834
3848
  }
@@ -8331,7 +8345,9 @@
8331
8345
  return [3 /*break*/, 7];
8332
8346
  case 4:
8333
8347
  if (!this._defaultBackHref) return [3 /*break*/, 6];
8334
- return [4 /*yield*/, this.router.navigateByUrl(this._defaultBackHref)];
8348
+ return [4 /*yield*/, this.router.navigateByUrl(this._defaultBackHref, {
8349
+ replaceUrl: true
8350
+ })];
8335
8351
  case 5:
8336
8352
  _a.sent();
8337
8353
  return [3 /*break*/, 7];
@@ -23170,7 +23186,7 @@
23170
23186
  };
23171
23187
  // Add fetch more capability, if total was fetched
23172
23188
  if (withTotal) {
23173
- nextOffset_1 = offset + entities.length;
23189
+ nextOffset_1 = (offset || 0) + entities.length;
23174
23190
  if (nextOffset_1 < res.total) {
23175
23191
  res.fetchMore = function () { return _this.loadAll(nextOffset_1, size, sortBy, sortDirection, filter, opts); };
23176
23192
  }