@devgateway/dvz-ui-react 1.5.3 → 1.6.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.
Files changed (70) hide show
  1. package/dist/cjs/common.css +1 -1
  2. package/dist/cjs/embeddable/chart/Bar.js +1 -1
  3. package/dist/cjs/embeddable/chart/Line.js +1 -1
  4. package/dist/cjs/embeddable/chart/Pie.js +1 -1
  5. package/dist/cjs/embeddable/chart/colors/ManualColors.js +1 -1
  6. package/dist/cjs/embeddable/chart/data/Bar.js +1 -1
  7. package/dist/cjs/embeddable/chart/index.js +1 -1
  8. package/dist/cjs/embeddable/common/colors/ManualColors.js +1 -1
  9. package/dist/cjs/embeddable/d3Map/BaseLayer.js +1 -1
  10. package/dist/cjs/embeddable/d3Map/DataLayer.js +1 -1
  11. package/dist/cjs/embeddable/filtered-posts/NoData.js +2 -2
  12. package/dist/cjs/embeddable/filtered-posts/index.js +1 -1
  13. package/dist/cjs/embeddable/filtered-posts/utils.js +1 -1
  14. package/dist/cjs/embeddable/posts-filter/CategoricalFilter.js +1 -0
  15. package/dist/cjs/embeddable/posts-filter/PostsFilterDropdown.js +1 -1
  16. package/dist/cjs/embeddable/posts-filter/YearFilter.js +1 -0
  17. package/dist/cjs/embeddable/posts-filter/index.js +1 -1
  18. package/dist/cjs/embeddable/posts-filters-reset-button/index.js +1 -1
  19. package/dist/cjs/embeddable/posts-pagination/index.js +1 -1
  20. package/dist/cjs/embeddable/reducers/data-api.js +1 -1
  21. package/dist/cjs/embeddable/reducers/data.js +1 -1
  22. package/dist/cjs/embeddable/reducers/embeddable-api.js +1 -1
  23. package/dist/cjs/embeddable/time-line/mobile.js +1 -1
  24. package/dist/cjs/embeddable/vertical-featuredtabs/index.js +2 -2
  25. package/dist/cjs/index.js +1 -1
  26. package/dist/cjs/layout/Layout.js +1 -1
  27. package/dist/cjs/styles.css +1 -1
  28. package/dist/esm/common.css +1 -1
  29. package/dist/esm/embeddable/chart/Bar.js +253 -235
  30. package/dist/esm/embeddable/chart/Line.js +122 -121
  31. package/dist/esm/embeddable/chart/Pie.js +82 -81
  32. package/dist/esm/embeddable/chart/colors/ManualColors.js +33 -33
  33. package/dist/esm/embeddable/chart/data/Bar.js +18 -16
  34. package/dist/esm/embeddable/chart/index.js +298 -286
  35. package/dist/esm/embeddable/common/colors/ManualColors.js +22 -22
  36. package/dist/esm/embeddable/d3Map/BaseLayer.js +4 -1
  37. package/dist/esm/embeddable/d3Map/DataLayer.js +5 -1
  38. package/dist/esm/embeddable/filtered-posts/NoData.js +25 -18
  39. package/dist/esm/embeddable/filtered-posts/index.js +131 -89
  40. package/dist/esm/embeddable/filtered-posts/utils.js +3 -2
  41. package/dist/esm/embeddable/posts-filter/CategoricalFilter.js +72 -0
  42. package/dist/esm/embeddable/posts-filter/PostsFilterDropdown.js +106 -92
  43. package/dist/esm/embeddable/posts-filter/YearFilter.js +60 -0
  44. package/dist/esm/embeddable/posts-filter/index.js +160 -191
  45. package/dist/esm/embeddable/posts-filters-reset-button/index.js +21 -15
  46. package/dist/esm/embeddable/posts-pagination/index.js +36 -33
  47. package/dist/esm/embeddable/reducers/data-api.js +35 -35
  48. package/dist/esm/embeddable/reducers/data.js +116 -107
  49. package/dist/esm/embeddable/reducers/embeddable-api.js +8 -8
  50. package/dist/esm/embeddable/time-line/mobile.js +119 -118
  51. package/dist/esm/embeddable/vertical-featuredtabs/index.js +202 -131
  52. package/dist/esm/index.js +66 -64
  53. package/dist/esm/layout/Layout.js +8 -6
  54. package/dist/esm/styles.css +1 -1
  55. package/dist/types/dvz-ui/src/embeddable/chart/colors/ManualColors.d.ts +1 -1
  56. package/dist/types/dvz-ui/src/embeddable/filtered-posts/NoData.d.ts +1 -0
  57. package/dist/types/dvz-ui/src/embeddable/filtered-posts/index.d.ts +2 -1
  58. package/dist/types/dvz-ui/src/embeddable/filtered-posts/utils.d.ts +3 -0
  59. package/dist/types/dvz-ui/src/embeddable/posts-filter/CategoricalFilter.d.ts +9 -0
  60. package/dist/types/dvz-ui/src/embeddable/posts-filter/PostsFilterDropdown.d.ts +1 -0
  61. package/dist/types/dvz-ui/src/embeddable/posts-filter/YearFilter.d.ts +12 -0
  62. package/dist/types/dvz-ui/src/embeddable/posts-filter/index.d.ts +2 -0
  63. package/dist/types/dvz-ui/src/embeddable/reducers/data-api.d.ts +3 -1
  64. package/dist/types/dvz-ui/src/embeddable/reducers/data.d.ts +5 -0
  65. package/dist/types/dvz-ui/src/embeddable/time-line/mobile.d.ts +2 -1
  66. package/dist/types/dvz-ui/src/translations/af.json.d.ts +1 -2
  67. package/dist/types/dvz-ui/src/translations/am.json.d.ts +35 -35
  68. package/dist/types/dvz-ui/src/translations/index.d.ts +2 -1
  69. package/dist/types/dvz-ui/src/utils/data.d.ts +2 -0
  70. package/package.json +4 -3
