/**
* Dot indicators overlaid at the bottom of the carousel.
* Hides when showDots is false or slideCount <= 1.
*
* @example
*/
import { memo } from 'react';
import { Container } from '@cleartrip/ct-design-container';
import { useTheme } from '@cleartrip/ct-design-theme';
import { staticStyles } from '../style';
import { IPaginationProps } from '../type';
const Pagination = ({
slideCount,
currentSlideIndex,
maxDotsToShow,
showDots = true,
styleConfig,
customIcon,
customIconIndex,
}: IPaginationProps) => {
const theme = useTheme();
const {
carouselDots: dotStyles = [],
selectedDots: selectedDotStyles = [],
dotsContainer: dotsContainerStyles = [],
} = styleConfig || {};
const activeIconColor = theme.color.background.neutral;
const inactiveIconColor = theme.color.text.tertiary;
if (!showDots || slideCount <= 1) {
return null;
}
const dotsToRender = Math.min(slideCount, maxDotsToShow);
return (
{Array.from({ length: dotsToRender }, (_, index) => {
const isActive = currentSlideIndex === index;
if (customIcon && index === customIconIndex) {
const Icon = customIcon;
return (
);
}
if (isActive) {
return (
);
}
return (
);
})}
);
};
export default memo(Pagination);