@geomak/ui 6.19.0 → 6.20.0

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/dist/index.cjs CHANGED
@@ -1862,10 +1862,9 @@ function RotatingCarousel({
1862
1862
  const count = slides.length;
1863
1863
  const [active, setActive] = React24.useState(0);
1864
1864
  const reduced = framerMotion.useReducedMotion();
1865
- const idx = Math.min(Math.max(active, 0), Math.max(0, count - 1));
1866
- const atStart = idx <= 0;
1867
- const atEnd = idx >= count - 1;
1868
- const step = (dir) => setActive((a) => Math.min(Math.max(a + dir, 0), count - 1));
1865
+ const wrap = (n) => count > 0 ? (n % count + count) % count : 0;
1866
+ const idx = wrap(active);
1867
+ const step = (dir) => setActive((a) => wrap(a + dir));
1869
1868
  const w = typeof itemWidth === "number" ? itemWidth : parseInt(String(itemWidth), 10) || 320;
1870
1869
  const widthCss = typeof itemWidth === "number" ? `${itemWidth}px` : itemWidth;
1871
1870
  const SPACING = w * 0.6;
@@ -1890,11 +1889,12 @@ function RotatingCarousel({
1890
1889
  style,
1891
1890
  onKeyDown,
1892
1891
  children: [
1893
- showArrows && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", "aria-label": "Previous", onClick: () => step(-1), disabled: atStart, className: `${arrowBtn} left-1`, children: /* @__PURE__ */ jsxRuntime.jsx(Arrow2, { dir: "left" }) }),
1892
+ showArrows && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", "aria-label": "Previous", onClick: () => step(-1), className: `${arrowBtn} left-1`, children: /* @__PURE__ */ jsxRuntime.jsx(Arrow2, { dir: "left" }) }),
1894
1893
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative mx-auto overflow-hidden py-6", children: [
1895
1894
  count > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "invisible mx-auto", style: { width: widthCss }, "aria-hidden": "true", children: slides[idx] }),
1896
1895
  slides.map((slide, i) => {
1897
- const offset = i - idx;
1896
+ let offset = wrap(i - idx);
1897
+ if (offset > count / 2) offset -= count;
1898
1898
  const abs = Math.abs(offset);
1899
1899
  if (abs > 2) return null;
1900
1900
  const isCenter = offset === 0;
@@ -1925,7 +1925,7 @@ function RotatingCarousel({
1925
1925
  );
1926
1926
  })
1927
1927
  ] }),
1928
- showArrows && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", "aria-label": "Next", onClick: () => step(1), disabled: atEnd, className: `${arrowBtn} right-1`, children: /* @__PURE__ */ jsxRuntime.jsx(Arrow2, { dir: "right" }) }),
1928
+ showArrows && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", "aria-label": "Next", onClick: () => step(1), className: `${arrowBtn} right-1`, children: /* @__PURE__ */ jsxRuntime.jsx(Arrow2, { dir: "right" }) }),
1929
1929
  showDots && count > 1 && /* @__PURE__ */ jsxRuntime.jsx(Dots, { count, active: idx, onSelect: setActive })
1930
1930
  ]
1931
1931
  }