@sap-ux/preview-middleware 0.16.8 → 0.16.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 (35) hide show
  1. package/README.md +7 -0
  2. package/dist/client/adp/api-handler.js +142 -142
  3. package/dist/client/adp/command-executor.js +58 -58
  4. package/dist/client/adp/control-utils.js +44 -44
  5. package/dist/client/adp/controllers/AddFragment.controller.js +219 -219
  6. package/dist/client/adp/controllers/BaseDialog.controller.js +105 -105
  7. package/dist/client/adp/controllers/ControllerExtension.controller.js +228 -228
  8. package/dist/client/adp/controllers/ExtensionPoint.controller.js +138 -138
  9. package/dist/client/adp/init-dialogs.js +138 -121
  10. package/dist/client/adp/init-dialogs.ts +39 -14
  11. package/dist/client/adp/init.js +1 -1
  12. package/dist/client/adp/init.ts +2 -1
  13. package/dist/client/adp/ui5-version-utils.js +63 -63
  14. package/dist/client/adp/utils.js +61 -61
  15. package/dist/client/cpe/changes/flex-change.js +51 -51
  16. package/dist/client/cpe/changes/index.js +10 -10
  17. package/dist/client/cpe/changes/validator.js +34 -34
  18. package/dist/client/cpe/documentation.js +164 -164
  19. package/dist/client/cpe/error-utils.js +19 -19
  20. package/dist/client/cpe/logger.js +30 -30
  21. package/dist/client/cpe/outline/index.js +11 -1
  22. package/dist/client/cpe/outline/index.ts +9 -4
  23. package/dist/client/cpe/outline/nodes.js +172 -151
  24. package/dist/client/cpe/outline/nodes.ts +40 -9
  25. package/dist/client/cpe/outline/utils.js +60 -37
  26. package/dist/client/cpe/outline/utils.ts +27 -0
  27. package/dist/client/cpe/types.js +4 -4
  28. package/dist/client/cpe/ui5-utils.js +49 -49
  29. package/dist/client/cpe/utils.js +48 -48
  30. package/dist/client/flp/WorkspaceConnector.js +84 -84
  31. package/dist/client/flp/common.js +28 -28
  32. package/dist/client/flp/enableFakeConnector.js +84 -84
  33. package/dist/client/flp/initConnectors.js +33 -33
  34. package/dist/client/flp/initRta.js +178 -178
  35. package/package.json +5 -5
