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