@vnejs/module.controller.accept 0.2.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.
@@ -0,0 +1,21 @@
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 = unknown> extends ModuleCore<TEvents, TConstants, TSettings, TParams, TState> {
5
+ abstract name: string;
6
+ abstract EVENT_SHOW: string;
7
+ abstract EVENT_HIDE: string;
8
+ abstract EVENT_ACCEPT: string;
9
+ abstract EVENT_STATE_UPDATE: string;
10
+ abstract CONTROLS_ZINDEX: number;
11
+ emitAccept: () => Promise<unknown[]> | undefined;
12
+ controls: {
13
+ abstract_accept: () => undefined;
14
+ abstract_interact: () => undefined;
15
+ };
16
+ subscribe: () => void;
17
+ getDefaultState: () => TState;
18
+ abstract onAccept: () => void | Promise<void>;
19
+ onShow: () => Promise<unknown[]> | undefined;
20
+ onHide: () => Promise<unknown[]> | undefined;
21
+ }
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ export class ModuleControllerAccept extends ModuleCore {
3
+ 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
+ };
8
+ subscribe = () => {
9
+ this.on(this.EVENT_SHOW, this.onShow);
10
+ this.on(this.EVENT_HIDE, this.onHide);
11
+ this.on(this.EVENT_ACCEPT, this.onAccept);
12
+ this.on(this.EVENT_STATE_UPDATE, this.updateState);
13
+ };
14
+ getDefaultState = () => ({});
15
+ onShow = () => this.emit(this.EVENTS.CONTROLS.PUSH, {
16
+ key: this.name,
17
+ controls: this.controls,
18
+ index: this.CONTROLS_ZINDEX + 1,
19
+ checkNext: true,
20
+ });
21
+ onHide = () => {
22
+ this.setDefaultState();
23
+ return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name });
24
+ };
25
+ }
@@ -0,0 +1,6 @@
1
+ import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
2
+ import type { Constants as ControlsConstants, PluginName as ControlsPluginName, SubscribeEvents as ControlsSubscribeEvents } from "@vnejs/contracts.controls";
3
+ export type ModuleControllerAcceptEvents = ModuleCoreEvents & Record<ControlsPluginName, ControlsSubscribeEvents>;
4
+ export type ModuleControllerAcceptConstants = ModuleCoreConstants & Record<ControlsPluginName, ControlsConstants>;
5
+ export type ModuleControllerAcceptSettings = ModuleCoreSettings;
6
+ export type ModuleControllerAcceptParams = ModuleCoreParams;
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@vnejs/module.controller.accept",
3
+ "version": "0.2.1",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "src",
18
+ "tsconfig.json"
19
+ ],
20
+ "scripts": {
21
+ "test": "echo \"Error: no test specified\" && exit 1",
22
+ "build": "npx @vnejs/monorepo package",
23
+ "publish:major": "npx @vnejs/monorepo publish major --access public",
24
+ "publish:minor": "npx @vnejs/monorepo publish minor --access public",
25
+ "publish:patch": "npx @vnejs/monorepo publish patch --access public"
26
+ },
27
+ "author": "",
28
+ "license": "ISC",
29
+ "peerDependencies": {
30
+ "@vnejs/module.core": "~0.2.0",
31
+ "@vnejs/contracts.controls": "~0.2.0",
32
+ "@vnejs/shared": "~0.2.0"
33
+ },
34
+ "devDependencies": {
35
+ "@vnejs/configs.ts-common": "~0.2.0",
36
+ "@vnejs/module.core": "~0.2.0",
37
+ "@vnejs/contracts.controls": "~0.2.0",
38
+ "@vnejs/shared": "~0.2.0"
39
+ }
40
+ }
package/src/index.ts ADDED
@@ -0,0 +1,65 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import type { ControlsPopPayload, ControlsPushPayload } from "@vnejs/contracts.controls";
3
+
4
+ import type {
5
+ ModuleControllerAcceptConstants,
6
+ ModuleControllerAcceptEvents,
7
+ ModuleControllerAcceptParams,
8
+ ModuleControllerAcceptSettings,
9
+ } from "./types.js";
10
+
11
+ export type {
12
+ ModuleControllerAcceptConstants,
13
+ ModuleControllerAcceptEvents,
14
+ ModuleControllerAcceptParams,
15
+ ModuleControllerAcceptSettings,
16
+ } from "./types.js";
17
+
18
+ export abstract class ModuleControllerAccept<
19
+ TEvents extends ModuleControllerAcceptEvents = ModuleControllerAcceptEvents,
20
+ TConstants extends ModuleControllerAcceptConstants = ModuleControllerAcceptConstants,
21
+ TSettings extends ModuleControllerAcceptSettings = ModuleControllerAcceptSettings,
22
+ TParams extends ModuleControllerAcceptParams = ModuleControllerAcceptParams,
23
+ TState = unknown,
24
+ > extends ModuleCore<TEvents, TConstants, TSettings, TParams, TState> {
25
+ abstract override name: string;
26
+
27
+ abstract EVENT_SHOW: string;
28
+ abstract EVENT_HIDE: string;
29
+ abstract EVENT_ACCEPT: string;
30
+ abstract EVENT_STATE_UPDATE: string;
31
+
32
+ abstract CONTROLS_ZINDEX: number;
33
+
34
+ emitAccept = () => this.emit(this.EVENT_ACCEPT);
35
+
36
+ controls = {
37
+ [this.CONST.CONTROLS.BUTTONS.ACCEPT]: () => void this.emitAccept(),
38
+ [this.CONST.CONTROLS.BUTTONS.INTERACT]: () => void this.emitAccept(),
39
+ };
40
+
41
+ subscribe = () => {
42
+ this.on(this.EVENT_SHOW, this.onShow);
43
+ this.on(this.EVENT_HIDE, this.onHide);
44
+ this.on(this.EVENT_ACCEPT, this.onAccept);
45
+ this.on(this.EVENT_STATE_UPDATE, this.updateState);
46
+ };
47
+
48
+ getDefaultState = (): TState => ({}) as TState;
49
+
50
+ abstract onAccept: () => void | Promise<void>;
51
+
52
+ onShow = () =>
53
+ this.emit(this.EVENTS.CONTROLS.PUSH, {
54
+ key: this.name,
55
+ controls: this.controls,
56
+ index: this.CONTROLS_ZINDEX + 1,
57
+ checkNext: true,
58
+ } satisfies ControlsPushPayload);
59
+
60
+ onHide = () => {
61
+ this.setDefaultState();
62
+
63
+ return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name } satisfies ControlsPopPayload);
64
+ };
65
+ }
package/src/types.ts ADDED
@@ -0,0 +1,14 @@
1
+ import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
2
+ import type {
3
+ Constants as ControlsConstants,
4
+ PluginName as ControlsPluginName,
5
+ SubscribeEvents as ControlsSubscribeEvents,
6
+ } from "@vnejs/contracts.controls";
7
+
8
+ export type ModuleControllerAcceptEvents = ModuleCoreEvents & Record<ControlsPluginName, ControlsSubscribeEvents>;
9
+
10
+ export type ModuleControllerAcceptConstants = ModuleCoreConstants & Record<ControlsPluginName, ControlsConstants>;
11
+
12
+ export type ModuleControllerAcceptSettings = ModuleCoreSettings;
13
+
14
+ export type ModuleControllerAcceptParams = ModuleCoreParams;
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "@vnejs/configs.ts-common/tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist"
6
+ },
7
+ "include": ["src/**/*.ts"],
8
+ "exclude": ["dist", "node_modules"]
9
+ }