@sumaris-net/ngx-components 2.0.0-rc21 → 2.0.0-rc22

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.
@@ -66,7 +66,7 @@ import { Keyboard } from '@capacitor/keyboard';
66
66
  import * as i1$1 from '@ngx-translate/core';
67
67
  import { TranslateModule, TranslateService } from '@ngx-translate/core';
68
68
  import * as momentImported from 'moment';
69
- import { isMoment } from 'moment';
69
+ import { isMoment, locale } from 'moment';
70
70
  import * as i1 from '@angular/material-moment-adapter';
71
71
  import { MatMomentDateModule } from '@angular/material-moment-adapter';
72
72
  import 'moment-timezone';
@@ -2530,7 +2530,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
2530
2530
  type: Input
2531
2531
  }] } });
2532
2532
 
2533
- const moment$c = momentImported;
2533
+ const moment$b = momentImported;
2534
2534
  class DateDiffDurationPipe {
2535
2535
  constructor(dateAdapter, translate) {
2536
2536
  this.dateAdapter = dateAdapter;
@@ -2546,11 +2546,11 @@ class DateDiffDurationPipe {
2546
2546
  return this.format(startDate, endDate, args);
2547
2547
  }
2548
2548
  format(startDate, endDate, args) {
2549
- const duration = moment$c.duration(endDate.diff(startDate));
2549
+ const duration = moment$b.duration(endDate.diff(startDate));
2550
2550
  if (duration.asMinutes() < 0)
2551
2551
  return '';
2552
2552
  const withSeconds = args?.seconds;
2553
- const timeDuration = moment$c(0)
2553
+ const timeDuration = moment$b(0)
2554
2554
  .hour(duration.hours())
2555
2555
  .minute(duration.minutes());
2556
2556
  if (withSeconds) {
@@ -2991,11 +2991,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
2991
2991
  args: [{ name: 'fileSize' }]
2992
2992
  }] });
2993
2993
 
2994
- const moment$b = momentImported;
2994
+ const moment$a = momentImported;
2995
2995
  const DATE_UNIX_TIMESTAMP = 'X';
2996
2996
  const DATE_UNIX_MS_TIMESTAMP = 'x';
2997
2997
  const MOMENT_NO_TIME_PROPERTY = '_hasNoTime';
2998
2998
  class DateUtils {
2999
+ static isEsModule(value) {
3000
+ return moment$a && moment$a['__esModule'] === true;
3001
+ }
3002
+ static get moment() {
3003
+ if (this.__momentResolved)
3004
+ return this.__momentResolved;
3005
+ if (this.isEsModule(moment$a)) {
3006
+ this.__momentResolved = moment$a.default;
3007
+ return this.__momentResolved;
3008
+ }
3009
+ if (typeof moment$a['isMoment'] === 'function') {
3010
+ this.__momentResolved = moment$a;
3011
+ return this.__momentResolved;
3012
+ }
3013
+ throw Error('Cannot find a valid \'moment\' namespace');
3014
+ }
2999
3015
  static min(date1, date2) {
3000
3016
  return date1 && (!date2 || date1.isSameOrBefore(date2)) ? date1 : date2;
3001
3017
  }
@@ -3080,37 +3096,37 @@ function fromDateISOString(value) {
3080
3096
  return value;
3081
3097
  if (typeof value === 'string' && value.length === 10) {
3082
3098
  // Parse the input value, as a date only
3083
- const dateOnly = moment$b(value, DATE_PATTERN);
3099
+ const dateOnly = moment$a(value, DATE_PATTERN);
3084
3100
  if (dateOnly.isValid())
3085
3101
  return DateUtils.markNoTime(dateOnly);
3086
3102
  }
3087
3103
  // Parse the input value, as a ISO date time
3088
- const date = moment$b(value, DATE_ISO_PATTERN);
3104
+ const date = moment$a(value, DATE_ISO_PATTERN);
3089
3105
  if (date.isValid())
3090
3106
  return date;
3091
3107
  // Not valid: trying to convert from unix timestamp
3092
3108
  if (typeof value === 'string') {
3093
3109
  console.warn('Wrong date format - Trying to convert from local time: ' + value);
3094
3110
  if (value.length === 10) {
3095
- return moment$b(value, DATE_UNIX_TIMESTAMP);
3111
+ return moment$a(value, DATE_UNIX_TIMESTAMP);
3096
3112
  }
3097
3113
  else if (value.length === 13) {
3098
- return moment$b(value, DATE_UNIX_MS_TIMESTAMP);
3114
+ return moment$a(value, DATE_UNIX_MS_TIMESTAMP);
3099
3115
  }
3100
3116
  }
3101
3117
  console.warn('Unable to parse date: ' + value);
3102
3118
  return undefined;
3103
3119
  }
3104
3120
  function fromUnixTimestamp(timeInSec) {
3105
- return moment$b(timeInSec, DATE_UNIX_TIMESTAMP);
3121
+ return moment$a(timeInSec, DATE_UNIX_TIMESTAMP);
3106
3122
  }
3107
3123
  function fromUnixMsTimestamp(timeInMs) {
3108
- return moment$b(timeInMs, DATE_UNIX_MS_TIMESTAMP);
3124
+ return moment$a(timeInMs, DATE_UNIX_MS_TIMESTAMP);
3109
3125
  }
3110
3126
  function toDuration(value, unit) {
3111
3127
  if (!value)
3112
3128
  return undefined;
3113
- const duration = moment$b.duration(value, unit);
3129
+ const duration = moment$a.duration(value, unit);
3114
3130
  // fix 990+ ms
3115
3131
  if (duration.milliseconds() >= 990) {
3116
3132
  duration.add(1000 - duration.milliseconds(), 'ms');
@@ -3385,7 +3401,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
3385
3401
  type: Injectable
3386
3402
  }] });
