New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@zag-js/interact-outside

Package Overview
Dependencies
Maintainers
1
Versions
826
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/interact-outside - npm Package Compare versions

Comparing version 0.0.0-dev-20230202113057 to 0.0.0-dev-20230214091932

42

dist/index.js

@@ -121,2 +121,30 @@ "use strict";

var FOCUS_OUTSIDE_EVENT = "focus.outside";
function getWindowFrames(win) {
const frames = {
each(cb) {
for (let i = 0; i < win.frames?.length; i += 1) {
const frame = win.frames[i];
if (frame)
cb(frame);
}
},
addEventListener(event, listener, options) {
frames.each((frame) => {
frame.document.addEventListener(event, listener, options);
});
return () => {
frames.removeEventListener(event, listener, options);
};
},
removeEventListener(event, listener, options) {
frames.each((frame) => {
frame.document.removeEventListener(event, listener, options);
});
}
};
return frames;
}
var isHTMLElement2 = (node) => {
return node !== null && typeof node === "object" && node.nodeType === 1;
};
function trackInteractOutside(node, options) {

@@ -128,10 +156,8 @@ const { exclude, onFocusOutside, onPointerDownOutside, onInteractOutside } = options;

const win = getWindow(node);
const frames = getWindowFrames(win);
function isEventOutside(event) {
const target = getEventTarget(event);
if (!(target instanceof win.HTMLElement)) {
if (!isHTMLElement2(target)) {
return false;
}
if (!contains(doc.documentElement, target)) {
return false;
}
if (contains(node, target)) {

@@ -162,5 +188,7 @@ return false;

if (event.pointerType === "touch") {
frames.removeEventListener("click", handler);
doc.removeEventListener("click", handler);
clickHandler = handler;
doc.addEventListener("click", handler, { once: true });
frames.addEventListener("click", handler, { once: true });
} else {

@@ -172,2 +200,3 @@ handler();

const timer = setTimeout(() => {
cleanups.add(frames.addEventListener("pointerdown", onPointerDown, true));
cleanups.add(addDomEvent(doc, "pointerdown", onPointerDown, true));

@@ -193,6 +222,9 @@ }, 0);

cleanups.add(addDomEvent(doc, "focusin", onFocusin, true));
cleanups.add(frames.addEventListener("focusin", onFocusin, true));
return () => {
clearTimeout(timer);
if (clickHandler)
if (clickHandler) {
frames.removeEventListener("click", clickHandler);
doc.removeEventListener("click", clickHandler);
}
cleanups.forEach((fn) => fn());

@@ -199,0 +231,0 @@ };

6

package.json
{
"name": "@zag-js/interact-outside",
"version": "0.0.0-dev-20230202113057",
"version": "0.0.0-dev-20230214091932",
"description": "Track interations or focus outside an element",

@@ -20,4 +20,4 @@ "keywords": [

"clean-package": "2.2.0",
"@zag-js/dom-utils": "0.0.0-dev-20230202113057",
"@zag-js/utils": "0.0.0-dev-20230202113057"
"@zag-js/dom-utils": "0.2.4",
"@zag-js/utils": "0.3.3"
},

@@ -24,0 +24,0 @@ "publishConfig": {

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