@nikitph/flux-ui 0.3.2 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +510 -220
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -223,7 +223,7 @@ var Reveal = forwardRef2(
|
|
|
223
223
|
animate: shouldAnimate ? target : initial,
|
|
224
224
|
transition: { ...springConfig, delay: isReducedMotion ? 0 : delay },
|
|
225
225
|
className,
|
|
226
|
-
style,
|
|
226
|
+
style: { ...style, willChange: "transform, opacity" },
|
|
227
227
|
...props,
|
|
228
228
|
children
|
|
229
229
|
}
|
|
@@ -236,6 +236,7 @@ Reveal.displayName = "Reveal";
|
|
|
236
236
|
import React3 from "react";
|
|
237
237
|
import { AnimatePresence, motion as motion2 } from "motion/react";
|
|
238
238
|
import { Fragment as Fragment2, jsx as jsx4 } from "react/jsx-runtime";
|
|
239
|
+
var MotionSlot = motion2.create(Slot);
|
|
239
240
|
var Presence = ({
|
|
240
241
|
children,
|
|
241
242
|
enterFrom = "below",
|
|
@@ -279,14 +280,14 @@ var Presence = ({
|
|
|
279
280
|
const animate = { opacity: 1, x: 0, y: 0, scale: 1 };
|
|
280
281
|
return /* @__PURE__ */ jsx4(AnimatePresence, { mode, onExitComplete, children: React3.Children.map(children, (child) => {
|
|
281
282
|
if (!React3.isValidElement(child)) return child;
|
|
282
|
-
const MotionChild = motion2.create(Slot);
|
|
283
283
|
return /* @__PURE__ */ jsx4(
|
|
284
|
-
|
|
284
|
+
MotionSlot,
|
|
285
285
|
{
|
|
286
286
|
initial,
|
|
287
287
|
animate,
|
|
288
288
|
exit: { ...exit, transition: exitSpring },
|
|
289
289
|
transition: enterSpring,
|
|
290
|
+
style: { willChange: "transform, opacity" },
|
|
290
291
|
children: child
|
|
291
292
|
},
|
|
292
293
|
child.key || Math.random().toString(36)
|
|
@@ -295,9 +296,10 @@ var Presence = ({
|
|
|
295
296
|
};
|
|
296
297
|
|
|
297
298
|
// src/primitives/03-stagger.tsx
|
|
298
|
-
import React4, { forwardRef as forwardRef3, useEffect as useEffect6, useState as useState4 } from "react";
|
|
299
|
+
import React4, { forwardRef as forwardRef3, useEffect as useEffect6, useMemo, useState as useState4 } from "react";
|
|
299
300
|
import { motion as motion3, useInView as useInView3 } from "motion/react";
|
|
300
301
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
302
|
+
var MotionSlot2 = motion3.create(Slot);
|
|
301
303
|
var Stagger = forwardRef3(
|
|
302
304
|
({
|
|
303
305
|
children,
|
|
@@ -336,8 +338,7 @@ var Stagger = forwardRef3(
|
|
|
336
338
|
}, [shouldAnimate, hasRevealed]);
|
|
337
339
|
const childrenArray = React4.Children.toArray(children);
|
|
338
340
|
const count = childrenArray.length;
|
|
339
|
-
|
|
340
|
-
const getInitial = () => {
|
|
341
|
+
const getInitial = useMemo(() => {
|
|
341
342
|
if (isReducedMotion) return { opacity: 0, x: 0, y: 0, scale: 1 };
|
|
342
343
|
const rFrom = reveal.from || "below";
|
|
343
344
|
const rDist = reveal.distance || motionScale.distance.md;
|
|
@@ -349,9 +350,10 @@ var Stagger = forwardRef3(
|
|
|
349
350
|
x: rFrom === "left" ? -rDist : rFrom === "right" ? rDist : 0,
|
|
350
351
|
scale: rScale !== false ? rScale : 1
|
|
351
352
|
};
|
|
352
|
-
};
|
|
353
|
+
}, [isReducedMotion, reveal.from, reveal.distance, reveal.fade, reveal.scale]);
|
|
353
354
|
const target = { opacity: 1, x: 0, y: 0, scale: 1 };
|
|
354
|
-
const initial = getInitial
|
|
355
|
+
const initial = getInitial;
|
|
356
|
+
let randomSeed = 0.5;
|
|
355
357
|
const renderChildren = childrenArray.map((child, i) => {
|
|
356
358
|
if (!React4.isValidElement(child)) return child;
|
|
357
359
|
let delay = 0;
|
|
@@ -364,13 +366,13 @@ var Stagger = forwardRef3(
|
|
|
364
366
|
delay = randomSeed / 233280 * count * interval;
|
|
365
367
|
}
|
|
366
368
|
}
|
|
367
|
-
const MotionChild = motion3.create(Slot);
|
|
368
369
|
return /* @__PURE__ */ jsx5(
|
|
369
|
-
|
|
370
|
+
MotionSlot2,
|
|
370
371
|
{
|
|
371
372
|
initial,
|
|
372
373
|
animate: shouldAnimate ? target : initial,
|
|
373
374
|
transition: { ...springConfig, delay },
|
|
375
|
+
style: { willChange: "transform, opacity" },
|
|
374
376
|
children: child
|
|
375
377
|
},
|
|
376
378
|
child.key || i
|
|
@@ -573,9 +575,9 @@ var MorphText = forwardRef6(
|
|
|
573
575
|
/* @__PURE__ */ jsx8(AnimatePresence2, { mode: "popLayout", initial: false, children: /* @__PURE__ */ jsx8(
|
|
574
576
|
motion6.span,
|
|
575
577
|
{
|
|
576
|
-
initial: { opacity: 0,
|
|
577
|
-
animate: { opacity: 1,
|
|
578
|
-
exit: { opacity: 0,
|
|
578
|
+
initial: { opacity: 0, y: 10 },
|
|
579
|
+
animate: { opacity: 1, y: 0 },
|
|
580
|
+
exit: { opacity: 0, y: -10 },
|
|
579
581
|
transition: springConfig,
|
|
580
582
|
style: { display: "inline-block" },
|
|
581
583
|
children: currentText
|
|
@@ -669,7 +671,8 @@ var FlipCard = forwardRef7(
|
|
|
669
671
|
width: "100%",
|
|
670
672
|
height: "100%",
|
|
671
673
|
backfaceVisibility: "hidden",
|
|
672
|
-
transformStyle: "preserve-3d"
|
|
674
|
+
transformStyle: "preserve-3d",
|
|
675
|
+
willChange: "transform"
|
|
673
676
|
},
|
|
674
677
|
children: front
|
|
675
678
|
}
|
|
@@ -685,7 +688,8 @@ var FlipCard = forwardRef7(
|
|
|
685
688
|
width: "100%",
|
|
686
689
|
height: "100%",
|
|
687
690
|
backfaceVisibility: "hidden",
|
|
688
|
-
transformStyle: "preserve-3d"
|
|
691
|
+
transformStyle: "preserve-3d",
|
|
692
|
+
willChange: "transform"
|
|
689
693
|
},
|
|
690
694
|
children: back
|
|
691
695
|
}
|
|
@@ -797,10 +801,30 @@ var Magnetic = forwardRef9(
|
|
|
797
801
|
const y = useMotionValue2(0);
|
|
798
802
|
const springX = useSpring2(x, isReducedMotion ? { duration: 0 } : springConfig);
|
|
799
803
|
const springY = useSpring2(y, isReducedMotion ? { duration: 0 } : springConfig);
|
|
800
|
-
const
|
|
804
|
+
const rectRef = useRef3(null);
|
|
805
|
+
const updateRect = useCallback(() => {
|
|
806
|
+
if (internalRef.current) {
|
|
807
|
+
rectRef.current = internalRef.current.getBoundingClientRect();
|
|
808
|
+
}
|
|
809
|
+
}, []);
|
|
810
|
+
useEffect11(() => {
|
|
811
|
+
updateRect();
|
|
812
|
+
window.addEventListener("scroll", updateRect, { passive: true });
|
|
813
|
+
window.addEventListener("resize", updateRect, { passive: true });
|
|
814
|
+
return () => {
|
|
815
|
+
window.removeEventListener("scroll", updateRect);
|
|
816
|
+
window.removeEventListener("resize", updateRect);
|
|
817
|
+
};
|
|
818
|
+
}, [updateRect]);
|
|
819
|
+
const rafId = useRef3(0);
|
|
820
|
+
const latestEvent = useRef3(null);
|
|
821
|
+
const processMouseMove = useCallback(() => {
|
|
822
|
+
const e = latestEvent.current;
|
|
823
|
+
rafId.current = 0;
|
|
824
|
+
if (!e) return;
|
|
801
825
|
if (isReducedMotion || disableOnTouch && isTouchDevice) return;
|
|
802
|
-
|
|
803
|
-
|
|
826
|
+
const rect = rectRef.current;
|
|
827
|
+
if (!rect) return;
|
|
804
828
|
const centerX = rect.left + rect.width / 2;
|
|
805
829
|
const centerY = rect.top + rect.height / 2;
|
|
806
830
|
const deltaX = e.clientX - centerX;
|
|
@@ -816,14 +840,21 @@ var Magnetic = forwardRef9(
|
|
|
816
840
|
y.set(0);
|
|
817
841
|
}
|
|
818
842
|
}, [x, y, radius, maxDisplacement, strength, isTouchDevice, disableOnTouch, isReducedMotion]);
|
|
819
|
-
const
|
|
843
|
+
const handleMouseMove = useCallback((e) => {
|
|
844
|
+
latestEvent.current = e;
|
|
845
|
+
if (!rafId.current) {
|
|
846
|
+
rafId.current = requestAnimationFrame(processMouseMove);
|
|
847
|
+
}
|
|
848
|
+
}, [processMouseMove]);
|
|
849
|
+
const handleMouseLeave = useCallback(() => {
|
|
820
850
|
x.set(0);
|
|
821
851
|
y.set(0);
|
|
822
|
-
};
|
|
852
|
+
}, [x, y]);
|
|
823
853
|
useEffect11(() => {
|
|
824
|
-
window.addEventListener("mousemove", handleMouseMove);
|
|
854
|
+
window.addEventListener("mousemove", handleMouseMove, { passive: true });
|
|
825
855
|
return () => {
|
|
826
856
|
window.removeEventListener("mousemove", handleMouseMove);
|
|
857
|
+
if (rafId.current) cancelAnimationFrame(rafId.current);
|
|
827
858
|
};
|
|
828
859
|
}, [handleMouseMove]);
|
|
829
860
|
const MotionComponent = asChild ? motion9.create(Slot) : motion9.div;
|
|
@@ -832,7 +863,7 @@ var Magnetic = forwardRef9(
|
|
|
832
863
|
{
|
|
833
864
|
ref: mergedRef,
|
|
834
865
|
className,
|
|
835
|
-
style: { ...style, x: springX, y: springY },
|
|
866
|
+
style: { ...style, x: springX, y: springY, willChange: "transform" },
|
|
836
867
|
onMouseLeave: handleMouseLeave,
|
|
837
868
|
...props,
|
|
838
869
|
children
|
|
@@ -932,10 +963,29 @@ var Tilt = forwardRef11(
|
|
|
932
963
|
const scaleVal = useSpring3(s, isReducedMotion ? { duration: 0 } : springConfig);
|
|
933
964
|
const gX = useSpring3(glareX, isReducedMotion ? { duration: 0 } : springConfig);
|
|
934
965
|
const gY = useSpring3(glareY, isReducedMotion ? { duration: 0 } : springConfig);
|
|
935
|
-
const
|
|
936
|
-
|
|
937
|
-
if (
|
|
938
|
-
|
|
966
|
+
const rectRef = useRef4(null);
|
|
967
|
+
const updateRect = useCallback2(() => {
|
|
968
|
+
if (internalRef.current) {
|
|
969
|
+
rectRef.current = internalRef.current.getBoundingClientRect();
|
|
970
|
+
}
|
|
971
|
+
}, []);
|
|
972
|
+
useEffect12(() => {
|
|
973
|
+
updateRect();
|
|
974
|
+
window.addEventListener("scroll", updateRect, { passive: true });
|
|
975
|
+
window.addEventListener("resize", updateRect, { passive: true });
|
|
976
|
+
return () => {
|
|
977
|
+
window.removeEventListener("scroll", updateRect);
|
|
978
|
+
window.removeEventListener("resize", updateRect);
|
|
979
|
+
};
|
|
980
|
+
}, [updateRect]);
|
|
981
|
+
const rafId = useRef4(0);
|
|
982
|
+
const latestEvent = useRef4(null);
|
|
983
|
+
const processMouseMove = useCallback2(() => {
|
|
984
|
+
rafId.current = 0;
|
|
985
|
+
const e = latestEvent.current;
|
|
986
|
+
if (!e) return;
|
|
987
|
+
const rect = rectRef.current;
|
|
988
|
+
if (!rect) return;
|
|
939
989
|
const centerX = rect.left + rect.width / 2;
|
|
940
990
|
const centerY = rect.top + rect.height / 2;
|
|
941
991
|
const mouseX = (e.clientX - centerX) / rect.width;
|
|
@@ -952,7 +1002,14 @@ var Tilt = forwardRef11(
|
|
|
952
1002
|
glareX.set((e.clientX - rect.left) / rect.width * 100);
|
|
953
1003
|
glareY.set((e.clientY - rect.top) / rect.height * 100);
|
|
954
1004
|
}
|
|
955
|
-
}, [x, y, s, glareX, glareY, maxTilt, reverse, axis, scale, glare
|
|
1005
|
+
}, [x, y, s, glareX, glareY, maxTilt, reverse, axis, scale, glare]);
|
|
1006
|
+
const handleMouseMove = useCallback2((e) => {
|
|
1007
|
+
if (disabled || isReducedMotion || disableOnTouch && isTouchDevice) return;
|
|
1008
|
+
latestEvent.current = e;
|
|
1009
|
+
if (!rafId.current) {
|
|
1010
|
+
rafId.current = requestAnimationFrame(processMouseMove);
|
|
1011
|
+
}
|
|
1012
|
+
}, [disabled, isReducedMotion, disableOnTouch, isTouchDevice, processMouseMove]);
|
|
956
1013
|
const handleMouseLeave = useCallback2(() => {
|
|
957
1014
|
if (disabled || isReducedMotion) return;
|
|
958
1015
|
if (resetOnLeave) {
|
|
@@ -961,6 +1018,11 @@ var Tilt = forwardRef11(
|
|
|
961
1018
|
}
|
|
962
1019
|
s.set(1);
|
|
963
1020
|
}, [x, y, s, resetOnLeave, disabled, isReducedMotion]);
|
|
1021
|
+
useEffect12(() => {
|
|
1022
|
+
return () => {
|
|
1023
|
+
if (rafId.current) cancelAnimationFrame(rafId.current);
|
|
1024
|
+
};
|
|
1025
|
+
}, []);
|
|
964
1026
|
const glareBackground = useMotionTemplate`radial-gradient(circle at ${gX}% ${gY}%, ${glareColor} 0%, transparent 80%)`;
|
|
965
1027
|
if (disabled || isReducedMotion) {
|
|
966
1028
|
return /* @__PURE__ */ jsx13("div", { ref: mergedRef, className, style, ...props, children });
|
|
@@ -977,7 +1039,15 @@ var Tilt = forwardRef11(
|
|
|
977
1039
|
children: /* @__PURE__ */ jsxs3(
|
|
978
1040
|
motion11.div,
|
|
979
1041
|
{
|
|
980
|
-
style: {
|
|
1042
|
+
style: {
|
|
1043
|
+
rotateX,
|
|
1044
|
+
rotateY,
|
|
1045
|
+
scale: scaleVal,
|
|
1046
|
+
transformStyle: "preserve-3d",
|
|
1047
|
+
width: "100%",
|
|
1048
|
+
height: "100%",
|
|
1049
|
+
willChange: "transform"
|
|
1050
|
+
},
|
|
981
1051
|
children: [
|
|
982
1052
|
children,
|
|
983
1053
|
glare && /* @__PURE__ */ jsx13(
|
|
@@ -1264,8 +1334,8 @@ var LongPress = forwardRef14(
|
|
|
1264
1334
|
LongPress.displayName = "LongPress";
|
|
1265
1335
|
|
|
1266
1336
|
// src/primitives/15-hover-3d.tsx
|
|
1267
|
-
import React16, { createContext as createContext2, forwardRef as forwardRef15, useCallback as useCallback3, useContext as useContext2, useEffect as useEffect13, useRef as useRef6 } from "react";
|
|
1268
|
-
import { motion as motion15, useMotionValue as useMotionValue4, useSpring as useSpring4 } from "motion/react";
|
|
1337
|
+
import React16, { createContext as createContext2, forwardRef as forwardRef15, useCallback as useCallback3, useContext as useContext2, useEffect as useEffect13, useMemo as useMemo2, useRef as useRef6 } from "react";
|
|
1338
|
+
import { motion as motion15, useMotionValue as useMotionValue4, useSpring as useSpring4, useTransform as useTransform2 } from "motion/react";
|
|
1269
1339
|
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1270
1340
|
var Hover3DContext = createContext2({
|
|
1271
1341
|
mouseX: null,
|
|
@@ -1296,21 +1366,52 @@ var Hover3DRoot = forwardRef15(
|
|
|
1296
1366
|
const y = useMotionValue4(0);
|
|
1297
1367
|
const mouseX = useSpring4(x, isReducedMotion ? { duration: 0 } : springConfig);
|
|
1298
1368
|
const mouseY = useSpring4(y, isReducedMotion ? { duration: 0 } : springConfig);
|
|
1299
|
-
const
|
|
1300
|
-
|
|
1301
|
-
if (
|
|
1302
|
-
|
|
1369
|
+
const rectRef = useRef6(null);
|
|
1370
|
+
const updateRect = useCallback3(() => {
|
|
1371
|
+
if (internalRef.current) {
|
|
1372
|
+
rectRef.current = internalRef.current.getBoundingClientRect();
|
|
1373
|
+
}
|
|
1374
|
+
}, []);
|
|
1375
|
+
useEffect13(() => {
|
|
1376
|
+
updateRect();
|
|
1377
|
+
window.addEventListener("scroll", updateRect, { passive: true });
|
|
1378
|
+
window.addEventListener("resize", updateRect, { passive: true });
|
|
1379
|
+
return () => {
|
|
1380
|
+
window.removeEventListener("scroll", updateRect);
|
|
1381
|
+
window.removeEventListener("resize", updateRect);
|
|
1382
|
+
};
|
|
1383
|
+
}, [updateRect]);
|
|
1384
|
+
const rafId = useRef6(0);
|
|
1385
|
+
const latestEvent = useRef6(null);
|
|
1386
|
+
const processMouseMove = useCallback3(() => {
|
|
1387
|
+
rafId.current = 0;
|
|
1388
|
+
const e = latestEvent.current;
|
|
1389
|
+
if (!e) return;
|
|
1390
|
+
const rect = rectRef.current;
|
|
1391
|
+
if (!rect) return;
|
|
1303
1392
|
const centerX = rect.left + rect.width / 2;
|
|
1304
1393
|
const centerY = rect.top + rect.height / 2;
|
|
1305
1394
|
const offsetX = (e.clientX - centerX) / rect.width;
|
|
1306
1395
|
const offsetY = (e.clientY - centerY) / rect.height;
|
|
1307
1396
|
x.set(offsetX * 2);
|
|
1308
1397
|
y.set(offsetY * 2);
|
|
1309
|
-
}, [x, y
|
|
1398
|
+
}, [x, y]);
|
|
1399
|
+
const handleMouseMove = useCallback3((e) => {
|
|
1400
|
+
if (disabled || isReducedMotion || disableOnTouch && isTouchDevice) return;
|
|
1401
|
+
latestEvent.current = e;
|
|
1402
|
+
if (!rafId.current) {
|
|
1403
|
+
rafId.current = requestAnimationFrame(processMouseMove);
|
|
1404
|
+
}
|
|
1405
|
+
}, [disabled, isReducedMotion, disableOnTouch, isTouchDevice, processMouseMove]);
|
|
1310
1406
|
const handleMouseLeave = useCallback3(() => {
|
|
1311
1407
|
x.set(0);
|
|
1312
1408
|
y.set(0);
|
|
1313
1409
|
}, [x, y]);
|
|
1410
|
+
useEffect13(() => {
|
|
1411
|
+
return () => {
|
|
1412
|
+
if (rafId.current) cancelAnimationFrame(rafId.current);
|
|
1413
|
+
};
|
|
1414
|
+
}, []);
|
|
1314
1415
|
if (disabled) {
|
|
1315
1416
|
return /* @__PURE__ */ jsx17("div", { ref: mergedRef, className, style: { position: "relative", ...style }, ...props, children });
|
|
1316
1417
|
}
|
|
@@ -1324,7 +1425,13 @@ var Hover3DRoot = forwardRef15(
|
|
|
1324
1425
|
}
|
|
1325
1426
|
return child;
|
|
1326
1427
|
});
|
|
1327
|
-
|
|
1428
|
+
const contextValue = useMemo2(() => ({
|
|
1429
|
+
mouseX,
|
|
1430
|
+
mouseY,
|
|
1431
|
+
maxMovement,
|
|
1432
|
+
isReducedMotion
|
|
1433
|
+
}), [mouseX, mouseY, maxMovement, isReducedMotion]);
|
|
1434
|
+
return /* @__PURE__ */ jsx17(Hover3DContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx17(
|
|
1328
1435
|
"div",
|
|
1329
1436
|
{
|
|
1330
1437
|
ref: mergedRef,
|
|
@@ -1342,6 +1449,8 @@ Hover3DRoot.displayName = "Hover3D";
|
|
|
1342
1449
|
var Hover3DLayer = forwardRef15(
|
|
1343
1450
|
({ children, depth = 0, className, style, ...props }, ref) => {
|
|
1344
1451
|
const { mouseX, mouseY, maxMovement, isReducedMotion } = useContext2(Hover3DContext);
|
|
1452
|
+
const layerX = useTransform2(mouseX ?? useMotionValue4(0), (val) => val * maxMovement * depth);
|
|
1453
|
+
const layerY = useTransform2(mouseY ?? useMotionValue4(0), (val) => val * maxMovement * depth);
|
|
1345
1454
|
if (isReducedMotion || mouseX === null) {
|
|
1346
1455
|
return /* @__PURE__ */ jsx17("div", { ref, className, style: { position: "absolute", inset: 0, ...style }, ...props, children });
|
|
1347
1456
|
}
|
|
@@ -1353,21 +1462,12 @@ var Hover3DLayer = forwardRef15(
|
|
|
1353
1462
|
style: {
|
|
1354
1463
|
position: "absolute",
|
|
1355
1464
|
inset: 0,
|
|
1356
|
-
x:
|
|
1357
|
-
|
|
1358
|
-
y: useMotionValue4(0),
|
|
1465
|
+
x: layerX,
|
|
1466
|
+
y: layerY,
|
|
1359
1467
|
transformStyle: "preserve-3d",
|
|
1468
|
+
willChange: "transform",
|
|
1360
1469
|
...style
|
|
1361
1470
|
},
|
|
1362
|
-
...{
|
|
1363
|
-
style: {
|
|
1364
|
-
x: depth > 0 ? mouseX.get() * maxMovement * depth : 0,
|
|
1365
|
-
y: depth > 0 ? mouseY.get() * maxMovement * depth : 0,
|
|
1366
|
-
position: "absolute",
|
|
1367
|
-
inset: 0,
|
|
1368
|
-
...style
|
|
1369
|
-
}
|
|
1370
|
-
},
|
|
1371
1471
|
...props,
|
|
1372
1472
|
children
|
|
1373
1473
|
}
|
|
@@ -1379,7 +1479,7 @@ var Hover3D = Object.assign(Hover3DRoot, { Layer: Hover3DLayer });
|
|
|
1379
1479
|
|
|
1380
1480
|
// src/primitives/16-scroll-velocity.tsx
|
|
1381
1481
|
import React17, { forwardRef as forwardRef16, useEffect as useEffect14, useRef as useRef7 } from "react";
|
|
1382
|
-
import { motion as motion16, useScroll as useScroll2, useVelocity, useSpring as useSpring5, useTransform as
|
|
1482
|
+
import { motion as motion16, useScroll as useScroll2, useVelocity, useSpring as useSpring5, useTransform as useTransform3 } from "motion/react";
|
|
1383
1483
|
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1384
1484
|
var ScrollVelocity = forwardRef16(
|
|
1385
1485
|
({
|
|
@@ -1409,21 +1509,21 @@ var ScrollVelocity = forwardRef16(
|
|
|
1409
1509
|
stiffness: 400
|
|
1410
1510
|
});
|
|
1411
1511
|
const maxEffectVal = maxEffect ?? (effect === "blur" ? 10 : effect === "stretch" ? 1.5 : effect === "skew" ? 15 : effect === "speed" ? 100 : 1);
|
|
1412
|
-
const filter =
|
|
1512
|
+
const filter = useTransform3(smoothedVelocity, (v) => {
|
|
1413
1513
|
if (effect !== "blur") return "none";
|
|
1414
1514
|
const val = Math.min(Math.abs(v) * sensitivity * 0.01, maxEffectVal);
|
|
1415
1515
|
return `blur(${val}px)`;
|
|
1416
1516
|
});
|
|
1417
|
-
const scaleY =
|
|
1517
|
+
const scaleY = useTransform3(smoothedVelocity, (v) => {
|
|
1418
1518
|
if (effect !== "stretch") return 1;
|
|
1419
1519
|
const val = Math.min(1 + Math.abs(v) * sensitivity * 1e-3, maxEffectVal);
|
|
1420
1520
|
return val;
|
|
1421
1521
|
});
|
|
1422
|
-
const
|
|
1522
|
+
const skewDeg = useTransform3(smoothedVelocity, (v) => {
|
|
1423
1523
|
if (effect !== "skew") return 0;
|
|
1424
1524
|
const sign = Math.sign(v);
|
|
1425
1525
|
const val = Math.min(Math.abs(v) * sensitivity * 0.1, maxEffectVal);
|
|
1426
|
-
return
|
|
1526
|
+
return sign * val;
|
|
1427
1527
|
});
|
|
1428
1528
|
useEffect14(() => {
|
|
1429
1529
|
if (effect === "speed" && internalRef.current) {
|
|
@@ -1434,10 +1534,26 @@ var ScrollVelocity = forwardRef16(
|
|
|
1434
1534
|
});
|
|
1435
1535
|
}
|
|
1436
1536
|
}, [effect, smoothedVelocity, sensitivity, maxEffectVal]);
|
|
1537
|
+
useEffect14(() => {
|
|
1538
|
+
if (typeof children === "function") {
|
|
1539
|
+
return smoothedVelocity.on("change", (latest) => {
|
|
1540
|
+
if (internalRef.current) {
|
|
1541
|
+
internalRef.current.dataset.velocity = latest.toString();
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
}, [children, smoothedVelocity]);
|
|
1437
1546
|
const [currentVelocity, setCurrentVelocity] = React17.useState(0);
|
|
1547
|
+
const lastUpdateRef = useRef7(0);
|
|
1438
1548
|
useEffect14(() => {
|
|
1439
1549
|
if (typeof children === "function") {
|
|
1440
|
-
return smoothedVelocity.on("change",
|
|
1550
|
+
return smoothedVelocity.on("change", (latest) => {
|
|
1551
|
+
const now = performance.now();
|
|
1552
|
+
if (now - lastUpdateRef.current > 33) {
|
|
1553
|
+
lastUpdateRef.current = now;
|
|
1554
|
+
setCurrentVelocity(latest);
|
|
1555
|
+
}
|
|
1556
|
+
});
|
|
1441
1557
|
}
|
|
1442
1558
|
}, [children, smoothedVelocity]);
|
|
1443
1559
|
return /* @__PURE__ */ jsx18(
|
|
@@ -1449,10 +1565,10 @@ var ScrollVelocity = forwardRef16(
|
|
|
1449
1565
|
...style,
|
|
1450
1566
|
filter,
|
|
1451
1567
|
scaleY,
|
|
1452
|
-
|
|
1453
|
-
|
|
1568
|
+
skewY: effect === "skew" ? skewDeg : void 0,
|
|
1569
|
+
transformOrigin: direction === "y" ? "center" : "left",
|
|
1570
|
+
willChange: "transform"
|
|
1454
1571
|
},
|
|
1455
|
-
animate: effect === "skew" ? { skewY: skewY.get() } : void 0,
|
|
1456
1572
|
...props,
|
|
1457
1573
|
children: typeof children === "function" ? children(currentVelocity) : children
|
|
1458
1574
|
}
|
|
@@ -1491,18 +1607,53 @@ var Spotlight = forwardRef17(
|
|
|
1491
1607
|
const mouseY = useMotionValue5(0);
|
|
1492
1608
|
const x = useSpring6(mouseX, isReducedMotion ? { duration: 0 } : springConfig);
|
|
1493
1609
|
const y = useSpring6(mouseY, isReducedMotion ? { duration: 0 } : springConfig);
|
|
1494
|
-
const
|
|
1495
|
-
|
|
1496
|
-
if (
|
|
1497
|
-
|
|
1610
|
+
const rectRef = useRef8(null);
|
|
1611
|
+
const updateRect = useCallback4(() => {
|
|
1612
|
+
if (internalRef.current) {
|
|
1613
|
+
rectRef.current = internalRef.current.getBoundingClientRect();
|
|
1614
|
+
}
|
|
1615
|
+
}, []);
|
|
1616
|
+
useEffect15(() => {
|
|
1617
|
+
updateRect();
|
|
1618
|
+
window.addEventListener("scroll", updateRect, { passive: true });
|
|
1619
|
+
window.addEventListener("resize", updateRect, { passive: true });
|
|
1620
|
+
return () => {
|
|
1621
|
+
window.removeEventListener("scroll", updateRect);
|
|
1622
|
+
window.removeEventListener("resize", updateRect);
|
|
1623
|
+
};
|
|
1624
|
+
}, [updateRect]);
|
|
1625
|
+
const rafId = useRef8(0);
|
|
1626
|
+
const latestEvent = useRef8(null);
|
|
1627
|
+
const processMouseMove = useCallback4(() => {
|
|
1628
|
+
rafId.current = 0;
|
|
1629
|
+
const e = latestEvent.current;
|
|
1630
|
+
if (!e) return;
|
|
1631
|
+
const rect = rectRef.current;
|
|
1632
|
+
if (!rect) return;
|
|
1498
1633
|
mouseX.set(e.clientX - rect.left);
|
|
1499
1634
|
mouseY.set(e.clientY - rect.top);
|
|
1500
|
-
}, [mouseX, mouseY
|
|
1635
|
+
}, [mouseX, mouseY]);
|
|
1636
|
+
const handleMouseMove = useCallback4((e) => {
|
|
1637
|
+
if (disabled || isReducedMotion || disableOnTouch && isTouchDevice) return;
|
|
1638
|
+
if (!rectRef.current && internalRef.current) {
|
|
1639
|
+
rectRef.current = internalRef.current.getBoundingClientRect();
|
|
1640
|
+
}
|
|
1641
|
+
latestEvent.current = e;
|
|
1642
|
+
if (!rafId.current) {
|
|
1643
|
+
rafId.current = requestAnimationFrame(processMouseMove);
|
|
1644
|
+
}
|
|
1645
|
+
}, [disabled, isReducedMotion, disableOnTouch, isTouchDevice, processMouseMove]);
|
|
1646
|
+
useEffect15(() => {
|
|
1647
|
+
return () => {
|
|
1648
|
+
if (rafId.current) cancelAnimationFrame(rafId.current);
|
|
1649
|
+
};
|
|
1650
|
+
}, []);
|
|
1651
|
+
const cappedBlur = Math.min(blur, 20);
|
|
1652
|
+
const background = useMotionTemplate2`radial-gradient(${size}px circle at ${x}px ${y}px, ${color}, transparent 100%)`;
|
|
1653
|
+
const borderBackground = borderColor ? useMotionTemplate2`radial-gradient(${size}px circle at ${x}px ${y}px, ${borderColor}, transparent 100%)` : background;
|
|
1501
1654
|
if (disabled || isReducedMotion) {
|
|
1502
1655
|
return /* @__PURE__ */ jsx19("div", { ref: mergedRef, className, style: { position: "relative", ...style }, ...props, children });
|
|
1503
1656
|
}
|
|
1504
|
-
const background = useMotionTemplate2`radial-gradient(${size}px circle at ${x}px ${y}px, ${color}, transparent 100%)`;
|
|
1505
|
-
const borderBackground = borderColor ? useMotionTemplate2`radial-gradient(${size}px circle at ${x}px ${y}px, ${borderColor}, transparent 100%)` : background;
|
|
1506
1657
|
return /* @__PURE__ */ jsxs6(
|
|
1507
1658
|
"div",
|
|
1508
1659
|
{
|
|
@@ -1518,14 +1669,14 @@ var Spotlight = forwardRef17(
|
|
|
1518
1669
|
style: {
|
|
1519
1670
|
position: "absolute",
|
|
1520
1671
|
inset: -1,
|
|
1521
|
-
// Adjust based on desired border width
|
|
1522
1672
|
background: borderBackground,
|
|
1523
1673
|
opacity,
|
|
1524
1674
|
zIndex: 0,
|
|
1525
1675
|
pointerEvents: "none",
|
|
1526
1676
|
borderRadius: "inherit",
|
|
1527
1677
|
maskImage: "linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",
|
|
1528
|
-
maskComposite: "exclude"
|
|
1678
|
+
maskComposite: "exclude",
|
|
1679
|
+
willChange: "background"
|
|
1529
1680
|
}
|
|
1530
1681
|
}
|
|
1531
1682
|
),
|
|
@@ -1542,7 +1693,8 @@ var Spotlight = forwardRef17(
|
|
|
1542
1693
|
pointerEvents: "none",
|
|
1543
1694
|
borderRadius: "inherit",
|
|
1544
1695
|
mixBlendMode: mode === "reveal" ? "overlay" : "normal",
|
|
1545
|
-
filter: `blur(${
|
|
1696
|
+
filter: `blur(${cappedBlur}px)`,
|
|
1697
|
+
willChange: "background"
|
|
1546
1698
|
}
|
|
1547
1699
|
}
|
|
1548
1700
|
)
|
|
@@ -1554,7 +1706,7 @@ var Spotlight = forwardRef17(
|
|
|
1554
1706
|
Spotlight.displayName = "Spotlight";
|
|
1555
1707
|
|
|
1556
1708
|
// src/primitives/18-follow-cursor.tsx
|
|
1557
|
-
import React19, { forwardRef as forwardRef18, useCallback as useCallback5, useEffect as useEffect16, useState as useState11 } from "react";
|
|
1709
|
+
import React19, { forwardRef as forwardRef18, useCallback as useCallback5, useEffect as useEffect16, useRef as useRef9, useState as useState11 } from "react";
|
|
1558
1710
|
import { motion as motion18, useMotionValue as useMotionValue6, useSpring as useSpring7 } from "motion/react";
|
|
1559
1711
|
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
1560
1712
|
var FollowCursor = forwardRef18(
|
|
@@ -1589,6 +1741,7 @@ var FollowCursor = forwardRef18(
|
|
|
1589
1741
|
const smoothY = useSpring7(y, isReducedMotion ? { duration: 0 } : springConfig);
|
|
1590
1742
|
const smoothR = useSpring7(r, isReducedMotion ? { duration: 0 } : springConfig);
|
|
1591
1743
|
const [isVisible, setIsVisible] = useState11(visible && !hideOnLeave);
|
|
1744
|
+
const prevPos = useRef9({ x: 0, y: 0 });
|
|
1592
1745
|
const updatePosition = useCallback5((clientX, clientY) => {
|
|
1593
1746
|
let posX = clientX + offset.x;
|
|
1594
1747
|
let posY = clientY + offset.y;
|
|
@@ -1598,21 +1751,34 @@ var FollowCursor = forwardRef18(
|
|
|
1598
1751
|
posY = clientY - parentRect.top + offset.y;
|
|
1599
1752
|
}
|
|
1600
1753
|
if (rotate) {
|
|
1601
|
-
const dx = posX - x
|
|
1602
|
-
const dy = posY - y
|
|
1754
|
+
const dx = posX - prevPos.current.x;
|
|
1755
|
+
const dy = posY - prevPos.current.y;
|
|
1603
1756
|
if (dx !== 0 || dy !== 0) {
|
|
1604
1757
|
const angle = Math.atan2(dy, dx) * (180 / Math.PI);
|
|
1605
1758
|
r.set(angle);
|
|
1606
1759
|
}
|
|
1607
1760
|
}
|
|
1761
|
+
prevPos.current.x = posX;
|
|
1762
|
+
prevPos.current.y = posY;
|
|
1608
1763
|
x.set(posX);
|
|
1609
1764
|
y.set(posY);
|
|
1610
1765
|
}, [x, y, r, rotate, offset, containTo]);
|
|
1766
|
+
const rafId = useRef9(0);
|
|
1767
|
+
const latestMouse = useRef9(null);
|
|
1768
|
+
const processMouseMove = useCallback5(() => {
|
|
1769
|
+
rafId.current = 0;
|
|
1770
|
+
const e = latestMouse.current;
|
|
1771
|
+
if (!e) return;
|
|
1772
|
+
updatePosition(e.x, e.y);
|
|
1773
|
+
}, [updatePosition]);
|
|
1611
1774
|
useEffect16(() => {
|
|
1612
1775
|
if (disabled || isReducedMotion) return;
|
|
1613
1776
|
const target = containTo === "viewport" ? window : internalRef.current?.parentElement || window;
|
|
1614
1777
|
const handleMouseMove = (e) => {
|
|
1615
|
-
|
|
1778
|
+
latestMouse.current = { x: e.clientX, y: e.clientY };
|
|
1779
|
+
if (!rafId.current) {
|
|
1780
|
+
rafId.current = requestAnimationFrame(processMouseMove);
|
|
1781
|
+
}
|
|
1616
1782
|
if (hideOnLeave && !isVisible) setIsVisible(visible);
|
|
1617
1783
|
};
|
|
1618
1784
|
const handleMouseEnter = () => {
|
|
@@ -1621,15 +1787,16 @@ var FollowCursor = forwardRef18(
|
|
|
1621
1787
|
const handleMouseLeave = () => {
|
|
1622
1788
|
if (hideOnLeave) setIsVisible(false);
|
|
1623
1789
|
};
|
|
1624
|
-
target.addEventListener("mousemove", handleMouseMove);
|
|
1625
|
-
target.addEventListener("mouseenter", handleMouseEnter);
|
|
1626
|
-
target.addEventListener("mouseleave", handleMouseLeave);
|
|
1790
|
+
target.addEventListener("mousemove", handleMouseMove, { passive: true });
|
|
1791
|
+
target.addEventListener("mouseenter", handleMouseEnter, { passive: true });
|
|
1792
|
+
target.addEventListener("mouseleave", handleMouseLeave, { passive: true });
|
|
1627
1793
|
return () => {
|
|
1628
1794
|
target.removeEventListener("mousemove", handleMouseMove);
|
|
1629
1795
|
target.removeEventListener("mouseenter", handleMouseEnter);
|
|
1630
1796
|
target.removeEventListener("mouseleave", handleMouseLeave);
|
|
1797
|
+
if (rafId.current) cancelAnimationFrame(rafId.current);
|
|
1631
1798
|
};
|
|
1632
|
-
}, [disabled, isReducedMotion, containTo,
|
|
1799
|
+
}, [disabled, isReducedMotion, containTo, processMouseMove, hideOnLeave, visible, isVisible]);
|
|
1633
1800
|
useEffect16(() => {
|
|
1634
1801
|
setIsVisible(visible);
|
|
1635
1802
|
}, [visible]);
|
|
@@ -1653,9 +1820,8 @@ var FollowCursor = forwardRef18(
|
|
|
1653
1820
|
rotate: smoothR,
|
|
1654
1821
|
opacity: isVisible ? 1 : 0,
|
|
1655
1822
|
pointerEvents: "none",
|
|
1656
|
-
// Cursor followers typically shouldn't block events
|
|
1657
1823
|
zIndex: 50,
|
|
1658
|
-
|
|
1824
|
+
willChange: "transform",
|
|
1659
1825
|
...style
|
|
1660
1826
|
},
|
|
1661
1827
|
animate: { opacity: isVisible ? 1 : 0 },
|
|
@@ -1714,7 +1880,7 @@ var Morph = forwardRef19(
|
|
|
1714
1880
|
Morph.displayName = "Morph";
|
|
1715
1881
|
|
|
1716
1882
|
// src/primitives/20-fluid-layout.tsx
|
|
1717
|
-
import { forwardRef as forwardRef20, useRef as
|
|
1883
|
+
import { forwardRef as forwardRef20, useRef as useRef10 } from "react";
|
|
1718
1884
|
import { motion as motion20 } from "motion/react";
|
|
1719
1885
|
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
1720
1886
|
var FluidLayout = forwardRef20(
|
|
@@ -1731,7 +1897,7 @@ var FluidLayout = forwardRef20(
|
|
|
1731
1897
|
...props
|
|
1732
1898
|
}, ref) => {
|
|
1733
1899
|
const isReducedMotion = useReducedMotion();
|
|
1734
|
-
const internalRef =
|
|
1900
|
+
const internalRef = useRef10(null);
|
|
1735
1901
|
const mergedRef = useMergedRef(ref, internalRef);
|
|
1736
1902
|
const springConfig = resolveMotion(physics2, void 0, isReducedMotion);
|
|
1737
1903
|
if (disabled || isReducedMotion) {
|
|
@@ -1983,7 +2149,7 @@ function AnimatedListComponent({
|
|
|
1983
2149
|
var AnimatedList = forwardRef23(AnimatedListComponent);
|
|
1984
2150
|
|
|
1985
2151
|
// src/primitives/24-marquee.tsx
|
|
1986
|
-
import { forwardRef as forwardRef24, useEffect as useEffect18, useRef as
|
|
2152
|
+
import { forwardRef as forwardRef24, useEffect as useEffect18, useMemo as useMemo3, useRef as useRef11, useState as useState13 } from "react";
|
|
1987
2153
|
import { jsx as jsx26, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1988
2154
|
var Marquee = forwardRef24(
|
|
1989
2155
|
({
|
|
@@ -2002,9 +2168,9 @@ var Marquee = forwardRef24(
|
|
|
2002
2168
|
...props
|
|
2003
2169
|
}, ref) => {
|
|
2004
2170
|
const isReducedMotion = useReducedMotion();
|
|
2005
|
-
const internalRef =
|
|
2006
|
-
const containerRef =
|
|
2007
|
-
const contentRef =
|
|
2171
|
+
const internalRef = useRef11(null);
|
|
2172
|
+
const containerRef = useRef11(null);
|
|
2173
|
+
const contentRef = useRef11(null);
|
|
2008
2174
|
const mergedRef = useMergedRef(ref, internalRef);
|
|
2009
2175
|
const [contentSize, setContentSize] = useState13(0);
|
|
2010
2176
|
const [containerSize, setContainerSize] = useState13(0);
|
|
@@ -2014,18 +2180,25 @@ var Marquee = forwardRef24(
|
|
|
2014
2180
|
const calcDir = dirFactor * revFactor;
|
|
2015
2181
|
useEffect18(() => {
|
|
2016
2182
|
if (disabled || isReducedMotion) return;
|
|
2183
|
+
let resizeTimeout;
|
|
2017
2184
|
const observer = new ResizeObserver((entries) => {
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2185
|
+
clearTimeout(resizeTimeout);
|
|
2186
|
+
resizeTimeout = setTimeout(() => {
|
|
2187
|
+
for (const entry of entries) {
|
|
2188
|
+
if (entry.target === containerRef.current) {
|
|
2189
|
+
setContainerSize(isHorizontal ? entry.contentRect.width : entry.contentRect.height);
|
|
2190
|
+
} else if (entry.target === contentRef.current) {
|
|
2191
|
+
setContentSize(isHorizontal ? entry.contentRect.width : entry.contentRect.height);
|
|
2192
|
+
}
|
|
2023
2193
|
}
|
|
2024
|
-
}
|
|
2194
|
+
}, 100);
|
|
2025
2195
|
});
|
|
2026
2196
|
if (containerRef.current) observer.observe(containerRef.current);
|
|
2027
2197
|
if (contentRef.current) observer.observe(contentRef.current);
|
|
2028
|
-
return () =>
|
|
2198
|
+
return () => {
|
|
2199
|
+
clearTimeout(resizeTimeout);
|
|
2200
|
+
observer.disconnect();
|
|
2201
|
+
};
|
|
2029
2202
|
}, [isHorizontal, disabled, isReducedMotion]);
|
|
2030
2203
|
if (disabled || isReducedMotion) {
|
|
2031
2204
|
return /* @__PURE__ */ jsx26("div", { ref: mergedRef, className, style: { display: "flex", flexWrap: "wrap", gap, ...style }, ...props, children });
|
|
@@ -2034,12 +2207,12 @@ var Marquee = forwardRef24(
|
|
|
2034
2207
|
const duration = (contentSize + gap) / speed;
|
|
2035
2208
|
const keyframesName = `flux-marquee-${calcDir < 0 ? "negative" : "positive"}-${isHorizontal ? "x" : "y"}`;
|
|
2036
2209
|
const translateProp = isHorizontal ? "translateX" : "translateY";
|
|
2037
|
-
const cssString = `
|
|
2210
|
+
const cssString = useMemo3(() => `
|
|
2038
2211
|
@keyframes ${keyframesName} {
|
|
2039
2212
|
0% { transform: ${translateProp}(${calcDir < 0 ? "0" : `-${contentSize + gap}px`}); }
|
|
2040
2213
|
100% { transform: ${translateProp}(${calcDir < 0 ? `-${contentSize + gap}px` : "0"}); }
|
|
2041
2214
|
}
|
|
2042
|
-
|
|
2215
|
+
`, [keyframesName, translateProp, calcDir, contentSize, gap]);
|
|
2043
2216
|
const gradientMask = gradientWidth > 0 && isHorizontal ? `linear-gradient(to right, transparent, black ${gradientWidth}px, black calc(100% - ${gradientWidth}px), transparent)` : gradientWidth > 0 && !isHorizontal ? `linear-gradient(to bottom, transparent, black ${gradientWidth}px, black calc(100% - ${gradientWidth}px), transparent)` : void 0;
|
|
2044
2217
|
return /* @__PURE__ */ jsxs7(
|
|
2045
2218
|
"div",
|
|
@@ -2068,7 +2241,8 @@ var Marquee = forwardRef24(
|
|
|
2068
2241
|
width: isHorizontal ? "fit-content" : "100%",
|
|
2069
2242
|
height: isHorizontal ? "100%" : "fit-content",
|
|
2070
2243
|
animation: `${keyframesName} ${duration}s linear infinite`,
|
|
2071
|
-
animationPlayState: "inherit"
|
|
2244
|
+
animationPlayState: "inherit",
|
|
2245
|
+
willChange: "transform"
|
|
2072
2246
|
},
|
|
2073
2247
|
onMouseEnter: (e) => {
|
|
2074
2248
|
if (pauseOnHover) e.currentTarget.style.animationPlayState = "paused";
|
|
@@ -2102,8 +2276,8 @@ var Marquee = forwardRef24(
|
|
|
2102
2276
|
Marquee.displayName = "Marquee";
|
|
2103
2277
|
|
|
2104
2278
|
// src/primitives/25-dock.tsx
|
|
2105
|
-
import React26, { forwardRef as forwardRef25, useRef as
|
|
2106
|
-
import { motion as motion23, useMotionValue as useMotionValue7, useSpring as useSpring8, useTransform as
|
|
2279
|
+
import React26, { forwardRef as forwardRef25, useCallback as useCallback6, useMemo as useMemo4, useRef as useRef12 } from "react";
|
|
2280
|
+
import { motion as motion23, useMotionValue as useMotionValue7, useSpring as useSpring8, useTransform as useTransform4 } from "motion/react";
|
|
2107
2281
|
import { jsx as jsx27, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2108
2282
|
var DockContext = React26.createContext({
|
|
2109
2283
|
mouseX: null,
|
|
@@ -2128,14 +2302,41 @@ var DockRoot = forwardRef25(
|
|
|
2128
2302
|
...props
|
|
2129
2303
|
}, ref) => {
|
|
2130
2304
|
const isReducedMotion = useReducedMotion();
|
|
2131
|
-
const internalRef =
|
|
2305
|
+
const internalRef = useRef12(null);
|
|
2132
2306
|
const mergedRef = useMergedRef(ref, internalRef);
|
|
2133
2307
|
const mouseX = useMotionValue7(Infinity);
|
|
2134
2308
|
const mouseY = useMotionValue7(Infinity);
|
|
2309
|
+
const rafId = useRef12(0);
|
|
2310
|
+
const latestEvent = useRef12(null);
|
|
2311
|
+
const processMouseMove = useCallback6(() => {
|
|
2312
|
+
rafId.current = 0;
|
|
2313
|
+
const e = latestEvent.current;
|
|
2314
|
+
if (!e) return;
|
|
2315
|
+
mouseX.set(e.clientX);
|
|
2316
|
+
mouseY.set(e.clientY);
|
|
2317
|
+
}, [mouseX, mouseY]);
|
|
2318
|
+
const handleMouseMove = useCallback6((e) => {
|
|
2319
|
+
latestEvent.current = { clientX: e.clientX, clientY: e.clientY };
|
|
2320
|
+
if (!rafId.current) {
|
|
2321
|
+
rafId.current = requestAnimationFrame(processMouseMove);
|
|
2322
|
+
}
|
|
2323
|
+
}, [processMouseMove]);
|
|
2324
|
+
const handleMouseLeave = useCallback6(() => {
|
|
2325
|
+
mouseX.set(Infinity);
|
|
2326
|
+
mouseY.set(Infinity);
|
|
2327
|
+
}, [mouseX, mouseY]);
|
|
2328
|
+
const contextValue = useMemo4(() => ({
|
|
2329
|
+
mouseX,
|
|
2330
|
+
mouseY,
|
|
2331
|
+
distance,
|
|
2332
|
+
magnification,
|
|
2333
|
+
direction,
|
|
2334
|
+
isReducedMotion: false
|
|
2335
|
+
}), [mouseX, mouseY, distance, magnification, direction]);
|
|
2135
2336
|
if (disabled || isReducedMotion) {
|
|
2136
2337
|
return /* @__PURE__ */ jsx27("div", { ref: mergedRef, className, style: { display: "flex", flexDirection: direction === "horizontal" ? "row" : "column", gap, ...style }, ...props, children });
|
|
2137
2338
|
}
|
|
2138
|
-
return /* @__PURE__ */ jsx27(DockContext.Provider, { value:
|
|
2339
|
+
return /* @__PURE__ */ jsx27(DockContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx27(
|
|
2139
2340
|
motion23.div,
|
|
2140
2341
|
{
|
|
2141
2342
|
ref: mergedRef,
|
|
@@ -2147,14 +2348,8 @@ var DockRoot = forwardRef25(
|
|
|
2147
2348
|
alignItems: "center",
|
|
2148
2349
|
...style
|
|
2149
2350
|
},
|
|
2150
|
-
onMouseMove:
|
|
2151
|
-
|
|
2152
|
-
mouseY.set(e.clientY);
|
|
2153
|
-
},
|
|
2154
|
-
onMouseLeave: () => {
|
|
2155
|
-
mouseX.set(Infinity);
|
|
2156
|
-
mouseY.set(Infinity);
|
|
2157
|
-
},
|
|
2351
|
+
onMouseMove: handleMouseMove,
|
|
2352
|
+
onMouseLeave: handleMouseLeave,
|
|
2158
2353
|
...props,
|
|
2159
2354
|
children
|
|
2160
2355
|
}
|
|
@@ -2165,16 +2360,33 @@ DockRoot.displayName = "Dock";
|
|
|
2165
2360
|
var DockItem = forwardRef25(
|
|
2166
2361
|
({ children, label, onClick, className, style, ...props }, ref) => {
|
|
2167
2362
|
const { mouseX, mouseY, distance, magnification, direction, isReducedMotion } = React26.useContext(DockContext);
|
|
2168
|
-
const itemRef =
|
|
2363
|
+
const itemRef = useRef12(null);
|
|
2169
2364
|
const mergedRef = useMergedRef(ref, itemRef);
|
|
2170
2365
|
const distVar = direction === "horizontal" ? mouseX : mouseY;
|
|
2171
|
-
const
|
|
2172
|
-
|
|
2173
|
-
const
|
|
2366
|
+
const rectRef = useRef12(null);
|
|
2367
|
+
React26.useEffect(() => {
|
|
2368
|
+
const el = itemRef.current;
|
|
2369
|
+
if (!el) return;
|
|
2370
|
+
const updateRect = () => {
|
|
2371
|
+
rectRef.current = el.getBoundingClientRect();
|
|
2372
|
+
};
|
|
2373
|
+
updateRect();
|
|
2374
|
+
const ro = new ResizeObserver(updateRect);
|
|
2375
|
+
ro.observe(el);
|
|
2376
|
+
window.addEventListener("scroll", updateRect, { passive: true });
|
|
2377
|
+
return () => {
|
|
2378
|
+
ro.disconnect();
|
|
2379
|
+
window.removeEventListener("scroll", updateRect);
|
|
2380
|
+
};
|
|
2381
|
+
}, []);
|
|
2382
|
+
const distanceCalc = useTransform4(distVar, (val) => {
|
|
2383
|
+
if (val === Infinity) return distance;
|
|
2384
|
+
const bounds = rectRef.current;
|
|
2385
|
+
if (!bounds) return distance;
|
|
2174
2386
|
const center = direction === "horizontal" ? bounds.x + bounds.width / 2 : bounds.y + bounds.height / 2;
|
|
2175
2387
|
return Math.abs(val - center);
|
|
2176
2388
|
});
|
|
2177
|
-
const scaleRaw =
|
|
2389
|
+
const scaleRaw = useTransform4(distanceCalc, [0, distance], [magnification, 1]);
|
|
2178
2390
|
const scale = useSpring8(scaleRaw, { mass: 0.1, stiffness: 300, damping: 20 });
|
|
2179
2391
|
const [isHovered, setIsHovered] = React26.useState(false);
|
|
2180
2392
|
if (isReducedMotion) {
|
|
@@ -2190,11 +2402,11 @@ var DockItem = forwardRef25(
|
|
|
2190
2402
|
style: {
|
|
2191
2403
|
scale,
|
|
2192
2404
|
transformOrigin: direction === "horizontal" ? "bottom" : "left",
|
|
2193
|
-
// Common dock origin
|
|
2194
2405
|
display: "flex",
|
|
2195
2406
|
alignItems: "center",
|
|
2196
2407
|
justifyContent: "center",
|
|
2197
2408
|
position: "relative",
|
|
2409
|
+
willChange: "transform",
|
|
2198
2410
|
...style
|
|
2199
2411
|
},
|
|
2200
2412
|
className,
|
|
@@ -2230,7 +2442,7 @@ DockItem.displayName = "Dock.Item";
|
|
|
2230
2442
|
var Dock = Object.assign(DockRoot, { Item: DockItem });
|
|
2231
2443
|
|
|
2232
2444
|
// src/primitives/26-infinite-scroll.tsx
|
|
2233
|
-
import { forwardRef as forwardRef26, useEffect as useEffect19, useRef as
|
|
2445
|
+
import { forwardRef as forwardRef26, useEffect as useEffect19, useRef as useRef13, useState as useState14 } from "react";
|
|
2234
2446
|
import { jsx as jsx28, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2235
2447
|
function InfiniteScrollComponent({
|
|
2236
2448
|
items,
|
|
@@ -2249,9 +2461,9 @@ function InfiniteScrollComponent({
|
|
|
2249
2461
|
disabled = false
|
|
2250
2462
|
}, ref) {
|
|
2251
2463
|
const isReducedMotion = useReducedMotion();
|
|
2252
|
-
const internalRef =
|
|
2253
|
-
const scrollRef =
|
|
2254
|
-
const endMarkerRef =
|
|
2464
|
+
const internalRef = useRef13(null);
|
|
2465
|
+
const scrollRef = useRef13(null);
|
|
2466
|
+
const endMarkerRef = useRef13(null);
|
|
2255
2467
|
const mergedRef = useMergedRef(ref, internalRef, scrollRef);
|
|
2256
2468
|
const [isLoading, setIsLoading] = useState14(false);
|
|
2257
2469
|
useEffect19(() => {
|
|
@@ -2296,7 +2508,7 @@ function InfiniteScrollComponent({
|
|
|
2296
2508
|
var InfiniteScroll = forwardRef26(InfiniteScrollComponent);
|
|
2297
2509
|
|
|
2298
2510
|
// src/primitives/27-scroll-progress.tsx
|
|
2299
|
-
import { forwardRef as forwardRef27, useRef as
|
|
2511
|
+
import { forwardRef as forwardRef27, useRef as useRef14 } from "react";
|
|
2300
2512
|
import { motion as motion24, useScroll as useScroll3, useSpring as useSpring9 } from "motion/react";
|
|
2301
2513
|
import { jsx as jsx29, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2302
2514
|
var ScrollProgress = forwardRef27(
|
|
@@ -2314,7 +2526,7 @@ var ScrollProgress = forwardRef27(
|
|
|
2314
2526
|
...props
|
|
2315
2527
|
}, ref) => {
|
|
2316
2528
|
const isReducedMotion = useReducedMotion();
|
|
2317
|
-
const internalRef =
|
|
2529
|
+
const internalRef = useRef14(null);
|
|
2318
2530
|
const mergedRef = useMergedRef(ref, internalRef);
|
|
2319
2531
|
const { scrollYProgress, scrollXProgress } = useScroll3({
|
|
2320
2532
|
container: container?.current ? container : void 0
|
|
@@ -2342,6 +2554,7 @@ var ScrollProgress = forwardRef27(
|
|
|
2342
2554
|
...dimStyles,
|
|
2343
2555
|
backgroundColor: color,
|
|
2344
2556
|
zIndex: 9999,
|
|
2557
|
+
willChange: "transform",
|
|
2345
2558
|
...style
|
|
2346
2559
|
},
|
|
2347
2560
|
...props
|
|
@@ -2363,7 +2576,8 @@ var ScrollProgress = forwardRef27(
|
|
|
2363
2576
|
scaleX: axis === "x" ? scaleValue : void 0,
|
|
2364
2577
|
scaleY: axis === "y" ? scaleValue : void 0,
|
|
2365
2578
|
transformOrigin: "0% 0%",
|
|
2366
|
-
zIndex: -1
|
|
2579
|
+
zIndex: -1,
|
|
2580
|
+
willChange: "transform"
|
|
2367
2581
|
}
|
|
2368
2582
|
}
|
|
2369
2583
|
)
|
|
@@ -2373,8 +2587,8 @@ var ScrollProgress = forwardRef27(
|
|
|
2373
2587
|
ScrollProgress.displayName = "ScrollProgress";
|
|
2374
2588
|
|
|
2375
2589
|
// src/primitives/28-parallax.tsx
|
|
2376
|
-
import { forwardRef as forwardRef28, useRef as
|
|
2377
|
-
import { motion as motion25, useScroll as useScroll4, useTransform as
|
|
2590
|
+
import { forwardRef as forwardRef28, useRef as useRef15 } from "react";
|
|
2591
|
+
import { motion as motion25, useScroll as useScroll4, useTransform as useTransform5 } from "motion/react";
|
|
2378
2592
|
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
2379
2593
|
var Parallax = forwardRef28(
|
|
2380
2594
|
({
|
|
@@ -2388,7 +2602,7 @@ var Parallax = forwardRef28(
|
|
|
2388
2602
|
...props
|
|
2389
2603
|
}, ref) => {
|
|
2390
2604
|
const isReducedMotion = useReducedMotion();
|
|
2391
|
-
const internalRef =
|
|
2605
|
+
const internalRef = useRef15(null);
|
|
2392
2606
|
const mergedRef = useMergedRef(ref, internalRef);
|
|
2393
2607
|
const { scrollYProgress } = useScroll4({
|
|
2394
2608
|
target: internalRef,
|
|
@@ -2397,7 +2611,7 @@ var Parallax = forwardRef28(
|
|
|
2397
2611
|
});
|
|
2398
2612
|
const transformStart = direction === "up" ? offset : direction === "down" ? -offset : direction === "left" ? offset : -offset;
|
|
2399
2613
|
const transformEnd = direction === "up" ? -offset : direction === "down" ? offset : direction === "left" ? -offset : offset;
|
|
2400
|
-
const translate =
|
|
2614
|
+
const translate = useTransform5(scrollYProgress, [0, 1], [transformStart, transformEnd]);
|
|
2401
2615
|
if (disabled || isReducedMotion) {
|
|
2402
2616
|
return /* @__PURE__ */ jsx30("div", { ref: mergedRef, className, style, ...props, children });
|
|
2403
2617
|
}
|
|
@@ -2409,7 +2623,8 @@ var Parallax = forwardRef28(
|
|
|
2409
2623
|
style: {
|
|
2410
2624
|
...style,
|
|
2411
2625
|
y: direction === "up" || direction === "down" ? translate : 0,
|
|
2412
|
-
x: direction === "left" || direction === "right" ? translate : 0
|
|
2626
|
+
x: direction === "left" || direction === "right" ? translate : 0,
|
|
2627
|
+
willChange: "transform"
|
|
2413
2628
|
},
|
|
2414
2629
|
...props,
|
|
2415
2630
|
children
|
|
@@ -2420,7 +2635,7 @@ var Parallax = forwardRef28(
|
|
|
2420
2635
|
Parallax.displayName = "Parallax";
|
|
2421
2636
|
|
|
2422
2637
|
// src/primitives/29-sticky-scroll.tsx
|
|
2423
|
-
import { forwardRef as forwardRef29, useEffect as useEffect20, useRef as
|
|
2638
|
+
import { forwardRef as forwardRef29, useEffect as useEffect20, useRef as useRef16, useState as useState15 } from "react";
|
|
2424
2639
|
import { motion as motion26, useScroll as useScroll5 } from "motion/react";
|
|
2425
2640
|
import { jsx as jsx31, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2426
2641
|
var StickyScroll = forwardRef29(
|
|
@@ -2434,7 +2649,7 @@ var StickyScroll = forwardRef29(
|
|
|
2434
2649
|
...props
|
|
2435
2650
|
}, ref) => {
|
|
2436
2651
|
const isReducedMotion = useReducedMotion();
|
|
2437
|
-
const internalRef =
|
|
2652
|
+
const internalRef = useRef16(null);
|
|
2438
2653
|
const mergedRef = useMergedRef(ref, internalRef);
|
|
2439
2654
|
const [activeSection, setActiveSection] = useState15(0);
|
|
2440
2655
|
const { scrollYProgress } = useScroll5({
|
|
@@ -2442,16 +2657,30 @@ var StickyScroll = forwardRef29(
|
|
|
2442
2657
|
container: container?.current ? container : void 0,
|
|
2443
2658
|
offset: ["start start", "end end"]
|
|
2444
2659
|
});
|
|
2660
|
+
const lastSectionRef = useRef16(0);
|
|
2445
2661
|
useEffect20(() => {
|
|
2446
|
-
|
|
2662
|
+
let rafId = 0;
|
|
2663
|
+
const unsubscribe = scrollYProgress.on("change", (latest) => {
|
|
2447
2664
|
const cardsCount = content.length;
|
|
2448
2665
|
const progressPerCard = 1 / cardsCount;
|
|
2449
2666
|
const index = Math.min(
|
|
2450
2667
|
Math.floor(latest / progressPerCard),
|
|
2451
2668
|
cardsCount - 1
|
|
2452
2669
|
);
|
|
2453
|
-
|
|
2670
|
+
if (index !== lastSectionRef.current) {
|
|
2671
|
+
lastSectionRef.current = index;
|
|
2672
|
+
if (!rafId) {
|
|
2673
|
+
rafId = requestAnimationFrame(() => {
|
|
2674
|
+
rafId = 0;
|
|
2675
|
+
setActiveSection(index);
|
|
2676
|
+
});
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2454
2679
|
});
|
|
2680
|
+
return () => {
|
|
2681
|
+
unsubscribe();
|
|
2682
|
+
if (rafId) cancelAnimationFrame(rafId);
|
|
2683
|
+
};
|
|
2455
2684
|
}, [scrollYProgress, content.length]);
|
|
2456
2685
|
if (disabled || isReducedMotion) {
|
|
2457
2686
|
return /* @__PURE__ */ jsx31("div", { ref: mergedRef, className, style: { display: "flex", flexDirection: "column", gap: "2rem", ...style }, ...props, children: content.map((item, i) => /* @__PURE__ */ jsxs11("div", { children: [
|
|
@@ -2490,7 +2719,7 @@ var StickyScroll = forwardRef29(
|
|
|
2490
2719
|
{
|
|
2491
2720
|
initial: { opacity: 0, y: 20 },
|
|
2492
2721
|
animate: { opacity: activeSection === index ? 1 : 0, y: activeSection === index ? 0 : 20 },
|
|
2493
|
-
style: { fontSize: "2rem", fontWeight: "bold", marginBottom: "1rem" },
|
|
2722
|
+
style: { fontSize: "2rem", fontWeight: "bold", marginBottom: "1rem", willChange: "transform, opacity" },
|
|
2494
2723
|
children: item.title
|
|
2495
2724
|
}
|
|
2496
2725
|
),
|
|
@@ -2522,7 +2751,7 @@ var StickyScroll = forwardRef29(
|
|
|
2522
2751
|
StickyScroll.displayName = "StickyScroll";
|
|
2523
2752
|
|
|
2524
2753
|
// src/primitives/30-scroll-snap.tsx
|
|
2525
|
-
import React31, { forwardRef as forwardRef30, useRef as
|
|
2754
|
+
import React31, { forwardRef as forwardRef30, useRef as useRef17 } from "react";
|
|
2526
2755
|
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
2527
2756
|
var ScrollSnapContainer = forwardRef30(
|
|
2528
2757
|
({
|
|
@@ -2537,7 +2766,7 @@ var ScrollSnapContainer = forwardRef30(
|
|
|
2537
2766
|
...props
|
|
2538
2767
|
}, ref) => {
|
|
2539
2768
|
const isReducedMotion = useReducedMotion();
|
|
2540
|
-
const internalRef =
|
|
2769
|
+
const internalRef = useRef17(null);
|
|
2541
2770
|
const mergedRef = useMergedRef(ref, internalRef);
|
|
2542
2771
|
return /* @__PURE__ */ jsx32(SnapContext.Provider, { value: { alignment, disabled: disabled || isReducedMotion }, children: /* @__PURE__ */ jsx32(
|
|
2543
2772
|
"div",
|
|
@@ -2582,7 +2811,7 @@ ScrollSnapItem.displayName = "ScrollSnap.Item";
|
|
|
2582
2811
|
var ScrollSnap = Object.assign(ScrollSnapContainer, { Item: ScrollSnapItem });
|
|
2583
2812
|
|
|
2584
2813
|
// src/primitives/31-aurora.tsx
|
|
2585
|
-
import { forwardRef as forwardRef31, useRef as
|
|
2814
|
+
import { forwardRef as forwardRef31, useRef as useRef18 } from "react";
|
|
2586
2815
|
import { jsx as jsx33, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2587
2816
|
var Aurora = forwardRef31(
|
|
2588
2817
|
({
|
|
@@ -2597,21 +2826,9 @@ var Aurora = forwardRef31(
|
|
|
2597
2826
|
...props
|
|
2598
2827
|
}, ref) => {
|
|
2599
2828
|
const isReducedMotion = useReducedMotion();
|
|
2600
|
-
const internalRef =
|
|
2829
|
+
const internalRef = useRef18(null);
|
|
2601
2830
|
const mergedRef = useMergedRef(ref, internalRef);
|
|
2602
2831
|
if (disabled) return null;
|
|
2603
|
-
const baseStyle = {
|
|
2604
|
-
position: "absolute",
|
|
2605
|
-
top: "-50%",
|
|
2606
|
-
left: "-50%",
|
|
2607
|
-
width: "200%",
|
|
2608
|
-
height: "200%",
|
|
2609
|
-
opacity,
|
|
2610
|
-
mixBlendMode: blendMode,
|
|
2611
|
-
filter: `blur(${blur}px)`,
|
|
2612
|
-
pointerEvents: "none",
|
|
2613
|
-
zIndex: 0
|
|
2614
|
-
};
|
|
2615
2832
|
const gradientString = `linear-gradient(-45deg, ${colors.join(", ")})`;
|
|
2616
2833
|
return /* @__PURE__ */ jsxs12(
|
|
2617
2834
|
"div",
|
|
@@ -2631,18 +2848,28 @@ var Aurora = forwardRef31(
|
|
|
2631
2848
|
"div",
|
|
2632
2849
|
{
|
|
2633
2850
|
style: {
|
|
2634
|
-
|
|
2851
|
+
position: "absolute",
|
|
2852
|
+
top: "-50%",
|
|
2853
|
+
left: "-50%",
|
|
2854
|
+
width: "200%",
|
|
2855
|
+
height: "200%",
|
|
2856
|
+
opacity,
|
|
2857
|
+
mixBlendMode: blendMode,
|
|
2858
|
+
filter: `blur(${blur}px)`,
|
|
2859
|
+
pointerEvents: "none",
|
|
2860
|
+
zIndex: 0,
|
|
2635
2861
|
background: gradientString,
|
|
2636
2862
|
backgroundSize: "400% 400%",
|
|
2863
|
+
willChange: "transform",
|
|
2637
2864
|
animation: isReducedMotion ? "none" : `flux-aurora ${speed}s ease infinite`
|
|
2638
2865
|
}
|
|
2639
2866
|
}
|
|
2640
2867
|
),
|
|
2641
2868
|
/* @__PURE__ */ jsx33("style", { children: `
|
|
2642
2869
|
@keyframes flux-aurora {
|
|
2643
|
-
0% { background-position: 0% 50%;
|
|
2644
|
-
50% { background-position: 100% 50%;
|
|
2645
|
-
100% { background-position: 0% 50%;
|
|
2870
|
+
0% { transform: rotate(0deg) scale(1); background-position: 0% 50%; }
|
|
2871
|
+
50% { transform: rotate(180deg) scale(1.05); background-position: 100% 50%; }
|
|
2872
|
+
100% { transform: rotate(360deg) scale(1); background-position: 0% 50%; }
|
|
2646
2873
|
}
|
|
2647
2874
|
` })
|
|
2648
2875
|
]
|
|
@@ -2653,7 +2880,7 @@ var Aurora = forwardRef31(
|
|
|
2653
2880
|
Aurora.displayName = "Aurora";
|
|
2654
2881
|
|
|
2655
2882
|
// src/primitives/32-mesh-gradient.tsx
|
|
2656
|
-
import { forwardRef as forwardRef32, useRef as
|
|
2883
|
+
import { forwardRef as forwardRef32, useRef as useRef19 } from "react";
|
|
2657
2884
|
import { jsx as jsx34, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2658
2885
|
var MeshGradient = forwardRef32(
|
|
2659
2886
|
({
|
|
@@ -2665,13 +2892,12 @@ var MeshGradient = forwardRef32(
|
|
|
2665
2892
|
...props
|
|
2666
2893
|
}, ref) => {
|
|
2667
2894
|
const isReducedMotion = useReducedMotion();
|
|
2668
|
-
const internalRef =
|
|
2895
|
+
const internalRef = useRef19(null);
|
|
2669
2896
|
const mergedRef = useMergedRef(ref, internalRef);
|
|
2670
2897
|
if (disabled) return null;
|
|
2671
2898
|
const baseStyle = {
|
|
2672
2899
|
position: "absolute",
|
|
2673
2900
|
inset: -50,
|
|
2674
|
-
// bleed edge to avoid seeing bounds during rotation
|
|
2675
2901
|
opacity: 0.8,
|
|
2676
2902
|
filter: "blur(60px)",
|
|
2677
2903
|
pointerEvents: "none",
|
|
@@ -2682,7 +2908,8 @@ var MeshGradient = forwardRef32(
|
|
|
2682
2908
|
radial-gradient(circle at 100% 100%, ${colors[2]} 0%, transparent 50%),
|
|
2683
2909
|
radial-gradient(circle at 0% 0%, ${colors[3]} 0%, transparent 50%)
|
|
2684
2910
|
`,
|
|
2685
|
-
backgroundSize: "200% 200%"
|
|
2911
|
+
backgroundSize: "200% 200%",
|
|
2912
|
+
willChange: "transform"
|
|
2686
2913
|
};
|
|
2687
2914
|
return /* @__PURE__ */ jsxs13(
|
|
2688
2915
|
"div",
|
|
@@ -2709,9 +2936,9 @@ var MeshGradient = forwardRef32(
|
|
|
2709
2936
|
),
|
|
2710
2937
|
/* @__PURE__ */ jsx34("style", { children: `
|
|
2711
2938
|
@keyframes flux-mesh {
|
|
2712
|
-
0% {
|
|
2713
|
-
50% {
|
|
2714
|
-
100% {
|
|
2939
|
+
0% { transform: scale(1) rotate(0deg); background-position: 0% 0%; }
|
|
2940
|
+
50% { transform: scale(1.1) rotate(5deg); background-position: 100% 100%; }
|
|
2941
|
+
100% { transform: scale(1) rotate(-5deg); background-position: 0% 0%; }
|
|
2715
2942
|
}
|
|
2716
2943
|
` })
|
|
2717
2944
|
]
|
|
@@ -2722,7 +2949,7 @@ var MeshGradient = forwardRef32(
|
|
|
2722
2949
|
MeshGradient.displayName = "MeshGradient";
|
|
2723
2950
|
|
|
2724
2951
|
// src/primitives/33-particles.tsx
|
|
2725
|
-
import { forwardRef as forwardRef33, useEffect as useEffect21, useRef as
|
|
2952
|
+
import { forwardRef as forwardRef33, useEffect as useEffect21, useRef as useRef20 } from "react";
|
|
2726
2953
|
import { jsx as jsx35 } from "react/jsx-runtime";
|
|
2727
2954
|
var Particles = forwardRef33(
|
|
2728
2955
|
({
|
|
@@ -2736,13 +2963,13 @@ var Particles = forwardRef33(
|
|
|
2736
2963
|
...props
|
|
2737
2964
|
}, ref) => {
|
|
2738
2965
|
const isReducedMotion = useReducedMotion();
|
|
2739
|
-
const internalRef =
|
|
2966
|
+
const internalRef = useRef20(null);
|
|
2740
2967
|
const mergedRef = useMergedRef(ref, internalRef);
|
|
2741
|
-
const context =
|
|
2742
|
-
const circles =
|
|
2743
|
-
const mouse =
|
|
2744
|
-
const canvasSize =
|
|
2745
|
-
const animationFrameId =
|
|
2968
|
+
const context = useRef20(null);
|
|
2969
|
+
const circles = useRef20([]);
|
|
2970
|
+
const mouse = useRef20({ x: 0, y: 0 });
|
|
2971
|
+
const canvasSize = useRef20({ w: 0, h: 0 });
|
|
2972
|
+
const animationFrameId = useRef20(0);
|
|
2746
2973
|
useEffect21(() => {
|
|
2747
2974
|
if (disabled || isReducedMotion || !internalRef.current) return;
|
|
2748
2975
|
const canvas = internalRef.current;
|
|
@@ -2802,18 +3029,29 @@ var Particles = forwardRef33(
|
|
|
2802
3029
|
};
|
|
2803
3030
|
resizeCanvas();
|
|
2804
3031
|
animate();
|
|
2805
|
-
|
|
2806
|
-
|
|
3032
|
+
let mouseRafId = 0;
|
|
3033
|
+
let latestMouseEvent = null;
|
|
3034
|
+
const processMouseMove = () => {
|
|
3035
|
+
mouseRafId = 0;
|
|
3036
|
+
const e = latestMouseEvent;
|
|
3037
|
+
if (!e || !internalRef.current) return;
|
|
2807
3038
|
const rect = internalRef.current.getBoundingClientRect();
|
|
2808
3039
|
mouse.current.x = e.clientX - rect.left - canvasSize.current.w / 2;
|
|
2809
3040
|
mouse.current.y = e.clientY - rect.top - canvasSize.current.h / 2;
|
|
2810
3041
|
};
|
|
3042
|
+
const handleMouseMove = (e) => {
|
|
3043
|
+
latestMouseEvent = e;
|
|
3044
|
+
if (!mouseRafId) {
|
|
3045
|
+
mouseRafId = requestAnimationFrame(processMouseMove);
|
|
3046
|
+
}
|
|
3047
|
+
};
|
|
2811
3048
|
window.addEventListener("resize", resizeCanvas);
|
|
2812
|
-
window.addEventListener("mousemove", handleMouseMove);
|
|
3049
|
+
window.addEventListener("mousemove", handleMouseMove, { passive: true });
|
|
2813
3050
|
return () => {
|
|
2814
3051
|
window.removeEventListener("resize", resizeCanvas);
|
|
2815
3052
|
window.removeEventListener("mousemove", handleMouseMove);
|
|
2816
3053
|
if (animationFrameId.current) window.cancelAnimationFrame(animationFrameId.current);
|
|
3054
|
+
if (mouseRafId) cancelAnimationFrame(mouseRafId);
|
|
2817
3055
|
};
|
|
2818
3056
|
}, [color, quantity, staticity, ease, disabled, isReducedMotion]);
|
|
2819
3057
|
if (disabled) return null;
|
|
@@ -2910,8 +3148,7 @@ var Noise = forwardRef35(
|
|
|
2910
3148
|
Noise.displayName = "Noise";
|
|
2911
3149
|
|
|
2912
3150
|
// src/primitives/36-streaming-text.tsx
|
|
2913
|
-
import
|
|
2914
|
-
import { motion as motion27 } from "motion/react";
|
|
3151
|
+
import { forwardRef as forwardRef36, useEffect as useEffect22, useRef as useRef21 } from "react";
|
|
2915
3152
|
import { jsx as jsx38, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2916
3153
|
var StreamingText = forwardRef36(
|
|
2917
3154
|
({
|
|
@@ -2927,43 +3164,71 @@ var StreamingText = forwardRef36(
|
|
|
2927
3164
|
...props
|
|
2928
3165
|
}, ref) => {
|
|
2929
3166
|
const isReducedMotion = useReducedMotion();
|
|
2930
|
-
const internalRef =
|
|
3167
|
+
const internalRef = useRef21(null);
|
|
2931
3168
|
const mergedRef = useMergedRef(ref, internalRef);
|
|
2932
|
-
const
|
|
2933
|
-
const
|
|
3169
|
+
const textNodeRef = useRef21(null);
|
|
3170
|
+
const cursorRef = useRef21(null);
|
|
3171
|
+
const onCompleteRef = useRef21(onComplete);
|
|
3172
|
+
onCompleteRef.current = onComplete;
|
|
2934
3173
|
useEffect22(() => {
|
|
3174
|
+
const el = internalRef.current;
|
|
3175
|
+
if (!el) return;
|
|
2935
3176
|
if (disabled || isReducedMotion) {
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
3177
|
+
if (!textNodeRef.current) {
|
|
3178
|
+
textNodeRef.current = document.createTextNode(text);
|
|
3179
|
+
el.insertBefore(textNodeRef.current, el.firstChild);
|
|
3180
|
+
} else {
|
|
3181
|
+
textNodeRef.current.textContent = text;
|
|
3182
|
+
}
|
|
3183
|
+
if (cursorRef.current) {
|
|
3184
|
+
cursorRef.current.style.display = "none";
|
|
3185
|
+
}
|
|
3186
|
+
onCompleteRef.current?.();
|
|
2939
3187
|
return;
|
|
2940
3188
|
}
|
|
2941
|
-
|
|
2942
|
-
|
|
3189
|
+
if (!textNodeRef.current) {
|
|
3190
|
+
textNodeRef.current = document.createTextNode("");
|
|
3191
|
+
el.insertBefore(textNodeRef.current, el.firstChild);
|
|
3192
|
+
} else {
|
|
3193
|
+
textNodeRef.current.textContent = "";
|
|
3194
|
+
}
|
|
3195
|
+
if (cursorRef.current) {
|
|
3196
|
+
cursorRef.current.style.display = "inline-block";
|
|
3197
|
+
}
|
|
2943
3198
|
let i = 0;
|
|
2944
3199
|
const intervalId = setInterval(() => {
|
|
2945
|
-
|
|
3200
|
+
if (textNodeRef.current) {
|
|
3201
|
+
textNodeRef.current.textContent = text.slice(0, i + 1);
|
|
3202
|
+
}
|
|
2946
3203
|
i++;
|
|
2947
3204
|
if (i >= text.length) {
|
|
2948
3205
|
clearInterval(intervalId);
|
|
2949
|
-
|
|
2950
|
-
|
|
3206
|
+
if (cursorRef.current) {
|
|
3207
|
+
cursorRef.current.style.display = "none";
|
|
3208
|
+
}
|
|
3209
|
+
onCompleteRef.current?.();
|
|
2951
3210
|
}
|
|
2952
3211
|
}, speed);
|
|
2953
3212
|
return () => clearInterval(intervalId);
|
|
2954
|
-
}, [text, speed, disabled, isReducedMotion
|
|
3213
|
+
}, [text, speed, disabled, isReducedMotion]);
|
|
2955
3214
|
return /* @__PURE__ */ jsxs14("span", { ref: mergedRef, className, style: { whiteSpace: "pre-wrap", ...style }, ...props, children: [
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
motion27.span,
|
|
3215
|
+
cursor && /* @__PURE__ */ jsx38(
|
|
3216
|
+
"span",
|
|
2959
3217
|
{
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
3218
|
+
ref: cursorRef,
|
|
3219
|
+
style: {
|
|
3220
|
+
display: "inline-block",
|
|
3221
|
+
marginLeft: "2px",
|
|
3222
|
+
fontWeight: "bold",
|
|
3223
|
+
animation: "flux-cursor-blink 0.8s step-end infinite"
|
|
3224
|
+
},
|
|
2964
3225
|
children: cursorChar
|
|
2965
3226
|
}
|
|
2966
|
-
)
|
|
3227
|
+
),
|
|
3228
|
+
/* @__PURE__ */ jsx38("style", { children: `@keyframes flux-cursor-blink {
|
|
3229
|
+
0%, 100% { opacity: 1; }
|
|
3230
|
+
50% { opacity: 0; }
|
|
3231
|
+
}` })
|
|
2967
3232
|
] });
|
|
2968
3233
|
}
|
|
2969
3234
|
);
|
|
@@ -2971,7 +3236,7 @@ StreamingText.displayName = "StreamingText";
|
|
|
2971
3236
|
|
|
2972
3237
|
// src/primitives/37-typing-indicator.tsx
|
|
2973
3238
|
import React38, { forwardRef as forwardRef37 } from "react";
|
|
2974
|
-
import { motion as
|
|
3239
|
+
import { motion as motion27 } from "motion/react";
|
|
2975
3240
|
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
2976
3241
|
var TypingIndicator = forwardRef37(
|
|
2977
3242
|
({
|
|
@@ -3001,7 +3266,7 @@ var TypingIndicator = forwardRef37(
|
|
|
3001
3266
|
style: { display: "inline-flex", alignItems: "center", gap: size / 2, ...style },
|
|
3002
3267
|
...props,
|
|
3003
3268
|
children: [0, 1, 2].map((i) => /* @__PURE__ */ jsx39(
|
|
3004
|
-
|
|
3269
|
+
motion27.div,
|
|
3005
3270
|
{
|
|
3006
3271
|
style: dotStyle,
|
|
3007
3272
|
animate: isReducedMotion ? void 0 : {
|
|
@@ -3025,7 +3290,7 @@ TypingIndicator.displayName = "TypingIndicator";
|
|
|
3025
3290
|
|
|
3026
3291
|
// src/primitives/38-skeleton.tsx
|
|
3027
3292
|
import React39, { forwardRef as forwardRef38 } from "react";
|
|
3028
|
-
import { motion as
|
|
3293
|
+
import { motion as motion28 } from "motion/react";
|
|
3029
3294
|
import { jsx as jsx40 } from "react/jsx-runtime";
|
|
3030
3295
|
var Skeleton = forwardRef38(
|
|
3031
3296
|
({
|
|
@@ -3070,7 +3335,7 @@ var Skeleton = forwardRef38(
|
|
|
3070
3335
|
},
|
|
3071
3336
|
...props,
|
|
3072
3337
|
children: !isReducedMotion && /* @__PURE__ */ jsx40(
|
|
3073
|
-
|
|
3338
|
+
motion28.div,
|
|
3074
3339
|
{
|
|
3075
3340
|
style: {
|
|
3076
3341
|
position: "absolute",
|
|
@@ -3097,7 +3362,7 @@ Skeleton.displayName = "Skeleton";
|
|
|
3097
3362
|
|
|
3098
3363
|
// src/primitives/39-ai-message.tsx
|
|
3099
3364
|
import React40, { forwardRef as forwardRef39 } from "react";
|
|
3100
|
-
import { motion as
|
|
3365
|
+
import { motion as motion29 } from "motion/react";
|
|
3101
3366
|
import { jsx as jsx41, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3102
3367
|
var AIMessage = forwardRef39(
|
|
3103
3368
|
({
|
|
@@ -3124,7 +3389,7 @@ var AIMessage = forwardRef39(
|
|
|
3124
3389
|
const alignment = role === "user" ? "flex-end" : "flex-start";
|
|
3125
3390
|
const origin = role === "user" ? "bottom right" : "bottom left";
|
|
3126
3391
|
return /* @__PURE__ */ jsxs15(
|
|
3127
|
-
|
|
3392
|
+
motion29.div,
|
|
3128
3393
|
{
|
|
3129
3394
|
ref: mergedRef,
|
|
3130
3395
|
className,
|
|
@@ -3141,7 +3406,7 @@ var AIMessage = forwardRef39(
|
|
|
3141
3406
|
...props,
|
|
3142
3407
|
children: [
|
|
3143
3408
|
role !== "user" && avatar && /* @__PURE__ */ jsx41(
|
|
3144
|
-
|
|
3409
|
+
motion29.div,
|
|
3145
3410
|
{
|
|
3146
3411
|
initial: isReducedMotion ? { opacity: 0 } : { opacity: 0, scale: 0 },
|
|
3147
3412
|
animate: { opacity: 1, scale: 1 },
|
|
@@ -3151,7 +3416,7 @@ var AIMessage = forwardRef39(
|
|
|
3151
3416
|
),
|
|
3152
3417
|
/* @__PURE__ */ jsx41("div", { style: { flex: 1, maxWidth: "80%" }, children }),
|
|
3153
3418
|
role === "user" && avatar && /* @__PURE__ */ jsx41(
|
|
3154
|
-
|
|
3419
|
+
motion29.div,
|
|
3155
3420
|
{
|
|
3156
3421
|
initial: isReducedMotion ? { opacity: 0 } : { opacity: 0, scale: 0 },
|
|
3157
3422
|
animate: { opacity: 1, scale: 1 },
|
|
@@ -3167,8 +3432,8 @@ var AIMessage = forwardRef39(
|
|
|
3167
3432
|
AIMessage.displayName = "AIMessage";
|
|
3168
3433
|
|
|
3169
3434
|
// src/primitives/40-hero-highlight.tsx
|
|
3170
|
-
import React41, { forwardRef as forwardRef40 } from "react";
|
|
3171
|
-
import { motion as
|
|
3435
|
+
import React41, { forwardRef as forwardRef40, useCallback as useCallback7, useEffect as useEffect23, useRef as useRef22 } from "react";
|
|
3436
|
+
import { motion as motion30, useMotionTemplate as useMotionTemplate3, useMotionValue as useMotionValue8 } from "motion/react";
|
|
3172
3437
|
import { jsx as jsx42, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
3173
3438
|
var HeroHighlight = forwardRef40(
|
|
3174
3439
|
({
|
|
@@ -3176,7 +3441,6 @@ var HeroHighlight = forwardRef40(
|
|
|
3176
3441
|
containerClassName,
|
|
3177
3442
|
className,
|
|
3178
3443
|
color = "45, 212, 191",
|
|
3179
|
-
// teal-400 equivalent typically
|
|
3180
3444
|
disabled = false,
|
|
3181
3445
|
...props
|
|
3182
3446
|
}, ref) => {
|
|
@@ -3185,12 +3449,50 @@ var HeroHighlight = forwardRef40(
|
|
|
3185
3449
|
const mergedRef = useMergedRef(ref, internalRef);
|
|
3186
3450
|
const mouseX = useMotionValue8(0);
|
|
3187
3451
|
const mouseY = useMotionValue8(0);
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
}
|
|
3452
|
+
const rectRef = useRef22(null);
|
|
3453
|
+
const updateRect = useCallback7(() => {
|
|
3454
|
+
if (internalRef.current) {
|
|
3455
|
+
rectRef.current = internalRef.current.getBoundingClientRect();
|
|
3456
|
+
}
|
|
3457
|
+
}, []);
|
|
3458
|
+
useEffect23(() => {
|
|
3459
|
+
updateRect();
|
|
3460
|
+
window.addEventListener("scroll", updateRect, { passive: true });
|
|
3461
|
+
window.addEventListener("resize", updateRect, { passive: true });
|
|
3462
|
+
return () => {
|
|
3463
|
+
window.removeEventListener("scroll", updateRect);
|
|
3464
|
+
window.removeEventListener("resize", updateRect);
|
|
3465
|
+
};
|
|
3466
|
+
}, [updateRect]);
|
|
3467
|
+
const rafId = useRef22(0);
|
|
3468
|
+
const latestEvent = useRef22(null);
|
|
3469
|
+
const processMouseMove = useCallback7(() => {
|
|
3470
|
+
rafId.current = 0;
|
|
3471
|
+
const e = latestEvent.current;
|
|
3472
|
+
if (!e) return;
|
|
3473
|
+
const rect = rectRef.current;
|
|
3474
|
+
if (!rect) return;
|
|
3475
|
+
mouseX.set(e.clientX - rect.left);
|
|
3476
|
+
mouseY.set(e.clientY - rect.top);
|
|
3477
|
+
}, [mouseX, mouseY]);
|
|
3478
|
+
const handleMouseMove = useCallback7((e) => {
|
|
3479
|
+
latestEvent.current = e;
|
|
3480
|
+
if (!rafId.current) {
|
|
3481
|
+
rafId.current = requestAnimationFrame(processMouseMove);
|
|
3482
|
+
}
|
|
3483
|
+
}, [processMouseMove]);
|
|
3484
|
+
useEffect23(() => {
|
|
3485
|
+
return () => {
|
|
3486
|
+
if (rafId.current) cancelAnimationFrame(rafId.current);
|
|
3487
|
+
};
|
|
3488
|
+
}, []);
|
|
3489
|
+
const maskTemplate = useMotionTemplate3`
|
|
3490
|
+
radial-gradient(
|
|
3491
|
+
200px circle at ${mouseX}px ${mouseY}px,
|
|
3492
|
+
black 0%,
|
|
3493
|
+
transparent 100%
|
|
3494
|
+
)
|
|
3495
|
+
`;
|
|
3194
3496
|
if (disabled || isReducedMotion) {
|
|
3195
3497
|
return /* @__PURE__ */ jsxs16("div", { ref: mergedRef, className: `relative flex items-center justify-center w-full group ${containerClassName || ""}`, ...props, children: [
|
|
3196
3498
|
/* @__PURE__ */ jsx42("div", { className: "absolute inset-0 bg-dot-thick-neutral-300 pointer-events-none" }),
|
|
@@ -3207,24 +3509,12 @@ var HeroHighlight = forwardRef40(
|
|
|
3207
3509
|
children: [
|
|
3208
3510
|
/* @__PURE__ */ jsx42("div", { className: "absolute inset-0 bg-dot-thick-neutral-300 dark:bg-dot-thick-neutral-800 pointer-events-none" }),
|
|
3209
3511
|
/* @__PURE__ */ jsx42(
|
|
3210
|
-
|
|
3512
|
+
motion30.div,
|
|
3211
3513
|
{
|
|
3212
3514
|
className: "absolute inset-0 opacity-0 transition duration-300 group-hover:opacity-100 pointer-events-none bg-dot-thick-teal-500",
|
|
3213
3515
|
style: {
|
|
3214
|
-
WebkitMaskImage:
|
|
3215
|
-
|
|
3216
|
-
200px circle at ${mouseX}px ${mouseY}px,
|
|
3217
|
-
black 0%,
|
|
3218
|
-
transparent 100%
|
|
3219
|
-
)
|
|
3220
|
-
`,
|
|
3221
|
-
maskImage: useMotionTemplate3`
|
|
3222
|
-
radial-gradient(
|
|
3223
|
-
200px circle at ${mouseX}px ${mouseY}px,
|
|
3224
|
-
black 0%,
|
|
3225
|
-
transparent 100%
|
|
3226
|
-
)
|
|
3227
|
-
`
|
|
3516
|
+
WebkitMaskImage: maskTemplate,
|
|
3517
|
+
maskImage: maskTemplate
|
|
3228
3518
|
}
|
|
3229
3519
|
}
|
|
3230
3520
|
),
|
|
@@ -3241,7 +3531,7 @@ var Highlight = ({
|
|
|
3241
3531
|
}) => {
|
|
3242
3532
|
const isReducedMotion = useReducedMotion();
|
|
3243
3533
|
return /* @__PURE__ */ jsx42(
|
|
3244
|
-
|
|
3534
|
+
motion30.span,
|
|
3245
3535
|
{
|
|
3246
3536
|
initial: {
|
|
3247
3537
|
backgroundSize: "0% 100%"
|