@veloceapps/sdk 7.0.2-20 → 7.0.2-22

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.
@@ -2,7 +2,7 @@ import { __decorate, __param, __metadata, __rest } from 'tslib';
2
2
  import * as i0 from '@angular/core';
3
3
  import { InjectionToken, Component, ChangeDetectionStrategy, Inject, Injector, Injectable, ViewContainerRef, SkipSelf, ViewChild, Input, ViewEncapsulation, NgModule, inject, ElementRef, Directive, ApplicationRef, createComponent, createNgModule } from '@angular/core';
4
4
  import * as rxjs from 'rxjs';
5
- import { BehaviorSubject, Subject, of, map, tap, switchMap, startWith, distinctUntilChanged, filter, ReplaySubject, noop, take, Observable, takeUntil, forkJoin, catchError, combineLatest } from 'rxjs';
5
+ import { BehaviorSubject, Subject, filter, map, distinctUntilChanged, of, tap, switchMap, startWith, ReplaySubject, noop, take, Observable, takeUntil, forkJoin, catchError, combineLatest } from 'rxjs';
6
6
  import lodash, { compact, isArray, pull, merge, omit, flatten, set, kebabCase, cloneDeep } from 'lodash';
7
7
  import { getCollectionUniqueName, UUID, isDefined, Operator, Predicate, parseJsonSafely, CoreModule } from '@veloceapps/core';
8
8
  import { applyPatch } from 'rfc6902';
@@ -70,6 +70,9 @@ var CmsAction;
70
70
  (function (CmsAction) {
71
71
  CmsAction.GO_TO_PAGE = '[CMS]_GO_TO_PAGE';
72
72
  CmsAction.UPDATE_CUSTOMIZATION = '[CMS]_UPDATE_CUSTOMIZATION';
73
+ CmsAction.SHOW_OVERLAY = '[CMS]_SHOW_OVERLAY';
74
+ CmsAction.HIDE_OVERLAY = '[CMS]_HIDE_OVERLAY';
75
+ CmsAction.HIDE_ALL_OVERLAYS = '[CMS]_HIDE_ALL_OVERLAYS';
73
76
  /**
74
77
  * Navigate UI definition to a specific page
75
78
  *
@@ -88,6 +91,34 @@ var CmsAction;
88
91
  type: CmsAction.UPDATE_CUSTOMIZATION,
89
92
  payload: { value },
90
93
  });
94
+ /**
95
+ * Show an Overlay on the selected page
96
+ *
97
+ * @param name - name of the overlay
98
+ * @returns void
99
+ */
100
+ CmsAction.ShowOverlay = (name) => ({
101
+ type: CmsAction.SHOW_OVERLAY,
102
+ payload: { name },
103
+ });
104
+ /**
105
+ * Hide an Overlay on the selected page
106
+ *
107
+ * @param name - name of the overlay
108
+ * @returns void
109
+ */
110
+ CmsAction.HideOverlay = (name) => ({
111
+ type: CmsAction.HIDE_OVERLAY,
112
+ payload: { name },
113
+ });
114
+ /**
115
+ * Hide all Overlays on the selected page
116
+ *
117
+ * @returns void
118
+ */
119
+ CmsAction.HideAllOverlays = () => ({
120
+ type: CmsAction.HIDE_ALL_OVERLAYS,
121
+ });
91
122
  })(CmsAction || (CmsAction = {}));
92
123
 
