Socket
Socket
Sign inDemoInstall

@semcore/outside-click

Package Overview
Dependencies
Maintainers
1
Versions
215
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@semcore/outside-click - npm Package Compare versions

Comparing version 3.0.0-beta.0 to 3.0.0-beta.1

19

lib/cjs/OutsideClick.js

@@ -26,14 +26,15 @@ "use strict";

var handleRef = (0, _ref.useForkRef)(children ? children.ref : null, nodeRef, forwardRef);
var handleOutsideClick = (0, _useEventCallback["default"])(function (e) {
var handleOutsideClick = (0, _useEventCallback["default"])(function (event) {
var isTargetEvent = [].concat((0, _toConsumableArray2["default"])(excludeRefs), [nodeRef]).filter(function (node) {
return (0, _ref.getNodeByRef)(node);
}).some(function (node) {
return (0, _ref.getNodeByRef)(node).contains(targetRef.current || e.target);
var _getNodeByRef;
return (_getNodeByRef = (0, _ref.getNodeByRef)(node)) === null || _getNodeByRef === void 0 ? void 0 : _getNodeByRef.contains(targetRef.current || event.target);
});
if (!isTargetEvent) {
onOutsideClick(e);
onOutsideClick === null || onOutsideClick === void 0 ? void 0 : onOutsideClick(event);
}
});
var handleMouseDown = (0, _useEventCallback["default"])(function (e) {
targetRef.current = e.target;
var handleMouseDown = (0, _useEventCallback["default"])(function (event) {
targetRef.current = event.target;
});

@@ -44,7 +45,7 @@ (0, _react.useEffect)(function () {

// Using capture to handle event faster than OutsideClick handler
outsideRoot.addEventListener('mouseup', handleOutsideClick, true);
outsideRoot.addEventListener('mousedown', handleMouseDown, true);
outsideRoot === null || outsideRoot === void 0 ? void 0 : outsideRoot.addEventListener('mouseup', handleOutsideClick, true);
outsideRoot === null || outsideRoot === void 0 ? void 0 : outsideRoot.addEventListener('mousedown', handleMouseDown, true);
return function () {
outsideRoot.removeEventListener('mouseup', handleOutsideClick, true);
outsideRoot.removeEventListener('mousedown', handleMouseDown, true);
outsideRoot === null || outsideRoot === void 0 ? void 0 : outsideRoot.removeEventListener('mouseup', handleOutsideClick, true);
outsideRoot === null || outsideRoot === void 0 ? void 0 : outsideRoot.removeEventListener('mousedown', handleMouseDown, true);
};

@@ -51,0 +52,0 @@ }, [root]);

@@ -21,14 +21,15 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";

var handleRef = useForkRef(children ? children.ref : null, nodeRef, forwardRef);
var handleOutsideClick = useEventCallback(function (e) {
var handleOutsideClick = useEventCallback(function (event) {
var isTargetEvent = [].concat(_toConsumableArray(excludeRefs), [nodeRef]).filter(function (node) {
return getNodeByRef(node);
}).some(function (node) {
return getNodeByRef(node).contains(targetRef.current || e.target);
var _getNodeByRef;
return (_getNodeByRef = getNodeByRef(node)) === null || _getNodeByRef === void 0 ? void 0 : _getNodeByRef.contains(targetRef.current || event.target);
});
if (!isTargetEvent) {
onOutsideClick(e);
onOutsideClick === null || onOutsideClick === void 0 ? void 0 : onOutsideClick(event);
}
});
var handleMouseDown = useEventCallback(function (e) {
targetRef.current = e.target;
var handleMouseDown = useEventCallback(function (event) {
targetRef.current = event.target;
});

@@ -39,7 +40,7 @@ useEffect(function () {

// Using capture to handle event faster than OutsideClick handler
outsideRoot.addEventListener('mouseup', handleOutsideClick, true);
outsideRoot.addEventListener('mousedown', handleMouseDown, true);
outsideRoot === null || outsideRoot === void 0 ? void 0 : outsideRoot.addEventListener('mouseup', handleOutsideClick, true);
outsideRoot === null || outsideRoot === void 0 ? void 0 : outsideRoot.addEventListener('mousedown', handleMouseDown, true);
return function () {
outsideRoot.removeEventListener('mouseup', handleOutsideClick, true);
outsideRoot.removeEventListener('mousedown', handleMouseDown, true);
outsideRoot === null || outsideRoot === void 0 ? void 0 : outsideRoot.removeEventListener('mouseup', handleOutsideClick, true);
outsideRoot === null || outsideRoot === void 0 ? void 0 : outsideRoot.removeEventListener('mousedown', handleMouseDown, true);
};

@@ -46,0 +47,0 @@ }, [root]);

@@ -7,3 +7,3 @@ import React from 'react';

}
export declare type OutsideClickProps = {
export type OutsideClickProps = {
/**

@@ -10,0 +10,0 @@ * Function called on click outside the component from excludeRefs

{
"name": "@semcore/outside-click",
"description": "Semrush OutsideClick Component",
"version": "3.0.0-beta.0",
"version": "3.0.0-beta.1",
"main": "lib/cjs/index.js",

@@ -12,6 +12,6 @@ "module": "lib/es6/index.js",

"dependencies": {
"@semcore/utils": "4.0.0-beta.0"
"@semcore/utils": "4.0.0-beta.1"
},
"peerDependencies": {
"@semcore/core": "2.0.0-beta.0",
"@semcore/core": "2.0.0-beta.1",
"react": "16.8 - 18",

@@ -18,0 +18,0 @@ "react-dom": "16.8 - 18"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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