@rc-component/trigger 2.2.2 → 2.2.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.
@@ -11,6 +11,7 @@ export interface PopupProps {
11
11
  onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
12
12
  onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
13
13
  onPointerEnter?: React.MouseEventHandler<HTMLDivElement>;
14
+ onMouseDownCapture?: React.MouseEventHandler<HTMLDivElement>;
14
15
  zIndex?: number;
15
16
  mask?: boolean;
16
17
  onVisibleChanged: (visible: boolean) => void;
package/es/Popup/index.js CHANGED
@@ -35,6 +35,7 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
35
35
  onMouseEnter = props.onMouseEnter,
36
36
  onMouseLeave = props.onMouseLeave,
37
37
  onPointerEnter = props.onPointerEnter,
38
+ onMouseDownCapture = props.onMouseDownCapture,
38
39
  ready = props.ready,
39
40
  offsetX = props.offsetX,
40
41
  offsetY = props.offsetY,
@@ -167,7 +168,8 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
167
168
  onMouseEnter: onMouseEnter,
168
169
  onMouseLeave: onMouseLeave,
169
170
  onPointerEnter: onPointerEnter,
170
- onClick: onClick
171
+ onClick: onClick,
172
+ onMouseDownCapture: onMouseDownCapture
171
173
  }, arrow && /*#__PURE__*/React.createElement(Arrow, {
172
174
  prefixCls: prefixCls,
173
175
  arrow: arrow,
package/es/index.js CHANGED
@@ -137,14 +137,12 @@ export function generateTrigger() {
137
137
  var child = React.Children.only(children);
138
138
  var originChildProps = (child === null || child === void 0 ? void 0 : child.props) || {};
139
139
  var cloneProps = {};
140
- var inContainer = function inContainer(target, container) {
141
- var _getShadowRoot, _getShadowRoot2;
142
- return target === container || container.contains(target) || ((_getShadowRoot = getShadowRoot(container)) === null || _getShadowRoot === void 0 ? void 0 : _getShadowRoot.host) === target || container.contains((_getShadowRoot2 = getShadowRoot(target)) === null || _getShadowRoot2 === void 0 ? void 0 : _getShadowRoot2.host);
143
- };
144
140
  var inPopupOrChild = useEvent(function (ele) {
141
+ var _getShadowRoot, _getShadowRoot2;
145
142
  var childDOM = targetEle;
146
- var eleInContainer = inContainer.bind(null, ele);
147
- return eleInContainer(childDOM) || eleInContainer(popupEle) || Object.values(subPopupElements.current).some(eleInContainer);
143
+ return (childDOM === null || childDOM === void 0 ? void 0 : childDOM.contains(ele)) || ((_getShadowRoot = getShadowRoot(childDOM)) === null || _getShadowRoot === void 0 ? void 0 : _getShadowRoot.host) === ele || ele === childDOM || (popupEle === null || popupEle === void 0 ? void 0 : popupEle.contains(ele)) || ((_getShadowRoot2 = getShadowRoot(popupEle)) === null || _getShadowRoot2 === void 0 ? void 0 : _getShadowRoot2.host) === ele || ele === popupEle || Object.values(subPopupElements.current).some(function (subPopupEle) {
144
+ return (subPopupEle === null || subPopupEle === void 0 ? void 0 : subPopupEle.contains(ele)) || ele === subPopupEle;
145
+ });
148
146
  });
149
147
 
150
148
  // =========================== Motion ===========================
@@ -495,7 +493,15 @@ export function generateTrigger() {
495
493
  fresh: fresh
496
494
  // Click
497
495
  ,
498
- onClick: onPopupClick
496
+ onClick: onPopupClick,
497
+ onMouseDownCapture: function onMouseDownCapture() {
498
+ // Additional check for click to hide
499
+ // Since `createPortal` will not included in the popup element
500
+ // So we use capture to handle this
501
+ if (clickToHide) {
502
+ triggerOpen(true);
503
+ }
504
+ }
499
505
  // Mask
500
506
  ,
501
507
  mask: mask
@@ -11,6 +11,7 @@ export interface PopupProps {
11
11
  onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
12
12
  onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
13
13
  onPointerEnter?: React.MouseEventHandler<HTMLDivElement>;
14
+ onMouseDownCapture?: React.MouseEventHandler<HTMLDivElement>;
14
15
  zIndex?: number;
15
16
  mask?: boolean;
16
17
  onVisibleChanged: (visible: boolean) => void;
@@ -43,6 +43,7 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
43
43
  onMouseEnter = props.onMouseEnter,
44
44
  onMouseLeave = props.onMouseLeave,
45
45
  onPointerEnter = props.onPointerEnter,
46
+ onMouseDownCapture = props.onMouseDownCapture,
46
47
  ready = props.ready,
47
48
  offsetX = props.offsetX,
48
49
  offsetY = props.offsetY,
@@ -175,7 +176,8 @@ var Popup = /*#__PURE__*/React.forwardRef(function (props, ref) {
175
176
  onMouseEnter: onMouseEnter,
176
177
  onMouseLeave: onMouseLeave,
177
178
  onPointerEnter: onPointerEnter,
178
- onClick: onClick
179
+ onClick: onClick,
180
+ onMouseDownCapture: onMouseDownCapture
179
181
  }, arrow && /*#__PURE__*/React.createElement(_Arrow.default, {
180
182
  prefixCls: prefixCls,
181
183
  arrow: arrow,
package/lib/index.js CHANGED
@@ -145,14 +145,12 @@ function generateTrigger() {
145
145
  var child = React.Children.only(children);
146
146
  var originChildProps = (child === null || child === void 0 ? void 0 : child.props) || {};
147
147
  var cloneProps = {};
148
- var inContainer = function inContainer(target, container) {
149
- var _getShadowRoot, _getShadowRoot2;
150
- return target === container || container.contains(target) || ((_getShadowRoot = (0, _shadow.getShadowRoot)(container)) === null || _getShadowRoot === void 0 ? void 0 : _getShadowRoot.host) === target || container.contains((_getShadowRoot2 = (0, _shadow.getShadowRoot)(target)) === null || _getShadowRoot2 === void 0 ? void 0 : _getShadowRoot2.host);
151
- };
152
148
  var inPopupOrChild = (0, _useEvent.default)(function (ele) {
149
+ var _getShadowRoot, _getShadowRoot2;
153
150
  var childDOM = targetEle;
154
- var eleInContainer = inContainer.bind(null, ele);
155
- return eleInContainer(childDOM) || eleInContainer(popupEle) || Object.values(subPopupElements.current).some(eleInContainer);
151
+ return (childDOM === null || childDOM === void 0 ? void 0 : childDOM.contains(ele)) || ((_getShadowRoot = (0, _shadow.getShadowRoot)(childDOM)) === null || _getShadowRoot === void 0 ? void 0 : _getShadowRoot.host) === ele || ele === childDOM || (popupEle === null || popupEle === void 0 ? void 0 : popupEle.contains(ele)) || ((_getShadowRoot2 = (0, _shadow.getShadowRoot)(popupEle)) === null || _getShadowRoot2 === void 0 ? void 0 : _getShadowRoot2.host) === ele || ele === popupEle || Object.values(subPopupElements.current).some(function (subPopupEle) {
152
+ return (subPopupEle === null || subPopupEle === void 0 ? void 0 : subPopupEle.contains(ele)) || ele === subPopupEle;
153
+ });
156
154
  });
157
155
 
158
156
  // =========================== Motion ===========================
@@ -503,7 +501,15 @@ function generateTrigger() {
503
501
  fresh: fresh
504
502
  // Click
505
503
  ,
506
- onClick: onPopupClick
504
+ onClick: onPopupClick,
505
+ onMouseDownCapture: function onMouseDownCapture() {
506
+ // Additional check for click to hide
507
+ // Since `createPortal` will not included in the popup element
508
+ // So we use capture to handle this
509
+ if (clickToHide) {
510
+ triggerOpen(true);
511
+ }
512
+ }
507
513
  // Mask
508
514
  ,
509
515
  mask: mask
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/trigger",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
4
4
  "description": "base abstract trigger component for react",
5
5
  "engines": {
6
6
  "node": ">=8.x"
@@ -33,7 +33,7 @@
33
33
  "start": "dumi dev",
34
34
  "build": "dumi build",
35
35
  "compile": "father build && lessc assets/index.less assets/index.css",
36
- "prepublishOnly": "npm run compile && np --yolo --no-publish",
36
+ "prepublishOnly": "npm run compile ",
37
37
  "lint": "eslint src/ docs/examples/ --ext .tsx,.ts,.jsx,.js",
38
38
  "test": "rc-test",
39
39
  "prettier": "prettier --write .",