@sumaris-net/ngx-components 1.19.6-rc1 → 1.19.8

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.
package/README.md CHANGED
@@ -3,26 +3,26 @@
3
3
  Based components, for Angular App.
4
4
 
5
5
  Features :
6
- - Material design
7
- - Ionic framework
6
+ - Angular v11
7
+ - Angular Material design
8
+ - Ionic framework v5
8
9
  - i18n
9
10
  - New form field components:
10
11
  * Authentication forms
11
12
  * Extensible menu
12
- * UI components :
13
+ * UI components (mobile or desktop) :
13
14
  * Autocomplete field, with search and highlight
14
15
  * Latitude and longitude field, with 3 entry format
15
16
  * Date + time
16
17
 
17
18
  ## Contribute
18
19
 
19
- See the [developer guide](./doc/build.md)
20
-
20
+ See the [developer guide](https://github.com/sumaris-net/ngx-sumaris-components/blob/master/doc/build.md)
21
21
 
22
22
  ## Change log
23
23
 
24
- See the [change log](./doc/changelog.md)
24
+ See the [change log](https://github.com/sumaris-net/ngx-sumaris-components/blob/master/doc/changelog.md)
25
25
 
26
26
  ## License
27
27
 
28
- Free software, distributed under a [AGPL v3 license](./LICENSE).
28
+ Free software, distributed under a [AGPL v3 license](https://github.com/sumaris-net/ngx-sumaris-components/blob/master/LICENSE).
@@ -511,7 +511,7 @@
511
511
  if (isNotNilOrBlank(value)) {
512
512
  // If wildcard, search using regexp
513
513
  if (value.indexOf('*') !== -1) {
514
- value = value.replace('*', '.*');
514
+ value = value.replace(/[*]+/g, '.*');
515
515
  filteredItems = filteredItems.filter(function (v) { return keys.findIndex(function (key) { return matchUpperCase(getPropertyByPathAsString(v, key), value); }) !== -1; });
516
516
  }
517
517
  // Else (no wildcard), search using startsWith
@@ -1705,14 +1705,14 @@
1705
1705
  // Wait a debounce time
1706
1706
  operators.debounceTime(this.debounceTime)
1707
1707
  // DEBUG
1708
- , operators.tap(function (value) { return _this.debug && console.debug(_this.logPrefix + ' Search text changes:', value); })),
1708
+ //,tap((value) => this.debug && console.debug(this.logPrefix + ' Search text changes:', value))
1709
+ ),
1709
1710
  // Object set: use it (no distinctUntilChanged() pipe need)
1710
1711
  this.formControl.valueChanges
1711
1712
  .pipe(operators.startWith(this.formControl.value), operators.filter(function (value) { return (isNotNil(value) && typeof value === 'object'); }), operators.tap(function (value) {
1712
- var _a;
1713
1713
  // DEBUG
1714
- if (_this.debug)
1715
- console.debug(_this.logPrefix + ' control object changes:', value);
1714
+ //if (this.debug) console.debug(this.logPrefix + ' control object changes:', value);
1715
+ var _a;
1716
1716
  // Update the display value (if need)
1717
1717
  var displayValue = _this.displayWith(value) || '';
1718
1718
  if (_this.displayValue !== displayValue) {
@@ -1728,20 +1728,23 @@
1728
1728
  // when formControl value changes
1729
1729
  operators.filter(function () { return !_this.multiple || _this.loading; }), operators.map(function (value) { return _this.showAllOnFocus && _this.suggestLengthThreshold <= 0 ? '*' : value; })
1730
1730
  // DEBUG
1731
- , operators.tap(function (value) { return _this.debug && console.debug(_this.logPrefix + ' Received an control object value: ', value); })),
1731
+ //,tap(value => this.debug && console.debug(this.logPrefix + ' Received an control object value: ', value))
1732
+ ),
1732
1733
  // Merge some observables, with a common distinctUntilChanged() pipe
1733
1734
  rxjs.merge(
1734
1735
  // On dropdown button click (no debounceTime)
1735
1736
  this.dropButtonClick
1736
1737
  .pipe(operators.filter(function (event) { return (!event || !event.defaultPrevented); })),
1737
1738
  // Focus or click => Load all (no debounceTime)
1738
- rxjs.merge(this.focused, this.clicked)
1739
- // DEBUG
1740
- .pipe(operators.tap(function (_) { return _this.debug && console.debug(_this.logPrefix + ' Received focused or clicked event'); })),
1739
+ rxjs.merge(this.focused, this.clicked),
1740
+ // DEBUG
1741
+ //.pipe(tap(_ => this.debug && console.debug(this.logPrefix + ' Received focused or clicked event'))),
1741
1742
  // Input items or filter changes
1742
1743
  rxjs.merge(this.$inputItems, this._$filter)
1743
1744
  // DEBUG
1744
- .pipe(operators.filter(function (_) { return !_this.loading; }), operators.tap(function (_) { return _this.debug && console.debug(_this.logPrefix + ' Received $inputItems or filter event'); })))
1745
+ .pipe(operators.filter(function (_) { return !_this.loading; })
1746
+ //,tap(_ => this.debug && console.debug(this.logPrefix + ' Received $inputItems or filter event'))
1747
+ ))
1745
1748
  .pipe(operators.filter(function (_) { return _this.enabled; }), operators.map(function (_) { return _this.showAllOnFocus ? '*' : _this.formControl.value; }),
1746
1749
  // Distinguish changes
1747
1750
  operators.distinctUntilChanged(function (v1, v2) {
@@ -1751,12 +1754,13 @@
1751
1754
  // Make sure there is enough characters
1752
1755
  operators.filter(thresholdFilterFn)
1753
1756
  // DEBUG
1754
- , operators.tap(function (value) { return _this.debug && console.debug(_this.logPrefix + ' Received update event from observables: ', value); })))
1757
+ //,tap(value => this.debug && console.debug(this.logPrefix + ' Received update event from observables: ', value))
1758
+ ))
1755
1759
  .pipe(
1756
1760
  // Suggest values
1757
1761
  operators.mergeMap(function (value) { return _this.suggest(value, _this.filter); }),
1758
1762
  // DEBUG
1759
- operators.tap(function (items) { return _this.debug && console.debug(_this.logPrefix + ' Received from suggest: ', items); }),
1763
+ //tap(items => this.debug && console.debug(this.logPrefix + ' Received from suggest: ', items)),
1760
1764
  // Store implicit value (will use it onBlur if not other value selected)
1761
1765
  operators.tap(function (items) { return !_this.multiple && !_this.mobile && _this.updateImplicitValue(items); }));
1762
1766
  // Fetch more events
@@ -1764,7 +1768,7 @@
1764
1768
  .pipe(operators.tap(function (event) { return event === null || event === void 0 ? void 0 : event.preventDefault(); }), // Avoid to close the mat-select
1765
1769
  operators.filter(function () { return _this.canFetchMore; }), operators.mergeMap(function () { return _this.fetchMore(); }),
1766
1770
  // DEBUG
1767
- operators.tap(function (moreItems) { return console.debug(_this.logPrefix + ' Received from fetch More: ', moreItems); }),
1771
+ //tap(moreItems => console.debug(this.logPrefix + ' Received from fetch More: ', moreItems)),
1768
1772
  // Concat to existing items
1769
1773
  operators.map(function (moreItems) { return (_this.$filteredItems.value || []).concat(moreItems); }));
1770
1774
  // Update filtered items
@@ -1794,9 +1798,10 @@
1794
1798
  this._subscription.add(this.blurred
1795
1799
  .pipe(
1796
1800
  // Skip if multiple (no implicit value) or disable
1797
- operators.filter(function (_) { return !_this.multiple && !_this.mobile && _this.enabled; })
1801
+ operators.filter(function (_) { return !_this.multiple && !_this.mobile && _this.enabled; }),
1798
1802
  // DEBUG
1799
- , operators.tap(function (_) { return _this.debug && console.debug(_this.logPrefix + ' Received blurred event'); }), operators.map(function (_) { return _this.formControl.value; }))
1803
+ //,tap(_ => this.debug && console.debug(this.logPrefix + ' Received blurred event')),
1804
+ operators.map(function (_) { return _this.formControl.value; }))
1800
1805
  .subscribe(function (value) {
1801
1806
  // When leave component without object, use implicit value if :
1802
1807
  // - an explicit value
@@ -1830,7 +1835,7 @@
1830
1835
  event === null || event === void 0 ? void 0 : event.stopPropagation();
1831
1836
  event === null || event === void 0 ? void 0 : event.preventDefault();
1832
1837
  // DEBUG
1833
- console.debug(_this.logPrefix + " Closing the panel (keydown.escape)");
1838
+ //console.debug(this.logPrefix + " Closing the panel (keydown.escape)");
1834
1839
  _this.closePanel();
1835
1840
  }
1836
1841
  }));
