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