@veloceapps/sdk 7.0.2-20 → 7.0.2-22
Sign up to get free protection for your applications and to get access to all the features.
- package/cms/cms.actions.d.ts +23 -0
- package/cms/components/preview/preview.component.d.ts +1 -0
- package/cms/modules/runtime/index.d.ts +1 -0
- package/cms/modules/runtime/services/runtime.service.d.ts +5 -1
- package/cms/plugins/page.plugin.d.ts +15 -0
- package/esm2020/cms/cms.actions.mjs +32 -1
- package/esm2020/cms/cms.elements.mjs +3 -2
- package/esm2020/cms/cms.layouts.mjs +17 -5
- package/esm2020/cms/components/preview/preview.component.mjs +11 -7
- package/esm2020/cms/modules/runtime/index.mjs +2 -1
- package/esm2020/cms/modules/runtime/services/runtime.service.mjs +31 -4
- package/esm2020/cms/plugins/page.plugin.mjs +37 -0
- package/fesm2015/veloceapps-sdk-cms.mjs +150 -48
- package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-cms.mjs +150 -48
- package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
- package/package.json +1 -1
@@ -2,7 +2,7 @@ import { __decorate, __param, __metadata } 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,
|
5
|
+
import { BehaviorSubject, Subject, filter, map, distinctUntilChanged, of, tap, switchMap, startWith, ReplaySubject, noop, take, Observable, takeUntil, forkJoin, catchError, combineLatest } from 'rxjs';
|
6
6
|
import * as i2 from '@veloceapps/sdk/core';
|
7
7
|
import { ConfigurationService, QuoteDraftService, FlowConfigurationService, LineItemWorker, ProductImagesService, ContextService, lineItemUtils, generateLineItem, getAttributeValue, SdkCoreModule, UI_DEFINITION_VERSION } from '@veloceapps/sdk/core';
|
8
8
|
import * as i3 from 'primeng/api';
|
@@ -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({
|
@@ -175,6 +206,40 @@ ElementComponent = __decorate([
|
|
175
206
|
__metadata("design:paramtypes", [Injector])
|
176
207
|
], ElementComponent);
|
177
208
|
|
209
|
+
class IntegrationState {
|
210
|
+
constructor() {
|
211
|
+
this.stateSubj$ = new BehaviorSubject({});
|
212
|
+
this.action$ = new Subject();
|
213
|
+
}
|
214
|
+
get state$() {
|
215
|
+
return this.stateSubj$.asObservable();
|
216
|
+
}
|
217
|
+
get state() {
|
218
|
+
return this.stateSubj$.getValue();
|
219
|
+
}
|
220
|
+
patchState(update) {
|
221
|
+
this.stateSubj$.next({ ...this.stateSubj$.getValue(), ...update });
|
222
|
+
}
|
223
|
+
dispatch(action) {
|
224
|
+
this.action$.next(action);
|
225
|
+
}
|
226
|
+
listen$(actionType) {
|
227
|
+
return this.action$.pipe(filter(action => action.type === actionType), map(action => action.payload));
|
228
|
+
}
|
229
|
+
listenAll$() {
|
230
|
+
return this.action$.asObservable();
|
231
|
+
}
|
232
|
+
clear() {
|
233
|
+
this.stateSubj$.next({});
|
234
|
+
}
|
235
|
+
}
|
236
|
+
IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
237
|
+
IntegrationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: IntegrationState, providedIn: 'root' });
|
238
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: IntegrationState, decorators: [{
|
239
|
+
type: Injectable,
|
240
|
+
args: [{ providedIn: 'root' }]
|
241
|
+
}] });
|
242
|
+
|
178
243
|
const insertElementAt = (source, target, parentPath, index) => {
|
179
244
|
const result = [...source];
|
180
245
|
const name = getCollectionUniqueName(result, target.name, (name) => (el) => el.name === name);
|
@@ -250,14 +315,38 @@ const findElementByModule = (elements, module, elementName) => {
|
|
250
315
|
const CMS_COMPILATION_SERVICE = new InjectionToken('VENDOR_MAP');
|
251
316
|
|
252
317
|
class RuntimeService {
|
253
|
-
constructor(injector) {
|
318
|
+
constructor(injector, integrationState) {
|
254
319
|
this.injector = injector;
|
320
|
+
this.integrationState = integrationState;
|
255
321
|
this.moduleRefs = [];
|
256
322
|
this.componentTypes = {};
|
257
323
|
this.applicationTree = [];
|
258
324
|
this.isInitialized$ = new BehaviorSubject(false);
|
259
325
|
this.updated$ = new Subject();
|
326
|
+
this.selectedPageName$ = new BehaviorSubject(null);
|
327
|
+
this.selectedOverlayNames$ = new BehaviorSubject([]);
|
260
328
|
this.compilationService = this.injector.get(CMS_COMPILATION_SERVICE);
|
329
|
+
this.integrationState
|
330
|
+
.listen$(CmsAction.GO_TO_PAGE)
|
331
|
+
.pipe(map(({ pageName }) => pageName), distinctUntilChanged())
|
332
|
+
.subscribe(pageName => this.selectedPageName$.next(pageName));
|
333
|
+
this.integrationState
|
334
|
+
.listen$(CmsAction.SHOW_OVERLAY)
|
335
|
+
.pipe(map(({ name }) => name))
|
336
|
+
.subscribe(overlayName => {
|
337
|
+
const overlayNames = this.selectedOverlayNames$.value;
|
338
|
+
if (!overlayNames.includes(overlayName)) {
|
339
|
+
this.selectedOverlayNames$.next([...overlayNames, overlayName]);
|
340
|
+
}
|
341
|
+
});
|
342
|
+
this.integrationState
|
343
|
+
.listen$(CmsAction.HIDE_OVERLAY)
|
344
|
+
.pipe(map(({ name }) => name))
|
345
|
+
.subscribe(overlayName => {
|
346
|
+
const overlayNames = this.selectedOverlayNames$.value;
|
347
|
+
this.selectedOverlayNames$.next(overlayNames.filter(name => name !== overlayName));
|
348
|
+
});
|
349
|
+
this.integrationState.listen$(CmsAction.HIDE_ALL_OVERLAYS).subscribe(() => this.selectedOverlayNames$.next([]));
|
261
350
|
}
|
262
351
|
initialize$(uiDefinition, config) {
|
263
352
|
this.config = config;
|
@@ -317,45 +406,11 @@ class RuntimeService {
|
|
317
406
|
applyPatch(this.applicationTree, [operation]);
|
318
407
|
}
|
319
408
|
}
|
320
|
-
RuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
409
|
+
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 });
|
321
410
|
RuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeService });
|
322
411
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeService, decorators: [{
|
323
412
|
type: Injectable
|
324
|
-
}], ctorParameters: function () { return [{ type: i0.Injector }]; } });
|
325
|
-
|
326
|
-
class IntegrationState {
|
327
|
-
constructor() {
|
328
|
-
this.stateSubj$ = new BehaviorSubject({});
|
329
|
-
this.action$ = new Subject();
|
330
|
-
}
|
331
|
-
get state$() {
|
332
|
-
return this.stateSubj$.asObservable();
|
333
|
-
}
|
334
|
-
get state() {
|
335
|
-
return this.stateSubj$.getValue();
|
336
|
-
}
|
337
|
-
patchState(update) {
|
338
|
-
this.stateSubj$.next({ ...this.stateSubj$.getValue(), ...update });
|
339
|
-
}
|
340
|
-
dispatch(action) {
|
341
|
-
this.action$.next(action);
|
342
|
-
}
|
343
|
-
listen$(actionType) {
|
344
|
-
return this.action$.pipe(filter(action => action.type === actionType), map(action => action.payload));
|
345
|
-
}
|
346
|
-
listenAll$() {
|
347
|
-
return this.action$.asObservable();
|
348
|
-
}
|
349
|
-
clear() {
|
350
|
-
this.stateSubj$.next({});
|
351
|
-
}
|
352
|
-
}
|
353
|
-
IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
354
|
-
IntegrationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: IntegrationState, providedIn: 'root' });
|
355
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: IntegrationState, decorators: [{
|
356
|
-
type: Injectable,
|
357
|
-
args: [{ providedIn: 'root' }]
|
358
|
-
}] });
|
413
|
+
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: IntegrationState }]; } });
|
359
414
|
|
360
415
|
class ResourcesService {
|
361
416
|
constructor() {
|
@@ -709,10 +764,7 @@ class PreviewComponent {
|
|
709
764
|
const elements = this.runtimeService.applicationTree;
|
710
765
|
// If UI definition contains pages, return page by SelectedPageName
|
711
766
|
if (this.uiDefinition?.pages?.length) {
|
712
|
-
return this.
|
713
|
-
const page = elements.find(el => el.name === pageName);
|
714
|
-
return page ? [page] : elements.slice(0, 1);
|
715
|
-
}));
|
767
|
+
return this.getPages$(elements);
|
716
768
|
}
|
717
769
|
return of(elements);
|
718
770
|
}));
|
@@ -763,6 +815,14 @@ class PreviewComponent {
|
|
763
815
|
}), takeUntil(this.destroy$))
|
764
816
|
.subscribe();
|
765
817
|
}
|
818
|
+
getPages$(elements) {
|
819
|
+
return combineLatest([this.runtimeService.selectedPageName$, this.runtimeService.selectedOverlayNames$]).pipe(map(([pageName, overlayNames]) => {
|
820
|
+
const page = elements.find(el => el.name === pageName);
|
821
|
+
const overlayName = overlayNames.at(-1);
|
822
|
+
const overlay = elements.find(el => el.name === overlayName);
|
823
|
+
return [...(page ? [page] : elements.slice(0, 1)), ...(overlay ? [overlay] : [])];
|
824
|
+
}));
|
825
|
+
}
|
766
826
|
}
|
767
827
|
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 });
|
768
828
|
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 });
|
@@ -1129,6 +1189,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
|
|
1129
1189
|
type: Directive
|
1130
1190
|
}], ctorParameters: function () { return [{ type: ElementComponent }]; } });
|
1131
1191
|
|
1192
|
+
class PagePlugin {
|
1193
|
+
constructor(host) {
|
1194
|
+
this.host = host;
|
1195
|
+
this.destroy$ = new Subject();
|
1196
|
+
this.metadata = this.host.injector.get(ELEMENT_METADATA);
|
1197
|
+
this.el = this.host.injector.get(ElementRef);
|
1198
|
+
const runtimeService = this.host.injector.get(RuntimeService);
|
1199
|
+
runtimeService.selectedOverlayNames$
|
1200
|
+
.pipe(tap(overlayNames => {
|
1201
|
+
if (this.metadata.pageType === 'FULL_PAGE') {
|
1202
|
+
this.styleFullPage(overlayNames.length > 0);
|
1203
|
+
}
|
1204
|
+
}), takeUntil(this.destroy$))
|
1205
|
+
.subscribe();
|
1206
|
+
}
|
1207
|
+
ngOnDestroy() {
|
1208
|
+
this.destroy$.next();
|
1209
|
+
this.destroy$.complete();
|
1210
|
+
}
|
1211
|
+
styleFullPage(hasOverlays) {
|
1212
|
+
this.el.nativeElement.style.background = hasOverlays ? 'rgba(0, 0, 0, 0.15)' : '';
|
1213
|
+
this.el.nativeElement.style.pointerEvents = hasOverlays ? 'none' : '';
|
1214
|
+
}
|
1215
|
+
}
|
1216
|
+
PagePlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PagePlugin, deps: [{ token: ElementComponent }], target: i0.ɵɵFactoryTarget.Directive });
|
1217
|
+
PagePlugin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.8", type: PagePlugin, ngImport: i0 });
|
1218
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PagePlugin, decorators: [{
|
1219
|
+
type: Directive
|
1220
|
+
}], ctorParameters: function () { return [{ type: ElementComponent }]; } });
|
1221
|
+
|
1132
1222
|
class RegionPlugin {
|
1133
1223
|
constructor(host) {
|
1134
1224
|
this.host = host;
|
@@ -1328,7 +1418,7 @@ const CONFIG = {
|
|
1328
1418
|
PAGE: {
|
1329
1419
|
component: ElementComponent,
|
1330
1420
|
defaultTemplate: '<element-children></element-children>',
|
1331
|
-
plugins: [IOPlugin, ScriptPlugin],
|
1421
|
+
plugins: [IOPlugin, ScriptPlugin, PagePlugin],
|
1332
1422
|
builder: {
|
1333
1423
|
suppressRemovable: true,
|
1334
1424
|
},
|
@@ -1785,12 +1875,18 @@ const LAYOUT = {
|
|
1785
1875
|
styles: `
|
1786
1876
|
/* start of LAYOUT_7 styles */
|
1787
1877
|
:host {
|
1788
|
-
|
1878
|
+
position: absolute;
|
1879
|
+
left: 300px;
|
1880
|
+
background: #ffffff;
|
1789
1881
|
display: grid;
|
1790
|
-
grid: "left" 1fr /
|
1882
|
+
grid: "left" 1fr / 1fr;
|
1791
1883
|
gap: 10px;
|
1792
1884
|
padding: 10px;
|
1793
1885
|
justify-content: start;
|
1886
|
+
width: 20%;
|
1887
|
+
height: fill-available;
|
1888
|
+
height: -webkit-fill-available;
|
1889
|
+
height: -moz-available;
|
1794
1890
|
}
|
1795
1891
|
:host ::ng-deep element-children > vl-cms-element-renderer {
|
1796
1892
|
&:nth-child(1) > vl-element {
|
@@ -1804,12 +1900,18 @@ const LAYOUT = {
|
|
1804
1900
|
styles: `
|
1805
1901
|
/* start of LAYOUT_8 styles */
|
1806
1902
|
:host {
|
1807
|
-
|
1903
|
+
position: absolute;
|
1904
|
+
right: 0;
|
1905
|
+
background: #ffffff;
|
1808
1906
|
display: grid;
|
1809
|
-
grid: "right" 1fr /
|
1907
|
+
grid: "right" 1fr / 1fr;
|
1810
1908
|
gap: 10px;
|
1811
1909
|
padding: 10px;
|
1812
1910
|
justify-content: end;
|
1911
|
+
width: 20%;
|
1912
|
+
height: fill-available;
|
1913
|
+
height: -webkit-fill-available;
|
1914
|
+
height: -moz-available;
|
1813
1915
|
}
|
1814
1916
|
:host ::ng-deep element-children > vl-cms-element-renderer {
|
1815
1917
|
&:nth-child(1) > vl-element {
|
@@ -2362,5 +2464,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
|
|
2362
2464
|
* Generated bundle index. Do not edit.
|
2363
2465
|
*/
|
2364
2466
|
|
2365
|
-
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 };
|
2467
|
+
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 };
|
2366
2468
|
//# sourceMappingURL=veloceapps-sdk-cms.mjs.map
|