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.

84 lines (83 loc) 3.56 kB
import { jsx as n, jsxs as O } from "react/jsx-runtime"; import { useState as P, useRef as C, useEffect as T } from "react"; import { connect as J } from "react-redux"; import { injectIntl as z } from "react-intl"; import { DataContext as E } from "./DataContext.js"; import { getData as R, setData as W } from "../reducers/data.js"; import { Container as y, Segment as v, Dimmer as $, Loader as q } from "semantic-ui-react"; const B = (a) => { const { app: e, source: r, store: i, params: t, csv: s, group: d, editing: j, style: u, isSvg: x, children: L, data: N, filters: p, autoApply: S, apply: l, error: D, loading: m, time: b, onSetData: I, onLoadData: h } = a, [k, f] = P(!1), o = C({ filters: p, params: t, app: e, source: r, csv: s, apply: l }), g = () => { const c = Date.now() - b; m && b && c > 1e3 ? f(!0) : m && setTimeout(g, 100); }; if (T(() => { e === "csv" ? I({ app: e, csv: s, store: i, params: t, group: d }) : (f(!1), h({ app: e, source: r, store: i, params: t, group: d }), setTimeout(g, 100)); }, []), T(() => { let c = !1; l != null && l !== o.current.apply && (c = !0), S !== !1 ? (p !== o.current.filters || JSON.stringify(t) !== JSON.stringify(o.current.params) || e !== o.current.app || JSON.stringify(r) !== JSON.stringify(o.current.source) || s !== o.current.csv) && (e === "csv" ? I({ app: e, csv: s, store: i, params: t, group: d }) : (f(!1), h({ app: e, source: r, store: i, params: t, group: d }), setTimeout(g, 100))) : c && (h({ app: e, source: r, store: i, params: t, group: d }), f(!1), setTimeout(g, 100)), o.current = { filters: p, params: t, app: e, source: r, csv: s, apply: l }; }, [p, t, e, r, s, l, S]), m && k && !j) { const c = { width: "100%", height: "100%", background: "transparent", verticalAlign: "middle", overflow: "hidden" }, w = Object.assign({}, u, { height: "90%", background: "transparent", textAlign: "center", margin: "30px" }), A = /* @__PURE__ */ n(v, { basic: !0, padded: !0, style: w, children: /* @__PURE__ */ n($, { active: !0, inverted: !0, style: { background: "transparent" }, children: /* @__PURE__ */ n(q, { size: "medium", style: { background: "transparent" } }) }) }); return x ? /* @__PURE__ */ n("foreignObject", { style: c, children: /* @__PURE__ */ n(y, { style: u, className: "loading", children: A }) }) : /* @__PURE__ */ n(y, { style: u, className: "loading", children: A }); } else return D ? D ? /* @__PURE__ */ O(v, { color: "red", children: [ /* @__PURE__ */ n("h1", { children: "500" }), /* @__PURE__ */ n("p", { children: "Wasn't able to load data" }) ] }) : /* @__PURE__ */ n(y, { children: /* @__PURE__ */ O(v, { color: "red", children: [ /* @__PURE__ */ n("h1", { children: "404" }), /* @__PURE__ */ n("p", { children: "Can't find this page" }) ] }) }) : /* @__PURE__ */ n(E.Provider, { value: N, children: L }); }, F = (a, e) => { const { store: r, group: i, app: t } = e; return { data: a.getIn(["data", ...r, "data"]), filters: a.getIn(["data", "filters", t, i]), autoApply: a.getIn(["data", "filters-settings", t, i, "autoApply"]), apply: a.getIn(["data", "filters-settings", t, i, "apply"]), error: a.getIn(["data", ...r, "error"]), loading: a.getIn(["data", ...r, "loading"]), time: a.getIn(["data", ...r, "time"]) }; }, G = { onSetData: W, onLoadData: R }, Y = J(F, G)(z(B)); export { Y as default };