@@ -1877,8 +1882,7 @@
1877
1882
  */
1878
1883
  MatAutocompleteField.prototype.reloadItems = function (value) {
1879
1884
  // DEBUG
1880
- if (this.debug)
1881
- console.debug(this.logPrefix + " Asking to reloadItems()");
1885
+ //if (this.debug) console.debug(this.logPrefix + " Asking to reloadItems()");
1882
1886
  // Force a refresh
1883
1887
  this._reload$.next(value || (this.showAllOnFocus && this.suggestLengthThreshold <= 0 ? '*' : this.formControl.value));
1884
1888
  // Clear the search bar (if hidden)
@@ -2091,7 +2095,7 @@
2091
2095
  case 1:
2092
2096
  res = _e.sent();
2093
2097
  // DEBUG
2094
- console.debug(this.logPrefix + ' Filtered items by suggestFn:', value, res);
2098
+ //if (this.debug) console.debug(this.logPrefix + ' Filtered items by suggestFn:', value, res);
2095
2099
  if (!res) {
2096
2100
  this._itemCount = 0;
2097
2101
  this._onFetchMoreCallback = undefined;
@@ -4752,12 +4756,10 @@
4752
4756
  };
4753
4757
  return FormGetPipe;
4754
4758
  }());
4755
- FormGetPipe.ɵprov = i0.ɵɵdefineInjectable({ factory: function FormGetPipe_Factory() { return new FormGetPipe(); }, token: FormGetPipe, providedIn: "root" });
4756
4759
  FormGetPipe.decorators = [
4757
4760
  { type: i0.Pipe, args: [{
4758
4761
  name: 'formGet'
4759
- },] },
4760
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
4762
+ },] }
4761
4763
  ];
