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