@devgateway/dvz-ui-react 1.8.5 → 1.8.7

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 o=require("react/jsx-runtime"),g=require("react"),f=require("semantic-ui-react"),at=require("../connected-templates/PostIntro.js"),it=require("./FilteredPostsIntro.js"),J=require("react-intl"),V=require("./utils.js"),lt=require("./NoData.js"),z=require("react-redux"),ut=require("../reducers/data-api.js"),W=require("../../utils/data.js"),ct=x=>{const{posts:u,numberOfColumns:j,sortFirstBy:c,countryCategory:d,postWidth:S,postHeight:R,locale:D}=x,y=[];if(d&&c&&c!=="none"){const a=u.filter(m=>m[d].includes(Number(c))),F=u.filter(m=>!m[d].includes(Number(c)));y.push(...a),y.push(...F)}else y.push(...u);const v=x.wordpressSourceType==="internal"||!x.wordpressSourceType;return o.jsx(f.Grid,{className:"filtered-posts",columns:j,children:o.jsx(f.GridRow,{children:y.map(a=>o.jsx(f.Grid.Column,{children:o.jsx("div",{className:"filtered-posts-column",style:{width:S,height:R,overflow:"hidden"},children:v?o.jsx(at.default,{style:{width:"100%",height:"100%",overflow:"hidden",margin:0,padding:0},as:f.Container,fluid:!0,post:a},a.id):o.jsx(it.default,{style:{width:"100%",height:"100%",overflow:"hidden",margin:0,padding:0},as:f.Container,fluid:!0,post:a,locale:D},a.id)})},a.id))})})},dt=x=>{const{"data-group":u,"data-number-of-columns":j,"data-type":c,"data-taxonomy":d,"data-categories":S="[]","data-height":R,"data-post-width":D,"data-post-height":y,"data-number-of-items-per-page":v,"data-enable-sorting":a,"data-sort-first-by":F,"data-sorting-taxonomy":m,"data-wordpress-source-type":L,"data-wordpress-source":O,"data-no-data-msg":U,"data-clear-filter-msg":$,editing:k}=x,K=z.useDispatch(),{locale:_}=J.useIntl(),[M,w]=g.useState(!1),E=g.useRef(0),G=z.useSelector(t=>t).getIn(["data","posts",u]),[P,T]=g.useState([]),A=g.useRef(null),[I,Y]=g.useState(void 0),Q=W.toBoolean(a)&&F!=="none"?W.toNumber(F):null,p=G??{yearFilter:null,categoryFilter:null,countryFilter:null,page:1,countryTaxonomy:null,categoryTaxonomy:null},C=t=>{if(t==null)return{values:[],isExplicitNone:!1};const e=Array.isArray(t)?t:[t],i=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:i}},X=t=>{if(!t||t.length===0)return null;const e=Array.from(new Set(t)).sort((b,q)=>b-q);if(e.length===0)return null;const i=e[0],s=e[e.length-1],r=V.getStartDateAndEndDateFromYear(i),n=V.getStartDateAndEndDateFromYear(s);return!(r!=null&&r.startDate)||!(n!=null&&n.endDate)?null:{startDate:r.startDate,endDate:n.endDate}},Z=()=>{const t=C(p.yearFilter),e=t.isExplicitNone?null:X(t.values),i=p.countryFilter??null,s=p.categoryFilter??null,r=p.categoryTaxonomy||(d&&d!=="none"?d:null),n=p.countryTaxonomy||null;return{before:(e==null?void 0:e.endDate)||null,after:(e==null?void 0:e.startDate)||null,categoryFilter:s,categoryTaxonomy:r,countryFilter:i,countryTaxonomy:n}},B=t=>k?t:decodeURIComponent(t),tt=t=>{try{return JSON.parse(B(t))}catch(e){return console.warn("JSON parsing failed for value:",t,"- treating as plain string. Error:",e),B(t)}},et=()=>{const t=tt(S);return t?typeof t=="string"?t.split(",").map(Number):typeof t=="number"?[t]:t:[]},rt=(t,e,i)=>{if(i)return null;if(t.length===0)return e.length>0?e:null;if(e.length===0)return t;const s=new Set(t),r=e.filter(n=>s.has(n));return r.length>0?r:null},nt=async()=>{const t=++E.current;A.current&&Y(A.current.offsetHeight),w(!0);const e=Z(),i=C(et()).values,s=C(e.categoryFilter),r=rt(i,s.values,s.isExplicitNone),n=C(e.countryFilter);if(s.isExplicitNone){T([]),w(!1);return}if(n.isExplicitNone){T([]),w(!1);return}const b=new Map;e.categoryTaxonomy&&r&&r.length>0&&b.set(e.categoryTaxonomy,r),e.countryTaxonomy&&n.values.length>0&&b.set(e.countryTaxonomy,n.values);const q=r?r.join(","):void 0,ot={after:e.after,before:e.before,perPage:Number(v||10),page:p.page||1,locale:_||"en",postType:c,taxonomy:e.categoryTaxonomy||void 0,category:q||void 0,taxonomyFilters:b,ordering:"date",orderingDirection:"desc",wpApiBase:O??void 0};await ut.getCustomPosts(ot).then(l=>{if(t===E.current)if(l){let N=null,h=null;if(l&&typeof l=="object"&&"data"in l?(N=l.data,h=l.meta):(Array.isArray(l),N=l),T(Array.isArray(N)?N:[]),h){const H=h["x-wp-totalpages"]?h["x-wp-totalpages"]:1,st=h["x-wp-total"]?h["x-wp-total"]:0;H&&K({type:"SET_POSTS_PAGINATION",group:u,totalPages:Number(H),totalItems:Number(st)})}}else T([])}).finally(()=>{t===E.current&&(w(!1),Y(void 0))})};return g.useEffect(()=>{c&&(async()=>await nt())()},[G,c,d,v,S,m]),o.jsx("div",{ref:A,id:`filtered-posts-${u}`,style:I!==void 0?{minHeight:I,border:"1px solid #e0e0e0",borderRadius:"4px"}:void 0,children:o.jsx(f.Container,{fluid:!0,children:M?o.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:I??"100%"},children:o.jsx(f.Loader,{active:!0,inline:"centered"})}):!M&&P&&P.length>0?o.jsx(ct,{posts:P,postWidth:Number(D),postHeight:Number(y),numberOfColumns:Number(j),sortFirstBy:Q,countryCategory:m,wordpressSourceType:L,wordpressSource:O,locale:_}):o.jsx(lt.default,{noDataMsg:U,clearFilterMsg:$,group:u})})})},gt=J.injectIntl(g.memo(dt));exports.default=gt;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),y=require("react"),g=require("semantic-ui-react"),ie=require("../connected-templates/PostIntro.js"),le=require("./FilteredPostsIntro.js"),Y=require("react-intl"),ue=require("./NoData.js"),V=require("react-redux"),ce=require("../reducers/data-api.js"),W=require("../../utils/data.js"),de=x=>{const{posts:u,numberOfColumns:C,sortFirstBy:c,countryCategory:s,postWidth:N,postHeight:O,locale:j}=x,m=[];if(s&&c&&c!=="none"){const i=u.filter(f=>f[s].includes(Number(c))),F=u.filter(f=>!f[s].includes(Number(c)));m.push(...i),m.push(...F)}else m.push(...u);const v=x.wordpressSourceType==="internal"||!x.wordpressSourceType;return n.jsx(g.Grid,{className:"filtered-posts",columns:C,children:n.jsx(g.GridRow,{children:m.map(i=>n.jsx(g.Grid.Column,{children:n.jsx("div",{className:"filtered-posts-column",style:{width:N,height:O,overflow:"hidden"},children:v?n.jsx(ie.default,{style:{width:"100%",height:"100%",overflow:"hidden",margin:0,padding:0},as:g.Container,fluid:!0,post:i},i.id):n.jsx(le.default,{style:{width:"100%",height:"100%",overflow:"hidden",margin:0,padding:0},as:g.Container,fluid:!0,post:i,locale:j},i.id)})},i.id))})})},ye=x=>{const{"data-group":u,"data-number-of-columns":C,"data-type":c,"data-taxonomy":s,"data-categories":N="[]","data-height":O,"data-post-width":j,"data-post-height":m,"data-number-of-items-per-page":v,"data-enable-sorting":i,"data-sort-first-by":F,"data-sorting-taxonomy":f,"data-wordpress-source-type":k,"data-wordpress-source":_,"data-no-data-msg":J,"data-clear-filter-msg":L,editing:U}=x,$=V.useDispatch(),{locale:B}=Y.useIntl(),[M,T]=y.useState(!1),P=y.useRef(0),z=V.useSelector(e=>e).getIn(["data","posts",u]),[E,S]=y.useState([]),I=y.useRef(null),[A,G]=y.useState(void 0),K=W.toBoolean(i)&&F!=="none"?W.toNumber(F):null,p=z??{yearFilter:null,categoryFilter:null,countryFilter:null,page:1,countryTaxonomy:null,categoryTaxonomy:null},w=e=>{if(e==null)return{values:[],isExplicitNone:!1};const t=Array.isArray(e)?e:[e],o=t.some(r=>Number(r)===Number.MIN_SAFE_INTEGER);return{values:t.map(r=>Number(r)).filter(r=>Number.isFinite(r)&&r!==Number.MIN_SAFE_INTEGER),isExplicitNone:o}},Q=e=>{if(!e||e.length===0)return null;const t=Array.from(new Set(e)).map(o=>Number(o)).filter(o=>Number.isFinite(o)&&o>0).sort((o,a)=>o-a);return t.length>0?t:null},X=()=>{const e=w(p.yearFilter),t=e.isExplicitNone?null:Q(e.values),o=p.countryFilter??null,a=p.categoryFilter??null,r=p.categoryTaxonomy||(s&&s!=="none"?s:null),d=p.countryTaxonomy||null;return{years:t,categoryFilter:a,categoryTaxonomy:r,countryFilter:o,countryTaxonomy:d}},D=e=>U?e:decodeURIComponent(e),Z=e=>{try{return JSON.parse(D(e))}catch(t){return console.warn("JSON parsing failed for value:",e,"- treating as plain string. Error:",t),D(e)}},ee=()=>{const e=Z(N);return e?typeof e=="string"?e.split(",").map(Number):typeof e=="number"?[e]:e:[]},te=(e,t,o)=>{if(o)return null;if(e.length===0)return t.length>0?t:null;if(t.length===0)return e;const a=new Set(e),r=t.filter(d=>a.has(d));return r.length>0?r:null},re=async()=>{const e=++P.current;I.current&&G(I.current.offsetHeight),T(!0);const t=X(),o=w(ee()).values,a=w(t.categoryFilter),r=te(o,a.values,a.isExplicitNone),d=w(t.countryFilter);if(a.isExplicitNone){S([]),T(!1);return}if(d.isExplicitNone){S([]),T(!1);return}const R=t.categoryTaxonomy&&t.categoryTaxonomy!=="none"?t.categoryTaxonomy:null,oe=R||(s&&s!=="none"?s:null)||void 0,q=new Map;R&&r&&r.length>0&&q.set(R,r),t.countryTaxonomy&&d.values.length>0&&q.set(t.countryTaxonomy,d.values);const ne=r?r.join(","):void 0,se={years:t.years||void 0,after:void 0,before:void 0,perPage:Number(v||10),page:p.page||1,locale:B||"en",postType:c,taxonomy:oe,category:ne||void 0,taxonomyFilters:q,ordering:"date",orderingDirection:"desc",wpApiBase:_??void 0};await ce.getCustomPosts(se).then(l=>{if(e===P.current)if(l){let b=null,h=null;if(l&&typeof l=="object"&&"data"in l?(b=l.data,h=l.meta):(Array.isArray(l),b=l),S(Array.isArray(b)?b:[]),h){const H=h["x-wp-totalpages"]?h["x-wp-totalpages"]:1,ae=h["x-wp-total"]?h["x-wp-total"]:0;H&&$({type:"SET_POSTS_PAGINATION",group:u,totalPages:Number(H),totalItems:Number(ae)})}}else S([])}).finally(()=>{e===P.current&&(T(!1),G(void 0))})};return y.useEffect(()=>{c&&(async()=>await re())()},[z,c,s,v,N,f]),n.jsx("div",{ref:I,id:`filtered-posts-${u}`,style:A!==void 0?{minHeight:A,border:"1px solid #e0e0e0",borderRadius:"4px"}:void 0,children:n.jsx(g.Container,{fluid:!0,children:M?n.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:A??"100%"},children:n.jsx(g.Loader,{active:!0,inline:"centered"})}):!M&&E&&E.length>0?n.jsx(de,{posts:E,postWidth:Number(j),postHeight:Number(m),numberOfColumns:Number(C),sortFirstBy:K,countryCategory:f,wordpressSourceType:k,wordpressSource:_,locale:B}):n.jsx(ue.default,{noDataMsg:J,clearFilterMsg:L,group:u})})})},ge=Y.injectIntl(y.memo(ye));exports.default=ge;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../../conf/index.js"),O=require("../../api/commons.js");function d(t){return JSON.parse(JSON.stringify(t))}const u=process.env.VITE_REACT_APP_API_ROOT||m.Config.REACT_APP_API_ROOT||null,T=typeof window<"u"?window.location.origin:"",P={},f={},E=3*60*1e3;function C(t){return Object.keys(t).map(n=>encodeURIComponent(n)+"="+encodeURIComponent(t[n])).join("&")}function S(t,n=!1){const e=t,r=Date.now();if(f[e]&&r-f[e].timestamp<E)return Promise.resolve(d(f[e].data));if(P[e])return P[e].then(d);const g=O.get(t,{},n).then(a=>(f[e]={data:a,timestamp:Date.now()},n?{data:d(a),meta:f[e].meta}:d(a))).finally(()=>{delete P[e]});return P[e]=g,g}const U=({app:t,params:n})=>{const e=`${u||T}/api/${t}/categories${n?"?"+C(n):""}`;return S(e)},b=({app:t,type:n,params:e})=>{const r=`${u||""}/api/${t}/categories/${n}${e?"?"+C(e):""}`;return S(r)},j=({source:t,app:n,params:e})=>{const r=`${u||T}/api/${n}/stats/${t}${e?"?"+C(e):""}`;return S(r)},D=({postType:t,taxonomy:n,category:e,taxonomyFilters:r,before:g,perPage:a,page:A,locale:_,after:h,ordering:R,orderingDirection:q,wpApiBase:l})=>{const I=`${l!=null&&l!==""?l:m.Config.REACT_APP_WP_API}/wp/v2/${t}`,o=new URLSearchParams,p=new Map,$=(s,i)=>{if(!s||i==null)return;const c=p.get(s)||[];Array.isArray(i)?i.forEach(y=>{y!=null&&c.push(String(y))}):c.push(String(i)),p.set(s,c)};r&&r instanceof Map&&r.forEach((s,i)=>{$(i,s)}),n&&e!=null&&!p.has(n)&&$(n,e),p.forEach((s,i)=>{const c=Array.from(new Set(s));c.length!==0&&o.set(i,c.join(","))}),g&&o.append("before",g.toISOString()),a&&o.append("per_page",a.toString()),o.append("page",A.toString()),o.append("lang",_),h&&o.append("after",h.toISOString()),o.append("orderby",R),o.append("order",q);const w=o.toString().replace(/%2C/g,",");return O.get(`${I}?${w}`,{headers:{"Content-Type":"application/json"}},!0)};exports.getCategories=U;exports.getCategory=b;exports.getCustomPosts=D;exports.getData=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("../../conf/index.js"),S=require("../../api/commons.js");function d(n){return JSON.parse(JSON.stringify(n))}const u=process.env.VITE_REACT_APP_API_ROOT||$.Config.REACT_APP_API_ROOT||null,T=typeof window<"u"?window.location.origin:"",m={},f={},E=3*60*1e3;function P(n){return Object.keys(n).map(t=>encodeURIComponent(t)+"="+encodeURIComponent(n[t])).join("&")}function C(n,t=!1){const e=n,i=Date.now();if(f[e]&&i-f[e].timestamp<E)return Promise.resolve(d(f[e].data));if(m[e])return m[e].then(d);const h=S.get(n,{},t).then(c=>(f[e]={data:c,timestamp:Date.now()},t?{data:d(c),meta:f[e].meta}:d(c))).finally(()=>{delete m[e]});return m[e]=h,h}const I=({app:n,params:t})=>{const e=`${u||T}/api/${n}/categories${t?"?"+P(t):""}`;return C(e)},U=({app:n,type:t,params:e})=>{const i=`${u||""}/api/${n}/categories/${t}${e?"?"+P(e):""}`;return C(i)},j=({source:n,app:t,params:e})=>{const i=`${u||T}/api/${t}/stats/${n}${e?"?"+P(e):""}`;return C(i)},D=({postType:n,taxonomy:t,category:e,taxonomyFilters:i,before:h,perPage:c,page:_,locale:O,after:N,ordering:R,orderingDirection:q,years:l,wpApiBase:g})=>{const b=`${g!=null&&g!==""?g:$.Config.REACT_APP_WP_API}/dg/v1/posts`,s=new URLSearchParams;s.append("post_type",n||"post");const p=new Map,y=(o,r)=>{if(!o||r==null)return;const a=p.get(o)||[];Array.isArray(r)?r.forEach(A=>{A!=null&&a.push(String(A))}):a.push(String(r)),p.set(o,a)};if(i&&i instanceof Map&&i.forEach((o,r)=>{y(r,o)}),t&&e!=null&&!p.has(t)&&y(t,e),p.forEach((o,r)=>{const a=Array.from(new Set(o));a.length!==0&&s.set(r,a.join(","))}),c&&s.append("per_page",c.toString()),s.append("page",_.toString()),s.append("lang",O),l&&Array.isArray(l)&&l.length>0){const o=Array.from(new Set(l.map(r=>Number(r)).filter(r=>Number.isFinite(r)&&r>0))).sort((r,a)=>r-a);o.length>0&&s.append("years",o.join(","))}s.append("orderby",R),s.append("order",q);const w=s.toString().replace(/%2C/g,",");return S.get(`${b}?${w}`,{headers:{"Content-Type":"application/json"}},!0)};exports.getCategories=I;exports.getCategory=U;exports.getCustomPosts=D;exports.getData=j;
@@ -1,24 +1,23 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
- import at, { useState as R, useRef as z, useEffect as st } from "react";
3
- import { Container as O, Loader as it, Grid as q, GridRow as lt } from "semantic-ui-react";
4
- import ct from "../connected-templates/PostIntro.js";
5
- import ut from "./FilteredPostsIntro.js";
6
- import { injectIntl as dt, useIntl as mt } from "react-intl";
7
- import { getStartDateAndEndDateFromYear as W } from "./utils.js";
2
+ import it, { useState as B, useRef as q, useEffect as at } from "react";
3
+ import { Container as O, Loader as lt, Grid as W, GridRow as ct } from "semantic-ui-react";
4
+ import ut from "../connected-templates/PostIntro.js";
5
+ import dt from "./FilteredPostsIntro.js";
6
+ import { injectIntl as mt, useIntl as yt } from "react-intl";
8
7
  import ft from "./NoData.js";
9
- import { useDispatch as gt, useSelector as yt } from "react-redux";
10
- import { getCustomPosts as pt } from "../reducers/data-api.js";
11
- import { toNumber as ht, toBoolean as bt } from "../../utils/data.js";
12
- const xt = (p) => {
13
- const { posts: c, numberOfColumns: T, sortFirstBy: u, countryCategory: d, postWidth: x, postHeight: _, locale: C } = p, m = [];
14
- if (d && u && u !== "none") {
15
- const s = c.filter((f) => f[d].includes(Number(u))), v = c.filter((f) => !f[d].includes(Number(u)));
16
- m.push(...s), m.push(...v);
8
+ import { useDispatch as gt, useSelector as pt } from "react-redux";
9
+ import { getCustomPosts as ht } from "../reducers/data-api.js";
10
+ import { toNumber as xt, toBoolean as bt } from "../../utils/data.js";
11
+ const Nt = (p) => {
12
+ const { posts: c, numberOfColumns: w, sortFirstBy: u, countryCategory: s, postWidth: x, postHeight: z, locale: S } = p, m = [];
13
+ if (s && u && u !== "none") {
14
+ const a = c.filter((y) => y[s].includes(Number(u))), N = c.filter((y) => !y[s].includes(Number(u)));
15
+ m.push(...a), m.push(...N);
17
16
  } else
18
17
  m.push(...c);
19
- const N = p.wordpressSourceType === "internal" || !p.wordpressSourceType;
20
- return /* @__PURE__ */ n(q, { className: "filtered-posts", columns: T, children: /* @__PURE__ */ n(lt, { children: m.map((s) => /* @__PURE__ */ n(q.Column, { children: /* @__PURE__ */ n("div", { className: "filtered-posts-column", style: { width: x, height: _, overflow: "hidden" }, children: N ? /* @__PURE__ */ n(
21
- ct,
18
+ const b = p.wordpressSourceType === "internal" || !p.wordpressSourceType;
19
+ return /* @__PURE__ */ n(W, { className: "filtered-posts", columns: w, children: /* @__PURE__ */ n(ct, { children: m.map((a) => /* @__PURE__ */ n(W.Column, { children: /* @__PURE__ */ n("div", { className: "filtered-posts-column", style: { width: x, height: z, overflow: "hidden" }, children: b ? /* @__PURE__ */ n(
20
+ ut,
22
21
  {
23
22
  style: {
24
23
  width: "100%",
@@ -29,11 +28,11 @@ const xt = (p) => {
29
28
  },
30
29
  as: O,
31
30
  fluid: !0,
32
- post: s
31
+ post: a
33
32
  },
34
- s.id
33
+ a.id
35
34
  ) : /* @__PURE__ */ n(
36
- ut,
35
+ dt,
37
36
  {
38
37
  style: {
39
38
  width: "100%",
@@ -44,151 +43,145 @@ const xt = (p) => {
44
43
  },
45
44
  as: O,
46
45
  fluid: !0,
47
- post: s,
48
- locale: C
46
+ post: a,
47
+ locale: S
49
48
  },
50
- s.id
51
- ) }) }, s.id)) }) });
52
- }, Nt = (p) => {
49
+ a.id
50
+ ) }) }, a.id)) }) });
51
+ }, vt = (p) => {
53
52
  const {
54
53
  "data-group": c,
55
- "data-number-of-columns": T,
54
+ "data-number-of-columns": w,
56
55
  "data-type": u,
57
- "data-taxonomy": d,
56
+ "data-taxonomy": s,
58
57
  "data-categories": x = "[]",
59
- "data-height": _,
60
- "data-post-width": C,
58
+ "data-height": z,
59
+ "data-post-width": S,
61
60
  "data-post-height": m,
62
- "data-number-of-items-per-page": N,
63
- "data-enable-sorting": s,
64
- "data-sort-first-by": v,
65
- "data-sorting-taxonomy": f,
66
- "data-wordpress-source-type": J,
67
- "data-wordpress-source": B,
68
- "data-no-data-msg": L,
69
- "data-clear-filter-msg": U,
70
- editing: $
71
- } = p, k = gt(), { locale: G } = mt(), [H, F] = R(!1), E = z(0), M = yt((t) => t).getIn(["data", "posts", c]), [P, w] = R([]), D = z(null), [I, V] = R(void 0), K = bt(s) && v !== "none" ? ht(v) : null, g = M ?? {
61
+ "data-number-of-items-per-page": b,
62
+ "data-enable-sorting": a,
63
+ "data-sort-first-by": N,
64
+ "data-sorting-taxonomy": y,
65
+ "data-wordpress-source-type": Y,
66
+ "data-wordpress-source": _,
67
+ "data-no-data-msg": k,
68
+ "data-clear-filter-msg": J,
69
+ editing: L
70
+ } = p, U = gt(), { locale: D } = yt(), [G, v] = B(!1), C = q(0), H = pt((t) => t).getIn(["data", "posts", c]), [P, F] = B([]), E = q(null), [I, M] = B(void 0), $ = bt(a) && N !== "none" ? xt(N) : null, f = H ?? {
72
71
  yearFilter: null,
73
72
  categoryFilter: null,
74
73
  countryFilter: null,
75
74
  page: 1,
76
75
  countryTaxonomy: null,
77
76
  categoryTaxonomy: null
78
- }, S = (t) => {
77
+ }, T = (t) => {
79
78
  if (t == null)
80
79
  return { values: [], isExplicitNone: !1 };
81
- const e = Array.isArray(t) ? t : [t], i = e.some(
82
- (r) => Number(r) === Number.MIN_SAFE_INTEGER
80
+ const e = Array.isArray(t) ? t : [t], r = e.some(
81
+ (o) => Number(o) === Number.MIN_SAFE_INTEGER
83
82
  );
84
83
  return {
85
- values: e.map((r) => Number(r)).filter((r) => Number.isFinite(r) && r !== Number.MIN_SAFE_INTEGER),
86
- isExplicitNone: i
84
+ values: e.map((o) => Number(o)).filter((o) => Number.isFinite(o) && o !== Number.MIN_SAFE_INTEGER),
85
+ isExplicitNone: r
87
86
  };
88
- }, Q = (t) => {
87
+ }, K = (t) => {
89
88
  if (!t || t.length === 0)
90
89
  return null;
91
- const e = Array.from(new Set(t)).sort((h, A) => h - A);
92
- if (e.length === 0)
93
- return null;
94
- const i = e[0], a = e[e.length - 1], r = W(i), o = W(a);
95
- return !(r != null && r.startDate) || !(o != null && o.endDate) ? null : {
96
- startDate: r.startDate,
97
- endDate: o.endDate
98
- };
99
- }, X = () => {
100
- const t = S(g.yearFilter), e = t.isExplicitNone ? null : Q(t.values), i = g.countryFilter ?? null, a = g.categoryFilter ?? null, r = g.categoryTaxonomy || (d && d !== "none" ? d : null), o = g.countryTaxonomy || null;
90
+ const e = Array.from(new Set(t)).map((r) => Number(r)).filter((r) => Number.isFinite(r) && r > 0).sort((r, i) => r - i);
91
+ return e.length > 0 ? e : null;
92
+ }, Q = () => {
93
+ const t = T(f.yearFilter), e = t.isExplicitNone ? null : K(t.values), r = f.countryFilter ?? null, i = f.categoryFilter ?? null, o = f.categoryTaxonomy || (s && s !== "none" ? s : null), d = f.countryTaxonomy || null;
101
94
  return {
102
- before: (e == null ? void 0 : e.endDate) || null,
103
- after: (e == null ? void 0 : e.startDate) || null,
104
- categoryFilter: a,
105
- categoryTaxonomy: r,
106
- countryFilter: i,
107
- countryTaxonomy: o
95
+ years: e,
96
+ categoryFilter: i,
97
+ categoryTaxonomy: o,
98
+ countryFilter: r,
99
+ countryTaxonomy: d
108
100
  };
109
- }, Y = (t) => $ ? t : decodeURIComponent(t), Z = (t) => {
101
+ }, V = (t) => L ? t : decodeURIComponent(t), X = (t) => {
110
102
  try {
111
- return JSON.parse(Y(t));
103
+ return JSON.parse(V(t));
112
104
  } catch (e) {
113
- return console.warn("JSON parsing failed for value:", t, "- treating as plain string. Error:", e), Y(t);
105
+ return console.warn("JSON parsing failed for value:", t, "- treating as plain string. Error:", e), V(t);
114
106
  }
115
- }, tt = () => {
116
- const t = Z(x);
107
+ }, Z = () => {
108
+ const t = X(x);
117
109
  return t ? typeof t == "string" ? t.split(",").map(Number) : typeof t == "number" ? [t] : t : [];
118
- }, et = (t, e, i) => {
119
- if (i) return null;
110
+ }, tt = (t, e, r) => {
111
+ if (r) return null;
120
112
  if (t.length === 0) return e.length > 0 ? e : null;
121
113
  if (e.length === 0) return t;
122
- const a = new Set(t), r = e.filter((o) => a.has(o));
123
- return r.length > 0 ? r : null;
124
- }, rt = async () => {
125
- const t = ++E.current;
126
- D.current && V(D.current.offsetHeight), F(!0);
127
- const e = X(), i = S(tt()).values, a = S(e.categoryFilter), r = et(
128
- i,
129
- a.values,
130
- a.isExplicitNone
131
- ), o = S(e.countryFilter);
132
- if (a.isExplicitNone) {
133
- w([]), F(!1);
114
+ const i = new Set(t), o = e.filter((d) => i.has(d));
115
+ return o.length > 0 ? o : null;
116
+ }, et = async () => {
117
+ const t = ++C.current;
118
+ E.current && M(E.current.offsetHeight), v(!0);
119
+ const e = Q(), r = T(Z()).values, i = T(e.categoryFilter), o = tt(
120
+ r,
121
+ i.values,
122
+ i.isExplicitNone
123
+ ), d = T(e.countryFilter);
124
+ if (i.isExplicitNone) {
125
+ F([]), v(!1);
134
126
  return;
135
127
  }
136
- if (o.isExplicitNone) {
137
- w([]), F(!1);
128
+ if (d.isExplicitNone) {
129
+ F([]), v(!1);
138
130
  return;
139
131
  }
140
- const h = /* @__PURE__ */ new Map();
141
- e.categoryTaxonomy && r && r.length > 0 && h.set(e.categoryTaxonomy, r), e.countryTaxonomy && o.values.length > 0 && h.set(e.countryTaxonomy, o.values);
142
- const A = r ? r.join(",") : void 0, ot = {
143
- after: e.after,
144
- before: e.before,
145
- perPage: Number(N || 10),
146
- page: g.page || 1,
147
- locale: G || "en",
132
+ const A = e.categoryTaxonomy && e.categoryTaxonomy !== "none" ? e.categoryTaxonomy : null, ot = A || (s && s !== "none" ? s : null) || void 0, R = /* @__PURE__ */ new Map();
133
+ A && o && o.length > 0 && R.set(A, o), e.countryTaxonomy && d.values.length > 0 && R.set(e.countryTaxonomy, d.values);
134
+ const rt = o ? o.join(",") : void 0, nt = {
135
+ years: e.years || void 0,
136
+ after: void 0,
137
+ before: void 0,
138
+ perPage: Number(b || 10),
139
+ page: f.page || 1,
140
+ locale: D || "en",
148
141
  postType: u,
149
- taxonomy: e.categoryTaxonomy || void 0,
150
- category: A || void 0,
151
- taxonomyFilters: h,
142
+ taxonomy: ot,
143
+ category: rt || void 0,
144
+ taxonomyFilters: R,
152
145
  ordering: "date",
153
146
  orderingDirection: "desc",
154
- wpApiBase: B ?? void 0
147
+ wpApiBase: _ ?? void 0
155
148
  };
156
- await pt(ot).then((l) => {
157
- if (t === E.current)
149
+ await ht(nt).then((l) => {
150
+ if (t === C.current)
158
151
  if (l) {
159
- let b = null, y = null;
160
- if (l && typeof l == "object" && "data" in l ? (b = l.data, y = l.meta) : (Array.isArray(l), b = l), w(Array.isArray(b) ? b : []), y) {
161
- const j = y["x-wp-totalpages"] ? y["x-wp-totalpages"] : 1, nt = y["x-wp-total"] ? y["x-wp-total"] : 0;
162
- j && k({
152
+ let h = null, g = null;
153
+ if (l && typeof l == "object" && "data" in l ? (h = l.data, g = l.meta) : (Array.isArray(l), h = l), F(Array.isArray(h) ? h : []), g) {
154
+ const j = g["x-wp-totalpages"] ? g["x-wp-totalpages"] : 1, st = g["x-wp-total"] ? g["x-wp-total"] : 0;
155
+ j && U({
163
156
  type: "SET_POSTS_PAGINATION",
164
157
  group: c,
165
158
  totalPages: Number(j),
166
- totalItems: Number(nt)
159
+ totalItems: Number(st)
167
160
  });
168
161
  }
169
162
  } else
170
- w([]);
163
+ F([]);
171
164
  }).finally(() => {
172
- t === E.current && (F(!1), V(void 0));
165
+ t === C.current && (v(!1), M(void 0));
173
166
  });
174
167
  };
175
- return st(() => {
176
- u && (async () => await rt())();
177
- }, [M, u, d, N, x, f]), /* @__PURE__ */ n("div", { ref: D, id: `filtered-posts-${c}`, style: I !== void 0 ? { minHeight: I, border: "1px solid #e0e0e0", borderRadius: "4px" } : void 0, children: /* @__PURE__ */ n(O, { fluid: !0, children: H ? /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: I ?? "100%" }, children: /* @__PURE__ */ n(it, { active: !0, inline: "centered" }) }) : !H && P && P.length > 0 ? /* @__PURE__ */ n(
178
- xt,
168
+ return at(() => {
169
+ u && (async () => await et())();
170
+ }, [H, u, s, b, x, y]), /* @__PURE__ */ n("div", { ref: E, id: `filtered-posts-${c}`, style: I !== void 0 ? { minHeight: I, border: "1px solid #e0e0e0", borderRadius: "4px" } : void 0, children: /* @__PURE__ */ n(O, { fluid: !0, children: G ? /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: I ?? "100%" }, children: /* @__PURE__ */ n(lt, { active: !0, inline: "centered" }) }) : !G && P && P.length > 0 ? /* @__PURE__ */ n(
171
+ Nt,
179
172
  {
180
173
  posts: P,
181
- postWidth: Number(C),
174
+ postWidth: Number(S),
182
175
  postHeight: Number(m),
183
- numberOfColumns: Number(T),
184
- sortFirstBy: K,
185
- countryCategory: f,
186
- wordpressSourceType: J,
187
- wordpressSource: B,
188
- locale: G
176
+ numberOfColumns: Number(w),
177
+ sortFirstBy: $,
178
+ countryCategory: y,
179
+ wordpressSourceType: Y,
180
+ wordpressSource: _,
181
+ locale: D
189
182
  }
190
- ) : /* @__PURE__ */ n(ft, { noDataMsg: L, clearFilterMsg: U, group: c }) }) });
191
- }, Ot = dt(at.memo(Nt));
183
+ ) : /* @__PURE__ */ n(ft, { noDataMsg: k, clearFilterMsg: J, group: c }) }) });
184
+ }, zt = mt(it.memo(vt));
192
185
  export {
193
- Ot as default
186
+ zt as default
194
187
  };
@@ -1,48 +1,58 @@
1
- import { Config as C } from "../../conf/index.js";
2
- import { get as O } from "../../api/commons.js";
1
+ import { Config as y } from "../../conf/index.js";
2
+ import { get as C } from "../../api/commons.js";
3
3
  function d(t) {
4
4
  return JSON.parse(JSON.stringify(t));
5
5
  }
6
- const u = process.env.VITE_REACT_APP_API_ROOT || C.REACT_APP_API_ROOT || null, T = typeof window < "u" ? window.location.origin : "", h = {}, f = {}, E = 3 * 60 * 1e3;
7
- function P(t) {
8
- return Object.keys(t).map((e) => encodeURIComponent(e) + "=" + encodeURIComponent(t[e])).join("&");
6
+ const u = process.env.VITE_REACT_APP_API_ROOT || y.REACT_APP_API_ROOT || null, T = typeof window < "u" ? window.location.origin : "", m = {}, p = {}, I = 3 * 60 * 1e3;
7
+ function A(t) {
8
+ return Object.keys(t).map((n) => encodeURIComponent(n) + "=" + encodeURIComponent(t[n])).join("&");
9
9
  }
10
- function $(t, e = !1) {
11
- const n = t, r = Date.now();
12
- if (f[n] && r - f[n].timestamp < E)
13
- return Promise.resolve(d(f[n].data));
14
- if (h[n])
15
- return h[n].then(d);
16
- const p = O(t, {}, e).then((a) => (f[n] = { data: a, timestamp: Date.now() }, e ? { data: d(a), meta: f[n].meta } : d(a))).finally(() => {
17
- delete h[n];
10
+ function P(t, n = !1) {
11
+ const e = t, i = Date.now();
12
+ if (p[e] && i - p[e].timestamp < I)
13
+ return Promise.resolve(d(p[e].data));
14
+ if (m[e])
15
+ return m[e].then(d);
16
+ const h = C(t, {}, n).then((c) => (p[e] = { data: c, timestamp: Date.now() }, n ? { data: d(c), meta: p[e].meta } : d(c))).finally(() => {
17
+ delete m[e];
18
18
  });
19
- return h[n] = p, p;
19
+ return m[e] = h, h;
20
20
  }
21
- const k = ({ app: t, params: e }) => {
22
- const n = `${u || T}/api/${t}/categories${e ? "?" + P(e) : ""}`;
23
- return $(n);
24
- }, V = ({ app: t, type: e, params: n }) => {
25
- const r = `${u || ""}/api/${t}/categories/${e}${n ? "?" + P(n) : ""}`;
26
- return $(r);
27
- }, J = ({ source: t, app: e, params: n }) => {
28
- const r = `${u || T}/api/${e}/stats/${t}${n ? "?" + P(n) : ""}`;
29
- return $(r);
30
- }, L = ({ postType: t, taxonomy: e, category: n, taxonomyFilters: r, before: p, perPage: a, page: _, locale: y, after: S, ordering: R, orderingDirection: I, wpApiBase: l }) => {
31
- const q = `${l != null && l !== "" ? l : C.REACT_APP_WP_API}/wp/v2/${t}`, o = new URLSearchParams(), g = /* @__PURE__ */ new Map(), m = (s, i) => {
32
- if (!s || i == null) return;
33
- const c = g.get(s) || [];
34
- Array.isArray(i) ? i.forEach((A) => {
35
- A != null && c.push(String(A));
36
- }) : c.push(String(i)), g.set(s, c);
21
+ const k = ({ app: t, params: n }) => {
22
+ const e = `${u || T}/api/${t}/categories${n ? "?" + A(n) : ""}`;
23
+ return P(e);
24
+ }, V = ({ app: t, type: n, params: e }) => {
25
+ const i = `${u || ""}/api/${t}/categories/${n}${e ? "?" + A(e) : ""}`;
26
+ return P(i);
27
+ }, J = ({ source: t, app: n, params: e }) => {
28
+ const i = `${u || T}/api/${n}/stats/${t}${e ? "?" + A(e) : ""}`;
29
+ return P(i);
30
+ }, L = ({ postType: t, taxonomy: n, category: e, taxonomyFilters: i, before: h, perPage: c, page: R, locale: S, after: U, ordering: O, orderingDirection: q, years: f, wpApiBase: l }) => {
31
+ const w = `${l != null && l !== "" ? l : y.REACT_APP_WP_API}/dg/v1/posts`, s = new URLSearchParams();
32
+ s.append("post_type", t || "post");
33
+ const g = /* @__PURE__ */ new Map(), $ = (o, r) => {
34
+ if (!o || r == null) return;
35
+ const a = g.get(o) || [];
36
+ Array.isArray(r) ? r.forEach((_) => {
37
+ _ != null && a.push(String(_));
38
+ }) : a.push(String(r)), g.set(o, a);
37
39
  };
38
- r && r instanceof Map && r.forEach((s, i) => {
39
- m(i, s);
40
- }), e && n != null && !g.has(e) && m(e, n), g.forEach((s, i) => {
41
- const c = Array.from(new Set(s));
42
- c.length !== 0 && o.set(i, c.join(","));
43
- }), p && o.append("before", p.toISOString()), a && o.append("per_page", a.toString()), o.append("page", _.toString()), o.append("lang", y), S && o.append("after", S.toISOString()), o.append("orderby", R), o.append("order", I);
44
- const w = o.toString().replace(/%2C/g, ",");
45
- return O(`${q}?${w}`, {
40
+ if (i && i instanceof Map && i.forEach((o, r) => {
41
+ $(r, o);
42
+ }), n && e != null && !g.has(n) && $(n, e), g.forEach((o, r) => {
43
+ const a = Array.from(new Set(o));
44
+ a.length !== 0 && s.set(r, a.join(","));
45
+ }), c && s.append("per_page", c.toString()), s.append("page", R.toString()), s.append("lang", S), f && Array.isArray(f) && f.length > 0) {
46
+ const o = Array.from(
47
+ new Set(
48
+ f.map((r) => Number(r)).filter((r) => Number.isFinite(r) && r > 0)
49
+ )
50
+ ).sort((r, a) => r - a);
51
+ o.length > 0 && s.append("years", o.join(","));
52
+ }
53
+ s.append("orderby", O), s.append("order", q);
54
+ const E = s.toString().replace(/%2C/g, ",");
55
+ return C(`${w}?${E}`, {
46
56
  headers: {
47
57
  "Content-Type": "application/json"
48
58
  }
@@ -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, wpApiBase }: {
15
+ export function getCustomPosts({ postType, taxonomy, category, taxonomyFilters, before, perPage, page, locale, after, ordering, orderingDirection, years, wpApiBase }: {
16
16
  postType: any;
17
17
  taxonomy: any;
18
18
  category: any;
@@ -24,5 +24,6 @@ export function getCustomPosts({ postType, taxonomy, category, taxonomyFilters,
24
24
  after: any;
25
25
  ordering: any;
26
26
  orderingDirection: any;
27
+ years: any;
27
28
  wpApiBase: any;
28
29
  }): Promise<unknown>;
@@ -12,6 +12,7 @@ interface GetCustomPostsQueryArgs {
12
12
  taxonomy?: string;
13
13
  category?: string;
14
14
  before?: Date | null;
15
+ years?: number[];
15
16
  perPage?: number;
16
17
  page?: number;
17
18
  locale?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devgateway/dvz-ui-react",
3
- "version": "1.8.5",
3
+ "version": "1.8.7",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@devgateway/wp-react-lib");function n(t){if(!t)return{startDate:null,endDate:null};const e=new Date(Date.UTC(t,0,1,0,0,0,0)),a=new Date(Date.UTC(t,11,31,23,59,59,999));return{startDate:e,endDate:a}}exports.getStartDateAndEndDateFromYear=n;
@@ -1,9 +0,0 @@
1
- import "@devgateway/wp-react-lib";
2
- function D(t) {
3
- if (!t) return { startDate: null, endDate: null };
4
- const e = new Date(Date.UTC(t, 0, 1, 0, 0, 0, 0)), n = new Date(Date.UTC(t, 11, 31, 23, 59, 59, 999));
5
- return { startDate: e, endDate: n };
6
- }
7
- export {
8
- D as getStartDateAndEndDateFromYear
9
- };