quirk-ui 0.0.256 → 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,165 +1,180 @@
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
- active: Tt,
15
- buttons: Wt,
16
- prev: At,
17
- disabled: Dt,
18
- next: Lt
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 Bt({
21
- items: M,
22
- itemsPerPage: i = 9,
23
- itemsPerRow: K = 3,
24
- autoplay: Q = !1,
25
- autoplayInterval: L = 3,
26
- className: V,
27
- externalRef: Z,
28
- siblingRef: l,
29
- isSplit: S = !1
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
+ siblingRef: u,
29
+ isSplit: z = !1
30
30
  }) {
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());
33
- }, at = (t) => {
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
- 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 = m - y;
43
- Math.abs(t) > 50 && (t > 0 ? T() : W()), I();
44
- }, ut = () => {
45
- I();
46
- }, I = () => {
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;
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), 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));
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
- }, [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) => {
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
- Mt(() => {
72
+ $t(() => {
73
73
  if (typeof window < "u") {
74
74
  const t = () => {
75
- const e = window.innerWidth < 768, n = e ? 1 : i;
76
- nt(e), et(e ? 1 : i), d(
77
- (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)
78
78
  );
79
79
  };
80
80
  return t(), window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
81
81
  }
82
- }, [i]);
83
- const N = Math.ceil(h / K), H = ft(M, h), p = H.length, pt = 3 * 16, vt = 3 * 16;
84
- D(() => {
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(() => {
85
99
  const t = new ResizeObserver((e) => {
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(
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(
92
106
  "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
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
96
110
  ));
97
- const mt = f ? 1 : i;
98
- d(
99
- (wt) => Math.min(wt, Math.ceil(M.length / mt) - 1)
111
+ const Ct = v ? 1 : d;
112
+ f(
113
+ (bt) => Math.min(bt, Math.ceil(m.length / Ct) - 1)
100
114
  );
101
115
  }
102
116
  });
103
- return x != null && x.current && t.observe(x.current), () => t.disconnect();
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);
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);
115
129
  };
116
- return D(() => (z && (_.current = setInterval(
117
- J,
118
- L * 1e3
130
+ return I(() => (B && (w.current = setInterval(
131
+ Q,
132
+ R * 1e3
119
133
  )), () => {
120
- _.current && clearInterval(_.current);
121
- }), [z, L, J]), /* @__PURE__ */ A("div", { className: `${V ?? ""} ${o.carousel}`, ref: st, children: [
122
- /* @__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(
123
137
  "div",
124
138
  {
125
- ref: F,
126
- className: `${o.trackContainer} ${ct || g ? o.noPointerEvents : ""}
139
+ ref: J,
140
+ className: `${c.trackContainer} ${it || M ? c.noPointerEvents : ""}
127
141
  `,
128
142
  style: {
129
- maxWidth: `${v}px`,
130
- touchAction: g ? "none" : "pan-y"
143
+ maxWidth: `${l}px`,
144
+ touchAction: M ? "none" : "pan-y"
131
145
  },
132
- onTouchStart: dt,
133
- onTouchEnd: ht,
134
- onMouseDown: at,
135
- onMouseMove: it,
136
- onMouseUp: lt,
137
- onMouseLeave: ut,
138
- 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(
139
153
  "div",
140
154
  {
141
- ref: a,
142
- className: o.track,
143
- style: { width: `${p * 100}%`, transform: gt() },
144
- 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(
145
159
  "div",
146
160
  {
147
- className: o.page,
161
+ className: c.page,
148
162
  style: {
149
- display: N > 1 ? "grid" : "flex",
163
+ display: A > 1 ? "grid" : "flex",
150
164
  gridTemplateColumns: `repeat(${Math.ceil(
151
- h / N
165
+ p / A
152
166
  )}, 1fr)`,
153
- gridTemplateRows: `repeat(${N}, auto)`,
154
- width: `${v}px`
167
+ gridTemplateRows: `repeat(${A}, auto)`,
168
+ width: `${l}px`
155
169
  },
156
- children: t.map((n, s) => /* @__PURE__ */ r(
170
+ children: t.map((n, s) => /* @__PURE__ */ i(
157
171
  "div",
158
172
  {
159
- onClickCapture: rt,
173
+ ref: e === 0 && s === 0 ? mt : null,
174
+ onClickCapture: at,
160
175
  style: {
161
- flexBasis: f ? "100%" : `${100 / h}%`,
162
- width: f ? `${v / h - 16}px` : "unset"
176
+ flexBasis: v ? "100%" : `${100 / p}%`,
177
+ width: v ? `${l / p - 16}px` : "unset"
163
178
  },
164
179
  children: n
165
180
  },
@@ -172,42 +187,42 @@ function Bt({
172
187
  )
173
188
  }
174
189
  ),
175
- p > 1 && /* @__PURE__ */ A(
190
+ _ > 1 && /* @__PURE__ */ P(
176
191
  "div",
177
192
  {
178
- className: o.controls,
193
+ className: c.controls,
179
194
  style: {
180
- maxWidth: P > 0 && i === 1 && !f ? `${P}px` : "unset"
195
+ maxWidth: g > 0 && d === 1 && !v ? `${g}px` : "unset"
181
196
  },
182
197
  children: [
183
- /* @__PURE__ */ r("div", { className: o.indicators, children: Array.from({ length: p }).map((t, e) => /* @__PURE__ */ r(
198
+ /* @__PURE__ */ i("div", { className: c.indicators, children: Array.from({ length: _ }).map((t, e) => /* @__PURE__ */ i(
184
199
  "button",
185
200
  {
186
- className: `${o.indicator} ${e === u ? o.active : ""}`,
187
- onClick: () => _t(e),
201
+ className: `${c.indicator} ${e === h ? c.active : ""}`,
202
+ onClick: () => wt(e),
188
203
  "aria-label": `Go to group ${e + 1}`
189
204
  },
190
205
  e
191
206
  )) }),
192
- /* @__PURE__ */ A("div", { className: o.buttons, children: [
193
- /* @__PURE__ */ r(
207
+ /* @__PURE__ */ P("div", { className: c.buttons, children: [
208
+ /* @__PURE__ */ i(
194
209
  "button",
195
210
  {
196
211
  "aria-label": "Previous slide",
197
- className: `${o.prev} ${u === 0 ? o.disabled : ""}`,
198
- onClick: W,
199
- disabled: u === 0,
200
- children: /* @__PURE__ */ r(bt, { size: 36 })
212
+ className: `${c.prev} ${h === 0 ? c.disabled : ""}`,
213
+ onClick: S,
214
+ disabled: h === 0,
215
+ children: /* @__PURE__ */ i(Et, { size: 36 })
201
216
  }
202
217
  ),
203
- /* @__PURE__ */ r(
218
+ /* @__PURE__ */ i(
204
219
  "button",
205
220
  {
206
221
  "aria-label": "Next slide",
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 })
222
+ className: `${c.next} ${h >= _ - 1 ? c.disabled : ""}`,
223
+ onClick: L,
224
+ disabled: h >= m.length - p,
225
+ children: /* @__PURE__ */ i(Xt, { size: 36 })
211
226
  }
212
227
  )
213
228
  ] })
@@ -217,5 +232,5 @@ function Bt({
217
232
  ] });
218
233
  }
219
234
  export {
220
- Bt as Carousel
235
+ Gt as Carousel
221
236
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "quirk-ui",
3
3
  "private": false,
4
- "version": "0.0.256",
4
+ "version": "0.0.257",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {