MobilePopupInner.js
2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import * as React from 'react';
import CSSMotion from 'rc-motion';
import classNames from 'classnames';
var MobilePopupInner = React.forwardRef(function (props, ref) {
var prefixCls = props.prefixCls,
visible = props.visible,
zIndex = props.zIndex,
children = props.children,
_props$mobile = props.mobile;
_props$mobile = _props$mobile === void 0 ? {} : _props$mobile;
var popupClassName = _props$mobile.popupClassName,
popupStyle = _props$mobile.popupStyle,
_props$mobile$popupMo = _props$mobile.popupMotion,
popupMotion = _props$mobile$popupMo === void 0 ? {} : _props$mobile$popupMo,
popupRender = _props$mobile.popupRender;
var elementRef = React.useRef(); // ========================= Refs =========================
React.useImperativeHandle(ref, function () {
return {
forceAlign: function forceAlign() {},
getElement: function getElement() {
return elementRef.current;
}
};
}); // ======================== Render ========================
var mergedStyle = _objectSpread({
zIndex: zIndex
}, popupStyle);
var childNode = children; // Wrapper when multiple children
if (React.Children.count(children) > 1) {
childNode = React.createElement("div", {
className: "".concat(prefixCls, "-content")
}, children);
} // Mobile support additional render
if (popupRender) {
childNode = popupRender(childNode);
}
return React.createElement(CSSMotion, Object.assign({
visible: visible,
ref: elementRef,
removeOnLeave: true
}, popupMotion), function (_ref, motionRef) {
var motionClassName = _ref.className,
motionStyle = _ref.style;
var mergedClassName = classNames(prefixCls, popupClassName, motionClassName);
return React.createElement("div", {
ref: motionRef,
className: mergedClassName,
style: _objectSpread(_objectSpread({}, motionStyle), mergedStyle)
}, childNode);
});
});
MobilePopupInner.displayName = 'MobilePopupInner';
export default MobilePopupInner;