@vnejs/module.controller.accept 0.2.1 → 0.2.2

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/dist/index.d.ts CHANGED
@@ -6,13 +6,12 @@ export declare abstract class ModuleControllerAccept<TEvents extends ModuleContr
6
6
  abstract EVENT_SHOW: string;
7
7
  abstract EVENT_HIDE: string;
8
8
  abstract EVENT_ACCEPT: string;
9
- abstract EVENT_STATE_UPDATE: string;
9
+ EVENT_STATE_UPDATE?: string;
10
10
  abstract CONTROLS_ZINDEX: number;
11
+ IS_ACCEPT_ENABLED: boolean;
12
+ IS_INTERACT_ENABLED: boolean;
11
13
  emitAccept: () => Promise<unknown[]> | undefined;
12
- controls: {
13
- abstract_accept: () => undefined;
14
- abstract_interact: () => undefined;
15
- };
14
+ get controls(): Record<string, () => void>;
16
15
  subscribe: () => void;
17
16
  getDefaultState: () => TState;
18
17
  abstract onAccept: () => void | Promise<void>;
package/dist/index.js CHANGED
@@ -1,15 +1,23 @@
1
1
  import { ModuleCore } from "@vnejs/module.core";
2
2
  export class ModuleControllerAccept extends ModuleCore {
3
+ EVENT_STATE_UPDATE;
4
+ IS_ACCEPT_ENABLED = true;
5
+ IS_INTERACT_ENABLED = true;
3
6
  emitAccept = () => this.emit(this.EVENT_ACCEPT);
4
- controls = {
5
- [this.CONST.CONTROLS.BUTTONS.ACCEPT]: () => void this.emitAccept(),
6
- [this.CONST.CONTROLS.BUTTONS.INTERACT]: () => void this.emitAccept(),
7
- };
7
+ get controls() {
8
+ const controls = {};
9
+ if (this.IS_ACCEPT_ENABLED)
10
+ controls[this.CONST.CONTROLS.BUTTONS.ACCEPT] = () => void this.emitAccept();
11
+ if (this.IS_INTERACT_ENABLED)
12
+ controls[this.CONST.CONTROLS.BUTTONS.INTERACT] = () => void this.emitAccept();
13
+ return controls;
14
+ }
8
15
  subscribe = () => {
9
16
  this.on(this.EVENT_SHOW, this.onShow);
10
17
  this.on(this.EVENT_HIDE, this.onHide);
11
18
  this.on(this.EVENT_ACCEPT, this.onAccept);
12
- this.on(this.EVENT_STATE_UPDATE, this.updateState);
19
+ if (this.EVENT_STATE_UPDATE)
20
+ this.on(this.EVENT_STATE_UPDATE, this.updateState);
13
21
  };
14
22
  getDefaultState = () => ({});
15
23
  onShow = () => this.emit(this.EVENTS.CONTROLS.PUSH, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/module.controller.accept",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -27,22 +27,29 @@ export abstract class ModuleControllerAccept<
27
27
  abstract EVENT_SHOW: string;
28
28
  abstract EVENT_HIDE: string;
29
29
  abstract EVENT_ACCEPT: string;
30
- abstract EVENT_STATE_UPDATE: string;
30
+ EVENT_STATE_UPDATE?: string;
31
31
 
32
32
  abstract CONTROLS_ZINDEX: number;
33
33
 
34
+ IS_ACCEPT_ENABLED = true;
35
+ IS_INTERACT_ENABLED = true;
36
+
34
37
  emitAccept = () => this.emit(this.EVENT_ACCEPT);
35
38
 
36
- controls = {
37
- [this.CONST.CONTROLS.BUTTONS.ACCEPT]: () => void this.emitAccept(),
38
- [this.CONST.CONTROLS.BUTTONS.INTERACT]: () => void this.emitAccept(),
39
- };
39
+ get controls() {
40
+ const controls: Record<string, () => void> = {};
41
+
42
+ if (this.IS_ACCEPT_ENABLED) controls[this.CONST.CONTROLS.BUTTONS.ACCEPT] = () => void this.emitAccept();
43
+ if (this.IS_INTERACT_ENABLED) controls[this.CONST.CONTROLS.BUTTONS.INTERACT] = () => void this.emitAccept();
44
+
45
+ return controls;
46
+ }
40
47
 
41
48
  subscribe = () => {
42
49
  this.on(this.EVENT_SHOW, this.onShow);
43
50
  this.on(this.EVENT_HIDE, this.onHide);
44
51
  this.on(this.EVENT_ACCEPT, this.onAccept);
45
- this.on(this.EVENT_STATE_UPDATE, this.updateState);
52
+ if (this.EVENT_STATE_UPDATE) this.on(this.EVENT_STATE_UPDATE, this.updateState);
46
53
  };
47
54
 
48
55
  getDefaultState = (): TState => ({}) as TState;