@ui5/create-webcomponents-package 0.0.0-7d5f73b20 → 0.0.0-7d8c57f70

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 (35) hide show
  1. package/CHANGELOG.md +690 -0
  2. package/README.md +12 -9
  3. package/create-package.js +106 -43
  4. package/package.json +2 -4
  5. package/template/.eslintignore +2 -1
  6. package/template/.eslintrc.js +5 -0
  7. package/template/bundle.esm.js +0 -2
  8. package/template/gitignore +4 -0
  9. package/template/npmrc +2 -0
  10. package/template/src/MyFirstComponent.hbs +6 -1
  11. package/template/src/MyFirstComponent.js +20 -5
  12. package/template/src/MyFirstComponent.ts +23 -18
  13. package/template/src/i18n/messagebundle.properties +3 -2
  14. package/template/src/i18n/messagebundle_de.properties +1 -1
  15. package/template/src/i18n/messagebundle_en.properties +1 -1
  16. package/template/src/i18n/messagebundle_es.properties +1 -1
  17. package/template/src/i18n/messagebundle_fr.properties +1 -1
  18. package/template/src/themes/MyFirstComponent.css +16 -10
  19. package/template/src/themes/sap_fiori_3/parameters-bundle.css +1 -1
  20. package/template/src/themes/sap_horizon_dark/parameters-bundle.css +3 -0
  21. package/template/src/themes/sap_horizon_hcb/parameters-bundle.css +3 -0
  22. package/template/test/pages/css/index.css +36 -0
  23. package/template/test/pages/img/logo.png +0 -0
  24. package/template/test/pages/index.html +35 -30
  25. package/template/test/specs/Demo.spec.js +3 -2
  26. package/template/tsconfig.json +2 -0
  27. package/template/config/postcss.components/postcss.config.js +0 -1
  28. package/template/config/postcss.themes/postcss.config.js +0 -1
  29. package/template/global.d.ts +0 -12
  30. package/template/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
  31. package/template/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
  32. package/template/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
  33. package/template/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
  34. /package/template/src/themes/{sap_belize → sap_horizon}/parameters-bundle.css +0 -0
  35. /package/template/src/themes/{sap_belize_hcb → sap_horizon_hcw}/parameters-bundle.css +0 -0
package/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  ![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-webcomponents/main/docs/images/UI5_logo_wide.png)
2
2
 
3
+
3
4
  # UI5 Web Components - Create Package
4
5
 
5
6
  [![npm Package Version](https://badge.fury.io/js/%40ui5%2Fwebcomponents.svg)](https://www.npmjs.com/package/@ui5/webcomponents)
@@ -13,13 +14,14 @@ Usage:
13
14
 
14
15
  # npm 6.x
15
16
  npm init @ui5/webcomponents-package [OPTIONS]
16
- # npm 7+, extra double-dash is needed:
17
+ # npm 7+, an extra double-dash is needed:
17
18
  npm init @ui5/webcomponents-package -- [OPTIONS]
18
19
 
19
20
  Options:
20
- --name <string> - defines package name
21
- --tag <string> - defines predefined custom element tag name
22
- --enable-typescript - enables TypeScript support to the package
21
+ --name <string> - defines the package name
22
+ --component-name <string> - defines the component class name that will be created in your new package
23
+ --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.
24
+ --enable-typescript - enables TypeScript support for the package
23
25
  --skip - skips configuration and generates package with a default value for each parameter that wasn't passed
24
26
  ```
25
27
 
@@ -32,10 +34,11 @@ components package.
32
34
  Usage:
33
35
  yarn create @ui5/webcomponents-package [OPTIONS]
34
36
  Options:
35
- --name <string> - defines package name
36
- --tag <string> - defines predefined custom element tag name
37
- --enable-typescript - enables TypeScript support to the package
38
- --skip - skips all configurations and generates package with default configurations
37
+ --name <string> - defines the package name
38
+ --component-name <string> - defines the component class name that will be created in your new package
39
+ --tag <string> - defines the tag name of the sample web component that will be created in your new package
40
+ --enable-typescript - enables TypeScript support for the package
41
+ --skip - skips configuration and generates package with a default value for each parameter that wasn't passed
39
42
  ```
40
43
 
41
44
  The script creates a new directory, and fills it with a `package.json` file and all necessary source files, and resources for a new
@@ -47,7 +50,7 @@ components package.
47
50
  - [UI5 Web Components - Playground and API Reference](https://sap.github.io/ui5-webcomponents/playground/)
48
51
 
49
52
  ## Support
50
- We welcome all comments, suggestions, questions, and bug reports. Please follow our [Support Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/SUPPORT.md#-content) on how to report an issue, or chat with us in the `#webcomponents` channel of the [OpenUI5 Community Slack](https://join-ui5-slack.herokuapp.com/).
53
+ We welcome all comments, suggestions, questions, and bug reports. Please follow our [Support Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/SUPPORT.md#-content) on how to report an issue, or chat with us in the `#webcomponents` channel of the [OpenUI5 Community Slack](https://ui5-slack-invite.cfapps.eu10.hana.ondemand.com/).
51
54
 
52
55
  ## Contribute
53
56
  Please check our [Contribution Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/docs/6-contributing/02-conventions-and-guidelines.md).
package/create-package.js CHANGED
@@ -5,8 +5,8 @@ const path = require("path");
5
5
  const mkdirp = require("mkdirp");
6
6
  const prompts = require("prompts");
7
7
  const parser = require("npm-config-user-agent-parser");
8
- const yargs = require('yargs/yargs');
9
- const { hideBin } = require('yargs/helpers');
8
+ const yargs = require("yargs/yargs");
9
+ const { hideBin } = require("yargs/helpers");
10
10
 
11
11
  const argv = yargs(hideBin(process.argv)).argv;
12
12
 
@@ -16,21 +16,41 @@ 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("");
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");
25
33
  };
26
- const isTypescriptRelatedFile = sourcePath => {
27
- return ["Аssets.ts", "MyFirstComponent.ts", "tsconfig.json", "global.d.ts"].some(fileName => sourcePath.includes(fileName));
28
- }
29
34
 
30
35
  // Validation of user input
31
- const isNameValid = name => typeof name === "string" && name.match(/^[a-zA-Z0-9\-_]+$/);
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);
32
41
  const isTagValid = tag => typeof tag === "string" && tag.match(/^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/);
33
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
+
34
54
  // Utils for building the file structure
35
55
  const replaceVarsInFileContent = (vars, content) => {
36
56
  for (let key in vars) {
@@ -45,17 +65,33 @@ const replaceVarsInFileName = (vars, fileName) => {
45
65
  };
46
66
 
47
67
  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)
68
+ const ignoreJsRelated = vars.INIT_PACKAGE_VAR_TYPESCRIPT && isJSRelatedFile(sourcePath);
69
+ const ignoreTsRelated = !vars.INIT_PACKAGE_VAR_TYPESCRIPT && isTSRelatedFile(sourcePath);
50
70
 
51
71
  if (ignoreJsRelated || ignoreTsRelated) {
52
72
  return;
53
73
  }
54
74
 
55
- let content = fs.readFileSync(sourcePath, {encoding: "UTF-8"});
75
+ if (isLogo(sourcePath)) {
76
+ fs.copyFileSync(sourcePath, destPath);
77
+ return;
78
+ }
79
+
80
+ let content = fs.readFileSync(sourcePath, { encoding: "UTF-8" });
56
81
  content = replaceVarsInFileContent(vars, content);
57
82
  destPath = replaceVarsInFileName(vars, destPath);
83
+
58
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
+ }
59
95
  };
60
96
 
61
97
  const copyFiles = (vars, sourcePath, destPath) => {
@@ -72,20 +108,20 @@ const copyFiles = (vars, sourcePath, destPath) => {
72
108
  }
73
109
  };
74
110
 
75
-
76
- const generateFilesContent = (name, tag, typescript) => {
77
- const className = capitalizeFirst(kebabToCamelCase(tag));
111
+ const generateFilesContent = (packageName, componentName, namespace, typescript, skipSubfolder) => {
112
+ const tagName = argv.tag || hyphaneteComponentName(componentName);
78
113
 
79
114
  // All variables that will be replaced in the content of the resources/
80
115
  const vars = {
81
- INIT_PACKAGE_VAR_NAME: name,
82
- INIT_PACKAGE_VAR_TAG: tag,
83
- INIT_PACKAGE_VAR_CLASS_NAME: className,
84
- INIT_PACKAGE_VAR_TYPESCRIPT: typescript
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,
85
121
  };
86
122
 
87
123
  const packageContent = {
88
- name,
124
+ name: packageName,
89
125
  version: "0.0.1",
90
126
  ui5: {
91
127
  webComponentsPackage: true,
@@ -117,15 +153,21 @@ const generateFilesContent = (name, tag, typescript) => {
117
153
  },
118
154
  };
119
155
 
156
+ if (typescript) {
157
+ packageContent.devDependencies.typescript = "5.2.2";
158
+ }
159
+
120
160
  // Update package.json
121
- const destDir = path.join(`./`, name);
161
+ let destDir = packageName.includes("@") ? packageName.slice(packageName.lastIndexOf("/") + 1) : packageName;
162
+
163
+ destDir = skipSubfolder ? path.join("./") : path.join("./", destDir);
122
164
  mkdirp.sync(destDir);
123
165
  fs.writeFileSync(path.join(destDir, "package.json"), JSON.stringify(packageContent, null, 2));
124
166
  // Copy files
125
167
  copyFiles(vars, TEMPLATE_DIR, destDir);
126
168
 
127
169
  console.log("\nPackage successfully created!\nNext steps:\n");
128
- console.log(`$ cd ${name}`);
170
+ console.log(`$ cd ${destDir}`);
129
171
 
130
172
  let userAgentInfo;
131
173
  try {
@@ -141,25 +183,35 @@ const generateFilesContent = (name, tag, typescript) => {
141
183
  }
142
184
 
143
185
  console.log("\n");
144
- }
186
+ };
145
187
 
146
188
  // Main function
147
189
  const createWebcomponentsPackage = async () => {
148
190
  let response;
149
- if (argv.name && !isNameValid(argv.name)) {
150
- throw new Error("The package name should be a string (a-z, A-Z, 0-9).");
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.");
151
201
  }
152
202
 
153
203
  if (argv.tag && !isTagValid(argv.tag) ) {
154
- throw new Error("The tag should be in kebab-case (my-first-component f.e) and it can't be a single word.");
204
+ throw new Error("The tag should be in kebab-case (f.e my-component) and it can't be a single word.");
155
205
  }
156
206
 
157
- let name = argv.name || "my-package";
158
- let tag = argv.tag || "my-first-component";
207
+ let packageName = argv.name || "my-package";
208
+ let componentName = argv.componentName || "MyComponent";
209
+ let namespace = argv.namespace || "demo.components";
159
210
  let typescriptSupport = !!argv.enableTypescript;
211
+ const skipSubfolder = !!argv.skipSubfolder;
160
212
 
161
- if (!!argv.skip) {
162
- return generateFilesContent(name, tag, typescriptSupport);
213
+ if (argv.skip) {
214
+ return generateFilesContent(packageName, componentName, namespace, typescriptSupport, skipSubfolder);
163
215
  }
164
216
 
165
217
  if (!argv.name) {
@@ -167,9 +219,9 @@ const createWebcomponentsPackage = async () => {
167
219
  type: "text",
168
220
  name: "name",
169
221
  message: "Package name:",
170
- validate: isNameValid,
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, _, -].",
171
223
  });
172
- name = response.name;
224
+ packageName = response.name;
173
225
  }
174
226
 
175
227
  if (!typescriptSupport) {
@@ -186,23 +238,34 @@ const createWebcomponentsPackage = async () => {
186
238
  title: "TypeScript",
187
239
  value: true,
188
240
  },
189
- ]
241
+ ],
190
242
  });
191
- typescript = response.language;
243
+ typescriptSupport = response.language;
192
244
  }
193
245
 
194
- if (!argv.tag) {
246
+ if (!argv.componentName) {
195
247
  response = await prompts({
196
248
  type: "text",
197
- name: "tag",
249
+ name: "componentName",
198
250
  message: "Component name:",
199
- initial: "my-first-component",
200
- validate: isTagValid,
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.",
201
264
  });
202
- tag = response.tag;
265
+ namespace = response.namespace;
203
266
  }
204
267
 
205
- return generateFilesContent(name, tag, typescript);
268
+ return generateFilesContent(packageName, componentName, namespace, typescriptSupport, skipSubfolder);
206
269
  };
207
270
 
208
271
  createWebcomponentsPackage();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/create-webcomponents-package",
3
- "version": "0.0.0-7d5f73b20",
3
+ "version": "0.0.0-7d8c57f70",
4
4
  "description": "UI5 Web Components: create package",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -21,9 +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"
25
- },
26
- "devDependencies": {
24
+ "prompts": "^2.4.1",
27
25
  "yargs": "^17.5.1"
28
26
  }
29
27
  }
@@ -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;
@@ -6,7 +6,6 @@ import { getLanguage } from "@ui5/webcomponents-base/dist/config/Language.js";
6
6
  import { getCalendarType } from "@ui5/webcomponents-base/dist/config/CalendarType.js";
7
7
  import { getTheme, setTheme } from "@ui5/webcomponents-base/dist/config/Theme.js";
8
8
  import { getNoConflict, setNoConflict } from "@ui5/webcomponents-base/dist/config/NoConflict.js";
9
- import { getRTL } from "@ui5/webcomponents-base/dist/config/RTL.js";
10
9
  import { getFirstDayOfWeek } from "@ui5/webcomponents-base/dist/config/FormatSettings.js";
11
10
 
12
11
  // Enable additional themes and i18n texts
