@veloceapps/sdk 7.0.0-1 → 7.0.0-11

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.
Files changed (33) hide show
  1. package/bundles/veloceapps-sdk-cms.umd.js +138 -20
  2. package/bundles/veloceapps-sdk-cms.umd.js.map +1 -1
  3. package/bundles/veloceapps-sdk.umd.js.map +1 -1
  4. package/cms/cms.actions.d.ts +10 -0
  5. package/cms/cms.elements.d.ts +1 -1
  6. package/cms/cms.layouts.d.ts +4 -0
  7. package/cms/components/preview/preview.component.d.ts +3 -2
  8. package/cms/plugins/region.plugin.d.ts +17 -0
  9. package/cms/types/common.types.d.ts +9 -2
  10. package/cms/types/index.d.ts +0 -1
  11. package/cms/types/layouts.types.d.ts +74 -0
  12. package/cms/utils/element.utils.d.ts +1 -1
  13. package/cms/vendor-map.d.ts +1 -0
  14. package/esm2015/cms/cms.actions.js +15 -1
  15. package/esm2015/cms/cms.elements.js +12 -1
  16. package/esm2015/cms/cms.layouts.js +179 -0
  17. package/esm2015/cms/components/preview/preview.component.js +23 -6
  18. package/esm2015/cms/plugins/region.plugin.js +58 -0
  19. package/esm2015/cms/types/common.types.js +1 -1
  20. package/esm2015/cms/types/index.js +1 -2
  21. package/esm2015/cms/types/layouts.types.js +2 -0
  22. package/esm2015/cms/utils/element.utils.js +10 -14
  23. package/esm2015/cms/utils/elements-resolver.js +8 -2
  24. package/esm2015/src/components/header/metrics/metrics.component.js +2 -2
  25. package/esm2015/src/types/index.js +2 -1
  26. package/esm2015/{cms → src}/types/metrics.types.js +1 -1
  27. package/fesm2015/veloceapps-sdk-cms.js +292 -21
  28. package/fesm2015/veloceapps-sdk-cms.js.map +1 -1
  29. package/fesm2015/veloceapps-sdk.js.map +1 -1
  30. package/package.json +2 -2
  31. package/src/components/header/metrics/metrics.component.d.ts +1 -1
  32. package/src/types/index.d.ts +1 -0
  33. /package/{cms → src}/types/metrics.types.d.ts +0 -0
@@ -77,6 +77,20 @@
77
77
  type: exports.FlowAction.FLOW_SWITCH_OBJECT,
78
78
  payload: payload,
79
79
  }); };
80
+ exports.CmsAction = void 0;
81
+ (function (CmsAction) {
82
+ CmsAction.GO_TO_PAGE = '[CMS]_GO_TO_PAGE';
83
+ /**
84
+ * Navigate UI definition to a specific page
85
+ *
86
+ * @param pageName name of the page
87
+ * @returns void
88
+ */
89
+ CmsAction.GoToPage = function (pageName) { return ({
90
+ type: CmsAction.GO_TO_PAGE,
91
+ payload: { pageName: pageName },
92
+ }); };
93
+ })(exports.CmsAction || (exports.CmsAction = {}));
80
94
 
81
95
  var cmsActions = /*#__PURE__*/Object.freeze({
82
96
  __proto__: null,
@@ -89,7 +103,8 @@
89
103
  CloseDocGenAction: CloseDocGenAction,
90
104
  RemoteApplyAction: RemoteApplyAction,
91
105
  RemoteCancelAction: RemoteCancelAction,
92
- SwitchObjectAction: SwitchObjectAction
106
+ SwitchObjectAction: SwitchObjectAction,
107
+ get CmsAction () { return exports.CmsAction; }
93
108
  });
94
109
 
