@nice2dev/icons 1.3.15 → 1.3.17

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