geno/wp-content/plugins/woocommerce/packages/woocommerce-blocks/build/product-search.js

1 line
7 KiB
JavaScript
Raw Permalink Normal View History

2024-02-01 17:24:18 +05:30
(()=>{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),tra