95
110
  /******************************************************************************
@@ -1150,9 +1165,27 @@
1150
1165
  this.integrationState = integrationState;
1151
1166
  this.cdr = cdr;
1152
1167
  this.state$ = new rxjs.BehaviorSubject({ loading: true, failure: false });
1153
- this.elements = [];
1154
1168
  this.destroy$ = new rxjs.Subject();
1155
1169
  this.runtimeService.updated$.pipe(rxjs.takeUntil(this.destroy$)).subscribe(function () { return _this.cdr.detectChanges(); });
1170
+ this.elements$ = this.state$.pipe(rxjs.switchMap(function (_c) {
1171
+ var loading = _c.loading, failure = _c.failure;
1172
+ var _a, _b;
1173
+ if (loading || failure) {
1174
+ return rxjs.of([]);
1175
+ }
1176
+ var elements = _this.runtimeService.applicationTree;
1177
+ // If UI definition contains pages, return page by SelectedPageName
1178
+ if ((_b = (_a = _this.uiDefinition) === null || _a === void 0 ? void 0 : _a.pages) === null || _b === void 0 ? void 0 : _b.length) {
1179
+ return _this.integrationState.listen$(exports.CmsAction.GO_TO_PAGE).pipe(rxjs.map(function (_c) {
1180
+ var pageName = _c.pageName;
1181
+ return pageName;
1182
+ }), rxjs.startWith(elements[0].name), rxjs.distinctUntilChanged(), rxjs.map(function (pageName) {
1183
+ var page = elements.find(function (el) { return el.name === pageName; });
1184
+ return page ? [page] : elements.slice(0, 1);
1185
+ }));
1186
+ }
1187
+ return rxjs.of(elements);
1188
+ }));
1156
1189
  }
1157
1190
  PreviewComponent.prototype.ngOnInit = function () {
1158
1191
  var _a;
@@ -1167,6 +1200,9 @@
1167
1200
  this.configurationService.reset();
1168
1201
  this.runtimeService.clear();
1169
1202
  };
1203
+ PreviewComponent.prototype.trackBy = function (_, el) {
1204
+ return el.path;
1205
+ };
1170
1206
  PreviewComponent.prototype.initializeConfiguration$ = function () {
1171
1207
  var _this = this;
1172
1208
  var isAlreadyInitialized = this.configurationRuntimeService.isInitialized;
@@ -1188,9 +1224,7 @@
1188
1224
  return;
1189
1225
  }
1190
1226
  rxjs.forkJoin([this.runtimeService.initialize$(this.uiDefinition, this.config), this.initializeConfiguration$()])
1191
- .pipe(rxjs.tap(function (_c) {
1192
- var _d = __read(_c, 1), elements = _d[0];
1193
- _this.elements = elements;
1227
+ .pipe(rxjs.tap(function () {
1194
1228
  _this.state$.next({ loading: false, failure: false });
1195
1229
  }), rxjs.catchError(function (error) {
1196
1230
  var _a, _b;
@@ -1206,7 +1240,7 @@
1206
1240
  return PreviewComponent;
1207
1241
  }());
1208
1242
  PreviewComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: PreviewComponent, deps: [{ token: RuntimeService }, { token: i2__namespace.ConfigurationService }, { token: i3__namespace.MessageService }, { token: i2__namespace.ConfigurationRuntimeService }, { token: IntegrationState }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
1209
- PreviewComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: PreviewComponent, selector: "vl-cms-preview", inputs: { modelId: "modelId", uiDefinition: "uiDefinition", config: "config" }, providers: [IOProviderService, TemplatesService], ngImport: i0__namespace, 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 *ngFor=\"let el of elements\" [meta]=\"el\"></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"], components: [{ type: i1__namespace.LoaderComponent, selector: "vl-loader", inputs: ["label", "overlayVisible"] }, { type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }], directives: [{ type: i7__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i7__namespace.AsyncPipe }, changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush, encapsulation: i0__namespace.ViewEncapsulation.ShadowDom });
1243
+ PreviewComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: PreviewComponent, selector: "vl-cms-preview", inputs: { modelId: "modelId", uiDefinition: "uiDefinition", config: "config" }, providers: [IOProviderService, TemplatesService], ngImport: i0__namespace, 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"], components: [{ type: i1__namespace.LoaderComponent, selector: "vl-loader", inputs: ["label", "overlayVisible"] }, { type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }], directives: [{ type: i7__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i7__namespace.AsyncPipe }, changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush, encapsulation: i0__namespace.ViewEncapsulation.ShadowDom });
1210
1244
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: PreviewComponent, decorators: [{
1211
1245
  type: i0.Component,
1212
1246
  args: [{
@@ -1446,6 +1480,58 @@
1446
1480
  type: i0.Directive
1447
1481
  }], ctorParameters: function () { return [{ type: exports.ElementComponent }]; } });
1448
1482
 
1483
+ var RegionPlugin = /** @class */ (function () {
1484
+ function RegionPlugin(host) {
1485
+ var _this = this;
1486
+ this.host = host;
1487
+ this.destroy$ = new rxjs.Subject();
1488
+ this.metadata = this.host.injector.get(ELEMENT_METADATA);
1489
+ this.document = this.host.injector.get(i7.DOCUMENT);
1490
+ this.el = this.host.injector.get(i0.ElementRef);
1491
+ var runtimeEditorService = this.host.injector.get(RuntimeEditorService);
1492
+ runtimeEditorService.editorMode$
1493
+ .pipe(rxjs.tap(function (editMode) {
1494
+ var _a;
1495
+ _this.el.nativeElement.style.outline = editMode ? 'solid 1px #dce5ef' : '';
1496
+ if (editMode && !_this.metadata.children.length) {
1497
+ _this.addRegionName();
1498
+ }
1499
+ else {
1500
+ (_a = _this.regionNameEl) === null || _a === void 0 ? void 0 : _a.remove();
1501
+ }
1502
+ }), rxjs.takeUntil(this.destroy$))
1503
+ .subscribe();
1504
+ }
1505
+ RegionPlugin.prototype.ngOnDestroy = function () {
1506
+ this.destroy$.next();
1507
+ this.destroy$.complete();
1508
+ };
1509
+ RegionPlugin.prototype.addRegionName = function () {
1510
+ if (this.regionNameEl) {
1511
+ this.regionNameEl.remove();
1512
+ }
1513
+ this.regionNameEl = this.document.createElement('div');
1514
+ this.regionNameEl.innerHTML = this.metadata.name;
1515
+ lodash.merge(this.regionNameEl.style, {
1516
+ width: '100%',
1517
+ height: '100%',
1518
+ display: 'flex',
1519
+ justifyContent: 'center',
1520
+ alignItems: 'center',
1521
+ color: '#AEB5BD',
1522
+ pointerEvents: 'none',
1523
+ userSelect: 'none',
1524
+ });
1525
+ this.el.nativeElement.append(this.regionNameEl);
1526
+ };
1527
+ return RegionPlugin;
1528
+ }());
1529
+ RegionPlugin.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RegionPlugin, deps: [{ token: exports.ElementComponent }], target: i0__namespace.ɵɵFactoryTarget.Directive });
1530
+ RegionPlugin.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: RegionPlugin, ngImport: i0__namespace });
1531
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RegionPlugin, decorators: [{
1532
+ type: i0.Directive
1533
+ }], ctorParameters: function () { return [{ type: exports.ElementComponent }]; } });
1534
+
1449
1535
  var ScriptPlugin = /** @class */ (function () {
1450
1536
  function ScriptPlugin(host) {
1451
1537
  var _this = this;
@@ -1531,6 +1617,16 @@
1531
1617
  plugins: [IOPlugin, ScriptPlugin],
1532
1618
  suppressTemplate: true,
1533
1619
  },
1620
+ PAGE: {
1621
+ component: exports.ElementComponent,
1622
+ defaultTemplate: '<element-children></element-children>',
1623
+ plugins: [IOPlugin, ScriptPlugin],
1624
+ },
1625
+ REGION: {
1626
+ component: exports.ElementComponent,
1627
+ defaultTemplate: '<element-children></element-children>',
1628
+ plugins: [IOPlugin, ScriptPlugin, RegionPlugin],
1629
+ },
1534
1630
  };
1535
1631
 
1536
1632
  var EXPORTED_CLASS_REGEX = /export class (\S+)/;
@@ -1560,21 +1656,17 @@
1560
1656
  };
