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
|
|
2
|
-
import { d as
|
|
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
|
-
],
|
|
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__ */
|
|
37
|
+
spotlight: /* @__PURE__ */ n("div", { children: "Spotlight Content" })
|
|
38
38
|
}
|
|
39
39
|
];
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}),
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
}),
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}),
|
|
53
|
-
|
|
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
|
-
}),
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}),
|
|
61
|
-
|
|
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
|
-
}),
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
}),
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
), a
|
|
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
|
|
2
|
-
import { useState as
|
|
3
|
-
import { s as e, N as
|
|
4
|
-
import { CallToAction as
|
|
5
|
-
import { ButtonGroup as
|
|
6
|
-
import { X as
|
|
7
|
-
import { c as
|
|
8
|
-
import { C as
|
|
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
|
|
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
|
-
],
|
|
19
|
+
], re = le("menu", ie), ce = {
|
|
20
20
|
default: e.default,
|
|
21
21
|
minimal: e.minimal
|
|
22
|
-
},
|
|
22
|
+
}, te = {
|
|
23
23
|
left: e.left,
|
|
24
24
|
center: e.center,
|
|
25
25
|
right: e.right
|
|
26
26
|
};
|
|
27
|
-
function
|
|
28
|
-
title:
|
|
29
|
-
logo:
|
|
30
|
-
items:
|
|
31
|
-
groups:
|
|
27
|
+
function pe({
|
|
28
|
+
title: _,
|
|
29
|
+
logo: x,
|
|
30
|
+
items: C,
|
|
31
|
+
groups: L,
|
|
32
32
|
utilityItems: l,
|
|
33
|
-
isSticky:
|
|
34
|
-
isTransparent:
|
|
33
|
+
isSticky: D = !1,
|
|
34
|
+
isTransparent: V = !1,
|
|
35
35
|
alignment: p = "right",
|
|
36
|
-
variant:
|
|
37
|
-
navigationType:
|
|
38
|
-
className:
|
|
36
|
+
variant: H = "default",
|
|
37
|
+
navigationType: R = "default",
|
|
38
|
+
className: U
|
|
39
39
|
}) {
|
|
40
|
-
const [
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
const s =
|
|
44
|
-
if (s &&
|
|
45
|
-
const
|
|
46
|
-
|
|
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
|
-
},
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
|
|
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
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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",
|
|
65
|
-
a && (window.removeEventListener("resize",
|
|
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 =
|
|
69
|
+
return document.body.style.overflow = c ? "hidden" : "", () => {
|
|
70
70
|
document.body.style.overflow = "";
|
|
71
71
|
};
|
|
72
|
-
}, [
|
|
73
|
-
const
|
|
74
|
-
const [s,
|
|
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
|
|
79
|
-
const
|
|
80
|
-
return /* @__PURE__ */
|
|
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),
|
|
86
|
+
N(null), t(null);
|
|
87
87
|
},
|
|
88
88
|
children: [
|
|
89
|
-
/* @__PURE__ */ n("div", { className: e.linkItem, children: /* @__PURE__ */
|
|
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} ${
|
|
93
|
+
"aria-expanded": k,
|
|
94
|
+
className: `${e.sublinkToggle} ${k ? e.open : ""} `,
|
|
95
95
|
children: [
|
|
96
96
|
i.title,
|
|
97
|
-
/* @__PURE__ */ n(
|
|
97
|
+
/* @__PURE__ */ n(se, { size: 18, className: e.chevron })
|
|
98
98
|
]
|
|
99
99
|
}
|
|
100
100
|
) }),
|
|
101
|
-
|
|
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__ */
|
|
108
|
-
/* @__PURE__ */ n("div", { className: e.sublinksColumn, children: (
|
|
109
|
-
|
|
110
|
-
{
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
`${
|
|
114
|
+
`${$}-${s}`
|
|
120
115
|
) }),
|
|
121
|
-
(i == null ? void 0 : i.secondaryItems) && ((
|
|
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
|
-
},
|
|
132
|
-
const d = `${s}/${
|
|
126
|
+
}, f = (a, s = "") => a.map((t) => {
|
|
127
|
+
const d = `${s}/${t.label}`;
|
|
133
128
|
return /* @__PURE__ */ n(
|
|
134
|
-
|
|
129
|
+
ne,
|
|
135
130
|
{
|
|
136
|
-
link:
|
|
131
|
+
link: t,
|
|
137
132
|
path: d,
|
|
138
133
|
parentPath: s,
|
|
139
|
-
openPath:
|
|
140
|
-
togglePath:
|
|
141
|
-
updateTriangleIndicator:
|
|
142
|
-
setOpenPath:
|
|
143
|
-
renderLinks:
|
|
144
|
-
buttonRefs:
|
|
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:
|
|
153
|
-
className: `${
|
|
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__ */
|
|
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
|
-
|
|
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:
|
|
160
|
+
ref: h,
|
|
166
161
|
style: {
|
|
167
|
-
left: p === "center" ? `calc(50% - ${
|
|
162
|
+
left: p === "center" ? `calc(50% - ${q / 2}px)` : "0"
|
|
168
163
|
},
|
|
169
|
-
className: `${e.nav} ${
|
|
164
|
+
className: `${e.nav} ${c ? e.open : ""} ${J ? e.visible : e.hidden}`,
|
|
170
165
|
id: "main-menu",
|
|
171
166
|
role: "menubar",
|
|
172
|
-
children: /* @__PURE__ */
|
|
167
|
+
children: /* @__PURE__ */ v("div", { className: e.navInner, children: [
|
|
173
168
|
/* @__PURE__ */ n(
|
|
174
169
|
"svg",
|
|
175
170
|
{
|
|
176
|
-
style: { left: `${
|
|
177
|
-
className: `${e.triangle} ${
|
|
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} ${
|
|
191
|
+
className: `${e.triangle} ${w ? e.show : ""}`
|
|
197
192
|
}
|
|
198
193
|
),
|
|
199
|
-
|
|
200
|
-
|
|
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(
|
|
205
|
-
|
|
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} ${
|
|
229
|
-
children: /* @__PURE__ */ n(
|
|
230
|
-
|
|
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:
|
|
256
|
-
"aria-label":
|
|
257
|
-
"aria-expanded":
|
|
250
|
+
onClick: Y,
|
|
251
|
+
"aria-label": c ? "Close menu" : "Open menu",
|
|
252
|
+
"aria-expanded": c,
|
|
258
253
|
"aria-controls": "main-menu",
|
|
259
|
-
children:
|
|
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
|
-
|
|
264
|
+
pe as Navbar
|
|
270
265
|
};
|