@vnejs/module.controller.accept 0.2.5 → 0.2.6
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 +4 -5
- package/dist/index.js +10 -12
- package/dist/types.d.ts +3 -0
- package/package.json +1 -1
- package/src/index.ts +26 -16
- package/src/types.ts +4 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
-
import type { ModuleControllerAcceptConstants, ModuleControllerAcceptEvents, ModuleControllerAcceptParams, ModuleControllerAcceptSettings } from "./types.js";
|
|
3
|
-
export type { ModuleControllerAcceptConstants, ModuleControllerAcceptEvents, ModuleControllerAcceptParams, ModuleControllerAcceptSettings } from "./types.js";
|
|
4
|
-
export declare abstract class ModuleControllerAccept<TEvents extends ModuleControllerAcceptEvents = ModuleControllerAcceptEvents, TConstants extends ModuleControllerAcceptConstants = ModuleControllerAcceptConstants, TSettings extends ModuleControllerAcceptSettings = ModuleControllerAcceptSettings, TParams extends ModuleControllerAcceptParams = ModuleControllerAcceptParams, TState =
|
|
2
|
+
import type { ModuleControllerAcceptConstants, ModuleControllerAcceptEvents, ModuleControllerAcceptParams, ModuleControllerAcceptSettings, ModuleControllerAcceptState } from "./types.js";
|
|
3
|
+
export type { ModuleControllerAcceptConstants, ModuleControllerAcceptEvents, ModuleControllerAcceptParams, ModuleControllerAcceptSettings, ModuleControllerAcceptState, } from "./types.js";
|
|
4
|
+
export declare abstract class ModuleControllerAccept<TEvents extends ModuleControllerAcceptEvents = ModuleControllerAcceptEvents, TConstants extends ModuleControllerAcceptConstants = ModuleControllerAcceptConstants, TSettings extends ModuleControllerAcceptSettings = ModuleControllerAcceptSettings, TParams extends ModuleControllerAcceptParams = ModuleControllerAcceptParams, TState extends ModuleControllerAcceptState = ModuleControllerAcceptState> extends ModuleCore<TEvents, TConstants, TSettings, TParams, TState> {
|
|
5
5
|
abstract name: string;
|
|
6
6
|
abstract EVENT_SHOW: string;
|
|
7
7
|
abstract EVENT_HIDE: string;
|
|
8
8
|
abstract EVENT_ACCEPT: string;
|
|
9
|
-
|
|
9
|
+
EVENT_UPDATE_STATE?: string;
|
|
10
10
|
abstract CONTROLS_ZINDEX: number;
|
|
11
11
|
IS_ACCEPT_ENABLED: boolean;
|
|
12
12
|
IS_INTERACT_ENABLED: boolean;
|
|
13
|
-
isShow: boolean;
|
|
14
13
|
emitAccept: () => Promise<import("@vnejs/shared").EmitResults<string>> | undefined;
|
|
15
14
|
get CONTROLS(): Record<string, () => void>;
|
|
16
15
|
subscribe: () => void;
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ModuleCore } from "@vnejs/module.core";
|
|
2
2
|
export class ModuleControllerAccept extends ModuleCore {
|
|
3
|
-
|
|
3
|
+
EVENT_UPDATE_STATE;
|
|
4
4
|
IS_ACCEPT_ENABLED = true;
|
|
5
5
|
IS_INTERACT_ENABLED = true;
|
|
6
|
-
isShow = false;
|
|
7
6
|
emitAccept = () => this.emit(this.EVENT_ACCEPT);
|
|
8
7
|
get CONTROLS() {
|
|
9
8
|
const controls = {};
|
|
@@ -14,17 +13,16 @@ export class ModuleControllerAccept extends ModuleCore {
|
|
|
14
13
|
return controls;
|
|
15
14
|
}
|
|
16
15
|
subscribe = () => {
|
|
17
|
-
|
|
18
|
-
this.on(this.
|
|
16
|
+
const { SHOW, HIDE } = this.CONST.COMPONENTS.LIFECYCLE_PRIORITY;
|
|
17
|
+
this.on(this.EVENT_SHOW, this.onShow, { priority: SHOW.CONTROLS });
|
|
18
|
+
this.on(this.EVENT_HIDE, this.onHide, { priority: HIDE.CONTROLS });
|
|
19
19
|
this.on(this.EVENT_ACCEPT, this.onAccept);
|
|
20
|
-
if (this.
|
|
21
|
-
this.on(this.
|
|
20
|
+
if (this.EVENT_UPDATE_STATE)
|
|
21
|
+
this.on(this.EVENT_UPDATE_STATE, this.updateState);
|
|
22
22
|
};
|
|
23
|
-
getDefaultState = () => ({});
|
|
23
|
+
getDefaultState = () => ({ isShow: false });
|
|
24
24
|
onShow = () => {
|
|
25
|
-
|
|
26
|
-
return;
|
|
27
|
-
this.isShow = true;
|
|
25
|
+
this.updateState({ isShow: true });
|
|
28
26
|
return this.emit(this.EVENTS.CONTROLS.PUSH, {
|
|
29
27
|
key: this.name,
|
|
30
28
|
controls: this.CONTROLS,
|
|
@@ -33,9 +31,9 @@ export class ModuleControllerAccept extends ModuleCore {
|
|
|
33
31
|
});
|
|
34
32
|
};
|
|
35
33
|
onHide = () => {
|
|
36
|
-
if (!this.isShow)
|
|
34
|
+
if (!this.state.isShow)
|
|
37
35
|
return;
|
|
38
|
-
this.isShow
|
|
36
|
+
this.updateState({ isShow: false });
|
|
39
37
|
this.setDefaultState();
|
|
40
38
|
return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name });
|
|
41
39
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -4,3 +4,6 @@ export type ModuleControllerAcceptEvents = ModuleCoreEvents & Record<ControlsPlu
|
|
|
4
4
|
export type ModuleControllerAcceptConstants = ModuleCoreConstants & Record<ControlsPluginName, ControlsConstants>;
|
|
5
5
|
export type ModuleControllerAcceptSettings = ModuleCoreSettings;
|
|
6
6
|
export type ModuleControllerAcceptParams = ModuleCoreParams;
|
|
7
|
+
export type ModuleControllerAcceptState = {
|
|
8
|
+
isShow: boolean;
|
|
9
|
+
};
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,31 +1,41 @@
|
|
|
1
1
|
import { ModuleCore } from "@vnejs/module.core";
|
|
2
2
|
import type { ControlsPopPayload, ControlsPushPayload } from "@vnejs/contracts.controls";
|
|
3
3
|
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import type {
|
|
5
|
+
ModuleControllerAcceptConstants,
|
|
6
|
+
ModuleControllerAcceptEvents,
|
|
7
|
+
ModuleControllerAcceptParams,
|
|
8
|
+
ModuleControllerAcceptSettings,
|
|
9
|
+
ModuleControllerAcceptState,
|
|
10
|
+
} from "./types.js";
|
|
11
|
+
|
|
12
|
+
export type {
|
|
13
|
+
ModuleControllerAcceptConstants,
|
|
14
|
+
ModuleControllerAcceptEvents,
|
|
15
|
+
ModuleControllerAcceptParams,
|
|
16
|
+
ModuleControllerAcceptSettings,
|
|
17
|
+
ModuleControllerAcceptState,
|
|
18
|
+
} from "./types.js";
|
|
7
19
|
|
|
8
20
|
export abstract class ModuleControllerAccept<
|
|
9
21
|
TEvents extends ModuleControllerAcceptEvents = ModuleControllerAcceptEvents,
|
|
10
22
|
TConstants extends ModuleControllerAcceptConstants = ModuleControllerAcceptConstants,
|
|
11
23
|
TSettings extends ModuleControllerAcceptSettings = ModuleControllerAcceptSettings,
|
|
12
24
|
TParams extends ModuleControllerAcceptParams = ModuleControllerAcceptParams,
|
|
13
|
-
TState =
|
|
25
|
+
TState extends ModuleControllerAcceptState = ModuleControllerAcceptState,
|
|
14
26
|
> extends ModuleCore<TEvents, TConstants, TSettings, TParams, TState> {
|
|
15
27
|
abstract override name: string;
|
|
16
28
|
|
|
17
29
|
abstract EVENT_SHOW: string;
|
|
18
30
|
abstract EVENT_HIDE: string;
|
|
19
31
|
abstract EVENT_ACCEPT: string;
|
|
20
|
-
|
|
32
|
+
EVENT_UPDATE_STATE?: string;
|
|
21
33
|
|
|
22
34
|
abstract CONTROLS_ZINDEX: number;
|
|
23
35
|
|
|
24
36
|
IS_ACCEPT_ENABLED = true;
|
|
25
37
|
IS_INTERACT_ENABLED = true;
|
|
26
38
|
|
|
27
|
-
isShow = false;
|
|
28
|
-
|
|
29
39
|
emitAccept = () => this.emit(this.EVENT_ACCEPT);
|
|
30
40
|
|
|
31
41
|
get CONTROLS() {
|
|
@@ -38,20 +48,20 @@ export abstract class ModuleControllerAccept<
|
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
subscribe = () => {
|
|
41
|
-
|
|
42
|
-
|
|
51
|
+
const { SHOW, HIDE } = this.CONST.COMPONENTS.LIFECYCLE_PRIORITY;
|
|
52
|
+
|
|
53
|
+
this.on(this.EVENT_SHOW, this.onShow, { priority: SHOW.CONTROLS });
|
|
54
|
+
this.on(this.EVENT_HIDE, this.onHide, { priority: HIDE.CONTROLS });
|
|
43
55
|
this.on(this.EVENT_ACCEPT, this.onAccept);
|
|
44
|
-
if (this.
|
|
56
|
+
if (this.EVENT_UPDATE_STATE) this.on(this.EVENT_UPDATE_STATE, this.updateState);
|
|
45
57
|
};
|
|
46
58
|
|
|
47
|
-
getDefaultState = (): TState => ({}) as TState;
|
|
59
|
+
getDefaultState = (): TState => ({ isShow: false }) as TState;
|
|
48
60
|
|
|
49
61
|
abstract onAccept: () => void | Promise<void>;
|
|
50
62
|
|
|
51
63
|
onShow = () => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
this.isShow = true;
|
|
64
|
+
this.updateState({ isShow: true } as Partial<TState>);
|
|
55
65
|
|
|
56
66
|
return this.emit(this.EVENTS.CONTROLS.PUSH, {
|
|
57
67
|
key: this.name,
|
|
@@ -62,9 +72,9 @@ export abstract class ModuleControllerAccept<
|
|
|
62
72
|
};
|
|
63
73
|
|
|
64
74
|
onHide = () => {
|
|
65
|
-
if (!this.isShow) return;
|
|
75
|
+
if (!this.state.isShow) return;
|
|
66
76
|
|
|
67
|
-
this.isShow
|
|
77
|
+
this.updateState({ isShow: false } as Partial<TState>);
|
|
68
78
|
this.setDefaultState();
|
|
69
79
|
|
|
70
80
|
return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name } satisfies ControlsPopPayload);
|
package/src/types.ts
CHANGED
|
@@ -8,3 +8,7 @@ export type ModuleControllerAcceptConstants = ModuleCoreConstants & Record<Contr
|
|
|
8
8
|
export type ModuleControllerAcceptSettings = ModuleCoreSettings;
|
|
9
9
|
|
|
10
10
|
export type ModuleControllerAcceptParams = ModuleCoreParams;
|
|
11
|
+
|
|
12
|
+
export type ModuleControllerAcceptState = {
|
|
13
|
+
isShow: boolean;
|
|
14
|
+
};
|