@devgateway/dvz-ui-react 1.5.4 → 1.6.1

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.
Files changed (70) hide show
  1. package/dist/cjs/common.css +1 -1
  2. package/dist/cjs/embeddable/chart/Bar.js +1 -1
  3. package/dist/cjs/embeddable/chart/Line.js +1 -1
  4. package/dist/cjs/embeddable/chart/Pie.js +1 -1
  5. package/dist/cjs/embeddable/chart/colors/ManualColors.js +1 -1
  6. package/dist/cjs/embeddable/chart/data/Bar.js +1 -1
  7. package/dist/cjs/embeddable/chart/index.js +1 -1
  8. package/dist/cjs/embeddable/common/colors/ManualColors.js +1 -1
  9. package/dist/cjs/embeddable/d3Map/BaseLayer.js +1 -1
  10. package/dist/cjs/embeddable/d3Map/DataLayer.js +1 -1
  11. package/dist/cjs/embeddable/filtered-posts/NoData.js +2 -2
  12. package/dist/cjs/embeddable/filtered-posts/index.js +1 -1
  13. package/dist/cjs/embeddable/filtered-posts/utils.js +1 -1
  14. package/dist/cjs/embeddable/posts-filter/CategoricalFilter.js +1 -0
  15. package/dist/cjs/embeddable/posts-filter/PostsFilterDropdown.js +1 -1
  16. package/dist/cjs/embeddable/posts-filter/YearFilter.js +1 -0
  17. package/dist/cjs/embeddable/posts-filter/index.js +1 -1
  18. package/dist/cjs/embeddable/posts-filters-reset-button/index.js +1 -1
  19. package/dist/cjs/embeddable/posts-pagination/index.js +1 -1
  20. package/dist/cjs/embeddable/reducers/data-api.js +1 -1
  21. package/dist/cjs/embeddable/reducers/data.js +1 -1
  22. package/dist/cjs/embeddable/reducers/embeddable-api.js +1 -1
  23. package/dist/cjs/embeddable/time-line/mobile.js +1 -1
  24. package/dist/cjs/embeddable/vertical-featuredtabs/index.js +2 -2
  25. package/dist/cjs/index.js +1 -1
  26. package/dist/cjs/layout/Layout.js +1 -1
  27. package/dist/cjs/styles.css +1 -1
  28. package/dist/esm/common.css +1 -1
  29. package/dist/esm/embeddable/chart/Bar.js +253 -235
  30. package/dist/esm/embeddable/chart/Line.js +122 -121
  31. package/dist/esm/embeddable/chart/Pie.js +82 -81
  32. package/dist/esm/embeddable/chart/colors/ManualColors.js +33 -33
  33. package/dist/esm/embeddable/chart/data/Bar.js +18 -16
  34. package/dist/esm/embeddable/chart/index.js +298 -286
  35. package/dist/esm/embeddable/common/colors/ManualColors.js +22 -22
  36. package/dist/esm/embeddable/d3Map/BaseLayer.js +4 -1
  37. package/dist/esm/embeddable/d3Map/DataLayer.js +5 -1
  38. package/dist/esm/embeddable/filtered-posts/NoData.js +25 -18
  39. package/dist/esm/embeddable/filtered-posts/index.js +136 -92
  40. package/dist/esm/embeddable/filtered-posts/utils.js +3 -2
  41. package/dist/esm/embeddable/posts-filter/CategoricalFilter.js +72 -0
  42. package/dist/esm/embeddable/posts-filter/PostsFilterDropdown.js +106 -92
  43. package/dist/esm/embeddable/posts-filter/YearFilter.js +60 -0
  44. package/dist/esm/embeddable/posts-filter/index.js +160 -191
  45. package/dist/esm/embeddable/posts-filters-reset-button/index.js +21 -15
  46. package/dist/esm/embeddable/posts-pagination/index.js +36 -33
  47. package/dist/esm/embeddable/reducers/data-api.js +35 -35
  48. package/dist/esm/embeddable/reducers/data.js +116 -107
  49. package/dist/esm/embeddable/reducers/embeddable-api.js +8 -8
  50. package/dist/esm/embeddable/time-line/mobile.js +119 -118
  51. package/dist/esm/embeddable/vertical-featuredtabs/index.js +202 -131
  52. package/dist/esm/index.js +66 -64
  53. package/dist/esm/layout/Layout.js +8 -6
  54. package/dist/esm/styles.css +1 -1
  55. package/dist/types/dvz-ui/src/embeddable/chart/colors/ManualColors.d.ts +1 -1
  56. package/dist/types/dvz-ui/src/embeddable/filtered-posts/NoData.d.ts +1 -0
  57. package/dist/types/dvz-ui/src/embeddable/filtered-posts/index.d.ts +2 -1
  58. package/dist/types/dvz-ui/src/embeddable/filtered-posts/utils.d.ts +3 -0
  59. package/dist/types/dvz-ui/src/embeddable/posts-filter/CategoricalFilter.d.ts +9 -0
  60. package/dist/types/dvz-ui/src/embeddable/posts-filter/PostsFilterDropdown.d.ts +1 -0
  61. package/dist/types/dvz-ui/src/embeddable/posts-filter/YearFilter.d.ts +12 -0
  62. package/dist/types/dvz-ui/src/embeddable/posts-filter/index.d.ts +2 -0
  63. package/dist/types/dvz-ui/src/embeddable/reducers/data-api.d.ts +3 -1
  64. package/dist/types/dvz-ui/src/embeddable/reducers/data.d.ts +5 -0
  65. package/dist/types/dvz-ui/src/embeddable/time-line/mobile.d.ts +2 -1
  66. package/dist/types/dvz-ui/src/translations/af.json.d.ts +1 -2
  67. package/dist/types/dvz-ui/src/translations/am.json.d.ts +35 -35
  68. package/dist/types/dvz-ui/src/translations/index.d.ts +2 -1
  69. package/dist/types/dvz-ui/src/utils/data.d.ts +2 -0
  70. package/package.json +3 -2
