@devgateway/dvz-ui-react 1.9.11 → 1.9.13

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 (29) hide show
  1. package/dist/cjs/embeddable/d3Map/DataLayer.js +1 -1
  2. package/dist/cjs/embeddable/d3Map/FlowLayer.js +1 -1
  3. package/dist/cjs/embeddable/d3Map/LatLongLayer.js +1 -1
  4. package/dist/cjs/embeddable/d3Map/Legends.js +1 -1
  5. package/dist/cjs/embeddable/d3Map/Tooltip.js +1 -1
  6. package/dist/cjs/embeddable/d3Map/Utils.js +1 -1
  7. package/dist/cjs/embeddable/data/D3MapDataProvider.js +1 -1
  8. package/dist/cjs/embeddable/filter/index.js +1 -1
  9. package/dist/cjs/embeddable/map/index.js +2 -2
  10. package/dist/cjs/embeddable/map/map.js +4 -4
  11. package/dist/cjs/embeddable/map/mapHelpers.js +1 -1
  12. package/dist/cjs/embeddable/tabbedposts/index.js +1 -1
  13. package/dist/cjs/styles.css +1 -1
  14. package/dist/esm/embeddable/d3Map/DataLayer.js +322 -311
  15. package/dist/esm/embeddable/d3Map/FlowLayer.js +105 -99
  16. package/dist/esm/embeddable/d3Map/LatLongLayer.js +106 -100
  17. package/dist/esm/embeddable/d3Map/Legends.js +151 -147
  18. package/dist/esm/embeddable/d3Map/Tooltip.js +64 -20
  19. package/dist/esm/embeddable/d3Map/Utils.js +26 -12
  20. package/dist/esm/embeddable/data/D3MapDataProvider.js +31 -30
  21. package/dist/esm/embeddable/filter/index.js +123 -123
  22. package/dist/esm/embeddable/map/index.js +77 -77
  23. package/dist/esm/embeddable/map/map.js +436 -453
  24. package/dist/esm/embeddable/map/mapHelpers.js +88 -104
  25. package/dist/esm/embeddable/tabbedposts/index.js +12 -12
  26. package/dist/esm/styles.css +1 -1
  27. package/dist/types/embeddable/d3Map/Utils.d.ts +4 -0
  28. package/dist/types/embeddable/map/mapHelpers.d.ts +0 -2
  29. package/package.json +1 -1
@@ -1,28 +1,14 @@
1
1
  import * as L from "topojson-client";
2
2
  import x from "geostats";
3
3
  import y from "../../utils/deviceType.js";
