@devgateway/dvz-ui-react 1.7.4 → 1.7.5
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.
- package/dist/cjs/embeddable/filtered-posts/NoData.js +2 -2
- package/dist/cjs/embeddable/filtered-posts/index.js +1 -1
- package/dist/cjs/embeddable/posts-filter/CategoricalFilter.js +1 -1
- package/dist/cjs/embeddable/posts-filter/index.js +1 -1
- package/dist/cjs/embeddable/reducers/data-api.js +1 -1
- package/dist/esm/embeddable/filtered-posts/NoData.js +13 -14
- package/dist/esm/embeddable/filtered-posts/index.js +69 -64
- package/dist/esm/embeddable/posts-filter/CategoricalFilter.js +56 -53
- package/dist/esm/embeddable/posts-filter/index.js +139 -148
- package/dist/esm/embeddable/reducers/data-api.js +46 -45
- package/dist/types/embeddable/filtered-posts/NoData.d.ts +1 -0
- package/dist/types/embeddable/filtered-posts/index.d.ts +4 -0
- package/dist/types/embeddable/filtered-posts/utils.d.ts +2 -1
- package/dist/types/embeddable/posts-filter/CategoricalFilter.d.ts +1 -0
- package/dist/types/embeddable/posts-filter/index.d.ts +2 -0
- package/dist/types/embeddable/reducers/data-api.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),n=require("../../redux/hooks.js"),t=require("semantic-ui-react"),d=require("../reducers/data.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),n=require("../../redux/hooks.js"),t=require("semantic-ui-react"),d=require("../reducers/data.js"),g=a=>{const{noDataMsg:l,clearFilterMsg:i,editing:p,group:s}=a,r=n.useAppDispatch(),o=n.useAppSelector(c=>c.getIn(["data","posts","initialFilters",s])),u=c=>{c.preventDefault(),d.clearPostsFilter({group:s,dispatch:r,initialFilters:o})};return e.jsxs(t.Segment,{placeholder:!0,className:"chartNoDataMessage",children:[e.jsxs(t.Header,{icon:!0,children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"noDataSVG",viewBox:"0 0 512 512",children:e.jsx("path",{d:`M403.7,96.3c-41-41-95.6-63.6-153.7-63.6c-58,0-112.6,22.6-153.7,63.6c-41,41-63.6,95.6-63.6,153.7
|
|
2
2
|
c0,58,22.6,112.6,63.6,153.7c41,41,95.6,63.6,153.7,63.6c58,0,112.6-22.6,153.7-63.6c41-41,63.7-95.6,63.7-153.7
|
|
3
3
|
C467.3,192,444.7,137.4,403.7,96.3z M57.7,250C57.7,144,144,57.7,250,57.7c37.2,0,72,10.6,101.5,29l-63,77.1c-2.8-3.5-6-6.8-9.5-10
|
|
4
4
|
c-18.2-16.7-39.9-24.5-65.1-23.5c-25.2,1.1-46.2,10.7-62.9,28.9c-16.7,18.2-24.5,39.9-23.5,65.1c1.1,25.2,10.7,46.2,28.9,62.9
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
c4,3.7,7.3,7.6,10.1,11.8L194.6,278.8z M250,442.3c-46,0-88.2-16.2-121.3-43.2l73.1-89.5c6.4,1,13,1.4,19.9,1.1
|
|
9
9
|
c10.2-0.4,19.7-2.5,28.6-6.1c8.9-3.6,16.7-8.4,23.4-14.2l81,74.4c2.6,2.4,6,3.6,9.3,3.6c3.7,0,7.4-1.5,10.1-4.5
|
|
10
10
|
c5.1-5.6,4.8-14.3-0.8-19.4l-81-74.4c5.3-7.2,9.3-15.3,12.2-24.5c2.8-9.2,4.1-18.8,3.6-29c-0.5-10.7-2.5-20.6-6-29.8l69.8-85.5
|
|
11
|
-
c43,35.3,70.5,88.8,70.5,148.7C442.3,356,356,442.3,250,442.3z`})}),
|
|
11
|
+
c43,35.3,70.5,88.8,70.5,148.7C442.3,356,356,442.3,250,442.3z`})}),e.jsx("div",{className:"WPnoDataMsg",children:l})]}),e.jsx(t.Button,{size:"medium",onClick:c=>u(c),children:i||"Clear Filter"})]})};exports.default=g;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),y=require("react"),p=require("semantic-ui-react"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),y=require("react"),p=require("semantic-ui-react"),rt=require("../connected-templates/PostIntro.js"),ot=require("react-intl"),Y=require("./utils.js"),nt=require("./NoData.js"),B=require("react-redux"),st=require("../reducers/data-api.js"),at=require("react-router"),H=require("../../utils/data.js"),it=T=>{const{posts:l,numberOfColumns:w,sortFirstBy:u,countryCategory:c,postWidth:b,postHeight:A}=T,g=[];if(c&&u&&u!=="none"){const d=l.filter(h=>h[c].includes(Number(u))),N=l.filter(h=>!h[c].includes(Number(u)));g.push(...d),g.push(...N)}else g.push(...l);return a.jsx(p.Grid,{className:"filtered-posts",columns:w,children:a.jsx(p.GridRow,{children:g.map(d=>a.jsx(p.Grid.Column,{children:a.jsx("div",{className:"filtered-posts-column",style:{width:b,height:A,overflow:"hidden"},children:a.jsx(rt.default,{style:{width:"100%",height:"100%",overflow:"hidden",margin:0,padding:0},as:p.Container,fluid:!0,post:d},d.id)})},d.id))})})},lt=T=>{const{"data-group":l,"data-number-of-columns":w,"data-type":u,"data-taxonomy":c,"data-categories":b="[]","data-height":A,"data-post-width":g,"data-post-height":d,"data-number-of-items-per-page":N,"data-enable-sorting":h,"data-sort-first-by":q,"data-sorting-taxonomy":R,"data-wordpress-source-type":ct,"data-wordpress-source":V,"data-no-data-msg":z,"data-clear-filter-msg":W,editing:J}=T,L=B.useDispatch(),{locale:U}=at.useParams(),[I,v]=y.useState(!1),O=B.useSelector(t=>t).getIn(["data","posts",l]),[C,S]=y.useState([]),D=y.useRef(null),[E,_]=y.useState(void 0),$=H.toBoolean(h)&&q!=="none"?H.toNumber(q):null,f=O??{yearFilter:null,categoryFilter:null,countryFilter:null,page:1,countryTaxonomy:null,categoryTaxonomy:null},F=t=>{if(t==null)return{values:[],isExplicitNone:!1};const e=Array.isArray(t)?t:[t],s=e.some(r=>Number(r)===Number.MIN_SAFE_INTEGER);return{values:e.map(r=>Number(r)).filter(r=>Number.isFinite(r)&&r!==Number.MIN_SAFE_INTEGER),isExplicitNone:s}},k=t=>{if(!t||t.length===0)return null;const e=Array.from(new Set(t)).sort((P,j)=>P-j);if(e.length===0)return null;const s=e[0],o=e[e.length-1],r=Y.getStartDateAndEndDateFromYear(s),n=Y.getStartDateAndEndDateFromYear(o);return!(r!=null&&r.startDate)||!(n!=null&&n.endDate)?null:{startDate:r.startDate,endDate:n.endDate}},K=()=>{const t=F(f.yearFilter),e=t.isExplicitNone?null:k(t.values),s=f.countryFilter??null,o=f.categoryFilter??null,r=f.categoryTaxonomy||(c&&c!=="none"?c:null),n=f.countryTaxonomy||null;return{before:(e==null?void 0:e.endDate)||null,after:(e==null?void 0:e.startDate)||null,categoryFilter:o,categoryTaxonomy:r,countryFilter:s,countryTaxonomy:n}},M=t=>J?t:decodeURIComponent(t),Q=t=>{try{return JSON.parse(M(t))}catch(e){return console.warn("JSON parsing failed for value:",t,"- treating as plain string. Error:",e),M(t)}},X=()=>{const t=Q(b);return t?typeof t=="string"?t.split(",").map(Number):typeof t=="number"?[t]:t:[]},Z=(t,e,s)=>{if(s)return null;if(t.length===0)return e.length>0?e:null;if(e.length===0)return t;const o=new Set(t),r=e.filter(n=>o.has(n));return r.length>0?r:null},tt=async()=>{D.current&&_(D.current.offsetHeight),v(!0);const t=K(),e=F(X()).values,s=F(t.categoryFilter),o=Z(e,s.values,s.isExplicitNone),r=F(t.countryFilter);if(s.isExplicitNone){S([]),v(!1);return}if(r.isExplicitNone){S([]),v(!1);return}const n=new Map;t.categoryTaxonomy&&o&&o.length>0&&n.set(t.categoryTaxonomy,o),t.countryTaxonomy&&r.values.length>0&&n.set(t.countryTaxonomy,r.values);const P=o?o.join(","):void 0,j={after:t.after,before:t.before,perPage:Number(N||10),page:f.page||1,locale:U||"en",postType:u,taxonomy:t.categoryTaxonomy||void 0,category:P||void 0,taxonomyFilters:n,ordering:"date",orderingDirection:"desc",wpApiBase:V??void 0};await st.getCustomPosts(j).then(i=>{if(i){let x=null,m=null;if(i&&typeof i=="object"&&"data"in i?(x=i.data,m=i.meta):(Array.isArray(i),x=i),S(Array.isArray(x)?x:[]),m){const G=m["x-wp-totalpages"]?m["x-wp-totalpages"]:1,et=m["x-wp-total"]?m["x-wp-total"]:0;G&&L({type:"SET_POSTS_PAGINATION",group:l,totalPages:Number(G),totalItems:Number(et)})}}else S([])}).finally(()=>{v(!1),_(void 0)})};return y.useEffect(()=>{u&&(async()=>await tt())()},[O,u,c,N,b,R]),a.jsx("div",{ref:D,id:`filtered-posts-${l}`,style:E!==void 0?{minHeight:E,border:"1px solid #e0e0e0",borderRadius:"4px"}:void 0,children:a.jsx(p.Container,{fluid:!0,children:I?a.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:E??"100%"},children:a.jsx(p.Loader,{active:!0,inline:"centered"})}):!I&&C&&C.length>0?a.jsx(it,{posts:C,postWidth:Number(g),postHeight:Number(d),numberOfColumns:Number(w),sortFirstBy:$,countryCategory:R}):a.jsx(nt.default,{noDataMsg:z,clearFilterMsg:W,group:l})})})},ut=ot.injectIntl(y.memo(lt));exports.default=ut;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=require("react/jsx-runtime"),c=require("react"),q=require("./PostsFilterDropdown.js"),F=require("../../conf/index.js"),R=u=>{const{taxonomy:n,group:p,placeholder:f,allLabel:d,noneLabel:g,useSingleColumn:y,enableTextSearch:m,filterType:h,showNoDataOption:x,closeOnSelect:S,allNoneSameBehaviour:O,autoApply:P,alphabeticalSort:A,ascOrder:b,type:v,categories:s,onChange:T,wpApiBase:t,...w}=u,[B,e]=c.useState([]),C=async()=>{if(!n||n==="none"){e([]);return}const i=t!=null&&t!==""?t:F.Config.REACT_APP_WP_API;console.log("Fetching taxonomy options from API base:",i);const r=await(await fetch(i+"/wp/v2/"+n)).json();if(r){const l=r.map(o=>({key:o.id,value:o.id,text:o.name}));if(s){const o=l.filter(_=>s.indexOf(_.value.toString())>-1);e([]),e(o)}else e([]),e(l)}};return c.useEffect(()=>{let a=!1;return a||(e([]),C()),()=>{a=!0}},[v,n,s,t]),j.jsx(q.default,{...w,group:p,placeholder:f,allLabel:d,noneLabel:g,useSingleColumn:y,enableTextSearch:m,filterType:h,showNoDataOption:x,closeOnSelect:S,allNoneSameBehaviour:O,autoApply:P,alphabeticalSort:A,ascOrder:b,options:B,onChange:T})};exports.default=R;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("react/jsx-runtime"),c=require("react"),ne=require("semantic-ui-react"),s=require("../../utils/data.js"),se=require("../../redux/hooks.js"),ie=require("react-redux"),ce=require("./CategoricalFilter.js"),ue=require("./YearFilter.js"),ye=E=>{const{"data-alphabetical-sort":Y,"data-asc-order":L,"data-group":u,"data-placeholder":T,"data-all-label":C,"data-none-label":b,"data-use-single-column":R,"data-enable-text-search":q,"data-filter-type":p,"data-show-no-data-option":v,"data-close-on-select":M,"data-all-none-same-behaviour":D,"data-auto-apply":P,"data-taxonomy":i,"data-categories":F="[]","data-is-country-filter":j,"data-is-year-filter":z,"data-type":J,"data-sort-first-by":B,"data-default-values":K="[]","data-wordpress-source-type":de,"data-wordpress-source":U,editing:k=!1}=E,d=se.useAppDispatch(),e=ie.useSelector(t=>t.getIn(["data","posts",u]))||{},l=p==="multi-select",[x,Fe]=c.useState(0),O=t=>k?t:decodeURIComponent(t);let n=(t=>{try{return JSON.parse(O(t))}catch(o){return console.warn("JSON parsing failed for value:",t,"- treating as plain string. Error:",o),O(t)}})(K);n||(n=[]),typeof n=="string"&&(n=n.split(",").map(Number)),typeof n=="number"&&(n=[n]);const $=s.toBoolean(Y),G=s.toBoolean(L),N=s.toBoolean(v),V=s.toBoolean(M),_=s.toBoolean(D),A=s.toBoolean(P),r=s.toBoolean(j),a=s.toBoolean(z),I=s.toBoolean(R),w=s.toBoolean(q),g=B!=="none"?s.toNumber(B):null,[y,H]=c.useState([]),[m,Q]=c.useState(!1),S=(t,o)=>o?Array.isArray(t)?t:t!=null?[t]:[]:t||void 0,W=c.useMemo(()=>S(e.countryFilter,l),[e.countryFilter,l]),X=c.useMemo(()=>S(e.categoryFilter,l),[e.categoryFilter,l]),Z=c.useMemo(()=>a?S(e.yearFilter,l):void 0,[e.yearFilter,l,a]),h=c.useMemo(()=>F?F.split(","):[],[F]),ee=t=>{d({type:"SET_POSTS_FILTER",group:u,...e,isYearFilter:a,yearFilter:a?t:null,isCountryFilter:r,categoryFilter:e.categoryFilter,countryFilter:e.countryFilter,sortFirstBy:g,countryCategory:i,categoryTaxonomy:i,countryTaxonomy:i})},te=t=>{d({type:"SET_POSTS_FILTER",group:u,...e,categoryFilter:r?e.categoryFilter:t,countryFilter:r?t:e.countryFilter,isYearFilter:a,yearFilter:e.yearFilter,isCountryFilter:r,sortFirstBy:r?g:e.sortFirstBy,countryCategory:r?i:e.countryCategory,categoryCategory:r?e.categoryCategory:t,categoryTaxonomy:r?e.categoryTaxonomy:i,countryTaxonomy:r?i:e.countryTaxonomy})};return c.useEffect(()=>{const t=n.length>0,o=l?n:n[0],re=r?e.categoryFilter:t?o:l?h.map(Number):e.categoryFilter,ae=r?t?o:l?h.map(Number):e.countryFilter:e.countryFilter,oe=a&&l?y.length>0?y.map(le=>le.value):[]:e.yearFilter;d({type:"SET_INITIAL_POSTS_FILTER",group:u,categoryFilter:re,countryFilter:ae,isYearFilter:a,isCountryFilter:r,sortFirstBy:g,yearFilter:a?oe:null,categoryCategory:r?null:e.categoryCategory,categoryTaxonomy:r?null:i,countryCategory:r?i:null,countryTaxonomy:r?i:null,page:1})},[]),c.useEffect(()=>{if(a&&!m){const t=a&&l?y.length>0?y.map(o=>o.value):[]:e.yearFilter;d({type:"SET_INITIAL_POSTS_FILTER",group:u,...e,isYearFilter:a,yearFilter:a?t:null})}},[m]),f.jsxs(ne.Container,{fluid:!0,className:"filter post-filter",children:[a&&f.jsx(ue.default,{group:u,placeholder:T,allLabel:C,noneLabel:b,useSingleColumn:I,enableTextSearch:w,filterType:p,showNoDataOption:N,closeOnSelect:V,allNoneSameBehaviour:_,autoApply:A,alphabeticalSort:$,ascOrder:G,options:y,value:Z,yearOptions:y,setYearOptions:H,yearFilterLoading:m,setYearFilterLoading:Q,onChange:(t,o)=>{ee(o)},resetKey:x}),!a&&f.jsx(ce.default,{group:u,placeholder:T,allLabel:C,noneLabel:b,useSingleColumn:I,enableTextSearch:w,filterType:p,showNoDataOption:N,closeOnSelect:V,allNoneSameBehaviour:_,autoApply:A,taxonomy:i,type:J,value:r?W:X,onChange:(t,o)=>{te(o)},categories:h,resetKey:x,wpApiBase:U??void 0},`cat-${u}`)]})};exports.default=ye;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("../../conf/index.js"),O=require("../../api/commons.js");function p(n){return JSON.parse(JSON.stringify(n))}const u=process.env.VITE_REACT_APP_API_ROOT||A.Config.REACT_APP_API_ROOT||null,T=typeof window<"u"?window.location.origin:"",d={},l={},E=3*60*1e3;function C(n){return Object.keys(n).map(t=>encodeURIComponent(t)+"="+encodeURIComponent(n[t])).join("&")}function S(n,t=!1){const e=n,o=Date.now();if(l[e]&&o-l[e].timestamp<E)return Promise.resolve(p(l[e].data));if(d[e])return d[e].then(p);const g=O.get(n,{},t).then(a=>(l[e]={data:a,timestamp:Date.now()},t?{data:p(a),meta:l[e].meta}:p(a))).finally(()=>{delete d[e]});return d[e]=g,g}const b=({app:n,params:t})=>{const e=`${u||T}/api/${n}/categories${t?"?"+C(t):""}`;return S(e)},j=({app:n,type:t,params:e})=>{const o=`${u||""}/api/${n}/categories/${t}${e?"?"+C(e):""}`;return S(o)},D=({source:n,app:t,params:e})=>{const o=`${u||T}/api/${t}/stats/${n}${e?"?"+C(e):""}`;return S(o)},k=({postType:n,taxonomy:t,category:e,taxonomyFilters:o,before:g,perPage:a,page:_,locale:R,after:y,ordering:q,orderingDirection:I,wpApiBase:f})=>{const $=f!=null&&f!==""?f:A.Config.REACT_APP_WP_API;console.log("Using API base:",$);const U=`${$}/wp/v2/${n}`,r=new URLSearchParams,P=new Map,h=(s,i)=>{if(!s||i==null)return;const c=P.get(s)||[];Array.isArray(i)?i.forEach(m=>{m!=null&&c.push(String(m))}):c.push(String(i)),P.set(s,c)};o&&o instanceof Map&&o.forEach((s,i)=>{h(i,s)}),t&&e!=null&&h(t,e),P.forEach((s,i)=>{const c=Array.from(new Set(s));c.length!==0&&r.set(i,c.join(","))}),g&&r.append("before",g.toISOString()),a&&r.append("per_page",a.toString()),r.append("page",_.toString()),r.append("locale",R),y&&r.append("after",y.toISOString()),r.append("orderby",q),r.append("order",I);const w=r.toString().replace(/%2C/g,",");return O.get(`${U}?${w}`,{headers:{"Content-Type":"application/json"}},!0)};exports.getCategories=b;exports.getCategory=j;exports.getCustomPosts=k;exports.getData=D;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useAppDispatch as p, useAppSelector as
|
|
3
|
-
import { Segment as
|
|
1
|
+
import { jsxs as n, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useAppDispatch as p, useAppSelector as m } from "../../redux/hooks.js";
|
|
3
|
+
import { Segment as d, Header as g, Button as h } from "semantic-ui-react";
|
|
4
4
|
import { clearPostsFilter as u } from "../reducers/data.js";
|
|
5
|
-
const
|
|
6
|
-
const { noDataMsg:
|
|
7
|
-
c.preventDefault(), u({ group:
|
|
5
|
+
const F = (s) => {
|
|
6
|
+
const { noDataMsg: a, clearFilterMsg: l, editing: M, group: e } = s, r = p(), i = m((c) => c.getIn(["data", "posts", "initialFilters", e])), o = (c) => {
|
|
7
|
+
c.preventDefault(), u({ group: e, dispatch: r, initialFilters: i });
|
|
8
8
|
};
|
|
9
|
-
return /* @__PURE__ */
|
|
10
|
-
/* @__PURE__ */
|
|
11
|
-
/* @__PURE__ */
|
|
9
|
+
return /* @__PURE__ */ n(d, { placeholder: !0, className: "chartNoDataMessage", children: [
|
|
10
|
+
/* @__PURE__ */ n(g, { icon: !0, children: [
|
|
11
|
+
/* @__PURE__ */ t(
|
|
12
12
|
"svg",
|
|
13
13
|
{
|
|
14
14
|
xmlns: "http://www.w3.org/2000/svg",
|
|
15
15
|
className: "noDataSVG",
|
|
16
16
|
viewBox: "0 0 512 512",
|
|
17
|
-
children: /* @__PURE__ */
|
|
17
|
+
children: /* @__PURE__ */ t("path", { d: `M403.7,96.3c-41-41-95.6-63.6-153.7-63.6c-58,0-112.6,22.6-153.7,63.6c-41,41-63.6,95.6-63.6,153.7
|
|
18
18
|
c0,58,22.6,112.6,63.6,153.7c41,41,95.6,63.6,153.7,63.6c58,0,112.6-22.6,153.7-63.6c41-41,63.7-95.6,63.7-153.7
|
|
19
19
|
C467.3,192,444.7,137.4,403.7,96.3z M57.7,250C57.7,144,144,57.7,250,57.7c37.2,0,72,10.6,101.5,29l-63,77.1c-2.8-3.5-6-6.8-9.5-10
|
|
20
20
|
c-18.2-16.7-39.9-24.5-65.1-23.5c-25.2,1.1-46.2,10.7-62.9,28.9c-16.7,18.2-24.5,39.9-23.5,65.1c1.1,25.2,10.7,46.2,28.9,62.9
|
|
@@ -27,12 +27,11 @@ const f = (n) => {
|
|
|
27
27
|
c43,35.3,70.5,88.8,70.5,148.7C442.3,356,356,442.3,250,442.3z` })
|
|
28
28
|
}
|
|
29
29
|
),
|
|
30
|
-
|
|
31
|
-
/* @__PURE__ */ e("div", { className: "WPnoDataMsg", children: r })
|
|
30
|
+
/* @__PURE__ */ t("div", { className: "WPnoDataMsg", children: a })
|
|
32
31
|
] }),
|
|
33
|
-
/* @__PURE__ */
|
|
32
|
+
/* @__PURE__ */ t(h, { size: "medium", onClick: (c) => o(c), children: l || "Clear Filter" })
|
|
34
33
|
] });
|
|
35
34
|
};
|
|
36
35
|
export {
|
|
37
|
-
|
|
36
|
+
F as default
|
|
38
37
|
};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { Container as
|
|
4
|
-
import
|
|
5
|
-
import { injectIntl as
|
|
6
|
-
import { getStartDateAndEndDateFromYear as
|
|
7
|
-
import
|
|
8
|
-
import { useDispatch as
|
|
9
|
-
import { getCustomPosts as
|
|
10
|
-
import { useParams as
|
|
11
|
-
import { toNumber as
|
|
12
|
-
const
|
|
13
|
-
const { posts: l, numberOfColumns:
|
|
2
|
+
import et, { useState as D, useRef as ot, useEffect as rt } from "react";
|
|
3
|
+
import { Container as Y, Loader as nt, Grid as M, GridRow as at } from "semantic-ui-react";
|
|
4
|
+
import st from "../connected-templates/PostIntro.js";
|
|
5
|
+
import { injectIntl as it } from "react-intl";
|
|
6
|
+
import { getStartDateAndEndDateFromYear as V } from "./utils.js";
|
|
7
|
+
import lt from "./NoData.js";
|
|
8
|
+
import { useDispatch as ct, useSelector as ut } from "react-redux";
|
|
9
|
+
import { getCustomPosts as dt } from "../reducers/data-api.js";
|
|
10
|
+
import { useParams as mt } from "react-router";
|
|
11
|
+
import { toNumber as ft, toBoolean as gt } from "../../utils/data.js";
|
|
12
|
+
const yt = (F) => {
|
|
13
|
+
const { posts: l, numberOfColumns: S, sortFirstBy: c, countryCategory: u, postWidth: h, postHeight: A } = F, m = [];
|
|
14
14
|
if (u && c && c !== "none") {
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
const d = l.filter((y) => y[u].includes(Number(c))), b = l.filter((y) => !y[u].includes(Number(c)));
|
|
16
|
+
m.push(...d), m.push(...b);
|
|
17
17
|
} else
|
|
18
|
-
|
|
19
|
-
return /* @__PURE__ */ s(
|
|
20
|
-
|
|
18
|
+
m.push(...l);
|
|
19
|
+
return /* @__PURE__ */ s(M, { className: "filtered-posts", columns: S, children: /* @__PURE__ */ s(at, { children: m.map((d) => /* @__PURE__ */ s(M.Column, { children: /* @__PURE__ */ s("div", { className: "filtered-posts-column", style: { width: h, height: A, overflow: "hidden" }, children: /* @__PURE__ */ s(
|
|
20
|
+
st,
|
|
21
21
|
{
|
|
22
22
|
style: {
|
|
23
23
|
width: "100%",
|
|
@@ -26,28 +26,32 @@ const dt = (F) => {
|
|
|
26
26
|
margin: 0,
|
|
27
27
|
padding: 0
|
|
28
28
|
},
|
|
29
|
-
as:
|
|
29
|
+
as: Y,
|
|
30
30
|
fluid: !0,
|
|
31
|
-
post:
|
|
31
|
+
post: d
|
|
32
32
|
},
|
|
33
|
-
|
|
34
|
-
) }) },
|
|
35
|
-
},
|
|
33
|
+
d.id
|
|
34
|
+
) }) }, d.id)) }) });
|
|
35
|
+
}, pt = (F) => {
|
|
36
36
|
const {
|
|
37
37
|
"data-group": l,
|
|
38
|
-
"data-number-of-columns":
|
|
38
|
+
"data-number-of-columns": S,
|
|
39
39
|
"data-type": c,
|
|
40
40
|
"data-taxonomy": u,
|
|
41
|
-
"data-categories": h,
|
|
41
|
+
"data-categories": h = "[]",
|
|
42
42
|
"data-height": A,
|
|
43
|
-
"data-post-width":
|
|
44
|
-
"data-post-height":
|
|
43
|
+
"data-post-width": m,
|
|
44
|
+
"data-post-height": d,
|
|
45
45
|
"data-number-of-items-per-page": b,
|
|
46
46
|
"data-enable-sorting": y,
|
|
47
47
|
"data-sort-first-by": I,
|
|
48
48
|
"data-sorting-taxonomy": O,
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
"data-wordpress-source-type": ht,
|
|
50
|
+
"data-wordpress-source": j,
|
|
51
|
+
"data-no-data-msg": z,
|
|
52
|
+
"data-clear-filter-msg": W,
|
|
53
|
+
editing: J
|
|
54
|
+
} = F, L = ct(), { locale: q } = mt(), [R, x] = D(!1), _ = ut((t) => t).getIn(["data", "posts", l]), [T, N] = D([]), w = ot(null), [C, B] = D(void 0), U = gt(y) && I !== "none" ? ft(I) : null, f = _ ?? {
|
|
51
55
|
yearFilter: null,
|
|
52
56
|
categoryFilter: null,
|
|
53
57
|
countryFilter: null,
|
|
@@ -64,19 +68,19 @@ const dt = (F) => {
|
|
|
64
68
|
values: e.map((o) => Number(o)).filter((o) => Number.isFinite(o) && o !== Number.MIN_SAFE_INTEGER),
|
|
65
69
|
isExplicitNone: a
|
|
66
70
|
};
|
|
67
|
-
},
|
|
71
|
+
}, $ = (t) => {
|
|
68
72
|
if (!t || t.length === 0)
|
|
69
73
|
return null;
|
|
70
|
-
const e = Array.from(new Set(t)).sort((
|
|
74
|
+
const e = Array.from(new Set(t)).sort((E, P) => E - P);
|
|
71
75
|
if (e.length === 0)
|
|
72
76
|
return null;
|
|
73
|
-
const a = e[0], r = e[e.length - 1], o =
|
|
77
|
+
const a = e[0], r = e[e.length - 1], o = V(a), n = V(r);
|
|
74
78
|
return !(o != null && o.startDate) || !(n != null && n.endDate) ? null : {
|
|
75
79
|
startDate: o.startDate,
|
|
76
80
|
endDate: n.endDate
|
|
77
81
|
};
|
|
78
|
-
},
|
|
79
|
-
const t = v(f.yearFilter), e = t.isExplicitNone ? null :
|
|
82
|
+
}, k = () => {
|
|
83
|
+
const t = v(f.yearFilter), e = t.isExplicitNone ? null : $(t.values), a = f.countryFilter ?? null, r = f.categoryFilter ?? null, o = f.categoryTaxonomy || (u && u !== "none" ? u : null), n = f.countryTaxonomy || null;
|
|
80
84
|
return {
|
|
81
85
|
before: (e == null ? void 0 : e.endDate) || null,
|
|
82
86
|
after: (e == null ? void 0 : e.startDate) || null,
|
|
@@ -85,24 +89,24 @@ const dt = (F) => {
|
|
|
85
89
|
countryFilter: a,
|
|
86
90
|
countryTaxonomy: n
|
|
87
91
|
};
|
|
88
|
-
},
|
|
92
|
+
}, G = (t) => J ? t : decodeURIComponent(t), K = (t) => {
|
|
89
93
|
try {
|
|
90
|
-
return JSON.parse(
|
|
94
|
+
return JSON.parse(G(t));
|
|
91
95
|
} catch (e) {
|
|
92
|
-
return console.warn("JSON parsing failed for value:", t, "- treating as plain string. Error:", e),
|
|
96
|
+
return console.warn("JSON parsing failed for value:", t, "- treating as plain string. Error:", e), G(t);
|
|
93
97
|
}
|
|
94
|
-
},
|
|
95
|
-
const t =
|
|
98
|
+
}, Q = () => {
|
|
99
|
+
const t = K(h);
|
|
96
100
|
return t ? typeof t == "string" ? t.split(",").map(Number) : typeof t == "number" ? [t] : t : [];
|
|
97
|
-
},
|
|
101
|
+
}, X = (t, e, a) => {
|
|
98
102
|
if (a) return null;
|
|
99
103
|
if (t.length === 0) return e.length > 0 ? e : null;
|
|
100
104
|
if (e.length === 0) return t;
|
|
101
105
|
const r = new Set(t), o = e.filter((n) => r.has(n));
|
|
102
106
|
return o.length > 0 ? o : null;
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
const t =
|
|
107
|
+
}, Z = async () => {
|
|
108
|
+
w.current && B(w.current.offsetHeight), x(!0);
|
|
109
|
+
const t = k(), e = v(Q()).values, a = v(t.categoryFilter), r = X(
|
|
106
110
|
e,
|
|
107
111
|
a.values,
|
|
108
112
|
a.isExplicitNone
|
|
@@ -117,51 +121,52 @@ const dt = (F) => {
|
|
|
117
121
|
}
|
|
118
122
|
const n = /* @__PURE__ */ new Map();
|
|
119
123
|
t.categoryTaxonomy && r && r.length > 0 && n.set(t.categoryTaxonomy, r), t.countryTaxonomy && o.values.length > 0 && n.set(t.countryTaxonomy, o.values);
|
|
120
|
-
const
|
|
124
|
+
const E = r ? r.join(",") : void 0, P = {
|
|
121
125
|
after: t.after,
|
|
122
126
|
before: t.before,
|
|
123
127
|
perPage: Number(b || 10),
|
|
124
128
|
page: f.page || 1,
|
|
125
|
-
locale:
|
|
129
|
+
locale: q || "en",
|
|
126
130
|
postType: c,
|
|
127
131
|
taxonomy: t.categoryTaxonomy || void 0,
|
|
128
|
-
category:
|
|
132
|
+
category: E || void 0,
|
|
129
133
|
taxonomyFilters: n,
|
|
130
134
|
ordering: "date",
|
|
131
|
-
orderingDirection: "desc"
|
|
135
|
+
orderingDirection: "desc",
|
|
136
|
+
wpApiBase: j ?? void 0
|
|
132
137
|
};
|
|
133
|
-
await
|
|
138
|
+
await dt(P).then((i) => {
|
|
134
139
|
if (i) {
|
|
135
140
|
let p = null, g = null;
|
|
136
141
|
if (i && typeof i == "object" && "data" in i ? (p = i.data, g = i.meta) : (Array.isArray(i), p = i), N(Array.isArray(p) ? p : []), g) {
|
|
137
|
-
const
|
|
138
|
-
|
|
142
|
+
const H = g["x-wp-totalpages"] ? g["x-wp-totalpages"] : 1, tt = g["x-wp-total"] ? g["x-wp-total"] : 0;
|
|
143
|
+
H && L({
|
|
139
144
|
type: "SET_POSTS_PAGINATION",
|
|
140
145
|
group: l,
|
|
141
|
-
totalPages: Number(
|
|
142
|
-
totalItems: Number(
|
|
146
|
+
totalPages: Number(H),
|
|
147
|
+
totalItems: Number(tt)
|
|
143
148
|
});
|
|
144
149
|
}
|
|
145
150
|
} else
|
|
146
151
|
N([]);
|
|
147
152
|
}).finally(() => {
|
|
148
|
-
x(!1),
|
|
153
|
+
x(!1), B(void 0);
|
|
149
154
|
});
|
|
150
155
|
};
|
|
151
|
-
return
|
|
152
|
-
(async () => await
|
|
153
|
-
}, [_, c, u, b, h, O]), /* @__PURE__ */ s("div", { ref:
|
|
154
|
-
|
|
156
|
+
return rt(() => {
|
|
157
|
+
c && (async () => await Z())();
|
|
158
|
+
}, [_, c, u, b, h, O]), /* @__PURE__ */ s("div", { ref: w, id: `filtered-posts-${l}`, style: C !== void 0 ? { minHeight: C, border: "1px solid #e0e0e0", borderRadius: "4px" } : void 0, children: /* @__PURE__ */ s(Y, { fluid: !0, children: R ? /* @__PURE__ */ s("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: C ?? "100%" }, children: /* @__PURE__ */ s(nt, { active: !0, inline: "centered" }) }) : !R && T && T.length > 0 ? /* @__PURE__ */ s(
|
|
159
|
+
yt,
|
|
155
160
|
{
|
|
156
|
-
posts:
|
|
157
|
-
postWidth: Number(
|
|
158
|
-
postHeight: Number(
|
|
159
|
-
numberOfColumns: Number(
|
|
160
|
-
sortFirstBy:
|
|
161
|
+
posts: T,
|
|
162
|
+
postWidth: Number(m),
|
|
163
|
+
postHeight: Number(d),
|
|
164
|
+
numberOfColumns: Number(S),
|
|
165
|
+
sortFirstBy: U,
|
|
161
166
|
countryCategory: O
|
|
162
167
|
}
|
|
163
|
-
) : /* @__PURE__ */ s(
|
|
164
|
-
},
|
|
168
|
+
) : /* @__PURE__ */ s(lt, { noDataMsg: z, clearFilterMsg: W, group: l }) }) });
|
|
169
|
+
}, At = it(et.memo(pt));
|
|
165
170
|
export {
|
|
166
|
-
|
|
171
|
+
At as default
|
|
167
172
|
};
|
|
@@ -1,73 +1,76 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as F } from "react/jsx-runtime";
|
|
2
2
|
import { useState as _, useEffect as j } from "react";
|
|
3
|
-
import
|
|
4
|
-
import { Config as
|
|
5
|
-
const
|
|
3
|
+
import D from "./PostsFilterDropdown.js";
|
|
4
|
+
import { Config as E } from "../../conf/index.js";
|
|
5
|
+
const W = (p) => {
|
|
6
6
|
const {
|
|
7
|
-
taxonomy:
|
|
8
|
-
group:
|
|
9
|
-
placeholder:
|
|
10
|
-
allLabel:
|
|
11
|
-
noneLabel:
|
|
12
|
-
useSingleColumn:
|
|
13
|
-
enableTextSearch:
|
|
14
|
-
filterType:
|
|
15
|
-
showNoDataOption:
|
|
16
|
-
closeOnSelect:
|
|
17
|
-
allNoneSameBehaviour:
|
|
7
|
+
taxonomy: n,
|
|
8
|
+
group: c,
|
|
9
|
+
placeholder: f,
|
|
10
|
+
allLabel: m,
|
|
11
|
+
noneLabel: u,
|
|
12
|
+
useSingleColumn: g,
|
|
13
|
+
enableTextSearch: y,
|
|
14
|
+
filterType: d,
|
|
15
|
+
showNoDataOption: h,
|
|
16
|
+
closeOnSelect: x,
|
|
17
|
+
allNoneSameBehaviour: A,
|
|
18
18
|
autoApply: O,
|
|
19
|
-
alphabeticalSort:
|
|
20
|
-
ascOrder:
|
|
21
|
-
type:
|
|
22
|
-
categories:
|
|
23
|
-
onChange:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
alphabeticalSort: P,
|
|
20
|
+
ascOrder: S,
|
|
21
|
+
type: w,
|
|
22
|
+
categories: a,
|
|
23
|
+
onChange: B,
|
|
24
|
+
wpApiBase: o,
|
|
25
|
+
...T
|
|
26
|
+
} = p, [b, e] = _([]), v = async () => {
|
|
27
|
+
if (!n || n === "none") {
|
|
27
28
|
e([]);
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
|
-
const
|
|
31
|
+
const i = o != null && o !== "" ? o : E.REACT_APP_WP_API;
|
|
32
|
+
console.log("Fetching taxonomy options from API base:", i);
|
|
33
|
+
const r = await (await fetch(i + "/wp/v2/" + n)).json();
|
|
31
34
|
if (r) {
|
|
32
|
-
const
|
|
33
|
-
key:
|
|
34
|
-
value:
|
|
35
|
-
text:
|
|
35
|
+
const l = r.map((t) => ({
|
|
36
|
+
key: t.id,
|
|
37
|
+
value: t.id,
|
|
38
|
+
text: t.name
|
|
36
39
|
}));
|
|
37
|
-
if (
|
|
38
|
-
const
|
|
39
|
-
e([]), e(
|
|
40
|
+
if (a) {
|
|
41
|
+
const t = l.filter((C) => a.indexOf(C.value.toString()) > -1);
|
|
42
|
+
e([]), e(t);
|
|
40
43
|
} else
|
|
41
|
-
e([]), e(
|
|
44
|
+
e([]), e(l);
|
|
42
45
|
}
|
|
43
46
|
};
|
|
44
47
|
return j(() => {
|
|
45
|
-
let
|
|
46
|
-
return
|
|
47
|
-
|
|
48
|
+
let s = !1;
|
|
49
|
+
return s || (e([]), v()), () => {
|
|
50
|
+
s = !0;
|
|
48
51
|
};
|
|
49
|
-
}, [
|
|
50
|
-
|
|
52
|
+
}, [w, n, a, o]), /* @__PURE__ */ F(
|
|
53
|
+
D,
|
|
51
54
|
{
|
|
52
|
-
...
|
|
53
|
-
group:
|
|
54
|
-
placeholder:
|
|
55
|
-
allLabel:
|
|
56
|
-
noneLabel:
|
|
57
|
-
useSingleColumn:
|
|
58
|
-
enableTextSearch:
|
|
59
|
-
filterType:
|
|
60
|
-
showNoDataOption:
|
|
61
|
-
closeOnSelect:
|
|
62
|
-
allNoneSameBehaviour:
|
|
55
|
+
...T,
|
|
56
|
+
group: c,
|
|
57
|
+
placeholder: f,
|
|
58
|
+
allLabel: m,
|
|
59
|
+
noneLabel: u,
|
|
60
|
+
useSingleColumn: g,
|
|
61
|
+
enableTextSearch: y,
|
|
62
|
+
filterType: d,
|
|
63
|
+
showNoDataOption: h,
|
|
64
|
+
closeOnSelect: x,
|
|
65
|
+
allNoneSameBehaviour: A,
|
|
63
66
|
autoApply: O,
|
|
64
|
-
alphabeticalSort:
|
|
65
|
-
ascOrder:
|
|
66
|
-
options:
|
|
67
|
-
onChange:
|
|
67
|
+
alphabeticalSort: P,
|
|
68
|
+
ascOrder: S,
|
|
69
|
+
options: b,
|
|
70
|
+
onChange: B
|
|
68
71
|
}
|
|
69
72
|
);
|
|
70
73
|
};
|
|
71
74
|
export {
|
|
72
|
-
|
|
75
|
+
W as default
|
|
73
76
|
};
|
|
@@ -1,184 +1,175 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import { Container as
|
|
4
|
-
import { toBoolean as
|
|
5
|
-
import { useAppDispatch as
|
|
6
|
-
import { useSelector as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
const
|
|
1
|
+
import { jsxs as se, jsx as Y } from "react/jsx-runtime";
|
|
2
|
+
import { useState as h, useMemo as p, useEffect as E } from "react";
|
|
3
|
+
import { Container as ce } from "semantic-ui-react";
|
|
4
|
+
import { toBoolean as s, toNumber as ye } from "../../utils/data.js";
|
|
5
|
+
import { useAppDispatch as ue } from "../../redux/hooks.js";
|
|
6
|
+
import { useSelector as pe } from "react-redux";
|
|
7
|
+
import Fe from "./CategoricalFilter.js";
|
|
8
|
+
import de from "./YearFilter.js";
|
|
9
|
+
const Ae = (L) => {
|
|
10
10
|
const {
|
|
11
|
-
"data-alphabetical-sort":
|
|
12
|
-
"data-asc-order":
|
|
11
|
+
"data-alphabetical-sort": D,
|
|
12
|
+
"data-asc-order": R,
|
|
13
13
|
"data-group": c,
|
|
14
|
-
"data-placeholder":
|
|
15
|
-
"data-all-label":
|
|
16
|
-
"data-none-label":
|
|
17
|
-
"data-use-single-column":
|
|
18
|
-
"data-enable-text-search":
|
|
19
|
-
"data-filter-type":
|
|
20
|
-
"data-show-no-data-option":
|
|
21
|
-
"data-close-on-select":
|
|
22
|
-
"data-all-none-same-behaviour":
|
|
23
|
-
"data-auto-apply":
|
|
24
|
-
"data-taxonomy":
|
|
25
|
-
"data-categories":
|
|
26
|
-
"data-is-country-filter":
|
|
27
|
-
"data-is-year-filter":
|
|
28
|
-
"data-type":
|
|
29
|
-
"data-sort-first-by":
|
|
30
|
-
"data-default-values":
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
14
|
+
"data-placeholder": T,
|
|
15
|
+
"data-all-label": C,
|
|
16
|
+
"data-none-label": b,
|
|
17
|
+
"data-use-single-column": v,
|
|
18
|
+
"data-enable-text-search": P,
|
|
19
|
+
"data-filter-type": F,
|
|
20
|
+
"data-show-no-data-option": z,
|
|
21
|
+
"data-close-on-select": j,
|
|
22
|
+
"data-all-none-same-behaviour": J,
|
|
23
|
+
"data-auto-apply": K,
|
|
24
|
+
"data-taxonomy": i,
|
|
25
|
+
"data-categories": d = "[]",
|
|
26
|
+
"data-is-country-filter": M,
|
|
27
|
+
"data-is-year-filter": U,
|
|
28
|
+
"data-type": $,
|
|
29
|
+
"data-sort-first-by": O,
|
|
30
|
+
"data-default-values": k = "[]",
|
|
31
|
+
"data-wordpress-source-type": ge,
|
|
32
|
+
"data-wordpress-source": q,
|
|
33
|
+
editing: G = !1
|
|
34
|
+
} = L, u = ue(), e = pe((t) => t.getIn(["data", "posts", c])) || {}, l = F === "multi-select", [x, fe] = h(0), N = (t) => G ? t : decodeURIComponent(t);
|
|
35
|
+
let n = ((t) => {
|
|
34
36
|
try {
|
|
35
|
-
return JSON.parse(
|
|
36
|
-
} catch (
|
|
37
|
-
return console.warn("JSON parsing failed for value:",
|
|
37
|
+
return JSON.parse(N(t));
|
|
38
|
+
} catch (o) {
|
|
39
|
+
return console.warn("JSON parsing failed for value:", t, "- treating as plain string. Error:", o), N(t);
|
|
38
40
|
}
|
|
39
|
-
})(
|
|
41
|
+
})(k);
|
|
40
42
|
n || (n = []), typeof n == "string" && (n = n.split(",").map(Number)), typeof n == "number" && (n = [n]);
|
|
41
|
-
const
|
|
42
|
-
() =>
|
|
43
|
-
[
|
|
44
|
-
),
|
|
45
|
-
() =>
|
|
46
|
-
[
|
|
47
|
-
),
|
|
48
|
-
() =>
|
|
49
|
-
[
|
|
50
|
-
),
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
});
|
|
56
|
-
V(() => {
|
|
57
|
-
const e = q.current, r = !x(e.countryFilter, F), d = !x(e.categoryFilter, p), m = l && !x(e.yearFilter, g), b = e.isMultiSelectFilter !== o;
|
|
58
|
-
(r || d || m || b) && (r && M(F), d && J(p), m && z(g), q.current = {
|
|
59
|
-
countryFilter: F,
|
|
60
|
-
categoryFilter: p,
|
|
61
|
-
yearFilter: g,
|
|
62
|
-
isMultiSelectFilter: o
|
|
63
|
-
});
|
|
64
|
-
}, [F, p, g, o, l]);
|
|
65
|
-
const Fe = (e) => {
|
|
66
|
-
z(e), h({
|
|
43
|
+
const H = s(D), Q = s(R), V = s(z), A = s(j), B = s(J), I = s(K), r = s(M), a = s(U), _ = s(v), w = s(P), g = O !== "none" ? ye(O) : null, [y, W] = h([]), [m, X] = h(!1), f = (t, o) => o ? Array.isArray(t) ? t : t != null ? [t] : [] : t || void 0, Z = p(
|
|
44
|
+
() => f(e.countryFilter, l),
|
|
45
|
+
[e.countryFilter, l]
|
|
46
|
+
), ee = p(
|
|
47
|
+
() => f(e.categoryFilter, l),
|
|
48
|
+
[e.categoryFilter, l]
|
|
49
|
+
), te = p(
|
|
50
|
+
() => a ? f(e.yearFilter, l) : void 0,
|
|
51
|
+
[e.yearFilter, l, a]
|
|
52
|
+
), S = p(
|
|
53
|
+
() => d ? d.split(",") : [],
|
|
54
|
+
[d]
|
|
55
|
+
), re = (t) => {
|
|
56
|
+
u({
|
|
67
57
|
type: "SET_POSTS_FILTER",
|
|
68
58
|
group: c,
|
|
69
|
-
...
|
|
70
|
-
isYearFilter:
|
|
71
|
-
yearFilter:
|
|
72
|
-
isCountryFilter:
|
|
73
|
-
categoryFilter:
|
|
74
|
-
countryFilter:
|
|
75
|
-
sortFirstBy:
|
|
76
|
-
countryCategory:
|
|
77
|
-
categoryTaxonomy:
|
|
78
|
-
countryTaxonomy:
|
|
59
|
+
...e,
|
|
60
|
+
isYearFilter: a,
|
|
61
|
+
yearFilter: a ? t : null,
|
|
62
|
+
isCountryFilter: r,
|
|
63
|
+
categoryFilter: e.categoryFilter,
|
|
64
|
+
countryFilter: e.countryFilter,
|
|
65
|
+
sortFirstBy: g,
|
|
66
|
+
countryCategory: i,
|
|
67
|
+
categoryTaxonomy: i,
|
|
68
|
+
countryTaxonomy: i
|
|
79
69
|
});
|
|
80
|
-
},
|
|
81
|
-
|
|
70
|
+
}, ae = (t) => {
|
|
71
|
+
u({
|
|
82
72
|
type: "SET_POSTS_FILTER",
|
|
83
73
|
group: c,
|
|
84
|
-
...
|
|
74
|
+
...e,
|
|
85
75
|
// Preserve both filters so they can work together
|
|
86
|
-
categoryFilter:
|
|
87
|
-
countryFilter:
|
|
88
|
-
isYearFilter:
|
|
89
|
-
yearFilter:
|
|
90
|
-
isCountryFilter:
|
|
91
|
-
sortFirstBy:
|
|
92
|
-
countryCategory:
|
|
93
|
-
categoryCategory:
|
|
94
|
-
categoryTaxonomy:
|
|
95
|
-
countryTaxonomy:
|
|
76
|
+
categoryFilter: r ? e.categoryFilter : t,
|
|
77
|
+
countryFilter: r ? t : e.countryFilter,
|
|
78
|
+
isYearFilter: a,
|
|
79
|
+
yearFilter: e.yearFilter,
|
|
80
|
+
isCountryFilter: r,
|
|
81
|
+
sortFirstBy: r ? g : e.sortFirstBy,
|
|
82
|
+
countryCategory: r ? i : e.countryCategory,
|
|
83
|
+
categoryCategory: r ? e.categoryCategory : t,
|
|
84
|
+
categoryTaxonomy: r ? e.categoryTaxonomy : i,
|
|
85
|
+
countryTaxonomy: r ? i : e.countryTaxonomy
|
|
96
86
|
});
|
|
97
87
|
};
|
|
98
|
-
return
|
|
99
|
-
const
|
|
100
|
-
|
|
88
|
+
return E(() => {
|
|
89
|
+
const t = n.length > 0, o = l ? n : n[0], oe = r ? e.categoryFilter : t ? o : l ? S.map(Number) : e.categoryFilter, le = r ? t ? o : l ? S.map(Number) : e.countryFilter : e.countryFilter, ne = a && l ? y.length > 0 ? y.map((ie) => ie.value) : [] : e.yearFilter;
|
|
90
|
+
u({
|
|
101
91
|
type: "SET_INITIAL_POSTS_FILTER",
|
|
102
92
|
group: c,
|
|
103
|
-
categoryFilter:
|
|
104
|
-
countryFilter:
|
|
105
|
-
isYearFilter:
|
|
106
|
-
isCountryFilter:
|
|
107
|
-
sortFirstBy:
|
|
108
|
-
yearFilter:
|
|
109
|
-
categoryCategory:
|
|
110
|
-
categoryTaxonomy:
|
|
111
|
-
countryCategory:
|
|
112
|
-
countryTaxonomy:
|
|
93
|
+
categoryFilter: oe,
|
|
94
|
+
countryFilter: le,
|
|
95
|
+
isYearFilter: a,
|
|
96
|
+
isCountryFilter: r,
|
|
97
|
+
sortFirstBy: g,
|
|
98
|
+
yearFilter: a ? ne : null,
|
|
99
|
+
categoryCategory: r ? null : e.categoryCategory,
|
|
100
|
+
categoryTaxonomy: r ? null : i,
|
|
101
|
+
countryCategory: r ? i : null,
|
|
102
|
+
countryTaxonomy: r ? i : null,
|
|
113
103
|
page: 1
|
|
114
104
|
});
|
|
115
|
-
}, []),
|
|
116
|
-
if (
|
|
117
|
-
const
|
|
118
|
-
|
|
105
|
+
}, []), E(() => {
|
|
106
|
+
if (a && !m) {
|
|
107
|
+
const t = a && l ? y.length > 0 ? y.map((o) => o.value) : [] : e.yearFilter;
|
|
108
|
+
u({
|
|
119
109
|
type: "SET_INITIAL_POSTS_FILTER",
|
|
120
110
|
group: c,
|
|
121
|
-
...
|
|
122
|
-
isYearFilter:
|
|
123
|
-
yearFilter:
|
|
111
|
+
...e,
|
|
112
|
+
isYearFilter: a,
|
|
113
|
+
yearFilter: a ? t : null
|
|
124
114
|
});
|
|
125
115
|
}
|
|
126
|
-
}, [
|
|
127
|
-
|
|
128
|
-
|
|
116
|
+
}, [m]), /* @__PURE__ */ se(ce, { fluid: !0, className: "filter post-filter", children: [
|
|
117
|
+
a && /* @__PURE__ */ Y(
|
|
118
|
+
de,
|
|
129
119
|
{
|
|
130
120
|
group: c,
|
|
131
|
-
placeholder:
|
|
132
|
-
allLabel:
|
|
133
|
-
noneLabel:
|
|
134
|
-
useSingleColumn:
|
|
135
|
-
enableTextSearch:
|
|
136
|
-
filterType:
|
|
137
|
-
showNoDataOption:
|
|
138
|
-
closeOnSelect:
|
|
139
|
-
allNoneSameBehaviour:
|
|
140
|
-
autoApply:
|
|
141
|
-
alphabeticalSort:
|
|
142
|
-
ascOrder:
|
|
143
|
-
options:
|
|
144
|
-
value:
|
|
145
|
-
yearOptions:
|
|
146
|
-
setYearOptions:
|
|
147
|
-
yearFilterLoading:
|
|
148
|
-
setYearFilterLoading:
|
|
149
|
-
onChange: (
|
|
150
|
-
|
|
121
|
+
placeholder: T,
|
|
122
|
+
allLabel: C,
|
|
123
|
+
noneLabel: b,
|
|
124
|
+
useSingleColumn: _,
|
|
125
|
+
enableTextSearch: w,
|
|
126
|
+
filterType: F,
|
|
127
|
+
showNoDataOption: V,
|
|
128
|
+
closeOnSelect: A,
|
|
129
|
+
allNoneSameBehaviour: B,
|
|
130
|
+
autoApply: I,
|
|
131
|
+
alphabeticalSort: H,
|
|
132
|
+
ascOrder: Q,
|
|
133
|
+
options: y,
|
|
134
|
+
value: te,
|
|
135
|
+
yearOptions: y,
|
|
136
|
+
setYearOptions: W,
|
|
137
|
+
yearFilterLoading: m,
|
|
138
|
+
setYearFilterLoading: X,
|
|
139
|
+
onChange: (t, o) => {
|
|
140
|
+
re(o);
|
|
151
141
|
},
|
|
152
|
-
resetKey:
|
|
142
|
+
resetKey: x
|
|
153
143
|
}
|
|
154
144
|
),
|
|
155
|
-
!
|
|
156
|
-
|
|
145
|
+
!a && /* @__PURE__ */ Y(
|
|
146
|
+
Fe,
|
|
157
147
|
{
|
|
158
148
|
group: c,
|
|
159
|
-
placeholder:
|
|
160
|
-
allLabel:
|
|
161
|
-
noneLabel:
|
|
162
|
-
useSingleColumn:
|
|
163
|
-
enableTextSearch:
|
|
164
|
-
filterType:
|
|
165
|
-
showNoDataOption:
|
|
166
|
-
closeOnSelect:
|
|
167
|
-
allNoneSameBehaviour:
|
|
168
|
-
autoApply:
|
|
169
|
-
taxonomy:
|
|
170
|
-
type:
|
|
171
|
-
value:
|
|
172
|
-
onChange: (
|
|
173
|
-
|
|
149
|
+
placeholder: T,
|
|
150
|
+
allLabel: C,
|
|
151
|
+
noneLabel: b,
|
|
152
|
+
useSingleColumn: _,
|
|
153
|
+
enableTextSearch: w,
|
|
154
|
+
filterType: F,
|
|
155
|
+
showNoDataOption: V,
|
|
156
|
+
closeOnSelect: A,
|
|
157
|
+
allNoneSameBehaviour: B,
|
|
158
|
+
autoApply: I,
|
|
159
|
+
taxonomy: i,
|
|
160
|
+
type: $,
|
|
161
|
+
value: r ? Z : ee,
|
|
162
|
+
onChange: (t, o) => {
|
|
163
|
+
ae(o);
|
|
174
164
|
},
|
|
175
|
-
categories:
|
|
176
|
-
resetKey:
|
|
165
|
+
categories: S,
|
|
166
|
+
resetKey: x,
|
|
167
|
+
wpApiBase: q ?? void 0
|
|
177
168
|
},
|
|
178
169
|
`cat-${c}`
|
|
179
170
|
)
|
|
180
171
|
] });
|
|
181
172
|
};
|
|
182
173
|
export {
|
|
183
|
-
|
|
174
|
+
Ae as default
|
|
184
175
|
};
|
|
@@ -1,57 +1,58 @@
|
|
|
1
|
-
import { Config as
|
|
2
|
-
import { get as
|
|
3
|
-
function
|
|
4
|
-
return JSON.parse(JSON.stringify(
|
|
1
|
+
import { Config as C } from "../../conf/index.js";
|
|
2
|
+
import { get as O } from "../../api/commons.js";
|
|
3
|
+
function g(e) {
|
|
4
|
+
return JSON.parse(JSON.stringify(e));
|
|
5
5
|
}
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
return Object.keys(
|
|
6
|
+
const u = process.env.VITE_REACT_APP_API_ROOT || C.REACT_APP_API_ROOT || null, T = typeof window < "u" ? window.location.origin : "", d = {}, l = {}, E = 3 * 60 * 1e3;
|
|
7
|
+
function $(e) {
|
|
8
|
+
return Object.keys(e).map((t) => encodeURIComponent(t) + "=" + encodeURIComponent(e[t])).join("&");
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
if (l[
|
|
13
|
-
return Promise.resolve(
|
|
14
|
-
if (
|
|
15
|
-
return
|
|
16
|
-
const
|
|
17
|
-
delete
|
|
10
|
+
function h(e, t = !1) {
|
|
11
|
+
const n = e, o = Date.now();
|
|
12
|
+
if (l[n] && o - l[n].timestamp < E)
|
|
13
|
+
return Promise.resolve(g(l[n].data));
|
|
14
|
+
if (d[n])
|
|
15
|
+
return d[n].then(g);
|
|
16
|
+
const f = O(e, {}, t).then((a) => (l[n] = { data: a, timestamp: Date.now() }, t ? { data: g(a), meta: l[n].meta } : g(a))).finally(() => {
|
|
17
|
+
delete d[n];
|
|
18
18
|
});
|
|
19
|
-
return
|
|
19
|
+
return d[n] = f, f;
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
return
|
|
24
|
-
},
|
|
25
|
-
const
|
|
26
|
-
return
|
|
27
|
-
},
|
|
28
|
-
const
|
|
29
|
-
return
|
|
30
|
-
},
|
|
31
|
-
const
|
|
21
|
+
const k = ({ app: e, params: t }) => {
|
|
22
|
+
const n = `${u || T}/api/${e}/categories${t ? "?" + $(t) : ""}`;
|
|
23
|
+
return h(n);
|
|
24
|
+
}, V = ({ app: e, type: t, params: n }) => {
|
|
25
|
+
const o = `${u || ""}/api/${e}/categories/${t}${n ? "?" + $(n) : ""}`;
|
|
26
|
+
return h(o);
|
|
27
|
+
}, J = ({ source: e, app: t, params: n }) => {
|
|
28
|
+
const o = `${u || T}/api/${t}/stats/${e}${n ? "?" + $(n) : ""}`;
|
|
29
|
+
return h(o);
|
|
30
|
+
}, L = ({ postType: e, taxonomy: t, category: n, taxonomyFilters: o, before: f, perPage: a, page: _, locale: R, after: m, ordering: I, orderingDirection: q, wpApiBase: p }) => {
|
|
31
|
+
const S = p != null && p !== "" ? p : C.REACT_APP_WP_API;
|
|
32
|
+
console.log("Using API base:", S);
|
|
33
|
+
const U = `${S}/wp/v2/${e}`, r = new URLSearchParams(), P = /* @__PURE__ */ new Map(), A = (s, i) => {
|
|
32
34
|
if (!s || i == null) return;
|
|
33
|
-
const
|
|
34
|
-
Array.isArray(i) ? i.forEach((
|
|
35
|
-
|
|
36
|
-
}) :
|
|
35
|
+
const c = P.get(s) || [];
|
|
36
|
+
Array.isArray(i) ? i.forEach((y) => {
|
|
37
|
+
y != null && c.push(String(y));
|
|
38
|
+
}) : c.push(String(i)), P.set(s, c);
|
|
37
39
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}), t &&
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
}),
|
|
44
|
-
const
|
|
45
|
-
return
|
|
40
|
+
o && o instanceof Map && o.forEach((s, i) => {
|
|
41
|
+
A(i, s);
|
|
42
|
+
}), t && n != null && A(t, n), P.forEach((s, i) => {
|
|
43
|
+
const c = Array.from(new Set(s));
|
|
44
|
+
c.length !== 0 && r.set(i, c.join(","));
|
|
45
|
+
}), f && r.append("before", f.toISOString()), a && r.append("per_page", a.toString()), r.append("page", _.toString()), r.append("locale", R), m && r.append("after", m.toISOString()), r.append("orderby", I), r.append("order", q);
|
|
46
|
+
const w = r.toString().replace(/%2C/g, ",");
|
|
47
|
+
return O(`${U}?${w}`, {
|
|
46
48
|
headers: {
|
|
47
49
|
"Content-Type": "application/json"
|
|
48
|
-
}
|
|
49
|
-
credentials: "include"
|
|
50
|
+
}
|
|
50
51
|
}, !0);
|
|
51
52
|
};
|
|
52
53
|
export {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
k as getCategories,
|
|
55
|
+
V as getCategory,
|
|
56
|
+
L as getCustomPosts,
|
|
57
|
+
J as getData
|
|
57
58
|
};
|
|
@@ -14,6 +14,10 @@ interface FilteredPostsProps extends WrappedComponentProps {
|
|
|
14
14
|
"data-sort-first-by": number | string;
|
|
15
15
|
"data-sorting-type": string;
|
|
16
16
|
"data-sorting-taxonomy": string;
|
|
17
|
+
"data-wordpress-source-type"?: string;
|
|
18
|
+
"data-wordpress-source"?: string;
|
|
19
|
+
"data-no-data-msg"?: string;
|
|
20
|
+
"data-clear-filter-msg"?: string;
|
|
17
21
|
editing?: boolean;
|
|
18
22
|
}
|
|
19
23
|
declare const _default: React.FC<import('react-intl').WithIntlProps<FilteredPostsProps>> & {
|
|
@@ -6,4 +6,5 @@ declare function getStartDateAndEndDateFromYear(year: number): {
|
|
|
6
6
|
endDate: Date;
|
|
7
7
|
};
|
|
8
8
|
declare function getYearsToDisplay(): Promise<unknown>;
|
|
9
|
-
|
|
9
|
+
declare function resolveWpApiBase(wordpressSourceType: string | undefined, wordpressSource: string | undefined): Promise<string | null>;
|
|
10
|
+
export { getStartDateAndEndDateFromYear, getYearsToDisplay, resolveWpApiBase };
|
|
@@ -4,6 +4,7 @@ interface CategoricalFilterProps extends PostFilterDropdownProps {
|
|
|
4
4
|
taxonomies?: any[] | null;
|
|
5
5
|
type?: string;
|
|
6
6
|
categories?: any[] | null;
|
|
7
|
+
wpApiBase?: string;
|
|
7
8
|
}
|
|
8
9
|
declare const CategoricalFilter: (props: CategoricalFilterProps) => React.JSX.Element;
|
|
9
10
|
export default CategoricalFilter;
|
|
@@ -21,6 +21,8 @@ interface PostsFilterProps {
|
|
|
21
21
|
"data-type"?: string;
|
|
22
22
|
"data-sort-first-by"?: string;
|
|
23
23
|
"data-default-values"?: string;
|
|
24
|
+
"data-wordpress-source-type"?: string;
|
|
25
|
+
"data-wordpress-source"?: string;
|
|
24
26
|
editing?: boolean;
|
|
25
27
|
}
|
|
26
28
|
declare const PostsFilter: (props: PostsFilterProps) => React.JSX.Element;
|
|
@@ -12,7 +12,7 @@ export function getData({ source, app, params }: {
|
|
|
12
12
|
app: any;
|
|
13
13
|
params: any;
|
|
14
14
|
}): any;
|
|
15
|
-
export function getCustomPosts({ postType, taxonomy, category, taxonomyFilters, before, perPage, page, locale, after, ordering, orderingDirection }: {
|
|
15
|
+
export function getCustomPosts({ postType, taxonomy, category, taxonomyFilters, before, perPage, page, locale, after, ordering, orderingDirection, wpApiBase }: {
|
|
16
16
|
postType: any;
|
|
17
17
|
taxonomy: any;
|
|
18
18
|
category: any;
|
|
@@ -24,4 +24,5 @@ export function getCustomPosts({ postType, taxonomy, category, taxonomyFilters,
|
|
|
24
24
|
after: any;
|
|
25
25
|
ordering: any;
|
|
26
26
|
orderingDirection: any;
|
|
27
|
+
wpApiBase: any;
|
|
27
28
|
}): Promise<unknown>;
|