@ui5/webcomponents-base 0.0.0-fb61e9889 → 0.0.0-fd6264051

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.
Files changed (105) hide show
  1. package/.eslintignore +3 -1
  2. package/CHANGELOG.md +125 -0
  3. package/README.md +2 -3
  4. package/bundle.esm.js +1 -2
  5. package/dist/Boot.js +34 -18
  6. package/dist/CSP.js +59 -0
  7. package/dist/CustomElementsRegistry.js +60 -4
  8. package/dist/Device.js +15 -1
  9. package/dist/FeaturesRegistry.js +4 -1
  10. package/dist/FontFace.js +7 -95
  11. package/dist/InitialConfiguration.js +11 -0
  12. package/dist/Keys.js +32 -0
  13. package/dist/ManagedStyles.js +83 -0
  14. package/dist/Render.js +3 -1
  15. package/dist/Runtimes.js +107 -0
  16. package/dist/StaticAreaItem.js +3 -9
  17. package/dist/SystemCSSVars.js +4 -25
  18. package/dist/UI5Element.js +20 -23
  19. package/dist/UI5ElementMetadata.js +16 -0
  20. package/dist/asset-registries/Icons.js +25 -14
  21. package/dist/assets-meta/IconCollectionsAlias.js +18 -0
  22. package/dist/config/Theme.js +25 -0
  23. package/dist/css/FontFace.css +45 -0
  24. package/dist/css/OverrideFontFace.css +32 -0
  25. package/dist/css/SystemCSSVars.css +17 -0
  26. package/dist/features/F6Navigation.js +106 -0
  27. package/dist/generated/AssetParameters.js +1 -1
  28. package/dist/generated/VersionInfo.js +10 -0
  29. package/dist/generated/css/FontFace.css.js +5 -0
  30. package/dist/generated/css/OverrideFontFace.css.js +5 -0
  31. package/dist/generated/css/SystemCSSVars.css.js +5 -0
  32. package/dist/i18nBundle.js +32 -2
  33. package/dist/renderer/LitRenderer.js +6 -4
  34. package/dist/renderer/directives/style-map.js +72 -0
  35. package/dist/resources/bundle.esm.js +8 -8
  36. package/dist/resources/bundle.esm.js.map +1 -1
  37. package/dist/sap/base/security/encodeCSS.js +14 -0
  38. package/dist/sap/base/security/encodeXML.js +23 -0
  39. package/dist/sap/base/strings/toHex.js +8 -0
  40. package/dist/test-resources/pages/i18n.html +1 -3
  41. package/dist/test-resources/specs/CustomTheme.spec.js +2 -2
  42. package/dist/test-resources/specs/Theming.spec.js +4 -4
  43. package/dist/theming/CustomStyle.js +23 -3
  44. package/dist/theming/applyTheme.js +11 -10
  45. package/dist/theming/getEffectiveLinksHrefs.js +20 -0
  46. package/dist/theming/getStylesString.js +4 -2
  47. package/dist/theming/getThemeDesignerTheme.js +25 -5
  48. package/dist/theming/preloadLinks.js +23 -0
  49. package/dist/updateShadowRoot.js +8 -4
  50. package/dist/util/FocusableElements.js +8 -6
  51. package/dist/util/InvisibleMessage.js +11 -9
  52. package/dist/util/TabbableElements.js +4 -0
  53. package/dist/util/createLinkInHead.js +19 -0
  54. package/dist/util/escapeRegex.js +10 -0
  55. package/dist/util/generateHighlightedMarkup.js +42 -0
  56. package/dist/util/isNodeHidden.js +1 -1
  57. package/hash.txt +1 -1
  58. package/lib/generate-styles/index.js +18 -0
  59. package/lib/generate-version-info/index.js +27 -0
  60. package/package-scripts.js +8 -3
  61. package/package.json +5 -4
  62. package/src/Boot.js +34 -18
  63. package/src/CSP.js +59 -0
  64. package/src/CustomElementsRegistry.js +60 -4
  65. package/src/Device.js +15 -1
  66. package/src/FeaturesRegistry.js +4 -1
  67. package/src/FontFace.js +7 -95
  68. package/src/InitialConfiguration.js +11 -0
  69. package/src/Keys.js +32 -0
  70. package/src/ManagedStyles.js +83 -0
  71. package/src/Render.js +3 -1
  72. package/src/Runtimes.js +107 -0
  73. package/src/StaticAreaItem.js +3 -9
  74. package/src/SystemCSSVars.js +4 -25
  75. package/src/UI5Element.js +20 -23
  76. package/src/UI5ElementMetadata.js +16 -0
  77. package/src/asset-registries/Icons.js +25 -14
  78. package/src/assets-meta/IconCollectionsAlias.js +18 -0
  79. package/src/config/Theme.js +25 -0
  80. package/src/css/FontFace.css +45 -0
  81. package/src/css/OverrideFontFace.css +32 -0
  82. package/src/css/SystemCSSVars.css +17 -0
  83. package/src/features/F6Navigation.js +106 -0
  84. package/src/i18nBundle.js +32 -2
  85. package/src/renderer/LitRenderer.js +6 -4
  86. package/src/renderer/directives/style-map.js +72 -0
  87. package/src/theming/CustomStyle.js +23 -3
  88. package/src/theming/applyTheme.js +11 -10
  89. package/src/theming/getEffectiveLinksHrefs.js +20 -0
  90. package/src/theming/getStylesString.js +4 -2
  91. package/src/theming/getThemeDesignerTheme.js +25 -5
  92. package/src/theming/preloadLinks.js +23 -0
  93. package/src/updateShadowRoot.js +8 -4
  94. package/src/util/FocusableElements.js +8 -6
  95. package/src/util/InvisibleMessage.js +11 -9
  96. package/src/util/TabbableElements.js +4 -0
  97. package/src/util/createLinkInHead.js +19 -0
  98. package/src/util/escapeRegex.js +10 -0
  99. package/src/util/generateHighlightedMarkup.js +42 -0
  100. package/src/util/isNodeHidden.js +1 -1
  101. package/used-modules.txt +4 -1
  102. package/dist/theming/createThemePropertiesStyleTag.js +0 -20
  103. package/dist/util/encodeCSS.js +0 -24
  104. package/src/theming/createThemePropertiesStyleTag.js +0 -20
  105. package/src/util/encodeCSS.js +0 -24
package/dist/Keys.js CHANGED
@@ -131,10 +131,18 @@ const isUpShift = event => (event.key ? (event.key === "ArrowUp" || event.key ==
131
131
 
132
132
  const isDownShift = event => (event.key ? (event.key === "ArrowDown" || event.key === "Down") : event.keyCode === KeyCodes.ARROW_DOWN) && checkModifierKeys(event, false, false, true);
133
133
 
134
+ const isUpAlt = event => (event.key ? (event.key === "ArrowUp" || event.key === "Up") : event.keyCode === KeyCodes.ARROW_UP) && checkModifierKeys(event, false, true, false);
135
+
136
+ const isDownAlt = event => (event.key ? (event.key === "ArrowDown" || event.key === "Down") : event.keyCode === KeyCodes.ARROW_DOWN) && checkModifierKeys(event, false, true, false);
137
+
134
138
  const isLeftShift = event => (event.key ? (event.key === "ArrowLeft" || event.key === "Left") : event.keyCode === KeyCodes.ARROW_LEFT) && checkModifierKeys(event, false, false, true);
135
139
 
136
140
  const isRightShift = event => (event.key ? (event.key === "ArrowRight" || event.key === "Right") : event.keyCode === KeyCodes.ARROW_RIGHT) && checkModifierKeys(event, false, false, true);
137
141
 
142
+ const isLeftShiftCtrl = event => (event.key ? (event.key === "ArrowLeft" || event.key === "Left") : event.keyCode === KeyCodes.ARROW_LEFT) && checkModifierKeys(event, true, false, true);
143
+
144
+ const isRightShiftCtrl = event => (event.key ? (event.key === "ArrowRight" || event.key === "Right") : event.keyCode === KeyCodes.ARROW_RIGHT) && checkModifierKeys(event, true, false, true);
145
+
138
146
  const isUpShiftCtrl = event => (event.key ? (event.key === "ArrowUp" || event.key === "Up") : event.keyCode === KeyCodes.ARROW_UP) && checkModifierKeys(event, true, false, true);
139
147
 
140
148
  const isDownShiftCtrl = event => (event.key ? (event.key === "ArrowDown" || event.key === "Down") : event.keyCode === KeyCodes.ARROW_DOWN) && checkModifierKeys(event, true, false, true);
@@ -145,8 +153,12 @@ const isEnd = event => (event.key ? event.key === "End" : event.keyCode === KeyC
145
153
 
146
154
  const isHomeCtrl = event => (event.key ? event.key === "Home" : event.keyCode === KeyCodes.HOME) && checkModifierKeys(event, true, false, false);
147
155
 
156
+ const isHomeShift = event => (event.key ? event.key === "Home" : event.keyCode === KeyCodes.HOME) && checkModifierKeys(event, false, false, true);
157
+
148
158
  const isEndCtrl = event => (event.key ? event.key === "End" : event.keyCode === KeyCodes.END) && checkModifierKeys(event, true, false, false);
149
159
 
160
+ const isEndShift = event => (event.key ? event.key === "End" : event.keyCode === KeyCodes.END) && checkModifierKeys(event, false, false, true);
161
+
150
162
  const isEscape = event => (event.key ? event.key === "Escape" || event.key === "Esc" : event.keyCode === KeyCodes.ESCAPE) && !hasModifierKeys(event);
151
163
 
152
164
  const isTabNext = event => (event.key ? event.key === "Tab" : event.keyCode === KeyCodes.TAB) && !hasModifierKeys(event);
@@ -191,12 +203,22 @@ const isF4 = event => {
191
203
 
192
204
  const isF4Shift = event => (event.key ? event.key === "F4" : event.keyCode === KeyCodes.F4) && checkModifierKeys(event, false, false, true);
193
205
 
206
+ const isF6Next = event => ((event.key ? event.key === "F6" : event.keyCode === KeyCodes.F6) && checkModifierKeys(event, false, false, false))
207
+ || ((event.key ? (event.key === "ArrowDown" || event.key === "Down") : event.keyCode === KeyCodes.ARROW_DOWN) && checkModifierKeys(event, true, true, false));
208
+
209
+ const isF6Previous = event => ((event.key ? event.key === "F6" : event.keyCode === KeyCodes.F6) && checkModifierKeys(event, false, false, true))
210
+ || ((event.key ? (event.key === "ArrowUp" || event.key === "Up") : event.keyCode === KeyCodes.ARROW_Up) && checkModifierKeys(event, true, true, false));
211
+
194
212
  const isF7 = event => (event.key ? event.key === "F7" : event.keyCode === KeyCodes.F7) && !hasModifierKeys(event);
195
213
 
196
214
  const isShowByArrows = event => {
197
215
  return ((event.key === "ArrowDown" || event.key === "Down") || (event.key === "ArrowUp" || event.key === "Up")) && checkModifierKeys(event, /* Ctrl */ false, /* Alt */ true, /* Shift */ false);
198
216
  };
199
217
 
218
+ const isShift = event => event.key === "Shift" || event.keyCode === KeyCodes.SHIFT;
219
+
220
+ const isCtrlA = event => ((event.key === "A" || event.key === "a") || event.which === KeyCodes.A) && checkModifierKeys(event, true, false, false);
221
+
200
222
  const hasModifierKeys = event => event.shiftKey || event.altKey || getCtrlKey(event);
201
223
 
202
224
  const getCtrlKey = event => !!(event.metaKey || event.ctrlKey); // double negation doesn't have effect on boolean but ensures null and undefined are equivalent to false.
@@ -218,8 +240,12 @@ export {
218
240
  isDownCtrl,
219
241
  isUpShift,
220
242
  isDownShift,
243
+ isUpAlt,
244
+ isDownAlt,
221
245
  isLeftShift,
222
246
  isRightShift,
247
+ isLeftShiftCtrl,
248
+ isRightShiftCtrl,
223
249
  isUpShiftCtrl,
224
250
  isDownShiftCtrl,
225
251
  isHome,
@@ -228,6 +254,8 @@ export {
228
254
  isMinus,
229
255
  isHomeCtrl,
230
256
  isEndCtrl,
257
+ isHomeShift,
258
+ isEndShift,
231
259
  isEscape,
232
260
  isTabNext,
233
261
  isTabPrevious,
@@ -236,6 +264,8 @@ export {
236
264
  isShow,
237
265
  isF4,
238
266
  isF4Shift,
267
+ isF6Previous,
268
+ isF6Next,
239
269
  isF7,
240
270
  isPageUp,
241
271
  isPageDown,
@@ -245,4 +275,6 @@ export {
245
275
  isPageDownAlt,
246
276
  isPageUpShiftCtrl,
247
277
  isPageDownShiftCtrl,
278
+ isShift,
279
+ isCtrlA,
248
280
  };
@@ -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/dist/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
- if (!filters || (filters.tag === tag) || (filters.rtlAware && rtlAware) || (filters.languageAware && languageAware)) {
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
  });
@@ -0,0 +1,107 @@
1
+ import VersionInfo from "./generated/VersionInfo.js";
2
+ import getSharedResource from "./getSharedResource.js";
3
+
4
+ let currentRuntimeIndex;
5
+ let currentRuntimeAlias = "";
6
+
7
+ const compareCache = new Map();
8
+
9
+ /**
10
+ * Central registry where all runtimes register themselves by pushing an object.
11
+ * The index in the registry servers as an ID for the runtime.
12
+ * @type {*}
13
+ */
14
+ const Runtimes = getSharedResource("Runtimes", []);
15
+
16
+ /**
17
+ * Registers the current runtime in the shared runtimes resource registry
18
+ */
19
+ const registerCurrentRuntime = () => {
20
+ if (currentRuntimeIndex === undefined) {
21
+ currentRuntimeIndex = Runtimes.length;
22
+ Runtimes.push({
23
+ ...VersionInfo,
24
+ alias: currentRuntimeAlias,
25
+ description: `Runtime ${currentRuntimeIndex} - ver ${VersionInfo.version}${currentRuntimeAlias ? ` (${currentRuntimeAlias})` : ""}`,
26
+ });
27
+ }
28
+ };
29
+
30
+ /**
31
+ * Returns the index of the current runtime's object in the shared runtimes resource registry
32
+ * @returns {*}
33
+ */
34
+ const getCurrentRuntimeIndex = () => {
35
+ return currentRuntimeIndex;
36
+ };
37
+
38
+ /**
39
+ * Compares two runtimes and returns 1 if the first is of a bigger version, -1 if the second is of a bigger version, and 0 if equal
40
+ * @param index1 The index of the first runtime to compare
41
+ * @param index2 The index of the second runtime to compare
42
+ * @returns {number}
43
+ */
44
+ const compareRuntimes = (index1, index2) => {
45
+ const cacheIndex = `${index1},${index2}`;
46
+ if (compareCache.has(cacheIndex)) {
47
+ return compareCache.get(cacheIndex);
48
+ }
49
+
50
+ const runtime1 = Runtimes[index1];
51
+ const runtime2 = Runtimes[index2];
52
+
53
+ if (!runtime1 || !runtime2) {
54
+ throw new Error("Invalid runtime index supplied");
55
+ }
56
+
57
+ // If any of the two is a next version, bigger buildTime wins
58
+ if (runtime1.isNext || runtime2.isNext) {
59
+ return runtime1.buildTime - runtime2.buildTime;
60
+ }
61
+
62
+ // If major versions differ, bigger one wins
63
+ const majorDiff = runtime1.major - runtime2.major;
64
+ if (majorDiff) {
65
+ return majorDiff;
66
+ }
67
+
68
+ // If minor versions differ, bigger one wins
69
+ const minorDiff = runtime1.minor - runtime2.minor;
70
+ if (minorDiff) {
71
+ return minorDiff;
72
+ }
73
+
74
+ // If patch versions differ, bigger one wins
75
+ const patchDiff = runtime1.patch - runtime2.patch;
76
+ if (patchDiff) {
77
+ return patchDiff;
78
+ }
79
+
80
+ // Bigger suffix wins, f.e. rc10 > rc9
81
+ // Important: suffix is alphanumeric, must use natural compare
82
+ const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" });
83
+ const result = collator.compare(runtime1.suffix, runtime2.suffix);
84
+
85
+ compareCache.set(cacheIndex, result);
86
+ return result;
87
+ };
88
+
89
+ /**
90
+ * Set an alias for the the current app/library/microfrontend which will appear in debug messages and console warnings
91
+ * @param alias
92
+ */
93
+ const setRuntimeAlias = alias => {
94
+ currentRuntimeAlias = alias;
95
+ };
96
+
97
+ const getAllRuntimes = () => {
98
+ return Runtimes;
99
+ };
100
+
101
+ export {
102
+ getCurrentRuntimeIndex,
103
+ registerCurrentRuntime,
104
+ compareRuntimes,
105
+ setRuntimeAlias,
106
+ getAllRuntimes,
107
+ };
@@ -25,6 +25,9 @@ class StaticAreaItem extends HTMLElement {
25
25
  setOwnerElement(ownerElement) {
26
26
  this.ownerElement = ownerElement;
27
27
  this.classList.add(this.ownerElement._id); // used for getting the popover in the tests
28
+ if (this.ownerElement.hasAttribute("data-ui5-static-stable")) {
29
+ this.setAttribute("data-ui5-stable", this.ownerElement.getAttribute("data-ui5-static-stable")); // stable selector
30
+ }
28
31
  }
29
32
 
30
33
  /**
@@ -76,15 +79,6 @@ class StaticAreaItem extends HTMLElement {
76
79
  return this.shadowRoot;
77
80
  }
78
81
 
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
82
  static getTag() {
89
83
  const pureTag = "ui5-static-area-item";
90
84
  const suffix = getEffectiveScopingSuffixForTag(pureTag);
@@ -1,31 +1,10 @@
1
- import createStyleInHead from "./util/createStyleInHead.js";
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 (document.querySelector(`head>style[data-ui5-system-css-vars]`)) {
25
- return;
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;
@@ -18,7 +18,7 @@ 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 isLegacyBrowser from "./isLegacyBrowser.js";
21
+ import preloadLinks from "./theming/preloadLinks.js";
22
22
 
23
23
  let autoId = 0;
24
24
 
@@ -101,6 +101,9 @@ class UI5Element extends HTMLElement {
101
101
  */
102
102
  async connectedCallback() {
103
103
  this.setAttribute(this.constructor.getMetadata().getPureTag(), "");
104
+ if (this.constructor.getMetadata().supportsF6FastNavigation()) {
105
+ this.setAttribute("data-sap-ui-fastnavgroup", "true");
106
+ }
104
107
 
105
108
  const slotsAreManaged = this.constructor.getMetadata().slotsAreManaged();
106
109
 
@@ -251,7 +254,8 @@ class UI5Element extends HTMLElement {
251
254
 
252
255
  // Listen for any invalidation on the child if invalidateOnChildChange is true or an object (ignore when false or not set)
253
256
  if (child.isUI5Element && slotData.invalidateOnChildChange) {
254
- child.attachInvalidate(this._getChildChangeListener(slotName));
257
+ const method = (child.attachInvalidate || child._attachChange).bind(child);
258
+ method(this._getChildChangeListener(slotName));
255
259
  }
256
260
 
257
261
  // Listen for the slotchange event if the child is a slot itself
@@ -311,7 +315,8 @@ class UI5Element extends HTMLElement {
311
315
 
312
316
  children.forEach(child => {
313
317
  if (child && child.isUI5Element) {
314
- child.detachInvalidate(this._getChildChangeListener(slotName));
318
+ const method = (child.detachInvalidate || child._detachChange).bind(child);
319
+ method(this._getChildChangeListener(slotName));
315
320
  }
316
321
 
317
322
  if (isSlot(child)) {
@@ -607,25 +612,27 @@ class UI5Element extends HTMLElement {
607
612
 
608
613
  /**
609
614
  * Returns the DOM Element inside the Shadow Root that corresponds to the opening tag in the UI5 Web Component's template
615
+ * *Note:* For logical (abstract) elements (items, options, etc...), returns the part of the parent's DOM that represents this option
610
616
  * Use this method instead of "this.shadowRoot" to read the Shadow DOM, if ever necessary
617
+ *
611
618
  * @public
612
619
  */
613
620
  getDomRef() {
621
+ // If a component set _getRealDomRef to its children, use the return value of this function
622
+ if (typeof this._getRealDomRef === "function") {
623
+ return this._getRealDomRef();
624
+ }
625
+
614
626
  if (!this.shadowRoot || this.shadowRoot.children.length === 0) {
615
627
  return;
616
628
  }
617
629
 
618
- this._assertShadowRootStructure();
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) {
630
+ const children = [...this.shadowRoot.children].filter(child => !["link", "style"].includes(child.localName));
631
+ if (children.length !== 1) {
627
632
  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
633
  }
634
+
635
+ return children[0];
629
636
  }
630
637
 
631
638
  /**
@@ -651,17 +658,6 @@ class UI5Element extends HTMLElement {
651
658
  return this.getFocusDomRef();
652
659
  }
653
660
 
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
661
  /**
666
662
  * Set the focus to the element, returned by "getFocusDomRef()" (marked by "data-sap-focus-ref")
667
663
  * @public
@@ -988,6 +984,7 @@ class UI5Element extends HTMLElement {
988
984
  this._generateAccessors();
989
985
  registerTag(tag);
990
986
  window.customElements.define(tag, this);
987
+ preloadLinks(this);
991
988
 
992
989
  if (altTag && !customElements.get(altTag)) {
993
990
  registerTag(altTag);
@@ -188,6 +188,14 @@ class UI5ElementMetadata {
188
188
  return !!this.metadata.managedSlots;
189
189
  }
190
190
 
191
+ /**
192
+ * Determines whether this control supports F6 fast navigation
193
+ * @public
194
+ */
195
+ supportsF6FastNavigation() {
196
+ return !!this.metadata.fastNavigation;
197
+ }
198
+
191
199
  /**
192
200
  * Returns an object with key-value pairs of properties and their metadata definitions
193
201
  * @public
@@ -212,6 +220,14 @@ class UI5ElementMetadata {
212
220
  return !!this.metadata.languageAware;
213
221
  }
214
222
 
223
+ /**
224
+ * Determines whether this UI5 Element has any theme dependant carachteristics.
225
+ * @returns {boolean}
226
+ */
227
+ isThemeAware() {
228
+ return !!this.metadata.themeAware;
229
+ }
230
+
215
231
  /**
216
232
  * Matches a changed entity (property/slot) with the given name against the "invalidateOnChildChange" configuration
217
233
  * 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 { isThemeFamily } 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 = DEFAULT_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 || DEFAULT_COLLECTION;
71
- // hardcoded alias in case icon explorer is used, resolve `SAP-icons-TNT` to `tnt`
72
- // aliases can be made a feature in the future if more collections need it or more aliases are needed.
73
- if (collection === "SAP-icons-TNT") {
74
- collection = "tnt";
75
- }
76
- // hardcoded alias in case icon explorer is used, resolve `BusinessSuiteInAppSymbols` to `business-suite`
77
- // aliases can be made a feature in the future if more collections need it or more aliases are needed.
78
- if (collection === "BusinessSuiteInAppSymbols") {
79
- collection = "business-suite";
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 isThemeFamily("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,
@@ -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;
@@ -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,33 @@ 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`;
36
+ };
37
+
38
+ /**
39
+ * Returns if the current theme is part of given theme family
40
+ * @private
41
+ * @param {String} the theme family
42
+ * @returns {boolean}
43
+ */
44
+ const isThemeFamily = _theme => {
45
+ return getTheme().startsWith(_theme);
23
46
  };
24
47
 
25
48
  export {
26
49
  getTheme,
27
50
  setTheme,
51
+ isTheme,
52
+ isThemeFamily,
28
53
  };
@@ -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
+ }