@ui5/create-webcomponents-package 0.0.0-7a547f8cc → 0.0.0-7b7921cd9

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +159 -0
  2. package/README.md +2 -1
  3. package/create-package.js +89 -33
  4. package/package.json +1 -1
  5. package/template/.eslintignore +2 -1
  6. package/template/.eslintrc.js +5 -0
  7. package/template/gitignore +4 -0
  8. package/template/npmrc +2 -0
  9. package/template/src/MyFirstComponent.hbs +1 -1
  10. package/template/src/MyFirstComponent.js +18 -5
  11. package/template/src/MyFirstComponent.ts +24 -17
  12. package/template/src/i18n/messagebundle.properties +3 -2
  13. package/template/src/i18n/messagebundle_de.properties +1 -1
  14. package/template/src/i18n/messagebundle_en.properties +1 -1
  15. package/template/src/i18n/messagebundle_es.properties +1 -1
  16. package/template/src/i18n/messagebundle_fr.properties +1 -1
  17. package/template/src/themes/MyFirstComponent.css +10 -9
  18. package/template/src/themes/sap_fiori_3/parameters-bundle.css +1 -1
  19. package/template/src/themes/sap_horizon_dark/parameters-bundle.css +3 -0
  20. package/template/src/themes/sap_horizon_hcb/parameters-bundle.css +3 -0
  21. package/template/test/pages/css/index.css +36 -0
  22. package/template/test/pages/img/logo.png +0 -0
  23. package/template/test/pages/index.html +36 -31
  24. package/template/test/specs/Demo.spec.js +3 -2
  25. package/template/tsconfig.json +1 -0
  26. package/template/global.d.ts +0 -12
  27. package/template/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
  28. package/template/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
  29. package/template/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
  30. package/template/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
  31. /package/template/src/themes/{sap_belize → sap_horizon}/parameters-bundle.css +0 -0
  32. /package/template/src/themes/{sap_belize_hcb → sap_horizon_hcw}/parameters-bundle.css +0 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,165 @@
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.14.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.14.0-rc.0...v1.14.0-rc.1) (2023-05-25)
7
+
8
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
9
+
10
+
11
+
12
+
13
+
14
+ # [1.14.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.13.2...v1.14.0-rc.0) (2023-05-18)
15
+
16
+
17
+ ### Features
18
+
19
+ * users can provide a JSDoc namespeace when creating a package ([#7034](https://github.com/SAP/ui5-webcomponents/issues/7034)) ([0af8d23](https://github.com/SAP/ui5-webcomponents/commit/0af8d2376e25e5abe6d940c72286ab7c682eea56))
20
+
21
+
22
+
23
+
24
+
25
+ ## [1.13.1](https://github.com/SAP/ui5-webcomponents/compare/v1.13.0-rc.5...v1.13.1) (2023-05-11)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * **create-package:** revert `moduleResolution` setting to `node` ([#7020](https://github.com/SAP/ui5-webcomponents/issues/7020)) ([9fc84e2](https://github.com/SAP/ui5-webcomponents/commit/9fc84e288452616ee72f3a2b6fc31d9752f05f6f))
31
+
32
+
33
+
34
+
35
+
36
+ # [1.13.0-rc.5](https://github.com/SAP/ui5-webcomponents/compare/v1.13.0-rc.4...v1.13.0-rc.5) (2023-05-11)
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * **create-webcomponents-package:** fix package creation issues with test and lint ([#6976](https://github.com/SAP/ui5-webcomponents/issues/6976)) ([dd70f3a](https://github.com/SAP/ui5-webcomponents/commit/dd70f3aa8ef70b592f1d4e0f3f9894c6280fb1bf))
42
+
43
+
44
+
45
+
46
+
47
+ # [1.13.0-rc.4](https://github.com/SAP/ui5-webcomponents/compare/v1.13.0-rc.3...v1.13.0-rc.4) (2023-05-04)
48
+
49
+
50
+ ### Features
51
+
52
+ * generate TS from HBS templates ([#6558](https://github.com/SAP/ui5-webcomponents/issues/6558)) ([02611b2](https://github.com/SAP/ui5-webcomponents/commit/02611b2e24b2c2a06129b8e60a8bc680d9501e39))
53
+
54
+
55
+
56
+
57
+
58
+ # [1.13.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v1.13.0-rc.2...v1.13.0-rc.3) (2023-04-27)
59
+
60
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
61
+
62
+
63
+
64
+
65
+
66
+ # [1.13.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v1.13.0-rc.1...v1.13.0-rc.2) (2023-04-20)
67
+
68
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
69
+
70
+
71
+
72
+
73
+
74
+ # [1.13.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.13.0-rc.0...v1.13.0-rc.1) (2023-04-13)
75
+
76
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
77
+
78
+
79
+
80
+
81
+
82
+ # [1.13.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.12.0...v1.13.0-rc.0) (2023-04-06)
83
+
84
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
85
+
86
+
87
+
88
+
89
+
90
+ # [1.12.0](https://github.com/SAP/ui5-webcomponents/compare/v1.12.0-rc.3...v1.12.0) (2023-04-04)
91
+
92
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
93
+
94
+
95
+
96
+
97
+
98
+ # [1.12.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v1.12.0-rc.2...v1.12.0-rc.3) (2023-03-30)
99
+
100
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
101
+
102
+
103
+
104
+
105
+
106
+ # [1.12.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v1.12.0-rc.1...v1.12.0-rc.2) (2023-03-23)
107
+
108
+
109
+ ### Bug Fixes
110
+
111
+ * inline sources in the .map file so the src folder is not mandatory ([#6732](https://github.com/SAP/ui5-webcomponents/issues/6732)) ([16771a6](https://github.com/SAP/ui5-webcomponents/commit/16771a64d7b13f418af9afa1a03b224fe3762775))
112
+
113
+
114
+
115
+
116
+
117
+ # [1.12.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.12.0-rc.0...v1.12.0-rc.1) (2023-03-16)
118
+
119
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
120
+
121
+
122
+
123
+
124
+
125
+ # [1.12.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.11.0...v1.12.0-rc.0) (2023-03-09)
126
+
127
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
128
+
129
+
130
+
131
+
132
+
133
+ # [1.11.0](https://github.com/SAP/ui5-webcomponents/compare/v1.11.0-rc.4...v1.11.0) (2023-03-06)
134
+
135
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
136
+
137
+
138
+
139
+
140
+
141
+ # [1.11.0-rc.4](https://github.com/SAP/ui5-webcomponents/compare/v1.11.0-rc.3...v1.11.0-rc.4) (2023-03-02)
142
+
143
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
144
+
145
+
146
+
147
+
148
+
149
+ # [1.11.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v1.11.0-rc.2...v1.11.0-rc.3) (2023-02-23)
150
+
151
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
152
+
153
+
154
+
155
+
156
+
157
+ # [1.11.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v1.11.0-rc.1...v1.11.0-rc.2) (2023-02-16)
158
+
159
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
160
+
161
+
162
+
163
+
164
+
6
165
  # [1.11.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.11.0-rc.0...v1.11.0-rc.1) (2023-02-09)
7
166
 
8
167
 
package/README.md CHANGED
@@ -18,7 +18,8 @@ Usage:
18
18
 
19
19
  Options:
20
20
  --name <string> - defines the package name
21
- --tag <string> - defines the tag name of the sample web component that will be created in your new package
21
+ --componentName <string> - defines the component class name that will be created in your new package
22
+ --tag <string> - defines the tag name of the sample web component that will be created in your new package. The tag will be derived from the component name if not provided.
22
23
  --enable-typescript - enables TypeScript support for the package
23
24
  --skip - skips configuration and generates package with a default value for each parameter that wasn't passed
24
25
  ```
package/create-package.js CHANGED
@@ -16,21 +16,38 @@ const version = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"))
16
16
  const TEMPLATE_DIR = path.join(`${__dirname}`, `template/`);
17
17
 
18
18
  // String utils
19
- const capitalizeFirst = str => str.substr(0,1).toUpperCase() + str.substr(1);
20
- const kebabToCamelCase = string => toCamelCase(string.split("-"));
21
- const toCamelCase = parts => {
22
- return parts.map((string, index) => {
23
- return index === 0 ? string.toLowerCase() : string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
24
- }).join("");
25
- };
26
- const isTypescriptRelatedFile = sourcePath => {
19
+ const isTSRelatedFile = sourcePath => {
27
20
  return ["Assets.ts", "MyFirstComponent.ts", "tsconfig.json", "global.d.ts"].some(fileName => sourcePath.includes(fileName));
28
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 isNPMRC = sourcePath => {
29
+ return sourcePath.includes("npmrc");
30
+ };
29
31
 
30
32
  // Validation of user input
31
- const isNameValid = name => typeof name === "string" && name.match(/^[a-zA-Z0-9\-_]+$/);
33
+ const ComponentNamePattern = /^[A-Z][A-Za-z0-9]+$/;
34
+ const NamespacePattern = /^[a-z][a-z0-9\.\-]+$/;
35
+ const isPackageNameValid = name => typeof name === "string" && name.match(/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/);
36
+ const isComponentNameValid = name => typeof name === "string" && ComponentNamePattern.test(name);
37
+ const isNamespaceValid = name => typeof name === "string" && NamespacePattern.test(name);
32
38
  const isTagValid = tag => typeof tag === "string" && tag.match(/^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/);
33
39
 
40
+ /**
41
+ * Hyphanates the given PascalCase string, f.e.:
42
+ * Foo -> "my-foo" (adds preffix)
43
+ * FooBar -> "foo-bar"
44
+ */
45
+ const hyphaneteComponentName = (componentName) => {
46
+ const result = componentName.replace(/([a-z])([A-Z])/g, '$1-$2' ).toLowerCase();
47
+
48
+ return result.includes("-") ? result : `my-${result}`;
49
+ };
50
+
34
51
  // Utils for building the file structure
35
52
  const replaceVarsInFileContent = (vars, content) => {
36
53
  for (let key in vars) {
@@ -45,8 +62,8 @@ const replaceVarsInFileName = (vars, fileName) => {
45
62
  };
46
63
 
47
64
  const copyFile = (vars, sourcePath, destPath) => {
48
- const ignoreJsRelated = vars.INIT_PACKAGE_VAR_TYPESCRIPT && sourcePath.includes("MyFirstComponent.js");
49
- const ignoreTsRelated = !vars.INIT_PACKAGE_VAR_TYPESCRIPT && isTypescriptRelatedFile(sourcePath);
65
+ const ignoreJsRelated = vars.INIT_PACKAGE_VAR_TYPESCRIPT && isJSRelatedFile(sourcePath);
66
+ const ignoreTsRelated = !vars.INIT_PACKAGE_VAR_TYPESCRIPT && isTSRelatedFile(sourcePath);
50
67
 
51
68
  if (ignoreJsRelated || ignoreTsRelated) {
52
69
  return;
@@ -55,7 +72,18 @@ const copyFile = (vars, sourcePath, destPath) => {
55
72
  let content = fs.readFileSync(sourcePath, { encoding: "UTF-8" });
56
73
  content = replaceVarsInFileContent(vars, content);
57
74
  destPath = replaceVarsInFileName(vars, destPath);
75
+
58
76
  fs.writeFileSync(destPath, content);
77
+
78
+ // Rename "gitignore" to ".gitignore" (npm init won't include ".gitignore", so we add it as "gitignore" and rename it later)
79
+ if (isGitIgnore(sourcePath)) {
80
+ fs.renameSync(destPath, destPath.replace("gitignore", ".gitignore"))
81
+ }
82
+
83
+ // Rename "npmrc" to ".npmrc" (npm init won't include ".npmrc", so we add it as "npmrc" and rename it later)
84
+ if (isNPMRC(sourcePath)) {
85
+ fs.renameSync(destPath, destPath.replace("npmrc", ".npmrc"));
86
+ }
59
87
  };
60
88
 
61
89
  const copyFiles = (vars, sourcePath, destPath) => {
@@ -72,19 +100,20 @@ const copyFiles = (vars, sourcePath, destPath) => {
72
100
  }
73
101
  };
74
102
 
75
- const generateFilesContent = (name, tag, typescript) => {
76
- const className = capitalizeFirst(kebabToCamelCase(tag));
103
+ const generateFilesContent = (packageName, componentName, namespace, typescript, skipSubfolder) => {
104
+ const tagName = argv.tag || hyphaneteComponentName(componentName);
77
105
 
78
106
  // All variables that will be replaced in the content of the resources/
79
107
  const vars = {
80
- INIT_PACKAGE_VAR_NAME: name,
81
- INIT_PACKAGE_VAR_TAG: tag,
82
- INIT_PACKAGE_VAR_CLASS_NAME: className,
108
+ INIT_PACKAGE_VAR_NAMESPACE: namespace, // namespace must be replaced before name
109
+ INIT_PACKAGE_VAR_NAME: packageName,
110
+ INIT_PACKAGE_VAR_TAG: tagName,
111
+ INIT_PACKAGE_VAR_CLASS_NAME: componentName,
83
112
  INIT_PACKAGE_VAR_TYPESCRIPT: typescript,
84
113
  };
85
114
 
86
115
  const packageContent = {
87
- name,
116
+ packageName,
88
117
  version: "0.0.1",
89
118
  ui5: {
90
119
  webComponentsPackage: true,
@@ -116,15 +145,21 @@ const generateFilesContent = (name, tag, typescript) => {
116
145
  },
117
146
  };
118
147
 
148
+ if (typescript) {
149
+ packageContent.devDependencies.typescript = "^4.9.4";
150
+ }
151
+
119
152
  // Update package.json
120
- const destDir = path.join(`./`, name);
153
+ let destDir = packageName.includes("@") ? packageName.slice(packageName.lastIndexOf("/") + 1) : packageName;
154
+
155
+ destDir = skipSubfolder ? path.join("./") : path.join("./", destDir);
121
156
  mkdirp.sync(destDir);
122
157
  fs.writeFileSync(path.join(destDir, "package.json"), JSON.stringify(packageContent, null, 2));
123
158
  // Copy files
124
159
  copyFiles(vars, TEMPLATE_DIR, destDir);
125
160
 
126
161
  console.log("\nPackage successfully created!\nNext steps:\n");
127
- console.log(`$ cd ${name}`);
162
+ console.log(`$ cd ${destDir}`);
128
163
 
129
164
  let userAgentInfo;
130
165
  try {
@@ -145,20 +180,30 @@ const generateFilesContent = (name, tag, typescript) => {
145
180
  // Main function
146
181
  const createWebcomponentsPackage = async () => {
147
182
  let response;
148
- if (argv.name && !isNameValid(argv.name)) {
149
- throw new Error("The package name should be a string (a-z, A-Z, 0-9).");
183
+ if (argv.name && !isPackageNameValid(argv.name)) {
184
+ throw new Error("The package name should be a string, starting with letter and containing the following symbols [a-z, A-Z, 0-9].");
185
+ }
186
+
187
+ if (argv.componentName && !isComponentNameValid(argv.componentName)) {
188
+ throw new Error("The component name should be a string, starting with a capital letter [A-Z][a-z], for example: Button, MyButton, etc.");
189
+ }
190
+
191
+ if (argv.namespace && !isNamespaceValid(argv.namespace)) {
192
+ throw new Error("The JSDoc namespace must start with a letter and can only contain small-case letters, numbers, dots and dashes.");
150
193
  }
151
194
 
152
195
  if (argv.tag && !isTagValid(argv.tag) ) {
153
- throw new Error("The tag should be in kebab-case (my-first-component f.e) and it can't be a single word.");
196
+ throw new Error("The tag should be in kebab-case (f.e my-component) and it can't be a single word.");
154
197
  }
155
198
 
156
- let name = argv.name || "my-package";
157
- let tag = argv.tag || "my-first-component";
199
+ let packageName = argv.name || "my-package";
200
+ let componentName = argv.componentName || "MyComponent";
201
+ let namespace = argv.namespace || "demo.components";
158
202
  let typescriptSupport = !!argv.enableTypescript;
203
+ const skipSubfolder = !!argv.skipSubfolder;
159
204
 
160
205
  if (argv.skip) {
161
- return generateFilesContent(name, tag, typescriptSupport);
206
+ return generateFilesContent(packageName, componentName, namespace, typescriptSupport, skipSubfolder);
162
207
  }
163
208
 
164
209
  if (!argv.name) {
@@ -166,9 +211,9 @@ const createWebcomponentsPackage = async () => {
166
211
  type: "text",
167
212
  name: "name",
168
213
  message: "Package name:",
169
- validate: isNameValid,
214
+ 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, _, -].",
170
215
  });
171
- name = response.name;
216
+ packageName = response.name;
172
217
  }
173
218
 
174
219
  if (!typescriptSupport) {
@@ -190,18 +235,29 @@ const createWebcomponentsPackage = async () => {
190
235
  typescriptSupport = response.language;
191
236
  }
192
237
 
193
- if (!argv.tag) {
238
+ if (!argv.componentName) {
194
239
  response = await prompts({
195
240
  type: "text",
196
- name: "tag",
241
+ name: "componentName",
197
242
  message: "Component name:",
198
- initial: "my-first-component",
199
- validate: isTagValid,
243
+ initial: "MyComponent",
244
+ validate: (value) => isComponentNameValid(value) ? true : "Component name should follow PascalCase naming convention (f.e. Button, MyButton, etc.).",
245
+ });
246
+ componentName = response.componentName;
247
+ }
248
+
249
+ if (!argv.namespace) {
250
+ response = await prompts({
251
+ type: "text",
252
+ name: "namespace",
253
+ message: "JSDoc namespace:",
254
+ initial: "demo.components",
255
+ validate: (value) => isNamespaceValid(value) ? true : "The JSDoc namespace must start with a letter and can only contain small-case letters, numbers, dots and dashes.",
200
256
  });
201
- tag = response.tag;
257
+ namespace = response.namespace;
202
258
  }
203
259
 
204
- return generateFilesContent(name, tag, typescriptSupport);
260
+ return generateFilesContent(packageName, componentName, namespace, typescriptSupport, skipSubfolder);
205
261
  };
206
262
 
207
263
  createWebcomponentsPackage();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/create-webcomponents-package",
3
- "version": "0.0.0-7a547f8cc",
3
+ "version": "0.0.0-7b7921cd9",
4
4
  "description": "UI5 Web Components: create package",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -2,4 +2,5 @@
2
2
  dist
3
3
  test
4
4
  src/generated
5
- jsdoc-dist
5
+ jsdoc-dist
6
+ .eslintrc.js
@@ -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;
@@ -0,0 +1,4 @@
1
+ node_modules
2
+ dist
3
+ jsdoc-dist
4
+ src/generated
package/template/npmrc ADDED
@@ -0,0 +1,2 @@
1
+ # Auto detect the chromedriver version
2
+ detect_chromedriver_version=true
@@ -1 +1 @@
1
- <div>This is: INIT_PACKAGE_VAR_TAG. {{pleaseWaitText}}</div>
1
+ <div @click="{{onClick}}">{{counterText}} :: {{counter}}</div>
@@ -8,14 +8,23 @@ import INIT_PACKAGE_VAR_CLASS_NAMETemplate from "./generated/templates/INIT_PACK
8
8
  // Styles
9
9
  import INIT_PACKAGE_VAR_CLASS_NAMECss from "./generated/themes/INIT_PACKAGE_VAR_CLASS_NAME.css.js";
10
10
 
11
- import { PLEASE_WAIT } from "./generated/i18n/i18n-defaults.js";
11
+ import { COUNTER } from "./generated/i18n/i18n-defaults.js";
12
12
 
13
13
  /**
14
14
  * @public
15
15
  */
16
16
  const metadata = {
17
17
  tag: "INIT_PACKAGE_VAR_TAG",
18
- properties: {
18
+ properties: /** @lends INIT_PACKAGE_VAR_NAMESPACE.INIT_PACKAGE_VAR_CLASS_NAME.prototype */ {
19
+ /**
20
+ * Defines the counter of the component.
21
+ * @type { number }
22
+ * @defaultvalue 0
23
+ * @public
24
+ */
25
+ counter: {
26
+ defaultValue: 0,
27
+ },
19
28
  },
20
29
  slots: {
21
30
  },
@@ -31,7 +40,7 @@ const metadata = {
31
40
  * The <code>INIT_PACKAGE_VAR_TAG</code> component is a demo component that displays some text.
32
41
  *
33
42
  * @constructor
34
- * @alias demo.components.INIT_PACKAGE_VAR_CLASS_NAME
43
+ * @alias INIT_PACKAGE_VAR_NAMESPACE.INIT_PACKAGE_VAR_CLASS_NAME
35
44
  * @extends sap.ui.webc.base.UI5Element
36
45
  * @tagname INIT_PACKAGE_VAR_TAG
37
46
  * @public
@@ -57,8 +66,12 @@ class INIT_PACKAGE_VAR_CLASS_NAME extends UI5Element {
57
66
  INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle = await getI18nBundle("INIT_PACKAGE_VAR_NAME");
58
67
  }
59
68
 
60
- get pleaseWaitText() {
61
- return INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle.getText(PLEASE_WAIT);
69
+ onClick() {
70
+ this.counter++;
71
+ }
72
+
73
+ get counterText() {
74
+ return INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle.getText(COUNTER);
62
75
  }
63
76
  }
64
77
 
@@ -1,5 +1,6 @@
1
1
  import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
2
2
  import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
3
+ import property from "@ui5/webcomponents-base/dist/decorators/property.js";
3
4
  import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
4
5
  import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
5
6
  import type I18nBundle from "@ui5/webcomponents-base/dist/i18nBundle.js";
@@ -10,7 +11,7 @@ import INIT_PACKAGE_VAR_CLASS_NAMETemplate from "./generated/templates/INIT_PACK
10
11
  // Styles
11
12
  import INIT_PACKAGE_VAR_CLASS_NAMECss from "./generated/themes/INIT_PACKAGE_VAR_CLASS_NAME.css.js";
12
13
 
13
- import { PLEASE_WAIT } from "./generated/i18n/i18n-defaults.js";
14
+ import { COUNTER } from "./generated/i18n/i18n-defaults.js";
14
15
 
15
16
  /**
16
17
  * @class
@@ -20,33 +21,39 @@ import { PLEASE_WAIT } from "./generated/i18n/i18n-defaults.js";
20
21
  * The <code>INIT_PACKAGE_VAR_TAG</code> component is a demo component that displays some text.
21
22
  *
22
23
  * @constructor
23
- * @alias demo.components.INIT_PACKAGE_VAR_CLASS_NAME
24
+ * @alias INIT_PACKAGE_VAR_NAMESPACE.INIT_PACKAGE_VAR_CLASS_NAME
24
25
  * @extends sap.ui.webc.base.UI5Element
25
26
  * @tagname INIT_PACKAGE_VAR_TAG
26
27
  * @public
27
28
  */
28
- @customElement("INIT_PACKAGE_VAR_TAG")
29
+ @customElement({
30
+ tag: "INIT_PACKAGE_VAR_TAG",
31
+ renderer: litRender,
32
+ styles: INIT_PACKAGE_VAR_CLASS_NAMECss,
33
+ template: INIT_PACKAGE_VAR_CLASS_NAMETemplate,
34
+ })
29
35
  class INIT_PACKAGE_VAR_CLASS_NAME extends UI5Element {
30
36
  static i18nBundle: I18nBundle;
31
37
 
32
- static get render() {
33
- return litRender;
34
- }
35
-
36
- static get template() {
37
- return INIT_PACKAGE_VAR_CLASS_NAMETemplate;
38
- }
39
-
40
- static get styles() {
41
- return INIT_PACKAGE_VAR_CLASS_NAMECss;
42
- }
43
-
44
38
  static async onDefine() {
45
39
  INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle = await getI18nBundle("INIT_PACKAGE_VAR_NAME");
46
40
  }
47
41
 
48
- get pleaseWaitText() {
49
- return INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle.getText(PLEASE_WAIT);
42
+ /**
43
+ * Defines the component counter.
44
+ * @name NIT_PACKAGE_VAR_NAMESPACE.INIT_PACKAGE_VAR_CLASS_NAME.prototype.counter
45
+ * @public
46
+ * @type { number }
47
+ */
48
+ @property({ defaultValue: 0 })
49
+ counter!: number;
50
+
51
+ onClick() {
52
+ this.counter++;
53
+ }
54
+
55
+ get counterText() {
56
+ return INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle.getText(COUNTER);
50
57
  }
51
58
  }
52
59
 
@@ -1,2 +1,3 @@
1
- #please wait text for the sample component
2
- PLEASE_WAIT=wait
1
+ # the "counter" text for the sample component
2
+ COUNTER=Counter
3
+
@@ -1 +1 @@
1
- PLEASE_WAIT=Bitte warten
1
+ COUNTER=Schalter
@@ -1 +1 @@
1
- PLEASE_WAIT=Please wait
1
+ COUNTER=Counter
@@ -1 +1 @@
1
- PLEASE_WAIT=Espere
1
+ COUNTER=Encimera
@@ -1 +1 @@
1
- PLEASE_WAIT=Patientez.
1
+ COUNTER=Comptoir
@@ -1,11 +1,12 @@
1
1
  :host {
2
- border: 2px solid var(--my-component-border-color);
3
- background-color: var(--sapBackgroundColor);
4
- color: var(--sapTextColor);
5
- display: block;
6
- width: 24rem;
7
- height: 3rem;
8
- text-align: center;
9
- vertical-align: middle;
10
- line-height: 3rem;
2
+ padding: 0 2rem;
3
+ color: var(--sapAvatar_6_TextColor);
4
+ background-color: var(--sapAvatar_6_Background);
5
+ border: 2px solid var(--my-component-border-color);
6
+ border-radius: 0.5rem;
7
+ box-shadow: var(--sapContent_Shadow0);
8
+ text-align: center;
9
+ line-height: 3rem;
10
+ font-size: 1.25rem;
11
+ user-select: none;
11
12
  }
@@ -1,3 +1,3 @@
1
1
  :root {
2
- --my-component-border-color: green;
2
+ --my-component-border-color: blue;
3
3
  }
@@ -0,0 +1,3 @@
1
+ :root {
2
+ --my-component-border-color: darkblue;
3
+ }
@@ -0,0 +1,3 @@
1
+ :root {
2
+ --my-component-border-color: white;
3
+ }
@@ -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-first-component, .app-settings, .app-docs {
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
- <ul>
27
- <li><a href="?sap-ui-theme=sap_fiori_3">Fiori 3</a></li>
28
- <li><a href="?sap-ui-theme=sap_fiori_3_dark">Fiori 3 Dark</a></li>
29
- <li><a href="?sap-ui-theme=sap_fiori_3_hcb">Fiori 3 High Contrast Black</a></li>
30
- <li><a href="?sap-ui-theme=sap_fiori_3_hcw">Fiori 3 High Contrast White</a></li>
31
- <li><a href="?sap-ui-theme=sap_belize">Belize</a></li>
32
- <li><a href="?sap-ui-theme=sap_belize_hcb">Belize High Contrast Black</a></li>
33
- <li><a href="?sap-ui-theme=sap_belize_hcw">Belize High Contrast White</a></li>
34
- </ul>
35
- <br>
36
- <span>or in the browser console, for example:</span>
37
- <code>window['sap-ui-webcomponents-bundle'].configuration.setTheme("sap_belize_hcb")</code>
38
-
39
- <br><br>
40
-
41
- <a href="?sap-ui-language=en">English</a> |
42
- <a href="?sap-ui-language=de">German</a> |
43
- <a href="?sap-ui-language=es">Spanish</a> |
44
- <a href="?sap-ui-language=fr">French</a>
45
-
46
- <br><br>
47
-
48
- <h1>Test your web components here</h1>
49
- <INIT_PACKAGE_VAR_TAG id="myFirstComponent"></INIT_PACKAGE_VAR_TAG>
23
+ <div class="app">
24
+ <a href="https://sap.github.io/ui5-webcomponents/playground/getting-started" 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>&lt;INIT_PACKAGE_VAR_TAG>&lt;/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/development">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
- await browser.url("test/pages/index.html");
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");
@@ -7,6 +7,7 @@
7
7
  "outDir": "dist",
8
8
  "skipLibCheck": true,
9
9
  "sourceMap": true,
10
+ "inlineSources": true,
10
11
  "strict": true,
11
12
  "moduleResolution": "node",
12
13
  "experimentalDecorators": true,
@@ -1,12 +0,0 @@
1
- // eslint-disable-next-line
2
- import "@ui5/webcomponents-base/dist/global";
3
- import { TemplateFunction } from "@ui5/webcomponents-base/dist/renderer/executeTemplate.js";
4
-
5
- export {};
6
-
7
- declare global {
8
- module "*.lit.js" {
9
- const content: TemplateFunction;
10
- export default content;
11
- }
12
- }
@@ -1,3 +0,0 @@
1
- :root {
2
- --my-component-border-color: black;
3
- }
@@ -1,3 +0,0 @@
1
- :root {
2
- --my-component-border-color: blue;
3
- }
@@ -1,3 +0,0 @@
1
- :root {
2
- --my-component-border-color: lightblue;
3
- }
@@ -1,3 +0,0 @@
1
- :root {
2
- --my-component-border-color: gray;
3
- }