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

2 lines
6.4 KiB
JavaScript
Raw Normal View History

2024-02-01 17:24:18 +05:30
(self.webpackChunkwebpackWcBlocksJsonp=self.webpackChunkwebpackWcBlocksJsonp||[]).push([[3706,5432],{9382:(e,t,o)=>{"use strict";o.d(t,{Z:()=>l});const l={showProductLink:{type:"boolean",default:!0},showSaleBadge:{type:"boolean",default:!0},saleBadgeAlign:{type:"string",default:"right"},imageSizing:{type:"string",default:o(9252).R.SINGLE},productId:{type:"number",default:0},isDescendentOfQueryLoop:{type:"boolean",default:!1},isDescendentOfSingleProductBlock:{type:"boolean",default:!1},width:{type:"string"},height:{type:"string"},scale:{type:"string",default:"cover"},aspectRatio:{type:"string"}}},1492:(e,t,o)=>{"use strict";o.d(t,{Z:()=>f});var l=o(9196),n=o(9307),s=o(5736),a=o(4184),c=o.n(a),r=o(4617),i=o(2864),u=o(3611),d=o(721),g=o(5918),m=o(4498),p=(o(8854),o(9252));const h=e=>(0,l.createElement)("img",{...e,src:r.PLACEHOLDER_IMG_SRC,alt:"",width:void 0,height:void 0}),y=({image:e,loaded:t,showFullSize:o,fallbackAlt:s,width:a,scale:c,height:r,aspectRatio:i})=>{const{thumbnail:u,src:d,srcset:g,sizes:m,alt:p}=e||{},y={alt:p||s,hidden:!t,src:u,...o&&{src:d,srcSet:g,sizes:m}},f={height:r,width:a,objectFit:c,aspectRatio:i};return(0,l.createElement)(n.Fragment,null,y.src&&(0,l.createElement)("img",{style:f,"data-testid":"product-image",...y}),!e&&(0,l.createElement)(h,{style:f}))},f=(0,d.withProductDataContext)((e=>{const{className:t,imageSizing:o=p.R.SINGLE,showProductLink:a=!0,showSaleBadge:r,saleBadgeAlign:d="right",height:f,width:b,scale:v,aspectRatio:k,...w}=e,S=(0,u.F)(e),{parentClassName:N}=(0,i.useInnerBlockLayoutContext)(),{product:C,isLoading:_}=(0,i.useProductDataContext)(),{dispatchStoreEvent:E}=(0,g.n)();if(!C.id)return(0,l.createElement)("div",{className:c()(t,"wc-block-components-product-image",{[`${N}__product-image`]:N},S.className),style:S.style},(0,l.createElement)(h,null));const x=!!C.images.length,F=x?C.images[0]:null,L=a?"a":n.Fragment,R=(0,s.sprintf)(/* translators: %s is referring to the product name */
(0,s.__)("Link to %s","woocommerce"),C.name),$={href:C.permalink,...!x&&{"aria-label":R},onClick:()=>{E("product-view-link",{product:C})}};return(0,l.createElement)("div",{className:c()(t,"wc-block-components-product-image",{[`${N}__product-image`]:N},S.className),style:S.style},(0,l.createElement)(L,{...a&&$},!!r&&(0,l.createElement)(m.default,{align:d,...w}),(0,l.createElement)(y,{fallbackAlt:C.name,image:F,loaded:!_,showFullSize:o!==p.R.THUMBNAIL,width:b,height:f,scale:v,aspectRatio:k})))}))},2097:(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>a});var l=o(721),n=o(1492),s=o(9382);const a=(0,l.withFilteredAttributes)(s.Z)(n.Z)},4498:(e,t,o)=>{"use strict";o.r(t),o.d(t,{Block:()=>d,default:()=>g});var l=o(9196),n=o(5736),s=o(4184),a=o.n(s),c=o(711),r=o(2864),i=o(3611),u=o(721);o(1314);const d=e=>{const{className:t,align:o}=e,s=(0,i.F)(e),{parentClassName:u}=(0,r.useInnerBlockLayoutContext)(),{product:d}=(0,r.useProductDataContext)();if(!(d.id&&d.on_sale||e.isDescendentOfSingleProductTemplate))return null;const g="string"==typeof o?`wc-block-components-product-sale-badge--align-${o}`:"";return(0,l.createElement)("div",{className:a()("wc-block-components-product-sale-badge",t,g,{[`${u}__product-onsale`]:u},s.className),style:s.style},(0,l.createElement)(c.Label,{label:(0,n.__)("Sale","woocommerce"),screenReaderLabel:(0,n.__)("Product on sale","woocommerce")}))},g=(0,u.withProductDataContext)(d)},5918:(e,t,o)=>{"use strict";o.d(t,{n:()=>a});var l=o(2694),n=o(9818),s=o(9307);const a=()=>({dispatchStoreEvent:(0,s.useCallback)(((e,t={})=>{try{(0,l.doAction)(`experimental__woocommerce_blocks-${e}`,t)}catch(e){console.error(e)}}),[]),dispatchCheckoutEvent:(0,s.useCallback)(((e,t={})=>{try{(0,l.doAction)(`experimental__woocommerce_blocks-checkout-${e}`,{...t,storeCart:(0,n.select)("wc/store/cart").getCartData()})}catch(e){console.error(e)}}),[])})},3611:(e,t,o)=>{"use strict";o.d(t,{F:()=>i});var l=o(4184),n=o.n(l),s=o(7884),a=o(2646),c=o(1473),r=o(2661);const i=e=>{const t=(e=>{const t=(0,s.Kn)(e)?e:{style:{}};let o=t.style;return(0,a.H)(o)&&(o=JSON.parse(o)||{}),(0,s.Kn)(o)||(o={}),{...t,style:o}})(e),o=(0,r.vc)(t),l=(0,r.l8)(t),i=(0,r.su)(t),u=(0,c.f)(t);return{className:n()(u.className,o.className,l.className,i.className),style:{...u.style,...o.style,...l.style,...i.style}}}},1473:(e,t,o)=>{"use strict";o.d(t,{f:()=>s});var l=o(7884),n=o(2646);const s=e=>{const t=(0,l.Kn)(e.style.typography)?e.style.typography:{},o=(0,n.H)(t.fontFamily)?t.fontFamily:"";return{className:e.fontFamily?`has-${e.fontFamily}-font-family`:o,style:{fontSize:e.fontSize?`var(--wp--preset--font-size--${e.fontSize})`:t.fontSize,fontStyle:t.fontStyle,fontWeight:t.fontWeight,letterSpacing:t.letterSpacing,lineHeight:t.lineHeight,textDecoration:t.textDecoration,textTransform:t.textTransform}}}},2661:(e,t,o)=>{"use strict";o.d(t,{l8:()=>d,su:()=>g,vc:()=>u});var l=o(4184),n=o.n(l),s=o(9784),a=o(2289),c=o(7884);function r(e={}){const t={};return(0,a.getCSSRules)(e,{selector:""}).forEach((e=>{t[e.key]=e.value})),t}function i(e,t){return e&&t?`has-${(0,s.o)(t)}-${e}`:""}function u(e){var t,o,l,s,a,u,d;const{backgroundColor:g,textColor:m,gradient:p,style:h}=e,y=i("background-color",g),f=i("color",m),b=function(e){if(e)return`has-${e}-gradient-background`}(p),v=b||(null==h||null===(t=h.color)||void 0===t?void 0:t.gradient);return{className:n()(f,b,{[y]:!v&&!!y,"has-text-color":m||(null==h||null===(o=h.color)||void 0===o?void 0:o.text),"has-background":g||(null==h||null===(l=h.color)||void 0===l?void 0:l.background)||p||(null==h||null===(s=h.color)||void 0===s?void 0:s.gradient),"has-link-color":(0,c.Kn)(null==h||null===(a=h.elements)||void 0===a?void 0:a.link)?null==h||null===(u=h.elements)||void 0===u||null===(d=u.link)||void 0===d?void 0:d.color:void 0}),style:r({color:(null==h?void 0:h.color)||{}})}}function d(e){var t;const o=(null===(t=e.style)||void 0===t?void 0:t.border)||{};return{className:function(e){var t;const{borderColor:o,style:l}=e,s=o?i("border-color",o):"";return n()({"has-border-color":!!o||!(null==l||null===(t=l.border)||void 0===t||!t.color