quirk-ui 0.0.205 → 0.0.206

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
- import { jsx as i } from "react/jsx-runtime";
2
- import { d as m, i as s, r as l, g as a, s as e, f as n, w as o } from "../../vi.ClIskdbk-CZ8iFAMK.js";
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { d as u, i as o, r as s, g as t, s as a, f as i, w as l } from "../../vi.ClIskdbk-CZ8iFAMK.js";
3
3
  import { Navbar as r } from "./index.js";
4
4
  const c = [
5
5
  { label: "Home", href: "/" },
@@ -18,7 +18,7 @@ const c = [
18
18
  ]
19
19
  },
20
20
  { label: "External", href: "https://example.com", isExternal: !0 }
21
- ], u = [
21
+ ], m = [
22
22
  {
23
23
  title: "Company",
24
24
  primaryItems: [
@@ -34,60 +34,50 @@ const c = [
34
34
  { label: "Careers", href: "/careers" },
35
35
  { label: "Blog", href: "/blog" }
36
36
  ],
37
- spotlight: /* @__PURE__ */ i("div", { children: "Spotlight Content" })
37
+ spotlight: /* @__PURE__ */ n("div", { children: "Spotlight Content" })
38
38
  }
39
39
  ];
40
- m("Navbar (default navigation)", () => {
41
- s("renders all top-level nav items", () => {
42
- l(/* @__PURE__ */ i(r, { navigationType: "default", alignment: "right", items: c })), a(e.getByText("Home")).toBeInTheDocument(), a(e.getByText("Services")).toBeInTheDocument(), a(e.getByText("External")).toBeInTheDocument();
43
- }), s("toggles mobile menu", () => {
44
- l(/* @__PURE__ */ i(r, { navigationType: "default", alignment: "right", items: c }));
45
- const t = e.getByLabelText("Open menu");
46
- n.click(t), a(t).toHaveAttribute("aria-label", "Close menu"), n.click(t), a(t).toHaveAttribute("aria-label", "Open menu");
47
- }), s("open and closes submenu on click", async () => {
48
- l(/* @__PURE__ */ i(r, { navigationType: "default", alignment: "right", items: c }));
49
- const t = e.getByText("Services"), g = e.getByRole("menu", { name: "Services submenu" });
50
- n.click(t), await o(() => {
51
- a(g).toHaveClass("show");
52
- }), n.click(t), await o(() => {
53
- a(g).not.toHaveClass("show");
40
+ u("Navbar (default navigation)", () => {
41
+ o("renders all top-level nav items", () => {
42
+ s(/* @__PURE__ */ n(r, { navigationType: "default", alignment: "right", items: c })), t(a.getByText("Home")).toBeInTheDocument(), t(a.getByText("Services")).toBeInTheDocument(), t(a.getByText("External")).toBeInTheDocument();
43
+ }), o("toggles mobile menu", () => {
44
+ s(/* @__PURE__ */ n(r, { navigationType: "default", alignment: "right", items: c }));
45
+ const e = a.getByLabelText("Open menu");
46
+ i.click(e), t(e).toHaveAttribute("aria-label", "Close menu"), i.click(e), t(e).toHaveAttribute("aria-label", "Open menu");
47
+ }), o("open and closes submenu on click", async () => {
48
+ s(/* @__PURE__ */ n(r, { navigationType: "default", alignment: "right", items: c }));
49
+ const e = a.getByText("Services"), g = a.getByRole("menu", { name: "Services submenu" });
50
+ i.click(e), await l(() => {
51
+ t(g).toHaveClass("show");
52
+ }), i.click(e), await l(() => {
53
+ t(g).not.toHaveClass("show");
54
54
  });
55
- }), s("has appropriate aria attributes", async () => {
56
- l(/* @__PURE__ */ i(r, { navigationType: "default", alignment: "right", items: c }));
57
- const t = e.getByText("Services");
58
- n.click(t), await o(() => {
59
- a(t).toHaveAttribute("aria-expanded", "true");
60
- }), n.click(t), await o(() => {
61
- a(t).toHaveAttribute("aria-expanded", "false");
55
+ }), o("has appropriate aria attributes", async () => {
56
+ s(/* @__PURE__ */ n(r, { navigationType: "default", alignment: "right", items: c }));
57
+ const e = a.getByText("Services");
58
+ i.click(e), await l(() => {
59
+ t(e).toHaveAttribute("aria-expanded", "true");
60
+ }), i.click(e), await l(() => {
61
+ t(e).toHaveAttribute("aria-expanded", "false");
62
62
  });
63
- }), s("only allows one submenu open at a time", async () => {
64
- l(/* @__PURE__ */ i(r, { navigationType: "default", alignment: "right", items: c }));
65
- const t = e.getByText("Services"), g = e.getByText("About");
66
- n.click(t), await o(() => {
67
- a(
68
- e.getByRole("menu", { name: "Services submenu" })
63
+ }), o("only allows one submenu open at a time", async () => {
64
+ s(/* @__PURE__ */ n(r, { navigationType: "default", alignment: "right", items: c }));
65
+ const e = a.getByText("Services"), g = a.getByText("About");
66
+ i.click(e), await l(() => {
67
+ t(
68
+ a.getByRole("menu", { name: "Services submenu" })
69
69
  ).toHaveClass("show");
70
- }), n.click(g), await o(() => {
71
- a(
72
- e.getByRole("menu", { name: "Services submenu" })
70
+ }), i.click(g), await l(() => {
71
+ t(
72
+ a.getByRole("menu", { name: "Services submenu" })
73
73
  ).not.toHaveClass("show");
74
74
  });
75
75
  });
76
76
  });
77
- m("Navbar (advanced navigation with groups)", () => {
78
- s("renders group title", () => {
79
- l(
80
- /* @__PURE__ */ i(r, { alignment: "right", groups: u, navigationType: "advanced" })
81
- ), a(e.getByText("Company")).toBeInTheDocument();
82
- }), s("renders dropdown on hover and shows all columns", async () => {
83
- l(
84
- /* @__PURE__ */ i(r, { alignment: "right", groups: u, navigationType: "advanced" })
85
- );
86
- const t = e.getByText("Company");
87
- n.mouseEnter(t), await o(() => {
88
- a(e.getByText("About")).toBeInTheDocument();
89
- }), n.mouseEnter(e.getByText("About")), await o(() => {
90
- a(e.getByText("Team")).toBeInTheDocument(), a(e.getByText("Careers")).toBeInTheDocument(), a(e.getByText("Spotlight Content")).toBeInTheDocument();
91
- });
77
+ u("Navbar (advanced navigation with groups)", () => {
78
+ o("renders group title", () => {
79
+ s(
80
+ /* @__PURE__ */ n(r, { alignment: "right", groups: m, navigationType: "advanced" })
81
+ ), t(a.getByText("Company")).toBeInTheDocument();
92
82
  });
93
83
  });
@@ -1,124 +1,119 @@
1
- import { jsx as n, jsxs as f } from "react/jsx-runtime";
2
- import { useState as t, useRef as k, useCallback as b, useEffect as _ } from "react";
3
- import { s as e, N as se } from "../../NavLink-D8ccaE3T.js";
4
- import { CallToAction as D } from "../CallToAction/index.js";
5
- import { ButtonGroup as V } from "../ButtonGroup/index.js";
6
- import { X as ie } from "../../x-CnsEH4Ox.js";
7
- import { c as re } from "../../createLucideIcon-C8GTh_Qx.js";
8
- import { C as ce } from "../../chevron-down-DSUzBz9F.js";
1
+ import { jsx as n, jsxs as v } from "react/jsx-runtime";
2
+ import { useState as o, useRef as y, useCallback as b, useEffect as G } from "react";
3
+ import { s as e, N as ne } from "../../NavLink-D8ccaE3T.js";
4
+ import { CallToAction as j } from "../CallToAction/index.js";
5
+ import { ButtonGroup as X } from "../ButtonGroup/index.js";
6
+ import { X as ae } from "../../x-CnsEH4Ox.js";
7
+ import { c as le } from "../../createLucideIcon-C8GTh_Qx.js";
8
+ import { C as se } from "../../chevron-down-DSUzBz9F.js";
9
9
  /**
10
10
  * @license lucide-react v0.488.0 - ISC
11
11
  *
12
12
  * This source code is licensed under the ISC license.
13
13
  * See the LICENSE file in the root directory of this source tree.
14
14
  */
15
- const oe = [
15
+ const ie = [
16
16
  ["line", { x1: "4", x2: "20", y1: "12", y2: "12", key: "1e0a9i" }],
17
17
  ["line", { x1: "4", x2: "20", y1: "6", y2: "6", key: "1owob3" }],
18
18
  ["line", { x1: "4", x2: "20", y1: "18", y2: "18", key: "yk5zj1" }]
19
- ], te = re("menu", oe), de = {
19
+ ], re = le("menu", ie), ce = {
20
20
  default: e.default,
21
21
  minimal: e.minimal
22
- }, he = {
22
+ }, te = {
23
23
  left: e.left,
24
24
  center: e.center,
25
25
  right: e.right
26
26
  };
27
- function Ne({
28
- title: H,
29
- logo: y,
30
- items: x,
31
- groups: C,
27
+ function pe({
28
+ title: _,
29
+ logo: x,
30
+ items: C,
31
+ groups: L,
32
32
  utilityItems: l,
33
- isSticky: U = !1,
34
- isTransparent: q = !1,
33
+ isSticky: D = !1,
34
+ isTransparent: V = !1,
35
35
  alignment: p = "right",
36
- variant: F = "default",
37
- navigationType: L = "default",
38
- className: J
36
+ variant: H = "default",
37
+ navigationType: R = "default",
38
+ className: U
39
39
  }) {
40
- const [o, R] = t(!1), [g, h] = t(null), [K, P] = t(0), [Q, Y] = t(!1), [Z, I] = t(null), w = k(null), m = k(null), S = k(/* @__PURE__ */ new Map()), ee = () => {
41
- R((a) => !a);
42
- }, ne = (a) => {
43
- const s = S.current.get(a);
44
- if (s && m.current) {
45
- const c = s.getBoundingClientRect(), d = m.current.getBoundingClientRect(), i = c.left - d.left + c.width / 4;
46
- I(i);
40
+ const [c, S] = o(!1), [w, m] = o(null), [q, F] = o(0), [J, K] = o(!1), [P, Q] = o(null), g = y(null), h = y(null), M = y(/* @__PURE__ */ new Map()), Y = () => {
41
+ S((a) => !a);
42
+ }, Z = (a) => {
43
+ const s = M.current.get(a);
44
+ if (s && h.current) {
45
+ const t = s.getBoundingClientRect(), d = h.current.getBoundingClientRect(), i = t.left - d.left + t.width / 4;
46
+ Q(i);
47
47
  }
48
- }, ae = (a) => {
49
- h((s) => s === a ? null : a);
50
- }, M = b((a) => {
51
- w.current && !w.current.contains(a.target) && h(null);
48
+ }, I = (a) => {
49
+ m((s) => s === a ? null : a);
50
+ }, A = b((a) => {
51
+ g.current && !g.current.contains(a.target) && m(null);
52
52
  }, []), E = b(() => {
53
- h(null);
54
- }, []), A = b(() => {
55
- T(), typeof window < "u" && window.innerWidth > 768 && (R(!1), h(null), typeof document < "u" && (document.body.style.overflow = ""));
53
+ m(null);
56
54
  }, []), T = b(() => {
57
- if (m.current) {
58
- const a = m.current.getBoundingClientRect().width;
59
- P(a), Y(!0);
55
+ z(), typeof window < "u" && window.innerWidth > 768 && (S(!1), m(null), typeof document < "u" && (document.body.style.overflow = ""));
56
+ }, []), z = b(() => {
57
+ if (h.current) {
58
+ const a = h.current.getBoundingClientRect().width;
59
+ F(a), K(!0);
60
60
  }
61
61
  }, []);
62
- _(() => {
62
+ G(() => {
63
63
  const a = typeof window < "u", s = typeof document < "u";
64
- return a && (window.addEventListener("resize", A), window.addEventListener("scroll", E)), s && document.addEventListener("click", M), T(), () => {
65
- a && (window.removeEventListener("resize", A), window.removeEventListener("scroll", E)), s && document.removeEventListener("click", M);
64
+ return a && (window.addEventListener("resize", T), window.addEventListener("scroll", E)), s && document.addEventListener("click", A), z(), () => {
65
+ a && (window.removeEventListener("resize", T), window.removeEventListener("scroll", E)), s && document.removeEventListener("click", A);
66
66
  };
67
- }, []), _(() => {
67
+ }, []), G(() => {
68
68
  if (typeof document < "u")
69
- return document.body.style.overflow = o ? "hidden" : "", () => {
69
+ return document.body.style.overflow = c ? "hidden" : "", () => {
70
70
  document.body.style.overflow = "";
71
71
  };
72
- }, [o]);
73
- const le = (a) => {
74
- const [s, c] = t(null), [d, N] = t(
72
+ }, [c]);
73
+ const ee = (a) => {
74
+ const [s, t] = o(null), [d, N] = o(
75
75
  null
76
76
  );
77
77
  return console.log("GROUPS", a), a.map((i, u) => {
78
- var O, W, B, G;
79
- const z = `group-${u}`, $ = d === u, r = (O = i.primaryItems) == null ? void 0 : O[s ?? 0];
80
- return /* @__PURE__ */ f(
78
+ var O, W, B;
79
+ const $ = `group-${u}`, k = d === u, r = (O = i.primaryItems) == null ? void 0 : O[s ?? 0];
80
+ return /* @__PURE__ */ v(
81
81
  "div",
82
82
  {
83
83
  className: `${e.linkWrapper} ${e.parent}`,
84
84
  onMouseEnter: () => N(u),
85
85
  onMouseLeave: () => {
86
- N(null), c(null);
86
+ N(null), t(null);
87
87
  },
88
88
  children: [
89
- /* @__PURE__ */ n("div", { className: e.linkItem, children: /* @__PURE__ */ f(
89
+ /* @__PURE__ */ n("div", { className: e.linkItem, children: /* @__PURE__ */ v(
90
90
  "button",
91
91
  {
92
92
  "aria-haspopup": "true",
93
- "aria-expanded": $,
94
- className: `${e.sublinkToggle} ${$ ? e.open : ""} `,
93
+ "aria-expanded": k,
94
+ className: `${e.sublinkToggle} ${k ? e.open : ""} `,
95
95
  children: [
96
96
  i.title,
97
- /* @__PURE__ */ n(ce, { size: 18, className: e.chevron })
97
+ /* @__PURE__ */ n(se, { size: 18, className: e.chevron })
98
98
  ]
99
99
  }
100
100
  ) }),
101
- $ && /* @__PURE__ */ n(
101
+ k && /* @__PURE__ */ n(
102
102
  "div",
103
103
  {
104
104
  className: `${e.sublinks} ${e.show}`,
105
105
  role: "menu",
106
106
  "aria-label": `${i.title} submenu`,
107
- children: /* @__PURE__ */ n("div", { children: /* @__PURE__ */ f("div", { className: e.sublinksInner, children: [
108
- /* @__PURE__ */ n("div", { className: e.sublinksColumn, children: (W = i.primaryItems) == null ? void 0 : W.map((j, X) => /* @__PURE__ */ n(
109
- "div",
110
- {
111
- className: e.linkItem,
112
- onMouseEnter: () => c(X),
113
- children: j.label
114
- },
115
- j._key ?? X
116
- )) }),
117
- (r == null ? void 0 : r.sublinks) && ((B = r == null ? void 0 : r.sublinks) == null ? void 0 : B.length) > 0 && /* @__PURE__ */ n("div", { className: e.sublinksColumn, children: (r == null ? void 0 : r.sublinks) && v(
107
+ children: /* @__PURE__ */ n("div", { children: /* @__PURE__ */ v("div", { className: e.sublinksInner, children: [
108
+ i.primaryItems && /* @__PURE__ */ n("div", { className: e.sublinksColumn, children: f(
109
+ i.primaryItems,
110
+ `${$}-${s}`
111
+ ) }),
112
+ (r == null ? void 0 : r.sublinks) && ((W = r == null ? void 0 : r.sublinks) == null ? void 0 : W.length) > 0 && /* @__PURE__ */ n("div", { className: e.sublinksColumn, children: (r == null ? void 0 : r.sublinks) && f(
118
113
  r.sublinks,
119
- `${z}-${s}`
114
+ `${$}-${s}`
120
115
  ) }),
121
- (i == null ? void 0 : i.secondaryItems) && ((G = i == null ? void 0 : i.secondaryItems) == null ? void 0 : G.length) > 0 && /* @__PURE__ */ n("div", { className: e.sublinksColumn, children: v(i.secondaryItems, `${z}-secondary`) }),
116
+ (i == null ? void 0 : i.secondaryItems) && ((B = i == null ? void 0 : i.secondaryItems) == null ? void 0 : B.length) > 0 && /* @__PURE__ */ n("div", { className: e.sublinksColumn, children: f(i.secondaryItems, `${$}-secondary`) }),
122
117
  i.spotlight && /* @__PURE__ */ n("div", { className: e.sublinksColumn, children: i.spotlight })
123
118
  ] }) })
124
119
  }
@@ -128,20 +123,20 @@ function Ne({
128
123
  u
129
124
  );
130
125
  });
131
- }, v = (a, s = "") => a.map((c) => {
132
- const d = `${s}/${c.label}`;
126
+ }, f = (a, s = "") => a.map((t) => {
127
+ const d = `${s}/${t.label}`;
133
128
  return /* @__PURE__ */ n(
134
- se,
129
+ ne,
135
130
  {
136
- link: c,
131
+ link: t,
137
132
  path: d,
138
133
  parentPath: s,
139
- openPath: g,
140
- togglePath: ae,
141
- updateTriangleIndicator: ne,
142
- setOpenPath: h,
143
- renderLinks: v,
144
- buttonRefs: S
134
+ openPath: w,
135
+ togglePath: I,
136
+ updateTriangleIndicator: Z,
137
+ setOpenPath: m,
138
+ renderLinks: f,
139
+ buttonRefs: M
145
140
  },
146
141
  d
147
142
  );
@@ -149,32 +144,32 @@ function Ne({
149
144
  return /* @__PURE__ */ n(
150
145
  "header",
151
146
  {
152
- ref: w,
153
- className: `${J ?? ""} ${he[p]} ${de[F]} ${e.navbar} ${U ? e.sticky : ""} ${q ? e.transparent : ""} `,
147
+ ref: g,
148
+ className: `${U ?? ""} ${te[p]} ${ce[H]} ${e.navbar} ${D ? e.sticky : ""} ${V ? e.transparent : ""} `,
154
149
  role: "navigation",
155
150
  "aria-label": "Main navigation",
156
- children: /* @__PURE__ */ f(
151
+ children: /* @__PURE__ */ v(
157
152
  "div",
158
153
  {
159
154
  className: `${e.container} ${(!l || l.length === 0) && p !== "center" ? e.twoColumn : ""}`,
160
155
  children: [
161
- y ? /* @__PURE__ */ n("div", { className: e.logo, children: y }) : /* @__PURE__ */ n("div", { className: e.title, children: H }),
156
+ x ? /* @__PURE__ */ n("div", { className: e.logo, children: x }) : /* @__PURE__ */ n("div", { className: e.title, children: _ }),
162
157
  /* @__PURE__ */ n(
163
158
  "nav",
164
159
  {
165
- ref: m,
160
+ ref: h,
166
161
  style: {
167
- left: p === "center" ? `calc(50% - ${K / 2}px)` : "0"
162
+ left: p === "center" ? `calc(50% - ${q / 2}px)` : "0"
168
163
  },
169
- className: `${e.nav} ${o ? e.open : ""} ${Q ? e.visible : e.hidden}`,
164
+ className: `${e.nav} ${c ? e.open : ""} ${J ? e.visible : e.hidden}`,
170
165
  id: "main-menu",
171
166
  role: "menubar",
172
- children: /* @__PURE__ */ f("div", { className: e.navInner, children: [
167
+ children: /* @__PURE__ */ v("div", { className: e.navInner, children: [
173
168
  /* @__PURE__ */ n(
174
169
  "svg",
175
170
  {
176
- style: { left: `${Z}px` },
177
- className: `${e.triangle} ${g ? e.show : ""}`,
171
+ style: { left: `${P}px` },
172
+ className: `${e.triangle} ${w ? e.show : ""}`,
178
173
  width: 16,
179
174
  height: 12,
180
175
  viewBox: "0 0 100 75",
@@ -193,16 +188,16 @@ function Ne({
193
188
  /* @__PURE__ */ n(
194
189
  "div",
195
190
  {
196
- className: `${e.triangle} ${g ? e.show : ""}`
191
+ className: `${e.triangle} ${w ? e.show : ""}`
197
192
  }
198
193
  ),
199
- L === "default" && x && /* @__PURE__ */ n("div", { className: e.grid, children: v(x) }),
200
- L === "advanced" && C && /* @__PURE__ */ n("div", { className: e.grid, children: le(C) })
194
+ R === "default" && C && /* @__PURE__ */ n("div", { className: e.grid, children: f(C) }),
195
+ R === "advanced" && L && /* @__PURE__ */ n("div", { className: e.grid, children: ee(L) })
201
196
  ] })
202
197
  }
203
198
  ),
204
- l && /* @__PURE__ */ n("nav", { className: e.utility, children: /* @__PURE__ */ n(V, { children: l.map((a, s) => /* @__PURE__ */ n(
205
- D,
199
+ l && /* @__PURE__ */ n("nav", { className: e.utility, children: /* @__PURE__ */ n(X, { children: l.map((a, s) => /* @__PURE__ */ n(
200
+ j,
206
201
  {
207
202
  as: "a",
208
203
  href: a.href ?? "/",
@@ -225,9 +220,9 @@ function Ne({
225
220
  l && /* @__PURE__ */ n(
226
221
  "nav",
227
222
  {
228
- className: `${e.utilityMobile} ${o ? e.open : ""}`,
229
- children: /* @__PURE__ */ n(V, { alignment: "center", children: /* @__PURE__ */ n(
230
- D,
223
+ className: `${e.utilityMobile} ${c ? e.open : ""}`,
224
+ children: /* @__PURE__ */ n(X, { alignment: "center", children: /* @__PURE__ */ n(
225
+ j,
231
226
  {
232
227
  as: "a",
233
228
  href: l[1].href ?? "/",
@@ -252,11 +247,11 @@ function Ne({
252
247
  "button",
253
248
  {
254
249
  className: e.menuToggle,
255
- onClick: ee,
256
- "aria-label": o ? "Close menu" : "Open menu",
257
- "aria-expanded": o,
250
+ onClick: Y,
251
+ "aria-label": c ? "Close menu" : "Open menu",
252
+ "aria-expanded": c,
258
253
  "aria-controls": "main-menu",
259
- children: o ? /* @__PURE__ */ n(ie, { size: 24 }) : /* @__PURE__ */ n(te, { size: 24 })
254
+ children: c ? /* @__PURE__ */ n(ae, { size: 24 }) : /* @__PURE__ */ n(re, { size: 24 })
260
255
  }
261
256
  )
262
257
  ]
@@ -266,5 +261,5 @@ function Ne({
266
261
  );
267
262
  }
268
263
  export {
269
- Ne as Navbar
264
+ pe as Navbar
270
265
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "quirk-ui",
3
3
  "private": false,
4
- "version": "0.0.205",
4
+ "version": "0.0.206",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {