@cashub/ui 0.31.0 → 0.31.1

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.
@@ -8,6 +8,7 @@ var _react = require("react");
8
8
  var _reactDom = _interopRequireWildcard(require("react-dom"));
9
9
  var _styledComponents = _interopRequireDefault(require("styled-components"));
10
10
  var _md = require("react-icons/md");
11
+ var _hooks = require("@cashub/hooks");
11
12
  var _utils = require("@cashub/utils");
12
13
  var _media = _interopRequireDefault(require("../styles/mixin/media"));
13
14
  var _scrollbar = _interopRequireDefault(require("../styles/mixin/scrollbar"));
@@ -112,11 +113,11 @@ const ModalBody = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
112
113
  } = _ref3,
113
114
  props = _objectWithoutProperties(_ref3, _excluded);
114
115
  const ownRef = (0, _react.useRef)(null);
115
- const bodyRef = ref || ownRef;
116
- const recalculateHeight = () => {
116
+ const bodyRef = (0, _hooks.useForkRef)(ownRef, ref);
117
+ const recalculateHeight = (0, _react.useCallback)(() => {
117
118
  // body element not render yet
118
- if (!bodyRef.current) return;
119
- const ModalBodyElement = bodyRef.current;
119
+ if (!ownRef.current) return;
120
+ const ModalBodyElement = ownRef.current;
120
121
  const ModalHeaderElement = ModalBodyElement.previousSibling;
121
122
  const ModalFooterElement = ModalBodyElement.nextSibling;
122
123
  let needSubtractHeight = 0;
@@ -127,12 +128,12 @@ const ModalBody = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
127
128
  needSubtractHeight += ModalFooterElement.offsetHeight;
128
129
  }
129
130
  ModalBodyElement.style.maxHeight = "calc(90vh - ".concat(needSubtractHeight, "px)");
130
- };
131
+ }, []);
131
132
  (0, _react.useEffect)(() => {
132
133
  recalculateHeight();
133
134
  window.addEventListener('resize', recalculateHeight);
134
135
  return () => window.removeEventListener('resize', recalculateHeight);
135
- }, []);
136
+ }, [recalculateHeight]);
136
137
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Body, _objectSpread(_objectSpread({
137
138
  ref: bodyRef
138
139
  }, props), {}, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cashub/ui",
3
- "version": "0.31.0",
3
+ "version": "0.31.1",
4
4
  "private": false,
5
5
  "author": "CasHUB Team",
6
6
  "description": "CasHUB UI components library",