@sumaris-net/ngx-components 0.27.12 → 0.27.16

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.
@@ -2654,7 +2654,7 @@
2654
2654
  function ArrayIncludesPipe() {
2655
2655
  }
2656
2656
  ArrayIncludesPipe.prototype.transform = function (val, args) {
2657
- return val && val.includes(args);
2657
+ return val && val.includes(args) || false;
2658
2658
  };
2659
2659
  return ArrayIncludesPipe;
2660
2660
  }());
@@ -2805,7 +2805,7 @@
2805
2805
  // Compute a contextual i18n key, using the context as suffix
2806
2806
  var contextKey = this.contextualKey(key, context);
2807
2807
  // Return the contextual translation, or default of not exists
2808
- return this.translate.get(contextKey)
2808
+ return this.translate.get(contextKey, interpolateParams)
2809
2809
  .pipe(operators.mergeMap(function (translation) { return (translation !== contextKey) ? rxjs.of(translation) : _this.translate.get(key); }));
2810
2810
  };
2811
2811
  TranslateContextService.prototype.instant = function (key, context, interpolateParams) {
@@ -2815,8 +2815,8 @@
2815
2815
  // Compute a contextual i18n key, using the context as suffix
2816
2816
  var contextualKey = this.contextualKey(key, context);
2817
2817
  // Return the contextual translation, or default of not exists
2818
- var translation = this.translate.instant(contextualKey);
2819
- return (translation !== contextualKey) ? translation : this.translate.instant(key);
2818
+ var translation = this.translate.instant(contextualKey, interpolateParams);
2819
+ return (translation !== contextualKey) ? translation : this.translate.instant(key, interpolateParams);
2820
2820
  };
2821
2821
  /**
2822
2822
  * Compute a contextual i18n key, using the context as suffix
@@ -2926,6 +2926,18 @@
2926
2926
  var SharedValidators = /** @class */ (function () {
2927
2927
  function SharedValidators() {
2928
2928
  }
2929
+ SharedValidators.getDoubleRegexp = function (maxDecimals) {
2930
+ if (isNil(maxDecimals))
2931
+ return this._REGEXP_CACHE.DOUBLE_BY_MAX_DECIMALS.NO_LIMIT;
2932
+ if (maxDecimals < 0)
2933
+ throw new Error("Invalid maxDecimals value: " + maxDecimals);
2934
+ var regexp = this._REGEXP_CACHE.DOUBLE_BY_MAX_DECIMALS[maxDecimals];
2935
+ if (regexp)
2936
+ return regexp;
2937
+ // New regexp: add it to cache
2938
+ this._REGEXP_CACHE.DOUBLE_BY_MAX_DECIMALS[maxDecimals] = new RegExp("^[-]?[0-9]+([.,][0-9]{1," + maxDecimals + "})?$");
2939
+ return this._REGEXP_CACHE.DOUBLE_BY_MAX_DECIMALS[maxDecimals];
2940
+ };
2929
2941
  SharedValidators.validDate = function (control) {
2930
2942
  var value = control.value;
2931
2943
  var date = !value || moment$4.isMoment(value) ? value : moment$4(control.value, DATE_ISO_PATTERN);
@@ -2985,24 +2997,15 @@
2985
2997
  return null;
2986
2998
  };
2987
2999
  SharedValidators.double = function (opts) {
2988
- var regexpStr;
2989
- if (opts && isNotNil(opts.maxDecimals)) {
2990
- if (opts.maxDecimals < 0)
2991
- throw new Error("Invalid maxDecimals value: " + opts.maxDecimals);
2992
- regexpStr = opts.maxDecimals > 1 ? "^[-]?[0-9]+([.,][0-9]{1," + opts.maxDecimals + "})?$" : '^[-]?[0-9]+([.,][0-9])?$';
2993
- }
2994
- else {
2995
- regexpStr = '^[-]?[0-9]+([.,][0-9]*)?$';
2996
- }
2997
- var regexp = new RegExp(regexpStr);
3000
+ var regexp = this.getDoubleRegexp(opts === null || opts === void 0 ? void 0 : opts.maxDecimals);
2998
3001
  return function (control) {
2999
3002
  var value = control.value;
3000
3003
  if (Number.isNaN(value)) {
3001
3004
  //console.log("WARN: Getting a NaN value !");
3002
- value = null;
3005
+ return null;
3003
3006
  }
3004
3007
  if (isNotNil(value) && value !== '' && !regexp.test(value)) {
3005
- return { maxDecimals: true };
3008
+ return { maxDecimals: { maxDecimals: opts === null || opts === void 0 ? void 0 : opts.maxDecimals } };
3006
3009
  }
3007
3010
  return null;
3008
3011
  };
@@ -3095,6 +3098,14 @@
3095
3098
  };
3096
3099
  return SharedValidators;
3097
3100
  }());
3101
+ SharedValidators._REGEXP_CACHE = {
3102
+ DOUBLE_BY_MAX_DECIMALS: {
3103
+ NO_LIMIT: /^[-]?[0-9]+([.,][0-9]*)?$/,
3104
+ 1: /^[-]?[0-9]+([.,][0-9])?$/,
3105
+ 2: /^[-]?[0-9]+([.,][0-9]{1,2})?$/,
3106
+ 3: /^[-]?[0-9]+([.,][0-9]{1,2})?$/,
3107
+ }
3108
+ };
3098
3109
  SharedValidators.I18N_ERROR_KEYS = {
3099
3110
  required: 'ERROR.FIELD_REQUIRED',
3100
3111
  min: 'ERROR.FIELD_MIN',