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

|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
14
|
npm install vadivam-react
|
|
@@ -50,6 +50,8 @@ Every icon also has a solid twin with the same name in `vadivam-react/solid`. So
|
|
|
50
50
|
import { Activity } from "vadivam-react/solid";
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
<!-- vadivam-packages:start -->
|
|
54
|
+
Package family: [SVG and JavaScript](https://www.npmjs.com/package/vadivam) · [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) · [Solid](https://www.npmjs.com/package/vadivam-solid) · [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)
|
|
55
|
+
<!-- vadivam-packages:end -->
|
|
54
56
|
|
|
55
57
|
[Issues](https://github.com/praveenjuge/vadivam/issues)
|
package/dist/IconBase.js
CHANGED
|
@@ -3,12 +3,9 @@ import React, { forwardRef } from "react";
|
|
|
3
3
|
import defaultAttributes from "./defaultAttributes.js";
|
|
4
4
|
import { useVadivamContext } from "./context.js";
|
|
5
5
|
|
|
6
|
-
function mergeClasses(...values) {
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
function hasA11yProp(props) {
|
|
10
|
-
return Object.keys(props).some((name) => name.startsWith("aria-") || name === "role" || name === "title");
|
|
11
|
-
}
|
|
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; }
|
|
12
9
|
function toPaint(value) {
|
|
13
10
|
return typeof value === "string" || typeof value === "number" ? value : "currentColor";
|
|
14
11
|
}
|
|
@@ -25,12 +22,7 @@ export function renderNode([tag, attrs]) {
|
|
|
25
22
|
export function useIconSvg({ color, size, strokeWidth, absoluteStrokeWidth, className = "", title, children }, ref, rootAttributes, nodes, paint = toPaint) {
|
|
26
23
|
const context = useVadivamContext();
|
|
27
24
|
const resolvedSize = size ?? context.size ?? 24;
|
|
28
|
-
const
|
|
29
|
-
const numericSize = Number(resolvedSize);
|
|
30
|
-
const numericStrokeWidth = Number(resolvedStrokeWidth);
|
|
31
|
-
const useAbsoluteStrokeWidth = absoluteStrokeWidth ?? context.absoluteStrokeWidth ?? false;
|
|
32
|
-
const calculatedStrokeWidth = useAbsoluteStrokeWidth && Number.isFinite(numericSize) && numericSize !== 0 && Number.isFinite(numericStrokeWidth) ? numericStrokeWidth * 24 / numericSize : resolvedStrokeWidth;
|
|
33
|
-
const labelled = Boolean(title) || hasA11yProp(rootAttributes);
|
|
25
|
+
const labelled = isLabelled(title, Object.keys(rootAttributes));
|
|
34
26
|
return React.createElement(
|
|
35
27
|
"svg",
|
|
36
28
|
{
|
|
@@ -38,8 +30,7 @@ export function useIconSvg({ color, size, strokeWidth, absoluteStrokeWidth, clas
|
|
|
38
30
|
...defaultAttributes,
|
|
39
31
|
width: resolvedSize,
|
|
40
32
|
height: resolvedSize,
|
|
41
|
-
stroke: paint(color ?? context.color),
|
|
42
|
-
strokeWidth: calculatedStrokeWidth,
|
|
33
|
+
stroke: paint(color ?? context.color), strokeWidth: scaledStrokeWidth(strokeWidth ?? context.strokeWidth ?? 2, resolvedSize, absoluteStrokeWidth ?? context.absoluteStrokeWidth ?? false),
|
|
43
34
|
className: mergeClasses("vadivam", context.className, className),
|
|
44
35
|
...(!labelled ? { "aria-hidden": "true" } : {}),
|
|
45
36
|
...(title ? { role: "img" } : {}),
|
package/dist/index.d.ts
CHANGED
|
@@ -2023,3 +2023,5 @@ export { createIcon, createVadivamIcon } from "./createIcon.js";
|
|
|
2023
2023
|
export { icons } from "./icons.js";
|
|
2024
2024
|
export { VadivamProvider, useVadivamContext } from "./context.js";
|
|
2025
2025
|
export type { IconName, IconNode, SVGAttributes, SVGElementType, VadivamIcon, VadivamProps } from "./types.js";
|
|
2026
|
+
export type { IconProps } from "./Icon.js";
|
|
2027
|
+
export type { VadivamProviderProps } from "./context.js";
|
package/dist/solid/IconBase.js
CHANGED
|
@@ -3,12 +3,8 @@ import React, { forwardRef } from "react";
|
|
|
3
3
|
import defaultAttributes from "./defaultAttributes.js";
|
|
4
4
|
import { useVadivamContext } from "../context.js";
|
|
5
5
|
|
|
6
|
-
function mergeClasses(...values) {
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
function hasA11yProp(props) {
|
|
10
|
-
return Object.keys(props).some((name) => name.startsWith("aria-") || name === "role" || name === "title");
|
|
11
|
-
}
|
|
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"); }
|
|
12
8
|
function toPaint(value) {
|
|
13
9
|
return typeof value === "string" || typeof value === "number" ? value : "currentColor";
|
|
14
10
|
}
|
|
@@ -25,7 +21,7 @@ export function renderNode([tag, attrs]) {
|
|
|
25
21
|
export function useIconSvg({ color, size, strokeWidth: _strokeWidth, absoluteStrokeWidth: _absoluteStrokeWidth, className = "", title, children }, ref, rootAttributes, nodes, paint = toPaint) {
|
|
26
22
|
const context = useVadivamContext();
|
|
27
23
|
const resolvedSize = size ?? context.size ?? 24;
|
|
28
|
-
const labelled =
|
|
24
|
+
const labelled = isLabelled(title, Object.keys(rootAttributes));
|
|
29
25
|
return React.createElement(
|
|
30
26
|
"svg",
|
|
31
27
|
{
|
package/dist/solid/index.d.ts
CHANGED
|
@@ -2023,3 +2023,5 @@ export { createIcon, createVadivamIcon } from "./createIcon.js";
|
|
|
2023
2023
|
export { icons } from "./icons.js";
|
|
2024
2024
|
export { VadivamProvider, useVadivamContext } from "../context.js";
|
|
2025
2025
|
export type { IconName, IconNode, SVGAttributes, SVGElementType, VadivamIcon, VadivamProps } from "./types.js";
|
|
2026
|
+
export type { IconProps } from "./Icon.js";
|
|
2027
|
+
export type { VadivamProviderProps } from "../context.js";
|