@4i/modal-manager 1.0.31 → 1.0.32
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/package.json
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import Manager from "./Manager";
|
2
2
|
declare class ModalManager extends Manager {
|
3
3
|
queue: string[];
|
4
|
+
_openModalStateCallback: null | ((state: boolean) => void);
|
4
5
|
constructor();
|
5
6
|
create<T>(name: string, payload: {
|
6
7
|
modalId: number;
|
@@ -8,6 +9,7 @@ declare class ModalManager extends Manager {
|
|
8
9
|
}): void;
|
9
10
|
call<T>(name: string, data?: T): void;
|
10
11
|
close<T>(position?: T): void;
|
12
|
+
getQueueState(): boolean;
|
11
13
|
onOpenModalState(callback: (state: boolean) => void): void;
|
12
14
|
}
|
13
15
|
declare const modal: ModalManager;
|
@@ -34,6 +34,7 @@ var ModalManager = /** @class */ (function (_super) {
|
|
34
34
|
_this.create = _this.create.bind(_this);
|
35
35
|
_this.call = _this.call.bind(_this);
|
36
36
|
_this.close = _this.close.bind(_this);
|
37
|
+
_this._openModalStateCallback = null;
|
37
38
|
return _this;
|
38
39
|
}
|
39
40
|
ModalManager.prototype.create = function (name, payload) {
|
@@ -44,13 +45,20 @@ var ModalManager = /** @class */ (function (_super) {
|
|
44
45
|
ModalManager.prototype.call = function (name, data) {
|
45
46
|
this.create(name, { modalId: uniqueID(), data: data });
|
46
47
|
this.queue.push(name);
|
48
|
+
this._openModalStateCallback &&
|
49
|
+
this._openModalStateCallback(this.getQueueState());
|
47
50
|
};
|
48
51
|
ModalManager.prototype.close = function (position) {
|
49
52
|
this.emitter.emit(constants.CLOSE, position);
|
50
53
|
this.queue.pop();
|
54
|
+
this._openModalStateCallback &&
|
55
|
+
this._openModalStateCallback(this.getQueueState());
|
56
|
+
};
|
57
|
+
ModalManager.prototype.getQueueState = function () {
|
58
|
+
return this.queue.length > 0;
|
51
59
|
};
|
52
60
|
ModalManager.prototype.onOpenModalState = function (callback) {
|
53
|
-
|
61
|
+
this._openModalStateCallback = callback;
|
54
62
|
};
|
55
63
|
return ModalManager;
|
56
64
|
}(Manager_1.default));
|
@@ -11,12 +11,14 @@ const constants = {
|
|
11
11
|
|
12
12
|
class ModalManager extends Manager {
|
13
13
|
queue: string[] = [];
|
14
|
+
_openModalStateCallback: null | ((state: boolean) => void);
|
14
15
|
|
15
16
|
constructor() {
|
16
17
|
super();
|
17
18
|
this.create = this.create.bind(this);
|
18
19
|
this.call = this.call.bind(this);
|
19
20
|
this.close = this.close.bind(this);
|
21
|
+
this._openModalStateCallback = null;
|
20
22
|
}
|
21
23
|
|
22
24
|
create<T>(name: string, payload: { modalId: number; data?: T }) {
|
@@ -28,15 +30,23 @@ class ModalManager extends Manager {
|
|
28
30
|
call<T>(name: string, data?: T) {
|
29
31
|
this.create<T>(name, { modalId: uniqueID(), data });
|
30
32
|
this.queue.push(name);
|
33
|
+
this._openModalStateCallback &&
|
34
|
+
this._openModalStateCallback(this.getQueueState());
|
31
35
|
}
|
32
36
|
|
33
37
|
close<T>(position?: T) {
|
34
38
|
this.emitter.emit(constants.CLOSE, position);
|
35
39
|
this.queue.pop();
|
40
|
+
this._openModalStateCallback &&
|
41
|
+
this._openModalStateCallback(this.getQueueState());
|
42
|
+
}
|
43
|
+
|
44
|
+
getQueueState() {
|
45
|
+
return this.queue.length > 0;
|
36
46
|
}
|
37
47
|
|
38
48
|
onOpenModalState(callback: (state: boolean) => void) {
|
39
|
-
|
49
|
+
this._openModalStateCallback = callback;
|
40
50
|
}
|
41
51
|
}
|
42
52
|
|