@rc-component/trigger 1.15.0 → 1.15.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/index.d.ts +1 -0
- package/es/Popup/index.js +2 -0
- package/es/hooks/useWatch.d.ts +1 -1
- package/es/hooks/useWatch.js +2 -1
- package/es/index.js +16 -9
- package/lib/Popup/index.d.ts +1 -0
- package/lib/Popup/index.js +2 -0
- package/lib/hooks/useWatch.d.ts +1 -1
- package/lib/hooks/useWatch.js +2 -1
- package/lib/index.js +16 -9
- package/package.json +1 -1
package/es/Popup/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface PopupProps {
|
|
|
10
10
|
target: HTMLElement;
|
|
11
11
|
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
|
|
12
12
|
onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
|
|
13
|
+
onPointerEnter?: React.MouseEventHandler<HTMLDivElement>;
|
|
13
14
|
zIndex?: number;
|
|
14
15
|
mask?: boolean;
|
|
15
16
|
onVisibleChanged: (visible: boolean) => void;
|
package/es/Popup/index.js
CHANGED
|
@@ -33,6 +33,7 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
33
33
|
zIndex = props.zIndex,
|
|
34
34
|
onMouseEnter = props.onMouseEnter,
|
|
35
35
|
onMouseLeave = props.onMouseLeave,
|
|
36
|
+
onPointerEnter = props.onPointerEnter,
|
|
36
37
|
ready = props.ready,
|
|
37
38
|
offsetX = props.offsetX,
|
|
38
39
|
offsetY = props.offsetY,
|
|
@@ -164,6 +165,7 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
164
165
|
}, style),
|
|
165
166
|
onMouseEnter: onMouseEnter,
|
|
166
167
|
onMouseLeave: onMouseLeave,
|
|
168
|
+
onPointerEnter: onPointerEnter,
|
|
167
169
|
onClick: onClick
|
|
168
170
|
}, arrow && /*#__PURE__*/React.createElement(Arrow, {
|
|
169
171
|
prefixCls: prefixCls,
|
package/es/hooks/useWatch.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function useWatch(open: boolean, target: HTMLElement, popup: HTMLElement, onAlign: VoidFunction): void;
|
|
1
|
+
export default function useWatch(open: boolean, target: HTMLElement, popup: HTMLElement, onAlign: VoidFunction, onScroll: VoidFunction): void;
|
package/es/hooks/useWatch.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
2
|
import useLayoutEffect from "rc-util/es/hooks/useLayoutEffect";
|
|
3
3
|
import { collectScroller, getWin } from "../util";
|
|
4
|
-
export default function useWatch(open, target, popup, onAlign) {
|
|
4
|
+
export default function useWatch(open, target, popup, onAlign, onScroll) {
|
|
5
5
|
useLayoutEffect(function () {
|
|
6
6
|
if (open && target && popup) {
|
|
7
7
|
var targetElement = target;
|
|
@@ -12,6 +12,7 @@ export default function useWatch(open, target, popup, onAlign) {
|
|
|
12
12
|
var mergedList = new Set([win].concat(_toConsumableArray(targetScrollList), _toConsumableArray(popupScrollList)));
|
|
13
13
|
function notifyScroll() {
|
|
14
14
|
onAlign();
|
|
15
|
+
onScroll();
|
|
15
16
|
}
|
|
16
17
|
mergedList.forEach(function (scroller) {
|
|
17
18
|
scroller.addEventListener('scroll', notifyScroll, {
|
package/es/index.js
CHANGED
|
@@ -226,12 +226,23 @@ export function generateTrigger() {
|
|
|
226
226
|
scaleY = _useAlign2[8],
|
|
227
227
|
alignInfo = _useAlign2[9],
|
|
228
228
|
onAlign = _useAlign2[10];
|
|
229
|
+
var _useAction = useAction(mobile, action, showAction, hideAction),
|
|
230
|
+
_useAction2 = _slicedToArray(_useAction, 2),
|
|
231
|
+
showActions = _useAction2[0],
|
|
232
|
+
hideActions = _useAction2[1];
|
|
233
|
+
var clickToShow = showActions.has('click');
|
|
234
|
+
var clickToHide = hideActions.has('click') || hideActions.has('contextMenu');
|
|
229
235
|
var triggerAlign = useEvent(function () {
|
|
230
236
|
if (!inMotion) {
|
|
231
237
|
onAlign();
|
|
232
238
|
}
|
|
233
239
|
});
|
|
234
|
-
|
|
240
|
+
var onScroll = function onScroll() {
|
|
241
|
+
if (openRef.current && alignPoint && clickToHide) {
|
|
242
|
+
triggerOpen(false);
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
useWatch(mergedOpen, targetEle, popupEle, triggerAlign, onScroll);
|
|
235
246
|
useLayoutEffect(function () {
|
|
236
247
|
triggerAlign();
|
|
237
248
|
}, [mousePos, popupPlacement]);
|
|
@@ -294,11 +305,6 @@ export function generateTrigger() {
|
|
|
294
305
|
};
|
|
295
306
|
|
|
296
307
|
// =========================== Action ===========================
|
|
297
|
-
var _useAction = useAction(mobile, action, showAction, hideAction),
|
|
298
|
-
_useAction2 = _slicedToArray(_useAction, 2),
|
|
299
|
-
showActions = _useAction2[0],
|
|
300
|
-
hideActions = _useAction2[1];
|
|
301
|
-
|
|
302
308
|
/**
|
|
303
309
|
* Util wrapper for trigger action
|
|
304
310
|
*/
|
|
@@ -317,8 +323,6 @@ export function generateTrigger() {
|
|
|
317
323
|
}
|
|
318
324
|
|
|
319
325
|
// ======================= Action: Click ========================
|
|
320
|
-
var clickToShow = showActions.has('click');
|
|
321
|
-
var clickToHide = hideActions.has('click') || hideActions.has('contextMenu');
|
|
322
326
|
if (clickToShow || clickToHide) {
|
|
323
327
|
cloneProps.onClick = function (event) {
|
|
324
328
|
var _originChildProps$onC;
|
|
@@ -455,7 +459,10 @@ export function generateTrigger() {
|
|
|
455
459
|
style: popupStyle,
|
|
456
460
|
target: targetEle,
|
|
457
461
|
onMouseEnter: onPopupMouseEnter,
|
|
458
|
-
onMouseLeave: onPopupMouseLeave
|
|
462
|
+
onMouseLeave: onPopupMouseLeave
|
|
463
|
+
// https://github.com/ant-design/ant-design/issues/43924
|
|
464
|
+
,
|
|
465
|
+
onPointerEnter: onPopupMouseEnter,
|
|
459
466
|
zIndex: zIndex
|
|
460
467
|
// Open
|
|
461
468
|
,
|
package/lib/Popup/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface PopupProps {
|
|
|
10
10
|
target: HTMLElement;
|
|
11
11
|
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
|
|
12
12
|
onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
|
|
13
|
+
onPointerEnter?: React.MouseEventHandler<HTMLDivElement>;
|
|
13
14
|
zIndex?: number;
|
|
14
15
|
mask?: boolean;
|
|
15
16
|
onVisibleChanged: (visible: boolean) => void;
|
package/lib/Popup/index.js
CHANGED
|
@@ -41,6 +41,7 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
41
41
|
zIndex = props.zIndex,
|
|
42
42
|
onMouseEnter = props.onMouseEnter,
|
|
43
43
|
onMouseLeave = props.onMouseLeave,
|
|
44
|
+
onPointerEnter = props.onPointerEnter,
|
|
44
45
|
ready = props.ready,
|
|
45
46
|
offsetX = props.offsetX,
|
|
46
47
|
offsetY = props.offsetY,
|
|
@@ -172,6 +173,7 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
172
173
|
}, style),
|
|
173
174
|
onMouseEnter: onMouseEnter,
|
|
174
175
|
onMouseLeave: onMouseLeave,
|
|
176
|
+
onPointerEnter: onPointerEnter,
|
|
175
177
|
onClick: onClick
|
|
176
178
|
}, arrow && /*#__PURE__*/React.createElement(_Arrow.default, {
|
|
177
179
|
prefixCls: prefixCls,
|
package/lib/hooks/useWatch.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function useWatch(open: boolean, target: HTMLElement, popup: HTMLElement, onAlign: VoidFunction): void;
|
|
1
|
+
export default function useWatch(open: boolean, target: HTMLElement, popup: HTMLElement, onAlign: VoidFunction, onScroll: VoidFunction): void;
|
package/lib/hooks/useWatch.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.default = useWatch;
|
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _useLayoutEffect = _interopRequireDefault(require("rc-util/lib/hooks/useLayoutEffect"));
|
|
10
10
|
var _util = require("../util");
|
|
11
|
-
function useWatch(open, target, popup, onAlign) {
|
|
11
|
+
function useWatch(open, target, popup, onAlign, onScroll) {
|
|
12
12
|
(0, _useLayoutEffect.default)(function () {
|
|
13
13
|
if (open && target && popup) {
|
|
14
14
|
var targetElement = target;
|
|
@@ -19,6 +19,7 @@ function useWatch(open, target, popup, onAlign) {
|
|
|
19
19
|
var mergedList = new Set([win].concat((0, _toConsumableArray2.default)(targetScrollList), (0, _toConsumableArray2.default)(popupScrollList)));
|
|
20
20
|
function notifyScroll() {
|
|
21
21
|
onAlign();
|
|
22
|
+
onScroll();
|
|
22
23
|
}
|
|
23
24
|
mergedList.forEach(function (scroller) {
|
|
24
25
|
scroller.addEventListener('scroll', notifyScroll, {
|
package/lib/index.js
CHANGED
|
@@ -236,12 +236,23 @@ function generateTrigger() {
|
|
|
236
236
|
scaleY = _useAlign2[8],
|
|
237
237
|
alignInfo = _useAlign2[9],
|
|
238
238
|
onAlign = _useAlign2[10];
|
|
239
|
+
var _useAction = (0, _useAction3.default)(mobile, action, showAction, hideAction),
|
|
240
|
+
_useAction2 = (0, _slicedToArray2.default)(_useAction, 2),
|
|
241
|
+
showActions = _useAction2[0],
|
|
242
|
+
hideActions = _useAction2[1];
|
|
243
|
+
var clickToShow = showActions.has('click');
|
|
244
|
+
var clickToHide = hideActions.has('click') || hideActions.has('contextMenu');
|
|
239
245
|
var triggerAlign = (0, _useEvent.default)(function () {
|
|
240
246
|
if (!inMotion) {
|
|
241
247
|
onAlign();
|
|
242
248
|
}
|
|
243
249
|
});
|
|
244
|
-
|
|
250
|
+
var onScroll = function onScroll() {
|
|
251
|
+
if (openRef.current && alignPoint && clickToHide) {
|
|
252
|
+
triggerOpen(false);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
(0, _useWatch.default)(mergedOpen, targetEle, popupEle, triggerAlign, onScroll);
|
|
245
256
|
(0, _useLayoutEffect.default)(function () {
|
|
246
257
|
triggerAlign();
|
|
247
258
|
}, [mousePos, popupPlacement]);
|
|
@@ -304,11 +315,6 @@ function generateTrigger() {
|
|
|
304
315
|
};
|
|
305
316
|
|
|
306
317
|
// =========================== Action ===========================
|
|
307
|
-
var _useAction = (0, _useAction3.default)(mobile, action, showAction, hideAction),
|
|
308
|
-
_useAction2 = (0, _slicedToArray2.default)(_useAction, 2),
|
|
309
|
-
showActions = _useAction2[0],
|
|
310
|
-
hideActions = _useAction2[1];
|
|
311
|
-
|
|
312
318
|
/**
|
|
313
319
|
* Util wrapper for trigger action
|
|
314
320
|
*/
|
|
@@ -327,8 +333,6 @@ function generateTrigger() {
|
|
|
327
333
|
}
|
|
328
334
|
|
|
329
335
|
// ======================= Action: Click ========================
|
|
330
|
-
var clickToShow = showActions.has('click');
|
|
331
|
-
var clickToHide = hideActions.has('click') || hideActions.has('contextMenu');
|
|
332
336
|
if (clickToShow || clickToHide) {
|
|
333
337
|
cloneProps.onClick = function (event) {
|
|
334
338
|
var _originChildProps$onC;
|
|
@@ -465,7 +469,10 @@ function generateTrigger() {
|
|
|
465
469
|
style: popupStyle,
|
|
466
470
|
target: targetEle,
|
|
467
471
|
onMouseEnter: onPopupMouseEnter,
|
|
468
|
-
onMouseLeave: onPopupMouseLeave
|
|
472
|
+
onMouseLeave: onPopupMouseLeave
|
|
473
|
+
// https://github.com/ant-design/ant-design/issues/43924
|
|
474
|
+
,
|
|
475
|
+
onPointerEnter: onPopupMouseEnter,
|
|
469
476
|
zIndex: zIndex
|
|
470
477
|
// Open
|
|
471
478
|
,
|