1 line
7.3 KiB
JavaScript
1 line
7.3 KiB
JavaScript
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["product-search"]=function(e){function t(t){for(var c,l,a=t[0],s=t[1],i=t[2],b=0,p=[];b<a.length;b++)l=a[b],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&p.push(o[l][0]),o[l]=0;for(c in s)Object.prototype.hasOwnProperty.call(s,c)&&(e[c]=s[c]);for(u&&u(t);p.length;)p.shift()();return n.push.apply(n,i||[]),r()}function r(){for(var e,t=0;t<n.length;t++){for(var r=n[t],c=!0,a=1;a<r.length;a++){var s=r[a];0!==o[s]&&(c=!1)}c&&(n.splice(t--,1),e=l(l.s=r[0]))}return e}var c={},o={33:0},n=[];function l(t){if(c[t])return c[t].exports;var r=c[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,l),r.l=!0,r.exports}l.m=e,l.c=c,l.d=function(e,t,r){l.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,t){if(1&t&&(e=l(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(l.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var c in e)l.d(r,c,function(t){return e[t]}.bind(null,c));return r},l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,"a",t),t},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.p="";var a=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],s=a.push.bind(a);a.push=t,a=a.slice();for(var i=0;i<a.length;i++)t(a[i]);var u=s;return n.push([777,0]),r()}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},12:function(e,t){e.exports=window.wp.blockEditor},21:function(e,t){e.exports=window.wp.compose},26:function(e,t){e.exports=window.wp.blocks},28:function(e,t){e.exports=window.wp.primitives},3:function(e,t){e.exports=window.wc.wcSettings},359:function(e,t){},360:function(e,t){},4:function(e,t){e.exports=window.wp.components},66:function(e,t,r){"use strict";var c=r(5),o=r.n(c),n=r(16),l=r.n(n),a=r(0),s=["srcElement","size"];function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);t&&(c=c.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,c)}return r}t.a=function(e){var t=e.srcElement,r=e.size,c=void 0===r?24:r,n=l()(e,s);return Object(a.isValidElement)(t)?Object(a.cloneElement)(t,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({width:c,height:c},n)):null}},777:function(e,t,r){e.exports=r(873)},778:function(e,t,r){"use strict";var c=r(0),o=r(28),n=Object(c.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24"},Object(c.createElement)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),Object(c.createElement)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}));t.a=n},873:function(e,t,r){"use strict";r.r(t);var c=r(0),o=r(1),n=r(26),l=r(66),a=r(778),s=(r(359),r(360),r(6)),i=r.n(s),u=(r(2),r(3)),b=function(e){var t=e.attributes,r=t.label,n=t.placeholder,l=t.formId,a=t.className,s=t.hasLabel,b=t.align,p=i()("wc-block-product-search",b?"align"+b:"",a);return Object(c.createElement)("div",{className:p},Object(c.createElement)("form",{role:"search",method:"get",action:u.HOME_URL},Object(c.createElement)("label",{htmlFor:l,className:s?"wc-block-product-search__label":"wc-block-product-search__label screen-reader-text"},r),Object(c.createElement)("div",{className:"wc-block-product-search__fields"},Object(c.createElement)("input",{type:"search",id:l,className:"wc-block-product-search__field",placeholder:n,name:"s"}),Object(c.createElement)("input",{type:"hidden",name:"post_type",value:"product"}),Object(c.createElement)("button",{type:"submit",className:"wc-block-product-search__button",label:Object(o.__)("Search",'woocommerce')},Object(c.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"},Object(c.createElement)("path",{d:"M6 15l5-5-5-5 1-2 7 7-7 7z"}))))))},p=r(12),d=r(4),w=r(21),f=Object(w.withInstanceId)((function(e){var t=e.attributes,r=t.label,n=t.placeholder,l=t.formId,a=t.className,s=t.hasLabel,u=t.align,b=e.instanceId,w=e.setAttributes,f=i()("wc-block-product-search",u?"align"+u:"",a);return Object(c.useEffect)((function(){l||w({formId:"wc-block-product-search-".concat(b)})}),[l,w,b]),Object(c.createElement)(c.Fragment,null,Object(c.createElement)(p.InspectorControls,{key:"inspector"},Object(c.createElement)(d.PanelBody,{title:Object(o.__)("Content",'woocommerce'),initialOpen:!0},Object(c.createElement)(d.ToggleControl,{label:Object(o.__)("Show search field label",'woocommerce'),help:s?Object(o.__)("Label is visible.",'woocommerce'):Object(o.__)("Label is hidden.",'woocommerce'),checked:s,onChange:function(){return w({hasLabel:!s})}}))),Object(c.createElement)("div",{className:f},!!s&&Object(c.createElement)(p.PlainText,{className:"wc-block-product-search__label",value:r,onChange:function(e){return w({label:e})}}),Object(c.createElement)("div",{className:"wc-block-product-search__fields"},Object(c.createElement)(d.TextControl,{className:"wc-block-product-search__field input-control",value:n,onChange:function(e){return w({placeholder:e})}}),Object(c.createElement)("button",{type:"submit",className:"wc-block-product-search__button",label:Object(o.__)("Search",'woocommerce'),onClick:function(e){return e.preventDefault()},tabIndex:"-1"},Object(c.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"},Object(c.createElement)("path",{d:"M6 15l5-5-5-5 1-2 7 7-7 7z"}))))))})),h={hasLabel:{type:"boolean",default:!0},label:{type:"string",default:Object(o.__)("Search",'woocommerce')},placeholder:{type:"string",default:Object(o.__)("Search products…",'woocommerce')},formId:{type:"string",default:""}};Object(n.registerBlockType)("woocommerce/product-search",{title:Object(o.__)("Product Search",'woocommerce'),icon:{src:Object(c.createElement)(l.a,{srcElement:a.a}),foreground:"#96588a"},category:"woocommerce",keywords:[Object(o.__)("WooCommerce",'woocommerce')],description:Object(o.__)("A search box to allow customers to search for products by keyword.",'woocommerce'),supports:{align:["wide","full"]},example:{attributes:{hasLabel:!0}},attributes:h,transforms:{from:[{type:"block",blocks:["core/legacy-widget"],isMatch:function(e){var t=e.idBase,r=e.instance;return"woocommerce_product_search"===t&&!(null==r||!r.raw)},transform:function(e){var t=e.instance;return Object(n.createBlock)("woocommerce/product-search",{label:""===t.raw.title?Object(o.__)("Search",'woocommerce'):t.raw.title})}}]},deprecated:[{attributes:h,save:function(e){return Object(c.createElement)("div",null,Object(c.createElement)(b,e))}}],edit:f,save:function(){return null}})}}); |