@devgateway/dvz-ui-react 1.9.11 → 1.9.12

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.
@@ -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
  };