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

@interop-ui/react-focus-scope

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-focus-scope - npm Package Compare versions

Comparing version 0.0.1-4 to 0.0.1-5

5

dist/index.d.ts
import * as React from "react";
export type FocusScopeProps = {
type FocusScopeProps = {
children: (args: {

@@ -22,4 +22,5 @@ ref: React.RefObject<any>;

};
export function FocusScope(props: FocusScopeProps): JSX.Element;
export function FocusScope(props: FocusScopeProps): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>;
export const Root: typeof FocusScope;
//# sourceMappingURL=index.d.ts.map

2

dist/index.js

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

var e,t,n=require("@interop-ui/react-utils").useCallbackRef,r=require("@interop-ui/react-debug-context").useDebugContext,u=require("@interop-ui/utils").arrayRemove,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 c(e){var t=document.activeElement;function n(t){if(!u.paused){var n="focusout"===t.type?t.relatedTarget:t.target;e.contains(n)||(t.stopImmediatePropagation(),a(e,n))}}var r,u={paused:!1,pause:function(){return u.paused=!0},resume:function(){return u.paused=!1},trap:function(){document.addEventListener("focusout",n,{capture:!0}),document.addEventListener("focusin",n,{capture:!0})},untrap:function(){document.removeEventListener("focusout",n,{capture:!0}),document.removeEventListener("focusin",n,{capture:!0})},destroy:function(){var n;!function(e){e.removeAttribute("tabIndex")}(e),u.untrap(),n=new Event("focusScope.autoFocusOnDestroy",{bubbles:!1,cancelable:!0}),e.dispatchEvent(n),n.defaultPrevented||i(t),f.remove(u)}};return f.add(u),function(e){e.tabIndex=-1}(e),r=new Event("focusScope.autoFocusOnCreate",{bubbles:!1,cancelable:!0}),e.dispatchEvent(r),r.defaultPrevented||a(e,null),u}function a(e,t){var n,r=function(e){return document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:function(e){return e.tabIndex>=0&&!e.disabled?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}})}(e),u=t?t.compareDocumentPosition(e):Node.DOCUMENT_POSITION_PRECEDING;if(u&Node.DOCUMENT_POSITION_PRECEDING)i(null!==(n=r.firstChild())&&void 0!==n?n:e);else if(u&Node.DOCUMENT_POSITION_FOLLOWING){var o;i(null!==(o=r.lastChild())&&void 0!==o?o:e)}}function i(e){e&&e.focus&&(e.focus({preventScroll:!0}),function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&e.select())}var s,f=(s=[],{add:function(e){var t=s[0];e!==t&&(null==t||t.pause()),(s=u(s,e)).unshift(e)},remove:function(e){var t;null===(t=(s=u(s,e))[0])||void 0===t||t.resume()},size:function(){return s.length}});function d(){return(d=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 l(e){var t=e.children,r=e.trapped,u=void 0!==r&&r,a=e.containerRef,i=o.useRef(),s=n(e.onMountAutoFocus),f=n(e.onUnmountAutoFocus);return o.useEffect((function(){var e=a.current;if(e)return e.addEventListener("focusScope.autoFocusOnCreate",s),e.addEventListener("focusScope.autoFocusOnDestroy",f),i.current=c(e),function(){e.removeEventListener("focusScope.autoFocusOnCreate",s),setTimeout((function(){var t;null===(t=i.current)||void 0===t||t.destroy(),e.removeEventListener("focusScope.autoFocusOnDestroy",f)}),0)}}),[a,s,f]),o.useEffect((function(){var e;if(u)return null===(e=i.current)||void 0===e||e.trap(),function(){var e;return null===(e=i.current)||void 0===e?void 0:e.untrap()}}),[u]),t({ref:a})}exports.FocusScope=function(e){var t=r(),n=o.useRef(null);return t.disableLock?e.children({ref:n}):o.createElement(l,d({containerRef:n},e))};
var e,t,n=require("@interop-ui/react-utils").useCallbackRef,u=require("@interop-ui/utils").arrayRemove,r=(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 o(e){var t=document.activeElement;function n(t){if(!r.paused){var n="focusout"===t.type?t.relatedTarget:t.target;e.contains(n)||(t.stopImmediatePropagation(),c(e,n))}}var u,r={paused:!1,pause:function(){return r.paused=!0},resume:function(){return r.paused=!1},trap:function(){document.addEventListener("focusout",n,{capture:!0}),document.addEventListener("focusin",n,{capture:!0})},untrap:function(){document.removeEventListener("focusout",n,{capture:!0}),document.removeEventListener("focusin",n,{capture:!0})},destroy:function(){var n;!function(e){e.removeAttribute("tabIndex")}(e),r.untrap(),n=new Event("focusScope.autoFocusOnDestroy",{bubbles:!1,cancelable:!0}),e.dispatchEvent(n),n.defaultPrevented||a(t),s.remove(r)}};return s.add(r),function(e){if(e.tabIndex>-1)return;e.tabIndex=-1}(e),u=new Event("focusScope.autoFocusOnCreate",{bubbles:!1,cancelable:!0}),e.dispatchEvent(u),u.defaultPrevented||c(e,null),r}function c(e,t){var n,u=function(e){return document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:function(e){return e.tabIndex>=0&&!e.disabled?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}})}(e),r=t?t.compareDocumentPosition(e):Node.DOCUMENT_POSITION_PRECEDING;if(r&Node.DOCUMENT_POSITION_PRECEDING)a(null!==(n=u.firstChild())&&void 0!==n?n:e);else if(r&Node.DOCUMENT_POSITION_FOLLOWING){var o;a(null!==(o=u.lastChild())&&void 0!==o?o:e)}}function a(e){e&&e.focus&&(e.focus({preventScroll:!0}),function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&e.select())}var i,s=(i=[],{add:function(e){var t=i[0];e!==t&&(null==t||t.pause()),(i=u(i,e)).unshift(e)},remove:function(e){var t;null===(t=(i=u(i,e))[0])||void 0===t||t.resume()},size:function(){return i.length}});function d(e){var t=e.children,u=e.trapped,c=void 0!==u&&u,a=r.useRef(null),i=r.useRef(),s=n(e.onMountAutoFocus),d=n(e.onUnmountAutoFocus);return r.useEffect((function(){var e=a.current;if(e)return e.addEventListener("focusScope.autoFocusOnCreate",s),e.addEventListener("focusScope.autoFocusOnDestroy",d),i.current=o(e),function(){e.removeEventListener("focusScope.autoFocusOnCreate",s),setTimeout((function(){var t;null===(t=i.current)||void 0===t||t.destroy(),e.removeEventListener("focusScope.autoFocusOnDestroy",d)}),0)}}),[a,s,d]),r.useEffect((function(){var e;if(c)return null===(e=i.current)||void 0===e||e.trap(),function(){var e;return null===(e=i.current)||void 0===e?void 0:e.untrap()}}),[c]),t({ref:a})}exports.FocusScope=d;var f=d;exports.Root=f;
//# sourceMappingURL=index.js.map

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

import{useCallbackRef as e}from"@interop-ui/react-utils";import{useDebugContext as t}from"@interop-ui/react-debug-context";import{arrayRemove as n}from"@interop-ui/utils";import*as o from"react";function r(e){const t=document.activeElement;function n(t){if(o.paused)return;const n="focusout"===t.type?t.relatedTarget:t.target;e.contains(n)||(t.stopImmediatePropagation(),u(e,n))}const o={paused:!1,pause:()=>o.paused=!0,resume:()=>o.paused=!1,trap:function(){document.addEventListener("focusout",n,{capture:!0}),document.addEventListener("focusin",n,{capture:!0})},untrap:function(){document.removeEventListener("focusout",n,{capture:!0}),document.removeEventListener("focusin",n,{capture:!0})},destroy:()=>{!function(e){e.removeAttribute("tabIndex")}(e),o.untrap(),function(){const n=new Event("focusScope.autoFocusOnDestroy",{bubbles:!1,cancelable:!0});e.dispatchEvent(n),n.defaultPrevented||c(t)}(),s.remove(o)}};return s.add(o),function(e){e.tabIndex=-1}(e),function(){const t=new Event("focusScope.autoFocusOnCreate",{bubbles:!1,cancelable:!0});e.dispatchEvent(t),t.defaultPrevented||u(e,null)}(),o}function u(e,t){const n=function(e){return document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.tabIndex>=0&&!e.disabled?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP})}(e),o=t?t.compareDocumentPosition(e):Node.DOCUMENT_POSITION_PRECEDING;var r;if(o&Node.DOCUMENT_POSITION_PRECEDING)c(null!==(r=n.firstChild())&&void 0!==r?r:e);else if(o&Node.DOCUMENT_POSITION_FOLLOWING){var u;c(null!==(u=n.lastChild())&&void 0!==u?u:e)}}function c(e){e&&e.focus&&(e.focus({preventScroll:!0}),function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&e.select())}const s=function(){let e=[];return{add(t){const o=e[0];t!==o&&(null==o||o.pause()),e=n(e,t),e.unshift(t)},remove(t){var o;e=n(e,t),null===(o=e[0])||void 0===o||o.resume()},size:()=>e.length}}();function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}export function FocusScope(e){const n=t(),r=o.useRef(null);return n.disableLock?e.children({ref:r}):o.createElement(a,i({containerRef:r},e))}function a(t){const{children:n,trapped:u=!1,containerRef:c}=t,s=o.useRef(),i=e(t.onMountAutoFocus),a=e(t.onUnmountAutoFocus);return o.useEffect((()=>{const e=c.current;if(e)return e.addEventListener("focusScope.autoFocusOnCreate",i),e.addEventListener("focusScope.autoFocusOnDestroy",a),s.current=r(e),()=>{e.removeEventListener("focusScope.autoFocusOnCreate",i),setTimeout((()=>{var t;null===(t=s.current)||void 0===t||t.destroy(),e.removeEventListener("focusScope.autoFocusOnDestroy",a)}),0)}}),[c,i,a]),o.useEffect((()=>{var e;if(u)return null===(e=s.current)||void 0===e||e.trap(),()=>{var e;return null===(e=s.current)||void 0===e?void 0:e.untrap()}}),[u]),n({ref:c})}
import{useCallbackRef as e}from"@interop-ui/react-utils";import{arrayRemove as t}from"@interop-ui/utils";import*as n from"react";function o(e){const t=document.activeElement;function n(t){if(o.paused)return;const n="focusout"===t.type?t.relatedTarget:t.target;e.contains(n)||(t.stopImmediatePropagation(),u(e,n))}const o={paused:!1,pause:()=>o.paused=!0,resume:()=>o.paused=!1,trap:function(){document.addEventListener("focusout",n,{capture:!0}),document.addEventListener("focusin",n,{capture:!0})},untrap:function(){document.removeEventListener("focusout",n,{capture:!0}),document.removeEventListener("focusin",n,{capture:!0})},destroy:()=>{!function(e){e.removeAttribute("tabIndex")}(e),o.untrap(),function(){const n=new Event("focusScope.autoFocusOnDestroy",{bubbles:!1,cancelable:!0});e.dispatchEvent(n),n.defaultPrevented||r(t)}(),c.remove(o)}};return c.add(o),function(e){if(e.tabIndex>-1)return;e.tabIndex=-1}(e),function(){const t=new Event("focusScope.autoFocusOnCreate",{bubbles:!1,cancelable:!0});e.dispatchEvent(t),t.defaultPrevented||u(e,null)}(),o}function u(e,t){const n=function(e){return document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.tabIndex>=0&&!e.disabled?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP})}(e),o=t?t.compareDocumentPosition(e):Node.DOCUMENT_POSITION_PRECEDING;var u;if(o&Node.DOCUMENT_POSITION_PRECEDING)r(null!==(u=n.firstChild())&&void 0!==u?u:e);else if(o&Node.DOCUMENT_POSITION_FOLLOWING){var c;r(null!==(c=n.lastChild())&&void 0!==c?c:e)}}function r(e){e&&e.focus&&(e.focus({preventScroll:!0}),function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&e.select())}const c=function(){let e=[];return{add(n){const o=e[0];n!==o&&(null==o||o.pause()),e=t(e,n),e.unshift(n)},remove(n){var o;e=t(e,n),null===(o=e[0])||void 0===o||o.resume()},size:()=>e.length}}();export function FocusScope(t){const{children:u,trapped:r=!1}=t,c=n.useRef(null),s=n.useRef(),i=e(t.onMountAutoFocus),a=e(t.onUnmountAutoFocus);return n.useEffect((()=>{const e=c.current;if(e)return e.addEventListener("focusScope.autoFocusOnCreate",i),e.addEventListener("focusScope.autoFocusOnDestroy",a),s.current=o(e),()=>{e.removeEventListener("focusScope.autoFocusOnCreate",i),setTimeout((()=>{var t;null===(t=s.current)||void 0===t||t.destroy(),e.removeEventListener("focusScope.autoFocusOnDestroy",a)}),0)}}),[c,i,a]),n.useEffect((()=>{var e;if(r)return null===(e=s.current)||void 0===e||e.trap(),()=>{var e;return null===(e=s.current)||void 0===e?void 0:e.untrap()}}),[r]),u({ref:c})}export const Root=FocusScope;
//# sourceMappingURL=index.module.js.map
{
"name": "@interop-ui/react-focus-scope",
"version": "0.0.1-4",
"version": "0.0.1-5",
"license": "MIT",

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

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

@@ -25,0 +24,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