Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rc-component/trigger

Package Overview
Dependencies
Maintainers
4
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rc-component/trigger - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

60

es/hooks/useAlign.js

@@ -84,8 +84,19 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";

// Calculate align style, we should consider `transform` case
var targetRect = Array.isArray(target) ? {
x: target[0],
y: target[1],
width: 0,
height: 0
} : target.getBoundingClientRect();
var targetRect;
if (Array.isArray(target)) {
targetRect = {
x: target[0],
y: target[1],
width: 0,
height: 0
};
} else {
var rect = target.getBoundingClientRect();
targetRect = {
x: rect.x,
y: rect.y,
width: rect.width,
height: rect.height
};
}
var popupRect = popupElement.getBoundingClientRect();

@@ -111,6 +122,26 @@ var _win$getComputedStyle = win.getComputedStyle(popupElement),

var placementInfo = builtinPlacements[placement] || popupAlign || {};
var _ref = placementInfo.points || [],
// Offset
var offset = placementInfo.offset,
targetOffset = placementInfo.targetOffset;
var _ref = offset || [],
_ref2 = _slicedToArray(_ref, 2),
popupPoint = _ref2[0],
targetPoint = _ref2[1];
_ref2$ = _ref2[0],
popupOffsetX = _ref2$ === void 0 ? 0 : _ref2$,
_ref2$2 = _ref2[1],
popupOffsetY = _ref2$2 === void 0 ? 0 : _ref2$2;
var _ref3 = targetOffset || [],
_ref4 = _slicedToArray(_ref3, 2),
_ref4$ = _ref4[0],
targetOffsetX = _ref4$ === void 0 ? 0 : _ref4$,
_ref4$2 = _ref4[1],
targetOffsetY = _ref4$2 === void 0 ? 0 : _ref4$2;
targetRect.x += targetOffsetX;
targetRect.y += targetOffsetY;
// Points
var _ref5 = placementInfo.points || [],
_ref6 = _slicedToArray(_ref5, 2),
popupPoint = _ref6[0],
targetPoint = _ref6[1];
var targetPoints = splitPoints(targetPoint);

@@ -124,12 +155,3 @@ var popupPoints = splitPoints(popupPoint);

// Offset
var offset = placementInfo.offset;
var _ref3 = offset || [],
_ref4 = _slicedToArray(_ref3, 2),
_ref4$ = _ref4[0],
popupOffsetX = _ref4$ === void 0 ? 0 : _ref4$,
_ref4$2 = _ref4[1],
popupOffsetY = _ref4$2 === void 0 ? 0 : _ref4$2;
// Placement
// Next Offset
var nextOffsetX = targetAlignPoint.x - popupAlignPoint.x + popupOffsetX;

@@ -136,0 +158,0 @@ var nextOffsetY = targetAlignPoint.y - popupAlignPoint.y + popupOffsetY;

@@ -23,2 +23,3 @@ /// <reference types="react" />

*/
targetOffset?: number[];
/**

@@ -25,0 +26,0 @@ * If adjustX field is true, will adjust source node in x direction if source node is invisible.

@@ -92,8 +92,19 @@ "use strict";

// Calculate align style, we should consider `transform` case
var targetRect = Array.isArray(target) ? {
x: target[0],
y: target[1],
width: 0,
height: 0
} : target.getBoundingClientRect();
var targetRect;
if (Array.isArray(target)) {
targetRect = {
x: target[0],
y: target[1],
width: 0,
height: 0
};
} else {
var rect = target.getBoundingClientRect();
targetRect = {
x: rect.x,
y: rect.y,
width: rect.width,
height: rect.height
};
}
var popupRect = popupElement.getBoundingClientRect();

@@ -119,6 +130,26 @@ var _win$getComputedStyle = win.getComputedStyle(popupElement),

var placementInfo = builtinPlacements[placement] || popupAlign || {};
var _ref = placementInfo.points || [],
// Offset
var offset = placementInfo.offset,
targetOffset = placementInfo.targetOffset;
var _ref = offset || [],
_ref2 = (0, _slicedToArray2.default)(_ref, 2),
popupPoint = _ref2[0],
targetPoint = _ref2[1];
_ref2$ = _ref2[0],
popupOffsetX = _ref2$ === void 0 ? 0 : _ref2$,
_ref2$2 = _ref2[1],
popupOffsetY = _ref2$2 === void 0 ? 0 : _ref2$2;
var _ref3 = targetOffset || [],
_ref4 = (0, _slicedToArray2.default)(_ref3, 2),
_ref4$ = _ref4[0],
targetOffsetX = _ref4$ === void 0 ? 0 : _ref4$,
_ref4$2 = _ref4[1],
targetOffsetY = _ref4$2 === void 0 ? 0 : _ref4$2;
targetRect.x += targetOffsetX;
targetRect.y += targetOffsetY;
// Points
var _ref5 = placementInfo.points || [],
_ref6 = (0, _slicedToArray2.default)(_ref5, 2),
popupPoint = _ref6[0],
targetPoint = _ref6[1];
var targetPoints = splitPoints(targetPoint);

@@ -132,12 +163,3 @@ var popupPoints = splitPoints(popupPoint);

// Offset
var offset = placementInfo.offset;
var _ref3 = offset || [],
_ref4 = (0, _slicedToArray2.default)(_ref3, 2),
_ref4$ = _ref4[0],
popupOffsetX = _ref4$ === void 0 ? 0 : _ref4$,
_ref4$2 = _ref4[1],
popupOffsetY = _ref4$2 === void 0 ? 0 : _ref4$2;
// Placement
// Next Offset
var nextOffsetX = targetAlignPoint.x - popupAlignPoint.x + popupOffsetX;

@@ -144,0 +166,0 @@ var nextOffsetY = targetAlignPoint.y - popupAlignPoint.y + popupOffsetY;

@@ -23,2 +23,3 @@ /// <reference types="react" />

*/
targetOffset?: number[];
/**

@@ -25,0 +26,0 @@ * If adjustX field is true, will adjust source node in x direction if source node is invisible.

{
"name": "@rc-component/trigger",
"version": "1.1.2",
"version": "1.2.0",
"description": "base abstract trigger component for react",

@@ -5,0 +5,0 @@ "engines": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc