@vnejs/module.controller.arrows.horizontal 0.2.7 → 0.2.9
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 -3
- package/dist/index.js +15 -8
- package/package.json +1 -1
- package/src/index.ts +20 -17
package/dist/index.d.ts
CHANGED
|
@@ -15,17 +15,18 @@ export declare abstract class ModuleControllerArrowsHorizontal<TEvents extends M
|
|
|
15
15
|
currentItem: number | null;
|
|
16
16
|
maxCurrentItem: number;
|
|
17
17
|
subscribe: () => void;
|
|
18
|
+
onShow: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:push">> | undefined;
|
|
19
|
+
onHide: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:pop">> | undefined;
|
|
20
|
+
onHideCleanup: () => Promise<import("@vnejs/shared").EmitResults<string> | undefined>;
|
|
21
|
+
emitCurrentItem: () => void;
|
|
18
22
|
getMaxCurrentItem: () => number | Promise<number>;
|
|
19
23
|
isArrowItemAvailable: (_index: number) => boolean | Promise<boolean>;
|
|
20
24
|
onArrowLeft: () => void | Promise<void>;
|
|
21
25
|
onArrowRight: () => void | Promise<void>;
|
|
22
|
-
onShow: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:push">> | undefined;
|
|
23
|
-
onHide: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:pop">> | undefined;
|
|
24
26
|
incCurrentItem: () => Promise<void>;
|
|
25
27
|
decCurrentItem: () => Promise<void>;
|
|
26
28
|
setCurrentItem: (value: number, defaultValue: number, direction?: 1 | -1) => Promise<void>;
|
|
27
29
|
applyCurrentItem: (value: number, defaultValue: number) => void;
|
|
28
30
|
skipUnavailableItems: (direction: 1 | -1) => Promise<void>;
|
|
29
|
-
emitCurrentItem: () => void;
|
|
30
31
|
syncMaxCurrentItem: () => Promise<void>;
|
|
31
32
|
}
|
package/dist/index.js
CHANGED
|
@@ -10,12 +10,9 @@ export class ModuleControllerArrowsHorizontal extends ModuleCore {
|
|
|
10
10
|
const { SHOW, HIDE } = this.CONST.COMPONENTS.LIFECYCLE_PRIORITY;
|
|
11
11
|
this.on(this.EVENT_SHOW, this.onShow, { priority: SHOW.CONTROLS });
|
|
12
12
|
this.on(this.EVENT_HIDE, this.onHide, { priority: HIDE.CONTROLS });
|
|
13
|
+
this.on(this.EVENT_HIDE, this.onHideCleanup, { priority: HIDE.CLEANUP });
|
|
13
14
|
this.on(this.EVENT_UPDATE_STATE, this.updateState);
|
|
14
15
|
};
|
|
15
|
-
getMaxCurrentItem = () => 0;
|
|
16
|
-
isArrowItemAvailable = (_index) => true;
|
|
17
|
-
onArrowLeft = () => void this.decCurrentItem();
|
|
18
|
-
onArrowRight = () => void this.incCurrentItem();
|
|
19
16
|
onShow = () => {
|
|
20
17
|
this.currentItem = null;
|
|
21
18
|
return this.emit(this.EVENTS.CONTROLS.PUSH, {
|
|
@@ -29,6 +26,20 @@ export class ModuleControllerArrowsHorizontal extends ModuleCore {
|
|
|
29
26
|
this.currentItem = null;
|
|
30
27
|
return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name });
|
|
31
28
|
};
|
|
29
|
+
onHideCleanup = async () => {
|
|
30
|
+
this.currentItem = null;
|
|
31
|
+
const unset = { currentArrowHorizontalItem: undefined };
|
|
32
|
+
await this.emit(this.EVENT_UPDATE_STATE, unset);
|
|
33
|
+
return this.emit(this.EVENT_UPDATE_FAST);
|
|
34
|
+
};
|
|
35
|
+
emitCurrentItem = () => {
|
|
36
|
+
this.emit(this.EVENT_UPDATE_STATE, { currentArrowHorizontalItem: this.currentItem });
|
|
37
|
+
this.emit(this.EVENT_UPDATE_FAST);
|
|
38
|
+
};
|
|
39
|
+
getMaxCurrentItem = () => 0;
|
|
40
|
+
isArrowItemAvailable = (_index) => true;
|
|
41
|
+
onArrowLeft = () => void this.decCurrentItem();
|
|
42
|
+
onArrowRight = () => void this.incCurrentItem();
|
|
32
43
|
incCurrentItem = async () => {
|
|
33
44
|
await this.syncMaxCurrentItem();
|
|
34
45
|
return this.setCurrentItem((this.currentItem ?? 0) + 1, 0, 1);
|
|
@@ -64,10 +75,6 @@ export class ModuleControllerArrowsHorizontal extends ModuleCore {
|
|
|
64
75
|
break;
|
|
65
76
|
}
|
|
66
77
|
};
|
|
67
|
-
emitCurrentItem = () => {
|
|
68
|
-
this.emit(this.EVENT_UPDATE_STATE, { currentArrowHorizontalItem: this.currentItem });
|
|
69
|
-
this.emit(this.EVENT_UPDATE_FAST);
|
|
70
|
-
};
|
|
71
78
|
syncMaxCurrentItem = async () => {
|
|
72
79
|
this.maxCurrentItem = await this.getMaxCurrentItem();
|
|
73
80
|
};
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -32,7 +32,6 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
32
32
|
abstract EVENT_UPDATE_FAST: string;
|
|
33
33
|
|
|
34
34
|
abstract CONTROLS_ZINDEX: number;
|
|
35
|
-
|
|
36
35
|
CONTROLS = {
|
|
37
36
|
[this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => void this.onArrowLeft(),
|
|
38
37
|
[this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: () => void this.onArrowRight(),
|
|
@@ -46,16 +45,10 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
46
45
|
|
|
47
46
|
this.on(this.EVENT_SHOW, this.onShow, { priority: SHOW.CONTROLS });
|
|
48
47
|
this.on(this.EVENT_HIDE, this.onHide, { priority: HIDE.CONTROLS });
|
|
48
|
+
this.on(this.EVENT_HIDE, this.onHideCleanup, { priority: HIDE.CLEANUP });
|
|
49
49
|
this.on(this.EVENT_UPDATE_STATE, this.updateState);
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
getMaxCurrentItem = (): number | Promise<number> => 0;
|
|
53
|
-
|
|
54
|
-
isArrowItemAvailable = (_index: number): boolean | Promise<boolean> => true;
|
|
55
|
-
|
|
56
|
-
onArrowLeft = (): void | Promise<void> => void this.decCurrentItem();
|
|
57
|
-
onArrowRight = (): void | Promise<void> => void this.incCurrentItem();
|
|
58
|
-
|
|
59
52
|
onShow = () => {
|
|
60
53
|
this.currentItem = null;
|
|
61
54
|
|
|
@@ -73,6 +66,25 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
73
66
|
return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name } satisfies ControlsPopPayload);
|
|
74
67
|
};
|
|
75
68
|
|
|
69
|
+
onHideCleanup = async () => {
|
|
70
|
+
this.currentItem = null;
|
|
71
|
+
|
|
72
|
+
const unset = { currentArrowHorizontalItem: undefined } satisfies Partial<ModuleControllerArrowsHorizontalState>;
|
|
73
|
+
|
|
74
|
+
await this.emit(this.EVENT_UPDATE_STATE, unset);
|
|
75
|
+
|
|
76
|
+
return this.emit(this.EVENT_UPDATE_FAST);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
emitCurrentItem = () => {
|
|
80
|
+
this.emit(this.EVENT_UPDATE_STATE, { currentArrowHorizontalItem: this.currentItem } satisfies Partial<ModuleControllerArrowsHorizontalState>);
|
|
81
|
+
this.emit(this.EVENT_UPDATE_FAST);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
getMaxCurrentItem = (): number | Promise<number> => 0;
|
|
85
|
+
isArrowItemAvailable = (_index: number): boolean | Promise<boolean> => true;
|
|
86
|
+
onArrowLeft = (): void | Promise<void> => void this.decCurrentItem();
|
|
87
|
+
onArrowRight = (): void | Promise<void> => void this.incCurrentItem();
|
|
76
88
|
incCurrentItem = async () => {
|
|
77
89
|
await this.syncMaxCurrentItem();
|
|
78
90
|
|
|
@@ -83,13 +95,11 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
83
95
|
|
|
84
96
|
return this.setCurrentItem((this.currentItem ?? 0) - 1, this.maxCurrentItem, -1);
|
|
85
97
|
};
|
|
86
|
-
|
|
87
98
|
setCurrentItem = async (value: number, defaultValue: number, direction: 1 | -1 = 1) => {
|
|
88
99
|
this.applyCurrentItem(value, defaultValue);
|
|
89
100
|
await this.skipUnavailableItems(direction);
|
|
90
101
|
this.emitCurrentItem();
|
|
91
102
|
};
|
|
92
|
-
|
|
93
103
|
applyCurrentItem = (value: number, defaultValue: number) => {
|
|
94
104
|
if (this.currentItem === null) {
|
|
95
105
|
this.currentItem = defaultValue;
|
|
@@ -99,7 +109,6 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
99
109
|
if (this.currentItem < 0) this.currentItem = this.maxCurrentItem;
|
|
100
110
|
}
|
|
101
111
|
};
|
|
102
|
-
|
|
103
112
|
skipUnavailableItems = async (direction: 1 | -1) => {
|
|
104
113
|
if (this.currentItem === null) return;
|
|
105
114
|
|
|
@@ -110,12 +119,6 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
110
119
|
if (this.currentItem === start) break;
|
|
111
120
|
}
|
|
112
121
|
};
|
|
113
|
-
|
|
114
|
-
emitCurrentItem = () => {
|
|
115
|
-
this.emit(this.EVENT_UPDATE_STATE, { currentArrowHorizontalItem: this.currentItem } satisfies Partial<ModuleControllerArrowsHorizontalState>);
|
|
116
|
-
this.emit(this.EVENT_UPDATE_FAST);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
122
|
syncMaxCurrentItem = async () => {
|
|
120
123
|
this.maxCurrentItem = await this.getMaxCurrentItem();
|
|
121
124
|
};
|