@sumaris-net/ngx-components 1.23.49 → 1.23.51

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.
@@ -1046,25 +1046,33 @@
1046
1046
  function decorateForFirst(obs, opts) {
1047
1047
  // Set take until notifier
1048
1048
  var takeUntil$ = (opts === null || opts === void 0 ? void 0 : opts.stop) || ((opts === null || opts === void 0 ? void 0 : opts.timeout) && rxjs.timer(opts.timeout));
1049
- if (takeUntil$) {
1050
- // When stop, throw an error (useful when used with a toPromise())
1051
- if (opts.stopError) {
1052
- return rxjs.merge(obs.pipe(operators.takeUntil(takeUntil$)), takeUntil$
1053
- .pipe(operators.map(function () {
1054
- throw new Error(opts.timeout ? "Timeout " + opts.timeout + "ms" : "Stop");
1055
- })));
1056
- }
1057
- // Add a takeUntil
1058
- return obs.pipe(operators.takeUntil(takeUntil$));
1059
- }
1060
- return obs;
1049
+ if (!takeUntil$)
1050
+ return obs;
1051
+ // When stop, throw an error (useful when used with a toPromise())
1052
+ if (opts.stopError) {
1053
+ var error_1;
1054
+ if (opts.stopError === true) {
1055
+ error_1 = new Error(opts.timeout ? "Timeout " + opts.timeout + "ms" : "stop");
1056
+ }
1057
+ else if (typeof opts.stopError === 'string') {
1058
+ error_1 = new Error(opts.stopError);
1059
+ }
1060
+ else {
1061
+ error_1 = opts.stopError;
1062
+ }
1063
+ takeUntil$ = takeUntil$.pipe(operators.map(function () {
1064
+ throw error_1;
1065
+ }));
1066
+ }
1067
+ return obs
1068
+ .pipe(operators.takeUntil(takeUntil$));
1061
1069
  }
1062
1070
  function firstNotNil(obs, opts) {
1063
1071
  return decorateForFirst(obs, opts).pipe(operators.first(isNotNil));
1064
1072
  }
1065
1073
  function firstTrue(obs, opts) {
1066
- return decorateForFirst(obs, opts).pipe(operators.first(function (v) { return v === true; }), operators.map(function (_) { }) // Convert to void
1067
- );
1074
+ return decorateForFirst(obs.pipe(operators.first(function (v) { return v === true; }), operators.map(function (_) { }) // Convert to void
1075
+ ), opts);
1068
1076
  }
