@radix-solid-js/accessible-icon 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 ADDED
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var solidJs = require('solid-js');
4
+ var visuallyHidden = require('@radix-solid-js/visually-hidden');
5
+
6
+ // src/accessible-icon.tsx
7
+ function AccessibleIcon(props) {
8
+ const resolved = solidJs.children(() => props.children);
9
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, (() => {
10
+ const child = resolved();
11
+ if (child instanceof Element) {
12
+ child.setAttribute("aria-hidden", "true");
13
+ child.setAttribute("focusable", "false");
14
+ }
15
+ return child;
16
+ })(), /* @__PURE__ */ React.createElement(visuallyHidden.VisuallyHidden, null, props.label));
17
+ }
18
+ var Root = AccessibleIcon;
19
+
20
+ exports.AccessibleIcon = AccessibleIcon;
21
+ exports.Root = Root;
22
+ //# sourceMappingURL=index.cjs.map
23
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/accessible-icon.tsx"],"names":["resolveChildren","VisuallyHidden"],"mappings":";;;;;;AAwBA,SAAS,eAAe,KAAA,EAA4B;AAClD,EAAA,MAAM,QAAA,GAAWA,gBAAA,CAAgB,MAAM,KAAA,CAAM,QAAQ,CAAA;AAErD,EAAA,kEAEM,MAAM;AACN,IAAA,MAAM,QAAQ,QAAA,EAAS;AACvB,IAAA,IAAI,iBAAiB,OAAA,EAAS;AAC5B,MAAA,KAAA,CAAM,YAAA,CAAa,eAAe,MAAM,CAAA;AACxC,MAAA,KAAA,CAAM,YAAA,CAAa,aAAa,OAAO,CAAA;AAAA,IACzC;AACA,IAAA,OAAO,KAAA;AAAA,EACT,IAAG,kBACH,KAAA,CAAA,aAAA,CAACC,6BAAA,EAAA,IAAA,EAAgB,KAAA,CAAM,KAAM,CAC/B,CAAA;AAEJ;AAIA,IAAM,IAAA,GAAO","file":"index.cjs","sourcesContent":["import { type JSX, children as resolveChildren } from 'solid-js';\nimport { VisuallyHidden } from '@radix-solid-js/visually-hidden';\n\n/* -------------------------------------------------------------------------------------------------\n * AccessibleIcon\n * -----------------------------------------------------------------------------------------------*/\n\ninterface AccessibleIconProps {\n children: JSX.Element;\n /**\n * The accessible label for the icon. This label will be visually hidden but announced to screen\n * reader users, similar to `alt` text for `img` tags.\n */\n label: string;\n}\n\n/**\n * Makes an icon accessible by hiding it from the accessibility tree\n * and providing a visually hidden label for screen readers.\n *\n * In React's Radix, this used `React.Children.only` + `cloneElement`.\n * In SolidJS, we use the `children()` helper and set attributes directly\n * on the resolved child element.\n */\nfunction AccessibleIcon(props: AccessibleIconProps) {\n const resolved = resolveChildren(() => props.children);\n\n return (\n <>\n {(() => {\n const child = resolved() as Element;\n if (child instanceof Element) {\n child.setAttribute('aria-hidden', 'true');\n child.setAttribute('focusable', 'false');\n }\n return child;\n })()}\n <VisuallyHidden>{props.label}</VisuallyHidden>\n </>\n );\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = AccessibleIcon;\n\nexport { AccessibleIcon, Root };\nexport type { AccessibleIconProps };\n"]}
@@ -0,0 +1,22 @@
1
+ import { JSX } from 'solid-js';
2
+
3
+ interface AccessibleIconProps {
4
+ children: JSX.Element;
5
+ /**
6
+ * The accessible label for the icon. This label will be visually hidden but announced to screen
7
+ * reader users, similar to `alt` text for `img` tags.
8
+ */
9
+ label: string;
10
+ }
11
+ /**
12
+ * Makes an icon accessible by hiding it from the accessibility tree
13
+ * and providing a visually hidden label for screen readers.
14
+ *
15
+ * In React's Radix, this used `React.Children.only` + `cloneElement`.
16
+ * In SolidJS, we use the `children()` helper and set attributes directly
17
+ * on the resolved child element.
18
+ */
19
+ declare function AccessibleIcon(props: AccessibleIconProps): JSX.Element;
20
+ declare const Root: typeof AccessibleIcon;
21
+
22
+ export { AccessibleIcon, type AccessibleIconProps, Root };
@@ -0,0 +1,22 @@
1
+ import { JSX } from 'solid-js';
2
+
3
+ interface AccessibleIconProps {
4
+ children: JSX.Element;
5
+ /**
6
+ * The accessible label for the icon. This label will be visually hidden but announced to screen
7
+ * reader users, similar to `alt` text for `img` tags.
8
+ */
9
+ label: string;
10
+ }
11
+ /**
12
+ * Makes an icon accessible by hiding it from the accessibility tree
13
+ * and providing a visually hidden label for screen readers.
14
+ *
15
+ * In React's Radix, this used `React.Children.only` + `cloneElement`.
16
+ * In SolidJS, we use the `children()` helper and set attributes directly
17
+ * on the resolved child element.
18
+ */
19
+ declare function AccessibleIcon(props: AccessibleIconProps): JSX.Element;
20
+ declare const Root: typeof AccessibleIcon;
21
+
22
+ export { AccessibleIcon, type AccessibleIconProps, Root };
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ import { children } from 'solid-js';
2
+ import { VisuallyHidden } from '@radix-solid-js/visually-hidden';
3
+
4
+ // src/accessible-icon.tsx
5
+ function AccessibleIcon(props) {
6
+ const resolved = children(() => props.children);
7
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, (() => {
8
+ const child = resolved();
9
+ if (child instanceof Element) {
10
+ child.setAttribute("aria-hidden", "true");
11
+ child.setAttribute("focusable", "false");
12
+ }
13
+ return child;
14
+ })(), /* @__PURE__ */ React.createElement(VisuallyHidden, null, props.label));
15
+ }
16
+ var Root = AccessibleIcon;
17
+
18
+ export { AccessibleIcon, Root };
19
+ //# sourceMappingURL=index.js.map
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/accessible-icon.tsx"],"names":["resolveChildren"],"mappings":";;;;AAwBA,SAAS,eAAe,KAAA,EAA4B;AAClD,EAAA,MAAM,QAAA,GAAWA,QAAA,CAAgB,MAAM,KAAA,CAAM,QAAQ,CAAA;AAErD,EAAA,kEAEM,MAAM;AACN,IAAA,MAAM,QAAQ,QAAA,EAAS;AACvB,IAAA,IAAI,iBAAiB,OAAA,EAAS;AAC5B,MAAA,KAAA,CAAM,YAAA,CAAa,eAAe,MAAM,CAAA;AACxC,MAAA,KAAA,CAAM,YAAA,CAAa,aAAa,OAAO,CAAA;AAAA,IACzC;AACA,IAAA,OAAO,KAAA;AAAA,EACT,IAAG,kBACH,KAAA,CAAA,aAAA,CAAC,cAAA,EAAA,IAAA,EAAgB,KAAA,CAAM,KAAM,CAC/B,CAAA;AAEJ;AAIA,IAAM,IAAA,GAAO","file":"index.js","sourcesContent":["import { type JSX, children as resolveChildren } from 'solid-js';\nimport { VisuallyHidden } from '@radix-solid-js/visually-hidden';\n\n/* -------------------------------------------------------------------------------------------------\n * AccessibleIcon\n * -----------------------------------------------------------------------------------------------*/\n\ninterface AccessibleIconProps {\n children: JSX.Element;\n /**\n * The accessible label for the icon. This label will be visually hidden but announced to screen\n * reader users, similar to `alt` text for `img` tags.\n */\n label: string;\n}\n\n/**\n * Makes an icon accessible by hiding it from the accessibility tree\n * and providing a visually hidden label for screen readers.\n *\n * In React's Radix, this used `React.Children.only` + `cloneElement`.\n * In SolidJS, we use the `children()` helper and set attributes directly\n * on the resolved child element.\n */\nfunction AccessibleIcon(props: AccessibleIconProps) {\n const resolved = resolveChildren(() => props.children);\n\n return (\n <>\n {(() => {\n const child = resolved() as Element;\n if (child instanceof Element) {\n child.setAttribute('aria-hidden', 'true');\n child.setAttribute('focusable', 'false');\n }\n return child;\n })()}\n <VisuallyHidden>{props.label}</VisuallyHidden>\n </>\n );\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Root = AccessibleIcon;\n\nexport { AccessibleIcon, Root };\nexport type { AccessibleIconProps };\n"]}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@radix-solid-js/accessible-icon",
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
+ "test": "vitest run"
30
+ },
31
+ "dependencies": {
32
+ "@radix-solid-js/visually-hidden": "workspace:*"
33
+ },
34
+ "peerDependencies": {
35
+ "solid-js": "^1.8.0"
36
+ },
37
+ "devDependencies": {
38
+ "@repo/tsconfig": "workspace:*",
39
+ "tsup": "^8.3.6",
40
+ "typescript": "^5.7.3",
41
+ "solid-js": "^1.9.3",
42
+ "vitest": "^2.1.8"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/ljho01/shadcn-solid-js.git",
50
+ "directory": "packages/solid/accessible-icon"
51
+ }
52
+ }