93
124
  var cmsActions = /*#__PURE__*/Object.freeze({
@@ -299,15 +330,73 @@ const getAbsolutePath = (elements, subject, path) => {
299
330
 
300
331
  const CMS_COMPILATION_SERVICE = new InjectionToken('VENDOR_MAP');
301
332
 
333
+ class IntegrationState {
334
+ constructor() {
335
+ this.stateSubj$ = new BehaviorSubject({});
336
+ this.action$ = new Subject();
337
+ }
338
+ get state$() {
339
+ return this.stateSubj$.asObservable();
340
+ }
341
+ get state() {
342
+ return this.stateSubj$.getValue();
343
+ }
344
+ patchState(update) {
345
+ this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.getValue()), update));
346
+ }
347
+ dispatch(action) {
348
+ this.action$.next(action);
349
+ }
350
+ listen$(actionType) {
351
+ return this.action$.pipe(filter(action => action.type === actionType), map(action => action.payload));
352
+ }
353
+ listenAll$() {
354
+ return this.action$.asObservable();
355
+ }
356
+ clear() {
357
+ this.stateSubj$.next({});
358
+ }
359
+ }
360
+ IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
361
+ IntegrationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: IntegrationState, providedIn: 'root' });
362
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: IntegrationState, decorators: [{
363
+ type: Injectable,
364
+ args: [{ providedIn: 'root' }]
365
+ }] });
366
+
302
367
  class RuntimeService {
303
- constructor(injector) {
368
+ constructor(injector, integrationState) {
304
369
  this.injector = injector;
370
+ this.integrationState = integrationState;
305
371
  this.moduleRefs = [];
306
372
  this.componentTypes = {};
307
373
  this.applicationTree = [];
308
374
  this.isInitialized$ = new BehaviorSubject(false);
309
375
  this.updated$ = new Subject();
376
+ this.selectedPageName$ = new BehaviorSubject(null);
377
+ this.selectedOverlayNames$ = new BehaviorSubject([]);
310
378
  this.compilationService = this.injector.get(CMS_COMPILATION_SERVICE);
379
+ this.integrationState
380
+ .listen$(CmsAction.GO_TO_PAGE)
381
+ .pipe(map(({ pageName }) => pageName), distinctUntilChanged())
382
+ .subscribe(pageName => this.selectedPageName$.next(pageName));
383
+ this.integrationState
384
+ .listen$(CmsAction.SHOW_OVERLAY)
385
+ .pipe(map(({ name }) => name))
386
+ .subscribe(overlayName => {
387
+ const overlayNames = this.selectedOverlayNames$.value;
388
+ if (!overlayNames.includes(overlayName)) {
389
+ this.selectedOverlayNames$.next([...overlayNames, overlayName]);
390
+ }
391
+ });
392
+ this.integrationState
393
+ .listen$(CmsAction.HIDE_OVERLAY)
394
+ .pipe(map(({ name }) => name))
395
+ .subscribe(overlayName => {
396
+ const overlayNames = this.selectedOverlayNames$.value;
397
+ this.selectedOverlayNames$.next(overlayNames.filter(name => name !== overlayName));
398
+ });
399
+ this.integrationState.listen$(CmsAction.HIDE_ALL_OVERLAYS).subscribe(() => this.selectedOverlayNames$.next([]));
311
400
  }
312
401
  initialize$(uiDefinition, config) {
313
402
  this.config = config;
@@ -361,11 +450,11 @@ class RuntimeService {
361
450
  applyPatch(this.applicationTree, [operation]);
362
451
  }
363
452
  }
364
- RuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
453
+ RuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeService, deps: [{ token: i0.Injector }, { token: IntegrationState }], target: i0.ɵɵFactoryTarget.Injectable });
365
454
  RuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeService });
366
455
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeService, decorators: [{
367
456
  type: Injectable
368
- }], ctorParameters: function () { return [{ type: i0.Injector }]; } });
457
+ }], ctorParameters: function () { return [{ type: i0.Injector }, { type: IntegrationState }]; } });
369
458
 
370
459
  class IOProviderService {
371
460
  constructor(runtimeService) {
@@ -443,40 +532,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
443
532
  type: Injectable
444
533
  }] });
445
534
 
