@rc-component/trigger 1.3.0 → 1.3.2
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/ServerPortal.d.ts +5 -0
- package/es/Popup/ServerPortal.js +6 -0
- package/es/Popup/index.js +4 -1
- package/es/hooks/useAlign.js +8 -2
- package/lib/Popup/ServerPortal.d.ts +5 -0
- package/lib/Popup/ServerPortal.js +12 -0
- package/lib/Popup/index.js +4 -1
- package/lib/hooks/useAlign.js +8 -2
- package/package.json +3 -3
package/es/Popup/index.js
CHANGED
|
@@ -5,9 +5,11 @@ 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 canUseDom from "rc-util/es/Dom/canUseDom";
|
|
8
9
|
import * as React from 'react';
|
|
9
10
|
import Arrow from "./Arrow";
|
|
10
11
|
import Mask from "./Mask";
|
|
12
|
+
import ServerPortal from "./ServerPortal";
|
|
11
13
|
var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
12
14
|
var popup = props.popup,
|
|
13
15
|
className = props.className,
|
|
@@ -28,7 +30,7 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
28
30
|
forceRender = props.forceRender,
|
|
29
31
|
getPopupContainer = props.getPopupContainer,
|
|
30
32
|
autoDestroy = props.autoDestroy,
|
|
31
|
-
|
|
33
|
+
portal = props.portal,
|
|
32
34
|
zIndex = props.zIndex,
|
|
33
35
|
onMouseEnter = props.onMouseEnter,
|
|
34
36
|
onMouseLeave = props.onMouseLeave,
|
|
@@ -90,6 +92,7 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
90
92
|
if (!open) {
|
|
91
93
|
miscStyle.pointerEvents = 'none';
|
|
92
94
|
}
|
|
95
|
+
var Portal = canUseDom() ? portal : ServerPortal;
|
|
93
96
|
return /*#__PURE__*/React.createElement(Portal, {
|
|
94
97
|
open: forceRender || isNodeVisible,
|
|
95
98
|
getContainer: getPopupContainer && function () {
|
package/es/hooks/useAlign.js
CHANGED
|
@@ -197,11 +197,17 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
|
|
|
197
197
|
adjustY = overflow.adjustY,
|
|
198
198
|
shiftX = overflow.shiftX,
|
|
199
199
|
shiftY = overflow.shiftY;
|
|
200
|
+
var supportAdjust = function supportAdjust(val) {
|
|
201
|
+
if (typeof val === 'boolean') {
|
|
202
|
+
return val;
|
|
203
|
+
}
|
|
204
|
+
return val >= 0;
|
|
205
|
+
};
|
|
200
206
|
|
|
201
207
|
// >>>>>>>>>> Top & Bottom
|
|
202
208
|
var nextPopupY = popupRect.y + nextOffsetY;
|
|
203
209
|
var nextPopupBottom = nextPopupY + popupHeight;
|
|
204
|
-
var needAdjustY = adjustY
|
|
210
|
+
var needAdjustY = supportAdjust(adjustY);
|
|
205
211
|
|
|
206
212
|
// Bottom to Top
|
|
207
213
|
if (needAdjustY && popupPoints[0] === 't' && nextPopupBottom > visibleArea.bottom) {
|
|
@@ -218,7 +224,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
|
|
|
218
224
|
// >>>>>>>>>> Left & Right
|
|
219
225
|
var nextPopupX = popupRect.x + nextOffsetX;
|
|
220
226
|
var nextPopupRight = nextPopupX + popupWidth;
|
|
221
|
-
var needAdjustX = adjustX
|
|
227
|
+
var needAdjustX = supportAdjust(adjustX);
|
|
222
228
|
|
|
223
229
|
// >>>>> Flip
|
|
224
230
|
// Right to Left
|
package/lib/Popup/index.js
CHANGED
|
@@ -13,9 +13,11 @@ 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 _canUseDom = _interopRequireDefault(require("rc-util/lib/Dom/canUseDom"));
|
|
16
17
|
var React = _interopRequireWildcard(require("react"));
|
|
17
18
|
var _Arrow = _interopRequireDefault(require("./Arrow"));
|
|
18
19
|
var _Mask = _interopRequireDefault(require("./Mask"));
|
|
20
|
+
var _ServerPortal = _interopRequireDefault(require("./ServerPortal"));
|
|
19
21
|
var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
20
22
|
var popup = props.popup,
|
|
21
23
|
className = props.className,
|
|
@@ -36,7 +38,7 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
36
38
|
forceRender = props.forceRender,
|
|
37
39
|
getPopupContainer = props.getPopupContainer,
|
|
38
40
|
autoDestroy = props.autoDestroy,
|
|
39
|
-
|
|
41
|
+
portal = props.portal,
|
|
40
42
|
zIndex = props.zIndex,
|
|
41
43
|
onMouseEnter = props.onMouseEnter,
|
|
42
44
|
onMouseLeave = props.onMouseLeave,
|
|
@@ -98,6 +100,7 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
98
100
|
if (!open) {
|
|
99
101
|
miscStyle.pointerEvents = 'none';
|
|
100
102
|
}
|
|
103
|
+
var Portal = (0, _canUseDom.default)() ? portal : _ServerPortal.default;
|
|
101
104
|
return /*#__PURE__*/React.createElement(Portal, {
|
|
102
105
|
open: forceRender || isNodeVisible,
|
|
103
106
|
getContainer: getPopupContainer && function () {
|
package/lib/hooks/useAlign.js
CHANGED
|
@@ -205,11 +205,17 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
205
205
|
adjustY = overflow.adjustY,
|
|
206
206
|
shiftX = overflow.shiftX,
|
|
207
207
|
shiftY = overflow.shiftY;
|
|
208
|
+
var supportAdjust = function supportAdjust(val) {
|
|
209
|
+
if (typeof val === 'boolean') {
|
|
210
|
+
return val;
|
|
211
|
+
}
|
|
212
|
+
return val >= 0;
|
|
213
|
+
};
|
|
208
214
|
|
|
209
215
|
// >>>>>>>>>> Top & Bottom
|
|
210
216
|
var nextPopupY = popupRect.y + nextOffsetY;
|
|
211
217
|
var nextPopupBottom = nextPopupY + popupHeight;
|
|
212
|
-
var needAdjustY = adjustY
|
|
218
|
+
var needAdjustY = supportAdjust(adjustY);
|
|
213
219
|
|
|
214
220
|
// Bottom to Top
|
|
215
221
|
if (needAdjustY && popupPoints[0] === 't' && nextPopupBottom > visibleArea.bottom) {
|
|
@@ -226,7 +232,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
226
232
|
// >>>>>>>>>> Left & Right
|
|
227
233
|
var nextPopupX = popupRect.x + nextOffsetX;
|
|
228
234
|
var nextPopupRight = nextPopupX + popupWidth;
|
|
229
|
-
var needAdjustX = adjustX
|
|
235
|
+
var needAdjustX = supportAdjust(adjustX);
|
|
230
236
|
|
|
231
237
|
// >>>>> Flip
|
|
232
238
|
// Right to Left
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rc-component/trigger",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "base abstract trigger component for react",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=8.x"
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@testing-library/react": "^13.0.0",
|
|
46
46
|
"@types/classnames": "^2.2.10",
|
|
47
47
|
"@types/jest": "^26.0.15",
|
|
48
|
-
"@types/react": "^
|
|
49
|
-
"@types/react-dom": "^
|
|
48
|
+
"@types/react": "^18.0.0",
|
|
49
|
+
"@types/react-dom": "^18.0.0",
|
|
50
50
|
"cross-env": "^7.0.1",
|
|
51
51
|
"dumi": "^2.1.0",
|
|
52
52
|
"eslint": "^7.0.0",
|