1 line
No EOL
7 KiB
JavaScript
1 line
No EOL
7 KiB
JavaScript
(()=>{var e,t={1818:(e,t,o)=>{"use strict";o.r(t);var r=o(9196);const c=window.wp.blockEditor,a=window.wp.data;var l=o(5736),s=o(1984),n=o(2395);const i=window.wc.wcSettings,d=window.wp.components,u=window.wp.blocks;o(4300),o(9428);var p=o(4184),b=o.n(p);const w=({attributes:{label:e,placeholder:t,formId:o,className:c,hasLabel:a,align:s}})=>{const n=b()("wc-block-product-search",s?"align"+s:"",c);return(0,r.createElement)("div",{className:n},(0,r.createElement)("form",{role:"search",method:"get",action:i.HOME_URL},(0,r.createElement)("label",{htmlFor:o,className:a?"wc-block-product-search__label":"wc-block-product-search__label screen-reader-text"},e),(0,r.createElement)("div",{className:"wc-block-product-search__fields"},(0,r.createElement)("input",{type:"search",id:o,className:"wc-block-product-search__field",placeholder:t,name:"s"}),(0,r.createElement)("input",{type:"hidden",name:"post_type",value:"product"}),(0,r.createElement)("button",{type:"submit",className:"wc-block-product-search__button","aria-label":(0,l.__)("Search","woocommerce")},(0,r.createElement)("svg",{"aria-hidden":"true",role:"img",focusable:"false",className:"dashicon dashicons-arrow-right-alt2",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20"},(0,r.createElement)("path",{d:"M6 15l5-5-5-5 1-2 7 7-7 7z"}))))))};var m=o(4333),h=o(9307);const g=(0,m.withInstanceId)((({attributes:{label:e,placeholder:t,formId:o,className:a,hasLabel:s,align:n},instanceId:i,setAttributes:u})=>{const p=b()("wc-block-product-search",n?"align"+n:"",a);return(0,h.useEffect)((()=>{o||u({formId:`wc-block-product-search-${i}`})}),[o,u,i]),(0,r.createElement)(r.Fragment,null,(0,r.createElement)(c.InspectorControls,{key:"inspector"},(0,r.createElement)(d.PanelBody,{title:(0,l.__)("Content","woocommerce"),initialOpen:!0},(0,r.createElement)(d.ToggleControl,{label:(0,l.__)("Show search field label","woocommerce"),checked:s,onChange:()=>u({hasLabel:!s})}))),(0,r.createElement)("div",{className:p},!!s&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("label",{className:"screen-reader-text",htmlFor:"wc-block-product-search__label"},(0,l.__)("Search Label","woocommerce")),(0,r.createElement)(c.PlainText,{className:"wc-block-product-search__label",id:"wc-block-product-search__label",value:e,onChange:e=>u({label:e}),style:{backgroundColor:"transparent"}})),(0,r.createElement)("div",{className:"wc-block-product-search__fields"},(0,r.createElement)(d.TextControl,{className:"wc-block-product-search__field input-control",value:t,placeholder:(0,l.__)("Enter search placeholder text","woocommerce"),onChange:e=>u({placeholder:e})}),(0,r.createElement)("button",{type:"submit",className:"wc-block-product-search__button","aria-label":(0,l.__)("Search","woocommerce"),onClick:e=>e.preventDefault(),tabIndex:-1},(0,r.createElement)("svg",{"aria-hidden":"true",role:"img",focusable:"false",className:"dashicon dashicons-arrow-right-alt2",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20"},(0,r.createElement)("path",{d:"M6 15l5-5-5-5 1-2 7 7-7 7z"}))))))})),k=(0,i.getSettingWithCoercion)("isBlockVariationAvailable",!1,(e=>"boolean"==typeof e)),_={hasLabel:{type:"boolean",default:!0},label:{type:"string",default:(0,l.__)("Search","woocommerce")},placeholder:{type:"string",default:(0,l.__)("Search products…","woocommerce")},formId:{type:"string",default:""}},f={label:_.label.default,buttonText:_.label.default,placeholder:_.placeholder.default,query:{post_type:"product"}};(0,u.registerBlockType)("woocommerce/product-search",{title:(0,l.__)("Product Search","woocommerce"),icon:{src:(0,r.createElement)(s.Z,{icon:n.Z,className:"wc-block-editor-components-block-icon"})},category:"woocommerce",keywords:[(0,l.__)("WooCommerce","woocommerce")],description:(0,l.__)("A search box to allow customers to search for products by keyword.","woocommerce"),supports:{align:["wide","full"],inserter:!k},attributes:_,transforms:{from:[{type:"block",blocks:["core/legacy-widget"],isMatch:({idBase:e,instance:t})=>"woocommerce_product_search"===e&&!(null==t||!t.raw),transform:({instance:e})=>(0,u.createBlock)("woocommerce/product-search",{label:e.raw.title||f.label})}]},deprecated:[{attributes:_,save:e=>(0,r.createElement)("div",null,(0,r.createElement)(w,{...e}))}],edit:k?({clientId:e})=>{const{replaceBlocks:t}=(0,a.useDispatch)(c.store),o=(0,a.useSelect)((t=>t("core/block-editor").getBlockAttributes(e)),[e]),s=[(0,r.createElement)(d.Button,{key:"update",onClick:()=>{t(e,(0,u.createBlock)("core/search",{label:(null==o?void 0:o.label)||f.label,buttonText:f.buttonText,placeholder:(null==o?void 0:o.placeholder)||f.placeholder,query:f.query}))},variant:"primary"},(0,l.__)("Upgrade Block","woocommerce"))];return(0,r.createElement)(c.Warning,{actions:s,className:"wc-block-components-actions"},(0,l.__)("This version of the Product Search block is outdated. Upgrade to continue using.","woocommerce"))}:g,save:()=>null}),k&&(0,u.registerBlockVariation)("core/search",{name:"woocommerce/product-search",title:(0,l.__)("Product Search","woocommerce"),icon:{src:(0,r.createElement)(s.Z,{icon:n.Z,className:"wc-block-editor-components-block-icon"})},isActive:(e,t)=>{var o;return(null===(o=e.query)||void 0===o?void 0:o.post_type)===t.query.post_type},category:"woocommerce",keywords:[(0,l.__)("WooCommerce","woocommerce")],description:(0,l.__)("A search box to allow customers to search for products by keyword.","woocommerce"),attributes:f})},9428:()=>{},4300:()=>{},9196:e=>{"use strict";e.exports=window.React},4333:e=>{"use strict";e.exports=window.wp.compose},9307:e=>{"use strict";e.exports=window.wp.element},5736:e=>{"use strict";e.exports=window.wp.i18n},444:e=>{"use strict";e.exports=window.wp.primitives}},o={};function r(e){var c=o[e];if(void 0!==c)return c.exports;var a=o[e]={exports:{}};return t[e].call(a.exports,a,a.exports,r),a.exports}r.m=t,e=[],r.O=(t,o,c,a)=>{if(!o){var l=1/0;for(d=0;d<e.length;d++){for(var[o,c,a]=e[d],s=!0,n=0;n<o.length;n++)(!1&a||l>=a)&&Object.keys(r.O).every((e=>r.O[e](o[n])))?o.splice(n--,1):(s=!1,a<l&&(l=a));if(s){e.splice(d--,1);var i=c();void 0!==i&&(t=i)}}return t}a=a||0;for(var d=e.length;d>0&&e[d-1][2]>a;d--)e[d]=e[d-1];e[d]=[o,c,a]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.j=2218,(()=>{var e={2218:0};r.O.j=t=>0===e[t];var t=(t,o)=>{var c,a,[l,s,n]=o,i=0;if(l.some((t=>0!==e[t]))){for(c in s)r.o(s,c)&&(r.m[c]=s[c]);if(n)var d=n(r)}for(t&&t(o);i<l.length;i++)a=l[i],r.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return r.O(d)},o=self.webpackChunkwebpackWcBlocksJsonp=self.webpackChunkwebpackWcBlocksJsonp||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var c=r.O(void 0,[2869],(()=>r(1818)));c=r.O(c),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["product-search"]=c})(); |