@connectif/ui-components 5.2.2 → 5.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.2.3] - 2026-02-17
4
+
5
+ ### Added
6
+
7
+ - New prop `alignLeft` for optional alignment of the `Carousel` component.
8
+
3
9
  ## [5.2.2] - 2026-02-11
4
10
 
5
11
  ### Added
@@ -4,6 +4,7 @@ export type CarouselProps<T> = {
4
4
  renderItem: (item: T, index: number) => React.ReactNode;
5
5
  gap?: number;
6
6
  padding?: number;
7
+ alignment?: 'left' | 'center';
7
8
  };
8
- declare function Carousel<T>({ items, renderItem, gap, padding }: CarouselProps<T>): import("react/jsx-runtime").JSX.Element;
9
+ declare function Carousel<T>({ items, renderItem, gap, padding, alignment }: CarouselProps<T>): import("react/jsx-runtime").JSX.Element;
9
10
  export default Carousel;
package/dist/index.js CHANGED
@@ -12107,6 +12107,7 @@ var EnhancedCard = React32.forwardRef(
12107
12107
  const isCenterColumnAlone = !leftIconId && !rightIconId;
12108
12108
  const cardStyle = {
12109
12109
  ...getCardStyles(size),
12110
+ ...borderless && { border: "none" },
12110
12111
  ...disableHover ? {} : hoverCardStyle,
12111
12112
  cursor: cursor2,
12112
12113
  ...selected && {
@@ -26306,7 +26307,8 @@ function Carousel({
26306
26307
  items,
26307
26308
  renderItem,
26308
26309
  gap: gap2 = 8,
26309
- padding: padding2 = 8
26310
+ padding: padding2 = 8,
26311
+ alignment = "left"
26310
26312
  }) {
26311
26313
  const rootRef = React86.useRef(null);
26312
26314
  const containerRef = React86.useRef(null);
@@ -26317,7 +26319,6 @@ function Carousel({
26317
26319
  const [paddingElement, setPaddingElement] = React86.useState();
26318
26320
  const [visibleCount, setVisibleCount] = React86.useState();
26319
26321
  const showedElementsRef = React86.useRef(void 0);
26320
- const [showedElements, setShowedElements] = React86.useState();
26321
26322
  const updateArrows = React86.useCallback(() => {
26322
26323
  if (!showedElementsRef.current) {
26323
26324
  return;
@@ -26343,7 +26344,6 @@ function Carousel({
26343
26344
  (root, container) => {
26344
26345
  root.style.width = "";
26345
26346
  showedElementsRef.current = void 0;
26346
- setShowedElements(void 0);
26347
26347
  container.scrollTo({ left: 0, behavior: "instant" });
26348
26348
  },
26349
26349
  []
@@ -26356,7 +26356,7 @@ function Carousel({
26356
26356
  return;
26357
26357
  }
26358
26358
  const containerWidth = getUsableWidth(root);
26359
- const initialHorizontalPadding = padding2 * 2;
26359
+ const initialHorizontalPadding = alignment === "left" ? 0 : padding2 * 2;
26360
26360
  let count = 0;
26361
26361
  let accumulatedWidth = initialHorizontalPadding;
26362
26362
  let nextChild = children[nextElementsIndex.start];
@@ -26367,15 +26367,15 @@ function Carousel({
26367
26367
  }
26368
26368
  const addGap = nextElementsIndex.start + count < items.length;
26369
26369
  const diffWidth = containerWidth - accumulatedWidth + initialHorizontalPadding + (addGap ? gap2 : 0);
26370
- setPaddingElement(`${diffWidth / 2}px`);
26370
+ const shouldCenter = alignment === "center" && count === items.length;
26371
+ setPaddingElement(`${shouldCenter ? diffWidth / 2 : 0}px`);
26371
26372
  setVisibleCount(count);
26372
26373
  showedElementsRef.current = nextElementsIndex;
26373
- setShowedElements(nextElementsIndex);
26374
26374
  return {
26375
26375
  childrenWidth: accumulatedWidth
26376
26376
  };
26377
26377
  },
26378
- [gap2, getUsableWidth, items.length, padding2]
26378
+ [alignment, gap2, getUsableWidth, items.length, padding2]
26379
26379
  );
26380
26380
  const updateVisibleCount = React86.useCallback(() => {
26381
26381
  const root = rootRef.current;
@@ -26392,7 +26392,7 @@ function Carousel({
26392
26392
  return;
26393
26393
  }
26394
26394
  const containerWidth = getUsableWidth(root);
26395
- const initialHorizontalPadding = padding2 * 2;
26395
+ const initialHorizontalPadding = alignment === "left" ? 0 : padding2 * 2;
26396
26396
  let count = 0;
26397
26397
  let accumulatedWidth = initialHorizontalPadding;
26398
26398
  for (const child of children) {
@@ -26405,12 +26405,12 @@ function Carousel({
26405
26405
  }
26406
26406
  const addGap = count < items.length;
26407
26407
  const diffWidth = containerWidth - accumulatedWidth + initialHorizontalPadding + (addGap ? gap2 : 0);
26408
- const newPaddingSize = `${diffWidth / 2}px`;
26408
+ const shouldCenter = alignment === "center" && count === items.length;
26409
+ const newPaddingSize = `${shouldCenter ? diffWidth / 2 : 0}px`;
26409
26410
  setPaddingElement(newPaddingSize);
26410
26411
  setVisibleCount(count);
26411
26412
  const newVisible = { start: 0, end: count - 1 };
26412
26413
  showedElementsRef.current = newVisible;
26413
- setShowedElements(newVisible);
26414
26414
  if (root) {
26415
26415
  root.style.width = `${containerWidth}px`;
26416
26416
  }
@@ -26420,6 +26420,7 @@ function Carousel({
26420
26420
  padding2,
26421
26421
  items.length,
26422
26422
  gap2,
26423
+ alignment,
26423
26424
  updateArrows,
26424
26425
  resetCarousel
26425
26426
  ]);
@@ -26491,7 +26492,7 @@ function Carousel({
26491
26492
  };
26492
26493
  const scrollHorizontal = ({
26493
26494
  elementsIndex
26494
- }, direction) => {
26495
+ }) => {
26495
26496
  const container = containerRef.current;
26496
26497
  const root = rootRef.current;
26497
26498
  if (!container || !root) {
@@ -26499,17 +26500,13 @@ function Carousel({
26499
26500
  }
26500
26501
  const newMeasures = setMeasures(root, container, elementsIndex);
26501
26502
  if (newMeasures) {
26502
- const scrollLeft = (elementsIndex.end < items.length - 1 ? container.scrollLeft + container.clientWidth : container.scrollWidth - newMeasures.childrenWidth) + padding2 * 2;
26503
- const targetLeft = direction === "right" ? scrollLeft : Math.max(
26504
- container.scrollLeft - newMeasures.childrenWidth,
26505
- 0
26506
- );
26503
+ const targetItem = container.children[elementsIndex.start];
26504
+ const targetLeft = targetItem?.offsetLeft ?? 0;
26507
26505
  waitForSmoothScrollEnd(container, () => {
26508
26506
  isScrolling.current = false;
26509
26507
  updateArrows();
26510
26508
  });
26511
26509
  showedElementsRef.current = elementsIndex;
26512
- setShowedElements(elementsIndex);
26513
26510
  container.scrollTo({ left: targetLeft, behavior: "smooth" });
26514
26511
  }
26515
26512
  };
@@ -26544,7 +26541,7 @@ function Carousel({
26544
26541
  elementsIndex: { start, end }
26545
26542
  };
26546
26543
  }
26547
- scrollHorizontal(scrollData, direction);
26544
+ scrollHorizontal(scrollData);
26548
26545
  };
26549
26546
  return /* @__PURE__ */ jsx151(Box_default2, { ref: rootRef, width: "100%", children: /* @__PURE__ */ jsxs80(
26550
26547
  Box_default2,
@@ -26552,9 +26549,9 @@ function Carousel({
26552
26549
  sx: {
26553
26550
  position: "relative",
26554
26551
  alignSelf: "center",
26555
- padding: `${padding2}px`,
26556
- ...paddingElement && {
26557
- padding: `${padding2}px ${paddingElement}`
26552
+ padding: `${alignment === "left" ? 0 : padding2}px`,
26553
+ ...(paddingElement || alignment === "left") && {
26554
+ padding: `${alignment === "left" ? 0 : padding2}px ${paddingElement || "0px"}`
26558
26555
  }
26559
26556
  },
26560
26557
  children: [
@@ -26576,6 +26573,7 @@ function Carousel({
26576
26573
  {
26577
26574
  ref: containerRef,
26578
26575
  sx: {
26576
+ position: "relative",
26579
26577
  width: "100%",
26580
26578
  overflowX: "hidden",
26581
26579
  display: "flex",
@@ -26588,9 +26586,6 @@ function Carousel({
26588
26586
  Box_default2,
26589
26587
  {
26590
26588
  sx: {
26591
- ...showedElements && (index < showedElements.start || index > showedElements.end) && {
26592
- opacity: 0
26593
- },
26594
26589
  transition: "opacity 0.5s ease"
26595
26590
  },
26596
26591
  children: renderItem(item, index)