@undp/data-viz 1.4.5 → 1.4.7

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.
@@ -3,19 +3,19 @@ import { useRef as ge, useState as L, useEffect as S } from "react";
3
3
  import { y as ue } from "./Spinner-C85UF28E.js";
4
4
  import fe from "react-globe.gl";
5
5
  import { i as ye } from "./index-27yTRcko.js";
6
- import * as J from "three";
6
+ import * as I from "three";
7
7
  import { X as xe } from "./Modal-DVVwpKhP.js";
8
8
  import { u as de } from "./Typography-Ctgfl1J5.js";
9
9
  import { T as ve } from "./Tooltip-DyM5snqx.js";
10
10
  import { n as be } from "./numberFormattingFunction-14YCbkN2.js";
11
- import { X as je } from "./index-BmCqpO1B.js";
12
- import { s as we } from "./string2HTML-CWHGfz_d.js";
11
+ import { X as we } from "./index-BmCqpO1B.js";
12
+ import { s as je } from "./string2HTML-CWHGfz_d.js";
13
13
  import { o as Ce } from "./ordinal-w9Lu4Stb.js";
14
14
  import { t as De } from "./threshold-DFfqcDMa.js";
15
15
  import { GraphHeader as ke } from "./GraphHeader.js";
16
16
  import { GraphFooter as Ne } from "./GraphFooter.js";
17
17
  import { f as Se } from "./fetchAndParseData-4gsYTy6_.js";
18
- import { Colors as T } from "./Colors.js";
18
+ import { Colors as R } from "./Colors.js";
19
19
  import { g as Le } from "./getUniqValue-BtUENB2H.js";
20
20
  import { g as Me } from "./getJenks-VhM3GIoC.js";
