@cfx-dev/ui-components 5.0.31 → 5.0.32
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.
|
@@ -10,6 +10,7 @@ export interface CarouselProps {
|
|
|
10
10
|
showControlsTop?: boolean;
|
|
11
11
|
skipFirstItem?: boolean;
|
|
12
12
|
controlsClassName?: string;
|
|
13
|
+
controlsRootClassName?: string;
|
|
13
14
|
text?: string;
|
|
14
15
|
showDots?: boolean;
|
|
15
16
|
trackClassName?: string;
|
|
@@ -19,6 +20,6 @@ export interface CarouselProps {
|
|
|
19
20
|
currentPage?: number;
|
|
20
21
|
onPageChange?: (page: number) => void;
|
|
21
22
|
}
|
|
22
|
-
declare function Carousel({ items, ImageComponent, visibleItems, onItemClick, showControlsBottom, showControlsTop, skipFirstItem, controlsClassName, text, showDots, trackClassName, className, rootClassName, headerClassName, currentPage: controlledCurrentPage, onPageChange, }: CarouselProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
declare function Carousel({ items, ImageComponent, visibleItems, onItemClick, showControlsBottom, showControlsTop, skipFirstItem, controlsClassName, controlsRootClassName, text, showDots, trackClassName, className, rootClassName, headerClassName, currentPage: controlledCurrentPage, onPageChange, }: CarouselProps): import("react/jsx-runtime").JSX.Element;
|
|
23
24
|
declare const _default: React.MemoExoticComponent<typeof Carousel>;
|
|
24
25
|
export default _default;
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { Dot as
|
|
1
|
+
import { jsxs as N, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import H, { useMemo as J, useState as K, useCallback as Q, useEffect as L } from "react";
|
|
3
|
+
import { Dot as O } from "../Dot/Dot.js";
|
|
4
4
|
import u from "../Flex/Flex.js";
|
|
5
|
-
import { clsx as
|
|
5
|
+
import { clsx as h } from "../../utils/clsx.js";
|
|
6
6
|
import "../../utils/contexts/MediaQueryContext/MediaQueryContext.js";
|
|
7
7
|
import "../../utils/contexts/MediaQueryContext/MediaQueryContextProvider.js";
|
|
8
|
-
import
|
|
9
|
-
import { useCarousel as
|
|
10
|
-
import { s as i, C as
|
|
11
|
-
import
|
|
12
|
-
function
|
|
8
|
+
import U from "../../utils/contexts/MediaQueryContext/useMediaQuery.js";
|
|
9
|
+
import { useCarousel as W } from "../../utils/hooks/useCarousel.js";
|
|
10
|
+
import { s as i, C as X } from "../../CarouselControls-CJ3tupLr.js";
|
|
11
|
+
import Y from "./CarouselItem.js";
|
|
12
|
+
function R({
|
|
13
13
|
showDots: n = !1,
|
|
14
14
|
pageCount: a,
|
|
15
15
|
currentPage: t,
|
|
16
16
|
onPageChange: o,
|
|
17
|
-
controlsClassName: m
|
|
17
|
+
controlsClassName: m,
|
|
18
|
+
controlsRootClassName: d
|
|
18
19
|
}) {
|
|
19
|
-
return a <= 1 ? null : /* @__PURE__ */
|
|
20
|
-
n && /* @__PURE__ */ s(u, { centered: !0, gap: 1, children: Array.from({ length: a }).map((
|
|
21
|
-
|
|
20
|
+
return a <= 1 ? null : /* @__PURE__ */ N(u, { gap: 2, centered: !0, className: h(i.controls, d), children: [
|
|
21
|
+
n && /* @__PURE__ */ s(u, { centered: !0, gap: 1, children: Array.from({ length: a }).map((p, c) => /* @__PURE__ */ s(
|
|
22
|
+
O,
|
|
22
23
|
{
|
|
23
24
|
className: i.dots,
|
|
24
25
|
color: c === t ? "primary" : "secondary",
|
|
@@ -27,7 +28,7 @@ function F({
|
|
|
27
28
|
c
|
|
28
29
|
)) }),
|
|
29
30
|
/* @__PURE__ */ s(
|
|
30
|
-
|
|
31
|
+
X,
|
|
31
32
|
{
|
|
32
33
|
currentPage: t,
|
|
33
34
|
pageCount: a,
|
|
@@ -37,89 +38,92 @@ function F({
|
|
|
37
38
|
)
|
|
38
39
|
] });
|
|
39
40
|
}
|
|
40
|
-
function
|
|
41
|
+
function Z({
|
|
41
42
|
items: n,
|
|
42
43
|
ImageComponent: a,
|
|
43
44
|
visibleItems: t = 4,
|
|
44
45
|
onItemClick: o,
|
|
45
46
|
showControlsBottom: m = !1,
|
|
46
|
-
showControlsTop:
|
|
47
|
-
skipFirstItem:
|
|
48
|
-
controlsClassName:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
showControlsTop: d = !1,
|
|
48
|
+
skipFirstItem: p = !1,
|
|
49
|
+
controlsClassName: c,
|
|
50
|
+
controlsRootClassName: S,
|
|
51
|
+
text: x,
|
|
52
|
+
showDots: M = !1,
|
|
53
|
+
trackClassName: V,
|
|
54
|
+
className: $,
|
|
55
|
+
rootClassName: q,
|
|
56
|
+
headerClassName: w,
|
|
57
|
+
currentPage: y,
|
|
56
58
|
onPageChange: l
|
|
57
59
|
}) {
|
|
58
60
|
const {
|
|
59
|
-
isMobile:
|
|
60
|
-
isTablet:
|
|
61
|
-
} =
|
|
62
|
-
carouselRef:
|
|
61
|
+
isMobile: T,
|
|
62
|
+
isTablet: j
|
|
63
|
+
} = U(), _ = J(() => typeof t == "number" ? t : T ? t.mobile : j ? t.tablet : t.desktop, [t, T, j]), z = p ? n.slice(1) : n, b = Math.ceil(z.length / _), {
|
|
64
|
+
carouselRef: A,
|
|
63
65
|
carouselApi: e
|
|
64
|
-
} =
|
|
65
|
-
slidesToScroll:
|
|
66
|
-
}), [
|
|
66
|
+
} = W({
|
|
67
|
+
slidesToScroll: _
|
|
68
|
+
}), [D, B] = K(0), E = y ?? D, F = Q(
|
|
67
69
|
(r) => {
|
|
68
|
-
e == null || e.scrollTo(r), l == null || l(r),
|
|
70
|
+
e == null || e.scrollTo(r), l == null || l(r), y == null && B(r);
|
|
69
71
|
},
|
|
70
|
-
[e, l,
|
|
71
|
-
),
|
|
72
|
+
[e, l, y]
|
|
73
|
+
), G = Q(
|
|
72
74
|
(r) => {
|
|
73
75
|
o == null || o(r);
|
|
74
76
|
},
|
|
75
77
|
[o]
|
|
76
78
|
);
|
|
77
|
-
return
|
|
79
|
+
return L(() => {
|
|
78
80
|
if (!e)
|
|
79
81
|
return;
|
|
80
82
|
const r = () => {
|
|
81
83
|
const f = e.selectedScrollSnap();
|
|
82
|
-
|
|
84
|
+
B(f), l == null || l(f);
|
|
83
85
|
};
|
|
84
86
|
return e.on("select", r), e.on("reInit", r), () => {
|
|
85
87
|
e.off("select", r), e.off("reInit", r);
|
|
86
88
|
};
|
|
87
|
-
}, [e, l]), /* @__PURE__ */
|
|
88
|
-
|
|
89
|
-
/* @__PURE__ */ s("span", { children:
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
}, [e, l]), /* @__PURE__ */ N("div", { className: q, children: [
|
|
90
|
+
x && /* @__PURE__ */ N(u, { spaceBetween: !0, alignItems: "center", className: w, children: [
|
|
91
|
+
/* @__PURE__ */ s("span", { children: x }),
|
|
92
|
+
d && /* @__PURE__ */ s(
|
|
93
|
+
R,
|
|
92
94
|
{
|
|
93
|
-
showDots:
|
|
94
|
-
pageCount:
|
|
95
|
-
currentPage:
|
|
96
|
-
onPageChange:
|
|
97
|
-
controlsClassName:
|
|
95
|
+
showDots: M,
|
|
96
|
+
pageCount: b,
|
|
97
|
+
currentPage: E,
|
|
98
|
+
onPageChange: F,
|
|
99
|
+
controlsClassName: c,
|
|
100
|
+
controlsRootClassName: S
|
|
98
101
|
}
|
|
99
102
|
)
|
|
100
103
|
] }),
|
|
101
|
-
/* @__PURE__ */ s("div", { className:
|
|
102
|
-
|
|
104
|
+
/* @__PURE__ */ s("div", { className: h(i.carousel, $), ref: A, children: /* @__PURE__ */ s(u, { className: h(i.carouselTrack, V), gap: 1, children: n.map((r, f) => f === 0 && p ? null : /* @__PURE__ */ s("div", { className: i.carouselItem, children: /* @__PURE__ */ s(
|
|
105
|
+
Y,
|
|
103
106
|
{
|
|
104
107
|
index: f,
|
|
105
108
|
item: r,
|
|
106
|
-
onClick:
|
|
109
|
+
onClick: G,
|
|
107
110
|
ImageComponent: a
|
|
108
111
|
}
|
|
109
112
|
) }, r.id)) }) }),
|
|
110
113
|
m && /* @__PURE__ */ s(u, { justifyContent: "flex-end", children: /* @__PURE__ */ s(
|
|
111
|
-
|
|
114
|
+
R,
|
|
112
115
|
{
|
|
113
|
-
showDots:
|
|
114
|
-
pageCount:
|
|
115
|
-
currentPage:
|
|
116
|
-
onPageChange:
|
|
117
|
-
controlsClassName:
|
|
116
|
+
showDots: M,
|
|
117
|
+
pageCount: b,
|
|
118
|
+
currentPage: E,
|
|
119
|
+
onPageChange: F,
|
|
120
|
+
controlsClassName: c,
|
|
121
|
+
controlsRootClassName: S
|
|
118
122
|
}
|
|
119
123
|
) })
|
|
120
124
|
] });
|
|
121
125
|
}
|
|
122
|
-
const
|
|
126
|
+
const or = H.memo(Z);
|
|
123
127
|
export {
|
|
124
|
-
|
|
128
|
+
or as default
|
|
125
129
|
};
|