@sap/ux-ui5-tooling 1.24.0 → 1.25.0

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.
@@ -169,14 +169,188 @@ sap.ui.define(["open/ux/preview/client/thirdparty/@sap-ux-private/control-proper
169
169
  return rawValue;
170
170
  }
171
171
  }
172
+ /**
173
+ * Build the documentation object for a configuration (manifest) property.
174
+ *
175
+ * @param property - manifest property
176
+ * @returns PropertyDocumentation
177
+ */
178
+ function buildConfigPropertyDocumentation(property) {
179
+ const defValue = ['undefined', 'null'].includes(String(property.defaultValue)) ? '-' : String(property.defaultValue);
180
+ return {
181
+ description: property.description,
182
+ propertyName: property.id,
183
+ type: property.type,
184
+ defaultValue: defValue || '-'
185
+ };
186
+ }
187
+
188
+ /**
189
+ * Process a manifest configuration property.
190
+ *
191
+ * @param property - manifest property
192
+ * @param control - ui5 control
193
+ * @returns ProcessedProperty or undefined if the property should be skipped
194
+ */
195
+ function processConfigProperty(property, control) {
196
+ const analyzedType = analyzeManifestProperty(property);
197
+ if (!analyzedType || property?.restrictedTo?.length && !property?.restrictedTo?.includes(getV4PageType(control))) {
198
+ return undefined;
199
+ }
200
+ return {
201
+ analyzedType,
202
+ isEnabled: true,
203
+ value: property.value,
204
+ propertyType: PropertyType.Configuration,
205
+ docu: buildConfigPropertyDocumentation(property)
206
+ };
207
+ }
208
+
209
+ /**
210
+ * Process a UI5 control property.
211
+ *
212
+ * @param property - control metadata property
213
+ * @param control - ui5 control
214
+ * @param hasStableId - whether the control has a stable ID
215
+ * @param controlProperties - overlay design-time property config
216
+ * @param controlOverlay - element overlay
217
+ * @returns ProcessedProperty or undefined if the property should be skipped
218
+ */
219
+ function processControlProperty(property, control, hasStableId, controlProperties, controlOverlay) {
220
+ const analyzedType = analyzePropertyType(property);
221
+ if (!analyzedType) {
222
+ return undefined;
223
+ }
224
+ const ignore = controlProperties?.[property.name]?.ignore ?? false;
225
+
226
+ //updating i18n text for the control if bindingInfo has bindingString
227
+ const controlNewData = {
228
+ id: control.getId(),
229
+ name: property.name,
230
+ newValue: control.getProperty(property.name)
231
+ };
232
+ const bindingInfo = control.getBindingInfo(controlNewData.name);
233
+ if (bindingInfo?.bindingString !== undefined) {
234
+ controlNewData.newValue = bindingInfo.bindingString;
235
+ }
236
+
237
+ // A property is enabled if:
238
+ // 1. The property supports changes
239
+ // 2. The control has stable ID
240
+ // 3. It is not configured to be ignored in design time
241
+ // 4. And control overlay is selectable
242
+ return {
243
+ analyzedType,
244
+ isEnabled: isControlEnabled(analyzedType, hasStableId, ignore, controlOverlay),
245
+ value: normalizeObjectPropertyValue(controlNewData.newValue),
246
+ propertyType: PropertyType.ControlProperty
247
+ };
248
+ }
249
+
250
+ /**
251
+ * Build a ControlProperty entry from an analyzed property.
252
+ *
253
+ * @param property - the raw property (manifest or control metadata)
254
+ * @param processed - the processed property data
255
+ * @param selectedControlName - name of the UI5 control class
256
+ * @returns ControlProperty or undefined if the type is not supported
257
+ */
258
+ function buildPropertyEntry(property, processed, selectedControlName) {
259
+ const {
260
+ analyzedType,
261
+ isEnabled,
262
+ value,
263
+ propertyType,
264
+ docu
265
+ } = processed;
266
+ const isIcon = testIconPattern(property.name) && selectedControlName !== 'sap.m.Image' && analyzedType.ui5Type === 'sap.ui.core.URI';
267
+ const ui5Type = analyzedType.ui5Type || undefined;
268
+ const readableName = convertCamelCaseToPascalCase(property.name);
269
+ const docuSpread = docu ? {
270
+ documentation: docu
271
+ } : {};
272
+ switch (analyzedType.primitiveType) {
273
+ case 'enum':
274
+ {
275
+ const values = analyzedType.enumValues ?? {};
276
+ const options = Object.keys(values).map(key => ({
277
+ key,
278
+ text: values[key]
279
+ }));
280
+ return {
281
+ type: STRING_VALUE_TYPE,
282
+ editor: DROPDOWN_EDITOR_TYPE,
283
+ propertyType,
284
+ name: property.name,
285
+ readableName,
286
+ value: value,
287
+ isEnabled,
288
+ ui5Type,
289
+ options,
290
+ ...docuSpread
291
+ };
292
+ }
293
+ case 'string':
294
+ return {
295
+ type: STRING_VALUE_TYPE,
296
+ editor: INPUT_EDITOR_TYPE,
297
+ propertyType,
298
+ name: property.name,
299
+ readableName,
300
+ value: value,
301
+ isEnabled,
302
+ isIcon,
303
+ ui5Type,
304
+ ...docuSpread
305
+ };
306
+ case 'int':
307
+ return {
308
+ type: INTEGER_VALUE_TYPE,
309
+ editor: INPUT_EDITOR_TYPE,
310
+ propertyType,
311
+ name: property.name,
312
+ readableName,
313
+ value: value,
314
+ isEnabled,
315
+ ui5Type,
316
+ ...docuSpread
317
+ };
318
+ case 'float':
319
+ return {
320
+ type: FLOAT_VALUE_TYPE,
321
+ editor: INPUT_EDITOR_TYPE,
322
+ propertyType,
323
+ name: property.name,
324
+ readableName,
325
+ value: value,
326
+ isEnabled,
327
+ ui5Type,
328
+ ...docuSpread
329
+ };
330
+ case 'boolean':
331
+ return {
332
+ type: BOOLEAN_VALUE_TYPE,
333
+ editor: CHECKBOX_EDITOR_TYPE,
334
+ propertyType,
335
+ name: property.name,
336
+ readableName,
337
+ value: value,
338
+ isEnabled,
339
+ ui5Type,
340
+ ...docuSpread
341
+ };
342
+ default:
343
+ return undefined;
344
+ }
345
+ }
346
+
172
347
  /**
173
348
  * Build control data.
174
349
  *
175
350
  * @param control - ui5 control
176
351
  * @param changeService - Changeservice for change stack event handling.
177
352
  * @param controlOverlay - element overlay
178
- * @param includeDocumentation - include documentation flag
179
- * @returns Promise<Control>
353
+ * @returns Control
180
354
  */
