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

@radix-ui/react-focus-scope

Package Overview
Dependencies
Maintainers
6
Versions
175
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-focus-scope - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

dist/index.js

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

var e,t,n=require("@radix-ui/react-utils").useCallbackRef,u=require("@radix-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;
var e,t,n=require("@radix-ui/react-utils").useCallbackRef,u=require("@radix-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)||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"@radix-ui/react-utils";import{arrayRemove as t}from"@radix-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(),a=e(t.onMountAutoFocus),i=e(t.onUnmountAutoFocus);return n.useEffect((()=>{const e=c.current;if(e)return e.addEventListener("focusScope.autoFocusOnCreate",a),e.addEventListener("focusScope.autoFocusOnDestroy",i),s.current=o(e),()=>{e.removeEventListener("focusScope.autoFocusOnCreate",a),setTimeout((()=>{var t;null===(t=s.current)||void 0===t||t.destroy(),e.removeEventListener("focusScope.autoFocusOnDestroy",i)}),0)}}),[c,a,i]),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;
import{useCallbackRef as e}from"@radix-ui/react-utils";import{arrayRemove as t}from"@radix-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)||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(),a=e(t.onMountAutoFocus),i=e(t.onUnmountAutoFocus);return n.useEffect((()=>{const e=c.current;if(e)return e.addEventListener("focusScope.autoFocusOnCreate",a),e.addEventListener("focusScope.autoFocusOnDestroy",i),s.current=o(e),()=>{e.removeEventListener("focusScope.autoFocusOnCreate",a),setTimeout((()=>{var t;null===(t=s.current)||void 0===t||t.destroy(),e.removeEventListener("focusScope.autoFocusOnDestroy",i)}),0)}}),[c,a,i]),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": "@radix-ui/react-focus-scope",
"version": "0.0.1",
"version": "0.0.2",
"license": "MIT",

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

"dependencies": {
"@radix-ui/react-utils": "0.0.1",
"@radix-ui/utils": "0.0.1"
"@radix-ui/react-utils": "0.0.2",
"@radix-ui/utils": "0.0.2"
},
"devDependencies": {
"parcel": "^2.0.0-beta.1"
},
"peerDependencies": {

@@ -29,0 +26,0 @@ "react": "^16.8 || ^17.0"

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