vadivam-solid 0.0.80 → 0.0.82

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.82)
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
@@ -6,31 +6,30 @@ import { createComponent as _$createComponent } from "solid-js/web";
6
6
  import { memo as _$memo } from "solid-js/web";
7
7
  import { escape as _$escape } from "solid-js/web";
8
8
  var _tmpl$ = ["<title", ">", "</title>"];
9
- import { For, splitProps } from "solid-js";
9
+ import { createMemo, For, splitProps } from "solid-js";
10
10
  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
- // built, and Icon passes caller nodes after sanitizing them.
26
+ // built, and Icon passes caller nodes after sanitizing them. The root
27
+ // attributes are sanitized in a memo, so props that start out undefined still apply.
22
28
  export function IconBase(props) {
23
29
  const [local, rest] = splitProps(props, ["color", "size", "strokeWidth", "absoluteStrokeWidth", "children", "iconNode", "name", "title", "class"]);
24
30
  const context = useVadivamContext();
25
31
  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
- const safeRest = sanitizeRootAttributes(rest, true);
32
+ const safeRest = createMemo(() => sanitizeRootAttributes(rest, true));
34
33
  return _$ssrElement("svg", _$mergeProps(defaultAttributes, {
35
34
  get width() {
36
35
  return resolvedSize();
@@ -42,16 +41,16 @@ export function IconBase(props) {
42
41
  return sanitizePaint(local.color ?? context.color);
43
42
  },
44
43
  get ["stroke-width"]() {
45
- return calculated();
44
+ return scaledStrokeWidth(local.strokeWidth ?? context.strokeWidth ?? 2, resolvedSize(), local.absoluteStrokeWidth ?? context.absoluteStrokeWidth ?? false);
46
45
  },
47
46
  get ["class"]() {
48
- return classes("vadivam", local.name && "vadivam-" + local.name, context.class, local.class);
47
+ return mergeClasses("vadivam", local.name && "vadivam-" + local.name, context.class, local.class);
49
48
  },
50
49
  get ["aria-hidden"]() {
51
- return !local.title && !hasA11y(safeRest) ? "true" : undefined;
50
+ return isLabelled(local.title, Object.keys(safeRest())) ? undefined : "true";
52
51
  },
53
52
  get role() {
54
- return local.title ? "img" : safeRest.role;
53
+ return local.title ? "img" : safeRest().role;
55
54
  }
56
55
  }, safeRest), () => ["<!--$-->", local.title ? _$ssr(_tmpl$, _$ssrHydrationKey(), _$escape(local.title)) : _$escape(null), "<!--/-->", "<!--$-->", _$escape(_$createComponent(For, {
57
56
  get each() {
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";
@@ -6,24 +6,25 @@ import { createComponent as _$createComponent } from "solid-js/web";
6
6
  import { memo as _$memo } from "solid-js/web";
7
7
  import { escape as _$escape } from "solid-js/web";
8
8
  var _tmpl$ = ["<title", ">", "</title>"];
9
- import { For, splitProps } from "solid-js";
9
+ import { createMemo, For, splitProps } from "solid-js";
10
10
  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
- // built, and Icon passes caller nodes after sanitizing them.
21
+ // built, and Icon passes caller nodes after sanitizing them. The root
22
+ // attributes are sanitized in a memo, so props that start out undefined still apply.
22
23
  export function IconBase(props) {
23
24
  const [local, rest] = splitProps(props, ["color", "size", "strokeWidth", "absoluteStrokeWidth", "children", "iconNode", "name", "title", "class"]);
24
25
  const context = useVadivamContext();
25
26
  const resolvedSize = () => local.size ?? context.size ?? 24;
26
- const safeRest = sanitizeRootAttributes(rest, true);
27
+ const safeRest = createMemo(() => sanitizeRootAttributes(rest, true));
27
28
  return _$ssrElement("svg", _$mergeProps(defaultAttributes, {
28
29
  get width() {
29
30
  return resolvedSize();
@@ -35,13 +36,13 @@ export function IconBase(props) {
35
36
  return sanitizePaint(local.color ?? context.color);
36
37
  },
37
38
  get ["class"]() {
38
- return classes("vadivam", local.name && "vadivam-" + local.name, context.class, local.class);
39
+ return mergeClasses("vadivam", local.name && "vadivam-" + local.name, context.class, local.class);
39
40
  },
40
41
  get ["aria-hidden"]() {
41
- return !local.title && !hasA11y(safeRest) ? "true" : undefined;
42
+ return isLabelled(local.title, Object.keys(safeRest())) ? undefined : "true";
42
43
  },
43
44
  get role() {
44
- return local.title ? "img" : safeRest.role;
45
+ return local.title ? "img" : safeRest().role;
45
46
  }
46
47
  }, safeRest), () => ["<!--$-->", local.title ? _$ssr(_tmpl$, _$ssrHydrationKey(), _$escape(local.title)) : _$escape(null), "<!--/-->", "<!--$-->", _$escape(_$createComponent(For, {
47
48
  get each() {
@@ -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";
@@ -1,10 +1,11 @@
1
- import { For, splitProps } from "solid-js";
1
+ import { createMemo, For, splitProps } from "solid-js";
2
2
  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
- // 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>; }
9
+ // built, and Icon passes caller nodes after sanitizing them. The root
10
+ // attributes are sanitized in a memo, so props that start out undefined still apply.
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 = createMemo(() => 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>; }
@@ -1,10 +1,12 @@
1
- import { For, splitProps } from "solid-js";
1
+ import { createMemo, For, splitProps } from "solid-js";
2
2
  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
- // 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>; }
10
+ // built, and Icon passes caller nodes after sanitizing them. The root
11
+ // attributes are sanitized in a memo, so props that start out undefined still apply.
12
+ 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 = createMemo(() => 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.82",
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",