@ui5/webcomponents-base 1.2.6 → 1.4.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 +27 -3
- 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/asset-registries/Themes.js +6 -2
- package/dist/config/Icons.js +52 -0
- package/dist/css/BusyIndicator.css +80 -0
- package/dist/css/FontFace.css +16 -16
- 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/generated/css/FontFace.css.js +1 -1
- 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/sap/ui/thirdparty/caja-html-sanitizer.js +1 -1
- package/dist/test-resources/specs/Theming.spec.js +11 -0
- 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/lib/generate-asset-parameters/index.js +8 -4
- package/lib/generate-styles/index.js +17 -9
- package/lib/generate-version-info/index.js +18 -13
- package/package-scripts.js +2 -11
- package/package.json +6 -6
- 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/asset-registries/Themes.js +6 -2
- package/src/config/Icons.js +52 -0
- package/src/css/BusyIndicator.css +80 -0
- package/src/css/FontFace.css +16 -16
- 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
|
@@ -1989,7 +1989,7 @@ if (typeof window !== 'undefined') {
|
|
|
1989
1989
|
}
|
|
1990
1990
|
/*!
|
|
1991
1991
|
* OpenUI5
|
|
1992
|
-
* (c) Copyright 2009-
|
|
1992
|
+
* (c) Copyright 2009-2022 SAP SE or an SAP affiliate company.
|
|
1993
1993
|
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
|
|
1994
1994
|
*/
|
|
1995
1995
|
// Based on coding from the HTML4 Sanitizer by Google Inc.
|
|
@@ -30,4 +30,15 @@ describe("Theming works", () => {
|
|
|
30
30
|
assert.strictEqual(res, true, "Theme parameters changed");
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
+
it("Tests fallback to default theme when setting unknown theme", async () => {
|
|
34
|
+
const unknownTheme = 'sap_unknown_theme';
|
|
35
|
+
await browser.url(`http://localhost:9191/test-resources/pages/AllTestElements.html?sap-ui-theme=${unknownTheme}`);
|
|
36
|
+
|
|
37
|
+
const res = await browser.executeAsync( async (done) => {
|
|
38
|
+
const cssVarValue = getComputedStyle(document.documentElement).getPropertyValue('--var1');
|
|
39
|
+
done(cssVarValue);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
assert.strictEqual(res, ' red', "Default theme parameters loaded");
|
|
43
|
+
});
|
|
33
44
|
});
|
|
@@ -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/dist/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;
|
package/hash.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
XeoUDYYqmjUwnJg4dGNgbPltSMo=
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const mkdirp = require('mkdirp');
|
|
1
|
+
const fs = require('fs').promises;
|
|
3
2
|
const assets = require('@ui5/webcomponents-tools/assets-meta.js');
|
|
4
3
|
|
|
5
4
|
const fileContent = `const assetParameters = ${JSON.stringify(assets)};
|
|
@@ -16,6 +15,11 @@ export {
|
|
|
16
15
|
SUPPORTED_LOCALES,
|
|
17
16
|
};`;
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
fs.
|
|
18
|
+
const generate = async () => {
|
|
19
|
+
await fs.mkdir("dist/generated/", { recursive: true });
|
|
20
|
+
return fs.writeFile("dist/generated/AssetParameters.js", fileContent);
|
|
21
|
+
}
|
|
21
22
|
|
|
23
|
+
generate().then(() => {
|
|
24
|
+
console.log("Assets parameters generated.");
|
|
25
|
+
});
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
1
|
+
const fs = require('fs').promises;
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const mkdirp = require('mkdirp');
|
|
4
3
|
const CleanCSS = require('clean-css');
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
fs.
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
5
|
+
const generate = async () => {
|
|
6
|
+
await fs.mkdir("dist/generated/css/");
|
|
7
|
+
|
|
8
|
+
const files = (await fs.readdir("src/css/")).filter(file => file.endsWith(".css"));
|
|
9
|
+
const filesPromises = files.map(async file => {
|
|
10
|
+
let content = await fs.readFile(path.join("src/css/", file));
|
|
11
|
+
const res = new CleanCSS().minify(`${content}`);
|
|
12
|
+
content = `export default {
|
|
11
13
|
packageName: "@ui5/webcomponents-base",
|
|
12
14
|
fileName: "${file}",
|
|
13
15
|
content: \`${res.styles}\`
|
|
14
16
|
};`;
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
+
return fs.writeFile(path.join("dist/generated/css/", `${file}.js`), content);
|
|
19
|
+
});
|
|
18
20
|
|
|
21
|
+
return Promise.all(filesPromises);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
generate().then(() => {
|
|
25
|
+
console.log("Styles files generated.");
|
|
26
|
+
});
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const mkdirp = require('mkdirp');
|
|
1
|
+
const fs = require('fs').promises;
|
|
3
2
|
|
|
4
|
-
const
|
|
3
|
+
const generate = async () => {
|
|
4
|
+
const version = JSON.parse(await fs.readFile("package.json")).version;
|
|
5
5
|
|
|
6
|
-
// Parse version
|
|
7
|
-
const matches = version.match(/^([0-9]+)\.([0-9]+)\.([0-9]+)(.*)$/);
|
|
8
|
-
if (!matches) {
|
|
9
|
-
|
|
10
|
-
}
|
|
6
|
+
// Parse version
|
|
7
|
+
const matches = version.match(/^([0-9]+)\.([0-9]+)\.([0-9]+)(.*)$/);
|
|
8
|
+
if (!matches) {
|
|
9
|
+
throw new Error("Unsupported version format");
|
|
10
|
+
}
|
|
11
11
|
|
|
12
|
-
const isNext = version.match(/[a-f0-9]{9}$/);
|
|
13
|
-
const buildTime = Math.floor(new Date().getTime() / 1000);
|
|
12
|
+
const isNext = version.match(/[a-f0-9]{9}$/);
|
|
13
|
+
const buildTime = Math.floor(new Date().getTime() / 1000);
|
|
14
14
|
|
|
15
|
-
const fileContent = `const VersionInfo = {
|
|
15
|
+
const fileContent = `const VersionInfo = {
|
|
16
16
|
version: "${version}",
|
|
17
17
|
major: ${matches[1]},
|
|
18
18
|
minor: ${matches[2]},
|
|
@@ -23,5 +23,10 @@ const fileContent = `const VersionInfo = {
|
|
|
23
23
|
};
|
|
24
24
|
export default VersionInfo;`;
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
fs.
|
|
26
|
+
await fs.mkdir("dist/generated/", { recursive: true });
|
|
27
|
+
await fs.writeFile("dist/generated/VersionInfo.js", fileContent);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
generate().then(() => {
|
|
31
|
+
console.log("Version info file generated.");
|
|
32
|
+
});
|
package/package-scripts.js
CHANGED
|
@@ -4,26 +4,18 @@ const assetParametersScript = resolve.sync("@ui5/webcomponents-base/lib/generate
|
|
|
4
4
|
const stylesScript = resolve.sync("@ui5/webcomponents-base/lib/generate-styles/index.js");
|
|
5
5
|
const versionScript = resolve.sync("@ui5/webcomponents-base/lib/generate-version-info/index.js");
|
|
6
6
|
const serve = resolve.sync("@ui5/webcomponents-tools/lib/serve/index.js");
|
|
7
|
-
const generateHash = resolve.sync("@ui5/webcomponents-tools/lib/hash/generate.js");
|
|
8
|
-
const hashIsUpToDate = resolve.sync("@ui5/webcomponents-tools/lib/hash/upToDate.js");
|
|
9
7
|
const copyUsedModules = resolve.sync("@ui5/webcomponents-tools/lib/copy-list/index.js");
|
|
10
|
-
const replaceGlobalCore = resolve.sync("@ui5/webcomponents-tools/lib/replace-global-core/index.js");
|
|
11
8
|
const esmAbsToRel = resolve.sync("@ui5/webcomponents-tools/lib/esm-abs-to-rel/index.js");
|
|
12
|
-
const UP_TO_DATE = `node "${hashIsUpToDate}" dist/ hash.txt && echo "Up to date."`;
|
|
13
9
|
|
|
14
10
|
const scripts = {
|
|
15
11
|
clean: "rimraf dist && rimraf .port",
|
|
16
12
|
lint: "eslint . --config config/.eslintrc.js",
|
|
17
13
|
prepare: "nps clean integrate copy generateAssetParameters generateVersionInfo generateStyles",
|
|
18
14
|
integrate: {
|
|
19
|
-
default: "nps integrate.copy-used-modules integrate.
|
|
15
|
+
default: "nps integrate.copy-used-modules integrate.replace-amd integrate.amd-to-es6 integrate.esm-abs-to-rel integrate.third-party",
|
|
20
16
|
"copy-used-modules": `node "${copyUsedModules}" ./used-modules.txt dist/`,
|
|
21
|
-
"copy-overlay": `copy-and-watch "overlay/**/*.js" dist/`,
|
|
22
17
|
"replace-amd": "replace-in-file sap.ui.define define dist/**/*.js",
|
|
23
|
-
"replace-export-true": `replace-in-file ", /* bExport= */ true" "" dist/**/*.js`,
|
|
24
|
-
"replace-export-false": `replace-in-file ", /* bExport= */ false" "" dist/**/*.js`,
|
|
25
18
|
"amd-to-es6": "amdtoes6 --src=dist/ --replace --glob=**/*.js",
|
|
26
|
-
"replace-global-core-usage": `node "${replaceGlobalCore}" dist/`,
|
|
27
19
|
"esm-abs-to-rel": `node "${esmAbsToRel}" dist/ dist/`,
|
|
28
20
|
"third-party": {
|
|
29
21
|
default: "nps integrate.third-party.copy integrate.third-party.fix",
|
|
@@ -32,7 +24,7 @@ const scripts = {
|
|
|
32
24
|
},
|
|
33
25
|
},
|
|
34
26
|
build: {
|
|
35
|
-
default:
|
|
27
|
+
default: `nps lint prepare build.bundle`,
|
|
36
28
|
bundle: "rollup --config config/rollup.config.js",
|
|
37
29
|
},
|
|
38
30
|
copy: {
|
|
@@ -58,7 +50,6 @@ const scripts = {
|
|
|
58
50
|
default: 'concurrently "nps serve" "nps test.run" --kill-others --success first',
|
|
59
51
|
run: "cross-env WDIO_LOG_LEVEL=error FORCE_COLOR=0 wdio config/wdio.conf.js",
|
|
60
52
|
},
|
|
61
|
-
hash: `node "${generateHash}" dist/ hash.txt`,
|
|
62
53
|
};
|
|
63
54
|
|
|
64
55
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui5/webcomponents-base",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "UI5 Web Components: webcomponents.base",
|
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,19 +28,19 @@
|
|
|
28
28
|
"start": "nps start",
|
|
29
29
|
"build": "nps build",
|
|
30
30
|
"test": "nps test",
|
|
31
|
-
"hash": "nps hash",
|
|
32
31
|
"prepublishOnly": "npm run clean && npm run build"
|
|
33
32
|
},
|
|
34
33
|
"dependencies": {
|
|
35
|
-
"lit-html": "2.0.1"
|
|
34
|
+
"lit-html": "^2.0.1"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
37
|
"@buxlabs/amd-to-es6": "0.16.1",
|
|
39
|
-
"@openui5/sap.ui.core": "1.
|
|
40
|
-
"@ui5/webcomponents-tools": "1.
|
|
41
|
-
"chromedriver": "
|
|
38
|
+
"@openui5/sap.ui.core": "1.101.0",
|
|
39
|
+
"@ui5/webcomponents-tools": "1.4.0",
|
|
40
|
+
"chromedriver": "101.0.0",
|
|
42
41
|
"clean-css": "^5.2.2",
|
|
43
42
|
"copy-and-watch": "^0.1.5",
|
|
43
|
+
"cross-env": "^7.0.3",
|
|
44
44
|
"eslint": "^7.22.0",
|
|
45
45
|
"mkdirp": "^1.0.4",
|
|
46
46
|
"resolve": "^1.20.0"
|
|
@@ -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/src/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/src/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/src/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/src/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
|
*
|