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