← Back
Editing: handpicked-products.js
(()=>{var e,t,r,s={98344:(e,t,r)=>{"use strict";const s=window.wp.blocks,i=window.wc.wcSettings;var o=r(11789),n=r(95007);r(9202);const c=JSON.parse('{"name":"woocommerce/handpicked-products","title":"Hand-picked Products","category":"woocommerce","keywords":["Handpicked Products","WooCommerce"],"description":"Display a selection of hand-picked products in a grid.","supports":{"interactivity":{"clientNavigation":false},"align":["wide","full"],"html":false,"inserter":false},"attributes":{"align":{"type":"string"},"columns":{"type":"number","default":3},"contentVisibility":{"type":"object","default":{"image":true,"title":true,"price":true,"rating":true,"button":true},"properties":{"image":{"type":"boolean","image":true},"title":{"type":"boolean","title":true},"price":{"type":"boolean","price":true},"rating":{"type":"boolean","rating":true},"button":{"type":"boolean","button":true}}},"orderby":{"type":"string","enum":["date","popularity","price_asc","price_desc","rating","title","menu_order"],"default":"date"},"products":{"type":"array","default":[]},"alignButtons":{"type":"boolean","default":false},"isPreview":{"type":"boolean","default":false}},"textdomain":"woocommerce","apiVersion":3,"$schema":"https://schemas.wp.org/trunk/block.json"}'),l=window.wp.blockEditor,a=window.wp.components;var d=r(86087),h=r(27723),m=r(10790);const u=({onChange:e,settings:t})=>{const{image:r,button:s,price:i,rating:o,title:n}=t,c=!1!==r;return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(a.ToggleControl,{label:(0,h.__)("Product image","woocommerce"),checked:c,onChange:()=>e({...t,image:!c})}),(0,m.jsx)(a.ToggleControl,{label:(0,h.__)("Product title","woocommerce"),checked:n,onChange:()=>e({...t,title:!n})}),(0,m.jsx)(a.ToggleControl,{label:(0,h.__)("Product price","woocommerce"),checked:i,onChange:()=>e({...t,price:!i})}),(0,m.jsx)(a.ToggleControl,{label:(0,h.__)("Product rating","woocommerce"),checked:o,onChange:()=>e({...t,rating:!o})}),(0,m.jsx)(a.ToggleControl,{label:(0,h.__)("Add to Cart button","woocommerce"),checked:s,onChange:()=>e({...t,button:!s})})]})},p=({value:e,setAttributes:t})=>(0,m.jsx)(a.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})});var x=r(74515),g=r(4921),w=r(29491);const E={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,t)=>null!==t&&(e.id===t||!!(Array.isArray(e.children)&&e.children.length>0)&&e.children.some(e=>_(e,t))),j=(e,t=e)=>{const r=e.reduce((e,t)=>{const r=t.parent||0;return e[r]||(e[r]=[]),e[r].push(t),e},{}),s=t.reduce((e,t)=>(e[String(t.id)]=t,e),{});const i=["0"],o=(e={})=>e.parent?[...o(s[e.parent]),e.name]:e.name?[e.name]:[],n=e=>e.map(e=>{const t=r[e.id];return i.push(""+e.id),{...e,breadcrumbs:o(s[e.parent]),children:t&&t.length?n(t):[]}}),c=n(r[0]||[]);return Object.entries(r).forEach(([e,t])=>{i.includes(e)||c.push(...n(t||[]))}),c},f=(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,m.jsx)("strong",{children:e},t):(0,m.jsx)(d.Fragment,{children:e},t))};function b(e,t,r){const s=new Set(t.map(e=>e[r]));return e.filter(e=>!s.has(e[r]))}const y=window.wp.htmlEntities,v=e=>{const t=e.children?.map(e=>[e,...v(e)]);return t?t.flat():[]},S=(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)),C=({label:e})=>(0,m.jsx)("span",{className:"woocommerce-search-list__item-count",children:e}),P=e=>{const{item:t,search:r}=e,s=t.breadcrumbs&&t.breadcrumbs.length;return(0,m.jsxs)("span",{className:"woocommerce-search-list__item-label",children:[s?(0,m.jsx)("span",{className:"woocommerce-search-list__item-prefix",children:(i=t.breadcrumbs,1===i.length?i.slice(0,1).toString():2===i.length?i.slice(0,1).toString()+" › "+i.slice(-1).toString():i.slice(0,1).toString()+" … "+i.slice(-1).toString())}):null,(0,m.jsx)("span",{className:"woocommerce-search-list__item-name",children:f((0,y.decodeEntities)(t.name),r)})]});var i},O=({countLabel:e,className:t,depth:r=0,controlId:s="",disabled:i=!1,item:o,isSelected:n,isSelectable:c=!0,isSingle:l,onSelect:h,search:u="",selected:p,useExpandedPanelId:x,...w})=>{const[E,j]=x,O=null!=e&&void 0!==o.count&&null!==o.count,N=!!o.breadcrumbs?.length,A=!!o.children?.length,T=_(o,E),I=(0,g.A)(["woocommerce-search-list__item",`depth-${r}`,t],{"has-breadcrumbs":N,"has-children":A,"has-count":O,"is-expanded":T,"is-radio-button":l}),B=w.name||`search-list-item-${s}`,M=`${B}-${o.id}`,R=(0,d.useCallback)(()=>{T||"number"!=typeof o.id&&"string"!=typeof o.id?!o.parent||"number"!=typeof o.parent&&"string"!=typeof o.parent?j(null):j(o.parent):j(o.id)},[T,o.id,o.parent,j]),L=(n||!c)&&k(o,p);return A?(0,m.jsx)("div",{className:I,onClick:R,onKeyDown:e=>"Enter"===e.key||" "===e.key?R():null,role:"treeitem",tabIndex:0,children:l?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("input",{type:"radio",id:M,name:B,value:o.value,onChange:()=>{h(o)(),T||j(o.id)},onClick:e=>e.stopPropagation(),checked:n,disabled:i,className:"woocommerce-search-list__item-input",...w}),(0,m.jsx)(P,{item:o,search:u}),O?(0,m.jsx)(C,{label:e||o.count}):null]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(a.CheckboxControl,{className:"woocommerce-search-list__item-input",checked:L,disabled:i,indeterminate:!L&&(n||S(o,p)),label:f((0,y.decodeEntities)(o.name),u),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),onChange:()=>{const e=v(o),t=c?[o,...e]:[...e],r=k(o,p);c&&n||!c&&r?h(b(p,t,"id"))():(h(function(e,t){const r=b(t,e,"id");return[...e,...r]}(p,t))(),T||j(o.id))},__nextHasNoMarginBottom:!0}),O?(0,m.jsx)(C,{label:e||o.count}):null]})}):(0,m.jsxs)("div",{className:I,onClick:i?void 0:h(o),children:[l?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("input",{...w,type:"radio",id:M,name:B,value:o.value,onChange:h(o),checked:n,disabled:i,className:"woocommerce-search-list__item-input",onClick:e=>e.stopPropagation()}),(0,m.jsx)("label",{htmlFor:M,children:(0,m.jsx)(P,{item:o,search:u})})]}):(0,m.jsx)(a.CheckboxControl,{...w,id:M,name:B,className:"woocommerce-search-list__item-input",value:(0,y.decodeEntities)(o.value),label:f((0,y.decodeEntities)(o.name),u),onChange:()=>{h(o)(),T||j(o.id)},checked:n,disabled:i,__nextHasNoMarginBottom:!0,onClick:e=>e.stopPropagation()}),O?(0,m.jsx)(C,{label:e||o.count}):null]})};var N=r(13739);r(75022);const A=({id:e,label:t,popoverContents:r,remove:s,screenReaderLabel:i,className:n=""})=>{const[c,l]=(0,d.useState)(!1),u=(0,w.useInstanceId)(A);if(i=i||t,!t)return null;t=(0,y.decodeEntities)(t);const p=(0,g.A)("woocommerce-tag",n,{"has-remove":!!s}),x=`woocommerce-tag__label-${u}`,E=(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("span",{className:"screen-reader-text",children:i}),(0,m.jsx)("span",{"aria-hidden":"true",children:t})]});return(0,m.jsxs)("span",{className:p,children:[r?(0,m.jsx)(a.Button,{className:"woocommerce-tag__text",id:x,onClick:()=>l(!0),children:E}):(0,m.jsx)("span",{className:"woocommerce-tag__text",id:x,children:E}),r&&c&&(0,m.jsx)(a.Popover,{onClose:()=>l(!1),children:r}),s&&(0,m.jsx)(a.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,m.jsx)(o.A,{icon:N.A,size:20,className:"clear-icon",role:"img"})})]})},T=A;r(71939);const I=e=>(0,m.jsx)(O,{...e}),B=e=>{const{list:t,selected:r,renderItem:s,depth:i=0,loadMoreChildrenText:o,onLoadMoreChildren:n,totalChildren:c,onSelect:l,instanceId:a,isSingle:u,search:p,useExpandedPanelId:x}=e,[g]=x;return t?(0,m.jsx)(m.Fragment,{children:t.map(t=>{const w=t.children?.length??0,E=!!r.find(({id:e})=>e===t.id),j=_(t,g),f=c?.[t.id],b="number"==typeof f&&w<f;return(0,m.jsxs)(d.Fragment,{children:[(0,m.jsx)("li",{children:s({item:t,isSelected:E,onSelect:l,isSingle:u,selected:r,search:p,depth:i,useExpandedPanelId:x,controlId:a})}),j?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(B,{...e,list:t.children,depth:i+1}),n&&b?(0,m.jsx)("li",{children:(0,m.jsx)("button",{type:"button",className:"woocommerce-search-list__item woocommerce-search-list__item-load-more",onClick:()=>n(),children:o||(0,h.__)("Load more","woocommerce")})}):null]}):null]},t.id)})}):null},M=({isLoading:e,isSingle:t,selected:r,messages:s,onChange:i,onRemove:o})=>{if(e||t||!r)return null;const n=r.length;return(0,m.jsxs)("div",{className:"woocommerce-search-list__selected",children:[(0,m.jsxs)("div",{className:"woocommerce-search-list__selected-header",children:[(0,m.jsx)("strong",{children:s.selected(n)}),n>0?(0,m.jsx)(a.Button,{variant:"link",isDestructive:!0,onClick:()=>i([]),"aria-label":s.clear,children:(0,h.__)("Clear all","woocommerce")}):null]}),n>0?(0,m.jsx)("ul",{children:r.map((e,t)=>(0,m.jsx)("li",{children:(0,m.jsx)(T,{label:e.name,id:e.id,remove:o})},t))}):null]})},R=({filteredList:e,search:t,onSelect:r,instanceId:s,useExpandedPanelId:i,...n})=>{const{messages:c,renderItem:l,selected:a,isSingle:d,loadMoreChildrenText:u,onLoadMoreChildren:p,totalChildren:g}=n,w=l||I;return 0===e.length?(0,m.jsxs)("div",{className:"woocommerce-search-list__list is-not-found",children:[(0,m.jsx)("span",{className:"woocommerce-search-list__not-found-icon",children:(0,m.jsx)(o.A,{icon:x.A,role:"img"})}),(0,m.jsx)("span",{className:"woocommerce-search-list__not-found-text",children:t?(0,h.sprintf)(c.noResults,t):c.noItems})]}):(0,m.jsx)("ul",{className:"woocommerce-search-list__list",children:(0,m.jsx)(B,{useExpandedPanelId:i,list:e,selected:a,renderItem:w,loadMoreChildrenText:u,onLoadMoreChildren:p,totalChildren:g,onSelect:r,instanceId:s,isSingle:d,search:t})})},L=e=>{const{className:t="",isCompact:r,isHierarchical:s,isLoading:i,isSingle:o,list:n,messages:c=E,onChange:l,onSearch:u,selected:p,type:x="text",debouncedSpeak:_}=e,[f,b]=(0,d.useState)(""),y=(0,d.useState)(null),v=(0,w.useInstanceId)(L),S=(0,d.useMemo)(()=>({...E,...c}),[c]),k=(0,d.useMemo)(()=>((e,t,r)=>{if(!t)return r?j(e):e;const s=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),i=e.map(e=>!!s.test(e.name)&&e).filter(Boolean);return r?j(i,e):i})(n,f,s),[n,f,s]);(0,d.useEffect)(()=>{_&&_(S.updated)},[_,S]),(0,d.useEffect)(()=>{"function"==typeof u&&u(f)},[f,u]);const C=(0,d.useCallback)(e=>()=>{o&&l([]);const t=p.findIndex(({id:t})=>t===e);l([...p.slice(0,t),...p.slice(t+1)])},[o,p,l]),P=(0,d.useCallback)(e=>()=>{Array.isArray(e)?l(e):-1===p.findIndex(({id:t})=>t===e.id)?l(o?[e]:[...p,e]):C(e.id)()},[o,C,l,p]),O=(0,d.useCallback)(e=>{const[t]=p.filter(t=>!e.find(e=>t.id===e.id));C(t.id)()},[C,p]);return(0,m.jsxs)("div",{className:(0,g.A)("woocommerce-search-list",t,{"is-compact":r,"is-loading":i,"is-token":"token"===x}),children:["text"===x&&(0,m.jsx)(M,{...e,onRemove:C,messages:S}),(0,m.jsx)("div",{className:"woocommerce-search-list__search",children:"text"===x?(0,m.jsx)(a.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:S.search,type:"search",value:f,onChange:e=>b(e)}):(0,m.jsx)(a.FormTokenField,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,disabled:i,label:S.search,onChange:O,onInputChange:e=>b(e),suggestions:[],__experimentalValidateInput:()=>!1,value:i?[(0,h.__)("Loading…","woocommerce")]:p.map(e=>({...e,value:e.name})),__experimentalShowHowTo:!1})}),i?(0,m.jsx)("div",{className:"woocommerce-search-list__list",children:(0,m.jsx)(a.Spinner,{})}):(0,m.jsx)(R,{...e,search:f,filteredList:k,messages:S,onSelect:P,instanceId:v,useExpandedPanelId:y})]})},F=((0,a.withSpokenMessages)(L),window.wc.wcTypes),G=(0,i.getSetting)("wcBlocksConfig",{pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),H=(G.pluginUrl,G.pluginUrl,i.STORE_PAGES.shop,i.STORE_PAGES.checkout,i.STORE_PAGES.checkout,i.STORE_PAGES.privacy,i.STORE_PAGES.privacy,i.STORE_PAGES.terms,i.STORE_PAGES.terms,i.STORE_PAGES.cart,i.STORE_PAGES.cart,i.STORE_PAGES.myaccount?.permalink?i.STORE_PAGES.myaccount.permalink:(0,i.getSetting)("wpLoginUrl","/wp-login.php"),(0,i.getSetting)("localPickupEnabled",!1),(0,i.getSetting)("shippingMethodsExist",!1),(0,i.getSetting)("shippingEnabled",!0),(0,i.getSettingWithCoercion)("countries",{},F.isObject)),$=(0,i.getSetting)("countryData",{}),D={...Object.fromEntries(Object.keys($).filter(e=>!0===$[e].allowBilling).map(e=>{const t=H[e];return[e,(0,F.isString)(t)?t:""]})),...Object.fromEntries(Object.keys($).filter(e=>!0===$[e].allowShipping).map(e=>{const t=H[e];return[e,(0,F.isString)(t)?t:""]}))},V=(Object.fromEntries(Object.keys(D).map(e=>[e,$[e].states||{}])),Object.fromEntries(Object.keys(D).map(e=>[e,$[e].locale||{}])),{address:["first_name","last_name","company","address_1","address_2","city","postcode","country","state","phone"],contact:["email"],order:[]}),J=((0,i.getSetting)("addressFieldsLocations",V).address,(0,i.getSetting)("addressFieldsLocations",V).contact,(0,i.getSetting)("addressFieldsLocations",V).order,(0,i.getSetting)("additionalOrderFields",{}),(0,i.getSetting)("additionalContactFields",{}),(0,i.getSetting)("additionalAddressFields",{}),window.wp.url),U=window.wp.apiFetch;var W=r.n(U);const q=({selected:e=[],search:t="",queryArgs:r={}})=>{const s=(({selected:e=[],search:t="",queryArgs:r={}})=>{const s=G.productCount>100&&e.length>0,i=[(0,J.addQueryArgs)("/wc/store/v1/products",{per_page:100,catalog_visibility:"any",search:t,orderby:"title",order:"asc",exclude:s?e:[],...r})];if(s){const t=Math.ceil(e.length/100);for(let r=1;r<=t;r++)i.push((0,J.addQueryArgs)("/wc/store/v1/products",{catalog_visibility:"any",include:e,per_page:100,page:r}))}return i})({selected:e,search:t,queryArgs:r});return Promise.all(s.map(e=>W()({path:e}))).then(e=>[...new Map(e.flatMap(e=>e.map(e=>[e.id,{...e,parent:0}]))).values()])};var z=r(64347);const Q=window.wp.escapeHtml,K=({message:e,type:t})=>e?"general"===t?(0,m.jsxs)("span",{children:[(0,h.__)("The following error was returned","woocommerce"),(0,m.jsx)("br",{}),(0,m.jsx)("code",{children:(0,Q.escapeHTML)(e)})]}):"api"===t?(0,m.jsxs)("span",{children:[(0,h.__)("The following error was returned from the API","woocommerce"),(0,m.jsx)("br",{}),(0,m.jsx)("code",{children:(0,Q.escapeHTML)(e)})]}):e:(0,h.__)("An error has prevented the block from being updated.","woocommerce"),Y=({error:e})=>(0,m.jsx)("div",{className:"wc-block-error-message",children:K(e)}),X=e=>{const{id:t,name:r,parent:s}=e;return{id:t,name:r,parent:s,breadcrumbs:[],children:[],details:e,value:e.slug}},Z=(se=({error:e,onChange:t,onSearch:r,selected:s=[],products:i=[],isLoading:o=!0,isCompact:n=!1})=>{const c={clear:(0,h.__)("Clear all products","woocommerce"),noItems:(0,h.__)("Your store doesn't have any products.","woocommerce"),search:(0,h.__)("Search for products to display","woocommerce"),selected:e=>(0,h.sprintf)(/* translators: %d is the number of selected products. */ /* translators: %d is the number of selected products. */ (0,h._n)("%d product selected","%d products selected",e,"woocommerce"),e),updated:(0,h.__)("Product search results updated.","woocommerce")};if(e)return(0,m.jsx)(Y,{error:e});const l=i.map(X);return(0,m.jsx)(L,{className:"woocommerce-products",list:l.map(e=>{const t=e.details?.sku?" ("+e.details.sku+")":"";return{...e,name:`${(0,y.decodeEntities)(e.name)}${t}`}}),isCompact:n,isLoading:o,isSingle:!1,selected:l.filter(({details:e})=>!(!e||!Number.isSafeInteger(e.id))&&s.includes(e.id)),onSearch:r,onChange:t,messages:c})},({selected:e,...t})=>{const[r,s]=(0,d.useState)(!0),[i,o]=(0,d.useState)(null),[n,c]=(0,d.useState)([]),l=G.productCount>100,a=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);o(t),s(!1)},h=(0,d.useRef)(e);(0,d.useEffect)(()=>{q({selected:h.current}).then(e=>{c(e),s(!1)}).catch(a)},[h]);const u=(0,z.YQ)(t=>{q({selected:e,search:t}).then(e=>{c(e),s(!1)}).catch(a)},400),p=(0,d.useCallback)(e=>{s(!0),u(e)},[s,u]);return(0,m.jsx)(se,{...t,selected:e,error:i,products:n,isLoading:r,onSearch:l?p:null})}),ee=e=>{const{attributes:t,setAttributes:r}=e,{columns:s,contentVisibility:o,orderby:n,alignButtons:c}=t;return(0,m.jsxs)(l.InspectorControls,{children:[(0,m.jsxs)(a.PanelBody,{title:(0,h.__)("Layout","woocommerce"),initialOpen:!0,children:[(0,m.jsx)(a.RangeControl,{label:(0,h.__)("Columns","woocommerce"),value:s,onChange:e=>r({columns:e}),min:(0,i.getSetting)("minColumns",1),max:(0,i.getSetting)("maxColumns",6)}),(0,m.jsx)(a.ToggleControl,{label:(0,h.__)("Align Buttons","woocommerce"),help:c?(0,h.__)("Buttons are aligned vertically.","woocommerce"):(0,h.__)("Buttons follow content.","woocommerce"),checked:c,onChange:()=>r({alignButtons:!c})})]}),(0,m.jsx)(a.PanelBody,{title:(0,h.__)("Content","woocommerce"),initialOpen:!0,children:(0,m.jsx)(u,{settings:o,onChange:e=>r({contentVisibility:e})})}),(0,m.jsx)(a.PanelBody,{title:(0,h.__)("Order By","woocommerce"),initialOpen:!1,children:(0,m.jsx)(p,{setAttributes:r,value:n})}),(0,m.jsx)(a.PanelBody,{title:(0,h.__)("Products","woocommerce"),initialOpen:!1,children:(0,m.jsx)(Z,{selected:t.products,onChange:(e=[])=>{const t=e.map(({id:e})=>e);r({products:t})},isCompact:!0})})]},"inspector")},te=e=>{const{attributes:t,setAttributes:r,debouncedSpeak:s,isEditing:i,setIsEditing:c}=e;return(0,m.jsxs)(a.Placeholder,{icon:(0,m.jsx)(o.A,{icon:n.A}),label:(0,h.__)("Hand-picked Products","woocommerce"),className:"wc-block-products-grid wc-block-handpicked-products",children:[(0,h.__)("Display a selection of hand-picked products in a grid.","woocommerce"),(0,m.jsxs)("div",{className:"wc-block-handpicked-products__selection",children:[(0,m.jsx)(Z,{selected:t.products,onChange:(e=[])=>{const t=e.map(({id:e})=>e);r({products:t})}}),(0,m.jsx)(a.Button,{variant:"primary",onClick:()=>{c(!i),s((0,h.__)("Now displaying a preview of the Hand-picked Products block.","woocommerce"))},children:(0,h.__)("Done","woocommerce")})]})]})},re=window.wp.serverSideRender;var se,ie=r.n(re);const oe=(0,m.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"},children:[(0,m.jsx)("title",{children:"Grid Block Preview"}),(0,m.jsx)("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,m.jsx)("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,m.jsx)("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,m.jsx)("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,m.jsx)("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,m.jsx)("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,m.jsx)("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,m.jsx)("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,m.jsx)("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,m.jsx)("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,m.jsx)("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,m.jsx)("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"221.798",fill:"#E1E3E6",rx:"3"})]}),ne=e=>{const{attributes:t,name:r}=e;return t.isPreview?oe:(0,m.jsx)(ie(),{block:r,attributes:t})},ce=(0,a.withSpokenMessages)(e=>{const t=(0,l.useBlockProps)(),{attributes:{products:r}}=e,[s,i]=(0,d.useState)(!r.length);return(0,m.jsxs)("div",{...t,children:[(0,m.jsx)(l.BlockControls,{children:(0,m.jsx)(a.ToolbarGroup,{controls:[{icon:"edit",title:(0,h.__)("Edit selected products","woocommerce"),onClick:()=>i(!s),isActive:s}]})}),(0,m.jsx)(ee,{...e}),s?(0,m.jsx)(te,{isEditing:s,setIsEditing:i,...e}):(0,m.jsx)(a.Disabled,{children:(0,m.jsx)(ne,{...e})})]})});(0,s.registerBlockType)(c,{icon:{src:(0,m.jsx)(o.A,{icon:n.A,className:"wc-block-editor-components-block-icon"})},attributes:{...c.attributes,columns:{type:"number",default:(0,i.getSetting)("defaultColumns",3)}},edit:ce,save:()=>null})},9202:()=>{},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}},i={};function o(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return s[e](r,r.exports,o),r.exports}o.m=s,e=[],o.O=(t,r,s,i)=>{if(!r){var n=1/0;for(d=0;d<e.length;d++){for(var[r,s,i]=e[d],c=!0,l=0;l<r.length;l++)(!1&i||n>=i)&&Object.keys(o.O).every(e=>o.O[e](r[l]))?r.splice(l--,1):(c=!1,i<n&&(n=i));if(c){e.splice(d--,1);var a=s();void 0!==a&&(t=a)}}return t}i=i||0;for(var d=e.length;d>0&&e[d-1][2]>i;d--)e[d]=e[d-1];e[d]=[r,s,i]},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.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 i=Object.create(null);o.r(i);var n={};t=t||[null,r({}),r([]),r(r)];for(var c=2&s&&e;"object"==typeof c&&!~t.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach(t=>n[t]=()=>e[t]);return n.default=()=>e,o.d(i,n),i},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.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),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=6461,(()=>{var e={6461:0};o.O.j=t=>0===e[t];var t=(t,r)=>{var s,i,[n,c,l]=r,a=0;if(n.some(t=>0!==e[t])){for(s in c)o.o(c,s)&&(o.m[s]=c[s]);if(l)var d=l(o)}for(t&&t(r);a<n.length;a++)i=n[a],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return o.O(d)},r=globalThis.webpackChunkwebpackWcBlocksMainJsonp=globalThis.webpackChunkwebpackWcBlocksMainJsonp||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var n=o.O(void 0,[94],()=>o(98344));n=o.O(n),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["handpicked-products"]=n})();
Save File
Cancel