ecomlab-components-next 0.1.224 → 0.1.226
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.
|
@@ -43,40 +43,94 @@ var AdvantagesBlock = function AdvantagesBlock(_ref) {
|
|
|
43
43
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
44
44
|
maxHeight = _useState4[0],
|
|
45
45
|
setMaxHeight = _useState4[1];
|
|
46
|
-
var _useState5 = (0, _react.useState)(
|
|
46
|
+
var _useState5 = (0, _react.useState)(0),
|
|
47
47
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
48
48
|
windowWidth = _useState6[0],
|
|
49
|
-
setWindowWidth = _useState6[1];
|
|
49
|
+
setWindowWidth = _useState6[1]; // ✅ Инициализируем 0
|
|
50
|
+
var _useState7 = (0, _react.useState)(false),
|
|
51
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
52
|
+
isReady = _useState8[0],
|
|
53
|
+
setIsReady = _useState8[1];
|
|
54
|
+
var _useState9 = (0, _react.useState)(false),
|
|
55
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
56
|
+
isClient = _useState10[0],
|
|
57
|
+
setIsClient = _useState10[1]; // ✅ Новое состояние для проверки клиента
|
|
50
58
|
|
|
51
|
-
// Мемоизированная функция для установки высоты
|
|
52
59
|
var setHeight = (0, _react.useCallback)(function () {
|
|
53
|
-
if (blocksRef.current.length === 0) return;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return
|
|
60
|
+
if (blocksRef.current.length === 0 || !isReady) return;
|
|
61
|
+
var heights = blocksRef.current.filter(function (block) {
|
|
62
|
+
return block && block.offsetHeight > 0;
|
|
63
|
+
}).map(function (block) {
|
|
64
|
+
return block.offsetHeight;
|
|
58
65
|
});
|
|
59
66
|
if (heights.length > 0) {
|
|
60
|
-
|
|
67
|
+
var newMaxHeight = Math.max.apply(Math, _toConsumableArray(heights));
|
|
68
|
+
if (newMaxHeight !== maxHeight) {
|
|
69
|
+
setMaxHeight(newMaxHeight);
|
|
70
|
+
}
|
|
61
71
|
}
|
|
62
|
-
}, []);
|
|
63
|
-
|
|
64
|
-
// Эффект для рефа страницы
|
|
72
|
+
}, [isReady, maxHeight]);
|
|
65
73
|
(0, _react.useEffect)(function () {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
74
|
+
// ✅ Устанавливаем флаг, что мы на клиенте
|
|
75
|
+
setIsClient(true);
|
|
76
|
+
setRefPage("?ref_page=".concat(window.location.href));
|
|
77
|
+
setWindowWidth(window.innerWidth);
|
|
69
78
|
}, []);
|
|
70
|
-
|
|
71
|
-
// Эффект для обработки ресайза
|
|
72
79
|
(0, _react.useEffect)(function () {
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
if (!isClient) return; // ✅ Не выполняем на сервере
|
|
81
|
+
|
|
82
|
+
var handleResize = function handleResize() {
|
|
83
|
+
setWindowWidth(window.innerWidth);
|
|
84
|
+
setHeight();
|
|
85
|
+
};
|
|
86
|
+
window.addEventListener("resize", handleResize);
|
|
87
|
+
if (document.readyState === 'complete') {
|
|
88
|
+
setIsReady(true);
|
|
89
|
+
} else {
|
|
90
|
+
window.addEventListener('load', function () {
|
|
91
|
+
return setIsReady(true);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
76
94
|
return function () {
|
|
77
|
-
window.removeEventListener("resize",
|
|
95
|
+
window.removeEventListener("resize", handleResize);
|
|
96
|
+
window.removeEventListener('load', function () {
|
|
97
|
+
return setIsReady(true);
|
|
98
|
+
});
|
|
78
99
|
};
|
|
79
|
-
}, [setHeight]);
|
|
100
|
+
}, [setHeight, isClient]); // ✅ Добавляем isClient в зависимости
|
|
101
|
+
|
|
102
|
+
(0, _react.useEffect)(function () {
|
|
103
|
+
if (isReady && isClient) {
|
|
104
|
+
// ✅ Проверяем isClient
|
|
105
|
+
var attempts = [0, 100, 300, 500];
|
|
106
|
+
attempts.forEach(function (delay) {
|
|
107
|
+
setTimeout(function () {
|
|
108
|
+
setHeight();
|
|
109
|
+
}, delay);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}, [isReady, setHeight, list.length, isClient]);
|
|
113
|
+
(0, _react.useEffect)(function () {
|
|
114
|
+
if (isReady && isClient) {
|
|
115
|
+
// ✅ Проверяем isClient
|
|
116
|
+
setHeight();
|
|
117
|
+
}
|
|
118
|
+
}, [list, isReady, setHeight, isClient]);
|
|
119
|
+
|
|
120
|
+
// ✅ Ранний возврат для серверного рендеринга
|
|
121
|
+
if (!isClient) {
|
|
122
|
+
return /*#__PURE__*/_react["default"].createElement("section", {
|
|
123
|
+
className: "advantages-block ".concat(className)
|
|
124
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
125
|
+
className: "advantages-block__header"
|
|
126
|
+
}, title && /*#__PURE__*/_react["default"].createElement("h2", {
|
|
127
|
+
className: "advantages-block__title"
|
|
128
|
+
}, title), description && /*#__PURE__*/_react["default"].createElement("p", {
|
|
129
|
+
className: "advantages-block__description"
|
|
130
|
+
}, description)), descriptionWhite && /*#__PURE__*/_react["default"].createElement("p", {
|
|
131
|
+
className: "advantages-block__description-white"
|
|
132
|
+
}, descriptionWhite));
|
|
133
|
+
}
|
|
80
134
|
return /*#__PURE__*/_react["default"].createElement("section", {
|
|
81
135
|
className: "advantages-block ".concat(className)
|
|
82
136
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -100,12 +154,16 @@ var AdvantagesBlock = function AdvantagesBlock(_ref) {
|
|
|
100
154
|
}
|
|
101
155
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
102
156
|
style: {
|
|
103
|
-
height: windowWidth > 430 ? maxHeight :
|
|
157
|
+
height: windowWidth > 430 && maxHeight > 0 ? maxHeight : 'auto',
|
|
158
|
+
minHeight: windowWidth > 430 && maxHeight > 0 ? maxHeight : undefined
|
|
104
159
|
}
|
|
105
160
|
}, itemTitle && /*#__PURE__*/_react["default"].createElement("div", {
|
|
106
161
|
className: "advantages-block__item-title",
|
|
107
162
|
ref: function ref(el) {
|
|
108
|
-
|
|
163
|
+
blocksRef.current[index] = el;
|
|
164
|
+
if (el && isReady) {
|
|
165
|
+
setTimeout(setHeight, 0);
|
|
166
|
+
}
|
|
109
167
|
}
|
|
110
168
|
}, itemTitle)), itemDescription && /*#__PURE__*/_react["default"].createElement("p", {
|
|
111
169
|
className: "advantages-block__item-description"
|