UNPKG

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