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.

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