quirk-ui 0.0.30 → 0.0.31
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,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as h, jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { useState as _, useRef as A, useEffect as
|
|
2
|
+
import { useState as _, useRef as A, useEffect as f } from "react";
|
|
3
3
|
import { A as C } from "../../arrow-left-BIJvHwNQ.js";
|
|
4
4
|
import { A as I } from "../../arrow-right-QEwnX3Sk.js";
|
|
5
5
|
import '../../assets/index31.css';const M = "_carousel_1h8mt_5", S = "_track_1h8mt_12", W = "_slide_1h8mt_18", E = "_controls_1h8mt_30", L = "_indicators_1h8mt_47", R = "_indicator_1h8mt_47", j = "_active_1h8mt_62", z = "_buttons_1h8mt_66", G = "_prev_1h8mt_71", T = "_disabled_1h8mt_71", V = "_next_1h8mt_72", e = {
|
|
@@ -19,73 +19,73 @@ function H({
|
|
|
19
19
|
items: c,
|
|
20
20
|
autoPlay: r = !1,
|
|
21
21
|
autoPlayInterval: m = 3e3,
|
|
22
|
-
className:
|
|
22
|
+
className: b
|
|
23
23
|
}) {
|
|
24
|
-
const [
|
|
25
|
-
|
|
24
|
+
const [i, l] = _(0), [s, u] = _(3), [v, N] = _(!1), a = A(null), $ = i === 0, g = i === c.length - 1, p = Math.ceil(c.length / s);
|
|
25
|
+
f(() => {
|
|
26
26
|
const t = () => {
|
|
27
27
|
l(0);
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
const n = window.innerWidth < 768;
|
|
29
|
+
N(n), u(n ? 1 : 3);
|
|
30
30
|
};
|
|
31
31
|
return t(), window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
|
|
32
32
|
}, []);
|
|
33
33
|
const d = () => {
|
|
34
34
|
(r || !g) && l(
|
|
35
|
-
(t) => t < c.length -
|
|
35
|
+
(t) => t < c.length - s ? t + s : t
|
|
36
36
|
);
|
|
37
37
|
}, w = () => {
|
|
38
|
-
(r ||
|
|
38
|
+
(r || !$) && l((t) => t > 0 ? t - s : 0);
|
|
39
39
|
}, x = (t) => {
|
|
40
|
-
l(t *
|
|
40
|
+
l(t * s);
|
|
41
41
|
};
|
|
42
|
-
|
|
42
|
+
f(() => (r && (a.current = setInterval(d, m)), () => {
|
|
43
43
|
a.current && clearInterval(a.current);
|
|
44
44
|
}), [r, m, d]);
|
|
45
45
|
const k = () => {
|
|
46
|
-
if (
|
|
47
|
-
return `translateX(calc(-${
|
|
48
|
-
const t = 100 /
|
|
49
|
-
return `translateX(-${
|
|
46
|
+
if (v)
|
|
47
|
+
return `translateX(calc(-${i * 80}% + 10%))`;
|
|
48
|
+
const t = 100 / s;
|
|
49
|
+
return `translateX(-${i * t}%)`;
|
|
50
50
|
};
|
|
51
|
-
return /* @__PURE__ */ h("div", { className: `${
|
|
51
|
+
return /* @__PURE__ */ h("div", { className: `${b ?? ""} ${e.carousel}`, children: [
|
|
52
52
|
/* @__PURE__ */ o(
|
|
53
53
|
"div",
|
|
54
54
|
{
|
|
55
55
|
className: e.track,
|
|
56
56
|
style: { transform: k() },
|
|
57
57
|
role: "list",
|
|
58
|
-
children: c.map((t,
|
|
58
|
+
children: c.map((t, n) => /* @__PURE__ */ o("div", { className: e.slide, children: t }, n))
|
|
59
59
|
}
|
|
60
60
|
),
|
|
61
|
-
|
|
62
|
-
/* @__PURE__ */ o("div", { className: e.indicators, children: Array.from({ length:
|
|
61
|
+
c.length > s && /* @__PURE__ */ h("div", { className: e.controls, children: [
|
|
62
|
+
/* @__PURE__ */ o("div", { className: e.indicators, children: Array.from({ length: p }).map((t, n) => /* @__PURE__ */ o(
|
|
63
63
|
"button",
|
|
64
64
|
{
|
|
65
|
-
className: `${e.indicator} ${
|
|
66
|
-
onClick: () => x(
|
|
67
|
-
"aria-label": `Go to group ${
|
|
65
|
+
className: `${e.indicator} ${n === Math.floor(i / s) ? e.active : ""}`,
|
|
66
|
+
onClick: () => x(n),
|
|
67
|
+
"aria-label": `Go to group ${n + 1}`
|
|
68
68
|
},
|
|
69
|
-
|
|
69
|
+
n
|
|
70
70
|
)) }),
|
|
71
71
|
/* @__PURE__ */ h("div", { className: e.buttons, children: [
|
|
72
72
|
/* @__PURE__ */ o(
|
|
73
73
|
"button",
|
|
74
74
|
{
|
|
75
|
-
className: `${e.prev} ${!r &&
|
|
75
|
+
className: `${e.prev} ${!r && i === 0 ? e.disabled : ""}`,
|
|
76
76
|
onClick: w,
|
|
77
77
|
"aria-label": "Previous slide",
|
|
78
|
-
disabled: !r &&
|
|
78
|
+
disabled: !r && i === 0,
|
|
79
79
|
children: /* @__PURE__ */ o(C, {})
|
|
80
80
|
}
|
|
81
81
|
),
|
|
82
82
|
/* @__PURE__ */ o(
|
|
83
83
|
"button",
|
|
84
84
|
{
|
|
85
|
-
className: `${e.next} ${!r &&
|
|
85
|
+
className: `${e.next} ${!r && i >= c.length - s ? e.disabled : ""}`,
|
|
86
86
|
onClick: d,
|
|
87
87
|
"aria-label": "Next slide",
|
|
88
|
-
disabled: !r &&
|
|
88
|
+
disabled: !r && i >= c.length - s,
|
|
89
89
|
children: /* @__PURE__ */ o(I, {})
|
|
90
90
|
}
|
|
91
91
|
)
|