@devgateway/dvz-ui-react 1.4.0 → 1.5.1
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/common.css +1 -1
- package/dist/cjs/embeddable/big-number-trend/index.js +1 -1
- package/dist/cjs/embeddable/body/index.js +1 -1
- package/dist/cjs/embeddable/chart/Bar.js +1 -1
- package/dist/cjs/embeddable/chart/Line.js +1 -1
- package/dist/cjs/embeddable/chart/colors/ColorProvider.js +1 -1
- package/dist/cjs/embeddable/chart/colors/ManualColors.js +1 -1
- package/dist/cjs/embeddable/chart/colors/SystemColors.js +1 -1
- package/dist/cjs/embeddable/chart/data/Bar.js +1 -1
- package/dist/cjs/embeddable/chart/data/Line.js +1 -1
- package/dist/cjs/embeddable/chart/data/Utils.js +1 -1
- package/dist/cjs/embeddable/d3Map/BaseLayer.js +1 -1
- package/dist/cjs/embeddable/d3Map/DataLayer.js +1 -1
- package/dist/cjs/embeddable/d3Map/FlowLayer.js +1 -1
- package/dist/cjs/embeddable/data/DataContext.js +1 -1
- package/dist/cjs/embeddable/featuredtabs/index.js +1 -1
- package/dist/cjs/embeddable/filter/index.js +1 -1
- package/dist/cjs/embeddable/filtered-posts/NoData.js +11 -0
- package/dist/cjs/embeddable/filtered-posts/index.js +1 -0
- package/dist/cjs/embeddable/index.js +1 -1
- package/dist/cjs/embeddable/inlinelist/index.js +1 -1
- package/dist/cjs/embeddable/map/MapDataFrame.js +1 -1
- package/dist/cjs/embeddable/map/index.js +2 -2
- package/dist/cjs/embeddable/map/map.js +4 -4
- package/dist/cjs/embeddable/posts-filter/PostsFilterDropdown.js +1 -0
- package/dist/cjs/embeddable/posts-filter/index.js +1 -0
- package/dist/cjs/embeddable/posts-filters-reset-button/index.js +1 -0
- package/dist/cjs/embeddable/posts-pagination/index.js +1 -0
- package/dist/cjs/embeddable/reducers/data-api.js +1 -1
- package/dist/cjs/embeddable/reducers/data.js +1 -1
- package/dist/cjs/embeddable/showcase/index.js +1 -1
- package/dist/cjs/embeddable/time-line/mobile.js +1 -1
- package/dist/cjs/embeddable/vertical-featuredtabs/index.js +2 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/layout/ClassicHeader.js +1 -1
- package/dist/cjs/layout/CustomSemanticSearch.js +1 -1
- package/dist/cjs/layout/Header.js +3 -3
- package/dist/cjs/layout/Layout.js +1 -1
- package/dist/cjs/layout/SearchControl.js +1 -1
- package/dist/cjs/styles.css +1 -1
- package/dist/cjs/translations/am.json.js +1 -0
- package/dist/cjs/utils/data.js +1 -1
- package/dist/esm/common.css +1 -1
- package/dist/esm/embeddable/big-number-trend/index.js +36 -36
- package/dist/esm/embeddable/body/index.js +141 -95
- package/dist/esm/embeddable/chart/Bar.js +390 -382
- package/dist/esm/embeddable/chart/Line.js +101 -102
- package/dist/esm/embeddable/chart/colors/ColorProvider.js +42 -39
- package/dist/esm/embeddable/chart/colors/ManualColors.js +40 -29
- package/dist/esm/embeddable/chart/colors/SystemColors.js +28 -17
- package/dist/esm/embeddable/chart/data/Bar.js +112 -114
- package/dist/esm/embeddable/chart/data/Line.js +126 -126
- package/dist/esm/embeddable/chart/data/Utils.js +32 -26
- package/dist/esm/embeddable/d3Map/BaseLayer.js +3 -8
- package/dist/esm/embeddable/d3Map/DataLayer.js +2 -9
- package/dist/esm/embeddable/d3Map/FlowLayer.js +12 -15
- package/dist/esm/embeddable/data/DataContext.js +1 -0
- package/dist/esm/embeddable/featuredtabs/index.js +128 -124
- package/dist/esm/embeddable/filter/index.js +207 -206
- package/dist/esm/embeddable/filtered-posts/NoData.js +31 -0
- package/dist/esm/embeddable/filtered-posts/index.js +123 -0
- package/dist/esm/embeddable/index.js +34 -31
- package/dist/esm/embeddable/inlinelist/index.js +82 -70
- package/dist/esm/embeddable/map/MapDataFrame.js +17 -14
- package/dist/esm/embeddable/map/index.js +180 -169
- package/dist/esm/embeddable/map/map.js +520 -437
- package/dist/esm/embeddable/posts-filter/PostsFilterDropdown.js +190 -0
- package/dist/esm/embeddable/posts-filter/index.js +215 -0
- package/dist/esm/embeddable/posts-filters-reset-button/index.js +33 -0
- package/dist/esm/embeddable/posts-pagination/index.js +69 -0
- package/dist/esm/embeddable/reducers/data-api.js +40 -25
- package/dist/esm/embeddable/reducers/data.js +180 -99
- package/dist/esm/embeddable/showcase/index.js +1 -1
- package/dist/esm/embeddable/time-line/mobile.js +158 -182
- package/dist/esm/embeddable/vertical-featuredtabs/index.js +177 -168
- package/dist/esm/index.js +69 -25
- package/dist/esm/layout/ClassicHeader.js +62 -62
- package/dist/esm/layout/CustomSemanticSearch.js +40 -102
- package/dist/esm/layout/Header.js +152 -144
- package/dist/esm/layout/Layout.js +4 -3
- package/dist/esm/layout/SearchControl.js +130 -113
- package/dist/esm/styles.css +1 -1
- package/dist/esm/translations/am.json.js +46 -0
- package/dist/esm/utils/data.js +4 -9
- package/dist/types/dvz-ui/src/countries.d.ts +7 -0
- package/dist/types/dvz-ui/src/embeddable/chart/colors/ManualColors.d.ts +1 -1
- package/dist/types/dvz-ui/src/embeddable/chart/colors/SystemColors.d.ts +1 -1
- package/dist/types/dvz-ui/src/embeddable/data/DataContext.d.ts +1 -0
- package/dist/types/dvz-ui/src/embeddable/featuredtabs/index.d.ts +1 -0
- package/dist/types/dvz-ui/src/embeddable/filtered-posts/NoData.d.ts +7 -0
- package/dist/types/dvz-ui/src/embeddable/filtered-posts/index.d.ts +21 -0
- package/dist/types/dvz-ui/src/embeddable/inlinelist/index.d.ts +2 -0
- package/dist/types/dvz-ui/src/embeddable/map/MapDataFrame.d.ts +1 -6
- package/dist/types/dvz-ui/src/embeddable/map/map.d.ts +1 -0
- package/dist/types/dvz-ui/src/embeddable/posts-filter/PostsFilterDropdown.d.ts +21 -0
- package/dist/types/dvz-ui/src/embeddable/posts-filter/index.d.ts +25 -0
- package/dist/types/dvz-ui/src/embeddable/posts-filters-reset-button/index.d.ts +3 -0
- package/dist/types/dvz-ui/src/embeddable/posts-pagination/index.d.ts +10 -0
- package/dist/types/dvz-ui/src/embeddable/reducers/data-api.d.ts +11 -0
- package/dist/types/dvz-ui/src/embeddable/reducers/post-reducer.d.ts +158 -0
- package/dist/types/dvz-ui/src/embeddable/time-line/mobile.d.ts +1 -2
- package/dist/types/dvz-ui/src/embeddable/vertical-featuredtabs/index.d.ts +1 -0
- package/dist/types/dvz-ui/src/index.d.ts +3 -0
- package/dist/types/dvz-ui/src/layout/Header.d.ts +2 -2
- package/dist/types/dvz-ui/src/translations/am.json.d.ts +39 -0
- package/package.json +7 -5
- package/dist/cjs/embeddable/posts-with-filters/DropDownFilter.js +0 -1
- package/dist/cjs/embeddable/posts-with-filters/Post.js +0 -1
- package/dist/cjs/embeddable/posts-with-filters/index.js +0 -1
- package/dist/esm/embeddable/posts-with-filters/DropDownFilter.js +0 -25
- package/dist/esm/embeddable/posts-with-filters/Post.js +0 -51
- package/dist/esm/embeddable/posts-with-filters/index.js +0 -206
- package/dist/types/dvz-ui/src/embeddable/posts-with-filters/DropDownFilter.d.ts +0 -4
- package/dist/types/dvz-ui/src/embeddable/posts-with-filters/Post.d.ts +0 -5
- package/dist/types/dvz-ui/src/embeddable/posts-with-filters/index.d.ts +0 -21
- /package/dist/cjs/{utils/countries.js → countries.js} +0 -0
- /package/dist/cjs/embeddable/{posts-with-filters → filtered-posts}/utils.js +0 -0
- /package/dist/esm/{utils/countries.js → countries.js} +0 -0
- /package/dist/esm/embeddable/{posts-with-filters → filtered-posts}/utils.js +0 -0
- /package/dist/types/dvz-ui/src/embeddable/{posts-with-filters → filtered-posts}/utils.d.ts +0 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { jsx as l, jsxs as m, Fragment as F } from "react/jsx-runtime";
|
|
2
|
+
import { useState as U, useRef as L, useEffect as P } from "react";
|
|
3
|
+
import { Dropdown as h, Segment as Y, Label as R, Container as O, Icon as q, Divider as z, Radio as H, Checkbox as J } from "semantic-ui-react";
|
|
4
|
+
const T = "multi-select", g = "single-select", Z = (b) => {
|
|
5
|
+
const {
|
|
6
|
+
allLabel: D,
|
|
7
|
+
noneLabel: M,
|
|
8
|
+
placeholder: w,
|
|
9
|
+
options: r,
|
|
10
|
+
// group,
|
|
11
|
+
current: C,
|
|
12
|
+
onChange: i,
|
|
13
|
+
useSingleColumn: y,
|
|
14
|
+
enableTextSearch: p,
|
|
15
|
+
filterType: o,
|
|
16
|
+
// defaultValues,
|
|
17
|
+
// showNoDataOption,
|
|
18
|
+
// defaultValueCriteria,
|
|
19
|
+
allNoneSameBehaviour: N,
|
|
20
|
+
hiddenFilters: f,
|
|
21
|
+
// autoApply,
|
|
22
|
+
// taxonomy,
|
|
23
|
+
// type,
|
|
24
|
+
value: a,
|
|
25
|
+
closeOnSelect: v = !0
|
|
26
|
+
} = b, u = o === T, s = Array.isArray(a) ? a : C || [], [c, V] = U(""), A = (e, t) => {
|
|
27
|
+
if (o === T) {
|
|
28
|
+
let n = Array.isArray(s) ? [...s] : [];
|
|
29
|
+
return n.indexOf(t) > -1 ? n = n.filter((I) => I !== t) : n = [...n, t], i && i(e, n);
|
|
30
|
+
}
|
|
31
|
+
if (o === g)
|
|
32
|
+
return i && i(e, t);
|
|
33
|
+
v && d.current && d.current.close();
|
|
34
|
+
}, $ = () => {
|
|
35
|
+
const e = (r || []).filter((t) => {
|
|
36
|
+
var n;
|
|
37
|
+
return p && c && c.trim().length > 0 && t.text ? (n = t.text) == null ? void 0 : n.toString().toLowerCase().includes(c.toLowerCase()) : !0;
|
|
38
|
+
}).map((t) => t.value);
|
|
39
|
+
u && i && i({}, e), !u && v && d.current && d.current.close();
|
|
40
|
+
}, K = () => {
|
|
41
|
+
let e = [];
|
|
42
|
+
N && (e = (r || []).filter((t) => {
|
|
43
|
+
var n;
|
|
44
|
+
return p && c && c.trim().length > 0 && t.text ? (n = t.text) == null ? void 0 : n.toString().toLowerCase().includes(c.toLowerCase()) : !0;
|
|
45
|
+
}).map((t) => t.value)), u && i && i({}, e), !u && v && d.current && d.current.close();
|
|
46
|
+
}, _ = (e) => {
|
|
47
|
+
V(e);
|
|
48
|
+
}, E = L(!1);
|
|
49
|
+
P(() => {
|
|
50
|
+
if (!(!u || E.current) && r && r.length > 0)
|
|
51
|
+
if (!(Array.isArray(s) ? s.length > 0 : !!s) && i) {
|
|
52
|
+
E.current = !0;
|
|
53
|
+
const t = r.map((n) => n.value);
|
|
54
|
+
i({}, t);
|
|
55
|
+
} else
|
|
56
|
+
E.current = !0;
|
|
57
|
+
}, [u, r]), P(() => {
|
|
58
|
+
if (u && r && r.length > 0 && i) {
|
|
59
|
+
const e = r.map((t) => t.value);
|
|
60
|
+
i({}, e);
|
|
61
|
+
}
|
|
62
|
+
}, []);
|
|
63
|
+
const j = () => {
|
|
64
|
+
if (o == g) {
|
|
65
|
+
const e = a ? r == null ? void 0 : r.filter((t) => t.value == a)[0] : null;
|
|
66
|
+
return e ? e.text : "";
|
|
67
|
+
} else {
|
|
68
|
+
const e = s ? s.filter((n) => n == Number.MIN_SAFE_INTEGER ? !1 : f && f.length > 0 ? f.indexOf(n) == -1 : !0).length : 0, t = (r == null ? void 0 : r.filter((n) => f && f.length > 0 ? f.indexOf(n.id) == -1 : !0).length) || 0;
|
|
69
|
+
return `${w} (${e}/${t})`;
|
|
70
|
+
}
|
|
71
|
+
}, d = L(null), k = j(), x = typeof k == "string" ? k : "", B = x && x.length > 0 ? x : w || "", S = L(void 0);
|
|
72
|
+
P(() => {
|
|
73
|
+
o === g && S.current === void 0 && a !== void 0 && (S.current = a);
|
|
74
|
+
}, [o, a]);
|
|
75
|
+
const G = o === g ? a != null && a !== S.current : C && C.length > 0;
|
|
76
|
+
return (
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
/* @__PURE__ */ l(
|
|
79
|
+
h,
|
|
80
|
+
{
|
|
81
|
+
...b,
|
|
82
|
+
ref: d,
|
|
83
|
+
fluid: !0,
|
|
84
|
+
text: B,
|
|
85
|
+
scrolling: !1,
|
|
86
|
+
button: !0,
|
|
87
|
+
icon: "angle down",
|
|
88
|
+
multiple: u,
|
|
89
|
+
search: !0,
|
|
90
|
+
floating: !1,
|
|
91
|
+
value: a,
|
|
92
|
+
closeOnChange: v,
|
|
93
|
+
...u ? { renderLabel: () => null } : {},
|
|
94
|
+
className: `multiple ${G ? "applied " : ""}`,
|
|
95
|
+
children: /* @__PURE__ */ m(h.Menu, { children: [
|
|
96
|
+
o != g && /* @__PURE__ */ m(F, { children: [
|
|
97
|
+
/* @__PURE__ */ l(Y, { children: /* @__PURE__ */ m(h.Item, { children: [
|
|
98
|
+
/* @__PURE__ */ l(R, { basic: !0, onClick: $, children: D }),
|
|
99
|
+
" ",
|
|
100
|
+
"|",
|
|
101
|
+
" ",
|
|
102
|
+
/* @__PURE__ */ l(R, { basic: !0, onClick: K, children: M })
|
|
103
|
+
] }) }),
|
|
104
|
+
p && /* @__PURE__ */ m(F, { children: [
|
|
105
|
+
/* @__PURE__ */ l(O, { children: /* @__PURE__ */ l(h.Item, { children: /* @__PURE__ */ l("div", { className: "ui action input", children: /* @__PURE__ */ m("div", { className: "ui input", children: [
|
|
106
|
+
/* @__PURE__ */ l(
|
|
107
|
+
"input",
|
|
108
|
+
{
|
|
109
|
+
className: "filter-search",
|
|
110
|
+
value: c,
|
|
111
|
+
placeholder: "Search...",
|
|
112
|
+
onChange: (e) => {
|
|
113
|
+
e && e.nativeEvent && e.nativeEvent.stopImmediatePropagation && e.nativeEvent.stopImmediatePropagation(), _(e.target.value);
|
|
114
|
+
},
|
|
115
|
+
onKeyDown: (e) => {
|
|
116
|
+
e && e.nativeEvent && e.nativeEvent.stopImmediatePropagation && e.nativeEvent.stopImmediatePropagation();
|
|
117
|
+
},
|
|
118
|
+
onKeyUp: (e) => {
|
|
119
|
+
e && e.nativeEvent && e.nativeEvent.stopImmediatePropagation && e.nativeEvent.stopImmediatePropagation();
|
|
120
|
+
},
|
|
121
|
+
onKeyPress: (e) => {
|
|
122
|
+
e && e.nativeEvent && e.nativeEvent.stopImmediatePropagation && e.nativeEvent.stopImmediatePropagation();
|
|
123
|
+
},
|
|
124
|
+
onMouseDown: (e) => {
|
|
125
|
+
e.stopPropagation();
|
|
126
|
+
},
|
|
127
|
+
onClick: (e) => {
|
|
128
|
+
e.stopPropagation();
|
|
129
|
+
},
|
|
130
|
+
onFocus: (e) => {
|
|
131
|
+
e.stopPropagation();
|
|
132
|
+
},
|
|
133
|
+
type: "text",
|
|
134
|
+
autoComplete: "off"
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
/* @__PURE__ */ l(
|
|
138
|
+
q,
|
|
139
|
+
{
|
|
140
|
+
name: "remove",
|
|
141
|
+
link: !0,
|
|
142
|
+
className: "clear-icon ignore",
|
|
143
|
+
onClick: (e) => {
|
|
144
|
+
_("");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
] }) }) }) }),
|
|
149
|
+
/* @__PURE__ */ l(z, {})
|
|
150
|
+
] })
|
|
151
|
+
] }),
|
|
152
|
+
/* @__PURE__ */ l("br", {}),
|
|
153
|
+
/* @__PURE__ */ l(O, { className: y ? "dropdown-single-column" : "", children: r == null ? void 0 : r.filter((e) => {
|
|
154
|
+
var t;
|
|
155
|
+
return p && c && c.trim().length > 0 && e.text ? (t = e.text) == null ? void 0 : t.toString().toLowerCase().includes(c.toLowerCase()) : !0;
|
|
156
|
+
}).map(({ value: e, text: t }, n) => /* @__PURE__ */ m(
|
|
157
|
+
h.Item,
|
|
158
|
+
{
|
|
159
|
+
className: y ? "dropdown-item-single-column" : "",
|
|
160
|
+
children: [
|
|
161
|
+
o === g && /* @__PURE__ */ l(
|
|
162
|
+
H,
|
|
163
|
+
{
|
|
164
|
+
checked: a === e,
|
|
165
|
+
onChange: (I) => {
|
|
166
|
+
A(I, e);
|
|
167
|
+
},
|
|
168
|
+
label: t
|
|
169
|
+
}
|
|
170
|
+
),
|
|
171
|
+
o === T && /* @__PURE__ */ l(
|
|
172
|
+
J,
|
|
173
|
+
{
|
|
174
|
+
checked: !!(s && s.indexOf(e) > -1 && !(r.length == s.length && N)),
|
|
175
|
+
onChange: () => A(null, e),
|
|
176
|
+
label: t
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
]
|
|
180
|
+
},
|
|
181
|
+
n
|
|
182
|
+
)) })
|
|
183
|
+
] })
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
);
|
|
187
|
+
};
|
|
188
|
+
export {
|
|
189
|
+
Z as default
|
|
190
|
+
};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { jsxs as re, jsx as L } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as oe, useState as d, useEffect as x } from "react";
|
|
3
|
+
import { Container as ae } from "semantic-ui-react";
|
|
4
|
+
import { toNumber as le, toBoolean as n } from "../../utils/data.js";
|
|
5
|
+
import { getYearRange as ne } from "@devgateway/wp-react-lib";
|
|
6
|
+
import q from "./PostsFilterDropdown.js";
|
|
7
|
+
import { Config as ie } from "../../conf/index.js";
|
|
8
|
+
import { useAppDispatch as se } from "../../redux/hooks.js";
|
|
9
|
+
import { useSelector as ce } from "react-redux";
|
|
10
|
+
const ye = (m) => {
|
|
11
|
+
const {
|
|
12
|
+
taxonomy: p,
|
|
13
|
+
group: O,
|
|
14
|
+
placeholder: l,
|
|
15
|
+
allLabel: S,
|
|
16
|
+
noneLabel: h,
|
|
17
|
+
useSingleColumn: f,
|
|
18
|
+
enableTextSearch: b,
|
|
19
|
+
filterType: A,
|
|
20
|
+
showNoDataOption: F,
|
|
21
|
+
closeOnSelect: N,
|
|
22
|
+
allNoneSameBehaviour: v,
|
|
23
|
+
autoApply: B,
|
|
24
|
+
alphabeticalSort: Y,
|
|
25
|
+
ascOrder: o,
|
|
26
|
+
type: i,
|
|
27
|
+
categories: C,
|
|
28
|
+
onChange: _
|
|
29
|
+
} = m, [T, c] = d([]), g = async () => {
|
|
30
|
+
if (!p || p === "none") {
|
|
31
|
+
c([]);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const e = await (await fetch(ie.REACT_APP_WP_API + "/wp/v2/" + p)).json();
|
|
35
|
+
if (e) {
|
|
36
|
+
const a = e.map((s) => ({
|
|
37
|
+
key: s.id,
|
|
38
|
+
value: s.id,
|
|
39
|
+
text: s.name
|
|
40
|
+
}));
|
|
41
|
+
if (C) {
|
|
42
|
+
const s = a.filter((w) => C.indexOf(w.value.toString()) > -1);
|
|
43
|
+
c(s);
|
|
44
|
+
} else
|
|
45
|
+
c(a);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return x(() => (g(), () => {
|
|
49
|
+
c([]);
|
|
50
|
+
}), [i]), /* @__PURE__ */ L(
|
|
51
|
+
q,
|
|
52
|
+
{
|
|
53
|
+
...m,
|
|
54
|
+
group: O,
|
|
55
|
+
placeholder: l,
|
|
56
|
+
allLabel: S,
|
|
57
|
+
noneLabel: h,
|
|
58
|
+
useSingleColumn: f,
|
|
59
|
+
enableTextSearch: b,
|
|
60
|
+
filterType: A,
|
|
61
|
+
showNoDataOption: F,
|
|
62
|
+
closeOnSelect: N,
|
|
63
|
+
allNoneSameBehaviour: v,
|
|
64
|
+
autoApply: B,
|
|
65
|
+
alphabeticalSort: Y,
|
|
66
|
+
ascOrder: o,
|
|
67
|
+
options: T,
|
|
68
|
+
onChange: _
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
}, Ce = (m) => {
|
|
72
|
+
const {
|
|
73
|
+
"data-alphabetical-sort": p,
|
|
74
|
+
"data-asc-order": O,
|
|
75
|
+
"data-group": l,
|
|
76
|
+
"data-placeholder": S,
|
|
77
|
+
"data-all-label": h,
|
|
78
|
+
"data-none-label": f,
|
|
79
|
+
"data-use-single-column": b,
|
|
80
|
+
"data-enable-text-search": A,
|
|
81
|
+
"data-filter-type": F,
|
|
82
|
+
"data-show-no-data-option": N,
|
|
83
|
+
"data-close-on-select": v,
|
|
84
|
+
"data-all-none-same-behaviour": B,
|
|
85
|
+
"data-auto-apply": Y,
|
|
86
|
+
"data-taxonomy": o,
|
|
87
|
+
"data-categories": i,
|
|
88
|
+
"data-is-country-filter": C,
|
|
89
|
+
"data-is-year-filter": _,
|
|
90
|
+
"data-type": T,
|
|
91
|
+
"data-sort-first-by": c
|
|
92
|
+
} = m, g = se(), e = ce((r) => r.getIn(["data", "posts", l])) || {}, a = F === "multi-select", s = oe(0), w = n(p), G = n(O), D = n(N), R = n(v), j = n(B), K = n(Y), t = n(C), y = n(_), k = n(b), $ = n(A), V = c !== "none" ? le(c) : null, [H, J] = d([]), [Q, U] = d(
|
|
93
|
+
a ? Array.isArray(e.yearFilter) ? e.yearFilter : e.yearFilter != null ? [e.yearFilter] : [] : e.yearFilter || void 0
|
|
94
|
+
), [M, P] = d(
|
|
95
|
+
a ? Array.isArray(e.countryFilter) ? e.countryFilter : e.countryFilter != null ? [e.countryFilter] : [] : e.countryFilter || void 0
|
|
96
|
+
), [W, E] = d(
|
|
97
|
+
a ? Array.isArray(e.categoryFilter) ? e.categoryFilter : e.categoryFilter != null ? [e.categoryFilter] : [] : e.categoryFilter || void 0
|
|
98
|
+
);
|
|
99
|
+
x(() => {
|
|
100
|
+
U(e.yearFilter || void 0), a ? (P(Array.isArray(e.countryFilter) ? e.countryFilter : e.countryFilter != null ? [e.countryFilter] : []), E(Array.isArray(e.categoryFilter) ? e.categoryFilter : e.categoryFilter != null ? [e.categoryFilter] : [])) : (P(e.countryFilter || void 0), E(e.categoryFilter || void 0));
|
|
101
|
+
}, [e, a]);
|
|
102
|
+
const X = (r) => {
|
|
103
|
+
g({
|
|
104
|
+
type: "SET_POSTS_FILTER",
|
|
105
|
+
group: l,
|
|
106
|
+
isYearFilter: y,
|
|
107
|
+
yearFilter: r,
|
|
108
|
+
isCountryFilter: t,
|
|
109
|
+
categoryFilter: e.categoryFilter,
|
|
110
|
+
countryFilter: e.countryFilter,
|
|
111
|
+
sortFirstBy: V,
|
|
112
|
+
countryCategory: o,
|
|
113
|
+
categoryTaxonomy: o,
|
|
114
|
+
countryTaxonomy: o
|
|
115
|
+
});
|
|
116
|
+
}, Z = (r) => {
|
|
117
|
+
t ? P(r) : E(r), g({
|
|
118
|
+
type: "SET_POSTS_FILTER",
|
|
119
|
+
group: l,
|
|
120
|
+
// Preserve both filters so they can work together
|
|
121
|
+
categoryFilter: t ? e.categoryFilter : r,
|
|
122
|
+
countryFilter: t ? r : e.countryFilter,
|
|
123
|
+
yearFilter: e.yearFilter,
|
|
124
|
+
isYearFilter: y,
|
|
125
|
+
isCountryFilter: t,
|
|
126
|
+
sortFirstBy: t ? V : e.sortFirstBy,
|
|
127
|
+
countryCategory: t ? o : e.countryCategory,
|
|
128
|
+
categoryCategory: t ? e.categoryCategory : r,
|
|
129
|
+
categoryTaxonomy: t ? e.categoryTaxonomy : o,
|
|
130
|
+
countryTaxonomy: t ? o : e.countryTaxonomy
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
x(() => {
|
|
134
|
+
const r = t ? e.categoryFilter : a ? i ? i.split(",").map(Number) : [] : e.categoryFilter, u = t && a ? i ? i.split(",").map(Number) : [] : e.countryFilter;
|
|
135
|
+
g({
|
|
136
|
+
type: "SET_INITIAL_POSTS_FILTER",
|
|
137
|
+
group: l,
|
|
138
|
+
categoryFilter: r,
|
|
139
|
+
countryFilter: u,
|
|
140
|
+
isYearFilter: y,
|
|
141
|
+
isCountryFilter: t,
|
|
142
|
+
sortFirstBy: V,
|
|
143
|
+
categoryCategory: t ? null : e.categoryCategory,
|
|
144
|
+
categoryTaxonomy: t ? null : o,
|
|
145
|
+
countryCategory: t ? e.countryCategory : null,
|
|
146
|
+
countryTaxonomy: t ? o : null
|
|
147
|
+
});
|
|
148
|
+
}, [l]), x(() => {
|
|
149
|
+
y && ee();
|
|
150
|
+
}, [y]);
|
|
151
|
+
const ee = async () => {
|
|
152
|
+
const te = (await ne()).data.map((I) => ({
|
|
153
|
+
key: I,
|
|
154
|
+
value: I,
|
|
155
|
+
text: `Year ${I}`
|
|
156
|
+
}));
|
|
157
|
+
J(te || []);
|
|
158
|
+
};
|
|
159
|
+
return /* @__PURE__ */ re(ae, { fluid: !0, className: "filter", children: [
|
|
160
|
+
y && /* @__PURE__ */ L(
|
|
161
|
+
q,
|
|
162
|
+
{
|
|
163
|
+
group: l,
|
|
164
|
+
placeholder: S,
|
|
165
|
+
allLabel: h,
|
|
166
|
+
noneLabel: f,
|
|
167
|
+
useSingleColumn: k,
|
|
168
|
+
enableTextSearch: $,
|
|
169
|
+
filterType: F,
|
|
170
|
+
showNoDataOption: D,
|
|
171
|
+
closeOnSelect: R,
|
|
172
|
+
allNoneSameBehaviour: j,
|
|
173
|
+
autoApply: K,
|
|
174
|
+
alphabeticalSort: w,
|
|
175
|
+
ascOrder: G,
|
|
176
|
+
options: H,
|
|
177
|
+
taxonomy: o,
|
|
178
|
+
type: T,
|
|
179
|
+
value: Q,
|
|
180
|
+
onChange: (r, u) => {
|
|
181
|
+
X(u);
|
|
182
|
+
},
|
|
183
|
+
resetKey: s.current
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
!y && /* @__PURE__ */ L(
|
|
187
|
+
ye,
|
|
188
|
+
{
|
|
189
|
+
group: l,
|
|
190
|
+
placeholder: S,
|
|
191
|
+
allLabel: h,
|
|
192
|
+
noneLabel: f,
|
|
193
|
+
useSingleColumn: k,
|
|
194
|
+
enableTextSearch: $,
|
|
195
|
+
filterType: F,
|
|
196
|
+
showNoDataOption: D,
|
|
197
|
+
closeOnSelect: R,
|
|
198
|
+
allNoneSameBehaviour: j,
|
|
199
|
+
autoApply: K,
|
|
200
|
+
taxonomy: o,
|
|
201
|
+
type: T,
|
|
202
|
+
value: t ? M : W,
|
|
203
|
+
onChange: (r, u) => {
|
|
204
|
+
Z(u);
|
|
205
|
+
},
|
|
206
|
+
categories: i ? i.split(",") : [],
|
|
207
|
+
resetKey: s.current
|
|
208
|
+
},
|
|
209
|
+
`cat-${l}`
|
|
210
|
+
)
|
|
211
|
+
] });
|
|
212
|
+
};
|
|
213
|
+
export {
|
|
214
|
+
Ce as default
|
|
215
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsxs as d, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import p from "react";
|
|
3
|
+
import { useDispatch as u, useSelector as i } from "react-redux";
|
|
4
|
+
import { Container as m, Icon as f } from "semantic-ui-react";
|
|
5
|
+
import I from "lodash.isequal";
|
|
6
|
+
const S = (l) => {
|
|
7
|
+
const {
|
|
8
|
+
"data-group": t,
|
|
9
|
+
"data-reset-label": n = "Reset All Filters"
|
|
10
|
+
} = l, c = u(), s = i((r) => r.getIn(["data", "posts", t])), e = i((r) => r.getIn(["data", "posts", "initialFilters", t])), o = p.useMemo(() => s && e ? !I(s, e) : !1, [s, e]);
|
|
11
|
+
return /* @__PURE__ */ d(
|
|
12
|
+
m,
|
|
13
|
+
{
|
|
14
|
+
fluid: !0,
|
|
15
|
+
className: `data-filters-reset ignore ${o ? "" : "disabled"}`,
|
|
16
|
+
onClick: () => {
|
|
17
|
+
c({
|
|
18
|
+
type: "SET_INITIAL_POSTS_FILTER",
|
|
19
|
+
group: t,
|
|
20
|
+
...e,
|
|
21
|
+
reset: !0
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
children: [
|
|
25
|
+
/* @__PURE__ */ a("span", { children: n }),
|
|
26
|
+
/* @__PURE__ */ a("span", { children: /* @__PURE__ */ a(f, { disabled: !o, name: "undo alternate", className: "custom-undo-icon" }) })
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
S as default
|
|
33
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsxs as a, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import P, { useState as c, useEffect as v } from "react";
|
|
3
|
+
import { useDispatch as C, useSelector as x } from "react-redux";
|
|
4
|
+
import { Container as I, Dropdown as y, Icon as d } from "semantic-ui-react";
|
|
5
|
+
import { injectIntl as b } from "react-intl";
|
|
6
|
+
const j = (u) => {
|
|
7
|
+
const {
|
|
8
|
+
"data-group": l
|
|
9
|
+
} = u, p = C(), e = x((t) => t.getIn(["data", "postsPagination", l])), s = e && (e != null && e.totalPages) ? e.totalPages : 1, [o, g] = c(1), [m, f] = c([]), h = () => {
|
|
10
|
+
const t = [];
|
|
11
|
+
for (let n = 1; n <= s; n++)
|
|
12
|
+
t.push({ key: n, text: n, value: n });
|
|
13
|
+
f(t);
|
|
14
|
+
}, i = (t) => {
|
|
15
|
+
t !== o && (t < 1 || t > s || (g(t), p({
|
|
16
|
+
type: "SET_POSTS_FILTER",
|
|
17
|
+
group: l,
|
|
18
|
+
...e,
|
|
19
|
+
page: t
|
|
20
|
+
})));
|
|
21
|
+
};
|
|
22
|
+
return v(() => {
|
|
23
|
+
h();
|
|
24
|
+
}, [e == null ? void 0 : e.totalPages]), /* @__PURE__ */ a(I, { fluid: !0, className: "posts-pagination", children: [
|
|
25
|
+
/* @__PURE__ */ a("div", { className: "posts-pagination-dropdown", children: [
|
|
26
|
+
/* @__PURE__ */ r("span", { children: "Page" }),
|
|
27
|
+
/* @__PURE__ */ r(
|
|
28
|
+
y,
|
|
29
|
+
{
|
|
30
|
+
options: m,
|
|
31
|
+
placeholder: "Select Item",
|
|
32
|
+
selection: !0,
|
|
33
|
+
compact: !0,
|
|
34
|
+
value: o,
|
|
35
|
+
onChange: (t, n) => i(Number(n.value))
|
|
36
|
+
}
|
|
37
|
+
),
|
|
38
|
+
/* @__PURE__ */ r("div", { children: /* @__PURE__ */ a("span", { children: [
|
|
39
|
+
"of ",
|
|
40
|
+
e && (e == null ? void 0 : e.totalPages)
|
|
41
|
+
] }) })
|
|
42
|
+
] }),
|
|
43
|
+
/* @__PURE__ */ a("div", { children: [
|
|
44
|
+
/* @__PURE__ */ r(
|
|
45
|
+
d,
|
|
46
|
+
{
|
|
47
|
+
size: "large",
|
|
48
|
+
style: { cursor: "pointer" },
|
|
49
|
+
onClick: () => i(o - 1),
|
|
50
|
+
name: "angle left",
|
|
51
|
+
disabled: o === 1
|
|
52
|
+
}
|
|
53
|
+
),
|
|
54
|
+
/* @__PURE__ */ r(
|
|
55
|
+
d,
|
|
56
|
+
{
|
|
57
|
+
size: "large",
|
|
58
|
+
style: { cursor: "pointer" },
|
|
59
|
+
onClick: () => i(o + 1),
|
|
60
|
+
name: "angle right",
|
|
61
|
+
disabled: o === s
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
] })
|
|
65
|
+
] });
|
|
66
|
+
}, w = b(P.memo(j));
|
|
67
|
+
export {
|
|
68
|
+
w as default
|
|
69
|
+
};
|
|
@@ -1,33 +1,48 @@
|
|
|
1
|
-
import "../../conf/index.js";
|
|
2
|
-
import { get as
|
|
3
|
-
function
|
|
1
|
+
import { Config as T } from "../../conf/index.js";
|
|
2
|
+
import { get as y } from "../../api/commons.js";
|
|
3
|
+
function f(t) {
|
|
4
4
|
return JSON.parse(JSON.stringify(t));
|
|
5
5
|
}
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function a(t) {
|
|
10
|
-
return Object.keys(t).map((e) => encodeURIComponent(e) + "=" + encodeURIComponent(t[e])).join("&");
|
|
6
|
+
const l = process.env.VITE_REACT_APP_API_ROOT, g = {}, p = {}, _ = 3 * 60 * 1e3;
|
|
7
|
+
function P(t) {
|
|
8
|
+
return Object.keys(t).map((n) => encodeURIComponent(n) + "=" + encodeURIComponent(t[n])).join("&");
|
|
11
9
|
}
|
|
12
|
-
function
|
|
13
|
-
const e = t,
|
|
14
|
-
if (
|
|
15
|
-
return Promise.resolve(
|
|
16
|
-
if (
|
|
17
|
-
return
|
|
18
|
-
const
|
|
19
|
-
delete
|
|
10
|
+
function h(t, n = !1) {
|
|
11
|
+
const e = t, o = Date.now();
|
|
12
|
+
if (p[e] && o - p[e].timestamp < _)
|
|
13
|
+
return Promise.resolve(f(p[e].data));
|
|
14
|
+
if (g[e])
|
|
15
|
+
return g[e].then(f);
|
|
16
|
+
const c = y(t, {}).then((a) => (p[e] = { data: a, timestamp: Date.now() }, n ? { data: f(a), meta: p[e].meta } : f(a))).finally(() => {
|
|
17
|
+
delete g[e];
|
|
20
18
|
});
|
|
21
|
-
return
|
|
19
|
+
return g[e] = c, c;
|
|
22
20
|
}
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
return
|
|
26
|
-
},
|
|
27
|
-
const
|
|
28
|
-
return
|
|
21
|
+
const w = ({ app: t, params: n }) => {
|
|
22
|
+
const e = `${l || ""}/api/${t}/categories${n ? "?" + P(n) : ""}`;
|
|
23
|
+
return h(e);
|
|
24
|
+
}, E = ({ source: t, app: n, params: e }) => {
|
|
25
|
+
const o = `${l || ""}/api/${n}/stats/${t}${e ? "?" + P(e) : ""}`;
|
|
26
|
+
return h(o);
|
|
27
|
+
}, U = ({ postType: t, taxonomy: n, category: e, taxonomyFilters: o, before: c, perPage: a, page: $, locale: A, after: d }) => {
|
|
28
|
+
const O = `${T.REACT_APP_WP_API}/wp/v2/${t}`, i = new URLSearchParams(), m = /* @__PURE__ */ new Map(), C = (s, r) => {
|
|
29
|
+
if (!s || r == null) return;
|
|
30
|
+
const u = m.get(s) || [];
|
|
31
|
+
Array.isArray(r) ? r.forEach((S) => {
|
|
32
|
+
S != null && u.push(String(S));
|
|
33
|
+
}) : u.push(String(r)), m.set(s, u);
|
|
34
|
+
};
|
|
35
|
+
o && o instanceof Map && o.forEach((s, r) => {
|
|
36
|
+
C(r, s);
|
|
37
|
+
}), m.forEach((s, r) => {
|
|
38
|
+
const u = Array.from(new Set(s));
|
|
39
|
+
i.set(r, u.join(","));
|
|
40
|
+
}), c && i.append("before", c.toISOString()), a && i.append("per_page", a.toString()), i.append("page", $.toString()), i.append("locale", A), d && i.append("after", d.toISOString());
|
|
41
|
+
const R = i.toString().replace(/%2C/g, ",");
|
|
42
|
+
return y(`${O}?${R}`, {});
|
|
29
43
|
};
|
|
30
44
|
export {
|
|
31
|
-
|
|
32
|
-
|
|
45
|
+
w as getCategories,
|
|
46
|
+
U as getCustomPosts,
|
|
47
|
+
E as getData
|
|
33
48
|
};
|