@devgateway/dvz-ui-react 1.7.2 → 1.7.4

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,23 +1,23 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import K, { useState as V, useEffect as Q } from "react";
3
- import { Container as R, Loader as X, Grid as Y, 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 B } 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);
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import X, { useState as w, useRef as Z, useEffect as tt } from "react";
3
+ import { Container as B, Loader as et, Grid as Y, GridRow as ot } from "semantic-ui-react";
4
+ import rt from "../connected-templates/PostIntro.js";
5
+ import { injectIntl as nt } from "react-intl";
6
+ import { getStartDateAndEndDateFromYear as j } from "./utils.js";
7
+ import at from "./NoData.js";
8
+ import { useDispatch as st, useSelector as it } from "react-redux";
9
+ import { getCustomPosts as lt } from "../reducers/data-api.js";
10
+ import { useParams as ut } from "react-router";
11
+ import { toNumber as ct, toBoolean as mt } from "../../utils/data.js";
12
+ const dt = (F) => {
13
+ const { posts: l, numberOfColumns: T, sortFirstBy: c, countryCategory: u, postWidth: h, postHeight: A } = F, d = [];
14
+ if (u && c && c !== "none") {
15
+ const m = l.filter((y) => y[u].includes(Number(c))), b = l.filter((y) => !y[u].includes(Number(c)));
16
+ d.push(...m), d.push(...b);
17
17
  } else
18
- f.push(...u);
19
- return /* @__PURE__ */ i(Y, { className: "filtered-posts", columns: E, children: /* @__PURE__ */ i(Z, { children: f.map((m) => /* @__PURE__ */ i(Y.Column, { children: /* @__PURE__ */ i("div", { className: "filtered-posts-column", style: { width: h, height: D, overflow: "hidden" }, children: /* @__PURE__ */ i(
20
- $,
18
+ d.push(...l);
19
+ return /* @__PURE__ */ s(Y, { className: "filtered-posts", columns: T, children: /* @__PURE__ */ s(ot, { children: d.map((m) => /* @__PURE__ */ s(Y.Column, { children: /* @__PURE__ */ s("div", { className: "filtered-posts-column", style: { width: h, height: A, overflow: "hidden" }, children: /* @__PURE__ */ s(
20
+ rt,
21
21
  {
22
22
  style: {
23
23
  width: "100%",
@@ -26,35 +26,35 @@ const lt = (T) => {
26
26
  margin: 0,
27
27
  padding: 0
28
28
  },
29
- as: R,
29
+ as: B,
30
30
  fluid: !0,
31
31
  post: m
32
32
  },
33
33
  m.id
34
34
  ) }) }, m.id)) }) });
35
- }, ut = (T) => {
35
+ }, ft = (F) => {
36
36
  const {
37
- "data-group": u,
38
- "data-number-of-columns": E,
37
+ "data-group": l,
38
+ "data-number-of-columns": T,
39
39
  "data-type": c,
40
- "data-taxonomy": l,
40
+ "data-taxonomy": u,
41
41
  "data-categories": h,
42
- "data-height": D,
43
- "data-post-width": f,
42
+ "data-height": A,
43
+ "data-post-width": d,
44
44
  "data-post-height": m,
45
- "data-number-of-items-per-page": N,
45
+ "data-number-of-items-per-page": b,
46
46
  "data-enable-sorting": y,
47
- "data-sort-first-by": v,
48
- "data-sorting-taxonomy": w,
49
- editing: j
50
- } = T, z = ot(), { locale: M } = at(), [A, b] = V(!1), I = rt((t) => t).getIn(["data", "posts", u]), [P, x] = V([]), H = it(y) && v !== "none" ? st(v) : null, g = I ?? {
47
+ "data-sort-first-by": I,
48
+ "data-sorting-taxonomy": O,
49
+ editing: M
50
+ } = F, z = st(), { locale: W } = ut(), [R, x] = w(!1), _ = it((t) => t).getIn(["data", "posts", l]), [C, N] = w([]), E = Z(null), [P, G] = w(void 0), J = mt(y) && I !== "none" ? ct(I) : null, f = _ ?? {
51
51
  yearFilter: null,
52
52
  categoryFilter: null,
53
53
  countryFilter: null,
54
54
  page: 1,
55
55
  countryTaxonomy: null,
56
56
  categoryTaxonomy: null
57
- }, F = (t) => {
57
+ }, v = (t) => {
58
58
  if (t == null)
59
59
  return { values: [], isExplicitNone: !1 };
60
60
  const e = Array.isArray(t) ? t : [t], a = e.some(
@@ -64,19 +64,19 @@ const lt = (T) => {
64
64
  values: e.map((o) => Number(o)).filter((o) => Number.isFinite(o) && o !== Number.MIN_SAFE_INTEGER),
65
65
  isExplicitNone: a
66
66
  };
67
- }, W = (t) => {
67
+ }, L = (t) => {
68
68
  if (!t || t.length === 0)
69
69
  return null;
70
- const e = Array.from(new Set(t)).sort((S, C) => S - C);
70
+ const e = Array.from(new Set(t)).sort((S, D) => S - D);
71
71
  if (e.length === 0)
72
72
  return null;
73
- const a = e[0], r = e[e.length - 1], o = B(a), n = B(r);
73
+ const a = e[0], r = e[e.length - 1], o = j(a), n = j(r);
74
74
  return !(o != null && o.startDate) || !(n != null && n.endDate) ? null : {
75
75
  startDate: o.startDate,
76
76
  endDate: n.endDate
77
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;
78
+ }, q = () => {
79
+ const t = v(f.yearFilter), e = t.isExplicitNone ? null : L(t.values), a = f.countryFilter ?? null, r = f.categoryFilter ?? null, o = f.categoryTaxonomy || (u && u !== "none" ? u : null), n = f.countryTaxonomy || null;
80
80
  return {
81
81
  before: (e == null ? void 0 : e.endDate) || null,
82
82
  after: (e == null ? void 0 : e.startDate) || null,
@@ -85,44 +85,44 @@ const lt = (T) => {
85
85
  countryFilter: a,
86
86
  countryTaxonomy: n
87
87
  };
88
- }, O = (t) => j ? t : decodeURIComponent(t), L = (t) => {
88
+ }, H = (t) => M ? t : decodeURIComponent(t), U = (t) => {
89
89
  try {
90
- return JSON.parse(O(t));
90
+ return JSON.parse(H(t));
91
91
  } catch (e) {
92
- return console.warn("JSON parsing failed for value:", t, "- treating as plain string. Error:", e), O(t);
92
+ return console.warn("JSON parsing failed for value:", t, "- treating as plain string. Error:", e), H(t);
93
93
  }
94
- }, q = () => {
95
- const t = L(h);
94
+ }, $ = () => {
95
+ const t = U(h);
96
96
  return t ? typeof t == "string" ? t.split(",").map(Number) : typeof t == "number" ? [t] : t : [];
97
- }, U = (t, e, a) => {
97
+ }, k = (t, e, a) => {
98
98
  if (a) return null;
99
99
  if (t.length === 0) return e.length > 0 ? e : null;
100
100
  if (e.length === 0) return t;
101
101
  const r = new Set(t), o = e.filter((n) => r.has(n));
102
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(
103
+ }, K = async () => {
104
+ E.current && G(E.current.offsetHeight), x(!0);
105
+ const t = q(), e = v($()).values, a = v(t.categoryFilter), r = k(
106
106
  e,
107
107
  a.values,
108
108
  a.isExplicitNone
109
- ), o = F(t.countryFilter);
109
+ ), o = v(t.countryFilter);
110
110
  if (a.isExplicitNone) {
111
- x([]), b(!1);
111
+ N([]), x(!1);
112
112
  return;
113
113
  }
114
114
  if (o.isExplicitNone) {
115
- x([]), b(!1);
115
+ N([]), x(!1);
116
116
  return;
117
117
  }
118
118
  const n = /* @__PURE__ */ new Map();
119
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 = {
120
+ const S = r ? r.join(",") : void 0, D = {
121
121
  after: t.after,
122
122
  before: t.before,
123
- perPage: Number(N || 10),
124
- page: g.page || 1,
125
- locale: M || "en",
123
+ perPage: Number(b || 10),
124
+ page: f.page || 1,
125
+ locale: W || "en",
126
126
  postType: c,
127
127
  taxonomy: t.categoryTaxonomy || void 0,
128
128
  category: S || void 0,
@@ -130,38 +130,38 @@ const lt = (T) => {
130
130
  ordering: "date",
131
131
  orderingDirection: "desc"
132
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 _ = d["x-wp-totalpages"] ? d["x-wp-totalpages"] : 1, G = d["x-wp-total"] ? d["x-wp-total"] : 0;
138
- _ && G && z({
133
+ await lt(D).then((i) => {
134
+ if (i) {
135
+ let p = null, g = null;
136
+ if (i && typeof i == "object" && "data" in i ? (p = i.data, g = i.meta) : (Array.isArray(i), p = i), N(Array.isArray(p) ? p : []), g) {
137
+ const V = g["x-wp-totalpages"] ? g["x-wp-totalpages"] : 1, Q = g["x-wp-total"] ? g["x-wp-total"] : 0;
138
+ V && z({
139
139
  type: "SET_POSTS_PAGINATION",
140
- group: u,
141
- totalPages: Number(_),
142
- totalItems: Number(G)
140
+ group: l,
141
+ totalPages: Number(V),
142
+ totalItems: Number(Q)
143
143
  });
144
144
  }
145
145
  } else
146
- x([]);
146
+ N([]);
147
147
  }).finally(() => {
148
- b(!1);
148
+ x(!1), G(void 0);
149
149
  });
150
150
  };
151
- return Q(() => {
152
- (async () => await k())();
153
- }, [I, c, l, N, h, w]), /* @__PURE__ */ i(R, { fluid: !0, children: A ? /* @__PURE__ */ i(X, { active: !0, inline: "centered" }) : !A && P && P.length > 0 ? /* @__PURE__ */ i(
154
- lt,
151
+ return tt(() => {
152
+ (async () => await K())();
153
+ }, [_, c, u, b, h, O]), /* @__PURE__ */ s("div", { ref: E, id: `filtered-posts-${l}`, style: P !== void 0 ? { minHeight: P, border: "1px solid #e0e0e0", borderRadius: "4px" } : void 0, children: /* @__PURE__ */ s(B, { fluid: !0, children: R ? /* @__PURE__ */ s("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: P ?? "100%" }, children: /* @__PURE__ */ s(et, { active: !0, inline: "centered" }) }) : !R && C && C.length > 0 ? /* @__PURE__ */ s(
154
+ dt,
155
155
  {
156
- posts: P,
157
- postWidth: Number(f),
156
+ posts: C,
157
+ postWidth: Number(d),
158
158
  postHeight: Number(m),
159
- numberOfColumns: Number(E),
160
- sortFirstBy: H,
161
- countryCategory: w
159
+ numberOfColumns: Number(T),
160
+ sortFirstBy: J,
161
+ countryCategory: O
162
162
  }
163
- ) : /* @__PURE__ */ i(et, { noDataMsg: "No posts found", group: u }) });
164
- }, Tt = tt(K.memo(ut));
163
+ ) : /* @__PURE__ */ s(at, { noDataMsg: "No posts found", group: l }) }) });
164
+ }, Pt = nt(X.memo(ft));
165
165
  export {
166
- Tt as default
166
+ Pt as default
167
167
  };
@@ -1,72 +1,78 @@
1
- import { jsxs as i, jsx as r } from "react/jsx-runtime";
2
- import I, { useState as g, useEffect as u } from "react";
3
- import { useDispatch as x, useSelector as m } from "react-redux";
4
- import { Container as y, Dropdown as b, Icon as p } from "semantic-ui-react";
5
- import { injectIntl as j } from "react-intl";
6
- const k = (f) => {
1
+ import { jsx as r, jsxs as s } from "react/jsx-runtime";
2
+ import x, { useState as g, useRef as y, useEffect as p } from "react";
3
+ import { useDispatch as R, useSelector as u } from "react-redux";
4
+ import { Container as b, Dropdown as E, Icon as m } from "semantic-ui-react";
5
+ import { injectIntl as S } from "react-intl";
6
+ const T = (f) => {
7
7
  const {
8
- "data-group": c
9
- } = f, h = x(), n = m((e) => e.getIn(["data", "postsPagination", c])), t = m((e) => e.getIn(["data", "posts", c])), s = n && (n != null && n.totalPages) ? n.totalPages : 1, [o, d] = g((t == null ? void 0 : t.page) ?? 1), [P, v] = g([]), C = () => {
8
+ "data-group": i
9
+ } = f, h = R(), t = u((e) => e.getIn(["data", "postsPagination", i])), n = u((e) => e.getIn(["data", "posts", i])), c = t && (t != null && t.totalPages) ? t.totalPages : 1, [a, d] = g((n == null ? void 0 : n.page) ?? 1), [P, v] = g([]), w = y(null), C = () => {
10
10
  const e = [];
11
- for (let a = 1; a <= s; a++)
12
- e.push({ key: a, text: a, value: a });
11
+ for (let o = 1; o <= c; o++)
12
+ e.push({ key: o, text: o, value: o });
13
13
  v(e);
14
14
  }, l = (e) => {
15
- e !== o && (e < 1 || e > s || (d(e), h({
15
+ if (e === a || e < 1 || e > c) return;
16
+ d(e), h({
16
17
  type: "SET_POSTS_FILTER",
17
- group: c,
18
- ...t,
18
+ group: i,
19
+ ...n,
19
20
  page: e
20
- })));
21
+ });
22
+ const o = document.getElementById(`filtered-posts-${i}`);
23
+ if (o) {
24
+ const I = o.getBoundingClientRect().top + window.scrollY - 50;
25
+ window.scrollTo({ top: I, behavior: "smooth" });
26
+ }
21
27
  };
22
- return u(() => {
28
+ return p(() => {
23
29
  C();
24
- }, [n == null ? void 0 : n.totalPages]), u(() => {
25
- const e = (t == null ? void 0 : t.page) ?? 1;
26
- e !== o && d(e);
27
- }, [t == null ? void 0 : t.page]), /* @__PURE__ */ i(y, { fluid: !0, className: "posts-pagination", children: [
28
- /* @__PURE__ */ i("div", { className: "posts-pagination-dropdown", children: [
30
+ }, [t]), p(() => {
31
+ const e = (n == null ? void 0 : n.page) ?? 1;
32
+ e !== a && d(e);
33
+ }, [n == null ? void 0 : n.page]), /* @__PURE__ */ r("div", { ref: w, children: /* @__PURE__ */ s(b, { fluid: !0, className: "posts-pagination", children: [
34
+ /* @__PURE__ */ s("div", { className: "posts-pagination-dropdown", children: [
29
35
  /* @__PURE__ */ r("span", { children: "Page" }),
30
36
  /* @__PURE__ */ r(
31
- b,
37
+ E,
32
38
  {
33
39
  options: P,
34
40
  placeholder: "Select Item",
35
41
  selection: !0,
36
42
  compact: !0,
37
- value: o,
38
- onChange: (e, a) => l(Number(a.value))
43
+ value: a,
44
+ onChange: (e, o) => l(Number(o.value))
39
45
  }
40
46
  ),
41
- /* @__PURE__ */ r("div", { children: /* @__PURE__ */ i("span", { children: [
47
+ /* @__PURE__ */ r("div", { children: /* @__PURE__ */ s("span", { children: [
42
48
  "of ",
43
- n && (n == null ? void 0 : n.totalPages)
49
+ t && (t == null ? void 0 : t.totalPages)
44
50
  ] }) })
45
51
  ] }),
46
- /* @__PURE__ */ i("div", { children: [
52
+ /* @__PURE__ */ s("div", { children: [
47
53
  /* @__PURE__ */ r(
48
- p,
54
+ m,
49
55
  {
50
56
  size: "large",
51
57
  style: { cursor: "pointer" },
52
- onClick: () => l(o - 1),
58
+ onClick: () => l(a - 1),
53
59
  name: "angle left",
54
- disabled: o === 1
60
+ disabled: a === 1
55
61
  }
56
62
  ),
57
63
  /* @__PURE__ */ r(
58
- p,
64
+ m,
59
65
  {
60
66
  size: "large",
61
67
  style: { cursor: "pointer" },
62
- onClick: () => l(o + 1),
68
+ onClick: () => l(a + 1),
63
69
  name: "angle right",
64
- disabled: o === s
70
+ disabled: a === c
65
71
  }
66
72
  )
67
73
  ] })
68
- ] });
69
- }, z = j(I.memo(k));
74
+ ] }) });
75
+ }, B = S(x.memo(T));
70
76
  export {
71
- z as default
77
+ B as default
72
78
  };