@ui5/webcomponents-base 1.11.0-rc.0 → 1.11.0-rc.2
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 +22 -0
- package/dist/Boot.js +4 -0
- package/dist/Boot.js.map +1 -1
- package/dist/Device.js +109 -34
- package/dist/Device.js.map +1 -1
- package/dist/InitialConfiguration.js +1 -1
- package/dist/InitialConfiguration.js.map +1 -1
- package/dist/asset-registries/Icons.d.ts +1 -1
- package/dist/asset-registries/Icons.js +21 -21
- package/dist/asset-registries/Icons.js.map +1 -1
- package/dist/assets/bundle.esm.2d0cb31f.js +56 -0
- package/dist/assets/test/pages/{i18n.html.a765def3.js → i18n.html.cd6e3cfc.js} +1 -1
- package/dist/assets/test/pages/{i18n_texts.html.9a235f8f.js → i18n_texts.html.7beb72ee.js} +1 -1
- package/dist/assets-meta/IconCollectionsAlias.d.ts +24 -10
- package/dist/assets-meta/IconCollectionsAlias.js +29 -9
- package/dist/assets-meta/IconCollectionsAlias.js.map +1 -1
- package/dist/config/Icons.d.ts +42 -18
- package/dist/config/Icons.js +74 -25
- package/dist/config/Icons.js.map +1 -1
- package/dist/config/RTL.js +3 -0
- package/dist/config/RTL.js.map +1 -1
- package/dist/delegate/ResizeHandler.d.ts +2 -1
- package/dist/delegate/ResizeHandler.js +3 -1
- package/dist/delegate/ResizeHandler.js.map +1 -1
- package/dist/features/F6Navigation.d.ts +3 -0
- package/dist/features/F6Navigation.js +77 -38
- package/dist/features/F6Navigation.js.map +1 -1
- package/dist/generated/VersionInfo.js +3 -3
- package/dist/getSharedResource.js +9 -1
- package/dist/getSharedResource.js.map +1 -1
- package/dist/test/pages/AllTestElements.html +1 -1
- package/dist/test/pages/Configuration.html +1 -1
- package/dist/test/pages/ConfigurationScript.html +1 -1
- package/dist/test/pages/WithComplexTemplate.html +1 -1
- package/dist/test/pages/i18n.html +2 -2
- package/dist/test/pages/i18n_texts.html +2 -2
- package/dist/theming/CustomStyle.js +7 -5
- package/dist/theming/CustomStyle.js.map +1 -1
- package/dist/util/AriaLabelHelper.d.ts +10 -1
- package/dist/util/AriaLabelHelper.js +135 -8
- package/dist/util/AriaLabelHelper.js.map +1 -1
- package/package-scripts.js +6 -2
- package/package.json +3 -3
- package/src/Boot.ts +4 -0
- package/src/Device.ts +113 -34
- package/src/InitialConfiguration.ts +1 -1
- package/src/asset-registries/Icons.ts +26 -27
- package/src/assets-meta/IconCollectionsAlias.ts +32 -9
- package/src/config/Icons.ts +85 -25
- package/src/config/RTL.ts +4 -0
- package/src/delegate/ResizeHandler.ts +7 -2
- package/src/features/F6Navigation.ts +98 -44
- package/src/getSharedResource.ts +10 -1
- package/src/theming/CustomStyle.ts +7 -5
- package/src/util/AriaLabelHelper.ts +167 -12
- package/dist/assets/bundle.esm.38c84565.js +0 -56
package/src/Device.ts
CHANGED
|
@@ -1,30 +1,98 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
const isSSR = typeof document === "undefined";
|
|
2
|
+
|
|
3
|
+
const internals = {
|
|
4
|
+
get userAgent() {
|
|
5
|
+
if (isSSR) {
|
|
6
|
+
return "";
|
|
7
|
+
}
|
|
8
|
+
return navigator.userAgent;
|
|
9
|
+
},
|
|
10
|
+
get touch() {
|
|
11
|
+
if (isSSR) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return "ontouchstart" in window || navigator.maxTouchPoints > 0;
|
|
15
|
+
},
|
|
16
|
+
get ie() {
|
|
17
|
+
if (isSSR) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return /(msie|trident)/i.test(internals.userAgent);
|
|
21
|
+
},
|
|
22
|
+
get chrome() {
|
|
23
|
+
if (isSSR) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return !internals.ie && /(Chrome|CriOS)/.test(internals.userAgent);
|
|
27
|
+
},
|
|
28
|
+
get firefox() {
|
|
29
|
+
if (isSSR) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return /Firefox/.test(internals.userAgent);
|
|
33
|
+
},
|
|
34
|
+
get safari() {
|
|
35
|
+
if (isSSR) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return !internals.ie && !internals.chrome && /(Version|PhantomJS)\/(\d+\.\d+).*Safari/.test(internals.userAgent);
|
|
39
|
+
},
|
|
40
|
+
get webkit() {
|
|
41
|
+
if (isSSR) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return !internals.ie && /webkit/.test(internals.userAgent);
|
|
45
|
+
},
|
|
46
|
+
get windows() {
|
|
47
|
+
if (isSSR) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
return navigator.platform.indexOf("Win") !== -1;
|
|
51
|
+
},
|
|
52
|
+
get iOS() {
|
|
53
|
+
if (isSSR) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return !!(navigator.platform.match(/iPhone|iPad|iPod/)) || !!(internals.userAgent.match(/Mac/) && "ontouchend" in document);
|
|
57
|
+
},
|
|
58
|
+
get android() {
|
|
59
|
+
if (isSSR) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return !internals.windows && /Android/.test(internals.userAgent);
|
|
63
|
+
},
|
|
64
|
+
get androidPhone() {
|
|
65
|
+
if (isSSR) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return internals.android && /(?=android)(?=.*mobile)/i.test(internals.userAgent);
|
|
69
|
+
},
|
|
70
|
+
get ipad() {
|
|
71
|
+
if (isSSR) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
// With iOS 13 the string 'iPad' was removed from the user agent string through a browser setting, which is applied on all sites by default:
|
|
75
|
+
// "Request Desktop Website -> All websites" (for more infos see: https://forums.developer.apple.com/thread/119186).
|
|
76
|
+
// Therefore the OS is detected as MACINTOSH instead of iOS and the device is a tablet if the Device.support.touch is true.
|
|
77
|
+
return /ipad/i.test(internals.userAgent) || (/Macintosh/i.test(internals.userAgent) && "ontouchend" in document);
|
|
78
|
+
},
|
|
79
|
+
};
|
|
16
80
|
|
|
17
81
|
let windowsVersion: number;
|
|
18
82
|
let webkitVersion: number;
|
|
19
83
|
let tablet: boolean;
|
|
20
84
|
|
|
21
85
|
const isWindows8OrAbove = () => {
|
|
22
|
-
if (
|
|
86
|
+
if (isSSR) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!internals.windows) {
|
|
23
91
|
return false;
|
|
24
92
|
}
|
|
25
93
|
|
|
26
94
|
if (windowsVersion === undefined) {
|
|
27
|
-
const matches =
|
|
95
|
+
const matches = internals.userAgent.match(/Windows NT (\d+).(\d)/);
|
|
28
96
|
windowsVersion = matches ? parseFloat(matches[1]) : 0;
|
|
29
97
|
}
|
|
30
98
|
|
|
@@ -32,12 +100,16 @@ const isWindows8OrAbove = () => {
|
|
|
32
100
|
};
|
|
33
101
|
|
|
34
102
|
const isWebkit537OrAbove = () => {
|
|
35
|
-
if (
|
|
103
|
+
if (isSSR) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!internals.webkit) {
|
|
36
108
|
return false;
|
|
37
109
|
}
|
|
38
110
|
|
|
39
111
|
if (webkitVersion === undefined) {
|
|
40
|
-
const matches =
|
|
112
|
+
const matches = internals.userAgent.match(/(webkit)[ /]([\w.]+)/);
|
|
41
113
|
webkitVersion = matches ? parseFloat(matches[1]) : 0;
|
|
42
114
|
}
|
|
43
115
|
|
|
@@ -45,28 +117,32 @@ const isWebkit537OrAbove = () => {
|
|
|
45
117
|
};
|
|
46
118
|
|
|
47
119
|
const detectTablet = () => {
|
|
120
|
+
if (isSSR) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
|
|
48
124
|
if (tablet !== undefined) {
|
|
49
125
|
return;
|
|
50
126
|
}
|
|
51
127
|
|
|
52
|
-
if (ipad) {
|
|
128
|
+
if (internals.ipad) {
|
|
53
129
|
tablet = true;
|
|
54
130
|
return;
|
|
55
131
|
}
|
|
56
132
|
|
|
57
|
-
if (touch) {
|
|
133
|
+
if (internals.touch) {
|
|
58
134
|
if (isWindows8OrAbove()) {
|
|
59
135
|
tablet = true;
|
|
60
136
|
return;
|
|
61
137
|
}
|
|
62
138
|
|
|
63
|
-
if (chrome && android) {
|
|
64
|
-
tablet = !/Mobile Safari\/[.0-9]+/.test(
|
|
139
|
+
if (internals.chrome && internals.android) {
|
|
140
|
+
tablet = !/Mobile Safari\/[.0-9]+/.test(internals.userAgent);
|
|
65
141
|
return;
|
|
66
142
|
}
|
|
67
143
|
|
|
68
144
|
let densityFactor = window.devicePixelRatio ? window.devicePixelRatio : 1; // may be undefined in Windows Phone devices
|
|
69
|
-
if (android && isWebkit537OrAbove()) {
|
|
145
|
+
if (internals.android && isWebkit537OrAbove()) {
|
|
70
146
|
densityFactor = 1;
|
|
71
147
|
}
|
|
72
148
|
|
|
@@ -74,26 +150,29 @@ const detectTablet = () => {
|
|
|
74
150
|
return;
|
|
75
151
|
}
|
|
76
152
|
|
|
77
|
-
tablet = (ie &&
|
|
153
|
+
tablet = (internals.ie && internals.userAgent.indexOf("Touch") !== -1) || (internals.android && !internals.androidPhone);
|
|
78
154
|
};
|
|
79
155
|
|
|
80
|
-
const supportsTouch = (): boolean => touch;
|
|
81
|
-
const isIE = (): boolean => ie;
|
|
82
|
-
const isSafari = (): boolean => safari;
|
|
83
|
-
const isChrome = (): boolean => chrome;
|
|
84
|
-
const isFirefox = (): boolean => firefox;
|
|
156
|
+
const supportsTouch = (): boolean => internals.touch;
|
|
157
|
+
const isIE = (): boolean => internals.ie;
|
|
158
|
+
const isSafari = (): boolean => internals.safari;
|
|
159
|
+
const isChrome = (): boolean => internals.chrome;
|
|
160
|
+
const isFirefox = (): boolean => internals.firefox;
|
|
85
161
|
|
|
86
162
|
const isTablet = (): boolean => {
|
|
87
163
|
detectTablet();
|
|
88
|
-
return (touch || isWindows8OrAbove()) && tablet;
|
|
164
|
+
return (internals.touch || isWindows8OrAbove()) && tablet;
|
|
89
165
|
};
|
|
90
166
|
|
|
91
167
|
const isPhone = (): boolean => {
|
|
92
168
|
detectTablet();
|
|
93
|
-
return touch && !tablet;
|
|
169
|
+
return internals.touch && !tablet;
|
|
94
170
|
};
|
|
95
171
|
|
|
96
172
|
const isDesktop = (): boolean => {
|
|
173
|
+
if (isSSR) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
97
176
|
return (!isTablet() && !isPhone()) || isWindows8OrAbove();
|
|
98
177
|
};
|
|
99
178
|
|
|
@@ -102,11 +181,11 @@ const isCombi = (): boolean => {
|
|
|
102
181
|
};
|
|
103
182
|
|
|
104
183
|
const isIOS = (): boolean => {
|
|
105
|
-
return iOS;
|
|
184
|
+
return internals.iOS;
|
|
106
185
|
};
|
|
107
186
|
|
|
108
187
|
const isAndroid = (): boolean => {
|
|
109
|
-
return android || androidPhone;
|
|
188
|
+
return internals.android || internals.androidPhone;
|
|
110
189
|
};
|
|
111
190
|
|
|
112
191
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import getSharedResource from "../getSharedResource.js";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import { getIconCollectionByAlias } from "../assets-meta/IconCollectionsAlias.js";
|
|
3
|
+
import { getEffectiveIconCollection } from "../config/Icons.js";
|
|
4
4
|
import { I18nText } from "../i18nBundle.js";
|
|
5
5
|
import { TemplateFunction } from "../renderer/executeTemplate.js";
|
|
6
6
|
|
|
@@ -19,7 +19,7 @@ type CollectionData = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
type IconData = {
|
|
22
|
-
collection
|
|
22
|
+
collection: string,
|
|
23
23
|
packageName: string,
|
|
24
24
|
pathData: string | Array<string>,
|
|
25
25
|
ltr: boolean,
|
|
@@ -67,11 +67,8 @@ const _fillRegistry = (bundleData: CollectionData) => {
|
|
|
67
67
|
|
|
68
68
|
// set
|
|
69
69
|
const registerIcon = (name: string, iconData: IconData) => { // eslint-disable-line
|
|
70
|
-
if (!iconData.collection) {
|
|
71
|
-
iconData.collection = getEffectiveDefaultIconCollection();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
70
|
const key = `${iconData.collection}/${name}`;
|
|
71
|
+
|
|
75
72
|
registry.set(key, {
|
|
76
73
|
pathData: iconData.pathData,
|
|
77
74
|
ltr: iconData.ltr,
|
|
@@ -79,38 +76,48 @@ const registerIcon = (name: string, iconData: IconData) => { // eslint-disable-l
|
|
|
79
76
|
packageName: iconData.packageName,
|
|
80
77
|
customTemplate: iconData.customTemplate,
|
|
81
78
|
viewBox: iconData.viewBox,
|
|
79
|
+
collection: iconData.collection,
|
|
82
80
|
});
|
|
83
81
|
};
|
|
84
82
|
|
|
85
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Processes the full icon name and splits it into - "name", "collection"
|
|
85
|
+
* to form the proper registry key ("collection/name") under which the icon is registered:
|
|
86
|
+
*
|
|
87
|
+
* - removes legacy protocol ("sap-icon://")
|
|
88
|
+
* - resolves aliases (f.e "SAP-icons-TNT/actor" => "tnt/actor")
|
|
89
|
+
* - determines theme dependant icon collection (f.e "home" => "SAP-icons-v4/home" in Quartz | "SAP-icons-v5/home" in Horizon)
|
|
90
|
+
*
|
|
91
|
+
* @param { string } name
|
|
92
|
+
* @return { object }
|
|
93
|
+
*/
|
|
94
|
+
const processName = (name: string) => {
|
|
86
95
|
// silently support ui5-compatible URIs
|
|
87
96
|
if (name.startsWith("sap-icon://")) {
|
|
88
97
|
name = name.replace("sap-icon://", "");
|
|
89
98
|
}
|
|
90
99
|
|
|
91
|
-
let collection;
|
|
100
|
+
let collection: string;
|
|
92
101
|
[name, collection] = name.split("/").reverse();
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// Normalize collection name.
|
|
96
|
-
// - resolve `SAP-icons-TNT` to `tnt`.
|
|
97
|
-
// - resolve `BusinessSuiteInAppSymbols` to `business-suite`.
|
|
98
|
-
// - resolve `horizon` to `SAP-icons-v5`,
|
|
99
|
-
// Note: aliases can be made as a feature, if more collections need it or more aliases are needed.
|
|
100
|
-
collection = _normalizeCollection(collection);
|
|
102
|
+
|
|
101
103
|
name = name.replace("icon-", "");
|
|
102
104
|
|
|
105
|
+
if (collection) {
|
|
106
|
+
collection = getIconCollectionByAlias(collection);
|
|
107
|
+
}
|
|
108
|
+
collection = getEffectiveIconCollection(collection);
|
|
109
|
+
|
|
103
110
|
const registryKey = `${collection}/${name}`;
|
|
104
111
|
return { name, collection, registryKey };
|
|
105
112
|
};
|
|
106
113
|
|
|
107
114
|
const getIconDataSync = (name: string) => {
|
|
108
|
-
const { registryKey } =
|
|
115
|
+
const { registryKey } = processName(name);
|
|
109
116
|
return registry.get(registryKey);
|
|
110
117
|
};
|
|
111
118
|
|
|
112
119
|
const getIconData = async (name: string) => {
|
|
113
|
-
const { collection, registryKey } =
|
|
120
|
+
const { collection, registryKey } = processName(name);
|
|
114
121
|
|
|
115
122
|
let iconData: string | CollectionData = ICON_NOT_FOUND;
|
|
116
123
|
try {
|
|
@@ -140,14 +147,6 @@ const _getRegisteredNames = async () => {
|
|
|
140
147
|
return Array.from(registry.keys());
|
|
141
148
|
};
|
|
142
149
|
|
|
143
|
-
const _normalizeCollection = (collectionName: string) => {
|
|
144
|
-
if (IconCollectionsAlias[collectionName as keyof typeof IconCollectionsAlias]) {
|
|
145
|
-
return IconCollectionsAlias[collectionName as keyof typeof IconCollectionsAlias];
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return collectionName;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
150
|
export {
|
|
152
151
|
registerIconLoader,
|
|
153
152
|
getIconData,
|
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Supported icon collection
|
|
2
|
+
* Supported icon collection aliases.
|
|
3
3
|
*
|
|
4
4
|
* Users might specify a collection, using both the key and the value in the following key-value pairs,
|
|
5
5
|
* e.g the following pairs are completely exchangeable:
|
|
6
|
-
* "SAP-icons-TNT/actor" and "tnt/actor", "BusinessSuiteInAppSymbols/3d" and "business-suite/3d",
|
|
7
|
-
* "SAP-icons-v5/accept" and "horizon/accept".
|
|
8
6
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* - "SAP-icons/accept" and "SAP-icons-v4/accept"
|
|
8
|
+
* - "horizon/accept" and "SAP-icons-v5/accept"
|
|
9
|
+
* - "SAP-icons-TNT/actor" and "tnt/actor"
|
|
10
|
+
* - "BusinessSuiteInAppSymbols/3d" and "business-suite/3d"
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
"SAP-icons
|
|
14
|
-
"
|
|
15
|
-
"
|
|
12
|
+
enum IconCollectionsAlias {
|
|
13
|
+
"SAP-icons" = "SAP-icons-v4",
|
|
14
|
+
"horizon" = "SAP-icons-v5",
|
|
15
|
+
"SAP-icons-TNT" = "tnt",
|
|
16
|
+
"BusinessSuiteInAppSymbols" = "business-suite",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Returns the mapped collection name for a given alias.
|
|
21
|
+
*
|
|
22
|
+
* <b>For example</b>:
|
|
23
|
+
* - "SAP-icons-TNT"resolves to "tnt"
|
|
24
|
+
* - "BusinessSuiteInAppSymbols" resolves to "business-suite"
|
|
25
|
+
* - "horizon" resolves to "SAP-icons-v5"
|
|
26
|
+
*
|
|
27
|
+
* @param { string } collectionName
|
|
28
|
+
* @return { string } the normalized collection name
|
|
29
|
+
*/
|
|
30
|
+
const getIconCollectionByAlias = (collectionName: string) => {
|
|
31
|
+
if (IconCollectionsAlias[collectionName as keyof typeof IconCollectionsAlias]) {
|
|
32
|
+
return IconCollectionsAlias[collectionName as keyof typeof IconCollectionsAlias];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return collectionName;
|
|
16
36
|
};
|
|
17
37
|
|
|
18
38
|
export default IconCollectionsAlias;
|
|
39
|
+
export {
|
|
40
|
+
getIconCollectionByAlias,
|
|
41
|
+
};
|
package/src/config/Icons.ts
CHANGED
|
@@ -1,59 +1,119 @@
|
|
|
1
1
|
import { getTheme, isThemeFamily } from "./Theme.js";
|
|
2
|
+
import { getIconCollectionByAlias } from "../assets-meta/IconCollectionsAlias.js";
|
|
2
3
|
|
|
3
4
|
const IconCollectionConfiguration = new Map<string, string>();
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
// All supported icon collections + uknown custom ones
|
|
7
|
+
type IconCollection = "SAP-icons" | "SAP-icons-v4" | "SAP-icons-v5" | "horizon" | "tnt" | "tnt-v2" | "tnt-v3" | "business-suite" | string;
|
|
8
|
+
|
|
9
|
+
// All registered icon collections - all icon collections resolves to these options at the end
|
|
10
|
+
enum RegisteredIconCollection {
|
|
11
|
+
SAPIconsV4 = "SAP-icons-v4",
|
|
12
|
+
SAPIconsV5 = "SAP-icons-v5",
|
|
13
|
+
SAPIconsTNTV2 = "tnt-v2",
|
|
14
|
+
SAPIconsTNTV3 = "tnt-v3",
|
|
15
|
+
SAPBSIcons = "business-suite",
|
|
8
16
|
}
|
|
9
17
|
|
|
10
18
|
/**
|
|
11
|
-
* Sets the default icon collection
|
|
12
|
-
*
|
|
19
|
+
* Sets the default icon collection for a given theme.
|
|
20
|
+
*
|
|
21
|
+
* SAP Icons is the default icon collection (that resolves to SAP-icons version 5.x in Horizon theme family and SAP-icons version 4.x in all other themes)
|
|
22
|
+
* and to display icons from other collections, you have to specify the icon collection in addition to the icon name, for example: "tnt/actor", "business-suite/1x2-grid-layout", etc.
|
|
23
|
+
* This method allows setting another (built-in or custom) icon collection as default per theme.
|
|
24
|
+
*
|
|
25
|
+
* <b>Usage</b>
|
|
26
|
+
* <b>For example</b>, to make "SAP-icons version 5.x" the default icon collection in "sap_fiori_3":
|
|
27
|
+
*
|
|
28
|
+
* <pre>
|
|
29
|
+
* setDefaultIconCollection("sap_fiori_3", "SAP-icons-v5");
|
|
30
|
+
*
|
|
31
|
+
* <ui5-icon name="home"></ui5-icon>
|
|
32
|
+
* </pre>
|
|
33
|
+
*
|
|
34
|
+
* <b>For example</b>, to make a custom icon collection (with name "my-custom-collection") the default icon collection in "sap_fiori_3":
|
|
35
|
+
*
|
|
36
|
+
* <pre>
|
|
37
|
+
* setDefaultIconCollection("sap_fiori_3", "my-custom-collection");
|
|
38
|
+
*
|
|
39
|
+
* <ui5-icon name="custom-icon-name"></ui5-icon>
|
|
40
|
+
* </pre>
|
|
13
41
|
*
|
|
14
|
-
* Note: by default SAP-icons-v5 is used in all SAP Horizon variants and SAP-icons-v4 for all the rest.
|
|
15
42
|
* @public
|
|
16
|
-
* @param {string} theme
|
|
17
|
-
* @param {
|
|
43
|
+
* @param { string } theme
|
|
44
|
+
* @param { string } collectionName
|
|
18
45
|
*/
|
|
19
|
-
const setDefaultIconCollection = (theme: string, collectionName:
|
|
20
|
-
if (collectionName === "horizon") {
|
|
21
|
-
collectionName = IconCollection.v5;
|
|
22
|
-
}
|
|
23
|
-
|
|
46
|
+
const setDefaultIconCollection = (theme: string, collectionName: IconCollection) => {
|
|
24
47
|
IconCollectionConfiguration.set(theme, collectionName);
|
|
25
48
|
};
|
|
26
49
|
|
|
27
50
|
/**
|
|
28
|
-
* Returns the default icon collection
|
|
29
|
-
* that is configured.
|
|
51
|
+
* Returns the configured default icon collection for a given theme.
|
|
30
52
|
*
|
|
31
|
-
* @param {string} theme
|
|
53
|
+
* @param { string } theme
|
|
32
54
|
* @public
|
|
33
|
-
* @returns {string | undefined}
|
|
55
|
+
* @returns { string | undefined }
|
|
34
56
|
*/
|
|
35
57
|
const getDefaultIconCollection = (theme: string): string | undefined => {
|
|
36
58
|
return IconCollectionConfiguration.get(theme);
|
|
37
59
|
};
|
|
38
60
|
|
|
39
61
|
/**
|
|
40
|
-
* Returns the effective icon collection
|
|
41
|
-
*
|
|
42
|
-
* @
|
|
62
|
+
* Returns the effective icon collection,
|
|
63
|
+
* based on the default icon collection configuration and the current theme:
|
|
64
|
+
* @param { IconCollection } collectionName
|
|
65
|
+
* @returns { IconCollection } the effective collection name
|
|
43
66
|
*/
|
|
44
|
-
const
|
|
67
|
+
const getEffectiveIconCollection = (collectionName?: IconCollection): IconCollection => {
|
|
45
68
|
const currentTheme = getTheme();
|
|
46
69
|
const currentThemeConfiguration = IconCollectionConfiguration.get(currentTheme);
|
|
47
70
|
|
|
48
|
-
|
|
49
|
-
|
|
71
|
+
// when no collection is set and default collection is configured - return the configured icon collection
|
|
72
|
+
if (!collectionName && currentThemeConfiguration) {
|
|
73
|
+
return getIconCollectionByAlias(currentThemeConfiguration);
|
|
50
74
|
}
|
|
51
75
|
|
|
52
|
-
return
|
|
76
|
+
// when collection is set - return the theme dependant icon collection
|
|
77
|
+
// when collection is not set and there is no default icon collection configured - return theme dependant icon collection
|
|
78
|
+
return getIconCollectionByTheme(collectionName);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Returns the icon theme dependant collection, based on the collection name and current theme as follows:
|
|
83
|
+
*
|
|
84
|
+
* - "no collection" resolves to "SAP-icons-v4" in "Quartz" and "Belize", and to "SAP-icons-v5" in "Horizon" (or as confugred via setDefaultIconCollection)
|
|
85
|
+
* - "SAP-icons-v4" (and its alias "SAP-icons") forces "SAP-icons v4" in any theme and resolves to itself "SAP-icons-v4"
|
|
86
|
+
* - "SAP-icons-v5" (and its alias "horizon") forces "SAP-icons v5" in any theme and resolves to itself "SAP-icons-v5"
|
|
87
|
+
* - "tnt" (and its alias "SAP-icons-TNT") resolves to "tnt-v2" in "Quartz", "Belize", and resolves to "tnt-v3" in "Horizon"
|
|
88
|
+
* - "tnt-v2" forces "TNT icons v2" in any theme and resolves to itself "tnt-v2"
|
|
89
|
+
* - "tnt-v3" forces "TNT icons v3" in any theme and resolves to itself "tnt-v3"
|
|
90
|
+
* - "business-suite" (and its alias "BusinessSuiteInAppSymbols") has no versioning and resolves to "business-suite"
|
|
91
|
+
*
|
|
92
|
+
* <b>Note:</b> "SAP-icons-v4", "SAP-icons-v5", "tnt-v2", "tnt-v3" and "business-suite" are just returned
|
|
93
|
+
* @param { IconCollection } collectionName
|
|
94
|
+
* @returns { RegisteredIconCollection } the registered collection name
|
|
95
|
+
*/
|
|
96
|
+
const getIconCollectionByTheme = (collectionName?: IconCollection): RegisteredIconCollection => {
|
|
97
|
+
const horizonThemeFamily = isThemeFamily("sap_horizon");
|
|
98
|
+
|
|
99
|
+
if (!collectionName) {
|
|
100
|
+
return horizonThemeFamily ? RegisteredIconCollection.SAPIconsV5 : RegisteredIconCollection.SAPIconsV4;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (collectionName === "tnt") {
|
|
104
|
+
return horizonThemeFamily ? RegisteredIconCollection.SAPIconsTNTV3 : RegisteredIconCollection.SAPIconsTNTV2;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return collectionName as RegisteredIconCollection;
|
|
53
108
|
};
|
|
54
109
|
|
|
55
110
|
export {
|
|
56
111
|
setDefaultIconCollection,
|
|
57
112
|
getDefaultIconCollection,
|
|
58
|
-
|
|
113
|
+
getEffectiveIconCollection,
|
|
114
|
+
RegisteredIconCollection,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export type {
|
|
118
|
+
IconCollection,
|
|
59
119
|
};
|
package/src/config/RTL.ts
CHANGED
|
@@ -29,6 +29,10 @@ const impliesRTL = (language: string) => {
|
|
|
29
29
|
* @returns {boolean} whether RTL should be used
|
|
30
30
|
*/
|
|
31
31
|
const getRTL = (): boolean => {
|
|
32
|
+
if (typeof document === "undefined") {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
32
36
|
const configurationRTL = getConfiguredRTL();
|
|
33
37
|
|
|
34
38
|
if (configurationRTL !== undefined) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { instanceOfUI5Element } from "../UI5Element.js";
|
|
2
2
|
|
|
3
|
-
type ResizeObserverCallback = () => void;
|
|
3
|
+
type ResizeObserverCallback = () => Promise<void> | void;
|
|
4
4
|
|
|
5
5
|
let resizeObserver: ResizeObserver;
|
|
6
6
|
const observedElements = new Map<HTMLElement, Array<ResizeObserverCallback>>();
|
|
@@ -10,7 +10,9 @@ const getResizeObserver = () => {
|
|
|
10
10
|
resizeObserver = new window.ResizeObserver(entries => {
|
|
11
11
|
entries.forEach(entry => {
|
|
12
12
|
const callbacks = observedElements.get(entry.target as HTMLElement);
|
|
13
|
-
|
|
13
|
+
// Callbacks could be async and we need to handle returned promises to comply with the eslint "no-misused-promises" rule.
|
|
14
|
+
// Although Promise.all awaits all, we don't additonal task after calling the callbacks and should not make any difference.
|
|
15
|
+
callbacks && Promise.all(callbacks.map((callback: ResizeObserverCallback) => callback()));
|
|
14
16
|
});
|
|
15
17
|
});
|
|
16
18
|
}
|
|
@@ -93,3 +95,6 @@ class ResizeHandler {
|
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
export default ResizeHandler;
|
|
98
|
+
export type {
|
|
99
|
+
ResizeObserverCallback,
|
|
100
|
+
};
|