4
- const w = "_Color_", M = "location", k = "showAll", A = "ifUnitHasData", j = 10, B = {
5
- mobile: 4,
6
- tablet: 4,
7
- midTablet: 2,
8
- laptop: 2,
9
- desktop: 2,
10
- wide: 2
11
- }, I = {
4
+ const A = "_Color_", I = "location", j = "showAll", w = "ifUnitHasData", C = 10, _ = {
12
5
  mobile: 330,
13
6
  tablet: 250,
14
7
  midTablet: 250,
15
8
  laptop: 200,
16
9
  desktop: 100,
17
10
  wide: 100
18
- }, _ = {
19
- mobile: 250,
20
- tablet: 250,
21
- midTablet: 250,
22
- laptop: 0,
23
- desktop: 0,
24
- wide: 0
25
- }, C = {
11
+ }, O = {
26
12
  greens: [
27
13
  "#ccffdd",
28
14
  "#b3ffcc",
@@ -96,148 +82,146 @@ const w = "_Color_", M = "location", k = "showAll", A = "ifUnitHasData", j = 10,
96
82
  "#0055ff"
97
83
  ]
98
84
  };
99
- function v(e, r, l) {
100
- var t;
101
- if (!(e != null && e.length)) return r;
102
- const o = ((t = e[0]) == null ? void 0 : t.items) ?? [], n = (i) => (i == null ? void 0 : i.trim().toLowerCase()) ?? "", s = n(r), c = n(l).toUpperCase(), f = o.find((i) => n(i.value) === s || n(i.code) === s) ?? null;
103
- if (!f) return r;
104
- const a = c && f.labels && f.labels[c] ? f.labels[c] : f.value;
105
- return (a == null ? void 0 : a.trim()) || f.value.trim();
85
+ function v(e, t, l) {
86
+ var r;
87
+ if (!(e != null && e.length)) return t;
88
+ const f = ((r = e[0]) == null ? void 0 : r.items) ?? [], n = (i) => (i == null ? void 0 : i.trim().toLowerCase()) ?? "", s = n(t), c = n(l).toUpperCase(), o = f.find((i) => n(i.value) === s || n(i.code) === s) ?? null;
89
+ if (!o) return t;
90
+ const a = c && o.labels && o.labels[c] ? o.labels[c] : o.value;
91
+ return (a == null ? void 0 : a.trim()) || o.value.trim();
106
92
  }
107
93
  function D(e) {
108
- let r = e;
109
- return r || (r = ["mobile", "tablet", "midTablet"].includes(y())), r ? "active zoom-enabled" : "active";
94
+ let t = e;
95
+ return t || (t = ["mobile", "tablet", "midTablet"].includes(y())), t ? "active zoom-enabled" : "active";
110
96
  }
111
- function E(e, r) {
112
- const { autoGenerateBreaks: l, numberOfBreaks: o, colorScheme: n } = r, s = [];
97
+ function M(e, t) {
98
+ const { autoGenerateBreaks: l, numberOfBreaks: f, colorScheme: n } = t, s = [];
113
99
  if (l && e && e.length > 0) {
114
- const c = e.filter((t) => t.properties && t.properties.value != null).map((t) => t.properties.value.toFixed(2)), f = [];
115
- c.forEach((t) => {
116
- if (t > 0) {
117
- const i = t * 0.99, p = t * 1.01;
118
- f.indexOf(i) === -1 && f.push(i), f.indexOf(p) === -1 && f.push(p);
100
+ const c = e.filter((r) => r.properties && r.properties.value != null).map((r) => r.properties.value.toFixed(2)), o = [];
101
+ c.forEach((r) => {
102
+ if (r > 0) {
103
+ const i = r * 0.99, u = r * 1.01;
104
+ o.indexOf(i) === -1 && o.push(i), o.indexOf(u) === -1 && o.push(u);
119
105
  }
120
106
  });
121
- const a = C[n];
122
- if (f.length > 0) {
123
- const t = new x(f);
124
- t.setPrecision(2);
125
- const i = f.length > 1 ? f.length - 1 : f.length;
126
- return t.getJenks(Math.min(o, i)), t.ranges.forEach((p, u) => {
107
+ const a = O[n];
108
+ if (o.length > 0) {
109
+ const r = new x(o);
110
+ r.setPrecision(2);
111
+ const i = o.length > 1 ? o.length - 1 : o.length;
112
+ return r.getJenks(Math.min(f, i)), r.ranges.forEach((u, p) => {
127
113
  const b = {};
128
- b.min = parseFloat(p.substr(0, p.indexOf("-") - 1)) + (u > 0 ? 0.01 : 0), b.max = parseFloat(p.substr(p.indexOf("-") + 2, p.length)), b.color = a[u], s.push(b);
114
+ b.min = parseFloat(u.substr(0, u.indexOf("-") - 1)) + (p > 0 ? 0.01 : 0), b.max = parseFloat(u.substr(u.indexOf("-") + 2, u.length)), b.color = a[p], s.push(b);
129
115
  }), s;
130
116
  }
131
117
  }
132
118
  return s;
133
119
  }
134
- function H(e, r, l) {
135
- const { mapNoDataColor: o, mainLayerId: n, enabledLayers: s, selectedMeasure: c } = l;
120
+ function T(e, t, l) {
121
+ const { mapNoDataColor: f, mainLayerId: n, enabledLayers: s, selectedMeasure: c } = l;
136
122
  if (e.properties && e.properties.variables && c && e.properties.value != null) {
137
- const a = w + c, t = e.properties.variables[a.trim()];
138
- if (t) return t;
123
+ const a = A + c, r = e.properties.variables[a.trim()];
124
+ if (r) return r;
139
125
  }
140
126
  if (e.properties.value != null && (n && e.properties.layerId === n || !n)) {
141
- const a = r.find((t) => t.min != null && t.max != null ? e.properties.value >= t.min && e.properties.value <= t.max : t.min != null ? e.properties.value >= t.min : t.max != null ? e.properties.value <= t.max : !1);
142
- return a && a.color ? a.color : o;
127
+ const a = t.find((r) => r.min != null && r.max != null ? e.properties.value >= r.min && e.properties.value <= r.max : r.min != null ? e.properties.value >= r.min : r.max != null ? e.properties.value <= r.max : !1);
128
+ return a && a.color ? a.color : f;
143
129
  }
144
- const f = s.filter((a) => a.id === e.properties.layerId)[0];
145
- return f && f.bgColor && f.bgColor != "undefined" ? f.bgColor : o;
130
+ const o = s.filter((a) => a.id === e.properties.layerId)[0];
131
+ return o && o.bgColor && o.bgColor != "undefined" ? o.bgColor : f;
146
132
  }
147
- function S(e, r) {
148
- if (e.properties[r]) {
149
- const o = e.properties[r].length;
150
- return o < 10 ? 80 : o * 8;
133
+ function E(e, t) {
134
+ if (e.properties[t]) {
135
+ const f = e.properties[t].length;
136
+ return f < 10 ? 80 : f * 8;
151
137
  }
152
138
  return 0;
153
139
  }
154
- function R(e) {
140
+ function H(e) {
155
141
  return e ? 30 : 25;
156
142
  }
157
- function O(e, r) {
143
+ function k(e, t) {
158
144
  if (e && e.objects) {
159
145
  const l = Object.keys(e.objects);
160
- for (const o in l) {
161
- const n = l[o];
146
+ for (const f in l) {
147
+ const n = l[f];
162
148
  if (e.objects[n].type == "GeometryCollection")
163
149
  return n;
164
150
  }
165
151
  }
166
- return r;
152
+ return t;
167
153
  }
168
- function W(e, r) {
169
- const l = O(e, r);
154
+ function S(e, t) {
155
+ const l = k(e, t);
170
156
  return e && e.objects && e.objects[l] ? L.feature(e, e.objects[l]).features : e && e.features ? e.features : [];
171
157
  }
172
- function U(e, r, l) {
158
+ function R(e, t, l) {
173
159
  if (e.properties.displayLayerLabels && e.properties.layerLocale) {
174
- const o = e.properties.layerMappingField || r, n = e.properties[o];
160
+ const f = e.properties.layerMappingField || t, n = e.properties[f];
175
161
  return v(l, n, e.properties.layerLocale);
176
162
  }
177
- return e.properties[r];
163
+ return e.properties[t];
178
164
  }
179
- function z(e, r, l, o) {
165
+ function U(e, t, l, f) {
180
166
  const {
181
167
  mapLabelField: n,
182
168
  mapLabelShowValue: s,
183
169
  intl: c,
184
- valueFormat: f,
170
+ valueFormat: o,
185
171
  showNoDataLabel: a,
186
- showAdminUnitLabel: t,
172
+ showAdminUnitLabel: r,
187
173
  noDataText: i,
188
- selectedMeasure: p
189
- } = r;
190
- let u = "";
191
- if (t == k || t == A && e.properties.hasDataRow || e.properties.displayLayerLabels) {
192
- const b = e.properties.displayLayerLabels && e.properties.layerMappingField ? e.properties.layerMappingField : n, d = e.properties[b], h = e.properties.layerLocale || (c == null ? void 0 : c.locale);
193
- u = v(l, d, h);
194
- const g = e.properties.abbrev;
195
- if (u && u.length > j && g && (u = g), s)
174
+ selectedMeasure: u
175
+ } = t;
176
+ let p = "";
177
+ if (r == j || r == w && e.properties.hasDataRow || e.properties.displayLayerLabels) {
178
+ const b = e.properties.displayLayerLabels && e.properties.layerMappingField ? e.properties.layerMappingField : n, g = e.properties[b], d = e.properties.layerLocale || (c == null ? void 0 : c.locale);
179
+ p = v(l, g, d);
180
+ const h = e.properties.abbrev;
181
+ if (p && p.length > C && h && (p = h), s)
196
182
  if (e.properties.value != null) {
197
183
  const m = e.properties.variables || {};
198
- u += "<br><span class='map-label-value'>" + o(
199
- f,
200
- { value: e.properties.value, measure: p, ...m },
184
+ p += "<br><span class='map-label-value'>" + f(
185
+ o,
186
+ { value: e.properties.value, measure: u, ...m },
201
187
  c
202
188
  ) + "</span>";
203
- } else a == !0 && e.properties.value == null && e.properties.hasDataRow && (u += "<br><span class='map-label-value'>" + i + "</span>");
189
+ } else a == !0 && e.properties.value == null && e.properties.hasDataRow && (p += "<br><span class='map-label-value'>" + i + "</span>");
204
190
  }
205
- return u;
191
+ return p;
206
192
  }
207
- function G(e) {
208
- const r = {};
193
+ function W(e) {
194
+ const t = {};
209
195
  return e && Object.keys(e).forEach((l) => {
210
- const o = e[l];
211
- o && (r[l] = Array.isArray(o) ? o.join(" ,") : o);
212
- }), r;
196
+ const f = e[l];
197
+ f && (t[l] = Array.isArray(f) ? f.join(" ,") : f);
198
+ }), t;
213
199
  }
214
- function N(e, r, l) {
215
- const o = e ? e.value : null;
216
- if (o != null) {
217
- const n = r.find((s) => s.min != null && s.max != null ? o >= s.min && o <= s.max : s.min != null ? o >= s.min : s.max != null ? o <= s.max : !1);
200
+ function z(e, t, l) {
201
+ const f = e ? e.value : null;
202
+ if (f != null) {
203
+ const n = t.find((s) => s.min != null && s.max != null ? f >= s.min && f <= s.max : s.min != null ? f >= s.min : s.max != null ? f <= s.max : !1);
218
204
  return n && n.color ? n.color : l;
219
205
  }
220
206
  return l;
221
207
  }
222
208
  export {
223
- w as COLOR_VARIABLE,
224
- M as LOCATION,
225
- j as MAX_LABEL_LEN,
226
- k as SHOW_ALL,
227
- A as SHOW_IF_HAS_DATA,
209
+ A as COLOR_VARIABLE,
210
+ I as LOCATION,
211
+ C as MAX_LABEL_LEN,
212
+ j as SHOW_ALL,
213
+ w as SHOW_IF_HAS_DATA,
228
214
  D as classColor,
229
- z as createLabel,
230
- I as deviceMapHeight,
231
- _ as deviceMapWidth,
232
- B as deviceTranslateMap,
233
- W as extractFeatures,
234
- H as fillColor,
235
- E as generateBreaks,
236
- O as getCollectionField,
237
- G as getFilters,
238
- N as getHighlightedLocationColor,
239
- R as getLabelBoxHeight,
240
- S as getLabelBoxWidth,
215
+ U as createLabel,
216
+ _ as deviceMapHeight,
217
+ S as extractFeatures,
218
+ T as fillColor,
219
+ M as generateBreaks,
220
+ k as getCollectionField,
221
+ W as getFilters,
222
+ z as getHighlightedLocationColor,
223
+ H as getLabelBoxHeight,
224
+ E as getLabelBoxWidth,
241
225
  v as getTranslatedItemLabel,
242
- U as getTranslatedLocationName
226
+ R as getTranslatedLocationName
243
227
  };
@@ -1,17 +1,17 @@
1
1
  import { jsx as e, jsxs as f } from "react/jsx-runtime";
2
2
  import I, { useState as w, useRef as G, useEffect as x } from "react";
3
3
  import { Container as b, Accordion as y, Icon as V, Menu as T, Grid as v, Label as M, Button as W } from "semantic-ui-react";
4
- import { PostProvider as q, PostConsumer as _, MediaProvider as P, MediaConsumer as A, PostIcon as $, PostLabel as k } from "@devgateway/wp-react-lib";
4
+ import { PostProvider as q, PostConsumer as _, MediaProvider as P, MediaConsumer as A, PostIcon as S, PostLabel as $ } from "@devgateway/wp-react-lib";
5
5
  import { injectIntl as E } from "react-intl";
6
6
  import { connect as O } from "react-redux";
7
- import L from "../connected-templates/PostIntro.js";
7
+ import k from "../connected-templates/PostIntro.js";
8
8
  import { useWindowDimensionsAndDevice as U } from "../../lib/hooks/window-dimensions.js";
9
9
  const Y = ({ posts: t, activeItem: o, setActive: i, showLabels: n }) => t ? t.map((l) => /* @__PURE__ */ e(
10
10
  T.Item,
11
11
  {
12
12
  onClick: () => i(l.slug),
13
13
  className: l.slug === o ? "active" : "",
14
- children: n ? /* @__PURE__ */ e(k, { post: l }) : /* @__PURE__ */ e(M, { children: /* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: l.title.rendered } }) })
14
+ children: n ? /* @__PURE__ */ e($, { post: l }) : /* @__PURE__ */ e(M, { children: /* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: l.title.rendered } }) })
15
15
  },
16
16
  l.id
17
17
  )) : null, J = ({
@@ -38,10 +38,10 @@ const Y = ({ posts: t, activeItem: o, setActive: i, showLabels: n }) => t ? t.ma
38
38
  P,
39
39
  {
40
40
  id: (m = a.meta_fields) != null && m.icon ? a.meta_fields.icon[0] : null,
41
- children: /* @__PURE__ */ e(A, { children: /* @__PURE__ */ e($, { className: "icon" }) })
41
+ children: /* @__PURE__ */ e(A, { children: /* @__PURE__ */ e(S, { className: "icon" }) })
42
42
  }
43
43
  ),
44
- l ? /* @__PURE__ */ e(k, { post: a }) : /* @__PURE__ */ e(M, { children: /* @__PURE__ */ e(
44
+ l ? /* @__PURE__ */ e($, { post: a }) : /* @__PURE__ */ e(M, { children: /* @__PURE__ */ e(
45
45
  "span",
46
46
  {
47
47
  dangerouslySetInnerHTML: { __html: a.title.rendered }
@@ -54,7 +54,7 @@ const Y = ({ posts: t, activeItem: o, setActive: i, showLabels: n }) => t ? t.ma
54
54
  a.id
55
55
  );
56
56
  }) : null;
57
- }, S = ({ posts: t, activeItem: o }) => (x(() => {
57
+ }, L = ({ posts: t, activeItem: o }) => (x(() => {
58
58
  const i = document.querySelector(".ui.container.content-tab");
59
59
  i && (i.scrollTop = 0);
60
60
  }, [o]), t ? t.map((i) => {
@@ -70,7 +70,7 @@ const Y = ({ posts: t, activeItem: o, setActive: i, showLabels: n }) => t ? t.ma
70
70
  visibility: "visible",
71
71
  position: "relative",
72
72
  width: "auto"
73
- }, /* @__PURE__ */ e(L, { as: b, fluid: !0, post: i, style: n }, i.slug);
73
+ }, /* @__PURE__ */ e(k, { as: b, fluid: !0, post: i, style: n }, i.slug);
74
74
  }) : null), K = ({ posts: t, activeItem: o, setActive: i }) => {
75
75
  const [n, l] = w(
76
76
  t.findIndex((s) => s.slug === o)
@@ -109,7 +109,7 @@ const Y = ({ posts: t, activeItem: o, setActive: i, showLabels: n }) => t ? t.ma
109
109
  },
110
110
  children: [
111
111
  /* @__PURE__ */ f("div", { style: { display: "flex", alignItems: "center" }, children: [
112
- c && /* @__PURE__ */ e(P, { id: c, children: /* @__PURE__ */ e(A, { children: /* @__PURE__ */ e($, { className: "icon" }) }) }),
112
+ c && /* @__PURE__ */ e(P, { id: c, children: /* @__PURE__ */ e(A, { children: /* @__PURE__ */ e(S, { className: "icon" }) }) }),
113
113
  /* @__PURE__ */ e(
114
114
  "span",
115
115
  {
@@ -129,7 +129,7 @@ const Y = ({ posts: t, activeItem: o, setActive: i, showLabels: n }) => t ? t.ma
129
129
  {
130
130
  className: "accordion-post-content",
131
131
  active: n === u,
132
- children: /* @__PURE__ */ e("div", { ref: d, children: /* @__PURE__ */ e(L, { post: s, as: b, fluid: !0 }) })
132
+ children: /* @__PURE__ */ e("div", { ref: d, children: /* @__PURE__ */ e(k, { post: s, as: b, fluid: !0 }) })
133
133
  }
134
134
  )
135
135
  ] }, s.id);
@@ -146,13 +146,13 @@ const Y = ({ posts: t, activeItem: o, setActive: i, showLabels: n }) => t ? t.ma
146
146
  }, [t]), /* @__PURE__ */ f(I.Fragment, { children: [
147
147
  t.map((r) => /* @__PURE__ */ e("anchor", { id: r.slug }, r.slug)),
148
148
  /* @__PURE__ */ e(T, { className: "tabbed posts", text: !0, children: /* @__PURE__ */ e(Y, { showLabels: o, posts: t, setActive: l, activeItem: n }) }),
149
- /* @__PURE__ */ e(b, { className: "content-tab", style: { height: `${i}px` }, children: /* @__PURE__ */ e(S, { posts: t, activeItem: n }) })
149
+ /* @__PURE__ */ e(b, { className: "content-tab", style: { height: `${i}px` }, children: /* @__PURE__ */ e(L, { posts: t, activeItem: n }) })
150
150
  ] });
151
151
  }, X = ({ posts: t, showLabels: o, showIcons: i, height: n }) => {
152
152
  const [l, r] = w(t ? t[0].slug : null);
153
153
  return /* @__PURE__ */ e(I.Fragment, { children: /* @__PURE__ */ f(v, { stackable: !0, className: "tabbed posts", columns: t.length, style: { height: n + "px" }, children: [
154
154
  /* @__PURE__ */ e(J, { showIcons: i, showLabels: o, posts: t, activeItem: l, setActive: r }),
155
- /* @__PURE__ */ e(v.Row, { style: { height: `${n}px` }, children: /* @__PURE__ */ e(v.Column, { width: 16, className: "content", children: /* @__PURE__ */ e(b, { className: "content-tab", style: { height: `${n}px` }, children: /* @__PURE__ */ e(S, { className: "content-tab", posts: t, activeItem: l }) }) }) })
155
+ /* @__PURE__ */ e(v.Row, { style: { height: `${n}px` }, children: /* @__PURE__ */ e(v.Column, { width: 16, className: "content", children: /* @__PURE__ */ e(b, { className: "content-tab", style: { height: `${n}px` }, children: /* @__PURE__ */ e(L, { className: "content-tab", posts: t, activeItem: l }) }) }) })
156
156
  ] }) });
157
157
  }, Z = (t) => {
158
158
  var N;
@@ -173,7 +173,7 @@ const Y = ({ posts: t, activeItem: o, setActive: i, showLabels: n }) => t ? t.ma
173
173
  unique: j
174
174
  } = t;
175
175
  c != null && c.previewMode && (c != null && c.editing) && (u = c.previewMode, g = c.editing);
176
- const D = t.intl.locale, R = Array.isArray(n) ? n.join(",") : n, p = d === "true", C = p ? s : void 0, { width: H } = U(), z = H <= 1024, B = u !== "Desktop" && g, F = z && !g;
176
+ const D = t.intl.locale, R = Array.isArray(n) ? n.join(",").toString() : n, p = d === "true", C = p ? s : void 0, { width: H } = U(), z = H <= 1024, B = u !== "Desktop" && g, F = z && !g;
177
177
  return g && !o ? /* @__PURE__ */ e(b, { className: `viz tabbed posts ${g ? "editing" : ""} ${p ? "scrollable" : ""}`, fluid: !0 }) : /* @__PURE__ */ e(b, { className: `viz tabbed posts ${g ? "editing" : ""} ${p ? "scrollable" : ""}`, fluid: !0, children: /* @__PURE__ */ e(
178
178
  q,
179
179
  {