UNPKG

@swplabs/peanutforwp

Version:

Peanut for WordPress. Build your themes and blocks with components.

2 lines 3.49 kB
/*! For license information please see view_whiteboard_app.js.LICENSE.txt */ (()=>{"use strict";var e={338:(e,s,r)=>{var t=r(206);t.createRoot,s.c=t.hydrateRoot},20:(e,s,r)=>{var t=r(594),n=Symbol.for("react.element"),o=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function i(e,s,r){var t,i={},l=null,p=null;for(t in void 0!==r&&(l=""+r),void 0!==s.key&&(l=""+s.key),void 0!==s.ref&&(p=s.ref),s)o.call(s,t)&&!c.hasOwnProperty(t)&&(i[t]=s[t]);if(e&&e.defaultProps)for(t in s=e.defaultProps)void 0===i[t]&&(i[t]=s[t]);return{$$typeof:n,type:e,key:l,ref:p,props:i,_owner:a.current}}s.jsx=i,s.jsxs=i},848:(e,s,r)=>{e.exports=r(20)},594:e=>{e.exports=React},206:e=>{e.exports=ReactDOM}},s={};function r(t){var n=s[t];if(void 0!==n)return n.exports;var o=s[t]={exports:{}};return e[t](o,o.exports,r),o.exports}r.d=(e,s)=>{for(var t in s)r.o(s,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:s[t]})},r.o=(e,s)=>Object.prototype.hasOwnProperty.call(e,s),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};r.r(t),r.d(t,{default:()=>m});var n=r(338),o=r(594);var a=r(848);const c=({pfwpConfig:{wp_host:e,compilations:{components_elements:{entry_map:s}}},setScreen:r})=>(0,a.jsxs)("div",{className:"S4hWIlXNeewjFMsxpc_q",children:[(0,a.jsx)("div",{className:"EMQy6anCHA1dsfgE9v9U",children:"peanut (wb)"}),(0,a.jsx)("div",{className:"wpW1tZDi2fOHXhpNVLbT",children:(0,a.jsx)("ul",{children:Object.keys(s).map((s=>(0,a.jsx)("li",{className:"HoSEzJ7edIcGxFWgXnxN",children:(0,a.jsxs)("a",{href:`${e}/_pfwp_wb/components/${s}/`,onClick:t=>((e,s,t)=>{e.preventDefault(),console.log("nav clicked item",s,t),r({key:s,url:t})})(t,s,`${e}/_pfwp_wb/components/${s}/`),children:[(0,a.jsx)("i",{className:"ng23xQB4ObsDZEwTJv7f bi-puzzle"}),(0,a.jsx)("span",{children:s})]})},s)))})})]}),i=({schema:e})=>e?.$schema?(0,a.jsx)("pre",{children:JSON.stringify(e,null,2)}):null,l="ArcVRN2y_Y6ybrEraW_r",p=({pfwpConfig:{wp_host:e},screen:s})=>{const{key:r}=s,[t,n]=(0,o.useState)(!1),[c,p]=(0,o.useState)({});return(0,o.useEffect)((()=>{r&&(n(!0),(async()=>{try{const s=await fetch(`${e}/wp-json/pfwp/v1/metadata/${r}/`),t=await s.json();console.log("fetchData",r,t),p(t?.data_schema||{})}catch(e){console.error(e)}n(!1)})())}),[r,e]),t?(0,a.jsx)("div",{className:l,children:"Loading..."}):(0,a.jsxs)("div",{className:l,children:[(0,a.jsxs)("div",{className:"o5Ly6HErIHWDR9v7nMLI",children:[(0,a.jsx)("div",{children:r||"Choose a component"}),(0,a.jsx)("div",{className:"NhCobWPsiBPH3EpHmiI0",children:(0,a.jsx)("i",{className:"K4S7yFywBHJdhPilzPwT bi-layout-sidebar-reverse"})})]}),(0,a.jsx)("div",{className:"ALxOh5iArURuBYvchv6H",children:(0,a.jsx)(i,{schema:c})})]})},d=({screen:e})=>{const{url:s="about:blank"}=e;return(0,a.jsx)("div",{className:"P40qygH23w1Jmbk80yC7",children:(0,a.jsx)("iframe",{src:s,className:"eUDMmeQEnnqFjLulT8JA"})})},f=({config:e})=>{const[s,r]=(0,o.useState)({});return(0,a.jsxs)("div",{className:"a3H0F77HN88gsKICCPXX",children:[(0,a.jsx)(c,{pfwpConfig:e,setScreen:r}),(0,a.jsx)(d,{screen:s}),(0,a.jsx)(p,{pfwpConfig:e,screen:s,setScreen:r})]})},m=({root:e,config:s})=>(0,n.c)(e||document.getElementById("root"),(0,a.jsx)(f,{config:s}));(window.peanutSrcClientJs=window.peanutSrcClientJs||{}).view_whiteboard_app=t})();