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