@veloceapps/sdk 7.0.2-43 → 7.0.2-44

Sign up to get free protection for your applications and to get access to all the features.
@@ -1007,7 +1007,7 @@ class PreviewComponent {
1007
1007
  }
1008
1008
  const elements = this.runtimeService.applicationTree;
1009
1009
  // If UI definition contains pages, return page by SelectedPageName
1010
- if (this.uiDefinition?.pages?.length) {
1010
+ if (this.uiDefinition?.pages) {
1011
1011
  return this.getPages$(elements);
1012
1012
  }
1013
1013
  return of(elements);
@@ -1266,6 +1266,24 @@ function ElementDefinition(definition) {
1266
1266
  };
1267
1267
  }
1268
1268
 
1269
+ const DEFAULT_ELEMENT = {
1270
+ template: '<element-children></element-children>',
1271
+ styles: '',
1272
+ script: `import { ElementDefinition } from '@veloceapps/sdk/cms';
1273
+
1274
+ export class Script {}`,
1275
+ };
1276
+ const STARTING_PAGE_NAME = 'Starting Page';
1277
+ const STARTING_PAGE_TYPE = 'FULL_PAGE';
1278
+ const STARTING_PAGE_LAYOUT = 'LAYOUT_6';
1279
+ const STARTING_PAGE_STYLES = {
1280
+ padding: '16px 16px 16px 16px',
1281
+ backgroundColor: '#FFFFFF',
1282
+ border: 'solid',
1283
+ borderColor: '#DCE5EF',
1284
+ borderWidth: '1px 1px 1px 1px',
1285
+ };
1286
+
1269
1287
  // eslint-disable-next-line @angular-eslint/directive-selector
1270
1288
  class CustomTemplateDirective {
1271
1289
  constructor(templateRef, templatesService) {
@@ -2137,6 +2155,51 @@ class ElementsResolver {
2137
2155
  }
2138
2156
  }
2139
2157
 
2158
+ const constructPageChildren = (path, layout) => {
2159
+ switch (layout) {
2160
+ case 'LAYOUT_1': // Header, One region, and Footer
2161
+ case 'LAYOUT_4': // Two Regions and Footer
2162
+ return [constructRegion('Region A', path), constructRegion('Region B', path), constructRegion('Region C', path)];
2163
+ case 'LAYOUT_2': // Header, Two Regions, and Footer
2164
+ return [
2165
+ constructRegion('Region A', path),
2166
+ constructRegion('Region B', path),
2167
+ constructRegion('Region C', path),
2168
+ constructRegion('Region D', path),
2169
+ ];
2170
+ case 'LAYOUT_3': // One Region and Footer
2171
+ case 'LAYOUT_5': // Header and One Region
2172
+ return [constructRegion('Region A', path), constructRegion('Region B', path)];
2173
+ case 'LAYOUT_6': // One Region
2174
+ case 'LAYOUT_7': // Left Sidepanel
2175
+ case 'LAYOUT_8': // Right Sidepanel
2176
+ return [constructRegion('Region A', path)];
2177
+ default:
2178
+ return [];
2179
+ }
2180
+ };
2181
+ const constructRegion = (name, parentPath) => {
2182
+ return {
2183
+ name,
2184
+ path: `${parentPath}/${name}`,
2185
+ type: 'REGION',
2186
+ children: [],
2187
+ ...DEFAULT_ELEMENT,
2188
+ };
2189
+ };
2190
+ const constructPage = (name, pageType, layout, configuredStyles) => {
2191
+ return {
2192
+ name,
2193
+ path: name,
2194
+ type: 'PAGE',
2195
+ layout,
2196
+ pageType,
2197
+ configuredStyles,
2198
+ children: constructPageChildren(name, layout),
2199
+ ...DEFAULT_ELEMENT,
2200
+ };
2201
+ };
2202
+
2140
2203
  class FederatedHostDirective {
2141
2204
  constructor(viewContainerRef) {
2142
2205
  this.viewContainerRef = viewContainerRef;
@@ -2350,11 +2413,16 @@ const migrations = {
2350
2413
  throw 'Migration from Legacy UI definition is not possible';
2351
2414
  },
2352
2415
  3: uiDef => {
2353
- const children = uiDef.children ?? [];
2416
+ const defaultStartingPage = metadataToElement(constructPage(STARTING_PAGE_NAME, STARTING_PAGE_TYPE, STARTING_PAGE_LAYOUT, STARTING_PAGE_STYLES));
2417
+ // overwrite children if provided from the UI Definition
2418
+ const startingPage = {
2419
+ ...defaultStartingPage,
2420
+ ...(uiDef.children && uiDef.children.length > 0 && { children: uiDef.children }),
2421
+ };
2354
2422
  return {
2355
2423
  ...uiDef,
2356
2424
  children: undefined,
2357
- pages: children,
2425
+ pages: [startingPage],
2358
2426
  version: 3,
2359
2427
  };
2360
2428
  },
@@ -2482,5 +2550,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
2482
2550
  * Generated bundle index. Do not edit.
2483
2551
  */
2484
2552
 
2485
- export { ApplyProductConfigurationAction, CloseDocGenAction, CmsAction, ConfigureProductAction, DEFAULT_PLUGINS_TOKEN, ELEMENT_CONFIG, ELEMENT_METADATA, ElementComponent, ElementDefinition, ElementsResolver, FlowAction, IntegrationState, LAYOUT, 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 };
2553
+ export { ApplyProductConfigurationAction, CloseDocGenAction, CmsAction, ConfigureProductAction, DEFAULT_ELEMENT, DEFAULT_PLUGINS_TOKEN, ELEMENT_CONFIG, ELEMENT_METADATA, ElementComponent, ElementDefinition, ElementsResolver, FlowAction, IntegrationState, LAYOUT, LauncherModule, MigrationsModule, MigrationsService, NavigateBackAction, NavigateToCatalogAction, OpenDocGenAction, PreviewComponent, PreviewModule, RemoteApplyAction, RemoteCancelAction, ResourcesService, RuntimeEditorService, RuntimeModule, RuntimeService, SHARED_ELEMENT_METADATA, STARTING_PAGE_LAYOUT, STARTING_PAGE_NAME, STARTING_PAGE_STYLES, STARTING_PAGE_TYPE, SwitchObjectAction, TemplatesService, UI_DEFINITION_METADATA, UiBuildError, constructPage, constructPageChildren, constructRegion, doesElementSupportIO, elementToMetadata, extendElementMetadata, extractElementMetadata, findElementByModule, findElementByPath, flattenElements, getAbsolutePath, getElementConfig, insertElement, isSharedElement, isValidScript, metadataToElement, normalizeElementMetadata, parseBoundPath, parsePath, removeElement, stringifyElementMetadata };
2486
2554
  //# sourceMappingURL=veloceapps-sdk-cms.mjs.map