3387
3403
 
3388
- const moment$a = momentImported;
3404
+ const moment$9 = momentImported;
3389
3405
  // @dynamic
3390
3406
  class SharedValidators {
3391
3407
  static getDoubleRegexp(maxDecimals) {
@@ -3466,7 +3482,7 @@ class SharedValidators {
3466
3482
  }
3467
3483
  static validDate(control) {
3468
3484
  const value = control.value;
3469
- const date = !value || moment$a.isMoment(value) ? value : moment$a(value, DATE_ISO_PATTERN);
3485
+ const date = !value || moment$9.isMoment(value) ? value : moment$9(value, DATE_ISO_PATTERN);
3470
3486
  if (date && (!date.isValid() || date.year() < 1970)) {
3471
3487
  return { validDate: true };
3472
3488
  }
@@ -5723,7 +5739,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
5723
5739
  }]
5724
5740
  }] });
5725
5741
 
5726
- const moment$9 = momentImported;
5742
+ const moment$8 = momentImported;
5727
5743
  const DEFAULT_VALUE_ACCESSOR$5 = {
5728
5744
  provide: NG_VALUE_ACCESSOR,
5729
5745
  useExisting: forwardRef(() => MatDate),
@@ -5905,7 +5921,7 @@ class MatDate {
5905
5921
  // No value, but mobile mode: use the current date
5906
5922
  if (!value && this.mobile) {
5907
5923
  this._writing = true;
5908
- value = DateUtils.resetTime(moment$9().locale(this.locale), this.timezone);
5924
+ value = DateUtils.resetTime(DateUtils.moment().locale(this.locale), this.timezone);
5909
5925
  this.formControl.setValue(value, { emitEvent: false });
5910
5926
  this.markForCheck();
5911
5927
  this._writing = false;
@@ -6083,7 +6099,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
6083
6099
  args: ['matInput', { static: false }]
6084
6100
  }] } });
6085
6101
 
