@vnejs/module.controller.arrows.horizontal 0.2.3 → 0.2.5

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 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 EVENT_STATE_UPDATE: string;
8
+ abstract EVENT_UPDATE_STATE: string;
9
9
  abstract EVENT_UPDATE_FAST: string;
10
10
  abstract CONTROLS_ZINDEX: number;
11
11
  CONTROLS: {
@@ -18,8 +18,8 @@ export declare abstract class ModuleControllerArrowsHorizontal<TEvents extends M
18
18
  getDefaultState: () => TState;
19
19
  abstract getMaxCurrentItem: () => number | Promise<number>;
20
20
  isArrowItemAvailable: (_index: number) => boolean | Promise<boolean>;
21
- onShow: () => Promise<unknown[]> | undefined;
22
- onHide: () => Promise<unknown[]> | undefined;
21
+ onShow: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:push">> | undefined;
22
+ onHide: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:pop">> | undefined;
23
23
  incCurrentItem: () => Promise<void>;
24
24
  decCurrentItem: () => Promise<void>;
25
25
  setCurrentItem: (value: number, defaultValue: number, direction?: 1 | -1) => Promise<void>;
package/dist/index.js CHANGED
@@ -7,12 +7,14 @@ export class ModuleControllerArrowsHorizontal extends ModuleCore {
7
7
  currentItem = null;
8
8
  maxCurrentItem = 0;
9
9
  subscribe = () => {
10
- this.on(this.EVENT_SHOW, this.onShow);
11
- this.on(this.EVENT_HIDE, this.onHide);
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 });
12
13
  };
13
- getDefaultState = () => ({});
14
+ getDefaultState = () => ({ isShow: false });
14
15
  isArrowItemAvailable = (_index) => true;
15
16
  onShow = () => {
17
+ this.updateState({ isShow: true });
16
18
  this.currentItem = null;
17
19
  return this.emit(this.EVENTS.CONTROLS.PUSH, {
18
20
  key: this.name,
@@ -22,6 +24,9 @@ export class ModuleControllerArrowsHorizontal extends ModuleCore {
22
24
  });
23
25
  };
24
26
  onHide = () => {
27
+ if (!this.state.isShow)
28
+ return;
29
+ this.updateState({ isShow: false });
25
30
  this.currentItem = null;
26
31
  return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name });
27
32
  };
@@ -61,7 +66,7 @@ export class ModuleControllerArrowsHorizontal extends ModuleCore {
61
66
  }
62
67
  };
63
68
  emitCurrentItem = () => {
64
- this.emit(this.EVENT_STATE_UPDATE, { currentArrowHorizontalItem: this.currentItem });
69
+ this.emit(this.EVENT_UPDATE_STATE, { currentArrowHorizontalItem: this.currentItem });
65
70
  this.emit(this.EVENT_UPDATE_FAST);
66
71
  };
67
72
  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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/module.controller.arrows.horizontal",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -28,7 +28,7 @@ export abstract class ModuleControllerArrowsHorizontal<
28
28
 
29
29
  abstract EVENT_SHOW: string;
30
30
  abstract EVENT_HIDE: string;
31
- abstract EVENT_STATE_UPDATE: string;
31
+ abstract EVENT_UPDATE_STATE: string;
32
32
  abstract EVENT_UPDATE_FAST: string;
33
33
 
34
34
  abstract CONTROLS_ZINDEX: number;
@@ -42,17 +42,20 @@ export abstract class ModuleControllerArrowsHorizontal<
42
42
  maxCurrentItem = 0;
43
43
 
44
44
  subscribe = () => {
45
- this.on(this.EVENT_SHOW, this.onShow);
46
- this.on(this.EVENT_HIDE, this.onHide);
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 });
47
49
  };
48
50
 
49
- getDefaultState = (): TState => ({}) as TState;
51
+ getDefaultState = (): TState => ({ isShow: false }) as TState;
50
52
 
51
53
  abstract getMaxCurrentItem: () => number | Promise<number>;
52
54
 
53
55
  isArrowItemAvailable = (_index: number): boolean | Promise<boolean> => true;
54
56
 
55
57
  onShow = () => {
58
+ this.updateState({ isShow: true } as Partial<TState>);
56
59
  this.currentItem = null;
57
60
 
58
61
  return this.emit(this.EVENTS.CONTROLS.PUSH, {
@@ -64,6 +67,9 @@ export abstract class ModuleControllerArrowsHorizontal<
64
67
  };
65
68
 
66
69
  onHide = () => {
70
+ if (!this.state.isShow) return;
71
+
72
+ this.updateState({ isShow: false } as Partial<TState>);
67
73
  this.currentItem = null;
68
74
 
69
75
  return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name } satisfies ControlsPopPayload);
@@ -108,7 +114,7 @@ export abstract class ModuleControllerArrowsHorizontal<
108
114
  };
109
115
 
110
116
  emitCurrentItem = () => {
111
- this.emit(this.EVENT_STATE_UPDATE, { currentArrowHorizontalItem: this.currentItem } satisfies ModuleControllerArrowsHorizontalState);
117
+ this.emit(this.EVENT_UPDATE_STATE, { currentArrowHorizontalItem: this.currentItem } satisfies Partial<ModuleControllerArrowsHorizontalState>);
112
118
  this.emit(this.EVENT_UPDATE_FAST);
113
119
  };
114
120
 
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
  };