"use client"; import { memo, Children } from "react"; import useEmblaCarousel from "embla-carousel-react"; import { ChevronLeft, ChevronRight } from "lucide-react"; import CardStackTextBox from "../../CardStackTextBox"; import { cls } from "@/lib/utils"; import { ButtonCarouselProps } from "../../types"; import { usePrevNextButtons } from "../../hooks/usePrevNextButtons"; import { useScrollProgress } from "../../hooks/useScrollProgress"; import { useCardAnimation } from "../../hooks/useCardAnimation"; const ButtonCarousel = ({ children, uniformGridCustomHeightClasses, animationType, title, titleSegments, description, tag, tagIcon, buttons, textboxLayout = "default", useInvertedBackground, bottomContent, className = "", containerClassName = "", carouselClassName = "", carouselItemClassName = "", controlsClassName = "", textBoxClassName = "", titleClassName = "", titleImageWrapperClassName = "", titleImageClassName = "", descriptionClassName = "", tagClassName = "", buttonContainerClassName = "", buttonClassName = "", buttonTextClassName = "", ariaLabel, }: ButtonCarouselProps) => { const [emblaRef, emblaApi] = useEmblaCarousel({ dragFree: true }); const { prevBtnDisabled, nextBtnDisabled, onPrevButtonClick, onNextButtonClick, } = usePrevNextButtons(emblaApi); const scrollProgress = useScrollProgress(emblaApi); const childrenArray = Children.toArray(children); const heightClasses = uniformGridCustomHeightClasses || "min-h-80 2xl:min-h-90"; const { itemRefs, bottomContentRef } = useCardAnimation({ animationType, itemCount: childrenArray.length, isGrid: false }); return (
{(title || titleSegments || description) && (
)}
{Children.map(childrenArray, (child, index) => (
{ itemRefs.current[index] = el; }} > {child}
))}
{bottomContent && (
{bottomContent}
)}
); }; ButtonCarousel.displayName = "ButtonCarousel"; export default memo(ButtonCarousel);