@nice2dev/icons 1.3.15 → 1.3.16

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.
Files changed (140) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/NiceDesktopIconExporter.js +688 -599
  3. package/dist/cjs/NiceFaviconGenerator.js +603 -417
  4. package/dist/cjs/NiceIconPicker.js +788 -508
  5. package/dist/cjs/NiceIconPreview.js +246 -188
  6. package/dist/cjs/NiceIconSetCreator.js +683 -552
  7. package/dist/cjs/NiceIconStacker.js +547 -171
  8. package/dist/cjs/NiceIconValue.js +27 -35
  9. package/dist/cjs/NtdIconBadge.js +384 -360
  10. package/dist/cjs/NtdIconMorph.js +419 -354
  11. package/dist/cjs/NtdStateMorph.js +150 -147
  12. package/dist/cjs/advancedIconSearch.js +373 -510
  13. package/dist/cjs/animationControls.js +518 -642
  14. package/dist/cjs/client.js +12 -15
  15. package/dist/cjs/createIcon.js +349 -251
  16. package/dist/cjs/design-tokens.js +324 -390
  17. package/dist/cjs/figmaExport.js +162 -257
  18. package/dist/cjs/figmaSync.js +234 -316
  19. package/dist/cjs/headless-ui.js +240 -368
  20. package/dist/cjs/iconAnalytics.js +337 -393
  21. package/dist/cjs/iconHtml.js +64 -86
  22. package/dist/cjs/iconMetadata.js +392 -472
  23. package/dist/cjs/iconParts.js +120 -90
  24. package/dist/cjs/iconStack.js +136 -155
  25. package/dist/cjs/iconStyles.js +1609 -504
  26. package/dist/cjs/iconValue.js +359 -430
  27. package/dist/cjs/icons/accessibility.js +1119 -134
  28. package/dist/cjs/icons/actions.js +1290 -330
  29. package/dist/cjs/icons/ai.js +1424 -144
  30. package/dist/cjs/icons/brand.js +1344 -172
  31. package/dist/cjs/icons/business.js +903 -193
  32. package/dist/cjs/icons/devtech.js +1656 -227
  33. package/dist/cjs/icons/ecommerce.js +802 -111
  34. package/dist/cjs/icons/education.js +1345 -199
  35. package/dist/cjs/icons/files.js +1597 -328
  36. package/dist/cjs/icons/fintech.js +793 -104
  37. package/dist/cjs/icons/food.js +1507 -153
  38. package/dist/cjs/icons/fun.js +786 -109
  39. package/dist/cjs/icons/gaming.js +916 -170
  40. package/dist/cjs/icons/health.js +623 -112
  41. package/dist/cjs/icons/index.js +32 -35
  42. package/dist/cjs/icons/input.js +282 -83
  43. package/dist/cjs/icons/legal.js +1065 -122
  44. package/dist/cjs/icons/media.js +1061 -267
  45. package/dist/cjs/icons/navigation.js +387 -122
  46. package/dist/cjs/icons/omniverk.js +747 -90
  47. package/dist/cjs/icons/realestate.js +1520 -193
  48. package/dist/cjs/icons/saas.js +867 -98
  49. package/dist/cjs/icons/science.js +1451 -202
  50. package/dist/cjs/icons/shapes.js +1316 -308
  51. package/dist/cjs/icons/smarthome.js +786 -90
  52. package/dist/cjs/icons/social.js +591 -59
  53. package/dist/cjs/icons/sports.js +1225 -133
  54. package/dist/cjs/icons/sustainability.js +1211 -139
  55. package/dist/cjs/icons/travel.js +1470 -148
  56. package/dist/cjs/icons/ui.js +1508 -315
  57. package/dist/cjs/icons/weather.js +1160 -173
  58. package/dist/cjs/index.js +566 -568
  59. package/dist/cjs/lottieIntegration.js +261 -266
  60. package/dist/cjs/nicetodev-icons.css +1 -1
  61. package/dist/cjs/particleEffects.js +270 -251
  62. package/dist/cjs/resolver.js +229 -284
  63. package/dist/cjs/rsc.js +175 -193
  64. package/dist/cjs/sharpen.js +73 -130
  65. package/dist/cjs/smilAnimations.js +371 -165
  66. package/dist/cjs/stacking.js +87 -122
  67. package/dist/cjs/tailwind-plugin.js +280 -320
  68. package/dist/cjs/types.js +46 -72
  69. package/dist/cjs/utilities.js +163 -324
  70. package/dist/cjs/variantProps.js +12 -52
  71. package/dist/esm/NiceDesktopIconExporter.js +671 -598
  72. package/dist/esm/NiceFaviconGenerator.js +583 -416
  73. package/dist/esm/NiceIconPicker.js +789 -507
  74. package/dist/esm/NiceIconPreview.js +247 -187
  75. package/dist/esm/NiceIconSetCreator.js +685 -551
  76. package/dist/esm/NiceIconStacker.js +549 -170
  77. package/dist/esm/NiceIconValue.js +29 -34
  78. package/dist/esm/NtdIconBadge.js +388 -359
  79. package/dist/esm/NtdIconMorph.js +423 -353
  80. package/dist/esm/NtdStateMorph.js +152 -146
  81. package/dist/esm/advancedIconSearch.js +391 -509
  82. package/dist/esm/animationControls.js +527 -641
  83. package/dist/esm/client.js +48 -10
  84. package/dist/esm/createIcon.js +350 -250
  85. package/dist/esm/design-tokens.js +334 -387
  86. package/dist/esm/figmaExport.js +170 -256
  87. package/dist/esm/figmaSync.js +237 -315
  88. package/dist/esm/headless-ui.js +254 -365
  89. package/dist/esm/iconAnalytics.js +342 -392
  90. package/dist/esm/iconHtml.js +67 -85
  91. package/dist/esm/iconMetadata.js +404 -471
  92. package/dist/esm/iconParts.js +125 -89
  93. package/dist/esm/iconStack.js +145 -154
  94. package/dist/esm/iconStyles.js +1620 -503
  95. package/dist/esm/iconValue.js +361 -429
  96. package/dist/esm/icons/accessibility.js +1133 -133
  97. package/dist/esm/icons/actions.js +1320 -329
  98. package/dist/esm/icons/ai.js +1441 -143
  99. package/dist/esm/icons/brand.js +1351 -171
  100. package/dist/esm/icons/business.js +931 -201
  101. package/dist/esm/icons/devtech.js +1687 -226
  102. package/dist/esm/icons/ecommerce.js +816 -110
  103. package/dist/esm/icons/education.js +1364 -198
  104. package/dist/esm/icons/files.js +1628 -327
  105. package/dist/esm/icons/fintech.js +807 -103
  106. package/dist/esm/icons/food.js +1524 -152
  107. package/dist/esm/icons/fun.js +801 -108
  108. package/dist/esm/icons/gaming.js +933 -169
  109. package/dist/esm/icons/health.js +636 -111
  110. package/dist/esm/icons/index.js +596 -32
  111. package/dist/esm/icons/input.js +326 -82
  112. package/dist/esm/icons/legal.js +1079 -121
  113. package/dist/esm/icons/media.js +1086 -266
  114. package/dist/esm/icons/navigation.js +401 -121
  115. package/dist/esm/icons/omniverk.js +759 -89
  116. package/dist/esm/icons/realestate.js +1544 -198
  117. package/dist/esm/icons/saas.js +880 -97
  118. package/dist/esm/icons/science.js +1477 -208
  119. package/dist/esm/icons/shapes.js +1343 -307
  120. package/dist/esm/icons/smarthome.js +799 -89
  121. package/dist/esm/icons/social.js +599 -58
  122. package/dist/esm/icons/sports.js +1240 -132
  123. package/dist/esm/icons/sustainability.js +1226 -138
  124. package/dist/esm/icons/travel.js +1486 -147
  125. package/dist/esm/icons/ui.js +1540 -314
  126. package/dist/esm/icons/weather.js +1181 -172
  127. package/dist/esm/index.js +756 -58
  128. package/dist/esm/lottieIntegration.js +264 -265
  129. package/dist/esm/nicetodev-icons.css +1 -1
  130. package/dist/esm/particleEffects.js +271 -250
  131. package/dist/esm/resolver.js +231 -283
  132. package/dist/esm/rsc.js +182 -192
  133. package/dist/esm/sharpen.js +78 -129
  134. package/dist/esm/smilAnimations.js +376 -164
  135. package/dist/esm/stacking.js +99 -121
  136. package/dist/esm/tailwind-plugin.js +282 -319
  137. package/dist/esm/types.js +50 -71
  138. package/dist/esm/utilities.js +177 -321
  139. package/dist/esm/variantProps.js +23 -52
  140. package/package.json +15 -22
