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