@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.
@@ -67,7 +67,7 @@ import { Keyboard } from '@capacitor/keyboard';
67
67
  import * as i1$1 from '@ngx-translate/core';
68
68
  import { TranslateModule, TranslateService } from '@ngx-translate/core';
69
69
  import * as momentImported from 'moment';
70
- import { isMoment } from 'moment';
70
+ import { isMoment, locale } from 'moment';
71
71
  import * as i1 from '@angular/material-moment-adapter';
72
72
  import { MatMomentDateModule } from '@angular/material-moment-adapter';
73
73
  import 'moment-timezone';
@@ -2543,7 +2543,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
2543
2543
  type: Input
2544
2544
  }] } });
2545
2545
 
2546
- const moment$c = momentImported;
2546
+ const moment$b = momentImported;
2547
2547
  class DateDiffDurationPipe {
2548
2548
  constructor(dateAdapter, translate) {
2549
2549
  this.dateAdapter = dateAdapter;
@@ -2559,11 +2559,11 @@ class DateDiffDurationPipe {
2559
2559
  return this.format(startDate, endDate, args);
2560
2560
  }
2561
2561
  format(startDate, endDate, args) {
2562
- const duration = moment$c.duration(endDate.diff(startDate));
2562
+ const duration = moment$b.duration(endDate.diff(startDate));
2563
2563
  if (duration.asMinutes() < 0)
2564
2564
  return '';
2565
2565
  const withSeconds = args === null || args === void 0 ? void 0 : args.seconds;
2566
- const timeDuration = moment$c(0)
2566
+ const timeDuration = moment$b(0)
2567
2567
  .hour(duration.hours())
2568
2568
  .minute(duration.minutes());
2569
2569
  if (withSeconds) {
@@ -2998,11 +2998,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
2998
2998
  args: [{ name: 'fileSize' }]
2999
2999
  }] });
3000
3000
 
3001
- const moment$b = momentImported;
3001
+ const moment$a = momentImported;
3002
3002
  const DATE_UNIX_TIMESTAMP = 'X';
3003
3003
  const DATE_UNIX_MS_TIMESTAMP = 'x';
3004
3004
  const MOMENT_NO_TIME_PROPERTY = '_hasNoTime';
3005
3005
  class DateUtils {
3006
+ static isEsModule(value) {
3007
+ return moment$a && moment$a['__esModule'] === true;
3008
+ }
3009
+ static get moment() {
3010
+ if (this.__momentResolved)
3011
+ return this.__momentResolved;
3012
+ if (this.isEsModule(moment$a)) {
3013
+ this.__momentResolved = moment$a.default;
3014
+ return this.__momentResolved;
3015
+ }
3016
+ if (typeof moment$a['isMoment'] === 'function') {
3017
+ this.__momentResolved = moment$a;
3018
+ return this.__momentResolved;
3019
+ }
3020
+ throw Error('Cannot find a valid \'moment\' namespace');
3021
+ }
3006
3022
  static min(date1, date2) {
3007
3023
  return date1 && (!date2 || date1.isSameOrBefore(date2)) ? date1 : date2;
3008
3024
  }
@@ -3087,37 +3103,37 @@ function fromDateISOString(value) {
3087
3103
  return value;
3088
3104
  if (typeof value === 'string' && value.length === 10) {
3089
3105
  // Parse the input value, as a date only
3090
- const dateOnly = moment$b(value, DATE_PATTERN);
3106
+ const dateOnly = moment$a(value, DATE_PATTERN);
3091
3107
  if (dateOnly.isValid())
3092
3108
  return DateUtils.markNoTime(dateOnly);
3093
3109
  }
3094
3110
  // Parse the input value, as a ISO date time
3095
- const date = moment$b(value, DATE_ISO_PATTERN);
3111
+ const date = moment$a(value, DATE_ISO_PATTERN);
3096
3112
  if (date.isValid())
3097
3113
  return date;
3098
3114
  // Not valid: trying to convert from unix timestamp
3099
3115
  if (typeof value === 'string') {
3100
3116
  console.warn('Wrong date format - Trying to convert from local time: ' + value);
3101
3117
  if (value.length === 10) {
3102
- return moment$b(value, DATE_UNIX_TIMESTAMP);
3118
+ return moment$a(value, DATE_UNIX_TIMESTAMP);
3103
3119
  }
3104
3120
  else if (value.length === 13) {
3105
- return moment$b(value, DATE_UNIX_MS_TIMESTAMP);
3121
+ return moment$a(value, DATE_UNIX_MS_TIMESTAMP);
3106
3122
  }
3107
3123
  }
3108
3124
  console.warn('Unable to parse date: ' + value);
3109
3125
  return undefined;
3110
3126
  }
3111
3127
  function fromUnixTimestamp(timeInSec) {
3112
- return moment$b(timeInSec, DATE_UNIX_TIMESTAMP);
3128
+ return moment$a(timeInSec, DATE_UNIX_TIMESTAMP);
3113
3129
  }
3114
3130
  function fromUnixMsTimestamp(timeInMs) {
3115
- return moment$b(timeInMs, DATE_UNIX_MS_TIMESTAMP);
3131
+ return moment$a(timeInMs, DATE_UNIX_MS_TIMESTAMP);
3116
3132
  }
3117
3133
  function toDuration(value, unit) {
3118
3134
  if (!value)
3119
3135
  return undefined;
3120
- const duration = moment$b.duration(value, unit);
3136
+ const duration = moment$a.duration(value, unit);
3121
3137
  // fix 990+ ms
3122
3138
  if (duration.milliseconds() >= 990) {
3123
3139
  duration.add(1000 - duration.milliseconds(), 'ms');
@@ -3393,7 +3409,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
3393
3409
  type: Injectable
3394
3410
  }] });
