@devgateway/dvz-ui-react 1.7.5 → 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,58 +1,59 @@
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) => {
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": D,
12
- "data-asc-order": R,
12
+ "data-alphabetical-sort": v,
13
+ "data-asc-order": D,
13
14
  "data-group": c,
14
- "data-placeholder": T,
15
- "data-all-label": C,
15
+ "data-placeholder": C,
16
+ "data-all-label": T,
16
17
  "data-none-label": b,
17
- "data-use-single-column": v,
18
- "data-enable-text-search": P,
18
+ "data-use-single-column": P,
19
+ "data-enable-text-search": z,
19
20
  "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,
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,
24
25
  "data-taxonomy": i,
25
26
  "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,
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,
33
34
  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
+ } = 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);
35
36
  let n = ((t) => {
36
37
  try {
37
- return JSON.parse(N(t));
38
+ return JSON.parse(V(t));
38
39
  } catch (o) {
39
- return console.warn("JSON parsing failed for value:", t, "- treating as plain string. Error:", o), N(t);
40
+ return console.warn("JSON parsing failed for value:", t, "- treating as plain string. Error:", o), V(t);
40
41
  }
41
- })(k);
42
+ })(q);
42
43
  n || (n = []), typeof n == "string" && (n = n.split(",").map(Number)), typeof n == "number" && (n = [n]);
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
+ 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(
44
45
  () => f(e.countryFilter, l),
45
46
  [e.countryFilter, l]
46
- ), ee = p(
47
+ ), te = p(
47
48
  () => f(e.categoryFilter, l),
48
49
  [e.categoryFilter, l]
49
- ), te = p(
50
+ ), re = p(
50
51
  () => a ? f(e.yearFilter, l) : void 0,
51
52
  [e.yearFilter, l, a]
52
53
  ), S = p(
53
54
  () => d ? d.split(",") : [],
54
55
  [d]
55
- ), re = (t) => {
56
+ ), ae = (t) => {
56
57
  u({
57
58
  type: "SET_POSTS_FILTER",
58
59
  group: c,
@@ -62,12 +63,12 @@ const Ae = (L) => {
62
63
  isCountryFilter: r,
63
64
  categoryFilter: e.categoryFilter,
64
65
  countryFilter: e.countryFilter,
65
- sortFirstBy: g,
66
+ sortFirstBy: m,
66
67
  countryCategory: i,
67
68
  categoryTaxonomy: i,
68
69
  countryTaxonomy: i
69
70
  });
70
- }, ae = (t) => {
71
+ }, oe = (t) => {
71
72
  u({
72
73
  type: "SET_POSTS_FILTER",
73
74
  group: c,
@@ -75,35 +76,35 @@ const Ae = (L) => {
75
76
  // Preserve both filters so they can work together
76
77
  categoryFilter: r ? e.categoryFilter : t,
77
78
  countryFilter: r ? t : e.countryFilter,
78
- isYearFilter: a,
79
+ isYearFilter: e.isYearFilter,
79
80
  yearFilter: e.yearFilter,
80
- isCountryFilter: r,
81
- sortFirstBy: r ? g : e.sortFirstBy,
81
+ isCountryFilter: e.isCountryFilter,
82
+ sortFirstBy: r ? m : e.sortFirstBy,
82
83
  countryCategory: r ? i : e.countryCategory,
83
84
  categoryCategory: r ? e.categoryCategory : t,
84
85
  categoryTaxonomy: r ? e.categoryTaxonomy : i,
85
86
  countryTaxonomy: r ? i : e.countryTaxonomy
86
87
  });
87
88
  };
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;
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;
90
91
  u({
91
92
  type: "SET_INITIAL_POSTS_FILTER",
92
93
  group: c,
93
- categoryFilter: oe,
94
- countryFilter: le,
94
+ categoryFilter: le,
95
+ countryFilter: ne,
95
96
  isYearFilter: a,
96
97
  isCountryFilter: r,
97
- sortFirstBy: g,
98
- yearFilter: a ? ne : null,
98
+ sortFirstBy: m,
99
+ yearFilter: a ? ie : null,
99
100
  categoryCategory: r ? null : e.categoryCategory,
100
101
  categoryTaxonomy: r ? null : i,
101
102
  countryCategory: r ? i : null,
102
103
  countryTaxonomy: r ? i : null,
103
104
  page: 1
104
105
  });
105
- }, []), E(() => {
106
- if (a && !m) {
106
+ }, []), L(() => {
107
+ if (a && !g) {
107
108
  const t = a && l ? y.length > 0 ? y.map((o) => o.value) : [] : e.yearFilter;
108
109
  u({
109
110
  type: "SET_INITIAL_POSTS_FILTER",
@@ -113,63 +114,65 @@ const Ae = (L) => {
113
114
  yearFilter: a ? t : null
114
115
  });
115
116
  }
116
- }, [m]), /* @__PURE__ */ se(ce, { fluid: !0, className: "filter post-filter", children: [
117
- a && /* @__PURE__ */ Y(
118
- de,
117
+ }, [g]), /* @__PURE__ */ ce(ue, { fluid: !0, className: "filter post-filter", children: [
118
+ a && /* @__PURE__ */ E(
119
+ ge,
119
120
  {
120
121
  group: c,
121
- placeholder: T,
122
- allLabel: C,
122
+ placeholder: C,
123
+ allLabel: T,
123
124
  noneLabel: b,
124
- useSingleColumn: _,
125
- enableTextSearch: w,
125
+ useSingleColumn: Y,
126
+ enableTextSearch: _,
126
127
  filterType: F,
127
- showNoDataOption: V,
128
+ showNoDataOption: I,
128
129
  closeOnSelect: A,
129
130
  allNoneSameBehaviour: B,
130
- autoApply: I,
131
- alphabeticalSort: H,
132
- ascOrder: Q,
131
+ autoApply: w,
132
+ alphabeticalSort: Q,
133
+ ascOrder: W,
133
134
  options: y,
134
- value: te,
135
+ value: re,
135
136
  yearOptions: y,
136
- setYearOptions: W,
137
- yearFilterLoading: m,
138
- setYearFilterLoading: X,
137
+ setYearOptions: X,
138
+ yearFilterLoading: g,
139
+ setYearFilterLoading: Z,
139
140
  onChange: (t, o) => {
140
- re(o);
141
+ ae(o);
141
142
  },
142
- resetKey: x
143
+ resetKey: N,
144
+ wpApiBase: O ?? void 0
143
145
  }
144
146
  ),
145
- !a && /* @__PURE__ */ Y(
146
- Fe,
147
+ !a && /* @__PURE__ */ E(
148
+ me,
147
149
  {
148
150
  group: c,
149
- placeholder: T,
150
- allLabel: C,
151
+ placeholder: C,
152
+ allLabel: T,
151
153
  noneLabel: b,
152
- useSingleColumn: _,
153
- enableTextSearch: w,
154
+ useSingleColumn: Y,
155
+ enableTextSearch: _,
154
156
  filterType: F,
155
- showNoDataOption: V,
157
+ showNoDataOption: I,
156
158
  closeOnSelect: A,
157
159
  allNoneSameBehaviour: B,
158
- autoApply: I,
160
+ autoApply: w,
159
161
  taxonomy: i,
160
- type: $,
161
- value: r ? Z : ee,
162
+ type: k,
163
+ value: r ? ee : te,
162
164
  onChange: (t, o) => {
163
- ae(o);
165
+ oe(o);
164
166
  },
165
167
  categories: S,
166
- resetKey: x,
167
- wpApiBase: q ?? void 0
168
+ resetKey: N,
169
+ wpApiBase: O ?? void 0,
170
+ locale: H
168
171
  },
169
172
  `cat-${c}`
170
173
  )
171
174
  ] });
172
- };
175
+ }, Ee = fe(ye.memo(he));
173
176
  export {
174
- Ae as default
177
+ Ee as default
175
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
  };
@@ -1,50 +1,48 @@
1
1
  import { Config as C } from "../../conf/index.js";
2
2
  import { get as O } from "../../api/commons.js";
3
- function g(e) {
4
- return JSON.parse(JSON.stringify(e));
3
+ function d(t) {
4
+ return JSON.parse(JSON.stringify(t));
5
5
  }
6
- const u = process.env.VITE_REACT_APP_API_ROOT || C.REACT_APP_API_ROOT || null, T = typeof window < "u" ? window.location.origin : "", d = {}, l = {}, E = 3 * 60 * 1e3;
7
- function $(e) {
8
- return Object.keys(e).map((t) => encodeURIComponent(t) + "=" + encodeURIComponent(e[t])).join("&");
6
+ const u = process.env.VITE_REACT_APP_API_ROOT || C.REACT_APP_API_ROOT || null, T = typeof window < "u" ? window.location.origin : "", h = {}, f = {}, E = 3 * 60 * 1e3;
7
+ function P(t) {
8
+ return Object.keys(t).map((e) => encodeURIComponent(e) + "=" + encodeURIComponent(t[e])).join("&");
9
9
  }
10
- function h(e, t = !1) {
11
- const n = e, o = Date.now();
12
- if (l[n] && o - l[n].timestamp < E)
13
- return Promise.resolve(g(l[n].data));
14
- if (d[n])
15
- return d[n].then(g);
16
- const f = O(e, {}, t).then((a) => (l[n] = { data: a, timestamp: Date.now() }, t ? { data: g(a), meta: l[n].meta } : g(a))).finally(() => {
17
- delete d[n];
10
+ function $(t, e = !1) {
11
+ const n = t, r = Date.now();
12
+ if (f[n] && r - f[n].timestamp < E)
13
+ return Promise.resolve(d(f[n].data));
14
+ if (h[n])
15
+ return h[n].then(d);
16
+ const p = O(t, {}, e).then((a) => (f[n] = { data: a, timestamp: Date.now() }, e ? { data: d(a), meta: f[n].meta } : d(a))).finally(() => {
17
+ delete h[n];
18
18
  });
19
- return d[n] = f, f;
19
+ return h[n] = p, p;
20
20
  }
21
- const k = ({ app: e, params: t }) => {
22
- const n = `${u || T}/api/${e}/categories${t ? "?" + $(t) : ""}`;
23
- return h(n);
24
- }, V = ({ app: e, type: t, params: n }) => {
25
- const o = `${u || ""}/api/${e}/categories/${t}${n ? "?" + $(n) : ""}`;
26
- return h(o);
27
- }, J = ({ source: e, app: t, params: n }) => {
28
- const o = `${u || T}/api/${t}/stats/${e}${n ? "?" + $(n) : ""}`;
29
- return h(o);
30
- }, L = ({ postType: e, taxonomy: t, category: n, taxonomyFilters: o, before: f, perPage: a, page: _, locale: R, after: m, ordering: I, orderingDirection: q, wpApiBase: p }) => {
31
- const S = p != null && p !== "" ? p : C.REACT_APP_WP_API;
32
- console.log("Using API base:", S);
33
- const U = `${S}/wp/v2/${e}`, r = new URLSearchParams(), P = /* @__PURE__ */ new Map(), A = (s, i) => {
21
+ const k = ({ app: t, params: e }) => {
22
+ const n = `${u || T}/api/${t}/categories${e ? "?" + P(e) : ""}`;
23
+ return $(n);
24
+ }, V = ({ app: t, type: e, params: n }) => {
25
+ const r = `${u || ""}/api/${t}/categories/${e}${n ? "?" + P(n) : ""}`;
26
+ return $(r);
27
+ }, J = ({ source: t, app: e, params: n }) => {
28
+ const r = `${u || T}/api/${e}/stats/${t}${n ? "?" + P(n) : ""}`;
29
+ return $(r);
30
+ }, L = ({ postType: t, taxonomy: e, category: n, taxonomyFilters: r, before: p, perPage: a, page: _, locale: y, after: S, ordering: R, orderingDirection: I, wpApiBase: l }) => {
31
+ const q = `${l != null && l !== "" ? l : C.REACT_APP_WP_API}/wp/v2/${t}`, o = new URLSearchParams(), g = /* @__PURE__ */ new Map(), m = (s, i) => {
34
32
  if (!s || i == null) return;
35
- const c = P.get(s) || [];
36
- Array.isArray(i) ? i.forEach((y) => {
37
- y != null && c.push(String(y));
38
- }) : c.push(String(i)), P.set(s, c);
33
+ const c = g.get(s) || [];
34
+ Array.isArray(i) ? i.forEach((A) => {
35
+ A != null && c.push(String(A));
36
+ }) : c.push(String(i)), g.set(s, c);
39
37
  };
40
- o && o instanceof Map && o.forEach((s, i) => {
41
- A(i, s);
42
- }), t && n != null && A(t, n), P.forEach((s, i) => {
38
+ r && r instanceof Map && r.forEach((s, i) => {
39
+ m(i, s);
40
+ }), e && n != null && !g.has(e) && m(e, n), g.forEach((s, i) => {
43
41
  const c = Array.from(new Set(s));
44
- c.length !== 0 && r.set(i, c.join(","));
45
- }), f && r.append("before", f.toISOString()), a && r.append("per_page", a.toString()), r.append("page", _.toString()), r.append("locale", R), m && r.append("after", m.toISOString()), r.append("orderby", I), r.append("order", q);
46
- const w = r.toString().replace(/%2C/g, ",");
47
- return O(`${U}?${w}`, {
42
+ c.length !== 0 && o.set(i, c.join(","));
43
+ }), p && o.append("before", p.toISOString()), a && o.append("per_page", a.toString()), o.append("page", _.toString()), o.append("lang", y), S && o.append("after", S.toISOString()), o.append("orderby", R), o.append("order", I);
44
+ const w = o.toString().replace(/%2C/g, ",");
45
+ return O(`${q}?${w}`, {
48
46
  headers: {
49
47
  "Content-Type": "application/json"
50
48
  }