woocommerce/packages/woocommerce-blocks/build/atomic-block-components/image.js
2021-12-10 12:03:04 +00:00

3 lines
2.9 KiB
JavaScript

(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[11],{374:function(e,t,c){"use strict";t.a={showProductLink:{type:"boolean",default:!0},showSaleBadge:{type:"boolean",default:!0},saleBadgeAlign:{type:"string",default:"right"},imageSizing:{type:"string",default:"full-size"},productId:{type:"number",default:0}}},375:function(e,t,c){"use strict";var n=c(9),r=c.n(n),a=c(5),o=c.n(a),l=c(8),i=c.n(l),s=c(0),u=(c(2),c(1)),d=c(6),p=c.n(d),b=c(3),m=c(45),g=c(86),f=c(68),O=c(304);function j(e,t){var c=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),c.push.apply(c,n)}return c}function w(e){for(var t=1;t<arguments.length;t++){var c=null!=arguments[t]?arguments[t]:{};t%2?j(Object(c),!0).forEach((function(t){o()(e,t,c[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(c)):j(Object(c)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(c,t))}))}return e}c(558);var h=function(){return Object(s.createElement)("img",{src:b.PLACEHOLDER_IMG_SRC,alt:"",width:500,height:500})},k=function(e){var t=e.image,c=e.onLoad,n=e.loaded,a=e.showFullSize,o=e.fallbackAlt,l=t||{},i=l.thumbnail,u=l.src,d=l.srcset,p=l.sizes,b=w({alt:l.alt||o,onLoad:c,hidden:!n,src:i},a&&{src:u,srcSet:d,sizes:p});return Object(s.createElement)(s.Fragment,null,b.src&&Object(s.createElement)("img",r()({"data-testid":"product-image"},b)),!n&&Object(s.createElement)(h,null))};t.a=Object(g.withProductDataContext)((function(e){var t=e.className,c=e.imageSizing,n=void 0===c?"full-size":c,r=e.showProductLink,a=void 0===r||r,l=e.showSaleBadge,d=e.saleBadgeAlign,b=void 0===d?"right":d,g=Object(m.useInnerBlockLayoutContext)().parentClassName,j=Object(m.useProductDataContext)().product,v=Object(s.useState)(!1),y=i()(v,2),E=y[0],P=y[1],S=Object(f.a)().dispatchStoreEvent;if(!j.id)return Object(s.createElement)("div",{className:p()(t,"wc-block-components-product-image","wc-block-components-product-image--placeholder",o()({},"".concat(g,"__product-image"),g))},Object(s.createElement)(h,null));var L=!!j.images.length,z=L?j.images[0]:null,_=a?"a":s.Fragment,B=Object(u.sprintf)(
/* translators: %s is referring to the product name */
Object(u.__)("Link to %s",'woocommerce'),j.name),C=w(w({href:j.permalink,rel:"nofollow"},!L&&{"aria-label":B}),{},{onClick:function(){S("product-view-link",{product:j})}});return Object(s.createElement)("div",{className:p()(t,"wc-block-components-product-image",o()({},"".concat(g,"__product-image"),g))},Object(s.createElement)(_,a&&C,!!l&&Object(s.createElement)(O.default,{align:b,product:j}),Object(s.createElement)(k,{fallbackAlt:j.name,image:z,onLoad:function(){return P(!0)},loaded:E,showFullSize:"cropped"!==n})))}))},558:function(e,t){},901:function(e,t,c){"use strict";c.r(t);var n=c(900),r=c(375),a=c(374);t.default=Object(n.a)(a.a)(r.a)}}]);