3395
3411
 
3396
- const moment$a = momentImported;
3412
+ const moment$9 = momentImported;
3397
3413
  // @dynamic
3398
3414
  class SharedValidators {
3399
3415
  static getDoubleRegexp(maxDecimals) {
@@ -3474,7 +3490,7 @@ class SharedValidators {
3474
3490
  }
3475
3491
  static validDate(control) {
3476
3492
  const value = control.value;
3477
- const date = !value || moment$a.isMoment(value) ? value : moment$a(value, DATE_ISO_PATTERN);
3493
+ const date = !value || moment$9.isMoment(value) ? value : moment$9(value, DATE_ISO_PATTERN);
3478
3494
  if (date && (!date.isValid() || date.year() < 1970)) {
3479
3495
  return { validDate: true };
3480
3496
  }
@@ -5711,7 +5727,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
5711
5727
  }]
5712
5728
  }] });
5713
5729
 
5714
- const moment$9 = momentImported;
5730
+ const moment$8 = momentImported;
5715
5731
  const DEFAULT_VALUE_ACCESSOR$5 = {
5716
5732
  provide: NG_VALUE_ACCESSOR,
5717
5733
  useExisting: forwardRef(() => MatDate),
@@ -5893,7 +5909,7 @@ class MatDate {
5893
5909
  // No value, but mobile mode: use the current date
5894
5910
  if (!value && this.mobile) {
5895
5911
  this._writing = true;
5896
- value = DateUtils.resetTime(moment$9().locale(this.locale), this.timezone);
5912
+ value = DateUtils.resetTime(DateUtils.moment().locale(this.locale), this.timezone);
5897
5913
  this.formControl.setValue(value, { emitEvent: false });
5898
5914
  this.markForCheck();
5899
5915
  this._writing = false;
@@ -6072,7 +6088,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
6072
6088
  args: ['matInput', { static: false }]
6073
6089
  }] } });
6074
6090
 
