woocommerce/packages/woocommerce-blocks/build/product-tag.js

5 lines
28 KiB
JavaScript
Raw Normal View History

2021-12-10 12:03:04 +00:00
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["product-tag"]=function(e){function t(t){for(var n,i,l=t[0],a=t[1],u=t[2],b=0,d=[];b<l.length;b++)i=l[b],Object.prototype.hasOwnProperty.call(c,i)&&c[i]&&d.push(c[i][0]),c[i]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(s&&s(t);d.length;)d.shift()();return o.push.apply(o,u||[]),r()}function r(){for(var e,t=0;t<o.length;t++){for(var r=o[t],n=!0,l=1;l<r.length;l++){var a=r[l];0!==c[a]&&(n=!1)}n&&(o.splice(t--,1),e=i(i.s=r[0]))}return e}var n={},c={34:0},o=[];function i(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.m=e,i.c=n,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(r,n,function(t){return e[t]}.bind(null,n));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="";var l=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],a=l.push.bind(l);l.push=t,l=l.slice();for(var u=0;u<l.length;u++)t(l[u]);var s=a;return o.push([779,0]),r()}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},11:function(e,t){e.exports=window.React},12:function(e,t){e.exports=window.wp.blockEditor},121:function(e,t){},122:function(e,t){e.exports=window.wp.coreData},130:function(e,t,r){"use strict";var n=r(0),c=r(1),o=r(4);r(2),t.a=function(e){var t=e.value,r=e.setAttributes;return Object(n.createElement)(o.SelectControl,{label:Object(c.__)("Order products by",'woocommerce'),value:t,options:[{label:Object(c.__)("Newness - newest first",'woocommerce'),value:"date"},{label:Object(c.__)("Price - low to high",'woocommerce'),value:"price_asc"},{label:Object(c.__)("Price - high to low",'woocommerce'),value:"price_desc"},{label:Object(c.__)("Rating - highest first",'woocommerce'),value:"rating"},{label:Object(c.__)("Sales - most first",'woocommerce'),value:"popularity"},{label:Object(c.__)("Title - alphabetical",'woocommerce'),value:"title"},{label:Object(c.__)("Menu Order",'woocommerce'),value:"menu_order"}],onChange:function(e){return r({orderby:e})}})}},14:function(e,t){e.exports=window.wp.data},15:function(e,t){e.exports=window.wp.apiFetch},188:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(0),c=Object(n.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"}},Object(n.createElement)("title",null,"Grid Block Preview"),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),Object(n.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),Object(n.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),Object(n.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),Object(n.cre
/* translators: %1$d is the count of products, %2$s is the name of the tag. */
Object(c._n)("%1$d product tagged as %2$s","%1$d products tagged as %2$s",t.count,'woocommerce'),t.count,l)}))}},{key:"render",value:function(){var e=this.state,t=e.list,r=e.loading,o=this.props,l=o.isCompact,a=o.onChange,u=o.onOperatorChange,s=o.operator,b=o.selected,d={clear:Object(c.__)("Clear all product tags",'woocommerce'),list:Object(c.__)("Product Tags",'woocommerce'),noItems:Object(c.__)("Your store doesn't have any product tags.",'woocommerce'),search:Object(c.__)("Search for product tags",'woocommerce'),selected:function(e){return Object(c.sprintf)(
/* translators: %d is the count of selected tags. */
Object(c._n)("%d tag selected","%d tags selected",e,'woocommerce'),e)},updated:Object(c.__)("Tag search results updated.",'woocommerce')},g=Object(i.getSetting)("limitTags",!1);return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(B.b,{className:"woocommerce-product-tags",list:t,isLoading:r,selected:b.map((function(e){return t.find((function(t){return t.id===e}))})).filter(Boolean),onChange:a,onSearch:g?this.debouncedOnSearch:null,renderItem:this.renderItem,messages:d,isCompact:l,isHierarchical:!0}),!!u&&Object(n.createElement)("div",{hidden:b.length<2},Object(n.createElement)(P.SelectControl,{className:"woocommerce-product-tags__operator",label:Object(c.__)("Display products matching",'woocommerce'),help:Object(c.__)("Pick at least two tags to use this setting.",'woocommerce'),value:s,onChange:u,options:[{label:Object(c.__)("Any selected tags",'woocommerce'),value:"any"},{label:Object(c.__)("All selected tags",'woocommerce'),value:"all"}]})))}}]),l}(n.Component);M.defaultProps={isCompact:!1,operator:"any"};var I=M,V=r(130),H=r(188);function L(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?L(Object(r),!0).forEach((function(t){b()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):L(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var q=function(e){O()(a,e);var t,r,o=(t=a,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=v()(t);if(r){var c=v()(this).constructor;e=Reflect.construct(n,arguments,c)}else e=n.apply(this,arguments);return j()(this,e)});function a(){var e;return g()(this,a),(e=o.apply(this,arguments)).state={changedAttributes:{},isEditing:!1},e.startEditing=e.startEditing.bind(E()(e)),e.stopEditing=e.stopEditing.bind(E()(e)),e.setChangedAttributes=e.setChangedAttributes.bind(E()(e)),e.save=e.save.bind(E()(e)),e}return h()(a,[{key:"componentDidMount",value:function(){this.props.attributes.tags.length||this.setState({isEditing:!0})}},{key:"startEditing",value:function(){this.setState({isEditing:!0,changedAttributes:{}})}},{key:"stopEditing",value:function(){this.setState({isEditing:!1,changedAttributes:{}})}},{key:"setChangedAttributes",value:function(e){this.setState((function(t){return{changedAttributes:Q(Q({},t.changedAttributes),e)}}))}},{key:"save",value:function(){var e=this.state.changedAttributes;(0,this.props.setAttributes)(e),this.stopEditing()}},{key:"getInspectorControls",value:function(){var e=this.props,t=e.attributes,r=e.setAttributes,o=this.state.isEditing,l=t.columns,a=t.tagOperator,u=t.contentVisibility,s=t.orderby,b=t.rows,d=t.alignButtons;return Object(n.createElement)(_.InspectorControls,{key:"inspector"},Object(n.createElement)(P.PanelBody,{title:Object(c.__)("Product Tag",'woocommerce'),initialOpen:!t.tags.length&&!o},Object(n.createElement)(I,{selected:t.tags,onChange:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=e.map((function(e){return e.id}));r({tags:t})},operator:a,onOperatorChange:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"any";return r({tagOperator:e})},isCompact:!0})),Object(n.createElement)(P.PanelBody,{title:Object(c.__)("Layout",'woocommerce'),initialOpen:!0},Object(n.createElement)(C.a,{columns:l,rows:b,alignButtons:d,setAttributes:r,minColumns:Object(i.getSetting)("min_columns",1),maxColumns:Object(i.getSetting)("max_columns",6),minRows:Object(i.getSetting)("min_rows",1),maxRows:Object(i.getSetting)("max_rows",6)})),Object(n.createElement)(P.PanelBody,{title:Object(c.__)("Content",'woocommerce'),initialOpen:!