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