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.
@@ -1,156 +1,165 @@
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";
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", 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 = {
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: Xt,
12
- indicators: yt,
13
- indicator: Et,
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 Lt({
21
- items: p,
22
- itemsPerPage: r = 9,
23
- itemsPerRow: F = 3,
24
- autoplay: H = !1,
20
+ function Pt({
21
+ items: _,
22
+ itemsPerPage: l = 9,
23
+ itemsPerRow: J = 3,
24
+ autoplay: K = !1,
25
25
  autoplayInterval: W = 3,
26
- className: J,
27
- externalRef: K,
28
- siblingRef: l,
26
+ className: Q,
27
+ externalRef: V,
28
+ siblingRef: i,
29
29
  isSplit: D = !1
30
30
  }) {
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);
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
- u !== null && Math.abs(t.clientX - u) > 5 && (U(!0), G(t.clientX));
37
- }, rt = () => {
38
- if (!u || !$) {
39
- y();
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 = 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);
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
- 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);
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 s = [];
59
- for (let c = 0; c < t.length; c += e)
60
- s.push(t.slice(c, c + e));
61
- return s;
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
- A(() => {
72
+ E(() => {
64
73
  if (typeof window < "u") {
65
74
  const t = () => {
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)
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
- }, [r]);
74
- const z = Math.ceil(m / F), O = ht(p, m), h = O.length, bt = 3 * 16, vt = 6 * 16;
75
- A(() => {
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 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
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 = M ? 1 : r;
86
- d(
87
- (mt) => Math.min(mt, Math.ceil(p.length / _t) - 1)
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 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));
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
- E(), d(t);
101
- }, pt = () => b ? `translateX(-${i * b}px)` : "translateX(0px)", q = () => {
102
- d((t) => t >= h - 1 ? 0 : t + 1);
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 A(() => (P && (v.current = setInterval(
105
- q,
113
+ return E(() => (L && (b.current = setInterval(
114
+ H,
106
115
  W * 1e3
107
116
  )), () => {
108
- v.current && clearInterval(v.current);
109
- }), [P, W, q]), /* @__PURE__ */ k("div", { className: `${J ?? ""} ${n.carousel}`, ref: et, children: [
110
- /* @__PURE__ */ a(
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
- className: `${n.trackContainer} ${ot || x ? n.noPointerEvents : ""}
122
+ ref: q,
123
+ className: `${o.trackContainer} ${st || f ? o.noPointerEvents : ""}
114
124
  `,
115
125
  style: {
116
- maxWidth: `${b}px`,
117
- touchAction: x ? "none" : "pan-y"
126
+ maxWidth: `${v}px`,
127
+ touchAction: f ? "none" : "pan-y"
118
128
  },
119
- onTouchStart: it,
120
- onTouchMove: dt,
129
+ onTouchStart: dt,
121
130
  onTouchEnd: ut,
122
- onMouseDown: ct,
131
+ onMouseDown: rt,
123
132
  onMouseMove: at,
124
- onMouseUp: rt,
125
- onMouseLeave: lt,
126
- children: /* @__PURE__ */ a(
133
+ onMouseUp: lt,
134
+ onMouseLeave: it,
135
+ children: /* @__PURE__ */ r(
127
136
  "div",
128
137
  {
129
- ref: w,
130
- className: n.track,
138
+ ref: g,
139
+ className: o.track,
131
140
  style: { width: `${h * 100}%`, transform: pt() },
132
- children: O.map((t, e) => /* @__PURE__ */ a(
141
+ children: F.map((t, e) => /* @__PURE__ */ r(
133
142
  "div",
134
143
  {
135
- className: n.page,
144
+ className: o.page,
136
145
  style: {
137
146
  display: z > 1 ? "grid" : "flex",
138
147
  gridTemplateColumns: `repeat(${Math.ceil(
139
- m / z
148
+ M / z
140
149
  )}, 1fr)`,
141
150
  gridTemplateRows: `repeat(${z}, auto)`,
142
- width: `${b}px`
151
+ width: `${v}px`
143
152
  },
144
- children: t.map((s, c) => /* @__PURE__ */ a(
153
+ children: t.map((n, s) => /* @__PURE__ */ r(
145
154
  "div",
146
155
  {
147
- onClickCapture: st,
156
+ onClickCapture: ct,
148
157
  style: {
149
- width: `${b / z - 16}px`
158
+ width: `${v / z - 16}px`
150
159
  },
151
- children: s
160
+ children: n
152
161
  },
153
- c
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__ */ k(
171
+ h > 1 && /* @__PURE__ */ A(
163
172
  "div",
164
173
  {
165
- className: n.controls,
174
+ className: o.controls,
166
175
  style: {
167
- maxWidth: S > 0 && r === 1 && !M ? `${S}px` : "unset"
176
+ maxWidth: S > 0 && l === 1 && !w ? `${S}px` : "unset"
168
177
  },
169
178
  children: [
170
- /* @__PURE__ */ a("div", { className: n.indicators, children: Array.from({ length: h }).map((t, e) => /* @__PURE__ */ a(
179
+ /* @__PURE__ */ r("div", { className: o.indicators, children: Array.from({ length: h }).map((t, e) => /* @__PURE__ */ r(
171
180
  "button",
172
181
  {
173
- className: `${n.indicator} ${e === i ? n.active : ""}`,
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__ */ k("div", { className: n.buttons, children: [
180
- /* @__PURE__ */ a(
188
+ /* @__PURE__ */ A("div", { className: o.buttons, children: [
189
+ /* @__PURE__ */ r(
181
190
  "button",
182
191
  {
183
192
  "aria-label": "Previous slide",
184
- className: `${n.prev} ${i === 0 ? n.disabled : ""}`,
185
- onClick: N,
186
- disabled: i === 0,
187
- children: /* @__PURE__ */ a(Mt, { size: 36 })
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__ */ a(
199
+ /* @__PURE__ */ r(
191
200
  "button",
192
201
  {
193
202
  "aria-label": "Next slide",
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 })
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
- Lt as Carousel
216
+ Pt as Carousel
208
217
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "quirk-ui",
3
3
  "private": false,
4
- "version": "0.0.81",
4
+ "version": "0.0.82",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {