@bonprix-ds/react-carousel-v2 1.0.6 → 1.0.7
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.js +1 -2
- package/dist/src/CarouselArrow.js +1 -2
- package/dist/src/CarouselV2.js +1 -2
- package/dist/src/CarouselV2Root.js +1 -2
- package/dist/src/PositionIndicator/PositionIndicator.js +1 -2
- package/dist/src/Slide/Slide.js +1 -2
- package/dist/src/Slides/Slides.js +1 -2
- package/dist/src/carouselContext.js +1 -2
- package/dist/src/throttle.js +3 -8
- package/dist/src/throttle.js.map +1 -1
- package/dist/src/useConsumeCarousel.js +1 -2
- package/dist/src/useCreateCarousel.js +1 -2
- package/dist/src/useSimulateTouch.js +1 -2
- package/dist/src/useStart.js +1 -2
- package/dist/src/utils.js +1 -2
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { e as default };
|
|
1
|
+
export { default } from "./src/CarouselV2.js";
|
|
@@ -5,7 +5,7 @@ import { BaseButton as t } from "@bonprix-ds/internal-components";
|
|
|
5
5
|
import { ArrowLeftIcon as n, ArrowRightIcon as r } from "@bonprix-ds/react-icon/icons";
|
|
6
6
|
import i from "@bonprix-ds/react-theme-forcer";
|
|
7
7
|
import { jsx as a } from "react/jsx-runtime";
|
|
8
|
-
|
|
8
|
+
// src/CarouselArrow.tsx
|
|
9
9
|
var o = e({
|
|
10
10
|
slots: {
|
|
11
11
|
wrapper: "absolute top-1/2 z-[1] -translate-y-1/2 transform",
|
|
@@ -58,7 +58,6 @@ var o = e({
|
|
|
58
58
|
})
|
|
59
59
|
});
|
|
60
60
|
};
|
|
61
|
-
//#endregion
|
|
62
61
|
export { s as default };
|
|
63
62
|
|
|
64
63
|
//# sourceMappingURL=CarouselArrow.js.map
|
package/dist/src/CarouselV2.js
CHANGED
|
@@ -4,10 +4,9 @@ import n from "./Slide/Slide.js";
|
|
|
4
4
|
import r from "./Slides/Slides.js";
|
|
5
5
|
import "react";
|
|
6
6
|
import { jsx as i } from "react/jsx-runtime";
|
|
7
|
-
|
|
7
|
+
// src/CarouselV2.tsx
|
|
8
8
|
var a = (t) => /* @__PURE__ */ i(e, { ...t });
|
|
9
9
|
a.displayName = "CarouselV2", a.Slides = r, a.Slide = n, a.PositionIndicator = t;
|
|
10
|
-
//#endregion
|
|
11
10
|
export { a as default };
|
|
12
11
|
|
|
13
12
|
//# sourceMappingURL=CarouselV2.js.map
|
|
@@ -6,7 +6,7 @@ import i from "./useCreateCarousel.js";
|
|
|
6
6
|
import { useId as a, useImperativeHandle as o, useRef as s, useState as c } from "react";
|
|
7
7
|
import { tv as l } from "tailwind-variants";
|
|
8
8
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
9
|
-
|
|
9
|
+
// src/CarouselV2Root.tsx
|
|
10
10
|
var f = l({
|
|
11
11
|
base: "group relative min-h-8 touch-manipulation",
|
|
12
12
|
slots: {
|
|
@@ -112,7 +112,6 @@ var f = l({
|
|
|
112
112
|
});
|
|
113
113
|
};
|
|
114
114
|
p.displayName = "CarouselV2";
|
|
115
|
-
//#endregion
|
|
116
115
|
export { p as default };
|
|
117
116
|
|
|
118
117
|
//# sourceMappingURL=CarouselV2Root.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import e from "../useConsumeCarousel.js";
|
|
3
3
|
import "react";
|
|
4
4
|
import { jsx as t } from "react/jsx-runtime";
|
|
5
|
-
|
|
5
|
+
// src/PositionIndicator/PositionIndicator.tsx
|
|
6
6
|
var n = ({ ref: n }) => {
|
|
7
7
|
let { activePage: r, pages: i } = e(), a = (e) => r === e ? "bg-clr-primary w-3 h-1" : "bg-clr-on-bg-low w-3 h-0.25", o = [];
|
|
8
8
|
for (let e = 0; e < i; e++) o.push(/* @__PURE__ */ t("div", { className: a(e) }, e));
|
|
@@ -13,7 +13,6 @@ var n = ({ ref: n }) => {
|
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
n.displayName = "CarouselV2.PositionIndicator";
|
|
16
|
-
//#endregion
|
|
17
16
|
export { n as default };
|
|
18
17
|
|
|
19
18
|
//# sourceMappingURL=PositionIndicator.js.map
|
package/dist/src/Slide/Slide.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import e from "../useConsumeCarousel.js";
|
|
3
3
|
import { useEffect as t, useRef as n } from "react";
|
|
4
4
|
import { jsx as r } from "react/jsx-runtime";
|
|
5
|
-
|
|
5
|
+
// src/Slide/Slide.tsx
|
|
6
6
|
var i = ({ children: i, ...a }) => {
|
|
7
7
|
let o = n(null), { slideWidth: s, getIntersectionObserver: c } = e(), l = c();
|
|
8
8
|
return t(() => {
|
|
@@ -20,7 +20,6 @@ var i = ({ children: i, ...a }) => {
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
i.displayName = "CarouselV2.Slide";
|
|
23
|
-
//#endregion
|
|
24
23
|
export { i as default };
|
|
25
24
|
|
|
26
25
|
//# sourceMappingURL=Slide.js.map
|
|
@@ -3,7 +3,7 @@ import e from "../useConsumeCarousel.js";
|
|
|
3
3
|
import { useEffect as t } from "react";
|
|
4
4
|
import { tv as n } from "tailwind-variants";
|
|
5
5
|
import { jsx as r } from "react/jsx-runtime";
|
|
6
|
-
|
|
6
|
+
// src/Slides/Slides.tsx
|
|
7
7
|
var i = n({
|
|
8
8
|
slots: { root: "scrollbar-none m-0 flex snap-x snap-mandatory list-none overflow-y-hidden overflow-x-scroll overscroll-x-none ps-0 outline-2 outline-offset-2 outline-clr-primary focus-visible:outline [&::-webkit-scrollbar]:hidden" },
|
|
9
9
|
variants: { simulateTouch: { true: { root: "select-none" } } }
|
|
@@ -32,7 +32,6 @@ var i = n({
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
a.displayName = "CarouselV2.Slides";
|
|
35
|
-
//#endregion
|
|
36
35
|
export { a as default };
|
|
37
36
|
|
|
38
37
|
//# sourceMappingURL=Slides.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext as e } from "react";
|
|
3
|
-
|
|
3
|
+
// src/carouselContext.ts
|
|
4
4
|
var t = e({
|
|
5
5
|
activePage: 1,
|
|
6
6
|
activeSlide: 1,
|
|
@@ -14,7 +14,6 @@ var t = e({
|
|
|
14
14
|
getIntersectionObserver: () => null,
|
|
15
15
|
simulateTouch: !1
|
|
16
16
|
});
|
|
17
|
-
//#endregion
|
|
18
17
|
export { t as default };
|
|
19
18
|
|
|
20
19
|
//# sourceMappingURL=carouselContext.js.map
|
package/dist/src/throttle.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
// src/throttle.ts
|
|
2
2
|
var e = (e, t) => {
|
|
3
3
|
let n = 0, r, i, a = (t) => {
|
|
4
4
|
n = Date.now(), e(...t);
|
|
5
5
|
};
|
|
6
6
|
return (...e) => {
|
|
7
7
|
let o = t - (Date.now() - n);
|
|
8
|
-
|
|
9
|
-
a(e);
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
r = e, i ??= setTimeout(() => {
|
|
8
|
+
o <= 0 && i === void 0 ? a(e) : (r = e, i ??= setTimeout(() => {
|
|
13
9
|
i = void 0, r && a(r);
|
|
14
|
-
}, o);
|
|
10
|
+
}, o));
|
|
15
11
|
};
|
|
16
12
|
};
|
|
17
|
-
//#endregion
|
|
18
13
|
export { e as throttle };
|
|
19
14
|
|
|
20
15
|
//# sourceMappingURL=throttle.js.map
|
package/dist/src/throttle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throttle.js","names":["throttle","lastTime","trailingArgs","trailingTimeout","call","func","args","remaining","timeFrame"],"sources":["../../src/throttle.ts"],"sourcesContent":["// You-Dont-Need-Lodash-Underscore's `throttle`, plus the trailing call lodash makes with `trailing: true`. Without it,\n// the scroll events at the end of a swipe are dropped, and the carousel keeps a stale position and active slide.\nexport const throttle = <Args extends unknown[]>(func: (...args: Args) => void, timeFrame: number) => {\n let lastTime = 0;\n let trailingArgs: Args | undefined;\n let trailingTimeout: ReturnType<typeof setTimeout> | undefined;\n\n const call = (args: Args) => {\n lastTime = Date.now();\n func(...args);\n };\n\n return (...args: Args) => {\n const remaining = timeFrame - (Date.now() - lastTime);\n if (remaining <= 0 && trailingTimeout === undefined) {\n call(args);\n return;\n }\n\n trailingArgs = args;\n trailingTimeout ??= setTimeout(() => {\n trailingTimeout = undefined;\n if (trailingArgs) call(trailingArgs);\n }, remaining);\n };\n};\n"],"mappings":";AAEA,IAAaA,KAAoC,GAA+B,MAAsB;CACpG,IAAIC,IAAW,GACXC,GACAC,GAEEC,KAAQ,MAAe;EAE3B,AADA,IAAW,KAAK,IAAI,GACpBC,EAAK,GAAGC,CAAI;CACd;CAEA,QAAQ,GAAGA,MAAe;EACxB,IAAMC,IAAYC,KAAa,KAAK,IAAI,IAAIP;EAC5C,
|
|
1
|
+
{"version":3,"file":"throttle.js","names":["throttle","lastTime","trailingArgs","trailingTimeout","call","func","args","remaining","timeFrame"],"sources":["../../src/throttle.ts"],"sourcesContent":["// You-Dont-Need-Lodash-Underscore's `throttle`, plus the trailing call lodash makes with `trailing: true`. Without it,\n// the scroll events at the end of a swipe are dropped, and the carousel keeps a stale position and active slide.\nexport const throttle = <Args extends unknown[]>(func: (...args: Args) => void, timeFrame: number) => {\n let lastTime = 0;\n let trailingArgs: Args | undefined;\n let trailingTimeout: ReturnType<typeof setTimeout> | undefined;\n\n const call = (args: Args) => {\n lastTime = Date.now();\n func(...args);\n };\n\n return (...args: Args) => {\n const remaining = timeFrame - (Date.now() - lastTime);\n if (remaining <= 0 && trailingTimeout === undefined) {\n call(args);\n return;\n }\n\n trailingArgs = args;\n trailingTimeout ??= setTimeout(() => {\n trailingTimeout = undefined;\n if (trailingArgs) call(trailingArgs);\n }, remaining);\n };\n};\n"],"mappings":";AAEA,IAAaA,KAAoC,GAA+B,MAAsB;CACpG,IAAIC,IAAW,GACXC,GACAC,GAEEC,KAAQ,MAAe;EAE3B,AADA,IAAW,KAAK,IAAI,GACpBC,EAAK,GAAGC,CAAI;CACd;CAEA,QAAQ,GAAGA,MAAe;EACxB,IAAMC,IAAYC,KAAa,KAAK,IAAI,IAAIP;EAC5C,AAAIM,KAAa,KAAKJ,MAAoB,KAAA,IACxCC,EAAKE,CAAI,KAIX,IAAeA,GACf,MAAoB,iBAAiB;GAEnC,AADA,IAAkB,KAAA,GACdJ,KAAcE,EAAKF,CAAY;EACrC,GAAGK,CAAS;CACd;AACF"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import e from "./carouselContext.js";
|
|
2
2
|
import { useContext as t } from "react";
|
|
3
|
-
|
|
3
|
+
// src/useConsumeCarousel.ts
|
|
4
4
|
var n = () => t(e);
|
|
5
|
-
//#endregion
|
|
6
5
|
export { n as default };
|
|
7
6
|
|
|
8
7
|
//# sourceMappingURL=useConsumeCarousel.js.map
|
|
@@ -3,7 +3,7 @@ import t from "./useSimulateTouch.js";
|
|
|
3
3
|
import n from "./useStart.js";
|
|
4
4
|
import { getActivePage as r, getActiveSlide as i, getBreakpoint as a, getCanScrollNext as o, getCanScrollPrev as s, getCurrentPerMove as c, getCurrentPerPage as ee, getPages as te, getScrollDistanceNext as l, getScrollDistancePrev as u, getSlideWidthStyle as d, roughlyEqual as f } from "./utils.js";
|
|
5
5
|
import { useCallback as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
|
|
6
|
-
|
|
6
|
+
// src/useCreateCarousel.ts
|
|
7
7
|
var v = ({ perPage: v = 1, perMove: ne = v, rewind: y = !1, padding: b = 0, gap: x = 0, children: S, simulateTouch: C = !1, start: w }) => {
|
|
8
8
|
let T = g(null), re = typeof document < "u" ? document.documentElement.clientWidth : 0, [ie, ae] = _(re), [E, oe] = _(0), [D, se] = _(0), [O, k] = _(0), [A, j] = _(!1), [M, N] = _(!0), [P, F] = _(!1), [I, L] = _(null), [R, z] = _(0), B = () => {
|
|
9
9
|
F(!1), L(null);
|
|
@@ -155,7 +155,6 @@ var v = ({ perPage: v = 1, perMove: ne = v, rewind: y = !1, padding: b = 0, gap:
|
|
|
155
155
|
currentPerPage: G
|
|
156
156
|
};
|
|
157
157
|
};
|
|
158
|
-
//#endregion
|
|
159
158
|
export { v as default };
|
|
160
159
|
|
|
161
160
|
//# sourceMappingURL=useCreateCarousel.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect as e } from "react";
|
|
2
|
-
|
|
2
|
+
// src/useSimulateTouch.ts
|
|
3
3
|
var t = ({ simulateTouch: t, listRef: n }) => {
|
|
4
4
|
e(() => {
|
|
5
5
|
if (!t) return;
|
|
@@ -24,7 +24,6 @@ var t = ({ simulateTouch: t, listRef: n }) => {
|
|
|
24
24
|
};
|
|
25
25
|
}, [n, t]);
|
|
26
26
|
};
|
|
27
|
-
//#endregion
|
|
28
27
|
export { t as default };
|
|
29
28
|
|
|
30
29
|
//# sourceMappingURL=useSimulateTouch.js.map
|
package/dist/src/useStart.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect as e } from "react";
|
|
2
|
-
|
|
2
|
+
// src/useStart.ts
|
|
3
3
|
var t = ({ slidesCount: t, start: n, listRef: r }) => {
|
|
4
4
|
e(() => {
|
|
5
5
|
!r.current || !n || n < 1 || n > t || r.current.querySelector(`[data-index='${n}']`)?.scrollIntoView({
|
|
@@ -12,7 +12,6 @@ var t = ({ slidesCount: t, start: n, listRef: r }) => {
|
|
|
12
12
|
r
|
|
13
13
|
]);
|
|
14
14
|
};
|
|
15
|
-
//#endregion
|
|
16
15
|
export { t as default };
|
|
17
16
|
|
|
18
17
|
//# sourceMappingURL=useStart.js.map
|
package/dist/src/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { breakpoints as e } from "@bonprix-ds/utils";
|
|
2
|
-
|
|
2
|
+
// src/utils.ts
|
|
3
3
|
var t = (e, t, n = 10) => Math.abs(e - t) <= n, n = ({ slidesCount: e, currentPerPage: t }) => Math.ceil(e / t), r = ({ perPage: e, padding: t, gap: n }) => {
|
|
4
4
|
let r = i(e), s = a(t, e);
|
|
5
5
|
return `calc(${r} - ${o(n, e, t)} - ${s})`;
|
|
@@ -35,7 +35,6 @@ var t = (e, t, n = 10) => Math.abs(e - t) <= n, n = ({ slidesCount: e, currentPe
|
|
|
35
35
|
let { perMove: t, breakpoint: n } = e;
|
|
36
36
|
return typeof t == "number" ? t : t[n] ?? 1;
|
|
37
37
|
}, y = ({ pageNumber: e, perPage: t }) => e * t;
|
|
38
|
-
//#endregion
|
|
39
38
|
export { p as getActivePage, f as getActiveSlide, d as getBreakpoint, c as getCanScrollNext, s as getCanScrollPrev, g as getClosestSlideIndex, v as getCurrentPerMove, _ as getCurrentPerPage, y as getFirstSlideIndexOnPage, n as getPages, u as getScrollDistanceNext, l as getScrollDistancePrev, r as getSlideWidthStyle, m as rightEdgeReached, t as roughlyEqual };
|
|
40
39
|
|
|
41
40
|
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bonprix-ds/react-carousel-v2",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "CarouselV2 component, implemented in React, for the Bonprix Design System.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -32,18 +32,18 @@
|
|
|
32
32
|
"provenance": true
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@bonprix-ds/internal-components": "0.2.
|
|
36
|
-
"@bonprix-ds/react-icon": "1.3.
|
|
35
|
+
"@bonprix-ds/internal-components": "0.2.6",
|
|
36
|
+
"@bonprix-ds/react-icon": "1.3.3",
|
|
37
37
|
"@bonprix-ds/react-theme-forcer": "1.0.1",
|
|
38
|
-
"@bonprix-ds/utils": "0.
|
|
38
|
+
"@bonprix-ds/utils": "0.6.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
+
"@bonprix-ds/vite-config": "0.0.0",
|
|
41
42
|
"@testing-library/dom": "10.4.2",
|
|
42
43
|
"@testing-library/react": "16.3.3",
|
|
43
44
|
"@types/react": "19.3.0",
|
|
44
|
-
"vite": "8.3.
|
|
45
|
-
"vitest": "5.0.5"
|
|
46
|
-
"@bonprix-ds/vite-config": "0.0.0"
|
|
45
|
+
"vite": "8.3.5",
|
|
46
|
+
"vitest": "5.0.5"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"react": "^19",
|