1561
1657
  var metadataToElement = function (metadata, recursive) {
1562
1658
  if (recursive === void 0) { recursive = true; }
1563
- var elMetadata = {
1564
- name: metadata.name,
1565
- isShared: metadata.isShared,
1566
- type: metadata.type,
1567
- model: metadata.model,
1568
- module: metadata.module,
1569
- reference: metadata.reference,
1570
- inputs: metadata.inputs,
1571
- outputs: metadata.outputs,
1572
- children: metadata.children.map(function (_e) {
1659
+ var cleanMetadata = lodash.omit(metadata, [
1660
+ 'path',
1661
+ 'template',
1662
+ 'styles',
1663
+ 'script',
1664
+ 'metadata',
1665
+ ]);
1666
+ var elMetadata = Object.assign(Object.assign({}, cleanMetadata), { children: metadata.children.map(function (_e) {
1573
1667
  var name = _e.name;
1574
1668
  return name;
1575
- }),
1576
- configuredStyles: metadata.configuredStyles,
1577
- };
1669
+ }) });
1578
1670
  var normalizedElMetadata = normalizeElementMetadata(elMetadata);
1579
1671
  if (!metadata.script || !EXPORTED_CLASS_REGEX.test(metadata.script)) {
1580
1672
  throw new UiBuildError("'" + metadata.name + "' component script is missing an exported class", metadata);
@@ -1824,6 +1916,27 @@
1824
1916
  DEFAULT: [],
1825
1917
  };
1826
1918
 
1919
+ var LAYOUT = {
1920
+ LAYOUT_1: {
1921
+ styles: "\n/* start of LAYOUT_1 styles */\n:host {\n height: 100%;\n display: grid;\n grid:\n \"header\" auto\n \"main\" 1fr\n \"footer\" auto\n / 1fr;\n gap: 10px;\n padding: 10px;\n}\n\n:host ::ng-deep element-children > vl-cms-element-renderer {\n &:nth-child(1) > vl-element {\n min-height: 80px;\n grid-area: header;\n }\n\n &:nth-child(2) > vl-element {\n grid-area: main;\n }\n\n &:nth-child(3) > vl-element {\n min-height: 80px;\n grid-area: footer;\n }\n}\n/* end of LAYOUT_1 styles */\n",
1922
+ },
1923
+ LAYOUT_2: {
1924
+ styles: "\n/* start of LAYOUT_2 styles */\n:host {\n height: 100%;\n display: grid;\n grid:\n \"header header\" auto\n \"left right\" 1fr\n \"footer footer\" auto\n / 1fr 1fr;\n gap: 10px;\n padding: 10px;\n}\n\n:host ::ng-deep element-children > vl-cms-element-renderer {\n &:nth-child(1) > vl-element {\n min-height: 80px;\n grid-area: header;\n }\n\n &:nth-child(2) > vl-element {\n grid-area: left;\n }\n\n &:nth-child(3) > vl-element {\n grid-area: right;\n }\n\n &:nth-child(4) > vl-element {\n min-height: 80px;\n grid-area: footer;\n }\n}\n/* end of LAYOUT_2 styles */\n",
1925
+ },
1926
+ LAYOUT_3: {
1927
+ styles: "\n/* start of LAYOUT_3 styles */\n:host {\n height: 100%;\n display: grid;\n grid:\n \"main\" 1fr\n \"footer\" auto\n / 1fr;\n gap: 10px;\n padding: 10px;\n}\n\n:host ::ng-deep element-children > vl-cms-element-renderer {\n &:nth-child(1) > vl-element {\n grid-area: main;\n }\n\n &:nth-child(2) > vl-element {\n min-height: 80px;\n grid-area: footer;\n }\n}\n/* end of LAYOUT_3 styles */\n",
1928
+ },
1929
+ LAYOUT_4: {
1930
+ styles: "\n/* start of LAYOUT_4 styles */\n:host {\n height: 100%;\n display: grid;\n grid:\n \"left right\" 1fr\n \"footer footer\" auto\n / auto auto;\n gap: 10px;\n padding: 10px;\n}\n\n:host ::ng-deep element-children > vl-cms-element-renderer {\n &:nth-child(1) > vl-element {\n grid-area: left;\n }\n\n &:nth-child(2) > vl-element {\n grid-area: right;\n }\n\n &:nth-child(3) > vl-element {\n min-height: 80px;\n grid-area: footer;\n }\n}\n/* end of LAYOUT_4 styles */\n",
1931
+ },
1932
+ LAYOUT_5: {
1933
+ styles: "\n/* start of LAYOUT_5 styles */\n:host {\n height: 100%;\n display: grid;\n grid:\n \"header\" auto\n \"main\" 1fr\n / 1fr;\n gap: 10px;\n padding: 10px;\n}\n\n:host ::ng-deep element-children > vl-cms-element-renderer {\n &:nth-child(1) > vl-element {\n min-height: 80px;\n grid-area: header;\n }\n\n &:nth-child(2) > vl-element {\n grid-area: main;\n }\n}\n/* end of LAYOUT_5 styles */\n",
1934
+ },
1935
+ LAYOUT_6: {
1936
+ styles: "\n/* start of LAYOUT_6 styles */\n:host {\n height: 100%;\n display: grid;\n grid:\n \"main\" 1fr\n / 1fr;\n gap: 10px;\n padding: 10px;\n}\n\n:host ::ng-deep element-children > vl-cms-element-renderer {\n &:nth-child(1) > vl-element {\n grid-area: main;\n }\n}\n/* end of LAYOUT_6 styles */\n",
1937
+ },
1938
+ };
1939
+
1827
1940
  var VELOCE_LIBS = {
1828
1941
  '@veloceapps/core': {
1829
1942
  isDefined: core.isDefined,
@@ -1946,7 +2059,12 @@
1946
2059
  ElementsResolver.prototype.resolveElementStyles = function (element) {
1947
2060
  var _a;
1948
2061
  var config = CONFIG[element.type];
1949
- return !config.suppressStyles ? (_a = element.styles) !== null && _a !== void 0 ? _a : '' : '';
2062
+ var styles = !config.suppressStyles ? (_a = element.styles) !== null && _a !== void 0 ? _a : '' : '';
2063
+ var layout = element.layout && LAYOUT[element.layout];
2064
+ if (layout === null || layout === void 0 ? void 0 : layout.styles) {
2065
+ styles += layout.styles;
2066
+ }
2067
+ return styles;
1950
2068
  };
1951
2069
  ElementsResolver.prototype.processElementMetadata = function (sourceElement) {
1952
2070
  var _this = this;