quirk-ui 0.0.50 → 0.0.51

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