Jake Vanderwerf
2026-09-18 a6413da67a4579866f0fd0323ddb23a7b6b9654a
1
(()=>{"use strict";var e={604(){const e=window.wp.blocks,s=window.wp.blockEditor,n=window.wp.components,i=window.wp.i18n,o=window.wp.element,t=window.ReactJSXRuntime;(0,e.registerBlockType)("jvb/faq",{edit:function({attributes:e,setAttributes:l}){const{sectionOrder:a,showSectionTitles:c,collapseByDefault:r}=e,[d,h]=(0,o.useState)([]),p=window.jvbFaq?.sections||[];(0,o.useEffect)(()=>{if(p.length)if(0===a.length){const e=p.map(e=>({id:e.id,name:e.name}));h(e),l({sectionOrder:e.map(e=>e.id)})}else{const e=[],s=new Set(a);a.forEach(s=>{const n=p.find(e=>e.id===s);n&&e.push({id:n.id,name:n.name})}),p.forEach(n=>{s.has(n.id)||e.push({id:n.id,name:n.name})}),h(e)}},[p,a]);const b=(e,s)=>{const n=[...d],i="up"===s?e-1:e+1;i<0||i>=n.length||([n[e],n[i]]=[n[i],n[e]],h(n),l({sectionOrder:n.map(e=>e.id)}))},j=(0,s.useBlockProps)({className:"faq-block-editor"});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(s.InspectorControls,{children:[(0,t.jsxs)(n.PanelBody,{title:(0,i.__)("FAQ Settings","jvb"),initialOpen:!0,children:[(0,t.jsx)(n.ToggleControl,{label:(0,i.__)("Show Section Titles","jvb"),checked:c,onChange:e=>l({showSectionTitles:e}),help:(0,i.__)("Display section names as headings","jvb")}),(0,t.jsx)(n.ToggleControl,{label:(0,i.__)("Collapse by Default","jvb"),checked:r,onChange:e=>l({collapseByDefault:e}),help:(0,i.__)("Questions start collapsed and expand on click","jvb")})]}),(0,t.jsxs)(n.PanelBody,{title:(0,i.__)("Section Order","jvb"),initialOpen:!1,children:[(0,t.jsx)("p",{className:"components-base-control__help",children:(0,i.__)("Use the arrow buttons to reorder sections","jvb")}),d.length>0?(0,t.jsx)("div",{className:"faq-section-list",children:d.map((e,s)=>(0,t.jsxs)("div",{className:"faq-section-item",children:[(0,t.jsxs)("div",{className:"faq-section-controls",children:[(0,t.jsx)(n.Button,{icon:"arrow-up-alt2",label:(0,i.__)("Move up","jvb"),disabled:0===s,onClick:()=>b(s,"up"),className:"faq-section-button"}),(0,t.jsx)(n.Button,{icon:"arrow-down-alt2",label:(0,i.__)("Move down","jvb"),disabled:s===d.length-1,onClick:()=>b(s,"down"),className:"faq-section-button"})]}),(0,t.jsx)("span",{className:"faq-section-name",children:e.name})]},e.id))}):(0,t.jsx)(n.Notice,{status:"info",isDismissible:!1,children:(0,i.__)("No sections found. Create sections in the FAQ taxonomy.","jvb")})]})]}),(0,t.jsx)("div",{...j,children:(0,t.jsxs)("div",{className:"faq-block-preview",children:[(0,t.jsx)("h3",{children:(0,i.__)("FAQ Block","jvb")}),(0,t.jsx)("p",{children:(0,i.__)("This block will display FAQs organized by sections.","jvb")}),d.length>0?(0,t.jsxs)("div",{className:"faq-sections-preview",children:[(0,t.jsx)("strong",{children:(0,i.__)("Section Order:","jvb")}),(0,t.jsx)("ol",{children:d.map(e=>(0,t.jsx)("li",{children:e.name},e.id))})]}):(0,t.jsx)(n.Notice,{status:"warning",isDismissible:!1,children:(0,i.__)("No sections available. Create sections in the FAQ taxonomy.","jvb")})]})})]})},save:()=>null})}};const s={};function n(i){const o=s[i];if(void 0!==o)return o.exports;const t=s[i]={exports:{}};return e[i](t,t.exports,n),t.exports}n.m=e,(()=>{const e=[];n.O=(s,i,o,t)=>{if(i){t||=0;for(var l=e.length;l>0&&e[l-1][2]>t;l--)e[l]=e[l-1];return void(e[l]=[i,o,t])}let a=1/0;for(l=0;l<e.length;l++){let[i,o,t]=e[l],r=!0;for(var c=0;c<i.length;c++)1&t&&!(a>=t)||!Object.keys(n.O).every(e=>n.O[e](i[c]))?(r=!1,t<a&&(a=t)):i.splice(c--,1);if(r){e.splice(l--,1);const n=o();void 0!==n&&(s=n)}}return s}})(),n.o=(e,s)=>Object.hasOwn(e,s),(()=>{const e={456:0,656:0};n.O.j=s=>0===e[s];const s=(s,i)=>{let[o,t,l]=i;var a,c,r=0;if(o.some(s=>0!==e[s])){for(a in t)n.o(t,a)&&(n.m[a]=t[a]);if(l)var d=l(n)}for(s&&s(i);r<o.length;r++)c=o[r],n.o(e,c)&&e[c]&&e[c][0](),e[c]=0;return n.O(d)},i=globalThis.webpackChunkjvb||=[];i.forEach(s.bind(null,0)),i.push=s.bind(null,i.push.bind(i))})();let i=n.O(void 0,[656],()=>n(604));i=n.O(i)})();