4762
4764
  var FormGetControlPipe = /** @class */ (function () {
4763
4765
  function FormGetControlPipe() {
@@ -4767,12 +4769,10 @@
4767
4769
  };
4768
4770
  return FormGetControlPipe;
4769
4771
  }());
4770
- FormGetControlPipe.ɵprov = i0.ɵɵdefineInjectable({ factory: function FormGetControlPipe_Factory() { return new FormGetControlPipe(); }, token: FormGetControlPipe, providedIn: "root" });
4771
4772
  FormGetControlPipe.decorators = [
4772
4773
  { type: i0.Pipe, args: [{
4773
4774
  name: 'formGetControl'
4774
- },] },
4775
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
4775
+ },] }
4776
4776
  ];
4777
4777
  var FormGetArrayPipe = /** @class */ (function () {
4778
4778
  function FormGetArrayPipe() {
@@ -4782,12 +4782,10 @@
4782
4782
  };
4783
4783
  return FormGetArrayPipe;
4784
4784
  }());
4785
- FormGetArrayPipe.ɵprov = i0.ɵɵdefineInjectable({ factory: function FormGetArrayPipe_Factory() { return new FormGetArrayPipe(); }, token: FormGetArrayPipe, providedIn: "root" });
4786
4785
  FormGetArrayPipe.decorators = [
4787
4786
  { type: i0.Pipe, args: [{
4788
4787
  name: 'formGetArray'
4789
- },] },
4790
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
4788
+ },] }
4791
4789
  ];
4792
4790
  var FormGetGroupPipe = /** @class */ (function () {
4793
4791
  function FormGetGroupPipe() {
@@ -4797,13 +4795,70 @@
4797
4795
  };
4798
4796
  return FormGetGroupPipe;
4799
4797
  }());
