@tamagui/focus-guard 2.0.0-1

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.
Files changed (44) hide show
  1. package/dist/cjs/FocusGuard.cjs +56 -0
  2. package/dist/cjs/FocusGuard.js +48 -0
  3. package/dist/cjs/FocusGuard.js.map +6 -0
  4. package/dist/cjs/FocusGuard.native.js +37 -0
  5. package/dist/cjs/FocusGuard.native.js.map +1 -0
  6. package/dist/cjs/index.cjs +18 -0
  7. package/dist/cjs/index.js +15 -0
  8. package/dist/cjs/index.js.map +6 -0
  9. package/dist/cjs/index.native.js +21 -0
  10. package/dist/cjs/index.native.js.map +1 -0
  11. package/dist/esm/FocusGuard.js +24 -0
  12. package/dist/esm/FocusGuard.js.map +6 -0
  13. package/dist/esm/FocusGuard.mjs +20 -0
  14. package/dist/esm/FocusGuard.mjs.map +1 -0
  15. package/dist/esm/FocusGuard.native.js +9 -0
  16. package/dist/esm/FocusGuard.native.js.map +1 -0
  17. package/dist/esm/index.js +2 -0
  18. package/dist/esm/index.js.map +6 -0
  19. package/dist/esm/index.mjs +2 -0
  20. package/dist/esm/index.mjs.map +1 -0
  21. package/dist/esm/index.native.js +2 -0
  22. package/dist/esm/index.native.js.map +1 -0
  23. package/dist/jsx/FocusGuard.js +24 -0
  24. package/dist/jsx/FocusGuard.js.map +6 -0
  25. package/dist/jsx/FocusGuard.mjs +20 -0
  26. package/dist/jsx/FocusGuard.mjs.map +1 -0
  27. package/dist/jsx/FocusGuard.native.js +37 -0
  28. package/dist/jsx/FocusGuard.native.js.map +1 -0
  29. package/dist/jsx/index.js +2 -0
  30. package/dist/jsx/index.js.map +6 -0
  31. package/dist/jsx/index.mjs +2 -0
  32. package/dist/jsx/index.mjs.map +1 -0
  33. package/dist/jsx/index.native.js +21 -0
  34. package/dist/jsx/index.native.js.map +1 -0
  35. package/package.json +37 -0
  36. package/src/FocusGuard.native.tsx +18 -0
  37. package/src/FocusGuard.tsx +50 -0
  38. package/src/index.tsx +1 -0
  39. package/types/FocusGuard.d.ts +9 -0
  40. package/types/FocusGuard.d.ts.map +1 -0
  41. package/types/FocusGuard.native.d.ts +5 -0
  42. package/types/FocusGuard.native.d.ts.map +1 -0
  43. package/types/index.d.ts +2 -0
  44. package/types/index.d.ts.map +1 -0
