@sumaris-net/ngx-components 1.20.10 → 1.20.11

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.
@@ -4769,16 +4769,15 @@ const noop$1 = () => {
4769
4769
  };
4770
4770
  const ɵ0$2 = noop$1;
4771
4771
  class MatLatLongField {
4772
- constructor(translate, formBuilder, cd, formGroupDir) {
4773
- this.translate = translate;
4772
+ constructor(formBuilder, cd, formGroupDir) {
4774
4773
  this.formBuilder = formBuilder;
4775
4774
  this.cd = cd;
4776
4775
  this.formGroupDir = formGroupDir;
4777
4776
  this._onChangeCallback = noop$1;
4778
4777
  this._onTouchedCallback = noop$1;
4779
4778
  this._subscription = new Subscription();
4780
- this.disabling = false;
4781
- this.writing = false;
4779
+ this._disabling = false;
4780
+ this._writing = false;
4782
4781
  this._readonly = false;
4783
4782
  this.required = false;
4784
4783
  this.floatLabel = 'auto';
@@ -4851,7 +4850,7 @@ class MatLatLongField {
4851
4850
  .subscribe((_) => this.onFormChange(this.textFormControl.value)));
4852
4851
  // Listen status changes (when done outside the component - e.g. when setErrors() is calling on the formControl)
4853
4852
  this._subscription.add(this.formControl.statusChanges
4854
- .pipe(filter((_) => !this.readonly && !this.writing && !this.disabling) // Skip
4853
+ .pipe(filter((_) => !this.readonly && !this._writing && !this._disabling) // Skip
4855
4854
  )
4856
4855
  .subscribe((_) => this.markForCheck()));
4857
4856
  }
@@ -4859,12 +4858,12 @@ class MatLatLongField {
4859
4858
  this._subscription.unsubscribe();
4860
4859
  }
4861
4860
  writeValue(obj) {
4862
- if (this.writing)
4861
+ if (this._writing)
4863
4862
  return;
4864
- this.value = (typeof obj === 'string') ? parseFloat(obj.replace(/,/g, '.')) : obj;
4865
- this.writing = true;
4863
+ const value = (typeof obj === 'string') ? parseFloat(obj.replace(/,/g, '.')) : obj;
4864
+ this._writing = true;
4866
4865
  const strValue = this._formatFn(this.value, Object.assign(Object.assign({}, this._formatOptions), { placeholderChar: this.placeholderChar }));
4867
- const sign = isNotNil(this.value) ? (this.value < 0 ? -1 : 1) :
4866
+ const sign = isNotNil(this.value) ? (value < 0 ? -1 : 1) :
4868
4867
  // Use default sign, if any
4869
4868
  (this.defaultSign ? (this.defaultSign === '-' ? -1 : 1) : null);
4870
4869
  // DEBUG
@@ -4872,7 +4871,7 @@ class MatLatLongField {
4872
4871
  // console.debug("sign: " + sign)
4873
4872
  this.textFormControl.patchValue(strValue, { emitEvent: false });
4874
4873
  this.signFormControl.patchValue(sign, { emitEvent: false });
4875
- this.writing = false;
4874
+ this._writing = false;
4876
4875
  this.markForCheck();
4877
4876
  }
4878
4877
  registerOnChange(fn) {
@@ -4882,9 +4881,9 @@ class MatLatLongField {
4882
4881
  this._onTouchedCallback = fn;
4883
4882
  }
4884
4883
  setDisabledState(isDisabled) {
4885
- if (this.disabling)
4884
+ if (this._disabling)
4886
4885
  return;
4887
- this.disabling = true;
4886
+ this._disabling = true;
4888
4887
  if (isDisabled) {
4889
4888
  this.textFormControl.disable({ onlySelf: true, emitEvent: false });
4890
4889
  this.signFormControl.disable({ onlySelf: true, emitEvent: false });
@@ -4893,7 +4892,7 @@ class MatLatLongField {
4893
4892
  this.textFormControl.enable({ onlySelf: true, emitEvent: false });
4894
4893
  this.signFormControl.enable({ onlySelf: true, emitEvent: false });
4895
4894
  }
4896
- this.disabling = false;
4895
+ this._disabling = false;
4897
4896
  this.markForCheck();
4898
4897
  }
4899
4898
  /**
@@ -5013,13 +5012,13 @@ class MatLatLongField {
5013
5012
  }
5014
5013
  }
5015
5014
  onFormChange(strValue) {
5016
- if (this.writing)
5015
+ if (this._writing)
5017
5016
  return; // Skip if call by self
5018
- this.writing = true;
5017
+ this._writing = true;
5019
5018
  if (this.textFormControl.invalid || this.signFormControl.invalid) {
5020
5019
  this.formControl.markAsPending();
5021
5020
  this.formControl.setErrors(Object.assign(Object.assign(Object.assign({}, this.formControl.errors), this.textFormControl.errors), this.signFormControl.errors));
5022
- this.writing = false;
5021
+ this._writing = false;
5023
5022
  return;
5024
5023
  }
5025
5024
  const parsedValue = isNotNilOrBlank(strValue) ? parseLatitudeOrLongitude(strValue, this.pattern, 7 /*=precision of the converted double value */, this.placeholderChar) : null;
@@ -5028,15 +5027,15 @@ class MatLatLongField {
5028
5027
  if (isNaN(parsedValue)) {
5029
5028
  this.formControl.markAsPending();
5030
5029
  this.formControl.setErrors(this.type === 'latitude' ? { latitude: true } : { longitude: true });
5031
- this.writing = false;
5030
+ this._writing = false;
5032
5031
  return;
5033
5032
  }
5034
5033
  const sign = (this.pattern === 'DD') ? 1 /*ignore sign*/ : (this.signFormControl.value || 1);
5035
- this.value = isNotNil(parsedValue) ? sign * parsedValue : null;
5034
+ const value = isNotNil(parsedValue) ? sign * parsedValue : null;
5036
5035
  // Get the model value
5037
- //console.debug("[mat-latlon] Setting value {" + this.value + "} parsed from {" + strValue + "}");
5038
- this.formControl.patchValue(this.value, { emitEvent: false });
5039
- this.writing = false;
5036
+ //console.debug("[mat-latlon] Setting value {" + value + "} parsed from {" + strValue + "}");
5037
+ this.formControl.patchValue(value, { emitEvent: false });
5038
+ this._writing = false;
5040
5039
  this.markForCheck();
5041
5040
  this._onChangeCallback(this.value);
5042
5041
  }
@@ -5055,7 +5054,7 @@ class MatLatLongField {
5055
5054
  MatLatLongField.decorators = [
5056
5055
  { type: Component, args: [{
5057
5056
  selector: 'mat-latlong-field',
5058
- template: "<!-- readonly -->\n<mat-form-field *ngIf=\"readonly; else writable\"\n [floatLabel]=\"floatLabel\"\n class=\"mat-form-field-disabled\">\n\n <div matPrefix>\n <ng-container *ngTemplateOutlet=\"matPrefixTemplate\"></ng-container>\n </div>\n\n <input matInput hidden type=\"text\"\n readonly\n [placeholder]=\"placeholder\"\n [formControl]=\"formControl\">\n <ion-text>{{_format(value) }}</ion-text>\n\n <div matSuffix>\n <ng-container *ngTemplateOutlet=\"matSuffixTemplate\"></ng-container>\n </div>\n</mat-form-field>\n\n<!-- writable -->\n<ng-template #writable>\n\n <ion-grid class=\"ion-no-padding\">\n <ion-row class=\"ion-no-padding no-wrap\">\n <ion-col class=\"text ion-no-padding\">\n <mat-form-field [floatLabel]=\"floatLabel\"\n [class.mat-form-field-disabled]=\"formControl.disabled\"\n [class.mat-form-field-invalid]=\"formControl.touched && formControl.invalid\">\n\n <mat-label *ngIf=\"placeholder\">{{placeholder}}</mat-label>\n\n <div matPrefix>\n <ng-container *ngTemplateOutlet=\"matPrefixTemplate\"></ng-container>\n </div>\n\n <input matInput #inputElement\n type=\"text\"\n autocomplete=\"off\"\n [textMask]=\"textMaskConfig\"\n [formControl]=\"textFormControl\"\n [placeholder]=\"inputPlaceholder|translate\"\n (keypress)=\"onKeypress($event)\"\n (keydown.tab)=\"moveCaretToSeparator($event, true)\"\n (keydown.shift.tab)=\"moveCaretToSeparator($event, false)\"\n (focus)=\"_onFocus($event)\"\n (blur)=\"_onBlur($event)\"\n [required]=\"required\"\n [tabindex]=\"tabindex\">\n\n <div matSuffix *ngIf=\"!showSignControl\">\n <ng-container *ngTemplateOutlet=\"matSuffixTemplate\"></ng-container>\n </div>\n\n <div class=\"mat-form-field-subscript mat-form-field-subscript-wrapper\">\n\n <!-- errors -->\n <ng-container *ngIf=\"formControl.touched && formControl.errors|mapKeys|arrayFirst; let errorKey\" [ngSwitch]=\"errorKey\">\n <mat-error *ngSwitchCase=\"'required'\" translate>ERROR.FIELD_REQUIRED</mat-error>\n <mat-error *ngSwitchCase=\"'latitude'\" translate>ERROR.FIELD_NOT_VALID_LATITUDE</mat-error>\n <mat-error *ngSwitchCase=\"'longitude'\" translate>ERROR.FIELD_NOT_VALID_LONGITUDE</mat-error>\n <mat-error *ngSwitchCase=\"'min'\">{{'ERROR.FIELD_MIN_COMPACT'|translate: {min: _format(formControl.errors.min.min) } }}</mat-error>\n <mat-error *ngSwitchCase=\"'max'\">{{'ERROR.FIELD_MAX_COMPACT'|translate: {max: _format(formControl.errors.max.max) } }}</mat-error>\n <mat-error *ngSwitchCase=\"'msg'\">{{(formControl.errors.msg?.key || formControl.errors.msg) | translate: formControl.errors.msg?.params}}</mat-error>\n </ng-container>\n <ng-content select=\"mat-error\"></ng-content>\n\n <!-- mat hint -->\n <div class=\"mat-form-field-hint-wrapper\" [class.cdk-visually-hidden]=\"formControl.invalid\">\n <div class=\"mat-form-field-hint-spacer\"></div>\n <ng-content select=\"mat-hint\"></ng-content>\n </div>\n </div>\n </mat-form-field>\n </ion-col>\n\n <!-- sign -->\n <ion-col class=\"sign ion-no-padding\" [ngSwitch]=\"type\" *ngIf=\"showSignControl\">\n\n <!-- sign on latitude -->\n <mat-form-field *ngSwitchCase=\"'latitude'\"\n floatLabel=\"never\"\n [class.mat-form-field-invalid]=\"formControl.touched && signFormControl.invalid\">\n <mat-label *ngIf=\"placeholder && floatLabel != 'never'\" translate>COMMON.LAT_LONG.LAT_SIGN_PLACEHOLDER</mat-label>\n <mat-select [formControl]=\"signFormControl\"\n [tabindex]=\"tabindex+1\">\n <mat-option [value]=\"1\">{{'COMMON.LAT_LONG.LAT_SIGN_N'|translate}}</mat-option>\n <mat-option [value]=\"-1\" >{{'COMMON.LAT_LONG.LAT_SIGN_S'|translate}}</mat-option>\n </mat-select>\n\n <div matSuffix>\n <ng-container *ngTemplateOutlet=\"matSuffixTemplate\"></ng-container>\n </div>\n </mat-form-field>\n\n <!-- sign on longitude -->\n <mat-form-field floatLabel=\"never\"\n *ngSwitchCase=\"'longitude'\"\n [class.mat-form-field-invalid]=\"formControl.touched && signFormControl.invalid\">\n <mat-label *ngIf=\"placeholder && floatLabel != 'never'\" translate>COMMON.LAT_LONG.LONG_SIGN_PLACEHOLDER</mat-label>\n <mat-select [formControl]=\"signFormControl\"\n [tabindex]=\"tabindex+2\">\n <mat-option [value]=\"1\" translate>{{'COMMON.LAT_LONG.LONG_SIGN_E'|translate}}</mat-option>\n <mat-option [value]=\"-1\" translate>{{'COMMON.LAT_LONG.LONG_SIGN_W'|translate}}</mat-option>\n </mat-select>\n\n <div matSuffix>\n <ng-container *ngTemplateOutlet=\"matSuffixTemplate\"></ng-container>\n </div>\n </mat-form-field>\n </ion-col>\n </ion-row>\n </ion-grid>\n\n</ng-template>\n\n<ng-template #matPrefixTemplate>\n <ng-content select=\"[matPrefix]\"></ng-content>\n</ng-template>\n\n\n<ng-template #matSuffixTemplate>\n <ng-content select=\"[matSuffix]\"></ng-content>\n</ng-template>\n",
5057
+ template: "<!-- readonly -->\n<mat-form-field *ngIf=\"readonly; else writable\"\n [floatLabel]=\"floatLabel\"\n class=\"mat-form-field-disabled\">\n\n <div matPrefix>\n <ng-container *ngTemplateOutlet=\"matPrefixTemplate\"></ng-container>\n </div>\n\n <input matInput hidden type=\"text\"\n readonly\n [placeholder]=\"placeholder\"\n [formControl]=\"formControl\">\n <ion-text>{{_format(formControl.value) }}</ion-text>\n\n <div matSuffix>\n <ng-container *ngTemplateOutlet=\"matSuffixTemplate\"></ng-container>\n </div>\n</mat-form-field>\n\n<!-- writable -->\n<ng-template #writable>\n\n <ion-grid class=\"ion-no-padding\">\n <ion-row class=\"ion-no-padding no-wrap\">\n <ion-col class=\"text ion-no-padding\">\n <mat-form-field [floatLabel]=\"floatLabel\"\n [class.mat-form-field-disabled]=\"formControl.disabled\"\n [class.mat-form-field-invalid]=\"formControl.touched && formControl.invalid\">\n\n <mat-label *ngIf=\"placeholder\">{{placeholder}}</mat-label>\n\n <div matPrefix>\n <ng-container *ngTemplateOutlet=\"matPrefixTemplate\"></ng-container>\n </div>\n\n <input matInput #inputElement\n type=\"text\"\n autocomplete=\"off\"\n [textMask]=\"textMaskConfig\"\n [formControl]=\"textFormControl\"\n [placeholder]=\"inputPlaceholder|translate\"\n (keypress)=\"onKeypress($event)\"\n (keydown.tab)=\"moveCaretToSeparator($event, true)\"\n (keydown.shift.tab)=\"moveCaretToSeparator($event, false)\"\n (focus)=\"_onFocus($event)\"\n (blur)=\"_onBlur($event)\"\n [required]=\"required\"\n [tabindex]=\"tabindex\">\n\n <div matSuffix *ngIf=\"!showSignControl\">\n <ng-container *ngTemplateOutlet=\"matSuffixTemplate\"></ng-container>\n </div>\n\n <div class=\"mat-form-field-subscript mat-form-field-subscript-wrapper\">\n\n <!-- errors -->\n <ng-container *ngIf=\"formControl.touched && formControl.errors|mapKeys|arrayFirst; let errorKey\" [ngSwitch]=\"errorKey\">\n <mat-error *ngSwitchCase=\"'required'\" translate>ERROR.FIELD_REQUIRED</mat-error>\n <mat-error *ngSwitchCase=\"'latitude'\" translate>ERROR.FIELD_NOT_VALID_LATITUDE</mat-error>\n <mat-error *ngSwitchCase=\"'longitude'\" translate>ERROR.FIELD_NOT_VALID_LONGITUDE</mat-error>\n <mat-error *ngSwitchCase=\"'min'\">{{'ERROR.FIELD_MIN_COMPACT'|translate: {min: _format(formControl.errors.min.min) } }}</mat-error>\n <mat-error *ngSwitchCase=\"'max'\">{{'ERROR.FIELD_MAX_COMPACT'|translate: {max: _format(formControl.errors.max.max) } }}</mat-error>\n <mat-error *ngSwitchCase=\"'msg'\">{{(formControl.errors.msg?.key || formControl.errors.msg) | translate: formControl.errors.msg?.params}}</mat-error>\n </ng-container>\n <ng-content select=\"mat-error\"></ng-content>\n\n <!-- mat hint -->\n <div class=\"mat-form-field-hint-wrapper\" [class.cdk-visually-hidden]=\"formControl.invalid\">\n <div class=\"mat-form-field-hint-spacer\"></div>\n <ng-content select=\"mat-hint\"></ng-content>\n </div>\n </div>\n </mat-form-field>\n </ion-col>\n\n <!-- sign -->\n <ion-col class=\"sign ion-no-padding\" [ngSwitch]=\"type\" *ngIf=\"showSignControl\">\n\n <!-- sign on latitude -->\n <mat-form-field *ngSwitchCase=\"'latitude'\"\n floatLabel=\"never\"\n [class.mat-form-field-invalid]=\"formControl.touched && signFormControl.invalid\">\n <mat-label *ngIf=\"placeholder && floatLabel != 'never'\" translate>COMMON.LAT_LONG.LAT_SIGN_PLACEHOLDER</mat-label>\n <mat-select [formControl]=\"signFormControl\"\n [tabindex]=\"tabindex+1\">\n <mat-option [value]=\"1\">{{'COMMON.LAT_LONG.LAT_SIGN_N'|translate}}</mat-option>\n <mat-option [value]=\"-1\" >{{'COMMON.LAT_LONG.LAT_SIGN_S'|translate}}</mat-option>\n </mat-select>\n\n <div matSuffix>\n <ng-container *ngTemplateOutlet=\"matSuffixTemplate\"></ng-container>\n </div>\n </mat-form-field>\n\n <!-- sign on longitude -->\n <mat-form-field floatLabel=\"never\"\n *ngSwitchCase=\"'longitude'\"\n [class.mat-form-field-invalid]=\"formControl.touched && signFormControl.invalid\">\n <mat-label *ngIf=\"placeholder && floatLabel != 'never'\" translate>COMMON.LAT_LONG.LONG_SIGN_PLACEHOLDER</mat-label>\n <mat-select [formControl]=\"signFormControl\"\n [tabindex]=\"tabindex+2\">\n <mat-option [value]=\"1\" translate>{{'COMMON.LAT_LONG.LONG_SIGN_E'|translate}}</mat-option>\n <mat-option [value]=\"-1\" translate>{{'COMMON.LAT_LONG.LONG_SIGN_W'|translate}}</mat-option>\n </mat-select>\n\n <div matSuffix>\n <ng-container *ngTemplateOutlet=\"matSuffixTemplate\"></ng-container>\n </div>\n </mat-form-field>\n </ion-col>\n </ion-row>\n </ion-grid>\n\n</ng-template>\n\n<ng-template #matPrefixTemplate>\n <ng-content select=\"[matPrefix]\"></ng-content>\n</ng-template>\n\n\n<ng-template #matSuffixTemplate>\n <ng-content select=\"[matSuffix]\"></ng-content>\n</ng-template>\n",
5059
5058
  providers: [
5060
5059
  {
5061
5060
  provide: NG_VALUE_ACCESSOR,
@@ -5063,12 +5062,10 @@ MatLatLongField.decorators = [
5063
5062
  useExisting: forwardRef(() => MatLatLongField),
5064
5063
  }
5065
5064
  ],
5066
- changeDetection: ChangeDetectionStrategy.OnPush,
5067
- styles: [":host{display:inline-block;width:100%;min-width:140px;position:relative;--ion-grid-column-padding:0}mat-form-field .datetime-md{padding:0!important}ion-row{flex-wrap:nowrap}ion-row ion-col.text{min-width:80px}ion-row ion-col.sign{min-width:40px;max-width:55px}mat-form-field{width:100%}mat-form-field .mat-form-field-subscript-wrapper{overflow:visible;white-space:nowrap;top:100%}mat-form-field .mat-form-field-subscript-wrapper .mat-form-field-hint-wrapper{display:flex}mat-form-field .mat-form-field-subscript-wrapper .mat-form-field-hint-wrapper .mat-form-field-hint-spacer{flex:1 0 1em}mat-error{text-align:right;width:100%}"]
5065
+ changeDetection: ChangeDetectionStrategy.OnPush
5068
5066
  },] }
5069
5067
  ];
5070
5068
  MatLatLongField.ctorParameters = () => [
5071
- { type: TranslateService },
5072
5069
  { type: FormBuilder },
5073
5070
  { type: ChangeDetectorRef },
5074
5071
  { type: FormGroupDirective, decorators: [{ type: Optional }] }
@@ -16095,6 +16092,30 @@ class FilesUtils {
16095
16092
  }
16096
16093
  }
16097
16094
  }
16095
+ static downloadUri(uri, filename) {
16096
+ if (navigator.msLaunchUri) { // IE 10+
16097
+ navigator.msLaunchUri(uri);
16098
+ }
16099
+ else {
16100
+ filename = filename || this.getFilenameFromUri(uri);
16101
+ const link = document.createElement('a');
16102
+ if (link.download !== undefined) {
16103
+ // Browsers that support HTML5 download attribute
16104
+ link.setAttribute('href', uri);
16105
+ link.setAttribute('download', filename);
16106
+ link.style.visibility = 'hidden';
16107
+ document.body.appendChild(link);
16108
+ link.click();
16109
+ document.body.removeChild(link);
16110
+ }
16111
+ }
16112
+ }
16113
+ static getFilenameFromUri(uri) {
16114
+ const lastSlashIndex = uri === null || uri === void 0 ? void 0 : uri.lastIndexOf('/');
16115
+ if (lastSlashIndex === -1 || lastSlashIndex === uri.length - 1)
16116
+ throw new Error('Invalid URI format. No slash found');
16117
+ return uri.substring(lastSlashIndex + 1);
16118
+ }
16098
16119
  }
16099
16120
  FilesUtils.UTF8_BOM_CHAR = new Uint8Array([0xEF, 0xBB, 0xBF]); // UTF-8 BOM
16100
16121