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.

41 lines (40 loc) 2.02 kB
import { jsx as r, jsxs as c } from "react/jsx-runtime"; import u from "react"; import { connect as S } from "react-redux"; import { injectIntl as C } from "react-intl"; import { CategoriesContext as D } from "./DataContext.js"; import { getCategories as v } from "../reducers/data.js"; import { Container as h, Segment as l } from "semantic-ui-react"; class x extends u.Component { componentDidMount() { const { categories: t } = this.props; !t && !this.props.loading && this.props.onLoadData(this.props); } componentDidUpdate(t, s, n) { const { app: e, filters: a, source: o, store: m, params: p, csv: d, group: g, editing: f } = this.props; (a != t.filters || JSON.stringify(p) != JSON.stringify(t.params) || e != t.app || t.source != o || d != t.csv) && (e === "csv" ? this.props.onSetData({ app: e, csv: d, store: m, params: p, group: g }) : (f && (p.v = (Math.random() + 1).toString(36).substring(7)), this.setState({ showLoading: !1 }), this.props.onLoadData(this.props), setTimeout(this.checkLoadingTime, 100))); } render() { const { data: t, loading: s, error: n } = this.props; return s ? /* @__PURE__ */ r(h, {}) : t ? /* @__PURE__ */ r(D.Provider, { value: t.toJS(), children: this.props.children }) : n ? /* @__PURE__ */ c(l, { color: "red", children: [ /* @__PURE__ */ r("h1", { children: "500" }), /* @__PURE__ */ r("p", { children: "Wasn't able to load data" }) ] }) : /* @__PURE__ */ r(h, { children: /* @__PURE__ */ c(l, { color: "red", children: [ /* @__PURE__ */ r("h1", { children: "404" }), /* @__PURE__ */ r("p", { children: "Can't find this page" }) ] }) }); } } const I = (i, t) => { const { app: s, params: n, dvzProxyDatasetId: e, uniqueStorage: a } = t, o = ["data", "categories", s]; return e && o.push(e), a && o.push(a), { data: i.getIn([...o, "items"]), error: i.getIn([...o, "error"]), loading: i.getIn([...o, "loading"]) }; }, L = { onLoadData: v }, O = S(I, L)(C(x)); export { O as default };