4800
- FormGetGroupPipe.ɵprov = i0.ɵɵdefineInjectable({ factory: function FormGetGroupPipe_Factory() { return new FormGetGroupPipe(); }, token: FormGetGroupPipe, providedIn: "root" });
4801
4798
  FormGetGroupPipe.decorators = [
4802
4799
  { type: i0.Pipe, args: [{
4803
4800
  name: 'formGetGroup'
4804
- },] },
4805
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
4801
+ },] }
4802
+ ];
4803
+ var FormGetValuePipe = /** @class */ (function () {
4804
+ function FormGetValuePipe(adapter, _ref) {
4805
+ this.adapter = adapter;
4806
+ this._ref = _ref;
4807
+ this.value = undefined;
4808
+ this._lastControl = null;
4809
+ }
4810
+ FormGetValuePipe.prototype.transform = function (form, path) {
4811
+ var _this = this;
4812
+ if (!form) {
4813
+ this._dispose();
4814
+ return undefined;
4815
+ }
4816
+ // if we ask another time for the same form and opts, return the last value
4817
+ if (form === this._lastControl && equals(path, this._lastPath)) {
4818
+ return this.value;
4819
+ }
4820
+ // store the query, in case it changes
4821
+ this._lastControl = form;
4822
+ // store the params, in case they change
4823
+ this._lastPath = path;
4824
+ // set the value
4825
+ var control = isNotNilOrBlank(path) ? form.get(path) : form;
4826
+ this.value = control === null || control === void 0 ? void 0 : control.value;
4827
+ // if there is a subscription to onLangChange, clean it
4828
+ this._dispose();
4829
+ // subscribe to valueChanges event, in case control value change
4830
+ if (!this._onControlValueChanges && control) {
4831
+ this._onControlValueChanges = control.valueChanges.subscribe(function (value) {
4832
+ _this.value = value;
4833
+ _this._ref.markForCheck();
4834
+ });
4835
+ }
4836
+ return this.value;
4837
+ };
4838
+ FormGetValuePipe.prototype.ngOnDestroy = function () {
4839
+ this._dispose();
4840
+ };
4841
+ /**
4842
+ * Clean any existing subscription to change events
4843
+ */
4844
+ FormGetValuePipe.prototype._dispose = function () {
4845
+ if (typeof this._onControlValueChanges !== 'undefined') {
4846
+ this._onControlValueChanges.unsubscribe();
4847
+ this._onControlValueChanges = undefined;
4848
+ }
4849
+ };
4850
+ return FormGetValuePipe;
4851
+ }());
4852
+ FormGetValuePipe.decorators = [
4853
+ { type: i0.Pipe, args: [{
4854
+ name: 'formGetValue',
4855
+ pure: false
4856
+ },] }
4806
4857
  ];
4858
+ FormGetValuePipe.ctorParameters = function () { return [
4859
+ { type: FormErrorTranslator },
4860
+ { type: i0.ChangeDetectorRef }
4861
+ ]; };
4807
4862
 
