@limetech/lime-web-components 5.10.0 → 5.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -176,4 +176,14 @@ export declare function Command(options: CommandOptions): (commandClass: Command
176
176
  * @group Command bus
177
177
  */
178
178
  export declare function getCommandId(value: object | CommandIdentifier): string;
179
+ /**
180
+ * Get all registered ids of a command and its parent classes
181
+ *
182
+ * @param value - either a command or a command identifier
183
+ *
184
+ * @returns ids of the command
185
+ * @beta
186
+ * @group Command bus
187
+ */
188
+ export declare function getCommandIds(value: object | CommandIdentifier): string[];
179
189
  //# sourceMappingURL=commandbus.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commandbus.d.ts","sourceRoot":"","sources":["../../src/commandbus/commandbus.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAEvD;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,MAAM,CAAC;AAEtD;;;;GAIG;AACH,MAAM,WAAW,UAAW,SAAQ,cAAc;IAC9C;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAEpE;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC;IAE7B;;;;;;OAMG;IACH,WAAW,CAAC,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAEnD;;;;;;OAMG;IACH,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,cAAc,CAAC;IAEvD;;;;;OAKG;IACH,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;CACvD;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC3B;;;;;;OAMG;IACH,MAA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,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,kBAAkB,CAAC,CAAC;AAE3D;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC3B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,GAAG;IAClC;;;;OAIG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;CAC9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,kBACrB,YAAY,UAIrC;AAeD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,GAAG,MAAM,CAgBtE;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,GAAG,MAAM,EAAE,CAWzE"}
@@ -37,12 +37,20 @@ export var CommandEventName;
37
37
  export function Command(options) {
38
38
  return (commandClass) => {
39
39
  setCommandId(commandClass, options.id);
40
+ setHasInstance(commandClass, options.id);
40
41
  };
41
42
  }
42
43
  function setCommandId(commandClass, id) {
43
44
  // eslint-disable-next-line @typescript-eslint/dot-notation
44
45
  commandClass['commandId'] = id;
45
46
  }
47
+ function setHasInstance(commandClass, id) {
48
+ Object.defineProperty(commandClass, Symbol.hasInstance, {
49
+ value: (instance) => {
50
+ return getCommandIds(instance).includes(id);
51
+ },
52
+ });
53
+ }
46
54
  /**
47
55
  * Get the registered id of the command
48
56
  *
@@ -66,3 +74,22 @@ export function getCommandId(value) {
66
74
  /* eslint-enable @typescript-eslint/dot-notation */
67
75
  return null;
68
76
  }
77
+ /**
78
+ * Get all registered ids of a command and its parent classes
79
+ *
80
+ * @param value - either a command or a command identifier
81
+ *
82
+ * @returns ids of the command
83
+ * @beta
84
+ * @group Command bus
85
+ */
86
+ export function getCommandIds(value) {
87
+ let ids = [];
88
+ let id;
89
+ let commandClass = value;
90
+ while ((id = getCommandId(commandClass))) {
91
+ ids = [...ids, id];
92
+ commandClass = Object.getPrototypeOf(commandClass);
93
+ }
94
+ return Array.from(new Set(ids));
95
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=commandbus.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandbus.spec.d.ts","sourceRoot":"","sources":["../../src/commandbus/commandbus.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,55 @@
1
+ import { __decorate } from "tslib";
2
+ /* eslint-disable max-classes-per-file */
3
+ import { Command, getCommandIds } from './commandbus';
4
+ var Webclient;
5
+ (function (Webclient) {
6
+ let TestCommand = class TestCommand {
7
+ };
8
+ TestCommand = __decorate([
9
+ Command({
10
+ id: 'test',
11
+ })
12
+ ], TestCommand);
13
+ Webclient.TestCommand = TestCommand;
14
+ let MyTestCommand = class MyTestCommand extends TestCommand {
15
+ };
16
+ MyTestCommand = __decorate([
17
+ Command({
18
+ id: 'my-test',
19
+ })
20
+ ], MyTestCommand);
21
+ Webclient.MyTestCommand = MyTestCommand;
22
+ })(Webclient || (Webclient = {}));
23
+ var Addon;
24
+ (function (Addon) {
25
+ let TestCommand = class TestCommand {
26
+ };
27
+ TestCommand = __decorate([
28
+ Command({
29
+ id: 'test',
30
+ })
31
+ ], TestCommand);
32
+ Addon.TestCommand = TestCommand;
33
+ })(Addon || (Addon = {}));
34
+ test.each([
35
+ [new Webclient.TestCommand(), ['test']],
36
+ [new Webclient.MyTestCommand(), ['my-test', 'test']],
37
+ ['test', ['test']],
38
+ [null, []],
39
+ ])('getCommandIds() with instance %s returns %j', (value, result) => {
40
+ expect(getCommandIds(value)).toEqual(result);
41
+ });
42
+ test.each([
43
+ [Webclient.TestCommand, ['test']],
44
+ [Webclient.MyTestCommand, ['my-test', 'test']],
45
+ ])('getCommandIds() with class %p returns %j', (value, result) => {
46
+ expect(getCommandIds(value)).toEqual(result);
47
+ });
48
+ test('instanceof returns true when class from another namespace has same command ID', () => {
49
+ const command = new Webclient.TestCommand();
50
+ expect(command).toBeInstanceOf(Addon.TestCommand);
51
+ });
52
+ test('instanceof returns true when sub-class from another namespace has same command ID', () => {
53
+ const command = new Webclient.MyTestCommand();
54
+ expect(command).toBeInstanceOf(Addon.TestCommand);
55
+ });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCommandId = exports.Command = exports.CommandEventName = void 0;
3
+ exports.getCommandIds = exports.getCommandId = exports.Command = exports.CommandEventName = void 0;
4
+ var tslib_1 = require("tslib");
4
5
  var CommandEventName;
5
6
  (function (CommandEventName) {
6
7
  CommandEventName["Received"] = "command.received";
@@ -10,12 +11,20 @@ var CommandEventName;
10
11
  function Command(options) {
11
12
  return function (commandClass) {
12
13
  setCommandId(commandClass, options.id);
14
+ setHasInstance(commandClass, options.id);
13
15
  };
14
16
  }
15
17
  exports.Command = Command;
16
18
  function setCommandId(commandClass, id) {
17
19
  commandClass['commandId'] = id;
18
20
  }
21
+ function setHasInstance(commandClass, id) {
22
+ Object.defineProperty(commandClass, Symbol.hasInstance, {
23
+ value: function (instance) {
24
+ return getCommandIds(instance).includes(id);
25
+ },
26
+ });
27
+ }
19
28
  function getCommandId(value) {
20
29
  if (typeof value === 'string') {
21
30
  return value;
@@ -29,3 +38,14 @@ function getCommandId(value) {
29
38
  return null;
30
39
  }
31
40
  exports.getCommandId = getCommandId;
41
+ function getCommandIds(value) {
42
+ var ids = [];
43
+ var id;
44
+ var commandClass = value;
45
+ while ((id = getCommandId(commandClass))) {
46
+ ids = tslib_1.__spreadArray(tslib_1.__spreadArray([], ids, true), [id], false);
47
+ commandClass = Object.getPrototypeOf(commandClass);
48
+ }
49
+ return Array.from(new Set(ids));
50
+ }
51
+ exports.getCommandIds = getCommandIds;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ var commandbus_1 = require("./commandbus");
5
+ var Webclient;
6
+ (function (Webclient) {
7
+ var TestCommand = (function () {
8
+ function TestCommand() {
9
+ }
10
+ TestCommand = tslib_1.__decorate([
11
+ (0, commandbus_1.Command)({
12
+ id: 'test',
13
+ })
14
+ ], TestCommand);
15
+ return TestCommand;
16
+ }());
17
+ Webclient.TestCommand = TestCommand;
18
+ var MyTestCommand = (function (_super) {
19
+ tslib_1.__extends(MyTestCommand, _super);
20
+ function MyTestCommand() {
21
+ return _super !== null && _super.apply(this, arguments) || this;
22
+ }
23
+ MyTestCommand = tslib_1.__decorate([
24
+ (0, commandbus_1.Command)({
25
+ id: 'my-test',
26
+ })
27
+ ], MyTestCommand);
28
+ return MyTestCommand;
29
+ }(TestCommand));
30
+ Webclient.MyTestCommand = MyTestCommand;
31
+ })(Webclient || (Webclient = {}));
32
+ var Addon;
33
+ (function (Addon) {
34
+ var TestCommand = (function () {
35
+ function TestCommand() {
36
+ }
37
+ TestCommand = tslib_1.__decorate([
38
+ (0, commandbus_1.Command)({
39
+ id: 'test',
40
+ })
41
+ ], TestCommand);
42
+ return TestCommand;
43
+ }());
44
+ Addon.TestCommand = TestCommand;
45
+ })(Addon || (Addon = {}));
46
+ test.each([
47
+ [new Webclient.TestCommand(), ['test']],
48
+ [new Webclient.MyTestCommand(), ['my-test', 'test']],
49
+ ['test', ['test']],
50
+ [null, []],
51
+ ])('getCommandIds() with instance %s returns %j', function (value, result) {
52
+ expect((0, commandbus_1.getCommandIds)(value)).toEqual(result);
53
+ });
54
+ test.each([
55
+ [Webclient.TestCommand, ['test']],
56
+ [Webclient.MyTestCommand, ['my-test', 'test']],
57
+ ])('getCommandIds() with class %p returns %j', function (value, result) {
58
+ expect((0, commandbus_1.getCommandIds)(value)).toEqual(result);
59
+ });
60
+ test('instanceof returns true when class from another namespace has same command ID', function () {
61
+ var command = new Webclient.TestCommand();
62
+ expect(command).toBeInstanceOf(Addon.TestCommand);
63
+ });
64
+ test('instanceof returns true when sub-class from another namespace has same command ID', function () {
65
+ var command = new Webclient.MyTestCommand();
66
+ expect(command).toBeInstanceOf(Addon.TestCommand);
67
+ });
@@ -26,6 +26,7 @@ export declare class CreateLimeobjectDialogCommand {
26
26
  */
27
27
  route?: boolean;
28
28
  title?: string;
29
+ subtitle?: string;
29
30
  context?: LimeWebComponentContext;
30
31
  /**
31
32
  * @beta
@@ -1 +1 @@
1
- {"version":3,"file":"create-dialog.d.ts","sourceRoot":"","sources":["../../../src/limeobject/commands/create-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C;;;;;;;;;;;GAWG;AACH,qBAGa,6BAA6B;IACtC;;OAEG;IACI,QAAQ,EAAE,QAAQ,CAAC;IAE1B;;OAEG;IACI,UAAU,CAAC,EAAE,GAAG,CAAC;IAExB;;OAEG;IACI,KAAK,CAAC,EAAE,OAAO,CAAS;IAKxB,KAAK,CAAC,EAAE,MAAM,CAAC;IAKf,OAAO,CAAC,EAAE,uBAAuB,CAAC;IAEzC;;;;OAIG;IACI,WAAW,CAAC,EAAE,GAAG,CAAC;CAC5B"}
1
+ {"version":3,"file":"create-dialog.d.ts","sourceRoot":"","sources":["../../../src/limeobject/commands/create-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C;;;;;;;;;;;GAWG;AACH,qBAGa,6BAA6B;IACtC;;OAEG;IACI,QAAQ,EAAE,QAAQ,CAAC;IAE1B;;OAEG;IACI,UAAU,CAAC,EAAE,GAAG,CAAC;IAExB;;OAEG;IACI,KAAK,CAAC,EAAE,OAAO,CAAS;IAKxB,KAAK,CAAC,EAAE,MAAM,CAAC;IAKf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAKlB,OAAO,CAAC,EAAE,uBAAuB,CAAC;IAEzC;;;;OAIG;IACI,WAAW,CAAC,EAAE,GAAG,CAAC;CAC5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@limetech/lime-web-components",
3
- "version": "5.10.0",
3
+ "version": "5.12.0",
4
4
  "description": "Lime Web Components",
5
5
  "author": "Lime Technologies",
6
6
  "license": "Apache-2.0",
@@ -35,13 +35,13 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@commitlint/config-conventional": "^16.2.4",
38
- "@microsoft/api-extractor": "^7.34.7",
38
+ "@microsoft/api-extractor": "^7.34.9",
39
39
  "@types/jest": "^27.5.0",
40
- "@typescript-eslint/eslint-plugin": "^5.59.2",
41
- "@typescript-eslint/parser": "^5.59.2",
40
+ "@typescript-eslint/eslint-plugin": "^5.59.6",
41
+ "@typescript-eslint/parser": "^5.59.6",
42
42
  "commitizen": "^4.3.0",
43
43
  "cz-conventional-changelog": "^3.3.0",
44
- "eslint": "^8.39.0",
44
+ "eslint": "^8.40.0",
45
45
  "eslint-config-prettier": "^8.8.0",
46
46
  "eslint-plugin-ban": "^1.6.0",
47
47
  "eslint-plugin-prefer-arrow": "^1.2.3",