@nikitph/flux-ui 0.3.2 → 0.3.3
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 +382 -148
- 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
|
}
|
|
@@ -295,9 +295,10 @@ var Presence = ({
|
|
|
295
295
|
};
|
|
296
296
|
|
|
297
297
|
// src/primitives/03-stagger.tsx
|
|
298
|
-
import React4, { forwardRef as forwardRef3, useEffect as useEffect6, useState as useState4 } from "react";
|
|
298
|
+
import React4, { forwardRef as forwardRef3, useEffect as useEffect6, useMemo, useState as useState4 } from "react";
|
|
299
299
|
import { motion as motion3, useInView as useInView3 } from "motion/react";
|
|
300
300
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
301
|
+
var MotionSlot = motion3.create(Slot);
|
|
301
302
|
var Stagger = forwardRef3(
|
|
302
303
|
({
|
|
303
304
|
children,
|
|
@@ -336,8 +337,7 @@ var Stagger = forwardRef3(
|
|
|
336
337
|
}, [shouldAnimate, hasRevealed]);
|
|
337
338
|
const childrenArray = React4.Children.toArray(children);
|
|
338
339
|
const count = childrenArray.length;
|
|
339
|
-
|
|
340
|
-
const getInitial = () => {
|
|
340
|
+
const getInitial = useMemo(() => {
|
|
341
341
|
if (isReducedMotion) return { opacity: 0, x: 0, y: 0, scale: 1 };
|
|
342
342
|
const rFrom = reveal.from || "below";
|
|
343
343
|
const rDist = reveal.distance || motionScale.distance.md;
|
|
@@ -349,9 +349,10 @@ var Stagger = forwardRef3(
|
|
|
349
349
|
x: rFrom === "left" ? -rDist : rFrom === "right" ? rDist : 0,
|
|
350
350
|
scale: rScale !== false ? rScale : 1
|
|
351
351
|
};
|
|
352
|
-
};
|
|
352
|
+
}, [isReducedMotion, reveal.from, reveal.distance, reveal.fade, reveal.scale]);
|
|
353
353
|
const target = { opacity: 1, x: 0, y: 0, scale: 1 };
|
|
354
|
-
const initial = getInitial
|
|
354
|
+
const initial = getInitial;
|
|
355
|
+
let randomSeed = 0.5;
|
|
355
356
|
const renderChildren = childrenArray.map((child, i) => {
|
|
356
357
|
if (!React4.isValidElement(child)) return child;
|
|
357
358
|
let delay = 0;
|
|
@@ -364,13 +365,13 @@ var Stagger = forwardRef3(
|
|
|
364
365
|
delay = randomSeed / 233280 * count * interval;
|
|
365
366
|
}
|
|
366
367
|
}
|
|
367
|
-
const MotionChild = motion3.create(Slot);
|
|
368
368
|
return /* @__PURE__ */ jsx5(
|
|
369
|
-
|
|
369
|
+
MotionSlot,
|
|
370
370
|
{
|
|
371
371
|
initial,
|
|
372
372
|
animate: shouldAnimate ? target : initial,
|
|
373
373
|
transition: { ...springConfig, delay },
|
|
374
|
+
style: { willChange: "transform, opacity" },
|
|
374
375
|
children: child
|
|
375
376
|
},
|
|
376
377
|
child.key || i
|
|
@@ -797,10 +798,30 @@ var Magnetic = forwardRef9(
|
|
|
797
798
|
const y = useMotionValue2(0);
|
|
798
799
|
const springX = useSpring2(x, isReducedMotion ? { duration: 0 } : springConfig);
|
|
799
800
|
const springY = useSpring2(y, isReducedMotion ? { duration: 0 } : springConfig);
|
|
800
|
-
const
|
|
801
|
+
const rectRef = useRef3(null);
|
|
802
|
+
const updateRect = useCallback(() => {
|
|
803
|
+
if (internalRef.current) {
|
|
804
|
+
rectRef.current = internalRef.current.getBoundingClientRect();
|
|
805
|
+
}
|
|
806
|
+
}, []);
|
|
807
|
+
useEffect11(() => {
|
|
808
|
+
updateRect();
|
|
809
|
+
window.addEventListener("scroll", updateRect, { passive: true });
|
|
810
|
+
window.addEventListener("resize", updateRect, { passive: true });
|
|
811
|
+
return () => {
|
|
812
|
+
window.removeEventListener("scroll", updateRect);
|
|
813
|
+
window.removeEventListener("resize", updateRect);
|
|
814
|
+
};
|
|
815
|
+
}, [updateRect]);
|
|
816
|
+
const rafId = useRef3(0);
|
|
817
|
+
const latestEvent = useRef3(null);
|
|
818
|
+
const processMouseMove = useCallback(() => {
|
|
819
|
+
const e = latestEvent.current;
|
|
820
|
+
rafId.current = 0;
|
|
821
|
+
if (!e) return;
|
|
801
822
|
if (isReducedMotion || disableOnTouch && isTouchDevice) return;
|
|
802
|
-
|
|
803
|
-
|
|
823
|
+
const rect = rectRef.current;
|
|
824
|
+
if (!rect) return;
|
|
804
825
|
const centerX = rect.left + rect.width / 2;
|
|
805
826
|
const centerY = rect.top + rect.height / 2;
|
|
806
827
|
const deltaX = e.clientX - centerX;
|
|
@@ -816,14 +837,21 @@ var Magnetic = forwardRef9(
|
|
|
816
837
|
y.set(0);
|
|
817
838
|
}
|
|
818
839
|
}, [x, y, radius, maxDisplacement, strength, isTouchDevice, disableOnTouch, isReducedMotion]);
|
|
819
|
-
const
|
|
840
|
+
const handleMouseMove = useCallback((e) => {
|
|
841
|
+
latestEvent.current = e;
|
|
842
|
+
if (!rafId.current) {
|
|
843
|
+
rafId.current = requestAnimationFrame(processMouseMove);
|
|
844
|
+
}
|
|
845
|
+
}, [processMouseMove]);
|
|
846
|
+
const handleMouseLeave = useCallback(() => {
|
|
820
847
|
x.set(0);
|
|
821
848
|
y.set(0);
|
|
822
|
-
};
|
|
849
|
+
}, [x, y]);
|
|
823
850
|
useEffect11(() => {
|
|
824
|
-
window.addEventListener("mousemove", handleMouseMove);
|
|
851
|
+
window.addEventListener("mousemove", handleMouseMove, { passive: true });
|
|
825
852
|
return () => {
|
|
826
853
|
window.removeEventListener("mousemove", handleMouseMove);
|
|
854
|
+
if (rafId.current) cancelAnimationFrame(rafId.current);
|
|
827
855
|
};
|
|
828
856
|
}, [handleMouseMove]);
|
|
829
857
|
const MotionComponent = asChild ? motion9.create(Slot) : motion9.div;
|
|
@@ -832,7 +860,7 @@ var Magnetic = forwardRef9(
|
|
|
832
860
|
{
|
|
833
861
|
ref: mergedRef,
|
|
834
862
|
className,
|
|
835
|
-
style: { ...style, x: springX, y: springY },
|
|
863
|
+
style: { ...style, x: springX, y: springY, willChange: "transform" },
|
|
836
864
|
onMouseLeave: handleMouseLeave,
|
|
837
865
|
...props,
|
|
838
866
|
children
|
|
@@ -932,10 +960,29 @@ var Tilt = forwardRef11(
|
|
|
932
960
|
const scaleVal = useSpring3(s, isReducedMotion ? { duration: 0 } : springConfig);
|
|
933
961
|
const gX = useSpring3(glareX, isReducedMotion ? { duration: 0 } : springConfig);
|
|
934
962
|
const gY = useSpring3(glareY, isReducedMotion ? { duration: 0 } : springConfig);
|
|
935
|
-
const
|
|
936
|
-
|
|
937
|
-
if (
|
|
938
|
-
|
|
963
|
+
const rectRef = useRef4(null);
|
|
964
|
+
const updateRect = useCallback2(() => {
|
|
965
|
+
if (internalRef.current) {
|
|
966
|
+
rectRef.current = internalRef.current.getBoundingClientRect();
|
|
967
|
+
}
|
|
968
|
+
}, []);
|
|
969
|
+
useEffect12(() => {
|
|
970
|
+
updateRect();
|
|
971
|
+
window.addEventListener("scroll", updateRect, { passive: true });
|
|
972
|
+
window.addEventListener("resize", updateRect, { passive: true });
|
|
973
|
+
return () => {
|
|
974
|
+
window.removeEventListener("scroll", updateRect);
|
|
975
|
+
window.removeEventListener("resize", updateRect);
|
|
976
|
+
};
|
|
977
|
+
}, [updateRect]);
|
|
978
|
+
const rafId = useRef4(0);
|
|
979
|
+
const latestEvent = useRef4(null);
|
|
980
|
+
const processMouseMove = useCallback2(() => {
|
|
981
|
+
rafId.current = 0;
|
|
982
|
+
const e = latestEvent.current;
|
|
983
|
+
if (!e) return;
|
|
984
|
+
const rect = rectRef.current;
|
|
985
|
+
if (!rect) return;
|
|
939
986
|
const centerX = rect.left + rect.width / 2;
|
|
940
987
|
const centerY = rect.top + rect.height / 2;
|
|
941
988
|
const mouseX = (e.clientX - centerX) / rect.width;
|
|
@@ -952,7 +999,14 @@ var Tilt = forwardRef11(
|
|
|
952
999
|
glareX.set((e.clientX - rect.left) / rect.width * 100);
|
|
953
1000
|
glareY.set((e.clientY - rect.top) / rect.height * 100);
|
|
954
1001
|
}
|
|
955
|
-
}, [x, y, s, glareX, glareY, maxTilt, reverse, axis, scale, glare
|
|
1002
|
+
}, [x, y, s, glareX, glareY, maxTilt, reverse, axis, scale, glare]);
|
|
1003
|
+
const handleMouseMove = useCallback2((e) => {
|
|
1004
|
+
if (disabled || isReducedMotion || disableOnTouch && isTouchDevice) return;
|
|
1005
|
+
latestEvent.current = e;
|
|
1006
|
+
if (!rafId.current) {
|
|
1007
|
+
rafId.current = requestAnimationFrame(processMouseMove);
|
|
1008
|
+
}
|
|
1009
|
+
}, [disabled, isReducedMotion, disableOnTouch, isTouchDevice, processMouseMove]);
|
|
956
1010
|
const handleMouseLeave = useCallback2(() => {
|
|
957
1011
|
if (disabled || isReducedMotion) return;
|
|
958
1012
|
if (resetOnLeave) {
|
|
@@ -961,6 +1015,11 @@ var Tilt = forwardRef11(
|
|
|
961
1015
|
}
|
|
962
1016
|
s.set(1);
|
|
963
1017
|
}, [x, y, s, resetOnLeave, disabled, isReducedMotion]);
|
|
1018
|
+
useEffect12(() => {
|
|
1019
|
+
return () => {
|
|
1020
|
+
if (rafId.current) cancelAnimationFrame(rafId.current);
|
|
1021
|
+
};
|
|
1022
|
+
}, []);
|
|
964
1023
|
const glareBackground = useMotionTemplate`radial-gradient(circle at ${gX}% ${gY}%, ${glareColor} 0%, transparent 80%)`;
|
|
965
1024
|
if (disabled || isReducedMotion) {
|
|
966
1025
|
return /* @__PURE__ */ jsx13("div", { ref: mergedRef, className, style, ...props, children });
|
|
@@ -977,7 +1036,15 @@ var Tilt = forwardRef11(
|
|
|
977
1036
|
children: /* @__PURE__ */ jsxs3(
|
|
978
1037
|
motion11.div,
|
|
979
1038
|
{
|
|
980
|
-
style: {
|
|
1039
|
+
style: {
|
|
1040
|
+
rotateX,
|
|
1041
|
+
rotateY,
|
|
1042
|
+
scale: scaleVal,
|
|
1043
|
+
transformStyle: "preserve-3d",
|
|
1044
|
+
width: "100%",
|
|
1045
|
+
height: "100%",
|
|
1046
|
+
willChange: "transform"
|
|
1047
|
+
},
|
|
981
1048
|
children: [
|
|
982
1049
|
children,
|
|
983
1050
|
glare && /* @__PURE__ */ jsx13(
|
|
@@ -1264,8 +1331,8 @@ var LongPress = forwardRef14(
|
|
|
1264
1331
|
LongPress.displayName = "LongPress";
|
|
1265
1332
|
|
|
1266
1333
|
// 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";
|
|
1334
|
+
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";
|
|
1335
|
+
import { motion as motion15, useMotionValue as useMotionValue4, useSpring as useSpring4, useTransform as useTransform2 } from "motion/react";
|
|
1269
1336
|
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1270
1337
|
var Hover3DContext = createContext2({
|
|
1271
1338
|
mouseX: null,
|
|
@@ -1296,21 +1363,52 @@ var Hover3DRoot = forwardRef15(
|
|
|
1296
1363
|
const y = useMotionValue4(0);
|
|
1297
1364
|
const mouseX = useSpring4(x, isReducedMotion ? { duration: 0 } : springConfig);
|
|
1298
1365
|
const mouseY = useSpring4(y, isReducedMotion ? { duration: 0 } : springConfig);
|
|
1299
|
-
const
|
|
1300
|
-
|
|
1301
|
-
if (
|
|
1302
|
-
|
|
1366
|
+
const rectRef = useRef6(null);
|
|
1367
|
+
const updateRect = useCallback3(() => {
|
|
1368
|
+
if (internalRef.current) {
|
|
1369
|
+
rectRef.current = internalRef.current.getBoundingClientRect();
|
|
1370
|
+
}
|
|
1371
|
+
}, []);
|
|
1372
|
+
useEffect13(() => {
|
|
1373
|
+
updateRect();
|
|
1374
|
+
window.addEventListener("scroll", updateRect, { passive: true });
|
|
1375
|
+
window.addEventListener("resize", updateRect, { passive: true });
|
|
1376
|
+
return () => {
|
|
1377
|
+
window.removeEventListener("scroll", updateRect);
|
|
1378
|
+
window.removeEventListener("resize", updateRect);
|
|
1379
|
+
};
|
|
1380
|
+
}, [updateRect]);
|
|
1381
|
+
const rafId = useRef6(0);
|
|
1382
|
+
const latestEvent = useRef6(null);
|
|
1383
|
+
const processMouseMove = useCallback3(() => {
|
|
1384
|
+
rafId.current = 0;
|
|
1385
|
+
const e = latestEvent.current;
|
|
1386
|
+
if (!e) return;
|
|
1387
|
+
const rect = rectRef.current;
|
|
1388
|
+
if (!rect) return;
|
|
1303
1389
|
const centerX = rect.left + rect.width / 2;
|
|
1304
1390
|
const centerY = rect.top + rect.height / 2;
|
|
1305
1391
|
const offsetX = (e.clientX - centerX) / rect.width;
|
|
1306
1392
|
const offsetY = (e.clientY - centerY) / rect.height;
|
|
1307
1393
|
x.set(offsetX * 2);
|
|
1308
1394
|
y.set(offsetY * 2);
|
|
1309
|
-
}, [x, y
|
|
1395
|
+
}, [x, y]);
|
|
1396
|
+
const handleMouseMove = useCallback3((e) => {
|
|
1397
|
+
if (disabled || isReducedMotion || disableOnTouch && isTouchDevice) return;
|
|
1398
|
+
latestEvent.current = e;
|
|
1399
|
+
if (!rafId.current) {
|
|
1400
|
+
rafId.current = requestAnimationFrame(processMouseMove);
|
|
1401
|
+
}
|
|
1402
|
+
}, [disabled, isReducedMotion, disableOnTouch, isTouchDevice, processMouseMove]);
|
|
1310
1403
|
const handleMouseLeave = useCallback3(() => {
|
|
1311
1404
|
x.set(0);
|
|
1312
1405
|
y.set(0);
|
|
1313
1406
|
}, [x, y]);
|
|
1407
|
+
useEffect13(() => {
|
|
1408
|
+
return () => {
|
|
1409
|
+
if (rafId.current) cancelAnimationFrame(rafId.current);
|
|
1410
|
+
};
|
|
1411
|
+
}, []);
|
|
1314
1412
|
if (disabled) {
|
|
1315
1413
|
return /* @__PURE__ */ jsx17("div", { ref: mergedRef, className, style: { position: "relative", ...style }, ...props, children });
|
|
1316
1414
|
}
|
|
@@ -1324,7 +1422,13 @@ var Hover3DRoot = forwardRef15(
|
|
|
1324
1422
|
}
|
|
1325
1423
|
return child;
|
|
1326
1424
|
});
|
|
1327
|
-
|
|
1425
|
+
const contextValue = useMemo2(() => ({
|
|
1426
|
+
mouseX,
|
|
1427
|
+
mouseY,
|
|
1428
|
+
maxMovement,
|
|
1429
|
+
isReducedMotion
|
|
1430
|
+
}), [mouseX, mouseY, maxMovement, isReducedMotion]);
|
|
1431
|
+
return /* @__PURE__ */ jsx17(Hover3DContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx17(
|
|
1328
1432
|
"div",
|
|
1329
1433
|
{
|
|
1330
1434
|
ref: mergedRef,
|
|
@@ -1342,6 +1446,8 @@ Hover3DRoot.displayName = "Hover3D";
|
|
|
1342
1446
|
var Hover3DLayer = forwardRef15(
|
|
1343
1447
|
({ children, depth = 0, className, style, ...props }, ref) => {
|
|
1344
1448
|
const { mouseX, mouseY, maxMovement, isReducedMotion } = useContext2(Hover3DContext);
|
|
1449
|
+
const layerX = useTransform2(mouseX ?? useMotionValue4(0), (val) => val * maxMovement * depth);
|
|
1450
|
+
const layerY = useTransform2(mouseY ?? useMotionValue4(0), (val) => val * maxMovement * depth);
|
|
1345
1451
|
if (isReducedMotion || mouseX === null) {
|
|
1346
1452
|
return /* @__PURE__ */ jsx17("div", { ref, className, style: { position: "absolute", inset: 0, ...style }, ...props, children });
|
|
1347
1453
|
}
|
|
@@ -1353,21 +1459,12 @@ var Hover3DLayer = forwardRef15(
|
|
|
1353
1459
|
style: {
|
|
1354
1460
|
position: "absolute",
|
|
1355
1461
|
inset: 0,
|
|
1356
|
-
x:
|
|
1357
|
-
|
|
1358
|
-
y: useMotionValue4(0),
|
|
1462
|
+
x: layerX,
|
|
1463
|
+
y: layerY,
|
|
1359
1464
|
transformStyle: "preserve-3d",
|
|
1465
|
+
willChange: "transform",
|
|
1360
1466
|
...style
|
|
1361
1467
|
},
|
|
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
1468
|
...props,
|
|
1372
1469
|
children
|
|
1373
1470
|
}
|
|
@@ -1379,7 +1476,7 @@ var Hover3D = Object.assign(Hover3DRoot, { Layer: Hover3DLayer });
|
|
|
1379
1476
|
|
|
1380
1477
|
// src/primitives/16-scroll-velocity.tsx
|
|
1381
1478
|
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
|
|
1479
|
+
import { motion as motion16, useScroll as useScroll2, useVelocity, useSpring as useSpring5, useTransform as useTransform3 } from "motion/react";
|
|
1383
1480
|
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1384
1481
|
var ScrollVelocity = forwardRef16(
|
|
1385
1482
|
({
|
|
@@ -1409,21 +1506,21 @@ var ScrollVelocity = forwardRef16(
|
|
|
1409
1506
|
stiffness: 400
|
|
1410
1507
|
});
|
|
1411
1508
|
const maxEffectVal = maxEffect ?? (effect === "blur" ? 10 : effect === "stretch" ? 1.5 : effect === "skew" ? 15 : effect === "speed" ? 100 : 1);
|
|
1412
|
-
const filter =
|
|
1509
|
+
const filter = useTransform3(smoothedVelocity, (v) => {
|
|
1413
1510
|
if (effect !== "blur") return "none";
|
|
1414
1511
|
const val = Math.min(Math.abs(v) * sensitivity * 0.01, maxEffectVal);
|
|
1415
1512
|
return `blur(${val}px)`;
|
|
1416
1513
|
});
|
|
1417
|
-
const scaleY =
|
|
1514
|
+
const scaleY = useTransform3(smoothedVelocity, (v) => {
|
|
1418
1515
|
if (effect !== "stretch") return 1;
|
|
1419
1516
|
const val = Math.min(1 + Math.abs(v) * sensitivity * 1e-3, maxEffectVal);
|
|
1420
1517
|
return val;
|
|
1421
1518
|
});
|
|
1422
|
-
const
|
|
1519
|
+
const skewDeg = useTransform3(smoothedVelocity, (v) => {
|
|
1423
1520
|
if (effect !== "skew") return 0;
|
|
1424
1521
|
const sign = Math.sign(v);
|
|
1425
1522
|
const val = Math.min(Math.abs(v) * sensitivity * 0.1, maxEffectVal);
|
|
1426
|
-
return
|
|
1523
|
+
return sign * val;
|
|
1427
1524
|
});
|
|
1428
1525
|
useEffect14(() => {
|
|
1429
1526
|
if (effect === "speed" && internalRef.current) {
|
|
@@ -1434,10 +1531,26 @@ var ScrollVelocity = forwardRef16(
|
|
|
1434
1531
|
});
|
|
1435
1532
|
}
|
|
1436
1533
|
}, [effect, smoothedVelocity, sensitivity, maxEffectVal]);
|
|
1534
|
+
useEffect14(() => {
|
|
1535
|
+
if (typeof children === "function") {
|
|
1536
|
+
return smoothedVelocity.on("change", (latest) => {
|
|
1537
|
+
if (internalRef.current) {
|
|
1538
|
+
internalRef.current.dataset.velocity = latest.toString();
|
|
1539
|
+
}
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
}, [children, smoothedVelocity]);
|
|
1437
1543
|
const [currentVelocity, setCurrentVelocity] = React17.useState(0);
|
|
1544
|
+
const lastUpdateRef = useRef7(0);
|
|
1438
1545
|
useEffect14(() => {
|
|
1439
1546
|
if (typeof children === "function") {
|
|
1440
|
-
return smoothedVelocity.on("change",
|
|
1547
|
+
return smoothedVelocity.on("change", (latest) => {
|
|
1548
|
+
const now = performance.now();
|
|
1549
|
+
if (now - lastUpdateRef.current > 33) {
|
|
1550
|
+
lastUpdateRef.current = now;
|
|
1551
|
+
setCurrentVelocity(latest);
|
|
1552
|
+
}
|
|
1553
|
+
});
|
|
1441
1554
|
}
|
|
1442
1555
|
}, [children, smoothedVelocity]);
|
|
1443
1556
|
return /* @__PURE__ */ jsx18(
|
|
@@ -1449,10 +1562,10 @@ var ScrollVelocity = forwardRef16(
|
|
|
1449
1562
|
...style,
|
|
1450
1563
|
filter,
|
|
1451
1564
|
scaleY,
|
|
1452
|
-
|
|
1453
|
-
|
|
1565
|
+
skewY: effect === "skew" ? skewDeg : void 0,
|
|
1566
|
+
transformOrigin: direction === "y" ? "center" : "left",
|
|
1567
|
+
willChange: "transform"
|
|
1454
1568
|
},
|
|
1455
|
-
animate: effect === "skew" ? { skewY: skewY.get() } : void 0,
|
|
1456
1569
|
...props,
|
|
1457
1570
|
children: typeof children === "function" ? children(currentVelocity) : children
|
|
1458
1571
|
}
|
|
@@ -1491,18 +1604,53 @@ var Spotlight = forwardRef17(
|
|
|
1491
1604
|
const mouseY = useMotionValue5(0);
|
|
1492
1605
|
const x = useSpring6(mouseX, isReducedMotion ? { duration: 0 } : springConfig);
|
|
1493
1606
|
const y = useSpring6(mouseY, isReducedMotion ? { duration: 0 } : springConfig);
|
|
1494
|
-
const
|
|
1495
|
-
|
|
1496
|
-
if (
|
|
1497
|
-
|
|
1607
|
+
const rectRef = useRef8(null);
|
|
1608
|
+
const updateRect = useCallback4(() => {
|
|
1609
|
+
if (internalRef.current) {
|
|
1610
|
+
rectRef.current = internalRef.current.getBoundingClientRect();
|
|
1611
|
+
}
|
|
1612
|
+
}, []);
|
|
1613
|
+
useEffect15(() => {
|
|
1614
|
+
updateRect();
|
|
1615
|
+
window.addEventListener("scroll", updateRect, { passive: true });
|
|
1616
|
+
window.addEventListener("resize", updateRect, { passive: true });
|
|
1617
|
+
return () => {
|
|
1618
|
+
window.removeEventListener("scroll", updateRect);
|
|
1619
|
+
window.removeEventListener("resize", updateRect);
|
|
1620
|
+
};
|
|
1621
|
+
}, [updateRect]);
|
|
1622
|
+
const rafId = useRef8(0);
|
|
1623
|
+
const latestEvent = useRef8(null);
|
|
1624
|
+
const processMouseMove = useCallback4(() => {
|
|
1625
|
+
rafId.current = 0;
|
|
1626
|
+
const e = latestEvent.current;
|
|
1627
|
+
if (!e) return;
|
|
1628
|
+
const rect = rectRef.current;
|
|
1629
|
+
if (!rect) return;
|
|
1498
1630
|
mouseX.set(e.clientX - rect.left);
|
|
1499
1631
|
mouseY.set(e.clientY - rect.top);
|
|
1500
|
-
}, [mouseX, mouseY
|
|
1632
|
+
}, [mouseX, mouseY]);
|
|
1633
|
+
const handleMouseMove = useCallback4((e) => {
|
|
1634
|
+
if (disabled || isReducedMotion || disableOnTouch && isTouchDevice) return;
|
|
1635
|
+
if (!rectRef.current && internalRef.current) {
|
|
1636
|
+
rectRef.current = internalRef.current.getBoundingClientRect();
|
|
1637
|
+
}
|
|
1638
|
+
latestEvent.current = e;
|
|
1639
|
+
if (!rafId.current) {
|
|
1640
|
+
rafId.current = requestAnimationFrame(processMouseMove);
|
|
1641
|
+
}
|
|
1642
|
+
}, [disabled, isReducedMotion, disableOnTouch, isTouchDevice, processMouseMove]);
|
|
1643
|
+
useEffect15(() => {
|
|
1644
|
+
return () => {
|
|
1645
|
+
if (rafId.current) cancelAnimationFrame(rafId.current);
|
|
1646
|
+
};
|
|
1647
|
+
}, []);
|
|
1648
|
+
const cappedBlur = Math.min(blur, 20);
|
|
1649
|
+
const background = useMotionTemplate2`radial-gradient(${size}px circle at ${x}px ${y}px, ${color}, transparent 100%)`;
|
|
1650
|
+
const borderBackground = borderColor ? useMotionTemplate2`radial-gradient(${size}px circle at ${x}px ${y}px, ${borderColor}, transparent 100%)` : background;
|
|
1501
1651
|
if (disabled || isReducedMotion) {
|
|
1502
1652
|
return /* @__PURE__ */ jsx19("div", { ref: mergedRef, className, style: { position: "relative", ...style }, ...props, children });
|
|
1503
1653
|
}
|
|
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
1654
|
return /* @__PURE__ */ jsxs6(
|
|
1507
1655
|
"div",
|
|
1508
1656
|
{
|
|
@@ -1518,14 +1666,14 @@ var Spotlight = forwardRef17(
|
|
|
1518
1666
|
style: {
|
|
1519
1667
|
position: "absolute",
|
|
1520
1668
|
inset: -1,
|
|
1521
|
-
// Adjust based on desired border width
|
|
1522
1669
|
background: borderBackground,
|
|
1523
1670
|
opacity,
|
|
1524
1671
|
zIndex: 0,
|
|
1525
1672
|
pointerEvents: "none",
|
|
1526
1673
|
borderRadius: "inherit",
|
|
1527
1674
|
maskImage: "linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",
|
|
1528
|
-
maskComposite: "exclude"
|
|
1675
|
+
maskComposite: "exclude",
|
|
1676
|
+
willChange: "background"
|
|
1529
1677
|
}
|
|
1530
1678
|
}
|
|
1531
1679
|
),
|
|
@@ -1542,7 +1690,8 @@ var Spotlight = forwardRef17(
|
|
|
1542
1690
|
pointerEvents: "none",
|
|
1543
1691
|
borderRadius: "inherit",
|
|
1544
1692
|
mixBlendMode: mode === "reveal" ? "overlay" : "normal",
|
|
1545
|
-
filter: `blur(${
|
|
1693
|
+
filter: `blur(${cappedBlur}px)`,
|
|
1694
|
+
willChange: "background"
|
|
1546
1695
|
}
|
|
1547
1696
|
}
|
|
1548
1697
|
)
|
|
@@ -1983,7 +2132,7 @@ function AnimatedListComponent({
|
|
|
1983
2132
|
var AnimatedList = forwardRef23(AnimatedListComponent);
|
|
1984
2133
|
|
|
1985
2134
|
// src/primitives/24-marquee.tsx
|
|
1986
|
-
import { forwardRef as forwardRef24, useEffect as useEffect18, useRef as useRef10, useState as useState13 } from "react";
|
|
2135
|
+
import { forwardRef as forwardRef24, useEffect as useEffect18, useMemo as useMemo3, useRef as useRef10, useState as useState13 } from "react";
|
|
1987
2136
|
import { jsx as jsx26, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1988
2137
|
var Marquee = forwardRef24(
|
|
1989
2138
|
({
|
|
@@ -2014,18 +2163,25 @@ var Marquee = forwardRef24(
|
|
|
2014
2163
|
const calcDir = dirFactor * revFactor;
|
|
2015
2164
|
useEffect18(() => {
|
|
2016
2165
|
if (disabled || isReducedMotion) return;
|
|
2166
|
+
let resizeTimeout;
|
|
2017
2167
|
const observer = new ResizeObserver((entries) => {
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2168
|
+
clearTimeout(resizeTimeout);
|
|
2169
|
+
resizeTimeout = setTimeout(() => {
|
|
2170
|
+
for (const entry of entries) {
|
|
2171
|
+
if (entry.target === containerRef.current) {
|
|
2172
|
+
setContainerSize(isHorizontal ? entry.contentRect.width : entry.contentRect.height);
|
|
2173
|
+
} else if (entry.target === contentRef.current) {
|
|
2174
|
+
setContentSize(isHorizontal ? entry.contentRect.width : entry.contentRect.height);
|
|
2175
|
+
}
|
|
2023
2176
|
}
|
|
2024
|
-
}
|
|
2177
|
+
}, 100);
|
|
2025
2178
|
});
|
|
2026
2179
|
if (containerRef.current) observer.observe(containerRef.current);
|
|
2027
2180
|
if (contentRef.current) observer.observe(contentRef.current);
|
|
2028
|
-
return () =>
|
|
2181
|
+
return () => {
|
|
2182
|
+
clearTimeout(resizeTimeout);
|
|
2183
|
+
observer.disconnect();
|
|
2184
|
+
};
|
|
2029
2185
|
}, [isHorizontal, disabled, isReducedMotion]);
|
|
2030
2186
|
if (disabled || isReducedMotion) {
|
|
2031
2187
|
return /* @__PURE__ */ jsx26("div", { ref: mergedRef, className, style: { display: "flex", flexWrap: "wrap", gap, ...style }, ...props, children });
|
|
@@ -2034,12 +2190,12 @@ var Marquee = forwardRef24(
|
|
|
2034
2190
|
const duration = (contentSize + gap) / speed;
|
|
2035
2191
|
const keyframesName = `flux-marquee-${calcDir < 0 ? "negative" : "positive"}-${isHorizontal ? "x" : "y"}`;
|
|
2036
2192
|
const translateProp = isHorizontal ? "translateX" : "translateY";
|
|
2037
|
-
const cssString = `
|
|
2193
|
+
const cssString = useMemo3(() => `
|
|
2038
2194
|
@keyframes ${keyframesName} {
|
|
2039
2195
|
0% { transform: ${translateProp}(${calcDir < 0 ? "0" : `-${contentSize + gap}px`}); }
|
|
2040
2196
|
100% { transform: ${translateProp}(${calcDir < 0 ? `-${contentSize + gap}px` : "0"}); }
|
|
2041
2197
|
}
|
|
2042
|
-
|
|
2198
|
+
`, [keyframesName, translateProp, calcDir, contentSize, gap]);
|
|
2043
2199
|
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
2200
|
return /* @__PURE__ */ jsxs7(
|
|
2045
2201
|
"div",
|
|
@@ -2068,7 +2224,8 @@ var Marquee = forwardRef24(
|
|
|
2068
2224
|
width: isHorizontal ? "fit-content" : "100%",
|
|
2069
2225
|
height: isHorizontal ? "100%" : "fit-content",
|
|
2070
2226
|
animation: `${keyframesName} ${duration}s linear infinite`,
|
|
2071
|
-
animationPlayState: "inherit"
|
|
2227
|
+
animationPlayState: "inherit",
|
|
2228
|
+
willChange: "transform"
|
|
2072
2229
|
},
|
|
2073
2230
|
onMouseEnter: (e) => {
|
|
2074
2231
|
if (pauseOnHover) e.currentTarget.style.animationPlayState = "paused";
|
|
@@ -2102,8 +2259,8 @@ var Marquee = forwardRef24(
|
|
|
2102
2259
|
Marquee.displayName = "Marquee";
|
|
2103
2260
|
|
|
2104
2261
|
// src/primitives/25-dock.tsx
|
|
2105
|
-
import React26, { forwardRef as forwardRef25, useRef as useRef11 } from "react";
|
|
2106
|
-
import { motion as motion23, useMotionValue as useMotionValue7, useSpring as useSpring8, useTransform as
|
|
2262
|
+
import React26, { forwardRef as forwardRef25, useCallback as useCallback6, useMemo as useMemo4, useRef as useRef11 } from "react";
|
|
2263
|
+
import { motion as motion23, useMotionValue as useMotionValue7, useSpring as useSpring8, useTransform as useTransform4 } from "motion/react";
|
|
2107
2264
|
import { jsx as jsx27, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2108
2265
|
var DockContext = React26.createContext({
|
|
2109
2266
|
mouseX: null,
|
|
@@ -2132,10 +2289,37 @@ var DockRoot = forwardRef25(
|
|
|
2132
2289
|
const mergedRef = useMergedRef(ref, internalRef);
|
|
2133
2290
|
const mouseX = useMotionValue7(Infinity);
|
|
2134
2291
|
const mouseY = useMotionValue7(Infinity);
|
|
2292
|
+
const rafId = useRef11(0);
|
|
2293
|
+
const latestEvent = useRef11(null);
|
|
2294
|
+
const processMouseMove = useCallback6(() => {
|
|
2295
|
+
rafId.current = 0;
|
|
2296
|
+
const e = latestEvent.current;
|
|
2297
|
+
if (!e) return;
|
|
2298
|
+
mouseX.set(e.clientX);
|
|
2299
|
+
mouseY.set(e.clientY);
|
|
2300
|
+
}, [mouseX, mouseY]);
|
|
2301
|
+
const handleMouseMove = useCallback6((e) => {
|
|
2302
|
+
latestEvent.current = { clientX: e.clientX, clientY: e.clientY };
|
|
2303
|
+
if (!rafId.current) {
|
|
2304
|
+
rafId.current = requestAnimationFrame(processMouseMove);
|
|
2305
|
+
}
|
|
2306
|
+
}, [processMouseMove]);
|
|
2307
|
+
const handleMouseLeave = useCallback6(() => {
|
|
2308
|
+
mouseX.set(Infinity);
|
|
2309
|
+
mouseY.set(Infinity);
|
|
2310
|
+
}, [mouseX, mouseY]);
|
|
2311
|
+
const contextValue = useMemo4(() => ({
|
|
2312
|
+
mouseX,
|
|
2313
|
+
mouseY,
|
|
2314
|
+
distance,
|
|
2315
|
+
magnification,
|
|
2316
|
+
direction,
|
|
2317
|
+
isReducedMotion: false
|
|
2318
|
+
}), [mouseX, mouseY, distance, magnification, direction]);
|
|
2135
2319
|
if (disabled || isReducedMotion) {
|
|
2136
2320
|
return /* @__PURE__ */ jsx27("div", { ref: mergedRef, className, style: { display: "flex", flexDirection: direction === "horizontal" ? "row" : "column", gap, ...style }, ...props, children });
|
|
2137
2321
|
}
|
|
2138
|
-
return /* @__PURE__ */ jsx27(DockContext.Provider, { value:
|
|
2322
|
+
return /* @__PURE__ */ jsx27(DockContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx27(
|
|
2139
2323
|
motion23.div,
|
|
2140
2324
|
{
|
|
2141
2325
|
ref: mergedRef,
|
|
@@ -2147,14 +2331,8 @@ var DockRoot = forwardRef25(
|
|
|
2147
2331
|
alignItems: "center",
|
|
2148
2332
|
...style
|
|
2149
2333
|
},
|
|
2150
|
-
onMouseMove:
|
|
2151
|
-
|
|
2152
|
-
mouseY.set(e.clientY);
|
|
2153
|
-
},
|
|
2154
|
-
onMouseLeave: () => {
|
|
2155
|
-
mouseX.set(Infinity);
|
|
2156
|
-
mouseY.set(Infinity);
|
|
2157
|
-
},
|
|
2334
|
+
onMouseMove: handleMouseMove,
|
|
2335
|
+
onMouseLeave: handleMouseLeave,
|
|
2158
2336
|
...props,
|
|
2159
2337
|
children
|
|
2160
2338
|
}
|
|
@@ -2168,13 +2346,30 @@ var DockItem = forwardRef25(
|
|
|
2168
2346
|
const itemRef = useRef11(null);
|
|
2169
2347
|
const mergedRef = useMergedRef(ref, itemRef);
|
|
2170
2348
|
const distVar = direction === "horizontal" ? mouseX : mouseY;
|
|
2171
|
-
const
|
|
2172
|
-
|
|
2173
|
-
const
|
|
2349
|
+
const rectRef = useRef11(null);
|
|
2350
|
+
React26.useEffect(() => {
|
|
2351
|
+
const el = itemRef.current;
|
|
2352
|
+
if (!el) return;
|
|
2353
|
+
const updateRect = () => {
|
|
2354
|
+
rectRef.current = el.getBoundingClientRect();
|
|
2355
|
+
};
|
|
2356
|
+
updateRect();
|
|
2357
|
+
const ro = new ResizeObserver(updateRect);
|
|
2358
|
+
ro.observe(el);
|
|
2359
|
+
window.addEventListener("scroll", updateRect, { passive: true });
|
|
2360
|
+
return () => {
|
|
2361
|
+
ro.disconnect();
|
|
2362
|
+
window.removeEventListener("scroll", updateRect);
|
|
2363
|
+
};
|
|
2364
|
+
}, []);
|
|
2365
|
+
const distanceCalc = useTransform4(distVar, (val) => {
|
|
2366
|
+
if (val === Infinity) return distance;
|
|
2367
|
+
const bounds = rectRef.current;
|
|
2368
|
+
if (!bounds) return distance;
|
|
2174
2369
|
const center = direction === "horizontal" ? bounds.x + bounds.width / 2 : bounds.y + bounds.height / 2;
|
|
2175
2370
|
return Math.abs(val - center);
|
|
2176
2371
|
});
|
|
2177
|
-
const scaleRaw =
|
|
2372
|
+
const scaleRaw = useTransform4(distanceCalc, [0, distance], [magnification, 1]);
|
|
2178
2373
|
const scale = useSpring8(scaleRaw, { mass: 0.1, stiffness: 300, damping: 20 });
|
|
2179
2374
|
const [isHovered, setIsHovered] = React26.useState(false);
|
|
2180
2375
|
if (isReducedMotion) {
|
|
@@ -2190,11 +2385,11 @@ var DockItem = forwardRef25(
|
|
|
2190
2385
|
style: {
|
|
2191
2386
|
scale,
|
|
2192
2387
|
transformOrigin: direction === "horizontal" ? "bottom" : "left",
|
|
2193
|
-
// Common dock origin
|
|
2194
2388
|
display: "flex",
|
|
2195
2389
|
alignItems: "center",
|
|
2196
2390
|
justifyContent: "center",
|
|
2197
2391
|
position: "relative",
|
|
2392
|
+
willChange: "transform",
|
|
2198
2393
|
...style
|
|
2199
2394
|
},
|
|
2200
2395
|
className,
|
|
@@ -2342,6 +2537,7 @@ var ScrollProgress = forwardRef27(
|
|
|
2342
2537
|
...dimStyles,
|
|
2343
2538
|
backgroundColor: color,
|
|
2344
2539
|
zIndex: 9999,
|
|
2540
|
+
willChange: "transform",
|
|
2345
2541
|
...style
|
|
2346
2542
|
},
|
|
2347
2543
|
...props
|
|
@@ -2363,7 +2559,8 @@ var ScrollProgress = forwardRef27(
|
|
|
2363
2559
|
scaleX: axis === "x" ? scaleValue : void 0,
|
|
2364
2560
|
scaleY: axis === "y" ? scaleValue : void 0,
|
|
2365
2561
|
transformOrigin: "0% 0%",
|
|
2366
|
-
zIndex: -1
|
|
2562
|
+
zIndex: -1,
|
|
2563
|
+
willChange: "transform"
|
|
2367
2564
|
}
|
|
2368
2565
|
}
|
|
2369
2566
|
)
|
|
@@ -2374,7 +2571,7 @@ ScrollProgress.displayName = "ScrollProgress";
|
|
|
2374
2571
|
|
|
2375
2572
|
// src/primitives/28-parallax.tsx
|
|
2376
2573
|
import { forwardRef as forwardRef28, useRef as useRef14 } from "react";
|
|
2377
|
-
import { motion as motion25, useScroll as useScroll4, useTransform as
|
|
2574
|
+
import { motion as motion25, useScroll as useScroll4, useTransform as useTransform5 } from "motion/react";
|
|
2378
2575
|
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
2379
2576
|
var Parallax = forwardRef28(
|
|
2380
2577
|
({
|
|
@@ -2397,7 +2594,7 @@ var Parallax = forwardRef28(
|
|
|
2397
2594
|
});
|
|
2398
2595
|
const transformStart = direction === "up" ? offset : direction === "down" ? -offset : direction === "left" ? offset : -offset;
|
|
2399
2596
|
const transformEnd = direction === "up" ? -offset : direction === "down" ? offset : direction === "left" ? -offset : offset;
|
|
2400
|
-
const translate =
|
|
2597
|
+
const translate = useTransform5(scrollYProgress, [0, 1], [transformStart, transformEnd]);
|
|
2401
2598
|
if (disabled || isReducedMotion) {
|
|
2402
2599
|
return /* @__PURE__ */ jsx30("div", { ref: mergedRef, className, style, ...props, children });
|
|
2403
2600
|
}
|
|
@@ -2409,7 +2606,8 @@ var Parallax = forwardRef28(
|
|
|
2409
2606
|
style: {
|
|
2410
2607
|
...style,
|
|
2411
2608
|
y: direction === "up" || direction === "down" ? translate : 0,
|
|
2412
|
-
x: direction === "left" || direction === "right" ? translate : 0
|
|
2609
|
+
x: direction === "left" || direction === "right" ? translate : 0,
|
|
2610
|
+
willChange: "transform"
|
|
2413
2611
|
},
|
|
2414
2612
|
...props,
|
|
2415
2613
|
children
|
|
@@ -2600,18 +2798,6 @@ var Aurora = forwardRef31(
|
|
|
2600
2798
|
const internalRef = useRef17(null);
|
|
2601
2799
|
const mergedRef = useMergedRef(ref, internalRef);
|
|
2602
2800
|
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
2801
|
const gradientString = `linear-gradient(-45deg, ${colors.join(", ")})`;
|
|
2616
2802
|
return /* @__PURE__ */ jsxs12(
|
|
2617
2803
|
"div",
|
|
@@ -2631,18 +2817,28 @@ var Aurora = forwardRef31(
|
|
|
2631
2817
|
"div",
|
|
2632
2818
|
{
|
|
2633
2819
|
style: {
|
|
2634
|
-
|
|
2820
|
+
position: "absolute",
|
|
2821
|
+
top: "-50%",
|
|
2822
|
+
left: "-50%",
|
|
2823
|
+
width: "200%",
|
|
2824
|
+
height: "200%",
|
|
2825
|
+
opacity,
|
|
2826
|
+
mixBlendMode: blendMode,
|
|
2827
|
+
filter: `blur(${blur}px)`,
|
|
2828
|
+
pointerEvents: "none",
|
|
2829
|
+
zIndex: 0,
|
|
2635
2830
|
background: gradientString,
|
|
2636
2831
|
backgroundSize: "400% 400%",
|
|
2832
|
+
willChange: "transform",
|
|
2637
2833
|
animation: isReducedMotion ? "none" : `flux-aurora ${speed}s ease infinite`
|
|
2638
2834
|
}
|
|
2639
2835
|
}
|
|
2640
2836
|
),
|
|
2641
2837
|
/* @__PURE__ */ jsx33("style", { children: `
|
|
2642
2838
|
@keyframes flux-aurora {
|
|
2643
|
-
0% { background-position: 0% 50%;
|
|
2644
|
-
50% { background-position: 100% 50%;
|
|
2645
|
-
100% { background-position: 0% 50%;
|
|
2839
|
+
0% { transform: rotate(0deg) scale(1); background-position: 0% 50%; }
|
|
2840
|
+
50% { transform: rotate(180deg) scale(1.05); background-position: 100% 50%; }
|
|
2841
|
+
100% { transform: rotate(360deg) scale(1); background-position: 0% 50%; }
|
|
2646
2842
|
}
|
|
2647
2843
|
` })
|
|
2648
2844
|
]
|
|
@@ -2671,7 +2867,6 @@ var MeshGradient = forwardRef32(
|
|
|
2671
2867
|
const baseStyle = {
|
|
2672
2868
|
position: "absolute",
|
|
2673
2869
|
inset: -50,
|
|
2674
|
-
// bleed edge to avoid seeing bounds during rotation
|
|
2675
2870
|
opacity: 0.8,
|
|
2676
2871
|
filter: "blur(60px)",
|
|
2677
2872
|
pointerEvents: "none",
|
|
@@ -2682,7 +2877,8 @@ var MeshGradient = forwardRef32(
|
|
|
2682
2877
|
radial-gradient(circle at 100% 100%, ${colors[2]} 0%, transparent 50%),
|
|
2683
2878
|
radial-gradient(circle at 0% 0%, ${colors[3]} 0%, transparent 50%)
|
|
2684
2879
|
`,
|
|
2685
|
-
backgroundSize: "200% 200%"
|
|
2880
|
+
backgroundSize: "200% 200%",
|
|
2881
|
+
willChange: "transform"
|
|
2686
2882
|
};
|
|
2687
2883
|
return /* @__PURE__ */ jsxs13(
|
|
2688
2884
|
"div",
|
|
@@ -2709,9 +2905,9 @@ var MeshGradient = forwardRef32(
|
|
|
2709
2905
|
),
|
|
2710
2906
|
/* @__PURE__ */ jsx34("style", { children: `
|
|
2711
2907
|
@keyframes flux-mesh {
|
|
2712
|
-
0% {
|
|
2713
|
-
50% {
|
|
2714
|
-
100% {
|
|
2908
|
+
0% { transform: scale(1) rotate(0deg); background-position: 0% 0%; }
|
|
2909
|
+
50% { transform: scale(1.1) rotate(5deg); background-position: 100% 100%; }
|
|
2910
|
+
100% { transform: scale(1) rotate(-5deg); background-position: 0% 0%; }
|
|
2715
2911
|
}
|
|
2716
2912
|
` })
|
|
2717
2913
|
]
|
|
@@ -2802,18 +2998,29 @@ var Particles = forwardRef33(
|
|
|
2802
2998
|
};
|
|
2803
2999
|
resizeCanvas();
|
|
2804
3000
|
animate();
|
|
2805
|
-
|
|
2806
|
-
|
|
3001
|
+
let mouseRafId = 0;
|
|
3002
|
+
let latestMouseEvent = null;
|
|
3003
|
+
const processMouseMove = () => {
|
|
3004
|
+
mouseRafId = 0;
|
|
3005
|
+
const e = latestMouseEvent;
|
|
3006
|
+
if (!e || !internalRef.current) return;
|
|
2807
3007
|
const rect = internalRef.current.getBoundingClientRect();
|
|
2808
3008
|
mouse.current.x = e.clientX - rect.left - canvasSize.current.w / 2;
|
|
2809
3009
|
mouse.current.y = e.clientY - rect.top - canvasSize.current.h / 2;
|
|
2810
3010
|
};
|
|
3011
|
+
const handleMouseMove = (e) => {
|
|
3012
|
+
latestMouseEvent = e;
|
|
3013
|
+
if (!mouseRafId) {
|
|
3014
|
+
mouseRafId = requestAnimationFrame(processMouseMove);
|
|
3015
|
+
}
|
|
3016
|
+
};
|
|
2811
3017
|
window.addEventListener("resize", resizeCanvas);
|
|
2812
|
-
window.addEventListener("mousemove", handleMouseMove);
|
|
3018
|
+
window.addEventListener("mousemove", handleMouseMove, { passive: true });
|
|
2813
3019
|
return () => {
|
|
2814
3020
|
window.removeEventListener("resize", resizeCanvas);
|
|
2815
3021
|
window.removeEventListener("mousemove", handleMouseMove);
|
|
2816
3022
|
if (animationFrameId.current) window.cancelAnimationFrame(animationFrameId.current);
|
|
3023
|
+
if (mouseRafId) cancelAnimationFrame(mouseRafId);
|
|
2817
3024
|
};
|
|
2818
3025
|
}, [color, quantity, staticity, ease, disabled, isReducedMotion]);
|
|
2819
3026
|
if (disabled) return null;
|
|
@@ -2910,8 +3117,7 @@ var Noise = forwardRef35(
|
|
|
2910
3117
|
Noise.displayName = "Noise";
|
|
2911
3118
|
|
|
2912
3119
|
// src/primitives/36-streaming-text.tsx
|
|
2913
|
-
import
|
|
2914
|
-
import { motion as motion27 } from "motion/react";
|
|
3120
|
+
import { forwardRef as forwardRef36, useEffect as useEffect22, useRef as useRef20 } from "react";
|
|
2915
3121
|
import { jsx as jsx38, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2916
3122
|
var StreamingText = forwardRef36(
|
|
2917
3123
|
({
|
|
@@ -2927,43 +3133,71 @@ var StreamingText = forwardRef36(
|
|
|
2927
3133
|
...props
|
|
2928
3134
|
}, ref) => {
|
|
2929
3135
|
const isReducedMotion = useReducedMotion();
|
|
2930
|
-
const internalRef =
|
|
3136
|
+
const internalRef = useRef20(null);
|
|
2931
3137
|
const mergedRef = useMergedRef(ref, internalRef);
|
|
2932
|
-
const
|
|
2933
|
-
const
|
|
3138
|
+
const textNodeRef = useRef20(null);
|
|
3139
|
+
const cursorRef = useRef20(null);
|
|
3140
|
+
const onCompleteRef = useRef20(onComplete);
|
|
3141
|
+
onCompleteRef.current = onComplete;
|
|
2934
3142
|
useEffect22(() => {
|
|
3143
|
+
const el = internalRef.current;
|
|
3144
|
+
if (!el) return;
|
|
2935
3145
|
if (disabled || isReducedMotion) {
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
3146
|
+
if (!textNodeRef.current) {
|
|
3147
|
+
textNodeRef.current = document.createTextNode(text);
|
|
3148
|
+
el.insertBefore(textNodeRef.current, el.firstChild);
|
|
3149
|
+
} else {
|
|
3150
|
+
textNodeRef.current.textContent = text;
|
|
3151
|
+
}
|
|
3152
|
+
if (cursorRef.current) {
|
|
3153
|
+
cursorRef.current.style.display = "none";
|
|
3154
|
+
}
|
|
3155
|
+
onCompleteRef.current?.();
|
|
2939
3156
|
return;
|
|
2940
3157
|
}
|
|
2941
|
-
|
|
2942
|
-
|
|
3158
|
+
if (!textNodeRef.current) {
|
|
3159
|
+
textNodeRef.current = document.createTextNode("");
|
|
3160
|
+
el.insertBefore(textNodeRef.current, el.firstChild);
|
|
3161
|
+
} else {
|
|
3162
|
+
textNodeRef.current.textContent = "";
|
|
3163
|
+
}
|
|
3164
|
+
if (cursorRef.current) {
|
|
3165
|
+
cursorRef.current.style.display = "inline-block";
|
|
3166
|
+
}
|
|
2943
3167
|
let i = 0;
|
|
2944
3168
|
const intervalId = setInterval(() => {
|
|
2945
|
-
|
|
3169
|
+
if (textNodeRef.current) {
|
|
3170
|
+
textNodeRef.current.textContent = text.slice(0, i + 1);
|
|
3171
|
+
}
|
|
2946
3172
|
i++;
|
|
2947
3173
|
if (i >= text.length) {
|
|
2948
3174
|
clearInterval(intervalId);
|
|
2949
|
-
|
|
2950
|
-
|
|
3175
|
+
if (cursorRef.current) {
|
|
3176
|
+
cursorRef.current.style.display = "none";
|
|
3177
|
+
}
|
|
3178
|
+
onCompleteRef.current?.();
|
|
2951
3179
|
}
|
|
2952
3180
|
}, speed);
|
|
2953
3181
|
return () => clearInterval(intervalId);
|
|
2954
|
-
}, [text, speed, disabled, isReducedMotion
|
|
3182
|
+
}, [text, speed, disabled, isReducedMotion]);
|
|
2955
3183
|
return /* @__PURE__ */ jsxs14("span", { ref: mergedRef, className, style: { whiteSpace: "pre-wrap", ...style }, ...props, children: [
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
motion27.span,
|
|
3184
|
+
cursor && /* @__PURE__ */ jsx38(
|
|
3185
|
+
"span",
|
|
2959
3186
|
{
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
3187
|
+
ref: cursorRef,
|
|
3188
|
+
style: {
|
|
3189
|
+
display: "inline-block",
|
|
3190
|
+
marginLeft: "2px",
|
|
3191
|
+
fontWeight: "bold",
|
|
3192
|
+
animation: "flux-cursor-blink 0.8s step-end infinite"
|
|
3193
|
+
},
|
|
2964
3194
|
children: cursorChar
|
|
2965
3195
|
}
|
|
2966
|
-
)
|
|
3196
|
+
),
|
|
3197
|
+
/* @__PURE__ */ jsx38("style", { children: `@keyframes flux-cursor-blink {
|
|
3198
|
+
0%, 100% { opacity: 1; }
|
|
3199
|
+
50% { opacity: 0; }
|
|
3200
|
+
}` })
|
|
2967
3201
|
] });
|
|
2968
3202
|
}
|
|
2969
3203
|
);
|
|
@@ -2971,7 +3205,7 @@ StreamingText.displayName = "StreamingText";
|
|
|
2971
3205
|
|
|
2972
3206
|
// src/primitives/37-typing-indicator.tsx
|
|
2973
3207
|
import React38, { forwardRef as forwardRef37 } from "react";
|
|
2974
|
-
import { motion as
|
|
3208
|
+
import { motion as motion27 } from "motion/react";
|
|
2975
3209
|
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
2976
3210
|
var TypingIndicator = forwardRef37(
|
|
2977
3211
|
({
|
|
@@ -3001,7 +3235,7 @@ var TypingIndicator = forwardRef37(
|
|
|
3001
3235
|
style: { display: "inline-flex", alignItems: "center", gap: size / 2, ...style },
|
|
3002
3236
|
...props,
|
|
3003
3237
|
children: [0, 1, 2].map((i) => /* @__PURE__ */ jsx39(
|
|
3004
|
-
|
|
3238
|
+
motion27.div,
|
|
3005
3239
|
{
|
|
3006
3240
|
style: dotStyle,
|
|
3007
3241
|
animate: isReducedMotion ? void 0 : {
|
|
@@ -3025,7 +3259,7 @@ TypingIndicator.displayName = "TypingIndicator";
|
|
|
3025
3259
|
|
|
3026
3260
|
// src/primitives/38-skeleton.tsx
|
|
3027
3261
|
import React39, { forwardRef as forwardRef38 } from "react";
|
|
3028
|
-
import { motion as
|
|
3262
|
+
import { motion as motion28 } from "motion/react";
|
|
3029
3263
|
import { jsx as jsx40 } from "react/jsx-runtime";
|
|
3030
3264
|
var Skeleton = forwardRef38(
|
|
3031
3265
|
({
|
|
@@ -3070,7 +3304,7 @@ var Skeleton = forwardRef38(
|
|
|
3070
3304
|
},
|
|
3071
3305
|
...props,
|
|
3072
3306
|
children: !isReducedMotion && /* @__PURE__ */ jsx40(
|
|
3073
|
-
|
|
3307
|
+
motion28.div,
|
|
3074
3308
|
{
|
|
3075
3309
|
style: {
|
|
3076
3310
|
position: "absolute",
|
|
@@ -3097,7 +3331,7 @@ Skeleton.displayName = "Skeleton";
|
|
|
3097
3331
|
|
|
3098
3332
|
// src/primitives/39-ai-message.tsx
|
|
3099
3333
|
import React40, { forwardRef as forwardRef39 } from "react";
|
|
3100
|
-
import { motion as
|
|
3334
|
+
import { motion as motion29 } from "motion/react";
|
|
3101
3335
|
import { jsx as jsx41, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3102
3336
|
var AIMessage = forwardRef39(
|
|
3103
3337
|
({
|
|
@@ -3124,7 +3358,7 @@ var AIMessage = forwardRef39(
|
|
|
3124
3358
|
const alignment = role === "user" ? "flex-end" : "flex-start";
|
|
3125
3359
|
const origin = role === "user" ? "bottom right" : "bottom left";
|
|
3126
3360
|
return /* @__PURE__ */ jsxs15(
|
|
3127
|
-
|
|
3361
|
+
motion29.div,
|
|
3128
3362
|
{
|
|
3129
3363
|
ref: mergedRef,
|
|
3130
3364
|
className,
|
|
@@ -3141,7 +3375,7 @@ var AIMessage = forwardRef39(
|
|
|
3141
3375
|
...props,
|
|
3142
3376
|
children: [
|
|
3143
3377
|
role !== "user" && avatar && /* @__PURE__ */ jsx41(
|
|
3144
|
-
|
|
3378
|
+
motion29.div,
|
|
3145
3379
|
{
|
|
3146
3380
|
initial: isReducedMotion ? { opacity: 0 } : { opacity: 0, scale: 0 },
|
|
3147
3381
|
animate: { opacity: 1, scale: 1 },
|
|
@@ -3151,7 +3385,7 @@ var AIMessage = forwardRef39(
|
|
|
3151
3385
|
),
|
|
3152
3386
|
/* @__PURE__ */ jsx41("div", { style: { flex: 1, maxWidth: "80%" }, children }),
|
|
3153
3387
|
role === "user" && avatar && /* @__PURE__ */ jsx41(
|
|
3154
|
-
|
|
3388
|
+
motion29.div,
|
|
3155
3389
|
{
|
|
3156
3390
|
initial: isReducedMotion ? { opacity: 0 } : { opacity: 0, scale: 0 },
|
|
3157
3391
|
animate: { opacity: 1, scale: 1 },
|
|
@@ -3168,7 +3402,7 @@ AIMessage.displayName = "AIMessage";
|
|
|
3168
3402
|
|
|
3169
3403
|
// src/primitives/40-hero-highlight.tsx
|
|
3170
3404
|
import React41, { forwardRef as forwardRef40 } from "react";
|
|
3171
|
-
import { motion as
|
|
3405
|
+
import { motion as motion30, useMotionTemplate as useMotionTemplate3, useMotionValue as useMotionValue8 } from "motion/react";
|
|
3172
3406
|
import { jsx as jsx42, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
3173
3407
|
var HeroHighlight = forwardRef40(
|
|
3174
3408
|
({
|
|
@@ -3207,7 +3441,7 @@ var HeroHighlight = forwardRef40(
|
|
|
3207
3441
|
children: [
|
|
3208
3442
|
/* @__PURE__ */ jsx42("div", { className: "absolute inset-0 bg-dot-thick-neutral-300 dark:bg-dot-thick-neutral-800 pointer-events-none" }),
|
|
3209
3443
|
/* @__PURE__ */ jsx42(
|
|
3210
|
-
|
|
3444
|
+
motion30.div,
|
|
3211
3445
|
{
|
|
3212
3446
|
className: "absolute inset-0 opacity-0 transition duration-300 group-hover:opacity-100 pointer-events-none bg-dot-thick-teal-500",
|
|
3213
3447
|
style: {
|
|
@@ -3241,7 +3475,7 @@ var Highlight = ({
|
|
|
3241
3475
|
}) => {
|
|
3242
3476
|
const isReducedMotion = useReducedMotion();
|
|
3243
3477
|
return /* @__PURE__ */ jsx42(
|
|
3244
|
-
|
|
3478
|
+
motion30.span,
|
|
3245
3479
|
{
|
|
3246
3480
|
initial: {
|
|
3247
3481
|
backgroundSize: "0% 100%"
|