@rc-component/trigger 1.3.3 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/Popup/index.js +40 -37
- package/es/index.js +5 -1
- package/lib/Popup/index.js +40 -37
- package/lib/index.js +5 -1
- package/package.json +1 -1
package/es/Popup/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import classNames from 'classnames';
|
|
|
5
5
|
import CSSMotion from 'rc-motion';
|
|
6
6
|
import ResizeObserver from 'rc-resize-observer';
|
|
7
7
|
import useLayoutEffect from "rc-util/es/hooks/useLayoutEffect";
|
|
8
|
+
import { composeRef } from "rc-util/es/ref";
|
|
8
9
|
import * as React from 'react';
|
|
9
10
|
import Arrow from "./Arrow";
|
|
10
11
|
import Mask from "./Mask";
|
|
@@ -105,43 +106,45 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
105
106
|
}), /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
106
107
|
onResize: onAlign,
|
|
107
108
|
disabled: !open
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
109
|
+
}, function (resizeObserverRef) {
|
|
110
|
+
return /*#__PURE__*/React.createElement(CSSMotion, _extends({
|
|
111
|
+
motionAppear: true,
|
|
112
|
+
motionEnter: true,
|
|
113
|
+
motionLeave: true,
|
|
114
|
+
removeOnLeave: false,
|
|
115
|
+
forceRender: forceRender,
|
|
116
|
+
leavedClassName: "".concat(prefixCls, "-hidden")
|
|
117
|
+
}, motion, {
|
|
118
|
+
onAppearPrepare: onPrepare,
|
|
119
|
+
onEnterPrepare: onPrepare,
|
|
120
|
+
visible: open,
|
|
121
|
+
onVisibleChanged: function onVisibleChanged(nextVisible) {
|
|
122
|
+
var _motion$onVisibleChan;
|
|
123
|
+
motion === null || motion === void 0 ? void 0 : (_motion$onVisibleChan = motion.onVisibleChanged) === null || _motion$onVisibleChan === void 0 ? void 0 : _motion$onVisibleChan.call(motion, nextVisible);
|
|
124
|
+
_onVisibleChanged(nextVisible);
|
|
125
|
+
}
|
|
126
|
+
}), function (_ref, motionRef) {
|
|
127
|
+
var motionClassName = _ref.className,
|
|
128
|
+
motionStyle = _ref.style;
|
|
129
|
+
var cls = classNames(prefixCls, motionClassName, className);
|
|
130
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
131
|
+
ref: composeRef(resizeObserverRef, ref, motionRef),
|
|
132
|
+
className: cls,
|
|
133
|
+
style: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, offsetStyle), miscStyle), motionStyle), {}, {
|
|
134
|
+
boxSizing: 'border-box',
|
|
135
|
+
zIndex: zIndex
|
|
136
|
+
}, style),
|
|
137
|
+
onMouseEnter: onMouseEnter,
|
|
138
|
+
onMouseLeave: onMouseLeave,
|
|
139
|
+
onClick: onClick
|
|
140
|
+
}, arrow && /*#__PURE__*/React.createElement(Arrow, {
|
|
141
|
+
prefixCls: prefixCls,
|
|
142
|
+
align: align,
|
|
143
|
+
arrowX: arrowX,
|
|
144
|
+
arrowY: arrowY
|
|
145
|
+
}), childNode);
|
|
146
|
+
});
|
|
147
|
+
}));
|
|
145
148
|
});
|
|
146
149
|
if (process.env.NODE_ENV !== 'production') {
|
|
147
150
|
Popup.displayName = 'Popup';
|
package/es/index.js
CHANGED
|
@@ -161,8 +161,12 @@ export function generateTrigger() {
|
|
|
161
161
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
162
162
|
inMotion = _React$useState6[0],
|
|
163
163
|
setInMotion = _React$useState6[1];
|
|
164
|
+
var mountRef = React.useRef(true);
|
|
164
165
|
useLayoutEffect(function () {
|
|
165
|
-
|
|
166
|
+
if (!mountRef.current || mergedOpen) {
|
|
167
|
+
setInMotion(true);
|
|
168
|
+
}
|
|
169
|
+
mountRef.current = true;
|
|
166
170
|
}, [mergedOpen]);
|
|
167
171
|
var _React$useState7 = React.useState(null),
|
|
168
172
|
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
package/lib/Popup/index.js
CHANGED
|
@@ -13,6 +13,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
13
13
|
var _rcMotion = _interopRequireDefault(require("rc-motion"));
|
|
14
14
|
var _rcResizeObserver = _interopRequireDefault(require("rc-resize-observer"));
|
|
15
15
|
var _useLayoutEffect = _interopRequireDefault(require("rc-util/lib/hooks/useLayoutEffect"));
|
|
16
|
+
var _ref2 = require("rc-util/lib/ref");
|
|
16
17
|
var React = _interopRequireWildcard(require("react"));
|
|
17
18
|
var _Arrow = _interopRequireDefault(require("./Arrow"));
|
|
18
19
|
var _Mask = _interopRequireDefault(require("./Mask"));
|
|
@@ -113,43 +114,45 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
113
114
|
}), /*#__PURE__*/React.createElement(_rcResizeObserver.default, {
|
|
114
115
|
onResize: onAlign,
|
|
115
116
|
disabled: !open
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
117
|
+
}, function (resizeObserverRef) {
|
|
118
|
+
return /*#__PURE__*/React.createElement(_rcMotion.default, (0, _extends2.default)({
|
|
119
|
+
motionAppear: true,
|
|
120
|
+
motionEnter: true,
|
|
121
|
+
motionLeave: true,
|
|
122
|
+
removeOnLeave: false,
|
|
123
|
+
forceRender: forceRender,
|
|
124
|
+
leavedClassName: "".concat(prefixCls, "-hidden")
|
|
125
|
+
}, motion, {
|
|
126
|
+
onAppearPrepare: onPrepare,
|
|
127
|
+
onEnterPrepare: onPrepare,
|
|
128
|
+
visible: open,
|
|
129
|
+
onVisibleChanged: function onVisibleChanged(nextVisible) {
|
|
130
|
+
var _motion$onVisibleChan;
|
|
131
|
+
motion === null || motion === void 0 ? void 0 : (_motion$onVisibleChan = motion.onVisibleChanged) === null || _motion$onVisibleChan === void 0 ? void 0 : _motion$onVisibleChan.call(motion, nextVisible);
|
|
132
|
+
_onVisibleChanged(nextVisible);
|
|
133
|
+
}
|
|
134
|
+
}), function (_ref, motionRef) {
|
|
135
|
+
var motionClassName = _ref.className,
|
|
136
|
+
motionStyle = _ref.style;
|
|
137
|
+
var cls = (0, _classnames.default)(prefixCls, motionClassName, className);
|
|
138
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
139
|
+
ref: (0, _ref2.composeRef)(resizeObserverRef, ref, motionRef),
|
|
140
|
+
className: cls,
|
|
141
|
+
style: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, offsetStyle), miscStyle), motionStyle), {}, {
|
|
142
|
+
boxSizing: 'border-box',
|
|
143
|
+
zIndex: zIndex
|
|
144
|
+
}, style),
|
|
145
|
+
onMouseEnter: onMouseEnter,
|
|
146
|
+
onMouseLeave: onMouseLeave,
|
|
147
|
+
onClick: onClick
|
|
148
|
+
}, arrow && /*#__PURE__*/React.createElement(_Arrow.default, {
|
|
149
|
+
prefixCls: prefixCls,
|
|
150
|
+
align: align,
|
|
151
|
+
arrowX: arrowX,
|
|
152
|
+
arrowY: arrowY
|
|
153
|
+
}), childNode);
|
|
154
|
+
});
|
|
155
|
+
}));
|
|
153
156
|
});
|
|
154
157
|
if (process.env.NODE_ENV !== 'production') {
|
|
155
158
|
Popup.displayName = 'Popup';
|
package/lib/index.js
CHANGED
|
@@ -170,8 +170,12 @@ function generateTrigger() {
|
|
|
170
170
|
_React$useState6 = (0, _slicedToArray2.default)(_React$useState5, 2),
|
|
171
171
|
inMotion = _React$useState6[0],
|
|
172
172
|
setInMotion = _React$useState6[1];
|
|
173
|
+
var mountRef = React.useRef(true);
|
|
173
174
|
(0, _useLayoutEffect.default)(function () {
|
|
174
|
-
|
|
175
|
+
if (!mountRef.current || mergedOpen) {
|
|
176
|
+
setInMotion(true);
|
|
177
|
+
}
|
|
178
|
+
mountRef.current = true;
|
|
175
179
|
}, [mergedOpen]);
|
|
176
180
|
var _React$useState7 = React.useState(null),
|
|
177
181
|
_React$useState8 = (0, _slicedToArray2.default)(_React$useState7, 2),
|