@rc-component/trigger 1.14.2 → 1.14.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.
@@ -1,4 +1,4 @@
1
1
  import type { ActionType } from '../interface';
2
- declare type ActionTypes = ActionType | ActionType[];
2
+ type ActionTypes = ActionType | ActionType[];
3
3
  export default function useAction(mobile: boolean, action: ActionTypes, showAction?: ActionTypes, hideAction?: ActionTypes): [showAction: Set<ActionType>, hideAction: Set<ActionType>];
4
4
  export {};
@@ -413,7 +413,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
413
413
  if (typeof numShiftY === 'number') {
414
414
  // Top
415
415
  if (nextPopupY < visibleRegionArea.top) {
416
- nextOffsetY -= nextPopupY - visibleRegionArea.top;
416
+ nextOffsetY -= nextPopupY - visibleRegionArea.top + popupOffsetY;
417
417
  if (targetRect.y + targetHeight < visibleRegionArea.top + numShiftY) {
418
418
  nextOffsetY += targetRect.y - visibleRegionArea.top + targetHeight - numShiftY;
419
419
  }
@@ -421,7 +421,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
421
421
 
422
422
  // Bottom
423
423
  if (nextPopupBottom > visibleRegionArea.bottom) {
424
- nextOffsetY -= nextPopupBottom - visibleRegionArea.bottom;
424
+ nextOffsetY -= nextPopupBottom - visibleRegionArea.bottom - popupOffsetY;
425
425
  if (targetRect.y > visibleRegionArea.bottom - numShiftY) {
426
426
  nextOffsetY += targetRect.y - visibleRegionArea.bottom + numShiftY;
427
427
  }
@@ -53,16 +53,16 @@ export default function useWinClick(open, clickToHide, targetEle, popupEle, mask
53
53
  onShadowMouseDown = _genClickEvents4[0],
54
54
  onShadowClick = _genClickEvents4[1];
55
55
  var win = getWin(popupEle);
56
- win.addEventListener('mousedown', onWinMouseDown);
57
- win.addEventListener('click', onWinClick);
58
- win.addEventListener('contextmenu', onWinClick);
56
+ win.addEventListener('mousedown', onWinMouseDown, true);
57
+ win.addEventListener('click', onWinClick, true);
58
+ win.addEventListener('contextmenu', onWinClick, true);
59
59
 
60
60
  // shadow root
61
61
  var targetShadowRoot = getShadowRoot(targetEle);
62
62
  if (targetShadowRoot) {
63
- targetShadowRoot.addEventListener('mousedown', onShadowMouseDown);
64
- targetShadowRoot.addEventListener('click', onShadowClick);
65
- targetShadowRoot.addEventListener('contextmenu', onShadowClick);
63
+ targetShadowRoot.addEventListener('mousedown', onShadowMouseDown, true);
64
+ targetShadowRoot.addEventListener('click', onShadowClick, true);
65
+ targetShadowRoot.addEventListener('contextmenu', onShadowClick, true);
66
66
  }
67
67
 
68
68
  // Warning if target and popup not in same root
@@ -73,13 +73,13 @@ export default function useWinClick(open, clickToHide, targetEle, popupEle, mask
73
73
  warning(targetRoot === popupRoot, "trigger element and popup element should in same shadow root.");
74
74
  }
75
75
  return function () {
76
- win.removeEventListener('mousedown', onWinMouseDown);
77
- win.removeEventListener('click', onWinClick);
78
- win.removeEventListener('contextmenu', onWinClick);
76
+ win.removeEventListener('mousedown', onWinMouseDown, true);
77
+ win.removeEventListener('click', onWinClick, true);
78
+ win.removeEventListener('contextmenu', onWinClick, true);
79
79
  if (targetShadowRoot) {
80
- targetShadowRoot.removeEventListener('mousedown', onShadowMouseDown);
81
- targetShadowRoot.removeEventListener('click', onShadowClick);
82
- targetShadowRoot.removeEventListener('contextmenu', onShadowClick);
80
+ targetShadowRoot.removeEventListener('mousedown', onShadowMouseDown, true);
81
+ targetShadowRoot.removeEventListener('click', onShadowClick, true);
82
+ targetShadowRoot.removeEventListener('contextmenu', onShadowClick, true);
83
83
  }
84
84
  };
85
85
  }
package/es/interface.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import type { CSSMotionProps } from 'rc-motion';
3
- export declare type Placement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
4
- export declare type AlignPointTopBottom = 't' | 'b' | 'c';
5
- export declare type AlignPointLeftRight = 'l' | 'r' | 'c';
3
+ export type Placement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
4
+ export type AlignPointTopBottom = 't' | 'b' | 'c';
5
+ export type AlignPointLeftRight = 'l' | 'r' | 'c';
6
6
  /** Two char of 't' 'b' 'c' 'l' 'r'. Example: 'lt' */
7
- export declare type AlignPoint = `${AlignPointTopBottom}${AlignPointLeftRight}`;
8
- export declare type OffsetType = number | `${number}%`;
7
+ export type AlignPoint = `${AlignPointTopBottom}${AlignPointLeftRight}`;
8
+ export type OffsetType = number | `${number}%`;
9
9
  export interface AlignType {
10
10
  /**
11
11
  * move point of source node to align with point of target node.
@@ -75,15 +75,15 @@ export interface ArrowTypeOuter {
75
75
  className?: string;
76
76
  content?: React.ReactNode;
77
77
  }
78
- export declare type ArrowPos = {
78
+ export type ArrowPos = {
79
79
  x?: number;
80
80
  y?: number;
81
81
  };
82
- export declare type BuildInPlacements = Record<string, AlignType>;
83
- export declare type StretchType = string;
84
- export declare type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu';
85
- export declare type AnimationType = string;
86
- export declare type TransitionNameType = string;
82
+ export type BuildInPlacements = Record<string, AlignType>;
83
+ export type StretchType = string;
84
+ export type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu';
85
+ export type AnimationType = string;
86
+ export type TransitionNameType = string;
87
87
  export interface Point {
88
88
  pageX: number;
89
89
  pageY: number;
@@ -1,4 +1,4 @@
1
1
  import type { ActionType } from '../interface';
2
- declare type ActionTypes = ActionType | ActionType[];
2
+ type ActionTypes = ActionType | ActionType[];
3
3
  export default function useAction(mobile: boolean, action: ActionTypes, showAction?: ActionTypes, hideAction?: ActionTypes): [showAction: Set<ActionType>, hideAction: Set<ActionType>];
4
4
  export {};
@@ -421,7 +421,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
421
421
  if (typeof numShiftY === 'number') {
422
422
  // Top
423
423
  if (nextPopupY < visibleRegionArea.top) {
424
- nextOffsetY -= nextPopupY - visibleRegionArea.top;
424
+ nextOffsetY -= nextPopupY - visibleRegionArea.top + popupOffsetY;
425
425
  if (targetRect.y + targetHeight < visibleRegionArea.top + numShiftY) {
426
426
  nextOffsetY += targetRect.y - visibleRegionArea.top + targetHeight - numShiftY;
427
427
  }
@@ -429,7 +429,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
429
429
 
430
430
  // Bottom
431
431
  if (nextPopupBottom > visibleRegionArea.bottom) {
432
- nextOffsetY -= nextPopupBottom - visibleRegionArea.bottom;
432
+ nextOffsetY -= nextPopupBottom - visibleRegionArea.bottom - popupOffsetY;
433
433
  if (targetRect.y > visibleRegionArea.bottom - numShiftY) {
434
434
  nextOffsetY += targetRect.y - visibleRegionArea.bottom + numShiftY;
435
435
  }
@@ -61,16 +61,16 @@ function useWinClick(open, clickToHide, targetEle, popupEle, mask, maskClosable,
61
61
  onShadowMouseDown = _genClickEvents4[0],
62
62
  onShadowClick = _genClickEvents4[1];
63
63
  var win = (0, _util.getWin)(popupEle);
64
- win.addEventListener('mousedown', onWinMouseDown);
65
- win.addEventListener('click', onWinClick);
66
- win.addEventListener('contextmenu', onWinClick);
64
+ win.addEventListener('mousedown', onWinMouseDown, true);
65
+ win.addEventListener('click', onWinClick, true);
66
+ win.addEventListener('contextmenu', onWinClick, true);
67
67
 
68
68
  // shadow root
69
69
  var targetShadowRoot = (0, _shadow.getShadowRoot)(targetEle);
70
70
  if (targetShadowRoot) {
71
- targetShadowRoot.addEventListener('mousedown', onShadowMouseDown);
72
- targetShadowRoot.addEventListener('click', onShadowClick);
73
- targetShadowRoot.addEventListener('contextmenu', onShadowClick);
71
+ targetShadowRoot.addEventListener('mousedown', onShadowMouseDown, true);
72
+ targetShadowRoot.addEventListener('click', onShadowClick, true);
73
+ targetShadowRoot.addEventListener('contextmenu', onShadowClick, true);
74
74
  }
75
75
 
76
76
  // Warning if target and popup not in same root
@@ -81,13 +81,13 @@ function useWinClick(open, clickToHide, targetEle, popupEle, mask, maskClosable,
81
81
  (0, _rcUtil.warning)(targetRoot === popupRoot, "trigger element and popup element should in same shadow root.");
82
82
  }
83
83
  return function () {
84
- win.removeEventListener('mousedown', onWinMouseDown);
85
- win.removeEventListener('click', onWinClick);
86
- win.removeEventListener('contextmenu', onWinClick);
84
+ win.removeEventListener('mousedown', onWinMouseDown, true);
85
+ win.removeEventListener('click', onWinClick, true);
86
+ win.removeEventListener('contextmenu', onWinClick, true);
87
87
  if (targetShadowRoot) {
88
- targetShadowRoot.removeEventListener('mousedown', onShadowMouseDown);
89
- targetShadowRoot.removeEventListener('click', onShadowClick);
90
- targetShadowRoot.removeEventListener('contextmenu', onShadowClick);
88
+ targetShadowRoot.removeEventListener('mousedown', onShadowMouseDown, true);
89
+ targetShadowRoot.removeEventListener('click', onShadowClick, true);
90
+ targetShadowRoot.removeEventListener('contextmenu', onShadowClick, true);
91
91
  }
92
92
  };
93
93
  }
@@ -1,11 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import type { CSSMotionProps } from 'rc-motion';
3
- export declare type Placement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
4
- export declare type AlignPointTopBottom = 't' | 'b' | 'c';
5
- export declare type AlignPointLeftRight = 'l' | 'r' | 'c';
3
+ export type Placement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
4
+ export type AlignPointTopBottom = 't' | 'b' | 'c';
5
+ export type AlignPointLeftRight = 'l' | 'r' | 'c';
6
6
  /** Two char of 't' 'b' 'c' 'l' 'r'. Example: 'lt' */
7
- export declare type AlignPoint = `${AlignPointTopBottom}${AlignPointLeftRight}`;
8
- export declare type OffsetType = number | `${number}%`;
7
+ export type AlignPoint = `${AlignPointTopBottom}${AlignPointLeftRight}`;
8
+ export type OffsetType = number | `${number}%`;
9
9
  export interface AlignType {
10
10
  /**
11
11
  * move point of source node to align with point of target node.
@@ -75,15 +75,15 @@ export interface ArrowTypeOuter {
75
75
  className?: string;
76
76
  content?: React.ReactNode;
77
77
  }
78
- export declare type ArrowPos = {
78
+ export type ArrowPos = {
79
79
  x?: number;
80
80
  y?: number;
81
81
  };
82
- export declare type BuildInPlacements = Record<string, AlignType>;
83
- export declare type StretchType = string;
84
- export declare type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu';
85
- export declare type AnimationType = string;
86
- export declare type TransitionNameType = string;
82
+ export type BuildInPlacements = Record<string, AlignType>;
83
+ export type StretchType = string;
84
+ export type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu';
85
+ export type AnimationType = string;
86
+ export type TransitionNameType = string;
87
87
  export interface Point {
88
88
  pageX: number;
89
89
  pageY: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/trigger",
3
- "version": "1.14.2",
3
+ "version": "1.14.4",
4
4
  "description": "base abstract trigger component for react",
5
5
  "engines": {
6
6
  "node": ">=8.x"