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.

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