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.

157 lines (156 loc) 4.42 kB
import { jsx as a, jsxs as B } from "react/jsx-runtime"; import { useState as f, useRef as F, useEffect as V } from "react"; import { connect as J } from "react-redux"; import { parse as i, compareJsonProps as E, decode as W } from "../utils/parseUtils.js"; import G from "./Map.js"; import H from "./BaseLayer.js"; import K from "./DataLayer.js"; import O from "./LatLongLayer.js"; import Q from "./ZoomControl.js"; import U from "./ProjectedContainer.js"; import X from "./Legends.js"; import Y from "./FlowLayer.js"; const _ = (L) => { const { unique: l, editing: r, "data-identifier": M, "data-group": c, "data-layers": g = "[]", "data-height": w = 400, "data-width": h = 1e3, "data-back-ground-color": j = "#88e8dc", "data-map-position": y = "{}", "data-projection": k = "geoMercator", "data-zoom-enabled": x = !0, "data-rotation-enabled": z = !1, "data-wait-for-filters": n = "false", intl: p } = L, [P, S] = f(i(y, r), []), [s, u] = f(i(g), []), T = F(null), d = F(null), [b, v] = f(null), [C, I] = f(null), [Z, D] = f(null); V(() => { const o = i(y, r); E(P, o) || S(o); }, [y]), V(() => { const o = i(g); E(s, o) || u(o); }, [g]); const N = (o) => { const e = s.slice(), t = e.find((m) => m.id == o); t && (t.visible = !t.visible), u(e); }, R = (o) => { const e = s.slice(), t = e.find((m) => m.id == o); t && (t.patternsVisible = t.patternsVisible == null ? !1 : !t.patternsVisible), u(e); }, q = (o) => { D(o); }, A = (o) => { const e = s.slice(), t = e.find((m) => m.id == o); t && (t.colorLayerVisible = t.colorLayerVisible == null ? !1 : !t.colorLayerVisible), u(e); }; return /* @__PURE__ */ a("div", { ref: T, className: "d3map-container", children: /* @__PURE__ */ B( U, { backgroundColor: W(j), height: w, width: h, projectionName: k, editing: r, initialPosition: P, children: [ /* @__PURE__ */ a(G, { rotationEnabled: i(z, r), children: s.map((o, e) => { if (o.type === "base") return /* @__PURE__ */ a( H, { transform: b, intl: p, zoom: d, unique: l, ...o }, e ); if (o.type === "data") return /* @__PURE__ */ a( K, { editing: r, onLayerCreated: (t) => { }, transform: b, intl: p, group: c, zoom: d, unique: l, ...o, settings: L.wordress, togglePatterns: R, initialPosition: P, waitForFilters: n == "true" || n == !0 }, e ); if (o.type === "flow") return /* @__PURE__ */ a( Y, { transform: b, intl: p, group: c, zoom: d, unique: l, ...o, waitForFilters: n == "true" || n == !0 }, e ); if (o.type === "dataPoints") return /* @__PURE__ */ a( O, { onZoomToPoint: q, selectedItem: C, transform: b, intl: p, group: c, zoom: d, unique: l, ...o, waitForFilters: n == "true" || n == !0 }, e ); }) }), /* @__PURE__ */ a( X, { selectedItem: C, d2Click: (o) => I(o), patternsData: null, layers: s, group: c, onItemClick: N, toggleColorLayer: A } ), /* @__PURE__ */ a( Q, { selectedPoint: Z, rootationEmabled: i(z, r), zoomEnabled: i(x, r), onZoomed: v, width: h, height: w, ref: d, group: c, identifier: M, editing: r } ) ] } ) }); }, $ = (L, l) => ({}), oo = {}, uo = J($, oo)(_); export { uo as default };