@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.
- package/dist/cjs/embeddable/filtered-posts/index.js +1 -1
- package/dist/cjs/embeddable/posts-filter/CategoricalFilter.js +1 -1
- package/dist/cjs/embeddable/posts-filter/YearFilter.js +1 -1
- package/dist/cjs/embeddable/posts-filter/index.js +1 -1
- package/dist/cjs/embeddable/posts-filters-reset-button/index.js +1 -1
- package/dist/cjs/embeddable/reducers/data-api.js +1 -1
- package/dist/cjs/embeddable/reducers/data.js +1 -1
- package/dist/esm/embeddable/filtered-posts/index.js +100 -99
- package/dist/esm/embeddable/posts-filter/CategoricalFilter.js +35 -36
- package/dist/esm/embeddable/posts-filter/YearFilter.js +17 -16
- package/dist/esm/embeddable/posts-filter/index.js +82 -79
- package/dist/esm/embeddable/posts-filters-reset-button/index.js +9 -8
- package/dist/esm/embeddable/reducers/data-api.js +36 -38
- package/dist/esm/embeddable/reducers/data.js +103 -100
- package/dist/types/embeddable/posts-filter/CategoricalFilter.d.ts +1 -0
- package/dist/types/embeddable/posts-filter/index.d.ts +6 -3
- package/dist/types/embeddable/posts-filters-reset-button/index.d.ts +4 -2
- package/package.json +1 -1
|
@@ -1,58 +1,59 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as h, useMemo as p, useEffect as
|
|
3
|
-
import { Container as
|
|
4
|
-
import { toBoolean as s, toNumber as
|
|
5
|
-
import { useAppDispatch as
|
|
6
|
-
import { useSelector as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
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":
|
|
12
|
-
"data-asc-order":
|
|
12
|
+
"data-alphabetical-sort": v,
|
|
13
|
+
"data-asc-order": D,
|
|
13
14
|
"data-group": c,
|
|
14
|
-
"data-placeholder":
|
|
15
|
-
"data-all-label":
|
|
15
|
+
"data-placeholder": C,
|
|
16
|
+
"data-all-label": T,
|
|
16
17
|
"data-none-label": b,
|
|
17
|
-
"data-use-single-column":
|
|
18
|
-
"data-enable-text-search":
|
|
18
|
+
"data-use-single-column": P,
|
|
19
|
+
"data-enable-text-search": z,
|
|
19
20
|
"data-filter-type": F,
|
|
20
|
-
"data-show-no-data-option":
|
|
21
|
-
"data-close-on-select":
|
|
22
|
-
"data-all-none-same-behaviour":
|
|
23
|
-
"data-auto-apply":
|
|
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":
|
|
27
|
-
"data-is-year-filter":
|
|
28
|
-
"data-type":
|
|
29
|
-
"data-sort-first-by":
|
|
30
|
-
"data-default-values":
|
|
31
|
-
"data-wordpress-source-type":
|
|
32
|
-
"data-wordpress-source":
|
|
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
|
-
} =
|
|
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(
|
|
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),
|
|
40
|
+
return console.warn("JSON parsing failed for value:", t, "- treating as plain string. Error:", o), V(t);
|
|
40
41
|
}
|
|
41
|
-
})(
|
|
42
|
+
})(q);
|
|
42
43
|
n || (n = []), typeof n == "string" && (n = n.split(",").map(Number)), typeof n == "number" && (n = [n]);
|
|
43
|
-
const
|
|
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
|
-
),
|
|
47
|
+
), te = p(
|
|
47
48
|
() => f(e.categoryFilter, l),
|
|
48
49
|
[e.categoryFilter, l]
|
|
49
|
-
),
|
|
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
|
-
),
|
|
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:
|
|
66
|
+
sortFirstBy: m,
|
|
66
67
|
countryCategory: i,
|
|
67
68
|
categoryTaxonomy: i,
|
|
68
69
|
countryTaxonomy: i
|
|
69
70
|
});
|
|
70
|
-
},
|
|
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:
|
|
79
|
+
isYearFilter: e.isYearFilter,
|
|
79
80
|
yearFilter: e.yearFilter,
|
|
80
|
-
isCountryFilter:
|
|
81
|
-
sortFirstBy: r ?
|
|
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
|
|
89
|
-
const t = n.length > 0, o = l ? n : n[0],
|
|
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:
|
|
94
|
-
countryFilter:
|
|
94
|
+
categoryFilter: le,
|
|
95
|
+
countryFilter: ne,
|
|
95
96
|
isYearFilter: a,
|
|
96
97
|
isCountryFilter: r,
|
|
97
|
-
sortFirstBy:
|
|
98
|
-
yearFilter: a ?
|
|
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
|
-
}, []),
|
|
106
|
-
if (a && !
|
|
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
|
-
}, [
|
|
117
|
-
a && /* @__PURE__ */
|
|
118
|
-
|
|
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:
|
|
122
|
-
allLabel:
|
|
122
|
+
placeholder: C,
|
|
123
|
+
allLabel: T,
|
|
123
124
|
noneLabel: b,
|
|
124
|
-
useSingleColumn:
|
|
125
|
-
enableTextSearch:
|
|
125
|
+
useSingleColumn: Y,
|
|
126
|
+
enableTextSearch: _,
|
|
126
127
|
filterType: F,
|
|
127
|
-
showNoDataOption:
|
|
128
|
+
showNoDataOption: I,
|
|
128
129
|
closeOnSelect: A,
|
|
129
130
|
allNoneSameBehaviour: B,
|
|
130
|
-
autoApply:
|
|
131
|
-
alphabeticalSort:
|
|
132
|
-
ascOrder:
|
|
131
|
+
autoApply: w,
|
|
132
|
+
alphabeticalSort: Q,
|
|
133
|
+
ascOrder: W,
|
|
133
134
|
options: y,
|
|
134
|
-
value:
|
|
135
|
+
value: re,
|
|
135
136
|
yearOptions: y,
|
|
136
|
-
setYearOptions:
|
|
137
|
-
yearFilterLoading:
|
|
138
|
-
setYearFilterLoading:
|
|
137
|
+
setYearOptions: X,
|
|
138
|
+
yearFilterLoading: g,
|
|
139
|
+
setYearFilterLoading: Z,
|
|
139
140
|
onChange: (t, o) => {
|
|
140
|
-
|
|
141
|
+
ae(o);
|
|
141
142
|
},
|
|
142
|
-
resetKey:
|
|
143
|
+
resetKey: N,
|
|
144
|
+
wpApiBase: O ?? void 0
|
|
143
145
|
}
|
|
144
146
|
),
|
|
145
|
-
!a && /* @__PURE__ */
|
|
146
|
-
|
|
147
|
+
!a && /* @__PURE__ */ E(
|
|
148
|
+
me,
|
|
147
149
|
{
|
|
148
150
|
group: c,
|
|
149
|
-
placeholder:
|
|
150
|
-
allLabel:
|
|
151
|
+
placeholder: C,
|
|
152
|
+
allLabel: T,
|
|
151
153
|
noneLabel: b,
|
|
152
|
-
useSingleColumn:
|
|
153
|
-
enableTextSearch:
|
|
154
|
+
useSingleColumn: Y,
|
|
155
|
+
enableTextSearch: _,
|
|
154
156
|
filterType: F,
|
|
155
|
-
showNoDataOption:
|
|
157
|
+
showNoDataOption: I,
|
|
156
158
|
closeOnSelect: A,
|
|
157
159
|
allNoneSameBehaviour: B,
|
|
158
|
-
autoApply:
|
|
160
|
+
autoApply: w,
|
|
159
161
|
taxonomy: i,
|
|
160
|
-
type:
|
|
161
|
-
value: r ?
|
|
162
|
+
type: k,
|
|
163
|
+
value: r ? ee : te,
|
|
162
164
|
onChange: (t, o) => {
|
|
163
|
-
|
|
165
|
+
oe(o);
|
|
164
166
|
},
|
|
165
167
|
categories: S,
|
|
166
|
-
resetKey:
|
|
167
|
-
wpApiBase:
|
|
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
|
-
|
|
177
|
+
Ee as default
|
|
175
178
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { jsxs as p, jsx as
|
|
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
|
|
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
|
-
|
|
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(),
|
|
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__ */
|
|
32
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
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
|
|
4
|
-
return JSON.parse(JSON.stringify(
|
|
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 : "",
|
|
7
|
-
function
|
|
8
|
-
return Object.keys(
|
|
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
|
|
11
|
-
const n =
|
|
12
|
-
if (
|
|
13
|
-
return Promise.resolve(
|
|
14
|
-
if (
|
|
15
|
-
return
|
|
16
|
-
const
|
|
17
|
-
delete
|
|
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
|
|
19
|
+
return h[n] = p, p;
|
|
20
20
|
}
|
|
21
|
-
const k = ({ app:
|
|
22
|
-
const n = `${u || T}/api/${
|
|
23
|
-
return
|
|
24
|
-
}, V = ({ app:
|
|
25
|
-
const
|
|
26
|
-
return
|
|
27
|
-
}, J = ({ source:
|
|
28
|
-
const
|
|
29
|
-
return
|
|
30
|
-
}, L = ({ postType:
|
|
31
|
-
const
|
|
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 =
|
|
36
|
-
Array.isArray(i) ? i.forEach((
|
|
37
|
-
|
|
38
|
-
}) : c.push(String(i)),
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
}),
|
|
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 &&
|
|
45
|
-
}),
|
|
46
|
-
const w =
|
|
47
|
-
return O(`${
|
|
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
|
}
|