@vnejs/module.controller.arrows.horizontal 0.2.4 → 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: {
@@ -14,7 +14,6 @@ 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
  abstract getMaxCurrentItem: () => number | Promise<number>;
package/dist/index.js CHANGED
@@ -6,17 +6,15 @@ export class ModuleControllerArrowsHorizontal extends ModuleCore {
6
6
  };
7
7
  currentItem = null;
8
8
  maxCurrentItem = 0;
9
- isShow = false;
10
9
  subscribe = () => {
11
- this.on(this.EVENT_SHOW, this.onShow);
12
- 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 });
13
13
  };
14
- getDefaultState = () => ({});
14
+ getDefaultState = () => ({ isShow: false });
15
15
  isArrowItemAvailable = (_index) => true;
16
16
  onShow = () => {
17
- if (this.isShow)
18
- return;
19
- this.isShow = true;
17
+ this.updateState({ isShow: true });
20
18
  this.currentItem = null;
21
19
  return this.emit(this.EVENTS.CONTROLS.PUSH, {
22
20
  key: this.name,
@@ -26,9 +24,9 @@ export class ModuleControllerArrowsHorizontal extends ModuleCore {
26
24
  });
27
25
  };
28
26
  onHide = () => {
29
- if (!this.isShow)
27
+ if (!this.state.isShow)
30
28
  return;
31
- this.isShow = false;
29
+ this.updateState({ isShow: false });
32
30
  this.currentItem = null;
33
31
  return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name });
34
32
  };
@@ -68,7 +66,7 @@ export class ModuleControllerArrowsHorizontal extends ModuleCore {
68
66
  }
69
67
  };
70
68
  emitCurrentItem = () => {
71
- this.emit(this.EVENT_STATE_UPDATE, { currentArrowHorizontalItem: this.currentItem });
69
+ this.emit(this.EVENT_UPDATE_STATE, { currentArrowHorizontalItem: this.currentItem });
72
70
  this.emit(this.EVENT_UPDATE_FAST);
73
71
  };
74
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.4",
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;
@@ -41,23 +41,21 @@ export abstract class ModuleControllerArrowsHorizontal<
41
41
  currentItem: number | null = null;
42
42
  maxCurrentItem = 0;
43
43
 
44
- isShow = false;
45
-
46
44
  subscribe = () => {
47
- this.on(this.EVENT_SHOW, this.onShow);
48
- 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 });
49
49
  };
50
50
 
51
- getDefaultState = (): TState => ({}) as TState;
51
+ getDefaultState = (): TState => ({ isShow: false }) as TState;
52
52
 
53
53
  abstract getMaxCurrentItem: () => number | Promise<number>;
54
54
 
55
55
  isArrowItemAvailable = (_index: number): boolean | Promise<boolean> => true;
56
56
 
57
57
  onShow = () => {
58
- if (this.isShow) return;
59
-
60
- this.isShow = true;
58
+ this.updateState({ isShow: true } as Partial<TState>);
61
59
  this.currentItem = null;
62
60
 
63
61
  return this.emit(this.EVENTS.CONTROLS.PUSH, {
@@ -69,9 +67,9 @@ export abstract class ModuleControllerArrowsHorizontal<
69
67
  };
70
68
 
71
69
  onHide = () => {
72
- if (!this.isShow) return;
70
+ if (!this.state.isShow) return;
73
71
 
74
- this.isShow = false;
72
+ this.updateState({ isShow: false } as Partial<TState>);
75
73
  this.currentItem = null;
76
74
 
77
75
  return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name } satisfies ControlsPopPayload);
@@ -116,7 +114,7 @@ export abstract class ModuleControllerArrowsHorizontal<
116
114
  };
117
115
 
118
116
  emitCurrentItem = () => {
119
- this.emit(this.EVENT_STATE_UPDATE, { currentArrowHorizontalItem: this.currentItem } satisfies ModuleControllerArrowsHorizontalState);
117
+ this.emit(this.EVENT_UPDATE_STATE, { currentArrowHorizontalItem: this.currentItem } satisfies Partial<ModuleControllerArrowsHorizontalState>);
120
118
  this.emit(this.EVENT_UPDATE_FAST);
121
119
  };
122
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
  };