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.

67 lines (66 loc) 2.9 kB
import { jsxs as p, jsx as n } from "react/jsx-runtime"; import { useState as a, useEffect as f } from "react"; import { Container as T, Grid as E, GridColumn as y, GridRow as R } from "semantic-ui-react"; import { connect as C } from "react-redux"; import { useWindowDimensionsAndDevice as O } from "../../lib/hooks/window-dimensions.js"; const S = ({ content: r, link: t, index: i }) => /* @__PURE__ */ n(y, { children: /* @__PURE__ */ p(R, { id: "ref_" + i, className: "reference", children: [ /* @__PURE__ */ n("div", { className: "index", children: i }), /* @__PURE__ */ n("div", { className: "content", children: r }), /* @__PURE__ */ n("div", { className: "link", children: /* @__PURE__ */ n("a", { href: t, target: "_blank", children: t }) }) ] }) }), W = (r) => { let t; try { t = decodeURIComponent(r); } catch { t = r, console.error("error occurred decoding content:" + r); } return t; }, P = ({ random: r, editing: t = !1, "data-columns": i = 3, "data-height": w = 1e3, "data-flex-direction": c = "row" }) => { const { width: b } = O(), [z, g] = a(window.innerWidth > window.innerHeight ? "landscape" : "portrait"), [l, I] = a(b < 1380); f(() => { const e = () => { g(window.innerWidth > window.innerHeight ? "landscape" : "portrait"), I(window.innerWidth < 1380); }; return window.addEventListener("resize", e), () => window.removeEventListener("resize", e); }, []); const m = { flexDirection: c }, [u, v] = a([]); c == "column" && i > 1 && (m.height = w + "px"), f(() => { try { setTimeout(() => { const e = window.parent.document.querySelectorAll("div.wp-reference"); v(e); }, 3e3); } catch { } }); const A = u ? new Array(...u) : [], s = []; return A.forEach((e) => { s.find((d) => d.getAttribute("data-index") == e.getAttribute("data-index")) || s.push(e); }), /* @__PURE__ */ p(T, { className: "references list", children: [ t && /* @__PURE__ */ n("div", { className: "edit-mode-message", children: /* @__PURE__ */ n("p", { children: "No preview available. The full list of references will be displayed in the live page." }) }), /* @__PURE__ */ n(E, { fluid: !0, stretched: !!l, columns: l ? 1 : i, style: m, children: s.sort((e, o) => { const d = e.getAttribute("data-index") ?? "", h = o.getAttribute("data-index") ?? "", N = d ? parseInt(d) : Number.POSITIVE_INFINITY, x = h ? parseInt(h) : Number.POSITIVE_INFINITY; return N - x; }).map((e) => { const o = e.getAttribute("data-index") ?? ""; return /* @__PURE__ */ n( S, { index: o, content: W(e.getAttribute("data-description")), link: e.getAttribute("data-link") }, o ); }) }) ] }); }, _ = (r, t) => ({ random: r.getIn(["embeddable", "random"]) }), k = {}, F = C(_, k)(P); export { F as default };