Socket
Socket
Sign inDemoInstall

@radix-ui/react-dismissable-layer

Package Overview
Dependencies
Maintainers
5
Versions
188
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-dismissable-layer - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

2

dist/index.js

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

function e(e,t,n){Object.defineProperty(e,t,{get:n,enumerable:!0})}var t=require("@radix-ui/react-use-escape-keydown").useEscapeKeydown,n=require("@radix-ui/react-use-callback-ref").useCallbackRef,r=require("@radix-ui/react-use-body-pointer-events").useBodyPointerEvents,u=require("react"),o=u.createElement,s=u.useRef,i=u.useEffect,c=u.createContext,a=u.useState,l=u.useMemo,d=u.useContext,f=u.useLayoutEffect,v={};const[m,p]=D(),[y,E]=x(),[P,C]=D("TotalLayerCountWithDisabledOutsidePointerEventsProvider"),[b,w]=x("RunningLayerCountWithDisabledOutsidePointerEventsProvider");function L(e){const t=0===E(),n=o(h,e);return t?o(m,null,o(P,null,n)):n}function h(e){const{children:u,disableOutsidePointerEvents:c=!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:d,onInteractOutside:f,onDismiss:v}=e,m=s(null),P=p(),L=E()+1,h=L===P,D=C(c),x=w()+(c?1:0),O=x<D;r({disabled:c}),t((e=>{h&&(null==a||a(e),e.defaultPrevented||null==v||v())}));const T=function(e){const t=n(e),r=s(!1);i((()=>{const e=e=>{r.current||t(e),r.current=!1};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}}),[t]);const u=()=>{r.current=!0};return{onMouseDownCapture:u,onTouchStartCapture:u}}((e=>{O||(null==l||l(e),null==f||f(e),e.defaultPrevented||null==v||v())})),g=function(e){const t=s(0);return{onBlurCapture:n=>{n.persist(),t.current=window.setTimeout((()=>{null==e||e(n)}),0)},onFocusCapture:()=>{window.clearTimeout(t.current)}}}((e=>{null==d||d(e),null==f||f(e),e.defaultPrevented||null==v||v()}));return o(y,{runningCount:L},o(b,{runningCount:x},u({ref:m,style:D>0&&!O?{pointerEvents:"auto"}:{},...T,...g})))}function D(e){const t=c({total:0,setTotal:()=>{}}),n=({children:e})=>{const[n,r]=a(0),u=l((()=>({total:n,setTotal:r})),[n,r]);return o(t.Provider,{value:u},e)};return e&&(n.displayName=e),[n,function(e=!0){const{total:n,setTotal:r}=d(t);return f((()=>{if(e)return r((e=>e+1)),()=>r((e=>e-1))}),[e,r]),n}]}function x(e){const t=c(0),n=e=>{const{children:n,runningCount:r}=e;return o(t.Provider,{value:r},n)};return e&&(n.displayName=e),[n,function(){return d(t)||0}]}exports.DismissableLayer=L;const O=L;exports.Root=O,e(v,"Root",(function(){return O})),e(v,"DismissableLayer",(function(){return L}));
var e,t,n=require("@radix-ui/react-use-escape-keydown").useEscapeKeydown,r=require("@radix-ui/react-use-callback-ref").useCallbackRef,u=require("@radix-ui/react-use-body-pointer-events").useBodyPointerEvents,o=(e={},t=require("react"),Object.keys(t).forEach((function(n){"default"!==n&&"__esModule"!==n&&Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),e);const[s,c]=p(),[i,a]=y(),[l,d]=p("TotalLayerCountWithDisabledOutsidePointerEventsProvider"),[f,m]=y("RunningLayerCountWithDisabledOutsidePointerEventsProvider");function v(e){const t=0===a(),n=o.createElement(E,e);return t?o.createElement(s,null,o.createElement(l,null,n)):n}function E(e){const{children:t,disableOutsidePointerEvents:s=!1,onEscapeKeyDown:l,onPointerDownOutside:v,onFocusOutside:E,onInteractOutside:p,onDismiss:y}=e,C=o.useRef(null),P=c(),b=a()+1,w=b===P,h=d(s),x=m()+(s?1:0),L=x<h;u({disabled:s}),n((e=>{w&&(null==l||l(e),e.defaultPrevented||null==y||y())}));const O=function(e){const t=r(e),n=o.useRef(!1);o.useEffect((()=>{const e=e=>{n.current||t(e),n.current=!1};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}}),[t]);const u=()=>{n.current=!0};return{onMouseDownCapture:u,onTouchStartCapture:u}}((e=>{L||(null==v||v(e),null==p||p(e),e.defaultPrevented||null==y||y())})),D=function(e){const t=o.useRef(0);return{onBlurCapture:n=>{n.persist(),t.current=window.setTimeout((()=>{null==e||e(n)}),0)},onFocusCapture:()=>{window.clearTimeout(t.current)}}}((e=>{null==E||E(e),null==p||p(e),e.defaultPrevented||null==y||y()})),T=h>0&&!L;return o.createElement(i,{runningCount:b},o.createElement(f,{runningCount:x},t({ref:C,style:T?{pointerEvents:"auto"}:{},...O,...D})))}function p(e){const t=o.createContext({total:0,setTotal:()=>{}}),n=({children:e})=>{const[n,r]=o.useState(0),u=o.useMemo((()=>({total:n,setTotal:r})),[n,r]);return o.createElement(t.Provider,{value:u},e)};return e&&(n.displayName=e),[n,function(e=!0){const{total:n,setTotal:r}=o.useContext(t);return o.useLayoutEffect((()=>{if(e)return r((e=>e+1)),()=>r((e=>e-1))}),[e,r]),n}]}function y(e){const t=o.createContext(0),n=e=>{const{children:n,runningCount:r}=e;return o.createElement(t.Provider,{value:r},n)};return e&&(n.displayName=e),[n,function(){return o.useContext(t)||0}]}exports.DismissableLayer=v;const C=v;exports.Root=C;
//# sourceMappingURL=index.js.map

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

function t(t,n,e){Object.defineProperty(t,n,{get:e,enumerable:!0})}import{useEscapeKeydown as n}from"@radix-ui/react-use-escape-keydown";import{useCallbackRef as e}from"@radix-ui/react-use-callback-ref";import{useBodyPointerEvents as r}from"@radix-ui/react-use-body-pointer-events";import{createElement as o,useRef as u,useEffect as i,createContext as s,useState as c,useMemo as l,useContext as a,useLayoutEffect as d}from"react";var m={};const[f,v]=D(),[p,P]=L(),[w,y]=D("TotalLayerCountWithDisabledOutsidePointerEventsProvider"),[b,C]=L("RunningLayerCountWithDisabledOutsidePointerEventsProvider");function E(t){const n=0===P(),e=o(h,t);return n?o(f,null,o(w,null,e)):e}export{E as DismissableLayer};function h(t){const{children:s,disableOutsidePointerEvents:c=!1,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:d,onInteractOutside:m,onDismiss:f}=t,w=u(null),E=v(),h=P()+1,D=h===E,L=y(c),O=C()+(c?1:0),T=O<L;r({disabled:c}),n((t=>{D&&(null==l||l(t),t.defaultPrevented||null==f||f())}));const g=function(t){const n=e(t),r=u(!1);i((()=>{const t=t=>{r.current||n(t),r.current=!1};return document.addEventListener("mousedown",t),document.addEventListener("touchstart",t),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("touchstart",t)}}),[n]);const o=()=>{r.current=!0};return{onMouseDownCapture:o,onTouchStartCapture:o}}((t=>{T||(null==a||a(t),null==m||m(t),t.defaultPrevented||null==f||f())})),x=function(t){const n=u(0);return{onBlurCapture:e=>{e.persist(),n.current=window.setTimeout((()=>{null==t||t(e)}),0)},onFocusCapture:()=>{window.clearTimeout(n.current)}}}((t=>{null==d||d(t),null==m||m(t),t.defaultPrevented||null==f||f()}));return o(p,{runningCount:h},o(b,{runningCount:O},s({ref:w,style:L>0&&!T?{pointerEvents:"auto"}:{},...g,...x})))}function D(t){const n=s({total:0,setTotal:()=>{}}),e=({children:t})=>{const[e,r]=c(0),u=l((()=>({total:e,setTotal:r})),[e,r]);return o(n.Provider,{value:u},t)};return t&&(e.displayName=t),[e,function(t=!0){const{total:e,setTotal:r}=a(n);return d((()=>{if(t)return r((t=>t+1)),()=>r((t=>t-1))}),[t,r]),e}]}function L(t){const n=s(0),e=t=>{const{children:e,runningCount:r}=t;return o(n.Provider,{value:r},e)};return t&&(e.displayName=t),[e,function(){return a(n)||0}]}export const Root=E;t(m,"Root",(function(){return Root})),t(m,"DismissableLayer",(function(){return E}));
import{useEscapeKeydown as e}from"@radix-ui/react-use-escape-keydown";import{useCallbackRef as t}from"@radix-ui/react-use-callback-ref";import{useBodyPointerEvents as n}from"@radix-ui/react-use-body-pointer-events";import*as r from"react";const[o,u]=f(),[s,i]=v(),[a,c]=f("TotalLayerCountWithDisabledOutsidePointerEventsProvider"),[l,d]=v("RunningLayerCountWithDisabledOutsidePointerEventsProvider");export function DismissableLayer(e){const t=0===i(),n=r.createElement(m,e);return t?r.createElement(o,null,r.createElement(a,null,n)):n}function m(o){const{children:a,disableOutsidePointerEvents:m=!1,onEscapeKeyDown:f,onPointerDownOutside:v,onFocusOutside:E,onInteractOutside:p,onDismiss:C}=o,y=r.useRef(null),P=u(),w=i()+1,x=w===P,L=c(m),b=d()+(m?1:0),h=b<L;n({disabled:m}),e((e=>{x&&(null==f||f(e),e.defaultPrevented||null==C||C())}));const D=function(e){const n=t(e),o=r.useRef(!1);r.useEffect((()=>{const e=e=>{o.current||n(e),o.current=!1};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}}),[n]);const u=()=>{o.current=!0};return{onMouseDownCapture:u,onTouchStartCapture:u}}((e=>{h||(null==v||v(e),null==p||p(e),e.defaultPrevented||null==C||C())})),T=function(e){const t=r.useRef(0);return{onBlurCapture:n=>{n.persist(),t.current=window.setTimeout((()=>{null==e||e(n)}),0)},onFocusCapture:()=>{window.clearTimeout(t.current)}}}((e=>{null==E||E(e),null==p||p(e),e.defaultPrevented||null==C||C()})),O=L>0&&!h;return r.createElement(s,{runningCount:w},r.createElement(l,{runningCount:b},a({ref:y,style:O?{pointerEvents:"auto"}:{},...D,...T})))}function f(e){const t=r.createContext({total:0,setTotal:()=>{}}),n=({children:e})=>{const[n,o]=r.useState(0),u=r.useMemo((()=>({total:n,setTotal:o})),[n,o]);return r.createElement(t.Provider,{value:u},e)};return e&&(n.displayName=e),[n,function(e=!0){const{total:n,setTotal:o}=r.useContext(t);return r.useLayoutEffect((()=>{if(e)return o((e=>e+1)),()=>o((e=>e-1))}),[e,o]),n}]}function v(e){const t=r.createContext(0),n=e=>{const{children:n,runningCount:o}=e;return r.createElement(t.Provider,{value:o},n)};return e&&(n.displayName=e),[n,function(){return r.useContext(t)||0}]}export const Root=DismissableLayer;
//# sourceMappingURL=index.module.js.map
{
"name": "@radix-ui/react-dismissable-layer",
"version": "0.0.10",
"version": "0.0.11",
"license": "MIT",

@@ -21,5 +21,5 @@ "source": "src/index.ts",

"@babel/runtime": "^7.13.10",
"@radix-ui/react-use-body-pointer-events": "0.0.4",
"@radix-ui/react-use-callback-ref": "0.0.3",
"@radix-ui/react-use-escape-keydown": "0.0.4"
"@radix-ui/react-use-body-pointer-events": "0.0.5",
"@radix-ui/react-use-callback-ref": "0.0.4",
"@radix-ui/react-use-escape-keydown": "0.0.5"
},

@@ -26,0 +26,0 @@ "devDependencies": {

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