123456789101112131415161718192021222324252627282930313233343536373839 |
- import {useEffect as $1wErz$useEffect} from "react";
- /** Number of components which have requested interest to have focus guards */ let $3db38b7d1fb3fe6a$var$count = 0;
- function $3db38b7d1fb3fe6a$export$ac5b58043b79449b(props) {
- $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c();
- return props.children;
- }
- /**
- * Injects a pair of focus guards at the edges of the whole DOM tree
- * to ensure `focusin` & `focusout` events can be caught consistently.
- */ function $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c() {
- $1wErz$useEffect(()=>{
- var _edgeGuards$, _edgeGuards$2;
- const edgeGuards = document.querySelectorAll('[data-radix-focus-guard]');
- document.body.insertAdjacentElement('afterbegin', (_edgeGuards$ = edgeGuards[0]) !== null && _edgeGuards$ !== void 0 ? _edgeGuards$ : $3db38b7d1fb3fe6a$var$createFocusGuard());
- document.body.insertAdjacentElement('beforeend', (_edgeGuards$2 = edgeGuards[1]) !== null && _edgeGuards$2 !== void 0 ? _edgeGuards$2 : $3db38b7d1fb3fe6a$var$createFocusGuard());
- $3db38b7d1fb3fe6a$var$count++;
- return ()=>{
- if ($3db38b7d1fb3fe6a$var$count === 1) document.querySelectorAll('[data-radix-focus-guard]').forEach((node)=>node.remove()
- );
- $3db38b7d1fb3fe6a$var$count--;
- };
- }, []);
- }
- function $3db38b7d1fb3fe6a$var$createFocusGuard() {
- const element = document.createElement('span');
- element.setAttribute('data-radix-focus-guard', '');
- element.tabIndex = 0;
- element.style.cssText = 'outline: none; opacity: 0; position: fixed; pointer-events: none';
- return element;
- }
- const $3db38b7d1fb3fe6a$export$be92b6f5f03c0fe9 = $3db38b7d1fb3fe6a$export$ac5b58043b79449b;
- export {$3db38b7d1fb3fe6a$export$ac5b58043b79449b as FocusGuards, $3db38b7d1fb3fe6a$export$be92b6f5f03c0fe9 as Root, $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c as useFocusGuards};
- //# sourceMappingURL=index.mjs.map
|