@@ -1,153 +1,174 @@
1
- "use strict";
2
-
3
- sap.ui.define(["./utils"], function (___utils) {
4
- "use strict";
5
-
6
- const isEditable = ___utils["isEditable"];
7
- /**
8
- * Retrieves additional data for a given control ID.
9
- *
10
- * @param id The unique identifier of the control.
11
- * @returns An object containing the text and the technical name of the control.
12
- */
13
- function getAdditionalData(id) {
14
- const control = sap.ui.getCore().byId(id);
15
- if (!control) {
16
- return {};
17
- }
18
- const metadata = control.getMetadata();
19
- let details = {};
20
- const technicalName = metadata.getElementName();
21
- if (technicalName) {
22
- details.technicalName = technicalName;
23
- }
24
- if (metadata.getProperty('text')) {
25
- const text = control.getProperty('text');
26
- if (typeof text === 'string' && text.trim() !== '') {
27
- details.text = text;
28
- }
29
- }
30
- return details;
31
- }
32
-
33
- /**
34
- * Gets the children nodes of an aggregation type node.
35
- *
36
- * @param current The current node to retrieve children from
37
- * @returns An array of children nodes, or an empty array if none are found
38
- */
39
- function getChildren(current) {
40
- return (current.elements ?? []).flatMap(element => element.type === 'aggregation' ? element.elements ?? [] : []);
41
- }
42
-
43
- /**
44
- * Adds a new child node to the extension point's children array based on the given control ID.
45
- *
46
- * @param {string} id - The unique identifier of the control to be added as a child node.
47
- * @param {OutlineNode[]} children - The array of children nodes to which the new node will be added.
48
- */
49
- function addChildToExtensionPoint(id, children) {
50
- const {
51
- text,
52
- technicalName
53
- } = getAdditionalData(id);
54
- const editable = isEditable(id);
55
- children.push({
56
- controlId: id,
57
- controlType: technicalName ?? 'sap.ui.extensionpoint.child',
58
- name: text ?? id,
59
- visible: true,
60
- editable,
61
- children: [],
62
- hasDefaultContent: false
63
- });
64
- }
65
-
66
- /**
67
- * Transform node.
68
- *
69
- * @param input outline view node
70
- * @param scenario type of project
71
- * @param extPointIDs ids that need are filled when extension point has default content or created controls inside
72
- * @returns {Promise<OutlineNode[]>} transformed outline tree nodes
73
- */
74
- async function transformNodes(input, scenario) {
75
- const stack = [...input];
76
- const items = [];
77
- while (stack.length) {
78
- const current = stack.shift();
79
- const editable = isEditable(current?.id);
80
- const isAdp = scenario === 'ADAPTATION_PROJECT';
81
- const isExtPoint = current?.type === 'extensionPoint';
82
- if (current?.type === 'element') {
83
- const children = getChildren(current);
84
- const {
85
- text
86
- } = getAdditionalData(current.id);
87
- const technicalName = current.technicalName.split('.').slice(-1)[0];
88
- const transformedChildren = isAdp ? await handleDuplicateNodes(children, scenario) : await transformNodes(children, scenario);
89
- const node = {
90
- controlId: current.id,
91
- controlType: current.technicalName,
92
- name: text ?? technicalName,
93
- editable,
94
- visible: current.visible ?? true,
95
- children: transformedChildren
96
- };
97
- items.push(node);
98
- }
99
- if (isAdp && isExtPoint) {
100
- const {
101
- defaultContent,
102
- createdControls
103
- } = current.extensionPointInfo;
104
- let children = [];
105
- // We can combine both because there can only be either defaultContent or createdControls for one extension point node.
106
- [...defaultContent, ...createdControls].forEach(id => {
107
- addChildToExtensionPoint(id, children);
108
- });
109
- const node = {
110
- controlId: current.id,
111
- controlType: current.technicalName,
112
- name: current.name ?? '',
113
- editable,
114
- visible: current.visible ?? true,
115
- children,
116
- hasDefaultContent: defaultContent.length > 0
117
- };
118
- items.push(node);
119
- }
120
- }
121
- return items;
122
- }
123
-
124
- /**
125
- * Handles duplicate nodes that are retrieved from extension point default content and created controls,
126
- * if they exist under an extension point these controls are removed from the children array
127
- *
128
- * @param children outline view node children
129
- * @param scenario type of project
130
- * @returns transformed outline tree nodes
131
- */
132
- async function handleDuplicateNodes(children, scenario) {
133
- const extPointIDs = new Set();
134
- children.forEach(child => {
135
- if (child.type === 'extensionPoint') {
136
- const {
137
- defaultContent,
138
- createdControls
139
- } = child.extensionPointInfo;
140
- [...defaultContent, ...createdControls].forEach(id => extPointIDs.add(id));
141
- }
142
- });
143
- const uniqueChildren = children.filter(child => !extPointIDs.has(child.id));
144
- return transformNodes(uniqueChildren, scenario);
145
- }
146
- var __exports = {
147
- __esModule: true
148
- };
149
- __exports.transformNodes = transformNodes;
150
- __exports.handleDuplicateNodes = handleDuplicateNodes;
151
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define(["./utils", "sap/ui/VersionInfo"], function (___utils, VersionInfo) {
4
+ "use strict";
5
+
6
+ const isEditable = ___utils["isEditable"];
7
+ const isReuseComponent = ___utils["isReuseComponent"];
8
+ /**
9
+ * Retrieves additional data for a given control ID.
10
+ *
11
+ * @param id The unique identifier of the control.
12
+ * @returns An object containing the text and the technical name of the control.
13
+ */
14
+ function getAdditionalData(id) {
15
+ const control = sap.ui.getCore().byId(id);
16
+ if (!control) {
17
+ return {};
18
+ }
19
+ const metadata = control.getMetadata();
20
+ let details = {};
21
+ const technicalName = metadata.getElementName();
22
+ if (technicalName) {
23
+ details.technicalName = technicalName;
24
+ }
25
+ if (metadata.getProperty('text')) {
26
+ const text = control.getProperty('text');
27
+ if (typeof text === 'string' && text.trim() !== '') {
28
+ details.text = text;
29
+ }
30
+ }
31
+ return details;
32
+ }
33
+
34
+ /**
35
+ * Gets the children nodes of an aggregation type node.
36
+ *
37
+ * @param current The current node to retrieve children from
38
+ * @returns An array of children nodes, or an empty array if none are found
39
+ */
40
+ function getChildren(current) {
41
+ return (current.elements ?? []).flatMap(element => element.type === 'aggregation' ? element.elements ?? [] : []);
42
+ }
43
+
44
+ /**
45
+ * Adds a new child node to the extension point's children array based on the given control ID.
46
+ *
47
+ * @param {string} id - The unique identifier of the control to be added as a child node.
48
+ * @param {OutlineNode[]} children - The array of children nodes to which the new node will be added.
49
+ */
50
+ function addChildToExtensionPoint(id, children) {
51
+ const {
52
+ text,
53
+ technicalName
54
+ } = getAdditionalData(id);
55
+ const editable = isEditable(id);
56
+ children.push({
57
+ controlId: id,
58
+ controlType: technicalName ?? 'sap.ui.extensionpoint.child',
59
+ name: text ?? id,
60
+ visible: true,
61
+ editable,
62
+ children: [],
63
+ hasDefaultContent: false
64
+ });
65
+ }
66
+
67
+ /**
68
+ * Transform node.
69
+ *
70
+ * @param input outline view node
71
+ * @param scenario type of project
72
+ * @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
73
+ * @returns {Promise<OutlineNode[]>} transformed outline tree nodes
74
+ */
75
+ async function transformNodes(input, scenario, reuseComponentsIds) {
76
+ const stack = [...input];
77
+ const items = [];
78
+ const {
79
+ version
80
+ } = await VersionInfo.load();
81
+ const versionParts = version.split('.');
82
+ const minor = parseInt(versionParts[1], 10);
83
+ while (stack.length) {
84
+ const current = stack.shift();
85
+ const editable = isEditable(current?.id);
86
+ const isAdp = scenario === 'ADAPTATION_PROJECT';
87
+ const isExtPoint = current?.type === 'extensionPoint';
88
+ if (current?.type === 'element') {
89
+ const children = getChildren(current);
90
+ const {
91
+ text
92
+ } = getAdditionalData(current.id);
93
+ const technicalName = current.technicalName.split('.').slice(-1)[0];
94
+ const transformedChildren = isAdp ? await handleDuplicateNodes(children, scenario, reuseComponentsIds) : await transformNodes(children, scenario, reuseComponentsIds);
95
+ const node = {
96
+ controlId: current.id,
97
+ controlType: current.technicalName,
98
+ name: text ?? technicalName,
99
+ editable,
100
+ visible: current.visible ?? true,
101
+ children: transformedChildren
102
+ };
103
+ fillReuseComponents(reuseComponentsIds, current, scenario, minor);
104
+ items.push(node);
105
+ }
106
+ if (isAdp && isExtPoint) {
107
+ const {
108
+ defaultContent,
109
+ createdControls
110
+ } = current.extensionPointInfo;
111
+ let children = [];
112
+ // We can combine both because there can only be either defaultContent or createdControls for one extension point node.
113
+ [...defaultContent, ...createdControls].forEach(id => {
114
+ addChildToExtensionPoint(id, children);
115
+ });
116
+ const node = {
117
+ controlId: current.id,
118
+ controlType: current.technicalName,
119
+ name: current.name ?? '',
120
+ editable,
121
+ visible: current.visible ?? true,
122
+ children,
123
+ hasDefaultContent: defaultContent.length > 0
124
+ };
125
+ items.push(node);
126
+ }
127
+ }
128
+ return items;
129
+ }
130
+
131
+ /**
132
+ * Fill reuse components ids.
133
+ *
134
+ * @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
135
+ * @param node view node
136
+ * @param scenario type of project
137
+ * @param minorUI5Version miner UI5 version
138
+ */
139
+ function fillReuseComponents(reuseComponentsIds, node, scenario, minorUI5Version) {
140
+ if (scenario === 'ADAPTATION_PROJECT' && node?.component && isReuseComponent(node.id, minorUI5Version)) {
141
+ reuseComponentsIds.add(node.id);
142
+ }
143
+ }
144
+ /**
145
+ * Handles duplicate nodes that are retrieved from extension point default content and created controls,
146
+ * if they exist under an extension point these controls are removed from the children array
147
+ *
148
+ * @param children outline view node children
149
+ * @param scenario type of project
150
+ * @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
151
+ * @returns transformed outline tree nodes
152
+ */
153
+ async function handleDuplicateNodes(children, scenario, reuseComponentsIds) {
154
+ const extPointIDs = new Set();
155
+ children.forEach(child => {
156
+ if (child.type === 'extensionPoint') {
157
+ const {
158
+ defaultContent,
159
+ createdControls
160
+ } = child.extensionPointInfo;
161
+ [...defaultContent, ...createdControls].forEach(id => extPointIDs.add(id));
162
+ }
163
+ });
164
+ const uniqueChildren = children.filter(child => !extPointIDs.has(child.id));
165
+ return transformNodes(uniqueChildren, scenario, reuseComponentsIds);
166
+ }
167
+ var __exports = {
168
+ __esModule: true
169
+ };
170
+ __exports.transformNodes = transformNodes;
171
+ __exports.handleDuplicateNodes = handleDuplicateNodes;
172
+ return __exports;
152
173
  });
153
174
  //# sourceMappingURL=nodes.js.map
@@ -1,9 +1,8 @@
1
1
  import type { OutlineNode } from '@sap-ux-private/control-property-editor-common';
2
-
3
2
  import type { OutlineViewNode } from 'sap/ui/rta/command/OutlineService';
4
3
  import type { Scenario } from 'sap/ui/fl/Scenario';
5
-
6
- import { isEditable } from './utils';
4
+ import { isEditable, isReuseComponent } from './utils';
5
+ import VersionInfo from 'sap/ui/VersionInfo';
7
6
 
8
7
  interface AdditionalData {
9
8
  text?: string;
@@ -78,12 +77,19 @@ function addChildToExtensionPoint(id: string, children: OutlineNode[]) {
78
77
  *
79
78
  * @param input outline view node
80
79
  * @param scenario type of project
81
- * @param extPointIDs ids that need are filled when extension point has default content or created controls inside
80
+ * @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
82
81
  * @returns {Promise<OutlineNode[]>} transformed outline tree nodes
83
82
  */
84
- export async function transformNodes(input: OutlineViewNode[], scenario: Scenario): Promise<OutlineNode[]> {
83
+ export async function transformNodes(
84
+ input: OutlineViewNode[],
85
+ scenario: Scenario,
86
+ reuseComponentsIds: Set<string>
87
+ ): Promise<OutlineNode[]> {
85
88
  const stack = [...input];
86
89
  const items: OutlineNode[] = [];
90
+ const { version } = (await VersionInfo.load()) as { version: string };
91
+ const versionParts = version.split('.');
92
+ const minor = parseInt(versionParts[1], 10);
87
93
  while (stack.length) {
88
94
  const current = stack.shift();
89
95
  const editable = isEditable(current?.id);
@@ -96,8 +102,8 @@ export async function transformNodes(input: OutlineViewNode[], scenario: Scenari
96
102
  const technicalName = current.technicalName.split('.').slice(-1)[0];
97
103
 
98
104
  const transformedChildren = isAdp
99
- ? await handleDuplicateNodes(children, scenario)
100
- : await transformNodes(children, scenario);
105
+ ? await handleDuplicateNodes(children, scenario, reuseComponentsIds)
106
+ : await transformNodes(children, scenario, reuseComponentsIds);
101
107
 
102
108
  const node: OutlineNode = {
103
109
  controlId: current.id,
@@ -108,6 +114,8 @@ export async function transformNodes(input: OutlineViewNode[], scenario: Scenari
108
114
  children: transformedChildren
109
115
  };
110
116
 
117
+ fillReuseComponents(reuseComponentsIds, current, scenario, minor);
118
+
111
119
  items.push(node);
112
120
  }
113
121
 
@@ -136,15 +144,38 @@ export async function transformNodes(input: OutlineViewNode[], scenario: Scenari
136
144
  return items;
137
145
  }
138
146
 
147
+ /**
148
+ * Fill reuse components ids.
149
+ *
150
+ * @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
151
+ * @param node view node
152
+ * @param scenario type of project
153
+ * @param minorUI5Version miner UI5 version
154
+ */
155
+ function fillReuseComponents(
156
+ reuseComponentsIds: Set<string>,
157
+ node: OutlineViewNode,
158
+ scenario: Scenario,
159
+ minorUI5Version: number
160
+ ): void {
161
+ if (scenario === 'ADAPTATION_PROJECT' && node?.component && isReuseComponent(node.id, minorUI5Version)) {
162
+ reuseComponentsIds.add(node.id);
163
+ }
164
+ }
139
165
  /**
140
166
  * Handles duplicate nodes that are retrieved from extension point default content and created controls,
141
167
  * if they exist under an extension point these controls are removed from the children array
142
168
  *
143
169
  * @param children outline view node children
144
170
  * @param scenario type of project
171
+ * @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
145
172
  * @returns transformed outline tree nodes
146
173
  */
147
- export async function handleDuplicateNodes(children: OutlineViewNode[], scenario: Scenario): Promise<OutlineNode[]> {
174
+ export async function handleDuplicateNodes(
175
+ children: OutlineViewNode[],
176
+ scenario: Scenario,
177
+ reuseComponentsIds: Set<string>
178
+ ): Promise<OutlineNode[]> {
148
179
  const extPointIDs = new Set<string>();
149
180
 
150
181
  children.forEach((child: OutlineViewNode) => {
@@ -156,5 +187,5 @@ export async function handleDuplicateNodes(children: OutlineViewNode[], scenario
156
187
 
157
188
  const uniqueChildren = children.filter((child) => !extPointIDs.has(child.id));
158
189
 
159
- return transformNodes(uniqueChildren, scenario);
190
+ return transformNodes(uniqueChildren, scenario, reuseComponentsIds);
160
191
  }
@@ -1,39 +1,62 @@
1
- "use strict";
2
-
3
- sap.ui.define(["../control-data", "../utils", "sap/ui/dt/OverlayUtil", "sap/ui/dt/OverlayRegistry", "../ui5-utils"], function (___control_data, ___utils, OverlayUtil, OverlayRegistry, ___ui5_utils) {
4
- "use strict";
5
-
6
- const buildControlData = ___control_data["buildControlData"];
7
- const getRuntimeControl = ___utils["getRuntimeControl"];
8
- const getComponent = ___ui5_utils["getComponent"];
9
- const isEditable = function () {
10
- let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
11
- let editable = false;
12
- const control = sap.ui.getCore().byId(id);
13
- if (!control) {
14
- const component = getComponent(id);
15
- if (component) {
16
- return editable;
17
- }
18
- } else {
19
- let controlOverlay = OverlayRegistry.getOverlay(control);
20
- if (!controlOverlay?.getDomRef()) {
21
- //look for closest control
22
- controlOverlay = OverlayUtil.getClosestOverlayFor(control);
23
- }
24
- if (controlOverlay) {
25
- const runtimeControl = getRuntimeControl(controlOverlay);
26
- const controlData = buildControlData(runtimeControl, controlOverlay);
27
- const prop = controlData.properties.find(item => item.isEnabled === true);
28
- editable = prop !== undefined;
29
- }
30
- }
31
- return editable;
32
- };
33
- var __exports = {
34
- __esModule: true
35
- };
36
- __exports.isEditable = isEditable;
37
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define(["../control-data", "../utils", "sap/ui/dt/OverlayUtil", "sap/ui/dt/OverlayRegistry", "../ui5-utils", "sap/ui/core/Component"], function (___control_data, ___utils, OverlayUtil, OverlayRegistry, ___ui5_utils, Component) {
4
+ "use strict";
5
+
6
+ const buildControlData = ___control_data["buildControlData"];
7
+ const getRuntimeControl = ___utils["getRuntimeControl"];
8
+ const getComponent = ___ui5_utils["getComponent"];
9
+ const isEditable = function () {
10
+ let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
11
+ let editable = false;
12
+ const control = sap.ui.getCore().byId(id);
13
+ if (!control) {
14
+ const component = getComponent(id);
15
+ if (component) {
16
+ return editable;
17
+ }
18
+ } else {
19
+ let controlOverlay = OverlayRegistry.getOverlay(control);
20
+ if (!controlOverlay?.getDomRef()) {
21
+ //look for closest control
22
+ controlOverlay = OverlayUtil.getClosestOverlayFor(control);
23
+ }
24
+ if (controlOverlay) {
25
+ const runtimeControl = getRuntimeControl(controlOverlay);
26
+ const controlData = buildControlData(runtimeControl, controlOverlay);
27
+ const prop = controlData.properties.find(item => item.isEnabled === true);
28
+ editable = prop !== undefined;
29
+ }
30
+ }
31
+ return editable;
32
+ };
33
+
34
+ /**
35
+ * Function that checks if control is reuse component
36
+ *
37
+ * @param controlId id control
38
+ * @param minorUI5Version minor UI5 version
39
+ * @returns boolean if control is from reused component view
40
+ */
41
+ const isReuseComponent = (controlId, minorUI5Version) => {
42
+ if (minorUI5Version <= 114) {
43
+ return false;
44
+ }
45
+ const component = Component.getComponentById(controlId);
46
+ if (!component) {
47
+ return false;
48
+ }
49
+ const manifest = component.getManifest();
50
+ if (!manifest) {
51
+ return false;
52
+ }
53
+ return manifest['sap.app']?.type === 'component';
54
+ };
55
+ var __exports = {
56
+ __esModule: true
57
+ };
58
+ __exports.isEditable = isEditable;
59
+ __exports.isReuseComponent = isReuseComponent;
60
+ return __exports;
38
61
  });
39
62
  //# sourceMappingURL=utils.js.map
@@ -3,6 +3,8 @@ import { getRuntimeControl } from '../utils';
3
3
  import OverlayUtil from 'sap/ui/dt/OverlayUtil';
4
4
  import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
5
5
  import { getComponent } from '../ui5-utils';
6
+ import Component from 'sap/ui/core/Component';
7
+ import { Manifest } from 'sap/ui/rta/RuntimeAuthoring';
6
8
 
7
9
  export const isEditable = (id = ''): boolean => {
8
10
  let editable = false;
@@ -27,3 +29,28 @@ export const isEditable = (id = ''): boolean => {
27
29
  }
28
30
  return editable;
29
31
  };
32
+
33
+ /**
34
+ * Function that checks if control is reuse component
35
+ *
36
+ * @param controlId id control
37
+ * @param minorUI5Version minor UI5 version
38
+ * @returns boolean if control is from reused component view
39
+ */
40
+ export const isReuseComponent = (controlId: string, minorUI5Version: number): boolean => {
41
+ if(minorUI5Version <= 114) {
42
+ return false;
43
+ }
44
+
45
+ const component = Component.getComponentById(controlId);
46
+ if (!component) {
47
+ return false;
48
+ }
49
+
50
+ const manifest = component.getManifest() as Manifest;
51
+ if(!manifest) {
52
+ return false;
53
+ }
54
+
55
+ return manifest['sap.app']?.type === 'component';
56
+ };
@@ -1,6 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
5
  });
6
6
  //# sourceMappingURL=types.js.map