product-price-frontend.js
6.15 KB
(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[72],{115:function(e,t,r){"use strict";var c=r(15),n=r.n(c),a=r(0),i=r(154),o=r(5),l=r.n(o);r(219);const s=e=>({thousandSeparator:e.thousandSeparator,decimalSeparator:e.decimalSeparator,decimalScale:e.minorUnit,fixedDecimalScale:!0,prefix:e.prefix,suffix:e.suffix,isNumericString:!0});t.a=e=>{let{className:t,value:r,currency:c,onValueChange:o,displayType:u="text",...p}=e;const m="string"==typeof r?parseInt(r,10):r;if(!Number.isFinite(m))return null;const b=m/10**c.minorUnit;if(!Number.isFinite(b))return null;const f=l()("wc-block-formatted-money-amount","wc-block-components-formatted-money-amount",t),d={...p,...s(c),value:void 0,currency:void 0,onValueChange:void 0},y=o?e=>{const t=+e.value*10**c.minorUnit;o(t)}:()=>{};return Object(a.createElement)(i.a,n()({className:f,displayType:u},d,{value:b,onValueChange:y}))}},116:function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r(51);var c=r(36);const n=()=>c.m>1},117:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var c=r(24),n=r(19);const a=e=>Object(c.a)(e)?JSON.parse(e)||{}:Object(n.a)(e)?e:{}},19:function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"b",(function(){return n}));const c=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;function n(e,t){return c(e)&&t in e}},219:function(e,t){},288:function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var c=r(63),n=r(116),a=r(19),i=r(117);const o=e=>{if(!Object(n.a)())return{className:"",style:{}};const t=Object(a.a)(e)?e:{},r=Object(i.a)(t.style);return Object(c.__experimentalUseColorProps)({...t,style:r})}},294:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var c=r(19),n=r(117);const a=e=>{const t=Object(c.a)(e)?e:{},r=Object(n.a)(t.style),a=Object(c.a)(r.typography)?r.typography:{};return{style:{fontSize:t.fontSize?`var(--wp--preset--font-size--${t.fontSize})`:a.fontSize,lineHeight:a.lineHeight,fontWeight:a.fontWeight,fontStyle:a.fontStyle,textTransform:a.textTransform,fontFamily:t.fontFamily}}}},299:function(e,t,r){"use strict";var c=r(0),n=r(1),a=r(115),i=r(5),o=r.n(i),l=r(42);r(300);const s=e=>{let{currency:t,maxPrice:r,minPrice:i,priceClassName:s,priceStyle:u={}}=e;return Object(c.createElement)(c.Fragment,null,Object(c.createElement)("span",{className:"screen-reader-text"},Object(n.sprintf)(
/* translators: %1$s min price, %2$s max price */
Object(n.__)("Price between %1$s and %2$s","woocommerce"),Object(l.formatPrice)(i),Object(l.formatPrice)(r))),Object(c.createElement)("span",{"aria-hidden":!0},Object(c.createElement)(a.a,{className:o()("wc-block-components-product-price__value",s),currency:t,value:i,style:u})," — ",Object(c.createElement)(a.a,{className:o()("wc-block-components-product-price__value",s),currency:t,value:r,style:u})))},u=e=>{let{currency:t,regularPriceClassName:r,regularPriceStyle:i,regularPrice:l,priceClassName:s,priceStyle:u,price:p}=e;return Object(c.createElement)(c.Fragment,null,Object(c.createElement)("span",{className:"screen-reader-text"},Object(n.__)("Previous price:","woocommerce")),Object(c.createElement)(a.a,{currency:t,renderText:e=>Object(c.createElement)("del",{className:o()("wc-block-components-product-price__regular",r),style:i},e),value:l}),Object(c.createElement)("span",{className:"screen-reader-text"},Object(n.__)("Discounted price:","woocommerce")),Object(c.createElement)(a.a,{currency:t,renderText:e=>Object(c.createElement)("ins",{className:o()("wc-block-components-product-price__value","is-discounted",s),style:u},e),value:p}))};t.a=e=>{let{align:t,className:r,currency:n,format:i="<price/>",maxPrice:l,minPrice:p,price:m,priceClassName:b,priceStyle:f,regularPrice:d,regularPriceClassName:y,regularPriceStyle:g}=e;const j=o()(r,"price","wc-block-components-product-price",{["wc-block-components-product-price--align-"+t]:t});i.includes("<price/>")||(i="<price/>",console.error("Price formats need to include the `<price/>` tag."));const O=d&&m!==d;let v=Object(c.createElement)("span",{className:o()("wc-block-components-product-price__value",b)});return O?v=Object(c.createElement)(u,{currency:n,price:m,priceClassName:b,priceStyle:f,regularPrice:d,regularPriceClassName:y,regularPriceStyle:g}):void 0!==p&&void 0!==l?v=Object(c.createElement)(s,{currency:n,maxPrice:l,minPrice:p,priceClassName:b,priceStyle:f}):m&&(v=Object(c.createElement)(a.a,{className:o()("wc-block-components-product-price__value",b),currency:n,value:m,style:f})),Object(c.createElement)("span",{className:j},Object(c.createInterpolateElement)(i,{price:v}))}},300:function(e,t){},335:function(e,t){},359:function(e,t,r){"use strict";r.r(t),r.d(t,"Block",(function(){return m}));var c=r(0),n=r(5),a=r.n(n),i=r(299),o=r(42),l=r(50),s=r(288),u=r(294),p=r(140);r(335);const m=e=>{var t,r;const{className:n,textAlign:p}=e,{parentClassName:m}=Object(l.useInnerBlockLayoutContext)(),{product:b}=Object(l.useProductDataContext)(),f=Object(s.a)(e),d=Object(u.a)(e),y=a()("wc-block-components-product-price",n,f.className,{[m+"__product-price"]:m}),g={...d.style,...f.style};if(!b.id)return Object(c.createElement)(i.a,{align:p,className:y});const j=b.prices,O=Object(o.getCurrencyFromPriceResponse)(j),v=j.price!==j.regular_price,_=a()({[m+"__product-price__value"]:m,[m+"__product-price__value--on-sale"]:v});return Object(c.createElement)(i.a,{align:p,className:y,priceStyle:g,regularPriceStyle:g,priceClassName:_,currency:O,price:j.price,minPrice:null==j||null===(t=j.price_range)||void 0===t?void 0:t.min_amount,maxPrice:null==j||null===(r=j.price_range)||void 0===r?void 0:r.max_amount,regularPrice:j.regular_price,regularPriceClassName:a()({[m+"__product-price__regular"]:m})})};t.default=Object(p.withProductDataContext)(m)},5:function(e,t,r){var c;!function(){"use strict";var r={}.hasOwnProperty;function n(){for(var e=[],t=0;t<arguments.length;t++){var c=arguments[t];if(c){var a=typeof c;if("string"===a||"number"===a)e.push(c);else if(Array.isArray(c)){if(c.length){var i=n.apply(null,c);i&&e.push(i)}}else if("object"===a)if(c.toString===Object.prototype.toString)for(var o in c)r.call(c,o)&&c[o]&&e.push(o);else e.push(c.toString())}}return e.join(" ")}e.exports?(n.default=n,e.exports=n):void 0===(c=function(){return n}.apply(t,[]))||(e.exports=c)}()}}]);