@radix-solid-js/focus-guards 0.1.0
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.
- package/dist/index.cjs +46 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var solidJs = require('solid-js');
|
|
4
|
+
|
|
5
|
+
// src/focus-guards.tsx
|
|
6
|
+
var count = 0;
|
|
7
|
+
function FocusGuards(props) {
|
|
8
|
+
useFocusGuards();
|
|
9
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.children);
|
|
10
|
+
}
|
|
11
|
+
function useFocusGuards() {
|
|
12
|
+
solidJs.onMount(() => {
|
|
13
|
+
const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
|
|
14
|
+
document.body.insertAdjacentElement(
|
|
15
|
+
"afterbegin",
|
|
16
|
+
edgeGuards[0] ?? createFocusGuard()
|
|
17
|
+
);
|
|
18
|
+
document.body.insertAdjacentElement(
|
|
19
|
+
"beforeend",
|
|
20
|
+
edgeGuards[1] ?? createFocusGuard()
|
|
21
|
+
);
|
|
22
|
+
count++;
|
|
23
|
+
});
|
|
24
|
+
solidJs.onCleanup(() => {
|
|
25
|
+
if (count === 1) {
|
|
26
|
+
document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
|
|
27
|
+
}
|
|
28
|
+
count--;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function createFocusGuard() {
|
|
32
|
+
const element = document.createElement("span");
|
|
33
|
+
element.setAttribute("data-radix-focus-guard", "");
|
|
34
|
+
element.tabIndex = 0;
|
|
35
|
+
element.style.outline = "none";
|
|
36
|
+
element.style.opacity = "0";
|
|
37
|
+
element.style.position = "fixed";
|
|
38
|
+
element.style.pointerEvents = "none";
|
|
39
|
+
return element;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exports.FocusGuards = FocusGuards;
|
|
43
|
+
exports.Root = FocusGuards;
|
|
44
|
+
exports.useFocusGuards = useFocusGuards;
|
|
45
|
+
//# sourceMappingURL=index.cjs.map
|
|
46
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/focus-guards.tsx"],"names":["onMount","onCleanup"],"mappings":";;;;;AAGA,IAAI,KAAA,GAAQ,CAAA;AAMZ,SAAS,YAAY,KAAA,EAAyB;AAC5C,EAAA,cAAA,EAAe;AACf,EAAA,uBAAO,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EAAG,MAAM,QAAS,CAAA;AAC3B;AAMA,SAAS,cAAA,GAAiB;AACxB,EAAAA,eAAA,CAAQ,MAAM;AACZ,IAAA,MAAM,UAAA,GAAa,QAAA,CAAS,gBAAA,CAAiB,0BAA0B,CAAA;AACvE,IAAA,QAAA,CAAS,IAAA,CAAK,qBAAA;AAAA,MACZ,YAAA;AAAA,MACA,UAAA,CAAW,CAAC,CAAA,IAAK,gBAAA;AAAiB,KACpC;AACA,IAAA,QAAA,CAAS,IAAA,CAAK,qBAAA;AAAA,MACZ,WAAA;AAAA,MACA,UAAA,CAAW,CAAC,CAAA,IAAK,gBAAA;AAAiB,KACpC;AACA,IAAA,KAAA,EAAA;AAAA,EACF,CAAC,CAAA;AAED,EAAAC,iBAAA,CAAU,MAAM;AACd,IAAA,IAAI,UAAU,CAAA,EAAG;AACf,MAAA,QAAA,CACG,gBAAA,CAAiB,0BAA0B,CAAA,CAC3C,OAAA,CAAQ,CAAC,IAAA,KAAS,IAAA,CAAK,QAAQ,CAAA;AAAA,IACpC;AACA,IAAA,KAAA,EAAA;AAAA,EACF,CAAC,CAAA;AACH;AAEA,SAAS,gBAAA,GAAmB;AAC1B,EAAA,MAAM,OAAA,GAAU,QAAA,CAAS,aAAA,CAAc,MAAM,CAAA;AAC7C,EAAA,OAAA,CAAQ,YAAA,CAAa,0BAA0B,EAAE,CAAA;AACjD,EAAA,OAAA,CAAQ,QAAA,GAAW,CAAA;AACnB,EAAA,OAAA,CAAQ,MAAM,OAAA,GAAU,MAAA;AACxB,EAAA,OAAA,CAAQ,MAAM,OAAA,GAAU,GAAA;AACxB,EAAA,OAAA,CAAQ,MAAM,QAAA,GAAW,OAAA;AACzB,EAAA,OAAA,CAAQ,MAAM,aAAA,GAAgB,MAAA;AAC9B,EAAA,OAAO,OAAA;AACT","file":"index.cjs","sourcesContent":["import { onMount, onCleanup, type JSX } from 'solid-js';\n\n/** Number of components which have requested interest to have focus guards */\nlet count = 0;\n\ninterface FocusGuardsProps {\n children?: JSX.Element;\n}\n\nfunction FocusGuards(props: FocusGuardsProps) {\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 onMount(() => {\n const edgeGuards = document.querySelectorAll('[data-radix-focus-guard]');\n document.body.insertAdjacentElement(\n 'afterbegin',\n edgeGuards[0] ?? createFocusGuard()\n );\n document.body.insertAdjacentElement(\n 'beforeend',\n edgeGuards[1] ?? createFocusGuard()\n );\n count++;\n });\n\n onCleanup(() => {\n if (count === 1) {\n document\n .querySelectorAll('[data-radix-focus-guard]')\n .forEach((node) => node.remove());\n }\n count--;\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.outline = 'none';\n element.style.opacity = '0';\n element.style.position = 'fixed';\n element.style.pointerEvents = 'none';\n return element;\n}\n\nexport { FocusGuards, useFocusGuards };\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { JSX } from 'solid-js';
|
|
2
|
+
|
|
3
|
+
interface FocusGuardsProps {
|
|
4
|
+
children?: JSX.Element;
|
|
5
|
+
}
|
|
6
|
+
declare function FocusGuards(props: FocusGuardsProps): JSX.Element;
|
|
7
|
+
/**
|
|
8
|
+
* Injects a pair of focus guards at the edges of the whole DOM tree
|
|
9
|
+
* to ensure `focusin` & `focusout` events can be caught consistently.
|
|
10
|
+
*/
|
|
11
|
+
declare function useFocusGuards(): void;
|
|
12
|
+
|
|
13
|
+
export { FocusGuards, FocusGuards as Root, useFocusGuards };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { JSX } from 'solid-js';
|
|
2
|
+
|
|
3
|
+
interface FocusGuardsProps {
|
|
4
|
+
children?: JSX.Element;
|
|
5
|
+
}
|
|
6
|
+
declare function FocusGuards(props: FocusGuardsProps): JSX.Element;
|
|
7
|
+
/**
|
|
8
|
+
* Injects a pair of focus guards at the edges of the whole DOM tree
|
|
9
|
+
* to ensure `focusin` & `focusout` events can be caught consistently.
|
|
10
|
+
*/
|
|
11
|
+
declare function useFocusGuards(): void;
|
|
12
|
+
|
|
13
|
+
export { FocusGuards, FocusGuards as Root, useFocusGuards };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { onMount, onCleanup } from 'solid-js';
|
|
2
|
+
|
|
3
|
+
// src/focus-guards.tsx
|
|
4
|
+
var count = 0;
|
|
5
|
+
function FocusGuards(props) {
|
|
6
|
+
useFocusGuards();
|
|
7
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.children);
|
|
8
|
+
}
|
|
9
|
+
function useFocusGuards() {
|
|
10
|
+
onMount(() => {
|
|
11
|
+
const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
|
|
12
|
+
document.body.insertAdjacentElement(
|
|
13
|
+
"afterbegin",
|
|
14
|
+
edgeGuards[0] ?? createFocusGuard()
|
|
15
|
+
);
|
|
16
|
+
document.body.insertAdjacentElement(
|
|
17
|
+
"beforeend",
|
|
18
|
+
edgeGuards[1] ?? createFocusGuard()
|
|
19
|
+
);
|
|
20
|
+
count++;
|
|
21
|
+
});
|
|
22
|
+
onCleanup(() => {
|
|
23
|
+
if (count === 1) {
|
|
24
|
+
document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
|
|
25
|
+
}
|
|
26
|
+
count--;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function createFocusGuard() {
|
|
30
|
+
const element = document.createElement("span");
|
|
31
|
+
element.setAttribute("data-radix-focus-guard", "");
|
|
32
|
+
element.tabIndex = 0;
|
|
33
|
+
element.style.outline = "none";
|
|
34
|
+
element.style.opacity = "0";
|
|
35
|
+
element.style.position = "fixed";
|
|
36
|
+
element.style.pointerEvents = "none";
|
|
37
|
+
return element;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { FocusGuards, FocusGuards as Root, useFocusGuards };
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/focus-guards.tsx"],"names":[],"mappings":";;;AAGA,IAAI,KAAA,GAAQ,CAAA;AAMZ,SAAS,YAAY,KAAA,EAAyB;AAC5C,EAAA,cAAA,EAAe;AACf,EAAA,uBAAO,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EAAG,MAAM,QAAS,CAAA;AAC3B;AAMA,SAAS,cAAA,GAAiB;AACxB,EAAA,OAAA,CAAQ,MAAM;AACZ,IAAA,MAAM,UAAA,GAAa,QAAA,CAAS,gBAAA,CAAiB,0BAA0B,CAAA;AACvE,IAAA,QAAA,CAAS,IAAA,CAAK,qBAAA;AAAA,MACZ,YAAA;AAAA,MACA,UAAA,CAAW,CAAC,CAAA,IAAK,gBAAA;AAAiB,KACpC;AACA,IAAA,QAAA,CAAS,IAAA,CAAK,qBAAA;AAAA,MACZ,WAAA;AAAA,MACA,UAAA,CAAW,CAAC,CAAA,IAAK,gBAAA;AAAiB,KACpC;AACA,IAAA,KAAA,EAAA;AAAA,EACF,CAAC,CAAA;AAED,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,UAAU,CAAA,EAAG;AACf,MAAA,QAAA,CACG,gBAAA,CAAiB,0BAA0B,CAAA,CAC3C,OAAA,CAAQ,CAAC,IAAA,KAAS,IAAA,CAAK,QAAQ,CAAA;AAAA,IACpC;AACA,IAAA,KAAA,EAAA;AAAA,EACF,CAAC,CAAA;AACH;AAEA,SAAS,gBAAA,GAAmB;AAC1B,EAAA,MAAM,OAAA,GAAU,QAAA,CAAS,aAAA,CAAc,MAAM,CAAA;AAC7C,EAAA,OAAA,CAAQ,YAAA,CAAa,0BAA0B,EAAE,CAAA;AACjD,EAAA,OAAA,CAAQ,QAAA,GAAW,CAAA;AACnB,EAAA,OAAA,CAAQ,MAAM,OAAA,GAAU,MAAA;AACxB,EAAA,OAAA,CAAQ,MAAM,OAAA,GAAU,GAAA;AACxB,EAAA,OAAA,CAAQ,MAAM,QAAA,GAAW,OAAA;AACzB,EAAA,OAAA,CAAQ,MAAM,aAAA,GAAgB,MAAA;AAC9B,EAAA,OAAO,OAAA;AACT","file":"index.js","sourcesContent":["import { onMount, onCleanup, type JSX } from 'solid-js';\n\n/** Number of components which have requested interest to have focus guards */\nlet count = 0;\n\ninterface FocusGuardsProps {\n children?: JSX.Element;\n}\n\nfunction FocusGuards(props: FocusGuardsProps) {\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 onMount(() => {\n const edgeGuards = document.querySelectorAll('[data-radix-focus-guard]');\n document.body.insertAdjacentElement(\n 'afterbegin',\n edgeGuards[0] ?? createFocusGuard()\n );\n document.body.insertAdjacentElement(\n 'beforeend',\n edgeGuards[1] ?? createFocusGuard()\n );\n count++;\n });\n\n onCleanup(() => {\n if (count === 1) {\n document\n .querySelectorAll('[data-radix-focus-guard]')\n .forEach((node) => node.remove());\n }\n count--;\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.outline = 'none';\n element.style.opacity = '0';\n element.style.position = 'fixed';\n element.style.pointerEvents = 'none';\n return element;\n}\n\nexport { FocusGuards, useFocusGuards };\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@radix-solid-js/focus-guards",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"default": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup",
|
|
27
|
+
"clean": "rm -rf dist",
|
|
28
|
+
"typecheck": "tsc --noEmit"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"solid-js": "^1.8.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@repo/tsconfig": "workspace:*",
|
|
35
|
+
"tsup": "^8.3.6",
|
|
36
|
+
"typescript": "^5.7.3",
|
|
37
|
+
"solid-js": "^1.9.3"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/ljho01/shadcn-solid-js.git",
|
|
45
|
+
"directory": "packages/solid/focus-guards"
|
|
46
|
+
}
|
|
47
|
+
}
|