@ui5/webcomponents-base 0.0.0-33967dd12 → 0.0.0-33e059bcd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +1 -1
- package/CHANGELOG.md +340 -0
- package/README.md +2 -1
- package/dist/.tsbuildinfo +1 -0
- package/dist/AssetRegistry.d.ts +2 -2
- package/dist/AssetRegistry.js +2 -2
- package/dist/AssetRegistry.js.map +1 -1
- package/dist/CustomElementsScope.d.ts +4 -4
- package/dist/CustomElementsScope.js +2 -2
- package/dist/CustomElementsScope.js.map +1 -1
- package/dist/CustomElementsScopeUtils.d.ts +8 -1
- package/dist/CustomElementsScopeUtils.js +13 -1
- package/dist/CustomElementsScopeUtils.js.map +1 -1
- package/dist/Device.d.ts +2 -1
- package/dist/Device.js +10 -1
- package/dist/Device.js.map +1 -1
- package/dist/InitialConfiguration.d.ts +2 -1
- package/dist/InitialConfiguration.js +6 -1
- package/dist/InitialConfiguration.js.map +1 -1
- package/dist/Keys.js +104 -105
- package/dist/Keys.js.map +1 -1
- package/dist/ManagedStyles.d.ts +5 -4
- package/dist/ManagedStyles.js +96 -23
- package/dist/ManagedStyles.js.map +1 -1
- package/dist/MediaRange.d.ts +0 -6
- package/dist/MediaRange.js +5 -15
- package/dist/MediaRange.js.map +1 -1
- package/dist/StaticAreaItem.d.ts +2 -4
- package/dist/StaticAreaItem.js +2 -7
- package/dist/StaticAreaItem.js.map +1 -1
- package/dist/UI5Element.d.ts +29 -25
- package/dist/UI5Element.js +45 -38
- package/dist/UI5Element.js.map +1 -1
- package/dist/UI5ElementMetadata.d.ts +4 -11
- package/dist/UI5ElementMetadata.js +15 -13
- package/dist/UI5ElementMetadata.js.map +1 -1
- package/dist/asset-registries/Illustrations.d.ts +1 -0
- package/dist/asset-registries/Illustrations.js +50 -20
- package/dist/asset-registries/Illustrations.js.map +1 -1
- package/dist/asset-registries/Themes.d.ts +4 -3
- package/dist/asset-registries/Themes.js +26 -10
- package/dist/asset-registries/Themes.js.map +1 -1
- package/dist/asset-registries/i18n.js +2 -1
- package/dist/asset-registries/i18n.js.map +1 -1
- package/dist/config/CalendarType.d.ts +8 -1
- package/dist/config/CalendarType.js +18 -2
- package/dist/config/CalendarType.js.map +1 -1
- package/dist/config/Icons.d.ts +1 -1
- package/dist/config/Icons.js.map +1 -1
- package/dist/connectToComponent.d.ts +9 -0
- package/dist/connectToComponent.js +59 -0
- package/dist/connectToComponent.js.map +1 -0
- package/dist/css/FontFace.css +13 -1
- package/dist/custom-elements-internal.json +2765 -0
- package/dist/custom-elements.json +2528 -0
- package/dist/decorators/customElement.d.ts +1 -1
- package/dist/decorators/customElement.js +1 -1
- package/dist/decorators/customElement.js.map +1 -1
- package/dist/decorators/event.d.ts +5 -2
- package/dist/decorators/event.js.map +1 -1
- package/dist/delegate/ItemNavigation.d.ts +9 -8
- package/dist/delegate/ItemNavigation.js +12 -13
- package/dist/delegate/ItemNavigation.js.map +1 -1
- package/dist/delegate/ResizeHandler.d.ts +4 -6
- package/dist/delegate/ResizeHandler.js +4 -6
- package/dist/delegate/ResizeHandler.js.map +1 -1
- package/dist/delegate/ScrollEnablement.js +2 -2
- package/dist/delegate/ScrollEnablement.js.map +1 -1
- package/dist/features/OpenUI5Enablement.d.ts +1 -1
- package/dist/features/OpenUI5Support.js +2 -1
- package/dist/features/OpenUI5Support.js.map +1 -1
- package/dist/generated/AssetParameters.d.ts +6 -0
- package/dist/generated/AssetParameters.js +3 -10
- package/dist/generated/AssetParameters.js.map +1 -0
- package/dist/generated/VersionInfo.d.ts +10 -0
- package/dist/generated/VersionInfo.js +9 -8
- package/dist/generated/VersionInfo.js.map +1 -0
- package/dist/generated/css/FontFace.css.js +1 -1
- package/dist/generated/css/FontFace.css.js.map +1 -1
- package/dist/generated/templates/elements/WithComplexTemplateTemplate.lit.d.ts +1 -1
- package/dist/i18nBundle.d.ts +1 -3
- package/dist/i18nBundle.js +1 -4
- package/dist/i18nBundle.js.map +1 -1
- package/dist/renderer/LitRenderer.d.ts +2 -2
- package/dist/sap/base/Log.js +698 -188
- package/dist/sap/base/assert.js +28 -1
- package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
- package/dist/sap/base/security/URLListValidator.js +253 -6
- package/dist/sap/base/security/encodeCSS.js +34 -8
- package/dist/sap/base/security/encodeXML.js +47 -17
- package/dist/sap/base/security/sanitizeHTML.js +35 -13
- package/dist/sap/base/strings/toHex.js +27 -2
- package/dist/sap/base/util/now.js +24 -3
- package/dist/sap/base/util/uid.js +27 -0
- package/dist/sap/ui/thirdparty/caja-html-sanitizer.js +1 -1
- package/dist/ssr-dom-shim.d.ts +1 -0
- package/dist/ssr-dom-shim.js +12 -0
- package/dist/ssr-dom-shim.js.map +1 -0
- package/dist/ssr-dom.d.ts +0 -0
- package/dist/ssr-dom.js +3 -0
- package/dist/ssr-dom.js.map +1 -0
- package/dist/theming/applyTheme.js +5 -6
- package/dist/theming/applyTheme.js.map +1 -1
- package/dist/types/AnimationMode.d.ts +0 -8
- package/dist/types/AnimationMode.js +0 -8
- package/dist/types/AnimationMode.js.map +1 -1
- package/dist/types/CSSColor.d.ts +0 -4
- package/dist/types/CSSColor.js +0 -4
- package/dist/types/CSSColor.js.map +1 -1
- package/dist/types/CSSSize.d.ts +11 -0
- package/dist/types/CSSSize.js +14 -0
- package/dist/types/CSSSize.js.map +1 -0
- package/dist/types/CalendarType.d.ts +0 -9
- package/dist/types/CalendarType.js +0 -9
- package/dist/types/CalendarType.js.map +1 -1
- package/dist/types/DOMReference.d.ts +0 -4
- package/dist/types/DOMReference.js +0 -4
- package/dist/types/DOMReference.js.map +1 -1
- package/dist/types/DataType.d.ts +1 -6
- package/dist/types/DataType.js +1 -6
- package/dist/types/DataType.js.map +1 -1
- package/dist/types/Float.d.ts +0 -3
- package/dist/types/Float.js +0 -3
- package/dist/types/Float.js.map +1 -1
- package/dist/types/Integer.d.ts +0 -3
- package/dist/types/Integer.js +0 -3
- package/dist/types/Integer.js.map +1 -1
- package/dist/types/InvisibleMessageMode.d.ts +5 -10
- package/dist/types/InvisibleMessageMode.js +4 -11
- package/dist/types/InvisibleMessageMode.js.map +1 -1
- package/dist/types/ItemNavigationBehavior.d.ts +0 -6
- package/dist/types/ItemNavigationBehavior.js +0 -6
- package/dist/types/ItemNavigationBehavior.js.map +1 -1
- package/dist/types/NavigationMode.d.ts +0 -8
- package/dist/types/NavigationMode.js +0 -8
- package/dist/types/NavigationMode.js.map +1 -1
- package/dist/types/ValueState.d.ts +0 -14
- package/dist/types/ValueState.js +0 -14
- package/dist/types/ValueState.js.map +1 -1
- package/dist/updateShadowRoot.js +2 -1
- package/dist/updateShadowRoot.js.map +1 -1
- package/dist/util/ColorConversion.js +200 -195
- package/dist/util/ColorConversion.js.map +1 -1
- package/dist/util/InvisibleMessage.d.ts +1 -1
- package/dist/util/InvisibleMessage.js.map +1 -1
- package/dist/util/detectNavigatorLanguage.d.ts +2 -2
- package/dist/util/detectNavigatorLanguage.js +6 -1
- package/dist/util/detectNavigatorLanguage.js.map +1 -1
- package/dist/util/getClassCopy.d.ts +52 -33
- package/dist/util/getDesigntimePropertyAsArray.d.ts +2 -2
- package/dist/util/getDesigntimePropertyAsArray.js +2 -1
- package/dist/util/getDesigntimePropertyAsArray.js.map +1 -1
- package/dist/util/getParentElement.d.ts +2 -0
- package/dist/util/getParentElement.js +5 -0
- package/dist/util/getParentElement.js.map +1 -0
- package/dist/util/isElementContainingBlock.d.ts +2 -0
- package/dist/util/isElementContainingBlock.js +11 -0
- package/dist/util/isElementContainingBlock.js.map +1 -0
- package/index.js +1 -1
- package/lib/generate-asset-parameters/index.js +2 -2
- package/lib/generate-version-info/index.js +2 -2
- package/package-scripts.cjs +12 -18
- package/package.json +14 -6
- package/src/css/FontFace.css +13 -1
- package/tsconfig.json +4 -0
- package/used-modules.txt +4 -0
- package/dist/api.json +0 -1
- package/dist/assets/Boot.34b7cea0.css +0 -1
- package/dist/assets/Boot.4ba9c8eb.js +0 -9
- package/dist/assets/bundle.esm.3c881d7f.js +0 -50
package/dist/ManagedStyles.js
CHANGED
|
@@ -1,70 +1,126 @@
|
|
|
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 {
|
|
4
|
+
import { isSafari } from "./Device.js";
|
|
5
|
+
import { getCurrentRuntimeIndex, compareRuntimes } from "./Runtimes.js";
|
|
6
|
+
const isSSR = typeof document === "undefined";
|
|
5
7
|
const getStyleId = (name, value) => {
|
|
6
8
|
return value ? `${name}|${value}` : name;
|
|
7
9
|
};
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
content = content.replaceAll("[_ui5host]", `[_ui5rt${getCurrentRuntimeIndex()}]`);
|
|
10
|
+
const shouldUpdate = (runtimeIndex) => {
|
|
11
|
+
if (runtimeIndex === undefined) {
|
|
12
|
+
return true;
|
|
12
13
|
}
|
|
14
|
+
return compareRuntimes(getCurrentRuntimeIndex(), parseInt(runtimeIndex)) === 1; // 1 means the current is newer, 0 means the same, -1 means the resource's runtime is newer
|
|
15
|
+
};
|
|
16
|
+
const createStyle = (data, name, value = "", theme) => {
|
|
17
|
+
const content = typeof data === "string" ? data : data.content;
|
|
18
|
+
const currentRuntimeIndex = getCurrentRuntimeIndex();
|
|
13
19
|
if (shouldUseLinks()) {
|
|
14
20
|
const attributes = {};
|
|
15
21
|
attributes[name] = value;
|
|
22
|
+
if (theme) {
|
|
23
|
+
attributes["data-ui5-runtime-index"] = currentRuntimeIndex;
|
|
24
|
+
attributes["data-ui5-theme"] = theme;
|
|
25
|
+
}
|
|
16
26
|
const href = getUrl(data.packageName, data.fileName);
|
|
17
27
|
createLinkInHead(href, attributes);
|
|
18
28
|
}
|
|
19
|
-
else if (document.adoptedStyleSheets) {
|
|
29
|
+
else if (document.adoptedStyleSheets && !isSafari()) {
|
|
20
30
|
const stylesheet = new CSSStyleSheet();
|
|
21
31
|
stylesheet.replaceSync(content);
|
|
22
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
|
+
}
|
|
23
37
|
document.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];
|
|
24
38
|
}
|
|
25
39
|
else {
|
|
26
40
|
const attributes = {};
|
|
27
41
|
attributes[name] = value;
|
|
42
|
+
if (theme) {
|
|
43
|
+
attributes["data-ui5-runtime-index"] = currentRuntimeIndex;
|
|
44
|
+
attributes["data-ui5-theme"] = theme;
|
|
45
|
+
}
|
|
28
46
|
createStyleInHead(content, attributes);
|
|
29
47
|
}
|
|
30
48
|
};
|
|
31
|
-
const updateStyle = (data, name, value = "") => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
content = content.replaceAll("[_ui5host]", `[_ui5rt${getCurrentRuntimeIndex()}]`);
|
|
35
|
-
}
|
|
49
|
+
const updateStyle = (data, name, value = "", theme) => {
|
|
50
|
+
const content = typeof data === "string" ? data : data.content;
|
|
51
|
+
const currentRuntimeIndex = getCurrentRuntimeIndex();
|
|
36
52
|
if (shouldUseLinks()) {
|
|
37
53
|
const link = document.querySelector(`head>link[${name}="${value}"]`);
|
|
38
|
-
|
|
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
|
+
}
|
|
39
67
|
}
|
|
40
|
-
else if (document.adoptedStyleSheets) {
|
|
68
|
+
else if (document.adoptedStyleSheets && !isSafari()) {
|
|
41
69
|
const stylesheet = document.adoptedStyleSheets.find(sh => sh._ui5StyleId === getStyleId(name, value));
|
|
42
|
-
if (stylesheet) {
|
|
70
|
+
if (!stylesheet) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (!theme) {
|
|
43
74
|
stylesheet.replaceSync(content || "");
|
|
44
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
|
+
}
|
|
45
85
|
}
|
|
46
86
|
else {
|
|
47
87
|
const style = document.querySelector(`head>style[${name}="${value}"]`);
|
|
48
|
-
if (style) {
|
|
88
|
+
if (!style) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (!theme) {
|
|
49
92
|
style.textContent = content || "";
|
|
50
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
|
+
}
|
|
102
|
+
}
|
|
51
103
|
}
|
|
52
104
|
};
|
|
53
105
|
const hasStyle = (name, value = "") => {
|
|
106
|
+
if (isSSR) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
54
109
|
if (shouldUseLinks()) {
|
|
55
110
|
return !!document.querySelector(`head>link[${name}="${value}"]`);
|
|
56
111
|
}
|
|
57
|
-
|
|
58
|
-
|
|
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));
|
|
59
115
|
}
|
|
60
|
-
return !!
|
|
116
|
+
return !!styleElement;
|
|
61
117
|
};
|
|
62
118
|
const removeStyle = (name, value = "") => {
|
|
63
119
|
if (shouldUseLinks()) {
|
|
64
120
|
const linkElement = document.querySelector(`head>link[${name}="${value}"]`);
|
|
65
121
|
linkElement?.parentElement?.removeChild(linkElement);
|
|
66
122
|
}
|
|
67
|
-
else if (document.adoptedStyleSheets) {
|
|
123
|
+
else if (document.adoptedStyleSheets && !isSafari()) {
|
|
68
124
|
document.adoptedStyleSheets = document.adoptedStyleSheets.filter(sh => sh._ui5StyleId !== getStyleId(name, value));
|
|
69
125
|
}
|
|
70
126
|
else {
|
|
@@ -72,13 +128,30 @@ const removeStyle = (name, value = "") => {
|
|
|
72
128
|
styleElement?.parentElement?.removeChild(styleElement);
|
|
73
129
|
}
|
|
74
130
|
};
|
|
75
|
-
const createOrUpdateStyle = (data, name, value = "") => {
|
|
131
|
+
const createOrUpdateStyle = (data, name, value = "", theme) => {
|
|
76
132
|
if (hasStyle(name, value)) {
|
|
77
|
-
updateStyle(data, name, value);
|
|
133
|
+
updateStyle(data, name, value, theme);
|
|
78
134
|
}
|
|
79
135
|
else {
|
|
80
|
-
createStyle(data, name, value);
|
|
136
|
+
createStyle(data, name, value, theme);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
const mergeStyles = (style1, style2) => {
|
|
140
|
+
if (style1 === undefined) {
|
|
141
|
+
return style2;
|
|
142
|
+
}
|
|
143
|
+
if (style2 === undefined) {
|
|
144
|
+
return style1;
|
|
145
|
+
}
|
|
146
|
+
const style2Content = typeof style2 === "string" ? style2 : style2.content;
|
|
147
|
+
if (typeof style1 === "string") {
|
|
148
|
+
return `${style1} ${style2Content}`;
|
|
81
149
|
}
|
|
150
|
+
return {
|
|
151
|
+
content: `${style1.content} ${style2Content}`,
|
|
152
|
+
packageName: style1.packageName,
|
|
153
|
+
fileName: style1.fileName,
|
|
154
|
+
};
|
|
82
155
|
};
|
|
83
|
-
export { createStyle, hasStyle, updateStyle, removeStyle, createOrUpdateStyle, };
|
|
156
|
+
export { createStyle, hasStyle, updateStyle, removeStyle, createOrUpdateStyle, mergeStyles, };
|
|
84
157
|
//# 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;AAElD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEvD,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,WAAW,GAAG,CAAC,IAAe,EAAE,IAAY,EAAE,KAAK,GAAG,EAAE,EAAE,EAAE;IACjE,IAAI,OAAO,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IAE7D,IAAI,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;QACnC,OAAO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AAC,IAAY,EAAE,KAAK,GAAG,EAAE,EAAE,EAAE;IAChD,IAAI,cAAc,EAAE,EAAE;QACrB,MAAM,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,aAAa,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC;QAC5E,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;KACrD;SAAM,IAAI,QAAQ,CAAC,kBAAkB,EAAE;QACvC,QAAQ,CAAC,kBAAkB,GAAG,QAAQ,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAE,EAA0B,CAAC,WAAW,KAAK,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;KAC5I;SAAM;QACN,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,gBAAgB,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC;QAChF,YAAY,EAAE,aAAa,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;KACvD;AACF,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,IAAe,EAAE,IAAY,EAAE,KAAK,GAAG,EAAE,EAAE,EAAE;IACzE,IAAI,QAAQ,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,\n\tupdateStyle,\n\tremoveStyle,\n\tcreateOrUpdateStyle,\n};\n\nexport type {\n\tStyleData,\n\tStyleDataCSP,\n};\n"]}
|
|
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;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAExE,MAAM,KAAK,GAAG,OAAO,QAAQ,KAAK,WAAW,CAAC;AAE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AAM,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"]}
|
package/dist/MediaRange.d.ts
CHANGED
|
@@ -2,8 +2,6 @@ type Range = Map<string, Array<number>>;
|
|
|
2
2
|
/**
|
|
3
3
|
* Enumeration containing the names and settings of predefined screen width media query range sets.
|
|
4
4
|
*
|
|
5
|
-
* @namespace
|
|
6
|
-
* @name MediaRange.RANGESETS
|
|
7
5
|
* @public
|
|
8
6
|
*/
|
|
9
7
|
declare enum RANGESETS {
|
|
@@ -18,16 +16,12 @@ declare enum RANGESETS {
|
|
|
18
16
|
* <li><code>"XL"</code>: For screens greater than or equal to 1440 pixels.</li>
|
|
19
17
|
* </ul>
|
|
20
18
|
*
|
|
21
|
-
* @name MediaRange.RANGESETS.RANGE_4STEPS
|
|
22
19
|
* @public
|
|
23
20
|
*/
|
|
24
21
|
RANGE_4STEPS = "4Step"
|
|
25
22
|
}
|
|
26
23
|
/**
|
|
27
24
|
* API for screen width changes.
|
|
28
|
-
*
|
|
29
|
-
* @namespace
|
|
30
|
-
* @name MediaRange
|
|
31
25
|
*/
|
|
32
26
|
declare const MediaRange: {
|
|
33
27
|
RANGESETS: typeof RANGESETS;
|
package/dist/MediaRange.js
CHANGED
|
@@ -7,8 +7,6 @@ DEAFULT_RANGE_SET.set("XL", [1440, Infinity]);
|
|
|
7
7
|
/**
|
|
8
8
|
* Enumeration containing the names and settings of predefined screen width media query range sets.
|
|
9
9
|
*
|
|
10
|
-
* @namespace
|
|
11
|
-
* @name MediaRange.RANGESETS
|
|
12
10
|
* @public
|
|
13
11
|
*/
|
|
14
12
|
var RANGESETS;
|
|
@@ -24,7 +22,6 @@ var RANGESETS;
|
|
|
24
22
|
* <li><code>"XL"</code>: For screens greater than or equal to 1440 pixels.</li>
|
|
25
23
|
* </ul>
|
|
26
24
|
*
|
|
27
|
-
* @name MediaRange.RANGESETS.RANGE_4STEPS
|
|
28
25
|
* @public
|
|
29
26
|
*/
|
|
30
27
|
RANGESETS["RANGE_4STEPS"] = "4Step";
|
|
@@ -45,10 +42,9 @@ var RANGESETS;
|
|
|
45
42
|
* <li><code>"Large"</code>: For screens greater than or equal to 400 pixels.</li>
|
|
46
43
|
* </ul>
|
|
47
44
|
*
|
|
48
|
-
* @param
|
|
45
|
+
* @param name The name of the range set to be initialized.
|
|
49
46
|
* The name must be a valid id and consist only of letters and numeric digits.
|
|
50
|
-
* @param
|
|
51
|
-
* @name MediaRange.initRangeSet
|
|
47
|
+
* @param range The given range set.
|
|
52
48
|
*/
|
|
53
49
|
const initRangeSet = (name, range) => {
|
|
54
50
|
mediaRanges.set(name, range);
|
|
@@ -59,13 +55,10 @@ const initRangeSet = (name, range) => {
|
|
|
59
55
|
* If the optional parameter <code>width</code> is given, the active range will be determined for that width,
|
|
60
56
|
* otherwise it is determined for the current window size.
|
|
61
57
|
*
|
|
62
|
-
* @param
|
|
63
|
-
* @param
|
|
58
|
+
* @param name The name of the range set. The range set must be initialized beforehand ({@link MediaRange.initRangeSet})
|
|
59
|
+
* @param [width] An optional width, based on which the range should be determined;
|
|
64
60
|
* If <code>width</code> is not provided, the window size will be used.
|
|
65
|
-
* @returns
|
|
66
|
-
*
|
|
67
|
-
* @name MediaRange.getCurrentRange
|
|
68
|
-
* @function
|
|
61
|
+
* @returns The name of the current active interval of the range set.
|
|
69
62
|
* @public
|
|
70
63
|
*/
|
|
71
64
|
const getCurrentRange = (name, width = window.innerWidth) => {
|
|
@@ -84,9 +77,6 @@ const getCurrentRange = (name, width = window.innerWidth) => {
|
|
|
84
77
|
};
|
|
85
78
|
/**
|
|
86
79
|
* API for screen width changes.
|
|
87
|
-
*
|
|
88
|
-
* @namespace
|
|
89
|
-
* @name MediaRange
|
|
90
80
|
*/
|
|
91
81
|
const MediaRange = {
|
|
92
82
|
RANGESETS,
|
package/dist/MediaRange.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MediaRange.js","sourceRoot":"","sources":["../src/MediaRange.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,GAAG,IAAI,GAAG,EAAiB,CAAC;AAE7C,MAAM,iBAAiB,GAAU,IAAI,GAAG,EAAyB,CAAC;AAClE,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;AACrC,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AACxC,iBAAiB,CAAC,GAAG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AG,CAAC,SAAS,CAAC,YAAY,CAAE,CAAC;KACpD;IAED,IAAI,gBAAgB,CAAC;IACrB,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAEzC,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC/B,IAAI,cAAc,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,cAAc,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE;YAC7D,gBAAgB,GAAG,GAAG,CAAC;SACvB;IACF,CAAC,CAAC,CAAC;IAEH,OAAO,gBAAgB,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,GAAG;IAClB,SAAS;IACT,YAAY;IACZ,eAAe;CACf,CAAC;AAEF,UAAU,CAAC,YAAY,CAAC,UAAU,CAAC,SAAS,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;AAE9E,eAAe,UAAU,CAAC","sourcesContent":["type Range = Map<string, Array<number>>;\n\nconst mediaRanges = new Map<string, Range>();\n\nconst DEAFULT_RANGE_SET: Range = new Map<string, Array<number>>();\nDEAFULT_RANGE_SET.set(\"S\", [0, 599]);\nDEAFULT_RANGE_SET.set(\"M\", [600, 1023]);\nDEAFULT_RANGE_SET.set(\"L\", [1024, 1439]);\nDEAFULT_RANGE_SET.set(\"XL\", [1440, Infinity]);\n\n/**\n * Enumeration containing the names and settings of predefined screen width media query range sets.\n *\n * @public\n */\n enum RANGESETS {\n\t/**\n\t * A 4-step range set (S-M-L-XL).\n\t *\n\t * The ranges of this set are:\n\t * <ul>\n\t * <li><code>\"S\"</code>: For screens smaller than 600 pixels.</li>\n\t * <li><code>\"M\"</code>: For screens greater than or equal to 600 pixels and smaller than 1024 pixels.</li>\n\t * <li><code>\"L\"</code>: For screens greater than or equal to 1024 pixels and smaller than 1440 pixels.</li>\n\t * <li><code>\"XL\"</code>: For screens greater than or equal to 1440 pixels.</li>\n\t * </ul>\n\t *\n\t * @public\n\t */\n\tRANGE_4STEPS = \"4Step\",\n}\n\n/**\n * Initializes a screen width media query range set.\n *\n * This initialization step makes the range set ready to be used for one of the other functions in namespace <code>MediaRange</code>.\n *\n * A range set can be defined as shown in the following example:\n * <pre>\n * MediaRange.initRangeSet(\"MyRangeSet\", [200, 400], [\"Small\", \"Medium\", \"Large\"]);\n * </pre>\n * This example defines the following named ranges:\n * <ul>\n * <li><code>\"Small\"</code>: For screens smaller than 200 pixels.</li>\n * <li><code>\"Medium\"</code>: For screens greater than or equal to 200 pixels and smaller than 400 pixels.</li>\n * <li><code>\"Large\"</code>: For screens greater than or equal to 400 pixels.</li>\n * </ul>\n *\n * @param name The name of the range set to be initialized.\n * The name must be a valid id and consist only of letters and numeric digits.\n * @param range The given range set.\n */\nconst initRangeSet = (name: string, range: Range) => {\n\tmediaRanges.set(name, range);\n};\n\n/**\n * Returns information about the current active range of the range set with the given name.\n *\n * If the optional parameter <code>width</code> is given, the active range will be determined for that width,\n * otherwise it is determined for the current window size.\n *\n * @param name The name of the range set. The range set must be initialized beforehand ({@link MediaRange.initRangeSet})\n * @param [width] An optional width, based on which the range should be determined;\n * If <code>width</code> is not provided, the window size will be used.\n * @returns The name of the current active interval of the range set.\n * @public\n */\nconst getCurrentRange = (name: string, width = window.innerWidth): string => {\n\tlet rangeSet = mediaRanges.get(name);\n\n\tif (!rangeSet) {\n\t\trangeSet = mediaRanges.get(RANGESETS.RANGE_4STEPS)!;\n\t}\n\n\tlet currentRangeName;\n\tconst effectiveWidth = Math.floor(width);\n\n\trangeSet.forEach((value, key) => {\n\t\tif (effectiveWidth >= value[0] && effectiveWidth <= value[1]) {\n\t\t\tcurrentRangeName = key;\n\t\t}\n\t});\n\n\treturn currentRangeName || [...rangeSet.keys()][0];\n};\n\n/**\n * API for screen width changes.\n */\nconst MediaRange = {\n\tRANGESETS,\n\tinitRangeSet,\n\tgetCurrentRange,\n};\n\nMediaRange.initRangeSet(MediaRange.RANGESETS.RANGE_4STEPS, DEAFULT_RANGE_SET);\n\nexport default MediaRange;\n"]}
|
package/dist/StaticAreaItem.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import "./StaticArea.js";
|
|
2
2
|
import type UI5Element from "./UI5Element.js";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
4
|
* @class
|
|
6
|
-
* @author SAP SE
|
|
7
5
|
* @private
|
|
8
6
|
*/
|
|
9
7
|
declare class StaticAreaItem extends HTMLElement {
|
|
@@ -11,7 +9,7 @@ declare class StaticAreaItem extends HTMLElement {
|
|
|
11
9
|
ownerElement?: UI5Element;
|
|
12
10
|
constructor();
|
|
13
11
|
/**
|
|
14
|
-
* @param
|
|
12
|
+
* @param ownerElement the UI5Element instance that owns this static area item
|
|
15
13
|
*/
|
|
16
14
|
setOwnerElement(ownerElement: UI5Element): void;
|
|
17
15
|
/**
|
|
@@ -27,8 +25,8 @@ declare class StaticAreaItem extends HTMLElement {
|
|
|
27
25
|
_updateDirection(): void;
|
|
28
26
|
_updateAdditionalAttrs(): void;
|
|
29
27
|
/**
|
|
30
|
-
* @protected
|
|
31
28
|
* Returns reference to the DOM element where the current fragment is added.
|
|
29
|
+
* @protected
|
|
32
30
|
*/
|
|
33
31
|
getDomRef(): Promise<ShadowRoot | null>;
|
|
34
32
|
static getTag(): string;
|
package/dist/StaticAreaItem.js
CHANGED
|
@@ -4,13 +4,10 @@ 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
|
/**
|
|
11
|
-
*
|
|
12
10
|
* @class
|
|
13
|
-
* @author SAP SE
|
|
14
11
|
* @private
|
|
15
12
|
*/
|
|
16
13
|
class StaticAreaItem extends HTMLElement {
|
|
@@ -20,7 +17,7 @@ class StaticAreaItem extends HTMLElement {
|
|
|
20
17
|
this.attachShadow({ mode: "open" });
|
|
21
18
|
}
|
|
22
19
|
/**
|
|
23
|
-
* @param
|
|
20
|
+
* @param ownerElement the UI5Element instance that owns this static area item
|
|
24
21
|
*/
|
|
25
22
|
setOwnerElement(ownerElement) {
|
|
26
23
|
this.ownerElement = ownerElement;
|
|
@@ -69,14 +66,12 @@ class StaticAreaItem extends HTMLElement {
|
|
|
69
66
|
}
|
|
70
67
|
}
|
|
71
68
|
_updateAdditionalAttrs() {
|
|
72
|
-
this.setAttribute(`_ui5rt${getCurrentRuntimeIndex()}`, "");
|
|
73
|
-
this.setAttribute("_ui5host", "");
|
|
74
69
|
this.setAttribute(pureTagName, "");
|
|
75
70
|
this.setAttribute(popupIntegrationAttr, "");
|
|
76
71
|
}
|
|
77
72
|
/**
|
|
78
|
-
* @protected
|
|
79
73
|
* Returns reference to the DOM element where the current fragment is added.
|
|
74
|
+
* @protected
|
|
80
75
|
*/
|
|
81
76
|
async getDomRef() {
|
|
82
77
|
this.updateAdditionalProperties();
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"StaticAreaItem.js","sour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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) {\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"]}
|
package/dist/UI5Element.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "@ui5/webcomponents-base/dist/ssr-dom.js";
|
|
1
2
|
import UI5ElementMetadata, { Slot, SlotValue, State, PropertyValue, Metadata } from "./UI5ElementMetadata.js";
|
|
2
3
|
import EventProvider from "./EventProvider.js";
|
|
3
4
|
import StaticAreaItem from "./StaticAreaItem.js";
|
|
@@ -26,12 +27,9 @@ type InvalidationInfo = ChangeInfo & {
|
|
|
26
27
|
type ChildChangeListener = (param: InvalidationInfo) => void;
|
|
27
28
|
type SlotChangeListener = (this: HTMLSlotElement, ev: Event) => void;
|
|
28
29
|
/**
|
|
30
|
+
* @class
|
|
29
31
|
* Base class for all UI5 Web Components
|
|
30
32
|
*
|
|
31
|
-
* @class
|
|
32
|
-
* @constructor
|
|
33
|
-
* @author SAP SE
|
|
34
|
-
* @alias sap.ui.webc.base.UI5Element
|
|
35
33
|
* @extends HTMLElement
|
|
36
34
|
* @public
|
|
37
35
|
*/
|
|
@@ -39,7 +37,8 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
39
37
|
__id?: string;
|
|
40
38
|
_suppressInvalidation: boolean;
|
|
41
39
|
_changedState: Array<ChangeInfo>;
|
|
42
|
-
|
|
40
|
+
_invalidationEventProvider: EventProvider<InvalidationInfo, void>;
|
|
41
|
+
_componentStateFinalizedEventProvider: EventProvider<void, void>;
|
|
43
42
|
_inDOM: boolean;
|
|
44
43
|
_fullyConnected: boolean;
|
|
45
44
|
_childChangeListeners: Map<string, ChildChangeListener>;
|
|
@@ -49,7 +48,6 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
49
48
|
};
|
|
50
49
|
_doNotSyncAttributes: Set<string>;
|
|
51
50
|
_state: State;
|
|
52
|
-
_onComponentStateFinalized?: () => void;
|
|
53
51
|
_getRealDomRef?: () => HTMLElement;
|
|
54
52
|
staticAreaItem?: StaticAreaItem;
|
|
55
53
|
static template?: TemplateFunction;
|
|
@@ -125,22 +123,22 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
125
123
|
/**
|
|
126
124
|
* Attach a callback that will be executed whenever the component is invalidated
|
|
127
125
|
*
|
|
128
|
-
* @param
|
|
126
|
+
* @param callback
|
|
129
127
|
* @public
|
|
130
128
|
*/
|
|
131
129
|
attachInvalidate(callback: (param: InvalidationInfo) => void): void;
|
|
132
130
|
/**
|
|
133
131
|
* Detach the callback that is executed whenever the component is invalidated
|
|
134
132
|
*
|
|
135
|
-
* @param
|
|
133
|
+
* @param callback
|
|
136
134
|
* @public
|
|
137
135
|
*/
|
|
138
136
|
detachInvalidate(callback: (param: InvalidationInfo) => void): void;
|
|
139
137
|
/**
|
|
140
138
|
* Callback that is executed whenever a monitored child changes its state
|
|
141
139
|
*
|
|
142
|
-
* @param
|
|
143
|
-
* @param
|
|
140
|
+
* @param slotName the slot in which a child was invalidated
|
|
141
|
+
* @param childChangeInfo the changeInfo object for the child in the given slot
|
|
144
142
|
* @private
|
|
145
143
|
*/
|
|
146
144
|
_onChildChange(slotName: string, childChangeInfo: ChangeInfo): void;
|
|
@@ -165,15 +163,13 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
165
163
|
* Returns a singleton event listener for the "change" event of a child in a given slot
|
|
166
164
|
*
|
|
167
165
|
* @param slotName the name of the slot, where the child is
|
|
168
|
-
* @returns {ChildChangeListener}
|
|
169
166
|
* @private
|
|
170
167
|
*/
|
|
171
|
-
_getChildChangeListener(slotName: string): ChildChangeListener
|
|
168
|
+
_getChildChangeListener(slotName: string): ChildChangeListener;
|
|
172
169
|
/**
|
|
173
170
|
* Returns a singleton slotchange event listener that invalidates the component due to changes in the given slot
|
|
174
171
|
*
|
|
175
172
|
* @param slotName the name of the slot, where the slot element (whose slotchange event we're listening to) is
|
|
176
|
-
* @returns {SlotChangeListener}
|
|
177
173
|
* @private
|
|
178
174
|
*/
|
|
179
175
|
_getSlotChangeListener(slotName: string): SlotChangeListener;
|
|
@@ -257,7 +253,7 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
257
253
|
getFocusDomRefAsync(): Promise<HTMLElement | undefined>;
|
|
258
254
|
/**
|
|
259
255
|
* Set the focus to the element, returned by "getFocusDomRef()" (marked by "data-sap-focus-ref")
|
|
260
|
-
* @param
|
|
256
|
+
* @param focusOptions additional options for the focus
|
|
261
257
|
* @public
|
|
262
258
|
*/
|
|
263
259
|
focus(focusOptions?: FocusOptions): Promise<void>;
|
|
@@ -268,7 +264,7 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
268
264
|
* @param data - additional data for the event
|
|
269
265
|
* @param cancelable - true, if the user can call preventDefault on the event object
|
|
270
266
|
* @param bubbles - true, if the event bubbles
|
|
271
|
-
* @returns
|
|
267
|
+
* @returns false, if the event was cancelled (preventDefault called), true otherwise
|
|
272
268
|
*/
|
|
273
269
|
fireEvent<T>(name: string, data?: T, cancelable?: boolean, bubbles?: boolean): boolean;
|
|
274
270
|
_fireEvent<T>(name: string, data?: T, cancelable?: boolean, bubbles?: boolean): boolean;
|
|
@@ -277,19 +273,33 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
277
273
|
* Useful when there are transitive slots in nested component scenarios and you don't want to get a list of the slots, but rather of their content.
|
|
278
274
|
* @public
|
|
279
275
|
*/
|
|
280
|
-
getSlottedNodes<T = Node>(slotName: string): T
|
|
276
|
+
getSlottedNodes<T = Node>(slotName: string): Array<T>;
|
|
277
|
+
/**
|
|
278
|
+
* Attach a callback that will be executed whenever the component's state is finalized
|
|
279
|
+
*
|
|
280
|
+
* @param callback
|
|
281
|
+
* @public
|
|
282
|
+
*/
|
|
283
|
+
attachComponentStateFinalized(callback: () => void): void;
|
|
284
|
+
/**
|
|
285
|
+
* Detach the callback that is executed whenever the component's state is finalized
|
|
286
|
+
*
|
|
287
|
+
* @param callback
|
|
288
|
+
* @public
|
|
289
|
+
*/
|
|
290
|
+
detachComponentStateFinalized(callback: () => void): void;
|
|
281
291
|
/**
|
|
282
292
|
* Determines whether the component should be rendered in RTL mode or not.
|
|
283
293
|
* Returns: "rtl", "ltr" or undefined
|
|
284
294
|
*
|
|
285
295
|
* @public
|
|
286
|
-
* @
|
|
296
|
+
* @default undefined
|
|
287
297
|
*/
|
|
288
298
|
get effectiveDir(): string | undefined;
|
|
289
299
|
/**
|
|
290
300
|
* Used to duck-type UI5 elements without using instanceof
|
|
291
|
-
* @returns {boolean}
|
|
292
301
|
* @public
|
|
302
|
+
* @default true
|
|
293
303
|
*/
|
|
294
304
|
get isUI5Element(): boolean;
|
|
295
305
|
get classes(): ClassMap;
|
|
@@ -342,37 +352,31 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
342
352
|
*
|
|
343
353
|
* @public
|
|
344
354
|
*/
|
|
345
|
-
static getUniqueDependencies(this: typeof UI5Element):
|
|
355
|
+
static getUniqueDependencies(this: typeof UI5Element): Array<typeof UI5Element>;
|
|
346
356
|
/**
|
|
347
357
|
* Returns a promise that resolves whenever all dependencies for this UI5 Web Component have resolved
|
|
348
|
-
*
|
|
349
|
-
* @returns {Promise}
|
|
350
358
|
*/
|
|
351
359
|
static whenDependenciesDefined(): Promise<Array<typeof UI5Element>>;
|
|
352
360
|
/**
|
|
353
361
|
* Hook that will be called upon custom element definition
|
|
354
362
|
*
|
|
355
363
|
* @protected
|
|
356
|
-
* @returns {Promise<void>}
|
|
357
364
|
*/
|
|
358
365
|
static onDefine(): Promise<void>;
|
|
359
366
|
/**
|
|
360
367
|
* Registers a UI5 Web Component in the browser window object
|
|
361
368
|
* @public
|
|
362
|
-
* @returns {Promise<UI5Element>}
|
|
363
369
|
*/
|
|
364
370
|
static define(): Promise<typeof UI5Element>;
|
|
365
371
|
/**
|
|
366
372
|
* Returns an instance of UI5ElementMetadata.js representing this UI5 Web Component's full metadata (its and its parents')
|
|
367
373
|
* Note: not to be confused with the "get metadata()" method, which returns an object for this class's metadata only
|
|
368
374
|
* @public
|
|
369
|
-
* @returns {UI5ElementMetadata}
|
|
370
375
|
*/
|
|
371
376
|
static getMetadata(): UI5ElementMetadata;
|
|
372
377
|
}
|
|
373
378
|
/**
|
|
374
379
|
* Always use duck-typing to cover all runtimes on the page.
|
|
375
|
-
* @returns {boolean}
|
|
376
380
|
*/
|
|
377
381
|
declare const instanceOfUI5Element: (object: any) => object is UI5Element;
|
|
378
382
|
export default UI5Element;
|