446
- class IntegrationState {
447
- constructor() {
448
- this.stateSubj$ = new BehaviorSubject({});
449
- this.action$ = new Subject();
450
- }
451
- get state$() {
452
- return this.stateSubj$.asObservable();
453
- }
454
- get state() {
455
- return this.stateSubj$.getValue();
456
- }
457
- patchState(update) {
458
- this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.getValue()), update));
459
- }
460
- dispatch(action) {
461
- this.action$.next(action);
462
- }
463
- listen$(actionType) {
464
- return this.action$.pipe(filter(action => action.type === actionType), map(action => action.payload));
465
- }
466
- listenAll$() {
467
- return this.action$.asObservable();
468
- }
469
- clear() {
470
- this.stateSubj$.next({});
471
- }
472
- }
473
- IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
474
- IntegrationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: IntegrationState, providedIn: 'root' });
475
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: IntegrationState, decorators: [{
476
- type: Injectable,
477
- args: [{ providedIn: 'root' }]
478
- }] });
479
-
480
535
  class ResourcesService {
481
536
  constructor() {
482
537
  this.scripts = new Map();
@@ -714,10 +769,7 @@ class PreviewComponent {
714
769
  const elements = this.runtimeService.applicationTree;
715
770
  // If UI definition contains pages, return page by SelectedPageName
716
771
  if ((_b = (_a = this.uiDefinition) === null || _a === void 0 ? void 0 : _a.pages) === null || _b === void 0 ? void 0 : _b.length) {
717
- return this.integrationState.listen$(CmsAction.GO_TO_PAGE).pipe(map(({ pageName }) => pageName), startWith(elements[0].name), distinctUntilChanged(), map(pageName => {
718
- const page = elements.find(el => el.name === pageName);
719
- return page ? [page] : elements.slice(0, 1);
720
- }));
772
+ return this.getPages$(elements);
721
773
  }
722
774
  return of(elements);
723
775
  }));
@@ -770,6 +822,14 @@ class PreviewComponent {
770
822
  }), takeUntil(this.destroy$))
771
823
  .subscribe();
772
824
  }
825
+ getPages$(elements) {
826
+ return combineLatest([this.runtimeService.selectedPageName$, this.runtimeService.selectedOverlayNames$]).pipe(map(([pageName, overlayNames]) => {
827
+ const page = elements.find(el => el.name === pageName);
828
+ const overlayName = overlayNames.at(-1);
829
+ const overlay = elements.find(el => el.name === overlayName);
830
+ return [...(page ? [page] : elements.slice(0, 1)), ...(overlay ? [overlay] : [])];
831
+ }));
832
+ }
773
833
  }
774
834
  PreviewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PreviewComponent, deps: [{ token: RuntimeService }, { token: i2.ConfigurationService }, { token: i3.MessageService }, { token: i2.ConfigurationRuntimeService }, { token: IntegrationState }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
775
835
  PreviewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.8", type: PreviewComponent, selector: "vl-cms-preview", inputs: { modelId: "modelId", uiDefinition: "uiDefinition", config: "config" }, providers: [IOProviderService, TemplatesService], ngImport: i0, template: "<ng-container *ngIf=\"state$ | async as state\">\n <vl-loader *ngIf=\"state.loading; else content\" [label]=\"'Loading UI'\"></vl-loader>\n\n <ng-template #content>\n <ng-container *ngIf=\"!state.failure\">\n <vl-cms-element-renderer\n *ngFor=\"let el of elements$ | async; trackBy: trackBy\"\n [meta]=\"el\"\n ></vl-cms-element-renderer>\n </ng-container>\n </ng-template>\n</ng-container>\n", styles: [":host{flex-grow:1;display:flex;flex-direction:column;height:100%}\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: i1.LoaderComponent, selector: "vl-loader", inputs: ["label", "overlayVisible"] }, { kind: "component", type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }, { kind: "pipe", type: i5.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.ShadowDom });
@@ -1143,6 +1203,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1143
1203
  type: Directive
1144
1204
  }], ctorParameters: function () { return [{ type: ElementComponent }]; } });
1145
1205
 
