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.

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