@@ -1,215 +1,184 @@
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) => {
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) => {
11
10
  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;
11
+ "data-alphabetical-sort": G,
12
+ "data-asc-order": H,
13
+ "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) => {
34
+ 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);
33
38
  }
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({
39
+ })(le);
40
+ 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({
104
67
  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
68
+ 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
115
79
  });
116
- }, Z = (r) => {
117
- t ? P(r) : E(r), g({
80
+ }, pe = (e) => {
81
+ a ? M(e) : J(e), h({
118
82
  type: "SET_POSTS_FILTER",
119
- group: l,
83
+ group: c,
84
+ ...t,
120
85
  // 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
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
131
96
  });
132
97
  };
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({
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({
136
101
  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
102
+ 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,
113
+ page: 1
147
114
  });
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,
115
+ }, []), V(() => {
116
+ if (l && !T) {
117
+ const e = l && o ? u.length > 0 ? u.map((r) => r.value) : [] : t.yearFilter;
118
+ h({
119
+ type: "SET_INITIAL_POSTS_FILTER",
120
+ group: c,
121
+ ...t,
122
+ isYearFilter: l,
123
+ yearFilter: l ? e : null
124
+ });
125
+ }
126
+ }, [T]), /* @__PURE__ */ de(me, { fluid: !0, className: "filter post-filter", children: [
127
+ l && /* @__PURE__ */ U(
128
+ Te,
162
129
  {
163
- group: l,
164
- placeholder: S,
165
- allLabel: h,
166
- noneLabel: f,
167
- useSingleColumn: k,
168
- enableTextSearch: $,
169
- filterType: F,
170
- showNoDataOption: D,
130
+ group: c,
131
+ placeholder: A,
132
+ allLabel: Y,
133
+ noneLabel: I,
134
+ useSingleColumn: P,
135
+ enableTextSearch: v,
136
+ filterType: S,
137
+ showNoDataOption: L,
171
138
  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);
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);
182
151
  },
183
- resetKey: s.current
152
+ resetKey: B.current
184
153
  }
185
154
  ),
186
- !y && /* @__PURE__ */ L(
187
- ye,
155
+ !l && /* @__PURE__ */ U(
156
+ Ce,
188
157
  {
189
- group: l,
190
- placeholder: S,
191
- allLabel: h,
192
- noneLabel: f,
193
- useSingleColumn: k,
194
- enableTextSearch: $,
195
- filterType: F,
196
- showNoDataOption: D,
158
+ group: c,
159
+ placeholder: A,
160
+ allLabel: Y,
161
+ noneLabel: I,
162
+ useSingleColumn: P,
163
+ enableTextSearch: v,
164
+ filterType: S,
165
+ showNoDataOption: L,
197
166
  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);
167
+ allNoneSameBehaviour: w,
168
+ autoApply: D,
169
+ taxonomy: s,
170
+ type: oe,
171
+ value: a ? K : j,
172
+ onChange: (e, r) => {
173
+ pe(r);
205
174
  },
206
- categories: i ? i.split(",") : [],
207
- resetKey: s.current
175
+ categories: y ? y.split(",") : [],
176
+ resetKey: B.current
208
177
  },
209
- `cat-${l}`
178
+ `cat-${c}`
210
179
  )
211
180
  ] });
