@4i/modal-manager 1.1.31 → 1.1.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
@@ -123,11 +123,10 @@ var ModalProvider = function (_a) {
|
|
123
123
|
], false); });
|
124
124
|
};
|
125
125
|
var handleClose = function (position) { return __awaiter(void 0, void 0, void 0, function () {
|
126
|
-
var i,
|
126
|
+
var i, indexToRemove;
|
127
127
|
return __generator(this, function (_a) {
|
128
128
|
switch (_a.label) {
|
129
129
|
case 0:
|
130
|
-
console.log("POS", position);
|
131
130
|
if (!(position === "all")) return [3 /*break*/, 5];
|
132
131
|
i = modals.length - 1;
|
133
132
|
_a.label = 1;
|
@@ -144,18 +143,19 @@ var ModalProvider = function (_a) {
|
|
144
143
|
setModals([]);
|
145
144
|
return [2 /*return*/];
|
146
145
|
case 5:
|
147
|
-
|
148
|
-
|
149
|
-
|
146
|
+
indexToRemove = position;
|
147
|
+
if (!indexToRemove ||
|
148
|
+
indexToRemove < 0 ||
|
149
|
+
indexToRemove >= modals.length) {
|
150
150
|
// Если индекс невалидный, закрываем последний
|
151
|
-
|
151
|
+
indexToRemove = modals.length - 1;
|
152
152
|
}
|
153
|
-
if (!(
|
154
|
-
return [4 /*yield*/, applyCloseStyles(
|
153
|
+
if (!(indexToRemove >= 0 && indexToRemove < modals.length)) return [3 /*break*/, 7];
|
154
|
+
return [4 /*yield*/, applyCloseStyles(indexToRemove)];
|
155
155
|
case 6:
|
156
156
|
_a.sent();
|
157
157
|
setModals(function (prevModals) {
|
158
|
-
return prevModals.filter(function (_, index) { return index !==
|
158
|
+
return prevModals.filter(function (_, index) { return index !== indexToRemove; });
|
159
159
|
});
|
160
160
|
_a.label = 7;
|
161
161
|
case 7: return [2 /*return*/];
|
@@ -81,7 +81,6 @@ const ModalProvider: React.FC<ModalProviderProps> = ({
|
|
81
81
|
};
|
82
82
|
|
83
83
|
const handleClose = async (position: number | string) => {
|
84
|
-
console.log("POS", position);
|
85
84
|
if (position === "all") {
|
86
85
|
// Закрыть все модальные окна с анимацией
|
87
86
|
for (let i = modals.length - 1; i >= 0; i--) {
|
@@ -91,22 +90,24 @@ const ModalProvider: React.FC<ModalProviderProps> = ({
|
|
91
90
|
return;
|
92
91
|
}
|
93
92
|
|
94
|
-
|
95
|
-
|
96
|
-
let indexToRemove: number = position;
|
93
|
+
// Обработка числовых позиций
|
94
|
+
let indexToRemove: number | undefined = position as number | undefined;
|
97
95
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
96
|
+
if (
|
97
|
+
!indexToRemove ||
|
98
|
+
indexToRemove < 0 ||
|
99
|
+
indexToRemove >= modals.length
|
100
|
+
) {
|
101
|
+
// Если индекс невалидный, закрываем последний
|
102
|
+
indexToRemove = modals.length - 1;
|
103
|
+
}
|
102
104
|
|
103
|
-
|
104
|
-
|
105
|
+
if (indexToRemove >= 0 && indexToRemove < modals.length) {
|
106
|
+
await applyCloseStyles(indexToRemove);
|
105
107
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
}
|
108
|
+
setModals((prevModals) =>
|
109
|
+
prevModals.filter((_, index) => index !== indexToRemove)
|
110
|
+
);
|
110
111
|
}
|
111
112
|
};
|
112
113
|
|