1 line
4.7 KiB
JavaScript
1 line
4.7 KiB
JavaScript
(()=>{"use strict";const t=window.wp.i18n,e=window.wp.blocks,l=window.wp.blockEditor,a=window.ReactJSXRuntime,r=(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 242.5 239.46",children:[(0,a.jsx)("defs",{children:(0,a.jsx)("clipPath",{id:"clip-path",transform:"translate(1.72)",children:(0,a.jsx)("circle",{className:"cls-1",cx:"119.73",cy:"119.73",r:"116.15",fill:"none"})})}),(0,a.jsx)("g",{id:"Layer_2","data-name":"Layer 2",children:(0,a.jsxs)("g",{id:"Layer_1","data-name":"Layer 1",children:[(0,a.jsxs)("g",{className:"cls-2",clipPath:"url(#clip-path)",children:[(0,a.jsx)("circle",{className:"cls-3",cx:"121.45",cy:"119.73",r:"116.15",fill:"#33c6f4"}),(0,a.jsx)("path",{className:"cls-4",d:"M239.32,167.79c-53.41-24-108.37-91.46-113-94.55s-10.84.77-10.84.77c-3.87-6.19-10.06.77-10.06.77C76.77,123.55.14,170.11.14,170.11S36.94,237.79,122,237.79C208.48,237.79,239.32,167.79,239.32,167.79Z",transform:"translate(1.72)",fill:"#1b447e"}),(0,a.jsx)("path",{className:"cls-5",d:"M67.48,116.58s15.48-7,12.38,4.65-15.48,28.64-11.61,29.41S83,140.58,86.06,142.12s5.42.78,3.87,6.2-3.1,9.29,0,9.29,5.42-7,9.29-13.94,10.06-3.87,12.38-1.55,9.29,15.49,14.71,13.94,8.51-8.52,6.19-24,1.55-20.12,1.55-20.12,4.64-2.32,13.16,8.51,24,27.09,26.31,26.32-10.83-17.8-7.74-19.35,15.48,2.32,21.68,7.74c0,0,2.12,8.87,2.12.36L126.31,73.24,115.47,74l-10.06.77S80.64,111.94,67.48,116.58Z",transform:"translate(1.72)",fill:"#fff"}),(0,a.jsx)("path",{className:"cls-6",d:"M239.32,170.11c-53.41-24-108.37-93.78-113-96.87s-10.84.77-10.84.77c-3.87-6.19-10.06.77-10.06.77C76.77,123.55.14,170.11.14,170.11",transform:"translate(1.72)",fill:"none",stroke:"#221e1f",strokeMiterlimit:"10",strokeWidth:"8px"})]}),(0,a.jsx)("circle",{className:"cls-6",cx:"121.45",cy:"119.73",r:"116.15",fill:"none",stroke:"#1b447e",strokeMiterlimit:"10",strokeWidth:"8px"})]})})]}),o=window.wp.element,s=window.wp.components,c=window.wp.apiFetch,n=window.wp.url,i=async t=>c({path:(0,n.addQueryArgs)("/contact-form-7/v1/contact-forms",{posts_per_page:20,orderby:"modified",order:"DESC",...t})}).then(t=>t),m=t=>{let e="[contact-form-7]";return t.hash?e=e.replace(/\]$/,` id="${t.hash}"]`):t.id&&(e=e.replace(/\]$/,` id="${t.id}"]`)),t.title&&(e=e.replace(/\]$/,` title="${t.title}"]`)),t.htmlId&&(e=e.replace(/\]$/,` html_id="${t.htmlId}"]`)),t.htmlName&&(e=e.replace(/\]$/,` html_name="${t.htmlName}"]`)),t.htmlTitle&&(e=e.replace(/\]$/,` html_title="${t.htmlTitle}"]`)),t.htmlClass&&(e=e.replace(/\]$/,` html_class="${t.htmlClass}"]`)),"raw_form"===t.output&&(e=e.replace(/\]$/,` output="${t.output}"]`)),e},h=t=>{const e=ajaxurl.replace(/\/admin-ajax\.php$/,"/admin.php");return(0,n.addQueryArgs)(e,{page:"wpcf7",post:t.id,action:"edit"})},d={from:[],to:[{type:"block",blocks:["core/shortcode"],transform:t=>{const l=m(t);return(0,e.createBlock)("core/shortcode",{text:l})}}]};(0,e.registerBlockType)("contact-form-7/contact-form-selector",{icon:r,transforms:d,edit:function({attributes:e,setAttributes:r}){const c=t=>t.reduce((t,e)=>t.set(e.id,e),new Map),[n,m]=(0,o.useState)(()=>c([]));return(0,o.useEffect)(()=>{i().then(t=>{m(c(t))})},[]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(l.InspectorControls,{children:[!!e.id&&(0,a.jsx)(s.PanelBody,{title:e.title,children:(0,a.jsx)(s.ExternalLink,{href:h(e),children:(0,t.__)("Edit this contact form","contact-form-7")})}),!!e.id&&(0,a.jsxs)(s.PanelBody,{title:(0,t.__)("Form attributes","contact-form-7"),initialOpen:!1,children:[(0,a.jsx)(s.TextControl,{label:(0,t.__)("ID","contact-form-7"),value:e.htmlId,onChange:t=>r({htmlId:t}),help:(0,t.__)("Used for the id attribute value of the form element.","contact-form-7")}),(0,a.jsx)(s.TextControl,{label:(0,t.__)("Name","contact-form-7"),value:e.htmlName,onChange:t=>r({htmlName:t}),help:(0,t.__)("Used for the name attribute value of the form element.","contact-form-7")}),(0,a.jsx)(s.TextControl,{label:(0,t.__)("Title","contact-form-7"),value:e.htmlTitle,onChange:t=>r({htmlTitle:t}),help:(0,t.__)("Used for the aria-label attribute value of the form element.","contact-form-7")}),(0,a.jsx)(s.TextControl,{label:(0,t.__)("Class","contact-form-7"),value:e.htmlClass,onChange:t=>r({htmlClass:t}),help:(0,t.__)("Used for the class attribute value of the form element.","contact-form-7")})]})]}),(0,a.jsx)("div",{...(0,l.useBlockProps)({className:"components-placeholder",style:{marginTop:"28px",marginBottom:"28px"}}),children:(0,a.jsx)(s.ComboboxControl,{label:(0,t.__)("Select a contact form:","contact-form-7"),options:(t=>{const e=[];for(const[l,a]of t)e.push({value:l,label:a.title});return e})(n),value:e.id,onChange:t=>r({id:parseInt(t),hash:n.get(parseInt(t))?.hash,title:n.get(parseInt(t))?.title}),onFilterValueChange:t=>{i({search:t}).then(t=>{m(c(t))})}})})]})},save:({attributes:t})=>{const e=m(t);return(0,a.jsx)("div",{...l.useBlockProps.save(),children:e})}})})(); |