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.

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