@devgateway/dvz-ui-react 1.6.9 → 1.6.10

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