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