1206
+ class PagePlugin {
1207
+ constructor(host) {
1208
+ this.host = host;
1209
+ this.destroy$ = new Subject();
1210
+ this.metadata = this.host.injector.get(ELEMENT_METADATA);
1211
+ this.el = this.host.injector.get(ElementRef);
1212
+ const runtimeService = this.host.injector.get(RuntimeService);
1213
+ runtimeService.selectedOverlayNames$
1214
+ .pipe(tap(overlayNames => {
1215
+ if (this.metadata.pageType === 'FULL_PAGE') {
1216
+ this.styleFullPage(overlayNames.length > 0);
1217
+ }
1218
+ }), takeUntil(this.destroy$))
1219
+ .subscribe();
1220
+ }
1221
+ ngOnDestroy() {
1222
+ this.destroy$.next();
1223
+ this.destroy$.complete();
1224
+ }
1225
+ styleFullPage(hasOverlays) {
1226
+ this.el.nativeElement.style.background = hasOverlays ? 'rgba(0, 0, 0, 0.15)' : '';
1227
+ this.el.nativeElement.style.pointerEvents = hasOverlays ? 'none' : '';
1228
+ }
1229
+ }
1230
+ PagePlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PagePlugin, deps: [{ token: ElementComponent }], target: i0.ɵɵFactoryTarget.Directive });
1231
+ PagePlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.8", type: PagePlugin, ngImport: i0 });
1232
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PagePlugin, decorators: [{
1233
+ type: Directive
1234
+ }], ctorParameters: function () { return [{ type: ElementComponent }]; } });
1235
+
1146
1236
  class RegionPlugin {
1147
1237
  constructor(host) {
1148
1238
  this.host = host;
@@ -1329,7 +1419,7 @@ const CONFIG = {
1329
1419
  PAGE: {
1330
1420
  component: ElementComponent,
1331
1421
  defaultTemplate: '<element-children></element-children>',
1332
- plugins: [IOPlugin, ScriptPlugin],
1422
+ plugins: [IOPlugin, ScriptPlugin, PagePlugin],
1333
1423
  builder: {
1334
1424
  suppressRemovable: true,
1335
1425
  },
@@ -1784,12 +1874,18 @@ const LAYOUT = {
1784
1874
  styles: `
1785
1875
  /* start of LAYOUT_7 styles */
1786
1876
  :host {
1787
- height: 100%;
1877
+ position: absolute;
1878
+ left: 300px;
1879
+ background: #ffffff;
1788
1880
  display: grid;
1789
- grid: "left" 1fr / 0.3fr;
1881
+ grid: "left" 1fr / 1fr;
1790
1882
  gap: 10px;
1791
1883
  padding: 10px;
1792
1884
  justify-content: start;
1885
+ width: 20%;
1886
+ height: fill-available;
1887
+ height: -webkit-fill-available;
1888
+ height: -moz-available;
1793
1889
  }
1794
1890
  :host ::ng-deep element-children > vl-cms-element-renderer {
1795
1891
  &:nth-child(1) > vl-element {
@@ -1803,12 +1899,18 @@ const LAYOUT = {
1803
1899
  styles: `
1804
1900
  /* start of LAYOUT_8 styles */
1805
1901
  :host {
1806
- height: 100%;
1902
+ position: absolute;
1903
+ right: 0;
1904
+ background: #ffffff;
1807
1905
  display: grid;
1808
- grid: "right" 1fr / 0.3fr;
1906
+ grid: "right" 1fr / 1fr;
1809
1907
  gap: 10px;
1810
1908
  padding: 10px;
1811
1909
  justify-content: end;
1910
+ width: 20%;
1911
+ height: fill-available;
1912
+ height: -webkit-fill-available;
1913
+ height: -moz-available;
1812
1914
  }
1813
1915
  :host ::ng-deep element-children > vl-cms-element-renderer {
1814
1916
  &:nth-child(1) > vl-element {
@@ -2262,5 +2364,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
2262
2364
  * Generated bundle index. Do not edit.
2263
2365
  */
2264
2366
 
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 };
2367
+ 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, RuntimeService, 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 };
2266
2368
  //# sourceMappingURL=veloceapps-sdk-cms.mjs.map