@devgateway/dvz-ui-react 1.7.15 → 1.8.0

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