@@ -1,48 +1,48 @@
1
1
  import O from "./Colors.js";
2
2
  class D extends O {
3
- constructor(l, u, r, b, v, h, a, B, _, e, f, g, y) {
4
- if (super(r, b, v, B, _), this._manualColor = {}, this._manualColor[g] = e ? e.Overall : null, l != "csv") {
5
- const m = (t) => {
3
+ constructor(i, _, r, C, v, h, u, g, a, e, f, x, p) {
4
+ if (super(r, C, v, g, a), this._manualColor = {}, this._manualColor[x] = e ? e.Overall : null, i != "csv") {
5
+ const y = (t) => {
6
6
  const o = [...h][t];
7
7
  o && (c = o.items), e != null && e != null && Object.keys(e).forEach((s) => {
8
- const i = c.filter((n) => n.code === s);
9
- if (i.length > 0 && i[0].labels) {
8
+ const l = c.filter((n) => n.code === s);
9
+ if (l.length > 0 && l[0].labels) {
10
10
  let n;
11
- f && (n = i[0].labels[f.toUpperCase()]), n ? this._manualColor[n] = e[s] : this._manualColor[i[0].value] = e[s];
11
+ f && (n = l[0].labels[f.toUpperCase()]), n ? this._manualColor[n] = e[s] : this._manualColor[l[0].value] = e[s];
12
12
  }
13
13
  });
14
- }, p = () => {
15
- c = a, Object.keys(e).forEach((t) => {
14
+ }, b = () => {
15
+ c = u, Object.keys(e).forEach((t) => {
16
16
  const o = [...c].filter((s) => s.value === t);
17
17
  if (o.length > 0 && o[0].labels) {
18
- const s = y[t];
19
- y && s && (this._manualColor[s] = e[t]);
20
- let i;
21
- f && (i = o[0].labels[f.toUpperCase()]), i ? this._manualColor[i] = e[t] : this._manualColor[o[0].label] = e[t];
18
+ const s = p[t];
19
+ p && s && (this._manualColor[s] = e[t]);
20
+ let l;
21
+ f && (l = o[0].labels[f.toUpperCase()]), l ? this._manualColor[l] = e[t] : this._manualColor[o[0].label] = e[t];
22
22
  }
23
23
  });
24
- }, x = () => {
24
+ }, B = () => {
25
25
  Object.keys(e).forEach((t) => {
26
26
  this._manualColor[t] = e[t];
27
27
  });
28
28
  };
29
29
  let c = [];
30
- const C = u == "line" ? 1 : r === "index" ? 0 : 1;
31
- !h && !a ? x() : h ? h.size == 1 && C == 1 ? _ == "measure" ? m(0) : p() : m(C) : p();
30
+ const m = _ == "line" ? 1 : r === "index" ? 0 : 1;
31
+ !h && !u ? B() : h ? h.size == 1 && m == 1 ? a == "measure" ? y(0) : b() : y(m) : b();
32
32
  } else
33
- this._manualColor = e;
33
+ this._manualColor = e && e[r] ? e[r] : {};
34
34
  }
35
- getColor(l, u) {
35
+ getColor(i, _) {
36
36
  if (this.colorBy === "index") {
37
- const r = this._manualColor[l] || this._manualColor[u[this.indexBy]];
37
+ const r = this._manualColor[i] || this._manualColor[_[this.indexBy]];
38
38
  return r || "#5555";
39
39
  }
40
- return this.colorBy === "id" && this._manualColor[l] ? this._manualColor[l] : "#5555";
40
+ return this.colorBy === "id" && this._manualColor[i] ? this._manualColor[i] : "#5555";
41
41
  }
42
- getColorByIndex(l) {
42
+ getColorByIndex(i) {
43
43
  }
44
- getColorByKey(l) {
45
- return this._manualColor[l] ? this._manualColor[l] : "#5555";
44
+ getColorByKey(i) {
45
+ return this._manualColor[i] ? this._manualColor[i] : "#5555";
46
46
  }
47
47
  }
48
48
  export {
@@ -46,7 +46,10 @@ class F extends v {
46
46
  console.log("minLabelZoomVisible", s, r), r < s ? (console.log("remove layers"), this.g.selectAll(".feature-label").transition().style("display", "none")) : this.g.selectAll(".feature-label").style("display", ""), this.g.selectAll(".feature-label").attr("font-size", (o) => Math.max(0.5, e / r) + "px");
47
47
  }
48
48
  createLayer(e) {
49
- this.createPaths(e), this.createLabels(e), this.props.onReady && this.props.onReady();
49
+ if (this.createPaths(e), this.createLabels(e), this.props.onReady) {
50
+ debugger;
51
+ this.props.onReady();
52
+ }
50
53
  }
51
54
  componentDidMount() {
52
55
  super.componentDidMount();
@@ -378,7 +378,11 @@ class ht extends pt {
378
378
  }
379
379
  componentDidUpdate(e, l, C) {
380
380
  const { app: i, file: u, featureJoinAttribute: h, data: c, measures: x, patternDiscriminator: o, editing: f, usePattern: n } = this.props;
381
- if ((f || JSON.stringify(e.data) !== JSON.stringify(c)) && this.create(), e.visible != this.props.visible && this.g.style("display", this.props.visible ? "" : "none"), e.patternsVisible != this.props.patternsVisible) {
381
+ if ((f || JSON.stringify(e.data) !== JSON.stringify(c)) && this.create(), e.visible != this.props.visible) {
382
+ debugger;
383
+ this.g.style("display", this.props.visible ? "" : "none");
384
+ }
385
+ if (e.patternsVisible != this.props.patternsVisible) {
382
386
  const p = M.select(this.gRef.current.parentNode.parentNode).select(`.layer_${W(this.props.id)}`);
383
387
  p.select(".patterns-checkbox").text(this.props.patternsVisible ? "☑ " : "☐ "), p.selectAll(".patterns-labels").style("display", this.props.patternsVisible ? "" : "none"), p.selectAll("rect").style("display", this.props.patternsVisible ? "" : "none"), p.select("svg").attr("height", this.props.patternsVisible ? 30 + (p.selectAll("rect").size() - 1) * 23 + "px" : "30px"), this.g.selectAll(".shape-pattern").style("display", this.props.patternsVisible ? "" : "none");
384
388
  }
@@ -1,15 +1,20 @@
1
- import { jsx as c, jsxs as t } from "react/jsx-runtime";
2
- import { Segment as r, Header as s } from "semantic-ui-react";
3
- const d = (a) => {
4
- const { noDataMsg: e, editing: n } = a;
5
- return /* @__PURE__ */ c(r, { placeholder: !0, className: "chartNoDataMessage", children: /* @__PURE__ */ t(s, { icon: !0, children: [
6
- /* @__PURE__ */ c(
7
- "svg",
8
- {
9
- xmlns: "http://www.w3.org/2000/svg",
10
- className: "noDataSVG",
11
- viewBox: "0 0 512 512",
12
- children: /* @__PURE__ */ c("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
1
+ import { jsxs as a, jsx as e } from "react/jsx-runtime";
2
+ import { useAppDispatch as p, useAppSelector as d } from "../../redux/hooks.js";
3
+ import { Segment as m, Header as h, Button as g } from "semantic-ui-react";
4
+ import { clearPostsFilter as u } from "../reducers/data.js";
5
+ const f = (n) => {
6
+ const { noDataMsg: r, editing: s, group: t } = n, l = p(), o = d((c) => c.getIn(["data", "posts", "initialFilters", t])), i = (c) => {
7
+ c.preventDefault(), u({ group: t, dispatch: l, initialFilters: o });
8
+ };
9
+ return /* @__PURE__ */ a(m, { placeholder: !0, className: "chartNoDataMessage", children: [
10
+ /* @__PURE__ */ a(h, { icon: !0, children: [
11
+ /* @__PURE__ */ e(
12
+ "svg",
13
+ {
14
+ xmlns: "http://www.w3.org/2000/svg",
15
+ className: "noDataSVG",
16
+ viewBox: "0 0 512 512",
17
+ children: /* @__PURE__ */ e("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
13
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
14
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
15
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
@@ -20,12 +25,14 @@ const d = (a) => {
20
25
  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
21
26
  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
22
27
  c43,35.3,70.5,88.8,70.5,148.7C442.3,356,356,442.3,250,442.3z` })
23
- }
24
- ),
25
- n && /* @__PURE__ */ c("div", { className: "WPnoDataMsg", children: "Not enough parameters to render the chart" }),
26
- /* @__PURE__ */ c("div", { className: "WPnoDataMsg", children: e })
27
- ] }) });
28
+ }
29
+ ),
30
+ s && /* @__PURE__ */ e("div", { className: "WPnoDataMsg", children: "Not enough parameters to render the chart" }),
31
+ /* @__PURE__ */ e("div", { className: "WPnoDataMsg", children: r })
32
+ ] }),
33
+ /* @__PURE__ */ e(g, { size: "medium", onClick: (c) => i(c), children: "Clear Filter" })
34
+ ] });
28
35
  };
29
36
  export {
30
- d as default
37
+ f as default
31
38
  };
@@ -1,23 +1,23 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- import R, { useState as S, useEffect as W } from "react";
3
- import { Container as A, Loader as j, Grid as I, GridRow as L } from "semantic-ui-react";
4
- import M from "../connected-templates/PostIntro.js";
5
- import { injectIntl as V } from "react-intl";
6
- import { getStartDateAndEndDateFromYear as k } from "./utils.js";
7
- import Y from "./NoData.js";
8
- import { useDispatch as q, useSelector as z } from "react-redux";
9
- import { getCustomPosts as J } from "../reducers/data-api.js";
10
- import { useParams as K } from "react-router";
11
- import { toNumber as Q, toBoolean as U } from "../../utils/data.js";
12
- const X = (d) => {
13
- const { posts: i, numberOfColumns: g, sortFirstBy: n, countryCategory: e, postWidth: b, postHeight: x } = d, l = [];
14
- if (e && n) {
15
- const a = i.filter((c) => c[e].includes(Number(n))), m = i.filter((c) => !c[e].includes(Number(n)));
16
- l.push(...a, ...m);
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import K, { useState as Y, useEffect as Q } from "react";
3
+ import { Container as j, Loader as X, Grid as B, GridRow as Z } from "semantic-ui-react";
4
+ import $ from "../connected-templates/PostIntro.js";
5
+ import { injectIntl as tt } from "react-intl";
6
+ import { getStartDateAndEndDateFromYear as R } from "./utils.js";
7
+ import et from "./NoData.js";
8
+ import { useDispatch as ot, useSelector as rt } from "react-redux";
9
+ import { getCustomPosts as nt } from "../reducers/data-api.js";
10
+ import { useParams as at } from "react-router";
11
+ import { toNumber as st, toBoolean as it } from "../../utils/data.js";
12
+ const lt = (T) => {
13
+ const { posts: u, numberOfColumns: E, sortFirstBy: c, countryCategory: l, postWidth: h, postHeight: D } = T, f = [];
14
+ if (l && c && c !== "none") {
15
+ const m = u.filter((y) => y[l].includes(Number(c))), N = u.filter((y) => !y[l].includes(Number(c)));
16
+ f.push(...m), f.push(...N);
17
17
  } else
18
- l.push(...i);
19
- return /* @__PURE__ */ o(I, { columns: g, children: /* @__PURE__ */ o(L, { children: l.map((a) => /* @__PURE__ */ o(I.Column, { children: /* @__PURE__ */ o("div", { style: { width: b, height: x, overflow: "hidden" }, children: /* @__PURE__ */ o(
20
- M,
18
+ f.push(...u);
19
+ return /* @__PURE__ */ i(B, { className: "filtered-posts", columns: E, children: /* @__PURE__ */ i(Z, { children: f.map((m) => /* @__PURE__ */ i(B.Column, { children: /* @__PURE__ */ i("div", { className: "filtered-posts-column", style: { width: h, height: D, overflow: "hidden" }, children: /* @__PURE__ */ i(
20
+ $,
21
21
  {
22
22
  style: {
23
23
  width: "100%",
@@ -26,98 +26,142 @@ const X = (d) => {
26
26
  margin: 0,
27
27
  padding: 0
28
28
  },
29
- as: A,
29
+ as: j,
30
30
  fluid: !0,
31
- post: a
31
+ post: m
32
32
  },
33
- a.id
34
- ) }) }, a.id)) }) });
35
- }, Z = (d) => {
33
+ m.id
34
+ ) }) }, m.id)) }) });
35
+ }, ut = (T) => {
36
36
  const {
37
- "data-group": i,
38
- "data-number-of-columns": g,
39
- "data-type": n,
40
- "data-taxonomy": e,
41
- "data-categories": b,
42
- "data-height": x,
43
- "data-post-width": l,
44
- "data-post-height": a,
45
- "data-number-of-items-per-page": m,
46
- "data-enable-sorting": c,
47
- "data-sort-first-by": F,
48
- "data-sorting-taxonomy": D
49
- } = d, v = q(), { locale: O } = K(), [P, p] = S(!1), B = z((t) => t), [f, T] = S([]), G = U(c), N = B.getIn(["data", "posts", i]), _ = G && F !== "none" ? Q(F) : null, s = N ?? {
37
+ "data-group": u,
38
+ "data-number-of-columns": E,
39
+ "data-type": c,
40
+ "data-taxonomy": l,
41
+ "data-categories": h,
42
+ "data-height": D,
43
+ "data-post-width": f,
44
+ "data-post-height": m,
45
+ "data-number-of-items-per-page": N,
46
+ "data-enable-sorting": y,
47
+ "data-sort-first-by": v,
48
+ "data-sorting-taxonomy": w,
49
+ editing: z
50
+ } = T, M = ot(), { locale: H } = at(), [A, b] = Y(!1), I = rt((t) => t).getIn(["data", "posts", u]), [P, x] = Y([]), O = it(y) && v !== "none" ? st(v) : null, g = I ?? {
50
51
  yearFilter: null,
51
52
  categoryFilter: null,
52
53
  countryFilter: null,
53
54
  page: 1,
54
55
  countryTaxonomy: null,
55
56
  categoryTaxonomy: null
56
- }, E = () => {
57
- const t = s.yearFilter ? k(Number(s.yearFilter)) : null, u = s.countryFilter ?? null, y = s.categoryFilter ?? null, h = s.categoryTaxonomy || (e && e !== "none" ? e : null), r = s.countryTaxonomy || null;
57
+ }, F = (t) => {
58
+ if (t == null)
59
+ return { values: [], isExplicitNone: !1 };
60
+ const e = Array.isArray(t) ? t : [t], a = e.some(
61
+ (o) => Number(o) === Number.MIN_SAFE_INTEGER
62
+ );
58
63
  return {
59
- before: (t == null ? void 0 : t.endDate) || null,
60
- after: (t == null ? void 0 : t.startDate) || null,
61
- categoryFilter: y,
62
- categoryTaxonomy: h,
63
- countryFilter: u,
64
- countryTaxonomy: r
64
+ values: e.map((o) => Number(o)).filter((o) => Number.isFinite(o) && o !== Number.MIN_SAFE_INTEGER),
65
+ isExplicitNone: a
65
66
  };
66
- }, H = async () => {
67
- const t = E();
68
- if (!n) {
69
- console.warn("FilteredPosts: missing post type. Configure 'type' in block settings."), T([]), p(!1);
67
+ }, W = (t) => {
68
+ if (!t || t.length === 0)
69
+ return null;
70
+ const e = Array.from(new Set(t)).sort((S, C) => S - C);
71
+ if (e.length === 0)
72
+ return null;
73
+ const a = e[0], r = e[e.length - 1], o = R(a), n = R(r);
74
+ return !(o != null && o.startDate) || !(n != null && n.endDate) ? null : {
75
+ startDate: o.startDate,
76
+ endDate: n.endDate
77
+ };
78
+ }, J = () => {
79
+ const t = F(g.yearFilter), e = t.isExplicitNone ? null : W(t.values), a = g.countryFilter ?? null, r = g.categoryFilter ?? null, o = g.categoryTaxonomy || (l && l !== "none" ? l : null), n = g.countryTaxonomy || null;
80
+ return {
81
+ before: (e == null ? void 0 : e.endDate) || null,
82
+ after: (e == null ? void 0 : e.startDate) || null,
83
+ categoryFilter: r,
84
+ categoryTaxonomy: o,
85
+ countryFilter: a,
86
+ countryTaxonomy: n
87
+ };
88
+ }, _ = (t) => z ? t : decodeURIComponent(t), L = (t) => {
89
+ try {
90
+ return JSON.parse(_(t));
91
+ } catch (e) {
92
+ return console.warn("JSON parsing failed for value:", t, "- treating as plain string. Error:", e), _(t);
93
+ }
94
+ }, q = () => {
95
+ const t = L(h);
96
+ return t ? typeof t == "string" ? t.split(",").map(Number) : typeof t == "number" ? [t] : t : [];
97
+ }, U = (t, e, a) => {
98
+ if (a) return null;
99
+ if (t.length === 0) return e.length > 0 ? e : null;
100
+ if (e.length === 0) return t;
101
+ const r = new Set(t), o = e.filter((n) => r.has(n));
102
+ return o.length > 0 ? o : null;
103
+ }, k = async () => {
104
+ b(!0);
105
+ const t = J(), e = F(q()).values, a = F(t.categoryFilter), r = U(
106
+ e,
107
+ a.values,
108
+ a.isExplicitNone
109
+ ), o = F(t.countryFilter);
110
+ if (a.isExplicitNone) {
111
+ x([]), b(!1);
70
112
  return;
71
113
  }
72
- p(!0);
73
- const u = /* @__PURE__ */ new Map();
74
- t.categoryTaxonomy && t.categoryFilter != null && u.set(
75
- t.categoryTaxonomy,
76
- Array.isArray(t.categoryFilter) ? t.categoryFilter : [t.categoryFilter]
77
- ), t.countryTaxonomy && t.countryFilter != null && u.set(
78
- t.countryTaxonomy,
79
- Array.isArray(t.countryFilter) ? t.countryFilter : [t.countryFilter]
80
- ), await J({
114
+ if (o.isExplicitNone) {
115
+ x([]), b(!1);
116
+ return;
117
+ }
118
+ const n = /* @__PURE__ */ new Map();
119
+ 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 S = r ? r.join(",") : void 0, C = {
81
121
  after: t.after,
82
122
  before: t.before,
83
- perPage: Number(m || 10),
84
- page: s.page || 1,
85
- locale: O || "en",
86
- postType: n,
87
- // explicit undefineds for legacy params to satisfy types
88
- taxonomy: void 0,
89
- category: void 0,
90
- taxonomyFilters: u
91
- }).then((y) => {
92
- if (y) {
93
- const { data: h, meta: r } = y;
94
- T(h);
95
- const w = r && r["x-wp-totalpages"] ? r["x-wp-totalpages"] : 1, C = r && r["x-wp-total"] ? r["x-wp-total"] : 0;
96
- w && C && v({
97
- type: "SET_POSTS_PAGINATION",
98
- group: i,
99
- totalPages: Number(w),
100
- totalItems: Number(C)
101
- });
102
- }
123
+ perPage: Number(N || 10),
124
+ page: g.page || 1,
125
+ locale: H || "en",
126
+ postType: c,
127
+ taxonomy: t.categoryTaxonomy || void 0,
128
+ category: S || void 0,
129
+ taxonomyFilters: n,
130
+ ordering: "date",
131
+ orderingDirection: "desc"
132
+ };
133
+ await nt(C).then((s) => {
134
+ if (s) {
135
+ let p = null, d = null;
136
+ if (s && typeof s == "object" && "data" in s ? (p = s.data, d = s.meta) : (Array.isArray(s), p = s), x(Array.isArray(p) ? p : []), d) {
137
+ const G = d["x-wp-totalpages"] ? d["x-wp-totalpages"] : 1, V = d["x-wp-total"] ? d["x-wp-total"] : 0;
138
+ G && V && M({
139
+ type: "SET_POSTS_PAGINATION",
140
+ group: u,
141
+ totalPages: Number(G),
142
+ totalItems: Number(V)
143
+ });
144
+ }
145
+ } else
146
+ x([]);
103
147
  }).finally(() => {
104
- p(!1);
148
+ b(!1);
105
149
  });
106
150
  };
107
- return W(() => {
108
- H();
109
- }, [N, n, e, m]), /* @__PURE__ */ o(A, { fluid: !0, children: P ? /* @__PURE__ */ o(j, { active: !0, inline: "centered" }) : !P && f && f.length > 0 ? /* @__PURE__ */ o(
110
- X,
151
+ return Q(() => {
152
+ (async () => await k())();
153
+ }, [I, c, l, N, h, O, w]), /* @__PURE__ */ i(j, { fluid: !0, children: A ? /* @__PURE__ */ i(X, { active: !0, inline: "centered" }) : !A && P && P.length > 0 ? /* @__PURE__ */ i(
154
+ lt,
111
155
  {
112
- posts: f,
113
- postWidth: Number(l),
114
- postHeight: Number(a),
115
- numberOfColumns: Number(g),
116
- sortFirstBy: _,
117
- countryCategory: D
156
+ posts: P,
157
+ postWidth: Number(f),
158
+ postHeight: Number(m),
159
+ numberOfColumns: Number(E),
160
+ sortFirstBy: O,
161
+ countryCategory: w
118
162
  }
119
- ) : /* @__PURE__ */ o(Y, { noDataMsg: "No posts found" }) });
120
- }, ut = V(R.memo(Z));
163
+ ) : /* @__PURE__ */ i(et, { noDataMsg: "No posts found", group: u }) });
164
+ }, Tt = tt(K.memo(ut));
121
165
  export {
122
- ut as default
166
+ Tt as default
123
167
  };
@@ -1,7 +1,8 @@
1
1
  import "@devgateway/wp-react-lib";
2
2
  function D(t) {
3
- 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));
4
- return { startDate: e, endDate: a };
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 };
5
6
  }
6
7
  export {
7
8
  D as getStartDateAndEndDateFromYear
@@ -0,0 +1,72 @@
1
+ import { jsx as v } from "react/jsx-runtime";
2
+ import { useState as A, useEffect as _ } from "react";
3
+ import j from "./PostsFilterDropdown.js";
4
+ import { Config as B } from "../../conf/index.js";
5
+ const N = (r) => {
6
+ const {
7
+ taxonomy: o,
8
+ group: l,
9
+ placeholder: p,
10
+ allLabel: c,
11
+ noneLabel: f,
12
+ useSingleColumn: m,
13
+ enableTextSearch: u,
14
+ filterType: g,
15
+ showNoDataOption: y,
16
+ closeOnSelect: d,
17
+ allNoneSameBehaviour: x,
18
+ autoApply: O,
19
+ alphabeticalSort: S,
20
+ ascOrder: h,
21
+ type: P,
22
+ categories: n,
23
+ onChange: T
24
+ } = r, [w, e] = A([]), C = async () => {
25
+ if (!o || o === "none") {
26
+ e([]);
27
+ return;
28
+ }
29
+ const s = await (await fetch(B.REACT_APP_WP_API + "/wp/v2/" + o)).json();
30
+ if (s) {
31
+ const i = s.map((t) => ({
32
+ key: t.id,
33
+ value: t.id,
34
+ text: t.name
35
+ }));
36
+ if (n) {
37
+ const t = i.filter((b) => n.indexOf(b.value.toString()) > -1);
38
+ e([]), e(t);
39
+ } else
40
+ e([]), e(i);
41
+ }
42
+ };
43
+ return _(() => {
44
+ let a = !1;
45
+ return a || (e([]), C()), () => {
46
+ a = !0;
47
+ };
48
+ }, [P, o, n]), /* @__PURE__ */ v(
49
+ j,
50
+ {
51
+ ...r,
52
+ group: l,
53
+ placeholder: p,
54
+ allLabel: c,
55
+ noneLabel: f,
56
+ useSingleColumn: m,
57
+ enableTextSearch: u,
58
+ filterType: g,
59
+ showNoDataOption: y,
60
+ closeOnSelect: d,
61
+ allNoneSameBehaviour: x,
62
+ autoApply: O,
63
+ alphabeticalSort: S,
64
+ ascOrder: h,
65
+ options: w,
66
+ onChange: T
67
+ }
68
+ );
69
+ };
70
+ export {
71
+ N as default
72
+ };