@sumaris-net/ngx-components 2.7.0-rc6 → 2.7.0-rc7

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.
@@ -1,7 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, Directive, Injectable, Pipe, EventEmitter, Output, Optional, Inject, NgModule, forwardRef, Component, ChangeDetectionStrategy, Input, ViewChildren, HostBinding, HostListener, ElementRef, ViewChild, ANIMATION_MODULE_TYPE, inject, ChangeDetectorRef, ContentChild, CUSTOM_ELEMENTS_SCHEMA, ViewEncapsulation, APP_INITIALIZER } from '@angular/core';
3
3
  import { shareReplay, tap, of, firstValueFrom, Subject, merge, isObservable, from, timer, Subscription, BehaviorSubject, fromEvent, noop as noop$9, Observable, forkJoin, defer, timeout, fromEventPattern, interval, combineLatest, mergeMap as mergeMap$1, EMPTY, delay, iif } from 'rxjs';
4
- import { catchError, map, first, tap as tap$1, switchMap, takeUntil, filter, mergeMap, debounceTime, startWith, distinctUntilChanged, throttleTime, skip, bufferWhen, mapTo, distinctUntilKeyChanged, take } from 'rxjs/operators';
4
+ import { catchError, map, first, tap as tap$1, switchMap, takeUntil, filter, mergeMap, debounceTime, startWith, distinctUntilChanged, skip, throttleTime, bufferWhen, mapTo, distinctUntilKeyChanged, take } from 'rxjs/operators';
5
5
  import * as i2 from '@angular/common/http';
6
6
  import { HttpEventType, HttpClient, HttpHeaders, HttpResponse, HttpClientModule } from '@angular/common/http';
7
7
  import * as i2$3 from '@angular/common';
@@ -8337,10 +8337,13 @@ class MatDate {
8337
8337
  () => this.formControl.errors);
8338
8338
  // Get patterns to display date
8339
8339
  this.updatePattern(this.translate.instant('COMMON.DATE_PATTERN'));
8340
- this._subscription.add(this.translate.get('COMMON.DATE_PATTERN')
8341
- .subscribe((pattern) => this.updatePattern(pattern)));
8342
- // Create mask options
8343
- this.createMaskOptions();
8340
+ this.updateMaskOptions(this.translate.instant('COMMON.DATE_PLACEHOLDER'));
8341
+ this._subscription.add(this.translate.get(['COMMON.DATE_PATTERN', 'COMMON.DATE_PLACEHOLDER'])
8342
+ .pipe(skip(1))
8343
+ .subscribe((translate) => {
8344
+ this.updatePattern(translate['COMMON.DATE_PATTERN']);
8345
+ this.updateMaskOptions(translate['COMMON.DATE_PLACEHOLDER']);
8346
+ }));
8344
8347
  this._subscription.add(this.textControl.valueChanges
8345
8348
  .subscribe((value) => this.onFormChange(value)));
8346
8349
  // Listen status changes (when done outside the component - e.g. when setErrors() is calling on the formControl)
