@vnejs/module.controller.arrows.horizontal 0.2.4 → 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 -3
- package/dist/index.js +14 -12
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/index.ts +17 -15
- package/src/types.ts +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare abstract class ModuleControllerArrowsHorizontal<TEvents extends M
|
|
|
5
5
|
abstract name: string;
|
|
6
6
|
abstract EVENT_SHOW: string;
|
|
7
7
|
abstract EVENT_HIDE: string;
|
|
8
|
-
abstract
|
|
8
|
+
abstract EVENT_UPDATE_STATE: string;
|
|
9
9
|
abstract EVENT_UPDATE_FAST: string;
|
|
10
10
|
abstract CONTROLS_ZINDEX: number;
|
|
11
11
|
CONTROLS: {
|
|
@@ -14,11 +14,12 @@ export declare abstract class ModuleControllerArrowsHorizontal<TEvents extends M
|
|
|
14
14
|
};
|
|
15
15
|
currentItem: number | null;
|
|
16
16
|
maxCurrentItem: number;
|
|
17
|
-
isShow: boolean;
|
|
18
17
|
subscribe: () => void;
|
|
19
18
|
getDefaultState: () => TState;
|
|
20
|
-
|
|
19
|
+
getMaxCurrentItem: () => number | Promise<number>;
|
|
21
20
|
isArrowItemAvailable: (_index: number) => boolean | Promise<boolean>;
|
|
21
|
+
onArrowLeft: () => void | Promise<void>;
|
|
22
|
+
onArrowRight: () => void | Promise<void>;
|
|
22
23
|
onShow: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:push">> | undefined;
|
|
23
24
|
onHide: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:pop">> | undefined;
|
|
24
25
|
incCurrentItem: () => Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
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;
|
|
9
|
-
isShow = false;
|
|
10
9
|
subscribe = () => {
|
|
11
|
-
|
|
12
|
-
this.on(this.
|
|
10
|
+
const { SHOW, HIDE } = this.CONST.COMPONENTS.LIFECYCLE_PRIORITY;
|
|
11
|
+
this.on(this.EVENT_SHOW, this.onShow, { priority: SHOW.CONTROLS });
|
|
12
|
+
this.on(this.EVENT_HIDE, this.onHide, { priority: HIDE.CONTROLS });
|
|
13
|
+
this.on(this.EVENT_UPDATE_STATE, this.updateState);
|
|
13
14
|
};
|
|
14
|
-
getDefaultState = () => ({});
|
|
15
|
+
getDefaultState = () => ({ isShow: false });
|
|
16
|
+
getMaxCurrentItem = () => 0;
|
|
15
17
|
isArrowItemAvailable = (_index) => true;
|
|
18
|
+
onArrowLeft = () => void this.decCurrentItem();
|
|
19
|
+
onArrowRight = () => void this.incCurrentItem();
|
|
16
20
|
onShow = () => {
|
|
17
|
-
|
|
18
|
-
return;
|
|
19
|
-
this.isShow = true;
|
|
21
|
+
this.updateState({ isShow: true });
|
|
20
22
|
this.currentItem = null;
|
|
21
23
|
return this.emit(this.EVENTS.CONTROLS.PUSH, {
|
|
22
24
|
key: this.name,
|
|
@@ -26,9 +28,9 @@ export class ModuleControllerArrowsHorizontal extends ModuleCore {
|
|
|
26
28
|
});
|
|
27
29
|
};
|
|
28
30
|
onHide = () => {
|
|
29
|
-
if (!this.isShow)
|
|
31
|
+
if (!this.state.isShow)
|
|
30
32
|
return;
|
|
31
|
-
this.isShow
|
|
33
|
+
this.updateState({ isShow: false });
|
|
32
34
|
this.currentItem = null;
|
|
33
35
|
return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name });
|
|
34
36
|
};
|
|
@@ -68,7 +70,7 @@ export class ModuleControllerArrowsHorizontal extends ModuleCore {
|
|
|
68
70
|
}
|
|
69
71
|
};
|
|
70
72
|
emitCurrentItem = () => {
|
|
71
|
-
this.emit(this.
|
|
73
|
+
this.emit(this.EVENT_UPDATE_STATE, { currentArrowHorizontalItem: this.currentItem });
|
|
72
74
|
this.emit(this.EVENT_UPDATE_FAST);
|
|
73
75
|
};
|
|
74
76
|
syncMaxCurrentItem = async () => {
|
package/dist/types.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ 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;
|
|
8
9
|
currentArrowHorizontalItem?: number | null;
|
|
9
10
|
};
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -28,36 +28,38 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
28
28
|
|
|
29
29
|
abstract EVENT_SHOW: string;
|
|
30
30
|
abstract EVENT_HIDE: string;
|
|
31
|
-
abstract
|
|
31
|
+
abstract EVENT_UPDATE_STATE: string;
|
|
32
32
|
abstract EVENT_UPDATE_FAST: string;
|
|
33
33
|
|
|
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;
|
|
42
42
|
maxCurrentItem = 0;
|
|
43
43
|
|
|
44
|
-
isShow = false;
|
|
45
|
-
|
|
46
44
|
subscribe = () => {
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
const { SHOW, HIDE } = this.CONST.COMPONENTS.LIFECYCLE_PRIORITY;
|
|
46
|
+
|
|
47
|
+
this.on(this.EVENT_SHOW, this.onShow, { priority: SHOW.CONTROLS });
|
|
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
|
-
getDefaultState = (): TState => ({}) as TState;
|
|
52
|
+
getDefaultState = (): TState => ({ isShow: false }) as TState;
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
getMaxCurrentItem = (): number | Promise<number> => 0;
|
|
54
55
|
|
|
55
56
|
isArrowItemAvailable = (_index: number): boolean | Promise<boolean> => true;
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
onArrowLeft = (): void | Promise<void> => void this.decCurrentItem();
|
|
59
|
+
onArrowRight = (): void | Promise<void> => void this.incCurrentItem();
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
onShow = () => {
|
|
62
|
+
this.updateState({ isShow: true } as Partial<TState>);
|
|
61
63
|
this.currentItem = null;
|
|
62
64
|
|
|
63
65
|
return this.emit(this.EVENTS.CONTROLS.PUSH, {
|
|
@@ -69,9 +71,9 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
69
71
|
};
|
|
70
72
|
|
|
71
73
|
onHide = () => {
|
|
72
|
-
if (!this.isShow) return;
|
|
74
|
+
if (!this.state.isShow) return;
|
|
73
75
|
|
|
74
|
-
this.isShow
|
|
76
|
+
this.updateState({ isShow: false } as Partial<TState>);
|
|
75
77
|
this.currentItem = null;
|
|
76
78
|
|
|
77
79
|
return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name } satisfies ControlsPopPayload);
|
|
@@ -116,7 +118,7 @@ export abstract class ModuleControllerArrowsHorizontal<
|
|
|
116
118
|
};
|
|
117
119
|
|
|
118
120
|
emitCurrentItem = () => {
|
|
119
|
-
this.emit(this.
|
|
121
|
+
this.emit(this.EVENT_UPDATE_STATE, { currentArrowHorizontalItem: this.currentItem } satisfies Partial<ModuleControllerArrowsHorizontalState>);
|
|
120
122
|
this.emit(this.EVENT_UPDATE_FAST);
|
|
121
123
|
};
|
|
122
124
|
|
package/src/types.ts
CHANGED
|
@@ -10,5 +10,6 @@ export type ModuleControllerArrowsHorizontalSettings = ModuleCoreSettings;
|
|
|
10
10
|
export type ModuleControllerArrowsHorizontalParams = ModuleCoreParams;
|
|
11
11
|
|
|
12
12
|
export type ModuleControllerArrowsHorizontalState = {
|
|
13
|
+
isShow: boolean;
|
|
13
14
|
currentArrowHorizontalItem?: number | null;
|
|
14
15
|
};
|