quirk-ui 0.0.50 → 0.0.51
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as t, jsx as s } from "react/jsx-runtime";
|
|
2
|
-
import { d as
|
|
2
|
+
import { d as i, a, i as o, r as n, g as l, s as c } from "../../vi.ClIskdbk-CZ8iFAMK.js";
|
|
3
3
|
import { Carousel as d } from "./index.js";
|
|
4
4
|
import "../../index-BBIdMcpm.js";
|
|
5
|
-
|
|
5
|
+
i("Carousel", () => {
|
|
6
6
|
const r = Array.from({ length: 6 }, (m, e) => /* @__PURE__ */ t("div", { "data-testid": "carousel-item", children: [
|
|
7
7
|
"Item ",
|
|
8
8
|
e + 1
|
|
@@ -12,7 +12,7 @@ a("Carousel", () => {
|
|
|
12
12
|
writable: !0,
|
|
13
13
|
configurable: !0,
|
|
14
14
|
value: 1024
|
|
15
|
-
}),
|
|
15
|
+
}), a(() => {
|
|
16
16
|
window.dispatchEvent(new Event("resize"));
|
|
17
17
|
}), global.ResizeObserver = class {
|
|
18
18
|
observe() {
|
|
@@ -23,6 +23,8 @@ a("Carousel", () => {
|
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
}), o("renders without crashing", () => {
|
|
26
|
-
n(
|
|
26
|
+
n(
|
|
27
|
+
/* @__PURE__ */ s(d, { isSplit: !0, items: r, itemsPerPage: 3, itemsPerRow: 1 })
|
|
28
|
+
), l(c.getAllByTestId("carousel-item").length).toBeGreaterThan(0);
|
|
27
29
|
});
|
|
28
30
|
});
|
|
@@ -1,129 +1,135 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { A as
|
|
4
|
-
import { A as
|
|
5
|
-
import '../../assets/index31.css';const
|
|
6
|
-
carousel:
|
|
7
|
-
trackContainer:
|
|
8
|
-
track:
|
|
9
|
-
page:
|
|
10
|
-
controls:
|
|
11
|
-
indicators:
|
|
12
|
-
indicator:
|
|
1
|
+
import { jsxs as w, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { useState as m, useRef as W, useEffect as x } from "react";
|
|
3
|
+
import { A as O } from "../../arrow-left-BIJvHwNQ.js";
|
|
4
|
+
import { A as q } from "../../arrow-right-QEwnX3Sk.js";
|
|
5
|
+
import '../../assets/index31.css';const B = "_carousel_pk3a7_1", F = "_trackContainer_pk3a7_9", H = "_track_pk3a7_9", J = "_page_pk3a7_24", K = "_controls_pk3a7_30", Q = "_indicators_pk3a7_47", R = "_indicator_pk3a7_47", S = "_active_pk3a7_64", U = "_buttons_pk3a7_68", V = "_prev_pk3a7_73", Y = "_disabled_pk3a7_73", Z = "_next_pk3a7_74", n = {
|
|
6
|
+
carousel: B,
|
|
7
|
+
trackContainer: F,
|
|
8
|
+
track: H,
|
|
9
|
+
page: J,
|
|
10
|
+
controls: K,
|
|
11
|
+
indicators: Q,
|
|
12
|
+
indicator: R,
|
|
13
13
|
active: S,
|
|
14
|
-
buttons:
|
|
15
|
-
prev:
|
|
16
|
-
disabled:
|
|
17
|
-
next:
|
|
14
|
+
buttons: U,
|
|
15
|
+
prev: V,
|
|
16
|
+
disabled: Y,
|
|
17
|
+
next: Z
|
|
18
18
|
};
|
|
19
|
-
function
|
|
20
|
-
items:
|
|
21
|
-
itemsPerPage:
|
|
22
|
-
itemsPerRow:
|
|
23
|
-
autoPlay:
|
|
24
|
-
autoPlayInterval:
|
|
25
|
-
className:
|
|
19
|
+
function rt({
|
|
20
|
+
items: $,
|
|
21
|
+
itemsPerPage: v = 3,
|
|
22
|
+
itemsPerRow: z = 3,
|
|
23
|
+
autoPlay: c = !1,
|
|
24
|
+
autoPlayInterval: N = 3e3,
|
|
25
|
+
className: A,
|
|
26
|
+
externalRef: y,
|
|
27
|
+
siblingRef: o,
|
|
28
|
+
isSplit: b = !1
|
|
26
29
|
}) {
|
|
27
|
-
const [
|
|
28
|
-
const
|
|
29
|
-
for (let
|
|
30
|
-
|
|
31
|
-
return
|
|
30
|
+
const [i, p] = m(0), [l, C] = m(0), [h, T] = m(v), [g, E] = m(!0), I = W(null), k = W(null), u = b && g ? y : I, L = (t, e) => {
|
|
31
|
+
const a = [];
|
|
32
|
+
for (let r = 0; r < t.length; r += e)
|
|
33
|
+
a.push(t.slice(r, r + e));
|
|
34
|
+
return a;
|
|
32
35
|
};
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
36
|
+
x(() => {
|
|
37
|
+
const t = () => {
|
|
38
|
+
const e = window.innerWidth < 768;
|
|
39
|
+
E(e), T(e ? 1 : v);
|
|
37
40
|
};
|
|
38
|
-
return
|
|
39
|
-
}, [
|
|
40
|
-
const _ = Math.ceil(
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
return t(), window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
|
|
42
|
+
}, [v]);
|
|
43
|
+
const _ = Math.ceil(h / z), M = L($, h), d = M.length, j = 3 * 16;
|
|
44
|
+
x(() => {
|
|
45
|
+
const t = new ResizeObserver((e) => {
|
|
46
|
+
var a;
|
|
47
|
+
for (let r of e)
|
|
48
|
+
r.contentRect && (b && g ? o != null && o.current && C(
|
|
49
|
+
r.contentRect.width - ((a = o == null ? void 0 : o.current) == null ? void 0 : a.offsetWidth) - j
|
|
50
|
+
) : C(r.contentRect.width), p(0));
|
|
45
51
|
});
|
|
46
|
-
return u.current &&
|
|
52
|
+
return u != null && u.current && t.observe(u.current), () => t.disconnect();
|
|
47
53
|
}, []);
|
|
48
54
|
const f = () => {
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
}), [
|
|
58
|
-
/* @__PURE__ */
|
|
55
|
+
p((t) => Math.min(t + 1, d - 1));
|
|
56
|
+
}, X = () => {
|
|
57
|
+
p((t) => Math.max(t - 1, 0));
|
|
58
|
+
}, D = (t) => {
|
|
59
|
+
p(t);
|
|
60
|
+
}, G = () => l ? `translateX(-${i * l}px)` : "translateX(0px)";
|
|
61
|
+
return x(() => (c && (k.current = setInterval(f, N)), () => {
|
|
62
|
+
k.current && clearInterval(k.current);
|
|
63
|
+
}), [c, N, f]), /* @__PURE__ */ w("div", { className: `${A ?? ""} ${n.carousel}`, ref: I, children: [
|
|
64
|
+
/* @__PURE__ */ s(
|
|
59
65
|
"div",
|
|
60
66
|
{
|
|
61
|
-
className:
|
|
62
|
-
style: { maxWidth: `${
|
|
63
|
-
children: /* @__PURE__ */
|
|
67
|
+
className: n.trackContainer,
|
|
68
|
+
style: { maxWidth: `${l}px` },
|
|
69
|
+
children: /* @__PURE__ */ s(
|
|
64
70
|
"div",
|
|
65
71
|
{
|
|
66
|
-
className:
|
|
67
|
-
style: { width: `${
|
|
68
|
-
children:
|
|
72
|
+
className: n.track,
|
|
73
|
+
style: { width: `${d * 100}%`, transform: G() },
|
|
74
|
+
children: M.map((t, e) => /* @__PURE__ */ s(
|
|
69
75
|
"div",
|
|
70
76
|
{
|
|
71
|
-
className:
|
|
77
|
+
className: n.page,
|
|
72
78
|
style: {
|
|
73
79
|
display: _ > 1 ? "grid" : "flex",
|
|
74
80
|
gridTemplateColumns: `repeat(${Math.ceil(
|
|
75
|
-
|
|
81
|
+
h / _
|
|
76
82
|
)}, 1fr)`,
|
|
77
83
|
gridTemplateRows: `repeat(${_}, auto)`,
|
|
78
|
-
width: `${
|
|
84
|
+
width: `${l}px`
|
|
79
85
|
},
|
|
80
|
-
children:
|
|
86
|
+
children: t.map((a, r) => /* @__PURE__ */ s(
|
|
81
87
|
"div",
|
|
82
88
|
{
|
|
83
|
-
className:
|
|
89
|
+
className: n.slide,
|
|
84
90
|
style: {
|
|
85
|
-
width: `${
|
|
91
|
+
width: `${l / _ - 16}px`
|
|
86
92
|
},
|
|
87
|
-
children:
|
|
93
|
+
children: a
|
|
88
94
|
},
|
|
89
|
-
|
|
95
|
+
r
|
|
90
96
|
))
|
|
91
97
|
},
|
|
92
|
-
|
|
98
|
+
e
|
|
93
99
|
))
|
|
94
100
|
}
|
|
95
101
|
)
|
|
96
102
|
}
|
|
97
103
|
),
|
|
98
|
-
|
|
99
|
-
/* @__PURE__ */
|
|
104
|
+
d > 1 && /* @__PURE__ */ w("div", { className: n.controls, children: [
|
|
105
|
+
/* @__PURE__ */ s("div", { className: n.indicators, children: Array.from({ length: d }).map((t, e) => /* @__PURE__ */ s(
|
|
100
106
|
"button",
|
|
101
107
|
{
|
|
102
|
-
className: `${
|
|
103
|
-
onClick: () =>
|
|
104
|
-
"aria-label": `Go to group ${
|
|
108
|
+
className: `${n.indicator} ${e === i ? n.active : ""}`,
|
|
109
|
+
onClick: () => D(e),
|
|
110
|
+
"aria-label": `Go to group ${e + 1}`
|
|
105
111
|
},
|
|
106
|
-
|
|
112
|
+
e
|
|
107
113
|
)) }),
|
|
108
|
-
/* @__PURE__ */
|
|
109
|
-
/* @__PURE__ */
|
|
114
|
+
/* @__PURE__ */ w("div", { className: n.buttons, children: [
|
|
115
|
+
/* @__PURE__ */ s(
|
|
110
116
|
"button",
|
|
111
117
|
{
|
|
112
118
|
"aria-label": "Previous slide",
|
|
113
|
-
className: `${
|
|
114
|
-
onClick:
|
|
115
|
-
disabled: !
|
|
116
|
-
children: /* @__PURE__ */
|
|
119
|
+
className: `${n.prev} ${!c && i === 0 ? n.disabled : ""}`,
|
|
120
|
+
onClick: X,
|
|
121
|
+
disabled: !c && i === 0,
|
|
122
|
+
children: /* @__PURE__ */ s(O, { size: 36 })
|
|
117
123
|
}
|
|
118
124
|
),
|
|
119
|
-
/* @__PURE__ */
|
|
125
|
+
/* @__PURE__ */ s(
|
|
120
126
|
"button",
|
|
121
127
|
{
|
|
122
128
|
"aria-label": "Next slide",
|
|
123
|
-
className: `${
|
|
129
|
+
className: `${n.next} ${!c && i >= d - 1 ? n.disabled : ""}`,
|
|
124
130
|
onClick: f,
|
|
125
|
-
disabled: !
|
|
126
|
-
children: /* @__PURE__ */
|
|
131
|
+
disabled: !c && i >= $.length - h,
|
|
132
|
+
children: /* @__PURE__ */ s(q, { size: 36 })
|
|
127
133
|
}
|
|
128
134
|
)
|
|
129
135
|
] })
|
|
@@ -131,5 +137,5 @@ function V({
|
|
|
131
137
|
] });
|
|
132
138
|
}
|
|
133
139
|
export {
|
|
134
|
-
|
|
140
|
+
rt as Carousel
|
|
135
141
|
};
|
|
@@ -5,7 +5,10 @@ type CarouselProps = {
|
|
|
5
5
|
itemsPerRow?: number;
|
|
6
6
|
autoPlay?: boolean;
|
|
7
7
|
autoPlayInterval?: number;
|
|
8
|
+
externalRef?: React.RefObject<HTMLElement>;
|
|
9
|
+
siblingRef?: React.RefObject<HTMLElement>;
|
|
10
|
+
isSplit: boolean;
|
|
8
11
|
className?: string;
|
|
9
12
|
};
|
|
10
|
-
export declare function Carousel({ items, itemsPerPage, itemsPerRow, autoPlay, autoPlayInterval, className, }: CarouselProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function Carousel({ items, itemsPerPage, itemsPerRow, autoPlay, autoPlayInterval, className, externalRef, siblingRef, isSplit, }: CarouselProps): import("react/jsx-runtime").JSX.Element;
|
|
11
14
|
export {};
|