@wavemaker/angular-codegen 11.1.4-rc.5189 → 11.2.0-next.140104

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,6 +37,9 @@
37
37
  "@wm/core": [
38
38
  "node_modules/@wavemaker/app-ng-runtime/core"
39
39
  ],
40
+ "@wm/common/variables": [
41
+ "node_modules/@wavemaker/variables/"
42
+ ],
40
43
  "@wm/components/base": [
41
44
  "node_modules/@wavemaker/app-ng-runtime/components/base"
42
45
  ],
@@ -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)) {
@@ -46603,41 +46638,42 @@ const validateDataSourceCtx = (ds, ctx) => {
46603
46638
  * @param name name of the variable
46604
46639
  * @param context scope of the variable
46605
46640
  */
46606
- const processFilterExpBindNode = (context, filterExpressions) => {
46641
+ const processFilterExpBindNode = (context, filterExpressions, variable) => {
46607
46642
  const destroyFn = context.registerDestroyListener ? context.registerDestroyListener.bind(context) : _.noop;
46608
46643
  const filter$ = new Subject();
46609
46644
  const bindFilExpObj = (obj, targetNodeKey) => {
46645
+ const listener = (newVal, oldVal) => {
46646
+ if ((newVal === oldVal && _.isUndefined(newVal)) || (_.isUndefined(newVal) && !_.isUndefined(oldVal))) {
46647
+ return;
46648
+ }
46649
+ // Skip cloning for blob column
46650
+ if (!_.includes(['blob', 'file'], obj.type)) {
46651
+ newVal = getClonedObject(newVal);
46652
+ }
46653
+ // backward compatibility: where we are allowing the user to bind complete object
46654
+ if (obj.target === 'dataBinding') {
46655
+ // remove the existing databinding element
46656
+ filterExpressions.rules = [];
46657
+ // now add all the returned values
46658
+ _.forEach(newVal, function (value, target) {
46659
+ filterExpressions.rules.push({
46660
+ 'target': target,
46661
+ 'value': value,
46662
+ 'matchMode': obj.matchMode || 'startignorecase',
46663
+ 'required': false,
46664
+ 'type': ''
46665
+ });
46666
+ });
46667
+ }
46668
+ else {
46669
+ // setting value to the root node
46670
+ obj[targetNodeKey] = newVal;
46671
+ }
46672
+ filter$.next({ filterExpressions, newVal });
46673
+ };
46610
46674
  if (stringStartsWith(obj[targetNodeKey], 'bind:')) {
46611
46675
  // [Todo-CSP]: needs a check, where is this used
46612
- destroyFn($watch(obj[targetNodeKey].replace('bind:', ''), context, {}, (newVal, oldVal) => {
46613
- if ((newVal === oldVal && _.isUndefined(newVal)) || (_.isUndefined(newVal) && !_.isUndefined(oldVal))) {
46614
- return;
46615
- }
46616
- // Skip cloning for blob column
46617
- if (!_.includes(['blob', 'file'], obj.type)) {
46618
- newVal = getClonedObject(newVal);
46619
- }
46620
- // backward compatibility: where we are allowing the user to bind complete object
46621
- if (obj.target === 'dataBinding') {
46622
- // remove the existing databinding element
46623
- filterExpressions.rules = [];
46624
- // now add all the returned values
46625
- _.forEach(newVal, function (value, target) {
46626
- filterExpressions.rules.push({
46627
- 'target': target,
46628
- 'value': value,
46629
- 'matchMode': obj.matchMode || 'startignorecase',
46630
- 'required': false,
46631
- 'type': ''
46632
- });
46633
- });
46634
- }
46635
- else {
46636
- // setting value to the root node
46637
- obj[targetNodeKey] = newVal;
46638
- }
46639
- filter$.next({ filterExpressions, newVal });
46640
- }, undefined, false, { arrayType: _.includes(['in', 'notin'], obj.matchMode) }));
46676
+ destroyFn($watch(obj[targetNodeKey].replace('bind:', ''), context, {}, variable ? variable.invokeOnFiltertExpressionChange.bind(variable, obj, targetNodeKey) : listener, undefined, false, { arrayType: _.includes(['in', 'notin'], obj.matchMode) }));
46641
46677
  }
46642
46678
  };
46643
46679
  const traverseFilterExpressions = expressions => {
@@ -46919,6 +46955,9 @@ const findRootContainer = ($el) => {
46919
46955
  if (!root.length) {
46920
46956
  root = $el.closest('.app-partial');
46921
46957
  }
46958
+ if (!root.length) {
46959
+ root = $el.closest('.app-spa-page');
46960
+ }
46922
46961
  if (!root.length) {
46923
46962
  root = $el.closest('.app-page');
46924
46963
  }
@@ -47032,6 +47071,7 @@ var Utils = /*#__PURE__*/Object.freeze({
47032
47071
  getResourceURL: getResourceURL,
47033
47072
  triggerFn: triggerFn,
47034
47073
  getFormattedDate: getFormattedDate,
47074
+ hasOffsetStr: hasOffsetStr,
47035
47075
  getDateObj: getDateObj,
47036
47076
  addEventListenerOnElement: addEventListenerOnElement,
47037
47077
  getClonedObject: getClonedObject,
@@ -47055,6 +47095,7 @@ var Utils = /*#__PURE__*/Object.freeze({
47055
47095
  isEqualWithFields: isEqualWithFields,
47056
47096
  loadStyleSheet: loadStyleSheet,
47057
47097
  loadStyleSheets: loadStyleSheets,
47098
+ getMomentLocaleObject: getMomentLocaleObject,
47058
47099
  loadScript: loadScript,
47059
47100
  loadScripts: loadScripts,
47060
47101
  _WM_APP_PROJECT: _WM_APP_PROJECT,
@@ -69437,10 +69478,11 @@ const getEpochValue = data => {
69437
69478
  return epoch;
69438
69479
  };
69439
69480
  class ToDatePipe {
69440
- constructor(datePipe) {
69481
+ constructor(datePipe, i18nService) {
69441
69482
  this.datePipe = datePipe;
69483
+ this.i18nService = i18nService;
69442
69484
  }
69443
- transform(data, format) {
69485
+ transform(data, format, timezone, compInstance) {
69444
69486
  let timestamp;
69445
69487
  // '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
69488
  if (data === 'null' || data === '') {
@@ -69454,7 +69496,18 @@ class ToDatePipe {
69454
69496
  if (format === 'timestamp') {
69455
69497
  return timestamp;
69456
69498
  }
69457
- return this.datePipe.transform(timestamp, format);
69499
+ if (format === 'UTC') {
69500
+ return new Date(timestamp).toISOString();
69501
+ }
69502
+ let formattedVal;
69503
+ const timeZone = this.i18nService ? this.i18nService.getTimezone(compInstance) : timezone;
69504
+ if (timeZone && (data === timestamp || hasOffsetStr(data))) {
69505
+ formattedVal = moment(timestamp).tz(timeZone).format(format.replaceAll('y', 'Y').replaceAll('d', 'D').replace('a', 'A'));
69506
+ }
69507
+ else {
69508
+ formattedVal = this.datePipe.transform(timestamp, format);
69509
+ }
69510
+ return formattedVal;
69458
69511
  }
69459
69512
  return '';
69460
69513
  }
@@ -69465,18 +69518,22 @@ ToDatePipe.decorators = [
69465
69518
  },] }
69466
69519
  ];
69467
69520
  ToDatePipe.ctorParameters = () => [
69468
- { type: DatePipe$1 }
69521
+ { type: DatePipe$1 },
69522
+ { type: AbstractI18nService }
69469
69523
  ];
69470
69524
  class ToNumberPipe {
69471
- constructor(decimalPipe) {
69525
+ constructor(decimalPipe, i18Service) {
69472
69526
  this.decimalPipe = decimalPipe;
69527
+ this.i18Service = i18Service;
69473
69528
  }
69474
69529
  transform(data, fracSize) {
69475
69530
  if (fracSize && !String(fracSize).match(/^(\d+)?\.((\d+)(-(\d+))?)?$/)) {
69476
69531
  fracSize = '1.' + fracSize + '-' + fracSize;
69477
69532
  }
69478
69533
  if (!_.isNaN(+data)) {
69479
- return this.decimalPipe.transform(data, fracSize);
69534
+ const locale = this.i18Service.getwidgetLocale() ? this.i18Service.getwidgetLocale() : undefined;
69535
+ const formattedLocale = locale ? locale['number'] : undefined;
69536
+ return this.decimalPipe.transform(data, fracSize, formattedLocale);
69480
69537
  }
69481
69538
  }
69482
69539
  }
@@ -69486,15 +69543,17 @@ ToNumberPipe.decorators = [
69486
69543
  },] }
69487
69544
  ];
69488
69545
  ToNumberPipe.ctorParameters = () => [
69489
- { type: DecimalPipe$1 }
69546
+ { type: DecimalPipe$1 },
69547
+ { type: AbstractI18nService, decorators: [{ type: Inject$1, args: [AbstractI18nService,] }] }
69490
69548
  ];
69491
69549
  class ToCurrencyPipe {
69492
- constructor(decimalPipe) {
69550
+ constructor(decimalPipe, i18Service) {
69493
69551
  this.decimalPipe = decimalPipe;
69552
+ this.i18Service = i18Service;
69494
69553
  }
69495
69554
  transform(data, currencySymbol, fracSize) {
69496
69555
  const _currencySymbol = (CURRENCY_INFO[currencySymbol] || {}).symbol || currencySymbol || '';
69497
- let _val = new ToNumberPipe(this.decimalPipe).transform(data, fracSize);
69556
+ let _val = new ToNumberPipe(this.decimalPipe, this.i18Service).transform(data, fracSize);
69498
69557
  const isNegativeNumber = _.startsWith(_val, '-');
69499
69558
  if (isNegativeNumber) {
69500
69559
  _val = _val.replace('-', '');
@@ -69508,7 +69567,8 @@ ToCurrencyPipe.decorators = [
69508
69567
  },] }
69509
69568
  ];
69510
69569
  ToCurrencyPipe.ctorParameters = () => [
69511
- { type: DecimalPipe$1 }
69570
+ { type: DecimalPipe$1 },
69571
+ { type: AbstractI18nService, decorators: [{ type: Inject$1, args: [AbstractI18nService,] }] }
69512
69572
  ];
69513
69573
  class PrefixPipe {
69514
69574
  transform(data, padding) {
@@ -71632,11 +71692,14 @@ Title$1.ctorParameters = () => [
71632
71692
  const VERSION$4 = new Version('12.2.16');
71633
71693
 
71634
71694
  class PipeProvider {
71635
- constructor(compiler, injector, domSanitizer) {
71695
+ constructor(compiler, injector, domSanitizer, i18service) {
71696
+ var _a;
71636
71697
  this.compiler = compiler;
71637
71698
  this.injector = injector;
71638
71699
  this.domSanitizer = domSanitizer;
71700
+ this.i18service = i18service;
71639
71701
  this._locale = getSessionStorageItem('selectedLocale') || 'en';
71702
+ this.formatsByLocale = (_a = this.i18service) === null || _a === void 0 ? void 0 : _a.getwidgetLocale();
71640
71703
  this.preparePipeMeta = (reference, name, pure, diDeps = []) => ({
71641
71704
  type: { reference, diDeps },
71642
71705
  name,
@@ -71671,10 +71734,12 @@ class PipeProvider {
71671
71734
  new DatePipe(this._locale)
71672
71735
  ]),
71673
71736
  this.preparePipeMeta(ToNumberPipe, 'toNumber', true, [
71674
- new DecimalPipe(this._locale)
71737
+ new DecimalPipe(this._locale),
71738
+ this.i18service
71675
71739
  ]),
71676
71740
  this.preparePipeMeta(ToCurrencyPipe, 'toCurrency', true, [
71677
- new DecimalPipe(this._locale)
71741
+ new DecimalPipe(this._locale),
71742
+ this.i18service
71678
71743
  ]),
71679
71744
  this.preparePipeMeta(PrefixPipe, 'prefix', true),
71680
71745
  this.preparePipeMeta(SuffixPipe, 'suffix', true),
@@ -71729,7 +71794,7 @@ class PipeProvider {
71729
71794
  }
71730
71795
  }
71731
71796
  }
71732
- PipeProvider.ɵprov = ɵɵdefineInjectable({ factory: function PipeProvider_Factory() { return new PipeProvider(ɵɵinject(Compiler), ɵɵinject(INJECTOR$1), ɵɵinject(DomSanitizer$1)); }, token: PipeProvider, providedIn: "root" });
71797
+ 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
71798
  PipeProvider.decorators = [
71734
71799
  { type: Injectable, args: [{
71735
71800
  providedIn: 'root'
@@ -71738,7 +71803,8 @@ PipeProvider.decorators = [
71738
71803
  PipeProvider.ctorParameters = () => [
71739
71804
  { type: Compiler },
71740
71805
  { type: Injector },
71741
- { type: DomSanitizer$1 }
71806
+ { type: DomSanitizer$1 },
71807
+ { type: AbstractI18nService }
71742
71808
  ];
71743
71809
 
71744
71810
  exports.PipeProvider = PipeProvider;