Jake Vanderwerf
7 days ago 46d681c6b825d21b3f698d793c4e630c687d90ad
1
(()=>{"use strict";var e,t={111(e,t,n){const o=window.wp.blocks,l=window.wp.element,i=window.wp.blockEditor,r=window.wp.components,s=window.wp.apiFetch;var c=n.n(s);const a=window.wp.i18n,d=window.ReactJSXRuntime;(0,o.registerBlockType)("jvb/feed",{edit:function({attributes:e,setAttributes:t}){const[n,o]=(0,l.useState)(null),[s,h]=(0,l.useState)(!0),[p,j]=(0,l.useState)(null),x=(0,i.useBlockProps)({className:"feed-block-editor"});(0,l.useEffect)(()=>{c()({path:"/jvb/v1/feed/types",headers:{"If-Modified-Since":localStorage.getItem("feed_types_modified")}}).then(n=>{if(o(n),h(!1),!e.contentTypes&&!e.inheritQuery){const e=Object.keys(n)[0];e&&t({contentTypes:[e]})}}).catch(e=>{console.error("Error loading feed types:",e),j(e.message),h(!1)})},[e.inheritQuery]);const y=(n,o)=>{const l=e.contentTypes||[],i=o?[...l,n]:l.filter(e=>e!==n);t({contentTypes:i})},b=(e,t)=>`${t.plural} (${t.type})`,g=n?{content:Object.entries(n).filter(([e,t])=>"content"===t.type),taxonomy:Object.entries(n).filter(([e,t])=>"taxonomy"===t.type)}:{content:[],taxonomy:[]};return(0,d.jsxs)("div",{...x,children:[(0,d.jsxs)(i.InspectorControls,{children:[(0,d.jsxs)(r.PanelBody,{title:(0,a.__)("Feed Settings","jvb"),initialOpen:!0,children:[(0,d.jsx)(r.ToggleControl,{label:(0,a.__)("Inherit from Page Context","jvb"),help:e.inheritQuery?(0,a.__)("Feed will adapt to the current page (profile, taxonomy, etc.)","jvb"):(0,a.__)("Manually select content types to display","jvb"),checked:e.inheritQuery,onChange:e=>t({inheritQuery:e})}),!e.inheritQuery&&(0,d.jsxs)(d.Fragment,{children:[s&&(0,d.jsxs)("div",{style:{textAlign:"center",padding:"20px"},children:[(0,d.jsx)(r.Spinner,{}),(0,d.jsx)("p",{children:(0,a.__)("Loading feed types...","jvb")})]}),p&&(0,d.jsxs)(r.Notice,{status:"error",isDismissible:!1,children:[(0,a.__)("Error loading feed types: ","jvb")," ",p]}),!s&&!p&&n&&(0,d.jsxs)(d.Fragment,{children:[g.content.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("h4",{children:(0,a.__)("Content Types","jvb")}),g.content.map(([t,n])=>(0,d.jsx)(r.CheckboxControl,{label:b(0,n),checked:e.contentTypes?.includes(t)||!1,onChange:e=>y(t,e),help:n.taxonomies?.length>0?`Filters: ${n.taxonomies.join(", ")}`:null},t))]}),g.taxonomy.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("h4",{style:{marginTop:"20px"},children:(0,a.__)("Content Taxonomies","jvb")}),(0,d.jsx)("p",{style:{fontSize:"12px",color:"#757575"},children:(0,a.__)("These are collections that group other content","jvb")}),g.taxonomy.map(([t,n])=>(0,d.jsx)(r.CheckboxControl,{label:b(0,n),checked:e.contentTypes?.includes(t)||!1,onChange:e=>y(t,e),help:n.for_content?.length>0?`Contains: ${n.for_content.join(", ")}`:null},t))]}),!e.contentTypes?.length&&(0,d.jsx)(r.Notice,{status:"warning",isDismissible:!1,children:(0,a.__)("Please select at least one content type","jvb")})]})]})]}),(0,d.jsx)(r.PanelBody,{title:(0,a.__)("Display Settings","jvb"),initialOpen:!1,children:(0,d.jsx)(r.ToggleControl,{label:(0,a.__)("Show Gallery View","jvb"),help:(0,a.__)("Enable lightbox for images","jvb"),checked:e.enableGallery||!1,onChange:e=>t({enableGallery:e})})})]}),(0,d.jsxs)("div",{className:"feed-block-placeholder",children:[(0,d.jsx)("div",{className:"feed-block-icon",children:(0,d.jsxs)("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",children:[(0,d.jsx)("rect",{x:"3",y:"3",width:"7",height:"7",fill:"currentColor",opacity:"0.3"}),(0,d.jsx)("rect",{x:"13",y:"3",width:"7",height:"7",fill:"currentColor",opacity:"0.3"}),(0,d.jsx)("rect",{x:"3",y:"13",width:"7",height:"7",fill:"currentColor",opacity:"0.3"}),(0,d.jsx)("rect",{x:"13",y:"13",width:"7",height:"7",fill:"currentColor",opacity:"0.3"})]})}),(0,d.jsx)("h3",{children:(0,a.__)("Feed Block","jvb")}),e.inheritQuery?(0,d.jsx)("p",{className:"feed-block-description",children:(0,a.__)("📍 Inheriting from page context","jvb")}):(0,d.jsx)("div",{className:"feed-block-description",children:e.contentTypes?.length>0?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{children:(0,d.jsx)("strong",{children:(0,a.__)("Showing:","jvb")})}),(0,d.jsx)("ul",{style:{listStyle:"none",padding:"0",margin:"8px 0"},children:e.contentTypes.map(e=>{const t=n?.[e];return(0,d.jsxs)("li",{style:{padding:"4px 0",color:"#2271b1"},children:["✓ ",t?.plural||e]},e)})})]}):(0,d.jsx)("p",{style:{color:"#d63638"},children:(0,a.__)("⚠️  No content types selected","jvb")})}),(0,d.jsx)("p",{className:"feed-block-note",children:(0,a.__)("Feed will be displayed on the frontend","jvb")})]})]})},save:function(){return null}})}},n={};function o(e){var l=n[e];if(void 0!==l)return l.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.m=t,e=[],o.O=(t,n,l,i)=>{if(!n){var r=1/0;for(d=0;d<e.length;d++){for(var[n,l,i]=e[d],s=!0,c=0;c<n.length;c++)(!1&i||r>=i)&&Object.keys(o.O).every(e=>o.O[e](n[c]))?n.splice(c--,1):(s=!1,i<r&&(r=i));if(s){e.splice(d--,1);var a=l();void 0!==a&&(t=a)}}return t}i=i||0;for(var d=e.length;d>0&&e[d-1][2]>i;d--)e[d]=e[d-1];e[d]=[n,l,i]},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={814:0,138:0};o.O.j=t=>0===e[t];var t=(t,n)=>{var l,i,[r,s,c]=n,a=0;if(r.some(t=>0!==e[t])){for(l in s)o.o(s,l)&&(o.m[l]=s[l]);if(c)var d=c(o)}for(t&&t(n);a<r.length;a++)i=r[a],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return o.O(d)},n=globalThis.webpackChunkjvb=globalThis.webpackChunkjvb||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var l=o.O(void 0,[138],()=>o(111));l=o.O(l)})();