@devgateway/dvz-ui-react 1.1.1 → 1.2.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.
Files changed (34) hide show
  1. package/dist/cjs/embeddable/big-number/index.js +1 -1
  2. package/dist/cjs/embeddable/chart/Bar.js +1 -1
  3. package/dist/cjs/embeddable/chart/index.js +1 -1
  4. package/dist/cjs/embeddable/d3Map/BaseLayer.js +1 -1
  5. package/dist/cjs/embeddable/d3Map/DataLayer.js +1 -1
  6. package/dist/cjs/embeddable/d3Map/FlowLayer.js +1 -1
  7. package/dist/cjs/embeddable/d3Map/ZoomControl.js +1 -1
  8. package/dist/cjs/embeddable/d3Map/index.js +1 -1
  9. package/dist/cjs/embeddable/posts-with-filters/DropDownFilter.js +1 -0
  10. package/dist/cjs/embeddable/posts-with-filters/Post.js +1 -1
  11. package/dist/cjs/embeddable/posts-with-filters/index.js +1 -1
  12. package/dist/cjs/embeddable/reducers/data-api.js +1 -1
  13. package/dist/cjs/layout/containers/SlugPostContainer.js +1 -1
  14. package/dist/cjs/styles.css +1 -1
  15. package/dist/esm/embeddable/big-number/index.js +92 -85
  16. package/dist/esm/embeddable/chart/Bar.js +128 -123
  17. package/dist/esm/embeddable/chart/index.js +229 -225
  18. package/dist/esm/embeddable/d3Map/BaseLayer.js +40 -27
  19. package/dist/esm/embeddable/d3Map/DataLayer.js +196 -204
  20. package/dist/esm/embeddable/d3Map/FlowLayer.js +104 -101
  21. package/dist/esm/embeddable/d3Map/ZoomControl.js +64 -54
  22. package/dist/esm/embeddable/d3Map/index.js +110 -99
  23. package/dist/esm/embeddable/posts-with-filters/DropDownFilter.js +25 -0
  24. package/dist/esm/embeddable/posts-with-filters/Post.js +49 -24
  25. package/dist/esm/embeddable/posts-with-filters/index.js +120 -119
  26. package/dist/esm/embeddable/reducers/data-api.js +13 -11
  27. package/dist/esm/layout/containers/SlugPostContainer.js +3 -3
  28. package/dist/esm/styles.css +1 -1
  29. package/dist/types/embeddable/chart/Bar.d.ts +2 -0
  30. package/dist/types/embeddable/d3Map/BaseLayer.d.ts +1 -0
  31. package/dist/types/embeddable/d3Map/ZoomControl.d.ts +2 -1
  32. package/dist/types/embeddable/posts-with-filters/DropDownFilter.d.ts +4 -0
  33. package/dist/types/embeddable/posts-with-filters/Post.d.ts +4 -2
  34. package/package.json +4 -2
