vadivam-solid 0.0.80 → 0.0.81
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/README.md +4 -2
- package/dist/IconBase.js +11 -13
- package/dist/index.d.ts +1 -0
- package/dist/solid/IconBase.js +5 -5
- package/dist/solid/index.d.ts +1 -0
- package/dist/solid/source/IconBase.jsx +3 -3
- package/dist/source/IconBase.jsx +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Tree-shakeable 24px outline and solid SVG icons for Solid.
|
|
|
8
8
|
[](https://www.npmjs.com/package/vadivam-solid)
|
|
9
9
|
[](https://github.com/praveenjuge/vadivam/blob/main/LICENSE)
|
|
10
10
|
|
|
11
|
-

|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
14
|
npm install vadivam-solid
|
|
@@ -32,6 +32,8 @@ Every icon also has a solid twin with the same name in `vadivam-solid/solid`. So
|
|
|
32
32
|
import { Activity } from "vadivam-solid/solid";
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
<!-- vadivam-packages:start -->
|
|
36
|
+
Package family: [SVG and JavaScript](https://www.npmjs.com/package/vadivam) · [React](https://www.npmjs.com/package/vadivam-react) · [React Native](https://www.npmjs.com/package/vadivam-react-native) · [Vue](https://www.npmjs.com/package/vadivam-vue) · [Svelte](https://www.npmjs.com/package/vadivam-svelte) · [Preact](https://www.npmjs.com/package/vadivam-preact) · [Astro](https://www.npmjs.com/package/vadivam-astro) · [Angular](https://www.npmjs.com/package/vadivam-angular) · [Qwik](https://www.npmjs.com/package/vadivam-qwik) · [Lit](https://www.npmjs.com/package/vadivam-lit) · [Flutter](https://pub.dev/packages/vadivam) · [Compose](https://central.sonatype.com/artifact/com.praveenjuge/vadivam-compose) · [MCP server](https://www.npmjs.com/package/vadivam-mcp)
|
|
37
|
+
<!-- vadivam-packages:end -->
|
|
36
38
|
|
|
37
39
|
[Issues](https://github.com/praveenjuge/vadivam/issues)
|
package/dist/IconBase.js
CHANGED
|
@@ -11,11 +11,16 @@ import { Dynamic } from "solid-js/web";
|
|
|
11
11
|
import defaultAttributes from "./defaultAttributes.js";
|
|
12
12
|
import { sanitizePaint, sanitizeRootAttributes } from "./runtimePolicy.js";
|
|
13
13
|
import { useVadivamContext } from "./context.js";
|
|
14
|
-
function
|
|
14
|
+
function mergeClasses(...values) {
|
|
15
15
|
return values.flatMap(value => typeof value === "string" ? value.split(/\s+/) : []).filter((value, index, all) => value && all.indexOf(value) === index).join(" ");
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
return
|
|
17
|
+
function isLabelled(title, attributeNames) {
|
|
18
|
+
return Boolean(title) || attributeNames.some(name => name.startsWith("aria-") || name === "role" || name === "title");
|
|
19
|
+
}
|
|
20
|
+
function scaledStrokeWidth(strokeWidth, size, absolute) {
|
|
21
|
+
const numericSize = Number(size);
|
|
22
|
+
const numericStroke = Number(strokeWidth);
|
|
23
|
+
return absolute && Number.isFinite(numericSize) && numericSize !== 0 && Number.isFinite(numericStroke) ? numericStroke * 24 / numericSize : strokeWidth;
|
|
19
24
|
}
|
|
20
25
|
// Renders nodes as given: built-in icons pass nodes checked when the package is
|
|
21
26
|
// built, and Icon passes caller nodes after sanitizing them.
|
|
@@ -23,13 +28,6 @@ export function IconBase(props) {
|
|
|
23
28
|
const [local, rest] = splitProps(props, ["color", "size", "strokeWidth", "absoluteStrokeWidth", "children", "iconNode", "name", "title", "class"]);
|
|
24
29
|
const context = useVadivamContext();
|
|
25
30
|
const resolvedSize = () => local.size ?? context.size ?? 24;
|
|
26
|
-
const resolvedStroke = () => local.strokeWidth ?? context.strokeWidth ?? 2;
|
|
27
|
-
const calculated = () => {
|
|
28
|
-
const size = Number(resolvedSize());
|
|
29
|
-
const stroke = Number(resolvedStroke());
|
|
30
|
-
const absolute = local.absoluteStrokeWidth ?? context.absoluteStrokeWidth ?? false;
|
|
31
|
-
return absolute && Number.isFinite(size) && size !== 0 && Number.isFinite(stroke) ? stroke * 24 / size : resolvedStroke();
|
|
32
|
-
};
|
|
33
31
|
const safeRest = sanitizeRootAttributes(rest, true);
|
|
34
32
|
return _$ssrElement("svg", _$mergeProps(defaultAttributes, {
|
|
35
33
|
get width() {
|
|
@@ -42,13 +40,13 @@ export function IconBase(props) {
|
|
|
42
40
|
return sanitizePaint(local.color ?? context.color);
|
|
43
41
|
},
|
|
44
42
|
get ["stroke-width"]() {
|
|
45
|
-
return
|
|
43
|
+
return scaledStrokeWidth(local.strokeWidth ?? context.strokeWidth ?? 2, resolvedSize(), local.absoluteStrokeWidth ?? context.absoluteStrokeWidth ?? false);
|
|
46
44
|
},
|
|
47
45
|
get ["class"]() {
|
|
48
|
-
return
|
|
46
|
+
return mergeClasses("vadivam", local.name && "vadivam-" + local.name, context.class, local.class);
|
|
49
47
|
},
|
|
50
48
|
get ["aria-hidden"]() {
|
|
51
|
-
return
|
|
49
|
+
return isLabelled(local.title, Object.keys(safeRest)) ? undefined : "true";
|
|
52
50
|
},
|
|
53
51
|
get role() {
|
|
54
52
|
return local.title ? "img" : safeRest.role;
|
package/dist/index.d.ts
CHANGED
|
@@ -2024,3 +2024,4 @@ export { icons } from "./icons.js";
|
|
|
2024
2024
|
export { VadivamContext, VadivamProvider, useVadivamContext } from "./context.js";
|
|
2025
2025
|
export { dynamicIconImports, iconNames } from "./dynamicIconImports.js";
|
|
2026
2026
|
export type { IconName, IconNode, SVGElementType, VadivamIcon, VadivamProps } from "./types.js";
|
|
2027
|
+
export type { VadivamProviderProps } from "./context.js";
|
package/dist/solid/IconBase.js
CHANGED
|
@@ -11,11 +11,11 @@ import { Dynamic } from "solid-js/web";
|
|
|
11
11
|
import defaultAttributes from "./defaultAttributes.js";
|
|
12
12
|
import { sanitizePaint, sanitizeRootAttributes } from "../runtimePolicy.js";
|
|
13
13
|
import { useVadivamContext } from "../context.js";
|
|
14
|
-
function
|
|
14
|
+
function mergeClasses(...values) {
|
|
15
15
|
return values.flatMap(value => typeof value === "string" ? value.split(/\s+/) : []).filter((value, index, all) => value && all.indexOf(value) === index).join(" ");
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
return
|
|
17
|
+
function isLabelled(title, attributeNames) {
|
|
18
|
+
return Boolean(title) || attributeNames.some(name => name.startsWith("aria-") || name === "role" || name === "title");
|
|
19
19
|
}
|
|
20
20
|
// Renders nodes as given: built-in icons pass nodes checked when the package is
|
|
21
21
|
// built, and Icon passes caller nodes after sanitizing them.
|
|
@@ -35,10 +35,10 @@ export function IconBase(props) {
|
|
|
35
35
|
return sanitizePaint(local.color ?? context.color);
|
|
36
36
|
},
|
|
37
37
|
get ["class"]() {
|
|
38
|
-
return
|
|
38
|
+
return mergeClasses("vadivam", local.name && "vadivam-" + local.name, context.class, local.class);
|
|
39
39
|
},
|
|
40
40
|
get ["aria-hidden"]() {
|
|
41
|
-
return
|
|
41
|
+
return isLabelled(local.title, Object.keys(safeRest)) ? undefined : "true";
|
|
42
42
|
},
|
|
43
43
|
get role() {
|
|
44
44
|
return local.title ? "img" : safeRest.role;
|
package/dist/solid/index.d.ts
CHANGED
|
@@ -2024,3 +2024,4 @@ export { icons } from "./icons.js";
|
|
|
2024
2024
|
export { VadivamContext, VadivamProvider, useVadivamContext } from "../context.js";
|
|
2025
2025
|
export { dynamicIconImports, iconNames } from "./dynamicIconImports.js";
|
|
2026
2026
|
export type { IconName, IconNode, SVGElementType, VadivamIcon, VadivamProps } from "./types.js";
|
|
2027
|
+
export type { VadivamProviderProps } from "../context.js";
|
|
@@ -3,8 +3,8 @@ import { Dynamic } from "solid-js/web";
|
|
|
3
3
|
import defaultAttributes from "./defaultAttributes.js";
|
|
4
4
|
import { sanitizePaint, sanitizeRootAttributes } from "../../runtimePolicy.js";
|
|
5
5
|
import { useVadivamContext } from "../../source/context.jsx";
|
|
6
|
-
function
|
|
7
|
-
function
|
|
6
|
+
function mergeClasses(...values) { return values.flatMap((value) => typeof value === "string" ? value.split(/\s+/) : []).filter((value, index, all) => value && all.indexOf(value) === index).join(" "); }
|
|
7
|
+
function isLabelled(title, attributeNames) { return Boolean(title) || attributeNames.some((name) => name.startsWith("aria-") || name === "role" || name === "title"); }
|
|
8
8
|
// Renders nodes as given: built-in icons pass nodes checked when the package is
|
|
9
9
|
// built, and Icon passes caller nodes after sanitizing them.
|
|
10
|
-
export function IconBase(props) { const [local, rest] = splitProps(props, ["color", "size", "strokeWidth", "absoluteStrokeWidth", "children", "iconNode", "name", "title", "class"]); const context = useVadivamContext(); const resolvedSize = () => local.size ?? context.size ?? 24; const safeRest = sanitizeRootAttributes(rest, true); return <svg {...defaultAttributes} width={resolvedSize()} height={resolvedSize()} fill={sanitizePaint(local.color ?? context.color)} class={
|
|
10
|
+
export function IconBase(props) { const [local, rest] = splitProps(props, ["color", "size", "strokeWidth", "absoluteStrokeWidth", "children", "iconNode", "name", "title", "class"]); const context = useVadivamContext(); const resolvedSize = () => local.size ?? context.size ?? 24; const safeRest = sanitizeRootAttributes(rest, true); return <svg {...defaultAttributes} width={resolvedSize()} height={resolvedSize()} fill={sanitizePaint(local.color ?? context.color)} class={mergeClasses("vadivam", local.name && "vadivam-" + local.name, context.class, local.class)} aria-hidden={isLabelled(local.title, Object.keys(safeRest)) ? undefined : "true"} role={local.title ? "img" : safeRest.role} {...safeRest}>{local.title ? <title>{local.title}</title> : null}<For each={local.iconNode ?? []}>{([tag, attrs]) => <Dynamic component={tag} {...attrs} />}</For>{local.children}</svg>; }
|
package/dist/source/IconBase.jsx
CHANGED
|
@@ -3,8 +3,9 @@ import { Dynamic } from "solid-js/web";
|
|
|
3
3
|
import defaultAttributes from "./defaultAttributes.js";
|
|
4
4
|
import { sanitizePaint, sanitizeRootAttributes } from "./runtimePolicy.js";
|
|
5
5
|
import { useVadivamContext } from "./context.jsx";
|
|
6
|
-
function
|
|
7
|
-
function
|
|
6
|
+
function mergeClasses(...values) { return values.flatMap((value) => typeof value === "string" ? value.split(/\s+/) : []).filter((value, index, all) => value && all.indexOf(value) === index).join(" "); }
|
|
7
|
+
function isLabelled(title, attributeNames) { return Boolean(title) || attributeNames.some((name) => name.startsWith("aria-") || name === "role" || name === "title"); }
|
|
8
|
+
function scaledStrokeWidth(strokeWidth, size, absolute) { const numericSize = Number(size); const numericStroke = Number(strokeWidth); return absolute && Number.isFinite(numericSize) && numericSize !== 0 && Number.isFinite(numericStroke) ? numericStroke * 24 / numericSize : strokeWidth; }
|
|
8
9
|
// Renders nodes as given: built-in icons pass nodes checked when the package is
|
|
9
10
|
// built, and Icon passes caller nodes after sanitizing them.
|
|
10
|
-
export function IconBase(props) { const [local, rest] = splitProps(props, ["color", "size", "strokeWidth", "absoluteStrokeWidth", "children", "iconNode", "name", "title", "class"]); const context = useVadivamContext(); const resolvedSize = () => local.size ?? context.size ?? 24; const
|
|
11
|
+
export function IconBase(props) { const [local, rest] = splitProps(props, ["color", "size", "strokeWidth", "absoluteStrokeWidth", "children", "iconNode", "name", "title", "class"]); const context = useVadivamContext(); const resolvedSize = () => local.size ?? context.size ?? 24; const safeRest = sanitizeRootAttributes(rest, true); return <svg {...defaultAttributes} width={resolvedSize()} height={resolvedSize()} stroke={sanitizePaint(local.color ?? context.color)} stroke-width={scaledStrokeWidth(local.strokeWidth ?? context.strokeWidth ?? 2, resolvedSize(), local.absoluteStrokeWidth ?? context.absoluteStrokeWidth ?? false)} class={mergeClasses("vadivam", local.name && "vadivam-" + local.name, context.class, local.class)} aria-hidden={isLabelled(local.title, Object.keys(safeRest)) ? undefined : "true"} role={local.title ? "img" : safeRest.role} {...safeRest}>{local.title ? <title>{local.title}</title> : null}<For each={local.iconNode ?? []}>{([tag, attrs]) => <Dynamic component={tag} {...attrs} />}</For>{local.children}</svg>; }
|