quirk-ui 0.0.30 → 0.0.31

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,5 +1,5 @@
1
1
  import { jsxs as h, jsx as o } from "react/jsx-runtime";
2
- import { useState as _, useRef as A, useEffect as b } from "react";
2
+ import { useState as _, useRef as A, useEffect as f } from "react";
3
3
  import { A as C } from "../../arrow-left-BIJvHwNQ.js";
4
4
  import { A as I } from "../../arrow-right-QEwnX3Sk.js";
5
5
  import '../../assets/index31.css';const M = "_carousel_1h8mt_5", S = "_track_1h8mt_12", W = "_slide_1h8mt_18", E = "_controls_1h8mt_30", L = "_indicators_1h8mt_47", R = "_indicator_1h8mt_47", j = "_active_1h8mt_62", z = "_buttons_1h8mt_66", G = "_prev_1h8mt_71", T = "_disabled_1h8mt_71", V = "_next_1h8mt_72", e = {
@@ -19,73 +19,73 @@ function H({
19
19
  items: c,
20
20
  autoPlay: r = !1,
21
21
  autoPlayInterval: m = 3e3,
22
- className: u
22
+ className: b
23
23
  }) {
24
- const [n, l] = _(0), [i, v] = _(1), [N, $] = _(!1), a = A(null), p = n === 0, g = n === c.length - 1, f = Math.ceil(c.length / i);
25
- b(() => {
24
+ const [i, l] = _(0), [s, u] = _(3), [v, N] = _(!1), a = A(null), $ = i === 0, g = i === c.length - 1, p = Math.ceil(c.length / s);
25
+ f(() => {
26
26
  const t = () => {
27
27
  l(0);
28
- const s = window.innerWidth < 768;
29
- $(s), v(s ? 1 : 3);
28
+ const n = window.innerWidth < 768;
29
+ N(n), u(n ? 1 : 3);
30
30
  };
31
31
  return t(), window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
32
32
  }, []);
33
33
  const d = () => {
34
34
  (r || !g) && l(
35
- (t) => t < c.length - i ? t + i : t
35
+ (t) => t < c.length - s ? t + s : t
36
36
  );
37
37
  }, w = () => {
38
- (r || !p) && l((t) => t > 0 ? t - i : 0);
38
+ (r || !$) && l((t) => t > 0 ? t - s : 0);
39
39
  }, x = (t) => {
40
- l(t * i);
40
+ l(t * s);
41
41
  };
42
- b(() => (r && (a.current = setInterval(d, m)), () => {
42
+ f(() => (r && (a.current = setInterval(d, m)), () => {
43
43
  a.current && clearInterval(a.current);
44
44
  }), [r, m, d]);
45
45
  const k = () => {
46
- if (N)
47
- return `translateX(calc(-${n * 80}% + 10%))`;
48
- const t = 100 / i;
49
- return `translateX(-${n * t}%)`;
46
+ if (v)
47
+ return `translateX(calc(-${i * 80}% + 10%))`;
48
+ const t = 100 / s;
49
+ return `translateX(-${i * t}%)`;
50
50
  };
51
- return /* @__PURE__ */ h("div", { className: `${u ?? ""} ${e.carousel}`, children: [
51
+ return /* @__PURE__ */ h("div", { className: `${b ?? ""} ${e.carousel}`, children: [
52
52
  /* @__PURE__ */ o(
53
53
  "div",
54
54
  {
55
55
  className: e.track,
56
56
  style: { transform: k() },
57
57
  role: "list",
58
- children: c.map((t, s) => /* @__PURE__ */ o("div", { className: e.slide, children: t }, s))
58
+ children: c.map((t, n) => /* @__PURE__ */ o("div", { className: e.slide, children: t }, n))
59
59
  }
60
60
  ),
61
- f > 1 && /* @__PURE__ */ h("div", { className: e.controls, children: [
62
- /* @__PURE__ */ o("div", { className: e.indicators, children: Array.from({ length: f }).map((t, s) => /* @__PURE__ */ o(
61
+ c.length > s && /* @__PURE__ */ h("div", { className: e.controls, children: [
62
+ /* @__PURE__ */ o("div", { className: e.indicators, children: Array.from({ length: p }).map((t, n) => /* @__PURE__ */ o(
63
63
  "button",
64
64
  {
65
- className: `${e.indicator} ${s === Math.floor(n / i) ? e.active : ""}`,
66
- onClick: () => x(s),
67
- "aria-label": `Go to group ${s + 1}`
65
+ className: `${e.indicator} ${n === Math.floor(i / s) ? e.active : ""}`,
66
+ onClick: () => x(n),
67
+ "aria-label": `Go to group ${n + 1}`
68
68
  },
69
- s
69
+ n
70
70
  )) }),
71
71
  /* @__PURE__ */ h("div", { className: e.buttons, children: [
72
72
  /* @__PURE__ */ o(
73
73
  "button",
74
74
  {
75
- className: `${e.prev} ${!r && n === 0 ? e.disabled : ""}`,
75
+ className: `${e.prev} ${!r && i === 0 ? e.disabled : ""}`,
76
76
  onClick: w,
77
77
  "aria-label": "Previous slide",
78
- disabled: !r && n === 0,
78
+ disabled: !r && i === 0,
79
79
  children: /* @__PURE__ */ o(C, {})
80
80
  }
81
81
  ),
82
82
  /* @__PURE__ */ o(
83
83
  "button",
84
84
  {
85
- className: `${e.next} ${!r && n >= c.length - i ? e.disabled : ""}`,
85
+ className: `${e.next} ${!r && i >= c.length - s ? e.disabled : ""}`,
86
86
  onClick: d,
87
87
  "aria-label": "Next slide",
88
- disabled: !r && n >= c.length - i,
88
+ disabled: !r && i >= c.length - s,
89
89
  children: /* @__PURE__ */ o(I, {})
90
90
  }
91
91
  )
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "quirk-ui",
3
3
  "private": false,
4
- "version": "0.0.30",
4
+ "version": "0.0.31",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {