@ui5/webcomponents-base 0.0.0-41ab6cd28 → 0.0.0-4237771ff

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 (124) hide show
  1. package/CHANGELOG.md +394 -0
  2. package/README.md +2 -1
  3. package/dist/.tsbuildinfo +1 -0
  4. package/dist/AssetRegistry.d.ts +2 -2
  5. package/dist/AssetRegistry.js +2 -2
  6. package/dist/AssetRegistry.js.map +1 -1
  7. package/dist/Boot.js +1 -1
  8. package/dist/Boot.js.map +1 -1
  9. package/dist/CustomElementsScope.d.ts +4 -4
  10. package/dist/CustomElementsScope.js +2 -2
  11. package/dist/CustomElementsScope.js.map +1 -1
  12. package/dist/CustomElementsScopeUtils.d.ts +8 -1
  13. package/dist/CustomElementsScopeUtils.js +13 -1
  14. package/dist/CustomElementsScopeUtils.js.map +1 -1
  15. package/dist/Device.d.ts +2 -1
  16. package/dist/Device.js +10 -1
  17. package/dist/Device.js.map +1 -1
  18. package/dist/FontFace.js +1 -1
  19. package/dist/FontFace.js.map +1 -1
  20. package/dist/InitialConfiguration.d.ts +2 -1
  21. package/dist/InitialConfiguration.js +7 -2
  22. package/dist/InitialConfiguration.js.map +1 -1
  23. package/dist/Keys.d.ts +5 -1
  24. package/dist/Keys.js +109 -106
  25. package/dist/Keys.js.map +1 -1
  26. package/dist/ManagedStyles.d.ts +5 -4
  27. package/dist/ManagedStyles.js +92 -23
  28. package/dist/ManagedStyles.js.map +1 -1
  29. package/dist/StaticAreaItem.d.ts +1 -0
  30. package/dist/StaticAreaItem.js +7 -7
  31. package/dist/StaticAreaItem.js.map +1 -1
  32. package/dist/UI5Element.d.ts +16 -2
  33. package/dist/UI5Element.js +31 -15
  34. package/dist/UI5Element.js.map +1 -1
  35. package/dist/UI5ElementMetadata.d.ts +1 -0
  36. package/dist/UI5ElementMetadata.js +2 -2
  37. package/dist/UI5ElementMetadata.js.map +1 -1
  38. package/dist/api.json +1 -1
  39. package/dist/asset-registries/Icons.d.ts +4 -3
  40. package/dist/asset-registries/Icons.js +28 -17
  41. package/dist/asset-registries/Icons.js.map +1 -1
  42. package/dist/asset-registries/Illustrations.d.ts +1 -0
  43. package/dist/asset-registries/Illustrations.js +57 -19
  44. package/dist/asset-registries/Illustrations.js.map +1 -1
  45. package/dist/asset-registries/Themes.d.ts +4 -3
  46. package/dist/asset-registries/Themes.js +26 -10
  47. package/dist/asset-registries/Themes.js.map +1 -1
  48. package/dist/asset-registries/i18n.js +2 -1
  49. package/dist/asset-registries/i18n.js.map +1 -1
  50. package/dist/{assets-meta → asset-registries/util}/IconCollectionsAlias.d.ts +1 -2
  51. package/dist/{assets-meta → asset-registries/util}/IconCollectionsAlias.js +1 -2
  52. package/dist/asset-registries/util/IconCollectionsAlias.js.map +1 -0
  53. package/dist/asset-registries/util/IconCollectionsByTheme.d.ts +20 -0
  54. package/dist/asset-registries/util/IconCollectionsByTheme.js +42 -0
  55. package/dist/asset-registries/util/IconCollectionsByTheme.js.map +1 -0
  56. package/dist/asset-registries/util/getIconCollectionByTheme.d.ts +13 -0
  57. package/dist/asset-registries/util/getIconCollectionByTheme.js +29 -0
  58. package/dist/asset-registries/util/getIconCollectionByTheme.js.map +1 -0
  59. package/dist/config/CalendarType.d.ts +8 -1
  60. package/dist/config/CalendarType.js +18 -2
  61. package/dist/config/CalendarType.js.map +1 -1
  62. package/dist/config/Icons.d.ts +2 -17
  63. package/dist/config/Icons.js +1 -60
  64. package/dist/config/Icons.js.map +1 -1
  65. package/dist/connectToComponent.d.ts +9 -0
  66. package/dist/connectToComponent.js +59 -0
  67. package/dist/connectToComponent.js.map +1 -0
  68. package/dist/css/FontFace.css +47 -17
  69. package/dist/delegate/ItemNavigation.d.ts +1 -0
  70. package/dist/delegate/ItemNavigation.js +4 -5
  71. package/dist/delegate/ItemNavigation.js.map +1 -1
  72. package/dist/delegate/ScrollEnablement.js +2 -2
  73. package/dist/delegate/ScrollEnablement.js.map +1 -1
  74. package/dist/features/OpenUI5Enablement.d.ts +1 -1
  75. package/dist/features/OpenUI5Support.d.ts +13 -3
  76. package/dist/features/OpenUI5Support.js +89 -33
  77. package/dist/features/OpenUI5Support.js.map +1 -1
  78. package/dist/generated/AssetParameters.d.ts +6 -0
  79. package/dist/generated/AssetParameters.js +3 -10
  80. package/dist/generated/AssetParameters.js.map +1 -0
  81. package/dist/generated/VersionInfo.d.ts +10 -0
  82. package/dist/generated/VersionInfo.js +9 -8
  83. package/dist/generated/VersionInfo.js.map +1 -0
  84. package/dist/generated/css/FontFace.css.js +1 -1
  85. package/dist/generated/css/FontFace.css.js.map +1 -1
  86. package/dist/generated/templates/elements/WithComplexTemplateTemplate.lit.d.ts +1 -1
  87. package/dist/i18nBundle.d.ts +1 -1
  88. package/dist/i18nBundle.js.map +1 -1
  89. package/dist/renderer/LitRenderer.d.ts +2 -2
  90. package/dist/sap/ui/thirdparty/caja-html-sanitizer.js +111 -96
  91. package/dist/theming/applyTheme.js +5 -5
  92. package/dist/theming/applyTheme.js.map +1 -1
  93. package/dist/types/CSSSize.d.ts +15 -0
  94. package/dist/types/CSSSize.js +18 -0
  95. package/dist/types/CSSSize.js.map +1 -0
  96. package/dist/types/InvisibleMessageMode.d.ts +5 -4
  97. package/dist/types/InvisibleMessageMode.js +4 -5
  98. package/dist/types/InvisibleMessageMode.js.map +1 -1
  99. package/dist/updateShadowRoot.js +2 -1
  100. package/dist/updateShadowRoot.js.map +1 -1
  101. package/dist/util/ColorConversion.js +200 -195
  102. package/dist/util/ColorConversion.js.map +1 -1
  103. package/dist/util/InvisibleMessage.d.ts +1 -1
  104. package/dist/util/InvisibleMessage.js.map +1 -1
  105. package/dist/util/PopupUtils.js +1 -1
  106. package/dist/util/PopupUtils.js.map +1 -1
  107. package/dist/util/getClassCopy.d.ts +47 -31
  108. package/dist/util/getParentElement.d.ts +2 -0
  109. package/dist/util/getParentElement.js +5 -0
  110. package/dist/util/getParentElement.js.map +1 -0
  111. package/dist/util/isElementContainingBlock.d.ts +2 -0
  112. package/dist/util/isElementContainingBlock.js +11 -0
  113. package/dist/util/isElementContainingBlock.js.map +1 -0
  114. package/index.js +3 -3
  115. package/lib/generate-asset-parameters/index.js +2 -2
  116. package/lib/generate-version-info/index.js +2 -2
  117. package/package-scripts.cjs +6 -7
  118. package/package.json +8 -5
  119. package/src/css/FontFace.css +47 -17
  120. package/tsconfig.json +3 -0
  121. package/dist/assets/Boot.34b7cea0.css +0 -1
  122. package/dist/assets/Boot.e98db706.js +0 -9
  123. package/dist/assets/bundle.esm.027ecc55.js +0 -50
  124. package/dist/assets-meta/IconCollectionsAlias.js.map +0 -1
@@ -1,70 +1,122 @@
1
1
  import createStyleInHead from "./util/createStyleInHead.js";
2
2
  import createLinkInHead from "./util/createLinkInHead.js";
3
3
  import { shouldUseLinks, getUrl } from "./CSP.js";
4
- import { getCurrentRuntimeIndex } from "./Runtimes.js";
4
+ import { isSafari } from "./Device.js";
5
+ import { getCurrentRuntimeIndex, compareRuntimes } from "./Runtimes.js";
5
6
  const getStyleId = (name, value) => {
6
7
  return value ? `${name}|${value}` : name;
7
8
  };
8
- const createStyle = (data, name, value = "") => {
9
- let content = typeof data === "string" ? data : data.content;
10
- if (content.includes("[_ui5host]")) {
11
- content = content.replaceAll("[_ui5host]", `[_ui5rt${getCurrentRuntimeIndex()}]`);
9
+ const shouldUpdate = (runtimeIndex) => {
10
+ if (runtimeIndex === undefined) {
11
+ return true;
12
12
  }
13
+ return compareRuntimes(getCurrentRuntimeIndex(), parseInt(runtimeIndex)) === 1; // 1 means the current is newer, 0 means the same, -1 means the resource's runtime is newer
14
+ };
15
+ const createStyle = (data, name, value = "", theme) => {
16
+ const content = typeof data === "string" ? data : data.content;
17
+ const currentRuntimeIndex = getCurrentRuntimeIndex();
13
18
  if (shouldUseLinks()) {
14
19
  const attributes = {};
15
20
  attributes[name] = value;
21
+ if (theme) {
22
+ attributes["data-ui5-runtime-index"] = currentRuntimeIndex;
23
+ attributes["data-ui5-theme"] = theme;
24
+ }
16
25
  const href = getUrl(data.packageName, data.fileName);
17
26
  createLinkInHead(href, attributes);
18
27
  }
19
- else if (document.adoptedStyleSheets) {
28
+ else if (document.adoptedStyleSheets && !isSafari()) {
20
29
  const stylesheet = new CSSStyleSheet();
21
30
  stylesheet.replaceSync(content);
22
31
  stylesheet._ui5StyleId = getStyleId(name, value); // set an id so that we can find the style later
32
+ if (theme) {
33
+ stylesheet._ui5RuntimeIndex = currentRuntimeIndex;
34
+ stylesheet._ui5Theme = theme;
35
+ }
23
36
  document.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];
24
37
  }
25
38
  else {
26
39
  const attributes = {};
27
40
  attributes[name] = value;
41
+ if (theme) {
42
+ attributes["data-ui5-runtime-index"] = currentRuntimeIndex;
43
+ attributes["data-ui5-theme"] = theme;
44
+ }
28
45
  createStyleInHead(content, attributes);
29
46
  }
30
47
  };
31
- const updateStyle = (data, name, value = "") => {
32
- let content = typeof data === "string" ? data : data.content;
33
- if (content.includes("[_ui5host]")) {
34
- content = content.replaceAll("[_ui5host]", `[_ui5rt${getCurrentRuntimeIndex()}]`);
35
- }
48
+ const updateStyle = (data, name, value = "", theme) => {
49
+ const content = typeof data === "string" ? data : data.content;
50
+ const currentRuntimeIndex = getCurrentRuntimeIndex();
36
51
  if (shouldUseLinks()) {
37
52
  const link = document.querySelector(`head>link[${name}="${value}"]`);
38
- link.href = getUrl(data.packageName, data.fileName);
53
+ const href = getUrl(data.packageName, data.fileName);
54
+ if (!theme) {
55
+ link.href = href;
56
+ }
57
+ else {
58
+ const linkRuntimeIndex = link.getAttribute("data-ui5-runtime-index") || undefined;
59
+ const linkTheme = link.getAttribute("data-ui5-theme");
60
+ if (linkTheme !== theme || shouldUpdate(linkRuntimeIndex)) {
61
+ link.href = href;
62
+ link.setAttribute("data-ui5-runtime-index", String(currentRuntimeIndex));
63
+ link.setAttribute("data-ui5-theme", theme);
64
+ }
65
+ }
39
66
  }
40
- else if (document.adoptedStyleSheets) {
67
+ else if (document.adoptedStyleSheets && !isSafari()) {
41
68
  const stylesheet = document.adoptedStyleSheets.find(sh => sh._ui5StyleId === getStyleId(name, value));
42
- if (stylesheet) {
69
+ if (!stylesheet) {
70
+ return;
71
+ }
72
+ if (!theme) {
43
73
  stylesheet.replaceSync(content || "");
44
74
  }
75
+ else {
76
+ const stylesheetRuntimeIndex = stylesheet._ui5RuntimeIndex;
77
+ const stylesheetTheme = stylesheet._ui5Theme;
78
+ if (stylesheetTheme !== theme || shouldUpdate(stylesheetRuntimeIndex)) {
79
+ stylesheet.replaceSync(content || "");
80
+ stylesheet._ui5RuntimeIndex = String(currentRuntimeIndex);
81
+ stylesheet._ui5Theme = theme;
82
+ }
83
+ }
45
84
  }
46
85
  else {
47
86
  const style = document.querySelector(`head>style[${name}="${value}"]`);
48
- if (style) {
87
+ if (!style) {
88
+ return;
89
+ }
90
+ if (!theme) {
49
91
  style.textContent = content || "";
50
92
  }
93
+ else {
94
+ const styleRuntimeIndex = style.getAttribute("data-ui5-runtime-index") || undefined;
95
+ const styleTheme = style.getAttribute("data-ui5-theme");
96
+ if (styleTheme !== theme || shouldUpdate(styleRuntimeIndex)) {
97
+ style.textContent = content || "";
98
+ style.setAttribute("data-ui5-runtime-index", String(currentRuntimeIndex));
99
+ style.setAttribute("data-ui5-theme", theme);
100
+ }
101
+ }
51
102
  }
52
103
  };
53
104
  const hasStyle = (name, value = "") => {
54
105
  if (shouldUseLinks()) {
55
106
  return !!document.querySelector(`head>link[${name}="${value}"]`);
56
107
  }
57
- if (document.adoptedStyleSheets) {
58
- return !!document.adoptedStyleSheets.find(sh => sh._ui5StyleId === getStyleId(name, value));
108
+ const styleElement = document.querySelector(`head>style[${name}="${value}"]`);
109
+ if (document.adoptedStyleSheets && !isSafari()) {
110
+ return !!styleElement || !!document.adoptedStyleSheets.find(sh => sh._ui5StyleId === getStyleId(name, value));
59
111
  }
60
- return !!document.querySelector(`head>style[${name}="${value}"]`);
112
+ return !!styleElement;
61
113
  };
62
114
  const removeStyle = (name, value = "") => {
63
115
  if (shouldUseLinks()) {
64
116
  const linkElement = document.querySelector(`head>link[${name}="${value}"]`);
65
117
  linkElement?.parentElement?.removeChild(linkElement);
66
118
  }
67
- else if (document.adoptedStyleSheets) {
119
+ else if (document.adoptedStyleSheets && !isSafari()) {
68
120
  document.adoptedStyleSheets = document.adoptedStyleSheets.filter(sh => sh._ui5StyleId !== getStyleId(name, value));
69
121
  }
70
122
  else {
@@ -72,13 +124,30 @@ const removeStyle = (name, value = "") => {
72
124
  styleElement?.parentElement?.removeChild(styleElement);
73
125
  }
74
126
  };
75
- const createOrUpdateStyle = (data, name, value = "") => {
127
+ const createOrUpdateStyle = (data, name, value = "", theme) => {
76
128
  if (hasStyle(name, value)) {
77
- updateStyle(data, name, value);
129
+ updateStyle(data, name, value, theme);
78
130
  }
79
131
  else {
80
- createStyle(data, name, value);
132
+ createStyle(data, name, value, theme);
133
+ }
134
+ };
135
+ const mergeStyles = (style1, style2) => {
136
+ if (style1 === undefined) {
137
+ return style2;
138
+ }
139
+ if (style2 === undefined) {
140
+ return style1;
141
+ }
142
+ const style2Content = typeof style2 === "string" ? style2 : style2.content;
143
+ if (typeof style1 === "string") {
144
+ return `${style1} ${style2Content}`;
81
145
  }
146
+ return {
147
+ content: `${style1.content} ${style2Content}`,
148
+ packageName: style1.packageName,
149
+ fileName: style1.fileName,
150
+ };
82
151
  };
83
- export { createStyle, hasStyle, updateStyle, removeStyle, createOrUpdateStyle, };
152
+ export { createStyle, hasStyle, updateStyle, removeStyle, createOrUpdateStyle, mergeStyles, };
84
153
  //# sourceMappingURL=ManagedStyles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ManagedStyles.js","sourceRoot":"","sources":["../src/ManagedStyles.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAC5D,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC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AQ,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE;QAC1B,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;KAC/B;SAAM;QACN,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;KAC/B;AACF,CAAC,CAAC;AAEF,OAAO,EACN,WAAW,EACX,QAAQ,EACR,WAAW,EACX,WAAW,EACX,mBAAmB,GACnB,CAAC","sourcesContent":["import createStyleInHead from \"./util/createStyleInHead.js\";\nimport createLinkInHead from \"./util/createLinkInHead.js\";\nimport { shouldUseLinks, getUrl } from \"./CSP.js\";\nimport { StyleData, StyleDataCSP } from \"./types.js\";\nimport { getCurrentRuntimeIndex } from \"./Runtimes.js\";\n\nconst getStyleId = (name: string, value: string) => {\n\treturn value ? `${name}|${value}` : name;\n};\n\nconst createStyle = (data: StyleData, name: string, value = \"\") => {\n\tlet content = typeof data === \"string\" ? data : data.content;\n\n\tif (content.includes(\"[_ui5host]\")) {\n\t\tcontent = content.replaceAll(\"[_ui5host]\", `[_ui5rt${getCurrentRuntimeIndex()}]`);\n\t}\n\n\tif (shouldUseLinks()) {\n\t\tconst attributes = {} as Record<string, any>;\n\t\tattributes[name] = value;\n\t\tconst href = getUrl((data as StyleDataCSP).packageName, (data as StyleDataCSP).fileName);\n\t\tcreateLinkInHead(href, attributes);\n\t} else if (document.adoptedStyleSheets) {\n\t\tconst stylesheet = new CSSStyleSheet();\n\t\tstylesheet.replaceSync(content);\n\t\t(stylesheet as Record<string, any>)._ui5StyleId = getStyleId(name, value); // set an id so that we can find the style later\n\t\tdocument.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];\n\t} else {\n\t\tconst attributes = {} as Record<string, any>;\n\t\tattributes[name] = value;\n\t\tcreateStyleInHead(content, attributes);\n\t}\n};\n\nconst updateStyle = (data: StyleData, name: string, value = \"\") => {\n\tlet content = typeof data === \"string\" ? data : data.content;\n\n\tif (content.includes(\"[_ui5host]\")) {\n\t\tcontent = content.replaceAll(\"[_ui5host]\", `[_ui5rt${getCurrentRuntimeIndex()}]`);\n\t}\n\n\tif (shouldUseLinks()) {\n\t\tconst link = document.querySelector(`head>link[${name}=\"${value}\"]`) as HTMLLinkElement;\n\t\tlink.href = getUrl((data as StyleDataCSP).packageName, (data as StyleDataCSP).fileName);\n\t} else if (document.adoptedStyleSheets) {\n\t\tconst stylesheet = document.adoptedStyleSheets.find(sh => (sh as Record<string, any>)._ui5StyleId === getStyleId(name, value));\n\t\tif (stylesheet) {\n\t\t\tstylesheet.replaceSync(content || \"\");\n\t\t}\n\t} else {\n\t\tconst style = document.querySelector(`head>style[${name}=\"${value}\"]`);\n\t\tif (style) {\n\t\t\tstyle.textContent = content || \"\";\n\t\t}\n\t}\n};\n\nconst hasStyle = (name: string, value = \"\") => {\n\tif (shouldUseLinks()) {\n\t\treturn !!document.querySelector(`head>link[${name}=\"${value}\"]`);\n\t}\n\n\tif (document.adoptedStyleSheets) {\n\t\treturn !!document.adoptedStyleSheets.find(sh => (sh as Record<string, any>)._ui5StyleId === getStyleId(name, value));\n\t}\n\n\treturn !!document.querySelector(`head>style[${name}=\"${value}\"]`);\n};\n\nconst removeStyle = (name: string, value = \"\") => {\n\tif (shouldUseLinks()) {\n\t\tconst linkElement = document.querySelector(`head>link[${name}=\"${value}\"]`);\n\t\tlinkElement?.parentElement?.removeChild(linkElement);\n\t} else if (document.adoptedStyleSheets) {\n\t\tdocument.adoptedStyleSheets = document.adoptedStyleSheets.filter(sh => (sh as Record<string, any>)._ui5StyleId !== getStyleId(name, value));\n\t} else {\n\t\tconst styleElement = document.querySelector(`head > style[${name}=\"${value}\"]`);\n\t\tstyleElement?.parentElement?.removeChild(styleElement);\n\t}\n};\n\nconst createOrUpdateStyle = (data: StyleData, name: string, value = \"\") => {\n\tif (hasStyle(name, value)) {\n\t\tupdateStyle(data, name, value);\n\t} else {\n\t\tcreateStyle(data, name, value);\n\t}\n};\n\nexport {\n\tcreateStyle,\n\thasStyle,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AI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;KACtC;SAAM;QACN,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;KACtC;AACF,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,MAAkB,EAAE,MAAkB,EAAE,EAAE;IAC9D,IAAI,MAAM,KAAK,SAAS,EAAE;QACzB,OAAO,MAAM,CAAC;KACd;IACD,IAAI,MAAM,KAAK,SAAS,EAAE;QACzB,OAAO,MAAM,CAAC;KACd;IACD,MAAM,aAAa,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;IAC3E,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC/B,OAAO,GAAG,MAAM,IAAI,aAAa,EAAE,CAAC;KACpC;IACD,OAAO;QACN,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,IAAI,aAAa,EAAE;QAC7C,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ;KACzB,CAAC;AACH,CAAC,CAAC;AAEF,OAAO,EACN,WAAW,EACX,QAAQ,EACR,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,WAAW,GACX,CAAC","sourcesContent":["import createStyleInHead from \"./util/createStyleInHead.js\";\nimport createLinkInHead from \"./util/createLinkInHead.js\";\nimport { shouldUseLinks, getUrl } from \"./CSP.js\";\nimport { StyleData, StyleDataCSP } from \"./types.js\";\nimport { isSafari } from \"./Device.js\";\nimport { getCurrentRuntimeIndex, compareRuntimes } from \"./Runtimes.js\";\n\nconst getStyleId = (name: string, value: string) => {\n\treturn value ? `${name}|${value}` : name;\n};\n\nconst shouldUpdate = (runtimeIndex: string | undefined) => {\n\tif (runtimeIndex === undefined) {\n\t\treturn true;\n\t}\n\treturn compareRuntimes(getCurrentRuntimeIndex(), parseInt(runtimeIndex)) === 1; // 1 means the current is newer, 0 means the same, -1 means the resource's runtime is newer\n};\n\nconst createStyle = (data: StyleData, name: string, value = \"\", theme?: string) => {\n\tconst content = typeof data === \"string\" ? data : data.content;\n\tconst currentRuntimeIndex = getCurrentRuntimeIndex();\n\n\tif (shouldUseLinks()) {\n\t\tconst attributes = {} as Record<string, any>;\n\t\tattributes[name] = value;\n\t\tif (theme) {\n\t\t\tattributes[\"data-ui5-runtime-index\"] = currentRuntimeIndex;\n\t\t\tattributes[\"data-ui5-theme\"] = theme;\n\t\t}\n\t\tconst href = getUrl((data as StyleDataCSP).packageName, (data as StyleDataCSP).fileName);\n\t\tcreateLinkInHead(href, attributes);\n\t} else if (document.adoptedStyleSheets && !isSafari()) {\n\t\tconst stylesheet = new CSSStyleSheet();\n\t\tstylesheet.replaceSync(content);\n\t\t(stylesheet as Record<string, any>)._ui5StyleId = getStyleId(name, value); // set an id so that we can find the style later\n\t\tif (theme) {\n\t\t\t(stylesheet as Record<string, any>)._ui5RuntimeIndex = currentRuntimeIndex;\n\t\t\t(stylesheet as Record<string, any>)._ui5Theme = theme;\n\t\t}\n\t\tdocument.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];\n\t} else {\n\t\tconst attributes = {} as Record<string, any>;\n\t\tattributes[name] = value;\n\t\tif (theme) {\n\t\t\tattributes[\"data-ui5-runtime-index\"] = currentRuntimeIndex;\n\t\t\tattributes[\"data-ui5-theme\"] = theme;\n\t\t}\n\t\tcreateStyleInHead(content, attributes);\n\t}\n};\n\nconst updateStyle = (data: StyleData, name: string, value = \"\", theme?: string) => {\n\tconst content = typeof data === \"string\" ? data : data.content;\n\tconst currentRuntimeIndex = getCurrentRuntimeIndex();\n\n\tif (shouldUseLinks()) {\n\t\tconst link = document.querySelector(`head>link[${name}=\"${value}\"]`) as HTMLLinkElement;\n\t\tconst href = getUrl((data as StyleDataCSP).packageName, (data as StyleDataCSP).fileName);\n\n\t\tif (!theme) {\n\t\t\tlink.href = href;\n\t\t} else {\n\t\t\tconst linkRuntimeIndex = link.getAttribute(\"data-ui5-runtime-index\") || undefined;\n\t\t\tconst linkTheme = link.getAttribute(\"data-ui5-theme\");\n\t\t\tif (linkTheme !== theme || shouldUpdate(linkRuntimeIndex)) {\n\t\t\t\tlink.href = href;\n\t\t\t\tlink.setAttribute(\"data-ui5-runtime-index\", String(currentRuntimeIndex));\n\t\t\t\tlink.setAttribute(\"data-ui5-theme\", theme);\n\t\t\t}\n\t\t}\n\t} else if (document.adoptedStyleSheets && !isSafari()) {\n\t\tconst stylesheet = document.adoptedStyleSheets.find(sh => (sh as Record<string, any>)._ui5StyleId === getStyleId(name, value));\n\t\tif (!stylesheet) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!theme) {\n\t\t\tstylesheet.replaceSync(content || \"\");\n\t\t} else {\n\t\t\tconst stylesheetRuntimeIndex: string | undefined = (stylesheet as Record<string, any>)._ui5RuntimeIndex;\n\t\t\tconst stylesheetTheme: string | undefined = (stylesheet as Record<string, any>)._ui5Theme;\n\t\t\tif (stylesheetTheme !== theme || shouldUpdate(stylesheetRuntimeIndex)) {\n\t\t\t\tstylesheet.replaceSync(content || \"\");\n\t\t\t\t(stylesheet as Record<string, any>)._ui5RuntimeIndex = String(currentRuntimeIndex);\n\t\t\t\t(stylesheet as Record<string, any>)._ui5Theme = theme;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tconst style = document.querySelector(`head>style[${name}=\"${value}\"]`);\n\t\tif (!style) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (!theme) {\n\t\t\tstyle.textContent = content || \"\";\n\t\t} else {\n\t\t\tconst styleRuntimeIndex = style.getAttribute(\"data-ui5-runtime-index\") || undefined;\n\t\t\tconst styleTheme = style.getAttribute(\"data-ui5-theme\");\n\t\t\tif (styleTheme !== theme || shouldUpdate(styleRuntimeIndex)) {\n\t\t\t\tstyle.textContent = content || \"\";\n\t\t\t\tstyle.setAttribute(\"data-ui5-runtime-index\", String(currentRuntimeIndex));\n\t\t\t\tstyle.setAttribute(\"data-ui5-theme\", theme);\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst hasStyle = (name: string, value = \"\"): boolean => {\n\tif (shouldUseLinks()) {\n\t\treturn !!document.querySelector(`head>link[${name}=\"${value}\"]`);\n\t}\n\n\tconst styleElement = document.querySelector(`head>style[${name}=\"${value}\"]`);\n\n\tif (document.adoptedStyleSheets && !isSafari()) {\n\t\treturn !!styleElement || !!document.adoptedStyleSheets.find(sh => (sh as Record<string, any>)._ui5StyleId === getStyleId(name, value));\n\t}\n\n\treturn !!styleElement;\n};\n\nconst removeStyle = (name: string, value = \"\") => {\n\tif (shouldUseLinks()) {\n\t\tconst linkElement = document.querySelector(`head>link[${name}=\"${value}\"]`);\n\t\tlinkElement?.parentElement?.removeChild(linkElement);\n\t} else if (document.adoptedStyleSheets && !isSafari()) {\n\t\tdocument.adoptedStyleSheets = document.adoptedStyleSheets.filter(sh => (sh as Record<string, any>)._ui5StyleId !== getStyleId(name, value));\n\t} else {\n\t\tconst styleElement = document.querySelector(`head > style[${name}=\"${value}\"]`);\n\t\tstyleElement?.parentElement?.removeChild(styleElement);\n\t}\n};\n\nconst createOrUpdateStyle = (data: StyleData, name: string, value = \"\", theme?: string) => {\n\tif (hasStyle(name, value)) {\n\t\tupdateStyle(data, name, value, theme);\n\t} else {\n\t\tcreateStyle(data, name, value, theme);\n\t}\n};\n\nconst mergeStyles = (style1?: StyleData, style2?: StyleData) => {\n\tif (style1 === undefined) {\n\t\treturn style2;\n\t}\n\tif (style2 === undefined) {\n\t\treturn style1;\n\t}\n\tconst style2Content = typeof style2 === \"string\" ? style2 : style2.content;\n\tif (typeof style1 === \"string\") {\n\t\treturn `${style1} ${style2Content}`;\n\t}\n\treturn {\n\t\tcontent: `${style1.content} ${style2Content}`,\n\t\tpackageName: style1.packageName,\n\t\tfileName: style1.fileName,\n\t};\n};\n\nexport {\n\tcreateStyle,\n\thasStyle,\n\tupdateStyle,\n\tremoveStyle,\n\tcreateOrUpdateStyle,\n\tmergeStyles,\n};\n\nexport type {\n\tStyleData,\n\tStyleDataCSP,\n};\n"]}
@@ -18,6 +18,7 @@ declare class StaticAreaItem extends HTMLElement {
18
18
  * Updates the shadow root of the static area item with the latest state, if rendered
19
19
  */
20
20
  update(): void;
21
+ updateAdditionalProperties(): void;
21
22
  /**
22
23
  * Sets the correct content density based on the owner element's state
23
24
  * @private
@@ -4,7 +4,6 @@ import { renderFinished } from "./Render.js";
4
4
  import getEffectiveContentDensity from "./util/getEffectiveContentDensity.js";
5
5
  import { getEffectiveScopingSuffixForTag } from "./CustomElementsScopeUtils.js";
6
6
  import getEffectiveDir from "./locale/getEffectiveDir.js";
7
- import { getCurrentRuntimeIndex } from "./Runtimes.js";
8
7
  const pureTagName = "ui5-static-area-item";
9
8
  const popupIntegrationAttr = "data-sap-ui-integration-popup-content";
10
9
  /**
@@ -34,12 +33,15 @@ class StaticAreaItem extends HTMLElement {
34
33
  */
35
34
  update() {
36
35
  if (this._rendered) {
37
- this._updateAdditionalAttrs();
38
- this._updateContentDensity();
39
- this._updateDirection();
36
+ this.updateAdditionalProperties();
40
37
  updateShadowRoot(this.ownerElement, true);
41
38
  }
42
39
  }
40
+ updateAdditionalProperties() {
41
+ this._updateAdditionalAttrs();
42
+ this._updateContentDensity();
43
+ this._updateDirection();
44
+ }
43
45
  /**
44
46
  * Sets the correct content density based on the owner element's state
45
47
  * @private
@@ -66,8 +68,6 @@ class StaticAreaItem extends HTMLElement {
66
68
  }
67
69
  }
68
70
  _updateAdditionalAttrs() {
69
- this.setAttribute(`_ui5rt${getCurrentRuntimeIndex()}`, "");
70
- this.setAttribute("_ui5host", "");
71
71
  this.setAttribute(pureTagName, "");
72
72
  this.setAttribute(popupIntegrationAttr, "");
73
73
  }
@@ -76,7 +76,7 @@ class StaticAreaItem extends HTMLElement {
76
76
  * Returns reference to the DOM element where the current fragment is added.
77
77
  */
78
78
  async getDomRef() {
79
- this._updateContentDensity();
79
+ this.updateAdditionalProperties();
80
80
  if (!this._rendered) {
81
81
  this._rendered = true;
82
82
  updateShadowRoot(this.ownerElement, true);
@@ -1 +1 @@
1
- {"version":3,"file":"StaticAreaItem.js","sourceRoot":"","sources":["../src/StaticAreaItem.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;AACzB,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,0BAA0B,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,eAAe,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEvD,MAAM,WAAW,GAAG,sBAAsB,CAAC;AAC3C,MAAM,oBAAoB,GAAG,uCAAuC,CAAC;AAErE;;;;;GAKG;AACH,MAAM,cAAe,SAAQ,WAAW;IAIvC;QACC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,eAAe,CAAC,YAAwB;QACvC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,4CAA4C;QACvF,IAAI,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,wBAAwB,CAAC,EAAE;YAC7D,IAAI,CAAC,YAAY,CAAC,iBAAiB,EAAE,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,wBAAwB,CAAE,CAAC,CAAC,CAAC,kBAAkB;SACnH;IACF,CAAC;IAED;;OAEG;IACH,MAAM;QACL,IAAI,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAC9B,IAA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C,SAAS,GAAG,IAAI,CAAC;YACtB,gBAAgB,CAAC,IAAI,CAAC,YAAa,EAAE,IAAI,CAAC,CAAC;SAC3C;QACD,MAAM,cAAc,EAAE,CAAC,CAAC,kEAAkE;QAC1F,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,MAAM;QACZ,MAAM,MAAM,GAAG,+BAA+B,CAAC,WAAW,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,EAAE;YACZ,OAAO,WAAW,CAAC;SACnB;QAED,OAAO,GAAG,WAAW,IAAI,MAAM,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,cAAc;QACpB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE;YACjD,cAAc,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,cAAc,CAAC,CAAC;SAC/D;QAED,OAAO,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,CAAmB,CAAC;IAChE,CAAC;CACD;AAED,eAAe,cAAc,CAAC","sourcesContent":["import \"./StaticArea.js\";\nimport updateShadowRoot from \"./updateShadowRoot.js\";\nimport { renderFinished } from \"./Render.js\";\nimport getEffectiveContentDensity from \"./util/getEffectiveContentDensity.js\";\nimport { getEffectiveScopingSuffixForTag } from \"./CustomElementsScopeUtils.js\";\nimport getEffectiveDir from \"./locale/getEffectiveDir.js\";\nimport type UI5Element from \"./UI5Element.js\";\nimport { getCurrentRuntimeIndex } from \"./Runtimes.js\";\n\nconst pureTagName = \"ui5-static-area-item\";\nconst popupIntegrationAttr = \"data-sap-ui-integration-popup-content\";\n\n/**\n *\n * @class\n * @author SAP SE\n * @private\n */\nclass StaticAreaItem extends HTMLElement {\n\t_rendered: boolean;\n\townerElement?: UI5Element;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis._rendered = false;\n\t\tthis.attachShadow({ mode: \"open\" });\n\t}\n\n\t/**\n\t * @param {UI5Element} ownerElement the UI5Element instance that owns this static area item\n\t */\n\tsetOwnerElement(ownerElement: UI5Element) {\n\t\tthis.ownerElement = ownerElement;\n\t\tthis.classList.add(this.ownerElement._id); // used for getting the popover in the tests\n\t\tif (this.ownerElement.hasAttribute(\"data-ui5-static-stable\")) {\n\t\t\tthis.setAttribute(\"data-ui5-stable\", this.ownerElement.getAttribute(\"data-ui5-static-stable\")!); // stable selector\n\t\t}\n\t}\n\n\t/**\n\t * Updates the shadow root of the static area item with the latest state, if rendered\n\t */\n\tupdate() {\n\t\tif (this._rendered) {\n\t\t\tthis._updateAdditionalAttrs();\n\t\t\tthis._updateContentDensity();\n\t\t\tthis._updateDirection();\n\t\t\tupdateShadowRoot(this.ownerElement!, true);\n\t\t}\n\t}\n\n\t/**\n\t * Sets the correct content density based on the owner element's state\n\t * @private\n\t */\n\t_updateContentDensity() {\n\t\tif (getEffectiveContentDensity(this.ownerElement!) === \"compact\") {\n\t\t\tthis.classList.add(\"sapUiSizeCompact\");\n\t\t\tthis.classList.add(\"ui5-content-density-compact\");\n\t\t} else {\n\t\t\tthis.classList.remove(\"sapUiSizeCompact\");\n\t\t\tthis.classList.remove(\"ui5-content-density-compact\");\n\t\t}\n\t}\n\n\t_updateDirection() {\n\t\tif (this.ownerElement) {\n\t\t\tconst dir = getEffectiveDir(this.ownerElement);\n\t\t\tif (dir) {\n\t\t\t\tthis.setAttribute(\"dir\", dir);\n\t\t\t} else {\n\t\t\t\tthis.removeAttribute(\"dir\");\n\t\t\t}\n\t\t}\n\t}\n\n\t_updateAdditionalAttrs() {\n\t\tthis.setAttribute(`_ui5rt${getCurrentRuntimeIndex()}`, \"\");\n\t\tthis.setAttribute(\"_ui5host\", \"\");\n\t\tthis.setAttribute(pureTagName, \"\");\n\t\tthis.setAttribute(popupIntegrationAttr, \"\");\n\t}\n\n\t/**\n\t * @protected\n\t * Returns reference to the DOM element where the current fragment is added.\n\t */\n\tasync getDomRef() {\n\t\tthis._updateContentDensity();\n\t\tif (!this._rendered) {\n\t\t\tthis._rendered = true;\n\t\t\tupdateShadowRoot(this.ownerElement!, true);\n\t\t}\n\t\tawait renderFinished(); // Wait for the content of the ui5-static-area-item to be rendered\n\t\treturn this.shadowRoot;\n\t}\n\n\tstatic getTag() {\n\t\tconst suffix = getEffectiveScopingSuffixForTag(pureTagName);\n\t\tif (!suffix) {\n\t\t\treturn pureTagName;\n\t\t}\n\n\t\treturn `${pureTagName}-${suffix}`;\n\t}\n\n\tstatic createInstance() {\n\t\tif (!customElements.get(StaticAreaItem.getTag())) {\n\t\t\tcustomElements.define(StaticAreaItem.getTag(), StaticAreaItem);\n\t\t}\n\n\t\treturn document.createElement(this.getTag()) as StaticAreaItem;\n\t}\n}\n\nexport default StaticAreaItem;\n"]}
1
+ {"version":3,"file":"StaticAreaItem.js","sourceRoot":"","sources":["../src/StaticAreaItem.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;AACzB,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,0BAA0B,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,eAAe,MAAM,6BAA6B,CAAC;AAG1D,MAAM,WAAW,GAAG,sBAAsB,CAAC;AAC3C,MAAM,oBAAoB,GAAG,uCAAuC,CAAC;AAErE;;;;;GAKG;AACH,MAAM,cAAe,SAAQ,WAAW;IAIvC;QACC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,eAAe,CAAC,YAAwB;QACvC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,C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AAsB;QACrB,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,YAAY,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,SAAS;QACd,IAAI,CAAC,0BAA0B,EAAE,CAAC;QAClC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACpB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,gBAAgB,CAAC,IAAI,CAAC,YAAa,EAAE,IAAI,CAAC,CAAC;SAC3C;QACD,MAAM,cAAc,EAAE,CAAC,CAAC,kEAAkE;QAC1F,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,MAAM;QACZ,MAAM,MAAM,GAAG,+BAA+B,CAAC,WAAW,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,EAAE;YACZ,OAAO,WAAW,CAAC;SACnB;QAED,OAAO,GAAG,WAAW,IAAI,MAAM,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,cAAc;QACpB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE;YACjD,cAAc,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,cAAc,CAAC,CAAC;SAC/D;QAED,OAAO,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,CAAmB,CAAC;IAChE,CAAC;CACD;AAED,eAAe,cAAc,CAAC","sourcesContent":["import \"./StaticArea.js\";\nimport updateShadowRoot from \"./updateShadowRoot.js\";\nimport { renderFinished } from \"./Render.js\";\nimport getEffectiveContentDensity from \"./util/getEffectiveContentDensity.js\";\nimport { getEffectiveScopingSuffixForTag } from \"./CustomElementsScopeUtils.js\";\nimport getEffectiveDir from \"./locale/getEffectiveDir.js\";\nimport type UI5Element from \"./UI5Element.js\";\n\nconst pureTagName = \"ui5-static-area-item\";\nconst popupIntegrationAttr = \"data-sap-ui-integration-popup-content\";\n\n/**\n *\n * @class\n * @author SAP SE\n * @private\n */\nclass StaticAreaItem extends HTMLElement {\n\t_rendered: boolean;\n\townerElement?: UI5Element;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis._rendered = false;\n\t\tthis.attachShadow({ mode: \"open\" });\n\t}\n\n\t/**\n\t * @param {UI5Element} ownerElement the UI5Element instance that owns this static area item\n\t */\n\tsetOwnerElement(ownerElement: UI5Element) {\n\t\tthis.ownerElement = ownerElement;\n\t\tthis.classList.add(this.ownerElement._id); // used for getting the popover in the tests\n\t\tif (this.ownerElement.hasAttribute(\"data-ui5-static-stable\")) {\n\t\t\tthis.setAttribute(\"data-ui5-stable\", this.ownerElement.getAttribute(\"data-ui5-static-stable\")!); // stable selector\n\t\t}\n\t}\n\n\t/**\n\t * Updates the shadow root of the static area item with the latest state, if rendered\n\t */\n\tupdate() {\n\t\tif (this._rendered) {\n\t\t\tthis.updateAdditionalProperties();\n\t\t\tupdateShadowRoot(this.ownerElement!, true);\n\t\t}\n\t}\n\n\tupdateAdditionalProperties() {\n\t\tthis._updateAdditionalAttrs();\n\t\tthis._updateContentDensity();\n\t\tthis._updateDirection();\n\t}\n\n\t/**\n\t * Sets the correct content density based on the owner element's state\n\t * @private\n\t */\n\t_updateContentDensity() {\n\t\tif (getEffectiveContentDensity(this.ownerElement!) === \"compact\") {\n\t\t\tthis.classList.add(\"sapUiSizeCompact\");\n\t\t\tthis.classList.add(\"ui5-content-density-compact\");\n\t\t} else {\n\t\t\tthis.classList.remove(\"sapUiSizeCompact\");\n\t\t\tthis.classList.remove(\"ui5-content-density-compact\");\n\t\t}\n\t}\n\n\t_updateDirection() {\n\t\tif (this.ownerElement) {\n\t\t\tconst dir = getEffectiveDir(this.ownerElement);\n\t\t\tif (dir) {\n\t\t\t\tthis.setAttribute(\"dir\", dir);\n\t\t\t} else {\n\t\t\t\tthis.removeAttribute(\"dir\");\n\t\t\t}\n\t\t}\n\t}\n\n\t_updateAdditionalAttrs() {\n\t\tthis.setAttribute(pureTagName, \"\");\n\t\tthis.setAttribute(popupIntegrationAttr, \"\");\n\t}\n\n\t/**\n\t * @protected\n\t * Returns reference to the DOM element where the current fragment is added.\n\t */\n\tasync getDomRef() {\n\t\tthis.updateAdditionalProperties();\n\t\tif (!this._rendered) {\n\t\t\tthis._rendered = true;\n\t\t\tupdateShadowRoot(this.ownerElement!, true);\n\t\t}\n\t\tawait renderFinished(); // Wait for the content of the ui5-static-area-item to be rendered\n\t\treturn this.shadowRoot;\n\t}\n\n\tstatic getTag() {\n\t\tconst suffix = getEffectiveScopingSuffixForTag(pureTagName);\n\t\tif (!suffix) {\n\t\t\treturn pureTagName;\n\t\t}\n\n\t\treturn `${pureTagName}-${suffix}`;\n\t}\n\n\tstatic createInstance() {\n\t\tif (!customElements.get(StaticAreaItem.getTag())) {\n\t\t\tcustomElements.define(StaticAreaItem.getTag(), StaticAreaItem);\n\t\t}\n\n\t\treturn document.createElement(this.getTag()) as StaticAreaItem;\n\t}\n}\n\nexport default StaticAreaItem;\n"]}
@@ -39,7 +39,8 @@ declare abstract class UI5Element extends HTMLElement {
39
39
  __id?: string;
40
40
  _suppressInvalidation: boolean;
41
41
  _changedState: Array<ChangeInfo>;
42
- _eventProvider: EventProvider<InvalidationInfo, void>;
42
+ _invalidationEventProvider: EventProvider<InvalidationInfo, void>;
43
+ _componentStateFinalizedEventProvider: EventProvider<void, void>;
43
44
  _inDOM: boolean;
44
45
  _fullyConnected: boolean;
45
46
  _childChangeListeners: Map<string, ChildChangeListener>;
@@ -49,7 +50,6 @@ declare abstract class UI5Element extends HTMLElement {
49
50
  };
50
51
  _doNotSyncAttributes: Set<string>;
51
52
  _state: State;
52
- _onComponentStateFinalized?: () => void;
53
53
  _getRealDomRef?: () => HTMLElement;
54
54
  staticAreaItem?: StaticAreaItem;
55
55
  static template?: TemplateFunction;
@@ -278,6 +278,20 @@ declare abstract class UI5Element extends HTMLElement {
278
278
  * @public
279
279
  */
280
280
  getSlottedNodes<T = Node>(slotName: string): T[];
281
+ /**
282
+ * Attach a callback that will be executed whenever the component's state is finalized
283
+ *
284
+ * @param {} callback
285
+ * @public
286
+ */
287
+ attachComponentStateFinalized(callback: () => void): void;
288
+ /**
289
+ * Detach the callback that is executed whenever the component's state is finalized
290
+ *
291
+ * @param {} callback
292
+ * @public
293
+ */
294
+ detachComponentStateFinalized(callback: () => void): void;
281
295
  /**
282
296
  * Determines whether the component should be rendered in RTL mode or not.
283
297
  * Returns: "rtl", "ltr" or undefined
@@ -18,7 +18,6 @@ import arraysAreEqual from "./util/arraysAreEqual.js";
18
18
  import { markAsRtlAware } from "./locale/RTLAwareRegistry.js";
19
19
  import preloadLinks from "./theming/preloadLinks.js";
20
20
  import executeTemplate from "./renderer/executeTemplate.js";
21
- import { getCurrentRuntimeIndex } from "./Runtimes.js";
22
21
  let autoId = 0;
23
22
  const elementTimeouts = new Map();
24
23
  const uniqueDependenciesCache = new Map();
@@ -37,7 +36,7 @@ function _invalidate(changeInfo) {
37
36
  this.onInvalidation(changeInfo);
38
37
  this._changedState.push(changeInfo);
39
38
  renderDeferred(this);
40
- this._eventProvider.fireEvent("invalidate", { ...changeInfo, target: this });
39
+ this._invalidationEventProvider.fireEvent("invalidate", { ...changeInfo, target: this });
41
40
  }
42
41
  /**
43
42
  * Base class for all UI5 Web Components
@@ -59,7 +58,8 @@ class UI5Element extends HTMLElement {
59
58
  this._fullyConnected = false; // A flag telling whether the UI5Element's onEnterDOM hook was called (since it's possible to have the element removed from DOM before that)
60
59
  this._childChangeListeners = new Map(); // used to store lazy listeners per slot for the child change event of every child inside that slot
61
60
  this._slotChangeListeners = new Map(); // used to store lazy listeners per slot for the slotchange event of all slot children inside that slot
62
- this._eventProvider = new EventProvider(); // used by parent components for listening to changes to child components
61
+ this._invalidationEventProvider = new EventProvider(); // used by parent components for listening to changes to child components
62
+ this._componentStateFinalizedEventProvider = new EventProvider(); // used by friend classes for synchronization
63
63
  let deferredResolve;
64
64
  this._domRefReadyPromise = new Promise(resolve => {
65
65
  deferredResolve = resolve;
@@ -98,8 +98,6 @@ class UI5Element extends HTMLElement {
98
98
  */
99
99
  async connectedCallback() {
100
100
  const ctor = this.constructor;
101
- this.setAttribute(`_ui5rt${getCurrentRuntimeIndex()}`, "");
102
- this.setAttribute("_ui5host", "");
103
101
  this.setAttribute(ctor.getMetadata().getPureTag(), "");
104
102
  if (ctor.getMetadata().supportsF6FastNavigation()) {
105
103
  this.setAttribute("data-sap-ui-fastnavgroup", "true");
@@ -164,14 +162,16 @@ class UI5Element extends HTMLElement {
164
162
  */
165
163
  _startObservingDOMChildren() {
166
164
  const ctor = this.constructor;
167
- const shouldObserveChildren = ctor.getMetadata().hasSlots();
165
+ const metadata = ctor.getMetadata();
166
+ const shouldObserveChildren = metadata.hasSlots();
168
167
  if (!shouldObserveChildren) {
169
168
  return;
170
169
  }
171
- const canSlotText = ctor.getMetadata().canSlotText();
170
+ const canSlotText = metadata.canSlotText();
171
+ const hasClonedSlot = Object.keys(metadata.getSlots()).some(slotName => metadata.getSlots()[slotName].cloned);
172
172
  const mutationObserverOptions = {
173
173
  childList: true,
174
- subtree: canSlotText,
174
+ subtree: canSlotText || hasClonedSlot,
175
175
  characterData: canSlotText,
176
176
  };
177
177
  observeDOMNode(this, this._processChildren.bind(this), mutationObserverOptions);
@@ -323,7 +323,7 @@ class UI5Element extends HTMLElement {
323
323
  * @public
324
324
  */
325
325
  attachInvalidate(callback) {
326
- this._eventProvider.attachEvent("invalidate", callback);
326
+ this._invalidationEventProvider.attachEvent("invalidate", callback);
327
327
  }
328
328
  /**
329
329
  * Detach the callback that is executed whenever the component is invalidated
@@ -332,7 +332,7 @@ class UI5Element extends HTMLElement {
332
332
  * @public
333
333
  */
334
334
  detachInvalidate(callback) {
335
- this._eventProvider.detachEvent("invalidate", callback);
335
+ this._invalidationEventProvider.detachEvent("invalidate", callback);
336
336
  }
337
337
  /**
338
338
  * Callback that is executed whenever a monitored child changes its state
@@ -537,9 +537,7 @@ class UI5Element extends HTMLElement {
537
537
  this._suppressInvalidation = true;
538
538
  this.onBeforeRendering();
539
539
  // Intended for framework usage only. Currently ItemNavigation updates tab indexes after the component has updated its state but before the template is rendered
540
- if (this._onComponentStateFinalized) {
541
- this._onComponentStateFinalized();
542
- }
540
+ this._componentStateFinalizedEventProvider.fireEvent("componentStateFinalized");
543
541
  // resume normal invalidation handling
544
542
  this._suppressInvalidation = false;
545
543
  // Update the shadow root with the render result
@@ -662,7 +660,7 @@ class UI5Element extends HTMLElement {
662
660
  const eventResult = this._fireEvent(name, data, cancelable, bubbles);
663
661
  const camelCaseEventName = kebabToCamelCase(name);
664
662
  if (camelCaseEventName !== name) {
665
- return eventResult && this._fireEvent(camelCaseEventName, data, cancelable);
663
+ return eventResult && this._fireEvent(camelCaseEventName, data, cancelable, bubbles);
666
664
  }
667
665
  return eventResult;
668
666
  }
@@ -697,6 +695,24 @@ class UI5Element extends HTMLElement {
697
695
  getSlottedNodes(slotName) {
698
696
  return getSlottedNodesList(this[slotName]);
699
697
  }
698
+ /**
699
+ * Attach a callback that will be executed whenever the component's state is finalized
700
+ *
701
+ * @param {} callback
702
+ * @public
703
+ */
704
+ attachComponentStateFinalized(callback) {
705
+ this._componentStateFinalizedEventProvider.attachEvent("componentStateFinalized", callback);
706
+ }
707
+ /**
708
+ * Detach the callback that is executed whenever the component's state is finalized
709
+ *
710
+ * @param {} callback
711
+ * @public
712
+ */
713
+ detachComponentStateFinalized(callback) {
714
+ this._componentStateFinalizedEventProvider.detachEvent("componentStateFinalized", callback);
715
+ }
700
716
  /**
701
717
  * Determines whether the component should be rendered in RTL mode or not.
702
718
  * Returns: "rtl", "ltr" or undefined
@@ -918,7 +934,7 @@ class UI5Element extends HTMLElement {
918
934
  ]);
919
935
  const tag = this.getMetadata().getTag();
920
936
  const definedLocally = isTagRegistered(tag);
921
- const definedGlobally = customElements.get(tag);
937
+ const definedGlobally = window.customElements.get(tag);
922
938
  if (definedGlobally && !definedLocally) {
923
939
  recordTagRegistrationFailure(tag);
924
940
  }