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.

107 lines (106 loc) 4.12 kB
import { jsx as e, jsxs as i, Fragment as T } from "react/jsx-runtime"; import v, { useState as p, useEffect as x } from "react"; import { Container as h, Grid as y, Label as R } from "semantic-ui-react"; import { PostProvider as _, PostConsumer as M, MediaProvider as S, MediaConsumer as B, PostIcon as L, utils as N } from "@devgateway/wp-react-lib"; import j from "../connected-templates/PostIntro.js"; import { useParams as E } from "react-router"; import k from "../connected-templates/PostContent.js"; const H = v.forwardRef((m, C) => { const { posts: c, showIcons: l, showContentToggle: g, contentToggleHPosition: b, locale: u } = m, [r, f] = p({}), n = C; x(() => { window.setTimeout(() => { if (window.location.hash) { const t = document.getElementById(window.location.hash.substring(1)); t && t.scrollIntoView({ behavior: "auto", block: "start" }); } }, 0); }, [c]); const w = (t) => { const o = t.content ? t.content.rendered.split("<!--more-->") : []; return o.length > 1 ? o[1] : o[0]; }, a = (t) => { const o = r[t] ?? !1, s = o ? "Read less" : "Read more"; return /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("div", { style: { position: "relative", left: b + "%" }, children: /* @__PURE__ */ e("a", { className: "link", onClick: () => { n != null && n.current && o && (n.current.scrollIntoView({ behavior: "smooth", block: "start" }), n.current.scrollTop = 0), f({ ...r, [t]: !o }); }, children: s }) }) }); }, d = (t) => { const o = t.content ? t.content.rendered.split("<!--more-->") : [], s = o.length > 1 ? o[0] : null; return s ? s.trim() : null; }, P = (t) => { const o = t.content ? t.content.rendered.split("<!--more-->") : []; return o.length > 1 && o[1].trim().length > 0; }; return /* @__PURE__ */ e(h, { fluid: !0, className: "inline list", children: c && c.map((t) => /* @__PURE__ */ i(y, { children: [ l && /* @__PURE__ */ i(y.Column, { textAlign: "center", width: 1, children: [ /* @__PURE__ */ e("a", { id: t.slug }), /* @__PURE__ */ e( S, { id: t.meta_fields && t.meta_fields.icon ? t.meta_fields.icon[0] : null, children: /* @__PURE__ */ e(B, { children: /* @__PURE__ */ e(L, { as: R }) }) } ) ] }), /* @__PURE__ */ i(y.Column, { width: l ? 15 : 16, children: [ d(t) && /* @__PURE__ */ e(j, { as: h, fluid: !0, post: t, ref: n }), !d(t) && /* @__PURE__ */ e( k, { post: { content: { rendered: w(t) } }, style: { clear: "both", display: "block" } } ), P(t) && /* @__PURE__ */ i(h, { children: [ g && /* @__PURE__ */ i(T, { children: [ !r[t.slug] && a(t.slug), /* @__PURE__ */ e( k, { post: { content: { rendered: w(t) } }, style: { clear: "both", display: r[t.slug] ? "block" : "none" } } ), r[t.slug] && a(t.slug) ] }), !g && /* @__PURE__ */ e("a", { href: N.replaceLink(t.link, u), className: "link", children: "Read More" }) ] }) ] }) ] })) }); }), D = (m) => { const [C, c] = p(Math.random() * 99998 + 1), { locale: l } = E(), { "data-width": g, "data-height": b, "data-type": u, "data-taxonomy": r, "data-categories": f, "data-items": n, "data-color": w, "data-show-post-icons": a, "data-show-content-toggle": d, "data-content-toggle-h-position": P, //horizontal position parent: t, editing: o, component: s, unique: I } = m; return /* @__PURE__ */ e(h, { fluid: !0, children: /* @__PURE__ */ e( _, { type: u, locale: l, taxonomy: r, categories: f, store: "inline_list_" + t + "_" + I, page: 1, perPage: n, children: /* @__PURE__ */ e(M, { children: /* @__PURE__ */ e(H, { locale: l ?? "en", showIcons: a === "true", showContentToggle: d === "true", contentToggleHPosition: P }) }) } ) }); }; export { D as default };