@ui5/create-webcomponents-package 0.0.0-ee3bbe46b → 0.0.0-f24ff9019
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 +428 -0
- package/README.md +30 -7
- package/create-package.js +271 -0
- package/package.json +4 -3
- package/template/.eslintignore +3 -0
- package/template/.eslintrc.js +5 -0
- package/template/gitignore +4 -0
- package/template/npmrc +2 -0
- package/template/package-scripts.js +2 -1
- package/template/src/Assets.ts +5 -0
- package/template/src/MyFirstComponent.hbs +1 -1
- package/template/src/MyFirstComponent.js +20 -5
- package/template/src/MyFirstComponent.ts +63 -0
- package/template/src/i18n/messagebundle.properties +3 -2
- package/template/src/i18n/messagebundle_de.properties +1 -1
- package/template/src/i18n/messagebundle_en.properties +1 -1
- package/template/src/i18n/messagebundle_es.properties +1 -1
- package/template/src/i18n/messagebundle_fr.properties +1 -1
- package/template/src/themes/MyFirstComponent.css +14 -9
- package/template/src/themes/sap_fiori_3/parameters-bundle.css +1 -1
- package/template/src/themes/sap_horizon_dark/parameters-bundle.css +3 -0
- package/template/src/themes/sap_horizon_hcb/parameters-bundle.css +3 -0
- package/template/test/pages/css/index.css +36 -0
- package/template/test/pages/img/logo.png +0 -0
- package/template/test/pages/index.html +35 -30
- package/template/test/specs/Demo.spec.js +3 -2
- package/template/tsconfig.json +15 -0
- package/index.js +0 -169
- package/template/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
- package/template/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
- package/template/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
- package/template/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
- /package/template/src/themes/{sap_belize → sap_horizon}/parameters-bundle.css +0 -0
- /package/template/src/themes/{sap_belize_hcb → sap_horizon_hcw}/parameters-bundle.css +0 -0
@@ -0,0 +1,271 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
const fs = require("fs");
|
4
|
+
const path = require("path");
|
5
|
+
const mkdirp = require("mkdirp");
|
6
|
+
const prompts = require("prompts");
|
7
|
+
const parser = require("npm-config-user-agent-parser");
|
8
|
+
const yargs = require("yargs/yargs");
|
9
|
+
const { hideBin } = require("yargs/helpers");
|
10
|
+
|
11
|
+
const argv = yargs(hideBin(process.argv)).argv;
|
12
|
+
|
13
|
+
const version = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"))).version;
|
14
|
+
|
15
|
+
// from where all the files will be copied
|
16
|
+
const TEMPLATE_DIR = path.join(`${__dirname}`, `template/`);
|
17
|
+
|
18
|
+
// String utils
|
19
|
+
const isTSRelatedFile = sourcePath => {
|
20
|
+
return ["Assets.ts", "MyFirstComponent.ts", "tsconfig.json", "global.d.ts"].some(fileName => sourcePath.includes(fileName));
|
21
|
+
};
|
22
|
+
const isJSRelatedFile = sourcePath => {
|
23
|
+
return ["Assets.js", "MyFirstComponent.js"].some(fileName => sourcePath.includes(fileName));
|
24
|
+
};
|
25
|
+
const isGitIgnore = sourcePath => {
|
26
|
+
return sourcePath.includes("gitignore");
|
27
|
+
};
|
28
|
+
const isLogo = sourcePath => {
|
29
|
+
return sourcePath.includes("logo");
|
30
|
+
};
|
31
|
+
const isNPMRC = sourcePath => {
|
32
|
+
return sourcePath.includes("npmrc");
|
33
|
+
};
|
34
|
+
|
35
|
+
// Validation of user input
|
36
|
+
const ComponentNamePattern = /^[A-Z][A-Za-z0-9]+$/;
|
37
|
+
const NamespacePattern = /^[a-z][a-z0-9\.\-]+$/;
|
38
|
+
const isPackageNameValid = name => typeof name === "string" && name.match(/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/);
|
39
|
+
const isComponentNameValid = name => typeof name === "string" && ComponentNamePattern.test(name);
|
40
|
+
const isNamespaceValid = name => typeof name === "string" && NamespacePattern.test(name);
|
41
|
+
const isTagValid = tag => typeof tag === "string" && tag.match(/^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/);
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Hyphanates the given PascalCase string, f.e.:
|
45
|
+
* Foo -> "my-foo" (adds preffix)
|
46
|
+
* FooBar -> "foo-bar"
|
47
|
+
*/
|
48
|
+
const hyphaneteComponentName = (componentName) => {
|
49
|
+
const result = componentName.replace(/([a-z])([A-Z])/g, '$1-$2' ).toLowerCase();
|
50
|
+
|
51
|
+
return result.includes("-") ? result : `my-${result}`;
|
52
|
+
};
|
53
|
+
|
54
|
+
// Utils for building the file structure
|
55
|
+
const replaceVarsInFileContent = (vars, content) => {
|
56
|
+
for (let key in vars) {
|
57
|
+
const re = new RegExp(key, "g");
|
58
|
+
content = content.replace(re, vars[key]);
|
59
|
+
}
|
60
|
+
return content;
|
61
|
+
};
|
62
|
+
|
63
|
+
const replaceVarsInFileName = (vars, fileName) => {
|
64
|
+
return fileName.replace(/MyFirstComponent/, vars.INIT_PACKAGE_VAR_CLASS_NAME);
|
65
|
+
};
|
66
|
+
|
67
|
+
const copyFile = (vars, sourcePath, destPath) => {
|
68
|
+
const ignoreJsRelated = vars.INIT_PACKAGE_VAR_TYPESCRIPT && isJSRelatedFile(sourcePath);
|
69
|
+
const ignoreTsRelated = !vars.INIT_PACKAGE_VAR_TYPESCRIPT && isTSRelatedFile(sourcePath);
|
70
|
+
|
71
|
+
if (ignoreJsRelated || ignoreTsRelated) {
|
72
|
+
return;
|
73
|
+
}
|
74
|
+
|
75
|
+
if (isLogo(sourcePath)) {
|
76
|
+
fs.copyFileSync(sourcePath, destPath);
|
77
|
+
return;
|
78
|
+
}
|
79
|
+
|
80
|
+
let content = fs.readFileSync(sourcePath, { encoding: "UTF-8" });
|
81
|
+
content = replaceVarsInFileContent(vars, content);
|
82
|
+
destPath = replaceVarsInFileName(vars, destPath);
|
83
|
+
|
84
|
+
fs.writeFileSync(destPath, content);
|
85
|
+
|
86
|
+
// Rename "gitignore" to ".gitignore" (npm init won't include ".gitignore", so we add it as "gitignore" and rename it later)
|
87
|
+
if (isGitIgnore(sourcePath)) {
|
88
|
+
fs.renameSync(destPath, destPath.replace("gitignore", ".gitignore"))
|
89
|
+
}
|
90
|
+
|
91
|
+
// Rename "npmrc" to ".npmrc" (npm init won't include ".npmrc", so we add it as "npmrc" and rename it later)
|
92
|
+
if (isNPMRC(sourcePath)) {
|
93
|
+
fs.renameSync(destPath, destPath.replace("npmrc", ".npmrc"));
|
94
|
+
}
|
95
|
+
};
|
96
|
+
|
97
|
+
const copyFiles = (vars, sourcePath, destPath) => {
|
98
|
+
const isDir = fs.lstatSync(sourcePath).isDirectory();
|
99
|
+
if (isDir) {
|
100
|
+
if (destPath) {
|
101
|
+
mkdirp.sync(destPath);
|
102
|
+
}
|
103
|
+
fs.readdirSync(sourcePath).forEach(file => {
|
104
|
+
copyFiles(vars, path.join(sourcePath, file), path.join(destPath, file));
|
105
|
+
});
|
106
|
+
} else {
|
107
|
+
copyFile(vars, sourcePath, destPath);
|
108
|
+
}
|
109
|
+
};
|
110
|
+
|
111
|
+
const generateFilesContent = (packageName, componentName, namespace, typescript, skipSubfolder) => {
|
112
|
+
const tagName = argv.tag || hyphaneteComponentName(componentName);
|
113
|
+
|
114
|
+
// All variables that will be replaced in the content of the resources/
|
115
|
+
const vars = {
|
116
|
+
INIT_PACKAGE_VAR_NAMESPACE: namespace, // namespace must be replaced before name
|
117
|
+
INIT_PACKAGE_VAR_NAME: packageName,
|
118
|
+
INIT_PACKAGE_VAR_TAG: tagName,
|
119
|
+
INIT_PACKAGE_VAR_CLASS_NAME: componentName,
|
120
|
+
INIT_PACKAGE_VAR_TYPESCRIPT: typescript,
|
121
|
+
};
|
122
|
+
|
123
|
+
const packageContent = {
|
124
|
+
name: packageName,
|
125
|
+
version: "0.0.1",
|
126
|
+
ui5: {
|
127
|
+
webComponentsPackage: true,
|
128
|
+
},
|
129
|
+
scripts: {
|
130
|
+
"clean": "wc-dev clean",
|
131
|
+
"lint": "wc-dev lint",
|
132
|
+
"start": "wc-dev start",
|
133
|
+
"watch": "wc-dev watch",
|
134
|
+
"build": "wc-dev build",
|
135
|
+
"test": "wc-dev test",
|
136
|
+
"create-ui5-element": "wc-create-ui5-element",
|
137
|
+
"prepublishOnly": "npm run build",
|
138
|
+
},
|
139
|
+
exports: {
|
140
|
+
"./src/*": "./src/*",
|
141
|
+
"./dist/*": "./dist/*",
|
142
|
+
"./package.json": "./package.json",
|
143
|
+
"./bundle.js": "./bundle.js",
|
144
|
+
"./*": "./dist/*",
|
145
|
+
},
|
146
|
+
"dependencies": {
|
147
|
+
"@ui5/webcomponents-base": version,
|
148
|
+
"@ui5/webcomponents-theming": version,
|
149
|
+
},
|
150
|
+
"devDependencies": {
|
151
|
+
"@ui5/webcomponents-tools": version,
|
152
|
+
"chromedriver": "*",
|
153
|
+
},
|
154
|
+
};
|
155
|
+
|
156
|
+
if (typescript) {
|
157
|
+
packageContent.devDependencies.typescript = "^4.9.4";
|
158
|
+
}
|
159
|
+
|
160
|
+
// Update package.json
|
161
|
+
let destDir = packageName.includes("@") ? packageName.slice(packageName.lastIndexOf("/") + 1) : packageName;
|
162
|
+
|
163
|
+
destDir = skipSubfolder ? path.join("./") : path.join("./", destDir);
|
164
|
+
mkdirp.sync(destDir);
|
165
|
+
fs.writeFileSync(path.join(destDir, "package.json"), JSON.stringify(packageContent, null, 2));
|
166
|
+
// Copy files
|
167
|
+
copyFiles(vars, TEMPLATE_DIR, destDir);
|
168
|
+
|
169
|
+
console.log("\nPackage successfully created!\nNext steps:\n");
|
170
|
+
console.log(`$ cd ${destDir}`);
|
171
|
+
|
172
|
+
let userAgentInfo;
|
173
|
+
try {
|
174
|
+
userAgentInfo = parser(process.env.npm_config_user_agent);
|
175
|
+
} catch (e) {}
|
176
|
+
|
177
|
+
if (userAgentInfo && userAgentInfo.yarn) {
|
178
|
+
console.log(`$ yarn`);
|
179
|
+
console.log(`$ yarn start`);
|
180
|
+
} else {
|
181
|
+
console.log(`$ npm i`);
|
182
|
+
console.log(`$ npm start`);
|
183
|
+
}
|
184
|
+
|
185
|
+
console.log("\n");
|
186
|
+
};
|
187
|
+
|
188
|
+
// Main function
|
189
|
+
const createWebcomponentsPackage = async () => {
|
190
|
+
let response;
|
191
|
+
if (argv.name && !isPackageNameValid(argv.name)) {
|
192
|
+
throw new Error("The package name should be a string, starting with letter and containing the following symbols [a-z, A-Z, 0-9].");
|
193
|
+
}
|
194
|
+
|
195
|
+
if (argv.componentName && !isComponentNameValid(argv.componentName)) {
|
196
|
+
throw new Error("The component name should be a string, starting with a capital letter [A-Z][a-z], for example: Button, MyButton, etc.");
|
197
|
+
}
|
198
|
+
|
199
|
+
if (argv.namespace && !isNamespaceValid(argv.namespace)) {
|
200
|
+
throw new Error("The JSDoc namespace must start with a letter and can only contain small-case letters, numbers, dots and dashes.");
|
201
|
+
}
|
202
|
+
|
203
|
+
if (argv.tag && !isTagValid(argv.tag) ) {
|
204
|
+
throw new Error("The tag should be in kebab-case (f.e my-component) and it can't be a single word.");
|
205
|
+
}
|
206
|
+
|
207
|
+
let packageName = argv.name || "my-package";
|
208
|
+
let componentName = argv.componentName || "MyComponent";
|
209
|
+
let namespace = argv.namespace || "demo.components";
|
210
|
+
let typescriptSupport = !!argv.enableTypescript;
|
211
|
+
const skipSubfolder = !!argv.skipSubfolder;
|
212
|
+
|
213
|
+
if (argv.skip) {
|
214
|
+
return generateFilesContent(packageName, componentName, namespace, typescriptSupport, skipSubfolder);
|
215
|
+
}
|
216
|
+
|
217
|
+
if (!argv.name) {
|
218
|
+
response = await prompts({
|
219
|
+
type: "text",
|
220
|
+
name: "name",
|
221
|
+
message: "Package name:",
|
222
|
+
validate: (value) => isPackageNameValid(value) ? true : "Package name should be a string, starting with a letter and containing the following symbols [a-z, A-Z ,0-9, _, -].",
|
223
|
+
});
|
224
|
+
packageName = response.name;
|
225
|
+
}
|
226
|
+
|
227
|
+
if (!typescriptSupport) {
|
228
|
+
response = await prompts({
|
229
|
+
type: "select",
|
230
|
+
name: "language",
|
231
|
+
message: "Project type:",
|
232
|
+
choices: [
|
233
|
+
{
|
234
|
+
title: "JavaScript",
|
235
|
+
value: false,
|
236
|
+
},
|
237
|
+
{
|
238
|
+
title: "TypeScript",
|
239
|
+
value: true,
|
240
|
+
},
|
241
|
+
],
|
242
|
+
});
|
243
|
+
typescriptSupport = response.language;
|
244
|
+
}
|
245
|
+
|
246
|
+
if (!argv.componentName) {
|
247
|
+
response = await prompts({
|
248
|
+
type: "text",
|
249
|
+
name: "componentName",
|
250
|
+
message: "Component name:",
|
251
|
+
initial: "MyComponent",
|
252
|
+
validate: (value) => isComponentNameValid(value) ? true : "Component name should follow PascalCase naming convention (f.e. Button, MyButton, etc.).",
|
253
|
+
});
|
254
|
+
componentName = response.componentName;
|
255
|
+
}
|
256
|
+
|
257
|
+
if (!argv.namespace) {
|
258
|
+
response = await prompts({
|
259
|
+
type: "text",
|
260
|
+
name: "namespace",
|
261
|
+
message: "JSDoc namespace:",
|
262
|
+
initial: "demo.components",
|
263
|
+
validate: (value) => isNamespaceValid(value) ? true : "The JSDoc namespace must start with a letter and can only contain small-case letters, numbers, dots and dashes.",
|
264
|
+
});
|
265
|
+
namespace = response.namespace;
|
266
|
+
}
|
267
|
+
|
268
|
+
return generateFilesContent(packageName, componentName, namespace, typescriptSupport, skipSubfolder);
|
269
|
+
};
|
270
|
+
|
271
|
+
createWebcomponentsPackage();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/create-webcomponents-package",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-f24ff9019",
|
4
4
|
"description": "UI5 Web Components: create package",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -11,7 +11,7 @@
|
|
11
11
|
"ui5"
|
12
12
|
],
|
13
13
|
"bin": {
|
14
|
-
"create-webcomponents-package": "
|
14
|
+
"create-webcomponents-package": "create-package.js"
|
15
15
|
},
|
16
16
|
"repository": {
|
17
17
|
"type": "git",
|
@@ -21,6 +21,7 @@
|
|
21
21
|
"dependencies": {
|
22
22
|
"mkdirp": "^1.0.4",
|
23
23
|
"npm-config-user-agent-parser": "^1.0.0",
|
24
|
-
"prompts": "^2.4.1"
|
24
|
+
"prompts": "^2.4.1",
|
25
|
+
"yargs": "^17.5.1"
|
25
26
|
}
|
26
27
|
}
|
package/template/.eslintignore
CHANGED
@@ -0,0 +1,5 @@
|
|
1
|
+
const config = require("@ui5/webcomponents-tools/components-package/eslint.js");
|
2
|
+
|
3
|
+
// This eslint config is defined @ui5/webcomponents-tools,
|
4
|
+
// Feel free to override part of the configuration or provide entirely new config to fit your dev requirements.
|
5
|
+
module.exports = config;
|
package/template/npmrc
ADDED
@@ -1 +1 @@
|
|
1
|
-
<div>
|
1
|
+
<div @click="{{onClick}}">{{counterText}} :: {{count}}</div>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
|
2
2
|
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
|
3
3
|
import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
|
4
|
+
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js";
|
4
5
|
|
5
6
|
// Template
|
6
7
|
import INIT_PACKAGE_VAR_CLASS_NAMETemplate from "./generated/templates/INIT_PACKAGE_VAR_CLASS_NAMETemplate.lit.js";
|
@@ -8,14 +9,24 @@ import INIT_PACKAGE_VAR_CLASS_NAMETemplate from "./generated/templates/INIT_PACK
|
|
8
9
|
// Styles
|
9
10
|
import INIT_PACKAGE_VAR_CLASS_NAMECss from "./generated/themes/INIT_PACKAGE_VAR_CLASS_NAME.css.js";
|
10
11
|
|
11
|
-
import {
|
12
|
+
import { COUNT } from "./generated/i18n/i18n-defaults.js";
|
12
13
|
|
13
14
|
/**
|
14
15
|
* @public
|
15
16
|
*/
|
16
17
|
const metadata = {
|
17
18
|
tag: "INIT_PACKAGE_VAR_TAG",
|
18
|
-
properties: {
|
19
|
+
properties: /** @lends INIT_PACKAGE_VAR_NAMESPACE.INIT_PACKAGE_VAR_CLASS_NAME.prototype */ {
|
20
|
+
/**
|
21
|
+
* Defines the count of the component.
|
22
|
+
* @type { sap.ui.webc.base.types.Integer }
|
23
|
+
* @defaultvalue 0
|
24
|
+
* @public
|
25
|
+
*/
|
26
|
+
count: {
|
27
|
+
type: Integer,
|
28
|
+
defaultValue: 0,
|
29
|
+
},
|
19
30
|
},
|
20
31
|
slots: {
|
21
32
|
},
|
@@ -31,7 +42,7 @@ const metadata = {
|
|
31
42
|
* The <code>INIT_PACKAGE_VAR_TAG</code> component is a demo component that displays some text.
|
32
43
|
*
|
33
44
|
* @constructor
|
34
|
-
* @alias
|
45
|
+
* @alias INIT_PACKAGE_VAR_NAMESPACE.INIT_PACKAGE_VAR_CLASS_NAME
|
35
46
|
* @extends sap.ui.webc.base.UI5Element
|
36
47
|
* @tagname INIT_PACKAGE_VAR_TAG
|
37
48
|
* @public
|
@@ -57,8 +68,12 @@ class INIT_PACKAGE_VAR_CLASS_NAME extends UI5Element {
|
|
57
68
|
INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle = await getI18nBundle("INIT_PACKAGE_VAR_NAME");
|
58
69
|
}
|
59
70
|
|
60
|
-
|
61
|
-
|
71
|
+
onClick() {
|
72
|
+
this.count++;
|
73
|
+
}
|
74
|
+
|
75
|
+
get counterText() {
|
76
|
+
return INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle.getText(COUNT);
|
62
77
|
}
|
63
78
|
}
|
64
79
|
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
|
2
|
+
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
|
3
|
+
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
|
4
|
+
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
|
5
|
+
import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
|
6
|
+
import type I18nBundle from "@ui5/webcomponents-base/dist/i18nBundle.js";
|
7
|
+
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js";
|
8
|
+
|
9
|
+
// Template
|
10
|
+
import INIT_PACKAGE_VAR_CLASS_NAMETemplate from "./generated/templates/INIT_PACKAGE_VAR_CLASS_NAMETemplate.lit.js";
|
11
|
+
|
12
|
+
// Styles
|
13
|
+
import INIT_PACKAGE_VAR_CLASS_NAMECss from "./generated/themes/INIT_PACKAGE_VAR_CLASS_NAME.css.js";
|
14
|
+
|
15
|
+
import { COUNT } from "./generated/i18n/i18n-defaults.js";
|
16
|
+
|
17
|
+
/**
|
18
|
+
* @class
|
19
|
+
*
|
20
|
+
* <h3 class="comment-api-title">Overview</h3>
|
21
|
+
*
|
22
|
+
* The <code>INIT_PACKAGE_VAR_TAG</code> component is a demo component that displays some text.
|
23
|
+
*
|
24
|
+
* @constructor
|
25
|
+
* @alias INIT_PACKAGE_VAR_NAMESPACE.INIT_PACKAGE_VAR_CLASS_NAME
|
26
|
+
* @extends sap.ui.webc.base.UI5Element
|
27
|
+
* @tagname INIT_PACKAGE_VAR_TAG
|
28
|
+
* @public
|
29
|
+
*/
|
30
|
+
@customElement({
|
31
|
+
tag: "INIT_PACKAGE_VAR_TAG",
|
32
|
+
renderer: litRender,
|
33
|
+
styles: INIT_PACKAGE_VAR_CLASS_NAMECss,
|
34
|
+
template: INIT_PACKAGE_VAR_CLASS_NAMETemplate,
|
35
|
+
})
|
36
|
+
class INIT_PACKAGE_VAR_CLASS_NAME extends UI5Element {
|
37
|
+
static i18nBundle: I18nBundle;
|
38
|
+
|
39
|
+
static async onDefine() {
|
40
|
+
INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle = await getI18nBundle("INIT_PACKAGE_VAR_NAME");
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Defines the component count.
|
45
|
+
* @name INIT_PACKAGE_VAR_NAMESPACE.INIT_PACKAGE_VAR_CLASS_NAME.prototype.count
|
46
|
+
* @public
|
47
|
+
* @type { sap.ui.webc.base.types.Integer }
|
48
|
+
*/
|
49
|
+
@property({ validator: Integer, defaultValue: 0 })
|
50
|
+
count!: number;
|
51
|
+
|
52
|
+
onClick() {
|
53
|
+
this.count++;
|
54
|
+
}
|
55
|
+
|
56
|
+
get counterText() {
|
57
|
+
return INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle.getText(COUNT);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
INIT_PACKAGE_VAR_CLASS_NAME.define();
|
62
|
+
|
63
|
+
export default INIT_PACKAGE_VAR_CLASS_NAME;
|
@@ -1,2 +1,3 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# the "counter" text for the sample component
|
2
|
+
COUNT=Count
|
3
|
+
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
COUNT=Zählung
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
COUNT=Count
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
COUNT=Cuenta
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
COUNT=Comte
|
@@ -1,11 +1,16 @@
|
|
1
1
|
:host {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
display: inline-flex;
|
3
|
+
align-items: center;
|
4
|
+
justify-content: center;
|
5
|
+
flex-direction: column;
|
6
|
+
padding: 0 2rem;
|
7
|
+
color: var(--sapAvatar_6_TextColor);
|
8
|
+
background-color: var(--sapAvatar_6_Background);
|
9
|
+
border: 2px solid var(--my-component-border-color);
|
10
|
+
border-radius: 0.5rem;
|
11
|
+
box-shadow: var(--sapContent_Shadow0);
|
12
|
+
text-align: center;
|
13
|
+
line-height: 3rem;
|
14
|
+
font-size: 1.25rem;
|
15
|
+
user-select: none;
|
11
16
|
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
body {
|
2
|
+
color: var(--sapTextColor);
|
3
|
+
background-color: var(--sapBackgroundColor);
|
4
|
+
font-size: var(--sapFontSize);
|
5
|
+
font-family: var(--sapFontFamily);
|
6
|
+
}
|
7
|
+
|
8
|
+
h1 {
|
9
|
+
font-size: var(--sapFontHeader2Size);
|
10
|
+
margin-bottom: 0.5rem;
|
11
|
+
}
|
12
|
+
|
13
|
+
h2 {
|
14
|
+
font-size: var(--sapFontHeader3Size);
|
15
|
+
margin-bottom: 0.5rem;
|
16
|
+
}
|
17
|
+
|
18
|
+
.app, .app-settings, .app-docs, .app-first-component {
|
19
|
+
display: flex;
|
20
|
+
align-items: center;
|
21
|
+
justify-content: center;
|
22
|
+
flex-direction: column;
|
23
|
+
}
|
24
|
+
|
25
|
+
.app-first-component {
|
26
|
+
margin-bottom: 3rem;
|
27
|
+
}
|
28
|
+
|
29
|
+
.app-docs {
|
30
|
+
margin-top: 3rem;
|
31
|
+
}
|
32
|
+
|
33
|
+
a {
|
34
|
+
margin: 0.25rem;
|
35
|
+
color: var(--sapLinkColor);
|
36
|
+
}
|
Binary file
|
@@ -10,43 +10,48 @@
|
|
10
10
|
|
11
11
|
<script data-ui5-config type="application/json">
|
12
12
|
{
|
13
|
+
"theme": "sap_horizon_dark",
|
13
14
|
"language": "EN"
|
14
15
|
}
|
15
16
|
</script>
|
16
17
|
|
18
|
+
<link rel="stylesheet" type="text/css" href="./css/index.css">
|
17
19
|
<script src="../../bundle.esm.js" type="module"></script>
|
18
|
-
|
19
|
-
<style>
|
20
|
-
code { color: blue; font-size: small; }
|
21
|
-
</style>
|
22
|
-
|
23
20
|
</head>
|
24
21
|
|
25
22
|
<body>
|
26
|
-
<
|
27
|
-
|
28
|
-
|
29
|
-
<
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
23
|
+
<div class="app">
|
24
|
+
<a href="https://sap.github.io/ui5-webcomponents/playground/?path=/docs/docs-getting-started-first-steps--docs" target="_blank"><img src="./img/logo.png" alt="logo"/></a>
|
25
|
+
|
26
|
+
<div class="app-first-component">
|
27
|
+
<h1>Hooray! It's Your First Web Component!</h1>
|
28
|
+
<div> <pre><INIT_PACKAGE_VAR_TAG></INIT_PACKAGE_VAR_TAG> </pre></div>
|
29
|
+
<INIT_PACKAGE_VAR_TAG id="myFirstComponent"></INIT_PACKAGE_VAR_TAG>
|
30
|
+
</div>
|
31
|
+
|
32
|
+
<div class="app-settings">
|
33
|
+
|
34
|
+
<h2>Switch themes</h2>
|
35
|
+
<div style="display: flex; flex-direction: row;">
|
36
|
+
<a class="link" href="?sap-ui-theme=sap_horizon">Horizon</a>
|
37
|
+
<a class="link" href="?sap-ui-theme=sap_horizon_dark">Horizon Dark</a>
|
38
|
+
<a class="link" href="?sap-ui-theme=sap_horizon_hcb">Horizon High Contrast Black</a>
|
39
|
+
<a class="link" href="?sap-ui-theme=sap_horizon_hcw">Horizon High Contrast White</a>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<h2>Switch language</h2>
|
43
|
+
<div>
|
44
|
+
<a class="link" href="?sap-ui-language=en">English</a>
|
45
|
+
<a class="link" href="?sap-ui-language=de">German</a>
|
46
|
+
<a class="link" href="?sap-ui-language=es">Spanish</a>
|
47
|
+
<a class="link" href="?sap-ui-language=fr">French</a>
|
48
|
+
</div>
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div class="app-docs">
|
52
|
+
<h2>Documentation</h2>
|
53
|
+
<a class="link" href="https://sap.github.io/ui5-webcomponents/playground/?path=/docs/docs-development-custom-ui5-web-components-packages--docs">Custom Component Development</a>
|
54
|
+
</div>
|
55
|
+
</div>
|
50
56
|
</body>
|
51
|
-
|
52
57
|
</html>
|
@@ -1,10 +1,11 @@
|
|
1
1
|
const assert = require("assert");
|
2
2
|
|
3
3
|
describe("INIT_PACKAGE_VAR_TAG rendering", async () => {
|
4
|
-
|
4
|
+
before(async () => {
|
5
|
+
await browser.url("test/pages/index.html");
|
6
|
+
});
|
5
7
|
|
6
8
|
it("tests if web component is correctly rendered", async () => {
|
7
|
-
|
8
9
|
const innerContent = await browser.$("#myFirstComponent").shadow$("div");
|
9
10
|
|
10
11
|
assert.ok(innerContent, "content rendered");
|