6086
- const moment$8 = momentImported;
6102
+ const moment$7 = momentImported;
6087
6103
  const DEFAULT_VALUE_ACCESSOR$4 = {
6088
6104
  provide: NG_VALUE_ACCESSOR,
6089
6105
  useExisting: forwardRef(() => MatDateTime),
@@ -6278,7 +6294,7 @@ class MatDateTime {
6278
6294
  // No value, but mobile mode: use the current date
6279
6295
  if (!value && this.mobile) {
6280
6296
  this._writing = true;
6281
- value = DateUtils.resetTime(moment$8().locale(this.locale));
6297
+ value = DateUtils.resetTime(DateUtils.moment().locale(this.locale));
6282
6298
  this.formControl.setValue(value, { emitEvent: false });
6283
6299
  this.markForCheck();
6284
6300
  this._writing = false;
@@ -13005,7 +13021,7 @@ Peer = Peer_1 = __decorate([
13005
13021
  EntityClass({ typename: 'PeerVO' })
13006
13022
  ], Peer);
13007
13023
 
13008
- const moment$7 = momentImported;
13024
+ const moment$6 = momentImported;
13009
13025
  const SETTINGS_STORAGE_KEY = 'settings';
13010
13026
  const SETTINGS_TRANSIENT_PROPERTIES = ['mobile', 'touchUi' /*deprecated*/];
13011
13027
  // fixme: this constant points to static environment
@@ -13233,11 +13249,11 @@ class LocalSettingsService extends StartableService {
13233
13249
  if (!feature) {
13234
13250
  feature = {
13235
13251
  name: featureName.toLowerCase(),
13236
- lastSyncDate: moment$7().toISOString()
13252
+ lastSyncDate: DateUtils.moment().toISOString()
13237
13253
  };
13238
13254
  }
13239
13255
  else {
13240
- feature.lastSyncDate = moment$7().toISOString();
13256
+ feature.lastSyncDate = DateUtils.moment().toISOString();
13241
13257
  }
13242
13258
  this.saveOfflineFeature(feature);
13243
13259
  }
@@ -13392,7 +13408,7 @@ class LocalSettingsService extends StartableService {
13392
13408
  if (!page || !page.title || !page.path)
13393
13409
  throw Error('Missing required argument \'page\', \'page.path\' or \'page.title\'');
13394
13410
  // Set time
13395
- page.time = page.time || moment$7();
13411
+ page.time = page.time || DateUtils.moment();
13396
13412
  // Clean the title (remove <small> tags)
13397
13413
  if (!opts || opts.removeTitleSmallTag !== false) {
13398
13414
  const tagIndex = page.title.indexOf('</small>');
@@ -17309,7 +17325,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
17309
17325
  args: [APP_CONFIG_OPTIONS]
17310
17326
  }] }]; } });
17311
17327
 
17312
- const moment$6 = momentImported;
17313
17328
  const AndroidOsEnvironment = Object.freeze({
17314
17329
  DIRECTORY_DOWNLOADS: 'Download',
17315
17330
  DIRECTORY_DOWNLOADS_OLD: 'Downloads', // Old name, for older Android version
@@ -17595,16 +17610,16 @@ class PlatformService extends StartableService {
17595
17610
  }
17596
17611
  // config moment lib
17597
17612
  try {
17598
- moment$6.locale(event.lang);
17613
+ locale(event.lang);
17599
17614
  console.debug('[platform] Use locale {' + event.lang + '}');
17600
17615
  }
17601
17616
  // If error, fallback to en
17602
17617
  catch (err) {
17603
- moment$6.locale('en');
17604
- console.warn('[platform] Unknown local for moment lib. Using default [en]');
17618
+ locale('en');
17619
+ console.warn('[platform] Unknown locale for moment lib. Using default [en]');
17605
17620
  }
17606
17621
  // Config date adapter
17607
- this.dateAdapter.setLocale(moment$6.locale());
17622
+ this.dateAdapter.setLocale(locale());
17608
17623
  }
17609
17624
  });
