quirk-ui 0.0.182 → 0.0.183
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,7 +1,7 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as u, useRef as m, useCallback as f, useEffect as
|
|
3
|
-
import { CallToAction as
|
|
4
|
-
import { ButtonGroup as
|
|
1
|
+
import { jsx as t, jsxs as _ } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u, useRef as m, useCallback as f, useEffect as R } from "react";
|
|
3
|
+
import { CallToAction as W } from "../CallToAction/index.js";
|
|
4
|
+
import { ButtonGroup as z } from "../ButtonGroup/index.js";
|
|
5
5
|
import { X as J } from "../../x-CnsEH4Ox.js";
|
|
6
6
|
import { c as K } from "../../createLucideIcon-C8GTh_Qx.js";
|
|
7
7
|
import { C as Q } from "../../chevron-down-DSUzBz9F.js";
|
|
@@ -15,182 +15,182 @@ const U = [
|
|
|
15
15
|
["line", { x1: "4", x2: "20", y1: "12", y2: "12", key: "1e0a9i" }],
|
|
16
16
|
["line", { x1: "4", x2: "20", y1: "6", y2: "6", key: "1owob3" }],
|
|
17
17
|
["line", { x1: "4", x2: "20", y1: "18", y2: "18", key: "yk5zj1" }]
|
|
18
|
-
], Y = K("menu", U), Z = "_navbar_937v2_5", ee = "_left_937v2_18", ne = "_container_937v2_19", te = "_logo_937v2_23",
|
|
18
|
+
], Y = K("menu", U), Z = "_navbar_937v2_5", ee = "_left_937v2_18", ne = "_container_937v2_19", te = "_logo_937v2_23", le = "_nav_937v2_5", ie = "_center_937v2_38", ae = "_hidden_937v2_44", oe = "_visible_937v2_51", se = "_right_937v2_66", re = "_title_937v2_72", ce = "_sublinks_937v2_82", de = "_sublinksInner_937v2_94", ue = "_linkItem_937v2_108", ve = "_minimal_937v2_113", _e = "_menuToggle_937v2_117", me = "_linkWrapper_937v2_121", fe = "_triangle_937v2_159", he = "_transparent_937v2_164", pe = "_sticky_937v2_216", ge = "_twoColumn_937v2_245", be = "_utilityMobile_937v2_292", we = "_utility_937v2_292", ye = "_navInner_937v2_320", ke = "_grid_937v2_329", $e = "_sublinkToggle_937v2_354", Ne = "_link_937v2_108", Ce = "_open_937v2_368", xe = "_show_937v2_419", Te = "_sublinksColumn_937v2_467", Le = "_chevron_937v2_477", Me = "_parent_937v2_556", e = {
|
|
19
19
|
navbar: Z,
|
|
20
20
|
left: ee,
|
|
21
21
|
container: ne,
|
|
22
22
|
logo: te,
|
|
23
|
-
nav:
|
|
24
|
-
center:
|
|
25
|
-
hidden:
|
|
26
|
-
visible:
|
|
27
|
-
right:
|
|
28
|
-
title:
|
|
23
|
+
nav: le,
|
|
24
|
+
center: ie,
|
|
25
|
+
hidden: ae,
|
|
26
|
+
visible: oe,
|
|
27
|
+
right: se,
|
|
28
|
+
title: re,
|
|
29
29
|
default: "_default_937v2_81",
|
|
30
30
|
sublinks: ce,
|
|
31
31
|
sublinksInner: de,
|
|
32
32
|
linkItem: ue,
|
|
33
|
-
minimal:
|
|
34
|
-
menuToggle:
|
|
33
|
+
minimal: ve,
|
|
34
|
+
menuToggle: _e,
|
|
35
35
|
linkWrapper: me,
|
|
36
36
|
triangle: fe,
|
|
37
37
|
transparent: he,
|
|
38
|
-
sticky:
|
|
39
|
-
twoColumn:
|
|
38
|
+
sticky: pe,
|
|
39
|
+
twoColumn: ge,
|
|
40
40
|
utilityMobile: be,
|
|
41
41
|
utility: we,
|
|
42
|
-
navInner:
|
|
43
|
-
grid:
|
|
42
|
+
navInner: ye,
|
|
43
|
+
grid: ke,
|
|
44
44
|
sublinkToggle: $e,
|
|
45
45
|
link: Ne,
|
|
46
46
|
open: Ce,
|
|
47
47
|
show: xe,
|
|
48
|
-
sublinksColumn:
|
|
48
|
+
sublinksColumn: Te,
|
|
49
49
|
chevron: Le,
|
|
50
|
-
parent:
|
|
51
|
-
},
|
|
50
|
+
parent: Me
|
|
51
|
+
}, Ee = {
|
|
52
52
|
default: e.default,
|
|
53
53
|
minimal: e.minimal
|
|
54
|
-
},
|
|
54
|
+
}, Re = {
|
|
55
55
|
left: e.left,
|
|
56
56
|
center: e.center,
|
|
57
57
|
right: e.right
|
|
58
58
|
};
|
|
59
|
-
function
|
|
60
|
-
title:
|
|
59
|
+
function Xe({
|
|
60
|
+
title: S,
|
|
61
61
|
logo: b,
|
|
62
62
|
items: O,
|
|
63
|
-
utilityItems:
|
|
64
|
-
isSticky:
|
|
65
|
-
isTransparent:
|
|
63
|
+
utilityItems: i,
|
|
64
|
+
isSticky: A = !1,
|
|
65
|
+
isTransparent: B = !1,
|
|
66
66
|
alignment: h = "right",
|
|
67
|
-
variant:
|
|
68
|
-
className:
|
|
67
|
+
variant: j = "default",
|
|
68
|
+
className: X
|
|
69
69
|
}) {
|
|
70
|
-
const [
|
|
71
|
-
w((
|
|
72
|
-
}, H = (
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
const
|
|
70
|
+
const [s, w] = u(!1), [p, r] = u(null), [I, D] = u(0), [V, G] = u(!1), [P, q] = u(null), g = m(null), c = m(null), y = m(/* @__PURE__ */ new Map()), F = () => {
|
|
71
|
+
w((n) => !n);
|
|
72
|
+
}, H = (n) => {
|
|
73
|
+
const a = y.current.get(n);
|
|
74
|
+
if (a && c.current) {
|
|
75
|
+
const l = a.getBoundingClientRect(), o = c.current.getBoundingClientRect(), d = l.left - o.left + l.width / 4;
|
|
76
76
|
q(d);
|
|
77
77
|
}
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
}, $ = f((
|
|
81
|
-
|
|
78
|
+
}, k = (n) => {
|
|
79
|
+
r((a) => a === n ? null : n);
|
|
80
|
+
}, $ = f((n) => {
|
|
81
|
+
g.current && !g.current.contains(n.target) && r(null);
|
|
82
82
|
}, []), N = f(() => {
|
|
83
|
-
|
|
83
|
+
r(null);
|
|
84
84
|
}, []), C = f(() => {
|
|
85
|
-
x(), typeof window < "u" && window.innerWidth > 768 && (w(!1),
|
|
85
|
+
x(), typeof window < "u" && window.innerWidth > 768 && (w(!1), r(null), typeof document < "u" && (document.body.style.overflow = ""));
|
|
86
86
|
}, []), x = f(() => {
|
|
87
87
|
if (c.current) {
|
|
88
|
-
const
|
|
89
|
-
|
|
88
|
+
const n = c.current.getBoundingClientRect().width;
|
|
89
|
+
D(n), G(!0);
|
|
90
90
|
}
|
|
91
91
|
}, []);
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
return
|
|
95
|
-
|
|
92
|
+
R(() => {
|
|
93
|
+
const n = typeof window < "u", a = typeof document < "u";
|
|
94
|
+
return n && (window.addEventListener("resize", C), window.addEventListener("scroll", N)), a && document.addEventListener("click", $), x(), () => {
|
|
95
|
+
n && (window.removeEventListener("resize", C), window.removeEventListener("scroll", N)), a && document.removeEventListener("click", $);
|
|
96
96
|
};
|
|
97
|
-
}, []),
|
|
97
|
+
}, []), R(() => {
|
|
98
98
|
if (typeof document < "u")
|
|
99
|
-
return document.body.style.overflow =
|
|
99
|
+
return document.body.style.overflow = s ? "hidden" : "", () => {
|
|
100
100
|
document.body.style.overflow = "";
|
|
101
101
|
};
|
|
102
|
-
}, [
|
|
103
|
-
const
|
|
104
|
-
var
|
|
105
|
-
const
|
|
106
|
-
return
|
|
102
|
+
}, [s]);
|
|
103
|
+
const T = (n, a = "") => n.map((l) => {
|
|
104
|
+
var M;
|
|
105
|
+
const o = `${a}/${l.label}`, v = p === o, d = (M = l.sublinks) == null ? void 0 : M.length, L = m(null);
|
|
106
|
+
return y.current.set(o, L.current), /* @__PURE__ */ _(
|
|
107
107
|
"div",
|
|
108
108
|
{
|
|
109
|
-
className: `${e.linkWrapper} ${
|
|
109
|
+
className: `${e.linkWrapper} ${a ? "" : e.parent}`,
|
|
110
110
|
children: [
|
|
111
|
-
/* @__PURE__ */
|
|
111
|
+
/* @__PURE__ */ t("div", { className: e.linkItem, children: l.href ? /* @__PURE__ */ t(
|
|
112
112
|
"a",
|
|
113
113
|
{
|
|
114
|
-
href:
|
|
114
|
+
href: l.href,
|
|
115
115
|
className: e.link,
|
|
116
|
-
target:
|
|
117
|
-
rel:
|
|
116
|
+
target: l.isExternal ? "_blank" : "_self",
|
|
117
|
+
rel: l.isExternal ? "noopener noreferrer" : void 0,
|
|
118
118
|
onClick: () => {
|
|
119
|
-
var
|
|
120
|
-
|
|
119
|
+
var E;
|
|
120
|
+
r(null), (E = l.onClick) == null || E.call(l);
|
|
121
121
|
},
|
|
122
122
|
onMouseEnter: () => {
|
|
123
|
-
|
|
123
|
+
a || r(null);
|
|
124
124
|
},
|
|
125
125
|
role: "menuitem",
|
|
126
|
-
children:
|
|
126
|
+
children: l.label
|
|
127
127
|
}
|
|
128
|
-
) : /* @__PURE__ */
|
|
128
|
+
) : /* @__PURE__ */ _(
|
|
129
129
|
"button",
|
|
130
130
|
{
|
|
131
131
|
ref: L,
|
|
132
132
|
"aria-haspopup": d ? "true" : void 0,
|
|
133
|
-
"aria-expanded":
|
|
134
|
-
className: `${e.sublinkToggle} ${
|
|
135
|
-
onClick: () =>
|
|
133
|
+
"aria-expanded": v,
|
|
134
|
+
className: `${e.sublinkToggle} ${v ? e.open : ""}`,
|
|
135
|
+
onClick: () => k(o),
|
|
136
136
|
onMouseEnter: () => {
|
|
137
|
-
H(
|
|
137
|
+
H(o), r(o);
|
|
138
138
|
},
|
|
139
139
|
children: [
|
|
140
|
-
|
|
141
|
-
d && /* @__PURE__ */
|
|
140
|
+
l.label,
|
|
141
|
+
d && /* @__PURE__ */ t(Q, { size: 18, className: e.chevron })
|
|
142
142
|
]
|
|
143
143
|
}
|
|
144
144
|
) }),
|
|
145
|
-
d && /* @__PURE__ */
|
|
145
|
+
d && /* @__PURE__ */ t(
|
|
146
146
|
"div",
|
|
147
147
|
{
|
|
148
|
-
className: `${e.sublinks} ${
|
|
149
|
-
onMouseLeave: () =>
|
|
148
|
+
className: `${e.sublinks} ${v ? e.show : ""}`,
|
|
149
|
+
onMouseLeave: () => k(o),
|
|
150
150
|
role: "menu",
|
|
151
|
-
"aria-label": `${
|
|
152
|
-
children: /* @__PURE__ */
|
|
151
|
+
"aria-label": `${l.label} submenu`,
|
|
152
|
+
children: /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t("div", { className: e.sublinksInner, children: /* @__PURE__ */ t("div", { className: e.sublinksColumn, children: T(l.sublinks, o) }) }) })
|
|
153
153
|
}
|
|
154
154
|
)
|
|
155
155
|
]
|
|
156
156
|
},
|
|
157
|
-
|
|
157
|
+
o
|
|
158
158
|
);
|
|
159
159
|
});
|
|
160
|
-
return /* @__PURE__ */
|
|
160
|
+
return /* @__PURE__ */ t(
|
|
161
161
|
"header",
|
|
162
162
|
{
|
|
163
|
-
ref:
|
|
164
|
-
className: `${
|
|
163
|
+
ref: g,
|
|
164
|
+
className: `${X ?? ""} ${Re[h]} ${Ee[j]} ${e.navbar} ${A ? e.sticky : ""} ${B ? e.transparent : ""} `,
|
|
165
165
|
role: "navigation",
|
|
166
166
|
"aria-label": "Main navigation",
|
|
167
|
-
children: /* @__PURE__ */
|
|
167
|
+
children: /* @__PURE__ */ _(
|
|
168
168
|
"div",
|
|
169
169
|
{
|
|
170
|
-
className: `${e.container} ${(!
|
|
170
|
+
className: `${e.container} ${(!i || i.length === 0) && h !== "center" ? e.twoColumn : ""}`,
|
|
171
171
|
children: [
|
|
172
|
-
b ? /* @__PURE__ */
|
|
173
|
-
/* @__PURE__ */
|
|
172
|
+
b ? /* @__PURE__ */ t("div", { className: e.logo, children: b }) : /* @__PURE__ */ t("div", { className: e.title, children: S }),
|
|
173
|
+
/* @__PURE__ */ t(
|
|
174
174
|
"nav",
|
|
175
175
|
{
|
|
176
176
|
ref: c,
|
|
177
177
|
style: {
|
|
178
|
-
left: h === "center" ? `calc(50% - ${
|
|
178
|
+
left: h === "center" ? `calc(50% - ${I / 2}px)` : "0"
|
|
179
179
|
},
|
|
180
|
-
className: `${e.nav} ${
|
|
180
|
+
className: `${e.nav} ${s ? e.open : ""} ${V ? e.visible : e.hidden}`,
|
|
181
181
|
id: "main-menu",
|
|
182
182
|
role: "menubar",
|
|
183
|
-
children: /* @__PURE__ */
|
|
184
|
-
/* @__PURE__ */
|
|
183
|
+
children: /* @__PURE__ */ _("div", { className: e.navInner, children: [
|
|
184
|
+
/* @__PURE__ */ t(
|
|
185
185
|
"svg",
|
|
186
186
|
{
|
|
187
187
|
style: { left: `${P}px` },
|
|
188
|
-
className: `${e.triangle} ${
|
|
188
|
+
className: `${e.triangle} ${p ? e.show : ""}`,
|
|
189
189
|
width: 16,
|
|
190
190
|
height: 12,
|
|
191
191
|
viewBox: "0 0 100 75",
|
|
192
192
|
xmlns: "http://www.w3.org/2000/svg",
|
|
193
|
-
children: /* @__PURE__ */
|
|
193
|
+
children: /* @__PURE__ */ t(
|
|
194
194
|
"polygon",
|
|
195
195
|
{
|
|
196
196
|
points: "50,5 95,70 5,70",
|
|
@@ -201,51 +201,58 @@ function Se({
|
|
|
201
201
|
)
|
|
202
202
|
}
|
|
203
203
|
),
|
|
204
|
-
/* @__PURE__ */
|
|
204
|
+
/* @__PURE__ */ t(
|
|
205
205
|
"div",
|
|
206
206
|
{
|
|
207
|
-
className: `${e.triangle} ${
|
|
207
|
+
className: `${e.triangle} ${p ? e.show : ""}`
|
|
208
208
|
}
|
|
209
209
|
),
|
|
210
|
-
/* @__PURE__ */
|
|
210
|
+
/* @__PURE__ */ t("div", { className: e.grid, children: T(O) })
|
|
211
211
|
] })
|
|
212
212
|
}
|
|
213
213
|
),
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
i && /* @__PURE__ */ t("nav", { className: e.utility, children: /* @__PURE__ */ t(z, { children: i.map((n, a) => /* @__PURE__ */ t(
|
|
215
|
+
W,
|
|
216
216
|
{
|
|
217
217
|
as: "a",
|
|
218
|
-
href:
|
|
219
|
-
variant:
|
|
220
|
-
|
|
218
|
+
href: n.href ?? "/",
|
|
219
|
+
variant: n.variant ?? "primary",
|
|
220
|
+
displayType: n.displayType ?? "text",
|
|
221
|
+
imageSrc: n.imageSrc,
|
|
222
|
+
imageAlt: n.imageAlt,
|
|
223
|
+
"aria-label": n.ariaLabel ?? n.label,
|
|
224
|
+
children: n.displayType === "image" ? null : n.label
|
|
221
225
|
},
|
|
222
|
-
|
|
226
|
+
n._key || a
|
|
223
227
|
)) }) }),
|
|
224
|
-
|
|
228
|
+
i && /* @__PURE__ */ t(
|
|
225
229
|
"nav",
|
|
226
230
|
{
|
|
227
|
-
className: `${e.utilityMobile} ${
|
|
228
|
-
children: /* @__PURE__ */
|
|
229
|
-
|
|
231
|
+
className: `${e.utilityMobile} ${s ? e.open : ""}`,
|
|
232
|
+
children: /* @__PURE__ */ t(z, { alignment: "center", children: /* @__PURE__ */ t(
|
|
233
|
+
W,
|
|
230
234
|
{
|
|
231
235
|
as: "a",
|
|
232
|
-
href:
|
|
233
|
-
variant: "primary",
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
236
|
+
href: i[1].href ?? "/",
|
|
237
|
+
variant: i[1].variant ?? "primary",
|
|
238
|
+
displayType: i[1].displayType ?? "text",
|
|
239
|
+
imageSrc: i[1].imageSrc,
|
|
240
|
+
imageAlt: i[1].imageAlt,
|
|
241
|
+
"aria-label": i[1].ariaLabel ?? i[1].label,
|
|
242
|
+
children: i[1].displayType === "image" ? null : i[1].label
|
|
243
|
+
}
|
|
237
244
|
) })
|
|
238
245
|
}
|
|
239
246
|
),
|
|
240
|
-
/* @__PURE__ */
|
|
247
|
+
/* @__PURE__ */ t(
|
|
241
248
|
"button",
|
|
242
249
|
{
|
|
243
250
|
className: e.menuToggle,
|
|
244
251
|
onClick: F,
|
|
245
|
-
"aria-label":
|
|
246
|
-
"aria-expanded":
|
|
252
|
+
"aria-label": s ? "Close menu" : "Open menu",
|
|
253
|
+
"aria-expanded": s,
|
|
247
254
|
"aria-controls": "main-menu",
|
|
248
|
-
children:
|
|
255
|
+
children: s ? /* @__PURE__ */ t(J, { size: 24 }) : /* @__PURE__ */ t(Y, { size: 24 })
|
|
249
256
|
}
|
|
250
257
|
)
|
|
251
258
|
]
|
|
@@ -255,5 +262,5 @@ function Se({
|
|
|
255
262
|
);
|
|
256
263
|
}
|
|
257
264
|
export {
|
|
258
|
-
|
|
265
|
+
Xe as Navbar
|
|
259
266
|
};
|
|
@@ -14,8 +14,12 @@ type Alignment = keyof typeof alignmentClassMap;
|
|
|
14
14
|
export type UtilityItem = {
|
|
15
15
|
_key?: string;
|
|
16
16
|
label: string;
|
|
17
|
+
ariaLabel: string;
|
|
17
18
|
href?: string;
|
|
18
|
-
variant
|
|
19
|
+
variant?: ButtonVariant;
|
|
20
|
+
displayType?: "text" | "image";
|
|
21
|
+
imageSrc?: string;
|
|
22
|
+
imageAlt?: string;
|
|
19
23
|
};
|
|
20
24
|
export type NavItem = {
|
|
21
25
|
_key?: string;
|