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