UNPKG

2.82 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
5var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
6
7Object.defineProperty(exports, "__esModule", {
8 value: true
9});
10exports.default = void 0;
11
12var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
14var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
15
16var React = _interopRequireWildcard(require("react"));
17
18var _rcMotion = _interopRequireDefault(require("rc-motion"));
19
20var _classnames = _interopRequireDefault(require("classnames"));
21
22var MobilePopupInner = /*#__PURE__*/React.forwardRef(function (props, ref) {
23 var prefixCls = props.prefixCls,
24 visible = props.visible,
25 zIndex = props.zIndex,
26 children = props.children,
27 _props$mobile = props.mobile;
28 _props$mobile = _props$mobile === void 0 ? {} : _props$mobile;
29 var popupClassName = _props$mobile.popupClassName,
30 popupStyle = _props$mobile.popupStyle,
31 _props$mobile$popupMo = _props$mobile.popupMotion,
32 popupMotion = _props$mobile$popupMo === void 0 ? {} : _props$mobile$popupMo,
33 popupRender = _props$mobile.popupRender,
34 onClick = props.onClick;
35 var elementRef = React.useRef(); // ========================= Refs =========================
36
37 React.useImperativeHandle(ref, function () {
38 return {
39 forceAlign: function forceAlign() {},
40 getElement: function getElement() {
41 return elementRef.current;
42 }
43 };
44 }); // ======================== Render ========================
45
46 var mergedStyle = (0, _objectSpread2.default)({
47 zIndex: zIndex
48 }, popupStyle);
49 var childNode = children; // Wrapper when multiple children
50
51 if (React.Children.count(children) > 1) {
52 childNode = /*#__PURE__*/React.createElement("div", {
53 className: "".concat(prefixCls, "-content")
54 }, children);
55 } // Mobile support additional render
56
57
58 if (popupRender) {
59 childNode = popupRender(childNode);
60 }
61
62 return /*#__PURE__*/React.createElement(_rcMotion.default, (0, _extends2.default)({
63 visible: visible,
64 ref: elementRef,
65 removeOnLeave: true
66 }, popupMotion), function (_ref, motionRef) {
67 var motionClassName = _ref.className,
68 motionStyle = _ref.style;
69 var mergedClassName = (0, _classnames.default)(prefixCls, popupClassName, motionClassName);
70 return /*#__PURE__*/React.createElement("div", {
71 ref: motionRef,
72 className: mergedClassName,
73 onClick: onClick,
74 style: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, motionStyle), mergedStyle)
75 }, childNode);
76 });
77});
78MobilePopupInner.displayName = 'MobilePopupInner';
79var _default = MobilePopupInner;
80exports.default = _default;
\No newline at end of file