@cashub/ui 0.30.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.
- package/modal/TitleModal.js +11 -8
- package/package.json +1 -1
package/modal/TitleModal.js
CHANGED
|
@@ -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"));
|
|
@@ -106,16 +107,17 @@ const ModalHeader = _ref2 => {
|
|
|
106
107
|
})]
|
|
107
108
|
});
|
|
108
109
|
};
|
|
109
|
-
const ModalBody = _ref3 => {
|
|
110
|
+
const ModalBody = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
|
|
110
111
|
let {
|
|
111
112
|
children
|
|
112
113
|
} = _ref3,
|
|
113
114
|
props = _objectWithoutProperties(_ref3, _excluded);
|
|
114
|
-
const
|
|
115
|
-
const
|
|
115
|
+
const ownRef = (0, _react.useRef)(null);
|
|
116
|
+
const bodyRef = (0, _hooks.useForkRef)(ownRef, ref);
|
|
117
|
+
const recalculateHeight = (0, _react.useCallback)(() => {
|
|
116
118
|
// body element not render yet
|
|
117
|
-
if (!
|
|
118
|
-
const ModalBodyElement =
|
|
119
|
+
if (!ownRef.current) return;
|
|
120
|
+
const ModalBodyElement = ownRef.current;
|
|
119
121
|
const ModalHeaderElement = ModalBodyElement.previousSibling;
|
|
120
122
|
const ModalFooterElement = ModalBodyElement.nextSibling;
|
|
121
123
|
let needSubtractHeight = 0;
|
|
@@ -126,18 +128,19 @@ const ModalBody = _ref3 => {
|
|
|
126
128
|
needSubtractHeight += ModalFooterElement.offsetHeight;
|
|
127
129
|
}
|
|
128
130
|
ModalBodyElement.style.maxHeight = "calc(90vh - ".concat(needSubtractHeight, "px)");
|
|
129
|
-
};
|
|
131
|
+
}, []);
|
|
130
132
|
(0, _react.useEffect)(() => {
|
|
131
133
|
recalculateHeight();
|
|
132
134
|
window.addEventListener('resize', recalculateHeight);
|
|
133
135
|
return () => window.removeEventListener('resize', recalculateHeight);
|
|
134
|
-
}, []);
|
|
136
|
+
}, [recalculateHeight]);
|
|
135
137
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Body, _objectSpread(_objectSpread({
|
|
136
138
|
ref: bodyRef
|
|
137
139
|
}, props), {}, {
|
|
138
140
|
children: children
|
|
139
141
|
}));
|
|
140
|
-
};
|
|
142
|
+
});
|
|
143
|
+
ModalBody.displayName = 'ModalBody';
|
|
141
144
|
const ModalFooter = _ref4 => {
|
|
142
145
|
let {
|
|
143
146
|
children
|