@c-rex/components 0.3.0-build.26 → 0.3.0-build.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-rex/components",
3
- "version": "0.3.0-build.26",
3
+ "version": "0.3.0-build.28",
4
4
  "files": [
5
5
  "src"
6
6
  ],
@@ -324,16 +324,25 @@ const CarouselIndicators: FC<{ className?: string }> = ({ className }) => {
324
324
  if (!setPage) {
325
325
  const totalOfIndicators = Math.max(slidesLength - slidesToShow + 1, 1);
326
326
  if (totalOfIndicators === 1) return null;
327
- if (totalOfIndicators > 8) {
328
- return (
329
- <div className={cn("mt-3 flex items-center gap-2 text-sm text-muted-foreground", className)}>
330
- <span className="rounded-full border px-3 py-1">{current + 1} / {totalOfIndicators}</span>
331
- </div>
332
- );
327
+ const maxVisibleIndicators = 7;
328
+ const visibleIndicators = Math.min(totalOfIndicators, maxVisibleIndicators);
329
+ const halfWindow = Math.floor(visibleIndicators / 2);
330
+ let startIndicator = Math.max(0, current - halfWindow);
331
+ let endIndicator = startIndicator + visibleIndicators - 1;
332
+
333
+ if (endIndicator >= totalOfIndicators) {
334
+ endIndicator = totalOfIndicators - 1;
335
+ startIndicator = Math.max(0, endIndicator - visibleIndicators + 1);
333
336
  }
337
+
338
+ const indicatorsToRender = Array.from(
339
+ { length: endIndicator - startIndicator + 1 },
340
+ (_, index) => startIndicator + index
341
+ );
342
+
334
343
  return (
335
- <ol className={cn("flex gap-2 z-20 list-none p-0 m-0", className)}>
336
- {Array.from({ length: totalOfIndicators }).map((_, index) => (
344
+ <ol className={cn("mt-3 flex gap-2 z-20 list-none p-0 m-0", className)}>
345
+ {indicatorsToRender.map((index) => (
337
346
  <li key={`indicator-${index}`}>
338
347
  <Button
339
348
  className={`w-3 h-3 rounded-full border-0 cursor-pointer transition-colors ${index === current ? "bg-gray-800" : "bg-gray-300"}`}