Socket
Socket
Sign inDemoInstall

@radix-ui/react-dismissable-layer

Package Overview
Dependencies
Maintainers
6
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.12 to 0.0.13

1

dist/index.d.ts
import * as React from "react";
type DismissableLayerProps = {
children: (args: ReturnType<typeof usePointerDownOutside> & ReturnType<typeof useFocusOutside> & {
ref: React.RefObject<any>;
style: React.CSSProperties;

@@ -6,0 +5,0 @@ }) => React.ReactElement;

2

dist/index.js

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

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]=C(),[i,a]=p(),[l,d]=C("TotalLayerCountWithDisabledOutsidePointerEventsProvider"),[f,v]=p("RunningLayerCountWithDisabledOutsidePointerEventsProvider");function m(e){const t=0===a(),n=/*#__PURE__*/o.createElement(E,e);return t?/*#__PURE__*/o.createElement(s,null,/*#__PURE__*/o.createElement(l,null,n)):n}function E(e){const{children:t,disableOutsidePointerEvents:s=!1,onEscapeKeyDown:l,onPointerDownOutside:m,onFocusOutside:E,onInteractOutside:C,onDismiss:p}=e,P=o.useRef(null),y=c(),b=a()+1,w=b===y,h=d(s),x=v()+(s?1:0),L=x<h;u({disabled:s}),n((e=>{w&&(null==l||l(e),e.defaultPrevented||null==p||p())}));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==m||m(e),null==C||C(e),e.defaultPrevented||null==p||p())})),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==C||C(e),e.defaultPrevented||null==p||p()})),T=h>0&&!L;/*#__PURE__*/return o.createElement(i,{runningCount:b},/*#__PURE__*/o.createElement(f,{runningCount:x},t({ref:P,style:T?{pointerEvents:"auto"}:{},...O,...D})))}function C(e){const t=/*#__PURE__*/o.createContext({total:0,setTotal:()=>{}}),n=({children:e})=>{const[n,r]=o.useState(0),u=o.useMemo((()=>({total:n,setTotal:r})),[n,r]);/*#__PURE__*/return o.createElement(t.Provider,{value:u},e)};return[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 p(e){const t=/*#__PURE__*/o.createContext(0),n=e=>{const{children:n,runningCount:r}=e;/*#__PURE__*/return o.createElement(t.Provider,{value:r},n)};return[n,function(){return o.useContext(t)||0}]}exports.DismissableLayer=m;const P=m;exports.Root=P;
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]=C(),[i,a]=p(),[l,d]=C("TotalLayerCountWithDisabledOutsidePointerEventsProvider"),[f,m]=p("RunningLayerCountWithDisabledOutsidePointerEventsProvider");function v(e){const t=0===a(),n=/*#__PURE__*/o.createElement(E,e);return t?/*#__PURE__*/o.createElement(s,null,/*#__PURE__*/o.createElement(l,null,n)):n}function E(e){const{children:t,disableOutsidePointerEvents:s=!1,onEscapeKeyDown:l,onPointerDownOutside:v,onFocusOutside:E,onInteractOutside:C,onDismiss:p}=e,w=c(),P=a()+1,y=P===w,b=d(s),h=m()+(s?1:0),x=h<b;u({disabled:s}),n((e=>{y&&(null==l||l(e),e.defaultPrevented||null==p||p())}));const L=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=>{x||(null==v||v(e),null==C||C(e),e.defaultPrevented||null==p||p())})),O=function(e){const t=o.useRef(0);return o.useEffect((()=>()=>window.clearTimeout(t.current)),[]),{onBlurCapture:n=>{n.persist(),t.current=window.setTimeout((()=>{null==e||e(n)}),0)},onFocusCapture:()=>{window.clearTimeout(t.current)}}}((e=>{null==E||E(e),null==C||C(e),e.defaultPrevented||null==p||p()})),T=b>0&&!x;/*#__PURE__*/return o.createElement(i,{runningCount:P},/*#__PURE__*/o.createElement(f,{runningCount:h},t({style:T?{pointerEvents:"auto"}:{},...L,...O})))}function C(e){const t=/*#__PURE__*/o.createContext({total:0,setTotal:()=>{}}),n=({children:e})=>{const[n,r]=o.useState(0),u=o.useMemo((()=>({total:n,setTotal:r})),[n,r]);/*#__PURE__*/return o.createElement(t.Provider,{value:u},e)};return[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 p(e){const t=/*#__PURE__*/o.createContext(0),n=e=>{const{children:n,runningCount:r}=e;/*#__PURE__*/return o.createElement(t.Provider,{value:r},n)};return[n,function(){return o.useContext(t)||0}]}exports.DismissableLayer=v;const w=v;exports.Root=w;
//# sourceMappingURL=index.js.map

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

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(),[c,a]=f("TotalLayerCountWithDisabledOutsidePointerEventsProvider"),[l,d]=v("RunningLayerCountWithDisabledOutsidePointerEventsProvider");export function DismissableLayer(e){const t=0===i(),n=/*#__PURE__*/r.createElement(m,e);return t?/*#__PURE__*/r.createElement(o,null,/*#__PURE__*/r.createElement(c,null,n)):n}function m(o){const{children:c,disableOutsidePointerEvents:m=!1,onEscapeKeyDown:f,onPointerDownOutside:v,onFocusOutside:E,onInteractOutside:p,onDismiss:C}=o,P=r.useRef(null),w=u(),x=i()+1,y=x===w,L=a(m),b=d()+(m?1:0),h=b<L;n({disabled:m}),e((e=>{y&&(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;/*#__PURE__*/return r.createElement(s,{runningCount:x},/*#__PURE__*/r.createElement(l,{runningCount:b},c({ref:P,style:O?{pointerEvents:"auto"}:{},...D,...T})))}function f(e){const t=/*#__PURE__*/r.createContext({total:0,setTotal:()=>{}}),n=({children:e})=>{const[n,o]=r.useState(0),u=r.useMemo((()=>({total:n,setTotal:o})),[n,o]);/*#__PURE__*/return r.createElement(t.Provider,{value:u},e)};return[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=/*#__PURE__*/r.createContext(0),n=e=>{const{children:n,runningCount:o}=e;/*#__PURE__*/return r.createElement(t.Provider,{value:o},n)};return[n,function(){return r.useContext(t)||0}]}export const Root=DismissableLayer;
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(),[c,a]=f("TotalLayerCountWithDisabledOutsidePointerEventsProvider"),[l,d]=v("RunningLayerCountWithDisabledOutsidePointerEventsProvider");export function DismissableLayer(e){const t=0===i(),n=/*#__PURE__*/r.createElement(m,e);return t?/*#__PURE__*/r.createElement(o,null,/*#__PURE__*/r.createElement(c,null,n)):n}function m(o){const{children:c,disableOutsidePointerEvents:m=!1,onEscapeKeyDown:f,onPointerDownOutside:v,onFocusOutside:E,onInteractOutside:p,onDismiss:C}=o,w=u(),P=i()+1,x=P===w,y=a(m),L=d()+(m?1:0),b=L<y;n({disabled:m}),e((e=>{x&&(null==f||f(e),e.defaultPrevented||null==C||C())}));const h=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=>{b||(null==v||v(e),null==p||p(e),e.defaultPrevented||null==C||C())})),D=function(e){const t=r.useRef(0);return r.useEffect((()=>()=>window.clearTimeout(t.current)),[]),{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()})),T=y>0&&!b;/*#__PURE__*/return r.createElement(s,{runningCount:P},/*#__PURE__*/r.createElement(l,{runningCount:L},c({style:T?{pointerEvents:"auto"}:{},...h,...D})))}function f(e){const t=/*#__PURE__*/r.createContext({total:0,setTotal:()=>{}}),n=({children:e})=>{const[n,o]=r.useState(0),u=r.useMemo((()=>({total:n,setTotal:o})),[n,o]);/*#__PURE__*/return r.createElement(t.Provider,{value:u},e)};return[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=/*#__PURE__*/r.createContext(0),n=e=>{const{children:n,runningCount:o}=e;/*#__PURE__*/return r.createElement(t.Provider,{value:o},n)};return[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.12",
"version": "0.0.13",
"license": "MIT",

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

Sorry, the diff of this file is not supported yet

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