@@ -25,7 +24,6 @@ window["sap-ui-webcomponents-bundle"] = {
25
24
  getNoConflict,
26
25
  setNoConflict,
27
26
  getCalendarType,
28
- getRTL,
29
27
  getFirstDayOfWeek,
30
28
  },
31
29
  };
@@ -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,6 @@
1
- <div>This is: INIT_PACKAGE_VAR_TAG. {{pleaseWaitText}}</div>
1
+ <div
2
+ class="root"
3
+ @click="{{onClick}}"
4
+ >
5
+ {{counterText}} :: {{count}}
6
+ </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 { PLEASE_WAIT } from "./generated/i18n/i18n-defaults.js";
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 demo.components.INIT_PACKAGE_VAR_CLASS_NAME
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
- get pleaseWaitText() {
61
- return INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle.getText(PLEASE_WAIT);
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
 
@@ -1,8 +1,10 @@
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";
7
+ import Integer from "@ui5/webcomponents-base/dist/types/Integer.js";
6
8
 
7
9
  // Template
8
10
  import INIT_PACKAGE_VAR_CLASS_NAMETemplate from "./generated/templates/INIT_PACKAGE_VAR_CLASS_NAMETemplate.lit.js";
@@ -10,7 +12,7 @@ import INIT_PACKAGE_VAR_CLASS_NAMETemplate from "./generated/templates/INIT_PACK
10
12
  // Styles
11
13
  import INIT_PACKAGE_VAR_CLASS_NAMECss from "./generated/themes/INIT_PACKAGE_VAR_CLASS_NAME.css.js";
12
14
 
13
- import { PLEASE_WAIT } from "./generated/i18n/i18n-defaults.js";
15
+ import { COUNT } from "./generated/i18n/i18n-defaults.js";
14
16
 
15
17
  /**
16
18
  * @class
@@ -20,33 +22,36 @@ import { PLEASE_WAIT } from "./generated/i18n/i18n-defaults.js";
20
22
  * The <code>INIT_PACKAGE_VAR_TAG</code> component is a demo component that displays some text.
21
23
  *
22
24
  * @constructor
23
- * @alias demo.components.INIT_PACKAGE_VAR_CLASS_NAME
24
- * @extends sap.ui.webc.base.UI5Element
25
- * @tagname INIT_PACKAGE_VAR_TAG
25
+ * @extends UI5Element
26
26
  * @public
27
27
  */
28
- @customElement("INIT_PACKAGE_VAR_TAG")
28
+ @customElement({
29
+ tag: "INIT_PACKAGE_VAR_TAG",
30
+ renderer: litRender,
31
+ styles: INIT_PACKAGE_VAR_CLASS_NAMECss,
32
+ template: INIT_PACKAGE_VAR_CLASS_NAMETemplate,
33
+ })
29
34
  class INIT_PACKAGE_VAR_CLASS_NAME extends UI5Element {
30
35
  static i18nBundle: I18nBundle;
31
36
 
32
- static get render() {
33
- return litRender;
37
+ static async onDefine() {
38
+ INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle = await getI18nBundle("INIT_PACKAGE_VAR_NAME");
34
39
  }
35
40
 
36
- static get template() {
37
- return INIT_PACKAGE_VAR_CLASS_NAMETemplate;
38
- }
41
+ /**
42
+ * Defines the component count.
43
+ * @default 0
44
+ * @public
45
+ */
46
+ @property({ validator: Integer, defaultValue: 0 })
47
+ count!: number;
39
48
 
40
- static get styles() {
41
- return INIT_PACKAGE_VAR_CLASS_NAMECss;
42
- }
43
-
44
- static async onDefine() {
45
- INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle = await getI18nBundle("INIT_PACKAGE_VAR_NAME");
49
+ onClick() {
50
+ this.count++;
46
51
  }
47
52
 
48
- get pleaseWaitText() {
49
- return INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle.getText(PLEASE_WAIT);
53
+ get counterText() {
54
+ return INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle.getText(COUNT);
50
55
  }
51
56
  }
52
57
 
@@ -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
+ COUNT=Count
3
+
@@ -1 +1 @@
1
- PLEASE_WAIT=Bitte warten
1
+ COUNT=Zählung
@@ -1 +1 @@
1
- PLEASE_WAIT=Please wait
1
+ COUNT=Count
@@ -1 +1 @@
1
- PLEASE_WAIT=Espere
1
+ COUNT=Cuenta
@@ -1 +1 @@
1
- PLEASE_WAIT=Patientez.
1
+ COUNT=Comte
@@ -1,11 +1,17 @@
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;
1
+ .root {
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;
16
+ cursor: pointer;
11
17
  }
@@ -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-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