@ui5/webcomponents-base 0.0.0-11d529e8a → 0.0.0-1e08ebdef
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 +42 -0
- package/README.md +2 -3
- package/bundle.esm.js +1 -2
- package/dist/CSP.js +59 -0
- package/dist/Device.js +11 -0
- package/dist/FontFace.js +7 -95
- package/dist/InitialConfiguration.js +11 -0
- package/dist/ManagedStyles.js +83 -0
- package/dist/Render.js +3 -1
- package/dist/StaticAreaItem.js +0 -9
- package/dist/SystemCSSVars.js +4 -25
- package/dist/UI5Element.js +14 -21
- package/dist/UI5ElementMetadata.js +8 -0
- package/dist/asset-registries/Icons.js +25 -14
- 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/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 +32 -2
- package/dist/renderer/LitRenderer.js +6 -4
- package/dist/renderer/directives/style-map.js +72 -0
- package/dist/resources/bundle.esm.js +8 -8
- package/dist/resources/bundle.esm.js.map +1 -1
- package/dist/sap/base/security/encodeCSS.js +14 -0
- package/dist/sap/base/security/encodeXML.js +23 -0
- package/dist/sap/base/strings/toHex.js +8 -0
- package/dist/test-resources/pages/i18n.html +1 -3
- package/dist/test-resources/specs/CustomTheme.spec.js +2 -2
- package/dist/test-resources/specs/Theming.spec.js +4 -4
- package/dist/theming/CustomStyle.js +23 -3
- package/dist/theming/applyTheme.js +11 -10
- package/dist/theming/getEffectiveLinksHrefs.js +20 -0
- package/dist/theming/getStylesString.js +4 -2
- package/dist/theming/getThemeDesignerTheme.js +25 -5
- package/dist/theming/preloadLinks.js +23 -0
- package/dist/updateShadowRoot.js +8 -4
- package/dist/util/createLinkInHead.js +19 -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 +6 -3
- package/package.json +8 -9
- package/src/CSP.js +59 -0
- package/src/Device.js +11 -0
- package/src/FontFace.js +7 -95
- package/src/InitialConfiguration.js +11 -0
- package/src/ManagedStyles.js +83 -0
- package/src/Render.js +3 -1
- package/src/StaticAreaItem.js +0 -9
- package/src/SystemCSSVars.js +4 -25
- package/src/UI5Element.js +14 -21
- package/src/UI5ElementMetadata.js +8 -0
- package/src/asset-registries/Icons.js +25 -14
- 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/i18nBundle.js +32 -2
- package/src/renderer/LitRenderer.js +6 -4
- package/src/renderer/directives/style-map.js +72 -0
- package/src/theming/CustomStyle.js +23 -3
- package/src/theming/applyTheme.js +11 -10
- package/src/theming/getEffectiveLinksHrefs.js +20 -0
- package/src/theming/getStylesString.js +4 -2
- package/src/theming/getThemeDesignerTheme.js +25 -5
- package/src/theming/preloadLinks.js +23 -0
- package/src/updateShadowRoot.js +8 -4
- package/src/util/createLinkInHead.js +19 -0
- package/src/util/escapeRegex.js +10 -0
- package/src/util/generateHighlightedMarkup.js +42 -0
- package/used-modules.txt +4 -1
- package/dist/theming/createThemePropertiesStyleTag.js +0 -20
- package/dist/util/encodeCSS.js +0 -24
- package/src/theming/createThemePropertiesStyleTag.js +0 -20
- package/src/util/encodeCSS.js +0 -24
package/src/FontFace.js
CHANGED
|
@@ -1,95 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
* CSS font face used for the texts provided by SAP.
|
|
3
|
-
*/
|
|
4
|
-
import createStyleInHead from "./util/createStyleInHead.js";
|
|
1
|
+
import { hasStyle, createStyle } from "./ManagedStyles.js";
|
|
5
2
|
import { getFeature } from "./FeaturesRegistry.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const font72RegularWoff = `https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Regular.woff?ui5-webcomponents`;
|
|
9
|
-
const font72RegularWoff2 = `https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Regular.woff2?ui5-webcomponents`;
|
|
10
|
-
|
|
11
|
-
const font72RegularFullWoff = `https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Regular-full.woff?ui5-webcomponents`;
|
|
12
|
-
const font72RegularFullWoff2 = `https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Regular-full.woff2?ui5-webcomponents`;
|
|
13
|
-
|
|
14
|
-
const font72BoldWoff = `https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Bold.woff?ui5-webcomponents`;
|
|
15
|
-
const font72BoldWoff2 = `https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Bold.woff2?ui5-webcomponents`;
|
|
16
|
-
|
|
17
|
-
const font72BoldFullWoff = `https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Bold-full.woff?ui5-webcomponents`;
|
|
18
|
-
const font72BoldFullWoff2 = `https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Bold-full.woff2?ui5-webcomponents`;
|
|
19
|
-
|
|
20
|
-
const fontFaceCSS = `
|
|
21
|
-
@font-face {
|
|
22
|
-
font-family: "72";
|
|
23
|
-
font-style: normal;
|
|
24
|
-
font-weight: 400;
|
|
25
|
-
src: local("72"),
|
|
26
|
-
url(${font72RegularWoff2}) format("woff2"),
|
|
27
|
-
url(${font72RegularWoff}) format("woff");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@font-face {
|
|
31
|
-
font-family: "72full";
|
|
32
|
-
font-style: normal;
|
|
33
|
-
font-weight: 400;
|
|
34
|
-
src: local('72-full'),
|
|
35
|
-
url(${font72RegularFullWoff2}) format("woff2"),
|
|
36
|
-
url(${font72RegularFullWoff}) format("woff");
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@font-face {
|
|
41
|
-
font-family: "72";
|
|
42
|
-
font-style: normal;
|
|
43
|
-
font-weight: 700;
|
|
44
|
-
src: local('72-Bold'),
|
|
45
|
-
url(${font72BoldWoff2}) format("woff2"),
|
|
46
|
-
url(${font72BoldWoff}) format("woff");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@font-face {
|
|
50
|
-
font-family: "72full";
|
|
51
|
-
font-style: normal;
|
|
52
|
-
font-weight: 700;
|
|
53
|
-
src: local('72-Bold-full'),
|
|
54
|
-
url(${font72BoldFullWoff2}) format("woff2"),
|
|
55
|
-
url(${font72BoldFullWoff}) format("woff");
|
|
56
|
-
}
|
|
57
|
-
`;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Some diacritics are supported by the 72 font:
|
|
61
|
-
* * Grave
|
|
62
|
-
* * Acute
|
|
63
|
-
* * Circumflex
|
|
64
|
-
* * Tilde
|
|
65
|
-
*
|
|
66
|
-
* However, the following diacritics and the combination of multiple diacritics (including the supported ones) are not supported:
|
|
67
|
-
* * Breve
|
|
68
|
-
* * Horn
|
|
69
|
-
* * Dot below
|
|
70
|
-
* * Hook above
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* Override for the characters that aren't covered by the '72' font to other system fonts
|
|
74
|
-
*
|
|
75
|
-
* U+0102-0103: A and a with Breve
|
|
76
|
-
* U+01A0-01A1: O and o with Horn
|
|
77
|
-
* U+01AF-01B0: U and u with Horn
|
|
78
|
-
* U+1EA0-1EB7: A and a with diacritics that are not supported by the font and combination of multiple diacritics
|
|
79
|
-
* U+1EB8-1EC7: E and e with diacritics that are not supported by the font and combination of multiple diacritics
|
|
80
|
-
* U+1EC8-1ECB: I and i with diacritics that are not supported by the font and combination of multiple diacritics
|
|
81
|
-
* U+1ECC-1EE3: O and o with diacritics that are not supported by the font and combination of multiple diacritics
|
|
82
|
-
* U+1EE4-1EF1: U and u with diacritics that are not supported by the font and combination of multiple diacritics
|
|
83
|
-
* U+1EF4-1EF7: Y and y with diacritics that are not supported by the font and combination of multiple diacritics
|
|
84
|
-
*
|
|
85
|
-
*/
|
|
86
|
-
const overrideFontFaceCSS = `
|
|
87
|
-
@font-face {
|
|
88
|
-
font-family: '72override';
|
|
89
|
-
unicode-range: U+0102-0103, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EB7, U+1EB8-1EC7, U+1EC8-1ECB, U+1ECC-1EE3, U+1EE4-1EF1, U+1EF4-1EF7;
|
|
90
|
-
src: local('Arial'), local('Helvetica'), local('sans-serif');
|
|
91
|
-
}
|
|
92
|
-
`;
|
|
3
|
+
import fontFaceCSS from "./generated/css/FontFace.css.js";
|
|
4
|
+
import overrideFontFaceCSS from "./generated/css/OverrideFontFace.css.js";
|
|
93
5
|
|
|
94
6
|
const insertFontFace = () => {
|
|
95
7
|
const OpenUI5Support = getFeature("OpenUI5Support");
|
|
@@ -104,14 +16,14 @@ const insertFontFace = () => {
|
|
|
104
16
|
};
|
|
105
17
|
|
|
106
18
|
const insertMainFontFace = () => {
|
|
107
|
-
if (!
|
|
108
|
-
|
|
19
|
+
if (!hasStyle("data-ui5-font-face")) {
|
|
20
|
+
createStyle(fontFaceCSS, "data-ui5-font-face");
|
|
109
21
|
}
|
|
110
22
|
};
|
|
111
23
|
|
|
112
24
|
const insertOverrideFontFace = () => {
|
|
113
|
-
if (!
|
|
114
|
-
|
|
25
|
+
if (!hasStyle("data-ui5-font-face-override")) {
|
|
26
|
+
createStyle(overrideFontFaceCSS, "data-ui5-font-face-override");
|
|
115
27
|
}
|
|
116
28
|
};
|
|
117
29
|
|
|
@@ -106,6 +106,14 @@ const parseURLParameters = () => {
|
|
|
106
106
|
});
|
|
107
107
|
};
|
|
108
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
|
+
|
|
109
117
|
const applyURLParam = (key, value, paramType) => {
|
|
110
118
|
const lowerCaseValue = value.toLowerCase();
|
|
111
119
|
const param = key.split(`${paramType}-`)[1];
|
|
@@ -113,6 +121,9 @@ const applyURLParam = (key, value, paramType) => {
|
|
|
113
121
|
if (booleanMapping.has(value)) {
|
|
114
122
|
value = booleanMapping.get(lowerCaseValue);
|
|
115
123
|
}
|
|
124
|
+
|
|
125
|
+
value = normalizeParamValue(param, value);
|
|
126
|
+
|
|
116
127
|
initialConfig[param] = value;
|
|
117
128
|
};
|
|
118
129
|
|
|
@@ -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
|
@@ -76,15 +76,6 @@ class StaticAreaItem extends HTMLElement {
|
|
|
76
76
|
return this.shadowRoot;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
/**
|
|
80
|
-
* @protected
|
|
81
|
-
* @param refName
|
|
82
|
-
* @returns {Element}
|
|
83
|
-
*/
|
|
84
|
-
getStableDomRef(refName) {
|
|
85
|
-
return this.shadowRoot.querySelector(`[data-ui5-stable=${refName}]`);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
79
|
static getTag() {
|
|
89
80
|
const pureTag = "ui5-static-area-item";
|
|
90
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
|
@@ -18,7 +18,8 @@ import { isSlot, getSlotName, getSlottedElementsList } from "./util/SlotsHelper.
|
|
|
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
|
+
import "focus-visible";
|
|
22
23
|
|
|
23
24
|
let autoId = 0;
|
|
24
25
|
|
|
@@ -607,25 +608,27 @@ class UI5Element extends HTMLElement {
|
|
|
607
608
|
|
|
608
609
|
/**
|
|
609
610
|
* Returns the DOM Element inside the Shadow Root that corresponds to the opening tag in the UI5 Web Component's template
|
|
611
|
+
* *Note:* For logical (abstract) elements (items, options, etc...), returns the part of the parent's DOM that represents this option
|
|
610
612
|
* Use this method instead of "this.shadowRoot" to read the Shadow DOM, if ever necessary
|
|
613
|
+
*
|
|
611
614
|
* @public
|
|
612
615
|
*/
|
|
613
616
|
getDomRef() {
|
|
617
|
+
// If a component set _getRealDomRef to its children, use the return value of this function
|
|
618
|
+
if (typeof this._getRealDomRef === "function") {
|
|
619
|
+
return this._getRealDomRef();
|
|
620
|
+
}
|
|
621
|
+
|
|
614
622
|
if (!this.shadowRoot || this.shadowRoot.children.length === 0) {
|
|
615
623
|
return;
|
|
616
624
|
}
|
|
617
625
|
|
|
618
|
-
this.
|
|
619
|
-
|
|
620
|
-
return this.shadowRoot.children.length === 1
|
|
621
|
-
? this.shadowRoot.children[0] : this.shadowRoot.children[1];
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
_assertShadowRootStructure() {
|
|
625
|
-
const expectedChildrenCount = document.adoptedStyleSheets || isLegacyBrowser() ? 1 : 2;
|
|
626
|
-
if (this.shadowRoot.children.length !== expectedChildrenCount) {
|
|
626
|
+
const children = [...this.shadowRoot.children].filter(child => !["link", "style"].includes(child.localName));
|
|
627
|
+
if (children.length !== 1) {
|
|
627
628
|
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
|
|
628
629
|
}
|
|
630
|
+
|
|
631
|
+
return children[0];
|
|
629
632
|
}
|
|
630
633
|
|
|
631
634
|
/**
|
|
@@ -651,17 +654,6 @@ class UI5Element extends HTMLElement {
|
|
|
651
654
|
return this.getFocusDomRef();
|
|
652
655
|
}
|
|
653
656
|
|
|
654
|
-
/**
|
|
655
|
-
* 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
|
|
656
|
-
* @public
|
|
657
|
-
* @method
|
|
658
|
-
* @param {String} refName Defines the name of the stable DOM ref
|
|
659
|
-
*/
|
|
660
|
-
getStableDomRef(refName) {
|
|
661
|
-
const staticAreaResult = this.staticAreaItem && this.staticAreaItem.getStableDomRef(refName);
|
|
662
|
-
return staticAreaResult || this.getDomRef().querySelector(`[data-ui5-stable=${refName}]`);
|
|
663
|
-
}
|
|
664
|
-
|
|
665
657
|
/**
|
|
666
658
|
* Set the focus to the element, returned by "getFocusDomRef()" (marked by "data-sap-focus-ref")
|
|
667
659
|
* @public
|
|
@@ -988,6 +980,7 @@ class UI5Element extends HTMLElement {
|
|
|
988
980
|
this._generateAccessors();
|
|
989
981
|
registerTag(tag);
|
|
990
982
|
window.customElements.define(tag, this);
|
|
983
|
+
preloadLinks(this);
|
|
991
984
|
|
|
992
985
|
if (altTag && !customElements.get(altTag)) {
|
|
993
986
|
registerTag(altTag);
|
|
@@ -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,18 +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
|
-
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
name = name.replace("icon-", "");
|
|
81
|
-
}
|
|
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
|
+
|
|
82
81
|
const registryKey = `${collection}/${name}`;
|
|
83
82
|
return { name, collection, registryKey };
|
|
84
83
|
};
|
|
@@ -118,6 +117,18 @@ const _getRegisteredNames = async () => {
|
|
|
118
117
|
return Array.from(registry.keys());
|
|
119
118
|
};
|
|
120
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
|
+
|
|
121
132
|
export {
|
|
122
133
|
registerIconBundle,
|
|
123
134
|
registerIconLoader,
|
|
@@ -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;
|
package/src/config/Theme.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getTheme as getConfiguredTheme } from "../InitialConfiguration.js";
|
|
2
|
+
import { reRenderAllUI5Elements } from "../Render.js";
|
|
2
3
|
import applyTheme from "../theming/applyTheme.js";
|
|
3
4
|
|
|
4
5
|
let theme;
|
|
@@ -20,9 +21,22 @@ const setTheme = async newTheme => {
|
|
|
20
21
|
|
|
21
22
|
// Update CSS Custom Properties
|
|
22
23
|
await applyTheme(theme);
|
|
24
|
+
await reRenderAllUI5Elements({ themeAware: true });
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Returns if the given theme name is the one currently applied.
|
|
29
|
+
* @private
|
|
30
|
+
* @param {String}
|
|
31
|
+
* @returns {boolean}
|
|
32
|
+
*/
|
|
33
|
+
const isTheme = _theme => {
|
|
34
|
+
const currentTheme = getTheme();
|
|
35
|
+
return currentTheme === _theme || currentTheme === `${_theme}_exp`;
|
|
23
36
|
};
|
|
24
37
|
|
|
25
38
|
export {
|
|
26
39
|
getTheme,
|
|
27
40
|
setTheme,
|
|
41
|
+
isTheme,
|
|
28
42
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
@font-face {
|
|
2
|
+
font-family: "72";
|
|
3
|
+
font-style: normal;
|
|
4
|
+
font-weight: 400;
|
|
5
|
+
src: local("72"),
|
|
6
|
+
url(https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Regular.woff2?ui5-webcomponents) format("woff2"),
|
|
7
|
+
url(https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Regular.woff?ui5-webcomponents) format("woff");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@font-face {
|
|
11
|
+
font-family: "72full";
|
|
12
|
+
font-style: normal;
|
|
13
|
+
font-weight: 400;
|
|
14
|
+
src: local('72-full'),
|
|
15
|
+
url(https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Regular-full.woff2?ui5-webcomponents) format("woff2"),
|
|
16
|
+
url(https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Regular-full.woff?ui5-webcomponents) format("woff");
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@font-face {
|
|
21
|
+
font-family: "72";
|
|
22
|
+
font-style: normal;
|
|
23
|
+
font-weight: 700;
|
|
24
|
+
src: local('72-Bold'),
|
|
25
|
+
url(https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Bold.woff2?ui5-webcomponents) format("woff2"),
|
|
26
|
+
url(https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Bold.woff?ui5-webcomponents) format("woff");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@font-face {
|
|
30
|
+
font-family: "72full";
|
|
31
|
+
font-style: normal;
|
|
32
|
+
font-weight: 700;
|
|
33
|
+
src: local('72-Bold-full'),
|
|
34
|
+
url(https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Bold-full.woff2?ui5-webcomponents) format("woff2"),
|
|
35
|
+
url(https://ui5.sap.com/sdk/resources/sap/ui/core/themes/sap_fiori_3/fonts/72-Bold-full.woff?ui5-webcomponents) format("woff");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@font-face {
|
|
39
|
+
font-family: "72Black";
|
|
40
|
+
font-style: bold;
|
|
41
|
+
font-weight: 900;
|
|
42
|
+
src: local('72Black'),
|
|
43
|
+
url(https://openui5nightly.hana.ondemand.com/resources/sap/ui/core/themes/sap_horizon/fonts/72-Black.woff2?ui5-webcomponents) format("woff2"),
|
|
44
|
+
url(https://openui5nightly.hana.ondemand.com/resources/sap/ui/core/themes/sap_horizon/fonts/72-Black.woff?ui5-webcomponents) format("woff");
|
|
45
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Some diacritics are supported by the 72 font:
|
|
3
|
+
* * Grave
|
|
4
|
+
* * Acute
|
|
5
|
+
* * Circumflex
|
|
6
|
+
* * Tilde
|
|
7
|
+
*
|
|
8
|
+
* However, the following diacritics and the combination of multiple diacritics (including the supported ones) are not supported:
|
|
9
|
+
* * Breve
|
|
10
|
+
* * Horn
|
|
11
|
+
* * Dot below
|
|
12
|
+
* * Hook above
|
|
13
|
+
*
|
|
14
|
+
*
|
|
15
|
+
* Override for the characters that aren't covered by the '72' font to other system fonts
|
|
16
|
+
*
|
|
17
|
+
* U+0102-0103: A and a with Breve
|
|
18
|
+
* U+01A0-01A1: O and o with Horn
|
|
19
|
+
* U+01AF-01B0: U and u with Horn
|
|
20
|
+
* U+1EA0-1EB7: A and a with diacritics that are not supported by the font and combination of multiple diacritics
|
|
21
|
+
* U+1EB8-1EC7: E and e with diacritics that are not supported by the font and combination of multiple diacritics
|
|
22
|
+
* U+1EC8-1ECB: I and i with diacritics that are not supported by the font and combination of multiple diacritics
|
|
23
|
+
* U+1ECC-1EE3: O and o with diacritics that are not supported by the font and combination of multiple diacritics
|
|
24
|
+
* U+1EE4-1EF1: U and u with diacritics that are not supported by the font and combination of multiple diacritics
|
|
25
|
+
* U+1EF4-1EF7: Y and y with diacritics that are not supported by the font and combination of multiple diacritics
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
@font-face {
|
|
29
|
+
font-family: '72override';
|
|
30
|
+
unicode-range: U+0102-0103, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EB7, U+1EB8-1EC7, U+1EC8-1ECB, U+1ECC-1EE3, U+1EE4-1EF1, U+1EF4-1EF7;
|
|
31
|
+
src: local('Arial'), local('Helvetica'), local('sans-serif');
|
|
32
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--_ui5_content_density:cozy;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
[data-ui5-compact-size],
|
|
6
|
+
.ui5-content-density-compact,
|
|
7
|
+
.sapUiSizeCompact {
|
|
8
|
+
--_ui5_content_density:compact;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
[dir="rtl"] {
|
|
12
|
+
--_ui5_dir:rtl;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
[dir="ltr"] {
|
|
16
|
+
--_ui5_dir:ltr;
|
|
17
|
+
}
|