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.7 to 0.0.8

2

dist/index.js

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

function e(e){return e&&e.__esModule?e.default:e}function t(e,t,n){Object.defineProperty(e,t,{get:n,enumerable:!0})}var n=require("@radix-ui/react-use-callback-ref").useCallbackRef,r=e(require("@babel/runtime-corejs3/core-js-stable/instance/splice")),u=e(require("@babel/runtime-corejs3/core-js-stable/instance/index-of")),o=e(require("@babel/runtime-corejs3/helpers/toConsumableArray")),c=require("react"),a=c.useRef,i=c.useEffect,s=e(require("@babel/runtime-corejs3/core-js-stable/set-timeout")),l={};function d(e){var t=document.activeElement;function n(t){if(!u.paused){var n="focusout"===t.type?t.relatedTarget:t.target;e.contains(n)||f(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||v(t),b.remove(u)}};return b.add(u),function(e){if(e.tabIndex>-1)return;e.tabIndex=-1}(e),r=new Event("focusScope.autoFocusOnCreate",{bubbles:!1,cancelable:!0}),e.dispatchEvent(r),r.defaultPrevented||f(e,null),u}function f(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)v(null!==(n=r.firstChild())&&void 0!==n?n:e);else if(u&Node.DOCUMENT_POSITION_FOLLOWING){var o;v(null!==(o=r.lastChild())&&void 0!==o?o:e)}}function v(e){e&&e.focus&&(e.focus({preventScroll:!0}),function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&e.select())}var p,b=(p=[],{add:function(e){var t=p[0];e!==t&&(null==t||t.pause()),(p=E(p,e)).unshift(e)},remove:function(e){var t;null===(t=(p=E(p,e))[0])||void 0===t||t.resume()},size:function(){return p.length}});function E(e,t){var n=o(e),c=u(n).call(n,t);return-1!==c&&r(n).call(n,c,1),n}function m(e){var t=e.children,r=e.trapped,u=void 0!==r&&r,o=a(null),c=a(),l=n(e.onMountAutoFocus),f=n(e.onUnmountAutoFocus);return i((function(){var e=o.current;if(e)return e.addEventListener("focusScope.autoFocusOnCreate",l),e.addEventListener("focusScope.autoFocusOnDestroy",f),c.current=d(e),function(){e.removeEventListener("focusScope.autoFocusOnCreate",l),s((function(){var t;null===(t=c.current)||void 0===t||t.destroy(),e.removeEventListener("focusScope.autoFocusOnDestroy",f)}),0)}}),[o,l,f]),i((function(){var e;if(u)return null===(e=c.current)||void 0===e||e.trap(),function(){var e;return null===(e=c.current)||void 0===e?void 0:e.untrap()}}),[u]),t({ref:o})}exports.FocusScope=m;var O=m;exports.Root=O,t(l,"Root",(function(){return O})),t(l,"FocusScope",(function(){return m}));
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}));
//# 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 n from"@babel/runtime-corejs3/core-js-stable/instance/splice";import r from"@babel/runtime-corejs3/core-js-stable/instance/index-of";import o from"@babel/runtime-corejs3/helpers/esm/toConsumableArray";import{useRef as u,useEffect as c}from"react";import a from"@babel/runtime-corejs3/core-js-stable/set-timeout";var i={};function s(e){var t=document.activeElement;function n(t){if(!o.paused){var n="focusout"===t.type?t.relatedTarget:t.target;e.contains(n)||f(e,n)}}var r,o={paused:!1,pause:function(){return o.paused=!0},resume:function(){return 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(){var n;!function(e){e.removeAttribute("tabIndex")}(e),o.untrap(),n=new Event("focusScope.autoFocusOnDestroy",{bubbles:!1,cancelable:!0}),e.dispatchEvent(n),n.defaultPrevented||l(t),v.remove(o)}};return v.add(o),function(e){if(e.tabIndex>-1)return;e.tabIndex=-1}(e),r=new Event("focusScope.autoFocusOnCreate",{bubbles:!1,cancelable:!0}),e.dispatchEvent(r),r.defaultPrevented||f(e,null),o}function f(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),o=t?t.compareDocumentPosition(e):Node.DOCUMENT_POSITION_PRECEDING;if(o&Node.DOCUMENT_POSITION_PRECEDING)l(null!==(n=r.firstChild())&&void 0!==n?n:e);else if(o&Node.DOCUMENT_POSITION_FOLLOWING){var u;l(null!==(u=r.lastChild())&&void 0!==u?u:e)}}function l(e){e&&e.focus&&(e.focus({preventScroll:!0}),function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&e.select())}var d,v=(d=[],{add:function(e){var t=d[0];e!==t&&(null==t||t.pause()),(d=p(d,e)).unshift(e)},remove:function(e){var t;null===(t=(d=p(d,e))[0])||void 0===t||t.resume()},size:function(){return d.length}});function p(e,t){var u=o(e),c=r(u).call(u,t);return-1!==c&&n(u).call(u,c,1),u}function m(e){var n=e.children,r=e.trapped,o=void 0!==r&&r,i=u(null),f=u(),l=t(e.onMountAutoFocus),d=t(e.onUnmountAutoFocus);return c((function(){var e=i.current;if(e)return e.addEventListener("focusScope.autoFocusOnCreate",l),e.addEventListener("focusScope.autoFocusOnDestroy",d),f.current=s(e),function(){e.removeEventListener("focusScope.autoFocusOnCreate",l),a((function(){var t;null===(t=f.current)||void 0===t||t.destroy(),e.removeEventListener("focusScope.autoFocusOnDestroy",d)}),0)}}),[i,l,d]),c((function(){var e;if(o)return null===(e=f.current)||void 0===e||e.trap(),function(){var e;return null===(e=f.current)||void 0===e?void 0:e.untrap()}}),[o]),n({ref:i})}export{m as FocusScope};export var Root=m;e(i,"Root",(function(){return Root})),e(i,"FocusScope",(function(){return m}));
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}));
//# sourceMappingURL=index.module.js.map
{
"name": "@radix-ui/react-focus-scope",
"version": "0.0.7",
"version": "0.0.8",
"license": "MIT",

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

"dependencies": {
"@babel/runtime-corejs3": "^7.13.10",
"@babel/runtime": "^7.13.10",
"@radix-ui/react-use-callback-ref": "0.0.2"

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