@4i/modal-manager 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.
package/package.json
CHANGED
@@ -28,8 +28,8 @@ export declare class ModalManager extends Manager {
|
|
28
28
|
modalId: number;
|
29
29
|
data?: T;
|
30
30
|
}, options?: Options): string;
|
31
|
-
call<T>(name: string, data?: T, options?: Options)
|
32
|
-
close<T>(position?: T)
|
31
|
+
call: <T>(name: string, data?: T | undefined, options?: Options) => string;
|
32
|
+
close: <T>(position?: T | undefined) => void;
|
33
33
|
getQueueState({ queue, closedModalName, lastOpenedModal }: QueueState): {
|
34
34
|
isHaveOpenModals: boolean;
|
35
35
|
queue: string[];
|
@@ -33,8 +33,33 @@ var ModalManager = /** @class */ (function (_super) {
|
|
33
33
|
var _this = _super.call(this) || this;
|
34
34
|
_this.queue = [];
|
35
35
|
_this.modalData = new Map(); // Сохраняем данные для каждого модального окна
|
36
|
+
_this.call = function (name, data, options) {
|
37
|
+
var modalId = uniqueID();
|
38
|
+
var id = _this.create(name, { modalId: modalId, data: data }, options);
|
39
|
+
var lastOpenedModal = name;
|
40
|
+
_this.queue.push(id);
|
41
|
+
// Используем setTimeout чтобы дать React возможность обновить DOM
|
42
|
+
setTimeout(function () {
|
43
|
+
var _a;
|
44
|
+
(_a = _this._openModalStateCallback) === null || _a === void 0 ? void 0 : _a.call(_this, _this.getQueueState({
|
45
|
+
queue: _this.queue,
|
46
|
+
lastOpenedModal: lastOpenedModal,
|
47
|
+
}));
|
48
|
+
}, 0);
|
49
|
+
return id;
|
50
|
+
};
|
51
|
+
_this.close = function (position) {
|
52
|
+
var _a, _b;
|
53
|
+
_this.emitter.emit(exports.constants.CLOSE, position !== null && position !== void 0 ? position : ((_a = _this.queue) === null || _a === void 0 ? void 0 : _a.length) - 1);
|
54
|
+
var closedModalName = _this.queue[_this.queue.length - 1];
|
55
|
+
_this.queue.pop();
|
56
|
+
(_b = _this._openModalStateCallback) === null || _b === void 0 ? void 0 : _b.call(_this, _this.getQueueState({
|
57
|
+
queue: _this.queue,
|
58
|
+
closedModalName: closedModalName,
|
59
|
+
}));
|
60
|
+
};
|
36
61
|
_this.create = _this.create.bind(_this);
|
37
|
-
|
62
|
+
// this.call = this.call.bind(this);
|
38
63
|
_this._openModalStateCallback = null;
|
39
64
|
return _this;
|
40
65
|
}
|
@@ -48,32 +73,6 @@ var ModalManager = /** @class */ (function (_super) {
|
|
48
73
|
}, 0);
|
49
74
|
return modalId;
|
50
75
|
};
|
51
|
-
ModalManager.prototype.call = function (name, data, options) {
|
52
|
-
var _this = this;
|
53
|
-
var modalId = uniqueID();
|
54
|
-
var id = this.create(name, { modalId: modalId, data: data }, options);
|
55
|
-
var lastOpenedModal = name;
|
56
|
-
this.queue.push(id);
|
57
|
-
// Используем setTimeout чтобы дать React возможность обновить DOM
|
58
|
-
setTimeout(function () {
|
59
|
-
var _a;
|
60
|
-
(_a = _this._openModalStateCallback) === null || _a === void 0 ? void 0 : _a.call(_this, _this.getQueueState({
|
61
|
-
queue: _this.queue,
|
62
|
-
lastOpenedModal: lastOpenedModal,
|
63
|
-
}));
|
64
|
-
}, 0);
|
65
|
-
return id;
|
66
|
-
};
|
67
|
-
ModalManager.prototype.close = function (position) {
|
68
|
-
var _a, _b;
|
69
|
-
this.emitter.emit(exports.constants.CLOSE, position !== null && position !== void 0 ? position : ((_a = this.queue) === null || _a === void 0 ? void 0 : _a.length) - 1);
|
70
|
-
var closedModalName = this.queue[this.queue.length - 1];
|
71
|
-
this.queue.pop();
|
72
|
-
(_b = this._openModalStateCallback) === null || _b === void 0 ? void 0 : _b.call(this, this.getQueueState({
|
73
|
-
queue: this.queue,
|
74
|
-
closedModalName: closedModalName,
|
75
|
-
}));
|
76
|
-
};
|
77
76
|
ModalManager.prototype.getQueueState = function (_a) {
|
78
77
|
var queue = _a.queue, closedModalName = _a.closedModalName, lastOpenedModal = _a.lastOpenedModal;
|
79
78
|
return {
|
@@ -36,7 +36,7 @@ export class ModalManager extends Manager {
|
|
36
36
|
constructor() {
|
37
37
|
super();
|
38
38
|
this.create = this.create.bind(this);
|
39
|
-
this.call = this.call.bind(this);
|
39
|
+
// this.call = this.call.bind(this);
|
40
40
|
this._openModalStateCallback = null;
|
41
41
|
}
|
42
42
|
|
@@ -56,7 +56,7 @@ export class ModalManager extends Manager {
|
|
56
56
|
return modalId;
|
57
57
|
}
|
58
58
|
|
59
|
-
call<T>(name: string, data?: T, options?: Options) {
|
59
|
+
call = <T>(name: string, data?: T, options?: Options) => {
|
60
60
|
const modalId = uniqueID();
|
61
61
|
const id = this.create<T>(name, { modalId, data }, options);
|
62
62
|
|
@@ -74,9 +74,9 @@ export class ModalManager extends Manager {
|
|
74
74
|
}, 0);
|
75
75
|
|
76
76
|
return id;
|
77
|
-
}
|
77
|
+
};
|
78
78
|
|
79
|
-
close<T>(position?: T) {
|
79
|
+
close = <T>(position?: T) => {
|
80
80
|
this.emitter.emit(constants.CLOSE, position ?? this.queue?.length - 1);
|
81
81
|
const closedModalName = this.queue[this.queue.length - 1];
|
82
82
|
this.queue.pop();
|
@@ -87,7 +87,7 @@ export class ModalManager extends Manager {
|
|
87
87
|
closedModalName,
|
88
88
|
})
|
89
89
|
);
|
90
|
-
}
|
90
|
+
};
|
91
91
|
|
92
92
|
getQueueState({ queue, closedModalName, lastOpenedModal }: QueueState) {
|
93
93
|
return {
|