UNPKG

@swplabs/peanutforwp

Version:

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

232 lines (213 loc) 8.14 kB
/******/ (() => { // webpackBootstrap /******/ "use strict"; /******/ // The require scope /******/ var __webpack_require__ = {}; /******/ /************************************************************************/ /******/ /* webpack/runtime/define property getters */ /******/ (() => { /******/ // define getter functions for harmony exports /******/ __webpack_require__.d = (exports, definition) => { /******/ for(var key in definition) { /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); /******/ } /******/ } /******/ }; /******/ })(); /******/ /******/ /* webpack/runtime/hasOwnProperty shorthand */ /******/ (() => { /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) /******/ })(); /******/ /******/ /* webpack/runtime/make namespace object */ /******/ (() => { /******/ // define __esModule on exports /******/ __webpack_require__.r = (exports) => { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ })(); /******/ /************************************************************************/ var __webpack_exports__ = {}; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { "default": () => (/* binding */ render) }); ;// external "react" const external_react_namespaceObject = require("react"); ;// ./src/whiteboard/shared/components/nav/style.scss // extracted by mini-css-extract-plugin /* harmony default export */ const style = ({"container":"S4hWIlXNeewjFMsxpc_q","logo":"EMQy6anCHA1dsfgE9v9U","menu":"wpW1tZDi2fOHXhpNVLbT","navItem":"HoSEzJ7edIcGxFWgXnxN","icon":"ng23xQB4ObsDZEwTJv7f"}); ;// external "react/jsx-runtime" const jsx_runtime_namespaceObject = require("react/jsx-runtime"); ;// ./src/whiteboard/shared/components/nav/view.js const Nav = ({ pfwpConfig: { wp_host, compilations: { components_elements: { entry_map: entryMap // TODO: use metadata for link params // metadata } } }, setScreen }) => { const updateScreen = (e, key, url) => { e.preventDefault(); console.log('nav clicked item', key, url); setScreen({ key, url }); }; return /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsxs)("div", { className: style.container, children: [/*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)("div", { className: style.logo, children: "peanut (wb)" }), /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)("div", { className: style.menu, children: /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)("ul", { children: Object.keys(entryMap).map(key => { return /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)("li", { className: style.navItem, children: /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsxs)("a", { href: `${wp_host}/_pfwp_wb/components/${key}/`, onClick: e => updateScreen(e, key, `${wp_host}/_pfwp_wb/components/${key}/`), children: [/*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)("i", { className: `${style.icon} bi-puzzle` }), /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)("span", { children: key })] }) }, key); }) }) })] }); }; /* harmony default export */ const view = (Nav); ;// ./src/whiteboard/shared/components/json-form/view.js const JsonForm = ({ schema }) => { return schema?.$schema ? /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)("pre", { children: JSON.stringify(schema, null, 2) }) : null; }; /* harmony default export */ const json_form_view = (JsonForm); ;// ./src/whiteboard/shared/components/schema/style.scss // extracted by mini-css-extract-plugin /* harmony default export */ const schema_style = ({"container":"ArcVRN2y_Y6ybrEraW_r","header":"o5Ly6HErIHWDR9v7nMLI","schemaControls":"NhCobWPsiBPH3EpHmiI0","jsonSchemaContainer":"ALxOh5iArURuBYvchv6H","icon":"K4S7yFywBHJdhPilzPwT"}); ;// ./src/whiteboard/shared/components/schema/view.js const Schema = ({ pfwpConfig: { wp_host }, screen }) => { const { key: screenKey } = screen; const [loading, setLoading] = (0,external_react_namespaceObject.useState)(false); const [metadata, setMetadata] = (0,external_react_namespaceObject.useState)({}); (0,external_react_namespaceObject.useEffect)(() => { if (!screenKey) return; setLoading(true); const fetchData = async () => { try { const response = await fetch(`${wp_host}/wp-json/pfwp/v1/metadata/${screenKey}/`); const data = await response.json(); console.log('fetchData', screenKey, data); setMetadata(data?.data_schema || {}); } catch (error) { console.error(error); } setLoading(false); }; fetchData(); }, [screenKey, wp_host]); return loading ? /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)("div", { className: schema_style.container, children: "Loading..." }) : /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsxs)("div", { className: schema_style.container, children: [/*#__PURE__*/(0,jsx_runtime_namespaceObject.jsxs)("div", { className: schema_style.header, children: [/*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)("div", { children: screenKey || 'Choose a component' }), /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)("div", { className: schema_style.schemaControls, children: /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)("i", { className: `${schema_style.icon} bi-layout-sidebar-reverse` }) })] }), /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)("div", { className: schema_style.jsonSchemaContainer, children: /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)(json_form_view, { schema: metadata }) })] }); }; /* harmony default export */ const schema_view = (Schema); ;// ./src/whiteboard/shared/components/screen/style.scss // extracted by mini-css-extract-plugin /* harmony default export */ const screen_style = ({"container":"P40qygH23w1Jmbk80yC7","screen":"eUDMmeQEnnqFjLulT8JA"}); ;// ./src/whiteboard/shared/components/screen/view.js const Screen = ({ screen }) => { const { url: screenUrl = 'about:blank' } = screen; return /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)("div", { className: screen_style.container, children: /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)("iframe", { src: screenUrl, className: screen_style.screen }) }); }; /* harmony default export */ const screen_view = (Screen); ;// ./src/whiteboard/shared/components/app/style.scss // extracted by mini-css-extract-plugin /* harmony default export */ const app_style = ({"container":"a3H0F77HN88gsKICCPXX"}); ;// ./src/whiteboard/shared/components/app/view.js const App = ({ config }) => { const [screen, setScreen] = (0,external_react_namespaceObject.useState)({}); return /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsxs)("div", { className: app_style.container, children: [/*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)(view, { pfwpConfig: config, setScreen: setScreen }), /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)(screen_view, { screen: screen }), /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)(schema_view, { pfwpConfig: config, screen: screen, setScreen: setScreen })] }); }; /* harmony default export */ const app_view = (App); ;// ./src/whiteboard/shared/routes/app/render.js /* harmony default export */ const render = (({ config }) => /*#__PURE__*/(0,jsx_runtime_namespaceObject.jsx)(app_view, { config: config })); module.exports = __webpack_exports__; /******/ })() ;