212
181
  };
213
182
  export {
214
- Ce as default
183
+ Ee as default
215
184
  };
@@ -1,33 +1,39 @@
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";
1
+ import { jsxs as p, jsx as a } from "react/jsx-runtime";
2
+ import d from "react";
3
+ import { useDispatch as u, useSelector as n } 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 S = (l) => {
6
+ const R = (i) => {
7
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(
8
+ "data-group": s,
9
+ "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
+ return /* @__PURE__ */ p(
12
12
  m,
13
13
  {
14
14
  fluid: !0,
15
- className: `data-filters-reset ignore ${o ? "" : "disabled"}`,
15
+ style: {
16
+ pointerEvents: e ? "auto" : "none",
17
+ cursor: e ? "pointer" : "not-allowed",
18
+ opacity: e ? 1 : 0.5
19
+ },
20
+ className: `data-filters-reset ignore ${e ? "" : "disabled"}`,
16
21
  onClick: () => {
17
22
  c({
18
23
  type: "SET_INITIAL_POSTS_FILTER",
19
- group: t,
20
- ...e,
21
- reset: !0
24
+ group: s,
25
+ ...t,
26
+ reset: !0,
27
+ page: 1
22
28
  });
23
29
  },
24
30
  children: [
25
- /* @__PURE__ */ a("span", { children: n }),
26
- /* @__PURE__ */ a("span", { children: /* @__PURE__ */ a(f, { disabled: !o, name: "undo alternate", className: "custom-undo-icon" }) })
31
+ /* @__PURE__ */ a("span", { children: l }),
32
+ /* @__PURE__ */ a("span", { children: /* @__PURE__ */ a(f, { disabled: !e, name: "undo alternate", className: "custom-undo-icon" }) })
27
33
  ]
28
34
  }
29
35
  );
30
36
  };
31
37
  export {
32
- S as default
38
+ R as default
33
39
  };
@@ -1,69 +1,72 @@
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) => {
1
+ import { jsxs as i, jsx as r } from "react/jsx-runtime";
2
+ import I, { useState as g, useEffect as u } from "react";
3
+ import { useDispatch as x, useSelector as m } from "react-redux";
4
+ import { Container as y, Dropdown as b, Icon as p } from "semantic-ui-react";
5
+ import { injectIntl as j } from "react-intl";
6
+ const k = (f) => {
7
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({
8
+ "data-group": c
9
+ } = f, h = x(), n = m((e) => e.getIn(["data", "postsPagination", c])), t = m((e) => e.getIn(["data", "posts", c])), s = n && (n != null && n.totalPages) ? n.totalPages : 1, [o, d] = g((t == null ? void 0 : t.page) ?? 1), [P, v] = g([]), C = () => {
10
+ const e = [];
11
+ for (let a = 1; a <= s; a++)
12
+ e.push({ key: a, text: a, value: a });
13
+ v(e);
14
+ }, l = (e) => {
15
+ e !== o && (e < 1 || e > s || (d(e), h({
16
16
  type: "SET_POSTS_FILTER",
17
- group: l,
18
- ...e,
19
- page: t
17
+ group: c,
18
+ ...t,
19
+ page: e
20
20
  })));
21
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: [
22
+ return u(() => {
23
+ C();
24
+ }, [n == null ? void 0 : n.totalPages]), u(() => {
25
+ const e = (t == null ? void 0 : t.page) ?? 1;
26
+ e !== o && d(e);
27
+ }, [t == null ? void 0 : t.page]), /* @__PURE__ */ i(y, { fluid: !0, className: "posts-pagination", children: [
28
+ /* @__PURE__ */ i("div", { className: "posts-pagination-dropdown", children: [
26
29
  /* @__PURE__ */ r("span", { children: "Page" }),
27
30
  /* @__PURE__ */ r(
28
- y,
31
+ b,
29
32
  {
30
- options: m,
33
+ options: P,
31
34
  placeholder: "Select Item",
32
35
  selection: !0,
33
36
  compact: !0,
34
37
  value: o,
35
- onChange: (t, n) => i(Number(n.value))
38
+ onChange: (e, a) => l(Number(a.value))
36
39
  }
37
40
  ),
38
- /* @__PURE__ */ r("div", { children: /* @__PURE__ */ a("span", { children: [
41
+ /* @__PURE__ */ r("div", { children: /* @__PURE__ */ i("span", { children: [
39
42
  "of ",
40
- e && (e == null ? void 0 : e.totalPages)
43
+ n && (n == null ? void 0 : n.totalPages)
41
44
  ] }) })
42
45
  ] }),
43
- /* @__PURE__ */ a("div", { children: [
46
+ /* @__PURE__ */ i("div", { children: [
44
47
  /* @__PURE__ */ r(
45
- d,
48
+ p,
46
49
  {
47
50
  size: "large",
48
51
  style: { cursor: "pointer" },
49
- onClick: () => i(o - 1),
52
+ onClick: () => l(o - 1),
50
53
  name: "angle left",
51
54
  disabled: o === 1
52
55
  }
53
56
  ),
54
57
  /* @__PURE__ */ r(
55
- d,
58
+ p,
56
59
  {
57
60
  size: "large",
58
61
  style: { cursor: "pointer" },
59
- onClick: () => i(o + 1),
62
+ onClick: () => l(o + 1),
60
63
  name: "angle right",
61
64
  disabled: o === s
62
65
  }
63
66
  )
64
67
  ] })
65
68
  ] });
66
- }, w = b(P.memo(j));
69
+ }, z = j(I.memo(k));
67
70
  export {
68
- w as default
71
+ z as default
69
72
  };
@@ -1,48 +1,48 @@
1
- import { Config as S } from "../../conf/index.js";
2
- import { get as y } from "../../api/commons.js";
3
- function p(n) {
1
+ import { Config as A } from "../../conf/index.js";
2
+ import { get as h } from "../../api/commons.js";
3
+ function f(n) {
4
4
  return JSON.parse(JSON.stringify(n));
5
5
  }
6
- const g = process.env.VITE_REACT_APP_API_ROOT || S.REACT_APP_API_ROOT || null, A = typeof window < "u" ? window.location.origin : null, l = {}, f = {}, C = 3 * 60 * 1e3;
7
- function O(n) {
6
+ const d = process.env.VITE_REACT_APP_API_ROOT || A.REACT_APP_API_ROOT || null, O = typeof window < "u" ? window.location.origin : "", l = {}, u = {}, q = 3 * 60 * 1e3;
7
+ function _(n) {
8
8
  return Object.keys(n).map((t) => encodeURIComponent(t) + "=" + encodeURIComponent(n[t])).join("&");
9
9
  }
10
- function _(n, t = !1) {
11
- const e = n, r = Date.now();
12
- if (f[e] && r - f[e].timestamp < C)
13
- return Promise.resolve(p(f[e].data));
10
+ function w(n, t = !1) {
11
+ const e = n, i = Date.now();
12
+ if (u[e] && i - u[e].timestamp < q)
13
+ return Promise.resolve(f(u[e].data));
14
14
  if (l[e])
15
- return l[e].then(p);
16
- const c = y(n, {}).then((a) => (f[e] = { data: a, timestamp: Date.now() }, t ? { data: p(a), meta: f[e].meta } : p(a))).finally(() => {
15
+ return l[e].then(f);
16
+ const p = h(n, {}).then((a) => (u[e] = { data: a, timestamp: Date.now() }, t ? { data: f(a), meta: u[e].meta } : f(a))).finally(() => {
17
17
  delete l[e];
18
18
  });
19
- return l[e] = c, c;
19
+ return l[e] = p, p;
20
20
  }
21
- const E = ({ app: n, params: t }) => {
22
- const e = `${g || A}/api/${n}/categories${t ? "?" + O(t) : ""}`;
23
- return _(e);
24
- }, U = ({ source: n, app: t, params: e }) => {
25
- const r = `${g || A}/api/${t}/stats/${n}${e ? "?" + O(e) : ""}`;
26
- return _(r);
27
- }, D = ({ postType: n, taxonomy: t, category: e, taxonomyFilters: r, before: c, perPage: a, page: h, locale: w, after: m }) => {
28
- const R = `${S.REACT_APP_WP_API}/wp/v2/${n}`, i = new URLSearchParams(), d = /* @__PURE__ */ new Map(), T = (s, o) => {
21
+ const D = ({ app: n, params: t }) => {
22
+ const e = `${d || O}/api/${n}/categories${t ? "?" + _(t) : ""}`;
23
+ return w(e);
24
+ }, b = ({ source: n, app: t, params: e }) => {
25
+ const i = `${d || O}/api/${t}/stats/${n}${e ? "?" + _(e) : ""}`;
26
+ return w(i);
27
+ }, j = ({ postType: n, taxonomy: t, category: e, taxonomyFilters: i, before: p, perPage: a, page: R, locale: T, after: m, ordering: $, orderingDirection: y }) => {
28
+ const C = `${A.REACT_APP_WP_API}/wp/v2/${n}`, r = new URLSearchParams(), g = /* @__PURE__ */ new Map(), P = (s, o) => {
29
29
  if (!s || o == null) return;
30
- const u = d.get(s) || [];
31
- Array.isArray(o) ? o.forEach((P) => {
32
- P != null && u.push(String(P));
33
- }) : u.push(String(o)), d.set(s, u);
30
+ const c = g.get(s) || [];
31
+ Array.isArray(o) ? o.forEach((S) => {
32
+ S != null && c.push(String(S));
33
+ }) : c.push(String(o)), g.set(s, c);
34
34
  };
35
- r && r instanceof Map && r.forEach((s, o) => {
36
- T(o, s);
37
- }), d.forEach((s, o) => {
38
- const u = Array.from(new Set(s));
39
- i.set(o, u.join(","));
40
- }), c && i.append("before", c.toISOString()), a && i.append("per_page", a.toString()), i.append("page", h.toString()), i.append("locale", w), m && i.append("after", m.toISOString());
41
- const $ = i.toString().replace(/%2C/g, ",");
42
- return y(`${R}?${$}`, {});
35
+ i && i instanceof Map && i.forEach((s, o) => {
36
+ P(o, s);
37
+ }), t && e != null && P(t, e), g.forEach((s, o) => {
38
+ const c = Array.from(new Set(s));
39
+ c.length !== 0 && r.set(o, c.join(","));
40
+ }), p && r.append("before", p.toISOString()), a && r.append("per_page", a.toString()), r.append("page", R.toString()), r.append("locale", T), m && r.append("after", m.toISOString()), r.append("orderby", $), r.append("order", y);
41
+ const I = r.toString().replace(/%2C/g, ",");
42
+ return h(`${C}?${I}`, {});
43
43
  };
44
44
  export {
45
- E as getCategories,
46
- D as getCustomPosts,
47
- U as getData
45
+ D as getCategories,
46
+ j as getCustomPosts,
47
+ b as getData
48
48
  };