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

@interop-ui/react-dismissable-layer

Package Overview
Dependencies
Maintainers
4
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.0.1-4 to 0.0.1-5

3

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

@@ -59,3 +59,4 @@ ref: React.RefObject<any>;

};
export const Root: typeof DismissableLayer;
//# sourceMappingURL=index.d.ts.map

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

var e,t,n=require("@interop-ui/react-debug-context").useDebugContext,r=require("@interop-ui/react-utils"),u=r.useCallbackRef,o=r.useDisableBodyPointerEvents,i=(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);function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){l(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(){return(f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,u=!1,o=void 0;try{for(var i,c=e[Symbol.iterator]();!(r=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){u=!0,o=e}finally{try{r||null==c.return||c.return()}finally{if(u)throw o}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var v=s(L(),2),p=v[0],y=v[1],b=s(S(),2),m=b[0],O=b[1],h=s(L("TotalLayerCountWithDisabledOutsidePointerEventsProvider"),2),E=h[0],g=h[1],w=s(S("RunningLayerCountWithDisabledOutsidePointerEventsProvider"),2),P=w[0],j=w[1];function C(e){var t=0===O(),n=i.createElement(D,e);return t?i.createElement(p,null,i.createElement(E,null,n)):n}function D(e){var t=e.nodeRef,n=e.children,r=e.disableOutsidePointerEvents,c=void 0!==r&&r,l=e.onEscapeKeyDown,f=e.onPointerDownOutside,s=e.onFocusOutside,d=e.onInteractOutside,v=e.onDismiss,p=y(),b=O()+1,h=b===p,E=g(c),w=j()+(c?1:0),C=w<E;o({disabled:c}),function(e){var t=u(e);i.useEffect((function(){var e=function(e){"Escape"===e.key&&t(e)};return document.addEventListener("keydown",e),function(){return document.removeEventListener("keydown",e)}}),[t])}((function(e){h&&(null==l||l(e),e.defaultPrevented||null==v||v())}));var D=function(e){var t=u(e),n=i.useRef(!1);i.useEffect((function(){var e=function(e){n.current||t(e),n.current=!1};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),function(){document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}}),[t]);var r=function(){n.current=!0};return{onMouseDownCapture:r,onTouchStartCapture:r}}((function(e){C||(null==f||f(e),null==d||d(e),e.defaultPrevented||null==v||v())})),L=function(e){var t=i.useRef(0);return{onBlurCapture:function(n){n.persist(),t.current=window.setTimeout((function(){null==e||e(n)}),0)},onFocusCapture:function(){window.clearTimeout(t.current)}}}((function(e){null==s||s(e),null==d||d(e),e.defaultPrevented||null==v||v()})),S=E>0&&!C;return i.createElement(m,{runningCount:b},i.createElement(P,{runningCount:w},n(a(a({ref:t,style:S?{pointerEvents:"auto"}:{}},D),L))))}function L(e){var t=i.createContext({total:0,setTotal:function(){}}),n=function(e){var n=e.children,r=s(i.useState(0),2),u=r[0],o=r[1],c=i.useMemo((function(){return{total:u,setTotal:o}}),[u,o]);return i.createElement(t.Provider,{value:c},n)};return e&&(n.displayName=e),[n,function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=i.useContext(t),r=n.total,u=n.setTotal;return i.useLayoutEffect((function(){if(e)return u((function(e){return e+1})),function(){return u((function(e){return e-1}))}}),[e,u]),r}]}function S(e){var t=i.createContext(0),n=function(e){var n=e.children,r=e.runningCount;return i.createElement(t.Provider,{value:r},n)};return e&&(n.displayName=e),[n,function(){return i.useContext(t)||0}]}exports.DismissableLayer=function(e){var t=n(),r=i.useRef(null);return t.disableLock?e.children({ref:r,style:{},onBlurCapture:function(){},onFocusCapture:function(){},onMouseDownCapture:function(){},onTouchStartCapture:function(){}}):i.createElement(C,f({nodeRef:r},e))};
var e,t,n=require("@interop-ui/react-utils"),r=n.useCallbackRef,u=n.useDisableBodyPointerEvents,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);function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,u=!1,o=void 0;try{for(var i,c=e[Symbol.iterator]();!(r=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){u=!0,o=e}finally{try{r||null==c.return||c.return()}finally{if(u)throw o}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var s=l(C(),2),d=s[0],v=s[1],y=l(D(),2),m=y[0],b=y[1],p=l(C("TotalLayerCountWithDisabledOutsidePointerEventsProvider"),2),O=p[0],E=p[1],h=l(D("RunningLayerCountWithDisabledOutsidePointerEventsProvider"),2),w=h[0],P=h[1];function g(e){var t=0===b(),n=o.createElement(j,e);return t?o.createElement(d,null,o.createElement(O,null,n)):n}function j(e){var t=e.children,n=e.disableOutsidePointerEvents,i=void 0!==n&&n,a=e.onEscapeKeyDown,l=e.onPointerDownOutside,f=e.onFocusOutside,s=e.onInteractOutside,d=e.onDismiss,y=o.useRef(null),p=v(),O=b()+1,h=O===p,g=E(i),j=P()+(i?1:0),C=j<g;u({disabled:i}),function(e){var t=r(e);o.useEffect((function(){var e=function(e){"Escape"===e.key&&t(e)};return document.addEventListener("keydown",e),function(){return document.removeEventListener("keydown",e)}}),[t])}((function(e){h&&(null==a||a(e),e.defaultPrevented||null==d||d())}));var D=function(e){var t=r(e),n=o.useRef(!1);o.useEffect((function(){var e=function(e){n.current||t(e),n.current=!1};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),function(){document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}}),[t]);var u=function(){n.current=!0};return{onMouseDownCapture:u,onTouchStartCapture:u}}((function(e){C||(null==l||l(e),null==s||s(e),e.defaultPrevented||null==d||d())})),L=function(e){var t=o.useRef(0);return{onBlurCapture:function(n){n.persist(),t.current=window.setTimeout((function(){null==e||e(n)}),0)},onFocusCapture:function(){window.clearTimeout(t.current)}}}((function(e){null==f||f(e),null==s||s(e),e.defaultPrevented||null==d||d()})),S=g>0&&!C;return o.createElement(m,{runningCount:O},o.createElement(w,{runningCount:j},t(c(c({ref:y,style:S?{pointerEvents:"auto"}:{}},D),L))))}function C(e){var t=o.createContext({total:0,setTotal:function(){}}),n=function(e){var n=e.children,r=l(o.useState(0),2),u=r[0],i=r[1],c=o.useMemo((function(){return{total:u,setTotal:i}}),[u,i]);return o.createElement(t.Provider,{value:c},n)};return e&&(n.displayName=e),[n,function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=o.useContext(t),r=n.total,u=n.setTotal;return o.useLayoutEffect((function(){if(e)return u((function(e){return e+1})),function(){return u((function(e){return e-1}))}}),[e,u]),r}]}function D(e){var t=o.createContext(0),n=function(e){var n=e.children,r=e.runningCount;return o.createElement(t.Provider,{value:r},n)};return e&&(n.displayName=e),[n,function(){return o.useContext(t)||0}]}exports.DismissableLayer=g;var L=g;exports.Root=L;
//# sourceMappingURL=index.js.map

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

import{useDebugContext as e}from"@interop-ui/react-debug-context";import{useCallbackRef as t,useDisableBodyPointerEvents as n}from"@interop-ui/react-utils";import*as r from"react";function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){c(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}const[i,a]=O(),[l,d]=E(),[f,p]=O("TotalLayerCountWithDisabledOutsidePointerEventsProvider"),[m,v]=E("RunningLayerCountWithDisabledOutsidePointerEventsProvider");export function DismissableLayer(t){const n=e(),o=r.useRef(null);return n.disableLock?t.children({ref:o,style:{},onBlurCapture:()=>{},onFocusCapture:()=>{},onMouseDownCapture:()=>{},onTouchStartCapture:()=>{}}):r.createElement(b,s({nodeRef:o},t))}function b(e){const t=0===d(),n=r.createElement(y,e);return t?r.createElement(i,null,r.createElement(f,null,n)):n}function y(e){const{nodeRef:o,children:c,disableOutsidePointerEvents:s=!1,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:b,onInteractOutside:y,onDismiss:O}=e,E=a(),P=d()+1,w=P===E,h=p(s),C=v()+(s?1:0),g=C<h;n({disabled:s}),function(e){const n=t(e);r.useEffect((()=>{const e=e=>{"Escape"===e.key&&n(e)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)}),[n])}((e=>{w&&(null==i||i(e),e.defaultPrevented||null==O||O())}));const j=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=>{g||(null==f||f(e),null==y||y(e),e.defaultPrevented||null==O||O())})),D=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==b||b(e),null==y||y(e),e.defaultPrevented||null==O||O()})),L=h>0&&!g;return r.createElement(l,{runningCount:P},r.createElement(m,{runningCount:C},c(u(u({ref:o,style:L?{pointerEvents:"auto"}:{}},j),D))))}function O(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 E(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}]}
import{useCallbackRef as e,useDisableBodyPointerEvents as t}from"@interop-ui/react-utils";import*as n from"react";function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){u(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const[c,s]=v(),[i,l]=b(),[a,d]=v("TotalLayerCountWithDisabledOutsidePointerEventsProvider"),[f,m]=b("RunningLayerCountWithDisabledOutsidePointerEventsProvider");export function DismissableLayer(e){const t=0===l(),r=n.createElement(p,e);return t?n.createElement(c,null,n.createElement(a,null,r)):r}function p(r){const{children:u,disableOutsidePointerEvents:c=!1,onEscapeKeyDown:a,onPointerDownOutside:p,onFocusOutside:v,onInteractOutside:b,onDismiss:y}=r,E=n.useRef(null),O=s(),P=l()+1,w=P===O,C=d(c),g=m()+(c?1:0),h=g<C;t({disabled:c}),function(t){const r=e(t);n.useEffect((()=>{const e=e=>{"Escape"===e.key&&r(e)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)}),[r])}((e=>{w&&(null==a||a(e),e.defaultPrevented||null==y||y())}));const j=function(t){const r=e(t),o=n.useRef(!1);n.useEffect((()=>{const e=e=>{o.current||r(e),o.current=!1};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}}),[r]);const u=()=>{o.current=!0};return{onMouseDownCapture:u,onTouchStartCapture:u}}((e=>{h||(null==p||p(e),null==b||b(e),e.defaultPrevented||null==y||y())})),D=function(e){const t=n.useRef(0);return{onBlurCapture:n=>{n.persist(),t.current=window.setTimeout((()=>{null==e||e(n)}),0)},onFocusCapture:()=>{window.clearTimeout(t.current)}}}((e=>{null==v||v(e),null==b||b(e),e.defaultPrevented||null==y||y()})),L=C>0&&!h;return n.createElement(i,{runningCount:P},n.createElement(f,{runningCount:g},u(o(o({ref:E,style:L?{pointerEvents:"auto"}:{}},j),D))))}function v(e){const t=n.createContext({total:0,setTotal:()=>{}}),r=({children:e})=>{const[r,o]=n.useState(0),u=n.useMemo((()=>({total:r,setTotal:o})),[r,o]);return n.createElement(t.Provider,{value:u},e)};return e&&(r.displayName=e),[r,function(e=!0){const{total:r,setTotal:o}=n.useContext(t);return n.useLayoutEffect((()=>{if(e)return o((e=>e+1)),()=>o((e=>e-1))}),[e,o]),r}]}function b(e){const t=n.createContext(0),r=e=>{const{children:r,runningCount:o}=e;return n.createElement(t.Provider,{value:o},r)};return e&&(r.displayName=e),[r,function(){return n.useContext(t)||0}]}export const Root=DismissableLayer;
//# sourceMappingURL=index.module.js.map
{
"name": "@interop-ui/react-dismissable-layer",
"version": "0.0.1-4",
"version": "0.0.1-5",
"license": "MIT",

@@ -20,4 +20,3 @@ "source": "src/index.ts",

"dependencies": {
"@interop-ui/react-debug-context": "0.0.1-12",
"@interop-ui/react-utils": "0.0.1-13"
"@interop-ui/react-utils": "0.0.1-14"
},

@@ -24,0 +23,0 @@ "devDependencies": {

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