@openui5/sap.ui.webc.common 1.117.1 → 1.119.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.
@@ -1,76 +1,81 @@
1
- sap.ui.define(["exports", "../asset-registries/Themes", "../ManagedStyles", "./getThemeDesignerTheme", "./ThemeLoaded", "../FeaturesRegistry", "../config/ThemeRoot", "../generated/AssetParameters", "../Runtimes"], function (_exports, _Themes, _ManagedStyles, _getThemeDesignerTheme, _ThemeLoaded, _FeaturesRegistry, _ThemeRoot, _AssetParameters, _Runtimes) {
2
- "use strict";
3
-
4
- Object.defineProperty(_exports, "__esModule", {
5
- value: true
6
- });
7
- _exports.default = void 0;
8
- _getThemeDesignerTheme = _interopRequireDefault(_getThemeDesignerTheme);
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- const BASE_THEME_PACKAGE = "@ui5/webcomponents-theming";
11
- const isThemeBaseRegistered = () => {
12
- const registeredPackages = (0, _Themes.getRegisteredPackages)();
13
- return registeredPackages.has(BASE_THEME_PACKAGE);
14
- };
15
- const loadThemeBase = async theme => {
16
- if (!isThemeBaseRegistered()) {
17
- return;
1
+ sap.ui.define([
2
+ 'exports',
3
+ '../asset-registries/Themes',
4
+ '../ManagedStyles',
5
+ './getThemeDesignerTheme',
6
+ './ThemeLoaded',
7
+ '../FeaturesRegistry',
8
+ '../config/ThemeRoot',
9
+ '../generated/AssetParameters',
10
+ '../Runtimes'
11
+ ], function (_exports, _Themes, _ManagedStyles, _getThemeDesignerTheme, _ThemeLoaded, _FeaturesRegistry, _ThemeRoot, _AssetParameters, _Runtimes) {
12
+ 'use strict';
13
+ Object.defineProperty(_exports, '__esModule', { value: true });
14
+ _exports.default = void 0;
15
+ _getThemeDesignerTheme = _interopRequireDefault(_getThemeDesignerTheme);
16
+ function _interopRequireDefault(obj) {
17
+ return obj && obj.__esModule ? obj : { default: obj };
18
18
  }
19
- const cssData = await (0, _Themes.getThemeProperties)(BASE_THEME_PACKAGE, theme);
20
- if (cssData) {
21
- (0, _ManagedStyles.createOrUpdateStyle)(cssData, "data-ui5-theme-properties", BASE_THEME_PACKAGE);
22
- }
23
- };
24
- const deleteThemeBase = () => {
25
- (0, _ManagedStyles.removeStyle)("data-ui5-theme-properties", BASE_THEME_PACKAGE);
26
- };
27
- const loadComponentPackages = async theme => {
28
- const registeredPackages = (0, _Themes.getRegisteredPackages)();
29
- const packagesStylesPromises = [...registeredPackages].map(async packageName => {
30
- if (packageName === BASE_THEME_PACKAGE) {
31
- return;
32
- }
33
- const cssData = await (0, _Themes.getThemeProperties)(packageName, theme);
34
- if (cssData) {
35
- (0, _ManagedStyles.createOrUpdateStyle)(cssData, `data-ui5-component-properties-${(0, _Runtimes.getCurrentRuntimeIndex)()}`, packageName);
36
- }
37
- });
38
- return Promise.all(packagesStylesPromises);
39
- };
40
- const detectExternalTheme = async theme => {
41
- // If theme designer theme is detected, use this
42
- const extTheme = (0, _getThemeDesignerTheme.default)();
43
- if (extTheme) {
44
- return extTheme;
45
- }
46
- // If OpenUI5Support is enabled, try to find out if it loaded variables
47
- const openUI5Support = (0, _FeaturesRegistry.getFeature)("OpenUI5Support");
48
- if (openUI5Support) {
49
- const varsLoaded = openUI5Support.cssVariablesLoaded();
50
- if (varsLoaded) {
51
- return {
52
- themeName: openUI5Support.getConfigurationSettingsObject()?.theme,
53
- baseThemeName: "" // baseThemeName is only relevant for custom themes
54
- };
55
- }
56
- } else if ((0, _ThemeRoot.getThemeRoot)()) {
57
- await (0, _ThemeRoot.attachCustomThemeStylesToHead)(theme);
58
- return (0, _getThemeDesignerTheme.default)();
59
- }
60
- };
61
- const applyTheme = async theme => {
62
- const extTheme = await detectExternalTheme(theme);
63
- // Only load theme_base properties if there is no externally loaded theme, or there is, but it is not being loaded
64
- if (!extTheme || theme !== extTheme.themeName) {
65
- await loadThemeBase(theme);
66
- } else {
67
- deleteThemeBase();
68
- }
69
- // Always load component packages properties. For non-registered themes, try with the base theme, if any
70
- const packagesTheme = (0, _Themes.isThemeRegistered)(theme) ? theme : extTheme && extTheme.baseThemeName;
71
- await loadComponentPackages(packagesTheme || _AssetParameters.DEFAULT_THEME);
72
- (0, _ThemeLoaded.fireThemeLoaded)(theme);
73
- };
74
- var _default = applyTheme;
75
- _exports.default = _default;
19
+ const BASE_THEME_PACKAGE = '@ui5/webcomponents-theming';
20
+ const isThemeBaseRegistered = () => {
21
+ const registeredPackages = (0, _Themes.getRegisteredPackages)();
22
+ return registeredPackages.has(BASE_THEME_PACKAGE);
23
+ };
24
+ const loadThemeBase = async theme => {
25
+ if (!isThemeBaseRegistered()) {
26
+ return;
27
+ }
28
+ const cssData = await (0, _Themes.getThemeProperties)(BASE_THEME_PACKAGE, theme);
29
+ if (cssData) {
30
+ (0, _ManagedStyles.createOrUpdateStyle)(cssData, 'data-ui5-theme-properties', BASE_THEME_PACKAGE);
31
+ }
32
+ };
33
+ const deleteThemeBase = () => {
34
+ (0, _ManagedStyles.removeStyle)('data-ui5-theme-properties', BASE_THEME_PACKAGE);
35
+ };
36
+ const loadComponentPackages = async theme => {
37
+ const registeredPackages = (0, _Themes.getRegisteredPackages)();
38
+ const packagesStylesPromises = [...registeredPackages].map(async packageName => {
39
+ if (packageName === BASE_THEME_PACKAGE) {
40
+ return;
41
+ }
42
+ const cssData = await (0, _Themes.getThemeProperties)(packageName, theme);
43
+ if (cssData) {
44
+ (0, _ManagedStyles.createOrUpdateStyle)(cssData, `data-ui5-component-properties-${ (0, _Runtimes.getCurrentRuntimeIndex)() }`, packageName);
45
+ }
46
+ });
47
+ return Promise.all(packagesStylesPromises);
48
+ };
49
+ const detectExternalTheme = async theme => {
50
+ const extTheme = (0, _getThemeDesignerTheme.default)();
51
+ if (extTheme) {
52
+ return extTheme;
53
+ }
54
+ const openUI5Support = (0, _FeaturesRegistry.getFeature)('OpenUI5Support');
55
+ if (openUI5Support) {
56
+ const varsLoaded = openUI5Support.cssVariablesLoaded();
57
+ if (varsLoaded) {
58
+ return {
59
+ themeName: openUI5Support.getConfigurationSettingsObject()?.theme,
60
+ baseThemeName: ''
61
+ };
62
+ }
63
+ } else if ((0, sap.ui.require('sap/ui/webc/common/thirdparty/base/config/ThemeRoot').getThemeRoot)()) {
64
+ await (0, sap.ui.require('sap/ui/webc/common/thirdparty/base/config/ThemeRoot').attachCustomThemeStylesToHead)(theme);
65
+ return (0, _getThemeDesignerTheme.default)();
66
+ }
67
+ };
68
+ const applyTheme = async theme => {
69
+ const extTheme = await detectExternalTheme(theme);
70
+ if (!extTheme || theme !== extTheme.themeName) {
71
+ await loadThemeBase(theme);
72
+ } else {
73
+ deleteThemeBase();
74
+ }
75
+ const packagesTheme = (0, _Themes.isThemeRegistered)(theme) ? theme : extTheme && extTheme.baseThemeName;
76
+ await loadComponentPackages(packagesTheme || _AssetParameters.DEFAULT_THEME);
77
+ (0, _ThemeLoaded.fireThemeLoaded)(theme);
78
+ };
79
+ var _default = applyTheme;
80
+ _exports.default = _default;
76
81
  });
package/ui5.yaml CHANGED
@@ -66,6 +66,13 @@ customConfiguration:
66
66
  "^@ui5\/webcomponents-base\/dist\/(.*?).js$": "sap/ui/webc/common/thirdparty/base/$1"
67
67
  reverseAliases:
68
68
  "^/resources/sap/ui/webc/common/thirdparty/base/(.*?)$": "@ui5/webcomponents-base/dist/$1"
69
+ cyclicDependencies:
70
+ "sap/ui/webc/common/thirdparty/base/config/Theme":
71
+ - "sap/ui/webc/common/thirdparty/base/theming/applyTheme"
72
+ "sap/ui/webc/common/thirdparty/base/theming/applyTheme":
73
+ - "sap/ui/webc/common/thirdparty/base/config/ThemeRoot"
74
+ "sap/ui/webc/common/thirdparty/base/config/ThemeRoot":
75
+ - "sap/ui/webc/common/thirdparty/base/config/Theme"
69
76
  inputPath: "dist/"
70
77
  outputPath: "src/sap/ui/webc/common/thirdparty/base/"
71
78
  inputPathFilters:
@@ -1,320 +0,0 @@
1
- /*!
2
- * OpenUI5
3
- * (c) Copyright 2009-2023 SAP SE or an SAP affiliate company.
4
- * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
- */
6
-
7
- // Provides default renderer for all web components
8
- sap.ui.define([
9
- "sap/ui/core/Element",
10
- "sap/ui/core/Control",
11
- "sap/base/strings/hyphenate"
12
- ],
13
- function(Element, Control, hyphenate) {
14
- "use strict";
15
-
16
- /**
17
- * WebComponent renderer.
18
- * @namespace
19
- * @experimental Since 1.92.0 The API might change. It is not intended for productive usage yet!
20
- */
21
- var WebComponentRenderer = {
22
- apiVersion: 2
23
- };
24
-
25
- /**
26
- * Renders the HTML for the given control, using the provided {@link sap.ui.core.RenderManager}.
27
- * @param {sap.ui.core.RenderManager} oRm the RenderManager that can be used for writing to the Render-Output-Buffer
28
- * @param {sap.ui.webc.common.WebComponent} oWebComponent an object representation of the control that should be rendered
29
- */
30
- WebComponentRenderer.render = function(oRm, oWebComponent){
31
- var sTag = oWebComponent.getMetadata().getTag();
32
-
33
- // Opening custom element tag
34
- oRm.openStart(sTag, oWebComponent);
35
-
36
- // Properties with mapping="attribute"
37
- this.renderAttributeProperties(oRm, oWebComponent);
38
- // Properties with mapping="style"
39
- this.renderStyleProperties(oRm, oWebComponent);
40
- // Properties, managed by associations
41
- this.renderAssociationProperties(oRm, oWebComponent);
42
- // Tooltip aggregation
43
- this.renderTooltipAggregation(oRm, oWebComponent);
44
- // Hook for customization
45
- this.customRenderInOpeningTag(oRm, oWebComponent);
46
- // Attributes/Styles that the component sets internally
47
- this.preserveUnmanagedAttributes(oRm, oWebComponent);
48
- // Styles that the component sets internally
49
- this.preserveUnmanagedStyles(oRm, oWebComponent);
50
-
51
- oRm.openEnd();
52
-
53
- // Properties with mapping="textContent"
54
- this.renderTextContentProperties(oRm, oWebComponent);
55
- // Properties with mapping="slot"
56
- this.renderSlotProperties(oRm, oWebComponent);
57
- // Aggregations
58
- this.renderAggregations(oRm, oWebComponent);
59
- // Hook for customization (additional children)
60
- this.customRenderInsideTag(oRm, oWebComponent);
61
-
62
- // Closing custom element tag
63
- oRm.close(sTag);
64
- };
65
-
66
- /**
67
- * Renders attributes, based on the control's properties
68
- * @private
69
- * @param oRm
70
- * @param oWebComponent
71
- */
72
- WebComponentRenderer.renderAttributeProperties = function(oRm, oWebComponent) {
73
- var oAttrProperties = oWebComponent.getMetadata().getPropertiesByMapping("attribute");
74
- var aPropsToAlwaysSet = ["enabled"]; // some properties can be initial and still have a non-default value due to side effects (e.g. EnabledPropagator)
75
- for (var sPropName in oAttrProperties) {
76
- if (oWebComponent.isPropertyInitial(sPropName) && !aPropsToAlwaysSet.includes(sPropName)) {
77
- continue; // do not set attributes for properties that were not explicitly set or bound
78
- }
79
-
80
- var oPropData = oAttrProperties[sPropName];
81
- var vPropValue = oPropData.get(oWebComponent);
82
- if (oPropData.type === "object" || typeof vPropValue === "object") {
83
- continue; // Properties of type "object" and custom-type properties with object values are set during onAfterRendering
84
- }
85
-
86
- var sAttrName = oPropData._sMapTo ? oPropData._sMapTo : hyphenate(sPropName);
87
- if (oPropData._fnMappingFormatter) {
88
- vPropValue = oWebComponent[oPropData._fnMappingFormatter].call(oWebComponent, vPropValue);
89
- }
90
-
91
- if (oPropData.type === "boolean") {
92
- if (vPropValue) {
93
- oRm.attr(sAttrName, "");
94
- }
95
- } else {
96
- if (vPropValue != null) {
97
- oRm.attr(sAttrName, vPropValue);
98
- }
99
- }
100
- }
101
- };
102
-
103
- /**
104
- * Preserves attributes that the component set on itself internally (such as private attributes and the attribute that mimics the tag, e.g. "ui5-button")
105
- * This is necessary as otherwise Patcher.js will remove them upon each re-rendering
106
- * @private
107
- * @param oRm
108
- * @param oWebComponent
109
- */
110
- WebComponentRenderer.preserveUnmanagedAttributes = function(oRm, oWebComponent) {
111
- var oDomRef = oWebComponent.getDomRef();
112
- if (!oDomRef) {
113
- return; // First rendering - the unmanaged attributes haven't been set yet
114
- }
115
-
116
- var aAttributes = oDomRef.getAttributeNames();
117
- var aSkipList = ["id", "data-sap-ui", "style", "class", "__is-busy"];
118
- aAttributes.forEach(function(sAttr) {
119
- if (aSkipList.indexOf(sAttr) !== -1) {
120
- return; // Skip attributes, set by the framework
121
- }
122
-
123
- if (oWebComponent.getMetadata().isManagedAttribute(sAttr)) {
124
- return;
125
- }
126
-
127
- var sValue = oDomRef.getAttribute(sAttr); // Repeat the value from DOM
128
- if (sValue !== null) {
129
- oRm.attr(sAttr, sValue);
130
- }
131
- });
132
- };
133
-
134
- /**
135
- * Preserves styles that the component set on itself internally (such as position top, left and CSS Variables)
136
- * This is necessary as otherwise Patcher.js will remove them upon each re-rendering
137
- * @private
138
- * @param oRm
139
- * @param oWebComponent
140
- */
141
- WebComponentRenderer.preserveUnmanagedStyles = function(oRm, oWebComponent) {
142
- var oDomRef = oWebComponent.getDomRef();
143
- if (!oDomRef) {
144
- return; // First rendering - the unmanaged styles haven't been set yet
145
- }
146
- var aSetStyles = Array.prototype.slice.apply(oDomRef.style);
147
- if (aSetStyles.length === 0) {
148
- return; // No styles set at all
149
- }
150
-
151
- var oStyleProperties = oWebComponent.getMetadata().getPropertiesByMapping("style");
152
- var aManagedStyles = [];
153
- for (var sPropName in oStyleProperties) {
154
- var oPropData = oStyleProperties[sPropName];
155
- var sStyleName = oPropData._sMapTo ? oPropData._sMapTo : hyphenate(sPropName);
156
- aManagedStyles.push(sStyleName);
157
- }
158
-
159
- aSetStyles.forEach(function(sStyle) {
160
- if (aManagedStyles.indexOf(sStyle) !== -1) {
161
- return; // Do not preserve any managed styles
162
- }
163
- var sValue = sStyle.startsWith("--") ? window.getComputedStyle(oDomRef).getPropertyValue(sStyle) : oDomRef.style[sStyle]; // CSS Values can only be read from getComputedStyle
164
- oRm.style(sStyle, sValue);
165
- });
166
- };
167
-
168
- /**
169
- * Renders styles, based on the control's properties
170
- * @private
171
- * @param oRm
172
- * @param oWebComponent
173
- */
174
- WebComponentRenderer.renderStyleProperties = function(oRm, oWebComponent) {
175
- var oStyleProperties = oWebComponent.getMetadata().getPropertiesByMapping("style");
176
- for (var sPropName in oStyleProperties) {
177
- var oPropData = oStyleProperties[sPropName];
178
- var sStyleName = oPropData._sMapTo ? oPropData._sMapTo : hyphenate(sPropName);
179
- var vPropValue = oPropData.get(oWebComponent);
180
- if (oPropData._fnMappingFormatter) {
181
- vPropValue = oWebComponent[oPropData._fnMappingFormatter].call(oWebComponent, vPropValue);
182
- }
183
-
184
- if (vPropValue != null) {
185
- oRm.style(sStyleName, vPropValue);
186
- }
187
- }
188
- };
189
-
190
- /**
191
- * Renders properties, controlled by associations
192
- * @private
193
- * @param oRm
194
- * @param oWebComponent
195
- */
196
- WebComponentRenderer.renderAssociationProperties = function(oRm, oWebComponent) {
197
- var oAssociations = oWebComponent.getMetadata().getAssociationsWithMapping();
198
- for (var sAssocName in oAssociations) {
199
- var oAssocData = oAssociations[sAssocName];
200
- var vAssocValue = oAssocData.get(oWebComponent);
201
- var sAttrName = hyphenate(oAssocData._sMapTo); // The name of the attribute to be set with the association's ID value
202
- if (oAssocData._fnMappingFormatter) {
203
- vAssocValue = oWebComponent[oAssocData._fnMappingFormatter].call(oWebComponent, vAssocValue);
204
- }
205
-
206
- if (!oAssocData.multiple && vAssocValue && typeof vAssocValue === "object") {
207
- vAssocValue = vAssocValue.getId(); // The value will be the control ID, held by the association
208
- }
209
-
210
- if (vAssocValue) { // Only set the property, if the association is set
211
- oRm.attr(sAttrName, vAssocValue);
212
- }
213
- }
214
- };
215
-
216
- /**
217
- * Transforms the tooltip aggregation to a tooltip attribute - components that support this attribute will use it
218
- * @private
219
- * @param oRm
220
- * @param oWebComponent
221
- */
222
- WebComponentRenderer.renderTooltipAggregation = function(oRm, oWebComponent) {
223
- var sTooltipText = oWebComponent.getTooltip_Text();
224
- if (sTooltipText) {
225
- oRm.attr("tooltip", sTooltipText);
226
- }
227
- };
228
-
229
- /**
230
- * Renders text inside the component, if it has a property of type textContent
231
- * Normally a single property of this type is expected (such as button text), but if more than one are set, they are all rendered
232
- * @private
233
- * @param oRm
234
- * @param oWebComponent
235
- */
236
- WebComponentRenderer.renderTextContentProperties = function(oRm, oWebComponent) {
237
- var oTextContentProperties = oWebComponent.getMetadata().getPropertiesByMapping("textContent");
238
- for (var sPropName in oTextContentProperties) {
239
- var oPropData = oTextContentProperties[sPropName];
240
- var vPropValue = oPropData.get(oWebComponent);
241
- if (oPropData._fnMappingFormatter) {
242
- vPropValue = oWebComponent[oPropData._fnMappingFormatter].call(oWebComponent, vPropValue);
243
- }
244
-
245
- oRm.text(vPropValue);
246
- }
247
- };
248
-
249
- /**
250
- * Renders properties as slotted text inside a div/span or another tag
251
- * This is mostly useful for value state message as UI5 Web Components get the value state message as slotted text
252
- * @private
253
- * @param oRm
254
- * @param oWebComponent
255
- */
256
- WebComponentRenderer.renderSlotProperties = function(oRm, oWebComponent) {
257
- var oSlotProperties = oWebComponent.getMetadata().getPropertiesByMapping("slot");
258
- for (var sPropName in oSlotProperties) {
259
- var oPropData = oSlotProperties[sPropName];
260
- var vPropValue = oPropData.get(oWebComponent);
261
- if (oPropData._fnMappingFormatter) {
262
- vPropValue = oWebComponent[oPropData._fnMappingFormatter].call(oWebComponent, vPropValue);
263
- }
264
- var sTag = oPropData._sMapTo ? oPropData._sMapTo : "span";
265
-
266
- if (vPropValue) {
267
- oRm.openStart(sTag);
268
- oRm.attr("slot", sPropName);
269
- oRm.openEnd();
270
- oRm.text(vPropValue);
271
- oRm.close(sTag);
272
- }
273
- }
274
- };
275
-
276
- /**
277
- * Render children.
278
- * Note: for each child, RenderManager.js will set the "slot" attribute automatically
279
- * @private
280
- * @param oRm
281
- * @param oWebComponent
282
- */
283
- WebComponentRenderer.renderAggregations = function(oRm, oWebComponent) {
284
- var oAggregations = oWebComponent.getMetadata().getAllAggregations();
285
- for (var sAggName in oAggregations) {
286
- if (Element.getMetadata().getAggregations().hasOwnProperty(sAggName) || Control.getMetadata().getAggregations().hasOwnProperty(sAggName)) {
287
- continue; // Skip aggregations, derived from Element.js / Control.js such as dependents and layoutData
288
- }
289
-
290
- var aggData = oAggregations[sAggName];
291
- var aggValue = aggData.get(oWebComponent);
292
-
293
- if (aggData.multiple) {
294
- aggValue.forEach(oRm.renderControl, oRm);
295
- } else {
296
- if (aggValue) {
297
- oRm.renderControl(aggValue);
298
- }
299
- }
300
- }
301
- };
302
-
303
- /**
304
- * Hook. For future use.
305
- * @protected
306
- * @param oRm
307
- * @param oWebComponent
308
- */
309
- WebComponentRenderer.customRenderInOpeningTag = function(oRm, oWebComponent) {};
310
-
311
- /**
312
- * Hook. For future use.
313
- * @param oRm
314
- * @param oWebComponent
315
- */
316
- WebComponentRenderer.customRenderInsideTag = function(oRm, oWebComponent) {};
317
-
318
- return WebComponentRenderer;
319
-
320
- });