11 lines
No EOL
26 KiB
JavaScript
11 lines
No EOL
26 KiB
JavaScript
(()=>{var e,t={2930:(e,t,r)=>{"use strict";r.r(t);var o=r(9196),l=r(5736);const n=window.wp.blocks;var c=r(1984),a=r(3183);const s=window.wp.components,i=window.wp.serverSideRender;var d=r.n(i);const u=(0,o.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"}},(0,o.createElement)("title",null,"Grid Block Preview"),(0,o.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,o.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,o.createElement)("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,o.createElement)("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,o.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,o.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,o.createElement)("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,o.createElement)("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,o.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,o.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,o.createElement)("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,o.createElement)("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,o.createElement)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"221.798",fill:"#E1E3E6",rx:"3"})),m=window.wp.blockEditor,g=({onChange:e,settings:t})=>{const{image:r,button:n,price:c,rating:a,title:i}=t,d=!1!==r;return(0,o.createElement)(o.Fragment,null,(0,o.createElement)(s.ToggleControl,{label:(0,l.__)("Product image","woocommerce"),checked:d,onChange:()=>e({...t,image:!d})}),(0,o.createElement)(s.ToggleControl,{label:(0,l.__)("Product title","woocommerce"),checked:i,onChange:()=>e({...t,title:!i})}),(0,o.createElement)(s.ToggleControl,{label:(0,l.__)("Product price","woocommerce"),checked:c,onChange:()=>e({...t,price:!c})}),(0,o.createElement)(s.ToggleControl,{label:(0,l.__)("Product rating","woocommerce"),checked:a,onChange:()=>e({...t,rating:!a})}),(0,o.createElement)(s.ToggleControl,{label:(0,l.__)("Add to Cart button","woocommerce"),checked:n,onChange:()=>e({...t,button:!n})}))},h=(e,t,r)=>r?Math.min(e,t)===e?t:Math.max(e,r)===e?r:e:Math.max(e,t)===t?e:t,E=({columns:e,rows:t,setAttributes:r,alignButtons:n,minColumns:c=1,maxColumns:a=6,minRows:i=1,maxRows:d=6})=>(0,o.createElement)(o.Fragment,null,(0,o.createElement)(s.RangeControl,{label:(0,l.__)("Columns","woocommerce"),value:e,onChange:e=>{const t=h(e,c,a);r({columns:Number.isNaN(t)?"":t})},min:c,max:a}),(0,o.createElement)(s.RangeControl,{label:(0,l.__)("Rows","woocommerce"),value:t,onChange:e=>{const t=h(e,i,d);r({rows:Number.isNaN(t)?"":t})},min:i,max:d}),(0,o.createElement)(s.ToggleControl,{label:(0,l.__)("Align the last block to the bottom","woocommerce"),help:n?(0,l.__)("Align the last block to the bottom.","woocommerce"):(0,l.__)("The last inner block will follow other content.","woocommerce"),checked:n,onChange:()=>r({alignButtons:!n})}));var p=r(4184),b=r.n(p),w=r(9307);function _(e,t,r){const o=new Set(t.map((e=>e[r])));return e.filter((e=>!o.has(e[r])))}const f=window.wp.htmlEntities,x={clear:(0,l.__)("Clear all selected items","woocommerce"),noItems:(0,l.__)("No items found.","woocommerce"),
|
||
/* Translators: %s search term */
|
||
noResults:(0,l.__)("No results for %s","woocommerce"),search:(0,l.__)("Search for items","woocommerce"),selected:e=>(0,l.sprintf)(/* translators: Number of items selected from list. */
|
||
(0,l._n)("%d item selected","%d items selected",e,"woocommerce"),e),updated:(0,l.__)("Search results updated.","woocommerce")},y=(e,t=e)=>{const r=e.reduce(((e,t)=>{const r=t.parent||0;return e[r]||(e[r]=[]),e[r].push(t),e}),{}),o=("id",t.reduce(((e,t)=>(e[String(t.id)]=t,e)),{}));const l=["0"],n=(e={})=>e.parent?[...n(o[e.parent]),e.name]:e.name?[e.name]:[],c=e=>e.map((e=>{const t=r[e.id];return l.push(""+e.id),{...e,breadcrumbs:n(o[e.parent]),children:t&&t.length?c(t):[]}})),a=c(r[0]||[]);return Object.entries(r).forEach((([e,t])=>{l.includes(e)||a.push(...c(t||[]))})),a},k=(e,t)=>{if(!t)return e;const r=new RegExp(`(${t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")})`,"ig");return e.split(r).map(((e,t)=>r.test(e)?(0,o.createElement)("strong",{key:t},e):(0,o.createElement)(w.Fragment,{key:t},e)))},v=({label:e})=>(0,o.createElement)("span",{className:"woocommerce-search-list__item-count"},e),C=e=>{const{item:t,search:r}=e,l=t.breadcrumbs&&t.breadcrumbs.length;return(0,o.createElement)("span",{className:"woocommerce-search-list__item-label"},l?(0,o.createElement)("span",{className:"woocommerce-search-list__item-prefix"},1===(n=t.breadcrumbs).length?n.slice(0,1).toString():2===n.length?n.slice(0,1).toString()+" › "+n.slice(-1).toString():n.slice(0,1).toString()+" … "+n.slice(-1).toString()):null,(0,o.createElement)("span",{className:"woocommerce-search-list__item-name"},k((0,f.decodeEntities)(t.name),r)));var n},S=({countLabel:e,className:t,depth:r=0,controlId:l="",item:n,isSelected:c,isSingle:a,onSelect:i,search:d="",selected:u,useExpandedPanelId:m,...g})=>{var h,E;const[p,x]=m,y=null!=e&&void 0!==n.count&&null!==n.count,S=!(null===(h=n.breadcrumbs)||void 0===h||!h.length),N=!(null===(E=n.children)||void 0===E||!E.length),O=p===n.id,P=b()(["woocommerce-search-list__item",`depth-${r}`,t],{"has-breadcrumbs":S,"has-children":N,"has-count":y,"is-expanded":O,"is-radio-button":a}),I=g.name||`search-list-item-${l}`,R=`${I}-${n.id}`,B=(0,w.useCallback)((()=>{x(O?-1:Number(n.id))}),[O,n.id,x]);return N?(0,o.createElement)("div",{className:P,onClick:B,onKeyDown:e=>"Enter"===e.key||" "===e.key?B():null,role:"treeitem",tabIndex:0},a?(0,o.createElement)(o.Fragment,null,(0,o.createElement)("input",{type:"radio",id:R,name:I,value:n.value,onChange:i(n),onClick:e=>e.stopPropagation(),checked:c,className:"woocommerce-search-list__item-input",...g}),(0,o.createElement)(C,{item:n,search:d}),y?(0,o.createElement)(v,{label:e||n.count}):null):(0,o.createElement)(o.Fragment,null,(0,o.createElement)(s.CheckboxControl,{className:"woocommerce-search-list__item-input",checked:c,...!c&&n.children.some((e=>u.find((t=>t.id===e.id))))?{indeterminate:!0}:{},label:k((0,f.decodeEntities)(n.name),d),onChange:()=>{c?i(_(u,n.children,"id"))():i(function(e,t,r){const o=_(t,e,"id");return[...e,...o]}(u,n.children))()},onClick:e=>e.stopPropagation()}),y?(0,o.createElement)(v,{label:e||n.count}):null)):(0,o.createElement)("label",{htmlFor:R,className:P},a?(0,o.createElement)(o.Fragment,null,(0,o.createElement)("input",{...g,type:"radio",id:R,name:I,value:n.value,onChange:i(n),checked:c,className:"woocommerce-search-list__item-input"}),(0,o.createElement)(C,{item:n,search:d})):(0,o.createElement)(s.CheckboxControl,{...g,id:R,name:I,className:"woocommerce-search-list__item-input",value:(0,f.decodeEntities)(n.value),label:k((0,f.decodeEntities)(n.name),d),onChange:i(n),checked:c}),y?(0,o.createElement)(v,{label:e||n.count}):null)},N=S;var O=r(5430),P=r(4333),I=r(906);r(5932);const R=({id:e,label:t,popoverContents:r,remove:n,screenReaderLabel:a,className:i=""})=>{const[d,u]=(0,w.useState)(!1),m=(0,P.useInstanceId)(R);if(a=a||t,!t)return null;t=(0,f.decodeEntities)(t);const g=b()("woocommerce-tag",i,{"has-remove":!!n}),h=`woocommerce-tag__label-${m}`,E=(0,o.createElement)(o.Fragment,null,(0,o.createElement)("span",{className:"screen-reader-text"},a),(0,o.createElement)("span",{"aria-hidden":"true"},t));return(0,o.createElement)("span",{className:g},r?(0,o.createElement)(s.Button,{className:"woocommerce-tag__text",id:h,onClick:()=>u(!0)},E):(0,o.createElement)("span",{className:"woocommerce-tag__text",id:h},E),r&&d&&(0,o.createElement)(s.Popover,{onClose:()=>u(!1)},r),n&&(0,o.createElement)(s.Button,{className:"woocommerce-tag__remove",onClick:n(e),label:(0,l.sprintf)(
|
||
// Translators: %s label.
|
||
(0,l.__)("Remove %s","woocommerce"),t),"aria-describedby":h},(0,o.createElement)(c.Z,{icon:I.Z,size:20,className:"clear-icon",role:"img"})))},B=R;r(8462);const T=e=>(0,o.createElement)(N,{...e}),$=e=>{const{list:t,selected:r,renderItem:l,depth:n=0,onSelect:c,instanceId:a,isSingle:s,search:i,useExpandedPanelId:d}=e,[u]=d;return t?(0,o.createElement)(w.Fragment,null,t.map((t=>{var m,g;const h=null!==(m=t.children)&&void 0!==m&&m.length&&!s?t.children.every((({id:e})=>r.find((t=>t.id===e)))):!!r.find((({id:e})=>e===t.id)),E=(null===(g=t.children)||void 0===g?void 0:g.length)&&u===t.id;return(0,o.createElement)(w.Fragment,{key:t.id},(0,o.createElement)("li",null,l({item:t,isSelected:h,onSelect:c,isSingle:s,selected:r,search:i,depth:n,useExpandedPanelId:d,controlId:a})),E?(0,o.createElement)($,{...e,list:t.children,depth:n+1}):null)}))):null},A=({isLoading:e,isSingle:t,selected:r,messages:n,onChange:c,onRemove:a})=>{if(e||t||!r)return null;const i=r.length;return(0,o.createElement)("div",{className:"woocommerce-search-list__selected"},(0,o.createElement)("div",{className:"woocommerce-search-list__selected-header"},(0,o.createElement)("strong",null,n.selected(i)),i>0?(0,o.createElement)(s.Button,{isLink:!0,isDestructive:!0,onClick:()=>c([]),"aria-label":n.clear},(0,l.__)("Clear all","woocommerce")):null),i>0?(0,o.createElement)("ul",null,r.map(((e,t)=>(0,o.createElement)("li",{key:t},(0,o.createElement)(B,{label:e.name,id:e.id,remove:a}))))):null)},F=({filteredList:e,search:t,onSelect:r,instanceId:n,useExpandedPanelId:a,...s})=>{const{messages:i,renderItem:d,selected:u,isSingle:m}=s,g=d||T;return 0===e.length?(0,o.createElement)("div",{className:"woocommerce-search-list__list is-not-found"},(0,o.createElement)("span",{className:"woocommerce-search-list__not-found-icon"},(0,o.createElement)(c.Z,{icon:O.Z,role:"img"})),(0,o.createElement)("span",{className:"woocommerce-search-list__not-found-text"},t?(0,l.sprintf)(i.noResults,t):i.noItems)):(0,o.createElement)("ul",{className:"woocommerce-search-list__list"},(0,o.createElement)($,{useExpandedPanelId:a,list:e,selected:u,renderItem:g,onSelect:r,instanceId:n,isSingle:m,search:t}))},j=e=>{const{className:t="",isCompact:r,isHierarchical:n,isLoading:c,isSingle:a,list:i,messages:d=x,onChange:u,onSearch:m,selected:g,type:h="text",debouncedSpeak:E}=e,[p,_]=(0,w.useState)(""),f=(0,w.useState)(-1),k=(0,P.useInstanceId)(j),v=(0,w.useMemo)((()=>({...x,...d})),[d]),C=(0,w.useMemo)((()=>((e,t,r)=>{if(!t)return r?y(e):e;const o=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),l=e.map((e=>!!o.test(e.name)&&e)).filter(Boolean);return r?y(l,e):l})(i,p,n)),[i,p,n]);(0,w.useEffect)((()=>{E&&E(v.updated)}),[E,v]),(0,w.useEffect)((()=>{"function"==typeof m&&m(p)}),[p,m]);const S=(0,w.useCallback)((e=>()=>{a&&u([]);const t=g.findIndex((({id:t})=>t===e));u([...g.slice(0,t),...g.slice(t+1)])}),[a,g,u]),N=(0,w.useCallback)((e=>()=>{Array.isArray(e)?u(e):-1===g.findIndex((({id:t})=>t===e.id))?u(a?[e]:[...g,e]):S(e.id)()}),[a,S,u,g]),O=(0,w.useCallback)((e=>{const[t]=g.filter((t=>!e.find((e=>t.id===e.id))));S(t.id)()}),[S,g]);return(0,o.createElement)("div",{className:b()("woocommerce-search-list",t,{"is-compact":r,"is-loading":c,"is-token":"token"===h})},"text"===h&&(0,o.createElement)(A,{...e,onRemove:S,messages:v}),(0,o.createElement)("div",{className:"woocommerce-search-list__search"},"text"===h?(0,o.createElement)(s.TextControl,{label:v.search,type:"search",value:p,onChange:e=>_(e)}):(0,o.createElement)(s.FormTokenField,{disabled:c,label:v.search,onChange:O,onInputChange:e=>_(e),suggestions:[],__experimentalValidateInput:()=>!1,value:c?[(0,l.__)("Loading…","woocommerce")]:g.map((e=>({...e,value:e.name}))),__experimentalShowHowTo:!1})),c?(0,o.createElement)("div",{className:"woocommerce-search-list__list"},(0,o.createElement)(s.Spinner,null)):(0,o.createElement)(F,{...e,search:p,filteredList:C,messages:v,onSelect:N,instanceId:k,useExpandedPanelId:f}))},L=((0,s.withSpokenMessages)(j),window.wp.url),M=window.wp.apiFetch;var Z=r.n(M);const H=window.wc.wcSettings,D=(0,P.createHigherOrderComponent)((e=>class extends w.Component{constructor(){super(...arguments),this.state={error:null,loading:!1,categories:[]},this.loadCategories=this.loadCategories.bind(this)}componentDidMount(){this.loadCategories()}loadCategories(){this.setState({loading:!0}),Z()({path:(0,L.addQueryArgs)("wc/store/v1/products/categories",{per_page:0})}).then((e=>{this.setState({categories:e,loading:!1,error:null})})).catch((async e=>{const t=await(async e=>{if(!("json"in e))return{message:e.message,type:e.type||"general"};try{const t=await e.json();return{message:t.message,type:t.type||"api"}}catch(e){return{message:e.message,type:"general"}}})(e);this.setState({categories:[],loading:!1,error:t})}))}render(){const{error:t,loading:r,categories:l}=this.state;return(0,o.createElement)(e,{...this.props,error:t,isLoading:r,categories:l})}}),"withCategories"),V=window.wp.escapeHtml,W=({error:e})=>(0,o.createElement)("div",{className:"wc-block-error-message"},(({message:e,type:t})=>e?"general"===t?(0,o.createElement)("span",null,(0,l.__)("The following error was returned","woocommerce"),(0,o.createElement)("br",null),(0,o.createElement)("code",null,(0,V.escapeHTML)(e))):"api"===t?(0,o.createElement)("span",null,(0,l.__)("The following error was returned from the API","woocommerce"),(0,o.createElement)("br",null),(0,o.createElement)("code",null,(0,V.escapeHTML)(e))):e:(0,l.__)("An error has prevented the block from being updated.","woocommerce"))(e));r(3366);const J=({categories:e,error:t,isLoading:r,onChange:n,onOperatorChange:c,operator:a,selected:i,isCompact:d,isSingle:u,showReviewCount:m})=>{const g={clear:(0,l.__)("Clear all product categories","woocommerce"),list:(0,l.__)("Product Categories","woocommerce"),noItems:(0,l.__)("Your store doesn't have any product categories.","woocommerce"),search:(0,l.__)("Search for product categories","woocommerce"),selected:e=>(0,l.sprintf)(/* translators: %d is the count of selected categories. */
|
||
(0,l._n)("%d category selected","%d categories selected",e,"woocommerce"),e),updated:(0,l.__)("Category search results updated.","woocommerce")};return t?(0,o.createElement)(W,{error:t}):(0,o.createElement)(o.Fragment,null,(0,o.createElement)(j,{className:"woocommerce-product-categories",list:e,isLoading:r,selected:i.map((t=>e.find((e=>e.id===t)))).filter(Boolean),onChange:n,renderItem:e=>{const{item:t,search:r,depth:n=0}=e,c=t.breadcrumbs.length?`${t.breadcrumbs.join(", ")}, ${t.name}`:t.name,a=m?(0,l.sprintf)(/* translators: %1$s is the item name, %2$d is the count of reviews for the item. */
|
||
(0,l._n)("%1$s, has %2$d review","%1$s, has %2$d reviews",t.review_count,"woocommerce"),c,t.review_count):(0,l.sprintf)(/* translators: %1$s is the item name, %2$d is the count of products for the item. */
|
||
(0,l._n)("%1$s, has %2$d product","%1$s, has %2$d products",t.count,"woocommerce"),c,t.count),s=m?(0,l.sprintf)(/* translators: %d is the count of reviews. */
|
||
(0,l._n)("%d review","%d reviews",t.review_count,"woocommerce"),t.review_count):(0,l.sprintf)(/* translators: %d is the count of products. */
|
||
(0,l._n)("%d product","%d products",t.count,"woocommerce"),t.count);return(0,o.createElement)(S,{className:b()("woocommerce-product-categories__item","has-count",{"is-searching":r.length>0,"is-skip-level":0===n&&0!==t.parent}),...e,countLabel:s,"aria-label":a})},messages:g,isCompact:d,isHierarchical:!0,isSingle:u}),!!c&&(0,o.createElement)("div",{hidden:i.length<2},(0,o.createElement)(s.SelectControl,{className:"woocommerce-product-categories__operator",label:(0,l.__)("Display products matching","woocommerce"),help:(0,l.__)("Pick at least two categories to use this setting.","woocommerce"),value:a,onChange:c,options:[{label:(0,l.__)("Any selected categories","woocommerce"),value:"any"},{label:(0,l.__)("All selected categories","woocommerce"),value:"all"}]})))};J.defaultProps={operator:"any",isCompact:!1,isSingle:!1};const z=D(J),G=({value:e,setAttributes:t})=>(0,o.createElement)(s.SelectControl,{label:(0,l.__)("Order products by","woocommerce"),value:e,options:[{label:(0,l.__)("Newness - newest first","woocommerce"),value:"date"},{label:(0,l.__)("Price - low to high","woocommerce"),value:"price_asc"},{label:(0,l.__)("Price - high to low","woocommerce"),value:"price_desc"},{label:(0,l.__)("Rating - highest first","woocommerce"),value:"rating"},{label:(0,l.__)("Sales - most first","woocommerce"),value:"popularity"},{label:(0,l.__)("Title - alphabetical","woocommerce"),value:"title"},{label:(0,l.__)("Menu Order","woocommerce"),value:"menu_order"}],onChange:e=>t({orderby:e})}),K=(0,H.getSetting)("hideOutOfStockItems",!1),Q=(0,H.getSetting)("stockStatusOptions",{}),Y=({value:e,setAttributes:t})=>{const{outofstock:r,...n}=Q,c=K?n:Q,a=Object.entries(c).map((([e,t])=>({value:e,label:t}))).filter((e=>!!e.label)),i=Object.keys(c).filter((e=>!!e)),[d,u]=(0,w.useState)(e||i);(0,w.useEffect)((()=>{t({stockStatus:["",...d]})}),[d,t]);const m=(0,w.useCallback)((e=>{const t=d.includes(e),r=d.filter((t=>t!==e));t||(r.push(e),r.sort()),u(r)}),[d]);return(0,o.createElement)(o.Fragment,null,a.map((e=>{const t=d.includes(e.value)?/* translators: %s stock status. */(0,l.__)('Stock status "%s" visible.',"woocommerce"):/* translators: %s stock status. */(0,l.__)('Stock status "%s" hidden.',"woocommerce");return(0,o.createElement)(s.ToggleControl,{label:e.label,key:e.value,help:(0,l.sprintf)(t,e.label),checked:d.includes(e.value),onChange:()=>m(e.value)})})))},q=e=>{const{attributes:t,setAttributes:r}=e,{categories:n,catOperator:c,columns:a,contentVisibility:i,rows:d,orderby:u,alignButtons:h,stockStatus:p}=t;return(0,o.createElement)(m.InspectorControls,{key:"inspector"},(0,o.createElement)(s.PanelBody,{title:(0,l.__)("Layout","woocommerce"),initialOpen:!0},(0,o.createElement)(E,{columns:a,rows:d,alignButtons:h,setAttributes:r,minColumns:(0,H.getSetting)("minColumns",1),maxColumns:(0,H.getSetting)("maxColumns",6),minRows:(0,H.getSetting)("minRows",1),maxRows:(0,H.getSetting)("maxRows",6)})),(0,o.createElement)(s.PanelBody,{title:(0,l.__)("Content","woocommerce"),initialOpen:!0},(0,o.createElement)(g,{settings:i,onChange:e=>r({contentVisibility:e})})),(0,o.createElement)(s.PanelBody,{title:(0,l.__)("Order By","woocommerce"),initialOpen:!1},(0,o.createElement)(G,{setAttributes:r,value:u})),(0,o.createElement)(s.PanelBody,{title:(0,l.__)("Filter by Product Category","woocommerce"),initialOpen:!1},(0,o.createElement)(z,{selected:n,onChange:(e=[])=>{const t=e.map((({id:e})=>e));r({categories:t})},operator:c,onOperatorChange:(e="any")=>r({catOperator:e})})),(0,o.createElement)(s.PanelBody,{title:(0,l.__)("Filter by stock status","woocommerce"),initialOpen:!1},(0,o.createElement)(Y,{setAttributes:r,value:p})))},U=()=>(0,o.createElement)(s.Placeholder,{icon:(0,o.createElement)(c.Z,{icon:a.Z}),label:(0,l.__)("On Sale Products","woocommerce"),className:"wc-block-product-on-sale"},(0,l.__)("This block shows on-sale products. There are currently no discounted products in your store.","woocommerce")),X=e=>{const{attributes:t,setAttributes:r,name:l}=e;return t.isPreview?u:(0,o.createElement)(o.Fragment,null,(0,o.createElement)(q,{attributes:t,setAttributes:r}),(0,o.createElement)(s.Disabled,null,(0,o.createElement)(d(),{block:l,attributes:t,EmptyResponsePlaceholder:U})))};r(418);const ee={columns:{type:"number",default:(0,H.getSetting)("defaultColumns",3)},rows:{type:"number",default:(0,H.getSetting)("defaultRows",3)},alignButtons:{type:"boolean",default:!1},categories:{type:"array",default:[]},catOperator:{type:"string",default:"any"},contentVisibility:{type:"object",default:{image:!0,title:!0,price:!0,rating:!0,button:!0}},isPreview:{type:"boolean",default:!1},stockStatus:{type:"array",default:Object.keys((0,H.getSetting)("stockStatusOptions",[]))}};(0,n.registerBlockType)("woocommerce/product-on-sale",{title:(0,l.__)("On Sale Products","woocommerce"),icon:{src:(0,o.createElement)(c.Z,{icon:a.Z,className:"wc-block-editor-components-block-icon"})},category:"woocommerce",keywords:[(0,l.__)("WooCommerce","woocommerce")],description:(0,l.__)("Display a grid of products currently on sale.","woocommerce"),supports:{align:["wide","full"],html:!1},attributes:{...ee,orderby:{type:"string",default:"date"}},transforms:{from:[{type:"block",blocks:["woocommerce/product-best-sellers","woocommerce/product-category","woocommerce/product-new","woocommerce/product-on-sale","woocommerce/product-top-rated"].filter((e=>"woocommerce/product-on-sale"!==e)),transform:e=>(0,n.createBlock)("woocommerce/product-on-sale",e)}]},edit:e=>(0,o.createElement)(X,{...e}),save:()=>null})},418:()=>{},3366:()=>{},8462:()=>{},5932:()=>{},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}},r={};function o(e){var l=r[e];if(void 0!==l)return l.exports;var n=r[e]={exports:{}};return t[e].call(n.exports,n,n.exports,o),n.exports}o.m=t,e=[],o.O=(t,r,l,n)=>{if(!r){var c=1/0;for(d=0;d<e.length;d++){for(var[r,l,n]=e[d],a=!0,s=0;s<r.length;s++)(!1&n||c>=n)&&Object.keys(o.O).every((e=>o.O[e](r[s])))?r.splice(s--,1):(a=!1,n<c&&(c=n));if(a){e.splice(d--,1);var i=l();void 0!==i&&(t=i)}}return t}n=n||0;for(var d=e.length;d>0&&e[d-1][2]>n;d--)e[d]=e[d-1];e[d]=[r,l,n]},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.j=9597,(()=>{var e={9597:0};o.O.j=t=>0===e[t];var t=(t,r)=>{var l,n,[c,a,s]=r,i=0;if(c.some((t=>0!==e[t]))){for(l in a)o.o(a,l)&&(o.m[l]=a[l]);if(s)var d=s(o)}for(t&&t(r);i<c.length;i++)n=c[i],o.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return o.O(d)},r=self.webpackChunkwebpackWcBlocksJsonp=self.webpackChunkwebpackWcBlocksJsonp||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var l=o.O(void 0,[2869],(()=>o(2930)));l=o.O(l),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["product-on-sale"]=l})(); |