@ui5/webcomponents-base 0.0.0-7c7170d4a → 0.0.0-7d8c57f70

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 (120) hide show
  1. package/.eslintignore +18 -0
  2. package/.eslintrc.cjs +3 -0
  3. package/CHANGELOG.md +22 -411
  4. package/README.md +8 -0
  5. package/bundle.esm.js +66 -0
  6. package/config/wdio.conf.cjs +8 -0
  7. package/dist/.tsbuildinfo +1 -1
  8. package/dist/Boot.js +4 -3
  9. package/dist/Boot.js.map +1 -1
  10. package/dist/CSP.d.ts +33 -0
  11. package/dist/CSP.js +54 -0
  12. package/dist/CSP.js.map +1 -0
  13. package/dist/Device.d.ts +2 -1
  14. package/dist/Device.js +12 -5
  15. package/dist/Device.js.map +1 -1
  16. package/dist/FeaturesRegistry.d.ts +10 -1
  17. package/dist/FeaturesRegistry.js +37 -1
  18. package/dist/FeaturesRegistry.js.map +1 -1
  19. package/dist/Keys.d.ts +1 -3
  20. package/dist/Keys.js +1 -5
  21. package/dist/Keys.js.map +1 -1
  22. package/dist/ManagedStyles.js +99 -21
  23. package/dist/ManagedStyles.js.map +1 -1
  24. package/dist/StaticAreaItem.d.ts +35 -0
  25. package/dist/StaticAreaItem.js +100 -0
  26. package/dist/StaticAreaItem.js.map +1 -0
  27. package/dist/UI5Element.d.ts +27 -12
  28. package/dist/UI5Element.js +64 -54
  29. package/dist/UI5Element.js.map +1 -1
  30. package/dist/UI5ElementMetadata.d.ts +6 -7
  31. package/dist/UI5ElementMetadata.js +7 -9
  32. package/dist/UI5ElementMetadata.js.map +1 -1
  33. package/dist/asset-registries/Icons.js +1 -1
  34. package/dist/asset-registries/Icons.js.map +1 -1
  35. package/dist/asset-registries/util/getIconCollectionByTheme.d.ts +3 -3
  36. package/dist/asset-registries/util/getIconCollectionByTheme.js +3 -3
  37. package/dist/asset-registries/util/getIconCollectionByTheme.js.map +1 -1
  38. package/dist/config/AnimationMode.js +1 -2
  39. package/dist/config/AnimationMode.js.map +1 -1
  40. package/dist/config/Theme.d.ts +2 -3
  41. package/dist/config/Theme.js +3 -7
  42. package/dist/config/Theme.js.map +1 -1
  43. package/dist/custom-elements-internal.json +2863 -0
  44. package/dist/custom-elements.json +2593 -0
  45. package/dist/decorators/customElement.d.ts +3 -2
  46. package/dist/decorators/customElement.js +5 -8
  47. package/dist/decorators/customElement.js.map +1 -1
  48. package/dist/features/OpenUI5Support.d.ts +2 -0
  49. package/dist/features/OpenUI5Support.js +25 -5
  50. package/dist/features/OpenUI5Support.js.map +1 -1
  51. package/dist/features/patchPopup.d.ts +3 -7
  52. package/dist/features/patchPopup.js +8 -43
  53. package/dist/features/patchPopup.js.map +1 -1
  54. package/dist/generated/AssetParameters.js +1 -1
  55. package/dist/generated/AssetParameters.js.map +1 -1
  56. package/dist/generated/VersionInfo.js +6 -6
  57. package/dist/generated/VersionInfo.js.map +1 -1
  58. package/dist/renderer/LitRenderer.js +8 -2
  59. package/dist/renderer/LitRenderer.js.map +1 -1
  60. package/dist/renderer/executeTemplate.d.ts +0 -8
  61. package/dist/renderer/executeTemplate.js +0 -1
  62. package/dist/renderer/executeTemplate.js.map +1 -1
  63. package/dist/sap/ui/thirdparty/caja-html-sanitizer.js +1 -1
  64. package/dist/ssr-dom.js +3 -0
  65. package/dist/ssr-dom.js.map +1 -0
  66. package/dist/theming/getConstructableStyle.d.ts +1 -1
  67. package/dist/theming/getConstructableStyle.js +3 -3
  68. package/dist/theming/getConstructableStyle.js.map +1 -1
  69. package/dist/theming/getEffectiveLinksHrefs.d.ts +3 -0
  70. package/dist/theming/getEffectiveLinksHrefs.js +17 -0
  71. package/dist/theming/getEffectiveLinksHrefs.js.map +1 -0
  72. package/dist/theming/getEffectiveStyle.d.ts +1 -1
  73. package/dist/theming/getEffectiveStyle.js +12 -5
  74. package/dist/theming/getEffectiveStyle.js.map +1 -1
  75. package/dist/theming/preloadLinks.d.ts +3 -0
  76. package/dist/theming/preloadLinks.js +19 -0
  77. package/dist/theming/preloadLinks.js.map +1 -0
  78. package/dist/types/ValueState.d.ts +3 -3
  79. package/dist/types/ValueState.js +3 -3
  80. package/dist/types/ValueState.js.map +1 -1
  81. package/dist/types.d.ts +2 -15
  82. package/dist/types.js.map +1 -1
  83. package/dist/updateShadowRoot.d.ts +2 -1
  84. package/dist/updateShadowRoot.js +29 -5
  85. package/dist/updateShadowRoot.js.map +1 -1
  86. package/dist/util/PopupUtils.d.ts +3 -1
  87. package/dist/util/PopupUtils.js +15 -1
  88. package/dist/util/PopupUtils.js.map +1 -1
  89. package/dist/util/createStyleInHead.d.ts +8 -0
  90. package/dist/util/createStyleInHead.js +18 -0
  91. package/dist/util/createStyleInHead.js.map +1 -0
  92. package/dist/util/dragAndDrop/DragRegistry.d.ts +1 -1
  93. package/dist/util/dragAndDrop/DragRegistry.js +0 -2
  94. package/dist/util/dragAndDrop/DragRegistry.js.map +1 -1
  95. package/dist/util/getClassCopy.d.ts +9 -8
  96. package/dist/vscode.html-custom-data.json +22 -0
  97. package/index.js +14 -0
  98. package/lib/generate-asset-parameters/index.js +27 -0
  99. package/lib/generate-styles/index.js +31 -0
  100. package/lib/generate-version-info/index.js +32 -0
  101. package/package-scripts.cjs +2 -9
  102. package/package.json +6 -13
  103. package/tsconfig.json +2 -2
  104. package/used-modules.txt +14 -0
  105. package/dist/features/InputElementsFormSupport.d.ts +0 -18
  106. package/dist/features/InputElementsFormSupport.js +0 -40
  107. package/dist/features/InputElementsFormSupport.js.map +0 -1
  108. package/dist/features/patchPatcher.d.ts +0 -11
  109. package/dist/features/patchPatcher.js +0 -11
  110. package/dist/features/patchPatcher.js.map +0 -1
  111. package/dist/locale/timezoneChange.d.ts +0 -5
  112. package/dist/types/AriaHasPopup.d.ts +0 -32
  113. package/dist/types/AriaHasPopup.js +0 -34
  114. package/dist/types/AriaHasPopup.js.map +0 -1
  115. package/dist/types/AriaLandmarkRole.d.ts +0 -79
  116. package/dist/types/AriaLandmarkRole.js +0 -81
  117. package/dist/types/AriaLandmarkRole.js.map +0 -1
  118. package/dist/types/AriaRole.d.ts +0 -27
  119. package/dist/types/AriaRole.js +0 -29
  120. package/dist/types/AriaRole.js.map +0 -1
@@ -1,3 +1,7 @@
1
+ import createStyleInHead from "./util/createStyleInHead.js";
2
+ import createLinkInHead from "./util/createLinkInHead.js";
3
+ import { shouldUseLinks, getUrl } from "./CSP.js";
4
+ import { isSafari } from "./Device.js";
1
5
  import { getCurrentRuntimeIndex, compareRuntimes } from "./Runtimes.js";
2
6
  const isSSR = typeof document === "undefined";
3
7
  const getStyleId = (name, value) => {
@@ -12,32 +16,89 @@ const shouldUpdate = (runtimeIndex) => {
12
16
  const createStyle = (data, name, value = "", theme) => {
13
17
  const content = typeof data === "string" ? data : data.content;
14
18
  const currentRuntimeIndex = getCurrentRuntimeIndex();
15
- const stylesheet = new CSSStyleSheet();
16
- stylesheet.replaceSync(content);
17
- stylesheet._ui5StyleId = getStyleId(name, value); // set an id so that we can find the style later
18
- if (theme) {
19
- stylesheet._ui5RuntimeIndex = currentRuntimeIndex;
20
- stylesheet._ui5Theme = theme;
21
- }
22
- document.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];
19
+ if (shouldUseLinks()) {
20
+ const attributes = {};
21
+ attributes[name] = value;
22
+ if (theme) {
23
+ attributes["data-ui5-runtime-index"] = currentRuntimeIndex;
24
+ attributes["data-ui5-theme"] = theme;
25
+ }
26
+ const href = getUrl(data.packageName, data.fileName);
27
+ createLinkInHead(href, attributes);
28
+ }
29
+ else if (document.adoptedStyleSheets && !isSafari()) {
30
+ const stylesheet = new CSSStyleSheet();
31
+ stylesheet.replaceSync(content);
32
+ stylesheet._ui5StyleId = getStyleId(name, value); // set an id so that we can find the style later
33
+ if (theme) {
34
+ stylesheet._ui5RuntimeIndex = currentRuntimeIndex;
35
+ stylesheet._ui5Theme = theme;
36
+ }
37
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];
38
+ }
39
+ else {
40
+ const attributes = {};
41
+ attributes[name] = value;
42
+ if (theme) {
43
+ attributes["data-ui5-runtime-index"] = currentRuntimeIndex;
44
+ attributes["data-ui5-theme"] = theme;
45
+ }
46
+ createStyleInHead(content, attributes);
47
+ }
23
48
  };
24
49
  const updateStyle = (data, name, value = "", theme) => {
25
50
  const content = typeof data === "string" ? data : data.content;
26
51
  const currentRuntimeIndex = getCurrentRuntimeIndex();
27
- const stylesheet = document.adoptedStyleSheets.find(sh => sh._ui5StyleId === getStyleId(name, value));
28
- if (!stylesheet) {
29
- return;
52
+ if (shouldUseLinks()) {
53
+ const link = document.querySelector(`head>link[${name}="${value}"]`);
54
+ const href = getUrl(data.packageName, data.fileName);
55
+ if (!theme) {
56
+ link.href = href;
57
+ }
58
+ else {
59
+ const linkRuntimeIndex = link.getAttribute("data-ui5-runtime-index") || undefined;
60
+ const linkTheme = link.getAttribute("data-ui5-theme");
61
+ if (linkTheme !== theme || shouldUpdate(linkRuntimeIndex)) {
62
+ link.href = href;
63
+ link.setAttribute("data-ui5-runtime-index", String(currentRuntimeIndex));
64
+ link.setAttribute("data-ui5-theme", theme);
65
+ }
66
+ }
30
67
  }
31
- if (!theme) {
32
- stylesheet.replaceSync(content || "");
68
+ else if (document.adoptedStyleSheets && !isSafari()) {
69
+ const stylesheet = document.adoptedStyleSheets.find(sh => sh._ui5StyleId === getStyleId(name, value));
70
+ if (!stylesheet) {
71
+ return;
72
+ }
73
+ if (!theme) {
74
+ stylesheet.replaceSync(content || "");
75
+ }
76
+ else {
77
+ const stylesheetRuntimeIndex = stylesheet._ui5RuntimeIndex;
78
+ const stylesheetTheme = stylesheet._ui5Theme;
79
+ if (stylesheetTheme !== theme || shouldUpdate(stylesheetRuntimeIndex)) {
80
+ stylesheet.replaceSync(content || "");
81
+ stylesheet._ui5RuntimeIndex = String(currentRuntimeIndex);
82
+ stylesheet._ui5Theme = theme;
83
+ }
84
+ }
33
85
  }
34
86
  else {
35
- const stylesheetRuntimeIndex = stylesheet._ui5RuntimeIndex;
36
- const stylesheetTheme = stylesheet._ui5Theme;
37
- if (stylesheetTheme !== theme || shouldUpdate(stylesheetRuntimeIndex)) {
38
- stylesheet.replaceSync(content || "");
39
- stylesheet._ui5RuntimeIndex = String(currentRuntimeIndex);
40
- stylesheet._ui5Theme = theme;
87
+ const style = document.querySelector(`head>style[${name}="${value}"]`);
88
+ if (!style) {
89
+ return;
90
+ }
91
+ if (!theme) {
92
+ style.textContent = content || "";
93
+ }
94
+ else {
95
+ const styleRuntimeIndex = style.getAttribute("data-ui5-runtime-index") || undefined;
96
+ const styleTheme = style.getAttribute("data-ui5-theme");
97
+ if (styleTheme !== theme || shouldUpdate(styleRuntimeIndex)) {
98
+ style.textContent = content || "";
99
+ style.setAttribute("data-ui5-runtime-index", String(currentRuntimeIndex));
100
+ style.setAttribute("data-ui5-theme", theme);
101
+ }
41
102
  }
42
103
  }
43
104
  };
@@ -45,10 +106,27 @@ const hasStyle = (name, value = "") => {
45
106
  if (isSSR) {
46
107
  return true;
47
108
  }
48
- return !!document.adoptedStyleSheets.find(sh => sh._ui5StyleId === getStyleId(name, value));
109
+ if (shouldUseLinks()) {
110
+ return !!document.querySelector(`head>link[${name}="${value}"]`);
111
+ }
112
+ const styleElement = document.querySelector(`head>style[${name}="${value}"]`);
113
+ if (document.adoptedStyleSheets && !isSafari()) {
114
+ return !!styleElement || !!document.adoptedStyleSheets.find(sh => sh._ui5StyleId === getStyleId(name, value));
115
+ }
116
+ return !!styleElement;
49
117
  };
50
118
  const removeStyle = (name, value = "") => {
51
- document.adoptedStyleSheets = document.adoptedStyleSheets.filter(sh => sh._ui5StyleId !== getStyleId(name, value));
119
+ if (shouldUseLinks()) {
120
+ const linkElement = document.querySelector(`head>link[${name}="${value}"]`);
121
+ linkElement?.parentElement?.removeChild(linkElement);
122
+ }
123
+ else if (document.adoptedStyleSheets && !isSafari()) {
124
+ document.adoptedStyleSheets = document.adoptedStyleSheets.filter(sh => sh._ui5StyleId !== getStyleId(name, value));
125
+ }
126
+ else {
127
+ const styleElement = document.querySelector(`head > style[${name}="${value}"]`);
128
+ styleElement?.parentElement?.removeChild(styleElement);
129
+ }
52
130
  };
53
131
  const createOrUpdateStyle = (data, name, value = "", theme) => {
54
132
  if (hasStyle(name, value)) {
@@ -1 +1 @@
1
- {"version":3,"file":"ManagedStyles.js","sourceRoot":"","sources":["../src/ManagedStyles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAExE,MAAM,KAAK,GAAG,OAAO,QAAQ,KAAK,WAAW,CAAC;AAE9C,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,KAAa,EAAE,EAAE;IAClD,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,YAAgC,EAAE,EAAE;IACzD,IAAI,YAAY,KAAK,SAAS,EAAE;QAC/B,OAAO,IAAI,CAAC;KACZ;IACD,OAAO,eAAe,CAAC,sBAAsB,EAAE,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,2FAA2F;AAC5K,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,IAAe,EAAE,IAAY,EAAE,KAAK,GAAG,EAAE,EAAE,KAAc,EAAE,EAAE;IACjF,MAAM,OAAO,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IAC/D,MAAM,mBAAmB,GAAG,sBAAsB,EAAE,CAAC;IAErD,MAAM,UAAU,GAAG,IAAI,aAAa,EAAE,CAAC;IACvC,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/B,UAAkC,CAAC,WAAW,GAAG,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,gDAAgD;IAC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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 { StyleData, StyleDataCSP } from \"./types.js\";\nimport { getCurrentRuntimeIndex, compareRuntimes } from \"./Runtimes.js\";\n\nconst isSSR = typeof document === \"undefined\";\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\tconst stylesheet = new CSSStyleSheet();\n\tstylesheet.replaceSync(content);\n\t(stylesheet as Record<string, any>)._ui5StyleId = getStyleId(name, value); // set an id so that we can find the style later\n\tif (theme) {\n\t\t(stylesheet as Record<string, any>)._ui5RuntimeIndex = currentRuntimeIndex;\n\t\t(stylesheet as Record<string, any>)._ui5Theme = theme;\n\t}\n\tdocument.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];\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\tconst stylesheet = document.adoptedStyleSheets.find(sh => (sh as Record<string, any>)._ui5StyleId === getStyleId(name, value));\n\tif (!stylesheet) {\n\t\treturn;\n\t}\n\n\tif (!theme) {\n\t\tstylesheet.replaceSync(content || \"\");\n\t} else {\n\t\tconst stylesheetRuntimeIndex: string | undefined = (stylesheet as Record<string, any>)._ui5RuntimeIndex;\n\t\tconst stylesheetTheme: string | undefined = (stylesheet as Record<string, any>)._ui5Theme;\n\t\tif (stylesheetTheme !== theme || shouldUpdate(stylesheetRuntimeIndex)) {\n\t\t\tstylesheet.replaceSync(content || \"\");\n\t\t\t(stylesheet as Record<string, any>)._ui5RuntimeIndex = String(currentRuntimeIndex);\n\t\t\t(stylesheet as Record<string, any>)._ui5Theme = theme;\n\t\t}\n\t}\n};\n\nconst hasStyle = (name: string, value = \"\"): boolean => {\n\tif (isSSR) {\n\t\treturn true;\n\t}\n\n\treturn !!document.adoptedStyleSheets.find(sh => (sh as Record<string, any>)._ui5StyleId === getStyleId(name, value));\n};\n\nconst removeStyle = (name: string, value = \"\") => {\n\tdocument.adoptedStyleSheets = document.adoptedStyleSheets.filter(sh => (sh as Record<string, any>)._ui5StyleId !== getStyleId(name, value));\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};\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B,WAAW,CAAC,IAAI,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 isSSR = typeof document === \"undefined\";\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 (isSSR) {\n\t\treturn true;\n\t}\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"]}
@@ -0,0 +1,35 @@
1
+ import "./StaticArea.js";
2
+ import type UI5Element from "./UI5Element.js";
3
+ /**
4
+ * @class
5
+ * @private
6
+ */
7
+ declare class StaticAreaItem extends HTMLElement {
8
+ _rendered: boolean;
9
+ ownerElement?: UI5Element;
10
+ constructor();
11
+ /**
12
+ * @param ownerElement the UI5Element instance that owns this static area item
13
+ */
14
+ setOwnerElement(ownerElement: UI5Element): void;
15
+ /**
16
+ * Updates the shadow root of the static area item with the latest state, if rendered
17
+ */
18
+ update(): void;
19
+ updateAdditionalProperties(): void;
20
+ /**
21
+ * Sets the correct content density based on the owner element's state
22
+ * @private
23
+ */
24
+ _updateContentDensity(): void;
25
+ _updateDirection(): void;
26
+ _updateAdditionalAttrs(): void;
27
+ /**
28
+ * Returns reference to the DOM element where the current fragment is added.
29
+ * @protected
30
+ */
31
+ getDomRef(): Promise<ShadowRoot | null>;
32
+ static getTag(): string;
33
+ static createInstance(): StaticAreaItem;
34
+ }
35
+ export default StaticAreaItem;
@@ -0,0 +1,100 @@
1
+ import "./StaticArea.js";
2
+ import updateShadowRoot from "./updateShadowRoot.js";
3
+ import { renderFinished } from "./Render.js";
4
+ import getEffectiveContentDensity from "./util/getEffectiveContentDensity.js";
5
+ import { getEffectiveScopingSuffixForTag } from "./CustomElementsScopeUtils.js";
6
+ import getEffectiveDir from "./locale/getEffectiveDir.js";
7
+ const pureTagName = "ui5-static-area-item";
8
+ const popupIntegrationAttr = "data-sap-ui-integration-popup-content";
9
+ /**
10
+ * @class
11
+ * @private
12
+ */
13
+ class StaticAreaItem extends HTMLElement {
14
+ constructor() {
15
+ super();
16
+ this._rendered = false;
17
+ this.attachShadow({ mode: "open" });
18
+ }
19
+ /**
20
+ * @param ownerElement the UI5Element instance that owns this static area item
21
+ */
22
+ setOwnerElement(ownerElement) {
23
+ this.ownerElement = ownerElement;
24
+ this.classList.add(this.ownerElement._id); // used for getting the popover in the tests
25
+ if (this.ownerElement.hasAttribute("data-ui5-static-stable")) {
26
+ this.setAttribute("data-ui5-stable", this.ownerElement.getAttribute("data-ui5-static-stable")); // stable selector
27
+ }
28
+ }
29
+ /**
30
+ * Updates the shadow root of the static area item with the latest state, if rendered
31
+ */
32
+ update() {
33
+ if (this._rendered) {
34
+ this.updateAdditionalProperties();
35
+ updateShadowRoot(this.ownerElement, true);
36
+ }
37
+ }
38
+ updateAdditionalProperties() {
39
+ this._updateAdditionalAttrs();
40
+ this._updateContentDensity();
41
+ this._updateDirection();
42
+ }
43
+ /**
44
+ * Sets the correct content density based on the owner element's state
45
+ * @private
46
+ */
47
+ _updateContentDensity() {
48
+ if (getEffectiveContentDensity(this.ownerElement) === "compact") {
49
+ this.classList.add("sapUiSizeCompact");
50
+ this.classList.add("ui5-content-density-compact");
51
+ }
52
+ else {
53
+ this.classList.remove("sapUiSizeCompact");
54
+ this.classList.remove("ui5-content-density-compact");
55
+ }
56
+ }
57
+ _updateDirection() {
58
+ if (this.ownerElement) {
59
+ const dir = getEffectiveDir(this.ownerElement);
60
+ if (dir === "rtl") {
61
+ this.setAttribute("dir", dir);
62
+ }
63
+ else {
64
+ this.removeAttribute("dir");
65
+ }
66
+ }
67
+ }
68
+ _updateAdditionalAttrs() {
69
+ this.setAttribute(pureTagName, "");
70
+ this.setAttribute(popupIntegrationAttr, "");
71
+ }
72
+ /**
73
+ * Returns reference to the DOM element where the current fragment is added.
74
+ * @protected
75
+ */
76
+ async getDomRef() {
77
+ this.updateAdditionalProperties();
78
+ if (!this._rendered) {
79
+ this._rendered = true;
80
+ updateShadowRoot(this.ownerElement, true);
81
+ }
82
+ await renderFinished(); // Wait for the content of the ui5-static-area-item to be rendered
83
+ return this.shadowRoot;
84
+ }
85
+ static getTag() {
86
+ const suffix = getEffectiveScopingSuffixForTag(pureTagName);
87
+ if (!suffix) {
88
+ return pureTagName;
89
+ }
90
+ return `${pureTagName}-${suffix}`;
91
+ }
92
+ static createInstance() {
93
+ if (!customElements.get(StaticAreaItem.getTag())) {
94
+ customElements.define(StaticAreaItem.getTag(), StaticAreaItem);
95
+ }
96
+ return document.createElement(this.getTag());
97
+ }
98
+ }
99
+ export default StaticAreaItem;
100
+ //# sourceMappingURL=StaticAreaItem.js.map
@@ -0,0 +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;AAG1D,MAAM,WAAW,GAAG,sBAAsB,CAAC;AAC3C,MAAM,oBAAoB,GAAG,uCAAuC,CAAC;AAErE;;;GAGG;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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,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 * @class\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 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 === \"rtl\") {\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 * Returns reference to the DOM element where the current fragment is added.\n\t * @protected\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"]}
@@ -1,9 +1,10 @@
1
1
  import "@ui5/webcomponents-base/dist/ssr-dom.js";
2
2
  import UI5ElementMetadata, { Slot, SlotValue, State, PropertyValue, Metadata } from "./UI5ElementMetadata.js";
3
3
  import EventProvider from "./EventProvider.js";
4
+ import StaticAreaItem from "./StaticAreaItem.js";
4
5
  import type { TemplateFunction, TemplateFunctionResult } from "./renderer/executeTemplate.js";
5
6
  import type { AccessibilityInfo, PromiseResolve, ComponentStylesData, ClassMap } from "./types.js";
6
- type Renderer = (templateResult: TemplateFunctionResult, container: HTMLElement | DocumentFragment, options: RendererOptions) => void;
7
+ type Renderer = (templateResult: TemplateFunctionResult, container: HTMLElement | DocumentFragment, styleStrOrHrefsArr: string | Array<string> | undefined, forStaticArea: boolean, options: RendererOptions) => void;
7
8
  type RendererOptions = {
8
9
  /**
9
10
  * An object to use as the `this` value for event listeners. It's often
@@ -47,11 +48,16 @@ declare abstract class UI5Element extends HTMLElement {
47
48
  };
48
49
  _doNotSyncAttributes: Set<string>;
49
50
  _state: State;
50
- _internals?: ElementInternals;
51
51
  _getRealDomRef?: () => HTMLElement;
52
+ staticAreaItem?: StaticAreaItem;
52
53
  static template?: TemplateFunction;
54
+ static staticAreaTemplate?: TemplateFunction;
53
55
  static _metadata: UI5ElementMetadata;
54
- static renderer: Renderer;
56
+ /**
57
+ * @deprecated
58
+ */
59
+ static render: Renderer;
60
+ static renderer?: Renderer;
55
61
  constructor();
56
62
  /**
57
63
  * Returns a unique ID for this UI5 Element
@@ -61,6 +67,7 @@ declare abstract class UI5Element extends HTMLElement {
61
67
  */
62
68
  get _id(): string;
63
69
  render(): object;
70
+ renderStatic(): object;
64
71
  /**
65
72
  * Do not call this method from derivatives of UI5Element, use "onEnterDOM" only
66
73
  * @private
@@ -140,8 +147,6 @@ declare abstract class UI5Element extends HTMLElement {
140
147
  * @private
141
148
  */
142
149
  attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
143
- formAssociatedCallback(): void;
144
- static get formAssociated(): boolean;
145
150
  /**
146
151
  * @private
147
152
  */
@@ -198,9 +203,9 @@ declare abstract class UI5Element extends HTMLElement {
198
203
  * 1) children: immediate children (HTML elements or text nodes) were added, removed or reordered in the slot
199
204
  * 2) textcontent: text nodes in the slot changed value (or nested text nodes were added or changed value). Can only trigger for slots of "type: Node"
200
205
  * 3) slotchange: a slot element, slotted inside that slot had its "slotchange" event listener called. This practically means that transitively slotted children changed.
201
- * Can only trigger if the child of a slot is a slot element itself.
206
+ * Can only trigger if the child of a slot is a slot element itself.
202
207
  * 4) childchange: indicates that a UI5Element child in that slot was invalidated and in turn invalidated the component.
203
- * Can only trigger for slots with "invalidateOnChildChange" metadata descriptor
208
+ * Can only trigger for slots with "invalidateOnChildChange" metadata descriptor
204
209
  *
205
210
  * - newValue: the new value of the property (for type="property" only)
206
211
  *
@@ -312,6 +317,14 @@ declare abstract class UI5Element extends HTMLElement {
312
317
  * @private
313
318
  */
314
319
  static _needsShadowDOM(): boolean;
320
+ /**
321
+ * @private
322
+ */
323
+ static _needsStaticArea(): boolean;
324
+ /**
325
+ * @public
326
+ */
327
+ getStaticAreaItemDomRef(): Promise<ShadowRoot | null>;
315
328
  /**
316
329
  * @private
317
330
  */
@@ -326,6 +339,11 @@ declare abstract class UI5Element extends HTMLElement {
326
339
  * @protected
327
340
  */
328
341
  static styles: ComponentStylesData;
342
+ /**
343
+ * Returns the Static Area CSS for this UI5 Web Component Class
344
+ * @protected
345
+ */
346
+ static get staticAreaStyles(): ComponentStylesData;
329
347
  /**
330
348
  * Returns an array with the dependencies for this UI5 Web Component, which could be:
331
349
  * - composed components (used in its shadow root or static area item)
@@ -334,6 +352,7 @@ declare abstract class UI5Element extends HTMLElement {
334
352
  * @protected
335
353
  */
336
354
  static get dependencies(): Array<typeof UI5Element>;
355
+ static cacheUniqueDependencies(this: typeof UI5Element): void;
337
356
  /**
338
357
  * Returns a list of the unique dependencies for this UI5 Web Component
339
358
  *
@@ -361,15 +380,11 @@ declare abstract class UI5Element extends HTMLElement {
361
380
  * @public
362
381
  */
363
382
  static getMetadata(): UI5ElementMetadata;
364
- get validity(): ValidityState | undefined;
365
- get validationMessage(): string | undefined;
366
- checkValidity(): boolean | undefined;
367
- reportValidity(): boolean | undefined;
368
383
  }
369
384
  /**
370
385
  * Always use duck-typing to cover all runtimes on the page.
371
386
  */
372
387
  declare const instanceOfUI5Element: (object: any) => object is UI5Element;
373
388
  export default UI5Element;
374
- export { instanceOfUI5Element, };
389
+ export { instanceOfUI5Element };
375
390
  export type { ChangeInfo, Renderer, RendererOptions, };