ecomlab-components-next 0.1.224 → 0.1.225

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.
@@ -47,36 +47,71 @@ var AdvantagesBlock = function AdvantagesBlock(_ref) {
47
47
  _useState6 = _slicedToArray(_useState5, 2),
48
48
  windowWidth = _useState6[0],
49
49
  setWindowWidth = _useState6[1];
50
-
51
- // Мемоизированная функция для установки высоты
50
+ var _useState7 = (0, _react.useState)(false),
51
+ _useState8 = _slicedToArray(_useState7, 2),
52
+ isReady = _useState8[0],
53
+ setIsReady = _useState8[1];
52
54
  var setHeight = (0, _react.useCallback)(function () {
53
- if (blocksRef.current.length === 0) return;
54
- setWindowWidth(window.innerWidth);
55
- var heights = blocksRef.current.filter(Boolean).map(function (block) {
56
- var _block$getBoundingCli;
57
- return (_block$getBoundingCli = block.getBoundingClientRect()) === null || _block$getBoundingCli === void 0 ? void 0 : _block$getBoundingCli.height;
55
+ if (blocksRef.current.length === 0 || !isReady) return;
56
+ var heights = blocksRef.current.filter(function (block) {
57
+ return block && block.offsetHeight > 0;
58
+ }).map(function (block) {
59
+ return block.offsetHeight;
58
60
  });
59
61
  if (heights.length > 0) {
60
- setMaxHeight(Math.max.apply(Math, _toConsumableArray(heights)));
62
+ var newMaxHeight = Math.max.apply(Math, _toConsumableArray(heights));
63
+ if (newMaxHeight !== maxHeight) {
64
+ setMaxHeight(newMaxHeight);
65
+ }
61
66
  }
62
- }, []);
63
-
64
- // Эффект для рефа страницы
67
+ }, [isReady, maxHeight]);
65
68
  (0, _react.useEffect)(function () {
66
69
  if (typeof window !== 'undefined') {
67
70
  setRefPage("?ref_page=".concat(window.location.href));
71
+ setWindowWidth(window.innerWidth);
68
72
  }
69
73
  }, []);
70
-
71
- // Эффект для обработки ресайза
72
74
  (0, _react.useEffect)(function () {
73
75
  if (typeof window === 'undefined') return;
74
- setHeight(); // Инициализация высоты
75
- window.addEventListener("resize", setHeight);
76
+ var handleResize = function handleResize() {
77
+ setWindowWidth(window.innerWidth);
78
+ setHeight();
79
+ };
80
+ window.addEventListener("resize", handleResize);
81
+
82
+ // Ждем полной загрузки страницы включая шрифты
83
+ if (document.readyState === 'complete') {
84
+ setIsReady(true);
85
+ } else {
86
+ window.addEventListener('load', function () {
87
+ return setIsReady(true);
88
+ });
89
+ }
76
90
  return function () {
77
- window.removeEventListener("resize", setHeight);
91
+ window.removeEventListener("resize", handleResize);
92
+ window.removeEventListener('load', function () {
93
+ return setIsReady(true);
94
+ });
78
95
  };
79
96
  }, [setHeight]);
97
+ (0, _react.useEffect)(function () {
98
+ if (isReady) {
99
+ // Несколько попыток установить высоту с интервалами
100
+ var attempts = [0, 100, 300, 500];
101
+ attempts.forEach(function (delay) {
102
+ setTimeout(function () {
103
+ setHeight();
104
+ }, delay);
105
+ });
106
+ }
107
+ }, [isReady, setHeight, list.length]);
108
+
109
+ // Обновляем высоту при изменении контента
110
+ (0, _react.useEffect)(function () {
111
+ if (isReady) {
112
+ setHeight();
113
+ }
114
+ }, [list, isReady, setHeight]);
80
115
  return /*#__PURE__*/_react["default"].createElement("section", {
81
116
  className: "advantages-block ".concat(className)
82
117
  }, /*#__PURE__*/_react["default"].createElement("div", {
@@ -100,12 +135,17 @@ var AdvantagesBlock = function AdvantagesBlock(_ref) {
100
135
  }
101
136
  }, /*#__PURE__*/_react["default"].createElement("div", {
102
137
  style: {
103
- height: windowWidth > 430 ? maxHeight : undefined
138
+ height: windowWidth > 430 && maxHeight > 0 ? maxHeight : 'auto',
139
+ minHeight: windowWidth > 430 && maxHeight > 0 ? maxHeight : undefined
104
140
  }
105
141
  }, itemTitle && /*#__PURE__*/_react["default"].createElement("div", {
106
142
  className: "advantages-block__item-title",
107
143
  ref: function ref(el) {
108
- return blocksRef.current[index] = el;
144
+ blocksRef.current[index] = el;
145
+ if (el && isReady) {
146
+ // Обновляем высоту при изменении ref
147
+ setTimeout(setHeight, 0);
148
+ }
109
149
  }
110
150
  }, itemTitle)), itemDescription && /*#__PURE__*/_react["default"].createElement("p", {
111
151
  className: "advantages-block__item-description"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecomlab-components-next",
3
- "version": "0.1.224",
3
+ "version": "0.1.225",
4
4
  "description": "A set of common and reusable React components",
5
5
  "main": "dist/index.js",
6
6
  "files": [