UNPKG

@devgateway/dvz-ui-react

Version:

A modular, embeddable React component library for data visualization and UI, built with TypeScript. Provides reusable components for charts, maps, dashboards, and more, with built-in support for internationalization and Redux integration.

228 lines (227 loc) 8.3 kB
import { jsx as r } from "react/jsx-runtime"; import "react"; import { connect as Va } from "react-redux"; import Wa from "../data/DataProvider.js"; import Ga from "../data/DataConsumer.js"; import ja from "./map.js"; import Za from "./MapDataFrame.js"; import Ha from "./MapCSVDataFrame.js"; const Ja = [ { label: "KENYA", value: "KEN", center: [35.8166634, 0.1], scale: 2e3 }, { label: "Nigeria", value: "NGA", center: [7.491302, 9.072264], scale: 2e3 }, { label: "South Africa", value: "ZAF", center: [24.676997, -28.48322], scale: 2e3 }, { label: "West Africa", value: "West Africa", center: [-7.293255, 13.90572], scale: 1500 }, { label: "Africa", value: "Africa", center: [13.134227, -11.523088], scale: 550 }, { label: "Ethiopia", value: "ETH", center: [35.8166634, 1.7], scale: 2e3 }, { label: "Zambia", value: "ZMB", center: [26.459455, -14.668135], scale: 2e3 }, { label: "Democratic Republic of the Congo", value: "DRC", center: [23.174338, -5.837475], scale: 1250 }, { label: "World", value: "World", center: [0, 20.050043], scale: 150 } ], Ka = (n) => /* @__PURE__ */ r(qa, { ...n }), qa = (n) => { var R; const { unique: c, editing: s, "data-filters": P = "{}", "data-app": i = "csv", "data-csv": k = "", "data-dimension1": E = "", "data-dimension2": M = "", "data-measures": u = '["prevalenceSmokeAny"]', "data-height": O = 600, width: V = 960, "data-data-source-text": W = "NIDS", "data-data-source-label": G = "Source", "data-national-average-label": j = "National Prevalence Avg", "data-legend-title": Z = "Tobacco Prevalence Rate", "data-legend-breaks": H = "[]", "data-zoom-enabled": g = !1, "data-show-legend-labels": h = !1, "data-map-file": J, "data-mapping-field": K = "zone", "data-map-label-field": q = "admin", "data-has-multiple-measures": v = "false", topoJSONField: Y = "collection", "data-map-center": $ = "NGA", //country "data-map-label-show-value": y = "false", "data-show-tooltip": C = "true", "data-measure-selector-label": Q = "", "data-value-format": X = "", "data-show-overall-value": F = "false", "data-auto-generate-breaks": L = "false", "data-number-of-breaks": _ = 5, "data-scheme": aa = "reds", "data-show-no-data-label": w = "false", "data-group": S = "default", "data-map-symbols": ea = "[]", "data-tooltip-theme": ta = "map-tooltip-dark", "data-label-font-size": oa = 12, "data-label-font-weight": la = "normal", "data-label-font-color": ra = "#595959", "data-legend-font-size": na = 12, "data-legend-font-weight": sa = "normal", "data-custom-tooltips": ia = "[]", "data-format-style": p = "decimal", "data-decimals": D = "2", "data-currency": da = "", "data-tooltip-font-size": ma = 14, "data-show-admin-unit-label": ca = "showAll", "data-map-no-data-color": ua = "#f8f8f8", "data-map-boundary-color": pa = "#000", "data-map-focus-boundary-color": fa = "#000", "data-highlighted-location": ba = "", "data-tooltip-format": ga = `{locationName} %({value},2) {label}: %({value},2)`, "data-show-no-data-tooltip": I = "false", "data-map-container-bg-color": ha = "#fff", "data-map-position": va = "{}", "data-main-layer-id": ya = "", "data-enabled-layers": Ca, "data-point-label-color": Fa = "#fff", "data-point-label-format": La = "{locationName} %({value},2)", "data-show-no-data-legend-item": N = !1, "data-highlighted-loc-label-format": wa = "{locationName} - Score: #({value},2)", "data-enable-summary-view": Qa = "false", "data-map-type": z = "DEFAULT", "data-default-point-color": Sa = "#FFFF00", "data-aggregation-formula": Da = "COUNT", "data-zoom-level-to-show-points": Ia = 2, "data-zoom-on-filter": T = "false", "data-zoom-on-filter-field": Na = "", "data-no-data-text": za = "No Data", "data-labels-exclusion-list": Ta = "", "data-custom-measure-labels": xa = "{}", "data-show-shading-layer-labels": Aa = "ifUnitHasData", "data-dvz-proxy-dataset-id": f, "data-recently-toggled-layer-id": Ua = null, intl: Xa, settings: _a } = n, Ra = (a) => s ? a : decodeURIComponent(a), o = (a) => { try { if (a) return JSON.parse(Ra(a)); } catch { console.error("error parsing value:" + a); } return null; }, Ba = (a) => { let t = o(a) || []; return t = t.map((e) => (e.min && (e.min = parseFloat(e.min)), e.max && (e.max = parseFloat(e.max)), e.color = decodeURIComponent(e.color), e)), t; }, Pa = (a) => { const t = o(a) || []; let e = {}; return t && t.forEach ? t.forEach((m) => { m.value != null && m.value.filter((B) => B != null && B.toString().trim() != "").length > 0 && (e[m.param] = m.value); }) : e = t, e; }, ka = { style: p === "compacted" ? "decimal" : p, notation: p === "compacted" ? "compact" : "standard", currency: da, minimumFractionDigits: parseInt(D), maximumFractionDigits: parseInt(D) }; let b = o(Ca) || []; b = b.map((a) => (a.bgColor = decodeURIComponent(a.bgColor), a.fontColor = decodeURIComponent(a.fontColor), a)); const x = Ja.find((a) => a.value === $), A = v == !0 || v == "true"; let l = [E, M].filter((a) => a != "none" && a != null).join("/"); const d = { unique: c, editing: s, source: `/${J}`, center: x.center, scale: x.scale, measures: u, legendTitle: Z, height: O, width: V, topoJSONField: Y, mappingField: K, dataSourceText: W, dataSourceLabel: G, nationalAverageLabel: j, legendBreaks: Ba(H), mapLabelField: q, zoomEnabled: g == !0 || g == "true", showLegendLabels: h == !0 || h == "true", multipleMeasures: A, app: i, mapLabelShowValue: y == !0 || y == "true", showTooltip: C == !0 || C == "true", showOverallValue: F == !0 || F == "true", measureSelectorLabel: Q, valueFormat: X, autoGenerateBreaks: L == !0 || L == "true", showNoDataLabel: w == !0 || w == "true", numberOfBreaks: _, colorScheme: aa, group: S, symbols: o(ea) || [], tooltipTheme: ta, labelFontSize: oa, labelFontColor: decodeURIComponent(ra), labelFontWeight: la, legendFontSize: na, legendFontWeight: sa, customTooltips: o(ia) || [], format: ka, tooltipFontSize: ma, showAdminUnitLabel: ca, mapNoDataColor: decodeURIComponent(ua), mapBoundaryColor: decodeURIComponent(pa), mapFocusBoundaryColor: decodeURIComponent(fa), highlightedLocation: ba, tooltipFormat: ga, showNoDataTooltip: I == !0 || I == "true", fields: l.split("/"), mapContainerBgColor: decodeURIComponent(ha), mapPosition: o(va), mainLayerId: ya, enabledLayers: b, pointLabelColor: decodeURIComponent(Fa), pointLabelFormat: La, showNoDataLegendItem: N == !0 || N == "true", highlightedLocLabelFormat: wa, mapType: z, defaultPointColor: decodeURIComponent(Sa), zoomLevelToShowPoints: Ia, zoomOnFilter: T == !0 || T == "true", zoomOnFilterField: Na, noDataText: za, labelsExclusionList: Ta.split(",").map((a) => a.trim()), showShadingLayerLabels: Aa, dvzProxyDatasetId: f, recentlyToggledLayerId: Ua }; if (d.recentlyToggledLayerId) { const a = d.enabledLayers.find((t) => String(t.id) === String(d.recentlyToggledLayerId)); a && (a != null && a.apiField) && (l = (R = a.apiField) == null ? void 0 : R.toLowerCase()); } const Ea = o(xa) || {}, Ma = i === "csv" ? Ha : Za, Oa = s ? (o(u) || []).join(",") : u, U = Pa(P); return f && (U.dvzProxyDatasetId = f), /* @__PURE__ */ r( Wa, { params: U, app: i, csv: decodeURIComponent(k), group: S, editing: s, store: [i, c, ...l.split("/")], source: l, children: /* @__PURE__ */ r(Ga, { children: /* @__PURE__ */ r( Ma, { measures: Oa, multipleMeasures: A, mapType: z, aggregationFormula: Da, customMeasureLabels: Ea, source: l, children: /* @__PURE__ */ r(ja, { ...d }) } ) }) } ); }, Ya = (n, c) => ({}), $a = {}, de = Va(Ya, $a)(Ka); export { de as default };