@@ -0,0 +1,56 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var FocusGuard_exports = {};
33
+ __export(FocusGuard_exports, {
34
+ FocusGuards: () => FocusGuards,
35
+ Root: () => Root,
36
+ useFocusGuards: () => useFocusGuards
37
+ });
38
+ module.exports = __toCommonJS(FocusGuard_exports);
39
+ var React = __toESM(require("react"));
40
+ let count = 0;
41
+ function FocusGuards(props) {
42
+ return useFocusGuards(), props.children;
43
+ }
44
+ function useFocusGuards() {
45
+ React.useEffect(() => {
46
+ const edgeGuards = document.querySelectorAll("[data-tamagui-focus-guard]");
47
+ return document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard()), document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard()), count++, () => {
48
+ count === 1 && document.querySelectorAll("[data-tamagui-focus-guard]").forEach(node => node.remove()), count--;
49
+ };
50
+ }, []);
51
+ }
52
+ function createFocusGuard() {
53
+ const element = document.createElement("span");
54
+ return element.setAttribute("data-tamagui-focus-guard", ""), element.tabIndex = 0, element.style.cssText = "outline: none; opacity: 0; position: fixed; pointer-events: none", element;
55
+ }
56
+ const Root = FocusGuards;
@@ -0,0 +1,48 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
+ mod
22
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
+ var FocusGuard_exports = {};
24
+ __export(FocusGuard_exports, {
25
+ FocusGuards: () => FocusGuards,
26
+ Root: () => Root,
27
+ useFocusGuards: () => useFocusGuards
28
+ });
29
+ module.exports = __toCommonJS(FocusGuard_exports);
30
+ var React = __toESM(require("react"));
31
+ let count = 0;
32
+ function FocusGuards(props) {
33
+ return useFocusGuards(), props.children;
34
+ }
35
+ function useFocusGuards() {
36
+ React.useEffect(() => {
37
+ const edgeGuards = document.querySelectorAll("[data-tamagui-focus-guard]");
38
+ return document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard()), document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard()), count++, () => {
39
+ count === 1 && document.querySelectorAll("[data-tamagui-focus-guard]").forEach((node) => node.remove()), count--;
40
+ };
41
+ }, []);
42
+ }
43
+ function createFocusGuard() {
44
+ const element = document.createElement("span");
45
+ return element.setAttribute("data-tamagui-focus-guard", ""), element.tabIndex = 0, element.style.cssText = "outline: none; opacity: 0; position: fixed; pointer-events: none", element;
46
+ }
47
+ const Root = FocusGuards;
48
+ //# sourceMappingURL=FocusGuard.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/FocusGuard.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AAGvB,IAAI,QAAQ;AAEZ,SAAS,YAAY,OAAY;AAC/B,wBAAe,GACR,MAAM;AACf;AAMA,SAAS,iBAAiB;AACxB,QAAM,UAAU,MAAM;AACpB,UAAM,aAAa,SAAS,iBAAiB,4BAA4B;AACzE,oBAAS,KAAK,sBAAsB,cAAc,WAAW,CAAC,KAAK,iBAAiB,CAAC,GACrF,SAAS,KAAK,sBAAsB,aAAa,WAAW,CAAC,KAAK,iBAAiB,CAAC,GACpF,SAEO,MAAM;AACX,MAAI,UAAU,KACZ,SACG,iBAAiB,4BAA4B,EAC7C,QAAQ,CAAC,SAAS,KAAK,OAAO,CAAC,GAEpC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AACP;AAEA,SAAS,mBAAmB;AAC1B,QAAM,UAAU,SAAS,cAAc,MAAM;AAC7C,iBAAQ,aAAa,4BAA4B,EAAE,GACnD,QAAQ,WAAW,GACnB,QAAQ,MAAM,UACZ,oEACK;AACT;AAEA,MAAM,OAAO;",
5
+ "names": []
6
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: !0
22
+ }), mod);
23
+ var FocusGuard_native_exports = {};
24
+ __export(FocusGuard_native_exports, {
25
+ FocusGuards: () => FocusGuards,
26
+ Root: () => Root,
27
+ useFocusGuards: () => useFocusGuards
28
+ });
29
+ module.exports = __toCommonJS(FocusGuard_native_exports);
30
+ function FocusGuards(props) {
31
+ return useFocusGuards(), props.children;
32
+ }
33
+ function useFocusGuards() {
34
+ return null;
35
+ }
36
+ var Root = FocusGuards;
37
+ //# sourceMappingURL=FocusGuard.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["FocusGuard_native_exports","__export","FocusGuards","Root","useFocusGuards","module","exports","__toCommonJS","props","children"],"sources":["../../src/FocusGuard.native.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,yBAAA;AAAAC,QAAA,CAAAD,yBAAA;EAAAE,WAAA,EAAAA,CAAA,KAAAA,WAAA;EAAAC,IAAA,EAAAA,CAAA,KAAAA,IAAA;EAAAC,cAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAC,YAAA,CAAAP,yBAAA;AAAA,SAASE,YAAYM,KAAA,EAAO;EACxB,OAAAJ,cAAA,CAAe,GACRI,KAAA,CAAMC,QAAA;AACjB;AACA,SAASL,eAAA,EAAiB;EACtB,OAAO;AACX;AACA,IAAID,IAAA,GAAOD,WAAA","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
+ get: () => from[key],
8
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ });
10
+ return to;
11
+ },
12
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
+ value: !0
15
+ }), mod);
16
+ var index_exports = {};
17
+ module.exports = __toCommonJS(index_exports);
18
+ __reExport(index_exports, require("./FocusGuard.cjs"), module.exports);
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from == "object" || typeof from == "function")
7
+ for (let key of __getOwnPropNames(from))
8
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
+ return to;
10
+ }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
+ var index_exports = {};
13
+ module.exports = __toCommonJS(index_exports);
14
+ __reExport(index_exports, require("./FocusGuard"), module.exports);
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.tsx"],
4
+ "mappings": ";;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,yBAAd;",
5
+ "names": []
6
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
9
+ get: () => from[key],
10
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
11
+ });
12
+ return to;
13
+ },
14
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
16
+ value: !0
17
+ }), mod);
18
+ var index_exports = {};
19
+ module.exports = __toCommonJS(index_exports);
20
+ __reExport(index_exports, require("./FocusGuard.native.js"), module.exports);
21
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports"],"sources":["../../src/index.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ import * as React from "react";
2
+ let count = 0;
3
+ function FocusGuards(props) {
4
+ return useFocusGuards(), props.children;
5
+ }
6
+ function useFocusGuards() {
7
+ React.useEffect(() => {
8
+ const edgeGuards = document.querySelectorAll("[data-tamagui-focus-guard]");
9
+ return document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard()), document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard()), count++, () => {
10
+ count === 1 && document.querySelectorAll("[data-tamagui-focus-guard]").forEach((node) => node.remove()), count--;
11
+ };
12
+ }, []);
13
+ }
14
+ function createFocusGuard() {
15
+ const element = document.createElement("span");
16
+ return element.setAttribute("data-tamagui-focus-guard", ""), element.tabIndex = 0, element.style.cssText = "outline: none; opacity: 0; position: fixed; pointer-events: none", element;
17
+ }
18
+ const Root = FocusGuards;
19
+ export {
20
+ FocusGuards,
21
+ Root,
22
+ useFocusGuards
23
+ };
24
+ //# sourceMappingURL=FocusGuard.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/FocusGuard.tsx"],
4
+ "mappings": "AAAA,YAAY,WAAW;AAGvB,IAAI,QAAQ;AAEZ,SAAS,YAAY,OAAY;AAC/B,wBAAe,GACR,MAAM;AACf;AAMA,SAAS,iBAAiB;AACxB,QAAM,UAAU,MAAM;AACpB,UAAM,aAAa,SAAS,iBAAiB,4BAA4B;AACzE,oBAAS,KAAK,sBAAsB,cAAc,WAAW,CAAC,KAAK,iBAAiB,CAAC,GACrF,SAAS,KAAK,sBAAsB,aAAa,WAAW,CAAC,KAAK,iBAAiB,CAAC,GACpF,SAEO,MAAM;AACX,MAAI,UAAU,KACZ,SACG,iBAAiB,4BAA4B,EAC7C,QAAQ,CAAC,SAAS,KAAK,OAAO,CAAC,GAEpC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AACP;AAEA,SAAS,mBAAmB;AAC1B,QAAM,UAAU,SAAS,cAAc,MAAM;AAC7C,iBAAQ,aAAa,4BAA4B,EAAE,GACnD,QAAQ,WAAW,GACnB,QAAQ,MAAM,UACZ,oEACK;AACT;AAEA,MAAM,OAAO;",
5
+ "names": []
6
+ }
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+ let count = 0;
3
+ function FocusGuards(props) {
4
+ return useFocusGuards(), props.children;
5
+ }
6
+ function useFocusGuards() {
7
+ React.useEffect(() => {
8
+ const edgeGuards = document.querySelectorAll("[data-tamagui-focus-guard]");
9
+ return document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard()), document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard()), count++, () => {
10
+ count === 1 && document.querySelectorAll("[data-tamagui-focus-guard]").forEach(node => node.remove()), count--;
11
+ };
12
+ }, []);
13
+ }
14
+ function createFocusGuard() {
15
+ const element = document.createElement("span");
16
+ return element.setAttribute("data-tamagui-focus-guard", ""), element.tabIndex = 0, element.style.cssText = "outline: none; opacity: 0; position: fixed; pointer-events: none", element;
17
+ }
18
+ const Root = FocusGuards;
19
+ export { FocusGuards, Root, useFocusGuards };
20
+ //# sourceMappingURL=FocusGuard.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","count","FocusGuards","props","useFocusGuards","children","useEffect","edgeGuards","document","querySelectorAll","body","insertAdjacentElement","createFocusGuard","forEach","node","remove","element","createElement","setAttribute","tabIndex","style","cssText","Root"],"sources":["../../src/FocusGuard.tsx"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAGvB,IAAIC,KAAA,GAAQ;AAEZ,SAASC,YAAYC,KAAA,EAAY;EAC/B,OAAAC,cAAA,CAAe,GACRD,KAAA,CAAME,QAAA;AACf;AAMA,SAASD,eAAA,EAAiB;EACxBJ,KAAA,CAAMM,SAAA,CAAU,MAAM;IACpB,MAAMC,UAAA,GAAaC,QAAA,CAASC,gBAAA,CAAiB,4BAA4B;IACzE,OAAAD,QAAA,CAASE,IAAA,CAAKC,qBAAA,CAAsB,cAAcJ,UAAA,CAAW,CAAC,KAAKK,gBAAA,CAAiB,CAAC,GACrFJ,QAAA,CAASE,IAAA,CAAKC,qBAAA,CAAsB,aAAaJ,UAAA,CAAW,CAAC,KAAKK,gBAAA,CAAiB,CAAC,GACpFX,KAAA,IAEO,MAAM;MACPA,KAAA,KAAU,KACZO,QAAA,CACGC,gBAAA,CAAiB,4BAA4B,EAC7CI,OAAA,CAASC,IAAA,IAASA,IAAA,CAAKC,MAAA,CAAO,CAAC,GAEpCd,KAAA;IACF;EACF,GAAG,EAAE;AACP;AAEA,SAASW,iBAAA,EAAmB;EAC1B,MAAMI,OAAA,GAAUR,QAAA,CAASS,aAAA,CAAc,MAAM;EAC7C,OAAAD,OAAA,CAAQE,YAAA,CAAa,4BAA4B,EAAE,GACnDF,OAAA,CAAQG,QAAA,GAAW,GACnBH,OAAA,CAAQI,KAAA,CAAMC,OAAA,GACZ,oEACKL,OAAA;AACT;AAEA,MAAMM,IAAA,GAAOpB,WAAA","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ function FocusGuards(props) {
2
+ return useFocusGuards(), props.children;
3
+ }
4
+ function useFocusGuards() {
5
+ return null;
6
+ }
7
+ var Root = FocusGuards;
8
+ export { FocusGuards, Root, useFocusGuards };
9
+ //# sourceMappingURL=FocusGuard.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["FocusGuards","props","useFocusGuards","children","Root"],"sources":["../../src/FocusGuard.native.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,YAAYC,KAAA,EAAO;EACxB,OAAAC,cAAA,CAAe,GACRD,KAAA,CAAME,QAAA;AACjB;AACA,SAASD,eAAA,EAAiB;EACtB,OAAO;AACX;AACA,IAAIE,IAAA,GAAOJ,WAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./FocusGuard";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.tsx"],
4
+ "mappings": "AAAA,cAAc;",
5
+ "names": []
6
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./FocusGuard.mjs";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.tsx"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./FocusGuard.native.js";
2
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.tsx"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ import * as React from "react";
2
+ let count = 0;
3
+ function FocusGuards(props) {
4
+ return useFocusGuards(), props.children;
5
+ }
6
+ function useFocusGuards() {
7
+ React.useEffect(() => {
8
+ const edgeGuards = document.querySelectorAll("[data-tamagui-focus-guard]");
9
+ return document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard()), document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard()), count++, () => {
10
+ count === 1 && document.querySelectorAll("[data-tamagui-focus-guard]").forEach((node) => node.remove()), count--;
11
+ };
12
+ }, []);
13
+ }
14
+ function createFocusGuard() {
15
+ const element = document.createElement("span");
16
+ return element.setAttribute("data-tamagui-focus-guard", ""), element.tabIndex = 0, element.style.cssText = "outline: none; opacity: 0; position: fixed; pointer-events: none", element;
17
+ }
18
+ const Root = FocusGuards;
19
+ export {
20
+ FocusGuards,
21
+ Root,
22
+ useFocusGuards
23
+ };
24
+ //# sourceMappingURL=FocusGuard.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/FocusGuard.tsx"],
4
+ "mappings": "AAAA,YAAY,WAAW;AAGvB,IAAI,QAAQ;AAEZ,SAAS,YAAY,OAAY;AAC/B,wBAAe,GACR,MAAM;AACf;AAMA,SAAS,iBAAiB;AACxB,QAAM,UAAU,MAAM;AACpB,UAAM,aAAa,SAAS,iBAAiB,4BAA4B;AACzE,oBAAS,KAAK,sBAAsB,cAAc,WAAW,CAAC,KAAK,iBAAiB,CAAC,GACrF,SAAS,KAAK,sBAAsB,aAAa,WAAW,CAAC,KAAK,iBAAiB,CAAC,GACpF,SAEO,MAAM;AACX,MAAI,UAAU,KACZ,SACG,iBAAiB,4BAA4B,EAC7C,QAAQ,CAAC,SAAS,KAAK,OAAO,CAAC,GAEpC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AACP;AAEA,SAAS,mBAAmB;AAC1B,QAAM,UAAU,SAAS,cAAc,MAAM;AAC7C,iBAAQ,aAAa,4BAA4B,EAAE,GACnD,QAAQ,WAAW,GACnB,QAAQ,MAAM,UACZ,oEACK;AACT;AAEA,MAAM,OAAO;",
5
+ "names": []
6
+ }
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+ let count = 0;
3
+ function FocusGuards(props) {
4
+ return useFocusGuards(), props.children;
5
+ }
6
+ function useFocusGuards() {
7
+ React.useEffect(() => {
8
+ const edgeGuards = document.querySelectorAll("[data-tamagui-focus-guard]");
9
+ return document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard()), document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard()), count++, () => {
10
+ count === 1 && document.querySelectorAll("[data-tamagui-focus-guard]").forEach(node => node.remove()), count--;
11
+ };
12
+ }, []);
13
+ }
14
+ function createFocusGuard() {
15
+ const element = document.createElement("span");
16
+ return element.setAttribute("data-tamagui-focus-guard", ""), element.tabIndex = 0, element.style.cssText = "outline: none; opacity: 0; position: fixed; pointer-events: none", element;
17
+ }
18
+ const Root = FocusGuards;
19
+ export { FocusGuards, Root, useFocusGuards };
20
+ //# sourceMappingURL=FocusGuard.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","count","FocusGuards","props","useFocusGuards","children","useEffect","edgeGuards","document","querySelectorAll","body","insertAdjacentElement","createFocusGuard","forEach","node","remove","element","createElement","setAttribute","tabIndex","style","cssText","Root"],"sources":["../../src/FocusGuard.tsx"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAGvB,IAAIC,KAAA,GAAQ;AAEZ,SAASC,YAAYC,KAAA,EAAY;EAC/B,OAAAC,cAAA,CAAe,GACRD,KAAA,CAAME,QAAA;AACf;AAMA,SAASD,eAAA,EAAiB;EACxBJ,KAAA,CAAMM,SAAA,CAAU,MAAM;IACpB,MAAMC,UAAA,GAAaC,QAAA,CAASC,gBAAA,CAAiB,4BAA4B;IACzE,OAAAD,QAAA,CAASE,IAAA,CAAKC,qBAAA,CAAsB,cAAcJ,UAAA,CAAW,CAAC,KAAKK,gBAAA,CAAiB,CAAC,GACrFJ,QAAA,CAASE,IAAA,CAAKC,qBAAA,CAAsB,aAAaJ,UAAA,CAAW,CAAC,KAAKK,gBAAA,CAAiB,CAAC,GACpFX,KAAA,IAEO,MAAM;MACPA,KAAA,KAAU,KACZO,QAAA,CACGC,gBAAA,CAAiB,4BAA4B,EAC7CI,OAAA,CAASC,IAAA,IAASA,IAAA,CAAKC,MAAA,CAAO,CAAC,GAEpCd,KAAA;IACF;EACF,GAAG,EAAE;AACP;AAEA,SAASW,iBAAA,EAAmB;EAC1B,MAAMI,OAAA,GAAUR,QAAA,CAASS,aAAA,CAAc,MAAM;EAC7C,OAAAD,OAAA,CAAQE,YAAA,CAAa,4BAA4B,EAAE,GACnDF,OAAA,CAAQG,QAAA,GAAW,GACnBH,OAAA,CAAQI,KAAA,CAAMC,OAAA,GACZ,oEACKL,OAAA;AACT;AAEA,MAAMM,IAAA,GAAOpB,WAAA","ignoreList":[]}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: !0
22
+ }), mod);
23
+ var FocusGuard_native_exports = {};
24
+ __export(FocusGuard_native_exports, {
25
+ FocusGuards: () => FocusGuards,
26
+ Root: () => Root,
27
+ useFocusGuards: () => useFocusGuards
28
+ });
29
+ module.exports = __toCommonJS(FocusGuard_native_exports);
30
+ function FocusGuards(props) {
31
+ return useFocusGuards(), props.children;
32
+ }
33
+ function useFocusGuards() {
34
+ return null;
35
+ }
36
+ var Root = FocusGuards;
37
+ //# sourceMappingURL=FocusGuard.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["FocusGuard_native_exports","__export","FocusGuards","Root","useFocusGuards","module","exports","__toCommonJS","props","children"],"sources":["../../src/FocusGuard.native.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,yBAAA;AAAAC,QAAA,CAAAD,yBAAA;EAAAE,WAAA,EAAAA,CAAA,KAAAA,WAAA;EAAAC,IAAA,EAAAA,CAAA,KAAAA,IAAA;EAAAC,cAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAC,YAAA,CAAAP,yBAAA;AAAA,SAASE,YAAYM,KAAA,EAAO;EACxB,OAAAJ,cAAA,CAAe,GACRI,KAAA,CAAMC,QAAA;AACjB;AACA,SAASL,eAAA,EAAiB;EACtB,OAAO;AACX;AACA,IAAID,IAAA,GAAOD,WAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./FocusGuard";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.tsx"],
4
+ "mappings": "AAAA,cAAc;",
5
+ "names": []
6
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./FocusGuard.mjs";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.tsx"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
9
+ get: () => from[key],
10
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
11
+ });
12
+ return to;
13
+ },
14
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
16
+ value: !0
17
+ }), mod);
18
+ var index_exports = {};
19
+ module.exports = __toCommonJS(index_exports);
20
+ __reExport(index_exports, require("./FocusGuard.native.js"), module.exports);
21
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.tsx"],"sourcesContent":[null],"mappings":"AAAA","ignoreList":[]}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@tamagui/focus-guard",
3
+ "version": "2.0.0-001",
4
+ "sideEffects": true,
5
+ "source": "src/index.ts",
6
+ "types": "./types/index.d.ts",
7
+ "main": "dist/cjs",
8
+ "module": "dist/esm",
9
+ "module:jsx": "dist/jsx",
10
+ "files": [
11
+ "src",
12
+ "types",
13
+ "dist"
14
+ ],
15
+ "scripts": {
16
+ "build": "tamagui-build",
17
+ "watch": "tamagui-build --watch",
18
+ "lint": "../../node_modules/.bin/biome check src",
19
+ "lint:fix": "../../node_modules/.bin/biome check --apply-unsafe src",
20
+ "clean": "tamagui-build clean",
21
+ "clean:build": "tamagui-build clean:build"
22
+ },
23
+ "dependencies": {
24
+ "@tamagui/compose-refs": "2.0.0-001",
25
+ "@tamagui/use-event": "2.0.0-001"
26
+ },
27
+ "peerDependencies": {
28
+ "react": "*"
29
+ },
30
+ "devDependencies": {
31
+ "@tamagui/build": "2.0.0-001",
32
+ "react": "*"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ }
37
+ }
@@ -0,0 +1,18 @@
1
+ function FocusGuards(props: any) {
2
+ useFocusGuards()
3
+ return props.children
4
+ }
5
+
6
+ function useFocusGuards() {
7
+ return null
8
+ }
9
+
10
+ const Root = FocusGuards
11
+
12
+ export {
13
+ FocusGuards,
14
+ //
15
+ Root,
16
+ //
17
+ useFocusGuards,
18
+ }
@@ -0,0 +1,50 @@
1
+ import * as React from 'react'
2
+
3
+ /** Number of components which have requested interest to have focus guards */
4
+ let count = 0
5
+
6
+ function FocusGuards(props: any) {
7
+ useFocusGuards()
8
+ return props.children
9
+ }
10
+
11
+ /**
12
+ * Injects a pair of focus guards at the edges of the whole DOM tree
13
+ * to ensure `focusin` & `focusout` events can be caught consistently.
14
+ */
15
+ function useFocusGuards() {
16
+ React.useEffect(() => {
17
+ const edgeGuards = document.querySelectorAll('[data-tamagui-focus-guard]')
18
+ document.body.insertAdjacentElement('afterbegin', edgeGuards[0] ?? createFocusGuard())
19
+ document.body.insertAdjacentElement('beforeend', edgeGuards[1] ?? createFocusGuard())
20
+ count++
21
+
22
+ return () => {
23
+ if (count === 1) {
24
+ document
25
+ .querySelectorAll('[data-tamagui-focus-guard]')
26
+ .forEach((node) => node.remove())
27
+ }
28
+ count--
29
+ }
30
+ }, [])
31
+ }
32
+
33
+ function createFocusGuard() {
34
+ const element = document.createElement('span')
35
+ element.setAttribute('data-tamagui-focus-guard', '')
36
+ element.tabIndex = 0
37
+ element.style.cssText =
38
+ 'outline: none; opacity: 0; position: fixed; pointer-events: none'
39
+ return element
40
+ }
41
+
42
+ const Root = FocusGuards
43
+
44
+ export {
45
+ FocusGuards,
46
+ //
47
+ Root,
48
+ //
49
+ useFocusGuards,
50
+ }
package/src/index.tsx ADDED
@@ -0,0 +1 @@
1
+ export * from './FocusGuard'
@@ -0,0 +1,9 @@
1
+ declare function FocusGuards(props: any): any;
2
+ /**
3
+ * Injects a pair of focus guards at the edges of the whole DOM tree
4
+ * to ensure `focusin` & `focusout` events can be caught consistently.
5
+ */
6
+ declare function useFocusGuards(): void;
7
+ declare const Root: typeof FocusGuards;
8
+ export { FocusGuards, Root, useFocusGuards, };
9
+ //# sourceMappingURL=FocusGuard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FocusGuard.d.ts","sourceRoot":"","sources":["../src/FocusGuard.tsx"],"names":[],"mappings":"AAKA,iBAAS,WAAW,CAAC,KAAK,EAAE,GAAG,OAG9B;AAED;;;GAGG;AACH,iBAAS,cAAc,SAgBtB;AAWD,QAAA,MAAM,IAAI,oBAAc,CAAA;AAExB,OAAO,EACL,WAAW,EAEX,IAAI,EAEJ,cAAc,GACf,CAAA"}
@@ -0,0 +1,5 @@
1
+ declare function FocusGuards(props: any): any;
2
+ declare function useFocusGuards(): null;
3
+ declare const Root: typeof FocusGuards;
4
+ export { FocusGuards, Root, useFocusGuards, };
5
+ //# sourceMappingURL=FocusGuard.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FocusGuard.native.d.ts","sourceRoot":"","sources":["../src/FocusGuard.native.tsx"],"names":[],"mappings":"AAAA,iBAAS,WAAW,CAAC,KAAK,EAAE,GAAG,OAG9B;AAED,iBAAS,cAAc,SAEtB;AAED,QAAA,MAAM,IAAI,oBAAc,CAAA;AAExB,OAAO,EACL,WAAW,EAEX,IAAI,EAEJ,cAAc,GACf,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './FocusGuard';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}