@veloceapps/sdk 7.0.2-38 → 7.0.2-39

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. package/core/core.module.d.ts +2 -0
  2. package/core/directives/directives.module.d.ts +7 -0
  3. package/core/directives/index.d.ts +2 -0
  4. package/core/directives/primeng-calendar.directive.d.ts +14 -0
  5. package/core/index.d.ts +2 -0
  6. package/core/pipes/date.pipe.d.ts +12 -0
  7. package/core/pipes/index.d.ts +4 -0
  8. package/core/pipes/number.pipe.d.ts +10 -0
  9. package/core/pipes/pipes.module.d.ts +9 -0
  10. package/core/pipes/price.pipe.d.ts +10 -0
  11. package/core/services/runtime-settings.service.d.ts +3 -0
  12. package/core/types/formatting-settings.types.d.ts +11 -0
  13. package/core/types/index.d.ts +1 -0
  14. package/esm2020/cms/modules/runtime/services/compilation.service.mjs +3 -1
  15. package/esm2020/core/core.module.mjs +18 -1
  16. package/esm2020/core/directives/directives.module.mjs +16 -0
  17. package/esm2020/core/directives/index.mjs +3 -0
  18. package/esm2020/core/directives/primeng-calendar.directive.mjs +41 -0
  19. package/esm2020/core/index.mjs +3 -1
  20. package/esm2020/core/modules/configuration/configuration.module.mjs +2 -2
  21. package/esm2020/core/pipes/date.pipe.mjs +38 -0
  22. package/esm2020/core/pipes/index.mjs +5 -0
  23. package/esm2020/core/pipes/number.pipe.mjs +27 -0
  24. package/esm2020/core/pipes/pipes.module.mjs +18 -0
  25. package/esm2020/core/pipes/price.pipe.mjs +30 -0
  26. package/esm2020/core/services/runtime-settings.service.mjs +31 -5
  27. package/esm2020/core/types/formatting-settings.types.mjs +3 -0
  28. package/esm2020/core/types/index.mjs +2 -1
  29. package/esm2020/src/components/header/header.component.mjs +10 -17
  30. package/esm2020/src/components/header/header.module.mjs +7 -3
  31. package/esm2020/src/components/header/metrics/metrics.component.mjs +3 -3
  32. package/esm2020/src/components/header/metrics/metrics.module.mjs +7 -3
  33. package/fesm2015/veloceapps-sdk-cms.mjs +2 -1
  34. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  35. package/fesm2015/veloceapps-sdk-core.mjs +199 -6
  36. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  37. package/fesm2015/veloceapps-sdk.mjs +26 -28
  38. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  39. package/fesm2020/veloceapps-sdk-cms.mjs +2 -1
  40. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  41. package/fesm2020/veloceapps-sdk-core.mjs +191 -6
  42. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  43. package/fesm2020/veloceapps-sdk.mjs +26 -27
  44. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  45. package/package.json +1 -1
  46. package/src/components/header/header.component.d.ts +2 -3
  47. package/src/components/header/header.module.d.ts +2 -1
  48. package/src/components/header/metrics/metrics.module.d.ts +2 -1
@@ -1,6 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, NgModule } from '@angular/core';
3
- import { UUID, ConfigurationContext, RuntimeModel, ConfigurationContextMode, SalesforceIdUtils, ConfigurationMode, ConfigurationTranslatorUtils, ChargeGroupUtils, parseJsonSafely } from '@veloceapps/core';
2
+ import { Injectable, InjectionToken, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
3
+ import { UUID, ConfigurationContext, RuntimeModel, ConfigurationContextMode, SalesforceIdUtils, ConfigurationMode, ConfigurationTranslatorUtils, ChargeGroupUtils, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, getSupportedDateFormats, DEFAULT_DECIMALS_COUNT, parseJsonSafely, formatNumber } from '@veloceapps/core';
4
4
  import * as i1 from '@veloceapps/api';
5
5
  import { PriceApiService, ContextApiService, ProductModelApiService, ConfigurationApiService } from '@veloceapps/api';
6
6
  import { BehaviorSubject, combineLatest, zip, noop, throwError, shareReplay as shareReplay$1, tap as tap$1, map as map$2, of, switchMap as switchMap$1, catchError as catchError$1, Subject, take as take$1, distinctUntilChanged } from 'rxjs';
@@ -10,6 +10,9 @@ import { ToastType, ConfirmationComponent, ConfirmationDialogModule } from '@vel
10
10
  import * as i5 from 'primeng/api';
11
11
  import * as i6 from 'primeng/dynamicdialog';
12
12
  import moment from 'moment';
13
+ import { NgControl } from '@angular/forms';
14
+ import 'primeng/calendar';
15
+ import { DATE_PIPE_DEFAULT_OPTIONS, formatDate } from '@angular/common';
13
16
 
14
17
  const getDefaultLineItem = (context, uiDefinitionProperties, qty = 1) => {
15
18
  const id = UUID.UUID();
@@ -81,6 +84,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
81
84
  args: [{ providedIn: 'root' }]
82
85
  }], ctorParameters: function () { return [{ type: i1.ContextApiService }]; } });
83
86
 
87
+ const FORMATTING_SETTINGS_TOKEN = new InjectionToken('Summary of formatting settings for variant types of data, e.g. numbers, text, dates, etc');
88
+
84
89
  var RuntimeMode;
85
90
  (function (RuntimeMode) {
86
91
  RuntimeMode[RuntimeMode["TEST"] = 0] = "TEST";
@@ -1293,8 +1298,8 @@ class RuntimeSettingsService {
1293
1298
  this.configurationSettingsApiService = configurationSettingsApiService;
1294
1299
  this.configurationSettings$ = new BehaviorSubject({});
1295
1300
  this.currencySettings$ = new BehaviorSubject({
1296
- iso: 'USD',
1297
- symbol: '$',
1301
+ iso: DEFAULT_CURRENCY_ISO_CODE,
1302
+ symbol: DEFAULT_CURRENCY_SYMBOL,
1298
1303
  });
1299
1304
  this.getCurrencySymbol = (locale, currency) => {
1300
1305
  return (0)
@@ -1304,7 +1309,10 @@ class RuntimeSettingsService {
1304
1309
  };
1305
1310
  }
1306
1311
  create() {
1307
- return this.configurationSettingsApiService.fetchSettings().pipe(map$2(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => this.configurationSettings$.next(configurationSettings)), map$2(() => undefined));
1312
+ return this.configurationSettingsApiService.fetchSettings().pipe(map$2(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
1313
+ this.configurationSettings$.next(configurationSettings);
1314
+ this.formattingSettings = this.getFormattingSettings();
1315
+ }), map$2(() => undefined));
1308
1316
  }
1309
1317
  initCurrency(iso) {
1310
1318
  if (iso) {
@@ -1312,6 +1320,29 @@ class RuntimeSettingsService {
1312
1320
  this.currencySettings$.next({ iso, symbol });
1313
1321
  }
1314
1322
  }
1323
+ getFormattingSettings() {
1324
+ if (this.formattingSettings) {
1325
+ return this.formattingSettings;
1326
+ }
1327
+ const shoppingCartSettings = this.getConfigurationSettings()['shopping-cart']?.reduce((acc, setting) => {
1328
+ return { ...acc, [setting.id]: setting.properties };
1329
+ }, {});
1330
+ const currencySettings = this.getCurrencySettings();
1331
+ const dateFormat = (validateDateFormat(shoppingCartSettings?.DATE_FORMAT ?? '') && shoppingCartSettings?.DATE_FORMAT) ||
1332
+ DEFAULT_DATE_FORMAT;
1333
+ const decimalSeparator = shoppingCartSettings?.DECIMAL_SEPARATOR ?? DEFAULT_DECIMAL_SEPARATOR;
1334
+ const thousandsSeparator = shoppingCartSettings?.THOUSANDS_SEPARATOR ?? DEFAULT_THOUSANDS_SEPARATOR;
1335
+ return {
1336
+ currencySymbol: currencySettings.symbol,
1337
+ dateFormats: getSupportedDateFormats(dateFormat),
1338
+ decimalSeparator: (['.', ','].includes(decimalSeparator) && decimalSeparator) || DEFAULT_DECIMAL_SEPARATOR,
1339
+ decimalsCount: (!isNaN(Number(shoppingCartSettings?.PRICE_SCALE)) && Number(shoppingCartSettings?.PRICE_SCALE)) ||
1340
+ DEFAULT_DECIMALS_COUNT,
1341
+ thousandsSeparator: ['.', ',', ''].includes(thousandsSeparator)
1342
+ ? thousandsSeparator
1343
+ : DEFAULT_THOUSANDS_SEPARATOR,
1344
+ };
1345
+ }
1315
1346
  getConfigurationSettings() {
1316
1347
  return this.configurationSettings$.value;
1317
1348
  }
@@ -1344,6 +1375,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1344
1375
  args: [{ providedIn: 'root' }]
1345
1376
  }], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
1346
1377
 
1378
+ const DEFAULT_FORMATTING_SETTINGS = {
1379
+ currencySymbol: DEFAULT_CURRENCY_SYMBOL,
1380
+ decimalsCount: DEFAULT_DECIMALS_COUNT,
1381
+ dateFormats: getSupportedDateFormats(DEFAULT_DATE_FORMAT),
1382
+ decimalSeparator: DEFAULT_DECIMAL_SEPARATOR,
1383
+ thousandsSeparator: DEFAULT_THOUSANDS_SEPARATOR,
1384
+ };
1347
1385
  class SdkCoreModule {
1348
1386
  }
1349
1387
  SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -1354,6 +1392,10 @@ SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version:
1354
1392
  ProductImagesService,
1355
1393
  MetricsCalculationService,
1356
1394
  RuntimeSettingsService,
1395
+ {
1396
+ provide: FORMATTING_SETTINGS_TOKEN,
1397
+ useExisting: RuntimeSettingsService,
1398
+ },
1357
1399
  ], imports: [ConfigurationModule, FlowConfigurationModule] });
1358
1400
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, decorators: [{
1359
1401
  type: NgModule,
@@ -1365,13 +1407,156 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1365
1407
  ProductImagesService,
1366
1408
  MetricsCalculationService,
1367
1409
  RuntimeSettingsService,
1410
+ {
1411
+ provide: FORMATTING_SETTINGS_TOKEN,
1412
+ useExisting: RuntimeSettingsService,
1413
+ },
1368
1414
  ],
1369
1415
  }]
1370
1416
  }] });
1371
1417
 
1418
+ class CalendarDirective {
1419
+ constructor() {
1420
+ this.ngControl = inject(NgControl, { host: true, optional: true });
1421
+ this.formattingSettings = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })?.getFormattingSettings();
1422
+ this.destroy$ = new Subject();
1423
+ }
1424
+ set vlCalendar(calendar) {
1425
+ this.calendar = calendar;
1426
+ }
1427
+ ngOnDestroy() {
1428
+ this.destroy$.next();
1429
+ this.destroy$.complete();
1430
+ }
1431
+ ngOnInit() {
1432
+ if (this.calendar) {
1433
+ this.calendar.dateFormat = this.formattingSettings?.dateFormats.primengFormat ?? DEFAULT_DATE_FORMAT;
1434
+ if (this.ngControl && this.ngControl.control) {
1435
+ const control = this.ngControl.control;
1436
+ control.setValue(control.value, { emitEvent: false });
1437
+ }
1438
+ }
1439
+ }
1440
+ }
1441
+ CalendarDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: CalendarDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1442
+ CalendarDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.8", type: CalendarDirective, selector: "[vlCalendar]", inputs: { vlCalendar: "vlCalendar" }, ngImport: i0 });
1443
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: CalendarDirective, decorators: [{
1444
+ type: Directive,
1445
+ args: [{
1446
+ selector: '[vlCalendar]',
1447
+ }]
1448
+ }], propDecorators: { vlCalendar: [{
1449
+ type: Input
1450
+ }] } });
1451
+
1452
+ class SdkDirectivesModule {
1453
+ }
1454
+ SdkDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1455
+ SdkDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule, declarations: [CalendarDirective], exports: [CalendarDirective] });
1456
+ SdkDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule });
1457
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule, decorators: [{
1458
+ type: NgModule,
1459
+ args: [{
1460
+ declarations: [CalendarDirective],
1461
+ exports: [CalendarDirective],
1462
+ }]
1463
+ }] });
1464
+
1465
+ class DatePipe {
1466
+ constructor() {
1467
+ this.locale = inject(LOCALE_ID);
1468
+ this.defaultOptions = inject(DATE_PIPE_DEFAULT_OPTIONS, { optional: true });
1469
+ this.formattingSettings = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })?.getFormattingSettings();
1470
+ this.destroy$ = new Subject();
1471
+ }
1472
+ ngOnDestroy() {
1473
+ this.destroy$.next();
1474
+ this.destroy$.complete();
1475
+ }
1476
+ transform(date) {
1477
+ if (!date) {
1478
+ return '';
1479
+ }
1480
+ try {
1481
+ return formatDate(date, this.formattingSettings?.dateFormats.datePipeFormat || DEFAULT_DATE_FORMAT, this.locale, this.defaultOptions?.timezone);
1482
+ }
1483
+ catch (error) {
1484
+ return new Date(date).toString();
1485
+ }
1486
+ }
1487
+ }
1488
+ DatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1489
+ DatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: DatePipe, name: "vlDate" });
1490
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DatePipe, decorators: [{
1491
+ type: Pipe,
1492
+ args: [{
1493
+ name: 'vlDate',
1494
+ }]
1495
+ }] });
1496
+
1497
+ class NumberPipe {
1498
+ constructor() {
1499
+ this.formattingSettings = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })?.getFormattingSettings();
1500
+ this.destroy$ = new Subject();
1501
+ }
1502
+ ngOnDestroy() {
1503
+ this.destroy$.next();
1504
+ this.destroy$.complete();
1505
+ }
1506
+ transform(price) {
1507
+ return formatNumber(price, this.formattingSettings?.thousandsSeparator, this.formattingSettings?.decimalSeparator, this.formattingSettings?.decimalsCount);
1508
+ }
1509
+ }
1510
+ NumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1511
+ NumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: NumberPipe, name: "vlNumber" });
1512
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NumberPipe, decorators: [{
1513
+ type: Pipe,
1514
+ args: [{
1515
+ name: 'vlNumber',
1516
+ }]
1517
+ }] });
1518
+
1519
+ class PricePipe {
1520
+ constructor() {
1521
+ this.formattingSettings = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })?.getFormattingSettings();
1522
+ this.destroy$ = new Subject();
1523
+ }
1524
+ ngOnDestroy() {
1525
+ this.destroy$.next();
1526
+ this.destroy$.complete();
1527
+ }
1528
+ transform(price) {
1529
+ if (price == null || price === '') {
1530
+ return '';
1531
+ }
1532
+ return `${this.formattingSettings?.currencySymbol || DEFAULT_CURRENCY_SYMBOL}${formatNumber(price, this.formattingSettings?.thousandsSeparator, this.formattingSettings?.decimalSeparator, this.formattingSettings?.decimalsCount)}`;
1533
+ }
1534
+ }
1535
+ PricePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PricePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1536
+ PricePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: PricePipe, name: "vlPrice" });
1537
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PricePipe, decorators: [{
1538
+ type: Pipe,
1539
+ args: [{
1540
+ name: 'vlPrice',
1541
+ }]
1542
+ }] });
1543
+
1544
+ class SdkPipesModule {
1545
+ }
1546
+ SdkPipesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1547
+ SdkPipesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule, declarations: [NumberPipe, PricePipe, DatePipe], exports: [NumberPipe, PricePipe, DatePipe] });
1548
+ SdkPipesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule });
1549
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule, decorators: [{
1550
+ type: NgModule,
1551
+ args: [{
1552
+ declarations: [NumberPipe, PricePipe, DatePipe],
1553
+ exports: [NumberPipe, PricePipe, DatePipe],
1554
+ }]
1555
+ }] });
1556
+
1372
1557
  /**
1373
1558
  * Generated bundle index. Do not edit.
1374
1559
  */
1375
1560
 
1376
- export { ConfigurationRuntimeService, ConfigurationService, ContextService, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, MetricsCalculationService, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
1561
+ export { CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, MetricsCalculationService, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
1377
1562
  //# sourceMappingURL=veloceapps-sdk-core.mjs.map