@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.
- package/THIRDPARTY.txt +2 -2
- package/package.json +2 -2
- package/src/sap/ui/webc/common/.library +1 -1
- package/src/sap/ui/webc/common/WebComponent.js +106 -466
- package/src/sap/ui/webc/common/WebComponentMetadata.js +33 -245
- package/src/sap/ui/webc/common/library.js +3 -3
- package/src/sap/ui/webc/common/thirdparty/base/config/Theme.js +50 -79
- package/src/sap/ui/webc/common/thirdparty/base/config/ThemeRoot.js +45 -68
- package/src/sap/ui/webc/common/thirdparty/base/theming/applyTheme.js +79 -74
- package/ui5.yaml +7 -0
- package/src/sap/ui/webc/common/WebComponentRenderer.js +0 -320
@@ -6,248 +6,36 @@
|
|
6
6
|
|
7
7
|
// Provides class sap.ui.webc.common.WebComponentMetadata
|
8
8
|
sap.ui.define([
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
// mapping validation function
|
43
|
-
var fnValidateType = function (sType) {
|
44
|
-
return MAPPING_TYPES.includes(sType) ? sType : MAPPING_TYPES[0];
|
45
|
-
};
|
46
|
-
|
47
|
-
// Enrich property factory
|
48
|
-
var OriginalProperty = ElementMetadata.prototype.metaFactoryProperty;
|
49
|
-
var WebComponentProperty = function(oClass, name, info) {
|
50
|
-
OriginalProperty.apply(this, arguments);
|
51
|
-
|
52
|
-
if (!info.mapping || typeof info.mapping === "string") {
|
53
|
-
this._sMapping = fnValidateType(info.mapping);
|
54
|
-
} else if (typeof info.mapping === "object") {
|
55
|
-
this._sMapping = fnValidateType(info.mapping.type);
|
56
|
-
this._sMapTo = info.mapping.to;
|
57
|
-
this._fnMappingFormatter = info.mapping.formatter;
|
58
|
-
}
|
59
|
-
};
|
60
|
-
WebComponentProperty.prototype = Object.create(OriginalProperty.prototype);
|
61
|
-
WebComponentProperty.prototype.constructor = WebComponentProperty;
|
62
|
-
WebComponentMetadata.prototype.metaFactoryProperty = WebComponentProperty;
|
63
|
-
|
64
|
-
// Enrich aggregation factory
|
65
|
-
var OriginalAggregation = ElementMetadata.prototype.metaFactoryAggregation;
|
66
|
-
var WebComponentAggregation = function(oClass, name, info) {
|
67
|
-
OriginalAggregation.apply(this, arguments);
|
68
|
-
this._sSlot = info.slot || "";
|
69
|
-
};
|
70
|
-
WebComponentAggregation.prototype = Object.create(OriginalAggregation.prototype);
|
71
|
-
WebComponentAggregation.prototype.constructor = WebComponentAggregation;
|
72
|
-
WebComponentMetadata.prototype.metaFactoryAggregation = WebComponentAggregation;
|
73
|
-
|
74
|
-
// Enrich association factory
|
75
|
-
var OriginalAssociation = ElementMetadata.prototype.metaFactoryAssociation;
|
76
|
-
var WebComponentAssociation = function(oClass, name, info) {
|
77
|
-
OriginalAssociation.apply(this, arguments);
|
78
|
-
if (!info.mapping || typeof info.mapping !== "object") {
|
79
|
-
this._sMapping = ""; // For associations, "mapping" must be an object, because "to" is required
|
80
|
-
} else {
|
81
|
-
this._sMapping = "property"; // Associations map only to properties, no matter what is set, it's always "property" mapping
|
82
|
-
this._sMapTo = info.mapping.to; // The property, to which the association is related
|
83
|
-
this._fnMappingFormatter = info.mapping.formatter;
|
84
|
-
}
|
85
|
-
};
|
86
|
-
WebComponentAssociation.prototype = Object.create(OriginalAssociation.prototype);
|
87
|
-
WebComponentAssociation.prototype.constructor = WebComponentAssociation;
|
88
|
-
WebComponentMetadata.prototype.metaFactoryAssociation = WebComponentAssociation;
|
89
|
-
|
90
|
-
WebComponentMetadata.prototype.applySettings = function(oClassInfo) {
|
91
|
-
var oStaticInfo = oClassInfo.metadata;
|
92
|
-
|
93
|
-
this._sTag = oStaticInfo.tag;
|
94
|
-
this._aMethods = oStaticInfo.methods || [];
|
95
|
-
this._aGetters = oStaticInfo.getters || [];
|
96
|
-
|
97
|
-
ElementMetadata.prototype.applySettings.call(this, oClassInfo);
|
98
|
-
};
|
99
|
-
|
100
|
-
WebComponentMetadata.prototype.generateAccessors = function() {
|
101
|
-
ElementMetadata.prototype.generateAccessors.call(this);
|
102
|
-
var proto = this.getClass().prototype;
|
103
|
-
|
104
|
-
// Generate accessors for proxied public methods - only if not created explicitly already
|
105
|
-
this._aMethods.forEach(function(name) {
|
106
|
-
if (!proto[name]) {
|
107
|
-
proto[name] = function() {
|
108
|
-
return this.__callPublicMethod(name, arguments);
|
109
|
-
};
|
110
|
-
}
|
111
|
-
});
|
112
|
-
|
113
|
-
// Generate accessors for proxied public getters - only if not created explicitly already
|
114
|
-
this._aGetters.forEach(function(name) {
|
115
|
-
var functionName = "get" + name.substr(0, 1).toUpperCase() + name.substr(1);
|
116
|
-
if (!proto[functionName]) {
|
117
|
-
proto[functionName] = function() {
|
118
|
-
return this.__callPublicGetter(name);
|
119
|
-
};
|
120
|
-
}
|
121
|
-
});
|
122
|
-
};
|
123
|
-
|
124
|
-
/**
|
125
|
-
* Returns the tag, used to render the Component Wrapper
|
126
|
-
* @public
|
127
|
-
* @returns {string}
|
128
|
-
*/
|
129
|
-
WebComponentMetadata.prototype.getTag = function() {
|
130
|
-
return this._sTag;
|
131
|
-
};
|
132
|
-
|
133
|
-
/**
|
134
|
-
* Returns the list of public methods, proxied by the Component Wrapper to the component itself
|
135
|
-
* @public
|
136
|
-
* @returns {Array}
|
137
|
-
*/
|
138
|
-
WebComponentMetadata.prototype.getMethods = function() {
|
139
|
-
return this._aMethods;
|
140
|
-
};
|
141
|
-
|
142
|
-
/**
|
143
|
-
* Returns the list of public getters, proxied by the Component Wrapper to the component itself
|
144
|
-
* @public
|
145
|
-
* @returns {Array}
|
146
|
-
*/
|
147
|
-
WebComponentMetadata.prototype.getGetters = function() {
|
148
|
-
return this._aGetters;
|
149
|
-
};
|
150
|
-
|
151
|
-
/**
|
152
|
-
* Returns the slot to be assigned to a particular aggregation's items
|
153
|
-
* @private
|
154
|
-
*/
|
155
|
-
WebComponentMetadata.prototype.getAggregationSlot = function(sAggregationName) {
|
156
|
-
var oAggregation = this._mAllAggregations[sAggregationName];
|
157
|
-
return oAggregation ? oAggregation._sSlot : undefined;
|
158
|
-
};
|
159
|
-
|
160
|
-
/**
|
161
|
-
* Determines whether the attribute corresponds to a managed property
|
162
|
-
* @param sAttr the attribute's name
|
163
|
-
* @returns {boolean}
|
164
|
-
*/
|
165
|
-
WebComponentMetadata.prototype.isManagedAttribute = function(sAttr) {
|
166
|
-
var mProperties = this.getAllProperties();
|
167
|
-
for (var propName in mProperties) {
|
168
|
-
if (mProperties.hasOwnProperty(propName)) {
|
169
|
-
var propData = mProperties[propName];
|
170
|
-
if (propData._sMapping === "attribute" && (propData._sMapTo === sAttr || camelize(sAttr) === propName)) {
|
171
|
-
return true;
|
172
|
-
}
|
173
|
-
}
|
174
|
-
}
|
175
|
-
|
176
|
-
var mAssociations = this.getAllAssociations();
|
177
|
-
for (var sAssocName in mAssociations) {
|
178
|
-
if (mAssociations.hasOwnProperty(sAssocName)) {
|
179
|
-
var oAssocData = mAssociations[sAssocName];
|
180
|
-
if (oAssocData._sMapping === "property" && oAssocData._sMapTo === camelize(sAttr)) {
|
181
|
-
return true;
|
182
|
-
}
|
183
|
-
}
|
184
|
-
}
|
185
|
-
|
186
|
-
return false;
|
187
|
-
};
|
188
|
-
|
189
|
-
/**
|
190
|
-
* Returns a map, containing all properties of a certain mapping type
|
191
|
-
* @param sMapping
|
192
|
-
* @returns {Object}
|
193
|
-
*/
|
194
|
-
WebComponentMetadata.prototype.getPropertiesByMapping = function(sMapping) {
|
195
|
-
var mFiltered = {};
|
196
|
-
var mProperties = this.getAllProperties();
|
197
|
-
var mPrivateProperties = this.getAllPrivateProperties();
|
198
|
-
for (var propName in mProperties) {
|
199
|
-
if (mProperties.hasOwnProperty(propName)) {
|
200
|
-
var propData = mProperties[propName];
|
201
|
-
if (propData._sMapping === sMapping) {
|
202
|
-
mFiltered[propName] = propData;
|
203
|
-
}
|
204
|
-
}
|
205
|
-
}
|
206
|
-
|
207
|
-
for (var propName in mPrivateProperties) {
|
208
|
-
if (mPrivateProperties.hasOwnProperty(propName)) {
|
209
|
-
var propData = mPrivateProperties[propName];
|
210
|
-
if (propData._sMapping === sMapping) {
|
211
|
-
mFiltered[propName] = propData;
|
212
|
-
}
|
213
|
-
}
|
214
|
-
}
|
215
|
-
|
216
|
-
return mFiltered;
|
217
|
-
};
|
218
|
-
|
219
|
-
/**
|
220
|
-
* Returns a map of all associations that control properties (have mapping to properties)
|
221
|
-
* returns {Object}
|
222
|
-
*/
|
223
|
-
WebComponentMetadata.prototype.getAssociationsWithMapping = function() {
|
224
|
-
var mFiltered = {};
|
225
|
-
var mAssociations = this.getAllAssociations();
|
226
|
-
for (var sAssocName in mAssociations) {
|
227
|
-
if (mAssociations.hasOwnProperty(sAssocName)) {
|
228
|
-
var oAssocData = mAssociations[sAssocName];
|
229
|
-
if (oAssocData._sMapping) {
|
230
|
-
mFiltered[sAssocName] = oAssocData;
|
231
|
-
}
|
232
|
-
}
|
233
|
-
}
|
234
|
-
|
235
|
-
return mFiltered;
|
236
|
-
};
|
237
|
-
|
238
|
-
/**
|
239
|
-
* Retrieves the renderer for the described web component class.
|
240
|
-
* Note: this is always the default renderer and Web Component wrappers should not define their own renderers.
|
241
|
-
* @public
|
242
|
-
*/
|
243
|
-
WebComponentMetadata.prototype.getRenderer = function() {
|
244
|
-
if (this._oRenderer) {
|
245
|
-
return this._oRenderer;
|
246
|
-
}
|
247
|
-
|
248
|
-
return WebComponentRenderer;
|
249
|
-
};
|
250
|
-
|
251
|
-
return WebComponentMetadata;
|
252
|
-
|
253
|
-
});
|
9
|
+
"sap/ui/core/webc/WebComponentMetadata"
|
10
|
+
],
|
11
|
+
function(CoreWebComponentMetadata) {
|
12
|
+
"use strict";
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Creates a new metadata object for a WebComponent Wrapper subclass.
|
16
|
+
*
|
17
|
+
* @param {string} sClassName fully qualified name of the class that is described by this metadata object
|
18
|
+
* @param {object} oClassInfo static info to construct the metadata from
|
19
|
+
*
|
20
|
+
* @class
|
21
|
+
* @author SAP SE
|
22
|
+
* @version 1.119.0
|
23
|
+
* @since 1.92.0
|
24
|
+
* @experimental Since 1.92.0 The API might change. It is not intended for productive usage yet!
|
25
|
+
* @deprecated Since 1.118.0 Use sap.ui.core.webc.WebComponentMetadata instead!
|
26
|
+
* @alias sap.ui.webc.common.WebComponentMetadata
|
27
|
+
* @extends sap.ui.core.webc.WebComponentMetadata
|
28
|
+
* @public
|
29
|
+
*/
|
30
|
+
var WebComponentMetadata = function(sClassName, oClassInfo) {
|
31
|
+
// call super constructor
|
32
|
+
CoreWebComponentMetadata.apply(this, arguments);
|
33
|
+
};
|
34
|
+
|
35
|
+
//chain the prototypes
|
36
|
+
WebComponentMetadata.prototype = Object.create(CoreWebComponentMetadata.prototype);
|
37
|
+
WebComponentMetadata.prototype.constructor = WebComponentMetadata;
|
38
|
+
|
39
|
+
return WebComponentMetadata;
|
40
|
+
|
41
|
+
});
|
@@ -29,7 +29,7 @@ sap.ui.define([
|
|
29
29
|
* @namespace
|
30
30
|
* @name sap.ui.webc
|
31
31
|
* @author SAP SE
|
32
|
-
* @version 1.
|
32
|
+
* @version 1.119.0
|
33
33
|
* @public
|
34
34
|
* @since 1.92.0
|
35
35
|
* @experimental Since 1.92.0
|
@@ -41,14 +41,14 @@ sap.ui.define([
|
|
41
41
|
* @namespace
|
42
42
|
* @alias sap.ui.webc.common
|
43
43
|
* @author SAP SE
|
44
|
-
* @version 1.
|
44
|
+
* @version 1.119.0
|
45
45
|
* @public
|
46
46
|
* @since 1.92.0
|
47
47
|
* @experimental Since 1.92.0
|
48
48
|
*/
|
49
49
|
var thisLib = Library.init({
|
50
50
|
name : "sap.ui.webc.common",
|
51
|
-
version: "1.
|
51
|
+
version: "1.119.0",
|
52
52
|
dependencies : ["sap.ui.core"],
|
53
53
|
noLibraryCSS: true,
|
54
54
|
designtime: "sap/ui/webc/common/designtime/library.designtime",
|
@@ -1,81 +1,52 @@
|
|
1
|
-
sap.ui.define([
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
*/
|
17
|
-
const getTheme = () => {
|
18
|
-
if (curTheme === undefined) {
|
19
|
-
curTheme = (0, _InitialConfiguration.getTheme)();
|
1
|
+
sap.ui.define([
|
2
|
+
'exports',
|
3
|
+
'../InitialConfiguration',
|
4
|
+
'../Render',
|
5
|
+
'../theming/applyTheme',
|
6
|
+
'../theming/getThemeDesignerTheme',
|
7
|
+
'../generated/AssetParameters'
|
8
|
+
], function (_exports, _InitialConfiguration, _Render, _applyTheme, _getThemeDesignerTheme, _AssetParameters) {
|
9
|
+
'use strict';
|
10
|
+
Object.defineProperty(_exports, '__esModule', { value: true });
|
11
|
+
_exports.setTheme = _exports.isTheme = _exports.isLegacyThemeFamily = _exports.getTheme = _exports.getDefaultTheme = void 0;
|
12
|
+
_applyTheme = _interopRequireDefault(sap.ui.require('sap/ui/webc/common/thirdparty/base/theming/applyTheme'));
|
13
|
+
_getThemeDesignerTheme = _interopRequireDefault(_getThemeDesignerTheme);
|
14
|
+
function _interopRequireDefault(obj) {
|
15
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
20
16
|
}
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
* @param {string} theme
|
57
|
-
* @returns {boolean}
|
58
|
-
*/
|
59
|
-
_exports.getDefaultTheme = getDefaultTheme;
|
60
|
-
const isTheme = theme => {
|
61
|
-
const currentTheme = getTheme();
|
62
|
-
return currentTheme === theme || currentTheme === `${theme}_exp`;
|
63
|
-
};
|
64
|
-
/**
|
65
|
-
* Returns if the currently set theme is part of legacy theme families ("sap_belize" or "sap_fiori_3").
|
66
|
-
* <b>Note</b>: in addition, the method checks the base theme of a custom theme, built via the ThemeDesigner.
|
67
|
-
*
|
68
|
-
* @private
|
69
|
-
* @returns { boolean }
|
70
|
-
*/
|
71
|
-
_exports.isTheme = isTheme;
|
72
|
-
const isLegacyThemeFamily = () => {
|
73
|
-
const currentTheme = getTheme();
|
74
|
-
if (!isKnownTheme(currentTheme)) {
|
75
|
-
return !(0, _getThemeDesignerTheme.default)()?.baseThemeName?.startsWith("sap_horizon");
|
76
|
-
}
|
77
|
-
return !currentTheme.startsWith("sap_horizon");
|
78
|
-
};
|
79
|
-
_exports.isLegacyThemeFamily = isLegacyThemeFamily;
|
80
|
-
const isKnownTheme = theme => _AssetParameters.SUPPORTED_THEMES.includes(theme);
|
17
|
+
let curTheme;
|
18
|
+
const getTheme = () => {
|
19
|
+
if (curTheme === undefined) {
|
20
|
+
curTheme = (0, _InitialConfiguration.getTheme)();
|
21
|
+
}
|
22
|
+
return curTheme;
|
23
|
+
};
|
24
|
+
_exports.getTheme = getTheme;
|
25
|
+
const setTheme = async theme => {
|
26
|
+
if (curTheme === theme) {
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
curTheme = theme;
|
30
|
+
await (0, sap.ui.require('sap/ui/webc/common/thirdparty/base/theming/applyTheme').default)(curTheme);
|
31
|
+
await (0, _Render.reRenderAllUI5Elements)({ themeAware: true });
|
32
|
+
};
|
33
|
+
_exports.setTheme = setTheme;
|
34
|
+
const getDefaultTheme = () => {
|
35
|
+
return _AssetParameters.DEFAULT_THEME;
|
36
|
+
};
|
37
|
+
_exports.getDefaultTheme = getDefaultTheme;
|
38
|
+
const isTheme = theme => {
|
39
|
+
const currentTheme = getTheme();
|
40
|
+
return currentTheme === theme || currentTheme === `${ theme }_exp`;
|
41
|
+
};
|
42
|
+
_exports.isTheme = isTheme;
|
43
|
+
const isLegacyThemeFamily = () => {
|
44
|
+
const currentTheme = getTheme();
|
45
|
+
if (!isKnownTheme(currentTheme)) {
|
46
|
+
return !(0, _getThemeDesignerTheme.default)()?.baseThemeName?.startsWith('sap_horizon');
|
47
|
+
}
|
48
|
+
return !currentTheme.startsWith('sap_horizon');
|
49
|
+
};
|
50
|
+
_exports.isLegacyThemeFamily = isLegacyThemeFamily;
|
51
|
+
const isKnownTheme = theme => _AssetParameters.SUPPORTED_THEMES.includes(theme);
|
81
52
|
});
|
@@ -1,70 +1,47 @@
|
|
1
|
-
sap.ui.define([
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
* @public
|
16
|
-
* @since 1.14.0
|
17
|
-
* @returns { string } the current theme root
|
18
|
-
*/
|
19
|
-
const getThemeRoot = () => {
|
20
|
-
if (currThemeRoot === undefined) {
|
21
|
-
currThemeRoot = (0, _InitialConfiguration.getThemeRoot)();
|
1
|
+
sap.ui.define([
|
2
|
+
'exports',
|
3
|
+
'../util/createLinkInHead',
|
4
|
+
'../validateThemeRoot',
|
5
|
+
'../InitialConfiguration',
|
6
|
+
'./Theme'
|
7
|
+
], function (_exports, _createLinkInHead, _validateThemeRoot, _InitialConfiguration, _Theme) {
|
8
|
+
'use strict';
|
9
|
+
Object.defineProperty(_exports, '__esModule', { value: true });
|
10
|
+
_exports.setThemeRoot = _exports.getThemeRoot = _exports.attachCustomThemeStylesToHead = void 0;
|
11
|
+
_createLinkInHead = _interopRequireDefault(_createLinkInHead);
|
12
|
+
_validateThemeRoot = _interopRequireDefault(_validateThemeRoot);
|
13
|
+
function _interopRequireDefault(obj) {
|
14
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
22
15
|
}
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
}
|
53
|
-
|
54
|
-
};
|
55
|
-
_exports.setThemeRoot = setThemeRoot;
|
56
|
-
const formatThemeLink = theme => {
|
57
|
-
return `${getThemeRoot()}Base/baseLib/${theme}/css_variables.css`; // theme root is always set at this point.
|
58
|
-
};
|
59
|
-
|
60
|
-
const attachCustomThemeStylesToHead = async theme => {
|
61
|
-
const link = document.querySelector(`[sap-ui-webcomponents-theme="${theme}"]`);
|
62
|
-
if (link) {
|
63
|
-
document.head.removeChild(link);
|
64
|
-
}
|
65
|
-
await (0, _createLinkInHead.default)(formatThemeLink(theme), {
|
66
|
-
"sap-ui-webcomponents-theme": theme
|
67
|
-
});
|
68
|
-
};
|
69
|
-
_exports.attachCustomThemeStylesToHead = attachCustomThemeStylesToHead;
|
16
|
+
let currThemeRoot;
|
17
|
+
const getThemeRoot = () => {
|
18
|
+
if (currThemeRoot === undefined) {
|
19
|
+
currThemeRoot = (0, _InitialConfiguration.getThemeRoot)();
|
20
|
+
}
|
21
|
+
return currThemeRoot;
|
22
|
+
};
|
23
|
+
_exports.getThemeRoot = getThemeRoot;
|
24
|
+
const setThemeRoot = themeRoot => {
|
25
|
+
if (currThemeRoot === themeRoot) {
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
currThemeRoot = themeRoot;
|
29
|
+
if (!(0, _validateThemeRoot.default)(themeRoot)) {
|
30
|
+
console.warn(`The ${ themeRoot } is not valid. Check the allowed origins as suggested in the "setThemeRoot" description.`);
|
31
|
+
return;
|
32
|
+
}
|
33
|
+
return attachCustomThemeStylesToHead((0, sap.ui.require('sap/ui/webc/common/thirdparty/base/config/Theme').getTheme)());
|
34
|
+
};
|
35
|
+
_exports.setThemeRoot = setThemeRoot;
|
36
|
+
const formatThemeLink = theme => {
|
37
|
+
return `${ getThemeRoot() }Base/baseLib/${ theme }/css_variables.css`;
|
38
|
+
};
|
39
|
+
const attachCustomThemeStylesToHead = async theme => {
|
40
|
+
const link = document.querySelector(`[sap-ui-webcomponents-theme="${ theme }"]`);
|
41
|
+
if (link) {
|
42
|
+
document.head.removeChild(link);
|
43
|
+
}
|
44
|
+
await (0, _createLinkInHead.default)(formatThemeLink(theme), { 'sap-ui-webcomponents-theme': theme });
|
45
|
+
};
|
46
|
+
_exports.attachCustomThemeStylesToHead = attachCustomThemeStylesToHead;
|
70
47
|
});
|