181
355
  function buildControlData(control, changeService, controlOverlay) {
182
356
  const controlMetadata = control.getMetadata();
@@ -185,174 +359,25 @@ sap.ui.define(["open/ux/preview/client/thirdparty/@sap-ux-private/control-proper
185
359
  const overlayData = controlOverlay?.getDesignTimeMetadata().getData();
186
360
  const controlProperties = controlOverlay ? overlayData?.properties : undefined;
187
361
  const manifestProperties = getManifestProperties(control, changeService, controlOverlay);
188
- // Add the control's properties/manifest properties
189
362
  const allProperties = {
190
363
  ...controlMetadata.getAllProperties(),
191
364
  ...manifestProperties
192
365
  };
193
- let propertyType;
194
- const propertyNames = Object.keys(allProperties);
195
366
  const properties = [];
196
- for (const propertyName of propertyNames) {
367
+ for (const propertyName of Object.keys(allProperties)) {
197
368
  const property = allProperties[propertyName];
198
- let analyzedType;
199
- let isEnabled;
200
- let value;
201
- if (property && 'configuration' in property) {
202
- propertyType = PropertyType.Configuration;
203
- analyzedType = analyzeManifestProperty(property);
204
- if (!analyzedType || property?.restrictedTo?.length && !property?.restrictedTo?.includes(getV4PageType(control))) {
205
- continue;
206
- }
207
- isEnabled = true;
208
- value = property.value;
209
- } else {
210
- propertyType = PropertyType.ControlProperty;
211
- // the default behavior is that the property is enabled
212
- // meaning it's not ignored during design time
213
- analyzedType = analyzePropertyType(property);
214
- if (!analyzedType) {
215
- continue;
216
- }
217
- let ignore = false;
218
- if (controlProperties?.[property.name]) {
219
- // check whether the property should be ignored in design time or not
220
- // if it's 'undefined' then it's not considered when building isEnabled because it's 'true'
221
- ignore = controlProperties[property.name].ignore;
222
- }
223
-
224
- //updating i18n text for the control if bindingInfo has bindingString
225
- const controlNewData = {
226
- id: control.getId(),
227
- name: property.name,
228
- newValue: control.getProperty(property.name)
229
- };
230
- const bindingInfo = control.getBindingInfo(controlNewData.name);
231
- if (bindingInfo?.bindingString !== undefined) {
232
- controlNewData.newValue = bindingInfo.bindingString;
233
- }
234
-
235
- // A property is enabled if:
236
- // 1. The property supports changes
237
- // 2. The control has stable ID
238
- // 3. It is not configured to be ignored in design time
239
- // 4. And control overlay is selectable
240
- isEnabled = isControlEnabled(analyzedType, hasStableId, ignore, controlOverlay);
241
- value = normalizeObjectPropertyValue(controlNewData.newValue);
242
- }
243
- const isIcon = testIconPattern(property.name) && selectedControlName !== 'sap.m.Image' && analyzedType.ui5Type === 'sap.ui.core.URI';
244
- const ui5Type = analyzedType.ui5Type || undefined;
245
- const readableName = convertCamelCaseToPascalCase(property.name);
246
- let docu;
247
- if ('configuration' in property) {
248
- const defValue = ['undefined', 'null'].includes(String(property.defaultValue)) ? '-' : String(property.defaultValue);
249
- docu = {
250
- description: property.description,
251
- propertyName: property.id,
252
- type: property.type,
253
- defaultValue: defValue || '-'
254
- };
369
+ const processed = property && 'configuration' in property ? processConfigProperty(property, control) : processControlProperty(property, control, hasStableId, controlProperties, controlOverlay);
370
+ if (!processed) {
371
+ continue;
255
372
  }
256
- switch (analyzedType.primitiveType) {
257
- case 'enum':
258
- {
259
- const values = analyzedType.enumValues ?? {};
260
- const options = Object.keys(values).map(key => ({
261
- key,
262
- text: values[key]
263
- }));
264
- properties.push({
265
- type: STRING_VALUE_TYPE,
266
- editor: DROPDOWN_EDITOR_TYPE,
267
- propertyType,
268
- name: property.name,
269
- readableName,
270
- value: value,
271
- isEnabled,
272
- ui5Type,
273
- options,
274
- ...(docu && {
275
- documentation: docu
276
- })
277
- });
278
- break;
279
- }
280
- case 'string':
281
- {
282
- properties.push({
283
- type: STRING_VALUE_TYPE,
284
- editor: INPUT_EDITOR_TYPE,
285
- propertyType,
286
- name: property.name,
287
- readableName,
288
- value: value,
289
- isEnabled,
290
- isIcon,
291
- ui5Type,
292
- ...(docu && {
293
- documentation: docu
294
- })
295
- });
296
- break;
297
- }
298
- case 'int':
299
- {
300
- properties.push({
301
- type: INTEGER_VALUE_TYPE,
302
- editor: INPUT_EDITOR_TYPE,
303
- propertyType,
304
- name: property.name,
305
- readableName,
306
- value: value,
307
- isEnabled,
308
- ui5Type,
309
- ...(docu && {
310
- documentation: docu
311
- })
312
- });
313
- break;
314
- }
315
- case 'float':
316
- {
317
- properties.push({
318
- type: FLOAT_VALUE_TYPE,
319
- editor: INPUT_EDITOR_TYPE,
320
- propertyType,
321
- name: property.name,
322
- readableName,
323
- value: value,
324
- isEnabled,
325
- ui5Type,
326
- ...(docu && {
327
- documentation: docu
328
- })
329
- });
330
- break;
331
- }
332
- case 'boolean':
333
- {
334
- properties.push({
335
- type: BOOLEAN_VALUE_TYPE,
336
- editor: CHECKBOX_EDITOR_TYPE,
337
- propertyType,
338
- name: property.name,
339
- readableName,
340
- value: value,
341
- isEnabled,
342
- ui5Type,
343
- ...(docu && {
344
- documentation: docu
345
- })
346
- });
347
- break;
348
- }
373
+ const entry = buildPropertyEntry(property, processed, selectedControlName);
374
+ if (entry) {
375
+ properties.push(entry);
349
376
  }
350
377
  }
351
378
  return {
352
379
  id: control.getId(),
353
- //the id of the underlying control/aggregation
354
380
  type: selectedControlName,
355
- //the name of the ui5 class of the control/aggregation
356
381
  properties: [...properties].sort((a, b) => a.name > b.name ? 1 : -1),
357
382
  name: selectedControlName
358
383
  };