@etsoo/shared 1.1.30 → 1.1.31

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.
@@ -1,17 +1,7 @@
1
- import {
2
- EHistory,
3
- EHistoryEventData,
4
- EHistoryEventType
5
- } from '../src/types/EHistory';
6
- import { EventBase } from '../src/types/EventClass';
1
+ import { EHistory, EHistoryEvent } from '../src/types/EHistory';
7
2
 
8
3
  // Extended for tests
9
- class LHistoryEvent extends EventBase<EHistoryEventType, EHistoryEventData> {}
10
- class LHistory extends EHistory<number, EHistoryEventData> {
11
- protected createEvent(type: EHistoryEventType, index: number) {
12
- return new LHistoryEvent(this, type, { index });
13
- }
14
- }
4
+ class LHistory extends EHistory<number> {}
15
5
 
16
6
  test('Tests for history', () => {
17
7
  const history = new LHistory();
@@ -37,7 +27,7 @@ test('Tests for history', () => {
37
27
 
38
28
  test('Tests for events', () => {
39
29
  const navigatorFn = jest.fn();
40
- const navigatorStopFn = jest.fn((event: LHistoryEvent) => {
30
+ const navigatorStopFn = jest.fn((event: EHistoryEvent) => {
41
31
  event.stopImmediatePropagation();
42
32
  });
43
33
  const clearFn = jest.fn();
@@ -12,10 +12,15 @@ export interface EHistoryEventData {
12
12
  */
13
13
  index: number;
14
14
  }
15
+ /**
16
+ * ETSOO Extended history event
17
+ */
18
+ export declare class EHistoryEvent extends EventBase<EHistoryEventType, EHistoryEventData> {
19
+ }
15
20
  /**
16
21
  * ETSOO Extended abstract history class
17
22
  */
18
- export declare abstract class EHistory<T, D extends EHistoryEventData = EHistoryEventData> extends EventClass<EHistoryEventType, D> {
23
+ export declare abstract class EHistory<T> extends EventClass<EHistoryEventType, EHistoryEventData> {
19
24
  private _index;
20
25
  /**
21
26
  * States
@@ -46,7 +51,7 @@ export declare abstract class EHistory<T, D extends EHistoryEventData = EHistory
46
51
  * @param type Type
47
52
  * @param index Current index
48
53
  */
49
- protected abstract createEvent(type: EHistoryEventType, index: number): EventBase<EHistoryEventType, D>;
54
+ protected createEvent(type: EHistoryEventType, index: number): EHistoryEvent;
50
55
  /**
51
56
  * Forward to the next state
52
57
  */
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EHistory = void 0;
3
+ exports.EHistory = exports.EHistoryEvent = void 0;
4
4
  const EventClass_1 = require("./EventClass");
5
+ /**
6
+ * ETSOO Extended history event
7
+ */
8
+ class EHistoryEvent extends EventClass_1.EventBase {
9
+ }
10
+ exports.EHistoryEvent = EHistoryEvent;
5
11
  /**
6
12
  * ETSOO Extended abstract history class
7
13
  */
@@ -50,6 +56,14 @@ class EHistory extends EventClass_1.EventClass {
50
56
  this._index = -1;
51
57
  this.trigger(this.createEvent('clear', this._index));
52
58
  }
59
+ /**
60
+ * Create event
61
+ * @param type Type
62
+ * @param index Current index
63
+ */
64
+ createEvent(type, index) {
65
+ return new EHistoryEvent(this, type, { index });
66
+ }
53
67
  /**
54
68
  * Forward to the next state
55
69
  */
@@ -12,10 +12,15 @@ export interface EHistoryEventData {
12
12
  */
13
13
  index: number;
14
14
  }
15
+ /**
16
+ * ETSOO Extended history event
17
+ */
18
+ export declare class EHistoryEvent extends EventBase<EHistoryEventType, EHistoryEventData> {
19
+ }
15
20
  /**
16
21
  * ETSOO Extended abstract history class
17
22
  */
18
- export declare abstract class EHistory<T, D extends EHistoryEventData = EHistoryEventData> extends EventClass<EHistoryEventType, D> {
23
+ export declare abstract class EHistory<T> extends EventClass<EHistoryEventType, EHistoryEventData> {
19
24
  private _index;
20
25
  /**
21
26
  * States
@@ -46,7 +51,7 @@ export declare abstract class EHistory<T, D extends EHistoryEventData = EHistory
46
51
  * @param type Type
47
52
  * @param index Current index
48
53
  */
49
- protected abstract createEvent(type: EHistoryEventType, index: number): EventBase<EHistoryEventType, D>;
54
+ protected createEvent(type: EHistoryEventType, index: number): EHistoryEvent;
50
55
  /**
51
56
  * Forward to the next state
52
57
  */
@@ -1,4 +1,9 @@
1
- import { EventClass } from './EventClass';
1
+ import { EventBase, EventClass } from './EventClass';
2
+ /**
3
+ * ETSOO Extended history event
4
+ */
5
+ export class EHistoryEvent extends EventBase {
6
+ }
2
7
  /**
3
8
  * ETSOO Extended abstract history class
4
9
  */
@@ -47,6 +52,14 @@ export class EHistory extends EventClass {
47
52
  this._index = -1;
48
53
  this.trigger(this.createEvent('clear', this._index));
49
54
  }
55
+ /**
56
+ * Create event
57
+ * @param type Type
58
+ * @param index Current index
59
+ */
60
+ createEvent(type, index) {
61
+ return new EHistoryEvent(this, type, { index });
62
+ }
50
63
  /**
51
64
  * Forward to the next state
52
65
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/shared",
3
- "version": "1.1.30",
3
+ "version": "1.1.31",
4
4
  "description": "TypeScript shared utilities and functions",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -15,13 +15,21 @@ export interface EHistoryEventData {
15
15
  index: number;
16
16
  }
17
17
 
18
+ /**
19
+ * ETSOO Extended history event
20
+ */
21
+ export class EHistoryEvent extends EventBase<
22
+ EHistoryEventType,
23
+ EHistoryEventData
24
+ > {}
25
+
18
26
  /**
19
27
  * ETSOO Extended abstract history class
20
28
  */
21
- export abstract class EHistory<
22
- T,
23
- D extends EHistoryEventData = EHistoryEventData
24
- > extends EventClass<EHistoryEventType, D> {
29
+ export abstract class EHistory<T> extends EventClass<
30
+ EHistoryEventType,
31
+ EHistoryEventData
32
+ > {
25
33
  // Index
26
34
  private _index: number = -1;
27
35
 
@@ -74,10 +82,9 @@ export abstract class EHistory<
74
82
  * @param type Type
75
83
  * @param index Current index
76
84
  */
77
- protected abstract createEvent(
78
- type: EHistoryEventType,
79
- index: number
80
- ): EventBase<EHistoryEventType, D>;
85
+ protected createEvent(type: EHistoryEventType, index: number) {
86
+ return new EHistoryEvent(this, type, { index });
87
+ }
81
88
 
82
89
  /**
83
90
  * Forward to the next state