@@ -1,288 +1,287 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import React, { forwardRef, useRef, useMemo } from 'react';
3
- import { SIZE_MAP } from './types.js';
4
-
5
- /* ────────────────────────────────────────────────────────────────────────────
6
- LOTTIE → SVG RENDERER (Lightweight)
7
- ───────────────────────────────────────────────────────────────────────────── */
1
+ import { jsx } from "react/jsx-runtime";
2
+ import React, { forwardRef, useRef, useMemo } from "react";
3
+ import { SIZE_MAP } from "./types.js";
8
4
  function lottiePathToSvg(pathData) {
9
- var _a;
10
- if (!((_a = pathData === null || pathData === void 0 ? void 0 : pathData.v) === null || _a === void 0 ? void 0 : _a.length)) {
11
- return '';
5
+ if (!pathData?.v?.length) {
6
+ return "";
7
+ }
8
+ const vertices = pathData.v;
9
+ const inTangents = pathData.i;
10
+ const outTangents = pathData.o;
11
+ const parts = [];
12
+ parts.push(`M${vertices[0][0]} ${vertices[0][1]}`);
13
+ for (let i = 1; i < vertices.length; i++) {
14
+ const prev = vertices[i - 1];
15
+ const curr = vertices[i];
16
+ const oT = outTangents[i - 1];
17
+ const iT = inTangents[i];
18
+ const cp1x = prev[0] + oT[0];
19
+ const cp1y = prev[1] + oT[1];
20
+ const cp2x = curr[0] + iT[0];
21
+ const cp2y = curr[1] + iT[1];
22
+ if (Math.abs(oT[0]) + Math.abs(oT[1]) + Math.abs(iT[0]) + Math.abs(iT[1]) > 0.01) {
23
+ parts.push(`C${cp1x} ${cp1y} ${cp2x} ${cp2y} ${curr[0]} ${curr[1]}`);
24
+ } else {
25
+ parts.push(`L${curr[0]} ${curr[1]}`);
12
26
  }
13
- const vertices = pathData.v;
14
- const inTangents = pathData.i;
15
- const outTangents = pathData.o;
16
- const parts = [];
17
- // Move to first vertex
18
- parts.push(`M${vertices[0][0]} ${vertices[0][1]}`);
19
- for (let i = 1; i < vertices.length; i++) {
20
- const prev = vertices[i - 1];
21
- const curr = vertices[i];
22
- const oT = outTangents[i - 1]; // out tangent of previous
23
- const iT = inTangents[i]; // in tangent of current
24
- // Control points are relative to their vertices
25
- const cp1x = prev[0] + oT[0];
26
- const cp1y = prev[1] + oT[1];
27
- const cp2x = curr[0] + iT[0];
28
- const cp2y = curr[1] + iT[1];
29
- // Use cubic bezier if tangents are non-zero, otherwise line
30
- if (Math.abs(oT[0]) + Math.abs(oT[1]) + Math.abs(iT[0]) + Math.abs(iT[1]) > 0.01) {
31
- parts.push(`C${cp1x} ${cp1y} ${cp2x} ${cp2y} ${curr[0]} ${curr[1]}`);
32
- }
33
- else {
34
- parts.push(`L${curr[0]} ${curr[1]}`);
35
- }
36
- }
37
- // Close path if needed
38
- if (pathData.c && vertices.length > 1) {
39
- const last = vertices[vertices.length - 1];
40
- const first = vertices[0];
41
- const oT = outTangents[vertices.length - 1];
42
- const iT = inTangents[0];
43
- const cp1x = last[0] + oT[0];
44
- const cp1y = last[1] + oT[1];
45
- const cp2x = first[0] + iT[0];
46
- const cp2y = first[1] + iT[1];
47
- if (Math.abs(oT[0]) + Math.abs(oT[1]) + Math.abs(iT[0]) + Math.abs(iT[1]) > 0.01) {
48
- parts.push(`C${cp1x} ${cp1y} ${cp2x} ${cp2y} ${first[0]} ${first[1]}`);
49
- }
50
- parts.push('Z');
27
+ }
28
+ if (pathData.c && vertices.length > 1) {
29
+ const last = vertices[vertices.length - 1];
30
+ const first = vertices[0];
31
+ const oT = outTangents[vertices.length - 1];
32
+ const iT = inTangents[0];
33
+ const cp1x = last[0] + oT[0];
34
+ const cp1y = last[1] + oT[1];
35
+ const cp2x = first[0] + iT[0];
36
+ const cp2y = first[1] + iT[1];
37
+ if (Math.abs(oT[0]) + Math.abs(oT[1]) + Math.abs(iT[0]) + Math.abs(iT[1]) > 0.01) {
38
+ parts.push(`C${cp1x} ${cp1y} ${cp2x} ${cp2y} ${first[0]} ${first[1]}`);
51
39
  }
52
- return parts.join(' ');
40
+ parts.push("Z");
41
+ }
42
+ return parts.join(" ");
53
43
  }
54
44
  function extractPaths(shapes, result) {
55
- for (const shape of shapes) {
56
- if (shape.ty === 'gr' && shape.it) {
57
- extractPaths(shape.it, result);
58
- }
59
- else if (shape.ty === 'sh' && shape.ks) {
60
- const pathData = shape.ks.k;
61
- if (pathData === null || pathData === void 0 ? void 0 : pathData.v) {
62
- result.push({ d: lottiePathToSvg(pathData) });
63
- }
64
- }
65
- // Attach fill/stroke to previous path
66
- if (shape.ty === 'fl' && shape.c && result.length > 0) {
67
- const c = shape.c.k;
68
- if (Array.isArray(c) && c.length >= 3) {
69
- result[result.length - 1].fill =
70
- `rgb(${Math.round(c[0] * 255)},${Math.round(c[1] * 255)},${Math.round(c[2] * 255)})`;
71
- }
72
- }
73
- if (shape.ty === 'st' && shape.c && result.length > 0) {
74
- const c = shape.c.k;
75
- if (Array.isArray(c) && c.length >= 3) {
76
- result[result.length - 1].stroke =
77
- `rgb(${Math.round(c[0] * 255)},${Math.round(c[1] * 255)},${Math.round(c[2] * 255)})`;
78
- }
79
- if (shape.w) {
80
- const w = shape.w.k;
81
- result[result.length - 1].strokeWidth = typeof w === 'number' ? w : 2;
82
- }
83
- }
45
+ for (const shape of shapes) {
46
+ if (shape.ty === "gr" && shape.it) {
47
+ extractPaths(shape.it, result);
48
+ } else if (shape.ty === "sh" && shape.ks) {
49
+ const pathData = shape.ks.k;
50
+ if (pathData?.v) {
51
+ result.push({ d: lottiePathToSvg(pathData) });
52
+ }
53
+ }
54
+ if (shape.ty === "fl" && shape.c && result.length > 0) {
55
+ const c = shape.c.k;
56
+ if (Array.isArray(c) && c.length >= 3) {
57
+ result[result.length - 1].fill = `rgb(${Math.round(c[0] * 255)},${Math.round(c[1] * 255)},${Math.round(c[2] * 255)})`;
58
+ }
84
59
  }
60
+ if (shape.ty === "st" && shape.c && result.length > 0) {
61
+ const c = shape.c.k;
62
+ if (Array.isArray(c) && c.length >= 3) {
63
+ result[result.length - 1].stroke = `rgb(${Math.round(c[0] * 255)},${Math.round(c[1] * 255)},${Math.round(c[2] * 255)})`;
64
+ }
65
+ if (shape.w) {
66
+ const w = shape.w.k;
67
+ result[result.length - 1].strokeWidth = typeof w === "number" ? w : 2;
68
+ }
69
+ }
70
+ }
85
71
  }
86
- /* ────────────────────────────────────────────────────────────────────────────
87
- COMPONENT
88
- ───────────────────────────────────────────────────────────────────────────── */
89
- /**
90
- * Renders a Lottie animation as an SVG icon.
91
- * Uses a lightweight built-in renderer for static frames.
92
- * For animated playback, renders the first frame as a static fallback.
93
- */
94
72
  const NtdLottieIcon = /* @__PURE__ */ Object.assign(
95
- /* @__PURE__ */ forwardRef(({ data, size = 'md', autoplay: _autoplay = true, loop: _loop = true, speed: _speed = 1, frame: _frame, className, style, 'aria-label': ariaLabel, }, ref) => {
96
- var _a;
97
- const resolvedSize = typeof size === 'number' ? size : ((_a = SIZE_MAP[size]) !== null && _a !== void 0 ? _a : 24);
98
- const svgRef = useRef(null);
99
- // Extract static SVG paths from Lottie data
100
- const paths = useMemo(() => {
73
+ /* @__PURE__ */ forwardRef(
74
+ ({
75
+ data,
76
+ size = "md",
77
+ autoplay: _autoplay = true,
78
+ loop: _loop = true,
79
+ speed: _speed = 1,
80
+ frame: _frame,
81
+ className,
82
+ style,
83
+ "aria-label": ariaLabel
84
+ }, ref) => {
85
+ const resolvedSize = typeof size === "number" ? size : SIZE_MAP[size] ?? 24;
86
+ const svgRef = useRef(null);
87
+ const paths = useMemo(() => {
101
88
  const result = [];
102
89
  for (const layer of data.layers) {
103
- if (layer.shapes) {
104
- extractPaths(layer.shapes, result);
105
- }
90
+ if (layer.shapes) {
91
+ extractPaths(layer.shapes, result);
92
+ }
106
93
  }
107
94
  return result;
108
- }, [data]);
109
- // Forward ref
110
- React.useImperativeHandle(ref, () => svgRef.current);
111
- return (jsx("svg", { ref: svgRef, xmlns: "http://www.w3.org/2000/svg", viewBox: `0 0 ${data.w} ${data.h}`, width: resolvedSize, height: resolvedSize, className: className, style: style, "aria-label": ariaLabel, role: ariaLabel ? 'img' : undefined, children: paths.map((p, i) => {
112
- var _a, _b;
113
- return (jsx("path", { d: p.d, fill: (_a = p.fill) !== null && _a !== void 0 ? _a : 'currentColor', stroke: (_b = p.stroke) !== null && _b !== void 0 ? _b : 'none', strokeWidth: p.strokeWidth }, i));
114
- }) }));
115
- }), { displayName: 'NtdLottieIcon' });
116
- /* ────────────────────────────────────────────────────────────────────────────
117
- LOTTIE → ICON CONVERTER
118
- ───────────────────────────────────────────────────────────────────────────── */
119
- /**
120
- * Converts a Lottie animation to a static React icon component.
121
- * Extracts SVG paths from the first frame.
122
- *
123
- * @param data - Lottie animation JSON
124
- * @param _options - Optional: which frame to freeze at
125
- * @returns React component compatible with NtdIconProps
126
- */
127
- function lottieToIcon(data, _options) {
128
- var _a;
129
- const paths = [];
130
- for (const layer of data.layers) {
131
- if (layer.shapes) {
132
- extractPaths(layer.shapes, paths);
95
+ }, [data]);
96
+ React.useImperativeHandle(ref, () => svgRef.current);
97
+ return /* @__PURE__ */ jsx(
98
+ "svg",
99
+ {
100
+ ref: svgRef,
101
+ xmlns: "http://www.w3.org/2000/svg",
102
+ viewBox: `0 0 ${data.w} ${data.h}`,
103
+ width: resolvedSize,
104
+ height: resolvedSize,
105
+ className,
106
+ style,
107
+ "aria-label": ariaLabel,
108
+ role: ariaLabel ? "img" : void 0,
109
+ children: paths.map((p, i) => /* @__PURE__ */ jsx(
110
+ "path",
111
+ {
112
+ d: p.d,
113
+ fill: p.fill ?? "currentColor",
114
+ stroke: p.stroke ?? "none",
115
+ strokeWidth: p.strokeWidth
116
+ },
117
+ i
118
+ ))
133
119
  }
120
+ );
121
+ }
122
+ ),
123
+ { displayName: "NtdLottieIcon" }
124
+ );
125
+ function lottieToIcon(data, _options) {
126
+ const paths = [];
127
+ for (const layer of data.layers) {
128
+ if (layer.shapes) {
129
+ extractPaths(layer.shapes, paths);
134
130
  }
135
- const LottieIcon = ({ size = 'md', className, style }) => {
136
- var _a;
137
- const s = typeof size === 'number' ? size : ((_a = SIZE_MAP[size]) !== null && _a !== void 0 ? _a : 24);
138
- return (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: `0 0 ${data.w} ${data.h}`, width: s, height: s, className: className, style: style, children: paths.map((p, i) => {
139
- var _a, _b;
140
- return (jsx("path", { d: p.d, fill: (_a = p.fill) !== null && _a !== void 0 ? _a : 'currentColor', stroke: (_b = p.stroke) !== null && _b !== void 0 ? _b : 'none', strokeWidth: p.strokeWidth }, i));
141
- }) }));
142
- };
143
- LottieIcon.displayName = `LottieIcon(${(_a = data.nm) !== null && _a !== void 0 ? _a : 'unnamed'})`;
144
- return LottieIcon;
131
+ }
132
+ const LottieIcon = ({ size = "md", className, style }) => {
133
+ const s = typeof size === "number" ? size : SIZE_MAP[size] ?? 24;
134
+ return /* @__PURE__ */ jsx(
135
+ "svg",
136
+ {
137
+ xmlns: "http://www.w3.org/2000/svg",
138
+ viewBox: `0 0 ${data.w} ${data.h}`,
139
+ width: s,
140
+ height: s,
141
+ className,
142
+ style,
143
+ children: paths.map((p, i) => /* @__PURE__ */ jsx(
144
+ "path",
145
+ {
146
+ d: p.d,
147
+ fill: p.fill ?? "currentColor",
148
+ stroke: p.stroke ?? "none",
149
+ strokeWidth: p.strokeWidth
150
+ },
151
+ i
152
+ ))
153
+ }
154
+ );
155
+ };
156
+ LottieIcon.displayName = `LottieIcon(${data.nm ?? "unnamed"})`;
157
+ return LottieIcon;
145
158
  }
146
- /* ────────────────────────────────────────────────────────────────────────────
147
- ICON → LOTTIE EXPORTER
148
- ───────────────────────────────────────────────────────────────────────────── */
149
- /**
150
- * Exports an NtdIcon to Lottie JSON format.
151
- *
152
- * Creates a valid bodymovin/Lottie animation with the icon rendered as shape layers.
153
- * This produces a static (single-frame) Lottie unless `animation` is specified.
154
- *
155
- * @param svgContent - Rendered SVG `d` attribute strings (one per path)
156
- * @param options - Export configuration
157
- * @returns LottieAnimationData JSON
158
- */
159
159
  function exportToLottie(svgPaths, options) {
160
- const { fps = 30, duration = 60, size = 24, fillColor = '#000000', strokeWidth: _strokeWidth = 2, } = options !== null && options !== void 0 ? options : {};
161
- // Parse hex color to [0-1] RGB
162
- const parseColor = (hex) => {
163
- const h = hex.replace('#', '');
164
- return [
165
- parseInt(h.substring(0, 2), 16) / 255,
166
- parseInt(h.substring(2, 4), 16) / 255,
167
- parseInt(h.substring(4, 6), 16) / 255,
168
- ];
169
- };
170
- const fillRgb = parseColor(fillColor);
171
- const shapes = svgPaths.map((d, i) => ({
172
- ty: 'gr',
173
- nm: `Path ${i + 1}`,
174
- it: [
175
- {
176
- ty: 'sh',
177
- nm: `Path`,
178
- ks: {
179
- k: svgPathToLottiePath(d),
180
- },
181
- },
182
- {
183
- ty: 'fl',
184
- nm: 'Fill',
185
- c: { k: fillRgb, a: 0 },
186
- o: { k: 100, a: 0 },
187
- },
188
- ],
189
- }));
190
- return {
191
- v: '5.7.1',
192
- fr: fps,
160
+ const {
161
+ fps = 30,
162
+ duration = 60,
163
+ size = 24,
164
+ fillColor = "#000000",
165
+ strokeWidth: _strokeWidth = 2
166
+ } = options ?? {};
167
+ const parseColor = (hex) => {
168
+ const h = hex.replace("#", "");
169
+ return [
170
+ parseInt(h.substring(0, 2), 16) / 255,
171
+ parseInt(h.substring(2, 4), 16) / 255,
172
+ parseInt(h.substring(4, 6), 16) / 255
173
+ ];
174
+ };
175
+ const fillRgb = parseColor(fillColor);
176
+ const shapes = svgPaths.map((d, i) => ({
177
+ ty: "gr",
178
+ nm: `Path ${i + 1}`,
179
+ it: [
180
+ {
181
+ ty: "sh",
182
+ nm: `Path`,
183
+ ks: {
184
+ k: svgPathToLottiePath(d)
185
+ }
186
+ },
187
+ {
188
+ ty: "fl",
189
+ nm: "Fill",
190
+ c: { k: fillRgb, a: 0 },
191
+ o: { k: 100, a: 0 }
192
+ }
193
+ ]
194
+ }));
195
+ return {
196
+ v: "5.7.1",
197
+ fr: fps,
198
+ ip: 0,
199
+ op: duration,
200
+ w: size,
201
+ h: size,
202
+ nm: "NtdIcon Export",
203
+ layers: [
204
+ {
205
+ ty: 4,
206
+ nm: "Icon Layer",
193
207
  ip: 0,
194
208
  op: duration,
195
- w: size,
196
- h: size,
197
- nm: 'NtdIcon Export',
198
- layers: [
199
- {
200
- ty: 4,
201
- nm: 'Icon Layer',
202
- ip: 0,
203
- op: duration,
204
- ks: {
205
- o: { k: 100, a: 0 },
206
- r: { k: 0, a: 0 },
207
- p: { k: [size / 2, size / 2], a: 0 },
208
- s: { k: [100, 100], a: 0 },
209
- a: { k: [size / 2, size / 2], a: 0 },
210
- },
211
- shapes,
212
- },
213
- ],
214
- };
209
+ ks: {
210
+ o: { k: 100, a: 0 },
211
+ r: { k: 0, a: 0 },
212
+ p: { k: [size / 2, size / 2], a: 0 },
213
+ s: { k: [100, 100], a: 0 },
214
+ a: { k: [size / 2, size / 2], a: 0 }
215
+ },
216
+ shapes
217
+ }
218
+ ]
219
+ };
215
220
  }
216
- /**
217
- * Simplified SVG path → Lottie path converter.
218
- * Handles M, L, C, Z commands.
219
- */
220
221
  function svgPathToLottiePath(d) {
221
- const vertices = [];
222
- const inTangents = [];
223
- const outTangents = [];
224
- let closed = false;
225
- const re = /([MLCZmlcz])([^MLCZmlcz]*)/g;
226
- let match;
227
- let currentX = 0;
228
- let currentY = 0;
229
- while ((match = re.exec(d)) !== null) {
230
- const cmd = match[1];
231
- const vals = match[2]
232
- .trim()
233
- .split(/[\s,]+/)
234
- .filter(Boolean)
235
- .map(Number);
236
- switch (cmd) {
237
- case 'M':
238
- case 'm': {
239
- currentX = cmd === 'M' ? vals[0] : currentX + vals[0];
240
- currentY = cmd === 'M' ? vals[1] : currentY + vals[1];
241
- vertices.push([currentX, currentY]);
242
- inTangents.push([0, 0]);
243
- outTangents.push([0, 0]);
244
- break;
245
- }
246
- case 'L':
247
- case 'l': {
248
- currentX = cmd === 'L' ? vals[0] : currentX + vals[0];
249
- currentY = cmd === 'L' ? vals[1] : currentY + vals[1];
250
- vertices.push([currentX, currentY]);
251
- inTangents.push([0, 0]);
252
- outTangents.push([0, 0]);
253
- break;
254
- }
255
- case 'C':
256
- case 'c': {
257
- for (let i = 0; i < vals.length; i += 6) {
258
- const abs = cmd === 'C';
259
- const cp1x = abs ? vals[i] : currentX + vals[i];
260
- const cp1y = abs ? vals[i + 1] : currentY + vals[i + 1];
261
- const cp2x = abs ? vals[i + 2] : currentX + vals[i + 2];
262
- const cp2y = abs ? vals[i + 3] : currentY + vals[i + 3];
263
- const x = abs ? vals[i + 4] : currentX + vals[i + 4];
264
- const y = abs ? vals[i + 5] : currentY + vals[i + 5];
265
- // Out tangent of previous vertex
266
- if (outTangents.length > 0) {
267
- const prevIdx = outTangents.length - 1;
268
- const prev = vertices[prevIdx];
269
- outTangents[prevIdx] = [cp1x - prev[0], cp1y - prev[1]];
270
- }
271
- vertices.push([x, y]);
272
- inTangents.push([cp2x - x, cp2y - y]);
273
- outTangents.push([0, 0]);
274
- currentX = x;
275
- currentY = y;
276
- }
277
- break;
278
- }
279
- case 'Z':
280
- case 'z':
281
- closed = true;
282
- break;
222
+ const vertices = [];
223
+ const inTangents = [];
224
+ const outTangents = [];
225
+ let closed = false;
226
+ const re = /([MLCZmlcz])([^MLCZmlcz]*)/g;
227
+ let match;
228
+ let currentX = 0;
229
+ let currentY = 0;
230
+ while ((match = re.exec(d)) !== null) {
231
+ const cmd = match[1];
232
+ const vals = match[2].trim().split(/[\s,]+/).filter(Boolean).map(Number);
233
+ switch (cmd) {
234
+ case "M":
235
+ case "m": {
236
+ currentX = cmd === "M" ? vals[0] : currentX + vals[0];
237
+ currentY = cmd === "M" ? vals[1] : currentY + vals[1];
238
+ vertices.push([currentX, currentY]);
239
+ inTangents.push([0, 0]);
240
+ outTangents.push([0, 0]);
241
+ break;
242
+ }
243
+ case "L":
244
+ case "l": {
245
+ currentX = cmd === "L" ? vals[0] : currentX + vals[0];
246
+ currentY = cmd === "L" ? vals[1] : currentY + vals[1];
247
+ vertices.push([currentX, currentY]);
248
+ inTangents.push([0, 0]);
249
+ outTangents.push([0, 0]);
250
+ break;
251
+ }
252
+ case "C":
253
+ case "c": {
254
+ for (let i = 0; i < vals.length; i += 6) {
255
+ const abs = cmd === "C";
256
+ const cp1x = abs ? vals[i] : currentX + vals[i];
257
+ const cp1y = abs ? vals[i + 1] : currentY + vals[i + 1];
258
+ const cp2x = abs ? vals[i + 2] : currentX + vals[i + 2];
259
+ const cp2y = abs ? vals[i + 3] : currentY + vals[i + 3];
260
+ const x = abs ? vals[i + 4] : currentX + vals[i + 4];
261
+ const y = abs ? vals[i + 5] : currentY + vals[i + 5];
262
+ if (outTangents.length > 0) {
263
+ const prevIdx = outTangents.length - 1;
264
+ const prev = vertices[prevIdx];
265
+ outTangents[prevIdx] = [cp1x - prev[0], cp1y - prev[1]];
266
+ }
267
+ vertices.push([x, y]);
268
+ inTangents.push([cp2x - x, cp2y - y]);
269
+ outTangents.push([0, 0]);
270
+ currentX = x;
271
+ currentY = y;
283
272
  }
273
+ break;
274
+ }
275
+ case "Z":
276
+ case "z":
277
+ closed = true;
278
+ break;
284
279
  }
285
- return { c: closed, v: vertices, i: inTangents, o: outTangents };
280
+ }
281
+ return { c: closed, v: vertices, i: inTangents, o: outTangents };
286
282
  }
287
-
288
- export { NtdLottieIcon, exportToLottie, lottieToIcon };
283
+ export {
284
+ NtdLottieIcon,
285
+ exportToLottie,
286
+ lottieToIcon
287
+ };