@4i/modal-manager 1.0.20 → 1.0.30
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 +1 -1
- package/readme.md +2 -0
- package/src/utils/ModalManager.d.ts +2 -0
- package/src/utils/ModalManager.js +10 -0
- package/src/utils/ModalManager.ts +8 -0
package/package.json
CHANGED
package/readme.md
CHANGED
@@ -31,6 +31,8 @@ create table with methods
|
|
31
31
|
| |
|
32
32
|
| close() | Close last modals. (default) |
|
33
33
|
| |
|
34
|
+
| haveOpenModal | (getter) Is there at least one window open now |
|
35
|
+
| |
|
34
36
|
| addEventListener(event, callback) | Add an event listener to the modal manager. |
|
35
37
|
| |
|
36
38
|
| removeEventListener(event, callback) | Remove an event listener from the modal manager. |
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import Manager from "./Manager";
|
2
2
|
declare class ModalManager extends Manager {
|
3
|
+
queue: string[];
|
3
4
|
constructor();
|
4
5
|
create<T>(name: string, payload: {
|
5
6
|
modalId: number;
|
@@ -7,6 +8,7 @@ declare class ModalManager extends Manager {
|
|
7
8
|
}): void;
|
8
9
|
call<T>(name: string, data?: T): void;
|
9
10
|
close<T>(position?: T): void;
|
11
|
+
get haveOpenModal(): boolean;
|
10
12
|
}
|
11
13
|
declare const modal: ModalManager;
|
12
14
|
export default modal;
|
@@ -30,6 +30,7 @@ var ModalManager = /** @class */ (function (_super) {
|
|
30
30
|
__extends(ModalManager, _super);
|
31
31
|
function ModalManager() {
|
32
32
|
var _this = _super.call(this) || this;
|
33
|
+
_this.queue = [];
|
33
34
|
_this.create = _this.create.bind(_this);
|
34
35
|
_this.call = _this.call.bind(_this);
|
35
36
|
_this.close = _this.close.bind(_this);
|
@@ -42,10 +43,19 @@ var ModalManager = /** @class */ (function (_super) {
|
|
42
43
|
};
|
43
44
|
ModalManager.prototype.call = function (name, data) {
|
44
45
|
this.create(name, { modalId: uniqueID(), data: data });
|
46
|
+
this.queue.push(name);
|
45
47
|
};
|
46
48
|
ModalManager.prototype.close = function (position) {
|
47
49
|
this.emitter.emit(constants.CLOSE, position);
|
50
|
+
this.queue.pop();
|
48
51
|
};
|
52
|
+
Object.defineProperty(ModalManager.prototype, "haveOpenModal", {
|
53
|
+
get: function () {
|
54
|
+
return this.queue.length > 0;
|
55
|
+
},
|
56
|
+
enumerable: false,
|
57
|
+
configurable: true
|
58
|
+
});
|
49
59
|
return ModalManager;
|
50
60
|
}(Manager_1.default));
|
51
61
|
var modal = new ModalManager();
|
@@ -10,6 +10,8 @@ const constants = {
|
|
10
10
|
};
|
11
11
|
|
12
12
|
class ModalManager extends Manager {
|
13
|
+
queue: string[] = [];
|
14
|
+
|
13
15
|
constructor() {
|
14
16
|
super();
|
15
17
|
this.create = this.create.bind(this);
|
@@ -25,10 +27,16 @@ class ModalManager extends Manager {
|
|
25
27
|
|
26
28
|
call<T>(name: string, data?: T) {
|
27
29
|
this.create<T>(name, { modalId: uniqueID(), data });
|
30
|
+
this.queue.push(name);
|
28
31
|
}
|
29
32
|
|
30
33
|
close<T>(position?: T) {
|
31
34
|
this.emitter.emit(constants.CLOSE, position);
|
35
|
+
this.queue.pop();
|
36
|
+
}
|
37
|
+
|
38
|
+
get haveOpenModal() {
|
39
|
+
return this.queue.length > 0;
|
32
40
|
}
|
33
41
|
}
|
34
42
|
|