quirk-ui 0.0.76 → 0.0.77
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/components/Carousel/index.js +108 -83
- package/package.json +1 -1
|
@@ -1,109 +1,134 @@
|
|
|
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 X, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { useState as o, useRef as C, useEffect as q } from "react";
|
|
3
|
+
import { A as ut } from "../../arrow-left-BIJvHwNQ.js";
|
|
4
|
+
import { A as ht } from "../../arrow-right-QEwnX3Sk.js";
|
|
5
|
+
import '../../assets/index31.css';const ft = "_carousel_oeqfz_1", _t = "_trackContainer_oeqfz_9", mt = "_track_oeqfz_9", pt = "_page_oeqfz_24", vt = "_controls_oeqfz_30", wt = "_indicators_oeqfz_41", Mt = "_indicator_oeqfz_41", xt = "_active_oeqfz_58", bt = "_buttons_oeqfz_62", gt = "_prev_oeqfz_67", zt = "_disabled_oeqfz_67", $t = "_next_oeqfz_68", n = {
|
|
6
|
+
carousel: ft,
|
|
7
|
+
trackContainer: _t,
|
|
8
|
+
track: mt,
|
|
9
|
+
page: pt,
|
|
10
|
+
controls: vt,
|
|
11
|
+
indicators: wt,
|
|
12
|
+
indicator: Mt,
|
|
13
|
+
active: xt,
|
|
14
|
+
buttons: bt,
|
|
15
|
+
prev: gt,
|
|
16
|
+
disabled: zt,
|
|
17
|
+
next: $t
|
|
18
18
|
};
|
|
19
|
-
function
|
|
20
|
-
items:
|
|
19
|
+
function qt({
|
|
20
|
+
items: T,
|
|
21
21
|
itemsPerPage: _ = 9,
|
|
22
|
-
itemsPerRow:
|
|
23
|
-
autoplay:
|
|
24
|
-
autoplayInterval:
|
|
25
|
-
className:
|
|
26
|
-
externalRef:
|
|
27
|
-
siblingRef:
|
|
28
|
-
isSplit:
|
|
22
|
+
itemsPerRow: G = 3,
|
|
23
|
+
autoplay: O = !1,
|
|
24
|
+
autoplayInterval: k = 3,
|
|
25
|
+
className: F,
|
|
26
|
+
externalRef: H,
|
|
27
|
+
siblingRef: a,
|
|
28
|
+
isSplit: E = !1
|
|
29
29
|
}) {
|
|
30
|
-
const [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
const [l, i] = o(0), [u, m] = o(0), [I, J] = o(0), [p, K] = o(_), [W, Q] = o(!1), [A, V] = o(O), Y = C(null), v = C(null), h = C(null), w = H, [S, D] = o(null), [L, j] = o(null), [x, b] = o(!1), [P, g] = o(null), [R, z] = o(null), Z = (t) => {
|
|
31
|
+
b(!0), g(t.clientX);
|
|
32
|
+
}, tt = (t) => {
|
|
33
|
+
x && z(t.clientX);
|
|
34
|
+
}, et = () => {
|
|
35
|
+
if (!x || P === null || R === null) return;
|
|
36
|
+
const t = P - R;
|
|
37
|
+
Math.abs(t) > 50 && (t > 0 ? y() : N()), b(!1), g(null), z(null);
|
|
38
|
+
}, nt = () => {
|
|
39
|
+
x && (b(!1), g(null), z(null));
|
|
40
|
+
}, ot = (t) => {
|
|
41
|
+
D(t.touches[0].clientX);
|
|
42
|
+
}, st = (t) => {
|
|
43
|
+
j(t.touches[0].clientX);
|
|
44
|
+
}, ct = () => {
|
|
45
|
+
if (S === null || L === null) return;
|
|
46
|
+
const t = S - L;
|
|
47
|
+
Math.abs(t) > 50 && (t > 0 ? y() : N()), D(null), j(null);
|
|
48
|
+
}, rt = (t, e) => {
|
|
49
|
+
const r = [];
|
|
50
|
+
for (let c = 0; c < t.length; c += e)
|
|
51
|
+
r.push(t.slice(c, c + e));
|
|
52
|
+
return r;
|
|
35
53
|
};
|
|
36
|
-
|
|
54
|
+
q(() => {
|
|
37
55
|
if (typeof window < "u") {
|
|
38
56
|
const t = () => {
|
|
39
57
|
const e = window.innerWidth < 768;
|
|
40
|
-
|
|
58
|
+
Q(e), K(e ? 1 : _), i(0);
|
|
41
59
|
};
|
|
42
60
|
return t(), window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
|
|
43
61
|
}
|
|
44
62
|
}, [_]);
|
|
45
|
-
const
|
|
46
|
-
|
|
63
|
+
const M = Math.ceil(p / G), U = rt(T, p), d = U.length, at = 3 * 16, lt = 6 * 16;
|
|
64
|
+
q(() => {
|
|
47
65
|
const t = new ResizeObserver((e) => {
|
|
48
|
-
var
|
|
66
|
+
var r, c;
|
|
49
67
|
for (let f of e)
|
|
50
|
-
f.contentRect && (
|
|
51
|
-
f.contentRect.width - ((
|
|
52
|
-
) : m(f.contentRect.width) : (m(f.contentRect.width),
|
|
53
|
-
((
|
|
68
|
+
f.contentRect && (W ? m(f.contentRect.width - lt) : E ? a != null && a.current ? m(
|
|
69
|
+
f.contentRect.width - ((r = a == null ? void 0 : a.current) == null ? void 0 : r.offsetWidth) - at
|
|
70
|
+
) : m(f.contentRect.width) : (m(f.contentRect.width), J(
|
|
71
|
+
((c = v == null ? void 0 : v.current) == null ? void 0 : c.children[0].children[0].children[0].getBoundingClientRect().width) ?? 0
|
|
54
72
|
)), i(0));
|
|
55
73
|
});
|
|
56
74
|
return w != null && w.current && t.observe(w.current), () => t.disconnect();
|
|
57
|
-
}, [
|
|
58
|
-
const
|
|
59
|
-
h.current && clearInterval(h.current),
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
},
|
|
67
|
-
i((t) => t >=
|
|
75
|
+
}, [W, E]);
|
|
76
|
+
const $ = () => {
|
|
77
|
+
h.current && clearInterval(h.current), V(!1);
|
|
78
|
+
}, y = () => {
|
|
79
|
+
$(), i((t) => Math.min(t + 1, d - 1));
|
|
80
|
+
}, N = () => {
|
|
81
|
+
$(), i((t) => Math.max(t - 1, 0));
|
|
82
|
+
}, it = (t) => {
|
|
83
|
+
$(), i(t);
|
|
84
|
+
}, dt = () => u ? `translateX(-${l * u}px)` : "translateX(0px)", B = () => {
|
|
85
|
+
i((t) => t >= d - 1 ? 0 : t + 1);
|
|
68
86
|
};
|
|
69
|
-
return
|
|
70
|
-
|
|
71
|
-
|
|
87
|
+
return q(() => (A && (h.current = setInterval(
|
|
88
|
+
B,
|
|
89
|
+
k * 1e3
|
|
72
90
|
)), () => {
|
|
73
91
|
h.current && clearInterval(h.current);
|
|
74
|
-
}), [
|
|
75
|
-
/* @__PURE__ */
|
|
92
|
+
}), [A, k, B]), /* @__PURE__ */ X("div", { className: `${F ?? ""} ${n.carousel}`, ref: Y, children: [
|
|
93
|
+
/* @__PURE__ */ s(
|
|
76
94
|
"div",
|
|
77
95
|
{
|
|
78
96
|
className: n.trackContainer,
|
|
79
97
|
style: { maxWidth: `${u}px` },
|
|
80
|
-
|
|
98
|
+
onTouchStart: ot,
|
|
99
|
+
onTouchMove: st,
|
|
100
|
+
onTouchEnd: ct,
|
|
101
|
+
onMouseDown: Z,
|
|
102
|
+
onMouseMove: tt,
|
|
103
|
+
onMouseUp: et,
|
|
104
|
+
onMouseLeave: nt,
|
|
105
|
+
children: /* @__PURE__ */ s(
|
|
81
106
|
"div",
|
|
82
107
|
{
|
|
83
108
|
ref: v,
|
|
84
109
|
className: n.track,
|
|
85
|
-
style: { width: `${
|
|
86
|
-
children:
|
|
110
|
+
style: { width: `${d * 100}%`, transform: dt() },
|
|
111
|
+
children: U.map((t, e) => /* @__PURE__ */ s(
|
|
87
112
|
"div",
|
|
88
113
|
{
|
|
89
114
|
className: n.page,
|
|
90
115
|
style: {
|
|
91
|
-
display:
|
|
116
|
+
display: M > 1 ? "grid" : "flex",
|
|
92
117
|
gridTemplateColumns: `repeat(${Math.ceil(
|
|
93
|
-
p /
|
|
118
|
+
p / M
|
|
94
119
|
)}, 1fr)`,
|
|
95
|
-
gridTemplateRows: `repeat(${
|
|
120
|
+
gridTemplateRows: `repeat(${M}, auto)`,
|
|
96
121
|
width: `${u}px`
|
|
97
122
|
},
|
|
98
|
-
children: t.map((
|
|
123
|
+
children: t.map((r, c) => /* @__PURE__ */ s(
|
|
99
124
|
"div",
|
|
100
125
|
{
|
|
101
126
|
style: {
|
|
102
|
-
width: `${u /
|
|
127
|
+
width: `${u / M - 16}px`
|
|
103
128
|
},
|
|
104
|
-
children:
|
|
129
|
+
children: r
|
|
105
130
|
},
|
|
106
|
-
|
|
131
|
+
c
|
|
107
132
|
))
|
|
108
133
|
},
|
|
109
134
|
e
|
|
@@ -112,42 +137,42 @@ function ht({
|
|
|
112
137
|
)
|
|
113
138
|
}
|
|
114
139
|
),
|
|
115
|
-
|
|
140
|
+
d > 1 && /* @__PURE__ */ X(
|
|
116
141
|
"div",
|
|
117
142
|
{
|
|
118
143
|
className: n.controls,
|
|
119
144
|
style: {
|
|
120
|
-
maxWidth:
|
|
145
|
+
maxWidth: I > 0 && _ === 1 ? `${I}px` : "unset"
|
|
121
146
|
},
|
|
122
147
|
children: [
|
|
123
|
-
/* @__PURE__ */
|
|
148
|
+
/* @__PURE__ */ s("div", { className: n.indicators, children: Array.from({ length: d }).map((t, e) => /* @__PURE__ */ s(
|
|
124
149
|
"button",
|
|
125
150
|
{
|
|
126
|
-
className: `${n.indicator} ${e ===
|
|
127
|
-
onClick: () =>
|
|
151
|
+
className: `${n.indicator} ${e === l ? n.active : ""}`,
|
|
152
|
+
onClick: () => it(e),
|
|
128
153
|
"aria-label": `Go to group ${e + 1}`
|
|
129
154
|
},
|
|
130
155
|
e
|
|
131
156
|
)) }),
|
|
132
|
-
/* @__PURE__ */
|
|
133
|
-
/* @__PURE__ */
|
|
157
|
+
/* @__PURE__ */ X("div", { className: n.buttons, children: [
|
|
158
|
+
/* @__PURE__ */ s(
|
|
134
159
|
"button",
|
|
135
160
|
{
|
|
136
161
|
"aria-label": "Previous slide",
|
|
137
|
-
className: `${n.prev} ${
|
|
138
|
-
onClick:
|
|
139
|
-
disabled:
|
|
140
|
-
children: /* @__PURE__ */
|
|
162
|
+
className: `${n.prev} ${l === 0 ? n.disabled : ""}`,
|
|
163
|
+
onClick: N,
|
|
164
|
+
disabled: l === 0,
|
|
165
|
+
children: /* @__PURE__ */ s(ut, { size: 36 })
|
|
141
166
|
}
|
|
142
167
|
),
|
|
143
|
-
/* @__PURE__ */
|
|
168
|
+
/* @__PURE__ */ s(
|
|
144
169
|
"button",
|
|
145
170
|
{
|
|
146
171
|
"aria-label": "Next slide",
|
|
147
|
-
className: `${n.next} ${
|
|
148
|
-
onClick:
|
|
149
|
-
disabled:
|
|
150
|
-
children: /* @__PURE__ */
|
|
172
|
+
className: `${n.next} ${l >= d - 1 ? n.disabled : ""}`,
|
|
173
|
+
onClick: y,
|
|
174
|
+
disabled: l >= T.length - p,
|
|
175
|
+
children: /* @__PURE__ */ s(ht, { size: 36 })
|
|
151
176
|
}
|
|
152
177
|
)
|
|
153
178
|
] })
|
|
@@ -157,5 +182,5 @@ function ht({
|
|
|
157
182
|
] });
|
|
158
183
|
}
|
|
159
184
|
export {
|
|
160
|
-
|
|
185
|
+
qt as Carousel
|
|
161
186
|
};
|