@vnejs/module.controller.arrows.horizontal 0.2.5 → 0.2.7
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 +3 -2
- package/dist/index.js +6 -7
- package/dist/types.d.ts +0 -1
- package/package.json +1 -1
- package/src/index.ts +7 -9
- package/src/types.ts +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -15,9 +15,10 @@ export declare abstract class ModuleControllerArrowsHorizontal<TEvents extends M
|
|
|
15
15
|
currentItem: number | null;
|
|
16
16
|
maxCurrentItem: number;
|
|
17
17
|
subscribe: () => void;
|
|
18
|
-
|
|
19
|
-
abstract getMaxCurrentItem: () => number | Promise<number>;
|
|
18
|
+
getMaxCurrentItem: () => number | Promise<number>;
|
|
20
19
|
isArrowItemAvailable: (_index: number) => boolean | Promise<boolean>;
|
|
20
|
+
onArrowLeft: () => void | Promise<void>;
|
|
21
|
+
onArrowRight: () => void | Promise<void>;
|
|
21
22
|
onShow: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:push">> | undefined;
|
|
22
23
|
onHide: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:pop">> | undefined;
|
|
23
24
|
incCurrentItem: () => Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ModuleCore } from "@vnejs/module.core";
|
|
2
2
|
export class ModuleControllerArrowsHorizontal extends ModuleCore {
|
|
3
3
|
CONTROLS = {
|
|
4
|
-
[this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => void this.
|
|
5
|
-
[this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: () => void this.
|
|
4
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => void this.onArrowLeft(),
|
|
5
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: () => void this.onArrowRight(),
|
|
6
6
|
};
|
|
7
7
|
currentItem = null;
|
|
8
8
|
maxCurrentItem = 0;
|
|
@@ -10,11 +10,13 @@ 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_UPDATE_STATE, this.updateState);
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
+
getMaxCurrentItem = () => 0;
|
|
15
16
|
isArrowItemAvailable = (_index) => true;
|
|
17
|
+
onArrowLeft = () => void this.decCurrentItem();
|
|
18
|
+
onArrowRight = () => void this.incCurrentItem();
|
|
16
19
|
onShow = () => {
|
|
17
|
-
this.updateState({ isShow: true });
|
|
18
20
|
this.currentItem = null;
|
|
19
21
|
return this.emit(this.EVENTS.CONTROLS.PUSH, {
|
|
20
22
|
key: this.name,
|
|
@@ -24,9 +26,6 @@ export class ModuleControllerArrowsHorizontal extends ModuleCore {
|
|
|
24
26
|
});
|
|
25
27
|
};
|
|
26
28
|
onHide = () => {
|
|
27
|
-
if (!this.state.isShow)
|
|
28
|
-
return;
|
|
29
|
-
this.updateState({ isShow: false });
|
|
30
29
|
this.currentItem = null;
|
|
31
30
|
return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name });
|
|
32
31
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -5,6 +5,5 @@ export type ModuleControllerArrowsHorizontalConstants = ModuleCoreConstants & Re
|
|
|
5
5
|
export type ModuleControllerArrowsHorizontalSettings = ModuleCoreSettings;
|
|
6
6
|
export type ModuleControllerArrowsHorizontalParams = ModuleCoreParams;
|
|
7
7
|
export type ModuleControllerArrowsHorizontalState = {
|
|
8
|
-
isShow: boolean;
|
|
9
8
|
currentArrowHorizontalItem?: number | null;
|
|
10
9
|
};
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -34,8 +34,8 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
34
34
|
abstract CONTROLS_ZINDEX: number;
|
|
35
35
|
|
|
36
36
|
CONTROLS = {
|
|
37
|
-
[this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => void this.
|
|
38
|
-
[this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: () => void this.
|
|
37
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => void this.onArrowLeft(),
|
|
38
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: () => void this.onArrowRight(),
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
currentItem: number | null = null;
|
|
@@ -46,16 +46,17 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
46
46
|
|
|
47
47
|
this.on(this.EVENT_SHOW, this.onShow, { priority: SHOW.CONTROLS });
|
|
48
48
|
this.on(this.EVENT_HIDE, this.onHide, { priority: HIDE.CONTROLS });
|
|
49
|
+
this.on(this.EVENT_UPDATE_STATE, this.updateState);
|
|
49
50
|
};
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
abstract getMaxCurrentItem: () => number | Promise<number>;
|
|
52
|
+
getMaxCurrentItem = (): number | Promise<number> => 0;
|
|
54
53
|
|
|
55
54
|
isArrowItemAvailable = (_index: number): boolean | Promise<boolean> => true;
|
|
56
55
|
|
|
56
|
+
onArrowLeft = (): void | Promise<void> => void this.decCurrentItem();
|
|
57
|
+
onArrowRight = (): void | Promise<void> => void this.incCurrentItem();
|
|
58
|
+
|
|
57
59
|
onShow = () => {
|
|
58
|
-
this.updateState({ isShow: true } as Partial<TState>);
|
|
59
60
|
this.currentItem = null;
|
|
60
61
|
|
|
61
62
|
return this.emit(this.EVENTS.CONTROLS.PUSH, {
|
|
@@ -67,9 +68,6 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
67
68
|
};
|
|
68
69
|
|
|
69
70
|
onHide = () => {
|
|
70
|
-
if (!this.state.isShow) return;
|
|
71
|
-
|
|
72
|
-
this.updateState({ isShow: false } as Partial<TState>);
|
|
73
71
|
this.currentItem = null;
|
|
74
72
|
|
|
75
73
|
return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name } satisfies ControlsPopPayload);
|
package/src/types.ts
CHANGED
|
@@ -10,6 +10,5 @@ export type ModuleControllerArrowsHorizontalSettings = ModuleCoreSettings;
|
|
|
10
10
|
export type ModuleControllerArrowsHorizontalParams = ModuleCoreParams;
|
|
11
11
|
|
|
12
12
|
export type ModuleControllerArrowsHorizontalState = {
|
|
13
|
-
isShow: boolean;
|
|
14
13
|
currentArrowHorizontalItem?: number | null;
|
|
15
14
|
};
|