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