@wavemaker/angular-codegen 11.1.4-rc.5187 → 11.2.0-next.140101

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.
@@ -45619,6 +45619,8 @@ var Operation;
45619
45619
  const DataSource = {
45620
45620
  Operation
45621
45621
  };
45622
+ class AbstractI18nService {
45623
+ }
45622
45624
 
45623
45625
  const userAgent = window.navigator.userAgent;
45624
45626
  const REGEX = {
@@ -45651,7 +45653,8 @@ const REGEX = {
45651
45653
  SPECIAL_CHARACTERS: /[^A-Z0-9a-z_]+/i,
45652
45654
  APP_SERVER_URL_FORMAT: /^(http[s]?:\/\/)(www\.){0,1}[a-zA-Z0-9\.\-]+([:]?[0-9]{2,5}|\.[a-zA-Z]{2,5}[\.]{0,1})\/+[^?#&=]+$/,
45653
45655
  JSON_DATE_FORMAT: /\d{4}-[0-1]\d-[0-3]\d(T[0-2]\d:[0-5]\d:[0-5]\d.\d{1,3}Z$)?/,
45654
- DATA_URL: /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*)\s*$/i
45656
+ DATA_URL: /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*)\s*$/i,
45657
+ ISO_DATE_FORMAT: /(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})(\.\d+)?([+-]\d{2}:?\d{2}|Z)$/
45655
45658
  }, compareBySeparator = ':';
45656
45659
  const NUMBER_TYPES = ['int', DataType.INTEGER, DataType.FLOAT, DataType.DOUBLE, DataType.LONG, DataType.SHORT, DataType.BYTE, DataType.BIG_INTEGER, DataType.BIG_DECIMAL];
45657
45660
  const now = new Date();
