@devgateway/dvz-ui-react 1.7.1 → 1.7.2
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.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),h=require("react"),m=require("@devgateway/wp-react-lib"),M=require("./CustomSemanticSearch.js"),C=require("react-dom"),N=require("semantic-ui-react"),w=require("react-intl"),v=(s,r)=>{if(!s||!r)return s||"";const c=new RegExp(`(${r})`,"gi");return s.replace(c,"<strong>$1</strong>")},y=w.injectIntl(({ID:s,title:r,slug:c,parent_title:i,parent_slug:t,parent_link:n,extract:a,type:l,link:d,terms:j,subtype:f,bread_crumbs:u=[],metadata:o,intl:{locale:S},searchTerm:x})=>{let p=n?m.utils.replaceLink(n,S)+`#${c}`:m.utils.replaceLink(d,S);const g=o==null?void 0:o.redirect_url;p=g?g+`#${c}`:p;const R=v(String(r),x),I=v(a,x);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=p,children:[e.jsx("h5",{className:"breadcrumbs-search",dangerouslySetInnerHTML:{__html:u&&u.length>0?v(u.join(" / "),x):""}}),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,S)}})]})})}),E=({results:s,meta:r,perPage:c,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<c?n:c,total:n})}),s.map(a=>e.jsx(y,{...a,searchTerm:t},a.ID))]})},_=({onSearch:s,perPage:r,loading:c,results:i,meta:t,intl:n,searchTerm:a})=>(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",value:a,onChange:l=>{s(l.target.value)}})),L=({onSearch:s,onSetSelected:r,perPage:c,loading:i,results:t,meta:n,locale:a,intl:l,searchTerm:d,selected:j})=>{const[f,u]=h.useState(!1),o=h.useRef(null),S=()=>{u(!1)};h.useEffect(()=>{const p=document.createElement("div");p.setAttribute("id","float-input-container"),p.setAttribute("class","input container"),p.style.display="none";const g=document.getElementById("root");return g&&(g.appendChild(p),o.current=p),()=>{o.current&&o.current.parentNode&&o.current.parentNode.removeChild(o.current)}},[]),h.useEffect(()=>{o.current&&(o.current.style.display=f?"block":"none")},[f]);const x=()=>{u(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{id:"ui-float-search",className
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),h=require("react"),m=require("@devgateway/wp-react-lib"),M=require("./CustomSemanticSearch.js"),C=require("react-dom"),N=require("semantic-ui-react"),w=require("react-intl"),v=(s,r)=>{if(!s||!r)return s||"";const c=new RegExp(`(${r})`,"gi");return s.replace(c,"<strong>$1</strong>")},y=w.injectIntl(({ID:s,title:r,slug:c,parent_title:i,parent_slug:t,parent_link:n,extract:a,type:l,link:d,terms:j,subtype:f,bread_crumbs:u=[],metadata:o,intl:{locale:S},searchTerm:x})=>{let p=n?m.utils.replaceLink(n,S)+`#${c}`:m.utils.replaceLink(d,S);const g=o==null?void 0:o.redirect_url;p=g?g+`#${c}`:p;const R=v(String(r),x),I=v(a,x);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=p,children:[e.jsx("h5",{className:"breadcrumbs-search",dangerouslySetInnerHTML:{__html:u&&u.length>0?v(u.join(" / "),x):""}}),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,S)}})]})})}),E=({results:s,meta:r,perPage:c,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<c?n:c,total:n})}),s.map(a=>e.jsx(y,{...a,searchTerm:t},a.ID))]})},_=({onSearch:s,perPage:r,loading:c,results:i,meta:t,intl:n,searchTerm:a})=>(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",value:a,onChange:l=>{s(l.target.value)}})),L=({onSearch:s,onSetSelected:r,perPage:c,loading:i,results:t,meta:n,locale:a,intl:l,searchTerm:d,selected:j})=>{const[f,u]=h.useState(!1),o=h.useRef(null),S=()=>{u(!1)};h.useEffect(()=>{const p=document.createElement("div");p.setAttribute("id","float-input-container"),p.setAttribute("class","input container"),p.style.display="none";const g=document.getElementById("root");return g&&(g.appendChild(p),o.current=p),()=>{o.current&&o.current.parentNode&&o.current.parentNode.removeChild(o.current)}},[]),h.useEffect(()=>{o.current&&(o.current.style.display=f?"block":"none")},[f]);const x=()=>{u(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{id:"ui-float-search",className:`ui float-search${f?" ui-float-search-active":""}`,onMouseOver:x,children:e.jsx(N.Icon,{name:"search",size:"small"})}),o.current&&C.createPortal(f?e.jsxs("div",{onMouseLeave:S,children:[e.jsx("div",{className:"float-search-container",children:e.jsx(_,{onSearch:s,perPage:c,loading:i,results:t,meta:n,intl:l,searchTerm:d})}),t&&t.length>0&&e.jsx(w.IntlProvider,{locale:a,children:e.jsx(E,{results:t,meta:n,perPage:c,intl:l,searchTerm:d})})]}):null,o.current)]})},b=({onSearch:s,perPage:r,loading:c,results:i,meta:t,intl:n})=>{const a=t?t["x-wp-total"]:0,l=t?t["x-wp-totalpages"]:0,[d,j]=h.useState("");h.useEffect(()=>{const u=setTimeout(()=>{s(d)},300);return()=>clearTimeout(u)},[d]);const f=u=>e.jsx(y,{...u,searchTerm:d});return e.jsx(M.default,{value:d,loading:c,placeholder:n.formatMessage({id:"search.placeholder",defaultMessage:"Search..."}),onResultSelect:(u,o)=>null,total:a,perPage:r,totalPages:l,onSearchChange:(u,o)=>{j(o.value)},resultRenderer:f,results:i,showNoResults:!1,intl:n,searchTerm:d})},q=w.injectIntl(s=>{const{intl:r,onSetSelected:c}=s,[i,t]=h.useState(""),[n,a]=h.useState(!1);return h.useEffect(()=>{const l=()=>{a(window.innerWidth<=1365)};return l(),window.addEventListener("resize",l),()=>window.removeEventListener("resize",l)},[]),e.jsx(m.SearchProvider,{search:i,perPage:5,locale:r.locale,children:e.jsx(T,{...s,onSetSelected:c,setQuery:t,query:i,isSmallScreen:n,intl:r})})}),T=({onSetSelected:s,selected:r,setQuery:c,query:i,isSmallScreen:t,intl:n,...a})=>{const l=h.useContext(m.SearchContext);return a.settings.react_search_type==="floating"||t?e.jsx(L,{onSetSelected:s,selected:r,onSearch:c,perPage:5,intl:n,...a,...l,searchTerm:i}):e.jsx(b,{onSetSelected:s,onSearch:c,perPage:5,intl:n,...a,...l})};exports.default=q;
|
|
@@ -4,7 +4,7 @@ import { utils as x, SearchProvider as T, SearchContext as b } from "@devgateway
|
|
|
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
|
-
import { injectIntl as I, IntlProvider as
|
|
7
|
+
import { injectIntl as I, IntlProvider as $ } from "react-intl";
|
|
8
8
|
const C = (n, s) => {
|
|
9
9
|
if (!n || !s) return n || "";
|
|
10
10
|
const o = new RegExp(`(${s})`, "gi");
|
|
@@ -76,7 +76,7 @@ const C = (n, s) => {
|
|
|
76
76
|
}
|
|
77
77
|
);
|
|
78
78
|
}
|
|
79
|
-
),
|
|
79
|
+
), j = ({ results: n, meta: s, perPage: o, intl: i, searchTerm: e }) => {
|
|
80
80
|
const r = s ? s["x-wp-total"] : 0;
|
|
81
81
|
return s && s["x-wp-totalpages"], /* @__PURE__ */ S("div", { id: "float-results-container", children: [
|
|
82
82
|
/* @__PURE__ */ t("span", { className: "float-results-header", children: i.formatMessage(
|
|
@@ -88,7 +88,7 @@ const C = (n, s) => {
|
|
|
88
88
|
) }),
|
|
89
89
|
n.map((a) => /* @__PURE__ */ t(N, { ...a, searchTerm: e }, a.ID))
|
|
90
90
|
] });
|
|
91
|
-
},
|
|
91
|
+
}, k = ({
|
|
92
92
|
onSearch: n,
|
|
93
93
|
perPage: s,
|
|
94
94
|
loading: o,
|
|
@@ -111,7 +111,7 @@ const C = (n, s) => {
|
|
|
111
111
|
n(l.target.value);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
)),
|
|
114
|
+
)), D = ({
|
|
115
115
|
onSearch: n,
|
|
116
116
|
onSetSelected: s,
|
|
117
117
|
perPage: o,
|
|
@@ -142,7 +142,7 @@ const C = (n, s) => {
|
|
|
142
142
|
"div",
|
|
143
143
|
{
|
|
144
144
|
id: "ui-float-search",
|
|
145
|
-
className:
|
|
145
|
+
className: `ui float-search${p ? " ui-float-search-active" : ""}`,
|
|
146
146
|
onMouseOver: () => {
|
|
147
147
|
u(!0);
|
|
148
148
|
},
|
|
@@ -152,7 +152,7 @@ const C = (n, s) => {
|
|
|
152
152
|
c.current && P(
|
|
153
153
|
p ? /* @__PURE__ */ S("div", { onMouseLeave: m, children: [
|
|
154
154
|
/* @__PURE__ */ t("div", { className: "float-search-container", children: /* @__PURE__ */ t(
|
|
155
|
-
|
|
155
|
+
k,
|
|
156
156
|
{
|
|
157
157
|
onSearch: n,
|
|
158
158
|
perPage: o,
|
|
@@ -163,8 +163,8 @@ const C = (n, s) => {
|
|
|
163
163
|
searchTerm: d
|
|
164
164
|
}
|
|
165
165
|
) }),
|
|
166
|
-
e && e.length > 0 && /* @__PURE__ */ t(
|
|
167
|
-
|
|
166
|
+
e && e.length > 0 && /* @__PURE__ */ t($, { locale: a, children: /* @__PURE__ */ t(
|
|
167
|
+
j,
|
|
168
168
|
{
|
|
169
169
|
results: e,
|
|
170
170
|
meta: r,
|
|
@@ -177,7 +177,7 @@ const C = (n, s) => {
|
|
|
177
177
|
c.current
|
|
178
178
|
)
|
|
179
179
|
] });
|
|
180
|
-
},
|
|
180
|
+
}, H = ({ onSearch: n, perPage: s, loading: o, results: i, meta: e, intl: r }) => {
|
|
181
181
|
const a = e ? e["x-wp-total"] : 0, l = e ? e["x-wp-totalpages"] : 0, [d, y] = v("");
|
|
182
182
|
w(() => {
|
|
183
183
|
const u = setTimeout(() => {
|
|
@@ -230,7 +230,7 @@ const C = (n, s) => {
|
|
|
230
230
|
}), A = ({ onSetSelected: n, selected: s, setQuery: o, query: i, isSmallScreen: e, intl: r, ...a }) => {
|
|
231
231
|
const l = _(b);
|
|
232
232
|
return a.settings.react_search_type === "floating" || e ? /* @__PURE__ */ t(
|
|
233
|
-
|
|
233
|
+
D,
|
|
234
234
|
{
|
|
235
235
|
onSetSelected: n,
|
|
236
236
|
selected: s,
|
|
@@ -242,7 +242,7 @@ const C = (n, s) => {
|
|
|
242
242
|
searchTerm: i
|
|
243
243
|
}
|
|
244
244
|
) : /* @__PURE__ */ t(
|
|
245
|
-
|
|
245
|
+
H,
|
|
246
246
|
{
|
|
247
247
|
onSetSelected: n,
|
|
248
248
|
onSearch: o,
|