quirk-ui 0.0.65 → 0.0.67

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,4 +1,4 @@
1
- import { jsxs as w, jsx as s } from "react/jsx-runtime";
1
+ import { jsxs as g, jsx as s } from "react/jsx-runtime";
2
2
  import { useState as p, useRef as A, useEffect as x } from "react";
3
3
  import { A as F } from "../../arrow-left-BIJvHwNQ.js";
4
4
  import { A as H } from "../../arrow-right-QEwnX3Sk.js";
@@ -27,47 +27,49 @@ function it({
27
27
  siblingRef: c,
28
28
  isSplit: N = !1
29
29
  }) {
30
- const [a, i] = p(0), [d, h] = p(0), [_, P] = p(v), [k, T] = p(!1), [y, L] = p(W), j = A(null), u = A(null), m = E, R = (t, e) => {
30
+ const [a, i] = p(0), [d, h] = p(0), [_, P] = p(v), [y, T] = p(!1), [k, L] = p(W), j = A(null), u = A(null), m = E, R = (t, e) => {
31
31
  const o = [];
32
32
  for (let r = 0; r < t.length; r += e)
33
33
  o.push(t.slice(r, r + e));
34
34
  return o;
35
35
  };
36
36
  x(() => {
37
- const t = () => {
38
- const e = window.innerWidth < 768;
39
- T(e), P(e ? 1 : v), i(0);
40
- };
41
- return t(), window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
37
+ if (typeof window < "u") {
38
+ const t = () => {
39
+ const e = window.innerWidth < 768;
40
+ T(e), P(e ? 1 : v), i(0);
41
+ };
42
+ return t(), window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
43
+ }
42
44
  }, [v]);
43
45
  const f = Math.ceil(_ / M), C = R(b, _), l = C.length, X = 3 * 16, D = 6 * 16;
44
46
  x(() => {
45
47
  const t = new ResizeObserver((e) => {
46
48
  var o;
47
49
  for (let r of e)
48
- r.contentRect && (k ? h(r.contentRect.width - D) : N && c != null && c.current ? h(
50
+ r.contentRect && (y ? h(r.contentRect.width - D) : N && c != null && c.current ? h(
49
51
  r.contentRect.width - ((o = c == null ? void 0 : c.current) == null ? void 0 : o.offsetWidth) - X
50
52
  ) : h(r.contentRect.width), i(0));
51
53
  });
52
54
  return m != null && m.current && t.observe(m.current), () => t.disconnect();
53
- }, [k, N]);
54
- const g = () => {
55
+ }, [y, N]);
56
+ const w = () => {
55
57
  u.current && clearInterval(u.current), L(!1);
56
58
  }, G = () => {
57
- g(), i((t) => Math.min(t + 1, l - 1));
59
+ w(), i((t) => Math.min(t + 1, l - 1));
58
60
  }, O = () => {
59
- g(), i((t) => Math.max(t - 1, 0));
61
+ w(), i((t) => Math.max(t - 1, 0));
60
62
  }, q = (t) => {
61
- g(), i(t);
63
+ w(), i(t);
62
64
  }, B = () => d ? `translateX(-${a * d}px)` : "translateX(0px)", I = () => {
63
65
  i((t) => t >= l - 1 ? 0 : t + 1);
64
66
  };
65
- return x(() => (y && (u.current = setInterval(
67
+ return x(() => (k && (u.current = setInterval(
66
68
  I,
67
69
  $ * 1e3
68
70
  )), () => {
69
71
  u.current && clearInterval(u.current);
70
- }), [y, $, I]), /* @__PURE__ */ w("div", { className: `${z ?? ""} ${n.carousel}`, ref: j, children: [
72
+ }), [k, $, I]), /* @__PURE__ */ g("div", { className: `${z ?? ""} ${n.carousel}`, ref: j, children: [
71
73
  /* @__PURE__ */ s(
72
74
  "div",
73
75
  {
@@ -107,7 +109,7 @@ function it({
107
109
  )
108
110
  }
109
111
  ),
110
- l > 1 && /* @__PURE__ */ w("div", { className: n.controls, children: [
112
+ l > 1 && /* @__PURE__ */ g("div", { className: n.controls, children: [
111
113
  /* @__PURE__ */ s("div", { className: n.indicators, children: Array.from({ length: l }).map((t, e) => /* @__PURE__ */ s(
112
114
  "button",
113
115
  {
@@ -117,7 +119,7 @@ function it({
117
119
  },
118
120
  e
119
121
  )) }),
120
- /* @__PURE__ */ w("div", { className: n.buttons, children: [
122
+ /* @__PURE__ */ g("div", { className: n.buttons, children: [
121
123
  /* @__PURE__ */ s(
122
124
  "button",
123
125
  {
@@ -1,5 +1,5 @@
1
- import { jsx as o, jsxs as d } from "react/jsx-runtime";
2
- import { useState as f, useRef as T, useCallback as m, useEffect as y } from "react";
1
+ import { jsx as s, jsxs as u } from "react/jsx-runtime";
2
+ import { useState as k, useRef as T, useCallback as m, useEffect as w } from "react";
3
3
  import { X as z } from "../../x-CnsEH4Ox.js";
4
4
  import { c as I } from "../../createLucideIcon-C8GTh_Qx.js";
5
5
  import { C as O } from "../../chevron-down-DSUzBz9F.js";
@@ -13,12 +13,12 @@ const W = [
13
13
  ["line", { x1: "4", x2: "20", y1: "12", y2: "12", key: "1e0a9i" }],
14
14
  ["line", { x1: "4", x2: "20", y1: "6", y2: "6", key: "1owob3" }],
15
15
  ["line", { x1: "4", x2: "20", y1: "18", y2: "18", key: "yk5zj1" }]
16
- ], j = I("menu", W), M = "_navbar_12ooa_5", R = "_sticky_12ooa_19", S = "_container_12ooa_25", P = "_logo_12ooa_35", D = "_menuToggle_12ooa_41", X = "_nav_12ooa_5", q = "_linkWrapper_12ooa_57", A = "_linkItem_12ooa_63", B = "_sublinkToggle_12ooa_71", F = "_link_12ooa_57", G = "_sublinks_12ooa_102", H = "_show_12ooa_125", J = "_chevron_12ooa_132", K = "_open_12ooa_136", Q = "_parent_12ooa_178", e = {
16
+ ], j = I("menu", W), M = "_navbar_12ooa_5", R = "_sticky_12ooa_19", S = "_container_12ooa_25", D = "_logo_12ooa_35", P = "_menuToggle_12ooa_41", X = "_nav_12ooa_5", q = "_linkWrapper_12ooa_57", A = "_linkItem_12ooa_63", B = "_sublinkToggle_12ooa_71", F = "_link_12ooa_57", G = "_sublinks_12ooa_102", H = "_show_12ooa_125", J = "_chevron_12ooa_132", K = "_open_12ooa_136", Q = "_parent_12ooa_178", e = {
17
17
  navbar: M,
18
18
  sticky: R,
19
19
  container: S,
20
- logo: P,
21
- menuToggle: D,
20
+ logo: D,
21
+ menuToggle: P,
22
22
  nav: X,
23
23
  linkWrapper: q,
24
24
  linkItem: A,
@@ -31,36 +31,42 @@ const W = [
31
31
  parent: Q
32
32
  };
33
33
  function ne({
34
- logo: w,
34
+ logo: y,
35
35
  items: $,
36
36
  isSticky: x = !1,
37
37
  className: N
38
38
  }) {
39
- const [s, _] = f(!1), [C, l] = f(null), i = T(null), E = () => {
40
- _((a) => !a);
41
- }, L = (a) => {
42
- l((r) => r === a ? null : a);
43
- }, v = m((a) => {
44
- i.current && !i.current.contains(a.target) && l(null);
39
+ const [t, _] = k(!1), [C, l] = k(null), r = T(null), E = () => {
40
+ _((o) => !o);
41
+ }, L = (o) => {
42
+ l((a) => a === o ? null : o);
43
+ }, f = m((o) => {
44
+ r.current && !r.current.contains(o.target) && l(null);
45
45
  }, []), p = m(() => {
46
46
  l(null);
47
- }, []), b = m(() => {
48
- window.innerWidth > 768 && (_(!1), l(null), document.body.style.overflow = "");
47
+ }, []), v = m(() => {
48
+ typeof window < "u" && window.innerWidth > 768 && (_(!1), l(null), typeof document < "u" && (document.body.style.overflow = ""));
49
49
  }, []);
50
- y(() => (window.addEventListener("resize", b), document.addEventListener("click", v), window.addEventListener("scroll", p), () => {
51
- window.removeEventListener("resize", b), document.removeEventListener("click", v), window.removeEventListener("scroll", p);
52
- }), []), y(() => (document.body.style.overflow = s ? "hidden" : "", () => {
53
- document.body.style.overflow = "";
54
- }), [s]);
55
- const h = (a, r = "") => a.map((n) => {
56
- var g;
57
- const t = `${r}/${n.label}`, c = C === t, u = (g = n.sublinks) == null ? void 0 : g.length;
58
- return /* @__PURE__ */ d(
50
+ w(() => {
51
+ const o = typeof window < "u", a = typeof window < "u";
52
+ return o && (window.addEventListener("resize", v), window.addEventListener("scroll", p)), a && document.addEventListener("click", f), () => {
53
+ o && (window.removeEventListener("resize", v), window.removeEventListener("scroll", p)), a && document.removeEventListener("click", f);
54
+ };
55
+ }, []), w(() => {
56
+ if (typeof document < "u")
57
+ return document.body.style.overflow = t ? "hidden" : "", () => {
58
+ document.body.style.overflow = "";
59
+ };
60
+ }, [t]);
61
+ const h = (o, a = "") => o.map((n) => {
62
+ var b;
63
+ const i = `${a}/${n.label}`, c = C === i, d = (b = n.sublinks) == null ? void 0 : b.length;
64
+ return /* @__PURE__ */ u(
59
65
  "div",
60
66
  {
61
- className: `${e.linkWrapper} ${r ? "" : e.parent}`,
67
+ className: `${e.linkWrapper} ${a ? "" : e.parent}`,
62
68
  children: [
63
- /* @__PURE__ */ o("div", { className: e.linkItem, children: n.href ? /* @__PURE__ */ o(
69
+ /* @__PURE__ */ s("div", { className: e.linkItem, children: n.href ? /* @__PURE__ */ s(
64
70
  "a",
65
71
  {
66
72
  href: n.href,
@@ -68,63 +74,63 @@ function ne({
68
74
  target: n.isExternal ? "_blank" : "_self",
69
75
  rel: n.isExternal ? "noopener noreferrer" : void 0,
70
76
  onClick: () => {
71
- var k;
72
- l(null), (k = n.onClick) == null || k.call(n);
77
+ var g;
78
+ l(null), (g = n.onClick) == null || g.call(n);
73
79
  },
74
80
  role: "menuitem",
75
81
  children: n.label
76
82
  }
77
- ) : /* @__PURE__ */ d(
83
+ ) : /* @__PURE__ */ u(
78
84
  "button",
79
85
  {
80
- "aria-haspopup": u ? "true" : void 0,
86
+ "aria-haspopup": d ? "true" : void 0,
81
87
  "aria-expanded": c,
82
88
  className: `${e.sublinkToggle} ${c ? e.open : ""}`,
83
- onClick: () => L(t),
89
+ onClick: () => L(i),
84
90
  children: [
85
91
  n.label,
86
- u && /* @__PURE__ */ o(O, { size: 21, className: e.chevron })
92
+ d && /* @__PURE__ */ s(O, { size: 21, className: e.chevron })
87
93
  ]
88
94
  }
89
95
  ) }),
90
- u && /* @__PURE__ */ o(
96
+ d && /* @__PURE__ */ s(
91
97
  "div",
92
98
  {
93
99
  className: `${e.sublinks} ${c ? e.show : ""}`,
94
100
  role: "menu",
95
101
  "aria-label": `${n.label} submenu`,
96
- children: h(n.sublinks, t)
102
+ children: h(n.sublinks, i)
97
103
  }
98
104
  )
99
105
  ]
100
106
  },
101
- t
107
+ i
102
108
  );
103
109
  });
104
- return /* @__PURE__ */ o(
110
+ return /* @__PURE__ */ s(
105
111
  "header",
106
112
  {
107
- ref: i,
113
+ ref: r,
108
114
  className: `${N ?? ""} ${e.navbar} ${x ? e.sticky : ""} `,
109
115
  role: "navigation",
110
116
  "aria-label": "Main navigation",
111
- children: /* @__PURE__ */ d("div", { className: e.container, children: [
112
- /* @__PURE__ */ o("div", { className: e.logo, children: w }),
113
- /* @__PURE__ */ o(
117
+ children: /* @__PURE__ */ u("div", { className: e.container, children: [
118
+ /* @__PURE__ */ s("div", { className: e.logo, children: y }),
119
+ /* @__PURE__ */ s(
114
120
  "button",
115
121
  {
116
122
  className: e.menuToggle,
117
123
  onClick: E,
118
- "aria-label": s ? "Close menu" : "Open menu",
119
- "aria-expanded": s,
124
+ "aria-label": t ? "Close menu" : "Open menu",
125
+ "aria-expanded": t,
120
126
  "aria-controls": "main-menu",
121
- children: s ? /* @__PURE__ */ o(z, { size: 24 }) : /* @__PURE__ */ o(j, { size: 24 })
127
+ children: t ? /* @__PURE__ */ s(z, { size: 24 }) : /* @__PURE__ */ s(j, { size: 24 })
122
128
  }
123
129
  ),
124
- /* @__PURE__ */ o(
130
+ /* @__PURE__ */ s(
125
131
  "nav",
126
132
  {
127
- className: `${e.nav} ${s ? e.open : ""}`,
133
+ className: `${e.nav} ${t ? e.open : ""}`,
128
134
  id: "main-menu",
129
135
  role: "menubar",
130
136
  children: h($)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "quirk-ui",
3
3
  "private": false,
4
- "version": "0.0.65",
4
+ "version": "0.0.67",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {