@devgateway/dvz-ui-react 1.7.11 → 1.7.13

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