@ui5/webcomponents-base 1.2.4 → 1.3.0
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 +0 -1
- package/CHANGELOG.md +20 -0
- package/dist/CustomElementsScope.js +20 -98
- package/dist/CustomElementsScopeUtils.js +108 -0
- package/dist/Device.js +5 -0
- package/dist/Keys.js +15 -0
- package/dist/StaticAreaItem.js +1 -1
- package/dist/UI5Element.js +11 -1
- package/dist/UI5ElementMetadata.js +1 -1
- package/dist/asset-registries/Icons.js +3 -7
- package/dist/config/Icons.js +52 -0
- package/dist/css/BusyIndicator.css +76 -0
- package/dist/features/F6Navigation.js +2 -0
- package/dist/features/OpenUI5Enablement.js +119 -0
- package/dist/generated/VersionInfo.js +4 -4
- package/dist/generated/css/BusyIndicator.css.js +5 -0
- package/dist/renderer/LitRenderer.js +29 -11
- package/dist/renderer/executeTemplate.js +1 -1
- package/dist/resources/bundle.esm.js +8 -13
- package/dist/resources/bundle.esm.js.map +1 -1
- package/dist/theming/getEffectiveLinksHrefs.js +7 -0
- package/dist/theming/getEffectiveStyle.js +9 -0
- package/dist/updateShadowRoot.js +1 -1
- package/dist/util/getNormalizedTarget.js +16 -0
- package/hash.txt +1 -1
- package/package-scripts.js +1 -6
- package/package.json +3 -3
- package/src/CustomElementsScope.js +20 -98
- package/src/CustomElementsScopeUtils.js +108 -0
- package/src/Device.js +5 -0
- package/src/Keys.js +15 -0
- package/src/StaticAreaItem.js +1 -1
- package/src/UI5Element.js +11 -1
- package/src/UI5ElementMetadata.js +1 -1
- package/src/asset-registries/Icons.js +3 -7
- package/src/config/Icons.js +52 -0
- package/src/css/BusyIndicator.css +76 -0
- package/src/features/F6Navigation.js +2 -0
- package/src/features/OpenUI5Enablement.js +119 -0
- package/src/renderer/LitRenderer.js +29 -11
- package/src/renderer/executeTemplate.js +1 -1
- package/src/theming/getEffectiveLinksHrefs.js +7 -0
- package/src/theming/getEffectiveStyle.js +9 -0
- package/src/updateShadowRoot.js +1 -1
- package/src/util/getNormalizedTarget.js +16 -0
package/.eslintignore
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.3.0](https://github.com/SAP/ui5-webcomponents/compare/v1.2.4...v1.3.0) (2022-04-19)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **framework:** make listeners passive ([#5012](https://github.com/SAP/ui5-webcomponents/issues/5012)) ([30f2dc7](https://github.com/SAP/ui5-webcomponents/commit/30f2dc7))
|
|
12
|
+
* **framework:** fix F6 navigation on windows browsers ([#4886](https://github.com/SAP/ui5-webcomponents/issues/4886)) ([36fd3d1](https://github.com/SAP/ui5-webcomponents/commit/36fd3d1))
|
|
13
|
+
* **framework:** fix submit event handling in forms ([#4942](https://github.com/SAP/ui5-webcomponents/issues/4942)) ([883809f](https://github.com/SAP/ui5-webcomponents/commit/883809f))
|
|
14
|
+
* **framework:** add 72-* font as system styles ([#4934](https://github.com/SAP/ui5-webcomponents/issues/4934)) ([4b45d32](https://github.com/SAP/ui5-webcomponents/commit/4b45d32))
|
|
15
|
+
* **framework:** fix scoping of self tag ([#4952](https://github.com/SAP/ui5-webcomponents/issues/4952)) ([8d53e95](https://github.com/SAP/ui5-webcomponents/commit/8d53e95))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **framework:** configure default icon collection per theme ([#5031](https://github.com/SAP/ui5-webcomponents/issues/5031)) ([7f84b83](https://github.com/SAP/ui5-webcomponents/commit/7f84b83))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
6
26
|
## [1.2.4](https://github.com/SAP/ui5-webcomponents/compare/v1.2.3...v1.2.4) (2022-03-30)
|
|
7
27
|
|
|
8
28
|
|
|
@@ -1,102 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
const tagsCache = new Map(); // true/false means the tag should/should not be cached, undefined means not known yet.
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Sets the suffix to be used for custom elements scoping, f.e. pass "demo" to get tags such as "ui5-button-demo".
|
|
10
|
-
* Note: by default all tags starting with "ui5-" will be scoped, unless you change this by calling "setCustomElementsScopingRules"
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
* @param suffix The scoping suffix
|
|
14
|
-
*/
|
|
15
|
-
const setCustomElementsScopingSuffix = suffix => {
|
|
16
|
-
if (!suffix.match(/^[a-zA-Z0-9_-]+$/)) {
|
|
17
|
-
throw new Error("Only alphanumeric characters and dashes allowed for the scoping suffix");
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
suf = suffix;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Returns the currently set scoping suffix, or undefined if not set.
|
|
25
|
-
*
|
|
26
|
-
* @public
|
|
27
|
-
* @returns {String|undefined}
|
|
28
|
-
*/
|
|
29
|
-
const getCustomElementsScopingSuffix = () => {
|
|
30
|
-
return suf;
|
|
31
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
html,
|
|
3
|
+
svg,
|
|
4
|
+
unsafeStatic,
|
|
5
|
+
} from "lit-html/static.js";
|
|
32
6
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
throw new Error(`"rules.include" must be an array of regular expressions`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (rules.exclude && (!Array.isArray(rules.exclude) || rules.exclude.some(rule => !(rule instanceof RegExp)))) {
|
|
52
|
-
throw new Error(`"rules.exclude" must be an array of regular expressions`);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
rules.exclude = rules.exclude || [];
|
|
56
|
-
rulesObj = rules;
|
|
57
|
-
tagsCache.clear(); // reset the cache upon setting new rules
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Returns the rules, governing which custom element tags to scope and which not. By default, all elements
|
|
62
|
-
* starting with "ui5-" are scoped. The default rules are: {include: [/^ui5-/]}.
|
|
63
|
-
*
|
|
64
|
-
* @public
|
|
65
|
-
* @returns {Object}
|
|
66
|
-
*/
|
|
67
|
-
const getCustomElementsScopingRules = () => {
|
|
68
|
-
return rulesObj;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Determines whether custom elements with the given tag should be scoped or not.
|
|
73
|
-
* The tag is first matched against the "include" rules and then against the "exclude" rules and the
|
|
74
|
-
* result is cached until new rules are set.
|
|
75
|
-
*
|
|
76
|
-
* @public
|
|
77
|
-
* @param tag
|
|
78
|
-
*/
|
|
79
|
-
const shouldScopeCustomElement = tag => {
|
|
80
|
-
if (!tagsCache.has(tag)) {
|
|
81
|
-
const result = rulesObj.include.some(rule => tag.match(rule)) && !rulesObj.exclude.some(rule => tag.match(rule));
|
|
82
|
-
tagsCache.set(tag, result);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return tagsCache.get(tag);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Returns the currently set scoping suffix, if any and if the tag should be scoped, or undefined otherwise.
|
|
90
|
-
*
|
|
91
|
-
* @public
|
|
92
|
-
* @param tag
|
|
93
|
-
* @returns {String}
|
|
94
|
-
*/
|
|
95
|
-
const getEffectiveScopingSuffixForTag = tag => {
|
|
96
|
-
if (shouldScopeCustomElement(tag)) {
|
|
97
|
-
return getCustomElementsScopingSuffix();
|
|
98
|
-
}
|
|
99
|
-
};
|
|
7
|
+
import {
|
|
8
|
+
setCustomElementsScopingSuffix,
|
|
9
|
+
getCustomElementsScopingSuffix,
|
|
10
|
+
setCustomElementsScopingRules,
|
|
11
|
+
getCustomElementsScopingRules,
|
|
12
|
+
shouldScopeCustomElement,
|
|
13
|
+
getEffectiveScopingSuffixForTag,
|
|
14
|
+
} from "./CustomElementsScopeUtils.js";
|
|
15
|
+
import { registerFeature } from "./FeaturesRegistry.js";
|
|
16
|
+
|
|
17
|
+
registerFeature("LitStatic", {
|
|
18
|
+
html,
|
|
19
|
+
svg,
|
|
20
|
+
unsafeStatic,
|
|
21
|
+
});
|
|
100
22
|
|
|
101
23
|
export {
|
|
102
24
|
setCustomElementsScopingSuffix,
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
let suf;
|
|
2
|
+
let rulesObj = {
|
|
3
|
+
include: [/^ui5-/],
|
|
4
|
+
exclude: [],
|
|
5
|
+
};
|
|
6
|
+
const tagsCache = new Map(); // true/false means the tag should/should not be cached, undefined means not known yet.
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Sets the suffix to be used for custom elements scoping, f.e. pass "demo" to get tags such as "ui5-button-demo".
|
|
10
|
+
* Note: by default all tags starting with "ui5-" will be scoped, unless you change this by calling "setCustomElementsScopingRules"
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
* @param suffix The scoping suffix
|
|
14
|
+
*/
|
|
15
|
+
const setCustomElementsScopingSuffix = suffix => {
|
|
16
|
+
if (!suffix.match(/^[a-zA-Z0-9_-]+$/)) {
|
|
17
|
+
throw new Error("Only alphanumeric characters and dashes allowed for the scoping suffix");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
suf = suffix;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Returns the currently set scoping suffix, or undefined if not set.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
* @returns {String|undefined}
|
|
28
|
+
*/
|
|
29
|
+
const getCustomElementsScopingSuffix = () => {
|
|
30
|
+
return suf;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Sets the rules, governing which custom element tags to scope and which not, f.e.
|
|
35
|
+
* setCustomElementsScopingRules({include: [/^ui5-/]}, exclude: [/^ui5-mylib-/, /^ui5-carousel$/]);
|
|
36
|
+
* will scope all elements starting with "ui5-" but not the ones starting with "ui5-mylib-" and not "ui5-carousel".
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
* @param rules Object with "include" and "exclude" properties, both arrays of regular expressions. Note that "include"
|
|
40
|
+
* rules are applied first and "exclude" rules second.
|
|
41
|
+
*/
|
|
42
|
+
const setCustomElementsScopingRules = rules => {
|
|
43
|
+
if (!rules || !rules.include) {
|
|
44
|
+
throw new Error(`"rules" must be an object with at least an "include" property`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!Array.isArray(rules.include) || rules.include.some(rule => !(rule instanceof RegExp))) {
|
|
48
|
+
throw new Error(`"rules.include" must be an array of regular expressions`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (rules.exclude && (!Array.isArray(rules.exclude) || rules.exclude.some(rule => !(rule instanceof RegExp)))) {
|
|
52
|
+
throw new Error(`"rules.exclude" must be an array of regular expressions`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
rules.exclude = rules.exclude || [];
|
|
56
|
+
rulesObj = rules;
|
|
57
|
+
tagsCache.clear(); // reset the cache upon setting new rules
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Returns the rules, governing which custom element tags to scope and which not. By default, all elements
|
|
62
|
+
* starting with "ui5-" are scoped. The default rules are: {include: [/^ui5-/]}.
|
|
63
|
+
*
|
|
64
|
+
* @public
|
|
65
|
+
* @returns {Object}
|
|
66
|
+
*/
|
|
67
|
+
const getCustomElementsScopingRules = () => {
|
|
68
|
+
return rulesObj;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Determines whether custom elements with the given tag should be scoped or not.
|
|
73
|
+
* The tag is first matched against the "include" rules and then against the "exclude" rules and the
|
|
74
|
+
* result is cached until new rules are set.
|
|
75
|
+
*
|
|
76
|
+
* @public
|
|
77
|
+
* @param tag
|
|
78
|
+
*/
|
|
79
|
+
const shouldScopeCustomElement = tag => {
|
|
80
|
+
if (!tagsCache.has(tag)) {
|
|
81
|
+
const result = rulesObj.include.some(rule => tag.match(rule)) && !rulesObj.exclude.some(rule => tag.match(rule));
|
|
82
|
+
tagsCache.set(tag, result);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return tagsCache.get(tag);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Returns the currently set scoping suffix, if any and if the tag should be scoped, or undefined otherwise.
|
|
90
|
+
*
|
|
91
|
+
* @public
|
|
92
|
+
* @param tag
|
|
93
|
+
* @returns {String}
|
|
94
|
+
*/
|
|
95
|
+
const getEffectiveScopingSuffixForTag = tag => {
|
|
96
|
+
if (shouldScopeCustomElement(tag)) {
|
|
97
|
+
return getCustomElementsScopingSuffix();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export {
|
|
102
|
+
setCustomElementsScopingSuffix,
|
|
103
|
+
getCustomElementsScopingSuffix,
|
|
104
|
+
setCustomElementsScopingRules,
|
|
105
|
+
getCustomElementsScopingRules,
|
|
106
|
+
shouldScopeCustomElement,
|
|
107
|
+
getEffectiveScopingSuffixForTag,
|
|
108
|
+
};
|
package/dist/Device.js
CHANGED
|
@@ -103,6 +103,10 @@ const isIOS = () => {
|
|
|
103
103
|
return iOS;
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
+
const isAndroid = () => {
|
|
107
|
+
return android || androidPhone;
|
|
108
|
+
};
|
|
109
|
+
|
|
106
110
|
export {
|
|
107
111
|
supportsTouch,
|
|
108
112
|
isIE,
|
|
@@ -113,4 +117,5 @@ export {
|
|
|
113
117
|
isDesktop,
|
|
114
118
|
isCombi,
|
|
115
119
|
isIOS,
|
|
120
|
+
isAndroid,
|
|
116
121
|
};
|
package/dist/Keys.js
CHANGED
|
@@ -111,6 +111,8 @@ const isSpace = event => (event.key ? (event.key === "Spacebar" || event.key ===
|
|
|
111
111
|
|
|
112
112
|
const isSpaceShift = event => (event.key ? (event.key === "Spacebar" || event.key === " ") : event.keyCode === KeyCodes.SPACE) && checkModifierKeys(event, false, false, true);
|
|
113
113
|
|
|
114
|
+
const isSpaceCtrl = event => (event.key ? (event.key === "Spacebar" || event.key === " ") : event.keyCode === KeyCodes.SPACE) && checkModifierKeys(event, true, false, false);
|
|
115
|
+
|
|
114
116
|
const isLeft = event => (event.key ? (event.key === "ArrowLeft" || event.key === "Left") : event.keyCode === KeyCodes.ARROW_LEFT) && !hasModifierKeys(event);
|
|
115
117
|
|
|
116
118
|
const isRight = event => (event.key ? (event.key === "ArrowRight" || event.key === "Right") : event.keyCode === KeyCodes.ARROW_RIGHT) && !hasModifierKeys(event);
|
|
@@ -169,6 +171,12 @@ const isBackSpace = event => (event.key ? event.key === "Backspace" : event.keyC
|
|
|
169
171
|
|
|
170
172
|
const isDelete = event => (event.key ? event.key === "Delete" : event.keyCode === KeyCodes.DELETE) && !hasModifierKeys(event);
|
|
171
173
|
|
|
174
|
+
const isDeleteShift = event => (event.key ? event.key === "Delete" : event.keyCode === KeyCodes.DELETE) && checkModifierKeys(event, false, false, true);
|
|
175
|
+
|
|
176
|
+
const isInsertShift = event => (event.key ? event.key === "Insert" : event.keyCode === KeyCodes.DELETE) && checkModifierKeys(event, false, false, true);
|
|
177
|
+
|
|
178
|
+
const isInsertCtrl = event => (event.key ? event.key === "Insert" : event.keyCode === KeyCodes.DELETE) && checkModifierKeys(event, true, false, false);
|
|
179
|
+
|
|
172
180
|
const isPageUp = event => (event.key ? event.key === "PageUp" : event.keyCode === KeyCodes.PAGE_UP) && !hasModifierKeys(event);
|
|
173
181
|
|
|
174
182
|
const isPageDown = event => (event.key ? event.key === "PageDown" : event.keyCode === KeyCodes.PAGE_DOWN) && !hasModifierKeys(event);
|
|
@@ -219,6 +227,8 @@ const isShift = event => event.key === "Shift" || event.keyCode === KeyCodes.SHI
|
|
|
219
227
|
|
|
220
228
|
const isCtrlA = event => ((event.key === "A" || event.key === "a") || event.which === KeyCodes.A) && checkModifierKeys(event, true, false, false);
|
|
221
229
|
|
|
230
|
+
const isCtrlV = event => ((event.key === "V" || event.key === "v") || event.which === KeyCodes.V) && checkModifierKeys(event, true, false, false);
|
|
231
|
+
|
|
222
232
|
const hasModifierKeys = event => event.shiftKey || event.altKey || getCtrlKey(event);
|
|
223
233
|
|
|
224
234
|
const getCtrlKey = event => !!(event.metaKey || event.ctrlKey); // double negation doesn't have effect on boolean but ensures null and undefined are equivalent to false.
|
|
@@ -230,6 +240,7 @@ export {
|
|
|
230
240
|
isEnterShift,
|
|
231
241
|
isSpace,
|
|
232
242
|
isSpaceShift,
|
|
243
|
+
isSpaceCtrl,
|
|
233
244
|
isLeft,
|
|
234
245
|
isRight,
|
|
235
246
|
isUp,
|
|
@@ -277,4 +288,8 @@ export {
|
|
|
277
288
|
isPageDownShiftCtrl,
|
|
278
289
|
isShift,
|
|
279
290
|
isCtrlA,
|
|
291
|
+
isCtrlV,
|
|
292
|
+
isDeleteShift,
|
|
293
|
+
isInsertShift,
|
|
294
|
+
isInsertCtrl,
|
|
280
295
|
};
|
package/dist/StaticAreaItem.js
CHANGED
|
@@ -2,7 +2,7 @@ import "./StaticArea.js";
|
|
|
2
2
|
import updateShadowRoot from "./updateShadowRoot.js";
|
|
3
3
|
import { renderFinished } from "./Render.js";
|
|
4
4
|
import getEffectiveContentDensity from "./util/getEffectiveContentDensity.js";
|
|
5
|
-
import { getEffectiveScopingSuffixForTag } from "./
|
|
5
|
+
import { getEffectiveScopingSuffixForTag } from "./CustomElementsScopeUtils.js";
|
|
6
6
|
import getEffectiveDir from "./locale/getEffectiveDir.js";
|
|
7
7
|
|
|
8
8
|
/**
|
package/dist/UI5Element.js
CHANGED
|
@@ -46,6 +46,8 @@ function _invalidate(changeInfo) {
|
|
|
46
46
|
this._eventProvider.fireEvent("invalidate", { ...changeInfo, target: this });
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
let metadata = {};
|
|
50
|
+
|
|
49
51
|
/**
|
|
50
52
|
* Base class for all UI5 Web Components
|
|
51
53
|
*
|
|
@@ -896,7 +898,15 @@ class UI5Element extends HTMLElement {
|
|
|
896
898
|
* @protected
|
|
897
899
|
*/
|
|
898
900
|
static get metadata() {
|
|
899
|
-
return
|
|
901
|
+
return metadata;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* Sets a new metadata object for this UI5 Web Component Class
|
|
906
|
+
* @protected
|
|
907
|
+
*/
|
|
908
|
+
static set metadata(newMetadata) {
|
|
909
|
+
metadata = newMetadata;
|
|
900
910
|
}
|
|
901
911
|
|
|
902
912
|
/**
|
|
@@ -2,7 +2,7 @@ import DataType from "./types/DataType.js";
|
|
|
2
2
|
import isDescendantOf from "./util/isDescendantOf.js";
|
|
3
3
|
import { camelToKebabCase } from "./util/StringHelper.js";
|
|
4
4
|
import { getSlottedElements } from "./util/SlotsHelper.js";
|
|
5
|
-
import { getEffectiveScopingSuffixForTag } from "./
|
|
5
|
+
import { getEffectiveScopingSuffixForTag } from "./CustomElementsScopeUtils.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import getSharedResource from "../getSharedResource.js";
|
|
2
2
|
import IconCollectionsAlias from "../assets-meta/IconCollectionsAlias.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getEffectiveDefaultIconCollection } from "../config/Icons.js";
|
|
4
4
|
|
|
5
5
|
const loaders = new Map();
|
|
6
6
|
const registry = getSharedResource("SVGIcons.registry", new Map());
|
|
@@ -48,7 +48,7 @@ const _fillRegistry = bundleData => {
|
|
|
48
48
|
// set
|
|
49
49
|
const registerIcon = (name, { pathData, ltr, accData, collection, packageName } = {}) => { // eslint-disable-line
|
|
50
50
|
if (!collection) {
|
|
51
|
-
collection =
|
|
51
|
+
collection = getEffectiveDefaultIconCollection();
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
const key = `${collection}/${name}`;
|
|
@@ -68,7 +68,7 @@ const _parseName = name => {
|
|
|
68
68
|
|
|
69
69
|
let collection;
|
|
70
70
|
[name, collection] = name.split("/").reverse();
|
|
71
|
-
collection = collection ||
|
|
71
|
+
collection = collection || getEffectiveDefaultIconCollection();
|
|
72
72
|
|
|
73
73
|
// Normalize collection name.
|
|
74
74
|
// - resolve `SAP-icons-TNT` to `tnt`.
|
|
@@ -117,10 +117,6 @@ const _getRegisteredNames = async () => {
|
|
|
117
117
|
return Array.from(registry.keys());
|
|
118
118
|
};
|
|
119
119
|
|
|
120
|
-
const _getDefaultCollection = () => {
|
|
121
|
-
return isThemeFamily("sap_horizon") ? "SAP-icons-v5" : "SAP-icons";
|
|
122
|
-
};
|
|
123
|
-
|
|
124
120
|
const _normalizeCollection = collectionName => {
|
|
125
121
|
if (IconCollectionsAlias[collectionName]) {
|
|
126
122
|
return IconCollectionsAlias[collectionName];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { getTheme, isThemeFamily } from "./Theme.js";
|
|
2
|
+
|
|
3
|
+
const IconCollectionConfiguration = new Map();
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Sets the default icon collection (v4 or v5) per theme,
|
|
7
|
+
* which will be applied in case icon collection is not specified.
|
|
8
|
+
*
|
|
9
|
+
* Note: by default SAP-icons-v5 is used in SAP Horizon and SAP-icons-v4 for all the rest.
|
|
10
|
+
* @param {String} theme
|
|
11
|
+
* @param {String} collectionName
|
|
12
|
+
*/
|
|
13
|
+
const setDefaultIconCollection = (theme, collectionName) => {
|
|
14
|
+
if (collectionName === "horizon") {
|
|
15
|
+
collectionName = "SAP-icons-v5";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
IconCollectionConfiguration.set(theme, collectionName);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Returns the default icon collection (v4 or v5) for given theme,
|
|
23
|
+
* that is configured.
|
|
24
|
+
*
|
|
25
|
+
* @param {String} theme
|
|
26
|
+
* @returns {String}
|
|
27
|
+
*/
|
|
28
|
+
const getDefaultIconCollection = theme => {
|
|
29
|
+
return IconCollectionConfiguration.get(theme);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Returns the effective icon collection that will be applied for icon web components
|
|
34
|
+
* whenever namespace is not specified.
|
|
35
|
+
* @returns {String}
|
|
36
|
+
*/
|
|
37
|
+
const getEffectiveDefaultIconCollection = () => {
|
|
38
|
+
const currentTheme = getTheme();
|
|
39
|
+
const currentThemeConfiguration = IconCollectionConfiguration.get(currentTheme);
|
|
40
|
+
|
|
41
|
+
if (currentThemeConfiguration) {
|
|
42
|
+
return currentThemeConfiguration;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return isThemeFamily("sap_horizon") ? "SAP-icons-v5" : "SAP-icons";
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
setDefaultIconCollection,
|
|
50
|
+
getDefaultIconCollection,
|
|
51
|
+
getEffectiveDefaultIconCollection,
|
|
52
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
.busy-indicator-wrapper {
|
|
2
|
+
position: relative;
|
|
3
|
+
height: 100%;
|
|
4
|
+
width: 100%;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.busy-indicator-overlay {
|
|
8
|
+
display: var(--ui5_web_components_busy_indicator_display);
|
|
9
|
+
position: absolute;
|
|
10
|
+
inset: 0;
|
|
11
|
+
background: var(--ui5_web_components_busy_indicator_background-color);
|
|
12
|
+
z-index: 99;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.busy-indicator-busy-area {
|
|
16
|
+
display: var(--ui5_web_components_busy_indicator_display);
|
|
17
|
+
position: absolute;
|
|
18
|
+
z-index: 99;
|
|
19
|
+
inset: 0;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
align-items: center;
|
|
22
|
+
background-color: inherit;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
color: var(--_ui5_busy_indicator_color);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
:host([__is-busy]) .busy-indicator-wrapper > :not(.busy-indicator-busy-area):not(.busy-indicator-overlay):not([busy-indicator-before-span]) {
|
|
28
|
+
--ui5_web_components_busy_indicator_display: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.busy-indicator-busy-area:focus {
|
|
32
|
+
outline: var(--_ui5_busy_indicator_focus_outline);
|
|
33
|
+
outline-offset: -.125rem;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.busy-indicator-circle {
|
|
37
|
+
width: 1rem;
|
|
38
|
+
height: 1rem;
|
|
39
|
+
display: inline-block;
|
|
40
|
+
background-color: currentColor;
|
|
41
|
+
border-radius: 50%;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.circle-animation-0 {
|
|
45
|
+
animation: grow 1.6s infinite cubic-bezier(0.32, 0.06, 0.85, 1.11);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.circle-animation-1 {
|
|
49
|
+
animation: grow 1.6s infinite cubic-bezier(0.32, 0.06, 0.85, 1.11);
|
|
50
|
+
animation-delay: 200ms;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.circle-animation-2 {
|
|
54
|
+
animation: grow 1.6s infinite cubic-bezier(0.32, 0.06, 0.85, 1.11);
|
|
55
|
+
animation-delay: 400ms;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.sapUiLocalBusy {
|
|
59
|
+
--ui5_web_components_busy_indicator_display: none;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@keyframes grow {
|
|
63
|
+
0%, 50%, 100% {
|
|
64
|
+
-webkit-transform: scale(0.5);
|
|
65
|
+
-moz-transform: scale(0.5);
|
|
66
|
+
-ms-transform: scale(0.5);
|
|
67
|
+
transform: scale(0.5);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
25% {
|
|
71
|
+
-webkit-transform: scale(1);
|
|
72
|
+
-moz-transform: scale(1);
|
|
73
|
+
-ms-transform: scale(1);
|
|
74
|
+
transform: scale(1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { registerFeature } from "../FeaturesRegistry.js";
|
|
2
|
+
import BusyIndicatorStyles from "../generated/css/BusyIndicator.css.js";
|
|
3
|
+
import merge from "../thirdparty/merge.js";
|
|
4
|
+
import {
|
|
5
|
+
isTabPrevious,
|
|
6
|
+
} from "../Keys.js";
|
|
7
|
+
|
|
8
|
+
const busyIndicatorMetadata = {
|
|
9
|
+
properties: {
|
|
10
|
+
__isBusy: {
|
|
11
|
+
type: Boolean,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const getBusyIndicatorStyles = () => {
|
|
17
|
+
return BusyIndicatorStyles;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const wrapTemplateResultInBusyMarkup = (html, host, templateResult) => {
|
|
21
|
+
if (host.isOpenUI5Component && host.__isBusy) {
|
|
22
|
+
templateResult = html`
|
|
23
|
+
<div class="busy-indicator-wrapper">
|
|
24
|
+
<span tabindex="0" busy-indicator-before-span @focusin=${host.__suppressFocusIn}></span>
|
|
25
|
+
${templateResult}
|
|
26
|
+
<div class="busy-indicator-overlay"></div>
|
|
27
|
+
<div busy-indicator
|
|
28
|
+
class="busy-indicator-busy-area"
|
|
29
|
+
tabindex="0"
|
|
30
|
+
role="progressbar"
|
|
31
|
+
@keydown=${host.__suppressFocusBack}
|
|
32
|
+
aria-valuemin="0"
|
|
33
|
+
aria-valuemax="100"
|
|
34
|
+
aria-valuetext="Busy">
|
|
35
|
+
<div>
|
|
36
|
+
<div class="busy-indicator-circle circle-animation-0"></div>
|
|
37
|
+
<div class="busy-indicator-circle circle-animation-1"></div>
|
|
38
|
+
<div class="busy-indicator-circle circle-animation-2"></div>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</div>`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return templateResult;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const enrichBusyIndicatorMetadata = UI5Element => {
|
|
48
|
+
UI5Element.metadata = merge(UI5Element.metadata, busyIndicatorMetadata);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const enrichBusyIndicatorMethods = UI5ElementPrototype => {
|
|
52
|
+
Object.defineProperties(UI5ElementPrototype, {
|
|
53
|
+
"__redirectFocus": { value: true, writable: true },
|
|
54
|
+
"__suppressFocusBack": {
|
|
55
|
+
get() {
|
|
56
|
+
const that = this;
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
handleEvent: e => {
|
|
60
|
+
if (isTabPrevious(e)) {
|
|
61
|
+
const beforeElem = that.shadowRoot.querySelector("[busy-indicator-before-span]");
|
|
62
|
+
that.__redirectFocus = false;
|
|
63
|
+
beforeElem.focus();
|
|
64
|
+
that.__redirectFocus = true;
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
capture: true,
|
|
68
|
+
passive: false,
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
"isOpenUI5Component": { get: () => { return true; } },
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
UI5ElementPrototype.__suppressFocusIn = function handleFocusIn() {
|
|
76
|
+
const busyIndicator = this.shadowRoot.querySelector("[busy-indicator]");
|
|
77
|
+
if (busyIndicator && this.__redirectFocus) {
|
|
78
|
+
busyIndicator.focus();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
UI5ElementPrototype.getDomRef = function getDomRef() {
|
|
83
|
+
// If a component set _getRealDomRef to its children, use the return value of this function
|
|
84
|
+
if (typeof this._getRealDomRef === "function") {
|
|
85
|
+
return this._getRealDomRef();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!this.shadowRoot || this.shadowRoot.children.length === 0) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const children = [...this.shadowRoot.children].filter(child => !["link", "style"].includes(child.localName));
|
|
93
|
+
|
|
94
|
+
if (children.length !== 1) {
|
|
95
|
+
console.warn(`The shadow DOM for ${this.constructor.getMetadata().getTag()} does not have a top level element, the getDomRef() method might not work as expected`); // eslint-disable-line
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (this.__isBusy) {
|
|
99
|
+
return children[0].querySelector(".busy-indicator-wrapper > :not([busy-indicator-before-span]):not(.busy-indicator-overlay):not(.busy-indicator-busy-area)");
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return children[0];
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const enrichBusyIndicatorSettings = UI5Element => {
|
|
107
|
+
enrichBusyIndicatorMetadata(UI5Element);
|
|
108
|
+
enrichBusyIndicatorMethods(UI5Element.prototype);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const OpenUI5Enablement = {
|
|
112
|
+
enrichBusyIndicatorSettings,
|
|
113
|
+
wrapTemplateResultInBusyMarkup,
|
|
114
|
+
getBusyIndicatorStyles,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export default OpenUI5Enablement;
|
|
118
|
+
|
|
119
|
+
registerFeature("OpenUI5Enablement", OpenUI5Enablement);
|