@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.
@@ -6,248 +6,36 @@
6
6
 
7
7
  // Provides class sap.ui.webc.common.WebComponentMetadata
8
8
  sap.ui.define([
9
- "sap/ui/core/ElementMetadata",
10
- "./WebComponentRenderer",
11
- "sap/base/strings/camelize"
12
- ],
13
- function(ElementMetadata, WebComponentRenderer, camelize) {
14
- "use strict";
15
-
16
- var MAPPING_TYPES = ["attribute", "style", "textContent", "slot", "none"];
17
-
18
- /**
19
- * Creates a new metadata object for a WebComponent Wrapper subclass.
20
- *
21
- * @param {string} sClassName fully qualified name of the class that is described by this metadata object
22
- * @param {object} oClassInfo static info to construct the metadata from
23
- *
24
- * @class
25
- * @author SAP SE
26
- * @version 1.117.1
27
- * @since 1.92.0
28
- * @experimental Since 1.92.0 The API might change. It is not intended for productive usage yet!
29
- * @alias sap.ui.webc.common.WebComponentMetadata
30
- * @extends sap.ui.core.ElementMetadata
31
- * @public
32
- */
33
- var WebComponentMetadata = function(sClassName, oClassInfo) {
34
- // call super constructor
35
- ElementMetadata.apply(this, arguments);
36
- };
37
-
38
- //chain the prototypes
39
- WebComponentMetadata.prototype = Object.create(ElementMetadata.prototype);
40
- WebComponentMetadata.prototype.constructor = WebComponentMetadata;
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.117.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.117.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.117.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(["exports", "../InitialConfiguration", "../Render", "../theming/applyTheme", "../theming/getThemeDesignerTheme", "../generated/AssetParameters"], function (_exports, _InitialConfiguration, _Render, _applyTheme, _getThemeDesignerTheme, _AssetParameters) {
2
- "use strict";
3
-
4
- Object.defineProperty(_exports, "__esModule", {
5
- value: true
6
- });
7
- _exports.setTheme = _exports.isTheme = _exports.isLegacyThemeFamily = _exports.getTheme = _exports.getDefaultTheme = void 0;
8
- _applyTheme = _interopRequireDefault(_applyTheme);
9
- _getThemeDesignerTheme = _interopRequireDefault(_getThemeDesignerTheme);
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- let curTheme;
12
- /**
13
- * Returns the current theme.
14
- * @public
15
- * @returns {string} the current theme name
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
- return curTheme;
22
- };
23
- /**
24
- * Applies a new theme after fetching its assets from the network.
25
- * @public
26
- * @param {string} theme the name of the new theme
27
- * @returns {Promise<void>} a promise that is resolved when the new theme assets have been fetched and applied to the DOM
28
- */
29
- _exports.getTheme = getTheme;
30
- const setTheme = async theme => {
31
- if (curTheme === theme) {
32
- return;
33
- }
34
- curTheme = theme;
35
- // Update CSS Custom Properties
36
- await (0, _applyTheme.default)(curTheme);
37
- await (0, _Render.reRenderAllUI5Elements)({
38
- themeAware: true
39
- });
40
- };
41
- /**
42
- * Returns the default theme.
43
- *
44
- * Note: Default theme might be different than the configurated one.
45
- *
46
- * @public
47
- * @returns {string}
48
- */
49
- _exports.setTheme = setTheme;
50
- const getDefaultTheme = () => {
51
- return _AssetParameters.DEFAULT_THEME;
52
- };
53
- /**
54
- * Returns if the given theme name is the one currently applied.
55
- * @private
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(["exports", "../util/createLinkInHead", "../validateThemeRoot", "../InitialConfiguration", "./Theme"], function (_exports, _createLinkInHead, _validateThemeRoot, _InitialConfiguration, _Theme) {
2
- "use strict";
3
-
4
- Object.defineProperty(_exports, "__esModule", {
5
- value: true
6
- });
7
- _exports.setThemeRoot = _exports.getThemeRoot = _exports.attachCustomThemeStylesToHead = void 0;
8
- _createLinkInHead = _interopRequireDefault(_createLinkInHead);
9
- _validateThemeRoot = _interopRequireDefault(_validateThemeRoot);
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- let currThemeRoot;
12
- /**
13
- * Returns the current theme root.
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
- return currThemeRoot;
24
- };
25
- /**
26
- * Sets theme root for the current theme.
27
- * When set, the framework will validate the theme root and fetch the theme styles (CSS variables) from this location.
28
- *
29
- * <b>Note:</b> The feature is specific to custom themes, created with the `UI Theme Designer`.
30
- * The provided theme root is used only as a base to construct the actual location of the theme styles: `{themeRoot}/.../css_variables.css`.
31
- *
32
- * <br/>
33
- *
34
- * <b>Note:</b> Certain security restrictions will apply before fetching the theme assets.
35
- * Absolute URLs to a different origin than the current page will result in using the current page as an origin.
36
- * To allow specific origins, use &lt;meta name="sap-allowedThemeOrigins" content="https://my-example-host.com/"&gt; tag inside the &lt;head&gt; of the page.
37
- *
38
- * @public
39
- * @since 1.14.0
40
- * @param { string } themeRoot the new theme root
41
- * @returns { Promise<void> }
42
- */
43
- _exports.getThemeRoot = getThemeRoot;
44
- const setThemeRoot = themeRoot => {
45
- if (currThemeRoot === themeRoot) {
46
- return;
47
- }
48
- currThemeRoot = themeRoot;
49
- if (!(0, _validateThemeRoot.default)(themeRoot)) {
50
- console.warn(`The ${themeRoot} is not valid. Check the allowed origins as suggested in the "setThemeRoot" description.`); // eslint-disable-line
51
- return;
52
- }
53
- return attachCustomThemeStylesToHead((0, _Theme.getTheme)());
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
  });