quirk-ui 0.0.72 → 0.0.74

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,109 +1,107 @@
1
1
  import { jsxs as z, jsx as o } from "react/jsx-runtime";
2
- import { useState as u, useRef as $, useEffect as y } from "react";
3
- import { A as S } from "../../arrow-left-BIJvHwNQ.js";
4
- import { A as U } from "../../arrow-right-QEwnX3Sk.js";
5
- import '../../assets/index31.css';const V = "_carousel_oeqfz_1", Y = "_trackContainer_oeqfz_9", Z = "_track_oeqfz_9", tt = "_page_oeqfz_24", et = "_controls_oeqfz_30", nt = "_indicators_oeqfz_41", ot = "_indicator_oeqfz_41", rt = "_active_oeqfz_58", st = "_buttons_oeqfz_62", ct = "_prev_oeqfz_67", at = "_disabled_oeqfz_67", it = "_next_oeqfz_68", n = {
6
- carousel: V,
7
- trackContainer: Y,
8
- track: Z,
9
- page: tt,
10
- controls: et,
11
- indicators: nt,
12
- indicator: ot,
13
- active: rt,
14
- buttons: st,
15
- prev: ct,
16
- disabled: at,
17
- next: it
2
+ import { useState as d, useRef as $, useEffect as y } from "react";
3
+ import { A as Q } from "../../arrow-left-BIJvHwNQ.js";
4
+ import { A as S } from "../../arrow-right-QEwnX3Sk.js";
5
+ import '../../assets/index31.css';const U = "_carousel_oeqfz_1", V = "_trackContainer_oeqfz_9", Y = "_track_oeqfz_9", Z = "_page_oeqfz_24", tt = "_controls_oeqfz_30", et = "_indicators_oeqfz_41", nt = "_indicator_oeqfz_41", ot = "_active_oeqfz_58", rt = "_buttons_oeqfz_62", st = "_prev_oeqfz_67", ct = "_disabled_oeqfz_67", at = "_next_oeqfz_68", n = {
6
+ carousel: U,
7
+ trackContainer: V,
8
+ track: Y,
9
+ page: Z,
10
+ controls: tt,
11
+ indicators: et,
12
+ indicator: nt,
13
+ active: ot,
14
+ buttons: rt,
15
+ prev: st,
16
+ disabled: ct,
17
+ next: at
18
18
  };
19
- function ft({
19
+ function ht({
20
20
  items: N,
21
- itemsPerPage: m = 9,
22
- itemsPerRow: E = 3,
23
- autoplay: T = !1,
21
+ itemsPerPage: _ = 9,
22
+ itemsPerRow: M = 3,
23
+ autoplay: E = !1,
24
24
  autoplayInterval: C = 3,
25
- className: L,
26
- externalRef: j,
27
- siblingRef: a,
28
- isSplit: g = !1
25
+ className: T,
26
+ externalRef: L,
27
+ siblingRef: c,
28
+ isSplit: q = !1
29
29
  }) {
30
- const [i, l] = u(0), [h, p] = u(0), [q, P] = u(0), [v, X] = u(m), [I, B] = u(!1), [W, D] = u(T), G = $(null), s = $(null), f = $(null), w = j, O = (t, e) => {
31
- const c = [];
30
+ const [a, i] = d(0), [u, m] = d(0), [g, j] = d(0), [p, P] = d(_), [k, R] = d(!1), [I, X] = d(E), B = $(null), v = $(null), h = $(null), w = L, D = (t, e) => {
31
+ const s = [];
32
32
  for (let r = 0; r < t.length; r += e)
33
- c.push(t.slice(r, r + e));
34
- return c;
33
+ s.push(t.slice(r, r + e));
34
+ return s;
35
35
  };
36
36
  y(() => {
37
37
  if (typeof window < "u") {
38
38
  const t = () => {
39
39
  const e = window.innerWidth < 768;
40
- B(e), X(e ? 1 : m), l(0);
40
+ R(e), P(e ? 1 : _), i(0);
41
41
  };
42
42
  return t(), window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
43
43
  }
44
- }, [m]);
45
- const x = Math.ceil(v / E), k = O(N, v), d = k.length, F = 3 * 16, H = 6 * 16;
44
+ }, [_]);
45
+ const x = Math.ceil(p / M), W = D(N, p), l = W.length, G = 3 * 16, O = 6 * 16;
46
46
  y(() => {
47
47
  const t = new ResizeObserver((e) => {
48
- var c, r, M;
49
- for (let _ of e)
50
- _.contentRect && (I ? p(_.contentRect.width - H) : g ? a != null && a.current ? p(
51
- _.contentRect.width - ((c = a == null ? void 0 : a.current) == null ? void 0 : c.offsetWidth) - F
52
- ) : p(_.contentRect.width) : (console.log(
53
- (r = s == null ? void 0 : s.current) == null ? void 0 : r.children[0].children[0].children[0]
54
- ), p(_.contentRect.width), P(
55
- ((M = s == null ? void 0 : s.current) == null ? void 0 : M.children[0].children[0].children[0].getBoundingClientRect().width) ?? 0
56
- )), l(0));
48
+ var s, r;
49
+ for (let f of e)
50
+ f.contentRect && (k ? m(f.contentRect.width - O) : q ? c != null && c.current ? m(
51
+ f.contentRect.width - ((s = c == null ? void 0 : c.current) == null ? void 0 : s.offsetWidth) - G
52
+ ) : m(f.contentRect.width) : (m(f.contentRect.width), j(
53
+ ((r = v == null ? void 0 : v.current) == null ? void 0 : r.children[0].children[0].children[0].getBoundingClientRect().width) ?? 0
54
+ )), i(0));
57
55
  });
58
56
  return w != null && w.current && t.observe(w.current), () => t.disconnect();
59
- }, [I, g]);
57
+ }, [k, q]);
60
58
  const b = () => {
61
- f.current && clearInterval(f.current), D(!1);
62
- }, J = () => {
63
- b(), l((t) => Math.min(t + 1, d - 1));
64
- }, K = () => {
65
- b(), l((t) => Math.max(t - 1, 0));
66
- }, Q = (t) => {
67
- b(), l(t);
68
- }, R = () => h ? `translateX(-${i * h}px)` : "translateX(0px)", A = () => {
69
- l((t) => t >= d - 1 ? 0 : t + 1);
59
+ h.current && clearInterval(h.current), X(!1);
60
+ }, F = () => {
61
+ b(), i((t) => Math.min(t + 1, l - 1));
62
+ }, H = () => {
63
+ b(), i((t) => Math.max(t - 1, 0));
64
+ }, J = (t) => {
65
+ b(), i(t);
66
+ }, K = () => u ? `translateX(-${a * u}px)` : "translateX(0px)", A = () => {
67
+ i((t) => t >= l - 1 ? 0 : t + 1);
70
68
  };
71
- return y(() => (W && (f.current = setInterval(
69
+ return y(() => (I && (h.current = setInterval(
72
70
  A,
73
71
  C * 1e3
74
72
  )), () => {
75
- f.current && clearInterval(f.current);
76
- }), [W, C, A]), /* @__PURE__ */ z("div", { className: `${L ?? ""} ${n.carousel}`, ref: G, children: [
73
+ h.current && clearInterval(h.current);
74
+ }), [I, C, A]), /* @__PURE__ */ z("div", { className: `${T ?? ""} ${n.carousel}`, ref: B, children: [
77
75
  /* @__PURE__ */ o(
78
76
  "div",
79
77
  {
80
78
  className: n.trackContainer,
81
- style: { maxWidth: `${h}px` },
79
+ style: { maxWidth: `${u}px` },
82
80
  children: /* @__PURE__ */ o(
83
81
  "div",
84
82
  {
85
- ref: s,
83
+ ref: v,
86
84
  className: n.track,
87
- style: { width: `${d * 100}%`, transform: R() },
88
- children: k.map((t, e) => /* @__PURE__ */ o(
85
+ style: { width: `${l * 100}%`, transform: K() },
86
+ children: W.map((t, e) => /* @__PURE__ */ o(
89
87
  "div",
90
88
  {
91
89
  className: n.page,
92
90
  style: {
93
91
  display: x > 1 ? "grid" : "flex",
94
92
  gridTemplateColumns: `repeat(${Math.ceil(
95
- v / x
93
+ p / x
96
94
  )}, 1fr)`,
97
95
  gridTemplateRows: `repeat(${x}, auto)`,
98
- width: `${h}px`
96
+ width: `${u}px`
99
97
  },
100
- children: t.map((c, r) => /* @__PURE__ */ o(
98
+ children: t.map((s, r) => /* @__PURE__ */ o(
101
99
  "div",
102
100
  {
103
101
  style: {
104
- width: `${h / x - 16}px`
102
+ width: `${u / x - 16}px`
105
103
  },
106
- children: c
104
+ children: s
107
105
  },
108
106
  r
109
107
  ))
@@ -114,19 +112,19 @@ function ft({
114
112
  )
115
113
  }
116
114
  ),
117
- d > 1 && /* @__PURE__ */ z(
115
+ l > 1 && /* @__PURE__ */ z(
118
116
  "div",
119
117
  {
120
118
  className: n.controls,
121
119
  style: {
122
- maxWidth: q > 0 && m === 1 ? `${q}px` : "unset"
120
+ maxWidth: g > 0 && _ === 1 ? `${g}px` : "unset"
123
121
  },
124
122
  children: [
125
- /* @__PURE__ */ o("div", { className: n.indicators, children: Array.from({ length: d }).map((t, e) => /* @__PURE__ */ o(
123
+ /* @__PURE__ */ o("div", { className: n.indicators, children: Array.from({ length: l }).map((t, e) => /* @__PURE__ */ o(
126
124
  "button",
127
125
  {
128
- className: `${n.indicator} ${e === i ? n.active : ""}`,
129
- onClick: () => Q(e),
126
+ className: `${n.indicator} ${e === a ? n.active : ""}`,
127
+ onClick: () => J(e),
130
128
  "aria-label": `Go to group ${e + 1}`
131
129
  },
132
130
  e
@@ -136,20 +134,20 @@ function ft({
136
134
  "button",
137
135
  {
138
136
  "aria-label": "Previous slide",
139
- className: `${n.prev} ${i === 0 ? n.disabled : ""}`,
140
- onClick: K,
141
- disabled: i === 0,
142
- children: /* @__PURE__ */ o(S, { size: 36 })
137
+ className: `${n.prev} ${a === 0 ? n.disabled : ""}`,
138
+ onClick: H,
139
+ disabled: a === 0,
140
+ children: /* @__PURE__ */ o(Q, { size: 36 })
143
141
  }
144
142
  ),
145
143
  /* @__PURE__ */ o(
146
144
  "button",
147
145
  {
148
146
  "aria-label": "Next slide",
149
- className: `${n.next} ${i >= d - 1 ? n.disabled : ""}`,
150
- onClick: J,
151
- disabled: i >= N.length - v,
152
- children: /* @__PURE__ */ o(U, { size: 36 })
147
+ className: `${n.next} ${a >= l - 1 ? n.disabled : ""}`,
148
+ onClick: F,
149
+ disabled: a >= N.length - p,
150
+ children: /* @__PURE__ */ o(S, { size: 36 })
153
151
  }
154
152
  )
155
153
  ] })
@@ -159,5 +157,5 @@ function ft({
159
157
  ] });
160
158
  }
161
159
  export {
162
- ft as Carousel
160
+ ht as Carousel
163
161
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "quirk-ui",
3
3
  "private": false,
4
- "version": "0.0.72",
4
+ "version": "0.0.74",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {