@ui5/webcomponents-base 0.0.0-d9b978d1d → 0.0.0-da0d3eb88
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/CHANGELOG.md +653 -0
- package/README.md +0 -8
- package/config/wdio.conf.cjs +0 -8
- package/dist/.tsbuildinfo +1 -1
- package/dist/Boot.d.ts +3 -2
- package/dist/Boot.js +8 -6
- package/dist/Boot.js.map +1 -1
- package/dist/Device.d.ts +1 -2
- package/dist/Device.js +5 -12
- package/dist/Device.js.map +1 -1
- package/dist/IgnoreCustomElements.d.ts +3 -5
- package/dist/IgnoreCustomElements.js +3 -5
- package/dist/IgnoreCustomElements.js.map +1 -1
- package/dist/InitialConfiguration.d.ts +1 -2
- package/dist/InitialConfiguration.js +1 -5
- package/dist/InitialConfiguration.js.map +1 -1
- package/dist/Keys.d.ts +3 -1
- package/dist/Keys.js +5 -1
- package/dist/Keys.js.map +1 -1
- package/dist/ManagedStyles.js +24 -98
- package/dist/ManagedStyles.js.map +1 -1
- package/dist/MediaRange.d.ts +6 -12
- package/dist/MediaRange.js +21 -31
- package/dist/MediaRange.js.map +1 -1
- package/dist/UI5Element.d.ts +36 -54
- package/dist/UI5Element.js +152 -101
- package/dist/UI5Element.js.map +1 -1
- package/dist/UI5ElementMetadata.d.ts +12 -13
- package/dist/UI5ElementMetadata.js +24 -13
- package/dist/UI5ElementMetadata.js.map +1 -1
- package/dist/asset-registries/Icons.js +1 -1
- package/dist/asset-registries/Icons.js.map +1 -1
- package/dist/asset-registries/Illustrations.d.ts +1 -0
- package/dist/asset-registries/Illustrations.js +12 -19
- package/dist/asset-registries/Illustrations.js.map +1 -1
- package/dist/asset-registries/LocaleData.js +1 -1
- package/dist/asset-registries/LocaleData.js.map +1 -1
- package/dist/asset-registries/i18n.d.ts +2 -2
- package/dist/asset-registries/i18n.js +2 -2
- package/dist/asset-registries/i18n.js.map +1 -1
- package/dist/asset-registries/util/IconCollectionsByTheme.d.ts +1 -1
- package/dist/asset-registries/util/IconCollectionsByTheme.js +1 -1
- package/dist/asset-registries/util/IconCollectionsByTheme.js.map +1 -1
- package/dist/asset-registries/util/getIconCollectionByTheme.d.ts +3 -3
- package/dist/asset-registries/util/getIconCollectionByTheme.js +3 -3
- package/dist/asset-registries/util/getIconCollectionByTheme.js.map +1 -1
- package/dist/config/AnimationMode.js +2 -1
- package/dist/config/AnimationMode.js.map +1 -1
- package/dist/config/Icons.d.ts +7 -7
- package/dist/config/Icons.js +7 -7
- package/dist/config/Icons.js.map +1 -1
- package/dist/config/Language.d.ts +1 -1
- package/dist/config/Language.js +6 -3
- package/dist/config/Language.js.map +1 -1
- package/dist/config/Theme.d.ts +4 -3
- package/dist/config/Theme.js +13 -6
- package/dist/config/Theme.js.map +1 -1
- package/dist/config/ThemeRoot.d.ts +2 -4
- package/dist/config/ThemeRoot.js +2 -4
- package/dist/config/ThemeRoot.js.map +1 -1
- package/dist/config/Timezone.d.ts +1 -1
- package/dist/config/Timezone.js +1 -1
- package/dist/config/Timezone.js.map +1 -1
- package/dist/css/SystemCSSVars.css +0 -8
- package/dist/decorators/customElement.d.ts +3 -3
- package/dist/decorators/customElement.js +11 -6
- 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/decorators.d.ts +5 -0
- package/dist/decorators.js +6 -0
- package/dist/decorators.js.map +1 -0
- package/dist/delegate/ItemNavigation.d.ts +8 -8
- package/dist/delegate/ItemNavigation.js +9 -9
- 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/features/InputElementsFormSupport.d.ts +18 -0
- package/dist/features/InputElementsFormSupport.js +40 -0
- package/dist/features/InputElementsFormSupport.js.map +1 -0
- package/dist/features/OpenUI5Support.d.ts +0 -2
- package/dist/features/OpenUI5Support.js +6 -21
- package/dist/features/OpenUI5Support.js.map +1 -1
- package/dist/features/patchPatcher.d.ts +11 -0
- package/dist/features/patchPatcher.js +11 -0
- package/dist/features/patchPatcher.js.map +1 -0
- package/dist/features/patchPopup.d.ts +14 -0
- package/dist/features/patchPopup.js +50 -0
- package/dist/features/patchPopup.js.map +1 -0
- package/dist/generated/AssetParameters.js +1 -1
- package/dist/generated/AssetParameters.js.map +1 -1
- package/dist/generated/VersionInfo.js +5 -5
- package/dist/generated/VersionInfo.js.map +1 -1
- package/dist/generated/css/SystemCSSVars.css.js +1 -1
- package/dist/generated/css/SystemCSSVars.css.js.map +1 -1
- package/dist/i18nBundle.d.ts +1 -3
- package/dist/i18nBundle.js +1 -4
- package/dist/i18nBundle.js.map +1 -1
- package/dist/locale/applyDirection.d.ts +3 -2
- package/dist/locale/applyDirection.js +3 -2
- package/dist/locale/applyDirection.js.map +1 -1
- package/dist/locale/getEffectiveDir.d.ts +1 -1
- package/dist/locale/getEffectiveDir.js +3 -19
- package/dist/locale/getEffectiveDir.js.map +1 -1
- package/dist/renderer/LitRenderer.js +2 -8
- package/dist/renderer/LitRenderer.js.map +1 -1
- package/dist/renderer/directives/style-map.d.ts +13 -0
- package/dist/renderer/directives/style-map.js +59 -59
- package/dist/renderer/directives/style-map.js.map +1 -0
- package/dist/renderer/executeTemplate.d.ts +8 -0
- package/dist/renderer/executeTemplate.js +1 -0
- package/dist/renderer/executeTemplate.js.map +1 -1
- 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 +0 -0
- package/dist/theming/getConstructableStyle.d.ts +1 -1
- package/dist/theming/getConstructableStyle.js +3 -3
- package/dist/theming/getConstructableStyle.js.map +1 -1
- package/dist/theming/getEffectiveStyle.d.ts +1 -1
- package/dist/theming/getEffectiveStyle.js +5 -12
- package/dist/theming/getEffectiveStyle.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/AriaHasPopup.d.ts +32 -0
- package/dist/types/AriaHasPopup.js +34 -0
- package/dist/types/AriaHasPopup.js.map +1 -0
- package/dist/types/AriaLandmarkRole.d.ts +79 -0
- package/dist/types/AriaLandmarkRole.js +81 -0
- package/dist/types/AriaLandmarkRole.js.map +1 -0
- package/dist/types/AriaRole.d.ts +27 -0
- package/dist/types/AriaRole.js +29 -0
- package/dist/types/AriaRole.js.map +1 -0
- 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 +0 -4
- package/dist/types/CSSSize.js +0 -4
- package/dist/types/CSSSize.js.map +1 -1
- 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 +1 -5
- package/dist/types/DOMReference.js +1 -5
- 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 +0 -6
- package/dist/types/InvisibleMessageMode.js +0 -6
- 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/MovePlacement.d.ts +20 -0
- package/dist/types/MovePlacement.js +22 -0
- package/dist/types/MovePlacement.js.map +1 -0
- 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/Orientation.d.ts +16 -0
- package/dist/types/Orientation.js +18 -0
- package/dist/types/Orientation.js.map +1 -0
- package/dist/types/ValueState.d.ts +3 -17
- package/dist/types/ValueState.js +3 -17
- package/dist/types/ValueState.js.map +1 -1
- package/dist/types.d.ts +24 -1
- package/dist/types.js.map +1 -1
- package/dist/updateShadowRoot.d.ts +1 -2
- package/dist/updateShadowRoot.js +5 -29
- package/dist/updateShadowRoot.js.map +1 -1
- package/dist/util/InvisibleMessage.js +2 -2
- package/dist/util/InvisibleMessage.js.map +1 -1
- package/dist/util/PopupUtils.d.ts +1 -3
- package/dist/util/PopupUtils.js +1 -15
- package/dist/util/PopupUtils.js.map +1 -1
- package/dist/util/clamp.js +2 -1
- package/dist/util/clamp.js.map +1 -1
- package/dist/util/createLinkInHead.d.ts +1 -1
- package/dist/util/createLinkInHead.js +1 -1
- package/dist/util/createLinkInHead.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/dragAndDrop/DragRegistry.d.ts +12 -0
- package/dist/util/dragAndDrop/DragRegistry.js +68 -0
- package/dist/util/dragAndDrop/DragRegistry.js.map +1 -0
- package/dist/util/dragAndDrop/findClosestPosition.d.ts +7 -0
- package/dist/util/dragAndDrop/findClosestPosition.js +59 -0
- package/dist/util/dragAndDrop/findClosestPosition.js.map +1 -0
- package/dist/util/dragAndDrop/longDragOverHandler.d.ts +2 -0
- package/dist/util/dragAndDrop/longDragOverHandler.js +25 -0
- package/dist/util/dragAndDrop/longDragOverHandler.js.map +1 -0
- package/dist/util/getClassCopy.d.ts +17 -12
- package/dist/util/getDesigntimePropertyAsArray.d.ts +2 -2
- package/dist/util/getDesigntimePropertyAsArray.js +2 -1
- package/dist/util/getDesigntimePropertyAsArray.js.map +1 -1
- package/index.js +1 -17
- package/package-scripts.cjs +18 -14
- package/package.json +20 -8
- package/src/css/SystemCSSVars.css +0 -8
- package/tsconfig.json +3 -0
- package/.eslintignore +0 -16
- package/.eslintrc.cjs +0 -3
- package/bundle.esm.js +0 -67
- package/dist/CSP.d.ts +0 -30
- package/dist/CSP.js +0 -51
- package/dist/CSP.js.map +0 -1
- package/dist/StaticArea.js +0 -7
- package/dist/StaticArea.js.map +0 -1
- package/dist/StaticAreaItem.d.ts +0 -37
- package/dist/StaticAreaItem.js +0 -102
- package/dist/StaticAreaItem.js.map +0 -1
- package/dist/api.json +0 -1
- package/dist/config/RTL.d.ts +0 -7
- package/dist/config/RTL.js +0 -37
- package/dist/config/RTL.js.map +0 -1
- package/dist/theming/getEffectiveLinksHrefs.d.ts +0 -3
- package/dist/theming/getEffectiveLinksHrefs.js +0 -17
- package/dist/theming/getEffectiveLinksHrefs.js.map +0 -1
- package/dist/theming/preloadLinks.d.ts +0 -3
- package/dist/theming/preloadLinks.js +0 -19
- package/dist/theming/preloadLinks.js.map +0 -1
- package/dist/util/createStyleInHead.d.ts +0 -8
- package/dist/util/createStyleInHead.js +0 -18
- package/dist/util/createStyleInHead.js.map +0 -1
- package/lib/generate-asset-parameters/index.js +0 -27
- package/lib/generate-styles/index.js +0 -31
- package/lib/generate-version-info/index.js +0 -32
- package/src/renderer/directives/style-map.js +0 -72
- package/used-modules.txt +0 -10
package/dist/ManagedStyles.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
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";
|
|
5
1
|
import { getCurrentRuntimeIndex, compareRuntimes } from "./Runtimes.js";
|
|
2
|
+
const isSSR = typeof document === "undefined";
|
|
6
3
|
const getStyleId = (name, value) => {
|
|
7
4
|
return value ? `${name}|${value}` : name;
|
|
8
5
|
};
|
|
@@ -15,114 +12,43 @@ const shouldUpdate = (runtimeIndex) => {
|
|
|
15
12
|
const createStyle = (data, name, value = "", theme) => {
|
|
16
13
|
const content = typeof data === "string" ? data : data.content;
|
|
17
14
|
const currentRuntimeIndex = getCurrentRuntimeIndex();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
createLinkInHead(href, attributes);
|
|
27
|
-
}
|
|
28
|
-
else if (document.adoptedStyleSheets && !isSafari()) {
|
|
29
|
-
const stylesheet = new CSSStyleSheet();
|
|
30
|
-
stylesheet.replaceSync(content);
|
|
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
|
-
}
|
|
36
|
-
document.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
const attributes = {};
|
|
40
|
-
attributes[name] = value;
|
|
41
|
-
if (theme) {
|
|
42
|
-
attributes["data-ui5-runtime-index"] = currentRuntimeIndex;
|
|
43
|
-
attributes["data-ui5-theme"] = theme;
|
|
44
|
-
}
|
|
45
|
-
createStyleInHead(content, attributes);
|
|
46
|
-
}
|
|
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];
|
|
47
23
|
};
|
|
48
24
|
const updateStyle = (data, name, value = "", theme) => {
|
|
49
25
|
const content = typeof data === "string" ? data : data.content;
|
|
50
26
|
const currentRuntimeIndex = getCurrentRuntimeIndex();
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
}
|
|
27
|
+
const stylesheet = document.adoptedStyleSheets.find(sh => sh._ui5StyleId === getStyleId(name, value));
|
|
28
|
+
if (!stylesheet) {
|
|
29
|
+
return;
|
|
66
30
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (!stylesheet) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (!theme) {
|
|
73
|
-
stylesheet.replaceSync(content || "");
|
|
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
|
-
}
|
|
31
|
+
if (!theme) {
|
|
32
|
+
stylesheet.replaceSync(content || "");
|
|
84
33
|
}
|
|
85
34
|
else {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
}
|
|
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;
|
|
101
41
|
}
|
|
102
42
|
}
|
|
103
43
|
};
|
|
104
44
|
const hasStyle = (name, value = "") => {
|
|
105
|
-
if (
|
|
106
|
-
return
|
|
107
|
-
}
|
|
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));
|
|
45
|
+
if (isSSR) {
|
|
46
|
+
return true;
|
|
111
47
|
}
|
|
112
|
-
return !!
|
|
48
|
+
return !!document.adoptedStyleSheets.find(sh => sh._ui5StyleId === getStyleId(name, value));
|
|
113
49
|
};
|
|
114
50
|
const removeStyle = (name, value = "") => {
|
|
115
|
-
|
|
116
|
-
const linkElement = document.querySelector(`head>link[${name}="${value}"]`);
|
|
117
|
-
linkElement?.parentElement?.removeChild(linkElement);
|
|
118
|
-
}
|
|
119
|
-
else if (document.adoptedStyleSheets && !isSafari()) {
|
|
120
|
-
document.adoptedStyleSheets = document.adoptedStyleSheets.filter(sh => sh._ui5StyleId !== getStyleId(name, value));
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
const styleElement = document.querySelector(`head > style[${name}="${value}"]`);
|
|
124
|
-
styleElement?.parentElement?.removeChild(styleElement);
|
|
125
|
-
}
|
|
51
|
+
document.adoptedStyleSheets = document.adoptedStyleSheets.filter(sh => sh._ui5StyleId !== getStyleId(name, value));
|
|
126
52
|
};
|
|
127
53
|
const createOrUpdateStyle = (data, name, value = "", theme) => {
|
|
128
54
|
if (hasStyle(name, value)) {
|
|
@@ -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,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAExE,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,M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AO,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"]}
|
|
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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,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 { 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};\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 {
|
|
@@ -11,23 +9,19 @@ declare enum RANGESETS {
|
|
|
11
9
|
* A 4-step range set (S-M-L-XL).
|
|
12
10
|
*
|
|
13
11
|
* The ranges of this set are:
|
|
14
|
-
* <ul>
|
|
15
|
-
* <li><code>"S"</code>: For screens smaller than 600 pixels.</li>
|
|
16
|
-
* <li><code>"M"</code>: For screens greater than or equal to 600 pixels and smaller than 1024 pixels.</li>
|
|
17
|
-
* <li><code>"L"</code>: For screens greater than or equal to 1024 pixels and smaller than 1440 pixels.</li>
|
|
18
|
-
* <li><code>"XL"</code>: For screens greater than or equal to 1440 pixels.</li>
|
|
19
|
-
* </ul>
|
|
20
12
|
*
|
|
21
|
-
*
|
|
13
|
+
* - `"S"`: For screens smaller than 600 pixels.
|
|
14
|
+
* - `"M"`: For screens greater than or equal to 600 pixels and smaller than 1024 pixels.
|
|
15
|
+
* - `"L"`: For screens greater than or equal to 1024 pixels and smaller than 1440 pixels.
|
|
16
|
+
* - `"XL"`: For screens greater than or equal to 1440 pixels.
|
|
17
|
+
*
|
|
18
|
+
*
|
|
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;
|
|
@@ -17,14 +15,13 @@ var RANGESETS;
|
|
|
17
15
|
* A 4-step range set (S-M-L-XL).
|
|
18
16
|
*
|
|
19
17
|
* The ranges of this set are:
|
|
20
|
-
* <ul>
|
|
21
|
-
* <li><code>"S"</code>: For screens smaller than 600 pixels.</li>
|
|
22
|
-
* <li><code>"M"</code>: For screens greater than or equal to 600 pixels and smaller than 1024 pixels.</li>
|
|
23
|
-
* <li><code>"L"</code>: For screens greater than or equal to 1024 pixels and smaller than 1440 pixels.</li>
|
|
24
|
-
* <li><code>"XL"</code>: For screens greater than or equal to 1440 pixels.</li>
|
|
25
|
-
* </ul>
|
|
26
18
|
*
|
|
27
|
-
*
|
|
19
|
+
* - `"S"`: For screens smaller than 600 pixels.
|
|
20
|
+
* - `"M"`: For screens greater than or equal to 600 pixels and smaller than 1024 pixels.
|
|
21
|
+
* - `"L"`: For screens greater than or equal to 1024 pixels and smaller than 1440 pixels.
|
|
22
|
+
* - `"XL"`: For screens greater than or equal to 1440 pixels.
|
|
23
|
+
*
|
|
24
|
+
*
|
|
28
25
|
* @public
|
|
29
26
|
*/
|
|
30
27
|
RANGESETS["RANGE_4STEPS"] = "4Step";
|
|
@@ -32,23 +29,22 @@ var RANGESETS;
|
|
|
32
29
|
/**
|
|
33
30
|
* Initializes a screen width media query range set.
|
|
34
31
|
*
|
|
35
|
-
* This initialization step makes the range set ready to be used for one of the other functions in namespace
|
|
32
|
+
* This initialization step makes the range set ready to be used for one of the other functions in namespace `MediaRange`.
|
|
36
33
|
*
|
|
37
34
|
* A range set can be defined as shown in the following example:
|
|
38
|
-
*
|
|
35
|
+
* ```
|
|
39
36
|
* MediaRange.initRangeSet("MyRangeSet", [200, 400], ["Small", "Medium", "Large"]);
|
|
40
|
-
*
|
|
37
|
+
* ```
|
|
41
38
|
* This example defines the following named ranges:
|
|
42
|
-
* <ul>
|
|
43
|
-
* <li><code>"Small"</code>: For screens smaller than 200 pixels.</li>
|
|
44
|
-
* <li><code>"Medium"</code>: For screens greater than or equal to 200 pixels and smaller than 400 pixels.</li>
|
|
45
|
-
* <li><code>"Large"</code>: For screens greater than or equal to 400 pixels.</li>
|
|
46
|
-
* </ul>
|
|
47
39
|
*
|
|
48
|
-
*
|
|
40
|
+
* - `"Small"`: For screens smaller than 200 pixels.
|
|
41
|
+
* - `"Medium"`: For screens greater than or equal to 200 pixels and smaller than 400 pixels.
|
|
42
|
+
* - `"Large"`: For screens greater than or equal to 400 pixels.
|
|
43
|
+
*
|
|
44
|
+
*
|
|
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);
|
|
@@ -56,16 +52,13 @@ const initRangeSet = (name, range) => {
|
|
|
56
52
|
/**
|
|
57
53
|
* Returns information about the current active range of the range set with the given name.
|
|
58
54
|
*
|
|
59
|
-
* If the optional parameter
|
|
55
|
+
* If the optional parameter `width` 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
|
|
64
|
-
* If
|
|
65
|
-
* @returns
|
|
66
|
-
*
|
|
67
|
-
* @name MediaRange.getCurrentRange
|
|
68
|
-
* @function
|
|
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;
|
|
60
|
+
* If `width` is not provided, the window size will be used.
|
|
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,IA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,QAAQ,EAAE;QACd,QAAQ,GAAG,WAAW,CAAC,GAAG,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 *\n\t * - `\"S\"`: For screens smaller than 600 pixels.\n\t * - `\"M\"`: For screens greater than or equal to 600 pixels and smaller than 1024 pixels.\n\t * - `\"L\"`: For screens greater than or equal to 1024 pixels and smaller than 1440 pixels.\n\t * - `\"XL\"`: For screens greater than or equal to 1440 pixels.\n\t *\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 `MediaRange`.\n *\n * A range set can be defined as shown in the following example:\n * ```\n * MediaRange.initRangeSet(\"MyRangeSet\", [200, 400], [\"Small\", \"Medium\", \"Large\"]);\n * ```\n * This example defines the following named ranges:\n *\n * - `\"Small\"`: For screens smaller than 200 pixels.\n * - `\"Medium\"`: For screens greater than or equal to 200 pixels and smaller than 400 pixels.\n * - `\"Large\"`: For screens greater than or equal to 400 pixels.\n *\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 `width` 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 `width` 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/UI5Element.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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
|
-
import StaticAreaItem from "./StaticAreaItem.js";
|
|
4
4
|
import type { TemplateFunction, TemplateFunctionResult } from "./renderer/executeTemplate.js";
|
|
5
|
-
import type { PromiseResolve, ComponentStylesData, ClassMap } from "./types.js";
|
|
6
|
-
type Renderer = (templateResult: TemplateFunctionResult, container: HTMLElement | DocumentFragment,
|
|
5
|
+
import type { AccessibilityInfo, PromiseResolve, ComponentStylesData, ClassMap } from "./types.js";
|
|
6
|
+
type Renderer = (templateResult: TemplateFunctionResult, container: HTMLElement | DocumentFragment, options: RendererOptions) => void;
|
|
7
7
|
type RendererOptions = {
|
|
8
8
|
/**
|
|
9
9
|
* An object to use as the `this` value for event listeners. It's often
|
|
@@ -26,12 +26,9 @@ type InvalidationInfo = ChangeInfo & {
|
|
|
26
26
|
type ChildChangeListener = (param: InvalidationInfo) => void;
|
|
27
27
|
type SlotChangeListener = (this: HTMLSlotElement, ev: Event) => void;
|
|
28
28
|
/**
|
|
29
|
+
* @class
|
|
29
30
|
* Base class for all UI5 Web Components
|
|
30
31
|
*
|
|
31
|
-
* @class
|
|
32
|
-
* @constructor
|
|
33
|
-
* @author SAP SE
|
|
34
|
-
* @alias sap.ui.webc.base.UI5Element
|
|
35
32
|
* @extends HTMLElement
|
|
36
33
|
* @public
|
|
37
34
|
*/
|
|
@@ -44,22 +41,18 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
44
41
|
_inDOM: boolean;
|
|
45
42
|
_fullyConnected: boolean;
|
|
46
43
|
_childChangeListeners: Map<string, ChildChangeListener>;
|
|
44
|
+
_slotsAssignedNodes: WeakMap<HTMLSlotElement, Array<SlotValue>>;
|
|
47
45
|
_slotChangeListeners: Map<string, SlotChangeListener>;
|
|
48
46
|
_domRefReadyPromise: Promise<void> & {
|
|
49
47
|
_deferredResolve?: PromiseResolve;
|
|
50
48
|
};
|
|
51
49
|
_doNotSyncAttributes: Set<string>;
|
|
52
50
|
_state: State;
|
|
51
|
+
_internals?: ElementInternals;
|
|
53
52
|
_getRealDomRef?: () => HTMLElement;
|
|
54
|
-
staticAreaItem?: StaticAreaItem;
|
|
55
53
|
static template?: TemplateFunction;
|
|
56
|
-
static staticAreaTemplate?: TemplateFunction;
|
|
57
54
|
static _metadata: UI5ElementMetadata;
|
|
58
|
-
|
|
59
|
-
* @deprecated
|
|
60
|
-
*/
|
|
61
|
-
static render: Renderer;
|
|
62
|
-
static renderer?: Renderer;
|
|
55
|
+
static renderer: Renderer;
|
|
63
56
|
constructor();
|
|
64
57
|
/**
|
|
65
58
|
* Returns a unique ID for this UI5 Element
|
|
@@ -69,7 +62,6 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
69
62
|
*/
|
|
70
63
|
get _id(): string;
|
|
71
64
|
render(): object;
|
|
72
|
-
renderStatic(): object;
|
|
73
65
|
/**
|
|
74
66
|
* Do not call this method from derivatives of UI5Element, use "onEnterDOM" only
|
|
75
67
|
* @private
|
|
@@ -125,22 +117,22 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
125
117
|
/**
|
|
126
118
|
* Attach a callback that will be executed whenever the component is invalidated
|
|
127
119
|
*
|
|
128
|
-
* @param
|
|
120
|
+
* @param callback
|
|
129
121
|
* @public
|
|
130
122
|
*/
|
|
131
123
|
attachInvalidate(callback: (param: InvalidationInfo) => void): void;
|
|
132
124
|
/**
|
|
133
125
|
* Detach the callback that is executed whenever the component is invalidated
|
|
134
126
|
*
|
|
135
|
-
* @param
|
|
127
|
+
* @param callback
|
|
136
128
|
* @public
|
|
137
129
|
*/
|
|
138
130
|
detachInvalidate(callback: (param: InvalidationInfo) => void): void;
|
|
139
131
|
/**
|
|
140
132
|
* Callback that is executed whenever a monitored child changes its state
|
|
141
133
|
*
|
|
142
|
-
* @param
|
|
143
|
-
* @param
|
|
134
|
+
* @param slotName the slot in which a child was invalidated
|
|
135
|
+
* @param childChangeInfo the changeInfo object for the child in the given slot
|
|
144
136
|
* @private
|
|
145
137
|
*/
|
|
146
138
|
_onChildChange(slotName: string, childChangeInfo: ChangeInfo): void;
|
|
@@ -149,6 +141,8 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
149
141
|
* @private
|
|
150
142
|
*/
|
|
151
143
|
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
144
|
+
formAssociatedCallback(): void;
|
|
145
|
+
static get formAssociated(): boolean;
|
|
152
146
|
/**
|
|
153
147
|
* @private
|
|
154
148
|
*/
|
|
@@ -165,22 +159,20 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
165
159
|
* Returns a singleton event listener for the "change" event of a child in a given slot
|
|
166
160
|
*
|
|
167
161
|
* @param slotName the name of the slot, where the child is
|
|
168
|
-
* @returns {ChildChangeListener}
|
|
169
162
|
* @private
|
|
170
163
|
*/
|
|
171
|
-
_getChildChangeListener(slotName: string): ChildChangeListener
|
|
164
|
+
_getChildChangeListener(slotName: string): ChildChangeListener;
|
|
172
165
|
/**
|
|
173
166
|
* Returns a singleton slotchange event listener that invalidates the component due to changes in the given slot
|
|
174
167
|
*
|
|
175
168
|
* @param slotName the name of the slot, where the slot element (whose slotchange event we're listening to) is
|
|
176
|
-
* @returns {SlotChangeListener}
|
|
177
169
|
* @private
|
|
178
170
|
*/
|
|
179
171
|
_getSlotChangeListener(slotName: string): SlotChangeListener;
|
|
180
172
|
/**
|
|
181
173
|
* @private
|
|
182
174
|
*/
|
|
183
|
-
_attachSlotChange(
|
|
175
|
+
_attachSlotChange(slot: HTMLSlotElement, slotName: string, invalidateOnChildChange: boolean): void;
|
|
184
176
|
/**
|
|
185
177
|
* @private
|
|
186
178
|
*/
|
|
@@ -207,9 +199,9 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
207
199
|
* 1) children: immediate children (HTML elements or text nodes) were added, removed or reordered in the slot
|
|
208
200
|
* 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"
|
|
209
201
|
* 3) slotchange: a slot element, slotted inside that slot had its "slotchange" event listener called. This practically means that transitively slotted children changed.
|
|
210
|
-
*
|
|
202
|
+
* Can only trigger if the child of a slot is a slot element itself.
|
|
211
203
|
* 4) childchange: indicates that a UI5Element child in that slot was invalidated and in turn invalidated the component.
|
|
212
|
-
*
|
|
204
|
+
* Can only trigger for slots with "invalidateOnChildChange" metadata descriptor
|
|
213
205
|
*
|
|
214
206
|
* - newValue: the new value of the property (for type="property" only)
|
|
215
207
|
*
|
|
@@ -257,7 +249,7 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
257
249
|
getFocusDomRefAsync(): Promise<HTMLElement | undefined>;
|
|
258
250
|
/**
|
|
259
251
|
* Set the focus to the element, returned by "getFocusDomRef()" (marked by "data-sap-focus-ref")
|
|
260
|
-
* @param
|
|
252
|
+
* @param focusOptions additional options for the focus
|
|
261
253
|
* @public
|
|
262
254
|
*/
|
|
263
255
|
focus(focusOptions?: FocusOptions): Promise<void>;
|
|
@@ -268,7 +260,7 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
268
260
|
* @param data - additional data for the event
|
|
269
261
|
* @param cancelable - true, if the user can call preventDefault on the event object
|
|
270
262
|
* @param bubbles - true, if the event bubbles
|
|
271
|
-
* @returns
|
|
263
|
+
* @returns false, if the event was cancelled (preventDefault called), true otherwise
|
|
272
264
|
*/
|
|
273
265
|
fireEvent<T>(name: string, data?: T, cancelable?: boolean, bubbles?: boolean): boolean;
|
|
274
266
|
_fireEvent<T>(name: string, data?: T, cancelable?: boolean, bubbles?: boolean): boolean;
|
|
@@ -277,18 +269,18 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
277
269
|
* 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
270
|
* @public
|
|
279
271
|
*/
|
|
280
|
-
getSlottedNodes<T = Node>(slotName: string): T
|
|
272
|
+
getSlottedNodes<T = Node>(slotName: string): Array<T>;
|
|
281
273
|
/**
|
|
282
274
|
* Attach a callback that will be executed whenever the component's state is finalized
|
|
283
275
|
*
|
|
284
|
-
* @param
|
|
276
|
+
* @param callback
|
|
285
277
|
* @public
|
|
286
278
|
*/
|
|
287
279
|
attachComponentStateFinalized(callback: () => void): void;
|
|
288
280
|
/**
|
|
289
281
|
* Detach the callback that is executed whenever the component's state is finalized
|
|
290
282
|
*
|
|
291
|
-
* @param
|
|
283
|
+
* @param callback
|
|
292
284
|
* @public
|
|
293
285
|
*/
|
|
294
286
|
detachComponentStateFinalized(callback: () => void): void;
|
|
@@ -297,33 +289,30 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
297
289
|
* Returns: "rtl", "ltr" or undefined
|
|
298
290
|
*
|
|
299
291
|
* @public
|
|
300
|
-
* @
|
|
292
|
+
* @default undefined
|
|
301
293
|
*/
|
|
302
294
|
get effectiveDir(): string | undefined;
|
|
303
295
|
/**
|
|
304
296
|
* Used to duck-type UI5 elements without using instanceof
|
|
305
|
-
* @returns {boolean}
|
|
306
297
|
* @public
|
|
298
|
+
* @default true
|
|
307
299
|
*/
|
|
308
300
|
get isUI5Element(): boolean;
|
|
309
301
|
get classes(): ClassMap;
|
|
310
302
|
/**
|
|
311
|
-
*
|
|
303
|
+
* Returns the component accessibility info.
|
|
312
304
|
* @private
|
|
313
305
|
*/
|
|
314
|
-
|
|
306
|
+
get accessibilityInfo(): AccessibilityInfo;
|
|
315
307
|
/**
|
|
308
|
+
* Do not override this method in derivatives of UI5Element, use metadata properties instead
|
|
316
309
|
* @private
|
|
317
310
|
*/
|
|
318
|
-
static
|
|
311
|
+
static get observedAttributes(): string[];
|
|
319
312
|
/**
|
|
320
313
|
* @private
|
|
321
314
|
*/
|
|
322
|
-
static
|
|
323
|
-
/**
|
|
324
|
-
* @public
|
|
325
|
-
*/
|
|
326
|
-
getStaticAreaItemDomRef(): Promise<ShadowRoot | null>;
|
|
315
|
+
static _needsShadowDOM(): boolean;
|
|
327
316
|
/**
|
|
328
317
|
* @private
|
|
329
318
|
*/
|
|
@@ -337,12 +326,7 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
337
326
|
* Returns the CSS for this UI5 Web Component Class
|
|
338
327
|
* @protected
|
|
339
328
|
*/
|
|
340
|
-
static
|
|
341
|
-
/**
|
|
342
|
-
* Returns the Static Area CSS for this UI5 Web Component Class
|
|
343
|
-
* @protected
|
|
344
|
-
*/
|
|
345
|
-
static get staticAreaStyles(): ComponentStylesData;
|
|
329
|
+
static styles: ComponentStylesData;
|
|
346
330
|
/**
|
|
347
331
|
* Returns an array with the dependencies for this UI5 Web Component, which could be:
|
|
348
332
|
* - composed components (used in its shadow root or static area item)
|
|
@@ -356,39 +340,37 @@ declare abstract class UI5Element extends HTMLElement {
|
|
|
356
340
|
*
|
|
357
341
|
* @public
|
|
358
342
|
*/
|
|
359
|
-
static getUniqueDependencies(this: typeof UI5Element):
|
|
343
|
+
static getUniqueDependencies(this: typeof UI5Element): Array<typeof UI5Element>;
|
|
360
344
|
/**
|
|
361
345
|
* Returns a promise that resolves whenever all dependencies for this UI5 Web Component have resolved
|
|
362
|
-
*
|
|
363
|
-
* @returns {Promise}
|
|
364
346
|
*/
|
|
365
347
|
static whenDependenciesDefined(): Promise<Array<typeof UI5Element>>;
|
|
366
348
|
/**
|
|
367
349
|
* Hook that will be called upon custom element definition
|
|
368
350
|
*
|
|
369
351
|
* @protected
|
|
370
|
-
* @returns {Promise<void>}
|
|
371
352
|
*/
|
|
372
353
|
static onDefine(): Promise<void>;
|
|
373
354
|
/**
|
|
374
355
|
* Registers a UI5 Web Component in the browser window object
|
|
375
356
|
* @public
|
|
376
|
-
* @returns {Promise<UI5Element>}
|
|
377
357
|
*/
|
|
378
358
|
static define(): Promise<typeof UI5Element>;
|
|
379
359
|
/**
|
|
380
360
|
* Returns an instance of UI5ElementMetadata.js representing this UI5 Web Component's full metadata (its and its parents')
|
|
381
361
|
* Note: not to be confused with the "get metadata()" method, which returns an object for this class's metadata only
|
|
382
362
|
* @public
|
|
383
|
-
* @returns {UI5ElementMetadata}
|
|
384
363
|
*/
|
|
385
364
|
static getMetadata(): UI5ElementMetadata;
|
|
365
|
+
get validity(): ValidityState | undefined;
|
|
366
|
+
get validationMessage(): string | undefined;
|
|
367
|
+
checkValidity(): boolean | undefined;
|
|
368
|
+
reportValidity(): boolean | undefined;
|
|
386
369
|
}
|
|
387
370
|
/**
|
|
388
371
|
* Always use duck-typing to cover all runtimes on the page.
|
|
389
|
-
* @returns {boolean}
|
|
390
372
|
*/
|
|
391
373
|
declare const instanceOfUI5Element: (object: any) => object is UI5Element;
|
|
392
374
|
export default UI5Element;
|
|
393
|
-
export { instanceOfUI5Element };
|
|
375
|
+
export { instanceOfUI5Element, };
|
|
394
376
|
export type { ChangeInfo, Renderer, RendererOptions, };
|