@devgateway/dvz-ui-react 1.7.3 → 1.7.5

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,73 +1,76 @@
1
- import { jsx as A } from "react/jsx-runtime";
1
+ import { jsx as F } from "react/jsx-runtime";
2
2
  import { useState as _, useEffect as j } from "react";
3
- import B from "./PostsFilterDropdown.js";
4
- import { Config as D } from "../../conf/index.js";
5
- const k = (i) => {
3
+ import D from "./PostsFilterDropdown.js";
4
+ import { Config as E } from "../../conf/index.js";
5
+ const W = (p) => {
6
6
  const {
7
- taxonomy: t,
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,
7
+ taxonomy: n,
8
+ group: c,
9
+ placeholder: f,
10
+ allLabel: m,
11
+ noneLabel: u,
12
+ useSingleColumn: g,
13
+ enableTextSearch: y,
14
+ filterType: d,
15
+ showNoDataOption: h,
16
+ closeOnSelect: x,
17
+ allNoneSameBehaviour: A,
18
18
  autoApply: O,
19
- alphabeticalSort: S,
20
- ascOrder: h,
21
- type: P,
22
- categories: n,
23
- onChange: T,
24
- ...w
25
- } = i, [C, e] = _([]), b = async () => {
26
- if (!t || t === "none") {
19
+ alphabeticalSort: P,
20
+ ascOrder: S,
21
+ type: w,
22
+ categories: a,
23
+ onChange: B,
24
+ wpApiBase: o,
25
+ ...T
26
+ } = p, [b, e] = _([]), v = async () => {
27
+ if (!n || n === "none") {
27
28
  e([]);
28
29
  return;
29
30
  }
30
- const r = await (await fetch(D.REACT_APP_WP_API + "/wp/v2/" + t)).json();
31
+ const i = o != null && o !== "" ? o : E.REACT_APP_WP_API;
32
+ console.log("Fetching taxonomy options from API base:", i);
33
+ const r = await (await fetch(i + "/wp/v2/" + n)).json();
31
34
  if (r) {
32
- const s = r.map((o) => ({
33
- key: o.id,
34
- value: o.id,
35
- text: o.name
35
+ const l = r.map((t) => ({
36
+ key: t.id,
37
+ value: t.id,
38
+ text: t.name
36
39
  }));
37
- if (n) {
38
- const o = s.filter((v) => n.indexOf(v.value.toString()) > -1);
39
- e([]), e(o);
40
+ if (a) {
41
+ const t = l.filter((C) => a.indexOf(C.value.toString()) > -1);
42
+ e([]), e(t);
40
43
  } else
41
- e([]), e(s);
44
+ e([]), e(l);
42
45
  }
43
46
  };
44
47
  return j(() => {
45
- let a = !1;
46
- return a || (e([]), b()), () => {
47
- a = !0;
48
+ let s = !1;
49
+ return s || (e([]), v()), () => {
50
+ s = !0;
48
51
  };
49
- }, [P, t, n]), /* @__PURE__ */ A(
50
- B,
52
+ }, [w, n, a, o]), /* @__PURE__ */ F(
53
+ D,
51
54
  {
52
- ...w,
53
- group: l,
54
- placeholder: p,
55
- allLabel: c,
56
- noneLabel: f,
57
- useSingleColumn: m,
58
- enableTextSearch: u,
59
- filterType: g,
60
- showNoDataOption: y,
61
- closeOnSelect: d,
62
- allNoneSameBehaviour: x,
55
+ ...T,
56
+ group: c,
57
+ placeholder: f,
58
+ allLabel: m,
59
+ noneLabel: u,
60
+ useSingleColumn: g,
61
+ enableTextSearch: y,
62
+ filterType: d,
63
+ showNoDataOption: h,
64
+ closeOnSelect: x,
65
+ allNoneSameBehaviour: A,
63
66
  autoApply: O,
64
- alphabeticalSort: S,
65
- ascOrder: h,
66
- options: C,
67
- onChange: T
67
+ alphabeticalSort: P,
68
+ ascOrder: S,
69
+ options: b,
70
+ onChange: B
68
71
  }
69
72
  );
70
73
  };
71
74
  export {
72
- k as default
75
+ W as default
73
76
  };
@@ -1,184 +1,175 @@
1
- import { jsxs as de, jsx as U } from "react/jsx-runtime";
2
- import { useRef as $, useState as f, useMemo as N, useEffect as V } from "react";
3
- import { Container as me } from "semantic-ui-react";
4
- import { toBoolean as i, toNumber as fe } from "../../utils/data.js";
5
- import { useAppDispatch as he } from "../../redux/hooks.js";
6
- import { useSelector as Se } from "react-redux";
7
- import Ce from "./CategoricalFilter.js";
8
- import Te from "./YearFilter.js";
9
- const Ee = (k) => {
1
+ import { jsxs as se, jsx as Y } from "react/jsx-runtime";
2
+ import { useState as h, useMemo as p, useEffect as E } from "react";
3
+ import { Container as ce } from "semantic-ui-react";
4
+ import { toBoolean as s, toNumber as ye } from "../../utils/data.js";
5
+ import { useAppDispatch as ue } from "../../redux/hooks.js";
6
+ import { useSelector as pe } from "react-redux";
7
+ import Fe from "./CategoricalFilter.js";
8
+ import de from "./YearFilter.js";
9
+ const Ae = (L) => {
10
10
  const {
11
- "data-alphabetical-sort": G,
12
- "data-asc-order": H,
11
+ "data-alphabetical-sort": D,
12
+ "data-asc-order": R,
13
13
  "data-group": c,
14
- "data-placeholder": A,
15
- "data-all-label": Y,
16
- "data-none-label": I,
17
- "data-use-single-column": Q,
18
- "data-enable-text-search": W,
19
- "data-filter-type": S,
20
- "data-show-no-data-option": X,
21
- "data-close-on-select": Z,
22
- "data-all-none-same-behaviour": ee,
23
- "data-auto-apply": te,
24
- "data-taxonomy": s,
25
- "data-categories": y = "[]",
26
- "data-is-country-filter": re,
27
- "data-is-year-filter": ae,
28
- "data-type": oe,
29
- "data-sort-first-by": _,
30
- "data-default-values": le = "[]",
31
- editing: ne = !1
32
- } = k, h = he(), t = Se((e) => e.getIn(["data", "posts", c])) || {}, o = S === "multi-select", B = $(0), E = (e) => ne ? e : decodeURIComponent(e);
33
- let n = ((e) => {
14
+ "data-placeholder": T,
15
+ "data-all-label": C,
16
+ "data-none-label": b,
17
+ "data-use-single-column": v,
18
+ "data-enable-text-search": P,
19
+ "data-filter-type": F,
20
+ "data-show-no-data-option": z,
21
+ "data-close-on-select": j,
22
+ "data-all-none-same-behaviour": J,
23
+ "data-auto-apply": K,
24
+ "data-taxonomy": i,
25
+ "data-categories": d = "[]",
26
+ "data-is-country-filter": M,
27
+ "data-is-year-filter": U,
28
+ "data-type": $,
29
+ "data-sort-first-by": O,
30
+ "data-default-values": k = "[]",
31
+ "data-wordpress-source-type": ge,
32
+ "data-wordpress-source": q,
33
+ editing: G = !1
34
+ } = L, u = ue(), e = pe((t) => t.getIn(["data", "posts", c])) || {}, l = F === "multi-select", [x, fe] = h(0), N = (t) => G ? t : decodeURIComponent(t);
35
+ let n = ((t) => {
34
36
  try {
35
- return JSON.parse(E(e));
36
- } catch (r) {
37
- return console.warn("JSON parsing failed for value:", e, "- treating as plain string. Error:", r), E(e);
37
+ return JSON.parse(N(t));
38
+ } catch (o) {
39
+ return console.warn("JSON parsing failed for value:", t, "- treating as plain string. Error:", o), N(t);
38
40
  }
39
- })(le);
41
+ })(k);
40
42
  n || (n = []), typeof n == "string" && (n = n.split(",").map(Number)), typeof n == "number" && (n = [n]);
41
- const ie = i(G), se = i(H), L = i(X), R = i(Z), w = i(ee), D = i(te), a = i(re), l = i(ae), P = i(Q), v = i(W), C = _ !== "none" ? fe(_) : null, [u, ce] = f([]), [T, ye] = f(!1), O = (e, r) => r ? Array.isArray(e) ? e : e != null ? [e] : [] : e || void 0, x = (e, r) => Array.isArray(e) && Array.isArray(r) ? e.length !== r.length ? !1 : e.every((d, m) => d === r[m]) : e === r, F = N(
42
- () => O(t.countryFilter, o),
43
- [t.countryFilter, o]
44
- ), p = N(
45
- () => O(t.categoryFilter, o),
46
- [t.categoryFilter, o]
47
- ), g = N(
48
- () => l ? O(t.yearFilter, o) : void 0,
49
- [t.yearFilter, o, l]
50
- ), [ue, z] = f(g), [K, M] = f(F), [j, J] = f(p), q = $({
51
- countryFilter: F,
52
- categoryFilter: p,
53
- yearFilter: g,
54
- isMultiSelectFilter: o
55
- });
56
- V(() => {
57
- const e = q.current, r = !x(e.countryFilter, F), d = !x(e.categoryFilter, p), m = l && !x(e.yearFilter, g), b = e.isMultiSelectFilter !== o;
58
- (r || d || m || b) && (r && M(F), d && J(p), m && z(g), q.current = {
59
- countryFilter: F,
60
- categoryFilter: p,
61
- yearFilter: g,
62
- isMultiSelectFilter: o
63
- });
64
- }, [F, p, g, o, l]);
65
- const Fe = (e) => {
66
- z(e), h({
43
+ const H = s(D), Q = s(R), V = s(z), A = s(j), B = s(J), I = s(K), r = s(M), a = s(U), _ = s(v), w = s(P), g = O !== "none" ? ye(O) : null, [y, W] = h([]), [m, X] = h(!1), f = (t, o) => o ? Array.isArray(t) ? t : t != null ? [t] : [] : t || void 0, Z = p(
44
+ () => f(e.countryFilter, l),
45
+ [e.countryFilter, l]
46
+ ), ee = p(
47
+ () => f(e.categoryFilter, l),
48
+ [e.categoryFilter, l]
49
+ ), te = p(
50
+ () => a ? f(e.yearFilter, l) : void 0,
51
+ [e.yearFilter, l, a]
52
+ ), S = p(
53
+ () => d ? d.split(",") : [],
54
+ [d]
55
+ ), re = (t) => {
56
+ u({
67
57
  type: "SET_POSTS_FILTER",
68
58
  group: c,
69
- ...t,
70
- isYearFilter: l,
71
- yearFilter: l ? e : null,
72
- isCountryFilter: a,
73
- categoryFilter: t.categoryFilter,
74
- countryFilter: t.countryFilter,
75
- sortFirstBy: C,
76
- countryCategory: s,
77
- categoryTaxonomy: s,
78
- countryTaxonomy: s
59
+ ...e,
60
+ isYearFilter: a,
61
+ yearFilter: a ? t : null,
62
+ isCountryFilter: r,
63
+ categoryFilter: e.categoryFilter,
64
+ countryFilter: e.countryFilter,
65
+ sortFirstBy: g,
66
+ countryCategory: i,
67
+ categoryTaxonomy: i,
68
+ countryTaxonomy: i
79
69
  });
80
- }, pe = (e) => {
81
- a ? M(e) : J(e), h({
70
+ }, ae = (t) => {
71
+ u({
82
72
  type: "SET_POSTS_FILTER",
83
73
  group: c,
84
- ...t,
74
+ ...e,
85
75
  // Preserve both filters so they can work together
86
- categoryFilter: a ? t.categoryFilter : e,
87
- countryFilter: a ? e : t.countryFilter,
88
- isYearFilter: l,
89
- yearFilter: t.yearFilter,
90
- isCountryFilter: a,
91
- sortFirstBy: a ? C : t.sortFirstBy,
92
- countryCategory: a ? s : t.countryCategory,
93
- categoryCategory: a ? t.categoryCategory : e,
94
- categoryTaxonomy: a ? t.categoryTaxonomy : s,
95
- countryTaxonomy: a ? s : t.countryTaxonomy
76
+ categoryFilter: r ? e.categoryFilter : t,
77
+ countryFilter: r ? t : e.countryFilter,
78
+ isYearFilter: a,
79
+ yearFilter: e.yearFilter,
80
+ isCountryFilter: r,
81
+ sortFirstBy: r ? g : e.sortFirstBy,
82
+ countryCategory: r ? i : e.countryCategory,
83
+ categoryCategory: r ? e.categoryCategory : t,
84
+ categoryTaxonomy: r ? e.categoryTaxonomy : i,
85
+ countryTaxonomy: r ? i : e.countryTaxonomy
96
86
  });
97
87
  };
98
- return V(() => {
99
- const e = n.length > 0, r = o ? n : n[0], d = a ? t.categoryFilter : e ? r : o ? y ? y.split(",").map(Number) : [] : t.categoryFilter, m = a ? e ? r : o ? y ? y.split(",").map(Number) : [] : t.countryFilter : t.countryFilter, b = l && o ? u.length > 0 ? u.map((ge) => ge.value) : [] : t.yearFilter;
100
- h({
88
+ return E(() => {
89
+ const t = n.length > 0, o = l ? n : n[0], oe = r ? e.categoryFilter : t ? o : l ? S.map(Number) : e.categoryFilter, le = r ? t ? o : l ? S.map(Number) : e.countryFilter : e.countryFilter, ne = a && l ? y.length > 0 ? y.map((ie) => ie.value) : [] : e.yearFilter;
90
+ u({
101
91
  type: "SET_INITIAL_POSTS_FILTER",
102
92
  group: c,
103
- categoryFilter: d,
104
- countryFilter: m,
105
- isYearFilter: l,
106
- isCountryFilter: a,
107
- sortFirstBy: C,
108
- yearFilter: l ? b : null,
109
- categoryCategory: a ? null : t.categoryCategory,
110
- categoryTaxonomy: a ? null : s,
111
- countryCategory: a ? t.countryCategory : null,
112
- countryTaxonomy: a ? s : null,
93
+ categoryFilter: oe,
94
+ countryFilter: le,
95
+ isYearFilter: a,
96
+ isCountryFilter: r,
97
+ sortFirstBy: g,
98
+ yearFilter: a ? ne : null,
99
+ categoryCategory: r ? null : e.categoryCategory,
100
+ categoryTaxonomy: r ? null : i,
101
+ countryCategory: r ? i : null,
102
+ countryTaxonomy: r ? i : null,
113
103
  page: 1
114
104
  });
115
- }, []), V(() => {
116
- if (l && !T) {
117
- const e = l && o ? u.length > 0 ? u.map((r) => r.value) : [] : t.yearFilter;
118
- h({
105
+ }, []), E(() => {
106
+ if (a && !m) {
107
+ const t = a && l ? y.length > 0 ? y.map((o) => o.value) : [] : e.yearFilter;
108
+ u({
119
109
  type: "SET_INITIAL_POSTS_FILTER",
120
110
  group: c,
121
- ...t,
122
- isYearFilter: l,
123
- yearFilter: l ? e : null
111
+ ...e,
112
+ isYearFilter: a,
113
+ yearFilter: a ? t : null
124
114
  });
125
115
  }
126
- }, [T]), /* @__PURE__ */ de(me, { fluid: !0, className: "filter post-filter", children: [
127
- l && /* @__PURE__ */ U(
128
- Te,
116
+ }, [m]), /* @__PURE__ */ se(ce, { fluid: !0, className: "filter post-filter", children: [
117
+ a && /* @__PURE__ */ Y(
118
+ de,
129
119
  {
130
120
  group: c,
131
- placeholder: A,
132
- allLabel: Y,
133
- noneLabel: I,
134
- useSingleColumn: P,
135
- enableTextSearch: v,
136
- filterType: S,
137
- showNoDataOption: L,
138
- closeOnSelect: R,
139
- allNoneSameBehaviour: w,
140
- autoApply: D,
141
- alphabeticalSort: ie,
142
- ascOrder: se,
143
- options: u,
144
- value: ue,
145
- yearOptions: u,
146
- setYearOptions: ce,
147
- yearFilterLoading: T,
148
- setYearFilterLoading: ye,
149
- onChange: (e, r) => {
150
- Fe(r);
121
+ placeholder: T,
122
+ allLabel: C,
123
+ noneLabel: b,
124
+ useSingleColumn: _,
125
+ enableTextSearch: w,
126
+ filterType: F,
127
+ showNoDataOption: V,
128
+ closeOnSelect: A,
129
+ allNoneSameBehaviour: B,
130
+ autoApply: I,
131
+ alphabeticalSort: H,
132
+ ascOrder: Q,
133
+ options: y,
134
+ value: te,
135
+ yearOptions: y,
136
+ setYearOptions: W,
137
+ yearFilterLoading: m,
138
+ setYearFilterLoading: X,
139
+ onChange: (t, o) => {
140
+ re(o);
151
141
  },
152
- resetKey: B.current
142
+ resetKey: x
153
143
  }
154
144
  ),
155
- !l && /* @__PURE__ */ U(
156
- Ce,
145
+ !a && /* @__PURE__ */ Y(
146
+ Fe,
157
147
  {
158
148
  group: c,
159
- placeholder: A,
160
- allLabel: Y,
161
- noneLabel: I,
162
- useSingleColumn: P,
163
- enableTextSearch: v,
164
- filterType: S,
165
- showNoDataOption: L,
166
- closeOnSelect: R,
167
- allNoneSameBehaviour: w,
168
- autoApply: D,
169
- taxonomy: s,
170
- type: oe,
171
- value: a ? K : j,
172
- onChange: (e, r) => {
173
- pe(r);
149
+ placeholder: T,
150
+ allLabel: C,
151
+ noneLabel: b,
152
+ useSingleColumn: _,
153
+ enableTextSearch: w,
154
+ filterType: F,
155
+ showNoDataOption: V,
156
+ closeOnSelect: A,
157
+ allNoneSameBehaviour: B,
158
+ autoApply: I,
159
+ taxonomy: i,
160
+ type: $,
161
+ value: r ? Z : ee,
162
+ onChange: (t, o) => {
163
+ ae(o);
174
164
  },
175
- categories: y ? y.split(",") : [],
176
- resetKey: B.current
165
+ categories: S,
166
+ resetKey: x,
167
+ wpApiBase: q ?? void 0
177
168
  },
178
169
  `cat-${c}`
179
170
  )
180
171
  ] });
181
172
  };
182
173
  export {
183
- Ee as default
174
+ Ae as default
184
175
  };
@@ -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
  };