@ui5/webcomponents-base 1.2.3 → 1.3.1
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 +41 -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 +19 -2
- 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 +4 -4
- 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 +19 -2
- 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
|
@@ -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);
|
|
@@ -1,28 +1,46 @@
|
|
|
1
|
-
import { render } from "lit-html";
|
|
2
1
|
import {
|
|
2
|
+
render,
|
|
3
3
|
html,
|
|
4
4
|
svg,
|
|
5
|
-
|
|
6
|
-
} from "
|
|
5
|
+
} from "lit-html";
|
|
6
|
+
import { getFeature } from "../FeaturesRegistry.js";
|
|
7
|
+
|
|
8
|
+
const effectiveHtml = (...args) => {
|
|
9
|
+
const LitStatic = getFeature("LitStatic");
|
|
10
|
+
const fn = LitStatic ? LitStatic.html : html;
|
|
11
|
+
return fn(...args);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const effectiveSvg = (...args) => {
|
|
15
|
+
const LitStatic = getFeature("LitStatic");
|
|
16
|
+
const fn = LitStatic ? LitStatic.svg : svg;
|
|
17
|
+
return fn(...args);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const litRender = (templateResult, domNode, styleStrOrHrefsArr, forStaticArea, { host } = {}) => {
|
|
21
|
+
const OpenUI5Enablement = getFeature("OpenUI5Enablement");
|
|
22
|
+
if (OpenUI5Enablement && !forStaticArea) {
|
|
23
|
+
templateResult = OpenUI5Enablement.wrapTemplateResultInBusyMarkup(effectiveHtml, host, templateResult);
|
|
24
|
+
}
|
|
7
25
|
|
|
8
|
-
const litRender = (templateResult, domNode, styleStrOrHrefsArr, { host } = {}) => {
|
|
9
26
|
if (typeof styleStrOrHrefsArr === "string") {
|
|
10
|
-
templateResult =
|
|
27
|
+
templateResult = effectiveHtml`<style>${styleStrOrHrefsArr}</style>${templateResult}`;
|
|
11
28
|
} else if (Array.isArray(styleStrOrHrefsArr) && styleStrOrHrefsArr.length) {
|
|
12
|
-
templateResult =
|
|
29
|
+
templateResult = effectiveHtml`${styleStrOrHrefsArr.map(href => effectiveHtml`<link type="text/css" rel="stylesheet" href="${href}">`)}${templateResult}`;
|
|
13
30
|
}
|
|
14
31
|
render(templateResult, domNode, { host });
|
|
15
32
|
};
|
|
16
33
|
|
|
17
34
|
const scopeTag = (tag, tags, suffix) => {
|
|
18
|
-
const
|
|
19
|
-
|
|
35
|
+
const LitStatic = getFeature("LitStatic");
|
|
36
|
+
if (LitStatic) {
|
|
37
|
+
return LitStatic.unsafeStatic((tags || []).includes(tag) ? `${tag}-${suffix}` : tag);
|
|
38
|
+
}
|
|
20
39
|
};
|
|
21
40
|
|
|
22
41
|
export {
|
|
23
|
-
html,
|
|
24
|
-
svg,
|
|
25
|
-
unsafeStatic,
|
|
42
|
+
effectiveHtml as html,
|
|
43
|
+
effectiveSvg as svg,
|
|
26
44
|
};
|
|
27
45
|
export { scopeTag };
|
|
28
46
|
export { repeat } from "lit-html/directives/repeat.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getCustomElementsScopingSuffix, shouldScopeCustomElement } from "../
|
|
1
|
+
import { getCustomElementsScopingSuffix, shouldScopeCustomElement } from "../CustomElementsScopeUtils.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Runs a component's template with the component's current state, while also scoping HTML
|
|
@@ -9,9 +9,26 @@ import { getCustomElementsScopingSuffix, shouldScopeCustomElement } from "../Cus
|
|
|
9
9
|
* @returns {*}
|
|
10
10
|
*/
|
|
11
11
|
const executeTemplate = (template, component) => {
|
|
12
|
-
const tagsToScope = component
|
|
12
|
+
const tagsToScope = getTagsToScope(component);
|
|
13
13
|
const scope = getCustomElementsScopingSuffix();
|
|
14
14
|
return template(component, tagsToScope, scope);
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Returns all tags, used inside component's template subject to scoping.
|
|
19
|
+
* @param component - the component
|
|
20
|
+
* @returns {Array[]}
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
const getTagsToScope = component => {
|
|
24
|
+
const componentTag = component.constructor.getMetadata().getPureTag();
|
|
25
|
+
const tagsToScope = component.constructor.getUniqueDependencies().map(dep => dep.getMetadata().getPureTag()).filter(shouldScopeCustomElement);
|
|
26
|
+
|
|
27
|
+
if (shouldScopeCustomElement(componentTag)) {
|
|
28
|
+
tagsToScope.push(componentTag);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return tagsToScope;
|
|
32
|
+
};
|
|
33
|
+
|
|
17
34
|
export default executeTemplate;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getUrl } from "../CSP.js";
|
|
2
|
+
import { getFeature } from "../FeaturesRegistry.js";
|
|
2
3
|
|
|
3
4
|
const flatten = arr => {
|
|
4
5
|
return arr.reduce((acc, val) => acc.concat(Array.isArray(val) ? flatten(val) : val), []);
|
|
@@ -6,6 +7,8 @@ const flatten = arr => {
|
|
|
6
7
|
|
|
7
8
|
const getEffectiveLinksHrefs = (ElementClass, forStaticArea = false) => {
|
|
8
9
|
let stylesData = ElementClass[forStaticArea ? "staticAreaStyles" : "styles"];
|
|
10
|
+
const OpenUI5Enablement = getFeature("OpenUI5Enablement");
|
|
11
|
+
|
|
9
12
|
if (!stylesData) {
|
|
10
13
|
return;
|
|
11
14
|
}
|
|
@@ -14,6 +17,10 @@ const getEffectiveLinksHrefs = (ElementClass, forStaticArea = false) => {
|
|
|
14
17
|
stylesData = [stylesData];
|
|
15
18
|
}
|
|
16
19
|
|
|
20
|
+
if (OpenUI5Enablement) {
|
|
21
|
+
stylesData.push(OpenUI5Enablement.getBusyIndicatorStyles());
|
|
22
|
+
}
|
|
23
|
+
|
|
17
24
|
return flatten(stylesData).filter(data => !!data).map(data => getUrl(data.packageName, data.fileName));
|
|
18
25
|
};
|
|
19
26
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getCustomCSS, attachCustomCSSChange } from "./CustomStyle.js";
|
|
2
2
|
import getStylesString from "./getStylesString.js";
|
|
3
|
+
import { getFeature } from "../FeaturesRegistry.js";
|
|
3
4
|
|
|
4
5
|
const effectiveStyleMap = new Map();
|
|
5
6
|
|
|
@@ -10,9 +11,15 @@ attachCustomCSSChange(tag => {
|
|
|
10
11
|
const getEffectiveStyle = (ElementClass, forStaticArea = false) => {
|
|
11
12
|
const tag = ElementClass.getMetadata().getTag();
|
|
12
13
|
const key = `${tag}_${forStaticArea ? "static" : "normal"}`;
|
|
14
|
+
const OpenUI5Enablement = getFeature("OpenUI5Enablement");
|
|
13
15
|
|
|
14
16
|
if (!effectiveStyleMap.has(key)) {
|
|
15
17
|
let effectiveStyle;
|
|
18
|
+
let busyIndicatorStyles = "";
|
|
19
|
+
|
|
20
|
+
if (OpenUI5Enablement) {
|
|
21
|
+
busyIndicatorStyles = getStylesString(OpenUI5Enablement.getBusyIndicatorStyles());
|
|
22
|
+
}
|
|
16
23
|
|
|
17
24
|
if (forStaticArea) {
|
|
18
25
|
effectiveStyle = getStylesString(ElementClass.staticAreaStyles);
|
|
@@ -21,6 +28,8 @@ const getEffectiveStyle = (ElementClass, forStaticArea = false) => {
|
|
|
21
28
|
const builtInStyles = getStylesString(ElementClass.styles);
|
|
22
29
|
effectiveStyle = `${builtInStyles} ${customStyle}`;
|
|
23
30
|
}
|
|
31
|
+
|
|
32
|
+
effectiveStyle = `${effectiveStyle} ${busyIndicatorStyles}`;
|
|
24
33
|
effectiveStyleMap.set(key, effectiveStyle);
|
|
25
34
|
}
|
|
26
35
|
|
package/src/updateShadowRoot.js
CHANGED
|
@@ -24,7 +24,7 @@ const updateShadowRoot = (element, forStaticArea = false) => {
|
|
|
24
24
|
styleStrOrHrefsArr = getEffectiveStyle(element.constructor, forStaticArea);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
element.constructor.render(renderResult, shadowRoot, styleStrOrHrefsArr, { host: element });
|
|
27
|
+
element.constructor.render(renderResult, shadowRoot, styleStrOrHrefsArr, forStaticArea, { host: element });
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export default updateShadowRoot;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the normalized event target in cases when it has shadow root.
|
|
3
|
+
* @param {Object} target The original event target
|
|
4
|
+
* @returns {Object} The normalized target
|
|
5
|
+
*/
|
|
6
|
+
const getNormalizedTarget = target => {
|
|
7
|
+
let element = target;
|
|
8
|
+
|
|
9
|
+
if (target.shadowRoot && target.shadowRoot.activeElement) {
|
|
10
|
+
element = target.shadowRoot.activeElement;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return element;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default getNormalizedTarget;
|