@underverse-ui/underverse 1.0.65 → 1.0.66
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/api-reference.json +1 -1
- package/dist/index.cjs +78 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +78 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16224,6 +16224,7 @@ function Carousel({
|
|
|
16224
16224
|
const carouselRef = React42.useRef(null);
|
|
16225
16225
|
const rafRef = React42.useRef(null);
|
|
16226
16226
|
const isDraggingRef = React42.useRef(false);
|
|
16227
|
+
const dragDistanceRef = React42.useRef(0);
|
|
16227
16228
|
const startPosRef = React42.useRef(0);
|
|
16228
16229
|
const lastDragPositionRef = React42.useRef(0);
|
|
16229
16230
|
const slides = React42.useMemo(() => React42.Children.toArray(children), [children]);
|
|
@@ -16423,6 +16424,7 @@ function Carousel({
|
|
|
16423
16424
|
};
|
|
16424
16425
|
const touchStart = (event) => {
|
|
16425
16426
|
isDraggingRef.current = true;
|
|
16427
|
+
dragDistanceRef.current = 0;
|
|
16426
16428
|
const pos = isHorizontal ? getPositionX(event.nativeEvent) : getPositionY(event.nativeEvent);
|
|
16427
16429
|
startPosRef.current = pos;
|
|
16428
16430
|
lastDragPositionRef.current = pos;
|
|
@@ -16431,6 +16433,7 @@ function Carousel({
|
|
|
16431
16433
|
if (!isDraggingRef.current) return;
|
|
16432
16434
|
const pos = isHorizontal ? getPositionX(event.nativeEvent) : getPositionY(event.nativeEvent);
|
|
16433
16435
|
lastDragPositionRef.current = pos;
|
|
16436
|
+
dragDistanceRef.current = Math.max(dragDistanceRef.current, Math.abs(pos - startPosRef.current));
|
|
16434
16437
|
};
|
|
16435
16438
|
const touchEnd = () => {
|
|
16436
16439
|
if (!isDraggingRef.current) return;
|
|
@@ -16445,6 +16448,23 @@ function Carousel({
|
|
|
16445
16448
|
startPosRef.current = 0;
|
|
16446
16449
|
lastDragPositionRef.current = 0;
|
|
16447
16450
|
};
|
|
16451
|
+
const handleDeckAreaClick = React42.useCallback((event) => {
|
|
16452
|
+
if (!isDeckAnimation || dragDistanceRef.current > 8) {
|
|
16453
|
+
dragDistanceRef.current = 0;
|
|
16454
|
+
return;
|
|
16455
|
+
}
|
|
16456
|
+
const activeDeck = event.currentTarget.querySelector("[data-active-deck='true']");
|
|
16457
|
+
if (!activeDeck) return;
|
|
16458
|
+
const activeRect = activeDeck.getBoundingClientRect();
|
|
16459
|
+
const x = event.clientX;
|
|
16460
|
+
if (x < activeRect.left) {
|
|
16461
|
+
scrollPrev();
|
|
16462
|
+
return;
|
|
16463
|
+
}
|
|
16464
|
+
if (x > activeRect.right) {
|
|
16465
|
+
scrollNext();
|
|
16466
|
+
}
|
|
16467
|
+
}, [isDeckAnimation, scrollNext, scrollPrev]);
|
|
16448
16468
|
React42.useEffect(() => {
|
|
16449
16469
|
onSlideChange?.(currentIndex);
|
|
16450
16470
|
}, [currentIndex, onSlideChange]);
|
|
@@ -16480,6 +16500,7 @@ function Carousel({
|
|
|
16480
16500
|
return {
|
|
16481
16501
|
opacity: 0,
|
|
16482
16502
|
pointerEvents: "none",
|
|
16503
|
+
zIndex: 0,
|
|
16483
16504
|
transform: `translate3d(0, 0, -${mergedEffectOptions.depthStep * 2}px) scale(${mergedEffectOptions.farScale})`,
|
|
16484
16505
|
filter: `blur(${mergedEffectOptions.blur * 1.4}px)`
|
|
16485
16506
|
};
|
|
@@ -16492,7 +16513,8 @@ function Carousel({
|
|
|
16492
16513
|
opacity: distance === 0 ? 1 : distance === 1 || distance === -1 ? mergedEffectOptions.sideOpacity : mergedEffectOptions.farOpacity,
|
|
16493
16514
|
transform: `translate3d(${xOffset2}px, ${yOffset}px, -${absDistance * mergedEffectOptions.depthStep}px) scale(${scale2})`,
|
|
16494
16515
|
filter: distance === 0 ? "blur(0px)" : `blur(${Math.min(absDistance, 2) * mergedEffectOptions.blur}px)`,
|
|
16495
|
-
pointerEvents: "auto"
|
|
16516
|
+
pointerEvents: "auto",
|
|
16517
|
+
zIndex: 30 - absDistance
|
|
16496
16518
|
};
|
|
16497
16519
|
}
|
|
16498
16520
|
const xOffset = distance * mergedEffectOptions.sideOffset;
|
|
@@ -16502,7 +16524,8 @@ function Carousel({
|
|
|
16502
16524
|
opacity: distance === 0 ? 1 : distance === 1 || distance === -1 ? mergedEffectOptions.sideOpacity : mergedEffectOptions.farOpacity,
|
|
16503
16525
|
transform: `translate3d(${xOffset}%, 0, -${absDistance * mergedEffectOptions.depthStep}px) rotateY(${rotateY}deg) scale(${scale})`,
|
|
16504
16526
|
filter: distance === 0 ? "blur(0px)" : `blur(${Math.min(absDistance, 2) * mergedEffectOptions.blur}px)`,
|
|
16505
|
-
pointerEvents: "auto"
|
|
16527
|
+
pointerEvents: "auto",
|
|
16528
|
+
zIndex: 30 - absDistance
|
|
16506
16529
|
};
|
|
16507
16530
|
},
|
|
16508
16531
|
[effectiveAnimation, getLoopDistance, mergedEffectOptions]
|
|
@@ -16512,7 +16535,7 @@ function Carousel({
|
|
|
16512
16535
|
{
|
|
16513
16536
|
ref: carouselRef,
|
|
16514
16537
|
className: cn(
|
|
16515
|
-
"relative w-full overflow-hidden focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 rounded-xl md:rounded-3xl",
|
|
16538
|
+
"relative w-full overflow-hidden focus:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 rounded-xl md:rounded-3xl",
|
|
16516
16539
|
className
|
|
16517
16540
|
),
|
|
16518
16541
|
onKeyDown: handleKeyDown,
|
|
@@ -16542,32 +16565,61 @@ function Carousel({
|
|
|
16542
16565
|
onMouseMove: touchMove,
|
|
16543
16566
|
onMouseUp: touchEnd,
|
|
16544
16567
|
onMouseLeave: touchEnd,
|
|
16568
|
+
onClick: handleDeckAreaClick,
|
|
16545
16569
|
role: "group",
|
|
16546
16570
|
"aria-atomic": "false",
|
|
16547
16571
|
"aria-live": autoScroll ? "off" : "polite",
|
|
16548
|
-
children: slides.map((child, idx) =>
|
|
16549
|
-
|
|
16550
|
-
|
|
16551
|
-
|
|
16552
|
-
|
|
16553
|
-
|
|
16554
|
-
|
|
16555
|
-
|
|
16556
|
-
|
|
16557
|
-
|
|
16558
|
-
|
|
16559
|
-
|
|
16560
|
-
|
|
16561
|
-
|
|
16562
|
-
|
|
16563
|
-
|
|
16564
|
-
|
|
16565
|
-
|
|
16566
|
-
|
|
16567
|
-
|
|
16568
|
-
|
|
16569
|
-
|
|
16570
|
-
|
|
16572
|
+
children: slides.map((child, idx) => {
|
|
16573
|
+
const key = React42.isValidElement(child) && child.key || idx;
|
|
16574
|
+
const ariaHidden = effectiveAnimation === "slide" ? idx < currentIndex || idx >= currentIndex + slidesToShow : idx !== currentIndex;
|
|
16575
|
+
if (isDeckAnimation) {
|
|
16576
|
+
return /* @__PURE__ */ jsx49(
|
|
16577
|
+
"div",
|
|
16578
|
+
{
|
|
16579
|
+
className: "col-start-1 row-start-1 flex w-full items-center justify-center pointer-events-none",
|
|
16580
|
+
"aria-hidden": ariaHidden,
|
|
16581
|
+
children: /* @__PURE__ */ jsx49(
|
|
16582
|
+
"div",
|
|
16583
|
+
{
|
|
16584
|
+
className: cn(
|
|
16585
|
+
"w-full max-w-[68%] md:max-w-[60%] transition-[opacity,transform,filter] duration-500 ease-out",
|
|
16586
|
+
idx !== currentIndex && "cursor-pointer",
|
|
16587
|
+
slideClassName
|
|
16588
|
+
),
|
|
16589
|
+
"data-active-deck": idx === currentIndex ? "true" : void 0,
|
|
16590
|
+
style: getDeckSlideStyles(idx),
|
|
16591
|
+
onClick: idx !== currentIndex ? () => scrollTo(idx) : void 0,
|
|
16592
|
+
role: "group",
|
|
16593
|
+
"aria-roledescription": "slide",
|
|
16594
|
+
"aria-label": `${idx + 1} of ${totalSlides}`,
|
|
16595
|
+
children: child
|
|
16596
|
+
}
|
|
16597
|
+
)
|
|
16598
|
+
},
|
|
16599
|
+
key
|
|
16600
|
+
);
|
|
16601
|
+
}
|
|
16602
|
+
return /* @__PURE__ */ jsx49(
|
|
16603
|
+
"div",
|
|
16604
|
+
{
|
|
16605
|
+
className: cn(
|
|
16606
|
+
"shrink-0",
|
|
16607
|
+
effectiveAnimation === "slide" ? isHorizontal ? "h-full" : "h-full w-full" : "col-start-1 row-start-1",
|
|
16608
|
+
effectiveAnimation === "fade" && (idx === currentIndex ? "opacity-100 z-10" : "opacity-0 pointer-events-none z-0"),
|
|
16609
|
+
effectiveAnimation === "scale" && (idx === currentIndex ? "opacity-100 scale-100 z-10" : "opacity-0 scale-95 pointer-events-none z-0"),
|
|
16610
|
+
effectiveAnimation !== "slide" && "transition-[opacity,transform] duration-500 ease-in-out",
|
|
16611
|
+
slideClassName
|
|
16612
|
+
),
|
|
16613
|
+
style: effectiveAnimation === "slide" ? { [isHorizontal ? "width" : "height"]: `${slideWidth}%` } : void 0,
|
|
16614
|
+
role: "group",
|
|
16615
|
+
"aria-roledescription": "slide",
|
|
16616
|
+
"aria-label": `${idx + 1} of ${totalSlides}`,
|
|
16617
|
+
"aria-hidden": ariaHidden,
|
|
16618
|
+
children: child
|
|
16619
|
+
},
|
|
16620
|
+
key
|
|
16621
|
+
);
|
|
16622
|
+
})
|
|
16571
16623
|
}
|
|
16572
16624
|
),
|
|
16573
16625
|
shouldShowArrows && totalSlides > effectiveSlidesToShow && /* @__PURE__ */ jsxs41(Fragment17, { children: [
|