1069
1077
  function firstFalse(obs, opts) {
1070
1078
  return decorateForFirst(obs, opts).pipe(operators.first(function (v) { return v === false; }), operators.map(function (_) { }) // Convert to void
@@ -1126,9 +1134,8 @@
1126
1134
  opts = Object.assign({ stopError: true }, opts);
1127
1135
  // dueTime (without timeout)
1128
1136
  if (opts && opts.dueTime > 0) {
1129
- return rxjs.timer(opts.dueTime)
1130
- .pipe(operators.switchMap(function () { return firstTrue(observable, opts); }))
1131
- .toPromise();
1137
+ observable = rxjs.timer(opts.dueTime)
1138
+ .pipe(operators.switchMap(function () { return observable; }));
1132
1139
  }
1133
1140
  return firstTrue(observable, opts).toPromise();
1134
1141
  }
@@ -2068,8 +2075,7 @@
2068
2075
  ? rxjs.timer(0)
2069
2076
  : this.autocomplete.opened.pipe(operators.debounceTime(200));
2070
2077
  var scrollEnd$ = opened$
2071
- .pipe(operators.map(function (_) { return _this.getAutocompletePanel(); }), operators.filter(isNotNil), operators.switchMap(function (panel) { return fromScrollEndEvent(panel, threshold)
2072
- .pipe(operators.takeUntil(_this.autocomplete.closed)); }));
2078
+ .pipe(operators.map(function (_) { return _this.getAutocompletePanel(); }), operators.filter(isNotNil), operators.switchMap(function (panel) { return fromScrollEndEvent(panel, threshold); }), operators.takeUntil(this.autocomplete.closed));
2073
2079
  // Trigger fetch more, end end scroll reached
2074
2080
  this._openedSubscription = scrollEnd$
2075
2081
  .subscribe(function () { return _this._fetchMore$.emit(); });
@@ -2090,8 +2096,7 @@
2090
2096
  ? rxjs.timer(0)
2091
2097
  : this.matSelect._openedStream.pipe(operators.debounceTime(200));
2092
2098
  var scrollEnd$ = opened$
2093
- .pipe(operators.map(function (_) { return _this.getMatSelectPanel(); }), operators.filter(isNotNil), operators.switchMap(function (panel) { return fromScrollEndEvent(panel, threshold)
2094
- .pipe(operators.takeUntil(_this.matSelect._closedStream)); }));
2099
+ .pipe(operators.map(function (_) { return _this.getMatSelectPanel(); }), operators.filter(isNotNil), operators.switchMap(function (panel) { return fromScrollEndEvent(panel, threshold); }), operators.takeUntil(this.matSelect._closedStream));
2095
2100
  // Trigger fetch more, end end scroll reached
2096
2101
  this._openedSubscription = scrollEnd$
2097
2102
  .pipe(operators.filter(function (_) { return _this._moreItemsCount > 0; }))
@@ -9069,8 +9074,7 @@
9069
9074
  ? rxjs.timer(0)
9070
9075
  : this.autocomplete.opened.pipe(operators.debounceTime(200));
9071
9076
  var scrollEnd$ = opened$
9072
- .pipe(operators.map(function (_) { return _this.getAutocompletePanel(); }), operators.filter(isNotNil), operators.switchMap(function (panel) { return fromScrollEndEvent(panel, threshold)
9073
- .pipe(operators.takeUntil(_this.autocomplete.closed)); }));
9077
+ .pipe(operators.map(function (_) { return _this.getAutocompletePanel(); }), operators.filter(isNotNil), operators.switchMap(function (panel) { return fromScrollEndEvent(panel, threshold); }), operators.takeUntil(this.autocomplete.closed));
9074
9078
  // Trigger fetch more, end end scroll reached
9075
9079
  this._openedSubscription = scrollEnd$
9076
9080
  .subscribe(function () { return _this._fetchMore$.emit(); });
@@ -21126,10 +21130,6 @@
21126
21130
  return __generator(this, function (_c) {
21127
21131
  if (this.debug)
21128
21132
  console.debug('[memory-data-service] Stopping...');
21129
- if (!this.dataSubject.closed) {
21130
- this.dataSubject.complete();
21131
- this.dataSubject.unsubscribe();
21132
- }
21133
21133
  this._hiddenData = null;
21134
21134
  this.markAsSaved();
21135
21135
  this.markAsPristine();
@@ -33922,6 +33922,130 @@
33922
33922
  { type: i0.ChangeDetectorRef }
33923
33923
  ]; };
33924
33924
 
33925
+ var ObservableTestPage = /** @class */ (function () {
33926
+ function ObservableTestPage() {
33927
+ this._stopSubject = new rxjs.Subject();
33928
+ this.$value = new rxjs.Subject();
33929
+ this.runningTaskCount = 0;
33930
+ this.taskId = 0;
33931
+ this.options = {
33932
+ stop: this._stopSubject
33933
+ };
33934
+ }
33935
+ ObservableTestPage.prototype.ngOnDestroy = function () {
33936
+ this._stopSubject.next();
33937
+ };
33938
+ ObservableTestPage.prototype.setOptions = function (opts) {
33939
+ var _a;
33940
+ this.options = Object.assign(Object.assign({}, this.options), opts);
33941
+ this.log('Options changes to: ', Object.assign(Object.assign({}, this.options), { stop: ((_a = this.options) === null || _a === void 0 ? void 0 : _a.stop) ? '$stop' : 'null' }));
33942
+ };
33943
+ ObservableTestPage.prototype.setOptionsError = function (errorMessage) {
33944
+ this.setOptions({ stopError: new Error(errorMessage) });
33945
+ };
33946
+ ObservableTestPage.prototype.firstNotNilPromise = function (opts) {
33947
+ return __awaiter(this, void 0, void 0, function () {
33948
+ var logPrefix;
33949
+ return __generator(this, function (_b) {
33950
+ switch (_b.label) {
33951
+ case 0:
33952
+ logPrefix = "[firstNotNilPromise() #" + ++this.taskId + "] ";
33953
+ return [4 /*yield*/, this.execute(firstNotNilPromise, opts, logPrefix)];
33954
+ case 1:
33955
+ _b.sent();
33956
+ return [2 /*return*/];
33957
+ }
33958
+ });
33959
+ });
33960
+ };
33961
+ ObservableTestPage.prototype.waitForTrue = function (opts) {
33962
+ return __awaiter(this, void 0, void 0, function () {
33963
+ var logPrefix;
33964
+ return __generator(this, function (_b) {
33965
+ switch (_b.label) {
33966
+ case 0:
33967
+ logPrefix = "[waitForTrue() #" + ++this.taskId + "] ";
33968
+ return [4 /*yield*/, this.execute(waitForTrue, opts, logPrefix)];
33969
+ case 1:
33970
+ _b.sent();
33971
+ return [2 /*return*/];
33972
+ }
33973
+ });
33974
+ });
33975
+ };
33976
+ ObservableTestPage.prototype.execute = function (fn, opts, logPrefix) {
33977
+ return __awaiter(this, void 0, void 0, function () {
33978
+ var value$, result, err_1, errorMsg;
33979
+ var _this = this;
33980
+ return __generator(this, function (_b) {
33981
+ switch (_b.label) {
33982
+ case 0:
33983
+ opts = Object.assign(Object.assign(Object.assign({}, this.options), { stop: this._stopSubject }), opts);
33984
+ logPrefix = logPrefix || "[#" + ++this.taskId + "] ";
33985
+ value$ = this.$value.pipe(operators.tap(function (value) { return _this.log(logPrefix + ("Received value: " + value)); }));
33986
+ _b.label = 1;
33987
+ case 1:
33988
+ _b.trys.push([1, 3, 4, 5]);
33989
+ this.runningTaskCount++;
33990
+ this.log(logPrefix + 'Waiting...');
33991
+ return [4 /*yield*/, fn(value$, opts)];
33992
+ case 2:
33993
+ result = _b.sent();
33994
+ // Dump result
33995
+ if (isNotNil(result))
33996
+ this.log(logPrefix + '[OK] with result:', result);
33997
+ else
33998
+ this.log(logPrefix + '[OK]');
33999
+ return [3 /*break*/, 5];
34000
+ case 3:
34001
+ err_1 = _b.sent();
34002
+ errorMsg = logPrefix + 'Error: ' + ((err_1 === null || err_1 === void 0 ? void 0 : err_1.message) || '');
34003
+ console.error(errorMsg, err_1);
34004
+ this.log(errorMsg
34005
+ + ((err_1 === null || err_1 === void 0 ? void 0 : err_1.originalStack) ? "<pre>" + err_1.originalStack + "</pre>" : ''));
34006
+ return [3 /*break*/, 5];
34007
+ case 4:
34008
+ this.runningTaskCount--;
34009
+ return [7 /*endfinally*/];
34010
+ case 5: return [2 /*return*/];
34011
+ }
34012
+ });
34013
+ });
34014
+ };
34015
+ ObservableTestPage.prototype.emit = function (value) {
34016
+ this.$value.next(value);
34017
+ };
34018
+ ObservableTestPage.prototype.stop = function () {
34019
+ this._stopSubject.next();
34020
+ };
34021
+ ObservableTestPage.prototype.log = function (message) {
34022
+ var args = [];
34023
+ for (var _i = 1; _i < arguments.length; _i++) {
34024
+ args[_i - 1] = arguments[_i];
34025
+ }
34026
+ var fullMessage = toDateISOString(moment$3()) + " - " + message;
34027
+ if (args === null || args === void 0 ? void 0 : args.length) {
34028
+ fullMessage += ' - <small>' + args.map(JSON.stringify).join(', ') + '</small>';
34029
+ }
34030
+ this.appendLog(fullMessage);
34031
+ };
34032
+ ObservableTestPage.prototype.appendLog = function (message) {
34033
+ this.resultDiv.nativeElement.innerHTML += message + '<br/>';
34034
+ };
34035
+ return ObservableTestPage;
34036
+ }());
34037
+ ObservableTestPage.decorators = [
34038
+ { type: i0.Component, args: [{
34039
+ selector: 'app-observable-test',
34040
+ template: "\n<ion-header>\n <ion-toolbar color=\"primary\">\n\n <ion-buttons slot=\"start\">\n <ion-back-button></ion-back-button>\n </ion-buttons>\n\n <ion-title>Observables test page</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content class=\"ion-padding\">\n\n <ion-card>\n <ion-card-header>\n <ion-card-title>waitFor, waitForTrue, waitForFalse</ion-card-title>\n </ion-card-header>\n <ion-card-content>\n <div style=\"display: inline-block\">\n <p>Set options: </p>\n <ion-button color=\"medium\" fill=\"outline\" (click)=\"setOptions({stopError: false})\">stopError: false</ion-button>\n <ion-button color=\"medium\" fill=\"outline\" (click)=\"setOptions({stopError: true})\">stopError: true</ion-button>\n <ion-button color=\"medium\" fill=\"outline\" (click)=\"setOptions({stopError: 'my error'})\">stopError: 'my error'</ion-button>\n\n <ion-button color=\"medium\" fill=\"outline\" (click)=\"setOptions({timeout: 2000})\">timeout: 2000</ion-button>\n <ion-button color=\"medium\" fill=\"outline\" (click)=\"setOptions({timeout: null})\">timeout: null</ion-button>\n <br/>\n <p>Call await function: </p>\n <ion-button (click)=\"waitForTrue()\">waitForTrue</ion-button>\n <ion-button (click)=\"firstNotNilPromise()\">firstNotNilPromise</ion-button>\n <br/>\n <p>Send event to source: </p>\n <ion-button (click)=\"emit(true)\">Emit 'true'</ion-button>\n <ion-button (click)=\"emit(false)\">Emit 'false'</ion-button>\n <br/>\n <p>Stop: </p>\n <ion-button color=\"danger\" (click)=\"stop()\">Stop</ion-button>\n </div>\n </ion-card-content>\n </ion-card>\n\n <ion-card>\n <ion-toolbar>\n <ion-title>Running job count: {{runningTaskCount}}</ion-title>\n <ion-button fill=\"outline\" slot=\"end\" (click)=\"result.innerHTML=''\">Clear log</ion-button>\n </ion-toolbar>\n <ion-card-content>\n <div #result style=\"color: var(--ion-color-medium)\">\n </div>\n </ion-card-content>\n </ion-card>\n</ion-content>\n",
34041
+ styles: ["ion-button{text-transform:none!important}"]
34042
+ },] }
34043
+ ];
34044
+ ObservableTestPage.ctorParameters = function () { return []; };
34045
+ ObservableTestPage.propDecorators = {
34046
+ resultDiv: [{ type: i0.ViewChild, args: ['result',] }]
34047
+ };
34048
+
33925
34049
  var SHARED_MATERIAL_TESTING_PAGES = [
33926
34050
  { label: 'Shared Material components', divider: true },
33927
34051
  { label: 'Date/Time field', page: '/testing/shared/datetime' },
@@ -33932,7 +34056,9 @@
33932
34056
  { label: 'Swipe component', page: '/testing/shared/swipe' },
33933
34057
  { label: 'Chips component', page: '/testing/shared/chips' },
33934
34058
  { label: 'Shared directives', divider: true },
33935
- { label: 'Badge icon directive', page: '/testing/shared/badge-icon' }
34059
+ { label: 'Badge icon directive', page: '/testing/shared/badge-icon' },
34060
+ { label: 'Shared utils', divider: true },
34061
+ { label: 'Observable', page: '/testing/shared/observable' }
33936
34062
  ];
33937
34063
  var routes$1 = [
33938
34064
  {
@@ -33940,6 +34066,11 @@
33940
34066
  pathMatch: 'full',
33941
34067
  component: SharedTestsPage
33942
34068
  },
34069
+ {
34070
+ path: 'observable',
34071
+ pathMatch: 'full',
34072
+ component: ObservableTestPage
34073
+ },
33943
34074
  {
33944
34075
  path: 'autocomplete',
33945
34076
  pathMatch: 'full',
@@ -34004,7 +34135,8 @@
34004
34135
  NumpadTestPage,
34005
34136
  SwipeTestPage,
34006
34137
  ChipsTestPage,
34007
- MatBadgeIconTestPage
34138
+ MatBadgeIconTestPage,
34139
+ ObservableTestPage
34008
34140
  ],
34009
34141
  exports: [
34010
34142
  SharedMaterialModule,
@@ -34015,7 +34147,8 @@
34015
34147
  LatLongTestPage,
34016
34148
  NumpadTestPage,
34017
34149
  SwipeTestPage,
34018
- ChipsTestPage
34150
+ ChipsTestPage,
34151
+ ObservableTestPage
34019
34152
  ]
34020
34153
  },] }
34021
34154
  ];
@@ -35799,11 +35932,12 @@
35799
35932
  exports.ɵi = LocalSettingsValidatorService;
35800
35933
  exports.ɵj = AppUpdateOfflineModeCard;
35801
35934
  exports.ɵk = UserEventNotificationList;
35802
- exports.ɵl = DateTestPage;
35803
- exports.ɵm = NumpadTestPage;
35804
- exports.ɵn = MatBadgeIconTestPage;
35805
- exports.ɵo = ToastTestingModule;
35806
- exports.ɵp = ToastTestingPage;
35935
+ exports.ɵl = ObservableTestPage;
35936
+ exports.ɵm = DateTestPage;
35937
+ exports.ɵn = NumpadTestPage;
35938
+ exports.ɵo = MatBadgeIconTestPage;
35939
+ exports.ɵp = ToastTestingModule;
35940
+ exports.ɵq = ToastTestingPage;
35807
35941
 
35808
35942
  Object.defineProperty(exports, '__esModule', { value: true });
35809
35943