@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 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
- }, /*#__PURE__*/React.createElement(CSSMotion, _extends({
109
- motionAppear: true,
110
- motionEnter: true,
111
- motionLeave: true,
112
- removeOnLeave: false,
113
- forceRender: forceRender,
114
- leavedClassName: "".concat(prefixCls, "-hidden")
115
- }, motion, {
116
- onAppearPrepare: onPrepare,
117
- onEnterPrepare: onPrepare,
118
- visible: open,
119
- onVisibleChanged: function onVisibleChanged(nextVisible) {
120
- var _motion$onVisibleChan;
121
- motion === null || motion === void 0 ? void 0 : (_motion$onVisibleChan = motion.onVisibleChanged) === null || _motion$onVisibleChan === void 0 ? void 0 : _motion$onVisibleChan.call(motion, nextVisible);
122
- _onVisibleChanged(nextVisible);
123
- }
124
- }), function (_ref) {
125
- var motionClassName = _ref.className,
126
- motionStyle = _ref.style;
127
- var cls = classNames(prefixCls, motionClassName, className);
128
- return /*#__PURE__*/React.createElement("div", {
129
- ref: ref,
130
- className: cls,
131
- style: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, offsetStyle), miscStyle), motionStyle), {}, {
132
- boxSizing: 'border-box',
133
- zIndex: zIndex
134
- }, style),
135
- onMouseEnter: onMouseEnter,
136
- onMouseLeave: onMouseLeave,
137
- onClick: onClick
138
- }, arrow && /*#__PURE__*/React.createElement(Arrow, {
139
- prefixCls: prefixCls,
140
- align: align,
141
- arrowX: arrowX,
142
- arrowY: arrowY
143
- }), childNode);
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
- setInMotion(true);
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),
@@ -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
- }, /*#__PURE__*/React.createElement(_rcMotion.default, (0, _extends2.default)({
117
- motionAppear: true,
118
- motionEnter: true,
119
- motionLeave: true,
120
- removeOnLeave: false,
121
- forceRender: forceRender,
122
- leavedClassName: "".concat(prefixCls, "-hidden")
123
- }, motion, {
124
- onAppearPrepare: onPrepare,
125
- onEnterPrepare: onPrepare,
126
- visible: open,
127
- onVisibleChanged: function onVisibleChanged(nextVisible) {
128
- var _motion$onVisibleChan;
129
- motion === null || motion === void 0 ? void 0 : (_motion$onVisibleChan = motion.onVisibleChanged) === null || _motion$onVisibleChan === void 0 ? void 0 : _motion$onVisibleChan.call(motion, nextVisible);
130
- _onVisibleChanged(nextVisible);
131
- }
132
- }), function (_ref) {
133
- var motionClassName = _ref.className,
134
- motionStyle = _ref.style;
135
- var cls = (0, _classnames.default)(prefixCls, motionClassName, className);
136
- return /*#__PURE__*/React.createElement("div", {
137
- ref: ref,
138
- className: cls,
139
- style: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, offsetStyle), miscStyle), motionStyle), {}, {
140
- boxSizing: 'border-box',
141
- zIndex: zIndex
142
- }, style),
143
- onMouseEnter: onMouseEnter,
144
- onMouseLeave: onMouseLeave,
145
- onClick: onClick
146
- }, arrow && /*#__PURE__*/React.createElement(_Arrow.default, {
147
- prefixCls: prefixCls,
148
- align: align,
149
- arrowX: arrowX,
150
- arrowY: arrowY
151
- }), childNode);
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
- setInMotion(true);
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),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/trigger",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "base abstract trigger component for react",
5
5
  "engines": {
6
6
  "node": ">=8.x"