1 | "use strict";
|
2 |
|
3 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
4 |
|
5 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
6 |
|
7 | Object.defineProperty(exports, "__esModule", {
|
8 | value: true
|
9 | });
|
10 | exports.default = void 0;
|
11 |
|
12 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
13 |
|
14 | var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
15 |
|
16 | var React = _interopRequireWildcard(require("react"));
|
17 |
|
18 | var _rcMotion = _interopRequireDefault(require("rc-motion"));
|
19 |
|
20 | var _classnames = _interopRequireDefault(require("classnames"));
|
21 |
|
22 | var MobilePopupInner = 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();
|
36 |
|
37 | React.useImperativeHandle(ref, function () {
|
38 | return {
|
39 | forceAlign: function forceAlign() {},
|
40 | getElement: function getElement() {
|
41 | return elementRef.current;
|
42 | }
|
43 | };
|
44 | });
|
45 |
|
46 | var mergedStyle = (0, _objectSpread2.default)({
|
47 | zIndex: zIndex
|
48 | }, popupStyle);
|
49 | var childNode = children;
|
50 |
|
51 | if (React.Children.count(children) > 1) {
|
52 | childNode = React.createElement("div", {
|
53 | className: "".concat(prefixCls, "-content")
|
54 | }, children);
|
55 | }
|
56 |
|
57 |
|
58 | if (popupRender) {
|
59 | childNode = popupRender(childNode);
|
60 | }
|
61 |
|
62 | return 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 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 | });
|
78 | MobilePopupInner.displayName = 'MobilePopupInner';
|
79 | var _default = MobilePopupInner;
|
80 | exports.default = _default; |
\ | No newline at end of file |