1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
3 | import * as React from 'react';
|
4 | import CSSMotion from 'rc-motion';
|
5 | import classNames from 'classnames';
|
6 | var MobilePopupInner = 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();
|
20 |
|
21 | React.useImperativeHandle(ref, function () {
|
22 | return {
|
23 | forceAlign: function forceAlign() {},
|
24 | getElement: function getElement() {
|
25 | return elementRef.current;
|
26 | }
|
27 | };
|
28 | });
|
29 |
|
30 | var mergedStyle = _objectSpread({
|
31 | zIndex: zIndex
|
32 | }, popupStyle);
|
33 |
|
34 | var childNode = children;
|
35 |
|
36 | if (React.Children.count(children) > 1) {
|
37 | childNode = React.createElement("div", {
|
38 | className: "".concat(prefixCls, "-content")
|
39 | }, children);
|
40 | }
|
41 |
|
42 |
|
43 | if (popupRender) {
|
44 | childNode = popupRender(childNode);
|
45 | }
|
46 |
|
47 | return 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 React.createElement("div", {
|
56 | ref: motionRef,
|
57 | className: mergedClassName,
|
58 | onClick: onClick,
|
59 | style: _objectSpread(_objectSpread({}, motionStyle), mergedStyle)
|
60 | }, childNode);
|
61 | });
|
62 | });
|
63 | MobilePopupInner.displayName = 'MobilePopupInner';
|
64 | export default MobilePopupInner; |
\ | No newline at end of file |