@sumaris-net/ngx-components 0.27.21 → 0.28.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.
@@ -731,6 +731,60 @@
731
731
  return res;
732
732
  }, {});
733
733
  }
734
+ /**
735
+ * Determines if two objects or two values are equivalent.
736
+ *
737
+ * Two objects or values are considered equivalent if at least one of the following is true:
738
+ *
739
+ * * Both objects or values pass `===` comparison.
740
+ * * Both objects or values are of the same type and all of their properties are equal by
741
+ * comparing them with `equals`.
742
+ *
743
+ * @param o1 Object or value to compare.
744
+ * @param o2 Object or value to compare.
745
+ * @returns true if arguments are equal.
746
+ */
747
+ function equals(o1, o2) {
748
+ if (o1 === o2)
749
+ return true;
750
+ if (o1 === null || o2 === null)
751
+ return false;
752
+ if (o1 !== o1 && o2 !== o2)
753
+ return true; // NaN === NaN
754
+ var t1 = typeof o1, t2 = typeof o2, length, key, keySet;
755
+ if (t1 == t2 && t1 == 'object') {
756
+ if (Array.isArray(o1)) {
757
+ if (!Array.isArray(o2))
758
+ return false;
759
+ if ((length = o1.length) == o2.length) {
760
+ for (key = 0; key < length; key++) {
761
+ if (!equals(o1[key], o2[key]))
762
+ return false;
763
+ }
764
+ return true;
765
+ }
766
+ }
767
+ else {
768
+ if (Array.isArray(o2)) {
769
+ return false;
770
+ }
771
+ keySet = Object.create(null);
772
+ for (key in o1) {
773
+ if (!equals(o1[key], o2[key])) {
774
+ return false;
775
+ }
776
+ keySet[key] = true;
777
+ }
778
+ for (key in o2) {
779
+ if (!(key in keySet) && typeof o2[key] !== 'undefined') {
780
+ return false;
781
+ }
782
+ }
783
+ return true;
784
+ }
785
+ }
786
+ return false;
787
+ }
734
788
  var Beans = /** @class */ (function () {
735
789
  function Beans() {
736
790
  }
@@ -2427,7 +2481,7 @@
2427
2481
  return date1 && date2 && date1.isSameOrBefore(date2) ? date1 : date2;
2428
2482
  };
2429
2483
  DateUtils.max = function (date1, date2) {
2430
- return date1 && date2 && date1.isSameOrAfter(date2) ? date1 : date2;
2484
+ return !date1 ? date2 : (!date2 || date1.isSameOrAfter(date2) ? date1 : date2);
2431
2485
  };
2432
2486
  return DateUtils;
2433
2487
  }());
@@ -2800,7 +2854,7 @@
2800
2854
  TranslateContextService.prototype.get = function (key, context, interpolateParams) {
2801
2855
  var _this = this;
2802
2856
  // No context: do a normal translate
2803
- if (isNilOrBlank(context))
2857
+ if (!isNil(context))
2804
2858
  return this.translate.get(key, interpolateParams);
2805
2859
  // Compute a contextual i18n key, using the context as suffix
2806
2860
  var contextKey = this.contextualKey(key, context);
@@ -2847,23 +2901,51 @@
2847
2901
  ]; };
2848
2902
 
2849
2903
  var TranslateContextPipe = /** @class */ (function () {
2850
- function TranslateContextPipe(translateContext) {
2851
- this.translateContext = translateContext;
2852
- }
2853
- TranslateContextPipe.prototype.transform = function (key, context) {
2854
- return this.translateContext.instant(key, context);
2904
+ function TranslateContextPipe(translate, _ref) {
2905
+ this.translate = translate;
2906
+ this._ref = _ref;
2907
+ this.value = '';
2908
+ this.lastKey = null;
2909
+ this.lastSuffix = null;
2910
+ this.lastParams = [];
2911
+ }
2912
+ TranslateContextPipe.prototype.transform = function (query) {
2913
+ var params = [];
2914
+ for (var _i = 1; _i < arguments.length; _i++) {
2915
+ params[_i - 1] = arguments[_i];
2916
+ }
2917
+ if (!query || !query.length) {
2918
+ return query;
2919
+ }
2920
+ var suffix = params && params.length ? params[0] : '';
2921
+ params = suffix && params.slice(1);
2922
+ // if we ask another time for the same key, return the last value
2923
+ if (equalsOrNil(query, this.lastKey)
2924
+ && equals(suffix, this.lastSuffix)
2925
+ && equals(params, this.lastParams)) {
2926
+ return this.value;
2927
+ }
2928
+ // store the query, in case it changes
2929
+ this.lastKey = query;
2930
+ // store the params, in case they change
2931
+ this.lastParams = params;
2932
+ // store the params, in case they change
2933
+ this.lastSuffix = suffix;
2934
+ // set the value
2935
+ this.value = this.translate.instant(query, suffix, params);
2936
+ return this.value;
2855
2937
  };
2856
2938
  return TranslateContextPipe;
2857
2939
  }());
2858
- TranslateContextPipe.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function TranslateContextPipe_Factory() { return new TranslateContextPipe(i0__namespace.ɵɵinject(TranslateContextService)); }, token: TranslateContextPipe, providedIn: "root" });
2859
2940
  TranslateContextPipe.decorators = [
2941
+ { type: i0.Injectable },
2860
2942
  { type: i0.Pipe, args: [{
2861
2943
  name: 'translateContext'
2862
- },] },
2863
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
2944
+ },] }
2864
2945
  ];
2865
2946
  TranslateContextPipe.ctorParameters = function () { return [
2866
- { type: TranslateContextService }
2947
+ { type: TranslateContextService },
2948
+ { type: i0.ChangeDetectorRef }
2867
2949
  ]; };
2868
2950
  var TranslatablePipe = /** @class */ (function () {
2869
2951
  function TranslatablePipe() {
@@ -2875,12 +2957,11 @@
2875
2957
  };
2876
2958
  return TranslatablePipe;
2877
2959
  }());
2878
- TranslatablePipe.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function TranslatablePipe_Factory() { return new TranslatablePipe(); }, token: TranslatablePipe, providedIn: "root" });
2879
2960
  TranslatablePipe.decorators = [
2880
2961
  { type: i0.Pipe, args: [{
2881
2962
  name: 'translatable'
2882
2963
  },] },
2883
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
2964
+ { type: i0.Injectable }
2884
2965
  ];
2885
2966
 
2886
2967
  var PropertyGetPipe = /** @class */ (function () {
@@ -19279,7 +19360,7 @@
19279
19360
  }
19280
19361
  };
19281
19362
  AppForm.prototype.markAsReady = function (opts) {
19282
- if (!this._$ready.value) {
19363
+ if (this._$ready.value !== true) {
19283
19364
  this._$ready.next(true);
19284
19365
  // If subclasses implements OnReady
19285
19366
  if (typeof this['ngOnReady'] === 'function') {
@@ -28259,6 +28340,7 @@
28259
28340
  exports.disableControls = disableControls;
28260
28341
  exports.emitPromiseEvent = emitPromiseEvent;
28261
28342
  exports.entityToString = entityToString;
28343
+ exports.equals = equals;
28262
28344
  exports.equalsOrNil = equalsOrNil;
28263
28345
  exports.fadeInAnimation = fadeInAnimation;
28264
28346
  exports.fadeInOutAnimation = fadeInOutAnimation;