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