@@ -8561,30 +8564,33 @@ class MatDate {
8561
8564
  markForCheck() {
8562
8565
  this.cd.markForCheck();
8563
8566
  }
8564
- createMaskOptions() {
8565
- this.datePlaceholder = this.translate.instant('COMMON.DATE_PLACEHOLDER');
8566
- const dateOptions = maskitoDateOptionsGenerator({
8567
- mode: this.datePattern.toLowerCase(),
8568
- separator: '/',
8569
- });
8570
- const { plugins, // plugins keeps caret inside actual value and remove placeholder on blur
8571
- ...placeholderOptions
8572
- // pass 'true' as second argument to add plugin to hide placeholder when input is not focused
8573
- } = maskitoWithPlaceholder(this.datePlaceholder, true);
8574
- this.maskitoOptions = {
8575
- ...dateOptions,
8576
- plugins: plugins.concat(dateOptions.plugins || []),
8577
- preprocessors: [
8578
- // Always put it BEFORE all other preprocessors
8579
- ...placeholderOptions.preprocessors,
8580
- ...dateOptions.preprocessors,
8581
- ],
8582
- postprocessors: [
8583
- ...dateOptions.postprocessors,
8584
- // Always put it AFTER all other postprocessors
8585
- ...placeholderOptions.postprocessors,
8586
- ],
8587
- };
8567
+ updateMaskOptions(datePlaceholder) {
8568
+ if (this.datePlaceholder != datePlaceholder) {
8569
+ this.datePlaceholder = datePlaceholder;
8570
+ const dateOptions = maskitoDateOptionsGenerator({
8571
+ mode: this.datePattern.toLowerCase(),
8572
+ separator: '/',
8573
+ });
8574
+ const { plugins, // plugins keeps caret inside actual value and remove placeholder on blur
8575
+ ...placeholderOptions
8576
+ // pass 'true' as second argument to add plugin to hide placeholder when input is not focused
8577
+ } = maskitoWithPlaceholder(this.datePlaceholder, true);
8578
+ this.maskitoOptions = {
8579
+ ...dateOptions,
8580
+ plugins: plugins.concat(dateOptions.plugins || []),
8581
+ preprocessors: [
8582
+ // Always put it BEFORE all other preprocessors
8583
+ ...placeholderOptions.preprocessors,
8584
+ ...dateOptions.preprocessors,
8585
+ ],
8586
+ postprocessors: [
8587
+ ...dateOptions.postprocessors,
8588
+ // Always put it AFTER all other postprocessors
8589
+ ...placeholderOptions.postprocessors,
8590
+ ],
8591
+ };
8592
+ this.markForCheck();
8593
+ }
8588
8594
  }
8589
8595
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: MatDate, deps: [{ token: i1.MomentDateAdapter }, { token: i1$1.TranslateService }, { token: i1$2.UntypedFormBuilder }, { token: i0.ChangeDetectorRef }, { token: i1$2.FormGroupDirective, optional: true }], target: i0.ɵɵFactoryTarget.Component });
8590
8596
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.1.1", type: MatDate, selector: "mat-date-field", inputs: { mobile: "mobile", formControl: "formControl", formControlName: "formControlName", placeholder: "placeholder", floatLabel: "floatLabel", appearance: "appearance", required: "required", compact: "compact", autofocus: "autofocus", startDate: "startDate", clearable: "clearable", timezone: "timezone", datePickerFilter: "datePickerFilter", readonly: "readonly", tabindex: "tabindex" }, providers: [
@@ -8761,11 +8767,15 @@ class MatDateTime {
8761
8767
  this.timeControl = this.formBuilder.control(null, this.mobile ? null : Validators.pattern(TIME_REGEXP));
8762
8768
  // Get patterns to display date and date+time
8763
8769
  this.updatePattern(this.translate.instant(['COMMON.DATE_PATTERN', 'COMMON.TIME_PATTERN', 'COMMON.DATE_TIME_PATTERN']));
8764
- this._subscription.add(this.translate.get(['COMMON.DATE_PATTERN', 'COMMON.TIME_PATTERN', 'COMMON.DATE_TIME_PATTERN'])
8765
- .subscribe((patterns) => this.updatePattern(patterns)));
8766
- // Create mask options
8767
- this.createDateMaskOptions();
8768
- this.createTimeMaskOptions();
8770
+ this.updateDateMaskOptions(this.translate.instant('COMMON.DATE_PLACEHOLDER'));
8771
+ this.updateTimeMaskOptions(this.translate.instant('COMMON.TIME_PLACEHOLDER'));
8772
+ this._subscription.add(this.translate.get(['COMMON.DATE_PATTERN', 'COMMON.TIME_PATTERN', 'COMMON.DATE_TIME_PATTERN', 'COMMON.DATE_PLACEHOLDER', 'COMMON.TIME_PLACEHOLDER'])
8773
+ .pipe(skip(1))
8774
+ .subscribe((translate) => {
8775
+ this.updatePattern(translate);
8776
+ this.updateDateMaskOptions(translate['COMMON.DATE_PLACEHOLDER']);
8777
+ this.updateTimeMaskOptions(translate['COMMON.TIME_PLACEHOLDER']);
8778
+ }));
8769
8779
  this._subscription.add(merge(this.dateControl.valueChanges, this.timeControl.valueChanges)
8770
8780
  .subscribe((_) => this.onFormChange()));
8771
8781
  this._writing = false;
@@ -9099,54 +9109,60 @@ class MatDateTime {
9099
9109
  markForCheck() {
9100
9110
  this.cd.markForCheck();
9101
9111
  }
9102
- createDateMaskOptions() {
9103
- this.datePlaceholder = this.translate.instant('COMMON.DATE_PLACEHOLDER');
9104
- const dateOptions = maskitoDateOptionsGenerator({
9105
- mode: this.datePattern.toLowerCase(),
9106
- separator: '/',
9107
- });
9108
- const { plugins, // plugins keeps caret inside actual value and remove placeholder on blur
9109
- ...placeholderOptions
9110
- // pass 'true' as second argument to add plugin to hide placeholder when input is not focused
9111
- } = maskitoWithPlaceholder(this.datePlaceholder, true);
9112
- this.maskitoDateOptions = {
9113
- ...dateOptions,
9114
- plugins: plugins.concat(dateOptions.plugins || []),
9115
- preprocessors: [
9116
- // Always put it BEFORE all other preprocessors
9117
- ...placeholderOptions.preprocessors,
9118
- ...dateOptions.preprocessors,
9119
- ],
9120
- postprocessors: [
9121
- ...dateOptions.postprocessors,
9122
- // Always put it AFTER all other postprocessors
9123
- ...placeholderOptions.postprocessors,
9124
- ],
9125
- };
9112
+ updateDateMaskOptions(datePlaceholder) {
9113
+ if (this.datePlaceholder !== datePlaceholder) {
9114
+ this.datePlaceholder = datePlaceholder;
9115
+ const dateOptions = maskitoDateOptionsGenerator({
9116
+ mode: this.datePattern.toLowerCase(),
9117
+ separator: '/',
9118
+ });
9119
+ const { plugins, // plugins keeps caret inside actual value and remove placeholder on blur
9120
+ ...placeholderOptions
9121
+ // pass 'true' as second argument to add plugin to hide placeholder when input is not focused
9122
+ } = maskitoWithPlaceholder(this.datePlaceholder, true);
9123
+ this.maskitoDateOptions = {
9124
+ ...dateOptions,
9125
+ plugins: plugins.concat(dateOptions.plugins || []),
9126
+ preprocessors: [
9127
+ // Always put it BEFORE all other preprocessors
9128
+ ...placeholderOptions.preprocessors,
9129
+ ...dateOptions.preprocessors,
9130
+ ],
9131
+ postprocessors: [
9132
+ ...dateOptions.postprocessors,
9133
+ // Always put it AFTER all other postprocessors
9134
+ ...placeholderOptions.postprocessors,
9135
+ ],
9136
+ };
9137
+ this.markForCheck();
9138
+ }
9126
9139
  }
9127
- createTimeMaskOptions() {
9128
- this.timePlaceholder = this.translate.instant('COMMON.TIME_PLACEHOLDER');
9129
- const timeOptions = maskitoTimeOptionsGenerator({
9130
- mode: this.timePattern.toUpperCase()
9131
- });
9132
- const { plugins, // plugins keeps caret inside actual value and remove placeholder on blur
9133
- ...placeholderOptions
9134
- // pass 'true' as second argument to add plugin to hide placeholder when input is not focused
9135
- } = maskitoWithPlaceholder(this.timePlaceholder, true);
9136
- this.maskitoTimeOptions = {
9137
- ...timeOptions,
9138
- plugins: plugins.concat(timeOptions.plugins || []),
9139
- preprocessors: [
9140
- // Always put it BEFORE all other preprocessors
9141
- ...placeholderOptions.preprocessors,
9142
- ...timeOptions.preprocessors,
9143
- ],
9144
- postprocessors: [
9145
- ...timeOptions.postprocessors,
9146
- // Always put it AFTER all other postprocessors
9147
- ...placeholderOptions.postprocessors,
9148
- ],
9149
- };
9140
+ updateTimeMaskOptions(timePlaceholder) {
9141
+ if (this.timePlaceholder !== timePlaceholder) {
9142
+ this.timePlaceholder = timePlaceholder;
9143
+ const timeOptions = maskitoTimeOptionsGenerator({
9144
+ mode: this.timePattern.toUpperCase()
9145
+ });
9146
+ const { plugins, // plugins keeps caret inside actual value and remove placeholder on blur
9147
+ ...placeholderOptions
9148
+ // pass 'true' as second argument to add plugin to hide placeholder when input is not focused
9149
+ } = maskitoWithPlaceholder(this.timePlaceholder, true);
9150
+ this.maskitoTimeOptions = {
9151
+ ...timeOptions,
9152
+ plugins: plugins.concat(timeOptions.plugins || []),
9153
+ preprocessors: [
9154
+ // Always put it BEFORE all other preprocessors
9155
+ ...placeholderOptions.preprocessors,
9156
+ ...timeOptions.preprocessors,
9157
+ ],
9158
+ postprocessors: [
9159
+ ...timeOptions.postprocessors,
9160
+ // Always put it AFTER all other postprocessors
9161
+ ...placeholderOptions.postprocessors,
9162
+ ],
9163
+ };
9164
+ this.markForCheck();
9165
+ }
9150
9166
  }
9151
9167
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: MatDateTime, deps: [{ token: i1.MomentDateAdapter }, { token: i1$1.TranslateService }, { token: i1$2.UntypedFormBuilder }, { token: i0.ChangeDetectorRef }, { token: i1$2.FormGroupDirective, optional: true }, { token: MAT_FORM_FIELD_DEFAULT_OPTIONS }], target: i0.ɵɵFactoryTarget.Component });
9152
9168
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.1.1", type: MatDateTime, selector: "mat-date-time-field", inputs: { subscriptSizing: "subscriptSizing", formControl: "formControl", formControlName: "formControlName", required: "required", placeholder: "placeholder", floatLabel: "floatLabel", appearance: "appearance", mobile: "mobile", compact: "compact", autofocus: "autofocus", startDate: "startDate", clearable: "clearable", datePickerFilter: "datePickerFilter", readonly: "readonly", tabindex: "tabindex" }, providers: [
@@ -9296,10 +9312,13 @@ class MatDateShort {
9296
9312
  () => this.formControl.errors);
9297
9313
  // Get patterns to display date
9298
9314
  this.updatePattern(this.translate.instant('COMMON.DATE_YEAR_PATTERN'));
9299
- this._subscription.add(this.translate.get('COMMON.DATE_YEAR_PATTERN')
9300
- .subscribe((pattern) => this.updatePattern(pattern)));
9301
- // Create mask options
9302
- this.createMaskOptions();
9315
+ this.updateMaskOptions(this.translate.instant('COMMON.DATE_YEAR_PLACEHOLDER'));
9316
+ this._subscription.add(this.translate.get(['COMMON.DATE_YEAR_PATTERN', 'COMMON.DATE_YEAR_PLACEHOLDER'])
9317
+ .pipe(skip(1))
9318
+ .subscribe((translate) => {
9319
+ this.updatePattern(translate['COMMON.DATE_YEAR_PATTERN']);
9320
+ this.updateMaskOptions(translate['COMMON.DATE_YEAR_PLACEHOLDER']);
9321
+ }));
9303
9322
  this._subscription.add(this.textControl.valueChanges
9304
9323
  .subscribe((value) => this.onFormChange(value)));
9305
9324
  // Listen status changes (when done outside the component - e.g. when setErrors() is calling on the formControl)
@@ -9530,29 +9549,32 @@ class MatDateShort {
9530
9549
  markForCheck() {
9531
9550
  this.cd.markForCheck();
9532
9551
  }
9533
- createMaskOptions() {
9534
- this.yearPlaceholder = this.translate.instant('COMMON.DATE_YEAR_PLACEHOLDER');
9535
- const dateOptions = maskitoDateOptionsGenerator({
9536
- mode: this.datePattern.toLowerCase(),
9537
- });
9538
- const { plugins, // plugins keeps caret inside actual value and remove placeholder on blur
9539
- ...placeholderOptions
9540
- // pass 'true' as second argument to add plugin to hide placeholder when input is not focused
9541
- } = maskitoWithPlaceholder(this.yearPlaceholder, true);
9542
- this.maskitoOptions = {
9543
- ...dateOptions,
9544
- plugins: plugins.concat(dateOptions.plugins || []),
9545
- preprocessors: [
9546
- // Always put it BEFORE all other preprocessors
9547
- ...placeholderOptions.preprocessors,
9548
- ...dateOptions.preprocessors,
9549
- ],
9550
- postprocessors: [
9551
- ...dateOptions.postprocessors,
9552
- // Always put it AFTER all other postprocessors
9553
- ...placeholderOptions.postprocessors,
9554
- ],
9555
- };
9552
+ updateMaskOptions(yearPlaceholder) {
9553
+ if (this.yearPlaceholder !== yearPlaceholder) {
9554
+ this.yearPlaceholder = yearPlaceholder;
9555
+ const dateOptions = maskitoDateOptionsGenerator({
9556
+ mode: this.datePattern.toLowerCase(),
9557
+ });
9558
+ const { plugins, // plugins keeps caret inside actual value and remove placeholder on blur
9559
+ ...placeholderOptions
9560
+ // pass 'true' as second argument to add plugin to hide placeholder when input is not focused
9561
+ } = maskitoWithPlaceholder(this.yearPlaceholder, true);
9562
+ this.maskitoOptions = {
9563
+ ...dateOptions,
9564
+ plugins: plugins.concat(dateOptions.plugins || []),
9565
+ preprocessors: [
9566
+ // Always put it BEFORE all other preprocessors
9567
+ ...placeholderOptions.preprocessors,
9568
+ ...dateOptions.preprocessors,
9569
+ ],
9570
+ postprocessors: [
9571
+ ...dateOptions.postprocessors,
9572
+ // Always put it AFTER all other postprocessors
9573
+ ...placeholderOptions.postprocessors,
9574
+ ],
9575
+ };
9576
+ this.markForCheck();
9577
+ }
9556
9578
  }
9557
9579
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: MatDateShort, deps: [{ token: i1.MomentDateAdapter }, { token: i1$1.TranslateService }, { token: i1$2.UntypedFormBuilder }, { token: i0.ChangeDetectorRef }, { token: i1$2.FormGroupDirective, optional: true }], target: i0.ɵɵFactoryTarget.Component });
9558
9580
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.1.1", type: MatDateShort, selector: "mat-date-short-field", inputs: { mobile: "mobile", formControl: "formControl", formControlName: "formControlName", placeholder: "placeholder", floatLabel: "floatLabel", appearance: "appearance", required: "required", compact: "compact", autofocus: "autofocus", startDate: "startDate", clearable: "clearable", datePickerFilter: "datePickerFilter", readonly: "readonly", tabindex: "tabindex" }, providers: [