@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,693 +1,569 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var React = require('react');
5
-
6
- /* ────────────────────────────────────────────────────────────────────────────
7
- 2. HELPER FUNCTIONS
8
- ───────────────────────────────────────────────────────────────────────────── */
9
- /**
10
- * Build CSS class for animation
11
- */
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
12
5
  function getAnimationClass(animation) {
13
- return `ntd-anim-${animation}`;
6
+ return `ntd-anim-${animation}`;
14
7
  }
15
- /**
16
- * Build inline animation style
17
- */
18
- function getAnimationStyle(animation, duration = 1000, easing = 'ease-in-out', iterations = 1, delay = 0) {
19
- const iterationValue = iterations < 0 ? 'infinite' : iterations;
20
- return {
21
- animationName: `ntd-${animation}`,
22
- animationDuration: `${duration}ms`,
23
- animationTimingFunction: easing,
24
- animationIterationCount: iterationValue,
25
- animationDelay: `${delay}ms`,
26
- animationFillMode: 'forwards',
27
- };
8
+ function getAnimationStyle(animation, duration = 1e3, easing = "ease-in-out", iterations = 1, delay = 0) {
9
+ const iterationValue = iterations < 0 ? "infinite" : iterations;
10
+ return {
11
+ animationName: `ntd-${animation}`,
12
+ animationDuration: `${duration}ms`,
13
+ animationTimingFunction: easing,
14
+ animationIterationCount: iterationValue,
15
+ animationDelay: `${delay}ms`,
16
+ animationFillMode: "forwards"
17
+ };
28
18
  }
29
- /**
30
- * Check if config is a sequence
31
- */
32
19
  function isSequenceConfig(config) {
33
- return typeof config === 'object' && 'steps' in config;
20
+ return typeof config === "object" && "steps" in config;
34
21
  }
35
- /* ────────────────────────────────────────────────────────────────────────────
36
- 3. ANIMATION SEQUENCE HOOK
37
- ───────────────────────────────────────────────────────────────────────────── */
38
- /**
39
- * Hook to manage animation sequences
40
- */
41
22
  function useAnimationSequence(config) {
42
- const [currentStepIndex, setCurrentStepIndex] = React.useState(0);
43
- const [loopIteration, setLoopIteration] = React.useState(0);
44
- const [state, setState] = React.useState('idle');
45
- const [direction, setDirection] = React.useState('forward');
46
- const timeoutRef = React.useRef(null);
47
- const startTimeRef = React.useRef(0);
48
- const elapsedRef = React.useRef(0);
49
- const steps = React.useMemo(() => {
50
- if (config.direction === 'reverse') {
51
- return [...config.steps].reverse();
52
- }
53
- return config.steps;
54
- }, [config.steps, config.direction]);
55
- const currentStep = steps[currentStepIndex];
56
- const clearTimer = React.useCallback(() => {
57
- if (timeoutRef.current) {
58
- clearTimeout(timeoutRef.current);
59
- timeoutRef.current = null;
60
- }
61
- }, []);
62
- const play = React.useCallback(() => {
63
- if (state === 'finished') {
64
- // Reset if finished
65
- setCurrentStepIndex(0);
66
- setLoopIteration(0);
67
- elapsedRef.current = 0;
68
- }
69
- setState('playing');
70
- startTimeRef.current = Date.now();
71
- }, [state]);
72
- const pause = React.useCallback(() => {
73
- if (state === 'playing') {
74
- clearTimer();
75
- elapsedRef.current += Date.now() - startTimeRef.current;
76
- setState('paused');
77
- }
78
- }, [state, clearTimer]);
79
- const reset = React.useCallback(() => {
23
+ const [currentStepIndex, setCurrentStepIndex] = React.useState(0);
24
+ const [loopIteration, setLoopIteration] = React.useState(0);
25
+ const [state, setState] = React.useState("idle");
26
+ const [direction, setDirection] = React.useState("forward");
27
+ const timeoutRef = React.useRef(null);
28
+ const startTimeRef = React.useRef(0);
29
+ const elapsedRef = React.useRef(0);
30
+ const steps = React.useMemo(() => {
31
+ if (config.direction === "reverse") {
32
+ return [...config.steps].reverse();
33
+ }
34
+ return config.steps;
35
+ }, [config.steps, config.direction]);
36
+ const currentStep = steps[currentStepIndex];
37
+ const clearTimer = React.useCallback(() => {
38
+ if (timeoutRef.current) {
39
+ clearTimeout(timeoutRef.current);
40
+ timeoutRef.current = null;
41
+ }
42
+ }, []);
43
+ const play = React.useCallback(() => {
44
+ if (state === "finished") {
45
+ setCurrentStepIndex(0);
46
+ setLoopIteration(0);
47
+ elapsedRef.current = 0;
48
+ }
49
+ setState("playing");
50
+ startTimeRef.current = Date.now();
51
+ }, [state]);
52
+ const pause = React.useCallback(() => {
53
+ if (state === "playing") {
54
+ clearTimer();
55
+ elapsedRef.current += Date.now() - startTimeRef.current;
56
+ setState("paused");
57
+ }
58
+ }, [state, clearTimer]);
59
+ const reset = React.useCallback(() => {
60
+ clearTimer();
61
+ setCurrentStepIndex(0);
62
+ setLoopIteration(0);
63
+ setDirection("forward");
64
+ elapsedRef.current = 0;
65
+ setState("idle");
66
+ }, [clearTimer]);
67
+ const goToStep = React.useCallback(
68
+ (index) => {
69
+ if (index >= 0 && index < steps.length) {
80
70
  clearTimer();
81
- setCurrentStepIndex(0);
82
- setLoopIteration(0);
83
- setDirection('forward');
71
+ setCurrentStepIndex(index);
84
72
  elapsedRef.current = 0;
85
- setState('idle');
86
- }, [clearTimer]);
87
- const goToStep = React.useCallback((index) => {
88
- if (index >= 0 && index < steps.length) {
89
- clearTimer();
90
- setCurrentStepIndex(index);
91
- elapsedRef.current = 0;
92
- if (state === 'playing') {
93
- startTimeRef.current = Date.now();
94
- }
95
- }
96
- }, [steps.length, clearTimer, state]);
97
- const getProgress = React.useCallback(() => {
98
- if (state === 'idle') {
99
- return 0;
100
- }
101
- if (state === 'finished') {
102
- return 1;
103
- }
104
- const stepProgress = currentStepIndex / steps.length;
105
- return stepProgress;
106
- }, [state, currentStepIndex, steps.length]);
107
- // Handle step progression
108
- React.useEffect(() => {
109
- if (state !== 'playing' || !currentStep) {
110
- return;
111
- }
112
- const stepDuration = (currentStep.duration || 1000) * (currentStep.iterations || 1);
113
- const remainingTime = stepDuration - elapsedRef.current;
114
- timeoutRef.current = setTimeout(() => {
115
- elapsedRef.current = 0;
116
- // Determine next step
117
- let nextStepIndex;
118
- if (config.direction === 'alternate') {
119
- if (direction === 'forward') {
120
- if (currentStepIndex >= steps.length - 1) {
121
- setDirection('backward');
122
- nextStepIndex = currentStepIndex - 1;
123
- }
124
- else {
125
- nextStepIndex = currentStepIndex + 1;
126
- }
127
- }
128
- else {
129
- if (currentStepIndex <= 0) {
130
- setDirection('forward');
131
- nextStepIndex = currentStepIndex + 1;
132
- }
133
- else {
134
- nextStepIndex = currentStepIndex - 1;
135
- }
136
- }
137
- }
138
- else {
139
- nextStepIndex = currentStepIndex + 1;
140
- }
141
- // Check if sequence complete
142
- if (nextStepIndex >= steps.length && config.direction !== 'alternate') {
143
- if (config.loop) {
144
- const newIteraton = loopIteration + 1;
145
- if (config.loopCount && newIteraton >= config.loopCount) {
146
- setState('finished');
147
- }
148
- else {
149
- setLoopIteration(newIteraton);
150
- setCurrentStepIndex(0);
151
- // Apply loop delay
152
- if (config.loopDelay) {
153
- setState('paused');
154
- timeoutRef.current = setTimeout(() => {
155
- setState('playing');
156
- startTimeRef.current = Date.now();
157
- }, config.loopDelay);
158
- }
159
- else {
160
- startTimeRef.current = Date.now();
161
- }
162
- }
163
- }
164
- else {
165
- setState('finished');
166
- }
167
- }
168
- else if (nextStepIndex >= 0 && nextStepIndex < steps.length) {
169
- setCurrentStepIndex(nextStepIndex);
170
- startTimeRef.current = Date.now();
171
- }
172
- }, remainingTime + (currentStep.delay || 0));
173
- return clearTimer;
174
- }, [
175
- state,
176
- currentStep,
177
- currentStepIndex,
178
- steps.length,
179
- direction,
180
- config.loop,
181
- config.loopCount,
182
- config.loopDelay,
183
- config.direction,
184
- loopIteration,
185
- clearTimer,
186
- ]);
187
- return {
188
- currentStep,
189
- currentStepIndex,
190
- state,
191
- loopIteration,
192
- play,
193
- pause,
194
- reset,
195
- goToStep,
196
- getProgress,
197
- };
198
- }
199
- /* ────────────────────────────────────────────────────────────────────────────
200
- 4. ANIMATION CONTROLLER COMPONENT
201
- ───────────────────────────────────────────────────────────────────────────── */
202
- /**
203
- * Animation Controller component
204
- *
205
- * Wraps an icon and provides play/pause/reset controls.
206
- *
207
- * @example
208
- * ```tsx
209
- * const ref = useRef<AnimationControllerHandle>(null);
210
- *
211
- * <AnimationController
212
- * ref={ref}
213
- * animation="spin"
214
- * autoPlay={false}
215
- * >
216
- * <NiceIcon name="loading" />
217
- * </AnimationController>
218
- *
219
- * <button onClick={() => ref.current?.play()}>Play</button>
220
- * <button onClick={() => ref.current?.pause()}>Pause</button>
221
- * <button onClick={() => ref.current?.reset()}>Reset</button>
222
- * ```
223
- *
224
- * @example Sequence
225
- * ```tsx
226
- * <AnimationController
227
- * animation={{
228
- * steps: [
229
- * { animation: 'bounce', duration: 500 },
230
- * { animation: 'spin', duration: 1000 },
231
- * { animation: 'pulse', duration: 800 },
232
- * ],
233
- * loop: true,
234
- * loopCount: 3
235
- * }}
236
- * autoPlay
237
- * >
238
- * <NiceIcon name="star" />
239
- * </AnimationController>
240
- * ```
241
- */
242
- const AnimationController = /* @__PURE__ */ React.forwardRef(function AnimationController(props, ref) {
243
- const { children, animation, autoPlay = false, playState: externalPlayState, onStart, onEnd, onStepChange, onPause, onResume, className, style, } = props;
244
- // Determine if sequence or single animation
245
- const isSequence = isSequenceConfig(animation);
246
- // For single animations
247
- const [singleState, setSingleState] = React.useState(autoPlay ? 'playing' : 'idle');
248
- const singleIterationRef = React.useRef(0);
249
- // For sequences
250
- const sequenceConfig = isSequence ? animation : { steps: [{ animation, duration: 1000 }] };
251
- const sequence = useAnimationSequence(sequenceConfig);
252
- // Unified state
253
- const state = isSequence ? sequence.state : singleState;
254
- const currentStepIndex = isSequence ? sequence.currentStepIndex : 0;
255
- // Handle external playState control
256
- React.useEffect(() => {
257
- if (externalPlayState !== undefined) {
258
- if (isSequence) {
259
- if (externalPlayState === 'playing') {
260
- sequence.play();
261
- }
262
- else if (externalPlayState === 'paused') {
263
- sequence.pause();
264
- }
265
- else if (externalPlayState === 'idle') {
266
- sequence.reset();
267
- }
268
- }
269
- else {
270
- setSingleState(externalPlayState);
271
- }
73
+ if (state === "playing") {
74
+ startTimeRef.current = Date.now();
272
75
  }
273
- }, [externalPlayState, isSequence, sequence]);
274
- // Auto-play
275
- React.useEffect(() => {
276
- if (autoPlay) {
277
- if (isSequence) {
278
- sequence.play();
279
- }
280
- else {
281
- setSingleState('playing');
282
- }
283
- onStart === null || onStart === void 0 ? void 0 : onStart();
284
- }
285
- // eslint-disable-next-line react-hooks/exhaustive-deps
286
- }, []);
287
- // Step change callback
288
- const prevStepRef = React.useRef(currentStepIndex);
289
- React.useEffect(() => {
290
- if (prevStepRef.current !== currentStepIndex && isSequence) {
291
- const step = sequenceConfig.steps[currentStepIndex];
292
- onStepChange === null || onStepChange === void 0 ? void 0 : onStepChange(currentStepIndex, step);
293
- }
294
- prevStepRef.current = currentStepIndex;
295
- }, [currentStepIndex, isSequence, sequenceConfig.steps, onStepChange]);
296
- // State change callbacks
297
- const prevStateRef = React.useRef(state);
298
- React.useEffect(() => {
299
- if (prevStateRef.current !== state) {
300
- if (state === 'playing' && prevStateRef.current === 'paused') {
301
- onResume === null || onResume === void 0 ? void 0 : onResume();
302
- }
303
- else if (state === 'paused' && prevStateRef.current === 'playing') {
304
- onPause === null || onPause === void 0 ? void 0 : onPause();
305
- }
306
- else if (state === 'finished') {
307
- onEnd === null || onEnd === void 0 ? void 0 : onEnd();
76
+ }
77
+ },
78
+ [steps.length, clearTimer, state]
79
+ );
80
+ const getProgress = React.useCallback(() => {
81
+ if (state === "idle") {
82
+ return 0;
83
+ }
84
+ if (state === "finished") {
85
+ return 1;
86
+ }
87
+ const stepProgress = currentStepIndex / steps.length;
88
+ return stepProgress;
89
+ }, [state, currentStepIndex, steps.length]);
90
+ React.useEffect(() => {
91
+ if (state !== "playing" || !currentStep) {
92
+ return;
93
+ }
94
+ const stepDuration = (currentStep.duration || 1e3) * (currentStep.iterations || 1);
95
+ const remainingTime = stepDuration - elapsedRef.current;
96
+ timeoutRef.current = setTimeout(
97
+ () => {
98
+ elapsedRef.current = 0;
99
+ let nextStepIndex;
100
+ if (config.direction === "alternate") {
101
+ if (direction === "forward") {
102
+ if (currentStepIndex >= steps.length - 1) {
103
+ setDirection("backward");
104
+ nextStepIndex = currentStepIndex - 1;
105
+ } else {
106
+ nextStepIndex = currentStepIndex + 1;
308
107
  }
309
- else if (state === 'playing' && prevStateRef.current === 'idle') {
310
- onStart === null || onStart === void 0 ? void 0 : onStart();
108
+ } else {
109
+ if (currentStepIndex <= 0) {
110
+ setDirection("forward");
111
+ nextStepIndex = currentStepIndex + 1;
112
+ } else {
113
+ nextStepIndex = currentStepIndex - 1;
311
114
  }
115
+ }
116
+ } else {
117
+ nextStepIndex = currentStepIndex + 1;
312
118
  }
313
- prevStateRef.current = state;
314
- }, [state, onStart, onEnd, onPause, onResume]);
315
- // Imperative handle
316
- React.useImperativeHandle(ref, () => ({
317
- play: () => {
318
- if (isSequence) {
319
- sequence.play();
320
- }
321
- else {
322
- setSingleState('playing');
323
- singleIterationRef.current++;
324
- }
325
- onStart === null || onStart === void 0 ? void 0 : onStart();
326
- },
327
- pause: () => {
328
- if (isSequence) {
329
- sequence.pause();
330
- }
331
- else {
332
- setSingleState('paused');
333
- }
334
- onPause === null || onPause === void 0 ? void 0 : onPause();
335
- },
336
- reset: () => {
337
- if (isSequence) {
338
- sequence.reset();
339
- }
340
- else {
341
- setSingleState('idle');
342
- singleIterationRef.current++;
343
- }
344
- },
345
- goToStep: (index) => {
346
- if (isSequence) {
347
- sequence.goToStep(index);
348
- }
349
- },
350
- getState: () => state,
351
- getCurrentStep: () => currentStepIndex,
352
- getProgress: () => {
353
- if (isSequence) {
354
- return sequence.getProgress();
119
+ if (nextStepIndex >= steps.length && config.direction !== "alternate") {
120
+ if (config.loop) {
121
+ const newIteraton = loopIteration + 1;
122
+ if (config.loopCount && newIteraton >= config.loopCount) {
123
+ setState("finished");
124
+ } else {
125
+ setLoopIteration(newIteraton);
126
+ setCurrentStepIndex(0);
127
+ if (config.loopDelay) {
128
+ setState("paused");
129
+ timeoutRef.current = setTimeout(() => {
130
+ setState("playing");
131
+ startTimeRef.current = Date.now();
132
+ }, config.loopDelay);
133
+ } else {
134
+ startTimeRef.current = Date.now();
135
+ }
355
136
  }
356
- return state === 'playing' ? 0.5 : state === 'finished' ? 1 : 0;
357
- },
358
- }));
359
- // Build animation styles
360
- const animationStyles = React.useMemo(() => {
361
- if (state === 'idle') {
362
- return {};
137
+ } else {
138
+ setState("finished");
139
+ }
140
+ } else if (nextStepIndex >= 0 && nextStepIndex < steps.length) {
141
+ setCurrentStepIndex(nextStepIndex);
142
+ startTimeRef.current = Date.now();
363
143
  }
364
- if (state === 'paused') {
365
- return { animationPlayState: 'paused' };
366
- }
367
- if (isSequence && sequence.currentStep) {
368
- const step = sequence.currentStep;
369
- return getAnimationStyle(step.animation, step.duration, step.easing, step.iterations, step.delay);
370
- }
371
- if (!isSequence) {
372
- return getAnimationStyle(animation, 1000, 'ease-in-out', -1);
144
+ },
145
+ remainingTime + (currentStep.delay || 0)
146
+ );
147
+ return clearTimer;
148
+ }, [
149
+ state,
150
+ currentStep,
151
+ currentStepIndex,
152
+ steps.length,
153
+ direction,
154
+ config.loop,
155
+ config.loopCount,
156
+ config.loopDelay,
157
+ config.direction,
158
+ loopIteration,
159
+ clearTimer
160
+ ]);
161
+ return {
162
+ currentStep,
163
+ currentStepIndex,
164
+ state,
165
+ loopIteration,
166
+ play,
167
+ pause,
168
+ reset,
169
+ goToStep,
170
+ getProgress
171
+ };
172
+ }
173
+ const AnimationController = /* @__PURE__ */ React.forwardRef(function AnimationController2(props, ref) {
174
+ const {
175
+ children,
176
+ animation,
177
+ autoPlay = false,
178
+ playState: externalPlayState,
179
+ onStart,
180
+ onEnd,
181
+ onStepChange,
182
+ onPause,
183
+ onResume,
184
+ className,
185
+ style
186
+ } = props;
187
+ const isSequence = isSequenceConfig(animation);
188
+ const [singleState, setSingleState] = React.useState(
189
+ autoPlay ? "playing" : "idle"
190
+ );
191
+ const singleIterationRef = React.useRef(0);
192
+ const sequenceConfig = isSequence ? animation : { steps: [{ animation, duration: 1e3 }] };
193
+ const sequence = useAnimationSequence(sequenceConfig);
194
+ const state = isSequence ? sequence.state : singleState;
195
+ const currentStepIndex = isSequence ? sequence.currentStepIndex : 0;
196
+ React.useEffect(() => {
197
+ if (externalPlayState !== void 0) {
198
+ if (isSequence) {
199
+ if (externalPlayState === "playing") {
200
+ sequence.play();
201
+ } else if (externalPlayState === "paused") {
202
+ sequence.pause();
203
+ } else if (externalPlayState === "idle") {
204
+ sequence.reset();
373
205
  }
374
- return {};
375
- }, [state, isSequence, sequence.currentStep, animation]);
376
- // Animation class
377
- const animationClass = state === 'playing' || state === 'paused'
378
- ? isSequence && sequence.currentStep
379
- ? getAnimationClass(sequence.currentStep.animation)
380
- : getAnimationClass(animation)
381
- : '';
382
- // Clone child with animation props
383
- const animatedChild = React.cloneElement(children, {
384
- className: `${children.props.className || ''} ${animationClass}`.trim(),
385
- style: {
386
- ...children.props.style,
387
- ...animationStyles,
388
- },
389
- key: isSequence
390
- ? `seq-${currentStepIndex}-${sequence.loopIteration}`
391
- : `single-${singleIterationRef.current}`,
392
- });
393
- return (jsxRuntime.jsx("span", { className: `ntd-animation-controller ntd-animation-${state} ${className || ''}`.trim(), style: style, children: animatedChild }));
206
+ } else {
207
+ setSingleState(externalPlayState);
208
+ }
209
+ }
210
+ }, [externalPlayState, isSequence, sequence]);
211
+ React.useEffect(() => {
212
+ if (autoPlay) {
213
+ if (isSequence) {
214
+ sequence.play();
215
+ } else {
216
+ setSingleState("playing");
217
+ }
218
+ onStart?.();
219
+ }
220
+ }, []);
221
+ const prevStepRef = React.useRef(currentStepIndex);
222
+ React.useEffect(() => {
223
+ if (prevStepRef.current !== currentStepIndex && isSequence) {
224
+ const step = sequenceConfig.steps[currentStepIndex];
225
+ onStepChange?.(currentStepIndex, step);
226
+ }
227
+ prevStepRef.current = currentStepIndex;
228
+ }, [currentStepIndex, isSequence, sequenceConfig.steps, onStepChange]);
229
+ const prevStateRef = React.useRef(state);
230
+ React.useEffect(() => {
231
+ if (prevStateRef.current !== state) {
232
+ if (state === "playing" && prevStateRef.current === "paused") {
233
+ onResume?.();
234
+ } else if (state === "paused" && prevStateRef.current === "playing") {
235
+ onPause?.();
236
+ } else if (state === "finished") {
237
+ onEnd?.();
238
+ } else if (state === "playing" && prevStateRef.current === "idle") {
239
+ onStart?.();
240
+ }
241
+ }
242
+ prevStateRef.current = state;
243
+ }, [state, onStart, onEnd, onPause, onResume]);
244
+ React.useImperativeHandle(ref, () => ({
245
+ play: () => {
246
+ if (isSequence) {
247
+ sequence.play();
248
+ } else {
249
+ setSingleState("playing");
250
+ singleIterationRef.current++;
251
+ }
252
+ onStart?.();
253
+ },
254
+ pause: () => {
255
+ if (isSequence) {
256
+ sequence.pause();
257
+ } else {
258
+ setSingleState("paused");
259
+ }
260
+ onPause?.();
261
+ },
262
+ reset: () => {
263
+ if (isSequence) {
264
+ sequence.reset();
265
+ } else {
266
+ setSingleState("idle");
267
+ singleIterationRef.current++;
268
+ }
269
+ },
270
+ goToStep: (index) => {
271
+ if (isSequence) {
272
+ sequence.goToStep(index);
273
+ }
274
+ },
275
+ getState: () => state,
276
+ getCurrentStep: () => currentStepIndex,
277
+ getProgress: () => {
278
+ if (isSequence) {
279
+ return sequence.getProgress();
280
+ }
281
+ return state === "playing" ? 0.5 : state === "finished" ? 1 : 0;
282
+ }
283
+ }));
284
+ const animationStyles = React.useMemo(() => {
285
+ if (state === "idle") {
286
+ return {};
287
+ }
288
+ if (state === "paused") {
289
+ return { animationPlayState: "paused" };
290
+ }
291
+ if (isSequence && sequence.currentStep) {
292
+ const step = sequence.currentStep;
293
+ return getAnimationStyle(
294
+ step.animation,
295
+ step.duration,
296
+ step.easing,
297
+ step.iterations,
298
+ step.delay
299
+ );
300
+ }
301
+ if (!isSequence) {
302
+ return getAnimationStyle(animation, 1e3, "ease-in-out", -1);
303
+ }
304
+ return {};
305
+ }, [state, isSequence, sequence.currentStep, animation]);
306
+ const animationClass = state === "playing" || state === "paused" ? isSequence && sequence.currentStep ? getAnimationClass(sequence.currentStep.animation) : getAnimationClass(animation) : "";
307
+ const animatedChild = React.cloneElement(children, {
308
+ className: `${children.props.className || ""} ${animationClass}`.trim(),
309
+ style: {
310
+ ...children.props.style,
311
+ ...animationStyles
312
+ },
313
+ key: isSequence ? `seq-${currentStepIndex}-${sequence.loopIteration}` : `single-${singleIterationRef.current}`
314
+ });
315
+ return /* @__PURE__ */ jsxRuntime.jsx(
316
+ "span",
317
+ {
318
+ className: `ntd-animation-controller ntd-animation-${state} ${className || ""}`.trim(),
319
+ style,
320
+ children: animatedChild
321
+ }
322
+ );
394
323
  });
395
- /* ────────────────────────────────────────────────────────────────────────────
396
- 5. INTERACTIVE ICON COMPONENT
397
- ───────────────────────────────────────────────────────────────────────────── */
398
- /**
399
- * Interactive icon wrapper with hover/click/focus triggers
400
- *
401
- * @example
402
- * ```tsx
403
- * <InteractiveIcon
404
- * config={{
405
- * trigger: 'hover',
406
- * enterAnimation: 'bounce',
407
- * leaveAnimation: 'fadeOut',
408
- * }}
409
- * >
410
- * <NiceIcon name="heart" />
411
- * </InteractiveIcon>
412
- * ```
413
- *
414
- * @example Click
415
- * ```tsx
416
- * <InteractiveIcon
417
- * config={{
418
- * trigger: 'click',
419
- * enterAnimation: 'pulse',
420
- * once: true,
421
- * }}
422
- * >
423
- * <NiceIcon name="notification" />
424
- * </InteractiveIcon>
425
- * ```
426
- */
427
- const InteractiveIcon = /* @__PURE__ */ React.forwardRef(function InteractiveIcon(props, ref) {
428
- const { children, config, disabled = false, onInteractionStart, onInteractionEnd, className, style, } = props;
324
+ const InteractiveIcon = /* @__PURE__ */ React.forwardRef(
325
+ function InteractiveIcon2(props, ref) {
326
+ const {
327
+ children,
328
+ config,
329
+ disabled = false,
330
+ onInteractionStart,
331
+ onInteractionEnd,
332
+ className,
333
+ style
334
+ } = props;
429
335
  const [isActive, setIsActive] = React.useState(false);
430
336
  const [isLeaving, setIsLeaving] = React.useState(false);
431
337
  const [hasPlayed, setHasPlayed] = React.useState(false);
432
338
  const wrapperRef = React.useRef(null);
433
339
  const timeoutRef = React.useRef(null);
434
- // Merge refs
435
- const setRefs = React.useCallback((node) => {
340
+ const setRefs = React.useCallback(
341
+ (node) => {
436
342
  wrapperRef.current = node;
437
- if (typeof ref === 'function') {
438
- ref(node);
343
+ if (typeof ref === "function") {
344
+ ref(node);
345
+ } else if (ref) {
346
+ ref.current = node;
439
347
  }
440
- else if (ref) {
441
- ref.current = node;
442
- }
443
- }, [ref]);
444
- // Clear any pending timeouts
348
+ },
349
+ [ref]
350
+ );
445
351
  const clearTimer = React.useCallback(() => {
446
- if (timeoutRef.current) {
447
- clearTimeout(timeoutRef.current);
448
- timeoutRef.current = null;
449
- }
352
+ if (timeoutRef.current) {
353
+ clearTimeout(timeoutRef.current);
354
+ timeoutRef.current = null;
355
+ }
450
356
  }, []);
451
357
  React.useEffect(() => clearTimer, [clearTimer]);
452
- // Handle activation
453
358
  const activate = React.useCallback(() => {
454
- if (disabled) {
455
- return;
456
- }
457
- if (config.once && hasPlayed) {
458
- return;
459
- }
460
- clearTimer();
461
- setIsLeaving(false);
462
- if (config.delay) {
463
- timeoutRef.current = setTimeout(() => {
464
- setIsActive(true);
465
- setHasPlayed(true);
466
- onInteractionStart === null || onInteractionStart === void 0 ? void 0 : onInteractionStart();
467
- }, config.delay);
468
- }
469
- else {
470
- setIsActive(true);
471
- setHasPlayed(true);
472
- onInteractionStart === null || onInteractionStart === void 0 ? void 0 : onInteractionStart();
473
- }
359
+ if (disabled) {
360
+ return;
361
+ }
362
+ if (config.once && hasPlayed) {
363
+ return;
364
+ }
365
+ clearTimer();
366
+ setIsLeaving(false);
367
+ if (config.delay) {
368
+ timeoutRef.current = setTimeout(() => {
369
+ setIsActive(true);
370
+ setHasPlayed(true);
371
+ onInteractionStart?.();
372
+ }, config.delay);
373
+ } else {
374
+ setIsActive(true);
375
+ setHasPlayed(true);
376
+ onInteractionStart?.();
377
+ }
474
378
  }, [disabled, config.once, config.delay, hasPlayed, clearTimer, onInteractionStart]);
475
- // Handle deactivation
476
379
  const deactivate = React.useCallback(() => {
477
- if (!isActive) {
478
- return;
479
- }
480
- clearTimer();
481
- if (config.leaveAnimation) {
482
- setIsLeaving(true);
483
- setIsActive(false);
484
- timeoutRef.current = setTimeout(() => {
485
- setIsLeaving(false);
486
- onInteractionEnd === null || onInteractionEnd === void 0 ? void 0 : onInteractionEnd();
487
- }, config.leaveDuration || 300);
488
- }
489
- else {
490
- setIsActive(false);
491
- onInteractionEnd === null || onInteractionEnd === void 0 ? void 0 : onInteractionEnd();
492
- }
380
+ if (!isActive) {
381
+ return;
382
+ }
383
+ clearTimer();
384
+ if (config.leaveAnimation) {
385
+ setIsLeaving(true);
386
+ setIsActive(false);
387
+ timeoutRef.current = setTimeout(() => {
388
+ setIsLeaving(false);
389
+ onInteractionEnd?.();
390
+ }, config.leaveDuration || 300);
391
+ } else {
392
+ setIsActive(false);
393
+ onInteractionEnd?.();
394
+ }
493
395
  }, [isActive, config.leaveAnimation, config.leaveDuration, clearTimer, onInteractionEnd]);
494
- // Visibility observer
495
396
  React.useEffect(() => {
496
- var _a;
497
- if (config.trigger !== 'visible' || !wrapperRef.current) {
498
- return;
499
- }
500
- const threshold = (_a = config.visibilityThreshold) !== null && _a !== void 0 ? _a : 0.5;
501
- const observer = new IntersectionObserver(([entry]) => {
502
- if (entry.isIntersecting) {
503
- activate();
504
- }
505
- else if (!config.once) {
506
- deactivate();
507
- }
508
- }, { threshold });
509
- observer.observe(wrapperRef.current);
510
- return () => observer.disconnect();
397
+ if (config.trigger !== "visible" || !wrapperRef.current) {
398
+ return;
399
+ }
400
+ const threshold = config.visibilityThreshold ?? 0.5;
401
+ const observer = new IntersectionObserver(
402
+ ([entry]) => {
403
+ if (entry.isIntersecting) {
404
+ activate();
405
+ } else if (!config.once) {
406
+ deactivate();
407
+ }
408
+ },
409
+ { threshold }
410
+ );
411
+ observer.observe(wrapperRef.current);
412
+ return () => observer.disconnect();
511
413
  }, [config.trigger, config.visibilityThreshold, config.once, activate, deactivate]);
512
- // Event handlers
513
- const handleMouseEnter = config.trigger === 'hover' ? activate : undefined;
514
- const handleMouseLeave = config.trigger === 'hover' ? deactivate : undefined;
515
- const handleClick = config.trigger === 'click' ? activate : undefined;
516
- const handleFocus = config.trigger === 'focus' ? activate : undefined;
517
- const handleBlur = config.trigger === 'focus' ? deactivate : undefined;
518
- // Build animation props
519
- const currentAnimation = isActive
520
- ? config.enterAnimation
521
- : isLeaving
522
- ? config.leaveAnimation
523
- : undefined;
414
+ const handleMouseEnter = config.trigger === "hover" ? activate : void 0;
415
+ const handleMouseLeave = config.trigger === "hover" ? deactivate : void 0;
416
+ const handleClick = config.trigger === "click" ? activate : void 0;
417
+ const handleFocus = config.trigger === "focus" ? activate : void 0;
418
+ const handleBlur = config.trigger === "focus" ? deactivate : void 0;
419
+ const currentAnimation = isActive ? config.enterAnimation : isLeaving ? config.leaveAnimation : void 0;
524
420
  const animationDuration = isActive ? config.enterDuration : config.leaveDuration;
525
- const animationStyles = currentAnimation
526
- ? getAnimationStyle(currentAnimation, animationDuration || 300)
527
- : {};
528
- const animationClass = currentAnimation ? getAnimationClass(currentAnimation) : '';
529
- // Clone with animation
421
+ const animationStyles = currentAnimation ? getAnimationStyle(currentAnimation, animationDuration || 300) : {};
422
+ const animationClass = currentAnimation ? getAnimationClass(currentAnimation) : "";
530
423
  const animatedChild = React.cloneElement(children, {
531
- className: `${children.props.className || ''} ${animationClass}`.trim(),
424
+ className: `${children.props.className || ""} ${animationClass}`.trim(),
425
+ style: {
426
+ ...children.props.style,
427
+ ...animationStyles
428
+ }
429
+ });
430
+ return /* @__PURE__ */ jsxRuntime.jsx(
431
+ "span",
432
+ {
433
+ ref: setRefs,
434
+ className: `ntd-interactive-icon ${isActive ? "ntd-active" : ""} ${isLeaving ? "ntd-leaving" : ""} ${disabled ? "ntd-disabled" : ""} ${className || ""}`.trim(),
532
435
  style: {
533
- ...children.props.style,
534
- ...animationStyles,
436
+ display: "inline-flex",
437
+ cursor: disabled ? "default" : config.trigger === "click" ? "pointer" : void 0,
438
+ ...style
535
439
  },
536
- });
537
- return (jsxRuntime.jsx("span", { ref: setRefs, className: `ntd-interactive-icon ${isActive ? 'ntd-active' : ''} ${isLeaving ? 'ntd-leaving' : ''} ${disabled ? 'ntd-disabled' : ''} ${className || ''}`.trim(), style: {
538
- display: 'inline-flex',
539
- cursor: disabled ? 'default' : config.trigger === 'click' ? 'pointer' : undefined,
540
- ...style,
541
- }, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onClick: handleClick, onKeyDown: handleClick
542
- ? (e) => {
543
- if (e.key === 'Enter' || e.key === ' ') {
544
- e.preventDefault();
545
- handleClick();
546
- }
547
- }
548
- : undefined, onFocus: handleFocus, onBlur: handleBlur, tabIndex: config.trigger === 'focus' || config.trigger === 'click' ? 0 : undefined, role: config.trigger === 'click' ? 'button' : undefined, children: animatedChild }));
549
- });
550
- /* ────────────────────────────────────────────────────────────────────────────
551
- 6. UTILITY FUNCTIONS
552
- ───────────────────────────────────────────────────────────────────────────── */
553
- /**
554
- * Create an animation sequence configuration
555
- *
556
- * @example
557
- * ```tsx
558
- * const seq = createAnimationSequence([
559
- * { animation: 'shake', duration: 300 },
560
- * { animation: 'pulse', duration: 500 },
561
- * { animation: 'bounce', duration: 400 },
562
- * ], { loop: true, loopCount: 2 });
563
- * ```
564
- */
440
+ onMouseEnter: handleMouseEnter,
441
+ onMouseLeave: handleMouseLeave,
442
+ onClick: handleClick,
443
+ onKeyDown: handleClick ? (e) => {
444
+ if (e.key === "Enter" || e.key === " ") {
445
+ e.preventDefault();
446
+ handleClick();
447
+ }
448
+ } : void 0,
449
+ onFocus: handleFocus,
450
+ onBlur: handleBlur,
451
+ tabIndex: config.trigger === "focus" || config.trigger === "click" ? 0 : void 0,
452
+ role: config.trigger === "click" ? "button" : void 0,
453
+ children: animatedChild
454
+ }
455
+ );
456
+ }
457
+ );
565
458
  function createAnimationSequence(steps, options) {
566
- var _a, _b;
567
- return {
568
- steps,
569
- loop: (_a = options === null || options === void 0 ? void 0 : options.loop) !== null && _a !== void 0 ? _a : false,
570
- loopCount: options === null || options === void 0 ? void 0 : options.loopCount,
571
- loopDelay: options === null || options === void 0 ? void 0 : options.loopDelay,
572
- direction: (_b = options === null || options === void 0 ? void 0 : options.direction) !== null && _b !== void 0 ? _b : 'normal',
573
- };
459
+ return {
460
+ steps,
461
+ loop: options?.loop ?? false,
462
+ loopCount: options?.loopCount,
463
+ loopDelay: options?.loopDelay,
464
+ direction: options?.direction ?? "normal"
465
+ };
574
466
  }
575
- /**
576
- * Create an interactive config for hover effect
577
- */
578
467
  function createHoverAnimation(enterAnimation, leaveAnimation, options) {
579
- var _a, _b;
580
- return {
581
- trigger: 'hover',
582
- enterAnimation,
583
- leaveAnimation,
584
- enterDuration: (_a = options === null || options === void 0 ? void 0 : options.enterDuration) !== null && _a !== void 0 ? _a : 300,
585
- leaveDuration: (_b = options === null || options === void 0 ? void 0 : options.leaveDuration) !== null && _b !== void 0 ? _b : 200,
586
- delay: options === null || options === void 0 ? void 0 : options.delay,
587
- };
468
+ return {
469
+ trigger: "hover",
470
+ enterAnimation,
471
+ leaveAnimation,
472
+ enterDuration: options?.enterDuration ?? 300,
473
+ leaveDuration: options?.leaveDuration ?? 200,
474
+ delay: options?.delay
475
+ };
588
476
  }
589
- /**
590
- * Create an interactive config for click effect
591
- */
592
477
  function createClickAnimation(animation, options) {
593
- var _a, _b;
594
- return {
595
- trigger: 'click',
596
- enterAnimation: animation,
597
- enterDuration: (_a = options === null || options === void 0 ? void 0 : options.duration) !== null && _a !== void 0 ? _a : 500,
598
- once: (_b = options === null || options === void 0 ? void 0 : options.once) !== null && _b !== void 0 ? _b : false,
599
- delay: options === null || options === void 0 ? void 0 : options.delay,
600
- };
478
+ return {
479
+ trigger: "click",
480
+ enterAnimation: animation,
481
+ enterDuration: options?.duration ?? 500,
482
+ once: options?.once ?? false,
483
+ delay: options?.delay
484
+ };
601
485
  }
602
- /**
603
- * Create an interactive config for visibility trigger
604
- */
605
486
  function createVisibilityAnimation(animation, options) {
606
- var _a, _b, _c;
607
- return {
608
- trigger: 'visible',
609
- enterAnimation: animation,
610
- enterDuration: (_a = options === null || options === void 0 ? void 0 : options.duration) !== null && _a !== void 0 ? _a : 600,
611
- once: (_b = options === null || options === void 0 ? void 0 : options.once) !== null && _b !== void 0 ? _b : true,
612
- visibilityThreshold: (_c = options === null || options === void 0 ? void 0 : options.threshold) !== null && _c !== void 0 ? _c : 0.5,
613
- };
487
+ return {
488
+ trigger: "visible",
489
+ enterAnimation: animation,
490
+ enterDuration: options?.duration ?? 600,
491
+ once: options?.once ?? true,
492
+ visibilityThreshold: options?.threshold ?? 0.5
493
+ };
614
494
  }
615
- /* ────────────────────────────────────────────────────────────────────────────
616
- 7. PRESET SEQUENCES
617
- ───────────────────────────────────────────────────────────────────────────── */
618
- /**
619
- * Preset animation sequences for common use cases
620
- */
621
495
  const PRESET_SEQUENCES = {
622
- /** Attention grabber: bounce → shake → pulse */
623
- attention: createAnimationSequence([
624
- { animation: 'bounce', duration: 400 },
625
- { animation: 'shake', duration: 300 },
626
- { animation: 'pulse', duration: 500 },
627
- ]),
628
- /** Success animation: pop → bounce */
629
- success: createAnimationSequence([
630
- { animation: 'pop', duration: 200 },
631
- { animation: 'bounce', duration: 500 },
632
- ]),
633
- /** Error animation: shake → pulse */
634
- error: createAnimationSequence([
635
- { animation: 'shake', duration: 500, iterations: 2 },
636
- { animation: 'pulse', duration: 300 },
637
- ]),
638
- /** Loading sequence: spin → pulse (looping) */
639
- loading: createAnimationSequence([
640
- { animation: 'spin', duration: 1000 },
641
- { animation: 'pulse', duration: 500 },
642
- ], { loop: true }),
643
- /** Celebration: bounce → tada → heartbeat */
644
- celebrate: createAnimationSequence([
645
- { animation: 'bounce', duration: 500 },
646
- { animation: 'tada', duration: 800 },
647
- { animation: 'heartbeat', duration: 600 },
648
- ]),
649
- /** Notification: swing → bounce */
650
- notification: createAnimationSequence([
651
- { animation: 'swing', duration: 600 },
652
- { animation: 'bounce', duration: 400 },
653
- ]),
654
- /** Gentle: pulse → breathe */
655
- gentle: createAnimationSequence([
656
- { animation: 'pulse', duration: 800 },
657
- { animation: 'breathe', duration: 1500 },
658
- ], { loop: true }),
659
- /** Reveal: fade-in → pop */
660
- reveal: createAnimationSequence([
661
- { animation: 'fade-in', duration: 300 },
662
- { animation: 'pop', duration: 200 },
663
- ]),
496
+ /** Attention grabber: bounce → shake → pulse */
497
+ attention: createAnimationSequence([
498
+ { animation: "bounce", duration: 400 },
499
+ { animation: "shake", duration: 300 },
500
+ { animation: "pulse", duration: 500 }
501
+ ]),
502
+ /** Success animation: pop → bounce */
503
+ success: createAnimationSequence([
504
+ { animation: "pop", duration: 200 },
505
+ { animation: "bounce", duration: 500 }
506
+ ]),
507
+ /** Error animation: shake → pulse */
508
+ error: createAnimationSequence([
509
+ { animation: "shake", duration: 500, iterations: 2 },
510
+ { animation: "pulse", duration: 300 }
511
+ ]),
512
+ /** Loading sequence: spin → pulse (looping) */
513
+ loading: createAnimationSequence(
514
+ [
515
+ { animation: "spin", duration: 1e3 },
516
+ { animation: "pulse", duration: 500 }
517
+ ],
518
+ { loop: true }
519
+ ),
520
+ /** Celebration: bounce → tada → heartbeat */
521
+ celebrate: createAnimationSequence([
522
+ { animation: "bounce", duration: 500 },
523
+ { animation: "tada", duration: 800 },
524
+ { animation: "heartbeat", duration: 600 }
525
+ ]),
526
+ /** Notification: swing → bounce */
527
+ notification: createAnimationSequence([
528
+ { animation: "swing", duration: 600 },
529
+ { animation: "bounce", duration: 400 }
530
+ ]),
531
+ /** Gentle: pulse → breathe */
532
+ gentle: createAnimationSequence(
533
+ [
534
+ { animation: "pulse", duration: 800 },
535
+ { animation: "breathe", duration: 1500 }
536
+ ],
537
+ { loop: true }
538
+ ),
539
+ /** Reveal: fade-in → pop */
540
+ reveal: createAnimationSequence([
541
+ { animation: "fade-in", duration: 300 },
542
+ { animation: "pop", duration: 200 }
543
+ ])
664
544
  };
665
- /**
666
- * Preset interactive configs
667
- */
668
545
  const PRESET_INTERACTIONS = {
669
- /** Bounce on hover */
670
- hoverBounce: createHoverAnimation('bounce'),
671
- /** Pulse on hover */
672
- hoverPulse: createHoverAnimation('pulse'),
673
- /** Spin on hover */
674
- hoverSpin: createHoverAnimation('spin'),
675
- /** Shake on hover */
676
- hoverShake: createHoverAnimation('shake'),
677
- /** Pop on click */
678
- clickPop: createClickAnimation('pop', { once: true }),
679
- /** Bounce on click */
680
- clickBounce: createClickAnimation('bounce'),
681
- /** Tada on click */
682
- clickTada: createClickAnimation('tada'),
683
- /** FadeIn on visible */
684
- visibleFadeIn: createVisibilityAnimation('fade-in', { once: true }),
685
- /** Bounce on visible */
686
- visibleBounce: createVisibilityAnimation('bounce', { once: true }),
687
- /** Scale in on visible */
688
- visibleScaleIn: createVisibilityAnimation('scale-in', { once: true }),
546
+ /** Bounce on hover */
547
+ hoverBounce: createHoverAnimation("bounce"),
548
+ /** Pulse on hover */
549
+ hoverPulse: createHoverAnimation("pulse"),
550
+ /** Spin on hover */
551
+ hoverSpin: createHoverAnimation("spin"),
552
+ /** Shake on hover */
553
+ hoverShake: createHoverAnimation("shake"),
554
+ /** Pop on click */
555
+ clickPop: createClickAnimation("pop", { once: true }),
556
+ /** Bounce on click */
557
+ clickBounce: createClickAnimation("bounce"),
558
+ /** Tada on click */
559
+ clickTada: createClickAnimation("tada"),
560
+ /** FadeIn on visible */
561
+ visibleFadeIn: createVisibilityAnimation("fade-in", { once: true }),
562
+ /** Bounce on visible */
563
+ visibleBounce: createVisibilityAnimation("bounce", { once: true }),
564
+ /** Scale in on visible */
565
+ visibleScaleIn: createVisibilityAnimation("scale-in", { once: true })
689
566
  };
690
-
691
567
  exports.AnimationController = AnimationController;
692
568
  exports.InteractiveIcon = InteractiveIcon;
693
569
  exports.PRESET_INTERACTIONS = PRESET_INTERACTIONS;