← Back
Editing: product-tag.js
(()=>{var e,t,o,s={30760:(e,t,o)=>{"use strict";const s=window.wp.blocks,r=window.wc.wcSettings;var i=o(11789),c=o(49407);const l=JSON.parse('{"name":"woocommerce/product-tag","title":"Products by Tag","category":"woocommerce","keywords":["WooCommerce"],"description":"Display a grid of products with selected tags.","supports":{"interactivity":{"clientNavigation":false},"align":["wide","full"],"html":false,"inserter":false},"attributes":{"columns":{"type":"number","default":3},"rows":{"type":"number","default":3},"alignButtons":{"type":"boolean","default":false},"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}}},"tags":{"type":"array","default":[]},"tagOperator":{"type":"string","default":"any"},"orderby":{"type":"string","default":"date"},"isPreview":{"type":"boolean","default":false},"stockStatus":{"type":"array"}},"textdomain":"woocommerce","apiVersion":3,"$schema":"https://schemas.wp.org/trunk/block.json"}'),n=window.wp.blockEditor,a=window.wp.serverSideRender;var d=o.n(a),h=o(27723);const m=window.wp.components;var u=o(86087),g=o(10790);const x=({onChange:e,settings:t})=>{const{image:o,button:s,price:r,rating:i,title:c}=t,l=!1!==o;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(m.ToggleControl,{label:(0,h.__)("Product image","woocommerce"),checked:l,onChange:()=>e({...t,image:!l})}),(0,g.jsx)(m.ToggleControl,{label:(0,h.__)("Product title","woocommerce"),checked:c,onChange:()=>e({...t,title:!c})}),(0,g.jsx)(m.ToggleControl,{label:(0,h.__)("Product price","woocommerce"),checked:r,onChange:()=>e({...t,price:!r})}),(0,g.jsx)(m.ToggleControl,{label:(0,h.__)("Product rating","woocommerce"),checked:i,onChange:()=>e({...t,rating:!i})}),(0,g.jsx)(m.ToggleControl,{label:(0,h.__)("Add to Cart button","woocommerce"),checked:s,onChange:()=>e({...t,button:!s})})]})},p=(e,t,o)=>o?Math.min(e,t)===e?t:Math.max(e,o)===e?o:e:Math.max(e,t)===t?e:t,w=({columns:e,rows:t,setAttributes:o,alignButtons:s,minColumns:r=1,maxColumns:i=6,minRows:c=1,maxRows:l=6})=>(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(m.RangeControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,h.__)("Columns","woocommerce"),value:e,onChange:e=>{const t=p(e,r,i);o({columns:Number.isNaN(t)?"":t})},min:r,max:i}),(0,g.jsx)(m.RangeControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,h.__)("Rows","woocommerce"),value:t,onChange:e=>{const t=p(e,c,l);o({rows:Number.isNaN(t)?"":t})},min:c,max:l}),(0,g.jsx)(m.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,h.__)("Align the last block to the bottom","woocommerce"),help:s?(0,h.__)("Align the last block to the bottom.","woocommerce"):(0,h.__)("The last inner block will follow other content.","woocommerce"),checked:s,onChange:()=>o({alignButtons:!s})})]});var b=o(74515),_=o(4921),f=o(29491);const j={clear:(0,h.__)("Clear all selected items","woocommerce"),noItems:(0,h.__)("No items found.","woocommerce"), /* Translators: %s search term */ noResults:(0,h.__)("No results for %s","woocommerce"),search:(0,h.__)("Search for items","woocommerce"),selected:e=>(0,h.sprintf)(/* translators: Number of items selected from list. */ /* translators: Number of items selected from list. */ (0,h._n)("%d item selected","%d items selected",e,"woocommerce"),e),updated:(0,h.__)("Search results updated.","woocommerce")},E=(e,t)=>null!==t&&(e.id===t||!!(Array.isArray(e.children)&&e.children.length>0)&&e.children.some(e=>E(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},{}),s=t.reduce((e,t)=>(e[String(t.id)]=t,e),{});const r=["0"],i=(e={})=>e.parent?[...i(s[e.parent]),e.name]:e.name?[e.name]:[],c=e=>e.map(e=>{const t=o[e.id];return r.push(""+e.id),{...e,breadcrumbs:i(s[e.parent]),children:t&&t.length?c(t):[]}}),l=c(o[0]||[]);return Object.entries(o).forEach(([e,t])=>{r.includes(e)||l.push(...c(t||[]))}),l},v=(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,g.jsx)("strong",{children:e},t):(0,g.jsx)(u.Fragment,{children:e},t))};function C(e,t,o){const s=new Set(t.map(e=>e[o]));return e.filter(e=>!s.has(e[o]))}const k=window.wp.htmlEntities,S=e=>{const t=e.children?.map(e=>[e,...S(e)]);return t?t.flat():[]},N=(e,t)=>S(e).some(e=>t.find(t=>t.id===e.id)),P=(e,t)=>S(e).every(e=>t.find(t=>t.id===e.id)),O=({label:e})=>(0,g.jsx)("span",{className:"woocommerce-search-list__item-count",children:e}),T=e=>{const{item:t,search:o}=e,s=t.breadcrumbs&&t.breadcrumbs.length;return(0,g.jsxs)("span",{className:"woocommerce-search-list__item-label",children:[s?(0,g.jsx)("span",{className:"woocommerce-search-list__item-prefix",children:(r=t.breadcrumbs,1===r.length?r.slice(0,1).toString():2===r.length?r.slice(0,1).toString()+" › "+r.slice(-1).toString():r.slice(0,1).toString()+" … "+r.slice(-1).toString())}):null,(0,g.jsx)("span",{className:"woocommerce-search-list__item-name",children:v((0,k.decodeEntities)(t.name),o)})]});var r},A=({countLabel:e,className:t,depth:o=0,controlId:s="",disabled:r=!1,item:i,isSelected:c,isSelectable:l=!0,isSingle:n,onSelect:a,search:d="",selected:h,useExpandedPanelId:x,...p})=>{const[w,b]=x,f=null!=e&&void 0!==i.count&&null!==i.count,j=!!i.breadcrumbs?.length,y=!!i.children?.length,A=E(i,w),B=(0,_.A)(["woocommerce-search-list__item",`depth-${o}`,t],{"has-breadcrumbs":j,"has-children":y,"has-count":f,"is-expanded":A,"is-radio-button":n}),I=p.name||`search-list-item-${s}`,M=`${I}-${i.id}`,R=(0,u.useCallback)(()=>{A||"number"!=typeof i.id&&"string"!=typeof i.id?!i.parent||"number"!=typeof i.parent&&"string"!=typeof i.parent?b(null):b(i.parent):b(i.id)},[A,i.id,i.parent,b]),F=(c||!l)&&P(i,h);return y?(0,g.jsx)("div",{className:B,onClick:R,onKeyDown:e=>"Enter"===e.key||" "===e.key?R():null,role:"treeitem",tabIndex:0,children:n?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("input",{type:"radio",id:M,name:I,value:i.value,onChange:()=>{a(i)(),A||b(i.id)},onClick:e=>e.stopPropagation(),checked:c,disabled:r,className:"woocommerce-search-list__item-input",...p}),(0,g.jsx)(T,{item:i,search:d}),f?(0,g.jsx)(O,{label:e||i.count}):null]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(m.CheckboxControl,{className:"woocommerce-search-list__item-input",checked:F,disabled:r,indeterminate:!F&&(c||N(i,h)),label:v((0,k.decodeEntities)(i.name),d),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),onChange:()=>{const e=S(i),t=l?[i,...e]:[...e],o=P(i,h);l&&c||!l&&o?a(C(h,t,"id"))():(a(function(e,t){const o=C(t,e,"id");return[...e,...o]}(h,t))(),A||b(i.id))},__nextHasNoMarginBottom:!0}),f?(0,g.jsx)(O,{label:e||i.count}):null]})}):(0,g.jsxs)("div",{className:B,onClick:r?void 0:a(i),children:[n?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("input",{...p,type:"radio",id:M,name:I,value:i.value,onChange:a(i),checked:c,disabled:r,className:"woocommerce-search-list__item-input",onClick:e=>e.stopPropagation()}),(0,g.jsx)("label",{htmlFor:M,children:(0,g.jsx)(T,{item:i,search:d})})]}):(0,g.jsx)(m.CheckboxControl,{...p,id:M,name:I,className:"woocommerce-search-list__item-input",value:(0,k.decodeEntities)(i.value),label:v((0,k.decodeEntities)(i.name),d),onChange:()=>{a(i)(),A||b(i.id)},checked:c,disabled:r,__nextHasNoMarginBottom:!0,onClick:e=>e.stopPropagation()}),f?(0,g.jsx)(O,{label:e||i.count}):null]})},B=A;var I=o(13739);o(75022);const M=({id:e,label:t,popoverContents:o,remove:s,screenReaderLabel:r,className:c=""})=>{const[l,n]=(0,u.useState)(!1),a=(0,f.useInstanceId)(M);if(r=r||t,!t)return null;t=(0,k.decodeEntities)(t);const d=(0,_.A)("woocommerce-tag",c,{"has-remove":!!s}),x=`woocommerce-tag__label-${a}`,p=(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("span",{className:"screen-reader-text",children:r}),(0,g.jsx)("span",{"aria-hidden":"true",children:t})]});return(0,g.jsxs)("span",{className:d,children:[o?(0,g.jsx)(m.Button,{className:"woocommerce-tag__text",id:x,onClick:()=>n(!0),children:p}):(0,g.jsx)("span",{className:"woocommerce-tag__text",id:x,children:p}),o&&l&&(0,g.jsx)(m.Popover,{onClose:()=>n(!1),children:o}),s&&(0,g.jsx)(m.Button,{className:"woocommerce-tag__remove",onClick:s(e),label:(0,h.sprintf)( // Translators: %s label. // Translators: %s label. (0,h.__)("Remove %s","woocommerce"),t),"aria-describedby":x,children:(0,g.jsx)(i.A,{icon:I.A,size:20,className:"clear-icon",role:"img"})})]})},R=M;o(71939);const F=e=>(0,g.jsx)(B,{...e}),$=e=>{const{list:t,selected:o,renderItem:s,depth:r=0,loadMoreChildrenText:i,onLoadMoreChildren:c,totalChildren:l,onSelect:n,instanceId:a,isSingle:d,search:m,useExpandedPanelId:x}=e,[p]=x;return t?(0,g.jsx)(g.Fragment,{children:t.map(t=>{const w=t.children?.length??0,b=!!o.find(({id:e})=>e===t.id),_=E(t,p),f=l?.[t.id],j="number"==typeof f&&w<f;return(0,g.jsxs)(u.Fragment,{children:[(0,g.jsx)("li",{children:s({item:t,isSelected:b,onSelect:n,isSingle:d,selected:o,search:m,depth:r,useExpandedPanelId:x,controlId:a})}),_?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)($,{...e,list:t.children,depth:r+1}),c&&j?(0,g.jsx)("li",{children:(0,g.jsx)("button",{type:"button",className:"woocommerce-search-list__item woocommerce-search-list__item-load-more",onClick:()=>c(),children:i||(0,h.__)("Load more","woocommerce")})}):null]}):null]},t.id)})}):null},L=({isLoading:e,isSingle:t,selected:o,messages:s,onChange:r,onRemove:i})=>{if(e||t||!o)return null;const c=o.length;return(0,g.jsxs)("div",{className:"woocommerce-search-list__selected",children:[(0,g.jsxs)("div",{className:"woocommerce-search-list__selected-header",children:[(0,g.jsx)("strong",{children:s.selected(c)}),c>0?(0,g.jsx)(m.Button,{variant:"link",isDestructive:!0,onClick:()=>r([]),"aria-label":s.clear,children:(0,h.__)("Clear all","woocommerce")}):null]}),c>0?(0,g.jsx)("ul",{children:o.map((e,t)=>(0,g.jsx)("li",{children:(0,g.jsx)(R,{label:e.name,id:e.id,remove:i})},t))}):null]})},D=({filteredList:e,search:t,onSelect:o,instanceId:s,useExpandedPanelId:r,...c})=>{const{messages:l,renderItem:n,selected:a,isSingle:d,loadMoreChildrenText:m,onLoadMoreChildren:u,totalChildren:x}=c,p=n||F;return 0===e.length?(0,g.jsxs)("div",{className:"woocommerce-search-list__list is-not-found",children:[(0,g.jsx)("span",{className:"woocommerce-search-list__not-found-icon",children:(0,g.jsx)(i.A,{icon:b.A,role:"img"})}),(0,g.jsx)("span",{className:"woocommerce-search-list__not-found-text",children:t?(0,h.sprintf)(l.noResults,t):l.noItems})]}):(0,g.jsx)("ul",{className:"woocommerce-search-list__list",children:(0,g.jsx)($,{useExpandedPanelId:r,list:e,selected:a,renderItem:p,loadMoreChildrenText:m,onLoadMoreChildren:u,totalChildren:x,onSelect:o,instanceId:s,isSingle:d,search:t})})},H=e=>{const{className:t="",isCompact:o,isHierarchical:s,isLoading:r,isSingle:i,list:c,messages:l=j,onChange:n,onSearch:a,selected:d,type:x="text",debouncedSpeak:p}=e,[w,b]=(0,u.useState)(""),E=(0,u.useState)(null),v=(0,f.useInstanceId)(H),C=(0,u.useMemo)(()=>({...j,...l}),[l]),k=(0,u.useMemo)(()=>((e,t,o)=>{if(!t)return o?y(e):e;const s=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),r=e.map(e=>!!s.test(e.name)&&e).filter(Boolean);return o?y(r,e):r})(c,w,s),[c,w,s]);(0,u.useEffect)(()=>{p&&p(C.updated)},[p,C]),(0,u.useEffect)(()=>{"function"==typeof a&&a(w)},[w,a]);const S=(0,u.useCallback)(e=>()=>{i&&n([]);const t=d.findIndex(({id:t})=>t===e);n([...d.slice(0,t),...d.slice(t+1)])},[i,d,n]),N=(0,u.useCallback)(e=>()=>{Array.isArray(e)?n(e):-1===d.findIndex(({id:t})=>t===e.id)?n(i?[e]:[...d,e]):S(e.id)()},[i,S,n,d]),P=(0,u.useCallback)(e=>{const[t]=d.filter(t=>!e.find(e=>t.id===e.id));S(t.id)()},[S,d]);return(0,g.jsxs)("div",{className:(0,_.A)("woocommerce-search-list",t,{"is-compact":o,"is-loading":r,"is-token":"token"===x}),children:["text"===x&&(0,g.jsx)(L,{...e,onRemove:S,messages:C}),(0,g.jsx)("div",{className:"woocommerce-search-list__search",children:"text"===x?(0,g.jsx)(m.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:C.search,type:"search",value:w,onChange:e=>b(e)}):(0,g.jsx)(m.FormTokenField,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,disabled:r,label:C.search,onChange:P,onInputChange:e=>b(e),suggestions:[],__experimentalValidateInput:()=>!1,value:r?[(0,h.__)("Loading…","woocommerce")]:d.map(e=>({...e,value:e.name})),__experimentalShowHowTo:!1})}),r?(0,g.jsx)("div",{className:"woocommerce-search-list__list",children:(0,g.jsx)(m.Spinner,{})}):(0,g.jsx)(D,{...e,search:w,filteredList:k,messages:C,onSelect:N,instanceId:v,useExpandedPanelId:E})]})};(0,m.withSpokenMessages)(H);var W=o(64347);const z=({item:e,search:t,depth:o=0,...s})=>{const r=e.breadcrumbs.length?`${e.breadcrumbs.join(", ")}, ${e.name}`:e.name;return(0,g.jsx)(A,{className:(0,_.A)("woocommerce-product-tags__item","has-count",{"is-searching":t.length>0,"is-skip-level":0===o&&0!==e.parent}),item:e,search:t,depth:o,...s,ariaLabel:(0,h.sprintf)(/* translators: %1$d is the count of products, %2$s is the name of the tag. */ /* translators: %1$d is the count of products, %2$s is the name of the tag. */ (0,h._n)("%1$d product tagged as %2$s","%1$d products tagged as %2$s",e.count,"woocommerce"),e.count,r)})},V=window.wp.url,J=window.wp.apiFetch;var Q=o.n(J);o(69910);const G=({isCompact:e=!1,onChange:t,onOperatorChange:o,operator:s="any",selected:i})=>{const[c,l]=(0,u.useState)([]),[n,a]=(0,u.useState)(!0),[d,x]=(0,u.useState)(!1),p=(0,r.getSetting)("limitTags",!1),w=(0,u.useMemo)(()=>c.filter(e=>i.includes(e.id)),[c,i]),b=(0,u.useCallback)(e=>{a(!0),(({selected:e=[],search:t})=>{const o=(({selected:e=[],search:t})=>{const o=(0,r.getSetting)("limitTags",!1),s=[(0,V.addQueryArgs)("wc/store/v1/products/tags",{per_page:o?100:0,orderby:o?"count":"name",order:o?"desc":"asc",search:t})];return o&&e.length&&s.push((0,V.addQueryArgs)("wc/store/v1/products/tags",{include:e})),s})({selected:e,search:t});return Promise.all(o.map(e=>Q()({path:e}))).then(e=>[...new Map(e.flatMap(e=>e.map(e=>[e.id,e]))).values()])})({selected:i,search:e}).then(e=>{l(e),a(!1)}).catch(()=>{a(!1)})},[i]);(0,u.useEffect)(()=>{d||(b(""),x(!0))},[b,d]);const _=(0,W.YQ)(b,400),f={clear:(0,h.__)("Clear all product tags","woocommerce"),list:(0,h.__)("Product Tags","woocommerce"),noItems:(0,h.__)("You have not set up any product tags on your store.","woocommerce"),search:(0,h.__)("Search for product tags","woocommerce"),selected:e=>(0,h.sprintf)(/* translators: %d is the count of selected tags. */ /* translators: %d is the count of selected tags. */ (0,h._n)("%d tag selected","%d tags selected",e,"woocommerce"),e),updated:(0,h.__)("Tag search results updated.","woocommerce")};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(H,{className:"woocommerce-product-tags",list:c,isLoading:n,selected:w,onChange:t,onSearch:p?_:void 0,renderItem:z,messages:f,isCompact:e,isHierarchical:!0,isSingle:!1}),!!o&&(0,g.jsx)("div",{hidden:i.length<2,children:(0,g.jsx)(m.SelectControl,{className:"woocommerce-product-tags__operator",label:(0,h.__)("Display products matching","woocommerce"),help:(0,h.__)("Pick at least two tags to use this setting.","woocommerce"),value:s,onChange:o,options:[{label:(0,h.__)("Any selected tags","woocommerce"),value:"any"},{label:(0,h.__)("All selected tags","woocommerce"),value:"all"}]})})]})},K=({value:e,setAttributes:t})=>(0,g.jsx)(m.SelectControl,{label:(0,h.__)("Order products by","woocommerce"),value:e,options:[{label:(0,h.__)("Newness - newest first","woocommerce"),value:"date"},{label:(0,h.__)("Price - low to high","woocommerce"),value:"price_asc"},{label:(0,h.__)("Price - high to low","woocommerce"),value:"price_desc"},{label:(0,h.__)("Rating - highest first","woocommerce"),value:"rating"},{label:(0,h.__)("Sales - most first","woocommerce"),value:"popularity"},{label:(0,h.__)("Title - alphabetical","woocommerce"),value:"title"},{label:(0,h.__)("Menu Order","woocommerce"),value:"menu_order"}],onChange:e=>t({orderby:e})}),Y=(0,r.getSetting)("hideOutOfStockItems",!1),X=(0,r.getSetting)("stockStatusOptions",{}),q=({value:e,setAttributes:t})=>{const{outofstock:o,...s}=X,r=Y?s:X,i=Object.entries(r).map(([e,t])=>({value:e,label:t})).filter(e=>!!e.label),c=Object.keys(r).filter(e=>!!e),[l,n]=(0,u.useState)(e||c);(0,u.useEffect)(()=>{t({stockStatus:["",...l]})},[l,t]);const a=(0,u.useCallback)(e=>{const t=l.includes(e),o=l.filter(t=>t!==e);t||(o.push(e),o.sort()),n(o)},[l]);return(0,g.jsx)(g.Fragment,{children:i.map(e=>{const t=l.includes(e.value)?/* translators: %s stock status. */ /* translators: %s stock status. */(0,h.__)('Stock status "%s" visible.',"woocommerce"):/* translators: %s stock status. */ /* translators: %s stock status. */(0,h.__)('Stock status "%s" hidden.',"woocommerce");return(0,g.jsx)(m.ToggleControl,{label:e.label,help:(0,h.sprintf)(t,e.label),checked:l.includes(e.value),onChange:()=>a(e.value)},e.value)})})},U=(0,g.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"},children:[(0,g.jsx)("title",{children:"Grid Block Preview"}),(0,g.jsx)("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,g.jsx)("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,g.jsx)("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,g.jsx)("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,g.jsx)("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,g.jsx)("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,g.jsx)("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,g.jsx)("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,g.jsx)("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,g.jsx)("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,g.jsx)("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,g.jsx)("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,g.jsx)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"221.798",fill:"#E1E3E6",rx:"3"})]}),Z=window.wc.wcTypes,ee=(0,m.withSpokenMessages)(({attributes:e,name:t,setAttributes:o,debouncedSpeak:s})=>{const[l,a]=(0,u.useState)({}),[p,b]=(0,u.useState)(!1);(0,u.useEffect)(()=>{e.tags.length||b(!0)},[e.tags.length]);const _=()=>{b(!1),a({})};return e.isPreview?U:(0,r.getSetting)("hasTags",!0)?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(n.BlockControls,{children:(0,g.jsx)(m.ToolbarGroup,{controls:[{icon:"edit",title:(0,h.__)("Edit selected tags","woocommerce"),onClick:()=>p?_():(b(!0),void a({})),isActive:p}]})}),(()=>{const{columns:t,tagOperator:s,contentVisibility:i,orderby:c,rows:l,alignButtons:a,stockStatus:d}=e;return(0,g.jsxs)(n.InspectorControls,{children:[(0,g.jsx)(m.PanelBody,{title:(0,h.__)("Product Tag","woocommerce"),initialOpen:!e.tags.length&&!p,children:(0,g.jsx)(G,{selected:e.tags,onChange:(e=[])=>{const t=e.map(({id:e})=>e);o({tags:t})},operator:s,onOperatorChange:(e="any")=>o({tagOperator:e}),isCompact:!0})}),(0,g.jsx)(m.PanelBody,{title:(0,h.__)("Layout","woocommerce"),initialOpen:!0,children:(0,g.jsx)(w,{columns:t,rows:l,alignButtons:a,setAttributes:o,minColumns:(0,r.getSettingWithCoercion)("minColumns",1,Z.isNumber),maxColumns:(0,r.getSettingWithCoercion)("maxColumns",6,Z.isNumber),minRows:(0,r.getSettingWithCoercion)("minRows",6,Z.isNumber),maxRows:(0,r.getSettingWithCoercion)("maxRows",6,Z.isNumber)})}),(0,g.jsx)(m.PanelBody,{title:(0,h.__)("Content","woocommerce"),initialOpen:!0,children:(0,g.jsx)(x,{settings:i,onChange:e=>o({contentVisibility:e})})}),(0,g.jsx)(m.PanelBody,{title:(0,h.__)("Order By","woocommerce"),initialOpen:!1,children:(0,g.jsx)(K,{setAttributes:o,value:c})}),(0,g.jsx)(m.PanelBody,{title:(0,h.__)("Filter by stock status","woocommerce"),initialOpen:!1,children:(0,g.jsx)(q,{setAttributes:o,value:d})})]},"inspector")})(),p?(()=>{const t={...e,...l};return(0,g.jsxs)(m.Placeholder,{icon:(0,g.jsx)(i.A,{icon:c.A,className:"block-editor-block-icon"}),label:(0,h.__)("Products by Tag","woocommerce"),className:"wc-block-products-grid wc-block-product-tag",children:[(0,h.__)("Display a grid of products from your selected tags.","woocommerce"),(0,g.jsxs)("div",{className:"wc-block-product-tag__selection",children:[(0,g.jsx)(G,{selected:t.tags,onChange:(e=[])=>{const t=e.map(({id:e})=>e);a({...l,tags:t})},operator:t.tagOperator,onOperatorChange:(e="any")=>a({...l,tagOperator:e})}),(0,g.jsx)(m.Button,{variant:"primary",onClick:()=>{o(l),_(),s((0,h.__)("Showing Products by Tag block preview.","woocommerce"))},children:(0,h.__)("Done","woocommerce")}),(0,g.jsx)(m.Button,{className:"wc-block-product-tag__cancel-button",variant:"tertiary",onClick:()=>{_(),s((0,h.__)("Showing Products by Tag block preview.","woocommerce"))},children:(0,h.__)("Cancel","woocommerce")})]})]})})():(()=>{const o=e.tags.length;return(0,g.jsx)(m.Disabled,{children:o?(0,g.jsx)(d(),{block:t,attributes:e}):(0,g.jsx)(m.Placeholder,{icon:(0,g.jsx)(i.A,{icon:c.A,className:"block-editor-block-icon"}),label:(0,h.__)("Products by Tag","woocommerce"),className:"wc-block-products-grid wc-block-product-tag",children:(0,h.__)("This block displays products from selected tags. Select at least one tag to display its products.","woocommerce")})})})()]}):(0,g.jsx)(m.Placeholder,{icon:(0,g.jsx)(i.A,{icon:c.A,className:"block-editor-block-icon"}),label:(0,h.__)("Products by Tag","woocommerce"),className:"wc-block-products-grid wc-block-product-tag",children:(0,h.__)("This block displays products from selected tags. To use it you first need to create products and assign tags to them.","woocommerce")})});o(75152),(0,s.registerBlockType)(l,{icon:{src:(0,g.jsx)(i.A,{icon:c.A,className:"wc-block-editor-components-block-icon"})},attributes:{...l.attributes,columns:{type:"number",default:(0,r.getSetting)("defaultColumns",3)},rows:{type:"number",default:(0,r.getSetting)("defaultRows",3)},tags:{type:"array",default:[]},stockStatus:{type:"array",default:Object.keys((0,r.getSetting)("stockStatusOptions",[]))}},edit:e=>{const t=(0,n.useBlockProps)();return(0,g.jsx)("div",{...t,children:(0,g.jsx)(ee,{...e})})},save:()=>null})},75152:()=>{},69910:()=>{},71939:()=>{},75022:()=>{},51609:e=>{"use strict";e.exports=window.React},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}},r={};function i(e){var t=r[e];if(void 0!==t)return t.exports;var o=r[e]={exports:{}};return s[e](o,o.exports,i),o.exports}i.m=s,e=[],i.O=(t,o,s,r)=>{if(!o){var c=1/0;for(d=0;d<e.length;d++){for(var[o,s,r]=e[d],l=!0,n=0;n<o.length;n++)(!1&r||c>=r)&&Object.keys(i.O).every(e=>i.O[e](o[n]))?o.splice(n--,1):(l=!1,r<c&&(c=r));if(l){e.splice(d--,1);var a=s();void 0!==a&&(t=a)}}return t}r=r||0;for(var d=e.length;d>0&&e[d-1][2]>r;d--)e[d]=e[d-1];e[d]=[o,s,r]},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,s){if(1&s&&(e=this(e)),8&s)return e;if("object"==typeof e&&e){if(4&s&&e.__esModule)return e;if(16&s&&"function"==typeof e.then)return e}var r=Object.create(null);i.r(r);var c={};t=t||[null,o({}),o([]),o(o)];for(var l=2&s&&e;"object"==typeof l&&!~t.indexOf(l);l=o(l))Object.getOwnPropertyNames(l).forEach(t=>c[t]=()=>e[t]);return c.default=()=>e,i.d(r,c),r},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=1235,(()=>{var e={1235:0};i.O.j=t=>0===e[t];var t=(t,o)=>{var s,r,[c,l,n]=o,a=0;if(c.some(t=>0!==e[t])){for(s in l)i.o(l,s)&&(i.m[s]=l[s]);if(n)var d=n(i)}for(t&&t(o);a<c.length;a++)r=c[a],i.o(e,r)&&e[r]&&e[r][0](),e[r]=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 c=i.O(void 0,[94],()=>i(30760));c=i.O(c),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["product-tag"]=c})();
Save File
Cancel