21
21
  function Oe(_) {
@@ -23,42 +23,42 @@ function Oe(_) {
23
23
  width: p,
24
24
  autoRotate: d,
25
25
  data: u,
26
- enableZoom: R,
26
+ enableZoom: E,
27
27
  categorical: M,
28
28
  colorDomain: l,
29
29
  colors: i,
30
30
  globeMaterial: s,
31
- height: I,
31
+ height: W,
32
32
  polygonData: Y,
33
33
  mapProperty: c,
34
- mapBorderColor: E,
35
- atmosphereColor: W,
36
- tooltip: z,
34
+ mapBorderColor: H,
35
+ atmosphereColor: z,
36
+ tooltip: U,
37
37
  styles: v,
38
38
  classNames: K,
39
39
  mapNoDataColor: g,
40
- colorLegendTitle: H,
40
+ colorLegendTitle: $,
41
41
  showColorScale: Q,
42
42
  hoverStrokeColor: ee,
43
43
  detailsOnClick: f,
44
44
  onSeriesMouseClick: b,
45
45
  onSeriesMouseOver: h,
46
46
  resetSelectionOnDoubleClick: O,
47
- highlightedIds: U,
47
+ highlightedIds: q,
48
48
  scale: y,
49
- globeOffset: j,
50
- polygonAltitude: $,
51
- centerLng: A,
52
- centerLat: F,
53
- atmosphereAltitude: q,
49
+ globeOffset: w,
50
+ polygonAltitude: A,
51
+ centerLng: F,
52
+ centerLat: B,
53
+ atmosphereAltitude: X,
54
54
  globeCurvatureResolution: te,
55
- lightColor: B
56
- } = _, a = ge(void 0), [D, P] = L(void 0), [oe, X] = L(!(p < 680)), [V, re] = L({ x: 0, y: 0 }), [w, ie] = L(void 0), Z = M ? Ce().domain(l).range(i) : De().domain(l).range(i);
55
+ lightColor: T
56
+ } = _, a = ge(void 0), [D, P] = L(void 0), [oe, V] = L(!(p < 680)), [Z, re] = L({ x: 0, y: 0 }), [j, ie] = L(void 0), J = M ? Ce().domain(l).range(i) : De().domain(l).range(i);
57
57
  S(() => {
58
- a?.current && (a.current.controls().autoRotate = d !== 0, a.current.controls().enableZoom = R, a.current.controls().autoRotateSpeed = d);
59
- }, [d, R]), S(() => {
60
- a.current && (w ? a.current.controls().autoRotate = !1 : a.current.controls().autoRotate = d !== 0);
61
- }, [w, d]), S(() => {
58
+ a?.current && (a.current.controls().autoRotate = d !== 0, a.current.controls().enableZoom = E, a.current.controls().autoRotateSpeed = d);
59
+ }, [d, E]), S(() => {
60
+ a.current && (j ? a.current.controls().autoRotate = !1 : a.current.controls().autoRotate = d !== 0);
61
+ }, [j, d]), S(() => {
62
62
  const e = a.current?.renderer().domElement;
63
63
  if (!e) return;
64
64
  const o = (r) => {
@@ -66,44 +66,42 @@ function Oe(_) {
66
66
  };
67
67
  return e.addEventListener("mousemove", o), () => e.removeEventListener("mousemove", o);
68
68
  }, []), S(() => {
69
- a.current && a.current.pointOfView({ lat: F, lng: A, altitude: y }, 1e3);
70
- }, [y, A, F]);
71
- const ae = s || new J.MeshPhysicalMaterial({
72
- color: "#FFF",
73
- roughness: 0.5,
74
- reflectivity: 1.2
69
+ a.current && a.current.pointOfView({ lat: B, lng: F, altitude: y }, 1e3);
70
+ }, [y, F, B]);
71
+ const ae = s || new I.MeshBasicMaterial({
72
+ color: "#FFF"
75
73
  });
76
74
  return S(() => {
77
75
  if (!a.current) return;
78
76
  const e = a.current.scene();
79
77
  e.children.filter((r) => r.type === "DirectionalLight" || r.type === "AmbientLight").forEach((r) => e.remove(r));
80
- const o = new J.AmbientLight(B, 0.2);
78
+ const o = new I.AmbientLight(T, 0.2);
81
79
  e.add(o), setTimeout(() => {
82
80
  (e.children[3]?.children[0]?.children[4]?.children || []).forEach((m) => {
83
81
  const x = m.children[1];
84
82
  x && (x.renderOrder = 2);
85
83
  });
86
- }, 300);
87
- }, [B]), /* @__PURE__ */ t.jsxs("div", { className: "relative", children: [
84
+ }, 300), e.fog = new I.Fog(T, 150, 300);
85
+ }, [T]), /* @__PURE__ */ t.jsxs("div", { className: "relative", children: [
88
86
  /* @__PURE__ */ t.jsx(
89
87
  fe,
90
88
  {
91
89
  ref: a,
92
90
  width: p,
93
- height: I,
94
- globeOffset: j,
91
+ height: W,
92
+ globeOffset: w,
95
93
  lineHoverPrecision: 0,
96
94
  polygonsData: Y,
97
- polygonAltitude: (e) => U.includes(e?.properties?.[c]) ? 0.1 : e?.properties?.[c] === w?.id ? 0.01 : $,
95
+ polygonAltitude: (e) => q.includes(e?.properties?.[c]) ? 0.1 : e?.properties?.[c] === j?.id ? 0.01 : A,
98
96
  polygonCapColor: (e) => {
99
97
  const o = e?.properties?.[c], r = u.find((m) => m.id === o)?.x;
100
- return r != null ? Z(r) : g;
98
+ return r != null ? J(r) : g;
101
99
  },
102
100
  polygonSideColor: (e) => {
103
- const o = e?.properties?.[c], r = u.find((x) => x.id === o)?.x, m = r != null ? Z(r) : g;
104
- return U.includes(e?.properties?.[c]) ? m : "rgba(100,100,100,0)";
101
+ const o = e?.properties?.[c], r = u.find((x) => x.id === o)?.x, m = r != null ? J(r) : g;
102
+ return q.includes(e?.properties?.[c]) ? m : "rgba(100,100,100,0)";
105
103
  },
106
- polygonStrokeColor: (e) => e?.properties?.[c] === w?.id ? ee : E,
104
+ polygonStrokeColor: (e) => e?.properties?.[c] === j?.id ? ee : H,
107
105
  onPolygonClick: (e) => {
108
106
  const o = e?.properties?.[c] ? u.find((r) => r.id === e?.properties?.[c]) : void 0;
109
107
  (b || f) && (ye(D, o) && O && o ? (P(void 0), b?.(void 0)) : (P(o), b?.(o))), P(o), b?.(o);
@@ -112,8 +110,8 @@ function Oe(_) {
112
110
  const o = e?.properties?.[c] ? u.find((r) => r.id === e?.properties?.[c]) : void 0;
113
111
  ie(o), h?.(o);
114
112
  },
115
- atmosphereColor: W,
116
- atmosphereAltitude: q,
113
+ atmosphereColor: z,
114
+ atmosphereAltitude: X,
117
115
  globeCurvatureResolution: te,
118
116
  globeMaterial: ae,
119
117
  backgroundColor: "rgba(0, 0, 0, 0)",
@@ -121,21 +119,21 @@ function Oe(_) {
121
119
  onGlobeReady: () => {
122
120
  if (a.current) {
123
121
  a.current.pointOfView({
124
- lat: F,
125
- lng: A
122
+ lat: B,
123
+ lng: F
126
124
  });
127
125
  const e = a.current.scene();
128
126
  setTimeout(() => {
129
127
  e.children.filter((C) => C.type === "DirectionalLight").map((C) => {
130
128
  e.remove(C);
131
129
  });
132
- const m = new J.AmbientLight(B, 0.2);
130
+ const m = new I.AmbientLight(T, 0.2);
133
131
  e.add(m), (e.children[3]?.children[0]?.children[4]?.children || []).forEach((C) => {
134
132
  const k = C.children[1];
135
133
  k.renderOrder = 2;
136
134
  });
137
135
  }, 300);
138
- const o = new J.DirectionalLight(16777215, 0.1), r = a.current.camera();
136
+ const o = new I.DirectionalLight(16777215, 0.1), r = a.current.camera();
139
137
  o.position.set(0, 0, 1), r.add(o), e.add(r);
140
138
  }
141
139
  }
@@ -159,9 +157,9 @@ function Oe(_) {
159
157
  top: "-0.75rem"
160
158
  },
161
159
  onClick: () => {
162
- X(!1);
160
+ V(!1);
163
161
  },
164
- children: /* @__PURE__ */ t.jsx(je, {})
162
+ children: /* @__PURE__ */ t.jsx(we, {})
165
163
  }
166
164
  ),
167
165
  /* @__PURE__ */ t.jsxs(
@@ -173,7 +171,7 @@ function Oe(_) {
173
171
  width: M ? void 0 : "340px"
174
172
  },
175
173
  children: [
176
- H && H !== "" ? /* @__PURE__ */ t.jsx(
174
+ $ && $ !== "" ? /* @__PURE__ */ t.jsx(
177
175
  de,
178
176
  {
179
177
  size: "xs",
@@ -184,7 +182,7 @@ function Oe(_) {
184
182
  WebkitLineClamp: "1",
185
183
  WebkitBoxOrient: "vertical"
186
184
  },
187
- children: H
185
+ children: $
188
186
  }
189
187
  ) : null,
190
188
  M ? /* @__PURE__ */ t.jsx("div", { className: "flex flex-col gap-3", children: l.map((e, o) => /* @__PURE__ */ t.jsxs("div", { className: "flex gap-2 items-center", children: [
@@ -245,18 +243,18 @@ function Oe(_) {
245
243
  type: "button",
246
244
  className: "mb-0 border-0 bg-transparent p-0 self-start",
247
245
  onClick: () => {
248
- X(!0);
246
+ V(!0);
249
247
  },
250
248
  children: /* @__PURE__ */ t.jsx("div", { className: "items-start text-sm font-medium cursor-pointer p-2 mb-0 flex text-primary-black dark:text-primary-gray-300 bg-primary-gray-300 dark:bg-primary-gray-550 border-primary-gray-400 dark:border-primary-gray-500", children: "Show Legend" })
251
249
  }
252
250
  ) }),
253
- w && z ? /* @__PURE__ */ t.jsx(
251
+ j && U ? /* @__PURE__ */ t.jsx(
254
252
  ve,
255
253
  {
256
- data: w,
257
- body: z,
258
- xPos: V.x,
259
- yPos: V.y,
254
+ data: j,
255
+ body: U,
256
+ xPos: Z.x,
257
+ yPos: Z.y,
260
258
  backgroundStyle: v?.tooltip,
261
259
  className: K?.tooltip
262
260
  }
@@ -272,7 +270,7 @@ function Oe(_) {
272
270
  "div",
273
271
  {
274
272
  className: "graph-modal-content m-0",
275
- dangerouslySetInnerHTML: typeof f == "string" ? { __html: we(f, D) } : void 0,
273
+ dangerouslySetInnerHTML: typeof f == "string" ? { __html: je(f, D) } : void 0,
276
274
  children: typeof f == "function" ? f(D) : null
277
275
  }
278
276
  )
@@ -285,46 +283,46 @@ function _e(_) {
285
283
  data: p,
286
284
  mapData: d = "https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap-simplified.json",
287
285
  graphTitle: u,
288
- colors: R,
286
+ colors: E,
289
287
  sources: M,
290
288
  graphDescription: l,
291
289
  height: i,
292
290
  width: s,
293
- footNote: I = "The designations employed and the presentation of material on this map do not imply the expression of any opinion whatsoever on the part of the Secretariat of the United Nations or UNDP concerning the legal status of any country, territory, city or area or its authorities, or concerning the delimitation of its frontiers or boundaries.",
291
+ footNote: W = "The designations employed and the presentation of material on this map do not imply the expression of any opinion whatsoever on the part of the Secretariat of the United Nations or UNDP concerning the legal status of any country, territory, city or area or its authorities, or concerning the delimitation of its frontiers or boundaries.",
294
292
  colorDomain: Y,
295
293
  colorLegendTitle: c,
296
- scaleType: E = "threshold",
297
- padding: W,
298
- mapNoDataColor: z = T.light.graphNoData,
294
+ scaleType: H = "threshold",
295
+ padding: z,
296
+ mapNoDataColor: U = R.light.graphNoData,
299
297
  backgroundColor: v = !1,
300
- mapBorderColor: K = T.light.grays["gray-500"],
298
+ mapBorderColor: K = R.light.grays["gray-500"],
301
299
  relativeHeight: g,
302
- tooltip: H,
300
+ tooltip: $,
303
301
  graphID: Q,
304
302
  mapProperty: ee = "ISO3",
305
303
  dataDownload: f = !1,
306
304
  language: b = "en",
307
305
  minHeight: h = 0,
308
306
  theme: O = "light",
309
- ariaLabel: U,
307
+ ariaLabel: q,
310
308
  styles: y,
311
- classNames: j,
312
- autoRotate: $ = !0,
313
- enableZoom: A = !0,
314
- globeMaterial: F,
315
- centerPoint: q = [0, 0],
309
+ classNames: w,
310
+ autoRotate: A = !0,
311
+ enableZoom: F = !0,
312
+ globeMaterial: B,
313
+ centerPoint: X = [0, 0],
316
314
  atmosphereColor: te = "#999",
317
- showColorScale: B = !0,
315
+ showColorScale: T = !0,
318
316
  resetSelectionOnDoubleClick: a = !0,
319
317
  detailsOnClick: D,
320
318
  onSeriesMouseOver: P,
321
319
  onSeriesMouseClick: oe,
322
- highlightedIds: X = [],
323
- scale: V = 1,
320
+ highlightedIds: V = [],
321
+ scale: Z = 1,
324
322
  globeOffset: re = [0, 0],
325
- polygonAltitude: w = 0.01,
323
+ polygonAltitude: j = 0.01,
326
324
  globeCurvatureResolution: ie = 4,
327
- atmosphereAltitude: Z = 0.15,
325
+ atmosphereAltitude: J = 0.15,
328
326
  lightColor: ae = "#dce9fe"
329
327
  } = _, [e, o] = L(void 0), [r, m] = L(0), [x, C] = L(0), k = ge(null);
330
328
  S(() => {
@@ -352,9 +350,9 @@ function _e(_) {
352
350
  } else o(G.features);
353
351
  }) : o(d.features);
354
352
  }, [d]);
355
- const se = Y || (E === "categorical" ? Le(p, "x") : Me(
353
+ const se = Y || (H === "categorical" ? Le(p, "x") : Me(
356
354
  p.map((n) => n.x),
357
- R?.length || 4
355
+ E?.length || 4
358
356
  ));
359
357
  return /* @__PURE__ */ t.jsx(
360
358
  "div",
@@ -366,19 +364,19 @@ function _e(_) {
366
364
  {
367
365
  className: pe(
368
366
  `${v ? v === !0 ? "bg-primary-gray-200 dark:bg-primary-gray-650 " : "" : "bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${b || "en"}`,
369
- j?.graphContainer
367
+ w?.graphContainer
370
368
  ),
371
369
  style: {
372
370
  ...y?.graphContainer || {},
373
371
  ...v && v !== !0 ? { backgroundColor: v } : {}
374
372
  },
375
373
  id: Q,
376
- "aria-label": U || `${u ? `The graph shows ${u}. ` : ""}This is a map.${l ? ` ${l}` : ""}`,
374
+ "aria-label": q || `${u ? `The graph shows ${u}. ` : ""}This is a map.${l ? ` ${l}` : ""}`,
377
375
  children: /* @__PURE__ */ t.jsx(
378
376
  "div",
379
377
  {
380
378
  className: "flex grow",
381
- style: { padding: v ? W || "1rem" : W || 0 },
379
+ style: { padding: v ? z || "1rem" : z || 0 },
382
380
  children: /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col w-full gap-4 grow justify-between", children: [
383
381
  u || l || f ? /* @__PURE__ */ t.jsx(
384
382
  ke,
@@ -388,8 +386,8 @@ function _e(_) {
388
386
  description: y?.description
389
387
  },
390
388
  classNames: {
391
- title: j?.title,
392
- description: j?.description
389
+ title: w?.title,
390
+ description: w?.description
393
391
  },
394
392
  graphTitle: u,
395
393
  graphDescription: l,
@@ -416,31 +414,31 @@ function _e(_) {
416
414
  h,
417
415
  i || (g ? h ? (s || r) * g > h ? (s || r) * g : h : (s || r) * g : x)
418
416
  ),
419
- colors: R || (E === "categorical" ? T[O].sequentialColors[`neutralColorsx0${se.length}`] : T[O].sequentialColors[`neutralColorsx0${se.length + 1}`]),
420
- mapNoDataColor: z,
421
- categorical: E === "categorical",
417
+ colors: E || (H === "categorical" ? R[O].sequentialColors[`neutralColorsx0${se.length}`] : R[O].sequentialColors[`neutralColorsx0${se.length + 1}`]),
418
+ mapNoDataColor: U,
419
+ categorical: H === "categorical",
422
420
  mapBorderColor: K,
423
- tooltip: H,
421
+ tooltip: $,
424
422
  mapProperty: ee,
425
423
  styles: y,
426
- classNames: j,
427
- autoRotate: $ === !0 ? 1.5 : $ === !1 ? 0 : $,
428
- enableZoom: A,
429
- globeMaterial: F,
424
+ classNames: w,
425
+ autoRotate: A === !0 ? 1.5 : A === !1 ? 0 : A,
426
+ enableZoom: F,
427
+ globeMaterial: B,
430
428
  atmosphereColor: te,
431
429
  colorLegendTitle: c,
432
- showColorScale: B,
433
- hoverStrokeColor: O === "light" ? T.light.grays["gray-700"] : T.light.grays["gray-300"],
434
- highlightedIds: X,
430
+ showColorScale: T,
431
+ hoverStrokeColor: O === "light" ? R.light.grays["gray-700"] : R.light.grays["gray-300"],
432
+ highlightedIds: V,
435
433
  resetSelectionOnDoubleClick: a,
436
434
  detailsOnClick: D,
437
435
  onSeriesMouseOver: P,
438
436
  onSeriesMouseClick: oe,
439
- scale: V,
440
- polygonAltitude: w,
441
- centerLat: q[0],
442
- centerLng: q[1],
443
- atmosphereAltitude: Z,
437
+ scale: Z,
438
+ polygonAltitude: j,
439
+ centerLat: X[0],
440
+ centerLng: X[1],
441
+ atmosphereAltitude: J,
444
442
  globeCurvatureResolution: ie,
445
443
  lightColor: ae
446
444
  }
@@ -459,16 +457,16 @@ function _e(_) {
459
457
  )
460
458
  }
461
459
  ),
462
- M || I ? /* @__PURE__ */ t.jsx(
460
+ M || W ? /* @__PURE__ */ t.jsx(
463
461
  Ne,
464
462
  {
465
463
  styles: { footnote: y?.footnote, source: y?.source },
466
464
  classNames: {
467
- footnote: j?.footnote,
468
- source: j?.source
465
+ footnote: w?.footnote,
466
+ source: w?.source
469
467
  },
470
468
  sources: M,
471
- footNote: I,
469
+ footNote: W,
472
470
  width: s
473
471
  }
474
472
  ) : null