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"),D={standard:e.styles.standard,transparent:e.styles.transparent},F={left:e.styles.left,center:e.styles.center,right:e.styles.right};function H({title:L,logo:v,items:r,groups:y,utilityItems:p,isSticky:R=!1,showSearch:C=!0,showLocaleSelect:E=!0,alignment:u="right",variant:M="standard",navigationType:S="default",className:W}){const[w,B]=n.useState(0),[f,o]=n.useState(null),[c,z]=n.useState(!1),[m,I]=n.useState(!1),[g,O]=n.useState(!1),[q,_]=n.useState(null),h=n.useRef(null),a=n.useRef(null),x=n.useRef(new Map),P=()=>s.jsx("div",{className:`${e.styles.linkWrapper} ${e.styles.parent} ${e.styles.searchWrapper}`,children:s.jsx("div",{className:e.styles.linkItem})}),T=()=>s.jsx("div",{className:`${e.styles.linkWrapper} ${e.styles.parent} `,children:s.jsx("div",{className:e.styles.linkItem})}),j=t=>{const l=x.current.get(t);if(l&&a.current){const i=l.getBoundingClientRect(),d=a.current.getBoundingClientRect(),V=i.left-d.left+i.width/2;_(V)}};console.log(j);const X=t=>{o(l=>l===t?null:t)},b=(t,l="")=>t.map(i=>{const d=`${l}/${i.label}`;return s.jsx(e.NavLink,{link:i,path:d,parentPath:l,openPath:f,togglePath:X,updateTriangleIndicator:j,setOpenPath:o,renderLinks:b,buttonRefs:x},i._key??d)}),N=n.useCallback(t=>{h.current&&!h.current.contains(t.target)&&o(null)},[]),$=n.useCallback(()=>{k(),typeof window<"u"&&window.innerWidth>768&&(z(!1),o(null),typeof document<"u"&&(document.body.style.overflow=""))},[]),k=n.useCallback(()=>{if(a.current){const t=a.current.getBoundingClientRect().width;B(t),O(!0)}},[]);return n.useEffect(()=>{const t=typeof window<"u",l=typeof document<"u";return t&&window.addEventListener("resize",$),l&&document.addEventListener("click",N),k(),()=>{t&&window.removeEventListener("resize",$),l&&document.removeEventListener("click",N)}},[]),n.useEffect(()=>{if(typeof window<"u"){const t=()=>{const l=window.innerWidth<768;I(l)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)}},[]),n.useEffect(()=>{if(typeof document<"u")return document.body.style.overflow=c?"hidden":"",()=>{document.body.style.overflow=""}},[c]),s.jsx("header",{ref:h,className:`${W??""} ${F[u]} ${D[M]} ${e.styles.navbar} ${R?e.styles.sticky:""} ${y&&y.length?e.styles.advanced:e.styles.default}`,role:"navigation","aria-label":"Main navigation",children:s.jsxs("div",{className:`${e.styles.container} ${(!p||p.length===0)&&u!=="center"?e.styles.twoColumn:""}`,children:[v?s.jsx("div",{className:e.styles.logo,children:v}):s.jsx("div",{className:e.styles.title,children:L}),s.jsx("nav",{ref:a,style:{left:u==="center"?`calc(50% - ${w/2}px)`:"0"},className:`${e.styles.nav} ${c?e.styles.open:""} ${g?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:`${q}px`},className:`${e.styles.triangle} ${f?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"})}),S==="default"&&r&&s.jsxs("div",{className:e.styles.grid,children:[r&&r.length>0&&b(r),C&&!m&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:e.styles.separator}),s.jsx(P,{})]}),E&&s.jsx(T,{})]}),s.jsx("p",{children:"HELLO"}),s.jsxs("p",{children:["vis: ",g]}),s.jsxs("p",{children:["open: ",c]}),s.jsxs("p",{children:["path: ",f]}),s.jsxs("p",{children:["nav: ",w]}),s.jsxs("p",{children:["mobile: ",m]})]})})]})})}exports.Navbar=H;
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 t, jsxs as s, Fragment as G } from "react/jsx-runtime";
2
- import { useState as r, useRef as p, useCallback as m, useEffect as w } from "react";
3
- import { s as e, N as J } from "../../../NavLink-CkJJdirp.js";
4
- const K = {
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
- }, Q = {
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: x,
14
- logo: g,
15
- items: l,
16
- groups: N,
17
- utilityItems: $,
18
- isSticky: z = !1,
19
- showSearch: B = !0,
20
- showLocaleSelect: I = !0,
21
- alignment: u = "right",
22
- variant: O = "standard",
23
- navigationType: j = "default",
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: X
26
+ className: D
27
27
  }) {
28
- const [b, P] = r(0), [h, c] = r(null), [d, S] = r(!1), [y, T] = r(!1), [L, V] = r(!1), [D, F] = r(null), v = p(null), o = p(null), k = p(/* @__PURE__ */ new Map()), H = () => /* @__PURE__ */ t(
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__ */ t("div", { className: e.linkItem })
32
+ children: /* @__PURE__ */ n("div", { className: e.linkItem })
33
33
  }
34
- ), _ = () => /* @__PURE__ */ t("div", { className: `${e.linkWrapper} ${e.parent} `, children: /* @__PURE__ */ t("div", { className: e.linkItem }) }), R = (n) => {
35
- const i = k.current.get(n);
36
- if (i && o.current) {
37
- const a = i.getBoundingClientRect(), f = o.current.getBoundingClientRect(), A = a.left - f.left + a.width / 2;
38
- F(A);
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(R);
42
- const q = (n) => {
43
- c((i) => i === n ? null : n);
44
- }, W = (n, i = "") => n.map((a) => {
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__ */ t(
47
- J,
46
+ return /* @__PURE__ */ n(
47
+ K,
48
48
  {
49
49
  link: a,
50
50
  path: f,
51
51
  parentPath: i,
52
- openPath: h,
53
- togglePath: q,
54
- updateTriangleIndicator: R,
55
- setOpenPath: c,
56
- renderLinks: W,
57
- buttonRefs: k
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
- }), C = m((n) => {
62
- v.current && !v.current.contains(n.target) && c(null);
63
- }, []), E = m(() => {
64
- M(), typeof window < "u" && window.innerWidth > 768 && (S(!1), c(null), typeof document < "u" && (document.body.style.overflow = ""));
65
- }, []), M = m(() => {
66
- if (o.current) {
67
- const n = o.current.getBoundingClientRect().width;
68
- P(n), V(!0);
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 w(() => {
72
- const n = typeof window < "u", i = typeof document < "u";
73
- return n && window.addEventListener("resize", E), i && document.addEventListener("click", C), M(), () => {
74
- n && window.removeEventListener("resize", E), i && document.removeEventListener("click", C);
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
- }, []), w(() => {
76
+ }, []), N(() => {
77
77
  if (typeof window < "u") {
78
- const n = () => {
78
+ const t = () => {
79
79
  const i = window.innerWidth < 768;
80
80
  T(i);
81
81
  };
82
- return n(), window.addEventListener("resize", n), () => window.removeEventListener("resize", n);
82
+ return t(), window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
83
83
  }
84
- }, []), w(() => {
84
+ }, []), N(() => {
85
85
  if (typeof document < "u")
86
- return document.body.style.overflow = d ? "hidden" : "", () => {
86
+ return document.body.style.overflow = c ? "hidden" : "", () => {
87
87
  document.body.style.overflow = "";
88
88
  };
89
- }, [d]), /* @__PURE__ */ t(
89
+ }, [c]), /* @__PURE__ */ n(
90
90
  "header",
91
91
  {
92
- ref: v,
93
- className: `${X ?? ""} ${Q[u]} ${K[O]} ${e.navbar} ${z ? e.sticky : ""} ${N && N.length ? e.advanced : e.default}`,
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} ${(!$ || $.length === 0) && u !== "center" ? e.twoColumn : ""}`,
99
+ className: `${e.container} ${(!b || b.length === 0) && h !== "center" ? e.twoColumn : ""}`,
100
100
  children: [
101
- g ? /* @__PURE__ */ t("div", { className: e.logo, children: g }) : /* @__PURE__ */ t("div", { className: e.title, children: x }),
102
- /* @__PURE__ */ t(
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: o,
105
+ ref: l,
106
106
  style: {
107
- left: u === "center" ? `calc(50% - ${b / 2}px)` : "0"
107
+ left: h === "center" ? `calc(50% - ${R / 2}px)` : "0"
108
108
  },
109
- className: `${e.nav} ${d ? e.open : ""} ${L ? e.visible : e.hidden}`,
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__ */ t(
114
+ /* @__PURE__ */ n(
115
115
  "svg",
116
116
  {
117
- style: { left: `${D}px` },
118
- className: `${e.triangle} ${h ? e.show : ""}`,
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__ */ t(
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
- j === "default" && l && /* @__PURE__ */ s("div", { className: e.grid, children: [
135
- l && l.length > 0 && W(l),
136
- B && !y && /* @__PURE__ */ s(G, { children: [
137
- /* @__PURE__ */ t("span", { className: e.separator }),
138
- /* @__PURE__ */ t(H, {})
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
- I && /* @__PURE__ */ t(_, {})
140
+ L && /* @__PURE__ */ n(M, {})
141
141
  ] }),
142
- /* @__PURE__ */ t("p", { children: "HELLO" }),
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
- L
152
+ W
146
153
  ] }),
147
154
  /* @__PURE__ */ s("p", { children: [
148
155
  "open: ",
149
- d
156
+ c
150
157
  ] }),
151
158
  /* @__PURE__ */ s("p", { children: [
152
159
  "path: ",
153
- h
160
+ v
154
161
  ] }),
155
162
  /* @__PURE__ */ s("p", { children: [
156
163
  "nav: ",
157
- b
164
+ R
158
165
  ] }),
159
166
  /* @__PURE__ */ s("p", { children: [
160
167
  "mobile: ",
161
- y
168
+ p
162
169
  ] })
163
170
  ] })
164
171
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "quirk-ui",
3
3
  "private": false,
4
- "version": "0.0.407",
4
+ "version": "0.0.409",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {