@veloceapps/sdk 7.0.2-17 → 7.0.2-18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. package/cms/cms.actions.d.ts +7 -1
  2. package/cms/components/element-children/element-children.component.d.ts +3 -1
  3. package/cms/components/preview/preview.types.d.ts +4 -0
  4. package/cms/injection-tokens.d.ts +1 -3
  5. package/cms/modules/runtime/services/compilation.service.d.ts +2 -1
  6. package/cms/plugins/script.plugin.d.ts +0 -3
  7. package/cms/types/common.types.d.ts +2 -2
  8. package/cms/utils/elements-resolver.d.ts +5 -1
  9. package/cms/utils/script.utils.d.ts +2 -0
  10. package/cms/vendor-map.d.ts +1 -2
  11. package/core/types/ui-definition.types.d.ts +7 -2
  12. package/esm2020/cms/cms.actions.mjs +11 -2
  13. package/esm2020/cms/cms.elements.mjs +5 -5
  14. package/esm2020/cms/components/element-children/element-children.component.mjs +11 -6
  15. package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +2 -2
  16. package/esm2020/cms/components/preview/preview.types.mjs +1 -1
  17. package/esm2020/cms/injection-tokens.mjs +1 -2
  18. package/esm2020/cms/modules/runtime/services/compilation.service.mjs +3 -3
  19. package/esm2020/cms/modules/runtime/services/runtime.service.mjs +2 -2
  20. package/esm2020/cms/plugins/script.plugin.mjs +6 -40
  21. package/esm2020/cms/services/integration.state.mjs +3 -6
  22. package/esm2020/cms/types/common.types.mjs +1 -1
  23. package/esm2020/cms/utils/elements-resolver.mjs +22 -8
  24. package/esm2020/cms/utils/script.utils.mjs +42 -0
  25. package/esm2020/core/types/ui-definition.types.mjs +1 -1
  26. package/esm2020/src/flow-routing.module.mjs +1 -2
  27. package/fesm2015/veloceapps-sdk-cms.mjs +134 -105
  28. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  29. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  30. package/fesm2015/veloceapps-sdk.mjs +0 -1
  31. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  32. package/fesm2020/veloceapps-sdk-cms.mjs +147 -117
  33. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  34. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  35. package/fesm2020/veloceapps-sdk.mjs +0 -1
  36. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  37. package/package.json +1 -1
@@ -7,7 +7,7 @@ import lodash, { compact, isArray, pull, merge, omit, flatten, set, kebabCase, c
7
7
  import { getCollectionUniqueName, UUID, isDefined, Operator, Predicate, parseJsonSafely, CoreModule } from '@veloceapps/core';
8
8
  import { applyPatch } from 'rfc6902';
9
9
  import * as i2 from '@veloceapps/sdk/core';
10
- import { ConfigurationService, LineItemWorker, generateLineItem, getAttributeValue, QuoteDraftService, FlowConfigurationService, ProductImagesService, ContextService, lineItemUtils, SdkCoreModule, UI_DEFINITION_VERSION } from '@veloceapps/sdk/core';
10
+ import { ConfigurationService, QuoteDraftService, FlowConfigurationService, LineItemWorker, ProductImagesService, ContextService, lineItemUtils, generateLineItem, getAttributeValue, SdkCoreModule, UI_DEFINITION_VERSION } from '@veloceapps/sdk/core';
11
11
  import * as i3 from 'primeng/api';
12
12
  import * as i5 from '@angular/common';
13
13
  import { CommonModule, DOCUMENT } from '@angular/common';
@@ -21,8 +21,8 @@ import { DragDropModule } from '@angular/cdk/drag-drop';
21
21
  import { ScrollingModule } from '@angular/cdk/scrolling';
22
22
  import * as angularForms from '@angular/forms';
23
23
  import { FormsModule, ReactiveFormsModule } from '@angular/forms';
24
- import { transform } from '@babel/standalone';
25
24
  import * as rxjsOperators from 'rxjs/operators';
25
+ import { transform } from '@babel/standalone';
26
26
  import { loadRemoteModule } from '@angular-architects/module-federation';
27
27
 
28
28
  var FlowAction;
@@ -69,16 +69,25 @@ const SwitchObjectAction = (payload) => ({
69
69
  var CmsAction;
70
70
  (function (CmsAction) {
71
71
  CmsAction.GO_TO_PAGE = '[CMS]_GO_TO_PAGE';
72
+ CmsAction.UPDATE_CUSTOMIZATION = '[CMS]_UPDATE_CUSTOMIZATION';
72
73
  /**
73
74
  * Navigate UI definition to a specific page
74
75
  *
75
76
  * @param pageName name of the page
76
- * @returns void
77
77
  */
78
78
  CmsAction.GoToPage = (pageName) => ({
79
79
  type: CmsAction.GO_TO_PAGE,
80
80
  payload: { pageName },
81
81
  });
82
+ /**
83
+ * Update UI definition customization state
84
+ *
85
+ * @param pageName name of the page
86
+ */
87
+ CmsAction.UpdateCustomization = (value) => ({
88
+ type: CmsAction.UPDATE_CUSTOMIZATION,
89
+ payload: { value },
90
+ });
82
91
  })(CmsAction || (CmsAction = {}));
83
92
 
84
93
  var cmsActions = /*#__PURE__*/Object.freeze({
@@ -101,7 +110,6 @@ const UI_DEFINITION_METADATA = new InjectionToken('UI_DEFINITION_METADATA_TOKEN'
101
110
  const ELEMENT_METADATA = new InjectionToken('ELEMENT_METADATA_TOKEN');
102
111
  const SHARED_ELEMENT_METADATA = new InjectionToken('SHARED_ELEMENT_METADATA_TOKEN');
103
112
  const ELEMENT_CONFIG = new InjectionToken('ELEMENT_CONFIG_TOKEN');
104
- const VENDOR_MAP = new InjectionToken('VENDOR_MAP');
105
113
 
106
114
  var cmsInjectionTokens = /*#__PURE__*/Object.freeze({
107
115
  __proto__: null,
@@ -109,8 +117,7 @@ var cmsInjectionTokens = /*#__PURE__*/Object.freeze({
109
117
  ELEMENT_CONFIG: ELEMENT_CONFIG,
110
118
  ELEMENT_METADATA: ELEMENT_METADATA,
111
119
  SHARED_ELEMENT_METADATA: SHARED_ELEMENT_METADATA,
112
- UI_DEFINITION_METADATA: UI_DEFINITION_METADATA,
113
- VENDOR_MAP: VENDOR_MAP
120
+ UI_DEFINITION_METADATA: UI_DEFINITION_METADATA
114
121
  });
115
122
 
116
123
  class Entity {
@@ -307,7 +314,7 @@ class RuntimeService {
307
314
  if (!uiDefinition) {
308
315
  return of([]);
309
316
  }
310
- return this.compilationService.compileUIDefinition$(uiDefinition).pipe(map(result => {
317
+ return this.compilationService.compileUIDefinition$(uiDefinition, config).pipe(map(result => {
311
318
  this.applicationTree = result.elements;
312
319
  this.componentTypes = Object.assign(Object.assign({}, this.componentTypes), result.componentTypes);
313
320
  this.moduleRefs.push(result.moduleRef);
@@ -436,12 +443,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
436
443
  type: Injectable
437
444
  }] });
438
445
 
439
- const InitAction = { type: 'INIT' };
440
- const ClearAction = { type: 'CLEAR' };
441
446
  class IntegrationState {
442
447
  constructor() {
443
448
  this.stateSubj$ = new BehaviorSubject({});
444
- this.action$ = new BehaviorSubject(InitAction);
449
+ this.action$ = new Subject();
445
450
  }
446
451
  get state$() {
447
452
  return this.stateSubj$.asObservable();
@@ -463,7 +468,6 @@ class IntegrationState {
463
468
  }
464
469
  clear() {
465
470
  this.stateSubj$.next({});
466
- this.action$.next(ClearAction);
467
471
  }
468
472
  }
469
473
  IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
@@ -872,13 +876,18 @@ class ElementChildrenComponent {
872
876
  this.destroyed$.next();
873
877
  this.destroyed$.complete();
874
878
  }
879
+ getFilteredChildren(elements) {
880
+ return this.filter ? this.filter(elements) : elements;
881
+ }
875
882
  }
876
883
  ElementChildrenComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ElementChildrenComponent, deps: [{ token: ElementContextService }, { token: RuntimeService }, { token: RuntimeEditorService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
877
- ElementChildrenComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.8", type: ElementChildrenComponent, selector: "element-children", ngImport: i0, template: "<ng-container *ngIf=\"metadata$ | async as metadata\">\n <vl-element-drop-handle *ngIf=\"dragMode$ | async\" [index]=\"0\" [parentPath]=\"metadata.path\"></vl-element-drop-handle>\n <ng-container *ngFor=\"let child of metadata.children; let i = index\">\n <vl-cms-element-renderer [meta]=\"child\"></vl-cms-element-renderer>\n <vl-element-drop-handle\n *ngIf=\"dragMode$ | async\"\n [index]=\"i + 1\"\n [parentPath]=\"metadata.path\"\n ></vl-element-drop-handle>\n </ng-container>\n</ng-container>\n", styles: [":host{display:contents}\n"], dependencies: [{ kind: "directive", type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }, { kind: "component", type: ElementDropHandleComponent, selector: "vl-element-drop-handle", inputs: ["index", "parentPath"] }, { kind: "pipe", type: i5.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
884
+ ElementChildrenComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.8", type: ElementChildrenComponent, selector: "element-children", inputs: { filter: "filter" }, ngImport: i0, template: "<ng-container *ngIf=\"metadata$ | async as metadata\">\n <vl-element-drop-handle *ngIf=\"dragMode$ | async\" [index]=\"0\" [parentPath]=\"metadata.path\"></vl-element-drop-handle>\n <ng-container *ngFor=\"let child of getFilteredChildren(metadata.children); let i = index\">\n <vl-cms-element-renderer [meta]=\"child\"></vl-cms-element-renderer>\n <vl-element-drop-handle\n *ngIf=\"dragMode$ | async\"\n [index]=\"i + 1\"\n [parentPath]=\"metadata.path\"\n ></vl-element-drop-handle>\n </ng-container>\n</ng-container>\n", styles: [":host{display:contents}\n"], dependencies: [{ kind: "directive", type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }, { kind: "component", type: ElementDropHandleComponent, selector: "vl-element-drop-handle", inputs: ["index", "parentPath"] }, { kind: "pipe", type: i5.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
878
885
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ElementChildrenComponent, decorators: [{
879
886
  type: Component,
880
- args: [{ selector: 'element-children', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"metadata$ | async as metadata\">\n <vl-element-drop-handle *ngIf=\"dragMode$ | async\" [index]=\"0\" [parentPath]=\"metadata.path\"></vl-element-drop-handle>\n <ng-container *ngFor=\"let child of metadata.children; let i = index\">\n <vl-cms-element-renderer [meta]=\"child\"></vl-cms-element-renderer>\n <vl-element-drop-handle\n *ngIf=\"dragMode$ | async\"\n [index]=\"i + 1\"\n [parentPath]=\"metadata.path\"\n ></vl-element-drop-handle>\n </ng-container>\n</ng-container>\n", styles: [":host{display:contents}\n"] }]
881
- }], ctorParameters: function () { return [{ type: ElementContextService }, { type: RuntimeService }, { type: RuntimeEditorService }, { type: i0.ChangeDetectorRef }]; } });
887
+ args: [{ selector: 'element-children', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"metadata$ | async as metadata\">\n <vl-element-drop-handle *ngIf=\"dragMode$ | async\" [index]=\"0\" [parentPath]=\"metadata.path\"></vl-element-drop-handle>\n <ng-container *ngFor=\"let child of getFilteredChildren(metadata.children); let i = index\">\n <vl-cms-element-renderer [meta]=\"child\"></vl-cms-element-renderer>\n <vl-element-drop-handle\n *ngIf=\"dragMode$ | async\"\n [index]=\"i + 1\"\n [parentPath]=\"metadata.path\"\n ></vl-element-drop-handle>\n </ng-container>\n</ng-container>\n", styles: [":host{display:contents}\n"] }]
888
+ }], ctorParameters: function () { return [{ type: ElementContextService }, { type: RuntimeService }, { type: RuntimeEditorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { filter: [{
889
+ type: Input
890
+ }] } });
882
891
 
883
892
  class ElementChildrenModule {
884
893
  }
@@ -896,12 +905,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
896
905
 
897
906
  class ElementToolsPanelComponent {
898
907
  constructor() {
899
- var _a;
908
+ var _a, _b;
900
909
  this.metadata = inject(ELEMENT_METADATA);
901
910
  this.config = inject(ELEMENT_CONFIG);
902
911
  this.elementRef = inject(ElementRef);
903
- this.showDeleteButton = !this.config.builder.suppressRemovable;
904
- const hostRect = (_a = this.elementRef.nativeElement.parentElement) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
912
+ this.showDeleteButton = !((_a = this.config.builder) === null || _a === void 0 ? void 0 : _a.suppressRemovable);
913
+ const hostRect = (_b = this.elementRef.nativeElement.parentElement) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
905
914
  if (hostRect) {
906
915
  merge(this.elementRef.nativeElement.style, {
907
916
  width: `${hostRect.width}px`,
@@ -1184,58 +1193,103 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1184
1193
  type: Directive
1185
1194
  }], ctorParameters: function () { return [{ type: ElementComponent }]; } });
1186
1195
 
1196
+ const VELOCE_LIBS = {
1197
+ '@veloceapps/core': {
1198
+ isDefined,
1199
+ Operator,
1200
+ Predicate,
1201
+ parseJsonSafely,
1202
+ },
1203
+ '@veloceapps/components': {
1204
+ ToastService,
1205
+ ToastType,
1206
+ },
1207
+ '@veloceapps/api': {
1208
+ SalesforceApiService,
1209
+ QuoteApiService,
1210
+ DocumentTemplatesApiService,
1211
+ DocumentAttachmentApiService,
1212
+ RampApiService,
1213
+ CatalogApiService,
1214
+ DeltaApiService,
1215
+ PicklistsApiService,
1216
+ PriceApiService,
1217
+ ShoppingCartSettingsApiService,
1218
+ ConfigurationSettingsApiService,
1219
+ GuidedSellingApiService,
1220
+ },
1221
+ '@veloceapps/sdk/core': Object.assign({ ConfigurationService,
1222
+ QuoteDraftService,
1223
+ FlowConfigurationService,
1224
+ LineItemWorker,
1225
+ ProductImagesService,
1226
+ ContextService }, lineItemUtils),
1227
+ '@veloceapps/sdk/cms': Object.assign(Object.assign(Object.assign({}, cmsInjectionTokens), cmsActions), { TemplatesService,
1228
+ IntegrationState,
1229
+ ResourcesService }),
1230
+ };
1231
+ const VELOCE_LIBS_BACKWARDS_COMPATIBLE = Object.entries(VELOCE_LIBS).reduce((trunk, [key, value]) => (Object.assign(Object.assign({}, trunk), { [key.replace('@veloceapps/', '@veloce/')]: value })), {});
1232
+ const vendorMap = Object.assign(Object.assign(Object.assign({}, VELOCE_LIBS), VELOCE_LIBS_BACKWARDS_COMPATIBLE), { '@angular/core': i0, '@angular/forms': angularForms, rxjs: rxjs, 'rxjs/operators': rxjsOperators, lodash: lodash });
1233
+
1234
+ const importRegexp = new RegExp(`import([ \\n\\t]*(?:[^ \\n\\t\\{\\}]+[ \\n\\t]*,?)?(?:[ \\n\\t]*\\{(?:[ \\n\\t]*[^ \\n\\t"'\\{\\}]+[ \\n\\t]*,?)+\\})?[ \\n\\t]*)from[ \\n\\t]*(['"])([^'"\\n]+)(?:['"]);`, 'g');
1235
+ const normalizeImports = (script, elementPath) => {
1236
+ const result = script.replace(importRegexp, (match, g1, g2, src) => {
1237
+ const imports = g1
1238
+ .trim()
1239
+ .slice(1, -1)
1240
+ .split(',')
1241
+ .map(item => item.trim());
1242
+ imports.forEach(item => {
1243
+ var _a;
1244
+ if (!((_a = vendorMap[src]) === null || _a === void 0 ? void 0 : _a[item])) {
1245
+ throw new Error(`Failed to import ${item} from '${src}' in ${elementPath}/script.ts`);
1246
+ }
1247
+ });
1248
+ return `const ${g1} = vendor['${src}'];`;
1249
+ });
1250
+ return result;
1251
+ };
1252
+ const getScriptClass = (metadata) => {
1253
+ var _a;
1254
+ if (!(metadata === null || metadata === void 0 ? void 0 : metadata.script)) {
1255
+ return;
1256
+ }
1257
+ const id = btoa(UUID.UUID());
1258
+ const script = document.createElement('script');
1259
+ script.type = `text/javascript`;
1260
+ let scriptContent = normalizeImports(metadata.script, metadata.path);
1261
+ const classMatch = /export class (\S+)/.exec(scriptContent);
1262
+ const className = classMatch === null || classMatch === void 0 ? void 0 : classMatch[1];
1263
+ if (!classMatch || !className) {
1264
+ console.error("Script doesn't have exported class");
1265
+ return;
1266
+ }
1267
+ scriptContent = scriptContent.replace(classMatch[0], `class ${className}`);
1268
+ script.text = `var ${id} = function(vendor) {${scriptContent}
1269
+ return ${className}; };`;
1270
+ document.body.appendChild(script);
1271
+ const ScriptClass = (_a = window === null || window === void 0 ? void 0 : window[id]) === null || _a === void 0 ? void 0 : _a.call(window, vendorMap);
1272
+ document.body.removeChild(script);
1273
+ return ScriptClass;
1274
+ };
1275
+
1187
1276
  class ScriptPlugin {
1188
1277
  constructor(host) {
1189
1278
  this.host = host;
1190
- this.normalizeImports = (script, elementPath) => {
1191
- const regexp = new RegExp(`import([ \\n\\t]*(?:[^ \\n\\t\\{\\}]+[ \\n\\t]*,?)?(?:[ \\n\\t]*\\{(?:[ \\n\\t]*[^ \\n\\t"'\\{\\}]+[ \\n\\t]*,?)+\\})?[ \\n\\t]*)from[ \\n\\t]*(['"])([^'"\\n]+)(?:['"]);`, 'g');
1192
- const result = script.replace(regexp, (match, g1, g2, src) => {
1193
- const imports = g1
1194
- .trim()
1195
- .slice(1, -1)
1196
- .split(',')
1197
- .map(item => item.trim());
1198
- imports.forEach(item => {
1199
- var _a;
1200
- if (!((_a = this.vendorMap[src]) === null || _a === void 0 ? void 0 : _a[item])) {
1201
- throw new Error(`Failed to import ${item} from '${src}' in ${elementPath}/script.ts`);
1202
- }
1203
- });
1204
- return `const ${g1} = vendor['${src}'];`;
1205
- });
1206
- return result;
1207
- };
1208
- this.document = this.host.injector.get(DOCUMENT);
1209
- this.vendorMap = this.host.injector.get(VENDOR_MAP);
1210
1279
  const elementMetadata = this.host.injector.get(ELEMENT_METADATA);
1211
1280
  const sharedElementMetadata = this.host.injector.get(SHARED_ELEMENT_METADATA);
1212
1281
  this.addScript(sharedElementMetadata);
1213
1282
  this.addScript(elementMetadata);
1214
1283
  }
1215
1284
  addScript(metadata) {
1216
- var _a;
1217
1285
  if (!(metadata === null || metadata === void 0 ? void 0 : metadata.script)) {
1218
1286
  return;
1219
1287
  }
1220
- const id = btoa(UUID.UUID());
1221
- const script = this.document.createElement('script');
1222
- script.type = `text/javascript`;
1223
- let scriptContent = this.normalizeImports(metadata.script, (_a = metadata.path) !== null && _a !== void 0 ? _a : metadata.name);
1224
- const classMatch = /export class (\S+)/.exec(scriptContent);
1225
- const className = classMatch === null || classMatch === void 0 ? void 0 : classMatch[1];
1226
- if (!classMatch || !className) {
1227
- console.error("Script doesn't have exported class");
1228
- return;
1229
- }
1230
- scriptContent = scriptContent.replace(classMatch[0], `class ${className}`);
1231
- script.text = `var ${id} = function(vendor) {${scriptContent}
1232
- return ${className}; };`;
1233
- this.document.body.appendChild(script);
1234
- const ScriptClass = window[id](this.vendorMap);
1288
+ const ScriptClass = getScriptClass(metadata);
1235
1289
  if (ScriptClass instanceof Object) {
1236
- this.host.registerPlugin(new ScriptClass(this.host));
1290
+ const instance = new ScriptClass(this.host);
1291
+ this.host.registerPlugin(instance);
1237
1292
  }
1238
- this.document.body.removeChild(script);
1239
1293
  }
1240
1294
  }
1241
1295
  ScriptPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ScriptPlugin, deps: [{ token: ElementComponent }], target: i0.ɵɵFactoryTarget.Directive });
@@ -1248,29 +1302,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1248
1302
  * ScriptPlugin must always be the last plugin in the list to make sure user code is running after all pre-initializers.
1249
1303
  */
1250
1304
  const CONFIG = {
1305
+ CUSTOMIZATION_PAGE: {
1306
+ component: ElementComponent,
1307
+ plugins: [IOPlugin, ScriptPlugin],
1308
+ },
1251
1309
  CUSTOM: {
1252
1310
  component: ElementComponent,
1253
1311
  plugins: [IOPlugin, ElementHoverPlugin, ScriptPlugin],
1254
- builder: {},
1255
1312
  },
1256
1313
  CONTAINER: {
1257
1314
  component: ElementComponent,
1258
1315
  defaultTemplate: '<element-children></element-children>',
1259
1316
  plugins: [ScriptPlugin],
1260
- builder: {},
1261
1317
  },
1262
1318
  SERVICE: {
1263
1319
  component: ElementComponent,
1264
1320
  plugins: [IOPlugin, ScriptPlugin],
1265
1321
  suppressTemplate: true,
1266
1322
  suppressStyles: true,
1267
- builder: {},
1268
1323
  },
1269
1324
  REFERENCE: {
1270
1325
  component: ElementComponent,
1271
1326
  plugins: [IOPlugin, ScriptPlugin],
1272
1327
  suppressTemplate: true,
1273
- builder: {},
1274
1328
  },
1275
1329
  PAGE: {
1276
1330
  component: ElementComponent,
@@ -1766,47 +1820,11 @@ const LAYOUT = {
1766
1820
  },
1767
1821
  };
1768
1822
 
1769
- const VELOCE_LIBS = {
1770
- '@veloceapps/core': {
1771
- isDefined,
1772
- Operator,
1773
- Predicate,
1774
- parseJsonSafely,
1775
- },
1776
- '@veloceapps/components': {
1777
- ToastService,
1778
- ToastType,
1779
- },
1780
- '@veloceapps/api': {
1781
- SalesforceApiService,
1782
- QuoteApiService,
1783
- DocumentTemplatesApiService,
1784
- DocumentAttachmentApiService,
1785
- RampApiService,
1786
- CatalogApiService,
1787
- DeltaApiService,
1788
- PicklistsApiService,
1789
- PriceApiService,
1790
- ShoppingCartSettingsApiService,
1791
- ConfigurationSettingsApiService,
1792
- GuidedSellingApiService,
1793
- },
1794
- '@veloceapps/sdk/core': Object.assign({ ConfigurationService,
1795
- QuoteDraftService,
1796
- FlowConfigurationService,
1797
- LineItemWorker,
1798
- ProductImagesService,
1799
- ContextService }, lineItemUtils),
1800
- '@veloceapps/sdk/cms': Object.assign(Object.assign(Object.assign({}, cmsInjectionTokens), cmsActions), { TemplatesService,
1801
- IntegrationState,
1802
- ResourcesService }),
1803
- };
1804
- const VELOCE_LIBS_BACKWARDS_COMPATIBLE = Object.entries(VELOCE_LIBS).reduce((trunk, [key, value]) => (Object.assign(Object.assign({}, trunk), { [key.replace('@veloceapps/', '@veloce/')]: value })), {});
1805
- const vendorMap = Object.assign(Object.assign(Object.assign({}, VELOCE_LIBS), VELOCE_LIBS_BACKWARDS_COMPATIBLE), { '@angular/core': i0, '@angular/forms': angularForms, rxjs: rxjs, 'rxjs/operators': rxjsOperators, lodash: lodash });
1806
-
1807
1823
  class ElementsResolver {
1808
- constructor(uiDef, elements, sharedElements = []) {
1824
+ constructor(uiDef, elements, sharedElements = [], config) {
1825
+ var _a;
1809
1826
  this.uiDef = uiDef;
1827
+ this.config = config;
1810
1828
  this.renderableElements = [];
1811
1829
  this.sharedElements = [];
1812
1830
  const transpiledElements = this.transpileScripts(elements);
@@ -1816,6 +1834,7 @@ class ElementsResolver {
1816
1834
  .concat(transpiledSharedElements);
1817
1835
  this.elements = transpiledElements.map(el => this.processElementMetadata(el)).filter(isDefined);
1818
1836
  this.renderableElements = this.getRenderableElements(this.elements);
1837
+ this.uiDefMetadata = Object.assign(Object.assign({}, this.uiDef), { customization: (_a = this.uiDef.customization) !== null && _a !== void 0 ? _a : this.getDefaultCustomizationState() });
1819
1838
  }
1820
1839
  addElement(element) {
1821
1840
  if (element.isShared) {
@@ -1850,9 +1869,12 @@ class ElementsResolver {
1850
1869
  return Boolean(el.isShared) && el.type !== 'REFERENCE';
1851
1870
  }
1852
1871
  getRenderableElements(elements) {
1872
+ var _a;
1853
1873
  const renderable = [];
1854
1874
  for (const el of elements) {
1855
- if (!this.isSharedElement(el)) {
1875
+ // In `customizationMode` render only element with CUSTOMIZATION_PAGE type
1876
+ const typePerMode = Boolean((_a = this.config) === null || _a === void 0 ? void 0 : _a.customizationMode) === (el.type === 'CUSTOMIZATION_PAGE');
1877
+ if (!this.isSharedElement(el) && typePerMode) {
1856
1878
  const children = el.children.filter(child => !this.isSharedElement(child));
1857
1879
  const renderableChildren = this.getRenderableElements(children);
1858
1880
  renderable.push(Object.assign(Object.assign({}, el), { children }), ...renderableChildren);
@@ -1913,7 +1935,7 @@ class ElementsResolver {
1913
1935
  resolveElement(element) {
1914
1936
  var _a;
1915
1937
  const config = CONFIG[element.type];
1916
- const defaultPlugins = (_a = DEFAULT_PLUGINS[this.uiDef.type]) !== null && _a !== void 0 ? _a : [];
1938
+ const defaultPlugins = (_a = DEFAULT_PLUGINS[this.uiDefMetadata.type]) !== null && _a !== void 0 ? _a : [];
1917
1939
  if (!config) {
1918
1940
  console.warn(`Unknown element type "${element.type}"`);
1919
1941
  return;
@@ -1921,11 +1943,10 @@ class ElementsResolver {
1921
1943
  const styles = this.getElementStyles(element);
1922
1944
  const component = Object.assign(Object.assign({ selector: 'vl-element', template: element.template }, (styles ? { styles: [styles] } : {})), { providers: [
1923
1945
  { provide: DEFAULT_PLUGINS_TOKEN, useValue: defaultPlugins },
1924
- { provide: UI_DEFINITION_METADATA, useValue: this.uiDef },
1946
+ { provide: UI_DEFINITION_METADATA, useValue: this.uiDefMetadata },
1925
1947
  { provide: ELEMENT_METADATA, useValue: element },
1926
1948
  { provide: SHARED_ELEMENT_METADATA, useValue: this.getSharedElement(element) },
1927
1949
  { provide: ELEMENT_CONFIG, useValue: config },
1928
- { provide: VENDOR_MAP, useValue: vendorMap },
1929
1950
  ] });
1930
1951
  const cmp = Component(component)(class C extends config.component {
1931
1952
  });
@@ -1956,6 +1977,14 @@ class ElementsResolver {
1956
1977
  result += '}\n';
1957
1978
  return result;
1958
1979
  }
1980
+ getDefaultCustomizationState() {
1981
+ const customizationPage = this.elements.find(el => el.type === 'CUSTOMIZATION_PAGE');
1982
+ if (!(customizationPage === null || customizationPage === void 0 ? void 0 : customizationPage.script)) {
1983
+ return;
1984
+ }
1985
+ const c = getScriptClass(customizationPage);
1986
+ return c && 'default' in c ? c.default : undefined;
1987
+ }
1959
1988
  }
1960
1989
 
1961
1990
  class FederatedHostDirective {
@@ -2063,7 +2092,7 @@ class CompilationService {
2063
2092
  constructor(injector) {
2064
2093
  this.injector = injector;
2065
2094
  }
2066
- compileUIDefinition$(uiDefinition) {
2095
+ compileUIDefinition$(uiDefinition, config) {
2067
2096
  return of([]).pipe(map(() => {
2068
2097
  var _a, _b;
2069
2098
  const { children, pages, components } = uiDefinition, uiDefinitionMeta = __rest(uiDefinition, ["children", "pages", "components"]);
@@ -2072,7 +2101,7 @@ class CompilationService {
2072
2101
  const sharedElements = components !== null && components !== void 0 ? components : [];
2073
2102
  const metadata = elements.map(element => elementToMetadata(element));
2074
2103
  const sharedMetadata = sharedElements.map(element => elementToMetadata(element));
2075
- this.elementsResolver = new ElementsResolver(uiDefinition, metadata, sharedMetadata);
2104
+ this.elementsResolver = new ElementsResolver(uiDefinition, metadata, sharedMetadata, config);
2076
2105
  const componentTypes = this.elementsResolver.getNgComponents();
2077
2106
  const module = this.getModule(componentTypes);
2078
2107
  return {
@@ -2233,5 +2262,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
2233
2262
  * Generated bundle index. Do not edit.
2234
2263
  */
2235
2264
 
2236
- export { ApplyProductConfigurationAction, CloseDocGenAction, CmsAction, ConfigureProductAction, DEFAULT_PLUGINS_TOKEN, ELEMENT_CONFIG, ELEMENT_METADATA, ElementComponent, ElementDefinition, ElementsResolver, FlowAction, IntegrationState, LauncherModule, MigrationsModule, MigrationsService, NavigateBackAction, NavigateToCatalogAction, OpenDocGenAction, PreviewComponent, PreviewModule, RemoteApplyAction, RemoteCancelAction, ResourcesService, RuntimeEditorService, RuntimeModule, SHARED_ELEMENT_METADATA, SwitchObjectAction, TemplatesService, UI_DEFINITION_METADATA, UiBuildError, VENDOR_MAP, doesElementSupportIO, elementToMetadata, extendElementMetadata, extractElementMetadata, findElementByModule, findElementByPath, flattenElements, getAbsolutePath, getElementConfig, insertElement, isSharedElement, isValidScript, metadataToElement, normalizeElementMetadata, parseBoundPath, parsePath, removeElement, stringifyElementMetadata };
2265
+ export { ApplyProductConfigurationAction, CloseDocGenAction, CmsAction, ConfigureProductAction, DEFAULT_PLUGINS_TOKEN, ELEMENT_CONFIG, ELEMENT_METADATA, ElementComponent, ElementDefinition, ElementsResolver, FlowAction, IntegrationState, LauncherModule, MigrationsModule, MigrationsService, NavigateBackAction, NavigateToCatalogAction, OpenDocGenAction, PreviewComponent, PreviewModule, RemoteApplyAction, RemoteCancelAction, ResourcesService, RuntimeEditorService, RuntimeModule, SHARED_ELEMENT_METADATA, SwitchObjectAction, TemplatesService, UI_DEFINITION_METADATA, UiBuildError, doesElementSupportIO, elementToMetadata, extendElementMetadata, extractElementMetadata, findElementByModule, findElementByPath, flattenElements, getAbsolutePath, getElementConfig, insertElement, isSharedElement, isValidScript, metadataToElement, normalizeElementMetadata, parseBoundPath, parsePath, removeElement, stringifyElementMetadata };
2237
2266
  //# sourceMappingURL=veloceapps-sdk-cms.mjs.map