| 1 |
(()=>{"use strict";var e={24364:()=>{},24805:(e,t,n)=>{n.d(t,{A:()=>s});var a=n(51609),r=n(27723),i=n(94715),l=n(56427),o=n(36400);function s({attributes:e,setAttributes:t}){const{heading:n,headingTag:s,faqs:c,firstOpen:u,outputSchema:k,questionColor:d,answerColor:m,titleFontSize:h,itemSpacing:_,itemBackground:g,itemBorderColor:p,itemBorderRadius:f}=e,v=(0,i.useBlockProps)({className:"thinkrank-faq"}),C=s||"h2",b=Array.isArray(c)?c:[],q=(e,n,a)=>{t({faqs:b.map((t,r)=>r===e?{...t,[n]:a}:t)})},w=(e,n)=>{const a=e+n;if(a<0||a>=b.length)return;const r=[...b];[r[e],r[a]]=[r[a],r[e]],t({faqs:r})};return(0,a.createElement)(a.Fragment,null,(0,a.createElement)(i.InspectorControls,null,(0,a.createElement)(l.TabPanel,{className:"thinkrank-faq-tabs",activeClass:"is-active",tabs:[{name:"general",title:(0,r.__)("General","thinkrank")},{name:"style",title:(0,r.__)("Style","thinkrank")}]},e=>"general"===e.name?(0,a.createElement)(l.PanelBody,{title:(0,r.__)("Content","thinkrank"),initialOpen:!0},(0,a.createElement)(l.TextControl,{label:(0,r.__)("Section heading","thinkrank"),value:n,onChange:e=>t({heading:e}),placeholder:(0,r.__)("Frequently asked questions","thinkrank")}),(0,a.createElement)(l.SelectControl,{label:(0,r.__)("Heading tag","thinkrank"),value:s,options:o.f,onChange:e=>t({headingTag:e})}),(0,a.createElement)(l.ToggleControl,{label:(0,r.__)("Open first item by default","thinkrank"),checked:!!u,onChange:e=>t({firstOpen:e})}),(0,a.createElement)(l.ToggleControl,{label:(0,r.__)("Output FAQ schema (JSON-LD)","thinkrank"),help:(0,r.__)("Adds FAQPage structured data for rich results.","thinkrank"),checked:!!k,onChange:e=>t({outputSchema:e})})):(0,a.createElement)(a.Fragment,null,(0,a.createElement)(i.PanelColorSettings,{title:(0,r.__)("Colors","thinkrank"),initialOpen:!0,colorSettings:[{value:d,onChange:e=>t({questionColor:e}),label:(0,r.__)("Question","thinkrank")},{value:m,onChange:e=>t({answerColor:e}),label:(0,r.__)("Answer","thinkrank")},{value:g,onChange:e=>t({itemBackground:e}),label:(0,r.__)("Item background","thinkrank")},{value:p,onChange:e=>t({itemBorderColor:e}),label:(0,r.__)("Border","thinkrank")}]}),(0,a.createElement)(l.PanelBody,{title:(0,r.__)("Spacing & size","thinkrank"),initialOpen:!1},(0,a.createElement)(l.RangeControl,{label:(0,r.__)("Question size (px)","thinkrank"),value:h,onChange:e=>t({titleFontSize:e}),min:12,max:30}),(0,a.createElement)(l.RangeControl,{label:(0,r.__)("Space between items (px)","thinkrank"),value:_,onChange:e=>t({itemSpacing:e}),min:0,max:32}),(0,a.createElement)(l.RangeControl,{label:(0,r.__)("Corner radius (px)","thinkrank"),value:f,onChange:e=>t({itemBorderRadius:e}),min:0,max:24}))))),(0,a.createElement)("div",{...v},(0,a.createElement)(i.RichText,{tagName:C,className:"thinkrank-faq__heading",value:n,onChange:e=>t({heading:e}),placeholder:(0,r.__)("Frequently asked questions","thinkrank"),allowedFormats:[]}),b.map((n,s)=>(0,a.createElement)("div",{key:s,className:"thinkrank-faq__item thinkrank-faq__item--editing",style:(0,o.nE)(e)},(0,a.createElement)(i.RichText,{tagName:"div",className:"thinkrank-faq__question",style:(0,o.mP)(e),value:n.question,onChange:e=>q(s,"question",e),placeholder:(0,r.__)("Question…","thinkrank"),allowedFormats:["core/bold","core/italic"]}),(0,a.createElement)(i.RichText,{tagName:"div",className:"thinkrank-faq__answer",style:(0,o.W)(e),value:n.answer,onChange:e=>q(s,"answer",e),placeholder:(0,r.__)("Answer…","thinkrank")}),(0,a.createElement)("div",{className:"thinkrank-faq__item-actions"},(0,a.createElement)(l.Button,{size:"small",icon:"arrow-up-alt2",label:(0,r.__)("Move up","thinkrank"),disabled:0===s,onClick:()=>w(s,-1)}),(0,a.createElement)(l.Button,{size:"small",icon:"arrow-down-alt2",label:(0,r.__)("Move down","thinkrank"),disabled:s===b.length-1,onClick:()=>w(s,1)}),(0,a.createElement)(l.Button,{size:"small",icon:"admin-page",label:(0,r.__)("Duplicate","thinkrank"),onClick:()=>(e=>{const n=[...b];n.splice(e+1,0,{...b[e]}),t({faqs:n})})(s)}),(0,a.createElement)(l.Button,{size:"small",icon:"trash",isDestructive:!0,label:(0,r.__)("Remove","thinkrank"),disabled:b.length<=1,onClick:()=>(e=>t({faqs:b.filter((t,n)=>n!==e)}))(s)})))),(0,a.createElement)(l.Button,{variant:"secondary",icon:"plus",onClick:()=>t({faqs:[...b,{question:"",answer:""}]}),className:"thinkrank-faq__add"},(0,r.__)("Add question","thinkrank"))))}},27723:e=>{e.exports=window.wp.i18n},36400:(e,t,n)=>{n.d(t,{W:()=>l,f:()=>a,mP:()=>i,nE:()=>r});const a=[{label:"H2",value:"h2"},{label:"H3",value:"h3"},{label:"H4",value:"h4"},{label:"Paragraph",value:"p"}];function r(e){const{itemSpacing:t,itemBackground:n,itemBorderColor:a,itemBorderRadius:r}=e;return{marginBottom:`${null!=t?t:8}px`,background:n||void 0,border:`1px solid ${a||"#e2e4e7"}`,borderRadius:`${null!=r?r:6}px`}}function i(e){var t;return{color:e.questionColor||void 0,fontSize:`${null!==(t=e.titleFontSize)&&void 0!==t?t:17}px`}}function l(e){return{color:e.answerColor||void 0}}},51609:e=>{e.exports=window.React},56427:e=>{e.exports=window.wp.components},72824:(e,t,n)=>{n.d(t,{A:()=>l});var a=n(51609),r=n(94715),i=n(36400);function l({attributes:e}){const{heading:t,headingTag:n,faqs:l,firstOpen:o}=e,s=r.useBlockProps.save({className:"thinkrank-faq"}),c=n||"h2",u=(l||[]).filter(e=>e.question||e.answer);return 0===u.length?null:(0,a.createElement)("div",{...s},t?(0,a.createElement)(r.RichText.Content,{tagName:c,className:"thinkrank-faq__heading",value:t}):null,u.map((t,n)=>(0,a.createElement)("details",{key:n,className:"thinkrank-faq__item",style:(0,i.nE)(e),open:!(!o||0!==n)||void 0},(0,a.createElement)(r.RichText.Content,{tagName:"summary",className:"thinkrank-faq__question",style:(0,i.mP)(e),value:t.question}),(0,a.createElement)(r.RichText.Content,{tagName:"div",className:"thinkrank-faq__answer",style:(0,i.W)(e),value:t.answer}))))}},74997:e=>{e.exports=window.wp.blocks},94715:e=>{e.exports=window.wp.blockEditor}},t={};function n(a){var r=t[a];if(void 0!==r)return r.exports;var i=t[a]={exports:{}};return e[a](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var a=n(74997),r=n(27723),i=n(24805),l=n(72824);n(24364),(0,a.registerBlockType)("thinkrank/faq",{apiVersion:3,title:(0,r.__)("FAQ (ThinkRank)","thinkrank"),description:(0,r.__)("Add frequently asked questions as an accordion with FAQPage schema for rich results.","thinkrank"),category:"widgets",icon:"editor-help",keywords:[(0,r.__)("faq","thinkrank"),(0,r.__)("questions","thinkrank"),(0,r.__)("accordion","thinkrank"),(0,r.__)("schema","thinkrank")],supports:{html:!1,anchor:!0},attributes:{heading:{type:"string",default:""},headingTag:{type:"string",default:"h2"},faqs:{type:"array",default:[{question:"",answer:""}]},firstOpen:{type:"boolean",default:!0},outputSchema:{type:"boolean",default:!0},questionColor:{type:"string"},answerColor:{type:"string"},titleFontSize:{type:"number",default:17},itemSpacing:{type:"number",default:8},itemBackground:{type:"string"},itemBorderColor:{type:"string",default:"#e2e4e7"},itemBorderRadius:{type:"number",default:6}},edit:i.A,save:l.A})})(); |