@@ -45877,19 +45880,43 @@ function triggerFn(fn, ...argmnts) {
45877
45880
  /**
45878
45881
  * This method is used to get the formatted date
45879
45882
  */
45880
- const getFormattedDate = (datePipe, dateObj, format) => {
45883
+ const getFormattedDate = (datePipe, dateObj, format, timeZone, isTimeStampType, isIntervalDateTime, compInstance) => {
45881
45884
  if (!dateObj) {
45882
45885
  return undefined;
45883
45886
  }
45884
45887
  if (format === 'timestamp') {
45885
45888
  return moment(dateObj).valueOf();
45886
45889
  }
45887
- return datePipe.transform(dateObj, format);
45890
+ if (format === 'UTC') {
45891
+ return new Date(dateObj).toISOString();
45892
+ }
45893
+ if (timeZone) {
45894
+ const momentFormat = format.replaceAll('y', 'Y').replaceAll('d', 'D').replace('a', 'A');
45895
+ if (isIntervalDateTime) { // dates which are of type time widget (value is hh:mm:ss) but returned as date string from time comp
45896
+ return moment(dateObj).format(momentFormat);
45897
+ }
45898
+ if (isTimeStampType === 'datetimestamp') {
45899
+ dateObj = getMomentLocaleObject(timeZone, dateObj);
45900
+ return moment(dateObj).format(momentFormat);
45901
+ }
45902
+ }
45903
+ return datePipe.transform(dateObj, format, timeZone, compInstance);
45904
+ };
45905
+ /**
45906
+ * This method is used to check if the date has timezone information or not
45907
+ */
45908
+ const hasOffsetStr = (dateStr) => {
45909
+ if (typeof dateStr !== 'string')
45910
+ return;
45911
+ const matches = dateStr.match(REGEX.ISO_DATE_FORMAT);
45912
+ if (matches && matches[4]) {
45913
+ return true;
45914
+ }
45888
45915
  };
45889
45916
  /**
45890
45917
  * method to get the date object from the input received
45891
45918
  */
45892
- const getDateObj = (value, options) => {
45919
+ const getDateObj = (value, options, timezone) => {
45893
45920
  // Handling localization
45894
45921
  if (options && options.pattern && options.pattern !== 'timestamp') {
45895
45922
  // Fix for WMS-19601, invalid date is returned on date selection.
@@ -45921,7 +45948,7 @@ const getDateObj = (value, options) => {
45921
45948
  * (Ex: If date value is "1990-11-23" and moment(value).format() is "١٩٩٠-١١-٢٣T٠٠:٠٠:٠٠+٠٥:٣٠")
45922
45949
  * and new Date(moment(value).format()) is giving Invalid Date. So frst converting it to timestamp value.
45923
45950
  */
45924
- dateObj = new Date(moment(moment(value).format()).valueOf());
45951
+ dateObj = !timezone ? new Date(moment(moment(value).format()).valueOf()) : getMomentLocaleObject(timezone, value);
45925
45952
  }
45926
45953
  if (value === CURRENT_DATE || isNaN(dateObj.getDay())) {
45927
45954
  return now;
@@ -46313,6 +46340,14 @@ const loadStyleSheets = (urls = []) => {
46313
46340
  // function to check if the script is already loaded
46314
46341
  const isScriptLoaded = src => !!getNode(`script[src="${src}"], script[data-src="${src}"]`);
46315
46342
  const ɵ4$3 = isScriptLoaded;
46343
+ const getMomentLocaleObject = (timeZone, dateObj) => {
46344
+ if (dateObj) {
46345
+ return new Date(new Date(moment(dateObj).tz(timeZone).format()).toLocaleString("en-US", { timeZone: timeZone }));
46346
+ }
46347
+ else {
46348
+ return new Date(new Date(moment().tz(timeZone).format()).toLocaleString("en-US", { timeZone: timeZone }));
46349
+ }
46350
+ };
46316
46351
  const loadScript = (url, loadViaScriptTag, cacheable = false) => __awaiter$1(void 0, void 0, void 0, function* () {
46317
46352
  const _url = url.trim();
46318
46353
  if (!_url.length || isScriptLoaded(_url)) {
@@ -46919,6 +46954,9 @@ const findRootContainer = ($el) => {
46919
46954
  if (!root.length) {
46920
46955
  root = $el.closest('.app-partial');
46921
46956
  }
46957
+ if (!root.length) {
46958
+ root = $el.closest('.app-spa-page');
46959
+ }
46922
46960
  if (!root.length) {
46923
46961
  root = $el.closest('.app-page');
46924
46962
  }
@@ -47032,6 +47070,7 @@ var Utils = /*#__PURE__*/Object.freeze({
47032
47070
  getResourceURL: getResourceURL,
47033
47071
  triggerFn: triggerFn,
47034
47072
  getFormattedDate: getFormattedDate,
47073
+ hasOffsetStr: hasOffsetStr,
47035
47074
  getDateObj: getDateObj,
47036
47075
  addEventListenerOnElement: addEventListenerOnElement,
47037
47076
  getClonedObject: getClonedObject,
@@ -47055,6 +47094,7 @@ var Utils = /*#__PURE__*/Object.freeze({
47055
47094
  isEqualWithFields: isEqualWithFields,
47056
47095
  loadStyleSheet: loadStyleSheet,
47057
47096
  loadStyleSheets: loadStyleSheets,
47097
+ getMomentLocaleObject: getMomentLocaleObject,
47058
47098
  loadScript: loadScript,
47059
47099
  loadScripts: loadScripts,
47060
47100
  _WM_APP_PROJECT: _WM_APP_PROJECT,
@@ -69437,10 +69477,11 @@ const getEpochValue = data => {
69437
69477
  return epoch;
69438
69478
  };
69439
69479
  class ToDatePipe {
69440
- constructor(datePipe) {
69480
+ constructor(datePipe, i18nService) {
69441
69481
  this.datePipe = datePipe;
69482
+ this.i18nService = i18nService;
69442
69483
  }
69443
- transform(data, format) {
69484
+ transform(data, format, timezone, compInstance) {
69444
69485
  let timestamp;
69445
69486
  // 'null' is to be treated as a special case, If user wants to enter null value, empty string will be passed to the backend
69446
69487
  if (data === 'null' || data === '') {
@@ -69454,7 +69495,18 @@ class ToDatePipe {
69454
69495
  if (format === 'timestamp') {
69455
69496
  return timestamp;
69456
69497
  }
69457
- return this.datePipe.transform(timestamp, format);
69498
+ if (format === 'UTC') {
69499
+ return new Date(timestamp).toISOString();
69500
+ }
69501
+ let formattedVal;
69502
+ const timeZone = this.i18nService ? this.i18nService.getTimezone(compInstance) : timezone;
69503
+ if (timeZone && (data === timestamp || hasOffsetStr(data))) {
69504
+ formattedVal = moment(timestamp).tz(timeZone).format(format.replaceAll('y', 'Y').replaceAll('d', 'D').replace('a', 'A'));
69505
+ }
69506
+ else {
69507
+ formattedVal = this.datePipe.transform(timestamp, format);
69508
+ }
69509
+ return formattedVal;
69458
69510
  }
69459
69511
  return '';
69460
69512
  }
@@ -69465,18 +69517,22 @@ ToDatePipe.decorators = [
69465
69517
  },] }
69466
69518
  ];
69467
69519
  ToDatePipe.ctorParameters = () => [
69468
- { type: DatePipe$1 }
69520
+ { type: DatePipe$1 },
69521
+ { type: AbstractI18nService }
69469
69522
  ];
69470
69523
  class ToNumberPipe {
69471
- constructor(decimalPipe) {
69524
+ constructor(decimalPipe, i18Service) {
69472
69525
  this.decimalPipe = decimalPipe;
69526
+ this.i18Service = i18Service;
69473
69527
  }
69474
69528
  transform(data, fracSize) {
69475
69529
  if (fracSize && !String(fracSize).match(/^(\d+)?\.((\d+)(-(\d+))?)?$/)) {
69476
69530
  fracSize = '1.' + fracSize + '-' + fracSize;
69477
69531
  }
69478
69532
  if (!_.isNaN(+data)) {
69479
- return this.decimalPipe.transform(data, fracSize);
69533
+ const locale = this.i18Service.getwidgetLocale() ? this.i18Service.getwidgetLocale() : undefined;
69534
+ const formattedLocale = locale ? locale['number'] : undefined;
69535
+ return this.decimalPipe.transform(data, fracSize, formattedLocale);
69480
69536
  }
69481
69537
  }
69482
69538
  }
@@ -69486,15 +69542,17 @@ ToNumberPipe.decorators = [
69486
69542
  },] }
69487
69543
  ];
69488
69544
  ToNumberPipe.ctorParameters = () => [
69489
- { type: DecimalPipe$1 }
69545
+ { type: DecimalPipe$1 },
69546
+ { type: AbstractI18nService, decorators: [{ type: Inject$1, args: [AbstractI18nService,] }] }
69490
69547
  ];
69491
69548
  class ToCurrencyPipe {
69492
- constructor(decimalPipe) {
69549
+ constructor(decimalPipe, i18Service) {
69493
69550
  this.decimalPipe = decimalPipe;
69551
+ this.i18Service = i18Service;
69494
69552
  }
69495
69553
  transform(data, currencySymbol, fracSize) {
69496
69554
  const _currencySymbol = (CURRENCY_INFO[currencySymbol] || {}).symbol || currencySymbol || '';
69497
- let _val = new ToNumberPipe(this.decimalPipe).transform(data, fracSize);
69555
+ let _val = new ToNumberPipe(this.decimalPipe, this.i18Service).transform(data, fracSize);
69498
69556
  const isNegativeNumber = _.startsWith(_val, '-');
69499
69557
  if (isNegativeNumber) {
69500
69558
  _val = _val.replace('-', '');
@@ -69508,7 +69566,8 @@ ToCurrencyPipe.decorators = [
69508
69566
  },] }
69509
69567
  ];
69510
69568
  ToCurrencyPipe.ctorParameters = () => [
69511
- { type: DecimalPipe$1 }
69569
+ { type: DecimalPipe$1 },
69570
+ { type: AbstractI18nService, decorators: [{ type: Inject$1, args: [AbstractI18nService,] }] }
69512
69571
  ];
69513
69572
  class PrefixPipe {
69514
69573
  transform(data, padding) {
@@ -71632,11 +71691,14 @@ Title$1.ctorParameters = () => [
71632
71691
  const VERSION$4 = new Version('12.2.16');
71633
71692
 
71634
71693
  class PipeProvider {
71635
- constructor(compiler, injector, domSanitizer) {
71694
+ constructor(compiler, injector, domSanitizer, i18service) {
71695
+ var _a;
71636
71696
  this.compiler = compiler;
71637
71697
  this.injector = injector;
71638
71698
  this.domSanitizer = domSanitizer;
71699
+ this.i18service = i18service;
71639
71700
  this._locale = getSessionStorageItem('selectedLocale') || 'en';
71701
+ this.formatsByLocale = (_a = this.i18service) === null || _a === void 0 ? void 0 : _a.getwidgetLocale();
71640
71702
  this.preparePipeMeta = (reference, name, pure, diDeps = []) => ({
71641
71703
  type: { reference, diDeps },
71642
71704
  name,
@@ -71671,10 +71733,12 @@ class PipeProvider {
71671
71733
  new DatePipe(this._locale)
71672
71734
  ]),
71673
71735
  this.preparePipeMeta(ToNumberPipe, 'toNumber', true, [
71674
- new DecimalPipe(this._locale)
71736
+ new DecimalPipe(this._locale),
71737
+ this.i18service
71675
71738
  ]),
71676
71739
  this.preparePipeMeta(ToCurrencyPipe, 'toCurrency', true, [
71677
- new DecimalPipe(this._locale)
71740
+ new DecimalPipe(this._locale),
71741
+ this.i18service
71678
71742
  ]),
71679
71743
  this.preparePipeMeta(PrefixPipe, 'prefix', true),
71680
71744
  this.preparePipeMeta(SuffixPipe, 'suffix', true),
@@ -71729,7 +71793,7 @@ class PipeProvider {
71729
71793
  }
71730
71794
  }
71731
71795
  }
71732
- PipeProvider.ɵprov = ɵɵdefineInjectable({ factory: function PipeProvider_Factory() { return new PipeProvider(ɵɵinject(Compiler), ɵɵinject(INJECTOR$1), ɵɵinject(DomSanitizer$1)); }, token: PipeProvider, providedIn: "root" });
71796
+ PipeProvider.ɵprov = ɵɵdefineInjectable({ factory: function PipeProvider_Factory() { return new PipeProvider(ɵɵinject(Compiler), ɵɵinject(INJECTOR$1), ɵɵinject(DomSanitizer$1), ɵɵinject(AbstractI18nService)); }, token: PipeProvider, providedIn: "root" });
71733
71797
  PipeProvider.decorators = [
71734
71798
  { type: Injectable, args: [{
71735
71799
  providedIn: 'root'
@@ -71738,7 +71802,8 @@ PipeProvider.decorators = [
71738
71802
  PipeProvider.ctorParameters = () => [
71739
71803
  { type: Compiler },
71740
71804
  { type: Injector },
71741
- { type: DomSanitizer$1 }
71805
+ { type: DomSanitizer$1 },
71806
+ { type: AbstractI18nService }
71742
71807
  ];
71743
71808
 
71744
71809
  exports.PipeProvider = PipeProvider;