@@ -1,27 +1,28 @@
1
- import { jsxs as m, jsx as t } from "react/jsx-runtime";
2
- import { useState as A, useEffect as T } from "react";
3
- import { CategoriesProvider as $, CategoriesContext as H, PostProvider as J, PostConsumer as U, getYearRange as q } from "@devgateway/wp-react-lib";
4
- import { Container as R, Dropdown as b, Icon as k, Pagination as z } from "semantic-ui-react";
5
- import G from "./Post.js";
6
- import { getStartDateAndEndDateFromYear as K } from "./utils.js";
7
- import { toBoolean as x, toNumber as B } from "../../utils/data.js";
8
- const L = (C) => {
9
- const { posts: a, meta: n, showPaginationOptions: f, currentPage: c, setCurrentPage: w, countryCategory: P, height: r } = C, u = B(P), F = Array.isArray(a) ? a.filter((o) => o.categories.includes(u)) : [], d = Array.isArray(a) ? a.filter((o) => !o.categories.includes(u)) : [], s = [...F, ...d], h = n && n["x-wp-totalpages"] ? n["x-wp-totalpages"] : 1;
10
- return /* @__PURE__ */ m("div", { children: [
11
- /* @__PURE__ */ t("div", { className: "posts-grid", children: s == null ? void 0 : s.map((o) => /* @__PURE__ */ t(G, { post: o }, o.id)) }),
12
- f && /* @__PURE__ */ m("div", { className: "pagination-section", children: [
13
- /* @__PURE__ */ m("div", { className: "pagination-info", children: [
1
+ import { jsxs as w, jsx as t } from "react/jsx-runtime";
2
+ import { useState as C, useEffect as $ } from "react";
3
+ import { CategoriesProvider as H, CategoriesContext as J, PostProvider as U, PostConsumer as q, getYearRange as z } from "@devgateway/wp-react-lib";
4
+ import { Container as j, Icon as k, Pagination as G } from "semantic-ui-react";
5
+ import L from "./Post.js";
6
+ import { getStartDateAndEndDateFromYear as M } from "./utils.js";
7
+ import { toNumber as B, toBoolean as Y } from "../../utils/data.js";
8
+ import b from "./DropDownFilter.js";
9
+ const Q = (P) => {
10
+ const { posts: a, meta: i, showPaginationOptions: F, currentPage: h, setCurrentPage: S, countryCategory: v, height: s } = P, g = B(v), x = Array.isArray(a) ? a.filter((o) => o.categories.includes(g)) : [], u = Array.isArray(a) ? a.filter((o) => !o.categories.includes(g)) : [], n = [...x, ...u], l = i && i["x-wp-totalpages"] ? i["x-wp-totalpages"] : 1;
11
+ return /* @__PURE__ */ w("div", { children: [
12
+ /* @__PURE__ */ t("div", { className: "posts-grid", children: n == null ? void 0 : n.map((o) => /* @__PURE__ */ t(L, { post: o }, o.id)) }),
13
+ F && /* @__PURE__ */ w("div", { className: "pagination-section", children: [
14
+ /* @__PURE__ */ w("div", { className: "pagination-info", children: [
14
15
  "Page ",
15
- /* @__PURE__ */ t("span", { className: "current-page", children: c }),
16
+ /* @__PURE__ */ t("span", { className: "current-page", children: h }),
16
17
  " of ",
17
- h
18
+ l
18
19
  ] }),
19
20
  /* @__PURE__ */ t(
20
- z,
21
+ G,
21
22
  {
22
- activePage: c,
23
- totalPages: h,
24
- onPageChange: (o, { activePage: l }) => w(l),
23
+ activePage: h,
24
+ totalPages: l,
25
+ onPageChange: (o, { activePage: c }) => S(c),
25
26
  prevItem: { content: /* @__PURE__ */ t(k, { name: "angle left" }), icon: !0 },
26
27
  nextItem: { content: /* @__PURE__ */ t(k, { name: "angle right" }), icon: !0 },
27
28
  firstItem: null,
@@ -30,63 +31,63 @@ const L = (C) => {
30
31
  )
31
32
  ] })
32
33
  ] });
33
- }, M = (C) => {
34
+ }, X = (P) => {
34
35
  const {
35
36
  categories: a,
36
- selectedCategory: n,
37
- setSelectedCategory: f,
38
- selectedYear: c,
39
- setSelectedYear: w,
40
- onResetFilters: P,
41
- showCategoryFilter: r,
42
- categoryPlaceholder: u,
43
- showDateFilter: F,
44
- categoriesToBeShown: d,
45
- setCurrentPage: s,
46
- showCountryFilter: h,
37
+ selectedCategory: i,
38
+ setSelectedCategory: F,
39
+ selectedYear: h,
40
+ setSelectedYear: S,
41
+ onResetFilters: v,
42
+ showCategoryFilter: s,
43
+ categoryPlaceholder: g,
44
+ showDateFilter: x,
45
+ categoriesToBeShown: u,
46
+ setCurrentPage: n,
47
+ showCountryFilter: l,
47
48
  countryPlaceholder: o,
48
- countryCategory: l,
49
- selectedCountry: v,
50
- setSelectedCountry: Y
51
- } = C, [D, I] = A([]);
52
- T(() => {
49
+ countryCategory: c,
50
+ selectedCountry: N,
51
+ setSelectedCountry: p
52
+ } = P, [D, V] = C([]);
53
+ $(() => {
53
54
  const e = async () => {
54
- const V = (await q()).data.map((N) => ({
55
- key: N,
56
- value: N,
57
- text: `Year ${N}`
55
+ const O = (await z()).data.map((A) => ({
56
+ key: A,
57
+ value: A,
58
+ text: `Year ${A}`
58
59
  }));
59
- I(V);
60
+ V(O);
60
61
  };
61
62
  return e(), () => {
62
63
  e();
63
64
  };
64
65
  }, []);
65
- const S = a && d ? a.filter((e) => d.includes(e.id)) : [], O = a && l ? a.filter((e) => e.parent === parseInt(l)) : [];
66
- return /* @__PURE__ */ t("div", { className: "filters-section", children: /* @__PURE__ */ m("div", { className: "filter-controls", children: [
67
- h && /* @__PURE__ */ t(
66
+ const m = a && u ? a.filter((e) => u.includes(e.id)) : [], I = a && c ? a.filter((e) => e.parent === parseInt(c)) : [];
67
+ return /* @__PURE__ */ t("div", { children: /* @__PURE__ */ w("div", { children: [
68
+ l && /* @__PURE__ */ t(
68
69
  b,
69
70
  {
70
- options: O.map((e) => ({
71
+ options: I.map((e) => ({
71
72
  key: e.id,
72
73
  value: e.id,
73
74
  text: e.name
74
75
  })),
75
76
  placeholder: o,
76
- value: v,
77
- onChange: (e, { value: i }) => {
78
- Y(i), s(1);
77
+ value: N,
78
+ onChange: (e, { value: r }) => {
79
+ p(r), n(1);
79
80
  }
80
81
  }
81
82
  ),
82
- F && /* @__PURE__ */ t(
83
+ x && /* @__PURE__ */ t(
83
84
  b,
84
85
  {
85
86
  options: D,
86
87
  placeholder: "Select Year",
87
- value: c || "",
88
- onChange: (e, { value: i }) => {
89
- w(i), s(1);
88
+ value: h,
89
+ onChange: (e, { value: r }) => {
90
+ S(r), n(1);
90
91
  },
91
92
  multiple: !1,
92
93
  searchable: !0,
@@ -94,31 +95,30 @@ const L = (C) => {
94
95
  closeOnSelect: !0
95
96
  }
96
97
  ),
97
- r && /* @__PURE__ */ t(
98
+ s && /* @__PURE__ */ t(
98
99
  b,
99
100
  {
100
- options: S ? S.map((e) => ({
101
+ options: m ? m.map((e) => ({
101
102
  key: e.id,
102
103
  value: e.id,
103
104
  text: e.name
104
105
  })) : [],
105
- placeholder: u || "All Countries",
106
- value: n,
107
- onChange: (e, { value: i }) => {
108
- f(i), s(1);
106
+ placeholder: g || "All Countries",
107
+ value: i,
108
+ onChange: (e, { value: r }) => {
109
+ F(r), n(1);
109
110
  },
110
111
  multiple: !1,
111
112
  searchable: !1,
112
113
  showAllNone: !1,
113
- closeOnSelect: !0,
114
- className: "category-filter"
114
+ closeOnSelect: !0
115
115
  }
116
116
  ),
117
- /* @__PURE__ */ m(
118
- R,
117
+ /* @__PURE__ */ w(
118
+ j,
119
119
  {
120
- className: `data-filters-reset ignore ${n || c || v ? "" : "disabled"}`,
121
- onClick: P,
120
+ className: `data-filters-reset ignore ${i || h || N ? "" : "disabled"}`,
121
+ onClick: v,
122
122
  children: [
123
123
  /* @__PURE__ */ t("span", { children: "Reset Filters" }),
124
124
  /* @__PURE__ */ t("span", { children: /* @__PURE__ */ t(k, { name: "undo alternate", className: "custom-undo-icon" }) })
@@ -126,80 +126,81 @@ const L = (C) => {
126
126
  }
127
127
  )
128
128
  ] }) });
129
- }, ae = (C) => {
129
+ }, ne = (P) => {
130
130
  const {
131
131
  "data-height": a,
132
- "data-show-pagination": n,
133
- "data-show-posts-per-page": f,
134
- "data-show-filters": c,
135
- "data-show-date-filter": w,
136
- "data-show-category-filter": P,
137
- "data-categories": r,
138
- "data-category-placeholder": u,
139
- "data-show-country-filter": F,
140
- "data-country-category": d,
141
- "data-country-placeholder": s
142
- } = C, [h, o] = A(null), [l, v] = A(null), [Y, D] = A(null), [I, S] = A(1), O = B(a), e = x(n), i = B(f), j = x(c), V = x(w), N = x(P), W = x(F), E = () => {
143
- o(null), v(null), D(null);
144
- }, g = l ? K(l) : null;
145
- let p = [];
132
+ "data-show-pagination": i,
133
+ "data-show-posts-per-page": F,
134
+ "data-show-filters": h,
135
+ "data-show-date-filter": S,
136
+ "data-show-category-filter": v,
137
+ "data-categories": s,
138
+ "data-category-placeholder": g,
139
+ "data-show-country-filter": x,
140
+ "data-country-category": u,
141
+ "data-country-placeholder": n
142
+ } = P, [l, o] = C(null), [c, N] = C(null), [p, D] = C(null), [V, m] = C(1), [I, e] = C(0), r = B(a), R = Y(i), O = B(F), A = Y(h), W = Y(S), E = Y(v), K = Y(x), T = () => {
143
+ o(null), N(null), D(null), m(1), e((d) => d + 1);
144
+ }, y = c ? M(c) : null;
145
+ let f = [];
146
146
  try {
147
- if (r)
148
- if (Array.isArray(r))
149
- p = r;
150
- else if (typeof r == "string") {
151
- const y = decodeURIComponent(r);
152
- y && y !== "undefined" && (p = JSON.parse(y));
147
+ if (s)
148
+ if (Array.isArray(s))
149
+ f = s;
150
+ else if (typeof s == "string") {
151
+ const d = decodeURIComponent(s);
152
+ d && d !== "undefined" && (f = JSON.parse(d));
153
153
  } else
154
- p = r;
154
+ f = s;
155
155
  } catch {
156
- p = [];
156
+ f = [];
157
157
  }
158
- return /* @__PURE__ */ m(R, { fluid: !0, style: { height: "100%", minHeight: O + "px" }, children: [
159
- j && /* @__PURE__ */ t($, { children: /* @__PURE__ */ t(H.Consumer, { children: ({ categories: y }) => /* @__PURE__ */ t(
160
- M,
158
+ return console.log(r, "heightValue"), /* @__PURE__ */ w(j, { fluid: !0, className: "container", style: { height: r + "px", minHeight: r + "px" }, children: [
159
+ A && /* @__PURE__ */ t(H, { children: /* @__PURE__ */ t(J.Consumer, { children: ({ categories: d }) => /* @__PURE__ */ t(
160
+ X,
161
161
  {
162
- showCategoryFilter: N,
163
- categoryPlaceholder: u,
164
- showDateFilter: V,
165
- categories: y || [],
166
- categoriesToBeShown: p,
167
- selectedCategory: h,
162
+ showCategoryFilter: E,
163
+ categoryPlaceholder: g,
164
+ showDateFilter: W,
165
+ categories: d || [],
166
+ categoriesToBeShown: f,
167
+ selectedCategory: l,
168
168
  setSelectedCategory: o,
169
- selectedYear: l,
170
- setSelectedYear: v,
171
- onResetFilters: E,
172
- setCurrentPage: S,
173
- showCountryFilter: W,
174
- countryPlaceholder: s,
175
- countryCategory: d,
176
- selectedCountry: Y,
169
+ selectedYear: c,
170
+ setSelectedYear: N,
171
+ onResetFilters: T,
172
+ setCurrentPage: m,
173
+ showCountryFilter: K,
174
+ countryPlaceholder: n,
175
+ countryCategory: u,
176
+ selectedCountry: p,
177
177
  setSelectedCountry: D
178
178
  }
179
179
  ) }) }),
180
180
  /* @__PURE__ */ t(
181
- J,
181
+ U,
182
182
  {
183
- perPage: i || 10,
183
+ perPage: O || 10,
184
184
  store: "posts-with-filters",
185
- categories: Y || h || p.join(","),
186
- after: (g == null ? void 0 : g.startDate) || null,
187
- before: (g == null ? void 0 : g.endDate) || null,
188
- page: I,
189
- children: /* @__PURE__ */ t(U, { children: /* @__PURE__ */ t(
190
- L,
185
+ categories: (p == null ? void 0 : p.toString()) || (l == null ? void 0 : l.toString()) || f.join(","),
186
+ after: (y == null ? void 0 : y.startDate) || null,
187
+ before: (y == null ? void 0 : y.endDate) || null,
188
+ page: V,
189
+ children: /* @__PURE__ */ t(q, { children: /* @__PURE__ */ t(
190
+ Q,
191
191
  {
192
- showPaginationOptions: e,
193
- currentPage: I,
194
- setCurrentPage: S,
195
- countryCategory: d,
196
- height: O
192
+ showPaginationOptions: R,
193
+ currentPage: V,
194
+ setCurrentPage: m,
195
+ countryCategory: u,
196
+ height: r
197
197
  }
198
198
  ) })
199
- }
199
+ },
200
+ I
200
201
  )
201
202
  ] });
202
203
  };
203
204
  export {
204
- ae as default
205
+ ne as default
205
206
  };
@@ -3,27 +3,29 @@ import { get as f } from "../../api/commons.js";
3
3
  function c(t) {
4
4
  return JSON.parse(JSON.stringify(t));
5
5
  }
6
- const i = process.env.VITE_REACT_APP_API_ROOT, r = {}, s = {}, p = 3 * 60 * 1e3;
6
+ const o = process.env.VITE_REACT_APP_API_ROOT;
7
+ console.log("API_ROOT==>", o);
8
+ const s = {}, i = {}, p = 3 * 60 * 1e3;
7
9
  function a(t) {
8
10
  return Object.keys(t).map((e) => encodeURIComponent(e) + "=" + encodeURIComponent(t[e])).join("&");
9
11
  }
10
12
  function l(t) {
11
13
  const e = t, n = Date.now();
12
- if (s[e] && n - s[e].timestamp < p)
13
- return Promise.resolve(c(s[e].data));
14
- if (r[e])
15
- return r[e].then(c);
16
- const o = f(t).then((u) => (s[e] = { data: u, timestamp: Date.now() }, c(u))).finally(() => {
17
- delete r[e];
14
+ if (i[e] && n - i[e].timestamp < p)
15
+ return Promise.resolve(c(i[e].data));
16
+ if (s[e])
17
+ return s[e].then(c);
18
+ const r = f(t).then((u) => (i[e] = { data: u, timestamp: Date.now() }, c(u))).finally(() => {
19
+ delete s[e];
18
20
  });
19
- return r[e] = o, o;
21
+ return s[e] = r, r;
20
22
  }
21
23
  const O = ({ app: t, params: e }) => {
22
- const n = `${i || ""}/api/${t}/categories${e ? "?" + a(e) : ""}`;
24
+ const n = `${o || ""}/api/${t}/categories${e ? "?" + a(e) : ""}`;
23
25
  return console.log("categories==>", n), l(n);
24
26
  }, R = ({ source: t, app: e, params: n }) => {
25
- const o = `${i || ""}/api/${e}/stats/${t}${n ? "?" + a(n) : ""}`;
26
- return l(o);
27
+ const r = `${o || ""}/api/${e}/stats/${t}${n ? "?" + a(n) : ""}`;
28
+ return l(r);
27
29
  };
28
30
  export {
29
31
  O as getCategories,
@@ -4,15 +4,15 @@ import i from "../ResponsiveContainer.js";
4
4
  import { PostProvider as m, PostConsumer as l, Post as a } from "@devgateway/wp-react-lib";
5
5
  const d = ({ header: t, footer: e }) => {
6
6
  const { lan: s, slug: r } = n();
7
- return /* @__PURE__ */ o(i, { header: t, footer: e, children: /* @__PURE__ */ o(
7
+ return /* @__PURE__ */ o(
8
8
  m,
9
9
  {
10
10
  slug: r,
11
11
  store: r,
12
12
  locale: s,
13
- children: /* @__PURE__ */ o(l, { children: /* @__PURE__ */ o(a, {}) })
13
+ children: /* @__PURE__ */ o(i, { header: t, footer: e, children: /* @__PURE__ */ o(l, { children: /* @__PURE__ */ o(a, {}) }) })
14
14
  }
15
- ) });
15
+ );
16
16
  };
17
17
  export {
18
18
  d as default