quirk-ui 0.0.51 → 0.0.53

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