mvvm-mobx 1.0.3 → 1.1.1

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.
@@ -1,24 +1,24 @@
1
1
  import { InteractionResponse } from "./InteractionResponse";
2
2
  /** Contains predefined common responses and their ID. */
3
3
  export declare class CommonInteractionResponses {
4
- static get ok(): {
4
+ static readonly ok: {
5
5
  id: string;
6
- action: InteractionResponse;
6
+ response: InteractionResponse;
7
7
  };
8
- static get cancel(): {
8
+ static readonly cancel: {
9
9
  id: string;
10
- action: InteractionResponse;
10
+ response: InteractionResponse;
11
11
  };
12
- static get close(): {
12
+ static readonly close: {
13
13
  id: string;
14
- action: InteractionResponse;
14
+ response: InteractionResponse;
15
15
  };
16
- static get yes(): {
16
+ static readonly yes: {
17
17
  id: string;
18
- action: InteractionResponse;
18
+ response: InteractionResponse;
19
19
  };
20
- static get no(): {
20
+ static readonly no: {
21
21
  id: string;
22
- action: InteractionResponse;
22
+ response: InteractionResponse;
23
23
  };
24
24
  }
@@ -4,10 +4,10 @@ exports.CommonInteractionResponses = void 0;
4
4
  const InteractionResponse_1 = require("./InteractionResponse");
5
5
  /** Contains predefined common responses and their ID. */
6
6
  class CommonInteractionResponses {
7
- static get ok() { return { id: 'ok', action: new InteractionResponse_1.InteractionResponse('ok', 'OK') }; }
8
- static get cancel() { return { id: 'cancel', action: new InteractionResponse_1.InteractionResponse('cancel', 'Cancel') }; }
9
- static get close() { return { id: 'close', action: new InteractionResponse_1.InteractionResponse('close', 'Close') }; }
10
- static get yes() { return { id: 'yes', action: new InteractionResponse_1.InteractionResponse('yes', 'Yes') }; }
11
- static get no() { return { id: 'no', action: new InteractionResponse_1.InteractionResponse('no', 'No') }; }
12
7
  }
13
8
  exports.CommonInteractionResponses = CommonInteractionResponses;
9
+ CommonInteractionResponses.ok = { id: 'ok', response: new InteractionResponse_1.InteractionResponse('ok', 'OK') };
10
+ CommonInteractionResponses.cancel = { id: 'cancel', response: new InteractionResponse_1.InteractionResponse('cancel', 'Cancel') };
11
+ CommonInteractionResponses.close = { id: 'close', response: new InteractionResponse_1.InteractionResponse('close', 'Close') };
12
+ CommonInteractionResponses.yes = { id: 'yes', response: new InteractionResponse_1.InteractionResponse('yes', 'Yes') };
13
+ CommonInteractionResponses.no = { id: 'no', response: new InteractionResponse_1.InteractionResponse('no', 'No') };
@@ -14,7 +14,7 @@ class Interact {
14
14
  * @returns true if @constant CommonInteractionResponses.Ok.id was selected, or false if @constant CommonInteractionResponses.Cancel.id was selected.
15
15
  */
16
16
  static async withOkCancel(interactionManager, title, content) {
17
- return await this.withCustomAndCancel(interactionManager, title, content, CommonInteractionResponses_1.CommonInteractionResponses.ok.action);
17
+ return await this.withCustomAndCancel(interactionManager, title, content, CommonInteractionResponses_1.CommonInteractionResponses.ok.response);
18
18
  }
19
19
  /**
20
20
  * Interact with the user with a default OK action.
@@ -27,7 +27,7 @@ class Interact {
27
27
  return (await interactionManager.requestInteraction({
28
28
  title,
29
29
  content,
30
- responses: [CommonInteractionResponses_1.CommonInteractionResponses.ok.action],
30
+ responses: [CommonInteractionResponses_1.CommonInteractionResponses.ok.response],
31
31
  defaultActionId: CommonInteractionResponses_1.CommonInteractionResponses.ok.id,
32
32
  })) === CommonInteractionResponses_1.CommonInteractionResponses.ok.id;
33
33
  }
@@ -40,7 +40,7 @@ class Interact {
40
40
  * @returns true if @constant CommonInteractionResponses.Ok.id was selected, or false if @constant CommonInteractionResponses.Cancel.id was selected.
41
41
  */
42
42
  static async withOkCommand(interactionManager, title, content, okCommand) {
43
- return await this.withCustomAndCancel(interactionManager, title, content, new InteractionResponse_1.InteractionResponse(CommonInteractionResponses_1.CommonInteractionResponses.ok.id, CommonInteractionResponses_1.CommonInteractionResponses.ok.action.title, okCommand));
43
+ return await this.withCustomAndCancel(interactionManager, title, content, new InteractionResponse_1.InteractionResponse(CommonInteractionResponses_1.CommonInteractionResponses.ok.id, CommonInteractionResponses_1.CommonInteractionResponses.ok.response.title, okCommand));
44
44
  }
45
45
  /**
46
46
  * Interact with the user with default Yes and No responses.
@@ -53,7 +53,7 @@ class Interact {
53
53
  return (await interactionManager.requestInteraction({
54
54
  title,
55
55
  content,
56
- responses: [CommonInteractionResponses_1.CommonInteractionResponses.yes.action, CommonInteractionResponses_1.CommonInteractionResponses.no.action],
56
+ responses: [CommonInteractionResponses_1.CommonInteractionResponses.yes.response, CommonInteractionResponses_1.CommonInteractionResponses.no.response],
57
57
  defaultActionId: CommonInteractionResponses_1.CommonInteractionResponses.yes.id,
58
58
  cancelActionId: CommonInteractionResponses_1.CommonInteractionResponses.no.id,
59
59
  })) === CommonInteractionResponses_1.CommonInteractionResponses.yes.id;
@@ -75,7 +75,7 @@ class Interact {
75
75
  content,
76
76
  responses: [
77
77
  action,
78
- new InteractionResponse_1.InteractionResponse(CommonInteractionResponses_1.CommonInteractionResponses.cancel.id, CommonInteractionResponses_1.CommonInteractionResponses.cancel.action.title,
78
+ new InteractionResponse_1.InteractionResponse(CommonInteractionResponses_1.CommonInteractionResponses.cancel.id, CommonInteractionResponses_1.CommonInteractionResponses.cancel.response.title,
79
79
  // A Cancel action that becomes disabled when the OK command (if exists) is active:
80
80
  new RelayCommand_1.RelayCommand(() => content?.onOperationFinished?.call(CommonInteractionResponses_1.CommonInteractionResponses.cancel.id), () => action.command?.workingFlag?.isActive !== true)),
81
81
  ],
@@ -3,12 +3,12 @@ import { RelayCommand } from "../commands/RelayCommand";
3
3
  export declare class InteractionResponse {
4
4
  /** The ID of the response. */
5
5
  readonly id: string;
6
- /** The title of the response. */
7
- readonly title: string;
8
6
  /** An optional command to invoke as the user responds. */
9
7
  readonly command?: RelayCommand<void> | undefined;
10
8
  /** An optional icon. */
11
9
  readonly icon?: string | undefined;
10
+ /** The title of the response. */
11
+ accessor title: string;
12
12
  constructor(
13
13
  /** The ID of the response. */
14
14
  id: string,
@@ -1,21 +1,90 @@
1
1
  "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
37
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
38
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
39
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
40
+ };
41
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
42
+ if (kind === "m") throw new TypeError("Private method is not writable");
43
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
44
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
45
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
46
+ };
2
47
  Object.defineProperty(exports, "__esModule", { value: true });
3
48
  exports.InteractionResponse = void 0;
49
+ const mobx_1 = require("mobx");
4
50
  /** Represents an action for the user to respond on an interaction request. */
5
- class InteractionResponse {
6
- constructor(
7
- /** The ID of the response. */
8
- id,
9
- /** The title of the response. */
10
- title,
11
- /** An optional command to invoke as the user responds. */
12
- command,
13
- /** An optional icon. */
14
- icon) {
15
- this.id = id;
16
- this.title = title;
17
- this.command = command;
18
- this.icon = icon;
19
- }
20
- }
51
+ let InteractionResponse = (() => {
52
+ var _a, _InteractionResponse_title_accessor_storage;
53
+ let _title_decorators;
54
+ let _title_initializers = [];
55
+ let _title_extraInitializers = [];
56
+ return _a = class InteractionResponse {
57
+ /** The title of the response. */
58
+ get title() { return __classPrivateFieldGet(this, _InteractionResponse_title_accessor_storage, "f"); }
59
+ set title(value) { __classPrivateFieldSet(this, _InteractionResponse_title_accessor_storage, value, "f"); }
60
+ constructor(
61
+ /** The ID of the response. */
62
+ id,
63
+ /** The title of the response. */
64
+ title,
65
+ /** An optional command to invoke as the user responds. */
66
+ command,
67
+ /** An optional icon. */
68
+ icon) {
69
+ this.id = id;
70
+ this.command = command;
71
+ this.icon = icon;
72
+ _InteractionResponse_title_accessor_storage.set(this, __runInitializers(this, _title_initializers, ''));
73
+ __runInitializers(this, _title_extraInitializers);
74
+ this.id = id;
75
+ this.command = command;
76
+ this.icon = icon;
77
+ this.title = title;
78
+ (0, mobx_1.makeObservable)(this);
79
+ }
80
+ },
81
+ _InteractionResponse_title_accessor_storage = new WeakMap(),
82
+ (() => {
83
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
84
+ _title_decorators = [mobx_1.observable];
85
+ __esDecorate(_a, null, _title_decorators, { kind: "accessor", name: "title", static: false, private: false, access: { has: obj => "title" in obj, get: obj => obj.title, set: (obj, value) => { obj.title = value; } }, metadata: _metadata }, _title_initializers, _title_extraInitializers);
86
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
87
+ })(),
88
+ _a;
89
+ })();
21
90
  exports.InteractionResponse = InteractionResponse;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mvvm-mobx",
3
- "version": "1.0.3",
3
+ "version": "1.1.1",
4
4
  "description": "MVVM pattern implementation with MobX for reactive state management",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",