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

ahooks

Package Overview
Dependencies
Maintainers
4
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ahooks - npm Package Compare versions

Comparing version 3.5.0 to 3.5.1

es/utils/getDocumentOrShadow.d.ts

6

es/useClickAway/index.js
import useLatest from '../useLatest';
import { getTargetElement } from '../utils/domTarget';
import getDocumentOrShadow from '../utils/getDocumentOrShadow';
import useEffectWithTarget from '../utils/useEffectWithTarget';

@@ -24,9 +25,10 @@ export default function useClickAway(onClickAway, target, eventName) {

var documentOrShadow = getDocumentOrShadow(target);
var eventNames = Array.isArray(eventName) ? eventName : [eventName];
eventNames.forEach(function (event) {
return document.addEventListener(event, handler);
return documentOrShadow.addEventListener(event, handler);
});
return function () {
eventNames.forEach(function (event) {
return document.removeEventListener(event, handler);
return documentOrShadow.removeEventListener(event, handler);
});

@@ -33,0 +35,0 @@ };

@@ -50,5 +50,4 @@ var __read = this && this.__read || function (o, n) {

useEventListener('focusout', function (e) {
var _a, _b; // @ts-ignore
var _a, _b;
if (isFocusWithin && !((_b = (_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.contains) === null || _b === void 0 ? void 0 : _b.call(_a, e.relatedTarget))) {

@@ -55,0 +54,0 @@ onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);

@@ -5,4 +5,5 @@ import type { BasicTarget } from '../utils/domTarget';

onLeave?: () => void;
onChange?: (isHovering: boolean) => void;
}
declare const _default: (target: BasicTarget, options?: Options | undefined) => boolean;
export default _default;

@@ -33,3 +33,4 @@ var __read = this && this.__read || function (o, n) {

onEnter = _a.onEnter,
onLeave = _a.onLeave;
onLeave = _a.onLeave,
onChange = _a.onChange;

@@ -45,2 +46,3 @@ var _b = __read(useBoolean(false), 2),

setTrue();
onChange === null || onChange === void 0 ? void 0 : onChange(true);
}, {

@@ -52,2 +54,3 @@ target: target

setFalse();
onChange === null || onChange === void 0 ? void 0 : onChange(false);
}, {

@@ -54,0 +57,0 @@ target: target

@@ -27,3 +27,3 @@ import { useCallback, useEffect, useRef } from 'react';

if (timerRef.current) {
clearTimeout(timerRef.current);
clearInterval(timerRef.current);
}

@@ -30,0 +30,0 @@ }, []);

@@ -89,8 +89,3 @@ var __assign = this && this.__assign || function () {

setRatio(entry.intersectionRatio);
if (entry.isIntersecting) {
setState(true);
} else {
setState(false);
}
setState(entry.isIntersecting);
}

@@ -97,0 +92,0 @@ } catch (e_1_1) {

@@ -220,3 +220,3 @@ var __values = this && this.__values || function (o) {

function genKeyFormater(keyFilter, exactMatch) {
function genKeyFormatter(keyFilter, exactMatch) {
if (isFunction(keyFilter)) {

@@ -273,3 +273,3 @@ return keyFilter;

var genGuard = genKeyFormater(keyFilterRef.current, exactMatch);
var genGuard = genKeyFormatter(keyFilterRef.current, exactMatch);

@@ -276,0 +276,0 @@ if (genGuard(event)) {

@@ -46,2 +46,3 @@ var __values = this && this.__values || function (o) {

import { useEffect, useState } from 'react';
import isBrowser from '../utils/isBrowser';
var subscribers = new Set();

@@ -122,5 +123,3 @@ var info;

export function useResponsive() {
var windowExists = typeof window !== 'undefined';
if (windowExists && !listening) {
if (isBrowser && !listening) {
info = {};

@@ -137,3 +136,3 @@ calculate();

useEffect(function () {
if (!windowExists) return;
if (!isBrowser) return;

@@ -140,0 +139,0 @@ var subscriber = function subscriber() {

@@ -17,2 +17,4 @@ "use strict";

var getDocumentOrShadow_1 = __importDefault(require("../utils/getDocumentOrShadow"));
var useEffectWithTarget_1 = __importDefault(require("../utils/useEffectWithTarget"));

@@ -40,9 +42,10 @@

var documentOrShadow = getDocumentOrShadow_1["default"](target);
var eventNames = Array.isArray(eventName) ? eventName : [eventName];
eventNames.forEach(function (event) {
return document.addEventListener(event, handler);
return documentOrShadow.addEventListener(event, handler);
});
return function () {
eventNames.forEach(function (event) {
return document.removeEventListener(event, handler);
return documentOrShadow.removeEventListener(event, handler);
});

@@ -49,0 +52,0 @@ };

@@ -64,5 +64,4 @@ "use strict";

useEventListener_1["default"]('focusout', function (e) {
var _a, _b; // @ts-ignore
var _a, _b;
if (isFocusWithin && !((_b = (_a = e.currentTarget) === null || _a === void 0 ? void 0 : _a.contains) === null || _b === void 0 ? void 0 : _b.call(_a, e.relatedTarget))) {

@@ -69,0 +68,0 @@ onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);

@@ -5,4 +5,5 @@ import type { BasicTarget } from '../utils/domTarget';

onLeave?: () => void;
onChange?: (isHovering: boolean) => void;
}
declare const _default: (target: BasicTarget, options?: Options | undefined) => boolean;
export default _default;

@@ -47,3 +47,4 @@ "use strict";

onEnter = _a.onEnter,
onLeave = _a.onLeave;
onLeave = _a.onLeave,
onChange = _a.onChange;

@@ -59,2 +60,3 @@ var _b = __read(useBoolean_1["default"](false), 2),

setTrue();
onChange === null || onChange === void 0 ? void 0 : onChange(true);
}, {

@@ -66,2 +68,3 @@ target: target

setFalse();
onChange === null || onChange === void 0 ? void 0 : onChange(false);
}, {

@@ -68,0 +71,0 @@ target: target

@@ -41,3 +41,3 @@ "use strict";

if (timerRef.current) {
clearTimeout(timerRef.current);
clearInterval(timerRef.current);
}

@@ -44,0 +44,0 @@ }, []);

@@ -104,8 +104,3 @@ "use strict";

setRatio(entry.intersectionRatio);
if (entry.isIntersecting) {
setState(true);
} else {
setState(false);
}
setState(entry.isIntersecting);
}

@@ -112,0 +107,0 @@ } catch (e_1_1) {

@@ -236,3 +236,3 @@ "use strict";

function genKeyFormater(keyFilter, exactMatch) {
function genKeyFormatter(keyFilter, exactMatch) {
if (utils_1.isFunction(keyFilter)) {

@@ -289,3 +289,3 @@ return keyFilter;

var genGuard = genKeyFormater(keyFilterRef.current, exactMatch);
var genGuard = genKeyFormatter(keyFilterRef.current, exactMatch);

@@ -292,0 +292,0 @@ if (genGuard(event)) {

@@ -47,2 +47,8 @@ "use strict";

var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", {

@@ -55,2 +61,4 @@ value: true

var isBrowser_1 = __importDefault(require("../utils/isBrowser"));
var subscribers = new Set();

@@ -134,5 +142,3 @@ var info;

function useResponsive() {
var windowExists = typeof window !== 'undefined';
if (windowExists && !listening) {
if (isBrowser_1["default"] && !listening) {
info = {};

@@ -149,3 +155,3 @@ calculate();

react_1.useEffect(function () {
if (!windowExists) return;
if (!isBrowser_1["default"]) return;

@@ -152,0 +158,0 @@ var subscriber = function subscriber() {

{
"name": "ahooks",
"version": "3.5.0",
"version": "3.5.1",
"description": "react hooks library",

@@ -24,2 +24,5 @@ "keywords": [

"homepage": "https://github.com/alibaba/hooks",
"scripts": {
"build": "gulp && webpack-cli"
},
"files": [

@@ -61,6 +64,3 @@ "dist",

"license": "MIT",
"gitHead": "11f6ad571bd365c95ecb9409ca3050cbbfc9b34a",
"scripts": {
"build": "gulp && webpack-cli"
}
}
"gitHead": "11f6ad571bd365c95ecb9409ca3050cbbfc9b34a"
}

@@ -15,3 +15,3 @@ <p align="center">

[![npm](https://img.shields.io/github/issues/alibaba/hooks)](https://github.com/alibaba/hooks/issues)
[![Coverage Status](https://coveralls.io/repos/github/alibaba/hooks/badge.svg?branch=doc/beautify)](https://coveralls.io/github/alibaba/hooks?branch=doc/beautify)
[![Coverage Status](https://coveralls.io/repos/github/alibaba/hooks/badge.svg?branch=master)](https://coveralls.io/github/alibaba/hooks?branch=master)
![gzip size](https://img.badgesize.io/https:/unpkg.com/ahooks/dist/ahooks.js?label=gzip%20size&compression=gzip)

@@ -18,0 +18,0 @@ [![Percentage of issues still open](http://isitmaintained.com/badge/open/alibaba/hooks.svg)](http://isitmaintained.com/project/alibaba/hooks 'Percentage of issues still open')

Sorry, the diff of this file is too big to display

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