17610
17625
  this.settings.onChange.subscribe(data => {
@@ -28743,7 +28758,7 @@ class AbstractUserEventService extends BaseGraphqlService {
28743
28758
  }
28744
28759
  resetCount() {
28745
28760
  this._countSubject.next(undefined);
28746
- this.resetCountDate = moment$5();
28761
+ this.resetCountDate = DateUtils.moment();
28747
28762
  // restart listening count changes
28748
28763
  this.startListenCountChanges();
28749
28764
  }
@@ -28795,7 +28810,7 @@ class AbstractUserEventService extends BaseGraphqlService {
28795
28810
  if (!userEvents.length)
28796
28811
  return;
28797
28812
  // set read date
28798
- userEvents.forEach(userEvent => userEvent.readDate = moment$5());
28813
+ userEvents.forEach(userEvent => userEvent.readDate = DateUtils.moment());
28799
28814
  // split local/remote entities
28800
28815
  const localEntities = userEvents.filter(EntityUtils.isLocal);
28801
28816
  const remoteEntities = userEvents.filter(EntityUtils.isRemote);
@@ -30606,7 +30621,7 @@ class SwipeTestPage {
30606
30621
  this.formBuilder = formBuilder;
30607
30622
  this.dateFormatPipe = dateFormatPipe;
30608
30623
  this.$dates = new BehaviorSubject(undefined);
30609
- this._today = moment$4().startOf('day');
30624
+ this._today = DateUtils.moment().startOf('day');
30610
30625
  this.form = formBuilder.group({
30611
30626
  empty: [null, Validators.required],
30612
30627
  date: [null, Validators.compose([Validators.required, SharedValidators.validDate])],
@@ -30687,7 +30702,7 @@ class DateTimeTestPage {
30687
30702
  }
30688
30703
  // Load the form with data
30689
30704
  async loadData() {
30690
- const now = moment$3();
30705
+ const now = DateUtils.moment();
30691
30706
  const data = {
30692
30707
  empty: null,
30693
30708
  emptyRequired: null,
@@ -30953,7 +30968,7 @@ class DateTestPage {
30953
30968
  }
30954
30969
  // Load the form with data
30955
30970
  async loadData() {
30956
- const now = moment$2();
30971
+ const now = DateUtils.moment();
30957
30972
  const nowAtMahe = now.clone().tz(this.timezone).startOf('day');
30958
30973
  const data = {
30959
30974
  empty: null,
@@ -31083,7 +31098,7 @@ class ObservableTestPage {
31083
31098
  this._stopSubject.next();
31084
31099
  }
31085
31100
  log(message, ...args) {
31086
- let fullMessage = `${toDateISOString(moment$1())} - ${message}`;
31101
+ let fullMessage = `${toDateISOString(DateUtils.moment())} - ${message}`;
31087
31102
  if (args?.length) {
31088
31103
  fullMessage += ' - <small>' + args.map(JSON.stringify).join(', ') + '</small>';
31089
31104
  }
@@ -32572,7 +32587,7 @@ class UserEventTestingPage {
32572
32587
  type: 'message',
32573
32588
  level: 'INFO',
32574
32589
  message: 'message test message test message test message test message test message test message test message test',
32575
- creationDate: moment(),
32590
+ creationDate: DateUtils.moment(),
32576
32591
  }));
32577
32592
  }
32578
32593
  addError() {
@@ -32582,7 +32597,7 @@ class UserEventTestingPage {
32582
32597
  type: 'upload',
32583
32598
  level: 'ERROR',
32584
32599
  message: 'message error',
32585
- creationDate: moment(),
32600
+ creationDate: DateUtils.moment(),
32586
32601
  }));
32587
32602
  }
32588
32603
  addWarning() {
@@ -32592,7 +32607,7 @@ class UserEventTestingPage {
32592
32607
  type: 'download',
32593
32608
  level: 'WARNING',
32594
32609
  message: 'message warning',
32595
- creationDate: moment(),
32610
+ creationDate: DateUtils.moment(),
32596
32611
  }));
32597
32612
  }
32598
32613
  addDebug() {
@@ -32602,7 +32617,7 @@ class UserEventTestingPage {
32602
32617
  type: 'debug',
32603
32618
  level: 'DEBUG',
32604
32619
  message: 'message DEBUG',
32605
- creationDate: moment(),
32620
+ creationDate: DateUtils.moment(),
32606
32621
  }));
32607
32622
  }
32608
32623
  addNotificationWithLink() {
@@ -32612,7 +32627,7 @@ class UserEventTestingPage {
32612
32627
  type: 'message',
32613
32628
  level: 'INFO',
32614
32629
  message: 'message with link',
32615
- creationDate: moment(),
32630
+ creationDate: DateUtils.moment(),
32616
32631
  actions: [{
32617
32632
  name: 'click here',
32618
32633
  iconRef: {
@@ -32629,7 +32644,7 @@ class UserEventTestingPage {
32629
32644
  type: 'message',
32630
32645
  level: 'INFO',
32631
32646
  message: 'message with action',
32632
- creationDate: moment(),
32647
+ creationDate: DateUtils.moment(),
32633
32648
  actions: [
32634
32649
  {
32635
32650
  name: 'click here',
@@ -32699,7 +32714,7 @@ class UserEventTestingPage {
32699
32714
  type: 'message',
32700
32715
  level: 'INFO',
32701
32716
  message: 'message with action',
32702
- creationDate: moment(),
32717
+ creationDate: DateUtils.moment(),
32703
32718
  actions: [
32704
32719
  {
32705
32720
  default: true,