@vnejs/module.controller.arrows.horizontal 0.2.6 → 0.2.8

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
@@ -15,13 +15,13 @@ export declare abstract class ModuleControllerArrowsHorizontal<TEvents extends M
15
15
  currentItem: number | null;
16
16
  maxCurrentItem: number;
17
17
  subscribe: () => void;
18
- getDefaultState: () => TState;
19
18
  getMaxCurrentItem: () => number | Promise<number>;
20
19
  isArrowItemAvailable: (_index: number) => boolean | Promise<boolean>;
21
20
  onArrowLeft: () => void | Promise<void>;
22
21
  onArrowRight: () => void | Promise<void>;
23
22
  onShow: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:push">> | undefined;
24
23
  onHide: () => Promise<import("@vnejs/shared").EmitResults<"vne:controls:pop">> | undefined;
24
+ onHideCleanup: () => Promise<import("@vnejs/shared").EmitResults<string> | undefined>;
25
25
  incCurrentItem: () => Promise<void>;
26
26
  decCurrentItem: () => Promise<void>;
27
27
  setCurrentItem: (value: number, defaultValue: number, direction?: 1 | -1) => Promise<void>;
package/dist/index.js CHANGED
@@ -10,15 +10,14 @@ 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
- getDefaultState = () => ({ isShow: false });
16
16
  getMaxCurrentItem = () => 0;
17
17
  isArrowItemAvailable = (_index) => true;
18
18
  onArrowLeft = () => void this.decCurrentItem();
19
19
  onArrowRight = () => void this.incCurrentItem();
20
20
  onShow = () => {
21
- this.updateState({ isShow: true });
22
21
  this.currentItem = null;
23
22
  return this.emit(this.EVENTS.CONTROLS.PUSH, {
24
23
  key: this.name,
@@ -28,12 +27,15 @@ export class ModuleControllerArrowsHorizontal extends ModuleCore {
28
27
  });
29
28
  };
30
29
  onHide = () => {
31
- if (!this.state.isShow)
32
- return;
33
- this.updateState({ isShow: false });
34
30
  this.currentItem = null;
35
31
  return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name });
36
32
  };
33
+ onHideCleanup = async () => {
34
+ this.currentItem = null;
35
+ const unset = { currentArrowHorizontalItem: undefined };
36
+ await this.emit(this.EVENT_UPDATE_STATE, unset);
37
+ return this.emit(this.EVENT_UPDATE_FAST);
38
+ };
37
39
  incCurrentItem = async () => {
38
40
  await this.syncMaxCurrentItem();
39
41
  return this.setCurrentItem((this.currentItem ?? 0) + 1, 0, 1);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/module.controller.arrows.horizontal",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -46,11 +46,10 @@ 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_HIDE, this.onHideCleanup, { priority: HIDE.CLEANUP });
49
50
  this.on(this.EVENT_UPDATE_STATE, this.updateState);
50
51
  };
51
52
 
52
- getDefaultState = (): TState => ({ isShow: false }) as TState;
53
-
54
53
  getMaxCurrentItem = (): number | Promise<number> => 0;
55
54
 
56
55
  isArrowItemAvailable = (_index: number): boolean | Promise<boolean> => true;
@@ -59,7 +58,6 @@ export abstract class ModuleControllerArrowsHorizontal<
59
58
  onArrowRight = (): void | Promise<void> => void this.incCurrentItem();
60
59
 
61
60
  onShow = () => {
62
- this.updateState({ isShow: true } as Partial<TState>);
63
61
  this.currentItem = null;
64
62
 
65
63
  return this.emit(this.EVENTS.CONTROLS.PUSH, {
@@ -71,14 +69,21 @@ export abstract class ModuleControllerArrowsHorizontal<
71
69
  };
72
70
 
73
71
  onHide = () => {
74
- if (!this.state.isShow) return;
75
-
76
- this.updateState({ isShow: false } as Partial<TState>);
77
72
  this.currentItem = null;
78
73
 
79
74
  return this.emit(this.EVENTS.CONTROLS.POP, { key: this.name } satisfies ControlsPopPayload);
80
75
  };
81
76
 
77
+ onHideCleanup = async () => {
78
+ this.currentItem = null;
79
+
80
+ const unset = { currentArrowHorizontalItem: undefined } satisfies Partial<ModuleControllerArrowsHorizontalState>;
81
+
82
+ await this.emit(this.EVENT_UPDATE_STATE, unset);
83
+
84
+ return this.emit(this.EVENT_UPDATE_FAST);
85
+ };
86
+
82
87
  incCurrentItem = async () => {
83
88
  await this.syncMaxCurrentItem();
84
89
 
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
  };