quirk-ui 0.0.407 → 0.0.409
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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),n=require("react"),e=require("../../../NavLink-D2MSB11f.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),n=require("react"),e=require("../../../NavLink-D2MSB11f.cjs"),V={standard:e.styles.standard,transparent:e.styles.transparent},D={left:e.styles.left,center:e.styles.center,right:e.styles.right};function H({title:W,logo:p,items:r,groups:u,utilityItems:m,isSticky:B=!1,showSearch:w=!0,showLocaleSelect:x=!0,alignment:f="right",variant:S="standard",navigationType:g="default",className:z}){const[j,I]=n.useState(0),[v,c]=n.useState(null),[o,O]=n.useState(!1),[h,q]=n.useState(!1),[N,_]=n.useState(!1),[P,X]=n.useState(null),y=n.useRef(null),i=n.useRef(null),b=n.useRef(new Map),$=()=>s.jsx("div",{className:`${e.styles.linkWrapper} ${e.styles.parent} ${e.styles.searchWrapper}`,children:s.jsx("div",{className:e.styles.linkItem})}),k=()=>s.jsx("div",{className:`${e.styles.linkWrapper} ${e.styles.parent} `,children:s.jsx("div",{className:e.styles.linkItem})}),L=t=>{const l=b.current.get(t);if(l&&i.current){const a=l.getBoundingClientRect(),d=i.current.getBoundingClientRect(),T=a.left-d.left+a.width/2;X(T)}};console.log(L);const F=t=>{c(l=>l===t?null:t)},R=(t,l="")=>t.map(a=>{const d=`${l}/${a.label}`;return s.jsx(e.NavLink,{link:a,path:d,parentPath:l,openPath:v,togglePath:F,updateTriangleIndicator:L,setOpenPath:c,renderLinks:R,buttonRefs:b},a._key??d)}),C=n.useCallback(t=>{y.current&&!y.current.contains(t.target)&&c(null)},[]),E=n.useCallback(()=>{M(),typeof window<"u"&&window.innerWidth>768&&(O(!1),c(null),typeof document<"u"&&(document.body.style.overflow=""))},[]),M=n.useCallback(()=>{if(i.current){const t=i.current.getBoundingClientRect().width;I(t),_(!0)}},[]);return n.useEffect(()=>{const t=typeof window<"u",l=typeof document<"u";return t&&window.addEventListener("resize",E),l&&document.addEventListener("click",C),M(),()=>{t&&window.removeEventListener("resize",E),l&&document.removeEventListener("click",C)}},[]),n.useEffect(()=>{if(typeof window<"u"){const t=()=>{const l=window.innerWidth<768;q(l)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)}},[]),n.useEffect(()=>{if(typeof document<"u")return document.body.style.overflow=o?"hidden":"",()=>{document.body.style.overflow=""}},[o]),s.jsx("header",{ref:y,className:`${z??""} ${D[f]} ${V[S]} ${e.styles.navbar} ${B?e.styles.sticky:""} ${u&&u.length?e.styles.advanced:e.styles.default}`,role:"navigation","aria-label":"Main navigation",children:s.jsxs("div",{className:`${e.styles.container} ${(!m||m.length===0)&&f!=="center"?e.styles.twoColumn:""}`,children:[p?s.jsx("div",{className:e.styles.logo,children:p}):s.jsx("div",{className:e.styles.title,children:W}),s.jsx("nav",{ref:i,style:{left:f==="center"?`calc(50% - ${j/2}px)`:"0"},className:`${e.styles.nav} ${o?e.styles.open:""} ${N?e.styles.visible:e.styles.hidden}`,id:"main-menu",role:"menubar","aria-label":"Main navigation",children:s.jsxs("div",{className:e.styles.navInner,children:[s.jsx("svg",{style:{left:`${P}px`},className:`${e.styles.triangle} ${v?e.styles.show:""}`,width:16,height:12,viewBox:"0 0 100 75",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("polygon",{points:"50,5 95,70 5,70",strokeLinejoin:"round",fill:"white",stroke:"white"})}),g==="default"&&r&&s.jsxs("div",{className:e.styles.grid,children:[r&&r.length>0&&R(r),w&&!h&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:e.styles.separator}),s.jsx($,{})]}),x&&s.jsx(k,{})]}),!h&&g==="advanced"&&u&&s.jsxs("div",{className:e.styles.grid,children:[w&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:e.styles.separator}),s.jsx($,{})]}),x&&s.jsx(k,{})]}),s.jsx("p",{children:"HELLO"}),s.jsxs("p",{children:["vis: ",N]}),s.jsxs("p",{children:["open: ",o]}),s.jsxs("p",{children:["path: ",v]}),s.jsxs("p",{children:["nav: ",j]}),s.jsxs("p",{children:["mobile: ",h]})]})})]})})}exports.Navbar=H;
|
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as r, useRef as
|
|
3
|
-
import { s as e, N as
|
|
4
|
-
const
|
|
1
|
+
import { jsx as n, jsxs as s, Fragment as j } from "react/jsx-runtime";
|
|
2
|
+
import { useState as r, useRef as w, useCallback as g, useEffect as N } from "react";
|
|
3
|
+
import { s as e, N as K } from "../../../NavLink-CkJJdirp.js";
|
|
4
|
+
const Q = {
|
|
5
5
|
standard: e.standard,
|
|
6
6
|
transparent: e.transparent
|
|
7
|
-
},
|
|
7
|
+
}, S = {
|
|
8
8
|
left: e.left,
|
|
9
9
|
center: e.center,
|
|
10
10
|
right: e.right
|
|
11
11
|
};
|
|
12
12
|
function ne({
|
|
13
|
-
title:
|
|
14
|
-
logo:
|
|
15
|
-
items:
|
|
16
|
-
groups:
|
|
17
|
-
utilityItems:
|
|
18
|
-
isSticky:
|
|
19
|
-
showSearch:
|
|
20
|
-
showLocaleSelect:
|
|
21
|
-
alignment:
|
|
22
|
-
variant:
|
|
23
|
-
navigationType:
|
|
13
|
+
title: X,
|
|
14
|
+
logo: $,
|
|
15
|
+
items: o,
|
|
16
|
+
groups: u,
|
|
17
|
+
utilityItems: b,
|
|
18
|
+
isSticky: P = !1,
|
|
19
|
+
showSearch: y = !0,
|
|
20
|
+
showLocaleSelect: L = !0,
|
|
21
|
+
alignment: h = "right",
|
|
22
|
+
variant: V = "standard",
|
|
23
|
+
navigationType: k = "default",
|
|
24
24
|
// searchComponent,
|
|
25
25
|
// localeSelectComponent,
|
|
26
|
-
className:
|
|
26
|
+
className: D
|
|
27
27
|
}) {
|
|
28
|
-
const [
|
|
28
|
+
const [R, F] = r(0), [v, d] = r(null), [c, H] = r(!1), [p, T] = r(!1), [W, _] = r(!1), [q, A] = r(null), m = w(null), l = w(null), C = w(/* @__PURE__ */ new Map()), E = () => /* @__PURE__ */ n(
|
|
29
29
|
"div",
|
|
30
30
|
{
|
|
31
31
|
className: `${e.linkWrapper} ${e.parent} ${e.searchWrapper}`,
|
|
32
|
-
children: /* @__PURE__ */
|
|
32
|
+
children: /* @__PURE__ */ n("div", { className: e.linkItem })
|
|
33
33
|
}
|
|
34
|
-
),
|
|
35
|
-
const i =
|
|
36
|
-
if (i &&
|
|
37
|
-
const a = i.getBoundingClientRect(), f =
|
|
38
|
-
|
|
34
|
+
), M = () => /* @__PURE__ */ n("div", { className: `${e.linkWrapper} ${e.parent} `, children: /* @__PURE__ */ n("div", { className: e.linkItem }) }), x = (t) => {
|
|
35
|
+
const i = C.current.get(t);
|
|
36
|
+
if (i && l.current) {
|
|
37
|
+
const a = i.getBoundingClientRect(), f = l.current.getBoundingClientRect(), J = a.left - f.left + a.width / 2;
|
|
38
|
+
A(J);
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
console.log(
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
},
|
|
41
|
+
console.log(x);
|
|
42
|
+
const G = (t) => {
|
|
43
|
+
d((i) => i === t ? null : t);
|
|
44
|
+
}, z = (t, i = "") => t.map((a) => {
|
|
45
45
|
const f = `${i}/${a.label}`;
|
|
46
|
-
return /* @__PURE__ */
|
|
47
|
-
|
|
46
|
+
return /* @__PURE__ */ n(
|
|
47
|
+
K,
|
|
48
48
|
{
|
|
49
49
|
link: a,
|
|
50
50
|
path: f,
|
|
51
51
|
parentPath: i,
|
|
52
|
-
openPath:
|
|
53
|
-
togglePath:
|
|
54
|
-
updateTriangleIndicator:
|
|
55
|
-
setOpenPath:
|
|
56
|
-
renderLinks:
|
|
57
|
-
buttonRefs:
|
|
52
|
+
openPath: v,
|
|
53
|
+
togglePath: G,
|
|
54
|
+
updateTriangleIndicator: x,
|
|
55
|
+
setOpenPath: d,
|
|
56
|
+
renderLinks: z,
|
|
57
|
+
buttonRefs: C
|
|
58
58
|
},
|
|
59
59
|
a._key ?? f
|
|
60
60
|
);
|
|
61
|
-
}),
|
|
62
|
-
|
|
63
|
-
}, []),
|
|
64
|
-
|
|
65
|
-
}, []),
|
|
66
|
-
if (
|
|
67
|
-
const
|
|
68
|
-
|
|
61
|
+
}), B = g((t) => {
|
|
62
|
+
m.current && !m.current.contains(t.target) && d(null);
|
|
63
|
+
}, []), I = g(() => {
|
|
64
|
+
O(), typeof window < "u" && window.innerWidth > 768 && (H(!1), d(null), typeof document < "u" && (document.body.style.overflow = ""));
|
|
65
|
+
}, []), O = g(() => {
|
|
66
|
+
if (l.current) {
|
|
67
|
+
const t = l.current.getBoundingClientRect().width;
|
|
68
|
+
F(t), _(!0);
|
|
69
69
|
}
|
|
70
70
|
}, []);
|
|
71
|
-
return
|
|
72
|
-
const
|
|
73
|
-
return
|
|
74
|
-
|
|
71
|
+
return N(() => {
|
|
72
|
+
const t = typeof window < "u", i = typeof document < "u";
|
|
73
|
+
return t && window.addEventListener("resize", I), i && document.addEventListener("click", B), O(), () => {
|
|
74
|
+
t && window.removeEventListener("resize", I), i && document.removeEventListener("click", B);
|
|
75
75
|
};
|
|
76
|
-
}, []),
|
|
76
|
+
}, []), N(() => {
|
|
77
77
|
if (typeof window < "u") {
|
|
78
|
-
const
|
|
78
|
+
const t = () => {
|
|
79
79
|
const i = window.innerWidth < 768;
|
|
80
80
|
T(i);
|
|
81
81
|
};
|
|
82
|
-
return
|
|
82
|
+
return t(), window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
|
|
83
83
|
}
|
|
84
|
-
}, []),
|
|
84
|
+
}, []), N(() => {
|
|
85
85
|
if (typeof document < "u")
|
|
86
|
-
return document.body.style.overflow =
|
|
86
|
+
return document.body.style.overflow = c ? "hidden" : "", () => {
|
|
87
87
|
document.body.style.overflow = "";
|
|
88
88
|
};
|
|
89
|
-
}, [
|
|
89
|
+
}, [c]), /* @__PURE__ */ n(
|
|
90
90
|
"header",
|
|
91
91
|
{
|
|
92
|
-
ref:
|
|
93
|
-
className: `${
|
|
92
|
+
ref: m,
|
|
93
|
+
className: `${D ?? ""} ${S[h]} ${Q[V]} ${e.navbar} ${P ? e.sticky : ""} ${u && u.length ? e.advanced : e.default}`,
|
|
94
94
|
role: "navigation",
|
|
95
95
|
"aria-label": "Main navigation",
|
|
96
96
|
children: /* @__PURE__ */ s(
|
|
97
97
|
"div",
|
|
98
98
|
{
|
|
99
|
-
className: `${e.container} ${(
|
|
99
|
+
className: `${e.container} ${(!b || b.length === 0) && h !== "center" ? e.twoColumn : ""}`,
|
|
100
100
|
children: [
|
|
101
|
-
|
|
102
|
-
/* @__PURE__ */
|
|
101
|
+
$ ? /* @__PURE__ */ n("div", { className: e.logo, children: $ }) : /* @__PURE__ */ n("div", { className: e.title, children: X }),
|
|
102
|
+
/* @__PURE__ */ n(
|
|
103
103
|
"nav",
|
|
104
104
|
{
|
|
105
|
-
ref:
|
|
105
|
+
ref: l,
|
|
106
106
|
style: {
|
|
107
|
-
left:
|
|
107
|
+
left: h === "center" ? `calc(50% - ${R / 2}px)` : "0"
|
|
108
108
|
},
|
|
109
|
-
className: `${e.nav} ${
|
|
109
|
+
className: `${e.nav} ${c ? e.open : ""} ${W ? e.visible : e.hidden}`,
|
|
110
110
|
id: "main-menu",
|
|
111
111
|
role: "menubar",
|
|
112
112
|
"aria-label": "Main navigation",
|
|
113
113
|
children: /* @__PURE__ */ s("div", { className: e.navInner, children: [
|
|
114
|
-
/* @__PURE__ */
|
|
114
|
+
/* @__PURE__ */ n(
|
|
115
115
|
"svg",
|
|
116
116
|
{
|
|
117
|
-
style: { left: `${
|
|
118
|
-
className: `${e.triangle} ${
|
|
117
|
+
style: { left: `${q}px` },
|
|
118
|
+
className: `${e.triangle} ${v ? e.show : ""}`,
|
|
119
119
|
width: 16,
|
|
120
120
|
height: 12,
|
|
121
121
|
viewBox: "0 0 100 75",
|
|
122
122
|
xmlns: "http://www.w3.org/2000/svg",
|
|
123
|
-
children: /* @__PURE__ */
|
|
123
|
+
children: /* @__PURE__ */ n(
|
|
124
124
|
"polygon",
|
|
125
125
|
{
|
|
126
126
|
points: "50,5 95,70 5,70",
|
|
@@ -131,34 +131,41 @@ function ne({
|
|
|
131
131
|
)
|
|
132
132
|
}
|
|
133
133
|
),
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
/* @__PURE__ */
|
|
134
|
+
k === "default" && o && /* @__PURE__ */ s("div", { className: e.grid, children: [
|
|
135
|
+
o && o.length > 0 && z(o),
|
|
136
|
+
y && !p && /* @__PURE__ */ s(j, { children: [
|
|
137
|
+
/* @__PURE__ */ n("span", { className: e.separator }),
|
|
138
|
+
/* @__PURE__ */ n(E, {})
|
|
139
139
|
] }),
|
|
140
|
-
|
|
140
|
+
L && /* @__PURE__ */ n(M, {})
|
|
141
141
|
] }),
|
|
142
|
-
/* @__PURE__ */
|
|
142
|
+
!p && k === "advanced" && u && /* @__PURE__ */ s("div", { className: e.grid, children: [
|
|
143
|
+
y && /* @__PURE__ */ s(j, { children: [
|
|
144
|
+
/* @__PURE__ */ n("span", { className: e.separator }),
|
|
145
|
+
/* @__PURE__ */ n(E, {})
|
|
146
|
+
] }),
|
|
147
|
+
L && /* @__PURE__ */ n(M, {})
|
|
148
|
+
] }),
|
|
149
|
+
/* @__PURE__ */ n("p", { children: "HELLO" }),
|
|
143
150
|
/* @__PURE__ */ s("p", { children: [
|
|
144
151
|
"vis: ",
|
|
145
|
-
|
|
152
|
+
W
|
|
146
153
|
] }),
|
|
147
154
|
/* @__PURE__ */ s("p", { children: [
|
|
148
155
|
"open: ",
|
|
149
|
-
|
|
156
|
+
c
|
|
150
157
|
] }),
|
|
151
158
|
/* @__PURE__ */ s("p", { children: [
|
|
152
159
|
"path: ",
|
|
153
|
-
|
|
160
|
+
v
|
|
154
161
|
] }),
|
|
155
162
|
/* @__PURE__ */ s("p", { children: [
|
|
156
163
|
"nav: ",
|
|
157
|
-
|
|
164
|
+
R
|
|
158
165
|
] }),
|
|
159
166
|
/* @__PURE__ */ s("p", { children: [
|
|
160
167
|
"mobile: ",
|
|
161
|
-
|
|
168
|
+
p
|
|
162
169
|
] })
|
|
163
170
|
] })
|
|
164
171
|
}
|