geno/wp-content/plugins/woocommerce/packages/woocommerce-blocks/build/product-template.js

1 line
5.8 KiB
JavaScript
Raw Permalink Normal View History

2024-02-01 17:24:18 +05:30
(()=>{var e,t={6012:(e,t,o)=>{"use strict";o.r(t);const r=window.wp.blocks,n=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"woocommerce/product-template","title":"Product Template","category":"woocommerce","description":"Contains the block elements used to render a product.","keywords":["WooCommerce"],"textdomain":"woocommerce","usesContext":["queryId","query","queryContext","displayLayout","templateSlug"],"supports":{"inserter":false,"reusable":false,"html":false,"align":["wide","full"],"anchor":true,"__experimentalLayout":{"allowEditing":false},"color":{"gradients":true,"link":true,"__experimentalDefaultControls":{"background":true,"text":true}},"typography":{"fontSize":true,"lineHeight":true,"__experimentalFontFamily":true,"__experimentalFontWeight":true,"__experimentalFontStyle":true,"__experimentalTextTransform":true,"__experimentalTextDecoration":true,"__experimentalLetterSpacing":true,"__experimentalDefaultControls":{"fontSize":true}}}}');var l=o(9196),s=o(4184),c=o.n(s),a=o(9307);const i=window.wp.data;var p=o(5736);const u=window.wp.blockEditor,d=window.wp.components,m=window.wp.coreData,w=window.wc.wcSettings,g=e=>"number"==typeof e,b=()=>{const e=(0,u.useInnerBlocksProps)({className:"wc-block-product"},{__unstableDisableLayoutClassNames:!0});return(0,l.createElement)("li",{...e})},y=(0,a.memo)((({blocks:e,blockContextId:t,isHidden:o,setActiveBlockContextId:r})=>{const n=(0,u.__experimentalUseBlockPreview)({blocks:e,props:{className:"wc-block-product"}}),s=()=>{r(t)},c={display:o?"none":void 0};return(0,l.createElement)("li",{...n,tabIndex:0,role:"button",onClick:s,onKeyPress:s,style:c})}));o(5500),(0,r.registerBlockType)(n,{icon:()=>(0,l.createElement)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,l.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 4H18C19.1046 4 20 4.89543 20 6V18C20 19.1046 19.1046 20 18 20H6C4.89543 20 4 19.1046 4 18V6C4 4.89543 4.89543 4 6 4ZM18 5.5H6C5.72386 5.5 5.5 5.72386 5.5 6V9H18.5V6C18.5 5.72386 18.2761 5.5 18 5.5ZM18.5 10.5H10L10 18.5H18C18.2761 18.5 18.5 18.2761 18.5 18V10.5ZM8.5 10.5H5.5V18C5.5 18.2761 5.72386 18.5 6 18.5H8.5L8.5 10.5Z",fill:"#1E1E1E"})),edit:({clientId:e,context:{query:{perPage:t,offset:o=0,order:r,orderBy:n,search:s,exclude:v,inherit:f,taxQuery:k,pages:x,..._},queryContext:h=[{page:1}],templateSlug:C,displayLayout:{type:E,columns:S,shrinkColumns:O}={type:"flex",columns:3,shrinkColumns:!1}},__unstableLayoutClassNames:I})=>{const[{page:B}]=h,[P,j]=(0,a.useState)(),H="product",T=(0,w.getSettingWithCoercion)("loopShopPerPage",12,g),{products:L,blocks:M}=(0,i.useSelect)((l=>{const{getEntityRecords:c,getTaxonomies:a}=l(m.store),{getBlocks:i}=l(u.store),p=a({type:H,per_page:-1,context:"view"}),d=f&&(null==C?void 0:C.startsWith("category-"))&&c("taxonomy","category",{context:"view",per_page:1,_fields:["id"],slug:C.replace("category-","")}),w={postType:H,offset:t?t*(B-1)+o:0,order:r,orderby:n};if(k&&!f){const e=Object.entries(k).reduce(((e,[t,o])=>{const r=null==p?void 0:p.find((({slug:e})=>e===t));return null!=r&&r.rest_base&&(e[null==r?void 0:r.rest_base]=o),e}),{});Object.keys(e).length&&Object.assign(w,e)}var g;(t&&(w.per_page=t),s&&(w.search=s),null!=v&&v.length&&(w.exclude=v),f)&&(d&&(w.categories=null===(g=d[0])||void 0===g?void 0:g.id),w.per_page=T);return{products:c("postType",H,{...w,..._}),blocks:i(e)}}),[t,B,o,r,n,e,s,H,v,f,C,k,_]),N=(0,a.useMemo)((()=>null==L?void 0:L.map((e=>({postType:e.type,postId:e.id})))),[L]);let V="";"flex"===E&&S>1&&(V=O?`wc-block-product-template__responsive columns-${S}`:`is-flex-container columns-${S}`);const W=(0,u.useBlockProps)({className:c()(I,"wc-block-product-template",V)});return L?L.length?(0,l.createElement)("ul",{...W},N&&N.map((e=>{var t,o;return(0,l.createElement)(u.BlockContextProvider,{key:e.postId,value:e},e.postId===(P||(null===(t=N[0])||void 0===t?void 0:t.postId))?(0,l.createElement)(b,null):null,(0,l.createElement)(y,{blocks:M,blockContextId:e.postId,setActiveBlockContextId:j,isHidden:e.postId===(P|