mvvm-mobx 1.1.1 → 1.3.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.
- package/README.md +2 -2
- package/dist/commands/Command.d.ts +6 -0
- package/dist/commands/Command.js +2 -0
- package/dist/commands/RelayCommand.d.ts +2 -1
- package/dist/commands/prop-helpers.d.ts +7 -4
- package/dist/commands/prop-helpers.js +4 -1
- package/dist/interaction/Interact.d.ts +2 -2
- package/dist/interaction/Interact.js +2 -2
- package/dist/interaction/InteractionResponse.d.ts +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -115,8 +115,8 @@ const interactionObject: InteractionRequest = {
|
|
|
115
115
|
title: 'Confirmation',
|
|
116
116
|
content: 'Are you sure you want to delete?',
|
|
117
117
|
actions: [
|
|
118
|
-
CommonInteractionActions.yes.
|
|
119
|
-
CommonInteractionActions.no.
|
|
118
|
+
CommonInteractionActions.yes.response
|
|
119
|
+
CommonInteractionActions.no.response
|
|
120
120
|
]
|
|
121
121
|
};
|
|
122
122
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CounterFlag } from '../core/CounterFlag';
|
|
2
|
-
|
|
2
|
+
import { Command } from './Command';
|
|
3
|
+
export declare class RelayCommand<T = void> implements Command<T> {
|
|
3
4
|
private readonly executeFunc;
|
|
4
5
|
private readonly canExecuteFunc?;
|
|
5
6
|
readonly workingFlag: CounterFlag;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function bindCommand<T>(command:
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Command } from './Command';
|
|
2
|
+
export declare function bindCommand<T>(command: Command<T>, parameter?: any, config?: {
|
|
3
|
+
disabledPropName?: string;
|
|
4
|
+
loadingPropName?: string;
|
|
5
|
+
}): {
|
|
6
|
+
[x: string]: boolean | (() => void) | undefined;
|
|
7
|
+
onClick: () => void;
|
|
5
8
|
} | null;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.bindCommand = bindCommand;
|
|
4
|
-
function bindCommand(command, parameter = null,
|
|
4
|
+
function bindCommand(command, parameter = null, config) {
|
|
5
5
|
if (!command) {
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
8
8
|
const isDisabled = !command.canExecute(parameter);
|
|
9
|
+
const disabledPropName = config?.disabledPropName || 'disabled';
|
|
10
|
+
const loadingPropName = config?.loadingPropName || 'loading';
|
|
9
11
|
return {
|
|
10
12
|
onClick: () => command.execute(parameter),
|
|
11
13
|
[disabledPropName]: isDisabled,
|
|
14
|
+
[loadingPropName]: command.workingFlag?.isActive,
|
|
12
15
|
};
|
|
13
16
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InteractionResponse } from "./InteractionResponse";
|
|
2
2
|
import { InteractionManager } from "./InteractionManager";
|
|
3
|
-
import {
|
|
3
|
+
import { Command } from "../commands/Command";
|
|
4
4
|
import { ReportInteractionOperationFinished } from "./ReportInteractionOperationFinished";
|
|
5
5
|
/** A syntactic-sugar util for working with interactions. */
|
|
6
6
|
export declare class Interact {
|
|
@@ -28,7 +28,7 @@ export declare class Interact {
|
|
|
28
28
|
* @param okCommand The comment to execute when the OK action is selected.
|
|
29
29
|
* @returns true if @constant CommonInteractionResponses.Ok.id was selected, or false if @constant CommonInteractionResponses.Cancel.id was selected.
|
|
30
30
|
*/
|
|
31
|
-
static withOkCommand(interactionManager: InteractionManager, title: string | any, content: ReportInteractionOperationFinished, okCommand:
|
|
31
|
+
static withOkCommand(interactionManager: InteractionManager, title: string | any, content: ReportInteractionOperationFinished, okCommand: Command): Promise<boolean>;
|
|
32
32
|
/**
|
|
33
33
|
* Interact with the user with default Yes and No responses.
|
|
34
34
|
* @param interactionManager In interaction manager to use.
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Interact = void 0;
|
|
4
4
|
const InteractionResponse_1 = require("./InteractionResponse");
|
|
5
|
-
const RelayCommand_1 = require("../commands/RelayCommand");
|
|
6
5
|
const CommonInteractionResponses_1 = require("./CommonInteractionResponses");
|
|
6
|
+
const commands_1 = require("../commands");
|
|
7
7
|
/** A syntactic-sugar util for working with interactions. */
|
|
8
8
|
class Interact {
|
|
9
9
|
/**
|
|
@@ -77,7 +77,7 @@ class Interact {
|
|
|
77
77
|
action,
|
|
78
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
|
-
new
|
|
80
|
+
new commands_1.RelayCommand(() => content?.onOperationFinished?.call(CommonInteractionResponses_1.CommonInteractionResponses.cancel.id), () => action.command?.workingFlag?.isActive !== true)),
|
|
81
81
|
],
|
|
82
82
|
defaultActionId: action.id,
|
|
83
83
|
cancelActionId: CommonInteractionResponses_1.CommonInteractionResponses.cancel.id,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Command } from "../commands/Command";
|
|
2
2
|
/** Represents an action for the user to respond on an interaction request. */
|
|
3
3
|
export declare class InteractionResponse {
|
|
4
4
|
/** The ID of the response. */
|
|
5
5
|
readonly id: string;
|
|
6
6
|
/** An optional command to invoke as the user responds. */
|
|
7
|
-
readonly command?:
|
|
7
|
+
readonly command?: Command<void> | undefined;
|
|
8
8
|
/** An optional icon. */
|
|
9
9
|
readonly icon?: string | undefined;
|
|
10
10
|
/** The title of the response. */
|
|
@@ -15,7 +15,7 @@ export declare class InteractionResponse {
|
|
|
15
15
|
/** The title of the response. */
|
|
16
16
|
title: string,
|
|
17
17
|
/** An optional command to invoke as the user responds. */
|
|
18
|
-
command?:
|
|
18
|
+
command?: Command<void> | undefined,
|
|
19
19
|
/** An optional icon. */
|
|
20
20
|
icon?: string | undefined);
|
|
21
21
|
}
|