@rc-component/trigger 2.1.1 → 2.2.1

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.
@@ -473,7 +473,15 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
473
473
  // Additional calculate right & bottom position
474
474
  var offsetX4Right = popupMirrorRect.right - popupRect.x - (nextOffsetX + popupRect.width);
475
475
  var offsetY4Bottom = popupMirrorRect.bottom - popupRect.y - (nextOffsetY + popupRect.height);
476
- setOffsetInfo({
476
+ if (_scaleX === 1) {
477
+ nextOffsetX = Math.round(nextOffsetX);
478
+ offsetX4Right = Math.round(offsetX4Right);
479
+ }
480
+ if (_scaleY === 1) {
481
+ nextOffsetY = Math.round(nextOffsetY);
482
+ offsetY4Bottom = Math.round(offsetY4Bottom);
483
+ }
484
+ var nextOffsetInfo = {
477
485
  ready: true,
478
486
  offsetX: nextOffsetX / _scaleX,
479
487
  offsetY: nextOffsetY / _scaleY,
@@ -484,7 +492,8 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
484
492
  scaleX: _scaleX,
485
493
  scaleY: _scaleY,
486
494
  align: nextAlignInfo
487
- });
495
+ };
496
+ setOffsetInfo(nextOffsetInfo);
488
497
  }
489
498
  });
490
499
  var triggerAlign = function triggerAlign() {
@@ -9,9 +9,9 @@ export default function useWinClick(open, clickToHide, targetEle, popupEle, mask
9
9
  // Click to hide is special action since click popup element should not hide
10
10
  React.useEffect(function () {
11
11
  if (clickToHide && popupEle && (!mask || maskClosable)) {
12
- var onTriggerClose = function onTriggerClose(_ref) {
13
- var target = _ref.target;
14
- if (openRef.current && !inPopupOrChild(target)) {
12
+ var onTriggerClose = function onTriggerClose(e) {
13
+ var _e$composedPath;
14
+ if (openRef.current && !inPopupOrChild(((_e$composedPath = e.composedPath) === null || _e$composedPath === void 0 || (_e$composedPath = _e$composedPath.call(e)) === null || _e$composedPath === void 0 ? void 0 : _e$composedPath[0]) || e.target)) {
15
15
  triggerOpen(false);
16
16
  }
17
17
  };
@@ -481,7 +481,15 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
481
481
  // Additional calculate right & bottom position
482
482
  var offsetX4Right = popupMirrorRect.right - popupRect.x - (nextOffsetX + popupRect.width);
483
483
  var offsetY4Bottom = popupMirrorRect.bottom - popupRect.y - (nextOffsetY + popupRect.height);
484
- setOffsetInfo({
484
+ if (_scaleX === 1) {
485
+ nextOffsetX = Math.round(nextOffsetX);
486
+ offsetX4Right = Math.round(offsetX4Right);
487
+ }
488
+ if (_scaleY === 1) {
489
+ nextOffsetY = Math.round(nextOffsetY);
490
+ offsetY4Bottom = Math.round(offsetY4Bottom);
491
+ }
492
+ var nextOffsetInfo = {
485
493
  ready: true,
486
494
  offsetX: nextOffsetX / _scaleX,
487
495
  offsetY: nextOffsetY / _scaleY,
@@ -492,7 +500,8 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
492
500
  scaleX: _scaleX,
493
501
  scaleY: _scaleY,
494
502
  align: nextAlignInfo
495
- });
503
+ };
504
+ setOffsetInfo(nextOffsetInfo);
496
505
  }
497
506
  });
498
507
  var triggerAlign = function triggerAlign() {
@@ -16,9 +16,9 @@ function useWinClick(open, clickToHide, targetEle, popupEle, mask, maskClosable,
16
16
  // Click to hide is special action since click popup element should not hide
17
17
  React.useEffect(function () {
18
18
  if (clickToHide && popupEle && (!mask || maskClosable)) {
19
- var onTriggerClose = function onTriggerClose(_ref) {
20
- var target = _ref.target;
21
- if (openRef.current && !inPopupOrChild(target)) {
19
+ var onTriggerClose = function onTriggerClose(e) {
20
+ var _e$composedPath;
21
+ if (openRef.current && !inPopupOrChild(((_e$composedPath = e.composedPath) === null || _e$composedPath === void 0 || (_e$composedPath = _e$composedPath.call(e)) === null || _e$composedPath === void 0 ? void 0 : _e$composedPath[0]) || e.target)) {
22
22
  triggerOpen(false);
23
23
  }
24
24
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/trigger",
3
- "version": "2.1.1",
3
+ "version": "2.2.1",
4
4
  "description": "base abstract trigger component for react",
5
5
  "engines": {
6
6
  "node": ">=8.x"
@@ -42,7 +42,7 @@
42
42
  "devDependencies": {
43
43
  "@rc-component/father-plugin": "^1.0.0",
44
44
  "@testing-library/jest-dom": "^6.1.4",
45
- "@testing-library/react": "^14.0.0",
45
+ "@testing-library/react": "^15.0.4",
46
46
  "@types/classnames": "^2.2.10",
47
47
  "@types/jest": "^29.5.2",
48
48
  "@types/node": "^20.11.6",
@@ -54,7 +54,7 @@
54
54
  "eslint": "^8.51.0",
55
55
  "father": "^4.0.0",
56
56
  "less": "^4.2.0",
57
- "np": "^9.0.0",
57
+ "np": "^10.0.5",
58
58
  "rc-test": "^7.0.13",
59
59
  "react": "^18.0.0",
60
60
  "react-dom": "^18.0.0",