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

3 lines
5.9 KiB
JavaScript

(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[12],{124:function(e,r,c){"use strict";var t=c(5),a=c.n(t),n=c(0),o=c(1),l=c(53),i=c(6),s=c.n(i),u=(c(2),c(47)),p=(c(206),function(e){var r=e.currency,c=e.maxPrice,t=e.minPrice,a=e.priceClassName,i=e.priceStyle;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)("span",{className:"screen-reader-text"},Object(o.sprintf)(
/* translators: %1$s min price, %2$s max price */
Object(o.__)("Price between %1$s and %2$s",'woocommerce'),Object(u.formatPrice)(t),Object(u.formatPrice)(c))),Object(n.createElement)("span",{"aria-hidden":!0},Object(n.createElement)(l.a,{className:s()("wc-block-components-product-price__value",a),currency:r,value:t,style:i})," — ",Object(n.createElement)(l.a,{className:s()("wc-block-components-product-price__value",a),currency:r,value:c,style:i})))}),m=function(e){var r=e.currency,c=e.regularPriceClassName,t=e.regularPriceStyle,a=e.regularPrice,i=e.priceClassName,u=e.priceStyle,p=e.price;return Object(n.createElement)(n.Fragment,null,Object(n.createElement)("span",{className:"screen-reader-text"},Object(o.__)("Previous price:",'woocommerce')),Object(n.createElement)(l.a,{currency:r,renderText:function(e){return Object(n.createElement)("del",{className:s()("wc-block-components-product-price__regular",c),style:t},e)},value:a}),Object(n.createElement)("span",{className:"screen-reader-text"},Object(o.__)("Discounted price:",'woocommerce')),Object(n.createElement)(l.a,{currency:r,renderText:function(e){return Object(n.createElement)("ins",{className:s()("wc-block-components-product-price__value","is-discounted",i),style:u},e)},value:p}))};r.a=function(e){var r=e.align,c=e.className,t=e.currency,o=e.format,i=void 0===o?"<price/>":o,u=e.maxPrice,b=void 0===u?null:u,d=e.minPrice,O=void 0===d?null:d,f=e.price,j=void 0===f?null:f,y=e.priceClassName,g=e.priceStyle,v=e.regularPrice,_=e.regularPriceClassName,P=e.regularPriceStyle,N=s()(c,"price","wc-block-components-product-price",a()({},"wc-block-components-product-price--align-".concat(r),r));i.includes("<price/>")||(i="<price/>",console.error("Price formats need to include the `<price/>` tag."));var w=v&&j!==v,S=Object(n.createElement)("span",{className:s()("wc-block-components-product-price__value",y)});return w?S=Object(n.createElement)(m,{currency:t,price:j,priceClassName:y,priceStyle:g,regularPrice:v,regularPriceClassName:_,regularPriceStyle:P}):null!==O&&null!==b?S=Object(n.createElement)(p,{currency:t,maxPrice:b,minPrice:O,priceClassName:y,priceStyle:g}):null!==j&&(S=Object(n.createElement)(l.a,{className:s()("wc-block-components-product-price__value",y),currency:t,value:j,style:g})),Object(n.createElement)("span",{className:N},Object(n.createInterpolateElement)(i,{price:S}))}},175:function(e,r){},206:function(e,r){},482:function(e,r,c){"use strict";c.r(r);var t=c(5),a=c.n(t),n=c(0),o=(c(2),c(6)),l=c.n(o),i=c(124),s=c(47),u=c(45),p=c(12),m=c(159),b=c(86);r.default=Object(b.withProductDataContext)((function(e){var r,c,t,o,b,d,O,f=e.className,j=e.align,y=e.fontSize,g=e.customFontSize,v=e.saleFontSize,_=e.customSaleFontSize,P=e.color,N=e.customColor,w=e.saleColor,S=e.customSaleColor,C=Object(u.useInnerBlockLayoutContext)().parentClassName,E=Object(u.useProductDataContext)().product,x=l()(f,a()({},"".concat(C,"__product-price"),C));if(!E.id)return Object(n.createElement)(i.a,{align:j,className:x});var h=Object(p.getColorClassName)("color",P),k=Object(p.getFontSizeClass)(y),z=Object(p.getColorClassName)("color",w),F=Object(p.getFontSizeClass)(v),D=l()((r={"has-text-color":P||N,"has-font-size":y||g},a()(r,h,h),a()(r,k,k),r)),T=l()((c={"has-text-color":w||S,"has-font-size":v||_},a()(c,z,z),a()(c,F,F),c)),V={color:N,fontSize:g},B={color:S,fontSize:_},I=E.prices,U=Object(s.getCurrencyFromPriceResponse)(I),J=I.price!==I.regular_price,M=J?l()((t={},a()(t,"".concat(C,"__product-price__value"),C),a()(t,T,Object(m.b)()),t)):l()((o={},a()(o,"".concat(C,"__product-price__value"),C),a()(o,D,Object(m.b)()),o)),W=J?B:V;return Object(n.createElement)(i.a,{align:j,className:x,currency:U,price:I.price,priceClassName:M,priceStyle:Object(m.b)()?W:{},minPrice:null==I||null===(b=I.price_range)||void 0===b?void 0:b.min_amount,maxPrice:null==I||null===(d=I.price_range)||void 0===d?void 0:d.max_amount,regularPrice:I.regular_price,regularPriceClassName:l()((O={},a()(O,"".concat(C,"__product-price__regular"),C),a()(O,D,Object(m.b)()),O)),regularPriceStyle:Object(m.b)()?V:{}})}))},53:function(e,r,c){"use strict";var t=c(9),a=c.n(t),n=c(5),o=c.n(n),l=c(16),i=c.n(l),s=c(0),u=c(166),p=c(6),m=c.n(p),b=(c(175),["className","value","currency","onValueChange","displayType"]);function d(e,r){var c=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),c.push.apply(c,t)}return c}function O(e){for(var r=1;r<arguments.length;r++){var c=null!=arguments[r]?arguments[r]:{};r%2?d(Object(c),!0).forEach((function(r){o()(e,r,c[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(c)):d(Object(c)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(c,r))}))}return e}r.a=function(e){var r=e.className,c=e.value,t=e.currency,n=e.onValueChange,o=e.displayType,l=void 0===o?"text":o,p=i()(e,b),d="string"==typeof c?parseInt(c,10):c;if(!Number.isFinite(d))return null;var f=d/Math.pow(10,t.minorUnit);if(!Number.isFinite(f))return null;var j=m()("wc-block-formatted-money-amount","wc-block-components-formatted-money-amount",r),y=O(O(O({},p),function(e){return{thousandSeparator:e.thousandSeparator,decimalSeparator:e.decimalSeparator,decimalScale:e.minorUnit,fixedDecimalScale:!0,prefix:e.prefix,suffix:e.suffix,isNumericString:!0}}(t)),{},{value:void 0,currency:void 0,onValueChange:void 0}),g=n?function(e){var r=e.value*Math.pow(10,t.minorUnit);n(r)}:function(){};return Object(s.createElement)(u.a,a()({className:j,displayType:l},y,{value:f,onValueChange:g}))}}}]);