4808
4863
  var SharedPipesModule = /** @class */ (function () {
4809
4864
  function SharedPipesModule() {
@@ -4854,7 +4909,8 @@
4854
4909
  FormGetPipe,
4855
4910
  FormGetControlPipe,
4856
4911
  FormGetArrayPipe,
4857
- FormGetGroupPipe
4912
+ FormGetGroupPipe,
4913
+ FormGetValuePipe
4858
4914
  ],
4859
4915
  exports: [
4860
4916
  PropertyGetPipe,
@@ -11043,7 +11099,7 @@
11043
11099
  (items || []).forEach(EntityUtils.cleanIdAndUpdateDate);
11044
11100
  };
11045
11101
  EntityUtils.sort = function (data, sortBy, sortDirection) {
11046
- if (!data || data.length <= 1)
11102
+ if (!data || data.length <= 1 || !sortBy)
11047
11103
  return data;
11048
11104
  return data.sort(this.sortComparator(sortBy, sortDirection));
11049
11105
  };
@@ -13463,16 +13519,16 @@
13463
13519
  /**
13464
13520
  *
13465
13521
  * @param opts
13466
- * opts.force : force all entities to be persist, and not only if dirty
13522
+ * opts.skipIfPristine = false persist all entities, even if not dirty
13467
13523
  */
13468
13524
  EntityStore.prototype.persist = function (opts) {
13525
+ if (opts === void 0) { opts = { skipIfPristine: true }; }
13469
13526
  return __awaiter(this, void 0, void 0, function () {
13470
13527
  var dirtyIndexes, entities;
13471
13528
  var _this = this;
13472
13529
  return __generator(this, function (_b) {
13473
13530
  switch (_b.label) {
13474
13531
  case 0:
13475
- opts = Object.assign({ skipIfPristine: this.policy.skipNonLocalEntities }, opts);
13476
13532
  // Skip is not dirty
13477
13533
  if (opts.skipIfPristine && !this._dirty) {
13478
13534
  console.debug("[entity-storage] Persisting " + this.name + " not need. Skip");
@@ -14212,11 +14268,12 @@
14212
14268
  });
14213
14269
  });
14214
14270
  };
14215
- EntitiesStorage.prototype.persist = function () {
14216
- if (this._dirty) {
14217
- return this.storeLocally();
14218
- }
14219
- return Promise.resolve();
14271
+ EntitiesStorage.prototype.persist = function (opts) {
14272
+ if (opts === void 0) { opts = { skipIfPristine: true }; }
14273
+ // Skip if pristine
14274
+ if (opts.skipIfPristine && !this._dirty)
14275
+ return Promise.resolve();
14276
+ return this.storeLocally(opts);
14220
14277
  };
14221
14278
  EntitiesStorage.prototype.ngOnStart = function () {
14222
14279
  return __awaiter(this, void 0, void 0, function () {
@@ -14307,12 +14364,13 @@
14307
14364
  });
14308
14365
  });
14309
14366
  };
14310
- EntitiesStorage.prototype.storeLocally = function () {
14367
+ EntitiesStorage.prototype.storeLocally = function (opts) {
14368
+ if (opts === void 0) { opts = { skipIfPristine: true }; }
14311
14369
  return __awaiter(this, void 0, void 0, function () {
14312
14370
  var entityNames, now, currentEntityName;
14313
14371
  var _this = this;
14314
14372
  return __generator(this, function (_a) {
14315
- if (!this.dirty)
14373
+ if (opts.skipIfPristine && !this.dirty)
14316
14374
  return [2 /*return*/]; // skip
14317
14375
  // Saving progress: report this save later
14318
14376
  if (this._saving) {
@@ -14335,11 +14393,11 @@
14335
14393
  console.warn("[entities-storage] Persisting " + entityName + ": store not found!");
14336
14394
  return;
14337
14395
  }
14338
- // SKip store if not dirty
14339
- if (!entityStore.dirty)
14340
- return Promise.resolve(); // Skip
14396
+ // SKip store if pristine
14397
+ if (opts.skipIfPristine && !entityStore.dirty)
14398
+ return Promise.resolve();
14341
14399
  // Persist store
14342
- return (entityStore.dirty ? entityStore.persist() : Promise.resolve(entityStore.length))
14400
+ return entityStore.persist(opts)
14343
14401
  .then(function (count) {
14344
14402
  // If no entity found, remove from the entity names array
14345
14403
  if (!count) {
@@ -19512,8 +19570,8 @@
19512
19570
  return __generator(this, function (_a) {
19513
19571
  switch (_a.label) {
19514
19572
  case 0:
19515
- dirty = component.dirty;
19516
- valid = component.valid;
19573
+ dirty = component === null || component === void 0 ? void 0 : component.dirty;
19574
+ valid = component === null || component === void 0 ? void 0 : component.valid;
19517
19575
  can = {
19518
19576
  confirmed: !dirty,
19519
19577
  save: false,
@@ -28793,7 +28851,8 @@
28793
28851
  }, opts));
28794
28852
  };
28795
28853
  AppEntityEditor.prototype.markForCheck = function () {
28796
- this.cd.markForCheck();
28854
+ var _a;
28855
+ (_a = this.cd) === null || _a === void 0 ? void 0 : _a.markForCheck();
28797
28856
  };
28798
28857
  /* -- private functions -- */
28799
28858
  /**
@@ -32001,6 +32060,7 @@
32001
32060
  exports.FormGetControlPipe = FormGetControlPipe;
32002
32061
  exports.FormGetGroupPipe = FormGetGroupPipe;
32003
32062
  exports.FormGetPipe = FormGetPipe;
32063
+ exports.FormGetValuePipe = FormGetValuePipe;
32004
32064
  exports.Fragments = Fragments$1;
32005
32065
  exports.GraphqlService = GraphqlService;
32006
32066
  exports.HAMMER_PRESS_TIME = HAMMER_PRESS_TIME;