@ui5/webcomponents-base 0.33.0 → 1.0.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/.eslintignore +2 -1
- package/CHANGELOG.md +34 -0
- package/README.md +26 -2
- package/bundle.esm.js +6 -2
- package/dist/CSP.js +59 -0
- package/dist/Device.js +5 -0
- package/dist/EventProvider.js +19 -25
- package/dist/FontFace.js +7 -95
- package/dist/InitialConfiguration.js +11 -7
- package/dist/Keys.js +9 -0
- package/dist/ManagedStyles.js +83 -0
- package/dist/Render.js +3 -1
- package/dist/StaticAreaItem.js +11 -9
- package/dist/SystemCSSVars.js +4 -25
- package/dist/UI5Element.js +43 -59
- package/dist/UI5ElementMetadata.js +9 -1
- package/dist/asset-registries/Icons.js +26 -8
- package/dist/asset-registries/Illustrations.js +10 -3
- package/dist/asset-registries/LocaleData.js +11 -2
- package/dist/assets-meta/IconCollectionsAlias.js +18 -0
- package/dist/config/Theme.js +14 -0
- package/dist/css/FontFace.css +45 -0
- package/dist/css/OverrideFontFace.css +32 -0
- package/dist/css/SystemCSSVars.css +17 -0
- package/dist/delegate/ItemNavigation.js +66 -0
- package/dist/generated/AssetParameters.js +1 -1
- package/dist/generated/css/FontFace.css.js +5 -0
- package/dist/generated/css/OverrideFontFace.css.js +5 -0
- package/dist/generated/css/SystemCSSVars.css.js +5 -0
- package/dist/i18nBundle.js +33 -2
- package/dist/renderer/LitRenderer.js +7 -4
- package/dist/renderer/directives/style-map.js +72 -0
- package/dist/resources/bundle.esm.js +19 -8
- package/dist/resources/bundle.esm.js.map +1 -1
- package/dist/sap/base/Log.js +2 -10
- package/dist/sap/base/assert.js +1 -5
- package/dist/test-resources/elements/WithStaticArea.js +2 -1
- package/dist/test-resources/pages/AllTestElements.html +3 -0
- package/dist/test-resources/pages/i18n.html +1 -3
- package/dist/test-resources/specs/ConfigurationChange.spec.js +9 -9
- package/dist/test-resources/specs/ConfigurationScript.spec.js +24 -24
- package/dist/test-resources/specs/ConfigurationURL.spec.js +33 -33
- package/dist/test-resources/specs/CustomTheme.spec.js +7 -7
- package/dist/test-resources/specs/EventProvider.spec.js +63 -0
- package/dist/test-resources/specs/StaticArea.spec.js +55 -13
- package/dist/test-resources/specs/Theming.spec.js +11 -11
- package/dist/test-resources/specs/UI5ElementInvalidation.js +29 -29
- package/dist/test-resources/specs/UI5ElementLifecycle.js +11 -11
- package/dist/test-resources/specs/UI5ElementListenForChildPropChanges.spec.js +11 -11
- package/dist/test-resources/specs/UI5ElementMetadataExt.js +8 -8
- package/dist/test-resources/specs/UI5ElementPropertyValidation.js +6 -6
- package/dist/test-resources/specs/UI5ElementPropsAndAttrs.spec.js +36 -36
- package/dist/test-resources/specs/UI5ElementShadowDOM.js +9 -9
- package/dist/test-resources/specs/UI5ElementSlots.js +9 -9
- package/dist/theming/CustomStyle.js +23 -3
- package/dist/theming/applyTheme.js +5 -8
- package/dist/theming/getEffectiveLinksHrefs.js +20 -0
- package/dist/theming/getStylesString.js +4 -2
- package/dist/theming/getThemeDesignerTheme.js +2 -1
- package/dist/theming/preloadLinks.js +23 -0
- package/dist/types/DataType.js +12 -0
- package/dist/types/Float.js +4 -0
- package/dist/types/Integer.js +4 -0
- package/dist/updateShadowRoot.js +8 -4
- package/dist/util/createLinkInHead.js +19 -0
- package/dist/util/encodeXML.js +35 -0
- package/dist/util/escapeRegex.js +10 -0
- package/dist/util/generateHighlightedMarkup.js +42 -0
- package/hash.txt +1 -1
- package/lib/generate-asset-parameters/index.js +0 -1
- package/lib/generate-styles/index.js +18 -0
- package/package-scripts.js +9 -6
- package/package.json +10 -12
- package/src/CSP.js +59 -0
- package/src/Device.js +5 -0
- package/src/EventProvider.js +19 -25
- package/src/FontFace.js +7 -95
- package/src/InitialConfiguration.js +11 -7
- package/src/Keys.js +9 -0
- package/src/ManagedStyles.js +83 -0
- package/src/Render.js +3 -1
- package/src/StaticAreaItem.js +11 -9
- package/src/SystemCSSVars.js +4 -25
- package/src/UI5Element.js +43 -59
- package/src/UI5ElementMetadata.js +9 -1
- package/src/asset-registries/Icons.js +26 -8
- package/src/asset-registries/Illustrations.js +10 -3
- package/src/asset-registries/LocaleData.js +11 -2
- package/src/assets-meta/IconCollectionsAlias.js +18 -0
- package/src/config/Theme.js +14 -0
- package/src/css/FontFace.css +45 -0
- package/src/css/OverrideFontFace.css +32 -0
- package/src/css/SystemCSSVars.css +17 -0
- package/src/delegate/ItemNavigation.js +66 -0
- package/src/i18nBundle.js +33 -2
- package/src/renderer/LitRenderer.js +7 -4
- package/src/renderer/directives/style-map.js +72 -0
- package/src/theming/CustomStyle.js +23 -3
- package/src/theming/applyTheme.js +5 -8
- package/src/theming/getEffectiveLinksHrefs.js +20 -0
- package/src/theming/getStylesString.js +4 -2
- package/src/theming/getThemeDesignerTheme.js +2 -1
- package/src/theming/preloadLinks.js +23 -0
- package/src/types/DataType.js +12 -0
- package/src/types/Float.js +4 -0
- package/src/types/Integer.js +4 -0
- package/src/updateShadowRoot.js +8 -4
- package/src/util/createLinkInHead.js +19 -0
- package/src/util/encodeXML.js +35 -0
- package/src/util/escapeRegex.js +10 -0
- package/src/util/generateHighlightedMarkup.js +42 -0
- package/dist/config/AssetsPath.js +0 -17
- package/dist/theming/createThemePropertiesStyleTag.js +0 -20
- package/src/config/AssetsPath.js +0 -17
- package/src/theming/createThemePropertiesStyleTag.js +0 -20
|
@@ -13,7 +13,6 @@ let initialConfig = {
|
|
|
13
13
|
noConflict: false, // no URL
|
|
14
14
|
formatSettings: {},
|
|
15
15
|
fetchDefaultLanguage: false,
|
|
16
|
-
assetsPath: "",
|
|
17
16
|
};
|
|
18
17
|
|
|
19
18
|
/* General settings */
|
|
@@ -62,11 +61,6 @@ const getFormatSettings = () => {
|
|
|
62
61
|
return initialConfig.formatSettings;
|
|
63
62
|
};
|
|
64
63
|
|
|
65
|
-
const getAssetsPath = () => {
|
|
66
|
-
initConfiguration();
|
|
67
|
-
return initialConfig.assetsPath;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
64
|
const booleanMapping = new Map();
|
|
71
65
|
booleanMapping.set("true", true);
|
|
72
66
|
booleanMapping.set("false", false);
|
|
@@ -112,6 +106,14 @@ const parseURLParameters = () => {
|
|
|
112
106
|
});
|
|
113
107
|
};
|
|
114
108
|
|
|
109
|
+
const normalizeParamValue = (param, value) => {
|
|
110
|
+
if (param === "theme" && value.includes("@")) { // the theme parameter might have @<URL-TO-THEME> in the value - strip this
|
|
111
|
+
return value.split("@")[0];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return value;
|
|
115
|
+
};
|
|
116
|
+
|
|
115
117
|
const applyURLParam = (key, value, paramType) => {
|
|
116
118
|
const lowerCaseValue = value.toLowerCase();
|
|
117
119
|
const param = key.split(`${paramType}-`)[1];
|
|
@@ -119,6 +121,9 @@ const applyURLParam = (key, value, paramType) => {
|
|
|
119
121
|
if (booleanMapping.has(value)) {
|
|
120
122
|
value = booleanMapping.get(lowerCaseValue);
|
|
121
123
|
}
|
|
124
|
+
|
|
125
|
+
value = normalizeParamValue(param, value);
|
|
126
|
+
|
|
122
127
|
initialConfig[param] = value;
|
|
123
128
|
};
|
|
124
129
|
|
|
@@ -158,5 +163,4 @@ export {
|
|
|
158
163
|
getNoConflict,
|
|
159
164
|
getCalendarType,
|
|
160
165
|
getFormatSettings,
|
|
161
|
-
getAssetsPath,
|
|
162
166
|
};
|
package/src/Keys.js
CHANGED
|
@@ -163,8 +163,12 @@ const isPageDown = event => (event.key ? event.key === "PageDown" : event.keyCod
|
|
|
163
163
|
|
|
164
164
|
const isPageUpShift = event => (event.key ? event.key === "PageUp" : event.keyCode === KeyCodes.PAGE_UP) && checkModifierKeys(event, false, false, true);
|
|
165
165
|
|
|
166
|
+
const isPageUpAlt = event => (event.key ? event.key === "PageUp" : event.keyCode === KeyCodes.PAGE_UP) && checkModifierKeys(event, false, true, false);
|
|
167
|
+
|
|
166
168
|
const isPageDownShift = event => (event.key ? event.key === "PageDown" : event.keyCode === KeyCodes.PAGE_DOWN) && checkModifierKeys(event, false, false, true);
|
|
167
169
|
|
|
170
|
+
const isPageDownAlt = event => (event.key ? event.key === "PageDown" : event.keyCode === KeyCodes.PAGE_DOWN) && checkModifierKeys(event, false, true, false);
|
|
171
|
+
|
|
168
172
|
const isPageUpShiftCtrl = event => (event.key ? event.key === "PageUp" : event.keyCode === KeyCodes.PAGE_UP) && checkModifierKeys(event, true, false, true);
|
|
169
173
|
|
|
170
174
|
const isPageDownShiftCtrl = event => (event.key ? event.key === "PageDown" : event.keyCode === KeyCodes.PAGE_DOWN) && checkModifierKeys(event, true, false, true);
|
|
@@ -187,6 +191,8 @@ const isF4 = event => {
|
|
|
187
191
|
|
|
188
192
|
const isF4Shift = event => (event.key ? event.key === "F4" : event.keyCode === KeyCodes.F4) && checkModifierKeys(event, false, false, true);
|
|
189
193
|
|
|
194
|
+
const isF7 = event => (event.key ? event.key === "F7" : event.keyCode === KeyCodes.F7) && !hasModifierKeys(event);
|
|
195
|
+
|
|
190
196
|
const isShowByArrows = event => {
|
|
191
197
|
return ((event.key === "ArrowDown" || event.key === "Down") || (event.key === "ArrowUp" || event.key === "Up")) && checkModifierKeys(event, /* Ctrl */ false, /* Alt */ true, /* Shift */ false);
|
|
192
198
|
};
|
|
@@ -230,10 +236,13 @@ export {
|
|
|
230
236
|
isShow,
|
|
231
237
|
isF4,
|
|
232
238
|
isF4Shift,
|
|
239
|
+
isF7,
|
|
233
240
|
isPageUp,
|
|
234
241
|
isPageDown,
|
|
235
242
|
isPageUpShift,
|
|
243
|
+
isPageUpAlt,
|
|
236
244
|
isPageDownShift,
|
|
245
|
+
isPageDownAlt,
|
|
237
246
|
isPageUpShiftCtrl,
|
|
238
247
|
isPageDownShiftCtrl,
|
|
239
248
|
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import createStyleInHead from "./util/createStyleInHead.js";
|
|
2
|
+
import createLinkInHead from "./util/createLinkInHead.js";
|
|
3
|
+
import { shouldUseLinks, getUrl } from "./CSP.js";
|
|
4
|
+
|
|
5
|
+
const getStyleId = (name, value) => {
|
|
6
|
+
return value ? `${name}|${value}` : name;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const createStyle = (data, name, value = "") => {
|
|
10
|
+
const content = typeof data === "string" ? data : data.content;
|
|
11
|
+
|
|
12
|
+
if (shouldUseLinks()) {
|
|
13
|
+
const attributes = {};
|
|
14
|
+
attributes[name] = value;
|
|
15
|
+
const href = getUrl(data.packageName, data.fileName);
|
|
16
|
+
createLinkInHead(href, attributes);
|
|
17
|
+
} else if (document.adoptedStyleSheets) {
|
|
18
|
+
const stylesheet = new CSSStyleSheet();
|
|
19
|
+
stylesheet.replaceSync(content);
|
|
20
|
+
stylesheet._ui5StyleId = getStyleId(name, value); // set an id so that we can find the style later
|
|
21
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];
|
|
22
|
+
} else {
|
|
23
|
+
const attributes = {};
|
|
24
|
+
attributes[name] = value;
|
|
25
|
+
createStyleInHead(content, attributes);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const updateStyle = (data, name, value = "") => {
|
|
30
|
+
const content = typeof data === "string" ? data : data.content;
|
|
31
|
+
|
|
32
|
+
if (shouldUseLinks()) {
|
|
33
|
+
document.querySelector(`head>link[${name}="${value}"]`).href = getUrl(data.packageName, data.fileName);
|
|
34
|
+
} else if (document.adoptedStyleSheets) {
|
|
35
|
+
document.adoptedStyleSheets.find(sh => sh._ui5StyleId === getStyleId(name, value)).replaceSync(content || "");
|
|
36
|
+
} else {
|
|
37
|
+
document.querySelector(`head>style[${name}="${value}"]`).textContent = content || "";
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const hasStyle = (name, value = "") => {
|
|
42
|
+
if (shouldUseLinks()) {
|
|
43
|
+
return !!document.querySelector(`head>link[${name}="${value}"]`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (document.adoptedStyleSheets) {
|
|
47
|
+
return !!document.adoptedStyleSheets.find(sh => sh._ui5StyleId === getStyleId(name, value));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return !!document.querySelector(`head>style[${name}="${value}"]`);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const removeStyle = (name, value = "") => {
|
|
54
|
+
if (shouldUseLinks()) {
|
|
55
|
+
const linkElement = document.querySelector(`head>link[${name}="${value}"]`);
|
|
56
|
+
if (linkElement) {
|
|
57
|
+
linkElement.parentElement.removeChild(linkElement);
|
|
58
|
+
}
|
|
59
|
+
} else if (document.adoptedStyleSheets) {
|
|
60
|
+
document.adoptedStyleSheets = document.adoptedStyleSheets.filter(sh => sh._ui5StyleId !== getStyleId(name, value));
|
|
61
|
+
} else {
|
|
62
|
+
const styleElement = document.querySelector(`head > style[${name}="${value}"]`);
|
|
63
|
+
if (styleElement) {
|
|
64
|
+
styleElement.parentElement.removeChild(styleElement);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const createOrUpdateStyle = (data, name, value = "") => {
|
|
70
|
+
if (hasStyle(name, value)) {
|
|
71
|
+
updateStyle(data, name, value);
|
|
72
|
+
} else {
|
|
73
|
+
createStyle(data, name, value);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export {
|
|
78
|
+
createStyle,
|
|
79
|
+
hasStyle,
|
|
80
|
+
updateStyle,
|
|
81
|
+
removeStyle,
|
|
82
|
+
createOrUpdateStyle,
|
|
83
|
+
};
|
package/src/Render.js
CHANGED
|
@@ -135,6 +135,7 @@ const _resolveTaskPromise = () => {
|
|
|
135
135
|
* reRenderAllUI5Elements({tag: "ui5-button"}) -> re-renders only instances of ui5-button
|
|
136
136
|
* reRenderAllUI5Elements({rtlAware: true}) -> re-renders only rtlAware components
|
|
137
137
|
* reRenderAllUI5Elements({languageAware: true}) -> re-renders only languageAware components
|
|
138
|
+
* reRenderAllUI5Elements({themeAware: true}) -> re-renders only themeAware components
|
|
138
139
|
* reRenderAllUI5Elements({rtlAware: true, languageAware: true}) -> re-renders components that are rtlAware or languageAware
|
|
139
140
|
* etc...
|
|
140
141
|
*
|
|
@@ -147,7 +148,8 @@ const reRenderAllUI5Elements = async filters => {
|
|
|
147
148
|
const tag = element.constructor.getMetadata().getTag();
|
|
148
149
|
const rtlAware = isRtlAware(element.constructor);
|
|
149
150
|
const languageAware = element.constructor.getMetadata().isLanguageAware();
|
|
150
|
-
|
|
151
|
+
const themeAware = element.constructor.getMetadata().isThemeAware();
|
|
152
|
+
if (!filters || (filters.tag === tag) || (filters.rtlAware && rtlAware) || (filters.languageAware && languageAware) || (filters.themeAware && themeAware)) {
|
|
151
153
|
renderDeferred(element);
|
|
152
154
|
}
|
|
153
155
|
});
|
package/src/StaticAreaItem.js
CHANGED
|
@@ -3,6 +3,7 @@ import updateShadowRoot from "./updateShadowRoot.js";
|
|
|
3
3
|
import { renderFinished } from "./Render.js";
|
|
4
4
|
import getEffectiveContentDensity from "./util/getEffectiveContentDensity.js";
|
|
5
5
|
import { getEffectiveScopingSuffixForTag } from "./CustomElementsScope.js";
|
|
6
|
+
import getEffectiveDir from "./locale/getEffectiveDir.js";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
*
|
|
@@ -33,6 +34,7 @@ class StaticAreaItem extends HTMLElement {
|
|
|
33
34
|
update() {
|
|
34
35
|
if (this._rendered) {
|
|
35
36
|
this._updateContentDensity();
|
|
37
|
+
this._updateDirection();
|
|
36
38
|
updateShadowRoot(this.ownerElement, true);
|
|
37
39
|
}
|
|
38
40
|
}
|
|
@@ -51,6 +53,15 @@ class StaticAreaItem extends HTMLElement {
|
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
|
|
56
|
+
_updateDirection() {
|
|
57
|
+
const dir = getEffectiveDir(this.ownerElement);
|
|
58
|
+
if (dir) {
|
|
59
|
+
this.setAttribute("dir", dir);
|
|
60
|
+
} else {
|
|
61
|
+
this.removeAttribute("dir");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
54
65
|
/**
|
|
55
66
|
* @protected
|
|
56
67
|
* Returns reference to the DOM element where the current fragment is added.
|
|
@@ -65,15 +76,6 @@ class StaticAreaItem extends HTMLElement {
|
|
|
65
76
|
return this.shadowRoot;
|
|
66
77
|
}
|
|
67
78
|
|
|
68
|
-
/**
|
|
69
|
-
* @protected
|
|
70
|
-
* @param refName
|
|
71
|
-
* @returns {Element}
|
|
72
|
-
*/
|
|
73
|
-
getStableDomRef(refName) {
|
|
74
|
-
return this.shadowRoot.querySelector(`[data-ui5-stable=${refName}]`);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
79
|
static getTag() {
|
|
78
80
|
const pureTag = "ui5-static-area-item";
|
|
79
81
|
const suffix = getEffectiveScopingSuffixForTag(pureTag);
|
package/src/SystemCSSVars.js
CHANGED
|
@@ -1,31 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const systemCSSVars = `
|
|
4
|
-
:root {
|
|
5
|
-
--_ui5_content_density:cozy;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
[data-ui5-compact-size],
|
|
9
|
-
.ui5-content-density-compact,
|
|
10
|
-
.sapUiSizeCompact {
|
|
11
|
-
--_ui5_content_density:compact;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
[dir="rtl"] {
|
|
15
|
-
--_ui5_dir:rtl;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
[dir="ltr"] {
|
|
19
|
-
--_ui5_dir:ltr;
|
|
20
|
-
}
|
|
21
|
-
`;
|
|
1
|
+
import { hasStyle, createStyle } from "./ManagedStyles.js";
|
|
2
|
+
import systemCSSVars from "./generated/css/SystemCSSVars.css.js";
|
|
22
3
|
|
|
23
4
|
const insertSystemCSSVars = () => {
|
|
24
|
-
if (
|
|
25
|
-
|
|
5
|
+
if (!hasStyle("data-ui5-system-css-vars")) {
|
|
6
|
+
createStyle(systemCSSVars, "data-ui5-system-css-vars");
|
|
26
7
|
}
|
|
27
|
-
|
|
28
|
-
createStyleInHead(systemCSSVars, { "data-ui5-system-css-vars": "" });
|
|
29
8
|
};
|
|
30
9
|
|
|
31
10
|
export default insertSystemCSSVars;
|
package/src/UI5Element.js
CHANGED
|
@@ -10,15 +10,15 @@ import { registerTag, isTagRegistered, recordTagRegistrationFailure } from "./Cu
|
|
|
10
10
|
import { observeDOMNode, unobserveDOMNode } from "./DOMObserver.js";
|
|
11
11
|
import { skipOriginalEvent } from "./config/NoConflict.js";
|
|
12
12
|
import getEffectiveDir from "./locale/getEffectiveDir.js";
|
|
13
|
-
import
|
|
14
|
-
import Float from "./types/Float.js";
|
|
13
|
+
import DataType from "./types/DataType.js";
|
|
15
14
|
import { kebabToCamelCase, camelToKebabCase } from "./util/StringHelper.js";
|
|
16
15
|
import isValidPropertyName from "./util/isValidPropertyName.js";
|
|
16
|
+
import isDescendantOf from "./util/isDescendantOf.js";
|
|
17
17
|
import { isSlot, getSlotName, getSlottedElementsList } from "./util/SlotsHelper.js";
|
|
18
18
|
import arraysAreEqual from "./util/arraysAreEqual.js";
|
|
19
19
|
import getClassCopy from "./util/getClassCopy.js";
|
|
20
20
|
import { markAsRtlAware } from "./locale/RTLAwareRegistry.js";
|
|
21
|
-
import
|
|
21
|
+
import preloadLinks from "./theming/preloadLinks.js";
|
|
22
22
|
|
|
23
23
|
let autoId = 0;
|
|
24
24
|
|
|
@@ -43,7 +43,7 @@ function _invalidate(changeInfo) {
|
|
|
43
43
|
|
|
44
44
|
this._changedState.push(changeInfo);
|
|
45
45
|
renderDeferred(this);
|
|
46
|
-
this._eventProvider.fireEvent("
|
|
46
|
+
this._eventProvider.fireEvent("invalidate", { ...changeInfo, target: this });
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
@@ -102,7 +102,6 @@ class UI5Element extends HTMLElement {
|
|
|
102
102
|
async connectedCallback() {
|
|
103
103
|
this.setAttribute(this.constructor.getMetadata().getPureTag(), "");
|
|
104
104
|
|
|
105
|
-
const needsShadowDOM = this.constructor._needsShadowDOM();
|
|
106
105
|
const slotsAreManaged = this.constructor.getMetadata().slotsAreManaged();
|
|
107
106
|
|
|
108
107
|
this._inDOM = true;
|
|
@@ -113,10 +112,6 @@ class UI5Element extends HTMLElement {
|
|
|
113
112
|
await this._processChildren();
|
|
114
113
|
}
|
|
115
114
|
|
|
116
|
-
if (needsShadowDOM && !this.shadowRoot) { // Workaround for Firefox74 bug
|
|
117
|
-
await Promise.resolve();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
115
|
if (!this._inDOM) { // Component removed from DOM while _processChildren was running
|
|
121
116
|
return;
|
|
122
117
|
}
|
|
@@ -134,7 +129,6 @@ class UI5Element extends HTMLElement {
|
|
|
134
129
|
* @private
|
|
135
130
|
*/
|
|
136
131
|
disconnectedCallback() {
|
|
137
|
-
const needsShadowDOM = this.constructor._needsShadowDOM();
|
|
138
132
|
const slotsAreManaged = this.constructor.getMetadata().slotsAreManaged();
|
|
139
133
|
|
|
140
134
|
this._inDOM = false;
|
|
@@ -143,13 +137,11 @@ class UI5Element extends HTMLElement {
|
|
|
143
137
|
this._stopObservingDOMChildren();
|
|
144
138
|
}
|
|
145
139
|
|
|
146
|
-
if (
|
|
147
|
-
if (this.
|
|
148
|
-
|
|
149
|
-
this.onExitDOM();
|
|
150
|
-
}
|
|
151
|
-
this._fullyConnected = false;
|
|
140
|
+
if (this._fullyConnected) {
|
|
141
|
+
if (typeof this.onExitDOM === "function") {
|
|
142
|
+
this.onExitDOM();
|
|
152
143
|
}
|
|
144
|
+
this._fullyConnected = false;
|
|
153
145
|
}
|
|
154
146
|
|
|
155
147
|
if (this.staticAreaItem && this.staticAreaItem.parentElement) {
|
|
@@ -259,7 +251,7 @@ class UI5Element extends HTMLElement {
|
|
|
259
251
|
|
|
260
252
|
// Listen for any invalidation on the child if invalidateOnChildChange is true or an object (ignore when false or not set)
|
|
261
253
|
if (child.isUI5Element && slotData.invalidateOnChildChange) {
|
|
262
|
-
child.
|
|
254
|
+
child.attachInvalidate(this._getChildChangeListener(slotName));
|
|
263
255
|
}
|
|
264
256
|
|
|
265
257
|
// Listen for the slotchange event if the child is a slot itself
|
|
@@ -319,7 +311,7 @@ class UI5Element extends HTMLElement {
|
|
|
319
311
|
|
|
320
312
|
children.forEach(child => {
|
|
321
313
|
if (child && child.isUI5Element) {
|
|
322
|
-
child.
|
|
314
|
+
child.detachInvalidate(this._getChildChangeListener(slotName));
|
|
323
315
|
}
|
|
324
316
|
|
|
325
317
|
if (isSlot(child)) {
|
|
@@ -334,20 +326,20 @@ class UI5Element extends HTMLElement {
|
|
|
334
326
|
* Attach a callback that will be executed whenever the component is invalidated
|
|
335
327
|
*
|
|
336
328
|
* @param callback
|
|
337
|
-
* @
|
|
329
|
+
* @public
|
|
338
330
|
*/
|
|
339
|
-
|
|
340
|
-
this._eventProvider.attachEvent("
|
|
331
|
+
attachInvalidate(callback) {
|
|
332
|
+
this._eventProvider.attachEvent("invalidate", callback);
|
|
341
333
|
}
|
|
342
334
|
|
|
343
335
|
/**
|
|
344
336
|
* Detach the callback that is executed whenever the component is invalidated
|
|
345
337
|
*
|
|
346
338
|
* @param callback
|
|
347
|
-
* @
|
|
339
|
+
* @public
|
|
348
340
|
*/
|
|
349
|
-
|
|
350
|
-
this._eventProvider.detachEvent("
|
|
341
|
+
detachInvalidate(callback) {
|
|
342
|
+
this._eventProvider.detachEvent("invalidate", callback);
|
|
351
343
|
}
|
|
352
344
|
|
|
353
345
|
/**
|
|
@@ -384,12 +376,8 @@ class UI5Element extends HTMLElement {
|
|
|
384
376
|
const propertyTypeClass = properties[nameInCamelCase].type;
|
|
385
377
|
if (propertyTypeClass === Boolean) {
|
|
386
378
|
newValue = newValue !== null;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
newValue = parseInt(newValue);
|
|
390
|
-
}
|
|
391
|
-
if (propertyTypeClass === Float) {
|
|
392
|
-
newValue = parseFloat(newValue);
|
|
379
|
+
} else if (isDescendantOf(propertyTypeClass, DataType)) {
|
|
380
|
+
newValue = propertyTypeClass.attributeToProperty(newValue);
|
|
393
381
|
}
|
|
394
382
|
this[nameInCamelCase] = newValue;
|
|
395
383
|
}
|
|
@@ -402,22 +390,24 @@ class UI5Element extends HTMLElement {
|
|
|
402
390
|
if (!this.constructor.getMetadata().hasAttribute(name)) {
|
|
403
391
|
return;
|
|
404
392
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
|
|
393
|
+
const properties = this.constructor.getMetadata().getProperties();
|
|
394
|
+
const propertyTypeClass = properties[name].type;
|
|
410
395
|
const attrName = camelToKebabCase(name);
|
|
411
396
|
const attrValue = this.getAttribute(attrName);
|
|
412
|
-
|
|
397
|
+
|
|
398
|
+
if (propertyTypeClass === Boolean) {
|
|
413
399
|
if (newValue === true && attrValue === null) {
|
|
414
400
|
this.setAttribute(attrName, "");
|
|
415
401
|
} else if (newValue === false && attrValue !== null) {
|
|
416
402
|
this.removeAttribute(attrName);
|
|
417
403
|
}
|
|
418
|
-
} else if (
|
|
419
|
-
this.setAttribute(attrName, newValue);
|
|
420
|
-
}
|
|
404
|
+
} else if (isDescendantOf(propertyTypeClass, DataType)) {
|
|
405
|
+
this.setAttribute(attrName, propertyTypeClass.propertyToAttribute(newValue));
|
|
406
|
+
} else if (typeof newValue !== "object") {
|
|
407
|
+
if (attrValue !== newValue) {
|
|
408
|
+
this.setAttribute(attrName, newValue);
|
|
409
|
+
}
|
|
410
|
+
} // else { return; } // old object handling
|
|
421
411
|
}
|
|
422
412
|
|
|
423
413
|
/**
|
|
@@ -617,25 +607,27 @@ class UI5Element extends HTMLElement {
|
|
|
617
607
|
|
|
618
608
|
/**
|
|
619
609
|
* Returns the DOM Element inside the Shadow Root that corresponds to the opening tag in the UI5 Web Component's template
|
|
610
|
+
* *Note:* For logical (abstract) elements (items, options, etc...), returns the part of the parent's DOM that represents this option
|
|
620
611
|
* Use this method instead of "this.shadowRoot" to read the Shadow DOM, if ever necessary
|
|
612
|
+
*
|
|
621
613
|
* @public
|
|
622
614
|
*/
|
|
623
615
|
getDomRef() {
|
|
616
|
+
// If a component set _getRealDomRef to its children, use the return value of this function
|
|
617
|
+
if (typeof this._getRealDomRef === "function") {
|
|
618
|
+
return this._getRealDomRef();
|
|
619
|
+
}
|
|
620
|
+
|
|
624
621
|
if (!this.shadowRoot || this.shadowRoot.children.length === 0) {
|
|
625
622
|
return;
|
|
626
623
|
}
|
|
627
624
|
|
|
628
|
-
this.
|
|
629
|
-
|
|
630
|
-
return this.shadowRoot.children.length === 1
|
|
631
|
-
? this.shadowRoot.children[0] : this.shadowRoot.children[1];
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
_assertShadowRootStructure() {
|
|
635
|
-
const expectedChildrenCount = document.adoptedStyleSheets || isLegacyBrowser() ? 1 : 2;
|
|
636
|
-
if (this.shadowRoot.children.length !== expectedChildrenCount) {
|
|
625
|
+
const children = [...this.shadowRoot.children].filter(child => !["link", "style"].includes(child.localName));
|
|
626
|
+
if (children.length !== 1) {
|
|
637
627
|
console.warn(`The shadow DOM for ${this.constructor.getMetadata().getTag()} does not have a top level element, the getDomRef() method might not work as expected`); // eslint-disable-line
|
|
638
628
|
}
|
|
629
|
+
|
|
630
|
+
return children[0];
|
|
639
631
|
}
|
|
640
632
|
|
|
641
633
|
/**
|
|
@@ -661,17 +653,6 @@ class UI5Element extends HTMLElement {
|
|
|
661
653
|
return this.getFocusDomRef();
|
|
662
654
|
}
|
|
663
655
|
|
|
664
|
-
/**
|
|
665
|
-
* Use this method in order to get a reference to an element in the shadow root of the web component or the static area item of the component
|
|
666
|
-
* @public
|
|
667
|
-
* @method
|
|
668
|
-
* @param {String} refName Defines the name of the stable DOM ref
|
|
669
|
-
*/
|
|
670
|
-
getStableDomRef(refName) {
|
|
671
|
-
const staticAreaResult = this.staticAreaItem && this.staticAreaItem.getStableDomRef(refName);
|
|
672
|
-
return staticAreaResult || this.getDomRef().querySelector(`[data-ui5-stable=${refName}]`);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
656
|
/**
|
|
676
657
|
* Set the focus to the element, returned by "getFocusDomRef()" (marked by "data-sap-focus-ref")
|
|
677
658
|
* @public
|
|
@@ -861,6 +842,8 @@ class UI5Element extends HTMLElement {
|
|
|
861
842
|
const oldState = this._state[prop];
|
|
862
843
|
if (propData.multiple && propData.compareValues) {
|
|
863
844
|
isDifferent = !arraysAreEqual(oldState, value);
|
|
845
|
+
} else if (isDescendantOf(propData.type, DataType)) {
|
|
846
|
+
isDifferent = !propData.type.valuesAreEqual(oldState, value);
|
|
864
847
|
} else {
|
|
865
848
|
isDifferent = oldState !== value;
|
|
866
849
|
}
|
|
@@ -996,6 +979,7 @@ class UI5Element extends HTMLElement {
|
|
|
996
979
|
this._generateAccessors();
|
|
997
980
|
registerTag(tag);
|
|
998
981
|
window.customElements.define(tag, this);
|
|
982
|
+
preloadLinks(this);
|
|
999
983
|
|
|
1000
984
|
if (altTag && !customElements.get(altTag)) {
|
|
1001
985
|
registerTag(altTag);
|
|
@@ -126,7 +126,7 @@ class UI5ElementMetadata {
|
|
|
126
126
|
*/
|
|
127
127
|
hasAttribute(propName) {
|
|
128
128
|
const propData = this.getProperties()[propName];
|
|
129
|
-
return propData.type !== Object && !propData.noAttribute;
|
|
129
|
+
return propData.type !== Object && !propData.noAttribute && !propData.multiple;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/**
|
|
@@ -212,6 +212,14 @@ class UI5ElementMetadata {
|
|
|
212
212
|
return !!this.metadata.languageAware;
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Determines whether this UI5 Element has any theme dependant carachteristics.
|
|
217
|
+
* @returns {boolean}
|
|
218
|
+
*/
|
|
219
|
+
isThemeAware() {
|
|
220
|
+
return !!this.metadata.themeAware;
|
|
221
|
+
}
|
|
222
|
+
|
|
215
223
|
/**
|
|
216
224
|
* Matches a changed entity (property/slot) with the given name against the "invalidateOnChildChange" configuration
|
|
217
225
|
* and determines whether this should cause and invalidation
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import getSharedResource from "../getSharedResource.js";
|
|
2
|
+
import IconCollectionsAlias from "../assets-meta/IconCollectionsAlias.js";
|
|
3
|
+
import { isTheme } from "../config/Theme.js";
|
|
2
4
|
|
|
3
5
|
const loaders = new Map();
|
|
4
6
|
const registry = getSharedResource("SVGIcons.registry", new Map());
|
|
5
7
|
const iconCollectionPromises = getSharedResource("SVGIcons.promises", new Map());
|
|
6
8
|
|
|
7
9
|
const ICON_NOT_FOUND = "ICON_NOT_FOUND";
|
|
8
|
-
const DEFAULT_COLLECTION = "SAP-icons";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* @deprecated
|
|
@@ -47,7 +48,7 @@ const _fillRegistry = bundleData => {
|
|
|
47
48
|
// set
|
|
48
49
|
const registerIcon = (name, { pathData, ltr, accData, collection, packageName } = {}) => { // eslint-disable-line
|
|
49
50
|
if (!collection) {
|
|
50
|
-
collection =
|
|
51
|
+
collection = _getDefaultCollection();
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
const key = `${collection}/${name}`;
|
|
@@ -67,12 +68,16 @@ const _parseName = name => {
|
|
|
67
68
|
|
|
68
69
|
let collection;
|
|
69
70
|
[name, collection] = name.split("/").reverse();
|
|
70
|
-
collection = collection ||
|
|
71
|
-
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
collection = collection || _getDefaultCollection();
|
|
72
|
+
|
|
73
|
+
// Normalize collection name.
|
|
74
|
+
// - resolve `SAP-icons-TNT` to `tnt`.
|
|
75
|
+
// - resolve `BusinessSuiteInAppSymbols` to `business-suite`.
|
|
76
|
+
// - resolve `horizon` to `SAP-icons-v5`,
|
|
77
|
+
// Note: aliases can be made as a feature, if more collections need it or more aliases are needed.
|
|
78
|
+
collection = _normalizeCollection(collection);
|
|
79
|
+
name = name.replace("icon-", "");
|
|
80
|
+
|
|
76
81
|
const registryKey = `${collection}/${name}`;
|
|
77
82
|
return { name, collection, registryKey };
|
|
78
83
|
};
|
|
@@ -108,9 +113,22 @@ const _getRegisteredNames = async () => {
|
|
|
108
113
|
// fetch one icon of each collection to trigger the bundle load
|
|
109
114
|
await getIconData("edit");
|
|
110
115
|
await getIconData("tnt/arrow");
|
|
116
|
+
await getIconData("business-suite/3d");
|
|
111
117
|
return Array.from(registry.keys());
|
|
112
118
|
};
|
|
113
119
|
|
|
120
|
+
const _getDefaultCollection = () => {
|
|
121
|
+
return isTheme("sap_horizon") ? "SAP-icons-v5" : "SAP-icons";
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const _normalizeCollection = collectionName => {
|
|
125
|
+
if (IconCollectionsAlias[collectionName]) {
|
|
126
|
+
return IconCollectionsAlias[collectionName];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return collectionName;
|
|
130
|
+
};
|
|
131
|
+
|
|
114
132
|
export {
|
|
115
133
|
registerIconBundle,
|
|
116
134
|
registerIconLoader,
|
|
@@ -3,8 +3,8 @@ import getSharedResource from "../getSharedResource.js";
|
|
|
3
3
|
const registry = getSharedResource("SVGIllustration.registry", new Map());
|
|
4
4
|
const ILLUSTRATION_NOT_FOUND = "ILLUSTRATION_NOT_FOUND";
|
|
5
5
|
|
|
6
|
-
const registerIllustration = (name, { dialogSvg, sceneSvg, spotSvg, title, subtitle } = {}) => { // eslint-disable-line
|
|
7
|
-
registry.set(name
|
|
6
|
+
const registerIllustration = (name, { dialogSvg, sceneSvg, spotSvg, set, title, subtitle } = {}) => { // eslint-disable-line
|
|
7
|
+
registry.set(`${set}/${name}`, {
|
|
8
8
|
dialogSvg,
|
|
9
9
|
sceneSvg,
|
|
10
10
|
spotSvg,
|
|
@@ -14,7 +14,14 @@ const registerIllustration = (name, { dialogSvg, sceneSvg, spotSvg, title, subti
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const getIllustrationDataSync = nameProp => {
|
|
17
|
-
|
|
17
|
+
let set = "fiori";
|
|
18
|
+
|
|
19
|
+
if (nameProp.startsWith("Tnt")) {
|
|
20
|
+
set = "tnt";
|
|
21
|
+
nameProp = nameProp.replace(/^Tnt/, "");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return registry.get(`${set}/${nameProp}`) || ILLUSTRATION_NOT_FOUND;
|
|
18
25
|
};
|
|
19
26
|
|
|
20
27
|
export {
|
|
@@ -16,11 +16,20 @@ const M_ISO639_OLD_TO_NEW = {
|
|
|
16
16
|
"sh": "sr",
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
const DEV_MODE = false;
|
|
20
|
+
|
|
19
21
|
const _showAssetsWarningOnce = localeId => {
|
|
20
|
-
if (
|
|
22
|
+
if (warningShown) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!DEV_MODE) {
|
|
21
27
|
console.warn(`[LocaleData] Supported locale "${localeId}" not configured, import the "Assets.js" module from the webcomponents package you are using.`); /* eslint-disable-line */
|
|
22
|
-
|
|
28
|
+
} else {
|
|
29
|
+
console.warn(`[LocaleData] Note: in dev mode, CLDR assets might be disabled for performance reasons. Try running "ENABLE_CLDR=1 yarn start" to test CLDR assets.`); /* eslint-disable-line */
|
|
23
30
|
}
|
|
31
|
+
|
|
32
|
+
warningShown = true;
|
|
24
33
|
};
|
|
25
34
|
|
|
26
35
|
const calcLocale = (language, region, script) => {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported icon collection names and aliases.
|
|
3
|
+
*
|
|
4
|
+
* Users might specify a collection, using both the key and the value in the following key-value pairs,
|
|
5
|
+
* e.g the following pairs are completely exchangeable:
|
|
6
|
+
* "SAP-icons-TNT/actor" and "tnt/actor", "BusinessSuiteInAppSymbols/3d" and "business-suite/3d",
|
|
7
|
+
* "SAP-icons-v5/accept" and "horizon/accept".
|
|
8
|
+
*
|
|
9
|
+
* Note: technically, in the code we maintain the collections under the "value" name - "tnt", "business-suite",
|
|
10
|
+
* SAP-icons-v5" and "SAP-icons"(which does not have an alias).
|
|
11
|
+
*/
|
|
12
|
+
const IconCollectionsAlias = {
|
|
13
|
+
"SAP-icons-TNT": "tnt",
|
|
14
|
+
"BusinessSuiteInAppSymbols": "business-suite",
|
|
15
|
+
"horizon": "SAP-icons-v5",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default IconCollectionsAlias;
|