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

@delangle/use-modal

Package Overview
Dependencies
Maintainers
1
Versions
383
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@delangle/use-modal - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

1

dist/index.esm.js

@@ -106,3 +106,2 @@ import { useRef, useState, useMemo, useEffect, useCallback, useLayoutEffect } from 'react';

}, [domRef, handleClose, state]);
console.log('STATE', state);
return {

@@ -109,0 +108,0 @@ state,

@@ -109,3 +109,2 @@ 'use strict';

}, [domRef, handleClose, state]);
console.log('STATE', state);
return {

@@ -112,0 +111,0 @@ state,

2

dist/index.min.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react");!function(e){e.opening="opening",e.opened="opened",e.closing="closing",e.closed="closed"}(exports.ModalState||(exports.ModalState={}));const ESCAPE_KEY="Escape",DEFAULT_CONFIG={animationDuration:300,animated:!1,persistent:!1,open:!1,onClose:()=>{}},useSSRLayoutEffect="object"==typeof window?React.useLayoutEffect:React.useEffect,useMergedRef=e=>{const t=React.useRef(null);return e||t},useHasAlreadyBeenOpened=e=>{const t=React.useRef(!1);return!t.current&&e&&(t.current=!0),t.current},useDelayedOpen=(e,t)=>{const n=React.useRef(!1),r=!n.current&&t&&e,[o,a]=React.useState(!r);return React.useEffect(()=>{n.current=!0,o||a(!0)},[o]),!(!o||!e)},useModal=e=>{const t={...DEFAULT_CONFIG,...e},n=useDelayedOpen(t.open,t.animated),r=useHasAlreadyBeenOpened(n),o=useMergedRef(t.ref),a=React.useRef(t),[s,c]=React.useState(!1),u=React.useMemo(()=>n||s?!n&&s?exports.ModalState.closing:n&&!s?exports.ModalState.opening:exports.ModalState.opened:exports.ModalState.closed,[n,s]);React.useEffect(()=>{a.current=t}),useSSRLayoutEffect(()=>{a.current.animated||n===s||c(n)},[s,n]);const d=React.useCallback(()=>{a.current.onClose()},[]);return React.useEffect(()=>{if(a.current.animated){const e=setTimeout(()=>c(n),a.current.animationDuration);return()=>clearTimeout(e)}},[n]),React.useEffect(()=>{if(u===exports.ModalState.opened){const e=e=>{!a.current.persistent&&a.current.open&&"Escape"===e.key&&d()},t=e=>{a.current.persistent||!o.current||o.current.contains(e.target)||d()};return window.addEventListener("keydown",e),window.addEventListener("click",t),()=>{window.removeEventListener("keydown",e),window.removeEventListener("click",t)}}},[o,d,u]),console.log("STATE",u),{state:u,close:d,ref:o,hasAlreadyBeenOpened:r}};exports.default=useModal;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react");!function(e){e.opening="opening",e.opened="opened",e.closing="closing",e.closed="closed"}(exports.ModalState||(exports.ModalState={}));const ESCAPE_KEY="Escape",DEFAULT_CONFIG={animationDuration:300,animated:!1,persistent:!1,open:!1,onClose:()=>{}},useSSRLayoutEffect="object"==typeof window?React.useLayoutEffect:React.useEffect,useMergedRef=e=>{const t=React.useRef(null);return e||t},useHasAlreadyBeenOpened=e=>{const t=React.useRef(!1);return!t.current&&e&&(t.current=!0),t.current},useDelayedOpen=(e,t)=>{const n=React.useRef(!1),r=!n.current&&t&&e,[a,o]=React.useState(!r);return React.useEffect(()=>{n.current=!0,a||o(!0)},[a]),!(!a||!e)},useModal=e=>{const t={...DEFAULT_CONFIG,...e},n=useDelayedOpen(t.open,t.animated),r=useHasAlreadyBeenOpened(n),a=useMergedRef(t.ref),o=React.useRef(t),[s,c]=React.useState(!1),u=React.useMemo(()=>n||s?!n&&s?exports.ModalState.closing:n&&!s?exports.ModalState.opening:exports.ModalState.opened:exports.ModalState.closed,[n,s]);React.useEffect(()=>{o.current=t}),useSSRLayoutEffect(()=>{o.current.animated||n===s||c(n)},[s,n]);const d=React.useCallback(()=>{o.current.onClose()},[]);return React.useEffect(()=>{if(o.current.animated){const e=setTimeout(()=>c(n),o.current.animationDuration);return()=>clearTimeout(e)}},[n]),React.useEffect(()=>{if(u===exports.ModalState.opened){const e=e=>{!o.current.persistent&&o.current.open&&"Escape"===e.key&&d()},t=e=>{o.current.persistent||!a.current||a.current.contains(e.target)||d()};return window.addEventListener("keydown",e),window.addEventListener("click",t),()=>{window.removeEventListener("keydown",e),window.removeEventListener("click",t)}}},[a,d,u]),{state:u,close:d,ref:a,hasAlreadyBeenOpened:r}};exports.default=useModal;
//# sourceMappingURL=index.min.js.map
{
"name": "@delangle/use-modal",
"version": "1.0.1",
"version": "1.0.2",
"description": "React hook for modal management",

@@ -5,0 +5,0 @@ "private": false,

@@ -150,4 +150,2 @@ import * as React from 'react'

console.log('STATE', state)
return {

@@ -154,0 +152,0 @@ state,

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