@radix-ui/react-focus-guards 0.1.1-rc.1 → 0.1.1-rc.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"mappings":"AAKA,4BAAqB,KAAK,EAAE,GAAG,OAG9B;AAED;A;A;GAGG;AACH,uCAcC;AAUD,OAAA,MAAM,wBAAkB,CAAC","sources":["./packages/react/focus-guards/src/packages/react/focus-guards/src/FocusGuards.tsx","./packages/react/focus-guards/src/packages/react/focus-guards/src/index.ts"],"sourcesContent":[null,null],"names":[],"version":3,"file":"index.d.ts.map"}
1
+ {"mappings":"AAKA,4BAAqB,KAAK,EAAE,GAAG,OAG9B;AAED;;;GAGG;AACH,uCAcC;AAUD,OAAA,MAAM,wBAAkB,CAAC","sources":["packages/react/focus-guards/src/packages/react/focus-guards/src/FocusGuards.tsx","packages/react/focus-guards/src/packages/react/focus-guards/src/index.ts","packages/react/focus-guards/src/index.ts"],"sourcesContent":[null,null,"export * from './FocusGuards';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
package/dist/index.js CHANGED
@@ -1,2 +1,63 @@
1
- var e,t,n=(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);let o=0;function r(e){return u(),e.children}function u(){n.useEffect((()=>{var e,t;const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",null!==(e=n[0])&&void 0!==e?e:c()),document.body.insertAdjacentElement("beforeend",null!==(t=n[1])&&void 0!==t?t:c()),o++,()=>{1===o&&document.querySelectorAll("[data-radix-focus-guard]").forEach((e=>e.remove())),o--}}),[])}function c(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",e}exports.FocusGuards=r,exports.useFocusGuards=u;const d=r;exports.Root=d;
1
+ var $cnctE$react = require("react");
2
+
3
+ function $parcel$exportWildcard(dest, source) {
4
+ Object.keys(source).forEach(function(key) {
5
+ if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
6
+ return;
7
+ }
8
+
9
+ Object.defineProperty(dest, key, {
10
+ enumerable: true,
11
+ get: function get() {
12
+ return source[key];
13
+ }
14
+ });
15
+ });
16
+
17
+ return dest;
18
+ }
19
+ function $parcel$export(e, n, v, s) {
20
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
21
+ }
22
+ var $71476a6ed7dbbaf3$exports = {};
23
+
24
+ $parcel$export($71476a6ed7dbbaf3$exports, "FocusGuards", () => $71476a6ed7dbbaf3$export$ac5b58043b79449b);
25
+ $parcel$export($71476a6ed7dbbaf3$exports, "useFocusGuards", () => $71476a6ed7dbbaf3$export$b7ece24a22aeda8c);
26
+ $parcel$export($71476a6ed7dbbaf3$exports, "Root", () => $71476a6ed7dbbaf3$export$be92b6f5f03c0fe9);
27
+
28
+ /** Number of components which have requested interest to have focus guards */ let $71476a6ed7dbbaf3$var$count = 0;
29
+ function $71476a6ed7dbbaf3$export$ac5b58043b79449b(props) {
30
+ $71476a6ed7dbbaf3$export$b7ece24a22aeda8c();
31
+ return props.children;
32
+ }
33
+ /**
34
+ * Injects a pair of focus guards at the edges of the whole DOM tree
35
+ * to ensure `focusin` & `focusout` events can be caught consistently.
36
+ */ function $71476a6ed7dbbaf3$export$b7ece24a22aeda8c() {
37
+ $cnctE$react.useEffect(()=>{
38
+ var _edgeGuards$, _edgeGuards$2;
39
+ const edgeGuards = document.querySelectorAll('[data-radix-focus-guard]');
40
+ document.body.insertAdjacentElement('afterbegin', (_edgeGuards$ = edgeGuards[0]) !== null && _edgeGuards$ !== void 0 ? _edgeGuards$ : $71476a6ed7dbbaf3$var$createFocusGuard());
41
+ document.body.insertAdjacentElement('beforeend', (_edgeGuards$2 = edgeGuards[1]) !== null && _edgeGuards$2 !== void 0 ? _edgeGuards$2 : $71476a6ed7dbbaf3$var$createFocusGuard());
42
+ $71476a6ed7dbbaf3$var$count++;
43
+ return ()=>{
44
+ if ($71476a6ed7dbbaf3$var$count === 1) document.querySelectorAll('[data-radix-focus-guard]').forEach((node)=>node.remove()
45
+ );
46
+ $71476a6ed7dbbaf3$var$count--;
47
+ };
48
+ }, []);
49
+ }
50
+ function $71476a6ed7dbbaf3$var$createFocusGuard() {
51
+ const element = document.createElement('span');
52
+ element.setAttribute('data-radix-focus-guard', '');
53
+ element.tabIndex = 0;
54
+ element.style.cssText = 'outline: none; opacity: 0; position: fixed; pointer-events: none';
55
+ return element;
56
+ }
57
+ const $71476a6ed7dbbaf3$export$be92b6f5f03c0fe9 = $71476a6ed7dbbaf3$export$ac5b58043b79449b;
58
+
59
+
60
+ $parcel$exportWildcard(module.exports, $71476a6ed7dbbaf3$exports);
61
+
62
+
2
63
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":"IAYgCA,EAAMC,KAAND,KAAMC,mBACpCC,OAAOC,KAAKF,GAAQG,SAAQ,SAASC,GACvB,YAARA,GAA6B,eAARA,GAIzBH,OAAOI,eAAeN,EAAMK,EAAK,CAC/BE,YAAY,EACZC,IAAK,WACH,OAAOP,EAAOI,SAKbL,GCvBT,IAAIS,EAAQ,EAEZ,SAASC,EAAYC,GAEnB,OADAC,IACOD,EAAME,SAOf,SAASD,IACPE,EAAMC,WAAU,KAAM,IAAAC,EAAAC,EACpB,MAAMC,EAAaC,SAASC,iBAAiB,4BAK7C,OAJAD,SAASE,KAAKC,sBAAsB,aAApC,QAAAN,EAAkDE,EAAW,UAA7D,IAAAF,EAAAA,EAAmEO,KACnEJ,SAASE,KAAKC,sBAAsB,YAApC,QAAAL,EAAiDC,EAAW,UAA5D,IAAAD,EAAAA,EAAkEM,KAClEd,IAEO,KACS,IAAVA,GACFU,SAASC,iBAAiB,4BAA4BhB,SAASoB,GAASA,EAAKC,WAE/EhB,OAED,IAGL,SAASc,IACP,MAAMG,EAAUP,SAASQ,cAAc,QAIvC,OAHAD,EAAQE,aAAa,yBAA0B,IAC/CF,EAAQG,SAAW,EACnBH,EAAQI,MAAMC,QAAU,mEACjBL,iDAGT,MAAMM,EAAOtB","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/react/focus-guards/src/FocusGuards.tsx"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$reexport(e, n, v) {\n Object.defineProperty(e, n, {get: v, enumerable: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","import * as React from 'react';\n\n/** Number of components which have requested interest to have focus guards */\nlet count = 0;\n\nfunction FocusGuards(props: any) {\n useFocusGuards();\n return props.children;\n}\n\n/**\n * Injects a pair of focus guards at the edges of the whole DOM tree\n * to ensure `focusin` & `focusout` events can be caught consistently.\n */\nfunction useFocusGuards() {\n React.useEffect(() => {\n const edgeGuards = document.querySelectorAll('[data-radix-focus-guard]');\n document.body.insertAdjacentElement('afterbegin', edgeGuards[0] ?? createFocusGuard());\n document.body.insertAdjacentElement('beforeend', edgeGuards[1] ?? createFocusGuard());\n count++;\n\n return () => {\n if (count === 1) {\n document.querySelectorAll('[data-radix-focus-guard]').forEach((node) => node.remove());\n }\n count--;\n };\n }, []);\n}\n\nfunction createFocusGuard() {\n const element = document.createElement('span');\n element.setAttribute('data-radix-focus-guard', '');\n element.tabIndex = 0;\n element.style.cssText = 'outline: none; opacity: 0; position: fixed; pointer-events: none';\n return element;\n}\n\nconst Root = FocusGuards;\n\nexport {\n FocusGuards,\n //\n Root,\n //\n useFocusGuards,\n};\n"],"names":["dest","source","Object","keys","forEach","key","defineProperty","enumerable","get","count","FocusGuards","props","useFocusGuards","children","React","useEffect","_edgeGuards$","_edgeGuards$2","edgeGuards","document","querySelectorAll","body","insertAdjacentElement","createFocusGuard","node","remove","element","createElement","setAttribute","tabIndex","style","cssText","Root"],"version":3,"file":"index.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;ACAA;AAEA,8EAAA,CACA,IAAIC,2BAAK,GAAG,CAAZ,AAAA;AAEA,SAASC,yCAAT,CAAqBC,KAArB,EAAiC;IAC/BC,yCAAc,EAAdA,CAAAA;IACA,OAAOD,KAAK,CAACE,QAAb,CAAA;CACD;AAED;;;GAGA,CACA,SAASD,yCAAT,GAA0B;IACxBJ,sBAAA,CAAgB,IAAM;QAAA,IAAA,YAAA,EAAA,aAAA,AAAA;QACpB,MAAMO,UAAU,GAAGC,QAAQ,CAACC,gBAAT,CAA0B,0BAA1B,CAAnB,AAAA;QACAD,QAAQ,CAACE,IAAT,CAAcC,qBAAd,CAAoC,YAApC,EAAA,AAAA,CAAA,YAAA,GAAkDJ,UAAU,CAAC,CAAD,CAA5D,CAAA,KAAA,IAAA,IAAA,YAAA,KAAA,KAAA,CAAA,GAAA,YAAA,GAAmEK,sCAAgB,EAAnF,CAAAJ,CAAAA;QACAA,QAAQ,CAACE,IAAT,CAAcC,qBAAd,CAAoC,WAApC,EAAA,AAAA,CAAA,aAAA,GAAiDJ,UAAU,CAAC,CAAD,CAA3D,CAAA,KAAA,IAAA,IAAA,aAAA,KAAA,KAAA,CAAA,GAAA,aAAA,GAAkEK,sCAAgB,EAAlF,CAAAJ,CAAAA;QACAP,2BAAK,EAALA,CAAAA;QAEA,OAAO,IAAM;YACX,IAAIA,2BAAK,KAAK,CAAd,EACEO,QAAQ,CAACC,gBAAT,CAA0B,0BAA1B,CAAA,CAAsDI,OAAtD,CAA+DC,CAAAA,IAAD,GAAUA,IAAI,CAACC,MAAL,EAAxE;YAAA,CAAAP,CAAAA;YAEFP,2BAAK,EAALA,CAAAA;SAJF,CAKC;KAXH,EAYG,EAZH,CAYC,CAAA;CACF;AAED,SAASW,sCAAT,GAA4B;IAC1B,MAAMI,OAAO,GAAGR,QAAQ,CAACS,aAAT,CAAuB,MAAvB,CAAhB,AAAA;IACAD,OAAO,CAACE,YAAR,CAAqB,wBAArB,EAA+C,EAA/C,CAAAF,CAAAA;IACAA,OAAO,CAACG,QAAR,GAAmB,CAAnB,CAAAH;IACAA,OAAO,CAACI,KAAR,CAAcC,OAAd,GAAwB,kEAAxB,CAAAL;IACA,OAAOA,OAAP,CAAA;CACD;AAED,MAAMM,yCAAI,GAAGpB,yCAAb,AAAA;;ADtCA","sources":["packages/react/focus-guards/src/index.ts","packages/react/focus-guards/src/FocusGuards.tsx"],"sourcesContent":["export * from './FocusGuards';\n","import * as React from 'react';\n\n/** Number of components which have requested interest to have focus guards */\nlet count = 0;\n\nfunction FocusGuards(props: any) {\n useFocusGuards();\n return props.children;\n}\n\n/**\n * Injects a pair of focus guards at the edges of the whole DOM tree\n * to ensure `focusin` & `focusout` events can be caught consistently.\n */\nfunction useFocusGuards() {\n React.useEffect(() => {\n const edgeGuards = document.querySelectorAll('[data-radix-focus-guard]');\n document.body.insertAdjacentElement('afterbegin', edgeGuards[0] ?? createFocusGuard());\n document.body.insertAdjacentElement('beforeend', edgeGuards[1] ?? createFocusGuard());\n count++;\n\n return () => {\n if (count === 1) {\n document.querySelectorAll('[data-radix-focus-guard]').forEach((node) => node.remove());\n }\n count--;\n };\n }, []);\n}\n\nfunction createFocusGuard() {\n const element = document.createElement('span');\n element.setAttribute('data-radix-focus-guard', '');\n element.tabIndex = 0;\n element.style.cssText = 'outline: none; opacity: 0; position: fixed; pointer-events: none';\n return element;\n}\n\nconst Root = FocusGuards;\n\nexport {\n FocusGuards,\n //\n Root,\n //\n useFocusGuards,\n};\n"],"names":["React","count","FocusGuards","props","useFocusGuards","children","useEffect","edgeGuards","document","querySelectorAll","body","insertAdjacentElement","createFocusGuard","forEach","node","remove","element","createElement","setAttribute","tabIndex","style","cssText","Root"],"version":3,"file":"index.js.map"}
@@ -1,2 +1,47 @@
1
- import*as e from"react";let t=0;export function FocusGuards(e){return useFocusGuards(),e.children}export function useFocusGuards(){e.useEffect((()=>{var e,n;const r=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",null!==(e=r[0])&&void 0!==e?e:o()),document.body.insertAdjacentElement("beforeend",null!==(n=r[1])&&void 0!==n?n:o()),t++,()=>{1===t&&document.querySelectorAll("[data-radix-focus-guard]").forEach((e=>e.remove())),t--}}),[])}function o(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",e}export const Root=FocusGuards;
1
+ import {useEffect as $1wErz$useEffect} from "react";
2
+
3
+ function $parcel$export(e, n, v, s) {
4
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
5
+ }
6
+ var $3db38b7d1fb3fe6a$exports = {};
7
+
8
+ $parcel$export($3db38b7d1fb3fe6a$exports, "FocusGuards", () => $3db38b7d1fb3fe6a$export$ac5b58043b79449b);
9
+ $parcel$export($3db38b7d1fb3fe6a$exports, "useFocusGuards", () => $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c);
10
+ $parcel$export($3db38b7d1fb3fe6a$exports, "Root", () => $3db38b7d1fb3fe6a$export$be92b6f5f03c0fe9);
11
+
12
+ /** Number of components which have requested interest to have focus guards */ let $3db38b7d1fb3fe6a$var$count = 0;
13
+ function $3db38b7d1fb3fe6a$export$ac5b58043b79449b(props) {
14
+ $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c();
15
+ return props.children;
16
+ }
17
+ /**
18
+ * Injects a pair of focus guards at the edges of the whole DOM tree
19
+ * to ensure `focusin` & `focusout` events can be caught consistently.
20
+ */ function $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c() {
21
+ $1wErz$useEffect(()=>{
22
+ var _edgeGuards$, _edgeGuards$2;
23
+ const edgeGuards = document.querySelectorAll('[data-radix-focus-guard]');
24
+ document.body.insertAdjacentElement('afterbegin', (_edgeGuards$ = edgeGuards[0]) !== null && _edgeGuards$ !== void 0 ? _edgeGuards$ : $3db38b7d1fb3fe6a$var$createFocusGuard());
25
+ document.body.insertAdjacentElement('beforeend', (_edgeGuards$2 = edgeGuards[1]) !== null && _edgeGuards$2 !== void 0 ? _edgeGuards$2 : $3db38b7d1fb3fe6a$var$createFocusGuard());
26
+ $3db38b7d1fb3fe6a$var$count++;
27
+ return ()=>{
28
+ if ($3db38b7d1fb3fe6a$var$count === 1) document.querySelectorAll('[data-radix-focus-guard]').forEach((node)=>node.remove()
29
+ );
30
+ $3db38b7d1fb3fe6a$var$count--;
31
+ };
32
+ }, []);
33
+ }
34
+ function $3db38b7d1fb3fe6a$var$createFocusGuard() {
35
+ const element = document.createElement('span');
36
+ element.setAttribute('data-radix-focus-guard', '');
37
+ element.tabIndex = 0;
38
+ element.style.cssText = 'outline: none; opacity: 0; position: fixed; pointer-events: none';
39
+ return element;
40
+ }
41
+ const $3db38b7d1fb3fe6a$export$be92b6f5f03c0fe9 = $3db38b7d1fb3fe6a$export$ac5b58043b79449b;
42
+
43
+
44
+
45
+
46
+ export {$3db38b7d1fb3fe6a$export$ac5b58043b79449b as FocusGuards, $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c as useFocusGuards, $3db38b7d1fb3fe6a$export$be92b6f5f03c0fe9 as Root};
2
47
  //# sourceMappingURL=index.module.js.map
@@ -1 +1 @@
1
- {"mappings":"wBAGA,IAAIA,EAAQ,SAEZ,SAASC,YAAYC,GAEnB,OADAC,iBACOD,EAAME,gBAOf,SAASD,iBACPE,EAAMC,WAAU,KAAM,IAAAC,EAAAC,EACpB,MAAMC,EAAaC,SAASC,iBAAiB,4BAK7C,OAJAD,SAASE,KAAKC,sBAAsB,aAApC,QAAAN,EAAkDE,EAAW,UAA7D,IAAAF,EAAAA,EAAmEO,KACnEJ,SAASE,KAAKC,sBAAsB,YAApC,QAAAL,EAAiDC,EAAW,UAA5D,IAAAD,EAAAA,EAAkEM,KAClEd,IAEO,KACS,IAAVA,GACFU,SAASC,iBAAiB,4BAA4BI,SAASC,GAASA,EAAKC,WAE/EjB,OAED,IAGL,SAASc,IACP,MAAMI,EAAUR,SAASS,cAAc,QAIvC,OAHAD,EAAQE,aAAa,yBAA0B,IAC/CF,EAAQG,SAAW,EACnBH,EAAQI,MAAMC,QAAU,mEACjBL,SAGT,MAAMM,KAAOvB","sources":["./packages/react/focus-guards/src/FocusGuards.tsx"],"sourcesContent":["import * as React from 'react';\n\n/** Number of components which have requested interest to have focus guards */\nlet count = 0;\n\nfunction FocusGuards(props: any) {\n useFocusGuards();\n return props.children;\n}\n\n/**\n * Injects a pair of focus guards at the edges of the whole DOM tree\n * to ensure `focusin` & `focusout` events can be caught consistently.\n */\nfunction useFocusGuards() {\n React.useEffect(() => {\n const edgeGuards = document.querySelectorAll('[data-radix-focus-guard]');\n document.body.insertAdjacentElement('afterbegin', edgeGuards[0] ?? createFocusGuard());\n document.body.insertAdjacentElement('beforeend', edgeGuards[1] ?? createFocusGuard());\n count++;\n\n return () => {\n if (count === 1) {\n document.querySelectorAll('[data-radix-focus-guard]').forEach((node) => node.remove());\n }\n count--;\n };\n }, []);\n}\n\nfunction createFocusGuard() {\n const element = document.createElement('span');\n element.setAttribute('data-radix-focus-guard', '');\n element.tabIndex = 0;\n element.style.cssText = 'outline: none; opacity: 0; position: fixed; pointer-events: none';\n return element;\n}\n\nconst Root = FocusGuards;\n\nexport {\n FocusGuards,\n //\n Root,\n //\n useFocusGuards,\n};\n"],"names":["count","FocusGuards","props","useFocusGuards","children","React","useEffect","_edgeGuards$","_edgeGuards$2","edgeGuards","document","querySelectorAll","body","insertAdjacentElement","createFocusGuard","forEach","node","remove","element","createElement","setAttribute","tabIndex","style","cssText","Root"],"version":3,"file":"index.module.js.map"}
1
+ {"mappings":";;;;;;;;;;ACAA;AAEA,8EAAA,CACA,IAAIC,2BAAK,GAAG,CAAZ,AAAA;AAEA,SAASC,yCAAT,CAAqBC,KAArB,EAAiC;IAC/BC,yCAAc,EAAdA,CAAAA;IACA,OAAOD,KAAK,CAACE,QAAb,CAAA;CACD;AAED;;;GAGA,CACA,SAASD,yCAAT,GAA0B;IACxBJ,gBAAA,CAAgB,IAAM;QAAA,IAAA,YAAA,EAAA,aAAA,AAAA;QACpB,MAAMO,UAAU,GAAGC,QAAQ,CAACC,gBAAT,CAA0B,0BAA1B,CAAnB,AAAA;QACAD,QAAQ,CAACE,IAAT,CAAcC,qBAAd,CAAoC,YAApC,EAAA,AAAA,CAAA,YAAA,GAAkDJ,UAAU,CAAC,CAAD,CAA5D,CAAA,KAAA,IAAA,IAAA,YAAA,KAAA,KAAA,CAAA,GAAA,YAAA,GAAmEK,sCAAgB,EAAnF,CAAAJ,CAAAA;QACAA,QAAQ,CAACE,IAAT,CAAcC,qBAAd,CAAoC,WAApC,EAAA,AAAA,CAAA,aAAA,GAAiDJ,UAAU,CAAC,CAAD,CAA3D,CAAA,KAAA,IAAA,IAAA,aAAA,KAAA,KAAA,CAAA,GAAA,aAAA,GAAkEK,sCAAgB,EAAlF,CAAAJ,CAAAA;QACAP,2BAAK,EAALA,CAAAA;QAEA,OAAO,IAAM;YACX,IAAIA,2BAAK,KAAK,CAAd,EACEO,QAAQ,CAACC,gBAAT,CAA0B,0BAA1B,CAAA,CAAsDI,OAAtD,CAA+DC,CAAAA,IAAD,GAAUA,IAAI,CAACC,MAAL,EAAxE;YAAA,CAAAP,CAAAA;YAEFP,2BAAK,EAALA,CAAAA;SAJF,CAKC;KAXH,EAYG,EAZH,CAYC,CAAA;CACF;AAED,SAASW,sCAAT,GAA4B;IAC1B,MAAMI,OAAO,GAAGR,QAAQ,CAACS,aAAT,CAAuB,MAAvB,CAAhB,AAAA;IACAD,OAAO,CAACE,YAAR,CAAqB,wBAArB,EAA+C,EAA/C,CAAAF,CAAAA;IACAA,OAAO,CAACG,QAAR,GAAmB,CAAnB,CAAAH;IACAA,OAAO,CAACI,KAAR,CAAcC,OAAd,GAAwB,kEAAxB,CAAAL;IACA,OAAOA,OAAP,CAAA;CACD;AAED,MAAMM,yCAAI,GAAGpB,yCAAb,AAAA;;ADtCA","sources":["packages/react/focus-guards/src/index.ts","packages/react/focus-guards/src/FocusGuards.tsx"],"sourcesContent":["export * from './FocusGuards';\n","import * as React from 'react';\n\n/** Number of components which have requested interest to have focus guards */\nlet count = 0;\n\nfunction FocusGuards(props: any) {\n useFocusGuards();\n return props.children;\n}\n\n/**\n * Injects a pair of focus guards at the edges of the whole DOM tree\n * to ensure `focusin` & `focusout` events can be caught consistently.\n */\nfunction useFocusGuards() {\n React.useEffect(() => {\n const edgeGuards = document.querySelectorAll('[data-radix-focus-guard]');\n document.body.insertAdjacentElement('afterbegin', edgeGuards[0] ?? createFocusGuard());\n document.body.insertAdjacentElement('beforeend', edgeGuards[1] ?? createFocusGuard());\n count++;\n\n return () => {\n if (count === 1) {\n document.querySelectorAll('[data-radix-focus-guard]').forEach((node) => node.remove());\n }\n count--;\n };\n }, []);\n}\n\nfunction createFocusGuard() {\n const element = document.createElement('span');\n element.setAttribute('data-radix-focus-guard', '');\n element.tabIndex = 0;\n element.style.cssText = 'outline: none; opacity: 0; position: fixed; pointer-events: none';\n return element;\n}\n\nconst Root = FocusGuards;\n\nexport {\n FocusGuards,\n //\n Root,\n //\n useFocusGuards,\n};\n"],"names":["React","count","FocusGuards","props","useFocusGuards","children","useEffect","edgeGuards","document","querySelectorAll","body","insertAdjacentElement","createFocusGuard","forEach","node","remove","element","createElement","setAttribute","tabIndex","style","cssText","Root"],"version":3,"file":"index.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ui/react-focus-guards",
3
- "version": "0.1.1-rc.1",
3
+ "version": "0.1.1-rc.12",
4
4
  "license": "MIT",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",