@sap-ux/ui5-library-writer 0.5.39 → 0.5.40

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 (66) hide show
  1. package/dist/index.js +3 -1
  2. package/dist/utils.d.ts +18 -0
  3. package/dist/utils.js +41 -0
  4. package/package.json +1 -2
  5. package/templates/common/1.120.0/src/baselibrary/ExampleRenderer.js +47 -0
  6. package/templates/common/1.120.0/src/baselibrary/ExampleRenderer.ts +41 -0
  7. package/templates/common/1.120.0/src/baselibrary/library.js +68 -0
  8. package/templates/common/1.120.0/src/baselibrary/library.ts +58 -0
  9. package/templates/common/1.120.0/test/baselibrary/Example.html +21 -0
  10. package/templates/common/1.120.0/ui5.yaml +18 -0
  11. package/templates/common/1.71.0/gitignore.tmpl +9 -0
  12. package/templates/common/1.71.0/karma.conf.tmpl +7 -0
  13. package/templates/common/1.71.0/package.json +18 -0
  14. package/templates/common/1.71.0/src/baselibrary/.library +14 -0
  15. package/templates/common/1.71.0/src/baselibrary/Example.gen.d.ts +33 -0
  16. package/templates/common/1.71.0/src/baselibrary/Example.js +68 -0
  17. package/templates/common/1.71.0/src/baselibrary/Example.ts +65 -0
  18. package/templates/common/1.71.0/src/baselibrary/messagebundle.properties +2 -0
  19. package/templates/common/1.71.0/src/baselibrary/themes/base/Example.less +19 -0
  20. package/templates/common/1.71.0/src/baselibrary/themes/base/library.source.less +4 -0
  21. package/templates/common/1.71.0/src/baselibrary/themes/sap_belize/library.source.less +3 -0
  22. package/templates/common/1.71.0/src/baselibrary/themes/sap_belize_hcb/library.source.less +3 -0
  23. package/templates/common/1.71.0/src/baselibrary/themes/sap_belize_hcw/library.source.less +3 -0
  24. package/templates/common/1.71.0/src/baselibrary/themes/sap_belize_plus/library.source.less +3 -0
  25. package/templates/common/1.71.0/src/baselibrary/themes/sap_fiori_3/library.source.less +3 -0
  26. package/templates/common/1.71.0/src/baselibrary/themes/sap_fiori_3_dark/library.source.less +3 -0
  27. package/templates/common/1.71.0/src/baselibrary/themes/sap_fiori_3_hcb/library.source.less +3 -0
  28. package/templates/common/1.71.0/src/baselibrary/themes/sap_fiori_3_hcw/library.source.less +3 -0
  29. package/templates/common/1.71.0/test/baselibrary/Example.js +18 -0
  30. package/templates/common/1.71.0/test/baselibrary/Example.ts +9 -0
  31. package/templates/common/1.71.0/test/baselibrary/qunit/Example.qunit.js +65 -0
  32. package/templates/common/1.71.0/test/baselibrary/qunit/Example.qunit.ts +68 -0
  33. package/templates/common/1.71.0/test/baselibrary/qunit/testsuite.qunit.html +13 -0
  34. package/templates/common/1.71.0/test/baselibrary/qunit/testsuite.qunit.js +35 -0
  35. package/templates/common/1.71.0/test/baselibrary/qunit/testsuite.qunit.ts +35 -0
  36. /package/templates/common/{gitignore.tmpl → 1.120.0/gitignore.tmpl} +0 -0
  37. /package/templates/common/{karma.conf.tmpl → 1.120.0/karma.conf.tmpl} +0 -0
  38. /package/templates/common/{package.json → 1.120.0/package.json} +0 -0
  39. /package/templates/common/{src → 1.120.0/src}/baselibrary/.library +0 -0
  40. /package/templates/common/{src → 1.120.0/src}/baselibrary/Example.gen.d.ts +0 -0
  41. /package/templates/common/{src → 1.120.0/src}/baselibrary/Example.js +0 -0
  42. /package/templates/common/{src → 1.120.0/src}/baselibrary/Example.ts +0 -0
  43. /package/templates/common/{src → 1.120.0/src}/baselibrary/messagebundle.properties +0 -0
  44. /package/templates/common/{src → 1.120.0/src}/baselibrary/themes/base/Example.less +0 -0
  45. /package/templates/common/{src → 1.120.0/src}/baselibrary/themes/base/library.source.less +0 -0
  46. /package/templates/common/{src → 1.120.0/src}/baselibrary/themes/sap_belize/library.source.less +0 -0
  47. /package/templates/common/{src → 1.120.0/src}/baselibrary/themes/sap_belize_hcb/library.source.less +0 -0
  48. /package/templates/common/{src → 1.120.0/src}/baselibrary/themes/sap_belize_hcw/library.source.less +0 -0
  49. /package/templates/common/{src → 1.120.0/src}/baselibrary/themes/sap_belize_plus/library.source.less +0 -0
  50. /package/templates/common/{src → 1.120.0/src}/baselibrary/themes/sap_fiori_3/library.source.less +0 -0
  51. /package/templates/common/{src → 1.120.0/src}/baselibrary/themes/sap_fiori_3_dark/library.source.less +0 -0
  52. /package/templates/common/{src → 1.120.0/src}/baselibrary/themes/sap_fiori_3_hcb/library.source.less +0 -0
  53. /package/templates/common/{src → 1.120.0/src}/baselibrary/themes/sap_fiori_3_hcw/library.source.less +0 -0
  54. /package/templates/common/{test → 1.120.0/test}/baselibrary/Example.js +0 -0
  55. /package/templates/common/{test → 1.120.0/test}/baselibrary/Example.ts +0 -0
  56. /package/templates/common/{test → 1.120.0/test}/baselibrary/qunit/Example.qunit.js +0 -0
  57. /package/templates/common/{test → 1.120.0/test}/baselibrary/qunit/Example.qunit.ts +0 -0
  58. /package/templates/common/{test → 1.120.0/test}/baselibrary/qunit/testsuite.qunit.html +0 -0
  59. /package/templates/common/{test → 1.120.0/test}/baselibrary/qunit/testsuite.qunit.js +0 -0
  60. /package/templates/common/{test → 1.120.0/test}/baselibrary/qunit/testsuite.qunit.ts +0 -0
  61. /package/templates/common/{src → 1.71.0/src}/baselibrary/ExampleRenderer.js +0 -0
  62. /package/templates/common/{src → 1.71.0/src}/baselibrary/ExampleRenderer.ts +0 -0
  63. /package/templates/common/{src → 1.71.0/src}/baselibrary/library.js +0 -0
  64. /package/templates/common/{src → 1.71.0/src}/baselibrary/library.ts +0 -0
  65. /package/templates/common/{test → 1.71.0/test}/baselibrary/Example.html +0 -0
  66. /package/templates/common/{ui5.yaml → 1.71.0/ui5.yaml} +0 -0
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ const mem_fs_editor_1 = require("mem-fs-editor");
10
10
  const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
11
11
  const options_1 = require("./options");
12
12
  const data_1 = require("./data");
13
+ const utils_1 = require("./utils");
13
14
  /**
14
15
  * Writes the template to the memfs editor instance.
15
16
  *
@@ -27,7 +28,8 @@ async function generate(basePath, ui5LibConfig, fs) {
27
28
  basePath = (0, path_1.join)(basePath, libInput.libraryNamespace);
28
29
  const tmplPath = (0, path_1.join)(__dirname, '..', 'templates');
29
30
  const ignore = [reuseLib.typescript ? '**/*.js' : '**/*.ts'];
30
- fs.copyTpl((0, path_1.join)(tmplPath, 'common', '**/*.*'), basePath, libInput, undefined, {
31
+ const templateVersionPath = (0, utils_1.getTemplateVersionPath)(reuseLib.frameworkVersion);
32
+ fs.copyTpl((0, path_1.join)(tmplPath, 'common', templateVersionPath, '**/*.*'), basePath, libInput, undefined, {
31
33
  globOptions: { dot: true, ignore },
32
34
  processDestinationPath: (filePath) => filePath
33
35
  .replace('baselibrary', libInput.libraryNamespaceURI)
@@ -0,0 +1,18 @@
1
+ export declare const ui5LtsVersion_1_71 = "1.71.0";
2
+ export declare const ui5LtsVersion_1_120 = "1.120.0";
3
+ /**
4
+ * Compares two UI5 versions to determine if the first is greater than or equal to the second.
5
+ *
6
+ * @param {string} ui5VersionA - The first UI5 version to compare.
7
+ * @param {string} ui5VersionB - The second UI5 version to compare.
8
+ * @returns {boolean} - True if the first version is greater than or equal to the second, false otherwise.
9
+ */
10
+ export declare function compareUI5VersionGte(ui5VersionA: string, ui5VersionB: string): boolean;
11
+ /**
12
+ * Gets the template version path based on the UI5 version.
13
+ *
14
+ * @param version - The framework version.
15
+ * @returns {string} - The template version path.
16
+ */
17
+ export declare function getTemplateVersionPath(version: string): string;
18
+ //# sourceMappingURL=utils.d.ts.map
package/dist/utils.js ADDED
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ui5LtsVersion_1_120 = exports.ui5LtsVersion_1_71 = void 0;
4
+ exports.compareUI5VersionGte = compareUI5VersionGte;
5
+ exports.getTemplateVersionPath = getTemplateVersionPath;
6
+ const semver_1 = require("semver");
7
+ exports.ui5LtsVersion_1_71 = '1.71.0';
8
+ exports.ui5LtsVersion_1_120 = '1.120.0';
9
+ /**
10
+ * Compares two UI5 versions to determine if the first is greater than or equal to the second.
11
+ *
12
+ * @param {string} ui5VersionA - The first UI5 version to compare.
13
+ * @param {string} ui5VersionB - The second UI5 version to compare.
14
+ * @returns {boolean} - True if the first version is greater than or equal to the second, false otherwise.
15
+ */
16
+ function compareUI5VersionGte(ui5VersionA, ui5VersionB) {
17
+ if (ui5VersionA === '') {
18
+ // latest version
19
+ return true;
20
+ }
21
+ else {
22
+ return (0, semver_1.gte)(ui5VersionA, ui5VersionB, { loose: true });
23
+ }
24
+ }
25
+ /**
26
+ * Gets the template version path based on the UI5 version.
27
+ *
28
+ * @param version - The framework version.
29
+ * @returns {string} - The template version path.
30
+ */
31
+ function getTemplateVersionPath(version) {
32
+ let templateVersionPath = '';
33
+ if (compareUI5VersionGte(version, exports.ui5LtsVersion_1_120)) {
34
+ templateVersionPath = exports.ui5LtsVersion_1_120;
35
+ }
36
+ else {
37
+ templateVersionPath = exports.ui5LtsVersion_1_71;
38
+ }
39
+ return templateVersionPath;
40
+ }
41
+ //# sourceMappingURL=utils.js.map
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aui5-library-writer"
11
11
  },
12
- "version": "0.5.39",
12
+ "version": "0.5.40",
13
13
  "license": "Apache-2.0",
14
14
  "main": "dist/index.js",
15
15
  "files": [
@@ -30,7 +30,6 @@
30
30
  "mem-fs-editor": "9.4.0",
31
31
  "semver": "7.5.4",
32
32
  "@sap-ux/project-access": "1.28.10",
33
- "@sap-ux/ui5-application-writer": "1.2.8",
34
33
  "@sap-ux/ui5-config": "0.26.0"
35
34
  },
36
35
  "devDependencies": {
@@ -0,0 +1,47 @@
1
+ /*!
2
+ * ${copyright}
3
+ */
4
+
5
+ sap.ui.define([
6
+ "sap/ui/core/Lib",
7
+ "./library"
8
+ ], function (Lib, library) {
9
+ "use strict";
10
+
11
+ // refer to library types
12
+ var ExampleColor = library.ExampleColor;
13
+
14
+ /**
15
+ * Example renderer.
16
+ * @namespace
17
+ */
18
+ var ExampleRenderer = {
19
+ apiVersion: 2 // usage of DOM Patcher
20
+ };
21
+
22
+ /**
23
+ * Renders the HTML for the given control, using the provided
24
+ * {@link sap.ui.core.RenderManager}.
25
+ *
26
+ * @param {sap.ui.core.RenderManager} rm The reference to the <code>sap.ui.core.RenderManager</code>
27
+ * @param {sap.ui.core.Control} control The control instance to be rendered
28
+ */
29
+ ExampleRenderer.render = function (rm, control) {
30
+
31
+ var i18n = Lib.getResourceBundleFor("<%= libraryNamespace %>");
32
+
33
+ rm.openStart("div", control);
34
+ if (control.getColor() === ExampleColor.Highlight) {
35
+ rm.class("myLibPrefixExampleHighlight");
36
+ } else {
37
+ rm.class("myLibPrefixExample");
38
+ }
39
+ rm.openEnd( );
40
+ rm.text(i18n.getText("ANY_TEXT") + ": " + control.getText());
41
+ rm.close("div");
42
+
43
+ };
44
+
45
+ return ExampleRenderer;
46
+
47
+ });
@@ -0,0 +1,41 @@
1
+ /*!
2
+ * ${copyright}
3
+ */
4
+
5
+ import ResourceBundle from "sap/base/i18n/ResourceBundle";
6
+ import Lib from "sap/ui/core/Lib";
7
+ import RenderManager from "sap/ui/core/RenderManager";
8
+ import Example from "./Example";
9
+ import { ExampleColor } from "./library";
10
+
11
+ /**
12
+ * Example renderer.
13
+ * @namespace
14
+ */
15
+ const ExampleRenderer = {
16
+ apiVersion: 2, // usage of DOM Patcher
17
+
18
+ /**
19
+ * Renders the HTML for the given control, using the provided {@link RenderManager}.
20
+ *
21
+ * @param {RenderManager} rm The reference to the <code>sap.ui.core.RenderManager</code>
22
+ * @param {Example} control The control instance to be rendered
23
+ */
24
+ render: function (rm: RenderManager, control: Example) {
25
+
26
+ const i18n = Lib.getResourceBundleFor("<%= libraryNamespace %>") as ResourceBundle;
27
+
28
+ rm.openStart("div", control);
29
+ if (control.getColor() === ExampleColor.Highlight) {
30
+ rm.class("myLibPrefixExampleHighlight");
31
+ } else {
32
+ rm.class("myLibPrefixExample");
33
+ }
34
+ rm.openEnd( );
35
+ rm.text(i18n.getText("ANY_TEXT") + ": " + control.getText());
36
+ rm.close("div");
37
+ }
38
+
39
+ };
40
+
41
+ export default ExampleRenderer;
@@ -0,0 +1,68 @@
1
+ /*!
2
+ * ${copyright}
3
+ */
4
+
5
+ /**
6
+ * Initialization Code and shared classes of library <%= libraryNamespace %>.
7
+ */
8
+ sap.ui.define([
9
+ "sap/ui/core/Lib"
10
+ ], function (Lib) {
11
+ "use strict";
12
+
13
+ // delegate further initialization of this library to the Core
14
+ // Hint: sap.ui.getCore() must still be used to support preload with sync bootstrap!
15
+ Lib.init({
16
+ name: "<%= libraryNamespace %>",
17
+ version: "${version}",
18
+ dependencies: [ // keep in sync with the ui5.yaml and .library files
19
+ "sap.ui.core"
20
+ ],
21
+ types: [
22
+ "<%= libraryNamespace %>.ExampleColor"
23
+ ],
24
+ interfaces: [],
25
+ controls: [
26
+ "<%= libraryNamespace %>.Example"
27
+ ],
28
+ elements: [],
29
+ noLibraryCSS: false, // if no CSS is provided, you can disable the library.css load here
30
+ apiVersion: 2
31
+ });
32
+
33
+ /**
34
+ * Some description about <code><%= libraryName %></code>
35
+ *
36
+ * @namespace
37
+ * @name <%= libraryNamespace %>
38
+ * @author <%= author %>
39
+ * @version ${version}
40
+ * @public
41
+ */
42
+ var thisLib = <%= libraryNamespace %>;
43
+
44
+ /**
45
+ * Semantic Colors of the <code><%= libraryNamespace %>.Example</code>.
46
+ *
47
+ * @enum {string}
48
+ * @public
49
+ */
50
+ thisLib.ExampleColor = {
51
+
52
+ /**
53
+ * Default color (brand color)
54
+ * @public
55
+ */
56
+ Default : "Default",
57
+
58
+ /**
59
+ * Highlight color
60
+ * @public
61
+ */
62
+ Highlight : "Highlight"
63
+
64
+ };
65
+
66
+ return thisLib;
67
+
68
+ });
@@ -0,0 +1,58 @@
1
+ /*!
2
+ * ${copyright}
3
+ */
4
+
5
+ import ObjectPath from "sap/base/util/ObjectPath";
6
+ import Lib from "sap/ui/core/Lib";
7
+
8
+ /**
9
+ * Initialization Code and shared classes of library <%= libraryNamespace %>.
10
+ */
11
+
12
+ // delegate further initialization of this library to the Core
13
+ // Hint: sap.ui.getCore() must still be used here to support preload with sync bootstrap!
14
+ Lib.init({
15
+ name: "<%= libraryNamespace %>",
16
+ version: "${version}",
17
+ dependencies: [ // keep in sync with the ui5.yaml and .library files
18
+ "sap.ui.core"
19
+ ],
20
+ types: [
21
+ "<%= libraryNamespace %>.ExampleColor"
22
+ ],
23
+ interfaces: [],
24
+ controls: [
25
+ "<%= libraryNamespace %>.Example"
26
+ ],
27
+ elements: [],
28
+ noLibraryCSS: false, // if no CSS is provided, you can disable the library.css load here
29
+ apiVersion: 2,
30
+ });
31
+
32
+ // get the library object from global object space because all enums must be attached to it to be usable as UI5 types
33
+ // FIXME: this line is planned to become obsolete and may need to be removed later
34
+ const thisLib : {[key: string]: unknown} = ObjectPath.get("<%= libraryNamespace %>") as {[key: string]: unknown};
35
+
36
+ /**
37
+ * Semantic Colors of the com.myorg.myUI5Library.Example control.
38
+ *
39
+ * @enum {string}
40
+ * @public
41
+ */
42
+ export enum ExampleColor {
43
+
44
+ /**
45
+ * Default color (brand color)
46
+ * @public
47
+ */
48
+ Default = "Default",
49
+
50
+ /**
51
+ * Highlight color
52
+ * @public
53
+ */
54
+ Highlight = "Highlight"
55
+
56
+ }
57
+ // FIXME: this line is planned to become obsolete and may need to be removed later
58
+ thisLib.ExampleColor = ExampleColor; // add the enum to the library; this is important because UI5 otherwise cannot identify the type and will skip type checking for properties of this type
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
5
+ <title>Test Page for <%= libraryNamespace %>.Example</title>
6
+ <base href="<%= libraryBasepath %>../">
7
+ <script src="resources/sap-ui-core.js"
8
+ id="sap-ui-bootstrap"
9
+ data-sap-ui-async="true"
10
+ data-sap-ui-on-init="module:local/Example"
11
+ data-sap-ui-libs="sap.ui.core,<%= libraryNamespace %>"
12
+ data-sap-ui-theme="sap_fiori_3"
13
+ data-sap-ui-compat-version="edge"
14
+ data-sap-ui-resource-roots='{"local" : "./test-resources/<%= libraryNamespaceURI %>/"}'>
15
+ </script>
16
+ </head>
17
+ <body class="sapUiBody">
18
+ <h1 id="header">Test Page for <code><%= libraryNamespace %>.Example</code></h1>
19
+ <div id="content"></div>
20
+ </body>
21
+ </html>
@@ -0,0 +1,18 @@
1
+ specVersion: '2.2'
2
+ metadata:
3
+ name: "<%= libraryName %>"
4
+ type: library
5
+ framework:
6
+ name: <%= framework %>
7
+ version: <%= frameworkVersion %>
8
+ libraries:
9
+ - name: sap.ui.core
10
+ - name: themelib_sap_fiori_3
11
+ server:
12
+ customMiddleware:
13
+ - name: fiori-tools-appreload
14
+ afterMiddleware: compression
15
+ configuration:
16
+ path: test
17
+ port: 35729
18
+ delay: 300
@@ -0,0 +1,9 @@
1
+ node_modules/
2
+ dist/
3
+ .scp/
4
+ Makefile*.mta
5
+ mta_archives
6
+ mta-*
7
+ resources
8
+ archive.zip
9
+ .*_mta_build_tmp
@@ -0,0 +1,7 @@
1
+ // karma-ui5 usage: https://github.com/SAP/karma-ui5
2
+ module.exports = function (config) {
3
+ config.set({
4
+ frameworks: ["ui5"],
5
+ browsers: ["Chrome"]
6
+ });
7
+ };
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "<%= libraryName %>",
3
+ "version": "1.0.0",
4
+ "devDependencies": {
5
+ "@ui5/cli": "^3.9.1",
6
+ "karma": "6.3.17",
7
+ "karma-chrome-launcher": "^3.1.1",
8
+ "karma-cli": "^2.0.0",
9
+ "karma-ui5": "^3.0.3",
10
+ "@sap/ux-ui5-tooling": "1"
11
+ },
12
+ "scripts": {
13
+ "build": "ui5 build --clean-dest",
14
+ "start": "fiori run --open test-resources/<%= libraryNamespaceURI %>/Example.html",
15
+ "testsuite": "fiori run --open test-resources/<%= libraryNamespaceURI %>/qunit/testsuite.qunit.html",
16
+ "test": "karma start --browsers=ChromeHeadless --singleRun=true"
17
+ }
18
+ }
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" ?>
2
+ <library xmlns="http://www.sap.com/sap.ui.library.xsd">
3
+ <name><%= libraryNamespace %></name>
4
+ <vendor><%= author %></vendor>
5
+ <version>${version}</version>
6
+ <copyright>${copyright}</copyright>
7
+ <title><%= libraryName %></title>
8
+ <documentation>Some description about <%= libraryName %></documentation>
9
+ <dependencies>
10
+ <dependency>
11
+ <libraryName>sap.ui.core</libraryName>
12
+ </dependency>
13
+ </dependencies>
14
+ </library>
@@ -0,0 +1,33 @@
1
+ import { ExampleColor } from "./library";
2
+ import Event from "sap/ui/base/Event";
3
+ import { PropertyBindingInfo } from "sap/ui/base/ManagedObject";
4
+ import { $ControlSettings } from "sap/ui/core/Control";
5
+
6
+ declare module "./Example" {
7
+
8
+ /**
9
+ * Interface defining the settings object used in constructor calls
10
+ */
11
+ interface $ExampleSettings extends $ControlSettings {
12
+ text?: string | PropertyBindingInfo;
13
+ color?: ExampleColor | PropertyBindingInfo | `{${string}}`;
14
+ press?: (event: Event) => void;
15
+ }
16
+
17
+ export default interface Example {
18
+
19
+ // property: text
20
+ getText(): string;
21
+ setText(text: string): this;
22
+
23
+ // property: color
24
+ getColor(): ExampleColor;
25
+ setColor(color: ExampleColor): this;
26
+
27
+ // event: press
28
+ attachPress(fn: (event: Event) => void, listener?: object): this;
29
+ attachPress<CustomDataType extends object>(data: CustomDataType, fn: (event: Event, data: CustomDataType) => void, listener?: object): this;
30
+ detachPress(fn: (event: Event) => void, listener?: object): this;
31
+ firePress(parameters?: object): this;
32
+ }
33
+ }
@@ -0,0 +1,68 @@
1
+ /*!
2
+ * ${copyright}
3
+ */
4
+
5
+ // Provides control <%= libraryNamespace %>.Example.
6
+ sap.ui.define([
7
+ "./library",
8
+ "sap/ui/core/Control",
9
+ "./ExampleRenderer"
10
+ ], function (library, Control, ExampleRenderer) {
11
+ "use strict";
12
+
13
+ // refer to library types
14
+ var ExampleColor = library.ExampleColor;
15
+
16
+ /**
17
+ * Constructor for a new <code><%= libraryNamespace %>.Example</code> control.
18
+ *
19
+ * @param {string} [sId] id for the new control, generated automatically if no id is given
20
+ * @param {object} [mSettings] initial settings for the new control
21
+ *
22
+ * @class
23
+ * Some class description goes here.
24
+ * @extends sap.ui.core.Control
25
+ *
26
+ * @author <%= author %>
27
+ * @version ${version}
28
+ *
29
+ * @constructor
30
+ * @public
31
+ * @alias <%= libraryNamespace %>.Example
32
+ */
33
+ var Example = Control.extend("<%= libraryNamespace %>.Example", /** @lends <%= libraryNamespace %>.Example.prototype */ {
34
+ metadata: {
35
+ library: "<%= libraryNamespace %>",
36
+ properties: {
37
+ /**
38
+ * The text to display.
39
+ */
40
+ text: {
41
+ type: "string",
42
+ group: "Data",
43
+ defaultValue: null
44
+ },
45
+ /**
46
+ * The color to use (default to "Default" color).
47
+ */
48
+ color: {
49
+ type: "<%= libraryNamespace %>.ExampleColor",
50
+ group: "Appearance",
51
+ defaultValue: ExampleColor.Default
52
+ }
53
+ },
54
+ events: {
55
+ /**
56
+ * Event is fired when the user clicks the control.
57
+ */
58
+ press: {}
59
+ }
60
+ },
61
+ renderer: ExampleRenderer,
62
+ onclick: function() {
63
+ this.firePress();
64
+ }
65
+ });
66
+ return Example;
67
+
68
+ });
@@ -0,0 +1,65 @@
1
+ /*!
2
+ * ${copyright}
3
+ */
4
+
5
+ // Provides control <%= libraryNamespace %>.Example.
6
+ import Control from "sap/ui/core/Control";
7
+ import ExampleRenderer from "./ExampleRenderer";
8
+ import { ExampleColor } from "./library";
9
+
10
+
11
+
12
+ /**
13
+ * Constructor for a new <code><%= libraryNamespace %>.Example</code> control.
14
+ *
15
+ * Some class description goes here.
16
+ * @extends Control
17
+ *
18
+ * @author OpenUI5 Team
19
+ * @version ${version}
20
+ *
21
+ * @constructor
22
+ * @public
23
+ * @name <%= libraryNamespace %>.Example
24
+ */
25
+ export default class Example extends Control {
26
+
27
+ // The following three lines were generated and should remain as-is to make TypeScript aware of the constructor signatures
28
+ constructor(id?: string | $ExampleSettings);
29
+ constructor(id?: string, settings?: $ExampleSettings);
30
+ constructor(id?: string, settings?: $ExampleSettings) { super(id, settings); }
31
+
32
+ static readonly metadata = {
33
+ library: "<%= libraryNamespace %>",
34
+ properties: {
35
+ /**
36
+ * The text to display.
37
+ */
38
+ text: {
39
+ type: "string",
40
+ group: "Data",
41
+ defaultValue: null
42
+ },
43
+ /**
44
+ * The color to use (default to "Default" color).
45
+ */
46
+ color: {
47
+ type: "<%= libraryNamespace %>.ExampleColor",
48
+ group: "Appearance",
49
+ defaultValue: ExampleColor.Default
50
+ }
51
+ },
52
+ events: {
53
+ /**
54
+ * Event is fired when the user clicks the control.
55
+ */
56
+ press: {}
57
+ }
58
+ };
59
+
60
+ static renderer = ExampleRenderer;
61
+
62
+ onclick = () => {
63
+ this.firePress();
64
+ };
65
+ }
@@ -0,0 +1,2 @@
1
+ # Translation file of library <%= libraryNamespace %>.
2
+ ANY_TEXT=AnyText
@@ -0,0 +1,19 @@
1
+ /* Theme Parameter Toolbox: https://sdk.openui5.org/test-resources/sap/m/demokit/theming/webapp/index.html */
2
+
3
+ .myLibPrefixExample,
4
+ .myLibPrefixExampleHighlight {
5
+ color: @sapUiText;
6
+ background-color: @sapUiNeutralBG;
7
+ border: 1rem solid @sapUiContentForegroundBorderColor;
8
+ border-radius: 1rem;
9
+ opacity: 0.8;
10
+ padding: 2rem;
11
+ margin: 2rem 8rem;
12
+ text-align: center;
13
+ font-size: 2em;
14
+ line-height: 3em;
15
+ }
16
+
17
+ .myLibPrefixExampleHighlight {
18
+ background-color: @sapUiSuccessBG;
19
+ }
@@ -0,0 +1,4 @@
1
+ @import "/resources/sap/ui/core/themes/base/base.less";
2
+ @import "/resources/sap/ui/core/themes/base/global.less";
3
+
4
+ @import "Example.less";
@@ -0,0 +1,3 @@
1
+ @import "../base/library.source.less";
2
+ @import "/resources/sap/ui/core/themes/sap_belize/base.less";
3
+ @import "/resources/sap/ui/core/themes/sap_belize/global.less";
@@ -0,0 +1,3 @@
1
+ @import "../base/library.source.less";
2
+ @import "/resources/sap/ui/core/themes/sap_belize_hcb/base.less";
3
+ @import "/resources/sap/ui/core/themes/sap_belize_hcb/global.less";
@@ -0,0 +1,3 @@
1
+ @import "../base/library.source.less";
2
+ @import "/resources/sap/ui/core/themes/sap_belize_hcw/base.less";
3
+ @import "/resources/sap/ui/core/themes/sap_belize_hcw/global.less";
@@ -0,0 +1,3 @@
1
+ @import "../sap_belize/library.source.less";
2
+ @import "/resources/sap/ui/core/themes/sap_belize_plus/base.less";
3
+ @import "/resources/sap/ui/core/themes/sap_belize_plus/global.less";
@@ -0,0 +1,3 @@
1
+ @import "../base/library.source.less";
2
+ @import "/resources/sap/ui/core/themes/sap_fiori_3/base.less";
3
+ @import "/resources/sap/ui/core/themes/sap_fiori_3/global.less";
@@ -0,0 +1,3 @@
1
+ @import "../base/library.source.less";
2
+ @import "/resources/sap/ui/core/themes/sap_fiori_3_dark/base.less";
3
+ @import "/resources/sap/ui/core/themes/sap_fiori_3_dark/global.less";
@@ -0,0 +1,3 @@
1
+ @import "../base/library.source.less";
2
+ @import "/resources/sap/ui/core/themes/sap_fiori_3_hcb/base.less";
3
+ @import "/resources/sap/ui/core/themes/sap_fiori_3_hcb/global.less";
@@ -0,0 +1,3 @@
1
+ @import "../base/library.source.less";
2
+ @import "/resources/sap/ui/core/themes/sap_fiori_3_hcw/base.less";
3
+ @import "/resources/sap/ui/core/themes/sap_fiori_3_hcw/global.less";
@@ -0,0 +1,18 @@
1
+ // eslint-disable-next-line no-undef
2
+ sap.ui.define([
3
+ "<%= libraryNamespaceURI %>/library",
4
+ "<%= libraryNamespaceURI %>/Example"
5
+ ], function(library, Example) {
6
+ "use strict";
7
+
8
+ // refer to library types
9
+ var ExampleColor = library.ExampleColor;
10
+
11
+ // create a new instance of the Example control and
12
+ // place it into the DOM element with the id "content"
13
+ new Example({
14
+ text: "Example",
15
+ color: ExampleColor.Highlight
16
+ }).placeAt("content");
17
+
18
+ });
@@ -0,0 +1,9 @@
1
+ import { ExampleColor } from '<%= libraryNamespaceURI %>/library';
2
+ import Example from '<%= libraryNamespaceURI %>/Example';
3
+
4
+ // Create a new instance of the Example control and
5
+ // place it into the DOM element with the id "content"
6
+ new Example({
7
+ text: 'Example',
8
+ color: ExampleColor.Highlight,
9
+ }).placeAt('content');
@@ -0,0 +1,65 @@
1
+ /*global QUnit */
2
+ // eslint-disable-next-line no-undef
3
+ sap.ui.define([
4
+ "sap/ui/qunit/QUnitUtils",
5
+ "sap/ui/qunit/utils/createAndAppendDiv",
6
+ "<%= libraryNamespaceURI %>/library",
7
+ "<%= libraryNamespaceURI %>/Example"
8
+ ], function(qutils, createAndAppendDiv, library, Example) {
9
+ "use strict";
10
+
11
+ // refer to library types
12
+ var ExampleColor = library.ExampleColor;
13
+
14
+ // prepare DOM
15
+ createAndAppendDiv("uiArea1");
16
+
17
+ // module for basic checks
18
+ QUnit.module("Example Tests");
19
+
20
+ // example sync test
21
+ QUnit.test("Sync", function(assert) {
22
+ assert.expect(1);
23
+ assert.ok(true, "ok");
24
+ });
25
+
26
+ // example async test
27
+ QUnit.test("Async", function(assert) {
28
+ assert.expect(1);
29
+ return new Promise(function(resolve, reject) {
30
+ assert.ok(true, "ok");
31
+ resolve();
32
+ });
33
+ })
34
+
35
+ // module for basic checks
36
+ QUnit.module("Basic Control Checks");
37
+
38
+ // some basic control checks
39
+ QUnit.test("Test get properties", function(assert) {
40
+ assert.expect(2);
41
+ var oExample = new Example({
42
+ text: "Example"
43
+ });
44
+ assert.equal(oExample.getText(), "Example", "Check text equals 'Example'");
45
+ assert.equal(oExample.getColor(), ExampleColor.Default, "Check color equals 'Default'");
46
+ });
47
+
48
+ // some basic eventing check
49
+ QUnit.test("Test click event", function(assert) {
50
+ assert.expect(1);
51
+ var oExample = new Example("example", {
52
+ text: "Example",
53
+ press: function() {
54
+ assert.ok(true, "Event has been fired!")
55
+ }
56
+ }).placeAt("uiArea1");
57
+ return new Promise(function(resolve, reject) {
58
+ setTimeout(function() {
59
+ qutils.triggerMouseEvent("example", "click", 1, 1);
60
+ resolve();
61
+ }, 100);
62
+ });
63
+ });
64
+
65
+ });
@@ -0,0 +1,68 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-nocheck
3
+
4
+ /*global QUnit */
5
+ // eslint-disable-next-line no-undef
6
+ sap.ui.define([
7
+ "sap/ui/qunit/QUnitUtils",
8
+ "sap/ui/qunit/utils/createAndAppendDiv",
9
+ "<%= libraryNamespaceURI %>/library",
10
+ "<%= libraryNamespaceURI %>/Example"
11
+ ], function(qutils, createAndAppendDiv, library, Example) {
12
+ "use strict";
13
+
14
+ // refer to library types
15
+ const ExampleColor = library.ExampleColor;
16
+
17
+ // prepare DOM
18
+ createAndAppendDiv("uiArea1");
19
+
20
+ // module for basic checks
21
+ QUnit.module("Example Tests");
22
+
23
+ // example sync test
24
+ QUnit.test("Sync", function(assert) {
25
+ assert.expect(1);
26
+ assert.ok(true, "ok");
27
+ });
28
+
29
+ // example async test
30
+ QUnit.test("Async", function(assert) {
31
+ assert.expect(1);
32
+ return new Promise(function(resolve, reject) {
33
+ assert.ok(true, "ok");
34
+ resolve();
35
+ });
36
+ })
37
+
38
+ // module for basic checks
39
+ QUnit.module("Basic Control Checks");
40
+
41
+ // some basic control checks
42
+ QUnit.test("Test get properties", function(assert) {
43
+ assert.expect(2);
44
+ const oExample = new Example({
45
+ text: "Example"
46
+ });
47
+ assert.equal(oExample.getText(), "Example", "Check text equals 'Example'");
48
+ assert.equal(oExample.getColor(), ExampleColor.Default, "Check color equals 'Default'");
49
+ });
50
+
51
+ // some basic eventing check
52
+ QUnit.test("Test click event", function(assert) {
53
+ assert.expect(1);
54
+ const oExample = new Example("example", {
55
+ text: "Example",
56
+ press: function() {
57
+ assert.ok(true, "Event has been fired!")
58
+ }
59
+ }).placeAt("uiArea1");
60
+ return new Promise(function(resolve, reject) {
61
+ setTimeout(function() {
62
+ qutils.triggerMouseEvent("example", "click", 1, 1);
63
+ resolve();
64
+ }, 100);
65
+ });
66
+ });
67
+
68
+ });
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
5
+ <meta charset="utf-8">
6
+ <base href="<%= libraryBasepath %>../../">
7
+ <title>QUnit TestSuite for <%= libraryNamespace %></title>
8
+ <script src="resources/sap/ui/test/starter/createSuite.js"
9
+ data-sap-ui-testsuite="test-resources/<%= libraryNamespaceURI %>/qunit/testsuite.qunit"></script>
10
+ </head>
11
+ <body>
12
+ </body>
13
+ </html>
@@ -0,0 +1,35 @@
1
+ // eslint-disable-next-line no-undef
2
+ sap.ui.define(function() {
3
+ "use strict";
4
+
5
+ return {
6
+ name: "QUnit TestSuite for <%= libraryNamespace %>",
7
+ defaults: {
8
+ bootCore: true,
9
+ ui5: {
10
+ libs: "sap.ui.core,<%= libraryNamespace %>",
11
+ theme: "sap_fiori_3",
12
+ noConflict: true,
13
+ preload: "auto"
14
+ },
15
+ qunit: {
16
+ version: 2,
17
+ reorder: false
18
+ },
19
+ sinon: {
20
+ version: 4,
21
+ qunitBridge: true,
22
+ useFakeTimers: false
23
+ },
24
+ module: "./{name}.qunit"
25
+ },
26
+ tests: {
27
+ // test file for the Example control
28
+ Example: {
29
+ title: "QUnit Test for Example",
30
+ _alternativeTitle: "QUnit tests: <%= libraryNamespace %>.Example"
31
+ }
32
+ }
33
+ };
34
+
35
+ });
@@ -0,0 +1,35 @@
1
+ // eslint-disable-next-line no-undef
2
+ sap.ui.define(function() {
3
+ "use strict";
4
+
5
+ return {
6
+ name: "QUnit TestSuite for <%= libraryNamespace %>",
7
+ defaults: {
8
+ bootCore: true,
9
+ ui5: {
10
+ libs: "sap.ui.core,<%= libraryNamespace %>",
11
+ theme: "sap_fiori_3",
12
+ noConflict: true,
13
+ preload: "auto"
14
+ },
15
+ qunit: {
16
+ version: 2,
17
+ reorder: false
18
+ },
19
+ sinon: {
20
+ version: 4,
21
+ qunitBridge: true,
22
+ useFakeTimers: false
23
+ },
24
+ module: "./{name}.qunit"
25
+ },
26
+ tests: {
27
+ // test file for the Example control
28
+ Example: {
29
+ title: "QUnit Test for Example",
30
+ _alternativeTitle: "QUnit tests: <%= libraryNamespace %>.Example"
31
+ }
32
+ }
33
+ };
34
+
35
+ });
File without changes