Socket
Socket
Sign inDemoInstall

@radix-ui/react-focus-scope

Package Overview
Dependencies
Maintainers
5
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.9 to 0.0.10

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-callback-ref").useCallbackRef,n=require("react"),o=n.useRef,u=n.useEffect,r={};function c(e){const t=document.activeElement;function n(t){if(o.paused)return;const n="focusout"===t.type?t.relatedTarget:t.target;e.contains(n)||s(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||i(t)}(),a.remove(o)}};return a.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||s(e,null)}(),o}function s(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)i(null!==(u=n.firstChild())&&void 0!==u?u:e);else if(o&Node.DOCUMENT_POSITION_FOLLOWING){var r;i(null!==(r=n.lastChild())&&void 0!==r?r:e)}}function i(e){e&&e.focus&&(e.focus({preventScroll:!0}),function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&e.select())}const a=function(){let e=[];return{add:function(t){const n=e[0];t!==n&&(null==n||n.pause()),e=d(e,t),e.unshift(t)},remove:function(t){var n;e=d(e,t),null===(n=e[0])||void 0===n||n.resume()},size:function(){return e.length}}}();function d(e,t){const n=[...e],o=n.indexOf(t);return-1!==o&&n.splice(o,1),n}function f(e){const{children:n,trapped:r=!1}=e,s=o(null),i=o(),a=t(e.onMountAutoFocus),d=t(e.onUnmountAutoFocus);return u((()=>{const e=s.current;if(e)return e.addEventListener("focusScope.autoFocusOnCreate",a),e.addEventListener("focusScope.autoFocusOnDestroy",d),i.current=c(e),()=>{e.removeEventListener("focusScope.autoFocusOnCreate",a),setTimeout((()=>{var t;null===(t=i.current)||void 0===t||t.destroy(),e.removeEventListener("focusScope.autoFocusOnDestroy",d)}),0)}}),[s,a,d]),u((()=>{var e;if(r)return null===(e=i.current)||void 0===e||e.trap(),()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.untrap()}}),[r]),n({ref:s})}exports.FocusScope=f;const l=f;exports.Root=l,e(r,"Root",(function(){return l})),e(r,"FocusScope",(function(){return f}));
var e,t,n=require("@radix-ui/react-use-callback-ref").useCallbackRef,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 u(e){const t=document.activeElement;function n(t){if(o.paused)return;const n="focusout"===t.type?t.relatedTarget:t.target;e.contains(n)||r(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){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||r(e,null)}(),o}function r(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)c(null!==(u=n.firstChild())&&void 0!==u?u:e);else if(o&Node.DOCUMENT_POSITION_FOLLOWING){var r;c(null!==(r=n.lastChild())&&void 0!==r?r: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 n=e[0];t!==n&&(null==n||n.pause()),e=a(e,t),e.unshift(t)},remove(t){var n;e=a(e,t),null===(n=e[0])||void 0===n||n.resume()},size:()=>e.length}}();function a(e,t){const n=[...e],o=n.indexOf(t);return-1!==o&&n.splice(o,1),n}function i(e){const{children:t,trapped:r=!1}=e,c=o.useRef(null),s=o.useRef(),a=n(e.onMountAutoFocus),i=n(e.onUnmountAutoFocus);return o.useEffect((()=>{const e=c.current;if(e)return e.addEventListener("focusScope.autoFocusOnCreate",a),e.addEventListener("focusScope.autoFocusOnDestroy",i),s.current=u(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]),o.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]),t({ref:c})}exports.FocusScope=i;const d=i;exports.Root=d;
//# sourceMappingURL=index.js.map

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

function e(e,t,n){Object.defineProperty(e,t,{get:n,enumerable:!0})}import{useCallbackRef as t}from"@radix-ui/react-use-callback-ref";import{useRef as n,useEffect as o}from"react";var u={};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)||c(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||s(t)}(),i.remove(o)}};return i.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||c(e,null)}(),o}function c(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)s(null!==(u=n.firstChild())&&void 0!==u?u:e);else if(o&Node.DOCUMENT_POSITION_FOLLOWING){var r;s(null!==(r=n.lastChild())&&void 0!==r?r:e)}}function s(e){e&&e.focus&&(e.focus({preventScroll:!0}),function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&e.select())}const i=function(){let e=[];return{add:function(t){const n=e[0];t!==n&&(null==n||n.pause()),e=a(e,t),e.unshift(t)},remove:function(t){var n;e=a(e,t),null===(n=e[0])||void 0===n||n.resume()},size:function(){return e.length}}}();function a(e,t){const n=[...e],o=n.indexOf(t);return-1!==o&&n.splice(o,1),n}function d(e){const{children:u,trapped:c=!1}=e,s=n(null),i=n(),a=t(e.onMountAutoFocus),d=t(e.onUnmountAutoFocus);return o((()=>{const e=s.current;if(e)return e.addEventListener("focusScope.autoFocusOnCreate",a),e.addEventListener("focusScope.autoFocusOnDestroy",d),i.current=r(e),()=>{e.removeEventListener("focusScope.autoFocusOnCreate",a),setTimeout((()=>{var t;null===(t=i.current)||void 0===t||t.destroy(),e.removeEventListener("focusScope.autoFocusOnDestroy",d)}),0)}}),[s,a,d]),o((()=>{var e;if(c)return null===(e=i.current)||void 0===e||e.trap(),()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.untrap()}}),[c]),u({ref:s})}export{d as FocusScope};export const Root=d;e(u,"Root",(function(){return Root})),e(u,"FocusScope",(function(){return d}));
import{useCallbackRef as e}from"@radix-ui/react-use-callback-ref";import*as t from"react";function n(e){const t=document.activeElement;function n(t){if(c.paused)return;const n="focusout"===t.type?t.relatedTarget:t.target;e.contains(n)||o(e,n)}const c={paused:!1,pause:()=>c.paused=!0,resume:()=>c.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),c.untrap(),function(){const n=new Event("focusScope.autoFocusOnDestroy",{bubbles:!1,cancelable:!0});e.dispatchEvent(n),n.defaultPrevented||u(t)}(),r.remove(c)}};return r.add(c),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||o(e,null)}(),c}function o(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)u(null!==(r=n.firstChild())&&void 0!==r?r:e);else if(o&Node.DOCUMENT_POSITION_FOLLOWING){var c;u(null!==(c=n.lastChild())&&void 0!==c?c:e)}}function u(e){e&&e.focus&&(e.focus({preventScroll:!0}),function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&e.select())}const r=function(){let e=[];return{add(t){const n=e[0];t!==n&&(null==n||n.pause()),e=c(e,t),e.unshift(t)},remove(t){var n;e=c(e,t),null===(n=e[0])||void 0===n||n.resume()},size:()=>e.length}}();function c(e,t){const n=[...e],o=n.indexOf(t);return-1!==o&&n.splice(o,1),n}export function FocusScope(o){const{children:u,trapped:r=!1}=o,c=t.useRef(null),s=t.useRef(),a=e(o.onMountAutoFocus),i=e(o.onUnmountAutoFocus);return t.useEffect((()=>{const e=c.current;if(e)return e.addEventListener("focusScope.autoFocusOnCreate",a),e.addEventListener("focusScope.autoFocusOnDestroy",i),s.current=n(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]),t.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.9",
"version": "0.0.10",
"license": "MIT",

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

"@babel/runtime": "^7.13.10",
"@radix-ui/react-use-callback-ref": "0.0.3"
"@radix-ui/react-use-callback-ref": "0.0.4"
},

@@ -24,0 +24,0 @@ "peerDependencies": {

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