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.

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