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