@devgateway/dvz-ui-react 1.6.9 → 1.6.11
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,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),u=require("semantic-ui-react"),i=require("react"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),u=require("semantic-ui-react"),i=require("react"),h=require("@devgateway/wp-react-lib"),C=require("react-intl"),L=require("react-router"),T=require("./SearchControl.js"),$=require("./LangSwitcher.js"),k=(n,r)=>{const c=[];return n.items.forEach(l=>{l.child_items?l.child_items.forEach(a=>{a.slug==r.slug&&(c.push(l),c.push(a))}):l.slug==r.slug&&l.url!="/"&&c.push(l)}),c},E=(n,r)=>{if(n){const c=n.indexOf("/wp");if(c!==-1){const l=n.substr(c+3);return l.startsWith("/"+r)?l:"/"+r+l}else return n.startsWith("/"+r)?n:"/"+r+n}return""},O=C.injectIntl(({menu:n,intl:r})=>{const c=L.useParams(),l=k(n,c);return e.jsx(i.Fragment,{children:l.filter(a=>a.url!="#wpm-languages").map(a=>a.child_items?e.jsxs("span",{children:[a.post_title," "]}):e.jsxs("a",{className:a.slug==c.slug?"active":"",href:h.utils.replaceLink(a.url,r.locale),children:[" ",a.post_title]}))})}),N=C.injectIntl(({settings:n,withIcons:r,active:c,menu:l,onSetSelected:a,selected:d,intl:{locale:j},isSmallScreen:S})=>{const w=L.useParams();i.useEffect(s=>{const t=k(l,w).filter(x=>x.menu_item_parent==0);t&&t.length>0?a(t[0]):a(null)},[l,a,w.slug]);const[g,_]=i.useState(null);i.useEffect(()=>{_(l)},[l]),i.useEffect(()=>{if(n&&n.menu_settings&&g){const s=[],f=l.items.map(t=>(n.menu_settings&&n.menu_settings["nav_menu_item["+t.ID+"]"]===!1&&s.push(t.ID),n.menu_settings&&n.menu_settings["nav_menu_item["+t.ID+"]"]?(n.menu_settings["nav_menu_item["+t.ID+"]"],{...t,...n.menu_settings["nav_menu_item["+t.ID+"]"]}):t));Object.keys(n.menu_settings).map(t=>{const x=n.menu_settings[t];if(x.type=="nav_menu_item"){const b=/(-)?[0-9]+/g.exec(t),M=parseInt(b[0]);f.find(o=>o.ID==M)||f.push(x.value)}}),_({...l,items:f.filter(t=>s.indexOf(t.ID)===-1)})}},[n]);const[p,v]=i.useState(!1);return i.useEffect(()=>{const s=()=>{v(window.innerWidth<=1200)};return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[]),g&&e.jsx(i.Fragment,{children:g.items.filter(s=>s.url!=="#wpm-languages").map((s,f)=>e.jsxs(i.Fragment,{children:[e.jsxs(u.Menu.Item,{className:`divided ${s.child_items?"has-child-items":""}
|
|
2
2
|
${d&&d.ID===s.ID?"selected":""}
|
|
3
|
-
${c===s.slug?"active":""}`,children:[r&&e.jsx("a",{href:E(s.url,j),children:e.jsx("div",{className:"mark",children:e.jsx("span",{className:"sr-only",children:s.title})})}),S?s.child_items?e.jsx("span",{onClick:()=>a(d===s?null:s),children:s.title}):e.jsx("a",{href:E(s.url,j),children:s.title}):s.child_items?e.jsx("span",{onMouseOver:t=>a(s),onClick:()=>a(d===s?null:s),children:s.title}):e.jsx("a",{onMouseOut:t=>a(null),onMouseOver:t=>a(s),href:E(s.url,j),children:s.title})]}),p&&d&&d.ID===s.ID&&d.child_items&&e.jsx(i.Fragment,{children:d.child_items.map(t=>e.jsxs(u.Menu.Item,{className:`divided child-item ${c===t.slug?"active":""}`,children:[e.jsx("div",{className:"mark"}),e.jsx("a",{href:E(t.url,j),children:t.title})]},t.ID))})]},s.ID))})}),q=({intl:n,settings:r})=>{const[c,l]=i.useState(),[a,d]=i.useState(!1),[j,S]=i.useState(!1),[w,g]=i.useState(!1),[_,p]=i.useState(!1),{slug:v}=
|
|
3
|
+
${c===s.slug?"active":""}`,children:[r&&e.jsx("a",{href:E(s.url,j),children:e.jsx("div",{className:"mark",children:e.jsx("span",{className:"sr-only",children:s.title})})}),S?s.child_items?e.jsx("span",{onClick:()=>a(d===s?null:s),children:s.title}):e.jsx("a",{href:E(s.url,j),children:s.title}):s.child_items?e.jsx("span",{onMouseOver:t=>a(s),onClick:()=>a(d===s?null:s),children:s.title}):e.jsx("a",{onMouseOut:t=>a(null),onMouseOver:t=>a(s),href:E(s.url,j),children:s.title})]}),p&&d&&d.ID===s.ID&&d.child_items&&e.jsx(i.Fragment,{children:d.child_items.map(t=>e.jsxs(u.Menu.Item,{className:`divided child-item ${c===t.slug?"active":""}`,children:[e.jsx("div",{className:"mark"}),e.jsx("a",{href:E(t.url,j),children:t.title})]},t.ID))})]},s.ID))})}),q=({intl:n,settings:r})=>{const[c,l]=i.useState(),[a,d]=i.useState(!1),[j,S]=i.useState(!1),[w,g]=i.useState(!1),[_,p]=i.useState(!1),{slug:v}=L.useParams(),s=i.useRef(null),f=i.useRef(null),t=()=>{p(!_),d(!a)};i.useEffect(()=>{const o=m=>{(s.current&&!s.current.contains(m.target)&&!f.current.contains(m.target)||m.target.closest(".desktop")||m.target.closest(".breadcrumbs"))&&(d(!1),p(!1))},I=m=>{m.key==="Escape"&&(d(!1),p(!1))};return document.addEventListener("mousedown",o),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",I)}},[]),i.useEffect(()=>{let o;const I=()=>{const D=window.innerWidth<=1200;S(D),g(!1)},m=()=>{g(!0),clearTimeout(o),o=setTimeout(I,300)};return I(),window.addEventListener("resize",m),()=>{clearTimeout(o),window.removeEventListener("resize",m)}},[]);const[x,z]=i.useState(!1);i.useEffect(()=>{const o=()=>{z(window.innerWidth<=1364)};return o(),window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]);const b=({media:o})=>o?e.jsx(u.Image,{src:o.guid.rendered}):e.jsx("img",{className:"brand logo",size:"large",src:"/logo_full.png"}),M=(r==null?void 0:r.landing_page_url)&&r.landing_page_url!==!1&&r.landing_page_url!==void 0&&r.landing_page_url!=="",R=M?r.landing_page_url:`/${n.locale}`;return e.jsx(i.Fragment,{children:e.jsxs(h.MenuProvider,{slug:"main",locale:n.locale,children:[e.jsxs(u.Container,{fluid:!0,className:"header",children:[e.jsx(u.Container,{fluid:!0,className:"background",ref:s,children:e.jsxs(u.Menu,{className:"branding",text:!0,children:[e.jsx(u.Menu.Item,{children:e.jsxs("a",{href:`${R}`,target:M?"_blank":"_self",rel:"noopener noreferrer",id:"site_url",children:[r.site_logo!==0&&!x&&e.jsx(h.MediaProvider,{id:r.site_logo,children:e.jsx(h.MediaConsumer,{children:e.jsx(b,{},"logo")})}),r.site_logo===0&&!x&&e.jsx("img",{className:"brand logo",size:"large",src:"/logo_full.png"}),x&&e.jsx("img",{className:"brand logo small",size:"small",src:"/wp-media/TCDI-Icon-small_02.png"})]})}),e.jsx(u.Menu.Item,{className:"divider",children:e.jsx("div",{})}),e.jsxs(u.Menu.Item,{fitted:!0,href:"/",children:[e.jsx(u.Flag,{name:"za"}),e.jsx("div",{className:"site name",children:r.name})]}),!w&&(j?e.jsx(u.Menu,{className:`pages ${a?"show":""}`,children:e.jsx(u.Container,{fluid:!0,children:e.jsx(h.MenuConsumer,{children:e.jsx(N,{settings:r,active:v,selected:c,onSetSelected:l,isSmallScreen:j},"items")})})}):e.jsx(u.Menu.Menu,{className:"pages",children:e.jsx(h.MenuConsumer,{children:e.jsx(N,{settings:r,active:v,selected:c,onSetSelected:l},"items")})})),e.jsx(u.Menu.Item,{children:e.jsx(h.MenuConsumer,{children:e.jsx($.default,{locale:n.locale},"lang")})}),e.jsx(u.Menu.Item,{fitted:!0,children:e.jsx(h.MenuConsumer,{children:e.jsx(T.default,{onSetSelected:l,settings:r})})}),e.jsxs("div",{ref:f,className:`hamburger-menu ${_?"animate":""} ${a?"open":"close"}`,onClick:t,children:[e.jsx("div",{}),e.jsx("div",{className:"middle-line"}),e.jsx("div",{})]})]})}),e.jsx(u.Container,{fluid:!0,className:"child",children:c&&c.child_items&&e.jsx(u.Menu,{fluid:!0,text:!0,children:e.jsx(N,{active:v,locale:n.locale,withIcons:!0,onSetSelected:o=>null,menu:{items:c.child_items}})})})]},"header-container"),e.jsx(u.Container,{className:"url breadcrumbs",children:e.jsx(h.MenuConsumer,{children:e.jsx(O,{})})})]})})},y=C.injectIntl(q);exports.default=y;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),p=require("react"),v=require("@devgateway/wp-react-lib"),I=require("./CustomSemanticSearch.js"),M=require("react-dom"),L=require("semantic-ui-react"),C=require("react-intl"),w=(s,r)=>{if(!s||!r)return s||"";const a=new RegExp(`(${r})`,"gi");return s.replace(a,"<strong>$1</strong>")},R=C.injectIntl(({ID:s,title:r,slug:a,parent_title:i,parent_slug:t,parent_link:n,extract:c,type:u,link:m,terms:y,subtype:g,bread_crumbs:d=[],metadata:o,intl:{locale:f},searchTerm:S})=>{let x=n?v.utils.replaceLink(n,f)+`#${a}`:v.utils.replaceLink(m,f);const E=o==null?void 0:o.redirect_url;x=E?E+`#${a}`:x;const l=w(String(r),S),h=w(c,S);return e.jsx("div",{className:"search-results-wrapper searching-results",style:{display:"flex",flexDirection:"column"},children:e.jsxs("div",{className:"has-standard-12-font-size",onClick:N=>document.location.href=x,children:[e.jsx("h5",{className:"breadcrumbs-search",dangerouslySetInnerHTML:{__html:d&&d.length>0?w(d.join(" / "),S):""}}),e.jsx("div",{className:"has-standard-14-font-size",children:e.jsx("h4",{className:"search-title",dangerouslySetInnerHTML:{__html:l}})}),e.jsx("div",{className:"search-content",dangerouslySetInnerHTML:{__html:v.utils.replaceHTMLinks(h,f)}})]})})}),T=({results:s,meta:r,perPage:a,intl:i,searchTerm:t})=>{const n=r?r["x-wp-total"]:0;return r&&r["x-wp-totalpages"],e.jsxs("div",{id:"float-results-container",children:[e.jsx("span",{className:"float-results-header",children:i.formatMessage({id:"search.results.summary",defaultMessage:"{count} of {total} Results"},{count:n<a?n:a,total:n})}),s.map(c=>e.jsx(R,{...c,searchTerm:t},c.ID))]})},_=({onSearch:s,perPage:r,loading:a,results:i,meta:t,intl:n})=>(t&&t["x-wp-total"],t&&t["x-wp-totalpages"],e.jsx("input",{placeholder:n.formatMessage({id:"search.placeholder",defaultMessage:"Search..."}),type:"text",className:"input search",name:"search",onChange:c=>{s(c.target.value)}})),b=({onSearch:s,onSetSelected:r,perPage:a,loading:i,results:t,meta:n,locale:c,intl:u,searchTerm:m,selected:y})=>{const[g,d]=p.useState(!1),o=p.useRef(null),f=()=>{d(!1)},S=()=>{const l=document.getElementsByClassName("has-child-items");for(let h=0;h<l.length;h++){const j=l[h].getElementsByTagName("span");j.length>0&&j[0].addEventListener("mouseover",f)}},x=()=>{const l=document.getElementsByClassName("has-child-items");for(let h=0;h<l.length;h++){const j=l[h].getElementsByTagName("span");j.length>0&&j[0].removeEventListener("mouseover",f)}};p.useEffect(()=>{const l=document.createElement("div");l.setAttribute("id","float-input-container"),l.setAttribute("class","input container"),l.style.display="none";const h=document.getElementById("root");return h&&(h.appendChild(l),o.current=l),()=>{o.current&&o.current.parentNode&&o.current.parentNode.removeChild(o.current)}},[]),p.useEffect(()=>{o.current&&(o.current.style.display=g?"block":"none"),g?S():x()},[g]);const E=()=>{d(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{id:"ui-float-search",className:"ui float-search",onMouseOver:E,children:e.jsx(L.Icon,{name:"search",size:"small"})}),o.current&&M.createPortal(g?e.jsxs("div",{onMouseLeave:f,children:[e.jsx("div",{className:"float-search-container",children:e.jsx(_,{onSearch:s,perPage:a,loading:i,results:t,meta:n,intl:u,searchTerm:m})}),t&&t.length>0&&e.jsx(C.IntlProvider,{locale:c,children:e.jsx(T,{results:t,meta:n,perPage:a,intl:u,searchTerm:m})})]}):null,o.current)]})},q=({onSearch:s,perPage:r,loading:a,results:i,meta:t,intl:n})=>{const c=t?t["x-wp-total"]:0,u=t?t["x-wp-totalpages"]:0,[m,y]=p.useState("");p.useEffect(()=>{const d=setTimeout(()=>{s(m)},300);return()=>clearTimeout(d)},[m]);const g=d=>e.jsx(R,{...d,searchTerm:m});return e.jsx(I.default,{value:m,loading:a,placeholder:n.formatMessage({id:"search.placeholder",defaultMessage:"Search..."}),onResultSelect:(d,o)=>null,total:c,perPage:r,totalPages:u,onSearchChange:(d,o)=>{y(o.value)},resultRenderer:g,results:i,showNoResults:!1,intl:n,searchTerm:m})},P=C.injectIntl(s=>{const{intl:r,onSetSelected:a}=s,[i,t]=p.useState(""),[n,c]=p.useState(!1);return p.useEffect(()=>{const u=()=>{c(window.innerWidth<=1365)};return u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)},[]),e.jsx(v.SearchProvider,{search:i,perPage:5,locale:r.locale,children:e.jsx(z,{...s,onSetSelected:a,setQuery:t,query:i,isSmallScreen:n,intl:r})})}),z=({onSetSelected:s,selected:r,setQuery:a,query:i,isSmallScreen:t,intl:n,...c})=>{const u=p.useContext(v.SearchContext);return c.settings.react_search_type==="floating"||t?e.jsx(b,{onSetSelected:s,selected:r,onSearch:a,perPage:5,intl:n,...c,...u,searchTerm:i}):e.jsx(q,{onSetSelected:s,onSearch:a,perPage:5,intl:n,...c,...u})};exports.default=P;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as u } from "react/jsx-runtime";
|
|
2
2
|
import { Menu as d, Container as b, Flag as P, Image as U } from "semantic-ui-react";
|
|
3
|
-
import
|
|
4
|
-
import { utils as j, MenuProvider as H, MediaProvider as A, MediaConsumer as V, MenuConsumer as
|
|
3
|
+
import L, { useEffect as _, useState as p, useRef as y } from "react";
|
|
4
|
+
import { utils as j, MenuProvider as H, MediaProvider as A, MediaConsumer as V, MenuConsumer as E } from "@devgateway/wp-react-lib";
|
|
5
5
|
import { injectIntl as R } from "react-intl";
|
|
6
6
|
import { useParams as $ } from "react-router";
|
|
7
7
|
import B from "./SearchControl.js";
|
|
@@ -25,7 +25,7 @@ const W = (r, s) => {
|
|
|
25
25
|
return "";
|
|
26
26
|
}, q = R(({ menu: r, intl: s }) => {
|
|
27
27
|
const t = $(), i = W(r, t);
|
|
28
|
-
return /* @__PURE__ */ e(
|
|
28
|
+
return /* @__PURE__ */ e(L.Fragment, { children: i.filter((a) => a.url != "#wpm-languages").map(
|
|
29
29
|
(a) => a.child_items ? /* @__PURE__ */ u("span", { children: [
|
|
30
30
|
a.post_title,
|
|
31
31
|
" "
|
|
@@ -52,13 +52,13 @@ const W = (r, s) => {
|
|
|
52
52
|
intl: { locale: g },
|
|
53
53
|
isSmallScreen: D
|
|
54
54
|
}) => {
|
|
55
|
-
const
|
|
55
|
+
const z = $();
|
|
56
56
|
_(
|
|
57
57
|
(n) => {
|
|
58
|
-
const l = W(i,
|
|
58
|
+
const l = W(i, z).filter((f) => f.menu_item_parent == 0);
|
|
59
59
|
l && l.length > 0 ? a(l[0]) : a(null);
|
|
60
60
|
},
|
|
61
|
-
[i, a,
|
|
61
|
+
[i, a, z.slug]
|
|
62
62
|
);
|
|
63
63
|
const [v, I] = p(null);
|
|
64
64
|
_(() => {
|
|
@@ -72,8 +72,8 @@ const W = (r, s) => {
|
|
|
72
72
|
Object.keys(r.menu_settings).map((l) => {
|
|
73
73
|
const f = r.menu_settings[l];
|
|
74
74
|
if (f.type == "nav_menu_item") {
|
|
75
|
-
const S = /(-)?[0-9]+/g.exec(l),
|
|
76
|
-
h.find((c) => c.ID ==
|
|
75
|
+
const S = /(-)?[0-9]+/g.exec(l), k = parseInt(S[0]);
|
|
76
|
+
h.find((c) => c.ID == k) || h.push(f.value);
|
|
77
77
|
}
|
|
78
78
|
}), I({
|
|
79
79
|
...i,
|
|
@@ -87,7 +87,7 @@ const W = (r, s) => {
|
|
|
87
87
|
M(window.innerWidth <= 1200);
|
|
88
88
|
};
|
|
89
89
|
return n(), window.addEventListener("resize", n), () => window.removeEventListener("resize", n);
|
|
90
|
-
}, []), v && /* @__PURE__ */ e(
|
|
90
|
+
}, []), v && /* @__PURE__ */ e(L.Fragment, { children: v.items.filter((n) => n.url !== "#wpm-languages").map((n, h) => /* @__PURE__ */ u(L.Fragment, { children: [
|
|
91
91
|
/* @__PURE__ */ u(
|
|
92
92
|
d.Item,
|
|
93
93
|
{
|
|
@@ -121,7 +121,7 @@ const W = (r, s) => {
|
|
|
121
121
|
]
|
|
122
122
|
}
|
|
123
123
|
),
|
|
124
|
-
w && o && o.ID === n.ID && o.child_items && /* @__PURE__ */ e(
|
|
124
|
+
w && o && o.ID === n.ID && o.child_items && /* @__PURE__ */ e(L.Fragment, { children: o.child_items.map((l) => /* @__PURE__ */ u(
|
|
125
125
|
d.Item,
|
|
126
126
|
{
|
|
127
127
|
className: `divided child-item ${t === l.slug ? "active" : ""}`,
|
|
@@ -135,7 +135,7 @@ const W = (r, s) => {
|
|
|
135
135
|
] }, n.ID)) });
|
|
136
136
|
}
|
|
137
137
|
), G = ({ intl: r, settings: s }) => {
|
|
138
|
-
const [t, i] = p(), [a, o] = p(!1), [g, D] = p(!1), [
|
|
138
|
+
const [t, i] = p(), [a, o] = p(!1), [g, D] = p(!1), [z, v] = p(!1), [I, w] = p(!1), { slug: M } = $(), n = y(null), h = y(null), l = () => {
|
|
139
139
|
w(!I), o(!a);
|
|
140
140
|
};
|
|
141
141
|
_(() => {
|
|
@@ -166,11 +166,11 @@ const W = (r, s) => {
|
|
|
166
166
|
};
|
|
167
167
|
return c(), window.addEventListener("resize", c), () => window.removeEventListener("resize", c);
|
|
168
168
|
}, []);
|
|
169
|
-
const S = ({ media: c }) => c ? /* @__PURE__ */ e(U, { src: c.guid.rendered }) : /* @__PURE__ */ e("img", { className: "brand logo", size: "large", src: "/logo_full.png" }),
|
|
170
|
-
return /* @__PURE__ */ e(
|
|
169
|
+
const S = ({ media: c }) => c ? /* @__PURE__ */ e(U, { src: c.guid.rendered }) : /* @__PURE__ */ e("img", { className: "brand logo", size: "large", src: "/logo_full.png" }), k = (s == null ? void 0 : s.landing_page_url) && s.landing_page_url !== !1 && s.landing_page_url !== void 0 && s.landing_page_url !== "", O = k ? s.landing_page_url : `/${r.locale}`;
|
|
170
|
+
return /* @__PURE__ */ e(L.Fragment, { children: /* @__PURE__ */ u(H, { slug: "main", locale: r.locale, children: [
|
|
171
171
|
/* @__PURE__ */ u(b, { fluid: !0, className: "header", children: [
|
|
172
172
|
/* @__PURE__ */ e(b, { fluid: !0, className: "background", ref: n, children: /* @__PURE__ */ u(d, { className: "branding", text: !0, children: [
|
|
173
|
-
/* @__PURE__ */ e(d.Item, { children: /* @__PURE__ */ u("a", { href: `${O}`, target:
|
|
173
|
+
/* @__PURE__ */ e(d.Item, { children: /* @__PURE__ */ u("a", { href: `${O}`, target: k ? "_blank" : "_self", rel: "noopener noreferrer", id: "site_url", children: [
|
|
174
174
|
s.site_logo !== 0 && !f && /* @__PURE__ */ e(A, { id: s.site_logo, children: /* @__PURE__ */ e(V, { children: /* @__PURE__ */ e(S, {}, "logo") }) }),
|
|
175
175
|
s.site_logo === 0 && !f && /* @__PURE__ */ e(
|
|
176
176
|
"img",
|
|
@@ -194,7 +194,7 @@ const W = (r, s) => {
|
|
|
194
194
|
/* @__PURE__ */ e(P, { name: "za" }),
|
|
195
195
|
/* @__PURE__ */ e("div", { className: "site name", children: s.name })
|
|
196
196
|
] }),
|
|
197
|
-
!
|
|
197
|
+
!z && (g ? /* @__PURE__ */ e(d, { className: `pages ${a ? "show" : ""}`, children: /* @__PURE__ */ e(b, { fluid: !0, children: /* @__PURE__ */ e(E, { children: /* @__PURE__ */ e(
|
|
198
198
|
C,
|
|
199
199
|
{
|
|
200
200
|
settings: s,
|
|
@@ -204,7 +204,7 @@ const W = (r, s) => {
|
|
|
204
204
|
isSmallScreen: g
|
|
205
205
|
},
|
|
206
206
|
"items"
|
|
207
|
-
) }) }) }) : /* @__PURE__ */ e(d.Menu, { className: "pages", children: /* @__PURE__ */ e(
|
|
207
|
+
) }) }) }) : /* @__PURE__ */ e(d.Menu, { className: "pages", children: /* @__PURE__ */ e(E, { children: /* @__PURE__ */ e(
|
|
208
208
|
C,
|
|
209
209
|
{
|
|
210
210
|
settings: s,
|
|
@@ -214,20 +214,20 @@ const W = (r, s) => {
|
|
|
214
214
|
},
|
|
215
215
|
"items"
|
|
216
216
|
) }) })),
|
|
217
|
-
/* @__PURE__ */ e(d.Item, { children: /* @__PURE__ */ e(
|
|
217
|
+
/* @__PURE__ */ e(d.Item, { children: /* @__PURE__ */ e(E, { children: /* @__PURE__ */ e(
|
|
218
218
|
K,
|
|
219
219
|
{
|
|
220
220
|
locale: r.locale
|
|
221
221
|
},
|
|
222
222
|
"lang"
|
|
223
223
|
) }) }),
|
|
224
|
-
/* @__PURE__ */ e(d.Item, { fitted: !0, children: /* @__PURE__ */ e(
|
|
224
|
+
/* @__PURE__ */ e(d.Item, { fitted: !0, children: /* @__PURE__ */ e(E, { children: /* @__PURE__ */ e(
|
|
225
225
|
B,
|
|
226
226
|
{
|
|
227
227
|
onSetSelected: i,
|
|
228
228
|
settings: s
|
|
229
229
|
}
|
|
230
|
-
) }),
|
|
230
|
+
) }) }),
|
|
231
231
|
/* @__PURE__ */ u(
|
|
232
232
|
"div",
|
|
233
233
|
{
|
|
@@ -253,7 +253,7 @@ const W = (r, s) => {
|
|
|
253
253
|
}
|
|
254
254
|
) }) })
|
|
255
255
|
] }, "header-container"),
|
|
256
|
-
/* @__PURE__ */ e(b, { className: "url breadcrumbs", children: /* @__PURE__ */ e(
|
|
256
|
+
/* @__PURE__ */ e(b, { className: "url breadcrumbs", children: /* @__PURE__ */ e(E, { children: /* @__PURE__ */ e(q, {}) }) })
|
|
257
257
|
] }) });
|
|
258
258
|
}, se = R(G);
|
|
259
259
|
export {
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { utils as
|
|
4
|
-
import
|
|
5
|
-
import { createPortal as
|
|
1
|
+
import { jsx as t, jsxs as y, Fragment as T } from "react/jsx-runtime";
|
|
2
|
+
import { useState as w, useEffect as E, useContext as _, useRef as b } from "react";
|
|
3
|
+
import { utils as x, SearchProvider as z, SearchContext as H } from "@devgateway/wp-react-lib";
|
|
4
|
+
import P from "./CustomSemanticSearch.js";
|
|
5
|
+
import { createPortal as B } from "react-dom";
|
|
6
6
|
import { Icon as F } from "semantic-ui-react";
|
|
7
|
-
import { injectIntl as
|
|
8
|
-
const
|
|
9
|
-
if (!
|
|
10
|
-
const
|
|
11
|
-
return
|
|
12
|
-
},
|
|
7
|
+
import { injectIntl as M, IntlProvider as j } from "react-intl";
|
|
8
|
+
const I = (r, s) => {
|
|
9
|
+
if (!r || !s) return r || "";
|
|
10
|
+
const o = new RegExp(`(${s})`, "gi");
|
|
11
|
+
return r.replace(o, "<strong>$1</strong>");
|
|
12
|
+
}, R = M(
|
|
13
13
|
({
|
|
14
|
-
ID:
|
|
15
|
-
title:
|
|
16
|
-
slug:
|
|
17
|
-
parent_title:
|
|
14
|
+
ID: r,
|
|
15
|
+
title: s,
|
|
16
|
+
slug: o,
|
|
17
|
+
parent_title: i,
|
|
18
18
|
parent_slug: e,
|
|
19
|
-
parent_link:
|
|
20
|
-
extract:
|
|
21
|
-
type:
|
|
22
|
-
link:
|
|
23
|
-
terms:
|
|
24
|
-
subtype:
|
|
25
|
-
bread_crumbs:
|
|
26
|
-
metadata:
|
|
27
|
-
intl: { locale:
|
|
28
|
-
searchTerm:
|
|
19
|
+
parent_link: n,
|
|
20
|
+
extract: a,
|
|
21
|
+
type: d,
|
|
22
|
+
link: m,
|
|
23
|
+
terms: C,
|
|
24
|
+
subtype: p,
|
|
25
|
+
bread_crumbs: h = [],
|
|
26
|
+
metadata: l,
|
|
27
|
+
intl: { locale: f },
|
|
28
|
+
searchTerm: g
|
|
29
29
|
// Added searchTerm prop
|
|
30
30
|
}) => {
|
|
31
|
-
let
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
return /* @__PURE__ */
|
|
31
|
+
let S = n ? x.replaceLink(n, f) + `#${o}` : x.replaceLink(m, f);
|
|
32
|
+
const N = l == null ? void 0 : l.redirect_url;
|
|
33
|
+
S = N ? N + `#${o}` : S;
|
|
34
|
+
const c = I(String(s), g), u = I(a, g);
|
|
35
|
+
return /* @__PURE__ */ t(
|
|
36
36
|
"div",
|
|
37
37
|
{
|
|
38
38
|
className: "search-results-wrapper searching-results",
|
|
39
39
|
style: { display: "flex", flexDirection: "column" },
|
|
40
|
-
children: /* @__PURE__ */
|
|
40
|
+
children: /* @__PURE__ */ y(
|
|
41
41
|
"div",
|
|
42
42
|
{
|
|
43
43
|
className: "has-standard-12-font-size",
|
|
44
|
-
onClick: (
|
|
44
|
+
onClick: (L) => document.location.href = S,
|
|
45
45
|
children: [
|
|
46
|
-
/* @__PURE__ */
|
|
46
|
+
/* @__PURE__ */ t(
|
|
47
47
|
"h5",
|
|
48
48
|
{
|
|
49
49
|
className: "breadcrumbs-search",
|
|
50
50
|
dangerouslySetInnerHTML: {
|
|
51
|
-
__html:
|
|
51
|
+
__html: h && h.length > 0 ? I(h.join(" / "), g) : ""
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
),
|
|
55
|
-
/* @__PURE__ */
|
|
55
|
+
/* @__PURE__ */ t("div", { className: "has-standard-14-font-size", children: /* @__PURE__ */ t(
|
|
56
56
|
"h4",
|
|
57
57
|
{
|
|
58
58
|
className: "search-title",
|
|
59
59
|
dangerouslySetInnerHTML: {
|
|
60
|
-
__html:
|
|
60
|
+
__html: c
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
) }),
|
|
64
|
-
/* @__PURE__ */
|
|
64
|
+
/* @__PURE__ */ t(
|
|
65
65
|
"div",
|
|
66
66
|
{
|
|
67
67
|
className: "search-content",
|
|
68
68
|
dangerouslySetInnerHTML: {
|
|
69
|
-
__html:
|
|
69
|
+
__html: x.replaceHTMLinks(u, f)
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
)
|
|
@@ -76,180 +76,193 @@ const x = (o, t) => {
|
|
|
76
76
|
}
|
|
77
77
|
);
|
|
78
78
|
}
|
|
79
|
-
), k = ({ results:
|
|
80
|
-
const
|
|
81
|
-
return
|
|
82
|
-
/* @__PURE__ */
|
|
79
|
+
), k = ({ results: r, meta: s, perPage: o, intl: i, searchTerm: e }) => {
|
|
80
|
+
const n = s ? s["x-wp-total"] : 0;
|
|
81
|
+
return s && s["x-wp-totalpages"], /* @__PURE__ */ y("div", { id: "float-results-container", children: [
|
|
82
|
+
/* @__PURE__ */ t("span", { className: "float-results-header", children: i.formatMessage(
|
|
83
83
|
{
|
|
84
84
|
id: "search.results.summary",
|
|
85
85
|
defaultMessage: "{count} of {total} Results"
|
|
86
86
|
},
|
|
87
|
-
{ count:
|
|
87
|
+
{ count: n < o ? n : o, total: n }
|
|
88
88
|
) }),
|
|
89
|
-
|
|
89
|
+
r.map((a) => /* @__PURE__ */ t(R, { ...a, searchTerm: e }, a.ID))
|
|
90
90
|
] });
|
|
91
91
|
}, D = ({
|
|
92
|
-
onSearch:
|
|
93
|
-
perPage:
|
|
94
|
-
loading:
|
|
95
|
-
results:
|
|
92
|
+
onSearch: r,
|
|
93
|
+
perPage: s,
|
|
94
|
+
loading: o,
|
|
95
|
+
results: i,
|
|
96
96
|
meta: e,
|
|
97
|
-
intl:
|
|
98
|
-
}) => (e && e["x-wp-total"], e && e["x-wp-totalpages"], /* @__PURE__ */
|
|
97
|
+
intl: n
|
|
98
|
+
}) => (e && e["x-wp-total"], e && e["x-wp-totalpages"], /* @__PURE__ */ t(
|
|
99
99
|
"input",
|
|
100
100
|
{
|
|
101
|
-
placeholder:
|
|
101
|
+
placeholder: n.formatMessage({
|
|
102
102
|
id: "search.placeholder",
|
|
103
103
|
defaultMessage: "Search..."
|
|
104
104
|
}),
|
|
105
105
|
type: "text",
|
|
106
106
|
className: "input search",
|
|
107
107
|
name: "search",
|
|
108
|
-
onChange: (
|
|
109
|
-
|
|
108
|
+
onChange: (a) => {
|
|
109
|
+
r(a.target.value);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
)),
|
|
113
|
-
onSearch:
|
|
114
|
-
onSetSelected:
|
|
115
|
-
perPage:
|
|
116
|
-
loading:
|
|
112
|
+
)), $ = ({
|
|
113
|
+
onSearch: r,
|
|
114
|
+
onSetSelected: s,
|
|
115
|
+
perPage: o,
|
|
116
|
+
loading: i,
|
|
117
117
|
results: e,
|
|
118
|
-
meta:
|
|
119
|
-
locale:
|
|
120
|
-
intl:
|
|
121
|
-
searchTerm:
|
|
118
|
+
meta: n,
|
|
119
|
+
locale: a,
|
|
120
|
+
intl: d,
|
|
121
|
+
searchTerm: m,
|
|
122
122
|
// Added search from SearchConsumer
|
|
123
|
+
selected: C
|
|
124
|
+
// Added selected prop to track menu selection
|
|
123
125
|
}) => {
|
|
124
|
-
const [p,
|
|
125
|
-
|
|
126
|
-
const d = document.createElement("div");
|
|
127
|
-
d.setAttribute("id", "float-input-container"), d.setAttribute("class", "input container"), d.style.display = "none";
|
|
128
|
-
const m = document.getElementById("root");
|
|
129
|
-
return m && (m.appendChild(d), s.current = d), () => {
|
|
130
|
-
s.current && s.current.parentNode && s.current.parentNode.removeChild(s.current);
|
|
131
|
-
};
|
|
132
|
-
}, []), w(() => {
|
|
133
|
-
s.current && (s.current.style.display = p ? "block" : "none");
|
|
134
|
-
}, [p]);
|
|
135
|
-
const h = () => {
|
|
136
|
-
t(null), f(!0);
|
|
126
|
+
const [p, h] = w(!1), l = b(null), f = () => {
|
|
127
|
+
h(!1);
|
|
137
128
|
}, g = () => {
|
|
138
|
-
|
|
129
|
+
const c = document.getElementsByClassName("has-child-items");
|
|
130
|
+
for (let u = 0; u < c.length; u++) {
|
|
131
|
+
const v = c[u].getElementsByTagName("span");
|
|
132
|
+
v.length > 0 && v[0].addEventListener("mouseover", f);
|
|
133
|
+
}
|
|
134
|
+
}, S = () => {
|
|
135
|
+
const c = document.getElementsByClassName("has-child-items");
|
|
136
|
+
for (let u = 0; u < c.length; u++) {
|
|
137
|
+
const v = c[u].getElementsByTagName("span");
|
|
138
|
+
v.length > 0 && v[0].removeEventListener("mouseover", f);
|
|
139
|
+
}
|
|
139
140
|
};
|
|
140
|
-
return
|
|
141
|
-
|
|
141
|
+
return E(() => {
|
|
142
|
+
const c = document.createElement("div");
|
|
143
|
+
c.setAttribute("id", "float-input-container"), c.setAttribute("class", "input container"), c.style.display = "none";
|
|
144
|
+
const u = document.getElementById("root");
|
|
145
|
+
return u && (u.appendChild(c), l.current = c), () => {
|
|
146
|
+
l.current && l.current.parentNode && l.current.parentNode.removeChild(l.current);
|
|
147
|
+
};
|
|
148
|
+
}, []), E(() => {
|
|
149
|
+
l.current && (l.current.style.display = p ? "block" : "none"), p ? g() : S();
|
|
150
|
+
}, [p]), /* @__PURE__ */ y(T, { children: [
|
|
151
|
+
/* @__PURE__ */ t(
|
|
142
152
|
"div",
|
|
143
153
|
{
|
|
144
154
|
id: "ui-float-search",
|
|
145
155
|
className: "ui float-search",
|
|
146
|
-
onMouseOver:
|
|
147
|
-
|
|
156
|
+
onMouseOver: () => {
|
|
157
|
+
h(!0);
|
|
158
|
+
},
|
|
159
|
+
children: /* @__PURE__ */ t(F, { name: "search", size: "small" })
|
|
148
160
|
}
|
|
149
161
|
),
|
|
150
|
-
|
|
151
|
-
p ? /* @__PURE__ */
|
|
152
|
-
/* @__PURE__ */
|
|
162
|
+
l.current && B(
|
|
163
|
+
p ? /* @__PURE__ */ y("div", { onMouseLeave: f, children: [
|
|
164
|
+
/* @__PURE__ */ t("div", { className: "float-search-container", children: /* @__PURE__ */ t(
|
|
153
165
|
D,
|
|
154
166
|
{
|
|
155
|
-
onSearch:
|
|
156
|
-
perPage:
|
|
157
|
-
loading:
|
|
167
|
+
onSearch: r,
|
|
168
|
+
perPage: o,
|
|
169
|
+
loading: i,
|
|
158
170
|
results: e,
|
|
159
|
-
meta:
|
|
160
|
-
intl:
|
|
161
|
-
searchTerm:
|
|
171
|
+
meta: n,
|
|
172
|
+
intl: d,
|
|
173
|
+
searchTerm: m
|
|
162
174
|
}
|
|
163
175
|
) }),
|
|
164
|
-
e && e.length > 0 && /* @__PURE__ */
|
|
176
|
+
e && e.length > 0 && /* @__PURE__ */ t(j, { locale: a, children: /* @__PURE__ */ t(
|
|
165
177
|
k,
|
|
166
178
|
{
|
|
167
179
|
results: e,
|
|
168
|
-
meta:
|
|
169
|
-
perPage:
|
|
170
|
-
intl:
|
|
171
|
-
searchTerm:
|
|
180
|
+
meta: n,
|
|
181
|
+
perPage: o,
|
|
182
|
+
intl: d,
|
|
183
|
+
searchTerm: m
|
|
172
184
|
}
|
|
173
185
|
) })
|
|
174
186
|
] }) : null,
|
|
175
|
-
|
|
187
|
+
l.current
|
|
176
188
|
)
|
|
177
189
|
] });
|
|
178
|
-
},
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
const
|
|
182
|
-
|
|
190
|
+
}, W = ({ onSearch: r, perPage: s, loading: o, results: i, meta: e, intl: n }) => {
|
|
191
|
+
const a = e ? e["x-wp-total"] : 0, d = e ? e["x-wp-totalpages"] : 0, [m, C] = w("");
|
|
192
|
+
E(() => {
|
|
193
|
+
const h = setTimeout(() => {
|
|
194
|
+
r(m);
|
|
183
195
|
}, 300);
|
|
184
|
-
return () => clearTimeout(
|
|
185
|
-
}, [
|
|
186
|
-
const
|
|
187
|
-
return /* @__PURE__ */
|
|
188
|
-
|
|
196
|
+
return () => clearTimeout(h);
|
|
197
|
+
}, [m]);
|
|
198
|
+
const p = (h) => /* @__PURE__ */ t(R, { ...h, searchTerm: m });
|
|
199
|
+
return /* @__PURE__ */ t(
|
|
200
|
+
P,
|
|
189
201
|
{
|
|
190
|
-
value:
|
|
191
|
-
loading:
|
|
192
|
-
placeholder:
|
|
202
|
+
value: m,
|
|
203
|
+
loading: o,
|
|
204
|
+
placeholder: n.formatMessage({
|
|
193
205
|
id: "search.placeholder",
|
|
194
206
|
defaultMessage: "Search..."
|
|
195
207
|
}),
|
|
196
|
-
onResultSelect: (
|
|
197
|
-
total:
|
|
198
|
-
perPage:
|
|
199
|
-
totalPages:
|
|
200
|
-
onSearchChange: (
|
|
201
|
-
|
|
208
|
+
onResultSelect: (h, l) => null,
|
|
209
|
+
total: a,
|
|
210
|
+
perPage: s,
|
|
211
|
+
totalPages: d,
|
|
212
|
+
onSearchChange: (h, l) => {
|
|
213
|
+
C(l.value);
|
|
202
214
|
},
|
|
203
|
-
resultRenderer:
|
|
204
|
-
results:
|
|
215
|
+
resultRenderer: p,
|
|
216
|
+
results: i,
|
|
205
217
|
showNoResults: !1,
|
|
206
|
-
intl:
|
|
207
|
-
searchTerm:
|
|
218
|
+
intl: n,
|
|
219
|
+
searchTerm: m
|
|
208
220
|
}
|
|
209
221
|
);
|
|
210
|
-
},
|
|
211
|
-
const { intl:
|
|
212
|
-
return
|
|
213
|
-
const
|
|
214
|
-
|
|
222
|
+
}, V = M((r) => {
|
|
223
|
+
const { intl: s, onSetSelected: o } = r, [i, e] = w(""), [n, a] = w(!1);
|
|
224
|
+
return E(() => {
|
|
225
|
+
const d = () => {
|
|
226
|
+
a(window.innerWidth <= 1365);
|
|
215
227
|
};
|
|
216
|
-
return
|
|
217
|
-
}, []), /* @__PURE__ */
|
|
228
|
+
return d(), window.addEventListener("resize", d), () => window.removeEventListener("resize", d);
|
|
229
|
+
}, []), /* @__PURE__ */ t(z, { search: i, perPage: 5, locale: s.locale, children: /* @__PURE__ */ t(
|
|
218
230
|
A,
|
|
219
231
|
{
|
|
220
|
-
...
|
|
221
|
-
onSetSelected:
|
|
232
|
+
...r,
|
|
233
|
+
onSetSelected: o,
|
|
222
234
|
setQuery: e,
|
|
223
|
-
query:
|
|
224
|
-
isSmallScreen:
|
|
225
|
-
intl:
|
|
235
|
+
query: i,
|
|
236
|
+
isSmallScreen: n,
|
|
237
|
+
intl: s
|
|
226
238
|
}
|
|
227
239
|
) });
|
|
228
|
-
}), A = ({ onSetSelected:
|
|
229
|
-
const
|
|
230
|
-
return
|
|
231
|
-
|
|
240
|
+
}), A = ({ onSetSelected: r, selected: s, setQuery: o, query: i, isSmallScreen: e, intl: n, ...a }) => {
|
|
241
|
+
const d = _(H);
|
|
242
|
+
return a.settings.react_search_type === "floating" || e ? /* @__PURE__ */ t(
|
|
243
|
+
$,
|
|
232
244
|
{
|
|
233
|
-
onSetSelected:
|
|
234
|
-
|
|
245
|
+
onSetSelected: r,
|
|
246
|
+
selected: s,
|
|
247
|
+
onSearch: o,
|
|
235
248
|
perPage: 5,
|
|
236
|
-
intl:
|
|
237
|
-
...
|
|
238
|
-
...
|
|
239
|
-
searchTerm:
|
|
249
|
+
intl: n,
|
|
250
|
+
...a,
|
|
251
|
+
...d,
|
|
252
|
+
searchTerm: i
|
|
240
253
|
}
|
|
241
|
-
) : /* @__PURE__ */
|
|
242
|
-
|
|
254
|
+
) : /* @__PURE__ */ t(
|
|
255
|
+
W,
|
|
243
256
|
{
|
|
244
|
-
onSetSelected:
|
|
245
|
-
onSearch:
|
|
257
|
+
onSetSelected: r,
|
|
258
|
+
onSearch: o,
|
|
246
259
|
perPage: 5,
|
|
247
|
-
intl:
|
|
248
|
-
...
|
|
249
|
-
...
|
|
260
|
+
intl: n,
|
|
261
|
+
...a,
|
|
262
|
+
...d
|
|
250
263
|
}
|
|
251
264
|
);
|
|
252
265
|
};
|
|
253
266
|
export {
|
|
254
|
-
|
|
267
|
+
V as default
|
|
255
268
|
};
|
package/package.json
CHANGED