geno/wp-content/plugins/woocommerce/packages/woocommerce-blocks/build/checkout-blocks/order-summary-cart-items-frontend.js

5 lines
20 KiB
JavaScript
Raw Normal View History

2024-02-01 17:24:18 +05:30
(self.webpackChunkwebpackWcBlocksJsonp=self.webpackChunkwebpackWcBlocksJsonp||[]).push([[834],{3681:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>oe});var n=r(9196),o=r(5736),a=r(1445),c=r(711),i=r(4184),s=r.n(i),u=r(4293),l=r(9307);r(5138);const m=({currency:e,maxPrice:t,minPrice:r,priceClassName:a,priceStyle:i={}})=>(0,n.createElement)(n.Fragment,null,(0,n.createElement)("span",{className:"screen-reader-text"},(0,o.sprintf)(/* translators: %1$s min price, %2$s max price */
(0,o.__)("Price between %1$s and %2$s","woocommerce"),(0,u.formatPrice)(r),(0,u.formatPrice)(t))),(0,n.createElement)("span",{"aria-hidden":!0},(0,n.createElement)(c.FormattedMonetaryAmount,{className:s()("wc-block-components-product-price__value",a),currency:e,value:r,style:i})," — ",(0,n.createElement)(c.FormattedMonetaryAmount,{className:s()("wc-block-components-product-price__value",a),currency:e,value:t,style:i}))),p=({currency:e,regularPriceClassName:t,regularPriceStyle:r,regularPrice:a,priceClassName:i,priceStyle:u,price:l})=>(0,n.createElement)(n.Fragment,null,(0,n.createElement)("span",{className:"screen-reader-text"},(0,o.__)("Previous price:","woocommerce")),(0,n.createElement)(c.FormattedMonetaryAmount,{currency:e,renderText:e=>(0,n.createElement)("del",{className:s()("wc-block-components-product-price__regular",t),style:r},e),value:a}),(0,n.createElement)("span",{className:"screen-reader-text"},(0,o.__)("Discounted price:","woocommerce")),(0,n.createElement)(c.FormattedMonetaryAmount,{currency:e,renderText:e=>(0,n.createElement)("ins",{className:s()("wc-block-components-product-price__value","is-discounted",i),style:u},e),value:l})),d=({align:e,className:t,currency:r,format:o="<price/>",maxPrice:a,minPrice:i,price:u,priceClassName:d,priceStyle:g,regularPrice:f,regularPriceClassName:h,regularPriceStyle:y,style:v})=>{const b=s()(t,"price","wc-block-components-product-price",{[`wc-block-components-product-price--align-${e}`]:e});o.includes("<price/>")||(o="<price/>",console.error("Price formats need to include the `<price/>` tag."));const E=f&&u&&u<f;let _=(0,n.createElement)("span",{className:s()("wc-block-components-product-price__value",d)});return E?_=(0,n.createElement)(p,{currency:r,price:u,priceClassName:d,priceStyle:g,regularPrice:f,regularPriceClassName:h,regularPriceStyle:y}):void 0!==i&&void 0!==a?_=(0,n.createElement)(m,{currency:r,maxPrice:a,minPrice:i,priceClassName:d,priceStyle:g}):u&&(_=(0,n.createElement)(c.FormattedMonetaryAmount,{className:s()("wc-block-components-product-price__value",d),currency:r,value:u,style:g})),(0,n.createElement)("span",{className:b,style:v},(0,l.createInterpolateElement)(o,{price:_}))};var g=r(2629);r(5641);const f=({className:e="",disabled:t=!1,name:r,permalink:o="",target:a,rel:c,style:i,onClick:u,...l})=>{const m=s()("wc-block-components-product-name",e);if(t){const e=l;return(0,n.createElement)("span",{className:m,...e,dangerouslySetInnerHTML:{__html:(0,g.decodeEntities)(r)}})}return(0,n.createElement)("a",{className:m,href:o,target:a,...l,dangerouslySetInnerHTML:{__html:(0,g.decodeEntities)(r)},style:i})};var h=r(3554);function y(e){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y(e)}function v(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var E={normalizePrecision:function(e){var t=e.reduce((function(e,t){return Math.max(e.getPrecision(),t.getPrecision())}));return e.map((function(e){return e.getPrecision()!==t?e.convertPrecision(t):e}))},minimum:function(e){var t=v(e),r=t[0],n=t.slice(1),o=r;return n.forEach((function(e){o=o.lessThan(e)?o:e})),o},maximum:function(e){var t=v(e),r=t[0],n=t.slice(1),o=r;return n.forEach((function(e){o=o.greaterThan(e)?o:e})),o}};function _(e){return!isNaN(parseInt(e))&&isFinite(e)}function w(e){retu
(0,o.__)("%d left in stock","woocommerce"),e)):null;var U=function(){return U=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},U.apply(this,arguments)};function z(e){return e.toLowerCase()}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var W=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],Z=/[^A-Z0-9]+/gi;function q(e,t,r){return t instanceof RegExp?e.replace(t,r):t.reduce((function(e,t){return e.replace(t,r)}),e)}r(7984);const V=({details:e=[]})=>Array.isArray(e)?0===(e=e.filter((e=>!e.hidden))).length?null:(0,n.createElement)("ul",{className:"wc-block-components-product-details"},e.map((e=>{const t=(null==e?void 0:e.key)||e.name||"",r=(null==e?void 0:e.className)||(t?`wc-block-components-product-details__${o=t,void 0===a&&(a={}),function(e,t){return void 0===t&&(t={}),function(e,t){void 0===t&&(t={});for(var r=t.splitRegexp,n=void 0===r?W:r,o=t.stripRegexp,a=void 0===o?Z:o,c=t.transform,i=void 0===c?z:c,s=t.delimiter,u=void 0===s?" ":s,l=q(q(e,n,"$1\0$2"),a,"\0"),m=0,p=l.length;"\0"===l.charAt(m);)m++;for(;"\0"===l.charAt(p-1);)p--;return l.slice(m,p).split("\0").map(i).join(u)}(e,U({delimiter:"."},t))}(o,U({delimiter:"-"},a))}`:"");var o,a;return(0,n.createElement)("li",{key:t+(e.display||e.value),className:r},t&&(0,n.createElement)(n.Fragment,null,(0,n.createElement)("span",{className:"wc-block-components-product-details__name"},(0,g.decodeEntities)(t),":")," "),(0,n.createElement)("span",{className:"wc-block-components-product-details__value"},(0,g.decodeEntities)(e.display||e.value)))}))):null;var Y=r(987);const G=e=>e.replace(/<\/?[a-z][^>]*?>/gi,""),B=(e,t)=>e.replace(/[\s|\.\,]+$/i,"")+t;var J=r(5266);const X=({source:e,maxLength:t=15,countType:r="words",className:o="",style:a={}})=>{const c=(0,l.useMemo)((()=>((e,t=15,r="words")=>{const n=(0,Y.autop)(e);if((0,J.count)(n,r)<=t)return n;const o=(e=>{const t=e.indexOf("</p>");return-1===t?e:e.substr(0,t+4)})(n);return(0,J.count)(o,r)<=t?o:"words"===r?((e,t,r="&hellip;",n=!0)=>{const o=G(e),a=o.split(" ").splice(0,t).join(" ");return a===o?n?(0,Y.autop)(o):o:n?(0,Y.autop)(B(a,r)):B(a,r)})(o,t):((e,t,r=!0,n="&hellip;",o=!0)=>{const a=G(e),c=a.slice(0,t);if(c===a)return o?(0,Y.autop)(a):a;if(r)return(0,Y.autop)(B(c,n));const i=c.match(/([\s]+)/g),s=i?i.length:0,u=a.slice(0,t+s);return o?(0,Y.autop)(B(u,n)):B(u,n)})(o,t,"characters_including_spaces"===r)})(e,t,r)),[e,t,r]);return(0,n.createElement)(l.RawHTML,{style:a,className:o},c)};var K=r(5271);const Q=({className:e,shortDescription:t="",fullDescription:r=""})=>{const o=t||r;return o?(0,n.createElement)(X,{className:e,source:o,maxLength:15,countType:K.Cm.wordCountType||"words"}):null};r(9889);const ee=({shortDescription:e="",fullDescription:t="",itemData:r=[],variation:o=[]})=>(0,n.createElement)("div",{className:"wc-block-components-product-metadata"},(0,n.createElement)(Q,{className:"wc-block-components-product-metadata__description",shortDescription:e,fullDescription:t}),(0,n.createElement)(V,{details:r}),(0,n.createElement)(V,{details:o.map((({attribute:e="",value:t})=>({key:e,value:t})))})),te=e=>(0,h.mustContain)(e,"<price/>"),re=({cartItem:e})=>{const{images:t,low_stock_remaining:r,show_backorder_badge:a,name:i,permalink:m,prices:p,quantity:g,short_description:y,description:v,item_data:b,variation:E,totals:_,extensions:w}=e,{receiveCart:A,...N}=(0,I.b)(),k=(0,l.useMemo)((()=>({context:"summary",cartItem:e,cart:N})),[e,N]),P=(0,u.getCurrencyFromPriceResponse)(p),M=(0,h.applyCheckoutFilter)({filterName:"itemName",defaultValue:i,extensions:w,arg:k}),S=D({amount:parseInt(p.raw_prices.regular_price,10),precision:(0,T.H)(p.raw_prices.precision)?parseInt(p.raw_prices.precision,10):p.raw_prices.precision}).convertPrecision(P.minorUnit).getAmount(),C=D({amount:parseInt(p.raw_prices.price,10),precision:(0,T.H)(p.raw_prices.precision)?parseInt(p.raw_prices.precision,10):p.raw_prices.precision}).convertPrecision(P.minorUnit).getAmount(),O=(0,u.getCurrencyFromPriceResponse)(_);le
(0,o._n)("%d item","%d items",g,"woocommerce"),g)})),(0,n.createElement)($,{image:t.length?t[0]:{},fallbackAlt:M})),(0,n.createElement)("div",{className:"wc-block-components-order-summary-item__description"},(0,n.createElement)(f,{disabled:!0,name:M,permalink:m}),(0,n.createElement)(d,{currency:P,price:C,regularPrice:S,className:"wc-block-components-order-summary-item__individual-prices",priceClassName:"wc-block-components-order-summary-item__individual-price",regularPriceClassName:"wc-block-components-order-summary-item__regular-individual-price",format:L}),a?(0,n.createElement)(j,null):!!r&&(0,n.createElement)(H,{lowStockRemaining:r}),(0,n.createElement)(ee,{shortDescription:y,fullDescription:v,itemData:b,variation:E})),(0,n.createElement)("span",{className:"screen-reader-text"},(0,o.sprintf)(/* translators: %1$d is the number of items, %2$s is the item name and %3$s is the total price including the currency symbol. */
(0,o._n)("Total price for %1$d %2$s item: %3$s","Total price for %1$d %2$s items: %3$s",g,"woocommerce"),g,M,(0,u.formatPrice)(x,O))),(0,n.createElement)("div",{className:"wc-block-components-order-summary-item__total-price","aria-hidden":"true"},(0,n.createElement)(d,{currency:O,format:U,price:x})))};r(2911);const ne=({cartItems:e=[]})=>{const{isLarge:t,hasContainerWidth:r}=(0,a.N)();return r?(0,n.createElement)(c.Panel,{className:"wc-block-components-order-summary",initialOpen:t,hasBorder:!1,title:(0,n.createElement)("span",{className:"wc-block-components-order-summary__button-text"},(0,o.__)("Order summary","woocommerce"))},(0,n.createElement)("div",{className:"wc-block-components-order-summary__content"},e.map((e=>(0,n.createElement)(re,{key:e.key,cartItem:e}))))):null},oe=({className:e})=>{const{cartItems:t}=(0,I.b)();return(0,n.createElement)(c.TotalsWrapper,{className:e},(0,n.createElement)(ne,{cartItems:t}))}},2911:()=>{},6315:()=>{},7984:()=>{},9889:()=>{},5641:()=>{},5138:()=>{}}]);