6075
- const moment$8 = momentImported;
6091
+ const moment$7 = momentImported;
6076
6092
  const DEFAULT_VALUE_ACCESSOR$4 = {
6077
6093
  provide: NG_VALUE_ACCESSOR,
6078
6094
  useExisting: forwardRef(() => MatDateTime),
@@ -6267,7 +6283,7 @@ class MatDateTime {
6267
6283
  // No value, but mobile mode: use the current date
6268
6284
  if (!value && this.mobile) {
6269
6285
  this._writing = true;
6270
- value = DateUtils.resetTime(moment$8().locale(this.locale));
6286
+ value = DateUtils.resetTime(DateUtils.moment().locale(this.locale));
6271
6287
  this.formControl.setValue(value, { emitEvent: false });
6272
6288
  this.markForCheck();
6273
6289
  this._writing = false;
@@ -13126,7 +13142,7 @@ Peer = Peer_1 = __decorate([
13126
13142
  EntityClass({ typename: 'PeerVO' })
13127
13143
  ], Peer);
13128
13144
 
13129
- const moment$7 = momentImported;
13145
+ const moment$6 = momentImported;
13130
13146
  const SETTINGS_STORAGE_KEY = 'settings';
13131
13147
  const SETTINGS_TRANSIENT_PROPERTIES = ['mobile', 'touchUi' /*deprecated*/];
13132
13148
  // fixme: this constant points to static environment
@@ -13364,11 +13380,11 @@ class LocalSettingsService extends StartableService {
13364
13380
  if (!feature) {
13365
13381
  feature = {
13366
13382
  name: featureName.toLowerCase(),
13367
- lastSyncDate: moment$7().toISOString()
13383
+ lastSyncDate: DateUtils.moment().toISOString()
13368
13384
  };
13369
13385
  }
13370
13386
  else {
13371
- feature.lastSyncDate = moment$7().toISOString();
13387
+ feature.lastSyncDate = DateUtils.moment().toISOString();
13372
13388
  }
13373
13389
  this.saveOfflineFeature(feature);
13374
13390
  }
@@ -13529,7 +13545,7 @@ class LocalSettingsService extends StartableService {
13529
13545
  if (!page || !page.title || !page.path)
13530
13546
  throw Error('Missing required argument \'page\', \'page.path\' or \'page.title\'');
13531
13547
  // Set time
13532
- page.time = page.time || moment$7();
13548
+ page.time = page.time || DateUtils.moment();
13533
13549
  // Clean the title (remove <small> tags)
13534
13550
  if (!opts || opts.removeTitleSmallTag !== false) {
13535
13551
  const tagIndex = page.title.indexOf('</small>');
@@ -17573,7 +17589,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.8", ngImpor
17573
17589
  }] }];
17574
17590
  } });
17575
17591
 
17576
- const moment$6 = momentImported;
17577
17592
  const AndroidOsEnvironment = Object.freeze({
17578
17593
  DIRECTORY_DOWNLOADS: 'Download',
17579
17594
  DIRECTORY_DOWNLOADS_OLD: 'Downloads', // Old name, for older Android version
@@ -17853,16 +17868,16 @@ class PlatformService extends StartableService {
17853
17868
  }
17854
17869
  // config moment lib
17855
17870
  try {
17856
- moment$6.locale(event.lang);
17871
+ locale(event.lang);
17857
17872
  console.debug('[platform] Use locale {' + event.lang + '}');
17858
17873
  }
17859
17874
  // If error, fallback to en
17860
17875
  catch (err) {
17861
- moment$6.locale('en');
17862
- console.warn('[platform] Unknown local for moment lib. Using default [en]');
17876
+ locale('en');
17877
+ console.warn('[platform] Unknown locale for moment lib. Using default [en]');
17863
17878
  }
17864
17879
  // Config date adapter
17865
- this.dateAdapter.setLocale(moment$6.locale());
17880
+ this.dateAdapter.setLocale(locale());
17866
17881
  }
17867
17882
  });
