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 CHANGED
@@ -8,7 +8,7 @@ Tree-shakeable 24px outline and solid SVG icons for Solid.
8
8
  [![downloads](https://img.shields.io/npm/dw/vadivam-solid?style=flat-square&color=666)](https://www.npmjs.com/package/vadivam-solid)
9
9
  [![license](https://img.shields.io/npm/l/vadivam-solid?style=flat-square&color=111)](https://github.com/praveenjuge/vadivam/blob/main/LICENSE)
10
10
 
11
- ![All Vadivam icons](https://raw.githubusercontent.com/praveenjuge/vadivam/main/apps/docs/public/preview.png?v=0.0.80)
11
+ ![All Vadivam icons](https://raw.githubusercontent.com/praveenjuge/vadivam/main/apps/docs/public/preview.png?v=0.0.81)
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
- 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) · [Angular](https://www.npmjs.com/package/vadivam-angular) · [Astro](https://www.npmjs.com/package/vadivam-astro) · [Preact](https://www.npmjs.com/package/vadivam-preact) · [Qwik](https://www.npmjs.com/package/vadivam-qwik) · [Lit](https://www.npmjs.com/package/vadivam-lit) · [Flutter](https://pub.dev/packages/vadivam) · [Jetpack Compose](https://central.sonatype.com/artifact/com.praveenjuge/vadivam-compose) · [MCP server](https://www.npmjs.com/package/vadivam-mcp)
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 classes(...values) {
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 hasA11y(props) {
18
- return Object.keys(props).some(name => name.startsWith("aria-") || name === "role" || name === "title");
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 calculated();
43
+ return scaledStrokeWidth(local.strokeWidth ?? context.strokeWidth ?? 2, resolvedSize(), local.absoluteStrokeWidth ?? context.absoluteStrokeWidth ?? false);
46
44
  },
47
45
  get ["class"]() {
48
- return classes("vadivam", local.name && "vadivam-" + local.name, context.class, local.class);
46
+ return mergeClasses("vadivam", local.name && "vadivam-" + local.name, context.class, local.class);
49
47
  },
50
48
  get ["aria-hidden"]() {
51
- return !local.title && !hasA11y(safeRest) ? "true" : undefined;
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";
@@ -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 classes(...values) {
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 hasA11y(props) {
18
- return Object.keys(props).some(name => name.startsWith("aria-") || name === "role" || name === "title");
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 classes("vadivam", local.name && "vadivam-" + local.name, context.class, local.class);
38
+ return mergeClasses("vadivam", local.name && "vadivam-" + local.name, context.class, local.class);
39
39
  },
40
40
  get ["aria-hidden"]() {
41
- return !local.title && !hasA11y(safeRest) ? "true" : undefined;
41
+ return isLabelled(local.title, Object.keys(safeRest)) ? undefined : "true";
42
42
  },
43
43
  get role() {
44
44
  return local.title ? "img" : safeRest.role;
@@ -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 classes(...values) { return values.flatMap((value) => typeof value === "string" ? value.split(/\s+/) : []).filter((value, index, all) => value && all.indexOf(value) === index).join(" "); }
7
- function hasA11y(props) { return Object.keys(props).some((name) => name.startsWith("aria-") || name === "role" || name === "title"); }
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={classes("vadivam", local.name && "vadivam-" + local.name, context.class, local.class)} aria-hidden={!local.title && !hasA11y(safeRest) ? "true" : undefined} 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>; }
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>; }
@@ -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 classes(...values) { return values.flatMap((value) => typeof value === "string" ? value.split(/\s+/) : []).filter((value, index, all) => value && all.indexOf(value) === index).join(" "); }
7
- function hasA11y(props) { return Object.keys(props).some((name) => name.startsWith("aria-") || name === "role" || name === "title"); }
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 resolvedStroke = () => local.strokeWidth ?? context.strokeWidth ?? 2; const calculated = () => { const size = Number(resolvedSize()); const stroke = Number(resolvedStroke()); const absolute = local.absoluteStrokeWidth ?? context.absoluteStrokeWidth ?? false; return absolute && Number.isFinite(size) && size !== 0 && Number.isFinite(stroke) ? stroke * 24 / size : resolvedStroke(); }; const safeRest = sanitizeRootAttributes(rest, true); return <svg {...defaultAttributes} width={resolvedSize()} height={resolvedSize()} stroke={sanitizePaint(local.color ?? context.color)} stroke-width={calculated()} class={classes("vadivam", local.name && "vadivam-" + local.name, context.class, local.class)} aria-hidden={!local.title && !hasA11y(safeRest) ? "true" : undefined} 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>; }
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>; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vadivam-solid",
3
- "version": "0.0.80",
3
+ "version": "0.0.81",
4
4
  "description": "Pixel-perfect 24px outline and solid icon components for Solid with tree-shakeable imports.",
5
5
  "license": "MIT",
6
6
  "author": "Praveen Juge",