@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,177 +1,180 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var React = require('react');
5
- var types = require('./types.js');
6
-
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");
7
6
  function parsePath(d) {
8
- const segments = [];
9
- const re = /([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g;
10
- let match;
11
- while ((match = re.exec(d)) !== null) {
12
- const command = match[1];
13
- const values = match[2]
14
- .trim()
15
- .split(/[\s,]+/)
16
- .filter(Boolean)
17
- .map(Number)
18
- .filter((n) => !isNaN(n));
19
- segments.push({ command, values });
20
- }
21
- return segments;
7
+ const segments = [];
8
+ const re = /([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g;
9
+ let match;
10
+ while ((match = re.exec(d)) !== null) {
11
+ const command = match[1];
12
+ const values = match[2].trim().split(/[\s,]+/).filter(Boolean).map(Number).filter((n) => !isNaN(n));
13
+ segments.push({ command, values });
14
+ }
15
+ return segments;
22
16
  }
23
17
  function interpolateSegments(from, to, t) {
24
- var _a, _b;
25
- const maxLen = Math.max(from.length, to.length);
26
- const result = [];
27
- for (let i = 0; i < maxLen; i++) {
28
- const f = from[i] || { values: [] };
29
- const tt = to[i] || { command: 'L', values: [] };
30
- // Use target command, interpolate values
31
- const command = tt.command;
32
- const maxVals = Math.max(f.values.length, tt.values.length);
33
- const values = [];
34
- for (let j = 0; j < maxVals; j++) {
35
- const fv = (_a = f.values[j]) !== null && _a !== void 0 ? _a : 0;
36
- const tv = (_b = tt.values[j]) !== null && _b !== void 0 ? _b : 0;
37
- values.push(fv + (tv - fv) * t);
38
- }
39
- result.push(command + values.map((v) => Math.round(v * 100) / 100).join(' '));
18
+ const maxLen = Math.max(from.length, to.length);
19
+ const result = [];
20
+ for (let i = 0; i < maxLen; i++) {
21
+ const f = from[i] || { values: [] };
22
+ const tt = to[i] || { command: "L", values: [] };
23
+ const command = tt.command;
24
+ const maxVals = Math.max(f.values.length, tt.values.length);
25
+ const values = [];
26
+ for (let j = 0; j < maxVals; j++) {
27
+ const fv = f.values[j] ?? 0;
28
+ const tv = tt.values[j] ?? 0;
29
+ values.push(fv + (tv - fv) * t);
40
30
  }
41
- return result.join('');
31
+ result.push(command + values.map((v) => Math.round(v * 100) / 100).join(" "));
32
+ }
33
+ return result.join("");
42
34
  }
43
- /* ────────────────────────────────────────────────────────────────────────────
44
- COMPONENT
45
- ───────────────────────────────────────────────────────────────────────────── */
46
35
  const NtdStateMorph = /* @__PURE__ */ Object.assign(
47
- /* @__PURE__ */ React.forwardRef(({ states, currentState, fills, strokes, strokeWidth = 2, duration = 300, easing: _easing = 'ease-in-out', size = 'md', viewBox = '0 0 24 24', className, style, 'aria-label': ariaLabel, onTransitionEnd, }, ref) => {
48
- var _a;
49
- const svgRef = React.useRef(null);
50
- const animRef = React.useRef(0);
51
- const [currentPath, setCurrentPath] = React.useState(() => { var _a; return (_a = states[currentState]) !== null && _a !== void 0 ? _a : ''; });
52
- const [currentFill, setCurrentFill] = React.useState(() => { var _a; return (_a = fills === null || fills === void 0 ? void 0 : fills[currentState]) !== null && _a !== void 0 ? _a : 'currentColor'; });
53
- const [currentStroke, setCurrentStroke] = React.useState(() => { var _a; return (_a = strokes === null || strokes === void 0 ? void 0 : strokes[currentState]) !== null && _a !== void 0 ? _a : 'none'; });
54
- const prevState = React.useRef(currentState);
55
- const resolvedSize = typeof size === 'number' ? size : ((_a = types.SIZE_MAP[size]) !== null && _a !== void 0 ? _a : 24);
56
- // Animate on state change
57
- React.useEffect(() => {
58
- var _a, _b, _c, _d, _e, _f;
36
+ /* @__PURE__ */ React.forwardRef(
37
+ ({
38
+ states,
39
+ currentState,
40
+ fills,
41
+ strokes,
42
+ strokeWidth = 2,
43
+ duration = 300,
44
+ easing: _easing = "ease-in-out",
45
+ size = "md",
46
+ viewBox = "0 0 24 24",
47
+ className,
48
+ style,
49
+ "aria-label": ariaLabel,
50
+ onTransitionEnd
51
+ }, ref) => {
52
+ const svgRef = React.useRef(null);
53
+ const animRef = React.useRef(0);
54
+ const [currentPath, setCurrentPath] = React.useState(() => states[currentState] ?? "");
55
+ const [currentFill, setCurrentFill] = React.useState(() => fills?.[currentState] ?? "currentColor");
56
+ const [currentStroke, setCurrentStroke] = React.useState(() => strokes?.[currentState] ?? "none");
57
+ const prevState = React.useRef(currentState);
58
+ const resolvedSize = typeof size === "number" ? size : types.SIZE_MAP[size] ?? 24;
59
+ React.useEffect(() => {
59
60
  if (prevState.current === currentState) {
60
- return;
61
+ return;
61
62
  }
62
- const fromPath = (_a = states[prevState.current]) !== null && _a !== void 0 ? _a : '';
63
- const toPath = (_b = states[currentState]) !== null && _b !== void 0 ? _b : '';
64
- const fromFill = (_c = fills === null || fills === void 0 ? void 0 : fills[prevState.current]) !== null && _c !== void 0 ? _c : 'currentColor';
65
- const toFill = (_d = fills === null || fills === void 0 ? void 0 : fills[currentState]) !== null && _d !== void 0 ? _d : 'currentColor';
66
- const fromStroke = (_e = strokes === null || strokes === void 0 ? void 0 : strokes[prevState.current]) !== null && _e !== void 0 ? _e : 'none';
67
- const toStroke = (_f = strokes === null || strokes === void 0 ? void 0 : strokes[currentState]) !== null && _f !== void 0 ? _f : 'none';
63
+ const fromPath = states[prevState.current] ?? "";
64
+ const toPath = states[currentState] ?? "";
65
+ const fromFill = fills?.[prevState.current] ?? "currentColor";
66
+ const toFill = fills?.[currentState] ?? "currentColor";
67
+ const fromStroke = strokes?.[prevState.current] ?? "none";
68
+ const toStroke = strokes?.[currentState] ?? "none";
68
69
  const fromSegs = parsePath(fromPath);
69
70
  const toSegs = parsePath(toPath);
70
71
  const startTime = performance.now();
71
72
  prevState.current = currentState;
72
- // Cancel previous animation
73
73
  if (animRef.current) {
74
- cancelAnimationFrame(animRef.current);
74
+ cancelAnimationFrame(animRef.current);
75
75
  }
76
76
  function animate(now) {
77
- const elapsed = now - startTime;
78
- const rawT = Math.min(elapsed / duration, 1);
79
- // Apply easing (simple cubic ease-in-out)
80
- const t = rawT < 0.5 ? 4 * rawT * rawT * rawT : 1 - Math.pow(-2 * rawT + 2, 3) / 2;
81
- setCurrentPath(interpolateSegments(fromSegs, toSegs, t));
82
- // Interpolate fill if both are hex colors
83
- if (fromFill.startsWith('#') && toFill.startsWith('#')) {
84
- setCurrentFill(interpolateColor(fromFill, toFill, t));
85
- }
86
- else {
87
- setCurrentFill(t > 0.5 ? toFill : fromFill);
88
- }
89
- if (fromStroke.startsWith('#') && toStroke.startsWith('#')) {
90
- setCurrentStroke(interpolateColor(fromStroke, toStroke, t));
91
- }
92
- else {
93
- setCurrentStroke(t > 0.5 ? toStroke : fromStroke);
94
- }
95
- if (rawT < 1) {
96
- animRef.current = requestAnimationFrame(animate);
97
- }
98
- else {
99
- onTransitionEnd === null || onTransitionEnd === void 0 ? void 0 : onTransitionEnd(currentState);
100
- }
77
+ const elapsed = now - startTime;
78
+ const rawT = Math.min(elapsed / duration, 1);
79
+ const t = rawT < 0.5 ? 4 * rawT * rawT * rawT : 1 - Math.pow(-2 * rawT + 2, 3) / 2;
80
+ setCurrentPath(interpolateSegments(fromSegs, toSegs, t));
81
+ if (fromFill.startsWith("#") && toFill.startsWith("#")) {
82
+ setCurrentFill(interpolateColor(fromFill, toFill, t));
83
+ } else {
84
+ setCurrentFill(t > 0.5 ? toFill : fromFill);
85
+ }
86
+ if (fromStroke.startsWith("#") && toStroke.startsWith("#")) {
87
+ setCurrentStroke(interpolateColor(fromStroke, toStroke, t));
88
+ } else {
89
+ setCurrentStroke(t > 0.5 ? toStroke : fromStroke);
90
+ }
91
+ if (rawT < 1) {
92
+ animRef.current = requestAnimationFrame(animate);
93
+ } else {
94
+ onTransitionEnd?.(currentState);
95
+ }
101
96
  }
102
97
  animRef.current = requestAnimationFrame(animate);
103
98
  return () => {
104
- if (animRef.current) {
105
- cancelAnimationFrame(animRef.current);
106
- }
99
+ if (animRef.current) {
100
+ cancelAnimationFrame(animRef.current);
101
+ }
107
102
  };
108
- }, [currentState, states, fills, strokes, duration, onTransitionEnd]);
109
- React.useImperativeHandle(ref, () => ({
103
+ }, [currentState, states, fills, strokes, duration, onTransitionEnd]);
104
+ React.useImperativeHandle(ref, () => ({
110
105
  getState: () => currentState,
111
- setState: () => { },
112
- getSvgElement: () => svgRef.current,
113
- }));
114
- return (jsxRuntime.jsx("svg", { ref: svgRef, xmlns: "http://www.w3.org/2000/svg", viewBox: viewBox, width: resolvedSize, height: resolvedSize, fill: "none", className: className, style: style, "aria-label": ariaLabel, role: ariaLabel ? 'img' : undefined, children: jsxRuntime.jsx("path", { d: currentPath, fill: currentFill, stroke: currentStroke, strokeWidth: strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" }) }));
115
- }), { displayName: 'NtdStateMorph' });
116
- /* ────────────────────────────────────────────────────────────────────────────
117
- COLOR INTERPOLATION
118
- ───────────────────────────────────────────────────────────────────────────── */
106
+ setState: () => {
107
+ },
108
+ getSvgElement: () => svgRef.current
109
+ }));
110
+ return /* @__PURE__ */ jsxRuntime.jsx(
111
+ "svg",
112
+ {
113
+ ref: svgRef,
114
+ xmlns: "http://www.w3.org/2000/svg",
115
+ viewBox,
116
+ width: resolvedSize,
117
+ height: resolvedSize,
118
+ fill: "none",
119
+ className,
120
+ style,
121
+ "aria-label": ariaLabel,
122
+ role: ariaLabel ? "img" : void 0,
123
+ children: /* @__PURE__ */ jsxRuntime.jsx(
124
+ "path",
125
+ {
126
+ d: currentPath,
127
+ fill: currentFill,
128
+ stroke: currentStroke,
129
+ strokeWidth,
130
+ strokeLinecap: "round",
131
+ strokeLinejoin: "round"
132
+ }
133
+ )
134
+ }
135
+ );
136
+ }
137
+ ),
138
+ { displayName: "NtdStateMorph" }
139
+ );
119
140
  function hexToRgb(hex) {
120
- const h = hex.replace('#', '');
121
- const full = h.length === 3 ? h[0] + h[0] + h[1] + h[1] + h[2] + h[2] : h;
122
- return [
123
- parseInt(full.substring(0, 2), 16),
124
- parseInt(full.substring(2, 4), 16),
125
- parseInt(full.substring(4, 6), 16),
126
- ];
141
+ const h = hex.replace("#", "");
142
+ const full = h.length === 3 ? h[0] + h[0] + h[1] + h[1] + h[2] + h[2] : h;
143
+ return [
144
+ parseInt(full.substring(0, 2), 16),
145
+ parseInt(full.substring(2, 4), 16),
146
+ parseInt(full.substring(4, 6), 16)
147
+ ];
127
148
  }
128
149
  function rgbToHex(r, g, b) {
129
- const toHex = (n) => Math.round(Math.max(0, Math.min(255, n)))
130
- .toString(16)
131
- .padStart(2, '0');
132
- return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
150
+ const toHex = (n) => Math.round(Math.max(0, Math.min(255, n))).toString(16).padStart(2, "0");
151
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
133
152
  }
134
153
  function interpolateColor(from, to, t) {
135
- const [fr, fg, fb] = hexToRgb(from);
136
- const [tr, tg, tb] = hexToRgb(to);
137
- return rgbToHex(fr + (tr - fr) * t, fg + (tg - fg) * t, fb + (tb - fb) * t);
154
+ const [fr, fg, fb] = hexToRgb(from);
155
+ const [tr, tg, tb] = hexToRgb(to);
156
+ return rgbToHex(fr + (tr - fr) * t, fg + (tg - fg) * t, fb + (tb - fb) * t);
138
157
  }
139
- /* ────────────────────────────────────────────────────────────────────────────
140
- HOOK — useStateMorph
141
- ───────────────────────────────────────────────────────────────────────────── */
142
- /**
143
- * Hook for managing morph state transitions.
144
- *
145
- * @example
146
- * ```tsx
147
- * const { state, setState, toggle, props } = useStateMorph(
148
- * { empty: emptyPath, filled: filledPath },
149
- * 'empty',
150
- * { fills: { empty: 'none', filled: '#e74c3c' } },
151
- * );
152
- *
153
- * <NtdStateMorph {...props} />
154
- * <button onClick={toggle}>Toggle</button>
155
- * ```
156
- */
157
158
  function useStateMorph(states, initialState, options) {
158
- const stateNames = React.useMemo(() => Object.keys(states), [states]);
159
- const [state, setState] = React.useState(initialState);
160
- const toggle = React.useCallback(() => {
161
- setState((prev) => {
162
- const idx = stateNames.indexOf(prev);
163
- return stateNames[(idx + 1) % stateNames.length];
164
- });
165
- }, [stateNames]);
166
- const props = React.useMemo(() => ({
167
- states,
168
- currentState: state,
169
- fills: options === null || options === void 0 ? void 0 : options.fills,
170
- strokes: options === null || options === void 0 ? void 0 : options.strokes,
171
- duration: options === null || options === void 0 ? void 0 : options.duration,
172
- }), [states, state, options]);
173
- return { state, setState, toggle, props, stateNames };
159
+ const stateNames = React.useMemo(() => Object.keys(states), [states]);
160
+ const [state, setState] = React.useState(initialState);
161
+ const toggle = React.useCallback(() => {
162
+ setState((prev) => {
163
+ const idx = stateNames.indexOf(prev);
164
+ return stateNames[(idx + 1) % stateNames.length];
165
+ });
166
+ }, [stateNames]);
167
+ const props = React.useMemo(
168
+ () => ({
169
+ states,
170
+ currentState: state,
171
+ fills: options?.fills,
172
+ strokes: options?.strokes,
173
+ duration: options?.duration
174
+ }),
175
+ [states, state, options]
176
+ );
177
+ return { state, setState, toggle, props, stateNames };
174
178
  }
175
-
176
179
  exports.NtdStateMorph = NtdStateMorph;
177
180
  exports.useStateMorph = useStateMorph;