17868
17883
  this.settings.onChange.subscribe(data => {
@@ -29390,7 +29405,7 @@ class AbstractUserEventService extends BaseGraphqlService {
29390
29405
  }
29391
29406
  resetCount() {
29392
29407
  this._countSubject.next(undefined);
29393
- this.resetCountDate = moment$5();
29408
+ this.resetCountDate = DateUtils.moment();
29394
29409
  // restart listening count changes
29395
29410
  this.startListenCountChanges();
29396
29411
  }
@@ -29449,7 +29464,7 @@ class AbstractUserEventService extends BaseGraphqlService {
29449
29464
  if (!userEvents.length)
29450
29465
  return;
29451
29466
  // set read date
29452
- userEvents.forEach(userEvent => userEvent.readDate = moment$5());
29467
+ userEvents.forEach(userEvent => userEvent.readDate = DateUtils.moment());
29453
29468
  // split local/remote entities
29454
29469
  const localEntities = userEvents.filter(EntityUtils.isLocal);
29455
29470
  const remoteEntities = userEvents.filter(EntityUtils.isRemote);
@@ -31307,7 +31322,7 @@ class SwipeTestPage {
31307
31322
  this.formBuilder = formBuilder;
31308
31323
  this.dateFormatPipe = dateFormatPipe;
31309
31324
  this.$dates = new BehaviorSubject(undefined);
31310
- this._today = moment$4().startOf('day');
31325
+ this._today = DateUtils.moment().startOf('day');
31311
31326
  this.form = formBuilder.group({
31312
31327
  empty: [null, Validators.required],
31313
31328
  date: [null, Validators.compose([Validators.required, SharedValidators.validDate])],
@@ -31391,7 +31406,7 @@ class DateTimeTestPage {
31391
31406
  // Load the form with data
31392
31407
  loadData() {
31393
31408
  return __awaiter(this, void 0, void 0, function* () {
31394
- const now = moment$3();
31409
+ const now = DateUtils.moment();
31395
31410
  const data = {
31396
31411
  empty: null,
31397
31412
  emptyRequired: null,
@@ -31664,7 +31679,7 @@ class DateTestPage {
31664
31679
  // Load the form with data
31665
31680
  loadData() {
31666
31681
  return __awaiter(this, void 0, void 0, function* () {
31667
- const now = moment$2();
31682
+ const now = DateUtils.moment();
31668
31683
  const nowAtMahe = now.clone().tz(this.timezone).startOf('day');
31669
31684
  const data = {
31670
31685
  empty: null,
@@ -31795,7 +31810,7 @@ class ObservableTestPage {
31795
31810
  this._stopSubject.next();
31796
31811
  }
31797
31812
  log(message, ...args) {
31798
- let fullMessage = `${toDateISOString(moment$1())} - ${message}`;
31813
+ let fullMessage = `${toDateISOString(DateUtils.moment())} - ${message}`;
31799
31814
  if (args === null || args === void 0 ? void 0 : args.length) {
31800
31815
  fullMessage += ' - <small>' + args.map(JSON.stringify).join(', ') + '</small>';
31801
31816
  }
@@ -33291,7 +33306,7 @@ class UserEventTestingPage {
33291
33306
  type: 'message',
33292
33307
  level: 'INFO',
33293
33308
  message: 'message test message test message test message test message test message test message test message test',
33294
- creationDate: moment(),
33309
+ creationDate: DateUtils.moment(),
33295
33310
  }));
33296
33311
  }
33297
33312
  addError() {
@@ -33301,7 +33316,7 @@ class UserEventTestingPage {
33301
33316
  type: 'upload',
33302
33317
  level: 'ERROR',
33303
33318
  message: 'message error',
33304
- creationDate: moment(),
33319
+ creationDate: DateUtils.moment(),
33305
33320
  }));
33306
33321
  }
33307
33322
  addWarning() {
@@ -33311,7 +33326,7 @@ class UserEventTestingPage {
33311
33326
  type: 'download',
33312
33327
  level: 'WARNING',
33313
33328
  message: 'message warning',
33314
- creationDate: moment(),
33329
+ creationDate: DateUtils.moment(),
33315
33330
  }));
33316
33331
  }
33317
33332
  addDebug() {
@@ -33321,7 +33336,7 @@ class UserEventTestingPage {
33321
33336
  type: 'debug',
33322
33337
  level: 'DEBUG',
33323
33338
  message: 'message DEBUG',
33324
- creationDate: moment(),
33339
+ creationDate: DateUtils.moment(),
33325
33340
  }));
33326
33341
  }
33327
33342
  addNotificationWithLink() {
@@ -33331,7 +33346,7 @@ class UserEventTestingPage {
33331
33346
  type: 'message',
33332
33347
  level: 'INFO',
33333
33348
  message: 'message with link',
33334
- creationDate: moment(),
33349
+ creationDate: DateUtils.moment(),
33335
33350
  actions: [{
33336
33351
  name: 'click here',
33337
33352
  iconRef: {
@@ -33348,7 +33363,7 @@ class UserEventTestingPage {
33348
33363
  type: 'message',
33349
33364
  level: 'INFO',
33350
33365
  message: 'message with action',
33351
- creationDate: moment(),
33366
+ creationDate: DateUtils.moment(),
33352
33367
  actions: [
33353
33368
  {
33354
33369
  name: 'click here',
@@ -33420,7 +33435,7 @@ class UserEventTestingPage {
33420
33435
  type: 'message',
33421
33436
  level: 'INFO',
33422
33437
  message: 'message with action',
33423
- creationDate: moment(),
33438
+ creationDate: DateUtils.moment(),
33424
33439
  actions: [
33425
33440
  {
33426
33441
  default: true,