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