quirk-ui 0.0.79 → 0.0.81

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,10 +1,10 @@
1
- import { jsxs as d, jsx as a } from "react/jsx-runtime";
2
- import '../../assets/index23.css';const h = "_avatar_1ihs2_1", u = "_sm_1ihs2_17", f = "_md_1ihs2_23", v = "_lg_1ihs2_29", g = "_xl_1ihs2_35", b = "_image_1ihs2_41", x = "_initials_1ihs2_48", y = "_status_1ihs2_53", p = "_online_1ihs2_65", $ = "_offline_1ihs2_69", N = "_busy_1ihs2_73", s = {
3
- avatar: h,
4
- sm: u,
5
- md: f,
6
- lg: v,
7
- xl: g,
1
+ import { jsxs as h, jsx as i } from "react/jsx-runtime";
2
+ import '../../assets/index23.css';const u = "_avatar_1ihs2_1", f = "_sm_1ihs2_17", d = "_md_1ihs2_23", g = "_lg_1ihs2_29", v = "_xl_1ihs2_35", b = "_image_1ihs2_41", x = "_initials_1ihs2_48", y = "_status_1ihs2_53", p = "_online_1ihs2_65", $ = "_offline_1ihs2_69", N = "_busy_1ihs2_73", s = {
3
+ avatar: u,
4
+ sm: f,
5
+ md: d,
6
+ lg: g,
7
+ xl: v,
8
8
  image: b,
9
9
  initials: x,
10
10
  status: y,
@@ -22,31 +22,31 @@ import '../../assets/index23.css';const h = "_avatar_1ihs2_1", u = "_sm_1ihs2_17
22
22
  busy: s.busy
23
23
  };
24
24
  function z({
25
- src: i,
26
- alt: n = "User avatar",
25
+ src: a,
26
+ alt: t = "User avatar",
27
27
  size: _ = "md",
28
28
  initials: e,
29
- status: t,
30
- borderColor: c = "var(--color-border)",
31
- backgroundColor: r = "var(--color-secondary)",
29
+ status: n,
30
+ borderColor: m,
31
+ backgroundColor: c,
32
32
  onClick: l,
33
- className: m
33
+ className: r
34
34
  }) {
35
35
  const o = !!l;
36
- return /* @__PURE__ */ d(
36
+ return /* @__PURE__ */ h(
37
37
  "div",
38
38
  {
39
- className: `${m ?? ""} ${s.avatar} ${j[_]}`,
40
- style: { borderColor: c, backgroundColor: r },
39
+ className: `${r ?? ""} ${s.avatar} ${j[_]}`,
40
+ style: { borderColor: m, backgroundColor: c },
41
41
  onClick: l,
42
42
  role: o ? "button" : void 0,
43
- "aria-label": o ? n : void 0,
43
+ "aria-label": o ? t : void 0,
44
44
  children: [
45
- i ? /* @__PURE__ */ a("img", { src: i, alt: n, className: s.image }) : /* @__PURE__ */ a("span", { className: s.initials, children: e }),
46
- t && /* @__PURE__ */ a(
45
+ a ? /* @__PURE__ */ i("img", { src: a, alt: t, className: s.image }) : /* @__PURE__ */ i("span", { className: s.initials, children: e }),
46
+ n && /* @__PURE__ */ i(
47
47
  "span",
48
48
  {
49
- className: `${s.status} ${C[t]}`,
49
+ className: `${s.status} ${C[n]}`,
50
50
  role: "status"
51
51
  }
52
52
  )
@@ -1,141 +1,154 @@
1
- import { jsxs as E, jsx as s } from "react/jsx-runtime";
2
- import { useState as o, useRef as X, useEffect as y } from "react";
3
- import { A as vt } from "../../arrow-left-BIJvHwNQ.js";
4
- import { A as bt } from "../../arrow-right-QEwnX3Sk.js";
5
- import '../../assets/index31.css';const ft = "_carousel_zbb4v_1", _t = "_noPointerEvents_zbb4v_9", pt = "_trackContainer_zbb4v_13", mt = "_track_zbb4v_13", wt = "_page_zbb4v_28", Mt = "_controls_zbb4v_34", gt = "_indicators_zbb4v_45", xt = "_indicator_zbb4v_45", $t = "_active_zbb4v_62", zt = "_buttons_zbb4v_66", Ct = "_prev_zbb4v_71", Et = "_disabled_zbb4v_71", Xt = "_next_zbb4v_72", n = {
6
- carousel: ft,
7
- noPointerEvents: _t,
8
- trackContainer: pt,
9
- track: mt,
10
- page: wt,
11
- controls: Mt,
12
- indicators: gt,
13
- indicator: xt,
14
- active: $t,
15
- buttons: zt,
16
- prev: Ct,
17
- disabled: Et,
18
- next: Xt
1
+ import { jsxs as k, jsx as a } from "react/jsx-runtime";
2
+ import { useState as o, useRef as T, useEffect as A } from "react";
3
+ import { A as Mt } from "../../arrow-left-BIJvHwNQ.js";
4
+ import { A as wt } from "../../arrow-right-QEwnX3Sk.js";
5
+ import '../../assets/index31.css';const gt = "_carousel_zbb4v_1", xt = "_noPointerEvents_zbb4v_9", $t = "_trackContainer_zbb4v_13", zt = "_track_zbb4v_13", Ct = "_page_zbb4v_28", Xt = "_controls_zbb4v_34", yt = "_indicators_zbb4v_45", Et = "_indicator_zbb4v_45", It = "_active_zbb4v_62", Nt = "_buttons_zbb4v_66", kt = "_prev_zbb4v_71", Tt = "_disabled_zbb4v_71", At = "_next_zbb4v_72", n = {
6
+ carousel: gt,
7
+ noPointerEvents: xt,
8
+ trackContainer: $t,
9
+ track: zt,
10
+ page: Ct,
11
+ controls: Xt,
12
+ indicators: yt,
13
+ indicator: Et,
14
+ active: It,
15
+ buttons: Nt,
16
+ prev: kt,
17
+ disabled: Tt,
18
+ next: At
19
19
  };
20
- function It({
21
- items: N,
22
- itemsPerPage: f = 9,
23
- itemsPerRow: O = 3,
24
- autoplay: q = !1,
25
- autoplayInterval: k = 3,
26
- className: F,
27
- externalRef: H,
28
- siblingRef: a,
29
- isSplit: T = !1
20
+ function Lt({
21
+ items: p,
22
+ itemsPerPage: r = 9,
23
+ itemsPerRow: F = 3,
24
+ autoplay: H = !1,
25
+ autoplayInterval: W = 3,
26
+ className: J,
27
+ externalRef: K,
28
+ siblingRef: l,
29
+ isSplit: D = !1
30
30
  }) {
31
- const [l, i] = o(0), [h, _] = o(0), [I, J] = o(0), [p, K] = o(f), [W, Q] = o(!1), [A, V] = o(q), Y = X(null), m = X(null), v = X(null), w = H, [D, P] = o(null), [S, L] = o(null), [Z, j] = o(!1), [d, R] = o(null), [M, U] = o(null), tt = (t) => {
32
- console.log(Math.abs((M ?? 0) - (d ?? 0))), Math.abs((M ?? 0) - (d ?? 0)) > 25 && (t.stopPropagation(), t.preventDefault());
33
- }, et = (t) => {
34
- R(t.clientX);
35
- }, nt = (t) => {
36
- d !== null && Math.abs(t.clientX - d) > 5 && (j(!0), U(t.clientX));
37
- }, ot = () => {
38
- if (!d || !M) {
39
- x();
31
+ const [i, d] = o(0), [b, _] = o(0), [S, Q] = o(0), [m, V] = o(r), [M, Z] = o(!1), [P, tt] = o(H), et = T(null), w = T(null), v = T(null), g = K, [x, C] = o(!1), [nt, L] = o(null), [X, Y] = o(null), [j, R] = o(null), [ot, U] = o(!1), [u, B] = o(null), [$, G] = o(null), st = (t) => {
32
+ console.log(Math.abs(($ ?? 0) - (u ?? 0))), Math.abs(($ ?? 0) - (u ?? 0)) > 25 && (t.stopPropagation(), t.preventDefault());
33
+ }, ct = (t) => {
34
+ B(t.clientX);
35
+ }, at = (t) => {
36
+ u !== null && Math.abs(t.clientX - u) > 5 && (U(!0), G(t.clientX));
37
+ }, rt = () => {
38
+ if (!u || !$) {
39
+ y();
40
40
  return;
41
41
  }
42
- const t = d - M;
43
- Math.abs(t) > 50 && (t > 0 ? z() : C()), x();
44
- }, st = () => {
45
- x();
46
- }, x = () => {
47
- j(!1), R(null), U(null);
48
- }, ct = (t) => {
49
- P(t.touches[0].clientX);
50
- }, rt = (t) => {
51
- L(t.touches[0].clientX);
52
- }, at = () => {
53
- if (D === null || S === null) return;
54
- const t = D - S;
55
- Math.abs(t) > 50 && (t > 0 ? z() : C()), P(null), L(null);
56
- }, lt = (t, e) => {
57
- const r = [];
42
+ const t = u - $;
43
+ Math.abs(t) > 50 && (t > 0 ? I() : N()), y();
44
+ }, lt = () => {
45
+ y();
46
+ }, y = () => {
47
+ U(!1), B(null), G(null);
48
+ }, it = (t) => {
49
+ Y(t.touches[0].clientX), L(t.touches[0].clientY), C(!1);
50
+ }, dt = (t) => {
51
+ const e = t.touches[0].clientX - (X ?? 0), s = t.touches[0].clientY - (nt ?? 0);
52
+ !x && Math.abs(e) > Math.abs(s) && C(!0), x && (t.preventDefault(), R(t.touches[0].clientX));
53
+ }, ut = () => {
54
+ if (X === null || j === null) return;
55
+ const t = X - j;
56
+ Math.abs(t) > 50 && (t > 0 ? I() : N()), Y(null), R(null), L(null), C(!1);
57
+ }, ht = (t, e) => {
58
+ const s = [];
58
59
  for (let c = 0; c < t.length; c += e)
59
- r.push(t.slice(c, c + e));
60
- return r;
60
+ s.push(t.slice(c, c + e));
61
+ return s;
61
62
  };
62
- y(() => {
63
+ A(() => {
63
64
  if (typeof window < "u") {
64
65
  const t = () => {
65
- const e = window.innerWidth < 768;
66
- Q(e), K(e ? 1 : f), i(0);
66
+ const e = window.innerWidth < 768, s = e ? 1 : r;
67
+ Z(e), V(e ? 1 : r), d(
68
+ (c) => Math.min(c, Math.ceil(p.length / s) - 1)
69
+ );
67
70
  };
68
71
  return t(), window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
69
72
  }
70
- }, [f]);
71
- const g = Math.ceil(p / O), B = lt(N, p), u = B.length, it = 3 * 16, dt = 6 * 16;
72
- y(() => {
73
+ }, [r]);
74
+ const z = Math.ceil(m / F), O = ht(p, m), h = O.length, bt = 3 * 16, vt = 6 * 16;
75
+ A(() => {
73
76
  const t = new ResizeObserver((e) => {
74
- var r, c;
75
- for (let b of e)
76
- b.contentRect && (W ? _(b.contentRect.width - dt) : T ? a != null && a.current ? _(
77
- b.contentRect.width - ((r = a == null ? void 0 : a.current) == null ? void 0 : r.offsetWidth) - it
78
- ) : _(b.contentRect.width) : (_(b.contentRect.width), J(
79
- ((c = m == null ? void 0 : m.current) == null ? void 0 : c.children[0].children[0].children[0].getBoundingClientRect().width) ?? 0
80
- )), i(0));
77
+ var s, c;
78
+ for (let f of e)
79
+ if (f.contentRect) {
80
+ M ? _(f.contentRect.width - vt) : D ? l != null && l.current ? _(
81
+ f.contentRect.width - ((s = l == null ? void 0 : l.current) == null ? void 0 : s.offsetWidth) - bt
82
+ ) : _(f.contentRect.width) : (_(f.contentRect.width), Q(
83
+ ((c = w == null ? void 0 : w.current) == null ? void 0 : c.children[0].children[0].children[0].getBoundingClientRect().width) ?? 0
84
+ ));
85
+ const _t = M ? 1 : r;
86
+ d(
87
+ (mt) => Math.min(mt, Math.ceil(p.length / _t) - 1)
88
+ );
89
+ }
81
90
  });
82
- return w != null && w.current && t.observe(w.current), () => t.disconnect();
83
- }, [W, T]);
84
- const $ = () => {
85
- v.current && clearInterval(v.current), V(!1);
86
- }, z = () => {
87
- $(), i((t) => Math.min(t + 1, u - 1));
88
- }, C = () => {
89
- $(), i((t) => Math.max(t - 1, 0));
90
- }, ut = (t) => {
91
- $(), i(t);
92
- }, ht = () => h ? `translateX(-${l * h}px)` : "translateX(0px)", G = () => {
93
- i((t) => t >= u - 1 ? 0 : t + 1);
91
+ return g != null && g.current && t.observe(g.current), () => t.disconnect();
92
+ }, [M, D]);
93
+ const E = () => {
94
+ v.current && clearInterval(v.current), tt(!1);
95
+ }, I = () => {
96
+ E(), d((t) => Math.min(t + 1, h - 1));
97
+ }, N = () => {
98
+ E(), d((t) => Math.max(t - 1, 0));
99
+ }, ft = (t) => {
100
+ E(), d(t);
101
+ }, pt = () => b ? `translateX(-${i * b}px)` : "translateX(0px)", q = () => {
102
+ d((t) => t >= h - 1 ? 0 : t + 1);
94
103
  };
95
- return y(() => (A && (v.current = setInterval(
96
- G,
97
- k * 1e3
104
+ return A(() => (P && (v.current = setInterval(
105
+ q,
106
+ W * 1e3
98
107
  )), () => {
99
108
  v.current && clearInterval(v.current);
100
- }), [A, k, G]), /* @__PURE__ */ E("div", { className: `${F ?? ""} ${n.carousel}`, ref: Y, children: [
101
- /* @__PURE__ */ s(
109
+ }), [P, W, q]), /* @__PURE__ */ k("div", { className: `${J ?? ""} ${n.carousel}`, ref: et, children: [
110
+ /* @__PURE__ */ a(
102
111
  "div",
103
112
  {
104
- className: n.trackContainer,
105
- style: { maxWidth: `${h}px` },
106
- onTouchStart: ct,
107
- onTouchMove: rt,
108
- onTouchEnd: at,
109
- onMouseDown: et,
110
- onMouseMove: nt,
111
- onMouseUp: ot,
112
- onMouseLeave: st,
113
- children: /* @__PURE__ */ s(
113
+ className: `${n.trackContainer} ${ot || x ? n.noPointerEvents : ""}
114
+ `,
115
+ style: {
116
+ maxWidth: `${b}px`,
117
+ touchAction: x ? "none" : "pan-y"
118
+ },
119
+ onTouchStart: it,
120
+ onTouchMove: dt,
121
+ onTouchEnd: ut,
122
+ onMouseDown: ct,
123
+ onMouseMove: at,
124
+ onMouseUp: rt,
125
+ onMouseLeave: lt,
126
+ children: /* @__PURE__ */ a(
114
127
  "div",
115
128
  {
116
- ref: m,
117
- className: `${n.track} ${Z ? n.noPointerEvents : ""}`,
118
- style: { width: `${u * 100}%`, transform: ht() },
119
- children: B.map((t, e) => /* @__PURE__ */ s(
129
+ ref: w,
130
+ className: n.track,
131
+ style: { width: `${h * 100}%`, transform: pt() },
132
+ children: O.map((t, e) => /* @__PURE__ */ a(
120
133
  "div",
121
134
  {
122
135
  className: n.page,
123
136
  style: {
124
- display: g > 1 ? "grid" : "flex",
137
+ display: z > 1 ? "grid" : "flex",
125
138
  gridTemplateColumns: `repeat(${Math.ceil(
126
- p / g
139
+ m / z
127
140
  )}, 1fr)`,
128
- gridTemplateRows: `repeat(${g}, auto)`,
129
- width: `${h}px`
141
+ gridTemplateRows: `repeat(${z}, auto)`,
142
+ width: `${b}px`
130
143
  },
131
- children: t.map((r, c) => /* @__PURE__ */ s(
144
+ children: t.map((s, c) => /* @__PURE__ */ a(
132
145
  "div",
133
146
  {
134
- onClickCapture: tt,
147
+ onClickCapture: st,
135
148
  style: {
136
- width: `${h / g - 16}px`
149
+ width: `${b / z - 16}px`
137
150
  },
138
- children: r
151
+ children: s
139
152
  },
140
153
  c
141
154
  ))
@@ -146,42 +159,42 @@ function It({
146
159
  )
147
160
  }
148
161
  ),
149
- u > 1 && /* @__PURE__ */ E(
162
+ h > 1 && /* @__PURE__ */ k(
150
163
  "div",
151
164
  {
152
165
  className: n.controls,
153
166
  style: {
154
- maxWidth: I > 0 && f === 1 ? `${I}px` : "unset"
167
+ maxWidth: S > 0 && r === 1 && !M ? `${S}px` : "unset"
155
168
  },
156
169
  children: [
157
- /* @__PURE__ */ s("div", { className: n.indicators, children: Array.from({ length: u }).map((t, e) => /* @__PURE__ */ s(
170
+ /* @__PURE__ */ a("div", { className: n.indicators, children: Array.from({ length: h }).map((t, e) => /* @__PURE__ */ a(
158
171
  "button",
159
172
  {
160
- className: `${n.indicator} ${e === l ? n.active : ""}`,
161
- onClick: () => ut(e),
173
+ className: `${n.indicator} ${e === i ? n.active : ""}`,
174
+ onClick: () => ft(e),
162
175
  "aria-label": `Go to group ${e + 1}`
163
176
  },
164
177
  e
165
178
  )) }),
166
- /* @__PURE__ */ E("div", { className: n.buttons, children: [
167
- /* @__PURE__ */ s(
179
+ /* @__PURE__ */ k("div", { className: n.buttons, children: [
180
+ /* @__PURE__ */ a(
168
181
  "button",
169
182
  {
170
183
  "aria-label": "Previous slide",
171
- className: `${n.prev} ${l === 0 ? n.disabled : ""}`,
172
- onClick: C,
173
- disabled: l === 0,
174
- children: /* @__PURE__ */ s(vt, { size: 36 })
184
+ className: `${n.prev} ${i === 0 ? n.disabled : ""}`,
185
+ onClick: N,
186
+ disabled: i === 0,
187
+ children: /* @__PURE__ */ a(Mt, { size: 36 })
175
188
  }
176
189
  ),
177
- /* @__PURE__ */ s(
190
+ /* @__PURE__ */ a(
178
191
  "button",
179
192
  {
180
193
  "aria-label": "Next slide",
181
- className: `${n.next} ${l >= u - 1 ? n.disabled : ""}`,
182
- onClick: z,
183
- disabled: l >= N.length - p,
184
- children: /* @__PURE__ */ s(bt, { size: 36 })
194
+ className: `${n.next} ${i >= h - 1 ? n.disabled : ""}`,
195
+ onClick: I,
196
+ disabled: i >= p.length - m,
197
+ children: /* @__PURE__ */ a(wt, { size: 36 })
185
198
  }
186
199
  )
187
200
  ] })
@@ -191,5 +204,5 @@ function It({
191
204
  ] });
192
205
  }
193
206
  export {
194
- It as Carousel
207
+ Lt as Carousel
195
208
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "quirk-ui",
3
3
  "private": false,
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {