PluginProbe
WooCommerce / 11.1.0-beta.2
WooCommerce v11.1.0-beta.2
11.1.0 11.1.0-rc.2 11.1.0-rc.1 11.1.0-beta.2 11.1.0-beta.1 11.0.1 11.0.0 11.0.0-rc.3 11.0.0-rc.2 11.0.0-rc.1 11.0.0-beta.2 11.0.0-beta.1 10.9.4 10.9.3 10.9.2 10.9.1 10.9.0 10.9.0-rc.1 10.9.0-beta.2 10.9.0-beta.1 10.8.1 10.8.0 10.8.0-rc.1 10.8.0-beta.2 10.8.0-beta.1 All 648 releases
woocommerce / assets / client / blocks / product-image.js
product-image.js
4 lines 7.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (globalThis.webpackChunkwebpackWcBlocksMainJsonp=globalThis.webpackChunkwebpackWcBlocksMainJsonp||[]).push([[4232,4442],{3129:(e,t,o)=>{"use strict";o.d(t,{A:()=>w});var s=o(6087),a=o(7723),c=o(4921),r=o(5703),i=o(415),n=o(5076),l=o(1616),d=o(2269),u=o(8537),m=o(3993),p=o(4927),g=(o(1189),o(4903)),h=o(790);const y=e=>{const{aspectRatio:t,height:o,width:s,scale:a}=e;return{height:o,width:s,objectFit:a,aspectRatio:t}},f=e=>{const t=(0,r.getSetting)("placeholderImgSrcFullSize",r.PLACEHOLDER_IMG_SRC);return(0,h.jsx)("img",{...e,src:t,alt:"",width:void 0,height:void 0})},b=({image:e,loaded:t,fallbackAlt:o,width:s,scale:a,height:c,aspectRatio:r})=>{const{src:i,srcset:n,sizes:l,alt:d}=e||{},u={alt:d||o,hidden:!t,src:i,srcSet:n,sizes:l},m=y({height:c,width:s,scale:a,aspectRatio:r});return e?(0,h.jsx)("img",{style:m,"data-testid":"product-image",...u}):(0,h.jsx)(f,{style:m})},k=e=>{const{product:t}=e;return!(0,m.isEmpty)(t)&&(0,g.S)(e.showSaleBadge)},w=(0,l.withProductDataContext)(e=>{const{aspectRatio:t,children:o,className:l,height:m,imageId:w,imageSizing:S,scale:x,showProductLink:v=!0,style:_,width:C,isAdmin:N,product:R,isResolving:A,...j}=e,B=(0,n.p)(e),{parentClassName:P}=(0,i.useInnerBlockLayoutContext)(),{product:z,isLoading:D}=(0,i.useProductDataContext)({isAdmin:N,product:R,isResolving:A}),{dispatchStoreEvent:L}=(0,d.y)(),O=(0,r.getSetting)("thumbnailAspectRatio",null),I=(0,g.O)(_,t,O,S),$=`wc-block-components-product-image--aspect-ratio-${I?I.replace("/","-"):"auto"}`;if(!z?.id){const e=y({height:m,width:C,scale:x,aspectRatio:I});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("div",{className:(0,c.A)(l,"wc-block-components-product-image",$,{[`${P}__product-image`]:P},B.className),style:B.style,children:(0,h.jsx)(f,{style:e})}),o]})}const E=((e,t)=>e.images.length?t&&e.images.find(e=>e.id===t)||e.images[0]:null)(z,w);E&&(E.alt=E.alt||(0,u.decodeEntities)(z.name));const F=v?"a":s.Fragment,T=z?.name?
2 // translators: %s is the product name.
3 // translators: %s is the product name.
4 (0,a.sprintf)((0,a.__)("Link to %s","woocommerce"),z.name):"",H={href:v?z?.permalink:void 0,...v&&{"aria-label":T,onClick:()=>{L("product-view-link",{product:z})}}};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:(0,c.A)(l,"wc-block-components-product-image",$,{[`${P}__product-image`]:P},B.className),style:B.style,children:[k(e)&&(0,h.jsx)(p.default,{align:e.saleBadgeAlign||"right",...j}),(0,h.jsx)(F,{...!N&&v&&H,children:(0,h.jsx)(b,{fallbackAlt:(0,u.decodeEntities)(z.name),image:E,loaded:!D,width:C,height:m,scale:x,aspectRatio:I})})]}),o]})})},7156:(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>r});var s=o(1616),a=o(3129),c=o(7746);const r=(0,s.withFilteredAttributes)(c.attributes)(a.A)},1267:(e,t,o)=>{"use strict";o.d(t,{e:()=>s});let s=function(e){return e.SINGLE="single",e.THUMBNAIL="thumbnail",e.CROPPED="cropped",e}({})},4903:(e,t,o)=>{"use strict";o.d(t,{O:()=>c,S:()=>a});var s=o(1267);const a=e=>void 0===e||e,c=(e,t,o,a)=>e&&e.dimensions&&e.dimensions.aspectRatio&&"string"==typeof e.dimensions.aspectRatio?e.dimensions.aspectRatio:t&&"string"==typeof t?t:!a||a!==s.e.THUMBNAIL&&a!==s.e.CROPPED?void 0:o??void 0},4927:(e,t,o)=>{"use strict";o.r(t),o.d(t,{Block:()=>d,default:()=>u});var s=o(7723),a=o(4921),c=o(4656),r=o(415),i=o(5076),n=o(1616),l=(o(4313),o(790));const d=e=>{const{className:t,align:o,isDescendentOfSingleProductTemplate:n}=e,d=(0,i.p)(e),{parentClassName:u}=(0,r.useInnerBlockLayoutContext)(),{product:m}=(0,r.useProductDataContext)();if(!(m.id&&m.on_sale||n))return null;const p="string"==typeof o?`wc-block-components-product-sale-badge--align-${o}`:"";return(0,l.jsx)("div",{className:(0,a.A)("wc-block-components-product-sale-badge",t,p,{[`${u}__product-onsale`]:u},d.className),style:d.style,children:(0,l.jsx)(c.Label,{label:(0,s.__)("Sale","woocommerce"),screenReaderLabel:(0,s.__)("Product on sale","woocommerce")})})},u=(0,n.withProductDataContext)(d)},2269:(e,t,o)=>{"use strict";o.d(t,{y:()=>r});var s=o(2619),a=o(7143),c=o(6087);const r=()=>({dispatchStoreEvent:(0,c.useCallback)((e,t={})=>{try{(0,s.doAction)(`experimental__woocommerce_blocks-${e}`,t)}catch(e){console.error(e)}},[]),dispatchCheckoutEvent:(0,c.useCallback)((e,t={})=>{try{(0,s.doAction)(`experimental__woocommerce_blocks-checkout-${e}`,{...t,storeCart:(0,a.select)("wc/store/cart").getCartData()})}catch(e){console.error(e)}},[])})},5076:(e,t,o)=>{"use strict";o.d(t,{p:()=>i});var s=o(4921),a=o(3993),c=o(8270),r=o(5154);const i=e=>{const t=(e=>{const t=(0,a.isObject)(e)?e:{style:{}};let o=t.style;return(0,a.isString)(o)&&(o=JSON.parse(o)||{}),(0,a.isObject)(o)||(o={}),{...t,style:o}})(e),o=(0,r.BK)(t),i=(0,r.aR)(t),n=(0,r.fo)(t),l=(0,c.x)(t);return{className:(0,s.A)(l.className,o.className,i.className,n.className),style:{...l.style,...o.style,...i.style,...n.style}}}},8270:(e,t,o)=>{"use strict";o.d(t,{x:()=>a});var s=o(3993);const a=e=>{const t=(0,s.isObject)(e.style.typography)?e.style.typography:{},o=(0,s.isString)(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}}}},5154:(e,t,o)=>{"use strict";o.d(t,{BK:()=>l,aR:()=>d,fo:()=>u});var s=o(4921),a=o(7356),c=o(9786),r=o(3993);function i(e={}){const t={};return(0,c.getCSSRules)(e,{selector:""}).forEach(e=>{t[e.key]=e.value}),t}function n(e,t){return e&&t?`has-${(0,a.c)(t)}-${e}`:""}function l(e){const{backgroundColor:t,textColor:o,gradient:a,style:c}=e,l=n("background-color",t),d=n("color",o),u=function(e){if(e)return`has-${e}-gradient-background`}(a),m=u||c?.color?.gradient;return{className:(0,s.A)(d,u,{[l]:!m&&!!l,"has-text-color":o||c?.color?.text,"has-background":t||c?.color?.background||a||c?.color?.gradient,"has-link-color":(0,r.isObject)(c?.elements?.link)?c?.elements?.link?.color:void 0}),style:i({color:c?.color||{}})}}function d(e){const t=e.style?.border||{};return{className:function(e){const{borderColor:t,style:o}=e,a=t?n("border-color",t):"";return(0,s.A)({"has-border-color":!!t||!!o?.border?.color,[a]:!!a})}(e),style:i({border:t})}}function u(e){return{className:void 0,style:i({spacing:e.style?.spacing||{}})}}},1189:()=>{},4313:()=>{},7746:e=>{"use strict";e.exports=JSON.parse('{"name":"woocommerce/product-image","title":"Product Image","description":"Display the main product image.","category":"woocommerce-product-elements","attributes":{"showProductLink":{"type":"boolean","default":true},"showSaleBadge":{"type":"boolean","default":true},"saleBadgeAlign":{"type":"string","default":"right"},"imageSizing":{"type":"string","default":"single"},"productId":{"type":"number","default":0},"isDescendentOfQueryLoop":{"type":"boolean","default":false},"isDescendentOfSingleProductBlock":{"type":"boolean","default":false},"width":{"type":"string"},"height":{"type":"string"},"scale":{"type":"string","default":"cover"},"aspectRatio":{"type":"string"}},"supports":{"interactivity":{"clientNavigation":true},"html":false,"__experimentalBorder":{"radius":true,"__experimentalSkipSerialization":true},"typography":{"fontSize":true,"__experimentalSkipSerialization":true},"spacing":{"margin":true,"padding":true},"dimensions":{"aspectRatio":true,"__experimentalSkipSerialization":true},"email":true},"selectors":{"root":".wp-block-woocommerce-product-image.wc-block-components-product-image, .wp-block-woocommerce-product-image .wc-block-components-product-image"},"ancestor":["woocommerce/all-products","woocommerce/single-product","woocommerce/product-template","core/post-template"],"usesContext":["imageId","postId","query","queryId"],"keywords":["WooCommerce"],"textdomain":"woocommerce","apiVersion":3,"$schema":"https://schemas.wp.org/trunk/block.json"}')}}]);