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) 1.41 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),r=require("react"),o=require("react-router"),u=require("semantic-ui-react"),g=require("@devgateway/wp-react-lib"),w=require("../embeddable/index.js"),f=()=>{const m=o.useParams();o.useLocation();const[a]=r.useState(()=>w.getComponentByNameIgnoreCase(m.name??""));let[n,d]=o.useSearchParams();const i=l=>{console.log("-------------------------------reading message ----------------------------------------");const t=l.data;if(t.messageType&&t.messageType=="component-attributes"){const c={...n};Object.keys(t).forEach(s=>{c["data-"+s.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()]=typeof t[s]=="object"?JSON.stringify(t[s]):t[s]}),d(c)}};r.useEffect(()=>(window.addEventListener("message",i,!1),window.parent&&window.parent.postMessage({type:"componentReady",value:!0},"*"),window.top&&window.top.postMessage({type:"componentReady",value:!0},"*"),()=>{window.removeEventListener("message",i)}),[]);const p=r.useMemo(()=>Object.fromEntries(n.entries()),[n]);return e.jsx("div",{children:e.jsx(u.Container,{fluid:!0,className:"editing",children:a?e.jsx(a,{...p,editing:!0}):e.jsx(u.Segment.Group,{color:"red",textAlign:"center",children:e.jsx("h1",{children:"Wrong Component Name"})})})})},j=()=>e.jsx(g.SettingsConsumer,{children:e.jsx(f,{})});exports.default=j;